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 <class_drawpanel.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 {
69  SetName( aName );
70 }
71 
72 
73 LIB_ALIAS::LIB_ALIAS( const LIB_ALIAS& aAlias, LIB_PART* aRootPart ) :
74  EDA_ITEM( aAlias ),
75  shared( aRootPart )
76 {
77  name = aAlias.name;
78 
79  description = aAlias.description;
80  keyWords = aAlias.keyWords;
81  docFileName = aAlias.docFileName;
82 }
83 
84 
86 {
87  wxLogTrace( traceSchLibMem, wxT( "%s: destroying alias:'%s'" ),
88  GetChars( wxString::FromAscii( __WXFUNCTION__ ) ), GetChars( GetName() ) );
89 
90  wxCHECK_RET( shared, wxT( "~LIB_ALIAS() without a LIB_PART" ) );
91 
92  if( shared )
93  shared->RemoveAlias( this );
94 }
95 
96 
97 wxString LIB_ALIAS::GetLibNickname() const
98 {
99  wxASSERT_MSG( shared, wxT( "LIB_ALIAS without a LIB_PART" ) );
100 
101  if( shared )
102  return shared->GetLibraryName();
103 
104  return wxEmptyString;
105 }
106 
107 
108 bool LIB_ALIAS::IsRoot() const
109 {
110  return name == shared->GetName();
111 }
112 
113 
115 {
116  LIB_ID id = shared->GetLibId();
117  id.SetLibItemName( name );
118  return id;
119 }
120 
121 
123 {
124  return shared->GetLib();
125 }
126 
127 
128 void LIB_ALIAS::SetName( const wxString& aName )
129 {
131 }
132 
133 
135 {
136  return shared->GetUnitCount();
137 }
138 
139 
140 wxString LIB_ALIAS::GetUnitReference( int aUnit )
141 {
142  return LIB_PART::SubReference( aUnit, false );
143 }
144 
145 
147 {
148  // Matches are scored by offset from front of string, so inclusion of this spacer
149  // discounts matches found after it.
150  static const wxString discount( wxT( " " ) );
151 
152  wxString text = GetKeyWords() + discount + GetDescription();
153 
154  // If a footprint is defined for the part, add it to the serach string
155  if( shared )
156  {
157  wxString footprint = shared->GetFootprintField().GetText();
158 
159  if( !footprint.IsEmpty() )
160  text += discount + footprint;
161  }
162 
163  return text;
164 }
165 
166 
167 bool LIB_ALIAS::operator==( const wxChar* aName ) const
168 {
169  return name == aName;
170 }
171 
172 
173 bool operator<( const LIB_ALIAS& aItem1, const LIB_ALIAS& aItem2 )
174 {
175  return aItem1.GetName() < aItem2.GetName();
176 }
177 
178 
181 {
182  void operator()(void const *) const
183  {
184  }
185 };
186 
187 
188 LIB_PART::LIB_PART( const wxString& aName, PART_LIB* aLibrary ) :
189  EDA_ITEM( LIB_PART_T ),
190  m_me( this, null_deleter() )
191 {
192  m_dateLastEdition = 0;
193  m_unitCount = 1;
194  m_pinNameOffset = 40;
196  m_unitsLocked = false;
197  m_showPinNumbers = true;
198  m_showPinNames = true;
199 
200  // Add the MANDATORY_FIELDS in RAM only. These are assumed to be present
201  // when the field editors are invoked.
202  m_drawings[LIB_FIELD_T].reserve( 4 );
207 
208  SetLib( aLibrary );
209  SetName( aName );
210 }
211 
212 
213 LIB_PART::LIB_PART( LIB_PART& aPart, PART_LIB* aLibrary ) :
214  EDA_ITEM( aPart ),
215  m_me( this, null_deleter() )
216 {
217  LIB_ITEM* newItem;
218 
219  m_library = aLibrary;
221  m_unitCount = aPart.m_unitCount;
227  m_options = aPart.m_options;
228  m_libId = aPart.m_libId;
229 
230  for( LIB_ITEM& oldItem : aPart.m_drawings )
231  {
232  if( oldItem.IsNew() )
233  continue;
234 
235  newItem = (LIB_ITEM*) oldItem.Clone();
236  newItem->SetParent( this );
237  m_drawings.push_back( newItem );
238  }
239 
240  for( size_t i = 0; i < aPart.m_aliases.size(); i++ )
241  {
242  LIB_ALIAS* alias = new LIB_ALIAS( *aPart.m_aliases[i], this );
243  m_aliases.push_back( alias );
244  }
245 }
246 
247 
249 {
250  wxLogTrace( traceSchLibMem,
251  wxT( "%s: destroying symbol with alias list count of %llu" ),
252  GetChars( wxString::FromAscii( __WXFUNCTION__ ) ),
253  (long long unsigned) m_aliases.size() );
254 
255  // If the part is being deleted directly rather than through the library,
256  // delete all of the aliases.
257  while( m_aliases.size() )
258  {
259  LIB_ALIAS* alias = m_aliases.back();
260  m_aliases.pop_back();
261  delete alias;
262  }
263 }
264 
265 
266 const wxString LIB_PART::GetLibraryName()
267 {
268  if( m_library )
269  return m_library->GetName();
270 
271  return m_libId.GetLibNickname();
272 }
273 
274 
275 wxString LIB_PART::SubReference( int aUnit, bool aAddSeparator )
276 {
277  wxString subRef;
278 
279  if( m_subpartIdSeparator != 0 && aAddSeparator )
280  subRef << wxChar( m_subpartIdSeparator );
281 
282  if( m_subpartFirstId >= '0' && m_subpartFirstId <= '9' )
283  subRef << aUnit;
284  else
285  {
286  // use letters as notation. To allow more than 26 units, the sub ref
287  // use one letter if letter = A .. Z or a ... z, and 2 letters otherwise
288  // first letter is expected to be 'A' or 'a' (i.e. 26 letters are available)
289  int u;
290  aUnit -= 1; // Unit number starts to 1. now to 0.
291 
292  while( aUnit >= 26 ) // more than one letter are needed
293  {
294  u = aUnit / 26;
295  subRef << wxChar( m_subpartFirstId + u -1 );
296  aUnit %= 26;
297  }
298 
299  u = m_subpartFirstId + aUnit;
300  subRef << wxChar( u );
301  }
302 
303  return subRef;
304 }
305 
306 
307 const wxString& LIB_PART::GetName() const
308 {
309  static wxString dummy;
310 
311  wxCHECK_MSG( m_aliases.size(), dummy, "no aliases defined for symbol" );
312 
313  return m_aliases[0]->GetName();
314 }
315 
316 
317 void LIB_PART::SetName( const wxString& aName )
318 {
319  // The LIB_ALIAS that is the LIB_PART name has to be created so create it.
320  if( m_aliases.empty() )
321  m_aliases.push_back( new LIB_ALIAS( aName, this ) );
322  else
323  m_aliases[0]->SetName( aName );
324 
325  wxString validatedName = LIB_ID::FixIllegalChars( aName, LIB_ID::ID_SCH );
326  m_libId.SetLibItemName( validatedName, false );
327 
328  LIB_FIELD& valueField = GetValueField();
329 
330  // LIB_FIELD::SetText() calls LIB_PART::SetName(),
331  // the following if-clause is to break an infinite loop
332  if( valueField.GetText() != validatedName )
333  valueField.SetText( validatedName );
334 }
335 
336 
337 void LIB_PART::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDc, const wxPoint& aOffset,
338  int aMulti, int aConvert, const PART_DRAW_OPTIONS& aOpts )
339 {
340  BASE_SCREEN* screen = aPanel ? aPanel->GetScreen() : NULL;
341 
342  GRSetDrawMode( aDc, aOpts.draw_mode );
343 
344  /* draw background for filled items using background option
345  * Solid lines will be drawn after the background
346  * Note also, background is not drawn when:
347  * printing in black and white
348  * If the color is not the default color (aColor != -1 )
349  */
350  if( ! ( screen && screen->m_IsPrinting && GetGRForceBlackPenState() )
351  && ( aOpts.color == COLOR4D::UNSPECIFIED ) )
352  {
353  for( LIB_ITEM& drawItem : m_drawings )
354  {
355  if( drawItem.m_Fill != FILLED_WITH_BG_BODYCOLOR )
356  continue;
357 
358  if( aOpts.only_selected && !drawItem.IsSelected() )
359  continue;
360 
361  // Do not draw an item while moving (the cursor handler does that)
362  if( drawItem.m_Flags & IS_MOVED )
363  continue;
364 
365  // Do not draw items not attached to the current part
366  if( aMulti && drawItem.m_Unit && ( drawItem.m_Unit != aMulti ) )
367  continue;
368 
369  if( aConvert && drawItem.m_Convert && ( drawItem.m_Convert != aConvert ) )
370  continue;
371 
372  if( drawItem.Type() == LIB_FIELD_T )
373  continue;
374 
375  if( drawItem.Type() == LIB_FIELD_T ) // TODO dead code?
376  {
377  drawItem.Draw( aPanel, aDc, aOffset, aOpts.color,
378  aOpts.draw_mode, (void*) NULL, aOpts.transform );
379  }
380 
381  // Now, draw only the background for items with
382  // m_Fill == FILLED_WITH_BG_BODYCOLOR:
383  drawItem.Draw( aPanel, aDc, aOffset, aOpts.color,
384  aOpts.draw_mode, (void*) false, aOpts.transform );
385  }
386  }
387 
388  // Track the index into the dangling pins list
389  size_t pin_index = 0;
390 
391  for( LIB_ITEM& drawItem : m_drawings )
392  {
393  if( aOpts.only_selected && !drawItem.IsSelected() )
394  continue;
395 
396  // Do not draw an item while moving (the cursor handler does that)
397  if( drawItem.m_Flags & IS_MOVED )
398  continue;
399 
400  // Do not draw items not attached to the current part
401  if( aMulti && drawItem.m_Unit && ( drawItem.m_Unit != aMulti ) )
402  continue;
403 
404  if( aConvert && drawItem.m_Convert && ( drawItem.m_Convert != aConvert ) )
405  continue;
406 
407  if( drawItem.Type() == LIB_FIELD_T )
408  {
409  LIB_FIELD& field = dynamic_cast<LIB_FIELD&>( drawItem );
410 
411  if( field.IsVisible() && !aOpts.draw_visible_fields )
412  continue;
413 
414  if( !field.IsVisible() && !aOpts.draw_hidden_fields )
415  continue;
416  }
417 
418  if( drawItem.Type() == LIB_PIN_T )
419  {
420  LIB_PIN& pin = dynamic_cast<LIB_PIN&>( drawItem );
421 
422  uintptr_t flags = 0;
423  if( aOpts.show_pin_text )
424  flags |= PIN_DRAW_TEXTS;
425 
426  if( aOpts.show_elec_type )
428 
429  if( aOpts.PinIsDangling( pin_index ) )
430  flags |= PIN_DRAW_DANGLING;
431 
432  if( pin.IsPowerConnection() && IsPower() )
433  flags |= PIN_DANGLING_HIDDEN;
434 
435  drawItem.Draw( aPanel, aDc, aOffset, aOpts.color,
436  aOpts.draw_mode, (void*) flags, aOpts.transform );
437 
438  ++pin_index;
439  }
440  else if( drawItem.Type() == LIB_FIELD_T )
441  {
442  drawItem.Draw( aPanel, aDc, aOffset, aOpts.color,
443  aOpts.draw_mode, (void*) NULL, aOpts.transform );
444  }
445  else
446  {
447  bool forceNoFill = drawItem.m_Fill == FILLED_WITH_BG_BODYCOLOR;
448  drawItem.Draw( aPanel, aDc, aOffset, aOpts.color,
449  aOpts.draw_mode, (void*) forceNoFill,
450  aOpts.transform );
451  }
452  }
453 
454  // Enable this to draw the anchor of the component.
455 #if 0
456  int len = aDc->DeviceToLogicalXRel( 3 );
457  EDA_RECT* const clipbox = aPanel ? aPanel->GetClipBox() : NULL;
458 
459  GRLine( clipbox, aDc, aOffset.x, aOffset.y - len, aOffset.x,
460  aOffset.y + len, 0, aOpts.color );
461  GRLine( clipbox, aDc, aOffset.x - len, aOffset.y, aOffset.x + len,
462  aOffset.y, 0, aOpts.color );
463 #endif
464 
465  /* Enable this to draw the bounding box around the component to validate
466  * the bounding box calculations. */
467 #if 0
468  EDA_RECT bBox = GetUnitBoundingBox( aMulti, aConvert );
469  bBox.RevertYAxis();
470  bBox = aOpts.transform.TransformCoordinate( bBox );
471  bBox.Move( aOffset );
472  GRRect( aPanel ? aPanel->GetClipBox() : NULL, aDc, bBox, 0, LIGHTMAGENTA );
473 #endif
474 }
475 
476 
477 void LIB_PART::Plot( PLOTTER* aPlotter, int aUnit, int aConvert,
478  const wxPoint& aOffset, const TRANSFORM& aTransform )
479 {
480  wxASSERT( aPlotter != NULL );
481 
482  aPlotter->SetColor( GetLayerColor( LAYER_DEVICE ) );
483  bool fill = aPlotter->GetColorMode();
484 
485  // draw background for filled items using background option
486  // Solid lines will be drawn after the background
487  for( LIB_ITEM& item : m_drawings )
488  {
489  // Lib Fields are not plotted here, because this plot function
490  // is used to plot schematic items, which have they own fields
491  if( item.Type() == LIB_FIELD_T )
492  continue;
493 
494  if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
495  continue;
496 
497  if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
498  continue;
499 
500  if( item.m_Fill == FILLED_WITH_BG_BODYCOLOR )
501  item.Plot( aPlotter, aOffset, fill, aTransform );
502  }
503 
504  // Not filled items and filled shapes are now plotted
505  // (plot only items which are not already plotted)
506  for( LIB_ITEM& item : m_drawings )
507  {
508  if( item.Type() == LIB_FIELD_T )
509  continue;
510 
511  if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
512  continue;
513 
514  if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
515  continue;
516 
517  if( item.m_Fill != FILLED_WITH_BG_BODYCOLOR )
518  item.Plot( aPlotter, aOffset, fill, aTransform );
519  }
520 }
521 
522 
523 void LIB_PART::PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert,
524  const wxPoint& aOffset, const TRANSFORM& aTransform )
525 {
526  wxASSERT( aPlotter != NULL );
527 
528  aPlotter->SetColor( GetLayerColor( LAYER_FIELDS ) );
529  bool fill = aPlotter->GetColorMode();
530 
531  for( LIB_ITEM& item : m_drawings )
532  {
533  if( item.Type() != LIB_FIELD_T )
534  continue;
535 
536  if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
537  continue;
538 
539  if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
540  continue;
541 
542  // The reference is a special case: we should change the basic text
543  // to add '?' and the part id
544  LIB_FIELD& field = (LIB_FIELD&) item;
545  wxString tmp = field.GetShownText();
546  if( field.GetId() == REFERENCE )
547  {
548  wxString text = field.GetFullText( aUnit );
549  field.SetText( text );
550  }
551  item.Plot( aPlotter, aOffset, fill, aTransform );
552  field.SetText( tmp );
553  }
554 }
555 
556 
557 void LIB_PART::RemoveDrawItem( LIB_ITEM* aItem, EDA_DRAW_PANEL* aPanel, wxDC* aDc )
558 {
559  wxASSERT( aItem != NULL );
560 
561  // none of the MANDATORY_FIELDS may be removed in RAM, but they may be
562  // omitted when saving to disk.
563  if( aItem->Type() == LIB_FIELD_T )
564  {
565  LIB_FIELD* field = (LIB_FIELD*) aItem;
566 
567  if( field->GetId() < MANDATORY_FIELDS )
568  {
569  wxLogWarning( _(
570  "An attempt was made to remove the %s field from component %s in library %s." ),
571  GetChars( field->GetName() ), GetChars( GetName() ),
572  GetChars( GetLibraryName() ) );
573  return;
574  }
575  }
576 
577  LIB_ITEMS& items = m_drawings[ aItem->Type() ];
578 
579  for( LIB_ITEMS::iterator i = items.begin(); i != items.end(); i++ )
580  {
581  if( *i == aItem )
582  {
583  if( aDc != NULL )
584  aItem->Draw( aPanel, aDc, wxPoint( 0, 0 ), COLOR4D::UNSPECIFIED,
585  g_XorMode, NULL, DefaultTransform );
586 
587  items.erase( i );
588  SetModified();
589  break;
590  }
591  }
592 }
593 
594 
596 {
597  wxASSERT( aItem != NULL );
598 
599  m_drawings.push_back( aItem );
600 }
601 
602 
604 {
605  if( m_drawings.empty( aType ) )
606  return NULL;
607 
608  if( aItem == NULL )
609  return &( *( m_drawings.begin( aType ) ) );
610 
611  // Search for the last item, assume aItem is of type aType
612  wxASSERT( ( aType == TYPE_NOT_INIT ) || ( aType == aItem->Type() ) );
614 
615  while( ( it != m_drawings.end( aType ) ) && ( aItem != &( *it ) ) )
616  ++it;
617 
618  // Search the next item
619  if( it != m_drawings.end( aType ) )
620  {
621  ++it;
622 
623  if( it != m_drawings.end( aType ) )
624  return &( *it );
625  }
626 
627  return NULL;
628 }
629 
630 
631 void LIB_PART::GetPins( LIB_PINS& aList, int aUnit, int aConvert )
632 {
633  if( m_drawings.empty( LIB_PIN_T ) )
634  return;
635 
636  /* Notes:
637  * when aUnit == 0: no unit filtering
638  * when aConvert == 0: no convert (shape selection) filtering
639  * when .m_Unit == 0, the body item is common to units
640  * when .m_Convert == 0, the body item is common to shapes
641  */
642  for( LIB_ITEM& item : m_drawings[ LIB_PIN_T ] )
643  {
644  // Unit filtering:
645  if( aUnit && item.m_Unit && ( item.m_Unit != aUnit ) )
646  continue;
647 
648  // Shape filtering:
649  if( aConvert && item.m_Convert && ( item.m_Convert != aConvert ) )
650  continue;
651 
652  aList.push_back( (LIB_PIN*) &item );
653  }
654 }
655 
656 
657 LIB_PIN* LIB_PART::GetPin( const wxString& aNumber, int aUnit, int aConvert )
658 {
659  LIB_PINS pinList;
660 
661  GetPins( pinList, aUnit, aConvert );
662 
663  for( size_t i = 0; i < pinList.size(); i++ )
664  {
665  wxASSERT( pinList[i]->Type() == LIB_PIN_T );
666 
667  if( aNumber == pinList[i]->GetNumber() )
668  return pinList[i];
669  }
670 
671  return NULL;
672 }
673 
674 
675 bool LIB_PART::PinsConflictWith( LIB_PART& aOtherPart, bool aTestNums, bool aTestNames,
676  bool aTestType, bool aTestOrientation, bool aTestLength )
677 {
678  LIB_PINS thisPinList;
679  GetPins( thisPinList, /* aUnit */ 0, /* aConvert */ 0 );
680 
681  for( LIB_PIN* eachThisPin : thisPinList )
682  {
683  wxASSERT( eachThisPin );
684  LIB_PINS otherPinList;
685  aOtherPart.GetPins( otherPinList, /* aUnit */ 0, /* aConvert */ 0 );
686  bool foundMatch = false;
687 
688  for( LIB_PIN* eachOtherPin : otherPinList )
689  {
690  wxASSERT( eachOtherPin );
691  // Same position?
692  if( eachThisPin->GetPosition() != eachOtherPin->GetPosition() )
693  continue;
694 
695  // Same number?
696  if( aTestNums && ( eachThisPin->GetNumber() != eachOtherPin->GetNumber() ))
697  continue;
698 
699  // Same name?
700  if( aTestNames && ( eachThisPin->GetName() != eachOtherPin->GetName() ))
701  continue;
702 
703  // Same electrical type?
704  if( aTestType && ( eachThisPin->GetType() != eachOtherPin->GetType() ))
705  continue;
706 
707  // Same orientation?
708  if( aTestOrientation && ( eachThisPin->GetOrientation() != eachOtherPin->GetOrientation() ))
709  continue;
710 
711  // Same length?
712  if( aTestLength && ( eachThisPin->GetLength() != eachOtherPin->GetLength() ))
713  continue;
714 
715  foundMatch = true;
716  }
717 
718  if( !foundMatch )
719  {
720  // This means there was not an identical (according to the arguments)
721  // pin at the same position in the other component.
722  return true;
723  }
724  }
725 
726  // The loop never gave up, so no conflicts were found.
727  return false;
728 }
729 
730 
731 const EDA_RECT LIB_PART::GetUnitBoundingBox( int aUnit, int aConvert ) const
732 {
733  EDA_RECT bBox;
734  bool initialized = false;
735 
736  for( const LIB_ITEM& item : m_drawings )
737  {
738  if( ( item.m_Unit > 0 ) && ( ( m_unitCount > 1 ) && ( aUnit > 0 )
739  && ( aUnit != item.m_Unit ) ) )
740  continue;
741 
742  if( item.m_Convert > 0 && ( ( aConvert > 0 ) && ( aConvert != item.m_Convert ) ) )
743  continue;
744 
745  if ( ( item.Type() == LIB_FIELD_T ) && !( ( LIB_FIELD& ) item ).IsVisible() )
746  continue;
747 
748  if( initialized )
749  bBox.Merge( item.GetBoundingBox() );
750  else
751  {
752  bBox = item.GetBoundingBox();
753  initialized = true;
754  }
755  }
756 
757  return bBox;
758 }
759 
760 
761 const EDA_RECT LIB_PART::GetBodyBoundingBox( int aUnit, int aConvert ) const
762 {
763  EDA_RECT bBox;
764  bool initialized = false;
765 
766  for( const LIB_ITEM& item : m_drawings )
767  {
768  if( ( item.m_Unit > 0 ) && ( ( m_unitCount > 1 ) && ( aUnit > 0 )
769  && ( aUnit != item.m_Unit ) ) )
770  continue;
771 
772  if( item.m_Convert > 0 && ( ( aConvert > 0 ) && ( aConvert != item.m_Convert ) ) )
773  continue;
774 
775  if( item.Type() == LIB_FIELD_T )
776  continue;
777 
778  if( initialized )
779  bBox.Merge( item.GetBoundingBox() );
780  else
781  {
782  bBox = item.GetBoundingBox();
783  initialized = true;
784  }
785  }
786 
787  return bBox;
788 }
789 
790 
792 {
793  m_drawings[ LIB_FIELD_T ].clear();
794 }
795 
796 
797 void LIB_PART::SetFields( const std::vector <LIB_FIELD>& aFields )
798 {
799  deleteAllFields();
800 
801  for( unsigned i=0; i<aFields.size(); ++i )
802  {
803  // drawings is a ptr_vector, new and copy an object on the heap.
804  LIB_FIELD* field = new LIB_FIELD( aFields[i] );
805 
806  field->SetParent( this );
807  m_drawings.push_back( field );
808  }
809 }
810 
811 
813 {
814  LIB_FIELD* field;
815 
816  // The only caller of this function is the library field editor, so it
817  // establishes policy here.
818 
819  // Grab the MANDATORY_FIELDS first, in expected order given by
820  // enum NumFieldType
821  for( int id=0; id<MANDATORY_FIELDS; ++id )
822  {
823  field = GetField( id );
824 
825  // the MANDATORY_FIELDS are exactly that in RAM.
826  wxASSERT( field );
827 
828  aList.push_back( *field );
829  }
830 
831  // Now grab all the rest of fields.
832  for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
833  {
834  field = ( LIB_FIELD* ) &item;
835 
836  if( (unsigned) field->GetId() < MANDATORY_FIELDS )
837  continue; // was added above
838 
839  aList.push_back( *field );
840  }
841 }
842 
843 
845 {
846  for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
847  {
848  LIB_FIELD* field = ( LIB_FIELD* ) &item;
849 
850  if( field->GetId() == aId )
851  return field;
852  }
853 
854  return NULL;
855 }
856 
857 
858 LIB_FIELD* LIB_PART::FindField( const wxString& aFieldName )
859 {
860  for( LIB_ITEM& item : m_drawings[ LIB_FIELD_T ] )
861  {
862  LIB_FIELD* field = ( LIB_FIELD* ) &item;
863 
864  if( field->GetName() == aFieldName )
865  return field;
866  }
867 
868  return NULL;
869 }
870 
871 
873 {
874  LIB_FIELD* field = GetField( VALUE );
875  wxASSERT( field != NULL );
876  return *field;
877 }
878 
879 
881 {
882  LIB_FIELD* field = GetField( REFERENCE );
883  wxASSERT( field != NULL );
884  return *field;
885 }
886 
887 
889 {
890  LIB_FIELD* field = GetField( FOOTPRINT );
891  wxASSERT( field != NULL );
892  return *field;
893 }
894 
895 
897 {
898  int year, mon, day, hour, min, sec;
899 
900  if( m_dateLastEdition == 0 )
901  return true;
902 
903  sec = m_dateLastEdition & 63;
904  min = ( m_dateLastEdition >> 6 ) & 63;
905  hour = ( m_dateLastEdition >> 12 ) & 31;
906  day = ( m_dateLastEdition >> 17 ) & 31;
907  mon = ( m_dateLastEdition >> 22 ) & 15;
908  year = ( m_dateLastEdition >> 26 ) + 1990;
909 
910  aFormatter.Print( 0, "Ti %d/%d/%d %d:%d:%d\n", year, mon, day, hour, min, sec );
911 
912  return true;
913 }
914 
915 
916 bool LIB_PART::LoadDateAndTime( char* aLine )
917 {
918  int year, mon, day, hour, min, sec;
919 
920  year = mon = day = hour = min = sec = 0;
921  strtok( aLine, " \r\t\n" );
922  strtok( NULL, " \r\t\n" );
923 
924  if( sscanf( aLine, "%d/%d/%d %d:%d:%d", &year, &mon, &day, &hour, &min, &sec ) != 6 )
925  return false;
926 
927  m_dateLastEdition = ( sec & 63 ) + ( ( min & 63 ) << 6 ) +
928  ( ( hour & 31 ) << 12 ) + ( ( day & 31 ) << 17 ) +
929  ( ( mon & 15 ) << 22 ) + ( ( year - 1990 ) << 26 );
930 
931  return true;
932 }
933 
934 
935 void LIB_PART::SetOffset( const wxPoint& aOffset )
936 {
937  for( LIB_ITEM& item : m_drawings )
938  item.SetOffset( aOffset );
939 }
940 
941 
943 {
944  m_drawings.unique();
945 }
946 
947 
949 {
950  for( const LIB_ITEM& item : m_drawings )
951  {
952  if( item.m_Convert > 1 )
953  return true;
954  }
955 
956  return false;
957 }
958 
959 
961 {
962  for( LIB_ITEM& item : m_drawings )
963  {
964  item.m_Flags = 0;
965  }
966 }
967 
968 
969 int LIB_PART::SelectItems( EDA_RECT& aRect, int aUnit, int aConvert, bool aSyncPinEdit )
970 {
971  int itemCount = 0;
972 
973  for( LIB_ITEM& item : m_drawings )
974  {
975  item.ClearFlags( SELECTED );
976 
977  if( ( item.m_Unit && item.m_Unit != aUnit )
978  || ( item.m_Convert && item.m_Convert != aConvert ) )
979  {
980  if( item.Type() != LIB_PIN_T )
981  continue;
982 
983  // Specific rules for pins:
984  // - do not select pins in other units when synchronized pin edit mode is disabled
985  // - do not select pins in other units when units are not interchangeable
986  // - in other cases verify if the pin belongs to the requested unit
987  if( !aSyncPinEdit || m_unitsLocked
988  || ( item.m_Convert && item.m_Convert != aConvert ) )
989  continue;
990  }
991 
992  if( item.Inside( aRect ) )
993  {
994  item.SetFlags( SELECTED );
995  itemCount++;
996  }
997  }
998 
999  return itemCount;
1000 }
1001 
1002 
1003 void LIB_PART::MoveSelectedItems( const wxPoint& aOffset )
1004 {
1005  for( LIB_ITEM& item : m_drawings )
1006  {
1007  if( !item.IsSelected() )
1008  continue;
1009 
1010  item.SetOffset( aOffset );
1011  item.m_Flags = 0;
1012  }
1013 }
1014 
1015 
1017 {
1018  for( LIB_ITEM& item : m_drawings )
1019  {
1020  item.m_Flags = 0;
1021  }
1022 }
1023 
1024 
1026 {
1028 
1029  // We *do not* remove the 2 mandatory fields: reference and value
1030  // so skip them (do not remove) if they are flagged selected.
1031  // Skip also not visible items.
1032  // But I think fields must not be deleted by a block delete command or other global command
1033  // because they are not really graphic items
1034  while( item != m_drawings.end() )
1035  {
1036  if( item->Type() == LIB_FIELD_T )
1037  {
1038  item->ClearFlags( SELECTED );
1039  }
1040 
1041  if( !item->IsSelected() )
1042  ++item;
1043  else
1044  item = m_drawings.erase( item );
1045  }
1046 }
1047 
1048 
1049 void LIB_PART::CopySelectedItems( const wxPoint& aOffset )
1050 {
1051  std::vector< LIB_ITEM* > tmp;
1052 
1053  for( LIB_ITEM& item : m_drawings )
1054  {
1055  // We *do not* copy fields because they are unique for the whole component
1056  // so skip them (do not duplicate) if they are flagged selected.
1057  if( item.Type() == LIB_FIELD_T )
1058  item.ClearFlags( SELECTED );
1059 
1060  if( !item.IsSelected() )
1061  continue;
1062 
1063  item.ClearFlags( SELECTED );
1064  LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
1065  newItem->SetFlags( SELECTED );
1066 
1067  // When push_back elements in buffer, a memory reallocation can happen
1068  // and will break pointers.
1069  // So, push_back later.
1070  tmp.push_back( newItem );
1071  }
1072 
1073  for( auto item : tmp )
1074  m_drawings.push_back( item );
1075 
1076  MoveSelectedItems( aOffset );
1077 }
1078 
1079 
1081 {
1082  for( LIB_ITEM& item : m_drawings )
1083  {
1084  if( !item.IsSelected() )
1085  continue;
1086 
1087  item.MirrorHorizontal( aCenter );
1088  item.m_Flags = 0;
1089  }
1090 }
1091 
1092 
1094 {
1095  for( LIB_ITEM& item : m_drawings )
1096  {
1097  if( !item.IsSelected() )
1098  continue;
1099 
1100  item.MirrorVertical( aCenter );
1101  item.m_Flags = 0;
1102  }
1103 }
1104 
1105 
1107 {
1108  for( LIB_ITEM& item : m_drawings )
1109  {
1110  if( !item.IsSelected() )
1111  continue;
1112 
1113  item.Rotate( aCenter );
1114  item.m_Flags = 0;
1115  }
1116 }
1117 
1118 
1119 LIB_ITEM* LIB_PART::LocateDrawItem( int aUnit, int aConvert,
1120  KICAD_T aType, const wxPoint& aPoint )
1121 {
1122  for( LIB_ITEM& item : m_drawings )
1123  {
1124  if( ( aUnit && item.m_Unit && ( aUnit != item.m_Unit) )
1125  || ( aConvert && item.m_Convert && ( aConvert != item.m_Convert ) )
1126  || ( ( item.Type() != aType ) && ( aType != TYPE_NOT_INIT ) ) )
1127  continue;
1128 
1129  if( item.HitTest( aPoint ) )
1130  return &item;
1131  }
1132 
1133  return NULL;
1134 }
1135 
1136 
1137 LIB_ITEM* LIB_PART::LocateDrawItem( int aUnit, int aConvert, KICAD_T aType,
1138  const wxPoint& aPoint, const TRANSFORM& aTransform )
1139 {
1140  /* we use LocateDrawItem( int aUnit, int convert, KICAD_T type, const
1141  * wxPoint& pt ) to search items.
1142  * because this function uses DefaultTransform as orient/mirror matrix
1143  * we temporary copy aTransform in DefaultTransform
1144  */
1145  LIB_ITEM* item;
1146  TRANSFORM transform = DefaultTransform;
1147  DefaultTransform = aTransform;
1148 
1149  item = LocateDrawItem( aUnit, aConvert, aType, aPoint );
1150 
1151  // Restore matrix
1152  DefaultTransform = transform;
1153 
1154  return item;
1155 }
1156 
1157 
1158 void LIB_PART::SetUnitCount( int aCount )
1159 {
1160  if( m_unitCount == aCount )
1161  return;
1162 
1163  if( aCount < m_unitCount )
1164  {
1166 
1167  while( i != m_drawings.end() )
1168  {
1169  if( i->m_Unit > aCount )
1170  i = m_drawings.erase( i );
1171  else
1172  ++i;
1173  }
1174  }
1175  else
1176  {
1177  int prevCount = m_unitCount;
1178 
1179  // Temporary storage for new items, as adding new items directly to
1180  // m_drawings may cause the buffer reallocation which invalidates the
1181  // iterators
1182  std::vector< LIB_ITEM* > tmp;
1183 
1184  for( LIB_ITEM& item : m_drawings )
1185  {
1186  if( item.m_Unit != 1 )
1187  continue;
1188 
1189  for( int j = prevCount + 1; j <= aCount; j++ )
1190  {
1191  LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
1192  newItem->m_Unit = j;
1193  tmp.push_back( newItem );
1194  }
1195  }
1196 
1197  for( auto item : tmp )
1198  m_drawings.push_back( item );
1199  }
1200 
1201  m_unitCount = aCount;
1202 }
1203 
1204 
1205 void LIB_PART::SetConversion( bool aSetConvert )
1206 {
1207  if( aSetConvert == HasConversion() )
1208  return;
1209 
1210  // Duplicate items to create the converted shape
1211  if( aSetConvert )
1212  {
1213  std::vector< LIB_ITEM* > tmp; // Temporarily store the duplicated pins here.
1214 
1215  for( LIB_ITEM& item : m_drawings )
1216  {
1217  // Only pins are duplicated.
1218  if( item.Type() != LIB_PIN_T )
1219  continue;
1220 
1221  if( item.m_Convert == 1 )
1222  {
1223  LIB_ITEM* newItem = (LIB_ITEM*) item.Clone();
1224  newItem->m_Convert = 2;
1225  tmp.push_back( newItem );
1226  }
1227  }
1228 
1229  // Transfer the new pins to the LIB_PART.
1230  for( unsigned i = 0; i < tmp.size(); i++ )
1231  m_drawings.push_back( tmp[i] );
1232  }
1233  else
1234  {
1235  // Delete converted shape items because the converted shape does
1236  // not exist
1238 
1239  while( i != m_drawings.end() )
1240  {
1241  if( i->m_Convert > 1 )
1242  i = m_drawings.erase( i );
1243  else
1244  ++i;
1245  }
1246  }
1247 }
1248 
1249 
1250 wxArrayString LIB_PART::GetAliasNames( bool aIncludeRoot ) const
1251 {
1252  wxArrayString names;
1253 
1254  LIB_ALIASES::const_iterator it;
1255 
1256  for( it=m_aliases.begin(); it != m_aliases.end(); ++it )
1257  {
1258  if( !aIncludeRoot && (*it)->IsRoot() )
1259  continue;
1260 
1261  names.Add( (*it)->GetName() );
1262  }
1263 
1264  return names;
1265 }
1266 
1267 
1268 bool LIB_PART::HasAlias( const wxString& aName ) const
1269 {
1270  wxCHECK2_MSG( !aName.IsEmpty(), return false,
1271  wxT( "Cannot get alias with an empty name, bad programmer." ) );
1272 
1273  for( size_t i = 0; i < m_aliases.size(); i++ )
1274  {
1275  if( aName == m_aliases[i]->GetName() )
1276  return true;
1277  }
1278 
1279  return false;
1280 }
1281 
1282 
1283 void LIB_PART::RemoveAlias( const wxString& aName )
1284 {
1285  LIB_ALIAS* a = GetAlias( aName );
1286 
1287  if( a )
1288  RemoveAlias( a );
1289 }
1290 
1291 
1293 {
1294  wxCHECK_MSG( aAlias, NULL, wxT( "Cannot remove alias by NULL pointer." ) );
1295 
1296  LIB_ALIAS* nextAlias = NULL;
1297 
1298  LIB_ALIASES::iterator it = find( m_aliases.begin(), m_aliases.end(), aAlias );
1299 
1300  if( it != m_aliases.end() )
1301  {
1302  bool rename = aAlias->IsRoot();
1303 
1304  wxLogTrace( traceSchLibMem,
1305  wxT( "%s: symbol:'%s', alias:'%s', alias count %llu, reference count %ld." ),
1306  GetChars( wxString::FromAscii( __WXFUNCTION__ ) ),
1307  GetChars( GetName() ),
1308  GetChars( aAlias->GetName() ),
1309  (long long unsigned) m_aliases.size(),
1310  m_me.use_count() );
1311 
1312  it = m_aliases.erase( it );
1313 
1314  if( !m_aliases.empty() )
1315  {
1316  if( it == m_aliases.end() )
1317  it = m_aliases.begin();
1318 
1319  nextAlias = *it;
1320 
1321  if( rename )
1322  SetName( nextAlias->GetName() );
1323  }
1324  }
1325 
1326  return nextAlias;
1327 }
1328 
1329 
1331 {
1332  // Remove all of the aliases except the root alias.
1333  while( m_aliases.size() > 1 )
1334  m_aliases.pop_back();
1335 }
1336 
1337 
1338 LIB_ALIAS* LIB_PART::GetAlias( const wxString& aName )
1339 {
1340  wxCHECK2_MSG( !aName.IsEmpty(), return NULL,
1341  wxT( "Cannot get alias with an empty name. Bad programmer!" ) );
1342 
1343  for( size_t i = 0; i < m_aliases.size(); i++ )
1344  {
1345  if( aName == m_aliases[i]->GetName() )
1346  return m_aliases[i];
1347  }
1348 
1349  return NULL;
1350 }
1351 
1352 
1354 {
1355  wxCHECK2_MSG( aIndex < m_aliases.size(), return NULL,
1356  wxT( "Illegal alias list index, bad programmer." ) );
1357 
1358  return m_aliases[aIndex];
1359 }
1360 
1361 
1362 void LIB_PART::AddAlias( const wxString& aName )
1363 {
1364  m_aliases.push_back( new LIB_ALIAS( aName, this ) );
1365 }
1366 
1367 
1369 {
1370  m_aliases.push_back( aAlias );
1371 }
1372 
1373 
1374 void LIB_PART::SetSubpartIdNotation( int aSep, int aFirstId )
1375 {
1376  m_subpartFirstId = 'A';
1378 
1379  if( aSep == '.' || aSep == '-' || aSep == '_' )
1380  m_subpartIdSeparator = aSep;
1381 
1382  if( aFirstId == '1' && aSep != 0 )
1383  m_subpartFirstId = aFirstId;
1384 }
timestamp_t m_dateLastEdition
Date of the last modification.
LIB_ALIASES m_aliases
List of alias object pointers associated with the part.
PART_LIB * GetLib()
virtual ~LIB_ALIAS()
LIB_FIELD & GetFootprintField()
Return reference to the footprint field.
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:73
void SetLib(PART_LIB *aLibrary)
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
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:318
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:216
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)
wxString GetFullText(int unit=1) const
Return the text of a field.
Definition: lib_field.cpp:356
void ClearSelectedItems()
Clears all the draw items marked by a block select.
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:66
LIB_ITEMS_CONTAINER::ITEM_PTR_VECTOR LIB_ITEMS
void MirrorSelectedItemsH(const wxPoint &aCenter)
Horizontally (X axis) mirror selected draw items about a point.
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.
void MirrorSelectedItemsV(const wxPoint &aCenter)
Vertically (Y axis) mirror selected draw items about a point.
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
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()
#define SELECTED
Definition: base_struct.h:118
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:1098
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.
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:253
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:502
const wxString & GetKeyWords() const
void SetUnitCount(int count)
Set the units per part count.
void SetParent(EDA_ITEM *aParent)
Definition: base_struct.h:213
int GetId() const
Definition: lib_field.h:138
wxString docFileName
Associate doc file name.
void CopySelectedItems(const wxPoint &aOffset)
Make a copy of the selected draw items marked by a block select.
LIB_PART * shared
Actual LIB_PART referenced by [multiple] aliases.
void RotateSelectedItems(const wxPoint &aCenter)
Rotate CCW selected draw items about a point.
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.
int SelectItems(EDA_RECT &aRect, int aUnit, int aConvert, bool aSyncPinEdit)
Checks all draw objects of part to see if they are with block.
bool operator==(const wxChar *aName) const
KEEPCASE sensitive comparison of the part entry name.
Define a library symbol object.
EDA_RECT * GetClipBox()
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:380
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:432
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.
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:60
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:164
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:257
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.
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:176
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:151
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
void MoveSelectedItems(const wxPoint &aOffset)
Move the selected draw items marked by a block select.
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)
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:309
void DeleteSelectedItems()
Deletes the select draw items marked by a block select.
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 withing 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:110
PART_SPTR m_me
http://www.boost.org/doc/libs/1_55_0/libs/smart_ptr/sp_techniques.html#weak_without_shared ...