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< SYMBOL_INSTANCE_REFERENCE > & GetInstanceReferences ()
 
bool GetInstance (SYMBOL_INSTANCE_REFERENCE &aInstance, const KIID_PATH &aSheetPath) const
 
void SetDefaultInstance (const SYMBOL_INSTANCE_REFERENCE &aInstance)
 
void RemoveInstance (const SCH_SHEET_PATH &aInstancePath)
 
const SYMBOL_INSTANCE_REFERENCEGetDefaultInstance () const
 
void SetInstanceToDefault (const SCH_SHEET_PATH &aInstance)
 
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)
 
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...
 
SCH_FIELDFindField (const wxString &aFieldName, bool aIncludeDefaultFields=true)
 Search for a SCH_FIELD with aFieldName. More...
 
void SetFields (const SCH_FIELDS &aFields)
 Set multiple schematic fields. More...
 
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 * > GetLibPins () const
 Return a vector with all the pins from the library object. More...
 
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< SCH_PIN * > GetAllPins () const
 Retrieve all SCH_PINs (from all sheets) 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, const wxString &aValue=wxEmptyString, const wxString &aFootprint=wxEmptyString)
 Add a full hierarchical reference to this symbol. More...
 
void AddHierarchicalReference (const SYMBOL_INSTANCE_REFERENCE &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...
 
const wxString GetValue (const SCH_SHEET_PATH *sheet, bool aResolve) const
 Return the instance-specific value for the given sheet path. More...
 
void SetValue (const SCH_SHEET_PATH *sheet, const wxString &aValue)
 
void SetValue (const wxString &aValue)
 Set the value for all instances (the default GUI behavior). More...
 
const wxString GetFootprint (const SCH_SHEET_PATH *sheet, bool aResolve) const
 Return the instance-specific footprint assignment for the given sheet path. More...
 
void SetFootprint (const SCH_SHEET_PATH *sheet, const wxString &aFootprint)
 
void SetFootprint (const wxString &aFootprint)
 Set the value for all instances (the default GUI behavior). 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 GetSelectMenuText (UNITS_PROVIDER *aUnitsProvider) const override
 Return the text to display to be used in the selection clarification context menu when multiple items are found at the current cursor position. 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...
 
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 IsDragging () const
 
bool IsWireImage () const
 
bool IsSelected () const
 
bool IsEntered () const
 
bool IsResized () const
 
bool IsBrightened () const
 
bool IsRollover () const
 
void SetWireImage ()
 
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 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 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 ()
 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< SYMBOL_INSTANCE_REFERENCEm_instanceReferences
 
SYMBOL_INSTANCE_REFERENCE m_defaultInstance
 The default instance data for this symbol. More...
 
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 79 of file sch_symbol.h.

Constructor & Destructor Documentation

◆ SCH_SYMBOL() [1/4]

SCH_SYMBOL::SCH_SYMBOL ( )

Definition at line 100 of file sch_symbol.cpp.

100 :
101 SCH_ITEM( nullptr, SCH_SYMBOL_T )
102{
103 m_DNP = false;
104 Init( VECTOR2I( 0, 0 ) );
105}
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:206
bool m_DNP
True if symbol is set to 'Do Not Populate'.
Definition: sch_symbol.h:800
@ SCH_SYMBOL_T
Definition: typeinfo.h:155
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 108 of file sch_symbol.cpp.

110 :
111 SCH_ITEM( aParent, SCH_SYMBOL_T )
112{
113 Init( aPosition );
114
115 m_unit = aUnit;
116 m_convert = aConvert;
117 m_lib_id = aLibId;
118
119 std::unique_ptr< LIB_SYMBOL > part;
120
121 part = aSymbol.Flatten();
122 part->SetParent();
123 SetLibSymbol( part.release() );
124
125 // Copy fields from the library symbol
126 UpdateFields( aSheet,
127 true, /* update style */
128 false, /* update ref */
129 false, /* update other fields */
130 true, /* reset ref */
131 true /* reset other fields */ );
132
133 m_prefix = UTIL::GetRefDesPrefix( m_part->GetReferenceField().GetText() );
134
135 // Set initial default symbol instance data from library symbol and initial unit.
137
138 if( aSheet )
139 {
141
142 // Value and footprint name are stored in the SCH_SHEET_PATH path manager,
143 // if aSheet != nullptr, not in the symbol itself.
144 // Copy them to the currently displayed field texts
145 SetValue( GetValue( aSheet, false ) );
146 SetFootprint( GetFootprint( aSheet, false ) );
147 }
148
149 // Inherit the include in bill of materials and board netlist settings from library symbol.
150 m_inBom = aSymbol.GetIncludeInBom();
151 m_onBoard = aSymbol.GetIncludeOnBoard();
152 m_DNP = false;
153
154}
bool GetIncludeOnBoard() const
Definition: lib_symbol.h:660
bool GetIncludeInBom() const
Definition: lib_symbol.h:652
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:460
wxString m_prefix
C, R, U, Q etc - the first character(s) which typically indicate what the symbol is.
Definition: sch_symbol.h:775
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
Definition: sch_symbol.h:770
void SetValue(const SCH_SHEET_PATH *sheet, const wxString &aValue)
Definition: sch_symbol.cpp:795
const wxString GetFootprint(const SCH_SHEET_PATH *sheet, bool aResolve) const
Return the instance-specific footprint assignment for the given sheet path.
Definition: sch_symbol.cpp:833
SYMBOL_INSTANCE_REFERENCE m_defaultInstance
The default instance data for this symbol.
Definition: sch_symbol.h:814
int m_convert
The alternate body style for symbols that have more than one body style defined.
Definition: sch_symbol.h:772
void SetFootprint(const SCH_SHEET_PATH *sheet, const wxString &aFootprint)
Definition: sch_symbol.cpp:854
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:974
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:674
bool m_onBoard
True to include in netlist when updating board.
Definition: sch_symbol.h:799
int m_unit
The unit for multiple part per package symbols.
Definition: sch_symbol.h:771
const wxString GetValue(const SCH_SHEET_PATH *sheet, bool aResolve) const
Return the instance-specific value for the given sheet path.
Definition: sch_symbol.cpp:767
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
Definition: sch_symbol.cpp:305
bool m_inBom
True to include in bill of materials export.
Definition: sch_symbol.h:798
std::unique_ptr< LIB_SYMBOL > m_part
a flattened copy of the LIB_SYMBOL from the PROJECT's libraries.
Definition: sch_symbol.h:792
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(), GetFootprint(), LIB_SYMBOL::GetIncludeInBom(), LIB_SYMBOL::GetIncludeOnBoard(), UTIL::GetRefDesPrefix(), UTIL::GetRefDesUnannotated(), GetValue(), Init(), m_convert, m_defaultInstance, m_DNP, m_inBom, m_lib_id, m_onBoard, m_part, m_prefix, SYMBOL_INSTANCE_REFERENCE::m_Unit, m_unit, SetFootprint(), SetLibSymbol(), SetRef(), SetValue(), 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 157 of file sch_symbol.cpp.

159 :
160 SCH_SYMBOL( aSymbol, aSel.LibId, aSheet, aSel.Unit, aSel.Convert, aPosition, aParent )
161{
162 // Set any fields that were modified as part of the symbol selection
163 for( const std::pair<int, wxString>& i : aSel.Fields )
164 {
165 SCH_FIELD* field = GetFieldById( i.first );
166
167 if( field )
168 field->SetText( i.second );
169 }
170}
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:163
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:50
SCH_FIELD * GetFieldById(int aFieldId)
Return a field in this symbol.
Definition: sch_symbol.cpp:904
LIB_ID LibId
Definition: sch_screen.h:79
std::vector< std::pair< int, wxString > > Fields
Definition: sch_screen.h:83

References PICKED_SYMBOL::Fields, GetFieldById(), and EDA_TEXT::SetText().

◆ 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 173 of file sch_symbol.cpp.

173 :
174 SCH_ITEM( aSymbol )
175{
176 m_parent = aSymbol.m_parent;
177 m_pos = aSymbol.m_pos;
178 m_unit = aSymbol.m_unit;
179 m_convert = aSymbol.m_convert;
180 m_lib_id = aSymbol.m_lib_id;
182 m_inBom = aSymbol.m_inBom;
183 m_onBoard = aSymbol.m_onBoard;
184 m_DNP = aSymbol.m_DNP;
185
186 if( aSymbol.m_part )
187 SetLibSymbol( new LIB_SYMBOL( *aSymbol.m_part.get() ) );
188
189 const_cast<KIID&>( m_Uuid ) = aSymbol.m_Uuid;
190
191 m_transform = aSymbol.m_transform;
192 m_prefix = aSymbol.m_prefix;
194 m_fields = aSymbol.m_fields;
195
196 // Re-parent the fields, which before this had aSymbol as parent
197 for( SCH_FIELD& field : m_fields )
198 field.SetParent( this );
199
203}
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:47
Define a library symbol object.
Definition: lib_symbol.h:98
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:493
VECTOR2I m_pos
Definition: sch_symbol.h:769
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
Definition: sch_symbol.h:804
wxString m_schLibSymbolName
The name used to look up a symbol in the symbol library embedded in a schematic.
Definition: sch_symbol.h:787
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:790
bool m_isInNetlist
True if the symbol should appear in the netlist.
Definition: sch_symbol.h:797
TRANSFORM m_transform
The rotation/mirror transformation.
Definition: sch_symbol.h:789

References m_convert, m_defaultInstance, 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 112 of file sch_symbol.h.

112{ }

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 938 of file sch_symbol.cpp.

939{
940 int newNdx = m_fields.size();
941
942 m_fields.push_back( aField );
943 return &m_fields[newNdx];
944}

References m_fields.

Referenced by FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances(), SCH_SHEET_LIST::MigrateSimModelNameFields(), SCH_ALTIUM_PLUGIN::ParseParameter(), DIALOG_CHANGE_SYMBOLS::processSymbol(), and UpdateFields().

◆ AddHierarchicalReference() [1/2]

void SCH_SYMBOL::AddHierarchicalReference ( const KIID_PATH aPath,
const wxString &  aRef,
int  aUnit,
const wxString &  aValue = wxEmptyString,
const wxString &  aFootprint = wxEmptyString 
)

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 525 of file sch_symbol.cpp.

528{
529 // Search for an existing path and remove it if found (should not occur)
530 for( unsigned ii = 0; ii < m_instanceReferences.size(); ii++ )
531 {
532 if( m_instanceReferences[ii].m_Path == aPath )
533 {
534 wxLogTrace( traceSchSheetPaths, "Removing symbol instance:\n"
535 " sheet path %s\n"
536 " reference %s, unit %d from symbol %s.",
537 aPath.AsString(),
538 m_instanceReferences[ii].m_Reference,
539 m_instanceReferences[ii].m_Unit,
540 m_Uuid.AsString() );
541
542 m_instanceReferences.erase( m_instanceReferences.begin() + ii );
543 ii--;
544 }
545 }
546
548 instance.m_Path = aPath;
549 instance.m_Reference = aRef;
550 instance.m_Unit = aUnit;
551 instance.m_Value = aValue;
552 instance.m_Footprint = aFootprint;
553
554 wxLogTrace( traceSchSheetPaths,
555 "Adding symbol '%s' instance:\n"
556 " sheet path '%s'\n"
557 " reference '%s'\n"
558 " unit %d\n"
559 " value '%s'\n"
560 " footprint '%s'",
562 aPath.AsString(),
563 aRef,
564 aUnit,
565 aValue,
566 aFootprint );
567
568 m_instanceReferences.push_back( instance );
569
570 // This should set the default instance to the first saved instance data for each symbol
571 // when importing sheets.
572 if( m_instanceReferences.size() == 1 )
573 {
574 m_fields[ REFERENCE_FIELD ].SetText( aRef );
575 m_fields[ VALUE_FIELD ].SetText( aValue );
576 m_unit = aUnit;
577 m_fields[ FOOTPRINT_FIELD ].SetText( aFootprint );
578 }
579}
wxString AsString() const
Definition: kiid.cpp:330
wxString AsString() const
Definition: kiid.cpp:249
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
A simple container for schematic symbol instance information.
@ FOOTPRINT_FIELD
Field Name Module PCB, i.e. "16DIP300".
@ VALUE_FIELD
Field Value of part, i.e. "3.3K".
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".

References KIID::AsString(), KIID_PATH::AsString(), FOOTPRINT_FIELD, m_fields, SYMBOL_INSTANCE_REFERENCE::m_Footprint, m_instanceReferences, SYMBOL_INSTANCE_REFERENCE::m_Path, SYMBOL_INSTANCE_REFERENCE::m_Reference, SYMBOL_INSTANCE_REFERENCE::m_Unit, m_unit, EDA_ITEM::m_Uuid, SYMBOL_INSTANCE_REFERENCE::m_Value, REFERENCE_FIELD, traceSchSheetPaths, and VALUE_FIELD.

Referenced by SCH_SHEET_PATH::AddNewSymbolInstances(), AddSheetPathReferenceEntryIfMissing(), SetFootprint(), SetInstanceToDefault(), SCH_SCREEN::SetLegacySymbolInstanceData(), SetRef(), SetUnitSelection(), SetValue(), and SCH_SHEET_LIST::UpdateSymbolInstances().

◆ AddHierarchicalReference() [2/2]

void SCH_SYMBOL::AddHierarchicalReference ( const SYMBOL_INSTANCE_REFERENCE aInstance)

Definition at line 582 of file sch_symbol.cpp.

583{
584 // Search for an existing path and remove it if found (should not occur)
585 for( unsigned ii = 0; ii < m_instanceReferences.size(); ii++ )
586 {
587 if( m_instanceReferences[ii].m_Path == aInstance.m_Path )
588 {
589 wxLogTrace( traceSchSheetPaths, "Removing symbol instance:\n"
590 " sheet path %s\n"
591 " reference %s, unit %d from symbol %s.",
592 aInstance.m_Path.AsString(),
593 m_instanceReferences[ii].m_Reference,
594 m_instanceReferences[ii].m_Unit,
595 m_Uuid.AsString() );
596
597 m_instanceReferences.erase( m_instanceReferences.begin() + ii );
598 ii--;
599 }
600 }
601
602 SYMBOL_INSTANCE_REFERENCE instance = aInstance;
603
604 wxLogTrace( traceSchSheetPaths,
605 "Adding symbol '%s' instance:\n"
606 " sheet path '%s'\n"
607 " reference '%s'\n"
608 " unit %d\n"
609 " value '%s'\n"
610 " footprint '%s'",
612 instance.m_Path.AsString(),
613 instance.m_Reference,
614 instance.m_Unit,
615 instance.m_Value,
616 instance.m_Footprint );
617
618 m_instanceReferences.push_back( instance );
619
620 // This should set the default instance to the first saved instance data for each symbol
621 // when importing sheets.
622 if( m_instanceReferences.size() == 1 )
623 {
624 m_fields[ REFERENCE_FIELD ].SetText( instance.m_Reference );
625 m_fields[ VALUE_FIELD ].SetText( instance.m_Value );
626 m_unit = instance.m_Unit;
627 m_fields[ FOOTPRINT_FIELD ].SetText( instance.m_Footprint );
628 }
629}

References KIID::AsString(), KIID_PATH::AsString(), FOOTPRINT_FIELD, m_fields, SYMBOL_INSTANCE_REFERENCE::m_Footprint, m_instanceReferences, SYMBOL_INSTANCE_REFERENCE::m_Path, SYMBOL_INSTANCE_REFERENCE::m_Reference, SYMBOL_INSTANCE_REFERENCE::m_Unit, m_unit, EDA_ITEM::m_Uuid, SYMBOL_INSTANCE_REFERENCE::m_Value, REFERENCE_FIELD, traceSchSheetPaths, and VALUE_FIELD.

◆ 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 1335 of file sch_symbol.cpp.

1336{
1337 // An empty sheet path is illegal, at a minimum the root sheet UUID must be present.
1338 wxCHECK( aSheetPath.size() > 0, false );
1339
1340 for( const SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
1341 {
1342 // if aSheetPath is found, nothing to do:
1343 if( instance.m_Path == aSheetPath )
1344 return false;
1345 }
1346
1347 // This entry does not exist: add it, with its last-used reference
1349 return true;
1350}
void AddHierarchicalReference(const KIID_PATH &aPath, const wxString &aRef, int aUnit, const wxString &aValue=wxEmptyString, const wxString &aFootprint=wxEmptyString)
Add a full hierarchical reference to this symbol.
Definition: sch_symbol.cpp:525
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:102

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 DIALOG_CHANGE_SYMBOLS::processSymbol(), 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, "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 680 of file sch_symbol.h.

681 {
682 return ( aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_WIRE ) ||
683 ( aItem->Type() == SCH_NO_CONNECT_T ) ||
684 ( aItem->Type() == SCH_JUNCTION_T ) ||
685 ( aItem->Type() == SCH_SYMBOL_T ) ||
686 ( aItem->Type() == SCH_DIRECTIVE_LABEL_T ) ||
687 ( aItem->Type() == SCH_LABEL_T ) ||
688 ( aItem->Type() == SCH_HIER_LABEL_T ) ||
689 ( aItem->Type() == SCH_GLOBAL_LABEL_T );
690 }
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:145
@ SCH_NO_CONNECT_T
Definition: typeinfo.h:142
@ SCH_DIRECTIVE_LABEL_T
Definition: typeinfo.h:153
@ SCH_LABEL_T
Definition: typeinfo.h:150
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:152
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:151
@ SCH_JUNCTION_T
Definition: typeinfo.h:141

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 114 of file sch_symbol.h.

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

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 1291 of file sch_symbol.cpp.

1292{
1293 if( aSheetPath )
1294 {
1295 KIID_PATH path = aSheetPath->Path();
1296
1298 {
1299 if( instance.m_Path == path )
1300 {
1301 if( instance.m_Reference.IsEmpty() || aResetPrefix )
1302 instance.m_Reference = UTIL::GetRefDesUnannotated( m_prefix );
1303 else
1304 instance.m_Reference = UTIL::GetRefDesUnannotated( instance.m_Reference );
1305 }
1306 }
1307 }
1308 else
1309 {
1311 {
1312 if( instance.m_Reference.IsEmpty() || aResetPrefix)
1313 instance.m_Reference = UTIL::GetRefDesUnannotated( m_prefix );
1314 else
1315 instance.m_Reference = UTIL::GetRefDesUnannotated( instance.m_Reference );
1316 }
1317 }
1318
1319 for( std::unique_ptr<SCH_PIN>& pin : m_pins )
1320 pin->ClearDefaultNetName( aSheetPath );
1321
1322 // These 2 changes do not work in complex hierarchy.
1323 // When a clear annotation is made, the calling function must call a
1324 // UpdateAllScreenReferences for the active sheet.
1325 // But this call cannot made here.
1326 wxString currentReference = m_fields[REFERENCE_FIELD].GetText();
1327
1328 if( currentReference.IsEmpty() || aResetPrefix )
1330 else
1331 m_fields[REFERENCE_FIELD].SetText( UTIL::GetRefDesUnannotated( currentReference ) );
1332}
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:794

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 122 of file eda_item.h.

void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:143
#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 2232 of file sch_symbol.cpp.

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

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 143 of file eda_item.h.

143{ 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(), FOOTPRINT::BuildCourtyardCaches(), EDA_ITEM::ClearBrightened(), EDA_ITEM::ClearEditFlags(), EDA_ITEM::ClearSelected(), EDA_ITEM::ClearTempFlags(), ConvertOutlineToPolygon(), 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(), 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_TEST_PROVIDER_COURTYARD_CLEARANCE_ON_MOVE::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(), SCH_EDIT_FRAME::SelectUnit(), EDA_ITEM::SetIsShownAsBitmap(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), SCH_DRAWING_TOOLS::TwoClickPlace(), and EE_SELECTION_TOOL::unhighlight().

◆ ClearSelected()

◆ ClearTempFlags()

void EDA_ITEM::ClearTempFlags ( )
inlineinherited

Definition at line 155 of file eda_item.h.

156 {
158 }
#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 DO_NOT_DRAW
Used to disable draw function.
#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(), DO_NOT_DRAW, 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 236 of file sch_symbol.cpp.

237{
238 return new SCH_SYMBOL( *this );
239}

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:119
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(), SCH_EDIT_FRAME::RecalculateConnections(), CONNECTION_SUBGRAPH::ResolveDrivers(), 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 1577 of file sch_symbol.cpp.

1578{
1579 BOX2I bBox;
1580
1581 if( m_part )
1582 bBox = m_part->GetBodyBoundingBox( m_unit, m_convert, aIncludePins, false );
1583 else
1584 bBox = dummy()->GetBodyBoundingBox( m_unit, m_convert, aIncludePins, false );
1585
1586 int x0 = bBox.GetX();
1587 int xm = bBox.GetRight();
1588
1589 // We must reverse Y values, because matrix orientation
1590 // suppose Y axis normal for the library items coordinates,
1591 // m_transform reverse Y values, but bBox is already reversed!
1592 int y0 = -bBox.GetY();
1593 int ym = -bBox.GetBottom();
1594
1595 // Compute the real Boundary box (rotated, mirrored ...)
1596 int x1 = m_transform.x1 * x0 + m_transform.y1 * y0;
1597 int y1 = m_transform.x2 * x0 + m_transform.y2 * y0;
1598 int x2 = m_transform.x1 * xm + m_transform.y1 * ym;
1599 int y2 = m_transform.x2 * xm + m_transform.y2 * ym;
1600
1601 bBox.SetX( x1 );
1602 bBox.SetY( y1 );
1603 bBox.SetWidth( x2 - x1 );
1604 bBox.SetHeight( y2 - y1 );
1605 bBox.Normalize();
1606
1607 bBox.Offset( m_pos );
1608
1609 if( aIncludeFields )
1610 {
1611 for( const SCH_FIELD& field : m_fields )
1612 {
1613 if( field.IsVisible() )
1614 bBox.Merge( field.GetBoundingBox() );
1615 }
1616 }
1617
1618 return bBox;
1619}
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.
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:74

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 2088 of file sch_symbol.cpp.

2089{
2091
2092 for( const auto& pin : m_pins )
2093 {
2094 if( pin->GetType() == ELECTRICAL_PINTYPE::PT_NC )
2095 continue;
2096
2097 // Collect only pins attached to the current unit and convert.
2098 // others are not associated to this symbol instance
2099 int pin_unit = pin->GetLibPin()->GetUnit();
2100 int pin_convert = pin->GetLibPin()->GetConvert();
2101
2102 if( pin_unit > 0 && pin_unit != GetUnit() )
2103 continue;
2104
2105 if( pin_convert > 0 && pin_convert != GetConvert() )
2106 continue;
2107
2108 if( pin->GetLocalPosition() == new_pos )
2109 return true;
2110 }
2111
2112 return false;
2113}
int GetUnit() const
Definition: sch_symbol.h:231
int GetConvert() const
Definition: sch_symbol.h:273
TRANSFORM InverseTransform() const
Calculate the Inverse mirror/rotation transform.
Definition: transform.cpp:56
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:41
@ 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_EDIT_FRAME::BreakSegment(), 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 960 of file sch_symbol.cpp.

961{
962 unsigned start = aIncludeDefaultFields ? 0 : MANDATORY_FIELDS;
963
964 for( unsigned i = start; i < m_fields.size(); ++i )
965 {
966 if( aFieldName == m_fields[i].GetName( false ) )
967 return &m_fields[i];
968 }
969
970 return nullptr;
971}
@ 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(), SCH_SHEET_LIST::MigrateSimModelNameFields(), DIALOG_CHANGE_SYMBOLS::processSymbol(), NETLIST_EXPORTER_SPICE::readLibraryField(), NETLIST_EXPORTER_SPICE::readNameField(), 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:270
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:63
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:65
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:60
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:42

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(), 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().

◆ GetAllPins()

std::vector< SCH_PIN * > SCH_SYMBOL::GetAllPins ( ) const

Retrieve all SCH_PINs (from all sheets)

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

◆ GetBodyAndPinsBoundingBox()

BOX2I SCH_SYMBOL::GetBodyAndPinsBoundingBox ( ) const

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

Definition at line 1628 of file sch_symbol.cpp.

1629{
1630 return doGetBoundingBox( true, false );
1631}
BOX2I doGetBoundingBox(bool aIncludePins, bool aIncludeFields) const

References doGetBoundingBox().

Referenced by AUTOPLACER::getPossibleCollisions(), EE_SELECTION_TOOL::GuessSelectionCandidates(), CADSTAR_SCH_ARCHIVE_LOADER::Load(), and operator<().

◆ GetBodyBoundingBox()

BOX2I SCH_SYMBOL::GetBodyBoundingBox ( ) const

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

Definition at line 1622 of file sch_symbol.cpp.

1623{
1624 return doGetBoundingBox( false, false );
1625}

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 1634 of file sch_symbol.cpp.

1635{
1636 return doGetBoundingBox( true, true );
1637}

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 119 of file sch_symbol.h.

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

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 1861 of file sch_symbol.cpp.

1862{
1863 std::vector<VECTOR2I> retval;
1864
1865 for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
1866 {
1867 // Collect only pins attached to the current unit and convert.
1868 // others are not associated to this symbol instance
1869 int pin_unit = pin->GetLibPin()->GetUnit();
1870 int pin_convert = pin->GetLibPin()->GetConvert();
1871
1872 if( pin_unit > 0 && pin_unit != GetUnit() )
1873 continue;
1874
1875 if( pin_convert > 0 && pin_convert != GetConvert() )
1876 continue;
1877
1878 retval.push_back( m_transform.TransformCoordinate( pin->GetLocalPosition() ) + m_pos );
1879 }
1880
1881 return retval;
1882}

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 1151 of file sch_symbol.cpp.

1152{
1153 for( int i = 0; i < MANDATORY_FIELDS; ++i )
1154 aVars->push_back( m_fields[i].GetCanonicalName().Upper() );
1155
1156 for( size_t i = MANDATORY_FIELDS; i < m_fields.size(); ++i )
1157 aVars->push_back( m_fields[i].GetName() );
1158
1159 aVars->push_back( wxT( "FOOTPRINT_LIBRARY" ) );
1160 aVars->push_back( wxT( "FOOTPRINT_NAME" ) );
1161 aVars->push_back( wxT( "UNIT" ) );
1162 aVars->push_back( wxT( "SYMBOL_LIBRARY" ) );
1163 aVars->push_back( wxT( "SYMBOL_NAME" ) );
1164 aVars->push_back( wxT( "SYMBOL_DESCRIPTION" ) );
1165 aVars->push_back( wxT( "SYMBOL_KEYWORDS" ) );
1166 aVars->push_back( wxT( "EXCLUDE_FROM_BOM" ) );
1167 aVars->push_back( wxT( "EXCLUDE_FROM_BOARD" ) );
1168 aVars->push_back( wxT( "DNP" ) );
1169}

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 332 of file sch_symbol.cpp.

333{
334 if( m_part )
335 return m_part->GetDatasheetField().GetText();
336
337 return wxEmptyString;
338}

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(), and SCH_TEXTBOX::GetDrawFont().

◆ GetDefaultInstance()

const SYMBOL_INSTANCE_REFERENCE & SCH_SYMBOL::GetDefaultInstance ( ) const
inline

◆ GetDescription()

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

Definition at line 314 of file sch_symbol.cpp.

315{
316 if( m_part )
317 return m_part->GetDescription();
318
319 return wxEmptyString;
320}

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 1885 of file sch_symbol.cpp.

1886{
1887 if( m_part )
1888 {
1889 // Calculate the position relative to the symbol.
1890 VECTOR2I libPosition = aPosition - m_pos;
1891
1892 return m_part->LocateDrawItem( m_unit, m_convert, aType, libPosition, m_transform );
1893 }
1894
1895 return nullptr;
1896}

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 147 of file eda_item.h.

148 {
149 constexpr int mask = ( IS_NEW | IS_PASTED | IS_MOVING | IS_RESIZING | IS_DRAGGING
151
152 return m_flags & mask;
153 }
#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_DRAGGING
Item being dragged.
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.
#define STRUCT_DELETED
flag indication structures to be erased
#define IS_MOVING
Item being moved.
#define IS_RESIZING
Item being resized.

References IS_CHANGED, IS_DRAGGING, IS_MOVING, IS_NEW, IS_PASTED, IS_RESIZING, IS_WIRE_IMAGE, 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:148
Holds all the data relating to one schematic.
Definition: schematic.h:60
PROJECT & Prj() const override
Return a reference to the project this schematic is part of.
Definition: schematic.h:75
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 1787 of file sch_symbol.cpp.

1788{
1789 for( auto& pin : m_pins )
1790 {
1791 LIB_PIN* lib_pin = pin->GetLibPin();
1792
1793 if( lib_pin->GetUnit() && m_unit && ( m_unit != lib_pin->GetUnit() ) )
1794 continue;
1795
1796 DANGLING_END_ITEM item( PIN_END, lib_pin, GetPinPhysicalPosition( lib_pin ), this );
1797 aItemList.push_back( item );
1798 }
1799}
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 898 of file sch_symbol.cpp.

899{
900 return &m_fields[aFieldType];
901}

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 904 of file sch_symbol.cpp.

905{
906 for( size_t ii = 0; ii < m_fields.size(); ++ii )
907 {
908 if( m_fields[ii].GetId() == aFieldId )
909 return &m_fields[ii];
910 }
911
912 return nullptr;
913}

References m_fields.

Referenced by SCH_SYMBOL(), UpdateFields(), and SIM_PLOT_FRAME::UpdateTunerValue().

◆ GetFieldCount()

◆ GetFields() [1/3]

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

Return a vector of fields from the symbol.

Definition at line 421 of file sch_symbol.h.

421{ 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 422 of file sch_symbol.h.

422{ return m_fields; }

References m_fields.

◆ GetFields() [3/3]

◆ 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(), SCH_SEXPR_PLUGIN::saveText(), and EE_POINT_EDITOR::updateParentItem().

◆ 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 916 of file sch_symbol.cpp.

917{
918 for( const SCH_FIELD& field : m_fields )
919 {
920 if( aFieldName == field.GetName() || aFieldName == field.GetCanonicalName() )
921 return field.GetText();
922 }
923
924 return wxEmptyString;
925}

References m_fields.

Referenced by FIELDS_EDITOR_GRID_DATA_MODEL::AddColumn(), and SCH_ALTIUM_PLUGIN::ParseParameter().

◆ 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().

◆ GetFootprint()

const wxString SCH_SYMBOL::GetFootprint ( const SCH_SHEET_PATH sheet,
bool  aResolve 
) const

Return the instance-specific footprint assignment for the given sheet path.

Definition at line 833 of file sch_symbol.cpp.

834{
835 KIID_PATH path = sheet->Path();
836
837 for( const SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
838 {
839 if( instance.m_Path == path && !instance.m_Footprint.IsEmpty() )
840 {
841 // This can only be an override from an Update Schematic from PCB, and therefore
842 // will always be fully resolved.
843 return instance.m_Footprint;
844 }
845 }
846
847 if( !aResolve )
848 return GetField( FOOTPRINT_FIELD )->GetText();
849
851}
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_field.cpp:169
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:892

References FOOTPRINT_FIELD, GetField(), SCH_FIELD::GetShownText(), EDA_TEXT::GetText(), m_instanceReferences, SCH_SHEET_PATH::Path(), and path.

Referenced by NETLIST_EXPORTER_XML::addSymbolFields(), GetMsgPanelInfo(), netList(), SCH_FIELD::Replace(), ResolveTextVar(), SCH_REFERENCE::SCH_REFERENCE(), SCH_SYMBOL(), SCH_SHEET_PATH::UpdateAllScreenReferences(), and NETLIST_EXPORTER_ORCADPCB2::WriteNetlist().

◆ GetIncludeInBom()

bool SCH_SYMBOL::GetIncludeInBom ( ) const
inline

◆ GetIncludeOnBoard()

◆ GetInstance()

bool SCH_SYMBOL::GetInstance ( SYMBOL_INSTANCE_REFERENCE aInstance,
const KIID_PATH aSheetPath 
) const

Definition at line 487 of file sch_symbol.cpp.

489{
490 for( const SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
491 {
492 if( instance.m_Path == aSheetPath )
493 {
494 aInstance = instance;
495 return true;
496 }
497 }
498
499 return false;
500}

References m_instanceReferences.

Referenced by SCH_SHEET_PATH::AddNewSymbolInstances().

◆ GetInstanceReferences()

◆ GetKeyWords()

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

Definition at line 323 of file sch_symbol.cpp.

324{
325 if( m_part )
326 return m_part->GetKeyWords();
327
328 return wxEmptyString;
329}

References m_part.

Referenced by ResolveTextVar().

◆ GetLayer()

◆ GetLibId()

◆ GetLibPins() [1/2]

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

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

Returns
List of the pins

Definition at line 1072 of file sch_symbol.cpp.

1073{
1074 std::vector<LIB_PIN*> pinList;
1075
1076 GetLibPins( pinList );
1077 return pinList;
1078}
std::vector< LIB_PIN * > GetLibPins() const
Return a vector with all the pins from the library object.

References GetLibPins().

Referenced by GetLibPins().

◆ GetLibPins() [2/2]

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 1065 of file sch_symbol.cpp.

1066{
1067 if( m_part )
1068 m_part->GetPins( aPinsList, m_unit, m_convert );
1069}

References m_convert, m_part, and m_unit.

Referenced by DIALOG_SIM_MODEL< T >::DIALOG_SIM_MODEL().

◆ GetLibSymbolRef() [1/2]

◆ GetLibSymbolRef() [2/2]

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

Definition at line 196 of file sch_symbol.h.

196{ 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 1719 of file sch_symbol.cpp.

1720{
1722}
@ 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 1640 of file sch_symbol.cpp.

1641{
1642 wxString msg;
1643
1644 SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( aFrame );
1645 SCH_SHEET_PATH* currentSheet = schframe ? &schframe->GetCurrentSheet() : nullptr;
1646
1647 // part and alias can differ if alias is not the root
1648 if( m_part )
1649 {
1650 if( m_part.get() != dummy() )
1651 {
1652 if( m_part->IsPower() )
1653 {
1654 aList.emplace_back( _( "Power symbol" ), GetValue( currentSheet, true ) );
1655 }
1656 else
1657 {
1658 aList.emplace_back( _( "Reference" ), GetRef( currentSheet ) );
1659 aList.emplace_back( _( "Value" ), GetValue( currentSheet, true ) );
1660 aList.emplace_back( _( "Name" ), UnescapeString( GetLibId().GetLibItemName() ) );
1661 }
1662
1663#if 0 // Display symbol flags, for debug only
1664 aList.emplace_back( _( "flags" ), wxString::Format( "%X", GetEditFlags() ) );
1665#endif
1666
1667 if( !m_part->IsRoot() )
1668 {
1669 msg = _( "Missing parent" );
1670
1671 std::shared_ptr< LIB_SYMBOL > parent = m_part->GetParent().lock();
1672
1673 if( parent )
1674 msg = parent->GetName();
1675
1676 aList.emplace_back( _( "Alias of" ), UnescapeString( msg ) );
1677 }
1678 else if( !m_lib_id.GetLibNickname().empty() )
1679 {
1680 aList.emplace_back( _( "Library" ), m_lib_id.GetLibNickname() );
1681 }
1682 else
1683 {
1684 aList.emplace_back( _( "Library" ), _( "Undefined!!!" ) );
1685 }
1686
1687 // Display the current associated footprint, if exists.
1688 msg = GetFootprint( currentSheet, true );
1689
1690 if( msg.IsEmpty() )
1691 msg = _( "<Unknown>" );
1692
1693 aList.emplace_back( _( "Footprint" ), msg );
1694
1695 // Display description of the symbol, and keywords found in lib
1696 aList.emplace_back( _( "Description" ), m_part->GetDescription() );
1697 aList.emplace_back( _( "Keywords" ), m_part->GetKeyWords() );
1698 }
1699 }
1700 else
1701 {
1702 aList.emplace_back( _( "Reference" ), GetRef( currentSheet ) );
1703
1704 aList.emplace_back( _( "Value" ), GetValue( currentSheet, true ) );
1705 aList.emplace_back( _( "Name" ), GetLibId().GetLibItemName() );
1706
1707 wxString libNickname = GetLibId().GetLibNickname();
1708
1709 if( libNickname.empty() )
1710 msg = _( "No library defined!" );
1711 else
1712 msg.Printf( _( "Symbol not found in %s!" ), libNickname );
1713
1714 aList.emplace_back( _( "Library" ), msg );
1715 }
1716}
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:632
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:178
bool empty() const
Definition: utf8.h:103
#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 _, dummy(), UTF8::empty(), Format(), SCH_EDIT_FRAME::GetCurrentSheet(), EDA_ITEM::GetEditFlags(), GetFootprint(), GetLibId(), LIB_ID::GetLibNickname(), GetRef(), GetValue(), 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 1508 of file sch_symbol.cpp.

1509{
1510 int rotate_values[] =
1511 {
1524 };
1525
1526 // Try to find the current transform option:
1527 TRANSFORM transform = m_transform;
1528 SCH_SYMBOL temp( *this );
1529
1530 for( int type_rotate : rotate_values )
1531 {
1532 temp.SetOrientation( type_rotate );
1533
1534 if( transform == temp.GetTransform() )
1535 return type_rotate;
1536 }
1537
1538 // Error: orientation not found in list (should not happen)
1539 wxFAIL_MSG( "Schematic symbol orientation matrix internal error." );
1540
1541 return SYM_NORMAL;
1542}
Schematic symbol object.
Definition: sch_symbol.h:80
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 1053 of file sch_symbol.cpp.

1054{
1055 for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
1056 {
1057 if( pin->GetNumber() == aNumber )
1058 return pin.get();
1059 }
1060
1061 return nullptr;
1062}

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

Definition at line 1081 of file sch_symbol.cpp.

1082{
1083 wxASSERT( m_pinMap.count( aLibPin ) );
1084 return m_pins[ m_pinMap.at( aLibPin ) ].get();
1085}
std::unordered_map< LIB_PIN *, unsigned > m_pinMap
library pin pointer : SCH_PIN's index
Definition: sch_symbol.h:795

References m_pinMap, and m_pins.

◆ GetPinPhysicalPosition()

VECTOR2I SCH_SYMBOL::GetPinPhysicalPosition ( const LIB_PIN Pin) const

Definition at line 1852 of file sch_symbol.cpp.

1853{
1854 wxCHECK_MSG( Pin != nullptr && Pin->Type() == LIB_PIN_T, VECTOR2I( 0, 0 ),
1855 wxT( "Cannot get physical position of pin." ) );
1856
1858}
VECTOR2I GetPosition() const override
Definition: lib_pin.h:224
@ 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 1088 of file sch_symbol.cpp.

1089{
1090 std::vector<SCH_PIN*> pins;
1091
1092 if( aSheet == nullptr )
1093 {
1094 wxCHECK_MSG( Schematic(), pins, "Can't call GetPins on a symbol with no schematic" );
1095
1096 aSheet = &Schematic()->CurrentSheet();
1097 }
1098
1099 int unit = GetUnitSelection( aSheet );
1100
1101 for( const std::unique_ptr<SCH_PIN>& p : m_pins )
1102 {
1103 if( unit && p->GetLibPin()->GetUnit() && ( p->GetLibPin()->GetUnit() != unit ) )
1104 continue;
1105
1106 pins.push_back( p.get() );
1107 }
1108
1109 return pins;
1110}
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
Definition: sch_symbol.cpp:725

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

Referenced by NETLIST_EXPORTER_BASE::CreatePinList(), AUTOPLACER::fieldBoxPlacement(), NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol(), findSymbolsAndPins(), SCH_SCREEN::GetLabelOrientationForPoint(), highlightNet(), 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 277 of file sch_symbol.h.

277{ return m_prefix; }

References m_prefix.

Referenced by SCH_SCREEN::AllSymbolDefaultInstancesNotSet(), and 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 632 of file sch_symbol.cpp.

633{
634 KIID_PATH path = sheet->Path();
635 wxString ref;
636 wxString subRef;
637
638 for( const SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
639 {
640 if( instance.m_Path == path )
641 {
642 ref = instance.m_Reference;
643 subRef = LIB_SYMBOL::SubReference( instance.m_Unit );
644 break;
645 }
646 }
647
648 // If it was not found in m_Paths array, then see if it is in m_Field[REFERENCE] -- if so,
649 // use this as a default for this path. This will happen if we load a version 1 schematic
650 // file. It will also mean that multiple instances of the same sheet by default all have
651 // the same symbol references, but perhaps this is best.
652 if( ref.IsEmpty() && !GetField( REFERENCE_FIELD )->GetText().IsEmpty() )
653 {
654 const_cast<SCH_SYMBOL*>( this )->SetRef( sheet, GetField( REFERENCE_FIELD )->GetText() );
655 ref = GetField( REFERENCE_FIELD )->GetText();
656 }
657
658 if( ref.IsEmpty() )
660
661 if( aIncludeUnit && GetUnitCount() > 1 )
662 ref += subRef;
663
664 return ref;
665}
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Definition: lib_symbol.cpp:588
int GetUnitCount() const
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:429

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(), SCH_EDIT_FRAME::AnnotateSymbols(), SCH_SHEET_PATH::AppendMultiUnitSymbol(), SCH_SHEET_PATH::AppendSymbol(), TEST_SCH_REFERENCE_LIST_FIXTURE::checkAnnotation(), SCHEMATIC::ConvertKIIDsToRefs(), SCHEMATIC::ConvertRefsToKIIDs(), 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(), SCH_SHEET_LIST::MigrateSimModelNameFields(), netList(), SCH_EDITOR_CONTROL::Paste(), NETLIST_EXPORTER_SPICE::readRefName(), NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries(), SCH_REFERENCE_LIST::ReannotateByOptions(), SCH_FIELD::Replace(), SCHEMATIC::ResolveCrossReference(), ResolveTextVar(), SCH_REFERENCE::SCH_REFERENCE(), ERC_TESTER::TestMultiunitFootprints(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), SCH_SHEET_PATH::UpdateAllScreenReferences(), DIALOG_SCH_FIELD_PROPERTIES::UpdateField(), NETLIST_EXPORTER_CADSTAR::WriteNetlist(), and NETLIST_EXPORTER_ORCADPCB2::WriteNetlist().

◆ GetSchSymbolLibraryName()

wxString SCH_SYMBOL::GetSchSymbolLibraryName ( ) const

◆ GetSelectMenuText()

wxString SCH_SYMBOL::GetSelectMenuText ( UNITS_PROVIDER aUnitsProvider) const
overridevirtual

Return the text to display to be used in the selection clarification context menu when multiple items are found at the current cursor position.

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 1899 of file sch_symbol.cpp.

1900{
1901 return wxString::Format( _( "Symbol %s [%s]" ),
1902 GetField( REFERENCE_FIELD )->GetShownText(),
1903 UnescapeString( GetLibId().GetLibItemName() ) );
1904}

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

◆ 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 126 of file eda_item.h.

127 {
128 return m_status & type;
129 }
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 139 of file eda_item.h.

139{ 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 282 of file sch_symbol.h.

282{ return m_transform; }

References m_transform.

◆ GetTypeDesc()

wxString EDA_ITEM::GetTypeDesc ( )
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:512

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

Referenced by PROPERTIES_PANEL::update().

◆ 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 429 of file sch_symbol.cpp.

430{
431 if( m_part )
432 return m_part->GetUnitCount();
433
434 return 0;
435}

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 438 of file sch_symbol.cpp.

439{
440 wxCHECK( m_part, ( wxString::Format( _( "Unit %s" ), LIB_SYMBOL::SubReference( aUnit ) ) ) );
441
442 return m_part->GetUnitDisplayName( aUnit );
443}

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 725 of file sch_symbol.cpp.

726{
727 KIID_PATH path = aSheet->Path();
728
729 for( const SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
730 {
731 if( instance.m_Path == path )
732 return instance.m_Unit;
733 }
734
735 // If it was not found in m_Paths array, then use m_unit. This will happen if we load a
736 // version 1 schematic file.
737 return m_unit;
738}

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

Referenced by 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().

◆ GetValue()

const wxString SCH_SYMBOL::GetValue ( const SCH_SHEET_PATH sheet,
bool  aResolve 
) const

Return the instance-specific value for the given sheet path.

Definition at line 767 of file sch_symbol.cpp.

768{
769 KIID_PATH path = sheet->Path();
770
771 for( const SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
772 {
773 if( instance.m_Path == path && !instance.m_Value.IsEmpty() )
774 {
775 // This can only be overridden by a new value but if we are resolving,
776 // make sure that the symbol returns the fully resolved text
777 if( aResolve )
778 {
779 SCH_SYMBOL new_sym( *this );
780 new_sym.GetField( VALUE_FIELD )->SetText( instance.m_Value );
781 return new_sym.GetField( VALUE_FIELD )->GetShownText();
782 }
783
784 return instance.m_Value;
785 }
786 }
787
788 if( !aResolve )
789 return GetField( VALUE_FIELD )->GetText();
790
791 return GetField( VALUE_FIELD )->GetShownText();
792}

References GetField(), SCH_FIELD::GetShownText(), EDA_TEXT::GetText(), m_instanceReferences, SCH_SHEET_PATH::Path(), path, EDA_TEXT::SetText(), and VALUE_FIELD.

Referenced by NETLIST_EXPORTER_XML::addSymbolFields(), SCH_EDIT_FRAME::AnnotateSymbols(), DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS(), SCH_PIN::GetMsgPanelInfo(), GetMsgPanelInfo(), DIALOG_CHANGE_SYMBOLS::isMatch(), SCH_SHEET_LIST::MigrateSimModelNameFields(), netList(), SCH_FIELD::Replace(), ResolveTextVar(), SCH_REFERENCE::SCH_REFERENCE(), SCH_SYMBOL(), SCH_SHEET_PATH::UpdateAllScreenReferences(), NETLIST_EXPORTER_CADSTAR::WriteNetlist(), and NETLIST_EXPORTER_ORCADPCB2::WriteNetlist().

◆ HasBrightenedPins()

bool SCH_SYMBOL::HasBrightenedPins ( )

Definition at line 2220 of file sch_symbol.cpp.

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

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 446 of file sch_symbol.cpp.

447{
448 wxCHECK( m_part, false );
449
450 return m_part->HasUnitDisplayName( aUnit );
451}

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 2072 of file sch_symbol.cpp.

2073{
2075 return false;
2076
2077 BOX2I rect = aRect;
2078
2079 rect.Inflate( aAccuracy / 2 );
2080
2081 if( aContained )
2082 return rect.Contains( GetBodyBoundingBox() );
2083
2084 return rect.Intersects( GetBodyBoundingBox() );
2085}
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 2060 of file sch_symbol.cpp.

2061{
2062 BOX2I bBox = GetBodyBoundingBox();
2063 bBox.Inflate( aAccuracy / 2 );
2064
2065 if( bBox.Contains( aPosition ) )
2066 return true;
2067
2068 return false;
2069}

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

◆ Init()

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

Definition at line 206 of file sch_symbol.cpp.

207{
209 m_pos = pos;
210 m_unit = 1; // In multi unit chip - which unit to draw.
211 m_convert = LIB_ITEM::LIB_CONVERT::BASE; // De Morgan Handling
212
213 // The rotation/mirror transformation matrix. pos normal
215
216 // construct only the mandatory fields, which are the first 4 only.
217 for( int i = 0; i < MANDATORY_FIELDS; ++i )
218 {
219 m_fields.emplace_back( pos, i, this, TEMPLATE_FIELDNAME::GetDefaultFieldName( i ) );
220
221 if( i == REFERENCE_FIELD )
222 m_fields.back().SetLayer( LAYER_REFERENCEPART );
223 else if( i == VALUE_FIELD )
224 m_fields.back().SetLayer( LAYER_VALUEPART );
225 else
226 m_fields.back().SetLayer( LAYER_FIELDS );
227 }
228
229 m_prefix = wxString( wxT( "U" ) );
230 m_isInNetlist = true;
231 m_inBom = true;
232 m_onBoard = true;
233}
@ 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 711 of file sch_symbol.cpp.

712{
713 KIID_PATH path = aSheet->Path();
714
715 for( const SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
716 {
717 if( instance.m_Path == path )
718 return instance.m_Reference.Last() != '?';
719 }
720
721 return false;
722}

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

Referenced by SCH_EDIT_FRAME::mapExistingAnnotation(), 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 678 of file sch_symbol.h.

678{ 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().

◆ IsDragging()

bool EDA_ITEM::IsDragging ( ) const
inlineinherited

Definition at line 105 of file eda_item.h.

105{ return m_flags & IS_DRAGGING; }

References IS_DRAGGING, and EDA_ITEM::m_flags.

Referenced by DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES().

◆ IsEntered()

bool EDA_ITEM::IsEntered ( ) const
inlineinherited

Definition at line 108 of file eda_item.h.

108{ 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 203 of file eda_item.h.

203{ 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 2116 of file sch_symbol.cpp.

2117{
2118 return m_isInNetlist;
2119}

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 242 of file sch_symbol.cpp.

243{
244 if( !m_part )
245 return true;
246
247 return false;
248}

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 265 of file sch_symbol.cpp.

266{
267 // If a symbol's anchor is not grid-aligned to its pins then moving from the anchor is
268 // going to end up moving the symbol's pins off-grid.
269
270 // The minimal grid size allowed to place a pin is 25 mils
271 const int min_grid_size = schIUScale.MilsToIU( 25 );
272
273 for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
274 {
275 if( ( ( pin->GetPosition().x - m_pos.x ) % min_grid_size ) != 0 )
276 return false;
277
278 if( ( ( pin->GetPosition().y - m_pos.y ) % min_grid_size ) != 0 )
279 return false;
280 }
281
282 return true;
283}
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 2239 of file sch_symbol.cpp.

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

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 668 of file sch_symbol.cpp.

669{
670 return !UTIL::GetRefDesPrefix( aReferenceString ).IsEmpty();
671}

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 722 of file sch_symbol.h.

722{ return true; }

◆ IsResized()

bool EDA_ITEM::IsResized ( ) const
inlineinherited

Definition at line 109 of file eda_item.h.

109{ return m_flags & IS_RESIZING; }

References IS_RESIZING, and EDA_ITEM::m_flags.

◆ IsRollover()

bool EDA_ITEM::IsRollover ( ) const
inlineinherited

Definition at line 112 of file eda_item.h.

113 {
114 return ( m_flags & ( IS_ROLLOVER | IS_MOVING ) ) == IS_ROLLOVER;
115 }
#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 107 of file eda_item.h.

107{ 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(), 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(), PCB_SELECTION_TOOL::selectionContains(), PCB_SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), KIGFX::SCH_PAINTER::setDeviceColors(), PCB_BASE_EDIT_FRAME::unitsChangeRefresh(), GERBVIEW_SELECTION_TOOL::unselect(), 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 175 of file eda_item.h.

175{ 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:183
@ 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:169
@ SCH_ITEM_LOCATE_BUS_T
Definition: typeinfo.h:170
@ SCH_ITEM_LOCATE_GRAPHIC_LINE_T
Definition: typeinfo.h:171

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().

◆ IsWireImage()

bool EDA_ITEM::IsWireImage ( ) const
inlineinherited

Definition at line 106 of file eda_item.h.

106{ return m_flags & IS_WIRE_IMAGE; }

References IS_WIRE_IMAGE, and EDA_ITEM::m_flags.

◆ 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 1780 of file sch_symbol.cpp.

1781{
1782 // Symbols are searchable via the child field and pin item text.
1783 return false;
1784}

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 1725 of file sch_symbol.cpp.

1726{
1727 int dx = m_pos.x;
1728
1730 MIRROR( m_pos.x, aCenter );
1731 dx -= m_pos.x; // dx,0 is the move vector for this transform
1732
1733 for( SCH_FIELD& field : m_fields )
1734 {
1735 // Move the fields to the new position because the symbol itself has moved.
1736 VECTOR2I pos = field.GetTextPos();
1737 pos.x -= dx;
1738 field.SetTextPos( pos );
1739 }
1740}
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 1743 of file sch_symbol.cpp.

1744{
1745 int dy = m_pos.y;
1746
1748 MIRROR( m_pos.y, aCenter );
1749 dy -= m_pos.y; // 0,dy is the move vector for this transform
1750
1751 for( SCH_FIELD& field : m_fields )
1752 {
1753 // Move the fields to the new position because the symbol itself has moved.
1754 VECTOR2I pos = field.GetTextPos();
1755 pos.y -= dy;
1756 field.SetTextPos( pos );
1757 }
1758}

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 642 of file sch_symbol.h.

643 {
644 if( aMoveVector == VECTOR2I( 0, 0 ) )
645 return;
646
647 m_pos += aMoveVector;
648
649 for( SCH_FIELD& field : m_fields )
650 field.Move( aMoveVector );
651
652 SetModified();
653 }
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 2016 of file sch_symbol.cpp.

2017{
2018 return !( *this == aSymbol );
2019}

◆ 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 1979 of file sch_symbol.cpp.

1980{
1981 if( Type() != aItem.Type() )
1982 return Type() < aItem.Type();
1983
1984 auto symbol = static_cast<const SCH_SYMBOL*>( &aItem );
1985
1987
1988 if( rect.GetArea() != symbol->GetBodyAndPinsBoundingBox().GetArea() )
1989 return rect.GetArea() < symbol->GetBodyAndPinsBoundingBox().GetArea();
1990
1991 if( m_pos.x != symbol->m_pos.x )
1992 return m_pos.x < symbol->m_pos.x;
1993
1994 if( m_pos.y != symbol->m_pos.y )
1995 return m_pos.y < symbol->m_pos.y;
1996
1997 return m_Uuid < aItem.m_Uuid; // Ensure deterministic sort
1998}
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 2022 of file sch_symbol.cpp.

2023{
2024 wxCHECK_MSG( Type() == aItem.Type(), *this,
2025 wxT( "Cannot assign object type " ) + aItem.GetClass() + wxT( " to type " ) +
2026 GetClass() );
2027
2028 if( &aItem != this )
2029 {
2030 SCH_ITEM::operator=( aItem );
2031
2032 SCH_SYMBOL* c = (SCH_SYMBOL*) &aItem;
2033
2034 m_lib_id = c->m_lib_id;
2035
2036 LIB_SYMBOL* libSymbol = c->m_part ? new LIB_SYMBOL( *c->m_part.get() ) : nullptr;
2037
2038 m_part.reset( libSymbol );
2039 m_pos = c->m_pos;
2040 m_unit = c->m_unit;
2041 m_convert = c->m_convert;
2043
2046
2047 m_fields = c->m_fields; // std::vector's assignment operator
2048
2049 // Reparent fields after assignment to new symbol.
2050 for( SCH_FIELD& field : m_fields )
2051 field.SetParent( this );
2052
2053 UpdatePins();
2054 }
2055
2056 return *this;
2057}
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:119
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
Definition: sch_symbol.cpp:341

References SCH_ITEM::GetClass(), GetClass(), m_convert, m_defaultInstance, 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 2001 of file sch_symbol.cpp.

2002{
2003 if( GetFieldCount() != aSymbol.GetFieldCount() )
2004 return false;
2005
2006 for( int i = VALUE_FIELD; i < GetFieldCount(); i++ )
2007 {
2008 if( GetFields()[i].GetText().Cmp( aSymbol.GetFields()[i].GetText() ) != 0 )
2009 return false;
2010 }
2011
2012 return true;
2013}
std::vector< SCH_FIELD > & GetFields()
Return a vector of fields from the symbol.
Definition: sch_symbol.h:421
int GetFieldCount() const
Return the number of fields in this symbol.
Definition: sch_symbol.h:476
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:928

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 2122 of file sch_symbol.cpp.

2123{
2124 if( aBackground )
2125 return;
2126
2127 if( m_part )
2128 {
2129 LIB_PINS libPins;
2130 m_part->GetPins( libPins, GetUnit(), GetConvert() );
2131
2132 // Copy the source so we can re-orient and translate it.
2133 LIB_SYMBOL tempSymbol( *m_part );
2134 LIB_PINS tempPins;
2135 tempSymbol.GetPins( tempPins, GetUnit(), GetConvert() );
2136
2137 // Copy the pin info from the symbol to the temp pins
2138 for( unsigned i = 0; i < tempPins.size(); ++ i )
2139 {
2140 SCH_PIN* symbolPin = GetPin( libPins[ i ] );
2141 LIB_PIN* tempPin = tempPins[ i ];
2142
2143 tempPin->SetName( symbolPin->GetShownName() );
2144 tempPin->SetType( symbolPin->GetType() );
2145 tempPin->SetShape( symbolPin->GetShape() );
2146
2147 if( symbolPin->IsDangling() )
2148 tempPin->SetFlags( IS_DANGLING );
2149 }
2150
2151 TRANSFORM temp = GetTransform();
2152 aPlotter->StartBlock( nullptr );
2153
2154 for( bool local_background : { true, false } )
2155 {
2156 tempSymbol.Plot( aPlotter, GetUnit(), GetConvert(), local_background, m_pos, temp,
2157 GetDNP() );
2158
2159 for( SCH_FIELD field : m_fields )
2160 field.Plot( aPlotter, local_background );
2161 }
2162
2163 // Plot attributes to a hypertext menu
2164 std::vector<wxString> properties;
2165
2166 for( const SCH_FIELD& field : GetFields() )
2167 {
2168 properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
2169 field.GetName(),
2170 field.GetShownText() ) );
2171 }
2172
2173 properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
2174 _( "Description" ),
2175 m_part->GetDescription() ) );
2176
2177 properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
2178 _( "Keywords" ),
2179 m_part->GetKeyWords() ) );
2180
2181 aPlotter->HyperlinkMenu( GetBoundingBox(), properties );
2182
2183 aPlotter->EndBlock( nullptr );
2184
2185 if( !m_part->IsPower() )
2186 aPlotter->Bookmark( GetBoundingBox(), GetField( REFERENCE_FIELD )->GetShownText(), _("Symbols") );
2187 }
2188}
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:142
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
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
TRANSFORM & GetTransform()
Definition: sch_symbol.h:281
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
bool GetDNP() const
Definition: sch_symbol.h:757
#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_fields, m_part, m_pos, LIB_SYMBOL::Plot(), REFERENCE_FIELD, EDA_ITEM::SetFlags(), LIB_PIN::SetName(), LIB_PIN::SetShape(), LIB_PIN::SetType(), and PLOTTER::StartBlock().

◆ 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 2191 of file sch_symbol.cpp.

2192{
2193 if( m_part )
2194 {
2195 LIB_PINS libPins;
2196 m_part->GetPins( libPins, GetUnit(), GetConvert() );
2197
2198 // Copy the source to stay const
2199 LIB_SYMBOL tempSymbol( *m_part );
2200 LIB_PINS tempPins;
2201 tempSymbol.GetPins( tempPins, GetUnit(), GetConvert() );
2202
2203 TRANSFORM transform = GetTransform();
2204
2205 // Copy the pin info from the symbol to the temp pins
2206 for( unsigned i = 0; i < tempPins.size(); ++ i )
2207 {
2208 SCH_PIN* symbolPin = GetPin( libPins[ i ] );
2209 LIB_PIN* tempPin = tempPins[ i ];
2210
2211 tempPin->SetName( symbolPin->GetShownName() );
2212 tempPin->SetType( symbolPin->GetType() );
2213 tempPin->SetShape( symbolPin->GetShape() );
2214 tempPin->Plot( aPlotter, false, m_pos, transform, GetDNP() );
2215 }
2216 }
2217}
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:1128

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 466 of file sch_symbol.cpp.

467{
469 opts.transform = m_transform;
470 opts.draw_visible_fields = false;
471 opts.draw_hidden_fields = false;
472
473 if( m_part )
474 {
475 m_part->Print( aSettings, m_pos + aOffset, m_unit, m_convert, opts, GetDNP() );
476 }
477 else // Use dummy() part if the actual cannot be found.
478 {
479 dummy()->Print( aSettings, m_pos + aOffset, 0, 0, opts, GetDNP() );
480 }
481
482 for( SCH_FIELD& field : m_fields )
483 field.Print( aSettings, aOffset );
484}
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:656
bool draw_visible_fields
Definition: lib_symbol.h:65
TRANSFORM transform
Definition: lib_symbol.h:63

References LIB_SYMBOL_OPTIONS::draw_hidden_fields, LIB_SYMBOL_OPTIONS::draw_visible_fields, dummy(), GetDNP(), m_convert, m_fields, m_part, m_pos, m_transform, m_unit, LIB_SYMBOL::Print(), 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 454 of file sch_symbol.cpp.

455{
457 opts.transform = m_transform;
458 opts.draw_visible_fields = false;
459 opts.draw_hidden_fields = false;
460
461 if( m_part )
462 m_part->PrintBackground( aSettings, m_pos + aOffset, m_unit, m_convert, opts, GetDNP() );
463}

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.

◆ RemoveField()

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 947 of file sch_symbol.cpp.

948{
949 for( unsigned i = MANDATORY_FIELDS; i < m_fields.size(); ++i )
950 {
951 if( aFieldName == m_fields[i].GetName( false ) )
952 {
953 m_fields.erase( m_fields.begin() + i );
954 return;
955 }
956 }
957}

References m_fields, and MANDATORY_FIELDS.

Referenced by DIALOG_CHANGE_SYMBOLS::processSymbol().

◆ RemoveInstance()

void SCH_SYMBOL::RemoveInstance ( const SCH_SHEET_PATH aInstancePath)

Definition at line 503 of file sch_symbol.cpp.

504{
505 // Search for an existing path and remove it if found (should not occur)
506 for( unsigned ii = 0; ii < m_instanceReferences.size(); ii++ )
507 {
508 if( m_instanceReferences[ii].m_Path == aInstancePath.Path() )
509 {
510 wxLogTrace( traceSchSheetPaths, "Removing symbol instance:\n"
511 " sheet path %s\n"
512 " reference %s, unit %d from symbol %s.",
513 aInstancePath.Path().AsString(),
514 m_instanceReferences[ii].m_Reference,
515 m_instanceReferences[ii].m_Unit,
516 m_Uuid.AsString() );
517
518 m_instanceReferences.erase( m_instanceReferences.begin() + ii );
519 ii--;
520 }
521 }
522}

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_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_EDITOR_CONTROL::ReplaceAll(), and SCH_EDITOR_CONTROL::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 1353 of file sch_symbol.cpp.

1355{
1356 auto it = std::find_if( m_instanceReferences.begin(), m_instanceReferences.end(),
1357 [ aOldSheetPath ]( SYMBOL_INSTANCE_REFERENCE& r )->bool
1358 {
1359 return aOldSheetPath == r.m_Path;
1360 }
1361 );
1362
1363 if( it != m_instanceReferences.end() )
1364 {
1365 wxLogTrace( traceSchSheetPaths,
1366 "Replacing sheet path %s\n with sheet path %s\n for symbol %s.",
1367 aOldSheetPath.AsString(), aNewSheetPath.AsString(), m_Uuid.AsString() );
1368
1369 it->m_Path = aNewSheetPath;
1370 return true;
1371 }
1372
1373 wxLogTrace( traceSchSheetPaths,
1374 "Could not find sheet path %s\n to replace with sheet path %s\n for symbol %s.",
1375 aOldSheetPath.AsString(), aNewSheetPath.AsString(), m_Uuid.AsString() );
1376
1377 return false;
1378}
E_SERIE r
Definition: eserie.cpp:41

References KIID::AsString(), KIID_PATH::AsString(), m_instanceReferences, EDA_ITEM::m_Uuid, r, 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 1172 of file sch_symbol.cpp.

1173{
1174 SCHEMATIC* schematic = Schematic();
1175
1176 // SCH_SYMOL object has no context outside a schematic.
1177 if( !schematic )
1178 return false;
1179
1180 for( int i = 0; i < MANDATORY_FIELDS; ++i )
1181 {
1182 if( token->IsSameAs( m_fields[ i ].GetCanonicalName().Upper() ) )
1183 {
1184 if( i == REFERENCE_FIELD )
1185 *token = GetRef( &schematic->CurrentSheet(), true );
1186 else if( i == VALUE_FIELD )
1187 *token = GetValue( &schematic->CurrentSheet(), true );
1188 else if( i == FOOTPRINT_FIELD )
1189 *token = GetFootprint( &schematic->CurrentSheet(), true );
1190 else
1191 *token = m_fields[ i ].GetShownText( aDepth + 1 );
1192
1193 return true;
1194 }
1195 }
1196
1197 for( size_t i = MANDATORY_FIELDS; i < m_fields.size(); ++i )
1198 {
1199 if( token->IsSameAs( m_fields[ i ].GetName() )
1200 || token->IsSameAs( m_fields[ i ].GetName().Upper() ) )
1201 {
1202 *token = m_fields[ i ].GetShownText( aDepth + 1 );
1203 return true;
1204 }
1205 }
1206
1207 for( const TEMPLATE_FIELDNAME& templateFieldname :
1209 {
1210 if( token->IsSameAs( templateFieldname.m_Name )
1211 || token->IsSameAs( templateFieldname.m_Name.Upper() ) )
1212 {
1213 // If we didn't find it in the fields list then it isn't set on this symbol.
1214 // Just return an empty string.
1215 *token = wxEmptyString;
1216 return true;
1217 }
1218 }
1219
1220 if( token->IsSameAs( wxT( "FOOTPRINT_LIBRARY" ) ) )
1221 {
1222 wxString footprint;
1223
1224 footprint = GetFootprint( &schematic->CurrentSheet(), true );
1225
1226 wxArrayString parts = wxSplit( footprint, ':' );
1227
1228 *token = parts[ 0 ];
1229 return true;
1230 }
1231 else if( token->IsSameAs( wxT( "FOOTPRINT_NAME" ) ) )
1232 {
1233 wxString footprint;
1234
1235 footprint = GetFootprint( &schematic->CurrentSheet(), true );
1236
1237 wxArrayString parts = wxSplit( footprint, ':' );
1238
1239 *token = parts[ std::min( 1, (int) parts.size() - 1 ) ];
1240 return true;
1241 }
1242 else if( token->IsSameAs( wxT( "UNIT" ) ) )
1243 {
1244 int unit;
1245
1246 unit = GetUnitSelection( &schematic->CurrentSheet() );
1247
1248 *token = LIB_SYMBOL::SubReference( unit );
1249 return true;
1250 }
1251 else if( token->IsSameAs( wxT( "SYMBOL_LIBRARY" ) ) )
1252 {
1253 *token = m_lib_id.GetLibNickname();
1254 return true;
1255 }
1256 else if( token->IsSameAs( wxT( "SYMBOL_NAME" ) ) )
1257 {
1258 *token = m_lib_id.GetLibItemName();
1259 return true;
1260 }
1261 else if( token->IsSameAs( wxT( "SYMBOL_DESCRIPTION" ) ) )
1262 {
1263 *token = GetDescription();
1264 return true;
1265 }
1266 else if( token->IsSameAs( wxT( "SYMBOL_KEYWORDS" ) ) )
1267 {
1268 *token = GetKeyWords();
1269 return true;
1270 }
1271 else if( token->IsSameAs( wxT( "EXCLUDE_FROM_BOM" ) ) )
1272 {
1273 *token = this->GetIncludeInBom() ? wxT( "" ) : _( "Excluded from BOM" );
1274 return true;
1275 }
1276 else if( token->IsSameAs( wxT( "EXCLUDE_FROM_BOARD" ) ) )
1277 {
1278 *token = this->GetIncludeOnBoard() ? wxT( "" ) : _( "Excluded from board" );
1279 return true;
1280 }
1281 else if( token->IsSameAs( wxT( "DNP" ) ) )
1282 {
1283 *token = this->GetDNP() ? wxT( "" ) : _( "DNP" );
1284 return true;
1285 }
1286
1287 return false;
1288}
const UTF8 & GetLibItemName() const
Definition: lib_id.h:101
TEMPLATES m_TemplateFieldNames
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:172
bool GetIncludeOnBoard() const
Definition: sch_symbol.h:754
bool GetIncludeInBom() const
Definition: sch_symbol.h:751
wxString GetDescription() const
Definition: sch_symbol.cpp:314
wxString GetKeyWords() const
Definition: sch_symbol.cpp:323
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(), GetFootprint(), GetIncludeInBom(), GetIncludeOnBoard(), GetKeyWords(), LIB_ID::GetLibItemName(), LIB_ID::GetLibNickname(), GetRef(), TEMPLATES::GetTemplateFieldNames(), GetUnitSelection(), GetValue(), m_fields, m_lib_id, SCHEMATIC_SETTINGS::m_TemplateFieldNames, MANDATORY_FIELDS, REFERENCE_FIELD, SCH_ITEM::Schematic(), SCHEMATIC::Settings(), LIB_SYMBOL::SubReference(), and VALUE_FIELD.

Referenced by SCH_FIELD::GetShownText(), 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 1761 of file sch_symbol.cpp.

1762{
1763 VECTOR2I prev = m_pos;
1764
1765 RotatePoint( m_pos, aCenter, ANGLE_90 );
1766
1768
1769 for( SCH_FIELD& field : m_fields )
1770 {
1771 // Move the fields to the new position because the symbol itself has moved.
1772 VECTOR2I pos = field.GetTextPos();
1773 pos.x -= prev.x - m_pos.x;
1774 pos.y -= prev.y - m_pos.y;
1775 field.SetTextPos( pos );
1776 }
1777}
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:414
@ 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 1043 of file sch_symbol.cpp.

1044{
1045 for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
1046 aFunction( pin.get() );
1047
1048 for( SCH_FIELD& field : m_fields )
1049 aFunction( &field );
1050}

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:187

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

Referenced by 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_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_LABEL_BASE::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(), SetFootprint(), SetRef(), SetValue(), DIALOG_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_LABEL_PROPERTIES::TransferDataToWindow(), 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:263

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 406 of file sch_symbol.cpp.

407{
408 if( m_convert != aConvert )
409 {
410 m_convert = aConvert;
411
412 // The convert may have a different pin layout so the update the pin map.
413 UpdatePins();
414 SetModified();
415 }
416}

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

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

◆ SetDefaultInstance()

void SCH_SYMBOL::SetDefaultInstance ( const SYMBOL_INSTANCE_REFERENCE aInstance)
inline

◆ SetDNP()

void SCH_SYMBOL::SetDNP ( bool  aDNP)
inline

Definition at line 758 of file sch_symbol.h.

758{ m_DNP = aDNP; }

References m_DNP.

Referenced by DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow().

◆ SetFields()

void SCH_SYMBOL::SetFields ( const SCH_FIELDS aFields)
inline

Set multiple schematic fields.

Parameters
aFieldsare the fields to set in this symbol.

Definition at line 455 of file sch_symbol.h.

456 {
457 m_fields = aFields; // vector copying, length is changed possibly
458 }

References m_fields.

◆ SetFieldsAutoplaced()

void SCH_ITEM::SetFieldsAutoplaced ( )
inlineinherited

◆ SetFlags()

void EDA_ITEM::SetFlags ( EDA_ITEM_FLAGS  aMask)
inlineinherited

Definition at line 142 of file eda_item.h.

142{ 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(), 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(), EDIT_TOOL::doMoveSelection(), 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(), 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::ParseHarnessConnector(), 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(), SCH_EDIT_FRAME::SelectUnit(), EDA_ITEM::SetBrightened(), EDA_ITEM::SetIsShownAsBitmap(), EDA_ITEM::SetModified(), EDA_ITEM::SetSelected(), EDA_ITEM::SetWireImage(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_LINE_WIRE_BUS_TOOL::startSegments(), DS_DATA_ITEM::SyncDrawItems(), DS_DATA_ITEM_BITMAP::SyncDrawItems(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_DIMENSION_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXTBOX_PROPERTIES::TransferDataFromWindow(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace().

◆ SetFootprint() [1/2]

void SCH_SYMBOL::SetFootprint ( const SCH_SHEET_PATH sheet,
const wxString &  aFootprint 
)

Definition at line 854 of file sch_symbol.cpp.

855{
856 if( sheet == nullptr )
857 {
858 // Set all instances to new footprint value
860 instance.m_Footprint = aFootprint;
861
862 m_fields[ FOOTPRINT_FIELD ].SetText( aFootprint );
863 return;
864 }
865
866 KIID_PATH path = sheet->Path();
867 bool found = false;
868
869 // check to see if it is already there before inserting it
871 {
872 if( instance.m_Path == path )
873 {
874 found = true;
875 instance.m_Footprint = aFootprint;
876 break;
877 }
878 }
879
880 // didn't find it; better add it
881 if( !found )
882 {
884 wxEmptyString, aFootprint );
885 }
886
887 if( Schematic() && *sheet == Schematic()->CurrentSheet() )
888 m_fields[ FOOTPRINT_FIELD ].SetText( aFootprint );
889}

References AddHierarchicalReference(), FOOTPRINT_FIELD, UTIL::GetRefDesUnannotated(), m_fields, m_instanceReferences, m_prefix, m_unit, SCH_SHEET_PATH::Path(), path, and SCH_ITEM::Schematic().

Referenced by BACK_ANNOTATE::applyChangelist(), FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData(), SCH_EDITOR_CONTROL::AssignFootprints(), SCH_ALTIUM_PLUGIN::ParseImplementation(), SCH_EDITOR_CONTROL::processCmpToFootprintLinkFile(), DIALOG_CHANGE_SYMBOLS::processSymbol(), SCH_EDIT_FRAME::PutDataInPreviousState(), SCH_FIELD::Replace(), SCH_SYMBOL(), SetFootprint(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_SCH_FIELD_PROPERTIES::UpdateField(), UpdateFields(), and SCH_EDITOR_CONTROL::updatePastedSymbol().

◆ SetFootprint() [2/2]

void SCH_SYMBOL::SetFootprint ( const wxString &  aFootprint)
inline

Set the value for all instances (the default GUI behavior).

Definition at line 635 of file sch_symbol.h.

636 {
637 SetFootprint( nullptr, aFootprint );
638 }

References SetFootprint().

◆ 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 201 of file eda_item.h.

201{ m_forceVisible = aEnable; }

References EDA_ITEM::m_forceVisible.

Referenced by SCH_EDITOR_CONTROL::UpdateFind().

◆ SetIncludeInBom()

void SCH_SYMBOL::SetIncludeInBom ( bool  aIncludeInBom)
inline

Definition at line 752 of file sch_symbol.h.

752{ m_inBom = aIncludeInBom; }

References m_inBom.

Referenced by DIALOG_CHANGE_SYMBOLS::processSymbol(), and DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow().

◆ SetIncludeOnBoard()

void SCH_SYMBOL::SetIncludeOnBoard ( bool  aIncludeOnBoard)
inline

Definition at line 755 of file sch_symbol.h.

755{ m_onBoard = aIncludeOnBoard; }

References m_onBoard.

Referenced by DIALOG_CHANGE_SYMBOLS::processSymbol(), and DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow().

◆ SetInstanceToDefault()

void SCH_SYMBOL::SetInstanceToDefault ( const SCH_SHEET_PATH aInstance)

Definition at line 2260 of file sch_symbol.cpp.

2261{
2262 KIID_PATH path = aInstance.Path();
2263
2265 {
2266 if( instance.m_Path == path )
2267 {
2268 instance.m_Reference = m_defaultInstance.m_Reference;
2269 instance.m_Unit = m_defaultInstance.m_Unit;
2270 instance.m_Value = m_defaultInstance.m_Value;
2271 instance.m_Footprint = m_defaultInstance.m_Footprint;
2272 return;
2273 }
2274 }
2275
2276 // It's a new instance so add it.
2279}

References AddHierarchicalReference(), m_defaultInstance, SYMBOL_INSTANCE_REFERENCE::m_Footprint, m_instanceReferences, SYMBOL_INSTANCE_REFERENCE::m_Reference, SYMBOL_INSTANCE_REFERENCE::m_Unit, SYMBOL_INSTANCE_REFERENCE::m_Value, SCH_SHEET_PATH::Path(), and path.

Referenced by SCH_SHEET_PATH::SetSymbolInstancesToDefault().

◆ SetIsShownAsBitmap()

void EDA_ITEM::SetIsShownAsBitmap ( bool  aBitmap)
inlineinherited

Definition at line 167 of file eda_item.h.

168 {
169 if( aBitmap )
171 else
173 }

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()

void SCH_ITEM::SetLayer ( SCH_LAYER_ID  aLayer)
inlineinherited

◆ 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 305 of file sch_symbol.cpp.

306{
307 wxCHECK2( ( aLibSymbol == nullptr ) || ( aLibSymbol->IsRoot() ), aLibSymbol = nullptr );
308
309 m_part.reset( aLibSymbol );
310 UpdatePins();
311}
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
Definition: lib_symbol.h:182

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

Referenced by SCH_SCREEN::Append(), SCH_ALTIUM_PLUGIN::ParsePowerPort(), SCH_EDITOR_CONTROL::Paste(), DIALOG_CHANGE_SYMBOLS::processSymbol(), SCH_EDIT_FRAME::SaveSymbolToSchematic(), 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 1381 of file sch_symbol.cpp.

1382{
1383 TRANSFORM temp = TRANSFORM();
1384 bool transform = false;
1385
1386 switch( aOrientation )
1387 {
1388 case SYM_ORIENT_0:
1389 case SYM_NORMAL: // default transform matrix
1390 m_transform.x1 = 1;
1391 m_transform.y2 = -1;
1393 break;
1394
1395 case SYM_ROTATE_COUNTERCLOCKWISE: // Rotate + (incremental rotation)
1396 temp.x1 = temp.y2 = 0;
1397 temp.y1 = 1;
1398 temp.x2 = -1;
1399 transform = true;
1400 break;
1401
1402 case SYM_ROTATE_CLOCKWISE: // Rotate - (incremental rotation)
1403 temp.x1 = temp.y2 = 0;
1404 temp.y1 = -1;
1405 temp.x2 = 1;
1406 transform = true;
1407 break;
1408
1409 case SYM_MIRROR_Y: // Mirror Y (incremental rotation)
1410 temp.x1 = -1;
1411 temp.y2 = 1;
1412 temp.y1 = temp.x2 = 0;
1413 transform = true;
1414 break;
1415
1416 case SYM_MIRROR_X: // Mirror X (incremental rotation)
1417 temp.x1 = 1;
1418 temp.y2 = -1;
1419 temp.y1 = temp.x2 = 0;
1420 transform = true;
1421 break;
1422
1423 case SYM_ORIENT_90:
1426 break;
1427
1428 case SYM_ORIENT_180:
1432 break;
1433
1434 case SYM_ORIENT_270:
1437 break;
1438
1439 case ( SYM_ORIENT_0 + SYM_MIRROR_X ):
1442 break;
1443
1444 case ( SYM_ORIENT_0 + SYM_MIRROR_Y ):
1447 break;
1448
1449 case ( SYM_ORIENT_90 + SYM_MIRROR_X ):
1452 break;
1453
1454 case ( SYM_ORIENT_90 + SYM_MIRROR_Y ):
1457 break;
1458
1459 case ( SYM_ORIENT_180 + SYM_MIRROR_X ):
1462 break;
1463
1464 case ( SYM_ORIENT_180 + SYM_MIRROR_Y ):
1467 break;
1468
1469 case ( SYM_ORIENT_270 + SYM_MIRROR_X ):
1472 break;
1473
1474 case ( SYM_ORIENT_270 + SYM_MIRROR_Y ):
1477 break;
1478
1479 default:
1480 transform = false;
1481 wxFAIL_MSG( "Invalid schematic symbol orientation type." );
1482 break;
1483 }
1484
1485 if( transform )
1486 {
1487 /* The new matrix transform is the old matrix transform modified by the
1488 * requested transformation, which is the temp transform (rot,
1489 * mirror ..) in order to have (in term of matrix transform):
1490 * transform coord = new_m_transform * coord
1491 * where transform coord is the coord modified by new_m_transform from
1492 * the initial value coord.
1493 * new_m_transform is computed (from old_m_transform and temp) to
1494 * have:
1495 * transform coord = old_m_transform * temp
1496 */
1497 TRANSFORM newTransform;
1498
1499 newTransform.x1 = m_transform.x1 * temp.x1 + m_transform.x2 * temp.y1;
1500 newTransform.y1 = m_transform.y1 * temp.x1 + m_transform.y2 * temp.y1;
1501 newTransform.x2 = m_transform.x1 * temp.x2 + m_transform.x2 * temp.y2;
1502 newTransform.y2 = m_transform.y1 * temp.x2 + m_transform.y2 * temp.y2;
1503 m_transform = newTransform;
1504 }
1505}
@ 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(), 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(), DIALOG_LIB_EDIT_PIN_TABLE::OnAddRow(), 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(), SCH_SHEET_PIN::SCH_SHEET_PIN(), LIB_SYMBOL::SetFields(), PCB_DIMENSION_BASE::SetParent(), PIN_TABLE_DATA_MODEL::SetValue(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_LINE_WIRE_BUS_TOOL::startSegments(), SCH_LABEL_BASE::SwapData(), SCH_SHEET::SwapData(), SwapData(), 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 725 of file sch_symbol.h.

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

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 279 of file sch_symbol.h.

279{ m_prefix = aPrefix; }

References m_prefix.

◆ 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 674 of file sch_symbol.cpp.

675{
676 KIID_PATH path = sheet->Path();
677 bool found = false;
678
679 // check to see if it is already there before inserting it
681 {
682 if( instance.m_Path == path )
683 {
684 found = true;
685 instance.m_Reference = ref;
686 break;
687 }
688 }
689
690 if( !found )
693
694 for( std::unique_ptr<SCH_PIN>& pin : m_pins )
695 pin->ClearDefaultNetName( sheet );
696
697 if( Schematic() && *sheet == Schematic()->CurrentSheet() )
698 m_fields[ REFERENCE_FIELD ].SetText( ref );
699
700 // Reinit the m_prefix member if needed
702
703 if( m_prefix.IsEmpty() )
704 m_prefix = wxT( "U" );
705
706 // Power symbols have references starting with # and are not included in netlists
707 m_isInNetlist = ! ref.StartsWith( wxT( "#" ) );
708}

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

Referenced by SCH_REFERENCE::Annotate(), BACK_ANNOTATE::applyChangelist(), GetRef(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol(), SCH_ALTIUM_PLUGIN::ParseDesignator(), SCH_ALTIUM_PLUGIN::ParsePowerPort(), DIALOG_CHANGE_SYMBOLS::processSymbol(), 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 191 of file sch_symbol.h.

191{ m_schLibSymbolName = aName; }

References m_schLibSymbolName.

Referenced by SCH_SCREEN::Append(), and DIALOG_CHANGE_SYMBOLS::processSymbol().

◆ SetSelected()

◆ SetState()

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

Definition at line 131 of file eda_item.h.

132 {
133 if( state )
134 m_status |= type; // state = ON or OFF
135 else
136 m_status &= ~type;
137 }

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 140 of file eda_item.h.

140{ 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 419 of file sch_symbol.cpp.

420{
421 if( m_transform != aTransform )
422 {
423 m_transform = aTransform;
424 SetModified();
425 }
426}

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 390 of file sch_symbol.cpp.

391{
392 if( m_unit != aUnit )
393 {
394 UpdateUnit( aUnit );
395