KiCad PCB EDA Suite
SCH_COMPONENT Class Reference

Class 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 Types

enum  AUTOPLACED { AUTOPLACED_NO = 0, AUTOPLACED_AUTO, AUTOPLACED_MANUAL }
 

Public Member Functions

 SCH_COMPONENT (const wxPoint &pos=wxPoint(0, 0), SCH_ITEM *aParent=NULL)
 
 SCH_COMPONENT (LIB_PART &aPart, SCH_SHEET_PATH *aSheet, int unit=0, int convert=0, const wxPoint &pos=wxPoint(0, 0), bool setNewItemFlag=false)
 Create schematic component from library component object. More...
 
 SCH_COMPONENT (const SCH_COMPONENT &aComponent)
 Copy Constructor clones aComponent into a new object. More...
 
 ~SCH_COMPONENT ()
 
wxString GetClass () const override
 Function GetClass returns the class name. More...
 
const wxArrayString & GetPathsAndReferences () const
 
bool IsMovableFromAnchorPoint () override
 Virtual function IsMovableFromAnchorPoint 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, compoments) More...
 
void SetLibId (const LIB_ID &aName, PART_LIBS *aLibs=NULL)
 
void SetLibId (const LIB_ID &aLibId, SYMBOL_LIB_TABLE *aSymLibTable)
 
const LIB_IDGetLibId () const
 
PART_REFGetPartRef ()
 
wxString GetAliasDescription () const
 Return information about the aliased parts. More...
 
wxString GetAliasDocumentation () const
 Function GetAliasDocumentation Return the documentation text for the given part alias. More...
 
bool Resolve (PART_LIBS *aLibs)
 Function Resolve [re-]assigns the current LIB_PART from aLibs which this component is based on. More...
 
int GetUnit () const
 
void SetUnit (int aUnit)
 change the unit id to aUnit has maening only for multiple parts per package Also set the modified flag bit More...
 
void UpdateUnit (int aUnit)
 change the unit id to aUnit has maening only for multiple parts per package Do not change the modified flag bit, and should be used when change is not due to an edition command 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
 Function GetUnitCount returns the number of parts per package of the component. More...
 
bool Save (FILE *aFile) const override
 Function Save writes the data structures for this object out to a FILE in "*.sch" format. More...
 
bool Load (LINE_READER &aLine, wxString &aErrorMsg) override
 Function Load reads a schematic item from aLine in a .sch file. More...
 
void SetOrientation (int aOrientation)
 Function SetOrientation computes the new transform matrix based on aOrientation for the component which is applied to the current transform. More...
 
int GetOrientation ()
 Function GetOrientation Used to display component orientation (in dialog editor or info) More...
 
wxPoint GetScreenCoord (const wxPoint &aPoint)
 Function GetScreenCoord Returns the coordinated point relative to the orientation of the component of aPoint. More...
 
void GetMsgPanelInfo (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)
 Function ClearAnnotation clears exiting component annotation ( i.i IC23 changed to IC? and part reset to 1) More...
 
void SetTimeStamp (time_t aNewTimeStamp)
 Function SetTimeStamp changes the time stamp to aNewTimeStamp updates the reference path. 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
 Function GetBodyBoundingBox Return a bounding box for the component body but not the fields. More...
 
SCH_FIELDGetField (int aFieldNdx) const
 Function GetField returns a field. More...
 
wxString GetFieldText (wxString aFieldName, bool aIncludeDefaultFields=true) const
 Returns text associated with a given field (if such a field exists) is the name of the field. More...
 
void GetFields (std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
 Function GetFields populates a std::vector with SCH_FIELDs. More...
 
SCH_FIELDAddField (const SCH_FIELD &aField)
 Function AddField adds a field to the component. More...
 
SCH_FIELDFindField (const wxString &aFieldName, bool aIncludeDefaultFields=true)
 Function FindField searches for SCH_FIELD with aFieldName and returns it if found, else NULL. More...
 
void SetFields (const SCH_FIELDS &aFields)
 
int GetFieldCount () const
 Function GetFieldCount returns the number of fields in this component. More...
 
AUTOPLACED GetFieldsAutoplaced () const
 Function GetFieldsAutoplaced returns whether the fields are autoplaced. More...
 
void ClearFieldsAutoplaced ()
 Function ClearFieldsAutoplaced Set fields autoplaced flag false. More...
 
void AutoplaceFields (SCH_SCREEN *aScreen, bool aManual)
 Function AutoplaceFields Automatically orient all the fields in the component. More...
 
void AutoAutoplaceFields (SCH_SCREEN *aScreen)
 Function AutoAutoplaceFields Autoplace fields only if correct to do so automatically. More...
 
LIB_PINGetPin (const wxString &number)
 Function GetPin finds a component pin by number. More...
 
void GetPins (std::vector< LIB_PIN * > &aPinsList)
 Function GetPins populate a vector with all the pins. More...
 
void Draw (EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
 Virtual function, from the base class SCH_ITEM::Draw. More...
 
void Draw (EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor, bool aDrawPinText)
 Function Draw, specific to components. More...
 
void SwapData (SCH_ITEM *aItem) override
 Function SwapData swap the internal data structures aItem with the schematic item. More...
 
wxString GetPath (const SCH_SHEET_PATH *sheet) const
 
void SetCurrentSheetPath (const SCH_SHEET_PATH *aSheetPath)
 
const wxString GetRef (const SCH_SHEET_PATH *sheet)
 Function GetRef returns the reference, for the given sheet path. More...
 
void SetRef (const SCH_SHEET_PATH *sheet, const wxString &ref)
 Set the reference, for the given sheet path. More...
 
void AddHierarchicalReference (const wxString &aPath, const wxString &aRef, int aMulti)
 Function AddHierarchicalReference adds a full hierarchical reference (path + local reference) More...
 
int GetUnitSelection (SCH_SHEET_PATH *aSheet)
 
void SetUnitSelection (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, wxPoint *aFindLocation) 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 IsPinDanglingStateChanged (std::vector< DANGLING_END_ITEM > &aItemList, LIB_PINS &aLibPins, unsigned aPin)
 Test if the component's dangling state has changed for one given pin index. More...
 
bool IsDanglingStateChanged (std::vector< DANGLING_END_ITEM > &aItemList) override
 Test if the component's dangling state has changed for all pins. More...
 
bool IsDangling () const override
 Return whether any pin has dangling status. More...
 
wxPoint GetPinPhysicalPosition (LIB_PIN *Pin)
 
bool IsSelectStateChanged (const wxRect &aRect) override
 Function IsSelectStateChanged checks if the selection state of an item inside aRect has changed. More...
 
bool IsConnectable () const override
 Function IsConnectable returns true if the schematic item can connect to another schematic item. More...
 
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)
 Function GetDrawItem(). More...
 
wxString GetSelectMenuText () 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_ITEMoperator= (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) 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=false, 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...
 
SCH_ITEMNext () const
 
SCH_ITEMBack () const
 
wxPointGetStoredPos ()
 
void SetStoredPos (wxPoint aPos)
 
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...
 
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...
 
virtual bool HitTest (const wxPoint &aPosition) const override
 
virtual bool CanIncrementLabel () const
 
bool operator< (const EDA_ITEM &aItem) const
 Test if another item is less than this object. More...
 
KICAD_T Type () const
 Function Type() More...
 
time_t GetTimeStamp () const
 
EDA_ITEMGetParent () const
 
DHEADGetList () const
 
void SetNext (EDA_ITEM *aNext)
 
void SetBack (EDA_ITEM *aBack)
 
void SetParent (EDA_ITEM *aParent)
 
void SetList (DHEAD *aList)
 
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
 
void SetForceVisible (bool aEnable)
 Function SetForceVisible is used to set and cleag force visible flag used to force the item to be drawn even if it's draw attribute is set to not visible. More...
 
bool 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...
 
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
 
virtual void ViewGetLayers (int aLayers[], int &aCount) const override
 
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 of the item. More...
 
VIEW_ITEM_DATA * viewPrivData () const
 

Static Public Member Functions

static void ResolveAll (const SCH_COLLECTOR &aComponents, PART_LIBS *aLibs)
 
static bool IsReferenceStringValid (const wxString &aReferenceString)
 Function IsReferenceStringValid (static) Tests for an acceptable reference string An acceptable reference string must support unannotation i.e starts by letter. More...
 
static std::string FormatInternalUnits (int aValue)
 Function FormatInternalUnits converts aValue from schematic internal units to a string appropriate for writing to file. More...
 
static std::string FormatInternalUnits (const wxPoint &aPoint)
 
static std::string FormatInternalUnits (const wxSize &aSize)
 
static std::string FormatAngle (double aAngle)
 Function FormatAngle converts aAngle from board units to a string appropriate for writing to file. More...
 
static SEARCH_RESULT IterateForward (EDA_ITEM *listStart, INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
 Function IterateForward walks through the object tree calling the inspector() on each object type requested in scanTypes. 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...
 

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
 List of items connected to this item. More...
 
wxPoint m_storedPos
 a temporary variable used in some move commands

to store a initial pos (of the item or mouse cursor)

More...
 
EDA_ITEMPnext
 next in linked list More...
 
EDA_ITEMPback
 previous in linked list More...
 
DHEADm_List
 which DLIST I am on. More...
 
EDA_ITEMm_Parent
 Linked list: Link (parent struct) More...
 
time_t m_TimeStamp
 Time stamp used for logical links. 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...
 
PART_REF m_part
 points into the PROJECT's libraries to the LIB_PART for this component More...
 
std::vector< bool > m_isDangling
 One isDangling per pin. More...
 
AUTOPLACED m_fieldsAutoplaced
 indicates status of field autoplacement More...
 
const SCH_SHEET_PATHm_currentSheetPath
 A temporary sheet path is required to generate the correct reference designator string in complex heirarchies. More...
 
wxArrayString m_PathsAndReferences
 Defines the hierarchical path and reference of the component. More...
 

Friends

class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC
 

Detailed Description

Class SCH_COMPONENT describes a real schematic component.

Definition at line 69 of file sch_component.h.

Member Enumeration Documentation

Enumerator
AUTOPLACED_NO 
AUTOPLACED_AUTO 
AUTOPLACED_MANUAL 

Definition at line 74 of file sch_component.h.

Constructor & Destructor Documentation

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

Definition at line 117 of file sch_component.cpp.

References AUTOPLACED_NO, Init(), m_currentSheetPath, and m_fieldsAutoplaced.

Referenced by Clone().

117  :
118  SCH_ITEM( aParent, SCH_COMPONENT_T )
119 {
120  Init( aPos );
121  m_currentSheetPath = NULL;
123 }
const SCH_SHEET_PATH * m_currentSheetPath
A temporary sheet path is required to generate the correct reference designator string in complex hei...
void Init(const wxPoint &pos=wxPoint(0, 0))
AUTOPLACED m_fieldsAutoplaced
indicates status of field autoplacement
Definition: sch_component.h:97
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType)
SCH_COMPONENT::SCH_COMPONENT ( LIB_PART aPart,
SCH_SHEET_PATH aSheet,
int  unit = 0,
int  convert = 0,
const wxPoint pos = wxPoint( 0, 0 ),
bool  setNewItemFlag = false 
)

Create schematic component from library component object.

Parameters
aPart- library part to create schematic component from.
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 126 of file sch_component.cpp.

References AddField(), AUTOPLACED_NO, FindField(), FROM_UTF8(), GetField(), GetFieldCount(), LIB_PART::GetFields(), GetLibId(), LIB_PART::GetName(), GetNewTimeStamp(), LIB_PART::GetReferenceField(), EDA_TEXT::GetText(), SCH_FIELD::ImportValues(), Init(), IS_MOVED, IS_NEW, m_convert, m_currentSheetPath, m_fieldsAutoplaced, EDA_ITEM::m_Flags, m_lib_id, m_part, m_Pos, m_prefix, m_unit, MANDATORY_FIELDS, LIB_ID::SetLibItemName(), SetRef(), EDA_TEXT::SetText(), EDA_TEXT::SetTextPos(), SetTimeStamp(), LIB_PART::SharedPtr(), TO_UTF8, and VALUE.

127  :
128  SCH_ITEM( NULL, SCH_COMPONENT_T )
129 {
130  Init( pos );
131 
132  m_unit = unit;
133  m_convert = convert;
134  m_lib_id.SetLibItemName( TO_UTF8( aPart.GetName() ), false );
135  m_part = aPart.SharedPtr();
136  m_currentSheetPath = NULL;
138 
140 
141  if( setNewItemFlag )
142  m_Flags = IS_NEW | IS_MOVED;
143 
144  // Import user defined fields from the library component:
145  LIB_FIELDS libFields;
146 
147  aPart.GetFields( libFields );
148 
149  for( LIB_FIELDS::iterator it = libFields.begin(); it!=libFields.end(); ++it )
150  {
151  // Can no longer insert an empty name, since names are now keys. The
152  // field index is not used beyond the first MANDATORY_FIELDS
153  if( it->GetName().IsEmpty() )
154  continue;
155 
156  // See if field already exists (mandatory fields always exist).
157  // for mandatory fields, the name and field id are fixed, so we use the
158  // known and fixed id to get them (more reliable than names, which can be translated)
159  // for other fields (custom fields), locate the field by same name
160  // (field id has no known meaning for custom fields)
161  int idx = it->GetId();
162  SCH_FIELD* schField;
163 
164  if( idx < MANDATORY_FIELDS )
165  schField = GetField( idx );
166  else
167  schField = FindField( it->GetName() );
168 
169  if( !schField )
170  {
171  SCH_FIELD fld( wxPoint( 0, 0 ), GetFieldCount(), this, it->GetName() );
172  schField = AddField( fld );
173  }
174 
175  schField->ImportValues( *it );
176  schField->SetText( it->GetText() );
177 
178  // Now the field is initialized, place it to the right position:
179  schField->SetTextPos( m_Pos + it->GetTextPos() );
180  }
181 
182  wxString msg = aPart.GetReferenceField().GetText();
183 
184  if( msg.IsEmpty() )
185  msg = wxT( "U" );
186 
187  m_prefix = msg;
188 
189  // update the reference -- just the prefix for now.
190  msg += wxT( "?" );
191  SetRef( sheet, msg );
192 
193  // Use the schematic component name instead of the library value field name.
194  GetField( VALUE )->SetText( FROM_UTF8( GetLibId().GetLibItemName() ) );
195 }
Class SCH_FIELD instances are attached to a component and provide a place for the component's value...
Definition: sch_field.h:56
SCH_FIELD * FindField(const wxString &aFieldName, bool aIncludeDefaultFields=true)
Function FindField searches for SCH_FIELD with aFieldName and returns it if found, else NULL.
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
const SCH_SHEET_PATH * m_currentSheetPath
A temporary sheet path is required to generate the correct reference designator string in complex hei...
void ImportValues(const LIB_FIELD &aSource)
Function ImportValues copy parameters from a LIB_FIELD source.
Definition: sch_field.cpp:221
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors...
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:223
time_t GetNewTimeStamp()
Definition: common.cpp:166
void SetRef(const SCH_SHEET_PATH *sheet, const wxString &ref)
Set the reference, for the given sheet path.
#define IS_NEW
New item, just created.
Definition: base_struct.h:113
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
void SetTimeStamp(time_t aNewTimeStamp)
Function SetTimeStamp changes the time stamp to aNewTimeStamp updates the reference path...
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:93
LIB_FIELD & GetReferenceField()
Return reference to the reference designator field.
SCH_FIELD * GetField(int aFieldNdx) const
Function GetField returns a field.
const wxString & GetName() const
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:130
PART_SPTR SharedPtr()
SCH_FIELD * AddField(const SCH_FIELD &aField)
Function AddField adds a field to the component.
int SetLibItemName(const UTF8 &aLibItemName, bool aTestForRev=true)
Function SetLibItemName.
Definition: lib_id.cpp:232
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:82
Field Value of part, i.e. "3.3K".
void Init(const wxPoint &pos=wxPoint(0, 0))
int GetFieldCount() const
Function GetFieldCount returns the number of fields in this component.
std::vector< LIB_FIELD > LIB_FIELDS
Definition: lib_field.h:261
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:175
const LIB_ID & GetLibId() const
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:83
AUTOPLACED m_fieldsAutoplaced
indicates status of field autoplacement
Definition: sch_component.h:97
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is...
Definition: sch_component.h:86
void GetFields(LIB_FIELDS &aList)
Function GetFields returns a list of fields withing this part.
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType)
virtual void SetText(const wxString &aText)
Definition: eda_text.h:141
#define IS_MOVED
Item being moved.
Definition: base_struct.h:112
SCH_COMPONENT::SCH_COMPONENT ( const SCH_COMPONENT aComponent)

Copy Constructor clones aComponent into a new 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 parent, i.e. this new object.

Definition at line 198 of file sch_component.cpp.

References GetField(), GetFieldCount(), m_convert, m_currentSheetPath, m_Fields, m_fieldsAutoplaced, m_isDangling, m_lib_id, EDA_ITEM::m_Parent, m_part, m_PathsAndReferences, m_Pos, m_prefix, EDA_ITEM::m_TimeStamp, m_transform, m_unit, EDA_ITEM::SetParent(), and SetTimeStamp().

198  :
199  SCH_ITEM( aComponent )
200 {
201  m_currentSheetPath = NULL;
202  m_Parent = aComponent.m_Parent;
203  m_Pos = aComponent.m_Pos;
204  m_unit = aComponent.m_unit;
205  m_convert = aComponent.m_convert;
206  m_lib_id = aComponent.m_lib_id;
207  m_part = aComponent.m_part;
208 
209  SetTimeStamp( aComponent.m_TimeStamp );
210 
211  m_transform = aComponent.m_transform;
212  m_prefix = aComponent.m_prefix;
214  m_Fields = aComponent.m_Fields;
215 
216  // Re-parent the fields, which before this had aComponent as parent
217  for( int i = 0; i<GetFieldCount(); ++i )
218  {
219  GetField( i )->SetParent( this );
220  }
221 
222  m_isDangling = aComponent.m_isDangling;
224 }
EDA_ITEM * m_Parent
Linked list: Link (parent struct)
Definition: base_struct.h:168
time_t m_TimeStamp
Time stamp used for logical links.
Definition: base_struct.h:169
SCH_FIELDS m_Fields
Variable length list of fields.
Definition: sch_component.h:91
const SCH_SHEET_PATH * m_currentSheetPath
A temporary sheet path is required to generate the correct reference designator string in complex hei...
wxArrayString m_PathsAndReferences
Defines the hierarchical path and reference of the component.
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
std::vector< bool > m_isDangling
One isDangling per pin.
Definition: sch_component.h:95
void SetTimeStamp(time_t aNewTimeStamp)
Function SetTimeStamp changes the time stamp to aNewTimeStamp updates the reference path...
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:93
SCH_FIELD * GetField(int aFieldNdx) const
Function GetField returns a field.
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:213
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:82
int GetFieldCount() const
Function GetFieldCount returns the number of fields in this component.
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:83
AUTOPLACED m_fieldsAutoplaced
indicates status of field autoplacement
Definition: sch_component.h:97
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is...
Definition: sch_component.h:86
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:90
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType)
SCH_COMPONENT::~SCH_COMPONENT ( )
inline

Definition at line 146 of file sch_component.h.

146 { }

Member Function Documentation

SCH_FIELD * SCH_COMPONENT::AddField ( const SCH_FIELD aField)

Function AddField adds a field to the component.

The field is copied as it is put into the component.

Parameters
aFieldA const reference to the SCH_FIELD to add.
Returns
SCH_FIELD* - the newly inserted field.

Definition at line 817 of file sch_component.cpp.

References m_Fields.

Referenced by Init(), Load(), and SCH_COMPONENT().

818 {
819  int newNdx = m_Fields.size();
820 
821  m_Fields.push_back( aField );
822  return &m_Fields[newNdx];
823 }
SCH_FIELDS m_Fields
Variable length list of fields.
Definition: sch_component.h:91
void SCH_COMPONENT::AddHierarchicalReference ( const wxString &  aPath,
const wxString &  aRef,
int  aMulti 
)

Function AddHierarchicalReference adds a full hierarchical reference (path + local reference)

Parameters
aPathHierarchical path (/&ltsheet timestamp&gt/&ltcomponent timestamp&gt like /05678E50/A23EF560)
aRef:local reference like C45, R56
aMultiPart selection, used in multi part per package (0 or 1 for non multi)

Definition at line 514 of file sch_component.cpp.

References m_PathsAndReferences.

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

517 {
518  wxString h_path, h_ref;
519  wxStringTokenizer tokenizer;
520  wxString separators( wxT( " " ) );
521 
522  // Search for an existing path and remove it if found (should not occur)
523  for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
524  {
525  tokenizer.SetString( m_PathsAndReferences[ii], separators );
526  h_path = tokenizer.GetNextToken();
527 
528  if( h_path.Cmp( aPath ) == 0 )
529  {
530  m_PathsAndReferences.RemoveAt( ii );
531  ii--;
532  }
533  }
534 
535  h_ref = aPath + wxT( " " ) + aRef;
536  h_ref << wxT( " " ) << aMulti;
537  m_PathsAndReferences.Add( h_ref );
538 }
wxArrayString m_PathsAndReferences
Defines the hierarchical path and reference of the component.
void SCH_COMPONENT::AutoAutoplaceFields ( SCH_SCREEN aScreen)
inline

