KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_symbol.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2014 Dick Hollenbeck, [email protected]
6 * Copyright (C) 2015 Wayne Stambaugh <[email protected]>
7 * Copyright (C) 2022 CERN
8 * Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, you may find one here:
22 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
23 * or you may search the http://www.gnu.org website for the version 2 license,
24 * or you may write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 */
27
28#ifndef __SYMBOL_H__
29#define __SYMBOL_H__
30
31#include <eda_item.h>
32#include <core/typeinfo.h>
33#include <layer_ids.h>
34#include <lib_id.h>
35#include <widgets/msgpanel.h>
36
37#include <memory>
38#include <string>
39#include <unordered_map>
40#include <vector>
41#include <wx/arrstr.h>
42#include <wx/chartype.h>
43#include <wx/fdrepdlg.h>
44#include <wx/gdicmn.h>
45#include <wx/string.h>
46
47#include <schematic.h>
48#include <sch_field.h>
49#include <sch_item.h>
50#include <sch_pin.h>
51#include <sch_sheet_path.h> // SCH_SYMBOL_INSTANCE
52#include <symbol_lib_table.h>
53#include <transform.h>
54
55struct PICKED_SYMBOL;
56class KIID_PATH;
57class SCH_SCREEN;
58class LIB_ITEM;
59class LIB_PIN;
60class LIB_SYMBOL;
61class NETLIST_OBJECT_LIST;
62class SYMBOL_LIB;
63class SYMBOL_LIBS;
64class EE_COLLECTOR;
65class SCH_SCREEN;
67
68
70typedef std::vector<SCH_FIELD> SCH_FIELDS;
71
72typedef std::weak_ptr<LIB_SYMBOL> PART_REF;
73
74
75extern std::string toUTFTildaText( const wxString& txt );
76
77
78// @todo Move this to transform alone with all of the transform manipulation code.
81{
82 SYM_NORMAL, // Normal orientation, no rotation or mirror
83 SYM_ROTATE_CLOCKWISE, // Rotate -90
85 SYM_ORIENT_0, // No rotation and no mirror id SYM_NORMAL
86 SYM_ORIENT_90, // Rotate 90, no mirror
87 SYM_ORIENT_180, // Rotate 180, no mirror
88 SYM_ORIENT_270, // Rotate -90, no mirror
89 SYM_MIRROR_X = 0x100, // Mirror around X axis
90 SYM_MIRROR_Y = 0x200 // Mirror around Y axis
91};
92
93
94// Cover for SYMBOL_ORIENTATION_T for property manager (in order to expose only a subset of
95// SYMBOL_ORIENTATION_T's values).
97{
103
104
108class SCH_SYMBOL : public SCH_ITEM
109{
110public:
111 SCH_SYMBOL();
112
123 SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const LIB_ID& aLibId, const SCH_SHEET_PATH* aSheet,
124 int aUnit, int aBodyStyle = 0, const VECTOR2I& aPosition = VECTOR2I( 0, 0 ),
125 EDA_ITEM* aParent = nullptr );
126
127 SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const SCH_SHEET_PATH* aSheet, const PICKED_SYMBOL& aSel,
128 const VECTOR2I& aPosition = VECTOR2I( 0, 0 ), EDA_ITEM* aParent = nullptr );
129
139 SCH_SYMBOL( const SCH_SYMBOL& aSymbol );
140
142
143 static inline bool ClassOf( const EDA_ITEM* aItem )
144 {
145 return aItem && SCH_SYMBOL_T == aItem->Type();
146 }
147
148 wxString GetClass() const override
149 {
150 return wxT( "SCH_SYMBOL" );
151 }
152
166 bool IsMissingLibSymbol() const;
167
168 const std::vector<SCH_SYMBOL_INSTANCE>& GetInstances() const
169 {
171 }
172
173 bool GetInstance( SCH_SYMBOL_INSTANCE& aInstance,
174 const KIID_PATH& aSheetPath, bool aTestFromEnd = false ) const;
175
176 void RemoveInstance( const SCH_SHEET_PATH& aInstancePath );
177
178 void RemoveInstance( const KIID_PATH& aInstancePath );
179
180 void SortInstances( bool ( *aSortFunction )( const SCH_SYMBOL_INSTANCE& aLhs,
181 const SCH_SYMBOL_INSTANCE& aRhs ) );
182
183 void ViewGetLayers( int aLayers[], int& aCount ) const override;
184
199 bool IsMovableFromAnchorPoint() const override;
200
201 void SetLibId( const LIB_ID& aName );
202
203 const LIB_ID& GetLibId() const { return m_lib_id; }
204
205 wxString GetSymbolIDAsString() const { return m_lib_id.Format(); }
206
218 void SetSchSymbolLibraryName( const wxString& aName ) { m_schLibSymbolName = aName; }
219 wxString GetSchSymbolLibraryName() const;
220 bool UseLibIdLookup() const { return m_schLibSymbolName.IsEmpty(); }
221
222 std::unique_ptr< LIB_SYMBOL >& GetLibSymbolRef() { return m_part; }
223 const std::unique_ptr< LIB_SYMBOL >& GetLibSymbolRef() const { return m_part; }
224
241 void SetLibSymbol( LIB_SYMBOL* aLibSymbol );
242
246 wxString GetDescription() const;
247
251 wxString GetKeyWords() const;
252
256 wxString GetDatasheet() const;
257
258 int GetUnit() const { return m_unit; }
259
263 void UpdatePins();
264
274 void SetUnit( int aUnit );
275
281 bool HasUnitDisplayName( int aUnit );
282
288 wxString GetUnitDisplayName( int aUnit );
289
298 void UpdateUnit( int aUnit );
299
300 int GetBodyStyle() const { return m_bodyStyle; }
301 void SetBodyStyle( int aBodyStyle );
302
303 wxString GetPrefix() const { return m_prefix; }
304
305 void SetPrefix( const wxString& aPrefix ) { m_prefix = aPrefix; }
306
310 void UpdatePrefix();
311
312 wxString SubReference( int aUnit, bool aAddSeparator = true ) const;
313
315 const TRANSFORM& GetTransform() const { return m_transform; }
316
317 void SetTransform( const TRANSFORM& aTransform );
318
324 int GetUnitCount() const;
325
332 void SetOrientation( int aOrientation );
333
349 int GetOrientation() const;
350
355 {
356 int mirroring = GetOrientation();
357
358 mirroring &= ( SYMBOL_ORIENTATION_T::SYM_MIRROR_X | SYMBOL_ORIENTATION_T::SYM_MIRROR_Y );
359
360 SetOrientation( aAngle | mirroring );
361 }
362
364 {
365 int orientation = GetOrientation();
366
367 orientation &= ~( SYMBOL_ORIENTATION_T::SYM_MIRROR_X | SYMBOL_ORIENTATION_T::SYM_MIRROR_Y );
368
369 switch( orientation )
370 {
371 default:
372 case SYM_NORMAL:
373 case SYM_ORIENT_0: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_0;
374 case SYM_ORIENT_90: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_90;
375 case SYM_ORIENT_180: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_180;
376 case SYM_ORIENT_270: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_270;
377 }
378 }
379
380 void SetMirrorX( bool aMirror )
381 {
382 int orientation = GetOrientation();
383
384 if( aMirror )
385 orientation |= SYMBOL_ORIENTATION_T::SYM_MIRROR_X;
386 else
388
389 SetOrientation( orientation );
390 }
391
392 bool GetMirrorX() const
393 {
394 return GetOrientation() & SYMBOL_ORIENTATION_T::SYM_MIRROR_X;
395 }
396
397 void SetMirrorY( bool aMirror )
398 {
399 int orientation = GetOrientation();
400
401 if( aMirror )
402 orientation |= SYMBOL_ORIENTATION_T::SYM_MIRROR_Y;
403 else
405
406 SetOrientation( orientation );
407 }
408
409 bool GetMirrorY() const
410 {
411 return GetOrientation() & SYMBOL_ORIENTATION_T::SYM_MIRROR_Y;
412 }
413
417 void GetContextualTextVars( wxArrayString* aVars ) const;
418
424 bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth = 0 ) const;
425
426 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
427
438 void ClearAnnotation( const SCH_SHEET_PATH* aSheetPath, bool aResetPrefix );
439
451 bool AddSheetPathReferenceEntryIfMissing( const KIID_PATH& aSheetPath );
452
453
454 const BOX2I GetBoundingBox() const override;
455
460
465
466
467 //-----<Fields>-----------------------------------------------------------
468
477 SCH_FIELD* GetField( MANDATORY_FIELD_T aFieldType );
478 const SCH_FIELD* GetField( MANDATORY_FIELD_T aFieldNdx ) const;
479
487 SCH_FIELD* GetFieldById( int aFieldId );
488
496 SCH_FIELD* GetFieldByName( const wxString& aFieldName );
497
498 const SCH_FIELD* GetFieldByName( const wxString& aFieldName ) const;
499
506 void GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly );
507
511 std::vector<SCH_FIELD>& GetFields() { return m_fields; }
512 const std::vector<SCH_FIELD>& GetFields() const { return m_fields; }
513
521 SCH_FIELD* AddField( const SCH_FIELD& aField );
522
528 void RemoveField( const wxString& aFieldName );
529
530 void RemoveField( SCH_FIELD* aField ) { RemoveField( aField->GetName() ); }
531
541 SCH_FIELD* FindField( const wxString& aFieldName, bool aIncludeDefaultFields = true,
542 bool aCaseInsensitive = false );
543
544 const wxString GetValueFieldText( bool aResolve, const SCH_SHEET_PATH* aPath,
545 bool aAllowExtraText ) const;
546 void SetValueFieldText( const wxString& aValue );
547
548 const wxString GetFootprintFieldText( bool aResolve, const SCH_SHEET_PATH* aPath,
549 bool aAllowExtraText ) const;
550 void SetFootprintFieldText( const wxString& aFootprint );
551
552 /*
553 * Field access for property manager
554 */
555 wxString GetRefProp() const
556 {
557 return GetRef( &Schematic()->CurrentSheet() );
558 }
559 void SetRefProp( const wxString aRef )
560 {
561 SetRef( &Schematic()->CurrentSheet(), aRef );
562 }
563 wxString GetValueProp() const
564 {
565 return GetValueFieldText( false, &Schematic()->CurrentSheet(), false );
566 }
567 void SetValueProp( const wxString aRef )
568 {
569 SetValueFieldText( aRef );
570 }
571
582 void UpdateFields( const SCH_SHEET_PATH* aPath, bool aUpdateStyle, bool aUpdateRef,
583 bool aUpdateOtherFields, bool aResetRef, bool aResetOtherFields );
584
588 int GetFieldCount() const { return (int)m_fields.size(); }
589
599 void AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) override;
600
601 void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override;
602
603
604 //-----</Fields>----------------------------------------------------------
605
606
613 SCH_PIN* GetPin( const wxString& number ) const;
614
620 void GetLibPins( std::vector<LIB_PIN*>& aPinsList ) const;
621
626 std::vector<LIB_PIN*> GetAllLibPins() const;
627
631 size_t GetFullPinCount() { return m_part ? m_part->GetPinCount() : 0; }
632
636 SCH_PIN* GetPin( LIB_PIN* aLibPin ) const;
637
646 std::vector<SCH_PIN*> GetPins( const SCH_SHEET_PATH* aSheet = nullptr ) const;
647
648
649 std::vector<std::unique_ptr<SCH_PIN>>& GetRawPins() { return m_pins; }
650
658 void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
659
667 void PrintBackground( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override;
668
669 void SwapData( SCH_ITEM* aItem ) override;
670
679 static bool IsReferenceStringValid( const wxString& aReferenceString );
680
686 const wxString GetRef( const SCH_SHEET_PATH* aSheet, bool aIncludeUnit = false ) const;
687
694 void SetRef( const SCH_SHEET_PATH* aSheet, const wxString& aReference );
695
702 bool IsAnnotated( const SCH_SHEET_PATH* aSheet );
703
715 void AddHierarchicalReference( const KIID_PATH& aPath,
716 const wxString& aRef,
717 int aUnit );
718
719 void AddHierarchicalReference( const SCH_SYMBOL_INSTANCE& aInstance );
720
722 int GetUnitSelection( const SCH_SHEET_PATH* aSheet ) const;
723
725 void SetUnitSelection( const SCH_SHEET_PATH* aSheet, int aUnitSelection );
726
728 void SetUnitSelection( int aUnitSelection );
729
730 // Geometric transforms (used in block operations):
731
732 void Move( const VECTOR2I& aMoveVector ) override
733 {
734 if( aMoveVector == VECTOR2I( 0, 0 ) )
735 return;
736
737 m_pos += aMoveVector;
738
739 for( SCH_FIELD& field : m_fields )
740 field.Move( aMoveVector );
741 }
742
743 void MirrorHorizontally( int aCenter ) override;
744 void MirrorVertically( int aCenter ) override;
745 void Rotate( const VECTOR2I& aCenter ) override;
746
747 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
748
749 void GetEndPoints( std::vector<DANGLING_END_ITEM>& aItemList ) override;
750
761 bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
762 std::vector<DANGLING_END_ITEM>& aItemListByPos,
763 const SCH_SHEET_PATH* aPath = nullptr ) override;
764
765 VECTOR2I GetPinPhysicalPosition( const LIB_PIN* Pin ) const;
766
767 bool IsConnectable() const override { return true; }
768
769 bool HasConnectivityChanges( const SCH_ITEM* aItem,
770 const SCH_SHEET_PATH* aInstance = nullptr ) const override;
771
772 bool CanConnect( const SCH_ITEM* aItem ) const override
773 {
774 return ( aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_WIRE ) ||
775 ( aItem->Type() == SCH_NO_CONNECT_T ) ||
776 ( aItem->Type() == SCH_JUNCTION_T ) ||
777 ( aItem->Type() == SCH_SYMBOL_T ) ||
778 ( aItem->Type() == SCH_DIRECTIVE_LABEL_T ) ||
779 ( aItem->Type() == SCH_LABEL_T ) ||
780 ( aItem->Type() == SCH_HIER_LABEL_T ) ||
781 ( aItem->Type() == SCH_GLOBAL_LABEL_T );
782 }
783
787 bool IsInNetlist() const;
788
789 std::vector<VECTOR2I> GetConnectionPoints() const override;
790
791 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
792 const std::vector<KICAD_T>& aScanTypes ) override;
793
801 LIB_ITEM* GetDrawItem( const VECTOR2I& aPosition, KICAD_T aType = TYPE_NOT_INIT );
802
803 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
804
805 BITMAPS GetMenuImage() const override;
806
807 bool operator <( const SCH_ITEM& aItem ) const override;
808
809 bool operator==( const SCH_SYMBOL& aSymbol) const;
810 bool operator!=( const SCH_SYMBOL& aSymbol) const;
811
812 SCH_SYMBOL& operator=( const SCH_ITEM& aItem );
813
814 bool IsReplaceable() const override { return true; }
815
816 VECTOR2I GetPosition() const override { return m_pos; }
817 void SetPosition( const VECTOR2I& aPosition ) override { Move( aPosition - m_pos ); }
818
819 int GetX() const { return GetPosition().x; };
820 void SetX( int aX ) { SetPosition( VECTOR2I( aX, GetY() ) ); }
821
822 int GetY() const { return GetPosition().y; }
823 void SetY( int aY ) { SetPosition( VECTOR2I( GetX(), aY ) ); }
824
825 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
826 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
827
828 void Plot( PLOTTER* aPlotter, bool aBackground,
829 const SCH_PLOT_SETTINGS& aPlotSettings ) const override;
830
838 void PlotPins( PLOTTER* aPlotter ) const;
839
846 void PlotDNP( PLOTTER* aPlotter ) const;
847
848 EDA_ITEM* Clone() const override;
849
850#if defined(DEBUG)
851 void Show( int nestLevel, std::ostream& os ) const override;
852#endif
853
854 void ClearBrightenedPins();
855
856 bool HasBrightenedPins();
857
858 bool GetExcludedFromSim() const override { return m_excludedFromSim; }
859 void SetExcludedFromSim( bool aExclude ) override { m_excludedFromSim = aExclude; }
860
861 bool GetExcludedFromBOM() const { return m_excludedFromBOM; }
862 void SetExcludedFromBOM( bool aIncludeInBOM ) { m_excludedFromBOM = aIncludeInBOM; }
863
865 void SetExcludedFromBoard( bool aIncludeOnBoard ) { m_excludedFromBoard = aIncludeOnBoard; }
866
867 bool GetDNP() const { return m_DNP; }
868 void SetDNP( bool aDNP ) { m_DNP = aDNP; }
869
870 bool GetShowPinNumbers() const
871 {
872 return m_part && m_part->ShowPinNumbers();
873 }
874
875 void SetShowPinNumbers( bool aShow )
876 {
877 if( m_part )
878 m_part->SetShowPinNumbers( aShow );
879 }
880
881 bool GetShowPinNames() const { return m_part && m_part->ShowPinNames(); }
882
883 void SetShowPinNames( bool aShow )
884 {
885 if( m_part )
886 m_part->SetShowPinNames( aShow );
887 }
888
889 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override;
890
896 bool IsSymbolLikePowerGlobalLabel() const;
897
898 bool IsPower() const;
899
900 double Similarity( const SCH_ITEM& aOther ) const override;
901
902 bool operator==( const SCH_ITEM& aOther ) const override;
903
904private:
905 BOX2I doGetBoundingBox( bool aIncludePins, bool aIncludeFields ) const;
906
907 bool doIsConnected( const VECTOR2I& aPosition ) const override;
908
909 void Init( const VECTOR2I& pos = VECTOR2I( 0, 0 ) );
910
913 int m_unit;
917 wxString m_prefix;
921
930
932 std::vector<SCH_FIELD> m_fields;
933
934 std::unique_ptr< LIB_SYMBOL > m_part;
936 std::vector<std::unique_ptr<SCH_PIN>> m_pins;
937 std::unordered_map<LIB_PIN*, SCH_PIN*> m_pinMap;
938
943 bool m_DNP;
944
945 // Defines the hierarchical path and reference of the symbol. This allows support
946 // for multiple references to a single sub-sheet.
947 std::vector<SCH_SYMBOL_INSTANCE> m_instanceReferences;
948
950 static std::unordered_map<TRANSFORM, int> s_transformToOrientationCache;
951};
952
953#endif /* __SYMBOL_H__ */
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
UTF8 Format() const
Definition: lib_id.cpp:118
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:68
Define a library symbol object.
Definition: lib_symbol.h:99
Base plotter engine class.
Definition: plotter.h:104
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:52
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:1007
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:165
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:113
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:272
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Schematic symbol object.
Definition: sch_symbol.h:109
const TRANSFORM & GetTransform() const
Definition: sch_symbol.h:315
void UpdatePrefix()
Set the prefix based on the current reference designator.
Definition: sch_symbol.cpp:843
wxString m_prefix
C, R, U, Q etc - the first character(s) which typically indicate what the symbol is.
Definition: sch_symbol.h:917
SCH_FIELD * GetFieldByName(const wxString &aFieldName)
Return a field in this symbol.
Definition: sch_symbol.cpp:977
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction) override
void GetLibPins(std::vector< LIB_PIN * > &aPinsList) const
Populate a vector with all the pins from the library object.
int GetUnitCount() const
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:486
void SetMirrorX(bool aMirror)
Definition: sch_symbol.h:380
bool IsSymbolLikePowerGlobalLabel() const
VECTOR2I m_pos
Definition: sch_symbol.h:911
wxString GetSymbolIDAsString() const
Definition: sch_symbol.h:205
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
Definition: sch_symbol.h:912
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
wxString GetDatasheet() const
Return the documentation text for the given part alias.
Definition: sch_symbol.cpp:332
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
void SetLibId(const LIB_ID &aName)
Definition: sch_symbol.cpp:290
bool HasBrightenedPins()
std::vector< SCH_FIELD > & GetFields()
Return a vector of fields from the symbol.
Definition: sch_symbol.h:511
bool GetShowPinNumbers() const
Definition: sch_symbol.h:870
void Print(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print a symbol.
Definition: sch_symbol.cpp:523
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Automatically orient all the fields in the symbol.
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
size_t GetFullPinCount()
Definition: sch_symbol.h:631
std::vector< std::unique_ptr< SCH_PIN > > & GetRawPins()
Definition: sch_symbol.h:649
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstances() const
Definition: sch_symbol.h:168
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_symbol.h:817
void PlotDNP(PLOTTER *aPlotter) const
Plot the red 'X' over the symbol.
bool operator!=(const SCH_SYMBOL &aSymbol) const
LIB_ITEM * GetDrawItem(const VECTOR2I &aPosition, KICAD_T aType=TYPE_NOT_INIT)
Return the symbol library item at aPosition that is part of this symbol.
int GetUnit() const
Definition: sch_symbol.h:258
bool IsConnectable() const override
Definition: sch_symbol.h:767
SYMBOL_ORIENTATION_PROP GetOrientationProp() const
Definition: sch_symbol.h:363
int GetFieldCount() const
Return the number of fields in this symbol.
Definition: sch_symbol.h:588
void SetDNP(bool aDNP)
Definition: sch_symbol.h:868
void SetBodyStyle(int aBodyStyle)
Definition: sch_symbol.cpp:467
void UpdateUnit(int aUnit)
Change the unit number to aUnit without setting any internal flags.
Definition: sch_symbol.cpp:461
int GetY() const
Definition: sch_symbol.h:822
wxString SubReference(int aUnit, bool aAddSeparator=true) const
Definition: sch_symbol.cpp:870
wxString GetClass() const override
Return the class name.
Definition: sch_symbol.h:148
void RemoveInstance(const SCH_SHEET_PATH &aInstancePath)
Definition: sch_symbol.cpp:613
static bool IsReferenceStringValid(const wxString &aReferenceString)
Test for an acceptable reference string.
Definition: sch_symbol.cpp:787
void SetMirrorY(bool aMirror)
Definition: sch_symbol.h:397
void PlotPins(PLOTTER *aPlotter) const
Plot just the symbol pins.
bool UseLibIdLookup() const
Definition: sch_symbol.h:220
void SetRefProp(const wxString aRef)
Definition: sch_symbol.h:559
void SetValueFieldText(const wxString &aValue)
Definition: sch_symbol.cpp:931
int GetX() const
Definition: sch_symbol.h:819
void RemoveField(const wxString &aFieldName)
Remove a user field from the symbol.
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
wxString GetSchSymbolLibraryName() const
Definition: sch_symbol.cpp:296
SCH_FIELD * FindField(const wxString &aFieldName, bool aIncludeDefaultFields=true, bool aCaseInsensitive=false)
Search for a SCH_FIELD with aFieldName.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const
Return the reference for the given sheet path.
Definition: sch_symbol.cpp:751
bool GetShowPinNames() const
Definition: sch_symbol.h:881
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_symbol.h:143
bool IsInNetlist() const
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_symbol.h:732
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const override
Return a user-visible description string of this item.
void ClearBrightenedPins()
void SetY(int aY)
Definition: sch_symbol.h:823
void SetShowPinNumbers(bool aShow)
Definition: sch_symbol.h:875
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_symbol.cpp:239
void SetExcludedFromSim(bool aExclude) override
Definition: sch_symbol.h:859
bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const override
Check if aItem has connectivity changes against this object.
bool GetMirrorX() const
Definition: sch_symbol.h:392
wxString GetRefProp() const
Definition: sch_symbol.h:555
bool m_excludedFromSim
True to exclude from simulation.
Definition: sch_symbol.h:940
bool AddSheetPathReferenceEntryIfMissing(const KIID_PATH &aSheetPath)
Add an instance to the alternate references list (m_instanceReferences), if this entry does not alrea...
SCH_FIELD * GetField(MANDATORY_FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:953
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
bool m_excludedFromBoard
True to exclude from netlist when updating board.
Definition: sch_symbol.h:942
static std::unordered_map< TRANSFORM, int > s_transformToOrientationCache
Definition: sch_symbol.h:950
VECTOR2I GetPinPhysicalPosition(const LIB_PIN *Pin) const
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
Definition: sch_symbol.cpp:341
std::vector< SCH_SYMBOL_INSTANCE > m_instanceReferences
Definition: sch_symbol.h:947
const std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef() const
Definition: sch_symbol.h:223
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
void SetValueProp(const wxString aRef)
Definition: sch_symbol.h:567
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_SETTINGS &aPlotSettings) const override
Plot the schematic item to aPlotter.
bool IsPointClickableAnchor(const VECTOR2I &aPos) const override
void UpdateFields(const SCH_SHEET_PATH *aPath, bool aUpdateStyle, bool aUpdateRef, bool aUpdateOtherFields, bool aResetRef, bool aResetOtherFields)
Restore fields to the original library values.
wxString m_schLibSymbolName
The name used to look up a symbol in the symbol library embedded in a schematic.
Definition: sch_symbol.h:929
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
Definition: sch_symbol.cpp:793
void ClearAnnotation(const SCH_SHEET_PATH *aSheetPath, bool aResetPrefix)
Clear exiting symbol annotation.
void SetOrientationProp(SYMBOL_ORIENTATION_PROP aAngle)
Orientation/mirroring access for property manager.
Definition: sch_symbol.h:354
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve a list of the SCH_PINs for the given sheet path.
const wxString GetFootprintFieldText(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText) const
Definition: sch_symbol.cpp:937
void PrintBackground(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset) override
Print only the background parts of a symbol (if any)
Definition: sch_symbol.cpp:511
wxString GetDescription() const
Definition: sch_symbol.cpp:314
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:932
std::unordered_map< LIB_PIN *, SCH_PIN * > m_pinMap
library pin pointer : SCH_PIN's index
Definition: sch_symbol.h:937
void SetOrientation(int aOrientation)
Compute the new transform matrix based on aOrientation for the symbol which is applied to the current...
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
int m_unit
The unit for multiple part per package symbols.
Definition: sch_symbol.h:913
void SetFootprintFieldText(const wxString &aFootprint)
Definition: sch_symbol.cpp:947
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
bool GetExcludedFromBOM() const
Definition: sch_symbol.h:861
void AddHierarchicalReference(const KIID_PATH &aPath, const wxString &aRef, int aUnit)
Add a full hierarchical reference to this symbol.
Definition: sch_symbol.cpp:649
bool IsMissingLibSymbol() const
Check to see if the library symbol is set to the dummy library symbol.
Definition: sch_symbol.cpp:245
VECTOR2I GetPosition() const override
Definition: sch_symbol.h:816
void Rotate(const VECTOR2I &aCenter) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
void SetTransform(const TRANSFORM &aTransform)
Definition: sch_symbol.cpp:479
bool ResolveTextVar(const SCH_SHEET_PATH *aPath, wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
const std::vector< SCH_FIELD > & GetFields() const
Definition: sch_symbol.h:512
bool CanConnect(const SCH_ITEM *aItem) const override
Definition: sch_symbol.h:772
void Init(const VECTOR2I &pos=VECTOR2I(0, 0))
Definition: sch_symbol.cpp:208
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the layers the item is drawn on (which may be more than its "home" layer)
Definition: sch_symbol.cpp:254
bool GetExcludedFromSim() const override
Definition: sch_symbol.h:858
bool operator<(const SCH_ITEM &aItem) const override
bool m_DNP
True if symbol is set to 'Do Not Populate'.
Definition: sch_symbol.h:943
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this symbol.
wxString GetKeyWords() const
Definition: sch_symbol.cpp:323
void SetSchSymbolLibraryName(const wxString &aName)
The name of the symbol in the schematic library symbol list.
Definition: sch_symbol.h:218
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
SCH_FIELD * GetFieldById(int aFieldId)
Return a field in this symbol.
Definition: sch_symbol.cpp:965
bool UpdateDanglingState(std::vector< DANGLING_END_ITEM > &aItemListByType, std::vector< DANGLING_END_ITEM > &aItemListByPos, const SCH_SHEET_PATH *aPath=nullptr) override
Test if the symbol's dangling state has changed for all pins.
bool GetInstance(SCH_SYMBOL_INSTANCE &aInstance, const KIID_PATH &aSheetPath, bool aTestFromEnd=false) const
Definition: sch_symbol.cpp:589
TRANSFORM & GetTransform()
Definition: sch_symbol.h:314
bool HasUnitDisplayName(int aUnit)
Return true if the given unit aUnit has a display name set.
Definition: sch_symbol.cpp:503
void SetExcludedFromBOM(bool aIncludeInBOM)
Definition: sch_symbol.h:862
BOX2I doGetBoundingBox(bool aIncludePins, bool aIncludeFields) const
bool GetMirrorY() const
Definition: sch_symbol.h:409
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
const wxString GetValueFieldText(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText) const
Definition: sch_symbol.cpp:921
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
int GetOrientation() const
Get the display symbol orientation.
bool IsAnnotated(const SCH_SHEET_PATH *aSheet)
Check if the symbol has a valid annotation (reference) for the given sheet path.
Definition: sch_symbol.cpp:829
void RemoveField(SCH_FIELD *aField)
Definition: sch_symbol.h:530
void SetX(int aX)
Definition: sch_symbol.h:820
std::vector< VECTOR2I > GetConnectionPoints() const override
Add all the connection points for this item to aPoints.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void SetShowPinNames(bool aShow)
Definition: sch_symbol.h:883
bool m_isInNetlist
True if the symbol should appear in the netlist.
Definition: sch_symbol.h:939
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
Definition: sch_symbol.cpp:879
void SetUnit(int aUnit)
Change the unit number to aUnit.
Definition: sch_symbol.cpp:455
const LIB_ID & GetLibId() const
Definition: sch_symbol.h:203
wxString GetUnitDisplayName(int aUnit)
Return the display name for a given unit aUnit.
Definition: sch_symbol.cpp:495
BOX2I GetBodyAndPinsBoundingBox() const
Return a bounding box for the symbol body and pins but not the fields.
TRANSFORM m_transform
The rotation/mirror transformation.
Definition: sch_symbol.h:931
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
wxString GetValueProp() const
Definition: sch_symbol.h:563
SCH_SYMBOL & operator=(const SCH_ITEM &aItem)
std::vector< LIB_PIN * > GetAllLibPins() const
bool GetExcludedFromBoard() const
Definition: sch_symbol.h:864
void SetPrefix(const wxString &aPrefix)
Definition: sch_symbol.h:305
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
Definition: sch_symbol.cpp:895
bool m_excludedFromBOM
True to exclude from bill of materials export.
Definition: sch_symbol.h:941
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:222
std::vector< std::unique_ptr< SCH_PIN > > m_pins
a SCH_PIN for every LIB_PIN (all units)
Definition: sch_symbol.h:936
void SetExcludedFromBoard(bool aIncludeOnBoard)
Definition: sch_symbol.h:865
bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
Definition: sch_symbol.h:814
int m_bodyStyle
The alternate body style for symbols that have more than one body style defined.
Definition: sch_symbol.h:914
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
Definition: sch_symbol.cpp:305
int GetBodyStyle() const
Definition: sch_symbol.h:300
BOX2I GetBodyBoundingBox() const
Return a bounding box for the symbol body but not the pins or fields.
void SortInstances(bool(*aSortFunction)(const SCH_SYMBOL_INSTANCE &aLhs, const SCH_SYMBOL_INSTANCE &aRhs))
Definition: sch_symbol.cpp:641
wxString GetPrefix() const
Definition: sch_symbol.h:303
bool IsMovableFromAnchorPoint() const override
Return true for items which are moved with the anchor point at mouse cursor and false for items moved...
Definition: sch_symbol.cpp:269
bool IsPower() const
std::unique_ptr< LIB_SYMBOL > m_part
a flattened copy of the LIB_SYMBOL from the PROJECT's libraries.
Definition: sch_symbol.h:934
bool operator==(const SCH_SYMBOL &aSymbol) const
bool GetDNP() const
Definition: sch_symbol.h:867
A collection of SYMBOL_LIB objects.
Object used to load, save, search, and otherwise manipulate symbol library files.
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:46
INSPECT_RESULT
Definition: eda_item.h:42
const INSPECTOR_FUNC & INSPECTOR
Definition: eda_item.h:78
@ LAYER_WIRE
Definition: layer_ids.h:355
Message panel definition file.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
std::string toUTFTildaText(const wxString &txt)
Convert a wxString to UTF8 and replace any control characters with a ~, where a control character is ...
Definition: sch_symbol.cpp:57
std::weak_ptr< LIB_SYMBOL > PART_REF
Definition: sch_symbol.h:72
SYMBOL_ORIENTATION_PROP
Definition: sch_symbol.h:97
@ SYMBOL_ANGLE_180
Definition: sch_symbol.h:100
@ SYMBOL_ANGLE_0
Definition: sch_symbol.h:98
@ SYMBOL_ANGLE_90
Definition: sch_symbol.h:99
@ SYMBOL_ANGLE_270
Definition: sch_symbol.h:101
std::vector< SCH_FIELD > SCH_FIELDS
A container for several SCH_FIELD items.
Definition: sch_symbol.h:70
SYMBOL_ORIENTATION_T
enum used in RotationMiroir()
Definition: sch_symbol.h:81
@ SYM_ORIENT_270
Definition: sch_symbol.h:88
@ SYM_ROTATE_CLOCKWISE
Definition: sch_symbol.h:83
@ SYM_ROTATE_COUNTERCLOCKWISE
Definition: sch_symbol.h:84
@ SYM_MIRROR_Y
Definition: sch_symbol.h:90
@ SYM_ORIENT_180
Definition: sch_symbol.h:87
@ SYM_MIRROR_X
Definition: sch_symbol.h:89
@ SYM_NORMAL
Definition: sch_symbol.h:82
@ SYM_ORIENT_90
Definition: sch_symbol.h:86
@ SYM_ORIENT_0
Definition: sch_symbol.h:85
A simple container for schematic symbol instance information.
MANDATORY_FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_LINE_T
Definition: typeinfo.h:148
@ SCH_NO_CONNECT_T
Definition: typeinfo.h:145
@ TYPE_NOT_INIT
Definition: typeinfo.h:81
@ SCH_SYMBOL_T
Definition: typeinfo.h:160
@ SCH_DIRECTIVE_LABEL_T
Definition: typeinfo.h:158
@ SCH_LABEL_T
Definition: typeinfo.h:155
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:157
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:156
@ SCH_JUNCTION_T
Definition: typeinfo.h:144
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588