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

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, COMPONENT_SELECTION &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< COMPONENT_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...
 
SCH_CONNECTIONGetConnectionForPin (LIB_PIN *aPin, const SCH_SHEET_PATH &aSheet)
 Retrieves the connection for a given pin of the component. 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 (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...
 
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...
 
LIB_PINGetPin (const wxString &number)
 Find a symbol pin by number. More...
 
void GetPins (std::vector< LIB_PIN * > &aPinsList)
 Populate a vector with all the pins from the library object. More...
 
SCH_PIN_PTRS GetSchPins (const SCH_SHEET_PATH *aSheet=nullptr) const
 Retrieves a list of the SCH_PINs for the given sheet path. More...
 
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)
 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)
 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)
 
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
 
void GetConnectionPoints (std::vector< wxPoint > &aPoints) 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...
 
void GetNetListItem (NETLIST_OBJECT_LIST &aNetListItems, SCH_SHEET_PATH *aSheetPath) override
 Create a new NETLIST_OBJECT for the schematic object and adds it to aNetListItems. 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...
 
const wxPoint GetPosition () const override
 
void SetPosition (const wxPoint &aPosition) override
 Set the schematic item position to aPosition. More...
 
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 ()
 
void BrightenPin (LIB_PIN *aPin)
 
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...
 
wxPointGetStoredPos ()
 
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...
 
SCH_LAYER_ID GetLayer () const
 Return the layer this item is on. More...
 
void SetLayer (SCH_LAYER_ID aLayer)
 Set the layer this item is on. More...
 
virtual int GetPenWidth () const
 
virtual bool IsDangling () const
 
void ClearConnections ()
 Clears all of the connection items from the list. More...
 
bool IsConnected (const wxPoint &aPoint) const
 Test the item to see if it is connected to aPoint. More...
 
SCH_CONNECTIONConnection (const SCH_SHEET_PATH &aPath) const
 Retrieve the connection associated with this object in the given sheet. More...
 
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)
 
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 unsigned int 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 ()
 

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, 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
 True if connectivity info might be out of date. More...
 
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
 Name and library where symbol was loaded from, i.e. "74xx:74LS00". More...
 
LIB_ID m_lib_id
 
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
 
SCH_PINS m_pins
 a SCH_PIN for every LIB_PIN (across all units) More...
 
SCH_PIN_MAP m_pinMap
 the component's pins mapped by LIB_PIN* More...
 
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< COMPONENT_INSTANCE_REFERENCEm_instanceReferences
 

Detailed Description

Schematic symbol object.

Definition at line 88 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 111 of file sch_component.cpp.

111  :
112  SCH_ITEM( aParent, SCH_COMPONENT_T )
113 {
114  Init( aPos );
115 }
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 118 of file sch_component.cpp.

119  :
121 {
122  Init( pos );
123 
124  m_unit = unit;
125  m_convert = convert;
126  m_lib_id = aLibId;
127 
128  std::unique_ptr< LIB_PART > part;
129 
130  part = aPart.Flatten();
131  part->SetParent();
132  SetLibSymbol( part.release() );
133 
134  // Copy fields from the library component
135  UpdateFields( true, true );
136 
137  // Update the reference -- just the prefix for now.
138  if( sheet )
139  SetRef( sheet, m_part->GetReferenceField().GetText() + wxT( "?" ) );
140  else
141  m_prefix = m_part->GetReferenceField().GetText() + wxT( "?" );
142 }
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.
#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:99
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.
int m_convert
The alternate body style for components that have more than one body style defined.
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is.
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType)
Definition: sch_item.cpp:47

References LIB_PART::Flatten(), Init(), m_convert, m_lib_id, 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,
COMPONENT_SELECTION aSel,
const wxPoint pos = wxPoint( 0, 0 ) 
)

Definition at line 145 of file sch_component.cpp.

147  : SCH_COMPONENT( aPart, aSel.LibId, aSheet, aSel.Unit, aSel.Convert, pos )
148 {
149  // Set any fields that were modified as part of the component selection
150  for( auto const& i : aSel.Fields )
151  {
152  auto field = this->GetField( i.first );
153 
154  if( field )
155  field->SetText( i.second );
156  }
157 }
SCH_COMPONENT(const wxPoint &pos=wxPoint(0, 0), SCH_ITEM *aParent=NULL)
SCH_FIELD * GetField(int aFieldNdx)
Returns a field in this symbol.
std::vector< std::pair< int, wxString > > Fields
Definition: sch_screen.h:86

References COMPONENT_SELECTION::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 160 of file sch_component.cpp.