Function AutoAutoplaceFields Autoplace fields only if correct to do so automatically.

That is, do not autoplace if fields have been moved by hand.

Parameters
aScreen- the SCH_SCREEN associated with the current instance of the component.

Definition at line 370 of file sch_component.h.

References AUTOPLACED_MANUAL, AutoplaceFields(), and GetFieldsAutoplaced().

Referenced by SCH_EDIT_FRAME::EditComponent(), SCH_EDIT_FRAME::OnOrient(), SCH_EDIT_FRAME::OnRotate(), and SCH_EDIT_FRAME::OnSelectUnit().

371  {
372  if( GetFieldsAutoplaced() )
374  }
AUTOPLACED GetFieldsAutoplaced() const
Function GetFieldsAutoplaced returns whether the fields are autoplaced.
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual)
Function AutoplaceFields Automatically orient all the fields in the component.
void SCH_COMPONENT::AutoplaceFields ( SCH_SCREEN aScreen,
bool  aManual 
)

Function AutoplaceFields Automatically orient all the fields in the component.

Parameters
aScreen- the SCH_SCREEN associated with the current instance of the component. This can be NULL when aManual is false.
aManual- 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.

Definition at line 717 of file autoplace_fields.cpp.

References AUTOPLACED_AUTO, AUTOPLACED_MANUAL, AUTOPLACER::DoAutoplace(), and m_fieldsAutoplaced.

Referenced by AutoAutoplaceFields(), SCH_EDIT_FRAME::Load_Component(), and SCH_EDIT_FRAME::OnAutoplaceFields().

718 {
719  if( aManual )
720  wxASSERT_MSG( aScreen, "A SCH_SCREEN pointer must be given for manual autoplacement" );
721  AUTOPLACER autoplacer( this, aScreen );
722  autoplacer.DoAutoplace( aManual );
724 }
AUTOPLACED m_fieldsAutoplaced
indicates status of field autoplacement
Definition: sch_component.h:97
SCH_ITEM* SCH_ITEM::Back ( ) const
inlineinherited

Definition at line 145 of file sch_item_struct.h.

References EDA_ITEM::Pback.

Referenced by DrawSegment(), SCH_SHEET_PATH::FindPreviousItem(), and SCH_SHEET_LIST::FindPreviousItem().

145 { return static_cast<SCH_ITEM*>( Pback ); }
EDA_ITEM * Pback
previous in linked list
Definition: base_struct.h:165
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
virtual bool SCH_ITEM::CanIncrementLabel ( ) const
inlinevirtualinherited

Reimplemented in SCH_TEXT.

Definition at line 346 of file sch_item_struct.h.

Referenced by SCH_EDIT_FRAME::RepeatDrawItem().

346 { return false; }
void SCH_COMPONENT::ClearAnnotation ( SCH_SHEET_PATH aSheetPath)

Function ClearAnnotation clears exiting component annotation ( i.i IC23 changed to IC? and part reset to 1)

Parameters
aSheetPathSCH_SHEET_PATH value: if NULL remove all annotations, else remove annotation relative to this sheetpath

Definition at line 903 of file sch_component.cpp.

References GetPath(), IsReferenceStringValid(), m_Fields, m_part, m_PathsAndReferences, m_prefix, m_unit, REFERENCE, and EDA_ITEM::SetModified().

Referenced by SCH_SCREEN::ClearAnnotation(), and SCH_EDIT_FRAME::OnCopySchematicItemRequest().

