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#pragma once
28
29#include <base_units.h>
30#include <embedded_files.h>
31#include <symbol.h>
32#include <sch_field.h>
33#include <sch_pin.h>
34#include <lib_tree_item.h>
35#include <vector>
36#include <core/multivector.h>
37#include <default_values.h>
38
39class LINE_READER;
40class OUTPUTFORMATTER;
41class REPORTER;
43class LIB_SYMBOL;
45
46namespace KIFONT
47{
48 class OUTLINE_FONT;
49}
50
51
54
55
56/* values for member .m_options */
58{
59 ENTRY_NORMAL, // Libentry is a standard symbol (real or alias)
60 ENTRY_GLOBAL_POWER, // Libentry is a power symbol
61 ENTRY_LOCAL_POWER // Libentry is a local power symbol
62};
63
64
65extern bool operator<( const LIB_SYMBOL& aItem1, const LIB_SYMBOL& aItem2 );
66
67
69{
70 int m_unit;
72 std::vector<SCH_ITEM*> m_items;
73};
74
75
82class LIB_SYMBOL : public SYMBOL, public LIB_TREE_ITEM, public EMBEDDED_FILES
83{
84public:
85 LIB_SYMBOL( const wxString& aName, LIB_SYMBOL* aParent = nullptr, LEGACY_SYMBOL_LIB* aLibrary = nullptr );
86
87 LIB_SYMBOL( const LIB_SYMBOL& aSymbol, LEGACY_SYMBOL_LIB* aLibrary = nullptr, bool aCopyEmbeddedFiles = true );
88
89 virtual ~LIB_SYMBOL() = default;
90
92 std::shared_ptr<LIB_SYMBOL> SharedPtr() const { return m_me; }
93
97 virtual LIB_SYMBOL* Duplicate() const
98 {
99 LIB_SYMBOL* dupe = new LIB_SYMBOL( *this, m_library );
100 const_cast<KIID&>( dupe->m_Uuid ) = KIID();
101
102 for( SCH_ITEM& item : dupe->m_drawings )
103 const_cast<KIID&>( item.m_Uuid ) = KIID();
104
105 return dupe;
106 }
107
111 static LIB_SYMBOL* GetDummy();
112
113 void SetParent( LIB_SYMBOL* aParent = nullptr );
114 std::weak_ptr<LIB_SYMBOL>& GetParent() { return m_parent; }
115 const std::weak_ptr<LIB_SYMBOL>& GetParent() const { return m_parent; }
116
122 unsigned GetInheritanceDepth() const;
123
132 std::shared_ptr<LIB_SYMBOL> GetRootSymbol() const;
133
134 virtual wxString GetClass() const override
135 {
136 return wxT( "LIB_SYMBOL" );
137 }
138
139 static inline bool ClassOf( const EDA_ITEM* aItem )
140 {
141 return aItem && aItem->Type() == LIB_SYMBOL_T;
142 }
143
144 virtual void SetName( const wxString& aName );
145 wxString GetName() const override { return m_name; }
146
147 LIB_ID GetLIB_ID() const override { return m_libId; }
148 wxString GetDesc() override { return GetShownDescription(); }
149 wxString GetFootprint() override;
150 int GetSubUnitCount() const override { return GetUnitCount(); }
151
152 const LIB_ID& GetLibId() const override { return m_libId; }
153 void SetLibId( const LIB_ID& aLibId );
154
156 void SetSourceLibId( const LIB_ID& aLibId ) { m_sourceLibId = aLibId; }
157
158 wxString GetLibNickname() const override { return GetLibraryName(); }
159
161 void SetDescription( const wxString& aDescription );
162
164 wxString GetDescription() const override
165 {
166 if( GetDescriptionField().GetText().IsEmpty() && IsDerived() )
167 {
168 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
169 return parent->GetDescription();
170 }
171
172 return GetDescriptionField().GetText();
173 }
174
175 wxString GetShownDescription( int aDepth = 0 ) const override;
176
177 void SetKeyWords( const wxString& aKeyWords );
178
179 wxString GetKeyWords() const override
180 {
181 if( m_keyWords.IsEmpty() && IsDerived() )
182 {
183 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
184 return parent->GetKeyWords();
185 }
186
187 return m_keyWords;
188 }
189
190 wxString GetShownKeyWords( int aDepth = 0 ) const override;
191
192 std::vector<SEARCH_TERM>& GetSearchTerms() override { return m_searchTermsCache; }
193
194 void GetChooserFields( std::map<wxString , wxString>& aColumnMap ) override;
195
199 bool IsRoot() const override { return m_parent.use_count() == 0; }
200 bool IsDerived() const { return !m_parent.expired() && m_parent.use_count() > 0; }
201
202 const wxString GetLibraryName() const;
203
204 LEGACY_SYMBOL_LIB* GetLib() const { return m_library; }
205 void SetLib( LEGACY_SYMBOL_LIB* aLibrary );
206
208
209 void SetFPFilters( const wxArrayString& aFilters ) { m_fpFilters = aFilters; }
210
211 wxArrayString GetFPFilters() const
212 {
213 if( m_fpFilters.IsEmpty() && IsDerived() )
214 {
215 if( std::shared_ptr<LIB_SYMBOL> parent = m_parent.lock() )
216 return parent->GetFPFilters();
217 }
218
219 return m_fpFilters;
220 }
221
234 const BOX2I GetUnitBoundingBox( int aUnit, int aBodyStyle, bool aIgnoreHiddenFields = true,
235 bool aIgnoreLabelsOnInvisiblePins = true ) const;
236
237 const BOX2I GetBoundingBox() const override
238 {
239 return GetUnitBoundingBox( 0, 0 );
240 }
241
252 const BOX2I GetBodyBoundingBox( int aUnit, int aBodyStyle, bool aIncludePins,
253 bool aIncludePrivateItems ) const;
254
255 BOX2I GetBodyBoundingBox() const override
256 {
257 return GetBodyBoundingBox( m_previewUnit, m_previewBodyStyle, false, false );
258 }
259
261 {
263 }
264
265 bool IsGlobalPower() const override;
266 bool IsLocalPower() const override;
267 bool IsPower() const override;
268 bool IsNormal() const override;
269
270 // LIB_TREE_ITEM interface
271 bool IsPowerSymbol() const override { return IsPower(); }
272
273 void SetGlobalPower();
274 void SetLocalPower();
275 void SetNormal();
276
281 void LockUnits( bool aLockUnits ) { m_unitsLocked = aLockUnits; }
282
287 bool UnitsLocked() const { return m_unitsLocked; }
288
294 void SetFields( const std::vector<SCH_FIELD>& aFieldsList );
295
301 void GetFields( std::vector<SCH_FIELD*>& aList, bool aVisibleOnly = false ) const override;
302
306 void CopyFields( std::vector<SCH_FIELD>& aList );
307
311 void AddField( SCH_FIELD* aField );
312
313 void AddField( SCH_FIELD& aField ) { AddField( new SCH_FIELD( aField ) ); }
314
318 int GetNextFieldOrdinal() const;
319
323 SCH_FIELD* GetField( const wxString& aFieldName );
324 const SCH_FIELD* GetField( const wxString& aFieldName ) const;
325
326 SCH_FIELD* FindFieldCaseInsensitive( const wxString& aFieldName );
327 const SCH_FIELD* FindFieldCaseInsensitive( const wxString& aFieldName ) const;
328
329 const SCH_FIELD* GetField( FIELD_T aFieldType ) const;
330 SCH_FIELD* GetField( FIELD_T aFieldType );
331
334 const SCH_FIELD& GetValueField() const;
335
338 const SCH_FIELD& GetReferenceField() const;
339
342 const SCH_FIELD& GetFootprintField() const;
343
346 const SCH_FIELD& GetDatasheetField() const;
347
350 const SCH_FIELD& GetDescriptionField() const;
351
352 wxString GetPrefix();
353
354 const wxString GetRef( const SCH_SHEET_PATH* aSheet, bool aIncludeUnit = false ) const override
355 {
356 return GetReferenceField().GetText();
357 }
358
359 const wxString GetValue( bool aResolve, const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
360 const wxString& aVariantName = wxEmptyString ) const override
361 {
362 return GetValueField().GetText();
363 }
364
365 /*
366 * Field access for property manager
367 */
368 wxString GetRefProp() const
369 {
370 return GetReferenceField().GetText();
371 }
372
373 void SetRefProp( const wxString& aRef )
374 {
375 GetReferenceField().SetText( aRef );
376 }
377
378 wxString GetValueProp() const
379 {
380 return GetValueField().GetText();
381 }
382
383 void SetValueProp( const wxString& aValue )
384 {
385 GetValueField().SetText( aValue );
386 }
387
388 wxString GetFootprintProp() const
389 {
390 return GetFootprintField().GetText();
391 }
392
393 void SetFootprintProp( const wxString& aFootprint )
394 {
395 GetFootprintField().SetText( aFootprint );
396 }
397
398 wxString GetDatasheetProp() const
399 {
400 return GetDatasheetField().GetText();
401 }
402
403 void SetDatasheetProp( const wxString& aDatasheet )
404 {
405 GetDatasheetField().SetText( aDatasheet );
406 }
407
408 wxString GetKeywordsProp() const
409 {
410 return GetKeyWords();
411 }
412
413 void SetKeywordsProp( const wxString& aKeywords )
414 {
415 SetKeyWords( aKeywords );
416 }
417
419 {
420 return IsPower();
421 }
422
423 void SetPowerSymbolProp( bool aIsPower )
424 {
425 if( aIsPower )
427 else
428 SetNormal();
429 }
430
432 {
433 return IsLocalPower();
434 }
435
436 void SetLocalPowerSymbolProp( bool aIsLocalPower )
437 {
438 if( aIsLocalPower )
440 else if( IsPower() )
442 else
443 SetNormal();
444 }
445
447 {
448 return GetPinNameOffset() != 0;
449 }
450
451 void SetPinNamesInsideProp( bool aInside )
452 {
453 if( aInside && GetPinNameOffset() == 0 )
455 else if( !aInside )
456 SetPinNameOffset( 0 );
457 }
458
459 int GetUnitProp() const
460 {
461 return GetUnitCount();
462 }
463
464 void SetUnitProp( int aUnits )
465 {
466 SetUnitCount( aUnits, true );
467 }
468
470 {
471 return !UnitsLocked();
472 }
473
474 void SetUnitsInterchangeableProp( bool aInterchangeable )
475 {
476 LockUnits( !aInterchangeable );
477 }
478
479 wxString GetBodyStyleProp() const override
480 {
481 return GetBodyStyleDescription( 1, false );
482 }
483
484 void SetBodyStyleProp( const wxString& aBodyStyle ) override
485 {
486 // Body style setting is more complex for LIB_SYMBOL
487 // For now, this is primarily for display purposes
488 }
489
491 {
492 return GetExcludedFromSim();
493 }
494
495 void SetExcludedFromSimProp( bool aExclude )
496 {
497 SetExcludedFromSim( aExclude );
498 }
499
501 {
502 return GetExcludedFromBOM();
503 }
504
505 void SetExcludedFromBOMProp( bool aExclude )
506 {
507 SetExcludedFromBOM( aExclude );
508 }
509
511 {
512 return GetExcludedFromBoard();
513 }
514
515 void SetExcludedFromBoardProp( bool aExclude )
516 {
517 SetExcludedFromBoard( aExclude );
518 }
519
521 void SetExcludedFromPosFilesProp( bool aExclude ) { SetExcludedFromPosFiles( aExclude ); }
522
523 std::set<KIFONT::OUTLINE_FONT*> GetFonts() const override;
524
526 const EMBEDDED_FILES* GetEmbeddedFiles() const;
527 void AppendParentEmbeddedFiles( std::vector<EMBEDDED_FILES*>& aStack ) const;
528
529 void EmbedFonts() override;
530
537 void AutoplaceFields( SCH_SCREEN* aScreen, AUTOPLACE_ALGO aAlgo ) override;
538
539 void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction, RECURSE_MODE aMode ) override;
540
546 bool ResolveTextVar( wxString* token, int aDepth = 0 ) const;
547
548 void Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
549 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) override;
550
554 void PlotFields( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
555 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed );
556
563 void AddDrawItem( SCH_ITEM* aItem, bool aSort = true );
564
570 void RemoveDrawItem( SCH_ITEM* aItem );
571
572 void RemoveField( SCH_FIELD* aField ) { RemoveDrawItem( aField ); }
573
582 std::vector<const SCH_PIN*> GetGraphicalPins( int aUnit = 0, int aBodyStyle = 0 ) const;
583 std::vector<SCH_PIN*> GetGraphicalPins( int aUnit = 0, int aBodyStyle = 0 );
584
590 {
591 const SCH_PIN* pin;
592 wxString number;
593 };
594
599 std::vector<LOGICAL_PIN> GetLogicalPins( int aUnit, int aBodyStyle ) const;
600
602 {
603 wxString m_unitName;
604 std::vector<wxString> m_pinNumbers;
605 };
606
610 std::vector<UNIT_PIN_INFO> GetUnitPinInfo() const;
611
612 // Deprecated: use GetGraphicalPins(). This override remains to satisfy SYMBOL's pure virtual.
613 std::vector<SCH_PIN*> GetPins() const override;
614
618 int GetPinCount() override;
619
628 const SCH_PIN* GetPin( const wxString& aNumber, int aUnit = 0, int aBodyStyle = 0 ) const;
629
641 std::vector<SCH_PIN*> GetPinsByNumber( const wxString& aNumber, int aUnit = 0, int aBodyStyle = 0 );
642
654 bool PinsConflictWith( const LIB_SYMBOL& aOtherSymbol, bool aTestNums, bool aTestNames,
655 bool aTestType, bool aTestOrientation, bool aTestLength ) const;
656
662 void Move( const VECTOR2I& aOffset ) override;
663
670 bool HasLegacyAlternateBodyStyle() const;
671
676 int GetMaxPinNumber() const;
677
681 void ClearTempFlags() override;
682 void ClearEditFlags() override;
683
693 SCH_ITEM* LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint );
694
705 SCH_ITEM* LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I& aPoint,
706 const TRANSFORM& aTransform );
707
714 const LIB_ITEMS_CONTAINER& GetDrawItems() const { return m_drawings; }
715
720 void FixupDrawItems();
721
722 INSPECT_RESULT Visit( INSPECTOR inspector, void* testData,
723 const std::vector<KICAD_T>& aScanTypes ) override;
724
736 void SetUnitCount( int aCount, bool aDuplicateDrawItems );
737 int GetUnitCount() const override;
738
739 wxString GetUnitName( int aUnit ) const override
740 {
741 return GetUnitDisplayName( aUnit, true );
742 }
743
747 wxString GetUnitDisplayName( int aUnit, bool aLabel ) const override;
748
749 wxString GetBodyStyleDescription( int aBodyStyle, bool aLabel ) const override;
750
751 std::map<int, wxString>& GetUnitDisplayNames() { return m_unitDisplayNames; }
752 const std::map<int, wxString>& GetUnitDisplayNames() const { return m_unitDisplayNames; }
753
756
761 std::vector<std::set<wxString>>& JumperPinGroups() { return m_jumperPinGroups; }
762 const std::vector<std::set<wxString>>& JumperPinGroups() const { return m_jumperPinGroups; }
763
765 std::optional<const std::set<wxString>> GetJumperPinGroup( const wxString& aPinNumber ) const;
766
771 bool IsMultiUnit() const override { return m_unitCount > 1; }
772
773 static wxString LetterSubReference( int aUnit, wxChar aInitialLetter );
774
775 bool IsMultiBodyStyle() const override { return GetBodyStyleCount() > 1; }
776
777 int GetBodyStyleCount() const override
778 {
779 if( m_demorgan )
780 return 2;
781 else
782 return std::max( 1, (int) m_bodyStyleNames.size() );
783 }
784
785 bool HasDeMorganBodyStyles() const override { return m_demorgan; }
786 void SetHasDeMorganBodyStyles( bool aFlag ) { m_demorgan = aFlag; }
787
788 const std::vector<wxString>& GetBodyStyleNames() const { return m_bodyStyleNames; }
789 void SetBodyStyleNames( const std::vector<wxString>& aBodyStyleNames ) { m_bodyStyleNames = aBodyStyleNames; }
790
802 void SetBodyStyleCount( int aCount, bool aDuplicateDrawItems, bool aDuplicatePins );
803
813 int Compare( const LIB_SYMBOL& aRhs, int aCompareFlags = 0, REPORTER* aReporter = nullptr ) const;
814
815 const LIB_SYMBOL& operator=( const LIB_SYMBOL& aSymbol );
816
824 std::unique_ptr< LIB_SYMBOL > Flatten() const;
825
832 std::vector<struct LIB_SYMBOL_UNIT> GetUnitDrawItems();
833
844 std::vector<SCH_ITEM*> GetUnitDrawItems( int aUnit, int aBodyStyle );
845
852 double Similarity( const SCH_ITEM& aSymbol ) const override;
853
855
856 void SetParentName( const wxString& aParentName ) { m_parentName = aParentName; }
857 const wxString& GetParentName() const { return m_parentName; }
858
859#if defined(DEBUG)
860 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
861#endif
862
863private:
864 // We create a different set parent function for this class, so we hide the inherited one.
866
872 int compare( const SCH_ITEM& aOther, int aCompareFlags = SCH_ITEM::COMPARE_FLAGS::EQUALITY ) const override;
873
874 void deleteAllFields();
875
876 void cacheSearchTerms();
877 void cachePinCount();
879 void cacheChooserFields();
880
881private:
882 std::shared_ptr<LIB_SYMBOL> m_me;
883 std::weak_ptr<LIB_SYMBOL> m_parent;
884
885 wxString m_parentName;
886
890
894
898
900
902
904 wxString m_name;
905 wxString m_keyWords;
906 wxArrayString m_fpFilters;
908
911 std::vector<std::set<wxString> > m_jumperPinGroups;
912
916
917 std::map<int, wxString> m_unitDisplayNames;
918 std::vector<wxString> m_bodyStyleNames;
919
920 // Caches for things that are expensive to compute but required every time
921 // the symbol chooser or other library list is created
922
923 std::vector<SEARCH_TERM> m_searchTermsCache;
926 std::map<wxString, wxString> m_chooserFieldsCache;
927};
constexpr EDA_IU_SCALE schIUScale
Definition base_units.h:127
BOX2< VECTOR2I > BOX2I
Definition box2.h:922
const KIID m_Uuid
Definition eda_item.h:528
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:112
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:93
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:41
bool IsEmpty() const
EMBEDDED_FILES()=default
Class OUTLINE_FONT implements outline font drawing.
Definition kiid.h:48
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:83
std::vector< SEARCH_TERM > & GetSearchTerms() override
Definition lib_symbol.h:192
LIB_ITEMS_CONTAINER m_drawings
Definition lib_symbol.h:901
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:349
wxString GetDescription() const override
Definition lib_symbol.h:164
const LIB_ID & GetLibId() const override
Definition lib_symbol.h:152
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:179
void SetGlobalPower()
std::weak_ptr< LIB_SYMBOL > & GetParent()
Definition lib_symbol.h:114
wxString GetBodyStyleProp() const override
Definition lib_symbol.h:479
virtual ~LIB_SYMBOL()=default
LIBRENTRYOPTIONS m_options
Special symbol features such as POWER or NORMAL.
Definition lib_symbol.h:899
wxString GetRefProp() const
Definition lib_symbol.h:368
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:469
const std::map< int, wxString > & GetUnitDisplayNames() const
Definition lib_symbol.h:752
wxString m_shownDescriptionCache
Definition lib_symbol.h:925
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:156
wxString GetShownKeyWords(int aDepth=0) const override
bool UnitsLocked() const
Check whether symbol units are interchangeable.
Definition lib_symbol.h:287
SCH_FIELD & GetDatasheetField()
Return reference to the datasheet field.
Definition lib_symbol.h:345
void RefreshLibraryTreeCaches()
std::weak_ptr< LIB_SYMBOL > m_parent
Use for inherited symbols.
Definition lib_symbol.h:883
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
Definition lib_symbol.h:199
void SetExcludedFromBoardProp(bool aExclude)
Definition lib_symbol.h:515
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:572
std::map< int, wxString > m_unitDisplayNames
Definition lib_symbol.h:917
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:911
void ClearTempFlags() override
Clears the status flag all draw objects in this symbol.
void SetKeywordsProp(const wxString &aKeywords)
Definition lib_symbol.h:413
bool IsDerived() const
Definition lib_symbol.h:200
std::map< int, wxString > & GetUnitDisplayNames()
Definition lib_symbol.h:751
void SetDuplicatePinNumbersAreJumpers(bool aEnabled)
Definition lib_symbol.h:755
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:895
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:521
timestamp_t GetLastModDate() const
Definition lib_symbol.h:207
LIB_ID GetSourceLibId() const
Definition lib_symbol.h:155
void SetLib(LEGACY_SYMBOL_LIB *aLibrary)
bool GetPowerSymbolProp() const
Definition lib_symbol.h:418
bool IsMultiBodyStyle() const override
Definition lib_symbol.h:775
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:97
std::vector< SEARCH_TERM > m_searchTermsCache
Definition lib_symbol.h:923
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:237
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:359
bool IsPowerSymbol() const override
For symbols that could be a power symbol.
Definition lib_symbol.h:271
SCH_FIELD & GetFootprintField()
Return reference to the footprint field.
Definition lib_symbol.h:341
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:789
bool IsNormal() const override
wxString m_name
Definition lib_symbol.h:904
void SetUnitsInterchangeableProp(bool aInterchangeable)
Definition lib_symbol.h:474
std::set< KIFONT::OUTLINE_FONT * > GetFonts() const override
LEGACY_SYMBOL_LIB * m_library
Definition lib_symbol.h:903
static bool ClassOf(const EDA_ITEM *aItem)
Definition lib_symbol.h:139
bool GetExcludedFromPosFilesProp() const
Definition lib_symbol.h:520
SCH_FIELD * FindFieldCaseInsensitive(const wxString &aFieldName)
const std::vector< std::set< wxString > > & JumperPinGroups() const
Definition lib_symbol.h:762
wxString m_keyWords
Search keywords.
Definition lib_symbol.h:905
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:204
wxString GetDatasheetProp() const
Definition lib_symbol.h:398
void LockUnits(bool aLockUnits)
Set interchangeable the property for symbol units.
Definition lib_symbol.h:281
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition lib_symbol.h:713
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:373
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:739
wxString GetName() const override
Definition lib_symbol.h:145
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:882
wxString GetValueProp() const
Definition lib_symbol.h:378
bool GetExcludedFromBOMProp() const
Definition lib_symbol.h:500
void SetKeyWords(const wxString &aKeyWords)
SCH_FIELD & GetValueField()
Return reference to the value field.
Definition lib_symbol.h:333
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:459
wxArrayString GetFPFilters() const
Definition lib_symbol.h:211
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:92
bool GetPinNamesInsideProp() const
Definition lib_symbol.h:446
void SetHasDeMorganBodyStyles(bool aFlag)
Definition lib_symbol.h:786
const std::vector< wxString > & GetBodyStyleNames() const
Definition lib_symbol.h:788
void SetBodyStyleProp(const wxString &aBodyStyle) override
Definition lib_symbol.h:484
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:889
void SetExcludedFromSimProp(bool aExclude)
Definition lib_symbol.h:495
bool GetExcludedFromBoardProp() const
Definition lib_symbol.h:510
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:887
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:150
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:158
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:393
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:785
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:892
wxArrayString m_fpFilters
List of suitable footprint names for the symbol (wild card names accepted).
Definition lib_symbol.h:906
void Move(const VECTOR2I &aOffset) override
Move the symbol aOffset.
void SetFPFilters(const wxArrayString &aFilters)
Definition lib_symbol.h:209
bool IsMultiUnit() const override
Definition lib_symbol.h:771
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:490
int GetBodyStyleCount() const override
Definition lib_symbol.h:777
void SetDatasheetProp(const wxString &aDatasheet)
Definition lib_symbol.h:403
wxString GetDesc() override
Definition lib_symbol.h:148
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:354
EMBEDDED_FILES * GetEmbeddedFiles() override
void SetPowerSymbolProp(bool aIsPower)
Definition lib_symbol.h:423
void AddField(SCH_FIELD &aField)
Definition lib_symbol.h:313
void SetExcludedFromBOMProp(bool aExclude)
Definition lib_symbol.h:505
int m_unitCount
Number of units (parts) per package.
Definition lib_symbol.h:891
wxString GetShownDescription(int aDepth=0) const override
virtual wxString GetClass() const override
Return the class name.
Definition lib_symbol.h:134
bool IsGlobalPower() const override
LIB_ID m_sourceLibId
For database library symbols; the original symbol.
Definition lib_symbol.h:888
wxString GetBodyStyleDescription(int aBodyStyle, bool aLabel) const override
const wxString & GetParentName() const
Definition lib_symbol.h:857
unsigned GetInheritanceDepth() const
Get the number of parents for this symbol.
int GetUnitCount() const override
wxString GetKeywordsProp() const
Definition lib_symbol.h:408
std::vector< wxString > m_bodyStyleNames
Definition lib_symbol.h:918
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:255
void SetValueProp(const wxString &aValue)
Definition lib_symbol.h:383
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:260
void SetParentName(const wxString &aParentName)
Definition lib_symbol.h:856
std::map< wxString, wxString > m_chooserFieldsCache
Definition lib_symbol.h:926
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:924
bool GetLocalPowerSymbolProp() const
Definition lib_symbol.h:431
bool GetDuplicatePinNumbersAreJumpers() const
Definition lib_symbol.h:754
void deleteAllFields()
LIB_ID GetLIB_ID() const override
Definition lib_symbol.h:147
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:915
void SetUnitProp(int aUnits)
Definition lib_symbol.h:464
wxString GetFootprintProp() const
Definition lib_symbol.h:388
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:761
void SetPinNamesInsideProp(bool aInside)
Definition lib_symbol.h:451
const std::weak_ptr< LIB_SYMBOL > & GetParent() const
Definition lib_symbol.h:115
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:885
void EmbedFonts() override
void SetLocalPowerSymbolProp(bool aIsLocalPower)
Definition lib_symbol.h:436
virtual void SetName(const wxString &aName)
void SetNormal()
SCH_FIELD & GetReferenceField()
Return reference to the reference designator field.
Definition lib_symbol.h:337
const LIB_ITEMS_CONTAINER & GetDrawItems() const
Definition lib_symbol.h:714
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:66
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:295
Base plotter engine class.
Definition plotter.h:137
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:75
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:126
void SetText(const wxString &aText) override
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:168
friend class LIB_SYMBOL
Definition sch_item.h:803
SCH_ITEM(EDA_ITEM *aParent, KICAD_T aType, int aUnit=0, int aBodyStyle=0)
Definition sch_item.cpp:56
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
bool GetExcludedFromPosFiles(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Definition symbol.h:231
void SetExcludedFromBoard(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear exclude from board netlist flag.
Definition symbol.h:210
SYMBOL(KICAD_T idType)
Definition symbol.h:65
int m_previewBodyStyle
Definition symbol.h:281
int GetPinNameOffset() const
Definition symbol.h:163
virtual void SetExcludedFromSim(bool aExcludeFromSim, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from simulation flag.
Definition symbol.h:180
virtual bool GetExcludedFromBOM(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Definition symbol.h:201
void SetPinNameOffset(int aOffset)
Set the offset in mils of the pin name text from the pin symbol.
Definition symbol.h:162
bool GetExcludedFromBoard(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Definition symbol.h:216
void SetExcludedFromPosFiles(bool aExclude, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear exclude from position files flag.
Definition symbol.h:225
virtual bool GetExcludedFromSim(const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) const override
Definition symbol.h:186
int m_previewUnit
Definition symbol.h:280
virtual void SetExcludedFromBOM(bool aExcludeFromBOM, const SCH_SHEET_PATH *aInstance=nullptr, const wxString &aVariantName=wxEmptyString) override
Set or clear the exclude from schematic bill of materials flag.
Definition symbol.h:195
for transforming drawing coordinates for a wxDC device context.
Definition transform.h:46
#define DEFAULT_PIN_NAME_OFFSET
The intersheets references prefix string.
RECURSE_MODE
Definition eda_item.h:52
INSPECT_RESULT
Definition eda_item.h:46
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition eda_item.h:93
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:45
LIBRENTRYOPTIONS
Definition lib_symbol.h:58
@ ENTRY_NORMAL
Definition lib_symbol.h:59
@ ENTRY_LOCAL_POWER
Definition lib_symbol.h:61
@ ENTRY_GLOBAL_POWER
Definition lib_symbol.h:60
MULTIVECTOR< SCH_ITEM, SCH_SHAPE_T, SCH_PIN_T > LIB_ITEMS_CONTAINER
Definition lib_symbol.h:52
LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS
Definition lib_symbol.h:53
bool operator<(const LIB_SYMBOL &aItem1, const LIB_SYMBOL &aItem2)
AUTOPLACE_ALGO
Definition sch_item.h:69
Logical pins: Return expanded logical pins based on stacked-pin notation.
Definition lib_symbol.h:590
wxString number
expanded logical pin number
Definition lib_symbol.h:592
const SCH_PIN * pin
pointer to the base graphical pin
Definition lib_symbol.h:591
std::vector< wxString > m_pinNumbers
Definition lib_symbol.h:604
int m_bodyStyle
The alternate body style of the unit.
Definition lib_symbol.h:71
std::vector< SCH_ITEM * > m_items
The items unique to this unit and alternate body style.
Definition lib_symbol.h:72
int m_unit
The unit number.
Definition lib_symbol.h:70
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:75
@ LIB_SYMBOL_T
Definition typeinfo.h:149
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:687