KiCad PCB EDA Suite
SCH_COMPONENT Class Reference

Schematic symbol object. More...

#include <sch_component.h>

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

Public Member Functions

 SCH_COMPONENT (const wxPoint &pos=wxPoint(0, 0), SCH_ITEM *aParent=NULL)
 
 SCH_COMPONENT (LIB_PART &aPart, LIB_ID aLibId, SCH_SHEET_PATH *aSheet, int unit=0, int convert=0, const wxPoint &pos=wxPoint(0, 0))
 Create schematic component from library component object. More...
 
 SCH_COMPONENT (LIB_PART &aPart, SCH_SHEET_PATH *aSheet, PICKED_SYMBOL &aSel, const wxPoint &pos=wxPoint(0, 0))
 
 SCH_COMPONENT (const SCH_COMPONENT &aComponent)
 Clones aComponent into a new schematic symbol object. More...
 
 ~SCH_COMPONENT ()
 
wxString GetClass () const override
 Function GetClass returns the class name. More...
 
const std::vector< SYMBOL_INSTANCE_REFERENCE > & GetInstanceReferences ()
 
void ViewGetLayers (int aLayers[], int &aCount) const override
 Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on. More...
 
bool IsMovableFromAnchorPoint () 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_PART > & GetPartRef ()
 
void SetLibSymbol (LIB_PART *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
 
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 component. More...
 
void GetMsgPanelInfo (EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
 Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for display purposes. More...
 
void ClearAnnotation (const SCH_SHEET_PATH *aSheetPath)
 Clear exiting component 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
 Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes. More...
 
const EDA_RECT GetBoundingBox (bool aIncludeInvisibleText) const
 
EDA_RECT GetBodyBoundingBox () const
 Return a bounding box for the symbol body but not the fields. More...
 
SCH_FIELDGetField (int aFieldNdx)
 Returns a field in this symbol. More...
 
const SCH_FIELDGetField (int aFieldNdx) const
 
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)
 Populates a std::vector with SCH_FIELDs. More...
 
std::vector< SCH_FIELD > & GetFields ()
 Returns a vector of fields from the component. More...
 
SCH_FIELDAddField (const SCH_FIELD &aField)
 Add a field to the symbol. More...
 
void RemoveField (const wxString &aFieldName)
 Removes 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 (bool aResetStyle, bool aResetRef=false)
 Restores 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 component. More...
 
void RunOnChildren (const std::function< void(SCH_ITEM *)> &aFunction) override
 
SCH_PINGetPin (const wxString &number)
 Find a symbol pin by number. More...
 
void GetLibPins (std::vector< LIB_PIN * > &aPinsList)
 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
 Retrieves a list of the SCH_PINs for the given sheet path. More...
 
std::vector< std::unique_ptr< SCH_PIN > > & GetRawPins ()
 
void Print (RENDER_SETTINGS *aSettings, const wxPoint &aOffset) override
 Print a component. 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)
 Checks if the component 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
 
void SetUnitSelection (const SCH_SHEET_PATH *aSheet, int aUnitSelection)
 
const wxString GetValue (const SCH_SHEET_PATH *sheet, bool aResolve) const
 
void SetValue (const SCH_SHEET_PATH *sheet, const wxString &aValue)
 
void SetValue (const wxString &aValue)
 
const wxString GetFootprint (const SCH_SHEET_PATH *sheet, bool aResolve) const
 
void SetFootprint (const SCH_SHEET_PATH *sheet, const wxString &aFootprint)
 
void SetFootprint (const wxString &aFootprint)
 
void Move (const wxPoint &aMoveVector) override
 Move the item by aMoveVector to a new position. More...
 
void MirrorY (int aYaxis_position) override
 Mirror item relative to the Y axis about aYaxis_position. More...
 
void MirrorX (int aXaxis_position) override
 Mirror item relative to the X axis about aXaxis_position. More...
 
void Rotate (wxPoint aPosition) override
 Rotate the item around aPosition 90 degrees in the clockwise direction. More...
 
bool Matches (wxFindReplaceData &aSearchData, void *aAuxData) override
 Function Matches compares 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 component'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
 Function Visit 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 component library item at aPosition that is part of this component. More...
 
wxString GetSelectMenuText (EDA_UNITS aUnits) const override
 Function GetSelectMenuText returns the text to display to be used in the selection clarification context menu when multiple items are found at the current cursor position. More...
 
BITMAP_DEF GetMenuImage () const override
 Function GetMenuImage returns a pointer to an image to be used in menus. More...
 
bool operator< (const SCH_ITEM &aItem) const override
 
bool operator== (const SCH_COMPONENT &aComponent) const
 
bool operator!= (const SCH_COMPONENT &aComponent) const
 
SCH_COMPONENToperator= (const SCH_ITEM &aItem)
 
bool IsReplaceable () const override
 Function IsReplaceable. More...
 
wxPoint GetPosition () const override
 
void SetPosition (const wxPoint &aPosition) override
 
bool HitTest (const wxPoint &aPosition, int aAccuracy=0) const override
 Function HitTest tests if aPosition is contained within or on the bounding box of an item. More...
 
bool HitTest (const EDA_RECT &aRect, bool aContained, int aAccuracy=0) const override
 Function HitTest tests if aRect intersects or is contained within the bounding box of an item. More...
 
void Plot (PLOTTER *aPlotter) override
 Plot the schematic item to aPlotter. More...
 
EDA_ITEMClone () const override
 Function Clone creates 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)
 
SCH_ITEMDuplicate (bool doClone=false) const
 Routine to create a new copy of given item. More...
 
wxPoint & GetStoredPos ()
 
void SetStoredPos (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
 Allows 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
 
virtual bool IsPointClickableAnchor (const wxPoint &aPos) 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)
 Retrieves the set of items connected to this item on the given sheet. More...
 
void AddConnectionTo (const SCH_SHEET_PATH &aPath, SCH_ITEM *aItem)
 Adds a connection link between this item and another. More...
 
SCH_CONNECTIONInitializeConnection (const SCH_SHEET_PATH &aPath, CONNECTION_GRAPH *aGraph)
 Creates a new connection object associated with this object. More...
 
virtual bool ConnectionPropagatesTo (const EDA_ITEM *aItem) const
 Returns true if this item should propagate connection info to aItem. More...
 
bool IsConnectivityDirty ()
 
void SetConnectivityDirty (bool aDirty=true)
 
NETCLASSPTR NetClass (const SCH_SHEET_PATH *aSheet=nullptr) const
 
FIELDS_AUTOPLACED GetFieldsAutoplaced () const
 Return whether the fields have been automatically placed. More...
 
void ClearFieldsAutoplaced ()
 Set fields automatically placed flag false. More...
 
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
 Function Type() 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 IsResized () const
 
bool IsBrightened () const
 
void SetWireImage ()
 
void SetSelected ()
 
void SetBrightened ()
 
void ClearSelected ()
 
void ClearBrightened ()
 
void SetModified ()
 
int GetState (int type) const
 
void SetState (int type, int state)
 
STATUS_FLAGS GetStatus () const
 
void SetStatus (STATUS_FLAGS aStatus)
 
void SetFlags (STATUS_FLAGS aMask)
 
void ClearFlags (STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
 
STATUS_FLAGS GetFlags () const
 
bool HasFlag (STATUS_FLAGS aFlag)
 
STATUS_FLAGS GetEditFlags () const
 
void ClearTempFlags ()
 
void ClearEditFlags ()
 
virtual bool IsType (const KICAD_T aScanTypes[]) const
 Function IsType Checks whether the item is one of the listed types. More...
 
void SetForceVisible (bool aEnable)
 Function SetForceVisible is used to set and cleag 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
 Function GetFocusPosition similar to GetPosition, but allows items to return their visual center rather than their anchor. More...
 
virtual bool Replace (wxFindReplaceData &aSearchData, void *aAuxData=NULL)
 Function Replace performs 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
 Function ViewBBox() returns the bounding box of the item covering all its layers. More...
 
virtual void ViewDraw (int aLayer, VIEW *aView) const
 Function ViewDraw() Draws the parts of the object belonging to layer aLayer. More...
 
virtual double ViewGetLOD (int aLayer, VIEW *aView) const
 Function ViewGetLOD() Returns 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)
 Tests 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[])
 IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T ) More...
 
template<class T >
static SEARCH_RESULT IterateForward (std::vector< T > &aList, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
 IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T ) More...
 
static bool Replace (wxFindReplaceData &aSearchData, wxString &aText)
 Helper function used in search and replace dialog Function Replace performs 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)
 Function Sort is a 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, wxFindReplaceData &aSearchData)
 Function Matches compares 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
 Stores pointers to other items that are connected to this one, per sheet. More...
 
std::unordered_map< SCH_SHEET_PATH, SCH_CONNECTION * > m_connection_map
 Stores connectivity information, per sheet. More...
 
bool m_connectivity_dirty
 
STATUS_FLAGS m_status
 
EDA_ITEMm_parent
 Linked list: Link (parent struct) More...
 
bool m_forceVisible
 
STATUS_FLAGS m_flags
 

Private Member Functions

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

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 components. More...
 
int m_convert
 The alternate body style for components that have more than one body style defined. More...
 
wxString m_prefix
 C, R, U, Q etc - the first character which typically indicates what the component 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 matrix. More...
 
SCH_FIELDS m_fields
 Variable length list of fields. More...
 
std::unique_ptr< LIB_PARTm_part
 
std::vector< std::unique_ptr< SCH_PIN > > m_pins
 
std::unordered_map< LIB_PIN *, unsigned > m_pinMap
 
bool m_isInNetlist
 True if the component 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 79 of file sch_component.h.

Constructor & Destructor Documentation

◆ SCH_COMPONENT() [1/4]

SCH_COMPONENT::SCH_COMPONENT ( const wxPoint &  pos = wxPoint( 0, 0 ),
SCH_ITEM aParent = NULL 
)

Definition at line 95 of file sch_component.cpp.

95  :
96  SCH_ITEM( aParent, SCH_COMPONENT_T )
97 {
98  Init( aPos );
99 }
void Init(const wxPoint &pos=wxPoint(0, 0))
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType)
Definition: sch_item.cpp:47

References Init().

Referenced by Clone().

◆ SCH_COMPONENT() [2/4]

SCH_COMPONENT::SCH_COMPONENT ( LIB_PART aPart,
LIB_ID  aLibId,
SCH_SHEET_PATH aSheet,
int  unit = 0,
int  convert = 0,
const wxPoint &  pos = wxPoint( 0, 0 ) 
)

Create schematic component from library component object.

Parameters
aPart- library part to create schematic component from.
aLibId- libId of alias to create.
aSheet- Schematic sheet the component is place into.
unit- Part for components that have multiple parts per package.
convert- Use the alternate body style for the schematic component.
pos- Position to place new component.
setNewItemFlag- Set the component IS_NEW and IS_MOVED flags.

Definition at line 102 of file sch_component.cpp.

103  :
105 {
106  Init( pos );
107 
108  m_unit = unit;
109  m_convert = convert;
110  m_lib_id = aLibId;
111 
112  std::unique_ptr< LIB_PART > part;
113 
114  part = aPart.Flatten();
115  part->SetParent();
116  SetLibSymbol( part.release() );
117 
118  // Copy fields from the library component
119  UpdateFields( true, true );
120 
121  // Update the reference -- just the prefix for now.
122  if( sheet )
123  SetRef( sheet, m_part->GetReferenceField().GetText() + wxT( "?" ) );
124  else
125  m_prefix = m_part->GetReferenceField().GetText() + wxT( "?" );
126 
127  // Inherit the include in bill of materials and board netlist settings from library symbol.
128  m_inBom = aPart.GetIncludeInBom();
129  m_onBoard = aPart.GetIncludeOnBoard();
130 }
void UpdateFields(bool aResetStyle, bool aResetRef=false)
Restores fields to the original library values.
void SetLibSymbol(LIB_PART *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
bool m_onBoard
True to include in netlist when updating board.
#define NULL
std::unique_ptr< LIB_PART > m_part
std::unique_ptr< LIB_PART > Flatten() const
Return a flattened symbol inheritance to the caller.
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:84
void Init(const wxPoint &pos=wxPoint(0, 0))
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
Definition: sch_component.h:83
bool GetIncludeOnBoard() const
bool m_inBom
True to include in bill of materials export.
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:85
bool GetIncludeInBom() const
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is.
Definition: sch_component.h:88
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType)
Definition: sch_item.cpp:47

References LIB_PART::Flatten(), LIB_PART::GetIncludeInBom(), LIB_PART::GetIncludeOnBoard(), Init(), m_convert, m_inBom, m_lib_id, m_onBoard, m_part, m_prefix, m_unit, SetLibSymbol(), SetRef(), and UpdateFields().

◆ SCH_COMPONENT() [3/4]

SCH_COMPONENT::SCH_COMPONENT ( LIB_PART aPart,
SCH_SHEET_PATH aSheet,
PICKED_SYMBOL aSel,
const wxPoint &  pos = wxPoint( 0, 0 ) 
)

Definition at line 133 of file sch_component.cpp.

134  :
135  SCH_COMPONENT( aPart, aSel.LibId, aSheet, aSel.Unit, aSel.Convert, pos )
136 {
137  // Set any fields that were modified as part of the component selection
138  for( auto const& i : aSel.Fields )
139  {
140  auto field = this->GetField( i.first );
141 
142  if( field )
143  field->SetText( i.second );
144  }
145 }
SCH_COMPONENT(const wxPoint &pos=wxPoint(0, 0), SCH_ITEM *aParent=NULL)
SCH_FIELD * GetField(int aFieldNdx)
Returns a field in this symbol.
LIB_ID LibId
Definition: sch_screen.h:82
std::vector< std::pair< int, wxString > > Fields
Definition: sch_screen.h:86

References PICKED_SYMBOL::Fields, and GetField().

◆ SCH_COMPONENT() [4/4]

SCH_COMPONENT::SCH_COMPONENT ( const SCH_COMPONENT aComponent)

Clones aComponent 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
aComponentis the schematic symbol to clone.

Definition at line 148 of file sch_component.cpp.

148  :
149  SCH_ITEM( aComponent )
150 {
151  m_parent = aComponent.m_parent;
152  m_pos = aComponent.m_pos;
153  m_unit = aComponent.m_unit;
154  m_convert = aComponent.m_convert;
155  m_lib_id = aComponent.m_lib_id;
156  m_isInNetlist = aComponent.m_isInNetlist;
157  m_inBom = aComponent.m_inBom;
158  m_onBoard = aComponent.m_onBoard;
159 
160  if( aComponent.m_part )
161  SetLibSymbol( new LIB_PART( *aComponent.m_part.get() ) );
162 
163  const_cast<KIID&>( m_Uuid ) = aComponent.m_Uuid;
164 
165  m_transform = aComponent.m_transform;
166  m_prefix = aComponent.m_prefix;
168  m_fields = aComponent.m_fields;
169 
170  // Re-parent the fields, which before this had aComponent as parent
171  for( SCH_FIELD& field : m_fields )
172  field.SetParent( this );
173 
175 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:51
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:162
void SetLibSymbol(LIB_PART *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
bool m_onBoard
True to include in netlist when updating board.
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:201
bool m_isInNetlist
True if the component should appear in the netlist.
Define a library symbol object.
std::unique_ptr< LIB_PART > m_part
const KIID m_Uuid
Definition: eda_item.h:151
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:84
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
Definition: sch_component.h:83
bool m_inBom
True to include in bill of materials export.
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:85
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is.
Definition: sch_component.h:88
TRANSFORM m_transform
The rotation/mirror transformation matrix.
SCH_FIELDS m_fields
Variable length list of fields.
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType)
Definition: sch_item.cpp:47

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_transform, m_unit, EDA_ITEM::m_Uuid, and SetLibSymbol().

◆ ~SCH_COMPONENT()

SCH_COMPONENT::~SCH_COMPONENT ( )
inline

Definition at line 153 of file sch_component.h.

153 { }

Member Function Documentation

◆ AddConnectionTo()

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

Adds a connection link between this item and another.

Definition at line 170 of file sch_item.cpp.

171 {
172  m_connected_items[ aSheet ].insert( aItem );
173 }
std::unordered_map< SCH_SHEET_PATH, SCH_ITEM_SET > m_connected_items
Stores pointers to other items that are connected to this one, per sheet.
Definition: sch_item.h:206

References SCH_ITEM::m_connected_items.

Referenced by SCH_TEXT::UpdateDanglingState().

◆ AddField()

SCH_FIELD * SCH_COMPONENT::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 711 of file sch_component.cpp.

712 {
713  int newNdx = m_fields.size();
714 
715  m_fields.push_back( aField );
716  return &m_fields[newNdx];
717 }
SCH_FIELDS m_fields
Variable length list of fields.

References m_fields.

Referenced by FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData(), DIALOG_CHANGE_SYMBOLS::processSymbol(), and UpdateFields().

◆ AddHierarchicalReference()

void SCH_COMPONENT::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/&ltcomponent 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 intances)