904 {
905  bool keepMulti = false;
906  wxArrayString reference_fields;
907 
908  static const wxChar separators[] = wxT( " " );
909 
910  PART_SPTR part = m_part.lock();
911 
912  if( part && part->UnitsLocked() )
913  keepMulti = true;
914 
915  // Build a reference with no annotation,
916  // i.e. a reference ended by only one '?'
917  wxString defRef = m_prefix;
918 
919  if( IsReferenceStringValid( defRef ) )
920  {
921  while( defRef.Last() == '?' )
922  defRef.RemoveLast();
923  }
924  else
925  { // This is a malformed reference: reinit this reference
926  m_prefix = defRef = wxT("U"); // Set to default ref prefix
927  }
928 
929  defRef.Append( wxT( "?" ) );
930 
931  wxString multi = wxT( "1" );
932 
933  // For components with units locked,
934  // we cannot remove all annotations: part selection must be kept
935  // For all components: if aSheetPath is not NULL,
936  // remove annotation only for the given path
937  if( keepMulti || aSheetPath )
938  {
939  wxString NewHref;
940  wxString path;
941 
942  if( aSheetPath )
943  path = GetPath( aSheetPath );
944 
945  for( unsigned int ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
946  {
947  // Break hierarchical reference in path, ref and multi selection:
948  reference_fields = wxStringTokenize( m_PathsAndReferences[ii], separators );
949 
950  if( aSheetPath == NULL || reference_fields[0].Cmp( path ) == 0 )
951  {
952  if( keepMulti ) // Get and keep part selection
953  multi = reference_fields[2];
954 
955  NewHref = reference_fields[0];
956  NewHref << wxT( " " ) << defRef << wxT( " " ) << multi;
957  m_PathsAndReferences[ii] = NewHref;
958  }
959  }
960  }
961  else
962  {
963  // Clear reference strings, but does not free memory because a new annotation
964  // will reuse it
965  m_PathsAndReferences.Empty();
966  m_unit = 1;
967  }
968 
969  // These 2 changes do not work in complex hierarchy.
970  // When a clear annotation is made, the calling function must call a
971  // UpdateAllScreenReferences for the active sheet.
972  // But this call cannot made here.
973  m_Fields[REFERENCE].SetText( defRef ); //for drawing.
974 
975  SetModified();
976 }
void SetModified()
wxString GetPath(const SCH_SHEET_PATH *sheet) const
SCH_FIELDS m_Fields
Variable length list of fields.
Definition: sch_component.h:91
wxArrayString m_PathsAndReferences
Defines the hierarchical path and reference of the component.
Field Reference of part, i.e. "IC21".
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:93
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:82
static bool IsReferenceStringValid(const wxString &aReferenceString)
Function IsReferenceStringValid (static) Tests for an acceptable reference string An acceptable refer...
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is...
Definition: sch_component.h:86
void EDA_ITEM::ClearBrightened ( )
inlineinherited

Definition at line 233 of file base_struct.h.

References BRIGHTENED, and EDA_ITEM::ClearFlags().

Referenced by SELECTION_TOOL::disambiguationMenu().

233 { ClearFlags( BRIGHTENED ); }
#define BRIGHTENED
item is drawn with a bright contour
Definition: base_struct.h:137
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:254
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 305 of file sch_item_struct.h.

305 { m_connections.clear(); }
EDA_ITEMS m_connections
List of items connected to this item.
void SCH_COMPONENT::ClearFieldsAutoplaced ( )
inline

Function ClearFieldsAutoplaced Set fields autoplaced flag false.

Definition at line 350 of file sch_component.h.

References AUTOPLACED_NO.

Referenced by SCH_EDIT_FRAME::OnRotate(), and SCH_EDIT_FRAME::PrepareMoveItem().

AUTOPLACED m_fieldsAutoplaced
indicates status of field autoplacement
Definition: sch_component.h:97
void EDA_ITEM::ClearFlags ( STATUS_FLAGS  aMask = EDA_ITEM_ALL_FLAGS)
inlineinherited

Definition at line 254 of file base_struct.h.

Referenced by Abort_Edit_Pcb_Text(), Abort_EditEdge(), Abort_Move_ModuleOutline(), Abort_Move_Pad(), Abort_MoveOrCopyModule(), Abort_MoveTrack(), Abort_Zone_Create_Outline(), Abort_Zone_Move_Corner_Or_Outlines(), AbortMoveAndEditTarget(), abortMoveBitmap(), AbortMoveDimensionText(), abortMoveItem(), AbortMoveTextModule(), AbortPinMove(), SCH_SCREEN::addConnectedItemsToBlock(), SCH_EDIT_FRAME::addCurrentItemToList(), PNS_KICAD_IFACE::AddItem(), PCB_EDIT_FRAME::AppendBoardFile(), SCH_EDIT_FRAME::AppendOneEEProject(), PCB_EDIT_FRAME::Begin_DrawSegment(), FOOTPRINT_EDIT_FRAME::Begin_Edge_Module(), PCB_EDIT_FRAME::Begin_Zone(), SCH_EDIT_FRAME::BeginSegment(), PCB_EDIT_FRAME::Block_Delete(), PCB_EDIT_FRAME::Block_Flip(), PCB_EDIT_FRAME::Block_Move(), PCB_EDIT_FRAME::Change_Side_Module(), SCH_SCREEN::ClearAnnotation(), EDA_ITEM::ClearBrightened(), EDA_ITEM::ClearHighlighted(), ClearMarkItems(), clearModuleItemFlags(), EDA_ITEM::ClearSelected(), SCH_EDIT_FRAME::ConvertPart(), SCH_EDIT_FRAME::copyBlockItems(), CopyMarkedItems(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions(), LIB_PART::CopySelectedItems(), MWAVE::CreateMicrowaveInductor(), FOOTPRINT_EDIT_FRAME::CreateTextModule(), PCB_EDIT_FRAME::Delete_LastCreatedCorner(), PCB_EDIT_FRAME::Delete_Segment_Edge(), LIB_PART::DeleteSelectedItems(), DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN(), PCB_EDIT_FRAME::EditDimension(), PCB_EDIT_FRAME::End_Edge(), FOOTPRINT_EDIT_FRAME::End_Edge_Module(), PCB_EDIT_FRAME::End_Move_Zone_Corner_Or_Outlines(), PCB_EDIT_FRAME::End_Zone(), SCH_EDIT_FRAME::EndSegment(), PCB_EDIT_FRAME::Exchange_Module(), ExitSheet(), SCH_SCREEN::GetConnection(), PCB_BASE_FRAME::GlobalChange_PadSettings(), PCB_BASE_FRAME::Import_Pad_Settings(), SCH_JUNCTION::IsSelectStateChanged(), SCH_NO_CONNECT::IsSelectStateChanged(), SCH_MARKER::IsSelectStateChanged(), SCH_BUS_ENTRY_BASE::IsSelectStateChanged(), SCH_LINE::IsSelectStateChanged(), SCH_BITMAP::IsSelectStateChanged(), SCH_TEXT::IsSelectStateChanged(), IsSelectStateChanged(), SCH_SHEET::IsSelectStateChanged(), FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD(), MarkItemsInBloc(), MirrorX(), MirrorY(), moveBitmap(), FOOTPRINT_EDIT_FRAME::OnEditItemRequest(), LIB_EDIT_FRAME::OnEditPin(), FOOTPRINT_EDIT_FRAME::OnLeftClick(), SCH_EDIT_FRAME::OnLeftClick(), PCB_EDIT_FRAME::OnLeftClick(), LIB_EDIT_FRAME::OnRotateItem(), SCH_EDIT_FRAME::OnSelectUnit(), SCH_FIELD::Place(), PCB_EDIT_FRAME::Place_DrawItem(), FOOTPRINT_EDIT_FRAME::Place_EdgeMod(), PCB_EDIT_FRAME::Place_Texte_Pcb(), PCB_EDIT_FRAME::PlaceDimensionText(), PCB_EDIT_FRAME::PlaceDraggedOrMovedTrackSegment(), PCB_BASE_FRAME::PlaceModule(), PCB_BASE_FRAME::PlacePad(), PCB_EDIT_FRAME::PlaceTarget(), DRAWING_TOOL::PlaceText(), PCB_BASE_FRAME::PlaceTexteModule(), FOOTPRINT_EDIT_FRAME::Process_Special_Functions(), LIB_EDIT_FRAME::Process_Special_Functions(), EDIT_TOOL::Properties(), BOARD_COMMIT::Push(), PCB_BASE_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_FRAME::RepeatDrawItem(), LIB_EDIT_FRAME::RepeatPinItem(), BOARD_COMMIT::Revert(), PCB_BASE_FRAME::Rotate_Module(), RotateListOfItems(), LIB_PIN::Save(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint(), SCH_EDIT_FRAME::SetRepeatItem(), PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope(), PCB_EDIT_FRAME::StartMoveModule(), PCB_EDIT_FRAME::StartMoveOneNodeOrSegment(), and DIALOG_PAD_PROPERTIES::TransferDataFromWindow().

254 { m_Flags &= ~aMask; }
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:175
void EDA_ITEM::ClearHighlighted ( )
inlineinherited

Definition at line 232 of file base_struct.h.

References EDA_ITEM::ClearFlags(), and HIGHLIGHTED.

232 { ClearFlags( HIGHLIGHTED ); }
#define HIGHLIGHTED
item is drawn in normal colors, when the rest is darkened
Definition: base_struct.h:136
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:254
void EDA_ITEM::ClearSelected ( )
inlineinherited

Definition at line 231 of file base_struct.h.

References EDA_ITEM::ClearFlags(), and SELECTED.

Referenced by POINT_EDITOR::addCorner(), GAL_ARRAY_CREATOR::prePushAction(), SELECTION_TOOL::unselectVisually(), and PCB_EDITOR_CONTROL::ZoneDuplicate().

231 { ClearFlags( SELECTED ); }
#define SELECTED
Definition: base_struct.h:120
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:254
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 256 of file sch_component.cpp.

References SCH_COMPONENT().

257 {
258  return new SCH_COMPONENT( *this );
259 }
SCH_COMPONENT(const wxPoint &pos=wxPoint(0, 0), SCH_ITEM *aParent=NULL)
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 2191 of file sch_component.cpp.

References GetConnectionPoints().

2192 {
2193  std::vector< wxPoint > pts;
2194 
2195  GetConnectionPoints( pts );
2196 
2197  for( size_t i = 0; i < pts.size(); i++ )
2198  {
2199  if( pts[i] == aPosition )
2200  return true;
2201  }
2202 
2203  return false;
2204 }
void GetConnectionPoints(std::vector< wxPoint > &aPoints) const override
Function GetConnectionPoints add all the connection points for this item to aPoints.
void SCH_COMPONENT::Draw ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aOffset,
GR_DRAWMODE  aDrawMode,
COLOR4D  aColor = COLOR4D::UNSPECIFIED 
)
inlineoverridevirtual

Virtual function, from the base class SCH_ITEM::Draw.

Implements SCH_ITEM.

Definition at line 398 of file sch_component.h.

Referenced by SCH_EDIT_FRAME::ConvertPart(), SCH_EDIT_FRAME::Load_Component(), moveItemWithMouseCursor(), SCH_EDIT_FRAME::OnCopySchematicItemRequest(), SCH_EDIT_FRAME::OnSelectUnit(), and DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp().

400  {
401  Draw( aPanel, aDC, aOffset, aDrawMode, aColor, true );
402  }
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
Virtual function, from the base class SCH_ITEM::Draw.
void SCH_COMPONENT::Draw ( EDA_DRAW_PANEL aPanel,
wxDC *  aDC,
const wxPoint aOffset,
GR_DRAWMODE  aDrawMode,
COLOR4D  aColor,
bool  aDrawPinText 
)

Function Draw, specific to components.

Draw a component, with or without pin texts.

Parameters
aPanelDrawPanel to use (can be null) mainly used for clipping purposes.
aDCDevice Context (can be null)
aOffsetdrawing Offset (usually wxPoint(0,0), but can be different when moving an object)
aDrawModeGR_OR, GR_XOR, ...
aColorCOLOR4D::UNSPECIFIED to use the normal body item color, or use this color if >= 0
aDrawPinText= true to draw pin texts, false to draw only the pin shape usually false to draw a component when moving it, and true otherwise.

Definition at line 445 of file sch_component.cpp.

References boundingBox(), BROWN, PART_DRAW_OPTIONS::Default(), SCH_FIELD::Draw(), LIB_PART::Draw(), dummy(), SCH_FIELD::GetBoundingBox(), GetBoundingBox(), EDA_DRAW_PANEL::GetClipBox(), BASE_SCREEN::GetCurItem(), GetField(), GetFieldCount(), EDA_DRAW_PANEL::GetScreen(), GRRect(), EDA_DRAW_PANEL::IsMouseCaptured(), EDA_ITEM::IsMoving(), EDA_TEXT::IsVisible(), m_convert, m_isDangling, m_part, m_Pos, m_transform, m_unit, REFERENCE, and VALUE.

448 {
449  auto opts = PART_DRAW_OPTIONS::Default();
450  opts.draw_mode = aDrawMode;
451  opts.color = aColor;
452  opts.transform = m_transform;
453  opts.show_pin_text = aDrawPinText;
454  opts.draw_visible_fields = false;
455  opts.draw_hidden_fields = false;
456 
457  if( PART_SPTR part = m_part.lock() )
458  {
459  // Draw pin targets if part is being dragged
460  bool dragging = aPanel->GetScreen()->GetCurItem() == this && aPanel->IsMouseCaptured();
461 
462  if( !dragging )
463  {
464  opts.dangling = m_isDangling;
465  }
466 
467  part->Draw( aPanel, aDC, m_Pos + aOffset, m_unit, m_convert, opts );
468  }
469  else // Use dummy() part if the actual cannot be found.
470  {
471  dummy()->Draw( aPanel, aDC, m_Pos + aOffset, 0, 0, opts );
472  }
473 
474  SCH_FIELD* field = GetField( REFERENCE );
475 
476  if( field->IsVisible() && !field->IsMoving() )
477  {
478  field->Draw( aPanel, aDC, aOffset, aDrawMode );
479  }
480 
481  for( int ii = VALUE; ii < GetFieldCount(); ii++ )
482  {
483  field = GetField( ii );
484 
485  if( field->IsMoving() )
486  continue;
487 
488  field->Draw( aPanel, aDC, aOffset, aDrawMode );
489  }
490 
491 #if 0
492  // Only for testing purposes, draw the component bounding box
493  {
495  GRRect( aPanel->GetClipBox(), aDC, boundingBox, 0, BROWN );
496 #if 1
497  if( GetField( REFERENCE )->IsVisible() )
498  {
499  boundingBox = GetField( REFERENCE )->GetBoundingBox();
500  GRRect( aPanel->GetClipBox(), aDC, boundingBox, 0, BROWN );
501  }
502 
503  if( GetField( VALUE )->IsVisible() )
504  {
505  boundingBox = GetField( VALUE )->GetBoundingBox();
506  GRRect( aPanel->GetClipBox(), aDC, boundingBox, 0, BROWN );
507  }
508 #endif
509  }
510 #endif
511 }
Class SCH_FIELD instances are attached to a component and provide a place for the component's value...
Definition: sch_field.h:56
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDc, const wxPoint &aOffset, int aMulti, int aConvert, const PART_DRAW_OPTIONS &aOpts)
Draw part.
bool IsMoving() const
Definition: base_struct.h:218
EDA_ITEM * GetCurItem() const
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
Definition: sch_field.cpp:118
std::vector< bool > m_isDangling
One isDangling per pin.
Definition: sch_component.h:95
Field Reference of part, i.e. "IC21".
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
BOX2I boundingBox(T aObject)
boundingBox template method
Definition: shape_index.h:59
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1077
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:93
SCH_FIELD * GetField(int aFieldNdx) const
Function GetField returns a field.
bool IsMouseCaptured() const
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
EDA_RECT * GetClipBox()
static PART_DRAW_OPTIONS Default()
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:82
Field Value of part, i.e. "3.3K".
int GetFieldCount() const
Function GetFieldCount returns the number of fields in this component.
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_field.cpp:251
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
bool IsVisible() const
Definition: eda_text.h:176
Class EDA_RECT handles the component boundary box.
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:188
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:83
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:90
Definition: colors.h:62
SCH_FIELD * SCH_COMPONENT::FindField ( const wxString &  aFieldName,
bool  aIncludeDefaultFields = true 
)

Function FindField searches for SCH_FIELD with aFieldName and returns it if found, else NULL.

Definition at line 830 of file sch_component.cpp.

References m_Fields, and MANDATORY_FIELDS.

Referenced by NETLIST_EXPORTER_PSPICE::GetSpiceField(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), and SCH_COMPONENT().

831 {
832  unsigned start = aIncludeDefaultFields ? 0 : MANDATORY_FIELDS;
833 
834  for( unsigned i = start; i<m_Fields.size(); ++i )
835  {
836  if( aFieldName == m_Fields[i].GetName( false ) )
837  {
838  return &m_Fields[i];
839  }
840  }
841 
842  return NULL;
843 }
SCH_FIELDS m_Fields
Variable length list of fields.
Definition: sch_component.h:91
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors...
std::string SCH_ITEM::FormatAngle ( double  aAngle)
staticinherited

Function FormatAngle converts aAngle from board units to a string appropriate for writing to file.

Note
Internal angles for board items can be either degrees or tenths of degree on how KiCad is built.
Parameters
aAngleA angle value to convert.
Returns
A std::string object containing the converted angle.

Definition at line 131 of file sch_item_struct.cpp.

132 {
133  char temp[50];
134  int len;
135 
136  len = snprintf( temp, sizeof(temp), "%.10g", aAngle / 10.0 );
137 
138  return std::string( temp, len );
139 }
std::string SCH_ITEM::FormatInternalUnits ( int  aValue)
staticinherited

Function FormatInternalUnits converts aValue from schematic internal units to a string appropriate for writing to file.

Parameters
aValueA coordinate value to convert.
Returns
A std::string object containing the converted value.

Definition at line 107 of file sch_item_struct.cpp.

Referenced by SCH_ITEM::FormatInternalUnits().

108 {
109  char buf[50];
110  double engUnits = aValue;
111  int len;
112 
113  if( engUnits != 0.0 && fabs( engUnits ) <= 0.0001 )
114  {
115  len = snprintf( buf, sizeof(buf), "%.10f", engUnits );
116 
117  while( --len > 0 && buf[len] == '0' )
118  buf[len] = '\0';
119 
120  ++len;
121  }
122  else
123  {
124  len = snprintf( buf, sizeof(buf), "%.10g", engUnits );
125  }
126 
127  return std::string( buf, len );
128 }
std::string SCH_ITEM::FormatInternalUnits ( const wxPoint aPoint)
staticinherited

Definition at line 142 of file sch_item_struct.cpp.

References SCH_ITEM::FormatInternalUnits(), wxPoint::x, and wxPoint::y.

143 {
144  return FormatInternalUnits( aPoint.x ) + " " + FormatInternalUnits( aPoint.y );
145 }
static std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from schematic internal units to a string appropriate fo...
std::string SCH_ITEM::FormatInternalUnits ( const wxSize &  aSize)
staticinherited

Definition at line 148 of file sch_item_struct.cpp.

References SCH_ITEM::FormatInternalUnits().

149 {
150  return FormatInternalUnits( aSize.GetWidth() ) + " " + FormatInternalUnits( aSize.GetHeight() );
151 }
static std::string FormatInternalUnits(int aValue)
Function FormatInternalUnits converts aValue from schematic internal units to a string appropriate fo...
wxString SCH_COMPONENT::GetAliasDescription ( ) const

Return information about the aliased parts.

Function GetAliasDescription Return the description text for the given part alias.

Definition at line 300 of file sch_component.cpp.

References LIB_ALIAS::GetDescription(), GetLibId(), and m_part.

301 {
302  if( PART_SPTR part = m_part.lock() )
303  {
304  LIB_ALIAS* alias = part->GetAlias( GetLibId().GetLibItemName() );
305 
306  if( !alias )
307  return wxEmptyString;
308 
309  return alias->GetDescription();
310  }
311 
312  return wxEmptyString;
313 }
Part library alias object definition.
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:93
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
wxString GetDescription() const
const LIB_ID & GetLibId() const
wxString SCH_COMPONENT::GetAliasDocumentation ( ) const

Function GetAliasDocumentation Return the documentation text for the given part alias.

Definition at line 319 of file sch_component.cpp.

References LIB_ALIAS::GetDocFileName(), GetLibId(), and m_part.

320 {
321  if( PART_SPTR part = m_part.lock() )
322  {
323  LIB_ALIAS* alias = part->GetAlias( GetLibId().GetLibItemName() );
324 
325  if( !alias )
326  return wxEmptyString;
327 
328  return alias->GetDocFileName();
329  }
330 
331  return wxEmptyString;
332 }
Part library alias object definition.
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:93
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
wxString GetDocFileName() const
const LIB_ID & GetLibId() const
EDA_RECT SCH_COMPONENT::GetBodyBoundingBox ( ) const

Function GetBodyBoundingBox Return a bounding box for the component body but not the fields.

Definition at line 1618 of file sch_component.cpp.

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

1619 {
1620  EDA_RECT bBox;
1621 
1622  if( PART_SPTR part = m_part.lock() )
1623  {
1624  bBox = part->GetBodyBoundingBox( m_unit, m_convert );
1625  }
1626  else
1627  {
1628  bBox = dummy()->GetBodyBoundingBox( m_unit, m_convert );
1629  }
1630 
1631  int x0 = bBox.GetX();
1632  int xm = bBox.GetRight();
1633 
1634  // We must reverse Y values, because matrix orientation
1635  // suppose Y axis normal for the library items coordinates,
1636  // m_transform reverse Y values, but bBox is already reversed!
1637  int y0 = -bBox.GetY();
1638  int ym = -bBox.GetBottom();
1639 
1640  // Compute the real Boundary box (rotated, mirrored ...)
1641  int x1 = m_transform.x1 * x0 + m_transform.y1 * y0;
1642  int y1 = m_transform.x2 * x0 + m_transform.y2 * y0;
1643  int x2 = m_transform.x1 * xm + m_transform.y1 * ym;
1644  int y2 = m_transform.x2 * xm + m_transform.y2 * ym;
1645 
1646  // H and W must be > 0:
1647  if( x2 < x1 )
1648  std::swap( x2, x1 );
1649 
1650  if( y2 < y1 )
1651  std::swap( y2, y1 );
1652 
1653  bBox.SetX( x1 );
1654  bBox.SetY( y1 );
1655  bBox.SetWidth( x2 - x1 );
1656  bBox.SetHeight( y2 - y1 );
1657 
1658  bBox.Offset( m_Pos );
1659  return bBox;
1660 }
void Offset(int dx, int dy)
int y2
Definition: transform.h:51
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
const EDA_RECT GetBodyBoundingBox(int aUnit, int aConvert) const
Function GetBodyBoundingBox.
int x2
Definition: transform.h:50
int x1
Definition: transform.h:48
int y1
Definition: transform.h:49
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:93
void SetHeight(int val)
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
void SetX(int val)
int GetBottom() const
int GetRight() const
void SetWidth(int val)
void SetY(int val)
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:82
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
Class EDA_RECT handles the component boundary box.
int GetX() const
int GetY() const
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:83
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:90
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 1663 of file sch_component.cpp.

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

Referenced by Draw(), and IsSelectStateChanged().

1664 {
1665  EDA_RECT bbox = GetBodyBoundingBox();
1666 
1667  for( size_t i = 0; i < m_Fields.size(); i++ )
1668  {
1669  bbox.Merge( m_Fields[i].GetBoundingBox() );
1670  }
1671 
1672  return bbox;
1673 }
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.
Definition: sch_component.h:91
EDA_RECT GetBodyBoundingBox() const
Function GetBodyBoundingBox Return a bounding box for the component body but not the fields...
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Class EDA_RECT handles the component boundary box.
wxString SCH_COMPONENT::GetClass ( ) const
inlineoverridevirtual

Function GetClass returns the class name.

Returns
wxString

Reimplemented from SCH_ITEM.

Definition at line 148 of file sch_component.h.

Referenced by operator=().

149  {
150  return wxT( "SCH_COMPONENT" );
151  }
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 1918 of file sch_component.cpp.

References FROM_UTF8(), GetLibId(), LIB_PIN_T, m_convert, m_part, m_Pos, m_transform, m_unit, and TRANSFORM::TransformCoordinate().

Referenced by doIsConnected().

1919 {
1920  if( PART_SPTR part = m_part.lock() )
1921  {
1922  for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
1923  {
1924  wxCHECK_RET( pin->Type() == LIB_PIN_T,
1925  wxT( "GetNextPin() did not return a pin object. Bad programmer!" ) );
1926 
1927  // Skip items not used for this part.
1928  if( m_unit && pin->GetUnit() && ( pin->GetUnit() != m_unit ) )
1929  continue;
1930 
1931  if( m_convert && pin->GetConvert() && ( pin->GetConvert() != m_convert ) )
1932  continue;
1933 
1934  // Calculate the pin position relative to the component position and orientation.
1935  aPoints.push_back( m_transform.TransformCoordinate( pin->GetPosition() ) + m_Pos );
1936  }
1937  }
1938  else
1939  {
1940  wxCHECK_RET( 0,
1941  wxT( "Cannot add connection points to list. Cannot find component <" ) +
1942  FROM_UTF8( GetLibId().GetLibItemName() ) +
1943  wxT( "> in any of the loaded libraries." ) );
1944  }
1945 }
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:41
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:93
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:82
const LIB_ID & GetLibId() const
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:83
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:90
int SCH_COMPONENT::GetConvert ( ) const
inline
LIB_ITEM * SCH_COMPONENT::GetDrawItem ( const wxPoint aPosition,
KICAD_T  aType = TYPE_NOT_INIT 
)

Function GetDrawItem().

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

Parameters
aPosition- Schematic position of the component library object.
aType- Type of component library object to find or any if set to TYPE_NOT_INIT.
Returns
A pointer to the component library object if found, otherwise NULL.

Definition at line 1948 of file sch_component.cpp.

References m_convert, m_part, m_Pos, m_transform, and m_unit.

Referenced by SCH_SCREEN::GetPin().

1949 {
1950  if( PART_SPTR part = m_part.lock() )
1951  {
1952  // Calculate the position relative to the component.
1953  wxPoint libPosition = aPosition - m_Pos;
1954 
1955  return part->LocateDrawItem( m_unit, m_convert, aType, libPosition, m_transform );
1956  }
1957 
1958  return NULL;
1959 }
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:93
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:82
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:83
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:90
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 1790 of file sch_component.cpp.

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

1791 {
1792  if( PART_SPTR part = m_part.lock() )
1793  {
1794  for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
1795  {
1796  wxASSERT( pin->Type() == LIB_PIN_T );
1797 
1798  if( pin->GetUnit() && m_unit && ( m_unit != pin->GetUnit() ) )
1799  continue;
1800 
1801  if( pin->GetConvert() && m_convert && ( m_convert != pin->GetConvert() ) )
1802  continue;
1803 
1804  DANGLING_END_ITEM item( PIN_END, pin, GetPinPhysicalPosition( pin ) );
1805  aItemList.push_back( item );
1806  }
1807  }
1808 }
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:93
wxPoint GetPinPhysicalPosition(LIB_PIN *Pin)
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:82
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:83
Class DANGLING_END_ITEM is a helper class used to store the state of schematic items that can be conn...
SCH_FIELD * SCH_COMPONENT::GetField ( int  aFieldNdx) const

Function GetField returns a field.

Parameters
aFieldNdxAn index into the array of fields, not a field id.
Returns
SCH_FIELD* - the field value or NULL if does not exist

Definition at line 757 of file sch_component.cpp.

References m_Fields.

Referenced by NETLIST_EXPORTER_GENERIC::addComponentFields(), AddMenusForComponent(), SIM_PLOT_FRAME::AddTuner(), SCH_EDIT_FRAME::backAnnotateFootprints(), SCH_SHEET::ComponentCount(), Draw(), SCH_EDIT_FRAME::FindComponentAndItem(), FormatProbeItem(), SCH_SCREEN::GetItem(), LIB_PIN::GetMsgPanelInfo(), GetMsgPanelInfo(), GetRef(), GetSelectMenuText(), NETLIST_EXPORTER_PSPICE::GetSpiceFieldDefVal(), IsInNetlist(), Load(), SCH_EDIT_FRAME::Load_Component(), MirrorX(), MirrorY(), Move(), TUNER_SLIDER::onSave(), operator=(), operator==(), SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile(), Rotate(), Save(), SCH_LEGACY_PLUGIN::saveComponent(), SCH_COMPONENT(), SCH_REFERENCE::SCH_REFERENCE(), SCH_SCREEN::SetComponentFootprint(), BOM_TABLE_MODEL::SetComponents(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp(), SetRef(), SCH_REFERENCE_LIST::sortByReferenceOnly(), SwapData(), TUNER_SLIDER::TUNER_SLIDER(), SCH_SHEET_PATH::UpdateAllScreenReferences(), Visit(), NETLIST_EXPORTER_ORCADPCB2::WriteNetlist(), and NETLIST_EXPORTER_CADSTAR::WriteNetlist().

758 {
759  const SCH_FIELD* field;
760 
761  if( (unsigned) aFieldNdx < m_Fields.size() )
762  field = &m_Fields[aFieldNdx];
763  else
764  field = NULL;
765 
766  wxASSERT( field );
767 
768  // use cast to remove const-ness
769  return (SCH_FIELD*) field;
770 }
Class SCH_FIELD instances are attached to a component and provide a place for the component's value...
Definition: sch_field.h:56
SCH_FIELDS m_Fields
Variable length list of fields.
Definition: sch_component.h:91
int SCH_COMPONENT::GetFieldCount ( ) const
inline

Function GetFieldCount returns the number of fields in this component.

Definition at line 338 of file sch_component.h.

Referenced by NETLIST_EXPORTER_GENERIC::addComponentFields(), Draw(), SCH_SCREEN::GetItem(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers(), Load(), MirrorX(), MirrorY(), Move(), operator=(), operator==(), Rotate(), SCH_LEGACY_PLUGIN::saveComponent(), SCH_COMPONENT(), SwapData(), and Visit().

338 { return (int)m_Fields.size(); }
SCH_FIELDS m_Fields
Variable length list of fields.
Definition: sch_component.h:91
void SCH_COMPONENT::GetFields ( std::vector< SCH_FIELD * > &  aVector,
bool  aVisibleOnly 
)

Function GetFields populates a std::vector with SCH_FIELDs.

Parameters
aVector- vector to populate.
aVisibleOnly- if true, only get fields that are visible and contain text.

Definition at line 807 of file sch_component.cpp.

References m_Fields.

Referenced by BOM_TABLE_MODEL::AddComponentFields(), and AUTOPLACER::AUTOPLACER().

808 {
809  for( SCH_FIELD& each_field : m_Fields )
810  {
811  if( !aVisibleOnly || ( each_field.IsVisible() && !each_field.IsVoid() ) )
812  aVector.push_back( &each_field );
813  }
814 }
Class SCH_FIELD instances are attached to a component and provide a place for the component's value...
Definition: sch_field.h:56
SCH_FIELDS m_Fields
Variable length list of fields.
Definition: sch_component.h:91
AUTOPLACED SCH_COMPONENT::GetFieldsAutoplaced ( ) const
inline

Function GetFieldsAutoplaced returns whether the fields are autoplaced.

Definition at line 344 of file sch_component.h.

References m_fieldsAutoplaced.

Referenced by AutoAutoplaceFields().

344 { return m_fieldsAutoplaced; }
AUTOPLACED m_fieldsAutoplaced
indicates status of field autoplacement
Definition: sch_component.h:97
wxString SCH_COMPONENT::GetFieldText ( wxString  aFieldName,
bool  aIncludeDefaultFields = true 
) const

Returns text associated with a given field (if such a field exists) is the name of the field.

Definition at line 772 of file sch_component.cpp.

References TEMPLATE_FIELDNAME::GetDefaultFieldName(), m_Fields, and MANDATORY_FIELDS.

773 {
774  // Field name for comparison
775  wxString cmpFieldName;
776 
777  if( aIncludeDefaultFields )
778  {
779 
780  // Default field names
781  for ( unsigned int i=0; i<MANDATORY_FIELDS; i++)
782  {
783  cmpFieldName = TEMPLATE_FIELDNAME::GetDefaultFieldName( i );
784 
785  if( cmpFieldName.Cmp( aFieldName ) == 0 )
786  {
787  return m_Fields[i].GetText();
788  }
789  }
790  }
791 
792  // Search custom fields
793  for( unsigned int ii=MANDATORY_FIELDS; ii<m_Fields.size(); ii++ )
794  {
795  cmpFieldName = m_Fields[ii].GetName();
796 
797  if( cmpFieldName.Cmp( aFieldName ) == 0 )
798  {
799  return m_Fields[ii].GetText();
800  }
801  }
802 
803  return wxEmptyString;
804 }
SCH_FIELDS m_Fields
Variable length list of fields.
Definition: sch_component.h:91
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...
STATUS_FLAGS EDA_ITEM::GetFlags ( ) const
inlineinherited

Definition at line 255 of file base_struct.h.

References EDA_ITEM::m_Flags.

Referenced by AbortMoveAndEditTarget(), SCH_SCREEN::addConnectedItemsToBlock(), AddMenusForBitmap(), AddMenusForBusEntry(), AddMenusForComponent(), AddMenusForComponentField(), AddMenusForEditComponent(), AddMenusForGLabel(), AddMenusForHierchicalSheet(), AddMenusForHLabel(), AddMenusForLabel(), AddMenusForSheetPin(), AddMenusForText(), SCH_EDIT_FRAME::BeginSegment(), SCH_EDIT_FRAME::ChangeTextOrient(), Collect_TrackSegmentsToDrag(), SCH_EDIT_FRAME::ConvertPart(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions(), LIB_EDIT_FRAME::CreatePin(), PCB_EDIT_FRAME::createPopUpMenuForFootprints(), PCB_EDIT_FRAME::createPopUpMenuForFpPads(), PCB_EDIT_FRAME::createPopUpMenuForFpTexts(), PCB_EDIT_FRAME::createPopUpMenuForTexts(), PCB_EDIT_FRAME::createPopupMenuForTracks(), PCB_EDIT_FRAME::createPopUpMenuForZones(), PCB_EDIT_FRAME::Delete_Segment_Edge(), BOARD::Draw(), PCB_EDIT_FRAME::Edit_TrackSegm_Width(), SCH_EDIT_FRAME::EditComponentFieldText(), SCH_EDIT_FRAME::EditImage(), PCB_EDIT_FRAME::FlipTextePcb(), LIB_VIEW_FRAME::GeneralControl(), SCH_EDIT_FRAME::GeneralControl(), SCH_SCREEN::GetConnection(), InitialiseDragParameters(), LIB_EDIT_FRAME::LoadOneSymbol(), Magnetize(), SCH_EDIT_FRAME::MirrorImage(), SCH_EDIT_FRAME::MirrorSheet(), moveBitmap(), SCH_EDIT_FRAME::OnAutoplaceFields(), SCH_EDIT_FRAME::OnConvertTextType(), SCH_EDIT_FRAME::OnCopySchematicItemRequest(), SCH_EDIT_FRAME::OnDragItem(), SCH_EDIT_FRAME::OnEditItem(), LIB_EDIT_FRAME::OnEditPin(), FOOTPRINT_EDIT_FRAME::OnHotKey(), SCH_EDIT_FRAME::OnHotKey(), PCB_EDIT_FRAME::OnHotKey(), PCB_EDIT_FRAME::OnHotkeyBeginRoute(), PCB_EDIT_FRAME::OnHotkeyCopyItem(), PCB_EDIT_FRAME::OnHotkeyDeleteItem(), PCB_EDIT_FRAME::OnHotkeyDuplicateOrArrayItem(), PCB_EDIT_FRAME::OnHotkeyEditItem(), PCB_EDIT_FRAME::OnHotkeyFlipItem(), PCB_EDIT_FRAME::OnHotkeyMoveItem(), PCB_EDIT_FRAME::OnHotkeyPlaceItem(), PCB_EDIT_FRAME::OnHotkeyRotateItem(), FOOTPRINT_EDIT_FRAME::OnLeftClick(), SCH_EDIT_FRAME::OnLeftClick(), PCB_EDIT_FRAME::OnLeftClick(), FOOTPRINT_EDIT_FRAME::OnLeftDClick(), SCH_EDIT_FRAME::OnLeftDClick(), PCB_EDIT_FRAME::OnLeftDClick(), SCH_EDIT_FRAME::OnMoveItem(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick(), TARGET_PROPERTIES_DIALOG_EDITOR::OnOkClick(), SCH_EDIT_FRAME::OnOpenLibraryEditor(), SCH_EDIT_FRAME::OnOrient(), FOOTPRINT_EDIT_FRAME::OnRightClick(), GERBVIEW_FRAME::OnRightClick(), SCH_EDIT_FRAME::OnRightClick(), PCB_EDIT_FRAME::OnRightClick(), SCH_EDIT_FRAME::OnRotate(), SCH_EDIT_FRAME::OnSelectUnit(), PCB_EDIT_FRAME::PlaceTarget(), FOOTPRINT_EDIT_FRAME::PrepareItemForHotkey(), LIB_EDIT_FRAME::Process_Special_Functions(), EDIT_TOOL::Properties(), PCB_BASE_FRAME::Rotate_Module(), PCB_EDIT_FRAME::Rotate_Texte_Pcb(), SCH_EDIT_FRAME::RotateField(), SCH_EDIT_FRAME::RotateHierarchicalSheet(), SCH_EDIT_FRAME::RotateImage(), PCB_BASE_FRAME::RotateTextModule(), SCH_EDIT_FRAME::SaveCopyInUndoList(), SCH_SCREEN::SelectBlockItems(), SCH_EDIT_FRAME::SetBusEntryShape(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp(), Show_Drag_Track_Segment_With_Cte_Slope(), Show_MoveNode(), PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope(), PCB_EDIT_FRAME::StartMoveOneNodeOrSegment(), DIALOG_LABEL_EDITOR::TextPropertiesAccept(), DIALOG_PCB_TEXT_PROPERTIES::TransferDataFromWindow(), and DIALOG_MODULE_BOARD_EDITOR::TransferDataFromWindow().

255 { return m_Flags; }
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:175
DHEAD* EDA_ITEM::GetList ( ) const
inlineinherited
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 1719 of file sch_component.cpp.

1720 {
1721  return add_component_xpm;
1722 }
void SCH_COMPONENT::GetMsgPanelInfo ( 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 1676 of file sch_component.cpp.

References BROWN, DARKCYAN, DARKRED, FOOTPRINT, FROM_UTF8(), LIB_ALIAS::GetDescription(), GetField(), LIB_ALIAS::GetKeyWords(), GetLibId(), LIB_ALIAS::GetLibraryName(), LIB_ALIAS::GetName(), GetRef(), EDA_TEXT::GetShownText(), SCH_FIELD::IsVoid(), m_currentSheetPath, m_part, and VALUE.

Referenced by SCH_EDIT_FRAME::Load_Component().

1677 {
1678  // part and alias can differ if alias is not the root
1679  if( PART_SPTR part = m_part.lock() )
1680  {
1681  LIB_ALIAS* alias = part->GetAlias( FROM_UTF8( GetLibId().GetLibItemName() ) );
1682 
1683  if( !alias )
1684  return;
1685 
1686  if( m_currentSheetPath )
1687  aList.push_back( MSG_PANEL_ITEM( _( "Reference" ),
1689  DARKCYAN ) );
1690 
1691  wxString msg = part->IsPower() ? _( "Power symbol" ) : _( "Value" );
1692 
1693  aList.push_back( MSG_PANEL_ITEM( msg, GetField( VALUE )->GetShownText(), DARKCYAN ) );
1694 
1695  // Display component reference in library and library
1696  aList.push_back( MSG_PANEL_ITEM( _( "Component" ), FROM_UTF8( GetLibId().GetLibItemName() ),
1697  BROWN ) );
1698 
1699  if( alias->GetName() != part->GetName() )
1700  aList.push_back( MSG_PANEL_ITEM( _( "Alias of" ), part->GetName(), BROWN ) );
1701 
1702  aList.push_back( MSG_PANEL_ITEM( _( "Library" ), alias->GetLibraryName(), BROWN ) );
1703 
1704  // Display the current associated footprint, if exists.
1705  if( !GetField( FOOTPRINT )->IsVoid() )
1706  msg = GetField( FOOTPRINT )->GetShownText();
1707  else
1708  msg = _( "<Unknown>" );
1709 
1710  aList.push_back( MSG_PANEL_ITEM( _( "Footprint" ), msg, DARKRED ) );
1711 
1712  // Display description of the component, and keywords found in lib
1713  aList.push_back( MSG_PANEL_ITEM( _( "Description" ), alias->GetDescription(), DARKCYAN ) );
1714  aList.push_back( MSG_PANEL_ITEM( _( "Key Words" ), alias->GetKeyWords(), DARKCYAN ) );
1715  }
1716 }
Part library alias object definition.
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
const SCH_SHEET_PATH * m_currentSheetPath
A temporary sheet path is required to generate the correct reference designator string in complex hei...
const wxString GetLibraryName()
bool IsVoid() const
Function IsVoid returns true if the field is either empty or holds "~".
Definition: sch_field.h:116
Field Name Module PCB, i.e. "16DIP300".
Definition: colors.h:54
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:135
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:93
SCH_FIELD * GetField(int aFieldNdx) const
Function GetField returns a field.
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
wxString GetDescription() const
Field Value of part, i.e. "3.3K".
const wxString GetRef(const SCH_SHEET_PATH *sheet)
Function GetRef returns the reference, for the given sheet path.
const wxString & GetName() const
const LIB_ID & GetLibId() const
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
wxString GetKeyWords() const
Definition: colors.h:62
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 2037 of file sch_component.cpp.

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, NETLIST_OBJECT::m_PinNum, m_Pos, NETLIST_OBJECT::m_SheetPath, NETLIST_OBJECT::m_SheetPathInclude, NETLIST_OBJECT::m_Start, NETLIST_OBJECT::m_Type, NET_PIN, NET_PINLABEL, and TRANSFORM::TransformCoordinate().

2039 {
2040  if( PART_SPTR part = m_part.lock() )
2041  {
2042  for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
2043  {
2044  wxASSERT( pin->Type() == LIB_PIN_T );
2045 
2046  if( pin->GetUnit() && ( pin->GetUnit() != GetUnitSelection( aSheetPath ) ) )
2047  continue;
2048 
2049  if( pin->GetConvert() && ( pin->GetConvert() != GetConvert() ) )
2050  continue;
2051 
2052  wxPoint pos = GetTransform().TransformCoordinate( pin->GetPosition() ) + m_Pos;
2053 
2054  NETLIST_OBJECT* item = new NETLIST_OBJECT();
2055  item->m_SheetPathInclude = *aSheetPath;
2056  item->m_Comp = (SCH_ITEM*) pin;
2057  item->m_SheetPath = *aSheetPath;
2058  item->m_Type = NET_PIN;
2059  item->m_Link = (SCH_ITEM*) this;
2060  item->m_ElectricalPinType = pin->GetType();
2061  item->m_PinNum = pin->GetNumber();
2062  item->m_Label = pin->GetName();
2063  item->m_Start = item->m_End = pos;
2064 
2065  aNetListItems.push_back( item );
2066 
2067  if( pin->IsPowerConnection() )
2068  {
2069  // There is an associated PIN_LABEL.
2070  item = new NETLIST_OBJECT();
2071  item->m_SheetPathInclude = *aSheetPath;
2072  item->m_Comp = NULL;
2073  item->m_SheetPath = *aSheetPath;
2074  item->m_Type = NET_PINLABEL;
2075  item->m_Label = pin->GetName();
2076  item->m_Start = pos;
2077  item->m_End = item->m_Start;
2078 
2079  aNetListItems.push_back( item );
2080  }
2081  }
2082  }
2083 }
TRANSFORM & GetTransform() const
SCH_SHEET_PATH m_SheetPathInclude
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
int GetUnitSelection(SCH_SHEET_PATH *aSheet)
SCH_SHEET_PATH m_SheetPath
ELECTRICAL_PINTYPE m_ElectricalPinType
NETLIST_ITEM_T m_Type
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:41
int GetConvert() const
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:93
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
int SCH_COMPONENT::GetOrientation ( void  )

Function GetOrientation Used to display component orientation (in dialog editor or info)

Returns
the orientation and mirror Note: Because there are different ways to have a given orientation/mirror, the orientation/mirror is not necessary what the used does (example : a mirrorX then a mirrorY give no mirror but rotate the component). So this function find a rotation and a mirror value ( CMP_MIRROR_X because this is the first mirror option tested) but can differs from the orientation made by an user ( a CMP_MIRROR_Y is find as a CMP_MIRROR_X + orientation 180, because they are equivalent)

Definition at line 1106 of file sch_component.cpp.

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

Referenced by DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel(), and AUTOPLACER::get_preferred_sides().

1107 {
1108  int type_rotate = CMP_ORIENT_0;
1109  TRANSFORM transform;
1110  int ii;
1111 
1112  #define ROTATE_VALUES_COUNT 12
1113 
1114  // list of all possibilities, but only the first 8 are actually used
1115  int rotate_value[ROTATE_VALUES_COUNT] =
1116  {
1122  CMP_MIRROR_Y + CMP_ORIENT_180, CMP_MIRROR_Y + CMP_ORIENT_270
1123  };
1124 
1125  // Try to find the current transform option:
1126  transform = m_transform;
1127 
1128  for( ii = 0; ii < ROTATE_VALUES_COUNT; ii++ )
1129  {
1130  type_rotate = rotate_value[ii];
1131  SetOrientation( type_rotate );
1132 
1133  if( transform == m_transform )
1134  return type_rotate;
1135  }
1136 
1137  // Error: orientation not found in list (should not happen)
1138  wxMessageBox( wxT( "Component orientation matrix internal error" ) );
1139  m_transform = transform;
1140 
1141  return CMP_NORMAL;
1142 }
Class for tranforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
#define ROTATE_VALUES_COUNT
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:90
void SetOrientation(int aOrientation)
Function SetOrientation computes the new transform matrix based on aOrientation for the component whi...
PART_REF& SCH_COMPONENT::GetPartRef ( )
inline
wxString SCH_COMPONENT::GetPath ( const SCH_SHEET_PATH sheet) const

Definition at line 541 of file sch_component.cpp.

References EDA_ITEM::m_TimeStamp, and SCH_SHEET_PATH::Path().

Referenced by ClearAnnotation(), GetRef(), GetUnitSelection(), SetRef(), SetUnitSelection(), and NETLIST_EXPORTER_ORCADPCB2::WriteNetlist().

542 {
543  wxCHECK_MSG( sheet != NULL, wxEmptyString,
544  wxT( "Cannot get component path with invalid sheet object." ) );
545 
546  wxString str;
547 
548  str.Printf( wxT( "%8.8lX" ), (long unsigned) m_TimeStamp );
549  return sheet->Path() + str;
550 }
time_t m_TimeStamp
Time stamp used for logical links.
Definition: base_struct.h:169
wxString Path() const
Function Path the path uses the time stamps which do not changes even when editing sheet parameters a...
const wxArrayString& SCH_COMPONENT::GetPathsAndReferences ( ) const
inline

Definition at line 153 of file sch_component.h.

References m_PathsAndReferences.

Referenced by SCH_LEGACY_PLUGIN::saveComponent().

153 { return m_PathsAndReferences; }
wxArrayString m_PathsAndReferences
Defines the hierarchical path and reference of the component.
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_BUS_BUS_ENTRY, SCH_TEXT, SCH_BUS_WIRE_ENTRY, SCH_FIELD, SCH_SHEET_PIN, SCH_LINE, and SCH_NO_CONNECT.

Definition at line 177 of file sch_item_struct.h.

Referenced by SCH_BUS_ENTRY_BASE::Draw(), SCH_JUNCTION::GetBoundingBox(), SCH_BUS_ENTRY_BASE::GetBoundingBox(), SCH_BUS_ENTRY_BASE::Plot(), and SCH_BITMAP::Plot().

177 { return 0; }
LIB_PIN * SCH_COMPONENT::GetPin ( const wxString &  number)

Function GetPin finds a component pin by number.

Parameters
number- The number of the pin to find.
Returns
Pin object if found, otherwise NULL.

Definition at line 846 of file sch_component.cpp.

References m_convert, m_part, and m_unit.

Referenced by SCH_EDIT_FRAME::FindComponentAndItem().

847 {
848  if( PART_SPTR part = m_part.lock() )
849  {
850  return part->GetPin( number, m_unit, m_convert );
851  }
852  return NULL;
853 }
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:93
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:82
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:83
wxPoint SCH_COMPONENT::GetPinPhysicalPosition ( LIB_PIN Pin)

Definition at line 1894 of file sch_component.cpp.

References LIB_PIN::GetPosition(), LIB_PIN_T, m_Pos, m_transform, TRANSFORM::TransformCoordinate(), and EDA_ITEM::Type().

Referenced by GetEndPoints(), SCH_SCREEN::GetPin(), and IsPinDanglingStateChanged().

1895 {
1896  wxCHECK_MSG( Pin != NULL && Pin->Type() == LIB_PIN_T, wxPoint( 0, 0 ),
1897  wxT( "Cannot get physical position of pin." ) );
1898 
1899  return m_transform.TransformCoordinate( Pin->GetPosition() ) + m_Pos;
1900 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:41
wxPoint GetPosition() const override
Function GetPosition returns the current draw object position.
Definition: lib_pin.h:471
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:90
void SCH_COMPONENT::GetPins ( std::vector< LIB_PIN * > &  aPinsList)

Function GetPins populate a vector with all the pins.

Definition at line 856 of file sch_component.cpp.

References m_convert, m_part, and m_unit.

Referenced by NETLIST_EXPORTER_PSPICE::GetSpiceFieldDefVal(), and AUTOPLACER::pins_on_side().

857 {
858  if( PART_SPTR part = m_part.lock() )
859  {
860  part->GetPins( aPinsList, m_unit, m_convert );
861  }
862  else
863  wxFAIL_MSG( "Could not obtain PART_SPTR lock" );
864 }
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:93
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:82
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:83
wxPoint SCH_COMPONENT::GetPosition ( ) const
inlineoverridevirtual

Function GetPosition.

Returns
A wxPoint object containing the schematic item position.

Implements SCH_ITEM.

Definition at line 564 of file sch_component.h.

References m_Pos.

Referenced by SCH_FIELD::Draw(), SCH_EDIT_FRAME::FindComponentAndItem(), SCH_FIELD::GetBoundingBox(), LIB_PIN::GetMsgPanelInfo(), SCH_FIELD::GetPosition(), SCH_COLLECTOR::Inspect(), SCH_FIND_COLLECTOR::Inspect(), SCH_LEGACY_PLUGIN::saveComponent(), SCH_REFERENCE::SCH_REFERENCE(), and SCH_SCREEN::SetComponentFootprint().

564 { return m_Pos; }
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
wxString SCH_COMPONENT::GetPrefix ( ) const
inline

Definition at line 211 of file sch_component.h.

References m_prefix.

Referenced by SCH_SHEET_PATH::AnnotatePowerSymbols(), and SCH_LEGACY_PLUGIN::saveComponent().

211 { return m_prefix; }
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is...
Definition: sch_component.h:86
const wxString SCH_COMPONENT::GetRef ( const SCH_SHEET_PATH sheet)

Function GetRef returns the reference, for the given sheet path.

Definition at line 553 of file sch_component.cpp.

References GetField(), GetPath(), GetText(), EDA_TEXT::GetText(), m_PathsAndReferences, m_prefix, REFERENCE, and SetRef().

Referenced by NETLIST_EXPORTER_GENERIC::addComponentFields(), Diagnose(), NETLIST_EXPORTER::findAllUnitsOfComponent(), SCH_EDIT_FRAME::FindComponentAndItem(), NETLIST_EXPORTER::findNextComponent(), NETLIST_EXPORTER::findNextComponentAndCreatePinList(), SCH_SHEET_PATH::GetComponents(), GetMsgPanelInfo(), SCH_SHEET_PATH::GetMultiUnitComponents(), NETLIST_OBJECT::GetShortNetName(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers(), NETLIST_EXPORTER_GENERIC::makeComponents(), NETLIST_EXPORTER_GENERIC::makeListOfNets(), SCH_FIELD::Matches(), NETLIST_EXPORTER_PSPICE::ProcessNetlist(), SCH_REFERENCE::SCH_REFERENCE(), SCH_SCREEN::SetComponentFootprint(), SCH_SHEET_PATH::UpdateAllScreenReferences(), NETLIST_EXPORTER_CADSTAR::writeListOfNets(), NETLIST_EXPORTER_ORCADPCB2::WriteNetlist(), and NETLIST_EXPORTER_CADSTAR::WriteNetlist().

554 {
555  wxString path = GetPath( sheet );
556  wxString h_path, h_ref;
557  wxStringTokenizer tokenizer;
558  wxString separators( wxT( " " ) );
559 
560  for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
561  {
562  tokenizer.SetString( m_PathsAndReferences[ii], separators );
563  h_path = tokenizer.GetNextToken();
564 
565  if( h_path.Cmp( path ) == 0 )
566  {
567  h_ref = tokenizer.GetNextToken();
568 
569  /* printf( "GetRef hpath: %s\n",
570  * TO_UTF8( m_PathsAndReferences[ii] ) ); */
571  return h_ref;
572  }
573  }
574 
575  // if it was not found in m_Paths array, then see if it is in
576  // m_Field[REFERENCE] -- if so, use this as a default for this path.
577  // this will happen if we load a version 1 schematic file.
578  // it will also mean that multiple instances of the same sheet by default
579  // all have the same component references, but perhaps this is best.
580  if( !GetField( REFERENCE )->GetText().IsEmpty() )
581  {
582  SetRef( sheet, GetField( REFERENCE )->GetText() );
583  return GetField( REFERENCE )->GetText();
584  }
585 
586  return m_prefix;
587 }
wxString GetPath(const SCH_SHEET_PATH *sheet) const
wxArrayString m_PathsAndReferences
Defines the hierarchical path and reference of the component.
void SetRef(const SCH_SHEET_PATH *sheet, const wxString &ref)
Set the reference, for the given sheet path.
Field Reference of part, i.e. "IC21".
SCH_FIELD * GetField(int aFieldNdx) const
Function GetField returns a field.
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:130
wxString GetText(GRAPHIC_PINSHAPE shape)
Definition: pin_shape.cpp:33
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is...
Definition: sch_component.h:86
wxPoint SCH_COMPONENT::GetScreenCoord ( const wxPoint aPoint)

Function GetScreenCoord Returns the coordinated point relative to the orientation of the component of aPoint.

The coordinates are always relative to the anchor position of the component.

Parameters
aPointThe coordinates to transform.
Returns
The transformed point.

Definition at line 1145 of file sch_component.cpp.

References m_transform, and TRANSFORM::TransformCoordinate().

Referenced by SCH_FIELD::Draw().

1146 {
1147  return m_transform.TransformCoordinate( aPoint );
1148 }
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:41
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:90
wxString SCH_COMPONENT::GetSelectMenuText ( ) 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 1962 of file sch_component.cpp.

References FROM_UTF8(), GetChars(), GetField(), GetLibId(), and REFERENCE.

Referenced by Matches().

1963 {
1964  wxString tmp;
1965  tmp.Printf( _( "Component %s, %s" ),
1966  FROM_UTF8( GetLibId().GetLibItemName() ),
1967  GetChars( GetField( REFERENCE )->GetShownText() ) );
1968  return tmp;
1969 }
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
Field Reference of part, i.e. "IC21".
SCH_FIELD * GetField(int aFieldNdx) const
Function GetField returns a field.
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:92
const LIB_ID & GetLibId() const
STATUS_FLAGS EDA_ITEM::GetStatus ( ) const
inlineinherited

Definition at line 250 of file base_struct.h.

References EDA_ITEM::m_Status.

250 { return m_Status; }
STATUS_FLAGS m_Status
Definition: base_struct.h:161
wxPoint& SCH_ITEM::GetStoredPos ( )
inlineinherited

Definition at line 156 of file sch_item_struct.h.

References SCH_ITEM::m_storedPos.

Referenced by moveItemWithMouseCursor().

156 { return m_storedPos; }
wxPoint m_storedPos
a temporary variable used in some move commands to store a initial pos (of the item or mouse cursor) ...
TRANSFORM& SCH_COMPONENT::GetTransform ( ) const
inline
int SCH_COMPONENT::GetUnit ( ) const
inline
int SCH_COMPONENT::GetUnitCount ( void  ) const

Function GetUnitCount returns the number of parts per package of the component.

Returns
The number of parts per package or zero if the library entry cannot be found.

Definition at line 434 of file sch_component.cpp.

References m_part.

Referenced by NETLIST_EXPORTER_GENERIC::addComponentFields(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyOptionsToPanel(), SCH_FIELD::GetFullyQualifiedText(), and SCH_FIELD::Matches().

435 {
436  if( PART_SPTR part = m_part.lock() )
437  {
438  return part->GetUnitCount();
439  }
440 
441  return 0;
442 }
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:93
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
int SCH_COMPONENT::GetUnitSelection ( SCH_SHEET_PATH aSheet)

Definition at line 694 of file sch_component.cpp.

References GetPath(), m_PathsAndReferences, and m_unit.

Referenced by NETLIST_EXPORTER::findAllUnitsOfComponent(), NETLIST_EXPORTER::findNextComponentAndCreatePinList(), GetNetListItem(), SCH_REFERENCE::SCH_REFERENCE(), and SCH_SHEET_PATH::UpdateAllScreenReferences().

695 {
696  wxString path = GetPath( aSheet );
697  wxString h_path, h_multi;
698  wxStringTokenizer tokenizer;
699  wxString separators( wxT( " " ) );
700 
701  for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
702  {
703  tokenizer.SetString( m_PathsAndReferences[ii], separators );
704  h_path = tokenizer.GetNextToken();
705 
706  if( h_path.Cmp( path ) == 0 )
707  {
708  tokenizer.GetNextToken(); // Skip reference
709  h_multi = tokenizer.GetNextToken();
710  long imulti = 1;
711  h_multi.ToLong( &imulti );
712  return imulti;
713  }
714  }
715 
716  // if it was not found in m_Paths array, then use m_unit.
717  // this will happen if we load a version 1 schematic file.
718  return m_unit;
719 }
wxString GetPath(const SCH_SHEET_PATH *sheet) const
wxArrayString m_PathsAndReferences
Defines the hierarchical path and reference of the component.
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:82
virtual bool SCH_ITEM::HitTest ( const wxPoint aPosition) const
inlineoverridevirtualinherited

Reimplemented from EDA_ITEM.

Definition at line 317 of file sch_item_struct.h.

318  {
319  return HitTest( aPosition, 0 );
320  }
virtual bool HitTest(const wxPoint &aPosition) const override
bool SCH_COMPONENT::HitTest ( const wxPoint aPosition,
int  aAccuracy 
) 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 SCH_ITEM.

Definition at line 2163 of file sch_component.cpp.

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

2164 {
2165  EDA_RECT bBox = GetBodyBoundingBox();
2166  bBox.Inflate( aAccuracy );
2167 
2168  if( bBox.Contains( aPosition ) )
2169  return true;
2170 
2171  return false;
2172 }
bool Contains(const wxPoint &aPoint) const
Function Contains.
EDA_RECT GetBodyBoundingBox() const
Function GetBodyBoundingBox Return a bounding box for the component body but not the fields...
Class EDA_RECT handles the component boundary box.
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
bool SCH_COMPONENT::HitTest ( const EDA_RECT aRect,
bool  aContained = false,
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 SCH_ITEM.

Definition at line 2175 of file sch_component.cpp.

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

2176 {
2178  return false;
2179 
2180  EDA_RECT rect = aRect;
2181 
2182  rect.Inflate( aAccuracy );
2183 
2184  if( aContained )
2185  return rect.Contains( GetBodyBoundingBox() );
2186 
2187  return rect.Intersects( GetBodyBoundingBox() );
2188 }
bool Contains(const wxPoint &aPoint) const
Function Contains.
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: base_struct.h:124
EDA_RECT GetBodyBoundingBox() const
Function GetBodyBoundingBox Return a bounding box for the component body but not the fields...
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:122
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:175
Class EDA_RECT handles the component boundary box.
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
void SCH_COMPONENT::Init ( const wxPoint pos = wxPoint( 0, 0 ))
private

Definition at line 227 of file sch_component.cpp.

References AddField(), TEMPLATE_FIELDNAME::GetDefaultFieldName(), LAYER_REFERENCEPART, LAYER_VALUEPART, m_convert, m_Pos, m_prefix, m_transform, m_unit, MANDATORY_FIELDS, REFERENCE, SCH_ITEM::SetLayer(), and VALUE.

Referenced by SCH_COMPONENT().

228 {
229  m_Pos = pos;
230  m_unit = 0; // In multi unit chip - which unit to draw.
231  m_convert = 0; // De Morgan Handling
232 
233  // The rotation/mirror transformation matrix. pos normal
235 
236  // construct only the mandatory fields, which are the first 4 only.
237  for( int i = 0; i < MANDATORY_FIELDS; ++i )
238  {
239  SCH_FIELD field( pos, i, this, TEMPLATE_FIELDNAME::GetDefaultFieldName( i ) );
240 
241  if( i == REFERENCE )
242  field.SetLayer( LAYER_REFERENCEPART );
243  else if( i == VALUE )
244  field.SetLayer( LAYER_VALUEPART );
245 
246  // else keep LAYER_FIELDS from SCH_FIELD constructor
247 
248  // SCH_FIELD's implicitly created copy constructor is called in here
249  AddField( field );
250  }
251 
252  m_prefix = wxString( wxT( "U" ) );
253 }
Class SCH_FIELD instances are attached to a component and provide a place for the component's value...
Definition: sch_field.h:56
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
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".
Class for tranforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
SCH_FIELD * AddField(const SCH_FIELD &aField)
Function AddField adds a field to the component.
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:82
Field Value of part, i.e. "3.3K".
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:83
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is...
Definition: sch_component.h:86
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:90
bool EDA_ITEM::IsBrightened ( ) const
inlineinherited

Definition at line 224 of file base_struct.h.

References BRIGHTENED.

Referenced by SELECTION_TOOL::disambiguationMenu().

224 { return m_Flags & BRIGHTENED; }
#define BRIGHTENED
item is drawn with a bright contour
Definition: base_struct.h:137
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:175
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 525 of file sch_component.h.

525 { return true; }
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 79 of file sch_item_struct.cpp.

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

Referenced by SCH_SCREEN::addConnectedItemsToBlock(), SCH_SCREEN::CountConnectedItems(), and SCH_SCREEN::IsTerminalPoint().

80 {
82  return false;
83 
84  return doIsConnected( aPosition );
85 }
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: base_struct.h:124
virtual bool doIsConnected(const wxPoint &aPosition) const
Function doIsConnected provides the object specific test to see if it is connected to aPosition...
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:122
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:175
bool SCH_COMPONENT::IsDangling ( ) const
overridevirtual

Return whether any pin has dangling status.

Does NOT update the internal status, only checks the existing status.

Reimplemented from SCH_ITEM.

Definition at line 1883 of file sch_component.cpp.

References m_isDangling.

1884 {
1885  for( bool each : m_isDangling )
1886  {
1887  if( each )
1888  return true;
1889  }
1890  return false;
1891 }
std::vector< bool > m_isDangling
One isDangling per pin.
Definition: sch_component.h:95
bool SCH_COMPONENT::IsDanglingStateChanged ( std::vector< DANGLING_END_ITEM > &  aItemList)
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 (does not short-circuit).

Parameters
aItemList- list of all DANGLING_END_ITEMs to be tested
Returns
true if any pin's state has changed.

Reimplemented from SCH_ITEM.

Definition at line 1868 of file sch_component.cpp.

References IsPinDanglingStateChanged(), m_convert, m_part, and m_unit.

1869 {
1870  bool changed = false;
1871  LIB_PINS libPins;
1872  if( PART_SPTR part = m_part.lock() )
1873  part->GetPins( libPins, m_unit, m_convert );
1874  for( size_t i = 0; i < libPins.size(); ++i )
1875  {
1876  if( IsPinDanglingStateChanged( aItemList, libPins, i ) )
1877  changed = true;
1878  }
1879  return changed;
1880 }
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:93
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:82
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_draw_item.h:70
bool IsPinDanglingStateChanged(std::vector< DANGLING_END_ITEM > &aItemList, LIB_PINS &aLibPins, unsigned aPin)
Test if the component's dangling state has changed for one given pin index.
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:83
bool EDA_ITEM::IsDragging ( ) const
inlineinherited
bool EDA_ITEM::IsHighlighted ( ) const
inlineinherited

Definition at line 223 of file base_struct.h.

References HIGHLIGHTED.

223 { return m_Flags & HIGHLIGHTED; }
#define HIGHLIGHTED
item is drawn in normal colors, when the rest is darkened
Definition: base_struct.h:136
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:175
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 2207 of file sch_component.cpp.

References GetField(), EDA_TEXT::GetText(), and REFERENCE.

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

2208 {
2209  SCH_FIELD* rf = GetField( REFERENCE );
2210  return ! rf->GetText().StartsWith( wxT( "#" ) );
2211 }
Class SCH_FIELD instances are attached to a component and provide a place for the component's value...
Definition: sch_field.h:56
Field Reference of part, i.e. "IC21".
SCH_FIELD * GetField(int aFieldNdx) const
Function GetField returns a field.
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:130
bool EDA_ITEM::IsModified ( ) const
inlineinherited

Definition at line 217 of file base_struct.h.

References IS_CHANGED.

Referenced by LIB_EDIT_FRAME::OnEditPin().

217 { return m_Flags & IS_CHANGED; }
#define IS_CHANGED
std::function passed to nested users by ref, avoids copying std::function
Definition: base_struct.h:109
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:175
bool SCH_COMPONENT::IsMovableFromAnchorPoint ( )
inlineoverridevirtual

Virtual function IsMovableFromAnchorPoint 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, compoments)

Returns
false for a componant

Reimplemented from SCH_ITEM.

Definition at line 163 of file sch_component.h.

163 { return false; }
bool EDA_ITEM::IsNew ( ) const
inlineinherited

Definition at line 216 of file base_struct.h.

References IS_NEW.

Referenced by Abort_Edit_Pcb_Text(), Abort_EditEdge(), Abort_Move_ModuleOutline(), Abort_MoveOrCopyModule(), Abort_Zone_Create_Outline(), AbortBuildDimension(), AbortMoveAndEditTarget(), abortMoveBitmap(), abortMoveItem(), AbortPinMove(), AbortSymbolTraceOn(), SCH_EDIT_FRAME::addCurrentItemToList(), SCH_EDIT_FRAME::addJunctionMenuEntries(), AddMenusForBus(), AddMenusForWire(), PCB_EDIT_FRAME::Delete_Segment(), PCB_EDIT_FRAME::Delete_Segment_Edge(), SCH_EDIT_FRAME::DeleteCurrentSegment(), LIB_ARC::drawEditGraphics(), LIB_ARC::drawGraphic(), DrawMovePin(), SCH_EDIT_FRAME::EditSheetPin(), LIB_PIN::EnableEditMode(), LIB_EDIT_FRAME::EndDrawGraphicItem(), SCH_EDIT_FRAME::EndSegment(), ExitSheet(), SCH_EDIT_FRAME::OnAutoplaceFields(), SCH_EDIT_FRAME::OnConvertTextType(), LIB_EDIT_FRAME::OnEditPin(), SCH_EDIT_FRAME::OnHotKey(), FOOTPRINT_EDIT_FRAME::OnLeftClick(), LIB_EDIT_FRAME::OnLeftClick(), PCB_EDIT_FRAME::OnLeftClick(), FOOTPRINT_EDIT_FRAME::OnLeftDClick(), LIB_EDIT_FRAME::OnLeftDClick(), SCH_EDIT_FRAME::OnLeftDClick(), PCB_EDIT_FRAME::OnLeftDClick(), LIB_EDIT_FRAME::OnRightClick(), SCH_EDIT_FRAME::OnRightClick(), SCH_EDIT_FRAME::OnRotate(), PCB_EDIT_FRAME::Place_Texte_Pcb(), PCB_BASE_FRAME::PlaceModule(), LIB_EDIT_FRAME::PlacePin(), PCB_EDIT_FRAME::PlaceTarget(), SCH_EDIT_FRAME::PrepareMoveItem(), SCH_EDIT_FRAME::ReSizeSheet(), ShowClearance(), PCB_EDIT_FRAME::StartMoveTextePcb(), PCB_EDIT_FRAME::SwitchLayer(), and DIALOG_LABEL_EDITOR::TextPropertiesAccept().

216 { return m_Flags & IS_NEW; }
#define IS_NEW
New item, just created.
Definition: base_struct.h:113
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:175
bool SCH_COMPONENT::IsPinDanglingStateChanged ( std::vector< DANGLING_END_ITEM > &  aItemList,
LIB_PINS aLibPins,
unsigned  aPin 
)

Test if the component's dangling state has changed for one given pin index.

As a side effect, actually update the dangling status for that pin.

Parameters
aItemList- list of all DANGLING_END_ITEMs to be tested
aLibPins- list of all the LIB_PIN items in this component's symbol
aPin- index into aLibPins that identifies the pin to test
Returns
true if the pin's state has changed.

Definition at line 1811 of file sch_component.cpp.

References GetPinPhysicalPosition(), IsInNetlist(), LIB_PIN::IsPowerConnection(), JUNCTION_END, LABEL_END, m_isDangling, NO_CONNECT_END, PIN_END, SHEET_LABEL_END, WIRE_END_END, and WIRE_START_END.

Referenced by IsDanglingStateChanged().

1813 {
1814  bool previousState;
1815 
1816  if( aPin < m_isDangling.size() )
1817  {
1818  previousState = m_isDangling[aPin];
1819  m_isDangling[aPin] = true;
1820  }
1821  else
1822  {
1823  previousState = true;
1824  m_isDangling.push_back( true );
1825  }
1826 
1827  wxPoint pin_position = GetPinPhysicalPosition( aLibPins[aPin] );
1828 
1829  for( DANGLING_END_ITEM& each_item : aItemList )
1830  {
1831  // Some people like to stack pins on top of each other in a symbol to indicate
1832  // internal connection. While technically connected, it is not particularly useful
1833  // to display them that way, so skip any pins that are in the same symbol as this
1834  // one.
1835  //
1836  // Do not make this exception for hidden pins, because those actually make internal
1837  // connections to a power net.
1838  const LIB_PIN* item_pin = dynamic_cast<const LIB_PIN*>( each_item.GetItem() );
1839 
1840  if( item_pin
1841  && ( !item_pin->IsPowerConnection() || !IsInNetlist() )
1842  && std::find( aLibPins.begin(), aLibPins.end(), item_pin) != aLibPins.end() )
1843  continue;
1844 
1845  switch( each_item.GetType() )
1846  {
1847  case PIN_END:
1848  case LABEL_END:
1849  case SHEET_LABEL_END:
1850  case WIRE_START_END:
1851  case WIRE_END_END:
1852  case NO_CONNECT_END:
1853  case JUNCTION_END:
1854  if( pin_position == each_item.GetPosition() )
1855  m_isDangling[aPin] = false;
1856  break;
1857  default:
1858  break;
1859  }
1860  if( !m_isDangling[aPin] )
1861  break;
1862  }
1863 
1864  return previousState != m_isDangling[aPin];
1865 }
std::vector< bool > m_isDangling
One isDangling per pin.
Definition: sch_component.h:95
wxPoint GetPinPhysicalPosition(LIB_PIN *Pin)
bool IsInNetlist() const
bool IsPowerConnection() const
Return whether this pin forms an implicit power connection: i.e., is hidden and of type POWER_IN...
Definition: lib_pin.h:378
Class DANGLING_END_ITEM is a helper class used to store the state of schematic items that can be conn...
bool SCH_COMPONENT::IsReferenceStringValid ( const wxString &  aReferenceString)
static

Function IsReferenceStringValid (static) Tests for an acceptable reference string An acceptable reference string must support unannotation i.e starts by letter.

Parameters
aReferenceString= the reference string to validate
Returns
true if OK

Definition at line 596 of file sch_component.cpp.

Referenced by ClearAnnotation(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnOKButtonClick(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick(), SetRef(), and DIALOG_EDIT_ONE_FIELD::TransferDataFromWindow().

597 {
598  wxString text = aReferenceString;
599  bool ok = true;
600 
601  // Try to unannotate this reference
602  while( !text.IsEmpty() && ( text.Last() == '?' || isdigit( text.Last() ) ) )
603  text.RemoveLast();
604 
605  if( text.IsEmpty() )
606  ok = false;
607 
608  // Add here other constraints
609  // Currently:no other constraint
610 
611  return ok;
612 }
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 562 of file sch_component.h.

562 { return true; }
bool EDA_ITEM::IsResized ( ) const
inlineinherited

Definition at line 222 of file base_struct.h.

References IS_RESIZED.

Referenced by ExitSheet().

222 { return m_Flags & IS_RESIZED; }
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:175
#define IS_RESIZED
Item being resized.
Definition: base_struct.h:114
bool SCH_COMPONENT::IsSelectStateChanged ( const wxRect &  aRect)
overridevirtual

Function IsSelectStateChanged checks if the selection state of an item inside aRect has changed.

This is used by the block selection code to verify if an item is selected or not. True is be return anytime the select state changes. If you need to know the the current selection state, use the IsSelected() method.

Parameters
aRect- Rectangle to test against.

Reimplemented from SCH_ITEM.

Definition at line 1903 of file sch_component.cpp.

References boundingBox(), EDA_ITEM::ClearFlags(), GetBoundingBox(), EDA_ITEM::IsSelected(), SELECTED, and EDA_ITEM::SetFlags().

1904 {
1905  bool previousState = IsSelected();
1906 
1908 
1909  if( aRect.Intersects( boundingBox ) )
1910  SetFlags( SELECTED );
1911  else
1912  ClearFlags( SELECTED );
1913 
1914  return previousState != IsSelected();
1915 }
bool IsSelected() const
Definition: base_struct.h:221
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
BOX2I boundingBox(T aObject)
boundingBox template method
Definition: shape_index.h:59
#define SELECTED
Definition: base_struct.h:120
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:253
Class EDA_RECT handles the component boundary box.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:254
bool EDA_ITEM::IsWireImage ( ) const
inlineinherited

Definition at line 220 of file base_struct.h.

References IS_WIRE_IMAGE.

Referenced by abortMoveItem(), and SCH_FIELD::Draw().

220 { return m_Flags & IS_WIRE_IMAGE; }
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.
Definition: base_struct.h:117
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:175
SEARCH_RESULT EDA_ITEM::IterateForward ( EDA_ITEM listStart,
INSPECTOR  inspector,
void *  testData,
const KICAD_T  scanTypes[] 
)
staticinherited

Function IterateForward walks through the object tree calling the inspector() on each object type requested in scanTypes.

Parameters
listStartThe first in a list of EDA_ITEMs to iterate over.
inspectorIs an INSPECTOR to call on each object that is one of the requested scanTypes.
testDataIs an aid to testFunc, and should be sufficient to allow it to fully determine if an item meets the match criteria, but it may also be used to collect output.
scanTypesA KICAD_T array that is EOT terminated, and provides both the order and interest level of of the types of objects to be iterated over.
Returns
SEARCH_RESULT SEARCH_QUIT if the called INSPECTOR returned SEARCH_QUIT, else SCAN_CONTINUE;

Definition at line 132 of file base_struct.cpp.

References EDA_ITEM::Pnext, SEARCH_CONTINUE, SEARCH_QUIT, and EDA_ITEM::Visit().

Referenced by SCH_COLLECTOR::Collect(), SCH_FIND_COLLECTOR::Collect(), SCH_TYPE_COLLECTOR::Collect(), MODULE::Visit(), and BOARD::Visit().

136 {
137  EDA_ITEM* p = listStart;
138 
139  for( ; p; p = p->Pnext )
140  {
141  if( SEARCH_QUIT == p->Visit( inspector, testData, scanTypes ) )
142  return SEARCH_QUIT;
143  }
144 
145  return SEARCH_CONTINUE;
146 }
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...
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
EDA_ITEM * Pnext
next in linked list
Definition: base_struct.h:164
bool SCH_COMPONENT::Load ( LINE_READER aLine,
wxString &  aErrorMsg 
)
overridevirtual

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.

Reimplemented from SCH_ITEM.

Definition at line 1304 of file sch_component.cpp.

References AddField(), AddHierarchicalReference(), LIB_ID::clear(), EDA_TEXT::Empty(), FROM_UTF8(), TEMPLATE_FIELDNAME::GetDefaultFieldName(), GetDefaultTextSize(), GetField(), GetFieldCount(), GetText(), EDA_TEXT::GetText(), GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, LINE_READER::Line(), LINE_READER::LineNumber(), m_convert, EDA_ITEM::m_Flags, m_lib_id, m_Pos, m_prefix, EDA_ITEM::m_TimeStamp, m_transform, m_unit, MANDATORY_FIELDS, NULL_STRING, ReadDelimitedText(), LINE_READER::ReadLine(), REFERENCE, EDA_TEXT::SetBold(), EDA_TEXT::SetHorizJustify(), EDA_TEXT::SetItalic(), LIB_ID::SetLibItemName(), SCH_FIELD::SetName(), EDA_TEXT::SetText(), EDA_TEXT::SetTextAngle(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetVertJustify(), EDA_TEXT::SetVisible(), TEXT_ANGLE_HORIZ, TEXT_ANGLE_VERT, timeStamp(), TO_UTF8, VALUE, wxPoint::x, TRANSFORM::x1, TRANSFORM::x2, wxPoint::y, TRANSFORM::y1, and TRANSFORM::y2.

1305 {
1306  // Remark: avoid using sscanf to read texts entered by user
1307  // which are UTF8 encoded, because sscanf does not work well on Windows
1308  // with some UTF8 values.
1309  char name1[256], char1[256], char2[256], char3[256];
1310  int newfmt = 0;
1311  char* ptcar;
1312  wxString fieldName;
1313  char* line = aLine.Line();
1314  unsigned long timeStamp;
1315 
1316  m_convert = 1;
1317 
1318  if( line[0] == '$' )
1319  {
1320  newfmt = 1;
1321 
1322  if( !(line = aLine.ReadLine()) )
1323  return true;
1324  }
1325 
1326  // Parse the first line of description:
1327  // like "L partname ref" (for instance "L 74LS00 U4"
1328  // They are UTF8 texts, so do not use sscanf
1329 
1330  line += 1;
1331 
1332  if( *line == ' ' )
1333  line++;
1334 
1335  // line points the first parameter
1336  wxString buffer( FROM_UTF8( line ) );
1337  wxStringTokenizer tokenizer( buffer, wxT( " \r\n" ) );
1338 
1339  if( tokenizer.CountTokens() < 2 )
1340  {
1341  aErrorMsg.Printf( wxT( "Eeschema component description error at line %d, aborted" ),
1342  aLine.LineNumber() );
1343  aErrorMsg << wxT( "\n" ) << FROM_UTF8( line );
1344  return false;
1345  }
1346 
1347  wxString partname = tokenizer.NextToken();
1348  partname.Replace( wxT("~"), wxT(" ") ); // all spaces were replaced by ~ in files.
1349 
1350  if( partname != NULL_STRING )
1351  {
1352  m_lib_id.SetLibItemName( TO_UTF8( partname ), false );
1353 
1354  if( !newfmt )
1355  GetField( VALUE )->SetText( partname );
1356  }
1357  else
1358  {
1359  m_lib_id.clear();
1360  GetField( VALUE )->Empty();
1362  GetField( VALUE )->SetVisible( false );
1363  }
1364 
1365  wxString reference = tokenizer.NextToken();
1366  reference.Replace( wxT("~"), wxT(" ") ); // all spaces were replaced by ~ in files.
1367  reference.Trim( true );
1368  reference.Trim( false );
1369 
1370  if( reference != NULL_STRING )
1371  {
1372  wxString prefix = reference;
1373  // Build reference prefix from the actual reference by removing trailing digits
1374  // (Perhaps outdated code, only for very old schematic files)
1375  while( prefix.Length() )
1376  {
1377  if( ( prefix.Last() < '0' || prefix.Last() > '9') && prefix.Last() != '?' )
1378  break;
1379 
1380  prefix.RemoveLast();
1381  }
1382 
1383  // Avoid a prefix containing trailing/leading spaces
1384  prefix.Trim( true );
1385  prefix.Trim( false );
1386 
1387  if( prefix.IsEmpty() )
1388  m_prefix = wxT( "U" );
1389  else
1390  m_prefix = prefix;
1391 
1392  if( !newfmt )
1393  GetField( REFERENCE )->SetText( reference );
1394  }
1395  else
1396  {
1397  GetField( REFERENCE )->SetVisible( false );
1398  }
1399 
1400  /* Parse component description
1401  * These lines begin with:
1402  * "P" = Position
1403  * U = Num Unit and Conversion
1404  * "Fn" = Fields (0 .. n = = number of field)
1405  * "Ar" = Alternate reference in the case of multiple sheets referring to
1406  * one schematic file.
1407  */
1408  for( ; ; )
1409  {
1410  if( !(line = aLine.ReadLine()) )
1411  return false;
1412 
1413  if( line[0] == 'U' )
1414  {
1415  sscanf( line + 1, "%d %d %lX", &m_unit, &m_convert, &timeStamp );
1416  m_TimeStamp = (time_t)timeStamp;
1417  }
1418  else if( line[0] == 'P' )
1419  {
1420  sscanf( line + 1, "%d %d", &m_Pos.x, &m_Pos.y );
1421 
1422  // Set fields position to a default position (that is the
1423  // component position. For existing fields, the real position
1424  // will be set later
1425  for( int i = 0; i<GetFieldCount(); i++ )
1426  {
1427  if( GetField( i )->GetText().IsEmpty() )
1428  GetField( i )->SetTextPos( m_Pos );
1429  }
1430  }
1431  else if( line[0] == 'A' && line[1] == 'R' )
1432  {
1433  /* format:
1434  * AR Path="/9086AF6E/67452AA0" Ref="C99" Part="1"
1435  * where 9086AF6E is the unique timestamp of the containing sheet
1436  * and 67452AA0 is the timestamp of this component.
1437  * C99 is the reference given this path.
1438  */
1439  int ii;
1440  ptcar = line + 2;
1441 
1442  //copy the path.
1443  ii = ReadDelimitedText( name1, ptcar, 255 );
1444  ptcar += ii + 1;
1445  wxString path = FROM_UTF8( name1 );
1446 
1447  // copy the reference
1448  ii = ReadDelimitedText( name1, ptcar, 255 );
1449  ptcar += ii + 1;
1450  wxString ref = FROM_UTF8( name1 );
1451 
1452  // copy the multi, if exists
1453  ii = ReadDelimitedText( name1, ptcar, 255 );
1454 
1455  if( name1[0] == 0 ) // Nothing read, put a default value
1456  sprintf( name1, "%d", m_unit );
1457 
1458  int multi = atoi( name1 );
1459 
1460  if( multi < 0 || multi > 26 )
1461  multi = 1;
1462 
1463  AddHierarchicalReference( path, ref, multi );
1464  GetField( REFERENCE )->SetText( ref );
1465  }
1466  else if( line[0] == 'F' )
1467  {
1468  int fieldNdx;
1469 
1470  wxString fieldText;
1473 
1474  ptcar = (char*) aLine;
1475 
1476  while( *ptcar && (*ptcar != '"') )
1477  ptcar++;
1478 
1479  if( *ptcar != '"' )
1480  {
1481  aErrorMsg.Printf( wxT( "Eeschema file library field F at line %d, aborted" ),
1482  aLine.LineNumber() );
1483  return false;
1484  }
1485 
1486  ptcar += ReadDelimitedText( &fieldText, ptcar );
1487 
1488  if( *ptcar == 0 )
1489  {
1490  aErrorMsg.Printf( wxT( "Component field F at line %d, aborted" ),
1491  aLine.LineNumber() );
1492  return false;
1493  }
1494 
1495  fieldNdx = atoi( line + 2 );
1496 
1497  ReadDelimitedText( &fieldName, ptcar );
1498 
1499  if( fieldName.IsEmpty() )
1500  fieldName = TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldNdx );
1501 
1502  if( fieldNdx >= GetFieldCount() )
1503  {
1504  // The first MANDATOR_FIELDS _must_ be constructed within
1505  // the SCH_COMPONENT constructor. This assert is simply here
1506  // to guard against a change in that constructor.
1507  wxASSERT( GetFieldCount() >= MANDATORY_FIELDS );
1508 
1509  // Ignore the _supplied_ fieldNdx. It is not important anymore
1510  // if within the user defined fields region (i.e. >= MANDATORY_FIELDS).
1511  // We freely renumber the index to fit the next available field slot.
1512 
1513  fieldNdx = GetFieldCount(); // new has this index after insertion
1514 
1515  SCH_FIELD field( wxPoint( 0, 0 ),
1516  -1, // field id is not relavant for user defined fields
1517  this, fieldName );
1518 
1519  AddField( field );
1520  }
1521  else
1522  {
1523  GetField( fieldNdx )->SetName( fieldName );
1524  }
1525 
1526  GetField( fieldNdx )->SetText( fieldText );
1527  memset( char3, 0, sizeof(char3) );
1528  int ii, x, y, w, attr;
1529 
1530  if( ( ii = sscanf( ptcar, "%255s %d %d %d %X %255s %255s", char1, &x, &y, &w, &attr,
1531  char2, char3 ) ) < 4 )
1532  {
1533  aErrorMsg.Printf( wxT( "Component Field error line %d, aborted" ),
1534  aLine.LineNumber() );
1535  continue;
1536  }
1537 
1538  GetField( fieldNdx )->SetTextPos( wxPoint( x, y ) );
1539  GetField( fieldNdx )->SetVisible( !attr );
1540 
1541  if( (w == 0 ) || (ii == 4) )
1542  w = GetDefaultTextSize();
1543 
1544  GetField( fieldNdx )->SetTextSize( wxSize( w, w ) );
1545  GetField( fieldNdx )->SetTextAngle( TEXT_ANGLE_HORIZ );
1546 
1547  if( char1[0] == 'V' )
1548  GetField( fieldNdx )->SetTextAngle( TEXT_ANGLE_VERT );
1549 
1550  if( ii >= 7 )
1551  {
1552  if( *char2 == 'L' )
1553  hjustify = GR_TEXT_HJUSTIFY_LEFT;
1554  else if( *char2 == 'R' )
1555  hjustify = GR_TEXT_HJUSTIFY_RIGHT;
1556 
1557  if( char3[0] == 'B' )
1558  vjustify = GR_TEXT_VJUSTIFY_BOTTOM;
1559  else if( char3[0] == 'T' )
1560  vjustify = GR_TEXT_VJUSTIFY_TOP;
1561 
1562  GetField( fieldNdx )->SetItalic( char3[1] == 'I' );
1563  GetField( fieldNdx )->SetBold( char3[2] == 'B' );
1564  GetField( fieldNdx )->SetHorizJustify( hjustify );
1565  GetField( fieldNdx )->SetVertJustify( vjustify );
1566  }
1567 
1568  if( fieldNdx == REFERENCE )
1569  if( GetField( fieldNdx )->GetText()[0] == '#' )
1570  GetField( fieldNdx )->SetVisible( false );
1571  }
1572  else
1573  {
1574  break;
1575  }
1576  }
1577 
1578  if( sscanf( line, "%d %d %d", &m_unit, &m_Pos.x, &m_Pos.y ) != 3 )
1579  {
1580  aErrorMsg.Printf( wxT( "Component unit & pos error at line %d, aborted" ),
1581  aLine.LineNumber() );
1582  return false;
1583  }
1584 
1585  if( !(line = aLine.ReadLine()) ||
1586  sscanf( line, "%d %d %d %d",
1587  &m_transform.x1,
1588  &m_transform.y1,
1589  &m_transform.x2,
1590  &m_transform.y2 ) != 4 )
1591  {
1592  aErrorMsg.Printf( wxT( "Component orient error at line %d, aborted" ),
1593  aLine.LineNumber() );
1594  return false;
1595  }
1596 
1597  if( newfmt )
1598  {
1599  if( !(line = aLine.ReadLine()) )
1600  return false;
1601 
1602  if( strncasecmp( "$End", line, 4 ) != 0 )
1603  {
1604  aErrorMsg.Printf( wxT( "Component End expected at line %d, aborted" ),
1605  aLine.LineNumber() );
1606  return false;
1607  }
1608  }
1609 
1610  // ensure flags (mainly used in edit) are cleared.
1611  // some changes have set the modified flag
1612  m_Flags = 0;
1613 
1614  return true;
1615 }
void SetTextAngle(double aAngle)
Definition: eda_text.h:156
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: common.h:91
Class SCH_FIELD instances are attached to a component and provide a place for the component's value...
Definition: sch_field.h:56
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:47
virtual unsigned LineNumber() const
Function Line Number returns the line number of the last line read from this LINE_READER.
Definition: richio.h:159
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
int y2
Definition: transform.h:51
time_t m_TimeStamp
Time stamp used for logical links.
Definition: base_struct.h:169
unsigned long timeStamp(wxXmlNode *aTree)
Make a unique time stamp.
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
void SetItalic(bool isItalic)
Definition: eda_text.h:169
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors...
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:223
void SetVisible(bool aVisible)
Definition: eda_text.h:175
int x2
Definition: transform.h:50
int x1
Definition: transform.h:48
static const wxString GetDefaultFieldName(int aFieldNdx)
Function GetDefaultFieldName returns a default symbol field name for field aFieldNdx for all componen...
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:214
#define TEXT_ANGLE_VERT
Definition: common.h:92
Field Reference of part, i.e. "IC21".
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
int y1
Definition: transform.h:49
SCH_FIELD * GetField(int aFieldNdx) const
Function GetField returns a field.
char * Line() const
Function Line returns a pointer to the last line that was read in.
Definition: richio.h:139
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:130
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:194
void Empty()
Definition: eda_text.h:231
SCH_FIELD * AddField(const SCH_FIELD &aField)
Function AddField adds a field to the component.
wxString GetText(GRAPHIC_PINSHAPE shape)
Definition: pin_shape.cpp:33
void clear()
Function clear.
Definition: lib_id.cpp:114
int SetLibItemName(const UTF8 &aLibItemName, bool aTestForRev=true)
Function SetLibItemName.
Definition: lib_id.cpp:232
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:54
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:82
Field Value of part, i.e. "3.3K".
#define NULL_STRING
virtual char * ReadLine()=0
Function ReadLine reads a line of text into the buffer and increments the line number counter...
int GetFieldCount() const
Function GetFieldCount returns the number of fields in this component.
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:193
void AddHierarchicalReference(const wxString &aPath, const wxString &aRef, int aMulti)
Function AddHierarchicalReference adds a full hierarchical reference (path + local reference) ...
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:175
void SetName(const wxString &aName)
Definition: sch_field.h:85
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:83
int ReadDelimitedText(wxString *aDest, const char *aSource)
Function ReadDelimitedText copies bytes from aSource delimited string segment to aDest wxString...
Definition: string.cpp:43
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is...
Definition: sch_component.h:86
void SetBold(bool aBold)
Definition: eda_text.h:172
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:90
int GetDefaultTextSize()
Default size for text in general.
virtual void SetText(const wxString &aText)
Definition: eda_text.h:141
bool SCH_COMPONENT::Matches ( wxFindReplaceData &  aSearchData,
void *  aAuxData,
wxPoint aFindLocation 
)
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.
aFindLocationA pointer to a wxPoint object to store the location of matched item. The pointer can be NULL if it is not used.
Returns
True if the item's text matches the search criteria in aSearchData.

Reimplemented from EDA_ITEM.

Definition at line 1780 of file sch_component.cpp.

References GetSelectMenuText(), and traceFindItem.

1782 {
1783  wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText() );
1784 
1785  // Components are searchable via the child field and pin item text.
1786  return false;
1787 }
const wxString traceFindItem
Flag to enable find item tracing using the WXTRACE environment variable.
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
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 184 of file base_struct.cpp.

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

185 {
186  wxString text = aText;
187  wxString searchText = aSearchData.GetFindString();
188 
189  // Don't match if searching for replaceable item and the item doesn't support text replace.
190  if( (aSearchData.GetFlags() & FR_SEARCH_REPLACE) && !IsReplaceable() )
191  return false;
192 
193  if( aSearchData.GetFlags() & wxFR_WHOLEWORD )
194  return aText.IsSameAs( searchText, aSearchData.GetFlags() & wxFR_MATCHCASE );
195 
196  if( aSearchData.GetFlags() & FR_MATCH_WILDCARD )
197  {
198  if( aSearchData.GetFlags() & wxFR_MATCHCASE )
199  return text.Matches( searchText );
200 
201  return text.MakeUpper().Matches( searchText.MakeUpper() );
202  }
203 
204  if( aSearchData.GetFlags() & wxFR_MATCHCASE )
205  return aText.Find( searchText ) != wxNOT_FOUND;
206 
207  return text.MakeUpper().Find( searchText.MakeUpper() ) != wxNOT_FOUND;
208 }
virtual bool IsReplaceable() const
Function IsReplaceable.
Definition: base_struct.h:444
Perform search using simple wild card matching (* & ?).
Perform a search for a item that has replaceable text.
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 1743 of file sch_component.cpp.

References CMP_MIRROR_X, GetField(), GetFieldCount(), EDA_TEXT::GetTextPos(), m_Pos, MIRROR(), SetOrientation(), EDA_TEXT::SetTextPos(), and wxPoint::y.

1744 {
1745  int dy = m_Pos.y;
1746 
1748  MIRROR( m_Pos.y, aXaxis_position );
1749  dy -= m_Pos.y; // dy,0 is the move vector for this transform
1750 
1751  for( int ii = 0; ii < GetFieldCount(); ii++ )
1752  {
1753  // Move the fields to the new position because the component itself has moved.
1754  wxPoint pos = GetField( ii )->GetTextPos();
1755  pos.y -= dy;
1756  GetField( ii )->SetTextPos( pos );
1757  }
1758 }
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:223
void MIRROR(T &aPoint, const T &aMirrorRef)
Definition: macros.h:111
SCH_FIELD * GetField(int aFieldNdx) const
Function GetField returns a field.
int GetFieldCount() const
Function GetFieldCount returns the number of fields in this component.
void SetOrientation(int aOrientation)
Function SetOrientation computes the new transform matrix based on aOrientation for the component whi...
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 1725 of file sch_component.cpp.

References CMP_MIRROR_Y, GetField(), GetFieldCount(), EDA_TEXT::GetTextPos(), m_Pos, MIRROR(), SetOrientation(), EDA_TEXT::SetTextPos(), and wxPoint::x.

1726 {
1727  int dx = m_Pos.x;
1728 
1730  MIRROR( m_Pos.x, aYaxis_position );
1731  dx -= m_Pos.x; // dx,0 is the move vector for this transform
1732 
1733  for( int ii = 0; ii < GetFieldCount(); ii++ )
1734  {
1735  // Move the fields to the new position because the component itself has moved.
1736  wxPoint pos = GetField( ii )->GetTextPos();
1737  pos.x -= dx;
1738  GetField( ii )->SetTextPos( pos );
1739  }
1740 }
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:223
void MIRROR(T &aPoint, const T &aMirrorRef)
Definition: macros.h:111
SCH_FIELD * GetField(int aFieldNdx) const
Function GetField returns a field.
int GetFieldCount() const
Function GetFieldCount returns the number of fields in this component.
void SetOrientation(int aOrientation)
Function SetOrientation computes the new transform matrix based on aOrientation for the component whi...
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 471 of file sch_component.h.

References GetField(), GetFieldCount(), SCH_FIELD::Move(), and EDA_ITEM::SetModified().

Referenced by SetPosition().

472  {
473  if( aMoveVector == wxPoint( 0, 0 ) )
474  return;
475 
476  m_Pos += aMoveVector;
477 
478  for( int ii = 0; ii < GetFieldCount(); ii++ )
479  GetField( ii )->Move( aMoveVector );
480 
481  SetModified();
482  }
void Move(const wxPoint &aMoveVector) override
Function Move moves the item by aMoveVector to a new position.
Definition: sch_field.h:150
void SetModified()
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
SCH_FIELD * GetField(int aFieldNdx) const
Function GetField returns a field.
int GetFieldCount() const
Function GetFieldCount returns the number of fields in this component.
SCH_ITEM* SCH_ITEM::Next ( ) const
inlineinherited

Definition at line 144 of file sch_item_struct.h.

References EDA_ITEM::Pnext.

Referenced by SCH_SCREEN::addConnectedItemsToBlock(), SCH_SHEET_PATH::AnnotatePowerSymbols(), SCH_EDIT_FRAME::AppendOneEEProject(), SCH_SCREEN::BreakSegment(), SCH_SCREEN::BreakSegmentsOnJunctions(), NETLIST_OBJECT_LIST::BuildNetListInfo(), HIERARCHY_NAVIG_DLG::BuildSheetsTree(), SCH_SCREEN::CheckIfOnDrawList(), SCH_SCREEN::ClearAnnotation(), SCH_SCREEN::ClearDrawingState(), SCH_SCREEN::CountConnectedItems(), SCH_EDIT_FRAME::CreateArchiveLibrary(), SCH_SCREENS::DeleteAllMarkers(), DIALOG_ERC::DisplayERC_MarkersList(), SCH_SCREEN::Draw(), SCH_EDIT_FRAME::EndSegment(), SCH_SCREEN::ExtractWires(), SCH_EDIT_FRAME::FindComponentAndItem(), SCH_SHEET_PATH::FindNextItem(), SCH_SHEET_LIST::FindNextItem(), SCH_SHEET_PATH::FirstDrawList(), SCH_LEGACY_PLUGIN::Format(), get_components(), AUTOPLACER::get_possible_colliders(), SCH_SHEET_PATH::GetComponents(), SCH_SCREEN::GetConnection(), SCH_SCREEN::GetHierarchicalItems(), SCH_SCREEN::GetItem(), SCH_SCREEN::GetLabel(), SCH_SCREEN::GetLine(), SCH_SCREENS::GetMarkerCount(), SCH_SHEET_PATH::GetMultiUnitComponents(), SCH_SCREEN::GetNode(), SCH_SCREEN::GetPin(), SCH_SCREEN::GetSheet(), SCH_SCREEN::GetSheetLabel(), SCH_SCREEN::GetWireOrBus(), SCH_SCREENS::HasNoFullyDefinedLibIds(), SCH_SCREEN::MarkConnections(), SCH_EDIT_FRAME::OnConvertTextType(), DIALOG_ERC::OnLeftClickMarkersList(), SCH_SCREEN::Plot(), DIALOG_SYMBOL_REMAP::remapSymbolsToLibTable(), SCH_SCREEN::ReplaceWires(), SCH_SCREEN::Save(), SCH_SCREEN::SchematicCleanUp(), SCH_SCREEN::SetComponentFootprint(), SCH_EDIT_FRAME::SetCurrentSheetHighlightFlags(), SCH_SCREEN::TestDanglingEnds(), TestDuplicateSheetNames(), and SCH_SCREEN::UpdatePickList().

144 { return static_cast<SCH_ITEM*>( Pnext ); }
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
EDA_ITEM * Pnext
next in linked list
Definition: base_struct.h:164
bool SCH_COMPONENT::operator!= ( const SCH_COMPONENT aComponent) const

Definition at line 2123 of file sch_component.cpp.

2124 {
2125  return !( *this == aComponent );
2126 }
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 241 of file base_struct.cpp.

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

242 {
243  wxFAIL_MSG( wxString::Format( wxT( "Less than operator not defined for item type %s." ),
244  GetChars( GetClass() ) ) );
245 
246  return false;
247 }
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:92
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
bool SCH_COMPONENT::operator< ( const SCH_ITEM aItem) const
overridevirtual

Reimplemented from SCH_ITEM.

Definition at line 2086 of file sch_component.cpp.

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

2087 {
2088  if( Type() != aItem.Type() )
2089  return Type() < aItem.Type();
2090 
2091  SCH_COMPONENT* component = (SCH_COMPONENT*) &aItem;
2092 
2093  EDA_RECT rect = GetBodyBoundingBox();
2094 
2095  if( rect.GetArea() != component->GetBodyBoundingBox().GetArea() )
2096  return rect.GetArea() < component->GetBodyBoundingBox().GetArea();
2097 
2098  if( m_Pos.x != component->m_Pos.x )
2099  return m_Pos.x < component->m_Pos.x;
2100 
2101  if( m_Pos.y != component->m_Pos.y )
2102  return m_Pos.y < component->m_Pos.y;
2103 
2104  return false;
2105 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
EDA_RECT GetBodyBoundingBox() const
Function GetBodyBoundingBox Return a bounding box for the component body but not the fields...
double GetArea() const
Function GetArea returns the area of the rectangle.
Class EDA_RECT handles the component boundary box.
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
SCH_ITEM & SCH_COMPONENT::operator= ( const SCH_ITEM aItem)

Definition at line 2129 of file sch_component.cpp.

References SCH_ITEM::GetClass(), GetClass(), GetField(), GetFieldCount(), m_convert, m_Fields, m_lib_id, m_part, m_PathsAndReferences, m_Pos, m_transform, m_unit, EDA_ITEM::operator=(), EDA_ITEM::SetParent(), and EDA_ITEM::Type().

2130 {
2131  wxCHECK_MSG( Type() == aItem.Type(), *this,
2132  wxT( "Cannot assign object type " ) + aItem.GetClass() + wxT( " to type " ) +
2133  GetClass() );
2134 
2135  if( &aItem != this )
2136  {
2137  SCH_ITEM::operator=( aItem );
2138 
2139  SCH_COMPONENT* c = (SCH_COMPONENT*) &aItem;
2140 
2141  m_lib_id = c->m_lib_id;
2142  m_part = c->m_part;
2143  m_Pos = c->m_Pos;
2144  m_unit = c->m_unit;
2145  m_convert = c->m_convert;
2146  m_transform = c->m_transform;
2147 
2149 
2150  m_Fields = c->m_Fields; // std::vector's assignment operator.
2151 
2152  // Reparent fields after assignment to new component.
2153  for( int ii = 0; ii < GetFieldCount(); ++ii )
2154  {
2155  GetField( ii )->SetParent( this );
2156  }
2157  }
2158 
2159  return *this;
2160 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
SCH_FIELDS m_Fields
Variable length list of fields.
Definition: sch_component.h:91
wxArrayString m_PathsAndReferences
Defines the hierarchical path and reference of the component.
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:93
SCH_FIELD * GetField(int aFieldNdx) const
Function GetField returns a field.
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:213
EDA_ITEM & operator=(const EDA_ITEM &aItem)
Operator assignment is used to assign the members of aItem to another object.
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:82
int GetFieldCount() const
Function GetFieldCount returns the number of fields in this component.
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
virtual wxString GetClass() const override
Function GetClass returns the class name.
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:83
wxString GetClass() const override
Function GetClass returns the class name.
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:90
bool SCH_COMPONENT::operator== ( const SCH_COMPONENT aComponent) const

Definition at line 2108 of file sch_component.cpp.

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

2109 {
2110  if( GetFieldCount() != aComponent.GetFieldCount() )
2111  return false;
2112 
2113  for( int i = VALUE; i < GetFieldCount(); i++ )
2114  {
2115  if( GetField( i )->GetText().Cmp( aComponent.GetField( i )->GetText() ) != 0 )
2116  return false;
2117  }
2118 
2119  return true;
2120 }
SCH_FIELD * GetField(int aFieldNdx) const
Function GetField returns a field.
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:130
Field Value of part, i.e. "3.3K".
int GetFieldCount() const
Function GetFieldCount returns the number of fields in this component.
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 2214 of file sch_component.cpp.

References GetConvert(), GetTransform(), GetUnit(), m_Fields, m_part, and m_Pos.

2215 {
2216  TRANSFORM temp;
2217 
2218  if( PART_SPTR part = m_part.lock() )
2219  {
2220  temp = GetTransform();
2221 
2222  part->Plot( aPlotter, GetUnit(), GetConvert(), m_Pos, temp );
2223 
2224  for( size_t i = 0; i < m_Fields.size(); i++ )
2225  {
2226  m_Fields[i].Plot( aPlotter );
2227  }
2228  }
2229 }
TRANSFORM & GetTransform() const
SCH_FIELDS m_Fields
Variable length list of fields.
Definition: sch_component.h:91
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
int GetConvert() const
Class for tranforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:93
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
int GetUnit() const
bool EDA_ITEM::Replace ( wxFindReplaceData &  aSearchData,
wxString &  aText 
)
inherited

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

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

Referenced by SCH_TEXT::Replace(), SCH_FIELD::Replace(), SCH_SHEET_PIN::Replace(), SCH_SHEET::Replace(), and SCH_FIND_COLLECTOR::ReplaceItem().

212 {
213  wxCHECK_MSG( IsReplaceable(), false,
214  wxT( "Attempt to replace text in <" ) + GetClass() + wxT( "> item." ) );
215 
216  wxString searchString = (aSearchData.GetFlags() & wxFR_MATCHCASE) ? aText : aText.Upper();
217 
218  int result = searchString.Find( (aSearchData.GetFlags() & wxFR_MATCHCASE) ?
219  aSearchData.GetFindString() :
220  aSearchData.GetFindString().Upper() );
221 
222  if( result == wxNOT_FOUND )
223  return false;
224 
225  wxString prefix = aText.Left( result );
226  wxString suffix;
227 
228  if( aSearchData.GetFindString().length() + result < aText.length() )
229  suffix = aText.Right( aText.length() - ( aSearchData.GetFindString().length() + result ) );
230 
231  wxLogTrace( traceFindReplace, wxT( "Replacing '%s', prefix '%s', replace '%s', suffix '%s'." ),
232  GetChars( aText ), GetChars( prefix ), GetChars( aSearchData.GetReplaceString() ),
233  GetChars( suffix ) );
234 
235  aText = prefix + aSearchData.GetReplaceString() + suffix;
236 
237  return true;
238 }
virtual bool IsReplaceable() const
Function IsReplaceable.
Definition: base_struct.h:444
const wxString traceFindReplace(wxT("KicadFindReplace"))
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:92
virtual wxString GetClass() const =0
Function GetClass returns the class name.
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_SHEET, SCH_SHEET_PIN, SCH_FIELD, and SCH_TEXT.

Definition at line 432 of file base_struct.h.

432 { return false; }
bool SCH_COMPONENT::Resolve ( PART_LIBS aLibs)

Function Resolve [re-]assigns the current LIB_PART from aLibs which this component is based on.

Parameters
aLibsis the current set of LIB_PARTs to choose from.

Definition at line 334 of file sch_component.cpp.

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

Referenced by SCH_EDIT_FRAME::Load_Component(), ResolveAll(), and SetLibId().

335 {
336  // I've never been happy that the actual individual PART_LIB is left up to
337  // flimsy search path ordering. None-the-less find a part based on that design:
338  if( LIB_PART* part = aLibs->FindLibPart( m_lib_id ) )
339  {
340  m_part = part->SharedPtr();
341  return true;
342  }
343 
344  return false;
345 }
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:93
Class LIB_PART defines a library part object.
LIB_PART * FindLibPart(const LIB_ID &aLibId, const wxString &aLibraryName=wxEmptyString)
Function FindLibPart searches all libraries in the list for a part.
void SCH_COMPONENT::ResolveAll ( const SCH_COLLECTOR aComponents,
PART_LIBS aLibs 
)
static

Definition at line 354 of file sch_component.cpp.

References COLLECTOR::GetCount(), m_lib_id, m_part, Resolve(), and sort_by_libid().

Referenced by SCH_SCREEN::CheckComponentsToPartsLinks().

356 {
357  // Usually, many components use the same part lib.
358  // to avoid too long calculation time the list of components is grouped
359  // and once the lib part is found for one member of a group, it is also
360  // set for all other members of this group
361  std::vector<SCH_COMPONENT*> cmp_list;
362 
363  // build the cmp list.
364  for( int i = 0; i < aComponents.GetCount(); ++i )
365  {
366  SCH_COMPONENT* cmp = dynamic_cast<SCH_COMPONENT*>( aComponents[i] );
367  wxASSERT( cmp );
368 
369  if( cmp ) // cmp == NULL should not occur.
370  cmp_list.push_back( cmp );
371  }
372 
373  // sort it by lib part. Cmp will be grouped by same lib part.
374  std::sort( cmp_list.begin(), cmp_list.end(), sort_by_libid );
375 
376  LIB_ID curr_libid;
377 
378  for( unsigned ii = 0; ii < cmp_list.size (); ++ii )
379  {
380  SCH_COMPONENT* cmp = cmp_list[ii];
381  curr_libid = cmp->m_lib_id;
382  cmp->Resolve( aLibs );
383 
384  // Propagate the m_part pointer to other members using the same lib_id
385  for( unsigned jj = ii+1; jj < cmp_list.size (); ++jj )
386  {
387  SCH_COMPONENT* next_cmp = cmp_list[jj];
388 
389  if( curr_libid != next_cmp->m_lib_id )
390  break;
391 
392  next_cmp->m_part = cmp->m_part;
393  ii = jj;
394  }
395  }
396 }
int GetCount() const
Function GetCount returns the number of objects in the list.
bool Resolve(PART_LIBS *aLibs)
Function Resolve [re-]assigns the current LIB_PART from aLibs which this component is based on...
static bool sort_by_libid(const SCH_COMPONENT *ref, SCH_COMPONENT *cmp)
Class LIB_ID.
Definition: lib_id.h:56
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:93
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
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 1761 of file sch_component.cpp.

References CMP_ROTATE_COUNTERCLOCKWISE, GetField(), GetFieldCount(), EDA_TEXT::GetTextPos(), m_Pos, RotatePoint(), SetOrientation(), EDA_TEXT::SetTextPos(), wxPoint::x, and wxPoint::y.

1762 {
1763  wxPoint prev = m_Pos;
1764 
1765  RotatePoint( &m_Pos, aPosition, 900 );
1766 
1768 
1769  for( int ii = 0; ii < GetFieldCount(); ii++ )
1770  {
1771  // Move the fields to the new position because the component itself has moved.
1772  wxPoint pos = GetField( ii )->GetTextPos();
1773  pos.x -= prev.x - m_Pos.x;
1774  pos.y -= prev.y - m_Pos.y;
1775  GetField( ii )->SetTextPos( pos );
1776  }
1777 }
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:223
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
SCH_FIELD * GetField(int aFieldNdx) const
Function GetField returns a field.
int GetFieldCount() const
Function GetFieldCount returns the number of fields in this component.
void SetOrientation(int aOrientation)
Function SetOrientation computes the new transform matrix based on aOrientation for the component whi...
bool SCH_COMPONENT::Save ( FILE *  aFile) const
overridevirtual

Function Save writes the data structures for this object out to a FILE in "*.sch" format.

Parameters
aFileThe FILE to write to.
Returns
bool - true if success writing else false.

Implements SCH_ITEM.

Definition at line 1183 of file sch_component.cpp.

References FROM_UTF8(), GetField(), GetLibId(), GetText(), m_convert, m_Fields, m_PathsAndReferences, m_Pos, m_prefix, EDA_ITEM::m_TimeStamp, m_transform, m_unit, MANDATORY_FIELDS, NULL_STRING, REFERENCE, SCH_FIELD::Save(), SCH_FIELD::SetId(), TO_UTF8, toUTFTildaText(), wxPoint::x, TRANSFORM::x1, TRANSFORM::x2, wxPoint::y, TRANSFORM::y1, and TRANSFORM::y2.

1184 {
1185  std::string name1;
1186  std::string name2;
1187  wxArrayString reference_fields;
1188 
1189  static wxString delimiters( wxT( " " ) );
1190 
1191  // this is redundant with the AR entries below, but it makes the
1192  // files backwards-compatible.
1193  if( m_PathsAndReferences.GetCount() > 0 )
1194  {
1195  reference_fields = wxStringTokenize( m_PathsAndReferences[0], delimiters );
1196 
1197  name1 = toUTFTildaText( reference_fields[1] );
1198  }
1199  else
1200  {
1201  if( GetField( REFERENCE )->GetText().IsEmpty() )
1202  name1 = toUTFTildaText( m_prefix );
1203  else
1204  name1 = toUTFTildaText( GetField( REFERENCE )->GetText() );
1205  }
1206 
1207  wxString part_name = FROM_UTF8( GetLibId().GetLibItemName() );
1208 
1209  if( part_name.size() )
1210  {
1211  name2 = toUTFTildaText( part_name );
1212  }
1213  else
1214  {
1215  name2 = NULL_STRING;
1216  }
1217 
1218  if( fprintf( f, "$Comp\n" ) == EOF )
1219  return false;
1220 
1221  if( fprintf( f, "L %s %s\n", name2.c_str(), name1.c_str() ) == EOF )
1222  return false;
1223 
1224  // Generate unit number, convert and time stamp
1225  if( fprintf( f, "U %d %d %8.8lX\n", m_unit, m_convert, (unsigned long)m_TimeStamp ) == EOF )
1226  return false;
1227 
1228  // Save the position
1229  if( fprintf( f, "P %d %d\n", m_Pos.x, m_Pos.y ) == EOF )
1230  return false;
1231 
1232  /* If this is a complex hierarchy; save hierarchical references.
1233  * but for simple hierarchies it is not necessary.
1234  * the reference inf is already saved
1235  * this is useful for old Eeschema version compatibility
1236  */
1237  if( m_PathsAndReferences.GetCount() > 1 )
1238  {
1239  for( unsigned int ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
1240  {
1241  /*format:
1242  * AR Path="/140/2" Ref="C99" Part="1"
1243  * where 140 is the uid of the containing sheet
1244  * and 2 is the timestamp of this component.
1245  * (timestamps are actually 8 hex chars)
1246  * Ref is the conventional component reference for this 'path'
1247  * Part is the conventional component part selection for this 'path'
1248  */
1249  reference_fields = wxStringTokenize( m_PathsAndReferences[ii], delimiters );
1250 
1251  if( fprintf( f, "AR Path=\"%s\" Ref=\"%s\" Part=\"%s\" \n",
1252  TO_UTF8( reference_fields[0] ),
1253  TO_UTF8( reference_fields[1] ),
1254  TO_UTF8( reference_fields[2] ) ) == EOF )
1255  return false;
1256  }
1257  }
1258 
1259  // update the ugly field index, which I would like to see go away someday soon.
1260  for( unsigned i = 0; i<m_Fields.size(); ++i )
1261  {
1262  SCH_FIELD* fld = GetField( i );
1263  fld->SetId( i ); // we don't need field Ids, please be gone.
1264  }
1265 
1266  // Fixed fields:
1267  // Save mandatory fields even if they are blank,
1268  // because the visibility, size and orientation are set from libary editor.
1269  for( unsigned i = 0; i<MANDATORY_FIELDS; ++i )
1270  {
1271  SCH_FIELD* fld = GetField( i );
1272  if( !fld->Save( f ) )
1273  return false;
1274  }
1275 
1276  // User defined fields:
1277  // The *policy* about which user defined fields are part of a symbol is now
1278  // only in the dialog editors. No policy should be enforced here, simply
1279  // save all the user defined fields, they are present because a dialog editor
1280  // thought they should be. If you disagree, go fix the dialog editors.
1281  for( unsigned i = MANDATORY_FIELDS; i<m_Fields.size(); ++i )
1282  {
1283  SCH_FIELD* fld = GetField( i );
1284 
1285  if( !fld->Save( f ) )
1286  return false;
1287  }
1288 
1289  // Unit number, position, box ( old standard )
1290  if( fprintf( f, "\t%-4d %-4d %-4d\n", m_unit, m_Pos.x, m_Pos.y ) == EOF )
1291  return false;
1292 
1293  if( fprintf( f, "\t%-4d %-4d %-4d %-4d\n",
1295  return false;
1296 
1297  if( fprintf( f, "$EndComp\n" ) == EOF )
1298  return false;
1299 
1300  return true;
1301 }
Class SCH_FIELD instances are attached to a component and provide a place for the component's value...
Definition: sch_field.h:56
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes...
Definition: macros.h:53
int y2
Definition: transform.h:51
time_t m_TimeStamp
Time stamp used for logical links.
Definition: base_struct.h:169
SCH_FIELDS m_Fields
Variable length list of fields.
Definition: sch_component.h:91
wxArrayString m_PathsAndReferences
Defines the hierarchical path and reference of the component.
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors...
int x2
Definition: transform.h:50
bool Save(FILE *aFile) const override
Function Save writes the data structures for this object out to a FILE in "*.sch" format...
Definition: sch_field.cpp:314
int x1
Definition: transform.h:48
Field Reference of part, i.e. "IC21".
#define TO_UTF8(wxstring)
Macro TO_UTF8 converts a wxString to a UTF8 encoded C string for all wxWidgets build modes...
Definition: macros.h:47
int y1
Definition: transform.h:49
SCH_FIELD * GetField(int aFieldNdx) const
Function GetField returns a field.
std::string toUTFTildaText(const wxString &txt)
Function toUTFTildaText convert a wxString to UTF8 and replace any control characters with a ~...
wxString GetText(GRAPHIC_PINSHAPE shape)
Definition: pin_shape.cpp:33
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:82
#define NULL_STRING
const LIB_ID & GetLibId() const
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:83
void SetId(int aId)
Definition: sch_field.h:89
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is...
Definition: sch_component.h:86
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:90
void EDA_ITEM::SetBack ( EDA_ITEM aBack)
inlineinherited

Definition at line 212 of file base_struct.h.

Referenced by DHEAD::append(), DHEAD::insert(), SCH_EDIT_FRAME::PutDataInPreviousState(), and DHEAD::remove().

212 { Pback = aBack; }
EDA_ITEM * Pback
previous in linked list
Definition: base_struct.h:165
void EDA_ITEM::SetBrightened ( )
inlineinherited

Definition at line 229 of file base_struct.h.

References BRIGHTENED, and EDA_ITEM::SetFlags().

Referenced by SELECTION_TOOL::disambiguationMenu().

229 { SetFlags( BRIGHTENED ); }
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:253
#define BRIGHTENED
item is drawn with a bright contour
Definition: base_struct.h:137
void SCH_COMPONENT::SetConvert ( int  aConvert)

Definition at line 414 of file sch_component.cpp.

References m_convert, and EDA_ITEM::SetModified().

Referenced by SCH_EDIT_FRAME::ConvertPart(), and DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions().

415 {
416  if( m_convert != aConvert )
417  {
418  m_convert = aConvert;
419  SetModified();
420  }
421 }
void SetModified()
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:83
void SCH_COMPONENT::SetCurrentSheetPath ( const SCH_SHEET_PATH aSheetPath)
inline

Definition at line 435 of file sch_component.h.

Referenced by SCH_EDIT_FRAME::Load_Component().

436  {
437  m_currentSheetPath = aSheetPath;
438  }
const SCH_SHEET_PATH * m_currentSheetPath
A temporary sheet path is required to generate the correct reference designator string in complex hei...
void SCH_COMPONENT::SetFields ( const SCH_FIELDS aFields)
inline

Definition at line 330 of file sch_component.h.

Referenced by DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::EditSpiceModel(), and DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick().

331  {
332  m_Fields = aFields; // vector copying, length is changed possibly
333  }
SCH_FIELDS m_Fields
Variable length list of fields.
Definition: sch_component.h:91
void EDA_ITEM::SetFlags ( STATUS_FLAGS  aMask)
inlineinherited

Definition at line 253 of file base_struct.h.

Referenced by SCH_SCREEN::addConnectedItemsToBlock(), AddSegmentToDragList(), PCBNEW_CONTROL::AppendBoard(), PCB_EDIT_FRAME::AppendBoardFile(), PCB_EDIT_FRAME::Begin_DrawSegment(), FOOTPRINT_EDIT_FRAME::Begin_Edge_Module(), PCB_EDIT_FRAME::Begin_Route(), PCB_EDIT_FRAME::Begin_Zone(), PCB_EDIT_FRAME::BeginMoveDimensionText(), PCB_EDIT_FRAME::BeginMoveTarget(), SCH_EDIT_FRAME::BeginSegment(), PCB_EDIT_FRAME::Change_Side_Module(), SCH_EDIT_FRAME::ConvertPart(), CopyMarkedItems(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions(), LIB_PART::CopySelectedItems(), SCH_EDIT_FRAME::CreateBusBusEntry(), SCH_EDIT_FRAME::CreateBusWireEntry(), SCH_EDIT_FRAME::CreateNewImage(), SCH_EDIT_FRAME::CreateNewText(), LIB_EDIT_FRAME::CreatePin(), SCH_EDIT_FRAME::CreateSheet(), SCH_EDIT_FRAME::CreateSheetPin(), PCB_EDIT_FRAME::CreateTarget(), PCB_EDIT_FRAME::CreateTextePcb(), FOOTPRINT_EDIT_FRAME::CreateTextModule(), PCB_EDIT_FRAME::EditDimension(), LIB_PIN::EnableEditMode(), PCB_EDIT_FRAME::FlipTextePcb(), SCH_SCREEN::GetConnection(), PCB_BASE_FRAME::GlobalChange_PadSettings(), FOOTPRINT_EDIT_FRAME::HandleBlockEnd(), PCB_BASE_FRAME::Import_Pad_Settings(), SCH_EDIT_FRAME::ImportSheetPin(), SCH_JUNCTION::IsSelectStateChanged(), SCH_NO_CONNECT::IsSelectStateChanged(), SCH_MARKER::IsSelectStateChanged(), SCH_BUS_ENTRY_BASE::IsSelectStateChanged(), SCH_LINE::IsSelectStateChanged(), SCH_BITMAP::IsSelectStateChanged(), SCH_TEXT::IsSelectStateChanged(), IsSelectStateChanged(), SCH_SHEET::IsSelectStateChanged(), SCH_EDIT_FRAME::Load_Component(), PCB_BASE_FRAME::LoadModuleFromLibrary(), SCH_SCREEN::MarkConnections(), MarkItemsInBloc(), moveBitmap(), SCH_EDIT_FRAME::MoveImage(), SCH_EDIT_FRAME::OnConvertTextType(), SCH_EDIT_FRAME::OnCopySchematicItemRequest(), LIB_EDIT_FRAME::OnEditPin(), TARGET_PROPERTIES_DIALOG_EDITOR::OnOkClick(), SCH_EDIT_FRAME::OnSelectUnit(), PCB_EDIT_FRAME::Other_Layer_Route(), DRAWING_TOOL::PlaceText(), SCH_EDIT_FRAME::PrepareMoveItem(), LIB_EDIT_FRAME::Process_Special_Functions(), EDIT_TOOL::Properties(), SCH_EDIT_FRAME::PutDataInPreviousState(), SCH_EDIT_FRAME::RepeatDrawItem(), LIB_EDIT_FRAME::RepeatPinItem(), SCH_EDIT_FRAME::ReSizeSheet(), PCB_BASE_FRAME::Rotate_Module(), PCB_EDIT_FRAME::Rotate_Texte_Pcb(), SCH_SCREEN::SchematicCleanUp(), SCH_SCREEN::SelectBlockItems(), EDA_ITEM::SetBrightened(), LIB_PIN::SetConversion(), EDA_ITEM::SetHighlighted(), EDA_ITEM::SetModified(), LIB_PIN::SetNumber(), EDA_ITEM::SetSelected(), EDA_ITEM::SetWireImage(), PCB_EDIT_FRAME::Start_DragTrackSegmentAndKeepSlope(), PCB_EDIT_FRAME::Start_Move_DrawItem(), FOOTPRINT_EDIT_FRAME::Start_Move_EdgeMod(), PCB_EDIT_FRAME::Start_Move_Zone_Corner(), PCB_EDIT_FRAME::Start_Move_Zone_Drag_Outline_Edge(), PCB_EDIT_FRAME::Start_Move_Zone_Outlines(), PCB_EDIT_FRAME::StartMoveModule(), PCB_EDIT_FRAME::StartMoveOneNodeOrSegment(), PCB_BASE_FRAME::StartMovePad(), LIB_EDIT_FRAME::StartMovePin(), PCB_BASE_FRAME::StartMoveTexteModule(), PCB_EDIT_FRAME::StartMoveTextePcb(), DIALOG_PCB_TEXT_PROPERTIES::TransferDataFromWindow(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), and UndrawAndMarkSegmentsToDrag().

253 { m_Flags |= aMask; }
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:175
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 265 of file base_struct.h.

Referenced by SCH_EDIT_FRAME::OnFindSchematicItem(), and SCH_EDIT_FRAME::updateFindReplaceView().

265 { m_forceVisible = aEnable; }
bool m_forceVisible
Set to true to override the visibility setting of the item.
Definition: base_struct.h:172
void EDA_ITEM::SetHighlighted ( )
inlineinherited

Definition at line 228 of file base_struct.h.

References HIGHLIGHTED, and EDA_ITEM::SetFlags().

228 { SetFlags( HIGHLIGHTED ); }
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:253
#define HIGHLIGHTED
item is drawn in normal colors, when the rest is darkened
Definition: base_struct.h:136
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 171 of file sch_item_struct.h.

Referenced by Init(), SCH_FIELD::SCH_FIELD(), and SCH_NO_CONNECT::SCH_NO_CONNECT().

171 { m_Layer = aLayer; }
SCH_LAYER_ID m_Layer
void SCH_COMPONENT::SetLibId ( const LIB_ID aName,
PART_LIBS aLibs = NULL 
)

Definition at line 262 of file sch_component.cpp.

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

Referenced by DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions(), SCH_EDIT_FRAME::Load_Component(), and DIALOG_SYMBOL_REMAP::remapSymbolToLibTable().

263 {
264  if( m_lib_id != aLibId )
265  {
266  m_lib_id = aLibId;
267  SetModified();
268 
269  if( aLibs )
270  Resolve( aLibs );
271  else
272  m_part.reset();
273  }
274 }
void SetModified()
bool Resolve(PART_LIBS *aLibs)
Function Resolve [re-]assigns the current LIB_PART from aLibs which this component is based on...
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:93
void SCH_COMPONENT::SetLibId ( const LIB_ID aLibId,
SYMBOL_LIB_TABLE aSymLibTable 
)

Definition at line 277 of file sch_component.cpp.

References LIB_ID::GetLibItemName(), LIB_ID::GetLibNickname(), LIB_ALIAS::GetPart(), SYMBOL_LIB_TABLE::LoadSymbol(), m_lib_id, m_part, EDA_ITEM::SetModified(), and LIB_PART::SharedPtr().

278 {
279  if( m_lib_id != aLibId )
280  {
281  wxCHECK_RET( aSymLibTable, "No symbol library table provided." );
282 
283  m_lib_id = aLibId;
284  SetModified();
285 
286  LIB_ALIAS* alias = aSymLibTable->LoadSymbol( m_lib_id.GetLibNickname(),
288 
289  if( alias && alias->GetPart() )
290  m_part = alias->GetPart()->SharedPtr();
291  else
292  m_part.reset();
293  }
294 }
LIB_ALIAS * LoadSymbol(const wxString &aNickname, const wxString &aAliasName)
Function LoadSymbol.
void SetModified()
Part library alias object definition.
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:93
const UTF8 & GetLibItemName() const
Function GetLibItemName.
Definition: lib_id.h:129
PART_SPTR SharedPtr()
LIB_PART * GetPart() const
Function GetPart gets the shared LIB_PART.
const UTF8 & GetLibNickname() const
Function GetLibNickname.
Definition: lib_id.h:108
void EDA_ITEM::SetList ( DHEAD aList)
inlineinherited

Definition at line 214 of file base_struct.h.

Referenced by DHEAD::append(), DHEAD::insert(), and DHEAD::remove().

214 { m_List = aList; }
DHEAD * m_List
which DLIST I am on.
Definition: base_struct.h:166
void EDA_ITEM::SetModified ( )
inherited

Definition at line 102 of file base_struct.cpp.

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

Referenced by ClearAnnotation(), SCH_LINE::Move(), LIB_PIN::Move(), Move(), LIB_PART::RemoveDrawItem(), SetConvert(), LIB_PIN::SetLength(), SetLibId(), EDA_ITEM::SetModified(), LIB_FIELD::SetName(), LIB_PIN::SetName(), LIB_PIN::SetNameTextSize(), LIB_PIN::SetNumberTextSize(), LIB_PIN::SetOrientation(), LIB_PIN::SetPartNumber(), LIB_PIN::SetPinPosition(), LIB_PIN::SetShape(), SetTransform(), LIB_PIN::SetType(), SetUnit(), LIB_PIN::SetVisible(), and LIB_PIN::SetWidth().

103 {
104  SetFlags( IS_CHANGED );
105 
106  // If this a child object, then the parent modification state also needs to be set.
107  if( m_Parent )
109 }
void SetModified()
EDA_ITEM * m_Parent
Linked list: Link (parent struct)
Definition: base_struct.h:168
#define IS_CHANGED
std::function passed to nested users by ref, avoids copying std::function
Definition: base_struct.h:109
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:253
void EDA_ITEM::SetNext ( EDA_ITEM aNext)
inlineinherited

Definition at line 211 of file base_struct.h.

Referenced by DHEAD::append(), DHEAD::insert(), SCH_EDIT_FRAME::PutDataInPreviousState(), and DHEAD::remove().

211 { Pnext = aNext; }
EDA_ITEM * Pnext
next in linked list
Definition: base_struct.h:164
void SCH_COMPONENT::SetOrientation ( int  aOrientation)

Function SetOrientation computes the new transform matrix based on aOrientation for the component which is applied to the current transform.

Parameters
aOrientationThe orientation to apply to the transform.

Definition at line 979 of file sch_component.cpp.

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 DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions(), GetOrientation(), MirrorX(), MirrorY(), Rotate(), and DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp().

980 {
981  TRANSFORM temp = TRANSFORM();
982  bool transform = false;
983 
984  switch( aOrientation )
985  {
986  case CMP_ORIENT_0:
987  case CMP_NORMAL: // default transform matrix
988  m_transform.x1 = 1;
989  m_transform.y2 = -1;
991  break;
992 
993  case CMP_ROTATE_COUNTERCLOCKWISE: // Rotate + (incremental rotation)
994  temp.x1 = temp.y2 = 0;
995  temp.y1 = 1;
996  temp.x2 = -1;
997  transform = true;
998  break;
999 
1000  case CMP_ROTATE_CLOCKWISE: // Rotate - (incremental rotation)
1001  temp.x1 = temp.y2 = 0;
1002  temp.y1 = -1;
1003  temp.x2 = 1;
1004  transform = true;
1005  break;
1006 
1007  case CMP_MIRROR_Y: // Mirror Y (incremental rotation)
1008  temp.x1 = -1;
1009  temp.y2 = 1;
1010  temp.y1 = temp.x2 = 0;
1011  transform = true;
1012  break;
1013 
1014  case CMP_MIRROR_X: // Mirror X (incremental rotation)
1015  temp.x1 = 1;
1016  temp.y2 = -1;
1017  temp.y1 = temp.x2 = 0;
1018  transform = true;
1019  break;
1020 
1021  case CMP_ORIENT_90:
1024  break;
1025 
1026  case CMP_ORIENT_180:
1030  break;
1031 
1032  case CMP_ORIENT_270:
1035  break;
1036 
1037  case ( CMP_ORIENT_0 + CMP_MIRROR_X ):
1040  break;
1041 
1042  case ( CMP_ORIENT_0 + CMP_MIRROR_Y ):
1045  break;
1046 
1047  case ( CMP_ORIENT_90 + CMP_MIRROR_X ):
1050  break;
1051 
1052  case ( CMP_ORIENT_90 + CMP_MIRROR_Y ):
1055  break;
1056 
1057  case ( CMP_ORIENT_180 + CMP_MIRROR_X ):
1060  break;
1061 
1062  case ( CMP_ORIENT_180 + CMP_MIRROR_Y ):
1065  break;
1066 
1067  case ( CMP_ORIENT_270 + CMP_MIRROR_X ):
1070  break;
1071 
1072  case ( CMP_ORIENT_270 + CMP_MIRROR_Y ):
1075  break;
1076 
1077  default:
1078  transform = false;
1079  wxMessageBox( wxT( "SetRotateMiroir() error: ill value" ) );
1080  break;
1081  }
1082 
1083  if( transform )
1084  {
1085  /* The new matrix transform is the old matrix transform modified by the
1086  * requested transformation, which is the temp transform (rot,
1087  * mirror ..) in order to have (in term of matrix transform):
1088  * transform coord = new_m_transform * coord
1089  * where transform coord is the coord modified by new_m_transform from
1090  * the initial value coord.
1091  * new_m_transform is computed (from old_m_transform and temp) to
1092  * have:
1093  * transform coord = old_m_transform * temp
1094  */
1095  TRANSFORM newTransform;
1096 
1097  newTransform.x1 = m_transform.x1 * temp.x1 + m_transform.x2 * temp.y1;
1098  newTransform.y1 = m_transform.y1 * temp.x1 + m_transform.y2 * temp.y1;
1099  newTransform.x2 = m_transform.x1 * temp.x2 + m_transform.x2 * temp.y2;
1100  newTransform.y2 = m_transform.y1 * temp.x2 + m_transform.y2 * temp.y2;
1101  m_transform = newTransform;
1102  }
1103 }
int y2
Definition: transform.h:51
int x2
Definition: transform.h:50
int x1
Definition: transform.h:48
int y1
Definition: transform.h:49
Class for tranforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:90
void SetOrientation(int aOrientation)
Function SetOrientation computes the new transform matrix based on aOrientation for the component whi...
void EDA_ITEM::SetParent ( EDA_ITEM aParent)
inlineinherited

Definition at line 213 of file base_struct.h.

Referenced by MODULE::Add(), BOARD::Add(), BOARD_NETLIST_UPDATER::addNewComponent(), LIB_FIELD::Copy(), SCH_EDIT_FRAME::copyBlockItems(), CopyMarkedItems(), SCH_EDIT_FRAME::CreateSheet(), DIALOG_LIB_EDIT_PIN::DIALOG_LIB_EDIT_PIN(), PCB_EDIT_FRAME::Exchange_Module(), PCB_IO::FootprintSave(), DISPLAY_FOOTPRINTS_FRAME::Get_Module(), DIALOG_MODULE_MODULE_EDITOR::initModeditProperties(), DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties(), LIB_PART::LIB_PART(), SCH_SHEET::Load(), FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD(), SCH_LEGACY_PLUGIN::loadHierarchy(), LIB_EDIT_FRAME::LoadOneSymbol(), MODULE::MODULE(), DIALOG_MODULE_BOARD_EDITOR::OnEditReference(), DIALOG_MODULE_BOARD_EDITOR::OnEditValue(), DIALOG_LIB_EDIT_PIN::OnPaintShowPanel(), MODULE::operator=(), operator=(), PCB_PARSER::parseMODULE_unchecked(), MODULE_EDITOR_TOOLS::PasteItems(), FOOTPRINT_EDIT_FRAME::Process_Special_Functions(), FOOTPRINT_PREVIEW_PANEL::renderFootprint(), BOARD_NETLIST_UPDATER::replaceComponent(), BOARD::ReplaceNetlist(), FOOTPRINT_EDIT_FRAME::restoreLastFootprint(), PCB_BASE_EDIT_FRAME::SaveCopyInUndoList(), SaveCopyOfZones(), SCH_COMPONENT(), SCH_SHEET::SCH_SHEET(), SCH_SHEET_PIN::SCH_SHEET_PIN(), LIB_PART::SetFields(), SetSchItemParent(), PCB_EDIT_FRAME::StartMoveModule(), BOARD_ITEM::SwapData(), SwapData(), and SCH_SHEET::SwapData().

213 { m_Parent = aParent; }
EDA_ITEM * m_Parent
Linked list: Link (parent struct)
Definition: base_struct.h:168
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 566 of file sch_component.h.

References Move().

566 { Move( aPosition - m_Pos ); }
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
void Move(const wxPoint &aMoveVector) override
Function Move moves the item by aMoveVector to a new position.
void SCH_COMPONENT::SetPrefix ( const wxString &  aPrefix)
inline

Definition at line 213 of file sch_component.h.

213 { m_prefix = aPrefix; }
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is...
Definition: sch_component.h:86
void SCH_COMPONENT::SetRef ( const SCH_SHEET_PATH sheet,
const wxString &  ref 
)

Set the reference, for the given sheet path.

Definition at line 615 of file sch_component.cpp.

References abs, AddHierarchicalReference(), GetField(), GetPath(), EDA_TEXT::GetText(), EDA_TEXT::GetTextPos(), IsReferenceStringValid(), m_PathsAndReferences, m_Pos, m_prefix, m_unit, REFERENCE, EDA_TEXT::SetText(), EDA_TEXT::SetTextPos(), wxPoint::x, and wxPoint::y.

Referenced by SCH_REFERENCE::Annotate(), SCH_SHEET_PATH::AnnotatePowerSymbols(), GetRef(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick(), SCH_COMPONENT(), SCH_REFERENCE::SCH_REFERENCE(), and DIALOG_SCH_EDIT_ONE_FIELD::UpdateField().

616 {
617  wxString path = GetPath( sheet );
618 
619  bool notInArray = true;
620 
621  wxString h_path, h_ref;
622  wxStringTokenizer tokenizer;
623  wxString separators( wxT( " " ) );
624 
625  // check to see if it is already there before inserting it
626  for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
627  {
628  tokenizer.SetString( m_PathsAndReferences[ii], separators );
629  h_path = tokenizer.GetNextToken();
630 
631  if( h_path.Cmp( path ) == 0 )
632  {
633  // just update the reference text, not the timestamp.
634  h_ref = h_path + wxT( " " ) + ref;
635  h_ref += wxT( " " );
636  tokenizer.GetNextToken(); // Skip old reference
637  h_ref += tokenizer.GetNextToken(); // Add part selection
638 
639  // Add the part selection
640  m_PathsAndReferences[ii] = h_ref;
641  notInArray = false;
642  }
643  }
644 
645  if( notInArray )
646  AddHierarchicalReference( path, ref, m_unit );
647 
648  SCH_FIELD* rf = GetField( REFERENCE );
649 
650  if( rf->GetText().IsEmpty()
651  || ( abs( rf->GetTextPos().x - m_Pos.x ) +
652  abs( rf->GetTextPos().y - m_Pos.y ) > 10000 ) )
653  {
654  // move it to a reasonable position
655  rf->SetTextPos( m_Pos + wxPoint( 50, 50 ) );
656  }
657 
658  rf->SetText( ref ); // for drawing.
659 
660  // Reinit the m_prefix member if needed
661  wxString prefix = ref;
662 
663  if( IsReferenceStringValid( prefix ) )
664  {
665  while( prefix.Last() == '?' || isdigit( prefix.Last() ) )
666  prefix.RemoveLast();
667  }
668  else
669  {
670  prefix = wxT( "U" ); // Set to default ref prefix
671  }
672 
673  if( m_prefix != prefix )
674  m_prefix = prefix;
675 }
Class SCH_FIELD instances are attached to a component and provide a place for the component's value...
Definition: sch_field.h:56
wxString GetPath(const SCH_SHEET_PATH *sheet) const
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
wxArrayString m_PathsAndReferences
Defines the hierarchical path and reference of the component.
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:77
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:223
#define abs(a)
Definition: auxiliary.h:84
Field Reference of part, i.e. "IC21".
SCH_FIELD * GetField(int aFieldNdx) const
Function GetField returns a field.
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:130
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:82
void AddHierarchicalReference(const wxString &aPath, const wxString &aRef, int aMulti)
Function AddHierarchicalReference adds a full hierarchical reference (path + local reference) ...
static bool IsReferenceStringValid(const wxString &aReferenceString)
Function IsReferenceStringValid (static) Tests for an acceptable reference string An acceptable refer...
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is...
Definition: sch_component.h:86
virtual void SetText(const wxString &aText)
Definition: eda_text.h:141
void EDA_ITEM::SetSelected ( )
inlineinherited

Definition at line 227 of file base_struct.h.

References SELECTED, and EDA_ITEM::SetFlags().

Referenced by SELECTION_TOOL::selectVisually().

227 { SetFlags( SELECTED ); }
#define SELECTED
Definition: base_struct.h:120
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:253
void EDA_ITEM::SetStatus ( STATUS_FLAGS  aStatus)
inlineinherited
void SCH_ITEM::SetStoredPos ( wxPoint  aPos)
inlineinherited

Definition at line 157 of file sch_item_struct.h.

Referenced by SCH_EDIT_FRAME::PrepareMoveItem().

157 { m_storedPos = aPos; }
wxPoint m_storedPos
a temporary variable used in some move commands to store a initial pos (of the item or mouse cursor) ...
void SCH_COMPONENT::SetTimeStamp ( time_t  aNewTimeStamp)

Function SetTimeStamp changes the time stamp to aNewTimeStamp updates the reference path.

See also
m_PathsAndReferences
Parameters
aNewTimeStamp= new time stamp

Definition at line 678 of file sch_component.cpp.

References m_PathsAndReferences, EDA_ITEM::m_TimeStamp, and EDA_ITEM::SetTimeStamp().

Referenced by SCH_EDIT_FRAME::OnCopySchematicItemRequest(), and SCH_COMPONENT().

679 {
680  wxString string_timestamp, string_oldtimestamp;
681 
682  string_timestamp.Printf( wxT( "%08lX" ), (long unsigned) aNewTimeStamp );
683  string_oldtimestamp.Printf( wxT( "%08lX" ), (long unsigned) m_TimeStamp );
684  EDA_ITEM::SetTimeStamp( aNewTimeStamp );
685 
686  for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
687  {
688  m_PathsAndReferences[ii].Replace( string_oldtimestamp.GetData(),
689  string_timestamp.GetData() );
690  }
691 }
time_t m_TimeStamp
Time stamp used for logical links.
Definition: base_struct.h:169
wxArrayString m_PathsAndReferences
Defines the hierarchical path and reference of the component.
void SetTimeStamp(time_t aNewTimeStamp)
Definition: base_struct.h:203
void SCH_COMPONENT::SetTransform ( const TRANSFORM aTransform)

Definition at line 424 of file sch_component.cpp.

References m_transform, and EDA_ITEM::SetModified().

425 {
426  if( m_transform != aTransform )
427  {
428  m_transform = aTransform;
429  SetModified();
430  }
431 }
void SetModified()
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:90
void SCH_COMPONENT::SetUnit ( int  aUnit)

change the unit id to aUnit has maening only for multiple parts per package Also set the modified flag bit

Parameters
aUnit= the new unit Id

Definition at line 399 of file sch_component.cpp.

References m_unit, and EDA_ITEM::SetModified().

Referenced by SCH_REFERENCE::Annotate(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions(), and SCH_EDIT_FRAME::OnSelectUnit().

400 {
401  if( m_unit != aUnit )
402  {
403  m_unit = aUnit;
404  SetModified();
405  }
406 }
void SetModified()
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:82
void SCH_COMPONENT::SetUnitSelection ( SCH_SHEET_PATH aSheet,
int  aUnitSelection 
)

Definition at line 722 of file sch_component.cpp.

References AddHierarchicalReference(), GetPath(), m_PathsAndReferences, and m_prefix.

Referenced by SCH_REFERENCE::Annotate(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions(), and SCH_EDIT_FRAME::OnSelectUnit().

723 {
724  wxString path = GetPath( aSheet );
725 
726  bool notInArray = true;
727 
728  wxString h_path, h_ref;
729  wxStringTokenizer tokenizer;
730  wxString separators( wxT( " " ) );
731 
732  //check to see if it is already there before inserting it
733  for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
734  {
735  tokenizer.SetString( m_PathsAndReferences[ii], separators );
736  h_path = tokenizer.GetNextToken();
737 
738  if( h_path.Cmp( path ) == 0 )
739  {
740  //just update the unit selection.
741  h_ref = h_path + wxT( " " );
742  h_ref += tokenizer.GetNextToken(); // Add reference
743  h_ref += wxT( " " );
744  h_ref << aUnitSelection; // Add part selection
745 
746  // Ann the part selection
747  m_PathsAndReferences[ii] = h_ref;
748  notInArray = false;
749  }
750  }