KiCad PCB EDA Suite
SCH_SYMBOL Class Reference

Schematic symbol object. More...

#include <sch_symbol.h>

Inheritance diagram for SCH_SYMBOL:
SCH_ITEM EDA_ITEM KIGFX::VIEW_ITEM INSPECTABLE

Public Member Functions

 SCH_SYMBOL ()
 
 SCH_SYMBOL (const LIB_SYMBOL &aSymbol, const LIB_ID &aLibId, const SCH_SHEET_PATH *aSheet, int aUnit, int aConvert=0, const VECTOR2I &aPosition=VECTOR2I(0, 0), EDA_ITEM *aParent=nullptr)
 Create schematic symbol from library symbol object. More...
 
 SCH_SYMBOL (const LIB_SYMBOL &aSymbol, const SCH_SHEET_PATH *aSheet, const PICKED_SYMBOL &aSel, const VECTOR2I &aPosition=VECTOR2I(0, 0), EDA_ITEM *aParent=nullptr)
 
 SCH_SYMBOL (const SCH_SYMBOL &aSymbol)
 Clone aSymbol into a new schematic symbol object. More...
 
 ~SCH_SYMBOL ()
 
wxString GetClass () const override
 Return the class name. More...
 
bool IsMissingLibSymbol () const
 Check to see if the library symbol is set to the dummy library symbol. More...
 
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstanceReferences ()
 
bool GetInstance (SCH_SYMBOL_INSTANCE &aInstance, const KIID_PATH &aSheetPath, bool aTestFromEnd=false) const
 
void RemoveInstance (const SCH_SHEET_PATH &aInstancePath)
 
void RemoveAllInstances ()
 
void SortInstances (bool(*aSortFunction)(const SCH_SYMBOL_INSTANCE &aLhs, const SCH_SYMBOL_INSTANCE &aRhs))
 
void ViewGetLayers (int aLayers[], int &aCount) const override
 Return the layers the item is drawn on (which may be more than its "home" layer) More...
 
bool IsMovableFromAnchorPoint () const override
 Return true for items which are moved with the anchor point at mouse cursor and false for items moved with no reference to anchor. More...
 
void SetLibId (const LIB_ID &aName)
 
const LIB_IDGetLibId () const
 
void SetSchSymbolLibraryName (const wxString &aName)
 The name of the symbol in the schematic library symbol list. More...
 
wxString GetSchSymbolLibraryName () const
 
bool UseLibIdLookup () const
 
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef ()
 
const std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef () const
 
void SetLibSymbol (LIB_SYMBOL *aLibSymbol)
 Set this schematic symbol library symbol reference to aLibSymbol. More...
 
wxString GetDescription () const
 
wxString GetKeyWords () const
 
wxString GetDatasheet () const
 Return the documentation text for the given part alias. More...
 
int GetUnit () const
 
void UpdatePins ()
 Updates the cache of SCH_PIN objects for each pin. More...
 
void SetUnit (int aUnit)
 Change the unit number to aUnit. More...
 
bool HasUnitDisplayName (int aUnit)
 Return true if the given unit aUnit has a display name set. More...
 
wxString GetUnitDisplayName (int aUnit)
 Return the display name for a given unit aUnit. More...
 
void UpdateUnit (int aUnit)
 Change the unit number to aUnit without setting any internal flags. More...
 
int GetConvert () const
 
void SetConvert (int aConvert)
 
wxString GetPrefix () const
 
void SetPrefix (const wxString &aPrefix)
 
void UpdatePrefix ()
 Set the prefix based on the current reference designator. More...
 
TRANSFORMGetTransform ()
 
const TRANSFORMGetTransform () const
 
void SetTransform (const TRANSFORM &aTransform)
 
int GetUnitCount () const
 Return the number of units per package of the symbol. More...
 
void SetOrientation (int aOrientation)
 Compute the new transform matrix based on aOrientation for the symbol which is applied to the current transform. More...
 
int GetOrientation () const
 Get the display symbol orientation. More...
 
void GetContextualTextVars (wxArrayString *aVars) const
 Return the list of system text vars & fields for this symbol. More...
 
bool ResolveTextVar (wxString *token, int aDepth=0) const
 Resolve any references to system tokens supported by the symbol. More...
 
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. More...
 
void ClearAnnotation (const SCH_SHEET_PATH *aSheetPath, bool aResetPrefix)
 Clear exiting symbol annotation. More...
 
bool AddSheetPathReferenceEntryIfMissing (const KIID_PATH &aSheetPath)
 Add an instance to the alternate references list (m_instanceReferences), if this entry does not already exist. More...
 
bool ReplaceInstanceSheetPath (const KIID_PATH &aOldSheetPath, const KIID_PATH &aNewSheetPath)
 Replace aOldSheetPath with aNewSheetPath in the instance list. More...
 
const BOX2I GetBoundingBox () const override
 Return the orthogonal bounding box of this object for display purposes. More...
 
BOX2I GetBodyBoundingBox () const
 Return a bounding box for the symbol body but not the pins or fields. More...
 
BOX2I GetBodyAndPinsBoundingBox () const
 Return a bounding box for the symbol body and pins but not the fields. More...
 
SCH_FIELDGetField (MANDATORY_FIELD_T aFieldType)
 Return a mandatory field in this symbol. More...
 
const SCH_FIELDGetField (MANDATORY_FIELD_T aFieldNdx) const
 
SCH_FIELDGetFieldById (int aFieldId)
 Return a field in this symbol. More...
 
wxString GetFieldText (const wxString &aFieldName) const
 Search for a field named aFieldName and returns text associated with this field. More...
 
