KiCad PCB EDA Suite
Loading...
Searching...
No Matches
lib_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) 2004-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2008 Wayne Stambaugh <[email protected]>
6 * Copyright (C) 2022 CERN
7 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
23#pragma once
24
25#include <base_units.h>
26#include <embedded_files.h>
27#include <symbol.h>
28#include <sch_field.h>
29#include <sch_pin.h>
30#include <lib_tree_item.h>
31#include <pin_map.h>
32#include <set>
33#include <vector>
34#include <core/multivector.h>
35#include <default_values.h>
36
37class LINE_READER;
38class OUTPUTFORMATTER;
39class REPORTER;
41class LIB_SYMBOL;
43
45{
46class SchematicSymbol;
47}
48
49namespace KIFONT
50{
51 class OUTLINE_FONT;
52}
53
54
57
58
59/* values for member .m_options */
61{
62 ENTRY_NORMAL, // Libentry is a standard symbol (real or alias)
63 ENTRY_GLOBAL_POWER, // Libentry is a power symbol
64 ENTRY_LOCAL_POWER // Libentry is a local power symbol
65};
66
67
68extern bool operator<( const LIB_SYMBOL& aItem1, const LIB_SYMBOL& aItem2 );
69
70
72{
73 int m_unit;
75 std::vector<SCH_ITEM*> m_items;
76};
77
78
85{
87 bool m_updateAllFields = true;
88
90 std::set<wxString> m_updateFields;
91
93 bool m_removeExtraFields = false;
94
96 bool m_resetVisibility = false;
97
99 bool m_resetEffects = false;
100
102 bool m_resetPositions = false;
103
105 bool m_resetText = false;
106
108 bool m_resetEmptyText = false;
109};
110
111
118class LIB_SYMBOL : public SYMBOL, public LIB_TREE_ITEM, public EMBEDDED_FILES
119{
120public:
121 LIB_SYMBOL( const wxString& aName, LIB_SYMBOL* aParent = nullptr, LEGACY_SYMBOL_LIB* aLibrary = nullptr );
122
123 LIB_SYMBOL( const LIB_SYMBOL& aSymbol, LEGACY_SYMBOL_LIB* aLibrary = nullptr, bool aCopyEmbeddedFiles = true );
124
125 virtual ~LIB_SYMBOL() = default;
126
128 std::shared_ptr<LIB_SYMBOL> SharedPtr() const { return m_me; }
129
133 virtual LIB_SYMBOL* Duplicate() const
134 {
135 LIB_SYMBOL* dupe = new LIB_SYMBOL( *this, m_library );
136 const_cast<KIID&>( dupe->m_Uuid ) = KIID();
137
138 for( SCH_ITEM& item : dupe->m_drawings )
139 const_cast<KIID&>( item.m_Uuid ) = KIID();
140
141 return dupe;
142 }
143
147 static LIB_SYMBOL* GetDummy();
148
149 void SetParent( LIB_SYMBOL* aParent = nullptr );
150 std::weak_ptr<LIB_SYMBOL>& GetParent() { return m_parent; }
151 const std::weak_ptr<LIB_SYMBOL>& GetParent() const { return m_parent; }
152
158 unsigned GetInheritanceDepth() const;
159
168 std::shared_ptr<LIB_SYMBOL> GetRootSymbol() const;
169
170 virtual wxString GetClass() const override
171 {
172 return wxT( "LIB_SYMBOL" );
173 }
174
175 static inline bool ClassOf( const EDA_ITEM* aItem )
176 {
177 return aItem && aItem->Type() == LIB_SYMBOL_T;
178 }
179
180 virtual void SetName( const wxString& aName );
181 wxString GetName() const override { return m_name; }
182
183 LIB_ID GetLIB_ID() const override { return m_libId; }
184 wxString GetDesc() override { return GetShownDescription( FOR_GUI ); }
185 wxString GetFootprint() override;
186 int GetSubUnitCount() const override { return GetUnitCount(); }
187
188 const LIB_ID& GetLibId() const override { return m_libId; }
189 void SetLibId( const LIB_ID& aLibId );
190
192 void SetSourceLibId( const LIB_ID& aLibId ) { m_sourceLibId = aLibId; }
193
194 wxString GetLibNickname() const override { return GetLibraryName(); }
195
197 void SetDescription( const wxString& aDescription );
198
200 wxString GetDescription() const override
201 {
202 if( GetDescriptionField().GetText().IsEmpty() && IsDerived() )
203 {
204 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
205 return parent->GetDescription();
206 }
207
208 return GetDescriptionField().GetText();
209 }
210
211 wxString GetShownDescription( RESOLUTION_CONTEXT aContext, int aDepth = 0 ) const override;
212
213 void SetKeyWords( const wxString& aKeyWords );
214
215 wxString GetKeyWords() const override
216 {
217 if( m_keyWords.IsEmpty() && IsDerived() )
218 {
219 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
220 return parent->GetKeyWords();
221 }
222
223 return m_keyWords;
224 }
225
226 wxString GetShownKeyWords( RESOLUTION_CONTEXT aContext, int aDepth = 0 ) const override;
227
228 std::vector<SEARCH_TERM>& GetSearchTerms() override { return m_searchTermsCache; }
229
230 void GetChooserFields( std::map<wxString , wxString>& aColumnMap ) override;
231
235 bool IsRoot() const override { return m_parent.use_count() == 0; }
236 bool IsDerived() const { return !m_parent.expired() && m_parent.use_count() > 0; }
237
238 const wxString GetLibraryName() const;
239
240 LEGACY_SYMBOL_LIB* GetLib() const { return m_library; }
241 void SetLib( LEGACY_SYMBOL_LIB* aLibrary );
242
244
245 void SetFPFilters( const wxArrayString& aFilters ) { m_fpFilters = aFilters; }
246
247 wxArrayString GetFPFilters() const
248 {
249 if( m_fpFilters.IsEmpty() && IsDerived() )
250 {
251 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
252 return parent->GetFPFilters();
253 }
254
255 return m_fpFilters;
256 }
257
260
261 const PIN_MAP_SET& GetPinMaps() const { return m_pinMaps; }
263 void SetPinMaps( const PIN_MAP_SET& aPinMaps ) { m_pinMaps = aPinMaps; }
264
265 const std::vector<ASSOCIATED_FOOTPRINT>& GetAssociatedFootprints() const { return m_associatedFootprints; }
266
267 void SetAssociatedFootprints( std::vector<ASSOCIATED_FOOTPRINT> aList )
268 {
269 m_associatedFootprints = std::move( aList );
270 }
271
281 {
283 {
284 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
285 return parent->GetEffectivePinMaps();
286 }
287
288 return m_pinMaps;
289 }
290
295 const std::vector<ASSOCIATED_FOOTPRINT>& GetEffectiveAssociatedFootprints() const
296 {
298 {
299 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
300 return parent->GetEffectiveAssociatedFootprints();
301 }
302
304 }
305
318 const BOX2I GetUnitBoundingBox( int aUnit, int aBodyStyle, bool aIgnoreHiddenFields = true,
319 bool aIgnoreLabelsOnInvisiblePins = true ) const;
320
321 const BOX2I GetBoundingBox() const override
322 {
323 return GetUnitBoundingBox( 0, 0 );
324 }
325
336 const BOX2I GetBodyBoundingBox( int aUnit, int aBodyStyle, bool aIncludePins,
337 bool aIncludePrivateItems ) const;
338
339 BOX2I GetBodyBoundingBox() const override
340 {
341 return GetBodyBoundingBox( m_previewUnit, m_previewBodyStyle, false, false );
342 }
343
345 {
347 }
348
349 bool IsGlobalPower() const override;
350 bool IsLocalPower() const override;
351 bool IsPower() const override;
352 bool IsNormal() const override;
353
354 // LIB_TREE_ITEM interface
355 bool IsPowerSymbol() const override { return IsPower(); }
356
357 void SetGlobalPower();
358 void SetLocalPower();
359 void SetNormal();
360
365 void LockUnits( bool aLockUnits ) { m_unitsLocked = aLockUnits; }
366
375 bool UnitsLocked() const;
376
382 void SetFields( const std::vector<SCH_FIELD>& aFieldsList );
383
389 void GetFields( std::vector<SCH_FIELD*>& aList, bool aVisibleOnly = false ) const override;
390
394 void CopyFields( std::vector<SCH_FIELD>& aList );
395
403 void SyncFieldsFromParent( const LIB_FIELD_SYNC_OPTIONS& aOptions );
404
410 bool CanUpdateFieldsFromParent() const { return IsDerived(); }
411
415 void AddField( SCH_FIELD* aField );
416
417 void AddField( SCH_FIELD& aField ) { AddField( new SCH_FIELD( aField ) ); }
418
422 int GetNextFieldOrdinal() const;
423
427 SCH_FIELD* GetField( const wxString& aFieldName );
428 const SCH_FIELD* GetField( const wxString& aFieldName ) const;
429
430 SCH_FIELD* FindFieldCaseInsensitive( const wxString& aFieldName );
431 const SCH_FIELD* FindFieldCaseInsensitive( const wxString& aFieldName ) const;
432
433 const SCH_FIELD* GetField( FIELD_T aFieldType ) const;
434 SCH_FIELD* GetField( FIELD_T aFieldType );
435
438 const SCH_FIELD& GetValueField() const;
439
442 const SCH_FIELD& GetReferenceField() const;
443
446 const SCH_FIELD& GetFootprintField() const;
447
450 const SCH_FIELD& GetDatasheetField() const;
451
454 const SCH_FIELD& GetDescriptionField() const;
455
456 wxString GetPrefix();
457
458 const wxString GetRef( const SCH_SHEET_PATH* aSheet, bool aIncludeUnit = false ) const override
459 {
460 return GetReferenceField().GetText();
461 }
462
463 const wxString GetValue( const SCH_SHEET_PATH* aPath, RESOLUTION_CONTEXT aContext,
464 const wxString& aVariantName = wxEmptyString ) const override
465 {
466 return GetValueField().GetText();
467 }
468
469 /*
470 * Field access for property manager
471 */
472 wxString GetRefProp() const
473 {
474 return GetReferenceField().GetText();
475 }
476
477 void SetRefProp( const wxString& aRef )
478 {
479 GetReferenceField().SetText( aRef );
480 }
481
482 wxString GetValueProp() const
483 {
484 return GetValueField().GetText();
485 }
486
487 void SetValueProp( const wxString& aValue )
488 {
489 GetValueField().SetText( aValue );
490 }
491
492 wxString GetFootprintProp() const
493 {
494 return GetFootprintField().GetText();
495 }
496
497 void SetFootprintProp( const wxString& aFootprint )
498 {
499 GetFootprintField().SetText( aFootprint );
501 }
502
503 wxString GetDatasheetProp() const
504 {
505 return GetDatasheetField().GetText();
506 }
507
508 void SetDatasheetProp( const wxString& aDatasheet )
509 {
510 GetDatasheetField().SetText( aDatasheet );
511 }
512
513 wxString GetKeywordsProp() const
514 {
515 return GetKeyWords();
516 }
517
518 void SetKeywordsProp( const wxString& aKeywords )
519 {
520 SetKeyWords( aKeywords );
521 }
522
524 {
525 return IsPower();
526 }
527
528 void SetPowerSymbolProp( bool aIsPower )
529 {
530 if( aIsPower )
532 else
533 SetNormal();
534 }
535
537 {
538 return IsLocalPower();
539 }
540
541 void SetLocalPowerSymbolProp( bool aIsLocalPower )
542 {
543 if( aIsLocalPower )
545 else if( IsPower() )
547 else
548 SetNormal();
549 }
550
552 {
553 return GetPinNameOffset() != 0;
554 }
555
556 void SetPinNamesInsideProp( bool aInside )
557 {
558 if( aInside && GetPinNameOffset() == 0 )
560 else if( !aInside )
561 SetPinNameOffset( 0 );
562 }
563
564 int GetUnitProp() const
565 {
566 return GetUnitCount();
567 }
568
569 void SetUnitProp( int aUnits )
570 {
571 SetUnitCount( aUnits, true );
572 }
573
575 {
576 return !UnitsLocked();
577 }
578
579 void SetUnitsInterchangeableProp( bool aInterchangeable )
580 {
581 LockUnits( !aInterchangeable );
582 }
583
584 wxString GetBodyStyleProp() const override
585 {
586 return GetBodyStyleDescription( 1, false );
587 }
588
589 void SetBodyStyleProp( const wxString& aBodyStyle ) override
590 {
591 // Body style setting is more complex for LIB_SYMBOL
592 // For now, this is primarily for display purposes
593 }
594
596 {
597 return GetExcludedFromSim();
598 }
599
600 void SetExcludedFromSimProp( bool aExclude )
601 {
602 SetExcludedFromSim( aExclude );
603 }
604
606 {
607 return GetExcludedFromBOM();
608 }
609
610 void SetExcludedFromBOMProp( bool aExclude )
611 {
612 SetExcludedFromBOM( aExclude );
613 }
614
616 {
617 return GetExcludedFromBoard();
618 }
619
620 void SetExcludedFromBoardProp( bool aExclude )
621 {
622 SetExcludedFromBoard( aExclude );
623 }
624
626 void SetExcludedFromPosFilesProp( bool aExclude ) { SetExcludedFromPosFiles( aExclude ); }
627
628 void Serialize( kiapi::schematic::types::SchematicSymbol& aOutput, bool aSkipPins = false ) const;
629 bool Deserialize( const kiapi::schematic::types::SchematicSymbol& aInput );
630
631 void Serialize( google::protobuf::Any& aContainer ) const override;
632 bool Deserialize( const google::protobuf::Any& aContainer ) override;
633
634 std::set<KIFONT::OUTLINE_FONT*> GetFonts() const override;
635
637 const EMBEDDED_FILES* GetEmbeddedFiles() const;
638 void AppendParentEmbeddedFiles( std::vector<EMBEDDED_FILES*>& aStack ) const;
639
640 void EmbedFonts() override;
641
648 void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
649
650 void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction, RECURSE_MODE aMode ) override;
651
657 bool ResolveTextVar( wxString* token, int aDepth = 0 ) const;
658
659 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
660 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
661
665 void PlotFields( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
666 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed );
667
674 void AddDrawItem( SCH_ITEM* aItem, bool aSort = true );
675
681 void RemoveDrawItem( SCH_ITEM* aItem );
682
683 void RemoveField( SCH_FIELD* aField ) { RemoveDrawItem( aField ); }
684
693 std::vector<const SCH_PIN*> GetGraphicalPins( int aUnit = 0, int aBodyStyle = 0 ) const;
694 std::vector<SCH_PIN*> GetGraphicalPins( int aUnit = 0, int aBodyStyle = 0 );
695
701 {
702 const SCH_PIN* pin;
703 wxString number;
704 };
705
710 std::vector<LOGICAL_PIN> GetLogicalPins( int aUnit, int aBodyStyle ) const;
711
713 {
714 wxString m_unitName;
715 std::vector<wxString> m_pinNumbers;
716 };
717
721 std::vector<UNIT_PIN_INFO> GetUnitPinInfo() const;
722
723
724 // Deprecated: use GetGraphicalPins(). This override remains to satisfy SYMBOL's pure virtual.
725 std::vector<SCH_PIN*> GetPins() const override;
726
730 int GetPinCount() override;
731
740 const SCH_PIN* GetPin( const wxString& aNumber, int aUnit = 0, int aBodyStyle = 0 ) const;
741
753 std::vector<SCH_PIN*> GetPinsByNumber( const wxString& aNumber, int aUnit = 0, int aBodyStyle = 0 );
754
760 bool HasPinNumber( const wxString& aNumber ) const;
761
773 bool PinsConflictWith( const LIB_SYMBOL& aOtherSymbol, bool aTestNums, bool aTestNames,
774 bool aTestType, bool aTestOrientation, bool aTestLength ) const;
775
781 void Move( const VECTOR2I& aOffset ) override;
782
789 bool HasLegacyAlternateBodyStyle() const;
790
795 int GetMaxPinNumber() const;
796
800 void ClearTempFlags() override;
801 void ClearEditFlags() override;
802
812 SCH_ITEM* LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint );
813
824 SCH_ITEM* LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint,
825 const TRANSFORM& aTransform );
826
833 const LIB_ITEMS_CONTAINER& GetDrawItems() const { return m_drawings; }
834
839 void FixupDrawItems();
840
841 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
842 const std::vector<KICAD_T>& aScanTypes ) override;
843
855 void SetUnitCount( int aCount, bool aDuplicateDrawItems );
856 int GetUnitCount() const override;
857
858 wxString GetUnitName( int aUnit ) const override
859 {
860 return GetUnitDisplayName( aUnit, true );
861 }
862
866 wxString GetUnitDisplayName( int aUnit, bool aLabel ) const override;
867
868 wxString GetBodyStyleDescription( int aBodyStyle, bool aLabel ) const override;
869
870 std::map<int, wxString>& GetUnitDisplayNames() { return m_unitDisplayNames; }
871 const std::map<int, wxString>& GetUnitDisplayNames() const { return m_unitDisplayNames; }
872
875
880 std::vector<std::set<wxString>>& JumperPinGroups() { return m_jumperPinGroups; }
881 const std::vector<std::set<wxString>>& JumperPinGroups() const { return m_jumperPinGroups; }
882
884 std::optional<const std::set<wxString>> GetJumperPinGroup( const wxString& aPinNumber ) const;
885
890 bool IsMultiUnit() const override { return GetUnitCount() > 1; }
891
892 static wxString LetterSubReference( int aUnit, wxChar aInitialLetter );
893
894 bool IsMultiBodyStyle() const override { return GetBodyStyleCount() > 1; }
895
900 int GetBodyStyleCount() const override;
901 bool HasDeMorganBodyStyles() const override;
902 const std::vector<wxString>& GetBodyStyleNames() const;
903
904 void SetHasDeMorganBodyStyles( bool aFlag ) { m_demorgan = aFlag; }
905 void SetBodyStyleNames( const std::vector<wxString>& aBodyStyleNames ) { m_bodyStyleNames = aBodyStyleNames; }
906
918 void SetBodyStyleCount( int aCount, bool aDuplicateDrawItems, bool aDuplicatePins );
919
925 void PruneBodyStyleDrawItems( int aBodyStyleCount );
926
936 int Compare( const LIB_SYMBOL& aRhs, int aCompareFlags = ~COMPARE_FLAGS::UNIT,
937 REPORTER* aReporter = nullptr ) const;
938
939 const LIB_SYMBOL& operator=( const LIB_SYMBOL& aSymbol );
940
948 std::unique_ptr< LIB_SYMBOL > Flatten() const;
949
960 std::vector<struct LIB_SYMBOL_UNIT> GetUnitDrawItems();
961
972 std::vector<SCH_ITEM*> GetUnitDrawItems( int aUnit, int aBodyStyle );
973
980 double Similarity( const SCH_ITEM& aSymbol ) const override;
981
983
984 void SetParentName( const wxString& aParentName ) { m_parentName = aParentName; }
985 const wxString& GetParentName() const { return m_parentName; }
986
987#if defined(DEBUG)
988 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
989#endif
990
991protected:
1005 int compare( const SCH_ITEM& aOther,
1006 int aCompareFlags = ~( COMPARE_FLAGS::UUID | COMPARE_FLAGS::UNIT ) ) const override;
1007
1008private:
1009 // We create a different set parent function for this class, so we hide the inherited one.
1010 using EDA_ITEM::SetParent;
1011
1012 void deleteAllFields();
1013
1014 wxString getShownDescription( RESOLUTION_CONTEXT aContext, int aDepth ) const;
1015
1018 bool definesOwnPinMapBundle() const { return !m_pinMaps.IsEmpty() || !m_associatedFootprints.empty(); }
1019
1020 void cacheSearchTerms();
1021 void cachePinCount();
1022 void cacheShownDescription();
1023 void cacheChooserFields();
1024
1025private:
1026 std::shared_ptr<LIB_SYMBOL> m_me;
1027 std::weak_ptr<LIB_SYMBOL> m_parent;
1028
1029 wxString m_parentName;
1030
1034
1038
1042
1044
1046
1048 wxString m_name;
1049 wxString m_keyWords;
1050 wxArrayString m_fpFilters;
1052
1055
1058 std::vector<ASSOCIATED_FOOTPRINT> m_associatedFootprints;
1059
1062 std::vector<std::set<wxString> > m_jumperPinGroups;
1063
1067
1068 std::map<int, wxString> m_unitDisplayNames;
1069 std::vector<wxString> m_bodyStyleNames;
1070
1071 // Caches for things that are expensive to compute but required every time
1072 // the symbol chooser or other library list is created
1073
1074 std::vector<SEARCH_TERM> m_searchTermsCache;
1077 std::map<wxString, wxString> m_chooserFieldsCache;
1078};
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:123
BOX2< VECTOR2I > BOX2I
Definition box2.h:927
const KIID m_Uuid
Definition eda_item.h:597
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:153
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
bool IsEmpty() const
EMBEDDED_FILES()=default
Class OUTLINE_FONT implements outline font drawing.
Definition kiid.h:46
Object used to load, save, search, and otherwise manipulate symbol library files.
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
Define a library symbol object.
Definition lib_symbol.h:119
std::vector< SEARCH_TERM > & GetSearchTerms() override
Definition lib_symbol.h:228
LIB_ITEMS_CONTAINER m_drawings
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
SCH_FIELD & GetDescriptionField()
Return reference to the description field.
Definition lib_symbol.h:453
wxString GetDescription() const override
Definition lib_symbol.h:200
const LIB_ID & GetLibId() const override
Definition lib_symbol.h:188
const BOX2I GetUnitBoundingBox(int aUnit, int aBodyStyle, bool aIgnoreHiddenFields=true, bool aIgnoreLabelsOnInvisiblePins=true) const
Get the bounding box for the symbol.
wxString GetKeyWords() const override
Definition lib_symbol.h:215
void SetGlobalPower()
std::weak_ptr< LIB_SYMBOL > & GetParent()
Definition lib_symbol.h:150
wxString GetBodyStyleProp() const override
Definition lib_symbol.h:584
virtual ~LIB_SYMBOL()=default
const wxString GetValue(const SCH_SHEET_PATH *aPath, RESOLUTION_CONTEXT aContext, const wxString &aVariantName=wxEmptyString) const override
Definition lib_symbol.h:463
LIBRENTRYOPTIONS m_options
Special symbol features such as POWER or NORMAL.
wxString GetRefProp() const
Definition lib_symbol.h:472
bool PinsConflictWith(const LIB_SYMBOL &aOtherSymbol, bool aTestNums, bool aTestNames, bool aTestType, bool aTestOrientation, bool aTestLength) const
Return true if this symbol's pins do not match another symbol's pins.
bool GetUnitsInterchangeableProp() const
Definition lib_symbol.h:574
const std::map< int, wxString > & GetUnitDisplayNames() const
Definition lib_symbol.h:871
wxString m_shownDescriptionCache
std::vector< const SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
void GetFields(std::vector< SCH_FIELD * > &aList, bool aVisibleOnly=false) const override
Populate a std::vector with SCH_FIELDs, sorted in ordinal order.
bool IsPower() const override
wxString GetPrefix()
void SetSourceLibId(const LIB_ID &aLibId)
Definition lib_symbol.h:192
const std::vector< ASSOCIATED_FOOTPRINT > & GetEffectiveAssociatedFootprints() const
Definition lib_symbol.h:295
bool UnitsLocked() const
Check whether symbol units are interchangeable.
SCH_FIELD & GetDatasheetField()
Return reference to the datasheet field.
Definition lib_symbol.h:449
void RefreshLibraryTreeCaches()
std::weak_ptr< LIB_SYMBOL > m_parent
Use for inherited symbols.
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
Definition lib_symbol.h:235
void SetExcludedFromBoardProp(bool aExclude)
Definition lib_symbol.h:620
void cachePinCount()
std::vector< struct LIB_SYMBOL_UNIT > GetUnitDrawItems()
Return a list of SCH_ITEM objects separated by unit and convert number.
void RemoveField(SCH_FIELD *aField)
Definition lib_symbol.h:683
std::map< int, wxString > m_unitDisplayNames
std::vector< std::set< wxString > > m_jumperPinGroups
A list of jumper pin groups, each of which is a set of pin numbers that should be jumpered together (...
void ClearTempFlags() override
Clears the status flag all draw objects in this symbol.
void Serialize(kiapi::schematic::types::SchematicSymbol &aOutput, bool aSkipPins=false) const
void SetKeywordsProp(const wxString &aKeywords)
Definition lib_symbol.h:518
bool IsDerived() const
Definition lib_symbol.h:236
std::map< int, wxString > & GetUnitDisplayNames()
Definition lib_symbol.h:870
void SetDuplicatePinNumbersAreJumpers(bool aEnabled)
Definition lib_symbol.h:874
bool m_demorgan
True if there are two body styles: normal and De Morgan If false, the body style count is taken from ...
wxString GetFootprint() override
For items with footprint fields.
const wxString GetLibraryName() const
void SetFields(const std::vector< SCH_FIELD > &aFieldsList)
Overwrite all the existing fields in this symbol with fields supplied in aFieldsList.
void SetExcludedFromPosFilesProp(bool aExclude)
Definition lib_symbol.h:626
timestamp_t GetLastModDate() const
Definition lib_symbol.h:243
LIB_ID GetSourceLibId() const
Definition lib_symbol.h:191
void SetLib(LEGACY_SYMBOL_LIB *aLibrary)
bool GetPowerSymbolProp() const
Definition lib_symbol.h:523
bool IsMultiBodyStyle() const override
Definition lib_symbol.h:894
int GetMaxPinNumber() const
virtual LIB_SYMBOL * Duplicate() const
Create a copy of a LIB_SYMBOL and assigns unique KIIDs to the copy and its children.
Definition lib_symbol.h:133
bool CanUpdateFieldsFromParent() const
Definition lib_symbol.h:410
std::vector< SEARCH_TERM > m_searchTermsCache
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.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition lib_symbol.h:321
SCH_FIELD * GetField(const wxString &aFieldName)
Find a field within this symbol matching aFieldName; return nullptr if not found.
bool IsPowerSymbol() const override
For symbols that could be a power symbol.
Definition lib_symbol.h:355
SCH_FIELD & GetFootprintField()
Return reference to the footprint field.
Definition lib_symbol.h:445
void SetAssociatedFootprints(std::vector< ASSOCIATED_FOOTPRINT > aList)
Definition lib_symbol.h:267
void FixupDrawItems()
This function finds the filled draw items that are covering up smaller draw items and replaces their ...
void SetBodyStyleNames(const std::vector< wxString > &aBodyStyleNames)
Definition lib_symbol.h:905
bool IsNormal() const override
wxString m_name
void SetUnitsInterchangeableProp(bool aInterchangeable)
Definition lib_symbol.h:579
std::set< KIFONT::OUTLINE_FONT * > GetFonts() const override
LEGACY_SYMBOL_LIB * m_library
static bool ClassOf(const EDA_ITEM *aItem)
Definition lib_symbol.h:175
bool GetExcludedFromPosFilesProp() const
Definition lib_symbol.h:625
SCH_FIELD * FindFieldCaseInsensitive(const wxString &aFieldName)
const std::vector< std::set< wxString > > & JumperPinGroups() const
Definition lib_symbol.h:881
wxString m_keyWords
Search keywords.
SCH_ITEM * LocateDrawItem(int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I &aPoint)
Locate a draw object.
static wxString LetterSubReference(int aUnit, wxChar aInitialLetter)
double Similarity(const SCH_ITEM &aSymbol) const override
Return a measure of similarity between this symbol and aSymbol.
static LIB_SYMBOL * GetDummy()
Returns a dummy LIB_SYMBOL, used when one is missing in the schematic.
void PlotFields(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed)
Plot symbol fields.
LEGACY_SYMBOL_LIB * GetLib() const
Definition lib_symbol.h:240
wxString GetDatasheetProp() const
Definition lib_symbol.h:503
void LockUnits(bool aLockUnits)
Set interchangeable the property for symbol units.
Definition lib_symbol.h:365
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition lib_symbol.h:832
std::shared_ptr< LIB_SYMBOL > GetRootSymbol() const
Get the parent symbol that does not have another parent.
void SetRefProp(const wxString &aRef)
Definition lib_symbol.h:477
void SetParent(LIB_SYMBOL *aParent=nullptr)
std::vector< UNIT_PIN_INFO > GetUnitPinInfo() const
Return pin-number lists for each unit, ordered consistently for gate swapping.
wxString GetUnitName(int aUnit) const override
For items with units, return an identifier for unit x.
Definition lib_symbol.h:858
wxString GetName() const override
Definition lib_symbol.h:181
void SetUnitCount(int aCount, bool aDuplicateDrawItems)
Set the units per symbol count.
void SetDescription(const wxString &aDescription)
Gets the Description field text value *‍/.
void cacheChooserFields()
std::shared_ptr< LIB_SYMBOL > m_me
wxString GetValueProp() const
Definition lib_symbol.h:482
bool GetExcludedFromBOMProp() const
Definition lib_symbol.h:605
void SetKeyWords(const wxString &aKeyWords)
SCH_FIELD & GetValueField()
Return reference to the value field.
Definition lib_symbol.h:437
bool definesOwnPinMapBundle() const
bool IsLocalPower() const override
LIB_SYMBOL(const wxString &aName, LIB_SYMBOL *aParent=nullptr, LEGACY_SYMBOL_LIB *aLibrary=nullptr)
int GetUnitProp() const
Definition lib_symbol.h:564
wxArrayString GetFPFilters() const
Definition lib_symbol.h:247
void RemoveDrawItem(SCH_ITEM *aItem)
Remove draw aItem from list.
void GetChooserFields(std::map< wxString, wxString > &aColumnMap) override
Retrieves a key/value map of the fields on this item that should be exposed to the library browser/ch...
bool HasLegacyAlternateBodyStyle() const
Before V10 we didn't store the number of body styles in a symbol – we just looked through all its dra...
std::shared_ptr< LIB_SYMBOL > SharedPtr() const
http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared.
Definition lib_symbol.h:128
bool GetPinNamesInsideProp() const
Definition lib_symbol.h:551
void SetHasDeMorganBodyStyles(bool aFlag)
Definition lib_symbol.h:904
const std::vector< wxString > & GetBodyStyleNames() const
void SetBodyStyleProp(const wxString &aBodyStyle) override
Definition lib_symbol.h:589
void SetPinMaps(const PIN_MAP_SET &aPinMaps)
Definition lib_symbol.h:263
timestamp_t m_lastModDate
void SetExcludedFromSimProp(bool aExclude)
Definition lib_symbol.h:600
bool GetExcludedFromBoardProp() const
Definition lib_symbol.h:615
std::optional< const std::set< wxString > > GetJumperPinGroup(const wxString &aPinNumber) const
Retrieves the jumper group containing the specified pin number, if one exists.
wxString getShownDescription(RESOLUTION_CONTEXT aContext, int aDepth) const
LIB_ID m_libId
void SetLocalPower()
std::vector< SCH_PIN * > GetPins() const override
bool HasPinNumber(const wxString &aNumber) const
Return true if aNumber names a pin of this symbol, in any unit or body style.
int GetSubUnitCount() const override
For items with units, return the number of units.
Definition lib_symbol.h:186
void SetBodyStyleCount(int aCount, bool aDuplicateDrawItems, bool aDuplicatePins)
Set the number of body styles for the symbol.
wxString GetLibNickname() const override
Sets the Description field text value.
Definition lib_symbol.h:194
void AutoplaceFields(SCH_SCREEN *aScreen, AUTOPLACE_ALGO aAlgo) override
Automatically orient all the fields in the symbol.
void SetFootprintProp(const wxString &aFootprint)
Definition lib_symbol.h:497
std::vector< LOGICAL_PIN > GetLogicalPins(int aUnit, int aBodyStyle) const
Return all logical pins (expanded) filtered by unit/body.
bool HasDeMorganBodyStyles() const override
const LIB_SYMBOL & operator=(const LIB_SYMBOL &aSymbol)
bool m_unitsLocked
True if symbol has multiple units and changing one unit does not automatically change another unit.
wxArrayString m_fpFilters
List of suitable footprint names for the symbol (wild card names accepted).
void Move(const VECTOR2I &aOffset) override
Move the symbol aOffset.
void SetFPFilters(const wxArrayString &aFilters)
Definition lib_symbol.h:245
const PIN_MAP_SET & GetEffectivePinMaps() const
Definition lib_symbol.h:280
bool IsMultiUnit() const override
Definition lib_symbol.h:890
void CopyFields(std::vector< SCH_FIELD > &aList)
Create a copy of the SCH_FIELDs, sorted in ordinal order.
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode) override
int compare(const SCH_ITEM &aOther, int aCompareFlags=~(COMPARE_FLAGS::UUID|COMPARE_FLAGS::UNIT)) const override
The library symbol specific sort order is as follows:
bool GetExcludedFromSimProp() const
Definition lib_symbol.h:595
const PIN_MAP_SET & GetPinMaps() const
Pin-to-pad mapping (issue #2282).
Definition lib_symbol.h:261
int GetBodyStyleCount() const override
The body styles are a property of the drawings, which a derived symbol inherits from its root symbol ...
void SetDatasheetProp(const wxString &aDatasheet)
Definition lib_symbol.h:508
wxString GetDesc() override
Definition lib_symbol.h:184
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...
const wxString GetRef(const SCH_SHEET_PATH *aSheet, bool aIncludeUnit=false) const override
Definition lib_symbol.h:458
EMBEDDED_FILES * GetEmbeddedFiles() override
void SetPowerSymbolProp(bool aIsPower)
Definition lib_symbol.h:528
void AddField(SCH_FIELD &aField)
Definition lib_symbol.h:417
void SetExcludedFromBOMProp(bool aExclude)
Definition lib_symbol.h:610
int m_unitCount
Number of units (parts) per package.
void SyncFieldsFromParent(const LIB_FIELD_SYNC_OPTIONS &aOptions)
Reconcile this derived symbol's fields with those of its (flattened) parent.
virtual wxString GetClass() const override
Return the class name.
Definition lib_symbol.h:170
wxString GetShownKeyWords(RESOLUTION_CONTEXT aContext, int aDepth=0) const override
bool IsGlobalPower() const override
LIB_ID m_sourceLibId
For database library symbols; the original symbol.
wxString GetBodyStyleDescription(int aBodyStyle, bool aLabel) const override
const wxString & GetParentName() const
Definition lib_symbol.h:985
unsigned GetInheritanceDepth() const
Get the number of parents for this symbol.
int GetUnitCount() const override
bool Deserialize(const kiapi::schematic::types::SchematicSymbol &aInput)
PIN_MAP_SET m_pinMaps
Named pin-to-pad maps owned by this symbol (issue #2282).
wxString GetKeywordsProp() const
Definition lib_symbol.h:513
std::vector< wxString > m_bodyStyleNames
void AppendParentEmbeddedFiles(std::vector< EMBEDDED_FILES * > &aStack) const
std::vector< SCH_PIN * > GetPinsByNumber(const wxString &aNumber, int aUnit=0, int aBodyStyle=0)
Return all pin objects with the requested pin aNumber.
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
BOX2I GetBodyBoundingBox() const override
Return a bounding box for the symbol body but not the pins or fields.
Definition lib_symbol.h:339
void SetValueProp(const wxString &aValue)
Definition lib_symbol.h:487
int GetPinCount() override
BOX2I GetBodyAndPinsBoundingBox() const override
Return a bounding box for the symbol body and pins but not the fields.
Definition lib_symbol.h:344
void SetParentName(const wxString &aParentName)
Definition lib_symbol.h:984
std::map< wxString, wxString > m_chooserFieldsCache
void SetLibId(const LIB_ID &aLibId)
void cacheSearchTerms()
void AddField(SCH_FIELD *aField)
Add a field.
void ClearEditFlags() override
int m_pinCountCache
bool GetLocalPowerSymbolProp() const
Definition lib_symbol.h:536
bool GetDuplicatePinNumbersAreJumpers() const
Definition lib_symbol.h:873
void deleteAllFields()
PIN_MAP_SET & PinMaps()
Definition lib_symbol.h:262
LIB_ID GetLIB_ID() const override
Definition lib_symbol.h:183
std::vector< ASSOCIATED_FOOTPRINT > m_associatedFootprints
Footprints associated with this symbol, each tied to a named pin map.
const SCH_PIN * GetPin(const wxString &aNumber, int aUnit=0, int aBodyStyle=0) const
Return pin object with the requested pin aNumber.
bool m_duplicatePinNumbersAreJumpers
Flag that this symbol should automatically treat sets of two or more pins with the same number as jum...
void SetUnitProp(int aUnits)
Definition lib_symbol.h:569
wxString GetFootprintProp() const
Definition lib_symbol.h:492
std::vector< std::set< wxString > > & JumperPinGroups()
Each jumper pin group is a set of pin numbers that should be treated as internally connected.
Definition lib_symbol.h:880
void SetPinNamesInsideProp(bool aInside)
Definition lib_symbol.h:556
const std::weak_ptr< LIB_SYMBOL > & GetParent() const
Definition lib_symbol.h:151
int Compare(const LIB_SYMBOL &aRhs, int aCompareFlags=~COMPARE_FLAGS::UNIT, REPORTER *aReporter=nullptr) const
Comparison test that can be used for operators.
void AddDrawItem(SCH_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
wxString GetUnitDisplayName(int aUnit, bool aLabel) const override
Return the user-defined display name for aUnit for symbols with units.
wxString m_parentName
The name of the parent symbol or empty if root symbol.
void EmbedFonts() override
void SetLocalPowerSymbolProp(bool aIsLocalPower)
Definition lib_symbol.h:541
virtual void SetName(const wxString &aName)
const std::vector< ASSOCIATED_FOOTPRINT > & GetAssociatedFootprints() const
Definition lib_symbol.h:265
void SetNormal()
void PruneBodyStyleDrawItems(int aBodyStyleCount)
Delete the draw items belonging to a body style beyond aBodyStyleCount.
SCH_FIELD & GetReferenceField()
Return reference to the reference designator field.
Definition lib_symbol.h:441
const LIB_ITEMS_CONTAINER & GetDrawItems() const
Definition lib_symbol.h:833
wxString GetShownDescription(RESOLUTION_CONTEXT aContext, int aDepth=0) const override
void cacheShownDescription()
int GetNextFieldOrdinal() const
Return the next ordinal for a user field for this symbol.
A mix-in to provide polymorphism between items stored in libraries (symbols, aliases and footprints).
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition richio.h:65
Multivector container type.
Definition multivector.h:43
boost::ptr_vector< SCH_ITEM > ITEM_PTR_VECTOR
Definition multivector.h:61
An interface used to output 8 bit text in a convenient way.
Definition richio.h:294
A symbol-owned ordered set of named pin maps.
Definition pin_map.h:124
Base plotter engine class.
Definition plotter.h:136
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:138
void SetText(const wxString &aText) override
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:165
friend class LIB_SYMBOL
Definition sch_item.h:812
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:52
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
bool GetExcludedFromPosFiles(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Definition symbol.h:227
void SetExcludedFromBoard(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear exclude from board netlist flag.
Definition symbol.h:206
SYMBOL(KICAD_T idType)
Definition symbol.h:61
int m_previewBodyStyle
Definition symbol.h:277
int GetPinNameOffset() const
Definition symbol.h:159
virtual void SetExcludedFromSim(bool aExcludeFromSim, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from simulation flag.
Definition symbol.h:176
virtual bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Definition symbol.h:197
void SetPinNameOffset(int aOffset)
Set the offset in mils of the pin name text from the pin symbol.
Definition symbol.h:158
bool GetExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Definition symbol.h:212
void SetExcludedFromPosFiles(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear exclude from position files flag.
Definition symbol.h:221
virtual bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Definition symbol.h:182
int m_previewUnit
Definition symbol.h:276
virtual void SetExcludedFromBOM(bool aExcludeFromBOM, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from schematic bill of materials flag.
Definition symbol.h:191
for transforming drawing coordinates for a wxDC device context.
Definition transform.h:42
RESOLUTION_CONTEXT
Definition common.h:87
@ FOR_GUI
Definition common.h:89
#define DEFAULT_PIN_NAME_OFFSET
The intersheets references prefix string.
RECURSE_MODE
Definition eda_item.h:50
INSPECT_RESULT
Definition eda_item.h:44
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition eda_item.h:91
uint32_t timestamp_t
timestamp_t is our type to represent unique IDs for all kinds of elements; historically simply the ti...
Definition kiid.h:43
LIBRENTRYOPTIONS
Definition lib_symbol.h:61
@ ENTRY_NORMAL
Definition lib_symbol.h:62
@ ENTRY_LOCAL_POWER
Definition lib_symbol.h:64
@ ENTRY_GLOBAL_POWER
Definition lib_symbol.h:63
MULTIVECTOR< SCH_ITEM, SCH_SHAPE_T, SCH_PIN_T > LIB_ITEMS_CONTAINER
Definition lib_symbol.h:55
LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS
Definition lib_symbol.h:56
bool operator<(const LIB_SYMBOL &aItem1, const LIB_SYMBOL &aItem2)
AUTOPLACE_ALGO
Definition sch_item.h:68
Options controlling how a derived symbol's fields are reconciled with its parent.
Definition lib_symbol.h:85
bool m_removeExtraFields
Drop fields not present in the parent.
Definition lib_symbol.h:93
bool m_resetPositions
Copy parent field positions.
Definition lib_symbol.h:102
bool m_resetVisibility
Copy parent visibility and name-shown flags.
Definition lib_symbol.h:96
bool m_updateAllFields
Reconcile every field. When false only the names in m_updateFields are touched.
Definition lib_symbol.h:87
std::set< wxString > m_updateFields
Field names to reconcile when m_updateAllFields is false.
Definition lib_symbol.h:90
bool m_resetEffects
Copy parent text effects (font, justification, etc.) but keep local visibility/position.
Definition lib_symbol.h:99
bool m_resetEmptyText
Copy parent text even when the parent value is empty.
Definition lib_symbol.h:108
bool m_resetText
Copy parent text when the parent value is non-empty.
Definition lib_symbol.h:105
Logical pins: Return expanded logical pins based on stacked-pin notation.
Definition lib_symbol.h:701
wxString number
expanded logical pin number
Definition lib_symbol.h:703
const SCH_PIN * pin
pointer to the base graphical pin
Definition lib_symbol.h:702
std::vector< wxString > m_pinNumbers
Definition lib_symbol.h:715
int m_bodyStyle
The alternate body style of the unit.
Definition lib_symbol.h:74
std::vector< SCH_ITEM * > m_items
The items unique to this unit and alternate body style.
Definition lib_symbol.h:75
int m_unit
The unit number.
Definition lib_symbol.h:73
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
@ DESCRIPTION
Field Description of part, i.e. "1/4W 1% Metal Film Resistor".
@ FOOTPRINT
Field Name Module PCB, i.e. "16DIP300".
@ DATASHEET
name of datasheet
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition typeinfo.h:70
@ LIB_SYMBOL_T
Definition typeinfo.h:144
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683