Definition at line 376 of file sch_component.cpp.

379 {
380  // Search for an existing path and remove it if found (should not occur)
381  for( unsigned ii = 0; ii < m_instanceReferences.size(); ii++ )
382  {
383  if( m_instanceReferences[ii].m_Path == aPath )
384  {
385  wxLogTrace( traceSchSheetPaths, "Removing symbol instance:\n"
386  " sheet path %s\n"
387  " reference %s, unit %d from symbol %s.",
388  aPath.AsString(),
389  m_instanceReferences[ii].m_Reference,
390  m_instanceReferences[ii].m_Unit,
391  m_Uuid.AsString() );
392 
393  m_instanceReferences.erase( m_instanceReferences.begin() + ii );
394  ii--;
395  }
396  }
397 
398  SYMBOL_INSTANCE_REFERENCE instance;
399  instance.m_Path = aPath;
400  instance.m_Reference = aRef;
401  instance.m_Unit = aUnit;
402  instance.m_Value = aValue;
403  instance.m_Footprint = aFootprint;
404 
405  wxLogTrace( traceSchSheetPaths, "Adding symbol instance:\n"
406  " sheet path %s\n"
407  " reference %s, unit %d to symbol %s.",
408  aPath.AsString(),
409  aRef,
410  aUnit,
411  m_Uuid.AsString() );
412 
413  m_instanceReferences.push_back( instance );
414 }
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
wxString AsString() const
Definition: kiid.cpp:174
A simple container for schematic symbol instance infromation.
const KIID m_Uuid
Definition: eda_item.h:151
wxString AsString() const
Definition: kiid.cpp:206
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences

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(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol(), SetFootprint(), SetRef(), SetUnitSelection(), SetValue(), and SCH_SHEET_LIST::UpdateSymbolInstances().

◆ AddSheetPathReferenceEntryIfMissing()

bool SCH_COMPONENT::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 component 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 this sheet path is the sheet path of the sheet containing the component, not the full component sheet path
Returns
false if the alternate reference was existing, true if added.

Definition at line 1033 of file sch_component.cpp.

1034 {
1035  // a empty sheet path is illegal:
1036  wxCHECK( aSheetPath.size() > 0, false );
1037 
1038  wxString reference_path;
1039 
1040  for( const SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
1041  {
1042  // if aSheetPath is found, nothing to do:
1043  if( instance.m_Path == aSheetPath )
1044  return false;
1045  }
1046 
1047  // This entry does not exist: add it, with its last-used reference
1048  AddHierarchicalReference( aSheetPath, m_fields[REFERENCE_FIELD].GetText(), m_unit );
1049  return true;
1050 }
A simple container for schematic symbol instance infromation.
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:84
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
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.
Field Reference of part, i.e. "IC21".
SCH_FIELDS m_fields
Variable length list of fields.

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

468  {
469  if( GetFieldsAutoplaced() )
471  }
FIELDS_AUTOPLACED GetFieldsAutoplaced() const
Return whether the fields have been automatically placed.
Definition: sch_item.h:453
virtual void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual)
Definition: sch_item.h:473

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(), and SCH_EDIT_FRAME::SelectUnit().

◆ AutoplaceFields()

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

Automatically orient all the fields in the component.

Parameters
aScreenis the SCH_SCREEN associated with the current instance of the component. 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 679 of file eeschema/autoplace_fields.cpp.

680 {
681  if( aManual )
682  wxASSERT_MSG( aScreen, "A SCH_SCREEN pointer must be given for manual autoplacement" );
683 
684  AUTOPLACER autoplacer( this, aScreen );
685  autoplacer.DoAutoplace( aManual );
687 }
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:201

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

Referenced by SCH_DRAWING_TOOLS::PlaceComponent().

◆ CanConnect()

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

Reimplemented from SCH_ITEM.

Definition at line 617 of file sch_component.h.

618  {
619  return ( aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_WIRE ) ||
620  ( aItem->Type() == SCH_NO_CONNECT_T ) ||
621  ( aItem->Type() == SCH_JUNCTION_T ) ||
622  ( aItem->Type() == SCH_COMPONENT_T ) ;
623  }
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:285
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181

References SCH_ITEM::GetLayer(), LAYER_WIRE, SCH_COMPONENT_T, SCH_JUNCTION_T, SCH_LINE_T, SCH_NO_CONNECT_T, and EDA_ITEM::Type().

◆ ClassOf()

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

Definition at line 155 of file sch_component.h.

156  {
157  return aItem && SCH_COMPONENT_T == aItem->Type();
158  }
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181

References SCH_COMPONENT_T, and EDA_ITEM::Type().

◆ ClearAnnotation()

void SCH_COMPONENT::ClearAnnotation ( const SCH_SHEET_PATH aSheetPath)

Clear exiting component 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 990 of file sch_component.cpp.

991 {
992  // Build a reference with no annotation,
993  // i.e. a reference ended by only one '?'
994  wxString defRef = m_prefix;
995 
996  if( !IsReferenceStringValid( defRef ) )
997  { // This is a malformed reference: reinit this reference
998  m_prefix = defRef = wxT("U"); // Set to default ref prefix
999  }
1000 
1001  while( defRef.Last() == '?' )
1002  defRef.RemoveLast();
1003 
1004  defRef.Append( wxT( "?" ) );
1005 
1006  if( aSheetPath )
1007  {
1008  KIID_PATH path = aSheetPath->Path();
1009 
1011  {
1012  if( instance.m_Path == path )
1013  instance.m_Reference = defRef;
1014  }
1015  }
1016  else
1017  {
1019  instance.m_Reference = defRef;
1020  }
1021 
1022  for( std::unique_ptr<SCH_PIN>& pin : m_pins )
1023  pin->ClearDefaultNetName( aSheetPath );
1024 
1025  // These 2 changes do not work in complex hierarchy.
1026  // When a clear annotation is made, the calling function must call a
1027  // UpdateAllScreenReferences for the active sheet.
1028  // But this call cannot made here.
1029  m_fields[REFERENCE_FIELD].SetText( defRef ); //for drawing.
1030 }
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
A simple container for schematic symbol instance infromation.
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
std::vector< std::unique_ptr< SCH_PIN > > m_pins
static bool IsReferenceStringValid(const wxString &aReferenceString)
Tests for an acceptable reference string.
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is.
Definition: sch_component.h:88
Field Reference of part, i.e. "IC21".
SCH_FIELDS m_fields
Variable length list of fields.

References IsReferenceStringValid(), m_fields, m_instanceReferences, m_pins, m_prefix, SCH_SHEET_PATH::Path(), and REFERENCE_FIELD.

Referenced by SCH_SCREEN::ClearAnnotation(), SCH_EDIT_FRAME::DeleteAnnotation(), SCH_EDIT_TOOL::Duplicate(), SCH_EDITOR_CONTROL::Paste(), and SCH_EDITOR_CONTROL::updatePastedInstances().

◆ ClearBrightened()

void EDA_ITEM::ClearBrightened ( )
inlineinherited

◆ ClearBrightenedPins()

void SCH_COMPONENT::ClearBrightenedPins ( )

Definition at line 1852 of file sch_component.cpp.

1853 {
1854  for( auto& pin : m_pins )
1855  pin->ClearBrightened();
1856 }
std::vector< std::unique_ptr< SCH_PIN > > m_pins

References m_pins.

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

405 { m_connections.clear(); }
EDA_ITEMS m_connections
Definition: sch_item.h:200

References SCH_ITEM::m_connections.

◆ ClearEditFlags()

◆ ClearFieldsAutoplaced()

void SCH_ITEM::ClearFieldsAutoplaced ( )
inlineinherited

Set fields automatically placed flag false.

Definition at line 458 of file sch_item.h.

FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:201

References FIELDS_AUTOPLACED_NO, and SCH_ITEM::m_fieldsAutoplaced.

Referenced by SCH_MOVE_TOOL::moveItem(), DIALOG_SHEET_PROPERTIES::TransferDataFromWindow(), and DIALOG_SCH_EDIT_ONE_FIELD::UpdateField().

◆ ClearFlags()

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

Definition at line 221 of file eda_item.h.

221 { m_flags &= ~aMask; }
STATUS_FLAGS m_flags
Definition: eda_item.h:164

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(), LIB_EDIT_TOOL::Copy(), FOOTPRINT_EDITOR_TOOLS::CreateFootprint(), LIB_PIN_TOOL::CreateImagePins(), MICROWAVE_TOOL::createMicrowaveInductor(), DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES(), KIGFX::SCH_PAINTER::draw(), LIB_EDIT_TOOL::Duplicate(), SCH_ITEM::Duplicate(), PCB_EDIT_FRAME::ExchangeFootprint(), SYMBOL_EDIT_FRAME::GetSymbolFromRedoList(), SYMBOL_EDIT_FRAME::GetSymbolFromUndoList(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromLibrary(), EE_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::narrowSelection(), FOOTPRINT_EDITOR_TOOLS::NewFootprint(), FOOTPRINT_EDIT_FRAME::OpenProjectFiles(), PCB_BASE_FRAME::PlaceFootprint(), LIB_PIN_TOOL::PlacePin(), DRAWING_TOOL::PlaceText(), BOARD_COMMIT::Push(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_PIN_TOOL::RepeatPin(), SYMBOL_EDIT_FRAME::RollbackSymbolFromUndo(), SCH_EDIT_FRAME::SaveCopyForRepeatItem(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), SCH_SEXPR_PLUGIN_CACHE::savePin(), SCH_LEGACY_PLUGIN_CACHE::savePin(), 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 233 of file eda_item.h.

234  {
236  DO_NOT_DRAW );
237  }
#define TEMP_SELECTED
flag indicating that the structure has already selected
Definition: eda_item.h:114
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
Definition: eda_item.h:103
#define CANDIDATE
flag indicating that the structure is connected
Definition: eda_item.h:116
#define DO_NOT_DRAW
Used to disable draw function.
Definition: eda_item.h:118
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: eda_item.h:111
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:221
#define ENDPOINT
ends. (Used to support dragging.)
Definition: eda_item.h:112
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: eda_item.h:117

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 154 of file view_item.h.

155  {
157  }
VIEW_ITEM_DATA * m_viewPrivData
Definition: view_item.h:162
#define NULL

References KIGFX::VIEW_ITEM::m_viewPrivData, and NULL.

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

◆ Clone()

EDA_ITEM * SCH_COMPONENT::Clone ( ) const
overridevirtual

Function Clone creates 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 207 of file sch_component.cpp.

208 {
209  return new SCH_COMPONENT( *this );
210 }
SCH_COMPONENT(const wxPoint &pos=wxPoint(0, 0), SCH_ITEM *aParent=NULL)

References SCH_COMPONENT().

Referenced by SCH_DRAWING_TOOLS::PlaceComponent().

◆ ConnectedItems()

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

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

Definition at line 164 of file sch_item.cpp.

165 {
166  return m_connected_items[ aSheet ];
167 }
std::unordered_map< SCH_SHEET_PATH, SCH_ITEM_SET > m_connected_items
Stores pointers to other items that are connected to this one, per sheet.
Definition: sch_item.h:206

References SCH_ITEM::m_connected_items.

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

132 {
133  if( !aSheet )
134  aSheet = &Schematic()->CurrentSheet();
135 
136  auto it = m_connection_map.find( *aSheet );
137 
138  if( it == m_connection_map.end() )
139  return nullptr;
140  else
141  return it->second;
142 }
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:97
std::unordered_map< SCH_SHEET_PATH, SCH_CONNECTION * > m_connection_map
Stores connectivity information, per sheet.
Definition: sch_item.h:209
SCH_SHEET_PATH & CurrentSheet() const
Definition: schematic.h:127

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

Referenced by CONNECTION_SUBGRAPH::Absorb(), CONNECTION_SUBGRAPH::AddItem(), BACK_ANNOTATE::applyChangelist(), CONNECTION_GRAPH::buildConnectionGraph(), KIGFX::SCH_PAINTER::draw(), CONNECTION_GRAPH::ercCheckBusToBusConflicts(), CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts(), CONNECTION_GRAPH::ercCheckNoConnects(), SCH_PIN::GetMsgPanelInfo(), SCH_BUS_ENTRY_BASE::GetMsgPanelInfo(), SCH_LINE::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), CONNECTION_SUBGRAPH::GetNetName(), highlightNet(), SCH_ITEM::InitializeConnection(), SCH_ITEM::NetClass(), SCH_EDIT_FRAME::OnModify(), SCH_HIERLABEL::Print(), 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

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

Reimplemented in SCH_BUS_WIRE_ENTRY, and SCH_PIN.

Definition at line 442 of file sch_item.h.

442 { return true; }

Referenced by CONNECTION_GRAPH::updateItemConnectivity().

◆ DoHypertextMenu()

virtual void SCH_ITEM::DoHypertextMenu ( EDA_DRAW_FRAME aFrame)
inlinevirtualinherited

Reimplemented in SCH_FIELD.

Definition at line 280 of file sch_item.h.

280 { }

◆ doIsConnected()

bool SCH_COMPONENT::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
aPositionA reference to a wxPoint object containing the test position.
Returns
True if connection to aPosition exists.

Reimplemented from SCH_ITEM.

Definition at line 1792 of file sch_component.cpp.

1793 {
1794  wxPoint new_pos = m_transform.InverseTransform().TransformCoordinate( aPosition - m_pos );
1795 
1796  for( const auto& pin : m_pins )
1797  {
1798  // Collect only pins attached to the current unit and convert.
1799  // others are not associated to this component instance
1800  int pin_unit = pin->GetLibPin()->GetUnit();
1801  int pin_convert = pin->GetLibPin()->GetConvert();
1802 
1803  if( pin_unit > 0 && pin_unit != GetUnit() )
1804  continue;
1805 
1806  if( pin_convert > 0 && pin_convert != GetConvert() )
1807  continue;
1808 
1809  if( pin->GetLocalPosition() == new_pos )
1810  return true;
1811  }
1812 
1813  return false;
1814 }
TRANSFORM InverseTransform() const
Calculate the Inverse mirror/rotation transform.
Definition: transform.cpp:59
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
int GetUnit() const
int GetConvert() const
std::vector< std::unique_ptr< SCH_PIN > > m_pins
TRANSFORM m_transform
The rotation/mirror transformation matrix.

References GetConvert(), GetUnit(), TRANSFORM::InverseTransform(), m_pins, m_pos, m_transform, 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 78 of file sch_item.cpp.

79 {
80  SCH_ITEM* newItem = (SCH_ITEM*) Clone();
81 
82  if( !doClone )
83  const_cast<KIID&>( newItem->m_Uuid ) = KIID();
84 
85  newItem->ClearFlags( SELECTED | BRIGHTENED );
86 
87  newItem->RunOnChildren(
88  []( SCH_ITEM* aChild )
89  {
90  aChild->ClearFlags( SELECTED | BRIGHTENED );
91  } );
92 
93  return newItem;
94 }
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:97
virtual void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction)
Definition: sch_item.h:475
Definition: kiid.h:44
#define BRIGHTENED
item is drawn with a bright contour
Definition: eda_item.h:129
#define SELECTED
Definition: eda_item.h:113
const KIID m_Uuid
Definition: eda_item.h:151
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:221
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:194

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