void GetFields (std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
 Populate a std::vector with SCH_FIELDs. More...
 
std::vector< SCH_FIELD > & GetFields ()
 Return a vector of fields from the symbol. More...
 
const std::vector< SCH_FIELD > & GetFields () const
 
SCH_FIELDAddField (const SCH_FIELD &aField)
 Add a field to the symbol. More...
 
void RemoveField (const wxString &aFieldName)
 Remove a user field from the symbol. More...
 
void RemoveField (SCH_FIELD *aField)
 
SCH_FIELDFindField (const wxString &aFieldName, bool aIncludeDefaultFields=true)
 Search for a SCH_FIELD with aFieldName. More...
 
void SetFields (std::vector< SCH_FIELD > &aFields)
 Set multiple schematic fields. More...
 
const wxString GetValueFieldText (bool aResolve) const
 
void SetValueFieldText (const wxString &aValue)
 
const wxString GetFootprintFieldText (bool aResolve) const
 
void SetFootprintFieldText (const wxString &aFootprint)
 
void UpdateFields (const SCH_SHEET_PATH *aPath, bool aUpdateStyle, bool aUpdateRef, bool aUpdateOtherFields, bool aResetRef, bool aResetOtherFields)
 Restore fields to the original library values. More...
 
int GetFieldCount () const
 Return the number of fields in this symbol. More...
 
void AutoplaceFields (SCH_SCREEN *aScreen, bool aManual) override
 Automatically orient all the fields in the symbol. More...
 
void RunOnChildren (const std::function< void(SCH_ITEM *)> &aFunction) override
 
SCH_PINGetPin (const wxString &number) const
 Find a symbol pin by number. More...
 
void GetLibPins (std::vector< LIB_PIN * > &aPinsList) const
 Populate a vector with all the pins from the library object. More...
 
std::vector< LIB_PIN * > GetAllLibPins () const
 
size_t GetFullPinCount ()
 
SCH_PINGetPin (LIB_PIN *aLibPin) const
 
std::vector< SCH_PIN * > GetPins (const SCH_SHEET_PATH *aSheet=nullptr) const
 Retrieve a list of the SCH_PINs for the given sheet path. More...
 
std::vector< std::unique_ptr< SCH_PIN > > & GetRawPins ()
 
void Print (const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
 Print a symbol. More...
 
void PrintBackground (const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
 Print only the background parts of a symbol (if any) More...
 
void SwapData (SCH_ITEM *aItem) override
 Swap the internal data structures aItem with the schematic item. More...
 
const wxString GetRef (const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
 Return the reference for the given sheet path. More...
 
void SetRef (const SCH_SHEET_PATH *aSheet, const wxString &aReference)
 Set the reference for the given sheet path for this symbol. More...
 
bool IsAnnotated (const SCH_SHEET_PATH *aSheet)
 Check if the symbol has a valid annotation (reference) for the given sheet path. More...
 
void AddHierarchicalReference (const KIID_PATH &aPath, const wxString &aRef, int aUnit)
 Add a full hierarchical reference to this symbol. More...
 
void AddHierarchicalReference (const SCH_SYMBOL_INSTANCE &aInstance)
 
int GetUnitSelection (const SCH_SHEET_PATH *aSheet) const
 Return the instance-specific unit selection for the given sheet path. More...
 
void SetUnitSelection (const SCH_SHEET_PATH *aSheet, int aUnitSelection)
 Set the selected unit of this symbol on one sheet. More...
 
void SetUnitSelection (int aUnitSelection)
 Set the selected unit of this symbol for all sheets. More...
 
void Move (const VECTOR2I &aMoveVector) override
 Move the item by aMoveVector to a new position. More...
 
void MirrorHorizontally (int aCenter) override
 Mirror item horizontally about aCenter. More...
 
void MirrorVertically (int aCenter) override
 Mirror item vertically about aCenter. More...
 
void Rotate (const VECTOR2I &aCenter) override
 Rotate the item around aCenter 90 degrees in the clockwise direction. More...
 
bool Matches (const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
 Compare the item against the search criteria in aSearchData. More...
 
void GetEndPoints (std::vector< DANGLING_END_ITEM > &aItemList) override
 Add the schematic item end points to aItemList if the item has end points. More...
 
bool UpdateDanglingState (std::vector< DANGLING_END_ITEM > &aItemList, const SCH_SHEET_PATH *aPath=nullptr) override
 Test if the symbol's dangling state has changed for all pins. More...
 
VECTOR2I GetPinPhysicalPosition (const LIB_PIN *Pin) const
 
bool IsConnectable () const override
 
bool CanConnect (const SCH_ITEM *aItem) const override
 
bool IsInNetlist () const
 
std::vector< VECTOR2IGetConnectionPoints () const override
 Add all the connection points for this item to aPoints. More...
 
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 data. More...
 
LIB_ITEMGetDrawItem (const VECTOR2I &aPosition, KICAD_T aType=TYPE_NOT_INIT)
 Return the symbol library item at aPosition that is part of this symbol. More...
 
wxString GetItemDescription (UNITS_PROVIDER *aUnitsProvider) const override
 Return a user-visible description string of this item. More...
 
BITMAPS GetMenuImage () const override
 Return a pointer to an image to be used in menus. More...
 
bool operator< (const SCH_ITEM &aItem) const override
 
bool operator== (const SCH_SYMBOL &aSymbol) const
 
bool operator!= (const SCH_SYMBOL &aSymbol) const
 
SCH_SYMBOLoperator= (const SCH_ITEM &aItem)
 
bool IsReplaceable () const override
 Override this method in any derived object that supports test find and replace. More...
 
VECTOR2I GetPosition () const override
 
void SetPosition (const VECTOR2I &aPosition) override
 
bool HitTest (const VECTOR2I &aPosition, int aAccuracy=0) const override
 Test if aPosition is inside or on the boundary of this item. More...
 
bool HitTest (const BOX2I &aRect, bool aContained, int aAccuracy=0) const override
 Test if aRect intersects this item. More...
 
void Plot (PLOTTER *aPlotter, bool aBackground) const override
 Plot the schematic item to aPlotter. More...
 
void PlotPins (PLOTTER *aPlotter) const
 Plot just the symbol pins. More...
 
void PlotDNP (PLOTTER *aPlotter) const
 Plot the red 'X' over the symbol. More...
 
EDA_ITEMClone () const override
 Create a duplicate of this item with linked list members set to NULL. More...
 
void ClearBrightenedPins ()
 
bool HasBrightenedPins ()
 
bool GetIncludeInBom () const
 
void SetIncludeInBom (bool aIncludeInBom)
 
bool GetIncludeOnBoard () const
 
void SetIncludeOnBoard (bool aIncludeOnBoard)
 
bool GetDNP () const
 
void SetDNP (bool aDNP)
 
bool IsPointClickableAnchor (const VECTOR2I &aPos) const override
 
bool IsType (const std::vector< KICAD_T > &aScanTypes) const override
 Check whether the item is one of the listed types. More...
 
SCH_ITEMDuplicate (bool doClone=false) const
 Routine to create a new copy of given item. More...
 
VECTOR2IGetStoredPos ()
 
void SetStoredPos (const VECTOR2I &aPos)
 
SCHEMATICSchematic () const
 Searches the item hierarchy to find a SCHEMATIC. More...
 
virtual bool IsLocked () const
 
virtual void SetLocked (bool aLocked)
 Set the 'lock' status to aLocked for of this item. More...
 
virtual bool IsHypertext () const
 Allow items to support hypertext actions when hovered/clicked. More...
 
virtual void DoHypertextAction (EDA_DRAW_FRAME *aFrame) const
 
SCH_LAYER_ID GetLayer () const
 Return the layer this item is on. More...
 
void SetLayer (SCH_LAYER_ID aLayer)
 Set the layer this item is on. More...
 
virtual int GetPenWidth () const
 
const wxString & GetDefaultFont () const
 
bool RenderAsBitmap (double aWorldScale) const override
 
virtual bool IsDangling () const
 
void ClearConnections ()
 Clears all of the connection items from the list. More...
 
bool IsConnected (const VECTOR2I &aPoint) const
 Test the item to see if it is connected to aPoint. More...
 
SCH_CONNECTIONConnection (const SCH_SHEET_PATH *aSheet=nullptr) const
 Retrieve the connection associated with this object in the given sheet. More...
 
SCH_ITEM_SETConnectedItems (const SCH_SHEET_PATH &aPath)
 Retrieve the set of items connected to this item on the given sheet. More...
 
void AddConnectionTo (const SCH_SHEET_PATH &aPath, SCH_ITEM *aItem)
 Add a connection link between this item and another. More...
 
SCH_CONNECTIONInitializeConnection (const SCH_SHEET_PATH &aPath, CONNECTION_GRAPH *aGraph)
 Create a new connection object associated with this object. More...
 
SCH_CONNECTIONGetOrInitConnection (const SCH_SHEET_PATH &aPath, CONNECTION_GRAPH *aGraph)
 
virtual bool ConnectionPropagatesTo (const EDA_ITEM *aItem) const
 Return true if this item should propagate connection info to aItem. More...
 
bool IsConnectivityDirty () const
 
void SetConnectivityDirty (bool aDirty=true)
 
virtual void SetLastResolvedState (const SCH_ITEM *aItem)
 
std::shared_ptr< NETCLASSGetEffectiveNetClass (const SCH_SHEET_PATH *aSheet=nullptr) const
 
FIELDS_AUTOPLACED GetFieldsAutoplaced () const
 Return whether the fields have been automatically placed. More...
 
void SetFieldsAutoplaced ()
 
void ClearFieldsAutoplaced ()
 
void AutoAutoplaceFields (SCH_SCREEN *aScreen)
 Autoplace fields only if correct to do so automatically. More...
 
virtual void ClearCaches ()
 
virtual bool HasLineStroke () const
 Check if this schematic item has line stoke properties. More...
 
virtual STROKE_PARAMS GetStroke () const
 
virtual void SetStroke (const STROKE_PARAMS &aStroke)
 
bool operator< (const EDA_ITEM &aItem) const
 Test if another item is less than this object. More...
 
KICAD_T Type () const
 Returns the type of object. More...
 
EDA_ITEMGetParent () const
 
virtual void SetParent (EDA_ITEM *aParent)
 
bool IsModified () const
 
bool IsNew () const
 
bool IsMoving () const
 
bool IsSelected () const
 
bool IsEntered () const
 
bool IsBrightened () const
 
bool IsRollover () const
 
void SetSelected ()
 
void SetBrightened ()
 
void ClearSelected ()
 
void ClearBrightened ()
 
void SetModified ()
 
int GetState (EDA_ITEM_FLAGS type) const
 
void SetState (EDA_ITEM_FLAGS type, bool state)
 
EDA_ITEM_FLAGS GetStatus () const
 
void SetStatus (EDA_ITEM_FLAGS aStatus)
 
void SetFlags (EDA_ITEM_FLAGS aMask)
 
void XorFlags (EDA_ITEM_FLAGS aMask)
 
void ClearFlags (EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
 
EDA_ITEM_FLAGS GetFlags () const
 
bool HasFlag (EDA_ITEM_FLAGS aFlag) const
 
EDA_ITEM_FLAGS GetEditFlags () const
 
void ClearTempFlags ()
 
void ClearEditFlags ()
 
void SetIsShownAsBitmap (bool aBitmap)
 
bool IsShownAsBitmap () const
 
void SetForceVisible (bool aEnable)
 Set and clear force visible flag used to force the item to be drawn even if it's draw attribute is set to not visible. More...
 
bool IsForceVisible () const
 
virtual wxString GetFriendlyName () const
 
virtual const VECTOR2I GetFocusPosition () const
 Similar to GetPosition, but allows items to return their visual center rather than their anchor. More...
 
virtual VECTOR2I GetSortPosition () const
 Return the coordinates that should be used for sorting this element visually compared to other elements. More...
 
wxString GetTypeDesc () const
 Return a translated description of the type for this EDA_ITEM for display in user facing messages. More...
 
virtual bool Replace (const EDA_SEARCH_DATA &aSearchData, void *aAuxData=nullptr)
 Perform a text replace using the find and replace criteria in aSearchData on items that support text find and replace. More...
 
virtual const BOX2I ViewBBox () const override
 Return the bounding box of the item covering all its layers. More...
 
virtual void ViewDraw (int aLayer, VIEW *aView) const
 Draw the parts of the object belonging to layer aLayer. More...
 
virtual double ViewGetLOD (int aLayer, VIEW *aView) const
 Return the level of detail (LOD) of the item. More...
 
VIEW_ITEM_DATA * viewPrivData () const
 
void ClearViewPrivData ()
 
bool Set (PROPERTY_BASE *aProperty, wxAny &aValue)
 
template<typename T >
bool Set (PROPERTY_BASE *aProperty, T aValue)
 
template<typename T >
bool Set (const wxString &aProperty, T aValue)
 
wxAny Get (PROPERTY_BASE *aProperty) const
 
template<typename T >
Get (PROPERTY_BASE *aProperty) const
 
template<typename T >
std::optional< T > Get (const wxString &aProperty) const
 

Static Public Member Functions

static bool ClassOf (const EDA_ITEM *aItem)
 
static bool IsReferenceStringValid (const wxString &aReferenceString)
 Test for an acceptable reference string. More...
 
template<class T >
static INSPECT_RESULT IterateForward (std::deque< T > &aList, INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &scanTypes)
 This changes first parameter to avoid the DList and use the main queue instead. More...
 
template<class T >
static INSPECT_RESULT IterateForward (std::vector< T > &aList, INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &scanTypes)
 Change first parameter to avoid the DList and use std::vector instead. More...
 
static bool Replace (const EDA_SEARCH_DATA &aSearchData, wxString &aText)
 Perform a text replace on aText using the find and replace criteria in aSearchData on items that support text find and replace. More...
 
static bool Sort (const EDA_ITEM *aLeft, const EDA_ITEM *aRight)
 Helper function to be used by the C++ STL sort algorithm for sorting a STL container of EDA_ITEM pointers. More...
 

Public Attributes

const KIID m_Uuid
 

Protected Member Functions

bool Matches (const wxString &aText, const EDA_SEARCH_DATA &aSearchData) const
 Compare aText against search criteria in aSearchData. More...
 

Protected Attributes

SCH_LAYER_ID m_layer
 
EDA_ITEMS m_connections
 
FIELDS_AUTOPLACED m_fieldsAutoplaced
 
VECTOR2I m_storedPos
 
std::map< SCH_SHEET_PATH, SCH_ITEM_SET, SHEET_PATH_CMPm_connected_items
 Store pointers to other items that are connected to this one, per sheet. More...
 
std::unordered_map< SCH_SHEET_PATH, SCH_CONNECTION * > m_connection_map
 Store connectivity information, per sheet. More...
 
bool m_connectivity_dirty
 
EDA_ITEM_FLAGS m_status
 
EDA_ITEMm_parent
 Linked list: Link (parent struct) More...
 
bool m_forceVisible
 
EDA_ITEM_FLAGS m_flags
 

Private Member Functions

BOX2I doGetBoundingBox (bool aIncludePins, bool aIncludeFields) const
 
bool doIsConnected (const VECTOR2I &aPosition) const override
 Provide the object specific test to see if it is connected to aPosition. More...
 
void Init (const VECTOR2I &pos=VECTOR2I(0, 0))
 

Private Attributes

VECTOR2I m_pos
 
LIB_ID m_lib_id
 Name and library the symbol was loaded from, i.e. 74xx:74LS00. More...
 
int m_unit
 The unit for multiple part per package symbols. More...
 
int m_convert
 The alternate body style for symbols that have more than one body style defined. More...
 
wxString m_prefix
 C, R, U, Q etc - the first character(s) which typically indicate what the symbol is. More...
 
wxString m_schLibSymbolName
 The name used to look up a symbol in the symbol library embedded in a schematic. More...
 
TRANSFORM m_transform
 The rotation/mirror transformation. More...
 
std::vector< SCH_FIELDm_fields
 Variable length list of fields. More...
 
std::unique_ptr< LIB_SYMBOLm_part
 a flattened copy of the LIB_SYMBOL from the PROJECT's libraries. More...
 
std::vector< std::unique_ptr< SCH_PIN > > m_pins
 a SCH_PIN for every LIB_PIN (all units) More...
 
std::unordered_map< LIB_PIN *, unsigned > m_pinMap
 library pin pointer : SCH_PIN's index More...
 
bool m_isInNetlist
 True if the symbol should appear in the netlist. More...
 
bool m_inBom
 True to include in bill of materials export. More...
 
bool m_onBoard
 True to include in netlist when updating board. More...
 
bool m_DNP
 True if symbol is set to 'Do Not Populate'. More...
 
std::vector< SCH_SYMBOL_INSTANCEm_instanceReferences
 
KICAD_T m_structType
 Run time identification, keep private so it can never be changed after a ctor sets it. More...
 
VIEW_ITEM_DATA * m_viewPrivData
 

Detailed Description

Schematic symbol object.

Definition at line 80 of file sch_symbol.h.

Constructor & Destructor Documentation

◆ SCH_SYMBOL() [1/4]

SCH_SYMBOL::SCH_SYMBOL ( )

Definition at line 104 of file sch_symbol.cpp.

104 :
105 SCH_ITEM( nullptr, SCH_SYMBOL_T )
106{
107 m_DNP = false;
108 Init( VECTOR2I( 0, 0 ) );
109}
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType)
Definition: sch_item.cpp:52
void Init(const VECTOR2I &pos=VECTOR2I(0, 0))
Definition: sch_symbol.cpp:200
bool m_DNP
True if symbol is set to 'Do Not Populate'.
Definition: sch_symbol.h:796
@ SCH_SYMBOL_T
Definition: typeinfo.h:156
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

References Init(), and m_DNP.

Referenced by Clone().

◆ SCH_SYMBOL() [2/4]

SCH_SYMBOL::SCH_SYMBOL ( const LIB_SYMBOL aSymbol,
const LIB_ID aLibId,
const SCH_SHEET_PATH aSheet,
int  aUnit,
int  aConvert = 0,
const VECTOR2I aPosition = VECTOR2I( 0, 0 ),
EDA_ITEM aParent = nullptr 
)

Create schematic symbol from library symbol object.

Parameters
aSymbolis the library symbol to create schematic symbol from.
aLibIdis the LIB_ID of alias to create.
aSheetis the schematic sheet the symbol is place into.
aUnitis unit for symbols that have multiple parts per package.
aConvertis the alternate body style for the schematic symbols.
aPositionis the position of the symbol.

Definition at line 112 of file sch_symbol.cpp.

114 :
115 SCH_ITEM( aParent, SCH_SYMBOL_T )
116{
117 Init( aPosition );
118
119 m_unit = aUnit;
120 m_convert = aConvert;
121 m_lib_id = aLibId;
122
123 std::unique_ptr< LIB_SYMBOL > part;
124
125 part = aSymbol.Flatten();
126 part->SetParent();
127 SetLibSymbol( part.release() );
128
129 // Copy fields from the library symbol
130 UpdateFields( aSheet,
131 true, /* update style */
132 false, /* update ref */
133 false, /* update other fields */
134 true, /* reset ref */
135 true /* reset other fields */ );
136
137 m_prefix = UTIL::GetRefDesPrefix( m_part->GetReferenceField().GetText() );
138
139 if( aSheet )
140 {
142 }
143
144 // Inherit the include in bill of materials and board netlist settings from library symbol.
145 m_inBom = aSymbol.GetIncludeInBom();
146 m_onBoard = aSymbol.GetIncludeOnBoard();
147 m_DNP = false;
148
149}
bool GetIncludeOnBoard() const
Definition: lib_symbol.h:649
bool GetIncludeInBom() const
Definition: lib_symbol.h:641
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:456
wxString m_prefix
C, R, U, Q etc - the first character(s) which typically indicate what the symbol is.
Definition: sch_symbol.h:771
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
Definition: sch_symbol.h:766
int m_convert
The alternate body style for symbols that have more than one body style defined.
Definition: sch_symbol.h:768
void UpdateFields(const SCH_SHEET_PATH *aPath, bool aUpdateStyle, bool aUpdateRef, bool aUpdateOtherFields, bool aResetRef, bool aResetOtherFields)
Restore fields to the original library values.
Definition: sch_symbol.cpp:930
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
Definition: sch_symbol.cpp:694
bool m_onBoard
True to include in netlist when updating board.
Definition: sch_symbol.h:795
int m_unit
The unit for multiple part per package symbols.
Definition: sch_symbol.h:767
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
Definition: sch_symbol.cpp:299
bool m_inBom
True to include in bill of materials export.
Definition: sch_symbol.h:794
std::unique_ptr< LIB_SYMBOL > m_part
a flattened copy of the LIB_SYMBOL from the PROJECT's libraries.
Definition: sch_symbol.h:788
wxString GetRefDesPrefix(const wxString &aRefDes)
Get the (non-numeric) prefix from a refdes - e.g.
wxString GetRefDesUnannotated(const wxString &aSource)
Return an unannotated refdes from either a prefix or an existing refdes.

References LIB_SYMBOL::Flatten(), LIB_SYMBOL::GetIncludeInBom(), LIB_SYMBOL::GetIncludeOnBoard(), UTIL::GetRefDesPrefix(), UTIL::GetRefDesUnannotated(), Init(), m_convert, m_DNP, m_inBom, m_lib_id, m_onBoard, m_part, m_prefix, m_unit, SetLibSymbol(), SetRef(), and UpdateFields().

◆ SCH_SYMBOL() [3/4]

SCH_SYMBOL::SCH_SYMBOL ( const LIB_SYMBOL aSymbol,
const SCH_SHEET_PATH aSheet,
const PICKED_SYMBOL aSel,
const VECTOR2I aPosition = VECTOR2I( 0, 0 ),
EDA_ITEM aParent = nullptr 
)

Definition at line 152 of file sch_symbol.cpp.

154 :
155 SCH_SYMBOL( aSymbol, aSel.LibId, aSheet, aSel.Unit, aSel.Convert, aPosition, aParent )
156{
157 // Set any fields that were modified as part of the symbol selection
158 for( const std::pair<int, wxString>& i : aSel.Fields )
159 {
160 if( i.first == REFERENCE_FIELD )
161 SetRef( aSheet, i.second );
162 else if( SCH_FIELD* field = GetFieldById( i.first ) )
163 field->SetText( i.second );
164 }
165}
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
SCH_FIELD * GetFieldById(int aFieldId)
Return a field in this symbol.
Definition: sch_symbol.cpp:855
LIB_ID LibId
Definition: sch_screen.h:80
std::vector< std::pair< int, wxString > > Fields
Definition: sch_screen.h:84
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".

References PICKED_SYMBOL::Fields, GetFieldById(), REFERENCE_FIELD, and SetRef().

◆ SCH_SYMBOL() [4/4]

SCH_SYMBOL::SCH_SYMBOL ( const SCH_SYMBOL aSymbol)

Clone aSymbol into a new schematic symbol object.

All fields are copied as is except for the linked list management pointers which are set to NULL, and the SCH_FIELD's m_Parent pointers which are set to the new object.

Parameters
aSymbolis the schematic symbol to clone.

Definition at line 168 of file sch_symbol.cpp.

168 :
169 SCH_ITEM( aSymbol )
170{
171 m_parent = aSymbol.m_parent;
172 m_pos = aSymbol.m_pos;
173 m_unit = aSymbol.m_unit;
174 m_convert = aSymbol.m_convert;
175 m_lib_id = aSymbol.m_lib_id;
177 m_inBom = aSymbol.m_inBom;
178 m_onBoard = aSymbol.m_onBoard;
179 m_DNP = aSymbol.m_DNP;
180
181 if( aSymbol.m_part )
182 SetLibSymbol( new LIB_SYMBOL( *aSymbol.m_part.get() ) );
183
184 const_cast<KIID&>( m_Uuid ) = aSymbol.m_Uuid;
185
186 m_transform = aSymbol.m_transform;
187 m_prefix = aSymbol.m_prefix;
189 m_fields = aSymbol.m_fields;
190
191 // Re-parent the fields, which before this had aSymbol as parent
192 for( SCH_FIELD& field : m_fields )
193 field.SetParent( this );
194
197}
const KIID m_Uuid
Definition: eda_item.h:492
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:496
Definition: kiid.h:48
Define a library symbol object.
Definition: lib_symbol.h:99
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:493
VECTOR2I m_pos
Definition: sch_symbol.h:765
std::vector< SCH_SYMBOL_INSTANCE > m_instanceReferences
Definition: sch_symbol.h:800
wxString m_schLibSymbolName
The name used to look up a symbol in the symbol library embedded in a schematic.
Definition: sch_symbol.h:783
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:786
bool m_isInNetlist
True if the symbol should appear in the netlist.
Definition: sch_symbol.h:793
TRANSFORM m_transform
The rotation/mirror transformation.
Definition: sch_symbol.h:785

References m_convert, m_DNP, m_fields, SCH_ITEM::m_fieldsAutoplaced, m_inBom, m_instanceReferences, m_isInNetlist, m_lib_id, m_onBoard, EDA_ITEM::m_parent, m_part, m_pos, m_prefix, m_schLibSymbolName, m_transform, m_unit, EDA_ITEM::m_Uuid, and SetLibSymbol().

◆ ~SCH_SYMBOL()

SCH_SYMBOL::~SCH_SYMBOL ( )
inline

Definition at line 113 of file sch_symbol.h.

113{ }

Member Function Documentation

◆ AddConnectionTo()

void SCH_ITEM::AddConnectionTo ( const SCH_SHEET_PATH aPath,
SCH_ITEM aItem 
)
inherited

Add a connection link between this item and another.

Definition at line 193 of file sch_item.cpp.

194{
195 SCH_ITEM_SET& set = m_connected_items[ aSheet ];
196
197 // The vector elements are small, so reserve 1k at a time to prevent re-allocations
198 if( set.size() == set.capacity() )
199 set.reserve( set.size() + 4096 );
200
201 set.emplace_back( aItem );
202}
std::map< SCH_SHEET_PATH, SCH_ITEM_SET, SHEET_PATH_CMP > m_connected_items
Store pointers to other items that are connected to this one, per sheet.
Definition: sch_item.h:498
std::vector< SCH_ITEM * > SCH_ITEM_SET
Definition: sch_item.h:136

References SCH_ITEM::m_connected_items.

Referenced by SCH_LABEL_BASE::UpdateDanglingState(), and CONNECTION_GRAPH::updateItemConnectivity().

◆ AddField()

SCH_FIELD * SCH_SYMBOL::AddField ( const SCH_FIELD aField)

Add a field to the symbol.

Parameters
aFieldis the field to add to this symbol.
Returns
the newly inserted field.

Definition at line 894 of file sch_symbol.cpp.

895{
896 int newNdx = m_fields.size();
897
898 m_fields.push_back( aField );
899 return &m_fields[newNdx];
900}

References m_fields.

Referenced by FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances(), SCH_ALTIUM_PLUGIN::ParseParameter(), and UpdateFields().

◆ AddHierarchicalReference() [1/2]

void SCH_SYMBOL::AddHierarchicalReference ( const KIID_PATH aPath,
const wxString &  aRef,
int  aUnit 
)

Add a full hierarchical reference to this symbol.

Parameters
aPathis the hierarchical path (/&ltsheet timestamp&gt/&ltsymbol timestamp&gt like /05678E50/A23EF560).
aRefis the local reference like C45, R56.
aUnitis the unit selection used for symbols with multiple units per package.
aValueis the value used for this instance.
aFootprintis the footprint used for this instance (which might have different hole spacing or other board-specific changes from other instances).

Definition at line 550 of file sch_symbol.cpp.

551{
552 // Search for an existing path and remove it if found (should not occur)
553 for( unsigned ii = 0; ii < m_instanceReferences.size(); ii++ )
554 {
555 if( m_instanceReferences[ii].m_Path == aPath )
556 {
557 wxLogTrace( traceSchSheetPaths, "Removing symbol instance:\n"
558 " sheet path %s\n"
559 " reference %s, unit %d from symbol %s.",
560 aPath.AsString(),
561 m_instanceReferences[ii].m_Reference,
562 m_instanceReferences[ii].m_Unit,
563 m_Uuid.AsString() );
564
565 m_instanceReferences.erase( m_instanceReferences.begin() + ii );
566 ii--;
567 }
568 }
569
570 SCH_SYMBOL_INSTANCE instance;
571 instance.m_Path = aPath;
572 instance.m_Reference = aRef;
573 instance.m_Unit = aUnit;
574
575 wxLogTrace( traceSchSheetPaths,
576 "Adding symbol '%s' instance:\n"
577 " sheet path '%s'\n"
578 " reference '%s'\n"
579 " unit %d\n",
581 aPath.AsString(),
582 aRef,
583 aUnit );
584
585 m_instanceReferences.push_back( instance );
586
587 // This should set the default instance to the first saved instance data for each symbol
588 // when importing sheets.
589 if( m_instanceReferences.size() == 1 )
590 {
591 m_fields[ REFERENCE_FIELD ].SetText( aRef );
592 m_unit = aUnit;
593 }
594}
wxString AsString() const
Definition: kiid.cpp:359
wxString AsString() const
Definition: kiid.cpp:257
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
A simple container for schematic symbol instance information.

References KIID::AsString(), KIID_PATH::AsString(), m_fields, m_instanceReferences, SCH_SYMBOL_INSTANCE::m_Path, SCH_SYMBOL_INSTANCE::m_Reference, SCH_SYMBOL_INSTANCE::m_Unit, m_unit, EDA_ITEM::m_Uuid, REFERENCE_FIELD, and traceSchSheetPaths.

Referenced by SCH_SHEET_PATH::AddNewSymbolInstances(), AddSheetPathReferenceEntryIfMissing(), SCH_SCREEN::SetLegacySymbolInstanceData(), SetRef(), SetUnitSelection(), and SCH_SHEET_LIST::UpdateSymbolInstanceData().

◆ AddHierarchicalReference() [2/2]

void SCH_SYMBOL::AddHierarchicalReference ( const SCH_SYMBOL_INSTANCE aInstance)

Definition at line 597 of file sch_symbol.cpp.

598{
599 KIID_PATH searchPath( aInstance.m_Path );
600
601 std::vector<SCH_SYMBOL_INSTANCE>::iterator resultIt;
602
603 do
604 {
605 resultIt = std::find_if( m_instanceReferences.begin(), m_instanceReferences.end(),
606 [searchPath]( const auto& it )
607 {
608 return it.m_Path == searchPath;
609 } );
610
611 if( resultIt != m_instanceReferences.end() )
612 {
613 wxLogTrace( traceSchSheetPaths, "Removing symbol instance:\n"
614 " sheet path %s\n"
615 " reference %s, unit %d from symbol %s.",
616 aInstance.m_Path.AsString(),
617 resultIt->m_Reference,
618 resultIt->m_Unit,
619 m_Uuid.AsString() );
620
621 // Instance data should be unique by path. Double check just in case there was
622 // some buggy code in the past.
623 resultIt = m_instanceReferences.erase( resultIt );
624 }
625 }
626 while( resultIt != m_instanceReferences.end() );
627
628 SCH_SYMBOL_INSTANCE instance = aInstance;
629
630 wxLogTrace( traceSchSheetPaths,
631 "Adding symbol '%s' instance:\n"
632 " sheet path '%s'\n"
633 " reference '%s'\n"
634 " unit %d\n",
636 instance.m_Path.AsString(),
637 instance.m_Reference,
638 instance.m_Unit );
639
640 m_instanceReferences.push_back( instance );
641
642 // This should set the default instance to the first saved instance data for each symbol
643 // when importing sheets.
644 if( m_instanceReferences.size() == 1 )
645 {
646 m_fields[ REFERENCE_FIELD ].SetText( instance.m_Reference );
647 m_unit = instance.m_Unit;
648 }
649}

References KIID::AsString(), KIID_PATH::AsString(), m_fields, m_instanceReferences, SCH_SYMBOL_INSTANCE::m_Path, SCH_SYMBOL_INSTANCE::m_Reference, SCH_SYMBOL_INSTANCE::m_Unit, m_unit, EDA_ITEM::m_Uuid, REFERENCE_FIELD, and traceSchSheetPaths.

◆ AddSheetPathReferenceEntryIfMissing()

bool SCH_SYMBOL::AddSheetPathReferenceEntryIfMissing ( const KIID_PATH aSheetPath)

Add an instance to the alternate references list (m_instanceReferences), if this entry does not already exist.

Do nothing if already exists. In symbol lists shared by more than one sheet path, an entry for each sheet path must exist to manage references.

Parameters
aSheetPathis the candidate sheet path of the sheet containing the symbol not the full symbol sheet path.
Returns
false if the alternate reference was existing, true if added.

Definition at line 1310 of file sch_symbol.cpp.

1311{
1312 // An empty sheet path is illegal, at a minimum the root sheet UUID must be present.
1313 wxCHECK( aSheetPath.size() > 0, false );
1314
1315 for( const SCH_SYMBOL_INSTANCE& instance : m_instanceReferences )
1316 {
1317 // if aSheetPath is found, nothing to do:
1318 if( instance.m_Path == aSheetPath )
1319 return false;
1320 }
1321
1322 // This entry does not exist: add it, with its last-used reference
1324 return true;
1325}
void AddHierarchicalReference(const KIID_PATH &aPath, const wxString &aRef, int aUnit)
Add a full hierarchical reference to this symbol.
Definition: sch_symbol.cpp:550
wxString GetText(EDA_UNITS aUnits, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
Get the units string for a given units type.
Definition: eda_units.cpp:98

References AddHierarchicalReference(), EDA_UNIT_UTILS::GetText(), m_fields, m_instanceReferences, m_unit, and REFERENCE_FIELD.

Referenced by SCH_SCREEN::EnsureAlternateReferencesExist().

◆ AutoAutoplaceFields()

void SCH_ITEM::AutoAutoplaceFields ( SCH_SCREEN aScreen)
inlineinherited

Autoplace fields only if correct to do so automatically.

Fields that have been moved by hand are not automatically placed.

Parameters
aScreenis the SCH_SCREEN associated with the current instance of the symbol.

Definition at line 436 of file sch_item.h.

437 {
438 if( GetFieldsAutoplaced() )
440 }
FIELDS_AUTOPLACED GetFieldsAutoplaced() const
Return whether the fields have been automatically placed.
Definition: sch_item.h:424
virtual void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual)
Definition: sch_item.h:442
@ FIELDS_AUTOPLACED_MANUAL
Definition: sch_item.h:58

References SCH_ITEM::AutoplaceFields(), FIELDS_AUTOPLACED_MANUAL, and SCH_ITEM::GetFieldsAutoplaced().

Referenced by SCH_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Rotate(), SCH_SHEET::SCH_SHEET(), SCH_EDIT_FRAME::SelectUnit(), and DIALOG_LABEL_PROPERTIES::TransferDataFromWindow().

◆ AutoplaceFields()

void SCH_SYMBOL::AutoplaceFields ( SCH_SCREEN aScreen,
bool  aManual 
)
overridevirtual

Automatically orient all the fields in the symbol.

Parameters
aScreenis the SCH_SCREEN associated with the current instance of the symbol. This can be NULL when aManual is false.
aManualshould be true if the autoplace was manually initiated (e.g. by a hotkey or a menu item). Some more 'intelligent' routines will be used that would be annoying if done automatically during moves.

Reimplemented from SCH_ITEM.

Definition at line 739 of file autoplace_fields.cpp.

740{
741 if( aManual )
742 wxASSERT_MSG( aScreen, wxS( "A SCH_SCREEN pointer must be given for manual autoplacement" ) );
743
744 AUTOPLACER autoplacer( this, aScreen );
745 autoplacer.DoAutoplace( aManual );
747}
@ FIELDS_AUTOPLACED_AUTO
Definition: sch_item.h:57

References AUTOPLACER::DoAutoplace(), FIELDS_AUTOPLACED_AUTO, FIELDS_AUTOPLACED_MANUAL, and SCH_ITEM::m_fieldsAutoplaced.

Referenced by SYMBOL_EDITOR_CONTROL::AddSymbolToSchematic(), and SCH_DRAWING_TOOLS::PlaceSymbol().

◆ CanConnect()

bool SCH_SYMBOL::CanConnect ( const SCH_ITEM aItem) const
inlineoverridevirtual

Reimplemented from SCH_ITEM.

Definition at line 668 of file sch_symbol.h.

669 {
670 return ( aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_WIRE ) ||
671 ( aItem->Type() == SCH_NO_CONNECT_T ) ||
672 ( aItem->Type() == SCH_JUNCTION_T ) ||
673 ( aItem->Type() == SCH_SYMBOL_T ) ||
674 ( aItem->Type() == SCH_DIRECTIVE_LABEL_T ) ||
675 ( aItem->Type() == SCH_LABEL_T ) ||
676 ( aItem->Type() == SCH_HIER_LABEL_T ) ||
677 ( aItem->Type() == SCH_GLOBAL_LABEL_T );
678 }
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:246
@ LAYER_WIRE
Definition: layer_ids.h:344
@ SCH_LINE_T
Definition: typeinfo.h:146
@ SCH_NO_CONNECT_T
Definition: typeinfo.h:143
@ SCH_DIRECTIVE_LABEL_T
Definition: typeinfo.h:154
@ SCH_LABEL_T
Definition: typeinfo.h:151
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:153
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:152
@ SCH_JUNCTION_T
Definition: typeinfo.h:142

References SCH_ITEM::GetLayer(), LAYER_WIRE, SCH_DIRECTIVE_LABEL_T, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_JUNCTION_T, SCH_LABEL_T, SCH_LINE_T, SCH_NO_CONNECT_T, SCH_SYMBOL_T, and EDA_ITEM::Type().

◆ ClassOf()

static bool SCH_SYMBOL::ClassOf ( const EDA_ITEM aItem)
inlinestatic

Definition at line 115 of file sch_symbol.h.

116 {
117 return aItem && SCH_SYMBOL_T == aItem->Type();
118 }

References SCH_SYMBOL_T, and EDA_ITEM::Type().

◆ ClearAnnotation()

void SCH_SYMBOL::ClearAnnotation ( const SCH_SHEET_PATH aSheetPath,
bool  aResetPrefix 
)

Clear exiting symbol annotation.

For example, IC23 would be changed to IC? and unit number would be reset.

Parameters
aSheetPathis the hierarchical path of the symbol to clear or remove all annotations for this symbol if NULL.
[in]aResetPrefixThe annotation prefix ('R', 'U', etc.) should be reset to the symbol library prefix.

Definition at line 1266 of file sch_symbol.cpp.

1267{
1268 if( aSheetPath )
1269 {
1270 KIID_PATH path = aSheetPath->Path();
1271
1272 for( SCH_SYMBOL_INSTANCE& instance : m_instanceReferences )
1273 {
1274 if( instance.m_Path == path )
1275 {
1276 if( instance.m_Reference.IsEmpty() || aResetPrefix )
1277 instance.m_Reference = UTIL::GetRefDesUnannotated( m_prefix );
1278 else
1279 instance.m_Reference = UTIL::GetRefDesUnannotated( instance.m_Reference );
1280 }
1281 }
1282 }
1283 else
1284 {
1285 for( SCH_SYMBOL_INSTANCE& instance : m_instanceReferences )
1286 {
1287 if( instance.m_Reference.IsEmpty() || aResetPrefix)
1288 instance.m_Reference = UTIL::GetRefDesUnannotated( m_prefix );
1289 else
1290 instance.m_Reference = UTIL::GetRefDesUnannotated( instance.m_Reference );
1291 }
1292 }
1293
1294 for( std::unique_ptr<SCH_PIN>& pin : m_pins )
1295 pin->ClearDefaultNetName( aSheetPath );
1296
1297 // These 2 changes do not work in complex hierarchy.
1298 // When a clear annotation is made, the calling function must call a
1299 // UpdateAllScreenReferences for the active sheet.
1300 // But this call cannot made here.
1301 wxString currentReference = m_fields[REFERENCE_FIELD].GetText();
1302
1303 if( currentReference.IsEmpty() || aResetPrefix )
1305 else
1306 m_fields[REFERENCE_FIELD].SetText( UTIL::GetRefDesUnannotated( currentReference ) );
1307}
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
std::vector< std::unique_ptr< SCH_PIN > > m_pins
a SCH_PIN for every LIB_PIN (all units)
Definition: sch_symbol.h:790

References UTIL::GetRefDesUnannotated(), m_fields, m_instanceReferences, m_pins, m_prefix, SCH_SHEET_PATH::Path(), path, pin, and REFERENCE_FIELD.

Referenced by SCH_SCREEN::ClearAnnotation(), SCH_EDIT_FRAME::DeleteAnnotation(), SCH_DRAWING_TOOLS::PlaceSymbol(), and SCH_EDITOR_CONTROL::updatePastedSymbol().

◆ ClearBrightened()

void EDA_ITEM::ClearBrightened ( )
inlineinherited

Definition at line 119 of file eda_item.h.

void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:141
#define BRIGHTENED
item is drawn with a bright contour

References BRIGHTENED, and EDA_ITEM::ClearFlags().

Referenced by SCH_EDIT_FRAME::FocusOnItem(), PCB_BASE_FRAME::FocusOnItems(), EE_SELECTION_TOOL::unhighlight(), PL_SELECTION_TOOL::unhighlight(), PCB_SELECTION_TOOL::unhighlightInternal(), and SCH_EDITOR_CONTROL::UpdateNetHighlighting().

◆ ClearBrightenedPins()

void SCH_SYMBOL::ClearBrightenedPins ( )

Definition at line 2230 of file sch_symbol.cpp.

2231{
2232 for( auto& pin : m_pins )
2233 pin->ClearBrightened();
2234}

References m_pins, and pin.

Referenced by SCH_EDITOR_CONTROL::UpdateNetHighlighting().

◆ ClearCaches()

void SCH_ITEM::ClearCaches ( )
virtualinherited

Reimplemented in SCH_FIELD.

Definition at line 251 of file sch_item.cpp.

252{
253 auto clearTextCaches =
254 []( SCH_ITEM* aItem )
255 {
256 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( aItem );
257
258 if( text )
259 {
260 text->ClearBoundingBoxCache();
261 text->ClearRenderCache();
262 }
263 };
264
265 clearTextCaches( this );
266
267 RunOnChildren( clearTextCaches );
268}
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction)
Definition: sch_item.h:444

References SCH_ITEM::RunOnChildren(), and text.

◆ ClearConnections()

void SCH_ITEM::ClearConnections ( )
inlineinherited

Clears all of the connection items from the list.

The vector release method is used to prevent the item pointers from being deleted. Do not use the vector erase method on the connection list.

Definition at line 372 of file sch_item.h.

372{ m_connections.clear(); }
EDA_ITEMS m_connections
Definition: sch_item.h:492

References SCH_ITEM::m_connections.

◆ ClearEditFlags()

◆ ClearFieldsAutoplaced()

◆ ClearFlags()

void EDA_ITEM::ClearFlags ( EDA_ITEM_FLAGS  aMask = EDA_ITEM_ALL_FLAGS)
inlineinherited

Definition at line 141 of file eda_item.h.

141{ m_flags &= ~aMask; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:498

References EDA_ITEM::m_flags.

Referenced by FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), PNS_KICAD_IFACE::AddItem(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_MOVE_TOOL::AlignElements(), SCH_EDIT_TOOL::BreakWire(), FOOTPRINT::BuildCourtyardCaches(), EDA_ITEM::ClearBrightened(), EDA_ITEM::ClearEditFlags(), EDA_ITEM::ClearSelected(), EDA_ITEM::ClearTempFlags(), SCH_EDIT_FRAME::ConvertPart(), SYMBOL_EDITOR_EDIT_TOOL::Copy(), FOOTPRINT_EDITOR_CONTROL::CreateFootprint(), SYMBOL_EDITOR_PIN_TOOL::CreateImagePins(), MICROWAVE_TOOL::createMicrowaveInductor(), DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES(), PCB_TOOL_BASE::doInteractiveItemPlacement(), KIGFX::SCH_PAINTER::draw(), SCH_ITEM::Duplicate(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PCB_EDIT_FRAME::ExchangeFootprint(), PCB_SELECTION_TOOL::ExitGroup(), SYMBOL_EDIT_FRAME::GetSymbolFromRedoList(), SYMBOL_EDIT_FRAME::GetSymbolFromUndoList(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), DRC_INTERACTIVE_COURTYARD_CLEARANCE::Init(), EE_COLLECTOR::Inspect(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromLibrary(), FOOTPRINT_EDITOR_CONTROL::NewFootprint(), DIALOG_SYMBOL_PROPERTIES::OnUnitChoice(), FOOTPRINT_EDIT_FRAME::OpenProjectFiles(), PCB_BASE_FRAME::PlaceFootprint(), SYMBOL_EDITOR_PIN_TOOL::PlacePin(), BOARD_COMMIT::Push(), PCB_SELECTION_TOOL::RebuildSelection(), PAD_TOOL::RecombinePad(), SCH_EDIT_TOOL::RepeatDrawItem(), SYMBOL_EDIT_FRAME::RollbackSymbolFromUndo(), DRC_TEST_PROVIDER_DISALLOW::Run(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), SCH_SEXPR_PLUGIN_CACHE::savePin(), EE_SELECTION_TOOL::selectMultiple(), SCH_EDIT_FRAME::SelectUnit(), EDA_ITEM::SetIsShownAsBitmap(), BOARD_COMMIT::Stage(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), SCH_DRAWING_TOOLS::TwoClickPlace(), and EE_SELECTION_TOOL::unhighlight().

◆ ClearSelected()

◆ ClearTempFlags()

void EDA_ITEM::ClearTempFlags ( )
inlineinherited

Definition at line 153 of file eda_item.h.

154 {
156 }
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
#define SELECTED_BY_DRAG
Item was algorithmically selected as a dragged item.
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define CANDIDATE
flag indicating that the structure is connected

References CANDIDATE, EDA_ITEM::ClearFlags(), IS_LINKED, SELECTED_BY_DRAG, and SKIP_STRUCT.

Referenced by PCB_EDIT_FRAME::OpenProjectFiles(), and SCH_EDIT_FRAME::PutDataInPreviousState().

◆ ClearViewPrivData()

void KIGFX::VIEW_ITEM::ClearViewPrivData ( )
inlineinherited

Definition at line 143 of file view_item.h.

144 {
145 m_viewPrivData = nullptr;
146 }
VIEW_ITEM_DATA * m_viewPrivData
Definition: view_item.h:151

References KIGFX::VIEW_ITEM::m_viewPrivData.

Referenced by KIGFX::VIEW::OnDestroy().

◆ Clone()

EDA_ITEM * SCH_SYMBOL::Clone ( ) const
overridevirtual

Create a duplicate of this item with linked list members set to NULL.

The default version will return NULL in release builds and likely crash the program. In debug builds, a warning message indicating the derived class has not implemented cloning. This really should be a pure virtual function. Due to the fact that there are so many objects derived from EDA_ITEM, the decision was made to return NULL until all the objects derived from EDA_ITEM implement cloning. Once that happens, this function should be made pure.

Returns
A clone of the item.

Reimplemented from EDA_ITEM.

Definition at line 230 of file sch_symbol.cpp.

231{
232 return new SCH_SYMBOL( *this );
233}

References SCH_SYMBOL().

◆ ConnectedItems()

SCH_ITEM_SET & SCH_ITEM::ConnectedItems ( const SCH_SHEET_PATH aPath)
inherited

Retrieve the set of items connected to this item on the given sheet.

Definition at line 187 of file sch_item.cpp.

188{
189 return m_connected_items[ aSheet ];
190}

References SCH_ITEM::m_connected_items.

Referenced by addConnections(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_LINE::FindWireSegmentNetNameRecursive(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ Connection()

SCH_CONNECTION * SCH_ITEM::Connection ( const SCH_SHEET_PATH aSheet = nullptr) const
inherited

Retrieve the connection associated with this object in the given sheet.

Note
The returned value can be nullptr.

Definition at line 146 of file sch_item.cpp.

147{
148 if( !IsConnectable() )
149 return nullptr;
150
151 wxCHECK_MSG( !IsConnectivityDirty(), nullptr,
152 wxT( "Shouldn't be asking for connection if connectivity is dirty!" ) );
153
154 if( !aSheet )
155 aSheet = &Schematic()->CurrentSheet();
156
157 auto it = m_connection_map.find( *aSheet );
158
159 if( it == m_connection_map.end() )
160 return nullptr;
161 else
162 return it->second;
163}
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:122
virtual bool IsConnectable() const
Definition: sch_item.h:349
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:112
bool IsConnectivityDirty() const
Definition: sch_item.h:413
std::unordered_map< SCH_SHEET_PATH, SCH_CONNECTION * > m_connection_map
Store connectivity information, per sheet.
Definition: sch_item.h:501

References SCHEMATIC::CurrentSheet(), SCH_ITEM::IsConnectable(), SCH_ITEM::IsConnectivityDirty(), SCH_ITEM::m_connection_map, and SCH_ITEM::Schematic().

Referenced by CONNECTION_SUBGRAPH::Absorb(), CONNECTION_SUBGRAPH::AddItem(), CONNECTION_GRAPH::buildConnectionGraph(), KIGFX::SCH_PAINTER::draw(), CONNECTION_GRAPH::ercCheckBusToBusConflicts(), CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts(), CONNECTION_GRAPH::GetBusesNeedingMigration(), SCH_ITEM::GetEffectiveNetClass(), SCH_BUS_ENTRY_BASE::GetMsgPanelInfo(), SCH_LABEL_BASE::GetMsgPanelInfo(), SCH_LINE::GetMsgPanelInfo(), SCH_PIN::GetMsgPanelInfo(), CONNECTION_SUBGRAPH::GetNetName(), SCH_ITEM::GetOrInitConnection(), highlightNet(), SCH_ITEM::InitializeConnection(), SCH_LABEL_BASE::Plot(), SCH_LINE::Plot(), SCH_TEXT::Plot(), SCH_LABEL_BASE::Print(), NETLIST_EXPORTER_SPICE_MODEL::readPorts(), SCH_EDIT_FRAME::RecalculateConnections(), SCH_LABEL_BASE::ResolveTextVar(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataToWindow(), BUS_UNFOLD_MENU::update(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ ConnectionPropagatesTo()

virtual bool SCH_ITEM::ConnectionPropagatesTo ( const EDA_ITEM aItem) const
inlinevirtualinherited

Return true if this item should propagate connection info to aItem.

Reimplemented in SCH_BUS_WIRE_ENTRY, SCH_LINE, and SCH_PIN.

Definition at line 411 of file sch_item.h.

411{ return true; }

◆ doGetBoundingBox()

BOX2I SCH_SYMBOL::doGetBoundingBox ( bool  aIncludePins,
bool  aIncludeFields 
) const
private

Definition at line 1552 of file sch_symbol.cpp.

1553{
1554 BOX2I bBox;
1555
1556 if( m_part )
1557 bBox = m_part->GetBodyBoundingBox( m_unit, m_convert, aIncludePins, false );
1558 else
1559 bBox = dummy()->GetBodyBoundingBox( m_unit, m_convert, aIncludePins, false );
1560
1561 int x0 = bBox.GetX();
1562 int xm = bBox.GetRight();
1563
1564 // We must reverse Y values, because matrix orientation
1565 // suppose Y axis normal for the library items coordinates,
1566 // m_transform reverse Y values, but bBox is already reversed!
1567 int y0 = -bBox.GetY();
1568 int ym = -bBox.GetBottom();
1569
1570 // Compute the real Boundary box (rotated, mirrored ...)
1571 int x1 = m_transform.x1 * x0 + m_transform.y1 * y0;
1572 int y1 = m_transform.x2 * x0 + m_transform.y2 * y0;
1573 int x2 = m_transform.x1 * xm + m_transform.y1 * ym;
1574 int y2 = m_transform.x2 * xm + m_transform.y2 * ym;
1575
1576 bBox.SetX( x1 );
1577 bBox.SetY( y1 );
1578 bBox.SetWidth( x2 - x1 );
1579 bBox.SetHeight( y2 - y1 );
1580 bBox.Normalize();
1581
1582 bBox.Offset( m_pos );
1583
1584 if( aIncludeFields )
1585 {
1586 for( const SCH_FIELD& field : m_fields )
1587 {
1588 if( field.IsVisible() )
1589 bBox.Merge( field.GetBoundingBox() );
1590 }
1591 }
1592
1593 return bBox;
1594}
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:119
void Offset(coord_type dx, coord_type dy)
Definition: box2.h:224
void SetX(coord_type val)
Definition: box2.h:235
void SetY(coord_type val)
Definition: box2.h:240
coord_type GetY() const
Definition: box2.h:181
void SetWidth(coord_type val)
Definition: box2.h:245
coord_type GetX() const
Definition: box2.h:180
coord_type GetRight() const
Definition: box2.h:189
void SetHeight(coord_type val)
Definition: box2.h:250
coord_type GetBottom() const
Definition: box2.h:190
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h:588
const BOX2I GetBodyBoundingBox(int aUnit, int aConvert, bool aIncludePins, bool aIncludePrivateItems) const
Get the symbol bounding box excluding fields.
Definition: lib_symbol.cpp:997
int x2
Definition: transform.h:51
int y1
Definition: transform.h:50
int y2
Definition: transform.h:52
int x1
Definition: transform.h:49
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:78

References dummy(), LIB_SYMBOL::GetBodyBoundingBox(), BOX2< Vec >::GetBottom(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), m_convert, m_fields, m_part, m_pos, m_transform, m_unit, BOX2< Vec >::Merge(), BOX2< Vec >::Normalize(), BOX2< Vec >::Offset(), BOX2< Vec >::SetHeight(), BOX2< Vec >::SetWidth(), BOX2< Vec >::SetX(), BOX2< Vec >::SetY(), TRANSFORM::x1, TRANSFORM::x2, TRANSFORM::y1, and TRANSFORM::y2.

Referenced by GetBodyAndPinsBoundingBox(), GetBodyBoundingBox(), and GetBoundingBox().

◆ DoHypertextAction()

virtual void SCH_ITEM::DoHypertextAction ( EDA_DRAW_FRAME aFrame) const
inlinevirtualinherited

Reimplemented in SCH_FIELD, SCH_TEXT, and SCH_TEXTBOX.

Definition at line 241 of file sch_item.h.

241{ }

◆ doIsConnected()

bool SCH_SYMBOL::doIsConnected ( const VECTOR2I aPosition) const
overrideprivatevirtual

Provide the object specific test to see if it is connected to aPosition.

Note
Override this function if the derived object can be connect to another object such as a wire, bus, or junction. Do not override this function for objects that cannot have connections. The default will always return false. This functions is call through the public function IsConnected() which performs tests common to all schematic items before calling the item specific connection testing.
Parameters
aPositionis a reference to a VECTOR2I object containing the test position.
Returns
True if connection to aPosition exists.

Reimplemented from SCH_ITEM.

Definition at line 2062 of file sch_symbol.cpp.

2063{
2065
2066 for( const auto& pin : m_pins )
2067 {
2068 if( pin->GetType() == ELECTRICAL_PINTYPE::PT_NC )
2069 continue;
2070
2071 // Collect only pins attached to the current unit and convert.
2072 // others are not associated to this symbol instance
2073 int pin_unit = pin->GetLibPin()->GetUnit();
2074 int pin_convert = pin->GetLibPin()->GetConvert();
2075
2076 if( pin_unit > 0 && pin_unit != GetUnit() )
2077 continue;
2078
2079 if( pin_convert > 0 && pin_convert != GetConvert() )
2080 continue;
2081
2082 if( pin->GetLocalPosition() == new_pos )
2083 return true;
2084 }
2085
2086 return false;
2087}
int GetUnit() const
Definition: sch_symbol.h:228
int GetConvert() const
Definition: sch_symbol.h:270
TRANSFORM InverseTransform() const
Calculate the Inverse mirror/rotation transform.
Definition: transform.cpp:60
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:45
@ PT_NC
not connected (must be left open)

References GetConvert(), GetUnit(), TRANSFORM::InverseTransform(), m_pins, m_pos, m_transform, pin, PT_NC, and TRANSFORM::TransformCoordinate().

◆ Duplicate()

SCH_ITEM * SCH_ITEM::Duplicate ( bool  doClone = false) const
inherited

Routine to create a new copy of given item.

The new object is not put in draw list (not linked).

Parameters
doClone(default = false) indicates unique values (such as timestamp and sheet name) should be duplicated. Use only for undo/redo operations.

Definition at line 93 of file sch_item.cpp.

94{
95 SCH_ITEM* newItem = (SCH_ITEM*) Clone();
96
97 if( !doClone )
98 const_cast<KIID&>( newItem->m_Uuid ) = KIID();
99
100 newItem->ClearFlags( SELECTED | BRIGHTENED );
101
102 newItem->RunOnChildren(
103 []( SCH_ITEM* aChild )
104 {
105 aChild->ClearFlags( SELECTED | BRIGHTENED );
106 } );
107
108 return newItem;
109}
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:82

References BRIGHTENED, EDA_ITEM::ClearFlags(), EDA_ITEM::Clone(), EDA_ITEM::m_Uuid, SCH_ITEM::RunOnChildren(), and SELECTED.

Referenced by SCH_LINE::BreakAt(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), CADSTAR_SCH_ARCHIVE_LOADER::loadItemOntoKiCadSheet(), SCH_EAGLE_PLUGIN::loadSchematic(), SCH_DRAWING_TOOLS::PlaceSymbol(), SCH_EDIT_TOOL::RepeatDrawItem(), SCH_EDIT_FRAME::SaveCopyInUndoList(), and SCH_LINE_WIRE_BUS_TOOL::startSegments().

◆ FindField()

SCH_FIELD * SCH_SYMBOL::FindField ( const wxString &  aFieldName,
bool  aIncludeDefaultFields = true 
)

Search for a SCH_FIELD with aFieldName.

Parameters
aFieldNameis the name of the field to find.
aIncludeDefaultFieldssearches the library symbol default fields if true.
Returns
the field if found or NULL if the field was not found.

Definition at line 916 of file sch_symbol.cpp.

917{
918 unsigned start = aIncludeDefaultFields ? 0 : MANDATORY_FIELDS;
919
920 for( unsigned i = start; i < m_fields.size(); ++i )
921 {
922 if( aFieldName == m_fields[i].GetName( false ) )
923 return &m_fields[i];
924 }
925
926 return nullptr;
927}
@ MANDATORY_FIELDS
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.

References m_fields, and MANDATORY_FIELDS.

Referenced by FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), and UpdateFields().

◆ Get() [1/3]

template<typename T >
std::optional< T > INSPECTABLE::Get ( const wxString &  aProperty) const
inlineinherited

Definition at line 104 of file inspectable.h.

105 {
107 TYPE_ID thisType = TYPE_HASH( *this );
108 PROPERTY_BASE* prop = propMgr.GetProperty( thisType, aProperty );
109 std::optional<T> ret;
110
111 if( prop )
112 {
113 const void* object = propMgr.TypeCast( this, thisType, prop->OwnerHash() );
114
115 if( object )
116 ret = prop->get<T>( object );
117 }
118
119 return ret;
120 }
virtual size_t OwnerHash() const =0
Return type-id of the Owner class.
T get(const void *aObject) const
Definition: property.h:316
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:74
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:76
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Return a property for a specific type.
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.
#define TYPE_HASH(x)
Definition: property.h:62
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:46

References PROPERTY_BASE::get(), PROPERTY_MANAGER::GetProperty(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ Get() [2/3]

wxAny INSPECTABLE::Get ( PROPERTY_BASE aProperty) const
inlineinherited

Definition at line 84 of file inspectable.h.

85 {
87 const void* object = propMgr.TypeCast( this, TYPE_HASH( *this ), aProperty->OwnerHash() );
88 return object ? aProperty->getter( object ) : wxAny();
89 }
virtual wxAny getter(const void *aObject) const =0

References PROPERTY_BASE::getter(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

Referenced by BOOST_AUTO_TEST_CASE(), CLASS_D_DESC::CLASS_D_DESC(), EDA_SHAPE_DESC::EDA_SHAPE_DESC(), PROPERTIES_PANEL::getItemValue(), PCB_EXPR_VAR_REF::GetValue(), and PAD_DESC::PAD_DESC().

◆ Get() [3/3]

template<typename T >
T INSPECTABLE::Get ( PROPERTY_BASE aProperty) const
inlineinherited

Definition at line 92 of file inspectable.h.

93 {
95 const void* object = propMgr.TypeCast( this, TYPE_HASH( *this ), aProperty->OwnerHash() );
96
97 if( !object )
98 throw std::runtime_error( "Could not cast INSPECTABLE to the requested type" );
99
100 return aProperty->get<T>( object );
101 }

References PROPERTY_BASE::get(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ GetAllLibPins()

std::vector< LIB_PIN * > SCH_SYMBOL::GetAllLibPins ( ) const
Returns
a list of pin pointers for all units / converts. Used primarily for SPICE where we want to treat all units together as a single SPICE element.

Definition at line 1028 of file sch_symbol.cpp.

1029{
1030 std::vector<LIB_PIN*> pinList;
1031
1032 if( m_part )
1033 m_part->GetPins( pinList, 0, 0 );
1034
1035 return pinList;
1036}

References m_part.

Referenced by SIM_LIB_MGR::CreateModel(), and GetFullPinCount().

◆ GetBodyAndPinsBoundingBox()

BOX2I SCH_SYMBOL::GetBodyAndPinsBoundingBox ( ) const

Return a bounding box for the symbol body and pins but not the fields.

Definition at line 1603 of file sch_symbol.cpp.

1604{
1605 return doGetBoundingBox( true, false );
1606}
BOX2I doGetBoundingBox(bool aIncludePins, bool aIncludeFields) const

References doGetBoundingBox().

Referenced by KIGFX::SCH_PAINTER::draw(), AUTOPLACER::getPossibleCollisions(), EE_SELECTION_TOOL::GuessSelectionCandidates(), CADSTAR_SCH_ARCHIVE_LOADER::Load(), operator<(), PlotDNP(), and Print().

◆ GetBodyBoundingBox()

BOX2I SCH_SYMBOL::GetBodyBoundingBox ( ) const

Return a bounding box for the symbol body but not the pins or fields.

Definition at line 1597 of file sch_symbol.cpp.

1598{
1599 return doGetBoundingBox( false, false );
1600}

References doGetBoundingBox().

Referenced by AUTOPLACER::AUTOPLACER(), KIGFX::SCH_PAINTER::draw(), EE_SELECTION_TOOL::GuessSelectionCandidates(), and HitTest().

◆ GetBoundingBox()

const BOX2I SCH_SYMBOL::GetBoundingBox ( ) const
overridevirtual

Return the orthogonal bounding box of this object for display purposes.

This box should be an enclosing perimeter for visible components of this object, and the units should be in the pcb or schematic coordinate system. It is OK to overestimate the size by a few counts.

Reimplemented from EDA_ITEM.

Definition at line 1609 of file sch_symbol.cpp.

1610{
1611 return doGetBoundingBox( true, true );
1612}

References doGetBoundingBox().

Referenced by SCH_EDITOR_CONTROL::FindSymbolAndItem(), and Plot().

◆ GetClass()

wxString SCH_SYMBOL::GetClass ( ) const
inlineoverridevirtual

Return the class name.

Reimplemented from SCH_ITEM.

Definition at line 120 of file sch_symbol.h.

121 {
122 return wxT( "SCH_SYMBOL" );
123 }

Referenced by operator=().

◆ GetConnectionPoints()

std::vector< VECTOR2I > SCH_SYMBOL::GetConnectionPoints ( ) const
overridevirtual

Add all the connection points for this item to aPoints.

Not all schematic items have connection points so the default method does nothing.

Parameters
aPointsis the list of connection points to add to.

Reimplemented from SCH_ITEM.

Definition at line 1836 of file sch_symbol.cpp.

1837{
1838 std::vector<VECTOR2I> retval;
1839
1840 for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
1841 {
1842 // Collect only pins attached to the current unit and convert.
1843 // others are not associated to this symbol instance
1844 int pin_unit = pin->GetLibPin()->GetUnit();
1845 int pin_convert = pin->GetLibPin()->GetConvert();
1846
1847 if( pin_unit > 0 && pin_unit != GetUnit() )
1848 continue;
1849
1850 if( pin_convert > 0 && pin_convert != GetConvert() )
1851 continue;
1852
1853 retval.push_back( m_transform.TransformCoordinate( pin->GetLocalPosition() ) + m_pos );
1854 }
1855
1856 return retval;
1857}

References GetConvert(), GetUnit(), m_pins, m_pos, m_transform, pin, and TRANSFORM::TransformCoordinate().

◆ GetContextualTextVars()

void SCH_SYMBOL::GetContextualTextVars ( wxArrayString *  aVars) const

Return the list of system text vars & fields for this symbol.

Definition at line 1112 of file sch_symbol.cpp.

1113{
1114 for( int i = 0; i < MANDATORY_FIELDS; ++i )
1115 aVars->push_back( m_fields[i].GetCanonicalName().Upper() );
1116
1117 for( size_t i = MANDATORY_FIELDS; i < m_fields.size(); ++i )
1118 aVars->push_back( m_fields[i].GetName() );
1119
1120 aVars->push_back( wxT( "FOOTPRINT_LIBRARY" ) );
1121 aVars->push_back( wxT( "FOOTPRINT_NAME" ) );
1122 aVars->push_back( wxT( "UNIT" ) );
1123 aVars->push_back( wxT( "SYMBOL_LIBRARY" ) );
1124 aVars->push_back( wxT( "SYMBOL_NAME" ) );
1125 aVars->push_back( wxT( "SYMBOL_DESCRIPTION" ) );
1126 aVars->push_back( wxT( "SYMBOL_KEYWORDS" ) );
1127 aVars->push_back( wxT( "EXCLUDE_FROM_BOM" ) );
1128 aVars->push_back( wxT( "EXCLUDE_FROM_BOARD" ) );
1129 aVars->push_back( wxT( "DNP" ) );
1130}

References m_fields, and MANDATORY_FIELDS.

Referenced by DIALOG_SCH_FIELD_PROPERTIES::onScintillaCharAdded(), and DIALOG_TEXT_PROPERTIES::onScintillaCharAdded().

◆ GetConvert()

◆ GetDatasheet()

wxString SCH_SYMBOL::GetDatasheet ( ) const

Return the documentation text for the given part alias.

Definition at line 326 of file sch_symbol.cpp.

327{
328 if( m_part )
329 return m_part->GetDatasheetField().GetText();
330
331 return wxEmptyString;
332}

References m_part.

Referenced by UpdateFields().

◆ GetDefaultFont()

const wxString & SCH_ITEM::GetDefaultFont ( ) const
inherited

Definition at line 286 of file sch_item.cpp.

287{
288 EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
289
290 return cfg->m_Appearance.default_font;
291}
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111

References EESCHEMA_SETTINGS::APPEARANCE::default_font, EESCHEMA_SETTINGS::m_Appearance, and Pgm().

Referenced by SCH_FIELD::getDrawFont(), SCH_TEXT::getDrawFont(), SCH_TEXTBOX::getDrawFont(), SCH_FIELD::GetRenderCache(), and SCH_TEXTBOX::GetShownText().

◆ GetDescription()

wxString SCH_SYMBOL::GetDescription ( ) const
Returns
the associated LIB_SYMBOL's description field (or wxEmptyString).

Definition at line 308 of file sch_symbol.cpp.

309{
310 if( m_part )
311 return m_part->GetDescription();
312
313 return wxEmptyString;
314}

References m_part.

Referenced by NETLIST_EXPORTER_XML::makeSymbols(), and ResolveTextVar().

◆ GetDNP()

◆ GetDrawItem()

LIB_ITEM * SCH_SYMBOL::GetDrawItem ( const VECTOR2I aPosition,
KICAD_T  aType = TYPE_NOT_INIT 
)

Return the symbol library item at aPosition that is part of this symbol.

Parameters
aPositionis the schematic position of the symbol library object.
aTypeis the type of symbol library object to find or any if set to TYPE_NOT_INIT.
Returns
is the symbol library object if found otherwise NULL.

Definition at line 1860 of file sch_symbol.cpp.

1861{
1862 if( m_part )
1863 {
1864 // Calculate the position relative to the symbol.
1865 VECTOR2I libPosition = aPosition - m_pos;
1866
1867 return m_part->LocateDrawItem( m_unit, m_convert, aType, libPosition, m_transform );
1868 }
1869
1870 return nullptr;
1871}

References m_convert, m_part, m_pos, m_transform, and m_unit.

Referenced by SCH_SCREEN::GetPin().

◆ GetEditFlags()

EDA_ITEM_FLAGS EDA_ITEM::GetEditFlags ( ) const
inlineinherited

Definition at line 145 of file eda_item.h.

146 {
147 constexpr int mask =
149
150 return m_flags & mask;
151 }
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
#define IS_CHANGED
Item was edited, and modified.
#define IS_NEW
New item, just created.
#define IS_BROKEN
Is a segment just broken by BreakSegment.
#define STRUCT_DELETED
flag indication structures to be erased
#define IS_MOVING
Item being moved.

References IS_BROKEN, IS_CHANGED, IS_MOVING, IS_NEW, IS_PASTED, EDA_ITEM::m_flags, and STRUCT_DELETED.

Referenced by SCH_EDIT_TOOL::ChangeTextType(), EDA_ITEM::ClearEditFlags(), SCH_EDIT_FRAME::DeleteJunction(), SCH_EDIT_TOOL::editFieldText(), SYMBOL_EDITOR_PIN_TOOL::EditPinProperties(), SCH_EDITOR_CONTROL::EditWithSymbolEditor(), GetMsgPanelInfo(), SELECTION_CONDITIONS::Idle(), SELECTION_CONDITIONS::IdleSelection(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PCB_POINT_EDITOR::OnSelectionChange(), SYMBOL_EDITOR_EDIT_TOOL::Properties(), SCH_EDIT_FRAME::SelectUnit(), DIALOG_IMAGE_PROPERTIES::TransferDataFromWindow(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_DIMENSION_PROPERTIES::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), and DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow().

◆ GetEffectiveNetClass()

std::shared_ptr< NETCLASS > SCH_ITEM::GetEffectiveNetClass ( const SCH_SHEET_PATH aSheet = nullptr) const
inherited

Definition at line 166 of file sch_item.cpp.

167{
168 static std::shared_ptr<NETCLASS> nullNetclass = std::make_shared<NETCLASS>( wxEmptyString );
169
170 SCHEMATIC* schematic = Schematic();
171
172 if( schematic )
173 {
174 std::shared_ptr<NET_SETTINGS>& netSettings = schematic->Prj().GetProjectFile().m_NetSettings;
175 SCH_CONNECTION* connection = Connection( aSheet );
176
177 if( connection )
178 return netSettings->GetEffectiveNetClass( connection->Name() );
179 else
180 return netSettings->m_DefaultNetClass;
181 }
182
183 return nullNetclass;
184}
std::shared_ptr< NET_SETTINGS > m_NetSettings
Net settings for this project (owned here)
Definition: project_file.h:168
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:149
Holds all the data relating to one schematic.
Definition: schematic.h:61
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:76
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
wxString Name(bool aIgnoreSheet=false) const
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:146

References SCH_ITEM::Connection(), PROJECT::GetProjectFile(), PROJECT_FILE::m_NetSettings, SCH_CONNECTION::Name(), SCHEMATIC::Prj(), and SCH_ITEM::Schematic().

Referenced by SCH_BUS_ENTRY_BASE::GetBusEntryColor(), SCH_LINE::GetEffectiveLineStyle(), SCH_JUNCTION::getEffectiveShape(), SCH_FIELD::GetFieldColor(), SCH_JUNCTION::GetJunctionColor(), SCH_LABEL_BASE::GetLabelColor(), SCH_LINE::GetLineColor(), SCH_BUS_ENTRY_BASE::GetLineStyle(), SCH_BUS_ENTRY_BASE::GetMsgPanelInfo(), SCH_LABEL_BASE::GetMsgPanelInfo(), SCH_LINE::GetMsgPanelInfo(), SCH_BUS_WIRE_ENTRY::GetPenWidth(), SCH_BUS_BUS_ENTRY::GetPenWidth(), SCH_LINE::GetPenWidth(), SCH_LABEL_BASE::Plot(), SCH_LINE::Plot(), and SCH_LABEL_BASE::ResolveTextVar().

◆ GetEndPoints()

void SCH_SYMBOL::GetEndPoints ( std::vector< DANGLING_END_ITEM > &  aItemList)
overridevirtual

Add the schematic item end points to aItemList if the item has end points.

The default version doesn't do anything since many of the schematic object cannot be tested for dangling ends. If you add a new schematic item that can have a dangling end ( no connect ), override this method to provide the correct end points.

Parameters
aItemListis the list of DANGLING_END_ITEMS to add to.

Reimplemented from SCH_ITEM.

Definition at line 1762 of file sch_symbol.cpp.

1763{
1764 for( auto& pin : m_pins )
1765 {
1766 LIB_PIN* lib_pin = pin->GetLibPin();
1767
1768 if( lib_pin->GetUnit() && m_unit && ( m_unit != lib_pin->GetUnit() ) )
1769 continue;
1770
1771 DANGLING_END_ITEM item( PIN_END, lib_pin, GetPinPhysicalPosition( lib_pin ), this );
1772 aItemList.push_back( item );
1773 }
1774}
Helper class used to store the state of schematic items that can be connected to other schematic item...
Definition: sch_item.h:82
int GetUnit() const
Definition: lib_item.h:273
VECTOR2I GetPinPhysicalPosition(const LIB_PIN *Pin) const
@ PIN_END
Definition: sch_item.h:68

References GetPinPhysicalPosition(), LIB_ITEM::GetUnit(), m_pins, m_unit, pin, and PIN_END.

◆ GetField() [1/2]

const SCH_FIELD * SCH_SYMBOL::GetField ( MANDATORY_FIELD_T  aFieldNdx) const

Definition at line 849 of file sch_symbol.cpp.

850{
851 return &m_fields[aFieldType];
852}

References m_fields.

◆ GetField() [2/2]

◆ GetFieldById()

SCH_FIELD * SCH_SYMBOL::GetFieldById ( int  aFieldId)

Return a field in this symbol.

Parameters
aFieldIdis the id of the field requested. Note that this id ONLY SOMETIMES equates to the field's position in the vector.
Returns
is the field at aFieldType or NULL if the field does not exist.

Definition at line 855 of file sch_symbol.cpp.

856{
857 for( size_t ii = 0; ii < m_fields.size(); ++ii )
858 {
859 if( m_fields[ii].GetId() == aFieldId )
860 return &m_fields[ii];
861 }
862
863 return nullptr;
864}

References m_fields.

Referenced by SCH_SYMBOL(), and UpdateFields().

◆ GetFieldCount()

◆ GetFields() [1/3]

std::vector< SCH_FIELD > & SCH_SYMBOL::GetFields ( )
inline

Return a vector of fields from the symbol.

Definition at line 423 of file sch_symbol.h.

423{ return m_fields; }

References m_fields.

Referenced by operator==(), and Plot().

◆ GetFields() [2/3]

const std::vector< SCH_FIELD > & SCH_SYMBOL::GetFields ( ) const
inline

Definition at line 424 of file sch_symbol.h.

424{ return m_fields; }

References m_fields.

◆ GetFields() [3/3]

void SCH_SYMBOL::GetFields ( std::vector< SCH_FIELD * > &  aVector,
bool  aVisibleOnly 
)

◆ GetFieldsAutoplaced()

FIELDS_AUTOPLACED SCH_ITEM::GetFieldsAutoplaced ( ) const
inlineinherited

Return whether the fields have been automatically placed.

Definition at line 424 of file sch_item.h.

424{ return m_fieldsAutoplaced; }

References SCH_ITEM::m_fieldsAutoplaced.

Referenced by SCH_ITEM::AutoAutoplaceFields(), SCH_SEXPR_PLUGIN::saveSheet(), SCH_SEXPR_PLUGIN::saveSymbol(), and SCH_SEXPR_PLUGIN::saveText().

◆ GetFieldText()

wxString SCH_SYMBOL::GetFieldText ( const wxString &  aFieldName) const

Search for a field named aFieldName and returns text associated with this field.

Parameters
aFieldNameis the name of the field

Definition at line 867 of file sch_symbol.cpp.

868{
869 for( const SCH_FIELD& field : m_fields )
870 {
871 if( aFieldName == field.GetName() || aFieldName == field.GetCanonicalName() )
872 return field.GetText();
873 }
874
875 return wxEmptyString;
876}

References m_fields.

Referenced by FIELDS_EDITOR_GRID_DATA_MODEL::AddColumn(), SCH_ALTIUM_PLUGIN::ParseParameter(), NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries(), and DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow().

◆ GetFlags()

◆ GetFocusPosition()

virtual const VECTOR2I EDA_ITEM::GetFocusPosition ( ) const
inlinevirtualinherited

Similar to GetPosition, but allows items to return their visual center rather than their anchor.

Reimplemented in BOARD, PCB_SHAPE, and PCB_TRACK.

Definition at line 256 of file eda_item.h.

256{ return GetPosition(); }
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:249

References EDA_ITEM::GetPosition().

Referenced by SCH_EDIT_FRAME::FocusOnItem().

◆ GetFootprintFieldText()

const wxString SCH_SYMBOL::GetFootprintFieldText ( bool  aResolve) const

Definition at line 828 of file sch_symbol.cpp.

829{
830 if( aResolve )
832
833 return GetField( FOOTPRINT_FIELD )->GetText();
834}
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
wxString GetShownText(int aDepth=0, bool aAllowExtraText=true) const override
Return the string actually shown after processing of the base text.
Definition: sch_field.cpp:175
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:843
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".

References FOOTPRINT_FIELD, GetField(), SCH_FIELD::GetShownText(), and EDA_TEXT::GetText().

Referenced by FIELDS_EDITOR_GRID_DATA_MODEL::AddColumn(), NETLIST_EXPORTER_XML::addSymbolFields(), GetMsgPanelInfo(), netList(), SCH_FIELD::Replace(), ResolveTextVar(), SCH_SEXPR_PLUGIN::saveSymbol(), SCH_REFERENCE::SCH_REFERENCE(), NETLIST_EXPORTER_CADSTAR::WriteNetlist(), and NETLIST_EXPORTER_ORCADPCB2::WriteNetlist().

◆ GetFriendlyName()

wxString EDA_ITEM::GetFriendlyName ( ) const
virtualinherited

Reimplemented in PCB_SHAPE, PCB_TRACK, and ZONE.

Definition at line 310 of file eda_item.cpp.

311{
312 return GetTypeDesc();
313}
wxString GetTypeDesc() const
Return a translated description of the type for this EDA_ITEM for display in user facing messages.
Definition: eda_item.cpp:301

References EDA_ITEM::GetTypeDesc().

Referenced by PROPERTIES_PANEL::rebuildProperties().

◆ GetFullPinCount()

size_t SCH_SYMBOL::GetFullPinCount ( )
inline
Returns
a count of pins for all units / converts.

Definition at line 529 of file sch_symbol.h.

529{ return GetAllLibPins().size(); }
std::vector< LIB_PIN * > GetAllLibPins() const

References GetAllLibPins().

◆ GetIncludeInBom()

bool SCH_SYMBOL::GetIncludeInBom ( ) const
inline

◆ GetIncludeOnBoard()

◆ GetInstance()

bool SCH_SYMBOL::GetInstance ( SCH_SYMBOL_INSTANCE aInstance,
const KIID_PATH aSheetPath,
bool  aTestFromEnd = false 
) const

Definition at line 497 of file sch_symbol.cpp.

499{
500 for( const SCH_SYMBOL_INSTANCE& instance : m_instanceReferences )
501 {
502 if( !aTestFromEnd )
503 {
504 if( instance.m_Path == aSheetPath )
505 {
506 aInstance = instance;
507 return true;
508 }
509 }
510 else if( instance.m_Path.EndsWith( aSheetPath ) )
511 {
512 aInstance = instance;
513 return true;
514 }
515 }
516
517 return false;
518}

References m_instanceReferences.

Referenced by SCH_SHEET_PATH::AddNewSymbolInstances().

◆ GetInstanceReferences()

◆ GetItemDescription()

wxString SCH_SYMBOL::GetItemDescription ( UNITS_PROVIDER aUnitsProvider) const
overridevirtual

Return a user-visible description string of this item.

This description is used in disambiguation menus, the message panel, ERC/DRC reports, etc.

The default version of this function raises an assertion in the debug mode and returns a string to indicate that it was not overridden to provide the object specific text.

Returns
The menu text string.

Reimplemented from EDA_ITEM.

Definition at line 1874 of file sch_symbol.cpp.

1875{
1876 return wxString::Format( _( "Symbol %s [%s]" ),
1877 GetField( REFERENCE_FIELD )->GetShownText(),
1878 UnescapeString( GetLibId().GetLibItemName() ) );
1879}
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:175
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
wxString UnescapeString(const wxString &aSource)

References _, Format(), GetField(), GetLibId(), REFERENCE_FIELD, and UnescapeString().

◆ GetKeyWords()

wxString SCH_SYMBOL::GetKeyWords ( ) const
Returns
the associated LIB_SYMBOL's keywords field (or wxEmptyString).

Definition at line 317 of file sch_symbol.cpp.

318{
319 if( m_part )
320 return m_part->GetKeyWords();
321
322 return wxEmptyString;
323}

References m_part.

Referenced by ResolveTextVar().

◆ GetLayer()

◆ GetLibId()

◆ GetLibPins()

void SCH_SYMBOL::GetLibPins ( std::vector< LIB_PIN * > &  aPinsList) const

Populate a vector with all the pins from the library object.

Parameters
aPinsListis the list to populate with all of the pins.

Definition at line 1021 of file sch_symbol.cpp.

1022{
1023 if( m_part )
1024 m_part->GetPins( aPinsList, m_unit, m_convert );
1025}

References m_convert, m_part, and m_unit.

Referenced by SCH_SCREEN::GetPin().

◆ GetLibSymbolRef() [1/2]

◆ GetLibSymbolRef() [2/2]

const std::unique_ptr< LIB_SYMBOL > & SCH_SYMBOL::GetLibSymbolRef ( ) const
inline

Definition at line 193 of file sch_symbol.h.

193{ return m_part; }

References m_part.

◆ GetMenuImage()

BITMAPS SCH_SYMBOL::GetMenuImage ( ) const
overridevirtual

Return a pointer to an image to be used in menus.

The default version returns the right arrow image. Override this function to provide object specific menu images.

Returns
The menu image associated with the item.

Reimplemented from EDA_ITEM.

Definition at line 1694 of file sch_symbol.cpp.

1695{
1697}
@ add_component

References add_component.

◆ GetMsgPanelInfo()

void SCH_SYMBOL::GetMsgPanelInfo ( EDA_DRAW_FRAME aFrame,
std::vector< MSG_PANEL_ITEM > &  aList 
)
overridevirtual

Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.

Parameters
aListis the list to populate.

Reimplemented from EDA_ITEM.

Definition at line 1615 of file sch_symbol.cpp.

1616{
1617 wxString msg;
1618
1619 SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( aFrame );
1620 SCH_SHEET_PATH* currentSheet = schframe ? &schframe->GetCurrentSheet() : nullptr;
1621
1622 // part and alias can differ if alias is not the root
1623 if( m_part )
1624 {
1625 if( m_part.get() != dummy() )
1626 {
1627 if( m_part->IsPower() )
1628 {
1629 aList.emplace_back( _( "Power symbol" ), GetValueFieldText( true ) );
1630 }
1631 else
1632 {
1633 aList.emplace_back( _( "Reference" ), GetRef( currentSheet ) );
1634 aList.emplace_back( _( "Value" ), GetValueFieldText( true ) );
1635 aList.emplace_back( _( "Name" ), UnescapeString( GetLibId().GetLibItemName() ) );
1636 }
1637
1638#if 0 // Display symbol flags, for debug only
1639 aList.emplace_back( _( "flags" ), wxString::Format( "%X", GetEditFlags() ) );
1640#endif
1641
1642 if( !m_part->IsRoot() )
1643 {
1644 msg = _( "Missing parent" );
1645
1646 std::shared_ptr< LIB_SYMBOL > parent = m_part->GetParent().lock();
1647
1648 if( parent )
1649 msg = parent->GetName();
1650
1651 aList.emplace_back( _( "Derived from" ), UnescapeString( msg ) );
1652 }
1653 else if( !m_lib_id.GetLibNickname().empty() )
1654 {
1655 aList.emplace_back( _( "Library" ), m_lib_id.GetLibNickname() );
1656 }
1657 else
1658 {
1659 aList.emplace_back( _( "Library" ), _( "Undefined!!!" ) );
1660 }
1661
1662 // Display the current associated footprint, if exists.
1663 msg = GetFootprintFieldText( true );
1664
1665 if( msg.IsEmpty() )
1666 msg = _( "<Unknown>" );
1667
1668 aList.emplace_back( _( "Footprint" ), msg );
1669
1670 // Display description of the symbol, and keywords found in lib
1671 aList.emplace_back( _( "Description" ), m_part->GetDescription() );
1672 aList.emplace_back( _( "Keywords" ), m_part->GetKeyWords() );
1673 }
1674 }
1675 else
1676 {
1677 aList.emplace_back( _( "Reference" ), GetRef( currentSheet ) );
1678
1679 aList.emplace_back( _( "Value" ), GetValueFieldText( true ) );
1680 aList.emplace_back( _( "Name" ), GetLibId().GetLibItemName() );
1681
1682 wxString libNickname = GetLibId().GetLibNickname();
1683
1684 if( libNickname.empty() )
1685 msg = _( "No library defined!" );
1686 else
1687 msg.Printf( _( "Symbol not found in %s!" ), libNickname );
1688
1689 aList.emplace_back( _( "Library" ), msg );
1690 }
1691}
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:87
Schematic editor (Eeschema) main window.
SCH_SHEET_PATH & GetCurrentSheet() const
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:652
const wxString GetFootprintFieldText(bool aResolve) const
Definition: sch_symbol.cpp:828
const wxString GetValueFieldText(bool aResolve) const
Definition: sch_symbol.cpp:813
bool empty() const
Definition: utf8.h:103

References _, dummy(), UTF8::empty(), Format(), SCH_EDIT_FRAME::GetCurrentSheet(), EDA_ITEM::GetEditFlags(), GetFootprintFieldText(), GetLibId(), LIB_ID::GetLibNickname(), GetRef(), GetValueFieldText(), m_lib_id, m_part, and UnescapeString().

◆ GetOrientation()

int SCH_SYMBOL::GetOrientation ( ) const

Get the display symbol orientation.

Because there are different ways to have a given orientation/mirror, the orientation/mirror is not necessary what the user does. For example: a mirrorV then a mirrorH returns no mirror but a rotate. This function finds a rotation and a mirror value SYM_MIRROR_X because this is the first mirror option tested. This can differs from the orientation made by an user. A SYM_MIRROR_Y is returned as a SYM_MIRROR_X with an orientation 180 because they are equivalent.

See also
SYMBOL_ORIENTATION_T
Returns
the orientation and mirror of the symbol.

Definition at line 1483 of file sch_symbol.cpp.

1484{
1485 int rotate_values[] =
1486 {
1499 };
1500
1501 // Try to find the current transform option:
1502 TRANSFORM transform = m_transform;
1503 SCH_SYMBOL temp( *this );
1504
1505 for( int type_rotate : rotate_values )
1506 {
1507 temp.SetOrientation( type_rotate );
1508
1509 if( transform == temp.GetTransform() )
1510 return type_rotate;
1511 }
1512
1513 // Error: orientation not found in list (should not happen)
1514 wxFAIL_MSG( "Schematic symbol orientation matrix internal error." );
1515
1516 return SYM_NORMAL;
1517}
Schematic symbol object.
Definition: sch_symbol.h:81
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:47
@ SYM_ORIENT_270
@ SYM_MIRROR_Y
@ SYM_ORIENT_180
@ SYM_MIRROR_X
@ SYM_NORMAL
@ SYM_ORIENT_90
@ SYM_ORIENT_0

References GetTransform(), m_transform, SetOrientation(), SYM_MIRROR_X, SYM_MIRROR_Y, SYM_NORMAL, SYM_ORIENT_0, SYM_ORIENT_180, SYM_ORIENT_270, and SYM_ORIENT_90.

Referenced by KIGFX::SCH_PAINTER::draw(), SCH_SCREEN::GetLabelOrientationForPoint(), AUTOPLACER::getPreferredSides(), orientLabel(), SCH_SEXPR_PLUGIN::saveSymbol(), SCH_EDIT_TOOL::Swap(), and DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow().

◆ GetOrInitConnection()

SCH_CONNECTION * SCH_ITEM::GetOrInitConnection ( const SCH_SHEET_PATH aPath,
CONNECTION_GRAPH aGraph 
)
inherited

Definition at line 228 of file sch_item.cpp.

230{
231 if( !IsConnectable() )
232 return nullptr;
233
234 SetConnectivityDirty( false );
235
236 SCH_CONNECTION* connection = Connection( &aSheet );
237
238 if( connection )
239 return connection;
240 else
241 return InitializeConnection( aSheet, aGraph );
242}
SCH_CONNECTION * InitializeConnection(const SCH_SHEET_PATH &aPath, CONNECTION_GRAPH *aGraph)
Create a new connection object associated with this object.
Definition: sch_item.cpp:205
void SetConnectivityDirty(bool aDirty=true)
Definition: sch_item.h:415

References SCH_ITEM::Connection(), SCH_ITEM::InitializeConnection(), SCH_ITEM::IsConnectable(), and SCH_ITEM::SetConnectivityDirty().

◆ GetParent()

◆ GetPenWidth()

virtual int SCH_ITEM::GetPenWidth ( ) const
inlinevirtualinherited

◆ GetPin() [1/2]

SCH_PIN * SCH_SYMBOL::GetPin ( const wxString &  number) const

Find a symbol pin by number.

Parameters
numberis the number of the pin to find.
Returns
Pin object if found, otherwise NULL.

Definition at line 1009 of file sch_symbol.cpp.

1010{
1011 for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
1012 {
1013 if( pin->GetNumber() == aNumber )
1014 return pin.get();
1015 }
1016
1017 return nullptr;
1018}

References m_pins, and pin.

Referenced by BACK_ANNOTATE::applyChangelist(), KIGFX::SCH_PAINTER::draw(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), Plot(), PlotPins(), and DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow().

◆ GetPin() [2/2]

SCH_PIN * SCH_SYMBOL::GetPin ( LIB_PIN aLibPin) const
Returns
the SCH_PIN associated with a particular LIB_PIN.

Definition at line 1039 of file sch_symbol.cpp.

1040{
1041 wxASSERT( m_pinMap.count( aLibPin ) );
1042 return m_pins[ m_pinMap.at( aLibPin ) ].get();
1043}
std::unordered_map< LIB_PIN *, unsigned > m_pinMap
library pin pointer : SCH_PIN's index
Definition: sch_symbol.h:791

References m_pinMap, and m_pins.

◆ GetPinPhysicalPosition()

VECTOR2I SCH_SYMBOL::GetPinPhysicalPosition ( const LIB_PIN Pin) const

Definition at line 1827 of file sch_symbol.cpp.

1828{
1829 wxCHECK_MSG( Pin != nullptr && Pin->Type() == LIB_PIN_T, VECTOR2I( 0, 0 ),
1830 wxT( "Cannot get physical position of pin." ) );
1831
1833}
VECTOR2I GetPosition() const override
Definition: lib_pin.h:222
@ LIB_PIN_T
Definition: typeinfo.h:202

References LIB_PIN::GetPosition(), LIB_PIN_T, m_pos, m_transform, TRANSFORM::TransformCoordinate(), and EDA_ITEM::Type().

Referenced by SCH_EAGLE_PLUGIN::addImplicitConnections(), SCH_EAGLE_PLUGIN::checkConnections(), GetEndPoints(), and SCH_SCREEN::GetPin().

◆ GetPins()

std::vector< SCH_PIN * > SCH_SYMBOL::GetPins ( const SCH_SHEET_PATH aSheet = nullptr) const

Retrieve a list of the SCH_PINs for the given sheet path.

Since a symbol can have a different unit on a different instance of a sheet, this list returns the subset of pins that exist on a given sheet.

Returns
a vector of pointers (non-owning) to SCH_PINs

Definition at line 1046 of file sch_symbol.cpp.

1047{
1048 std::vector<SCH_PIN*> pins;
1049
1050 if( aSheet == nullptr )
1051 {
1052 wxCHECK_MSG( Schematic(), pins, "Can't call GetPins on a symbol with no schematic" );
1053
1054 aSheet = &Schematic()->CurrentSheet();
1055 }
1056
1057 int unit = GetUnitSelection( aSheet );
1058
1059 for( const std::unique_ptr<SCH_PIN>& p : m_pins )
1060 {
1061 if( unit && p->GetLibPin()->GetUnit() && ( p->GetLibPin()->GetUnit() != unit ) )
1062 continue;
1063
1064 pins.push_back( p.get() );
1065 }
1066
1067 return pins;
1068}
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
Definition: sch_symbol.cpp:771

References SCHEMATIC::CurrentSheet(), GetUnitSelection(), m_pins, and SCH_ITEM::Schematic().

Referenced by NETLIST_EXPORTER_BASE::CreatePinList(), AUTOPLACER::fieldBoxPlacement(), NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol(), findSymbolsAndPins(), SCH_PIN::GetDefaultNetName(), SCH_SCREEN::GetLabelOrientationForPoint(), highlightNet(), netList(), SCH_FIND_REPLACE_TOOL::nextMatch(), SCH_EDITOR_CONTROL::Paste(), AUTOPLACER::pinsOnSide(), TEST_SCH_PIN_FIXTURE::TEST_SCH_PIN_FIXTURE(), ERC_TESTER::TestNoConnectPins(), ERC_TESTER::TestOffGridEndpoints(), CONNECTION_GRAPH::updateItemConnectivity(), and SCH_EDITOR_CONTROL::UpdateNetHighlighting().

◆ GetPosition()

◆ GetPrefix()

wxString SCH_SYMBOL::GetPrefix ( ) const
inline

Definition at line 274 of file sch_symbol.h.

274{ return m_prefix; }

References m_prefix.

Referenced by SCH_LEGACY_PLUGIN::saveSymbol().

◆ GetRawPins()

std::vector< std::unique_ptr< SCH_PIN > > & SCH_SYMBOL::GetRawPins ( )
inline

◆ GetRef()

const wxString SCH_SYMBOL::GetRef ( const SCH_SHEET_PATH aSheet,
bool  aIncludeUnit = false 
) const

Return the reference for the given sheet path.

Returns
the reference for the sheet.

Definition at line 652 of file sch_symbol.cpp.

653{
654 KIID_PATH path = sheet->Path();
655 wxString ref;
656 wxString subRef;
657
658 for( const SCH_SYMBOL_INSTANCE& instance : m_instanceReferences )
659 {
660 if( instance.m_Path == path )
661 {
662 ref = instance.m_Reference;
663 subRef = LIB_SYMBOL::SubReference( instance.m_Unit );
664 break;
665 }
666 }
667
668 // If it was not found in m_Paths array, then see if it is in m_Field[REFERENCE] -- if so,
669 // use this as a default for this path. This will happen if we load a version 1 schematic
670 // file. It will also mean that multiple instances of the same sheet by default all have
671 // the same symbol references, but perhaps this is best.
672 if( ref.IsEmpty() && !GetField( REFERENCE_FIELD )->GetText().IsEmpty() )
673 {
674 const_cast<SCH_SYMBOL*>( this )->SetRef( sheet, GetField( REFERENCE_FIELD )->GetText() );
675 ref = GetField( REFERENCE_FIELD )->GetText();
676 }
677
678 if( ref.IsEmpty() )
680
681 if( aIncludeUnit && GetUnitCount() > 1 )
682 ref += subRef;
683
684 return ref;
685}
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Definition: lib_symbol.cpp:584
int GetUnitCount() const
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:423

References GetField(), UTIL::GetRefDesUnannotated(), EDA_TEXT::GetText(), EDA_UNIT_UTILS::GetText(), GetUnitCount(), m_instanceReferences, m_prefix, SCH_SHEET_PATH::Path(), path, REFERENCE_FIELD, SetRef(), and LIB_SYMBOL::SubReference().

Referenced by NETLIST_EXPORTER_XML::addSymbolFields(), SIM_PLOT_FRAME::AddTuner(), SCH_REFERENCE::AlwaysAnnotate(), SCH_EDIT_FRAME::AnnotateSymbols(), SCH_SHEET_PATH::AppendMultiUnitSymbol(), SCH_SHEET_PATH::AppendSymbol(), TEST_SCH_REFERENCE_LIST_FIXTURE::checkAnnotation(), SCHEMATIC::ConvertKIIDsToRefs(), SCHEMATIC::ConvertRefsToKIIDs(), SIM_LIB_MGR::CreateModel(), NETLIST_EXPORTER_BASE::CreatePinList(), DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS(), NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol(), NETLIST_EXPORTER_BASE::findNextSymbol(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), SCH_PIN::GetDefaultNetName(), SCH_PIN::GetMsgPanelInfo(), GetMsgPanelInfo(), DIALOG_EDIT_SYMBOLS_LIBID::initDlg(), DIALOG_CHANGE_SYMBOLS::isMatch(), TEST_SCH_REFERENCE_LIST_FIXTURE::loadTestCase(), NETLIST_EXPORTER_XML::makeSymbols(), SCH_EDIT_FRAME::mapExistingAnnotation(), SCH_FIELD::Matches(), netList(), NETLIST_EXPORTER_SPICE::readModel(), NETLIST_EXPORTER_SPICE::readRefName(), NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries(), SCH_REFERENCE_LIST::ReannotateByOptions(), SCH_FIELD::Replace(), SCHEMATIC::ResolveCrossReference(), ResolveTextVar(), SCH_EDIT_FRAME::SaveSymbolToSchematic(), SCH_REFERENCE::SCH_REFERENCE(), ERC_TESTER::TestMultiunitFootprints(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), TUNER_SLIDER::TUNER_SLIDER(), SCH_SHEET_PATH::UpdateAllScreenReferences(), DIALOG_SCH_FIELD_PROPERTIES::UpdateField(), NETLIST_EXPORTER_CADSTAR::WriteNetlist(), and NETLIST_EXPORTER_ORCADPCB2::WriteNetlist().

◆ GetSchSymbolLibraryName()

wxString SCH_SYMBOL::GetSchSymbolLibraryName ( ) const

◆ GetSortPosition()

virtual VECTOR2I EDA_ITEM::GetSortPosition ( ) const
inlinevirtualinherited

Return the coordinates that should be used for sorting this element visually compared to other elements.

For instance, for lines the midpoint might be a better sorting point than either end.

Returns
X,Y coordinate of the sort point

Reimplemented in SCH_LINE.

Definition at line 265 of file eda_item.h.

265{ return GetPosition(); }

References EDA_ITEM::GetPosition().

◆ GetState()

int EDA_ITEM::GetState ( EDA_ITEM_FLAGS  type) const
inlineinherited

Definition at line 123 of file eda_item.h.

124 {
125 return m_status & type;
126 }
EDA_ITEM_FLAGS m_status
Definition: eda_item.h:495

References EDA_ITEM::m_status.

◆ GetStatus()

EDA_ITEM_FLAGS EDA_ITEM::GetStatus ( ) const
inlineinherited

Definition at line 136 of file eda_item.h.

136{ return m_status; }

References EDA_ITEM::m_status.

◆ GetStoredPos()

VECTOR2I & SCH_ITEM::GetStoredPos ( )
inlineinherited

Definition at line 209 of file sch_item.h.

209{ return m_storedPos; }
VECTOR2I m_storedPos
Definition: sch_item.h:494

References SCH_ITEM::m_storedPos.

◆ GetStroke()

virtual STROKE_PARAMS SCH_ITEM::GetStroke ( ) const
inlinevirtualinherited

Reimplemented in SCH_BUS_ENTRY_BASE, SCH_LINE, and SCH_SHAPE.

Definition at line 457 of file sch_item.h.

457{ wxCHECK( false, STROKE_PARAMS() ); }
Simple container to manage line stroke parameters.
Definition: stroke_params.h:88

Referenced by DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem().

◆ GetTransform() [1/2]

◆ GetTransform() [2/2]

const TRANSFORM & SCH_SYMBOL::GetTransform ( ) const
inline

Definition at line 284 of file sch_symbol.h.

284{ return m_transform; }

References m_transform.

◆ GetTypeDesc()

wxString EDA_ITEM::GetTypeDesc ( ) const
inherited

Return a translated description of the type for this EDA_ITEM for display in user facing messages.

Definition at line 301 of file eda_item.cpp.

302{
303 //@see EDA_ITEM_DESC for definition of ENUM_MAP<KICAD_T>
304 wxString typeDescr = ENUM_MAP<KICAD_T>::Instance().ToString( Type() );
305
306 return wxGetTranslation( typeDescr );
307}
static ENUM_MAP< T > & Instance()
Definition: property.h:573

References ENUM_MAP< T >::Instance(), and EDA_ITEM::Type().

Referenced by PCB_GROUP::AddItem(), EDIT_TOOL::doMoveSelection(), and EDA_ITEM::GetFriendlyName().

◆ GetUnit()

◆ GetUnitCount()

int SCH_SYMBOL::GetUnitCount ( void  ) const

Return the number of units per package of the symbol.

Returns
the number of units per package or zero if the library entry cannot be found.

Definition at line 423 of file sch_symbol.cpp.

424{
425 if( m_part )
426 return m_part->GetUnitCount();
427
428 return 0;
429}

References m_part.

Referenced by NETLIST_EXPORTER_XML::addSymbolFields(), SCH_EDIT_FRAME::AnnotateSymbols(), GetRef(), SCH_FIELD::GetShownText(), DIALOG_EDIT_SYMBOLS_LIBID::initDlg(), SCH_FIELD::Matches(), SCH_DRAWING_TOOLS::PlaceSymbol(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), and DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow().

◆ GetUnitDisplayName()

wxString SCH_SYMBOL::GetUnitDisplayName ( int  aUnit)

Return the display name for a given unit aUnit.

Returns
the display name of a unit if set, or the ordinal name of the unit otherwise.

Definition at line 432 of file sch_symbol.cpp.

433{
434 wxCHECK( m_part, ( wxString::Format( _( "Unit %s" ), LIB_SYMBOL::SubReference( aUnit ) ) ) );
435
436 return m_part->GetUnitDisplayName( aUnit );
437}

References _, Format(), m_part, and LIB_SYMBOL::SubReference().

Referenced by DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow().

◆ GetUnitSelection()

int SCH_SYMBOL::GetUnitSelection ( const SCH_SHEET_PATH aSheet) const

Return the instance-specific unit selection for the given sheet path.

Definition at line 771 of file sch_symbol.cpp.

772{
773 KIID_PATH path = aSheet->Path();
774
775 for( const SCH_SYMBOL_INSTANCE& instance : m_instanceReferences )
776 {
777 if( instance.m_Path == path )
778 return instance.m_Unit;
779 }
780
781 // If it was not found in m_Paths array, then use m_unit. This will happen if we load a
782 // version 1 schematic file.
783 return m_unit;
784}

References m_instanceReferences, m_unit, SCH_SHEET_PATH::Path(), and path.

Referenced by NETLIST_EXPORTER_XML::addSymbolFields(), SCH_EDIT_FRAME::AnnotateSymbols(), KIGFX::SCH_PAINTER::draw(), GetPins(), CONNECTION_GRAPH::Recalculate(), ResolveTextVar(), SCH_REFERENCE::SCH_REFERENCE(), DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow(), and SCH_SHEET_PATH::UpdateAllScreenReferences().

◆ GetValueFieldText()

◆ HasBrightenedPins()

bool SCH_SYMBOL::HasBrightenedPins ( )

Definition at line 2218 of file sch_symbol.cpp.

2219{
2220 for( const auto& pin : m_pins )
2221 {
2222 if( pin->IsBrightened() )
2223 return true;
2224 }
2225
2226 return false;
2227}

References m_pins, and pin.

Referenced by SCH_EDITOR_CONTROL::UpdateNetHighlighting().

◆ HasFlag()

◆ HasLineStroke()

virtual bool SCH_ITEM::HasLineStroke ( ) const
inlinevirtualinherited

Check if this schematic item has line stoke properties.

See also
STROKE_PARAMS
Returns
true if this schematic item support line stroke properties. Otherwise, false.

Reimplemented in SCH_BUS_ENTRY_BASE, SCH_LINE, and SCH_SHAPE.

Definition at line 455 of file sch_item.h.

455{ return false; }

Referenced by SCH_EDIT_TOOL::Init(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem().

◆ HasUnitDisplayName()

bool SCH_SYMBOL::HasUnitDisplayName ( int  aUnit)

Return true if the given unit aUnit has a display name set.

Returns
true if the display name of a unit is set, otherwise false.

Definition at line 440 of file sch_symbol.cpp.

441{
442 wxCHECK( m_part, false );
443
444 return m_part->HasUnitDisplayName( aUnit );
445}

References m_part.

Referenced by DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow().

◆ HitTest() [1/2]

bool SCH_SYMBOL::HitTest ( const BOX2I aRect,
bool  aContained,
int  aAccuracy = 0 
) const
overridevirtual

Test if aRect intersects this item.

Parameters
aRectA reference to a BOX2I object containing the rectangle to test.
aContainedSet to true to test for containment instead of an intersection.
aAccuracyIncrease aRect by this amount.
Returns
True if aRect contains or intersects the item bounding box.

Reimplemented from EDA_ITEM.

Definition at line 2046 of file sch_symbol.cpp.

2047{
2049 return false;
2050
2051 BOX2I rect = aRect;
2052
2053 rect.Inflate( aAccuracy / 2 );
2054
2055 if( aContained )
2056 return rect.Contains( GetBodyBoundingBox() );
2057
2058 return rect.Intersects( GetBodyBoundingBox() );
2059}
bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:269
bool Contains(const Vec &aPoint) const
Definition: box2.h:141
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:506
BOX2I GetBodyBoundingBox() const
Return a bounding box for the symbol body but not the pins or fields.

References BOX2< Vec >::Contains(), GetBodyBoundingBox(), BOX2< Vec >::Inflate(), BOX2< Vec >::Intersects(), EDA_ITEM::m_flags, SKIP_STRUCT, and STRUCT_DELETED.

◆ HitTest() [2/2]

bool SCH_SYMBOL::HitTest ( const VECTOR2I aPosition,
int  aAccuracy = 0 
) const
overridevirtual

Test if aPosition is inside or on the boundary of this item.

Parameters
aPositionA reference to a VECTOR2I object containing the coordinates to test.
aAccuracyIncrease the item bounding box by this amount.
Returns
True if aPosition is within the item bounding box.

Reimplemented from EDA_ITEM.

Definition at line 2034 of file sch_symbol.cpp.

2035{
2036 BOX2I bBox = GetBodyBoundingBox();
2037 bBox.Inflate( aAccuracy / 2 );
2038
2039 if( bBox.Contains( aPosition ) )
2040 return true;
2041
2042 return false;
2043}

References BOX2< Vec >::Contains(), GetBodyBoundingBox(), and BOX2< Vec >::Inflate().

◆ Init()

void SCH_SYMBOL::Init ( const VECTOR2I pos = VECTOR2I( 0, 0 ))
private

Definition at line 200 of file sch_symbol.cpp.

201{
203 m_pos = pos;
204 m_unit = 1; // In multi unit chip - which unit to draw.
205 m_convert = LIB_ITEM::LIB_CONVERT::BASE; // De Morgan Handling
206
207 // The rotation/mirror transformation matrix. pos normal
209
210 // construct only the mandatory fields, which are the first 4 only.
211 for( int i = 0; i < MANDATORY_FIELDS; ++i )
212 {
213 m_fields.emplace_back( pos, i, this, TEMPLATE_FIELDNAME::GetDefaultFieldName( i ) );
214
215 if( i == REFERENCE_FIELD )
216 m_fields.back().SetLayer( LAYER_REFERENCEPART );
217 else if( i == VALUE_FIELD )
218 m_fields.back().SetLayer( LAYER_VALUEPART );
219 else
220 m_fields.back().SetLayer( LAYER_FIELDS );
221 }
222
223 m_prefix = wxString( wxT( "U" ) );
224 m_isInNetlist = true;
225 m_inBom = true;
226 m_onBoard = true;
227}
@ LAYER_DEVICE
Definition: layer_ids.h:357
@ LAYER_VALUEPART
Definition: layer_ids.h:353
@ LAYER_FIELDS
Definition: layer_ids.h:354
@ LAYER_REFERENCEPART
Definition: layer_ids.h:352
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslateForHI=false)
Return a default symbol field name for field aFieldNdx for all components.

References TEMPLATE_FIELDNAME::GetDefaultFieldName(), LAYER_DEVICE, LAYER_FIELDS, LAYER_REFERENCEPART, LAYER_VALUEPART, m_convert, m_fields, m_inBom, m_isInNetlist, SCH_ITEM::m_layer, m_onBoard, m_pos, m_prefix, m_transform, m_unit, MANDATORY_FIELDS, REFERENCE_FIELD, and VALUE_FIELD.

Referenced by SCH_SYMBOL().

◆ InitializeConnection()

SCH_CONNECTION * SCH_ITEM::InitializeConnection ( const SCH_SHEET_PATH aPath,
CONNECTION_GRAPH aGraph 
)
inherited

Create a new connection object associated with this object.

Parameters
aPathis the sheet path to initialize.

Definition at line 205 of file sch_item.cpp.

207{
208 SetConnectivityDirty( false );
209
210 SCH_CONNECTION* connection = Connection( &aSheet );
211
212 if( connection )
213 {
214 connection->Reset();
215 }
216 else
217 {
218 connection = new SCH_CONNECTION( this );
219 m_connection_map.insert( std::make_pair( aSheet, connection ) );
220 }
221
222 connection->SetGraph( aGraph );
223 connection->SetSheet( aSheet );
224 return connection;
225}
void Reset()
Clears connectivity information.
void SetGraph(CONNECTION_GRAPH *aGraph)
void SetSheet(SCH_SHEET_PATH aSheet)

References SCH_ITEM::Connection(), SCH_ITEM::m_connection_map, SCH_CONNECTION::Reset(), SCH_ITEM::SetConnectivityDirty(), SCH_CONNECTION::SetGraph(), and SCH_CONNECTION::SetSheet().

Referenced by SCH_ITEM::GetOrInitConnection().

◆ IsAnnotated()

bool SCH_SYMBOL::IsAnnotated ( const SCH_SHEET_PATH aSheet)

Check if the symbol has a valid annotation (reference) for the given sheet path.

Parameters
aSheetis the sheet path to test.
Returns
true if the symbol exists on that sheet and has a valid reference.

Definition at line 730 of file sch_symbol.cpp.

731{
732 KIID_PATH path = aSheet->Path();
733
734 for( const SCH_SYMBOL_INSTANCE& instance : m_instanceReferences )
735 {
736 if( instance.m_Path == path )
737 return instance.m_Reference.Last() != '?';
738 }
739
740 return false;
741}

References m_instanceReferences, SCH_SHEET_PATH::Path(), and path.

Referenced by SCH_EDIT_FRAME::mapExistingAnnotation(), SCH_EDIT_FRAME::SaveSymbolToSchematic(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), and DIALOG_SCH_FIELD_PROPERTIES::UpdateField().

◆ IsBrightened()

◆ IsConnectable()

bool SCH_SYMBOL::IsConnectable ( ) const
inlineoverridevirtual
Returns
true if the schematic item can connect to another schematic item.

Reimplemented from SCH_ITEM.

Definition at line 666 of file sch_symbol.h.

666{ return true; }

◆ IsConnected()

bool SCH_ITEM::IsConnected ( const VECTOR2I aPoint) const
inherited

Test the item to see if it is connected to aPoint.

Parameters
aPointis a reference to a VECTOR2I object containing the coordinates to test.
Returns
True if connection to aPoint exists.

Definition at line 137 of file sch_item.cpp.

138{
139 if(( m_flags & STRUCT_DELETED ) || ( m_flags & SKIP_STRUCT ) )
140 return false;
141
142 return doIsConnected( aPosition );
143}
virtual bool doIsConnected(const VECTOR2I &aPosition) const
Provide the object specific test to see if it is connected to aPosition.
Definition: sch_item.h:488

References SCH_ITEM::doIsConnected(), EDA_ITEM::m_flags, SKIP_STRUCT, and STRUCT_DELETED.

Referenced by SCH_SCREEN::doIsJunction(), SCH_MOVE_TOOL::getConnectedItems(), SCH_SCREEN::IsTerminalPoint(), and SCH_SCREEN::MarkConnections().

◆ IsConnectivityDirty()

◆ IsDangling()

virtual bool SCH_ITEM::IsDangling ( ) const
inlinevirtualinherited

Reimplemented in SCH_BUS_ENTRY_BASE, SCH_LABEL_BASE, SCH_LINE, and SCH_PIN.

Definition at line 342 of file sch_item.h.

342{ return false; }

Referenced by SCH_EDIT_TOOL::ChangeTextType(), and KIGFX::SCH_PAINTER::draw().

◆ IsEntered()

bool EDA_ITEM::IsEntered ( ) const
inlineinherited

Definition at line 107 of file eda_item.h.

107{ return m_flags & ENTERED; }
#define ENTERED
indicates a group has been entered

References ENTERED, and EDA_ITEM::m_flags.

Referenced by KIGFX::PCB_PAINTER::draw().

◆ IsForceVisible()

bool EDA_ITEM::IsForceVisible ( ) const
inlineinherited

Definition at line 201 of file eda_item.h.

201{ return m_forceVisible; }
bool m_forceVisible
Definition: eda_item.h:497

References EDA_ITEM::m_forceVisible.

Referenced by KIGFX::SCH_PAINTER::draw(), and SCH_FIELD::Print().

◆ IsHypertext()

virtual bool SCH_ITEM::IsHypertext ( ) const
inlinevirtualinherited

Allow items to support hypertext actions when hovered/clicked.

Reimplemented in SCH_FIELD, SCH_TEXT, and SCH_TEXTBOX.

Definition at line 239 of file sch_item.h.

239{ return false; }

Referenced by SCH_ITEM::RenderAsBitmap().

◆ IsInNetlist()

bool SCH_SYMBOL::IsInNetlist ( ) const
Returns
true if the symbol is in netlist.

Definition at line 2090 of file sch_symbol.cpp.

2091{
2092 return m_isInNetlist;
2093}

References m_isInNetlist.

Referenced by AUTOPLACER::AUTOPLACER().

◆ IsLocked()

virtual bool SCH_ITEM::IsLocked ( ) const
inlinevirtualinherited
Returns
true if the object is locked, else false.

Definition at line 229 of file sch_item.h.

229{ return false; }

◆ IsMissingLibSymbol()

bool SCH_SYMBOL::IsMissingLibSymbol ( ) const

Check to see if the library symbol is set to the dummy library symbol.

When the library symbol is missing (which technically should not happen now that the library symbols are cached in the schematic file), a dummy library symbol is substituted for the missing symbol as an indicator that something is amiss. The dummy symbol cannot be edited so a check for this symbol must be performed before attempting to edit the library symbol with the library editor or it will crash KiCad.

See also
dummy()
Returns
true if the library symbol is missing or false if it is valid.

Definition at line 236 of file sch_symbol.cpp.

237{
238 if( !m_part )
239 return true;
240
241 return false;
242}

References m_part.

Referenced by SCH_EDITOR_CONTROL::EditWithSymbolEditor(), and SCH_EDIT_TOOL::Properties().

◆ IsModified()

bool EDA_ITEM::IsModified ( ) const
inlineinherited

Definition at line 102 of file eda_item.h.

102{ return m_flags & IS_CHANGED; }

References IS_CHANGED, and EDA_ITEM::m_flags.

Referenced by PCB_EDIT_FRAME::OpenProjectFiles().

◆ IsMovableFromAnchorPoint()

bool SCH_SYMBOL::IsMovableFromAnchorPoint ( ) const
overridevirtual

Return true for items which are moved with the anchor point at mouse cursor and false for items moved with no reference to anchor.

Usually return true for small items (labels, junctions) and false for items which can be large (hierarchical sheets, symbols).

Note
We used to try and be smart about this and return false for symbols in case they are big. However, this annoyed some users and we now have a preference which controls warping on move in general, so this was switched to true for symbols.
We now use this to keep poorly-formed symbols from getting dragged off-grid. If the symbol contains off-grid pins we will not allow it to be moved from its anchor.

Reimplemented from SCH_ITEM.

Definition at line 259 of file sch_symbol.cpp.

260{
261 // If a symbol's anchor is not grid-aligned to its pins then moving from the anchor is
262 // going to end up moving the symbol's pins off-grid.
263
264 // The minimal grid size allowed to place a pin is 25 mils
265 const int min_grid_size = schIUScale.MilsToIU( 25 );
266
267 for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
268 {
269 if( ( ( pin->GetPosition().x - m_pos.x ) % min_grid_size ) != 0 )
270 return false;
271
272 if( ( ( pin->GetPosition().y - m_pos.y ) % min_grid_size ) != 0 )
273 return false;
274 }
275
276 return true;
277}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
constexpr int MilsToIU(int mils) const
Definition: base_units.h:94

References m_pins, m_pos, EDA_IU_SCALE::MilsToIU(), pin, schIUScale, VECTOR2< T >::x, and VECTOR2< T >::y.

◆ IsMoving()

◆ IsNew()

◆ IsPointClickableAnchor()

bool SCH_SYMBOL::IsPointClickableAnchor ( const VECTOR2I aPos) const
overridevirtual
Returns
true if the given point can start drawing (usually means the anchor is unused/free/dangling).

Reimplemented from SCH_ITEM.

Definition at line 2237 of file sch_symbol.cpp.

2238{
2239 for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
2240 {
2241 int pin_unit = pin->GetLibPin()->GetUnit();
2242 int pin_convert = pin->GetLibPin()->GetConvert();
2243
2244 if( pin_unit > 0 && pin_unit != GetUnit() )
2245 continue;
2246
2247 if( pin_convert > 0 && pin_convert != GetConvert() )
2248 continue;
2249
2250 if( pin->IsPointClickableAnchor( aPos ) )
2251 return true;
2252 }
2253
2254 return false;
2255}

References GetConvert(), GetUnit(), m_pins, and pin.

◆ IsReferenceStringValid()

bool SCH_SYMBOL::IsReferenceStringValid ( const wxString &  aReferenceString)
static

Test for an acceptable reference string.

An acceptable reference string must support unannotation i.e starts by letter

Parameters
aReferenceStringis the reference string to validate
Returns
true if reference string is valid.

Definition at line 688 of file sch_symbol.cpp.

689{
690 return !UTIL::GetRefDesPrefix( aReferenceString ).IsEmpty();
691}

References UTIL::GetRefDesPrefix().

Referenced by DIALOG_FIELD_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_SYMBOL_PROPERTIES::Validate(), and DIALOG_SYMBOL_PROPERTIES::Validate().

◆ IsReplaceable()

bool SCH_SYMBOL::IsReplaceable ( ) const
inlineoverridevirtual

Override this method in any derived object that supports test find and replace.

Returns
True if the item has replaceable text that can be modified using the find and replace dialog.

Reimplemented from EDA_ITEM.

Definition at line 710 of file sch_symbol.h.

710{ return true; }

◆ IsRollover()

bool EDA_ITEM::IsRollover ( ) const
inlineinherited

Definition at line 110 of file eda_item.h.

111 {
112 return ( m_flags & ( IS_ROLLOVER | IS_MOVING ) ) == IS_ROLLOVER;
113 }
#define IS_ROLLOVER
Rollover active. Used for hyperlink highlighting.

References IS_MOVING, IS_ROLLOVER, and EDA_ITEM::m_flags.

Referenced by KIGFX::SCH_PAINTER::draw().

◆ IsSelected()

bool EDA_ITEM::IsSelected ( ) const
inlineinherited

Definition at line 106 of file eda_item.h.

106{ return m_flags & SELECTED; }

References EDA_ITEM::m_flags, and SELECTED.

Referenced by ALIGN_DISTRIBUTE_TOOL::AlignBottom(), ALIGN_DISTRIBUTE_TOOL::AlignCenterX(), ALIGN_DISTRIBUTE_TOOL::AlignCenterY(), ALIGN_DISTRIBUTE_TOOL::AlignTop(), SCH_EDIT_TOOL::ChangeTextType(), SCH_EDIT_FRAME::ConvertPart(), DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS(), ALIGN_DISTRIBUTE_TOOL::doAlignLeft(), ALIGN_DISTRIBUTE_TOOL::doAlignRight(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersVertically(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsVertically(), EDIT_TOOL::doMoveSelection(), KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_PAINTER::draw(), KIGFX::PCB_PAINTER::Draw(), DS_PROXY_UNDO_ITEM::DS_PROXY_UNDO_ITEM(), KIGFX::GERBVIEW_RENDER_SETTINGS::GetColor(), KIGFX::DS_RENDER_SETTINGS::GetColor(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), SCH_MOVE_TOOL::getConnectedDragItems(), KIGFX::SCH_PAINTER::getLineWidth(), DIALOG_EXCHANGE_FOOTPRINTS::isMatch(), DIALOG_CHANGE_SYMBOLS::isMatch(), SCH_SCREEN::MarkConnections(), SCH_LINE::MergeOverlap(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), KIGFX::SCH_PAINTER::nonCached(), SCH_MOVE_TOOL::orthoLineDrag(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), BOARD_COMMIT::Push(), EE_SELECTION_TOOL::RebuildSelection(), PCB_SELECTION_TOOL::RebuildSelection(), RENDER_3D_OPENGL::renderFootprint(), SCH_EDIT_TOOL::Rotate(), EE_TOOL_BASE< T >::saveCopyInUndoList(), GERBVIEW_SELECTION_TOOL::select(), PCB_SELECTION_TOOL::select(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), KIGFX::SCH_PAINTER::setDeviceColors(), GERBVIEW_SELECTION_TOOL::unselect(), HIERARCHY_PANE::UpdateHierarchySelection(), PCB_BASE_FRAME::UpdateUserUnits(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem(), and DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::visitItem().

◆ IsShownAsBitmap()

bool EDA_ITEM::IsShownAsBitmap ( ) const
inlineinherited

Definition at line 173 of file eda_item.h.

173{ return m_flags & IS_SHOWN_AS_BITMAP; }
#define IS_SHOWN_AS_BITMAP

References IS_SHOWN_AS_BITMAP, and EDA_ITEM::m_flags.

◆ IsType()

bool SCH_ITEM::IsType ( const std::vector< KICAD_T > &  aScanTypes) const
inlineoverridevirtualinherited

Check whether the item is one of the listed types.

Parameters
aScanTypesList of item types
Returns
true if the item type is contained in the list aScanTypes

Reimplemented from EDA_ITEM.

Reimplemented in SCH_LABEL_BASE, and SCH_LINE.

Definition at line 162 of file sch_item.h.

163 {
164 if( EDA_ITEM::IsType( aScanTypes ) )
165 return true;
166
167 for( KICAD_T scanType : aScanTypes )
168 {
169 if( scanType == SCH_ITEM_LOCATE_WIRE_T && m_layer == LAYER_WIRE )
170 return true;
171
172 if ( scanType == SCH_ITEM_LOCATE_BUS_T && m_layer == LAYER_BUS )
173 return true;
174
175 if ( scanType == SCH_ITEM_LOCATE_GRAPHIC_LINE_T
176 && Type() == SCH_LINE_T && m_layer == LAYER_NOTES )
177 {
178 return true;
179 }
180 }
181
182 return false;
183 }
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:181
@ LAYER_NOTES
Definition: layer_ids.h:358
@ LAYER_BUS
Definition: layer_ids.h:345
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_ITEM_LOCATE_WIRE_T
Definition: typeinfo.h:170
@ SCH_ITEM_LOCATE_BUS_T
Definition: typeinfo.h:171
@ SCH_ITEM_LOCATE_GRAPHIC_LINE_T
Definition: typeinfo.h:172

References EDA_ITEM::IsType(), LAYER_BUS, LAYER_NOTES, LAYER_WIRE, SCH_ITEM::m_layer, SCH_ITEM_LOCATE_BUS_T, SCH_ITEM_LOCATE_GRAPHIC_LINE_T, SCH_ITEM_LOCATE_WIRE_T, SCH_LINE_T, and EDA_ITEM::Type().

Referenced by SCH_EDIT_TOOL::AutoplaceFields(), SCH_EDIT_FRAME::AutoRotateItem(), SCH_FIELD::IsType(), SCH_LABEL_BASE::IsType(), SCH_LINE::IsType(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ IterateForward() [1/2]

template<class T >
static INSPECT_RESULT EDA_ITEM::IterateForward ( std::deque< T > &  aList,
INSPECTOR  inspector,
void *  testData,
const std::vector< KICAD_T > &  scanTypes 
)
inlinestaticinherited

This changes first parameter to avoid the DList and use the main queue instead.

Definition at line 302 of file eda_item.h.

304 {
305 for( const auto& it : aList )
306 {
307 if( static_cast<EDA_ITEM*>( it )->Visit( inspector,
308 testData,
309 scanTypes ) == INSPECT_RESULT::QUIT )
310 {
312 }
313 }
314
316 }
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
virtual INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes)
May be re-implemented for each derived class in order to handle all the types given by its member dat...
Definition: eda_item.cpp:91

References CONTINUE, QUIT, and EDA_ITEM::Visit().

Referenced by GERBER_FILE_IMAGE::Visit().

◆ IterateForward() [2/2]

template<class T >
static INSPECT_RESULT EDA_ITEM::IterateForward ( std::vector< T > &  aList,
INSPECTOR  inspector,
void *  testData,
const std::vector< KICAD_T > &  scanTypes 
)
inlinestaticinherited

Change first parameter to avoid the DList and use std::vector instead.

Definition at line 322 of file eda_item.h.

324 {
325 for( const auto& it : aList )
326 {
327 if( static_cast<EDA_ITEM*>( it )->Visit( inspector,
328 testData,
329 scanTypes ) == INSPECT_RESULT::QUIT )
330 {
332 }
333 }
334
336 }

References CONTINUE, QUIT, and EDA_ITEM::Visit().

◆ Matches() [1/2]

bool SCH_SYMBOL::Matches ( const EDA_SEARCH_DATA aSearchData,
void *  aAuxData 
) const
overridevirtual

Compare the item against the search criteria in aSearchData.

The base class returns false since many of the objects derived from EDA_ITEM do not have any text to search.

Parameters
aSearchDataA reference to a wxFindReplaceData object containing the search criteria.
aAuxDataA pointer to optional data required for the search or NULL if not used.
Returns
True if the item's text matches the search criteria in aSearchData.

Reimplemented from EDA_ITEM.

Definition at line 1755 of file sch_symbol.cpp.

1756{
1757 // Symbols are searchable via the child field and pin item text.
1758 return false;
1759}

Referenced by SCH_DRAWING_TOOLS::PlaceSymbol().

◆ Matches() [2/2]

bool EDA_ITEM::Matches ( const wxString &  aText,
const EDA_SEARCH_DATA aSearchData 
) const
protectedinherited

Compare aText against search criteria in aSearchData.

This is a helper function for simplify derived class logic.

Parameters
aTextA reference to a wxString object containing the string to test.
aSearchDataThe criteria to search against.
Returns
True if aText matches the search criteria in aSearchData.

Definition at line 117 of file eda_item.cpp.

118{
119 wxString text = aText;
120 wxString searchText = aSearchData.findString;
121
122 // Don't match if searching for replaceable item and the item doesn't support text replace.
123 if( aSearchData.searchAndReplace && !IsReplaceable() )
124 return false;
125
126 if( !aSearchData.matchCase )
127 {
128 text.MakeUpper();
129 searchText.MakeUpper();
130 }
131
133 {
134 int ii = 0;
135
136 while( ii < (int) text.length() )
137 {
138 int next = text.find( searchText, ii );
139
140 if( next == wxNOT_FOUND )
141 return false;
142
143 ii = next;
144 next += searchText.length();
145
146 bool startOK = ( ii == 0 || !wxIsalnum( text.GetChar( ii - 1 ) ) );
147 bool endOK = ( next == (int) text.length() || !wxIsalnum( text.GetChar( next ) ) );
148
149 if( startOK && endOK )
150 return true;
151 else
152 ii++;
153 }
154
155 return false;
156 }
157 else if( aSearchData.matchMode == EDA_SEARCH_MATCH_MODE::WILDCARD )
158 {
159 return text.Matches( searchText );
160 }
161 else
162 {
163 return text.Find( searchText ) != wxNOT_FOUND;
164 }
165}
virtual bool IsReplaceable() const
Override this method in any derived object that supports test find and replace.
Definition: eda_item.h:420
CITER next(CITER it)
Definition: ptree.cpp:126
EDA_SEARCH_MATCH_MODE matchMode

References EDA_SEARCH_DATA::findString, EDA_ITEM::IsReplaceable(), EDA_SEARCH_DATA::matchCase, EDA_SEARCH_DATA::matchMode, next(), EDA_SEARCH_DATA::searchAndReplace, text, WHOLEWORD, and WILDCARD.

◆ MirrorHorizontally()

void SCH_SYMBOL::MirrorHorizontally ( int  aCenter)
overridevirtual

Mirror item horizontally about aCenter.

Implements SCH_ITEM.

Definition at line 1700 of file sch_symbol.cpp.

1701{
1702 int dx = m_pos.x;
1703
1705 MIRROR( m_pos.x, aCenter );
1706 dx -= m_pos.x; // dx,0 is the move vector for this transform
1707
1708 for( SCH_FIELD& field : m_fields )
1709 {
1710 // Move the fields to the new position because the symbol itself has moved.
1711 VECTOR2I pos = field.GetTextPos();
1712 pos.x -= dx;
1713 field.SetTextPos( pos );
1714 }
1715}
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:40

References m_fields, m_pos, MIRROR(), SetOrientation(), SYM_MIRROR_Y, and VECTOR2< T >::x.

◆ MirrorVertically()

void SCH_SYMBOL::MirrorVertically ( int  aCenter)
overridevirtual

Mirror item vertically about aCenter.

Implements SCH_ITEM.

Definition at line 1718 of file sch_symbol.cpp.

1719{
1720 int dy = m_pos.y;
1721
1723 MIRROR( m_pos.y, aCenter );
1724 dy -= m_pos.y; // 0,dy is the move vector for this transform
1725
1726 for( SCH_FIELD& field : m_fields )
1727 {
1728 // Move the fields to the new position because the symbol itself has moved.
1729 VECTOR2I pos = field.GetTextPos();
1730 pos.y -= dy;
1731 field.SetTextPos( pos );
1732 }
1733}

References m_fields, m_pos, MIRROR(), SetOrientation(), SYM_MIRROR_X, and VECTOR2< T >::y.

◆ Move()

void SCH_SYMBOL::Move ( const VECTOR2I aMoveVector)
inlineoverridevirtual

Move the item by aMoveVector to a new position.

Implements SCH_ITEM.

Definition at line 630 of file sch_symbol.h.

631 {
632 if( aMoveVector == VECTOR2I( 0, 0 ) )
633 return;
634
635 m_pos += aMoveVector;
636
637 for( SCH_FIELD& field : m_fields )
638 field.Move( aMoveVector );
639
640 SetModified();
641 }
void SetModified()
Definition: eda_item.cpp:64

References m_fields, m_pos, and EDA_ITEM::SetModified().

Referenced by SetPosition().

◆ operator!=()

bool SCH_SYMBOL::operator!= ( const SCH_SYMBOL aSymbol) const

Definition at line 1991 of file sch_symbol.cpp.

1992{
1993 return !( *this == aSymbol );
1994}

◆ operator<() [1/2]

bool EDA_ITEM::operator< ( const EDA_ITEM aItem) const
inherited

Test if another item is less than this object.

Parameters
aItem- Item to compare against.
Returns
- True if aItem is less than the item.

Definition at line 231 of file eda_item.cpp.

232{
233 wxFAIL_MSG( wxString::Format( wxT( "Less than operator not defined for item type %s." ),
234 GetClass() ) );
235
236 return false;
237}
virtual wxString GetClass() const =0
Return the class name.

References Format(), and EDA_ITEM::GetClass().

◆ operator<() [2/2]

bool SCH_SYMBOL::operator< ( const SCH_ITEM aItem) const
overridevirtual

Reimplemented from SCH_ITEM.

Definition at line 1954 of file sch_symbol.cpp.

1955{
1956 if( Type() != aItem.Type() )
1957 return Type() < aItem.Type();
1958
1959 auto symbol = static_cast<const SCH_SYMBOL*>( &aItem );
1960
1962
1963 if( rect.GetArea() != symbol->GetBodyAndPinsBoundingBox().GetArea() )
1964 return rect.GetArea() < symbol->GetBodyAndPinsBoundingBox().GetArea();
1965
1966 if( m_pos.x != symbol->m_pos.x )
1967 return m_pos.x < symbol->m_pos.x;
1968
1969 if( m_pos.y != symbol->m_pos.y )
1970 return m_pos.y < symbol->m_pos.y;
1971
1972 return m_Uuid < aItem.m_Uuid; // Ensure deterministic sort
1973}
ecoord_type GetArea() const
Return the area of the rectangle.
Definition: box2.h:701
BOX2I GetBodyAndPinsBoundingBox() const
Return a bounding box for the symbol body and pins but not the fields.

References BOX2< Vec >::GetArea(), GetBodyAndPinsBoundingBox(), m_pos, EDA_ITEM::m_Uuid, EDA_ITEM::Type(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ operator=()

SCH_SYMBOL & SCH_SYMBOL::operator= ( const SCH_ITEM aItem)

Definition at line 1997 of file sch_symbol.cpp.

1998{
1999 wxCHECK_MSG( Type() == aItem.Type(), *this,
2000 wxT( "Cannot assign object type " ) + aItem.GetClass() + wxT( " to type " ) +
2001 GetClass() );
2002
2003 if( &aItem != this )
2004 {
2005 SCH_ITEM::operator=( aItem );
2006
2007 SCH_SYMBOL* c = (SCH_SYMBOL*) &aItem;
2008
2009 m_lib_id = c->m_lib_id;
2010
2011 LIB_SYMBOL* libSymbol = c->m_part ? new LIB_SYMBOL( *c->m_part.get() ) : nullptr;
2012
2013 m_part.reset( libSymbol );
2014 m_pos = c->m_pos;
2015 m_unit = c->m_unit;
2016 m_convert = c->m_convert;
2018
2020
2021 m_fields = c->m_fields; // std::vector's assignment operator
2022
2023 // Reparent fields after assignment to new symbol.
2024 for( SCH_FIELD& field : m_fields )
2025 field.SetParent( this );
2026
2027 UpdatePins();
2028 }
2029
2030 return *this;
2031}
SCH_ITEM & operator=(const SCH_ITEM &aPin)
Definition: sch_item.cpp:70
virtual wxString GetClass() const override
Return the class name.
Definition: sch_item.h:157
wxString GetClass() const override
Return the class name.
Definition: sch_symbol.h:120
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
Definition: sch_symbol.cpp:335

References SCH_ITEM::GetClass(), GetClass(), m_convert, m_fields, m_instanceReferences, m_lib_id, m_part, m_pos, m_transform, m_unit, SCH_ITEM::operator=(), EDA_ITEM::Type(), and UpdatePins().

◆ operator==()

bool SCH_SYMBOL::operator== ( const SCH_SYMBOL aSymbol) const

Definition at line 1976 of file sch_symbol.cpp.

1977{
1978 if( GetFieldCount() != aSymbol.GetFieldCount() )
1979 return false;
1980
1981 for( int i = VALUE_FIELD; i < GetFieldCount(); i++ )
1982 {
1983 if( GetFields()[i].GetText().Cmp( aSymbol.GetFields()[i].GetText() ) != 0 )
1984 return false;
1985 }
1986
1987 return true;
1988}
std::vector< SCH_FIELD > & GetFields()
Return a vector of fields from the symbol.
Definition: sch_symbol.h:423
int GetFieldCount() const
Return the number of fields in this symbol.
Definition: sch_symbol.h:486
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:879

References GetFieldCount(), GetFields(), and VALUE_FIELD.

◆ Plot()

void SCH_SYMBOL::Plot ( PLOTTER aPlotter,
bool  aBackground 
) const
overridevirtual

Plot the schematic item to aPlotter.

Parameters
aPlotteris the PLOTTER object to plot to.
aBackgrounda poor-man's Z-order. The routine will get called twice, first with aBackground true and then with aBackground false.

Reimplemented from SCH_ITEM.

Definition at line 2096 of file sch_symbol.cpp.

2097{
2098 if( aBackground )
2099 return;
2100
2101 if( m_part )
2102 {
2103 LIB_PINS libPins;
2104 m_part->GetPins( libPins, GetUnit(), GetConvert() );
2105
2106 // Copy the source so we can re-orient and translate it.
2107 LIB_SYMBOL tempSymbol( *m_part );
2108 LIB_PINS tempPins;
2109 tempSymbol.GetPins( tempPins, GetUnit(), GetConvert() );
2110
2111 // Copy the pin info from the symbol to the temp pins
2112 for( unsigned i = 0; i < tempPins.size(); ++ i )
2113 {
2114 SCH_PIN* symbolPin = GetPin( libPins[ i ] );
2115 LIB_PIN* tempPin = tempPins[ i ];
2116
2117 tempPin->SetName( symbolPin->GetShownName() );
2118 tempPin->SetType( symbolPin->GetType() );
2119 tempPin->SetShape( symbolPin->GetShape() );
2120
2121 if( symbolPin->IsDangling() )
2122 tempPin->SetFlags( IS_DANGLING );
2123 }
2124
2125 TRANSFORM temp = GetTransform();
2126 aPlotter->StartBlock( nullptr );
2127
2128 for( bool local_background : { true, false } )
2129 {
2130 tempSymbol.Plot( aPlotter, GetUnit(), GetConvert(), local_background, m_pos, temp,
2131 GetDNP() );
2132
2133 for( SCH_FIELD field : m_fields )
2134 field.Plot( aPlotter, local_background );
2135 }
2136
2137 if( m_DNP )
2138 PlotDNP( aPlotter );
2139
2140 // Plot attributes to a hypertext menu
2141 std::vector<wxString> properties;
2142
2143 for( const SCH_FIELD& field : GetFields() )
2144 {
2145 properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
2146 field.GetName(),
2147 field.GetShownText() ) );
2148 }
2149
2150 properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
2151 _( "Description" ),
2152 m_part->GetDescription() ) );
2153
2154 properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
2155 _( "Keywords" ),
2156 m_part->GetKeyWords() ) );
2157
2158 aPlotter->HyperlinkMenu( GetBoundingBox(), properties );
2159
2160
2161
2162 aPlotter->EndBlock( nullptr );
2163
2164 if( !m_part->IsPower() )
2165 aPlotter->Bookmark( GetBoundingBox(), GetField( REFERENCE_FIELD )->GetShownText(), _("Symbols") );
2166 }
2167}
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:139
void SetShape(GRAPHIC_PINSHAPE aShape)
Definition: lib_pin.h:78
void SetName(const wxString &aName)
Definition: lib_pin.h:114
void SetType(ELECTRICAL_PINTYPE aType)
Definition: lib_pin.h:91
virtual void Bookmark(const BOX2I &aBox, const wxString &aName, const wxString &aGroupName=wxEmptyString)
Create a bookmark to a symbol.
Definition: plotter.h:457
virtual void StartBlock(void *aData)
calling this function allows one to define the beginning of a group of drawing items,...
Definition: plotter.h:518
virtual void HyperlinkMenu(const BOX2I &aBox, const std::vector< wxString > &aDestURLs)
Create a clickable hyperlink menu with a rectangular click area.
Definition: plotter.h:446
virtual void EndBlock(void *aData)
calling this function allows one to define the end of a group of drawing items for instance in SVG or...
Definition: plotter.h:527
bool IsDangling() const override
Definition: sch_pin.h:103
wxString GetShownName() const
Definition: sch_pin.cpp:94
GRAPHIC_PINSHAPE GetShape() const
Definition: sch_pin.cpp:126
ELECTRICAL_PINTYPE GetType() const
Definition: sch_pin.cpp:117
void PlotDNP(PLOTTER *aPlotter) const
Plot the red 'X' over the symbol.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
TRANSFORM & GetTransform()
Definition: sch_symbol.h:283
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
bool GetDNP() const
Definition: sch_symbol.h:753
#define IS_DANGLING
indicates a pin is dangling
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_item.h:54

References _, PLOTTER::Bookmark(), PLOTTER::EndBlock(), Format(), GetBoundingBox(), GetConvert(), GetDNP(), GetField(), GetFields(), GetPin(), LIB_SYMBOL::GetPins(), SCH_PIN::GetShape(), SCH_PIN::GetShownName(), GetTransform(), SCH_PIN::GetType(), GetUnit(), PLOTTER::HyperlinkMenu(), IS_DANGLING, SCH_PIN::IsDangling(), m_DNP, m_fields, m_part, m_pos, LIB_SYMBOL::Plot(), PlotDNP(), REFERENCE_FIELD, EDA_ITEM::SetFlags(), LIB_PIN::SetName(), LIB_PIN::SetShape(), LIB_PIN::SetType(), and PLOTTER::StartBlock().

◆ PlotDNP()

void SCH_SYMBOL::PlotDNP ( PLOTTER aPlotter) const

Plot the red 'X' over the symbol.

This is separated to allow it being used from the screen plot function, overlapping the pins

Parameters
aPlotterthe PLOTTER object used to draw the X

Definition at line 2170 of file sch_symbol.cpp.

2171{
2173
2174 COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
2175
2176 aPlotter->SetColor( colors->GetColor( LAYER_ERC_ERR ) );
2177
2178 aPlotter->ThickSegment( bbox.GetOrigin(), bbox.GetEnd(),
2180 FILLED, nullptr );
2181
2182 aPlotter->ThickSegment( bbox.GetOrigin() + VECTOR2I( bbox.GetWidth(), 0 ),
2183 bbox.GetOrigin() + VECTOR2I( 0, bbox.GetHeight() ),
2185 FILLED, nullptr );
2186}
const Vec & GetOrigin() const
Definition: box2.h:183
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetWidth() const
Definition: box2.h:187
const Vec GetEnd() const
Definition: box2.h:185
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
virtual void ThickSegment(const VECTOR2I &start, const VECTOR2I &end, int width, OUTLINE_MODE tracemode, void *aData)
Definition: plotter.cpp:549
virtual void SetColor(const COLOR4D &color)=0
#define DEFAULT_LINE_WIDTH_MILS
The default wire width in mils. (can be changed in preference menu)
@ LAYER_ERC_ERR
Definition: layer_ids.h:370
@ FILLED
Definition: outline_mode.h:27

References DEFAULT_LINE_WIDTH_MILS, FILLED, GetBodyAndPinsBoundingBox(), COLOR_SETTINGS::GetColor(), BOX2< Vec >::GetEnd(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetOrigin(), BOX2< Vec >::GetWidth(), LAYER_ERC_ERR, EDA_IU_SCALE::MilsToIU(), Pgm(), schIUScale, PLOTTER::SetColor(), and PLOTTER::ThickSegment().

Referenced by Plot().

◆ PlotPins()

void SCH_SYMBOL::PlotPins ( PLOTTER aPlotter) const

Plot just the symbol pins.

This is separated to match the GAL display order. The pins are ALSO plotted with the symbol group. This replotting allows us to ensure that they are shown above other elements in the schematic.

Parameters
aPlotteris the PLOTTER object used to plot pins.

Definition at line 2189 of file sch_symbol.cpp.

2190{
2191 if( m_part )
2192 {
2193 LIB_PINS libPins;
2194 m_part->GetPins( libPins, GetUnit(), GetConvert() );
2195
2196 // Copy the source to stay const
2197 LIB_SYMBOL tempSymbol( *m_part );
2198 LIB_PINS tempPins;
2199 tempSymbol.GetPins( tempPins, GetUnit(), GetConvert() );
2200
2201 TRANSFORM transform = GetTransform();
2202
2203 // Copy the pin info from the symbol to the temp pins
2204 for( unsigned i = 0; i < tempPins.size(); ++ i )
2205 {
2206 SCH_PIN* symbolPin = GetPin( libPins[ i ] );
2207 LIB_PIN* tempPin = tempPins[ i ];
2208
2209 tempPin->SetName( symbolPin->GetShownName() );
2210 tempPin->SetType( symbolPin->GetType() );
2211 tempPin->SetShape( symbolPin->GetShape() );
2212 tempPin->Plot( aPlotter, false, m_pos, transform, GetDNP() );
2213 }
2214 }
2215}
void Plot(PLOTTER *aPlotter, bool aBackground, const VECTOR2I &aOffset, const TRANSFORM &aTransform, bool aDimmed) const override
Plot the draw item using the plot object.
Definition: lib_pin.cpp:1141

References GetConvert(), GetDNP(), GetPin(), LIB_SYMBOL::GetPins(), SCH_PIN::GetShape(), SCH_PIN::GetShownName(), GetTransform(), SCH_PIN::GetType(), GetUnit(), m_part, m_pos, LIB_PIN::Plot(), LIB_PIN::SetName(), LIB_PIN::SetShape(), and LIB_PIN::SetType().

◆ Print()

void SCH_SYMBOL::Print ( const RENDER_SETTINGS aSettings,
const VECTOR2I aOffset 
)
overridevirtual

Print a symbol.

Parameters
aSettingsRender settings controlling output
aOffsetis the drawing offset (usually VECTOR2I(0,0), but can be different when moving an object)

Implements SCH_ITEM.

Definition at line 460 of file sch_symbol.cpp.

461{
463 opts.transform = m_transform;
464 opts.draw_visible_fields = false;
465 opts.draw_hidden_fields = false;
466
467 if( m_part )
468 {
469 m_part->Print( aSettings, m_pos + aOffset, m_unit, m_convert, opts, GetDNP() );
470 }
471 else // Use dummy() part if the actual cannot be found.
472 {
473 dummy()->Print( aSettings, m_pos + aOffset, 0, 0, opts, GetDNP() );
474 }
475
476 for( SCH_FIELD& field : m_fields )
477 field.Print( aSettings, aOffset );
478
479 if( m_DNP )
480 {
482 wxDC* DC = aSettings->GetPrintDC();
483 COLOR4D dnp_color = aSettings->GetLayerColor( LAYER_ERC_ERR );
484
485 GRFilledSegment( DC, bbox.GetOrigin(), bbox.GetEnd(),
487 dnp_color );
488
489 GRFilledSegment( DC, bbox.GetOrigin() + VECTOR2I( bbox.GetWidth(), 0 ),
490 bbox.GetOrigin() + VECTOR2I( 0, bbox.GetHeight() ),
492 dnp_color );
493 }
494}
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
wxDC * GetPrintDC() const
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset, int aMulti, int aConvert, const LIB_SYMBOL_OPTIONS &aOpts, bool aDimmed)
Print symbol.
Definition: lib_symbol.cpp:654
void GRFilledSegment(wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor)
Definition: gr_basic.cpp:269
bool draw_visible_fields
Definition: lib_symbol.h:66
TRANSFORM transform
Definition: lib_symbol.h:64

References DEFAULT_LINE_WIDTH_MILS, LIB_SYMBOL_OPTIONS::draw_hidden_fields, LIB_SYMBOL_OPTIONS::draw_visible_fields, dummy(), GetBodyAndPinsBoundingBox(), GetDNP(), BOX2< Vec >::GetEnd(), BOX2< Vec >::GetHeight(), KIGFX::RENDER_SETTINGS::GetLayerColor(), BOX2< Vec >::GetOrigin(), KIGFX::RENDER_SETTINGS::GetPrintDC(), BOX2< Vec >::GetWidth(), GRFilledSegment(), LAYER_ERC_ERR, m_convert, m_DNP, m_fields, m_part, m_pos, m_transform, m_unit, EDA_IU_SCALE::MilsToIU(), LIB_SYMBOL::Print(), schIUScale, and LIB_SYMBOL_OPTIONS::transform.

◆ PrintBackground()

void SCH_SYMBOL::PrintBackground ( const RENDER_SETTINGS aSettings,
const VECTOR2I aOffset 
)
overridevirtual

Print only the background parts of a symbol (if any)

Parameters
aSettingsRender settings controlling output
aOffsetis the drawing offset (usually VECTOR2I(0,0), but can be different when moving an object)

Reimplemented from SCH_ITEM.

Definition at line 448 of file sch_symbol.cpp.

449{
451 opts.transform = m_transform;
452 opts.draw_visible_fields = false;
453 opts.draw_hidden_fields = false;
454
455 if( m_part )
456 m_part->PrintBackground( aSettings, m_pos + aOffset, m_unit, m_convert, opts, GetDNP() );
457}

References LIB_SYMBOL_OPTIONS::draw_hidden_fields, LIB_SYMBOL_OPTIONS::draw_visible_fields, GetDNP(), m_convert, m_part, m_pos, m_transform, m_unit, and LIB_SYMBOL_OPTIONS::transform.

◆ RemoveAllInstances()

void SCH_SYMBOL::RemoveAllInstances ( )
inline

Definition at line 150 of file sch_symbol.h.

150{ m_instanceReferences.clear(); }

References m_instanceReferences.

◆ RemoveField() [1/2]

void SCH_SYMBOL::RemoveField ( const wxString &  aFieldName)

Remove a user field from the symbol.

Parameters
aFieldNameis the user fieldName to remove. Attempts to remove a mandatory field or a non-existant field are silently ignored.

Definition at line 903 of file sch_symbol.cpp.

904{
905 for( unsigned i = MANDATORY_FIELDS; i < m_fields.size(); ++i )
906 {
907 if( aFieldName == m_fields[i].GetName( false ) )
908 {
909 m_fields.erase( m_fields.begin() + i );
910 return;
911 }
912 }
913}

References m_fields, and MANDATORY_FIELDS.

◆ RemoveField() [2/2]

void SCH_SYMBOL::RemoveField ( SCH_FIELD aField)
inline

Definition at line 442 of file sch_symbol.h.

442{ RemoveField( aField->GetName() ); }
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:813
void RemoveField(const wxString &aFieldName)
Remove a user field from the symbol.
Definition: sch_symbol.cpp:903

References SCH_FIELD::GetName(), and RemoveField().

Referenced by RemoveField().

◆ RemoveInstance()

void SCH_SYMBOL::RemoveInstance ( const SCH_SHEET_PATH aInstancePath)

Definition at line 521 of file sch_symbol.cpp.

522{
523 // Search for an existing path and remove it if found (should not occur)
524 for( unsigned ii = 0; ii < m_instanceReferences.size(); ii++ )
525 {
526 if( m_instanceReferences[ii].m_Path == aInstancePath.Path() )
527 {
528 wxLogTrace( traceSchSheetPaths, "Removing symbol instance:\n"
529 " sheet path %s\n"
530 " reference %s, unit %d from symbol %s.",
531 aInstancePath.Path().AsString(),
532 m_instanceReferences[ii].m_Reference,
533 m_instanceReferences[ii].m_Unit,
534 m_Uuid.AsString() );
535
536 m_instanceReferences.erase( m_instanceReferences.begin() + ii );
537 ii--;
538 }
539 }
540}

References KIID::AsString(), KIID_PATH::AsString(), m_instanceReferences, EDA_ITEM::m_Uuid, SCH_SHEET_PATH::Path(), and traceSchSheetPaths.

Referenced by SCH_SHEET_PATH::RemoveSymbolInstances().

◆ RenderAsBitmap()

bool SCH_ITEM::RenderAsBitmap ( double  aWorldScale) const
overridevirtualinherited

Reimplemented from EDA_ITEM.

Definition at line 294 of file sch_item.cpp.

295{
296 if( IsHypertext() )
297 return false;
298
299 if( const EDA_TEXT* text = dynamic_cast<const EDA_TEXT*>( this ) )
300 return text->GetTextHeight() * aWorldScale < BITMAP_FONT_SIZE_THRESHOLD;
301
302 return false;
303}
virtual bool IsHypertext() const
Allow items to support hypertext actions when hovered/clicked.
Definition: sch_item.h:239
#define BITMAP_FONT_SIZE_THRESHOLD
Definition: sch_item.cpp:46

References BITMAP_FONT_SIZE_THRESHOLD, SCH_ITEM::IsHypertext(), and text.

Referenced by KIGFX::SCH_PAINTER::draw().

◆ Replace() [1/2]

virtual bool EDA_ITEM::Replace ( const EDA_SEARCH_DATA aSearchData,
void *  aAuxData = nullptr 
)
inlinevirtualinherited

Perform a text replace using the find and replace criteria in aSearchData on items that support text find and replace.

This function must be overridden for items that support text replace.

Parameters
aSearchDataA reference to a wxFindReplaceData object containing the search and replace criteria.
aAuxDataA pointer to optional data required for the search or NULL if not used.
Returns
True if the item text was modified, otherwise false.

Reimplemented in LIB_TEXTBOX, SCH_LABEL_BASE, SCH_PIN, SCH_TEXT, SCH_TEXTBOX, SCH_FIELD, and SCH_SHEET_PIN.

Definition at line 409 of file eda_item.h.

410 {
411 return false;
412 }

◆ Replace() [2/2]

bool EDA_ITEM::Replace ( const EDA_SEARCH_DATA aSearchData,
wxString &  aText 
)
staticinherited

Perform a text replace on aText using the find and replace criteria in aSearchData on items that support text find and replace.

Parameters
aSearchDataA reference to a wxFindReplaceData object containing the search and replace criteria.
aTextA reference to a wxString object containing the text to be replaced.
Returns
True if aText was modified, otherwise false.

Definition at line 168 of file eda_item.cpp.

169{
170 wxString text = aText;
171 wxString searchText = aSearchData.findString;
172 wxString result;
173 bool replaced = false;
174
175 if( !aSearchData.matchCase )
176 {
177 text = text.Upper();
178 searchText = searchText.Upper();
179 }
180
181 int ii = 0;
182
183 while( ii < (int) text.length() )
184 {
185 int next = text.find( searchText, ii );
186
187 if( next == wxNOT_FOUND )
188 {
189 result += aText.Mid( ii, wxString::npos );
190 break;
191 }
192
193 if( next > ii )
194 result += aText.Mid( ii, next - ii );
195
196 ii = next;
197 next += searchText.length();
198
199 bool startOK;
200 bool endOK;
201
203 {
204 startOK = ( ii == 0 || !wxIsalnum( text.GetChar( ii - 1 ) ) );
205 endOK = ( next == (int) text.length() || !wxIsalnum( text.GetChar( next ) ) );
206 }
207 else
208 {
209 startOK = true;
210 endOK = true;
211 }
212
213 if( startOK && endOK )
214 {
215 result += aSearchData.replaceString;
216 replaced = true;
217 ii = next;
218 }
219 else
220 {
221 result += aText.GetChar( ii );
222 ii++;
223 }
224 }
225
226 aText = result;
227 return replaced;
228}
wxString replaceString

References EDA_SEARCH_DATA::findString, EDA_SEARCH_DATA::matchCase, EDA_SEARCH_DATA::matchMode, next(), EDA_SEARCH_DATA::replaceString, text, and WHOLEWORD.

Referenced by EDA_TEXT::Replace(), SCH_FIELD::Replace(), SCH_FIND_REPLACE_TOOL::ReplaceAll(), and SCH_FIND_REPLACE_TOOL::ReplaceAndFindNext().

◆ ReplaceInstanceSheetPath()

bool SCH_SYMBOL::ReplaceInstanceSheetPath ( const KIID_PATH aOldSheetPath,
const KIID_PATH aNewSheetPath 
)

Replace aOldSheetPath with aNewSheetPath in the instance list.

Parameters
aOldSheetPathis a KIID_PATH object of an existing path in the instance list.
aNewSheetPathis a KIID_PATH object of the path to replace the existing path.
Returns
true if aOldSheetPath was found and replaced or false if aOldSheetPath was not found in the instance list.

Definition at line 1328 of file sch_symbol.cpp.

1330{
1331 auto it = std::find_if( m_instanceReferences.begin(), m_instanceReferences.end(),
1332 [ aOldSheetPath ]( SCH_SYMBOL_INSTANCE& r )->bool
1333 {
1334 return aOldSheetPath == r.m_Path;
1335 }
1336 );
1337
1338 if( it != m_instanceReferences.end() )
1339 {
1340 wxLogTrace( traceSchSheetPaths,
1341 "Replacing sheet path %s\n with sheet path %s\n for symbol %s.",
1342 aOldSheetPath.AsString(), aNewSheetPath.AsString(), m_Uuid.AsString() );
1343
1344 it->m_Path = aNewSheetPath;
1345 return true;
1346 }
1347
1348 wxLogTrace( traceSchSheetPaths,
1349 "Could not find sheet path %s\n to replace with sheet path %s\n for symbol %s.",
1350 aOldSheetPath.AsString(), aNewSheetPath.AsString(), m_Uuid.AsString() );
1351
1352 return false;
1353}

References KIID::AsString(), KIID_PATH::AsString(), m_instanceReferences, EDA_ITEM::m_Uuid, and traceSchSheetPaths.

◆ ResolveTextVar()

bool SCH_SYMBOL::ResolveTextVar ( wxString *  token,
int  aDepth = 0 
) const

Resolve any references to system tokens supported by the symbol.

Parameters
aDeptha counter to limit recursion and circular references.

Definition at line 1133 of file sch_symbol.cpp.

1134{
1135 SCHEMATIC* schematic = Schematic();
1136
1137 // SCH_SYMOL object has no context outside a schematic.
1138 if( !schematic )
1139 return false;
1140
1141 if( token->Contains( ':' ) )
1142 {
1143 if( schematic->ResolveCrossReference( token, aDepth + 1 ) )
1144 return true;
1145 }
1146
1147 for( int i = 0; i < MANDATORY_FIELDS; ++i )
1148 {
1149 if( token->IsSameAs( m_fields[ i ].GetCanonicalName().Upper() ) )
1150 {
1151 if( i == REFERENCE_FIELD )
1152 *token = GetRef( &schematic->CurrentSheet(), true );
1153 else if( i == VALUE_FIELD )
1154 *token = GetValueFieldText( true );
1155 else if( i == FOOTPRINT_FIELD )
1156 *token = GetFootprintFieldText( true );
1157 else
1158 *token = m_fields[ i ].GetShownText( aDepth + 1 );
1159
1160 return true;
1161 }
1162 }
1163
1164 for( size_t i = MANDATORY_FIELDS; i < m_fields.size(); ++i )
1165 {
1166 if( token->IsSameAs( m_fields[ i ].GetName() )
1167 || token->IsSameAs( m_fields[ i ].GetName().Upper() ) )
1168 {
1169 *token = m_fields[ i ].GetShownText( aDepth + 1 );
1170 return true;
1171 }
1172 }
1173
1174 for( const TEMPLATE_FIELDNAME& templateFieldname :
1176 {
1177 if( token->IsSameAs( templateFieldname.m_Name )
1178 || token->IsSameAs( templateFieldname.m_Name.Upper() ) )
1179 {
1180 // If we didn't find it in the fields list then it isn't set on this symbol.
1181 // Just return an empty string.
1182 *token = wxEmptyString;
1183 return true;
1184 }
1185 }
1186
1187 if( token->IsSameAs( wxT( "FOOTPRINT_LIBRARY" ) ) )
1188 {
1189 wxString footprint;
1190
1191 footprint = GetFootprintFieldText( true );
1192
1193 wxArrayString parts = wxSplit( footprint, ':' );
1194
1195 *token = parts[ 0 ];
1196 return true;
1197 }
1198 else if( token->IsSameAs( wxT( "FOOTPRINT_NAME" ) ) )
1199 {
1200 wxString footprint;
1201
1202 footprint = GetFootprintFieldText( true );
1203
1204 wxArrayString parts = wxSplit( footprint, ':' );
1205
1206 *token = parts[ std::min( 1, (int) parts.size() - 1 ) ];
1207 return true;
1208 }
1209 else if( token->IsSameAs( wxT( "UNIT" ) ) )
1210 {
1211 int unit;
1212
1213 unit = GetUnitSelection( &schematic->CurrentSheet() );
1214
1215 *token = LIB_SYMBOL::SubReference( unit );
1216 return true;
1217 }
1218 else if( token->IsSameAs( wxT( "SYMBOL_LIBRARY" ) ) )
1219 {
1220 *token = m_lib_id.GetLibNickname();
1221 return true;
1222 }
1223 else if( token->IsSameAs( wxT( "SYMBOL_NAME" ) ) )
1224 {
1225 *token = m_lib_id.GetLibItemName();
1226 return true;
1227 }
1228 else if( token->IsSameAs( wxT( "SYMBOL_DESCRIPTION" ) ) )
1229 {
1230 *token = GetDescription();
1231 return true;
1232 }
1233 else if( token->IsSameAs( wxT( "SYMBOL_KEYWORDS" ) ) )
1234 {
1235 *token = GetKeyWords();
1236 return true;
1237 }
1238 else if( token->IsSameAs( wxT( "EXCLUDE_FROM_BOM" ) ) )
1239 {
1240 *token = this->GetIncludeInBom() ? wxT( "" ) : _( "Excluded from BOM" );
1241 return true;
1242 }
1243 else if( token->IsSameAs( wxT( "EXCLUDE_FROM_BOARD" ) ) )
1244 {
1245 *token = this->GetIncludeOnBoard() ? wxT( "" ) : _( "Excluded from board" );
1246 return true;
1247 }
1248 else if( token->IsSameAs( wxT( "DNP" ) ) )
1249 {
1250 *token = this->GetDNP() ? _( "DNP" ) : wxT( "" );
1251 return true;
1252 }
1253
1254 // See if parent can resolve it (this will recurse to ancestors)
1255
1256 if( SCH_SHEET* sheet = schematic->CurrentSheet().Last() )
1257 {
1258 if( sheet->ResolveTextVar( token, aDepth + 1 ) )
1259 return true;
1260 }
1261
1262 return false;
1263}
const UTF8 & GetLibItemName() const
Definition: lib_id.h:102
TEMPLATES m_TemplateFieldNames
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:203
bool ResolveCrossReference(wxString *token, int aDepth) const
Resolves text vars that refer to other items.
Definition: schematic.cpp:323
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
bool GetIncludeOnBoard() const
Definition: sch_symbol.h:750
bool GetIncludeInBom() const
Definition: sch_symbol.h:747
wxString GetDescription() const
Definition: sch_symbol.cpp:308
wxString GetKeyWords() const
Definition: sch_symbol.cpp:317
const TEMPLATE_FIELDNAMES & GetTemplateFieldNames()
Return a template field name list for read only access.
Hold a name of a symbol's field, field value, and default visibility.

References _, SCHEMATIC::CurrentSheet(), FOOTPRINT_FIELD, GetDescription(), GetDNP(), GetFootprintFieldText(), GetIncludeInBom(), GetIncludeOnBoard(), GetKeyWords(), LIB_ID::GetLibItemName(), LIB_ID::GetLibNickname(), GetRef(), TEMPLATES::GetTemplateFieldNames(), GetUnitSelection(), GetValueFieldText(), SCH_SHEET_PATH::Last(), m_fields, m_lib_id, SCHEMATIC_SETTINGS::m_TemplateFieldNames, MANDATORY_FIELDS, REFERENCE_FIELD, SCHEMATIC::ResolveCrossReference(), SCH_ITEM::Schematic(), SCHEMATIC::Settings(), LIB_SYMBOL::SubReference(), and VALUE_FIELD.

Referenced by KIGFX::expandLibItemTextVars(), and SCHEMATIC::ResolveCrossReference().

◆ Rotate()

void SCH_SYMBOL::Rotate ( const VECTOR2I aCenter)
overridevirtual

Rotate the item around aCenter 90 degrees in the clockwise direction.

Implements SCH_ITEM.

Definition at line 1736 of file sch_symbol.cpp.

1737{
1738 VECTOR2I prev = m_pos;
1739
1740 RotatePoint( m_pos, aCenter, ANGLE_90 );
1741
1743
1744 for( SCH_FIELD& field : m_fields )
1745 {
1746 // Move the fields to the new position because the symbol itself has moved.
1747 VECTOR2I pos = field.GetTextPos();
1748 pos.x -= prev.x - m_pos.x;
1749 pos.y -= prev.y - m_pos.y;
1750 field.SetTextPos( pos );
1751 }
1752}
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:425
@ SYM_ROTATE_COUNTERCLOCKWISE
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183

References ANGLE_90, m_fields, m_pos, RotatePoint(), SetOrientation(), SYM_ROTATE_COUNTERCLOCKWISE, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SCH_EDIT_TOOL::Rotate().

◆ RunOnChildren()

void SCH_SYMBOL::RunOnChildren ( const std::function< void(SCH_ITEM *)> &  aFunction)
overridevirtual

Reimplemented from SCH_ITEM.

Definition at line 999 of file sch_symbol.cpp.

1000{
1001 for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
1002 aFunction( pin.get() );
1003
1004 for( SCH_FIELD& field : m_fields )
1005 aFunction( &field );
1006}

References m_fields, m_pins, and pin.

◆ Schematic()

SCHEMATIC * SCH_ITEM::Schematic ( ) const
inherited

Searches the item hierarchy to find a SCHEMATIC.

Every SCH_ITEM that lives on a SCH_SCREEN should be parented to either that screen or another SCH_ITEM on the same screen (for example, pins to their symbols).

Every SCH_SCREEN should be parented to the SCHEMATIC.

Note
This hierarchy is not the same as the sheet hierarchy!
Returns
the parent schematic this item lives on, or nullptr.

Definition at line 112 of file sch_item.cpp.

113{
114 EDA_ITEM* parent = GetParent();
115
116 while( parent )
117 {
118 if( parent->Type() == SCHEMATIC_T )
119 return static_cast<SCHEMATIC*>( parent );
120 else
121 parent = parent->GetParent();
122 }
123
124 return nullptr;
125}
EDA_ITEM * GetParent() const
Definition: eda_item.h:99
@ SCHEMATIC_T
Definition: typeinfo.h:188

References EDA_ITEM::GetParent(), SCHEMATIC_T, and EDA_ITEM::Type().

Referenced by EE_SELECTION_TOOL::autostartEvent(), SCH_EDIT_TOOL::ChangeTextType(), SCH_ITEM::Connection(), SCH_DRAWING_TOOLS::createSheetPin(), DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES(), SCH_SHEET::findSelf(), SCH_MARKER::GetColorLayer(), SCH_SHEET::GetContextualTextVars(), SCH_ITEM::GetEffectiveNetClass(), SCH_JUNCTION::getEffectiveShape(), SCH_LABEL_BASE::GetIntersheetRefs(), SCH_LABEL_BASE::GetLabelBoxExpansion(), SCH_DIRECTIVE_LABEL::GetPenWidth(), SCH_LINE::GetPenWidth(), SCH_NO_CONNECT::GetPenWidth(), SCH_SHAPE::GetPenWidth(), SCH_SHEET::GetPenWidth(), SCH_SHEET_PIN::GetPenWidth(), GetPins(), SCH_MARKER::GetSeverity(), SCH_FIELD::GetShownText(), SCH_TEXT::GetShownText(), SCH_TEXTBOX::GetShownText(), SCH_TEXT::GetTextOffset(), SCH_PIN::HitTest(), SCH_SHEET::IsRootSheet(), SCH_LABEL_BASE::IsType(), DIALOG_SYMBOL_PROPERTIES::OnAddField(), DIALOG_SCH_FIELD_PROPERTIES::onScintillaCharAdded(), DIALOG_TEXT_PROPERTIES::onScintillaCharAdded(), SCH_LABEL_BASE::ResolveTextVar(), SCH_GLOBALLABEL::ResolveTextVar(), SCH_SHEET::ResolveTextVar(), ResolveTextVar(), SetRef(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_LABEL_PROPERTIES::TransferDataToWindow(), SCH_SHEET_PATH::UpdateAllScreenReferences(), DIALOG_SCH_FIELD_PROPERTIES::UpdateField(), and SCH_MARKER::ViewGetLayers().

◆ Set() [1/3]

template<typename T >
bool INSPECTABLE::Set ( const wxString &  aProperty,
aValue 
)
inlineinherited

Definition at line 66 of file inspectable.h.

67 {
69 TYPE_ID thisType = TYPE_HASH( *this );
70 PROPERTY_BASE* prop = propMgr.GetProperty( thisType, aProperty );
71 void* object = nullptr;
72
73 if( prop )
74 {
75 object = propMgr.TypeCast( this, thisType, prop->OwnerHash() );
76
77 if( object )
78 prop->set<T>( object, aValue );
79 }
80
81 return object != nullptr;
82 }
void set(void *aObject, T aValue)
Definition: property.h:289

References PROPERTY_MANAGER::GetProperty(), PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), PROPERTY_BASE::set(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ Set() [2/3]

template<typename T >
bool INSPECTABLE::Set ( PROPERTY_BASE aProperty,
aValue 
)
inlineinherited

Definition at line 54 of file inspectable.h.

55 {
57 void* object = propMgr.TypeCast( this, TYPE_HASH( *this ), aProperty->OwnerHash() );
58
59 if( object )
60 aProperty->set<T>( object, aValue );
61
62 return object != nullptr;
63 }

References PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), PROPERTY_BASE::set(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

◆ Set() [3/3]

bool INSPECTABLE::Set ( PROPERTY_BASE aProperty,
wxAny &  aValue 
)
inlineinherited

Definition at line 42 of file inspectable.h.

43 {
45 void* object = propMgr.TypeCast( this, TYPE_HASH( *this ), aProperty->OwnerHash() );
46
47 if( object )
48 aProperty->setter( object, aValue );
49
50 return object != nullptr;
51 }
virtual void setter(void *aObject, wxAny &aValue)=0

References PROPERTY_MANAGER::Instance(), PROPERTY_BASE::OwnerHash(), PROPERTY_BASE::setter(), TYPE_HASH, and PROPERTY_MANAGER::TypeCast().

Referenced by PCB_PROPERTIES_PANEL::valueChanged().

◆ SetBrightened()

◆ SetConnectivityDirty()

◆ SetConvert()

void SCH_SYMBOL::SetConvert ( int  aConvert)

Definition at line 400 of file sch_symbol.cpp.

401{
402 if( m_convert != aConvert )
403 {
404 m_convert = aConvert;
405
406 // The convert may have a different pin layout so the update the pin map.
407 UpdatePins();
408 SetModified();
409 }
410}

References m_convert, EDA_ITEM::SetModified(), and UpdatePins().

Referenced by SCH_EDIT_FRAME::ConvertPart(), and DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow().

◆ SetDNP()

void SCH_SYMBOL::SetDNP ( bool  aDNP)
inline

Definition at line 754 of file sch_symbol.h.

754{ m_DNP = aDNP; }

References m_DNP.

Referenced by DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow().

◆ SetFields()

void SCH_SYMBOL::SetFields ( std::vector< SCH_FIELD > &  aFields)
inline

Set multiple schematic fields.

Parameters
aFieldsare the fields to set in this symbol.

Definition at line 459 of file sch_symbol.h.

460 {
461 m_fields = aFields; // vector copying, length is changed possibly
462 }

References m_fields.

◆ SetFieldsAutoplaced()

void SCH_ITEM::SetFieldsAutoplaced ( )
inlineinherited

◆ SetFlags()

void EDA_ITEM::SetFlags ( EDA_ITEM_FLAGS  aMask)
inlineinherited

Definition at line 139 of file eda_item.h.

139{ m_flags |= aMask; }

References EDA_ITEM::m_flags.

Referenced by SCH_EAGLE_PLUGIN::addBusEntries(), PCB_BASE_FRAME::AddFootprintToBoard(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), SCH_ALTIUM_PLUGIN::AddTextBox(), SCH_MOVE_TOOL::AlignElements(), PCB_CONTROL::AppendBoard(), SCH_EDIT_FRAME::BreakSegment(), SCH_EDIT_TOOL::BreakWire(), FOOTPRINT::BuildCourtyardCaches(), SCH_EDIT_TOOL::ChangeTextType(), GRAPHICS_CLEANER::cleanupShapes(), ConvertOutlineToPolygon(), SCH_EDIT_FRAME::ConvertPart(), SCH_DRAWING_TOOLS::createNewText(), SCH_DRAWING_TOOLS::createSheetPin(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCBNEW_JOBS_HANDLER::doFpExportSvg(), PCB_TOOL_BASE::doInteractiveItemPlacement(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), EDIT_TOOL::DragArcTrack(), KIGFX::SCH_PAINTER::draw(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), DRAWING_TOOL::DrawRectangle(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PCB_SELECTION_TOOL::EnterGroup(), PAD_TOOL::explodePad(), SCH_MOVE_TOOL::getConnectedDragItems(), SYMBOL_EDIT_FRAME::GetSymbolFromRedoList(), SYMBOL_EDIT_FRAME::GetSymbolFromUndoList(), EE_COLLECTOR::Inspect(), CONVERT_TOOL::makePolysFromChainedSegs(), CONVERT_TOOL::makePolysFromClosedGraphics(), CONVERT_TOOL::makePolysFromOpenGraphics(), SCH_SCREEN::MarkConnections(), TRACKS_CLEANER::mergeCollinearSegments(), SCH_MOVE_TOOL::moveItem(), SYMBOL_EDITOR_MOVE_TOOL::moveItem(), DIALOG_SYMBOL_PROPERTIES::OnUnitChoice(), KIGFX::ORIGIN_VIEWITEM::ORIGIN_VIEWITEM(), SCH_MOVE_TOOL::orthoLineDrag(), SCH_ALTIUM_PLUGIN::ParseBezier(), SCH_ALTIUM_PLUGIN::ParseBus(), SCH_ALTIUM_PLUGIN::ParseBusEntry(), SCH_ALTIUM_PLUGIN::ParseHarnessPort(), SCH_ALTIUM_PLUGIN::ParseJunction(), SCH_ALTIUM_PLUGIN::ParseLabel(), SCH_ALTIUM_PLUGIN::ParseLine(), SCH_ALTIUM_PLUGIN::ParseNetLabel(), SCH_ALTIUM_PLUGIN::ParseNoERC(), SCH_ALTIUM_PLUGIN::ParsePolygon(), SCH_ALTIUM_PLUGIN::ParsePolyline(), SCH_ALTIUM_PLUGIN::ParsePort(), SCH_ALTIUM_PLUGIN::ParseRectangle(), SCH_ALTIUM_PLUGIN::ParseRoundRectangle(), SCH_ALTIUM_PLUGIN::ParseSheetSymbol(), SCH_ALTIUM_PLUGIN::ParseSignalHarness(), SCH_ALTIUM_PLUGIN::ParseWire(), SCH_EDITOR_CONTROL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PL_DRAWING_TOOLS::PlaceItem(), DRAWING_TOOL::PlaceText(), Plot(), BACK_ANNOTATE::processNetNameChange(), SCH_EDIT_FRAME::PutDataInPreviousState(), PCB_SELECTION_TOOL::RebuildSelection(), BOARD::Remove(), FOOTPRINT::Remove(), SCH_EDIT_TOOL::RepeatDrawItem(), SCH_EDIT_TOOL::Rotate(), SYMBOL_EDIT_FRAME::SaveCopyInUndoList(), EE_SELECTION_TOOL::SelectAll(), EE_SELECTION_TOOL::selectMultiple(), SCH_EDIT_FRAME::SelectUnit(), EDA_ITEM::SetBrightened(), EDA_ITEM::SetIsShownAsBitmap(), EDA_ITEM::SetModified(), EDA_ITEM::SetSelected(), SCH_DRAWING_TOOLS::SingleClickPlace(), BOARD_COMMIT::Stage(), SCH_LINE_WIRE_BUS_TOOL::startSegments(), DS_DATA_ITEM::SyncDrawItems(), DS_DATA_ITEM_BITMAP::SyncDrawItems(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_DIMENSION_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace().

◆ SetFootprintFieldText()

◆ SetForceVisible()

void EDA_ITEM::SetForceVisible ( bool  aEnable)
inlineinherited

Set and clear force visible flag used to force the item to be drawn even if it's draw attribute is set to not visible.

Parameters
aEnableTrue forces the item to be drawn. False uses the item's visibility setting to determine if the item is to be drawn.

Definition at line 199 of file eda_item.h.

199{ m_forceVisible = aEnable; }

References EDA_ITEM::m_forceVisible.

Referenced by SCH_FIND_REPLACE_TOOL::FindNext(), and SCH_FIND_REPLACE_TOOL::UpdateFind().

◆ SetIncludeInBom()

void SCH_SYMBOL::SetIncludeInBom ( bool  aIncludeInBom)
inline

Definition at line 748 of file sch_symbol.h.

748{ m_inBom = aIncludeInBom; }

References m_inBom.

Referenced by DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow().

◆ SetIncludeOnBoard()

void SCH_SYMBOL::SetIncludeOnBoard ( bool  aIncludeOnBoard)
inline

Definition at line 751 of file sch_symbol.h.

751{ m_onBoard = aIncludeOnBoard; }

References m_onBoard.

Referenced by DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow().

◆ SetIsShownAsBitmap()

void EDA_ITEM::SetIsShownAsBitmap ( bool  aBitmap)
inlineinherited

Definition at line 165 of file eda_item.h.

166 {
167 if( aBitmap )
169 else
171 }

References EDA_ITEM::ClearFlags(), IS_SHOWN_AS_BITMAP, and EDA_ITEM::SetFlags().

◆ SetLastResolvedState()

virtual void SCH_ITEM::SetLastResolvedState ( const SCH_ITEM aItem)
inlinevirtualinherited

Reimplemented in SCH_BUS_ENTRY_BASE, SCH_FIELD, SCH_JUNCTION, SCH_LABEL_BASE, and SCH_LINE.

Definition at line 417 of file sch_item.h.

417{ }

Referenced by SCH_EDITOR_CONTROL::Paste().

◆ SetLayer()

◆ SetLibId()

void SCH_SYMBOL::SetLibId ( const LIB_ID aName)

◆ SetLibSymbol()

void SCH_SYMBOL::SetLibSymbol ( LIB_SYMBOL aLibSymbol)

Set this schematic symbol library symbol reference to aLibSymbol.

The schematic symbol object owns aLibSymbol and the pin list will be updated accordingly. The LIB_SYMBOL object can be null to clear the library symbol link as well as the pin map. If the LIB_SYMBOL object is not null, it must be a root symbol. Otherwise an assertion will be raised in debug builds and the library symbol will be cleared. The new file format will no longer require a cache library so all library symbols must be valid.

Note
This is the only way to publicly set the library symbol for a schematic symbol except for the ctors that take a LIB_SYMBOL reference. All previous public resolvers have been deprecated.
Parameters
aLibSymbolis the library symbol to associate with this schematic symbol.

Definition at line 299 of file sch_symbol.cpp.

300{
301 wxCHECK2( ( aLibSymbol == nullptr ) || ( aLibSymbol->IsRoot() ), aLibSymbol = nullptr );
302
303 m_part.reset( aLibSymbol );
304 UpdatePins();
305}
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
Definition: lib_symbol.h:187

References LIB_SYMBOL::IsRoot(), m_part, and UpdatePins().

Referenced by SCH_SCREEN::Append(), SCH_ALTIUM_PLUGIN::ParsePowerPort(), SCH_EDITOR_CONTROL::Paste(), and SCH_SYMBOL().

◆ SetLocked()

virtual void SCH_ITEM::SetLocked ( bool  aLocked)
inlinevirtualinherited

Set the 'lock' status to aLocked for of this item.

Definition at line 234 of file sch_item.h.

234{}

◆ SetModified()

◆ SetOrientation()

void SCH_SYMBOL::SetOrientation ( int  aOrientation)

Compute the new transform matrix based on aOrientation for the symbol which is applied to the current transform.

Parameters
aOrientationis the orientation to apply to the transform.

Definition at line 1356 of file sch_symbol.cpp.

1357{
1358 TRANSFORM temp = TRANSFORM();
1359 bool transform = false;
1360
1361 switch( aOrientation )
1362 {
1363 case SYM_ORIENT_0:
1364 case SYM_NORMAL: // default transform matrix
1365 m_transform.x1 = 1;
1366 m_transform.y2 = -1;
1368 break;
1369
1370 case SYM_ROTATE_COUNTERCLOCKWISE: // Rotate + (incremental rotation)
1371 temp.x1 = temp.y2 = 0;
1372 temp.y1 = 1;
1373 temp.x2 = -1;
1374 transform = true;
1375 break;
1376
1377 case SYM_ROTATE_CLOCKWISE: // Rotate - (incremental rotation)
1378 temp.x1 = temp.y2 = 0;
1379 temp.y1 = -1;
1380 temp.x2 = 1;
1381 transform = true;
1382 break;
1383
1384 case SYM_MIRROR_Y: // Mirror Y (incremental rotation)
1385 temp.x1 = -1;
1386 temp.y2 = 1;
1387 temp.y1 = temp.x2 = 0;
1388 transform = true;
1389 break;
1390
1391 case SYM_MIRROR_X: // Mirror X (incremental rotation)
1392 temp.x1 = 1;
1393 temp.y2 = -1;
1394 temp.y1 = temp.x2 = 0;
1395 transform = true;
1396 break;
1397
1398 case SYM_ORIENT_90:
1401 break;
1402
1403 case SYM_ORIENT_180:
1407 break;
1408
1409 case SYM_ORIENT_270:
1412 break;
1413
1414 case ( SYM_ORIENT_0 + SYM_MIRROR_X ):
1417 break;
1418
1419 case ( SYM_ORIENT_0 + SYM_MIRROR_Y ):
1422 break;
1423
1424 case ( SYM_ORIENT_90 + SYM_MIRROR_X ):
1427 break;
1428
1429 case ( SYM_ORIENT_90 + SYM_MIRROR_Y ):
1432 break;
1433
1434 case ( SYM_ORIENT_180 + SYM_MIRROR_X ):
1437 break;
1438
1439 case ( SYM_ORIENT_180 + SYM_MIRROR_Y ):
1442 break;
1443
1444 case ( SYM_ORIENT_270 + SYM_MIRROR_X ):
1447 break;
1448
1449 case ( SYM_ORIENT_270 + SYM_MIRROR_Y ):
1452 break;
1453
1454 default:
1455 transform = false;
1456 wxFAIL_MSG( "Invalid schematic symbol orientation type." );
1457 break;
1458 }
1459
1460 if( transform )
1461 {
1462 /* The new matrix transform is the old matrix transform modified by the
1463 * requested transformation, which is the temp transform (rot,
1464 * mirror ..) in order to have (in term of matrix transform):
1465 * transform coord = new_m_transform * coord
1466 * where transform coord is the coord modified by new_m_transform from
1467 * the initial value coord.
1468 * new_m_transform is computed (from old_m_transform and temp) to
1469 * have:
1470 * transform coord = old_m_transform * temp
1471 */
1472 TRANSFORM newTransform;
1473
1474 newTransform.x1 = m_transform.x1 * temp.x1 + m_transform.x2 * temp.y1;
1475 newTransform.y1 = m_transform.y1 * temp.x1 + m_transform.y2 * temp.y1;
1476 newTransform.x2 = m_transform.x1 * temp.x2 + m_transform.x2 * temp.y2;
1477 newTransform.y2 = m_transform.y1 * temp.x2 + m_transform.y2 * temp.y2;
1478 m_transform = newTransform;
1479 }
1480}
@ SYM_ROTATE_CLOCKWISE

References m_transform, SetOrientation(), SYM_MIRROR_X, SYM_MIRROR_Y, SYM_NORMAL, SYM_ORIENT_0, SYM_ORIENT_180, SYM_ORIENT_270, SYM_ORIENT_90, SYM_ROTATE_CLOCKWISE, SYM_ROTATE_COUNTERCLOCKWISE, TRANSFORM::x1, TRANSFORM::x2, TRANSFORM::y1, and TRANSFORM::y2.

Referenced by GetOrientation(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol(), SCH_EDIT_TOOL::Mirror(), MirrorHorizontally(), MirrorVertically(), SCH_ALTIUM_PLUGIN::ParsePowerPort(), Rotate(), SetOrientation(), SCH_EDIT_TOOL::Swap(), and DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow().

◆ SetParent()

virtual void EDA_ITEM::SetParent ( EDA_ITEM aParent)
inlinevirtualinherited

Reimplemented in LIB_SYMBOL, and PCB_DIMENSION_BASE.

Definition at line 100 of file eda_item.h.

100{ m_parent = aParent; }

References EDA_ITEM::m_parent.

Referenced by BOARD::Add(), FOOTPRINT::Add(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), BOARD_NETLIST_UPDATER::addNewFootprint(), SCH_SHEET::AddPin(), PAD::AddPrimitive(), PAD::AddPrimitiveAnnotationBox(), PAD::AddPrimitiveArc(), PAD::AddPrimitiveCircle(), PAD::AddPrimitiveCurve(), PAD::AddPrimitivePoly(), PAD::AddPrimitiveRect(), PAD::AddPrimitiveSegment(), SYMBOL_EDITOR_CONTROL::AddSymbolToSchematic(), SCH_SCREEN::Append(), LIB_FIELD::Copy(), SYMBOL_EDIT_FRAME::CreateNewSymbol(), SCH_DRAWING_TOOLS::createNewText(), DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES(), DIALOG_PIN_PROPERTIES::DIALOG_PIN_PROPERTIES(), PCBNEW_JOBS_HANDLER::doFpExportSvg(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PCB_EDIT_FRAME::ExchangeFootprint(), LIB_SYMBOL::Flatten(), FOOTPRINT::FOOTPRINT(), PCB_PLUGIN::FootprintSave(), DISPLAY_FOOTPRINTS_FRAME::GetFootprint(), CADSTAR_SCH_ARCHIVE_LOADER::getKiCadSchText(), LIB_SYMBOL::LIB_SYMBOL(), SCH_LEGACY_PLUGIN_CACHE::loadAliases(), CADSTAR_SCH_ARCHIVE_LOADER::loadChildSheets(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), SCH_SEXPR_PLUGIN::loadHierarchy(), SCH_LEGACY_PLUGIN::loadHierarchy(), KI_TEST::LoadHierarchy(), LIB_SYMBOL::operator=(), FOOTPRINT::operator=(), PCB_PARSER::parseFOOTPRINT_unchecked(), SCH_SEXPR_PARSER::ParseSchematic(), SCH_SEXPR_PARSER::ParseSymbol(), SCH_EDITOR_CONTROL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PCB_CONTROL::Paste(), pasteFootprintItemsToFootprintEditor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), BACK_ANNOTATE::processNetNameChange(), BOARD_COMMIT::Push(), SCH_LIB_PLUGIN_CACHE::removeSymbol(), PCB_BASE_EDIT_FRAME::saveCopyInUndoList(), SaveCopyOfZones(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), CLIPBOARD_IO::SaveSelection(), SCH_SHEET_PIN::SCH_SHEET_PIN(), LIB_SYMBOL::SetFields(), PCB_DIMENSION_BASE::SetParent(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_LINE_WIRE_BUS_TOOL::startSegments(), SCH_LABEL_BASE::SwapData(), SCH_SHEET::SwapData(), SwapData(), BOARD_ITEM::SwapItemData(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ SetPosition()

void SCH_SYMBOL::SetPosition ( const VECTOR2I aPosition)
inlineoverridevirtual

Reimplemented from EDA_ITEM.

Definition at line 713 of file sch_symbol.h.

713{ Move( aPosition - m_pos ); }
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_symbol.h:630

References m_pos, and Move().

Referenced by CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol(), SCH_ALTIUM_PLUGIN::ParseComponent(), SCH_ALTIUM_PLUGIN::ParsePowerPort(), and SCH_DRAWING_TOOLS::PlaceSymbol().

◆ SetPrefix()

void SCH_SYMBOL::SetPrefix ( const wxString &  aPrefix)
inline

Definition at line 276 of file sch_symbol.h.

276{ m_prefix = aPrefix; }

References m_prefix.

Referenced by UpdatePrefix().

◆ SetRef()

void SCH_SYMBOL::SetRef ( const SCH_SHEET_PATH aSheet,
const wxString &  aReference 
)

Set the reference for the given sheet path for this symbol.

Parameters
aSheetis the hierarchical path of the reference.
aReferenceis the new reference for the symbol.

Definition at line 694 of file sch_symbol.cpp.

695{
696 KIID_PATH path = sheet->Path();
697 bool found = false;
698
699 // check to see if it is already there before inserting it
701 {
702 if( instance.m_Path == path )
703 {
704 found = true;
705 instance.m_Reference = ref;
706 break;
707 }
708 }
709
710 if( !found )
712
713 for( std::unique_ptr<SCH_PIN>& pin : m_pins )
714 pin->ClearDefaultNetName( sheet );
715
716 if( Schematic() && *sheet == Schematic()->CurrentSheet() )
717 m_fields[ REFERENCE_FIELD ].SetText( ref );
718
719 // Reinit the m_prefix member if needed
721
722 if( m_prefix.IsEmpty() )
723 m_prefix = wxT( "U" );
724
725 // Power symbols have references starting with # and are not included in netlists
726 m_isInNetlist = ! ref.StartsWith( wxT( "#" ) );
727}

References AddHierarchicalReference(), UTIL::GetRefDesPrefix(), m_fields, m_instanceReferences, m_isInNetlist, m_pins, m_prefix, m_unit, SCH_SHEET_PATH::Path(), path, pin, REFERENCE_FIELD, and SCH_ITEM::Schematic().

Referenced by SCH_REFERENCE::Annotate(), BACK_ANNOTATE::applyChangelist(), GetRef(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol(), SCH_ALTIUM_PLUGIN::ParseDesignator(), SCH_ALTIUM_PLUGIN::ParsePowerPort(), SCH_EDIT_FRAME::PutDataInPreviousState(), SCH_FIELD::Replace(), SCH_REFERENCE::SCH_REFERENCE(), SCH_SYMBOL(), TEST_SCH_PIN_FIXTURE::TEST_SCH_PIN_FIXTURE(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_SCH_FIELD_PROPERTIES::UpdateField(), UpdateFields(), and SCH_EDITOR_CONTROL::updatePastedSymbol().

◆ SetSchSymbolLibraryName()

void SCH_SYMBOL::SetSchSymbolLibraryName ( const wxString &  aName)
inline

The name of the symbol in the schematic library symbol list.

Note
See SCH_SCREEN::m_libSymbols

The name of the schematic symbol list entry can vary from the item name in the LIB_ID object because the library symbol may have changed so a new name has to be generated but the original symbol library link has to be preserved in order to update it from the library at some point in the future. If this name is empty, then the library item name from LIB_ID is used.

Definition at line 188 of file sch_symbol.h.

188{ m_schLibSymbolName = aName; }

References m_schLibSymbolName.

Referenced by SCH_SCREEN::Append().

◆ SetSelected()

◆ SetState()

void EDA_ITEM::SetState ( EDA_ITEM_FLAGS  type,
bool  state 
)
inlineinherited

Definition at line 128 of file eda_item.h.

129 {
130 if( state )
131 m_status |= type; // state = ON or OFF
132 else
133 m_status &= ~type;
134 }

References EDA_ITEM::m_status.

Referenced by LEGACY_PLUGIN::loadTrackList(), and TRACKS_CLEANER::mergeCollinearSegments().

◆ SetStatus()

void EDA_ITEM::SetStatus ( EDA_ITEM_FLAGS  aStatus)
inlineinherited

Definition at line 137 of file eda_item.h.

137{ m_status = aStatus; }

References EDA_ITEM::m_status.

Referenced by BOARD_NETLIST_UPDATER::UpdateNetlist().

◆ SetStoredPos()

void SCH_ITEM::SetStoredPos ( const VECTOR2I aPos)
inlineinherited

Definition at line 210 of file sch_item.h.

210{ m_storedPos = aPos; }

References SCH_ITEM::m_storedPos.

Referenced by SCH_MOVE_TOOL::Main().

◆ SetStroke()

virtual void SCH_ITEM::SetStroke ( const STROKE_PARAMS aStroke)
inlinevirtualinherited

Reimplemented in SCH_BUS_ENTRY_BASE, SCH_LINE, and SCH_SHAPE.

Definition at line 459 of file sch_item.h.

459{ wxCHECK( false, /* void */ ); }

Referenced by DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem().

◆ SetTransform()

void SCH_SYMBOL::SetTransform ( const TRANSFORM aTransform)

Definition at line 413 of file sch_symbol.cpp.

414{
415 if( m_transform != aTransform )
416 {
417 m_transform = aTransform;
418 SetModified();
419 }
420}

References m_transform, and EDA_ITEM::SetModified().

◆ SetUnit()

void SCH_SYMBOL::SetUnit ( int  aUnit)

Change the unit number to aUnit.

This has meaning only for symbols made up of multiple units per package.

Note
This also set the modified flag bit
Parameters
aUnitis the new unit to select.

Definition at line 384 of file sch_symbol.cpp.

385{
386 if( m_unit != aUnit )
387 {
388 UpdateUnit( aUnit );
389 SetModified();
390 }
391}
void UpdateUnit(int aUnit)
Change the unit number to aUnit without setting any internal flags.
Definition: sch_symbol.cpp:394

References m_unit, EDA_ITEM::SetModified(), and UpdateUnit().

Referenced by SCH_REFERENCE::Annotate(), DIALOG_SYMBOL_PROPERTIES::OnUnitChoice(), SCH_ALTIUM_PLUGIN::ParseComponent(), SCH_DRAWING_TOOLS::PlaceSymbol(), SCH_EDIT_FRAME::SelectUnit(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), and SCH_EDITOR_CONTROL::updatePastedSymbol().

◆ SetUnitSelection() [1/2]

void SCH_SYMBOL::SetUnitSelection ( const SCH_SHEET_PATH aSheet,
int  aUnitSelection 
)

Set the selected unit of this symbol on one sheet.

Definition at line 787 of file sch_symbol.cpp.

788{
789 KIID_PATH path = aSheet->Path();
790
791 // check to see if it is already there before inserting it
793 {
794 if( instance.m_Path == path )
795 {
796 instance.m_Unit = aUnitSelection;
797 return;
798 }
799 }
800
801 // didn't find it; better add it
803}

References AddHierarchicalReference(), UTIL::GetRefDesUnannotated(), m_instanceReferences, m_prefix, SCH_SHEET_PATH::Path(), and path.

Referenced by SCH_REFERENCE::Annotate(), SCH_DRAWING_TOOLS::PlaceSymbol(), SCH_EDIT_FRAME::SelectUnit(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), and SCH_EDITOR_CONTROL::updatePastedSymbol().

◆ SetUnitSelection() [2/2]

void SCH_SYMBOL::SetUnitSelection ( int  aUnitSelection)

Set the selected unit of this symbol for all sheets.

Definition at line 806 of file sch_symbol.cpp.

807{
809 instance.m_Unit = aUnitSelection;
810}

References m_instanceReferences.

◆ SetValueFieldText()

◆ Sort()

static bool EDA_ITEM::Sort ( const EDA_ITEM aLeft,
const EDA_ITEM aRight 
)
inlinestaticinherited

Helper function to be used by the C++ STL sort algorithm for sorting a STL container of EDA_ITEM pointers.

Parameters
aLeftThe left hand item to compare.
aRightThe right