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 <set>
26#include <vector>
27
28#include <core/multivector.h>
29
30#include <base_units.h>
31#include <default_values.h>
32#include <embedded_files.h>
33#include <symbol.h>
34#include <sch_field.h>
35#include <sch_pin.h>
36#include <jumper_group.h>
37#include <lib_tree_item.h>
38#include <pin_map.h>
40
41class LINE_READER;
42class OUTPUTFORMATTER;
43class REPORTER;
45class LIB_SYMBOL;
47
49{
50class SchematicSymbol;
51}
52
53namespace KIFONT
54{
55 class OUTLINE_FONT;
56}
57
58
61
62
63extern bool operator<( const LIB_SYMBOL& aItem1, const LIB_SYMBOL& aItem2 );
64
65
67{
68 int m_unit;
70 std::vector<SCH_ITEM*> m_items;
71};
72
73
80{
82 bool m_updateAllFields = true;
83
85 std::set<wxString> m_updateFields;
86
88 bool m_removeExtraFields = false;
89
91 bool m_resetVisibility = false;
92
94 bool m_resetEffects = false;
95
97 bool m_resetPositions = false;
98
100 bool m_resetText = false;
101
103 bool m_resetEmptyText = false;
104};
105
106
113class LIB_SYMBOL : public SYMBOL, public LIB_TREE_ITEM, public EMBEDDED_FILES
114{
115public:
116 LIB_SYMBOL( const wxString& aName, LIB_SYMBOL* aParent = nullptr, LEGACY_SYMBOL_LIB* aLibrary = nullptr );
117
118 LIB_SYMBOL( const LIB_SYMBOL& aSymbol, LEGACY_SYMBOL_LIB* aLibrary = nullptr, bool aCopyEmbeddedFiles = true );
119
120 virtual ~LIB_SYMBOL() = default;
121
123
125 std::shared_ptr<LIB_SYMBOL> SharedPtr() const { return m_me; }
126
130 virtual LIB_SYMBOL* Duplicate() const
131 {
132 LIB_SYMBOL* dupe = new LIB_SYMBOL( *this, m_library );
133 const_cast<KIID&>( dupe->m_Uuid ) = KIID();
134
135 for( SCH_ITEM& item : dupe->m_drawings )
136 const_cast<KIID&>( item.m_Uuid ) = KIID();
137
138 return dupe;
139 }
140
141 EDA_ITEM* Clone() const override
142 {
143 return new LIB_SYMBOL( *this, m_library );
144 }
145
149 static LIB_SYMBOL* GetDummy();
150
151 void SetParent( LIB_SYMBOL* aParent = nullptr );
152 std::weak_ptr<LIB_SYMBOL>& GetParent() { return m_parent; }
153 const std::weak_ptr<LIB_SYMBOL>& GetParent() const { return m_parent; }
154
160 unsigned GetInheritanceDepth() const;
161
170 std::shared_ptr<LIB_SYMBOL> GetRootSymbol() const;
171
172 virtual wxString GetClass() const override
173 {
174 return wxT( "LIB_SYMBOL" );
175 }
176
177 static inline bool ClassOf( const EDA_ITEM* aItem )
178 {
179 return aItem && aItem->Type() == LIB_SYMBOL_T;
180 }
181
182 virtual void SetName( const wxString& aName );
183 wxString GetName() const override { return m_name; }
184
185 LIB_ID GetLIB_ID() const override { return m_libId; }
186 wxString GetDesc() override { return GetShownDescription( FOR_GUI ); }
187 wxString GetFootprint() const override;
188 int GetSubUnitCount() const override { return GetUnitCount(); }
189
190 const LIB_ID& GetLibId() const override { return m_libId; }
191 void SetLibId( const LIB_ID& aLibId );
192
194 void SetSourceLibId( const LIB_ID& aLibId ) { m_sourceLibId = aLibId; }
195
196 wxString GetLibNickname() const override { return GetLibraryName(); }
197
199 void SetDescription( const wxString& aDescription );
200
202 wxString GetDescription() const override
203 {
204 if( GetDescriptionField().GetText().IsEmpty() && IsDerived() )
205 {
206 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
207 return parent->GetDescription();
208 }
209
210 return GetDescriptionField().GetText();
211 }
212
213 wxString GetShownDescription( RESOLUTION_CONTEXT aContext, int aDepth = 0 ) const override;
214
215 void SetKeyWords( const wxString& aKeyWords );
216
218 const wxString& GetRawKeyWords() const { return m_keyWords; }
219
220 wxString GetKeyWords() const override
221 {
222 if( m_keyWords.IsEmpty() && IsDerived() )
223 {
224 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
225 return parent->GetKeyWords();
226 }
227
228 return m_keyWords;
229 }
230
231 wxString GetShownKeyWords( RESOLUTION_CONTEXT aContext, int aDepth = 0 ) const override;
232
233 std::vector<SEARCH_TERM>& GetSearchTerms() override;
234
235 void GetChooserFields( std::map<wxString , wxString>& aColumnMap ) override;
236
240 bool IsRoot() const override { return m_parent.use_count() == 0; }
241 bool IsDerived() const { return !m_parent.expired() && m_parent.use_count() > 0; }
242
243 const wxString GetLibraryName() const;
244
245 LEGACY_SYMBOL_LIB* GetLib() const { return m_library; }
246 void SetLib( LEGACY_SYMBOL_LIB* aLibrary );
247
249
250 void SetFPFilters( const wxArrayString& aFilters ) { m_fpFilters = aFilters; }
251
252 wxArrayString GetFPFilters() const
253 {
254 if( m_fpFilters.IsEmpty() && IsDerived() )
255 {
256 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
257 return parent->GetFPFilters();
258 }
259
260 return m_fpFilters;
261 }
262
265
266 const PIN_MAP_SET& GetPinMaps() const { return m_pinMaps; }
268 void SetPinMaps( const PIN_MAP_SET& aPinMaps ) { m_pinMaps = aPinMaps; }
269
270 const std::vector<ASSOCIATED_FOOTPRINT>& GetAssociatedFootprints() const { return m_associatedFootprints; }
271
272 void SetAssociatedFootprints( std::vector<ASSOCIATED_FOOTPRINT> aList )
273 {
274 m_associatedFootprints = std::move( aList );
275 }
276
286 {
288 {
289 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
290 return parent->GetEffectivePinMaps();
291 }
292
293 return m_pinMaps;
294 }
295
300 const std::vector<ASSOCIATED_FOOTPRINT>& GetEffectiveAssociatedFootprints() const
301 {
303 {
304 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
305 return parent->GetEffectiveAssociatedFootprints();
306 }
307
309 }
310
323 const BOX2I GetUnitBoundingBox( int aUnit, int aBodyStyle, bool aIgnoreHiddenFields = true,
324 bool aIgnoreLabelsOnInvisiblePins = true ) const;
325
326 const BOX2I GetBoundingBox() const override
327 {
328 return GetUnitBoundingBox( 0, 0 );
329 }
330
345 const BOX2I GetBodyBoundingBox( int aUnit, int aBodyStyle, bool aIncludePins,
346 bool aIncludePrivateItems ) const;
347
348 BOX2I GetBodyBoundingBox() const override
349 {
350 return GetBodyBoundingBox( m_previewUnit, m_previewBodyStyle, false, false );
351 }
352
354 {
356 }
357
358 bool IsGlobalPower() const override;
359 bool IsLocalPower() const override;
360 bool IsPower() const override;
361 bool IsNormal() const override;
362
363 // LIB_TREE_ITEM interface
364 bool IsPowerSymbol() const override { return IsPower(); }
365
366 void SetGlobalPower();
367 void SetLocalPower();
368 void SetNormal();
369
374 void LockUnits( bool aLockUnits ) { m_unitsLocked = aLockUnits; }
375
384 bool UnitsLocked() const;
385
391 void SetFields( const std::vector<SCH_FIELD>& aFieldsList );
392
399 void GetFields( std::vector<SCH_FIELD*>& aList, bool aVisibleOnly = false ) const override;
400
404 void CopyFields( std::vector<SCH_FIELD>& aList );
405
413 void SyncFieldsFromParent( const LIB_FIELD_SYNC_OPTIONS& aOptions );
414
420 bool CanUpdateFieldsFromParent() const { return IsDerived(); }
421
425 void AddField( SCH_FIELD* aField );
426
427 void AddField( SCH_FIELD& aField ) { AddField( new SCH_FIELD( aField ) ); }
428
432 int GetNextFieldOrdinal() const;
433
437 SCH_FIELD* GetField( const wxString& aFieldName );
438 const SCH_FIELD* GetField( const wxString& aFieldName ) const;
439
440 SCH_FIELD* FindFieldCaseInsensitive( const wxString& aFieldName );
441 const SCH_FIELD* FindFieldCaseInsensitive( const wxString& aFieldName ) const;
442
443 const SCH_FIELD* GetField( FIELD_T aFieldType ) const;
444 SCH_FIELD* GetField( FIELD_T aFieldType );
445
446 // Return reference to the value field.
448 const SCH_FIELD& GetValueField() const;
449
450 // Return reference to the reference designator field.
452 const SCH_FIELD& GetReferenceField() const;
453
454 // Return reference to the footprint field
456 const SCH_FIELD& GetFootprintField() const;
457
458 // Return reference to the datasheet field.
460 const SCH_FIELD& GetDatasheetField() const;
461
462 // Return reference to the description field.
464 const SCH_FIELD& GetDescriptionField() const;
465
466 wxString GetPrefix();
467
468 const wxString GetRef( const SCH_SHEET_PATH* aSheet, bool aIncludeUnit = false ) const override
469 {
470 return GetReferenceField().GetText();
471 }
472
473 const wxString GetValue( const SCH_SHEET_PATH* aPath, RESOLUTION_CONTEXT aContext,
474 const wxString& aVariantName = wxEmptyString ) const override
475 {
476 return GetValueField().GetText();
477 }
478
479 /*
480 * Field access for property manager
481 */
482 wxString GetRefProp() const
483 {
484 return GetReferenceField().GetText();
485 }
486
487 void SetRefProp( const wxString& aRef )
488 {
489 GetReferenceField().SetText( aRef );
490 m_cachesDirty = true;
491 }
492
493 wxString GetValueProp() const
494 {
495 return GetValueField().GetText();
496 }
497
498 void SetValueProp( const wxString& aValue )
499 {
500 GetValueField().SetText( aValue );
501 m_cachesDirty = true;
502 }
503
504 wxString GetFootprintProp() const
505 {
506 return GetFootprintField().GetText();
507 }
508
509 void SetFootprintProp( const wxString& aFootprint )
510 {
511 GetFootprintField().SetText( aFootprint );
512 m_cachesDirty = true;
513 }
514
515 wxString GetDatasheetProp() const
516 {
517 return GetDatasheetField().GetText();
518 }
519
520 void SetDatasheetProp( const wxString& aDatasheet )
521 {
522 GetDatasheetField().SetText( aDatasheet );
523 m_cachesDirty = true;
524 }
525
526 wxString GetKeywordsProp() const
527 {
528 return GetKeyWords();
529 }
530
531 void SetKeywordsProp( const wxString& aKeywords )
532 {
533 SetKeyWords( aKeywords );
534 m_cachesDirty = true;
535 }
536
538 {
539 return IsPower();
540 }
541
542 void SetPowerSymbolProp( bool aIsPower )
543 {
544 if( aIsPower )
546 else
547 SetNormal();
548 }
549
551 {
552 return IsLocalPower();
553 }
554
555 void SetLocalPowerSymbolProp( bool aIsLocalPower )
556 {
557 if( aIsLocalPower )
559 else if( IsPower() )
561 else
562 SetNormal();
563 }
564
566 {
567 return GetPinNameOffset() != 0;
568 }
569
570 void SetPinNamesInsideProp( bool aInside )
571 {
572 if( aInside && GetPinNameOffset() == 0 )
574 else if( !aInside )
575 SetPinNameOffset( 0 );
576 }
577
578 int GetUnitProp() const
579 {
580 return GetUnitCount();
581 }
582
583 void SetUnitProp( int aUnits )
584 {
585 SetUnitCount( aUnits, true );
586 }
587
589 {
590 return !UnitsLocked();
591 }
592
593 void SetUnitsInterchangeableProp( bool aInterchangeable )
594 {
595 LockUnits( !aInterchangeable );
596 }
597
598 wxString GetBodyStyleProp() const override
599 {
600 return GetBodyStyleDescription( 1, false );
601 }
602
603 void SetBodyStyleProp( const wxString& aBodyStyle ) override
604 {
605 // Body style setting is more complex for LIB_SYMBOL
606 // For now, this is primarily for display purposes
607 }
608
610
611 void SetExcludedFromSimProp( bool aExclude )
612 {
613 SetExcludedFromSim( aExclude );
614 m_cachesDirty = true;
615 }
616
618
619 void SetExcludedFromBOMProp( bool aExclude )
620 {
621 SetExcludedFromBOM( aExclude );
622 m_cachesDirty = true;
623 }
624
626
627 void SetExcludedFromBoardProp( bool aExclude )
628 {
629 SetExcludedFromBoard( aExclude );
630 m_cachesDirty = true;
631 }
632
634
635 void SetExcludedFromPosFilesProp( bool aExclude )
636 {
637 SetExcludedFromPosFiles( aExclude );
638 m_cachesDirty = true;
639 }
640
641 void Serialize( kiapi::schematic::types::SchematicSymbol& aOutput, bool aSkipPins = false ) const;
642 bool Deserialize( const kiapi::schematic::types::SchematicSymbol& aInput );
643
644 void Serialize( google::protobuf::Any& aContainer ) const override;
645 bool Deserialize( const google::protobuf::Any& aContainer ) override;
646
647 std::set<KIFONT::OUTLINE_FONT*> GetFonts() const override;
648
650 const EMBEDDED_FILES* GetEmbeddedFiles() const;
651 void AppendParentEmbeddedFiles( std::vector<EMBEDDED_FILES*>& aStack ) const;
652
653 void EmbedFonts() override;
654
662 void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
663
664 void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction, RECURSE_MODE aMode ) override;
665
672 bool ResolveTextVar( wxString* aToken, int aDepth = 0 ) const;
673
674 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
675 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
676
680 void PlotFields( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
681 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed );
682
689 void AddDrawItem( SCH_ITEM* aItem, bool aSort = true );
690
696 void RemoveDrawItem( SCH_ITEM* aItem );
697
698 void RemoveField( SCH_FIELD* aField ) { RemoveDrawItem( aField ); }
699
708 std::vector<SCH_PIN*> GetGraphicalPins( int aUnit = 0, int aBodyStyle = 0 ) const override;
709
715 {
716 const SCH_PIN* pin;
717 wxString number;
718 };
719
724 std::vector<LOGICAL_PIN> GetLogicalPins( int aUnit, int aBodyStyle ) const;
725
727 {
728 wxString m_unitName;
729 std::vector<wxString> m_pinNumbers;
730 };
731
735 std::vector<UNIT_PIN_INFO> GetUnitPinInfo() const;
736
737
741 int GetPinCount() const override;
742
751 const SCH_PIN* GetPin( const wxString& aNumber, int aUnit = 0, int aBodyStyle = 0 ) const;
752
764 std::vector<SCH_PIN*> GetPinsByNumber( const wxString& aNumber, int aUnit = 0, int aBodyStyle = 0 );
765
771 bool HasPinNumber( const wxString& aNumber ) const;
772
784 bool PinsConflictWith( const LIB_SYMBOL& aOtherSymbol, bool aTestNums, bool aTestNames,
785 bool aTestType, bool aTestOrientation, bool aTestLength ) const;
786
792 void Move( const VECTOR2I& aOffset ) override;
793
800 bool HasLegacyAlternateBodyStyle() const;
801
806 int GetMaxPinNumber() const;
807
811 void ClearTempFlags() override;
812 void ClearEditFlags() override;
813
823 SCH_ITEM* LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint );
824
835 SCH_ITEM* LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint,
836 const TRANSFORM& aTransform );
837
844 const LIB_ITEMS_CONTAINER& GetDrawItems() const { return m_drawings; }
845
850 void FixupDrawItems();
851
852 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
853 const std::vector<KICAD_T>& aScanTypes ) override;
854
866 void SetUnitCount( int aCount, bool aDuplicateDrawItems );
867 int GetUnitCount() const override;
868
869 wxString GetUnitName( int aUnit ) const override
870 {
871 return GetUnitDisplayName( aUnit, true );
872 }
873
877 wxString GetUnitDisplayName( int aUnit, bool aLabel ) const override;
878
879 wxString GetBodyStyleDescription( int aBodyStyle, bool aLabel ) const override;
880
881 std::map<int, wxString>& GetUnitDisplayNames() { return m_unitDisplayNames; }
882 const std::map<int, wxString>& GetUnitDisplayNames() const { return m_unitDisplayNames; }
883
886
893
898 bool IsMultiUnit() const override { return GetUnitCount() > 1; }
899
900 static wxString LetterSubReference( int aUnit, wxChar aInitialLetter );
901
902 bool IsMultiBodyStyle() const override { return GetBodyStyleCount() > 1; }
903
908 int GetBodyStyleCount() const override;
909 bool HasDeMorganBodyStyles() const override;
910 const std::vector<wxString>& GetBodyStyleNames() const;
911
912 void SetHasDeMorganBodyStyles( bool aFlag ) { m_demorgan = aFlag; }
913 void SetBodyStyleNames( const std::vector<wxString>& aBodyStyleNames ) { m_bodyStyleNames = aBodyStyleNames; }
914
926 void SetBodyStyleCount( int aCount, bool aDuplicateDrawItems, bool aDuplicatePins );
927
933 void PruneBodyStyleDrawItems( int aBodyStyleCount );
934
946 int Compare( const LIB_SYMBOL& aRhs, int aCompareFlags = ~COMPARE_FLAGS::UNIT,
947 REPORTER* aReporter = nullptr ) const;
948
949 const LIB_SYMBOL& operator=( const LIB_SYMBOL& aSymbol );
950
958 std::unique_ptr< LIB_SYMBOL > Flatten() const;
959
970 std::vector<struct LIB_SYMBOL_UNIT> GetUnitDrawItems();
971
982 std::vector<SCH_ITEM*> GetUnitDrawItems( int aUnit, int aBodyStyle );
983
990 double Similarity( const SCH_ITEM& aSymbol ) const override;
991
993
994 void SetParentName( const wxString& aParentName ) { m_parentName = aParentName; }
995 const wxString& GetParentName() const { return m_parentName; }
996
997#if defined(DEBUG)
998 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
999#endif
1000
1001protected:
1015 int compare( const SCH_ITEM& aOther,
1016 int aCompareFlags = ~( COMPARE_FLAGS::UUID | COMPARE_FLAGS::UNIT ) ) const override;
1017
1018private:
1019 // We create a different set parent function for this class, so we hide the inherited one.
1020 using EDA_ITEM::SetParent;
1021
1022 void deleteAllUserFields();
1023
1024 wxString getShownDescription( RESOLUTION_CONTEXT aContext, int aDepth ) const;
1025
1028 bool definesOwnPinMapBundle() const { return !m_pinMaps.IsEmpty() || !m_associatedFootprints.empty(); }
1029
1030 void rebuildCaches() const;
1031
1032private:
1033 std::shared_ptr<LIB_SYMBOL> m_me;
1034 std::weak_ptr<LIB_SYMBOL> m_parent;
1035
1036 wxString m_parentName;
1037
1041
1045
1049
1051
1053
1055 wxString m_name;
1056 wxString m_keyWords;
1057 wxArrayString m_fpFilters;
1059
1062
1065 std::vector<ASSOCIATED_FOOTPRINT> m_associatedFootprints;
1066
1070
1074
1075 std::map<int, wxString> m_unitDisplayNames;
1076 std::vector<wxString> m_bodyStyleNames;
1077
1078 // Caches for things that are expensive to compute but required every time the symbol chooser or
1079 // other library list is created
1080 mutable bool m_cachesDirty;
1081 mutable std::vector<SEARCH_TERM> m_searchTermsCache;
1082 mutable int m_pinCountCache;
1083 mutable wxString m_shownDescriptionCache;
1084 mutable std::map<wxString, wxString> m_chooserFieldsCache;
1085};
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:130
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
const KIID m_Uuid
Definition eda_item.h:599
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
Represents an (ordered) list of JUMPER_GROUP objects.
Implement 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:114
std::vector< SEARCH_TERM > & GetSearchTerms() override
LIB_ITEMS_CONTAINER m_drawings
const wxString & GetRawKeyWords() const
Return only this symbol's keywords, without inheriting from its parent.
Definition lib_symbol.h:218
SCH_FIELD & GetDescriptionField()
Definition lib_symbol.h:463
wxString GetDescription() const override
Get the Description field text value *‍/.
Definition lib_symbol.h:202
const LIB_ID & GetLibId() const override
Definition lib_symbol.h:190
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:220
void SetGlobalPower()
std::weak_ptr< LIB_SYMBOL > & GetParent()
Definition lib_symbol.h:152
wxString GetBodyStyleProp() const override
Definition lib_symbol.h:598
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:473
LIBRENTRYOPTIONS m_options
Special symbol features such as POWER or NORMAL.
void rebuildCaches() const
int GetPinCount() const override
wxString GetRefProp() const
Definition lib_symbol.h:482
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:588
const std::map< int, wxString > & GetUnitDisplayNames() const
Definition lib_symbol.h:882
wxString m_shownDescriptionCache
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()
bool m_cachesDirty
void SetSourceLibId(const LIB_ID &aLibId)
Definition lib_symbol.h:194
const std::vector< ASSOCIATED_FOOTPRINT > & GetEffectiveAssociatedFootprints() const
Definition lib_symbol.h:300
bool UnitsLocked() const
Check whether symbol units are interchangeable.
SCH_FIELD & GetDatasheetField()
Definition lib_symbol.h:459
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:240
void SetExcludedFromBoardProp(bool aExclude)
Definition lib_symbol.h:627
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:698
std::map< int, wxString > m_unitDisplayNames
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:531
bool IsDerived() const
Definition lib_symbol.h:241
std::map< int, wxString > & GetUnitDisplayNames()
Definition lib_symbol.h:881
void SetDuplicatePinNumbersAreJumpers(bool aEnabled)
Definition lib_symbol.h:885
bool m_demorgan
True if there are two body styles: normal and De Morgan If false, the body style count is taken from ...
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:635
timestamp_t GetLastModDate() const
Definition lib_symbol.h:248
LIB_ID GetSourceLibId() const
Definition lib_symbol.h:193
void SetLib(LEGACY_SYMBOL_LIB *aLibrary)
bool GetPowerSymbolProp() const
Definition lib_symbol.h:537
bool IsMultiBodyStyle() const override
Definition lib_symbol.h:902
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:130
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition lib_symbol.h:141
bool CanUpdateFieldsFromParent() const
Definition lib_symbol.h:420
std::vector< SEARCH_TERM > m_searchTermsCache
JUMPER_GROUP_SET & JumperPinGroups()
Each jumper pin group is a set of pin numbers that should be treated as internally connected.
Definition lib_symbol.h:891
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:326
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:364
SCH_FIELD & GetFootprintField()
Definition lib_symbol.h:455
void SetAssociatedFootprints(std::vector< ASSOCIATED_FOOTPRINT > aList)
Definition lib_symbol.h:272
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:913
bool IsNormal() const override
wxString m_name
void SetUnitsInterchangeableProp(bool aInterchangeable)
Definition lib_symbol.h:593
std::set< KIFONT::OUTLINE_FONT * > GetFonts() const override
LEGACY_SYMBOL_LIB * m_library
static bool ClassOf(const EDA_ITEM *aItem)
Definition lib_symbol.h:177
bool GetExcludedFromPosFilesProp() const
Definition lib_symbol.h:633
SCH_FIELD * FindFieldCaseInsensitive(const wxString &aFieldName)
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()
Return 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:245
wxString GetDatasheetProp() const
Definition lib_symbol.h:515
void LockUnits(bool aLockUnits)
Set interchangeable the property for symbol units.
Definition lib_symbol.h:374
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition lib_symbol.h:843
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:487
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:869
wxString GetName() const override
Definition lib_symbol.h:183
void SetUnitCount(int aCount, bool aDuplicateDrawItems)
Set the units per symbol count.
void SetDescription(const wxString &aDescription)
Set the Description field text value.
std::shared_ptr< LIB_SYMBOL > m_me
wxString GetValueProp() const
Definition lib_symbol.h:493
bool GetExcludedFromBOMProp() const
Definition lib_symbol.h:617
void SetKeyWords(const wxString &aKeyWords)
SCH_FIELD & GetValueField()
Definition lib_symbol.h:447
void deleteAllUserFields()
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:578
wxArrayString GetFPFilters() const
Definition lib_symbol.h:252
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:125
bool GetPinNamesInsideProp() const
Definition lib_symbol.h:565
void SetHasDeMorganBodyStyles(bool aFlag)
Definition lib_symbol.h:912
const std::vector< wxString > & GetBodyStyleNames() const
bool ResolveTextVar(wxString *aToken, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
void SetBodyStyleProp(const wxString &aBodyStyle) override
Definition lib_symbol.h:603
void SetPinMaps(const PIN_MAP_SET &aPinMaps)
Definition lib_symbol.h:268
timestamp_t m_lastModDate
void SetExcludedFromSimProp(bool aExclude)
Definition lib_symbol.h:611
bool GetExcludedFromBoardProp() const
Definition lib_symbol.h:625
wxString getShownDescription(RESOLUTION_CONTEXT aContext, int aDepth) const
LIB_ID m_libId
void SetLocalPower()
JUMPER_GROUP_SET m_jumperPinGroups
A list of jumper pin groups, each of which is a set of pin numbers that should be jumpered together (...
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:188
void SetBodyStyleCount(int aCount, bool aDuplicateDrawItems, bool aDuplicatePins)
Set the number of body styles for the symbol.
wxString GetLibNickname() const override
Definition lib_symbol.h:196
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:509
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:250
const PIN_MAP_SET & GetEffectivePinMaps() const
Definition lib_symbol.h:285
bool IsMultiUnit() const override
Definition lib_symbol.h:898
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:609
const PIN_MAP_SET & GetPinMaps() const
Pin-to-pad mapping (issue #2282).
Definition lib_symbol.h:266
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:520
wxString GetDesc() override
Definition lib_symbol.h:186
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:468
wxString GetFootprint() const override
For items with footprint fields.
EMBEDDED_FILES * GetEmbeddedFiles() override
void SetPowerSymbolProp(bool aIsPower)
Definition lib_symbol.h:542
LIB_SYMBOL_ATTRIBUTES ComparisonAttributes() const
void AddField(SCH_FIELD &aField)
Definition lib_symbol.h:427
void SetExcludedFromBOMProp(bool aExclude)
Definition lib_symbol.h:619
const JUMPER_GROUP_SET & JumperPinGroups() const
Definition lib_symbol.h:892
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:172
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:995
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:526
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:348
void SetValueProp(const wxString &aValue)
Definition lib_symbol.h:498
BOX2I GetBodyAndPinsBoundingBox() const override
Return a bounding box for the symbol body and pins but not the fields.
Definition lib_symbol.h:353
void SetParentName(const wxString &aParentName)
Definition lib_symbol.h:994
std::map< wxString, wxString > m_chooserFieldsCache
void SetLibId(const LIB_ID &aLibId)
void AddField(SCH_FIELD *aField)
Add a field.
void ClearEditFlags() override
int m_pinCountCache
bool GetLocalPowerSymbolProp() const
Definition lib_symbol.h:550
bool GetDuplicatePinNumbersAreJumpers() const
Definition lib_symbol.h:884
std::vector< SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const override
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
PIN_MAP_SET & PinMaps()
Definition lib_symbol.h:267
LIB_ID GetLIB_ID() const override
Definition lib_symbol.h:185
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:583
wxString GetFootprintProp() const
Definition lib_symbol.h:504
void SetPinNamesInsideProp(bool aInside)
Definition lib_symbol.h:570
const std::weak_ptr< LIB_SYMBOL > & GetParent() const
Definition lib_symbol.h:153
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:555
virtual void SetName(const wxString &aName)
const std::vector< ASSOCIATED_FOOTPRINT > & GetAssociatedFootprints() const
Definition lib_symbol.h:270
void SetNormal()
void PruneBodyStyleDrawItems(int aBodyStyleCount)
Delete the draw items belonging to a body style beyond aBodyStyleCount.
SCH_FIELD & GetReferenceField()
Definition lib_symbol.h:451
const LIB_ITEMS_CONTAINER & GetDrawItems() const
Definition lib_symbol.h:844
wxString GetShownDescription(RESOLUTION_CONTEXT aContext, int aDepth=0) const override
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:139
void SetText(const wxString &aText) override
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:170
friend class LIB_SYMBOL
Definition sch_item.h:817
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:65
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:231
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:210
SYMBOL(KICAD_T idType)
Definition symbol.h:62
int m_previewBodyStyle
Definition symbol.h:281
int GetPinNameOffset() const
Definition symbol.h:163
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:180
virtual bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Definition symbol.h:201
void SetPinNameOffset(int aOffset)
Set the offset in mils of the pin name text from the pin symbol.
Definition symbol.h:162
bool GetExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Definition symbol.h:216
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:225
virtual bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Definition symbol.h:186
int m_previewUnit
Definition symbol.h:280
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:195
for transforming drawing coordinates for a wxDC device context.
Definition transform.h:42
RESOLUTION_CONTEXT
Definition common.h:89
@ FOR_GUI
Definition common.h:91
#define DEFAULT_PIN_NAME_OFFSET
The offset of the pin name string from the end of the pin in mils.
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
MULTIVECTOR< SCH_ITEM, SCH_SHAPE_T, SCH_PIN_T > LIB_ITEMS_CONTAINER
Definition lib_symbol.h:59
LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS
Definition lib_symbol.h:60
bool operator<(const LIB_SYMBOL &aItem1, const LIB_SYMBOL &aItem2)
AUTOPLACE_ALGO
Definition sch_item.h:73
Options controlling how a derived symbol's fields are reconciled with its parent.
Definition lib_symbol.h:80
bool m_removeExtraFields
Drop fields not present in the parent.
Definition lib_symbol.h:88
bool m_resetPositions
Copy parent field positions.
Definition lib_symbol.h:97
bool m_resetVisibility
Copy parent visibility and name-shown flags.
Definition lib_symbol.h:91
bool m_updateAllFields
Reconcile every field. When false only the names in m_updateFields are touched.
Definition lib_symbol.h:82
std::set< wxString > m_updateFields
Field names to reconcile when m_updateAllFields is false.
Definition lib_symbol.h:85
bool m_resetEffects
Copy parent text effects (font, justification, etc.) but keep local visibility/position.
Definition lib_symbol.h:94
bool m_resetEmptyText
Copy parent text even when the parent value is empty.
Definition lib_symbol.h:103
bool m_resetText
Copy parent text when the parent value is non-empty.
Definition lib_symbol.h:100
Logical pins: Return expanded logical pins based on stacked-pin notation.
Definition lib_symbol.h:715
wxString number
expanded logical pin number
Definition lib_symbol.h:717
const SCH_PIN * pin
pointer to the base graphical pin
Definition lib_symbol.h:716
std::vector< wxString > m_pinNumbers
Definition lib_symbol.h:729
int m_bodyStyle
The alternate body style of the unit.
Definition lib_symbol.h:69
std::vector< SCH_ITEM * > m_items
The items unique to this unit and alternate body style.
Definition lib_symbol.h:70
int m_unit
The unit number.
Definition lib_symbol.h:68
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:708