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  m_includeInBom( true ),
92  m_includeOnBoard( true )
93 {
95  m_unitCount = 1;
98  m_unitsLocked = false;
99  m_showPinNumbers = true;
100  m_showPinNames = true;
101 
102  // Add the MANDATORY_FIELDS in RAM only. These are assumed to be present
103  // when the field editors are invoked.
104  m_drawings[LIB_FIELD_T].reserve( 4 );
109 
110  SetName( aName );
111 
112  if( aParent )
113  SetParent( aParent );
114 
115  SetLib( aLibrary );
116 }
117 
118 
119 LIB_PART::LIB_PART( const LIB_PART& aPart, PART_LIB* aLibrary ) :
120  EDA_ITEM( aPart ),
121  m_me( this, null_deleter() )
122 {
123  LIB_ITEM* newItem;
124 
125  m_library = aLibrary;
126  m_name = aPart.m_name;
127  m_FootprintList = wxArrayString( aPart.m_FootprintList );
128  m_unitCount = aPart.m_unitCount;
136  m_options = aPart.m_options;
137  m_libId = aPart.m_libId;
139  m_keyWords = aPart.m_keyWords;
140 
141  ClearSelected();
142 
143  for( const LIB_ITEM& oldItem : aPart.m_drawings )
144  {
145  if( ( oldItem.GetFlags() & ( IS_NEW | STRUCT_DELETED ) ) != 0 )
146  continue;
147 
148  try
149  {
150  newItem = (LIB_ITEM*) oldItem.Clone();
151  newItem->ClearSelected();
152  newItem->SetParent( this );
153  m_drawings.push_back( newItem );
154  }
155  catch( ... )
156  {
157  wxFAIL_MSG( "Failed to clone LIB_ITEM." );
158  }
159  }
160 
161  PART_SPTR parent = aPart.m_parent.lock();
162 
163  if( parent )
164  SetParent( parent.get() );
165 }
166 
167 
169 {
170 }
171 
172 
173 const LIB_PART& LIB_PART::operator=( const LIB_PART& aPart )
174 {
175  if( &aPart == this )
176  return aPart;
177 
178  LIB_ITEM* newItem;
179 
180  m_library = aPart.m_library;
181  m_name = aPart.m_name;
182  m_FootprintList = wxArrayString( aPart.m_FootprintList );
183  m_unitCount = aPart.m_unitCount;
191  m_options = aPart.m_options;
192  m_libId = aPart.m_libId;
194  m_keyWords = aPart.m_keyWords;
195 
196  m_drawings.clear();
197 
198  for( const LIB_ITEM& oldItem : aPart.m_drawings )
199  {
200  if( ( oldItem.GetFlags() & ( IS_NEW | STRUCT_DELETED ) ) != 0 )
201  continue;
202 
203  newItem = (LIB_ITEM*) oldItem.Clone();
204  newItem->SetParent( this );
205  m_drawings.push_back( newItem );
206  }
207 
208  PART_SPTR parent = aPart.m_parent.lock();
209 
210  if( parent )
211  SetParent( parent.get() );
212 
213  return *this;
214 }
215 
216 
217 int LIB_PART::Compare( const LIB_PART& aRhs ) const
218 {
219  if( m_me == aRhs.m_me )
220  return 0;
221 
222  int retv = m_name.Cmp( aRhs.m_name );
223 
224  if( retv )
225  return retv;
226 
227  retv = m_libId.compare( aRhs.m_libId );
228 
229  if( retv )
230  return retv;
231 
232  if( m_parent.lock() < aRhs.m_parent.lock() )
233  return -1;
234 
235  if( m_parent.lock() > aRhs.m_parent.lock() )
236  return 1;
237 
238  if( m_options != aRhs.m_options )
239  return ( m_options == ENTRY_NORMAL ) ? -1 : 1;
240 
241  if( m_unitCount != aRhs.m_unitCount )
242  return m_unitCount - aRhs.m_unitCount;
243 
244  if( m_drawings.size() != aRhs.m_drawings.size() )
245  return m_drawings.size() - aRhs.m_drawings.size();
246 
249 
250  while( lhsItem != m_drawings.end() )
251  {
252  if( lhsItem->Type() != rhsItem->Type() )
253  return lhsItem->Type() - rhsItem->Type();
254 
255  retv = lhsItem->compare( *rhsItem );
256 
257  if( retv )
258  return retv;
259 
260  ++lhsItem;
261  ++rhsItem;
262  }
263 
264  if( m_FootprintList.GetCount() != aRhs.m_FootprintList.GetCount() )
265  return m_FootprintList.GetCount() - aRhs.m_FootprintList.GetCount();
266 
267  for( size_t i = 0; i < m_FootprintList.GetCount(); i++ )
268  {
269  retv = m_FootprintList[i].Cmp( aRhs.m_FootprintList[i] );
270 
271  if( retv )
272  return retv;
273  }
274 
275  retv = m_description.Cmp( aRhs.m_description );
276 
277  if( retv )
278  return retv;
279 
280  retv = m_keyWords.Cmp( aRhs.m_keyWords );
281 
282  if( retv )
283  return retv;
284 
285  if( m_pinNameOffset != aRhs.m_pinNameOffset )
286  return m_pinNameOffset - aRhs.m_pinNameOffset;
287 
288  if( m_unitsLocked != aRhs.m_unitsLocked )
289  return ( m_unitsLocked ) ? 1 : -1;
290 
291  if( m_showPinNames != aRhs.m_showPinNames )
292  return ( m_showPinNames ) ? 1 : -1;
293 
294  if( m_showPinNumbers != aRhs.m_showPinNumbers )
295  return ( m_showPinNumbers ) ? 1 : -1;
296 
297  if( m_includeInBom != aRhs.m_includeInBom )
298  return ( m_includeInBom ) ? 1 : -1;
299 
300  if( m_includeOnBoard != aRhs.m_includeOnBoard )
301  return ( m_includeOnBoard ) ? 1 : -1;
302 
303  return 0;
304 }
305 
306 
307 wxString LIB_PART::GetUnitReference( int aUnit )
308 {
309  return LIB_PART::SubReference( aUnit, false );
310 }
311 
312 
313 void LIB_PART::SetName( const wxString& aName )
314 {
315  wxString validatedName = LIB_ID::FixIllegalChars( aName, LIB_ID::ID_SCH );
316 
317  m_name = validatedName;
318  m_libId.SetLibItemName( validatedName, false );
319 
320  GetValueField().SetText( validatedName );
321 }
322 
323 
325 {
326  if( aParent )
327  m_parent = aParent->SharedPtr();
328  else
329  m_parent.reset();
330 }
331 
332 
333 std::unique_ptr< LIB_PART > LIB_PART::Flatten() const
334 {
335  std::unique_ptr< LIB_PART > retv;
336 
337  if( IsAlias() )
338  {
339  PART_SPTR parent = m_parent.lock();
340 
341  wxCHECK_MSG( parent, retv,
342  wxString::Format( "Parent of derived symbol '%s' undefined", m_name ) );
343 
344  // Copy the parent.
345  retv.reset( new LIB_PART( *parent.get() ) );
346 
347  retv->SetName( m_name );
348 
349  // Now add the inherited part mandatory field (this) information.
350  for( int i = 0; i < MANDATORY_FIELDS; i++ )
351  {
352  wxString tmp = GetField( i )->GetText();
353 
354  // If the field isn't defined then inherit the parent field value.
355  if( tmp.IsEmpty() )
356  retv->GetField( i )->SetText( parent->GetField( i )->GetText() );
357  else
358  *retv->GetField( i ) = *GetField( i );
359  }
360 
361  // Grab all the rest of derived symbol fields.
362  for( const LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
363  {
364  const LIB_FIELD* aliasField = dynamic_cast<const LIB_FIELD*>( &item );
365 
366  wxCHECK2( aliasField, continue );
367 
368  // Mandatory fields were already resolved.
369  if( aliasField->IsMandatory() )
370  continue;
371 
372  LIB_FIELD* newField = new LIB_FIELD( *aliasField );
373  newField->SetParent( retv.get() );
374 
375  LIB_FIELD* parentField = retv->FindField( aliasField->GetName() );
376 
377  if( !parentField ) // Derived symbol field does not exist in parent symbol.
378  {
379  retv->AddDrawItem( newField );
380  }
381  else // Derived symbol field overrides the parent symbol field.
382  {
383  retv->RemoveDrawItem( parentField );
384  retv->AddDrawItem( newField );
385  }
386  }
387 
388  retv->SetKeyWords( m_keyWords );
389  retv->SetDescription( m_description );
390  }
391  else
392  {
393  retv.reset( new LIB_PART( *this ) );
394  }
395 
396  return retv;
397 }
398 
399 
400 const wxString LIB_PART::GetLibraryName() const
401 {
402  if( m_library )
403  return m_library->GetName();
404 
405  return m_libId.GetLibNickname();
406 }
407 
408 
409 wxString LIB_PART::SubReference( int aUnit, bool aAddSeparator )
410 {
411  wxString subRef;
412 
413  if( m_subpartIdSeparator != 0 && aAddSeparator )
414  subRef << wxChar( m_subpartIdSeparator );
415 
416  if( m_subpartFirstId >= '0' && m_subpartFirstId <= '9' )
417  subRef << aUnit;
418  else
419  {
420  // use letters as notation. To allow more than 26 units, the sub ref
421  // use one letter if letter = A .. Z or a ... z, and 2 letters otherwise
422  // first letter is expected to be 'A' or 'a' (i.e. 26 letters are available)
423  int u;
424  aUnit -= 1; // Unit number starts to 1. now to 0.
425 
426  while( aUnit >= 26 ) // more than one letter are needed
427  {
428  u = aUnit / 26;
429  subRef << wxChar( m_subpartFirstId + u -1 );
430  aUnit %= 26;
431  }
432 
433  u = m_subpartFirstId + aUnit;
434  subRef << wxChar( u );
435  }
436 
437  return subRef;
438 }
439 
440 
441 void LIB_PART::Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset, int aMulti,
442  int aConvert, const PART_DRAW_OPTIONS& aOpts )
443 {
444  /* draw background for filled items using background option
445  * Solid lines will be drawn after the background
446  * Note also, background is not drawn when printing in black and white
447  */
448  if( !GetGRForceBlackPenState() )
449  {
450  for( LIB_ITEM& drawItem : m_drawings )
451  {
452  if( drawItem.m_Fill != FILLED_WITH_BG_BODYCOLOR )
453  continue;
454 
455  // Do not draw items not attached to the current part
456  if( aMulti && drawItem.m_Unit && ( drawItem.m_Unit != aMulti ) )
457  continue;
458 
459  if( aConvert && drawItem.m_Convert && ( drawItem.m_Convert != aConvert ) )
460  continue;
461 
462  if( drawItem.Type() == LIB_FIELD_T )
463  continue;
464 
465  // Now, draw only the background for items with
466  // m_Fill == FILLED_WITH_BG_BODYCOLOR:
467  drawItem.Print( aSettings, aOffset, (void*) false, aOpts.transform );
468  }
469  }
470 
471  for( LIB_ITEM& drawItem : m_drawings )
472  {
473  // Do not draw items not attached to the current part
474  if( aMulti && drawItem.m_Unit && ( drawItem.m_Unit != aMulti ) )
475  continue;
476 
477  if( aConvert && drawItem.m_Convert && ( drawItem.m_Convert != aConvert ) )
478  continue;
479 
480  if( drawItem.Type() == LIB_FIELD_T )
481  {
482  LIB_FIELD& field = static_cast<LIB_FIELD&>( drawItem );
483 
484  if( field.IsVisible() && !aOpts.draw_visible_fields )
485  continue;
486 
487  if( !field.IsVisible() && !aOpts.draw_hidden_fields )
488  continue;
489  }
490 
491  if( drawItem.Type() == LIB_PIN_T )
492  {
493  drawItem.Print( aSettings, aOffset, (void*) &aOpts, aOpts.transform );
494  }
495  else if( drawItem.Type() == LIB_FIELD_T )
496  {
497  drawItem.Print( aSettings, aOffset, (void*) NULL, aOpts.transform );
498  }
499  else
500  {
501  bool forceNoFill = drawItem.m_Fill == FILLED_WITH_BG_BODYCOLOR;
502  drawItem.Print( aSettings, aOffset, (void*) forceNoFill, aOpts.transform );
503  }
504  }
505 }
506 
507 
508 void LIB_PART::Plot( PLOTTER* aPlotter, int aUnit, int aConvert,
509  const wxPoint& aOffset, const TRANSFORM& aTransform )
510 {
511  wxASSERT( aPlotter != NULL );
512 
513  aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_DEVICE ) );
514  bool fill = aPlotter->GetColorMode();
515 
516  // draw background for filled items using background option
517  // Solid lines will be drawn after the background
518  for( LIB_ITEM& item : m_drawings )
519  {
520  // Lib Fields are not plotted here, because this plot function
521  // is used to plot schematic items, which have they own fields
522  if( item.Type() == LIB_FIELD_T )
523  continue;
524 
525  if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
526  continue;
527 
528  if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
529  continue;
530 
531  if( item.m_Fill == FILLED_WITH_BG_BODYCOLOR )
532  item.Plot( aPlotter, aOffset, fill, aTransform );
533  }
534 
535  // Not filled items and filled shapes are now plotted
536  // Items that have BG fills only get re-stroked to ensure the edges are in the foreground
537  for( LIB_ITEM& item : m_drawings )
538  {
539  if( item.Type() == LIB_FIELD_T )
540  continue;
541 
542  if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
543  continue;
544 
545  if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
546  continue;
547 
548  item.Plot( aPlotter, aOffset, fill && ( item.m_Fill != FILLED_WITH_BG_BODYCOLOR ),
549  aTransform );
550  }
551 }
552 
553 
554 void LIB_PART::PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert,
555  const wxPoint& aOffset, const TRANSFORM& aTransform )
556 {
557  wxASSERT( aPlotter != NULL );
558 
559  aPlotter->SetColor( aPlotter->RenderSettings()->GetLayerColor( LAYER_FIELDS ) );
560  bool fill = aPlotter->GetColorMode();
561 
562  for( LIB_ITEM& item : m_drawings )
563  {
564  if( item.Type() != LIB_FIELD_T )
565  continue;
566 
567  if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
568  continue;
569 
570  if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
571  continue;
572 
573  LIB_FIELD& field = (LIB_FIELD&) item;
574 
575  // The reference is a special case: we should change the basic text
576  // to add '?' and the part id
577  wxString tmp = field.GetShownText();
578 
579  if( field.GetId() == REFERENCE )
580  {
581  wxString text = field.GetFullText( aUnit );
582  field.SetText( text );
583  }
584 
585  item.Plot( aPlotter, aOffset, fill, aTransform );
586  field.SetText( tmp );
587  }
588 }
589 
590 
592 {
593  wxASSERT( aItem != NULL );
594 
595  // none of the MANDATORY_FIELDS may be removed in RAM, but they may be
596  // omitted when saving to disk.
597  if( aItem->Type() == LIB_FIELD_T )
598  {
599  if( static_cast<LIB_FIELD*>( aItem )->IsMandatory() )
600  return;
601  }
602 
603  LIB_ITEMS& items = m_drawings[ aItem->Type() ];
604 
605  for( LIB_ITEMS::iterator i = items.begin(); i != items.end(); i++ )
606  {
607  if( *i == aItem )
608  {
609  items.erase( i );
610  SetModified();
611  break;
612  }
613  }
614 }
615 
616 
618 {
619  if( !aItem )
620  return;
621 
622  m_drawings.push_back( aItem );
623 }
624 
625 
627 {
628  if( aItem == NULL )
629  {
631 
632  return (it1 != m_drawings.end( aType ) ) ? &( *( m_drawings.begin( aType ) ) ) : nullptr;
633  }
634 
635  // Search for the last item, assume aItem is of type aType
636  wxASSERT( ( aType == TYPE_NOT_INIT ) || ( aType == aItem->Type() ) );
638 
639  while( ( it != m_drawings.end( aType ) ) && ( aItem != &( *it ) ) )
640  ++it;
641 
642  // Search the next item
643  if( it != m_drawings.end( aType ) )
644  {
645  ++it;
646 
647  if( it != m_drawings.end( aType ) )
648  return &( *it );
649  }
650 
651  return NULL;
652 }
653 
654 
655 void LIB_PART::GetPins( LIB_PINS& aList, int aUnit, int aConvert )
656 {
657  /* Notes:
658  * when aUnit == 0: no unit filtering
659  * when aConvert == 0: no convert (shape selection) filtering
660  * when .m_Unit == 0, the body item is common to units
661  * when .m_Convert == 0, the body item is common to shapes
662  */
663  for( LIB_ITEM& item : m_drawings[ LIB_PIN_T ] )
664  {
665  // Unit filtering:
666  if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
667  continue;
668 
669  // Shape filtering:
670  if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
671  continue;
672 
673  aList.push_back( (LIB_PIN*) &item );
674  }
675 }
676 
677 
678 LIB_PIN* LIB_PART::GetPin( const wxString& aNumber, int aUnit, int aConvert )
679 {
680  LIB_PINS pinList;
681 
682  GetPins( pinList, aUnit, aConvert );
683 
684  for( size_t i = 0; i < pinList.size(); i++ )
685  {
686  wxASSERT( pinList[i]->Type() == LIB_PIN_T );
687 
688  if( aNumber == pinList[i]->GetNumber() )
689  return pinList[i];
690  }
691 
692  return NULL;
693 }
694 
695 
696 bool LIB_PART::PinsConflictWith( LIB_PART& aOtherPart, bool aTestNums, bool aTestNames,
697  bool aTestType, bool aTestOrientation, bool aTestLength )
698 {
699  LIB_PINS thisPinList;
700  GetPins( thisPinList, /* aUnit */ 0, /* aConvert */ 0 );
701 
702  for( LIB_PIN* eachThisPin : thisPinList )
703  {
704  wxASSERT( eachThisPin );
705  LIB_PINS otherPinList;
706  aOtherPart.GetPins( otherPinList, /* aUnit */ 0, /* aConvert */ 0 );
707  bool foundMatch = false;
708 
709  for( LIB_PIN* eachOtherPin : otherPinList )
710  {
711  wxASSERT( eachOtherPin );
712 
713  // Same unit?
714  if( eachThisPin->GetUnit() != eachOtherPin->GetUnit() )
715  continue;
716 
717  // Same body stype?
718  if( eachThisPin->GetConvert() != eachOtherPin->GetConvert() )
719  continue;
720 
721  // Same position?
722  if( eachThisPin->GetPosition() != eachOtherPin->GetPosition() )
723  continue;
724 
725  // Same number?
726  if( aTestNums && ( eachThisPin->GetNumber() != eachOtherPin->GetNumber() ) )
727  continue;
728 
729  // Same name?
730  if( aTestNames && ( eachThisPin->GetName() != eachOtherPin->GetName() ) )
731  continue;
732 
733  // Same electrical type?
734  if( aTestType && ( eachThisPin->GetType() != eachOtherPin->GetType() ) )
735  continue;
736 
737  // Same orientation?
738  if( aTestOrientation
739  && ( eachThisPin->GetOrientation() != eachOtherPin->GetOrientation() ) )
740  continue;
741 
742  // Same length?
743  if( aTestLength && ( eachThisPin->GetLength() != eachOtherPin->GetLength() ) )
744  continue;
745 
746  foundMatch = true;
747  break; // Match found so seach is complete.
748  }
749 
750  if( !foundMatch )
751  {
752  // This means there was not an identical (according to the arguments)
753  // pin at the same position in the other component.
754  return true;
755  }
756  }
757 
758  // The loop never gave up, so no conflicts were found.
759  return false;
760 }
761 
762 
763 const EDA_RECT LIB_PART::GetUnitBoundingBox( int aUnit, int aConvert ) const
764 {
765  EDA_RECT bBox;
766  bool initialized = false;
767 
768  for( const LIB_ITEM& item : m_drawings )
769  {
770  if( ( item.m_Unit > 0 ) && ( ( m_unitCount > 1 ) && ( aUnit > 0 )
771  && ( aUnit != item.m_Unit ) ) )
772  continue;
773 
774  if( item.m_Convert > 0 && ( ( aConvert > 0 ) && ( aConvert != item.m_Convert ) ) )
775  continue;
776 
777  if ( ( item.Type() == LIB_FIELD_T ) && !( ( LIB_FIELD& ) item ).IsVisible() )
778  continue;
779 
780  if( initialized )
781  bBox.Merge( item.GetBoundingBox() );
782  else
783  {
784  bBox = item.GetBoundingBox();
785  initialized = true;
786  }
787  }
788 
789  return bBox;
790 }
791 
792 
793 void LIB_PART::ViewGetLayers( int aLayers[], int& aCount ) const
794 {
795  aCount = 6;
796  aLayers[0] = LAYER_DEVICE;
797  aLayers[1] = LAYER_DEVICE_BACKGROUND;
798  aLayers[2] = LAYER_REFERENCEPART;
799  aLayers[3] = LAYER_VALUEPART;
800  aLayers[4] = LAYER_FIELDS;
801  aLayers[5] = LAYER_SELECTION_SHADOWS;
802 }
803 
804 
805 const EDA_RECT LIB_PART::GetBodyBoundingBox( int aUnit, int aConvert ) const
806 {
807  EDA_RECT bbox;
808 
809  for( const LIB_ITEM& item : m_drawings )
810  {
811  if( ( item.m_Unit > 0 ) && ( ( m_unitCount > 1 ) && ( aUnit > 0 )
812  && ( aUnit != item.m_Unit ) ) )
813  continue;
814 
815  if( item.m_Convert > 0 && ( ( aConvert > 0 ) && ( aConvert != item.m_Convert ) ) )
816  continue;
817 
818  if( item.Type() == LIB_FIELD_T )
819  continue;
820 
821  bbox.Merge( item.GetBoundingBox() );
822  }
823 
824  return bbox;
825 }
826 
827 
829 {
831 }
832 
833 
834 void LIB_PART::SetFields( const std::vector <LIB_FIELD>& aFields )
835 {
836  deleteAllFields();
837 
838  for( unsigned i=0; i<aFields.size(); ++i )
839  {
840  // drawings is a ptr_vector, new and copy an object on the heap.
841  LIB_FIELD* field = new LIB_FIELD( aFields[i] );
842 
843  field->SetParent( this );
844  m_drawings.push_back( field );
845  }
846 }
847 
848 
850 {
851  LIB_FIELD* field;
852 
853  // Grab the MANDATORY_FIELDS first, in expected order given by
854  // enum NumFieldType
855  for( int id=0; id<MANDATORY_FIELDS; ++id )
856  {
857  field = GetField( id );
858 
859  // the MANDATORY_FIELDS are exactly that in RAM.
860  wxASSERT( field );
861 
862  aList.push_back( *field );
863  }
864 
865  // Now grab all the rest of fields.
866  for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
867  {
868  field = ( LIB_FIELD* ) &item;
869 
870  if( field->IsMandatory() )
871  continue; // was added above
872 
873  aList.push_back( *field );
874  }
875 }
876 
877 
878 LIB_FIELD* LIB_PART::GetField( int aId ) const
879 {
880  for( const LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
881  {
882  LIB_FIELD* field = ( LIB_FIELD* ) &item;
883 
884  if( field->GetId() == aId )
885  return field;
886  }
887 
888  return NULL;
889 }
890 
891 
892 LIB_FIELD* LIB_PART::FindField( const wxString& aFieldName )
893 {
894  for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
895  {
896  if( static_cast<LIB_FIELD*>( &item )->GetCanonicalName() == aFieldName )
897  return static_cast<LIB_FIELD*>( &item );
898  }
899 
900  return NULL;
901 }
902 
903 
904 const LIB_FIELD* LIB_PART::FindField( const wxString& aFieldName ) const
905 {
906  for( const LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
907  {
908  if( static_cast<const LIB_FIELD*>( &item )->GetCanonicalName() == aFieldName )
909  return static_cast<const LIB_FIELD*>( &item );
910  }
911 
912  return NULL;
913 }
914 
915 
917 {
918  LIB_FIELD* field = GetField( VALUE );
919  wxASSERT( field != NULL );
920  return *field;
921 }
922 
923 
925 {
926  LIB_FIELD* field = GetField( REFERENCE );
927  wxASSERT( field != NULL );
928  return *field;
929 }
930 
931 
933 {
934  LIB_FIELD* field = GetField( FOOTPRINT );
935  wxASSERT( field != NULL );
936  return *field;
937 }
938 
939 
941 {
942  LIB_FIELD* field = GetField( DATASHEET );
943  wxASSERT( field != NULL );
944  return *field;
945 }
946 
947 
948 void LIB_PART::SetOffset( const wxPoint& aOffset )
949 {
950  for( LIB_ITEM& item : m_drawings )
951  item.Offset( aOffset );
952 }
953 
954 
956 {
957  m_drawings.unique();
958 }
959 
960 
962 {
963  for( const LIB_ITEM& item : m_drawings )
964  {
965  if( item.m_Convert > LIB_ITEM::LIB_CONVERT::BASE )
966  return true;
967  }
968 
969  if( PART_SPTR parent = m_parent.lock() )
970  {
971  for( const LIB_ITEM& item : parent->GetDrawItems() )
972  {
973  if( item.m_Convert > LIB_ITEM::LIB_CONVERT::BASE )
974  return true;
975  }
976  }
977 
978  return false;
979 }
980 
981 
983 {
984  for( LIB_ITEM& item : m_drawings )
985  item.ClearTempFlags();
986 }
987 
988 
990 {
991  for( LIB_ITEM& item : m_drawings )
992  item.ClearEditFlags();
993 }
994 
995 
996 LIB_ITEM* LIB_PART::LocateDrawItem( int aUnit, int aConvert,
997  KICAD_T aType, const wxPoint& aPoint )
998 {
999  for( LIB_ITEM& item : m_drawings )
1000  {
1001  if( ( aUnit && item.m_Unit && ( aUnit != item.m_Unit) )
1002  || ( aConvert && item.m_Convert && ( aConvert != item.m_Convert ) )
1003  || ( ( item.Type() != aType ) && ( aType != TYPE_NOT_INIT ) ) )
1004  continue;
1005 
1006  if( item.HitTest( aPoint ) )
1007  return &item;
1008  }
1009 
1010  return NULL;
1011 }
1012 
1013 
1014 LIB_ITEM* LIB_PART::LocateDrawItem( int aUnit, int aConvert, KICAD_T aType,
1015  const wxPoint& aPoint, const TRANSFORM& aTransform )
1016 {
1017  /* we use LocateDrawItem( int aUnit, int convert, KICAD_T type, const
1018  * wxPoint& pt ) to search items.
1019  * because this function uses DefaultTransform as orient/mirror matrix
1020  * we temporary copy aTransform in DefaultTransform
1021  */
1022  LIB_ITEM* item;
1023  TRANSFORM transform = DefaultTransform;
1024  DefaultTransform = aTransform;
1025 
1026  item = LocateDrawItem( aUnit, aConvert, aType, aPoint );
1027 
1028  // Restore matrix
1029  DefaultTransform = transform;
1030 
1031  return item;
1032 }
1033 
1034 
1035 SEARCH_RESULT LIB_PART::Visit( INSPECTOR aInspector, void* aTestData, const KICAD_T aFilterTypes[] )
1036 {
1037  // The part itself is never inspected, only its children
1038  for( LIB_ITEM& item : m_drawings )
1039  {
1040  if( item.IsType( aFilterTypes ) )
1041  {
1042  if( aInspector( &item, aTestData ) == SEARCH_RESULT::QUIT )
1043  return SEARCH_RESULT::QUIT;
1044  }
1045  }
1046 
1047  return SEARCH_RESULT::CONTINUE;
1048 }
1049 
1050 
1051 void LIB_PART::SetUnitCount( int aCount, bool aDuplicateDrawItems )
1052 {
1053  if( m_unitCount == aCount )
1054  return;
1055 
1056  if( aCount < m_unitCount )
1057  {
1059 
1060  while( i != m_drawings.end() )
1061  {
1062  if( i->m_Unit > aCount )
1063  i = m_drawings.erase( i );
1064  else
1065  ++i;
1066  }
1067  }
1068  else if( aDuplicateDrawItems )
1069  {
1070  int prevCount = m_unitCount;
1071 
1072  // Temporary storage for new items, as adding new items directly to
1073  // m_drawings may cause the buffer reallocation which invalidates the
1074  // iterators
1075  std::vector< LIB_ITEM* > tmp;
1076 
1077  for( LIB_ITEM& item : m_drawings )
1078  {
1079  if( item.m_Unit != 1 )
1080  continue;
1081 
1082  for( int j = prevCount + 1; j <= aCount; j++ )
1083  {
1084  LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
1085  newItem->m_Unit = j;
1086  tmp.push_back( newItem );
1087  }
1088  }
1089 
1090  for( auto item : tmp )
1091  m_drawings.push_back( item );
1092  }
1093 
1094  m_unitCount = aCount;
1095 }
1096 
1097 
1099 {
1100  if( PART_SPTR parent = m_parent.lock() )
1101  return parent->GetUnitCount();
1102 
1103  return m_unitCount;
1104 }
1105 
1106 
1107 void LIB_PART::SetConversion( bool aSetConvert, bool aDuplicatePins )
1108 {
1109  if( aSetConvert == HasConversion() )
1110  return;
1111 
1112  // Duplicate items to create the converted shape
1113  if( aSetConvert )
1114  {
1115  if( aDuplicatePins )
1116  {
1117  std::vector< LIB_ITEM* > tmp; // Temporarily store the duplicated pins here.
1118 
1119  for( LIB_ITEM& item : m_drawings )
1120  {
1121  // Only pins are duplicated.
1122  if( item.Type() != LIB_PIN_T )
1123  continue;
1124 
1125  if( item.m_Convert == 1 )
1126  {
1127  LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
1128  newItem->m_Convert = 2;
1129  tmp.push_back( newItem );
1130  }
1131  }
1132 
1133  // Transfer the new pins to the LIB_PART.
1134  for( unsigned i = 0; i < tmp.size(); i++ )
1135  m_drawings.push_back( tmp[i] );
1136  }
1137  }
1138  else
1139  {
1140  // Delete converted shape items because the converted shape does
1141  // not exist
1143 
1144  while( i != m_drawings.end() )
1145  {
1146  if( i->m_Convert > 1 )
1147  i = m_drawings.erase( i );
1148  else
1149  ++i;
1150  }
1151  }
1152 }
1153 
1154 
1155 void LIB_PART::SetSubpartIdNotation( int aSep, int aFirstId )
1156 {
1157  m_subpartFirstId = 'A';
1159 
1160  if( aSep == '.' || aSep == '-' || aSep == '_' )
1161  m_subpartIdSeparator = aSep;
1162 
1163  if( aFirstId == '1' && aSep != 0 )
1164  m_subpartFirstId = aFirstId;
1165 }
1166 
1167 
1168 std::vector<LIB_ITEM*> LIB_PART::GetUnitItems( int aUnit, int aConvert )
1169 {
1170  std::vector<LIB_ITEM*> unitItems;
1171 
1172  for( LIB_ITEM& item : m_drawings )
1173  {
1174  if( item.Type() == LIB_FIELD_T )
1175  continue;
1176 
1177  if( ( aConvert == -1 && item.GetUnit() == aUnit )
1178  || ( aUnit == -1 && item.GetConvert() == aConvert )
1179  || ( aUnit == item.GetUnit() && aConvert == item.GetConvert() ) )
1180  unitItems.push_back( &item );
1181  }
1182 
1183  return unitItems;
1184 }
1185 
1186 
1187 std::vector<struct PART_UNITS> LIB_PART::GetUnitDrawItems()
1188 {
1189  std::vector<struct PART_UNITS> units;
1190 
1191  for( LIB_ITEM& item : m_drawings )
1192  {
1193  if( item.Type() == LIB_FIELD_T )
1194  continue;
1195 
1196  int unit = item.GetUnit();
1197  int convert = item.GetConvert();
1198 
1199  auto it = std::find_if( units.begin(), units.end(),
1200  [unit, convert] ( const auto& a ) {
1201  return a.m_unit == unit && a.m_convert == convert;
1202  } );
1203 
1204  if( it == units.end() )
1205  {
1206  struct PART_UNITS newUnit;
1207  newUnit.m_unit = item.GetUnit();
1208  newUnit.m_convert = item.GetConvert();
1209  newUnit.m_items.push_back( &item );
1210  units.emplace_back( newUnit );
1211  }
1212  else
1213  {
1214  it->m_items.push_back( &item );
1215  }
1216  }
1217 
1218  return units;
1219 }
1220 
1221 
1222 std::vector<struct PART_UNITS> LIB_PART::GetUniqueUnits()
1223 {
1224  int unitNum;
1225  size_t i;
1226  struct PART_UNITS unit;
1227  std::vector<LIB_ITEM*> compareDrawItems;
1228  std::vector<LIB_ITEM*> currentDrawItems;
1229  std::vector<struct PART_UNITS> uniqueUnits;
1230 
1231  // The first unit is guarenteed to be unique so always include it.
1232  unit.m_unit = 1;
1233  unit.m_convert = 1;
1234  unit.m_items = GetUnitItems( 1, 1 );
1235 
1236  // There are no unique units if there are no draw items other than fields.
1237  if( unit.m_items.size() == 0 )
1238  return uniqueUnits;
1239 
1240  uniqueUnits.emplace_back( unit );
1241 
1242  if( ( GetUnitCount() == 1 || UnitsLocked() ) && !HasConversion() )
1243  return uniqueUnits;
1244 
1245  currentDrawItems = unit.m_items;
1246 
1247  for( unitNum = 2; unitNum <= GetUnitCount(); unitNum++ )
1248  {
1249  compareDrawItems = GetUnitItems( unitNum, 1 );
1250 
1251  wxCHECK2_MSG( compareDrawItems.size() != 0, continue,
1252  "Multiple unit symbol defined with empty units." );
1253 
1254  if( currentDrawItems.size() != compareDrawItems.size() )
1255  {
1256  unit.m_unit = unitNum;
1257  unit.m_convert = 1;
1258  unit.m_items = compareDrawItems;
1259  uniqueUnits.emplace_back( unit );
1260  }
1261  else
1262  {
1263  for( i = 0; i < currentDrawItems.size(); i++ )
1264  {
1265  if( currentDrawItems[i]->compare( *compareDrawItems[i],
1266  LIB_ITEM::COMPARE_FLAGS::UNIT ) != 0 )
1267  {
1268  unit.m_unit = unitNum;
1269  unit.m_convert = 1;
1270  unit.m_items = compareDrawItems;
1271  uniqueUnits.emplace_back( unit );
1272  }
1273  }
1274  }
1275  }
1276 
1277  if( HasConversion() )
1278  {
1279  currentDrawItems = GetUnitItems( 1, 2 );
1280 
1281  if( ( GetUnitCount() == 1 || UnitsLocked() ) )
1282  {
1283  unit.m_unit = 1;
1284  unit.m_convert = 2;
1285  unit.m_items = currentDrawItems;
1286  uniqueUnits.emplace_back( unit );
1287 
1288  return uniqueUnits;
1289  }
1290 
1291  for( unitNum = 2; unitNum <= GetUnitCount(); unitNum++ )
1292  {
1293  compareDrawItems = GetUnitItems( unitNum, 2 );
1294 
1295  wxCHECK2_MSG( compareDrawItems.size() != 0, continue,
1296  "Multiple unit symbol defined with empty units." );
1297 
1298  if( currentDrawItems.size() != compareDrawItems.size() )
1299  {
1300  unit.m_unit = unitNum;
1301  unit.m_convert = 2;
1302  unit.m_items = compareDrawItems;
1303  uniqueUnits.emplace_back( unit );
1304  }
1305  else
1306  {
1307  for( i = 0; i < currentDrawItems.size(); i++ )
1308  {
1309  if( currentDrawItems[i]->compare( *compareDrawItems[i],
1310  LIB_ITEM::COMPARE_FLAGS::UNIT ) != 0 )
1311  {
1312  unit.m_unit = unitNum;
1313  unit.m_convert = 2;
1314  unit.m_items = compareDrawItems;
1315  uniqueUnits.emplace_back( unit );
1316  }
1317  }
1318  }
1319  }
1320  }
1321 
1322  return uniqueUnits;
1323 }
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:87
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
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.
LIB_FIELD & GetDatasheetField()
Return reference to the datasheet field.
bool m_showPinNumbers
Determines if part pin numbers are visible.
RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output surfac...
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
void ClearSelected()
Definition: base_struct.h:211
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_item.h:55
bool IsVisible() const
Definition: eda_text.h:186
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
bool m_includeOnBoard
Determines if symbol should be excluded from.
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.
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
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
int GetId() const
Definition: lib_field.h:138
wxString GetKeyWords() const
int m_unit
The unit number.
LIBRENTRYOPTIONS m_options
Special part features such as POWER or NORMAL.)
bool m_includeInBom
Determines if symbol should be included in schematic BOM.
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 Name Module PCB, i.e. "16DIP300".
Field Reference of part, i.e. "IC21".
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 void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:196
wxString GetName(bool aUseDefaultName=true) const
Returns the field name.
Definition: lib_field.cpp:366
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:61
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:117
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:105
void deleteAllFields()
PART_REF m_parent
Use for inherited symbols.
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:121
#define NULL
int GetUnitCount() const override
For items with units, return the number of units.
wxString m_name
Symbol name.
void push_back(T *aItem)
Definition: multivector.h:169
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:126
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
wxLogTrace helper definitions.
wxString GetDescription() override
LIB_PART(const wxString &aName, LIB_PART *aParent=nullptr, PART_LIB *aLibrary=nullptr)
void RemoveDuplicateDrawItems()
Remove duplicate draw items from list.
#define DEFAULT_PIN_NAME_OFFSET
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.
Field Value of part, i.e. "3.3K".
wxString GetUnitReference(int aUnit) override
Return an identifier for aUnit for symbols with units.
Base plotter engine class.
Definition: plotter.h:114
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:147
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:201
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:218
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:298
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:159
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)
void Print(RENDER_SETTINGS *aSettings, const wxPoint &aOffset, int aMulti, int aConvert, const PART_DRAW_OPTIONS &aOpts)
Print part.
bool operator<(const LIB_PART &aItem1, const LIB_PART &aItem2)
Definition for part library class.
SEARCH_RESULT
Definition: base_struct.h:51
bool GetGRForceBlackPenState(void)
Function GetGRForceBlackPenState.
Definition: gr_basic.cpp:213
STATUS_FLAGS GetFlags() const
Definition: base_struct.h:234
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:127
size_t size(int aType=UNDEFINED_TYPE) const
Definition: multivector.h:220
virtual wxString GetShownText(int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:134
bool UnitsLocked() const
Check whether part units are interchangeable.
bool IsMandatory() const
Definition: lib_field.cpp:456
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:193
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:144