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 <vector>
33#include <core/multivector.h>
34#include <default_values.h>
35
36class LINE_READER;
37class OUTPUTFORMATTER;
38class REPORTER;
40class LIB_SYMBOL;
42
43namespace KIFONT
44{
45 class OUTLINE_FONT;
46}
47
48
51
52
53/* values for member .m_options */
55{
56 ENTRY_NORMAL, // Libentry is a standard symbol (real or alias)
57 ENTRY_GLOBAL_POWER, // Libentry is a power symbol
58 ENTRY_LOCAL_POWER // Libentry is a local power symbol
59};
60
61
62extern bool operator<( const LIB_SYMBOL& aItem1, const LIB_SYMBOL& aItem2 );
63
64
66{
67 int m_unit;
69 std::vector<SCH_ITEM*> m_items;
70};
71
72
79class LIB_SYMBOL : public SYMBOL, public LIB_TREE_ITEM, public EMBEDDED_FILES
80{
81public:
82 LIB_SYMBOL( const wxString& aName, LIB_SYMBOL* aParent = nullptr, LEGACY_SYMBOL_LIB* aLibrary = nullptr );
83
84 LIB_SYMBOL( const LIB_SYMBOL& aSymbol, LEGACY_SYMBOL_LIB* aLibrary = nullptr, bool aCopyEmbeddedFiles = true );
85
86 virtual ~LIB_SYMBOL() = default;
87
89 std::shared_ptr<LIB_SYMBOL> SharedPtr() const { return m_me; }
90
94 virtual LIB_SYMBOL* Duplicate() const
95 {
96 LIB_SYMBOL* dupe = new LIB_SYMBOL( *this, m_library );
97 const_cast<KIID&>( dupe->m_Uuid ) = KIID();
98
99 for( SCH_ITEM& item : dupe->m_drawings )
100 const_cast<KIID&>( item.m_Uuid ) = KIID();
101
102 return dupe;
103 }
104
108 static LIB_SYMBOL* GetDummy();
109
110 void SetParent( LIB_SYMBOL* aParent = nullptr );
111 std::weak_ptr<LIB_SYMBOL>& GetParent() { return m_parent; }
112 const std::weak_ptr<LIB_SYMBOL>& GetParent() const { return m_parent; }
113
119 unsigned GetInheritanceDepth() const;
120
129 std::shared_ptr<LIB_SYMBOL> GetRootSymbol() const;
130
131 virtual wxString GetClass() const override
132 {
133 return wxT( "LIB_SYMBOL" );
134 }
135
136 static inline bool ClassOf( const EDA_ITEM* aItem )
137 {
138 return aItem && aItem->Type() == LIB_SYMBOL_T;
139 }
140
141 virtual void SetName( const wxString& aName );
142 wxString GetName() const override { return m_name; }
143
144 LIB_ID GetLIB_ID() const override { return m_libId; }
145 wxString GetDesc() override { return GetShownDescription(); }
146 wxString GetFootprint() override;
147 int GetSubUnitCount() const override { return GetUnitCount(); }
148
149 const LIB_ID& GetLibId() const override { return m_libId; }
150 void SetLibId( const LIB_ID& aLibId );
151
153 void SetSourceLibId( const LIB_ID& aLibId ) { m_sourceLibId = aLibId; }
154
155 wxString GetLibNickname() const override { return GetLibraryName(); }
156
158 void SetDescription( const wxString& aDescription );
159
161 wxString GetDescription() const override
162 {
163 if( GetDescriptionField().GetText().IsEmpty() && IsDerived() )
164 {
165 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
166 return parent->GetDescription();
167 }
168
169 return GetDescriptionField().GetText();
170 }
171
172 wxString GetShownDescription( int aDepth = 0 ) const override;
173
174 void SetKeyWords( const wxString& aKeyWords );
175
176 wxString GetKeyWords() const override
177 {
178 if( m_keyWords.IsEmpty() && IsDerived() )
179 {
180 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
181 return parent->GetKeyWords();
182 }
183
184 return m_keyWords;
185 }
186
187 wxString GetShownKeyWords( int aDepth = 0 ) const override;
188
189 std::vector<SEARCH_TERM>& GetSearchTerms() override { return m_searchTermsCache; }
190
191 void GetChooserFields( std::map<wxString , wxString>& aColumnMap ) override;
192
196 bool IsRoot() const override { return m_parent.use_count() == 0; }
197 bool IsDerived() const { return !m_parent.expired() && m_parent.use_count() > 0; }
198
199 const wxString GetLibraryName() const;
200
201 LEGACY_SYMBOL_LIB* GetLib() const { return m_library; }
202 void SetLib( LEGACY_SYMBOL_LIB* aLibrary );
203
205
206 void SetFPFilters( const wxArrayString& aFilters ) { m_fpFilters = aFilters; }
207
208 wxArrayString GetFPFilters() const
209 {
210 if( m_fpFilters.IsEmpty() && IsDerived() )
211 {
212 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
213 return parent->GetFPFilters();
214 }
215
216 return m_fpFilters;
217 }
218
221
222 const PIN_MAP_SET& GetPinMaps() const { return m_pinMaps; }
224 void SetPinMaps( const PIN_MAP_SET& aPinMaps ) { m_pinMaps = aPinMaps; }
225
226 const std::vector<ASSOCIATED_FOOTPRINT>& GetAssociatedFootprints() const { return m_associatedFootprints; }
227
228 void SetAssociatedFootprints( std::vector<ASSOCIATED_FOOTPRINT> aList )
229 {
230 m_associatedFootprints = std::move( aList );
231 }
232
242 {
244 {
245 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
246 return parent->GetEffectivePinMaps();
247 }
248
249 return m_pinMaps;
250 }
251
256 const std::vector<ASSOCIATED_FOOTPRINT>& GetEffectiveAssociatedFootprints() const
257 {
259 {
260 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
261 return parent->GetEffectiveAssociatedFootprints();
262 }
263
265 }
266
279 const BOX2I GetUnitBoundingBox( int aUnit, int aBodyStyle, bool aIgnoreHiddenFields = true,
280 bool aIgnoreLabelsOnInvisiblePins = true ) const;
281
282 const BOX2I GetBoundingBox() const override
283 {
284 return GetUnitBoundingBox( 0, 0 );
285 }
286
297 const BOX2I GetBodyBoundingBox( int aUnit, int aBodyStyle, bool aIncludePins,
298 bool aIncludePrivateItems ) const;
299
300 BOX2I GetBodyBoundingBox() const override
301 {
302 return GetBodyBoundingBox( m_previewUnit, m_previewBodyStyle, false, false );
303 }
304
306 {
308 }
309
310 bool IsGlobalPower() const override;
311 bool IsLocalPower() const override;
312 bool IsPower() const override;
313 bool IsNormal() const override;
314
315 // LIB_TREE_ITEM interface
316 bool IsPowerSymbol() const override { return IsPower(); }
317
318 void SetGlobalPower();
319 void SetLocalPower();
320 void SetNormal();
321
326 void LockUnits( bool aLockUnits ) { m_unitsLocked = aLockUnits; }
327
332 bool UnitsLocked() const { return m_unitsLocked; }
333
339 void SetFields( const std::vector<SCH_FIELD>& aFieldsList );
340
346 void GetFields( std::vector<SCH_FIELD*>& aList, bool aVisibleOnly = false ) const override;
347
351 void CopyFields( std::vector<SCH_FIELD>& aList );
352
356 void AddField( SCH_FIELD* aField );
357
358 void AddField( SCH_FIELD& aField ) { AddField( new SCH_FIELD( aField ) ); }
359
363 int GetNextFieldOrdinal() const;
364
368 SCH_FIELD* GetField( const wxString& aFieldName );
369 const SCH_FIELD* GetField( const wxString& aFieldName ) const;
370
371 SCH_FIELD* FindFieldCaseInsensitive( const wxString& aFieldName );
372 const SCH_FIELD* FindFieldCaseInsensitive( const wxString& aFieldName ) const;
373
374 const SCH_FIELD* GetField( FIELD_T aFieldType ) const;
375 SCH_FIELD* GetField( FIELD_T aFieldType );
376
379 const SCH_FIELD& GetValueField() const;
380
383 const SCH_FIELD& GetReferenceField() const;
384
387 const SCH_FIELD& GetFootprintField() const;
388
391 const SCH_FIELD& GetDatasheetField() const;
392
395 const SCH_FIELD& GetDescriptionField() const;
396
397 wxString GetPrefix();
398
399 const wxString GetRef( const SCH_SHEET_PATH* aSheet, bool aIncludeUnit = false ) const override
400 {
401 return GetReferenceField().GetText();
402 }
403
404 const wxString GetValue( bool aResolve, const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
405 const wxString& aVariantName = wxEmptyString ) const override
406 {
407 return GetValueField().GetText();
408 }
409
410 /*
411 * Field access for property manager
412 */
413 wxString GetRefProp() const
414 {
415 return GetReferenceField().GetText();
416 }
417
418 void SetRefProp( const wxString& aRef )
419 {
420 GetReferenceField().SetText( aRef );
421 }
422
423 wxString GetValueProp() const
424 {
425 return GetValueField().GetText();
426 }
427
428 void SetValueProp( const wxString& aValue )
429 {
430 GetValueField().SetText( aValue );
431 }
432
433 wxString GetFootprintProp() const
434 {
435 return GetFootprintField().GetText();
436 }
437
438 void SetFootprintProp( const wxString& aFootprint )
439 {
440 GetFootprintField().SetText( aFootprint );
441 }
442
443 wxString GetDatasheetProp() const
444 {
445 return GetDatasheetField().GetText();
446 }
447
448 void SetDatasheetProp( const wxString& aDatasheet )
449 {
450 GetDatasheetField().SetText( aDatasheet );
451 }
452
453 wxString GetKeywordsProp() const
454 {
455 return GetKeyWords();
456 }
457
458 void SetKeywordsProp( const wxString& aKeywords )
459 {
460 SetKeyWords( aKeywords );
461 }
462
464 {
465 return IsPower();
466 }
467
468 void SetPowerSymbolProp( bool aIsPower )
469 {
470 if( aIsPower )
472 else
473 SetNormal();
474 }
475
477 {
478 return IsLocalPower();
479 }
480
481 void SetLocalPowerSymbolProp( bool aIsLocalPower )
482 {
483 if( aIsLocalPower )
485 else if( IsPower() )
487 else
488 SetNormal();
489 }
490
492 {
493 return GetPinNameOffset() != 0;
494 }
495
496 void SetPinNamesInsideProp( bool aInside )
497 {
498 if( aInside && GetPinNameOffset() == 0 )
500 else if( !aInside )
501 SetPinNameOffset( 0 );
502 }
503
504 int GetUnitProp() const
505 {
506 return GetUnitCount();
507 }
508
509 void SetUnitProp( int aUnits )
510 {
511 SetUnitCount( aUnits, true );
512 }
513
515 {
516 return !UnitsLocked();
517 }
518
519 void SetUnitsInterchangeableProp( bool aInterchangeable )
520 {
521 LockUnits( !aInterchangeable );
522 }
523
524 wxString GetBodyStyleProp() const override
525 {
526 return GetBodyStyleDescription( 1, false );
527 }
528
529 void SetBodyStyleProp( const wxString& aBodyStyle ) override
530 {
531 // Body style setting is more complex for LIB_SYMBOL
532 // For now, this is primarily for display purposes
533 }
534
536 {
537 return GetExcludedFromSim();
538 }
539
540 void SetExcludedFromSimProp( bool aExclude )
541 {
542 SetExcludedFromSim( aExclude );
543 }
544
546 {
547 return GetExcludedFromBOM();
548 }
549
550 void SetExcludedFromBOMProp( bool aExclude )
551 {
552 SetExcludedFromBOM( aExclude );
553 }
554
556 {
557 return GetExcludedFromBoard();
558 }
559
560 void SetExcludedFromBoardProp( bool aExclude )
561 {
562 SetExcludedFromBoard( aExclude );
563 }
564
566 void SetExcludedFromPosFilesProp( bool aExclude ) { SetExcludedFromPosFiles( aExclude ); }
567
568 std::set<KIFONT::OUTLINE_FONT*> GetFonts() const override;
569
571 const EMBEDDED_FILES* GetEmbeddedFiles() const;
572 void AppendParentEmbeddedFiles( std::vector<EMBEDDED_FILES*>& aStack ) const;
573
574 void EmbedFonts() override;
575
582 void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
583
584 void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction, RECURSE_MODE aMode ) override;
585
591 bool ResolveTextVar( wxString* token, int aDepth = 0 ) const;
592
593 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
594 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
595
599 void PlotFields( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
600 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed );
601
608 void AddDrawItem( SCH_ITEM* aItem, bool aSort = true );
609
615 void RemoveDrawItem( SCH_ITEM* aItem );
616
617 void RemoveField( SCH_FIELD* aField ) { RemoveDrawItem( aField ); }
618
627 std::vector<const SCH_PIN*> GetGraphicalPins( int aUnit = 0, int aBodyStyle = 0 ) const;
628 std::vector<SCH_PIN*> GetGraphicalPins( int aUnit = 0, int aBodyStyle = 0 );
629
635 {
636 const SCH_PIN* pin;
637 wxString number;
638 };
639
644 std::vector<LOGICAL_PIN> GetLogicalPins( int aUnit, int aBodyStyle ) const;
645
647 {
648 wxString m_unitName;
649 std::vector<wxString> m_pinNumbers;
650 };
651
655 std::vector<UNIT_PIN_INFO> GetUnitPinInfo() const;
656
657
658 // Deprecated: use GetGraphicalPins(). This override remains to satisfy SYMBOL's pure virtual.
659 std::vector<SCH_PIN*> GetPins() const override;
660
664 int GetPinCount() override;
665
674 const SCH_PIN* GetPin( const wxString& aNumber, int aUnit = 0, int aBodyStyle = 0 ) const;
675
687 std::vector<SCH_PIN*> GetPinsByNumber( const wxString& aNumber, int aUnit = 0, int aBodyStyle = 0 );
688
700 bool PinsConflictWith( const LIB_SYMBOL& aOtherSymbol, bool aTestNums, bool aTestNames,
701 bool aTestType, bool aTestOrientation, bool aTestLength ) const;
702
708 void Move( const VECTOR2I& aOffset ) override;
709
716 bool HasLegacyAlternateBodyStyle() const;
717
722 int GetMaxPinNumber() const;
723
727 void ClearTempFlags() override;
728 void ClearEditFlags() override;
729
739 SCH_ITEM* LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint );
740
751 SCH_ITEM* LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint,
752 const TRANSFORM& aTransform );
753
760 const LIB_ITEMS_CONTAINER& GetDrawItems() const { return m_drawings; }
761
766 void FixupDrawItems();
767
768 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
769 const std::vector<KICAD_T>& aScanTypes ) override;
770
782 void SetUnitCount( int aCount, bool aDuplicateDrawItems );
783 int GetUnitCount() const override;
784
785 wxString GetUnitName( int aUnit ) const override
786 {
787 return GetUnitDisplayName( aUnit, true );
788 }
789
793 wxString GetUnitDisplayName( int aUnit, bool aLabel ) const override;
794
795 wxString GetBodyStyleDescription( int aBodyStyle, bool aLabel ) const override;
796
797 std::map<int, wxString>& GetUnitDisplayNames() { return m_unitDisplayNames; }
798 const std::map<int, wxString>& GetUnitDisplayNames() const { return m_unitDisplayNames; }
799
802
807 std::vector<std::set<wxString>>& JumperPinGroups() { return m_jumperPinGroups; }
808 const std::vector<std::set<wxString>>& JumperPinGroups() const { return m_jumperPinGroups; }
809
811 std::optional<const std::set<wxString>> GetJumperPinGroup( const wxString& aPinNumber ) const;
812
817 bool IsMultiUnit() const override { return m_unitCount > 1; }
818
819 static wxString LetterSubReference( int aUnit, wxChar aInitialLetter );
820
821 bool IsMultiBodyStyle() const override { return GetBodyStyleCount() > 1; }
822
823 int GetBodyStyleCount() const override
824 {
825 if( m_demorgan )
826 return 2;
827 else
828 return std::max( 1, (int) m_bodyStyleNames.size() );
829 }
830
831 bool HasDeMorganBodyStyles() const override { return m_demorgan; }
832 void SetHasDeMorganBodyStyles( bool aFlag ) { m_demorgan = aFlag; }
833
834 const std::vector<wxString>& GetBodyStyleNames() const { return m_bodyStyleNames; }
835 void SetBodyStyleNames( const std::vector<wxString>& aBodyStyleNames ) { m_bodyStyleNames = aBodyStyleNames; }
836
848 void SetBodyStyleCount( int aCount, bool aDuplicateDrawItems, bool aDuplicatePins );
849
859 int Compare( const LIB_SYMBOL& aRhs, int aCompareFlags = 0, REPORTER* aReporter = nullptr ) const;
860
861 const LIB_SYMBOL& operator=( const LIB_SYMBOL& aSymbol );
862
870 std::unique_ptr< LIB_SYMBOL > Flatten() const;
871
878 std::vector<struct LIB_SYMBOL_UNIT> GetUnitDrawItems();
879
890 std::vector<SCH_ITEM*> GetUnitDrawItems( int aUnit, int aBodyStyle );
891
898 double Similarity( const SCH_ITEM& aSymbol ) const override;
899
901
902 void SetParentName( const wxString& aParentName ) { m_parentName = aParentName; }
903 const wxString& GetParentName() const { return m_parentName; }
904
905#if defined(DEBUG)
906 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
907#endif
908
909private:
910 // We create a different set parent function for this class, so we hide the inherited one.
912
918 int compare( const SCH_ITEM& aOther, int aCompareFlags = SCH_ITEM::COMPARE_FLAGS::EQUALITY ) const override;
919
920 void deleteAllFields();
921
924 bool definesOwnPinMapBundle() const { return !m_pinMaps.IsEmpty() || !m_associatedFootprints.empty(); }
925
926 void cacheSearchTerms();
927 void cachePinCount();
929 void cacheChooserFields();
930
931private:
932 std::shared_ptr<LIB_SYMBOL> m_me;
933 std::weak_ptr<LIB_SYMBOL> m_parent;
934
935 wxString m_parentName;
936
940
944
948
950
952
954 wxString m_name;
955 wxString m_keyWords;
956 wxArrayString m_fpFilters;
958
961
964 std::vector<ASSOCIATED_FOOTPRINT> m_associatedFootprints;
965
968 std::vector<std::set<wxString> > m_jumperPinGroups;
969
973
974 std::map<int, wxString> m_unitDisplayNames;
975 std::vector<wxString> m_bodyStyleNames;
976
977 // Caches for things that are expensive to compute but required every time
978 // the symbol chooser or other library list is created
979
980 std::vector<SEARCH_TERM> m_searchTermsCache;
983 std::map<wxString, wxString> m_chooserFieldsCache;
984};
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:123
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
const KIID m_Uuid
Definition eda_item.h:531
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:89
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:37
bool IsEmpty() const
EMBEDDED_FILES()=default
Class OUTLINE_FONT implements outline font drawing.
Definition kiid.h:44
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:80
std::vector< SEARCH_TERM > & GetSearchTerms() override
Definition lib_symbol.h:189
LIB_ITEMS_CONTAINER m_drawings
Definition lib_symbol.h:951
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:394
wxString GetDescription() const override
Definition lib_symbol.h:161
const LIB_ID & GetLibId() const override
Definition lib_symbol.h:149
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:176
void SetGlobalPower()
std::weak_ptr< LIB_SYMBOL > & GetParent()
Definition lib_symbol.h:111
wxString GetBodyStyleProp() const override
Definition lib_symbol.h:524
virtual ~LIB_SYMBOL()=default
LIBRENTRYOPTIONS m_options
Special symbol features such as POWER or NORMAL.
Definition lib_symbol.h:949
wxString GetRefProp() const
Definition lib_symbol.h:413
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:514
const std::map< int, wxString > & GetUnitDisplayNames() const
Definition lib_symbol.h:798
wxString m_shownDescriptionCache
Definition lib_symbol.h:982
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:153
wxString GetShownKeyWords(int aDepth=0) const override
const std::vector< ASSOCIATED_FOOTPRINT > & GetEffectiveAssociatedFootprints() const
Definition lib_symbol.h:256
bool UnitsLocked() const
Check whether symbol units are interchangeable.
Definition lib_symbol.h:332
SCH_FIELD & GetDatasheetField()
Return reference to the datasheet field.
Definition lib_symbol.h:390
void RefreshLibraryTreeCaches()
std::weak_ptr< LIB_SYMBOL > m_parent
Use for inherited symbols.
Definition lib_symbol.h:933
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
Definition lib_symbol.h:196
void SetExcludedFromBoardProp(bool aExclude)
Definition lib_symbol.h:560
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:617
std::map< int, wxString > m_unitDisplayNames
Definition lib_symbol.h:974
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 (...
Definition lib_symbol.h:968
void ClearTempFlags() override
Clears the status flag all draw objects in this symbol.
void SetKeywordsProp(const wxString &aKeywords)
Definition lib_symbol.h:458
bool IsDerived() const
Definition lib_symbol.h:197
std::map< int, wxString > & GetUnitDisplayNames()
Definition lib_symbol.h:797
void SetDuplicatePinNumbersAreJumpers(bool aEnabled)
Definition lib_symbol.h:801
bool m_demorgan
True if there are two body styles: normal and De Morgan If false, the body style count is taken from ...
Definition lib_symbol.h:945
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:566
timestamp_t GetLastModDate() const
Definition lib_symbol.h:204
LIB_ID GetSourceLibId() const
Definition lib_symbol.h:152
void SetLib(LEGACY_SYMBOL_LIB *aLibrary)
bool GetPowerSymbolProp() const
Definition lib_symbol.h:463
bool IsMultiBodyStyle() const override
Definition lib_symbol.h:821
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:94
std::vector< SEARCH_TERM > m_searchTermsCache
Definition lib_symbol.h:980
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:282
SCH_FIELD * GetField(const wxString &aFieldName)
Find a field within this symbol matching aFieldName; return nullptr if not found.
const wxString GetValue(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText, const wxString &aVariantName=wxEmptyString) const override
Definition lib_symbol.h:404
bool IsPowerSymbol() const override
For symbols that could be a power symbol.
Definition lib_symbol.h:316
SCH_FIELD & GetFootprintField()
Return reference to the footprint field.
Definition lib_symbol.h:386
int Compare(const LIB_SYMBOL &aRhs, int aCompareFlags=0, REPORTER *aReporter=nullptr) const
Comparison test that can be used for operators.
void SetAssociatedFootprints(std::vector< ASSOCIATED_FOOTPRINT > aList)
Definition lib_symbol.h:228
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:835
bool IsNormal() const override
wxString m_name
Definition lib_symbol.h:954
void SetUnitsInterchangeableProp(bool aInterchangeable)
Definition lib_symbol.h:519
std::set< KIFONT::OUTLINE_FONT * > GetFonts() const override
LEGACY_SYMBOL_LIB * m_library
Definition lib_symbol.h:953
static bool ClassOf(const EDA_ITEM *aItem)
Definition lib_symbol.h:136
bool GetExcludedFromPosFilesProp() const
Definition lib_symbol.h:565
SCH_FIELD * FindFieldCaseInsensitive(const wxString &aFieldName)
const std::vector< std::set< wxString > > & JumperPinGroups() const
Definition lib_symbol.h:808
wxString m_keyWords
Search keywords.
Definition lib_symbol.h:955
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:201
wxString GetDatasheetProp() const
Definition lib_symbol.h:443
void LockUnits(bool aLockUnits)
Set interchangeable the property for symbol units.
Definition lib_symbol.h:326
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition lib_symbol.h:759
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:418
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:785
wxString GetName() const override
Definition lib_symbol.h:142
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
Definition lib_symbol.h:932
wxString GetValueProp() const
Definition lib_symbol.h:423
bool GetExcludedFromBOMProp() const
Definition lib_symbol.h:545
void SetKeyWords(const wxString &aKeyWords)
SCH_FIELD & GetValueField()
Return reference to the value field.
Definition lib_symbol.h:378
bool definesOwnPinMapBundle() const
Definition lib_symbol.h:924
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:504
wxArrayString GetFPFilters() const
Definition lib_symbol.h:208
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:89
bool GetPinNamesInsideProp() const
Definition lib_symbol.h:491
void SetHasDeMorganBodyStyles(bool aFlag)
Definition lib_symbol.h:832
const std::vector< wxString > & GetBodyStyleNames() const
Definition lib_symbol.h:834
void SetBodyStyleProp(const wxString &aBodyStyle) override
Definition lib_symbol.h:529
int compare(const SCH_ITEM &aOther, int aCompareFlags=SCH_ITEM::COMPARE_FLAGS::EQUALITY) const override
The library symbol specific sort order is as follows:
void SetPinMaps(const PIN_MAP_SET &aPinMaps)
Definition lib_symbol.h:224
timestamp_t m_lastModDate
Definition lib_symbol.h:939
void SetExcludedFromSimProp(bool aExclude)
Definition lib_symbol.h:540
bool GetExcludedFromBoardProp() const
Definition lib_symbol.h:555
std::optional< const std::set< wxString > > GetJumperPinGroup(const wxString &aPinNumber) const
Retrieves the jumper group containing the specified pin number, if one exists.
LIB_ID m_libId
Definition lib_symbol.h:937
void SetLocalPower()
std::vector< SCH_PIN * > GetPins() const override
int GetSubUnitCount() const override
For items with units, return the number of units.
Definition lib_symbol.h:147
void SetBodyStyleCount(int aCount, bool aDuplicateDrawItems, bool aDuplicatePins)
Set or clear the alternate body style (DeMorgan) for the symbol.
wxString GetLibNickname() const override
Sets the Description field text value.
Definition lib_symbol.h:155
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:438
std::vector< LOGICAL_PIN > GetLogicalPins(int aUnit, int aBodyStyle) const
Return all logical pins (expanded) filtered by unit/body.
bool HasDeMorganBodyStyles() const override
Definition lib_symbol.h:831
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.
Definition lib_symbol.h:942
wxArrayString m_fpFilters
List of suitable footprint names for the symbol (wild card names accepted).
Definition lib_symbol.h:956
void Move(const VECTOR2I &aOffset) override
Move the symbol aOffset.
void SetFPFilters(const wxArrayString &aFilters)
Definition lib_symbol.h:206
const PIN_MAP_SET & GetEffectivePinMaps() const
Definition lib_symbol.h:241
bool IsMultiUnit() const override
Definition lib_symbol.h:817
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
bool GetExcludedFromSimProp() const
Definition lib_symbol.h:535
const PIN_MAP_SET & GetPinMaps() const
Pin-to-pad mapping (issue #2282).
Definition lib_symbol.h:222
int GetBodyStyleCount() const override
Definition lib_symbol.h:823
void SetDatasheetProp(const wxString &aDatasheet)
Definition lib_symbol.h:448
wxString GetDesc() override
Definition lib_symbol.h:145
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:399
EMBEDDED_FILES * GetEmbeddedFiles() override
void SetPowerSymbolProp(bool aIsPower)
Definition lib_symbol.h:468
void AddField(SCH_FIELD &aField)
Definition lib_symbol.h:358
void SetExcludedFromBOMProp(bool aExclude)
Definition lib_symbol.h:550
int m_unitCount
Number of units (parts) per package.
Definition lib_symbol.h:941
wxString GetShownDescription(int aDepth=0) const override
virtual wxString GetClass() const override
Return the class name.
Definition lib_symbol.h:131
bool IsGlobalPower() const override
LIB_ID m_sourceLibId
For database library symbols; the original symbol.
Definition lib_symbol.h:938
wxString GetBodyStyleDescription(int aBodyStyle, bool aLabel) const override
const wxString & GetParentName() const
Definition lib_symbol.h:903
unsigned GetInheritanceDepth() const
Get the number of parents for this symbol.
int GetUnitCount() const override
PIN_MAP_SET m_pinMaps
Named pin-to-pad maps owned by this symbol (issue #2282).
Definition lib_symbol.h:960
wxString GetKeywordsProp() const
Definition lib_symbol.h:453
std::vector< wxString > m_bodyStyleNames
Definition lib_symbol.h:975
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:300
void SetValueProp(const wxString &aValue)
Definition lib_symbol.h:428
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:305
void SetParentName(const wxString &aParentName)
Definition lib_symbol.h:902
std::map< wxString, wxString > m_chooserFieldsCache
Definition lib_symbol.h:983
void SetLibId(const LIB_ID &aLibId)
void cacheSearchTerms()
void AddField(SCH_FIELD *aField)
Add a field.
void ClearEditFlags() override
int m_pinCountCache
Definition lib_symbol.h:981
bool GetLocalPowerSymbolProp() const
Definition lib_symbol.h:476
bool GetDuplicatePinNumbersAreJumpers() const
Definition lib_symbol.h:800
void deleteAllFields()
PIN_MAP_SET & PinMaps()
Definition lib_symbol.h:223
LIB_ID GetLIB_ID() const override
Definition lib_symbol.h:144
std::vector< ASSOCIATED_FOOTPRINT > m_associatedFootprints
Footprints associated with this symbol, each tied to a named pin map.
Definition lib_symbol.h:964
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...
Definition lib_symbol.h:972
void SetUnitProp(int aUnits)
Definition lib_symbol.h:509
wxString GetFootprintProp() const
Definition lib_symbol.h:433
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:807
void SetPinNamesInsideProp(bool aInside)
Definition lib_symbol.h:496
const std::weak_ptr< LIB_SYMBOL > & GetParent() const
Definition lib_symbol.h:112
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.
Definition lib_symbol.h:935
void EmbedFonts() override
void SetLocalPowerSymbolProp(bool aIsLocalPower)
Definition lib_symbol.h:481
virtual void SetName(const wxString &aName)
const std::vector< ASSOCIATED_FOOTPRINT > & GetAssociatedFootprints() const
Definition lib_symbol.h:226
void SetNormal()
SCH_FIELD & GetReferenceField()
Return reference to the reference designator field.
Definition lib_symbol.h:382
const LIB_ITEMS_CONTAINER & GetDrawItems() const
Definition lib_symbol.h:760
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:62
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:291
A symbol-owned ordered set of named pin maps.
Definition pin_map.h:123
Base plotter engine class.
Definition plotter.h:133
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:71
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:128
void SetText(const wxString &aText) override
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:162
friend class LIB_SYMBOL
Definition sch_item.h:797
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
#define DEFAULT_PIN_NAME_OFFSET
The intersheets references prefix string.
RECURSE_MODE
Definition eda_item.h:48
INSPECT_RESULT
Definition eda_item.h:42
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition eda_item.h:89
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:41
LIBRENTRYOPTIONS
Definition lib_symbol.h:55
@ ENTRY_NORMAL
Definition lib_symbol.h:56
@ ENTRY_LOCAL_POWER
Definition lib_symbol.h:58
@ ENTRY_GLOBAL_POWER
Definition lib_symbol.h:57
MULTIVECTOR< SCH_ITEM, SCH_SHAPE_T, SCH_PIN_T > LIB_ITEMS_CONTAINER
Definition lib_symbol.h:49
LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS
Definition lib_symbol.h:50
bool operator<(const LIB_SYMBOL &aItem1, const LIB_SYMBOL &aItem2)
AUTOPLACE_ALGO
Definition sch_item.h:65
Logical pins: Return expanded logical pins based on stacked-pin notation.
Definition lib_symbol.h:635
wxString number
expanded logical pin number
Definition lib_symbol.h:637
const SCH_PIN * pin
pointer to the base graphical pin
Definition lib_symbol.h:636
std::vector< wxString > m_pinNumbers
Definition lib_symbol.h:649
int m_bodyStyle
The alternate body style of the unit.
Definition lib_symbol.h:68
std::vector< SCH_ITEM * > m_items
The items unique to this unit and alternate body style.
Definition lib_symbol.h:69
int m_unit
The unit number.
Definition lib_symbol.h:67
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:71
@ LIB_SYMBOL_T
Definition typeinfo.h:145
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683