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 SCH_SYMBOL_H
29#define SCH_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 <symbol.h>
49#include <sch_field.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_PIN;
59class LIB_SYMBOL;
60class NETLIST_OBJECT_LIST;
61class SYMBOL_LIB;
62class SYMBOL_LIBS;
63class EE_COLLECTOR;
64class SCH_SCREEN;
66
67
69typedef std::vector<SCH_FIELD> SCH_FIELDS;
70
71typedef std::weak_ptr<LIB_SYMBOL> PART_REF;
72
73
74extern std::string toUTFTildaText( const wxString& txt );
75
76
77// @todo Move this to transform alone with all of the transform manipulation code.
80{
81 SYM_NORMAL, // Normal orientation, no rotation or mirror
82 SYM_ROTATE_CLOCKWISE, // Rotate -90
84 SYM_ORIENT_0, // No rotation and no mirror id SYM_NORMAL
85 SYM_ORIENT_90, // Rotate 90, no mirror
86 SYM_ORIENT_180, // Rotate 180, no mirror
87 SYM_ORIENT_270, // Rotate -90, no mirror
88 SYM_MIRROR_X = 0x100, // Mirror around X axis
89 SYM_MIRROR_Y = 0x200 // Mirror around Y axis
90};
91
92
93// Cover for SYMBOL_ORIENTATION_T for property manager (in order to expose only a subset of
94// SYMBOL_ORIENTATION_T's values).
96{
102
103
107class SCH_SYMBOL : public SYMBOL
108{
109public:
110 SCH_SYMBOL();
111
122 SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const LIB_ID& aLibId, const SCH_SHEET_PATH* aSheet,
123 int aUnit, int aBodyStyle = 0, const VECTOR2I& aPosition = VECTOR2I( 0, 0 ),
124 EDA_ITEM* aParent = nullptr );
125
126 SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const SCH_SHEET_PATH* aSheet, const PICKED_SYMBOL& aSel,
127 const VECTOR2I& aPosition = VECTOR2I( 0, 0 ), EDA_ITEM* aParent = nullptr );
128
138 SCH_SYMBOL( const SCH_SYMBOL& aSymbol );
139
141
142 static inline bool ClassOf( const EDA_ITEM* aItem )
143 {
144 return aItem && SCH_SYMBOL_T == aItem->Type();
145 }
146
147 wxString GetClass() const override
148 {
149 return wxT( "SCH_SYMBOL" );
150 }
151
165 bool IsMissingLibSymbol() const;
166
167 const std::vector<SCH_SYMBOL_INSTANCE>& GetInstances() const
168 {
170 }
171
172 bool GetInstance( SCH_SYMBOL_INSTANCE& aInstance,
173 const KIID_PATH& aSheetPath, bool aTestFromEnd = false ) const;
174
175 void RemoveInstance( const SCH_SHEET_PATH& aInstancePath );
176
177 void RemoveInstance( const KIID_PATH& aInstancePath );
178
193 bool IsMovableFromAnchorPoint() const override;
194
195 void SetLibId( const LIB_ID& aName );
196
197 const LIB_ID& GetLibId() const override { return m_lib_id; }
198
199 wxString GetSymbolIDAsString() const { return m_lib_id.Format(); }
200
212 void SetSchSymbolLibraryName( const wxString& aName ) { m_schLibSymbolName = aName; }
213 wxString GetSchSymbolLibraryName() const;
214 bool UseLibIdLookup() const { return m_schLibSymbolName.IsEmpty(); }
215
216 std::unique_ptr< LIB_SYMBOL >& GetLibSymbolRef() { return m_part; }
217 const std::unique_ptr< LIB_SYMBOL >& GetLibSymbolRef() const { return m_part; }
218
235 void SetLibSymbol( LIB_SYMBOL* aLibSymbol );
236
240 wxString GetDescription() const override;
241
245 wxString GetKeyWords() const override;
246
250 wxString GetDatasheet() const;
251
255 void UpdatePins();
256
262 bool HasUnitDisplayName( int aUnit );
263
269 wxString GetUnitDisplayName( int aUnit );
270
271 void SetBodyStyle( int aBodyStyle ) override;
272
273 bool HasAlternateBodyStyle() const override;
274
275 wxString GetPrefix() const { return m_prefix; }
276 void SetPrefix( const wxString& aPrefix ) { m_prefix = aPrefix; }
277
281 void UpdatePrefix();
282
283 wxString SubReference( int aUnit, bool aAddSeparator = true ) const;
284
286 const TRANSFORM& GetTransform() const { return m_transform; }
287
288 void SetTransform( const TRANSFORM& aTransform );
289
295 int GetUnitCount() const override;
296
297 bool IsMulti() const override { return GetUnitCount() > 1; }
298
305 void SetOrientation( int aOrientation );
306
322 int GetOrientation() const;
323
328 {
329 int mirroring = GetOrientation();
330
331 mirroring &= ( SYMBOL_ORIENTATION_T::SYM_MIRROR_X | SYMBOL_ORIENTATION_T::SYM_MIRROR_Y );
332
333 SetOrientation( aAngle | mirroring );
334 }
335
337 {
338 int orientation = GetOrientation();
339
340 orientation &= ~( SYMBOL_ORIENTATION_T::SYM_MIRROR_X | SYMBOL_ORIENTATION_T::SYM_MIRROR_Y );
341
342 switch( orientation )
343 {
344 default:
345 case SYM_NORMAL:
346 case SYM_ORIENT_0: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_0;
347 case SYM_ORIENT_90: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_90;
348 case SYM_ORIENT_180: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_180;
349 case SYM_ORIENT_270: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_270;
350 }
351 }
352
353 void SetMirrorX( bool aMirror )
354 {
355 int orientation = GetOrientation();
356
357 if( aMirror )
358 orientation |= SYMBOL_ORIENTATION_T::SYM_MIRROR_X;
359 else
361
362 SetOrientation( orientation );
363 }
364
365 bool GetMirrorX() const
366 {
367 return GetOrientation() & SYMBOL_ORIENTATION_T::SYM_MIRROR_X;
368 }
369
370 void SetMirrorY( bool aMirror )
371 {
372 int orientation = GetOrientation();
373
374 if( aMirror )
375 orientation |= SYMBOL_ORIENTATION_T::SYM_MIRROR_Y;
376 else
378
379 SetOrientation( orientation );
380 }
381
382 bool GetMirrorY() const
383 {
384 return GetOrientation() & SYMBOL_ORIENTATION_T::SYM_MIRROR_Y;
385 }
386
390 void GetContextualTextVars( wxArrayString* aVars ) const;
391
397 bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth = 0 ) const;
398
399 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
400
411 void ClearAnnotation( const SCH_SHEET_PATH* aSheetPath, bool aResetPrefix );
412
424 bool AddSheetPathReferenceEntryIfMissing( const KIID_PATH& aSheetPath );
425
426
427 const BOX2I GetBoundingBox() const override;
428
433
438
439
440 //-----<Fields>-----------------------------------------------------------
441
450 SCH_FIELD* GetField( MANDATORY_FIELD_T aFieldType );
451 const SCH_FIELD* GetField( MANDATORY_FIELD_T aFieldNdx ) const;
452
460 SCH_FIELD* GetFieldById( int aFieldId );
461
469 SCH_FIELD* GetFieldByName( const wxString& aFieldName );
470
471 const SCH_FIELD* GetFieldByName( const wxString& aFieldName ) const;
472
479 void GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly );
480
484 std::vector<SCH_FIELD>& GetFields() { return m_fields; }
485 const std::vector<SCH_FIELD>& GetFields() const { return m_fields; }
486
494 SCH_FIELD* AddField( const SCH_FIELD& aField );
495
501 void RemoveField( const wxString& aFieldName );
502
503 void RemoveField( SCH_FIELD* aField ) { RemoveField( aField->GetName() ); }
504
514 SCH_FIELD* FindField( const wxString& aFieldName, bool aIncludeDefaultFields = true,
515 bool aCaseInsensitive = false );
516
520 const wxString GetRef( const SCH_SHEET_PATH* aSheet,
521 bool aIncludeUnit = false ) const override;
522
526 const wxString GetValue( bool aResolve, const SCH_SHEET_PATH* aPath,
527 bool aAllowExtraText ) const override;
528
529 void SetValueFieldText( const wxString& aValue );
530
531 const wxString GetFootprintFieldText( bool aResolve, const SCH_SHEET_PATH* aPath,
532 bool aAllowExtraText ) const;
533 void SetFootprintFieldText( const wxString& aFootprint );
534
535 /*
536 * Field access for property manager
537 */
538 wxString GetRefProp() const
539 {
540 return GetRef( &Schematic()->CurrentSheet() );
541 }
542 void SetRefProp( const wxString& aRef )
543 {
544 SetRef( &Schematic()->CurrentSheet(), aRef );
545 }
546 wxString GetValueProp() const
547 {
548 return GetValue( false, &Schematic()->CurrentSheet(), false );
549 }
550 void SetValueProp( const wxString& aRef )
551 {
552 SetValueFieldText( aRef );
553 }
554
565 void UpdateFields( const SCH_SHEET_PATH* aPath, bool aUpdateStyle, bool aUpdateRef,
566 bool aUpdateOtherFields, bool aResetRef, bool aResetOtherFields );
567
571 int GetFieldCount() const { return (int)m_fields.size(); }
572
582 void AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) override;
583
584 void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override;
585
586
587 //-----</Fields>----------------------------------------------------------
588
589
596 SCH_PIN* GetPin( const wxString& number ) const;
597
603 void GetLibPins( std::vector<LIB_PIN*>& aPinsList ) const;
604
609 std::vector<LIB_PIN*> GetAllLibPins() const;
610
614 size_t GetFullPinCount() { return m_part ? m_part->GetPinCount() : 0; }
615
619 SCH_PIN* GetPin( LIB_PIN* aLibPin ) const;
620
629 std::vector<SCH_PIN*> GetPins( const SCH_SHEET_PATH* aSheet = nullptr ) const;
630
631
632 std::vector<std::unique_ptr<SCH_PIN>>& GetRawPins() { return m_pins; }
633
634 void SwapData( SCH_ITEM* aItem ) override;
635
644 static bool IsReferenceStringValid( const wxString& aReferenceString );
645
652 void SetRef( const SCH_SHEET_PATH* aSheet, const wxString& aReference );
653
660 bool IsAnnotated( const SCH_SHEET_PATH* aSheet ) const;
661
673 void AddHierarchicalReference( const KIID_PATH& aPath,
674 const wxString& aRef,
675 int aUnit );
676
677 void AddHierarchicalReference( const SCH_SYMBOL_INSTANCE& aInstance );
678
680 int GetUnitSelection( const SCH_SHEET_PATH* aSheet ) const;
681
683 void SetUnitSelection( const SCH_SHEET_PATH* aSheet, int aUnitSelection );
684
686 void SetUnitSelection( int aUnitSelection );
687
688 void Move( const VECTOR2I& aMoveVector ) override
689 {
690 if( aMoveVector == VECTOR2I( 0, 0 ) )
691 return;
692
693 m_pos += aMoveVector;
694
695 for( SCH_FIELD& field : m_fields )
696 field.Move( aMoveVector );
697 }
698
699 void MirrorHorizontally( int aCenter ) override;
700 void MirrorVertically( int aCenter ) override;
701 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
702
703 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
704
705 void GetEndPoints( std::vector<DANGLING_END_ITEM>& aItemList ) override;
706
717 bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
718 std::vector<DANGLING_END_ITEM>& aItemListByPos,
719 const SCH_SHEET_PATH* aPath = nullptr ) override;
720
721 VECTOR2I GetPinPhysicalPosition( const LIB_PIN* Pin ) const;
722
723 bool IsConnectable() const override { return true; }
724
725 bool HasConnectivityChanges( const SCH_ITEM* aItem,
726 const SCH_SHEET_PATH* aInstance = nullptr ) const override;
727
728 bool CanConnect( const SCH_ITEM* aItem ) const override
729 {
730 return ( aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_WIRE ) ||
731 ( aItem->Type() == SCH_NO_CONNECT_T ) ||
732 ( aItem->Type() == SCH_JUNCTION_T ) ||
733 ( aItem->Type() == SCH_SYMBOL_T ) ||
734 ( aItem->Type() == SCH_DIRECTIVE_LABEL_T ) ||
735 ( aItem->Type() == SCH_LABEL_T ) ||
736 ( aItem->Type() == SCH_HIER_LABEL_T ) ||
737 ( aItem->Type() == SCH_GLOBAL_LABEL_T );
738 }
739
743 bool IsInNetlist() const;
744
745 std::vector<VECTOR2I> GetConnectionPoints() const override;
746
747 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
748 const std::vector<KICAD_T>& aScanTypes ) override;
749
757 SCH_ITEM* GetDrawItem( const VECTOR2I& aPosition, KICAD_T aType = TYPE_NOT_INIT );
758
759 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const override;
760
761 BITMAPS GetMenuImage() const override;
762
763 bool operator <( const SCH_ITEM& aItem ) const override;
764
765 bool operator==( const SCH_SYMBOL& aSymbol) const;
766 bool operator!=( const SCH_SYMBOL& aSymbol) const;
767
768 SCH_SYMBOL& operator=( const SCH_SYMBOL& aItem );
769
770 bool IsReplaceable() const override { return true; }
771
772 VECTOR2I GetPosition() const override { return m_pos; }
773 void SetPosition( const VECTOR2I& aPosition ) override { Move( aPosition - m_pos ); }
774
775 int GetX() const { return GetPosition().x; };
776 void SetX( int aX ) { SetPosition( VECTOR2I( aX, GetY() ) ); }
777
778 int GetY() const { return GetPosition().y; }
779 void SetY( int aY ) { SetPosition( VECTOR2I( GetX(), aY ) ); }
780
781 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
782 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
783
791 void Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
792 const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) override;
793
801 void PrintBackground( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
802 const VECTOR2I& aOffset, bool aDimmed ) override;
803
804 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
805 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
806
814 void PlotPins( PLOTTER* aPlotter ) const;
815
822 void PlotDNP( PLOTTER* aPlotter ) const;
823
824 EDA_ITEM* Clone() const override;
825
826#if defined(DEBUG)
827 void Show( int nestLevel, std::ostream& os ) const override;
828#endif
829
830 void ClearBrightenedPins();
831
832 bool HasBrightenedPins();
833
834 bool GetExcludedFromSim() const override { return m_excludedFromSim; }
835 void SetExcludedFromSim( bool aExclude ) override { m_excludedFromSim = aExclude; }
836
837 bool GetExcludedFromBOM() const { return m_excludedFromBOM; }
838 void SetExcludedFromBOM( bool aIncludeInBOM ) { m_excludedFromBOM = aIncludeInBOM; }
839
841 void SetExcludedFromBoard( bool aIncludeOnBoard ) { m_excludedFromBoard = aIncludeOnBoard; }
842
843 bool GetDNP() const { return m_DNP; }
844 void SetDNP( bool aDNP ) { m_DNP = aDNP; }
845
846 bool GetShowPinNumbers() const
847 {
848 return m_part && m_part->GetShowPinNumbers();
849 }
850
851 void SetShowPinNumbers( bool aShow )
852 {
853 if( m_part )
854 m_part->SetShowPinNumbers( aShow );
855 }
856
857 bool GetShowPinNames() const { return m_part && m_part->GetShowPinNames(); }
858
859 void SetShowPinNames( bool aShow )
860 {
861 if( m_part )
862 m_part->SetShowPinNames( aShow );
863 }
864
865 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override;
866
872 bool IsSymbolLikePowerGlobalLabel() const;
873
874 bool IsPower() const override;
875 bool IsNormal() const override;
876
877 double Similarity( const SCH_ITEM& aOther ) const override;
878
879 bool operator==( const SCH_ITEM& aOther ) const override;
880
881private:
882 BOX2I doGetBoundingBox( bool aIncludePins, bool aIncludeFields ) const;
883
884 bool doIsConnected( const VECTOR2I& aPosition ) const override;
885
886 void Init( const VECTOR2I& pos = VECTOR2I( 0, 0 ) );
887
890 wxString m_prefix;
894
903
905 std::vector<SCH_FIELD> m_fields;
906
907 std::unique_ptr< LIB_SYMBOL > m_part;
909 std::vector<std::unique_ptr<SCH_PIN>> m_pins;
910 std::unordered_map<LIB_PIN*, SCH_PIN*> m_pinMap;
911
916 bool m_DNP;
917
918 // Defines the hierarchical path and reference of the symbol. This allows support
919 // for multiple references to a single sub-sheet.
920 std::vector<SCH_SYMBOL_INSTANCE> m_instanceReferences;
921
923 static std::unordered_map<TRANSFORM, int> s_transformToOrientationCache;
924};
925
926#endif /* SCH_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:88
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:100
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
Define a library symbol object.
Definition: lib_symbol.h:78
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:51
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:1130
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:172
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:139
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:287
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:108
const TRANSFORM & GetTransform() const
Definition: sch_symbol.h:286
void SetValueProp(const wxString &aRef)
Definition: sch_symbol.h:550
SCH_SYMBOL & operator=(const SCH_SYMBOL &aItem)
void UpdatePrefix()
Set the prefix based on the current reference designator.
Definition: sch_symbol.cpp:813
wxString m_prefix
C, R, U, Q etc - the first character(s) which typically indicate what the symbol is.
Definition: sch_symbol.h:890
SCH_FIELD * GetFieldByName(const wxString &aFieldName)
Return a field in this symbol.
Definition: sch_symbol.cpp:947
wxString GetDescription() const override
Definition: sch_symbol.cpp:291
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.
void SetMirrorX(bool aMirror)
Definition: sch_symbol.h:353
bool IsSymbolLikePowerGlobalLabel() const
VECTOR2I m_pos
Definition: sch_symbol.h:888
wxString GetSymbolIDAsString() const
Definition: sch_symbol.h:199
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
Definition: sch_symbol.h:889
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:309
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:267
bool HasBrightenedPins()
std::vector< SCH_FIELD > & GetFields()
Return a vector of fields from the symbol.
Definition: sch_symbol.h:484
bool GetShowPinNumbers() const
Definition: sch_symbol.h:846
void SetRefProp(const wxString &aRef)
Definition: sch_symbol.h:542
void Print(const SCH_RENDER_SETTINGS *aSettings, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aForceNoFill, bool aDimmed) override
Print a symbol.
Definition: sch_symbol.cpp:501
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.
SCH_ITEM * GetDrawItem(const VECTOR2I &aPosition, KICAD_T aType=TYPE_NOT_INIT)
Return the symbol library item at aPosition that is part of this 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:614
std::vector< std::unique_ptr< SCH_PIN > > & GetRawPins()
Definition: sch_symbol.h:632
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstances() const
Definition: sch_symbol.h:167
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_symbol.h:773
void PlotDNP(PLOTTER *aPlotter) const
Plot the red 'X' over the symbol.
bool operator!=(const SCH_SYMBOL &aSymbol) const
bool IsConnectable() const override
Definition: sch_symbol.h:723
SYMBOL_ORIENTATION_PROP GetOrientationProp() const
Definition: sch_symbol.h:336
int GetFieldCount() const
Return the number of fields in this symbol.
Definition: sch_symbol.h:571
void SetDNP(bool aDNP)
Definition: sch_symbol.h:844
int GetY() const
Definition: sch_symbol.h:778
wxString SubReference(int aUnit, bool aAddSeparator=true) const
Definition: sch_symbol.cpp:840
wxString GetClass() const override
Return the class name.
Definition: sch_symbol.h:147
void RemoveInstance(const SCH_SHEET_PATH &aInstancePath)
Definition: sch_symbol.cpp:596
static bool IsReferenceStringValid(const wxString &aReferenceString)
Test for an acceptable reference string.
Definition: sch_symbol.cpp:757
bool IsAnnotated(const SCH_SHEET_PATH *aSheet) const
Check if the symbol has a valid annotation (reference) for the given sheet path.
Definition: sch_symbol.cpp:799
void SetMirrorY(bool aMirror)
Definition: sch_symbol.h:370
void PlotPins(PLOTTER *aPlotter) const
Plot just the symbol pins.
bool UseLibIdLookup() const
Definition: sch_symbol.h:214
void SetValueFieldText(const wxString &aValue)
Definition: sch_symbol.cpp:901
int GetX() const
Definition: sch_symbol.h:775
void RemoveField(const wxString &aFieldName)
Remove a user field from the symbol.
Definition: sch_symbol.cpp:993
void SetBodyStyle(int aBodyStyle) override
Definition: sch_symbol.cpp:432
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
wxString GetKeyWords() const override
Definition: sch_symbol.cpp:300
wxString GetSchSymbolLibraryName() const
Definition: sch_symbol.cpp:273
SCH_FIELD * FindField(const wxString &aFieldName, bool aIncludeDefaultFields=true, bool aCaseInsensitive=false)
Search for a SCH_FIELD with aFieldName.
bool GetShowPinNames() const
Definition: sch_symbol.h:857
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_symbol.h:142
bool IsInNetlist() const
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_symbol.h:688
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:779
void SetShowPinNumbers(bool aShow)
Definition: sch_symbol.h:851
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_symbol.cpp:234
void SetExcludedFromSim(bool aExclude) override
Definition: sch_symbol.h:835
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:365
wxString GetRefProp() const
Definition: sch_symbol.h:538
bool m_excludedFromSim
True to exclude from simulation.
Definition: sch_symbol.h:913
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:923
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:915
static std::unordered_map< TRANSFORM, int > s_transformToOrientationCache
Definition: sch_symbol.h:923
VECTOR2I GetPinPhysicalPosition(const LIB_PIN *Pin) const
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
Definition: sch_symbol.cpp:318
std::vector< SCH_SYMBOL_INSTANCE > m_instanceReferences
Definition: sch_symbol.h:920
const wxString GetValue(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText) const override
Definition: sch_symbol.cpp:891
const std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef() const
Definition: sch_symbol.h:217
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
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:902
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:763
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:327
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:907
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:905
std::unordered_map< LIB_PIN *, SCH_PIN * > m_pinMap
library pin pointer : SCH_PIN's index
Definition: sch_symbol.h:910
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.
void SetFootprintFieldText(const wxString &aFootprint)
Definition: sch_symbol.cpp:917
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:837
void AddHierarchicalReference(const KIID_PATH &aPath, const wxString &aRef, int aUnit)
Add a full hierarchical reference to this symbol.
Definition: sch_symbol.cpp:624
bool IsMissingLibSymbol() const
Check to see if the library symbol is set to the dummy library symbol.
Definition: sch_symbol.cpp:240
VECTOR2I GetPosition() const override
Definition: sch_symbol.h:772
void SetTransform(const TRANSFORM &aTransform)
Definition: sch_symbol.cpp:453
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:485
bool CanConnect(const SCH_ITEM *aItem) const override
Definition: sch_symbol.h:728
void Init(const VECTOR2I &pos=VECTOR2I(0, 0))
Definition: sch_symbol.cpp:203
bool GetExcludedFromSim() const override
Definition: sch_symbol.h:834
bool HasAlternateBodyStyle() const override
Test if symbol has more than one body conversion type (DeMorgan).
Definition: sch_symbol.cpp:444
const LIB_ID & GetLibId() const override
Definition: sch_symbol.h:197
bool operator<(const SCH_ITEM &aItem) const override
bool m_DNP
True if symbol is set to 'Do Not Populate'.
Definition: sch_symbol.h:916
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this symbol.
void SetSchSymbolLibraryName(const wxString &aName)
The name of the symbol in the schematic library symbol list.
Definition: sch_symbol.h:212
bool IsMulti() const override
Definition: sch_symbol.h:297
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:935
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:572
TRANSFORM & GetTransform()
Definition: sch_symbol.h:285
bool HasUnitDisplayName(int aUnit)
Return true if the given unit aUnit has a display name set.
Definition: sch_symbol.cpp:476
void SetExcludedFromBOM(bool aIncludeInBOM)
Definition: sch_symbol.h:838
BOX2I doGetBoundingBox(bool aIncludePins, bool aIncludeFields) const
bool GetMirrorY() const
Definition: sch_symbol.h:382
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
Definition: sch_symbol.cpp:986
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.
void RemoveField(SCH_FIELD *aField)
Definition: sch_symbol.h:503
void SetX(int aX)
Definition: sch_symbol.h:776
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:859
bool m_isInNetlist
True if the symbol should appear in the netlist.
Definition: sch_symbol.h:912
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
Definition: sch_symbol.cpp:849
wxString GetUnitDisplayName(int aUnit)
Return the display name for a given unit aUnit.
Definition: sch_symbol.cpp:468
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:904
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
wxString GetValueProp() const
Definition: sch_symbol.h:546
void PrintBackground(const SCH_RENDER_SETTINGS *aSettings, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Print only the background parts of a symbol (if any)
Definition: sch_symbol.cpp:484
std::vector< LIB_PIN * > GetAllLibPins() const
bool GetExcludedFromBoard() const
Definition: sch_symbol.h:840
int GetUnitCount() const override
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:459
void SetPrefix(const wxString &aPrefix)
Definition: sch_symbol.h:276
void Plot(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed) override
Plot the item to aPlotter.
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
Definition: sch_symbol.cpp:865
bool m_excludedFromBOM
True to exclude from bill of materials export.
Definition: sch_symbol.h:914
bool IsNormal() const override
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:216
std::vector< std::unique_ptr< SCH_PIN > > m_pins
a SCH_PIN for every LIB_PIN (all units)
Definition: sch_symbol.h:909
void SetExcludedFromBoard(bool aIncludeOnBoard)
Definition: sch_symbol.h:841
bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
Definition: sch_symbol.h:770
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
Definition: sch_symbol.cpp:282
BOX2I GetBodyBoundingBox() const
Return a bounding box for the symbol body but not the pins or fields.
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
Definition: sch_symbol.cpp:724
wxString GetPrefix() const
Definition: sch_symbol.h:275
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
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:246
bool IsPower() const override
std::unique_ptr< LIB_SYMBOL > m_part
a flattened copy of the LIB_SYMBOL from the PROJECT's libraries.
Definition: sch_symbol.h:907
bool operator==(const SCH_SYMBOL &aSymbol) const
bool GetDNP() const
Definition: sch_symbol.h:843
A collection of SYMBOL_LIB objects.
Object used to load, save, search, and otherwise manipulate symbol library files.
A base class for LIB_SYMBOL and SCH_SYMBOL.
Definition: symbol.h:34
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:46
INSPECT_RESULT
Definition: eda_item.h:43
const INSPECTOR_FUNC & INSPECTOR
Definition: eda_item.h:81
@ LAYER_WIRE
Definition: layer_ids.h:356
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:71
SYMBOL_ORIENTATION_PROP
Definition: sch_symbol.h:96
@ SYMBOL_ANGLE_180
Definition: sch_symbol.h:99
@ SYMBOL_ANGLE_0
Definition: sch_symbol.h:97
@ SYMBOL_ANGLE_90
Definition: sch_symbol.h:98
@ SYMBOL_ANGLE_270
Definition: sch_symbol.h:100
std::vector< SCH_FIELD > SCH_FIELDS
A container for several SCH_FIELD items.
Definition: sch_symbol.h:69
SYMBOL_ORIENTATION_T
enum used in RotationMiroir()
Definition: sch_symbol.h:80
@ SYM_ORIENT_270
Definition: sch_symbol.h:87
@ SYM_ROTATE_CLOCKWISE
Definition: sch_symbol.h:82
@ SYM_ROTATE_COUNTERCLOCKWISE
Definition: sch_symbol.h:83
@ SYM_MIRROR_Y
Definition: sch_symbol.h:89
@ SYM_ORIENT_180
Definition: sch_symbol.h:86
@ SYM_MIRROR_X
Definition: sch_symbol.h:88
@ SYM_NORMAL
Definition: sch_symbol.h:81
@ SYM_ORIENT_90
Definition: sch_symbol.h:85
@ SYM_ORIENT_0
Definition: sch_symbol.h:84
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