KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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, dick@softplc.com
6 * Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
7 * Copyright (C) 2022 CERN
8 * Copyright The 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 <transform.h>
50
51struct PICKED_SYMBOL;
52class KIID_PATH;
53class SCH_SCREEN;
54class LIB_SYMBOL;
55class MSG_PANEL_ITEM;
56class SYMBOL_LIB;
57class SYMBOL_LIBS;
58class SCH_SCREEN;
59class SCH_COMMIT;
60
61
63typedef std::vector<SCH_FIELD> SCH_FIELDS;
64
65typedef std::weak_ptr<LIB_SYMBOL> PART_REF;
66
67
68extern std::string toUTFTildaText( const wxString& txt );
69
70
74class SCH_SYMBOL : public SYMBOL
75{
76public:
77 SCH_SYMBOL();
78
89 SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const LIB_ID& aLibId, const SCH_SHEET_PATH* aSheet,
90 int aUnit, int aBodyStyle = 0, const VECTOR2I& aPosition = VECTOR2I( 0, 0 ),
91 EDA_ITEM* aParent = nullptr );
92
93 SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const SCH_SHEET_PATH* aSheet, const PICKED_SYMBOL& aSel,
94 const VECTOR2I& aPosition = VECTOR2I( 0, 0 ), EDA_ITEM* aParent = nullptr );
95
105 SCH_SYMBOL( const SCH_SYMBOL& aSymbol );
106
107 ~SCH_SYMBOL();
108
109 static inline bool ClassOf( const EDA_ITEM* aItem )
110 {
111 return aItem && SCH_SYMBOL_T == aItem->Type();
112 }
113
114 wxString GetClass() const override
115 {
116 return wxT( "SCH_SYMBOL" );
117 }
118
132 bool IsMissingLibSymbol() const;
133
134 const std::vector<SCH_SYMBOL_INSTANCE>& GetInstances() const
135 {
137 }
138
139 bool GetInstance( SCH_SYMBOL_INSTANCE& aInstance,
140 const KIID_PATH& aSheetPath, bool aTestFromEnd = false ) const;
141
142 void RemoveInstance( const SCH_SHEET_PATH& aInstancePath );
143
144 void RemoveInstance( const KIID_PATH& aInstancePath );
145
160 bool IsMovableFromAnchorPoint() const override;
161
162 void SetLibId( const LIB_ID& aName );
163
164 const LIB_ID& GetLibId() const override { return m_lib_id; }
165
166 wxString GetSymbolIDAsString() const { return m_lib_id.Format(); }
167
179 void SetSchSymbolLibraryName( const wxString& aName ) { m_schLibSymbolName = aName; }
180 wxString GetSchSymbolLibraryName() const;
181 bool UseLibIdLookup() const { return m_schLibSymbolName.IsEmpty(); }
182
183 std::unique_ptr< LIB_SYMBOL >& GetLibSymbolRef() { return m_part; }
184 const std::unique_ptr< LIB_SYMBOL >& GetLibSymbolRef() const { return m_part; }
185
202 void SetLibSymbol( LIB_SYMBOL* aLibSymbol );
203
207 wxString GetDescription() const override;
208
212 wxString GetKeyWords() const override;
213
217 wxString GetDatasheet() const;
218
222 void UpdatePins();
223
229 bool HasUnitDisplayName( int aUnit ) const;
230
236 wxString GetUnitDisplayName( int aUnit ) const;
237
238 void SetBodyStyle( int aBodyStyle ) override;
239
245 void SetBodyStyleUnconditional( int aBodyStyle );
246
247 bool HasAlternateBodyStyle() const override;
248
249 wxString GetPrefix() const { return m_prefix; }
250 void SetPrefix( const wxString& aPrefix ) { m_prefix = aPrefix; }
251
255 void UpdatePrefix();
256
257 wxString SubReference( int aUnit, bool aAddSeparator = true ) const;
258
264 int GetUnitCount() const override;
265
266 bool IsMulti() const override { return GetUnitCount() > 1; }
267
274 void SetOrientation( int aOrientation );
275
291 int GetOrientation() const override;
292
297 {
298 int mirroring = GetOrientation();
299
300 mirroring &= ( SYMBOL_ORIENTATION_T::SYM_MIRROR_X | SYMBOL_ORIENTATION_T::SYM_MIRROR_Y );
301
302 SetOrientation( aAngle | mirroring );
303 }
304
306 {
307 int orientation = GetOrientation();
308
309 orientation &= ~( SYMBOL_ORIENTATION_T::SYM_MIRROR_X | SYMBOL_ORIENTATION_T::SYM_MIRROR_Y );
310
311 switch( orientation )
312 {
313 default:
314 case SYM_NORMAL:
315 case SYM_ORIENT_0: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_0;
316 case SYM_ORIENT_90: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_90;
317 case SYM_ORIENT_180: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_180;
318 case SYM_ORIENT_270: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_270;
319 }
320 }
321
322 void SetMirrorX( bool aMirror )
323 {
324 int orientation = GetOrientation();
325
326 if( aMirror )
327 orientation |= SYMBOL_ORIENTATION_T::SYM_MIRROR_X;
328 else
330
331 SetOrientation( orientation );
332 }
333
334 bool GetMirrorX() const
335 {
336 return GetOrientation() & SYMBOL_ORIENTATION_T::SYM_MIRROR_X;
337 }
338
339 void SetMirrorY( bool aMirror )
340 {
341 int orientation = GetOrientation();
342
343 if( aMirror )
344 orientation |= SYMBOL_ORIENTATION_T::SYM_MIRROR_Y;
345 else
347
348 SetOrientation( orientation );
349 }
350
351 bool GetMirrorY() const
352 {
353 return GetOrientation() & SYMBOL_ORIENTATION_T::SYM_MIRROR_Y;
354 }
355
359 void GetContextualTextVars( wxArrayString* aVars ) const;
360
366 bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth = 0 ) const;
367
368 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
369
380 void ClearAnnotation( const SCH_SHEET_PATH* aSheetPath, bool aResetPrefix );
381
393 bool AddSheetPathReferenceEntryIfMissing( const KIID_PATH& aSheetPath );
394
395
396 const BOX2I GetBoundingBox() const override;
397
401 BOX2I GetBodyBoundingBox() const override;
402
406 BOX2I GetBodyAndPinsBoundingBox() const override;
407
408
409 //-----<Fields>-----------------------------------------------------------
410
415 SCH_FIELD* GetField( FIELD_T aFieldType );
416 const SCH_FIELD* GetField( FIELD_T aFieldNdx ) const;
417
421 SCH_FIELD* GetField( const wxString& aFieldName );
422 const SCH_FIELD* GetField( const wxString& aFieldName ) const;
423
430 void GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly ) const override;
431
435 std::vector<SCH_FIELD>& GetFields() { return m_fields; }
436 const std::vector<SCH_FIELD>& GetFields() const { return m_fields; }
437
445 SCH_FIELD* AddField( const SCH_FIELD& aField );
446
452 void RemoveField( const wxString& aFieldName );
453
454 void RemoveField( SCH_FIELD* aField ) { RemoveField( aField->GetName() ); }
455
463 SCH_FIELD* FindFieldCaseInsensitive( const wxString& aFieldName );
464
468 const wxString GetRef( const SCH_SHEET_PATH* aSheet,
469 bool aIncludeUnit = false ) const override;
470
474 const wxString GetValue( bool aResolve, const SCH_SHEET_PATH* aPath,
475 bool aAllowExtraText ) const override;
476
477 void SetValueFieldText( const wxString& aValue );
478
479 const wxString GetFootprintFieldText( bool aResolve, const SCH_SHEET_PATH* aPath,
480 bool aAllowExtraText ) const;
481 void SetFootprintFieldText( const wxString& aFootprint );
482
483 /*
484 * Field access for property manager
485 */
486 wxString GetRefProp() const
487 {
488 return GetRef( &Schematic()->CurrentSheet() );
489 }
490
491 void SetRefProp( const wxString& aRef );
492 wxString GetValueProp() const
493 {
494 return GetValue( false, &Schematic()->CurrentSheet(), false );
495 }
496
497 void SetValueProp( const wxString& aRef )
498 {
499 SetValueFieldText( aRef );
500 }
501
502 wxString GetUnitProp() const
503 {
504 int unit = GetUnitSelection( &Schematic()->CurrentSheet() );
505
506 if( HasUnitDisplayName( unit ) )
507 return GetUnitDisplayName( unit );
508 else
509 return SubReference( unit, false );
510 }
511
512 void SetUnitProp( const wxString& aUnit )
513 {
514 for( int unit = 1; unit <= GetUnitCount(); unit++ )
515 {
516 if( HasUnitDisplayName( unit ) && GetUnitDisplayName( unit ) == aUnit )
517 {
518 SetUnitSelection( &Schematic()->CurrentSheet(), unit );
519 SetUnit( unit );
520 return;
521 }
522 }
523
524 for( int unit = 1; unit <= GetUnitCount(); unit++ )
525 {
526 if( SubReference( unit, false ) == aUnit )
527 {
528 SetUnitSelection( &Schematic()->CurrentSheet(), unit );
529 SetUnit( unit );
530 return;
531 }
532 }
533 }
534
536 {
537 return GetBodyStyle();
538 }
539
540 void SetBodyStyleProp( int aBodyStyle )
541 {
542 SetBodyStyle( aBodyStyle );
543 }
544
555 void UpdateFields( const SCH_SHEET_PATH* aPath, bool aUpdateStyle, bool aUpdateRef,
556 bool aUpdateOtherFields, bool aResetRef, bool aResetOtherFields );
557
567 void SyncOtherUnits( const SCH_SHEET_PATH& aSourceSheet, SCH_COMMIT& aCommit,
568 PROPERTY_BASE* aProperty );
569
573 int GetNextFieldOrdinal() const;
574
581 void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
582
583 void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction, RECURSE_MODE aMode ) override;
584
585
586 //-----</Fields>----------------------------------------------------------
587
588
595 SCH_PIN* GetPin( const wxString& number ) const;
596
603 std::vector<SCH_PIN*> GetLibPins() const;
604
609 std::vector<SCH_PIN*> GetAllLibPins() const;
610
614 size_t GetFullPinCount() const;
615
619 SCH_PIN* GetPin( SCH_PIN* aLibPin ) const;
620
628 const SCH_PIN* GetPin( const VECTOR2I& aPosition ) const;
629
638 std::vector<SCH_PIN*> GetPins( const SCH_SHEET_PATH* aSheet ) const;
639
640 std::vector<SCH_PIN*> GetPins() const override;
641
642
643 std::vector<std::unique_ptr<SCH_PIN>>& GetRawPins() { return m_pins; }
644
651 void SetRef( const SCH_SHEET_PATH* aSheet, const wxString& aReference );
652
659 bool IsAnnotated( const SCH_SHEET_PATH* aSheet ) const;
660
672 void AddHierarchicalReference( const KIID_PATH& aPath,
673 const wxString& aRef,
674 int aUnit );
675
676 void AddHierarchicalReference( const SCH_SYMBOL_INSTANCE& aInstance );
677
679 int GetUnitSelection( const SCH_SHEET_PATH* aSheet ) const;
680
682 void SetUnitSelection( const SCH_SHEET_PATH* aSheet, int aUnitSelection );
683
685 void SetUnitSelection( int aUnitSelection );
686
687 void Move( const VECTOR2I& aMoveVector ) override
688 {
689 if( aMoveVector == VECTOR2I( 0, 0 ) )
690 return;
691
692 m_pos += aMoveVector;
693
694 for( SCH_FIELD& field : m_fields )
695 field.Move( aMoveVector );
696 }
697
698 void MirrorHorizontally( int aCenter ) override;
699 void MirrorVertically( int aCenter ) override;
700 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
701
702 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
703
704 void GetEndPoints( std::vector<DANGLING_END_ITEM>& aItemList ) override;
705
716 bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
717 std::vector<DANGLING_END_ITEM>& aItemListByPos,
718 const SCH_SHEET_PATH* aPath = nullptr ) override;
719
720 VECTOR2I GetPinPhysicalPosition( const SCH_PIN* Pin ) const;
721
722 bool IsConnectable() const override { return true; }
723
724 bool HasConnectivityChanges( const SCH_ITEM* aItem,
725 const SCH_SHEET_PATH* aInstance = nullptr ) const override;
726
727 bool CanConnect( const SCH_ITEM* aItem ) const override
728 {
729 return ( aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_WIRE ) ||
730 ( aItem->Type() == SCH_NO_CONNECT_T ) ||
731 ( aItem->Type() == SCH_JUNCTION_T ) ||
732 ( aItem->Type() == SCH_SYMBOL_T ) ||
733 ( aItem->Type() == SCH_DIRECTIVE_LABEL_T ) ||
734 ( aItem->Type() == SCH_LABEL_T ) ||
735 ( aItem->Type() == SCH_HIER_LABEL_T ) ||
736 ( aItem->Type() == SCH_GLOBAL_LABEL_T );
737 }
738
742 bool IsInNetlist() const;
743
744 std::vector<VECTOR2I> GetConnectionPoints() const override;
745
746 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
747 const std::vector<KICAD_T>& aScanTypes ) override;
748
756 SCH_ITEM* GetDrawItem( const VECTOR2I& aPosition, KICAD_T aType = TYPE_NOT_INIT );
757
758 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
759
760 BITMAPS GetMenuImage() const override;
761
762 bool operator <( const SCH_ITEM& aItem ) const override;
763
764 bool operator==( const SCH_SYMBOL& aSymbol) const;
765 bool operator!=( const SCH_SYMBOL& aSymbol) const;
766
767 SCH_SYMBOL& operator=( const SCH_SYMBOL& aItem );
768
769 bool IsReplaceable() const override { return true; }
770
771 VECTOR2I GetPosition() const override { return m_pos; }
772 void SetPosition( const VECTOR2I& aPosition ) override { Move( aPosition - m_pos ); }
773
774 int GetX() const { return GetPosition().x; };
775 void SetX( int aX ) { SetPosition( VECTOR2I( aX, GetY() ) ); }
776
777 int GetY() const { return GetPosition().y; }
778 void SetY( int aY ) { SetPosition( VECTOR2I( GetX(), aY ) ); }
779
780 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
781 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
782
783 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
784 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
785
793 void PlotPins( PLOTTER* aPlotter ) const;
794
801 void PlotDNP( PLOTTER* aPlotter ) const;
802
803 EDA_ITEM* Clone() const override;
804
805#if defined(DEBUG)
806 void Show( int nestLevel, std::ostream& os ) const override;
807#endif
808
809 void ClearBrightenedPins();
810
811 bool HasBrightenedPins();
812
813 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override;
814
820 bool IsSymbolLikePowerGlobalLabel() const;
821 bool IsSymbolLikePowerLocalLabel() const;
822
823 bool IsGlobalPower() const override;
824 bool IsLocalPower() const override;
825 bool IsPower() const override;
826 bool IsNormal() const override;
827
828 bool GetShowPinNames() const override;
829 void SetShowPinNames( bool aShow ) override;
830
831 bool GetShowPinNumbers() const override;
832 void SetShowPinNumbers( bool aShow ) override;
833
834 double Similarity( const SCH_ITEM& aOther ) const override;
835
837 std::unordered_set<wxString> GetComponentClassNames( const SCH_SHEET_PATH* aPath ) const;
838
839 bool operator==( const SCH_ITEM& aOther ) const override;
840
841protected:
842 void swapData( SCH_ITEM* aItem ) override;
843
844private:
845 BOX2I doGetBoundingBox( bool aIncludePins, bool aIncludeFields ) const;
846
847 bool doIsConnected( const VECTOR2I& aPosition ) const override;
848
849 void Init( const VECTOR2I& pos = VECTOR2I( 0, 0 ) );
850
851private:
854 wxString m_prefix;
858
867
868 std::vector<SCH_FIELD> m_fields;
869
870 std::unique_ptr<LIB_SYMBOL> m_part;
873
874 std::vector<std::unique_ptr<SCH_PIN>> m_pins;
875 std::unordered_map<SCH_PIN*, SCH_PIN*> m_pinMap;
876
882 std::vector<SCH_SYMBOL_INSTANCE> m_instanceReferences;
883
885 static std::unordered_map<TRANSFORM, int> s_transformToOrientationCache;
886};
887
888#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:96
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:108
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:119
Define a library symbol object.
Definition: lib_symbol.h:85
EDA_MSG_PANEL items for displaying messages.
Definition: msgpanel.h:54
Base plotter engine class.
Definition: plotter.h:105
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:1086
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:167
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:151
int GetBodyStyle() const
Definition: sch_item.h:239
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:291
virtual void SetUnit(int aUnit)
Definition: sch_item.h:235
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:75
void SetValueProp(const wxString &aRef)
Definition: sch_symbol.h:497
SCH_SYMBOL & operator=(const SCH_SYMBOL &aItem)
size_t GetFullPinCount() const
void UpdatePrefix()
Set the prefix based on the current reference designator.
Definition: sch_symbol.cpp:703
wxString m_prefix
C, R, U, Q etc - the first character(s) which typically indicate what the symbol is.
Definition: sch_symbol.h:854
wxString GetDescription() const override
Definition: sch_symbol.cpp:260
std::unordered_map< SCH_PIN *, SCH_PIN * > m_pinMap
Library pin pointer : SCH_PIN indices.
Definition: sch_symbol.h:875
void SetMirrorX(bool aMirror)
Definition: sch_symbol.h:322
bool IsSymbolLikePowerGlobalLabel() const
VECTOR2I m_pos
Definition: sch_symbol.h:852
wxString GetSymbolIDAsString() const
Definition: sch_symbol.h:166
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
Definition: sch_symbol.h:853
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:278
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:236
bool HasBrightenedPins()
std::vector< SCH_FIELD > & GetFields()
Return a reference to the vector holding the symbol's fields.
Definition: sch_symbol.h:435
BOX2I GetBodyAndPinsBoundingBox() const override
Return a bounding box for the symbol body and pins but not the fields.
void SetRefProp(const wxString &aRef)
Definition: sch_symbol.cpp:644
wxString GetUnitDisplayName(int aUnit) const
Return the display name for a given unit aUnit.
Definition: sch_symbol.cpp:443
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...
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:643
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstances() const
Definition: sch_symbol.h:134
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_symbol.h:772
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:722
SYMBOL_ORIENTATION_PROP GetOrientationProp() const
Definition: sch_symbol.h:305
void SetBodyStyleUnconditional(int aBodyStyle)
Similar to SetBodyStyle(), but always set the body style, regardless the lib symbol properties (the L...
Definition: sch_symbol.cpp:399
int GetY() const
Definition: sch_symbol.h:777
wxString SubReference(int aUnit, bool aAddSeparator=true) const
Definition: sch_symbol.cpp:730
wxString GetClass() const override
Return the class name.
Definition: sch_symbol.h:114
void RemoveInstance(const SCH_SHEET_PATH &aInstancePath)
Definition: sch_symbol.cpp:483
void SetUnitProp(const wxString &aUnit)
Definition: sch_symbol.h:512
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:689
void SetMirrorY(bool aMirror)
Definition: sch_symbol.h:339
void PlotPins(PLOTTER *aPlotter) const
Plot just the symbol pins.
bool UseLibIdLookup() const
Definition: sch_symbol.h:181
void SetValueFieldText(const wxString &aValue)
Definition: sch_symbol.cpp:791
int GetX() const
Definition: sch_symbol.h:774
std::vector< SCH_PIN * > GetPins() const override
void RemoveField(const wxString &aFieldName)
Remove a user field from the symbol.
Definition: sch_symbol.cpp:875
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
Automatically orient all the fields in the symbol.
void SetBodyStyle(int aBodyStyle) override
Definition: sch_symbol.cpp:412
void SetShowPinNames(bool aShow) override
Set or clear the pin name visibility flag.
wxString GetKeyWords() const override
Definition: sch_symbol.cpp:269
wxString GetSchSymbolLibraryName() const
Definition: sch_symbol.cpp:242
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_symbol.h:109
bool IsInNetlist() const
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_symbol.h:687
void SetBodyStyleProp(int aBodyStyle)
Definition: sch_symbol.h:540
void ClearBrightenedPins()
void SetY(int aY)
Definition: sch_symbol.h:778
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_symbol.cpp:203
bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const override
Check if aItem has connectivity changes against this object.
bool IsGlobalPower() const override
bool GetMirrorX() const
Definition: sch_symbol.h:334
wxString GetRefProp() const
Definition: sch_symbol.h:486
wxString GetUnitProp() const
Definition: sch_symbol.h:502
bool AddSheetPathReferenceEntryIfMissing(const KIID_PATH &aSheetPath)
Add an instance to the alternate references list (m_instanceReferences), if this entry does not alrea...
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:885
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
Definition: sch_symbol.cpp:287
std::vector< SCH_SYMBOL_INSTANCE > m_instanceReferences
Define the hierarchical path and reference of the symbol.
Definition: sch_symbol.h:882
const wxString GetValue(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText) const override
Definition: sch_symbol.cpp:781
void SyncOtherUnits(const SCH_SHEET_PATH &aSourceSheet, SCH_COMMIT &aCommit, PROPERTY_BASE *aProperty)
Keep fields other than the reference, include/exclude flags, and alternate pin assignments in sync in...
Definition: sch_symbol.cpp:968
SCH_FIELD * FindFieldCaseInsensitive(const wxString &aFieldName)
Search for a SCH_FIELD with aFieldName.
Definition: sch_symbol.cpp:891
const std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef() const
Definition: sch_symbol.h:184
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.
Definition: sch_symbol.cpp:903
wxString m_schLibSymbolName
The name used to look up a symbol in the symbol library embedded in a schematic.
Definition: sch_symbol.h:866
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:653
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:296
bool GetShowPinNames() const override
const wxString GetFootprintFieldText(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText) const
Definition: sch_symbol.cpp:797
std::vector< SCH_FIELD > m_fields
Variable length list of fields.
Definition: sch_symbol.h:868
int GetBodyStyleProp() const
Definition: sch_symbol.h:535
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:807
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:511
bool IsMissingLibSymbol() const
Check to see if the library symbol is set to the dummy library symbol.
Definition: sch_symbol.cpp:209
VECTOR2I GetPosition() const override
Definition: sch_symbol.h:771
std::unique_ptr< LIB_SYMBOL > m_part
A flattened copy of the LIB_SYMBOL from the PROJECT object's libraries.
Definition: sch_symbol.h:870
int GetNextFieldOrdinal() const
Return the next ordinal for a user field for this symbol.
Definition: sch_symbol.cpp:862
void swapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
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:436
bool CanConnect(const SCH_ITEM *aItem) const override
Definition: sch_symbol.h:727
void Init(const VECTOR2I &pos=VECTOR2I(0, 0))
Definition: sch_symbol.cpp:174
bool HasAlternateBodyStyle() const override
Test if symbol has more than one body conversion type (DeMorgan).
Definition: sch_symbol.cpp:425
const LIB_ID & GetLibId() const override
Definition: sch_symbol.h:164
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 SetSchSymbolLibraryName(const wxString &aName)
The name of the symbol in the schematic library symbol list.
Definition: sch_symbol.h:179
bool IsMulti() const override
Definition: sch_symbol.h:266
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
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:459
BOX2I doGetBoundingBox(bool aIncludePins, bool aIncludeFields) const
bool GetMirrorY() const
Definition: sch_symbol.h:351
SCH_FIELD * AddField(const SCH_FIELD &aField)
Add a field to the symbol.
Definition: sch_symbol.cpp:868
void GetEndPoints(std::vector< DANGLING_END_ITEM > &aItemList) override
Add the schematic item end points to aItemList if the item has end points.
void RemoveField(SCH_FIELD *aField)
Definition: sch_symbol.h:454
void SetX(int aX)
Definition: sch_symbol.h:775
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:872
int GetUnitSelection(const SCH_SHEET_PATH *aSheet) const
Return the instance-specific unit selection for the given sheet path.
Definition: sch_symbol.cpp:739
SCH_PIN * GetPin(const wxString &number) const
Find a symbol pin by number.
wxString GetValueProp() const
Definition: sch_symbol.h:492
bool IsLocalPower() const override
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode) override
int GetUnitCount() const override
Return the number of units per package of the symbol.
Definition: sch_symbol.cpp:434
void SetPrefix(const wxString &aPrefix)
Definition: sch_symbol.h:250
int GetOrientation() const override
Get the display symbol orientation.
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.
bool IsSymbolLikePowerLocalLabel() const
void SetUnitSelection(const SCH_SHEET_PATH *aSheet, int aUnitSelection)
Set the selected unit of this symbol on one sheet.
Definition: sch_symbol.cpp:755
bool IsNormal() const override
std::unique_ptr< LIB_SYMBOL > & GetLibSymbolRef()
Definition: sch_symbol.h:183
std::unordered_set< wxString > GetComponentClassNames(const SCH_SHEET_PATH *aPath) const
Return the component classes this symbol belongs in.
std::vector< std::unique_ptr< SCH_PIN > > m_pins
A SCH_PIN for every #LIB_PIN.
Definition: sch_symbol.h:874
bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
Definition: sch_symbol.h:769
void SetLibSymbol(LIB_SYMBOL *aLibSymbol)
Set this schematic symbol library symbol reference to aLibSymbol.
Definition: sch_symbol.cpp:251
VECTOR2I GetPinPhysicalPosition(const SCH_PIN *Pin) const
BOX2I GetBodyBoundingBox() const override
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:611
wxString GetPrefix() const
Definition: sch_symbol.h:249
bool HasUnitDisplayName(int aUnit) const
Return true if the given unit aUnit has a display name set.
Definition: sch_symbol.cpp:451
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:215
bool IsPower() const override
bool operator==(const SCH_SYMBOL &aSymbol) const
SCH_FIELD * GetField(FIELD_T aFieldType)
Return a mandatory field in this symbol.
Definition: sch_symbol.cpp:813
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:63
RECURSE_MODE
Definition: eda_item.h:49
INSPECT_RESULT
Definition: eda_item.h:43
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition: eda_item.h:89
@ LAYER_WIRE
Definition: layer_ids.h:441
AUTOPLACE_ALGO
Definition: sch_item.h:68
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:56
std::weak_ptr< LIB_SYMBOL > PART_REF
Definition: sch_symbol.h:65
std::vector< SCH_FIELD > SCH_FIELDS
A container for several SCH_FIELD items.
Definition: sch_symbol.h:63
A simple container for schematic symbol instance information.
SYMBOL_ORIENTATION_PROP
Definition: symbol.h:51
SYMBOL_ORIENTATION_T
enum used in RotationMiroir()
Definition: symbol.h:35
@ SYM_ORIENT_270
Definition: symbol.h:42
@ SYM_MIRROR_Y
Definition: symbol.h:44
@ SYM_ORIENT_180
Definition: symbol.h:41
@ SYM_MIRROR_X
Definition: symbol.h:43
@ SYM_NORMAL
Definition: symbol.h:36
@ SYM_ORIENT_90
Definition: symbol.h:40
@ SYM_ORIENT_0
Definition: symbol.h:39
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:695