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)
 
const LIB_IDGetLibId () const
 
PART_REFGetPartRef ()
 
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...
 
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)
 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)
 
LAYERSCH_ID GetLayer () const
 Function GetLayer returns the layer this item is on. More...
 
void SetLayer (LAYERSCH_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

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

Member Enumeration Documentation

Enumerator
AUTOPLACED_NO 
AUTOPLACED_AUTO 
AUTOPLACED_MANUAL 

Definition at line 73 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:96
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
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:76
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
SCH_FIELD * FindField(const wxString &aFieldName)
Function FindField searches for SCH_FIELD with aFieldName and returns it if found, else NULL.
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:92
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:81
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:82
AUTOPLACED m_fieldsAutoplaced
indicates status of field autoplacement
Definition: sch_component.h:96
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is...
Definition: sch_component.h:85
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:90
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:76
std::vector< bool > m_isDangling
One isDangling per pin.
Definition: sch_component.h:94
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:92
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:81
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:82
AUTOPLACED m_fieldsAutoplaced
indicates status of field autoplacement
Definition: sch_component.h:96
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is...
Definition: sch_component.h:85
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:89
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType)
SCH_COMPONENT::~SCH_COMPONENT ( )
inline

Definition at line 145 of file sch_component.h.

145 { }

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

References m_Fields.

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

727 {
728  int newNdx = m_Fields.size();
729 
730  m_Fields.push_back( aField );
731  return &m_Fields[newNdx];
732 }
SCH_FIELDS m_Fields
Variable length list of fields.
Definition: sch_component.h:90
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 457 of file sch_component.cpp.

References m_PathsAndReferences.

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

460 {
461  wxString h_path, h_ref;
462  wxStringTokenizer tokenizer;
463  wxString separators( wxT( " " ) );
464 
465  // Search for an existing path and remove it if found (should not occur)
466  for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
467  {
468  tokenizer.SetString( m_PathsAndReferences[ii], separators );
469  h_path = tokenizer.GetNextToken();
470 
471  if( h_path.Cmp( aPath ) == 0 )
472  {
473  m_PathsAndReferences.RemoveAt( ii );
474  ii--;
475  }
476  }
477 
478  h_ref = aPath + wxT( " " ) + aRef;
479  h_ref << wxT( " " ) << aMulti;
480  m_PathsAndReferences.Add( h_ref );
481 }
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 355 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().

356  {
357  if( GetFieldsAutoplaced() )
359  }
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:96
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 804 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().

