KiCad PCB EDA Suite
lib_pin.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) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2015 Wayne Stambaugh <stambaughw@gmail.com>
6  * Copyright (C) 1992-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 <wx/tokenzr.h>
31 
32 #include <fctsys.h>
33 #include <pgm_base.h>
34 #include <gr_basic.h>
35 #include <macros.h>
36 #include <trigo.h>
37 #include <sch_draw_panel.h>
38 #include <draw_graphic_text.h>
39 #include <plotter.h>
40 #include <sch_edit_frame.h>
41 #include <base_units.h>
42 #include <msgpanel.h>
43 
44 #include <general.h>
45 #include <lib_edit_frame.h>
46 #include <class_libentry.h>
47 #include <lib_pin.h>
48 #include <transform.h>
49 #include <sch_component.h>
50 #include <sch_sheet_path.h>
51 #include <trace_helpers.h>
52 
53 
54 static const int pin_orientation_codes[] =
55 {
56  PIN_RIGHT,
57  PIN_LEFT,
58  PIN_UP,
59  PIN_DOWN
60 };
61 #define PIN_ORIENTATION_CNT arrayDim( pin_orientation_codes )
62 
63 // small margin in internal units between the pin text and the pin line
64 #define PIN_TEXT_MARGIN 4
65 
66 // bitmaps to show pins orientations in dialog editor
67 // must have same order than pin_orientation_names
68 static const BITMAP_DEF iconsPinsOrientations[] =
69 {
70  pinorient_right_xpm,
71  pinorient_left_xpm,
72  pinorient_up_xpm,
73  pinorient_down_xpm,
74 };
75 
76 
78 {
79  if( aType < 0 || aType >= (int) PINTYPE_COUNT )
80  return wxT( "???" );
81 
82  // These strings are the canonical name of the electrictal type
83  // Not translated, no space in name, only ASCII chars.
84  // to use when the string name must be known and well defined
85  // must have same order than enum ELECTRICAL_PINTYPE (see lib_pin.h)
86  static const wxChar* msgPinElectricType[] =
87  {
88  wxT( "input" ),
89  wxT( "output" ),
90  wxT( "BiDi" ),
91  wxT( "3state" ),
92  wxT( "passive" ),
93  wxT( "unspc" ),
94  wxT( "power_in" ),
95  wxT( "power_out" ),
96  wxT( "openCol" ),
97  wxT( "openEm" ),
98  wxT( "NotConnected" )
99  };
100 
101  return msgPinElectricType[ aType ];
102 }
103 
104 
105 // Helper functions to get the pin orientation name from pin_orientation_codes
106 // Note: the strings are *not* static because they are translated and must be built
107 // on the fly, to be properly translated
108 
109 static const wxString getPinOrientationName( unsigned aPinOrientationCode )
110 {
111  /* Note: The following name lists are sentence capitalized per the GNOME UI
112  * standards for list controls. Please do not change the capitalization
113  * of these strings unless the GNOME UI standards are changed.
114  */
115  const wxString pin_orientation_names[] =
116  {
117  _( "Right" ),
118  _( "Left" ),
119  _( "Up" ),
120  _( "Down" ),
121  wxT( "???" )
122  };
123 
124  if( aPinOrientationCode > PIN_ORIENTATION_CNT )
125  aPinOrientationCode = PIN_ORIENTATION_CNT;
126 
127  return pin_orientation_names[ aPinOrientationCode ];
128 }
129 
131 // i.e. the clock symbols (falling clock is actually external but is of
132 // the same kind)
133 
134 static int InternalPinDecoSize( const LIB_PIN &aPin )
135 {
136 
137  return aPin.GetNameTextSize() != 0 ? aPin.GetNameTextSize() / 2 : aPin.GetNumberTextSize() / 2;
138 }
139 
141 // i.e. the negation circle, the polarity 'slopes' and the nonlogic
142 // marker
143 static int ExternalPinDecoSize( const LIB_PIN &aPin )
144 {
145  return aPin.GetNumberTextSize() / 2;
146 }
147 
149  LIB_ITEM( LIB_PIN_T, aParent ),
150  m_shape( PINSHAPE_LINE )
151 {
153  m_orientation = PIN_RIGHT; // Pin orient: Up, Down, Left, Right
154  m_type = PIN_UNSPECIFIED; // electrical type of pin
155  m_attributes = 0; // bit 0 != 0: pin invisible
158  m_width = 0;
159 }
160 
161 
162 void LIB_PIN::SetName( const wxString& aName, bool aTestOtherPins )
163 {
164  wxString tmp = ( aName.IsEmpty() ) ? wxT( "~" ) : aName;
165 
166  // pin name string does not support spaces
167  tmp.Replace( wxT( " " ), wxT( "_" ) );
168 
169  if( m_name != tmp )
170  {
171  m_name = tmp;
172  SetModified();
173  }
174 
175  if( !aTestOtherPins )
176  return;
177 
178  if( GetParent() == NULL )
179  return;
180 
181  LIB_PINS pinList;
182  GetParent()->GetPins( pinList );
183 
184  for( size_t i = 0; i < pinList.size(); i++ )
185  {
186  if( ( pinList[i]->m_Flags & IS_LINKED ) == 0 || pinList[i]->m_name == m_name )
187  continue;
188 
189  pinList[i]->m_name = m_name;
190  SetModified();
191  }
192 }
193 
194 
195 void LIB_PIN::SetNameTextSize( int size, bool aTestOtherPins )
196 {
197  if( size != m_nameTextSize )
198  {
199  m_nameTextSize = size;
200  SetModified();
201  }
202 
203  if( !aTestOtherPins )
204  return;
205 
206  if( GetParent() == NULL )
207  return;
208 
209  LIB_PINS pinList;
210  GetParent()->GetPins( pinList );
211 
212  for( size_t i = 0; i < pinList.size(); i++ )
213  {
214  if( ( pinList[i]->m_Flags & IS_LINKED ) == 0 || pinList[i]->m_nameTextSize == size )
215  continue;
216 
217  pinList[i]->m_nameTextSize = size;
218  SetModified();
219  }
220 }
221 
222 
223 void LIB_PIN::SetNumber( const wxString& aNumber )
224 {
225  // Unlike SetName, others pin numbers marked by EnableEditMode() are
226  // not modified because each pin has its own number, so set number
227  // only for this.
228 
229  wxString tmp = ( aNumber.IsEmpty() ) ? wxT( "~" ) : aNumber;
230 
231  // pin number string does not support spaces
232  tmp.Replace( wxT( " " ), wxT( "_" ) );
233 
234  if( m_number != tmp )
235  {
236  m_number = tmp;
237  SetModified();
238  }
239 }
240 
241 
242 void LIB_PIN::SetNumberTextSize( int size, bool aTestOtherPins )
243 {
244  if( size != m_numTextSize )
245  {
246  m_numTextSize = size;
247  SetModified();
248  }
249 
250  if( !aTestOtherPins )
251  return;
252 
253  if( GetParent() == NULL )
254  return;
255 
256  LIB_PINS pinList;
257  GetParent()->GetPins( pinList );
258 
259  for( size_t i = 0; i < pinList.size(); i++ )
260  {
261  if( ( pinList[i]->m_Flags & IS_LINKED ) == 0 || pinList[i]->m_numTextSize == size )
262  continue;
263 
264  pinList[i]->m_numTextSize = size;
265  SetModified();
266  }
267 }
268 
269 
270 void LIB_PIN::SetOrientation( int orientation, bool aTestOtherPins )
271 {
272  if( m_orientation != orientation )
273  {
274  m_orientation = orientation;
275  SetModified();
276  }
277 
278  if( !aTestOtherPins )
279  return;
280 
281  if( GetParent() == NULL )
282  return;
283 
284  LIB_PINS pinList;
285  GetParent()->GetPins( pinList );
286 
287  for( size_t i = 0; i < pinList.size(); i++ )
288  {
289  if( ( pinList[i]->m_Flags & IS_LINKED ) == 0 ||
290  pinList[i]->m_orientation == orientation )
291  continue;
292 
293  pinList[i]->m_orientation = orientation;
294  SetModified();
295  }
296 }
297 
298 
300 {
301  assert( aShape >= 0 && aShape < int( PINSHAPE_COUNT ) );
302 
303  if( m_shape != aShape )
304  {
305  m_shape = aShape;
306  SetModified();
307  }
308 
309  if( GetParent() == NULL )
310  return;
311 
312  LIB_PINS pinList;
313  GetParent()->GetPins( pinList );
314 
315  for( size_t i = 0; i < pinList.size(); i++ )
316  {
317  if( ( pinList[i]->m_Flags & IS_LINKED ) == 0
318  || pinList[i]->m_Convert != m_Convert
319  || pinList[i]->m_shape == aShape )
320  continue;
321 
322  pinList[i]->m_shape = aShape;
323  SetModified();
324  }
325 }
326 
327 
328 void LIB_PIN::SetType( ELECTRICAL_PINTYPE aType, bool aTestOtherPins )
329 {
330  assert( aType >= 0 && aType < (int)PINTYPE_COUNT );
331 
332  if( aType < PIN_INPUT )
333  aType = PIN_INPUT;
334 
335  if( aType >= (int)PINTYPE_COUNT )
336  aType = PIN_NC;
337 
338  if( m_type != aType )
339  {
340  m_type = aType;
341  SetModified();
342  }
343 
344  if( !aTestOtherPins )
345  return;
346 
347  if( GetParent() == NULL )
348  return;
349 
350  LIB_PINS pinList;
351  GetParent()->GetPins( pinList );
352 
353  for( size_t i = 0; i < pinList.size(); i++ )
354  {
355  if( ( pinList[i]->m_Flags & IS_LINKED ) == 0 || pinList[i]->m_type == aType )
356  continue;
357 
358  pinList[i]->m_type = aType;
359  SetModified();
360  }
361 }
362 
363 
364 void LIB_PIN::SetLength( int length, bool aTestOtherPins )
365 {
366  if( m_length != length )
367  {
368  m_length = length;
369  SetModified();
370  }
371 
372  if( !aTestOtherPins )
373  return;
374 
375  if( GetParent() == NULL )
376  return;
377 
378  LIB_PINS pinList;
379  GetParent()->GetPins( pinList );
380 
381  for( size_t i = 0; i < pinList.size(); i++ )
382  {
383  if( ( pinList[i]->m_Flags & IS_LINKED ) == 0
384  || pinList[i]->m_Convert != m_Convert
385  || pinList[i]->m_length == length )
386  continue;
387 
388  pinList[i]->m_length = length;
389  SetModified();
390  }
391 }
392 
393 
394 void LIB_PIN::SetPinPosition( wxPoint aPosition )
395 {
396  if( m_position != aPosition )
397  {
398  m_position = aPosition;
399  SetModified();
400  }
401 
402  if( GetParent() == NULL )
403  return;
404 
405  LIB_PINS pinList;
406  GetParent()->GetPins( pinList );
407 
408  for( size_t i = 0; i < pinList.size(); i++ )
409  {
410  if( ( pinList[i]->m_Flags & IS_LINKED ) == 0
411  || pinList[i]->m_Convert != m_Convert
412  || pinList[i]->m_position == aPosition )
413  continue;
414 
415  pinList[i]->m_position = aPosition;
416  SetModified();
417  }
418 }
419 
420 
421 void LIB_PIN::SetPartNumber( int part )
422 {
423  if( m_Unit == part )
424  return;
425 
426  m_Unit = part;
427  SetModified();
428 
429  if( m_Unit == 0 )
430  {
431  LIB_PIN* pin;
432  LIB_PIN* tmp = GetParent()->GetNextPin();
433 
434  while( tmp != NULL )
435  {
436  pin = tmp;
437  tmp = GetParent()->GetNextPin( pin );
438 
439  if( pin->m_Flags == 0 || pin == this
440  || ( m_Convert && ( m_Convert != pin->m_Convert ) )
441  || ( m_position != pin->m_position )
442  || ( pin->m_orientation != m_orientation ) )
443  continue;
444 
445  GetParent()->RemoveDrawItem( (LIB_ITEM*) pin );
446  }
447  }
448 }
449 
450 
451 void LIB_PIN::SetConversion( int style )
452 {
453  if( m_Convert == style )
454  return;
455 
456  m_Convert = style;
457  SetFlags( IS_CHANGED );
458 
459  if( style == 0 )
460  {
461  LIB_PIN* pin;
462  LIB_PIN* tmp = GetParent()->GetNextPin();
463 
464  while( tmp != NULL )
465  {
466  pin = tmp;
467  tmp = GetParent()->GetNextPin( pin );
468 
469  if( ( pin->m_Flags & IS_LINKED ) == 0
470  || ( pin == this )
471  || ( m_Unit && ( m_Unit != pin->m_Unit ) )
472  || ( m_position != pin->m_position )
473  || ( pin->m_orientation != m_orientation ) )
474  continue;
475 
476  GetParent()->RemoveDrawItem( (LIB_ITEM*) pin );
477  }
478  }
479 }
480 
481 
482 void LIB_PIN::SetVisible( bool visible )
483 {
484  if( visible == IsVisible() )
485  return;
486 
487  if( visible )
489  else
491 
492  SetModified();
493 
494  if( GetParent() == NULL )
495  return;
496 
497  LIB_PINS pinList;
498  GetParent()->GetPins( pinList );
499 
500  for( size_t i = 0; i < pinList.size(); i++ )
501  {
502  if( ( pinList[i]->m_Flags & IS_LINKED ) == 0 || pinList[i]->IsVisible() == visible )
503  continue;
504 
505  if( visible )
506  pinList[i]->m_attributes &= ~PIN_INVISIBLE;
507  else
508  pinList[i]->m_attributes |= PIN_INVISIBLE;
509 
510  SetModified();
511  }
512 }
513 
514 
515 void LIB_PIN::EnableEditMode( bool aEnable, bool aEditPinByPin )
516 {
517  LIB_PINS pinList;
518 
519  if( GetParent() == NULL )
520  return;
521 
522  GetParent()->GetPins( pinList );
523 
524  for( size_t i = 0; i < pinList.size(); i++ )
525  {
526  if( pinList[i] == this )
527  continue;
528 
529  if( ( pinList[i]->m_position == m_position )
530  && ( pinList[i]->m_orientation == m_orientation )
531  && !IsNew() && !aEditPinByPin && aEnable )
532  {
533  pinList[i]->SetFlags( IS_LINKED | IN_EDIT );
534  }
535  else
536  pinList[i]->ClearFlags( IS_LINKED | IN_EDIT );
537  }
538 }
539 
540 
541 bool LIB_PIN::HitTest( const wxPoint& aPosition, int aAccuracy ) const
542 {
543  EDA_RECT rect = GetBoundingBox();
544 
545  return rect.Inflate( aAccuracy ).Contains( aPosition );
546 }
547 
548 
550 {
551  if( m_width > 0 )
552  return m_width;
553 
554  if( m_width == 0 )
555  return GetDefaultLineThickness();
556 
557  return 0;
558 }
559 
560 
561 void LIB_PIN::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, void* aData,
562  const TRANSFORM& aTransform )
563 {
564  // aData is used here as a boolean.
565  bool drawElectricalTypeName = (bool) aData;
566 
567  LIB_PART* Entry = GetParent();
568 
569  /* Calculate pin orient taking in account the component orientation. */
570  int orient = PinDrawOrient( aTransform );
571 
572  /* Calculate the pin position */
573  wxPoint pos1 = aTransform.TransformCoordinate( m_position ) + aOffset;
574 
575  // Invisible pins are only drawn on request.
576  if( !IsVisible() )
577  {
578  bool drawHidden = true;
579 
580  if( aPanel && aPanel->GetParent() )
581  {
582  EDA_DRAW_FRAME* frame = aPanel->GetParent();
583 
584  if( frame->IsType( FRAME_SCH ) )
585  drawHidden = static_cast<SCH_EDIT_FRAME*>( frame )->GetShowAllPins();
586  }
587 
588  if( !drawHidden )
589  return;
590  }
591 
592  DrawPinSymbol( aPanel, aDC, pos1, orient );
593 
594  DrawPinTexts( aPanel, aDC, pos1, orient, Entry->GetPinNameOffset(), Entry->ShowPinNumbers(),
595  Entry->ShowPinNames() );
596 
597  if( drawElectricalTypeName )
598  DrawPinElectricalTypeName( aPanel, aDC, pos1, orient );
599 }
600 
601 
602 void LIB_PIN::DrawPinSymbol( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPos, int aOrient )
603 {
604  int MapX1, MapY1, x1, y1;
605  int width = GetPenSize();
606  int posX = aPos.x, posY = aPos.y, len = m_length;
608 
609  EDA_RECT* clipbox = aPanel ? aPanel->GetClipBox() : NULL;
610 
611  MapX1 = MapY1 = 0;
612  x1 = posX;
613  y1 = posY;
614 
615  switch( aOrient )
616  {
617  case PIN_UP: y1 = posY - len; MapY1 = 1; break;
618  case PIN_DOWN: y1 = posY + len; MapY1 = -1; break;
619  case PIN_LEFT: x1 = posX - len; MapX1 = 1; break;
620  case PIN_RIGHT: x1 = posX + len; MapX1 = -1; break;
621  }
622 
624  {
625  const int radius = ExternalPinDecoSize( *this );
626  GRCircle( clipbox, aDC, MapX1 * radius + x1, MapY1 * radius + y1, radius, width, color );
627 
628  GRMoveTo( MapX1 * radius * 2 + x1, MapY1 * radius * 2 + y1 );
629  GRLineTo( clipbox, aDC, posX, posY, width, color );
630  }
631  else if( m_shape == PINSHAPE_FALLING_EDGE_CLOCK ) /* an alternative for Inverted Clock */
632  {
633  const int deco_size = InternalPinDecoSize( *this );
634  if( MapY1 == 0 ) /* MapX1 = +- 1 */
635  {
636  GRMoveTo( x1, y1 + deco_size );
637  GRLineTo( clipbox, aDC, x1 + MapX1 * deco_size * 2, y1, width, color );
638  GRLineTo( clipbox, aDC, x1, y1 - deco_size, width, color );
639  }
640  else /* MapX1 = 0 */
641  {
642  GRMoveTo( x1 + deco_size, y1 );
643  GRLineTo( clipbox, aDC, x1, y1 + MapY1 * deco_size * 2, width, color );
644  GRLineTo( clipbox, aDC, x1 - deco_size, y1, width, color );
645  }
646  GRMoveTo( MapX1 * deco_size * 2 + x1, MapY1 * deco_size * 2 + y1 );
647  GRLineTo( clipbox, aDC, posX, posY, width, color );
648  }
649  else
650  {
651  GRMoveTo( x1, y1 );
652  GRLineTo( clipbox, aDC, posX, posY, width, color );
653  }
654 
656  {
657  const int clock_size = InternalPinDecoSize( *this );
658  if( MapY1 == 0 ) /* MapX1 = +- 1 */
659  {
660  GRMoveTo( x1, y1 + clock_size );
661  GRLineTo( clipbox, aDC, x1 - MapX1 * clock_size * 2, y1, width, color );
662  GRLineTo( clipbox, aDC, x1, y1 - clock_size, width, color );
663  }
664  else /* MapX1 = 0 */
665  {
666  GRMoveTo( x1 + clock_size, y1 );
667  GRLineTo( clipbox, aDC, x1, y1 - MapY1 * clock_size * 2, width, color );
668  GRLineTo( clipbox, aDC, x1 - clock_size, y1, width, color );
669  }
670  }
671 
673  {
674  const int deco_size = ExternalPinDecoSize( *this );
675  if( MapY1 == 0 ) /* MapX1 = +- 1 */
676  {
677  GRMoveTo( x1 + MapX1 * deco_size * 2, y1 );
678  GRLineTo( clipbox, aDC, x1 + MapX1 * deco_size * 2, y1 - deco_size * 2, width, color );
679  GRLineTo( clipbox, aDC, x1, y1, width, color );
680  }
681  else /* MapX1 = 0 */
682  {
683  GRMoveTo( x1, y1 + MapY1 * deco_size * 2 );
684  GRLineTo( clipbox, aDC, x1 - deco_size * 2, y1 + MapY1 * deco_size * 2, width, color );
685  GRLineTo( clipbox, aDC, x1, y1, width, color );
686  }
687  }
688 
689 
690  if( m_shape == PINSHAPE_OUTPUT_LOW ) /* IEEE symbol "Active Low Output" */
691  {
692  const int deco_size = ExternalPinDecoSize( *this );
693  if( MapY1 == 0 ) /* MapX1 = +- 1 */
694  {
695  GRMoveTo( x1, y1 - deco_size * 2 );
696  GRLineTo( clipbox, aDC, x1 + MapX1 * deco_size * 2, y1, width, color );
697  }
698  else /* MapX1 = 0 */
699  {
700  GRMoveTo( x1 - deco_size * 2, y1 );
701  GRLineTo( clipbox, aDC, x1, y1 + MapY1 * deco_size * 2, width, color );
702  }
703  }
704  else if( m_shape == PINSHAPE_NONLOGIC ) /* NonLogic pin symbol */
705  {
706  const int deco_size = ExternalPinDecoSize( *this );
707  GRMoveTo( x1 - (MapX1 + MapY1) * deco_size, y1 - (MapY1 - MapX1) * deco_size );
708  GRLineTo( clipbox, aDC, x1 + (MapX1 + MapY1) * deco_size, y1 + (MapY1 - MapX1) * deco_size, width,
709  color );
710  GRMoveTo( x1 - (MapX1 - MapY1) * deco_size, y1 - (MapY1 + MapX1) * deco_size );
711  GRLineTo( clipbox, aDC, x1 + (MapX1 - MapY1) * deco_size, y1 + (MapY1 + MapX1) * deco_size, width,
712  color );
713  }
714 
715  if( m_type == PIN_NC ) // Draw a N.C. symbol
716  {
717  const int deco_size = TARGET_PIN_RADIUS;
718  GRLine( clipbox, aDC, posX - deco_size, posY - deco_size, posX + deco_size, posY + deco_size, width, color );
719  GRLine( clipbox, aDC, posX + deco_size, posY - deco_size, posX - deco_size, posY + deco_size, width, color );
720  }
721 }
722 
723 
724 void LIB_PIN::DrawPinTexts( EDA_DRAW_PANEL* panel, wxDC* DC, wxPoint& pin_pos, int orient,
725  int TextInside, bool DrawPinNum, bool DrawPinName )
726 {
727  if( !DrawPinName && !DrawPinNum )
728  return;
729 
730  int x, y;
731 
732  wxSize PinNameSize( m_nameTextSize, m_nameTextSize );
733  wxSize PinNumSize( m_numTextSize, m_numTextSize );
734  int nameLineWidth = Clamp_Text_PenSize( GetPenSize(), m_nameTextSize, false );
735  int numLineWidth = Clamp_Text_PenSize( GetPenSize(), m_numTextSize, false );
736  int name_offset = PIN_TEXT_MARGIN + ( nameLineWidth + GetDefaultLineThickness() ) / 2;
737  int num_offset = PIN_TEXT_MARGIN + ( numLineWidth + GetDefaultLineThickness() ) / 2;
738 
739  EDA_RECT* clipbox = panel? panel->GetClipBox() : NULL;
740 
741  /* Get the num and name colors */
744 
745  int x1 = pin_pos.x;
746  int y1 = pin_pos.y;
747 
748  switch( orient )
749  {
750  case PIN_UP: y1 -= m_length; break;
751  case PIN_DOWN: y1 += m_length; break;
752  case PIN_LEFT: x1 -= m_length; break;
753  case PIN_RIGHT: x1 += m_length; break;
754  }
755 
756  if( m_name.IsEmpty() )
757  DrawPinName = false;
758 
759  if( TextInside ) // Draw the text inside, but the pin numbers outside.
760  {
761  if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
762  {
763  // It is an horizontal line
764  if( DrawPinName )
765  {
766  if( orient == PIN_RIGHT )
767  {
768  x = x1 + TextInside;
769  DrawGraphicText( clipbox, DC, wxPoint( x, y1 ), NameColor,
770  m_name, TEXT_ANGLE_HORIZ, PinNameSize,
772  nameLineWidth, false, false );
773  }
774  else // Orient == PIN_LEFT
775  {
776  x = x1 - TextInside;
777  DrawGraphicText( clipbox, DC, wxPoint( x, y1 ), NameColor, m_name,
779  GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, false, false );
780  }
781  }
782 
783  if( DrawPinNum )
784  {
785  DrawGraphicText( clipbox, DC, wxPoint( (x1 + pin_pos.x) / 2, y1 - num_offset ),
786  NumColor, m_number, TEXT_ANGLE_HORIZ, PinNumSize,
788  false, false );
789  }
790  }
791  else /* Its a vertical line. */
792  {
793  // Text is drawn from bottom to top (i.e. to negative value for Y axis)
794  if( orient == PIN_DOWN )
795  {
796  y = y1 + TextInside;
797 
798  if( DrawPinName )
799  DrawGraphicText( clipbox, DC, wxPoint( x1, y ), NameColor, m_name,
801  GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, false, false );
802 
803  if( DrawPinNum )
804  DrawGraphicText( clipbox, DC, wxPoint( x1 - num_offset, (y1 + pin_pos.y) / 2 ),
805  NumColor, m_number, TEXT_ANGLE_VERT, PinNumSize,
807  numLineWidth, false, false );
808  }
809  else /* PIN_UP */
810  {
811  y = y1 - TextInside;
812 
813  if( DrawPinName )
814  DrawGraphicText( clipbox, DC, wxPoint( x1, y ), NameColor, m_name,
816  GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, false, false );
817 
818  if( DrawPinNum )
819  DrawGraphicText( clipbox, DC, wxPoint( x1 - num_offset, (y1 + pin_pos.y) / 2 ),
820  NumColor, m_number, TEXT_ANGLE_VERT, PinNumSize,
822  numLineWidth, false, false );
823  }
824  }
825  }
826  else /**** Draw num & text pin outside ****/
827  {
828  if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
829  {
830  /* Its an horizontal line. */
831  if( DrawPinName )
832  {
833  x = (x1 + pin_pos.x) / 2;
834  DrawGraphicText( clipbox, DC, wxPoint( x, y1 - name_offset ), NameColor, m_name,
836  GR_TEXT_VJUSTIFY_BOTTOM, nameLineWidth, false, false );
837  }
838  if( DrawPinNum )
839  {
840  x = (x1 + pin_pos.x) / 2;
841  DrawGraphicText( clipbox, DC, wxPoint( x, y1 + num_offset ), NumColor, m_number,
843  GR_TEXT_VJUSTIFY_TOP, numLineWidth, false, false );
844  }
845  }
846  else /* Its a vertical line. */
847  {
848  if( DrawPinName )
849  {
850  y = (y1 + pin_pos.y) / 2;
851  DrawGraphicText( clipbox, DC, wxPoint( x1 - name_offset, y ), NameColor, m_name,
853  GR_TEXT_VJUSTIFY_BOTTOM, nameLineWidth, false, false );
854  }
855 
856  if( DrawPinNum )
857  {
858  DrawGraphicText( clipbox, DC, wxPoint( x1 + num_offset, (y1 + pin_pos.y) / 2 ),
859  NumColor, m_number, TEXT_ANGLE_VERT, PinNumSize,
861  false, false );
862  }
863  }
864  }
865 }
866 
867 
868 
869 void LIB_PIN::DrawPinElectricalTypeName( EDA_DRAW_PANEL* aPanel, wxDC* aDC, wxPoint& aPosition,
870  int aOrientation )
871 {
872  wxString typeName = GetElectricalTypeName();
873 
874  // Use a reasonable (small) size to draw the text
875  int textSize = (m_nameTextSize*3)/4;
876 
877  #define ETXT_MAX_SIZE Millimeter2iu(0.7 )
878  if( textSize > ETXT_MAX_SIZE )
879  textSize = ETXT_MAX_SIZE;
880 
881  // Use a reasonable pen size to draw the text
882  int pensize = textSize/6;
883 
884  // Get a suitable color
886 
887  wxPoint txtpos = aPosition;
888  int offset = Millimeter2iu( 0.4 );
890  int orient = TEXT_ANGLE_HORIZ;
891 
892  switch( aOrientation )
893  {
894  case PIN_UP:
895  txtpos.y += offset;
896  orient = TEXT_ANGLE_VERT;
897  hjustify = GR_TEXT_HJUSTIFY_RIGHT;
898  break;
899 
900  case PIN_DOWN:
901  txtpos.y -= offset;
902  orient = TEXT_ANGLE_VERT;
903  break;
904 
905  case PIN_LEFT:
906  txtpos.x += offset;
907  break;
908 
909  case PIN_RIGHT:
910  txtpos.x -= offset;
911  hjustify = GR_TEXT_HJUSTIFY_RIGHT;
912  break;
913  }
914 
915  EDA_RECT* clipbox = aPanel ? aPanel->GetClipBox() : NULL;
916 
917  DrawGraphicText( clipbox, aDC, txtpos, color, typeName, orient, wxSize( textSize, textSize ),
918  hjustify, GR_TEXT_VJUSTIFY_CENTER, pensize, false, false );
919 }
920 
921 
922 void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrientation )
923 {
924  int MapX1, MapY1, x1, y1;
926 
927  aPlotter->SetColor( color );
928  aPlotter->SetCurrentLineWidth( GetPenSize() );
929 
930  MapX1 = MapY1 = 0;
931  x1 = aPosition.x; y1 = aPosition.y;
932 
933  switch( aOrientation )
934  {
935  case PIN_UP: y1 = aPosition.y - m_length; MapY1 = 1; break;
936  case PIN_DOWN: y1 = aPosition.y + m_length; MapY1 = -1; break;
937  case PIN_LEFT: x1 = aPosition.x - m_length; MapX1 = 1; break;
938  case PIN_RIGHT: x1 = aPosition.x + m_length; MapX1 = -1; break;
939  }
940 
942  {
943  const int radius = ExternalPinDecoSize( *this );
944  aPlotter->Circle( wxPoint( MapX1 * radius + x1, MapY1 * radius + y1 ),
945  radius * 2, NO_FILL, GetPenSize() );
946 
947  aPlotter->MoveTo( wxPoint( MapX1 * radius * 2 + x1, MapY1 * radius * 2 + y1 ) );
948  aPlotter->FinishTo( aPosition );
949  }
951  {
952  const int deco_size = InternalPinDecoSize( *this );
953  if( MapY1 == 0 ) /* MapX1 = +- 1 */
954  {
955  aPlotter->MoveTo( wxPoint( x1, y1 + deco_size ) );
956  aPlotter->LineTo( wxPoint( x1 + MapX1 * deco_size * 2, y1 ) );
957  aPlotter->FinishTo( wxPoint( x1, y1 - deco_size ) );
958  }
959  else /* MapX1 = 0 */
960  {
961  aPlotter->MoveTo( wxPoint( x1 + deco_size, y1 ) );
962  aPlotter->LineTo( wxPoint( x1, y1 + MapY1 * deco_size * 2 ) );
963  aPlotter->FinishTo( wxPoint( x1 - deco_size, y1 ) );
964  }
965 
966  aPlotter->MoveTo( wxPoint( MapX1 * deco_size * 2 + x1, MapY1 * deco_size * 2 + y1 ) );
967  aPlotter->FinishTo( aPosition );
968  }
969  else
970  {
971  aPlotter->MoveTo( wxPoint( x1, y1 ) );
972  aPlotter->FinishTo( aPosition );
973  }
974 
977  {
978  const int deco_size = InternalPinDecoSize( *this );
979  if( MapY1 == 0 ) /* MapX1 = +- 1 */
980  {
981  aPlotter->MoveTo( wxPoint( x1, y1 + deco_size ) );
982  aPlotter->LineTo( wxPoint( x1 - MapX1 * deco_size * 2, y1 ) );
983  aPlotter->FinishTo( wxPoint( x1, y1 - deco_size ) );
984  }
985  else /* MapX1 = 0 */
986  {
987  aPlotter->MoveTo( wxPoint( x1 + deco_size, y1 ) );
988  aPlotter->LineTo( wxPoint( x1, y1 - MapY1 * deco_size * 2 ) );
989  aPlotter->FinishTo( wxPoint( x1 - deco_size, y1 ) );
990  }
991  }
992 
993  if( m_shape == PINSHAPE_INPUT_LOW || m_shape == PINSHAPE_CLOCK_LOW ) /* IEEE symbol "Active Low Input" */
994  {
995  const int deco_size = ExternalPinDecoSize( *this );
996 
997  if( MapY1 == 0 ) /* MapX1 = +- 1 */
998  {
999  aPlotter->MoveTo( wxPoint( x1 + MapX1 * deco_size * 2, y1 ) );
1000  aPlotter->LineTo( wxPoint( x1 + MapX1 * deco_size * 2, y1 - deco_size * 2 ) );
1001  aPlotter->FinishTo( wxPoint( x1, y1 ) );
1002  }
1003  else /* MapX1 = 0 */
1004  {
1005  aPlotter->MoveTo( wxPoint( x1, y1 + MapY1 * deco_size * 2 ) );
1006  aPlotter->LineTo( wxPoint( x1 - deco_size * 2, y1 + MapY1 * deco_size * 2 ) );
1007  aPlotter->FinishTo( wxPoint( x1, y1 ) );
1008  }
1009  }
1010 
1011 
1012  if( m_shape == PINSHAPE_OUTPUT_LOW ) /* IEEE symbol "Active Low Output" */
1013  {
1014  const int symbol_size = ExternalPinDecoSize( *this );
1015 
1016  if( MapY1 == 0 ) /* MapX1 = +- 1 */
1017  {
1018  aPlotter->MoveTo( wxPoint( x1, y1 - symbol_size * 2 ) );
1019  aPlotter->FinishTo( wxPoint( x1 + MapX1 * symbol_size * 2, y1 ) );
1020  }
1021  else /* MapX1 = 0 */
1022  {
1023  aPlotter->MoveTo( wxPoint( x1 - symbol_size * 2, y1 ) );
1024  aPlotter->FinishTo( wxPoint( x1, y1 + MapY1 * symbol_size * 2 ) );
1025  }
1026  }
1027  else if( m_shape == PINSHAPE_NONLOGIC ) /* NonLogic pin symbol */
1028  {
1029  const int deco_size = ExternalPinDecoSize( *this );
1030  aPlotter->MoveTo( wxPoint( x1 - (MapX1 + MapY1) * deco_size, y1 - (MapY1 - MapX1) * deco_size ) );
1031  aPlotter->FinishTo( wxPoint( x1 + (MapX1 + MapY1) * deco_size, y1 + (MapY1 - MapX1) * deco_size ) );
1032  aPlotter->MoveTo( wxPoint( x1 - (MapX1 - MapY1) * deco_size, y1 - (MapY1 + MapX1) * deco_size ) );
1033  aPlotter->FinishTo( wxPoint( x1 + (MapX1 - MapY1) * deco_size, y1 + (MapY1 + MapX1) * deco_size ) );
1034  }
1035  if( m_type == PIN_NC ) // Draw a N.C. symbol
1036  {
1037  const int deco_size = TARGET_PIN_RADIUS;
1038  const int ex1 = aPosition.x;
1039  const int ey1 = aPosition.y;
1040  aPlotter->MoveTo( wxPoint( ex1 - deco_size, ey1 - deco_size ) );
1041  aPlotter->FinishTo( wxPoint( ex1 + deco_size, ey1 + deco_size ) );
1042  aPlotter->MoveTo( wxPoint( ex1 + deco_size, ey1 - deco_size ) );
1043  aPlotter->FinishTo( wxPoint( ex1 - deco_size, ey1 + deco_size ) );
1044  }
1045 }
1046 
1047 
1048 void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
1049  int TextInside, bool DrawPinNum,
1050  bool DrawPinName, int aWidth )
1051 {
1052  if( m_name.IsEmpty() || m_name == wxT( "~" ) )
1053  DrawPinName = false;
1054 
1055  if( m_number.IsEmpty() )
1056  DrawPinNum = false;
1057 
1058  if( !DrawPinNum && !DrawPinName )
1059  return;
1060 
1061  int x, y;
1062  wxSize PinNameSize = wxSize( m_nameTextSize, m_nameTextSize );
1063  wxSize PinNumSize = wxSize( m_numTextSize, m_numTextSize );
1064 
1065  int nameLineWidth = GetPenSize();
1066  nameLineWidth = Clamp_Text_PenSize( nameLineWidth, m_nameTextSize, false );
1067  int numLineWidth = GetPenSize();
1068  numLineWidth = Clamp_Text_PenSize( numLineWidth, m_numTextSize, false );
1069 
1070  int name_offset = PIN_TEXT_MARGIN +
1071  ( nameLineWidth + GetDefaultLineThickness() ) / 2;
1072  int num_offset = PIN_TEXT_MARGIN +
1073  ( numLineWidth + GetDefaultLineThickness() ) / 2;
1074 
1075  /* Get the num and name colors */
1076  COLOR4D NameColor = GetLayerColor( LAYER_PINNAM );
1077  COLOR4D NumColor = GetLayerColor( LAYER_PINNUM );
1078 
1079  int x1 = pin_pos.x;
1080  int y1 = pin_pos.y;
1081 
1082  switch( orient )
1083  {
1084  case PIN_UP: y1 -= m_length; break;
1085  case PIN_DOWN: y1 += m_length; break;
1086  case PIN_LEFT: x1 -= m_length; break;
1087  case PIN_RIGHT: x1 += m_length; break;
1088  }
1089 
1090  /* Draw the text inside, but the pin numbers outside. */
1091  if( TextInside )
1092  {
1093  if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) ) /* Its an horizontal line. */
1094  {
1095  if( DrawPinName )
1096  {
1097  if( orient == PIN_RIGHT )
1098  {
1099  x = x1 + TextInside;
1100  plotter->Text( wxPoint( x, y1 ), NameColor,
1101  m_name,
1103  PinNameSize,
1106  aWidth, false, false );
1107  }
1108  else // orient == PIN_LEFT
1109  {
1110  x = x1 - TextInside;
1111 
1112  if( DrawPinName )
1113  plotter->Text( wxPoint( x, y1 ),
1114  NameColor, m_name, TEXT_ANGLE_HORIZ,
1115  PinNameSize,
1118  aWidth, false, false );
1119  }
1120  }
1121  if( DrawPinNum )
1122  {
1123  plotter->Text( wxPoint( (x1 + pin_pos.x) / 2,
1124  y1 - num_offset ),
1125  NumColor, m_number,
1126  TEXT_ANGLE_HORIZ, PinNumSize,
1129  aWidth, false, false );
1130  }
1131  }
1132  else /* Its a vertical line. */
1133  {
1134  if( orient == PIN_DOWN )
1135  {
1136  y = y1 + TextInside;
1137 
1138  if( DrawPinName )
1139  plotter->Text( wxPoint( x1, y ), NameColor,
1140  m_name,
1141  TEXT_ANGLE_VERT, PinNameSize,
1144  aWidth, false, false );
1145 
1146  if( DrawPinNum )
1147  {
1148  plotter->Text( wxPoint( x1 - num_offset,
1149  (y1 + pin_pos.y) / 2 ),
1150  NumColor, m_number,
1151  TEXT_ANGLE_VERT, PinNumSize,
1154  aWidth, false, false );
1155  }
1156  }
1157  else /* PIN_UP */
1158  {
1159  y = y1 - TextInside;
1160 
1161  if( DrawPinName )
1162  plotter->Text( wxPoint( x1, y ), NameColor,
1163  m_name,
1164  TEXT_ANGLE_VERT, PinNameSize,
1167  aWidth, false, false );
1168 
1169  if( DrawPinNum )
1170  {
1171  plotter->Text( wxPoint( x1 - num_offset,
1172  (y1 + pin_pos.y) / 2 ),
1173  NumColor, m_number,
1174  TEXT_ANGLE_VERT, PinNumSize,
1177  aWidth, false, false );
1178  }
1179  }
1180  }
1181  }
1182  else /* Draw num & text pin outside */
1183  {
1184  if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
1185  {
1186  /* Its an horizontal line. */
1187  if( DrawPinName )
1188  {
1189  x = (x1 + pin_pos.x) / 2;
1190  plotter->Text( wxPoint( x, y1 - name_offset ),
1191  NameColor, m_name,
1192  TEXT_ANGLE_HORIZ, PinNameSize,
1195  aWidth, false, false );
1196  }
1197 
1198  if( DrawPinNum )
1199  {
1200  x = ( x1 + pin_pos.x ) / 2;
1201  plotter->Text( wxPoint( x, y1 + num_offset ),
1202  NumColor, m_number,
1203  TEXT_ANGLE_HORIZ, PinNumSize,
1206  aWidth, false, false );
1207  }
1208  }
1209  else /* Its a vertical line. */
1210  {
1211  if( DrawPinName )
1212  {
1213  y = ( y1 + pin_pos.y ) / 2;
1214  plotter->Text( wxPoint( x1 - name_offset, y ),
1215  NameColor, m_name,
1216  TEXT_ANGLE_VERT, PinNameSize,
1219  aWidth, false, false );
1220  }
1221 
1222  if( DrawPinNum )
1223  {
1224  plotter->Text( wxPoint( x1 + num_offset,
1225  ( y1 + pin_pos.y ) / 2 ),
1226  NumColor, m_number,
1227  TEXT_ANGLE_VERT, PinNumSize,
1230  aWidth, false, false );
1231  }
1232  }
1233  }
1234 }
1235 
1236 
1237 wxPoint LIB_PIN::PinEndPoint() const
1238 {
1239  wxPoint pos = m_position;
1240 
1241  switch( m_orientation )
1242  {
1243  case PIN_UP: pos.y += m_length; break;
1244  case PIN_DOWN: pos.y -= m_length; break;
1245  case PIN_LEFT: pos.x -= m_length; break;
1246  case PIN_RIGHT: pos.x += m_length; break;
1247  }
1248 
1249  return pos;
1250 }
1251 
1252 
1253 int LIB_PIN::PinDrawOrient( const TRANSFORM& aTransform ) const
1254 {
1255  int orient;
1256  wxPoint end; // position of pin end starting at 0,0 according to its orientation, length = 1
1257 
1258  switch( m_orientation )
1259  {
1260  case PIN_UP: end.y = 1; break;
1261  case PIN_DOWN: end.y = -1; break;
1262  case PIN_LEFT: end.x = -1; break;
1263  case PIN_RIGHT: end.x = 1; break;
1264  }
1265 
1266  // = pos of end point, according to the component orientation
1267  end = aTransform.TransformCoordinate( end );
1268  orient = PIN_UP;
1269 
1270  if( end.x == 0 )
1271  {
1272  if( end.y > 0 )
1273  orient = PIN_DOWN;
1274  }
1275  else
1276  {
1277  orient = PIN_RIGHT;
1278 
1279  if( end.x < 0 )
1280  orient = PIN_LEFT;
1281  }
1282 
1283  return orient;
1284 }
1285 
1286 
1288 {
1289  return new LIB_PIN( *this );
1290 }
1291 
1292 
1293 int LIB_PIN::compare( const LIB_ITEM& other ) const
1294 {
1295  wxASSERT( other.Type() == LIB_PIN_T );
1296 
1297  const LIB_PIN* tmp = (LIB_PIN*) &other;
1298 
1299  if( m_number != tmp->m_number )
1300  return m_number.Cmp( tmp->m_number );
1301 
1302  int result = m_name.CmpNoCase( tmp->m_name );
1303 
1304  if( result != 0 )
1305  return result;
1306 
1307  if( m_position.x != tmp->m_position.x )
1308  return m_position.x - tmp->m_position.x;
1309 
1310  if( m_position.y != tmp->m_position.y )
1311  return m_position.y - tmp->m_position.y;
1312 
1313  return 0;
1314 }
1315 
1316 
1317 void LIB_PIN::Offset( const wxPoint& aOffset )
1318 {
1319  m_position += aOffset;
1320 }
1321 
1322 
1323 bool LIB_PIN::Inside( EDA_RECT& rect ) const
1324 {
1325  wxPoint end = PinEndPoint();
1326 
1327  return rect.Contains( m_position.x, -m_position.y ) || rect.Contains( end.x, -end.y );
1328 }
1329 
1330 
1331 void LIB_PIN::MoveTo( const wxPoint& newPosition )
1332 {
1333  if( m_position != newPosition )
1334  {
1335  m_position = newPosition;
1336  SetModified();
1337  }
1338 }
1339 
1340 
1341 void LIB_PIN::MirrorHorizontal( const wxPoint& center )
1342 {
1343  m_position.x -= center.x;
1344  m_position.x *= -1;
1345  m_position.x += center.x;
1346 
1347  if( m_orientation == PIN_RIGHT )
1349  else if( m_orientation == PIN_LEFT )
1351 }
1352 
1353 void LIB_PIN::MirrorVertical( const wxPoint& center )
1354 {
1355  m_position.y -= center.y;
1356  m_position.y *= -1;
1357  m_position.y += center.y;
1358 
1359  if( m_orientation == PIN_UP )
1361  else if( m_orientation == PIN_DOWN )
1363 }
1364 
1365 void LIB_PIN::Rotate( const wxPoint& center, bool aRotateCCW )
1366 {
1367  int rot_angle = aRotateCCW ? -900 : 900;
1368 
1369  RotatePoint( &m_position, center, rot_angle );
1370 
1371  if( aRotateCCW )
1372  {
1373  switch( m_orientation )
1374  {
1375  case PIN_RIGHT: m_orientation = PIN_UP; break;
1376  case PIN_UP: m_orientation = PIN_LEFT; break;
1377  case PIN_LEFT: m_orientation = PIN_DOWN; break;
1378  case PIN_DOWN: m_orientation = PIN_RIGHT; break;
1379  }
1380  }
1381  else
1382  {
1383  switch( m_orientation )
1384  {
1385  case PIN_RIGHT: m_orientation = PIN_DOWN; break;
1386  case PIN_UP: m_orientation = PIN_RIGHT; break;
1387  case PIN_LEFT: m_orientation = PIN_UP; break;
1388  case PIN_DOWN: m_orientation = PIN_LEFT; break;
1389  }
1390  }
1391 }
1392 
1393 
1394 void LIB_PIN::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
1395  const TRANSFORM& aTransform )
1396 {
1397  if( ! IsVisible() )
1398  return;
1399 
1400  int orient = PinDrawOrient( aTransform );
1401 
1402  wxPoint pos = aTransform.TransformCoordinate( m_position ) + offset;
1403 
1404  PlotSymbol( plotter, pos, orient );
1405  PlotPinTexts( plotter, pos, orient, GetParent()->GetPinNameOffset(),
1406  GetParent()->ShowPinNumbers(), GetParent()->ShowPinNames(), GetPenSize() );
1407 }
1408 
1409 
1410 void LIB_PIN::SetWidth( int aWidth )
1411 {
1412  if( m_width != aWidth )
1413  {
1414  m_width = aWidth;
1415  SetModified();
1416  }
1417 }
1418 
1419 
1421 {
1422  wxString text = m_number.IsEmpty() ? wxT( "?" ) : m_number;
1423 
1424  LIB_ITEM::GetMsgPanelInfo( aUnits, aList );
1425 
1426  aList.push_back( MSG_PANEL_ITEM( _( "Name" ), m_name, DARKCYAN ) );
1427  aList.push_back( MSG_PANEL_ITEM( _( "Number" ), text, DARKCYAN ) );
1428  aList.push_back( MSG_PANEL_ITEM( _( "Type" ), GetText( m_type ), RED ) );
1429 
1430  text = GetText( m_shape );
1431  aList.push_back( MSG_PANEL_ITEM( _( "Style" ), text, BLUE ) );
1432 
1433  text = IsVisible() ? _( "Yes" ) : _( "No" );
1434  aList.push_back( MSG_PANEL_ITEM( _( "Visible" ), text, DARKGREEN ) );
1435 
1436  // Display pin length
1437  text = StringFromValue( aUnits, m_length, true );
1438  aList.push_back( MSG_PANEL_ITEM( _( "Length" ), text, MAGENTA ) );
1439 
1441  aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), text, DARKMAGENTA ) );
1442 }
1443 
1445 {
1446  getMsgPanelInfoBase( aUnits, aList );
1447 
1448  wxString text;
1449  wxPoint pinpos = GetPosition();
1450  pinpos.y = -pinpos.y; // Display coord are top to bottom
1451  // lib items coord are bottom to top
1452 
1453  text = MessageTextFromValue( aUnits, pinpos.x, true );
1454  aList.push_back( MSG_PANEL_ITEM( _( "Pos X" ), text, DARKMAGENTA ) );
1455 
1456  text = MessageTextFromValue( aUnits, pinpos.y, true );
1457  aList.push_back( MSG_PANEL_ITEM( _( "Pos Y" ), text, DARKMAGENTA ) );
1458 }
1459 
1460 void LIB_PIN::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList,
1461  SCH_COMPONENT* aComponent )
1462 {
1463  getMsgPanelInfoBase( aUnits, aList );
1464 
1465  if( !aComponent )
1466  return;
1467 
1468  wxString text;
1469  wxPoint pinpos = aComponent->GetTransform().TransformCoordinate( GetPosition() )
1470  + aComponent->GetPosition();
1471 
1472  text = MessageTextFromValue( aUnits, pinpos.x, true );
1473  aList.push_back( MSG_PANEL_ITEM( _( "Pos X" ), text, DARKMAGENTA ) );
1474 
1475  text = MessageTextFromValue( aUnits, pinpos.y, true );
1476  aList.push_back( MSG_PANEL_ITEM( _( "Pos Y" ), text, DARKMAGENTA ) );
1477 
1478  aList.push_back( MSG_PANEL_ITEM( aComponent->GetField( REFERENCE )->GetShownText(),
1479  aComponent->GetField( VALUE )->GetShownText(), DARKCYAN ) );
1480 
1481 #if defined(DEBUG)
1482 
1483  auto conn = aComponent->GetConnectionForPin( this, *g_CurrentSheet );
1484 
1485  if( conn )
1486  conn->AppendDebugInfoToMsgPanel( aList );
1487 
1488 #endif
1489 }
1490 
1491 const EDA_RECT LIB_PIN::GetBoundingBox( bool aIncludeInvisibles ) const
1492 {
1493  LIB_PART* entry = (LIB_PART* ) m_Parent;
1494  EDA_RECT bbox;
1495  wxPoint begin;
1496  wxPoint end;
1497  int nameTextOffset = 0;
1498  bool showName = !m_name.IsEmpty() && (m_name != wxT( "~" ));
1499  bool showNum = !m_number.IsEmpty();
1500  int minsizeV = TARGET_PIN_RADIUS;
1501 
1502  if( !aIncludeInvisibles && !IsVisible() )
1503  showName = false;
1504 
1505  if( entry )
1506  {
1507  if( entry->ShowPinNames() )
1508  nameTextOffset = entry->GetPinNameOffset();
1509  else
1510  showName = false;
1511 
1512  showNum = entry->ShowPinNumbers();
1513  }
1514 
1515  // First, calculate boundary box corners position
1516  int numberTextLength = showNum ? m_numTextSize * m_number.Len() : 0;
1517 
1518  // Actual text height is bigger than text size
1519  int numberTextHeight = showNum ? KiROUND( m_numTextSize * 1.1 ) : 0;
1520 
1522  minsizeV = std::max( TARGET_PIN_RADIUS, ExternalPinDecoSize( *this ) );
1523 
1524  // calculate top left corner position
1525  // for the default pin orientation (PIN_RIGHT)
1526  begin.y = std::max( minsizeV, numberTextHeight + PIN_TEXT_MARGIN );
1527  begin.x = std::min( -TARGET_PIN_RADIUS, m_length - (numberTextLength / 2) );
1528 
1529  // calculate bottom right corner position and adjust top left corner position
1530  int nameTextLength = 0;
1531  int nameTextHeight = 0;
1532 
1533  if( showName )
1534  {
1535  int length = m_name.Len();
1536 
1537  // Don't count the line over text symbol.
1538  if( m_name.Left( 1 ) == wxT( "~" ) )
1539  length -= 1;
1540 
1541  nameTextLength = ( m_nameTextSize * length ) + nameTextOffset;
1542 
1543  // Actual text height are bigger than text size
1544  nameTextHeight = KiROUND( m_nameTextSize * 1.1 ) + PIN_TEXT_MARGIN;
1545  }
1546 
1547  if( nameTextOffset ) // for values > 0, pin name is inside the body
1548  {
1549  end.x = m_length + nameTextLength;
1550  end.y = std::min( -minsizeV, -nameTextHeight / 2 );
1551  }
1552  else // if value == 0:
1553  // pin name is outside the body, and above the pin line
1554  // pin num is below the pin line
1555  {
1556  end.x = std::max(m_length, nameTextLength);
1557  end.y = -begin.y;
1558  begin.y = std::max( minsizeV, nameTextHeight );
1559  }
1560 
1561  // Now, calculate boundary box corners position for the actual pin orientation
1562  int orient = PinDrawOrient( DefaultTransform );
1563 
1564  /* Calculate the pin position */
1565  switch( orient )
1566  {
1567  case PIN_UP:
1568  // Pin is rotated and texts positions are mirrored
1569  RotatePoint( &begin, wxPoint( 0, 0 ), -900 );
1570  RotatePoint( &end, wxPoint( 0, 0 ), -900 );
1571  break;
1572 
1573  case PIN_DOWN:
1574  RotatePoint( &begin, wxPoint( 0, 0 ), 900 );
1575  RotatePoint( &end, wxPoint( 0, 0 ), 900 );
1576  begin.x = -begin.x;
1577  end.x = -end.x;
1578  break;
1579 
1580  case PIN_LEFT:
1581  begin.x = -begin.x;
1582  end.x = -end.x;
1583  break;
1584 
1585  case PIN_RIGHT:
1586  break;
1587  }
1588 
1589  begin += m_position;
1590  end += m_position;
1591 
1592  bbox.SetOrigin( begin );
1593  bbox.SetEnd( end );
1594  bbox.Normalize();
1595  bbox.Inflate( ( GetPenSize() / 2 ) + 1 );
1596 
1597  // Draw Y axis is reversed in schematic:
1598  bbox.RevertYAxis();
1599 
1600  return bbox;
1601 }
1602 
1603 
1604 wxArrayString LIB_PIN::GetOrientationNames( void )
1605 {
1606  wxArrayString tmp;
1607 
1608  for( unsigned ii = 0; ii < PIN_ORIENTATION_CNT; ii++ )
1609  tmp.Add( getPinOrientationName( ii ) );
1610 
1611  return tmp;
1612 }
1613 
1614 
1616 {
1617  if( index >= 0 && index < (int) PIN_ORIENTATION_CNT )
1618  return pin_orientation_codes[ index ];
1619 
1620  return PIN_RIGHT;
1621 }
1622 
1623 
1625 {
1626  size_t i;
1627 
1628  for( i = 0; i < PIN_ORIENTATION_CNT; i++ )
1629  {
1630  if( pin_orientation_codes[i] == code )
1631  return (int) i;
1632  }
1633 
1634  return wxNOT_FOUND;
1635 }
1636 
1637 
1639 {
1640  int orient = PIN_RIGHT;
1641 
1642  switch( GetOrientation() )
1643  {
1644  case PIN_UP: orient = PIN_LEFT; break;
1645  case PIN_DOWN: orient = PIN_RIGHT; break;
1646  case PIN_LEFT: orient = PIN_DOWN; break;
1647  case PIN_RIGHT: orient = PIN_UP; break;
1648  }
1649 
1650  // Set the new orientation
1651  SetOrientation( orient );
1652 }
1653 
1654 
1656 {
1657  return iconsPinsOrientations;
1658 }
1659 
1660 
1661 BITMAP_DEF LIB_PIN::GetMenuImage() const
1662 {
1663  return GetBitmap( m_type );
1664 }
1665 
1666 
1667 wxString LIB_PIN::GetSelectMenuText( EDA_UNITS_T aUnits ) const
1668 {
1669  return wxString::Format( _( "Pin %s, %s, %s" ),
1670  m_number,
1672  GetText( m_shape ));
1673 }
1674 
1675 
1676 bool LIB_PIN::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation )
1677 {
1678  wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText( MILLIMETRES ) );
1679 
1680  // Note: this will have to be modified if we add find and replace capability to the
1681  // compoment library editor. Otherwise, you wont be able to replace pin text.
1682  if( !( aSearchData.GetFlags() & FR_SEARCH_ALL_PINS )
1683  || ( aSearchData.GetFlags() & FR_SEARCH_REPLACE ) )
1684  return false;
1685 
1686  wxLogTrace( traceFindItem, wxT( " child item " ) + GetSelectMenuText( MILLIMETRES ) );
1687 
1688  if( EDA_ITEM::Matches( GetName(), aSearchData ) || EDA_ITEM::Matches( m_number, aSearchData ) )
1689  {
1690  if( aFindLocation )
1691  *aFindLocation = GetBoundingBox().Centre();
1692 
1693  return true;
1694  }
1695 
1696  return false;
1697 }
1698 
1699 
1700 #if defined(DEBUG)
1701 
1702 void LIB_PIN::Show( int nestLevel, std::ostream& os ) const
1703 {
1704  NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
1705  << " num=\"" << m_number.mb_str()
1706  << '"' << "/>\n";
1707 
1708 // NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
1709 }
1710 
1711 #endif
1712 
1713 void LIB_PIN::CalcEdit( const wxPoint& aPosition )
1714 {
1715  if( IsMoving() )
1716  {
1717  DBG(printf("MOVEPIN\n");)
1718  MoveTo( aPosition );
1719  }
1720 }
Definition: colors.h:57
#define TEXT_ANGLE_HORIZ
void FinishTo(const wxPoint &pos)
Definition: plotter.h:251
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
Definition: base_struct.h:111
wxString GetClass() const override
Function GetClass returns the class name.
Definition: lib_pin.h:99
bool Matches(wxFindReplaceData &aSearchData, void *aAuxData, wxPoint *aFindLocation) override
Function Matches compares the item against the search criteria in aSearchData.
Definition: lib_pin.cpp:1676
int compare(const LIB_ITEM &aOther) const override
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_pin.cpp:1293
void GetMsgPanelInfo(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
void SetModified()
int m_nameTextSize
Pin num and Pin name sizes.
Definition: lib_pin.h:77
void SetLength(int aLength, bool aTestOtherPins=true)
Set the pin length.
Definition: lib_pin.cpp:364
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: lib_pin.cpp:1287
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Function Clamp_Text_PenSize As a rule, pen width should not be >1/4em, otherwise the character will b...
EDA_ITEM * m_Parent
Linked list: Link (parent struct)
Definition: base_struct.h:174
#define IN_EDIT
Item currently edited.
Definition: base_struct.h:112
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:63
wxPoint PinEndPoint() const
Definition: lib_pin.cpp:1237
static int ExternalPinDecoSize(const LIB_PIN &aPin)
Utility for getting the size of the 'external' pin decorators (as a radius)
Definition: lib_pin.cpp:143
GRAPHIC_PINSHAPE m_shape
Shape drawn around pin.
Definition: lib_pin.h:70
int GetPinNameOffset()
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:118
#define ETXT_MAX_SIZE
#define TEXT_ANGLE_VERT
static const wxString getPinOrientationName(unsigned aPinOrientationCode)
Definition: lib_pin.cpp:109
static int GetOrientationIndex(int aCode)
Get the index of the orientation code.
Definition: lib_pin.cpp:1624
Implementation of conversion functions that require both schematic and board internal units.
int m_numTextSize
Definition: lib_pin.h:76
static wxArrayString GetOrientationNames()
Get a list of pin orientation names.
Definition: lib_pin.cpp:1604
int GetOrientation() const
Definition: lib_pin.h:205
virtual void SetColor(COLOR4D color)=0
LIB_PART * GetParent() const
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: lib_pin.cpp:1661
void SetShape(GRAPHIC_PINSHAPE aShape)
Set the shape of the pin to aShape.
Definition: lib_pin.cpp:299
Definition: colors.h:61
bool IsMoving() const
Definition: base_struct.h:224
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData, wxPoint *aFindLocation)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:458
int color
Definition: DXF_plotter.cpp:62
int GetDefaultLineThickness()
Default line thickness used to draw/plot items having a default thickness line value (i....
static int GetDefaultPinLength()
void SetName(const wxString &aName, bool aTestOtherPins=true)
Set the pin name.
Definition: lib_pin.cpp:162
void drawGraphic(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, void *aData, const TRANSFORM &aTransform) override
Draw a pin, with or without the pin texts.
Definition: lib_pin.cpp:561
static const BITMAP_DEF iconsPinsOrientations[]
Definition: lib_pin.cpp:68
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
void SetWidth(int aWidth) override
Set the width of the draw item to aWidth.
Definition: lib_pin.cpp:1410
Search texts (name and number (a 4 letters text) )in pins.
int m_Unit
Unit identification for multiple parts per package.
Definition: lib_draw_item.h:89
wxString m_name
Definition: lib_pin.h:74
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
Definition: lib_pin.cpp:541
static const BITMAP_DEF * GetOrientationSymbols()
Get a list of pin orientation bitmaps for menus and dialogs.
Definition: lib_pin.cpp:1655
virtual EDA_RECT * GetClipBox()
Definition: lib_pin.h:55
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
void EnableEditMode(bool aEnable, bool aEditPinByPin=false)
Enable or clear pin editing mode.
Definition: lib_pin.cpp:515
void PlotPinTexts(PLOTTER *aPlotter, wxPoint &aPosition, int aOrientation, int aTextInside, bool aDrawPinNum, bool aDrawPinName, int aWidth)
Plot the pin number and pin text info, given the pin line coordinates.
Definition: lib_pin.cpp:1048
const EDA_RECT GetBoundingBox() const override
Definition: lib_pin.h:129
The base class for create windows for drawing purpose.
Definition: draw_frame.h:82
int PinDrawOrient(const TRANSFORM &aTransform) const
Return the pin real orientation (PIN_UP, PIN_DOWN, PIN_RIGHT, PIN_LEFT), according to its orientation...
Definition: lib_pin.cpp:1253
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Definition: eeschema.cpp:174
int m_length
Length of the pin.
Definition: lib_pin.h:68
void RevertYAxis()
Function RevertYAxis Mirror the rectangle from the X axis (negate Y pos and size)
Definition: eda_rect.h:144
wxString GetShownText() const override
Returns the string actually shown after processing of the base text.
Definition: sch_field.cpp:115
COLOR4D GetInvisibleItemColor()
Field Reference of part, i.e. "IC21".
bool Contains(const wxPoint &aPoint) const
Function Contains.
void DrawGraphicText(EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aPos, COLOR4D aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, void(*aCallback)(int x0, int y0, int xf, int yf, void *aData), void *aCallbackData, PLOTTER *aPlotter)
Function DrawGraphicText Draw a graphic text (like module texts)
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
This file contains miscellaneous commonly used macros and functions.
bool IsNew() const
Definition: base_struct.h:222
SCH_FIELD * GetField(int aFieldNdx) const
Returns a field in this symbol.
virtual void Text(const wxPoint &aPos, const COLOR4D aColor, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, bool aMultilineAllowed=false, void *aData=NULL)
Draws text with the plotter.
void MirrorVertical(const wxPoint &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_pin.cpp:1353
void SetConversion(int aConversion)
Set the body style (conversion) of the pin.
Definition: lib_pin.cpp:451
void GRLineTo(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int width, COLOR4D Color)
Definition: gr_basic.cpp:337
wxString MessageTextFromValue(EDA_UNITS_T aUnits, int aValue, bool aUseMils)
Definition: base_units.cpp:125
void SetNumber(const wxString &aNumber)
Set the pin number.
Definition: lib_pin.cpp:223
void GetPins(LIB_PINS &aList, int aUnit=0, int aConvert=0)
Return a list of pin object pointers from the draw item list.
virtual EDA_DRAW_FRAME * GetParent() const =0
bool ShowPinNames()
int GetPenSize() const override
Definition: lib_pin.cpp:549
static int GetPinNumDefaultSize()
void LineTo(const wxPoint &pos)
Definition: plotter.h:246
int m_orientation
Pin orientation (Up, Down, Left, Right)
Definition: lib_pin.h:69
#define VALUE
GRAPHIC_PINSHAPE
Definition: pin_shape.h:35
#define IS_CHANGED
std::function passed to nested users by ref, avoids copying std::function
Definition: base_struct.h:110
bool ShowPinNumbers()
Class for tranforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
wxString m_number
Definition: lib_pin.h:75
void PlotSymbol(PLOTTER *aPlotter, const wxPoint &aPosition, int aOrientation)
Definition: lib_pin.cpp:922
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:259
SCH_SHEET_PATH * g_CurrentSheet
With the new connectivity algorithm, many more places than before want to know what the current sheet...
wxString const GetElectricalTypeName() const
return a translated string for messages giving the electrical type of the pin.
Definition: lib_pin.h:259
const wxString & GetName() const
Definition: lib_pin.h:150
TRANSFORM & GetTransform() const
#define PIN_INVISIBLE
Definition: lib_pin.h:46
Class LIB_ITEM definition.
void SetEnd(int x, int y)
Definition: eda_rect.h:134
bool Inside(EDA_RECT &aRect) const override
Test if any part of the draw object is inside rectangle bounds of aRect.
Definition: lib_pin.cpp:1323
void DrawPinElectricalTypeName(EDA_DRAW_PANEL *aPanel, wxDC *aDC, wxPoint &aPosition, int aOrientation)
Draw the electrical type text of the pin (only for the footprint editor)
Definition: lib_pin.cpp:869
Define a library symbol object.
void SetVisible(bool aVisible)
Set or clear the visibility flag for the pin.
Definition: lib_pin.cpp:482
SCH_CONNECTION * GetConnectionForPin(LIB_PIN *aPin, const SCH_SHEET_PATH &aSheet)
Retrieves the connection for a given pin of the component.
wxLogTrace helper definitions.
void Rotate() override
Rotate the draw item.
Definition: lib_pin.cpp:1638
Definition: colors.h:60
wxString GetText(GRAPHIC_PINSHAPE shape)
Definition: pin_shape.cpp:33
void GetMsgPanelInfo(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Display basic info (type, part and convert) about the current item in message panel.
bool IsVisible() const
Return the visibility status of the draw object.
Definition: lib_pin.h:346
static const int pin_orientation_codes[]
Definition: lib_pin.cpp:54
int GetNameTextSize() const
Definition: lib_pin.h:176
static int InternalPinDecoSize(const LIB_PIN &aPin)
Utility for getting the size of the 'internal' pin decorators (as a radius)
Definition: lib_pin.cpp:134
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
void DrawPinSymbol(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPos, int aOrientation)
Draw the pin symbol without text.
Definition: lib_pin.cpp:602
void CalcEdit(const wxPoint &aPosition) override
Calculates the attributes of an item at aPosition when it is being edited.
Definition: lib_pin.cpp:1713
void AppendDebugInfoToMsgPanel(MSG_PANEL_ITEMS &aList) const
Adds extended debug information about the connection object to aList.
LIB_PIN(LIB_PART *aParent)
Definition: lib_pin.cpp:148
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: lib_pin.cpp:1667
void SetPinPosition(wxPoint aPosition)
move this and all linked pins to the new position used in pin editing.
Definition: lib_pin.cpp:394
wxPoint GetPosition() const override
Return the current draw object position.
Definition: lib_pin.h:432
void MoveTo(const wxPoint &pos)
Definition: plotter.h:241
LIB_PIN * GetNextPin(LIB_PIN *aItem=NULL)
Return the next pin object from the draw list.
int m_attributes
Set bit 0 to indicate pin is invisible.
Definition: lib_pin.h:73
void GRMoveTo(int x, int y)
Definition: gr_basic.cpp:327
void Normalize()
Function Normalize ensures that the height ant width are positive.
Base plotter engine class.
Definition: plotter.h:97
void MoveTo(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_pin.cpp:1331
wxPoint m_position
Position of the pin.
Definition: lib_pin.h:67
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_draw_item.h:61
void SetPartNumber(int aPart)
Set the pin part number.
Definition: lib_pin.cpp:421
int GetNumberTextSize() const
Definition: lib_pin.h:203
see class PGM_BASE
TRANSFORM DefaultTransform
Definition: eeschema.cpp:59
void Plot(PLOTTER *aPlotter, const wxPoint &aOffset, bool aFill, const TRANSFORM &aTransform) override
Plot the draw item using the plot object.
Definition: lib_pin.cpp:1394
const wxChar *const traceFindItem
Flag to enable find debug tracing.
bool IsType(FRAME_T aType) const
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
static int GetPinNameDefaultSize()
ELECTRICAL_PINTYPE
The component library pin object electrical types used in ERC tests.
Definition: pin_type.h:37
#define max(a, b)
Definition: auxiliary.h:86
#define PIN_TEXT_MARGIN
Definition: lib_pin.cpp:64
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
Definition: gr_basic.cpp:755
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:181
size_t i
Definition: json11.cpp:597
Perform a search for a item that has replaceable text.
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
void SetType(ELECTRICAL_PINTYPE aType, bool aTestOtherPins=true)
Set the electrical type of the pin.
Definition: lib_pin.cpp:328
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
wxPoint GetPosition() const override
Function GetPosition.
void RemoveDrawItem(LIB_ITEM *aItem, EDA_DRAW_PANEL *aPanel=NULL, wxDC *aDc=NULL)
Remove draw aItem from list.
#define TARGET_PIN_RADIUS
Definition: lib_pin.h:43
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:157
ELECTRICAL_PINTYPE m_type
Electrical type of the pin. See enum ELECTRICAL_PINTYPE.
Definition: lib_pin.h:72
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
wxPoint Centre() const
Definition: eda_rect.h:60
int m_Convert
Shape identification for alternate body styles.
Definition: lib_draw_item.h:96
wxString StringFromValue(EDA_UNITS_T aUnits, int aValue, bool aAddUnitSymbol, bool aUseMils)
Function StringFromValue returns the string from aValue according to units (inch, mm ....
Definition: base_units.cpp:210
void SetOrientation(int aOrientation, bool aTestOtherPins=true)
Set orientation on the pin.
Definition: lib_pin.cpp:270
#define DBG(x)
Definition: fctsys.h:33
BITMAP_DEF GetBitmap(GRAPHIC_PINSHAPE shape)
Definition: pin_shape.cpp:70
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
wxString const GetCanonicalElectricalTypeName() const
return a string giving the electrical type of the pin.
Definition: lib_pin.h:250
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
void SetNameTextSize(int aSize, bool aTestOtherPins=true)
Set the aSize of the pin name text.
Definition: lib_pin.cpp:195
void Offset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_pin.cpp:1317
Message panel definition file.
int m_width
Line width of the pin.
Definition: lib_pin.h:71
#define PIN_ORIENTATION_CNT
Definition: lib_pin.cpp:61
EDA_UNITS_T
Definition: common.h:157
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
void DrawPinTexts(EDA_DRAW_PANEL *aPanel, wxDC *aDC, wxPoint &aPosition, int aOrientation, int TextInside, bool DrawPinNum, bool DrawPinName)
Put the pin number and pin text info, given the pin line coordinates.
Definition: lib_pin.cpp:724
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
void getMsgPanelInfoBase(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList)
Build the pin basic info to display in message panel.
Definition: lib_pin.cpp:1420
void SetNumberTextSize(int aSize, bool aTestOtherPins=true)
Set the size of the pin number text.
Definition: lib_pin.cpp:242
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204
#define min(a, b)
Definition: auxiliary.h:85
void MirrorHorizontal(const wxPoint &aCenter) override
Mirror the draw object along the horizontal (X) axis about aCenter point.
Definition: lib_pin.cpp:1341
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.
static int GetOrientationCode(int aIndex)
Get the orientation code by index used to set the pin orientation.
Definition: lib_pin.cpp:1615
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39