38#include <unordered_map>
41#include <wx/chartype.h>
56class NETLIST_OBJECT_LIST;
119 int aUnit,
int aBodyStyle = 0,
const VECTOR2I& aPosition =
VECTOR2I( 0, 0 ),
145 return wxT(
"SCH_SYMBOL" );
169 const KIID_PATH& aSheetPath,
bool aTestFromEnd =
false )
const;
286 wxString
SubReference(
int aUnit,
bool aAddSeparator =
true )
const;
334 mirroring &= ( SYMBOL_ORIENTATION_T::SYM_MIRROR_X | SYMBOL_ORIENTATION_T::SYM_MIRROR_Y );
343 orientation &= ~( SYMBOL_ORIENTATION_T::SYM_MIRROR_X | SYMBOL_ORIENTATION_T::SYM_MIRROR_Y );
345 switch( orientation )
349 case SYM_ORIENT_0:
return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_0;
350 case SYM_ORIENT_90:
return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_90;
351 case SYM_ORIENT_180:
return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_180;
352 case SYM_ORIENT_270:
return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_270;
361 orientation |= SYMBOL_ORIENTATION_T::SYM_MIRROR_X;
378 orientation |= SYMBOL_ORIENTATION_T::SYM_MIRROR_Y;
482 void GetFields( std::vector<SCH_FIELD*>& aVector,
bool aVisibleOnly );
518 bool aCaseInsensitive =
false );
524 bool aIncludeUnit =
false )
const override;
530 bool aAllowExtraText )
const override;
535 bool aAllowExtraText )
const;
589 bool aUpdateOtherFields,
bool aResetRef,
bool aResetOtherFields );
709 const wxString& aRef,
725 if( aMoveVector ==
VECTOR2I( 0, 0 ) )
728 m_pos += aMoveVector;
731 field.Move( aMoveVector );
740 void GetEndPoints( std::vector<DANGLING_END_ITEM>& aItemList )
override;
753 std::vector<DANGLING_END_ITEM>& aItemListByPos,
783 const std::vector<KICAD_T>& aScanTypes )
override;
816 bool HitTest(
const VECTOR2I& aPosition,
int aAccuracy = 0 )
const override;
817 bool HitTest(
const BOX2I& aRect,
bool aContained,
int aAccuracy = 0 )
const override;
827 const VECTOR2I& aOffset,
bool aForceNoFill,
bool aDimmed )
override;
837 const VECTOR2I& aOffset,
bool aDimmed )
override;
840 int aUnit,
int aBodyStyle,
const VECTOR2I& aOffset,
bool aDimmed )
override;
862 void Show(
int nestLevel, std::ostream& os )
const override;
925 std::vector<std::unique_ptr<SCH_PIN>>
m_pins;
BITMAPS
A list of all bitmap identifiers.
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
A logical library item identifier and consists of various portions much like a URI.
Define a library symbol object.
EDA_MSG_PANEL items for displaying messages.
Base plotter engine class.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
virtual void SetUnit(int aUnit)
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
const TRANSFORM & GetTransform() const
void SetValueProp(const wxString &aRef)
SCH_SYMBOL & operator=(const SCH_SYMBOL &aItem)
size_t GetFullPinCount() const
void UpdatePrefix()
Set the prefix based on the current reference designator.
wxString m_prefix
C, R, U, Q etc - the first character(s) which typically indicate what the symbol is.
SCH_FIELD * GetFieldByName(const wxString &aFieldName)
Return a field in this symbol.
wxString GetDescription() const override
std::unordered_map< SCH_PIN *, SCH_PIN * > m_pinMap
library pin pointer : SCH_PIN's index
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction) override
void SetMirrorX(bool aMirror)
bool IsSymbolLikePowerGlobalLabel() const
wxString GetSymbolIDAsString() const
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
bool GetShowPinNumbers() const override
wxString GetDatasheet() const
Return the documentation text for the given part alias.
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void SetLibId(const LIB_ID &aName)
std::vector< SCH_FIELD > & GetFields()
Return a vector of fields from the symbol.
void SetRefProp(const wxString &aRef)
void Print(const SCH_RENDER_SETTINGS *aSettings, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aForceNoFill, bool aDimmed) override
Print a symbol.
wxString GetUnitDisplayName(int aUnit) const
Return the display name for a given unit aUnit.
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Automatically orient all the fields in the symbol.
SCH_ITEM * GetDrawItem(const VECTOR2I &aPosition, KICAD_T aType=TYPE_NOT_INIT)
Return the symbol library item at aPosition that is part of this symbol.
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
std::vector< std::unique_ptr< SCH_PIN > > & GetRawPins()
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstances() const
void SetPosition(const VECTOR2I &aPosition) override
void PlotDNP(PLOTTER *aPlotter) const
Plot the red 'X' over the symbol.
bool operator!=(const SCH_SYMBOL &aSymbol) const
void SetShowPinNumbers(bool aShow) override
Set or clear the pin number visibility flag.
bool IsConnectable() const override
SYMBOL_ORIENTATION_PROP GetOrientationProp() const
int GetFieldCount() const
Return the number of fields in this symbol.
void SetBodyStyleUnconditional(int aBodyStyle)
Similar to SetBodyStyle(), but always set the body style, regardless the lib symbol properties (the L...
wxString SubReference(int aUnit, bool aAddSeparator=true) const
wxString GetClass() const override
Return the class name.
void RemoveInstance(const SCH_SHEET_PATH &aInstancePath)
bool IsAnnotated(const SCH_SHEET_PATH *aSheet) const
Check if the symbol has a valid annotation (reference) for the given sheet path.
void SetMirrorY(bool aMirror)
void PlotPins(PLOTTER *aPlotter) const
Plot just the symbol pins.
bool UseLibIdLookup() const
void SetValueFieldText(const wxString &aValue)
void RemoveField(const wxString &aFieldName)
Remove a user field from the symbol.
void SetBodyStyle(int aBodyStyle) override
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
void SetShowPinNames(bool aShow) override
Set or clear the pin name visibility flag.
wxString GetKeyWords() const override
wxString GetSchSymbolLibraryName() const
SCH_FIELD * FindField(const wxString &aFieldName, bool aIncludeDefaultFields=true, bool aCaseInsensitive=false)
Search for a SCH_FIELD with aFieldName.
static bool ClassOf(const EDA_ITEM *aItem)
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
void SetBodyStyleProp(int aBodyStyle)
void ClearBrightenedPins()
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const override
Check if aItem has connectivity changes against this object.
wxString GetRefProp() const
bool AddSheetPathReferenceEntryIfMissing(const KIID_PATH &aSheetPath)
Add an instance to the alternate references list (m_instanceReferences), if this entry does not alrea...
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
static std::unordered_map< TRANSFORM, int > s_transformToOrientationCache
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
std::vector< SCH_SYMBOL_INSTANCE > m_instanceReferences
const wxString GetValue(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText) const override
void SyncOtherUnits(const SCH_SHEET_PATH &aSourceSheet, SCH_COMMIT &aCommit, PROPERTY_BASE *aProperty)
Keep fields other than the reference, include/exclude flags, and alternate pin assignements in sync i...
const std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef() const
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
void UpdateFields(const SCH_SHEET_PATH *aPath, bool aUpdateStyle, bool aUpdateRef, bool aUpdateOtherFields, bool aResetRef, bool aResetOtherFields)
Restore fields to the original library values.
wxString m_schLibSymbolName
The name used to look up a symbol in the symbol library embedded in a schematic.
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
void ClearAnnotation(const SCH_SHEET_PATH *aSheetPath, bool aResetPrefix)
Clear exiting symbol annotation.
void SetOrientationProp(SYMBOL_ORIENTATION_PROP aAngle)
Orientation/mirroring access for property manager.
bool GetShowPinNames() const override
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve a list of the SCH_PINs for the given sheet path.
const wxString GetFootprintFieldText(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText) const
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
int GetBodyStyleProp() const
std::vector< SCH_PIN * > GetAllLibPins() const
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
void SetFootprintFieldText(const wxString &aFootprint)
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
void AddHierarchicalReference(const KIID_PATH &aPath, const wxString &aRef, int aUnit)
Add a full hierarchical reference to this symbol.
bool IsMissingLibSymbol() const
Check to see if the library symbol is set to the dummy library symbol.
VECTOR2I GetPosition() const override
void SetTransform(const TRANSFORM &aTransform)
std::unique_ptr< LIB_SYMBOL > m_part
A flattened copy of the LIB_SYMBOL from the PROJECT's libraries.
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
const std::vector< SCH_FIELD > & GetFields() const
bool CanConnect(const SCH_ITEM *aItem) const override
void Init(const VECTOR2I &pos=VECTOR2I(0, 0))
bool HasAlternateBodyStyle() const override
Test if symbol has more than one body conversion type (DeMorgan).
const LIB_ID & GetLibId() const override
bool operator<(const SCH_ITEM &aItem) const override
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this symbol.
void SetUnitProp(int aUnit)
void SetSchSymbolLibraryName(const wxString &aName)
The name of the symbol in the schematic library symbol list.
bool IsMulti() const override
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
SCH_FIELD * GetFieldById(int aFieldId)
Return a field in this symbol.
std::vector< SCH_PIN * > GetLibPins() const
Populate a vector with all the pins from the library object that match the current unit and bodyStyle...
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos, const SCH_SHEET_PATH *aPath=nullptr) override
Test if the symbol's dangling state has changed for all pins.
bool GetInstance(SCH_SYMBOL_INSTANCE &aInstance, const KIID_PATH &aSheetPath, bool aTestFromEnd=false) const
TRANSFORM & GetTransform()
BOX2I doGetBoundingBox(bool aIncludePins, bool aIncludeFields) const
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
int GetOrientation() const
Get the display symbol orientation.
void RemoveField(SCH_FIELD *aField)
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
bool m_isInNetlist
True if the symbol should appear in netlist.
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
BOX2I GetBodyAndPinsBoundingBox() const
Return a bounding box for the symbol body and pins but not the fields.
TRANSFORM m_transform
The rotation/mirror transformation.
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
wxString GetValueProp() const
void PrintBackground(const SCH_RENDER_SETTINGS *aSettings, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Print only the background parts of a symbol (if any)
int GetUnitCount() const override
Return the number of units per package of the symbol.
void SetPrefix(const wxString &aPrefix)
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
bool IsNormal() const override
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
std::unordered_set< wxString > GetComponentClassNames(const SCH_SHEET_PATH *aPath) const
Returns the component classes this symbol belongs in.
std::vector< std::unique_ptr< SCH_PIN > > m_pins
a SCH_PIN for every SCH_PIN (all units)
bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
VECTOR2I GetPinPhysicalPosition(const SCH_PIN *Pin) const
BOX2I GetBodyBoundingBox() const
Return a bounding box for the symbol body but not the pins or fields.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
wxString GetPrefix() const
bool HasUnitDisplayName(int aUnit) const
Return true if the given unit aUnit has a display name set.
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
bool IsMovableFromAnchorPoint() const override
Return true for items which are moved with the anchor point at mouse cursor and false for items moved...
bool IsPower() const override
bool operator==(const SCH_SYMBOL &aSymbol) const
A collection of SYMBOL_LIB objects.
Object used to load, save, search, and otherwise manipulate symbol library files.
A base class for LIB_SYMBOL and SCH_SYMBOL.
const INSPECTOR_FUNC & INSPECTOR
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
std::string toUTFTildaText(const wxString &txt)
Convert a wxString to UTF8 and replace any control characters with a ~, where a control character is ...
std::weak_ptr< LIB_SYMBOL > PART_REF
std::vector< SCH_FIELD > SCH_FIELDS
A container for several SCH_FIELD items.
SYMBOL_ORIENTATION_T
enum used in RotationMiroir()
@ SYM_ROTATE_COUNTERCLOCKWISE
A simple container for schematic symbol instance information.
MANDATORY_FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
VECTOR2< int32_t > VECTOR2I