160  :
161  SCH_ITEM( aComponent )
162 {
163  m_Parent = aComponent.m_Parent;
164  m_Pos = aComponent.m_Pos;
165  m_unit = aComponent.m_unit;
166  m_convert = aComponent.m_convert;
167  m_lib_id = aComponent.m_lib_id;
168  m_isInNetlist = aComponent.m_isInNetlist;
169  m_inBom = aComponent.m_inBom;
170  m_onBoard = aComponent.m_onBoard;
171 
172  if( aComponent.m_part )
173  SetLibSymbol( new LIB_PART( *aComponent.m_part.get() ) );
174 
175  const_cast<KIID&>( m_Uuid ) = aComponent.m_Uuid;
176 
177  m_transform = aComponent.m_transform;
178  m_prefix = aComponent.m_prefix;
180  m_Fields = aComponent.m_Fields;
181 
182  // Re-parent the fields, which before this had aComponent as parent
183  for( SCH_FIELD& field : m_Fields )
184  field.SetParent( this );
185 
187 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
EDA_ITEM * m_Parent
Linked list: Link (parent struct)
Definition: base_struct.h:174
void SetLibSymbol(LIB_PART *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
SCH_FIELDS m_Fields
Variable length list of fields.
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:94
bool m_onBoard
True to include in netlist when updating board.
std::vector< COMPONENT_INSTANCE_REFERENCE > m_instanceReferences
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:193
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: base_struct.h:162
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:99
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.
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is.
TRANSFORM m_transform
The rotation/mirror transformation matrix.
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 170 of file sch_component.h.

170 { }

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

164 {
165  m_connected_items[ aSheet ].insert( aItem );
166 }
std::unordered_map< SCH_SHEET_PATH, ITEM_SET > m_connected_items
Stores pointers to other items that are connected to this one, per sheet.
Definition: sch_item.h:198

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

613 {
614  int newNdx = m_Fields.size();
615 
616  m_Fields.push_back( aField );
617  return &m_Fields[newNdx];
618 }
SCH_FIELDS m_Fields
Variable length list of fields.

References m_Fields.

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

◆ AddHierarchicalReference()

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

Add a full hierarchical reference to this symbol.

Parameters
aPathis the hierarchical path (/&ltsheet timestamp&gt/&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.

Definition at line 385 of file sch_component.cpp.

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

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

Referenced by AddSheetPathReferenceEntryIfMissing(), SetRef(), SetUnitSelection(), 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 886 of file sch_component.cpp.

887 {
888  // a empty sheet path is illegal:
889  wxCHECK( aSheetPath.size() > 0, false );
890 
891  wxString reference_path;
892 
893  for( const COMPONENT_INSTANCE_REFERENCE& instance : m_instanceReferences )
894  {
895  // if aSheetPath is found, nothing to do:
896  if( instance.m_Path == aSheetPath )
897  return false;
898  }
899 
900  // This entry does not exist: add it, with its last-used reference
902  return true;
903 }
SCH_FIELDS m_Fields
Variable length list of fields.
std::vector< COMPONENT_INSTANCE_REFERENCE > m_instanceReferences
Field Reference of part, i.e. "IC21".
A simple container for schematic symbol instance infromation.
wxString GetText(GRAPHIC_PINSHAPE aShape)
Definition: pin_shape.cpp:58
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:99
void AddHierarchicalReference(const KIID_PATH &aPath, const wxString &aRef, int aUnit)
Add a full hierarchical reference to this symbol.

References AddHierarchicalReference(), GetText(), m_Fields, m_instanceReferences, m_unit, and REFERENCE.

◆ 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 component.

Definition at line 447 of file sch_item.h.

448  {
449  if( GetFieldsAutoplaced() )
451  }
FIELDS_AUTOPLACED GetFieldsAutoplaced() const
Return whether the fields have been automatically placed.
Definition: sch_item.h:432
virtual void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual)
Definition: sch_item.h:453

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 683 of file eeschema/autoplace_fields.cpp.

684 {
685  if( aManual )
686  wxASSERT_MSG( aScreen, "A SCH_SCREEN pointer must be given for manual autoplacement" );
687 
688  AUTOPLACER autoplacer( this, aScreen );
689  autoplacer.DoAutoplace( aManual );
691 }
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:193

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

Referenced by SCH_EDIT_TOOL::AutoplaceFields(), and SCH_DRAWING_TOOLS::PlaceComponent().

◆ BrightenPin()

void SCH_COMPONENT::BrightenPin ( LIB_PIN aPin)

Definition at line 1752 of file sch_component.cpp.

1753 {
1754  if( m_pinMap.count( aPin ) )
1755  m_pins[ m_pinMap.at( aPin ) ]->SetBrightened();
1756 }
SCH_PINS m_pins
a SCH_PIN for every LIB_PIN (across all units)
SCH_PIN_MAP m_pinMap
the component's pins mapped by LIB_PIN*

References m_pinMap, and m_pins.

Referenced by SCH_EDITOR_CONTROL::UpdateNetHighlighting().

◆ CanConnect()

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

Reimplemented from SCH_ITEM.

Definition at line 608 of file sch_component.h.

609  {
610  return ( aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_WIRE ) ||
611  ( aItem->Type() == SCH_NO_CONNECT_T ) ||
612  ( aItem->Type() == SCH_JUNCTION_T ) ||
613  ( aItem->Type() == SCH_COMPONENT_T ) ;
614  }
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:271
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

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

173  {
174  return aItem && SCH_COMPONENT_T == aItem->Type();
175  }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

References SCH_COMPONENT_T, and EDA_ITEM::Type().

◆ ClearAnnotation()

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

845 {
846  // Build a reference with no annotation,
847  // i.e. a reference ended by only one '?'
848  wxString defRef = m_prefix;
849 
850  if( !IsReferenceStringValid( defRef ) )
851  { // This is a malformed reference: reinit this reference
852  m_prefix = defRef = wxT("U"); // Set to default ref prefix
853  }
854 
855  while( defRef.Last() == '?' )
856  defRef.RemoveLast();
857 
858  defRef.Append( wxT( "?" ) );
859 
860  if( aSheetPath )
861  {
862  KIID_PATH path = aSheetPath->Path();
863 
865  {
866  if( instance.m_Path == path )
867  instance.m_Reference = defRef;
868  }
869  }
870  else
871  {
873  instance.m_Reference = defRef;
874  }
875 
876  // These 2 changes do not work in complex hierarchy.
877  // When a clear annotation is made, the calling function must call a
878  // UpdateAllScreenReferences for the active sheet.
879  // But this call cannot made here.
880  m_Fields[REFERENCE].SetText( defRef ); //for drawing.
881 
882  SetModified();
883 }
void SetModified()
Definition: base_struct.cpp:85
SCH_FIELDS m_Fields
Variable length list of fields.
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
std::vector< COMPONENT_INSTANCE_REFERENCE > m_instanceReferences
Field Reference of part, i.e. "IC21".
A simple container for schematic symbol instance infromation.
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.

References IsReferenceStringValid(), m_Fields, m_instanceReferences, m_prefix, SCH_SHEET_PATH::Path(), REFERENCE, and EDA_ITEM::SetModified().

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

◆ ClearBrightened()

void EDA_ITEM::ClearBrightened ( )
inlineinherited

◆ ClearBrightenedPins()

void SCH_COMPONENT::ClearBrightenedPins ( )

Definition at line 1745 of file sch_component.cpp.

1746 {
1747  for( auto& pin : m_pins )
1748  pin->ClearBrightened();
1749 }
SCH_PINS m_pins
a SCH_PIN for every LIB_PIN (across all units)

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

386 { m_connections.clear(); }
EDA_ITEMS m_connections
Definition: sch_item.h:192

References SCH_ITEM::m_connections.

◆ ClearEditFlags()

◆ ClearFieldsAutoplaced()

void SCH_ITEM::ClearFieldsAutoplaced ( )
inlineinherited

Set fields automatically placed flag false.

Definition at line 437 of file sch_item.h.

FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:193

References FIELDS_AUTOPLACED_NO, and SCH_ITEM::m_fieldsAutoplaced.

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

◆ ClearFlags()

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

Definition at line 233 of file base_struct.h.

233 { m_Flags &= ~aMask; }
STATUS_FLAGS m_Flags
Definition: base_struct.h:176

References EDA_ITEM::m_Flags.

Referenced by FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), PNS_KICAD_IFACE::AddItem(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_SCREEN::ClearAnnotation(), EDA_ITEM::ClearBrightened(), EDA_ITEM::ClearEditFlags(), clearModuleItemFlags(), EDA_ITEM::ClearSelected(), EDA_ITEM::ClearTempFlags(), SCH_EDIT_FRAME::ConvertPart(), LIB_EDIT_TOOL::Copy(), MICROWAVE_TOOL::createMicrowaveInductor(), DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN(), DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES(), KIGFX::SCH_PAINTER::draw(), LIB_EDIT_TOOL::Duplicate(), SCH_ITEM::Duplicate(), PCB_EDIT_FRAME::Exchange_Module(), LIB_EDIT_FRAME::GetComponentFromRedoList(), LIB_EDIT_FRAME::GetComponentFromUndoList(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD(), FOOTPRINT_EDIT_FRAME::LoadModuleFromLibrary(), FOOTPRINT_EDIT_FRAME::OpenProjectFiles(), PCB_BASE_FRAME::PlaceModule(), LIB_PIN_TOOL::PlacePin(), DRAWING_TOOL::PlaceText(), FOOTPRINT_EDIT_FRAME::Process_Special_Functions(), BOARD_COMMIT::Push(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_PIN_TOOL::RepeatPin(), LIB_EDIT_FRAME::RollbackPartFromUndo(), SCH_EDIT_FRAME::SaveCopyForRepeatItem(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), SCH_SEXPR_PLUGIN_CACHE::savePin(), SCH_LEGACY_PLUGIN_CACHE::savePin(), EE_SELECTION_TOOL::SelectPoint(), SCH_EDIT_FRAME::SelectUnit(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ ClearSelected()

◆ ClearTempFlags()

void EDA_ITEM::ClearTempFlags ( )
inlineinherited

Definition at line 245 of file base_struct.h.

246  {
248  DO_NOT_DRAW );
249  }
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
Definition: base_struct.h:114
#define TEMP_SELECTED
flag indicating that the structure has already selected
Definition: base_struct.h:125
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: base_struct.h:128
#define CANDIDATE
flag indicating that the structure is connected
Definition: base_struct.h:127
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:123
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:233
#define DO_NOT_DRAW
Used to disable draw function.
Definition: base_struct.h:129
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:122

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

154  {
156  }
VIEW_ITEM_DATA * m_viewPrivData
Definition: view_item.h:161
#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 219 of file sch_component.cpp.

220 {
221  return new SCH_COMPONENT( *this );
222 }
SCH_COMPONENT(const wxPoint &pos=wxPoint(0, 0), SCH_ITEM *aParent=NULL)

References SCH_COMPONENT().

Referenced by SCH_DRAWING_TOOLS::PlaceComponent().

◆ ConnectedItems()

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

158 {
159  return m_connected_items[ aSheet ];
160 }
std::unordered_map< SCH_SHEET_PATH, ITEM_SET > m_connected_items
Stores pointers to other items that are connected to this one, per sheet.
Definition: sch_item.h:198

References SCH_ITEM::m_connected_items.

Referenced by SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), CONNECTION_GRAPH::buildConnectionGraph(), and CONNECTION_GRAPH::updateItemConnectivity().

◆ Connection()

SCH_CONNECTION * SCH_ITEM::Connection ( const SCH_SHEET_PATH aPath) const
inherited

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

Definition at line 423 of file sch_item.h.

423 { return true; }

Referenced by CONNECTION_GRAPH::updateItemConnectivity().

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

1686 {
1687  wxPoint new_pos = m_transform.InverseTransform().TransformCoordinate( aPosition - m_Pos );
1688 
1689  for( const auto& pin : m_pins )
1690  {
1691  // Collect only pins attached to the current unit and convert.
1692  // others are not associated to this component instance
1693  int pin_unit = pin->GetLibPin()->GetUnit();
1694  int pin_convert = pin->GetLibPin()->GetConvert();
1695 
1696  if( pin_unit > 0 && pin_unit != GetUnit() )
1697  continue;
1698 
1699  if( pin_convert > 0 && pin_convert != GetConvert() )
1700  continue;
1701 
1702  if( pin->GetLocalPosition() == new_pos )
1703  return true;
1704  }
1705 
1706  return false;
1707 }
SCH_PINS m_pins
a SCH_PIN for every LIB_PIN (across all units)
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:94
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
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  if( newItem->Type() == SCH_COMPONENT_T )
88  {
89  SCH_COMPONENT* component = (SCH_COMPONENT*) newItem;
90 
91  for( SCH_PIN* pin : component->GetSchPins() )
92  pin->ClearFlags( SELECTED | BRIGHTENED );
93 
94  for( SCH_FIELD& field : component->GetFields() )
95  field.ClearFlags( SELECTED | BRIGHTENED );
96  }
97 
98  if( newItem->Type() == SCH_SHEET_T )
99  {
100  SCH_SHEET* sheet = (SCH_SHEET*) newItem;
101 
102  for( SCH_FIELD& field : sheet->GetFields() )
103  field.ClearFlags( SELECTED | BRIGHTENED );
104 
105  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
106  pin->ClearFlags( SELECTED | BRIGHTENED );
107  }
108 
109  return newItem;
110 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populates a std::vector with SCH_FIELDs.
std::vector< SCH_FIELD > & GetFields()
Definition: sch_sheet.h:268
#define SELECTED
Definition: base_struct.h:124
Definition: common.h:68
#define BRIGHTENED
item is drawn with a bright contour
Definition: base_struct.h:139
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:84
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:216
const KIID m_Uuid
Definition: base_struct.h:162
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:362
Schematic symbol object.
Definition: sch_component.h:88
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:233
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:186
SCH_PIN_PTRS GetSchPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieves a list of the SCH_PINs for the given sheet path.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

References BRIGHTENED, EDA_ITEM::ClearFlags(), EDA_ITEM::Clone(), SCH_SHEET::GetFields(), GetFields(), SCH_SHEET::GetPins(), GetSchPins(), EDA_ITEM::m_Uuid, SCH_COMPONENT_T, SCH_SHEET_T, SELECTED, and EDA_ITEM::Type().

Referenced by SCH_EDIT_TOOL::Duplicate(), 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 634 of file sch_component.cpp.

635 {
636  unsigned start = aIncludeDefaultFields ? 0 : MANDATORY_FIELDS;
637 
638  for( unsigned i = start; i < m_Fields.size(); ++i )
639  {
640  if( aFieldName == m_Fields[i].GetName( false ) )
641  return &m_Fields[i];
642  }
643 
644  return NULL;
645 }
SCH_FIELDS m_Fields
Variable length list of fields.
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
#define NULL

References m_Fields, MANDATORY_FIELDS, and NULL.

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

◆ GetBodyBoundingBox()

EDA_RECT SCH_COMPONENT::GetBodyBoundingBox ( ) const

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

Definition at line 1130 of file sch_component.cpp.

1131 {
1132  EDA_RECT bBox;
1133 
1134  if( m_part )
1135  bBox = m_part->GetBodyBoundingBox( m_unit, m_convert );
1136  else
1137  bBox = dummy()->GetBodyBoundingBox( m_unit, m_convert );
1138 
1139  int x0 = bBox.GetX();
1140  int xm = bBox.GetRight();
1141 
1142  // We must reverse Y values, because matrix orientation
1143  // suppose Y axis normal for the library items coordinates,
1144  // m_transform reverse Y values, but bBox is already reversed!
1145  int y0 = -bBox.GetY();
1146  int ym = -bBox.GetBottom();
1147 
1148  // Compute the real Boundary box (rotated, mirrored ...)
1149  int x1 = m_transform.x1 * x0 + m_transform.y1 * y0;
1150  int y1 = m_transform.x2 * x0 + m_transform.y2 * y0;
1151  int x2 = m_transform.x1 * xm + m_transform.y1 * ym;
1152  int y2 = m_transform.x2 * xm + m_transform.y2 * ym;
1153 
1154  bBox.SetX( x1 );
1155  bBox.SetY( y1 );
1156  bBox.SetWidth( x2 - x1 );
1157  bBox.SetHeight( y2 - y1 );
1158  bBox.Normalize();
1159 
1160  bBox.Offset( m_Pos );
1161  return bBox;
1162 }
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
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:94
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.
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:99
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.
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()

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

1166 {
1167  EDA_RECT bbox = GetBodyBoundingBox();
1168 
1169  for( const SCH_FIELD& field : m_Fields )
1170  bbox.Merge( field.GetBoundingBox() );
1171 
1172  return bbox;
1173 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
void Merge(const EDA_RECT &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
SCH_FIELDS m_Fields
Variable length list of fields.
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

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

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

◆ GetClass()

wxString SCH_COMPONENT::GetClass ( ) const
inlineoverridevirtual

Function GetClass returns the class name.

Returns
wxString

Reimplemented from SCH_ITEM.

Definition at line 177 of file sch_component.h.

178  {
179  return wxT( "SCH_COMPONENT" );
180  }

Referenced by operator=().

◆ GetConnectionForPin()

SCH_CONNECTION * SCH_COMPONENT::GetConnectionForPin ( LIB_PIN aPin,
const SCH_SHEET_PATH aSheet 
)

Retrieves the connection for a given pin of the component.

Definition at line 307 of file sch_component.cpp.

308 {
309  if( m_pinMap.count( aPin ) )
310  return m_pins[ m_pinMap[aPin] ]->Connection( aSheet );
311 
312  return nullptr;
313 }
SCH_PINS m_pins
a SCH_PIN for every LIB_PIN (across all units)
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:147
SCH_PIN_MAP m_pinMap
the component's pins mapped by LIB_PIN*

References SCH_ITEM::Connection(), m_pinMap, and m_pins.

Referenced by LIB_PIN::GetMsgPanelInfo(), and SCH_EDITOR_CONTROL::UpdateNetHighlighting().

◆ GetConnectionPoints()

void SCH_COMPONENT::GetConnectionPoints ( std::vector< wxPoint > &  aPoints) 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 1412 of file sch_component.cpp.

1413 {
1414  for( const std::unique_ptr<SCH_PIN>& pin : m_pins )
1415  {
1416  // Collect only pins attached to the current unit and convert.
1417  // others are not associated to this component instance
1418  int pin_unit = pin->GetLibPin()->GetUnit();
1419  int pin_convert = pin->GetLibPin()->GetConvert();
1420 
1421  if( pin_unit > 0 && pin_unit != GetUnit() )
1422  continue;
1423 
1424  if( pin_convert > 0 && pin_convert != GetConvert() )
1425  continue;
1426 
1427  aPoints.push_back( m_transform.TransformCoordinate( pin->GetLocalPosition() ) + m_Pos );
1428  }
1429 }
SCH_PINS m_pins
a SCH_PIN for every LIB_PIN (across all units)
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:94
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
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 783 of file sch_component.cpp.

784 {
785  for( int i = 0; i < MANDATORY_FIELDS; ++i )
786  aVars->push_back( m_Fields[i].GetCanonicalName().Upper() );
787 
788  for( size_t i = MANDATORY_FIELDS; i < m_Fields.size(); ++i )
789  aVars->push_back( m_Fields[i].GetName() );
790 
791  aVars->push_back( wxT( "FOOTPRINT_LIBRARY" ) );
792  aVars->push_back( wxT( "FOOTPRINT_NAME" ) );
793  aVars->push_back( wxT( "UNIT" ) );
794 }
SCH_FIELDS m_Fields
Variable length list of fields.
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.

References m_Fields, and MANDATORY_FIELDS.

Referenced by 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 273 of file sch_component.cpp.

274 {
275  if( m_part )
276  return m_part->GetDatasheetField().GetText();
277 
278  return wxEmptyString;
279 }
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 262 of file sch_component.cpp.

263 {
264  if( m_part )
265  {
266  return m_part->GetDescription();
267  }
268 
269  return wxEmptyString;
270 }
std::unique_ptr< LIB_PART > m_part

References m_part.

Referenced by NETLIST_EXPORTER_GENERIC::makeComponents().

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

1433 {
1434  if( m_part )
1435  {
1436  // Calculate the position relative to the component.
1437  wxPoint libPosition = aPosition - m_Pos;
1438 
1439  return m_part->LocateDrawItem( m_unit, m_convert, aType, libPosition, m_transform );
1440  }
1441 
1442  return NULL;
1443 }
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:94
#define NULL
std::unique_ptr< LIB_PART > m_part
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:99
int m_convert
The alternate body style for components that have more than one body style defined.
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 237 of file base_struct.h.

238  {
239  constexpr int mask = ( IS_NEW | IS_PASTED | IS_MOVED | IS_RESIZED | IS_DRAGGED |
241 
242  return m_Flags & mask;
243  }
#define IS_NEW
New item, just created.
Definition: base_struct.h:117
#define IS_DRAGGED
Item being dragged.
Definition: base_struct.h:119
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:126
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.
Definition: base_struct.h:121
STATUS_FLAGS m_Flags
Definition: base_struct.h:176
#define IS_RESIZED
Item being resized.
Definition: base_struct.h:118
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
Definition: base_struct.h:130
#define IS_MOVED
Item being moved.
Definition: base_struct.h:116

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(), SCH_EDITOR_CONTROL::EditWithLibEdit(), GetMsgPanelInfo(), 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_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_LIB_EDIT_PIN::TransferDataFromWindow(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_LABEL_EDITOR::TransferDataFromWindow(), DIALOG_FOOTPRINT_BOARD_EDITOR::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 1337 of file sch_component.cpp.

1338 {
1339  for( auto& pin : m_pins )
1340  {
1341  LIB_PIN* lib_pin = pin->GetLibPin();
1342 
1343  if( lib_pin->GetUnit() && m_unit && ( m_unit != lib_pin->GetUnit() ) )
1344  continue;
1345 
1346  DANGLING_END_ITEM item( PIN_END, lib_pin, GetPinPhysicalPosition( lib_pin ), this );
1347  aItemList.push_back( item );
1348  }
1349 }
SCH_PINS m_pins
a SCH_PIN for every LIB_PIN (across all units)
int GetUnit() const
Definition: lib_item.h:295
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:99
Helper class used to store the state of schematic items that can be connected to other schematic item...
Definition: sch_item.h:84
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 572 of file sch_component.cpp.

573 {
574  if( (unsigned) aFieldNdx < m_Fields.size() )
575  return &m_Fields[aFieldNdx];
576 
577  return nullptr;
578 }
SCH_FIELDS m_Fields
Variable length list of fields.

References m_Fields.

Referenced by NETLIST_EXPORTER_GENERIC::addComponentFields(), SCH_EAGLE_PLUGIN::addImplicitConnections(), SIM_PLOT_FRAME::AddTuner(), SCH_EDIT_FRAME::AnnotateComponents(), BACK_ANNOTATE::applyChangelist(), SCH_EDITOR_CONTROL::BackAnnotateFootprints(), SCH_SHEET::ComponentCount(), SCH_EDIT_TOOL::EditField(), FormatProbeItem(), LIB_PIN::GetMsgPanelInfo(), GetMsgPanelInfo(), GetRef(), GetSelectMenuText(), NETLIST_EXPORTER_PSPICE::GetSpiceFieldDefVal(), BACK_ANNOTATE::getTextFromField(), DIALOG_FIELDS_EDITOR_GLOBAL::LoadFieldNames(), SCH_EAGLE_PLUGIN::loadSchematic(), TUNER_SLIDER::onSave(), operator==(), SCH_EDITOR_CONTROL::processCmpToFootprintLinkFile(), SCH_LEGACY_PLUGIN::saveComponent(), SCH_COMPONENT(), SCH_REFERENCE::SCH_REFERENCE(), SCH_SCREEN::SetComponentFootprint(), SetRef(), EE_INSPECTION_TOOL::ShowDatasheet(), ERC_TESTER::TestMultiunitFootprints(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataToWindow(), TUNER_SLIDER::TUNER_SLIDER(), UpdateFields(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::UpdateFieldsFromLibrary(), SCH_SHEET_LIST::UpdateSymbolInstances(), Visit(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem(), NETLIST_EXPORTER_ORCADPCB2::WriteNetlist(), and NETLIST_EXPORTER_CADSTAR::WriteNetlist().

◆ GetField() [2/2]

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

Definition at line 581 of file sch_component.cpp.

582 {
583  if( (unsigned) aFieldNdx < m_Fields.size() )
584  return &m_Fields[aFieldNdx];
585 
586  return nullptr;
587 }
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 602 of file sch_component.cpp.

603 {
604  for( SCH_FIELD& field : m_Fields )
605  {
606  if( !aVisibleOnly || ( field.IsVisible() && !field.IsVoid() ) )
607  aVector.push_back( &field );
608  }
609 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
SCH_FIELDS m_Fields
Variable length list of fields.

References m_Fields.

Referenced by AUTOPLACER::AUTOPLACER(), KIGFX::SCH_PAINTER::draw(), SCH_ITEM::Duplicate(), SCH_SHEET_LIST::FillItemMap(), SCH_SHEET_LIST::GetItem(), SCH_SEXPR_PLUGIN::saveSymbol(), ERC_TESTER::TestTextVars(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow(), DIALOG_UPDATE_FIELDS::updateFields(), 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 416 of file sch_component.h.

416 { 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 432 of file sch_item.h.

432 { return m_fieldsAutoplaced; }
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:193

References SCH_ITEM::m_fieldsAutoplaced.

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

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

591 {
592  for( const SCH_FIELD& field : m_Fields )
593  {
594  if( aFieldName == field.GetName() )
595  return field.GetText();
596  }
597 
598  return wxEmptyString;
599 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
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 DRAWSEGMENT, and TRACK.

Definition at line 344 of file base_struct.h.

344 { return GetPosition(); }
virtual const wxPoint GetPosition() const
Definition: base_struct.h:337

References EDA_ITEM::GetPosition().

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

◆ GetIncludeInBom()

bool SCH_COMPONENT::GetIncludeInBom ( ) const
inline

Definition at line 672 of file sch_component.h.

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

References m_inBom.

Referenced by NETLIST_EXPORTER_GENERIC::makeComponents(), SCH_SEXPR_PLUGIN::saveSymbol(), and DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataToWindow().

◆ GetIncludeOnBoard()

bool SCH_COMPONENT::GetIncludeOnBoard ( ) const
inline

Definition at line 675 of file sch_component.h.

675 { return m_onBoard; }
bool m_onBoard
True to include in netlist when updating board.

References m_onBoard.

Referenced by NETLIST_EXPORTER_GENERIC::makeComponents(), SCH_SEXPR_PLUGIN::saveSymbol(), and DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataToWindow().

◆ GetInstanceReferences()

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

Definition at line 182 of file sch_component.h.

183  {
184  return m_instanceReferences;
185  }
std::vector< COMPONENT_INSTANCE_REFERENCE > m_instanceReferences

References m_instanceReferences.

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

◆ GetLayer()

◆ GetLibId()

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

1268 {
1269  return add_component_xpm;
1270 }
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 1176 of file sch_component.cpp.

1177 {
1178  wxString msg;
1179 
1180  SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( aFrame );
1181 
1182  // part and alias can differ if alias is not the root
1183  if( m_part )
1184  {
1185  if( m_part.get() != dummy() )
1186  {
1187  if( schframe )
1188  {
1189  aList.push_back( MSG_PANEL_ITEM(
1190  _( "Reference" ), GetRef( &schframe->GetCurrentSheet() ), DARKCYAN ) );
1191  }
1192 
1193  msg = m_part->IsPower() ? _( "Power symbol" ) : _( "Value" );
1194 
1195  aList.push_back( MSG_PANEL_ITEM( msg, GetField( VALUE )->GetShownText(), DARKCYAN ) );
1196 
1197 #if 0 // Display component flags, for debug only
1198  aList.push_back( MSG_PANEL_ITEM( _( "flags" ),
1199  wxString::Format("%X", GetEditFlags()), BROWN ) );
1200 #endif
1201 
1202  // Display component reference in library and library
1203  aList.push_back( MSG_PANEL_ITEM( _( "Name" ), GetLibId().GetLibItemName(), BROWN ) );
1204 
1205  if( !m_part->IsRoot() )
1206  {
1207  msg = _( "Missing parent" );
1208 
1209  std::shared_ptr< LIB_PART > parent = m_part->GetParent().lock();
1210 
1211  if( parent )
1212  msg = parent->GetName();
1213 
1214  aList.push_back( MSG_PANEL_ITEM( _( "Alias of" ), msg, BROWN ) );
1215  }
1216  else if( !m_lib_id.GetLibNickname().empty() )
1217  {
1218  aList.push_back( MSG_PANEL_ITEM( _( "Library" ), m_lib_id.GetLibNickname(),
1219  BROWN ) );
1220  }
1221  else
1222  {
1223  aList.push_back( MSG_PANEL_ITEM( _( "Library" ), _( "Undefined!!!" ), RED ) );
1224  }
1225 
1226  // Display the current associated footprint, if exists.
1227  if( !GetField( FOOTPRINT )->IsVoid() )
1228  msg = GetField( FOOTPRINT )->GetShownText();
1229  else
1230  msg = _( "<Unknown>" );
1231 
1232  aList.push_back( MSG_PANEL_ITEM( _( "Footprint" ), msg, DARKRED ) );
1233 
1234  // Display description of the component, and keywords found in lib
1235  aList.push_back( MSG_PANEL_ITEM( _( "Description" ), m_part->GetDescription(),
1236  DARKCYAN ) );
1237  aList.push_back( MSG_PANEL_ITEM( _( "Key words" ), m_part->GetKeyWords(), DARKCYAN ) );
1238  }
1239  }
1240  else
1241  {
1242  if( schframe )
1243  {
1244  aList.push_back( MSG_PANEL_ITEM(
1245  _( "Reference" ), GetRef( &schframe->GetCurrentSheet() ), DARKCYAN ) );
1246  }
1247 
1248  aList.push_back( MSG_PANEL_ITEM( _( "Value" ), GetField( VALUE )->GetShownText(),
1249  DARKCYAN ) );
1250  aList.push_back( MSG_PANEL_ITEM( _( "Name" ), GetLibId().GetLibItemName(), BROWN ) );
1251 
1252  wxString libNickname = GetLibId().GetLibNickname();
1253 
1254  if( libNickname.empty() )
1255  {
1256  aList.push_back( MSG_PANEL_ITEM( _( "Library" ), _( "No library defined!" ), RED ) );
1257  }
1258  else
1259  {
1260  msg.Printf( _( "Symbol not found in %s!" ), libNickname );
1261  aList.push_back( MSG_PANEL_ITEM( _( "Library" ), msg , RED ) );
1262  }
1263  }
1264 }
Definition: color4d.h:61
Schematic editor (Eeschema) main window.
Field Name Module PCB, i.e. "16DIP300".
wxString GetShownText(int aDepth=0) const override
Return the string actually shown after processing of the base text.
Definition: sch_field.cpp:102
#define VALUE
STATUS_FLAGS GetEditFlags() const
Definition: base_struct.h:237
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
std::unique_ptr< LIB_PART > m_part
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false)
Return the reference for the given sheet path.
Definition: color4d.h:59
SCH_FIELD * GetField(int aFieldNdx)
Returns a field in this symbol.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
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:53
const LIB_ID & GetLibId() const
bool empty() const
Definition: utf8.h:108

References _, BROWN, DARKCYAN, DARKRED, dummy(), UTF8::empty(), FOOTPRINT, Format(), SCH_EDIT_FRAME::GetCurrentSheet(), EDA_ITEM::GetEditFlags(), GetField(), GetLibId(), LIB_ID::GetLibNickname(), GetRef(), SCH_FIELD::GetShownText(), m_lib_id, m_part, RED, and VALUE.

◆ GetNetListItem()

void SCH_COMPONENT::GetNetListItem ( NETLIST_OBJECT_LIST aNetListItems,
SCH_SHEET_PATH aSheetPath 
)
overridevirtual

Create a new NETLIST_OBJECT for the schematic object and adds it to aNetListItems.

Not all schematic objects have net list items associated with them. This method only needs to be overridden for those schematic objects that have net list objects associated with them.

Reimplemented from SCH_ITEM.

Definition at line 1528 of file sch_component.cpp.

1530 {
1531  if( !m_part || !m_onBoard )
1532  return;
1533 
1534  for( LIB_PIN* pin = m_part->GetNextPin(); pin; pin = m_part->GetNextPin( pin ) )
1535  {
1536  wxASSERT( pin->Type() == LIB_PIN_T );
1537 
1538  if( pin->GetUnit() && ( pin->GetUnit() != GetUnitSelection( aSheetPath ) ) )
1539  continue;
1540 
1541  if( pin->GetConvert() && ( pin->GetConvert() != GetConvert() ) )
1542  continue;
1543 
1544  wxPoint pos = GetTransform().TransformCoordinate( pin->GetPosition() ) + m_Pos;
1545 
1546  NETLIST_OBJECT* item = new NETLIST_OBJECT();
1547  item->m_SheetPathInclude = *aSheetPath;
1548  item->m_Comp = m_pins[ m_pinMap.at( pin ) ].get();
1549  item->m_SheetPath = *aSheetPath;
1550  item->m_Type = NETLIST_ITEM::PIN;
1551  item->m_Link = (SCH_ITEM*) this;
1552  item->m_ElectricalPinType = pin->GetType();
1553  item->m_PinNum = pin->GetNumber();
1554  item->m_Label = pin->GetName();
1555  item->m_Start = item->m_End = pos;
1556 
1557  aNetListItems.push_back( item );
1558 
1559  if( pin->IsPowerConnection() )
1560  {
1561  // There is an associated PIN_LABEL.
1562  item = new NETLIST_OBJECT();
1563  item->m_SheetPathInclude = *aSheetPath;
1564  item->m_Comp = m_pins[ m_pinMap.at( pin ) ].get();
1565  item->m_SheetPath = *aSheetPath;
1567  item->m_Label = pin->GetName();
1568  item->m_Start = pos;
1569  item->m_End = item->m_Start;
1570 
1571  aNetListItems.push_back( item );
1572  }
1573  }
1574 }
SCH_PINS m_pins
a SCH_PIN for every LIB_PIN (across all units)
SCH_SHEET_PATH m_SheetPathInclude
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:94
bool m_onBoard
True to include in netlist when updating board.
SCH_SHEET_PATH m_SheetPath
ELECTRICAL_PINTYPE m_ElectricalPinType
EDA_ITEM * m_Comp
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
TRANSFORM & GetTransform() const
std::unique_ptr< LIB_PART > m_part
SCH_PIN_MAP m_pinMap
the component's pins mapped by LIB_PIN*
int GetConvert() const
NETLIST_ITEM m_Type
SCH_ITEM * m_Link
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:186
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const

References GetConvert(), GetTransform(), GetUnitSelection(), LIB_PIN_T, NETLIST_OBJECT::m_Comp, NETLIST_OBJECT::m_ElectricalPinType, NETLIST_OBJECT::m_End, NETLIST_OBJECT::m_Label, NETLIST_OBJECT::m_Link, m_onBoard, m_part, m_pinMap, NETLIST_OBJECT::m_PinNum, m_pins, m_Pos, NETLIST_OBJECT::m_SheetPath, NETLIST_OBJECT::m_SheetPathInclude, NETLIST_OBJECT::m_Start, NETLIST_OBJECT::m_Type, PIN, PINLABEL, and TRANSFORM::TransformCoordinate().

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

1062 {
1063  int rotate_values[] =
1064  {
1065  CMP_ORIENT_0,
1066  CMP_ORIENT_90,
1072  CMP_MIRROR_Y,
1077  };
1078 
1079  // Try to find the current transform option:
1080  TRANSFORM transform = m_transform;
1081 
1082  for( int type_rotate : rotate_values )
1083  {
1084  SetOrientation( type_rotate );
1085 
1086  if( transform == m_transform )
1087  return type_rotate;
1088  }
1089 
1090  // Error: orientation not found in list (should not happen)
1091  wxFAIL_MSG( "Schematic symbol orientation matrix internal error." );
1092  m_transform = transform;
1093 
1094  return CMP_NORMAL;
1095 }
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(), SCH_SEXPR_PLUGIN::saveSymbol(), and DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataToWindow().

◆ GetParent()

◆ GetPartRef()

◆ GetPenWidth()

virtual int SCH_ITEM::GetPenWidth ( ) const
inlinevirtualinherited

◆ GetPin()

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

705 {
706  if( m_part )
707  {
708  return m_part->GetPin( number, m_unit, m_convert );
709  }
710 
711  return NULL;
712 }
#define NULL
std::unique_ptr< LIB_PART > m_part
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:99
int m_convert
The alternate body style for components that have more than one body style defined.

References m_convert, m_part, m_unit, and NULL.

Referenced by SCH_EDITOR_CONTROL::FindComponentAndItem().

◆ GetPinPhysicalPosition()

wxPoint SCH_COMPONENT::GetPinPhysicalPosition ( const LIB_PIN Pin) const

Definition at line 1403 of file sch_component.cpp.

1404 {
1405  wxCHECK_MSG( Pin != NULL && Pin->Type() == LIB_PIN_T, wxPoint( 0, 0 ),
1406  wxT( "Cannot get physical position of pin." ) );
1407 
1408  return m_transform.TransformCoordinate( Pin->GetPosition() ) + m_Pos;
1409 }
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:94
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
#define NULL
const wxPoint GetPosition() const override
Definition: lib_pin.h:430
TRANSFORM m_transform
The rotation/mirror transformation matrix.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

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

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

716 {
717  if( m_part )
718  m_part->GetPins( aPinsList, m_unit, m_convert );
719 }
std::unique_ptr< LIB_PART > m_part
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:99
int m_convert
The alternate body style for components that have more than one body style defined.

References m_convert, m_part, and m_unit.

Referenced by AUTOPLACER::pins_on_side(), and SCH_EDITOR_CONTROL::UpdateNetHighlighting().

◆ GetPosition()

◆ GetPrefix()

wxString SCH_COMPONENT::GetPrefix ( ) const
inline

Definition at line 290 of file sch_component.h.

290 { return m_prefix; }
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is.

References m_prefix.

Referenced by SCH_LEGACY_PLUGIN::saveComponent().

◆ GetRef()

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

Return the reference for the given sheet path.

Returns
the reference for the sheet.

Definition at line 416 of file sch_component.cpp.

417 {
418  KIID_PATH path = sheet->Path();
419  wxString ref;
420 
421  for( const COMPONENT_INSTANCE_REFERENCE& instance : m_instanceReferences )
422  {
423  if( instance.m_Path == path )
424  {
425  wxLogTrace( traceSchSheetPaths,
426  "Setting symbol instance:\n sheet path %s\n reference %s, unit %d\n found in symbol %s.",
427  path.AsString(), instance.m_Reference, instance.m_Unit, m_Uuid.AsString() );
428 
429  ref = instance.m_Reference;
430  break;
431  }
432  }
433 
434  // If it was not found in m_Paths array, then see if it is in m_Field[REFERENCE] -- if so,
435  // use this as a default for this path. This will happen if we load a version 1 schematic
436  // file. It will also mean that multiple instances of the same sheet by default all have
437  // the same component references, but perhaps this is best.
438  if( ref.IsEmpty() && !GetField( REFERENCE )->GetText().IsEmpty() )
439  {
440  SetRef( sheet, GetField( REFERENCE )->GetText() );
441  ref = GetField( REFERENCE )->GetText();
442  }
443 
444  if( ref.IsEmpty() )
445  ref = m_prefix;
446 
447  if( aIncludeUnit && GetUnitCount() > 1 )
448  ref += LIB_PART::SubReference( GetUnit() );
449 
450  return ref;
451 }
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
int GetUnitCount() const
Return the number of units per package of the symbol.
std::vector< COMPONENT_INSTANCE_REFERENCE > m_instanceReferences
wxString AsString() const
Definition: common.cpp:165
Field Reference of part, i.e. "IC21".
int GetUnit() const
A simple container for schematic symbol instance infromation.
wxString GetText(GRAPHIC_PINSHAPE aShape)
Definition: pin_shape.cpp:58
const KIID m_Uuid
Definition: base_struct.h:162
SCH_FIELD * GetField(int aFieldNdx)
Returns a field in this symbol.
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
wxString AsString() const
Definition: common.h:137
static wxString SubReference(int aUnit, bool aAddSeparator=true)
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is.
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:126

References KIID::AsString(), KIID_PATH::AsString(), GetField(), GetText(), EDA_TEXT::GetText(), GetUnit(), GetUnitCount(), m_instanceReferences, m_prefix, EDA_ITEM::m_Uuid, SCH_SHEET_PATH::Path(), REFERENCE, SetRef(), LIB_PART::SubReference(), and traceSchSheetPaths.

Referenced by NETLIST_EXPORTER_GENERIC::addComponentFields(), SCH_EDIT_FRAME::AnnotateComponents(), CollectOtherUnits(), DIALOG_LABEL_EDITOR::convertKIIDsToReferences(), DIALOG_LABEL_EDITOR::convertReferencesToKIIDs(), NETLIST_EXPORTER::CreatePinList(), NETLIST_EXPORTER::findAllUnitsOfComponent(), SCH_EDITOR_CONTROL::FindComponentAndItem(), NETLIST_EXPORTER::findNextComponent(), SCH_PIN::GetDefaultNetName(), GetMsgPanelInfo(), NETLIST_OBJECT::GetShortNetName(), NETLIST_EXPORTER_GENERIC::makeComponents(), NETLIST_EXPORTER_GENERIC::makeListOfNets(), SCH_EDIT_FRAME::mapExistingAnnotation(), SCH_FIELD::Matches(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), SCH_FIELD::Replace(), SCH_REFERENCE::SCH_REFERENCE(), SCH_SCREEN::SetComponentFootprint(), ERC_TESTER::TestMultiunitFootprints(), NETLIST_EXPORTER_CADSTAR::writeListOfNets(), NETLIST_EXPORTER_ORCADPCB2::WriteNetlist(), and NETLIST_EXPORTER_CADSTAR::WriteNetlist().

◆ GetSchPins()

SCH_PIN_PTRS SCH_COMPONENT::GetSchPins ( 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 722 of file sch_component.cpp.

723 {
724  SCH_PIN_PTRS ptrs;
725 
726  if( aSheet == nullptr )
727  {
728  wxCHECK_MSG( Schematic(), ptrs, "Can't call GetSchPins on a component with no schematic" );
729 
730  aSheet = &Schematic()->CurrentSheet();
731  }
732 
733  int unit = GetUnitSelection( aSheet );
734 
735  for( const auto& p : m_pins )
736  {
737  if( unit && p->GetLibPin()->GetUnit() && ( p->GetLibPin()->GetUnit() != unit ) )
738  continue;
739 
740  ptrs.push_back( p.get() );
741  }
742 
743  return ptrs;
744 }
std::vector< SCH_PIN * > SCH_PIN_PTRS
Definition: sch_component.h:71
SCH_PINS m_pins
a SCH_PIN for every LIB_PIN (across all units)
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:113
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
SCH_SHEET_PATH & CurrentSheet() const
Definition: schematic.h:122

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

Referenced by NETLIST_EXPORTER::CreatePinList(), KIGFX::SCH_PAINTER::draw(), SCH_ITEM::Duplicate(), SCH_SHEET_LIST::FillItemMap(), NETLIST_EXPORTER::findAllUnitsOfComponent(), SCH_SHEET_LIST::GetItem(), and CONNECTION_GRAPH::updateItemConnectivity().

◆ GetSchSymbolLibraryName()

wxString SCH_COMPONENT::GetSchSymbolLibraryName ( ) const

Definition at line 244 of file sch_component.cpp.

245 {
246  if( !m_schLibSymbolName.IsEmpty() )
247  return m_schLibSymbolName;
248  else
249  return m_lib_id.Format().wx_str();
250 }
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
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 1446 of file sch_component.cpp.

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

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

Referenced by Matches().

◆ GetState()

int EDA_ITEM::GetState ( int  type) const
inlineinherited

Definition at line 216 of file base_struct.h.

217  {
218  return m_Status & type;
219  }
STATUS_FLAGS m_Status
Definition: base_struct.h:173

References EDA_ITEM::m_Status.

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

◆ GetStatus()

STATUS_FLAGS EDA_ITEM::GetStatus ( ) const
inlineinherited

Definition at line 229 of file base_struct.h.

229 { return m_Status; }
STATUS_FLAGS m_Status
Definition: base_struct.h:173

References EDA_ITEM::m_Status.

Referenced by PCB_IO::format().

◆ GetStoredPos()

wxPoint& SCH_ITEM::GetStoredPos ( )
inlineinherited

Definition at line 242 of file sch_item.h.

242 { return m_storedPos; }
wxPoint m_storedPos
Definition: sch_item.h:194

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

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

Referenced by DIALOG_EDIT_LINE_STYLE::resetDefaults().

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

356 {
357  if( m_part )
358  return m_part->GetUnitCount();
359 
360  return 0;
361 }
std::unique_ptr< LIB_PART > m_part

References m_part.

Referenced by NETLIST_EXPORTER_GENERIC::addComponentFields(), SCH_EDIT_FRAME::AnnotateComponents(), CollectOtherUnits(), GetRef(), SCH_FIELD::GetShownText(), SCH_EDIT_FRAME::mapExistingAnnotation(), SCH_FIELD::Matches(), SCH_DRAWING_TOOLS::PlaceComponent(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow(), and DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::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 COMPONENT_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.
std::vector< COMPONENT_INSTANCE_REFERENCE > m_instanceReferences
A simple container for schematic symbol instance infromation.
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:99

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

Referenced by SCH_EDIT_FRAME::AnnotateComponents(), GetNetListItem(), GetSchPins(), SCH_EDIT_FRAME::mapExistingAnnotation(), and SCH_REFERENCE::SCH_REFERENCE().

◆ HasBrightenedPins()

bool SCH_COMPONENT::HasBrightenedPins ( )

Definition at line 1733 of file sch_component.cpp.

1734 {
1735  for( const auto& pin : m_pins )
1736  {
1737  if( pin->IsBrightened() )
1738  return true;
1739  }
1740 
1741  return false;
1742 }
SCH_PINS m_pins
a SCH_PIN for every LIB_PIN (across all units)

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

462 { return false; }

Referenced by EE_SELECTION::AllItemsHaveLineStroke(), SCH_EDIT_TOOL::Init(), 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 1657 of file sch_component.cpp.

1658 {
1659  EDA_RECT bBox = GetBodyBoundingBox();
1660  bBox.Inflate( aAccuracy );
1661 
1662  if( bBox.Contains( aPosition ) )
1663  return true;
1664 
1665  return false;
1666 }
bool Contains(const wxPoint &aPoint) const
Function Contains.
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.

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

1670 {
1672  return false;
1673 
1674  EDA_RECT rect = aRect;
1675 
1676  rect.Inflate( aAccuracy );
1677 
1678  if( aContained )
1679  return rect.Contains( GetBodyBoundingBox() );
1680 
1681  return rect.Intersects( GetBodyBoundingBox() );
1682 }
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: base_struct.h:128
bool Contains(const wxPoint &aPoint) const
Function Contains.
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: base_struct.h:126
STATUS_FLAGS m_Flags
Definition: base_struct.h:176
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.
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.

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

191 {
192  m_Pos = pos;
193  m_unit = 1; // In multi unit chip - which unit to draw.
194  m_convert = LIB_ITEM::LIB_CONVERT::BASE; // De Morgan Handling
195 
196  // The rotation/mirror transformation matrix. pos normal
198 
199  // construct only the mandatory fields, which are the first 4 only.
200  for( int i = 0; i < MANDATORY_FIELDS; ++i )
201  {
202  m_Fields.emplace_back( pos, i, this, TEMPLATE_FIELDNAME::GetDefaultFieldName( i ) );
203 
204  if( i == REFERENCE )
205  m_Fields.back().SetLayer( LAYER_REFERENCEPART );
206  else if( i == VALUE )
207  m_Fields.back().SetLayer( LAYER_VALUEPART );
208  else
209  m_Fields.back().SetLayer( LAYER_FIELDS );
210  }
211 
212  m_prefix = wxString( wxT( "U" ) );
213  m_isInNetlist = true;
214  m_inBom = true;
215  m_onBoard = true;
216 }
SCH_FIELDS m_Fields
Variable length list of fields.
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:94
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.
static const wxString GetDefaultFieldName(int aFieldNdx)
Function GetDefaultFieldName returns a default symbol field name for field aFieldNdx for all componen...
Field Reference of part, i.e. "IC21".
#define VALUE
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.
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:99
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.
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is.
TRANSFORM m_transform
The rotation/mirror transformation matrix.

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, and VALUE.

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

171 {
172  if( Connection( aSheet ) )
173  {
174  Connection( aSheet )->Reset();
175  Connection( aSheet )->SetSheet( aSheet );
176  return Connection( aSheet );
177  }
178 
179  auto connection = new SCH_CONNECTION( this );
180  connection->SetSheet( aSheet );
181  m_connection_map.insert( std::make_pair( aSheet, connection ) );
182  connection->SetGraph( aGraph );
183 
184  return connection;
185 }
void SetSheet(SCH_SHEET_PATH aSheet)
void Reset()
Clears connectivity information.
std::unordered_map< SCH_SHEET_PATH, SCH_CONNECTION * > m_connection_map
Stores connectivity information, per sheet.
Definition: sch_item.h:201
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:147
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(), 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 COMPONENT_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.
std::vector< COMPONENT_INSTANCE_REFERENCE > m_instanceReferences
A simple container for schematic symbol instance infromation.

References m_instanceReferences, and SCH_SHEET_PATH::Path().

Referenced by CollectOtherUnits(), and SCH_EDIT_FRAME::mapExistingAnnotation().

◆ IsBrightened()

bool EDA_ITEM::IsBrightened ( ) const
inlineinherited

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

606 { return m_onBoard; }
bool m_onBoard
True to include in netlist when updating board.

References m_onBoard.

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

139 {
140  if( ( m_Flags & STRUCT_DELETED ) || ( m_Flags & SKIP_STRUCT ) )
141  return false;
142 
143  return doIsConnected( aPosition );
144 }
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: base_struct.h:128
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:126
STATUS_FLAGS m_Flags
Definition: base_struct.h:176
virtual bool doIsConnected(const wxPoint &aPosition) const
Provide the object specific test to see if it is connected to aPosition.
Definition: sch_item.h:510

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

425 { return m_connectivity_dirty; }
bool m_connectivity_dirty
True if connectivity info might be out of date.
Definition: sch_item.h:204

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

362 { return false; }

◆ IsDragging()

bool EDA_ITEM::IsDragging ( ) const
inlineinherited

Definition at line 201 of file base_struct.h.

201 { return m_Flags & IS_DRAGGED; }
#define IS_DRAGGED
Item being dragged.
Definition: base_struct.h:119
STATUS_FLAGS m_Flags
Definition: base_struct.h:176

References IS_DRAGGED, and EDA_ITEM::m_Flags.

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

◆ IsForceVisible()

bool EDA_ITEM::IsForceVisible ( ) const
inlineinherited

Definition at line 286 of file base_struct.h.

286 { return m_forceVisible; }
bool m_forceVisible
Definition: base_struct.h:175

References EDA_ITEM::m_forceVisible.

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

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

1711 {
1712  return m_isInNetlist;
1713 }
bool m_isInNetlist
True if the component should appear in the netlist.

References m_isInNetlist.

Referenced by AUTOPLACER::AUTOPLACER(), and NETLIST_OBJECT_LIST::findBestNetNameForEachNet().

◆ IsLocked()

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

Definition at line 261 of file sch_item.h.

261 { return false; }

Referenced by SCH_EDIT_TOOL::DeleteItemCursor().

◆ IsModified()

bool EDA_ITEM::IsModified ( ) const
inlineinherited

Definition at line 198 of file base_struct.h.

198 { return m_Flags & IS_CHANGED; }
#define IS_CHANGED
std::function passed to nested users by ref, avoids copying std::function
Definition: base_struct.h:113
STATUS_FLAGS m_Flags
Definition: base_struct.h:176

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

202 { return true; }

◆ IsMoving()

◆ IsNew()

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

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

Referenced by ClearAnnotation(), SetRef(), DIALOG_EDIT_ONE_FIELD::TransferDataFromWindow(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::Validate(), and DIALOG_EDIT_COMPONENT_IN_LIBRARY::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 650 of file sch_component.h.

650 { return true; }

◆ IsResized()

bool EDA_ITEM::IsResized ( ) const
inlineinherited

Definition at line 204 of file base_struct.h.

204 { return m_Flags & IS_RESIZED; }
STATUS_FLAGS m_Flags
Definition: base_struct.h:176
#define IS_RESIZED
Item being resized.
Definition: base_struct.h:118

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 SCH_LABEL, VIA, DIMENSION, D_PAD, DRAWSEGMENT, TEXTE_MODULE, SCH_FIELD, SCH_LINE, EDGE_MODULE, and TEXTE_PCB.

Definition at line 262 of file base_struct.h.

263  {
264  if( aScanTypes[0] == SCH_LOCATE_ANY_T )
265  return true;
266 
267  for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
268  {
269  if( m_StructType == *p )
270  return true;
271  }
272 
273  return false;
274  }
KICAD_T m_StructType
Run time identification, keep private so it can never be changed after a constructor sets it.
Definition: base_struct.h:170
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

References EOT, EDA_ITEM::m_StructType, and SCH_LOCATE_ANY_T.

Referenced by GetRule(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingBus(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingLine(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingWire(), TEXTE_PCB::IsType(), EDGE_MODULE::IsType(), SCH_LINE::IsType(), SCH_FIELD::IsType(), TEXTE_MODULE::IsType(), DRAWSEGMENT::IsType(), D_PAD::IsType(), DIMENSION::IsType(), VIA::IsType(), SCH_LABEL::IsType(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), EE_SELECTION_TOOL::RequestSelection(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), EDA_ITEM::Visit(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ IsWireImage()

bool EDA_ITEM::IsWireImage ( ) const
inlineinherited

Definition at line 202 of file base_struct.h.

202 { return m_Flags & IS_WIRE_IMAGE; }
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.
Definition: base_struct.h:121
STATUS_FLAGS m_Flags
Definition: base_struct.h:176

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 383 of file base_struct.h.

387  {
388  for( auto it : aList )
389  {
390  if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
392  return SEARCH_RESULT::QUIT;
393  }
394 
396  }
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...

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

Referenced by GERBER_FILE_IMAGE::Visit(), and BOARD::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 404 of file base_struct.h.

406  {
407  for( auto it : aList )
408  {
409  if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
411  return SEARCH_RESULT::QUIT;
412  }
413 
415  }
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...

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 143 of file base_struct.cpp.

144 {
145  wxString text = aText;
146  wxString searchText = aSearchData.GetFindString();
147 
148  // Don't match if searching for replaceable item and the item doesn't support text replace.
149  if( (aSearchData.GetFlags() & FR_SEARCH_REPLACE) && !IsReplaceable() )
150  return false;
151 
152  if( aSearchData.GetFlags() & wxFR_WHOLEWORD )
153  return aText.IsSameAs( searchText, aSearchData.GetFlags() & wxFR_MATCHCASE );
154 
155  if( aSearchData.GetFlags() & FR_MATCH_WILDCARD )
156  {
157  if( aSearchData.GetFlags() & wxFR_MATCHCASE )
158  return text.Matches( searchText );
159 
160  return text.MakeUpper().Matches( searchText.MakeUpper() );
161  }
162 
163  if( aSearchData.GetFlags() & wxFR_MATCHCASE )
164  return aText.Find( searchText ) != wxNOT_FOUND;
165 
166  return text.MakeUpper().Find( searchText.MakeUpper() ) != wxNOT_FOUND;
167 }
virtual bool IsReplaceable() const
Function IsReplaceable.
Definition: base_struct.h:501

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

1329 {
1330  wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText( EDA_UNITS::MILLIMETRES ) );
1331 
1332  // Components are searchable via the child field and pin item text.
1333  return false;
1334 }
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 1291 of file sch_component.cpp.

1292 {
1293  int dy = m_Pos.y;
1294 
1296  MIRROR( m_Pos.y, aXaxis_position );
1297  dy -= m_Pos.y; // dy,0 is the move vector for this transform
1298 
1299  for( SCH_FIELD& field : m_Fields )
1300  {
1301  // Move the fields to the new position because the component itself has moved.
1302  wxPoint pos = field.GetTextPos();
1303  pos.y -= dy;
1304  field.SetTextPos( pos );
1305  }
1306 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
SCH_FIELDS m_Fields
Variable length list of fields.
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:94
void MIRROR(T &aPoint, const T &aMirrorRef)
Definition: macros.h:175
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(), SetOrientation(), and wxPoint::y.

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

1274 {
1275  int dx = m_Pos.x;
1276 
1278  MIRROR( m_Pos.x, aYaxis_position );
1279  dx -= m_Pos.x; // dx,0 is the move vector for this transform
1280 
1281  for( SCH_FIELD& field : m_Fields )
1282  {
1283  // Move the fields to the new position because the component itself has moved.
1284  wxPoint pos = field.GetTextPos();
1285  pos.x -= dx;
1286  field.SetTextPos( pos );
1287  }
1288 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
SCH_FIELDS m_Fields
Variable length list of fields.
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:94
void MIRROR(T &aPoint, const T &aMirrorRef)
Definition: macros.h:175
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(), SetOrientation(), and wxPoint::x.

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

570  {
571  if( aMoveVector == wxPoint( 0, 0 ) )
572  return;
573 
574  m_Pos += aMoveVector;
575 
576  for( SCH_FIELD& field : m_Fields )
577  field.Move( aMoveVector );
578 
579  SetModified();
580  }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
void SetModified()
Definition: base_struct.cpp:85
SCH_FIELDS m_Fields
Variable length list of fields.
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:94

References m_Fields, m_Pos, and EDA_ITEM::SetModified().

Referenced by SetPosition().

◆ operator!=()

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

Definition at line 1614 of file sch_component.cpp.

1615 {
1616  return !( *this == aComponent );
1617 }

◆ 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 197 of file base_struct.cpp.

198 {
199  wxFAIL_MSG( wxString::Format( wxT( "Less than operator not defined for item type %s." ),
200  GetChars( GetClass() ) ) );
201 
202  return false;
203 }
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:153
virtual wxString GetClass() const =0
Function GetClass returns the class name.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205

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

◆ operator<() [2/2]

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

Reimplemented from SCH_ITEM.

Definition at line 1577 of file sch_component.cpp.

1578 {
1579  if( Type() != aItem.Type() )
1580  return Type() < aItem.Type();
1581 
1582  auto component = static_cast<const SCH_COMPONENT*>( &aItem );
1583 
1584  EDA_RECT rect = GetBodyBoundingBox();
1585 
1586  if( rect.GetArea() != component->GetBodyBoundingBox().GetArea() )
1587  return rect.GetArea() < component->GetBodyBoundingBox().GetArea();
1588 
1589  if( m_Pos.x != component->m_Pos.x )
1590  return m_Pos.x < component->m_Pos.x;
1591 
1592  if( m_Pos.y != component->m_Pos.y )
1593  return m_Pos.y < component->m_Pos.y;
1594 
1595  return m_Uuid < aItem.m_Uuid; // Ensure deterministic sort
1596 }
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:94
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.
const KIID m_Uuid
Definition: base_struct.h:162
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

References EDA_RECT::GetArea(), GetBodyBoundingBox(), m_Pos, EDA_ITEM::m_Uuid, EDA_ITEM::Type(), wxPoint::x, and wxPoint::y.

◆ operator=()

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

Definition at line 1620 of file sch_component.cpp.

1621 {
1622  wxCHECK_MSG( Type() == aItem.Type(), *this,
1623  wxT( "Cannot assign object type " ) + aItem.GetClass() + wxT( " to type " ) +
1624  GetClass() );
1625 
1626  if( &aItem != this )
1627  {
1628  SCH_ITEM::operator=( aItem );
1629 
1630  SCH_COMPONENT* c = (SCH_COMPONENT*) &aItem;
1631 
1632  m_lib_id = c->m_lib_id;
1633 
1634  LIB_PART* libSymbol = c->m_part ? new LIB_PART( *c->m_part.get() ) : nullptr;
1635 
1636  m_part.reset( libSymbol );
1637  m_Pos = c->m_Pos;
1638  m_unit = c->m_unit;
1639  m_convert = c->m_convert;
1640  m_transform = c->m_transform;
1641 
1643 
1644  m_Fields = c->m_Fields; // std::vector's assignment operator
1645 
1646  // Reparent fields after assignment to new component.
1647  for( SCH_FIELD& field : m_Fields )
1648  field.SetParent( this );
1649 
1650  UpdatePins();
1651  }
1652 
1653  return *this;
1654 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
SCH_FIELDS m_Fields
Variable length list of fields.
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:94
std::vector< COMPONENT_INSTANCE_REFERENCE > m_instanceReferences
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.
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:99
Schematic symbol object.
Definition: sch_component.h:88
virtual wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_item.h:213
int m_convert
The alternate body style for components that have more than one body style defined.
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.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

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

1600 {
1601  if( GetFieldCount() != aComponent.GetFieldCount() )
1602  return false;
1603 
1604  for( int i = VALUE; i < GetFieldCount(); i++ )
1605  {
1606  if( GetField( i )->GetText().Cmp( aComponent.GetField( i )->GetText() ) != 0 )
1607  return false;
1608  }
1609 
1610  return true;
1611 }
#define VALUE
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:126

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

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

1717 {
1718  if( m_part )
1719  {
1720  TRANSFORM temp = GetTransform();
1721  aPlotter->StartBlock( nullptr );
1722 
1723  m_part->Plot( aPlotter, GetUnit(), GetConvert(), m_Pos, temp );
1724 
1725  for( SCH_FIELD field : m_Fields )
1726  field.Plot( aPlotter );
1727 
1728  aPlotter->EndBlock( nullptr );
1729  }
1730 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
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:486
SCH_FIELDS m_Fields
Variable length list of fields.
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:94
virtual void StartBlock(void *aData)
calling this function allows one to define the beginning of a group of drawing items,...
Definition: plotter.h:477
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

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

365 {
366  PART_DRAW_OPTIONS opts;
367  opts.transform = m_transform;
368  opts.draw_visible_fields = false;
369  opts.draw_hidden_fields = false;
370 
371  if( m_part )
372  {
373  m_part->Print( aSettings, m_Pos + aOffset, m_unit, m_convert, opts );
374  }
375  else // Use dummy() part if the actual cannot be found.
376  {
377  dummy()->Print( aSettings, m_Pos + aOffset, 0, 0, opts );
378  }
379 
380  for( SCH_FIELD& field : m_Fields )
381  field.Print( aSettings, aOffset );
382 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
SCH_FIELDS m_Fields
Variable length list of fields.
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:94
std::unique_ptr< LIB_PART > m_part
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:99
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.
TRANSFORM m_transform
The rotation/mirror transformation matrix.

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

622 {
623  for( unsigned i = MANDATORY_FIELDS; i < m_Fields.size(); ++i )
624  {
625  if( aFieldName == m_Fields[i].GetName( false ) )
626  {
627  m_Fields.erase( m_Fields.begin() + i );
628  return;
629  }
630  }
631 }
SCH_FIELDS m_Fields
Variable length list of fields.
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.

References m_Fields, and MANDATORY_FIELDS.

Referenced by FIELDS_EDITOR_GRID_DATA_MODEL::ApplyData().

◆ 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 170 of file base_struct.cpp.

171 {
172  wxString searchString = (aSearchData.GetFlags() & wxFR_MATCHCASE) ? aText : aText.Upper();
173 
174  int result = searchString.Find( (aSearchData.GetFlags() & wxFR_MATCHCASE) ?
175  aSearchData.GetFindString() :
176  aSearchData.GetFindString().Upper() );
177 
178  if( result == wxNOT_FOUND )
179  return false;
180 
181  wxString prefix = aText.Left( result );
182  wxString suffix;
183 
184  if( aSearchData.GetFindString().length() + result < aText.length() )
185  suffix = aText.Right( aText.length() - ( aSearchData.GetFindString().length() + result ) );
186 
187  wxLogTrace( traceFindReplace, wxT( "Replacing '%s', prefix '%s', replace '%s', suffix '%s'." ),
188  GetChars( aText ), GetChars( prefix ), GetChars( aSearchData.GetReplaceString() ),
189  GetChars( suffix ) );
190 
191  aText = prefix + aSearchData.GetReplaceString() + suffix;
192 
193  return true;
194 }
const wxChar *const traceFindReplace
Flag to enable find and replace debug tracing.
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:153

References GetChars(), and 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, and SCH_FIELD.

Definition at line 489 of file base_struct.h.

489 { 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 906 of file sch_component.cpp.

908 {
909  auto it = std::find_if( m_instanceReferences.begin(), m_instanceReferences.end(),
910  [ aOldSheetPath ]( COMPONENT_INSTANCE_REFERENCE& r )->bool
911  {
912  return aOldSheetPath == r.m_Path;
913  }
914  );
915 
916  if( it != m_instanceReferences.end() )
917  {
918  wxLogTrace( traceSchSheetPaths,
919  "Replacing sheet path %s\n with sheet path %s\n for symbol %s.",
920  aOldSheetPath.AsString(), aNewSheetPath.AsString(), m_Uuid.AsString() );
921 
922  it->m_Path = aNewSheetPath;
923  return true;
924  }
925 
926  wxLogTrace( traceSchSheetPaths,
927  "Could not find sheet path %s\n to replace with sheet path %s\n for symbol %s.",
928  aOldSheetPath.AsString(), aNewSheetPath.AsString(), m_Uuid.AsString() );
929 
930  return false;
931 }
const wxChar *const traceSchSheetPaths
Flag to enable debug output of schematic symbol sheet path manipulation code.
std::vector< COMPONENT_INSTANCE_REFERENCE > m_instanceReferences
wxString AsString() const
Definition: common.cpp:165
A simple container for schematic symbol instance infromation.
const KIID m_Uuid
Definition: base_struct.h:162
wxString AsString() const
Definition: common.h:137

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

798 {
799  for( int i = 0; i < MANDATORY_FIELDS; ++i )
800  {
801  if( token->IsSameAs( m_Fields[ i ].GetCanonicalName().Upper() ) )
802  {
803  *token = m_Fields[ i ].GetShownText( aDepth + 1 );
804  return true;
805  }
806  }
807 
808  for( size_t i = MANDATORY_FIELDS; i < m_Fields.size(); ++i )
809  {
810  if( token->IsSameAs( m_Fields[ i ].GetName() )
811  || token->IsSameAs( m_Fields[ i ].GetName().Upper() ) )
812  {
813  *token = m_Fields[ i ].GetShownText( aDepth + 1 );
814  return true;
815  }
816  }
817 
818  if( token->IsSameAs( wxT( "FOOTPRINT_LIBRARY" ) ) )
819  {
820  const SCH_FIELD& field = m_Fields[ FOOTPRINT ];
821  wxArrayString parts = wxSplit( field.GetText(), ':' );
822 
823  *token = parts[ 0 ];
824  return true;
825  }
826  else if( token->IsSameAs( wxT( "FOOTPRINT_NAME" ) ) )
827  {
828  const SCH_FIELD& field = m_Fields[ FOOTPRINT ];
829  wxArrayString parts = wxSplit( field.GetText(), ':' );
830 
831  *token = parts[ std::min( 1, (int) parts.size() - 1 ) ];
832  return true;
833  }
834  else if( token->IsSameAs( wxT( "UNIT" ) ) )
835  {
836  *token = LIB_PART::SubReference( GetUnit() );
837  return true;
838  }
839 
840  return false;
841 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
SCH_FIELDS m_Fields
Variable length list of fields.
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
Field Name Module PCB, i.e. "16DIP300".
int GetUnit() const
static wxString SubReference(int aUnit, bool aAddSeparator=true)
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:126

References FOOTPRINT, EDA_TEXT::GetText(), GetUnit(), m_Fields, MANDATORY_FIELDS, and LIB_PART::SubReference().

Referenced by DIALOG_LABEL_EDITOR::convertReferencesToKIIDs(), SCH_FIELD::GetShownText(), and SCH_TEXT::GetShownText().

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

1310 {
1311  wxPoint prev = m_Pos;
1312 
1313  RotatePoint( &m_Pos, aPosition, 900 );
1314 
1316 
1317  for( SCH_FIELD& field : m_Fields )
1318  {
1319  // Move the fields to the new position because the component itself has moved.
1320  wxPoint pos = field.GetTextPos();
1321  pos.x -= prev.x - m_Pos.x;
1322  pos.y -= prev.y - m_Pos.y;
1323  field.SetTextPos( pos );
1324  }
1325 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
SCH_FIELDS m_Fields
Variable length list of fields.
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:94
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
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(), SetOrientation(), wxPoint::x, and wxPoint::y.

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

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

114 {
115  EDA_ITEM* parent = GetParent();
116 
117  while( parent )
118  {
119  if( parent->Type() == SCHEMATIC_T )
120  return static_cast<SCHEMATIC*>( parent );
121  else
122  parent = parent->GetParent();
123  }
124 
125  return nullptr;
126 }
EDA_ITEM * GetParent() const
Definition: base_struct.h:195
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

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

Referenced by SCH_EDIT_FRAME::CreateSheetPin(), SCH_JUNCTION::GetBoundingBox(), SCH_MARKER::GetColorLayer(), SCH_LINE::GetPenWidth(), SCH_BUS_WIRE_ENTRY::GetPenWidth(), SCH_BUS_BUS_ENTRY::GetPenWidth(), GetSchPins(), SCH_FIELD::GetShownText(), SCH_TEXT::GetShownText(), SCH_SHEET::IsRootSheet(), SCH_LABEL::IsType(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnAddField(), SCH_JUNCTION::Plot(), SCH_JUNCTION::Print(), SCH_HIERLABEL::Print(), SCH_SHEET::ResolveTextVar(), and SCH_MARKER::ViewGetLayers().

◆ SetBrightened()

void EDA_ITEM::SetBrightened ( )
inlineinherited

◆ SetConnectivityDirty()

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

Definition at line 427 of file sch_item.h.

427 { m_connectivity_dirty = aDirty; }
bool m_connectivity_dirty
True if connectivity info might be out of date.
Definition: sch_item.h:204

References SCH_ITEM::m_connectivity_dirty.

Referenced by SCH_EDIT_FRAME::SaveCopyInUndoList().

◆ SetConvert()

void SCH_COMPONENT::SetConvert ( int  aConvert)

Definition at line 332 of file sch_component.cpp.

333 {
334  if( m_convert != aConvert )
335  {
336  m_convert = aConvert;
337 
338  // The convert may have a different pin layout so the update the pin map.
339  UpdatePins();
340  SetModified();
341  }
342 }
void SetModified()
Definition: base_struct.cpp:85
int m_convert
The alternate body style for components that have more than one body style defined.
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_EDIT_COMPONENT_IN_SCHEMATIC::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 449 of file sch_component.h.

450  {
451  m_Fields = aFields; // vector copying, length is changed possibly
452  }
SCH_FIELDS m_Fields
Variable length list of fields.

References m_Fields.

Referenced by DIALOG_UPDATE_FIELDS::updateFields(), and DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::UpdateFieldsFromLibrary().

◆ SetFlags()

void EDA_ITEM::SetFlags ( STATUS_FLAGS  aMask)
inlineinherited

Definition at line 232 of file base_struct.h.

232 { m_Flags |= aMask; }
STATUS_FLAGS m_Flags
Definition: base_struct.h:176

References EDA_ITEM::m_Flags.

Referenced by SCH_EAGLE_PLUGIN::addBusEntries(), PCB_BASE_FRAME::AddModuleToBoard(), PCBNEW_CONTROL::AppendBoard(), SCH_EDIT_TOOL::ChangeTextType(), GRAPHICS_CLEANER::cleanupSegments(), TRACKS_CLEANER::cleanupSegments(), SCH_EDIT_FRAME::ConvertPart(), SCH_DRAWING_TOOLS::createNewText(), LIB_PIN_TOOL::CreatePin(), SCH_EDIT_FRAME::CreateSheetPin(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), KIGFX::SCH_PAINTER::draw(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), DRAWING_TOOL::DrawRectangle(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SCH_EDIT_TOOL::Duplicate(), LIB_EDIT_FRAME::GetComponentFromRedoList(), LIB_EDIT_FRAME::GetComponentFromUndoList(), SCH_MOVE_TOOL::getConnectedDragItems(), EDIT_POINTS_FACTORY::Make(), TRACKS_CLEANER::mergeCollinearSegments(), LIB_MOVE_TOOL::moveItem(), SCH_MOVE_TOOL::moveItem(), KIGFX::ORIGIN_VIEWITEM::ORIGIN_VIEWITEM(), 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(), SCH_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_PIN_TOOL::RepeatPin(), LIB_EDIT_FRAME::SaveCopyInUndoList(), SELECTION_TOOL::selectConnectedTracks(), EE_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectPoint(), SCH_EDIT_FRAME::SelectUnit(), EDA_ITEM::SetBrightened(), LIB_PIN::SetConversion(), 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_TARGET_PROPERTIES::TransferDataFromWindow(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow(), DIALOG_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), LIB_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ 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 284 of file base_struct.h.

284 { m_forceVisible = aEnable; }
bool m_forceVisible
Definition: base_struct.h:175

References EDA_ITEM::m_forceVisible.

◆ SetIncludeInBom()

void SCH_COMPONENT::SetIncludeInBom ( bool  aIncludeInBom)
inline

Definition at line 673 of file sch_component.h.

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

References m_inBom.

Referenced by DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow().

◆ SetIncludeOnBoard()

void SCH_COMPONENT::SetIncludeOnBoard ( bool  aIncludeOnBoard)
inline

Definition at line 676 of file sch_component.h.

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

References m_onBoard.

Referenced by DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow().

◆ SetLayer()

void SCH_ITEM::SetLayer ( SCH_LAYER_ID  aLayer)
inlineinherited

Set the layer this item is on.

Parameters
aLayerThe layer number.

Definition at line 278 of file sch_item.h.

278 { m_Layer = aLayer; }
SCH_LAYER_ID m_Layer
Definition: sch_item.h:191

References SCH_ITEM::m_Layer.

Referenced by PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems(), KIGFX::SCH_PAINTER::draw(), SCH_NO_CONNECT::SCH_NO_CONNECT(), SCH_FIELD::SetId(), and CONNECTION_GRAPH::updateItemConnectivity().

◆ SetLibId()

void SCH_COMPONENT::SetLibId ( const LIB_ID aName)

Definition at line 234 of file sch_component.cpp.

235 {
236  if( m_lib_id != aLibId )
237  {
238  m_lib_id = aLibId;
239  SetModified();
240  }
241 }
void SetModified()
Definition: base_struct.cpp:85

References m_lib_id, and EDA_ITEM::SetModified().

Referenced by DIALOG_SYMBOL_REMAP::remapSymbolToLibTable(), and DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow().

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

254 {
255  wxCHECK2( ( aLibSymbol == nullptr ) || ( aLibSymbol->IsRoot() ), aLibSymbol = nullptr );
256 
257  m_part.reset( aLibSymbol );
258  UpdatePins();
259 }
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 SCH_EDITOR_CONTROL::Paste(), SCH_COMPONENT(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow(), and DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::UpdateFieldsFromLibrary().

◆ SetLocked()

virtual void SCH_ITEM::SetLocked ( bool  aLocked)
inlinevirtualinherited

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

Definition at line 266 of file sch_item.h.

266 {}

◆ SetModified()

void EDA_ITEM::SetModified ( )
inherited

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

935 {
936  TRANSFORM temp = TRANSFORM();
937  bool transform = false;
938 
939  switch( aOrientation )
940  {
941  case CMP_ORIENT_0:
942  case CMP_NORMAL: // default transform matrix
943  m_transform.x1 = 1;
944  m_transform.y2 = -1;
946  break;
947 
948  case CMP_ROTATE_COUNTERCLOCKWISE: // Rotate + (incremental rotation)
949  temp.x1 = temp.y2 = 0;
950  temp.y1 = 1;
951  temp.x2 = -1;
952  transform = true;
953  break;
954 
955  case CMP_ROTATE_CLOCKWISE: // Rotate - (incremental rotation)
956  temp.x1 = temp.y2 = 0;
957  temp.y1 = -1;
958  temp.x2 = 1;
959  transform = true;
960  break;
961 
962  case CMP_MIRROR_Y: // Mirror Y (incremental rotation)
963  temp.x1 = -1;
964  temp.y2 = 1;
965  temp.y1 = temp.x2 = 0;
966  transform = true;
967  break;
968 
969  case CMP_MIRROR_X: // Mirror X (incremental rotation)
970  temp.x1 = 1;
971  temp.y2 = -1;
972  temp.y1 = temp.x2 = 0;
973  transform = true;
974  break;
975 
976  case CMP_ORIENT_90:
979  break;
980 
981  case CMP_ORIENT_180:
985  break;
986 
987  case CMP_ORIENT_270:
990  break;
991 
992  case ( CMP_ORIENT_0 + CMP_MIRROR_X ):
995  break;
996 
997  case ( CMP_ORIENT_0 + CMP_MIRROR_Y ):
1000  break;
1001 
1002  case ( CMP_ORIENT_90 + CMP_MIRROR_X ):
1005  break;
1006 
1007  case ( CMP_ORIENT_90 + CMP_MIRROR_Y ):
1010  break;
1011 
1012  case ( CMP_ORIENT_180 + CMP_MIRROR_X ):
1015  break;
1016 
1017  case ( CMP_ORIENT_180 + CMP_MIRROR_Y ):
1020  break;
1021 
1022  case ( CMP_ORIENT_270 + CMP_MIRROR_X ):
1025  break;
1026 
1027  case ( CMP_ORIENT_270 + CMP_MIRROR_Y ):
1030  break;
1031 
1032  default:
1033  transform = false;
1034  wxFAIL_MSG( "Invalid schematic symbol orientation type." );
1035  break;
1036  }
1037 
1038  if( transform )
1039  {
1040  /* The new matrix transform is the old matrix transform modified by the
1041  * requested transformation, which is the temp transform (rot,
1042  * mirror ..) in order to have (in term of matrix transform):
1043  * transform coord = new_m_transform * coord
1044  * where transform coord is the coord modified by new_m_transform from
1045  * the initial value coord.
1046  * new_m_transform is computed (from old_m_transform and temp) to
1047  * have:
1048  * transform coord = old_m_transform * temp
1049  */
1050  TRANSFORM newTransform;
1051 
1052  newTransform.x1 = m_transform.x1 * temp.x1 + m_transform.x2 * temp.y1;
1053  newTransform.y1 = m_transform.y1 * temp.x1 + m_transform.y2 * temp.y1;
1054  newTransform.x2 = m_transform.x1 * temp.x2 + m_transform.x2 * temp.y2;
1055  newTransform.y2 = m_transform.y1 * temp.x2 + m_transform.y2 * temp.y2;
1056  m_transform = newTransform;
1057  }
1058 }
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(), SCH_EDIT_TOOL::Mirror(), MirrorX(), MirrorY(), SCH_EDIT_TOOL::Rotate(), Rotate(), and DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow().

◆ SetParent()

virtual void EDA_ITEM::SetParent ( EDA_ITEM aParent)
inlinevirtualinherited

Definition at line 196 of file base_struct.h.

196 { m_Parent = aParent; }
EDA_ITEM * m_Parent
Linked list: Link (parent struct)
Definition: base_struct.h:174

References EDA_ITEM::m_Parent.

Referenced by MODULE::Add(), BOARD::Add(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), BOARD_NETLIST_UPDATER::addNewComponent(), SCH_SHEET::AddPin(), LIB_CONTROL::AddSymbolToSchematic(), SCH_SCREEN::Append(), LIB_FIELD::Copy(), LIB_EDIT_FRAME::CreateNewPart(), SCH_DRAWING_TOOLS::createNewText(), DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), SCH_EDIT_TOOL::Duplicate(), PCB_EDIT_FRAME::Exchange_Module(), LIB_PART::Flatten(), PCB_IO::FootprintSave(), DISPLAY_FOOTPRINTS_FRAME::GetModule(), LIB_PART::LIB_PART(), FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD(), SCH_LEGACY_PLUGIN_CACHE::loadAliases(), SCH_SEXPR_PLUGIN::loadHierarchy(), SCH_LEGACY_PLUGIN::loadHierarchy(), LIB_EDIT_FRAME::LoadOneSymbol(), MODULE::MODULE(), DIALOG_LIB_EDIT_PIN::OnPaintShowPanel(), MODULE::operator=(), LIB_PART::operator=(), PCB_PARSER::parseMODULE_unchecked(), SCH_SEXPR_PARSER::ParseSchematic(), SCH_SEXPR_PARSER::ParseSymbol(), LIB_EDIT_TOOL::Paste(), PCBNEW_CONTROL::Paste(), SCH_EDITOR_CONTROL::Paste(), pasteModuleItemsToModEdit(), SCH_DRAWING_TOOLS::PlaceComponent(), PCB_EDITOR_CONTROL::PlaceModule(), 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(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_SHEET::SwapData(), SwapData(), SwapItemData(), and DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::UpdateFieldsFromLibrary().

◆ SetPosition()

void SCH_COMPONENT::SetPosition ( const wxPoint aPosition)
inlineoverridevirtual

Set the schematic item position to aPosition.

Parameters
aPositionA reference to a wxPoint object containing the new position.

Implements SCH_ITEM.

Definition at line 653 of file sch_component.h.

653 { Move( aPosition - m_Pos ); }
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:94
void Move(const wxPoint &aMoveVector) override
Move the item by aMoveVector to a new position.

References m_Pos, and Move().

Referenced by SCH_DRAWING_TOOLS::PlaceComponent().

◆ SetPrefix()

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

Definition at line 292 of file sch_component.h.

292 { m_prefix = aPrefix; }
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is.

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

471 {
472  KIID_PATH path = sheet->Path();
473  bool notInArray = true;
474 
475  // check to see if it is already there before inserting it
477  {
478  if( instance.m_Path == path )
479  {
480  instance.m_Reference = ref;
481  notInArray = false;
482  }
483  }
484 
485  if( notInArray )
486  AddHierarchicalReference( path, ref, m_unit );
487 
488  SCH_FIELD* rf = GetField( REFERENCE );
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:52
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:94
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:246
std::vector< COMPONENT_INSTANCE_REFERENCE > m_instanceReferences
Field Reference of part, i.e. "IC21".
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:116
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:99
const wxPoint & GetTextPos() const
Definition: eda_text.h:247
void AddHierarchicalReference(const KIID_PATH &aPath, const wxString &aRef, int aUnit)
Add a full hierarchical reference to this symbol.
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.
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:126

References AddHierarchicalReference(), GetField(), EDA_TEXT::GetText(), EDA_TEXT::GetTextPos(), IsReferenceStringValid(), m_instanceReferences, m_isInNetlist, m_Pos, m_prefix, m_unit, SCH_SHEET_PATH::Path(), REFERENCE, EDA_TEXT::SetText(), EDA_TEXT::SetTextPos(), wxPoint::x, and wxPoint::y.

Referenced by SCH_REFERENCE::Annotate(), BACK_ANNOTATE::applyChangelist(), GetRef(), SCH_FIELD::Replace(), SCH_COMPONENT(), SCH_REFERENCE::SCH_REFERENCE(), TEST_SCH_PIN_FIXTURE::TEST_SCH_PIN_FIXTURE(), and DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow().

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

219 { 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 221 of file base_struct.h.

222  {
223  if( state )
224  m_Status |= type; // state = ON or OFF
225  else
226  m_Status &= ~type;
227  }
STATUS_FLAGS m_Status
Definition: base_struct.h:173

References EDA_ITEM::m_Status.

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

◆ SetStatus()

void EDA_ITEM::SetStatus ( STATUS_FLAGS  aStatus)
inlineinherited

Definition at line 230 of file base_struct.h.

230 { m_Status = aStatus; }
STATUS_FLAGS m_Status
Definition: base_struct.h:173

References EDA_ITEM::m_Status.

Referenced by BOARD_NETLIST_UPDATER::UpdateNetlist().

◆ SetStoredPos()

void SCH_ITEM::SetStoredPos ( wxPoint  aPos)
inlineinherited

Definition at line 243 of file sch_item.h.

243 { m_storedPos = aPos; }
wxPoint m_storedPos
Definition: sch_item.h:194

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

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

◆ SetTransform()

void SCH_COMPONENT::SetTransform ( const TRANSFORM aTransform)

Definition at line 345 of file sch_component.cpp.

346 {
347  if( m_transform != aTransform )
348  {
349  m_transform = aTransform;
350  SetModified();
351  }
352 }
void SetModified()
Definition: base_struct.cpp:85
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 316 of file sch_component.cpp.

317 {
318  if( m_unit != aUnit )
319  {
320  m_unit = aUnit;
321  SetModified();
322  }
323 }
void SetModified()
Definition: base_struct.cpp:85
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:99

References m_unit, and EDA_ITEM::SetModified().

Referenced by SCH_REFERENCE::Annotate(), SCH_EDITOR_CONTROL::Paste(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_EDIT_FRAME::SelectUnit(), and DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow().

◆ 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  bool notInArray = true;
556 
557  // check to see if it is already there before inserting it
559  {
560  if( instance.m_Path == path )
561  {
562  instance.m_Unit = aUnitSelection;
563  notInArray = false;
564  }
565  }
566 
567  if( notInArray )
568  AddHierarchicalReference( path, m_prefix, aUnitSelection );
569 }
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
std::vector< COMPONENT_INSTANCE_REFERENCE > m_instanceReferences
A simple container for schematic symbol instance infromation.
void AddHierarchicalReference(const KIID_PATH &aPath, const wxString &aRef, int aUnit)
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.

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_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow().

◆ SetWireImage()

void EDA_ITEM::SetWireImage ( )
inlineinherited

Definition at line 207 of file base_struct.h.

207 { SetFlags( IS_WIRE_IMAGE ); }
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:232
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.
Definition: base_struct.h:121

References IS_WIRE_IMAGE, and EDA_ITEM::SetFlags().

◆ Sort()

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

Function Sort is a helper function to be used by the C++ STL sort algorithm for sorting a STL container of EDA_ITEM pointers.

Parameters
aLeftThe left hand item to compare.
aRightThe right hand item to compare.
Returns
True if aLeft is less than aRight.

Definition at line 520 of file base_struct.h.

520 { return *aLeft < *aRight; }

◆ SwapData()

void SCH_COMPONENT::SwapData ( SCH_ITEM aItem)
overridevirtual

Swap the internal data structures aItem with the schematic item.

Obviously, aItem must have the same type than me

Parameters
aItemThe item to swap the data structures with.

Reimplemented from SCH_ITEM.

Definition at line 747 of file sch_component.cpp.

748 {
749  wxCHECK_RET( (aItem != NULL) && (aItem->Type() == SCH_COMPONENT_T),
750  wxT( "Cannot swap data with invalid component." ) );
751 
752  SCH_COMPONENT* component = (SCH_COMPONENT*) aItem;
753 
754  std::swap( m_lib_id, component->m_lib_id );
755 
756  LIB_PART* part = component->m_part.release();
757  component->m_part.reset( m_part.release() );
758  component->UpdatePins();
759  m_part.reset( part );
760  UpdatePins();
761 
762  std::swap( m_Pos, component->m_Pos );
763  std::swap( m_unit, component->m_unit );
764  std::swap( m_convert, component->m_convert );
765 
766  m_Fields.swap( component->m_Fields ); // std::vector's swap()
767 
768  for( SCH_FIELD& field : component->m_Fields )
769  field.SetParent( component );
770 
771  for( SCH_FIELD& field : m_Fields )
772  field.SetParent( this );
773 
774  TRANSFORM tmp = m_transform;
775 
776  m_transform = component->m_transform;
777  component->m_transform = tmp;
778 
779  std::swap( m_instanceReferences, component->m_instanceReferences );
780 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
SCH_FIELDS m_Fields
Variable length list of fields.
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:94
std::vector< COMPONENT_INSTANCE_REFERENCE > m_instanceReferences
virtual void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:196
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
#define NULL
Define a library symbol object.
std::unique_ptr< LIB_PART > m_part
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:99
Schematic symbol object.
Definition: sch_component.h:88
int m_convert
The alternate body style for components that have more than one body style defined.
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
TRANSFORM m_transform
The rotation/mirror transformation matrix.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

References m_convert, m_Fields, m_instanceReferences, m_lib_id, m_part, m_Pos, m_transform, m_unit, NULL, SCH_COMPONENT_T, EDA_ITEM::SetParent(), EDA_ITEM::Type(), and UpdatePins().

◆ Type()

KICAD_T EDA_ITEM::Type ( ) const
inlineinherited

Function Type()

returns the type of object. This attribute should never be changed after a constructor sets it, so there is no public "setter" method.

Returns
KICAD_T - the type of object.

Definition at line 193 of file base_struct.h.

193 { return m_StructType; }
KICAD_T m_StructType
Run time identification, keep private so it can never be changed after a constructor sets it.
Definition: base_struct.h:170

References EDA_ITEM::m_StructType.

Referenced by MODULE::Add(), CN_CONNECTIVITY_ALGO::Add(), BOARD::Add(), CN_CLUSTER::Add(), POINT_EDITOR::addCorner(), CONNECTION_SUBGRAPH::AddItem(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), SCH_LINE_WIRE_BUS_TOOL::AddJunctionsIfNeeded(), ZONE_FILLER::addKnockout(), SCH_SHEET::AddPin(), ALIGN_DISTRIBUTE_TOOL::AlignBottom(), ALIGN_DISTRIBUTE_TOOL::AlignCenterX(), ALIGN_DISTRIBUTE_TOOL::AlignCenterY(), ALIGN_DISTRIBUTE_TOOL::AlignTop(), CN_ITEM::AnchorCount(), SCH_SCREEN::Append(), CONNECTION_GRAPH::buildConnectionGraph(), SCH_SCREENS::buildScreenList(), calcArea(), calcMaxArea(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), POINT_EDITOR::canAddCorner(), SCH_JUNCTION::CanConnect(), SCH_NO_CONNECT::CanConnect(), SCH_BUS_WIRE_ENTRY::CanConnect(), SCH_LINE::CanConnect(), SCH_BUS_BUS_ENTRY::CanConnect(), SCH_LABEL::CanConnect(), SCH_GLOBALLABEL::CanConnect(), SCH_HIERLABEL::CanConnect(), SCH_SHEET::CanConnect(), CanConnect(), ROUTER_TOOL::CanInlineDrag(), SCH_EDIT_TOOL::ChangeTextType(), SCH_MARKER::ClassOf(), SCH_JUNCTION::ClassOf(), TEXTE_PCB::ClassOf(), MARKER_PCB::ClassOf(), SCH_NO_CONNECT::ClassOf(), BOARD_CONNECTED_ITEM::ClassOf(), SCH_PIN::ClassOf(), EDGE_MODULE::ClassOf(), SCH_LINE::ClassOf(), PCB_TARGET::ClassOf(), SCH_FIELD::ClassOf(), TEXTE_MODULE::ClassOf(), DRAWSEGMENT::ClassOf(), ZONE_CONTAINER::ClassOf(), SCH_BITMAP::ClassOf(), D_PAD::ClassOf(), DIMENSION::ClassOf(), TRACK::ClassOf(), NETINFO_ITEM::ClassOf(), SCH_SHEET_PIN::ClassOf(), MODULE::ClassOf(), SCH_BUS_WIRE_ENTRY::ClassOf(), ClassOf(), SCH_SCREEN::ClassOf(), SCH_BUS_BUS_ENTRY::ClassOf(), SCH_TEXT::ClassOf(), SCH_SHEET::ClassOf(), BOARD::ClassOf(), ARC::ClassOf(), SCH_LABEL::ClassOf(), VIA::ClassOf(), SCH_GLOBALLABEL::ClassOf(), SCH_HIERLABEL::ClassOf(), TRACKS_CLEANER::cleanupSegments(), LIB_BEZIER::compare(), LIB_CIRCLE::compare(), LIB_RECTANGLE::compare(), LIB_TEXT::compare(), LIB_POLYLINE::compare(), LIB_ARC::compare(), LIB_FIELD::compare(), LIB_ITEM::compare(), LIB_PIN::compare(), GRID_HELPER::computeAnchors(), SCH_BUS_WIRE_ENTRY::ConnectionPropagatesTo(), EE_RTREE::contains(), DIALOG_TEXT_PROPERTIES::convertKIIDsToReferences(), DIALOG_LABEL_EDITOR::convertKIIDsToReferences(), MODULE::CoverageRatio(), BOARD_ADAPTER::createLayers(), PCB_BASE_FRAME::CreateNewModule(), SCH_DRAWING_TOOLS::createNewText(), BOARD_ADAPTER::createNewTrack(), D_PAD::D_PAD(), SCH_SCREEN::DeleteItem(), DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR(), DIALOG_SCH_EDIT_ONE_FIELD::DIALOG_SCH_EDIT_ONE_FIELD(), DIALOG_TEXT_PROPERTIES::DIALOG_TEXT_PROPERTIES(), ALIGN_DISTRIBUTE_TOOL::doAlignLeft(), ALIGN_DISTRIBUTE_TOOL::doAlignRight(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDIT_TOOL::DoDelete(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeCentersVertically(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsHorizontally(), ALIGN_DISTRIBUTE_TOOL::doDistributeGapsVertically(), DRC::doTrackDrc(), KIGFX::SCH_PAINTER::draw(), KIGFX::GERBVIEW_PAINTER::Draw(), KIGFX::PCB_PAINTER::Draw(), CN_ITEM::Dump(), EDIT_TOOL::Duplicate(), SCH_ITEM::Duplicate(), MODULE::DuplicateItem(), SCH_EDIT_TOOL::EditField(), SCH_EDIT_TOOL::editFieldText(), LIB_EDIT_TOOL::editTextProperties(), EditToolSelectionFilter(), CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts(), CONNECTION_GRAPH::ercCheckLabels(), NETLIST_EXPORTER::findNextComponent(), PCB_BASE_FRAME::FocusOnItem(), EDIT_TOOL::FootprintFilter(), SCH_SEXPR_PLUGIN::Format(), SCH_LEGACY_PLUGIN::Format(), PCB_IO::Format(), PCB_IO::format(), FormatProbeItem(), POINT_EDITOR::get45DegConstrainer(), CN_ITEM::GetAnchor(), BOARD_ITEM::GetBoard(), SCH_FIELD::GetBoundingBox(), TRACK::GetBoundingBox(), SCH_FIELD::GetCanonicalName(), KIGFX::GERBVIEW_RENDER_SETTINGS::GetColor(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), NETLIST_OBJECT::GetComponentParent(), SCH_MOVE_TOOL::getConnectedDragItems(), SCH_TEXT::GetConnectionPoints(), SCH_TEXT::GetContextualTextVars(), CONNECTION_GRAPH::getDefaultConnection(), CONNECTION_SUBGRAPH::GetDriverPriority(), SCH_TEXT::GetEndPoints(), PL_EDITOR_FRAME::GetLayoutFromRedoList(), PL_EDITOR_FRAME::GetLayoutFromUndoList(), SCH_FIELD::GetMenuImage(), TEXTE_PCB::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), SCH_FIELD::GetName(), CONNECTION_SUBGRAPH::GetNameForDriver(), CONNECTIVITY_DATA::GetNetItems(), LIB_PART::GetNextDrawItem(), DRAWSEGMENT::GetParentModule(), LIB_PART::GetPin(), GetPinPhysicalPosition(), SCH_FIELD::GetPosition(), getRect(), KIGFX::SCH_PAINTER::getRenderColor(), TEXTE_PCB::GetShownText(), SCH_FIELD::GetShownText(), SCH_TEXT::GetShownText(), EE_SELECTION_TOOL::GuessSelectionCandidates(), SELECTION_TOOL::GuessSelectionCandidates(), hash_eda(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), highlightNet(), SCH_EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), EE_RTREE::insert(), EE_COLLECTOR::Inspect(), GENERAL_COLLECTOR::Inspect(), PCB_LAYER_COLLECTOR::Inspect(), ARRAY_CREATOR::Invoke(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingLineWireOrBus(), TRACK::IsNull(), SCH_LINE::IsParallel(), SCH_FIELD::IsReplaceable(), SCH_SCREEN::IsTerminalPoint(), BOARD_ITEM::IsTrack(), itemIsIncludedByFilter(), SELECTION_TOOL::itemPassesFilter(), CLIPBOARD_IO::Load(), PNS_PCBNEW_RULE_RESOLVER::localPadClearance(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), EDIT_POINTS_FACTORY::Make(), SCH_SCREEN::MarkConnections(), CN_CONNECTIVITY_ALGO::markItemNetAsDirty(), CONNECTIVITY_DATA::MarkItemNetAsDirty(), SCH_FIELD::Matches(), SCH_LINE::MergeOverlap(), SCH_EDIT_TOOL::Mirror(), SCH_MOVE_TOOL::moveItem(), SCH_EDITOR_CONTROL::nextMatch(), FOOTPRINT_EDIT_FRAME::OnEditItemRequest(), PCB_EDIT_FRAME::OnEditItemRequest(), SCH_JUNCTION::operator<(), SCH_BUS_ENTRY_BASE::operator<(), SCH_FIELD::operator<(), SCH_LINE::operator<(), LIB_ITEM::operator<(), SCH_TEXT::operator<(), SCH_ITEM::operator<(), SCH_SHEET::operator<(), operator<(), SCH_BITMAP::operator=(), SCH_SHEET::operator=(), operator=(), EDIT_TOOL::PadFilter(), BOARD_COMMIT::parentObject(), PCBNEW_CONTROL::Paste(), SCH_EDITOR_CONTROL::Paste(), DRAWING_TOOL::PlaceImportedGraphics(), SCH_FIELD::Plot(), SCH_SCREEN::Plot(), BRDITEMS_PLOTTER::PlotFootprintGraphicItem(), SCH_FIELD::Print(), SCH_SCREEN::Print(), DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), BOARD_COMMIT::Push(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), SELECTION_TOOL::RebuildSelection(), SCH_CONNECTION::recacheName(), SCH_BASE_FRAME::RefreshItem(), SCH_BASE_FRAME::RefreshSelection(), EE_RTREE::remove(), MODULE::Remove(), CN_CONNECTIVITY_ALGO::Remove(), SCH_SCREEN::Remove(), BOARD::Remove(), POINT_EDITOR::removeCorner(), POINT_EDITOR::removeCornerCondition(), LIB_PART::RemoveDrawItem(), SCH_SHEET::RemovePin(), SCH_EDIT_TOOL::RepeatDrawItem(), SCH_FIELD::Replace(), WS_PROXY_UNDO_ITEM::Restore(), PL_EDITOR_FRAME::RollbackFromUndo(), SCH_EDIT_TOOL::Rotate(), SCH_TEXT::Rotate(), DRC_TEXTVAR_TESTER::RunDRC(), SCH_SEXPR_PLUGIN_CACHE::saveArc(), SCH_LEGACY_PLUGIN_CACHE::saveArc(), SCH_SEXPR_PLUGIN_CACHE::saveBezier(), SCH_LEGACY_PLUGIN_CACHE::saveBezier(), SCH_SEXPR_PLUGIN_CACHE::saveCircle(), SCH_LEGACY_PLUGIN_CACHE::saveCircle(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), EE_TOOL_BASE< SCH_BASE_FRAME >::saveCopyInUndoList(), SCH_SEXPR_PLUGIN::saveField(), SCH_SEXPR_PLUGIN_CACHE::saveField(), SCH_LEGACY_PLUGIN_CACHE::saveField(), SCH_SEXPR_PLUGIN_CACHE::savePin(), SCH_LEGACY_PLUGIN_CACHE::savePin(), SCH_SEXPR_PLUGIN_CACHE::savePolyLine(), SCH_LEGACY_PLUGIN_CACHE::savePolyLine(), SCH_SEXPR_PLUGIN_CACHE::saveRectangle(), SCH_LEGACY_PLUGIN_CACHE::saveRectangle(), SCH_SEXPR_PLUGIN_CACHE::saveSymbolDrawItem(), SCH_SEXPR_PLUGIN::saveText(), SCH_SEXPR_PLUGIN_CACHE::saveText(), SCH_LEGACY_PLUGIN_CACHE::saveText(), SCH_SCREEN::Schematic(), SCH_ITEM::Schematic(), SELECTION_TOOL::select(), EE_SELECTION_TOOL::Selectable(), SELECTION_TOOL::Selectable(), SELECTION_TOOL::selectConnectedTracks(), SCH_FIELD::SetId(), ITEM_PICKER::SetItem(), SCH_FIELD::SetPosition(), DIALOG_LABEL_EDITOR::SetTitle(), PCB_EDIT_FRAME::SetTrackSegmentWidth(), BOARD_COMMIT::Stage(), SCH_JUNCTION::SwapData(), SCH_NO_CONNECT::SwapData(), SCH_BITMAP::SwapData(), PCB_TARGET::SwapData(), SCH_SHEET_PIN::SwapData(), SCH_FIELD::SwapData(), TEXTE_PCB::SwapData(), TRACK::SwapData(), DIMENSION::SwapData(), ARC::SwapData(), SCH_SHEET::SwapData(), VIA::SwapData(), SwapData(), D_PAD::SwapData(), MODULE::SwapData(), ZONE_CONTAINER::SwapData(), SwapItemData(), TEXTE_MODULE::TEXTE_MODULE(), DIALOG_LABEL_EDITOR::TransferDataFromWindow(), DIALOG_FIELDS_EDITOR_GLOBAL::TransferDataToWindow(), DIALOG_TEXT_PROPERTIES::TransferDataToWindow(), DIALOG_LABEL_EDITOR::TransferDataToWindow(), TRACK::TransformShapeWithClearanceToPolygon(), LIB_DRAWING_TOOLS::TwoClickPlace(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlight(), SCH_TEXT::UpdateDanglingState(), DIALOG_SCH_EDIT_ONE_FIELD::UpdateField(), EE_POINT_EDITOR::updateItem(), PL_POINT_EDITOR::updateItem(), POINT_EDITOR::updateItem(), CONNECTION_GRAPH::updateItemConnectivity(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), POINT_EDITOR::updatePoints(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateView(), PCB_BRIGHT_BOX::ViewDraw(), SCH_BUS_ENTRY_BASE::ViewGetLayers(), TRACK::Visit(), GERBER_DRAW_ITEM::Visit(), SCH_SHEET::Visit(), and DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem().

◆ UpdateDanglingState()

bool SCH_COMPONENT::UpdateDanglingState ( std::vector< DANGLING_END_ITEM > &  aItemList,
const SCH_SHEET_PATH aPath = nullptr 
)
overridevirtual

Test if the component's dangling state has changed for all pins.

As a side effect, actually update the dangling status for all pins.

Note
This does not test for short circuits.
Parameters
aItemListis list of all DANGLING_END_ITEM items to be tested.
Returns
true if any pin's state has changed.

Reimplemented from SCH_ITEM.

Definition at line 1352 of file sch_component.cpp.

1354 {
1355  bool changed = false;
1356 
1357  for( std::unique_ptr<SCH_PIN>& pin : m_pins )
1358  {
1359  bool previousState = pin->IsDangling();
1360  pin->SetIsDangling( true );
1361 
1362  wxPoint pos = m_transform.TransformCoordinate( pin->GetLocalPosition() ) + m_Pos;
1363 
1364  for( DANGLING_END_ITEM& each_item : aItemList )
1365  {
1366  // Some people like to stack pins on top of each other in a symbol to indicate
1367  // internal connection. While technically connected, it is not particularly useful
1368  // to display them that way, so skip any pins that are in the same symbol as this
1369  // one.
1370  if( each_item.GetParent() == this )
1371  continue;
1372 
1373  switch( each_item.GetType() )
1374  {
1375  case PIN_END:
1376  case LABEL_END:
1377  case SHEET_LABEL_END:
1378  case WIRE_START_END:
1379  case WIRE_END_END:
1380  case NO_CONNECT_END:
1381  case JUNCTION_END:
1382 
1383  if( pos == each_item.GetPosition() )
1384  pin->SetIsDangling( false );
1385 
1386  break;
1387 
1388  default:
1389  break;
1390  }
1391 
1392  if( !pin->IsDangling() )
1393  break;
1394  }
1395 
1396  changed = ( changed || ( previousState != pin->IsDangling() ) );
1397  }
1398 
1399  return changed;
1400 }
SCH_PINS m_pins
a SCH_PIN for every LIB_PIN (across all units)
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:94
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
Helper class used to store the state of schematic items that can be connected to other schematic item...
Definition: sch_item.h:84
TRANSFORM m_transform
The rotation/mirror transformation matrix.

References JUNCTION_END, LABEL_END, m_pins, m_Pos, m_transform, NO_CONNECT_END, PIN_END, SHEET_LABEL_END, TRANSFORM::TransformCoordinate(), WIRE_END_END, and WIRE_START_END.

◆ UpdateFields()

void SCH_COMPONENT::UpdateFields ( bool  aResetStyle,
bool  aResetRef = false 
)

Restores fields to the original library values.

Parameters
aResetStyleselects whether fields should reset the position and text attribute.
aResetRefselects whether the reference field should be restored.

Definition at line 648 of file sch_component.cpp.

649 {
650  if( m_part )
651  {
652  wxString symbolName;
653  LIB_FIELDS fields;
654  m_part->GetFields( fields );
655 
656  for( const LIB_FIELD& libField : fields )
657  {
658  int idx = libField.GetId();
659  SCH_FIELD* schField;
660 
661  if( idx == REFERENCE && !aResetRef )
662  continue;
663 
664  if( idx >= 0 && idx < MANDATORY_FIELDS )
665  {
666  schField = GetField( idx );
667  }
668  else
669  {
670  schField = FindField( libField.GetCanonicalName() );
671 
672  if( !schField )
673  {
674  wxString fieldName = libField.GetCanonicalName();
675  SCH_FIELD newField( wxPoint( 0, 0), GetFieldCount(), this, fieldName );
676  schField = AddField( newField );
677  }
678  }
679 
680  if( aResetStyle )
681  {
682  schField->ImportValues( libField );
683  schField->SetTextPos( m_Pos + libField.GetTextPos() );
684  }
685 
686  if( idx == VALUE )
687  {
688  schField->SetText( m_lib_id.GetLibItemName() ); // fetch alias-specific value
689  symbolName = m_lib_id.GetLibItemName();
690  }
691  else if( idx == DATASHEET )
692  {
693  schField->SetText( GetDatasheet() ); // fetch alias-specific value
694  }
695  else
696  {
697