KiCad PCB EDA Suite
class_libentry.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 <stambaughw@gmail.com>
6  * Copyright (C) 2004-2020 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #include <fctsys.h>
27 #include <macros.h>
28 #include <kicad_string.h>
29 #include <sch_draw_panel.h>
30 #include <plotter.h>
31 #include <gr_basic.h>
32 #include <sch_screen.h>
33 #include <richio.h>
34 #include <trace_helpers.h>
35 #include <general.h>
36 #include <template_fieldnames.h>
37 #include <transform.h>
38 #include <class_library.h>
39 #include <class_libentry.h>
40 #include <lib_pin.h>
41 #include <lib_arc.h>
43 
44 
45 // the separator char between the subpart id and the reference
46 // 0 (no separator) or '.' or some other character
48 
49 // the ascii char value to calculate the subpart symbol id from the part number:
50 // 'A' or '1' usually. (to print U1.A or U1.1)
51 // if this a a digit, a number is used as id symbol
53 
54 
56 {
57  // Matches are scored by offset from front of string, so inclusion of this spacer
58  // discounts matches found after it.
59  static const wxString discount( wxT( " " ) );
60 
61  wxString text = GetKeyWords() + discount + GetDescription();
62  wxString footprint = GetFootprintField().GetText();
63 
64  if( !footprint.IsEmpty() )
65  {
66  text += discount + footprint;
67  }
68 
69  return text;
70 }
71 
72 
73 bool operator<( const LIB_PART& aItem1, const LIB_PART& aItem2 )
74 {
75  return aItem1.GetName() < aItem2.GetName();
76 }
77 
78 
81 {
82  void operator()(void const *) const
83  {
84  }
85 };
86 
87 
88 LIB_PART::LIB_PART( const wxString& aName, LIB_PART* aParent, PART_LIB* aLibrary ) :
90  m_me( this, null_deleter() )
91 {
93  m_unitCount = 1;
96  m_unitsLocked = false;
97  m_showPinNumbers = true;
98  m_showPinNames = true;
99 
100  // Add the MANDATORY_FIELDS in RAM only. These are assumed to be present
101  // when the field editors are invoked.
102  m_drawings[LIB_FIELD_T].reserve( 4 );
107 
108  SetName( aName );
109 
110  if( aParent )
111  SetParent( aParent );
112 
113  SetLib( aLibrary );
114 }
115 
116 
117 LIB_PART::LIB_PART( const LIB_PART& aPart, PART_LIB* aLibrary ) :
118  EDA_ITEM( aPart ),
119  m_me( this, null_deleter() )
120 {
121  LIB_ITEM* newItem;
122 
123  m_library = aLibrary;
124  m_name = aPart.m_name;
125  m_FootprintList = wxArrayString( aPart.m_FootprintList );
126  m_unitCount = aPart.m_unitCount;
132  m_options = aPart.m_options;
133  m_libId = aPart.m_libId;
135  m_keyWords = aPart.m_keyWords;
137 
138  for( const LIB_ITEM& oldItem : aPart.m_drawings )
139  {
140  if( ( oldItem.GetFlags() & ( IS_NEW | STRUCT_DELETED ) ) != 0 )
141  continue;
142 
143  try
144  {
145  newItem = (LIB_ITEM*) oldItem.Clone();
146  newItem->SetParent( this );
147  m_drawings.push_back( newItem );
148  }
149  catch( ... )
150  {
151  wxFAIL_MSG( "Failed to clone LIB_ITEM." );
152  }
153  }
154 
155  PART_SPTR parent = aPart.m_parent.lock();
156 
157  if( parent )
158  SetParent( parent.get() );
159 }
160 
161 
163 {
164 }
165 
166 
167 const LIB_PART& LIB_PART::operator=( const LIB_PART& aPart )
168 {
169  if( &aPart == this )
170  return aPart;
171 
172  LIB_ITEM* newItem;
173 
174  m_library = aPart.m_library;
175  m_name = aPart.m_name;
176  m_FootprintList = wxArrayString( aPart.m_FootprintList );
177  m_unitCount = aPart.m_unitCount;
183  m_options = aPart.m_options;
184  m_libId = aPart.m_libId;
186  m_keyWords = aPart.m_keyWords;
188 
189  m_drawings.clear();
190 
191  for( const LIB_ITEM& oldItem : aPart.m_drawings )
192  {
193  if( ( oldItem.GetFlags() & ( IS_NEW | STRUCT_DELETED ) ) != 0 )
194  continue;
195 
196  newItem = (LIB_ITEM*) oldItem.Clone();
197  newItem->SetParent( this );
198  m_drawings.push_back( newItem );
199  }
200 
201  PART_SPTR parent = aPart.m_parent.lock();
202 
203  if( parent )
204  SetParent( parent.get() );
205 
206  return *this;
207 }
208 
209 
210 int LIB_PART::Compare( const LIB_PART& aRhs ) const
211 {
212  if( m_me == aRhs.m_me )
213  return 0;
214 
215  int retv = m_name.Cmp( aRhs.m_name );
216 
217  if( retv )
218  return retv;
219 
220  retv = m_libId.compare( aRhs.m_libId );
221 
222  if( retv )
223  return retv;
224 
225  if( m_parent.lock() < aRhs.m_parent.lock() )
226  return -1;
227 
228  if( m_parent.lock() > aRhs.m_parent.lock() )
229  return 1;
230 
231  if( m_options != aRhs.m_options )
232  return ( m_options == ENTRY_NORMAL ) ? -1 : 1;
233 
234  if( m_unitCount != aRhs.m_unitCount )
235  return m_unitCount - aRhs.m_unitCount;
236 
237  if( m_drawings.size() != aRhs.m_drawings.size() )
238  return m_drawings.size() - aRhs.m_drawings.size();
239 
242 
243  while( lhsItem != m_drawings.end() )
244  {
245  if( lhsItem->Type() != rhsItem->Type() )
246  return lhsItem->Type() - rhsItem->Type();
247 
248  retv = lhsItem->compare( *rhsItem );
249 
250  if( retv )
251  return retv;
252 
253  ++lhsItem;
254  ++rhsItem;
255  }
256 
257  if( m_FootprintList.GetCount() != aRhs.m_FootprintList.GetCount() )
258  return m_FootprintList.GetCount() - aRhs.m_FootprintList.GetCount();
259 
260  for( size_t i = 0; i < m_FootprintList.GetCount(); i++ )
261  {
262  retv = m_FootprintList[i].Cmp( aRhs.m_FootprintList[i] );
263 
264  if( retv )
265  return retv;
266  }
267 
268  retv = m_description.Cmp( aRhs.m_description );
269 
270  if( retv )
271  return retv;
272 
273  retv = m_keyWords.Cmp( aRhs.m_keyWords );
274 
275  if( retv )
276  return retv;
277 
278  retv = m_docFileName.Cmp( aRhs.m_docFileName );
279 
280  if( retv )
281  return retv;
282 
283  if( m_pinNameOffset != aRhs.m_pinNameOffset )
284  return m_pinNameOffset - aRhs.m_pinNameOffset;
285 
286  if( m_unitsLocked != aRhs.m_unitsLocked )
287  return ( m_unitsLocked ) ? 1 : -1;
288 
289  if( m_showPinNames != aRhs.m_showPinNames )
290  return ( m_showPinNames ) ? 1 : -1;
291 
292  if( m_showPinNumbers != aRhs.m_showPinNumbers )
293  return ( m_showPinNumbers ) ? 1 : -1;
294 
295  return 0;
296 }
297 
298 
299 wxString LIB_PART::GetUnitReference( int aUnit )
300 {
301  return LIB_PART::SubReference( aUnit, false );
302 }
303 
304 
305 void LIB_PART::SetName( const wxString& aName )
306 {
307  wxString validatedName = LIB_ID::FixIllegalChars( aName, LIB_ID::ID_SCH );
308 
309  m_name = validatedName;
310  m_libId.SetLibItemName( validatedName, false );
311 
312  GetValueField().SetText( validatedName );
313 }
314 
315 
317 {
318  if( aParent )
319  {
320  m_parent = aParent->SharedPtr();
321 
322  // Inherit the parent mandatory field attributes.
323  for( int id=0; id<MANDATORY_FIELDS; ++id )
324  {
325  LIB_FIELD* field = GetField( id );
326 
327  // the MANDATORY_FIELDS are exactly that in RAM.
328  wxASSERT( field );
329 
330  LIB_FIELD* parentField = aParent->GetField( id );
331 
332  wxASSERT( parentField );
333 
334  wxString name = field->GetText();
335 
336  *field = *parentField;
337 
338  if( id == VALUE )
339  field->SetText( name );
340  else if( id == DATASHEET && !GetDocFileName().IsEmpty() )
341  field->SetText( GetDocFileName() );
342 
343  field->SetParent( this );
344  }
345  }
346  else
347  {
348  m_parent.reset();
349  }
350 }
351 
352 
353 std::unique_ptr< LIB_PART > LIB_PART::Flatten() const
354 {
355  std::unique_ptr< LIB_PART > retv;
356 
357  if( IsAlias() )
358  {
359  PART_SPTR parent = m_parent.lock();
360 
361  wxCHECK_MSG( parent, retv,
362  wxString::Format( "Parent of derived symbol '%s' undefined", m_name ) );
363 
364  // Copy the parent.
365  retv.reset( new LIB_PART( *parent.get() ) );
366 
367  // Now add the inherited part (this) information.
368  retv->SetName( m_name );
369 
370  const LIB_FIELD* datasheetField = GetField( DATASHEET );
371  retv->GetField( DATASHEET )->SetText( datasheetField->GetText() );
372  retv->SetDocFileName( m_docFileName );
373  retv->SetKeyWords( m_keyWords );
374  retv->SetDescription( m_description );
375  }
376  else
377  {
378  retv.reset( new LIB_PART( *this ) );
379  }
380 
381  return retv;
382 }
383 
384 
385 const wxString LIB_PART::GetLibraryName() const
386 {
387  if( m_library )
388  return m_library->GetName();
389 
390  return m_libId.GetLibNickname();
391 }
392 
393 
394 wxString LIB_PART::SubReference( int aUnit, bool aAddSeparator )
395 {
396  wxString subRef;
397 
398  if( m_subpartIdSeparator != 0 && aAddSeparator )
399  subRef << wxChar( m_subpartIdSeparator );
400 
401  if( m_subpartFirstId >= '0' && m_subpartFirstId <= '9' )
402  subRef << aUnit;
403  else
404  {
405  // use letters as notation. To allow more than 26 units, the sub ref
406  // use one letter if letter = A .. Z or a ... z, and 2 letters otherwise
407  // first letter is expected to be 'A' or 'a' (i.e. 26 letters are available)
408  int u;
409  aUnit -= 1; // Unit number starts to 1. now to 0.
410 
411  while( aUnit >= 26 ) // more than one letter are needed
412  {
413  u = aUnit / 26;
414  subRef << wxChar( m_subpartFirstId + u -1 );
415  aUnit %= 26;
416  }
417 
418  u = m_subpartFirstId + aUnit;
419  subRef << wxChar( u );
420  }
421 
422  return subRef;
423 }
424 
425 
426 void LIB_PART::Print( wxDC* aDc, const wxPoint& aOffset, int aMulti, int aConvert,
427  const PART_DRAW_OPTIONS& aOpts )
428 {
429  /* draw background for filled items using background option
430  * Solid lines will be drawn after the background
431  * Note also, background is not drawn when printing in black and white
432  */
433  if( !GetGRForceBlackPenState() )
434  {
435  for( LIB_ITEM& drawItem : m_drawings )
436  {
437  if( drawItem.m_Fill != FILLED_WITH_BG_BODYCOLOR )
438  continue;
439 
440  // Do not draw items not attached to the current part
441  if( aMulti && drawItem.m_Unit && ( drawItem.m_Unit != aMulti ) )
442  continue;
443 
444  if( aConvert && drawItem.m_Convert && ( drawItem.m_Convert != aConvert ) )
445  continue;
446 
447  if( drawItem.Type() == LIB_FIELD_T )
448  continue;
449 
450  // Now, draw only the background for items with
451  // m_Fill == FILLED_WITH_BG_BODYCOLOR:
452  drawItem.Print( aDc, aOffset, (void*) false, aOpts.transform );
453  }
454  }
455 
456  for( LIB_ITEM& drawItem : m_drawings )
457  {
458  // Do not draw items not attached to the current part
459  if( aMulti && drawItem.m_Unit && ( drawItem.m_Unit != aMulti ) )
460  continue;
461 
462  if( aConvert && drawItem.m_Convert && ( drawItem.m_Convert != aConvert ) )
463  continue;
464 
465  if( drawItem.Type() == LIB_FIELD_T )
466  {
467  LIB_FIELD& field = static_cast<LIB_FIELD&>( drawItem );
468 
469  if( field.IsVisible() && !aOpts.draw_visible_fields )
470  continue;
471 
472  if( !field.IsVisible() && !aOpts.draw_hidden_fields )
473  continue;
474  }
475 
476  if( drawItem.Type() == LIB_PIN_T )
477  {
478  drawItem.Print( aDc, aOffset, (void*) &aOpts, aOpts.transform );
479  }
480  else if( drawItem.Type() == LIB_FIELD_T )
481  {
482  drawItem.Print( aDc, aOffset, (void*) NULL, aOpts.transform );
483  }
484  else
485  {
486  bool forceNoFill = drawItem.m_Fill == FILLED_WITH_BG_BODYCOLOR;
487  drawItem.Print( aDc, aOffset, (void*) forceNoFill, aOpts.transform );
488  }
489  }
490 }
491 
492 
493 void LIB_PART::Plot( PLOTTER* aPlotter, int aUnit, int aConvert,
494  const wxPoint& aOffset, const TRANSFORM& aTransform )
495 {
496  wxASSERT( aPlotter != NULL );
497 
498  aPlotter->SetColor( aPlotter->ColorSettings()->GetColor( LAYER_DEVICE ) );
499  bool fill = aPlotter->GetColorMode();
500 
501  // draw background for filled items using background option
502  // Solid lines will be drawn after the background
503  for( LIB_ITEM& item : m_drawings )
504  {
505  // Lib Fields are not plotted here, because this plot function
506  // is used to plot schematic items, which have they own fields
507  if( item.Type() == LIB_FIELD_T )
508  continue;
509 
510  if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
511  continue;
512 
513  if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
514  continue;
515 
516  if( item.m_Fill == FILLED_WITH_BG_BODYCOLOR )
517  item.Plot( aPlotter, aOffset, fill, aTransform );
518  }
519 
520  // Not filled items and filled shapes are now plotted
521  // Items that have BG fills only get re-stroked to ensure the edges are in the foreground
522  for( LIB_ITEM& item : m_drawings )
523  {
524  if( item.Type() == LIB_FIELD_T )
525  continue;
526 
527  if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
528  continue;
529 
530  if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
531  continue;
532 
533  item.Plot( aPlotter, aOffset, fill && ( item.m_Fill != FILLED_WITH_BG_BODYCOLOR ),
534  aTransform );
535  }
536 }
537 
538 
539 void LIB_PART::PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert,
540  const wxPoint& aOffset, const TRANSFORM& aTransform )
541 {
542  wxASSERT( aPlotter != NULL );
543 
544  aPlotter->SetColor( aPlotter->ColorSettings()->GetColor( LAYER_FIELDS ) );
545  bool fill = aPlotter->GetColorMode();
546 
547  for( LIB_ITEM& item : m_drawings )
548  {
549  if( item.Type() != LIB_FIELD_T )
550  continue;
551 
552  if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
553  continue;
554 
555  if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
556  continue;
557 
558  LIB_FIELD& field = (LIB_FIELD&) item;
559 
560  // The reference is a special case: we should change the basic text
561  // to add '?' and the part id
562  wxString tmp = field.GetShownText();
563 
564  if( field.GetId() == REFERENCE )
565  {
566  wxString text = field.GetFullText( aUnit );
567  field.SetText( text );
568  }
569 
570  item.Plot( aPlotter, aOffset, fill, aTransform );
571  field.SetText( tmp );
572  }
573 }
574 
575 
577 {
578  wxASSERT( aItem != NULL );
579 
580  // none of the MANDATORY_FIELDS may be removed in RAM, but they may be
581  // omitted when saving to disk.
582  if( aItem->Type() == LIB_FIELD_T )
583  {
584  LIB_FIELD* field = (LIB_FIELD*) aItem;
585 
586  if( field->GetId() < MANDATORY_FIELDS )
587  {
588  wxLogWarning( _(
589  "An attempt was made to remove the %s field from component %s in library %s." ),
591  return;
592  }
593  }
594 
595  LIB_ITEMS& items = m_drawings[ aItem->Type() ];
596 
597  for( LIB_ITEMS::iterator i = items.begin(); i != items.end(); i++ )
598  {
599  if( *i == aItem )
600  {
601  items.erase( i );
602  SetModified();
603  break;
604  }
605  }
606 }
607 
608 
610 {
611  if( !aItem )
612  return;
613 
614  m_drawings.push_back( aItem );
615 }
616 
617 
619 {
620  if( aItem == NULL )
621  {
623 
624  return (it1 != m_drawings.end( aType ) ) ? &( *( m_drawings.begin( aType ) ) ) : nullptr;
625  }
626 
627  // Search for the last item, assume aItem is of type aType
628  wxASSERT( ( aType == TYPE_NOT_INIT ) || ( aType == aItem->Type() ) );
630 
631  while( ( it != m_drawings.end( aType ) ) && ( aItem != &( *it ) ) )
632  ++it;
633 
634  // Search the next item
635  if( it != m_drawings.end( aType ) )
636  {
637  ++it;
638 
639  if( it != m_drawings.end( aType ) )
640  return &( *it );
641  }
642 
643  return NULL;
644 }
645 
646 
647 void LIB_PART::GetPins( LIB_PINS& aList, int aUnit, int aConvert )
648 {
649  /* Notes:
650  * when aUnit == 0: no unit filtering
651  * when aConvert == 0: no convert (shape selection) filtering
652  * when .m_Unit == 0, the body item is common to units
653  * when .m_Convert == 0, the body item is common to shapes
654  */
655  for( LIB_ITEM& item : m_drawings[ LIB_PIN_T ] )
656  {
657  // Unit filtering:
658  if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
659  continue;
660 
661  // Shape filtering:
662  if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
663  continue;
664 
665  aList.push_back( (LIB_PIN*) &item );
666  }
667 }
668 
669 
670 LIB_PIN* LIB_PART::GetPin( const wxString& aNumber, int aUnit, int aConvert )
671 {
672  LIB_PINS pinList;
673 
674  GetPins( pinList, aUnit, aConvert );
675 
676  for( size_t i = 0; i < pinList.size(); i++ )
677  {
678  wxASSERT( pinList[i]->Type() == LIB_PIN_T );
679 
680  if( aNumber == pinList[i]->GetNumber() )
681  return pinList[i];
682  }
683 
684  return NULL;
685 }
686 
687 
688 bool LIB_PART::PinsConflictWith( LIB_PART& aOtherPart, bool aTestNums, bool aTestNames,
689  bool aTestType, bool aTestOrientation, bool aTestLength )
690 {
691  LIB_PINS thisPinList;
692  GetPins( thisPinList, /* aUnit */ 0, /* aConvert */ 0 );
693 
694  for( LIB_PIN* eachThisPin : thisPinList )
695  {
696  wxASSERT( eachThisPin );
697  LIB_PINS otherPinList;
698  aOtherPart.GetPins( otherPinList, /* aUnit */ 0, /* aConvert */ 0 );
699  bool foundMatch = false;
700 
701  for( LIB_PIN* eachOtherPin : otherPinList )
702  {
703  wxASSERT( eachOtherPin );
704  // Same position?
705  if( eachThisPin->GetPosition() != eachOtherPin->GetPosition() )
706  continue;
707 
708  // Same number?
709  if( aTestNums && ( eachThisPin->GetNumber() != eachOtherPin->GetNumber() ) )
710  continue;
711 
712  // Same name?
713  if( aTestNames && ( eachThisPin->GetName() != eachOtherPin->GetName() ) )
714  continue;
715 
716  // Same electrical type?
717  if( aTestType && ( eachThisPin->GetType() != eachOtherPin->GetType() ) )
718  continue;
719 
720  // Same orientation?
721  if( aTestOrientation
722  && ( eachThisPin->GetOrientation() != eachOtherPin->GetOrientation() ) )
723  continue;
724 
725  // Same length?
726  if( aTestLength && ( eachThisPin->GetLength() != eachOtherPin->GetLength() ) )
727  continue;
728 
729  foundMatch = true;
730  }
731 
732  if( !foundMatch )
733  {
734  // This means there was not an identical (according to the arguments)
735  // pin at the same position in the other component.
736  return true;
737  }
738  }
739 
740  // The loop never gave up, so no conflicts were found.
741  return false;
742 }
743 
744 
745 const EDA_RECT LIB_PART::GetUnitBoundingBox( int aUnit, int aConvert ) const
746 {
747  EDA_RECT bBox;
748  bool initialized = false;
749 
750  for( const LIB_ITEM& item : m_drawings )
751  {
752  if( ( item.m_Unit > 0 ) && ( ( m_unitCount > 1 ) && ( aUnit > 0 )
753  && ( aUnit != item.m_Unit ) ) )
754  continue;
755 
756  if( item.m_Convert > 0 && ( ( aConvert > 0 ) && ( aConvert != item.m_Convert ) ) )
757  continue;
758 
759  if ( ( item.Type() == LIB_FIELD_T ) && !( ( LIB_FIELD& ) item ).IsVisible() )
760  continue;
761 
762  if( initialized )
763  bBox.Merge( item.GetBoundingBox() );
764  else
765  {
766  bBox = item.GetBoundingBox();
767  initialized = true;
768  }
769  }
770 
771  return bBox;
772 }
773 
774 
775 void LIB_PART::ViewGetLayers( int aLayers[], int& aCount ) const
776 {
777  aCount = 6;
778  aLayers[0] = LAYER_DEVICE;
779  aLayers[1] = LAYER_DEVICE_BACKGROUND;
780  aLayers[2] = LAYER_REFERENCEPART;
781  aLayers[3] = LAYER_VALUEPART;
782  aLayers[4] = LAYER_FIELDS;
783  aLayers[5] = LAYER_SELECTION_SHADOWS;
784 }
785 
786 
787 const EDA_RECT LIB_PART::GetBodyBoundingBox( int aUnit, int aConvert ) const
788 {
789  EDA_RECT bbox;
790 
791  for( const LIB_ITEM& item : m_drawings )
792  {
793  if( ( item.m_Unit > 0 ) && ( ( m_unitCount > 1 ) && ( aUnit > 0 )
794  && ( aUnit != item.m_Unit ) ) )
795  continue;
796 
797  if( item.m_Convert > 0 && ( ( aConvert > 0 ) && ( aConvert != item.m_Convert ) ) )
798  continue;
799 
800  if( item.Type() == LIB_FIELD_T )
801  continue;
802 
803  bbox.Merge( item.GetBoundingBox() );
804  }
805 
806  return bbox;
807 }
808 
809 
811 {
813 }
814 
815 
816 void LIB_PART::SetFields( const std::vector <LIB_FIELD>& aFields )
817 {
818  deleteAllFields();
819 
820  for( unsigned i=0; i<aFields.size(); ++i )
821  {
822  // drawings is a ptr_vector, new and copy an object on the heap.
823  LIB_FIELD* field = new LIB_FIELD( aFields[i] );
824 
825  field->SetParent( this );
826  m_drawings.push_back( field );
827  }
828 }
829 
830 
832 {
833  LIB_FIELD* field;
834 
835  // Grab the MANDATORY_FIELDS first, in expected order given by
836  // enum NumFieldType
837  for( int id=0; id<MANDATORY_FIELDS; ++id )
838  {
839  field = GetField( id );
840 
841  // the MANDATORY_FIELDS are exactly that in RAM.
842  wxASSERT( field );
843 
844  aList.push_back( *field );
845  }
846 
847  // Now grab all the rest of fields.
848  for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
849  {
850  field = ( LIB_FIELD* ) &item;
851 
852  if( (unsigned) field->GetId() < MANDATORY_FIELDS )
853  continue; // was added above
854 
855  aList.push_back( *field );
856  }
857 }
858 
859 
860 LIB_FIELD* LIB_PART::GetField( int aId ) const
861 {
862  for( const LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
863  {
864  LIB_FIELD* field = ( LIB_FIELD* ) &item;
865 
866  if( field->GetId() == aId )
867  return field;
868  }
869 
870  return NULL;
871 }
872 
873 
874 LIB_FIELD* LIB_PART::FindField( const wxString& aFieldName )
875 {
876  for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
877  {
878  LIB_FIELD* field = ( LIB_FIELD* ) &item;
879 
880  if( field->GetName( NATIVE_FIELD_NAME ) == aFieldName )
881  return field;
882  }
883 
884  return NULL;
885 }
886 
887 
889 {
890  LIB_FIELD* field = GetField( VALUE );
891  wxASSERT( field != NULL );
892  return *field;
893 }
894 
895 
897 {
898  LIB_FIELD* field = GetField( REFERENCE );
899  wxASSERT( field != NULL );
900  return *field;
901 }
902 
903 
905 {
906  LIB_FIELD* field = GetField( FOOTPRINT );
907  wxASSERT( field != NULL );
908  return *field;
909 }
910 
911 
912 void LIB_PART::SetOffset( const wxPoint& aOffset )
913 {
914  for( LIB_ITEM& item : m_drawings )
915  item.Offset( aOffset );
916 }
917 
918 
920 {
921  m_drawings.unique();
922 }
923 
924 
926 {
927  for( const LIB_ITEM& item : m_drawings )
928  {
929  if( item.m_Convert > LIB_ITEM::LIB_CONVERT::BASE )
930  return true;
931  }
932 
933  if( PART_SPTR parent = m_parent.lock() )
934  {
935  for( const LIB_ITEM& item : parent->GetDrawItems() )
936  {
937  if( item.m_Convert > LIB_ITEM::LIB_CONVERT::BASE )
938  return true;
939  }
940  }
941 
942  return false;
943 }
944 
945 
947 {
948  for( LIB_ITEM& item : m_drawings )
949  item.ClearTempFlags();
950 }
951 
952 
954 {
955  for( LIB_ITEM& item : m_drawings )
956  item.ClearEditFlags();
957 }
958 
959 
960 LIB_ITEM* LIB_PART::LocateDrawItem( int aUnit, int aConvert,
961  KICAD_T aType, const wxPoint& aPoint )
962 {
963  for( LIB_ITEM& item : m_drawings )
964  {
965  if( ( aUnit && item.m_Unit && ( aUnit != item.m_Unit) )
966  || ( aConvert && item.m_Convert && ( aConvert != item.m_Convert ) )
967  || ( ( item.Type() != aType ) && ( aType != TYPE_NOT_INIT ) ) )
968  continue;
969 
970  if( item.HitTest( aPoint ) )
971  return &item;
972  }
973 
974  return NULL;
975 }
976 
977 
978 LIB_ITEM* LIB_PART::LocateDrawItem( int aUnit, int aConvert, KICAD_T aType,
979  const wxPoint& aPoint, const TRANSFORM& aTransform )
980 {
981  /* we use LocateDrawItem( int aUnit, int convert, KICAD_T type, const
982  * wxPoint& pt ) to search items.
983  * because this function uses DefaultTransform as orient/mirror matrix
984  * we temporary copy aTransform in DefaultTransform
985  */
986  LIB_ITEM* item;
987  TRANSFORM transform = DefaultTransform;
988  DefaultTransform = aTransform;
989 
990  item = LocateDrawItem( aUnit, aConvert, aType, aPoint );
991 
992  // Restore matrix
993  DefaultTransform = transform;
994 
995  return item;
996 }
997 
998 
999 SEARCH_RESULT LIB_PART::Visit( INSPECTOR aInspector, void* aTestData, const KICAD_T aFilterTypes[] )
1000 {
1001  // The part itself is never inspected, only its children
1002  for( LIB_ITEM& item : m_drawings )
1003  {
1004  if( item.IsType( aFilterTypes ) )
1005  {
1006  if( aInspector( &item, aTestData ) == SEARCH_RESULT::QUIT )
1007  return SEARCH_RESULT::QUIT;
1008  }
1009  }
1010 
1011  return SEARCH_RESULT::CONTINUE;
1012 }
1013 
1014 
1015 void LIB_PART::SetUnitCount( int aCount, bool aDuplicateDrawItems )
1016 {
1017  if( m_unitCount == aCount )
1018  return;
1019 
1020  if( aCount < m_unitCount )
1021  {
1023 
1024  while( i != m_drawings.end() )
1025  {
1026  if( i->m_Unit > aCount )
1027  i = m_drawings.erase( i );
1028  else
1029  ++i;
1030  }
1031  }
1032  else if( aDuplicateDrawItems )
1033  {
1034  int prevCount = m_unitCount;
1035 
1036  // Temporary storage for new items, as adding new items directly to
1037  // m_drawings may cause the buffer reallocation which invalidates the
1038  // iterators
1039  std::vector< LIB_ITEM* > tmp;
1040 
1041  for( LIB_ITEM& item : m_drawings )
1042  {
1043  if( item.m_Unit != 1 )
1044  continue;
1045 
1046  for( int j = prevCount + 1; j <= aCount; j++ )
1047  {
1048  LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
1049  newItem->m_Unit = j;
1050  tmp.push_back( newItem );
1051  }
1052  }
1053 
1054  for( auto item : tmp )
1055  m_drawings.push_back( item );
1056  }
1057 
1058  m_unitCount = aCount;
1059 }
1060 
1061 
1063 {
1064  if( PART_SPTR parent = m_parent.lock() )
1065  return parent->GetUnitCount();
1066 
1067  return m_unitCount;
1068 }
1069 
1070 
1071 void LIB_PART::SetConversion( bool aSetConvert, bool aDuplicatePins )
1072 {
1073  if( aSetConvert == HasConversion() )
1074  return;
1075 
1076  // Duplicate items to create the converted shape
1077  if( aSetConvert )
1078  {
1079  if( aDuplicatePins )
1080  {
1081  std::vector< LIB_ITEM* > tmp; // Temporarily store the duplicated pins here.
1082 
1083  for( LIB_ITEM& item : m_drawings )
1084  {
1085  // Only pins are duplicated.
1086  if( item.Type() != LIB_PIN_T )
1087  continue;
1088 
1089  if( item.m_Convert == 1 )
1090  {
1091  LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
1092  newItem->m_Convert = 2;
1093  tmp.push_back( newItem );
1094  }
1095  }
1096 
1097  // Transfer the new pins to the LIB_PART.
1098  for( unsigned i = 0; i < tmp.size(); i++ )
1099  m_drawings.push_back( tmp[i] );
1100  }
1101  }
1102  else
1103  {
1104  // Delete converted shape items because the converted shape does
1105  // not exist
1107 
1108  while( i != m_drawings.end() )
1109  {
1110  if( i->m_Convert > 1 )
1111  i = m_drawings.erase( i );
1112  else
1113  ++i;
1114  }
1115  }
1116 }
1117 
1118 
1119 void LIB_PART::SetSubpartIdNotation( int aSep, int aFirstId )
1120 {
1121  m_subpartFirstId = 'A';
1123 
1124  if( aSep == '.' || aSep == '-' || aSep == '_' )
1125  m_subpartIdSeparator = aSep;
1126 
1127  if( aFirstId == '1' && aSep != 0 )
1128  m_subpartFirstId = aFirstId;
1129 }
1130 
1131 
1132 std::vector<LIB_ITEM*> LIB_PART::GetUnitItems( int aUnit, int aConvert )
1133 {
1134  std::vector<LIB_ITEM*> unitItems;
1135 
1136  for( LIB_ITEM& item : m_drawings )
1137  {
1138  if( item.Type() == LIB_FIELD_T )
1139  continue;
1140 
1141  if( ( aConvert == -1 && item.GetUnit() == aUnit )
1142  || ( aUnit == -1 && item.GetConvert() == aConvert )
1143  || ( aUnit == item.GetUnit() && aConvert == item.GetConvert() ) )
1144  unitItems.push_back( &item );
1145  }
1146 
1147  return unitItems;
1148 }
1149 
1150 
1151 std::vector<struct PART_UNITS> LIB_PART::GetUnitDrawItems()
1152 {
1153  std::vector<struct PART_UNITS> units;
1154 
1155  for( LIB_ITEM& item : m_drawings )
1156  {
1157  if( item.Type() == LIB_FIELD_T )
1158  continue;
1159 
1160  int unit = item.GetUnit();
1161  int convert = item.GetConvert();
1162 
1163  auto it = std::find_if( units.begin(), units.end(),
1164  [unit, convert] ( const auto& a ) {
1165  return a.m_unit == unit && a.m_convert == convert;
1166  } );
1167 
1168  if( it == units.end() )
1169  {
1170  struct PART_UNITS newUnit;
1171  newUnit.m_unit = item.GetUnit();
1172  newUnit.m_convert = item.GetConvert();
1173  newUnit.m_items.push_back( &item );
1174  units.emplace_back( newUnit );
1175  }
1176  else
1177  {
1178  it->m_items.push_back( &item );
1179  }
1180  }
1181 
1182  return units;
1183 }
1184 
1185 
1186 std::vector<struct PART_UNITS> LIB_PART::GetUniqueUnits()
1187 {
1188  int unitNum;
1189  size_t i;
1190  struct PART_UNITS unit;
1191  std::vector<LIB_ITEM*> compareDrawItems;
1192  std::vector<LIB_ITEM*> currentDrawItems;
1193  std::vector<struct PART_UNITS> uniqueUnits;
1194 
1195  // The first unit is guarenteed to be unique so always include it.
1196  unit.m_unit = 1;
1197  unit.m_convert = 1;
1198  unit.m_items = GetUnitItems( 1, 1 );
1199 
1200  // There are no unique units if there are no draw items other than fields.
1201  if( unit.m_items.size() == 0 )
1202  return uniqueUnits;
1203 
1204  uniqueUnits.emplace_back( unit );
1205 
1206  if( ( GetUnitCount() == 1 || UnitsLocked() ) && !HasConversion() )
1207  return uniqueUnits;
1208 
1209  currentDrawItems = unit.m_items;
1210 
1211  for( unitNum = 2; unitNum <= GetUnitCount(); unitNum++ )
1212  {
1213  compareDrawItems = GetUnitItems( unitNum, 1 );
1214 
1215  wxCHECK2_MSG( compareDrawItems.size() != 0, continue,
1216  "Multiple unit symbol defined with empty units." );
1217 
1218  if( currentDrawItems.size() != compareDrawItems.size() )
1219  {
1220  unit.m_unit = unitNum;
1221  unit.m_convert = 1;
1222  unit.m_items = compareDrawItems;
1223  uniqueUnits.emplace_back( unit );
1224  }
1225  else
1226  {
1227  for( i = 0; i < currentDrawItems.size(); i++ )
1228  {
1229  if( currentDrawItems[i]->compare( *compareDrawItems[i],
1231  {
1232  unit.m_unit = unitNum;
1233  unit.m_convert = 1;
1234  unit.m_items = compareDrawItems;
1235  uniqueUnits.emplace_back( unit );
1236  }
1237  }
1238  }
1239  }
1240 
1241  if( HasConversion() )
1242  {
1243  currentDrawItems = GetUnitItems( 1, 2 );
1244 
1245  if( ( GetUnitCount() == 1 || UnitsLocked() ) )
1246  {
1247  unit.m_unit = 1;
1248  unit.m_convert = 2;
1249  unit.m_items = currentDrawItems;
1250  uniqueUnits.emplace_back( unit );
1251 
1252  return uniqueUnits;
1253  }
1254 
1255  for( unitNum = 2; unitNum <= GetUnitCount(); unitNum++ )
1256  {
1257  compareDrawItems = GetUnitItems( unitNum, 2 );
1258 
1259  wxCHECK2_MSG( compareDrawItems.size() != 0, continue,
1260  "Multiple unit symbol defined with empty units." );
1261 
1262  if( currentDrawItems.size() != compareDrawItems.size() )
1263  {
1264  unit.m_unit = unitNum;
1265  unit.m_convert = 2;
1266  unit.m_items = compareDrawItems;
1267  uniqueUnits.emplace_back( unit );
1268  }
1269  else
1270  {
1271  for( i = 0; i < currentDrawItems.size(); i++ )
1272  {
1273  if( currentDrawItems[i]->compare( *compareDrawItems[i],
1275  {
1276  unit.m_unit = unitNum;
1277  unit.m_convert = 2;
1278  unit.m_items = compareDrawItems;
1279  uniqueUnits.emplace_back( unit );
1280  }
1281  }
1282  }
1283  }
1284  }
1285 
1286  return uniqueUnits;
1287 }
timestamp_t m_dateLastEdition
Date of the last modification.
const wxString GetName() const
Return the file name without path or extension.
LIB_FIELD & GetFootprintField()
Return reference to the footprint field.
void SetLib(PART_LIB *aLibrary)
bool PinsConflictWith(LIB_PART &aOtherPart, bool aTestNums, bool aTestNames, bool aTestType, bool aTestOrientation, bool aTestLength)
Return true if this part's pins do not match another part's pins.
void SetModified()
Definition: base_struct.cpp:94
static int m_subpartIdSeparator
the separator char between the subpart id and the reference like U1A ( m_subpartIdSeparator = 0 ) or ...
ITERATOR begin(int aType=UNDEFINED_TYPE)
Definition: multivector.h:183
#define UNIT
virtual ~LIB_PART()
name of datasheet
void Merge(const EDA_RECT &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
bool m_showPinNumbers
Determines if part pin numbers are visible.
wxString GetName() const override
const wxString GetLibraryName() const
bool HasConversion() const
Test if part has more than one body conversion type (DeMorgan).
virtual void SetColor(COLOR4D color)=0
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_item.h:54
bool IsVisible() const
Definition: eda_text.h:170
int m_unitCount
Number of units (parts) per package.
LIB_ITEM * GetNextDrawItem(LIB_ITEM *aItem=NULL, KICAD_T aType=TYPE_NOT_INIT)
Return the next draw object pointer.
PART_LIB * m_library
Library the part belongs to if any.
void clear(int aType=UNDEFINED_TYPE)
Definition: multivector.h:207
The first 4 are mandatory, and must be instantiated in SCH_COMPONENT and LIB_PART constructors.
Field object used in symbol libraries.
Definition: lib_field.h:59
void SetUnitCount(int aCount, bool aDuplicateDrawItems=true)
Set the units per part count.
static int m_subpartFirstId
the ASCII char value to calculate the subpart symbol id from the part number: only 'A',...
void unique()
Remove duplicate elements in list.
Definition: multivector.h:251
std::vector< struct PART_UNITS > GetUnitDrawItems()
Return a list of LIB_ITEM objects separated by unit and convert number.
LIB_ITEMS_CONTAINER m_drawings
Drawing items of this part.
std::vector< LIB_ITEM * > m_items
The items unique to this unit and alternate body style.
LIB_FIELD & GetValueField()
Return reference to the value field.
TRANSFORM DefaultTransform
int Compare(const LIB_PART &aRhs) const
Comparison test that can be used for operators.
int m_Unit
Unit identification for multiple parts per package.
Definition: lib_item.h:81
wxString m_docFileName
Associate doc file name.
int GetId() const
Definition: lib_field.h:139
wxString GetKeyWords() const
int m_unit
The unit number.
LIBRENTRYOPTIONS m_options
Special part features such as POWER or NORMAL.)
#define TRANSLATE_FIELD_NAME
Returns the field name.
Definition: lib_field.h:124
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:316
Field Reference of part, i.e. "IC21".
bool draw_hidden_fields
Whether to draw "hidden" fields.
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
bool m_unitsLocked
True if part has multiple units and changing one unit does not automatically change another unit.
void ClearTempFlags()
Clears the status flag all draw objects in this part.
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
The base class for drawable items used by schematic library components.
Definition: lib_item.h:60
std::vector< struct PART_UNITS > GetUniqueUnits()
Return a list of unit numbers that are unique to this symbol.
LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS
This file contains miscellaneous commonly used macros and functions.
void PlotLibFields(PLOTTER *aPlotter, int aUnit, int aConvert, const wxPoint &aOffset, const TRANSFORM &aTransform)
Plot Lib Fields only of the part to plotter.
void SetOffset(const wxPoint &aOffset)
Move the part aOffset.
ITERATOR end(int aType=UNDEFINED_TYPE)
Definition: multivector.h:189
void AddDrawItem(LIB_ITEM *aItem)
Add a new draw aItem to the draw object list.
void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on.
#define IS_NEW
New item, just created.
Definition: base_struct.h:120
int m_pinNameOffset
The offset in mils to draw the pin name.
void GetPins(LIB_PINS &aList, int aUnit=0, int aConvert=0)
Return a list of pin object pointers from the draw item list.
const INSPECTOR_FUNC & INSPECTOR
Definition: base_struct.h:108
void deleteAllFields()
PART_REF m_parent
Use for inherited symbols.
#define VALUE
void Print(wxDC *aDc, const wxPoint &aOffset, int aMulti, int aConvert, const PART_DRAW_OPTIONS &aOpts)
Print part.
void operator()(void const *) const
std::vector< LIB_ITEM * > GetUnitItems(int aUnit, int aConvert)
Return a list of item pointers for aUnit and aConvert for this symbol.
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
void SetConversion(bool aSetConvert, bool aDuplicatePins=true)
Set or clear the alternate body style (DeMorgan) for the part.
LIB_FIELD & GetReferenceField()
Return reference to the reference designator field.
void Plot(PLOTTER *aPlotter, int aUnit, int aConvert, const wxPoint &aOffset, const TRANSFORM &aTransform)
Plot lib part to plotter.
LIB_FIELD * FindField(const wxString &aFieldName)
Find a field within this part matching aFieldName and returns it or NULL if not found.
virtual void SetText(const wxString &aText)
Definition: eda_text.cpp:111
#define NULL
int GetUnitCount() const override
For items with units, return the number of units.
wxString m_name
Symbol name.
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:218
COLOR_SETTINGS * ColorSettings()
Definition: plotter.h:145
void push_back(T *aItem)
Definition: multivector.h:169
Class LIB_PIN definition.
std::shared_ptr< LIB_PART > PART_SPTR
shared pointer to LIB_PART
PART_SPTR SharedPtr()
void SetParent(LIB_PART *aParent=nullptr)
Define a library symbol object.
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:129
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
wxLogTrace helper definitions.
wxString GetDocFileName() const
wxString GetDescription() override
LIB_PART(const wxString &aName, LIB_PART *aParent=nullptr, PART_LIB *aLibrary=nullptr)
void RemoveDuplicateDrawItems()
Remove duplicate draw items from list.
wxArrayString m_FootprintList
List of suitable footprint names for the part (wild card names accepted).
std::unique_ptr< LIB_PART > Flatten() const
Return a flattened symbol inheritance to the caller.
LIB_ID m_libId
int SetLibItemName(const UTF8 &aLibItemName, bool aTestForRev=true)
Override the library item name portion of the LIB_ID to aLibItemName.
Definition: lib_id.cpp:206
ITERATOR erase(const ITERATOR &aIterator)
Definition: multivector.h:174
http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared
ITERATOR_BASE< LIB_ITEM, MULTIVECTOR< LIB_ITEM, FIRST_TYPE_VAL, LAST_TYPE_VAL >, typename ITEM_PTR_VECTOR::iterator > ITERATOR
The non-const iterator
Definition: multivector.h:160
int m_convert
The alternate body style of the unit.
wxString GetUnitReference(int aUnit) override
Return an identifier for aUnit for symbols with units.
Base plotter engine class.
Definition: plotter.h:104
COLOR4D GetColor(int aLayer) const
wxString GetName(bool aTranslate) const
Definition: lib_field.cpp:387
const char * name
Definition: DXF_plotter.cpp:60
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define _(s)
Definition: 3d_actions.cpp:33
static void SetSubpartIdNotation(int aSep, int aFirstId)
Set the separator char between the subpart id and the reference 0 (no separator) or '.
void ClearEditFlags()
std::vector< LIB_FIELD > LIB_FIELDS
Definition: lib_field.h:223
bool IsAlias() const
const EDA_RECT GetUnitBoundingBox(int aUnit, int aConvert) const
Get the bounding box for the symbol.
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
wxString GetFullText(int unit=1) const
Return the text of a field.
Definition: lib_field.cpp:315
static wxString SubReference(int aUnit, bool aAddSeparator=true)
wxString GetSearchText() override
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:166
#define DEFAULT_PIN_NAME_OFFSET
The offset of the pin name string from the end of the pin in mils.
Definition: lib_pin.h:43
SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[]) override
Function Visit may be re-implemented for each derived class in order to handle all the types given by...
static UTF8 FixIllegalChars(const UTF8 &aLibItemName, LIB_ID_TYPE aType, bool aLib=false)
Replace illegal LIB_ID item name characters with underscores '_'.
Definition: lib_id.cpp:352
int m_Convert
Shape identification for alternate body styles.
Definition: lib_item.h:87
ITERATOR_BASE< const LIB_ITEM, const MULTIVECTOR< LIB_ITEM, FIRST_TYPE_VAL, LAST_TYPE_VAL >, typename ITEM_PTR_VECTOR::const_iterator > CONST_ITERATOR
The const iterator
Definition: multivector.h:162
LIB_ITEM * LocateDrawItem(int aUnit, int aConvert, KICAD_T aType, const wxPoint &aPoint)
Locate a draw object.
const LIB_PART & operator=(const LIB_PART &aPart)
virtual void SetName(const wxString &aName)
wxString m_keyWords
keyword list (used for search for parts by keyword)
bool operator<(const LIB_PART &aItem1, const LIB_PART &aItem2)
virtual wxString GetShownText() const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:129
Definition for part library class.
bool draw_visible_fields
Whether to draw "visible" fields.
SEARCH_RESULT
Definition: base_struct.h:54
bool GetGRForceBlackPenState(void)
Function GetGRForceBlackPenState.
Definition: gr_basic.cpp:211
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:259
LIB_FIELD * GetField(int aId) const
Return pointer to the requested field.
bool m_showPinNames
Determines if part pin names are visible.
const EDA_RECT GetBodyBoundingBox(int aUnit, int aConvert) const
Get the symbol bounding box excluding fields.
void SetFields(const std::vector< LIB_FIELD > &aFieldsList)
Overwrite all the existing fields in this symbol with fields supplied in aFieldsList.
wxString m_description
documentation for info
Object used to load, save, search, and otherwise manipulate symbol library files.
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:123
size_t size(int aType=UNDEFINED_TYPE) const
Definition: multivector.h:220
TRANSFORM transform
Coordinate adjustment settings.
bool UnitsLocked() const
Check whether part units are interchangeable.
#define NATIVE_FIELD_NAME
Definition: lib_field.h:125
void GetFields(LIB_FIELDS &aList)
Return a list of fields within this part.
LIB_PIN * GetPin(const wxString &aNumber, int aUnit=0, int aConvert=0)
Return pin object with the requested pin aNumber.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
void RemoveDrawItem(LIB_ITEM *aItem)
Remove draw aItem from list.
PART_SPTR m_me
< http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared
bool GetColorMode() const
Definition: plotter.h:138