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
36#include <memory>
37#include <string>
38#include <unordered_map>
39#include <vector>
40#include <wx/arrstr.h>
41#include <wx/chartype.h>
42#include <wx/string.h>
43
44#include <schematic.h>
45#include <symbol.h>
46#include <sch_field.h>
47#include <sch_pin.h>
48#include <sch_sheet_path.h> // SCH_SYMBOL_INSTANCE
49#include <symbol_lib_table.h>
50#include <transform.h>
51
52struct PICKED_SYMBOL;
53class KIID_PATH;
54class SCH_SCREEN;
55class LIB_SYMBOL;
56class MSG_PANEL_ITEM;
57class NETLIST_OBJECT_LIST;
58class SYMBOL_LIB;
59class SYMBOL_LIBS;
60class EE_COLLECTOR;
61class SCH_SCREEN;
63
64
66typedef std::vector<SCH_FIELD> SCH_FIELDS;
67
68typedef std::weak_ptr<LIB_SYMBOL> PART_REF;
69
70
71extern std::string toUTFTildaText( const wxString& txt );
72
73
74// @todo Move this to transform alone with all of the transform manipulation code.
77{
78 SYM_NORMAL, // Normal orientation, no rotation or mirror
79 SYM_ROTATE_CLOCKWISE, // Rotate -90
81 SYM_ORIENT_0, // No rotation and no mirror id SYM_NORMAL
82 SYM_ORIENT_90, // Rotate 90, no mirror
83 SYM_ORIENT_180, // Rotate 180, no mirror
84 SYM_ORIENT_270, // Rotate -90, no mirror
85 SYM_MIRROR_X = 0x100, // Mirror around X axis
86 SYM_MIRROR_Y = 0x200 // Mirror around Y axis
87};
88
89
90// Cover for SYMBOL_ORIENTATION_T for property manager (in order to expose only a subset of
91// SYMBOL_ORIENTATION_T's values).
93{
98};
99
100
104class SCH_SYMBOL : public SYMBOL
105{
106public:
107 SCH_SYMBOL();
108
119 SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const LIB_ID& aLibId, const SCH_SHEET_PATH* aSheet,
120 int aUnit, int aBodyStyle = 0, const VECTOR2I& aPosition = VECTOR2I( 0, 0 ),
121 EDA_ITEM* aParent = nullptr );
122
123 SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const SCH_SHEET_PATH* aSheet, const PICKED_SYMBOL& aSel,
124 const VECTOR2I& aPosition = VECTOR2I( 0, 0 ), EDA_ITEM* aParent = nullptr );
125
135 SCH_SYMBOL( const SCH_SYMBOL& aSymbol );
136
137 ~SCH_SYMBOL();
138
139 static inline bool ClassOf( const EDA_ITEM* aItem )
140 {
141 return aItem && SCH_SYMBOL_T == aItem->Type();
142 }
143
144 wxString GetClass() const override
145 {
146 return wxT( "SCH_SYMBOL" );
147 }
148
162 bool IsMissingLibSymbol() const;
163
164 const std::vector<SCH_SYMBOL_INSTANCE>& GetInstances() const
165 {
167 }
168
169 bool GetInstance( SCH_SYMBOL_INSTANCE& aInstance,
170 const KIID_PATH& aSheetPath, bool aTestFromEnd = false ) const;
171
172 void RemoveInstance( const SCH_SHEET_PATH& aInstancePath );
173
174 void RemoveInstance( const KIID_PATH& aInstancePath );
175
190 bool IsMovableFromAnchorPoint() const override;
191
192 void SetLibId( const LIB_ID& aName );
193
194 const LIB_ID& GetLibId() const override { return m_lib_id; }
195
196 wxString GetSymbolIDAsString() const { return m_lib_id.Format(); }
197
209 void SetSchSymbolLibraryName( const wxString& aName ) { m_schLibSymbolName = aName; }
210 wxString GetSchSymbolLibraryName() const;
211 bool UseLibIdLookup() const { return m_schLibSymbolName.IsEmpty(); }
212
213 std::unique_ptr< LIB_SYMBOL >& GetLibSymbolRef() { return m_part; }
214 const std::unique_ptr< LIB_SYMBOL >& GetLibSymbolRef() const { return m_part; }
215
232 void SetLibSymbol( LIB_SYMBOL* aLibSymbol );
233
237 wxString GetDescription() const override;
238
242 wxString GetKeyWords() const override;
243
247 wxString GetDatasheet() const;
248
252 void UpdatePins();
253
259 bool HasUnitDisplayName( int aUnit ) const;
260
266 wxString GetUnitDisplayName( int aUnit ) const;
267
268 void SetBodyStyle( int aBodyStyle ) override;
269
270 bool HasAlternateBodyStyle() const override;
271
272 wxString GetPrefix() const { return m_prefix; }
273 void SetPrefix( const wxString& aPrefix ) { m_prefix = aPrefix; }
274
278 void UpdatePrefix();
279
280 wxString SubReference( int aUnit, bool aAddSeparator = true ) const;
281
283 const TRANSFORM& GetTransform() const { return m_transform; }
284
285 void SetTransform( const TRANSFORM& aTransform );
286
292 int GetUnitCount() const override;
293
294 bool IsMulti() const override { return GetUnitCount() > 1; }
295
302 void SetOrientation( int aOrientation );
303
319 int GetOrientation() const;
320
325 {
326 int mirroring = GetOrientation();
327
328 mirroring &= ( SYMBOL_ORIENTATION_T::SYM_MIRROR_X | SYMBOL_ORIENTATION_T::SYM_MIRROR_Y );
329
330 SetOrientation( aAngle | mirroring );
331 }
332
334 {
335 int orientation = GetOrientation();
336
337 orientation &= ~( SYMBOL_ORIENTATION_T::SYM_MIRROR_X | SYMBOL_ORIENTATION_T::SYM_MIRROR_Y );
338
339 switch( orientation )
340 {
341 default:
342 case SYM_NORMAL:
343 case SYM_ORIENT_0: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_0;
344 case SYM_ORIENT_90: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_90;
345 case SYM_ORIENT_180: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_180;
346 case SYM_ORIENT_270: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_270;
347 }
348 }
349
350 void SetMirrorX( bool aMirror )
351 {
352 int orientation = GetOrientation();
353
354 if( aMirror )
355 orientation |= SYMBOL_ORIENTATION_T::SYM_MIRROR_X;
356 else
358
359 SetOrientation( orientation );
360 }
361
362 bool GetMirrorX() const
363 {
364 return GetOrientation() & SYMBOL_ORIENTATION_T::SYM_MIRROR_X;
365 }
366
367 void SetMirrorY( bool aMirror )
368 {
369 int orientation = GetOrientation();
370
371 if( aMirror )
372 orientation |= SYMBOL_ORIENTATION_T::SYM_MIRROR_Y;
373 else
375
376 SetOrientation( orientation );
377 }
378
379 bool GetMirrorY() const
380 {
381 return GetOrientation() & SYMBOL_ORIENTATION_T::SYM_MIRROR_Y;
382 }
383
387 void GetContextualTextVars( wxArrayString* aVars ) const;
388
394 bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth = 0 ) const;
395
396 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
397
408 void ClearAnnotation( const SCH_SHEET_PATH* aSheetPath, bool aResetPrefix );
409
421 bool AddSheetPathReferenceEntryIfMissing( const KIID_PATH& aSheetPath );
422
423
424 const BOX2I GetBoundingBox() const override;
425
430
435
436
437 //-----<Fields>-----------------------------------------------------------
438
447 SCH_FIELD* GetField( MANDATORY_FIELD_T aFieldType );
448 const SCH_FIELD* GetField( MANDATORY_FIELD_T aFieldNdx ) const;
449
457 SCH_FIELD* GetFieldById( int aFieldId );
458
466 SCH_FIELD* GetFieldByName( const wxString& aFieldName );
467
468 const SCH_FIELD* GetFieldByName( const wxString& aFieldName ) const;
469
476 void GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly );
477
481 std::vector<SCH_FIELD>& GetFields() { return m_fields; }
482 const std::vector<SCH_FIELD>& GetFields() const { return m_fields; }
483
491 SCH_FIELD* AddField( const SCH_FIELD& aField );
492
498 void RemoveField( const wxString& aFieldName );
499
500 void RemoveField( SCH_FIELD* aField ) { RemoveField( aField->GetName() ); }
501
511 SCH_FIELD* FindField( const wxString& aFieldName, bool aIncludeDefaultFields = true,
512 bool aCaseInsensitive = false );
513
517 const wxString GetRef( const SCH_SHEET_PATH* aSheet,
518 bool aIncludeUnit = false ) const override;
519
523 const wxString GetValue( bool aResolve, const SCH_SHEET_PATH* aPath,
524 bool aAllowExtraText ) const override;
525
526 void SetValueFieldText( const wxString& aValue );
527
528 const wxString GetFootprintFieldText( bool aResolve, const SCH_SHEET_PATH* aPath,
529 bool aAllowExtraText ) const;
530 void SetFootprintFieldText( const wxString& aFootprint );
531
532 /*
533 * Field access for property manager
534 */
535 wxString GetRefProp() const
536 {
537 return GetRef( &Schematic()->CurrentSheet() );
538 }
539 void SetRefProp( const wxString& aRef )
540 {
541 SetRef( &Schematic()->CurrentSheet(), aRef );
542 }
543 wxString GetValueProp() const
544 {
545 return GetValue( false, &Schematic()->CurrentSheet(), false );
546 }
547 void SetValueProp( const wxString& aRef )
548 {
549 SetValueFieldText( aRef );
550 }
551 int GetUnitProp() const
552 {
553 return GetUnitSelection( &Schematic()->CurrentSheet() );
554 }
555 void SetUnitProp( int aUnit )
556 {
557 if( aUnit < 1 )
558 return;
559
560 if( aUnit > GetUnitCount() )
561 aUnit = GetUnitCount();
562
563 SetUnitSelection( &Schematic()->CurrentSheet(), aUnit );
564 SetUnit( aUnit );
565 }
567 {
568 return GetBodyStyle();
569 }
570 void SetBodyStyleProp( int aBodyStyle )
571 {
572 SetBodyStyle( aBodyStyle );
573 }
574
585 void UpdateFields( const SCH_SHEET_PATH* aPath, bool aUpdateStyle, bool aUpdateRef,
586 bool aUpdateOtherFields, bool aResetRef, bool aResetOtherFields );
587
591 int GetFieldCount() const { return (int)m_fields.size(); }
592
602 void AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) override;
603
604 void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override;
605
606
607 //-----</Fields>----------------------------------------------------------
608
609
616 SCH_PIN* GetPin( const wxString& number ) const;
617
624 std::vector<SCH_PIN*> GetLibPins() const;
625
630 std::vector<SCH_PIN*> GetAllLibPins() const;
631
635 size_t GetFullPinCount() const;
636
640 SCH_PIN* GetPin( SCH_PIN* aLibPin ) const;
641
649 const SCH_PIN* GetPin( const VECTOR2I& aPosition ) const;
650
659 std::vector<SCH_PIN*> GetPins( const SCH_SHEET_PATH* aSheet = nullptr ) const;
660
661
662 std::vector<std::unique_ptr<SCH_PIN>>& GetRawPins() { return m_pins; }
663
664 void SwapData( SCH_ITEM* aItem ) override;
665
674 static bool IsReferenceStringValid( const wxString& aReferenceString );
675
682 void SetRef( const SCH_SHEET_PATH* aSheet, const wxString& aReference );
683
690 bool IsAnnotated( const SCH_SHEET_PATH* aSheet ) const;
691
703 void AddHierarchicalReference( const KIID_PATH& aPath,
704 const wxString& aRef,
705 int aUnit );
706
707 void AddHierarchicalReference( const SCH_SYMBOL_INSTANCE& aInstance );
708
710 int GetUnitSelection( const SCH_SHEET_PATH* aSheet ) const;
711
713 void SetUnitSelection( const SCH_SHEET_PATH* aSheet, int aUnitSelection );
714
716 void SetUnitSelection( int aUnitSelection );
717
718 void Move( const VECTOR2I& aMoveVector ) override
719 {
720 if( aMoveVector == VECTOR2I( 0, 0 ) )
721 return;
722
723 m_pos += aMoveVector;
724
725 for( SCH_FIELD& field : m_fields )
726 field.Move( aMoveVector );
727 }
728
729 void MirrorHorizontally( int aCenter ) override;
730 void MirrorVertically( int aCenter ) override;
731 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
732
733 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
734
735 void GetEndPoints( std::vector<DANGLING_END_ITEM>& aItemList ) override;
736
747 bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
748 std::vector<DANGLING_END_ITEM>& aItemListByPos,
749 const SCH_SHEET_PATH* aPath = nullptr ) override;
750
751 VECTOR2I GetPinPhysicalPosition( const SCH_PIN* Pin ) const;
752
753 bool IsConnectable() const override { return true; }
754
755 bool HasConnectivityChanges( const SCH_ITEM* aItem,
756 const SCH_SHEET_PATH* aInstance = nullptr ) const override;
757
758 bool CanConnect( const SCH_ITEM* aItem ) const override
759 {
760 return ( aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_WIRE ) ||
761 ( aItem->Type() == SCH_NO_CONNECT_T ) ||
762 ( aItem->Type() == SCH_JUNCTION_T ) ||
763 ( aItem->Type() == SCH_SYMBOL_T ) ||
764 ( aItem->Type() == SCH_DIRECTIVE_LABEL_T ) ||
765 ( aItem->Type() == SCH_LABEL_T ) ||
766 ( aItem->Type() == SCH_HIER_LABEL_T ) ||
767 ( aItem->Type() == SCH_GLOBAL_LABEL_T );
768 }
769
773 bool IsInNetlist() const;
774
775 std::vector<VECTOR2I> GetConnectionPoints() const override;
776
777 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
778 const std::vector<KICAD_T>& aScanTypes ) override;
779
787 SCH_ITEM* GetDrawItem( const VECTOR2I& aPosition, KICAD_T aType = TYPE_NOT_INIT );
788
789 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
790
791 BITMAPS GetMenuImage() const override;
792
793 bool operator <( const SCH_ITEM& aItem ) const override;
794
795 bool operator==( const SCH_SYMBOL& aSymbol) const;
796 bool operator!=( const SCH_SYMBOL& aSymbol) const;
797
798 SCH_SYMBOL& operator=( const SCH_SYMBOL& aItem );
799
800 bool IsReplaceable() const override { return true; }
801
802 VECTOR2I GetPosition() const override { return m_pos; }
803 void SetPosition( const VECTOR2I& aPosition ) override { Move( aPosition - m_pos ); }
804
805 int GetX() const { return GetPosition().x; };
806 void SetX( int aX ) { SetPosition( VECTOR2I( aX, GetY() ) ); }
807
808 int GetY() const { return GetPosition().y; }
809 void SetY( int aY ) { SetPosition( VECTOR2I( GetX(), aY ) ); }
810
811 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
812 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
813
821 void Print( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
822 const VECTOR2I& aOffset, bool aForceNoFill, bool aDimmed ) override;
823
831 void PrintBackground( const SCH_RENDER_SETTINGS* aSettings, int aUnit, int aBodyStyle,
832 const VECTOR2I& aOffset, bool aDimmed ) override;
833
834 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
835 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
836
844 void PlotPins( PLOTTER* aPlotter ) const;
845
852 void PlotDNP( PLOTTER* aPlotter ) const;
853
854 EDA_ITEM* Clone() const override;
855
856#if defined(DEBUG)
857 void Show( int nestLevel, std::ostream& os ) const override;
858#endif
859
860 void ClearBrightenedPins();
861
862 bool HasBrightenedPins();
863
864 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override;
865
871 bool IsSymbolLikePowerGlobalLabel() const;
872
873 bool IsPower() const override;
874 bool IsNormal() const override;
875
876 bool GetShowPinNames() const override;
877 void SetShowPinNames( bool aShow ) override;
878
879 bool GetShowPinNumbers() const override;
880 void SetShowPinNumbers( bool aShow ) override;
881
882 double Similarity( const SCH_ITEM& aOther ) const override;
883
884 bool operator==( const SCH_ITEM& aOther ) const override;
885
886private:
887 BOX2I doGetBoundingBox( bool aIncludePins, bool aIncludeFields ) const;
888
889 bool doIsConnected( const VECTOR2I& aPosition ) const override;
890
891 void Init( const VECTOR2I& pos = VECTOR2I( 0, 0 ) );
892
893private:
896 wxString m_prefix;
900
909
911 std::vector<SCH_FIELD> m_fields;
912
913 std::unique_ptr<LIB_SYMBOL> m_part;
916
917 std::vector<std::unique_ptr<SCH_PIN>> m_pins;
918 std::unordered_map<SCH_PIN*, SCH_PIN*> m_pinMap;
919
920 // Defines the hierarchical path and reference of the symbol. This allows support for multiple
921 // references to a single sub-sheet.
922 std::vector<SCH_SYMBOL_INSTANCE> m_instanceReferences;
923
925 static std::unordered_map<TRANSFORM, int> s_transformToOrientationCache;
926};
927
928#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:89
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
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
EDA_MSG_PANEL items for displaying messages.
Definition: msgpanel.h:54
Base plotter engine class.
Definition: plotter.h:105
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:1204
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:166
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:150
int GetBodyStyle() const
Definition: sch_item.h:232
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:281
virtual void SetUnit(int aUnit)
Definition: sch_item.h:228
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:105
const TRANSFORM & GetTransform() const
Definition: sch_symbol.h:283
void SetValueProp(const wxString &aRef)
Definition: sch_symbol.h:547
SCH_SYMBOL & operator=(const SCH_SYMBOL &aItem)
int GetUnitProp() const
Definition: sch_symbol.h:551
size_t GetFullPinCount() const
void UpdatePrefix()
Set the prefix based on the current reference designator.
Definition: sch_symbol.cpp:809
wxString m_prefix
C, R, U, Q etc - the first character(s) which typically indicate what the symbol is.
Definition: sch_symbol.h:896
SCH_FIELD * GetFieldByName(const wxString &aFieldName)
Return a field in this symbol.
Definition: sch_symbol.cpp:943
wxString GetDescription() const override
Definition: sch_symbol.cpp:284
std::unordered_map< SCH_PIN *, SCH_PIN * > m_pinMap
library pin pointer : SCH_PIN's index
Definition: sch_symbol.h:918
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction) override
void SetMirrorX(bool aMirror)
Definition: sch_symbol.h:350
bool IsSymbolLikePowerGlobalLabel() const
VECTOR2I m_pos
Definition: sch_symbol.h:894
wxString GetSymbolIDAsString() const
Definition: sch_symbol.h:196
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
Definition: sch_symbol.h:895
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
bool GetShowPinNumbers() const override
wxString GetDatasheet() const
Return the documentation text for the given part alias.
Definition: sch_symbol.cpp:302
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:260
bool HasBrightenedPins()
std::vector< SCH_FIELD > & GetFields()
Return a vector of fields from the symbol.
Definition: sch_symbol.h:481
void SetRefProp(const wxString &aRef)
Definition: sch_symbol.h:539
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:493
wxString GetUnitDisplayName(int aUnit) const
Return the display name for a given unit aUnit.
Definition: sch_symbol.cpp:460
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.
std::vector< std::unique_ptr< SCH_PIN > > & GetRawPins()
Definition: sch_symbol.h:662
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstances() const
Definition: sch_symbol.h:164
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_symbol.h:803
void PlotDNP(PLOTTER *aPlotter) const
Plot the red 'X' over the symbol.
bool operator!=(const SCH_SYMBOL &aSymbol) const
void SetShowPinNumbers(bool aShow) override
Set or clear the pin number visibility flag.
bool IsConnectable() const override
Definition: sch_symbol.h:753
SYMBOL_ORIENTATION_PROP GetOrientationProp() const
Definition: sch_symbol.h:333
int GetFieldCount() const
Return the number of fields in this symbol.
Definition: sch_symbol.h:591
int GetY() const
Definition: sch_symbol.h:808
wxString SubReference(int aUnit, bool aAddSeparator=true) const
Definition: sch_symbol.cpp:836
wxString GetClass() const override
Return the class name.
Definition: sch_symbol.h:144
void RemoveInstance(const SCH_SHEET_PATH &aInstancePath)
Definition: sch_symbol.cpp:592
static bool IsReferenceStringValid(const wxString &aReferenceString)
Test for an acceptable reference string.
Definition: sch_symbol.cpp:753
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:795
void SetMirrorY(bool aMirror)
Definition: sch_symbol.h:367
void PlotPins(PLOTTER *aPlotter) const
Plot just the symbol pins.
bool UseLibIdLookup() const
Definition: sch_symbol.h:211
void SetValueFieldText(const wxString &aValue)
Definition: sch_symbol.cpp:897
int GetX() const
Definition: sch_symbol.h:805
void RemoveField(const wxString &aFieldName)
Remove a user field from the symbol.
Definition: sch_symbol.cpp:989
void SetBodyStyle(int aBodyStyle) override
Definition: sch_symbol.cpp:423
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
void SetShowPinNames(bool aShow) override
Set or clear the pin name visibility flag.
wxString GetKeyWords() const override
Definition: sch_symbol.cpp:293
wxString GetSchSymbolLibraryName() const
Definition: sch_symbol.cpp:266
SCH_FIELD * FindField(const wxString &aFieldName, bool aIncludeDefaultFields=true, bool aCaseInsensitive=false)
Search for a SCH_FIELD with aFieldName.
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_symbol.h:139
bool IsInNetlist() const
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_symbol.h:718
void SetBodyStyleProp(int aBodyStyle)
Definition: sch_symbol.h:570
void ClearBrightenedPins()
void SetY(int aY)
Definition: sch_symbol.h:809
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_symbol.cpp:227
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:362
wxString GetRefProp() const
Definition: sch_symbol.h:535
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:919
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
static std::unordered_map< TRANSFORM, int > s_transformToOrientationCache
Definition: sch_symbol.h:925
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
Definition: sch_symbol.cpp:311
std::vector< SCH_SYMBOL_INSTANCE > m_instanceReferences
Definition: sch_symbol.h:922
const wxString GetValue(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText) const override
Definition: sch_symbol.cpp:887
const std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef() const
Definition: sch_symbol.h:214
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:908
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:759
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:324
bool GetShowPinNames() const override
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:903
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:911
int GetBodyStyleProp() const
Definition: sch_symbol.h:566
std::vector< SCH_PIN * > GetAllLibPins() const
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:913
bool doIsConnected(const VECTOR2I &aPosition) const override
Provide the object specific test to see if it is connected to aPosition.
void AddHierarchicalReference(const KIID_PATH &aPath, const wxString &aRef, int aUnit)
Add a full hierarchical reference to this symbol.
Definition: sch_symbol.cpp:620
bool IsMissingLibSymbol() const
Check to see if the library symbol is set to the dummy library symbol.
Definition: sch_symbol.cpp:233
VECTOR2I GetPosition() const override
Definition: sch_symbol.h:802
void SetTransform(const TRANSFORM &aTransform)
Definition: sch_symbol.cpp:445
std::unique_ptr< LIB_SYMBOL > m_part
A flattened copy of the LIB_SYMBOL from the PROJECT's libraries.
Definition: sch_symbol.h:913
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:482
bool CanConnect(const SCH_ITEM *aItem) const override
Definition: sch_symbol.h:758
void Init(const VECTOR2I &pos=VECTOR2I(0, 0))
Definition: sch_symbol.cpp:199
bool HasAlternateBodyStyle() const override
Test if symbol has more than one body conversion type (DeMorgan).
Definition: sch_symbol.cpp:436
const LIB_ID & GetLibId() const override
Definition: sch_symbol.h:194
bool operator<(const SCH_ITEM &aItem) const override
void GetContextualTextVars(wxArrayString *aVars) const
Return the list of system text vars & fields for this symbol.
void SetUnitProp(int aUnit)
Definition: sch_symbol.h:555
void SetSchSymbolLibraryName(const wxString &aName)
The name of the symbol in the schematic library symbol list.
Definition: sch_symbol.h:209
bool IsMulti() const override
Definition: sch_symbol.h:294
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:931
std::vector< SCH_PIN * > GetLibPins() const
Populate a vector with all the pins from the library object that match the current unit and bodyStyle...
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:568
TRANSFORM & GetTransform()
Definition: sch_symbol.h:282
BOX2I doGetBoundingBox(bool aIncludePins, bool aIncludeFields) const
bool GetMirrorY() const
Definition: sch_symbol.h:379
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
Definition: sch_symbol.cpp:982
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:500
void SetX(int aX)
Definition: sch_symbol.h:806
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.
bool m_isInNetlist
True if the symbol should appear in netlist.
Definition: sch_symbol.h:915
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
Definition: sch_symbol.cpp:845
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:910
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
wxString GetValueProp() const
Definition: sch_symbol.h:543
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:476
int GetUnitCount() const override
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:451
void SetPrefix(const wxString &aPrefix)
Definition: sch_symbol.h:273
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:861
bool IsNormal() const override
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:213
std::vector< std::unique_ptr< SCH_PIN > > m_pins
a SCH_PIN for every SCH_PIN (all units)
Definition: sch_symbol.h:917
bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
Definition: sch_symbol.h:800
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
Definition: sch_symbol.cpp:275
VECTOR2I GetPinPhysicalPosition(const SCH_PIN *Pin) const
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:720
wxString GetPrefix() const
Definition: sch_symbol.h:272
bool HasUnitDisplayName(int aUnit) const
Return true if the given unit aUnit has a display name set.
Definition: sch_symbol.cpp:468
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
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:239
bool IsPower() const override
bool operator==(const SCH_SYMBOL &aSymbol) const
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:82
@ LAYER_WIRE
Definition: layer_ids.h:357
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:52
std::weak_ptr< LIB_SYMBOL > PART_REF
Definition: sch_symbol.h:68
SYMBOL_ORIENTATION_PROP
Definition: sch_symbol.h:93
@ SYMBOL_ANGLE_180
Definition: sch_symbol.h:96
@ SYMBOL_ANGLE_0
Definition: sch_symbol.h:94
@ SYMBOL_ANGLE_90
Definition: sch_symbol.h:95
@ SYMBOL_ANGLE_270
Definition: sch_symbol.h:97
std::vector< SCH_FIELD > SCH_FIELDS
A container for several SCH_FIELD items.
Definition: sch_symbol.h:66
SYMBOL_ORIENTATION_T
enum used in RotationMiroir()
Definition: sch_symbol.h:77
@ SYM_ORIENT_270
Definition: sch_symbol.h:84
@ SYM_ROTATE_CLOCKWISE
Definition: sch_symbol.h:79
@ SYM_ROTATE_COUNTERCLOCKWISE
Definition: sch_symbol.h:80
@ SYM_MIRROR_Y
Definition: sch_symbol.h:86
@ SYM_ORIENT_180
Definition: sch_symbol.h:83
@ SYM_MIRROR_X
Definition: sch_symbol.h:85
@ SYM_NORMAL
Definition: sch_symbol.h:78
@ SYM_ORIENT_90
Definition: sch_symbol.h:82
@ SYM_ORIENT_0
Definition: sch_symbol.h:81
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:163
@ SCH_NO_CONNECT_T
Definition: typeinfo.h:160
@ TYPE_NOT_INIT
Definition: typeinfo.h:81
@ SCH_SYMBOL_T
Definition: typeinfo.h:172
@ SCH_DIRECTIVE_LABEL_T
Definition: typeinfo.h:171
@ SCH_LABEL_T
Definition: typeinfo.h:167
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:169
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:168
@ SCH_JUNCTION_T
Definition: typeinfo.h:159
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:673