805 {
806  bool keepMulti = false;
807  wxArrayString reference_fields;
808 
809  static const wxChar separators[] = wxT( " " );
810 
811  PART_SPTR part = m_part.lock();
812 
813  if( part && part->UnitsLocked() )
814  keepMulti = true;
815 
816  // Build a reference with no annotation,
817  // i.e. a reference ended by only one '?'
818  wxString defRef = m_prefix;
819 
820  if( IsReferenceStringValid( defRef ) )
821  {
822  while( defRef.Last() == '?' )
823  defRef.RemoveLast();
824  }
825  else
826  { // This is a malformed reference: reinit this reference
827  m_prefix = defRef = wxT("U"); // Set to default ref prefix
828  }
829 
830  defRef.Append( wxT( "?" ) );
831 
832  wxString multi = wxT( "1" );
833 
834  // For components with units locked,
835  // we cannot remove all annotations: part selection must be kept
836  // For all components: if aSheetPath is not NULL,
837  // remove annotation only for the given path
838  if( keepMulti || aSheetPath )
839  {
840  wxString NewHref;
841  wxString path;
842 
843  if( aSheetPath )
844  path = GetPath( aSheetPath );
845 
846  for( unsigned int ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
847  {
848  // Break hierarchical reference in path, ref and multi selection:
849  reference_fields = wxStringTokenize( m_PathsAndReferences[ii], separators );
850 
851  if( aSheetPath == NULL || reference_fields[0].Cmp( path ) == 0 )
852  {
853  if( keepMulti ) // Get and keep part selection
854  multi = reference_fields[2];
855 
856  NewHref = reference_fields[0];
857  NewHref << wxT( " " ) << defRef << wxT( " " ) << multi;
858  m_PathsAndReferences[ii] = NewHref;
859  }
860  }
861  }
862  else
863  {
864  // Clear reference strings, but does not free memory because a new annotation
865  // will reuse it
866  m_PathsAndReferences.Empty();
867  m_unit = 1;
868  }
869 
870  // These 2 changes do not work in complex hierarchy.
871  // When a clear annotation is made, the calling function must call a
872  // UpdateAllScreenReferences for the active sheet.
873  // But this call cannot made here.
874  m_Fields[REFERENCE].SetText( defRef ); //for drawing.
875 
876  SetModified();
877 }
void SetModified()
wxString GetPath(const SCH_SHEET_PATH *sheet) const
SCH_FIELDS m_Fields
Variable length list of fields.
Definition: sch_component.h:90
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:92
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:81
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:85
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 335 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:96
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(), 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 2092 of file sch_component.cpp.

References GetConnectionPoints().

2093 {
2094  std::vector< wxPoint > pts;
2095 
2096  GetConnectionPoints( pts );
2097 
2098  for( size_t i = 0; i < pts.size(); i++ )
2099  {
2100  if( pts[i] == aPosition )
2101  return true;
2102  }
2103 
2104  return false;
2105 }
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 383 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().

385  {
386  Draw( aPanel, aDC, aOffset, aDrawMode, aColor, true );
387  }
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 388 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.

391 {
392  auto opts = PART_DRAW_OPTIONS::Default();
393  opts.draw_mode = aDrawMode;
394  opts.color = aColor;
395  opts.transform = m_transform;
396  opts.show_pin_text = aDrawPinText;
397  opts.draw_visible_fields = false;
398  opts.draw_hidden_fields = false;
399 
400  if( PART_SPTR part = m_part.lock() )
401  {
402  // Draw pin targets if part is being dragged
403  bool dragging = aPanel->GetScreen()->GetCurItem() == this && aPanel->IsMouseCaptured();
404 
405  if( !dragging )
406  {
407  opts.dangling = m_isDangling;
408  }
409 
410  part->Draw( aPanel, aDC, m_Pos + aOffset, m_unit, m_convert, opts );
411  }
412  else // Use dummy() part if the actual cannot be found.
413  {
414  dummy()->Draw( aPanel, aDC, m_Pos + aOffset, 0, 0, opts );
415  }
416 
417  SCH_FIELD* field = GetField( REFERENCE );
418 
419  if( field->IsVisible() && !field->IsMoving() )
420  {
421  field->Draw( aPanel, aDC, aOffset, aDrawMode );
422  }
423 
424  for( int ii = VALUE; ii < GetFieldCount(); ii++ )
425  {
426  field = GetField( ii );
427 
428  if( field->IsMoving() )
429  continue;
430 
431  field->Draw( aPanel, aDC, aOffset, aDrawMode );
432  }
433 
434 #if 0
435  // Only for testing purposes, draw the component bounding box
436  {
438  GRRect( aPanel->GetClipBox(), aDC, boundingBox, 0, BROWN );
439 #if 1
440  if( GetField( REFERENCE )->IsVisible() )
441  {
442  boundingBox = GetField( REFERENCE )->GetBoundingBox();
443  GRRect( aPanel->GetClipBox(), aDC, boundingBox, 0, BROWN );
444  }
445 
446  if( GetField( VALUE )->IsVisible() )
447  {
448  boundingBox = GetField( VALUE )->GetBoundingBox();
449  GRRect( aPanel->GetClipBox(), aDC, boundingBox, 0, BROWN );
450  }
451 #endif
452  }
453 #endif
454 }
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:76
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:94
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:92
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:81
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:82
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:89
Definition: colors.h:62
SCH_FIELD * SCH_COMPONENT::FindField ( const wxString &  aFieldName)

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

Definition at line 735 of file sch_component.cpp.

References m_Fields.

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

736 {
737  for( unsigned i = 0; i<m_Fields.size(); ++i )
738  {
739  if( aFieldName == m_Fields[i].GetName( false ) )
740  return &m_Fields[i];
741  }
742 
743  return NULL;
744 }
SCH_FIELDS m_Fields
Variable length list of fields.
Definition: sch_component.h:90
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...
EDA_RECT SCH_COMPONENT::GetBodyBoundingBox ( ) const

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

Definition at line 1519 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<().

1520 {
1521  EDA_RECT bBox;
1522 
1523  if( PART_SPTR part = m_part.lock() )
1524  {
1525  bBox = part->GetBodyBoundingBox( m_unit, m_convert );
1526  }
1527  else
1528  {
1529  bBox = dummy()->GetBodyBoundingBox( m_unit, m_convert );
1530  }
1531 
1532  int x0 = bBox.GetX();
1533  int xm = bBox.GetRight();
1534 
1535  // We must reverse Y values, because matrix orientation
1536  // suppose Y axis normal for the library items coordinates,
1537  // m_transform reverse Y values, but bBox is already reversed!
1538  int y0 = -bBox.GetY();
1539  int ym = -bBox.GetBottom();
1540 
1541  // Compute the real Boundary box (rotated, mirrored ...)
1542  int x1 = m_transform.x1 * x0 + m_transform.y1 * y0;
1543  int y1 = m_transform.x2 * x0 + m_transform.y2 * y0;
1544  int x2 = m_transform.x1 * xm + m_transform.y1 * ym;
1545  int y2 = m_transform.x2 * xm + m_transform.y2 * ym;
1546 
1547  // H and W must be > 0:
1548  if( x2 < x1 )
1549  std::swap( x2, x1 );
1550 
1551  if( y2 < y1 )
1552  std::swap( y2, y1 );
1553 
1554  bBox.SetX( x1 );
1555  bBox.SetY( y1 );
1556  bBox.SetWidth( x2 - x1 );
1557  bBox.SetHeight( y2 - y1 );
1558 
1559  bBox.Offset( m_Pos );
1560  return bBox;
1561 }
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:76
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:92
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:81
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:82
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:89
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 1564 of file sch_component.cpp.

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

Referenced by Draw(), and IsSelectStateChanged().

1565 {
1566  EDA_RECT bbox = GetBodyBoundingBox();
1567 
1568  for( size_t i = 0; i < m_Fields.size(); i++ )
1569  {
1570  bbox.Merge( m_Fields[i].GetBoundingBox() );
1571  }
1572 
1573  return bbox;
1574 }
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:90
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 147 of file sch_component.h.

Referenced by operator=().

148  {
149  return wxT( "SCH_COMPONENT" );
150  }
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 1819 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().

1820 {
1821  if( PART_SPTR part = m_part.lock() )
1822  {
1823  for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
1824  {
1825  wxCHECK_RET( pin->Type() == LIB_PIN_T,
1826  wxT( "GetNextPin() did not return a pin object. Bad programmer!" ) );
1827 
1828  // Skip items not used for this part.
1829  if( m_unit && pin->GetUnit() && ( pin->GetUnit() != m_unit ) )
1830  continue;
1831 
1832  if( m_convert && pin->GetConvert() && ( pin->GetConvert() != m_convert ) )
1833  continue;
1834 
1835  // Calculate the pin position relative to the component position and orientation.
1836  aPoints.push_back( m_transform.TransformCoordinate( pin->GetPosition() ) + m_Pos );
1837  }
1838  }
1839  else
1840  {
1841  wxCHECK_RET( 0,
1842  wxT( "Cannot add connection points to list. Cannot find component <" ) +
1843  FROM_UTF8( GetLibId().GetLibItemName() ) +
1844  wxT( "> in any of the loaded libraries." ) );
1845  }
1846 }
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:76
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:92
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:81
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:82
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:89
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 1849 of file sch_component.cpp.

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

Referenced by SCH_SCREEN::GetPin().

1850 {
1851  if( PART_SPTR part = m_part.lock() )
1852  {
1853  // Calculate the position relative to the component.
1854  wxPoint libPosition = aPosition - m_Pos;
1855 
1856  return part->LocateDrawItem( m_unit, m_convert, aType, libPosition, m_transform );
1857  }
1858 
1859  return NULL;
1860 }
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:76
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:92
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:81
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:82
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:89
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 1691 of file sch_component.cpp.

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

1692 {
1693  if( PART_SPTR part = m_part.lock() )
1694  {
1695  for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
1696  {
1697  wxASSERT( pin->Type() == LIB_PIN_T );
1698 
1699  if( pin->GetUnit() && m_unit && ( m_unit != pin->GetUnit() ) )
1700  continue;
1701 
1702  if( pin->GetConvert() && m_convert && ( m_convert != pin->GetConvert() ) )
1703  continue;
1704 
1705  DANGLING_END_ITEM item( PIN_END, pin, GetPinPhysicalPosition( pin ) );
1706  aItemList.push_back( item );
1707  }
1708  }
1709 }
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:92
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:81
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:82
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 700 of file sch_component.cpp.

References m_Fields.

Referenced by 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(), NETLIST_EXPORTER_GENERIC::makeComponents(), 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(), 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().

701 {
702  const SCH_FIELD* field;
703 
704  if( (unsigned) aFieldNdx < m_Fields.size() )
705  field = &m_Fields[aFieldNdx];
706  else
707  field = NULL;
708 
709  wxASSERT( field );
710 
711  // use cast to remove const-ness
712  return (SCH_FIELD*) field;
713 }
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:90
int SCH_COMPONENT::GetFieldCount ( ) const
inline

Function GetFieldCount returns the number of fields in this component.

Definition at line 323 of file sch_component.h.

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

323 { return (int)m_Fields.size(); }
SCH_FIELDS m_Fields
Variable length list of fields.
Definition: sch_component.h:90
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 716 of file sch_component.cpp.

References m_Fields.

Referenced by AUTOPLACER::AUTOPLACER().

717 {
718  for( SCH_FIELD& each_field : m_Fields )
719  {
720  if( !aVisibleOnly || ( each_field.IsVisible() && !each_field.IsVoid() ) )
721  aVector.push_back( &each_field );
722  }
723 }
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:90
AUTOPLACED SCH_COMPONENT::GetFieldsAutoplaced ( ) const
inline

Function GetFieldsAutoplaced returns whether the fields are autoplaced.

Definition at line 329 of file sch_component.h.

References m_fieldsAutoplaced.

Referenced by AutoAutoplaceFields().

329 { return m_fieldsAutoplaced; }
AUTOPLACED m_fieldsAutoplaced
indicates status of field autoplacement
Definition: sch_component.h:96
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 1620 of file sch_component.cpp.

1621 {
1622  return add_component_xpm;
1623 }
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 1577 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().

1578 {
1579  // part and alias can differ if alias is not the root
1580  if( PART_SPTR part = m_part.lock() )
1581  {
1582  LIB_ALIAS* alias = part->GetAlias( FROM_UTF8( GetLibId().GetLibItemName() ) );
1583 
1584  if( !alias )
1585  return;
1586 
1587  if( m_currentSheetPath )
1588  aList.push_back( MSG_PANEL_ITEM( _( "Reference" ),
1590  DARKCYAN ) );
1591 
1592  wxString msg = part->IsPower() ? _( "Power symbol" ) : _( "Value" );
1593 
1594  aList.push_back( MSG_PANEL_ITEM( msg, GetField( VALUE )->GetShownText(), DARKCYAN ) );
1595 
1596  // Display component reference in library and library
1597  aList.push_back( MSG_PANEL_ITEM( _( "Component" ), FROM_UTF8( GetLibId().GetLibItemName() ),
1598  BROWN ) );
1599 
1600  if( alias->GetName() != part->GetName() )
1601  aList.push_back( MSG_PANEL_ITEM( _( "Alias of" ), part->GetName(), BROWN ) );
1602 
1603  aList.push_back( MSG_PANEL_ITEM( _( "Library" ), alias->GetLibraryName(), BROWN ) );
1604 
1605  // Display the current associated footprint, if exists.
1606  if( !GetField( FOOTPRINT )->IsVoid() )
1607  msg = GetField( FOOTPRINT )->GetShownText();
1608  else
1609  msg = _( "<Unknown>" );
1610 
1611  aList.push_back( MSG_PANEL_ITEM( _( "Footprint" ), msg, DARKRED ) );
1612 
1613  // Display description of the component, and keywords found in lib
1614  aList.push_back( MSG_PANEL_ITEM( _( "Description" ), alias->GetDescription(), DARKCYAN ) );
1615  aList.push_back( MSG_PANEL_ITEM( _( "Key Words" ), alias->GetKeyWords(), DARKCYAN ) );
1616  }
1617 }
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:92
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 1938 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().

1940 {
1941  if( PART_SPTR part = m_part.lock() )
1942  {
1943  for( LIB_PIN* pin = part->GetNextPin(); pin; pin = part->GetNextPin( pin ) )
1944  {
1945  wxASSERT( pin->Type() == LIB_PIN_T );
1946 
1947  if( pin->GetUnit() && ( pin->GetUnit() != GetUnitSelection( aSheetPath ) ) )
1948  continue;
1949 
1950  if( pin->GetConvert() && ( pin->GetConvert() != GetConvert() ) )
1951  continue;
1952 
1953  wxPoint pos = GetTransform().TransformCoordinate( pin->GetPosition() ) + m_Pos;
1954 
1955  NETLIST_OBJECT* item = new NETLIST_OBJECT();
1956  item->m_SheetPathInclude = *aSheetPath;
1957  item->m_Comp = (SCH_ITEM*) pin;
1958  item->m_SheetPath = *aSheetPath;
1959  item->m_Type = NET_PIN;
1960  item->m_Link = (SCH_ITEM*) this;
1961  item->m_ElectricalPinType = pin->GetType();
1962  item->m_PinNum = pin->GetNumber();
1963  item->m_Label = pin->GetName();
1964  item->m_Start = item->m_End = pos;
1965 
1966  aNetListItems.push_back( item );
1967 
1968  if( pin->IsPowerConnection() )
1969  {
1970  // There is an associated PIN_LABEL.
1971  item = new NETLIST_OBJECT();
1972  item->m_SheetPathInclude = *aSheetPath;
1973  item->m_Comp = NULL;
1974  item->m_SheetPath = *aSheetPath;
1975  item->m_Type = NET_PINLABEL;
1976  item->m_Label = pin->GetName();
1977  item->m_Start = pos;
1978  item->m_End = item->m_Start;
1979 
1980  aNetListItems.push_back( item );
1981  }
1982  }
1983  }
1984 }
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:76
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:92
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 1007 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().

1008 {
1009  int type_rotate = CMP_ORIENT_0;
1010  TRANSFORM transform;
1011  int ii;
1012 
1013  #define ROTATE_VALUES_COUNT 12
1014 
1015  // list of all possibilities, but only the first 8 are actually used
1016  int rotate_value[ROTATE_VALUES_COUNT] =
1017  {
1023  CMP_MIRROR_Y + CMP_ORIENT_180, CMP_MIRROR_Y + CMP_ORIENT_270
1024  };
1025 
1026  // Try to find the current transform option:
1027  transform = m_transform;
1028 
1029  for( ii = 0; ii < ROTATE_VALUES_COUNT; ii++ )
1030  {
1031  type_rotate = rotate_value[ii];
1032  SetOrientation( type_rotate );
1033 
1034  if( transform == m_transform )
1035  return type_rotate;
1036  }
1037 
1038  // Error: orientation not found in list (should not happen)
1039  wxMessageBox( wxT( "Component orientation matrix internal error" ) );
1040  m_transform = transform;
1041 
1042  return CMP_NORMAL;
1043 }
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:89
void SetOrientation(int aOrientation)
Function SetOrientation computes the new transform matrix based on aOrientation for the component whi...
PART_REF& SCH_COMPONENT::GetPartRef ( )
inline

Definition at line 167 of file sch_component.h.

References m_part.

Referenced by SCH_SCREEN::GetPin().

167 { return m_part; }
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:92
wxString SCH_COMPONENT::GetPath ( const SCH_SHEET_PATH sheet) const

Definition at line 484 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().

485 {
486  wxCHECK_MSG( sheet != NULL, wxEmptyString,
487  wxT( "Cannot get component path with invalid sheet object." ) );
488 
489  wxString str;
490 
491  str.Printf( wxT( "%8.8lX" ), (long unsigned) m_TimeStamp );
492  return sheet->Path() + str;
493 }
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 152 of file sch_component.h.

References m_PathsAndReferences.

Referenced by SCH_LEGACY_PLUGIN::saveComponent().

152 { 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 747 of file sch_component.cpp.

References m_convert, m_part, and m_unit.

Referenced by SCH_EDIT_FRAME::FindComponentAndItem().

748 {
749  if( PART_SPTR part = m_part.lock() )
750  {
751  return part->GetPin( number, m_unit, m_convert );
752  }
753  return NULL;
754 }
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:92
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:81
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:82
wxPoint SCH_COMPONENT::GetPinPhysicalPosition ( LIB_PIN Pin)

Definition at line 1795 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().

1796 {
1797  wxCHECK_MSG( Pin != NULL && Pin->Type() == LIB_PIN_T, wxPoint( 0, 0 ),
1798  wxT( "Cannot get physical position of pin." ) );
1799 
1800  return m_transform.TransformCoordinate( Pin->GetPosition() ) + m_Pos;
1801 }
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:76
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:89
void SCH_COMPONENT::GetPins ( std::vector< LIB_PIN * > &  aPinsList)

Function GetPins populate a vector with all the pins.

Definition at line 757 of file sch_component.cpp.

References m_convert, m_part, and m_unit.

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

758 {
759  if( PART_SPTR part = m_part.lock() )
760  {
761  part->GetPins( aPinsList, m_unit, m_convert );
762  }
763  else
764  wxFAIL_MSG( "Could not obtain PART_SPTR lock" );
765 }
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:92
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:81
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:82
wxPoint SCH_COMPONENT::GetPosition ( ) const
inlineoverridevirtual

Function GetPosition.

Returns
A wxPoint object containing the schematic item position.

Implements SCH_ITEM.

Definition at line 549 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().

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

Definition at line 202 of file sch_component.h.

References m_prefix.

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

202 { 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:85
const wxString SCH_COMPONENT::GetRef ( const SCH_SHEET_PATH sheet)

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

Definition at line 496 of file sch_component.cpp.

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

Referenced by Diagnose(), NETLIST_EXPORTER::findAllInstancesOfComponent(), 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().

497 {
498  wxString path = GetPath( sheet );
499  wxString h_path, h_ref;
500  wxStringTokenizer tokenizer;
501  wxString separators( wxT( " " ) );
502 
503  for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
504  {
505  tokenizer.SetString( m_PathsAndReferences[ii], separators );
506  h_path = tokenizer.GetNextToken();
507 
508  if( h_path.Cmp( path ) == 0 )
509  {
510  h_ref = tokenizer.GetNextToken();
511 
512  /* printf( "GetRef hpath: %s\n",
513  * TO_UTF8( m_PathsAndReferences[ii] ) ); */
514  return h_ref;
515  }
516  }
517 
518  // if it was not found in m_Paths array, then see if it is in
519  // m_Field[REFERENCE] -- if so, use this as a default for this path.
520  // this will happen if we load a version 1 schematic file.
521  // it will also mean that multiple instances of the same sheet by default
522  // all have the same component references, but perhaps this is best.
523  if( !GetField( REFERENCE )->GetText().IsEmpty() )
524  {
525  SetRef( sheet, GetField( REFERENCE )->GetText() );
526  return GetField( REFERENCE )->GetText();
527  }
528 
529  return m_prefix;
530 }
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:85
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 1046 of file sch_component.cpp.

References m_transform, and TRANSFORM::TransformCoordinate().

Referenced by SCH_FIELD::Draw().

1047 {
1048  return m_transform.TransformCoordinate( aPoint );
1049 }
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:89
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 1863 of file sch_component.cpp.

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

Referenced by Matches().

1864 {
1865  wxString tmp;
1866  tmp.Printf( _( "Component %s, %s" ),
1867  FROM_UTF8( GetLibId().GetLibItemName() ),
1868  GetChars( GetField( REFERENCE )->GetShownText() ) );
1869  return tmp;
1870 }
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 377 of file sch_component.cpp.

References m_part.

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

378 {
379  if( PART_SPTR part = m_part.lock() )
380  {
381  return part->GetUnitCount();
382  }
383 
384  return 0;
385 }
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:92
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
int SCH_COMPONENT::GetUnitSelection ( SCH_SHEET_PATH aSheet)

Definition at line 637 of file sch_component.cpp.

References GetPath(), m_PathsAndReferences, and m_unit.

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

638 {
639  wxString path = GetPath( aSheet );
640  wxString h_path, h_multi;
641  wxStringTokenizer tokenizer;
642  wxString separators( wxT( " " ) );
643 
644  for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
645  {
646  tokenizer.SetString( m_PathsAndReferences[ii], separators );
647  h_path = tokenizer.GetNextToken();
648 
649  if( h_path.Cmp( path ) == 0 )
650  {
651  tokenizer.GetNextToken(); // Skip reference
652  h_multi = tokenizer.GetNextToken();
653  long imulti = 1;
654  h_multi.ToLong( &imulti );
655  return imulti;
656  }
657  }
658 
659  // if it was not found in m_Paths array, then use m_unit.
660  // this will happen if we load a version 1 schematic file.
661  return m_unit;
662 }
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:81
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 2064 of file sch_component.cpp.

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

2065 {
2066  EDA_RECT bBox = GetBodyBoundingBox();
2067  bBox.Inflate( aAccuracy );
2068 
2069  if( bBox.Contains( aPosition ) )
2070  return true;
2071 
2072  return false;
2073 }
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 2076 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.

2077 {
2079  return false;
2080 
2081  EDA_RECT rect = aRect;
2082 
2083  rect.Inflate( aAccuracy );
2084 
2085  if( aContained )
2086  return rect.Contains( GetBodyBoundingBox() );
2087 
2088  return rect.Intersects( GetBodyBoundingBox() );
2089 }
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:76
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:81
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:82
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is...
Definition: sch_component.h:85
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:89
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 510 of file sch_component.h.

510 { 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 1784 of file sch_component.cpp.

References m_isDangling.

1785 {
1786  for( bool each : m_isDangling )
1787  {
1788  if( each )
1789  return true;
1790  }
1791  return false;
1792 }
std::vector< bool > m_isDangling
One isDangling per pin.
Definition: sch_component.h:94
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 1769 of file sch_component.cpp.

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

1770 {
1771  bool changed = false;
1772  LIB_PINS libPins;
1773  if( PART_SPTR part = m_part.lock() )
1774  part->GetPins( libPins, m_unit, m_convert );
1775  for( size_t i = 0; i < libPins.size(); ++i )
1776  {
1777  if( IsPinDanglingStateChanged( aItemList, libPins, i ) )
1778  changed = true;
1779  }
1780  return changed;
1781 }
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:92
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:81
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:82
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 2108 of file sch_component.cpp.

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

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

2109 {
2110  SCH_FIELD* rf = GetField( REFERENCE );
2111  return ! rf->GetText().StartsWith( wxT( "#" ) );
2112 }
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 162 of file sch_component.h.

162 { 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 1712 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().

1714 {
1715  bool previousState;
1716 
1717  if( aPin < m_isDangling.size() )
1718  {
1719  previousState = m_isDangling[aPin];
1720  m_isDangling[aPin] = true;
1721  }
1722  else
1723  {
1724  previousState = true;
1725  m_isDangling.push_back( true );
1726  }
1727 
1728  wxPoint pin_position = GetPinPhysicalPosition( aLibPins[aPin] );
1729 
1730  for( DANGLING_END_ITEM& each_item : aItemList )
1731  {
1732  // Some people like to stack pins on top of each other in a symbol to indicate
1733  // internal connection. While technically connected, it is not particularly useful
1734  // to display them that way, so skip any pins that are in the same symbol as this
1735  // one.
1736  //
1737  // Do not make this exception for hidden pins, because those actually make internal
1738  // connections to a power net.
1739  const LIB_PIN* item_pin = dynamic_cast<const LIB_PIN*>( each_item.GetItem() );
1740 
1741  if( item_pin
1742  && ( !item_pin->IsPowerConnection() || !IsInNetlist() )
1743  && std::find( aLibPins.begin(), aLibPins.end(), item_pin) != aLibPins.end() )
1744  continue;
1745 
1746  switch( each_item.GetType() )
1747  {
1748  case PIN_END:
1749  case LABEL_END:
1750  case SHEET_LABEL_END:
1751  case WIRE_START_END:
1752  case WIRE_END_END:
1753  case NO_CONNECT_END:
1754  case JUNCTION_END:
1755  if( pin_position == each_item.GetPosition() )
1756  m_isDangling[aPin] = false;
1757  break;
1758  default:
1759  break;
1760  }
1761  if( !m_isDangling[aPin] )
1762  break;
1763  }
1764 
1765  return previousState != m_isDangling[aPin];
1766 }
std::vector< bool > m_isDangling
One isDangling per pin.
Definition: sch_component.h:94
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 539 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().

540 {
541  wxString text = aReferenceString;
542  bool ok = true;
543 
544  // Try to unannotate this reference
545  while( !text.IsEmpty() && ( text.Last() == '?' || isdigit( text.Last() ) ) )
546  text.RemoveLast();
547 
548  if( text.IsEmpty() )
549  ok = false;
550 
551  // Add here other constraints
552  // Currently:no other constraint
553 
554  return ok;
555 }
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 547 of file sch_component.h.

547 { 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 1804 of file sch_component.cpp.

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

1805 {
1806  bool previousState = IsSelected();
1807 
1809 
1810  if( aRect.Intersects( boundingBox ) )
1811  SetFlags( SELECTED );
1812  else
1813  ClearFlags( SELECTED );
1814 
1815  return previousState != IsSelected();
1816 }
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 1205 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.

1206 {
1207  // Remark: avoid using sscanf to read texts entered by user
1208  // which are UTF8 encoded, because sscanf does not work well on Windows
1209  // with some UTF8 values.
1210  char name1[256], char1[256], char2[256], char3[256];
1211  int newfmt = 0;
1212  char* ptcar;
1213  wxString fieldName;
1214  char* line = aLine.Line();
1215  unsigned long timeStamp;
1216 
1217  m_convert = 1;
1218 
1219  if( line[0] == '$' )
1220  {
1221  newfmt = 1;
1222 
1223  if( !(line = aLine.ReadLine()) )
1224  return true;
1225  }
1226 
1227  // Parse the first line of description:
1228  // like "L partname ref" (for instance "L 74LS00 U4"
1229  // They are UTF8 texts, so do not use sscanf
1230 
1231  line += 1;
1232 
1233  if( *line == ' ' )
1234  line++;
1235 
1236  // line points the first parameter
1237  wxString buffer( FROM_UTF8( line ) );
1238  wxStringTokenizer tokenizer( buffer, wxT( " \r\n" ) );
1239 
1240  if( tokenizer.CountTokens() < 2 )
1241  {
1242  aErrorMsg.Printf( wxT( "Eeschema component description error at line %d, aborted" ),
1243  aLine.LineNumber() );
1244  aErrorMsg << wxT( "\n" ) << FROM_UTF8( line );
1245  return false;
1246  }
1247 
1248  wxString partname = tokenizer.NextToken();
1249  partname.Replace( wxT("~"), wxT(" ") ); // all spaces were replaced by ~ in files.
1250 
1251  if( partname != NULL_STRING )
1252  {
1253  m_lib_id.SetLibItemName( TO_UTF8( partname ), false );
1254 
1255  if( !newfmt )
1256  GetField( VALUE )->SetText( partname );
1257  }
1258  else
1259  {
1260  m_lib_id.clear();
1261  GetField( VALUE )->Empty();
1263  GetField( VALUE )->SetVisible( false );
1264  }
1265 
1266  wxString reference = tokenizer.NextToken();
1267  reference.Replace( wxT("~"), wxT(" ") ); // all spaces were replaced by ~ in files.
1268  reference.Trim( true );
1269  reference.Trim( false );
1270 
1271  if( reference != NULL_STRING )
1272  {
1273  wxString prefix = reference;
1274  // Build reference prefix from the actual reference by removing trailing digits
1275  // (Perhaps outdated code, only for very old schematic files)
1276  while( prefix.Length() )
1277  {
1278  if( ( prefix.Last() < '0' || prefix.Last() > '9') && prefix.Last() != '?' )
1279  break;
1280 
1281  prefix.RemoveLast();
1282  }
1283 
1284  // Avoid a prefix containing trailing/leading spaces
1285  prefix.Trim( true );
1286  prefix.Trim( false );
1287 
1288  if( prefix.IsEmpty() )
1289  m_prefix = wxT( "U" );
1290  else
1291  m_prefix = prefix;
1292 
1293  if( !newfmt )
1294  GetField( REFERENCE )->SetText( reference );
1295  }
1296  else
1297  {
1298  GetField( REFERENCE )->SetVisible( false );
1299  }
1300 
1301  /* Parse component description
1302  * These lines begin with:
1303  * "P" = Position
1304  * U = Num Unit and Conversion
1305  * "Fn" = Fields (0 .. n = = number of field)
1306  * "Ar" = Alternate reference in the case of multiple sheets referring to
1307  * one schematic file.
1308  */
1309  for( ; ; )
1310  {
1311  if( !(line = aLine.ReadLine()) )
1312  return false;
1313 
1314  if( line[0] == 'U' )
1315  {
1316  sscanf( line + 1, "%d %d %lX", &m_unit, &m_convert, &timeStamp );
1317  m_TimeStamp = (time_t)timeStamp;
1318  }
1319  else if( line[0] == 'P' )
1320  {
1321  sscanf( line + 1, "%d %d", &m_Pos.x, &m_Pos.y );
1322 
1323  // Set fields position to a default position (that is the
1324  // component position. For existing fields, the real position
1325  // will be set later
1326  for( int i = 0; i<GetFieldCount(); i++ )
1327  {
1328  if( GetField( i )->GetText().IsEmpty() )
1329  GetField( i )->SetTextPos( m_Pos );
1330  }
1331  }
1332  else if( line[0] == 'A' && line[1] == 'R' )
1333  {
1334  /* format:
1335  * AR Path="/9086AF6E/67452AA0" Ref="C99" Part="1"
1336  * where 9086AF6E is the unique timestamp of the containing sheet
1337  * and 67452AA0 is the timestamp of this component.
1338  * C99 is the reference given this path.
1339  */
1340  int ii;
1341  ptcar = line + 2;
1342 
1343  //copy the path.
1344  ii = ReadDelimitedText( name1, ptcar, 255 );
1345  ptcar += ii + 1;
1346  wxString path = FROM_UTF8( name1 );
1347 
1348  // copy the reference
1349  ii = ReadDelimitedText( name1, ptcar, 255 );
1350  ptcar += ii + 1;
1351  wxString ref = FROM_UTF8( name1 );
1352 
1353  // copy the multi, if exists
1354  ii = ReadDelimitedText( name1, ptcar, 255 );
1355 
1356  if( name1[0] == 0 ) // Nothing read, put a default value
1357  sprintf( name1, "%d", m_unit );
1358 
1359  int multi = atoi( name1 );
1360 
1361  if( multi < 0 || multi > 26 )
1362  multi = 1;
1363 
1364  AddHierarchicalReference( path, ref, multi );
1365  GetField( REFERENCE )->SetText( ref );
1366  }
1367  else if( line[0] == 'F' )
1368  {
1369  int fieldNdx;
1370 
1371  wxString fieldText;
1374 
1375  ptcar = (char*) aLine;
1376 
1377  while( *ptcar && (*ptcar != '"') )
1378  ptcar++;
1379 
1380  if( *ptcar != '"' )
1381  {
1382  aErrorMsg.Printf( wxT( "Eeschema file library field F at line %d, aborted" ),
1383  aLine.LineNumber() );
1384  return false;
1385  }
1386 
1387  ptcar += ReadDelimitedText( &fieldText, ptcar );
1388 
1389  if( *ptcar == 0 )
1390  {
1391  aErrorMsg.Printf( wxT( "Component field F at line %d, aborted" ),
1392  aLine.LineNumber() );
1393  return false;
1394  }
1395 
1396  fieldNdx = atoi( line + 2 );
1397 
1398  ReadDelimitedText( &fieldName, ptcar );
1399 
1400  if( fieldName.IsEmpty() )
1401  fieldName = TEMPLATE_FIELDNAME::GetDefaultFieldName( fieldNdx );
1402 
1403  if( fieldNdx >= GetFieldCount() )
1404  {
1405  // The first MANDATOR_FIELDS _must_ be constructed within
1406  // the SCH_COMPONENT constructor. This assert is simply here
1407  // to guard against a change in that constructor.
1408  wxASSERT( GetFieldCount() >= MANDATORY_FIELDS );
1409 
1410  // Ignore the _supplied_ fieldNdx. It is not important anymore
1411  // if within the user defined fields region (i.e. >= MANDATORY_FIELDS).
1412  // We freely renumber the index to fit the next available field slot.
1413 
1414  fieldNdx = GetFieldCount(); // new has this index after insertion
1415 
1416  SCH_FIELD field( wxPoint( 0, 0 ),
1417  -1, // field id is not relavant for user defined fields
1418  this, fieldName );
1419 
1420  AddField( field );
1421  }
1422  else
1423  {
1424  GetField( fieldNdx )->SetName( fieldName );
1425  }
1426 
1427  GetField( fieldNdx )->SetText( fieldText );
1428  memset( char3, 0, sizeof(char3) );
1429  int ii, x, y, w, attr;
1430 
1431  if( ( ii = sscanf( ptcar, "%255s %d %d %d %X %255s %255s", char1, &x, &y, &w, &attr,
1432  char2, char3 ) ) < 4 )
1433  {
1434  aErrorMsg.Printf( wxT( "Component Field error line %d, aborted" ),
1435  aLine.LineNumber() );
1436  continue;
1437  }
1438 
1439  GetField( fieldNdx )->SetTextPos( wxPoint( x, y ) );
1440  GetField( fieldNdx )->SetVisible( !attr );
1441 
1442  if( (w == 0 ) || (ii == 4) )
1443  w = GetDefaultTextSize();
1444 
1445  GetField( fieldNdx )->SetTextSize( wxSize( w, w ) );
1446  GetField( fieldNdx )->SetTextAngle( TEXT_ANGLE_HORIZ );
1447 
1448  if( char1[0] == 'V' )
1449  GetField( fieldNdx )->SetTextAngle( TEXT_ANGLE_VERT );
1450 
1451  if( ii >= 7 )
1452  {
1453  if( *char2 == 'L' )
1454  hjustify = GR_TEXT_HJUSTIFY_LEFT;
1455  else if( *char2 == 'R' )
1456  hjustify = GR_TEXT_HJUSTIFY_RIGHT;
1457 
1458  if( char3[0] == 'B' )
1459  vjustify = GR_TEXT_VJUSTIFY_BOTTOM;
1460  else if( char3[0] == 'T' )
1461  vjustify = GR_TEXT_VJUSTIFY_TOP;
1462 
1463  GetField( fieldNdx )->SetItalic( char3[1] == 'I' );
1464  GetField( fieldNdx )->SetBold( char3[2] == 'B' );
1465  GetField( fieldNdx )->SetHorizJustify( hjustify );
1466  GetField( fieldNdx )->SetVertJustify( vjustify );
1467  }
1468 
1469  if( fieldNdx == REFERENCE )
1470  if( GetField( fieldNdx )->GetText()[0] == '#' )
1471  GetField( fieldNdx )->SetVisible( false );
1472  }
1473  else
1474  {
1475  break;
1476  }
1477  }
1478 
1479  if( sscanf( line, "%d %d %d", &m_unit, &m_Pos.x, &m_Pos.y ) != 3 )
1480  {
1481  aErrorMsg.Printf( wxT( "Component unit & pos error at line %d, aborted" ),
1482  aLine.LineNumber() );
1483  return false;
1484  }
1485 
1486  if( !(line = aLine.ReadLine()) ||
1487  sscanf( line, "%d %d %d %d",
1488  &m_transform.x1,
1489  &m_transform.y1,
1490  &m_transform.x2,
1491  &m_transform.y2 ) != 4 )
1492  {
1493  aErrorMsg.Printf( wxT( "Component orient error at line %d, aborted" ),
1494  aLine.LineNumber() );
1495  return false;
1496  }
1497 
1498  if( newfmt )
1499  {
1500  if( !(line = aLine.ReadLine()) )
1501  return false;
1502 
1503  if( strncasecmp( "$End", line, 4 ) != 0 )
1504  {
1505  aErrorMsg.Printf( wxT( "Component End expected at line %d, aborted" ),
1506  aLine.LineNumber() );
1507  return false;
1508  }
1509  }
1510 
1511  // ensure flags (mainly used in edit) are cleared.
1512  // some changes have set the modified flag
1513  m_Flags = 0;
1514 
1515  return true;
1516 }
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
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:76
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:81
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:82
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:85
void SetBold(bool aBold)
Definition: eda_text.h:172
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:89
static unsigned long timeStamp(CPTREE &aTree)
Make a unique time stamp.
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 1681 of file sch_component.cpp.

References GetSelectMenuText(), and traceFindItem.

1683 {
1684  wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText() );
1685 
1686  // Components are searchable via the child field and pin item text.
1687  return false;
1688 }
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 1644 of file sch_component.cpp.

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

1645 {
1646  int dy = m_Pos.y;
1647 
1649  MIRROR( m_Pos.y, aXaxis_position );
1650  dy -= m_Pos.y; // dy,0 is the move vector for this transform
1651 
1652  for( int ii = 0; ii < GetFieldCount(); ii++ )
1653  {
1654  // Move the fields to the new position because the component itself has moved.
1655  wxPoint pos = GetField( ii )->GetTextPos();
1656  pos.y -= dy;
1657  GetField( ii )->SetTextPos( pos );
1658  }
1659 }
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:76
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 1626 of file sch_component.cpp.

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

1627 {
1628  int dx = m_Pos.x;
1629 
1631  MIRROR( m_Pos.x, aYaxis_position );
1632  dx -= m_Pos.x; // dx,0 is the move vector for this transform
1633 
1634  for( int ii = 0; ii < GetFieldCount(); ii++ )
1635  {
1636  // Move the fields to the new position because the component itself has moved.
1637  wxPoint pos = GetField( ii )->GetTextPos();
1638  pos.x -= dx;
1639  GetField( ii )->SetTextPos( pos );
1640  }
1641 }
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:76
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 456 of file sch_component.h.

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

Referenced by SetPosition().

457  {
458  if( aMoveVector == wxPoint( 0, 0 ) )
459  return;
460 
461  m_Pos += aMoveVector;
462 
463  for( int ii = 0; ii < GetFieldCount(); ii++ )
464  GetField( ii )->Move( aMoveVector );
465 
466  SetModified();
467  }
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:76
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_SCREEN::MarkConnections(), SCH_EDIT_FRAME::OnConvertTextType(), DIALOG_ERC::OnLeftClickMarkersList(), SCH_SCREEN::Plot(), 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 2024 of file sch_component.cpp.

2025 {
2026  return !( *this == aComponent );
2027 }
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 1987 of file sch_component.cpp.

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

1988 {
1989  if( Type() != aItem.Type() )
1990  return Type() < aItem.Type();
1991 
1992  SCH_COMPONENT* component = (SCH_COMPONENT*) &aItem;
1993 
1994  EDA_RECT rect = GetBodyBoundingBox();
1995 
1996  if( rect.GetArea() != component->GetBodyBoundingBox().GetArea() )
1997  return rect.GetArea() < component->GetBodyBoundingBox().GetArea();
1998 
1999  if( m_Pos.x != component->m_Pos.x )
2000  return m_Pos.x < component->m_Pos.x;
2001 
2002  if( m_Pos.y != component->m_Pos.y )
2003  return m_Pos.y < component->m_Pos.y;
2004 
2005  return false;
2006 }
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:76
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:68
SCH_ITEM & SCH_COMPONENT::operator= ( const SCH_ITEM aItem)

Definition at line 2030 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().

2031 {
2032  wxCHECK_MSG( Type() == aItem.Type(), *this,
2033  wxT( "Cannot assign object type " ) + aItem.GetClass() + wxT( " to type " ) +
2034  GetClass() );
2035 
2036  if( &aItem != this )
2037  {
2038  SCH_ITEM::operator=( aItem );
2039 
2040  SCH_COMPONENT* c = (SCH_COMPONENT*) &aItem;
2041 
2042  m_lib_id = c->m_lib_id;
2043  m_part = c->m_part;
2044  m_Pos = c->m_Pos;
2045  m_unit = c->m_unit;
2046  m_convert = c->m_convert;
2047  m_transform = c->m_transform;
2048 
2050 
2051  m_Fields = c->m_Fields; // std::vector's assignment operator.
2052 
2053  // Reparent fields after assignment to new component.
2054  for( int ii = 0; ii < GetFieldCount(); ++ii )
2055  {
2056  GetField( ii )->SetParent( this );
2057  }
2058  }
2059 
2060  return *this;
2061 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
SCH_FIELDS m_Fields
Variable length list of fields.
Definition: sch_component.h:90
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:76
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:92
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:81
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:68
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:82
wxString GetClass() const override
Function GetClass returns the class name.
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:89
bool SCH_COMPONENT::operator== ( const SCH_COMPONENT aComponent) const

Definition at line 2009 of file sch_component.cpp.

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

2010 {
2011  if( GetFieldCount() != aComponent.GetFieldCount() )
2012  return false;
2013 
2014  for( int i = VALUE; i < GetFieldCount(); i++ )
2015  {
2016  if( GetField( i )->GetText().Cmp( aComponent.GetField( i )->GetText() ) != 0 )
2017  return false;
2018  }
2019 
2020  return true;
2021 }
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 2115 of file sch_component.cpp.

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

2116 {
2117  TRANSFORM temp;
2118 
2119  if( PART_SPTR part = m_part.lock() )
2120  {
2121  temp = GetTransform();
2122 
2123  part->Plot( aPlotter, GetUnit(), GetConvert(), m_Pos, temp );
2124 
2125  for( size_t i = 0; i < m_Fields.size(); i++ )
2126  {
2127  m_Fields[i].Plot( aPlotter );
2128  }
2129  }
2130 }
TRANSFORM & GetTransform() const
SCH_FIELDS m_Fields
Variable length list of fields.
Definition: sch_component.h:90
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:76
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:92
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 277 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().

278 {
279  // I've never been happy that the actual individual PART_LIB is left up to
280  // flimsy search path ordering. None-the-less find a part based on that design:
281  if( LIB_PART* part = aLibs->FindLibPart( m_lib_id ) )
282  {
283  m_part = part->SharedPtr();
284  return true;
285  }
286 
287  return false;
288 }
PART_REF m_part
points into the PROJECT's libraries to the LIB_PART for this component
Definition: sch_component.h:92
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 297 of file sch_component.cpp.

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

Referenced by SCH_SCREEN::CheckComponentsToPartsLinks().

299 {
300  // Usually, many components use the same part lib.
301  // to avoid too long calculation time the list of components is grouped
302  // and once the lib part is found for one member of a group, it is also
303  // set for all other members of this group
304  std::vector<SCH_COMPONENT*> cmp_list;
305 
306  // build the cmp list.
307  for( int i = 0; i < aComponents.GetCount(); ++i )
308  {
309  SCH_COMPONENT* cmp = dynamic_cast<SCH_COMPONENT*>( aComponents[i] );
310  wxASSERT( cmp );
311 
312  if( cmp ) // cmp == NULL should not occur.
313  cmp_list.push_back( cmp );
314  }
315 
316  // sort it by lib part. Cmp will be grouped by same lib part.
317  std::sort( cmp_list.begin(), cmp_list.end(), sort_by_libid );
318 
319  LIB_ID curr_libid;
320 
321  for( unsigned ii = 0; ii < cmp_list.size (); ++ii )
322  {
323  SCH_COMPONENT* cmp = cmp_list[ii];
324  curr_libid = cmp->m_lib_id;
325  cmp->Resolve( aLibs );
326 
327  // Propagate the m_part pointer to other members using the same lib_id
328  for( unsigned jj = ii+1; jj < cmp_list.size (); ++jj )
329  {
330  SCH_COMPONENT* next_cmp = cmp_list[jj];
331 
332  if( curr_libid != next_cmp->m_lib_id )
333  break;
334 
335  next_cmp->m_part = cmp->m_part;
336  ii = jj;
337  }
338  }
339 }
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:92
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:68
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 1662 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.

1663 {
1664  wxPoint prev = m_Pos;
1665 
1666  RotatePoint( &m_Pos, aPosition, 900 );
1667 
1669 
1670  for( int ii = 0; ii < GetFieldCount(); ii++ )
1671  {
1672  // Move the fields to the new position because the component itself has moved.
1673  wxPoint pos = GetField( ii )->GetTextPos();
1674  pos.x -= prev.x - m_Pos.x;
1675  pos.y -= prev.y - m_Pos.y;
1676  GetField( ii )->SetTextPos( pos );
1677  }
1678 }
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:76
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 1084 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.

1085 {
1086  std::string name1;
1087  std::string name2;
1088  wxArrayString reference_fields;
1089 
1090  static wxString delimiters( wxT( " " ) );
1091 
1092  // this is redundant with the AR entries below, but it makes the
1093  // files backwards-compatible.
1094  if( m_PathsAndReferences.GetCount() > 0 )
1095  {
1096  reference_fields = wxStringTokenize( m_PathsAndReferences[0], delimiters );
1097 
1098  name1 = toUTFTildaText( reference_fields[1] );
1099  }
1100  else
1101  {
1102  if( GetField( REFERENCE )->GetText().IsEmpty() )
1103  name1 = toUTFTildaText( m_prefix );
1104  else
1105  name1 = toUTFTildaText( GetField( REFERENCE )->GetText() );
1106  }
1107 
1108  wxString part_name = FROM_UTF8( GetLibId().GetLibItemName() );
1109 
1110  if( part_name.size() )
1111  {
1112  name2 = toUTFTildaText( part_name );
1113  }
1114  else
1115  {
1116  name2 = NULL_STRING;
1117  }
1118 
1119  if( fprintf( f, "$Comp\n" ) == EOF )
1120  return false;
1121 
1122  if( fprintf( f, "L %s %s\n", name2.c_str(), name1.c_str() ) == EOF )
1123  return false;
1124 
1125  // Generate unit number, convert and time stamp
1126  if( fprintf( f, "U %d %d %8.8lX\n", m_unit, m_convert, (unsigned long)m_TimeStamp ) == EOF )
1127  return false;
1128 
1129  // Save the position
1130  if( fprintf( f, "P %d %d\n", m_Pos.x, m_Pos.y ) == EOF )
1131  return false;
1132 
1133  /* If this is a complex hierarchy; save hierarchical references.
1134  * but for simple hierarchies it is not necessary.
1135  * the reference inf is already saved
1136  * this is useful for old Eeschema version compatibility
1137  */
1138  if( m_PathsAndReferences.GetCount() > 1 )
1139  {
1140  for( unsigned int ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
1141  {
1142  /*format:
1143  * AR Path="/140/2" Ref="C99" Part="1"
1144  * where 140 is the uid of the containing sheet
1145  * and 2 is the timestamp of this component.
1146  * (timestamps are actually 8 hex chars)
1147  * Ref is the conventional component reference for this 'path'
1148  * Part is the conventional component part selection for this 'path'
1149  */
1150  reference_fields = wxStringTokenize( m_PathsAndReferences[ii], delimiters );
1151 
1152  if( fprintf( f, "AR Path=\"%s\" Ref=\"%s\" Part=\"%s\" \n",
1153  TO_UTF8( reference_fields[0] ),
1154  TO_UTF8( reference_fields[1] ),
1155  TO_UTF8( reference_fields[2] ) ) == EOF )
1156  return false;
1157  }
1158  }
1159 
1160  // update the ugly field index, which I would like to see go away someday soon.
1161  for( unsigned i = 0; i<m_Fields.size(); ++i )
1162  {
1163  SCH_FIELD* fld = GetField( i );
1164  fld->SetId( i ); // we don't need field Ids, please be gone.
1165  }
1166 
1167  // Fixed fields:
1168  // Save mandatory fields even if they are blank,
1169  // because the visibility, size and orientation are set from libary editor.
1170  for( unsigned i = 0; i<MANDATORY_FIELDS; ++i )
1171  {
1172  SCH_FIELD* fld = GetField( i );
1173  if( !fld->Save( f ) )
1174  return false;
1175  }
1176 
1177  // User defined fields:
1178  // The *policy* about which user defined fields are part of a symbol is now
1179  // only in the dialog editors. No policy should be enforced here, simply
1180  // save all the user defined fields, they are present because a dialog editor
1181  // thought they should be. If you disagree, go fix the dialog editors.
1182  for( unsigned i = MANDATORY_FIELDS; i<m_Fields.size(); ++i )
1183  {
1184  SCH_FIELD* fld = GetField( i );
1185 
1186  if( !fld->Save( f ) )
1187  return false;
1188  }
1189 
1190  // Unit number, position, box ( old standard )
1191  if( fprintf( f, "\t%-4d %-4d %-4d\n", m_unit, m_Pos.x, m_Pos.y ) == EOF )
1192  return false;
1193 
1194  if( fprintf( f, "\t%-4d %-4d %-4d %-4d\n",
1196  return false;
1197 
1198  if( fprintf( f, "$EndComp\n" ) == EOF )
1199  return false;
1200 
1201  return true;
1202 }
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:90
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:76
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:81
#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:82
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:85
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:89
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 357 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().

358 {
359  if( m_convert != aConvert )
360  {
361  m_convert = aConvert;
362  SetModified();
363  }
364 }
void SetModified()
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:82
void SCH_COMPONENT::SetCurrentSheetPath ( const SCH_SHEET_PATH aSheetPath)
inline

Definition at line 420 of file sch_component.h.

Referenced by SCH_EDIT_FRAME::Load_Component().

421  {
422  m_currentSheetPath = aSheetPath;
423  }
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 315 of file sch_component.h.

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

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

Definition at line 253 of file base_struct.h.

Referenced by SCH_SCREEN::addConnectedItemsToBlock(), AddSegmentToDragList(), 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 ( LAYERSCH_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; }
LAYERSCH_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(), and SCH_EDIT_FRAME::Load_Component().

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:92
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(), Move(), LIB_PIN::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 880 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().

881 {
882  TRANSFORM temp = TRANSFORM();
883  bool transform = false;
884 
885  switch( aOrientation )
886  {
887  case CMP_ORIENT_0:
888  case CMP_NORMAL: // default transform matrix
889  m_transform.x1 = 1;
890  m_transform.y2 = -1;
892  break;
893 
894  case CMP_ROTATE_COUNTERCLOCKWISE: // Rotate + (incremental rotation)
895  temp.x1 = temp.y2 = 0;
896  temp.y1 = 1;
897  temp.x2 = -1;
898  transform = true;
899  break;
900 
901  case CMP_ROTATE_CLOCKWISE: // Rotate - (incremental rotation)
902  temp.x1 = temp.y2 = 0;
903  temp.y1 = -1;
904  temp.x2 = 1;
905  transform = true;
906  break;
907 
908  case CMP_MIRROR_Y: // Mirror Y (incremental rotation)
909  temp.x1 = -1;
910  temp.y2 = 1;
911  temp.y1 = temp.x2 = 0;
912  transform = true;
913  break;
914 
915  case CMP_MIRROR_X: // Mirror X (incremental rotation)
916  temp.x1 = 1;
917  temp.y2 = -1;
918  temp.y1 = temp.x2 = 0;
919  transform = true;
920  break;
921 
922  case CMP_ORIENT_90:
925  break;
926 
927  case CMP_ORIENT_180:
931  break;
932 
933  case CMP_ORIENT_270:
936  break;
937 
938  case ( CMP_ORIENT_0 + CMP_MIRROR_X ):
941  break;
942 
943  case ( CMP_ORIENT_0 + CMP_MIRROR_Y ):
946  break;
947 
948  case ( CMP_ORIENT_90 + CMP_MIRROR_X ):
951  break;
952 
953  case ( CMP_ORIENT_90 + CMP_MIRROR_Y ):
956  break;
957 
958  case ( CMP_ORIENT_180 + CMP_MIRROR_X ):
961  break;
962 
963  case ( CMP_ORIENT_180 + CMP_MIRROR_Y ):
966  break;
967 
968  case ( CMP_ORIENT_270 + CMP_MIRROR_X ):
971  break;
972 
973  case ( CMP_ORIENT_270 + CMP_MIRROR_Y ):
976  break;
977 
978  default:
979  transform = false;
980  wxMessageBox( wxT( "SetRotateMiroir() error: ill value" ) );
981  break;
982  }
983 
984  if( transform )
985  {
986  /* The new matrix transform is the old matrix transform modified by the
987  * requested transformation, which is the temp transform (rot,
988  * mirror ..) in order to have (in term of matrix transform):
989  * transform coord = new_m_transform * coord
990  * where transform coord is the coord modified by new_m_transform from
991  * the initial value coord.
992  * new_m_transform is computed (from old_m_transform and temp) to
993  * have:
994  * transform coord = old_m_transform * temp
995  */
996  TRANSFORM newTransform;
997 
998  newTransform.x1 = m_transform.x1 * temp.x1 + m_transform.x2 * temp.y1;
999  newTransform.y1 = m_transform.y1 * temp.x1 + m_transform.y2 * temp.y1;
1000  newTransform.x2 = m_transform.x1 * temp.x2 + m_transform.x2 * temp.y2;
1001  newTransform.y2 = m_transform.y1 * temp.x2 + m_transform.y2 * temp.y2;
1002  m_transform = newTransform;
1003  }
1004 }
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:89
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 551 of file sch_component.h.

References Move().

551 { Move( aPosition - m_Pos ); }
wxPoint m_Pos
Name and library where symbol was loaded from, i.e. "74xx:74LS00".
Definition: sch_component.h:76
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 204 of file sch_component.h.

204 { 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:85
void SCH_COMPONENT::SetRef ( const SCH_SHEET_PATH sheet,
const wxString &  ref 
)

Set the reference, for the given sheet path.

Definition at line 558 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().

559 {
560  wxString path = GetPath( sheet );
561 
562  bool notInArray = true;
563 
564  wxString h_path, h_ref;
565  wxStringTokenizer tokenizer;
566  wxString separators( wxT( " " ) );
567 
568  // check to see if it is already there before inserting it
569  for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
570  {
571  tokenizer.SetString( m_PathsAndReferences[ii], separators );
572  h_path = tokenizer.GetNextToken();
573 
574  if( h_path.Cmp( path ) == 0 )
575  {
576  // just update the reference text, not the timestamp.
577  h_ref = h_path + wxT( " " ) + ref;
578  h_ref += wxT( " " );
579  tokenizer.GetNextToken(); // Skip old reference
580  h_ref += tokenizer.GetNextToken(); // Add part selection
581 
582  // Add the part selection
583  m_PathsAndReferences[ii] = h_ref;
584  notInArray = false;
585  }
586  }
587 
588  if( notInArray )
589  AddHierarchicalReference( path, ref, m_unit );
590 
591  SCH_FIELD* rf = GetField( REFERENCE );
592 
593  if( rf->GetText().IsEmpty()
594  || ( abs( rf->GetTextPos().x - m_Pos.x ) +
595  abs( rf->GetTextPos().y - m_Pos.y ) > 10000 ) )
596  {
597  // move it to a reasonable position
598  rf->SetTextPos( m_Pos + wxPoint( 50, 50 ) );
599  }
600 
601  rf->SetText( ref ); // for drawing.
602 
603  // Reinit the m_prefix member if needed
604  wxString prefix = ref;
605 
606  if( IsReferenceStringValid( prefix ) )
607  {
608  while( prefix.Last() == '?' || isdigit( prefix.Last() ) )
609  prefix.RemoveLast();
610  }
611  else
612  {
613  prefix = wxT( "U" ); // Set to default ref prefix
614  }
615 
616  if( m_prefix != prefix )
617  m_prefix = prefix;
618 }
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:76
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:81
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:85
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 621 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().

622 {
623  wxString string_timestamp, string_oldtimestamp;
624 
625  string_timestamp.Printf( wxT( "%08lX" ), (long unsigned) aNewTimeStamp );
626  string_oldtimestamp.Printf( wxT( "%08lX" ), (long unsigned) m_TimeStamp );
627  EDA_ITEM::SetTimeStamp( aNewTimeStamp );
628 
629  for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
630  {
631  m_PathsAndReferences[ii].Replace( string_oldtimestamp.GetData(),
632  string_timestamp.GetData() );
633  }
634 }
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 367 of file sch_component.cpp.

References m_transform, and EDA_ITEM::SetModified().

368 {
369  if( m_transform != aTransform )
370  {
371  m_transform = aTransform;
372  SetModified();
373  }
374 }
void SetModified()
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:89
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 342 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().

343 {
344  if( m_unit != aUnit )
345  {
346  m_unit = aUnit;
347  SetModified();
348  }
349 }
void SetModified()
int m_unit
The unit for multiple part per package components.
Definition: sch_component.h:81
void SCH_COMPONENT::SetUnitSelection ( SCH_SHEET_PATH aSheet,
int  aUnitSelection 
)

Definition at line 665 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().

666 {
667  wxString path = GetPath( aSheet );
668 
669  bool notInArray = true;
670 
671  wxString h_path, h_ref;
672  wxStringTokenizer tokenizer;
673  wxString separators( wxT( " " ) );
674 
675  //check to see if it is already there before inserting it
676  for( unsigned ii = 0; ii < m_PathsAndReferences.GetCount(); ii++ )
677  {
678  tokenizer.SetString( m_PathsAndReferences[ii], separators );
679  h_path = tokenizer.GetNextToken();
680 
681  if( h_path.Cmp( path ) == 0 )
682  {
683  //just update the unit selection.
684  h_ref = h_path + wxT( " " );
685  h_ref += tokenizer.GetNextToken(); // Add reference
686  h_ref += wxT( " " );
687  h_ref << aUnitSelection; // Add part selection
688 
689  // Ann the part selection
690  m_PathsAndReferences[ii] = h_ref;
691  notInArray = false;
692  }
693  }
694 
695  if( notInArray )
696  AddHierarchicalReference( path, m_prefix, aUnitSelection );
697 }
wxString GetPath(const SCH_SHEET_PATH *sheet) const
wxArrayString m_PathsAndReferences
Defines the hierarchical path and reference of the component.
void AddHierarchicalReference(const wxString &aPath, const wxString &aRef, int aMulti)
Function AddHierarchicalReference adds a full hierarchical reference (path + local reference) ...
wxString m_prefix
C, R, U, Q etc - the first character which typically indicates what the component is...
Definition: sch_component.h:85
void EDA_ITEM::SetWireImage ( )
inlineinherited

Definition at line 226 of file base_struct.h.

References IS_WIRE_IMAGE, and EDA_ITEM::SetFlags().

Referenced by moveItemWithMouseCursor().

226 { SetFlags( IS_WIRE_IMAGE ); }
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:253
#define IS_WIRE_IMAGE
Item to be drawn as wireframe while editing.
Definition: base_struct.h:117
static bool EDA_ITEM::Sort ( const EDA_ITEM aLeft,
const EDA_ITEM aRight 
)
inlinestaticinherited

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

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

Definition at line 463 of file base_struct.h.

Referenced by PART_LIB::GetEntryTypePowerNames().

463 { return *aLeft < *aRight; }
void SCH_COMPONENT::SwapData ( SCH_ITEM aItem)
overridevirtual

Function SwapData swap the internal data structures aItem with the schematic item.

Obviously, aItem must have the same type than me

Parameters
aItemThe item to swap the data structures with.

Reimplemented from SCH_ITEM.

Definition at line 768 of file sch_component.cpp.

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

769 {
770  wxCHECK_RET( (aItem != NULL) && (aItem->Type() == SCH_COMPONENT_T),
771  wxT( "Cannot swap data with invalid component." ) );
772 
773  SCH_COMPONENT* component = (SCH_COMPONENT*) aItem;
774 
775  std::swap( m_lib_id, component->m_lib_id );
776  std::swap( m_part, component->m_part );
777  std::swap( m_Pos, component->m_Pos );
778  std::swap( m_unit, component->m_unit );
779  std::swap( m_convert, component->m_convert );
780 
781  TRANSFORM tmp = m_transform;
782 
783  m_transform = component->m_transform;
784  component->m_transform = tmp;
785 
786  m_Fields.swap( component->m_Fields ); // std::vector's swap()
787 
788  // Reparent items after copying data
789  // (after swap(), m_Parent member does not point to the right parent):
790  for( int ii = 0; ii < component->GetFieldCount(); ++ii )
791  {
792  component->GetField( ii )->SetParent( component );
793  }
794 
795  for( int ii = 0; ii < GetFieldCount(); ++ii )
796  {
797  GetField( ii )->SetParent( this );
798  }
799 
800  std::swap( m_PathsAndReferences, component->m_PathsAndReferences );
801 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
SCH_FIELDS m_Fields
Variable length list of fields.
Definition: sch_component.h:90
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:76
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:92
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:81
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:68
int m_convert
The alternate body style for components that have more than one body style defined.
Definition: sch_component.h:82
TRANSFORM m_transform
The rotation/mirror transformation matrix.
Definition: sch_component.h:89