KiCad PCB EDA Suite
Loading...
Searching...
No Matches
lib_symbol.cpp
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#include <font/outline_font.h>
28#include <sch_draw_panel.h>
29#include <plotters/plotter.h>
30#include <sch_screen.h>
31#include <template_fieldnames.h>
32#include <transform.h>
33#include <symbol_library.h>
35#include <sch_pin.h>
36#include <sch_shape.h>
37
38#include <memory>
39
40std::vector<SEARCH_TERM> LIB_SYMBOL::GetSearchTerms()
41{
42 std::vector<SEARCH_TERM> terms;
43
44 terms.emplace_back( SEARCH_TERM( GetName(), 8 ) );
45
46 wxStringTokenizer keywordTokenizer( GetKeyWords(), wxS( " " ), wxTOKEN_STRTOK );
47
48 while( keywordTokenizer.HasMoreTokens() )
49 terms.emplace_back( SEARCH_TERM( keywordTokenizer.GetNextToken(), 4 ) );
50
51 // TODO(JE) rework this later so we can highlight matches in their column
52 std::map<wxString, wxString> fields;
53 GetChooserFields( fields );
54
55 for( const auto& [ name, text ] : fields )
56 terms.emplace_back( SEARCH_TERM( text, 4 ) );
57
58 // Also include keywords as one long string, just in case
59 terms.emplace_back( SEARCH_TERM( GetKeyWords(), 1 ) );
60 terms.emplace_back( SEARCH_TERM( GetDescription(), 1 ) );
61
62 wxString footprint = GetFootprint();
63
64 if( !footprint.IsEmpty() )
65 terms.emplace_back( SEARCH_TERM( GetFootprintField().GetText(), 1 ) );
66
67 return terms;
68}
69
70
71void LIB_SYMBOL::GetChooserFields( std::map<wxString, wxString>& aColumnMap )
72{
73 for( SCH_ITEM& item : m_drawings[ SCH_FIELD_T ] )
74 {
75 SCH_FIELD* field = static_cast<SCH_FIELD*>( &item );
76
77 if( field->ShowInChooser() )
78 aColumnMap[field->GetName()] = field->EDA_TEXT::GetShownText( false );
79 }
80}
81
82
83bool operator<( const LIB_SYMBOL& aItem1, const LIB_SYMBOL& aItem2 )
84{
85 return aItem1.GetName() < aItem2.GetName();
86}
87
88
91{
92 void operator()(void const *) const
93 {
94 }
95};
96
97
98LIB_SYMBOL::LIB_SYMBOL( const wxString& aName, LIB_SYMBOL* aParent, SYMBOL_LIB* aLibrary ) :
100 m_me( this, null_deleter() )
101{
102 m_lastModDate = 0;
103 m_unitCount = 1;
106 m_unitsLocked = false;
107
108 auto addField =
109 [&]( FIELD_T id, bool visible )
110 {
111 SCH_FIELD* field = new SCH_FIELD( this, id );
112 field->SetVisible( visible );
114 };
115
116 // construct only the mandatory fields
117 addField( FIELD_T::REFERENCE, true );
118 addField( FIELD_T::VALUE, true );
119 addField( FIELD_T::FOOTPRINT, false );
120 addField( FIELD_T::DATASHEET, false );
121 addField( FIELD_T::DESCRIPTION, false );
122
123 SetName( aName );
124
125 if( aParent )
126 SetParent( aParent );
127
128 SetLib( aLibrary );
129}
130
131
132LIB_SYMBOL::LIB_SYMBOL( const LIB_SYMBOL& aSymbol, SYMBOL_LIB* aLibrary ) :
133 SYMBOL( aSymbol ),
134 EMBEDDED_FILES( aSymbol ),
135 m_me( this, null_deleter() )
136{
137 m_library = aLibrary;
138 m_name = aSymbol.m_name;
139 m_fpFilters = wxArrayString( aSymbol.m_fpFilters );
140 m_unitCount = aSymbol.m_unitCount;
143 m_options = aSymbol.m_options;
144 m_libId = aSymbol.m_libId;
145 m_keyWords = aSymbol.m_keyWords;
146
148
150
151 for( const SCH_ITEM& oldItem : aSymbol.m_drawings )
152 {
153 if( ( oldItem.GetFlags() & ( IS_NEW | STRUCT_DELETED ) ) != 0 )
154 continue;
155
156 try
157 {
158 SCH_ITEM* newItem = (SCH_ITEM*) oldItem.Clone();
159 newItem->ClearSelected();
160 newItem->SetParent( this );
161 m_drawings.push_back( newItem );
162 }
163 catch( ... )
164 {
165 wxFAIL_MSG( "Failed to clone SCH_ITEM." );
166 return;
167 }
168 }
169
170 LIB_SYMBOL_SPTR parent = aSymbol.m_parent.lock();
171
172 if( parent )
173 SetParent( parent.get() );
174}
175
176
178{
179 if( &aSymbol == this )
180 return aSymbol;
181
182 SYMBOL::operator=( aSymbol );
183
184 m_library = aSymbol.m_library;
185 m_name = aSymbol.m_name;
186 m_fpFilters = wxArrayString( aSymbol.m_fpFilters );
187 m_unitCount = aSymbol.m_unitCount;
190 m_options = aSymbol.m_options;
191 m_libId = aSymbol.m_libId;
192 m_keyWords = aSymbol.m_keyWords;
193
194 m_unitDisplayNames.clear();
196
198
199 for( const SCH_ITEM& oldItem : aSymbol.m_drawings )
200 {
201 if( ( oldItem.GetFlags() & ( IS_NEW | STRUCT_DELETED ) ) != 0 )
202 continue;
203
204 SCH_ITEM* newItem = (SCH_ITEM*) oldItem.Clone();
205 newItem->SetParent( this );
206 m_drawings.push_back( newItem );
207 }
208
210
211 LIB_SYMBOL_SPTR parent = aSymbol.m_parent.lock();
212
213 if( parent )
214 SetParent( parent.get() );
215
216 EMBEDDED_FILES::operator=( aSymbol );
217
218 return *this;
219}
220
221
228{
229 static LIB_SYMBOL* symbol;
230
231 if( !symbol )
232 {
233 symbol = new LIB_SYMBOL( wxEmptyString );
234
235 SCH_SHAPE* square = new SCH_SHAPE( SHAPE_T::RECTANGLE, LAYER_DEVICE );
236
237 square->SetPosition( VECTOR2I( schIUScale.MilsToIU( -200 ), schIUScale.MilsToIU( 200 ) ) );
238 square->SetEnd( VECTOR2I( schIUScale.MilsToIU( 200 ), schIUScale.MilsToIU( -200 ) ) );
239 symbol->AddDrawItem( square );
240
241 SCH_TEXT* text = new SCH_TEXT( { 0, 0 }, wxT( "??" ), LAYER_DEVICE );
242
243 text->SetTextSize( VECTOR2I( schIUScale.MilsToIU( 150 ), schIUScale.MilsToIU( 150 ) ) );
244 symbol->AddDrawItem( text );
245 }
246
247 return symbol;
248}
249
250
252{
253 unsigned depth = 0;
254
255 LIB_SYMBOL_SPTR parent = GetParent().lock();
256
257 while( parent )
258 {
259 depth += 1;
260 parent = parent->GetParent().lock();
261 }
262
263 return depth;
264}
265
266
268{
269 const LIB_SYMBOL_SPTR sp = m_parent.lock();
270
271 // Recurse until the parent symbol is empty.
272 if( sp )
273 return sp->GetRootSymbol();
274
275 return m_me;
276}
277
278
279wxString LIB_SYMBOL::GetUnitReference( int aUnit )
280{
281 return LIB_SYMBOL::LetterSubReference( aUnit, 'A' );
282}
283
284
286{
287 return ( m_unitDisplayNames.count( aUnit ) == 1 );
288}
289
290
292{
293 if( HasUnitDisplayName( aUnit ) )
294 return m_unitDisplayNames[aUnit];
295 else
296 return wxString::Format( _( "Unit %s" ), GetUnitReference( aUnit ) );
297}
298
299
300void LIB_SYMBOL::CopyUnitDisplayNames( std::map<int, wxString>& aTarget ) const
301{
302 for( const auto& it : m_unitDisplayNames )
303 aTarget[it.first] = it.second;
304}
305
306
307void LIB_SYMBOL::SetUnitDisplayName( int aUnit, const wxString& aName )
308{
309 if( aUnit <= GetUnitCount() )
310 {
311 if( aName.Length() > 0 )
312 m_unitDisplayNames[aUnit] = aName;
313 else
314 m_unitDisplayNames.erase( aUnit );
315 }
316}
317
318
319void LIB_SYMBOL::SetName( const wxString& aName )
320{
321 m_name = aName;
322 m_libId.SetLibItemName( aName );
323}
324
325
327{
328 if( aParent )
329 m_parent = aParent->SharedPtr();
330 else
331 m_parent.reset();
332}
333
334
335std::unique_ptr< LIB_SYMBOL > LIB_SYMBOL::Flatten() const
336{
337 std::unique_ptr< LIB_SYMBOL > retv;
338
339 if( IsDerived() )
340 {
341 LIB_SYMBOL_SPTR parent = m_parent.lock();
342
343 wxCHECK_MSG( parent, retv,
344 wxString::Format( "Parent of derived symbol '%s' undefined", m_name ) );
345
346 // Copy the parent.
347 if( parent->IsDerived() )
348 retv = parent->Flatten();
349 else
350 retv = std::make_unique<LIB_SYMBOL>( *parent.get() );
351
352 retv->m_name = m_name;
353 retv->SetLibId( m_libId );
354
355 // Overwrite parent's mandatory fields for fields which are defined in this.
356 for( FIELD_T fieldId : MANDATORY_FIELDS )
357 {
358 if( !GetField( fieldId )->GetText().IsEmpty() )
359 *retv->GetField( fieldId ) = *GetField( fieldId );
360 }
361
362 // Grab all the rest of derived symbol fields.
363 for( const SCH_ITEM& item : m_drawings[ SCH_FIELD_T ] )
364 {
365 const SCH_FIELD* field = static_cast<const SCH_FIELD*>( &item );
366
367 // Mandatory fields were already resolved.
368 if( field->IsMandatory() )
369 continue;
370
371 SCH_FIELD* newField = new SCH_FIELD( *field );
372 newField->SetParent( retv.get() );
373
374 SCH_FIELD* parentField = retv->GetField( field->GetName() );
375
376 if( !parentField ) // Derived symbol field does not exist in parent symbol.
377 {
378 retv->AddDrawItem( newField );
379 }
380 else // Derived symbol field overrides the parent symbol field.
381 {
382 retv->RemoveDrawItem( parentField );
383 retv->AddDrawItem( newField );
384 }
385 }
386
387 retv->SetKeyWords( m_keyWords.IsEmpty() ? parent->GetKeyWords() : m_keyWords );
388 retv->SetFPFilters( m_fpFilters.IsEmpty() ? parent->GetFPFilters() : m_fpFilters );
389
390 retv->SetExcludedFromSim( parent->GetExcludedFromSim() );
391 retv->SetExcludedFromBOM( parent->GetExcludedFromBOM() );
392 retv->SetExcludedFromBoard( parent->GetExcludedFromBoard() );
393
394 retv->m_parent.reset();
395 }
396 else
397 {
398 retv = std::make_unique<LIB_SYMBOL>( *this );
399 }
400
401 return retv;
402}
403
404
405const wxString LIB_SYMBOL::GetLibraryName() const
406{
407 if( m_library )
408 return m_library->GetName();
409
410 return m_libId.GetLibNickname();
411}
412
413
415{
416 std::shared_ptr<LIB_SYMBOL> parent;
417
418 if( !m_parent.expired() && ( parent = m_parent.lock() ) )
419 {
420 if( parent->IsRoot() )
421 return parent->m_options == ENTRY_LOCAL_POWER;
422 else
423 return parent->IsLocalPower();
424 }
425
427}
428
429
431{
432 if( LIB_SYMBOL_SPTR parent = m_parent.lock() )
433 {
434 if( parent->IsRoot() )
435 parent->m_options = ENTRY_LOCAL_POWER;
436 else
437 parent->SetLocalPower();
438 }
439
441}
442
443
445{
446 std::shared_ptr<LIB_SYMBOL> parent;
447
448 if( !m_parent.expired() && ( parent = m_parent.lock() ) )
449 {
450 if( parent->IsRoot() )
451 return parent->m_options == ENTRY_GLOBAL_POWER;
452 else
453 return parent->IsGlobalPower();
454 }
455
457}
458
459
461{
462 return IsLocalPower() || IsGlobalPower();
463}
464
465
467{
468 if( LIB_SYMBOL_SPTR parent = m_parent.lock() )
469 {
470 if( parent->IsRoot() )
471 parent->m_options = ENTRY_GLOBAL_POWER;
472 else
473 parent->SetGlobalPower();
474 }
475
477}
478
479
481{
482 if( LIB_SYMBOL_SPTR parent = m_parent.lock() )
483 {
484 if( parent->IsRoot() )
485 return parent->m_options == ENTRY_NORMAL;
486 else
487 return parent->IsNormal();
488 }
489
490 return m_options == ENTRY_NORMAL;
491}
492
493
495{
496 if( LIB_SYMBOL_SPTR parent = m_parent.lock() )
497 {
498 if( parent->IsRoot() )
499 parent->m_options = ENTRY_NORMAL;
500 else
501 parent->SetNormal();
502 }
503
505}
506
507
508wxString LIB_SYMBOL::LetterSubReference( int aUnit, int aFirstId )
509{
510 // use letters as notation. To allow more than 26 units, the sub ref
511 // use one letter if letter = A .. Z or a ... z, and 2 letters otherwise
512 // first letter is expected to be 'A' or 'a' (i.e. 26 letters are available)
513 int u;
514 wxString suffix;
515
516 do
517 {
518 u = ( aUnit - 1 ) % 26;
519 suffix = wxChar( aFirstId + u ) + suffix;
520 aUnit = ( aUnit - u ) / 26;
521 } while( aUnit > 0 );
522
523 return suffix;
524}
525
526
527bool LIB_SYMBOL::ResolveTextVar( wxString* token, int aDepth ) const
528{
529 wxString footprint;
530
531 for( const SCH_ITEM& item : m_drawings )
532 {
533 if( item.Type() == SCH_FIELD_T )
534 {
535 const SCH_FIELD& field = static_cast<const SCH_FIELD&>( item );
536
537 if( field.GetId() == FIELD_T::FOOTPRINT )
538 footprint = field.GetShownText( nullptr, false, aDepth + 1 );
539
540 if( token->IsSameAs( field.GetCanonicalName().Upper() )
541 || token->IsSameAs( field.GetName(), false ) )
542 {
543 *token = field.GetShownText( nullptr, false, aDepth + 1 );
544 return true;
545 }
546 }
547 }
548
549 // Consider missing simulation fields as empty, not un-resolved
550 if( token->IsSameAs( wxT( "SIM.DEVICE" ) )
551 || token->IsSameAs( wxT( "SIM.TYPE" ) )
552 || token->IsSameAs( wxT( "SIM.PINS" ) )
553 || token->IsSameAs( wxT( "SIM.PARAMS" ) )
554 || token->IsSameAs( wxT( "SIM.LIBRARY" ) )
555 || token->IsSameAs( wxT( "SIM.NAME" ) ) )
556 {
557 *token = wxEmptyString;
558 return true;
559 }
560
561 if( token->IsSameAs( wxT( "FOOTPRINT_LIBRARY" ) ) )
562 {
563 wxArrayString parts = wxSplit( footprint, ':' );
564
565 if( parts.Count() > 0 )
566 *token = parts[ 0 ];
567 else
568 *token = wxEmptyString;
569
570 return true;
571 }
572 else if( token->IsSameAs( wxT( "FOOTPRINT_NAME" ) ) )
573 {
574 wxArrayString parts = wxSplit( footprint, ':' );
575
576 if( parts.Count() > 1 )
577 *token = parts[ std::min( 1, (int) parts.size() - 1 ) ];
578 else
579 *token = wxEmptyString;
580
581 return true;
582 }
583 else if( token->IsSameAs( wxT( "SYMBOL_LIBRARY" ) ) )
584 {
586 return true;
587 }
588 else if( token->IsSameAs( wxT( "SYMBOL_NAME" ) ) )
589 {
591 return true;
592 }
593 else if( token->IsSameAs( wxT( "SYMBOL_DESCRIPTION" ) ) )
594 {
595 *token = GetDescription();
596 return true;
597 }
598 else if( token->IsSameAs( wxT( "SYMBOL_KEYWORDS" ) ) )
599 {
600 *token = GetKeyWords();
601 return true;
602 }
603 else if( token->IsSameAs( wxT( "EXCLUDE_FROM_BOM" ) ) )
604 {
605 *token = this->GetExcludedFromBOM() ? _( "Excluded from BOM" ) : wxString( "" );
606 return true;
607 }
608 else if( token->IsSameAs( wxT( "EXCLUDE_FROM_BOARD" ) ) )
609 {
610 *token = this->GetExcludedFromBoard() ? _( "Excluded from board" ) : wxString( "" );
611 return true;
612 }
613 else if( token->IsSameAs( wxT( "EXCLUDE_FROM_SIM" ) ) )
614 {
615 *token = this->GetExcludedFromSim() ? _( "Excluded from simulation" ) : wxString( "" );
616 return true;
617 }
618 else if( token->IsSameAs( wxT( "DNP" ) ) )
619 {
620 *token = this->GetDNP() ? _( "DNP" ) : wxString( "" );
621 return true;
622 }
623
624 return false;
625}
626
627
628void LIB_SYMBOL::Plot( PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
629 int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed )
630{
631 wxASSERT( aPlotter != nullptr );
632
633 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
634 COLOR4D color = renderSettings->GetLayerColor( LAYER_DEVICE );
635 COLOR4D bg = renderSettings->GetBackgroundColor();
636
637 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
638 bg = COLOR4D::WHITE;
639
640 if( aDimmed )
641 {
642 color.Desaturate( );
643 color = color.Mix( bg, 0.5f );
644 }
645
646 aPlotter->SetColor( color );
647
648 for( SCH_ITEM& item : m_drawings )
649 {
650 // Do not plot private items
651 if( item.IsPrivate() )
652 continue;
653
654 // LIB_FIELDs are not plotted here, because this plot function is used to plot schematic
655 // items which have their own SCH_FIELDs
656 if( item.Type() == SCH_FIELD_T )
657 continue;
658
659 if( aUnit && item.m_unit && ( item.m_unit != aUnit ) )
660 continue;
661
662 if( aBodyStyle && item.m_bodyStyle && ( item.m_bodyStyle != aBodyStyle ) )
663 continue;
664
665 item.Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
666 }
667}
668
669
670void LIB_SYMBOL::PlotFields( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts,
671 int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed )
672{
673 wxASSERT( aPlotter != nullptr );
674
675 SCH_RENDER_SETTINGS* renderSettings = getRenderSettings( aPlotter );
676 COLOR4D color = renderSettings->GetLayerColor( LAYER_FIELDS );
677 COLOR4D bg = renderSettings->GetBackgroundColor();
678
679 if( bg == COLOR4D::UNSPECIFIED || !aPlotter->GetColorMode() )
680 bg = COLOR4D::WHITE;
681
682 if( aDimmed )
683 {
684 color.Desaturate( );
685 color = color.Mix( bg, 0.5f );
686 }
687
688 aPlotter->SetColor( color );
689
690 for( SCH_ITEM& item : m_drawings[ SCH_FIELD_T ] )
691 {
692 SCH_FIELD& field = static_cast<SCH_FIELD&>( item );
693
694 if( !renderSettings->m_ShowHiddenFields && !field.IsVisible() )
695 continue;
696
697 // The reference is a special case: we should change the basic text
698 // to add '?' and the part id
699 wxString tmp = field.GetText();
700
701 field.SetText( field.GetFullText( aUnit ) );
702 item.Plot( aPlotter, aBackground, aPlotOpts, aUnit, aBodyStyle, aOffset, aDimmed );
703
704 field.SetText( tmp );
705 }
706}
707
708
710{
711 std::vector<SCH_SHAPE*> potential_top_items;
712 std::vector<SCH_ITEM*> bottom_items;
713
714 for( SCH_ITEM& item : m_drawings )
715 {
716 if( item.Type() == SCH_SHAPE_T )
717 {
718 SCH_SHAPE& shape = static_cast<SCH_SHAPE&>( item );
719
720 if( shape.GetFillMode() == FILL_T::FILLED_WITH_COLOR )
721 potential_top_items.push_back( &shape );
722 else
723 bottom_items.push_back( &item );
724 }
725 else
726 {
727 bottom_items.push_back( &item );
728 }
729 }
730
731 std::sort( potential_top_items.begin(), potential_top_items.end(),
732 []( SCH_ITEM* a, SCH_ITEM* b )
733 {
734 return a->GetBoundingBox().GetArea() > b->GetBoundingBox().GetArea();
735 } );
736
737 for( SCH_SHAPE* item : potential_top_items )
738 {
739 for( SCH_ITEM* bottom_item : bottom_items )
740 {
741 if( item->GetBoundingBox().Contains( bottom_item->GetBoundingBox() ) )
742 {
743 item->SetFillMode( FILL_T::FILLED_WITH_BG_BODYCOLOR );
744 break;
745 }
746 }
747 }
748}
749
750
752{
753 wxASSERT( aItem != nullptr );
754
755 // none of the MANDATORY_FIELDS may be removed in RAM, but they may be
756 // omitted when saving to disk.
757 if( aItem->Type() == SCH_FIELD_T )
758 {
759 if( static_cast<SCH_FIELD*>( aItem )->IsMandatory() )
760 return;
761 }
762
763 LIB_ITEMS& items = m_drawings[ aItem->Type() ];
764
765 for( LIB_ITEMS::iterator i = items.begin(); i != items.end(); i++ )
766 {
767 if( &*i == aItem )
768 {
769 items.erase( i );
770 break;
771 }
772 }
773}
774
775
776void LIB_SYMBOL::AddDrawItem( SCH_ITEM* aItem, bool aSort )
777{
778 if( aItem )
779 {
780 aItem->SetParent( this );
781
782 m_drawings.push_back( aItem );
783
784 if( aSort )
786 }
787}
788
789
790std::vector<SCH_PIN*> LIB_SYMBOL::GetPins( int aUnit, int aBodyStyle ) const
791{
792 std::vector<SCH_PIN*> pins;
793
794 /* Notes:
795 * when aUnit == 0: no unit filtering
796 * when aBodyStyle == 0: no body style filtering
797 * when m_unit == 0, the item is common to all units
798 * when m_bodyStyle == 0, the item is common to all body styles
799 */
800
801 LIB_SYMBOL_SPTR parent = m_parent.lock();
802 const LIB_ITEMS_CONTAINER& drawItems = parent ? parent->m_drawings : m_drawings;
803
804 for( const SCH_ITEM& item : drawItems[SCH_PIN_T] )
805 {
806 // Unit filtering:
807 if( aUnit && item.m_unit && ( item.m_unit != aUnit ) )
808 continue;
809
810 // De Morgan variant filtering:
811 if( aBodyStyle && item.m_bodyStyle && ( item.m_bodyStyle != aBodyStyle ) )
812 continue;
813
814 // TODO: get rid of const_cast. (It used to be a C-style cast so was less noticeable.)
815 pins.push_back( const_cast<SCH_PIN*>( static_cast<const SCH_PIN*>( &item ) ) );
816 }
817
818 return pins;
819}
820
821
822std::vector<SCH_PIN*> LIB_SYMBOL::GetPins() const
823{
824 return GetPins( 0, 0 );
825}
826
827
829{
830 return (int) GetPins( 0 /* all units */, 1 /* single body style */ ).size();
831}
832
833
834SCH_PIN* LIB_SYMBOL::GetPin( const wxString& aNumber, int aUnit, int aBodyStyle ) const
835{
836 for( SCH_PIN* pin : GetPins( aUnit, aBodyStyle ) )
837 {
838 if( aNumber == pin->GetNumber() )
839 return pin;
840 }
841
842 return nullptr;
843}
844
845
846bool LIB_SYMBOL::PinsConflictWith( const LIB_SYMBOL& aOtherPart, bool aTestNums, bool aTestNames,
847 bool aTestType, bool aTestOrientation, bool aTestLength ) const
848{
849 for( const SCH_PIN* pin : GetPins() )
850 {
851 wxASSERT( pin );
852 bool foundMatch = false;
853
854 for( const SCH_PIN* otherPin : aOtherPart.GetPins() )
855 {
856 wxASSERT( otherPin );
857
858 // Same unit?
859 if( pin->GetUnit() != otherPin->GetUnit() )
860 continue;
861
862 // Same body stype?
863 if( pin->GetBodyStyle() != otherPin->GetBodyStyle() )
864 continue;
865
866 // Same position?
867 if( pin->GetPosition() != otherPin->GetPosition() )
868 continue;
869
870 // Same number?
871 if( aTestNums && ( pin->GetNumber() != otherPin->GetNumber() ) )
872 continue;
873
874 // Same name?
875 if( aTestNames && ( pin->GetName() != otherPin->GetName() ) )
876 continue;
877
878 // Same electrical type?
879 if( aTestType && ( pin->GetType() != otherPin->GetType() ) )
880 continue;
881
882 // Same orientation?
883 if( aTestOrientation
884 && ( pin->GetOrientation() != otherPin->GetOrientation() ) )
885 continue;
886
887 // Same length?
888 if( aTestLength && ( pin->GetLength() != otherPin->GetLength() ) )
889 continue;
890
891 foundMatch = true;
892 break; // Match found so search is complete.
893 }
894
895 if( !foundMatch )
896 {
897 // This means there was not an identical (according to the arguments)
898 // pin at the same position in the other symbol.
899 return true;
900 }
901 }
902
903 // The loop never gave up, so no conflicts were found.
904 return false;
905}
906
907
908const BOX2I LIB_SYMBOL::GetUnitBoundingBox( int aUnit, int aBodyStyle,
909 bool aIgnoreHiddenFields ) const
910{
911 BOX2I bBox; // Start with a fresh BOX2I so the Merge algorithm works
912
913 for( const SCH_ITEM& item : m_drawings )
914 {
915 if( item.m_unit > 0 && m_unitCount > 1 && aUnit > 0 && aUnit != item.m_unit )
916 continue;
917
918 if( item.m_bodyStyle > 0 && aBodyStyle > 0 && aBodyStyle != item.m_bodyStyle )
919 continue;
920
921 if( aIgnoreHiddenFields && item.Type() == SCH_FIELD_T )
922 {
923 if( !static_cast<const SCH_FIELD&>( item ).IsVisible() )
924 continue;
925 }
926
927 bBox.Merge( item.GetBoundingBox() );
928 }
929
930 return bBox;
931}
932
933
934const BOX2I LIB_SYMBOL::GetBodyBoundingBox( int aUnit, int aBodyStyle, bool aIncludePins,
935 bool aIncludePrivateItems ) const
936{
937 BOX2I bbox;
938
939 for( const SCH_ITEM& item : m_drawings )
940 {
941 if( item.m_unit > 0 && aUnit > 0 && aUnit != item.m_unit )
942 continue;
943
944 if( item.m_bodyStyle > 0 && aBodyStyle > 0 && aBodyStyle != item.m_bodyStyle )
945 continue;
946
947 if( item.IsPrivate() && !aIncludePrivateItems )
948 continue;
949
950 if( item.Type() == SCH_FIELD_T )
951 continue;
952
953 if( item.Type() == SCH_PIN_T )
954 {
955 const SCH_PIN& pin = static_cast<const SCH_PIN&>( item );
956
957 if( pin.IsVisible() )
958 {
959 // Note: the roots of the pins are always included for symbols that don't have
960 // a well-defined body.
961
962 if( aIncludePins )
963 bbox.Merge( pin.GetBoundingBox( false, false, false ) );
964 else
965 bbox.Merge( pin.GetPinRoot() );
966 }
967 }
968 else
969 {
970 bbox.Merge( item.GetBoundingBox() );
971 }
972 }
973
974 return bbox;
975}
976
977
979{
981}
982
983
985{
986 AddDrawItem( aField );
987}
988
989
990void LIB_SYMBOL::SetFields( const std::vector<SCH_FIELD>& aFieldsList )
991{
993
994 for( const SCH_FIELD& src : aFieldsList )
995 {
996 // drawings is a ptr_vector, new and copy an object on the heap.
997 SCH_FIELD* field = new SCH_FIELD( src );
998
999 field->SetParent( this );
1000 m_drawings.push_back( field );
1001 }
1002
1003 m_drawings.sort();
1004}
1005
1006
1007void LIB_SYMBOL::GetFields( std::vector<SCH_FIELD*>& aList, bool aVisibleOnly ) const
1008{
1009 for( const SCH_ITEM& item : m_drawings[ SCH_FIELD_T ] )
1010 {
1011 const SCH_FIELD* field = static_cast<const SCH_FIELD*>( &item );
1012
1013 if( aVisibleOnly )
1014 {
1015 if( !field->IsVisible() || field->GetText().IsEmpty() )
1016 continue;
1017 }
1018
1019 aList.push_back( const_cast<SCH_FIELD*>( field ) );
1020 }
1021
1022 std::sort( aList.begin(), aList.end(),
1023 []( SCH_FIELD* lhs, SCH_FIELD* rhs )
1024 {
1025 return lhs->GetOrdinal() < rhs->GetOrdinal();
1026 } );
1027}
1028
1029
1030void LIB_SYMBOL::CopyFields( std::vector<SCH_FIELD>& aList )
1031{
1032 std::vector<SCH_FIELD*> orderedFields;
1033
1034 GetFields( orderedFields );
1035
1036 for( SCH_FIELD* field : orderedFields )
1037 aList.emplace_back( *field );
1038}
1039
1040
1042{
1043 int ordinal = 42; // Arbitrarily larger than any mandatory FIELD_T id
1044
1045 for( const SCH_ITEM& item : m_drawings[ SCH_FIELD_T ] )
1046 ordinal = std::max( ordinal, static_cast<const SCH_FIELD*>( &item )->GetOrdinal() + 1 );
1047
1048 return ordinal;
1049}
1050
1051
1052const SCH_FIELD* LIB_SYMBOL::GetField( FIELD_T aFieldType ) const
1053{
1054 for( const SCH_ITEM& item : m_drawings[ SCH_FIELD_T ] )
1055 {
1056 const SCH_FIELD* field = static_cast<const SCH_FIELD*>( &item );
1057
1058 if( field->GetId() == aFieldType )
1059 return field;
1060 }
1061
1062 return nullptr;
1063}
1064
1065
1067{
1068 for( SCH_ITEM& item : m_drawings[ SCH_FIELD_T ] )
1069 {
1070 SCH_FIELD* field = static_cast<SCH_FIELD*>( &item );
1071
1072 if( field->GetId() == aFieldType )
1073 return field;
1074 }
1075
1076 return nullptr;
1077}
1078
1079
1080const SCH_FIELD* LIB_SYMBOL::GetField( const wxString& aFieldName ) const
1081{
1082 for( const SCH_ITEM& item : m_drawings[ SCH_FIELD_T ] )
1083 {
1084 const SCH_FIELD& field = static_cast<const SCH_FIELD&>( item );
1085
1086 if( field.GetName() == aFieldName )
1087 return &field;
1088 }
1089
1090 return nullptr;
1091}
1092
1093
1094SCH_FIELD* LIB_SYMBOL::GetField( const wxString& aFieldName )
1095{
1096 for( SCH_ITEM& item : m_drawings[ SCH_FIELD_T ] )
1097 {
1098 SCH_FIELD& field = static_cast<SCH_FIELD&>( item );
1099
1100 if( field.GetName() == aFieldName )
1101 return &field;
1102 }
1103
1104 return nullptr;
1105}
1106
1107
1109{
1110 for( SCH_ITEM& item : m_drawings[ SCH_FIELD_T ] )
1111 {
1112 SCH_FIELD& field = static_cast<SCH_FIELD&>( item );
1113
1114 if( field.GetCanonicalName().IsSameAs( aFieldName, false ) )
1115 return &field;
1116 }
1117
1118 return nullptr;
1119}
1120
1121
1123{
1124 const SCH_FIELD* field = GetField( FIELD_T::VALUE );
1125 wxASSERT( field != nullptr );
1126 return *field;
1127}
1128
1129
1131{
1132 const SCH_FIELD* field = GetField( FIELD_T::REFERENCE );
1133 wxASSERT( field != nullptr );
1134 return *field;
1135}
1136
1137
1139{
1140 const SCH_FIELD* field = GetField( FIELD_T::FOOTPRINT );
1141 wxASSERT( field != nullptr );
1142 return *field;
1143}
1144
1145
1147{
1148 const SCH_FIELD* field = GetField( FIELD_T::DATASHEET );
1149 wxASSERT( field != nullptr );
1150 return *field;
1151}
1152
1153
1155{
1156 const SCH_FIELD* field = GetField( FIELD_T::DESCRIPTION );
1157 wxASSERT( field != nullptr );
1158 return *field;
1159}
1160
1161
1163{
1164 wxString refDesignator = GetField( FIELD_T::REFERENCE )->GetText();
1165
1166 refDesignator.Replace( wxS( "~" ), wxS( " " ) );
1167
1168 wxString prefix = refDesignator;
1169
1170 while( prefix.Length() )
1171 {
1172 wxUniCharRef last = prefix.Last();
1173
1174 if( ( last >= '0' && last <= '9' ) || last == '?' || last == '*' )
1175 prefix.RemoveLast();
1176 else
1177 break;
1178 }
1179
1180 // Avoid a prefix containing trailing/leading spaces
1181 prefix.Trim( true );
1182 prefix.Trim( false );
1183
1184 return prefix;
1185}
1186
1187
1188void LIB_SYMBOL::RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction )
1189{
1190 for( SCH_ITEM& item : m_drawings )
1191 aFunction( &item );
1192}
1193
1194
1195void LIB_SYMBOL::Move( const VECTOR2I& aOffset )
1196{
1197 for( SCH_ITEM& item : m_drawings )
1198 item.Move( aOffset );
1199}
1200
1201
1203{
1204 for( const SCH_ITEM& item : m_drawings )
1205 {
1206 if( item.m_bodyStyle > BODY_STYLE::BASE )
1207 return true;
1208 }
1209
1210 if( LIB_SYMBOL_SPTR parent = m_parent.lock() )
1211 {
1212 for( const SCH_ITEM& item : parent->GetDrawItems() )
1213 {
1214 if( item.m_bodyStyle > BODY_STYLE::BASE )
1215 return true;
1216 }
1217 }
1218
1219 return false;
1220}
1221
1222
1224{
1225 int maxPinNumber = 0;
1226 LIB_SYMBOL_SPTR parent = m_parent.lock();
1227 const LIB_ITEMS_CONTAINER& drawItems = parent ? parent->m_drawings : m_drawings;
1228
1229 for( const SCH_ITEM& item : drawItems[SCH_PIN_T] )
1230 {
1231 const SCH_PIN* pin = static_cast<const SCH_PIN*>( &item );
1232 long currentPinNumber = 0;
1233
1234 if( pin->GetNumber().ToLong( &currentPinNumber ) )
1235 maxPinNumber = std::max( maxPinNumber, (int) currentPinNumber );
1236 }
1237
1238 return maxPinNumber;
1239}
1240
1241
1243{
1245
1246 for( SCH_ITEM& item : m_drawings )
1247 item.ClearTempFlags();
1248}
1249
1250
1252{
1254
1255 for( SCH_ITEM& item : m_drawings )
1256 item.ClearEditFlags();
1257}
1258
1259
1260SCH_ITEM* LIB_SYMBOL::LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType,
1261 const VECTOR2I& aPoint )
1262{
1263 for( SCH_ITEM& item : m_drawings )
1264 {
1265 if( ( aUnit && item.m_unit && aUnit != item.m_unit )
1266 || ( aBodyStyle && item.m_bodyStyle && aBodyStyle != item.m_bodyStyle )
1267 || ( item.Type() != aType && aType != TYPE_NOT_INIT ) )
1268 {
1269 continue;
1270 }
1271
1272 if( item.HitTest( aPoint ) )
1273 return &item;
1274 }
1275
1276 return nullptr;
1277}
1278
1279
1280SCH_ITEM* LIB_SYMBOL::LocateDrawItem( int aUnit, int aBodyStyle, KICAD_T aType,
1281 const VECTOR2I& aPoint, const TRANSFORM& aTransform )
1282{
1283 /* we use LocateDrawItem( int aUnit, int convert, KICAD_T type, const
1284 * VECTOR2I& pt ) to search items.
1285 * because this function uses DefaultTransform as orient/mirror matrix
1286 * we temporary copy aTransform in DefaultTransform
1287 */
1288 TRANSFORM transform = DefaultTransform;
1289 DefaultTransform = aTransform;
1290
1291 SCH_ITEM* item = LocateDrawItem( aUnit, aBodyStyle, aType, aPoint );
1292
1293 // Restore matrix
1294 DefaultTransform = transform;
1295
1296 return item;
1297}
1298
1299
1300INSPECT_RESULT LIB_SYMBOL::Visit( INSPECTOR aInspector, void* aTestData,
1301 const std::vector<KICAD_T>& aScanTypes )
1302{
1303 // The part itself is never inspected, only its children
1304 for( SCH_ITEM& item : m_drawings )
1305 {
1306 if( item.IsType( aScanTypes ) )
1307 {
1308 if( aInspector( &item, aTestData ) == INSPECT_RESULT::QUIT )
1309 return INSPECT_RESULT::QUIT;
1310 }
1311 }
1312
1313 return INSPECT_RESULT::CONTINUE;
1314}
1315
1316
1317void LIB_SYMBOL::SetUnitCount( int aCount, bool aDuplicateDrawItems )
1318{
1319 if( m_unitCount == aCount )
1320 return;
1321
1322 if( aCount < m_unitCount )
1323 {
1325
1326 while( i != m_drawings.end() )
1327 {
1328 if( i->m_unit > aCount )
1329 i = m_drawings.erase( i );
1330 else
1331 ++i;
1332 }
1333 }
1334 else if( aDuplicateDrawItems )
1335 {
1336 int prevCount = m_unitCount;
1337
1338 // Temporary storage for new items, as adding new items directly to
1339 // m_drawings may cause the buffer reallocation which invalidates the
1340 // iterators
1341 std::vector<SCH_ITEM*> tmp;
1342
1343 for( SCH_ITEM& item : m_drawings )
1344 {
1345 if( item.m_unit != 1 )
1346 continue;
1347
1348 for( int j = prevCount + 1; j <= aCount; j++ )
1349 {
1350 SCH_ITEM* newItem = item.Duplicate();
1351 newItem->m_unit = j;
1352 tmp.push_back( newItem );
1353 }
1354 }
1355
1356 for( SCH_ITEM* item : tmp )
1357 m_drawings.push_back( item );
1358 }
1359
1360 m_drawings.sort();
1361 m_unitCount = aCount;
1362}
1363
1364
1366{
1367 if( LIB_SYMBOL_SPTR parent = m_parent.lock() )
1368 return parent->GetUnitCount();
1369
1370 return m_unitCount;
1371}
1372
1373
1374void LIB_SYMBOL::SetHasAlternateBodyStyle( bool aHasAlternate, bool aDuplicatePins )
1375{
1376 if( aHasAlternate == HasAlternateBodyStyle() )
1377 return;
1378
1379 // Duplicate items to create the converted shape
1380 if( aHasAlternate )
1381 {
1382 if( aDuplicatePins )
1383 {
1384 std::vector<SCH_ITEM*> tmp; // Temporarily store the duplicated pins here.
1385
1386 for( SCH_ITEM& item : m_drawings[ SCH_PIN_T ] )
1387 {
1388 if( item.m_bodyStyle == 1 )
1389 {
1390 SCH_ITEM* newItem = item.Duplicate();
1391 newItem->m_bodyStyle = 2;
1392 tmp.push_back( newItem );
1393 }
1394 }
1395
1396 // Transfer the new pins to the LIB_SYMBOL.
1397 for( SCH_ITEM* item : tmp )
1398 m_drawings.push_back( item );
1399 }
1400 }
1401 else
1402 {
1403 // Delete converted shape items because the converted shape does not exist
1405
1406 while( i != m_drawings.end() )
1407 {
1408 if( i->m_bodyStyle > 1 )
1409 i = m_drawings.erase( i );
1410 else
1411 ++i;
1412 }
1413 }
1414
1415 m_drawings.sort();
1416}
1417
1418
1419std::vector<SCH_ITEM*> LIB_SYMBOL::GetUnitDrawItems( int aUnit, int aBodyStyle )
1420{
1421 std::vector<SCH_ITEM*> unitItems;
1422
1423 for( SCH_ITEM& item : m_drawings )
1424 {
1425 if( item.Type() == SCH_FIELD_T )
1426 continue;
1427
1428 if( ( aBodyStyle == -1 && item.GetUnit() == aUnit )
1429 || ( aUnit == -1 && item.GetBodyStyle() == aBodyStyle )
1430 || ( aUnit == item.GetUnit() && aBodyStyle == item.GetBodyStyle() ) )
1431 {
1432 unitItems.push_back( &item );
1433 }
1434 }
1435
1436 return unitItems;
1437}
1438
1439
1440std::vector<LIB_SYMBOL_UNIT> LIB_SYMBOL::GetUnitDrawItems()
1441{
1442 std::vector<LIB_SYMBOL_UNIT> units;
1443
1444 for( SCH_ITEM& item : m_drawings )
1445 {
1446 if( item.Type() == SCH_FIELD_T )
1447 continue;
1448
1449 int unit = item.GetUnit();
1450 int bodyStyle = item.GetBodyStyle();
1451
1452 auto it = std::find_if( units.begin(), units.end(),
1453 [unit, bodyStyle]( const LIB_SYMBOL_UNIT& a )
1454 {
1455 return a.m_unit == unit && a.m_bodyStyle == bodyStyle;
1456 } );
1457
1458 if( it == units.end() )
1459 {
1460 LIB_SYMBOL_UNIT newUnit;
1461 newUnit.m_unit = item.GetUnit();
1462 newUnit.m_bodyStyle = item.GetBodyStyle();
1463 newUnit.m_items.push_back( &item );
1464 units.emplace_back( newUnit );
1465 }
1466 else
1467 {
1468 it->m_items.push_back( &item );
1469 }
1470 }
1471
1472 return units;
1473}
1474
1475
1476
1477
1478#define REPORT( msg ) { if( aReporter ) aReporter->Report( msg ); }
1479#define ITEM_DESC( item ) ( item )->GetItemDescription( &unitsProvider, true )
1480
1481int LIB_SYMBOL::Compare( const LIB_SYMBOL& aRhs, int aCompareFlags, REPORTER* aReporter ) const
1482{
1483 UNITS_PROVIDER unitsProvider( schIUScale, EDA_UNITS::MM );
1484
1485 if( m_me == aRhs.m_me )
1486 return 0;
1487
1488 if( !aReporter && ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::ERC ) == 0 )
1489 {
1490 if( int tmp = m_name.Cmp( aRhs.m_name ) )
1491 return tmp;
1492
1493 if( int tmp = m_libId.compare( aRhs.m_libId ) )
1494 return tmp;
1495
1496 if( m_parent.lock() < aRhs.m_parent.lock() )
1497 return -1;
1498
1499 if( m_parent.lock() > aRhs.m_parent.lock() )
1500 return 1;
1501 }
1502
1503 int retv = 0;
1504
1505 if( m_options != aRhs.m_options )
1506 {
1507 retv = ( m_options == ENTRY_NORMAL ) ? -1 : 1;
1508 REPORT( _( "Power flag differs." ) );
1509
1510 if( !aReporter )
1511 return retv;
1512 }
1513
1514 if( int tmp = m_unitCount - aRhs.m_unitCount )
1515 {
1516 retv = tmp;
1517 REPORT( _( "Unit count differs." ) );
1518
1519 if( !aReporter )
1520 return retv;
1521 }
1522
1523 // Make sure shapes and pins are sorted. No need with fields as those are
1524 // matched by id/name.
1525
1526 std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> aShapes;
1527 std::set<const SCH_ITEM*> aFields;
1528 std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> aPins;
1529
1530 for( auto it = m_drawings.begin(); it != m_drawings.end(); ++it )
1531 {
1532 if( it->Type() == SCH_SHAPE_T )
1533 aShapes.insert( &(*it) );
1534 else if( it->Type() == SCH_FIELD_T )
1535 aFields.insert( &(*it) );
1536 else if( it->Type() == SCH_PIN_T )
1537 aPins.insert( &(*it) );
1538 }
1539
1540 std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> bShapes;
1541 std::set<const SCH_ITEM*> bFields;
1542 std::set<const SCH_ITEM*, SCH_ITEM::cmp_items> bPins;
1543
1544 for( auto it = aRhs.m_drawings.begin(); it != aRhs.m_drawings.end(); ++it )
1545 {
1546 if( it->Type() == SCH_SHAPE_T )
1547 bShapes.insert( &(*it) );
1548 else if( it->Type() == SCH_FIELD_T )
1549 bFields.insert( &(*it) );
1550 else if( it->Type() == SCH_PIN_T )
1551 bPins.insert( &(*it) );
1552 }
1553
1554 if( int tmp = static_cast<int>( aShapes.size() - bShapes.size() ) )
1555 {
1556 retv = tmp;
1557 REPORT( _( "Graphic item count differs." ) );
1558
1559 if( !aReporter )
1560 return retv;
1561 }
1562 else
1563 {
1564 for( auto aIt = aShapes.begin(), bIt = bShapes.begin(); aIt != aShapes.end(); aIt++, bIt++ )
1565 {
1566 if( int tmp2 = (*aIt)->compare( *(*bIt), aCompareFlags ) )
1567 {
1568 retv = tmp2;
1569 REPORT( wxString::Format( _( "%s differs." ), ITEM_DESC( *aIt ) ) );
1570
1571 if( !aReporter )
1572 return retv;
1573 }
1574 }
1575 }
1576
1577 if( int tmp = static_cast<int>( aPins.size() - bPins.size() ) )
1578 {
1579 retv = tmp;
1580 REPORT( _( "Pin count differs." ) );
1581
1582 if( !aReporter )
1583 return retv;
1584 }
1585 else
1586 {
1587 for( const SCH_ITEM* aPinItem : aPins )
1588 {
1589 const SCH_PIN* aPin = static_cast<const SCH_PIN*>( aPinItem );
1590 const SCH_PIN* bPin = aRhs.GetPin( aPin->GetNumber(), aPin->GetUnit(),
1591 aPin->GetBodyStyle() );
1592
1593 if( !bPin )
1594 {
1595 retv = 1;
1596 REPORT( wxString::Format( _( "Pin %s not found." ), aPin->GetNumber() ) );
1597
1598 if( !aReporter )
1599 return retv;
1600 }
1601 else if( int tmp2 = aPinItem->compare( *bPin, aCompareFlags ) )
1602 {
1603 retv = tmp2;
1604 REPORT( wxString::Format( _( "Pin %s differs." ), aPin->GetNumber() ) );
1605
1606 if( !aReporter )
1607 return retv;
1608 }
1609 }
1610 }
1611
1612 for( const SCH_ITEM* aFieldItem : aFields )
1613 {
1614 const SCH_FIELD* aField = static_cast<const SCH_FIELD*>( aFieldItem );
1615 const SCH_FIELD* bField = nullptr;
1616 int tmp = 0;
1617
1618 if( aField->IsMandatory() )
1619 bField = aRhs.GetField( aField->GetId() );
1620 else
1621 bField = aRhs.GetField( aField->GetName() );
1622
1623 if( !bField )
1624 tmp = 1;
1625 else
1626 tmp = aFieldItem->compare( *bField, aCompareFlags );
1627
1628 if( tmp )
1629 {
1630 retv = tmp;
1631 REPORT( wxString::Format( _( "%s field differs." ), aField->GetName( false ) ) );
1632
1633 if( !aReporter )
1634 return retv;
1635 }
1636 }
1637
1638 if( int tmp = static_cast<int>( aFields.size() - bFields.size() ) )
1639 {
1640 retv = tmp;
1641 REPORT( _( "Field count differs." ) );
1642
1643 if( !aReporter )
1644 return retv;
1645 }
1646
1647 if( int tmp = static_cast<int>( m_fpFilters.GetCount() - aRhs.m_fpFilters.GetCount() ) )
1648 {
1649 retv = tmp;
1650 REPORT( _( "Footprint filters differs." ) );
1651
1652 if( !aReporter )
1653 return retv;
1654 }
1655 else
1656 {
1657 for( size_t i = 0; i < m_fpFilters.GetCount(); i++ )
1658 {
1659 if( int tmp2 = m_fpFilters[i].Cmp( aRhs.m_fpFilters[i] ) )
1660 {
1661 retv = tmp2;
1662 REPORT( _( "Footprint filters differ." ) );
1663
1664 if( !aReporter )
1665 return retv;
1666 }
1667 }
1668 }
1669
1670 if( int tmp = m_keyWords.Cmp( aRhs.m_keyWords ) )
1671 {
1672 retv = tmp;
1673 REPORT( _( "Symbol keywords differ." ) );
1674
1675 if( !aReporter )
1676 return retv;
1677 }
1678
1679 if( int tmp = m_pinNameOffset - aRhs.m_pinNameOffset )
1680 {
1681 retv = tmp;
1682 REPORT( _( "Symbol pin name offsets differ." ) );
1683
1684 if( !aReporter )
1685 return retv;
1686 }
1687
1688 if( ( aCompareFlags & SCH_ITEM::COMPARE_FLAGS::ERC ) == 0 )
1689 {
1690 if( m_showPinNames != aRhs.m_showPinNames )
1691 {
1692 retv = ( m_showPinNames ) ? 1 : -1;
1693 REPORT( _( "Show pin names settings differ." ) );
1694
1695 if( !aReporter )
1696 return retv;
1697 }
1698
1700 {
1701 retv = ( m_showPinNumbers ) ? 1 : -1;
1702 REPORT( _( "Show pin numbers settings differ." ) );
1703
1704 if( !aReporter )
1705 return retv;
1706 }
1707
1709 {
1710 retv = ( m_excludedFromSim ) ? -1 : 1;
1711 REPORT( _( "Exclude from simulation settings differ." ) );
1712
1713 if( !aReporter )
1714 return retv;
1715 }
1716
1718 {
1719 retv = ( m_excludedFromBOM ) ? -1 : 1;
1720 REPORT( _( "Exclude from bill of materials settings differ." ) );
1721
1722 if( !aReporter )
1723 return retv;
1724 }
1725
1727 {
1728 retv = ( m_excludedFromBoard ) ? -1 : 1;
1729 REPORT( _( "Exclude from board settings differ." ) );
1730
1731 if( !aReporter )
1732 return retv;
1733 }
1734 }
1735
1736 if( !aReporter )
1737 {
1738 if( m_unitsLocked != aRhs.m_unitsLocked )
1739 return ( m_unitsLocked ) ? 1 : -1;
1740
1741 // Compare unit display names
1743 return -1;
1744 else if( m_unitDisplayNames > aRhs.m_unitDisplayNames )
1745 return 1;
1746 }
1747
1748 return retv;
1749}
1750
1751
1752int LIB_SYMBOL::compare( const SCH_ITEM& aOther, int aCompareFlags ) const
1753{
1754 if( Type() != aOther.Type() )
1755 return Type() - aOther.Type();
1756
1757 const LIB_SYMBOL* tmp = static_cast<const LIB_SYMBOL*>( &aOther );
1758
1759 return Compare( *tmp, aCompareFlags );
1760}
1761
1762
1763double LIB_SYMBOL::Similarity( const SCH_ITEM& aOther ) const
1764{
1765 wxCHECK( aOther.Type() == LIB_SYMBOL_T, 0.0 );
1766
1767 const LIB_SYMBOL& other = static_cast<const LIB_SYMBOL&>( aOther );
1768 double similarity = 0.0;
1769 int totalItems = 0;
1770
1771 if( m_Uuid == aOther.m_Uuid )
1772 return 1.0;
1773
1774 for( const SCH_ITEM& item : m_drawings )
1775 {
1776 totalItems += 1;
1777 double max_similarity = 0.0;
1778
1779 for( const SCH_ITEM& otherItem : other.m_drawings )
1780 {
1781 double temp_similarity = item.Similarity( otherItem );
1782 max_similarity = std::max( max_similarity, temp_similarity );
1783
1784 if( max_similarity == 1.0 )
1785 break;
1786 }
1787
1788 similarity += max_similarity;
1789 }
1790
1791 for( const SCH_PIN* pin : GetPins() )
1792 {
1793 totalItems += 1;
1794 double max_similarity = 0.0;
1795
1796 for( const SCH_PIN* otherPin : other.GetPins() )
1797 {
1798 double temp_similarity = pin->Similarity( *otherPin );
1799 max_similarity = std::max( max_similarity, temp_similarity );
1800
1801 if( max_similarity == 1.0 )
1802 break;
1803 }
1804
1805 similarity += max_similarity;
1806 }
1807
1808 if( totalItems == 0 )
1809 similarity = 0.0;
1810 else
1811 similarity /= totalItems;
1812
1814 similarity *= 0.9;
1815
1817 similarity *= 0.9;
1818
1820 similarity *= 0.9;
1821
1822 if( m_flags != other.m_flags )
1823 similarity *= 0.9;
1824
1825 if( m_unitCount != other.m_unitCount )
1826 similarity *= 0.5;
1827
1828 if( m_pinNameOffset != other.m_pinNameOffset )
1829 similarity *= 0.9;
1830
1831 if( m_showPinNames != other.m_showPinNames )
1832 similarity *= 0.9;
1833
1834 if( m_showPinNumbers != other.m_showPinNumbers )
1835 similarity *= 0.9;
1836
1837 return similarity;
1838}
1839
1840
1842{
1843 return static_cast<EMBEDDED_FILES*>( this );
1844}
1845
1846
1848{
1849 return static_cast<const EMBEDDED_FILES*>( this );
1850}
1851
1852
1853std::set<KIFONT::OUTLINE_FONT*> LIB_SYMBOL::GetFonts() const
1854{
1855 using EMBEDDING_PERMISSION = KIFONT::OUTLINE_FONT::EMBEDDING_PERMISSION;
1856
1857 std::set<KIFONT::OUTLINE_FONT*> fonts;
1858
1859 for( const SCH_ITEM& item : m_drawings )
1860 {
1861 if( item.Type() == SCH_TEXT_T )
1862 {
1863 const SCH_TEXT& text = static_cast<const SCH_TEXT&>( item );
1864
1865 if( auto* font = text.GetFont(); font && !font->IsStroke() )
1866 {
1867 auto* outline = static_cast<KIFONT::OUTLINE_FONT*>( font );
1868 auto permission = outline->GetEmbeddingPermission();
1869
1870 if( permission == EMBEDDING_PERMISSION::EDITABLE
1871 || permission == EMBEDDING_PERMISSION::INSTALLABLE )
1872 {
1873 fonts.insert( outline );
1874 }
1875 }
1876 }
1877 }
1878
1879 return fonts;
1880}
1881
1882
1884{
1885 std::set<KIFONT::OUTLINE_FONT*> fonts = GetFonts();
1886
1887 for( KIFONT::OUTLINE_FONT* font : fonts )
1888 {
1889 auto file = GetEmbeddedFiles()->AddFile( font->GetFileName(), false );
1891 }
1892}
int color
Definition: DXF_plotter.cpp:60
const char * name
Definition: DXF_plotter.cpp:59
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:110
double square(double x)
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h:658
virtual void ClearEditFlags()
Definition: eda_item.h:139
const KIID m_Uuid
Definition: eda_item.h:488
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
void ClearSelected()
Definition: eda_item.h:120
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:499
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:104
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:86
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:128
virtual void ClearTempFlags()
Definition: eda_item.h:151
FILL_T GetFillMode() const
Definition: eda_shape.h:142
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:98
virtual bool IsVisible() const
Definition: eda_text.h:174
virtual void SetVisible(bool aVisible)
Definition: eda_text.cpp:379
bool IsEmpty() const
EMBEDDED_FILES & operator=(EMBEDDED_FILES &&other) noexcept
EMBEDDED_FILE * AddFile(const wxFileName &aName, bool aOverwrite)
Load a file from disk and adds it to the collection.
Class OUTLINE_FONT implements outline font drawing.
Definition: outline_font.h:53
EMBEDDING_PERMISSION GetEmbeddingPermission() const
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
int SetLibItemName(const UTF8 &aLibItemName)
Override the library item name portion of the LIB_ID to aLibItemName.
Definition: lib_id.cpp:111
int compare(const LIB_ID &aLibId) const
Compare the contents of LIB_ID objects by performing a std::string comparison of the library nickname...
Definition: lib_id.cpp:161
const wxString GetUniStringLibItemName() const
Get strings for display messages in dialogs.
Definition: lib_id.h:112
const wxString GetUniStringLibNickname() const
Definition: lib_id.h:88
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:87
Define a library symbol object.
Definition: lib_symbol.h:85
LIB_ITEMS_CONTAINER m_drawings
Definition: lib_symbol.h:672
bool ResolveTextVar(wxString *token, int aDepth=0) const
Resolve any references to system tokens supported by the symbol.
Definition: lib_symbol.cpp:527
SCH_FIELD & GetDescriptionField()
Return reference to the description field.
Definition: lib_symbol.h:350
wxString GetDescription() const override
Definition: lib_symbol.h:170
wxString GetKeyWords() const override
Definition: lib_symbol.h:183
void SetGlobalPower()
Definition: lib_symbol.cpp:466
std::vector< SCH_PIN * > GetPins(int aUnit, int aBodyStyle) const
Return a list of pin object pointers from the draw item list.
Definition: lib_symbol.cpp:790
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction) override
LIBRENTRYOPTIONS m_options
Special symbol features such as POWER or NORMAL.)
Definition: lib_symbol.h:670
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.
Definition: lib_symbol.cpp:846
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
Definition: lib_symbol.cpp:460
wxString GetPrefix()
void SetUnitCount(int aCount, bool aDuplicateDrawItems=true)
Set the units per symbol count.
SCH_FIELD & GetDatasheetField()
Return reference to the datasheet field.
Definition: lib_symbol.h:346
const BOX2I GetUnitBoundingBox(int aUnit, int aBodyStyle, bool aIgnoreHiddenFields=true) const
Get the bounding box for the symbol.
Definition: lib_symbol.cpp:908
std::vector< struct LIB_SYMBOL_UNIT > GetUnitDrawItems()
Return a list of SCH_ITEM objects separated by unit and convert number.
std::map< int, wxString > m_unitDisplayNames
Definition: lib_symbol.h:680
void ClearTempFlags() override
Clears the status flag all draw objects in this symbol.
bool IsDerived() const
Definition: lib_symbol.h:207
SYMBOL_LIB * m_library
Definition: lib_symbol.h:674
wxString GetFootprint() override
For items with footprint fields.
Definition: lib_symbol.h:196
wxString GetUnitDisplayName(int aUnit) override
Return the user-defined display name for aUnit for symbols with units.
Definition: lib_symbol.cpp:291
const wxString GetLibraryName() const
Definition: lib_symbol.cpp:405
void SetFields(const std::vector< SCH_FIELD > &aFieldsList)
Overwrite all the existing fields in this symbol with fields supplied in aFieldsList.
Definition: lib_symbol.cpp:990
std::vector< SEARCH_TERM > GetSearchTerms() override
Definition: lib_symbol.cpp:40
int GetMaxPinNumber() const
LIB_SYMBOL_SPTR m_me
Definition: lib_symbol.h:660
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.
Definition: lib_symbol.cpp:628
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:342
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 ...
Definition: lib_symbol.cpp:709
static wxString LetterSubReference(int aUnit, int aFirstId)
Definition: lib_symbol.cpp:508
SCH_PIN * GetPin(const wxString &aNumber, int aUnit=0, int aBodyStyle=0) const
Return pin object with the requested pin aNumber.
Definition: lib_symbol.cpp:834
bool IsNormal() const override
Definition: lib_symbol.cpp:480
wxString m_name
Definition: lib_symbol.h:675
std::set< KIFONT::OUTLINE_FONT * > GetFonts() const override
bool HasAlternateBodyStyle() const override
Test if symbol has more than one body conversion type (DeMorgan).
SCH_FIELD * FindFieldCaseInsensitive(const wxString &aFieldName)
wxString m_keyWords
Search keywords.
Definition: lib_symbol.h:676
SCH_ITEM * LocateDrawItem(int aUnit, int aBodyStyle, KICAD_T aType, const VECTOR2I &aPoint)
Locate a draw object.
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.
Definition: lib_symbol.cpp:227
void PlotFields(PLOTTER *aPlotter, bool aBackground, const SCH_PLOT_OPTS &aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I &aOffset, bool aDimmed)
Plot symbol fields.
Definition: lib_symbol.cpp:670
void SetParent(LIB_SYMBOL *aParent=nullptr)
Definition: lib_symbol.cpp:326
wxString GetName() const override
Definition: lib_symbol.h:149
SCH_FIELD & GetValueField()
Return reference to the value field.
Definition: lib_symbol.h:334
bool IsLocalPower() const override
Definition: lib_symbol.cpp:414
void RemoveDrawItem(SCH_ITEM *aItem)
Remove draw aItem from list.
Definition: lib_symbol.cpp:751
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...
Definition: lib_symbol.cpp:71
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:664
LIB_ID m_libId
Definition: lib_symbol.h:662
void SetLocalPower()
Definition: lib_symbol.cpp:430
void SetLib(SYMBOL_LIB *aLibrary)
Definition: lib_symbol.h:212
std::vector< SCH_PIN * > GetPins() const override
Return a list of pin pointers for all units / converts.
Definition: lib_symbol.cpp:822
const LIB_SYMBOL & operator=(const LIB_SYMBOL &aSymbol)
Definition: lib_symbol.cpp:177
bool m_unitsLocked
True if symbol has multiple units and changing one unit does not automatically change another unit.
Definition: lib_symbol.h:667
wxArrayString m_fpFilters
List of suitable footprint names for the symbol (wild card names accepted).
Definition: lib_symbol.h:677
void Move(const VECTOR2I &aOffset) override
Move the symbol aOffset.
bool HasUnitDisplayName(int aUnit) override
Return true if the given unit aUnit has a display name defined.
Definition: lib_symbol.cpp:285
void CopyFields(std::vector< SCH_FIELD > &aList)
Create a copy of the SCH_FIELDs, sorted in ordinal order.
LIB_SYMBOL_SPTR SharedPtr() const
http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared.
Definition: lib_symbol.h:96
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...
wxString GetUnitReference(int aUnit) override
Return an identifier for aUnit for symbols with units.
Definition: lib_symbol.cpp:279
EMBEDDED_FILES * GetEmbeddedFiles() override
int m_unitCount
Number of units (parts) per package.
Definition: lib_symbol.h:666
void SetHasAlternateBodyStyle(bool aHasAlternate, bool aDuplicatePins=true)
Set or clear the alternate body style (DeMorgan) for the symbol.
bool IsGlobalPower() const override
Definition: lib_symbol.cpp:444
unsigned GetInheritanceDepth() const
Get the number of parents for this symbol.
Definition: lib_symbol.cpp:251
int GetUnitCount() const override
LIB_SYMBOL_REF m_parent
Use for inherited symbols.
Definition: lib_symbol.h:661
std::unique_ptr< LIB_SYMBOL > Flatten() const
Return a flattened symbol inheritance to the caller.
Definition: lib_symbol.cpp:335
BOX2I GetBodyBoundingBox() const override
Return a bounding box for the symbol body but not the pins or fields.
Definition: lib_symbol.h:260
int GetPinCount() override
Definition: lib_symbol.cpp:828
void AddField(SCH_FIELD *aField)
Add a field.
Definition: lib_symbol.cpp:984
void ClearEditFlags() override
void deleteAllFields()
Definition: lib_symbol.cpp:978
LIB_SYMBOL_REF & GetParent()
Definition: lib_symbol.h:118
LIB_SYMBOL_SPTR GetRootSymbol() const
Get the parent symbol that does not have another parent.
Definition: lib_symbol.cpp:267
void SetUnitDisplayName(int aUnit, const wxString &aName)
Set the user-defined display name for aUnit to aName for symbols with units.
Definition: lib_symbol.cpp:307
void AddDrawItem(SCH_ITEM *aItem, bool aSort=true)
Add a new draw aItem to the draw object list and sort according to aSort.
Definition: lib_symbol.cpp:776
void EmbedFonts() override
virtual void SetName(const wxString &aName)
Definition: lib_symbol.cpp:319
void SetNormal()
Definition: lib_symbol.cpp:494
void CopyUnitDisplayNames(std::map< int, wxString > &aTarget) const
Copy all unit display names into the given map aTarget.
Definition: lib_symbol.cpp:300
SCH_FIELD & GetReferenceField()
Return reference to the reference designator field.
Definition: lib_symbol.h:338
int GetNextFieldOrdinal() const
Return the next ordinal for a user field for this symbol.
void sort()
Definition: multivector.h:248
void push_back(T *aItem)
Definition: multivector.h:175
ITERATOR_BASE< SCH_ITEM, MULTIVECTOR< SCH_ITEM, FIRST_TYPE_VAL, LAST_TYPE_VAL >, typename ITEM_PTR_VECTOR::iterator > ITERATOR
The const iterator.
Definition: multivector.h:165
ITERATOR end(int aType=UNDEFINED_TYPE)
Definition: multivector.h:195
void clear(int aType=UNDEFINED_TYPE)
Definition: multivector.h:213
ITERATOR erase(const ITERATOR &aIterator)
Definition: multivector.h:180
ITERATOR begin(int aType=UNDEFINED_TYPE)
Definition: multivector.h:189
Base plotter engine class.
Definition: plotter.h:105
bool GetColorMode() const
Definition: plotter.h:133
virtual void SetColor(const COLOR4D &color)=0
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:73
int compare(const SCH_ITEM &aOther, int aCompareFlags=0) const override
Provide the draw object specific comparison called by the == and < operators.
Definition: sch_field.cpp:1458
bool IsMandatory() const
Definition: sch_field.cpp:1331
wxString GetFullText(int unit=1) const
Return the text of a field.
Definition: sch_field.cpp:309
FIELD_T GetId() const
Definition: sch_field.h:124
wxString GetCanonicalName() const
Get a non-language-specific name for a field which can be used for storage, variable look-up,...
Definition: sch_field.cpp:1093
wxString GetName(bool aUseDefaultName=true) const
Return the field name (not translated).
Definition: sch_field.cpp:1079
wxString GetShownText(const SCH_SHEET_PATH *aPath, bool aAllowExtraText, int aDepth=0) const
Definition: sch_field.cpp:192
bool ShowInChooser() const
Definition: sch_field.h:229
void SetText(const wxString &aText) override
Definition: sch_field.cpp:1064
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:167
int m_unit
Definition: sch_item.h:695
int m_bodyStyle
Definition: sch_item.h:696
SCH_RENDER_SETTINGS * getRenderSettings(PLOTTER *aPlotter) const
Definition: sch_item.h:641
int GetBodyStyle() const
Definition: sch_item.h:236
friend class LIB_SYMBOL
Definition: sch_item.h:714
int GetUnit() const
Definition: sch_item.h:233
virtual void SetExcludedFromSim(bool aExclude)
Definition: sch_item.h:241
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:131
const wxString & GetNumber() const
Definition: sch_pin.h:123
const KIGFX::COLOR4D & GetBackgroundColor() const override
Return current background color settings.
Object used to load, save, search, and otherwise manipulate symbol library files.
const wxString GetName() const
Return the file name without path or extension.
A base class for LIB_SYMBOL and SCH_SYMBOL.
Definition: symbol.h:63
bool m_showPinNumbers
Definition: symbol.h:222
bool GetExcludedFromBoard() const
Definition: symbol.h:187
bool m_excludedFromSim
Definition: symbol.h:224
bool GetExcludedFromBOM() const
Definition: symbol.h:181
bool m_showPinNames
Definition: symbol.h:221
bool m_excludedFromBOM
Definition: symbol.h:225
bool GetDNP() const
Set or clear the 'Do Not Populate' flag.
Definition: symbol.h:192
bool m_excludedFromBoard
Definition: symbol.h:226
SYMBOL & operator=(const SYMBOL &aItem)
Definition: symbol.h:91
int m_pinNameOffset
The offset in mils to draw the pin name.
Definition: symbol.h:219
bool GetExcludedFromSim() const override
Definition: symbol.h:175
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:46
#define DEFAULT_PIN_NAME_OFFSET
The intersheets references prefix string.
#define _(s)
INSPECT_RESULT
Definition: eda_item.h:43
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition: eda_item.h:82
#define IS_NEW
New item, just created.
#define STRUCT_DELETED
flag indication structures to be erased
TRANSFORM DefaultTransform
Definition: transform.cpp:32
@ LAYER_DEVICE
Definition: layer_ids.h:455
@ LAYER_FIELDS
Definition: layer_ids.h:451
#define REPORT(msg)
bool operator<(const LIB_SYMBOL &aItem1, const LIB_SYMBOL &aItem2)
Definition: lib_symbol.cpp:83
#define ITEM_DESC(item)
@ ENTRY_NORMAL
Definition: lib_symbol.h:61
@ ENTRY_LOCAL_POWER
Definition: lib_symbol.h:63
@ ENTRY_GLOBAL_POWER
Definition: lib_symbol.h:62
std::shared_ptr< LIB_SYMBOL > LIB_SYMBOL_SPTR
shared pointer to LIB_SYMBOL
Definition: lib_symbol.h:52
LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS
Definition: lib_symbol.h:55
constexpr int MilsToIU(int mils) const
Definition: base_units.h:93
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
A structure for storing weighted search terms.
http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared
Definition: lib_symbol.cpp:91
void operator()(void const *) const
Definition: lib_symbol.cpp:92
Definition for symbol library class.
#define MANDATORY_FIELDS
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ LIB_SYMBOL_T
Definition: typeinfo.h:148
@ TYPE_NOT_INIT
Definition: typeinfo.h:81
@ SCH_FIELD_T
Definition: typeinfo.h:150
@ SCH_SHAPE_T
Definition: typeinfo.h:149
@ SCH_TEXT_T
Definition: typeinfo.h:151
@ SCH_PIN_T
Definition: typeinfo.h:153
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:695