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-2019 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 
156  return dummy;
157 };
158 
159 
161 {
162  // LIB_ALIAS may be displayed in preview windows, so ensure that it is always
163  // selected for drawing.
164  BOX2I bbox;
165  bbox.SetMaximum();
166  return bbox;
167 }
168 
169 
171 {
172  // Matches are scored by offset from front of string, so inclusion of this spacer
173  // discounts matches found after it.
174  static const wxString discount( wxT( " " ) );
175 
176  wxString text = GetKeyWords() + discount + GetDescription();
177 
178  // If a footprint is defined for the part, add it to the serach string
179  if( shared )
180  {
181  wxString footprint = shared->GetFootprintField().GetText();
182 
183  if( !footprint.IsEmpty() )
184  text += discount + footprint;
185  }
186 
187  return text;
188 }
189 
190 
191 bool LIB_ALIAS::operator==( const wxChar* aName ) const
192 {
193  return name == aName;
194 }
195 
196 
197 bool operator<( const LIB_ALIAS& aItem1, const LIB_ALIAS& aItem2 )
198 {
199  return aItem1.GetName() < aItem2.GetName();
200 }
201 
202 
203 void LIB_ALIAS::ViewGetLayers( int aLayers[], int& aCount ) const
204 {
205  // An alias's fields don't know how to fetch their parent's values so we don't let
206  // them draw themselves. This means the alias always has to draw them, which means
207  // it has to "own" their layers as well.
208  aCount = 5;
209  aLayers[0] = LAYER_DEVICE;
210  aLayers[1] = LAYER_DEVICE_BACKGROUND;
211  aLayers[2] = LAYER_REFERENCEPART;
212  aLayers[3] = LAYER_VALUEPART;
213  aLayers[4] = LAYER_FIELDS;
214 }
215 
216 
219 {
220  void operator()(void const *) const
221  {
222  }
223 };
224 
225 
226 LIB_PART::LIB_PART( const wxString& aName, PART_LIB* aLibrary ) :
227  EDA_ITEM( LIB_PART_T ),
228  m_me( this, null_deleter() )
229 {
230  m_dateLastEdition = 0;
231  m_unitCount = 1;
232  m_pinNameOffset = 40;
234  m_unitsLocked = false;
235  m_showPinNumbers = true;
236  m_showPinNames = true;
237 
238  // Add the MANDATORY_FIELDS in RAM only. These are assumed to be present
239  // when the field editors are invoked.
240  m_drawings[LIB_FIELD_T].reserve( 4 );
245 
246  SetLib( aLibrary );
247  SetName( aName );
248 }
249 
250 
251 LIB_PART::LIB_PART( LIB_PART& aPart, PART_LIB* aLibrary ) :
252  EDA_ITEM( aPart ),
253  m_me( this, null_deleter() )
254 {
255  LIB_ITEM* newItem;
256 
257  m_library = aLibrary;
259  m_unitCount = aPart.m_unitCount;
265  m_options = aPart.m_options;
266  m_libId = aPart.m_libId;
267 
268  for( LIB_ITEM& oldItem : aPart.m_drawings )
269  {
270  if( oldItem.IsNew() )
271  continue;
272 
273  newItem = (LIB_ITEM*) oldItem.Clone();
274  newItem->SetParent( this );
275  m_drawings.push_back( newItem );
276  }
277 
278  for( size_t i = 0; i < aPart.m_aliases.size(); i++ )
279  {
280  LIB_ALIAS* alias = new LIB_ALIAS( *aPart.m_aliases[i], this );
281  m_aliases.push_back( alias );
282  }
283 }
284 
285 
287 {
288  wxLogTrace( traceSchLibMem,
289  wxT( "%s: destroying symbol with alias list count of %llu" ),
290  GetChars( wxString::FromAscii( __WXFUNCTION__ ) ),
291  (long long unsigned) m_aliases.size() );
292 
293  // If the part is being deleted directly rather than through the library,
294  // delete all of the aliases.
295  while( m_aliases.size() )
296  {
297  LIB_ALIAS* alias = m_aliases.back();
298  m_aliases.pop_back();
299  delete alias;
300  }
301 }
302 
303 
304 const wxString LIB_PART::GetLibraryName()
305 {
306  if( m_library )
307  return m_library->GetName();
308 
309  return m_libId.GetLibNickname();
310 }
311 
312 
313 wxString LIB_PART::SubReference( int aUnit, bool aAddSeparator )
314 {
315  wxString subRef;
316 
317  if( m_subpartIdSeparator != 0 && aAddSeparator )
318  subRef << wxChar( m_subpartIdSeparator );
319 
320  if( m_subpartFirstId >= '0' && m_subpartFirstId <= '9' )
321  subRef << aUnit;
322  else
323  {
324  // use letters as notation. To allow more than 26 units, the sub ref
325  // use one letter if letter = A .. Z or a ... z, and 2 letters otherwise
326  // first letter is expected to be 'A' or 'a' (i.e. 26 letters are available)
327  int u;
328  aUnit -= 1; // Unit number starts to 1. now to 0.
329 
330  while( aUnit >= 26 ) // more than one letter are needed
331  {
332  u = aUnit / 26;
333  subRef << wxChar( m_subpartFirstId + u -1 );
334  aUnit %= 26;
335  }
336 
337  u = m_subpartFirstId + aUnit;
338  subRef << wxChar( u );
339  }
340 
341  return subRef;
342 }
343 
344 
345 const wxString& LIB_PART::GetName() const
346 {
347  static wxString dummy;
348 
349  wxCHECK_MSG( m_aliases.size(), dummy, "no aliases defined for symbol" );
350 
351  return m_aliases[0]->GetName();
352 }
353 
354 
355 void LIB_PART::SetName( const wxString& aName )
356 {
357  // The LIB_ALIAS that is the LIB_PART name has to be created so create it.
358  if( m_aliases.empty() )
359  m_aliases.push_back( new LIB_ALIAS( aName, this ) );
360  else
361  m_aliases[0]->SetName( aName );
362 
363  wxString validatedName = LIB_ID::FixIllegalChars( aName, LIB_ID::ID_SCH );
364  m_libId.SetLibItemName( validatedName, false );
365 
366  GetValueField().SetText( validatedName );
367 }
368 
369 
370 void LIB_PART::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset,
371  int aMulti, int aConvert, const PART_DRAW_OPTIONS& aOpts )
372 {
373  BASE_SCREEN* screen = aPanel ? aPanel->GetScreen() : NULL;
374  GRSetDrawMode( aDc, aOpts.draw_mode );
375 
376  /* draw background for filled items using background option
377  * Solid lines will be drawn after the background
378  * Note also, background is not drawn when:
379  * printing in black and white
380  * If the color is not the default color (aColor != -1 )
381  */
382  if( ! ( screen && screen->m_IsPrinting && GetGRForceBlackPenState() )
383  && ( aOpts.color == COLOR4D::UNSPECIFIED ) )
384  {
385  for( LIB_ITEM& drawItem : m_drawings )
386  {
387  if( drawItem.m_Fill != FILLED_WITH_BG_BODYCOLOR )
388  continue;
389 
390  if( aOpts.only_selected && !drawItem.IsSelected() )
391  continue;
392 
393  // Do not draw an item while moving (the cursor handler does that)
394  if( drawItem.m_Flags & IS_MOVED )
395  continue;
396 
397  // Do not draw items not attached to the current part
398  if( aMulti && drawItem.m_Unit && ( drawItem.m_Unit != aMulti ) )
399  continue;
400 
401  if( aConvert && drawItem.m_Convert && ( drawItem.m_Convert != aConvert ) )
402  continue;
403 
404  if( drawItem.Type() == LIB_FIELD_T )
405  continue;
406 
407  if( drawItem.Type() == LIB_FIELD_T ) // TODO dead code?
408  {
409  drawItem.Draw( aPanel, aDc, aOffset, aOpts.color,
410  aOpts.draw_mode, (void*) NULL, aOpts.transform );
411  }
412 
413  // Now, draw only the background for items with
414  // m_Fill == FILLED_WITH_BG_BODYCOLOR:
415  drawItem.Draw( aPanel, aDc, aOffset, aOpts.color,
416  aOpts.draw_mode, (void*) false, aOpts.transform );
417  }
418  }
419 
420  // Track the index into the dangling pins list
421  size_t pin_index = 0;
422 
423  for( LIB_ITEM& drawItem : m_drawings )
424  {
425  if( aOpts.only_selected && !drawItem.IsSelected() )
426  continue;
427 
428  // Do not draw an item while moving (the cursor handler does that)
429  if( drawItem.m_Flags & IS_MOVED )
430  continue;
431 
432  // Do not draw items not attached to the current part
433  if( aMulti && drawItem.m_Unit && ( drawItem.m_Unit != aMulti ) )
434  continue;
435 
436  if( aConvert && drawItem.m_Convert && ( drawItem.m_Convert != aConvert ) )
437  continue;
438 
439  if( drawItem.Type() == LIB_FIELD_T )
440  {
441  LIB_FIELD& field = static_cast<LIB_FIELD&>( drawItem );
442 
443  if( field.IsVisible() && !aOpts.draw_visible_fields )
444  continue;
445 
446  if( !field.IsVisible() && !aOpts.draw_hidden_fields )
447  continue;
448  }
449 
450  if( drawItem.Type() == LIB_PIN_T )
451  {
452  LIB_PIN& pin = static_cast<LIB_PIN&>( drawItem );
453 
454  uintptr_t flags = 0;
455  if( aOpts.show_pin_text )
456  flags |= PIN_DRAW_TEXTS;
457 
458  if( aOpts.show_elec_type )
460 
461  if( aOpts.PinIsDangling( pin_index ) )
462  flags |= PIN_DRAW_DANGLING;
463 
464  if( pin.IsPowerConnection() && IsPower() )
465  flags |= PIN_DANGLING_HIDDEN;
466 
467  drawItem.Draw( aPanel, aDc, aOffset, aOpts.color,
468  aOpts.draw_mode, (void*) flags, aOpts.transform );
469 
470  ++pin_index;
471  }
472  else if( drawItem.Type() == LIB_FIELD_T )
473  {
474  drawItem.Draw( aPanel, aDc, aOffset, aOpts.color,
475  aOpts.draw_mode, (void*) NULL, aOpts.transform );
476  }
477  else
478  {
479  bool forceNoFill = drawItem.m_Fill == FILLED_WITH_BG_BODYCOLOR;
480  drawItem.Draw( aPanel, aDc, aOffset, aOpts.color,
481  aOpts.draw_mode, (void*) forceNoFill,
482  aOpts.transform );
483  }
484  }
485 
486  // Enable this to draw the anchor of the component.
487 #if 0
488  int len = aDc->DeviceToLogicalXRel( 3 );
489  EDA_RECT* const clipbox = aPanel ? aPanel->GetClipBox() : NULL;
490 
491  GRLine( clipbox, aDc, aOffset.x, aOffset.y - len, aOffset.x,
492  aOffset.y + len, 0, aOpts.color );
493  GRLine( clipbox, aDc, aOffset.x - len, aOffset.y, aOffset.x + len,
494  aOffset.y, 0, aOpts.color );
495 #endif
496 
497  /* Enable this to draw the bounding box around the component to validate
498  * the bounding box calculations. */
499 #if 0
500  EDA_RECT bBox = GetUnitBoundingBox( aMulti, aConvert );
501  bBox.RevertYAxis();
502  bBox = aOpts.transform.TransformCoordinate( bBox );
503  bBox.Move( aOffset );
504  GRRect( aPanel ? aPanel->GetClipBox() : NULL, aDc, bBox, 0, LIGHTMAGENTA );
505 #endif
506 }
507 
508 
509 void LIB_PART::Plot( PLOTTER* aPlotter, int aUnit, int aConvert,
510  const wxPoint& aOffset, const TRANSFORM& aTransform )
511 {
512  wxASSERT( aPlotter != NULL );
513 
514  aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) );
515  bool fill = aPlotter->GetColorMode();
516 
517  // draw background for filled items using background option
518  // Solid lines will be drawn after the background
519  for( LIB_ITEM& item : m_drawings )
520  {
521  // Lib Fields are not plotted here, because this plot function
522  // is used to plot schematic items, which have they own fields
523  if( item.Type() == LIB_FIELD_T )
524  continue;
525 
526  if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
527  continue;
528 
529  if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
530  continue;
531 
532  if( item.m_Fill == FILLED_WITH_BG_BODYCOLOR )
533  item.Plot( aPlotter, aOffset, fill, aTransform );
534  }
535 
536  // Not filled items and filled shapes are now plotted
537  // (plot only items which are not already plotted)
538  for( LIB_ITEM& item : m_drawings )
539  {
540  if( item.Type() == LIB_FIELD_T )
541  continue;
542 
543  if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
544  continue;
545 
546  if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
547  continue;
548 
549  if( item.m_Fill != FILLED_WITH_BG_BODYCOLOR )
550  item.Plot( aPlotter, aOffset, fill, aTransform );
551  }
552 }
553 
554 
555 void LIB_PART::PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert,
556  const wxPoint& aOffset, const TRANSFORM& aTransform )
557 {
558  wxASSERT( aPlotter != NULL );
559 
560  aPlotter->SetColor( GetLayerColor( LAYER_FIELDS ) );
561  bool fill = aPlotter->GetColorMode();
562 
563  for( LIB_ITEM& item : m_drawings )
564  {
565  if( item.Type() != LIB_FIELD_T )
566  continue;
567 
568  if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
569  continue;
570 
571  if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
572  continue;
573 
574  // The reference is a special case: we should change the basic text
575  // to add '?' and the part id
576  LIB_FIELD& field = (LIB_FIELD&) item;
577  wxString tmp = field.GetShownText();
578  if( field.GetId() == REFERENCE )
579  {
580  wxString text = field.GetFullText( aUnit );
581  field.SetText( text );
582  }
583  item.Plot( aPlotter, aOffset, fill, aTransform );
584  field.SetText( tmp );
585  }
586 }
587 
588 
589 void LIB_PART::RemoveDrawItem( LIB_ITEM* aItem, EDA_DRAW_PANEL* aPanel, wxDC* aDc )
590 {
591  wxASSERT( aItem != NULL );
592 
593  // none of the MANDATORY_FIELDS may be removed in RAM, but they may be
594  // omitted when saving to disk.
595  if( aItem->Type() == LIB_FIELD_T )
596  {
597  LIB_FIELD* field = (LIB_FIELD*) aItem;
598 
599  if( field->GetId() < MANDATORY_FIELDS )
600  {
601  wxLogWarning( _(
602  "An attempt was made to remove the %s field from component %s in library %s." ),
603  GetChars( field->GetName() ), GetChars( GetName() ),
604  GetChars( GetLibraryName() ) );
605  return;
606  }
607  }
608 
609  LIB_ITEMS& items = m_drawings[ aItem->Type() ];
610 
611  for( LIB_ITEMS::iterator i = items.begin(); i != items.end(); i++ )
612  {
613  if( *i == aItem )
614  {
615  if( aDc != NULL )
616  aItem->Draw( aPanel, aDc, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED,
617  g_XorMode, NULL, DefaultTransform );
618 
619  items.erase( i );
620  SetModified();
621  break;
622  }
623  }
624 }
625 
626 
628 {
629  wxASSERT( aItem != NULL );
630 
631  m_drawings.push_back( aItem );
632 }
633 
634 
636 {
637  if( m_drawings.empty( aType ) )
638  return NULL;
639 
640  if( aItem == NULL )
641  return &( *( m_drawings.begin( aType ) ) );
642 
643  // Search for the last item, assume aItem is of type aType
644  wxASSERT( ( aType == TYPE_NOT_INIT ) || ( aType == aItem->Type() ) );
646 
647  while( ( it != m_drawings.end( aType ) ) && ( aItem != &( *it ) ) )
648  ++it;
649 
650  // Search the next item
651  if( it != m_drawings.end( aType ) )
652  {
653  ++it;
654 
655  if( it != m_drawings.end( aType ) )
656  return &( *it );
657  }
658 
659  return NULL;
660 }
661 
662 
663 void LIB_PART::GetPins( LIB_PINS& aList, int aUnit, int aConvert )
664 {
665  if( m_drawings.empty( LIB_PIN_T ) )
666  return;
667 
668  /* Notes:
669  * when aUnit == 0: no unit filtering
670  * when aConvert == 0: no convert (shape selection) filtering
671  * when .m_Unit == 0, the body item is common to units
672  * when .m_Convert == 0, the body item is common to shapes
673  */
674  for( LIB_ITEM& item : m_drawings[ LIB_PIN_T ] )
675  {
676  // Unit filtering:
677  if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
678  continue;
679 
680  // Shape filtering:
681  if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
682  continue;
683 
684  aList.push_back( (LIB_PIN*) &item );
685  }
686 }
687 
688 
689 LIB_PIN* LIB_PART::GetPin( const wxString& aNumber, int aUnit, int aConvert )
690 {
691  LIB_PINS pinList;
692 
693  GetPins( pinList, aUnit, aConvert );
694 
695  for( size_t i = 0; i < pinList.size(); i++ )
696  {
697  wxASSERT( pinList[i]->Type() == LIB_PIN_T );
698 
699  if( aNumber == pinList[i]->GetNumber() )
700  return pinList[i];
701  }
702 
703  return NULL;
704 }
705 
706 
707 bool LIB_PART::PinsConflictWith( LIB_PART& aOtherPart, bool aTestNums, bool aTestNames,
708  bool aTestType, bool aTestOrientation, bool aTestLength )
709 {
710  LIB_PINS thisPinList;
711  GetPins( thisPinList, /* aUnit */ 0, /* aConvert */ 0 );
712 
713  for( LIB_PIN* eachThisPin : thisPinList )
714  {
715  wxASSERT( eachThisPin );
716  LIB_PINS otherPinList;
717  aOtherPart.GetPins( otherPinList, /* aUnit */ 0, /* aConvert */ 0 );
718  bool foundMatch = false;
719 
720  for( LIB_PIN* eachOtherPin : otherPinList )
721  {
722  wxASSERT( eachOtherPin );
723  // Same position?
724  if( eachThisPin->GetPosition() != eachOtherPin->GetPosition() )
725  continue;
726 
727  // Same number?
728  if( aTestNums && ( eachThisPin->GetNumber() != eachOtherPin->GetNumber() ))
729  continue;
730 
731  // Same name?
732  if( aTestNames && ( eachThisPin->GetName() != eachOtherPin->GetName() ))
733  continue;
734 
735  // Same electrical type?
736  if( aTestType && ( eachThisPin->GetType() != eachOtherPin->GetType() ))
737  continue;
738 
739  // Same orientation?
740  if( aTestOrientation && ( eachThisPin->GetOrientation() != eachOtherPin->GetOrientation() ))
741  continue;
742 
743  // Same length?
744  if( aTestLength && ( eachThisPin->GetLength() != eachOtherPin->GetLength() ))
745  continue;
746 
747  foundMatch = true;
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 = 2;
796  aLayers[0] = LAYER_DEVICE;
797  aLayers[1] = LAYER_DEVICE_BACKGROUND;
798 }
799 
800 
801 const EDA_RECT LIB_PART::GetBodyBoundingBox( int aUnit, int aConvert ) const
802 {
803  EDA_RECT bBox;
804  bool initialized = false;
805 
806  for( const LIB_ITEM& item : m_drawings )
807  {
808  if( ( item.m_Unit > 0 ) && ( ( m_unitCount > 1 ) && ( aUnit > 0 )
809  && ( aUnit != item.m_Unit ) ) )
810  continue;
811 
812  if( item.m_Convert > 0 && ( ( aConvert > 0 ) && ( aConvert != item.m_Convert ) ) )
813  continue;
814 
815  if( item.Type() == LIB_FIELD_T )
816  continue;
817 
818  if( initialized )
819  bBox.Merge( item.GetBoundingBox() );
820  else
821  {
822  bBox = item.GetBoundingBox();
823  initialized = true;
824  }
825  }
826 
827  return bBox;
828 }
829 
830 
832 {
833  m_drawings[ LIB_FIELD_T ].clear();
834 }
835 
836 
837 void LIB_PART::SetFields( const std::vector <LIB_FIELD>& aFields )
838 {
839  deleteAllFields();
840 
841  for( unsigned i=0; i<aFields.size(); ++i )
842  {
843  // drawings is a ptr_vector, new and copy an object on the heap.
844  LIB_FIELD* field = new LIB_FIELD( aFields[i] );
845 
846  field->SetParent( this );
847  m_drawings.push_back( field );
848  }
849 }
850 
851 
853 {
854  LIB_FIELD* field;
855 
856  // Grab the MANDATORY_FIELDS first, in expected order given by
857  // enum NumFieldType
858  for( int id=0; id<MANDATORY_FIELDS; ++id )
859  {
860  field = GetField( id );
861 
862  // the MANDATORY_FIELDS are exactly that in RAM.
863  wxASSERT( field );
864 
865  aList.push_back( *field );
866  }
867 
868  // Now grab all the rest of fields.
869  for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
870  {
871  field = ( LIB_FIELD* ) &item;
872 
873  if( (unsigned) field->GetId() < MANDATORY_FIELDS )
874  continue; // was added above
875 
876  aList.push_back( *field );
877  }
878 }
879 
880 
882 {
883  for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
884  {
885  LIB_FIELD* field = ( LIB_FIELD* ) &item;
886 
887  if( field->GetId() == aId )
888  return field;
889  }
890 
891  return NULL;
892 }
893 
894 
895 LIB_FIELD* LIB_PART::FindField( const wxString& aFieldName )
896 {
897  for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
898  {
899  LIB_FIELD* field = ( LIB_FIELD* ) &item;
900 
901  if( field->GetName() == aFieldName )
902  return field;
903  }
904 
905  return NULL;
906 }
907 
908 
910 {
911  LIB_FIELD* field = GetField( VALUE );
912  wxASSERT( field != NULL );
913  return *field;
914 }
915 
916 
918 {
919  LIB_FIELD* field = GetField( REFERENCE );
920  wxASSERT( field != NULL );
921  return *field;
922 }
923 
924 
926 {
927  LIB_FIELD* field = GetField( FOOTPRINT );
928  wxASSERT( field != NULL );
929  return *field;
930 }
931 
932 
934 {
935  int year, mon, day, hour, min, sec;
936 
937  if( m_dateLastEdition == 0 )
938  return true;
939 
940  sec = m_dateLastEdition & 63;
941  min = ( m_dateLastEdition >> 6 ) & 63;
942  hour = ( m_dateLastEdition >> 12 ) & 31;
943  day = ( m_dateLastEdition >> 17 ) & 31;
944  mon = ( m_dateLastEdition >> 22 ) & 15;
945  year = ( m_dateLastEdition >> 26 ) + 1990;
946 
947  aFormatter.Print( 0, "Ti %d/%d/%d %d:%d:%d\n", year, mon, day, hour, min, sec );
948 
949  return true;
950 }
951 
952 
953 bool LIB_PART::LoadDateAndTime( char* aLine )
954 {
955  int year, mon, day, hour, min, sec;
956 
957  year = mon = day = hour = min = sec = 0;
958  strtok( aLine, " \r\t\n" );
959  strtok( NULL, " \r\t\n" );
960 
961  if( sscanf( aLine, "%d/%d/%d %d:%d:%d", &year, &mon, &day, &hour, &min, &sec ) != 6 )
962  return false;
963 
964  m_dateLastEdition = ( sec & 63 ) + ( ( min & 63 ) << 6 ) +
965  ( ( hour & 31 ) << 12 ) + ( ( day & 31 ) << 17 ) +
966  ( ( mon & 15 ) << 22 ) + ( ( year - 1990 ) << 26 );
967 
968  return true;
969 }
970 
971 
972 void LIB_PART::SetOffset( const wxPoint& aOffset )
973 {
974  for( LIB_ITEM& item : m_drawings )
975  item.SetOffset( aOffset );
976 }
977 
978 
980 {
981  m_drawings.unique();
982 }
983 
984 
986 {
987  for( const LIB_ITEM& item : m_drawings )
988  {
989  if( item.m_Convert > 1 )
990  return true;
991  }
992 
993  return false;
994 }
995 
997 {
998  for( LIB_ITEM& item : m_drawings )
999  {
1000  item.m_Flags = 0;
1001  }
1002 }
1003 
1004 LIB_ITEM* LIB_PART::LocateDrawItem( int aUnit, int aConvert,
1005  KICAD_T aType, const wxPoint& aPoint )
1006 {
1007  for( LIB_ITEM& item : m_drawings )
1008  {
1009  if( ( aUnit && item.m_Unit && ( aUnit != item.m_Unit) )
1010  || ( aConvert && item.m_Convert && ( aConvert != item.m_Convert ) )
1011  || ( ( item.Type() != aType ) && ( aType != TYPE_NOT_INIT ) ) )
1012  continue;
1013 
1014  if( item.HitTest( aPoint ) )
1015  return &item;
1016  }
1017 
1018  return NULL;
1019 }
1020 
1021 
1022 LIB_ITEM* LIB_PART::LocateDrawItem( int aUnit, int aConvert, KICAD_T aType,
1023  const wxPoint& aPoint, const TRANSFORM& aTransform )
1024 {
1025  /* we use LocateDrawItem( int aUnit, int convert, KICAD_T type, const
1026  * wxPoint& pt ) to search items.
1027  * because this function uses DefaultTransform as orient/mirror matrix
1028  * we temporary copy aTransform in DefaultTransform
1029  */
1030  LIB_ITEM* item;
1031  TRANSFORM transform = DefaultTransform;
1032  DefaultTransform = aTransform;
1033 
1034  item = LocateDrawItem( aUnit, aConvert, aType, aPoint );
1035 
1036  // Restore matrix
1037  DefaultTransform = transform;
1038 
1039  return item;
1040 }
1041 
1042 
1043 void LIB_PART::SetUnitCount( int aCount )
1044 {
1045  if( m_unitCount == aCount )
1046  return;
1047 
1048  if( aCount < m_unitCount )
1049  {
1051 
1052  while( i != m_drawings.end() )
1053  {
1054  if( i->m_Unit > aCount )
1055  i = m_drawings.erase( i );
1056  else
1057  ++i;
1058  }
1059  }
1060  else
1061  {
1062  int prevCount = m_unitCount;
1063 
1064  // Temporary storage for new items, as adding new items directly to
1065  // m_drawings may cause the buffer reallocation which invalidates the
1066  // iterators
1067  std::vector< LIB_ITEM* > tmp;
1068 
1069  for( LIB_ITEM& item : m_drawings )
1070  {
1071  if( item.m_Unit != 1 )
1072  continue;
1073 
1074  for( int j = prevCount + 1; j <= aCount; j++ )
1075  {
1076  LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
1077  newItem->m_Unit = j;
1078  tmp.push_back( newItem );
1079  }
1080  }
1081 
1082  for( auto item : tmp )
1083  m_drawings.push_back( item );
1084  }
1085 
1086  m_unitCount = aCount;
1087 }
1088 
1089 
1090 void LIB_PART::SetConversion( bool aSetConvert )
1091 {
1092  if( aSetConvert == HasConversion() )
1093  return;
1094 
1095  // Duplicate items to create the converted shape
1096  if( aSetConvert )
1097  {
1098  std::vector< LIB_ITEM* > tmp; // Temporarily store the duplicated pins here.
1099 
1100  for( LIB_ITEM& item : m_drawings )
1101  {
1102  // Only pins are duplicated.
1103  if( item.Type() != LIB_PIN_T )
1104  continue;
1105 
1106  if( item.m_Convert == 1 )
1107  {
1108  LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
1109  newItem->m_Convert = 2;
1110  tmp.push_back( newItem );
1111  }
1112  }
1113 
1114  // Transfer the new pins to the LIB_PART.
1115  for( unsigned i = 0; i < tmp.size(); i++ )
1116  m_drawings.push_back( tmp[i] );
1117  }
1118  else
1119  {
1120  // Delete converted shape items because the converted shape does
1121  // not exist
1123 
1124  while( i != m_drawings.end() )
1125  {
1126  if( i->m_Convert > 1 )
1127  i = m_drawings.erase( i );
1128  else
1129  ++i;
1130  }
1131  }
1132 }
1133 
1134 
1135 wxArrayString LIB_PART::GetAliasNames( bool aIncludeRoot ) const
1136 {
1137  wxArrayString names;
1138 
1139  LIB_ALIASES::const_iterator it;
1140 
1141  for( it=m_aliases.begin(); it != m_aliases.end(); ++it )
1142  {
1143  if( !aIncludeRoot && (*it)->IsRoot() )
1144  continue;
1145 
1146  names.Add( (*it)->GetName() );
1147  }
1148 
1149  return names;
1150 }
1151 
1152 
1153 bool LIB_PART::HasAlias( const wxString& aName ) const
1154 {
1155  wxCHECK2_MSG( !aName.IsEmpty(), return false,
1156  wxT( "Cannot get alias with an empty name, bad programmer." ) );
1157 
1158  for( size_t i = 0; i < m_aliases.size(); i++ )
1159  {
1160  if( aName == m_aliases[i]->GetName() )
1161  return true;
1162  }
1163 
1164  return false;
1165 }
1166 
1167 
1168 void LIB_PART::RemoveAlias( const wxString& aName )
1169 {
1170  LIB_ALIAS* a = GetAlias( aName );
1171 
1172  if( a )
1173  RemoveAlias( a );
1174 }
1175 
1176 
1178 {
1179  wxCHECK_MSG( aAlias, NULL, wxT( "Cannot remove alias by NULL pointer." ) );
1180 
1181  LIB_ALIAS* nextAlias = NULL;
1182 
1183  LIB_ALIASES::iterator it = find( m_aliases.begin(), m_aliases.end(), aAlias );
1184 
1185  if( it != m_aliases.end() )
1186  {
1187  bool rename = aAlias->IsRoot();
1188 
1189  wxLogTrace( traceSchLibMem,
1190  wxT( "%s: symbol:'%s', alias:'%s', alias count %llu, reference count %ld." ),
1191  GetChars( wxString::FromAscii( __WXFUNCTION__ ) ),
1192  GetChars( GetName() ),
1193  GetChars( aAlias->GetName() ),
1194  (long long unsigned) m_aliases.size(),
1195  m_me.use_count() );
1196 
1197  it = m_aliases.erase( it );
1198 
1199  if( !m_aliases.empty() )
1200  {
1201  if( it == m_aliases.end() )
1202  it = m_aliases.begin();
1203 
1204  nextAlias = *it;
1205 
1206  if( rename )
1207  SetName( nextAlias->GetName() );
1208  }
1209  }
1210 
1211  return nextAlias;
1212 }
1213 
1214 
1216 {
1217  // Remove all of the aliases except the root alias.
1218  while( m_aliases.size() > 1 )
1219  m_aliases.pop_back();
1220 }
1221 
1222 
1223 LIB_ALIAS* LIB_PART::GetAlias( const wxString& aName )
1224 {
1225  wxCHECK2_MSG( !aName.IsEmpty(), return NULL,
1226  wxT( "Cannot get alias with an empty name. Bad programmer!" ) );
1227 
1228  for( size_t i = 0; i < m_aliases.size(); i++ )
1229  {
1230  if( aName == m_aliases[i]->GetName() )
1231  return m_aliases[i];
1232  }
1233 
1234  return NULL;
1235 }
1236 
1237 
1239 {
1240  wxCHECK2_MSG( aIndex < m_aliases.size(), return NULL,
1241  wxT( "Illegal alias list index, bad programmer." ) );
1242 
1243  return m_aliases[aIndex];
1244 }
1245 
1246 
1247 void LIB_PART::AddAlias( const wxString& aName )
1248 {
1249  m_aliases.push_back( new LIB_ALIAS( aName, this ) );
1250 }
1251 
1252 
1254 {
1255  m_aliases.push_back( aAlias );
1256 }
1257 
1258 
1259 void LIB_PART::SetSubpartIdNotation( int aSep, int aFirstId )
1260 {
1261  m_subpartFirstId = 'A';
1263 
1264  if( aSep == '.' || aSep == '-' || aSep == '_' )
1265  m_subpartIdSeparator = aSep;
1266 
1267  if( aFirstId == '1' && aSep != 0 )
1268  m_subpartFirstId = aFirstId;
1269 }
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()
const wxString GetName() const
Return the file name without path or extension.
LIB_FIELD & GetFootprintField()
Return reference to the footprint field.
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:74
wxString GetName(bool aTranslate=true) const
Returns the field name.
Definition: lib_field.cpp:448
void SetLib(PART_LIB *aLibrary)
int GetUnitCount() const
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's pins do not match another part'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.
Part library alias object definition.
ITERATOR begin(int aType=UNDEFINED_TYPE)
Definition: multivector.h:183
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 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.
LIB_ALIAS * GetAlias(size_t aIndex)
bool HasConversion() const
Test if part has more than one body conversion type (DeMorgan).
virtual void SetColor(COLOR4D color)=0
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 'A',...
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
LIB_ITEMS_CONTAINER m_drawings
Drawing items of this part.
LIB_FIELD & GetValueField()
Return reference to the value field.
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()
int GetId() const
Definition: lib_field.h:140
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
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.
virtual EDA_ITEM * Clone() const
Function Clone creates a duplicate of this item with linked list members set to NULL.
wxPoint TransformCoordinate(const wxPoint &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:41
The base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:67
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_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS
wxString GetLibNickname() const override
This file contains miscellaneous commonly used macros and functions.
wxString name
bool IsNew() const
Definition: base_struct.h:219
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 IsVisible() const
Definition: lib_field.h:166
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.
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.
void deleteAllFields()
wxArrayString GetAliasNames(bool aIncludeRoot=true) const
bool IsRoot() const override
For symbols having aliases, IsRoot() indicates the principal item.
void SetName(const wxString &aName)
#define VALUE
void GRRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, COLOR4D aColor)
Definition: gr_basic.cpp:1003
void operator()(void const *) const
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:518
void SetUnitCount(int count)
Set the units per part count.
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:216
wxString docFileName
Associate doc file name.
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:143
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 & GetKeyWords() const
void SetMaximum()
Definition: box2.h:71
const LIB_ID & GetLibId() const
Define a library symbol object.
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Definition: lib_id.h:97
wxLogTrace helper definitions.
void RemoveDuplicateDrawItems()
Remove duplicate draw items from list.
bool operator<(const LIB_ALIAS &aItem1, const LIB_ALIAS &aItem2)
wxArrayString m_FootprintList
List of suitable footprint names for the part (wild card names accepted).
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
const wxString GetLibraryName()
bool PinIsDangling(size_t aPin) const
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
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
bool IsPower() const
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...
const wxString & GetName() const
static void SetSubpartIdNotation(int aSep, int aFirstId)
Set the separator char between the subpart id and the reference 0 (no separator) or '.
std::vector< LIB_FIELD > LIB_FIELDS
Definition: lib_field.h:259
size_t i
Definition: json11.cpp:597
const EDA_RECT GetUnitBoundingBox(int aUnit, int aConvert) const
Get the bounding box for the symbol.
Class 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:371
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 '_'.
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.
LIB_ITEM * LocateDrawItem(int aUnit, int aConvert, KICAD_T aType, const wxPoint &aPoint)
Locate a draw object.
virtual void SetName(const wxString &aName)
bool operator==(const wxChar *aName) const
KEEPCASE sensitive comparison of the part entry name.
virtual const BOX2I ViewBBox() const override
Returns a default bounding box for the alias.
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:148
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
bool GetGRForceBlackPenState(void)
Function GetGRForceBlackPenState.
Definition: gr_basic.cpp:214
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.
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.
bool HasAlias(const wxString &aName) const
Test if alias aName is in part alias list.
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:201
#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
bool GetColorMode() const
Definition: plotter.h:131