KiCad PCB EDA Suite
SCH_COMPONENT Class Reference

SCH_COMPONENT describes a real schematic component. 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, PART_LIBS *aLibs=NULL)
 
void SetLibId (const LIB_ID &aLibId, SYMBOL_LIB_TABLE *aSymLibTable, PART_LIB *aCacheLib)
 
const LIB_IDGetLibId () const
 
std::unique_ptr< LIB_PART > & GetPartRef ()
 
wxString GetDescription () const
 Return information about the aliased parts. More...
 
wxString GetDatasheet () const
 Return the documentation text for the given part alias. More...
 
bool Resolve (PART_LIBS *aLibs)
 Assigns the current LIB_PART from aLibs which this symbol is based on. More...
 
bool Resolve (SYMBOL_LIB_TABLE &aLibTable, PART_LIB *aCacheLib=NULL)
 
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 GetMsgPanelInfo (EDA_UNITS aUnits, 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 ClearAllHighlightFlags ()
 Clear the HIGHLIGHTED flag of all items of the component (fields, pins ...) 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) const
 Returns a field in this symbol. More...
 
wxString GetFieldText (const wxString &aFieldName, SCH_EDIT_FRAME *aFrame) const
 Search for a field named aFieldName and returns text associated with this field. More...
 
void GetFields (std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
 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 (wxDC *aDC, const wxPoint &aOffset) override
 Print a component. More...
 
void SwapData (SCH_ITEM *aItem) override
 Function SwapData 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
 Function Move moves the item by aMoveVector to a new position. More...
 
void MirrorY (int aYaxis_position) override
 Function MirrorY mirrors item relative to the Y axis about aYaxis_position. More...
 
void MirrorX (int aXaxis_position) override
 Function MirrorX mirrors item relative to the X axis about aXaxis_position. More...
 
void Rotate (wxPoint aPosition) override
 Function Rotate rotates 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
 Function GetEndPoints adds 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
 Function IsConnectable returns true if the schematic item can connect to another schematic item. More...
 
bool CanConnect (const SCH_ITEM *aItem) const override
 
bool IsInNetlist () const
 
void GetConnectionPoints (std::vector< wxPoint > &aPoints) const override
 Function GetConnectionPoints 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
 Function GetNetListItem creates 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...
 
wxPoint GetPosition () const override
 Function GetPosition. More...
 
void SetPosition (const wxPoint &aPosition) override
 Function SetPosition 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
 Function Plot plots 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)
 
void ClearHighlightedPins ()
 
bool HasHighlightedPins ()
 
void HighlightPin (LIB_PIN *aPin)
 
SCH_ITEMDuplicate (bool doClone=false) const
 Routine to create a new copy of given item. More...
 
wxPointGetStoredPos ()
 
void SetStoredPos (wxPoint aPos)
 
virtual bool IsLocked () const
 Function IsLocked. More...
 
virtual void SetLocked (bool aLocked)
 Function SetLocked modifies 'lock' status for of the item. More...
 
SCH_LAYER_ID GetLayer () const
 Function GetLayer returns the layer this item is on. More...
 
void SetLayer (SCH_LAYER_ID aLayer)
 Function SetLayer sets the layer this item is on. More...
 
virtual int GetPenSize () const
 Function GetPenSize virtual pure. More...
 
virtual bool Load (LINE_READER &aLine, wxString &aErrorMsg)
 Function Load reads a schematic item from aLine in a .sch file. More...
 
virtual bool IsDangling () const
 
void ClearConnections ()
 Function ClearConnections clears all of the connection items from the list. More...
 
bool IsConnected (const wxPoint &aPoint) const
 Function IsConnected tests the item to see if it is connected to aPoint. More...
 
SCH_CONNECTIONConnection (const SCH_SHEET_PATH &aPath) const
 Retrieves the connection associated with this object in the given sheet Note: the returned value can be nullptr. 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)
 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)
 
virtual bool CanIncrementLabel () const
 
FIELDS_AUTOPLACED GetFieldsAutoplaced () const
 Return whether the fields have been automatically placed. More...
 
void ClearFieldsAutoplaced ()
 Set fields automatically placed flag false. More...
 
void AutoAutoplaceFields (SCH_SCREEN *aScreen)
 Autoplace fields only if correct to do so automatically. More...
 
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
 
void SetParent (EDA_ITEM *aParent)
 
bool IsNew () const
 
bool IsModified () const
 
bool IsMoving () const
 
bool IsDragging () const
 
bool IsWireImage () const
 
bool IsSelected () const
 
bool IsResized () const
 
bool IsHighlighted () const
 
bool IsBrightened () const
 
void SetWireImage ()
 
void SetSelected ()
 
void SetHighlighted ()
 
void SetBrightened ()
 
void ClearSelected ()
 
void ClearHighlighted ()
 
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...
 
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 void ResolveAll (std::vector< SCH_COMPONENT * > &aComponents, SYMBOL_LIB_TABLE &aLibTable, PART_LIB *aCacheLib=NULL)
 
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...
 
EDA_ITEMm_Parent
 Linked list: Link (parent struct) More...
 
bool m_forceVisible
 Set to true to override the visibility setting of the item. More...
 
STATUS_FLAGS m_Flags
 Flag bits for editing and other uses. More...
 

Private Member Functions

void Init (const wxPoint &pos=wxPoint(0, 0))
 
bool doIsConnected (const wxPoint &aPosition) const override
 Function doIsConnected provides 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...
 
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...
 
std::vector< COMPONENT_INSTANCE_REFERENCEm_instanceReferences
 

Detailed Description

SCH_COMPONENT describes a real schematic component.

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

116  :
117  SCH_ITEM( aParent, SCH_COMPONENT_T )
118 {
119  Init( aPos );
121 }
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:154
void Init(const wxPoint &pos=wxPoint(0, 0))
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType)
Definition: sch_item.cpp:46

References FIELDS_AUTOPLACED_NO, Init(), and SCH_ITEM::m_fieldsAutoplaced.

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

125  :
127 {
128  Init( pos );
129 
130  m_unit = unit;
131  m_convert = convert;
132  m_lib_id = aLibId;
133 
134  std::unique_ptr< LIB_PART > part;
135 
136  part = aPart.Flatten();
137  part->SetParent();
138  m_part.reset( part.release() );
140 
141  // Copy fields from the library component
142  UpdateFields( true, true );
143 
144  // Update the pin locations
145  UpdatePins();
146 
147  // Update the reference -- just the prefix for now.
148  if( sheet )
149  SetRef( sheet, aPart.GetReferenceField().GetText() + wxT( "?" ) );
150  else
151  m_prefix = aPart.GetReferenceField().GetText() + wxT( "?" );
152 }
void UpdateFields(bool aResetStyle, bool aResetRef=false)
Restores fields to the original library values.
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:154
LIB_FIELD & GetReferenceField()
Return reference to the reference designator field.
#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.
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.
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
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:123
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType)
Definition: sch_item.cpp:46

References FIELDS_AUTOPLACED_NO, LIB_PART::Flatten(), LIB_PART::GetReferenceField(), EDA_TEXT::GetText(), Init(), m_convert, SCH_ITEM::m_fieldsAutoplaced, m_lib_id, m_part, m_prefix, m_unit, SetRef(), UpdateFields(), and UpdatePins().

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

156  : SCH_COMPONENT( aPart, aSel.LibId, aSheet, aSel.Unit, aSel.Convert, pos )
157 {
158  // Set any fields that were modified as part of the component selection
159  for( auto const& i : aSel.Fields )
160  {
161  auto field = this->GetField( i.first );
162 
163  if( field )
164  field->SetText( i.second );
165  }
166 }
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
SCH_COMPONENT(const wxPoint &pos=wxPoint(0, 0), SCH_ITEM *aParent=NULL)
std::vector< std::pair< int, wxString > > Fields
Definition: sch_screen.h:78

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

169  :
170  SCH_ITEM( aComponent )
171 {
172  m_Parent = aComponent.m_Parent;
173  m_Pos = aComponent.m_Pos;
174  m_unit = aComponent.m_unit;
175  m_convert = aComponent.m_convert;
176  m_lib_id = aComponent.m_lib_id;
177  m_isInNetlist = aComponent.m_isInNetlist;
178 
179  if( aComponent.m_part )
180  m_part.reset( new LIB_PART( *aComponent.m_part.get() ) );
181 
182  const_cast<KIID&>( m_Uuid ) = aComponent.m_Uuid;
183 
184  m_transform = aComponent.m_transform;
185  m_prefix = aComponent.m_prefix;
187  m_Fields = aComponent.m_Fields;
188 
189  // Re-parent the fields, which before this had aComponent as parent
190  for( SCH_FIELD& field : m_Fields )
191  field.SetParent( this );
192 
193  UpdatePins();
194 
196 }
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:183
SCH_FIELDS m_Fields
Variable length list of fields.
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
std::vector< COMPONENT_INSTANCE_REFERENCE > m_instanceReferences
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:154
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:169
int m_unit
The unit for multiple part per package components.
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 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:46

References m_convert, m_Fields, SCH_ITEM::m_fieldsAutoplaced, m_instanceReferences, m_isInNetlist, m_lib_id, EDA_ITEM::m_Parent, m_part, m_Pos, m_prefix, m_transform, m_unit, EDA_ITEM::m_Uuid, and UpdatePins().

◆ ~SCH_COMPONENT()

SCH_COMPONENT::~SCH_COMPONENT ( )
inline

Definition at line 168 of file sch_component.h.

168 { }

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

145 {
146  m_connected_items[ aSheet ].insert( aItem );
147 }
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:159

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

778 {
779  int newNdx = m_Fields.size();
780 
781  m_Fields.push_back( aField );
782  return &m_Fields[newNdx];
783 }
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 555 of file sch_component.cpp.

557 {
558  // Search for an existing path and remove it if found (should not occur)
559  for( unsigned ii = 0; ii < m_instanceReferences.size(); ii++ )
560  {
561  if( m_instanceReferences[ii].m_Path == aPath )
562  {
563  m_instanceReferences.erase( m_instanceReferences.begin() + ii );
564  ii--;
565  }
566  }
567 
569  instance.m_Path = aPath;
570  instance.m_Reference = aRef;
571  instance.m_Unit = aUnit;
572  m_instanceReferences.push_back( instance );
573 }
std::vector< COMPONENT_INSTANCE_REFERENCE > m_instanceReferences

References m_instanceReferences, COMPONENT_INSTANCE_REFERENCE::m_Path, COMPONENT_INSTANCE_REFERENCE::m_Reference, and COMPONENT_INSTANCE_REFERENCE::m_Unit.

Referenced by AddSheetPathReferenceEntryIfMissing(), SetRef(), and SetUnitSelection().

◆ 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
aSheetPathNameis the candidate sheet path name 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 998 of file sch_component.cpp.

999 {
1000  // a empty sheet path is illegal:
1001  wxCHECK( aSheetPath.size() > 0, false );
1002 
1003  wxString reference_path;
1004 
1005  for( const COMPONENT_INSTANCE_REFERENCE& instance : m_instanceReferences )
1006  {
1007  // if aSheetPath is found, nothing to do:
1008  if( instance.m_Path == aSheetPath )
1009  return false;
1010  }
1011 
1012  // This entry does not exist: add it, with its last-used reference
1014  return true;
1015 }
SCH_FIELDS m_Fields
Variable length list of fields.
std::vector< COMPONENT_INSTANCE_REFERENCE > m_instanceReferences
Field Reference of part, i.e. "IC21".
wxString GetText(GRAPHIC_PINSHAPE aShape)
Definition: pin_shape.cpp:58
int m_unit
The unit for multiple part per package components.
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 419 of file sch_item.h.

420  {
421  if( GetFieldsAutoplaced() )
423  }
FIELDS_AUTOPLACED GetFieldsAutoplaced() const
Return whether the fields have been automatically placed.
Definition: sch_item.h:404
virtual void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual)
Definition: sch_item.h:425

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

676 {
677  if( aManual )
678  wxASSERT_MSG( aScreen, "A SCH_SCREEN pointer must be given for manual autoplacement" );
679 
680  AUTOPLACER autoplacer( this, aScreen );
681  autoplacer.DoAutoplace( aManual );
683 }
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:154

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

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

◆ BrightenPin()

void SCH_COMPONENT::BrightenPin ( LIB_PIN aPin)

Definition at line 1803 of file sch_component.cpp.

1804 {
1805  if( m_pinMap.count( aPin ) )
1806  m_pins[ m_pinMap.at( aPin ) ]->SetBrightened();
1807 }
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 567 of file sch_component.h.

568  {
569  return ( aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_WIRE ) ||
570  ( aItem->Type() == SCH_NO_CONNECT_T ) ||
571  ( aItem->Type() == SCH_JUNCTION_T ) ||
572  ( aItem->Type() == SCH_COMPONENT_T ) ;
573  }
SCH_LAYER_ID GetLayer() const
Function GetLayer returns the layer this item is on.
Definition: sch_item.h:224
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212

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

◆ CanIncrementLabel()

virtual bool SCH_ITEM::CanIncrementLabel ( ) const
inlinevirtualinherited

Reimplemented in SCH_TEXT.

Definition at line 399 of file sch_item.h.

399 { return false; }

Referenced by SCH_EDIT_TOOL::RepeatDrawItem().

◆ ClassOf()

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

Definition at line 170 of file sch_component.h.

171  {
172  return aItem && SCH_COMPONENT_T == aItem->Type();
173  }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212

References SCH_COMPONENT_T, and EDA_ITEM::Type().

◆ ClearAllHighlightFlags()

bool SCH_COMPONENT::ClearAllHighlightFlags ( )

Clear the HIGHLIGHTED flag of all items of the component (fields, pins ...)

Definition at line 1836 of file sch_component.cpp.

1837 {
1838  bool retVal = false;
1839 
1840  if( IsHighlighted() )
1841  {
1843  retVal = true;
1844  }
1845 
1846  // Clear the HIGHLIGHTED flag of pins
1847  if( HasHighlightedPins() )
1848  {
1850  retVal = true;
1851  }
1852 
1853  // Clear the HIGHLIGHTED flag of other items, currently only fields
1854  for( SCH_FIELD& each_field : m_Fields )
1855  {
1856  if( each_field.IsHighlighted() )
1857  {
1858  each_field.ClearFlags( HIGHLIGHTED );
1859  retVal = true;
1860  }
1861  }
1862 
1863  return retVal;
1864 }
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.
bool HasHighlightedPins()
bool IsHighlighted() const
Definition: base_struct.h:227
#define HIGHLIGHTED
item is drawn in normal colors, when the rest is darkened
Definition: base_struct.h:142
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:258
void ClearHighlightedPins()

References EDA_ITEM::ClearFlags(), ClearHighlightedPins(), HasHighlightedPins(), HIGHLIGHTED, EDA_ITEM::IsHighlighted(), and m_Fields.

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

957 {
958  // Build a reference with no annotation,
959  // i.e. a reference ended by only one '?'
960  wxString defRef = m_prefix;
961 
962  if( !IsReferenceStringValid( defRef ) )
963  { // This is a malformed reference: reinit this reference
964  m_prefix = defRef = wxT("U"); // Set to default ref prefix
965  }
966 
967  while( defRef.Last() == '?' )
968  defRef.RemoveLast();
969 
970  defRef.Append( wxT( "?" ) );
971 
972  if( aSheetPath )
973  {
974  KIID_PATH path = aSheetPath->Path();
975 
977  {
978  if( instance.m_Path == path )
979  instance.m_Reference = defRef;
980  }
981  }
982  else
983  {
985  instance.m_Reference = defRef;
986  }
987 
988  // These 2 changes do not work in complex hierarchy.
989  // When a clear annotation is made, the calling function must call a
990  // UpdateAllScreenReferences for the active sheet.
991  // But this call cannot made here.
992  m_Fields[REFERENCE].SetText( defRef ); //for drawing.
993 
994  SetModified();
995 }
void SetModified()
Definition: base_struct.cpp:94
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".
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

Definition at line 237 of file base_struct.h.

237 { ClearFlags( BRIGHTENED ); }
#define BRIGHTENED
item is drawn with a bright contour
Definition: base_struct.h:143
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:258

References BRIGHTENED, and EDA_ITEM::ClearFlags().

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PCB_BASE_FRAME::FocusOnItem(), SCH_BASE_FRAME::FocusOnItem(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlight(), and SCH_EDITOR_CONTROL::UpdateNetHighlighting().

◆ ClearBrightenedPins()

void SCH_COMPONENT::ClearBrightenedPins ( )

Definition at line 1796 of file sch_component.cpp.

1797 {
1798  for( auto& pin : m_pins )
1799  pin->ClearBrightened();
1800 }
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

Function ClearConnections 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 356 of file sch_item.h.

356 { m_connections.clear(); }
EDA_ITEMS m_connections
Definition: sch_item.h:153

References SCH_ITEM::m_connections.

◆ ClearEditFlags()

void EDA_ITEM::ClearEditFlags ( )
inlineinherited

◆ ClearFieldsAutoplaced()

void SCH_ITEM::ClearFieldsAutoplaced ( )
inlineinherited

Set fields automatically placed flag false.

Definition at line 409 of file sch_item.h.

FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:154

References FIELDS_AUTOPLACED_NO, and SCH_ITEM::m_fieldsAutoplaced.

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

◆ ClearFlags()

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

Definition at line 258 of file base_struct.h.

258 { m_Flags &= ~aMask; }
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:189

References EDA_ITEM::m_Flags.

Referenced by FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), PNS_KICAD_IFACE::AddItem(), SCH_EDIT_FRAME::AddItemToScreenAndUndoList(), ClearAllHighlightFlags(), SCH_SCREEN::ClearAnnotation(), EDA_ITEM::ClearBrightened(), EDA_ITEM::ClearEditFlags(), EDA_ITEM::ClearHighlighted(), clearModuleItemFlags(), EDA_ITEM::ClearSelected(), EDA_ITEM::ClearTempFlags(), SCH_EDIT_FRAME::ConvertPart(), LIB_EDIT_TOOL::Copy(), MWAVE::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(), KIGFX::SCH_VIEW::HighlightItem(), MODULE_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().

◆ ClearHighlighted()

void EDA_ITEM::ClearHighlighted ( )
inlineinherited

Definition at line 236 of file base_struct.h.

236 { ClearFlags( HIGHLIGHTED ); }
#define HIGHLIGHTED
item is drawn in normal colors, when the rest is darkened
Definition: base_struct.h:142
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:258

References EDA_ITEM::ClearFlags(), and HIGHLIGHTED.

◆ ClearHighlightedPins()

void SCH_COMPONENT::ClearHighlightedPins ( )

Definition at line 1810 of file sch_component.cpp.

1811 {
1812  for( auto& pin : m_pins )
1813  pin->ClearHighlighted();
1814 }
SCH_PINS m_pins
a SCH_PIN for every LIB_PIN (across all units)

References m_pins.

Referenced by ClearAllHighlightFlags().

◆ ClearSelected()

void EDA_ITEM::ClearSelected ( )
inlineinherited

◆ ClearTempFlags()

void EDA_ITEM::ClearTempFlags ( )
inlineinherited

Definition at line 270 of file base_struct.h.

271  {
273  }
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
Definition: base_struct.h:117
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: base_struct.h:131
#define CANDIDATE
flag indicating that the structure is connected
Definition: base_struct.h:130
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:126
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:258
#define DO_NOT_DRAW
Used to disable draw function.
Definition: base_struct.h:132
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:125

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

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

227 {
228  return new SCH_COMPONENT( *this );
229 }
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 138 of file sch_item.cpp.

139 {
140  return m_connected_items[ aSheet ];
141 }
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:159

References SCH_ITEM::m_connected_items.

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

◆ Connection()

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

393 { return true; }

Referenced by CONNECTION_GRAPH::updateItemConnectivity().

◆ doIsConnected()

bool SCH_COMPONENT::doIsConnected ( const wxPoint aPosition) const
overrideprivatevirtual

Function doIsConnected provides 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 1745 of file sch_component.cpp.

1746 {
1747  wxPoint new_pos = m_transform.InverseTransform().TransformCoordinate( aPosition - m_Pos );
1748 
1749  for( const auto& pin : m_pins )
1750  {
1751  if( pin->GetPosition() == new_pos )
1752  return true;
1753  }
1754 
1755  return false;
1756 }
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".
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
TRANSFORM m_transform
The rotation/mirror transformation matrix.

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

76 {
77  SCH_ITEM* newItem = (SCH_ITEM*) Clone();
78 
79  if( !doClone )
80  const_cast<KIID&>( newItem->m_Uuid ) = KIID();
81 
82  newItem->ClearFlags( SELECTED | HIGHLIGHTED | BRIGHTENED );
83 
84  if( newItem->Type() == SCH_COMPONENT_T )
85  {
86  SCH_COMPONENT* component = (SCH_COMPONENT*) newItem;
87 
88  for( SCH_PIN* pin : component->GetSchPins() )
90 
91  for( SCH_FIELD* field : component->GetFields() )
92  field->ClearFlags( SELECTED | HIGHLIGHTED | BRIGHTENED );
93  }
94 
95  if( newItem->Type() == SCH_SHEET_T )
96  {
97  SCH_SHEET* sheet = (SCH_SHEET*) newItem;
98 
99  for( SCH_FIELD& field : sheet->GetFields() )
101 
102  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
103  pin->ClearFlags( SELECTED | HIGHLIGHTED | BRIGHTENED );
104  }
105 
106  return newItem;
107 }
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:127
Definition: common.h:65
#define BRIGHTENED
item is drawn with a bright contour
Definition: base_struct.h:143
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:215
const KIID m_Uuid
Definition: base_struct.h:169
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:357
#define HIGHLIGHTED
item is drawn in normal colors, when the rest is darkened
Definition: base_struct.h:142
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:99
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:258
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
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:212

References BRIGHTENED, EDA_ITEM::ClearFlags(), EDA_ITEM::Clone(), SCH_SHEET::GetFields(), GetFields(), SCH_SHEET::GetPins(), GetSchPins(), HIGHLIGHTED, 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 799 of file sch_component.cpp.

800 {
801  unsigned start = aIncludeDefaultFields ? 0 : MANDATORY_FIELDS;
802 
803  for( unsigned i = start; i < m_Fields.size(); ++i )
804  {
805  if( aFieldName == m_Fields[i].GetName( false ) )
806  return &m_Fields[i];
807  }
808 
809  return NULL;
810 }
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 1214 of file sch_component.cpp.

1215 {
1216  EDA_RECT bBox;
1217 
1218  if( m_part )
1219  {
1220  bBox = m_part->GetBodyBoundingBox( m_unit, m_convert );
1221  }
1222  else
1223  {
1224  bBox = dummy()->GetBodyBoundingBox( m_unit, m_convert );
1225  }
1226 
1227  int x0 = bBox.GetX();
1228  int xm = bBox.GetRight();
1229 
1230  // We must reverse Y values, because matrix orientation
1231  // suppose Y axis normal for the library items coordinates,
1232  // m_transform reverse Y values, but bBox is already reversed!
1233  int y0 = -bBox.GetY();
1234  int ym = -bBox.GetBottom();
1235 
1236  // Compute the real Boundary box (rotated, mirrored ...)
1237  int x1 = m_transform.x1 * x0 + m_transform.y1 * y0;
1238  int y1 = m_transform.x2 * x0 + m_transform.y2 * y0;
1239  int x2 = m_transform.x1 * xm + m_transform.y1 * ym;
1240  int y2 = m_transform.x2 * xm + m_transform.y2 * ym;
1241 
1242  bBox.SetX( x1 );
1243  bBox.SetY( y1 );
1244  bBox.SetWidth( x2 - x1 );
1245  bBox.SetHeight( y2 - y1 );
1246  bBox.Normalize();
1247 
1248  bBox.Offset( m_Pos );
1249  return bBox;
1250 }
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".
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.
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 1253 of file sch_component.cpp.

1254 {
1255  EDA_RECT bbox = GetBodyBoundingBox();
1256 
1257  for( size_t i = 0; i < m_Fields.size(); i++ )
1258  bbox.Merge( m_Fields[i].GetBoundingBox() );
1259 
1260  return bbox;
1261 }
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 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 175 of file sch_component.h.

176  {
177  return wxT( "SCH_COMPONENT" );
178  }

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

481 {
482  if( m_pinMap.count( aPin ) )
483  return m_pins[ m_pinMap[aPin] ]->Connection( aSheet );
484 
485  return nullptr;
486 }
SCH_PINS m_pins
a SCH_PIN for every LIB_PIN (across all units)
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieves the connection associated with this object in the given sheet Note: the returned value can ...
Definition: sch_item.cpp:128
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

Function GetConnectionPoints 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 1495 of file sch_component.cpp.

1496 {
1497  for( const auto& pin : m_pins )
1498  aPoints.push_back( m_transform.TransformCoordinate( pin->GetPosition() ) + m_Pos );
1499 }
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".
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
TRANSFORM m_transform
The rotation/mirror transformation matrix.

References m_pins, m_Pos, m_transform, and TRANSFORM::TransformCoordinate().

◆ GetConvert()

◆ GetDatasheet()

wxString SCH_COMPONENT::GetDatasheet ( ) const

Return the documentation text for the given part alias.

Definition at line 311 of file sch_component.cpp.

312 {
313  if( m_part )
314  {
315  return m_part->GetDocFileName();
316  }
317 
318  return wxEmptyString;
319 }
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 300 of file sch_component.cpp.

301 {
302  if( m_part )
303  {
304  return m_part->GetDescription();
305  }
306 
307  return wxEmptyString;
308 }
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 1502 of file sch_component.cpp.

1503 {
1504  UpdatePins();
1505 
1506  if( m_part )
1507  {
1508  // Calculate the position relative to the component.
1509  wxPoint libPosition = aPosition - m_Pos;
1510 
1511  return m_part->LocateDrawItem( m_unit, m_convert, aType, libPosition, m_transform );
1512  }
1513 
1514  return NULL;
1515 }
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
#define NULL
std::unique_ptr< LIB_PART > m_part
int m_unit
The unit for multiple part per package components.
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.

References m_convert, m_part, m_Pos, m_transform, m_unit, NULL, and UpdatePins().

Referenced by SCH_SCREEN::GetPin().

◆ GetEditFlags()

STATUS_FLAGS EDA_ITEM::GetEditFlags ( ) const
inlineinherited

Definition at line 262 of file base_struct.h.

263  {
267  return m_Flags & mask;
268  }
#define TEMP_SELECTED
flag indicating that the structure has already selected
Definition: base_struct.h:128
#define END_ONPAD
Pcbnew: flag set for track segment ending on a pad.
Definition: base_struct.h:139
#define BEGIN_ONPAD
Pcbnew: flag set for track segment starting on a pad.
Definition: base_struct.h:138
#define EDA_ITEM_ALL_FLAGS
Definition: base_struct.h:157
#define SELECTED
Definition: base_struct.h:127
#define BRIGHTENED
item is drawn with a bright contour
Definition: base_struct.h:143
#define DP_COUPLED
item is coupled with another item making a differential pair
Definition: base_struct.h:145
#define HIGHLIGHTED
item is drawn in normal colors, when the rest is darkened
Definition: base_struct.h:142
#define IS_DANGLING
indicates a pin is dangling
Definition: base_struct.h:149
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:189
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:126
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:125

References BEGIN_ONPAD, BRIGHTENED, DP_COUPLED, EDA_ITEM_ALL_FLAGS, END_ONPAD, ENDPOINT, HIGHLIGHTED, IS_DANGLING, EDA_ITEM::m_Flags, SELECTED, STARTPOINT, and TEMP_SELECTED.

Referenced by SCH_EDIT_TOOL::ChangeShape(), EDA_ITEM::ClearEditFlags(), SCH_EDIT_FRAME::ConvertTextType(), SCH_EDIT_FRAME::DeleteJunction(), SCH_EDIT_TOOL::editFieldText(), SCH_EDITOR_CONTROL::EditWithLibEdit(), LIB_MOVE_TOOL::Main(), POINT_EDITOR::OnSelectionChange(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), 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

Function GetEndPoints adds 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 1414 of file sch_component.cpp.

1415 {
1416  if( m_part )
1417  {
1418  for( LIB_PIN* pin = m_part->GetNextPin(); pin; pin = m_part->GetNextPin( pin ) )
1419  {
1420  wxASSERT( pin->Type() == LIB_PIN_T );
1421 
1422  if( pin->GetUnit() && m_unit && ( m_unit != pin->GetUnit() ) )
1423  continue;
1424 
1425  if( pin->GetConvert() && m_convert && ( m_convert != pin->GetConvert() ) )
1426  continue;
1427 
1428  DANGLING_END_ITEM item( PIN_END, pin, GetPinPhysicalPosition( pin ), this );
1429  aItemList.push_back( item );
1430  }
1431  }
1432 }
std::unique_ptr< LIB_PART > m_part
int m_unit
The unit for multiple part per package components.
int m_convert
The alternate body style for components that have more than one body style defined.
DANGLING_END_ITEM is a helper class used to store the state of schematic items that can be connected ...
Definition: sch_item.h:76
wxPoint GetPinPhysicalPosition(const LIB_PIN *Pin) const

References GetPinPhysicalPosition(), LIB_PIN_T, m_convert, m_part, m_unit, and PIN_END.

◆ GetField()

SCH_FIELD * SCH_COMPONENT::GetField ( int  aFieldNdx) const

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

729 {
730  const SCH_FIELD* field;
731 
732  if( (unsigned) aFieldNdx < m_Fields.size() )
733  field = &m_Fields[aFieldNdx];
734  else
735  field = NULL;
736 
737  wxASSERT( field );
738 
739  return const_cast<SCH_FIELD*>( field );
740 }
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.
#define NULL

References m_Fields, and NULL.

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(), NETLIST_EXPORTER_GENERIC::makeComponents(), TUNER_SLIDER::onSave(), operator==(), SCH_EDITOR_CONTROL::processCmpToFootprintLinkFile(), SCH_LEGACY_PLUGIN::saveComponent(), SCH_SEXPR_PLUGIN::saveSymbol(), SCH_COMPONENT(), SCH_REFERENCE::SCH_REFERENCE(), SCH_SCREEN::SetComponentFootprint(), SetRef(), EE_INSPECTION_TOOL::ShowDatasheet(), TestMultiunitFootprints(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataToWindow(), TUNER_SLIDER::TUNER_SLIDER(), UpdateFields(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::UpdateFieldsFromLibrary(), Visit(), DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::visitItem(), NETLIST_EXPORTER_ORCADPCB2::WriteNetlist(), and NETLIST_EXPORTER_CADSTAR::WriteNetlist().

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

756 {
757  for( SCH_FIELD& field : m_Fields )
758  {
759  if( !aVisibleOnly || ( field.IsVisible() && !field.IsVoid() ) )
760  aVector.push_back( &field );
761  }
762 }
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::GetItem(), SCH_SEXPR_PLUGIN::saveSymbol(), and DIALOG_UPDATE_FIELDS::updateFields().

◆ GetFields() [2/2]

std::vector< SCH_FIELD * > SCH_COMPONENT::GetFields ( )

Returns a vector of fields from the component.

Definition at line 765 of file sch_component.cpp.

766 {
767  std::vector<SCH_FIELD*> retvec;
768  retvec.reserve( m_Fields.size() );
769 
770  for( SCH_FIELD& field : m_Fields )
771  retvec.push_back( &field );
772 
773  return retvec;
774 }
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.

◆ GetFieldsAutoplaced()

FIELDS_AUTOPLACED SCH_ITEM::GetFieldsAutoplaced ( ) const
inlineinherited

Return whether the fields have been automatically placed.

Definition at line 404 of file sch_item.h.

404 { return m_fieldsAutoplaced; }
FIELDS_AUTOPLACED m_fieldsAutoplaced
Definition: sch_item.h:154

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

744 {
745  for( const SCH_FIELD& field : m_Fields )
746  {
747  if( aFieldName == field.GetName() )
748  return field.GetText();
749  }
750 
751  return wxEmptyString;
752 }
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()

◆ GetInstanceReferences()

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

Definition at line 180 of file sch_component.h.

181  {
182  return m_instanceReferences;
183  }
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 1344 of file sch_component.cpp.

1345 {
1346  return add_component_xpm;
1347 }
const BITMAP_OPAQUE add_component_xpm[1]

References add_component_xpm.

◆ GetMsgPanelInfo()

void SCH_COMPONENT::GetMsgPanelInfo ( EDA_UNITS  aUnits,
std::vector< MSG_PANEL_ITEM > &  aList 
)
overridevirtual

Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.

Note
This method replaces DisplayInfo() so that KiCad objects no longer have any knowledge of wxWidgets UI objects.
Parameters
aListis the list to populate.

Reimplemented from EDA_ITEM.

Definition at line 1264 of file sch_component.cpp.

1265 {
1266  wxString msg;
1267 
1268  // part and alias can differ if alias is not the root
1269  if( m_part )
1270  {
1271  if( m_part.get() != dummy() )
1272  {
1273  if( g_CurrentSheet )
1274  aList.push_back( MSG_PANEL_ITEM( _( "Reference" ), GetRef( g_CurrentSheet ),
1275  DARKCYAN ) );
1276 
1277  msg = m_part->IsPower() ? _( "Power symbol" ) : _( "Value" );
1278 
1279  aList.push_back( MSG_PANEL_ITEM( msg, GetField( VALUE )->GetShownText(), DARKCYAN ) );
1280 
1281  // Display component reference in library and library
1282  aList.push_back( MSG_PANEL_ITEM( _( "Name" ), GetLibId().GetLibItemName(), BROWN ) );
1283 
1284  if( !m_part->IsRoot() )
1285  {
1286  msg = _( "Missing parent" );
1287 
1288  std::shared_ptr< LIB_PART > parent = m_part->GetParent().lock();
1289 
1290  if( parent )
1291  msg = parent->GetName();
1292 
1293  aList.push_back( MSG_PANEL_ITEM( _( "Alias of" ), msg, BROWN ) );
1294  }
1295 
1296  if( m_part->GetLib() && m_part->GetLib()->IsCache() )
1297  aList.push_back( MSG_PANEL_ITEM( _( "Library" ),
1298  m_part->GetLib()->GetLogicalName(), RED ) );
1299  else if( !m_lib_id.GetLibNickname().empty() )
1300  aList.push_back( MSG_PANEL_ITEM( _( "Library" ), m_lib_id.GetLibNickname(),
1301  BROWN ) );
1302  else
1303  aList.push_back( MSG_PANEL_ITEM( _( "Library" ), _( "Undefined!!!" ), RED ) );
1304 
1305  // Display the current associated footprint, if exists.
1306  if( !GetField( FOOTPRINT )->IsVoid() )
1307  msg = GetField( FOOTPRINT )->GetShownText();
1308  else
1309  msg = _( "<Unknown>" );
1310 
1311  aList.push_back( MSG_PANEL_ITEM( _( "Footprint" ), msg, DARKRED ) );
1312 
1313  // Display description of the component, and keywords found in lib
1314  aList.push_back( MSG_PANEL_ITEM( _( "Description" ), m_part->GetDescription(),
1315  DARKCYAN ) );
1316  aList.push_back( MSG_PANEL_ITEM( _( "Key words" ), m_part->GetKeyWords(), DARKCYAN ) );
1317  }
1318  }
1319  else
1320  {
1321  if( g_CurrentSheet )
1322  aList.push_back( MSG_PANEL_ITEM( _( "Reference" ), GetRef( g_CurrentSheet ),
1323  DARKCYAN ) );
1324 
1325  aList.push_back( MSG_PANEL_ITEM( _( "Value" ), GetField( VALUE )->GetShownText(),
1326  DARKCYAN ) );
1327  aList.push_back( MSG_PANEL_ITEM( _( "Name" ), GetLibId().GetLibItemName(), BROWN ) );
1328 
1329  wxString libNickname = GetLibId().GetLibNickname();
1330 
1331  if( libNickname.empty() )
1332  {
1333  aList.push_back( MSG_PANEL_ITEM( _( "Library" ), _( "No library defined!" ), RED ) );
1334  }
1335  else
1336  {
1337  msg.Printf( _( "Symbol not found in %s!" ), libNickname );
1338  aList.push_back( MSG_PANEL_ITEM( _( "Library" ), msg , RED ) );
1339  }
1340  }
1341 }
Definition: colors.h:54
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
#define VALUE
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
Definition: colors.h:60
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.
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
virtual wxString GetShownText() const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:129
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
Definition: colors.h:62

References _, BROWN, DARKCYAN, DARKRED, dummy(), UTF8::empty(), FOOTPRINT, g_CurrentSheet, GetField(), GetLibId(), LIB_ID::GetLibNickname(), GetRef(), EDA_TEXT::GetShownText(), m_lib_id, m_part, RED, and VALUE.

◆ GetNetListItem()

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

Function GetNetListItem creates 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 1588 of file sch_component.cpp.

1590 {
1591  if( m_part )
1592  {
1593  for( LIB_PIN* pin = m_part->GetNextPin(); pin; pin = m_part->GetNextPin( pin ) )
1594  {
1595  wxASSERT( pin->Type() == LIB_PIN_T );
1596 
1597  if( pin->GetUnit() && ( pin->GetUnit() != GetUnitSelection( aSheetPath ) ) )
1598  continue;
1599 
1600  if( pin->GetConvert() && ( pin->GetConvert() != GetConvert() ) )
1601  continue;
1602 
1603  wxPoint pos = GetTransform().TransformCoordinate( pin->GetPosition() ) + m_Pos;
1604 
1605  NETLIST_OBJECT* item = new NETLIST_OBJECT();
1606  item->m_SheetPathInclude = *aSheetPath;
1607  item->m_Comp = m_pins[ m_pinMap.at( pin ) ].get();
1608  item->m_SheetPath = *aSheetPath;
1609  item->m_Type = NETLIST_ITEM::PIN;
1610  item->m_Link = (SCH_ITEM*) this;
1611  item->m_ElectricalPinType = pin->GetType();
1612  item->m_PinNum = pin->GetNumber();
1613  item->m_Label = pin->GetName();
1614  item->m_Start = item->m_End = pos;
1615 
1616  aNetListItems.push_back( item );
1617 
1618  if( pin->IsPowerConnection() )
1619  {
1620  // There is an associated PIN_LABEL.
1621  item = new NETLIST_OBJECT();
1622  item->m_SheetPathInclude = *aSheetPath;
1623  item->m_Comp = NULL;
1624  item->m_SheetPath = *aSheetPath;
1626  item->m_Label = pin->GetName();
1627  item->m_Start = pos;
1628  item->m_End = item->m_Start;
1629 
1630  aNetListItems.push_back( item );
1631  }
1632  }
1633  }
1634 }
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".
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
#define NULL
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
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
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_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, NULL, 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 1145 of file sch_component.cpp.

1146 {
1147  int rotate_values[] =
1148  {
1149  CMP_ORIENT_0,
1150  CMP_ORIENT_90,
1156  CMP_MIRROR_Y,
1161  };
1162 
1163  // Try to find the current transform option:
1164  TRANSFORM transform = m_transform;
1165 
1166  for( int type_rotate : rotate_values )
1167  {
1168  SetOrientation( type_rotate );
1169 
1170  if( transform == m_transform )
1171  return type_rotate;
1172  }
1173 
1174  // Error: orientation not found in list (should not happen)
1175  wxMessageBox( wxT( "Component orientation matrix internal error" ) );
1176  m_transform = transform;
1177 
1178  return CMP_NORMAL;
1179 }
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()

◆ GetPenSize()

virtual int SCH_ITEM::GetPenSize ( ) const
inlinevirtualinherited

Function GetPenSize virtual pure.

Returns
the size of the "pen" that be used to draw or plot this item

Reimplemented in SCH_SHEET, SCH_TEXT, SCH_BUS_BUS_ENTRY, SCH_LINE, SCH_FIELD, SCH_BUS_WIRE_ENTRY, SCH_SHEET_PIN, and SCH_NO_CONNECT.

Definition at line 243 of file sch_item.h.

243 { return 0; }

Referenced by SCH_JUNCTION::GetBoundingBox(), SCH_BUS_ENTRY_BASE::GetBoundingBox(), KIGFX::SCH_PAINTER::getLineWidth(), SCH_BUS_ENTRY_BASE::HitTest(), SCH_BUS_ENTRY_BASE::Plot(), SCH_BITMAP::Plot(), and SCH_BUS_ENTRY_BASE::Print().

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

882 {
883  if( m_part )
884  {
885  return m_part->GetPin( number, m_unit, m_convert );
886  }
887 
888  return NULL;
889 }
#define NULL
std::unique_ptr< LIB_PART > m_part
int m_unit
The unit for multiple part per package components.
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 1486 of file sch_component.cpp.

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

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

893 {
894  if( m_part )
895  m_part->GetPins( aPinsList, m_unit, m_convert );
896 }
std::unique_ptr< LIB_PART > m_part
int m_unit
The unit for multiple part per package components.
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 268 of file sch_component.h.

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

References m_prefix.

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

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

577 {
578  KIID_PATH path = sheet->Path();
579  wxString ref;
580 
581  for( const COMPONENT_INSTANCE_REFERENCE& instance : m_instanceReferences )
582  {
583  if( instance.m_Path == path )
584  {
585  ref = instance.m_Reference;
586  break;
587  }
588  }
589 
590  // If it was not found in m_Paths array, then see if it is in m_Field[REFERENCE] -- if so,
591  // use this as a default for this path. This will happen if we load a version 1 schematic
592  // file. It will also mean that multiple instances of the same sheet by default all have
593  // the same component references, but perhaps this is best.
594  if( ref.IsEmpty() && !GetField( REFERENCE )->GetText().IsEmpty() )
595  {
596  SetRef( sheet, GetField( REFERENCE )->GetText() );
597  ref = GetField( REFERENCE )->GetText();
598  }
599 
600  if( ref.IsEmpty() )
601  ref = m_prefix;
602 
603  if( aIncludeUnit )
604  ref += LIB_PART::SubReference( GetUnit() );
605 
606  return ref;
607 }
std::vector< COMPONENT_INSTANCE_REFERENCE > m_instanceReferences
Field Reference of part, i.e. "IC21".
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
int GetUnit() const
wxString GetText(GRAPHIC_PINSHAPE aShape)
Definition: pin_shape.cpp:58
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
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:123

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

Referenced by NETLIST_EXPORTER_GENERIC::addComponentFields(), SCH_EDIT_FRAME::AnnotateComponents(), 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(), mapExistingAnnotation(), SCH_FIELD::Matches(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), SCH_FIELD::Replace(), SCH_REFERENCE::SCH_REFERENCE(), SCH_SCREEN::SetComponentFootprint(), TestMultiunitFootprints(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow(), 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 899 of file sch_component.cpp.

900 {
901  if( aSheet == nullptr )
902  aSheet = g_CurrentSheet;
903 
904  // TODO(JE) if this works, consider caching in m_sheet_pins
905  int unit = GetUnitSelection( aSheet );
906  SCH_PIN_PTRS ptrs;
907 
908  for( const auto& p : m_pins )
909  {
910  if( unit && p->GetLibPin()->GetUnit() && ( p->GetLibPin()->GetUnit() != unit ) )
911  continue;
912 
913  ptrs.push_back( p.get() );
914  }
915 
916  return ptrs;
917 }
std::vector< SCH_PIN * > SCH_PIN_PTRS
Definition: sch_component.h:73
SCH_PINS m_pins
a SCH_PIN for every LIB_PIN (across all units)
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const

References g_CurrentSheet, GetUnitSelection(), and m_pins.

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

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

1519 {
1520  return wxString::Format( _( "Symbol %s, %s" ),
1521  GetLibId().GetLibItemName().wx_str(),
1522  GetField( REFERENCE )->GetShownText() );
1523 }
Field Reference of part, i.e. "IC21".
SCH_FIELD * GetField(int aFieldNdx) const
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 241 of file base_struct.h.

242  {
243  return m_Status & type;
244  }
STATUS_FLAGS m_Status
Definition: base_struct.h:179

References EDA_ITEM::m_Status.

Referenced by SELECTION_TOOL::expandConnection(), TRACK::GetMsgPanelInfoBase_Common(), TRACK::IsLocked(), TRACK::Print(), and ZONE_CONTAINER::PrintFilledArea().

◆ GetStatus()

STATUS_FLAGS EDA_ITEM::GetStatus ( ) const
inlineinherited

Definition at line 254 of file base_struct.h.

254 { return m_Status; }
STATUS_FLAGS m_Status
Definition: base_struct.h:179

References EDA_ITEM::m_Status.

Referenced by PCB_IO::format().

◆ GetStoredPos()

wxPoint& SCH_ITEM::GetStoredPos ( )
inlineinherited

Definition at line 205 of file sch_item.h.

205 { return m_storedPos; }
wxPoint m_storedPos
Definition: sch_item.h:155

References SCH_ITEM::m_storedPos.

Referenced by SCH_MOVE_TOOL::moveItem().

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

526 {
527  if( m_part )
528  return m_part->GetUnitCount();
529 
530  return 0;
531 }
std::unique_ptr< LIB_PART > m_part

References m_part.

Referenced by NETLIST_EXPORTER_GENERIC::addComponentFields(), SCH_EDIT_FRAME::AnnotateComponents(), SCH_FIELD::GetFullyQualifiedText(), 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 692 of file sch_component.cpp.

693 {
694  KIID_PATH path = aSheet->Path();
695 
696  for( const COMPONENT_INSTANCE_REFERENCE& instance : m_instanceReferences )
697  {
698  if( instance.m_Path == path )
699  return instance.m_Unit;
700  }
701 
702  // If it was not found in m_Paths array, then use m_unit. This will happen if we load a
703  // version 1 schematic file.
704  return m_unit;
705 }
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
std::vector< COMPONENT_INSTANCE_REFERENCE > m_instanceReferences
int m_unit
The unit for multiple part per package components.

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

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

◆ HasBrightenedPins()

bool SCH_COMPONENT::HasBrightenedPins ( )

Definition at line 1784 of file sch_component.cpp.

1785 {
1786  for( const auto& pin : m_pins )
1787  {
1788  if( pin->IsBrightened() )
1789  return true;
1790  }
1791 
1792  return false;
1793 }
SCH_PINS m_pins
a SCH_PIN for every LIB_PIN (across all units)

References m_pins.

Referenced by SCH_EDITOR_CONTROL::UpdateNetHighlighting().

◆ HasFlag()

◆ HasHighlightedPins()

bool SCH_COMPONENT::HasHighlightedPins ( )

Definition at line 1817 of file sch_component.cpp.

1818 {
1819  for( const auto& pin : m_pins )
1820  {
1821  if( pin->IsHighlighted() )
1822  return true;
1823  }
1824 
1825  return false;
1826 }
SCH_PINS m_pins
a SCH_PIN for every LIB_PIN (across all units)

References m_pins.

Referenced by ClearAllHighlightFlags().

◆ HighlightPin()

void SCH_COMPONENT::HighlightPin ( LIB_PIN aPin)

Definition at line 1829 of file sch_component.cpp.

1830 {
1831  if( m_pinMap.count( aPin ) )
1832  m_pins[ m_pinMap.at( aPin ) ]->SetHighlighted();
1833 }
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.

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

1718 {
1719  EDA_RECT bBox = GetBodyBoundingBox();
1720  bBox.Inflate( aAccuracy );
1721 
1722  if( bBox.Contains( aPosition ) )
1723  return true;
1724 
1725  return false;
1726 }
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 1729 of file sch_component.cpp.

1730 {
1732  return false;
1733 
1734  EDA_RECT rect = aRect;
1735 
1736  rect.Inflate( aAccuracy );
1737 
1738  if( aContained )
1739  return rect.Contains( GetBodyBoundingBox() );
1740 
1741  return rect.Intersects( GetBodyBoundingBox() );
1742 }
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: base_struct.h:131
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:129
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:189
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 199 of file sch_component.cpp.

200 {
201  m_Pos = pos;
202  m_unit = 1; // In multi unit chip - which unit to draw.
203  m_convert = LIB_ITEM::LIB_CONVERT::BASE; // De Morgan Handling
204 
205  // The rotation/mirror transformation matrix. pos normal
207 
208  // construct only the mandatory fields, which are the first 4 only.
209  for( int i = 0; i < MANDATORY_FIELDS; ++i )
210  {
211  m_Fields.emplace_back( pos, i, this, TEMPLATE_FIELDNAME::GetDefaultFieldName( i ) );
212 
213  if( i == REFERENCE )
214  m_Fields.back().SetLayer( LAYER_REFERENCEPART );
215  else if( i == VALUE )
216  m_Fields.back().SetLayer( LAYER_VALUEPART );
217  else
218  m_Fields.back().SetLayer( LAYER_FIELDS );
219  }
220 
221  m_prefix = wxString( wxT( "U" ) );
222  m_isInNetlist = true;
223 }
SCH_FIELDS m_Fields
Variable length list of fields.
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
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.
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_isInNetlist, 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)
inherited

Creates a new connection object associated with this object.

Parameters
aPathis the sheet path to initialize

Definition at line 150 of file sch_item.cpp.

151 {
152  if( Connection( aSheet ) )
153  {
154  Connection( aSheet )->Reset();
155  Connection( aSheet )->SetSheet( aSheet );
156  return Connection( aSheet );
157  }
158 
159  auto connection = new SCH_CONNECTION( this );
160  connection->SetSheet( aSheet );
161  m_connection_map.insert( std::make_pair( aSheet, connection ) );
162  return connection;
163 }
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:162
SCH_CONNECTION * Connection(const SCH_SHEET_PATH &aPath) const
Retrieves the connection associated with this object in the given sheet Note: the returned value can ...
Definition: sch_item.cpp:128
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 678 of file sch_component.cpp.

679 {
680  KIID_PATH path = aSheet->Path();
681 
682  for( const COMPONENT_INSTANCE_REFERENCE& instance : m_instanceReferences )
683  {
684  if( instance.m_Path == path )
685  return instance.m_Reference.Last() != '?';
686  }
687 
688  return false;
689 }
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
std::vector< COMPONENT_INSTANCE_REFERENCE > m_instanceReferences

References m_instanceReferences, and SCH_SHEET_PATH::Path().

Referenced by mapExistingAnnotation().

◆ IsBrightened()

bool EDA_ITEM::IsBrightened ( ) const
inlineinherited

◆ IsConnectable()

bool SCH_COMPONENT::IsConnectable ( ) const
inlineoverridevirtual

Function IsConnectable returns true if the schematic item can connect to another schematic item.

Reimplemented from SCH_ITEM.

Definition at line 565 of file sch_component.h.

565 { return true; }

◆ IsConnected()

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

Function IsConnected tests 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 119 of file sch_item.cpp.

120 {
121  if( ( m_Flags & STRUCT_DELETED ) || ( m_Flags & SKIP_STRUCT ) )
122  return false;
123 
124  return doIsConnected( aPosition );
125 }
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: base_struct.h:131
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:129
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:189
virtual bool doIsConnected(const wxPoint &aPosition) const
Function doIsConnected provides the object specific test to see if it is connected to aPosition.
Definition: sch_item.h:479

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

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

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

329 { return false; }

◆ IsDragging()

bool EDA_ITEM::IsDragging ( ) const
inlineinherited

Definition at line 223 of file base_struct.h.

223 { return m_Flags & IS_DRAGGED; }
#define IS_DRAGGED
Item being dragged.
Definition: base_struct.h:122
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:189

References IS_DRAGGED, and EDA_ITEM::m_Flags.

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

◆ IsHighlighted()

bool EDA_ITEM::IsHighlighted ( ) const
inlineinherited

Definition at line 227 of file base_struct.h.

227 { return m_Flags & HIGHLIGHTED; }
#define HIGHLIGHTED
item is drawn in normal colors, when the rest is darkened
Definition: base_struct.h:142
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:189

References HIGHLIGHTED, and EDA_ITEM::m_Flags.

Referenced by ClearAllHighlightFlags(), KIGFX::SCH_PAINTER::draw(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), and KIGFX::SCH_VIEW::HighlightItem().

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

1760 {
1761  return m_isInNetlist;
1762 }
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

Function IsLocked.

Returns
bool - true if the object is locked, else false

Definition at line 212 of file sch_item.h.

212 { return false; }

Referenced by SCH_EDIT_TOOL::DeleteItemCursor().

◆ IsModified()

bool EDA_ITEM::IsModified ( ) const
inlineinherited

Definition at line 221 of file base_struct.h.

221 { return m_Flags & IS_CHANGED; }
#define IS_CHANGED
std::function passed to nested users by ref, avoids copying std::function
Definition: base_struct.h:116
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:189

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

200 { 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 610 of file sch_component.cpp.

611 {
612  wxString text = aReferenceString;
613  bool ok = true;
614 
615  // Try to unannotate this reference
616  while( !text.IsEmpty() && ( text.Last() == '?' || wxIsdigit( text.Last() ) ) )
617  text.RemoveLast();
618 
619  if( text.IsEmpty() )
620  ok = false;
621 
622  return ok;
623 }

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

609 { return true; }

◆ IsResized()

bool EDA_ITEM::IsResized ( ) const
inlineinherited

Definition at line 226 of file base_struct.h.

226 { return m_Flags & IS_RESIZED; }
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:189
#define IS_RESIZED
Item being resized.
Definition: base_struct.h:121

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, SCH_FIELD, and SCH_LINE.

Definition at line 286 of file base_struct.h.

287  {
288  if( aScanTypes[0] == SCH_LOCATE_ANY_T )
289  return true;
290 
291  for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
292  {
293  if( m_StructType == *p )
294  return true;
295  }
296 
297  return false;
298  }
KICAD_T m_StructType
Run time identification, keep private so it can never be changed after a constructor sets it.
Definition: base_struct.h:178
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 SCH_LINE_WIRE_BUS_TOOL::IsDrawingBus(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingLine(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingWire(), SCH_LINE::IsType(), SCH_FIELD::IsType(), SCH_LABEL::IsType(), EE_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 224 of file base_struct.h.

224 { return m_Flags & IS_WIRE_IMAGE; }
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.
Definition: base_struct.h:124
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:189

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

403  {
404  for( auto it : aList )
405  {
406  if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
408  return SEARCH_RESULT::QUIT;
409  }
410 
412  }
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 420 of file base_struct.h.

422  {
423  for( auto it : aList )
424  {
425  if( static_cast<EDA_ITEM*>( it )->Visit( inspector, testData, scanTypes )
427  return SEARCH_RESULT::QUIT;
428  }
429 
431  }
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().

◆ Load()

virtual bool SCH_ITEM::Load ( LINE_READER aLine,
wxString &  aErrorMsg 
)
inlinevirtualinherited

Function Load reads a schematic item from aLine in a .sch file.

Parameters
aLine- Essentially this is file to read the object from.
aErrorMsg- Description of the error if an error occurs while loading the object.
Returns
True if the object loaded successfully.

Definition at line 291 of file sch_item.h.

291 { return false; }

◆ Matches() [1/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 1405 of file sch_component.cpp.

1406 {
1407  wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText( EDA_UNITS::MILLIMETRES ) );
1408 
1409  // Components are searchable via the child field and pin item text.
1410  return false;
1411 }
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.

◆ Matches() [2/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 152 of file base_struct.cpp.

153 {
154  wxString text = aText;
155  wxString searchText = aSearchData.GetFindString();
156 
157  // Don't match if searching for replaceable item and the item doesn't support text replace.
158  if( (aSearchData.GetFlags() & FR_SEARCH_REPLACE) && !IsReplaceable() )
159  return false;
160 
161  if( aSearchData.GetFlags() & wxFR_WHOLEWORD )
162  return aText.IsSameAs( searchText, aSearchData.GetFlags() & wxFR_MATCHCASE );
163 
164  if( aSearchData.GetFlags() & FR_MATCH_WILDCARD )
165  {
166  if( aSearchData.GetFlags() & wxFR_MATCHCASE )
167  return text.Matches( searchText );
168 
169  return text.MakeUpper().Matches( searchText.MakeUpper() );
170  }
171 
172  if( aSearchData.GetFlags() & wxFR_MATCHCASE )
173  return aText.Find( searchText ) != wxNOT_FOUND;
174 
175  return text.MakeUpper().Find( searchText.MakeUpper() ) != wxNOT_FOUND;
176 }
virtual bool IsReplaceable() const
Function IsReplaceable.
Definition: base_struct.h:517

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

◆ MirrorX()

void SCH_COMPONENT::MirrorX ( int  aXaxis_position)
overridevirtual

Function MirrorX mirrors item relative to the X axis about aXaxis_position.

Parameters
aXaxis_positionThe X axis position to mirror around.

Implements SCH_ITEM.

Definition at line 1368 of file sch_component.cpp.

1369 {
1370  int dy = m_Pos.y;
1371 
1373  MIRROR( m_Pos.y, aXaxis_position );
1374  dy -= m_Pos.y; // dy,0 is the move vector for this transform
1375 
1376  for( SCH_FIELD& field : m_Fields )
1377  {
1378  // Move the fields to the new position because the component itself has moved.
1379  wxPoint pos = field.GetTextPos();
1380  pos.y -= dy;
1381  field.SetTextPos( pos );
1382  }
1383 }
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".
void MIRROR(T &aPoint, const T &aMirrorRef)
Definition: macros.h:123
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

Function MirrorY mirrors item relative to the Y axis about aYaxis_position.

Parameters
aYaxis_positionThe Y axis position to mirror around.

Implements SCH_ITEM.

Definition at line 1350 of file sch_component.cpp.

1351 {
1352  int dx = m_Pos.x;
1353 
1355  MIRROR( m_Pos.x, aYaxis_position );
1356  dx -= m_Pos.x; // dx,0 is the move vector for this transform
1357 
1358  for( SCH_FIELD& field : m_Fields )
1359  {
1360  // Move the fields to the new position because the component itself has moved.
1361  wxPoint pos = field.GetTextPos();
1362  pos.x -= dx;
1363  field.SetTextPos( pos );
1364  }
1365 }
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".
void MIRROR(T &aPoint, const T &aMirrorRef)
Definition: macros.h:123
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

Function Move moves the item by aMoveVector to a new position.

Parameters
aMoveVector= the displacement vector

Implements SCH_ITEM.

Definition at line 528 of file sch_component.h.

529  {
530  if( aMoveVector == wxPoint( 0, 0 ) )
531  return;
532 
533  m_Pos += aMoveVector;
534 
535  for( SCH_FIELD& field : m_Fields )
536  field.Move( aMoveVector );
537 
538  SetModified();
539  }
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:94
SCH_FIELDS m_Fields
Variable length list of fields.
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".

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

1675 {
1676  return !( *this == aComponent );
1677 }

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

207 {
208  wxFAIL_MSG( wxString::Format( wxT( "Less than operator not defined for item type %s." ),
209  GetChars( GetClass() ) ) );
210 
211  return false;
212 }
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:101
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 1637 of file sch_component.cpp.

1638 {
1639  if( Type() != aItem.Type() )
1640  return Type() < aItem.Type();
1641 
1642  auto component = static_cast<const SCH_COMPONENT*>( &aItem );
1643 
1644  EDA_RECT rect = GetBodyBoundingBox();
1645 
1646  if( rect.GetArea() != component->GetBodyBoundingBox().GetArea() )
1647  return rect.GetArea() < component->GetBodyBoundingBox().GetArea();
1648 
1649  if( m_Pos.x != component->m_Pos.x )
1650  return m_Pos.x < component->m_Pos.x;
1651 
1652  if( m_Pos.y != component->m_Pos.y )
1653  return m_Pos.y < component->m_Pos.y;
1654 
1655  return m_Uuid < aItem.m_Uuid; // Ensure deterministic sort
1656 }
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
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:169
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212

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

1681 {
1682  wxCHECK_MSG( Type() == aItem.Type(), *this,
1683  wxT( "Cannot assign object type " ) + aItem.GetClass() + wxT( " to type " ) +
1684  GetClass() );
1685 
1686  if( &aItem != this )
1687  {
1688  SCH_ITEM::operator=( aItem );
1689 
1690  SCH_COMPONENT* c = (SCH_COMPONENT*) &aItem;
1691 
1692  m_lib_id = c->m_lib_id;
1693 
1694  LIB_PART* libSymbol = c->m_part ? new LIB_PART( *c->m_part.get() ) : nullptr;
1695 
1696  m_part.reset( libSymbol );
1697  m_Pos = c->m_Pos;
1698  m_unit = c->m_unit;
1699  m_convert = c->m_convert;
1700  m_transform = c->m_transform;
1701 
1703 
1704  m_Fields = c->m_Fields; // std::vector's assignment operator
1705 
1706  // Reparent fields after assignment to new component.
1707  for( SCH_FIELD& field : m_Fields )
1708  field.SetParent( this );
1709 
1710  UpdatePins();
1711  }
1712 
1713  return *this;
1714 }
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".
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.
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:99
virtual wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_item.h:174
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:212

References SCH_ITEM::GetClass(), 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 1659 of file sch_component.cpp.

1660 {
1661  if( GetFieldCount() != aComponent.GetFieldCount() )
1662  return false;
1663 
1664  for( int i = VALUE; i < GetFieldCount(); i++ )
1665  {
1666  if( GetField( i )->GetText().Cmp( aComponent.GetField( i )->GetText() ) != 0 )
1667  return false;
1668  }
1669 
1670  return true;
1671 }
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
#define VALUE
int GetFieldCount() const
Return the number of fields in this symbol.
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:123

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

◆ Plot()

void SCH_COMPONENT::Plot ( PLOTTER aPlotter)
overridevirtual

Function Plot plots the schematic item to aPlotter.

Parameters
aPlotterA pointer to a PLOTTER object.

Reimplemented from SCH_ITEM.

Definition at line 1765 of file sch_component.cpp.

1766 {
1767  TRANSFORM temp;
1768 
1769  if( m_part )
1770  {
1771  temp = GetTransform();
1772  aPlotter->StartBlock( nullptr );
1773 
1774  m_part->Plot( aPlotter, GetUnit(), GetConvert(), m_Pos, temp );
1775 
1776  for( SCH_FIELD field : m_Fields )
1777  field.Plot( aPlotter );
1778 
1779  aPlotter->EndBlock( nullptr );
1780  }
1781 }
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:497
SCH_FIELDS m_Fields
Variable length list of fields.
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
virtual void StartBlock(void *aData)
calling this function allows one to define the beginning of a group of drawing items,...
Definition: plotter.h:488
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 ( wxDC *  aDC,
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 534 of file sch_component.cpp.

535 {
536  auto opts = PART_DRAW_OPTIONS::Default();
537  opts.transform = m_transform;
538  opts.draw_visible_fields = false;
539  opts.draw_hidden_fields = false;
540 
541  if( m_part )
542  {
543  m_part->Print( aDC, m_Pos + aOffset, m_unit, m_convert, opts );
544  }
545  else // Use dummy() part if the actual cannot be found.
546  {
547  dummy()->Print( aDC, m_Pos + aOffset, 0, 0, opts );
548  }
549 
550  for( SCH_FIELD& field : m_Fields )
551  field.Print( aDC, aOffset );
552 }
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".
void Print(wxDC *aDc, const wxPoint &aOffset, int aMulti, int aConvert, const PART_DRAW_OPTIONS &aOpts)
Print part.
std::unique_ptr< LIB_PART > m_part
static PART_DRAW_OPTIONS Default()
int m_unit
The unit for multiple part per package components.
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
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::Default(), dummy(), m_convert, m_Fields, m_part, m_Pos, m_transform, m_unit, and LIB_PART::Print().

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

787 {
788  for( unsigned i = MANDATORY_FIELDS; i < m_Fields.size(); ++i )
789  {
790  if( aFieldName == m_Fields[i].GetName( false ) )
791  {
792  m_Fields.erase( m_Fields.begin() + i );
793  return;
794  }
795  }
796 }
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 179 of file base_struct.cpp.

180 {
181  wxString searchString = (aSearchData.GetFlags() & wxFR_MATCHCASE) ? aText : aText.Upper();
182 
183  int result = searchString.Find( (aSearchData.GetFlags() & wxFR_MATCHCASE) ?
184  aSearchData.GetFindString() :
185  aSearchData.GetFindString().Upper() );
186 
187  if( result == wxNOT_FOUND )
188  return false;
189 
190  wxString prefix = aText.Left( result );
191  wxString suffix;
192 
193  if( aSearchData.GetFindString().length() + result < aText.length() )
194  suffix = aText.Right( aText.length() - ( aSearchData.GetFindString().length() + result ) );
195 
196  wxLogTrace( traceFindReplace, wxT( "Replacing '%s', prefix '%s', replace '%s', suffix '%s'." ),
197  GetChars( aText ), GetChars( prefix ), GetChars( aSearchData.GetReplaceString() ),
198  GetChars( suffix ) );
199 
200  aText = prefix + aSearchData.GetReplaceString() + suffix;
201 
202  return true;
203 }
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:101

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

505 { return false; }

◆ Resolve() [1/2]

bool SCH_COMPONENT::Resolve ( PART_LIBS aLibs)

Assigns the current LIB_PART from aLibs which this symbol is based on.

Parameters
aLibsis the current set of LIB_PARTs to choose from.

Definition at line 322 of file sch_component.cpp.

323 {
324  // I've never been happy that the actual individual PART_LIB is left up to
325  // flimsy search path ordering. None-the-less find a part based on that design:
326  if( LIB_PART* part = aLibs->FindLibPart( m_lib_id ) )
327  {
328  std::unique_ptr< LIB_PART > flattenedPart = part->Flatten();
329  flattenedPart->SetParent();
330  m_part.reset( flattenedPart.release() );
331  UpdatePins();
332  return true;
333  }
334 
335  return false;
336 }
Define a library symbol object.
LIB_PART * FindLibPart(const LIB_ID &aLibId, const wxString &aLibraryName=wxEmptyString)
Search all libraries in the list for a part.
std::unique_ptr< LIB_PART > m_part
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.

References PART_LIBS::FindLibPart(), m_lib_id, m_part, and UpdatePins().

Referenced by LIB_CONTROL::AddSymbolToSchematic(), SCH_EDITOR_CONTROL::Paste(), SCH_DRAWING_TOOLS::PlaceComponent(), and SetLibId().

◆ Resolve() [2/2]

bool SCH_COMPONENT::Resolve ( SYMBOL_LIB_TABLE aLibTable,
PART_LIB aCacheLib = NULL 
)

Definition at line 339 of file sch_component.cpp.

340 {
341  std::unique_ptr< LIB_PART > part;
342 
343  try
344  {
345  // We want a full symbol not just the top level child symbol.
346  PROPERTIES props;
347 
348  props[ SCH_LEGACY_PLUGIN::PropNoDocFile ] = "";
349 
350  // LIB_TABLE_BASE::LoadSymbol() throws an IO_ERROR if the the library nickname
351  // is not found in the table so check if the library still exists in the table
352  // before attempting to load the symbol.
353  if( m_lib_id.IsValid() && aLibTable.HasLibrary( m_lib_id.GetLibNickname() ) )
354  {
355  LIB_PART* tmp = aLibTable.LoadSymbol( m_lib_id );
356 
357  if( tmp )
358  {
359  part = tmp->Flatten();
360  part->SetParent();
361  }
362  }
363 
364  // Fall back to cache library. This is temporary until the new schematic file
365  // format is implemented.
366  if( !part && aCacheLib )
367  {
368  wxString libId = m_lib_id.Format().wx_str();
369  libId.Replace( ":", "_" );
370  wxLogTrace( traceSymbolResolver,
371  "Library symbol %s not found falling back to cache library.",
372  m_lib_id.Format().wx_str() );
373  LIB_PART* tmp = aCacheLib->FindPart( libId );
374 
375  if( tmp )
376  {
377  part = tmp->Flatten();
378  part->SetParent();
379  }
380  }
381 
382  if( part )
383  {
384  m_part.reset( part.release() );
385  UpdatePins();
386  return true;
387  }
388  }
389  catch( const IO_ERROR& ioe )
390  {
391  wxLogTrace( traceSymbolResolver, "I/O error %s resolving library symbol %s", ioe.What(),
392  m_lib_id.Format().wx_str() );
393  }
394 
395  wxLogTrace( traceSymbolResolver, "Cannot resolve library symbol %s",
396  m_lib_id.Format().wx_str() );
397 
398  m_part.reset();
399  UpdatePins(); // This will clear the pin map and library symbol pin pointers.
400 
401  return false;
402 }
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
const wxChar *const traceSymbolResolver
Flag to enable debug output of symbol library resolver results.
LIB_PART * LoadSymbol(const wxString &aNickname, const wxString &aName)
Load a LIB_PART having aName from the library given by aNickname.
bool IsValid() const
Definition: lib_id.h:171
PROPERTIES is a name/value tuple with unique names and optional values.
Definition: properties.h:34
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:33
Define a library symbol object.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
static const char * PropNoDocFile
The property used internally by the plugin to disable writing the library documentation (....
std::unique_ptr< LIB_PART > m_part
std::unique_ptr< LIB_PART > Flatten() const
Return a flattened symbol inheritance to the caller.
LIB_PART * FindPart(const wxString &aName) const
Find LIB_PART by aName.
UTF8 Format() const
Definition: lib_id.cpp:237
wxString wx_str() const
Definition: utf8.cpp:51
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76

References PART_LIB::FindPart(), LIB_PART::Flatten(), LIB_ID::Format(), LIB_ID::GetLibNickname(), LIB_TABLE::HasLibrary(), LIB_ID::IsValid(), SYMBOL_LIB_TABLE::LoadSymbol(), m_lib_id, m_part, SCH_LEGACY_PLUGIN::PropNoDocFile, traceSymbolResolver, UpdatePins(), IO_ERROR::What(), and UTF8::wx_str().

◆ ResolveAll()

void SCH_COMPONENT::ResolveAll ( std::vector< SCH_COMPONENT * > &  aComponents,
SYMBOL_LIB_TABLE aLibTable,
PART_LIB aCacheLib = NULL 
)
static

Definition at line 420 of file sch_component.cpp.

422 {
423  // sort it by lib part. Cmp will be grouped by same lib part.
424  std::sort( aComponents.begin(), aComponents.end(), sort_by_libid );
425 
426  LIB_ID curr_libid;
427 
428  for( unsigned ii = 0; ii < aComponents.size(); ++ii )
429  {
430  SCH_COMPONENT* cmp = aComponents[ii];
431  curr_libid = cmp->m_lib_id;
432  cmp->Resolve( aLibTable, aCacheLib );
433  cmp->UpdatePins();
434 
435  // Propagate the m_part pointer to other members using the same lib_id
436  for( unsigned jj = ii + 1; jj < aComponents.size(); ++jj )
437  {
438  SCH_COMPONENT* next_cmp = aComponents[jj];
439 
440  if( curr_libid != next_cmp->m_lib_id )
441  break;
442 
443  if( cmp->m_part )
444  next_cmp->m_part.reset( new LIB_PART( *cmp->m_part.get() ) );
445 
446  next_cmp->UpdatePins();
447 
448  ii = jj;
449  }
450  }
451 }
static bool sort_by_libid(const SCH_COMPONENT *ref, SCH_COMPONENT *cmp)
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
Define a library symbol object.
std::unique_ptr< LIB_PART > m_part
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:99
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.

References m_lib_id, m_part, sort_by_libid(), and UpdatePins().

Referenced by SCH_SCREEN::UpdateSymbolLinks().

◆ Rotate()

void SCH_COMPONENT::Rotate ( wxPoint  aPosition)
overridevirtual

Function Rotate rotates 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 1386 of file sch_component.cpp.

1387 {
1388  wxPoint prev = m_Pos;
1389 
1390  RotatePoint( &m_Pos, aPosition, 900 );
1391 
1393 
1394  for( SCH_FIELD& field : m_Fields )
1395  {
1396  // Move the fields to the new position because the component itself has moved.
1397  wxPoint pos = field.GetTextPos();
1398  pos.x -= prev.x - m_Pos.x;
1399  pos.y -= prev.y - m_Pos.y;
1400  field.SetTextPos( pos );
1401  }
1402 }
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".
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.

◆ SetBrightened()

void EDA_ITEM::SetBrightened ( )
inlineinherited

◆ SetConnectivityDirty()

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

Definition at line 397 of file sch_item.h.

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

References SCH_ITEM::m_connectivity_dirty.

Referenced by SCH_EDIT_FRAME::SaveCopyInUndoList().

◆ SetConvert()

void SCH_COMPONENT::SetConvert ( int  aConvert)

Definition at line 505 of file sch_component.cpp.

506 {
507  if( m_convert != aConvert )
508  {
509  m_convert = aConvert;
510  SetModified();
511  }
512 }
void SetModified()
Definition: base_struct.cpp:94
int m_convert
The alternate body style for components that have more than one body style defined.

References m_convert, and EDA_ITEM::SetModified().

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

409  {
410  m_Fields = aFields; // vector copying, length is changed possibly
411  }
SCH_FIELDS m_Fields
Variable length list of fields.

References m_Fields.

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

◆ SetFlags()

void EDA_ITEM::SetFlags ( STATUS_FLAGS  aMask)
inlineinherited

Definition at line 257 of file base_struct.h.

257 { m_Flags |= aMask; }
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:189

References EDA_ITEM::m_Flags.

Referenced by SCH_EAGLE_PLUGIN::addBusEntries(), PCB_BASE_FRAME::AddModuleToBoard(), PCBNEW_CONTROL::AppendBoard(), SCH_EDIT_FRAME::ConvertPart(), SCH_EDIT_FRAME::ConvertTextType(), SCH_EDIT_FRAME::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(), LIB_DRAWING_TOOLS::DrawShape(), SCH_EDIT_TOOL::Duplicate(), LIB_EDIT_FRAME::GetComponentFromRedoList(), LIB_EDIT_FRAME::GetComponentFromUndoList(), SCH_MOVE_TOOL::getConnectedDragItems(), KIGFX::SCH_VIEW::HighlightItem(), EDIT_POINTS_FACTORY::Make(), TRACKS_CLEANER::mergeCollinearSegments(), SCH_MOVE_TOOL::moveItem(), LIB_MOVE_TOOL::moveItem(), KIGFX::ORIGIN_VIEWITEM::ORIGIN_VIEWITEM(), LIB_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), PCB_EDITOR_CONTROL::PlaceModule(), DRAWING_TOOL::PlaceText(), SCH_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_PIN_TOOL::RepeatPin(), LIB_EDIT_FRAME::SaveCopyInUndoList(), EE_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectPoint(), SCH_EDIT_FRAME::SelectUnit(), EDA_ITEM::SetBrightened(), LIB_PIN::SetConversion(), EDA_ITEM::SetHighlighted(), 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 308 of file base_struct.h.

308 { m_forceVisible = aEnable; }
bool m_forceVisible
Set to true to override the visibility setting of the item.
Definition: base_struct.h:186

References EDA_ITEM::m_forceVisible.

◆ SetHighlighted()

void EDA_ITEM::SetHighlighted ( )
inlineinherited

Definition at line 232 of file base_struct.h.

232 { SetFlags( HIGHLIGHTED ); }
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:257
#define HIGHLIGHTED
item is drawn in normal colors, when the rest is darkened
Definition: base_struct.h:142

References HIGHLIGHTED, and EDA_ITEM::SetFlags().

◆ SetLayer()

void SCH_ITEM::SetLayer ( SCH_LAYER_ID  aLayer)
inlineinherited

Function SetLayer sets the layer this item is on.

Parameters
aLayerThe layer number.

Definition at line 231 of file sch_item.h.

231 { m_Layer = aLayer; }
SCH_LAYER_ID m_Layer
Definition: sch_item.h:152

References SCH_ITEM::m_Layer.

Referenced by PANEL_EESCHEMA_COLOR_SETTINGS::createPreviewItems(), SCH_FIELD::SCH_FIELD(), and SCH_NO_CONNECT::SCH_NO_CONNECT().

◆ SetLibId() [1/2]

void SCH_COMPONENT::SetLibId ( const LIB_ID aName,
PART_LIBS aLibs = NULL 
)

Definition at line 241 of file sch_component.cpp.

242 {
243  if( m_lib_id != aLibId )
244  {
245  m_lib_id = aLibId;
246  SetModified();
247 
248  if( aLibs )
249  {
250  Resolve( aLibs );
251  }
252  else
253  {
254  m_part.reset();
255  m_pins.clear();
256  m_pinMap.clear();
257  }
258  }
259 }
void SetModified()
Definition: base_struct.cpp:94
SCH_PINS m_pins
a SCH_PIN for every LIB_PIN (across all units)
bool Resolve(PART_LIBS *aLibs)
Assigns the current LIB_PART from aLibs which this symbol is based on.
std::unique_ptr< LIB_PART > m_part
SCH_PIN_MAP m_pinMap
the component's pins mapped by LIB_PIN*

References m_lib_id, m_part, m_pinMap, m_pins, Resolve(), and EDA_ITEM::SetModified().

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

◆ SetLibId() [2/2]

void SCH_COMPONENT::SetLibId ( const LIB_ID aLibId,
SYMBOL_LIB_TABLE aSymLibTable,
PART_LIB aCacheLib 
)

Definition at line 262 of file sch_component.cpp.

264 {
265  if( m_lib_id == aLibId )
266  return;
267 
268  m_lib_id = aLibId;
269  SetModified();
270 
271  std::unique_ptr< LIB_PART > symbol;
272 
273  if( aSymLibTable && aSymLibTable->HasLibrary( m_lib_id.GetLibNickname() ) )
274  {
275  LIB_PART* tmp = aSymLibTable->LoadSymbol( m_lib_id );
276 
277  if( tmp )
278  {
279  symbol = tmp->Flatten();
280  symbol->SetParent();
281  }
282  }
283 
284  if( !symbol && aCacheLib )
285  {
286  LIB_PART* tmp = aCacheLib->FindPart( m_lib_id.Format().wx_str() );
287 
288  if( tmp )
289  {
290  symbol = tmp->Flatten();
291  symbol->SetParent();
292  }
293  }
294 
295  m_part.reset( symbol.release() );
296  UpdatePins();
297 }
void SetModified()
Definition: base_struct.cpp:94
bool HasLibrary(const wxString &aNickname, bool aCheckEnabled=false) const
Test for the existence of aNickname in the library table.
LIB_PART * LoadSymbol(const wxString &aNickname, const wxString &aName)
Load a LIB_PART having aName from the library given by aNickname.
Define a library symbol object.
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
std::unique_ptr< LIB_PART > Flatten() const
Return a flattened symbol inheritance to the caller.
LIB_PART * FindPart(const wxString &aName) const
Find LIB_PART by aName.
UTF8 Format() const
Definition: lib_id.cpp:237
wxString wx_str() const
Definition: utf8.cpp:51
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.

References PART_LIB::FindPart(), LIB_PART::Flatten(), LIB_ID::Format(), LIB_ID::GetLibNickname(), LIB_TABLE::HasLibrary(), SYMBOL_LIB_TABLE::LoadSymbol(), m_lib_id, m_part, EDA_ITEM::SetModified(), UpdatePins(), and UTF8::wx_str().

◆ SetLocked()

virtual void SCH_ITEM::SetLocked ( bool  aLocked)
inlinevirtualinherited

Function SetLocked modifies 'lock' status for of the item.

Definition at line 218 of file sch_item.h.

218 {}

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

1019 {
1020  TRANSFORM temp = TRANSFORM();
1021  bool transform = false;
1022 
1023  switch( aOrientation )
1024  {
1025  case CMP_ORIENT_0:
1026  case CMP_NORMAL: // default transform matrix
1027  m_transform.x1 = 1;
1028  m_transform.y2 = -1;
1029  m_transform.x2 = m_transform.y1 = 0;
1030  break;
1031 
1032  case CMP_ROTATE_COUNTERCLOCKWISE: // Rotate + (incremental rotation)
1033  temp.x1 = temp.y2 = 0;
1034  temp.y1 = 1;
1035  temp.x2 = -1;
1036  transform = true;
1037  break;
1038 
1039  case CMP_ROTATE_CLOCKWISE: // Rotate - (incremental rotation)
1040  temp.x1 = temp.y2 = 0;
1041  temp.y1 = -1;
1042  temp.x2 = 1;
1043  transform = true;
1044  break;
1045 
1046  case CMP_MIRROR_Y: // Mirror Y (incremental rotation)
1047  temp.x1 = -1;
1048  temp.y2 = 1;
1049  temp.y1 = temp.x2 = 0;
1050  transform = true;
1051  break;
1052 
1053  case CMP_MIRROR_X: // Mirror X (incremental rotation)
1054  temp.x1 = 1;
1055  temp.y2 = -1;
1056  temp.y1 = temp.x2 = 0;
1057  transform = true;
1058  break;
1059 
1060  case CMP_ORIENT_90:
1063  break;
1064 
1065  case CMP_ORIENT_180:
1069  break;
1070 
1071  case CMP_ORIENT_270:
1074  break;
1075 
1076  case ( CMP_ORIENT_0 + CMP_MIRROR_X ):
1079  break;
1080 
1081  case ( CMP_ORIENT_0 + CMP_MIRROR_Y ):
1084  break;
1085 
1086  case ( CMP_ORIENT_90 + CMP_MIRROR_X ):
1089  break;
1090 
1091  case ( CMP_ORIENT_90 + CMP_MIRROR_Y ):
1094  break;
1095 
1096  case ( CMP_ORIENT_180 + CMP_MIRROR_X ):
1099  break;
1100 
1101  case ( CMP_ORIENT_180 + CMP_MIRROR_Y ):
1104  break;
1105 
1106  case ( CMP_ORIENT_270 + CMP_MIRROR_X ):
1109  break;
1110 
1111  case ( CMP_ORIENT_270 + CMP_MIRROR_Y ):
1114  break;
1115 
1116  default:
1117  transform = false;
1118  wxMessageBox( wxT( "SetRotateMiroir() error: ill value" ) );
1119  break;
1120  }
1121 
1122  if( transform )
1123  {
1124  /* The new matrix transform is the old matrix transform modified by the
1125  * requested transformation, which is the temp transform (rot,
1126  * mirror ..) in order to have (in term of matrix transform):
1127  * transform coord = new_m_transform * coord
1128  * where transform coord is the coord modified by new_m_transform from
1129  * the initial value coord.
1130  * new_m_transform is computed (from old_m_transform and temp) to
1131  * have:
1132  * transform coord = old_m_transform * temp
1133  */
1134  TRANSFORM newTransform;
1135 
1136  newTransform.x1 = m_transform.x1 * temp.x1 + m_transform.x2 * temp.y1;
1137  newTransform.y1 = m_transform.y1 * temp.x1 + m_transform.y2 * temp.y1;
1138  newTransform.x2 = m_transform.x1 * temp.x2 + m_transform.x2 * temp.y2;
1139  newTransform.y2 = m_transform.y1 * temp.x2 + m_transform.y2 * temp.y2;
1140  m_transform = newTransform;
1141  }
1142 }
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()

◆ SetPosition()

void SCH_COMPONENT::SetPosition ( const wxPoint aPosition)
inlineoverridevirtual

Function SetPosition set the schematic item position to aPosition.

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

Implements SCH_ITEM.

Definition at line 612 of file sch_component.h.

612 { Move( aPosition - m_Pos ); }
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
void Move(const wxPoint &aMoveVector) override
Function Move moves 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 270 of file sch_component.h.

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

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

627 {
628  KIID_PATH path = sheet->Path();
629  bool notInArray = true;
630 
631  // check to see if it is already there before inserting it
633  {
634  if( instance.m_Path == path )
635  {
636  instance.m_Reference = ref;
637  notInArray = false;
638  }
639  }
640 
641  if( notInArray )
642  AddHierarchicalReference( path, ref, m_unit );
643 
644  SCH_FIELD* rf = GetField( REFERENCE );
645 
646  // @todo Should we really be checking for what is a "reasonable" position?
647  if( rf->GetText().IsEmpty()
648  || ( abs( rf->GetTextPos().x - m_Pos.x ) +
649  abs( rf->GetTextPos().y - m_Pos.y ) > Mils2iu( 10000 ) ) )
650  {
651  // move it to a reasonable position
652  rf->SetTextPos( m_Pos + wxPoint( Mils2iu( 50 ), Mils2iu( 50 ) ) );
653  }
654 
655  rf->SetText( ref ); // for drawing.
656 
657  // Reinit the m_prefix member if needed
658  wxString prefix = ref;
659 
660  if( IsReferenceStringValid( prefix ) )
661  {
662  while( prefix.Last() == '?' || wxIsdigit( prefix.Last() ) )
663  prefix.RemoveLast();
664  }
665  else
666  {
667  prefix = wxT( "U" ); // Set to default ref prefix
668  }
669 
670  if( m_prefix != prefix )
671  m_prefix = prefix;
672 
673  // Power components have references starting with # and are not included in netlists
674  m_isInNetlist = ! ref.StartsWith( wxT( "#" ) );
675 }
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".
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:231
std::vector< COMPONENT_INSTANCE_REFERENCE > m_instanceReferences
Field Reference of part, i.e. "IC21".
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:111
bool m_isInNetlist
True if the component should appear in the netlist.
int m_unit
The unit for multiple part per package components.
const wxPoint & GetTextPos() const
Definition: eda_text.h:232
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:123

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

◆ SetSelected()

void EDA_ITEM::SetSelected ( )
inlineinherited

◆ SetState()

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

Definition at line 246 of file base_struct.h.

247  {
248  if( state )
249  m_Status |= type; // state = ON or OFF
250  else
251  m_Status &= ~type;
252  }
STATUS_FLAGS m_Status
Definition: base_struct.h:179

References EDA_ITEM::m_Status.

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

◆ SetStatus()

void EDA_ITEM::SetStatus ( STATUS_FLAGS  aStatus)
inlineinherited

Definition at line 255 of file base_struct.h.

255 { m_Status = aStatus; }
STATUS_FLAGS m_Status
Definition: base_struct.h:179

References EDA_ITEM::m_Status.

Referenced by BOARD_NETLIST_UPDATER::UpdateNetlist().

◆ SetStoredPos()

void SCH_ITEM::SetStoredPos ( wxPoint  aPos)
inlineinherited

Definition at line 206 of file sch_item.h.

206 { m_storedPos = aPos; }
wxPoint m_storedPos
Definition: sch_item.h:155

References SCH_ITEM::m_storedPos.

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

◆ SetTransform()

void SCH_COMPONENT::SetTransform ( const TRANSFORM aTransform)

Definition at line 515 of file sch_component.cpp.

516 {
517  if( m_transform != aTransform )
518  {
519  m_transform = aTransform;
520  SetModified();
521  }
522 }
void SetModified()
Definition: base_struct.cpp:94
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 489 of file sch_component.cpp.

490 {
491  if( m_unit != aUnit )
492  {
493  m_unit = aUnit;
494  SetModified();
495  }
496 }
void SetModified()
Definition: base_struct.cpp:94
int m_unit
The unit for multiple part per package components.

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

709 {
710  KIID_PATH path = aSheet->Path();
711  bool notInArray = true;
712 
713  // check to see if it is already there before inserting it
715  {
716  if( instance.m_Path == path )
717  {
718  instance.m_Unit = aUnitSelection;
719  notInArray = false;
720  }
721  }
722 
723  if( notInArray )
724  AddHierarchicalReference( path, m_prefix, aUnitSelection );
725 }
KIID_PATH Path() const
Get the sheet path as an KIID_PATH.
std::vector< COMPONENT_INSTANCE_REFERENCE > m_instanceReferences
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 230 of file base_struct.h.

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

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

536 { return *aLeft < *aRight; }

◆ SwapData()

void SCH_COMPONENT::SwapData ( SCH_ITEM aItem)
overridevirtual

Function SwapData 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 920 of file sch_component.cpp.

921 {
922  wxCHECK_RET( (aItem != NULL) && (aItem->Type() == SCH_COMPONENT_T),
923  wxT( "Cannot swap data with invalid component." ) );
924 
925  SCH_COMPONENT* component = (SCH_COMPONENT*) aItem;
926 
927  std::swap( m_lib_id, component->m_lib_id );
928 
929  LIB_PART* part = component->m_part.release();
930  component->m_part.reset( m_part.release() );
931  component->UpdatePins();
932  m_part.reset( part );
933  UpdatePins();
934 
935  std::swap( m_Pos, component->m_Pos );
936  std::swap( m_unit, component->m_unit );
937  std::swap( m_convert, component->m_convert );
938 
939  m_Fields.swap( component->m_Fields ); // std::vector's swap()
940 
941  for( SCH_FIELD& field : component->m_Fields )
942  field.SetParent( component );
943 
944  for( SCH_FIELD& field : m_Fields )
945  field.SetParent( this );
946 
947  TRANSFORM tmp = m_transform;
948 
949  m_transform = component->m_transform;
950  component->m_transform = tmp;
951 
952  std::swap( m_instanceReferences, component->m_instanceReferences );
953 }
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".
std::vector< COMPONENT_INSTANCE_REFERENCE > m_instanceReferences
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
#define NULL
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:218
Define a library symbol object.
std::unique_ptr< LIB_PART > m_part
int m_unit
The unit for multiple part per package components.
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:99
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:212

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

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

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_BUS_BUS_ENTRY::CanConnect(), SCH_LINE::CanConnect(), SCH_LABEL::CanConnect(), SCH_GLOBALLABEL::CanConnect(), SCH_HIERLABEL::CanConnect(), SCH_SHEET::CanConnect(), CanConnect(), ROUTER_TOOL::CanInlineDrag(), SCH_MARKER::ClassOf(), SCH_JUNCTION::ClassOf(), TEXTE_PCB::ClassOf(), SCH_NO_CONNECT::ClassOf(), BOARD_CONNECTED_ITEM::ClassOf(), SCH_PIN::ClassOf(), EDGE_MODULE::ClassOf(), PCB_TARGET::ClassOf(), SCH_LINE::ClassOf(), SCH_FIELD::ClassOf(), TEXTE_MODULE::ClassOf(), DRAWSEGMENT::ClassOf(), ZONE_CONTAINER::ClassOf(), SCH_BITMAP::ClassOf(), TRACK::ClassOf(), DIMENSION::ClassOf(), NETINFO_ITEM::ClassOf(), MARKER_PCB::ClassOf(), SCH_SHEET_PIN::ClassOf(), MODULE::ClassOf(), SCH_BUS_WIRE_ENTRY::ClassOf(), SCH_SCREEN::ClassOf(), D_PAD::ClassOf(), ClassOf(), SCH_BUS_BUS_ENTRY::ClassOf(), BOARD::ClassOf(), SCH_TEXT::ClassOf(), SCH_SHEET::ClassOf(), ARC::ClassOf(), SCH_LABEL::ClassOf(), VIA::ClassOf(), SCH_GLOBALLABEL::ClassOf(), SCH_HIERLABEL::ClassOf(), TRACKS_CLEANER::cleanupSegments(), LIB_RECTANGLE::compare(), LIB_BEZIER::compare(), LIB_CIRCLE::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(), SCH_EDIT_FRAME::ConvertTextType(), MODULE::CoverageRatio(), CINFO3D_VISU::createLayers(), SCH_EDIT_FRAME::CreateNewText(), CINFO3D_VISU::createNewTrack(), NETLIST_EXPORTER::CreatePinList(), 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(), 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(), SCH_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(), KIGFX::GERBVIEW_RENDER_SETTINGS::GetColor(), KIGFX::PCB_RENDER_SETTINGS::GetColor(), NETLIST_OBJECT::GetComponentParent(), SCH_MOVE_TOOL::getConnectedDragItems(), SCH_TEXT::GetConnectionPoints(), CONNECTION_GRAPH::getDefaultConnection(), CONNECTION_SUBGRAPH::GetDriverPriority(), SCH_TEXT::GetEndPoints(), SCH_FIELD::GetFullyQualifiedText(), SCH_FIELD::GetMenuImage(), TEXTE_PCB::GetMsgPanelInfo(), SCH_TEXT::GetMsgPanelInfo(), SCH_FIELD::GetName(), CONNECTION_SUBGRAPH::GetNameForDriver(), CONNECTIVITY_DATA::GetNetItems(), LIB_PART::GetNextDrawItem(), DRAWSEGMENT::GetParentModule(), SCH_FIELD::GetParentPosition(), LIB_PART::GetPin(), GetPinPhysicalPosition(), SCH_FIELD::GetPosition(), getRect(), KIGFX::SCH_PAINTER::getRenderColor(), PCBNEW_SELECTION::GetTopLeftItem(), SELECTION_TOOL::GuessSelectionCandidates(), EE_SELECTION_TOOL::GuessSelectionCandidates(), hash_eda(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), KIGFX::SCH_VIEW::HighlightItem(), 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(), CLIPBOARD_IO::Load(), PNS_PCBNEW_RULE_RESOLVER::localPadClearance(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_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_CONNECTION::Name(), SCH_EDITOR_CONTROL::nextMatch(), FOOTPRINT_EDIT_FRAME::OnEditItemRequest(), PCB_EDIT_FRAME::OnEditItemRequest(), POINT_EDITOR::OnSelectionChange(), 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::Plot_1_EdgeModule(), 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_BASE_FRAME::RefreshItem(), SCH_BASE_FRAME::RefreshSelection(), EE_RTREE::remove(), MODULE::Remove(), CN_CONNECTIVITY_ALGO::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(), SCH_EDIT_TOOL::Rotate(), SCH_TEXT::Rotate(), 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_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(), SELECTION_TOOL::select(), SELECTION_TOOL::Selectable(), EE_SELECTION_TOOL::Selectable(), SELECTION_TOOL::selectConnectedTracks(), ITEM_PICKER::SetItem(), SCH_FIELD::SetPosition(), DIALOG_LABEL_EDITOR::SetTitle(), PCB_EDIT_FRAME::SetTrackSegmentWidth(), ShowClearance(), BOARD_COMMIT::Stage(), SCH_JUNCTION::SwapData(), SCH_NO_CONNECT::SwapData(), SCH_BITMAP::SwapData(), PCB_TARGET::SwapData(), TEXTE_PCB::SwapData(), SCH_SHEET_PIN::SwapData(), SCH_FIELD::SwapData(), TRACK::SwapData(), DIMENSION::SwapData(), ARC::SwapData(), SCH_SHEET::SwapData(), VIA::SwapData(), SwapData(), MODULE::SwapData(), ZONE_CONTAINER::SwapData(), D_PAD::SwapData(), SwapItemData(), TEXTE_MODULE::TEXTE_MODULE(), AR_MATRIX::TraceSegmentPcb(), 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(), POINT_EDITOR::updateItem(), CONNECTION_GRAPH::updateItemConnectivity(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_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(), 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 1435 of file sch_component.cpp.

1437 {
1438  bool changed = false;
1439 
1440  for( auto& pin : m_pins )
1441  {
1442  bool previousState = pin->IsDangling();
1443  pin->SetIsDangling( true );
1444 
1445  wxPoint pos = m_transform.TransformCoordinate( pin->GetPosition() ) + m_Pos;
1446 
1447  for( DANGLING_END_ITEM& each_item : aItemList )
1448  {
1449  // Some people like to stack pins on top of each other in a symbol to indicate
1450  // internal connection. While technically connected, it is not particularly useful
1451  // to display them that way, so skip any pins that are in the same symbol as this
1452  // one.
1453  if( each_item.GetParent() == this )
1454  continue;
1455 
1456  switch( each_item.GetType() )
1457  {
1458  case PIN_END:
1459  case LABEL_END:
1460  case SHEET_LABEL_END:
1461  case WIRE_START_END:
1462  case WIRE_END_END:
1463  case NO_CONNECT_END:
1464  case JUNCTION_END:
1465 
1466  if( pos == each_item.GetPosition() )
1467  pin->SetIsDangling( false );
1468 
1469  break;
1470 
1471  default:
1472  break;
1473  }
1474 
1475  if( !pin->IsDangling() )
1476  break;
1477  }
1478 
1479  changed = ( changed || ( previousState != pin->IsDangling() ) );
1480  }
1481 
1482  return changed;
1483 }
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".
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:42
DANGLING_END_ITEM is a helper class used to store the state of schematic items that can be connected ...
Definition: sch_item.h:76
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 813 of file sch_component.cpp.

814 {
815  if( m_part )
816  {
817  wxString symbolName;
818  LIB_FIELDS fields;
819  m_part->GetFields( fields );
820 
821  for( const LIB_FIELD& field : fields )
822  {
823  // Can no longer insert an empty name, since names are now keys. The
824  // field index is not used beyond the first MANDATORY_FIELDS
825  if( field.GetName( NATIVE_FIELD_NAME ).IsEmpty() )
826  continue;
827 
828  // See if field already exists (mandatory fields always exist).
829  // for mandatory fields, the name and field id are fixed, so we use the
830  // known and fixed id to get them (more reliable than names, which can be translated)
831  // for other fields (custom fields), locate the field by same name
832  // (field id has no known meaning for custom fields)
833  int idx = field.GetId();
834  SCH_FIELD* schField;
835 
836  if( idx == REFERENCE && !aResetRef )
837  continue;
838 
839  if( (unsigned) idx < MANDATORY_FIELDS )
840  schField = GetField( idx );
841  else
842  schField = FindField( field.GetName( NATIVE_FIELD_NAME ) );
843 
844  if( !schField )
845  {
846  SCH_FIELD newField( wxPoint( 0, 0 ), GetFieldCount(), this,
847  field.GetName( NATIVE_FIELD_NAME ) );
848  schField = AddField( newField );
849  }
850 
851  if( aResetStyle )
852  {
853  schField->ImportValues( field );
854  schField->SetTextPos( m_Pos + field.GetTextPos() );
855  }
856 
857  if( idx == VALUE )
858  {
859  schField->SetText( m_lib_id.GetLibItemName() ); // fetch alias-specific value
860  symbolName = m_lib_id.GetLibItemName();
861  }
862  else if( idx == DATASHEET )
863  {
864  schField->SetText( GetDatasheet() ); // fetch alias-specific value
865 
866  // Some older libraries may be broken and the alias datasheet information
867  // in the document file for the root part may have been dropped. This only
868  // happens for the root part.
869  if( schField->GetText().IsEmpty() && symbolName == m_part->GetName() )
870  schField->SetText( m_part->GetField( DATASHEET )->GetText() );
871  }
872  else
873  {
874  schField->SetText( field.GetText() );
875  }
876  }
877  }
878 }
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
SCH_FIELD * FindField(const wxString &aFieldName, bool aIncludeDefaultFields=true)
Search for a SCH_FIELD with aFieldName.
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
name of datasheet
void ImportValues(const LIB_FIELD &aSource)
Function ImportValues copy parameters from a LIB_FIELD source.
Definition: sch_field.cpp:185
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
Field object used in symbol libraries.
Definition: lib_field.h:59