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 (const wxPoint &pos=wxPoint(0, 0), SCH_ITEM *aParent=nullptr)
 
 SCH_SYMBOL (const LIB_SYMBOL &aSymbol, const LIB_ID &aLibId, const SCH_SHEET_PATH *aSheet, int unit, int convert=0, const wxPoint &pos=wxPoint(0, 0))
 Create schematic symbol from library symbol object. More...
 
 SCH_SYMBOL (const LIB_SYMBOL &aSymbol, const SCH_SHEET_PATH *aSheet, const PICKED_SYMBOL &aSel, const wxPoint &pos=wxPoint(0, 0))
 
 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...
 
const std::vector< SYMBOL_INSTANCE_REFERENCE > & GetInstanceReferences ()
 
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
 Return information about the aliased parts. More...
 
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...
 
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 ()
 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)
 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 EDA_RECT GetBoundingBox () const override
 Return the orthogonal bounding box of this object for display purposes. More...
 
EDA_RECT GetBodyBoundingBox () const
 Return a bounding box for the symbol body but not the pins or fields. More...
 
EDA_RECT 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, SCH_EDIT_FRAME *aFrame) 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...
 
SCH_PINGetPin (LIB_PIN *aLibPin)
 
std::vector< SCH_PIN * > GetPins (const SCH_SHEET_PATH *aSheet=nullptr) const
 Retrieve a list of the SCH_PINs for the given sheet path. More...
 
std::vector< std::unique_ptr< SCH_PIN > > & GetRawPins ()
 
void Print (const RENDER_SETTINGS *aSettings, const wxPoint &aOffset) override
 Print a symbol. 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...
 
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 wxPoint &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 wxPoint &aCenter) override
 Rotate the item around aCenter 90 degrees in the clockwise direction. More...
 
bool Matches (const wxFindReplaceData &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...
 
wxPoint GetPinPhysicalPosition (const LIB_PIN *Pin) const
 
bool IsConnectable () const override
 
bool CanConnect (const SCH_ITEM *aItem) const override
 
bool IsInNetlist () const
 
std::vector< wxPoint > GetConnectionPoints () const override
 Add all the connection points for this item to aPoints. More...
 
SEARCH_RESULT Visit (INSPECTOR inspector, void *testData, const KICAD_T scanTypes[]) 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 wxPoint &aPosition, KICAD_T aType=TYPE_NOT_INIT)
 Return the symbol library item at aPosition that is part of this symbol. More...
 
wxString GetSelectMenuText (EDA_UNITS aUnits) 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...
 
wxPoint GetPosition () const override
 
void SetPosition (const wxPoint &aPosition) override
 
bool HitTest (const wxPoint &aPosition, int aAccuracy=0) const override
 Test if aPosition is inside or on the boundary of this item. More...
 
bool HitTest (const EDA_RECT &aRect, bool aContained, int aAccuracy=0) const override
 Test if aRect intersects this item. More...
 
void Plot (PLOTTER *aPlotter) const override
 Plot the schematic item to aPlotter. 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 IsPointClickableAnchor (const wxPoint &aPos) const override
 
SCH_ITEMDuplicate (bool doClone=false) const
 Routine to create a new copy of given item. More...
 
wxPoint & GetStoredPos ()
 
void SetStoredPos (const wxPoint &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 DoHypertextMenu (EDA_DRAW_FRAME *aFrame)
 
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
 
virtual bool IsDangling () const
 
void ClearConnections ()
 Clears all of the connection items from the list. More...
 
bool IsConnected (const wxPoint &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)
 
NETCLASSPTR NetClass (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 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
 
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 ()
 
virtual bool IsType (const KICAD_T aScanTypes[]) const
 Check whether the item is one of the listed types. More...
 
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 wxPoint GetFocusPosition () const
 Similar to GetPosition, but allows items to return their visual center rather than their anchor. More...
 
virtual bool Replace (const wxFindReplaceData &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)
 
template<typename T >
Get (PROPERTY_BASE *aProperty)
 
template<typename T >
boost::optional< T > Get (const wxString &aProperty)
 

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 SEARCH_RESULT IterateForward (std::deque< T > &aList, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
 This changes first parameter to avoid the DList and use the main queue instead. More...
 
template<class T >
static SEARCH_RESULT IterateForward (std::vector< T > &aList, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
 Change first parameter to avoid the DList and use std::vector instead. More...
 
static bool Replace (const wxFindReplaceData &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 wxFindReplaceData &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
 
wxPoint m_storedPos
 
std::unordered_map< SCH_SHEET_PATH, SCH_ITEM_SETm_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

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

Private Attributes

wxPoint 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...
 
std::vector< SYMBOL_INSTANCE_REFERENCEm_instanceReferences
 

Detailed Description

Schematic symbol object.

Definition at line 78 of file sch_symbol.h.

Constructor & Destructor Documentation

◆ SCH_SYMBOL() [1/4]

SCH_SYMBOL::SCH_SYMBOL ( const wxPoint &  pos = wxPoint( 0, 0 ),
SCH_ITEM aParent = nullptr 
)

Definition at line 98 of file sch_symbol.cpp.

98  :
99  SCH_ITEM( aParent, SCH_SYMBOL_T )
100 {
101  Init( aPos );
102 }
void Init(const wxPoint &pos=wxPoint(0, 0))
Definition: sch_symbol.cpp:194
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType)
Definition: sch_item.cpp:44

References Init().

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  unit,
int  convert = 0,
const wxPoint &  pos = wxPoint( 0, 0 ) 
)

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.
unitis unit for symbols that have multiple parts per package.
convertis the alternate body style for the schematic symbols.
posis the position of the symbol.
setNewItemFlagis used to set the symbol IS_NEW and IS_MOVING flags.

Definition at line 105 of file sch_symbol.cpp.

106  :
107  SCH_ITEM( nullptr, SCH_SYMBOL_T )
108 {
109  Init( pos );
110 
111  m_unit = unit;
112  m_convert = convert;
113  m_lib_id = aLibId;
114 
115  std::unique_ptr< LIB_SYMBOL > part;
116 
117  part = aSymbol.Flatten();
118  part->SetParent();
119  SetLibSymbol( part.release() );
120 
121  // Copy fields from the library symbol
122  UpdateFields( aSheet,
123  true, /* update style */
124  false, /* update ref */
125  false, /* update other fields */
126  true, /* reset ref */
127  true /* reset other fields */ );
128 
129  m_prefix = UTIL::GetRefDesPrefix( m_part->GetReferenceField().GetText() );
130 
131  if( aSheet )
132  {
134 
135  // Value and footprint name are stored in the SCH_SHEET_PATH path manager,
136  // if aSheet != nullptr, not in the symbol itself.
137  // Copy them to the currently displayed field texts
138  SetValue( GetValue( aSheet, false ) );
139  SetFootprint( GetFootprint( aSheet, false ) );
140  }
141 
142  // Inherit the include in bill of materials and board netlist settings from library symbol.
143  m_inBom = aSymbol.GetIncludeInBom();
144  m_onBoard = aSymbol.GetIncludeOnBoard();
145 }
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:787
wxString GetRefDesUnannotated(const wxString &aSource)
Return an unannotated refdes from either a prefix or an existing refdes.
wxString m_prefix
C, R, U, Q etc - the first character(s) which typically indicate what the symbol is.
Definition: sch_symbol.h:684
void SetValue(const SCH_SHEET_PATH *sheet, const wxString &aValue)
Definition: sch_symbol.cpp:624
bool GetIncludeOnBoard() const
Definition: lib_symbol.h:604
void SetFootprint(const SCH_SHEET_PATH *sheet, const wxString &aFootprint)
Definition: sch_symbol.cpp:675
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
Definition: sch_symbol.cpp:280
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:380
void Init(const wxPoint &pos=wxPoint(0, 0))
Definition: sch_symbol.cpp:194
int m_unit
The unit for multiple part per package symbols.
Definition: sch_symbol.h:680
int m_convert
The alternate body style for symbols that have more than one body style defined.
Definition: sch_symbol.h:681
std::unique_ptr< LIB_SYMBOL > m_part
a flattened copy of the LIB_SYMBOL from the PROJECT's libraries.
Definition: sch_symbol.h:701
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:596
bool m_onBoard
True to include in netlist when updating board.
Definition: sch_symbol.h:708
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
Definition: sch_symbol.h:679
bool m_inBom
True to include in bill of materials export.
Definition: sch_symbol.h:707
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:504
wxString GetRefDesPrefix(const wxString &aRefDes)
Get the (non-numeric) prefix from a refdes - e.g.
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:654
bool GetIncludeInBom() const
Definition: lib_symbol.h:596
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType)
Definition: sch_item.cpp:44

References convert, LIB_SYMBOL::Flatten(), GetFootprint(), LIB_SYMBOL::GetIncludeInBom(), LIB_SYMBOL::GetIncludeOnBoard(), UTIL::GetRefDesPrefix(), UTIL::GetRefDesUnannotated(), GetValue(), Init(), m_convert, m_inBom, m_lib_id, m_onBoard, m_part, m_prefix, 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 wxPoint &  pos = wxPoint( 0, 0 ) 
)

Definition at line 148 of file sch_symbol.cpp.

149  :
150  SCH_SYMBOL( aSymbol, aSel.LibId, aSheet, aSel.Unit, aSel.Convert, pos )
151 {
152  // Set any fields that were modified as part of the symbol selection
153  for( const std::pair<int, wxString>& i : aSel.Fields )
154  {
155  SCH_FIELD* field = GetFieldById( i.first );
156 
157  if( field )
158  field->SetText( i.second );
159  }
160 }
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
SCH_SYMBOL(const wxPoint &pos=wxPoint(0, 0), SCH_ITEM *aParent=nullptr)
Definition: sch_symbol.cpp:98
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:124
LIB_ID LibId
Definition: sch_screen.h:82
SCH_FIELD * GetFieldById(int aFieldId)
Return a field in this symbol.
Definition: sch_symbol.cpp:717
std::vector< std::pair< int, wxString > > Fields
Definition: sch_screen.h:86

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

163  :
164  SCH_ITEM( aSymbol )
165 {
166  m_parent = aSymbol.m_parent;
167  m_pos = aSymbol.m_pos;
168  m_unit = aSymbol.m_unit;
169  m_convert = aSymbol.m_convert;
170  m_lib_id = aSymbol.m_lib_id;
171  m_isInNetlist = aSymbol.m_isInNetlist;
172  m_inBom = aSymbol.m_inBom;
173  m_onBoard = aSymbol.m_onBoard;
174 
175  if( aSymbol.m_part )
176  SetLibSymbol( new LIB_SYMBOL( *aSymbol.m_part.get() ) );
177 
178  const_cast<KIID&>( m_Uuid ) = aSymbol.m_Uuid;
179 
180  m_transform = aSymbol.m_transform;
181  m_prefix = aSymbol.m_prefix;
183  m_fields = aSymbol.m_fields;
184 
185  // Re-parent the fields, which before this had aSymbol as parent
186  for( SCH_FIELD& field : m_fields )
187  field.SetParent( this );
188 
191 }
bool m_isInNetlist
True if the symbol should appear in the netlist.
Definition: sch_symbol.h:706
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:478
wxString m_prefix
C, R, U, Q etc - the first character(s) which typically indicate what the symbol is.
Definition: sch_symbol.h:684
Define a library symbol object.
Definition: lib_symbol.h:96
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
Definition: sch_symbol.cpp:280
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:489
int m_unit
The unit for multiple part per package symbols.
Definition: sch_symbol.h:680
int m_convert
The alternate body style for symbols that have more than one body style defined.
Definition: sch_symbol.h:681
wxString m_schLibSymbolName
The name used to look up a symbol in the symbol library embedded in a schematic.
Definition: sch_symbol.h:696
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699
wxPoint m_pos
Definition: sch_symbol.h:678
std::unique_ptr< LIB_SYMBOL > m_part
a flattened copy of the LIB_SYMBOL from the PROJECT's libraries.
Definition: sch_symbol.h:701
bool m_onBoard
True to include in netlist when updating board.
Definition: sch_symbol.h:708
const KIID m_Uuid
Definition: eda_item.h:474
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
Definition: sch_symbol.h:679
bool m_inBom
True to include in bill of materials export.
Definition: sch_symbol.h:707
TRANSFORM m_transform
The rotation/mirror transformation.
Definition: sch_symbol.h:698
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
Definition: sch_symbol.h:712
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType)
Definition: sch_item.cpp:44

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

111 { }

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 183 of file sch_item.cpp.

184 {
185  SCH_ITEM_SET& set = m_connected_items[ aSheet ];
186 
187  // The vector elements are small, so reserve 1k at a time to prevent re-allocations
188  if( set.size() == set.capacity() )
189  set.reserve( set.size() + 4096 );
190 
191  set.emplace_back( aItem );
192 }
std::vector< SCH_ITEM * > SCH_ITEM_SET
Definition: sch_item.h:134
std::unordered_map< SCH_SHEET_PATH, SCH_ITEM_SET > m_connected_items
Store pointers to other items that are connected to this one, per sheet.
Definition: sch_item.h:494

References SCH_ITEM::m_connected_items.

Referenced by SCH_TEXT::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 751 of file sch_symbol.cpp.

752 {
753  int newNdx = m_fields.size();
754 
755  m_fields.push_back( aField );
756  return &m_fields[newNdx];
757 }
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699

References m_fields.

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

◆ AddHierarchicalReference()

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

426 {
427  // Search for an existing path and remove it if found (should not occur)
428  for( unsigned ii = 0; ii < m_instanceReferences.size(); ii++ )
429  {
430  if( m_instanceReferences[ii].m_Path == aPath )
431  {
432  wxLogTrace( traceSchSheetPaths, wxT( "Removing symbol instance:\n" )
433  wxT( " sheet path %s\n" )
434  wxT( " reference %s, unit %d from symbol %s." ),
435  aPath.AsString(),
436  m_instanceReferences[ii].m_Reference,
437  m_instanceReferences[ii].m_Unit,
438  m_Uuid.AsString() );
439 
440  m_instanceReferences.erase( m_instanceReferences.begin() + ii );
441  ii--;
442  }
443  }
444 
445  SYMBOL_INSTANCE_REFERENCE instance;
446  instance.m_Path = aPath;
447  instance.m_Reference = aRef;
448  instance.m_Unit = aUnit;
449  instance.m_Value = aValue;
450  instance.m_Footprint = aFootprint;
451 
452  wxLogTrace( traceSchSheetPaths, wxT( "Adding symbol instance:\n" )
453  wxT( " sheet path %s\n" )
454  wxT( " reference %s, unit %d to symbol %s." ),
455  aPath.AsString(),
456  aRef,
457  aUnit,
458  m_Uuid.AsString() );
459 
460  m_instanceReferences.push_back( instance );
461 }
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
wxString AsString() const
Definition: kiid.cpp:236
A simple container for schematic symbol instance information.
const KIID m_Uuid
Definition: eda_item.h:474
wxString AsString() const
Definition: kiid.cpp:316
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
Definition: sch_symbol.h:712

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