Referenced by SCH_EDIT_TOOL::Duplicate(), CADSTAR_SCH_ARCHIVE_LOADER::loadItemOntoKiCadSheet(), SCH_EAGLE_PLUGIN::loadSchematic(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_EDIT_TOOL::RepeatDrawItem(), and SCH_EDIT_FRAME::SaveCopyInUndoList().

◆ FindField()

SCH_FIELD * SCH_COMPONENT::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 733 of file sch_component.cpp.

734 {
735  unsigned start = aIncludeDefaultFields ? 0 : MANDATORY_FIELDS;
736 
737  for( unsigned i = start; i < m_fields.size(); ++i )
738  {
739  if( aFieldName == m_fields[i].GetName( false ) )
740  return &m_fields[i];
741  }
742 
743  return NULL;
744 }
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
#define NULL
SCH_FIELDS m_fields
Variable length list of fields.

References m_fields, MANDATORY_FIELDS, and NULL.

Referenced by FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData(), NETLIST_EXPORTER_PSPICE::GetSpiceField(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), DIALOG_CHANGE_SYMBOLS::processSymbol(), and UpdateFields().

◆ Get() [1/3]

wxAny INSPECTABLE::Get ( PROPERTY_BASE aProperty)
inlineinherited

Definition at line 84 of file inspectable.h.

85  {
87  TYPE_ID thisType = TYPE_HASH( *this );
88  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
89  return object ? aProperty->getter( object ) : wxAny();
90  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:64
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:55
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:41
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
virtual wxAny getter(void *aObject) const =0
Provides class metadata.
Definition: property_mgr.h:61
virtual size_t OwnerHash() const =0
Returns type-id of the Owner class.

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

Referenced by 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 93 of file inspectable.h.

94  {
96  TYPE_ID thisType = TYPE_HASH( *this );
97  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
98  return object ? aProperty->get<T>( object ) : T();
99  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:64
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:55
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:41
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
Provides class metadata.
Definition: property_mgr.h:61
T get(void *aObject)
Definition: property.h:275
virtual size_t OwnerHash() const =0
Returns 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 102 of file inspectable.h.

103  {
105  TYPE_ID thisType = TYPE_HASH( *this );
106  PROPERTY_BASE* prop = propMgr.GetProperty( thisType, aProperty );
107  boost::optional<T> ret;
108 
109  if( prop )
110  {
111  void* object = propMgr.TypeCast( this, thisType, prop->OwnerHash() );
112 
113  if( object )
114  ret = prop->get<T>( object );
115  }
116 
117  return ret;
118  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:64
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:55
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:41
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Returns a property for a specific type.
Provides class metadata.
Definition: property_mgr.h:61
T get(void *aObject)
Definition: property.h:275
virtual size_t OwnerHash() const =0
Returns 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().

◆ GetBodyBoundingBox()

EDA_RECT SCH_COMPONENT::GetBodyBoundingBox ( ) const

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

Definition at line 1277 of file sch_component.cpp.

1278 {
1279  EDA_RECT bBox;
1280 
1281  if( m_part )
1282  bBox = m_part->GetBodyBoundingBox( m_unit, m_convert );
1283  else
1284  bBox = dummy()->GetBodyBoundingBox( m_unit, m_convert );
1285 
1286  int x0 = bBox.GetX();
1287  int xm = bBox.GetRight();
1288 
1289  // We must reverse Y values, because matrix orientation
1290  // suppose Y axis normal for the library items coordinates,
1291  // m_transform reverse Y values, but bBox is already reversed!
1292  int y0 = -bBox.GetY();
1293  int ym = -bBox.GetBottom();
1294 
1295  // Compute the real Boundary box (rotated, mirrored ...)
1296  int x1 = m_transform.x1 * x0 + m_transform.y1 * y0;
1297  int y1 = m_transform.x2 * x0 + m_transform.y2 * y0;
1298  int x2 = m_transform.x1 * xm + m_transform.y1 * ym;
1299  int y2 = m_transform.x2 * xm + m_transform.y2 * ym;
1300 
1301  bBox.SetX( x1 );
1302  bBox.SetY( y1 );
1303  bBox.SetWidth( x2 - x1 );
1304  bBox.SetHeight( y2 - y1 );
1305  bBox.Normalize();
1306 
1307  bBox.Offset( m_pos );
1308  return bBox;
1309 }
void Offset(int dx, int dy)
Definition: eda_rect.h:157
int y2
Definition: transform.h:51
int GetX() const
Definition: eda_rect.h:111
int x2
Definition: transform.h:50
int x1
Definition: transform.h:48
int GetBottom() const
Definition: eda_rect.h:124
int y1
Definition: transform.h:49
void SetHeight(int val)
Definition: eda_rect.h:186
int GetRight() const
Definition: eda_rect.h:121
void SetX(int val)
Definition: eda_rect.h:168
std::unique_ptr< LIB_PART > m_part
void SetWidth(int val)
Definition: eda_rect.h:180
void SetY(int val)
Definition: eda_rect.h:174
void Normalize()
Function Normalize ensures that the height ant width are positive.
Definition: eda_rect.cpp:35
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:84
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
int GetY() const
Definition: eda_rect.h:112
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:85
const EDA_RECT GetBodyBoundingBox(int aUnit, int aConvert) const
Get the symbol bounding box excluding fields.
TRANSFORM m_transform
The rotation/mirror transformation matrix.

References dummy(), LIB_PART::GetBodyBoundingBox(), EDA_RECT::GetBottom(), EDA_RECT::GetRight(), EDA_RECT::GetX(), EDA_RECT::GetY(), m_convert, m_part, m_pos, m_transform, m_unit, 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 AUTOPLACER::AUTOPLACER(), GetBoundingBox(), HitTest(), and operator<().

◆ GetBoundingBox() [1/2]

const EDA_RECT SCH_COMPONENT::GetBoundingBox ( ) const
overridevirtual

Function GetBoundingBox returns 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 1312 of file sch_component.cpp.

1313 {
1314  EDA_RECT bbox = GetBodyBoundingBox();
1315 
1316  for( const SCH_FIELD& field : m_fields )
1317  bbox.Merge( field.GetBoundingBox() );
1318 
1319  return bbox;
1320 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:51
void Merge(const EDA_RECT &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
Definition: eda_rect.cpp:431
EDA_RECT GetBodyBoundingBox() const
Return a bounding box for the symbol body but not the fields.
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
SCH_FIELDS m_fields
Variable length list of fields.

References GetBodyBoundingBox(), m_fields, and EDA_RECT::Merge().

Referenced by SCH_EDITOR_CONTROL::FindComponentAndItem(), AUTOPLACER::get_possible_colliders(), and SCH_EDIT_FRAME::GetDocumentExtents().

◆ GetBoundingBox() [2/2]

const EDA_RECT SCH_COMPONENT::GetBoundingBox ( bool  aIncludeInvisibleText) const

Definition at line 1323 of file sch_component.cpp.

1324 {
1325  EDA_RECT bbox = GetBodyBoundingBox();
1326 
1327  for( const SCH_FIELD& field : m_fields )
1328  {
1329  if( field.IsVisible() || aIncludeInvisibleText )
1330  bbox.Merge( field.GetBoundingBox() );
1331  }
1332 
1333  return bbox;
1334 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:51
void Merge(const EDA_RECT &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
Definition: eda_rect.cpp:431
EDA_RECT GetBodyBoundingBox() const
Return a bounding box for the symbol body but not the fields.
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
SCH_FIELDS m_fields
Variable length list of fields.

References GetBodyBoundingBox(), m_fields, and EDA_RECT::Merge().

◆ GetClass()

wxString SCH_COMPONENT::GetClass ( ) const
inlineoverridevirtual

Function GetClass returns the class name.

Returns
wxString

Reimplemented from SCH_ITEM.

Definition at line 160 of file sch_component.h.

161  {
162  return wxT( "SCH_COMPONENT" );
163  }

Referenced by operator=().

◆ GetConnectionPoints()

std::vector< wxPoint > SCH_COMPONENT::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
aPointsList of connection points to add to.

Reimplemented from SCH_ITEM.

Definition at line 1564 of file sch_component.cpp.

1565 {
1566  std::vector<wxPoint> retval;
1567 
1568  for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
1569  {
1570  // Collect only pins attached to the current unit and convert.
1571  // others are not associated to this component instance
1572  int pin_unit = pin->GetLibPin()->GetUnit();
1573  int pin_convert = pin->GetLibPin()->GetConvert();
1574 
1575  if( pin_unit > 0 && pin_unit != GetUnit() )
1576  continue;
1577 
1578  if( pin_convert > 0 && pin_convert != GetConvert() )
1579  continue;
1580 
1581  retval.push_back( m_transform.TransformCoordinate( pin->GetLocalPosition() ) + m_pos );
1582  }
1583 
1584  return retval;
1585 }
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
int GetUnit() const
int GetConvert() const
std::vector< std::unique_ptr< SCH_PIN > > m_pins
TRANSFORM m_transform
The rotation/mirror transformation matrix.

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

◆ GetContextualTextVars()

void SCH_COMPONENT::GetContextualTextVars ( wxArrayString *  aVars) const

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

Definition at line 900 of file sch_component.cpp.

901 {
902  for( int i = 0; i < MANDATORY_FIELDS; ++i )
903  aVars->push_back( m_fields[i].GetCanonicalName().Upper() );
904 
905  for( size_t i = MANDATORY_FIELDS; i < m_fields.size(); ++i )
906  aVars->push_back( m_fields[i].GetName() );
907 
908  aVars->push_back( wxT( "FOOTPRINT_LIBRARY" ) );
909  aVars->push_back( wxT( "FOOTPRINT_NAME" ) );
910  aVars->push_back( wxT( "UNIT" ) );
911 }
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
SCH_FIELDS m_fields
Variable length list of fields.

References m_fields, and MANDATORY_FIELDS.

Referenced by DIALOG_LABEL_EDITOR::onScintillaCharAdded(), and DIALOG_SCH_EDIT_ONE_FIELD::onScintillaCharAdded().

◆ GetConvert()

◆ GetDatasheet()

wxString SCH_COMPONENT::GetDatasheet ( ) const

Return the documentation text for the given part alias.

Definition at line 259 of file sch_component.cpp.

260 {
261  if( m_part )
262  return m_part->GetDatasheetField().GetText();
263 
264  return wxEmptyString;
265 }
std::unique_ptr< LIB_PART > m_part

References m_part.

Referenced by UpdateFields().

◆ GetDescription()

wxString SCH_COMPONENT::GetDescription ( ) const

Return information about the aliased parts.

Definition at line 250 of file sch_component.cpp.

251 {
252  if( m_part )
253  return m_part->GetDescription();
254 
255  return wxEmptyString;
256 }
std::unique_ptr< LIB_PART > m_part

References m_part.

Referenced by NETLIST_EXPORTER_XML::makeSymbols().

◆ GetDrawItem()

LIB_ITEM * SCH_COMPONENT::GetDrawItem ( const wxPoint &  aPosition,
KICAD_T  aType = TYPE_NOT_INIT 
)

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

Parameters
aPositionis the schematic position of the component 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 1588 of file sch_component.cpp.

1589 {
1590  if( m_part )
1591  {
1592  // Calculate the position relative to the component.
1593  wxPoint libPosition = aPosition - m_pos;
1594 
1595  return m_part->LocateDrawItem( m_unit, m_convert, aType, libPosition, m_transform );
1596  }
1597 
1598  return NULL;
1599 }
#define NULL
std::unique_ptr< LIB_PART > m_part
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:84
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:85
TRANSFORM m_transform
The rotation/mirror transformation matrix.

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

Referenced by SCH_SCREEN::GetPin().

◆ GetEditFlags()

STATUS_FLAGS EDA_ITEM::GetEditFlags ( ) const
inlineinherited

Definition at line 225 of file eda_item.h.

226  {
227  constexpr int mask = ( IS_NEW | IS_PASTED | IS_MOVED | IS_RESIZED | IS_DRAGGED |
229 
230  return m_flags & mask;
231  }
#define IS_RESIZED
Item being resized.
Definition: eda_item.h:107
#define STRUCT_DELETED
flag indication structures to be erased
Definition: eda_item.h:115
#define IS_MOVED
Item being moved.
Definition: eda_item.h:105
#define IS_DRAGGED
Item being dragged.
Definition: eda_item.h:108
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
Definition: eda_item.h:119
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.
Definition: eda_item.h:110
STATUS_FLAGS m_flags
Definition: eda_item.h:164
#define IS_NEW
New item, just created.
Definition: eda_item.h:106

References IS_DRAGGED, IS_MOVED, IS_NEW, IS_PASTED, IS_RESIZED, IS_WIRE_IMAGE, EDA_ITEM::m_flags, and STRUCT_DELETED.

Referenced by SCH_EDIT_TOOL::ChangeTextType(), EDA_ITEM::ClearEditFlags(), SCH_EDIT_FRAME::DeleteJunction(), SCH_EDIT_TOOL::editFieldText(), LIB_PIN_TOOL::EditPinProperties(), SCH_EDITOR_CONTROL::EditWithLibEdit(), GetMsgPanelInfo(), SELECTION_CONDITIONS::Idle(), SELECTION_CONDITIONS::IdleSelection(), LIB_MOVE_TOOL::Main(), POINT_EDITOR::OnSelectionChange(), LIB_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_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LABEL_EDITOR::TransferDataFromWindow(), DIALOG_FOOTPRINT_PROPERTIES::TransferDataFromWindow(), and SCH_EDIT_FRAME::TrimWire().

◆ GetEndPoints()

void SCH_COMPONENT::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
aItemList- List of DANGLING_END_ITEMS to add to.

Reimplemented from SCH_ITEM.

Definition at line 1489 of file sch_component.cpp.

1490 {
1491  for( auto& pin : m_pins )
1492  {
1493  LIB_PIN* lib_pin = pin->GetLibPin();
1494 
1495  if( lib_pin->GetUnit() && m_unit && ( m_unit != lib_pin->GetUnit() ) )
1496  continue;
1497 
1498  DANGLING_END_ITEM item( PIN_END, lib_pin, GetPinPhysicalPosition( lib_pin ), this );
1499  aItemList.push_back( item );
1500  }
1501 }
int GetUnit() const
Definition: lib_item.h:296
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:84
Helper class used to store the state of schematic items that can be connected to other schematic item...
Definition: sch_item.h:85
std::vector< std::unique_ptr< SCH_PIN > > m_pins
wxPoint GetPinPhysicalPosition(const LIB_PIN *Pin) const

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

◆ GetField() [1/2]

SCH_FIELD * SCH_COMPONENT::GetField ( int  aFieldNdx)

Returns a field in this symbol.

Parameters
aFieldNdxis the index into the array of fields, not a field id.
Returns
is the field at aFieldNdx or NULL if the field does not exist.

Definition at line 671 of file sch_component.cpp.

672 {
673  if( (unsigned) aFieldNdx < m_fields.size() )
674  return &m_fields[aFieldNdx];
675 
676  return nullptr;
677 }
SCH_FIELDS m_fields
Variable length list of fields.

References m_fields.

Referenced by SCH_EAGLE_PLUGIN::addImplicitConnections(), NETLIST_EXPORTER_XML::addSymbolFields(), SIM_PLOT_FRAME::AddTuner(), SCH_EDITOR_CONTROL::AssignFootprints(), SCH_EDIT_TOOL::EditField(), FormatProbeItem(), GetFootprint(), GetRef(), GetSelectMenuText(), NETLIST_EXPORTER_PSPICE::GetSpiceFieldDefVal(), GetValue(), DIALOG_FIELDS_EDITOR_GLOBAL::LoadFieldNames(), SCH_EAGLE_PLUGIN::loadSchematic(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbolInstances(), TUNER_SLIDER::onSave(), operator==(), SCH_ALTIUM_PLUGIN::ParsePowerPort(), SCH_EDITOR_CONTROL::processCmpToFootprintLinkFile(), DIALOG_CHANGE_SYMBOLS::processSymbol(), SCH_LEGACY_PLUGIN::saveComponent(), SCH_COMPONENT(), SetRef(), EE_INSPECTION_TOOL::ShowDatasheet(), SCH_SHEET::SymbolCount(), DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow(), TUNER_SLIDER::TUNER_SLIDER(), SCH_SHEET_PATH::UpdateAllScreenReferences(), UpdateFields(), SCH_SHEET_LIST::UpdateSymbolInstances(), Visit(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem(), and NETLIST_EXPORTER_CADSTAR::WriteNetlist().

◆ GetField() [2/2]

const SCH_FIELD * SCH_COMPONENT::GetField ( int  aFieldNdx) const

Definition at line 680 of file sch_component.cpp.

681 {
682  if( (unsigned) aFieldNdx < m_fields.size() )
683  return &m_fields[aFieldNdx];
684 
685  return nullptr;
686 }
SCH_FIELDS m_fields
Variable length list of fields.

References m_fields.

◆ GetFieldCount()

int SCH_COMPONENT::GetFieldCount ( ) const
inline

◆ GetFields() [1/2]

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

Populates 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 701 of file sch_component.cpp.

702 {
703  for( SCH_FIELD& field : m_fields )
704  {
705  if( !aVisibleOnly || ( field.IsVisible() && !field.IsVoid() ) )
706  aVector.push_back( &field );
707  }
708 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:51
SCH_FIELDS m_fields
Variable length list of fields.

References m_fields.

Referenced by AUTOPLACER::AUTOPLACER(), KIGFX::SCH_PAINTER::draw(), NETLIST_EXPORTER_XML::makeSymbols(), DIALOG_CHANGE_SYMBOLS::processSymbol(), SCH_SEXPR_PLUGIN::saveSymbol(), ERC_TESTER::TestTextVars(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), and SCH_EDITOR_CONTROL::UpdateNetHighlighting().

◆ GetFields() [2/2]

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

Returns a vector of fields from the component.

Definition at line 396 of file sch_component.h.

396 { return m_fields; }
SCH_FIELDS m_fields
Variable length list of fields.

References m_fields.

◆ GetFieldsAutoplaced()

FIELDS_AUTOPLACED SCH_ITEM::GetFieldsAutoplaced ( ) const
inlineinherited

Return whether the fields have been automatically placed.

Definition at line 453 of file sch_item.h.

453 { return m_fieldsAutoplaced; }
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:201

References SCH_ITEM::m_fieldsAutoplaced.

Referenced by SCH_ITEM::AutoAutoplaceFields(), and EE_POINT_EDITOR::updateParentItem().

◆ GetFieldText()

wxString SCH_COMPONENT::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 689 of file sch_component.cpp.

690 {
691  for( const SCH_FIELD& field : m_fields )
692  {
693  if( aFieldName == field.GetName() || aFieldName == field.GetCanonicalName() )
694  return field.GetText();
695  }
696 
697  return wxEmptyString;
698 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:51
SCH_FIELDS m_fields
Variable length list of fields.

References m_fields.

Referenced by FIELDS_EDITOR_GRID_DATA_MODEL::AddColumn().

◆ GetFlags()

◆ GetFocusPosition()

virtual const wxPoint EDA_ITEM::GetFocusPosition ( ) const
inlinevirtualinherited

Function GetFocusPosition similar to GetPosition, but allows items to return their visual center rather than their anchor.

Reimplemented in BOARD, PCB_SHAPE, and TRACK.

Definition at line 333 of file eda_item.h.

333 { return GetPosition(); }
virtual wxPoint GetPosition() const
Definition: eda_item.h:325

References EDA_ITEM::GetPosition().

Referenced by PCB_BASE_FRAME::FocusOnItem(), and SCH_EDIT_FRAME::FocusOnItem().

◆ GetFootprint()

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

Definition at line 621 of file sch_component.cpp.

622 {
623  KIID_PATH path = sheet->Path();
624 
625  for( const SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
626  {
627  if( instance.m_Path == path && !instance.m_Footprint.IsEmpty() )
628  {
629  // This can only be an override from an Update Schematic from PCB, and therefore
630  // will always be fully resolved.
631  return instance.m_Footprint;
632  }
633  }
634 
635  if( !aResolve )
636  return GetField( FOOTPRINT_FIELD )->GetText();
637 
639 }
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:104
A simple container for schematic symbol instance infromation.
Field Name Module PCB, i.e. "16DIP300".
SCH_FIELD * GetField(int aFieldNdx)
Returns a field in this symbol.
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133

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

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

◆ GetIncludeInBom()

bool SCH_COMPONENT::GetIncludeInBom ( ) const
inline

Definition at line 677 of file sch_component.h.

677 { return m_inBom; }
bool m_inBom
True to include in bill of materials export.

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_COMPONENT::GetIncludeOnBoard ( ) const
inline

◆ GetInstanceReferences()

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

Definition at line 165 of file sch_component.h.

166  {
167  return m_instanceReferences;
168  }
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences

References m_instanceReferences.

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

◆ GetLayer()

◆ GetLibId()

◆ GetLibPins()

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

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 825 of file sch_component.cpp.

826 {
827  if( m_part )
828  m_part->GetPins( aPinsList, m_unit, m_convert );
829 }
std::unique_ptr< LIB_PART > m_part
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:84
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:85

References m_convert, m_part, and m_unit.

◆ GetMenuImage()

BITMAP_DEF SCH_COMPONENT::GetMenuImage ( ) const
overridevirtual

Function GetMenuImage returns 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 1419 of file sch_component.cpp.

1420 {
1421  return add_component_xpm;
1422 }
const BITMAP_OPAQUE add_component_xpm[1]

References add_component_xpm.

◆ GetMsgPanelInfo()

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

Function GetMsgPanelInfo populates 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 1337 of file sch_component.cpp.

1338 {
1339  wxString msg;
1340 
1341  SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( aFrame );
1342  SCH_SHEET_PATH* currentSheet = schframe ? &schframe->GetCurrentSheet() : nullptr;
1343 
1344  // part and alias can differ if alias is not the root
1345  if( m_part )
1346  {
1347  if( m_part.get() != dummy() )
1348  {
1349  aList.push_back( MSG_PANEL_ITEM( _( "Reference" ), GetRef( currentSheet ) ) );
1350 
1351  msg = m_part->IsPower() ? _( "Power symbol" ) : _( "Value" );
1352 
1353  aList.push_back( MSG_PANEL_ITEM( msg, GetValue( currentSheet, true ) ) );
1354 
1355 #if 0 // Display component flags, for debug only
1356  aList.push_back( MSG_PANEL_ITEM( _( "flags" ), wxString::Format( "%X",
1357  GetEditFlags() ) ) );
1358 #endif
1359 
1360  // Display component reference in library and library
1361  aList.push_back( MSG_PANEL_ITEM( _( "Name" ), GetLibId().GetLibItemName() ) );
1362 
1363  if( !m_part->IsRoot() )
1364  {
1365  msg = _( "Missing parent" );
1366 
1367  std::shared_ptr< LIB_PART > parent = m_part->GetParent().lock();
1368 
1369  if( parent )
1370  msg = parent->GetName();
1371 
1372  aList.push_back( MSG_PANEL_ITEM( _( "Alias of" ), msg ) );
1373  }
1374  else if( !m_lib_id.GetLibNickname().empty() )
1375  {
1376  aList.push_back( MSG_PANEL_ITEM( _( "Library" ), m_lib_id.GetLibNickname() ) );
1377  }
1378  else
1379  {
1380  aList.push_back( MSG_PANEL_ITEM( _( "Library" ), _( "Undefined!!!" ) ) );
1381  }
1382 
1383  // Display the current associated footprint, if exists.
1384  msg = GetFootprint( currentSheet, true );
1385 
1386  if( msg.IsEmpty() )
1387  msg = _( "<Unknown>" );
1388 
1389  aList.push_back( MSG_PANEL_ITEM( _( "Footprint" ), msg ) );
1390 
1391  // Display description of the component, and keywords found in lib
1392  aList.push_back( MSG_PANEL_ITEM( _( "Description" ), m_part->GetDescription(),
1393  DARKCYAN ) );
1394  aList.push_back( MSG_PANEL_ITEM( _( "Keywords" ), m_part->GetKeyWords() ) );
1395  }
1396  }
1397  else
1398  {
1399  aList.push_back( MSG_PANEL_ITEM( _( "Reference" ), GetRef( currentSheet ) ) );
1400 
1401  aList.push_back( MSG_PANEL_ITEM( _( "Value" ), GetValue( currentSheet, true ) ) );
1402  aList.push_back( MSG_PANEL_ITEM( _( "Name" ), GetLibId().GetLibItemName() ) );
1403 
1404  wxString libNickname = GetLibId().GetLibNickname();
1405 
1406  if( libNickname.empty() )
1407  {
1408  aList.push_back( MSG_PANEL_ITEM( _( "Library" ), _( "No library defined!" ) ) );
1409  }
1410  else
1411  {
1412  msg.Printf( _( "Symbol not found in %s!" ), libNickname );
1413  aList.push_back( MSG_PANEL_ITEM( _( "Library" ), msg ) );
1414  }
1415  }
1416 }
void push_back(SCH_SHEET *aSheet)
Forwarded method from std::vector.
Schematic editor (Eeschema) main window.
const wxString GetFootprint(const SCH_SHEET_PATH *sheet, bool aResolve) const
const wxString GetValue(const SCH_SHEET_PATH *sheet, bool aResolve) const
STATUS_FLAGS GetEditFlags() const
Definition: eda_item.h:225
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
std::unique_ptr< LIB_PART > m_part
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Function Format outputs 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_component.h:83
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
#define _(s)
Definition: 3d_actions.cpp:33
SCH_SHEET_PATH & GetCurrentSheet() const
EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:54
const LIB_ID & GetLibId() const
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
bool empty() const
Definition: utf8.h:108

References _, DARKCYAN, dummy(), UTF8::empty(), Format(), SCH_EDIT_FRAME::GetCurrentSheet(), EDA_ITEM::GetEditFlags(), GetFootprint(), GetLibId(), LIB_ID::GetLibNickname(), GetRef(), GetValue(), m_lib_id, m_part, and SCH_SHEET_PATH::push_back().

◆ GetOrientation()

int SCH_COMPONENT::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 mirrorX then a mirrorY returns no mirror but a rotate. This function finds a rotation and a mirror value CMP_MIRROR_X because this is the first mirror option tested. This can differs from the orientation made by an user. A CMP_MIRROR_Y is returned as a CMP_MIRROR_X with an orientation 180 because they are equivalent.

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

Definition at line 1208 of file sch_component.cpp.

1209 {
1210  int rotate_values[] =
1211  {
1212  CMP_ORIENT_0,
1213  CMP_ORIENT_90,
1219  CMP_MIRROR_Y,
1224  };
1225 
1226  // Try to find the current transform option:
1227  TRANSFORM transform = m_transform;
1228 
1229  for( int type_rotate : rotate_values )
1230  {
1231  SetOrientation( type_rotate );
1232 
1233  if( transform == m_transform )
1234  return type_rotate;
1235  }
1236 
1237  // Error: orientation not found in list (should not happen)
1238  wxFAIL_MSG( "Schematic symbol orientation matrix internal error." );
1239  m_transform = transform;
1240 
1241  return CMP_NORMAL;
1242 }
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
TRANSFORM m_transform
The rotation/mirror transformation matrix.
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...

References CMP_MIRROR_X, CMP_MIRROR_Y, CMP_NORMAL, CMP_ORIENT_0, CMP_ORIENT_180, CMP_ORIENT_270, CMP_ORIENT_90, m_transform, and SetOrientation().

Referenced by KIGFX::SCH_PAINTER::draw(), AUTOPLACER::get_preferred_sides(), orientLabel(), SCH_SEXPR_PLUGIN::saveSymbol(), and DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow().

◆ GetParent()

◆ GetPartRef()

◆ GetPenWidth()

virtual int SCH_ITEM::GetPenWidth ( ) const
inlinevirtualinherited

◆ GetPin() [1/2]

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

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 813 of file sch_component.cpp.

814 {
815  for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
816  {
817  if( pin->GetNumber() == aNumber )
818  return pin.get();
819  }
820 
821  return nullptr;
822 }
std::vector< std::unique_ptr< SCH_PIN > > m_pins

References m_pins.

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

◆ GetPin() [2/2]

SCH_PIN * SCH_COMPONENT::GetPin ( LIB_PIN aLibPin)

Definition at line 832 of file sch_component.cpp.

833 {
834  wxASSERT( m_pinMap.count( aLibPin ) );
835  return m_pins[ m_pinMap.at( aLibPin ) ].get();
836 }
std::vector< std::unique_ptr< SCH_PIN > > m_pins
std::unordered_map< LIB_PIN *, unsigned > m_pinMap

References m_pinMap, and m_pins.

◆ GetPinPhysicalPosition()

wxPoint SCH_COMPONENT::GetPinPhysicalPosition ( const LIB_PIN Pin) const

Definition at line 1555 of file sch_component.cpp.

1556 {
1557  wxCHECK_MSG( Pin != NULL && Pin->Type() == LIB_PIN_T, wxPoint( 0, 0 ),
1558  wxT( "Cannot get physical position of pin." ) );
1559 
1560  return m_transform.TransformCoordinate( Pin->GetPosition() ) + m_pos;
1561 }
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
#define NULL
wxPoint GetPosition() const override
Definition: lib_pin.h:258
TRANSFORM m_transform
The rotation/mirror transformation matrix.
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181

References LIB_PIN::GetPosition(), LIB_PIN_T, m_pos, m_transform, NULL, 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_COMPONENT::GetPins ( const SCH_SHEET_PATH aSheet = nullptr) const

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

Since a component 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 839 of file sch_component.cpp.

840 {
841  std::vector<SCH_PIN*> pins;
842 
843  if( aSheet == nullptr )
844  {
845  wxCHECK_MSG( Schematic(), pins, "Can't call GetPins on a component with no schematic" );
846 
847  aSheet = &Schematic()->CurrentSheet();
848  }
849 
850  int unit = GetUnitSelection( aSheet );
851 
852  for( const auto& p : m_pins )
853  {
854  if( unit && p->GetLibPin()->GetUnit() && ( p->GetLibPin()->GetUnit() != unit ) )
855  continue;
856 
857  pins.push_back( p.get() );
858  }
859 
860  return pins;
861 }
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:97
std::vector< std::unique_ptr< SCH_PIN > > m_pins
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
SCH_SHEET_PATH & CurrentSheet() const
Definition: schematic.h:127

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

Referenced by NETLIST_EXPORTER_BASE::CreatePinList(), NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol(), highlightNet(), AUTOPLACER::pins_on_side(), SCH_SEXPR_PLUGIN::saveSymbol(), TEST_SCH_PIN_FIXTURE::TEST_SCH_PIN_FIXTURE(), ERC_TESTER::TestNoConnectPins(), CONNECTION_GRAPH::updateItemConnectivity(), and SCH_EDITOR_CONTROL::UpdateNetHighlighting().

◆ GetPosition()

◆ GetPrefix()

wxString SCH_COMPONENT::GetPrefix ( ) const
inline

Definition at line 268 of file sch_component.h.

268 { return m_prefix; }
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is.
Definition: sch_component.h:88

References m_prefix.

Referenced by SCH_LEGACY_PLUGIN::saveComponent().

◆ GetRawPins()

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

Definition at line 489 of file sch_component.h.

489 { return m_pins; }
std::vector< std::unique_ptr< SCH_PIN > > m_pins

References m_pins.

Referenced by DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES().

◆ GetRef()

const wxString SCH_COMPONENT::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 417 of file sch_component.cpp.

418 {
419  KIID_PATH path = sheet->Path();
420  wxString ref;
421 
422  for( const SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
423  {
424  if( instance.m_Path == path )
425  {
426  ref = instance.m_Reference;
427  break;
428  }
429  }
430 
431  // If it was not found in m_Paths array, then see if it is in m_Field[REFERENCE] -- if so,
432  // use this as a default for this path. This will happen if we load a version 1 schematic
433  // file. It will also mean that multiple instances of the same sheet by default all have
434  // the same component references, but perhaps this is best.
435  if( ref.IsEmpty() && !GetField( REFERENCE_FIELD )->GetText().IsEmpty() )
436  {
437  const_cast<SCH_COMPONENT*>( this )->SetRef( sheet, GetField( REFERENCE_FIELD )->GetText() );
438  ref = GetField( REFERENCE_FIELD )->GetText();
439  }
440 
441  if( ref.IsEmpty() )
442  ref = m_prefix;
443 
444  if( aIncludeUnit && GetUnitCount() > 1 )
445  ref += LIB_PART::SubReference( GetUnit() );
446 
447  return ref;
448 }
int GetUnitCount() const
Return the number of units per package of the symbol.
int GetUnit() const
A simple container for schematic symbol instance infromation.
SCH_FIELD * GetField(int aFieldNdx)
Returns a field in this symbol.
static wxString SubReference(int aUnit, bool aAddSeparator=true)
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is.
Definition: sch_component.h:88
Field Reference of part, i.e. "IC21".
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133

References GetField(), EDA_TEXT::GetText(), GetUnit(), GetUnitCount(), m_instanceReferences, m_prefix, SCH_SHEET_PATH::Path(), REFERENCE_FIELD, and LIB_PART::SubReference().

Referenced by NETLIST_EXPORTER_XML::addSymbolFields(), SCH_EDIT_FRAME::AnnotateComponents(), SCHEMATIC::ConvertKIIDsToRefs(), SCHEMATIC::ConvertRefsToKIIDs(), NETLIST_EXPORTER_BASE::CreatePinList(), DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS(), SCH_EDITOR_CONTROL::EditWithLibEdit(), NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol(), SCH_EDITOR_CONTROL::FindComponentAndItem(), NETLIST_EXPORTER_BASE::findNextSymbol(), SCH_PIN::GetDefaultNetName(), SCH_PIN::GetMsgPanelInfo(), GetMsgPanelInfo(), SCH_SHEET_PATH::GetSymbols(), DIALOG_CHANGE_SYMBOLS::isMatch(), NETLIST_EXPORTER_XML::makeListOfNets(), NETLIST_EXPORTER_XML::makeSymbols(), SCH_EDIT_FRAME::mapExistingAnnotation(), SCH_FIELD::Matches(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), SCH_EDIT_TOOL::Properties(), SCH_FIELD::Replace(), ResolveTextVar(), SCH_REFERENCE::SCH_REFERENCE(), ERC_TESTER::TestMultiunitFootprints(), ERC_TESTER::TestMultUnitPinConflicts(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), SCH_SHEET_PATH::UpdateAllScreenReferences(), DIALOG_SCH_EDIT_ONE_FIELD::UpdateField(), NETLIST_EXPORTER_CADSTAR::writeListOfNets(), NETLIST_EXPORTER_ORCADPCB2::WriteNetlist(), and NETLIST_EXPORTER_CADSTAR::WriteNetlist().

◆ GetSchSymbolLibraryName()

wxString SCH_COMPONENT::GetSchSymbolLibraryName ( ) const

Definition at line 232 of file sch_component.cpp.

233 {
234  if( !m_schLibSymbolName.IsEmpty() )
235  return m_schLibSymbolName;
236  else
237  return m_lib_id.Format().wx_str();
238 }
wxString m_schLibSymbolName
The name used to look up a symbol in the symbol library embedded in a schematic.
UTF8 Format() const
Definition: lib_id.cpp:237
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
Definition: sch_component.h:83
wxString wx_str() const
Definition: utf8.cpp:51

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

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

◆ GetSelectMenuText()

wxString SCH_COMPONENT::GetSelectMenuText ( EDA_UNITS  aUnits) const
overridevirtual

Function GetSelectMenuText returns 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 1602 of file sch_component.cpp.

1603 {
1604  return wxString::Format( _( "Symbol %s [%s]" ),
1605  GetField( REFERENCE_FIELD )->GetShownText(),
1606  GetLibId().GetLibItemName().wx_str() );
1607 }
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
SCH_FIELD * GetField(int aFieldNdx)
Returns a field in this symbol.
#define _(s)
Definition: 3d_actions.cpp:33
const LIB_ID & GetLibId() const
Field Reference of part, i.e. "IC21".

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

Referenced by Matches().

◆ GetState()

int EDA_ITEM::GetState ( int  type) const
inlineinherited

Definition at line 204 of file eda_item.h.

205  {
206  return m_status & type;
207  }
STATUS_FLAGS m_status
Definition: eda_item.h:161

References EDA_ITEM::m_status.

Referenced by TRACK::GetMsgPanelInfoBase_Common(), and TRACK::IsLocked().

◆ GetStatus()

STATUS_FLAGS EDA_ITEM::GetStatus ( ) const
inlineinherited

Definition at line 217 of file eda_item.h.

217 { return m_status; }
STATUS_FLAGS m_status
Definition: eda_item.h:161

References EDA_ITEM::m_status.

◆ GetStoredPos()

wxPoint& SCH_ITEM::GetStoredPos ( )
inlineinherited

Definition at line 249 of file sch_item.h.

249 { return m_storedPos; }
wxPoint m_storedPos
Definition: sch_item.h:202

References SCH_ITEM::m_storedPos.

Referenced by SCH_MOVE_TOOL::moveItem().

◆ GetStroke()

virtual STROKE_PARAMS SCH_ITEM::GetStroke ( ) const
inlinevirtualinherited

Reimplemented in SCH_LINE, and SCH_BUS_ENTRY_BASE.

Definition at line 486 of file sch_item.h.

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

◆ GetTransform()

◆ GetUnit()

◆ GetUnitCount()

int SCH_COMPONENT::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 346 of file sch_component.cpp.

347 {
348  if( m_part )
349  return m_part->GetUnitCount();
350 
351  return 0;
352 }
std::unique_ptr< LIB_PART > m_part

References m_part.

Referenced by NETLIST_EXPORTER_XML::addSymbolFields(), SCH_EDIT_FRAME::AnnotateComponents(), GetRef(), SCH_FIELD::GetShownText(), SCH_EDIT_FRAME::mapExistingAnnotation(), SCH_FIELD::Matches(), SCH_DRAWING_TOOLS::PlaceComponent(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), and DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow().

◆ GetUnitSelection()

int SCH_COMPONENT::GetUnitSelection ( const SCH_SHEET_PATH aSheet) const

Definition at line 536 of file sch_component.cpp.

537 {
538  KIID_PATH path = aSheet->Path();
539 
540  for( const SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
541  {
542  if( instance.m_Path == path )
543  return instance.m_Unit;
544  }
545 
546  // If it was not found in m_Paths array, then use m_unit. This will happen if we load a
547  // version 1 schematic file.
548  return m_unit;
549 }
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
A simple container for schematic symbol instance infromation.
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:84
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences

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

Referenced by SCH_EDIT_FRAME::AnnotateComponents(), KIGFX::SCH_PAINTER::draw(), GetPins(), SCH_EDIT_FRAME::mapExistingAnnotation(), ResolveTextVar(), SCH_REFERENCE::SCH_REFERENCE(), and SCH_SHEET_PATH::UpdateAllScreenReferences().

◆ GetValue()

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

Definition at line 571 of file sch_component.cpp.

572 {
573  KIID_PATH path = sheet->Path();
574 
575  for( const SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
576  {
577  if( instance.m_Path == path && !instance.m_Value.IsEmpty() )
578  {
579  // This can only be an override from an Update Schematic from PCB, and therefore
580  // will always be fully resolved.
581  return instance.m_Value;
582  }
583  }
584 
585  if( !aResolve )
586  return GetField( VALUE_FIELD )->GetText();
587 
588  return GetField( VALUE_FIELD )->GetShownText();
589 }
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:104
Field Value of part, i.e. "3.3K".
A simple container for schematic symbol instance infromation.
SCH_FIELD * GetField(int aFieldNdx)
Returns a field in this symbol.
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133

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

Referenced by NETLIST_EXPORTER_XML::addSymbolFields(), SCH_EDIT_FRAME::AnnotateComponents(), DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS(), SCH_PIN::GetMsgPanelInfo(), GetMsgPanelInfo(), DIALOG_CHANGE_SYMBOLS::isMatch(), ResolveTextVar(), SCH_REFERENCE::SCH_REFERENCE(), SCH_SHEET_PATH::UpdateAllScreenReferences(), NETLIST_EXPORTER_ORCADPCB2::WriteNetlist(), and NETLIST_EXPORTER_CADSTAR::WriteNetlist().

◆ HasBrightenedPins()

bool SCH_COMPONENT::HasBrightenedPins ( )

Definition at line 1840 of file sch_component.cpp.

1841 {
1842  for( const auto& pin : m_pins )
1843  {
1844  if( pin->IsBrightened() )
1845  return true;
1846  }
1847 
1848  return false;
1849 }
std::vector< std::unique_ptr< SCH_PIN > > m_pins

References m_pins.

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

484 { return false; }

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

◆ HitTest() [1/2]

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

Function HitTest tests if aPosition is contained within or on the bounding box of an 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 1764 of file sch_component.cpp.

1765 {
1766  EDA_RECT bBox = GetBodyBoundingBox();
1767  bBox.Inflate( aAccuracy );
1768 
1769  if( bBox.Contains( aPosition ) )
1770  return true;
1771 
1772  return false;
1773 }
bool Contains(const wxPoint &aPoint) const
Function Contains.
Definition: eda_rect.cpp:57
EDA_RECT GetBodyBoundingBox() const
Return a bounding box for the symbol body but not the fields.
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:363

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

◆ HitTest() [2/2]

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

Function HitTest tests if aRect intersects or is contained within the bounding box of an 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 1776 of file sch_component.cpp.

1777 {
1779  return false;
1780 
1781  EDA_RECT rect = aRect;
1782 
1783  rect.Inflate( aAccuracy );
1784 
1785  if( aContained )
1786  return rect.Contains( GetBodyBoundingBox() );
1787 
1788  return rect.Intersects( GetBodyBoundingBox() );
1789 }
bool Contains(const wxPoint &aPoint) const
Function Contains.
Definition: eda_rect.cpp:57
EDA_RECT GetBodyBoundingBox() const
Return a bounding box for the symbol body but not the fields.
#define STRUCT_DELETED
flag indication structures to be erased
Definition: eda_item.h:115
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
Definition: eda_rect.cpp:150
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: eda_item.h:117
STATUS_FLAGS m_flags
Definition: eda_item.h:164
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:363

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

◆ Init()

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

Definition at line 178 of file sch_component.cpp.

179 {
180  m_pos = pos;
181  m_unit = 1; // In multi unit chip - which unit to draw.
182  m_convert = LIB_ITEM::LIB_CONVERT::BASE; // De Morgan Handling
183 
184  // The rotation/mirror transformation matrix. pos normal
186 
187  // construct only the mandatory fields, which are the first 4 only.
188  for( int i = 0; i < MANDATORY_FIELDS; ++i )
189  {
190  m_fields.emplace_back( pos, i, this, TEMPLATE_FIELDNAME::GetDefaultFieldName( i ) );
191 
192  if( i == REFERENCE_FIELD )
193  m_fields.back().SetLayer( LAYER_REFERENCEPART );
194  else if( i == VALUE_FIELD )
195  m_fields.back().SetLayer( LAYER_VALUEPART );
196  else
197  m_fields.back().SetLayer( LAYER_FIELDS );
198  }
199 
200  m_prefix = wxString( wxT( "U" ) );
201  m_isInNetlist = true;
202  m_inBom = true;
203  m_onBoard = true;
204 }
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
bool m_onBoard
True to include in netlist when updating board.
Field Value of part, i.e. "3.3K".
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
bool m_isInNetlist
True if the component should appear in the netlist.
static const wxString GetDefaultFieldName(int aFieldNdx, bool aTranslate=true)
Function GetDefaultFieldName returns a default symbol field name for field aFieldNdx for all componen...
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:84
bool m_inBom
True to include in bill of materials export.
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:85
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is.
Definition: sch_component.h:88
Field Reference of part, i.e. "IC21".
TRANSFORM m_transform
The rotation/mirror transformation matrix.
SCH_FIELDS m_fields
Variable length list of fields.

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

◆ InitializeConnection()

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

Creates a new connection object associated with this object.

Parameters
aPathis the sheet path to initialize

Definition at line 176 of file sch_item.cpp.

178 {
179  SCH_CONNECTION* connection = Connection( &aSheet );
180 
181  if( connection )
182  {
183  connection->Reset();
184  }
185  else
186  {
187  connection = new SCH_CONNECTION( this );
188  m_connection_map.insert( std::make_pair( aSheet, connection ) );
189  connection->SetGraph( aGraph );
190  }
191 
192  connection->SetSheet( aSheet );
193  return connection;
194 }
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:131
void Reset()
Clears connectivity information.
void SetGraph(CONNECTION_GRAPH *aGraph)
std::unordered_map< SCH_SHEET_PATH, SCH_CONNECTION * > m_connection_map
Stores connectivity information, per sheet.
Definition: sch_item.h:209
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).

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

Referenced by CONNECTION_GRAPH::buildConnectionGraph().

◆ IsAnnotated()

bool SCH_COMPONENT::IsAnnotated ( const SCH_SHEET_PATH aSheet)

Checks if the component has a valid annotation (reference) for the given sheet path.

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

Definition at line 522 of file sch_component.cpp.

523 {
524  KIID_PATH path = aSheet->Path();
525 
526  for( const SYMBOL_INSTANCE_REFERENCE& instance : m_instanceReferences )
527  {
528  if( instance.m_Path == path )
529  return instance.m_Reference.Last() != '?';
530  }
531 
532  return false;
533 }
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
A simple container for schematic symbol instance infromation.
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences

References m_instanceReferences, and SCH_SHEET_PATH::Path().

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

◆ IsBrightened()

◆ IsConnectable()

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

Reimplemented from SCH_ITEM.

Definition at line 615 of file sch_component.h.

615 { return true; }

◆ IsConnected()

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

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

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

Definition at line 122 of file sch_item.cpp.

123 {
124  if(( m_flags & STRUCT_DELETED ) || ( m_flags & SKIP_STRUCT ) )
125  return false;
126 
127  return doIsConnected( aPosition );
128 }
#define STRUCT_DELETED
flag indication structures to be erased
Definition: eda_item.h:115
virtual bool doIsConnected(const wxPoint &aPosition) const
Provide the object specific test to see if it is connected to aPosition.
Definition: sch_item.h:513
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: eda_item.h:117
STATUS_FLAGS m_flags
Definition: eda_item.h:164

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

Referenced by SCH_SCREEN::IsTerminalPoint().

◆ IsConnectivityDirty()

bool SCH_ITEM::IsConnectivityDirty ( )
inlineinherited

Definition at line 444 of file sch_item.h.

444 { return m_connectivity_dirty; }
bool m_connectivity_dirty
Definition: sch_item.h:211

References SCH_ITEM::m_connectivity_dirty.

◆ IsDangling()

virtual bool SCH_ITEM::IsDangling ( ) const
inlinevirtualinherited

Reimplemented in SCH_TEXT, SCH_LINE, SCH_BUS_ENTRY_BASE, and SCH_PIN.

Definition at line 376 of file sch_item.h.

376 { return false; }

◆ IsDragging()

bool EDA_ITEM::IsDragging ( ) const
inlineinherited

Definition at line 189 of file eda_item.h.

189 { return m_flags & IS_DRAGGED; }
#define IS_DRAGGED
Item being dragged.
Definition: eda_item.h:108
STATUS_FLAGS m_flags
Definition: eda_item.h:164

References IS_DRAGGED, and EDA_ITEM::m_flags.

Referenced by DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES(), and KIGFX::SCH_PAINTER::setDeviceColors().

◆ IsForceVisible()

bool EDA_ITEM::IsForceVisible ( ) const
inlineinherited

Definition at line 274 of file eda_item.h.

274 { return m_forceVisible; }
bool m_forceVisible
Definition: eda_item.h:163

References EDA_ITEM::m_forceVisible.

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

◆ IsHypertext()

virtual bool SCH_ITEM::IsHypertext ( ) const
inlinevirtualinherited

Allows items to support hypertext actions when hovered/clicked.

Reimplemented in SCH_FIELD.

Definition at line 278 of file sch_item.h.

278 { return false; }

◆ IsInNetlist()

bool SCH_COMPONENT::IsInNetlist ( ) const
Returns
true if the component is in netlist which means this is not a power component, or something like a component reference starting by #

Definition at line 1817 of file sch_component.cpp.

1818 {
1819  return m_isInNetlist;
1820 }
bool m_isInNetlist
True if the component should appear in the netlist.

References m_isInNetlist.

Referenced by AUTOPLACER::AUTOPLACER().

◆ IsLocked()

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

Definition at line 268 of file sch_item.h.

268 { return false; }

Referenced by SCH_EDIT_TOOL::DeleteItemCursor().

◆ IsModified()

bool EDA_ITEM::IsModified ( ) const
inlineinherited

Definition at line 186 of file eda_item.h.

186 { return m_flags & IS_CHANGED; }
#define IS_CHANGED
std::function passed to nested users by ref, avoids copying std::function
Definition: eda_item.h:102
STATUS_FLAGS m_flags
Definition: eda_item.h:164

References IS_CHANGED, and EDA_ITEM::m_flags.

Referenced by PCB_EDIT_FRAME::OpenProjectFiles().

◆ IsMovableFromAnchorPoint()

bool SCH_COMPONENT::IsMovableFromAnchorPoint ( )
inlineoverridevirtual

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

Note: we used to try and be smart about this and return false for components 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 components.

Returns
true for a component

Reimplemented from SCH_ITEM.

Definition at line 185 of file sch_component.h.

185 { return true; }

◆ IsMoving()

◆ IsNew()

◆ IsPointClickableAnchor()

virtual bool SCH_ITEM::IsPointClickableAnchor ( const wxPoint &  aPos) const
inlinevirtualinherited
Returns
true if the given point can start drawing (usually means the anchor is unused/free/dangling)

Reimplemented in SCH_HIERLABEL, SCH_GLOBALLABEL, SCH_LABEL, SCH_LINE, SCH_SHEET_PIN, SCH_JUNCTION, and SCH_PIN.

Definition at line 388 of file sch_item.h.

388 { return false; }

Referenced by EE_SELECTION_TOOL::GuessSelectionCandidates().

◆ IsReferenceStringValid()

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

Tests 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 451 of file sch_component.cpp.

452 {
453  wxString text = aReferenceString;
454  bool ok = true;
455 
456  // Try to unannotate this reference
457  while( !text.IsEmpty() && ( text.Last() == '?' || wxIsdigit( text.Last() ) ) )
458  text.RemoveLast();
459 
460  if( text.IsEmpty() )
461  ok = false;
462 
463  return ok;
464 }

Referenced by ClearAnnotation(), SetRef(), DIALOG_EDIT_ONE_FIELD::TransferDataFromWindow(), DIALOG_SYMBOL_PROPERTIES::Validate(), and DIALOG_LIB_SYMBOL_PROPERTIES::Validate().

◆ IsReplaceable()

bool SCH_COMPONENT::IsReplaceable ( ) const
inlineoverridevirtual

Function IsReplaceable.

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 657 of file sch_component.h.

657 { return true; }

◆ IsResized()

bool EDA_ITEM::IsResized ( ) const
inlineinherited

Definition at line 192 of file eda_item.h.

192 { return m_flags & IS_RESIZED; }
#define IS_RESIZED
Item being resized.
Definition: eda_item.h:107
STATUS_FLAGS m_flags
Definition: eda_item.h:164

References IS_RESIZED, and EDA_ITEM::m_flags.

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

◆ IsSelected()

◆ IsType()

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

Function IsType Checks 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 VIA, SCH_LABEL, DIMENSION_BASE, PAD, PCB_SHAPE, SCH_FIELD, SCH_LINE, FP_TEXT, FP_SHAPE, and PCB_TEXT.

Definition at line 250 of file eda_item.h.

251  {
252  if( aScanTypes[0] == SCH_LOCATE_ANY_T )
253  return true;
254 
255  for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
256  {
257  if( m_structType == *p )
258  return true;
259  }
260 
261  return false;
262  }
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
KICAD_T m_structType
Run time identification, keep private so it can never be changed after a ctor sets it.
Definition: eda_item.h:158

References EOT, EDA_ITEM::m_structType, and SCH_LOCATE_ANY_T.

Referenced by SCH_LINE_WIRE_BUS_TOOL::IsDrawingBus(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingLine(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingWire(), PCB_TEXT::IsType(), FP_SHAPE::IsType(), FP_TEXT::IsType(), SCH_LINE::IsType(), SCH_FIELD::IsType(), PCB_SHAPE::IsType(), PAD::IsType(), DIMENSION_BASE::IsType(), SCH_LABEL::IsType(), 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 190 of file eda_item.h.

190 { return m_flags & IS_WIRE_IMAGE; }
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.
Definition: eda_item.h:110
STATUS_FLAGS m_flags
Definition: eda_item.h:164

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

IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T )

IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T )

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

Definition at line 372 of file eda_item.h.

376  {
377  for( auto it : aList )
378  {
379  if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
381  return SEARCH_RESULT::QUIT;
382  }
383 
385  }
virtual SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
Function Visit may be re-implemented for each derived class in order to handle all the types given by...
Definition: eda_item.cpp:107

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

IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T )

IterateForward( EDA_ITEM*, INSPECTOR, void*, const KICAD_T )

This changes first parameter to avoid the DList and use std::vector instead

Definition at line 393 of file eda_item.h.

395  {
396  for( auto it : aList )
397  {
398  if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
400  return SEARCH_RESULT::QUIT;
401  }
402 
404  }
virtual SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
Function Visit may be re-implemented for each derived class in order to handle all the types given by...
Definition: eda_item.cpp:107

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

◆ Matches() [1/2]

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

Function Matches compares 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 132 of file eda_item.cpp.

133 {
134  wxString text = aText;
135  wxString searchText = aSearchData.GetFindString();
136 
137  // Don't match if searching for replaceable item and the item doesn't support text replace.
138  if( (aSearchData.GetFlags() & FR_SEARCH_REPLACE) && !IsReplaceable() )
139  return false;
140 
141  if( aSearchData.GetFlags() & wxFR_WHOLEWORD )
142  return aText.IsSameAs( searchText, aSearchData.GetFlags() & wxFR_MATCHCASE );
143 
144  if( aSearchData.GetFlags() & FR_MATCH_WILDCARD )
145  {
146  if( aSearchData.GetFlags() & wxFR_MATCHCASE )
147  return text.Matches( searchText );
148 
149  return text.MakeUpper().Matches( searchText.MakeUpper() );
150  }
151 
152  if( aSearchData.GetFlags() & wxFR_MATCHCASE )
153  return aText.Find( searchText ) != wxNOT_FOUND;
154 
155  return text.MakeUpper().Find( searchText.MakeUpper() ) != wxNOT_FOUND;
156 }
virtual bool IsReplaceable() const
Function IsReplaceable.
Definition: eda_item.h:490

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

◆ Matches() [2/2]

bool SCH_COMPONENT::Matches ( wxFindReplaceData &  aSearchData,
void *  aAuxData 
)
overridevirtual

Function Matches compares 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 1480 of file sch_component.cpp.

1481 {
1482  wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText( EDA_UNITS::MILLIMETRES ) );
1483 
1484  // Components are searchable via the child field and pin item text.
1485  return false;
1486 }
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
const wxChar *const traceFindItem
Flag to enable find debug tracing.

References GetSelectMenuText(), MILLIMETRES, and traceFindItem.

◆ MirrorX()

void SCH_COMPONENT::MirrorX ( int  aXaxis_position)
overridevirtual

Mirror item relative to the X axis about aXaxis_position.

Parameters
aXaxis_positionThe X axis position to mirror around.

Implements SCH_ITEM.

Definition at line 1443 of file sch_component.cpp.

1444 {
1445  int dy = m_pos.y;
1446 
1448  MIRROR( m_pos.y, aXaxis_position );
1449  dy -= m_pos.y; // dy,0 is the move vector for this transform
1450 
1451  for( SCH_FIELD& field : m_fields )
1452  {
1453  // Move the fields to the new position because the component itself has moved.
1454  wxPoint pos = field.GetTextPos();
1455  pos.y -= dy;
1456  field.SetTextPos( pos );
1457  }
1458 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:51
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:40
SCH_FIELDS m_fields
Variable length list of fields.
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...

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

◆ MirrorY()

void SCH_COMPONENT::MirrorY ( int  aYaxis_position)
overridevirtual

Mirror item relative to the Y axis about aYaxis_position.

Parameters
aYaxis_positionThe Y axis position to mirror around.

Implements SCH_ITEM.

Definition at line 1425 of file sch_component.cpp.

1426 {
1427  int dx = m_pos.x;
1428 
1430  MIRROR( m_pos.x, aYaxis_position );
1431  dx -= m_pos.x; // dx,0 is the move vector for this transform
1432 
1433  for( SCH_FIELD& field : m_fields )
1434  {
1435  // Move the fields to the new position because the component itself has moved.
1436  wxPoint pos = field.GetTextPos();
1437  pos.x -= dx;
1438  field.SetTextPos( pos );
1439  }
1440 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:51
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:40
SCH_FIELDS m_fields
Variable length list of fields.
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...

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

◆ Move()

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

Move the item by aMoveVector to a new position.

Parameters
aMoveVector= the displacement vector

Implements SCH_ITEM.

Definition at line 578 of file sch_component.h.

579  {
580  if( aMoveVector == wxPoint( 0, 0 ) )
581  return;
582 
583  m_pos += aMoveVector;
584 
585  for( SCH_FIELD& field : m_fields )
586  field.Move( aMoveVector );
587 
588  SetModified();
589  }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:51
void SetModified()
Definition: eda_item.cpp:79
SCH_FIELDS m_fields
Variable length list of fields.

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

146 {
147  if( m_connection_map.size() )
148  {
149  SCH_CONNECTION* connection = Connection( aSheet );
150 
151  if( connection )
152  {
153  NET_SETTINGS& netSettings = Schematic()->Prj().GetProjectFile().NetSettings();
154  const wxString& netclassName = netSettings.GetNetclassName( connection->Name() );
155 
156  return netSettings.m_NetClasses.Find( netclassName );
157  }
158  }
159 
160  return nullptr;
161 }
NETCLASSPTR Find(const wxString &aName) const
Function Find searches this container for a NETCLASS given by aName.
Definition: netclass.cpp:132
const wxString & GetNetclassName(const wxString &aNetName) const
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:97
NET_SETTINGS & NetSettings()
Definition: project_file.h:92
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:131
NETCLASSES m_NetClasses
Definition: net_settings.h:39
wxString Name(bool aIgnoreSheet=false) const
VTBL_ENTRY PROJECT_FILE & GetProjectFile() const
Definition: project.h:143
NET_SETTINGS stores various net-related settings in a project context.
Definition: net_settings.h:31
std::unordered_map< SCH_SHEET_PATH, SCH_CONNECTION * > m_connection_map
Stores connectivity information, per sheet.
Definition: sch_item.h:209
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
PROJECT & Prj() const
Return a reference to the project this schematic is part of.
Definition: schematic.h:85

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_COMPONENT::operator!= ( const SCH_COMPONENT aComponent) const

Definition at line 1721 of file sch_component.cpp.

1722 {
1723  return !( *this == aComponent );
1724 }

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

186 {
187  wxFAIL_MSG( wxString::Format( wxT( "Less than operator not defined for item type %s." ),
188  GetClass() ) );
189 
190  return false;
191 }
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
virtual wxString GetClass() const =0
Function GetClass returns the class name.

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

◆ operator<() [2/2]

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

Reimplemented from SCH_ITEM.

Definition at line 1684 of file sch_component.cpp.

1685 {
1686  if( Type() != aItem.Type() )
1687  return Type() < aItem.Type();
1688 
1689  auto component = static_cast<const SCH_COMPONENT*>( &aItem );
1690 
1691  EDA_RECT rect = GetBodyBoundingBox();
1692 
1693  if( rect.GetArea() != component->GetBodyBoundingBox().GetArea() )
1694  return rect.GetArea() < component->GetBodyBoundingBox().GetArea();
1695 
1696  if( m_pos.x != component->m_pos.x )
1697  return m_pos.x < component->m_pos.x;
1698 
1699  if( m_pos.y != component->m_pos.y )
1700  return m_pos.y < component->m_pos.y;
1701 
1702  return m_Uuid < aItem.m_Uuid; // Ensure deterministic sort
1703 }
EDA_RECT GetBodyBoundingBox() const
Return a bounding box for the symbol body but not the fields.
double GetArea() const
Function GetArea returns the area of the rectangle.
Definition: eda_rect.cpp:481
const KIID m_Uuid
Definition: eda_item.h:151
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181

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

◆ operator=()

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

Definition at line 1727 of file sch_component.cpp.

1728 {
1729  wxCHECK_MSG( Type() == aItem.Type(), *this,
1730  wxT( "Cannot assign object type " ) + aItem.GetClass() + wxT( " to type " ) +
1731  GetClass() );
1732 
1733  if( &aItem != this )
1734  {
1735  SCH_ITEM::operator=( aItem );
1736 
1737  SCH_COMPONENT* c = (SCH_COMPONENT*) &aItem;
1738 
1739  m_lib_id = c->m_lib_id;
1740 
1741  LIB_PART* libSymbol = c->m_part ? new LIB_PART( *c->m_part.get() ) : nullptr;
1742 
1743  m_part.reset( libSymbol );
1744  m_pos = c->m_pos;
1745  m_unit = c->m_unit;
1746  m_convert = c->m_convert;
1747  m_transform = c->m_transform;
1748 
1750 
1751  m_fields = c->m_fields; // std::vector's assignment operator
1752 
1753  // Reparent fields after assignment to new component.
1754  for( SCH_FIELD& field : m_fields )
1755  field.SetParent( this );
1756 
1757  UpdatePins();
1758  }
1759 
1760  return *this;
1761 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:51
Define a library symbol object.
std::unique_ptr< LIB_PART > m_part
EDA_ITEM & operator=(const EDA_ITEM &aItem)
Operator assignment is used to assign the members of aItem to another object.
Definition: eda_item.cpp:193
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:84
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
Definition: sch_component.h:83
Schematic symbol object.
Definition: sch_component.h:79
virtual wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_item.h:220
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:85
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
wxString GetClass() const override
Function GetClass returns the class name.
TRANSFORM m_transform
The rotation/mirror transformation matrix.
SCH_FIELDS m_fields
Variable length list of fields.
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181

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

◆ operator==()

bool SCH_COMPONENT::operator== ( const SCH_COMPONENT aComponent) const

Definition at line 1706 of file sch_component.cpp.

1707 {
1708  if( GetFieldCount() != aComponent.GetFieldCount() )
1709  return false;
1710 
1711  for( int i = VALUE_FIELD; i < GetFieldCount(); i++ )
1712  {
1713  if( GetField( i )->GetText().Cmp( aComponent.GetField( i )->GetText() ) != 0 )
1714  return false;
1715  }
1716 
1717  return true;
1718 }
Field Value of part, i.e. "3.3K".
int GetFieldCount() const
Return the number of fields in this symbol.
SCH_FIELD * GetField(int aFieldNdx)
Returns a field in this symbol.
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133

References GetField(), GetFieldCount(), EDA_TEXT::GetText(), and VALUE_FIELD.

◆ Plot()

void SCH_COMPONENT::Plot ( PLOTTER aPlotter)
overridevirtual

Plot the schematic item to aPlotter.

Parameters
aPlotterA pointer to a PLOTTER object.

Reimplemented from SCH_ITEM.

Definition at line 1823 of file sch_component.cpp.

1824 {
1825  if( m_part )
1826  {
1827  TRANSFORM temp = GetTransform();
1828  aPlotter->StartBlock( nullptr );
1829 
1830  m_part->Plot( aPlotter, GetUnit(), GetConvert(), m_pos, temp );
1831 
1832  for( SCH_FIELD field : m_fields )
1833  field.Plot( aPlotter );
1834 
1835  aPlotter->EndBlock( nullptr );
1836  }
1837 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:51
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:493
virtual void StartBlock(void *aData)
calling this function allows one to define the beginning of a group of drawing items,...
Definition: plotter.h:484
int GetUnit() const
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
TRANSFORM & GetTransform() const
std::unique_ptr< LIB_PART > m_part
int GetConvert() const
SCH_FIELDS m_fields
Variable length list of fields.

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

◆ Print()

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

Print a component.

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 355 of file sch_component.cpp.

356 {
357  PART_DRAW_OPTIONS opts;
358  opts.transform = m_transform;
359  opts.draw_visible_fields = false;
360  opts.draw_hidden_fields = false;
361 
362  if( m_part )
363  {
364  m_part->Print( aSettings, m_pos + aOffset, m_unit, m_convert, opts );
365  }
366  else // Use dummy() part if the actual cannot be found.
367  {
368  dummy()->Print( aSettings, m_pos + aOffset, 0, 0, opts );
369  }
370 
371  for( SCH_FIELD& field : m_fields )
372  field.Print( aSettings, aOffset );
373 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:51
std::unique_ptr< LIB_PART > m_part
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:84
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
void Print(RENDER_SETTINGS *aSettings, const wxPoint &aOffset, int aMulti, int aConvert, const PART_DRAW_OPTIONS &aOpts)
Print part.
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:85
TRANSFORM m_transform
The rotation/mirror transformation matrix.
SCH_FIELDS m_fields
Variable length list of fields.

References PART_DRAW_OPTIONS::draw_hidden_fields, PART_DRAW_OPTIONS::draw_visible_fields, dummy(), m_convert, m_fields, m_part, m_pos, m_transform, m_unit, LIB_PART::Print(), and PART_DRAW_OPTIONS::transform.

◆ RemoveField()

void SCH_COMPONENT::RemoveField ( const wxString &  aFieldName)

Removes 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 720 of file sch_component.cpp.

721 {
722  for( unsigned i = MANDATORY_FIELDS; i < m_fields.size(); ++i )
723  {
724  if( aFieldName == m_fields[i].GetName( false ) )
725  {
726  m_fields.erase( m_fields.begin() + i );
727  return;
728  }
729  }
730 }
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
SCH_FIELDS m_fields
Variable length list of fields.

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 ( wxFindReplaceData &  aSearchData,
wxString &  aText 
)
staticinherited

Helper function used in search and replace dialog Function Replace performs 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 159 of file eda_item.cpp.

160 {
161  wxString searchString = (aSearchData.GetFlags() & wxFR_MATCHCASE) ? aText : aText.Upper();
162 
163  int result = searchString.Find( (aSearchData.GetFlags() & wxFR_MATCHCASE) ?
164  aSearchData.GetFindString() :
165  aSearchData.GetFindString().Upper() );
166 
167  if( result == wxNOT_FOUND )
168  return false;
169 
170  wxString prefix = aText.Left( result );
171  wxString suffix;
172 
173  if( aSearchData.GetFindString().length() + result < aText.length() )
174  suffix = aText.Right( aText.length() - ( aSearchData.GetFindString().length() + result ) );
175 
176  wxLogTrace( traceFindReplace, wxT( "Replacing '%s', prefix '%s', replace '%s', suffix '%s'." ),
177  aText, prefix, aSearchData.GetReplaceString(), suffix );
178 
179  aText = prefix + aSearchData.GetReplaceString() + suffix;
180 
181  return true;
182 }
const wxChar *const traceFindReplace
Flag to enable find and replace debug tracing.

References traceFindReplace.

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

◆ Replace() [2/2]

virtual bool EDA_ITEM::Replace ( wxFindReplaceData &  aSearchData,
void *  aAuxData = NULL 
)
inlinevirtualinherited

Function Replace performs 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_SHEET_PIN, SCH_FIELD, and SCH_PIN.

Definition at line 478 of file eda_item.h.

478 { return false; }

◆ ReplaceInstanceSheetPath()

bool SCH_COMPONENT::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 1053 of file sch_component.cpp.

1055 {
1056  auto it = std::find_if( m_instanceReferences.begin(), m_instanceReferences.end(),
1057  [ aOldSheetPath ]( SYMBOL_INSTANCE_REFERENCE& r )->bool
1058  {
1059  return aOldSheetPath == r.m_Path;
1060  }
1061  );
1062 
1063  if( it != m_instanceReferences.end() )
1064  {
1065  wxLogTrace( traceSchSheetPaths,
1066  "Replacing sheet path %s\n with sheet path %s\n for symbol %s.",
1067  aOldSheetPath.AsString(), aNewSheetPath.AsString(), m_Uuid.AsString() );
1068 
1069  it->m_Path = aNewSheetPath;
1070  return true;
1071  }
1072 
1073  wxLogTrace( traceSchSheetPaths,
1074  "Could not find sheet path %s\n to replace with sheet path %s\n for symbol %s.",
1075  aOldSheetPath.AsString(), aNewSheetPath.AsString(), m_Uuid.AsString() );
1076 
1077  return false;
1078 }
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
wxString AsString() const
Definition: kiid.cpp:174
A simple container for schematic symbol instance infromation.
const KIID m_Uuid
Definition: eda_item.h:151
wxString AsString() const
Definition: kiid.cpp:206
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences

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

◆ ResolveTextVar()

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

Resolve any references to system tokens supported by the component.

Parameters
aDeptha counter to limit recursion and circular references.

Definition at line 914 of file sch_component.cpp.

915 {
916  SCHEMATIC* schematic = Schematic();
917 
918  for( int i = 0; i < MANDATORY_FIELDS; ++i )
919  {
920  if( token->IsSameAs( m_fields[ i ].GetCanonicalName().Upper() ) )
921  {
922  if( i == REFERENCE_FIELD && schematic )
923  *token = GetRef( &schematic->CurrentSheet(), true );
924  else if( i == VALUE_FIELD && schematic )
925  *token = GetValue( &schematic->CurrentSheet(), true );
926  else if( i == FOOTPRINT_FIELD && schematic )
927  *token = GetFootprint( &schematic->CurrentSheet(), true );
928  else
929  *token = m_fields[ i ].GetShownText( aDepth + 1 );
930 
931  return true;
932  }
933  }
934 
935  for( size_t i = MANDATORY_FIELDS; i < m_fields.size(); ++i )
936  {
937  if( token->IsSameAs( m_fields[ i ].GetName() )
938  || token->IsSameAs( m_fields[ i ].GetName().Upper() ) )
939  {
940  *token = m_fields[ i ].GetShownText( aDepth + 1 );
941  return true;
942  }
943  }
944 
945  if( token->IsSameAs( wxT( "FOOTPRINT_LIBRARY" ) ) )
946  {
947  wxString footprint;
948 
949  if( schematic )
950  footprint = GetFootprint( &schematic->CurrentSheet(), true );
951  else
952  footprint = m_fields[ FOOTPRINT_FIELD ].GetShownText();
953 
954  wxArrayString parts = wxSplit( footprint, ':' );
955 
956  *token = parts[ 0 ];
957  return true;
958  }
959  else if( token->IsSameAs( wxT( "FOOTPRINT_NAME" ) ) )
960  {
961  wxString footprint;
962 
963  if( schematic )
964  footprint = GetFootprint( &schematic->CurrentSheet(), true );
965  else
966  footprint = m_fields[ FOOTPRINT_FIELD ].GetShownText();
967 
968  wxArrayString parts = wxSplit( footprint, ':' );
969 
970  *token = parts[ std::min( 1, (int) parts.size() - 1 ) ];
971  return true;
972  }
973  else if( token->IsSameAs( wxT( "UNIT" ) ) )
974  {
975  int unit;
976 
977  if( schematic )
978  unit = GetUnitSelection( &schematic->CurrentSheet() );
979  else
980  unit = GetUnit();
981 
982  *token = LIB_PART::SubReference( unit );
983  return true;
984  }
985 
986  return false;
987 }
Holds all the data relating to one schematic A schematic may consist of one or more sheets (and one r...
Definition: schematic.h:44
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:97
Field Value of part, i.e. "3.3K".
const wxString GetFootprint(const SCH_SHEET_PATH *sheet, bool aResolve) const
int GetUnit() const
const wxString GetValue(const SCH_SHEET_PATH *sheet, bool aResolve) const
Field Name Module PCB, i.e. "16DIP300".
static wxString SubReference(int aUnit, bool aAddSeparator=true)
Field Reference of part, i.e. "IC21".
SCH_FIELDS m_fields
Variable length list of fields.
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
SCH_SHEET_PATH & CurrentSheet() const
Definition: schematic.h:127

References SCHEMATIC::CurrentSheet(), FOOTPRINT_FIELD, GetFootprint(), GetRef(), GetUnit(), GetUnitSelection(), GetValue(), m_fields, MANDATORY_FIELDS, REFERENCE_FIELD, SCH_ITEM::Schematic(), LIB_PART::SubReference(), and VALUE_FIELD.

Referenced by SCHEMATIC::ConvertRefsToKIIDs(), SCH_FIELD::GetShownText(), and SCHEMATIC::ResolveCrossReference().

◆ Rotate()

void SCH_COMPONENT::Rotate ( wxPoint  aPosition)
overridevirtual

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

Parameters
aPositionA reference to a wxPoint object containing the coordinates to rotate around.

Implements SCH_ITEM.

Definition at line 1461 of file sch_component.cpp.

1462 {
1463  wxPoint prev = m_pos;
1464 
1465  RotatePoint( &m_pos, aPosition, 900 );
1466 
1468 
1469  for( SCH_FIELD& field : m_fields )
1470  {
1471  // Move the fields to the new position because the component itself has moved.
1472  wxPoint pos = field.GetTextPos();
1473  pos.x -= prev.x - m_pos.x;
1474  pos.y -= prev.y - m_pos.y;
1475  field.SetTextPos( pos );
1476  }
1477 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:51
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
SCH_FIELDS m_fields
Variable length list of fields.
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...

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

◆ RunOnChildren()

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

Reimplemented from SCH_ITEM.

Definition at line 803 of file sch_component.cpp.

804 {
805  for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
806  aFunction( pin.get() );
807 
808  for( SCH_FIELD& field : m_fields )
809  aFunction( &field );
810 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:51
std::vector< std::unique_ptr< SCH_PIN > > m_pins
SCH_FIELDS m_fields
Variable length list of fields.

References m_fields, and m_pins.

◆ 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 that this hierarchy is not the same as the sheet hierarchy!

Returns
the parent schematic this item lives on, or nullptr

Definition at line 97 of file sch_item.cpp.

98 {
99  EDA_ITEM* parent = GetParent();
100 
101  while( parent )
102  {
103  if( parent->Type() == SCHEMATIC_T )
104  return static_cast<SCHEMATIC*>( parent );
105  else
106  parent = parent->GetParent();
107  }
108 
109  return nullptr;
110 }
EDA_ITEM * GetParent() const
Definition: eda_item.h:183
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181

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

Referenced by SCH_ITEM::Connection(), SCH_DRAWING_TOOLS::createSheetPin(), DIALOG_SCH_EDIT_ONE_FIELD::DIALOG_SCH_EDIT_ONE_FIELD(), SCH_FIELD::DoHypertextMenu(), SCH_MARKER::GetColorLayer(), SCH_JUNCTION::getEffectiveShape(), SCH_LINE::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), SCH_NO_CONNECT::GetPenWidth(), SCH_BUS_WIRE_ENTRY::GetPenWidth(), SCH_LINE::GetPenWidth(), SCH_BUS_BUS_ENTRY::GetPenWidth(), GetPins(), SCH_FIELD::GetShownText(), SCH_TEXT::GetShownText(), SCH_TEXT::GetTextOffset(), inheritNetclass(), SCH_SHEET::IsRootSheet(), SCH_LABEL::IsType(), SCH_ITEM::NetClass(), DIALOG_SYMBOL_PROPERTIES::OnAddField(), DIALOG_LABEL_EDITOR::onScintillaCharAdded(), DIALOG_SCH_EDIT_ONE_FIELD::onScintillaCharAdded(), SCH_HIERLABEL::Print(), ResolveTextVar(), SCH_SHEET::ResolveTextVar(), SCH_GLOBALLABEL::ResolveTextVar(), DIALOG_SCH_EDIT_ONE_FIELD::UpdateField(), and SCH_MARKER::ViewGetLayers().

◆ Set() [1/3]

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

Definition at line 40 of file inspectable.h.

41  {
43  TYPE_ID thisType = TYPE_HASH( *this );
44  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
45 
46  if( object )
47  aProperty->setter( object, aValue );
48 
49  return object != nullptr;
50  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:64
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:55
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:41
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
virtual void setter(void *aObject, wxAny &aValue)=0
Provides class metadata.
Definition: property_mgr.h:61
virtual size_t OwnerHash() const =0
Returns 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 53 of file inspectable.h.

54  {
56  TYPE_ID thisType = TYPE_HASH( *this );
57  void* object = propMgr.TypeCast( this, thisType, aProperty->OwnerHash() );
58 
59  if( object )
60  aProperty->set<T>( object, aValue );
61 
62  return object != nullptr;
63  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:64
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:55
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:41
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
Provides class metadata.
Definition: property_mgr.h:61
void set(void *aObject, T aValue)
Definition: property.h:268
virtual size_t OwnerHash() const =0
Returns 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 66 of file inspectable.h.

67  {
69  TYPE_ID thisType = TYPE_HASH( *this );
70  PROPERTY_BASE* prop = propMgr.GetProperty( thisType, aProperty );
71  void* object = nullptr;
72 
73  if( prop )
74  {
75  object = propMgr.TypeCast( this, thisType, prop->OwnerHash() );
76 
77  if( object )
78  prop->set<T>( object, aValue );
79  }
80 
81  return object != nullptr;
82  }
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:64
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:55
size_t TYPE_ID
Unique type identifier
Definition: property_mgr.h:41
const void * TypeCast(const void *aSource, TYPE_ID aBase, TYPE_ID aTarget) const
Casts a type to another type.
PROPERTY_BASE * GetProperty(TYPE_ID aType, const wxString &aProperty) const
Returns a property for a specific type.
Provides class metadata.
Definition: property_mgr.h:61
void set(void *aObject, T aValue)
Definition: property.h:268
virtual size_t OwnerHash() const =0
Returns 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()

void EDA_ITEM::SetBrightened ( )
inlineinherited

◆ SetConnectivityDirty()

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

Definition at line 446 of file sch_item.h.

446 { m_connectivity_dirty = aDirty; }
bool m_connectivity_dirty
Definition: sch_item.h:211

References SCH_ITEM::m_connectivity_dirty.

Referenced by SCH_EDIT_FRAME::SaveCopyInUndoList().

◆ SetConvert()

void SCH_COMPONENT::SetConvert ( int  aConvert)

Definition at line 323 of file sch_component.cpp.

324 {
325  if( m_convert != aConvert )
326  {
327  m_convert = aConvert;
328 
329  // The convert may have a different pin layout so the update the pin map.
330  UpdatePins();
331  SetModified();
332  }
333 }
void SetModified()
Definition: eda_item.cpp:79
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:85
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.

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

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

◆ SetFields()

void SCH_COMPONENT::SetFields ( const SCH_FIELDS aFields)
inline

Set multiple schematic fields.

Parameters
aFieldsare the fields to set in this symbol.

Definition at line 429 of file sch_component.h.

430  {
431  m_fields = aFields; // vector copying, length is changed possibly
432  }
SCH_FIELDS m_fields
Variable length list of fields.

References m_fields.

◆ SetFlags()

void EDA_ITEM::SetFlags ( STATUS_FLAGS  aMask)
inlineinherited

Definition at line 220 of file eda_item.h.

220 { m_flags |= aMask; }
STATUS_FLAGS m_flags
Definition: eda_item.h:164

References EDA_ITEM::m_flags.

Referenced by SCH_EAGLE_PLUGIN::addBusEntries(), PCB_BASE_FRAME::AddFootprintToBoard(), SCH_MOVE_TOOL::AlignElements(), PCBNEW_CONTROL::AppendBoard(), FOOTPRINT::BuildPolyCourtyards(), SCH_EDIT_TOOL::ChangeTextType(), TRACKS_CLEANER::cleanup(), GRAPHICS_CLEANER::cleanupSegments(), ConvertOutlineToPolygon(), SCH_EDIT_FRAME::ConvertPart(), SCH_DRAWING_TOOLS::createNewText(), LIB_PIN_TOOL::CreatePin(), SCH_DRAWING_TOOLS::createSheetPin(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), KIGFX::SCH_PAINTER::draw(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SCH_EDIT_TOOL::Duplicate(), SCH_MOVE_TOOL::getConnectedDragItems(), SYMBOL_EDIT_FRAME::GetSymbolFromRedoList(), SYMBOL_EDIT_FRAME::GetSymbolFromUndoList(), EE_SELECTION_TOOL::Main(), EDIT_POINTS_FACTORY::Make(), TRACKS_CLEANER::mergeCollinearSegments(), LIB_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(), LIB_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), DRAWING_TOOL::PlaceText(), BACK_ANNOTATE::processNetNameChange(), SCH_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_PIN_TOOL::RepeatPin(), DRC_TEST_PROVIDER_HOLE_CLEARANCE::Run(), SYMBOL_EDIT_FRAME::SaveCopyInUndoList(), EE_SELECTION_TOOL::selectMultiple(), 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(), WS_DATA_ITEM::SyncDrawItems(), WS_DATA_ITEM_TEXT::SyncDrawItems(), DIALOG_DIMENSION_PROPERTIES::TransferDataFromWindow(), DIALOG_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), LIB_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ SetFootprint() [1/2]

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

Definition at line 642 of file sch_component.cpp.

643 {
644  if( sheet == nullptr )
645  {
646  // Clear instance overrides and set primary field value
648  instance.m_Footprint = wxEmptyString;
649 
650  m_fields[ FOOTPRINT_FIELD ].SetText( aFootprint );
651  return;
652  }
653 
654  KIID_PATH path = sheet->Path();
655 
656  // check to see if it is already there before inserting it
658  {
659  if( instance.m_Path == path )
660  {
661  instance.m_Footprint = aFootprint;
662  return;
663  }
664  }
665 
666  // didn't find it; better add it
667  AddHierarchicalReference( path, m_prefix, m_unit, wxEmptyString, aFootprint );
668 }
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
A simple container for schematic symbol instance infromation.
Field Name Module PCB, i.e. "16DIP300".
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:84
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
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.
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is.
Definition: sch_component.h:88
SCH_FIELDS m_fields
Variable length list of fields.

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

Referenced by BACK_ANNOTATE::applyChangelist(), FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData(), SCH_EDITOR_CONTROL::AssignFootprints(), SCH_EDITOR_CONTROL::processCmpToFootprintLinkFile(), DIALOG_CHANGE_SYMBOLS::processSymbol(), SetFootprint(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_SCH_EDIT_ONE_FIELD::UpdateField(), and SCH_EDITOR_CONTROL::updatePastedInstances().

◆ SetFootprint() [2/2]

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

Definition at line 571 of file sch_component.h.

572  {
573  SetFootprint( nullptr, aFootprint );
574  }
void SetFootprint(const SCH_SHEET_PATH *sheet, const wxString &aFootprint)

References SetFootprint().

◆ SetForceVisible()

void EDA_ITEM::SetForceVisible ( bool  aEnable)
inlineinherited

Function SetForceVisible is used to set and cleag 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 272 of file eda_item.h.

272 { m_forceVisible = aEnable; }
bool m_forceVisible
Definition: eda_item.h:163

References EDA_ITEM::m_forceVisible.

Referenced by SCH_EDITOR_CONTROL::UpdateFind().

◆ SetIncludeInBom()

void SCH_COMPONENT::SetIncludeInBom ( bool  aIncludeInBom)
inline

Definition at line 678 of file sch_component.h.

678 { m_inBom = aIncludeInBom; }
bool m_inBom
True to include in bill of materials export.

References m_inBom.

Referenced by DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow().

◆ SetIncludeOnBoard()

void SCH_COMPONENT::SetIncludeOnBoard ( bool  aIncludeOnBoard)
inline

Definition at line 681 of file sch_component.h.

681 { m_onBoard = aIncludeOnBoard; }
bool m_onBoard
True to include in netlist when updating board.

References m_onBoard.

Referenced by DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow().

◆ SetLayer()

◆ SetLibId()

void SCH_COMPONENT::SetLibId ( const LIB_ID aName)

Definition at line 222 of file sch_component.cpp.

223 {
224  if( m_lib_id != aLibId )
225  {
226  m_lib_id = aLibId;
227  SetModified();
228  }
229 }
void SetModified()
Definition: eda_item.cpp:79
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
Definition: sch_component.h:83

References m_lib_id, and EDA_ITEM::SetModified().

Referenced by CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol(), SCH_ALTIUM_PLUGIN::ParseComponent(), SCH_ALTIUM_PLUGIN::ParsePowerPort(), DIALOG_CHANGE_SYMBOLS::processSymbol(), and DIALOG_SYMBOL_REMAP::remapSymbolToLibTable().

◆ SetLibSymbol()

void SCH_COMPONENT::SetLibSymbol ( LIB_PART 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_PART object can be null to clear the library symbol link as well as the pin map. If the LIB_PART 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_PART reference. All previous public resolvers have been deprecated.
Parameters
aLibSymbolis the library symbol to associate with this schematic symbol.

Definition at line 241 of file sch_component.cpp.

242 {
243  wxCHECK2( ( aLibSymbol == nullptr ) || ( aLibSymbol->IsRoot() ), aLibSymbol = nullptr );
244 
245  m_part.reset( aLibSymbol );
246  UpdatePins();
247 }
std::unique_ptr< LIB_PART > m_part
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.

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

Referenced by CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol(), SCH_ALTIUM_PLUGIN::ParsePowerPort(), SCH_EDITOR_CONTROL::Paste(), DIALOG_CHANGE_SYMBOLS::processSymbol(), SCH_COMPONENT(), and SCH_EDIT_FRAME::UpdateSymbolFromEditor().

◆ SetLocked()

virtual void SCH_ITEM::SetLocked ( bool  aLocked)
inlinevirtualinherited

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

Definition at line 273 of file sch_item.h.

273 {}

◆ SetModified()

void EDA_ITEM::SetModified ( )
inherited

Definition at line 79 of file eda_item.cpp.

80 {
82 
83  // If this a child object, then the parent modification state also needs to be set.
84  if( m_parent )
86 }
void SetModified()
Definition: eda_item.cpp:79
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:162
#define IS_CHANGED
std::function passed to nested users by ref, avoids copying std::function
Definition: eda_item.h:102
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:220

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

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

◆ SetOrientation()

void SCH_COMPONENT::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 1081 of file sch_component.cpp.

1082 {
1083  TRANSFORM temp = TRANSFORM();
1084  bool transform = false;
1085 
1086  switch( aOrientation )
1087  {
1088  case CMP_ORIENT_0:
1089  case CMP_NORMAL: // default transform matrix
1090  m_transform.x1 = 1;
1091  m_transform.y2 = -1;
1092  m_transform.x2 = m_transform.y1 = 0;
1093  break;
1094 
1095  case CMP_ROTATE_COUNTERCLOCKWISE: // Rotate + (incremental rotation)
1096  temp.x1 = temp.y2 = 0;
1097  temp.y1 = 1;
1098  temp.x2 = -1;
1099  transform = true;
1100  break;
1101 
1102  case CMP_ROTATE_CLOCKWISE: // Rotate - (incremental rotation)
1103  temp.x1 = temp.y2 = 0;
1104  temp.y1 = -1;
1105  temp.x2 = 1;
1106  transform = true;
1107  break;
1108 
1109  case CMP_MIRROR_Y: // Mirror Y (incremental rotation)
1110  temp.x1 = -1;
1111  temp.y2 = 1;
1112  temp.y1 = temp.x2 = 0;
1113  transform = true;
1114  break;
1115 
1116  case CMP_MIRROR_X: // Mirror X (incremental rotation)
1117  temp.x1 = 1;
1118  temp.y2 = -1;
1119  temp.y1 = temp.x2 = 0;
1120  transform = true;
1121  break;
1122 
1123  case CMP_ORIENT_90:
1126  break;
1127 
1128  case CMP_ORIENT_180:
1132  break;
1133 
1134  case CMP_ORIENT_270:
1137  break;
1138 
1139  case ( CMP_ORIENT_0 + CMP_MIRROR_X ):
1142  break;
1143 
1144  case ( CMP_ORIENT_0 + CMP_MIRROR_Y ):
1147  break;
1148 
1149  case ( CMP_ORIENT_90 + CMP_MIRROR_X ):
1152  break;
1153 
1154  case ( CMP_ORIENT_90 + CMP_MIRROR_Y ):
1157  break;
1158 
1159  case ( CMP_ORIENT_180 + CMP_MIRROR_X ):
1162  break;
1163 
1164  case ( CMP_ORIENT_180 + CMP_MIRROR_Y ):
1167  break;
1168 
1169  case ( CMP_ORIENT_270 + CMP_MIRROR_X ):
1172  break;
1173 
1174  case ( CMP_ORIENT_270 + CMP_MIRROR_Y ):
1177  break;
1178 
1179  default:
1180  transform = false;
1181  wxFAIL_MSG( "Invalid schematic symbol orientation type." );
1182  break;
1183  }
1184 
1185  if( transform )
1186  {
1187  /* The new matrix transform is the old matrix transform modified by the
1188  * requested transformation, which is the temp transform (rot,
1189  * mirror ..) in order to have (in term of matrix transform):
1190  * transform coord = new_m_transform * coord
1191  * where transform coord is the coord modified by new_m_transform from
1192  * the initial value coord.
1193  * new_m_transform is computed (from old_m_transform and temp) to
1194  * have:
1195  * transform coord = old_m_transform * temp
1196  */
1197  TRANSFORM newTransform;
1198 
1199  newTransform.x1 = m_transform.x1 * temp.x1 + m_transform.x2 * temp.y1;
1200  newTransform.y1 = m_transform.y1 * temp.x1 + m_transform.y2 * temp.y1;
1201  newTransform.x2 = m_transform.x1 * temp.x2 + m_transform.x2 * temp.y2;
1202  newTransform.y2 = m_transform.y1 * temp.x2 + m_transform.y2 * temp.y2;
1203  m_transform = newTransform;
1204  }
1205 }
int y2
Definition: transform.h:51
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 matrix.
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...

References CMP_MIRROR_X, CMP_MIRROR_Y, CMP_NORMAL, CMP_ORIENT_0, CMP_ORIENT_180, CMP_ORIENT_270, CMP_ORIENT_90, CMP_ROTATE_CLOCKWISE, CMP_ROTATE_COUNTERCLOCKWISE, m_transform, TRANSFORM::x1, TRANSFORM::x2, TRANSFORM::y1, and TRANSFORM::y2.

Referenced by GetOrientation(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol(), SCH_EDIT_TOOL::Mirror(), MirrorX(), MirrorY(), SCH_ALTIUM_PLUGIN::ParsePowerPort(), SCH_EDIT_TOOL::Rotate(), Rotate(), and DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow().

◆ SetParent()

virtual void EDA_ITEM::SetParent ( EDA_ITEM aParent)
inlinevirtualinherited

Reimplemented in DIMENSION_BASE.

Definition at line 184 of file eda_item.h.

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

References EDA_ITEM::m_parent.

Referenced by FOOTPRINT::Add(), BOARD::Add(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), BOARD_NETLIST_UPDATER::addNewComponent(), SCH_SHEET::AddPin(), LIB_CONTROL::AddSymbolToSchematic(), SCH_SCREEN::Append(), LIB_FIELD::Copy(), SYMBOL_EDIT_FRAME::CreateNewPart(), SCH_DRAWING_TOOLS::createNewText(), DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), SCH_EDIT_TOOL::Duplicate(), PCB_EDIT_FRAME::ExchangeFootprint(), LIB_PART::Flatten(), FOOTPRINT::FOOTPRINT(), PCB_IO::FootprintSave(), DISPLAY_FOOTPRINTS_FRAME::GetFootprint(), LIB_PART::LIB_PART(), SCH_LEGACY_PLUGIN_CACHE::loadAliases(), FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard(), SCH_SEXPR_PLUGIN::loadHierarchy(), SCH_LEGACY_PLUGIN::loadHierarchy(), SYMBOL_EDIT_FRAME::LoadOneSymbol(), FOOTPRINT::operator=(), LIB_PART::operator=(), PCB_PARSER::parseFOOTPRINT_unchecked(), SCH_SEXPR_PARSER::ParseSchematic(), SCH_SEXPR_PARSER::ParseSymbol(), LIB_EDIT_TOOL::Paste(), PCBNEW_CONTROL::Paste(), SCH_EDITOR_CONTROL::Paste(), pasteFootprintItemsToFootprintEditor(), SCH_DRAWING_TOOLS::PlaceComponent(), PCB_EDITOR_CONTROL::PlaceModule(), 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_PART::SetFields(), DIMENSION_BASE::SetParent(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_LINE_WIRE_BUS_TOOL::startSegments(), SCH_GLOBALLABEL::SwapData(), SCH_SHEET::SwapData(), SwapData(), and SwapItemData().

◆ SetPosition()

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

Reimplemented from EDA_ITEM.

Definition at line 660 of file sch_component.h.

660 { Move( aPosition - m_pos ); }
void Move(const wxPoint &aMoveVector) override
Move the item by aMoveVector to a new position.

References m_pos, and Move().

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

◆ SetPrefix()

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

Definition at line 270 of file sch_component.h.

270 { m_prefix = aPrefix; }
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is.
Definition: sch_component.h:88

References m_prefix.

◆ SetRef()

void SCH_COMPONENT::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 467 of file sch_component.cpp.

468 {
469  KIID_PATH path = sheet->Path();
470  bool notInArray = true;
471 
472  // check to see if it is already there before inserting it
474  {
475  if( instance.m_Path == path )
476  {
477  instance.m_Reference = ref;
478  notInArray = false;
479  }
480  }
481 
482  if( notInArray )
483  AddHierarchicalReference( path, ref, m_unit );
484 
485  for( std::unique_ptr<SCH_PIN>& pin : m_pins )
486  pin->ClearDefaultNetName( sheet );
487 
489 
490  // @todo Should we really be checking for what is a "reasonable" position?
491  if( rf->GetText().IsEmpty()
492  || ( abs( rf->GetTextPos().x - m_pos.x ) +
493  abs( rf->GetTextPos().y - m_pos.y ) > Mils2iu( 10000 ) ) )
494  {
495  // move it to a reasonable position
496  rf->SetTextPos( m_pos + wxPoint( Mils2iu( 50 ), Mils2iu( 50 ) ) );
497  }
498 
499  rf->SetText( ref ); // for drawing.
500 
501  // Reinit the m_prefix member if needed
502  wxString prefix = ref;
503 
504  if( IsReferenceStringValid( prefix ) )
505  {
506  while( prefix.Last() == '?' || wxIsdigit( prefix.Last() ) )
507  prefix.RemoveLast();
508  }
509  else
510  {
511  prefix = wxT( "U" ); // Set to default ref prefix
512  }
513 
514  if( m_prefix != prefix )
515  m_prefix = prefix;
516 
517  // Power components have references starting with # and are not included in netlists
518  m_isInNetlist = ! ref.StartsWith( wxT( "#" ) );
519 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:51
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:253
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:121
bool m_isInNetlist
True if the component should appear in the netlist.
A simple container for schematic symbol instance infromation.
SCH_FIELD * GetField(int aFieldNdx)
Returns a field in this symbol.
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:84
const wxPoint & GetTextPos() const
Definition: eda_text.h:254
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
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.
std::vector< std::unique_ptr< SCH_PIN > > m_pins
static bool IsReferenceStringValid(const wxString &aReferenceString)
Tests for an acceptable reference string.
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is.
Definition: sch_component.h:88
Field Reference of part, i.e. "IC21".
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133

References AddHierarchicalReference(), GetField(), EDA_TEXT::GetText(), EDA_TEXT::GetTextPos(), IsReferenceStringValid(), m_instanceReferences, m_isInNetlist, m_pins, m_pos, m_prefix, m_unit, SCH_SHEET_PATH::Path(), REFERENCE_FIELD, EDA_TEXT::SetText(), and EDA_TEXT::SetTextPos().

Referenced by SCH_REFERENCE::Annotate(), BACK_ANNOTATE::applyChangelist(), BOOST_AUTO_TEST_CASE(), SCH_ALTIUM_PLUGIN::ParsePowerPort(), DIALOG_CHANGE_SYMBOLS::processSymbol(), SCH_FIELD::Replace(), SCH_COMPONENT(), SCH_REFERENCE::SCH_REFERENCE(), TEST_SCH_PIN_FIXTURE::TEST_SCH_PIN_FIXTURE(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), DIALOG_SCH_EDIT_ONE_FIELD::UpdateField(), and SCH_EDITOR_CONTROL::updatePastedInstances().

◆ SetSchSymbolLibraryName()

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

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

Note
See SCH_SCREEN::m_libSymbols

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

Definition at line 202 of file sch_component.h.

202 { m_schLibSymbolName = aName; }
wxString m_schLibSymbolName
The name used to look up a symbol in the symbol library embedded in a schematic.

References m_schLibSymbolName.

Referenced by SCH_SCREEN::Append().

◆ SetSelected()

◆ SetState()

void EDA_ITEM::SetState ( int  type,
int  state 
)
inlineinherited

Definition at line 209 of file eda_item.h.

210  {
211  if( state )
212  m_status |= type; // state = ON or OFF
213  else
214  m_status &= ~type;
215  }
STATUS_FLAGS m_status
Definition: eda_item.h:161

References EDA_ITEM::m_status.

Referenced by LEGACY_PLUGIN::loadTrackList(), TRACKS_CLEANER::mergeCollinearSegments(), SELECTION_TOOL::selectConnectedTracks(), and TRACK::SetLocked().

◆ SetStatus()

void EDA_ITEM::SetStatus ( STATUS_FLAGS  aStatus)
inlineinherited

Definition at line 218 of file eda_item.h.

218 { m_status = aStatus; }
STATUS_FLAGS m_status
Definition: eda_item.h:161

References EDA_ITEM::m_status.

Referenced by BOARD_NETLIST_UPDATER::UpdateNetlist().

◆ SetStoredPos()

void SCH_ITEM::SetStoredPos ( wxPoint  aPos)
inlineinherited

Definition at line 250 of file sch_item.h.

250 { m_storedPos = aPos; }
wxPoint m_storedPos
Definition: sch_item.h:202

References SCH_ITEM::m_storedPos.

Referenced by SCH_MOVE_TOOL::Main(), and SCH_MOVE_TOOL::moveItem().

◆ SetStroke()

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

Reimplemented in SCH_LINE, and SCH_BUS_ENTRY_BASE.

Definition at line 488 of file sch_item.h.

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

◆ SetTransform()

void SCH_COMPONENT::SetTransform ( const TRANSFORM aTransform)

Definition at line 336 of file sch_component.cpp.

337 {
338  if( m_transform != aTransform )
339  {
340  m_transform = aTransform;
341  SetModified();
342  }
343 }
void SetModified()
Definition: eda_item.cpp:79
TRANSFORM m_transform
The rotation/mirror transformation matrix.

References m_transform, and EDA_ITEM::SetModified().

◆ SetUnit()

void SCH_COMPONENT::SetUnit ( int  aUnit)

Change the unit number to aUnit.

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

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

Definition at line 307 of file sch_component.cpp.

308 {
309  if( m_unit != aUnit )
310  {
311  m_unit = aUnit;
312  SetModified();
313  }
314 }
void SetModified()
Definition: eda_item.cpp:79
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:84

References m_unit, and EDA_ITEM::SetModified().

Referenced by SCH_REFERENCE::Annotate(), CADSTAR_SCH_ARCHIVE_LOADER::loadSchematicSymbol(), SCH_ALTIUM_PLUGIN::ParseComponent(), SCH_EDITOR_CONTROL::Paste(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_EDIT_FRAME::SelectUnit(), DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow(), and SCH_EDITOR_CONTROL::updatePastedInstances().

◆ SetUnitSelection()

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

Definition at line 552 of file sch_component.cpp.

553 {
554  KIID_PATH path = aSheet->Path();
555 
556  // check to see if it is already there before inserting it
558  {
559  if( instance.m_Path == path )
560  {
561  instance.m_Unit = aUnitSelection;
562  return;
563  }
564  }
565 
566  // didn't find it; better add it
567  AddHierarchicalReference( path, m_prefix, aUnitSelection );
568 }
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
A simple container for schematic symbol instance infromation.
std::vector< SYMBOL_INSTANCE_REFERENCE > m_instanceReferences
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.
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is.
Definition: sch_component.h:88

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

Referenced by SCH_REFERENCE::Annotate(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_EDIT_FRAME::SelectUnit(), and DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow().

◆ SetValue() [1/2]

void SCH_COMPONENT::SetValue ( const SCH_SHEET_PATH sheet,
const wxString &  aValue 
)

Definition at line 592 of file sch_component.cpp.

593 {
594  if( sheet == nullptr )
595  {
596  // Clear instance overrides and set primary field value
598  instance.m_Value = wxEmptyString;
599 
600  m_fields[ VALUE_FIELD ].SetText( aValue );
601  return;
602  }
603 
604  KIID_PATH path = sheet->