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
44namespace KIFONT
45{
46 class OUTLINE_FONT;
47}
48
49
52
53
54/* values for member .m_options */
56{
57 ENTRY_NORMAL, // Libentry is a standard symbol (real or alias)
58 ENTRY_GLOBAL_POWER, // Libentry is a power symbol
59 ENTRY_LOCAL_POWER // Libentry is a local power symbol
60};
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 std::shared_ptr<LIB_SYMBOL> SharedPtr() const { return m_me; }
124
128 virtual LIB_SYMBOL* Duplicate() const
129 {
130 LIB_SYMBOL* dupe = new LIB_SYMBOL( *this, m_library );
131 const_cast<KIID&>( dupe->m_Uuid ) = KIID();
132
133 for( SCH_ITEM& item : dupe->m_drawings )
134 const_cast<KIID&>( item.m_Uuid ) = KIID();
135
136 return dupe;
137 }
138
142 static LIB_SYMBOL* GetDummy();
143
144 void SetParent( LIB_SYMBOL* aParent = nullptr );
145 std::weak_ptr<LIB_SYMBOL>& GetParent() { return m_parent; }
146 const std::weak_ptr<LIB_SYMBOL>& GetParent() const { return m_parent; }
147
153 unsigned GetInheritanceDepth() const;
154
163 std::shared_ptr<LIB_SYMBOL> GetRootSymbol() const;
164
165 virtual wxString GetClass() const override
166 {
167 return wxT( "LIB_SYMBOL" );
168 }
169
170 static inline bool ClassOf( const EDA_ITEM* aItem )
171 {
172 return aItem && aItem->Type() == LIB_SYMBOL_T;
173 }
174
175 virtual void SetName( const wxString& aName );
176 wxString GetName() const override { return m_name; }
177
178 LIB_ID GetLIB_ID() const override { return m_libId; }
179 wxString GetDesc() override { return GetShownDescription(); }
180 wxString GetFootprint() override;
181 int GetSubUnitCount() const override { return GetUnitCount(); }
182
183 const LIB_ID& GetLibId() const override { return m_libId; }
184 void SetLibId( const LIB_ID& aLibId );
185
187 void SetSourceLibId( const LIB_ID& aLibId ) { m_sourceLibId = aLibId; }
188
189 wxString GetLibNickname() const override { return GetLibraryName(); }
190
192 void SetDescription( const wxString& aDescription );
193
195 wxString GetDescription() const override
196 {
197 if( GetDescriptionField().GetText().IsEmpty() && IsDerived() )
198 {
199 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
200 return parent->GetDescription();
201 }
202
203 return GetDescriptionField().GetText();
204 }
205
206 wxString GetShownDescription( int aDepth = 0 ) const override;
207
208 void SetKeyWords( const wxString& aKeyWords );
209
210 wxString GetKeyWords() const override
211 {
212 if( m_keyWords.IsEmpty() && IsDerived() )
213 {
214 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
215 return parent->GetKeyWords();
216 }
217
218 return m_keyWords;
219 }
220
221 wxString GetShownKeyWords( int aDepth = 0 ) const override;
222
223 std::vector<SEARCH_TERM>& GetSearchTerms() override { return m_searchTermsCache; }
224
225 void GetChooserFields( std::map<wxString , wxString>& aColumnMap ) override;
226
230 bool IsRoot() const override { return m_parent.use_count() == 0; }
231 bool IsDerived() const { return !m_parent.expired() && m_parent.use_count() > 0; }
232
233 const wxString GetLibraryName() const;
234
235 LEGACY_SYMBOL_LIB* GetLib() const { return m_library; }
236 void SetLib( LEGACY_SYMBOL_LIB* aLibrary );
237
239
240 void SetFPFilters( const wxArrayString& aFilters ) { m_fpFilters = aFilters; }
241
242 wxArrayString GetFPFilters() const
243 {
244 if( m_fpFilters.IsEmpty() && IsDerived() )
245 {
246 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
247 return parent->GetFPFilters();
248 }
249
250 return m_fpFilters;
251 }
252
255
256 const PIN_MAP_SET& GetPinMaps() const { return m_pinMaps; }
258 void SetPinMaps( const PIN_MAP_SET& aPinMaps ) { m_pinMaps = aPinMaps; }
259
260 const std::vector<ASSOCIATED_FOOTPRINT>& GetAssociatedFootprints() const { return m_associatedFootprints; }
261
262 void SetAssociatedFootprints( std::vector<ASSOCIATED_FOOTPRINT> aList )
263 {
264 m_associatedFootprints = std::move( aList );
265 }
266
276 {
278 {
279 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
280 return parent->GetEffectivePinMaps();
281 }
282
283 return m_pinMaps;
284 }
285
290 const std::vector<ASSOCIATED_FOOTPRINT>& GetEffectiveAssociatedFootprints() const
291 {
293 {
294 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
295 return parent->GetEffectiveAssociatedFootprints();
296 }
297
299 }
300
313 const BOX2I GetUnitBoundingBox( int aUnit, int aBodyStyle, bool aIgnoreHiddenFields = true,
314 bool aIgnoreLabelsOnInvisiblePins = true ) const;
315
316 const BOX2I GetBoundingBox() const override
317 {
318 return GetUnitBoundingBox( 0, 0 );
319 }
320
331 const BOX2I GetBodyBoundingBox( int aUnit, int aBodyStyle, bool aIncludePins,
332 bool aIncludePrivateItems ) const;
333
334 BOX2I GetBodyBoundingBox() const override
335 {
336 return GetBodyBoundingBox( m_previewUnit, m_previewBodyStyle, false, false );
337 }
338
340 {
342 }
343
344 bool IsGlobalPower() const override;
345 bool IsLocalPower() const override;
346 bool IsPower() const override;
347 bool IsNormal() const override;
348
349 // LIB_TREE_ITEM interface
350 bool IsPowerSymbol() const override { return IsPower(); }
351
352 void SetGlobalPower();
353 void SetLocalPower();
354 void SetNormal();
355
360 void LockUnits( bool aLockUnits ) { m_unitsLocked = aLockUnits; }
361
366 bool UnitsLocked() const { return m_unitsLocked; }
367
373 void SetFields( const std::vector<SCH_FIELD>& aFieldsList );
374
380 void GetFields( std::vector<SCH_FIELD*>& aList, bool aVisibleOnly = false ) const override;
381
385 void CopyFields( std::vector<SCH_FIELD>& aList );
386
394 void SyncFieldsFromParent( const LIB_FIELD_SYNC_OPTIONS& aOptions );
395
401 bool CanUpdateFieldsFromParent() const { return IsDerived(); }
402
406 void AddField( SCH_FIELD* aField );
407
408 void AddField( SCH_FIELD& aField ) { AddField( new SCH_FIELD( aField ) ); }
409
413 int GetNextFieldOrdinal() const;
414
418 SCH_FIELD* GetField( const wxString& aFieldName );
419 const SCH_FIELD* GetField( const wxString& aFieldName ) const;
420
421 SCH_FIELD* FindFieldCaseInsensitive( const wxString& aFieldName );
422 const SCH_FIELD* FindFieldCaseInsensitive( const wxString& aFieldName ) const;
423
424 const SCH_FIELD* GetField( FIELD_T aFieldType ) const;
425 SCH_FIELD* GetField( FIELD_T aFieldType );
426
429 const SCH_FIELD& GetValueField() const;
430
433 const SCH_FIELD& GetReferenceField() const;
434
437 const SCH_FIELD& GetFootprintField() const;
438
441 const SCH_FIELD& GetDatasheetField() const;
442
445 const SCH_FIELD& GetDescriptionField() const;
446
447 wxString GetPrefix();
448
449 const wxString GetRef( const SCH_SHEET_PATH* aSheet, bool aIncludeUnit = false ) const override
450 {
451 return GetReferenceField().GetText();
452 }
453
454 const wxString GetValue( bool aResolve, const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
455 const wxString& aVariantName = wxEmptyString ) const override
456 {
457 return GetValueField().GetText();
458 }
459
460 /*
461 * Field access for property manager
462 */
463 wxString GetRefProp() const
464 {
465 return GetReferenceField().GetText();
466 }
467
468 void SetRefProp( const wxString& aRef )
469 {
470 GetReferenceField().SetText( aRef );
471 }
472
473 wxString GetValueProp() const
474 {
475 return GetValueField().GetText();
476 }
477
478 void SetValueProp( const wxString& aValue )
479 {
480 GetValueField().SetText( aValue );
481 }
482
483 wxString GetFootprintProp() const
484 {
485 return GetFootprintField().GetText();
486 }
487
488 void SetFootprintProp( const wxString& aFootprint )
489 {
490 GetFootprintField().SetText( aFootprint );
491 }
492
493 wxString GetDatasheetProp() const
494 {
495 return GetDatasheetField().GetText();
496 }
497
498 void SetDatasheetProp( const wxString& aDatasheet )
499 {
500 GetDatasheetField().SetText( aDatasheet );
501 }
502
503 wxString GetKeywordsProp() const
504 {
505 return GetKeyWords();
506 }
507
508 void SetKeywordsProp( const wxString& aKeywords )
509 {
510 SetKeyWords( aKeywords );
511 }
512
514 {
515 return IsPower();
516 }
517
518 void SetPowerSymbolProp( bool aIsPower )
519 {
520 if( aIsPower )
522 else
523 SetNormal();
524 }
525
527 {
528 return IsLocalPower();
529 }
530
531 void SetLocalPowerSymbolProp( bool aIsLocalPower )
532 {
533 if( aIsLocalPower )
535 else if( IsPower() )
537 else
538 SetNormal();
539 }
540
542 {
543 return GetPinNameOffset() != 0;
544 }
545
546 void SetPinNamesInsideProp( bool aInside )
547 {
548 if( aInside && GetPinNameOffset() == 0 )
550 else if( !aInside )
551 SetPinNameOffset( 0 );
552 }
553
554 int GetUnitProp() const
555 {
556 return GetUnitCount();
557 }
558
559 void SetUnitProp( int aUnits )
560 {
561 SetUnitCount( aUnits, true );
562 }
563
565 {
566 return !UnitsLocked();
567 }
568
569 void SetUnitsInterchangeableProp( bool aInterchangeable )
570 {
571 LockUnits( !aInterchangeable );
572 }
573
574 wxString GetBodyStyleProp() const override
575 {
576 return GetBodyStyleDescription( 1, false );
577 }
578
579 void SetBodyStyleProp( const wxString& aBodyStyle ) override
580 {
581 // Body style setting is more complex for LIB_SYMBOL
582 // For now, this is primarily for display purposes
583 }
584
586 {
587 return GetExcludedFromSim();
588 }
589
590 void SetExcludedFromSimProp( bool aExclude )
591 {
592 SetExcludedFromSim( aExclude );
593 }
594
596 {
597 return GetExcludedFromBOM();
598 }
599
600 void SetExcludedFromBOMProp( bool aExclude )
601 {
602 SetExcludedFromBOM( aExclude );
603 }
604
606 {
607 return GetExcludedFromBoard();
608 }
609
610 void SetExcludedFromBoardProp( bool aExclude )
611 {
612 SetExcludedFromBoard( aExclude );
613 }
614
616 void SetExcludedFromPosFilesProp( bool aExclude ) { SetExcludedFromPosFiles( aExclude ); }
617
618 std::set<KIFONT::OUTLINE_FONT*> GetFonts() const override;
619
621 const EMBEDDED_FILES* GetEmbeddedFiles() const;
622 void AppendParentEmbeddedFiles( std::vector<EMBEDDED_FILES*>& aStack ) const;
623
624 void EmbedFonts() override;
625
632 void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
633
634 void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction, RECURSE_MODE aMode ) override;
635
641 bool ResolveTextVar( wxString* token, int aDepth = 0 ) const;
642
643 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
644 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
645
649 void PlotFields( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
650 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed );
651
658 void AddDrawItem( SCH_ITEM* aItem, bool aSort = true );
659
665 void RemoveDrawItem( SCH_ITEM* aItem );
666
667 void RemoveField( SCH_FIELD* aField ) { RemoveDrawItem( aField ); }
668
677 std::vector<const SCH_PIN*> GetGraphicalPins( int aUnit = 0, int aBodyStyle = 0 ) const;
678 std::vector<SCH_PIN*> GetGraphicalPins( int aUnit = 0, int aBodyStyle = 0 );
679
685 {
686 const SCH_PIN* pin;
687 wxString number;
688 };
689
694 std::vector<LOGICAL_PIN> GetLogicalPins( int aUnit, int aBodyStyle ) const;
695
697 {
698 wxString m_unitName;
699 std::vector<wxString> m_pinNumbers;
700 };
701
705 std::vector<UNIT_PIN_INFO> GetUnitPinInfo() const;
706
707
708 // Deprecated: use GetGraphicalPins(). This override remains to satisfy SYMBOL's pure virtual.
709 std::vector<SCH_PIN*> GetPins() const override;
710
714 int GetPinCount() override;
715
724 const SCH_PIN* GetPin( const wxString& aNumber, int aUnit = 0, int aBodyStyle = 0 ) const;
725
737 std::vector<SCH_PIN*> GetPinsByNumber( const wxString& aNumber, int aUnit = 0, int aBodyStyle = 0 );
738
750 bool PinsConflictWith( const LIB_SYMBOL& aOtherSymbol, bool aTestNums, bool aTestNames,
751 bool aTestType, bool aTestOrientation, bool aTestLength ) const;
752
758 void Move( const VECTOR2I& aOffset ) override;
759
766 bool HasLegacyAlternateBodyStyle() const;
767
772 int GetMaxPinNumber() const;
773
777 void ClearTempFlags() override;
778 void ClearEditFlags() override;
779
789 SCH_ITEM* LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint );
790
801 SCH_ITEM* LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint,
802 const TRANSFORM& aTransform );
803
810 const LIB_ITEMS_CONTAINER& GetDrawItems() const { return m_drawings; }
811
816 void FixupDrawItems();
817
818 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
819 const std::vector<KICAD_T>& aScanTypes ) override;
820
832 void SetUnitCount( int aCount, bool aDuplicateDrawItems );
833 int GetUnitCount() const override;
834
835 wxString GetUnitName( int aUnit ) const override
836 {
837 return GetUnitDisplayName( aUnit, true );
838 }
839
843 wxString GetUnitDisplayName( int aUnit, bool aLabel ) const override;
844
845 wxString GetBodyStyleDescription( int aBodyStyle, bool aLabel ) const override;
846
847 std::map<int, wxString>& GetUnitDisplayNames() { return m_unitDisplayNames; }
848 const std::map<int, wxString>& GetUnitDisplayNames() const { return m_unitDisplayNames; }
849
852
857 std::vector<std::set<wxString>>& JumperPinGroups() { return m_jumperPinGroups; }
858 const std::vector<std::set<wxString>>& JumperPinGroups() const { return m_jumperPinGroups; }
859
861 std::optional<const std::set<wxString>> GetJumperPinGroup( const wxString& aPinNumber ) const;
862
867 bool IsMultiUnit() const override { return m_unitCount > 1; }
868
869 static wxString LetterSubReference( int aUnit, wxChar aInitialLetter );
870
871 bool IsMultiBodyStyle() const override { return GetBodyStyleCount() > 1; }
872
873 int GetBodyStyleCount() const override
874 {
875 if( m_demorgan )
876 return 2;
877 else
878 return std::max( 1, (int) m_bodyStyleNames.size() );
879 }
880
881 bool HasDeMorganBodyStyles() const override { return m_demorgan; }
882 void SetHasDeMorganBodyStyles( bool aFlag ) { m_demorgan = aFlag; }
883
884 const std::vector<wxString>& GetBodyStyleNames() const { return m_bodyStyleNames; }
885 void SetBodyStyleNames( const std::vector<wxString>& aBodyStyleNames ) { m_bodyStyleNames = aBodyStyleNames; }
886
898 void SetBodyStyleCount( int aCount, bool aDuplicateDrawItems, bool aDuplicatePins );
899
909 int Compare( const LIB_SYMBOL& aRhs, int aCompareFlags = 0, REPORTER* aReporter = nullptr ) const;
910
911 const LIB_SYMBOL& operator=( const LIB_SYMBOL& aSymbol );
912
920 std::unique_ptr< LIB_SYMBOL > Flatten() const;
921
928 std::vector<struct LIB_SYMBOL_UNIT> GetUnitDrawItems();
929
940 std::vector<SCH_ITEM*> GetUnitDrawItems( int aUnit, int aBodyStyle );
941
948 double Similarity( const SCH_ITEM& aSymbol ) const override;
949
951
952 void SetParentName( const wxString& aParentName ) { m_parentName = aParentName; }
953 const wxString& GetParentName() const { return m_parentName; }
954
955#if defined(DEBUG)
956 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
957#endif
958
959private:
960 // We create a different set parent function for this class, so we hide the inherited one.
962
968 int compare( const SCH_ITEM& aOther, int aCompareFlags = SCH_ITEM::COMPARE_FLAGS::EQUALITY ) const override;
969
970 void deleteAllFields();
971
974 bool definesOwnPinMapBundle() const { return !m_pinMaps.IsEmpty() || !m_associatedFootprints.empty(); }
975
976 void cacheSearchTerms();
977 void cachePinCount();
979 void cacheChooserFields();
980
981private:
982 std::shared_ptr<LIB_SYMBOL> m_me;
983 std::weak_ptr<LIB_SYMBOL> m_parent;
984
985 wxString m_parentName;
986
990
994
998
1000
1002
1004 wxString m_name;
1005 wxString m_keyWords;
1006 wxArrayString m_fpFilters;
1008
1011
1014 std::vector<ASSOCIATED_FOOTPRINT> m_associatedFootprints;
1015
1018 std::vector<std::set<wxString> > m_jumperPinGroups;
1019
1023
1024 std::map<int, wxString> m_unitDisplayNames;
1025 std::vector<wxString> m_bodyStyleNames;
1026
1027 // Caches for things that are expensive to compute but required every time
1028 // the symbol chooser or other library list is created
1029
1030 std::vector<SEARCH_TERM> m_searchTermsCache;
1033 std::map<wxString, wxString> m_chooserFieldsCache;
1034};
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: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
Definition lib_symbol.h:223
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:444
wxString GetDescription() const override
Definition lib_symbol.h:195
const LIB_ID & GetLibId() const override
Definition lib_symbol.h:183
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:210
void SetGlobalPower()
std::weak_ptr< LIB_SYMBOL > & GetParent()
Definition lib_symbol.h:145
wxString GetBodyStyleProp() const override
Definition lib_symbol.h:574
virtual ~LIB_SYMBOL()=default
LIBRENTRYOPTIONS m_options
Special symbol features such as POWER or NORMAL.
Definition lib_symbol.h:999
wxString GetRefProp() const
Definition lib_symbol.h:463
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:564
const std::map< int, wxString > & GetUnitDisplayNames() const
Definition lib_symbol.h:848
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:187
wxString GetShownKeyWords(int aDepth=0) const override
const std::vector< ASSOCIATED_FOOTPRINT > & GetEffectiveAssociatedFootprints() const
Definition lib_symbol.h:290
bool UnitsLocked() const
Check whether symbol units are interchangeable.
Definition lib_symbol.h:366
SCH_FIELD & GetDatasheetField()
Return reference to the datasheet field.
Definition lib_symbol.h:440
void RefreshLibraryTreeCaches()
std::weak_ptr< LIB_SYMBOL > m_parent
Use for inherited symbols.
Definition lib_symbol.h:983
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
Definition lib_symbol.h:230
void SetExcludedFromBoardProp(bool aExclude)
Definition lib_symbol.h:610
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:667
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 SetKeywordsProp(const wxString &aKeywords)
Definition lib_symbol.h:508
bool IsDerived() const
Definition lib_symbol.h:231
std::map< int, wxString > & GetUnitDisplayNames()
Definition lib_symbol.h:847
void SetDuplicatePinNumbersAreJumpers(bool aEnabled)
Definition lib_symbol.h:851
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:995
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:616
timestamp_t GetLastModDate() const
Definition lib_symbol.h:238
LIB_ID GetSourceLibId() const
Definition lib_symbol.h:186
void SetLib(LEGACY_SYMBOL_LIB *aLibrary)
bool GetPowerSymbolProp() const
Definition lib_symbol.h:513
bool IsMultiBodyStyle() const override
Definition lib_symbol.h:871
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:128
bool CanUpdateFieldsFromParent() const
Definition lib_symbol.h:401
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:316
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:454
bool IsPowerSymbol() const override
For symbols that could be a power symbol.
Definition lib_symbol.h:350
SCH_FIELD & GetFootprintField()
Return reference to the footprint field.
Definition lib_symbol.h:436
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:262
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:885
bool IsNormal() const override
wxString m_name
void SetUnitsInterchangeableProp(bool aInterchangeable)
Definition lib_symbol.h:569
std::set< KIFONT::OUTLINE_FONT * > GetFonts() const override
LEGACY_SYMBOL_LIB * m_library
static bool ClassOf(const EDA_ITEM *aItem)
Definition lib_symbol.h:170
bool GetExcludedFromPosFilesProp() const
Definition lib_symbol.h:615
SCH_FIELD * FindFieldCaseInsensitive(const wxString &aFieldName)
const std::vector< std::set< wxString > > & JumperPinGroups() const
Definition lib_symbol.h:858
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:235
wxString GetDatasheetProp() const
Definition lib_symbol.h:493
void LockUnits(bool aLockUnits)
Set interchangeable the property for symbol units.
Definition lib_symbol.h:360
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition lib_symbol.h:809
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:468
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:835
wxString GetName() const override
Definition lib_symbol.h:176
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:982
wxString GetValueProp() const
Definition lib_symbol.h:473
bool GetExcludedFromBOMProp() const
Definition lib_symbol.h:595
void SetKeyWords(const wxString &aKeyWords)
SCH_FIELD & GetValueField()
Return reference to the value field.
Definition lib_symbol.h:428
bool definesOwnPinMapBundle() const
Definition lib_symbol.h:974
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:554
wxArrayString GetFPFilters() const
Definition lib_symbol.h:242
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:123
bool GetPinNamesInsideProp() const
Definition lib_symbol.h:541
void SetHasDeMorganBodyStyles(bool aFlag)
Definition lib_symbol.h:882
const std::vector< wxString > & GetBodyStyleNames() const
Definition lib_symbol.h:884
void SetBodyStyleProp(const wxString &aBodyStyle) override
Definition lib_symbol.h:579
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:258
timestamp_t m_lastModDate
Definition lib_symbol.h:989
void SetExcludedFromSimProp(bool aExclude)
Definition lib_symbol.h:590
bool GetExcludedFromBoardProp() const
Definition lib_symbol.h:605
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:987
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:181
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:189
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:488
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:881
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:992
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:240
const PIN_MAP_SET & GetEffectivePinMaps() const
Definition lib_symbol.h:275
bool IsMultiUnit() const override
Definition lib_symbol.h:867
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:585
const PIN_MAP_SET & GetPinMaps() const
Pin-to-pad mapping (issue #2282).
Definition lib_symbol.h:256
int GetBodyStyleCount() const override
Definition lib_symbol.h:873
void SetDatasheetProp(const wxString &aDatasheet)
Definition lib_symbol.h:498
wxString GetDesc() override
Definition lib_symbol.h:179
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:449
EMBEDDED_FILES * GetEmbeddedFiles() override
void SetPowerSymbolProp(bool aIsPower)
Definition lib_symbol.h:518
void AddField(SCH_FIELD &aField)
Definition lib_symbol.h:408
void SetExcludedFromBOMProp(bool aExclude)
Definition lib_symbol.h:600
int m_unitCount
Number of units (parts) per package.
Definition lib_symbol.h:991
wxString GetShownDescription(int aDepth=0) const override
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:165
bool IsGlobalPower() const override
LIB_ID m_sourceLibId
For database library symbols; the original symbol.
Definition lib_symbol.h:988
wxString GetBodyStyleDescription(int aBodyStyle, bool aLabel) const override
const wxString & GetParentName() const
Definition lib_symbol.h:953
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).
wxString GetKeywordsProp() const
Definition lib_symbol.h:503
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:334
void SetValueProp(const wxString &aValue)
Definition lib_symbol.h:478
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:339
void SetParentName(const wxString &aParentName)
Definition lib_symbol.h:952
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:526
bool GetDuplicatePinNumbersAreJumpers() const
Definition lib_symbol.h:850
void deleteAllFields()
PIN_MAP_SET & PinMaps()
Definition lib_symbol.h:257
LIB_ID GetLIB_ID() const override
Definition lib_symbol.h:178
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:559
wxString GetFootprintProp() const
Definition lib_symbol.h:483
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:857
void SetPinNamesInsideProp(bool aInside)
Definition lib_symbol.h:546
const std::weak_ptr< LIB_SYMBOL > & GetParent() const
Definition lib_symbol.h:146
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:985
void EmbedFonts() override
void SetLocalPowerSymbolProp(bool aIsLocalPower)
Definition lib_symbol.h:531
virtual void SetName(const wxString &aName)
const std::vector< ASSOCIATED_FOOTPRINT > & GetAssociatedFootprints() const
Definition lib_symbol.h:260
void SetNormal()
SCH_FIELD & GetReferenceField()
Return reference to the reference designator field.
Definition lib_symbol.h:432
const LIB_ITEMS_CONTAINER & GetDrawItems() const
Definition lib_symbol.h:810
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:72
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:43
LIBRENTRYOPTIONS
Definition lib_symbol.h:56
@ ENTRY_NORMAL
Definition lib_symbol.h:57
@ ENTRY_LOCAL_POWER
Definition lib_symbol.h:59
@ ENTRY_GLOBAL_POWER
Definition lib_symbol.h:58
MULTIVECTOR< SCH_ITEM, SCH_SHAPE_T, SCH_PIN_T > LIB_ITEMS_CONTAINER
Definition lib_symbol.h:50
LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS
Definition lib_symbol.h:51
bool operator<(const LIB_SYMBOL &aItem1, const LIB_SYMBOL &aItem2)
AUTOPLACE_ALGO
Definition sch_item.h:65
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:685
wxString number
expanded logical pin number
Definition lib_symbol.h:687
const SCH_PIN * pin
pointer to the base graphical pin
Definition lib_symbol.h:686
std::vector< wxString > m_pinNumbers
Definition lib_symbol.h:699
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:71
@ LIB_SYMBOL_T
Definition typeinfo.h:145
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683