Referenced by AddSheetPathReferenceEntryIfMissing(), SetFootprint(), SetRef(), SetUnitSelection(), SetValue(), and SCH_SHEET_LIST::UpdateSymbolInstances().

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

1088 {
1089  // a empty sheet path is illegal:
1090  wxCHECK( aSheetPath.size() > 0, false );
1091 
1092  wxString reference_path;
1093 
1094  for( const SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
1095  {
1096  // if aSheetPath is found, nothing to do:
1097  if( instance.m_Path == aSheetPath )
1098  return false;
1099  }
1100 
1101  // This entry does not exist: add it, with its last-used reference
1102  AddHierarchicalReference( aSheetPath, m_fields[REFERENCE_FIELD].GetText(), m_unit );
1103  return true;
1104 }
Field Reference of part, i.e. "IC21".
int m_unit
The unit for multiple part per package symbols.
Definition: sch_symbol.h:680
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699
A simple container for schematic symbol instance information.
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:423
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
Definition: sch_symbol.h:712

References AddHierarchicalReference(), 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

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

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

◆ 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 745 of file autoplace_fields.cpp.

746 {
747  if( aManual )
748  wxASSERT_MSG( aScreen, wxT( "A SCH_SCREEN pointer must be given for manual autoplacement" ) );
749 
750  AUTOPLACER autoplacer( this, aScreen );
751  autoplacer.DoAutoplace( aManual );
753 }
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:489

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

Referenced by SCH_DRAWING_TOOLS::PlaceSymbol().

◆ CanConnect()

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

Reimplemented from SCH_ITEM.

Definition at line 603 of file sch_symbol.h.

604  {
605  return ( aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_WIRE ) ||
606  ( aItem->Type() == SCH_NO_CONNECT_T ) ||
607  ( aItem->Type() == SCH_JUNCTION_T ) ||
608  ( aItem->Type() == SCH_SYMBOL_T ) ||
609  ( aItem->Type() == SCH_LABEL_T ) ||
610  ( aItem->Type() == SCH_HIER_LABEL_T ) ||
611  ( aItem->Type() == SCH_GLOBAL_LABEL_T );
612  }
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:259
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References SCH_ITEM::GetLayer(), LAYER_WIRE, 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 113 of file sch_symbol.h.

114  {
115  return aItem && SCH_SYMBOL_T == aItem->Type();
116  }
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References SCH_SYMBOL_T, and EDA_ITEM::Type().

◆ ClearAnnotation()

void SCH_SYMBOL::ClearAnnotation ( const SCH_SHEET_PATH aSheetPath)

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.

Definition at line 1055 of file sch_symbol.cpp.

1056 {
1057  // Build a reference with no annotation, i.e. a reference ending with a single '?'
1058  wxString defRef = UTIL::GetRefDesUnannotated( m_prefix );
1059 
1060  if( aSheetPath )
1061  {
1062  KIID_PATH path = aSheetPath->Path();
1063 
1065  {
1066  if( instance.m_Path == path )
1067  instance.m_Reference = defRef;
1068  }
1069  }
1070  else
1071  {
1073  instance.m_Reference = defRef;
1074  }
1075 
1076  for( std::unique_ptr<SCH_PIN>& pin : m_pins )
1077  pin->ClearDefaultNetName( aSheetPath );
1078 
1079  // These 2 changes do not work in complex hierarchy.
1080  // When a clear annotation is made, the calling function must call a
1081  // UpdateAllScreenReferences for the active sheet.
1082  // But this call cannot made here.
1083  m_fields[REFERENCE_FIELD].SetText( defRef ); //for drawing.
1084 }
Field Reference of part, i.e. "IC21".
wxString m_prefix
C, R, U, Q etc - the first character(s) which typically indicate what the symbol is.
Definition: sch_symbol.h:684
wxString GetRefDesUnannotated(const wxString &aSource)
Return an unannotated refdes from either a prefix or an existing refdes.
std::vector< std::unique_ptr< SCH_PIN > > m_pins
a SCH_PIN for every LIB_PIN (all units)
Definition: sch_symbol.h:703
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699
A simple container for schematic symbol instance information.
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
Definition: sch_symbol.h:712

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(), and SCH_EDITOR_CONTROL::updatePastedSymbol().

◆ ClearBrightened()

void EDA_ITEM::ClearBrightened ( )
inlineinherited

◆ ClearBrightenedPins()

void SCH_SYMBOL::ClearBrightenedPins ( )

Definition at line 1905 of file sch_symbol.cpp.

1906 {
1907  for( auto& pin : m_pins )
1908  pin->ClearBrightened();
1909 }
std::vector< std::unique_ptr< SCH_PIN > > m_pins
a SCH_PIN for every LIB_PIN (all units)
Definition: sch_symbol.h:703

References m_pins, and pin.

Referenced by SCH_EDITOR_CONTROL::UpdateNetHighlighting().

◆ 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:488

References SCH_ITEM::m_connections.

◆ ClearEditFlags()

◆ ClearFieldsAutoplaced()

void SCH_ITEM::ClearFieldsAutoplaced ( )
inlineinherited

◆ ClearFlags()

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

Definition at line 153 of file eda_item.h.

153 { m_flags &= ~aMask; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480

References EDA_ITEM::m_flags.

Referenced by FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), PNS_KICAD_IFACE::AddItem(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_MOVE_TOOL::AlignElements(), FOOTPRINT::BuildPolyCourtyards(), 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(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), SCH_ITEM::Duplicate(), PCB_EDIT_FRAME::ExchangeFootprint(), PCB_SELECTION_TOOL::ExitGroup(), SYMBOL_EDIT_FRAME::GetSymbolFromRedoList(), SYMBOL_EDIT_FRAME::GetSymbolFromUndoList(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromLibrary(), EE_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::narrowSelection(), FOOTPRINT_EDITOR_CONTROL::NewFootprint(), FOOTPRINT_EDIT_FRAME::OpenProjectFiles(), PCB_BASE_FRAME::PlaceFootprint(), SYMBOL_EDITOR_PIN_TOOL::PlacePin(), BOARD_COMMIT::Push(), PCB_SELECTION_TOOL::RebuildSelection(), SCH_EDIT_TOOL::RepeatDrawItem(), SYMBOL_EDIT_FRAME::RollbackSymbolFromUndo(), SCH_EDIT_FRAME::SaveCopyForRepeatItem(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), SCH_SEXPR_PLUGIN_CACHE::savePin(), EE_SELECTION_TOOL::selectMultiple(), SCH_EDIT_FRAME::SelectUnit(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ ClearSelected()

◆ ClearTempFlags()

void EDA_ITEM::ClearTempFlags ( )
inlineinherited

Definition at line 165 of file eda_item.h.

166  {
168  DO_NOT_DRAW );
169  }
#define DO_NOT_DRAW
Used to disable draw function.
#define STARTPOINT
When a line is selected, these flags indicate which.
#define ENDPOINT
ends. (Used to support dragging.)
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
#define CANDIDATE
flag indicating that the structure is connected
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:153
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define TEMP_SELECTED
flag indicating that the structure has already selected

References CANDIDATE, EDA_ITEM::ClearFlags(), DO_NOT_DRAW, ENDPOINT, IS_LINKED, SKIP_STRUCT, STARTPOINT, and TEMP_SELECTED.

Referenced by 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 223 of file sch_symbol.cpp.

224 {
225  return new SCH_SYMBOL( *this );
226 }
SCH_SYMBOL(const wxPoint &pos=wxPoint(0, 0), SCH_ITEM *aParent=nullptr)
Definition: sch_symbol.cpp:98

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 177 of file sch_item.cpp.

178 {
179  return m_connected_items[ aSheet ];
180 }
std::unordered_map< SCH_SHEET_PATH, SCH_ITEM_SET > m_connected_items
Store pointers to other items that are connected to this one, per sheet.
Definition: sch_item.h:494

References SCH_ITEM::m_connected_items.

Referenced by addConnections(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), CONNECTION_GRAPH::updateItemConnectivity(), 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 138 of file sch_item.cpp.

139 {
140  if( !IsConnectable() )
141  return nullptr;
142 
143  wxCHECK_MSG( !IsConnectivityDirty(), nullptr,
144  wxT( "Shouldn't be asking for connection if connectivity is dirty!" ) );
145 
146  if( !aSheet )
147  aSheet = &Schematic()->CurrentSheet();
148 
149  auto it = m_connection_map.find( *aSheet );
150 
151  if( it == m_connection_map.end() )
152  return nullptr;
153  else
154  return it->second;
155 }
virtual bool IsConnectable() const
Definition: sch_item.h:349
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:104
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:497
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:121

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_PIN::GetMsgPanelInfo(), SCH_BUS_ENTRY_BASE::GetMsgPanelInfo(), SCH_LINE::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), CONNECTION_SUBGRAPH::GetNetName(), SCH_ITEM::GetOrInitConnection(), highlightNet(), SCH_ITEM::InitializeConnection(), SCH_ITEM::NetClass(), SCH_TEXT::Plot(), SCH_GLOBALLABEL::Print(), SCH_HIERLABEL::Print(), SCH_EDIT_FRAME::RecalculateConnections(), CONNECTION_SUBGRAPH::ResolveDrivers(), 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_LINE, SCH_BUS_WIRE_ENTRY, and SCH_PIN.

Definition at line 411 of file sch_item.h.

411 { return true; }

Referenced by CONNECTION_GRAPH::updateItemConnectivity().

◆ doGetBoundingBox()

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

Definition at line 1331 of file sch_symbol.cpp.

1332 {
1333  EDA_RECT bBox;
1334 
1335  if( m_part )
1336  bBox = m_part->GetBodyBoundingBox( m_unit, m_convert, aIncludePins );
1337  else
1338  bBox = dummy()->GetBodyBoundingBox( m_unit, m_convert, aIncludePins );
1339 
1340  int x0 = bBox.GetX();
1341  int xm = bBox.GetRight();
1342 
1343  // We must reverse Y values, because matrix orientation
1344  // suppose Y axis normal for the library items coordinates,
1345  // m_transform reverse Y values, but bBox is already reversed!
1346  int y0 = -bBox.GetY();
1347  int ym = -bBox.GetBottom();
1348 
1349  // Compute the real Boundary box (rotated, mirrored ...)
1350  int x1 = m_transform.x1 * x0 + m_transform.y1 * y0;
1351  int y1 = m_transform.x2 * x0 + m_transform.y2 * y0;
1352  int x2 = m_transform.x1 * xm + m_transform.y1 * ym;
1353  int y2 = m_transform.x2 * xm + m_transform.y2 * ym;
1354 
1355  bBox.SetX( x1 );
1356  bBox.SetY( y1 );
1357  bBox.SetWidth( x2 - x1 );
1358  bBox.SetHeight( y2 - y1 );
1359  bBox.Normalize();
1360 
1361  bBox.Offset( m_pos );
1362 
1363  if( aIncludeFields )
1364  {
1365  for( const SCH_FIELD& field : m_fields )
1366  {
1367  if( field.IsVisible() )
1368  bBox.Merge( field.GetBoundingBox() );
1369  }
1370  }
1371 
1372  return bBox;
1373 }
void Offset(int dx, int dy)
Definition: eda_rect.h:156
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
void Merge(const EDA_RECT &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: eda_rect.cpp:432
int y2
Definition: transform.h:51
int GetX() const
Definition: eda_rect.h:107
int x2
Definition: transform.h:50
int x1
Definition: transform.h:48
int m_unit
The unit for multiple part per package symbols.
Definition: sch_symbol.h:680
int GetBottom() const
Definition: eda_rect.h:123
const EDA_RECT GetBodyBoundingBox(int aUnit, int aConvert, bool aIncludePins) const
Get the symbol bounding box excluding fields.
Definition: lib_symbol.cpp:916
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
int y1
Definition: transform.h:49
int m_convert
The alternate body style for symbols that have more than one body style defined.
Definition: sch_symbol.h:681
void SetHeight(int val)
Definition: eda_rect.h:185
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699
int GetRight() const
Definition: eda_rect.h:120
wxPoint m_pos
Definition: sch_symbol.h:678
void SetX(int val)
Definition: eda_rect.h:167
std::unique_ptr< LIB_SYMBOL > m_part
a flattened copy of the LIB_SYMBOL from the PROJECT's libraries.
Definition: sch_symbol.h:701
void SetWidth(int val)
Definition: eda_rect.h:179
void SetY(int val)
Definition: eda_rect.h:173
void Normalize()
Ensures that the height ant width are positive.
Definition: eda_rect.cpp:35
Handle the component boundary box.
Definition: eda_rect.h:42
TRANSFORM m_transform
The rotation/mirror transformation.
Definition: sch_symbol.h:698
int GetY() const
Definition: eda_rect.h:108

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

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

◆ DoHypertextMenu()

virtual void SCH_ITEM::DoHypertextMenu ( EDA_DRAW_FRAME aFrame)
inlinevirtualinherited

Reimplemented in SCH_FIELD.

Definition at line 254 of file sch_item.h.

254 { }

◆ doIsConnected()

bool SCH_SYMBOL::doIsConnected ( const wxPoint &  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 wxPoint object containing the test position.
Returns
True if connection to aPosition exists.

Reimplemented from SCH_ITEM.

Definition at line 1842 of file sch_symbol.cpp.

1843 {
1844  wxPoint new_pos = m_transform.InverseTransform().TransformCoordinate( aPosition - m_pos );
1845 
1846  for( const auto& pin : m_pins )
1847  {
1848  if( pin->GetType() == ELECTRICAL_PINTYPE::PT_NC )
1849  continue;
1850 
1851  // Collect only pins attached to the current unit and convert.
1852  // others are not associated to this symbol instance
1853  int pin_unit = pin->GetLibPin()->GetUnit();
1854  int pin_convert = pin->GetLibPin()->GetConvert();
1855 
1856  if( pin_unit > 0 && pin_unit != GetUnit() )
1857  continue;
1858 
1859  if( pin_convert > 0 && pin_convert != GetConvert() )
1860  continue;
1861 
1862  if( pin->GetLocalPosition() == new_pos )
1863  return true;
1864  }
1865 
1866  return false;
1867 }
std::vector< std::unique_ptr< SCH_PIN > > m_pins
a SCH_PIN for every LIB_PIN (all units)
Definition: sch_symbol.h:703
TRANSFORM InverseTransform() const
Calculate the Inverse mirror/rotation transform.
Definition: transform.cpp:57
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
wxPoint m_pos
Definition: sch_symbol.h:678
TRANSFORM m_transform
The rotation/mirror transformation.
Definition: sch_symbol.h:698
int GetUnit() const
Definition: sch_symbol.h:196
not connected (must be left open)
int GetConvert() const
Definition: sch_symbol.h:224

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 85 of file sch_item.cpp.

86 {
87  SCH_ITEM* newItem = (SCH_ITEM*) Clone();
88 
89  if( !doClone )
90  const_cast<KIID&>( newItem->m_Uuid ) = KIID();
91 
92  newItem->ClearFlags( SELECTED | BRIGHTENED );
93 
94  newItem->RunOnChildren(
95  []( SCH_ITEM* aChild )
96  {
97  aChild->ClearFlags( SELECTED | BRIGHTENED );
98  } );
99 
100  return newItem;
101 }
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:83
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction)
Definition: sch_item.h:444
Definition: kiid.h:44
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:153
#define SELECTED
const KIID m_Uuid
Definition: eda_item.h:474
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:182
#define BRIGHTENED
item is drawn with a bright contour

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

774 {
775  unsigned start = aIncludeDefaultFields ? 0 : MANDATORY_FIELDS;
776 
777  for( unsigned i = start; i < m_fields.size(); ++i )
778  {
779  if( aFieldName == m_fields[i].GetName( false ) )
780  return &m_fields[i];
781  }
782 
783  return nullptr;
784 }
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699
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(), NETLIST_EXPORTER_PSPICE::GetSpiceField(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), DIALOG_CHANGE_SYMBOLS::processSymbol(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), TUNER_SLIDER::TUNER_SLIDER(), and UpdateFields().

◆ Get() [1/3]

wxAny INSPECTABLE::Get ( PROPERTY_BASE aProperty)
inlineinherited

Definition at line 86 of file inspectable.h.

87  {
89  TYPE_ID thisType = TYPE_HASH( *this );
90  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
91  return object ? aProperty->getter( object ) : wxAny();
92  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:65
#define TYPE_HASH(x)
Definition: property.h:59
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:42
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.
virtual wxAny getter(void *aObject) const =0
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:62
virtual size_t OwnerHash() const =0
Return type-id of the Owner class.

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(), PCB_EXPR_VAR_REF::GetValue(), and PAD_DESC::PAD_DESC().

◆ Get() [2/3]

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

Definition at line 95 of file inspectable.h.

96  {
98  TYPE_ID thisType = TYPE_HASH( *this );
99  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
100  return object ? aProperty->get<T>( object ) : T();
101  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:65
#define TYPE_HASH(x)
Definition: property.h:59
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:42
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:62
T get(void *aObject)
Definition: property.h:268
virtual size_t OwnerHash() const =0
Return type-id of the Owner class.

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

◆ Get() [3/3]

template<typename T >
boost::optional<T> INSPECTABLE::Get ( const wxString &  aProperty)
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  boost::optional<T> ret = T();
110 
111  if( prop )
112  {
113  void* object = propMgr.TypeCast( this, thisType, prop->OwnerHash() );
114 
115  if( object )
116  ret = prop->get<T>( object );
117  }
118 
119  return ret;
120  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:65
#define TYPE_HASH(x)
Definition: property.h:59
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:42
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Return a property for a specific type.
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:62
T get(void *aObject)
Definition: property.h:268
virtual size_t OwnerHash() const =0
Return type-id of the Owner class.

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

◆ GetBodyAndPinsBoundingBox()

EDA_RECT SCH_SYMBOL::GetBodyAndPinsBoundingBox ( ) const

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

Definition at line 1382 of file sch_symbol.cpp.

1383 {
1384  return doGetBoundingBox( true, false );
1385 }
EDA_RECT doGetBoundingBox(bool aIncludePins, bool aIncludeFields) const

References doGetBoundingBox().

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

◆ GetBodyBoundingBox()

EDA_RECT SCH_SYMBOL::GetBodyBoundingBox ( ) const

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

Definition at line 1376 of file sch_symbol.cpp.

1377 {
1378  return doGetBoundingBox( false, false );
1379 }
EDA_RECT doGetBoundingBox(bool aIncludePins, bool aIncludeFields) const

References doGetBoundingBox().

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

◆ GetBoundingBox()

const EDA_RECT 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 1388 of file sch_symbol.cpp.

1389 {
1390  return doGetBoundingBox( true, true );
1391 }
EDA_RECT doGetBoundingBox(bool aIncludePins, bool aIncludeFields) const

References doGetBoundingBox().

Referenced by SCH_EDITOR_CONTROL::FindSymbolAndItem().

◆ GetClass()

wxString SCH_SYMBOL::GetClass ( ) const
inlineoverridevirtual

Return the class name.

Reimplemented from SCH_ITEM.

Definition at line 118 of file sch_symbol.h.

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

Referenced by operator=().

◆ GetConnectionPoints()

std::vector< wxPoint > 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 1614 of file sch_symbol.cpp.

1615 {
1616  std::vector<wxPoint> retval;
1617 
1618  for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
1619  {
1620  // Collect only pins attached to the current unit and convert.
1621  // others are not associated to this symbol instance
1622  int pin_unit = pin->GetLibPin()->GetUnit();
1623  int pin_convert = pin->GetLibPin()->GetConvert();
1624 
1625  if( pin_unit > 0 && pin_unit != GetUnit() )
1626  continue;
1627 
1628  if( pin_convert > 0 && pin_convert != GetConvert() )
1629  continue;
1630 
1631  retval.push_back( m_transform.TransformCoordinate( pin->GetLocalPosition() ) + m_pos );
1632  }
1633 
1634  return retval;
1635 }
std::vector< std::unique_ptr< SCH_PIN > > m_pins
a SCH_PIN for every LIB_PIN (all units)
Definition: sch_symbol.h:703
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
wxPoint m_pos
Definition: sch_symbol.h:678
TRANSFORM m_transform
The rotation/mirror transformation.
Definition: sch_symbol.h:698
int GetUnit() const
Definition: sch_symbol.h:196
int GetConvert() const
Definition: sch_symbol.h:224

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

959 {
960  for( int i = 0; i < MANDATORY_FIELDS; ++i )
961  aVars->push_back( m_fields[i].GetCanonicalName().Upper() );
962 
963  for( size_t i = MANDATORY_FIELDS; i < m_fields.size(); ++i )
964  aVars->push_back( m_fields[i].GetName() );
965 
966  aVars->push_back( wxT( "FOOTPRINT_LIBRARY" ) );
967  aVars->push_back( wxT( "FOOTPRINT_NAME" ) );
968  aVars->push_back( wxT( "UNIT" ) );
969 }
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.

References m_fields, and MANDATORY_FIELDS.

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

◆ GetConvert()

◆ GetDatasheet()

wxString SCH_SYMBOL::GetDatasheet ( ) const

Return the documentation text for the given part alias.

Definition at line 298 of file sch_symbol.cpp.

299 {
300  if( m_part )
301  return m_part->GetDatasheetField().GetText();
302 
303  return wxEmptyString;
304 }
std::unique_ptr< LIB_SYMBOL > m_part
a flattened copy of the LIB_SYMBOL from the PROJECT's libraries.
Definition: sch_symbol.h:701

References m_part.

Referenced by UpdateFields().

◆ GetDescription()

wxString SCH_SYMBOL::GetDescription ( ) const

Return information about the aliased parts.

Definition at line 289 of file sch_symbol.cpp.

290 {
291  if( m_part )
292  return m_part->GetDescription();
293 
294  return wxEmptyString;
295 }
std::unique_ptr< LIB_SYMBOL > m_part
a flattened copy of the LIB_SYMBOL from the PROJECT's libraries.
Definition: sch_symbol.h:701

References m_part.

Referenced by NETLIST_EXPORTER_XML::makeSymbols().

◆ GetDrawItem()

LIB_ITEM * SCH_SYMBOL::GetDrawItem ( const wxPoint &  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 1638 of file sch_symbol.cpp.

1639 {
1640  if( m_part )
1641  {
1642  // Calculate the position relative to the symbol.
1643  wxPoint libPosition = aPosition - m_pos;
1644 
1645  return m_part->LocateDrawItem( m_unit, m_convert, aType, libPosition, m_transform );
1646  }
1647 
1648  return nullptr;
1649 }
int m_unit
The unit for multiple part per package symbols.
Definition: sch_symbol.h:680
int m_convert
The alternate body style for symbols that have more than one body style defined.
Definition: sch_symbol.h:681
wxPoint m_pos
Definition: sch_symbol.h:678
std::unique_ptr< LIB_SYMBOL > m_part
a flattened copy of the LIB_SYMBOL from the PROJECT's libraries.
Definition: sch_symbol.h:701
TRANSFORM m_transform
The rotation/mirror transformation.
Definition: sch_symbol.h:698

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

158  {
159  constexpr int mask = ( IS_NEW | IS_PASTED | IS_MOVING | IS_RESIZING | IS_DRAGGING
161 
162  return m_flags & mask;
163  }
#define IS_NEW
New item, just created.
#define IS_RESIZING
Item being resized.
#define IS_DRAGGING
Item being dragged.
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
#define IS_MOVING
Item being moved.
#define STRUCT_DELETED
flag indication structures to be erased
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.

References IS_DRAGGING, IS_MOVING, IS_NEW, IS_PASTED, IS_RESIZING, IS_WIRE_IMAGE, EDA_ITEM::m_flags, and STRUCT_DELETED.

Referenced by 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_TOOL::Properties(), PAD_TOOL::recombinePad(), SCH_EDIT_FRAME::SchematicCleanUp(), SCH_EDIT_FRAME::SelectUnit(), DIALOG_DIMENSION_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_AND_LABEL_PROPERTIES::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), and DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow().

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

1541 {
1542  for( auto& pin : m_pins )
1543  {
1544  LIB_PIN* lib_pin = pin->GetLibPin();
1545 
1546  if( lib_pin->GetUnit() && m_unit && ( m_unit != lib_pin->GetUnit() ) )
1547  continue;
1548 
1549  DANGLING_END_ITEM item( PIN_END, lib_pin, GetPinPhysicalPosition( lib_pin ), this );
1550  aItemList.push_back( item );
1551  }
1552 }
std::vector< std::unique_ptr< SCH_PIN > > m_pins
a SCH_PIN for every LIB_PIN (all units)
Definition: sch_symbol.h:703
wxPoint GetPinPhysicalPosition(const LIB_PIN *Pin) const
int m_unit
The unit for multiple part per package symbols.
Definition: sch_symbol.h:680
int GetUnit() const
Definition: lib_item.h:266
Helper class used to store the state of schematic items that can be connected to other schematic item...
Definition: sch_item.h:79

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

◆ GetField() [1/2]

SCH_FIELD * SCH_SYMBOL::GetField ( MANDATORY_FIELD_T  aFieldType)

◆ GetField() [2/2]

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

Definition at line 711 of file sch_symbol.cpp.

712 {
713  return &m_fields[aFieldType];
714 }
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699

References m_fields.

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

718 {
719  for( size_t ii = 0; ii < m_fields.size(); ++ii )
720  {
721  if( m_fields[ii].GetId() == aFieldId )
722  return &m_fields[ii];
723  }
724 
725  return nullptr;
726 }
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699

References m_fields.

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

◆ GetFieldCount()

◆ GetFields() [1/3]

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

Populate a std::vector with SCH_FIELDs.

Parameters
aVectoris the vector to populate.
aVisibleOnlyis used to add only the fields that are visible and contain text.

Definition at line 741 of file sch_symbol.cpp.

742 {
743  for( SCH_FIELD& field : m_fields )
744  {
745  if( !aVisibleOnly || ( field.IsVisible() && !field.IsVoid() ) )
746  aVector.push_back( &field );
747  }
748 }
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699

References m_fields.

Referenced by NETLIST_EXPORTER_XML::addSymbolFields(), AUTOPLACER::AUTOPLACER(), KIGFX::SCH_PAINTER::draw(), CADSTAR_SCH_ARCHIVE_LOADER::Load(), DIALOG_SYMBOL_FIELDS_TABLE::LoadFieldNames(), SYMBOL_EDIT_FRAME::LoadSymbolFromSchematic(), NETLIST_EXPORTER_XML::makeSymbols(), SCH_EDITOR_CONTROL::nextMatch(), operator==(), DIALOG_CHANGE_SYMBOLS::processSymbol(), SCH_SEXPR_PLUGIN::saveSymbol(), SCH_LEGACY_PLUGIN::saveSymbol(), ERC_TESTER::TestTextVars(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow(), DIALOG_CHANGE_SYMBOLS::updateFieldsList(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ GetFields() [2/3]

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

Return a vector of fields from the symbol.

Definition at line 370 of file sch_symbol.h.

370 { return m_fields; }
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699

References m_fields.

Referenced by operator==().

◆ GetFields() [3/3]

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

Definition at line 371 of file sch_symbol.h.

371 { return m_fields; }
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699

References m_fields.

◆ 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; }
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:489

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,
SCH_EDIT_FRAME aFrame 
) const

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

Parameters
aFieldNameis the name of the field

Definition at line 729 of file sch_symbol.cpp.

730 {
731  for( const SCH_FIELD& field : m_fields )
732  {
733  if( aFieldName == field.GetName() || aFieldName == field.GetCanonicalName() )
734  return field.GetText();
735  }
736 
737  return wxEmptyString;
738 }
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699

References m_fields.

Referenced by FIELDS_EDITOR_GRID_DATA_MODEL::AddColumn().

◆ GetFlags()

◆ GetFocusPosition()

virtual const wxPoint EDA_ITEM::GetFocusPosition ( ) const
inlinevirtualinherited

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

Reimplemented in BOARD, PCB_TRACK, and PCB_SHAPE.

Definition at line 258 of file eda_item.h.

258 { return GetPosition(); }
virtual wxPoint GetPosition() const
Definition: eda_item.h:251

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

655 {
656  KIID_PATH path = sheet->Path();
657 
658  for( const SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
659  {
660  if( instance.m_Path == path && !instance.m_Footprint.IsEmpty() )
661  {
662  // This can only be an override from an Update Schematic from PCB, and therefore
663  // will always be fully resolved.
664  return instance.m_Footprint;
665  }
666  }
667 
668  if( !aResolve )
669  return GetField( FOOTPRINT_FIELD )->GetText();
670 
672 }
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:705
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_field.cpp:105
A simple container for schematic symbol instance information.
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
Definition: sch_symbol.h:712
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154
Field Name Module PCB, i.e. "16DIP300".

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

Definition at line 663 of file sch_symbol.h.

663 { return m_inBom; }
bool m_inBom
True to include in bill of materials export.
Definition: sch_symbol.h:707

References m_inBom.

Referenced by NETLIST_EXPORTER_XML::makeListOfNets(), NETLIST_EXPORTER_XML::makeSymbols(), SCH_SEXPR_PLUGIN::saveSymbol(), and DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow().

◆ GetIncludeOnBoard()

bool SCH_SYMBOL::GetIncludeOnBoard ( ) const
inline

◆ GetInstanceReferences()

const std::vector<SYMBOL_INSTANCE_REFERENCE>& SCH_SYMBOL::GetInstanceReferences ( )
inline

Definition at line 123 of file sch_symbol.h.

124  {
125  return m_instanceReferences;
126  }
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
Definition: sch_symbol.h:712

References m_instanceReferences.

Referenced by FIELDS_EDITOR_GRID_DATA_MODEL::AddColumn(), DIALOG_CHANGE_SYMBOLS::processSymbol(), SCH_SEXPR_PLUGIN::saveSymbol(), and SCH_LEGACY_PLUGIN::saveSymbol().

◆ GetLayer()

SCH_LAYER_ID SCH_ITEM::GetLayer ( ) const
inlineinherited

◆ GetLibId()

◆ GetLibPins()

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

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

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

Definition at line 882 of file sch_symbol.cpp.

883 {
884  if( m_part )
885  m_part->GetPins( aPinsList, m_unit, m_convert );
886 }
int m_unit
The unit for multiple part per package symbols.
Definition: sch_symbol.h:680
int m_convert
The alternate body style for symbols that have more than one body style defined.
Definition: sch_symbol.h:681
std::unique_ptr< LIB_SYMBOL > m_part
a flattened copy of the LIB_SYMBOL from the PROJECT's libraries.
Definition: sch_symbol.h:701

References m_convert, m_part, and m_unit.

◆ GetLibSymbolRef() [1/2]

◆ GetLibSymbolRef() [2/2]

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

Definition at line 166 of file sch_symbol.h.

166 { return m_part; }
std::unique_ptr< LIB_SYMBOL > m_part
a flattened copy of the LIB_SYMBOL from the PROJECT's libraries.
Definition: sch_symbol.h:701

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

1471 {
1472  return BITMAPS::add_component;
1473 }

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

1395 {
1396  wxString msg;
1397 
1398  SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( aFrame );
1399  SCH_SHEET_PATH* currentSheet = schframe ? &schframe->GetCurrentSheet() : nullptr;
1400 
1401  // part and alias can differ if alias is not the root
1402  if( m_part )
1403  {
1404  if( m_part.get() != dummy() )
1405  {
1406  aList.emplace_back( _( "Reference" ), GetRef( currentSheet ) );
1407 
1408  msg = m_part->IsPower() ? _( "Power symbol" ) : _( "Value" );
1409  aList.emplace_back( msg, GetValue( currentSheet, true ) );
1410 
1411 #if 0 // Display symbol flags, for debug only
1412  aList.emplace_back( _( "flags" ), wxString::Format( "%X", GetEditFlags() ) );
1413 #endif
1414 
1415  // Display symbol reference in library and library
1416  aList.emplace_back( _( "Name" ), UnescapeString( GetLibId().GetLibItemName() ) );
1417 
1418  if( !m_part->IsRoot() )
1419  {
1420  msg = _( "Missing parent" );
1421 
1422  std::shared_ptr< LIB_SYMBOL > parent = m_part->GetParent().lock();
1423 
1424  if( parent )
1425  msg = parent->GetName();
1426 
1427  aList.emplace_back( _( "Alias of" ), UnescapeString( msg ) );
1428  }
1429  else if( !m_lib_id.GetLibNickname().empty() )
1430  {
1431  aList.emplace_back( _( "Library" ), m_lib_id.GetLibNickname() );
1432  }
1433  else
1434  {
1435  aList.emplace_back( _( "Library" ), _( "Undefined!!!" ) );
1436  }
1437 
1438  // Display the current associated footprint, if exists.
1439  msg = GetFootprint( currentSheet, true );
1440 
1441  if( msg.IsEmpty() )
1442  msg = _( "<Unknown>" );
1443 
1444  aList.emplace_back( _( "Footprint" ), msg );
1445 
1446  // Display description of the symbol, and keywords found in lib
1447  aList.emplace_back( _( "Description" ), m_part->GetDescription() );
1448  aList.emplace_back( _( "Keywords" ), m_part->GetKeyWords() );
1449  }
1450  }
1451  else
1452  {
1453  aList.emplace_back( _( "Reference" ), GetRef( currentSheet ) );
1454 
1455  aList.emplace_back( _( "Value" ), GetValue( currentSheet, true ) );
1456  aList.emplace_back( _( "Name" ), GetLibId().GetLibItemName() );
1457 
1458  wxString libNickname = GetLibId().GetLibNickname();
1459 
1460  if( libNickname.empty() )
1461  msg = _( "No library defined!" );
1462  else
1463  msg.Printf( _( "Symbol not found in %s!" ), libNickname );
1464 
1465  aList.emplace_back( _( "Library" ), msg );
1466  }
1467 }
Schematic editor (Eeschema) main window.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:464
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
#define _(s)
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:90
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
std::unique_ptr< LIB_SYMBOL > m_part
a flattened copy of the LIB_SYMBOL from the PROJECT's libraries.
Definition: sch_symbol.h:701
EDA_ITEM_FLAGS GetEditFlags() const
Definition: eda_item.h:157
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:596
wxString UnescapeString(const wxString &aSource)
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
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
Definition: sch_symbol.h:679
SCH_SHEET_PATH & GetCurrentSheet() const
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:654
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:148
bool empty() const
Definition: utf8.h:103

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

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

1263 {
1264  int rotate_values[] =
1265  {
1266  SYM_ORIENT_0,
1267  SYM_ORIENT_90,
1273  SYM_MIRROR_Y,
1278  };
1279 
1280  // Try to find the current transform option:
1281  TRANSFORM transform = m_transform;
1282 
1283  for( int type_rotate : rotate_values )
1284  {
1285  SetOrientation( type_rotate );
1286 
1287  if( transform == m_transform )
1288  return type_rotate;
1289  }
1290 
1291  // Error: orientation not found in list (should not happen)
1292  wxFAIL_MSG( wxT( "Schematic symbol orientation matrix internal error." ) );
1293  m_transform = transform;
1294 
1295  return SYM_NORMAL;
1296 }
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
TRANSFORM m_transform
The rotation/mirror transformation.
Definition: sch_symbol.h:698

References 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(), AUTOPLACER::getPreferredSides(), orientLabel(), SCH_SEXPR_PLUGIN::saveSymbol(), and DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow().

◆ GetOrInitConnection()

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

Definition at line 218 of file sch_item.cpp.

220 {
221  if( !IsConnectable() )
222  return nullptr;
223 
224  SetConnectivityDirty( false );
225 
226  SCH_CONNECTION* connection = Connection( &aSheet );
227 
228  if( connection )
229  return connection;
230  else
231  return InitializeConnection( aSheet, aGraph );
232 }
virtual bool IsConnectable() const
Definition: sch_item.h:349
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:138
SCH_CONNECTION * InitializeConnection(const SCH_SHEET_PATH &aPath, CONNECTION_GRAPH *aGraph)
Create a new connection object associated with this object.
Definition: sch_item.cpp:195
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
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()

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

871 {
872  for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
873  {
874  if( pin->GetNumber() == aNumber )
875  return pin.get();
876  }
877 
878  return nullptr;
879 }
std::vector< std::unique_ptr< SCH_PIN > > m_pins
a SCH_PIN for every LIB_PIN (all units)
Definition: sch_symbol.h:703

References m_pins, and pin.

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

◆ GetPin() [2/2]

SCH_PIN * SCH_SYMBOL::GetPin ( LIB_PIN aLibPin)

Definition at line 889 of file sch_symbol.cpp.

890 {
891  wxASSERT( m_pinMap.count( aLibPin ) );
892  return m_pins[ m_pinMap.at( aLibPin ) ].get();
893 }
std::vector< std::unique_ptr< SCH_PIN > > m_pins
a SCH_PIN for every LIB_PIN (all units)
Definition: sch_symbol.h:703
std::unordered_map< LIB_PIN *, unsigned > m_pinMap
library pin pointer : SCH_PIN's index
Definition: sch_symbol.h:704

References m_pinMap, and m_pins.

◆ GetPinPhysicalPosition()

wxPoint SCH_SYMBOL::GetPinPhysicalPosition ( const LIB_PIN Pin) const

Definition at line 1605 of file sch_symbol.cpp.

1606 {
1607  wxCHECK_MSG( Pin != nullptr && Pin->Type() == LIB_PIN_T, wxPoint( 0, 0 ),
1608  wxT( "Cannot get physical position of pin." ) );
1609 
1610  return m_transform.TransformCoordinate( Pin->GetPosition() ) + m_pos;
1611 }
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
wxPoint m_pos
Definition: sch_symbol.h:678
wxPoint GetPosition() const override
Definition: lib_pin.h:212
TRANSFORM m_transform
The rotation/mirror transformation.
Definition: sch_symbol.h:698
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

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

897 {
898  std::vector<SCH_PIN*> pins;
899 
900  if( aSheet == nullptr )
901  {
902  wxCHECK_MSG( Schematic(), pins, wxT( "Can't call GetPins on a symbol with no schematic" ) );
903 
904  aSheet = &Schematic()->CurrentSheet();
905  }
906 
907  int unit = GetUnitSelection( aSheet );
908 
909  for( const auto& p : m_pins )
910  {
911  if( unit && p->GetLibPin()->GetUnit() && ( p->GetLibPin()->GetUnit() != unit ) )
912  continue;
913 
914  pins.push_back( p.get() );
915  }
916 
917  return pins;
918 }
std::vector< std::unique_ptr< SCH_PIN > > m_pins
a SCH_PIN for every LIB_PIN (all units)
Definition: sch_symbol.h:703
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:104
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
Definition: sch_symbol.cpp:554
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:121

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

Referenced by NETLIST_EXPORTER_BASE::CreatePinList(), AUTOPLACER::fieldBoxPlacement(), NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol(), SCH_EDITOR_CONTROL::nextMatch(), SCH_EDITOR_CONTROL::Paste(), AUTOPLACER::pinsOnSide(), TEST_SCH_PIN_FIXTURE::TEST_SCH_PIN_FIXTURE(), ERC_TESTER::TestNoConnectPins(), CONNECTION_GRAPH::updateItemConnectivity(), and SCH_EDITOR_CONTROL::UpdateNetHighlighting().

◆ GetPosition()

◆ GetPrefix()

wxString SCH_SYMBOL::GetPrefix ( ) const
inline

Definition at line 228 of file sch_symbol.h.

228 { return m_prefix; }
wxString m_prefix
C, R, U, Q etc - the first character(s) which typically indicate what the symbol is.
Definition: sch_symbol.h:684

References m_prefix.

Referenced by SCH_LEGACY_PLUGIN::saveSymbol().

◆ GetRawPins()

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

Definition at line 471 of file sch_symbol.h.

471 { return m_pins; }
std::vector< std::unique_ptr< SCH_PIN > > m_pins
a SCH_PIN for every LIB_PIN (all units)
Definition: sch_symbol.h:703

References m_pins.

Referenced by DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES(), and SCH_SEXPR_PLUGIN::saveSymbol().

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

465 {
466  KIID_PATH path = sheet->Path();
467  wxString ref;
468 
469  for( const SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
470  {
471  if( instance.m_Path == path )
472  {
473  ref = instance.m_Reference;
474  break;
475  }
476  }
477 
478  // If it was not found in m_Paths array, then see if it is in m_Field[REFERENCE] -- if so,
479  // use this as a default for this path. This will happen if we load a version 1 schematic
480  // file. It will also mean that multiple instances of the same sheet by default all have
481  // the same symbol references, but perhaps this is best.
482  if( ref.IsEmpty() && !GetField( REFERENCE_FIELD )->GetText().IsEmpty() )
483  {
484  const_cast<SCH_SYMBOL*>( this )->SetRef( sheet, GetField( REFERENCE_FIELD )->GetText() );
485  ref = GetField( REFERENCE_FIELD )->GetText();
486  }
487 
488  if( ref.IsEmpty() )
490 
491  if( aIncludeUnit && GetUnitCount() > 1 )
492  ref += LIB_SYMBOL::SubReference( GetUnit() );
493 
494  return ref;
495 }
Field Reference of part, i.e. "IC21".
wxString m_prefix
C, R, U, Q etc - the first character(s) which typically indicate what the symbol is.
Definition: sch_symbol.h:684
wxString GetRefDesUnannotated(const wxString &aSource)
Return an unannotated refdes from either a prefix or an existing refdes.
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:705
int GetUnitCount() const
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:393
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Definition: lib_symbol.cpp:495
A simple container for schematic symbol instance information.
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
Definition: sch_symbol.h:712
int GetUnit() const
Definition: sch_symbol.h:196
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154

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

Referenced by NETLIST_EXPORTER_XML::addSymbolFields(), SCH_EDIT_FRAME::AnnotateSymbols(), SCH_SHEET_PATH::AppendMultiUnitSymbol(), SCH_SHEET_PATH::AppendSymbol(), 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_CHANGE_SYMBOLS::isMatch(), NETLIST_EXPORTER_XML::makeSymbols(), SCH_EDIT_FRAME::mapExistingAnnotation(), SCH_FIELD::Matches(), SCH_EDITOR_CONTROL::Paste(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), SCH_REFERENCE_LIST::ReannotateDuplicates(), 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_ORCADPCB2::WriteNetlist(), and NETLIST_EXPORTER_CADSTAR::WriteNetlist().

◆ GetSchSymbolLibraryName()

wxString SCH_SYMBOL::GetSchSymbolLibraryName ( ) const

Definition at line 271 of file sch_symbol.cpp.

272 {
273  if( !m_schLibSymbolName.IsEmpty() )
274  return m_schLibSymbolName;
275  else
276  return m_lib_id.Format();
277 }
wxString m_schLibSymbolName
The name used to look up a symbol in the symbol library embedded in a schematic.
Definition: sch_symbol.h:696
UTF8 Format() const
Definition: lib_id.cpp:116
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
Definition: sch_symbol.h:679

References LIB_ID::Format(), m_lib_id, and m_schLibSymbolName.

Referenced by SCH_SCREEN::Append(), NETLIST_EXPORTER_BASE::findNextSymbol(), SCH_SEXPR_PLUGIN::Format(), NETLIST_EXPORTER_XML::makeSymbols(), SCH_EDITOR_CONTROL::Paste(), SCH_SCREEN::Remove(), and SCH_SEXPR_PLUGIN::saveSymbol().

◆ GetSelectMenuText()

wxString SCH_SYMBOL::GetSelectMenuText ( EDA_UNITS  aUnits) 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 1652 of file sch_symbol.cpp.

1653 {
1654  return wxString::Format( _( "Symbol %s [%s]" ),
1655  GetField( REFERENCE_FIELD )->GetShownText(),
1656  UnescapeString( GetLibId().GetLibItemName() ) );
1657 }
Field Reference of part, i.e. "IC21".
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:705
#define _(s)
wxString UnescapeString(const wxString &aSource)
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
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:148

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

Referenced by Matches().

◆ GetState()

int EDA_ITEM::GetState ( EDA_ITEM_FLAGS  type) const
inlineinherited

Definition at line 136 of file eda_item.h.

137  {
138  return m_status & type;
139  }
EDA_ITEM_FLAGS m_status
Definition: eda_item.h:477

References EDA_ITEM::m_status.

Referenced by BOARD_ITEM::IsLocked().

◆ GetStatus()

EDA_ITEM_FLAGS EDA_ITEM::GetStatus ( ) const
inlineinherited

Definition at line 149 of file eda_item.h.

149 { return m_status; }
EDA_ITEM_FLAGS m_status
Definition: eda_item.h:477

References EDA_ITEM::m_status.

◆ GetStoredPos()

wxPoint& SCH_ITEM::GetStoredPos ( )
inlineinherited

Definition at line 222 of file sch_item.h.

222 { return m_storedPos; }
wxPoint m_storedPos
Definition: sch_item.h:490

References SCH_ITEM::m_storedPos.

◆ GetStroke()

virtual STROKE_PARAMS SCH_ITEM::GetStroke ( ) const
inlinevirtualinherited

Reimplemented in SCH_LINE, and SCH_BUS_ENTRY_BASE.

Definition at line 455 of file sch_item.h.

455 { wxCHECK( false, STROKE_PARAMS() ); }
Simple container to manage line stroke parameters.
Definition: sch_item.h:140

Referenced by DIALOG_LINE_WIRE_BUS_PROPERTIES::TransferDataToWindow().

◆ GetTransform() [1/2]

◆ GetTransform() [2/2]

const TRANSFORM& SCH_SYMBOL::GetTransform ( ) const
inline

Definition at line 233 of file sch_symbol.h.

233 { return m_transform; }
TRANSFORM m_transform
The rotation/mirror transformation.
Definition: sch_symbol.h:698

References m_transform.

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

394 {
395  if( m_part )
396  return m_part->GetUnitCount();
397 
398  return 0;
399 }
std::unique_ptr< LIB_SYMBOL > m_part
a flattened copy of the LIB_SYMBOL from the PROJECT's libraries.
Definition: sch_symbol.h:701

References m_part.

Referenced by NETLIST_EXPORTER_XML::addSymbolFields(), SCH_EDIT_FRAME::AnnotateSymbols(), GetRef(), SCH_FIELD::GetShownText(), SCH_EDIT_FRAME::mapExistingAnnotation(), SCH_FIELD::Matches(), SCH_DRAWING_TOOLS::PlaceSymbol(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), and 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 554 of file sch_symbol.cpp.

555 {
556  KIID_PATH path = aSheet->Path();
557 
558  for( const SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
559  {
560  if( instance.m_Path == path )
561  return instance.m_Unit;
562  }
563 
564  // If it was not found in m_Paths array, then use m_unit. This will happen if we load a
565  // version 1 schematic file.
566  return m_unit;
567 }
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
int m_unit
The unit for multiple part per package symbols.
Definition: sch_symbol.h:680
A simple container for schematic symbol instance information.
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
Definition: sch_symbol.h:712

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

Referenced by SCH_EDIT_FRAME::AnnotateSymbols(), KIGFX::SCH_PAINTER::draw(), GetPins(), SCH_EDIT_FRAME::mapExistingAnnotation(), ResolveTextVar(), SCH_REFERENCE::SCH_REFERENCE(), 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 596 of file sch_symbol.cpp.

597 {
598  KIID_PATH path = sheet->Path();
599 
600  for( const SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
601  {
602  if( instance.m_Path == path && !instance.m_Value.IsEmpty() )
603  {
604  // This can only be overridden by a new value but if we are resolving,
605  // make sure that the symbol returns the fully resolved text
606  if( aResolve )
607  {
608  SCH_SYMBOL new_sym( *this );
609  new_sym.GetField( VALUE_FIELD )->SetText( instance.m_Value );
610  return new_sym.GetField( VALUE_FIELD )->GetShownText();
611  }
612 
613  return instance.m_Value;
614  }
615  }
616 
617  if( !aResolve )
618  return GetField( VALUE_FIELD )->GetText();
619 
620  return GetField( VALUE_FIELD )->GetShownText();
621 }
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:705
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_field.cpp:105
Field Value of part, i.e. "3.3K".
A simple container for schematic symbol instance information.
Schematic symbol object.
Definition: sch_symbol.h:78
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
Definition: sch_symbol.h:712
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:154

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_FIELD::Replace(), ResolveTextVar(), SCH_REFERENCE::SCH_REFERENCE(), SCH_SYMBOL(), SCH_SHEET_PATH::UpdateAllScreenReferences(), NETLIST_EXPORTER_ORCADPCB2::WriteNetlist(), and NETLIST_EXPORTER_CADSTAR::WriteNetlist().

◆ HasBrightenedPins()

bool SCH_SYMBOL::HasBrightenedPins ( )

Definition at line 1893 of file sch_symbol.cpp.

1894 {
1895  for( const auto& pin : m_pins )
1896  {
1897  if( pin->IsBrightened() )
1898  return true;
1899  }
1900 
1901  return false;
1902 }
std::vector< std::unique_ptr< SCH_PIN > > m_pins
a SCH_PIN for every LIB_PIN (all units)
Definition: sch_symbol.h:703

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_LINE, and SCH_BUS_ENTRY_BASE.

Definition at line 453 of file sch_item.h.

453 { return false; }

Referenced by EE_SELECTION::AllItemsHaveLineStroke(), and SCH_EDIT_TOOL::Properties().

◆ HitTest() [1/2]

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

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

Parameters
aPositionA reference to a wxPoint 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 1814 of file sch_symbol.cpp.

1815 {
1816  EDA_RECT bBox = GetBodyBoundingBox();
1817  bBox.Inflate( aAccuracy / 2 );
1818 
1819  if( bBox.Contains( aPosition ) )
1820  return true;
1821 
1822  return false;
1823 }
bool Contains(const wxPoint &aPoint) const
Definition: eda_rect.cpp:57
EDA_RECT GetBodyBoundingBox() const
Return a bounding box for the symbol body but not the pins or fields.
Handle the component boundary box.
Definition: eda_rect.h:42
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364

References EDA_RECT::Contains(), GetBodyBoundingBox(), and EDA_RECT::Inflate().

◆ HitTest() [2/2]

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

Test if aRect intersects this item.

Parameters
aRectA reference to a EDA_RECT 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 1826 of file sch_symbol.cpp.

1827 {
1829  return false;
1830 
1831  EDA_RECT rect = aRect;
1832 
1833  rect.Inflate( aAccuracy / 2 );
1834 
1835  if( aContained )
1836  return rect.Contains( GetBodyBoundingBox() );
1837 
1838  return rect.Intersects( GetBodyBoundingBox() );
1839 }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480
bool Contains(const wxPoint &aPoint) const
Definition: eda_rect.cpp:57
EDA_RECT GetBodyBoundingBox() const
Return a bounding box for the symbol body but not the pins or fields.
#define STRUCT_DELETED
flag indication structures to be erased
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Handle the component boundary box.
Definition: eda_rect.h:42
bool Intersects(const EDA_RECT &aRect) const
Test for a common area between rectangles.
Definition: eda_rect.cpp:150
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364

References EDA_RECT::Contains(), GetBodyBoundingBox(), EDA_RECT::Inflate(), EDA_RECT::Intersects(), EDA_ITEM::m_flags, SKIP_STRUCT, and STRUCT_DELETED.

◆ Init()

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

Definition at line 194 of file sch_symbol.cpp.

195 {
196  m_pos = pos;
197  m_unit = 1; // In multi unit chip - which unit to draw.
198  m_convert = LIB_ITEM::LIB_CONVERT::BASE; // De Morgan Handling
199 
200  // The rotation/mirror transformation matrix. pos normal
202 
203  // construct only the mandatory fields, which are the first 4 only.
204  for( int i = 0; i < MANDATORY_FIELDS; ++i )
205  {
206  m_fields.emplace_back( pos, i, this, TEMPLATE_FIELDNAME::GetDefaultFieldName( i ) );
207 
208  if( i == REFERENCE_FIELD )
209  m_fields.back().SetLayer( LAYER_REFERENCEPART );
210  else if( i == VALUE_FIELD )
211  m_fields.back().SetLayer( LAYER_VALUEPART );
212  else
213  m_fields.back().SetLayer( LAYER_FIELDS );
214  }
215 
216  m_prefix = wxString( wxT( "U" ) );
217  m_isInNetlist = true;
218  m_inBom = true;
219  m_onBoard = true;
220 }
bool m_isInNetlist
True if the symbol should appear in the netlist.
Definition: sch_symbol.h:706
Field Reference of part, i.e. "IC21".
wxString m_prefix
C, R, U, Q etc - the first character(s) which typically indicate what the symbol is.
Definition: sch_symbol.h:684
int m_unit
The unit for multiple part per package symbols.
Definition: sch_symbol.h:680
int m_convert
The alternate body style for symbols that have more than one body style defined.
Definition: sch_symbol.h:681
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
Field Value of part, i.e. "3.3K".
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699
wxPoint m_pos
Definition: sch_symbol.h:678
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslate=true)
Return a default symbol field name for field aFieldNdx for all components.
bool m_onBoard
True to include in netlist when updating board.
Definition: sch_symbol.h:708
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
bool m_inBom
True to include in bill of materials export.
Definition: sch_symbol.h:707
TRANSFORM m_transform
The rotation/mirror transformation.
Definition: sch_symbol.h:698

References TEMPLATE_FIELDNAME::GetDefaultFieldName(), LAYER_FIELDS, LAYER_REFERENCEPART, LAYER_VALUEPART, m_convert, m_fields, m_inBom, m_isInNetlist, 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 195 of file sch_item.cpp.

197 {
198  SetConnectivityDirty( false );
199 
200  SCH_CONNECTION* connection = Connection( &aSheet );
201 
202  if( connection )
203  {
204  connection->Reset();
205  }
206  else
207  {
208  connection = new SCH_CONNECTION( this );
209  m_connection_map.insert( std::make_pair( aSheet, connection ) );
210  }
211 
212  connection->SetGraph( aGraph );
213  connection->SetSheet( aSheet );
214  return connection;
215 }
void SetSheet(SCH_SHEET_PATH aSheet)
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:138
void Reset()
Clears connectivity information.
void SetGraph(CONNECTION_GRAPH *aGraph)
std::unordered_map< SCH_SHEET_PATH, SCH_CONNECTION * > m_connection_map
Store connectivity information, per sheet.
Definition: sch_item.h:497
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
void SetConnectivityDirty(bool aDirty=true)
Definition: sch_item.h:415

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

541 {
542  KIID_PATH path = aSheet->Path();
543 
544  for( const SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
545  {
546  if( instance.m_Path == path )
547  return instance.m_Reference.Last() != '?';
548  }
549 
550  return false;
551 }
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
A simple container for schematic symbol instance information.
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
Definition: sch_symbol.h:712

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

601 { return true; }

◆ IsConnected()

bool SCH_ITEM::IsConnected ( const wxPoint &  aPoint) const
inherited

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

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

Definition at line 129 of file sch_item.cpp.

130 {
131  if(( m_flags & STRUCT_DELETED ) || ( m_flags & SKIP_STRUCT ) )
132  return false;
133 
134  return doIsConnected( aPosition );
135 }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480
#define STRUCT_DELETED
flag indication structures to be erased
#define SKIP_STRUCT
flag indicating that the structure should be ignored
virtual bool doIsConnected(const wxPoint &aPosition) const
Provide the object specific test to see if it is connected to aPosition.
Definition: sch_item.h:484

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

Referenced by SCH_SCREEN::doIsJunction(), and SCH_SCREEN::IsTerminalPoint().

◆ IsConnectivityDirty()

◆ IsDangling()

virtual bool SCH_ITEM::IsDangling ( ) const
inlinevirtualinherited

Reimplemented in SCH_TEXT, SCH_LINE, SCH_BUS_ENTRY_BASE, and SCH_PIN.

Definition at line 342 of file sch_item.h.

342 { return false; }

◆ IsDragging()

bool EDA_ITEM::IsDragging ( ) const
inlineinherited

Definition at line 120 of file eda_item.h.

120 { return m_flags & IS_DRAGGING; }
#define IS_DRAGGING
Item being dragged.
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480

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

123 { return m_flags & ENTERED; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480
#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 205 of file eda_item.h.

205 { return m_forceVisible; }
bool m_forceVisible
Definition: eda_item.h:479

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.

Definition at line 252 of file sch_item.h.

252 { return false; }

◆ IsInNetlist()

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

Definition at line 1870 of file sch_symbol.cpp.

1871 {
1872  return m_isInNetlist;
1873 }
bool m_isInNetlist
True if the symbol should appear in the netlist.
Definition: sch_symbol.h:706

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 242 of file sch_item.h.

242 { return false; }

◆ IsModified()

bool EDA_ITEM::IsModified ( ) const
inlineinherited

Definition at line 117 of file eda_item.h.

117 { return m_flags & IS_CHANGED; }
#define IS_CHANGED
Item was edited, and modified.
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480

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

241 {
242  // If a symbol's anchor is not grid-aligned to its pins then moving from the anchor is
243  // going to end up moving the symbol's pins off-grid.
244 
245  // The minimal grid size allowed to place a pin is 25 mils
246  const int min_grid_size = Mils2iu( 25 );
247 
248  for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
249  {
250  if( ( ( pin->GetPosition().x - m_pos.x ) % min_grid_size ) != 0 )
251  return false;
252 
253  if( ( ( pin->GetPosition().y - m_pos.y ) % min_grid_size ) != 0 )
254  return false;
255  }
256 
257  return true;
258 }
std::vector< std::unique_ptr< SCH_PIN > > m_pins
a SCH_PIN for every LIB_PIN (all units)
Definition: sch_symbol.h:703
wxPoint m_pos
Definition: sch_symbol.h:678

References m_pins, m_pos, and pin.

◆ IsMoving()

◆ IsNew()

◆ IsPointClickableAnchor()

bool SCH_SYMBOL::IsPointClickableAnchor ( const wxPoint &  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 1912 of file sch_symbol.cpp.

1913 {
1914  for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
1915  {
1916  int pin_unit = pin->GetLibPin()->GetUnit();
1917  int pin_convert = pin->GetLibPin()->GetConvert();
1918 
1919  if( pin_unit > 0 && pin_unit != GetUnit() )
1920  continue;
1921 
1922  if( pin_convert > 0 && pin_convert != GetConvert() )
1923  continue;
1924 
1925  if( pin->IsPointClickableAnchor( aPos ) )
1926  return true;
1927  }
1928 
1929  return false;
1930 }
std::vector< std::unique_ptr< SCH_PIN > > m_pins
a SCH_PIN for every LIB_PIN (all units)
Definition: sch_symbol.h:703
int GetUnit() const
Definition: sch_symbol.h:196
int GetConvert() const
Definition: sch_symbol.h:224

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

499 {
500  return !UTIL::GetRefDesPrefix( aReferenceString ).IsEmpty();
501 }
wxString GetRefDesPrefix(const wxString &aRefDes)
Get the (non-numeric) prefix from a refdes - e.g.

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

643 { return true; }

◆ IsResized()

bool EDA_ITEM::IsResized ( ) const
inlineinherited

Definition at line 124 of file eda_item.h.

124 { return m_flags & IS_RESIZING; }
#define IS_RESIZING
Item being resized.
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480

References IS_RESIZING, and EDA_ITEM::m_flags.

◆ IsSelected()

bool EDA_ITEM::IsSelected ( ) const
inlineinherited

Definition at line 122 of file eda_item.h.

122 { return m_flags & SELECTED; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480
#define 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_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::DS_RENDER_SETTINGS::GetColor(), KIGFX::GERBVIEW_RENDER_SETTINGS::GetColor(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), SCH_MOVE_TOOL::getConnectedDragItems(), KIGFX::SCH_PAINTER::getLineWidth(), KIGFX::SCH_PAINTER::getRenderColor(), KIGFX::SCH_PAINTER::getTextThickness(), DIALOG_EXCHANGE_FOOTPRINTS::isMatch(), DIALOG_CHANGE_SYMBOLS::isMatch(), SCH_LINE::MergeOverlap(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::processItem(), BOARD_COMMIT::Push(), PCB_SELECTION_TOOL::RebuildSelection(), EE_SELECTION_TOOL::RebuildSelection(), RENDER_3D_OPENGL::renderFootprint(), SCH_EDIT_TOOL::Rotate(), EE_TOOL_BASE< SCH_BASE_FRAME >::saveCopyInUndoList(), SCH_EDIT_FRAME::SchematicCleanUp(), GERBVIEW_SELECTION_TOOL::select(), PCB_SELECTION_TOOL::select(), PCB_SELECTION_TOOL::selectionContains(), PCB_SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), KIGFX::SCH_PAINTER::setDeviceColors(), GERBVIEW_SELECTION_TOOL::unselect(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::visitItem(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ IsType()

virtual bool EDA_ITEM::IsType ( const KICAD_T  aScanTypes[]) const
inlinevirtualinherited

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 in PCB_VIA, SCH_LABEL, PCB_DIMENSION_BASE, PAD, SCH_FIELD, FP_TEXT, SCH_LINE, PCB_SHAPE, FP_SHAPE, and PCB_TEXT.

Definition at line 182 of file eda_item.h.

183  {
184  if( aScanTypes[0] == SCH_LOCATE_ANY_T )
185  return true;
186 
187  for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
188  {
189  if( m_structType == *p )
190  return true;
191  }
192 
193  return false;
194  }
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
KICAD_T m_structType
Run time identification, keep private so it can never be changed after a ctor sets it.
Definition: eda_item.h:487

References EOT, EDA_ITEM::m_structType, and SCH_LOCATE_ANY_T.

Referenced by SCH_EDIT_TOOL::AutoplaceFields(), ROUTER_TOOL::CanInlineDrag(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingBus(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingLine(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingWire(), PCB_TEXT::IsType(), FP_SHAPE::IsType(), PCB_SHAPE::IsType(), SCH_LINE::IsType(), FP_TEXT::IsType(), SCH_FIELD::IsType(), PAD::IsType(), PCB_DIMENSION_BASE::IsType(), SCH_LABEL::IsType(), PCB_VIA::IsType(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), EE_SELECTION_TOOL::RequestSelection(), SCH_BASE_FRAME::UpdateItem(), EDA_ITEM::Visit(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ IsWireImage()

bool EDA_ITEM::IsWireImage ( ) const
inlineinherited

Definition at line 121 of file eda_item.h.

121 { return m_flags & IS_WIRE_IMAGE; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.

References IS_WIRE_IMAGE, and EDA_ITEM::m_flags.

◆ IterateForward() [1/2]

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

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

Definition at line 294 of file eda_item.h.

298  {
299  for( auto it : aList )
300  {
301  if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
303  return SEARCH_RESULT::QUIT;
304  }
305 
307  }
virtual SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
May be re-implemented for each derived class in order to handle all the types given by its member dat...
Definition: eda_item.cpp:93

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

Referenced by GERBER_FILE_IMAGE::Visit().

◆ IterateForward() [2/2]

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

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

Definition at line 313 of file eda_item.h.

315  {
316  for( auto it : aList )
317  {
318  if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
320  return SEARCH_RESULT::QUIT;
321  }
322 
324  }
virtual SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
May be re-implemented for each derived class in order to handle all the types given by its member dat...
Definition: eda_item.cpp:93

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

◆ Matches() [1/2]

bool EDA_ITEM::Matches ( const wxString &  aText,
const wxFindReplaceData &  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 118 of file eda_item.cpp.

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

References FR_MATCH_WILDCARD, FR_SEARCH_REPLACE, EDA_ITEM::IsReplaceable(), next(), and text.

◆ Matches() [2/2]

bool SCH_SYMBOL::Matches ( const wxFindReplaceData &  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 1531 of file sch_symbol.cpp.

1532 {
1533  wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText( EDA_UNITS::MILLIMETRES ) );
1534 
1535  // Symbols are searchable via the child field and pin item text.
1536  return false;
1537 }
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
const wxChar *const traceFindItem
Flag to enable find debug tracing.

References GetSelectMenuText(), MILLIMETRES, and traceFindItem.

◆ MirrorHorizontally()

void SCH_SYMBOL::MirrorHorizontally ( int  aCenter)
overridevirtual

Mirror item horizontally about aCenter.

Implements SCH_ITEM.

Definition at line 1476 of file sch_symbol.cpp.

1477 {
1478  int dx = m_pos.x;
1479 
1481  MIRROR( m_pos.x, aCenter );
1482  dx -= m_pos.x; // dx,0 is the move vector for this transform
1483 
1484  for( SCH_FIELD& field : m_fields )
1485  {
1486  // Move the fields to the new position because the symbol itself has moved.
1487  wxPoint pos = field.GetTextPos();
1488  pos.x -= dx;
1489  field.SetTextPos( pos );
1490  }
1491 }
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
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
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699
wxPoint m_pos
Definition: sch_symbol.h:678

References m_fields, m_pos, MIRROR(), SetOrientation(), and SYM_MIRROR_Y.

◆ MirrorVertically()

void SCH_SYMBOL::MirrorVertically ( int  aCenter)
overridevirtual

Mirror item vertically about aCenter.

Implements SCH_ITEM.

Definition at line 1494 of file sch_symbol.cpp.

1495 {
1496  int dy = m_pos.y;
1497 
1499  MIRROR( m_pos.y, aCenter );
1500  dy -= m_pos.y; // 0,dy is the move vector for this transform
1501 
1502  for( SCH_FIELD& field : m_fields )
1503  {
1504  // Move the fields to the new position because the symbol itself has moved.
1505  wxPoint pos = field.GetTextPos();
1506  pos.y -= dy;
1507  field.SetTextPos( pos );
1508  }
1509 }
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
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
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699
wxPoint m_pos
Definition: sch_symbol.h:678

References m_fields, m_pos, MIRROR(), SetOrientation(), and SYM_MIRROR_X.

◆ Move()

void SCH_SYMBOL::Move ( const wxPoint &  aMoveVector)
inlineoverridevirtual

Move the item by aMoveVector to a new position.

Implements SCH_ITEM.

Definition at line 565 of file sch_symbol.h.

566  {
567  if( aMoveVector == wxPoint( 0, 0 ) )
568  return;
569 
570  m_pos += aMoveVector;
571 
572  for( SCH_FIELD& field : m_fields )
573  field.Move( aMoveVector );
574 
575  SetModified();
576  }
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
void SetModified()
Definition: eda_item.cpp:65
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699
wxPoint m_pos
Definition: sch_symbol.h:678

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

Referenced by SetPosition().

◆ NetClass()

NETCLASSPTR SCH_ITEM::NetClass ( const SCH_SHEET_PATH aSheet = nullptr) const
inherited

Definition at line 158 of file sch_item.cpp.

159 {
160  if( m_connection_map.size() )
161  {
162  SCH_CONNECTION* connection = Connection( aSheet );
163 
164  if( connection )
165  {
166  NET_SETTINGS& netSettings = Schematic()->Prj().GetProjectFile().NetSettings();
167  const wxString& netclassName = netSettings.GetNetclassName( connection->Name() );
168 
169  return netSettings.m_NetClasses.Find( netclassName );
170  }
171  }
172 
173  return nullptr;
174 }
NETCLASSPTR Find(const wxString &aName) const
Search this container for a NETCLASS given by aName.
Definition: netclass.cpp:132
const wxString & GetNetclassName(const wxString &aNetName) const
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:145
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:104
NET_SETTINGS & NetSettings()
Definition: project_file.h:96
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:138
NETCLASSES m_NetClasses
Definition: net_settings.h:40
wxString Name(bool aIgnoreSheet=false) const
NET_SETTINGS stores various net-related settings in a project context.
Definition: net_settings.h:32
std::unordered_map< SCH_SHEET_PATH, SCH_CONNECTION * > m_connection_map
Store connectivity information, per sheet.
Definition: sch_item.h:497
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).

References SCH_ITEM::Connection(), NETCLASSES::Find(), NET_SETTINGS::GetNetclassName(), PROJECT::GetProjectFile(), SCH_ITEM::m_connection_map, NET_SETTINGS::m_NetClasses, SCH_CONNECTION::Name(), PROJECT_FILE::NetSettings(), SCHEMATIC::Prj(), and SCH_ITEM::Schematic().

Referenced by SCH_LINE::GetEffectiveLineStyle(), SCH_JUNCTION::getEffectiveShape(), SCH_JUNCTION::GetJunctionColor(), SCH_LINE::GetLineColor(), SCH_BUS_WIRE_ENTRY::GetPenWidth(), SCH_LINE::GetPenWidth(), SCH_BUS_BUS_ENTRY::GetPenWidth(), SCH_BUS_ENTRY_BASE::GetStrokeColor(), and SCH_BUS_ENTRY_BASE::GetStrokeStyle().

◆ operator!=()

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

Definition at line 1771 of file sch_symbol.cpp.

1772 {
1773  return !( *this == aSymbol );
1774 }

◆ 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 234 of file eda_item.cpp.

235 {
236  wxFAIL_MSG( wxString::Format( wxT( "Less than operator not defined for item type %s." ),
237  GetClass() ) );
238 
239  return false;
240 }
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
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 1734 of file sch_symbol.cpp.

1735 {
1736  if( Type() != aItem.Type() )
1737  return Type() < aItem.Type();
1738 
1739  auto symbol = static_cast<const SCH_SYMBOL*>( &aItem );
1740 
1742 
1743  if( rect.GetArea() != symbol->GetBodyAndPinsBoundingBox().GetArea() )
1744  return rect.GetArea() < symbol->GetBodyAndPinsBoundingBox().GetArea();
1745 
1746  if( m_pos.x != symbol->m_pos.x )
1747  return m_pos.x < symbol->m_pos.x;
1748 
1749  if( m_pos.y != symbol->m_pos.y )
1750  return m_pos.y < symbol->m_pos.y;
1751 
1752  return m_Uuid < aItem.m_Uuid; // Ensure deterministic sort
1753 }
EDA_RECT GetBodyAndPinsBoundingBox() const
Return a bounding box for the symbol body and pins but not the fields.
wxPoint m_pos
Definition: sch_symbol.h:678
double GetArea() const
Return the area of the rectangle.
Definition: eda_rect.cpp:483
const KIID m_Uuid
Definition: eda_item.h:474
Handle the component boundary box.
Definition: eda_rect.h:42
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References EDA_RECT::GetArea(), GetBodyAndPinsBoundingBox(), m_pos, EDA_ITEM::m_Uuid, and EDA_ITEM::Type().

◆ operator=()

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

Definition at line 1777 of file sch_symbol.cpp.

1778 {
1779  wxCHECK_MSG( Type() == aItem.Type(), *this,
1780  wxT( "Cannot assign object type " ) + aItem.GetClass() + wxT( " to type " ) +
1781  GetClass() );
1782 
1783  if( &aItem != this )
1784  {
1785  SCH_ITEM::operator=( aItem );
1786 
1787  SCH_SYMBOL* c = (SCH_SYMBOL*) &aItem;
1788 
1789  m_lib_id = c->m_lib_id;
1790 
1791  LIB_SYMBOL* libSymbol = c->m_part ? new LIB_SYMBOL( *c->m_part.get() ) : nullptr;
1792 
1793  m_part.reset( libSymbol );
1794  m_pos = c->m_pos;
1795  m_unit = c->m_unit;
1796  m_convert = c->m_convert;
1797  m_transform = c->m_transform;
1798 
1800 
1801  m_fields = c->m_fields; // std::vector's assignment operator
1802 
1803  // Reparent fields after assignment to new symbol.
1804  for( SCH_FIELD& field : m_fields )
1805  field.SetParent( this );
1806 
1807  UpdatePins();
1808  }
1809 
1810  return *this;
1811 }
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
Define a library symbol object.
Definition: lib_symbol.h:96
int m_unit
The unit for multiple part per package symbols.
Definition: sch_symbol.h:680
int m_convert
The alternate body style for symbols that have more than one body style defined.
Definition: sch_symbol.h:681
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
Definition: sch_symbol.cpp:307
wxPoint m_pos
Definition: sch_symbol.h:678
std::unique_ptr< LIB_SYMBOL > m_part
a flattened copy of the LIB_SYMBOL from the PROJECT's libraries.
Definition: sch_symbol.h:701
wxString GetClass() const override
Return the class name.
Definition: sch_symbol.h:118
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
Definition: sch_symbol.h:679
Schematic symbol object.
Definition: sch_symbol.h:78
TRANSFORM m_transform
The rotation/mirror transformation.
Definition: sch_symbol.h:698
virtual wxString GetClass() const override
Return the class name.
Definition: sch_item.h:193
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
Definition: sch_symbol.h:712
SCH_ITEM & operator=(const SCH_ITEM &aPin)
Definition: sch_item.cpp:62
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

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

◆ operator==()

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

Definition at line 1756 of file sch_symbol.cpp.

1757 {
1758  if( GetFieldCount() != aSymbol.GetFieldCount() )
1759  return false;
1760 
1761  for( int i = VALUE_FIELD; i < GetFieldCount(); i++ )
1762  {
1763  if( GetFields()[i].GetText().Cmp( aSymbol.GetFields()[i].GetText() ) != 0 )
1764  return false;
1765  }
1766 
1767  return true;
1768 }
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:741
Field Value of part, i.e. "3.3K".
int GetFieldCount() const
Return the number of fields in this symbol.
Definition: sch_symbol.h:425
std::vector< SCH_FIELD > & GetFields()
Return a vector of fields from the symbol.
Definition: sch_symbol.h:370

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

◆ Plot()

void SCH_SYMBOL::Plot ( PLOTTER aPlotter) const
overridevirtual

Plot the schematic item to aPlotter.

Parameters
aPlotteris the PLOTTER object to plot to.

Reimplemented from SCH_ITEM.

Definition at line 1876 of file sch_symbol.cpp.

1877 {
1878  if( m_part )
1879  {
1880  TRANSFORM temp = GetTransform();
1881  aPlotter->StartBlock( nullptr );
1882 
1883  m_part->Plot( aPlotter, GetUnit(), GetConvert(), m_pos, temp );
1884 
1885  for( SCH_FIELD field : m_fields )
1886  field.Plot( aPlotter );
1887 
1888  aPlotter->EndBlock( nullptr );
1889  }
1890 }
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
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:496
virtual void StartBlock(void *aData)
calling this function allows one to define the beginning of a group of drawing items,...
Definition: plotter.h:487
TRANSFORM & GetTransform()
Definition: sch_symbol.h:232
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699
wxPoint m_pos
Definition: sch_symbol.h:678
std::unique_ptr< LIB_SYMBOL > m_part
a flattened copy of the LIB_SYMBOL from the PROJECT's libraries.
Definition: sch_symbol.h:701
int GetUnit() const
Definition: sch_symbol.h:196
int GetConvert() const
Definition: sch_symbol.h:224

References PLOTTER::EndBlock(), GetConvert(), GetTransform(), GetUnit(), m_fields, m_part, m_pos, and PLOTTER::StartBlock().

◆ Print()

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

Print a symbol.

Parameters
aDCis the device context (can be null).
aOffsetis the drawing offset (usually wxPoint(0,0), but can be different when moving an object)

Implements SCH_ITEM.

Definition at line 402 of file sch_symbol.cpp.

403 {
404  LIB_SYMBOL_OPTIONS opts;
405  opts.transform = m_transform;
406  opts.draw_visible_fields = false;
407  opts.draw_hidden_fields = false;
408 
409  if( m_part )
410  {
411  m_part->Print( aSettings, m_pos + aOffset, m_unit, m_convert, opts );
412  }
413  else // Use dummy() part if the actual cannot be found.
414  {
415  dummy()->Print( aSettings, m_pos + aOffset, 0, 0, opts );
416  }
417 
418  for( SCH_FIELD& field : m_fields )
419  field.Print( aSettings, aOffset );
420 }
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
bool draw_visible_fields
Definition: lib_symbol.h:65
int m_unit
The unit for multiple part per package symbols.
Definition: sch_symbol.h:680
TRANSFORM transform
Definition: lib_symbol.h:64
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
int m_convert
The alternate body style for symbols that have more than one body style defined.
Definition: sch_symbol.h:681
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699
wxPoint m_pos
Definition: sch_symbol.h:678
std::unique_ptr< LIB_SYMBOL > m_part
a flattened copy of the LIB_SYMBOL from the PROJECT's libraries.
Definition: sch_symbol.h:701
void Print(const RENDER_SETTINGS *aSettings, const wxPoint &aOffset, int aMulti, int aConvert, const LIB_SYMBOL_OPTIONS &aOpts)
Print symbol.
Definition: lib_symbol.cpp:527
TRANSFORM m_transform
The rotation/mirror transformation.
Definition: sch_symbol.h:698

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

761 {
762  for( unsigned i = MANDATORY_FIELDS; i < m_fields.size(); ++i )
763  {
764  if( aFieldName == m_fields[i].GetName( false ) )
765  {
766  m_fields.erase( m_fields.begin() + i );
767  return;
768  }
769  }
770 }
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699
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(), and DIALOG_CHANGE_SYMBOLS::processSymbol().

◆ Replace() [1/2]

bool EDA_ITEM::Replace ( const wxFindReplaceData &  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 170 of file eda_item.cpp.

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

References next(), and text.

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

◆ Replace() [2/2]

virtual bool EDA_ITEM::Replace ( const wxFindReplaceData &  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 SCH_TEXT, SCH_FIELD, SCH_SHEET_PIN, and SCH_PIN.

Definition at line 391 of file eda_item.h.

392  {
393  return false;
394  }

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

1109 {
1110  auto it = std::find_if( m_instanceReferences.begin(), m_instanceReferences.end(),
1111  [ aOldSheetPath ]( SYMBOL_INSTANCE_REFERENCE& r )->bool
1112  {
1113  return aOldSheetPath == r.m_Path;
1114  }
1115  );
1116 
1117  if( it != m_instanceReferences.end() )
1118  {
1119  wxLogTrace( traceSchSheetPaths,
1120  wxT( "Replacing sheet path %s\n with sheet path %s\n for symbol %s." ),
1121  aOldSheetPath.AsString(), aNewSheetPath.AsString(), m_Uuid.AsString() );
1122 
1123  it->m_Path = aNewSheetPath;
1124  return true;
1125  }
1126 
1127  wxLogTrace( traceSchSheetPaths,
1128  wxT( "Could not find sheet path %s\n to replace with sheet path %s\n for symbol %s." ),
1129  aOldSheetPath.AsString(), aNewSheetPath.AsString(), m_Uuid.AsString() );
1130 
1131  return false;
1132 }
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
wxString AsString() const
Definition: kiid.cpp:236
A simple container for schematic symbol instance information.
E_SERIE r
Definition: eserie.cpp:41
const KIID m_Uuid
Definition: eda_item.h:474
wxString AsString() const
Definition: kiid.cpp:316
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
Definition: sch_symbol.h:712

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

973 {
974  SCHEMATIC* schematic = Schematic();
975 
976  // SCH_SYMOL object has no context outside a schematic.
977  wxCHECK( schematic, false );
978 
979  for( int i = 0; i < MANDATORY_FIELDS; ++i )
980  {
981  if( token->IsSameAs( m_fields[ i ].GetCanonicalName().Upper() ) )
982  {
983  if( i == REFERENCE_FIELD )
984  *token = GetRef( &schematic->CurrentSheet(), true );
985  else if( i == VALUE_FIELD )
986  *token = GetValue( &schematic->CurrentSheet(), true );
987  else if( i == FOOTPRINT_FIELD )
988  *token = GetFootprint( &schematic->CurrentSheet(), true );
989  else
990  *token = m_fields[ i ].GetShownText( aDepth + 1 );
991 
992  return true;
993  }
994  }
995 
996  for( size_t i = MANDATORY_FIELDS; i < m_fields.size(); ++i )
997  {
998  if( token->IsSameAs( m_fields[ i ].GetName() )
999  || token->IsSameAs( m_fields[ i ].GetName().Upper() ) )
1000  {
1001  *token = m_fields[ i ].GetShownText( aDepth + 1 );
1002  return true;
1003  }
1004  }
1005 
1006  for( const TEMPLATE_FIELDNAME& templateFieldname :
1008  {
1009  if( token->IsSameAs( templateFieldname.m_Name )
1010  || token->IsSameAs( templateFieldname.m_Name.Upper() ) )
1011  {
1012  // If we didn't find it in the fields list then it isn't set on this symbol.
1013  // Just return an empty string.
1014  *token = wxEmptyString;
1015  return true;
1016  }
1017  }
1018 
1019  if( token->IsSameAs( wxT( "FOOTPRINT_LIBRARY" ) ) )
1020  {
1021  wxString footprint;
1022 
1023  footprint = GetFootprint( &schematic->CurrentSheet(), true );
1024 
1025  wxArrayString parts = wxSplit( footprint, ':' );
1026 
1027  *token = parts[ 0 ];
1028  return true;
1029  }
1030  else if( token->IsSameAs( wxT( "FOOTPRINT_NAME" ) ) )
1031  {
1032  wxString footprint;
1033 
1034  footprint = GetFootprint( &schematic->CurrentSheet(), true );
1035 
1036  wxArrayString parts = wxSplit( footprint, ':' );
1037 
1038  *token = parts[ std::min( 1, (int) parts.size() - 1 ) ];
1039  return true;
1040  }
1041  else if( token->IsSameAs( wxT( "UNIT" ) ) )
1042  {
1043  int unit;
1044 
1045  unit = GetUnitSelection( &schematic->CurrentSheet() );
1046 
1047  *token = LIB_SYMBOL::SubReference( unit );
1048  return true;
1049  }
1050 
1051  return false;
1052 }
Field Reference of part, i.e. "IC21".
Holds all the data relating to one schematic.
Definition: schematic.h:59
SCHEMATIC_SETTINGS & Settings() const
Definition: schematic.cpp:167
TEMPLATES m_TemplateFieldNames
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:104
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Definition: lib_symbol.cpp:495
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:464
Field Value of part, i.e. "3.3K".
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
Definition: sch_symbol.cpp:554
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:596
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
Hold a name of a symbol's field, field value, and default visibility.
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:654
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:121
const TEMPLATE_FIELDNAMES & GetTemplateFieldNames()
Return a template field name list for read only access.
Field Name Module PCB, i.e. "16DIP300".

References SCHEMATIC::CurrentSheet(), FOOTPRINT_FIELD, GetFootprint(), GetRef(), TEMPLATES::GetTemplateFieldNames(), GetUnitSelection(), GetValue(), m_fields, 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 wxPoint &  aCenter)
overridevirtual

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

Implements SCH_ITEM.

Definition at line 1512 of file sch_symbol.cpp.

1513 {
1514  wxPoint prev = m_pos;
1515 
1516  RotatePoint( &m_pos, aCenter, 900 );
1517 
1519 
1520  for( SCH_FIELD& field : m_fields )
1521  {
1522  // Move the fields to the new position because the symbol itself has moved.
1523  wxPoint pos = field.GetTextPos();
1524  pos.x -= prev.x - m_pos.x;
1525  pos.y -= prev.y - m_pos.y;
1526  field.SetTextPos( pos );
1527  }
1528 }
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699
wxPoint m_pos
Definition: sch_symbol.h:678

References m_fields, m_pos, RotatePoint(), SetOrientation(), and SYM_ROTATE_COUNTERCLOCKWISE.

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

861 {
862  for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
863  aFunction( pin.get() );
864 
865  for( SCH_FIELD& field : m_fields )
866  aFunction( &field );
867 }
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
std::vector< std::unique_ptr< SCH_PIN > > m_pins
a SCH_PIN for every LIB_PIN (all units)
Definition: sch_symbol.h:703
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699

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 104 of file sch_item.cpp.

105 {
106  EDA_ITEM* parent = GetParent();
107 
108  while( parent )
109  {
110  if( parent->Type() == SCHEMATIC_T )
111  return static_cast<SCHEMATIC*>( parent );
112  else
113  parent = parent->GetParent();
114  }
115 
116  return nullptr;
117 }
EDA_ITEM * GetParent() const
Definition: eda_item.h:114
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

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

Referenced by SCH_ITEM::Connection(), SCH_DRAWING_TOOLS::createSheetPin(), DIALOG_SCH_FIELD_PROPERTIES::DIALOG_SCH_FIELD_PROPERTIES(), SCH_FIELD::DoHypertextMenu(), SCH_GLOBALLABEL::GetBoundingBox(), SCH_MARKER::GetColorLayer(), SCH_JUNCTION::getEffectiveShape(), SCH_TEXT::GetLabelBoxExpansion(), SCH_BUS_ENTRY_BASE::GetMsgPanelInfo(), SCH_LINE::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), SCH_NO_CONNECT::GetPenWidth(), SCH_SHEET_PIN::GetPenWidth(), SCH_LINE::GetPenWidth(), SCH_SHEET::GetPenWidth(), GetPins(), SCH_FIELD::GetShownText(), SCH_TEXT::GetShownText(), SCH_TEXT::GetTextOffset(), SCH_PIN::HitTest(), SCH_GLOBALLABEL::HitTest(), inheritNetclass(), SCH_SHEET::IsRootSheet(), SCH_LABEL::IsType(), SCH_ITEM::NetClass(), DIALOG_SYMBOL_PROPERTIES::OnAddField(), DIALOG_TEXT_AND_LABEL_PROPERTIES::onScintillaCharAdded(), DIALOG_SCH_FIELD_PROPERTIES::onScintillaCharAdded(), SCH_GLOBALLABEL::Plot(), SCH_GLOBALLABEL::Print(), SCH_HIERLABEL::Print(), SCH_SHEET::ResolveTextVar(), ResolveTextVar(), SCH_GLOBALLABEL::ResolveTextVar(), DIALOG_SCH_FIELD_PROPERTIES::UpdateField(), and SCH_MARKER::ViewGetLayers().

◆ Set() [1/3]

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

Definition at line 42 of file inspectable.h.

43  {
45  TYPE_ID thisType = TYPE_HASH( *this );
46  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
47 
48  if( object )
49  aProperty->setter( object, aValue );
50 
51  return object != nullptr;
52  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:65
#define TYPE_HASH(x)
Definition: property.h:59
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:42
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.
virtual void setter(void *aObject, wxAny &aValue)=0
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:62
virtual size_t OwnerHash() const =0
Return type-id of the Owner class.

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

◆ Set() [2/3]

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

Definition at line 55 of file inspectable.h.

56  {
58  TYPE_ID thisType = TYPE_HASH( *this );
59  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
60 
61  if( object )
62  aProperty->set<T>( object, aValue );
63 
64  return object != nullptr;
65  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:65
#define TYPE_HASH(x)
Definition: property.h:59
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:42
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:62
void set(void *aObject, T aValue)
Definition: property.h:261
virtual size_t OwnerHash() const =0
Return type-id of the Owner class.

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

◆ Set() [3/3]

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

Definition at line 68 of file inspectable.h.

69  {
71  TYPE_ID thisType = TYPE_HASH( *this );
72  PROPERTY_BASE* prop = propMgr.GetProperty( thisType, aProperty );
73  void* object = nullptr;
74 
75  if( prop )
76  {
77  object = propMgr.TypeCast( this, thisType, prop->OwnerHash() );
78 
79  if( object )
80  prop->set<T>( object, aValue );
81  }
82 
83  return object != nullptr;
84  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:65
#define TYPE_HASH(x)
Definition: property.h:59
size_t TYPE_ID
Unique type identifier.
Definition: property_mgr.h:42
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Cast a type to another type.
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Return a property for a specific type.
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:62
void set(void *aObject, T aValue)
Definition: property.h:261
virtual size_t OwnerHash() const =0
Return type-id of the Owner class.

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

◆ SetBrightened()

◆ SetConnectivityDirty()

void SCH_ITEM::SetConnectivityDirty ( bool  aDirty = true)
inlineinherited

◆ SetConvert()

void SCH_SYMBOL::SetConvert ( int  aConvert)

Definition at line 370 of file sch_symbol.cpp.

371 {
372  if( m_convert != aConvert )
373  {
374  m_convert = aConvert;
375 
376  // The convert may have a different pin layout so the update the pin map.
377  UpdatePins();
378  SetModified();
379  }
380 }
void SetModified()
Definition: eda_item.cpp:65
int m_convert
The alternate body style for symbols that have more than one body style defined.
Definition: sch_symbol.h:681
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
Definition: sch_symbol.cpp:307

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

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

405  {
406  m_fields = aFields; // vector copying, length is changed possibly
407  }
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699

References m_fields.

◆ SetFieldsAutoplaced()

void SCH_ITEM::SetFieldsAutoplaced ( )
inlineinherited

Definition at line 426 of file sch_item.h.

References FIELDS_AUTOPLACED_AUTO, and SCH_ITEM::m_fieldsAutoplaced.

◆ SetFlags()

void EDA_ITEM::SetFlags ( EDA_ITEM_FLAGS  aMask)
inlineinherited

Definition at line 152 of file eda_item.h.

152 { m_flags |= aMask; }
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:480

References EDA_ITEM::m_flags.

Referenced by SCH_EAGLE_PLUGIN::addBusEntries(), PCB_BASE_FRAME::AddFootprintToBoard(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), SCH_MOVE_TOOL::AlignElements(), PCB_CONTROL::AppendBoard(), FOOTPRINT::BuildPolyCourtyards(), 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(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), EDIT_TOOL::DragArcTrack(), KIGFX::SCH_PAINTER::draw(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), PCB_SELECTION_TOOL::EnterGroup(), PCB_SELECTION_TOOL::FilterCollectorForHierarchy(), SCH_MOVE_TOOL::getConnectedDragItems(), SYMBOL_EDIT_FRAME::GetSymbolFromRedoList(), SYMBOL_EDIT_FRAME::GetSymbolFromUndoList(), EE_SELECTION_TOOL::Main(), TRACKS_CLEANER::mergeCollinearSegments(), SYMBOL_EDITOR_MOVE_TOOL::moveItem(), SCH_MOVE_TOOL::moveItem(), EE_SELECTION_TOOL::narrowSelection(), KIGFX::ORIGIN_VIEWITEM::ORIGIN_VIEWITEM(), SCH_ALTIUM_PLUGIN::ParseBezier(), SCH_ALTIUM_PLUGIN::ParseBus(), SCH_ALTIUM_PLUGIN::ParseBusEntry(), 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::ParseWire(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PL_DRAWING_TOOLS::PlaceItem(), DRAWING_TOOL::PlaceText(), BACK_ANNOTATE::processNetNameChange(), SCH_EDIT_FRAME::PutDataInPreviousState(), PCB_SELECTION_TOOL::RebuildSelection(), FOOTPRINT::Remove(), BOARD::Remove(), SCH_EDIT_TOOL::RepeatDrawItem(), SCH_EDIT_TOOL::Rotate(), SYMBOL_EDIT_FRAME::SaveCopyInUndoList(), SCH_EDIT_FRAME::SelectUnit(), EDA_ITEM::SetBrightened(), 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_DIMENSION_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ SetFootprint() [1/2]

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

Definition at line 675 of file sch_symbol.cpp.

676 {
677  if( sheet == nullptr )
678  {
679  // Set all instances to new footprint value
681  instance.m_Footprint = aFootprint;
682 
683  m_fields[ FOOTPRINT_FIELD ].SetText( aFootprint );
684  return;
685  }
686 
687  KIID_PATH path = sheet->Path();
688 
689  // check to see if it is already there before inserting it
691  {
692  if( instance.m_Path == path )
693  {
694  instance.m_Footprint = aFootprint;
695  return;
696  }
697  }
698 
699  // didn't find it; better add it
701  wxEmptyString, aFootprint );
702 }
wxString m_prefix
C, R, U, Q etc - the first character(s) which typically indicate what the symbol is.
Definition: sch_symbol.h:684
wxString GetRefDesUnannotated(const wxString &aSource)
Return an unannotated refdes from either a prefix or an existing refdes.
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
int m_unit
The unit for multiple part per package symbols.
Definition: sch_symbol.h:680
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:699
A simple container for schematic symbol instance information.
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:423
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
Definition: sch_symbol.h:712
Field Name Module PCB, i.e. "16DIP300".

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

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

559  {
560  SetFootprint( nullptr, aFootprint );
561  }
void SetFootprint(const SCH_SHEET_PATH *sheet, const wxString &aFootprint)
Definition: sch_symbol.cpp:675

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

203 { m_forceVisible = aEnable; }
bool m_forceVisible
Definition: eda_item.h:479

References EDA_ITEM::m_forceVisible.

Referenced by SCH_EDITOR_CONTROL::UpdateFind().

◆ SetIncludeInBom()

void SCH_SYMBOL::SetIncludeInBom ( bool  aIncludeInBom)
inline

Definition at line 664 of file sch_symbol.h.

664 { m_inBom = aIncludeInBom; }
bool m_inBom
True to include in bill of materials export.
Definition: sch_symbol.h:707

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

667 { m_onBoard = aIncludeOnBoard; }
bool m_onBoard
True to include in netlist when updating board.
Definition: sch_symbol.h:708

References m_onBoard.

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

◆ SetLastResolvedState()

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

Reimplemented in SCH_LINE, SCH_JUNCTION, and SCH_BUS_ENTRY_BASE.

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)

Definition at line 261 of file sch_symbol.cpp.

262 {
263  if( m_lib_id != aLibId )
264  {
265  m_lib_id = aLibId;
266  SetModified();
267  }
268 }
void SetModified()
Definition: eda_item.cpp:65
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
Definition: sch_symbol.h:679

References m_lib_id, and EDA_ITEM::SetModified().

Referenced by SCH_SCREENS::ChangeSymbolLibNickname(), SCH_ALTIUM_PLUGIN::ParseComponent(), SCH_ALTIUM_PLUGIN::ParsePowerPort(), DIALOG_CHANGE_SYMBOLS::processSymbol(), and DIALOG_SYMBOL_REMAP::remapSymbolToLibTable().

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

281 {
282  wxCHECK2( ( aLibSymbol == nullptr ) || ( aLibSymbol->IsRoot() ), aLibSymbol = nullptr );
283 
284  m_part.reset( aLibSymbol );
285  UpdatePins();
286 }
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
Definition: sch_symbol.cpp:307
std::unique_ptr< LIB_SYMBOL > m_part
a flattened copy of the LIB_SYMBOL from the PROJECT's libraries.
Definition: sch_symbol.h:701
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
Definition: lib_symbol.h:171

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 247 of file sch_item.h.

247 {}

◆ SetModified()

void EDA_ITEM::SetModified ( )
inherited

Definition at line 65 of file eda_item.cpp.

66 {
68 
69  // If this a child object, then the parent modification state also needs to be set.
70  if( m_parent )
72 }
#define IS_CHANGED
Item was edited, and modified.
void SetModified()
Definition: eda_item.cpp:65
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:478
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:152

References IS_CHANGED, EDA_ITEM::m_parent, EDA_ITEM::SetFlags(), and EDA_ITEM::SetModified().

Referenced by SYMBOL_EDITOR_PIN_TOOL::EditPinProperties(), LEGACY_PLUGIN::loadZONE_CONTAINER(), SCH_LINE::Move(), Move(), SCH_LINE::MoveEnd(), SCH_LINE::MoveStart(), LIB_PIN::MoveTo(), PCB_EDIT_FRAME::OpenProjectFiles(), ALTIUM_PCB::Parse(), SCH_ALTIUM_PLUGIN::ParseFileHeader(), LIB_SYMBOL::RemoveDrawItem(), SetConvert(), SetLibId(), EDA_ITEM::SetModified(), LIB_FIELD::SetName(), SetTransform(), and SetUnit().

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

1136 {
1137  TRANSFORM temp = TRANSFORM();
1138  bool transform = false;
1139 
1140  switch( aOrientation )
1141  {
1142  case SYM_ORIENT_0:
1143  case SYM_NORMAL: // default transform matrix
1144  m_transform.x1 = 1;
1145  m_transform.y2 = -1;
1146  m_transform.x2 = m_transform.y1 = 0;
1147  break;
1148 
1149  case SYM_ROTATE_COUNTERCLOCKWISE: // Rotate + (incremental rotation)
1150  temp.x1 = temp.y2 = 0;
1151  temp.y1 = 1;
1152  temp.x2 = -1;
1153  transform = true;
1154  break;
1155 
1156  case SYM_ROTATE_CLOCKWISE: // Rotate - (incremental rotation)
1157  temp.x1 = temp.y2 = 0;
1158  temp.y1 = -1;
1159  temp.x2 = 1;
1160  transform = true;
1161  break;
1162 
1163  case SYM_MIRROR_Y: // Mirror Y (incremental rotation)
1164  temp.x1 = -1;
1165  temp.y2 = 1;
1166  temp.y1 = temp.x2 = 0;
1167  transform = true;
1168  break;
1169 
1170  case SYM_MIRROR_X: // Mirror X (incremental rotation)
1171  temp.x1 = 1;
1172  temp.y2 = -1;
1173  temp.y1 = temp.x2 = 0;
1174  transform = true;
1175  break;
1176 
1177  case SYM_ORIENT_90:
1180  break;
1181 
1182  case SYM_ORIENT_180:
1186  break;
1187 
1188  case SYM_ORIENT_270:
1191  break;
1192 
1193  case ( SYM_ORIENT_0 + SYM_MIRROR_X ):
1196  break;
1197 
1198  case ( SYM_ORIENT_0 + SYM_MIRROR_Y ):
1201  break;
1202 
1203  case ( SYM_ORIENT_90 + SYM_MIRROR_X ):
1206  break;
1207 
1208  case ( SYM_ORIENT_90 + SYM_MIRROR_Y ):
1211  break;
1212 
1213  case ( SYM_ORIENT_180 + SYM_MIRROR_X ):
1216  break;
1217 
1218  case ( SYM_ORIENT_180 + SYM_MIRROR_Y ):
1221  break;
1222 
1223  case ( SYM_ORIENT_270 + SYM_MIRROR_X ):
1226  break;
1227 
1228  case ( SYM_ORIENT_270 + SYM_MIRROR_Y ):
1231  break;
1232 
1233  default:
1234  transform = false;
1235  wxFAIL_MSG( wxT( "Invalid schematic symbol orientation type." ) );
1236  break;
1237  }
1238 
1239  if( transform )
1240  {
1241  /* The new matrix transform is the old matrix transform modified by the
1242  * requested transformation, which is the temp transform (rot,
1243  * mirror ..) in order to have (in term of matrix transform):
1244  * transform coord = new_m_transform * coord
1245  * where transform coord is the coord modified by new_m_transform from
1246  * the initial value coord.
1247  * new_m_transform is computed (from old_m_transform and temp) to
1248  * have:
1249  * transform coord = old_m_transform * temp
1250  */
1251  TRANSFORM newTransform;
1252 
1253  newTransform.x1 = m_transform.x1 * temp.x1 + m_transform.x2 * temp.y1;
1254  newTransform.y1 = m_transform.y1 * temp.x1 + m_transform.y2 * temp.y1;
1255  newTransform.x2 = m_transform.x1 * temp.x2 + m_transform.x2 * temp.y2;
1256  newTransform.y2 = m_transform.y1 * temp.x2 + m_transform.y2 * temp.y2;
1257  m_transform = newTransform;
1258  }
1259 }
int y2
Definition: transform.h:51
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
int x2
Definition: transform.h:50
int x1
Definition: transform.h:48
int y1
Definition: transform.h:49
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
TRANSFORM m_transform
The rotation/mirror transformation.
Definition: sch_symbol.h:698

References m_transform, 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(), and DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow().

◆ SetParent()

virtual void EDA_ITEM::SetParent ( EDA_ITEM aParent)
inlinevirtualinherited

Reimplemented in PCB_DIMENSION_BASE.

Definition at line 115 of file eda_item.h.

115 { m_parent = aParent; }
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:478

References EDA_ITEM::m_parent.

Referenced by FOOTPRINT::Add(), BOARD::Add(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), BOARD_NETLIST_UPDATER::addNewFootprint(), SCH_SHEET::AddPin(), PAD::AddPrimitive(), 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(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), 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(), FOOTPRINT::operator=(), LIB_SYMBOL::operator=(), PCB_PARSER::parseFOOTPRINT_unchecked(), SCH_SEXPR_PARSER::ParseSchematic(), SCH_SEXPR_PARSER::ParseSymbol(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PCB_CONTROL::Paste(), SCH_EDITOR_CONTROL::Paste(), pasteFootprintItemsToFootprintEditor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), BACK_ANNOTATE::processNetNameChange(), BOARD_COMMIT::Push(), SCH_SEXPR_PLUGIN_CACHE::removeSymbol(), SCH_LEGACY_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(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_LINE_WIRE_BUS_TOOL::startSegments(), SCH_SHEET::SwapData(), SCH_GLOBALLABEL::SwapData(), SwapData(), and SwapItemData().

◆ SetPosition()

void SCH_SYMBOL::SetPosition ( const wxPoint &  aPosition)
inlineoverridevirtual

Reimplemented from EDA_ITEM.

Definition at line 646 of file sch_symbol.h.

646 { Move( aPosition - m_pos ); }
wxPoint m_pos
Definition: sch_symbol.h:678
void Move(const wxPoint &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_symbol.h:565

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

230 { m_prefix = aPrefix; }
wxString m_prefix
C, R, U, Q etc - the first character(s) which typically indicate what the symbol is.
Definition: sch_symbol.h:684

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

505 {
506  KIID_PATH path = sheet->Path();
507  bool notInArray = true;
508 
509  // check to see if it is already there before inserting it
511  {
512  if( instance.m_Path == path )
513  {
514  instance.m_Reference = ref;
515  notInArray = false;
516  }
517  }
518 
519  if( notInArray )
521 
522  for( std::unique_ptr<SCH_PIN>& pin : m_pins )
523  pin->ClearDefaultNetName( sheet );
524 
526