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-2018 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 
30 #include <fctsys.h>
31 #include <macros.h>
32 #include <kicad_string.h>
33 #include <sch_draw_panel.h>
34 #include <plotter.h>
35 #include <gr_basic.h>
36 #include <sch_screen.h>
37 #include <richio.h>
38 #include <kicad_string.h>
39 #include <trace_helpers.h>
40 
41 #include <general.h>
42 #include <template_fieldnames.h>
43 #include <transform.h>
44 #include <class_library.h>
45 #include <class_libentry.h>
46 #include <lib_pin.h>
47 #include <lib_arc.h>
48 #include <lib_bezier.h>
49 #include <lib_circle.h>
50 #include <lib_polyline.h>
51 #include <lib_rectangle.h>
52 #include <lib_text.h>
53 
54 
55 // the separator char between the subpart id and the reference
56 // 0 (no separator) or '.' or some other character
58 
59 // the ascii char value to calculate the subpart symbol id from the part number:
60 // 'A' or '1' usually. (to print U1.A or U1.1)
61 // if this a a digit, a number is used as id symbol
63 
64 
65 LIB_ALIAS::LIB_ALIAS( const wxString& aName, LIB_PART* aRootPart ) :
67  shared( aRootPart ),
68  tmpUnit( 0 ),
69  tmpConversion( 0 )
70 {
71  SetName( aName );
72 }
73 
74 
75 LIB_ALIAS::LIB_ALIAS( const LIB_ALIAS& aAlias, LIB_PART* aRootPart ) :
76  EDA_ITEM( aAlias ),
77  shared( aRootPart ),
78  tmpUnit( 0 ),
79  tmpConversion( 0 )
80 {
81  name = aAlias.name;
82 
83  description = aAlias.description;
84  keyWords = aAlias.keyWords;
85  docFileName = aAlias.docFileName;
86 }
87 
88 
90 {
91  wxLogTrace( traceSchLibMem, wxT( "%s: destroying alias:'%s'" ),
92  GetChars( wxString::FromAscii( __WXFUNCTION__ ) ), GetChars( GetName() ) );
93 
94  wxCHECK_RET( shared, wxT( "~LIB_ALIAS() without a LIB_PART" ) );
95 
96  if( shared )
97  shared->RemoveAlias( this );
98 }
99 
100 
102 {
103  wxASSERT_MSG( shared, wxT( "LIB_ALIAS without a LIB_PART" ) );
104 
105  if( shared )
106  return shared->GetLibraryName();
107 
108  return wxEmptyString;
109 }
110 
111 
112 bool LIB_ALIAS::IsRoot() const
113 {
114  return name == shared->GetName();
115 }
116 
117 
119 {
120  LIB_ID id = shared->GetLibId();
121  id.SetLibItemName( name );
122  return id;
123 }
124 
125 
127 {
128  return shared->GetLib();
129 }
130 
131 
132 void LIB_ALIAS::SetName( const wxString& aName )
133 {
135 }
136 
137 
139 {
140  return shared->GetUnitCount();
141 }
142 
143 
144 wxString LIB_ALIAS::GetUnitReference( int aUnit )
145 {
146  return LIB_PART::SubReference( aUnit, false );
147 }
148 
149 
151 {
152  // a LIB_ALIAS does not really have a bounding box.
153  // return a 0 size rect.
154  EDA_RECT dummy;
155  return dummy;
156 };
157 
158 
160 {
161  // Matches are scored by offset from front of string, so inclusion of this spacer
162  // discounts matches found after it.
163  static const wxString discount( wxT( " " ) );
164 
165  wxString text = GetKeyWords() + discount + GetDescription();
166 
167  // If a footprint is defined for the part, add it to the serach string
168  if( shared )
169  {
170  wxString footprint = shared->GetFootprintField().GetText();
171 
172  if( !footprint.IsEmpty() )
173  text += discount + footprint;
174  }
175 
176  return text;
177 }
178 
179 
180 bool LIB_ALIAS::operator==( const wxChar* aName ) const
181 {
182  return name == aName;
183 }
184 
185 
186 bool operator<( const LIB_ALIAS& aItem1, const LIB_ALIAS& aItem2 )
187 {
188  return aItem1.GetName() < aItem2.GetName();
189 }
190 
191 
192 void LIB_ALIAS::ViewGetLayers( int aLayers[], int& aCount ) const
193 {
194  // An alias's fields don't know how to fetch their parent's values so we don't let
195  // them draw themselves. This means the alias always has to draw them, which means
196  // it has to "own" their layers as well.
197  aCount = 5;
198  aLayers[0] = LAYER_DEVICE;
199  aLayers[1] = LAYER_DEVICE_BACKGROUND;
200  aLayers[2] = LAYER_REFERENCEPART;
201  aLayers[3] = LAYER_VALUEPART;
202  aLayers[4] = LAYER_FIELDS;
203 }
204 
205 
208 {
209  void operator()(void const *) const
210  {
211  }
212 };
213 
214 
215 LIB_PART::LIB_PART( const wxString& aName, PART_LIB* aLibrary ) :
216  EDA_ITEM( LIB_PART_T ),
217  m_me( this, null_deleter() )
218 {
219  m_dateLastEdition = 0;
220  m_unitCount = 1;
221  m_pinNameOffset = 40;
223  m_unitsLocked = false;
224  m_showPinNumbers = true;
225  m_showPinNames = true;
226 
227  // Add the MANDATORY_FIELDS in RAM only. These are assumed to be present
228  // when the field editors are invoked.
229  m_drawings[LIB_FIELD_T].reserve( 4 );
234 
235  SetLib( aLibrary );
236  SetName( aName );
237 }
238 
239 
240 LIB_PART::LIB_PART( LIB_PART& aPart, PART_LIB* aLibrary ) :
241  EDA_ITEM( aPart ),
242  m_me( this, null_deleter() )
243 {
244  LIB_ITEM* newItem;
245 
246  m_library = aLibrary;
248  m_unitCount = aPart.m_unitCount;
254  m_options = aPart.m_options;
255  m_libId = aPart.m_libId;
256 
257  for( LIB_ITEM& oldItem : aPart.m_drawings )
258  {
259  if( oldItem.IsNew() )
260  continue;
261 
262  newItem = (LIB_ITEM*) oldItem.Clone();
263  newItem->SetParent( this );
264  m_drawings.push_back( newItem );
265  }
266 
267  for( size_t i = 0; i < aPart.m_aliases.size(); i++ )
268  {
269  LIB_ALIAS* alias = new LIB_ALIAS( *aPart.m_aliases[i], this );
270  m_aliases.push_back( alias );
271  }
272 }
273 
274 
276 {
277  wxLogTrace( traceSchLibMem,
278  wxT( "%s: destroying symbol with alias list count of %llu" ),
279  GetChars( wxString::FromAscii( __WXFUNCTION__ ) ),
280  (long long unsigned) m_aliases.size() );
281 
282  // If the part is being deleted directly rather than through the library,
283  // delete all of the aliases.
284  while( m_aliases.size() )
285  {
286  LIB_ALIAS* alias = m_aliases.back();
287  m_aliases.pop_back();
288  delete alias;
289  }
290 }
291 
292 
293 const wxString LIB_PART::GetLibraryName()
294 {
295  if( m_library )
296  return m_library->GetName();
297 
298  return m_libId.GetLibNickname();
299 }
300 
301 
302 wxString LIB_PART::SubReference( int aUnit, bool aAddSeparator )
303 {
304  wxString subRef;
305 
306  if( m_subpartIdSeparator != 0 && aAddSeparator )
307  subRef << wxChar( m_subpartIdSeparator );
308 
309  if( m_subpartFirstId >= '0' && m_subpartFirstId <= '9' )
310  subRef << aUnit;
311  else
312  {
313  // use letters as notation. To allow more than 26 units, the sub ref
314  // use one letter if letter = A .. Z or a ... z, and 2 letters otherwise
315  // first letter is expected to be 'A' or 'a' (i.e. 26 letters are available)
316  int u;
317  aUnit -= 1; // Unit number starts to 1. now to 0.
318 
319  while( aUnit >= 26 ) // more than one letter are needed
320  {
321  u = aUnit / 26;
322  subRef << wxChar( m_subpartFirstId + u -1 );
323  aUnit %= 26;
324  }
325 
326  u = m_subpartFirstId + aUnit;
327  subRef << wxChar( u );
328  }
329 
330  return subRef;
331 }
332 
333 
334 const wxString& LIB_PART::GetName() const
335 {
336  static wxString dummy;
337 
338  wxCHECK_MSG( m_aliases.size(), dummy, "no aliases defined for symbol" );
339 
340  return m_aliases[0]->GetName();
341 }
342 
343 
344 void LIB_PART::SetName( const wxString& aName )
345 {
346  // The LIB_ALIAS that is the LIB_PART name has to be created so create it.
347  if( m_aliases.empty() )
348  m_aliases.push_back( new LIB_ALIAS( aName, this ) );
349  else
350  m_aliases[0]->SetName( aName );
351 
352  wxString validatedName = LIB_ID::FixIllegalChars( aName, LIB_ID::ID_SCH );
353  m_libId.SetLibItemName( validatedName, false );
354 
355  GetValueField().SetText( validatedName );
356 }
357 
358 
359 void LIB_PART::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset,
360  int aMulti, int aConvert, const PART_DRAW_OPTIONS& aOpts )
361 {
362  BASE_SCREEN* screen = aPanel ? aPanel->GetScreen() : NULL;
363  GRSetDrawMode( aDc, aOpts.draw_mode );
364 
365  /* draw background for filled items using background option
366  * Solid lines will be drawn after the background
367  * Note also, background is not drawn when:
368  * printing in black and white
369  * If the color is not the default color (aColor != -1 )
370  */
371  if( ! ( screen && screen->m_IsPrinting && GetGRForceBlackPenState() )
372  && ( aOpts.color == COLOR4D::UNSPECIFIED ) )
373  {
374  for( LIB_ITEM& drawItem : m_drawings )
375  {
376  if( drawItem.m_Fill != FILLED_WITH_BG_BODYCOLOR )
377  continue;
378 
379  if( aOpts.only_selected && !drawItem.IsSelected() )
380  continue;
381 
382  // Do not draw an item while moving (the cursor handler does that)
383  if( drawItem.m_Flags & IS_MOVED )
384  continue;
385 
386  // Do not draw items not attached to the current part
387  if( aMulti && drawItem.m_Unit && ( drawItem.m_Unit != aMulti ) )
388  continue;
389 
390  if( aConvert && drawItem.m_Convert && ( drawItem.m_Convert != aConvert ) )
391  continue;
392 
393  if( drawItem.Type() == LIB_FIELD_T )
394  continue;
395 
396  if( drawItem.Type() == LIB_FIELD_T ) // TODO dead code?
397  {
398  drawItem.Draw( aPanel, aDc, aOffset, aOpts.color,
399  aOpts.draw_mode, (void*) NULL, aOpts.transform );
400  }
401 
402  // Now, draw only the background for items with
403  // m_Fill == FILLED_WITH_BG_BODYCOLOR:
404  drawItem.Draw( aPanel, aDc, aOffset, aOpts.color,
405  aOpts.draw_mode, (void*) false, aOpts.transform );
406  }
407  }
408 
409  // Track the index into the dangling pins list
410  size_t pin_index = 0;
411 
412  for( LIB_ITEM& drawItem : m_drawings )
413  {
414  if( aOpts.only_selected && !drawItem.IsSelected() )
415  continue;
416 
417  // Do not draw an item while moving (the cursor handler does that)
418  if( drawItem.m_Flags & IS_MOVED )
419  continue;
420 
421  // Do not draw items not attached to the current part
422  if( aMulti && drawItem.m_Unit && ( drawItem.m_Unit != aMulti ) )
423  continue;
424 
425  if( aConvert && drawItem.m_Convert && ( drawItem.m_Convert != aConvert ) )
426  continue;
427 
428  if( drawItem.Type() == LIB_FIELD_T )
429  {
430  LIB_FIELD& field = static_cast<LIB_FIELD&>( drawItem );
431 
432  if( field.IsVisible() && !aOpts.draw_visible_fields )
433  continue;
434 
435  if( !field.IsVisible() && !aOpts.draw_hidden_fields )
436  continue;
437  }
438 
439  if( drawItem.Type() == LIB_PIN_T )
440  {
441  LIB_PIN& pin = static_cast<LIB_PIN&>( drawItem );
442 
443  uintptr_t flags = 0;
444  if( aOpts.show_pin_text )
445  flags |= PIN_DRAW_TEXTS;
446 
447  if( aOpts.show_elec_type )
449 
450  if( aOpts.PinIsDangling( pin_index ) )
451  flags |= PIN_DRAW_DANGLING;
452 
453  if( pin.IsPowerConnection() && IsPower() )
454  flags |= PIN_DANGLING_HIDDEN;
455 
456  drawItem.Draw( aPanel, aDc, aOffset, aOpts.color,
457  aOpts.draw_mode, (void*) flags, aOpts.transform );
458 
459  ++pin_index;
460  }
461  else if( drawItem.Type() == LIB_FIELD_T )
462  {
463  drawItem.Draw( aPanel, aDc, aOffset, aOpts.color,
464  aOpts.draw_mode, (void*) NULL, aOpts.transform );
465  }
466  else
467  {
468  bool forceNoFill = drawItem.m_Fill == FILLED_WITH_BG_BODYCOLOR;
469  drawItem.Draw( aPanel, aDc, aOffset, aOpts.color,
470  aOpts.draw_mode, (void*) forceNoFill,
471  aOpts.transform );
472  }
473  }
474 
475  // Enable this to draw the anchor of the component.
476 #if 0
477  int len = aDc->DeviceToLogicalXRel( 3 );
478  EDA_RECT* const clipbox = aPanel ? aPanel->GetClipBox() : NULL;
479 
480  GRLine( clipbox, aDc, aOffset.x, aOffset.y - len, aOffset.x,
481  aOffset.y + len, 0, aOpts.color );
482  GRLine( clipbox, aDc, aOffset.x - len, aOffset.y, aOffset.x + len,
483  aOffset.y, 0, aOpts.color );
484 #endif
485 
486  /* Enable this to draw the bounding box around the component to validate
487  * the bounding box calculations. */
488 #if 0
489  EDA_RECT bBox = GetUnitBoundingBox( aMulti, aConvert );
490  bBox.RevertYAxis();
491  bBox = aOpts.transform.TransformCoordinate( bBox );
492  bBox.Move( aOffset );
493  GRRect( aPanel ? aPanel->GetClipBox() : NULL, aDc, bBox, 0, LIGHTMAGENTA );
494 #endif
495 }
496 
497 
498 void LIB_PART::Plot( PLOTTER* aPlotter, int aUnit, int aConvert,
499  const wxPoint& aOffset, const TRANSFORM& aTransform )
500 {
501  wxASSERT( aPlotter != NULL );
502 
503  aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) );
504  bool fill = aPlotter->GetColorMode();
505 
506  // draw background for filled items using background option
507  // Solid lines will be drawn after the background
508  for( LIB_ITEM& item : m_drawings )
509  {
510  // Lib Fields are not plotted here, because this plot function
511  // is used to plot schematic items, which have they own fields
512  if( item.Type() == LIB_FIELD_T )
513  continue;
514 
515  if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
516  continue;
517 
518  if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
519  continue;
520 
521  if( item.m_Fill == FILLED_WITH_BG_BODYCOLOR )
522  item.Plot( aPlotter, aOffset, fill, aTransform );
523  }
524 
525  // Not filled items and filled shapes are now plotted
526  // (plot only items which are not already plotted)
527  for( LIB_ITEM& item : m_drawings )
528  {
529  if( item.Type() == LIB_FIELD_T )
530  continue;
531 
532  if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
533  continue;
534 
535  if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
536  continue;
537 
538  if( item.m_Fill != FILLED_WITH_BG_BODYCOLOR )
539  item.Plot( aPlotter, aOffset, fill, aTransform );
540  }
541 }
542 
543 
544 void LIB_PART::PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert,
545  const wxPoint& aOffset, const TRANSFORM& aTransform )
546 {
547  wxASSERT( aPlotter != NULL );
548 
549  aPlotter->SetColor( GetLayerColor( LAYER_FIELDS ) );
550  bool fill = aPlotter->GetColorMode();
551 
552  for( LIB_ITEM& item : m_drawings )
553  {
554  if( item.Type() != LIB_FIELD_T )
555  continue;
556 
557  if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
558  continue;
559 
560  if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
561  continue;
562 
563  // The reference is a special case: we should change the basic text
564  // to add '?' and the part id
565  LIB_FIELD& field = (LIB_FIELD&) item;
566  wxString tmp = field.GetShownText();
567  if( field.GetId() == REFERENCE )
568  {
569  wxString text = field.GetFullText( aUnit );
570  field.SetText( text );
571  }
572  item.Plot( aPlotter, aOffset, fill, aTransform );
573  field.SetText( tmp );
574  }
575 }
576 
577 
578 void LIB_PART::RemoveDrawItem( LIB_ITEM* aItem, EDA_DRAW_PANEL* aPanel, wxDC* aDc )
579 {
580  wxASSERT( aItem != NULL );
581 
582  // none of the MANDATORY_FIELDS may be removed in RAM, but they may be
583  // omitted when saving to disk.
584  if( aItem->Type() == LIB_FIELD_T )
585  {
586  LIB_FIELD* field = (LIB_FIELD*) aItem;
587 
588  if( field->GetId() < MANDATORY_FIELDS )
589  {
590  wxLogWarning( _(
591  "An attempt was made to remove the %s field from component %s in library %s." ),
592  GetChars( field->GetName() ), GetChars( GetName() ),
593  GetChars( GetLibraryName() ) );
594  return;
595  }
596  }
597 
598  LIB_ITEMS& items = m_drawings[ aItem->Type() ];
599 
600  for( LIB_ITEMS::iterator i = items.begin(); i != items.end(); i++ )
601  {
602  if( *i == aItem )
603  {
604  if( aDc != NULL )
605  aItem->Draw( aPanel, aDc, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED,
606  g_XorMode, NULL, DefaultTransform );
607 
608  items.erase( i );
609  SetModified();
610  break;
611  }
612  }
613 }
614 
615 
617 {
618  wxASSERT( aItem != NULL );
619 
620  m_drawings.push_back( aItem );
621 }
622 
623 
625 {
626  if( m_drawings.empty( aType ) )
627  return NULL;
628 
629  if( aItem == NULL )
630  return &( *( m_drawings.begin( aType ) ) );
631 
632  // Search for the last item, assume aItem is of type aType
633  wxASSERT( ( aType == TYPE_NOT_INIT ) || ( aType == aItem->Type() ) );
635 
636  while( ( it != m_drawings.end( aType ) ) && ( aItem != &( *it ) ) )
637  ++it;
638 
639  // Search the next item
640  if( it != m_drawings.end( aType ) )
641  {
642  ++it;
643 
644  if( it != m_drawings.end( aType ) )
645  return &( *it );
646  }
647 
648  return NULL;
649 }
650 
651 
652 void LIB_PART::GetPins( LIB_PINS& aList, int aUnit, int aConvert )
653 {
654  if( m_drawings.empty( LIB_PIN_T ) )
655  return;
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  // Same position?
713  if( eachThisPin->GetPosition() != eachOtherPin->GetPosition() )
714  continue;
715 
716  // Same number?
717  if( aTestNums && ( eachThisPin->GetNumber() != eachOtherPin->GetNumber() ))
718  continue;
719 
720  // Same name?
721  if( aTestNames && ( eachThisPin->GetName() != eachOtherPin->GetName() ))
722  continue;
723 
724  // Same electrical type?
725  if( aTestType && ( eachThisPin->GetType() != eachOtherPin->GetType() ))
726  continue;
727 
728  // Same orientation?
729  if( aTestOrientation && ( eachThisPin->GetOrientation() != eachOtherPin->GetOrientation() ))
730  continue;
731 
732  // Same length?
733  if( aTestLength && ( eachThisPin->GetLength() != eachOtherPin->GetLength() ))
734  continue;
735 
736  foundMatch = true;
737  }
738 
739  if( !foundMatch )
740  {
741  // This means there was not an identical (according to the arguments)
742  // pin at the same position in the other component.
743  return true;
744  }
745  }
746 
747  // The loop never gave up, so no conflicts were found.
748  return false;
749 }
750 
751 
752 const EDA_RECT LIB_PART::GetUnitBoundingBox( int aUnit, int aConvert ) const
753 {
754  EDA_RECT bBox;
755  bool initialized = false;
756 
757  for( const LIB_ITEM& item : m_drawings )
758  {
759  if( ( item.m_Unit > 0 ) && ( ( m_unitCount > 1 ) && ( aUnit > 0 )
760  && ( aUnit != item.m_Unit ) ) )
761  continue;
762 
763  if( item.m_Convert > 0 && ( ( aConvert > 0 ) && ( aConvert != item.m_Convert ) ) )
764  continue;
765 
766  if ( ( item.Type() == LIB_FIELD_T ) && !( ( LIB_FIELD& ) item ).IsVisible() )
767  continue;
768 
769  if( initialized )
770  bBox.Merge( item.GetBoundingBox() );
771  else
772  {
773  bBox = item.GetBoundingBox();
774  initialized = true;
775  }
776  }
777 
778  return bBox;
779 }
780 
781 
782 void LIB_PART::ViewGetLayers( int aLayers[], int& aCount ) const
783 {
784  aCount = 2;
785  aLayers[0] = LAYER_DEVICE;
786  aLayers[1] = LAYER_DEVICE_BACKGROUND;
787 }
788 
789 
790 const EDA_RECT LIB_PART::GetBodyBoundingBox( int aUnit, int aConvert ) const
791 {
792  EDA_RECT bBox;
793  bool initialized = false;
794 
795  for( const LIB_ITEM& item : m_drawings )
796  {
797  if( ( item.m_Unit > 0 ) && ( ( m_unitCount > 1 ) && ( aUnit > 0 )
798  && ( aUnit != item.m_Unit ) ) )
799  continue;
800 
801  if( item.m_Convert > 0 && ( ( aConvert > 0 ) && ( aConvert != item.m_Convert ) ) )
802  continue;
803 
804  if( item.Type() == LIB_FIELD_T )
805  continue;
806 
807  if( initialized )
808  bBox.Merge( item.GetBoundingBox() );
809  else
810  {
811  bBox = item.GetBoundingBox();
812  initialized = true;
813  }
814  }
815 
816  return bBox;
817 }
818 
819 
821 {
822  m_drawings[ LIB_FIELD_T ].clear();
823 }
824 
825 
826 void LIB_PART::SetFields( const std::vector <LIB_FIELD>& aFields )
827 {
828  deleteAllFields();
829 
830  for( unsigned i=0; i<aFields.size(); ++i )
831  {
832  // drawings is a ptr_vector, new and copy an object on the heap.
833  LIB_FIELD* field = new LIB_FIELD( aFields[i] );
834 
835  field->SetParent( this );
836  m_drawings.push_back( field );
837  }
838 }
839 
840 
842 {
843  LIB_FIELD* field;
844 
845  // Grab the MANDATORY_FIELDS first, in expected order given by
846  // enum NumFieldType
847  for( int id=0; id<MANDATORY_FIELDS; ++id )
848  {
849  field = GetField( id );
850 
851  // the MANDATORY_FIELDS are exactly that in RAM.
852  wxASSERT( field );
853 
854  aList.push_back( *field );
855  }
856 
857  // Now grab all the rest of fields.
858  for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
859  {
860  field = ( LIB_FIELD* ) &item;
861 
862  if( (unsigned) field->GetId() < MANDATORY_FIELDS )
863  continue; // was added above
864 
865  aList.push_back( *field );
866  }
867 }
868 
869 
871 {
872  for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
873  {
874  LIB_FIELD* field = ( LIB_FIELD* ) &item;
875 
876  if( field->GetId() == aId )
877  return field;
878  }
879 
880  return NULL;
881 }
882 
883 
884 LIB_FIELD* LIB_PART::FindField( const wxString& aFieldName )
885 {
886  for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
887  {
888  LIB_FIELD* field = ( LIB_FIELD* ) &item;
889 
890  if( field->GetName() == aFieldName )
891  return field;
892  }
893 
894  return NULL;
895 }
896 
897 
899 {
900  LIB_FIELD* field = GetField( VALUE );
901  wxASSERT( field != NULL );
902  return *field;
903 }
904 
905 
907 {
908  LIB_FIELD* field = GetField( REFERENCE );
909  wxASSERT( field != NULL );
910  return *field;
911 }
912 
913 
915 {
916  LIB_FIELD* field = GetField( FOOTPRINT );
917  wxASSERT( field != NULL );
918  return *field;
919 }
920 
921 
923 {
924  int year, mon, day, hour, min, sec;
925 
926  if( m_dateLastEdition == 0 )
927  return true;
928 
929  sec = m_dateLastEdition & 63;
930  min = ( m_dateLastEdition >> 6 ) & 63;
931  hour = ( m_dateLastEdition >> 12 ) & 31;
932  day = ( m_dateLastEdition >> 17 ) & 31;
933  mon = ( m_dateLastEdition >> 22 ) & 15;
934  year = ( m_dateLastEdition >> 26 ) + 1990;
935 
936  aFormatter.Print( 0, "Ti %d/%d/%d %d:%d:%d\n", year, mon, day, hour, min, sec );
937 
938  return true;
939 }
940 
941 
942 bool LIB_PART::LoadDateAndTime( char* aLine )
943 {
944  int year, mon, day, hour, min, sec;
945 
946  year = mon = day = hour = min = sec = 0;
947  strtok( aLine, " \r\t\n" );
948  strtok( NULL, " \r\t\n" );
949 
950  if( sscanf( aLine, "%d/%d/%d %d:%d:%d", &year, &mon, &day, &hour, &min, &sec ) != 6 )
951  return false;
952 
953  m_dateLastEdition = ( sec & 63 ) + ( ( min & 63 ) << 6 ) +
954  ( ( hour & 31 ) << 12 ) + ( ( day & 31 ) << 17 ) +
955  ( ( mon & 15 ) << 22 ) + ( ( year - 1990 ) << 26 );
956 
957  return true;
958 }
959 
960 
961 void LIB_PART::SetOffset( const wxPoint& aOffset )
962 {
963  for( LIB_ITEM& item : m_drawings )
964  item.SetOffset( aOffset );
965 }
966 
967 
969 {
970  m_drawings.unique();
971 }
972 
973 
975 {
976  for( const LIB_ITEM& item : m_drawings )
977  {
978  if( item.m_Convert > 1 )
979  return true;
980  }
981 
982  return false;
983 }
984 
986 {
987  for( LIB_ITEM& item : m_drawings )
988  {
989  item.m_Flags = 0;
990  }
991 }
992 
993 LIB_ITEM* LIB_PART::LocateDrawItem( int aUnit, int aConvert,
994  KICAD_T aType, const wxPoint& aPoint )
995 {
996  for( LIB_ITEM& item : m_drawings )
997  {
998  if( ( aUnit && item.m_Unit && ( aUnit != item.m_Unit) )
999  || ( aConvert && item.m_Convert && ( aConvert != item.m_Convert ) )
1000  || ( ( item.Type() != aType ) && ( aType != TYPE_NOT_INIT ) ) )
1001  continue;
1002 
1003  if( item.HitTest( aPoint ) )
1004  return &item;
1005  }
1006 
1007  return NULL;
1008 }
1009 
1010 
1011 LIB_ITEM* LIB_PART::LocateDrawItem( int aUnit, int aConvert, KICAD_T aType,
1012  const wxPoint& aPoint, const TRANSFORM& aTransform )
1013 {
1014  /* we use LocateDrawItem( int aUnit, int convert, KICAD_T type, const
1015  * wxPoint& pt ) to search items.
1016  * because this function uses DefaultTransform as orient/mirror matrix
1017  * we temporary copy aTransform in DefaultTransform
1018  */
1019  LIB_ITEM* item;
1020  TRANSFORM transform = DefaultTransform;
1021  DefaultTransform = aTransform;
1022 
1023  item = LocateDrawItem( aUnit, aConvert, aType, aPoint );
1024 
1025  // Restore matrix
1026  DefaultTransform = transform;
1027 
1028  return item;
1029 }
1030 
1031 
1032 void LIB_PART::SetUnitCount( int aCount )
1033 {
1034  if( m_unitCount == aCount )
1035  return;
1036 
1037  if( aCount < m_unitCount )
1038  {
1040 
1041  while( i != m_drawings.end() )
1042  {
1043  if( i->m_Unit > aCount )
1044  i = m_drawings.erase( i );
1045  else
1046  ++i;
1047  }
1048  }
1049  else
1050  {
1051  int prevCount = m_unitCount;
1052 
1053  // Temporary storage for new items, as adding new items directly to
1054  // m_drawings may cause the buffer reallocation which invalidates the
1055  // iterators
1056  std::vector< LIB_ITEM* > tmp;
1057 
1058  for( LIB_ITEM& item : m_drawings )
1059  {
1060  if( item.m_Unit != 1 )
1061  continue;
1062 
1063  for( int j = prevCount + 1; j <= aCount; j++ )
1064  {
1065  LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
1066  newItem->m_Unit = j;
1067  tmp.push_back( newItem );
1068  }
1069  }
1070 
1071  for( auto item : tmp )
1072  m_drawings.push_back( item );
1073  }
1074 
1075  m_unitCount = aCount;
1076 }
1077 
1078 
1079 void LIB_PART::SetConversion( bool aSetConvert )
1080 {
1081  if( aSetConvert == HasConversion() )
1082  return;
1083 
1084  // Duplicate items to create the converted shape
1085  if( aSetConvert )
1086  {
1087  std::vector< LIB_ITEM* > tmp; // Temporarily store the duplicated pins here.
1088 
1089  for( LIB_ITEM& item : m_drawings )
1090  {
1091  // Only pins are duplicated.
1092  if( item.Type() != LIB_PIN_T )
1093  continue;
1094 
1095  if( item.m_Convert == 1 )
1096  {
1097  LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
1098  newItem->m_Convert = 2;
1099  tmp.push_back( newItem );
1100  }
1101  }
1102 
1103  // Transfer the new pins to the LIB_PART.
1104  for( unsigned i = 0; i < tmp.size(); i++ )
1105  m_drawings.push_back( tmp[i] );
1106  }
1107  else
1108  {
1109  // Delete converted shape items because the converted shape does
1110  // not exist
1112 
1113  while( i != m_drawings.end() )
1114  {
1115  if( i->m_Convert > 1 )
1116  i = m_drawings.erase( i );
1117  else
1118  ++i;
1119  }
1120  }
1121 }
1122 
1123 
1124 wxArrayString LIB_PART::GetAliasNames( bool aIncludeRoot ) const
1125 {
1126  wxArrayString names;
1127 
1128  LIB_ALIASES::const_iterator it;
1129 
1130  for( it=m_aliases.begin(); it != m_aliases.end(); ++it )
1131  {
1132  if( !aIncludeRoot && (*it)->IsRoot() )
1133  continue;
1134 
1135  names.Add( (*it)->GetName() );
1136  }
1137 
1138  return names;
1139 }
1140 
1141 
1142 bool LIB_PART::HasAlias( const wxString& aName ) const
1143 {
1144  wxCHECK2_MSG( !aName.IsEmpty(), return false,
1145  wxT( "Cannot get alias with an empty name, bad programmer." ) );
1146 
1147  for( size_t i = 0; i < m_aliases.size(); i++ )
1148  {
1149  if( aName == m_aliases[i]->GetName() )
1150  return true;
1151  }
1152 
1153  return false;
1154 }
1155 
1156 
1157 void LIB_PART::RemoveAlias( const wxString& aName )
1158 {
1159  LIB_ALIAS* a = GetAlias( aName );
1160 
1161  if( a )
1162  RemoveAlias( a );
1163 }
1164 
1165 
1167 {
1168  wxCHECK_MSG( aAlias, NULL, wxT( "Cannot remove alias by NULL pointer." ) );
1169 
1170  LIB_ALIAS* nextAlias = NULL;
1171 
1172  LIB_ALIASES::iterator it = find( m_aliases.begin(), m_aliases.end(), aAlias );
1173 
1174  if( it != m_aliases.end() )
1175  {
1176  bool rename = aAlias->IsRoot();
1177 
1178  wxLogTrace( traceSchLibMem,
1179  wxT( "%s: symbol:'%s', alias:'%s', alias count %llu, reference count %ld." ),
1180  GetChars( wxString::FromAscii( __WXFUNCTION__ ) ),
1181  GetChars( GetName() ),
1182  GetChars( aAlias->GetName() ),
1183  (long long unsigned) m_aliases.size(),
1184  m_me.use_count() );
1185 
1186  it = m_aliases.erase( it );
1187 
1188  if( !m_aliases.empty() )
1189  {
1190  if( it == m_aliases.end() )
1191  it = m_aliases.begin();
1192 
1193  nextAlias = *it;
1194 
1195  if( rename )
1196  SetName( nextAlias->GetName() );
1197  }
1198  }
1199 
1200  return nextAlias;
1201 }
1202 
1203 
1205 {
1206  // Remove all of the aliases except the root alias.
1207  while( m_aliases.size() > 1 )
1208  m_aliases.pop_back();
1209 }
1210 
1211 
1212 LIB_ALIAS* LIB_PART::GetAlias( const wxString& aName )
1213 {
1214  wxCHECK2_MSG( !aName.IsEmpty(), return NULL,
1215  wxT( "Cannot get alias with an empty name. Bad programmer!" ) );
1216 
1217  for( size_t i = 0; i < m_aliases.size(); i++ )
1218  {
1219  if( aName == m_aliases[i]->GetName() )
1220  return m_aliases[i];
1221  }
1222 
1223  return NULL;
1224 }
1225 
1226 
1228 {
1229  wxCHECK2_MSG( aIndex < m_aliases.size(), return NULL,
1230  wxT( "Illegal alias list index, bad programmer." ) );
1231 
1232  return m_aliases[aIndex];
1233 }
1234 
1235 
1236 void LIB_PART::AddAlias( const wxString& aName )
1237 {
1238  m_aliases.push_back( new LIB_ALIAS( aName, this ) );
1239 }
1240 
1241 
1243 {
1244  m_aliases.push_back( aAlias );
1245 }
1246 
1247 
1248 void LIB_PART::SetSubpartIdNotation( int aSep, int aFirstId )
1249 {
1250  m_subpartFirstId = 'A';
1252 
1253  if( aSep == '.' || aSep == '-' || aSep == '_' )
1254  m_subpartIdSeparator = aSep;
1255 
1256  if( aFirstId == '1' && aSep != 0 )
1257  m_subpartFirstId = aFirstId;
1258 }
timestamp_t m_dateLastEdition
Date of the last modification.
LIB_ALIASES m_aliases
List of alias object pointers associated with the part.
virtual BASE_SCREEN * GetScreen()=0
void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on...
PART_LIB * GetLib()
virtual ~LIB_ALIAS()
LIB_FIELD & GetFootprintField()
Return reference to the footprint field.
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:74
void SetLib(PART_LIB *aLibrary)
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
LIB_FIELD * GetField(int aId)
Return pointer to the requested field.
bool PinsConflictWith(LIB_PART &aOtherPart, bool aTestNums, bool aTestNames, bool aTestType, bool aTestOrientation, bool aTestLength)
Return true if this part&#39;s pins do not match another part&#39;s pins.
void SetModified()
static int m_subpartIdSeparator
the separator char between the subpart id and the reference like U1A ( m_subpartIdSeparator = 0 ) or ...
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDc, const wxPoint &aOffset, int aMulti, int aConvert, const PART_DRAW_OPTIONS &aOpts)
Draw part.
const EDA_RECT GetUnitBoundingBox(int aUnit, int aConvert) const
Get the bounding box for the symbol.
Part library alias object definition.
ITERATOR begin(int aType=UNDEFINED_TYPE)
Definition: multivector.h:183
bool PinIsDangling(size_t aPin) const
void Move(const wxPoint &aMoveVector)
Function Move moves the rectangle by the aMoveVector.
void SetConversion(bool aSetConvert)
Set or clear the alternate body style (DeMorgan) for the part.
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 HasConversion() const
Test if part has more than one body conversion type (DeMorgan).
bool m_showPinNumbers
Determines if part pin numbers are visible.
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:223
wxString description
documentation for info
int GetUnitCount() override
For symbols with units, return the number of units.
bool operator<(const EDA_ITEM &aItem) const
Test if another item is less than this object.
bool IsPower() const
LIB_ALIAS * GetAlias(size_t aIndex)
bool IsNew() const
Definition: base_struct.h:219
virtual void SetColor(COLOR4D color)=0
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
LIB_ID GetLibId() const override
wxString GetSearchText() override
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.
bool empty(int aType=UNDEFINED_TYPE)
Definition: multivector.h:224
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
static int m_subpartFirstId
the ascii char value to calculate the subpart symbol id from the part number: only &#39;A&#39;...
wxString GetUnitReference(int aUnit) override
For symbols with units, return an identifier for unit x.
void unique()
Remove duplicate elements in list.
Definition: multivector.h:238
const EDA_RECT GetBodyBoundingBox(int aUnit, int aConvert) const
Get the symbol bounding box excluding fields.
bool HasAlias(const wxString &aName) const
Test if alias aName is in part alias list.
LIB_ITEMS_CONTAINER m_drawings
Drawing items of this part.
LIB_FIELD & GetValueField()
Return reference to the value field.
const LIB_ID & GetLibId() const
int m_Unit
Unit identification for multiple parts per package.
Class OUTPUTFORMATTER is an important interface (abstract class) used to output 8 bit text in a conve...
Definition: richio.h:327
LIB_ALIAS(const wxString &aName, LIB_PART *aRootComponent)
virtual EDA_RECT * GetClipBox()
wxString GetFullText(int unit=1) const
Return the text of a field.
Definition: lib_field.cpp:363
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
void AddAlias(const wxString &aName)
Add an alias aName to the part.
LIBRENTRYOPTIONS m_options
Special part features such as POWER or NORMAL.)
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Definition: eeschema.cpp:174
PART_LIB * GetLib()
void RevertYAxis()
Function RevertYAxis Mirror the rectangle from the X axis (negate Y pos and size) ...
Definition: eda_rect.h:144
void operator()(void const *) const
Field Name Module PCB, i.e. "16DIP300".
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...
The base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:67
LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS
wxString GetLibNickname() const override
This file contains miscellaneous commonly used macros and functions.
wxString name
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.
bool LoadDateAndTime(char *aLine)
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.
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:148
void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on...
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.
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:41
void deleteAllFields()
bool IsRoot() const override
For symbols having aliases, IsRoot() indicates the principal item.
void SetName(const wxString &aName)
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1003
Class for tranforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
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)
Findd a field within this part matching aFieldName and returns it or NULL if not found.
void SetText(const wxString &aText) override
Sets the field text to aText.
Definition: lib_field.cpp:510
const wxString & GetKeyWords() const
void SetUnitCount(int count)
Set the units per part count.
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:216
int GetId() const
Definition: lib_field.h:138
wxString docFileName
Associate doc file name.
LIB_PART * shared
Actual LIB_PART referenced by [multiple] aliases.
Class BASE_SCREEN handles how to draw a screen (a board, a schematic ...)
Definition: base_screen.h:76
void push_back(T *aItem)
Definition: multivector.h:169
Class LIB_ITEM definition.
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:143
const wxString GetName() const
Return the file name without path or extension.
bool operator==(const wxChar *aName) const
KEEPCASE sensitive comparison of the part entry name.
Define a library symbol object.
wxLogTrace helper definitions.
void RemoveDuplicateDrawItems()
Remove duplicate draw items from list.
wxArrayString m_FootprintList
List of suitable footprint names for the part (wild card names accepted).
bool GetColorMode() const
Definition: plotter.h:131
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:285
LIB_PART(const wxString &aName, PART_LIB *aLibrary=NULL)
bool m_IsPrinting
Definition: base_screen.h:220
LIB_ID m_libId
const wxChar *const traceSchLibMem
Flag to enable schematic library memory deletion debug output.
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
wxString GetName(bool aTranslate=true) const
Returns the field name.
Definition: lib_field.cpp:440
const wxString GetLibraryName()
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 ...
int GetUnitCount() const
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
const wxString & GetDescription() override
Definitions for the Eeschema program SCH_SCREEN class.
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Base plotter engine class.
Definition: plotter.h:97
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_draw_item.h:61
void ClearStatus()
Clears the status flag all draw objects in this part.
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
TRANSFORM DefaultTransform
Definition: eeschema.cpp:59
const wxString & GetName() const override
GR_DRAWMODE draw_mode
Device context drawing mode, see wxDC.
COLOR4D color
Color to draw part in.
void RemoveAlias(const wxString &aName)
void RemoveAllAliases()
virtual void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, COLOR4D aColor, GR_DRAWMODE aDrawMode, void *aData, const TRANSFORM &aTransform)
Draw an item.
static LIB_PART * dummy()
Used when a LIB_PART is not found in library to draw a dummy shape This component is a 400 mils squar...
bool IsVisible() const
Definition: lib_field.h:166
static void SetSubpartIdNotation(int aSep, int aFirstId)
Set the separator char between the subpart id and the reference 0 (no separator) or &#39;...
std::vector< LIB_FIELD > LIB_FIELDS
Definition: lib_field.h:259
wxArrayString GetAliasNames(bool aIncludeRoot=true) const
size_t i
Definition: json11.cpp:597
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
static wxString SubReference(int aUnit, bool aAddSeparator=true)
bool show_pin_text
Whether to show pin texts.
void RemoveDrawItem(LIB_ITEM *aItem, EDA_DRAW_PANEL *aPanel=NULL, wxDC *aDc=NULL)
Remove draw aItem from list.
bool only_selected
Draws only the body items that are selected, for block moves.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
static UTF8 FixIllegalChars(const UTF8 &aLibItemName, LIB_ID_TYPE aType, bool aLib=false)
Replace illegal LIB_ID item name characters with underscores &#39;_&#39;.
Definition: lib_id.cpp:352
bool show_elec_type
Whether to show the pin electrical type.
int m_Convert
Shape identification for alternate body styles.
const wxString & GetName() const
bool IsPowerConnection() const
Return whether this pin forms an implicit power connection: i.e., is hidden and of type POWER_IN...
Definition: lib_pin.h:368
LIB_ITEM * LocateDrawItem(int aUnit, int aConvert, KICAD_T aType, const wxPoint &aPoint)
Locate a draw object.
virtual void SetName(const wxString &aName)
int tmpUnit
Temporary unit designator (used for rendering)
int tmpConversion
Temporary conversion designator (used for rendering)
Definition for part library class.
bool draw_visible_fields
Whether to draw "visible" fields.
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Function Print formats and writes text to the output stream.
Definition: richio.cpp:404
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
bool GetGRForceBlackPenState(void)
Function GetGRForceBlackPenState.
Definition: gr_basic.cpp:214
bool m_showPinNames
Determines if part pin names are visible.
void SetFields(const std::vector< LIB_FIELD > &aFieldsList)
Overwrite all the existing fields in this symbol with fields supplied in aFieldsList.
#define VALUE
Object used to load, save, search, and otherwise manipulate symbol library files. ...
TRANSFORM transform
Coordinate adjustment settings.
wxString keyWords
keyword list (used for search for parts by keyword)
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.
#define min(a, b)
Definition: auxiliary.h:85
bool SaveDateAndTime(OUTPUTFORMATTER &aFormatter)
Write the date and time of part to aFile in the format: "Ti yy/mm/jj hh:mm:ss".
#define IS_MOVED
Item being moved.
Definition: base_struct.h:113
PART_SPTR m_me
http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared ...