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, you may find one here:
21 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22 * or you may search the http://www.gnu.org website for the version 2 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
27#ifndef LIB_SYMBOL_H
28#define LIB_SYMBOL_H
29
30#include <base_units.h>
31#include <embedded_files.h>
32#include <symbol.h>
33#include <sch_field.h>
34#include <sch_pin.h>
35#include <lib_tree_item.h>
36#include <vector>
37#include <core/multivector.h>
38#include <default_values.h>
39
40class LINE_READER;
41class OUTPUTFORMATTER;
42class REPORTER;
44class LIB_SYMBOL;
45class OUTLINE_FONT;
47
48namespace KIFONT
49{
50 class OUTLINE_FONT;
51}
52
53
56
57
58/* values for member .m_options */
60{
61 ENTRY_NORMAL, // Libentry is a standard symbol (real or alias)
62 ENTRY_GLOBAL_POWER, // Libentry is a power symbol
63 ENTRY_LOCAL_POWER // Libentry is a local power symbol
64};
65
66
67extern bool operator<( const LIB_SYMBOL& aItem1, const LIB_SYMBOL& aItem2 );
68
69
71{
72 int m_unit;
74 std::vector<SCH_ITEM*> m_items;
75};
76
77
84class LIB_SYMBOL : public SYMBOL, public LIB_TREE_ITEM, public EMBEDDED_FILES
85{
86public:
87 LIB_SYMBOL( const wxString& aName, LIB_SYMBOL* aParent = nullptr,
88 LEGACY_SYMBOL_LIB* aLibrary = nullptr );
89
90 LIB_SYMBOL( const LIB_SYMBOL& aSymbol, LEGACY_SYMBOL_LIB* aLibrary = nullptr );
91
92 virtual ~LIB_SYMBOL() = default;
93
95 std::shared_ptr<LIB_SYMBOL> SharedPtr() const { return m_me; }
96
100 virtual LIB_SYMBOL* Duplicate() const
101 {
102 LIB_SYMBOL* dupe = new LIB_SYMBOL( *this, m_library );
103 const_cast<KIID&>( dupe->m_Uuid ) = KIID();
104
105 for( SCH_ITEM& item : dupe->m_drawings )
106 const_cast<KIID&>( item.m_Uuid ) = KIID();
107
108 return dupe;
109 }
110
114 static LIB_SYMBOL* GetDummy();
115
116 void SetParent( LIB_SYMBOL* aParent = nullptr );
117 std::weak_ptr<LIB_SYMBOL>& GetParent() { return m_parent; }
118 const std::weak_ptr<LIB_SYMBOL>& GetParent() const { return m_parent; }
119
125 unsigned GetInheritanceDepth() const;
126
135 std::shared_ptr<LIB_SYMBOL> GetRootSymbol() const;
136
137 virtual wxString GetClass() const override
138 {
139 return wxT( "LIB_SYMBOL" );
140 }
141
142 static inline bool ClassOf( const EDA_ITEM* aItem )
143 {
144 return aItem && aItem->Type() == LIB_SYMBOL_T;
145 }
146
147 virtual void SetName( const wxString& aName );
148 wxString GetName() const override { return m_name; }
149
150 LIB_ID GetLIB_ID() const override { return m_libId; }
151 wxString GetDesc() override { return GetShownDescription(); }
152 wxString GetFootprint() override { return GetFootprintField().GetShownText( false ); }
153 int GetSubUnitCount() const override { return GetUnitCount(); }
154
155 const LIB_ID& GetLibId() const override { return m_libId; }
156 void SetLibId( const LIB_ID& aLibId ) { m_libId = aLibId; }
157
159 void SetSourceLibId( const LIB_ID& aLibId ) { m_sourceLibId = aLibId; }
160
161 wxString GetLibNickname() const override { return GetLibraryName(); }
162
164 void SetDescription( const wxString& aDescription )
165 {
166 GetDescriptionField().SetText( aDescription );
167 }
168
170 wxString GetDescription() const override
171 {
172 if( GetDescriptionField().GetText().IsEmpty() && IsDerived() )
173 {
174 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
175 return parent->GetDescription();
176 }
177
178 return GetDescriptionField().GetText();
179 }
180
181 wxString GetShownDescription( int aDepth = 0 ) const override;
182
183 void SetKeyWords( const wxString& aKeyWords ) { m_keyWords = aKeyWords; }
184
185 wxString GetKeyWords() const override
186 {
187 if( m_keyWords.IsEmpty() && IsDerived() )
188 {
189 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
190 return parent->GetKeyWords();
191 }
192
193 return m_keyWords;
194 }
195
196 wxString GetShownKeyWords( int aDepth = 0 ) const override;
197
198 std::vector<SEARCH_TERM> GetSearchTerms() override;
199
200 void GetChooserFields( std::map<wxString , wxString>& aColumnMap ) override;
201
205 bool IsRoot() const override { return m_parent.use_count() == 0; }
206 bool IsDerived() const { return !m_parent.expired() && m_parent.use_count() > 0; }
207
208 const wxString GetLibraryName() const;
209
210 LEGACY_SYMBOL_LIB* GetLib() const { return m_library; }
211 void SetLib( LEGACY_SYMBOL_LIB* aLibrary ) { m_library = aLibrary; }
212
214
215 void SetFPFilters( const wxArrayString& aFilters ) { m_fpFilters = aFilters; }
216
217 wxArrayString GetFPFilters() const
218 {
219 if( m_fpFilters.IsEmpty() && IsDerived() )
220 {
221 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
222 return parent->GetFPFilters();
223 }
224
225 return m_fpFilters;
226 }
227
240 const BOX2I GetUnitBoundingBox( int aUnit, int aBodyStyle,
241 bool aIgnoreHiddenFields = true,
242 bool aIgnoreLabelsOnInvisiblePins = true ) const;
243
244 const BOX2I GetBoundingBox() const override
245 {
246 return GetUnitBoundingBox( 0, 0 );
247 }
248
259 const BOX2I GetBodyBoundingBox( int aUnit, int aBodyStyle, bool aIncludePins,
260 bool aIncludePrivateItems ) const;
261
262 BOX2I GetBodyBoundingBox() const override
263 {
264 return GetBodyBoundingBox( m_previewUnit, m_previewBodyStyle, false, false );
265 }
266
268 {
270 }
271
272 bool IsGlobalPower() const override;
273 bool IsLocalPower() const override;
274 bool IsPower() const override;
275 bool IsNormal() const override;
276
277 void SetGlobalPower();
278 void SetLocalPower();
279 void SetNormal();
280
285 void LockUnits( bool aLockUnits ) { m_unitsLocked = aLockUnits; }
286
291 bool UnitsLocked() const { return m_unitsLocked; }
292
298 void SetFields( const std::vector<SCH_FIELD>& aFieldsList );
299
305 void GetFields( std::vector<SCH_FIELD*>& aList, bool aVisibleOnly = false ) const override;
306
310 void CopyFields( std::vector<SCH_FIELD>& aList );
311
315 void AddField( SCH_FIELD* aField );
316
317 void AddField( SCH_FIELD& aField ) { AddField( new SCH_FIELD( aField ) ); }
318
322 int GetNextFieldOrdinal() const;
323
327 SCH_FIELD* GetField( const wxString& aFieldName );
328 const SCH_FIELD* GetField( const wxString& aFieldName ) const;
329
330 SCH_FIELD* FindFieldCaseInsensitive( const wxString& aFieldName );
331
332 const SCH_FIELD* GetField( FIELD_T aFieldType ) const;
333 SCH_FIELD* GetField( FIELD_T aFieldType );
334
337 const SCH_FIELD& GetValueField() const;
338
341 const SCH_FIELD& GetReferenceField() const;
342
345 const SCH_FIELD& GetFootprintField() const;
346
349 const SCH_FIELD& GetDatasheetField() const;
350
353 const SCH_FIELD& GetDescriptionField() const;
354
355 wxString GetPrefix();
356
357 const wxString GetRef( const SCH_SHEET_PATH* aSheet, bool aIncludeUnit = false ) const override
358 {
359 return GetReferenceField().GetText();
360 }
361
362 const wxString GetValue( bool aResolve, const SCH_SHEET_PATH* aPath,
363 bool aAllowExtraText ) const override
364 {
365 return GetValueField().GetText();
366 }
367
368 /*
369 * Field access for property manager
370 */
371 wxString GetRefProp() const
372 {
373 return GetReferenceField().GetText();
374 }
375
376 void SetRefProp( const wxString& aRef )
377 {
378 GetReferenceField().SetText( aRef );
379 }
380
381 wxString GetValueProp() const
382 {
383 return GetValueField().GetText();
384 }
385
386 void SetValueProp( const wxString& aValue )
387 {
388 GetValueField().SetText( aValue );
389 }
390
391 wxString GetFootprintProp() const
392 {
393 return GetFootprintField().GetText();
394 }
395
396 void SetFootprintProp( const wxString& aFootprint )
397 {
398 GetFootprintField().SetText( aFootprint );
399 }
400
401 wxString GetDatasheetProp() const
402 {
403 return GetDatasheetField().GetText();
404 }
405
406 void SetDatasheetProp( const wxString& aDatasheet )
407 {
408 GetDatasheetField().SetText( aDatasheet );
409 }
410
411 wxString GetKeywordsProp() const
412 {
413 return GetKeyWords();
414 }
415
416 void SetKeywordsProp( const wxString& aKeywords )
417 {
418 SetKeyWords( aKeywords );
419 }
420
422 {
423 return IsPower();
424 }
425
426 void SetPowerSymbolProp( bool aIsPower )
427 {
428 if( aIsPower )
430 else
431 SetNormal();
432 }
433
435 {
436 return IsLocalPower();
437 }
438
439 void SetLocalPowerSymbolProp( bool aIsLocalPower )
440 {
441 if( aIsLocalPower )
443 else if( IsPower() )
445 else
446 SetNormal();
447 }
448
450 {
451 return GetPinNameOffset() != 0;
452 }
453
454 void SetPinNamesInsideProp( bool aInside )
455 {
456 if( aInside && GetPinNameOffset() == 0 )
458 else if( !aInside )
459 SetPinNameOffset( 0 );
460 }
461
462 int GetUnitProp() const
463 {
464 return GetUnitCount();
465 }
466
467 void SetUnitProp( int aUnits )
468 {
469 SetUnitCount( aUnits, true );
470 }
471
473 {
474 return !UnitsLocked();
475 }
476
477 void SetUnitsInterchangeableProp( bool aInterchangeable )
478 {
479 LockUnits( !aInterchangeable );
480 }
481
482 wxString GetBodyStyleProp() const override
483 {
484 return GetBodyStyleDescription( 1, false );
485 }
486
487 void SetBodyStyleProp( const wxString& aBodyStyle ) override
488 {
489 // Body style setting is more complex for LIB_SYMBOL
490 // For now, this is primarily for display purposes
491 }
492
494 {
495 return GetExcludedFromSim();
496 }
497
498 void SetExcludedFromSimProp( bool aExclude )
499 {
500 SetExcludedFromSim( aExclude );
501 }
502
504 {
505 return GetExcludedFromBOM();
506 }
507
508 void SetExcludedFromBOMProp( bool aExclude )
509 {
510 SetExcludedFromBOM( aExclude );
511 }
512
513 std::set<KIFONT::OUTLINE_FONT*> GetFonts() const override;
514
516 const EMBEDDED_FILES* GetEmbeddedFiles() const;
517
518 void EmbedFonts() override;
519
526 void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
527
528 void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction, RECURSE_MODE aMode ) override;
529
535 bool ResolveTextVar( wxString* token, int aDepth = 0 ) const;
536
537 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
538 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
539
543 void PlotFields( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
544 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed );
545
552 void AddDrawItem( SCH_ITEM* aItem, bool aSort = true );
553
559 void RemoveDrawItem( SCH_ITEM* aItem );
560
561 void RemoveField( SCH_FIELD* aField ) { RemoveDrawItem( aField ); }
562
571 std::vector<SCH_PIN*> GetGraphicalPins( int aUnit = 0, int aBodyStyle = 0 ) const;
572
578 {
580 wxString number;
581 };
582
587 std::vector<LOGICAL_PIN> GetLogicalPins( int aUnit, int aBodyStyle ) const;
588
590 {
591 wxString m_unitName;
592 std::vector<wxString> m_pinNumbers;
593 };
594
598 std::vector<UNIT_PIN_INFO> GetUnitPinInfo() const;
599
600 // Deprecated: use GetGraphicalPins(). This override remains to satisfy SYMBOL's pure virtual.
601 std::vector<SCH_PIN*> GetPins() const override;
602
606 int GetPinCount() override;
607
616 SCH_PIN* GetPin( const wxString& aNumber, int aUnit = 0, int aBodyStyle = 0 ) const;
617
629 bool PinsConflictWith( const LIB_SYMBOL& aOtherSymbol, bool aTestNums, bool aTestNames,
630 bool aTestType, bool aTestOrientation, bool aTestLength ) const;
631
637 void Move( const VECTOR2I& aOffset ) override;
638
645 bool HasLegacyAlternateBodyStyle() const;
646
651 int GetMaxPinNumber() const;
652
656 void ClearTempFlags() override;
657 void ClearEditFlags() override;
658
668 SCH_ITEM* LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint );
669
680 SCH_ITEM* LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint,
681 const TRANSFORM& aTransform );
682
689 const LIB_ITEMS_CONTAINER& GetDrawItems() const { return m_drawings; }
690
695 void FixupDrawItems();
696
697 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
698 const std::vector<KICAD_T>& aScanTypes ) override;
699
711 void SetUnitCount( int aCount, bool aDuplicateDrawItems );
712 int GetUnitCount() const override;
713
714 wxString GetUnitName( int aUnit ) const override
715 {
716 return GetUnitDisplayName( aUnit, true );
717 }
718
722 wxString GetUnitDisplayName( int aUnit, bool aLabel ) const override;
723
724 wxString GetBodyStyleDescription( int aBodyStyle, bool aLabel ) const override;
725
726 std::map<int, wxString>& GetUnitDisplayNames() { return m_unitDisplayNames; }
727 const std::map<int, wxString>& GetUnitDisplayNames() const { return m_unitDisplayNames; }
728
731
736 std::vector<std::set<wxString>>& JumperPinGroups() { return m_jumperPinGroups; }
737 const std::vector<std::set<wxString>>& JumperPinGroups() const { return m_jumperPinGroups; }
738
740 std::optional<const std::set<wxString>> GetJumperPinGroup( const wxString& aPinNumber ) const;
741
746 bool IsMultiUnit() const override { return m_unitCount > 1; }
747
748 static wxString LetterSubReference( int aUnit, wxChar aInitialLetter );
749
750 bool IsMultiBodyStyle() const override { return GetBodyStyleCount() > 1; }
751
752 int GetBodyStyleCount() const override
753 {
754 if( m_demorgan )
755 return 2;
756 else
757 return std::max( 1, (int) m_bodyStyleNames.size() );
758 }
759
760 bool HasDeMorganBodyStyles() const override { return m_demorgan; }
761 void SetHasDeMorganBodyStyles( bool aFlag ) { m_demorgan = aFlag; }
762
763 const std::vector<wxString>& GetBodyStyleNames() const { return m_bodyStyleNames; }
764 void SetBodyStyleNames( const std::vector<wxString>& aBodyStyleNames ) { m_bodyStyleNames = aBodyStyleNames; }
765
777 void SetBodyStyleCount( int aCount, bool aDuplicateDrawItems, bool aDuplicatePins );
778
788 int Compare( const LIB_SYMBOL& aRhs, int aCompareFlags = 0,
789 REPORTER* aReporter = nullptr ) const;
790
791 const LIB_SYMBOL& operator=( const LIB_SYMBOL& aSymbol );
792
800 std::unique_ptr< LIB_SYMBOL > Flatten() const;
801
808 std::vector<struct LIB_SYMBOL_UNIT> GetUnitDrawItems();
809
820 std::vector<SCH_ITEM*> GetUnitDrawItems( int aUnit, int aBodyStyle );
821
828 double Similarity( const SCH_ITEM& aSymbol ) const override;
829
830 void SetParentName( const wxString& aParentName ) { m_parentName = aParentName; }
831 const wxString& GetParentName() const { return m_parentName; }
832
833#if defined(DEBUG)
834 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
835#endif
836
837private:
838 // We create a different set parent function for this class, so we hide the inherited one.
840
846 int compare( const SCH_ITEM& aOther,
847 int aCompareFlags = SCH_ITEM::COMPARE_FLAGS::EQUALITY ) const override;
848
849 void deleteAllFields();
850
851private:
852 std::shared_ptr<LIB_SYMBOL> m_me;
853 std::weak_ptr<LIB_SYMBOL> m_parent;
854
855 wxString m_parentName;
856
860
864
868
870
872
874 wxString m_name;
875 wxString m_keyWords;
876 wxArrayString m_fpFilters;
878
881 std::vector<std::set<wxString> > m_jumperPinGroups;
882
886
887 std::map<int, wxString> m_unitDisplayNames;
888 std::vector<wxString> m_bodyStyleNames;
889};
890
891#endif // CLASS_LIBENTRY_H
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:114
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
const KIID m_Uuid
Definition eda_item.h:516
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.h:113
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:39
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition eda_text.h:98
bool IsEmpty() const
EMBEDDED_FILES()=default
Class OUTLINE_FONT implements outline font drawing.
Definition kiid.h:49
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:49
Define a library symbol object.
Definition lib_symbol.h:85
LIB_ITEMS_CONTAINER m_drawings
Definition lib_symbol.h:871
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:352
wxString GetDescription() const override
Definition lib_symbol.h:170
const LIB_ID & GetLibId() const override
Definition lib_symbol.h:155
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:185
void SetGlobalPower()
std::weak_ptr< LIB_SYMBOL > & GetParent()
Definition lib_symbol.h:117
wxString GetBodyStyleProp() const override
Definition lib_symbol.h:482
virtual ~LIB_SYMBOL()=default
LIBRENTRYOPTIONS m_options
Special symbol features such as POWER or NORMAL.
Definition lib_symbol.h:869
wxString GetRefProp() const
Definition lib_symbol.h:371
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:472
const std::map< int, wxString > & GetUnitDisplayNames() const
Definition lib_symbol.h:727
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:159
wxString GetShownKeyWords(int aDepth=0) const override
bool UnitsLocked() const
Check whether symbol units are interchangeable.
Definition lib_symbol.h:291
SCH_FIELD & GetDatasheetField()
Return reference to the datasheet field.
Definition lib_symbol.h:348
std::weak_ptr< LIB_SYMBOL > m_parent
Use for inherited symbols.
Definition lib_symbol.h:853
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
Definition lib_symbol.h:205
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:561
std::map< int, wxString > m_unitDisplayNames
Definition lib_symbol.h:887
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:881
void ClearTempFlags() override
Clears the status flag all draw objects in this symbol.
void SetKeywordsProp(const wxString &aKeywords)
Definition lib_symbol.h:416
bool IsDerived() const
Definition lib_symbol.h:206
std::map< int, wxString > & GetUnitDisplayNames()
Definition lib_symbol.h:726
void SetDuplicatePinNumbersAreJumpers(bool aEnabled)
Definition lib_symbol.h:730
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:865
wxString GetFootprint() override
For items with footprint fields.
Definition lib_symbol.h:152
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.
std::vector< SEARCH_TERM > GetSearchTerms() override
timestamp_t GetLastModDate() const
Definition lib_symbol.h:213
LIB_ID GetSourceLibId() const
Definition lib_symbol.h:158
void SetLib(LEGACY_SYMBOL_LIB *aLibrary)
Definition lib_symbol.h:211
bool GetPowerSymbolProp() const
Definition lib_symbol.h:421
bool IsMultiBodyStyle() const override
Definition lib_symbol.h:750
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:100
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:244
SCH_FIELD * GetField(const wxString &aFieldName)
Find a field within this symbol matching aFieldName; return nullptr if not found.
SCH_FIELD & GetFootprintField()
Return reference to the footprint field.
Definition lib_symbol.h:344
int Compare(const LIB_SYMBOL &aRhs, int aCompareFlags=0, REPORTER *aReporter=nullptr) const
Comparison test that can be used for operators.
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:764
SCH_PIN * GetPin(const wxString &aNumber, int aUnit=0, int aBodyStyle=0) const
Return pin object with the requested pin aNumber.
bool IsNormal() const override
wxString m_name
Definition lib_symbol.h:874
void SetUnitsInterchangeableProp(bool aInterchangeable)
Definition lib_symbol.h:477
std::set< KIFONT::OUTLINE_FONT * > GetFonts() const override
LEGACY_SYMBOL_LIB * m_library
Definition lib_symbol.h:873
static bool ClassOf(const EDA_ITEM *aItem)
Definition lib_symbol.h:142
SCH_FIELD * FindFieldCaseInsensitive(const wxString &aFieldName)
const std::vector< std::set< wxString > > & JumperPinGroups() const
Definition lib_symbol.h:737
wxString m_keyWords
Search keywords.
Definition lib_symbol.h:875
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:210
wxString GetDatasheetProp() const
Definition lib_symbol.h:401
void LockUnits(bool aLockUnits)
Set interchangeable the property for symbol units.
Definition lib_symbol.h:285
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition lib_symbol.h:688
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:376
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:714
wxString GetName() const override
Definition lib_symbol.h:148
void SetUnitCount(int aCount, bool aDuplicateDrawItems)
Set the units per symbol count.
void SetDescription(const wxString &aDescription)
Gets the Description field text value *‍/.
Definition lib_symbol.h:164
std::shared_ptr< LIB_SYMBOL > m_me
Definition lib_symbol.h:852
wxString GetValueProp() const
Definition lib_symbol.h:381
bool GetExcludedFromBOMProp() const
Definition lib_symbol.h:503
void SetKeyWords(const wxString &aKeyWords)
Definition lib_symbol.h:183
SCH_FIELD & GetValueField()
Return reference to the value field.
Definition lib_symbol.h:336
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:462
wxArrayString GetFPFilters() const
Definition lib_symbol.h:217
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:95
bool GetPinNamesInsideProp() const
Definition lib_symbol.h:449
void SetHasDeMorganBodyStyles(bool aFlag)
Definition lib_symbol.h:761
const std::vector< wxString > & GetBodyStyleNames() const
Definition lib_symbol.h:763
void SetBodyStyleProp(const wxString &aBodyStyle) override
Definition lib_symbol.h:487
int compare(const SCH_ITEM &aOther, int aCompareFlags=SCH_ITEM::COMPARE_FLAGS::EQUALITY) const override
The library symbol specific sort order is as follows:
timestamp_t m_lastModDate
Definition lib_symbol.h:859
void SetExcludedFromSimProp(bool aExclude)
Definition lib_symbol.h:498
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:857
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:153
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:161
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:396
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:760
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:862
wxArrayString m_fpFilters
List of suitable footprint names for the symbol (wild card names accepted).
Definition lib_symbol.h:876
void Move(const VECTOR2I &aOffset) override
Move the symbol aOffset.
void SetFPFilters(const wxArrayString &aFilters)
Definition lib_symbol.h:215
bool IsMultiUnit() const override
Definition lib_symbol.h:746
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
std::vector< SCH_PIN * > GetGraphicalPins(int aUnit=0, int aBodyStyle=0) const
Graphical pins: Return schematic pin objects as drawn (unexpanded), filtered by unit/body.
bool GetExcludedFromSimProp() const
Definition lib_symbol.h:493
const wxString GetValue(bool aResolve, const SCH_SHEET_PATH *aPath, bool aAllowExtraText) const override
Definition lib_symbol.h:362
int GetBodyStyleCount() const override
Definition lib_symbol.h:752
void SetDatasheetProp(const wxString &aDatasheet)
Definition lib_symbol.h:406
wxString GetDesc() override
Definition lib_symbol.h:151
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:357
EMBEDDED_FILES * GetEmbeddedFiles() override
void SetPowerSymbolProp(bool aIsPower)
Definition lib_symbol.h:426
void AddField(SCH_FIELD &aField)
Definition lib_symbol.h:317
void SetExcludedFromBOMProp(bool aExclude)
Definition lib_symbol.h:508
int m_unitCount
Number of units (parts) per package.
Definition lib_symbol.h:861
wxString GetShownDescription(int aDepth=0) const override
virtual wxString GetClass() const override
Return the class name.
Definition lib_symbol.h:137
bool IsGlobalPower() const override
LIB_ID m_sourceLibId
For database library symbols; the original symbol.
Definition lib_symbol.h:858
wxString GetBodyStyleDescription(int aBodyStyle, bool aLabel) const override
const wxString & GetParentName() const
Definition lib_symbol.h:831
unsigned GetInheritanceDepth() const
Get the number of parents for this symbol.
int GetUnitCount() const override
wxString GetKeywordsProp() const
Definition lib_symbol.h:411
std::vector< wxString > m_bodyStyleNames
Definition lib_symbol.h:888
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:262
void SetValueProp(const wxString &aValue)
Definition lib_symbol.h:386
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:267
void SetParentName(const wxString &aParentName)
Definition lib_symbol.h:830
void SetLibId(const LIB_ID &aLibId)
Definition lib_symbol.h:156
void AddField(SCH_FIELD *aField)
Add a field.
void ClearEditFlags() override
bool GetLocalPowerSymbolProp() const
Definition lib_symbol.h:434
bool GetDuplicatePinNumbersAreJumpers() const
Definition lib_symbol.h:729
void deleteAllFields()
LIB_ID GetLIB_ID() const override
Definition lib_symbol.h:150
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:885
void SetUnitProp(int aUnits)
Definition lib_symbol.h:467
wxString GetFootprintProp() const
Definition lib_symbol.h:391
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:736
void SetPinNamesInsideProp(bool aInside)
Definition lib_symbol.h:454
const std::weak_ptr< LIB_SYMBOL > & GetParent() const
Definition lib_symbol.h:118
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:855
void EmbedFonts() override
void SetLocalPowerSymbolProp(bool aIsLocalPower)
Definition lib_symbol.h:439
virtual void SetName(const wxString &aName)
void SetNormal()
SCH_FIELD & GetReferenceField()
Return reference to the reference designator field.
Definition lib_symbol.h:340
const LIB_ITEMS_CONTAINER & GetDrawItems() const
Definition lib_symbol.h:689
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:94
Multivector container type.
Definition multivector.h:47
boost::ptr_vector< SCH_ITEM > ITEM_PTR_VECTOR
Definition multivector.h:65
An interface used to output 8 bit text in a convenient way.
Definition richio.h:323
Base plotter engine class.
Definition plotter.h:121
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
void SetText(const wxString &aText) override
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:167
friend class LIB_SYMBOL
Definition sch_item.h:773
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:51
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
SYMBOL(KICAD_T idType)
Definition symbol.h:65
int m_previewBodyStyle
Definition symbol.h:253
int GetPinNameOffset() const
Definition symbol.h:160
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:177
virtual bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Definition symbol.h:198
void SetPinNameOffset(int aOffset)
Set the offset in mils of the pin name text from the pin symbol.
Definition symbol.h:159
virtual bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Definition symbol.h:183
int m_previewUnit
Definition symbol.h:252
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:192
for transforming drawing coordinates for a wxDC device context.
Definition transform.h:46
#define DEFAULT_PIN_NAME_OFFSET
The intersheets references prefix string.
RECURSE_MODE
Definition eda_item.h:50
INSPECT_RESULT
Definition eda_item.h:44
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition eda_item.h:91
uint32_t timestamp_t
timestamp_t is our type to represent unique IDs for all kinds of elements; historically simply the ti...
Definition kiid.h:46
LIBRENTRYOPTIONS
Definition lib_symbol.h:60
@ ENTRY_NORMAL
Definition lib_symbol.h:61
@ ENTRY_LOCAL_POWER
Definition lib_symbol.h:63
@ ENTRY_GLOBAL_POWER
Definition lib_symbol.h:62
MULTIVECTOR< SCH_ITEM, SCH_SHAPE_T, SCH_PIN_T > LIB_ITEMS_CONTAINER
Definition lib_symbol.h:54
LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS
Definition lib_symbol.h:55
bool operator<(const LIB_SYMBOL &aItem1, const LIB_SYMBOL &aItem2)
AUTOPLACE_ALGO
Definition sch_item.h:68
Logical pins: Return expanded logical pins based on stacked-pin notation.
Definition lib_symbol.h:578
wxString number
expanded logical pin number
Definition lib_symbol.h:580
SCH_PIN * pin
pointer to the base graphical pin
Definition lib_symbol.h:579
std::vector< wxString > m_pinNumbers
Definition lib_symbol.h:592
int m_bodyStyle
The alternate body style of the unit.
Definition lib_symbol.h:73
std::vector< SCH_ITEM * > m_items
The items unique to this unit and alternate body style.
Definition lib_symbol.h:74
int m_unit
The unit number.
Definition lib_symbol.h:72
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:78
@ LIB_SYMBOL_T
Definition typeinfo.h:152
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695