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 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 NETLIST_OBJECT_LIST;
57class SYMBOL_LIB;
58class SYMBOL_LIBS;
59class EE_COLLECTOR;
60class SCH_SCREEN;
61class SCH_COMMIT;
62
63
65typedef std::vector<SCH_FIELD> SCH_FIELDS;
66
67typedef std::weak_ptr<LIB_SYMBOL> PART_REF;
68
69
70extern std::string toUTFTildaText( const wxString& txt );
71
72
76class SCH_SYMBOL : public SYMBOL
77{
78public:
79 SCH_SYMBOL();
80
91 SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const LIB_ID& aLibId, const SCH_SHEET_PATH* aSheet,
92 int aUnit, int aBodyStyle = 0, const VECTOR2I& aPosition = VECTOR2I( 0, 0 ),
93 EDA_ITEM* aParent = nullptr );
94
95 SCH_SYMBOL( const LIB_SYMBOL& aSymbol, const SCH_SHEET_PATH* aSheet, const PICKED_SYMBOL& aSel,
96 const VECTOR2I& aPosition = VECTOR2I( 0, 0 ), EDA_ITEM* aParent = nullptr );
97
107 SCH_SYMBOL( const SCH_SYMBOL& aSymbol );
108
109 ~SCH_SYMBOL();
110
111 static inline bool ClassOf( const EDA_ITEM* aItem )
112 {
113 return aItem && SCH_SYMBOL_T == aItem->Type();
114 }
115
116 wxString GetClass() const override
117 {
118 return wxT( "SCH_SYMBOL" );
119 }
120
134 bool IsMissingLibSymbol() const;
135
136 const std::vector<SCH_SYMBOL_INSTANCE>& GetInstances() const
137 {
139 }
140
141 bool GetInstance( SCH_SYMBOL_INSTANCE& aInstance,
142 const KIID_PATH& aSheetPath, bool aTestFromEnd = false ) const;
143
144 void RemoveInstance( const SCH_SHEET_PATH& aInstancePath );
145
146 void RemoveInstance( const KIID_PATH& aInstancePath );
147
162 bool IsMovableFromAnchorPoint() const override;
163
164 void SetLibId( const LIB_ID& aName );
165
166 const LIB_ID& GetLibId() const override { return m_lib_id; }
167
168 wxString GetSymbolIDAsString() const { return m_lib_id.Format(); }
169
181 void SetSchSymbolLibraryName( const wxString& aName ) { m_schLibSymbolName = aName; }
182 wxString GetSchSymbolLibraryName() const;
183 bool UseLibIdLookup() const { return m_schLibSymbolName.IsEmpty(); }
184
185 std::unique_ptr< LIB_SYMBOL >& GetLibSymbolRef() { return m_part; }
186 const std::unique_ptr< LIB_SYMBOL >& GetLibSymbolRef() const { return m_part; }
187
204 void SetLibSymbol( LIB_SYMBOL* aLibSymbol );
205
209 wxString GetDescription() const override;
210
214 wxString GetKeyWords() const override;
215
219 wxString GetDatasheet() const;
220
224 void UpdatePins();
225
231 bool HasUnitDisplayName( int aUnit ) const;
232
238 wxString GetUnitDisplayName( int aUnit ) const;
239
240 void SetBodyStyle( int aBodyStyle ) override;
241
247 void SetBodyStyleUnconditional( int aBodyStyle );
248
249 bool HasAlternateBodyStyle() const override;
250
251 wxString GetPrefix() const { return m_prefix; }
252 void SetPrefix( const wxString& aPrefix ) { m_prefix = aPrefix; }
253
257 void UpdatePrefix();
258
259 wxString SubReference( int aUnit, bool aAddSeparator = true ) const;
260
266 int GetUnitCount() const override;
267
268 bool IsMulti() const override { return GetUnitCount() > 1; }
269
276 void SetOrientation( int aOrientation );
277
293 int GetOrientation() const override;
294
299 {
300 int mirroring = GetOrientation();
301
302 mirroring &= ( SYMBOL_ORIENTATION_T::SYM_MIRROR_X | SYMBOL_ORIENTATION_T::SYM_MIRROR_Y );
303
304 SetOrientation( aAngle | mirroring );
305 }
306
308 {
309 int orientation = GetOrientation();
310
311 orientation &= ~( SYMBOL_ORIENTATION_T::SYM_MIRROR_X | SYMBOL_ORIENTATION_T::SYM_MIRROR_Y );
312
313 switch( orientation )
314 {
315 default:
316 case SYM_NORMAL:
317 case SYM_ORIENT_0: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_0;
318 case SYM_ORIENT_90: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_90;
319 case SYM_ORIENT_180: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_180;
320 case SYM_ORIENT_270: return SYMBOL_ORIENTATION_PROP::SYMBOL_ANGLE_270;
321 }
322 }
323
324 void SetMirrorX( bool aMirror )
325 {
326 int orientation = GetOrientation();
327
328 if( aMirror )
329 orientation |= SYMBOL_ORIENTATION_T::SYM_MIRROR_X;
330 else
332
333 SetOrientation( orientation );
334 }
335
336 bool GetMirrorX() const
337 {
338 return GetOrientation() & SYMBOL_ORIENTATION_T::SYM_MIRROR_X;
339 }
340
341 void SetMirrorY( bool aMirror )
342 {
343 int orientation = GetOrientation();
344
345 if( aMirror )
346 orientation |= SYMBOL_ORIENTATION_T::SYM_MIRROR_Y;
347 else
349
350 SetOrientation( orientation );
351 }
352
353 bool GetMirrorY() const
354 {
355 return GetOrientation() & SYMBOL_ORIENTATION_T::SYM_MIRROR_Y;
356 }
357
361 void GetContextualTextVars( wxArrayString* aVars ) const;
362
368 bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth = 0 ) const;
369
370 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
371
382 void ClearAnnotation( const SCH_SHEET_PATH* aSheetPath, bool aResetPrefix );
383
395 bool AddSheetPathReferenceEntryIfMissing( const KIID_PATH& aSheetPath );
396
397
398 const BOX2I GetBoundingBox() const override;
399
403 BOX2I GetBodyBoundingBox() const override;
404
408 BOX2I GetBodyAndPinsBoundingBox() const override;
409
410
411 //-----<Fields>-----------------------------------------------------------
412
417 SCH_FIELD* GetField( FIELD_T aFieldType );
418 const SCH_FIELD* GetField( FIELD_T aFieldNdx ) const;
419
423 SCH_FIELD* GetField( const wxString& aFieldName );
424 const SCH_FIELD* GetField( const wxString& aFieldName ) const;
425
432 void GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly ) const override;
433
437 std::vector<SCH_FIELD>& GetFields() { return m_fields; }
438 const std::vector<SCH_FIELD>& GetFields() const { return m_fields; }
439
447 SCH_FIELD* AddField( const SCH_FIELD& aField );
448
454 void RemoveField( const wxString& aFieldName );
455
456 void RemoveField( SCH_FIELD* aField ) { RemoveField( aField->GetName() ); }
457
465 SCH_FIELD* FindFieldCaseInsensitive( const wxString& aFieldName );
466
470 const wxString GetRef( const SCH_SHEET_PATH* aSheet,
471 bool aIncludeUnit = false ) const override;
472
476 const wxString GetValue( bool aResolve, const SCH_SHEET_PATH* aPath,
477 bool aAllowExtraText ) const override;
478
479 void SetValueFieldText( const wxString& aValue );
480
481 const wxString GetFootprintFieldText( bool aResolve, const SCH_SHEET_PATH* aPath,
482 bool aAllowExtraText ) const;
483 void SetFootprintFieldText( const wxString& aFootprint );
484
485 /*
486 * Field access for property manager
487 */
488 wxString GetRefProp() const
489 {
490 return GetRef( &Schematic()->CurrentSheet() );
491 }
492
493 void SetRefProp( const wxString& aRef );
494 wxString GetValueProp() const
495 {
496 return GetValue( false, &Schematic()->CurrentSheet(), false );
497 }
498
499 void SetValueProp( const wxString& aRef )
500 {
501 SetValueFieldText( aRef );
502 }
503
504 wxString GetUnitProp() const
505 {
506 int unit = GetUnitSelection( &Schematic()->CurrentSheet() );
507
508 if( HasUnitDisplayName( unit ) )
509 return GetUnitDisplayName( unit );
510 else
511 return SubReference( unit, false );
512 }
513
514 void SetUnitProp( const wxString& aUnit )
515 {
516 for( int unit = 1; unit <= GetUnitCount(); unit++ )
517 {
518 if( HasUnitDisplayName( unit ) && GetUnitDisplayName( unit ) == aUnit )
519 {
520 SetUnitSelection( &Schematic()->CurrentSheet(), unit );
521 SetUnit( unit );
522 return;
523 }
524 }
525
526 for( int unit = 1; unit <= GetUnitCount(); unit++ )
527 {
528 if( SubReference( unit, false ) == aUnit )
529 {
530 SetUnitSelection( &Schematic()->CurrentSheet(), unit );
531 SetUnit( unit );
532 return;
533 }
534 }
535 }
536
538 {
539 return GetBodyStyle();
540 }
541
542 void SetBodyStyleProp( int aBodyStyle )
543 {
544 SetBodyStyle( aBodyStyle );
545 }
546
557 void UpdateFields( const SCH_SHEET_PATH* aPath, bool aUpdateStyle, bool aUpdateRef,
558 bool aUpdateOtherFields, bool aResetRef, bool aResetOtherFields );
559
569 void SyncOtherUnits( const SCH_SHEET_PATH& aSourceSheet, SCH_COMMIT& aCommit,
570 PROPERTY_BASE* aProperty );
571
575 int GetNextFieldOrdinal() const;
576
583 void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
584
585 void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override;
586
587
588 //-----</Fields>----------------------------------------------------------
589
590
597 SCH_PIN* GetPin( const wxString& number ) const;
598
605 std::vector<SCH_PIN*> GetLibPins() const;
606
611 std::vector<SCH_PIN*> GetAllLibPins() const;
612
616 size_t GetFullPinCount() const;
617
621 SCH_PIN* GetPin( SCH_PIN* aLibPin ) const;
622
630 const SCH_PIN* GetPin( const VECTOR2I& aPosition ) const;
631
640 std::vector<SCH_PIN*> GetPins( const SCH_SHEET_PATH* aSheet ) const;
641
642 std::vector<SCH_PIN*> GetPins() const override;
643
644
645 std::vector<std::unique_ptr<SCH_PIN>>& GetRawPins() { return m_pins; }
646
647 void SwapData( SCH_ITEM* aItem ) override;
648
655 void SetRef( const SCH_SHEET_PATH* aSheet, const wxString& aReference );
656
663 bool IsAnnotated( const SCH_SHEET_PATH* aSheet ) const;
664
676 void AddHierarchicalReference( const KIID_PATH& aPath,
677 const wxString& aRef,
678 int aUnit );
679
680 void AddHierarchicalReference( const SCH_SYMBOL_INSTANCE& aInstance );
681
683 int GetUnitSelection( const SCH_SHEET_PATH* aSheet ) const;
684
686 void SetUnitSelection( const SCH_SHEET_PATH* aSheet, int aUnitSelection );
687
689 void SetUnitSelection( int aUnitSelection );
690
691 void Move( const VECTOR2I& aMoveVector ) override
692 {
693 if( aMoveVector == VECTOR2I( 0, 0 ) )
694 return;
695
696 m_pos += aMoveVector;
697
698 for( SCH_FIELD& field : m_fields )
699 field.Move( aMoveVector );
700 }
701
702 void MirrorHorizontally( int aCenter ) override;
703 void MirrorVertically( int aCenter ) override;
704 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
705
706 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
707
708 void GetEndPoints( std::vector<DANGLING_END_ITEM>& aItemList ) override;
709
720 bool UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemListByType,
721 std::vector<DANGLING_END_ITEM>& aItemListByPos,
722 const SCH_SHEET_PATH* aPath = nullptr ) override;
723
724 VECTOR2I GetPinPhysicalPosition( const SCH_PIN* Pin ) const;
725
726 bool IsConnectable() const override { return true; }
727
728 bool HasConnectivityChanges( const SCH_ITEM* aItem,
729 const SCH_SHEET_PATH* aInstance = nullptr ) const override;
730
731 bool CanConnect( const SCH_ITEM* aItem ) const override
732 {
733 return ( aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_WIRE ) ||
734 ( aItem->Type() == SCH_NO_CONNECT_T ) ||
735 ( aItem->Type() == SCH_JUNCTION_T ) ||
736 ( aItem->Type() == SCH_SYMBOL_T ) ||
737 ( aItem->Type() == SCH_DIRECTIVE_LABEL_T ) ||
738 ( aItem->Type() == SCH_LABEL_T ) ||
739 ( aItem->Type() == SCH_HIER_LABEL_T ) ||
740 ( aItem->Type() == SCH_GLOBAL_LABEL_T );
741 }
742
746 bool IsInNetlist() const;
747
748 std::vector<VECTOR2I> GetConnectionPoints() const override;
749
750 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
751 const std::vector<KICAD_T>& aScanTypes ) override;
752
760 SCH_ITEM* GetDrawItem( const VECTOR2I& aPosition, KICAD_T aType = TYPE_NOT_INIT );
761
762 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
763
764 BITMAPS GetMenuImage() const override;
765
766 bool operator <( const SCH_ITEM& aItem ) const override;
767
768 bool operator==( const SCH_SYMBOL& aSymbol) const;
769 bool operator!=( const SCH_SYMBOL& aSymbol) const;
770
771 SCH_SYMBOL& operator=( const SCH_SYMBOL& aItem );
772
773 bool IsReplaceable() const override { return true; }
774
775 VECTOR2I GetPosition() const override { return m_pos; }
776 void SetPosition( const VECTOR2I& aPosition ) override { Move( aPosition - m_pos ); }
777
778 int GetX() const { return GetPosition().x; };
779 void SetX( int aX ) { SetPosition( VECTOR2I( aX, GetY() ) ); }
780
781 int GetY() const { return GetPosition().y; }
782 void SetY( int aY ) { SetPosition( VECTOR2I( GetX(), aY ) ); }
783
784 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
785 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
786
787 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
788 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
789
797 void PlotPins( PLOTTER* aPlotter ) const;
798
805 void PlotDNP( PLOTTER* aPlotter ) const;
806
807 EDA_ITEM* Clone() const override;
808
809#if defined(DEBUG)
810 void Show( int nestLevel, std::ostream& os ) const override;
811#endif
812
813 void ClearBrightenedPins();
814
815 bool HasBrightenedPins();
816
817 bool IsPointClickableAnchor( const VECTOR2I& aPos ) const override;
818
824 bool IsSymbolLikePowerGlobalLabel() const;
825 bool IsSymbolLikePowerLocalLabel() const;
826
827 bool IsGlobalPower() const override;
828 bool IsLocalPower() const override;
829 bool IsPower() const override;
830 bool IsNormal() const override;
831
832 bool GetShowPinNames() const override;
833 void SetShowPinNames( bool aShow ) override;
834
835 bool GetShowPinNumbers() const override;
836 void SetShowPinNumbers( bool aShow ) override;
837
838 double Similarity( const SCH_ITEM& aOther ) const override;
839
841 std::unordered_set<wxString> GetComponentClassNames( const SCH_SHEET_PATH* aPath ) const;
842
843 bool operator==( const SCH_ITEM& aOther ) const override;
844
845private:
846 BOX2I doGetBoundingBox( bool aIncludePins, bool aIncludeFields ) const;
847
848 bool doIsConnected( const VECTOR2I& aPosition ) const override;
849
850 void Init( const VECTOR2I& pos = VECTOR2I( 0, 0 ) );
851
852private:
855 wxString m_prefix;
859
868
869 std::vector<SCH_FIELD> m_fields;
870
871 std::unique_ptr<LIB_SYMBOL> m_part;
874
875 std::vector<std::unique_ptr<SCH_PIN>> m_pins;
876 std::unordered_map<SCH_PIN*, SCH_PIN*> m_pinMap;
877
883 std::vector<SCH_SYMBOL_INSTANCE> m_instanceReferences;
884
886 static std::unordered_map<TRANSFORM, int> s_transformToOrientationCache;
887};
888
889#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: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:1079
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:150
int GetBodyStyle() const
Definition: sch_item.h:236
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
Definition: sch_item.h:288
virtual void SetUnit(int aUnit)
Definition: sch_item.h:232
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:77
void SetValueProp(const wxString &aRef)
Definition: sch_symbol.h:499
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:855
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:876
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction) override
void SetMirrorX(bool aMirror)
Definition: sch_symbol.h:324
bool IsSymbolLikePowerGlobalLabel() const
VECTOR2I m_pos
Definition: sch_symbol.h:853
wxString GetSymbolIDAsString() const
Definition: sch_symbol.h:168
LIB_ID m_lib_id
Name and library the symbol was loaded from, i.e. 74xx:74LS00.
Definition: sch_symbol.h:854
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:437
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:645
const std::vector< SCH_SYMBOL_INSTANCE > & GetInstances() const
Definition: sch_symbol.h:136
void SetPosition(const VECTOR2I &aPosition) override
Definition: sch_symbol.h:776
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:726
SYMBOL_ORIENTATION_PROP GetOrientationProp() const
Definition: sch_symbol.h:307
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:781
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:116
void RemoveInstance(const SCH_SHEET_PATH &aInstancePath)
Definition: sch_symbol.cpp:483
void SetUnitProp(const wxString &aUnit)
Definition: sch_symbol.h:514
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:341
void PlotPins(PLOTTER *aPlotter) const
Plot just the symbol pins.
bool UseLibIdLookup() const
Definition: sch_symbol.h:183
void SetValueFieldText(const wxString &aValue)
Definition: sch_symbol.cpp:791
int GetX() const
Definition: sch_symbol.h:778
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 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:269
wxString GetSchSymbolLibraryName() const
Definition: sch_symbol.cpp:242
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_symbol.h:111
bool IsInNetlist() const
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_symbol.h:691
void SetBodyStyleProp(int aBodyStyle)
Definition: sch_symbol.h:542
void ClearBrightenedPins()
void SetY(int aY)
Definition: sch_symbol.h:782
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:336
wxString GetRefProp() const
Definition: sch_symbol.h:488
wxString GetUnitProp() const
Definition: sch_symbol.h:504
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:886
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:883
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:186
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:867
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:298
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:869
int GetBodyStyleProp() const
Definition: sch_symbol.h:537
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:775
std::unique_ptr< LIB_SYMBOL > m_part
A flattened copy of the LIB_SYMBOL from the PROJECT object's libraries.
Definition: sch_symbol.h:871
int GetNextFieldOrdinal() const
Return the next ordinal for a user field for this symbol.
Definition: sch_symbol.cpp:862
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:438
bool CanConnect(const SCH_ITEM *aItem) const override
Definition: sch_symbol.h:731
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:166
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:181
bool IsMulti() const override
Definition: sch_symbol.h:268
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:353
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:456
void SetX(int aX)
Definition: sch_symbol.h:779
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:873
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:494
bool IsLocalPower() const 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:252
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:185
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:875
bool IsReplaceable() const override
Override this method in any derived object that supports test find and replace.
Definition: sch_symbol.h:773
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:251
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
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:82
@ 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:67
std::vector< SCH_FIELD > SCH_FIELDS
A container for several SCH_FIELD items.
Definition: sch_symbol.h:65
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