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 <gr_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::print( wxDC* aDC, const wxPoint& aOffset, void* aData, const TRANSFORM& aTransform )
562 {
563  PART_DRAW_OPTIONS* opts = (PART_DRAW_OPTIONS*) aData;
564  LIB_PART* part = GetParent();
565 
566  /* Calculate pin orient taking in account the component orientation. */
567  int orient = PinDrawOrient( aTransform );
568 
569  /* Calculate the pin position */
570  wxPoint pos1 = aTransform.TransformCoordinate( m_position ) + aOffset;
571 
572  if( IsVisible() || ( opts && opts->draw_hidden_fields ) )
573  {
574  PrintPinSymbol( aDC, pos1, orient );
575 
576  PrintPinTexts( aDC, pos1, orient, part->GetPinNameOffset(), part->ShowPinNumbers(),
577  part->ShowPinNames() );
578 
579  if( opts && opts->show_elec_type )
580  PrintPinElectricalTypeName( aDC, pos1, orient );
581  }
582 }
583 
584 
585 void LIB_PIN::PrintPinSymbol( wxDC* aDC, const wxPoint& aPos, int aOrient )
586 {
587  int MapX1, MapY1, x1, y1;
588  int width = GetPenSize();
589  int posX = aPos.x, posY = aPos.y, len = m_length;
591 
592  MapX1 = MapY1 = 0;
593  x1 = posX;
594  y1 = posY;
595 
596  switch( aOrient )
597  {
598  case PIN_UP: y1 = posY - len; MapY1 = 1; break;
599  case PIN_DOWN: y1 = posY + len; MapY1 = -1; break;
600  case PIN_LEFT: x1 = posX - len; MapX1 = 1; break;
601  case PIN_RIGHT: x1 = posX + len; MapX1 = -1; break;
602  }
603 
605  {
606  const int radius = ExternalPinDecoSize( *this );
607  GRCircle( nullptr, aDC, MapX1 * radius + x1, MapY1 * radius + y1, radius, width, color );
608 
609  GRMoveTo( MapX1 * radius * 2 + x1, MapY1 * radius * 2 + y1 );
610  GRLineTo( nullptr, aDC, posX, posY, width, color );
611  }
612  else
613  {
614  GRMoveTo( x1, y1 );
615  GRLineTo( nullptr, aDC, posX, posY, width, color );
616  }
617 
618  // Draw the clock shape (>)inside the symbol
621  {
622  const int clock_size = InternalPinDecoSize( *this );
623  if( MapY1 == 0 ) /* MapX1 = +- 1 */
624  {
625  GRMoveTo( x1, y1 + clock_size );
626  GRLineTo( nullptr, aDC, x1 - MapX1 * clock_size * 2, y1, width, color );
627  GRLineTo( nullptr, aDC, x1, y1 - clock_size, width, color );
628  }
629  else /* MapX1 = 0 */
630  {
631  GRMoveTo( x1 + clock_size, y1 );
632  GRLineTo( nullptr, aDC, x1, y1 - MapY1 * clock_size * 2, width, color );
633  GRLineTo( nullptr, aDC, x1 - clock_size, y1, width, color );
634  }
635  }
636 
637  // Draw the active low (or H to L active transition)
638  if( m_shape == PINSHAPE_INPUT_LOW ||
640  {
641  const int deco_size = ExternalPinDecoSize( *this );
642  if( MapY1 == 0 ) /* MapX1 = +- 1 */
643  {
644  GRMoveTo( x1 + MapX1 * deco_size * 2, y1 );
645  GRLineTo( nullptr, aDC, x1 + MapX1 * deco_size * 2, y1 - deco_size * 2, width, color );
646  GRLineTo( nullptr, aDC, x1, y1, width, color );
647  }
648  else /* MapX1 = 0 */
649  {
650  GRMoveTo( x1, y1 + MapY1 * deco_size * 2 );
651  GRLineTo( nullptr, aDC, x1 - deco_size * 2, y1 + MapY1 * deco_size * 2, width, color );
652  GRLineTo( nullptr, aDC, x1, y1, width, color );
653  }
654  }
655 
656  if( m_shape == PINSHAPE_OUTPUT_LOW ) /* IEEE symbol "Active Low Output" */
657  {
658  const int deco_size = ExternalPinDecoSize( *this );
659  if( MapY1 == 0 ) /* MapX1 = +- 1 */
660  {
661  GRMoveTo( x1, y1 - deco_size * 2 );
662  GRLineTo( nullptr, aDC, x1 + MapX1 * deco_size * 2, y1, width, color );
663  }
664  else /* MapX1 = 0 */
665  {
666  GRMoveTo( x1 - deco_size * 2, y1 );
667  GRLineTo( nullptr, aDC, x1, y1 + MapY1 * deco_size * 2, width, color );
668  }
669  }
670  else if( m_shape == PINSHAPE_NONLOGIC ) /* NonLogic pin symbol */
671  {
672  const int deco_size = ExternalPinDecoSize( *this );
673  GRMoveTo( x1 - (MapX1 + MapY1) * deco_size, y1 - (MapY1 - MapX1) * deco_size );
674  GRLineTo( nullptr, aDC, x1 + (MapX1 + MapY1) * deco_size, y1 + (MapY1 - MapX1) * deco_size, width,
675  color );
676  GRMoveTo( x1 - (MapX1 - MapY1) * deco_size, y1 - (MapY1 + MapX1) * deco_size );
677  GRLineTo( nullptr, aDC, x1 + (MapX1 - MapY1) * deco_size, y1 + (MapY1 + MapX1) * deco_size, width,
678  color );
679  }
680 
681  if( m_type == PIN_NC ) // Draw a N.C. symbol
682  {
683  const int deco_size = TARGET_PIN_RADIUS;
684  GRLine( nullptr, aDC, posX - deco_size, posY - deco_size, posX + deco_size, posY + deco_size, width, color );
685  GRLine( nullptr, aDC, posX + deco_size, posY - deco_size, posX - deco_size, posY + deco_size, width, color );
686  }
687 }
688 
689 
690 void LIB_PIN::PrintPinTexts( wxDC* DC, wxPoint& pin_pos, int orient, int TextInside,
691  bool DrawPinNum, bool DrawPinName )
692 {
693  if( !DrawPinName && !DrawPinNum )
694  return;
695 
696  int x, y;
697 
698  wxSize PinNameSize( m_nameTextSize, m_nameTextSize );
699  wxSize PinNumSize( m_numTextSize, m_numTextSize );
700  int nameLineWidth = Clamp_Text_PenSize( GetPenSize(), m_nameTextSize, false );
701  int numLineWidth = Clamp_Text_PenSize( GetPenSize(), m_numTextSize, false );
702  int name_offset = PIN_TEXT_MARGIN + ( nameLineWidth + GetDefaultLineThickness() ) / 2;
703  int num_offset = PIN_TEXT_MARGIN + ( numLineWidth + GetDefaultLineThickness() ) / 2;
704 
705  /* Get the num and name colors */
708 
709  int x1 = pin_pos.x;
710  int y1 = pin_pos.y;
711 
712  switch( orient )
713  {
714  case PIN_UP: y1 -= m_length; break;
715  case PIN_DOWN: y1 += m_length; break;
716  case PIN_LEFT: x1 -= m_length; break;
717  case PIN_RIGHT: x1 += m_length; break;
718  }
719 
720  if( m_name.IsEmpty() )
721  DrawPinName = false;
722 
723  if( TextInside ) // Draw the text inside, but the pin numbers outside.
724  {
725  if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
726  {
727  // It is an horizontal line
728  if( DrawPinName )
729  {
730  if( orient == PIN_RIGHT )
731  {
732  x = x1 + TextInside;
733  GRText( DC, wxPoint( x, y1 ), NameColor, m_name, TEXT_ANGLE_HORIZ,
735  nameLineWidth, false, false );
736  }
737  else // Orient == PIN_LEFT
738  {
739  x = x1 - TextInside;
740  GRText( DC, wxPoint( x, y1 ), NameColor, m_name, TEXT_ANGLE_HORIZ,
742  nameLineWidth, false, false );
743  }
744  }
745 
746  if( DrawPinNum )
747  {
748  GRText( DC, wxPoint( (x1 + pin_pos.x) / 2, y1 - num_offset ), NumColor, m_number,
750  GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth, false, false );
751  }
752  }
753  else /* Its a vertical line. */
754  {
755  // Text is drawn from bottom to top (i.e. to negative value for Y axis)
756  if( orient == PIN_DOWN )
757  {
758  y = y1 + TextInside;
759 
760  if( DrawPinName )
761  GRText( DC, wxPoint( x1, y ), NameColor, m_name, TEXT_ANGLE_VERT, PinNameSize,
762  GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, false,
763  false );
764 
765  if( DrawPinNum )
766  GRText( DC, wxPoint( x1 - num_offset, (y1 + pin_pos.y) / 2 ), NumColor,
768  GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth, false, false );
769  }
770  else /* PIN_UP */
771  {
772  y = y1 - TextInside;
773 
774  if( DrawPinName )
775  GRText( DC, wxPoint( x1, y ), NameColor, m_name, TEXT_ANGLE_VERT, PinNameSize,
776  GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, nameLineWidth, false,
777  false );
778 
779  if( DrawPinNum )
780  GRText( DC, wxPoint( x1 - num_offset, (y1 + pin_pos.y) / 2 ), NumColor,
782  GR_TEXT_VJUSTIFY_BOTTOM, numLineWidth, false, false );
783  }
784  }
785  }
786  else /**** Draw num & text pin outside ****/
787  {
788  if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
789  {
790  /* Its an horizontal line. */
791  if( DrawPinName )
792  {
793  x = (x1 + pin_pos.x) / 2;
794  GRText( DC, wxPoint( x, y1 - name_offset ), NameColor, m_name, TEXT_ANGLE_HORIZ,
796  nameLineWidth, false, false );
797  }
798  if( DrawPinNum )
799  {
800  x = (x1 + pin_pos.x) / 2;
801  GRText( DC, wxPoint( x, y1 + num_offset ), NumColor, m_number, TEXT_ANGLE_HORIZ,
802  PinNumSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, numLineWidth,
803  false, false );
804  }
805  }
806  else /* Its a vertical line. */
807  {
808  if( DrawPinName )
809  {
810  y = (y1 + pin_pos.y) / 2;
811  GRText( DC, wxPoint( x1 - name_offset, y ), NameColor, m_name, TEXT_ANGLE_VERT,
813  nameLineWidth, false, false );
814  }
815 
816  if( DrawPinNum )
817  {
818  GRText( DC, wxPoint( x1 + num_offset, (y1 + pin_pos.y) / 2 ), NumColor, m_number,
820  numLineWidth, false, false );
821  }
822  }
823  }
824 }
825 
826 
827 
828 void LIB_PIN::PrintPinElectricalTypeName( wxDC* aDC, wxPoint& aPosition, int aOrientation )
829 {
830  wxString typeName = GetElectricalTypeName();
831 
832  // Use a reasonable (small) size to draw the text
833  int textSize = (m_nameTextSize*3)/4;
834 
835  #define ETXT_MAX_SIZE Millimeter2iu(0.7 )
836  if( textSize > ETXT_MAX_SIZE )
837  textSize = ETXT_MAX_SIZE;
838 
839  // Use a reasonable pen size to draw the text
840  int pensize = textSize/6;
841 
842  // Get a suitable color
844 
845  wxPoint txtpos = aPosition;
846  int offset = Millimeter2iu( 0.4 );
848  int orient = TEXT_ANGLE_HORIZ;
849 
850  switch( aOrientation )
851  {
852  case PIN_UP:
853  txtpos.y += offset;
854  orient = TEXT_ANGLE_VERT;
855  hjustify = GR_TEXT_HJUSTIFY_RIGHT;
856  break;
857 
858  case PIN_DOWN:
859  txtpos.y -= offset;
860  orient = TEXT_ANGLE_VERT;
861  break;
862 
863  case PIN_LEFT:
864  txtpos.x += offset;
865  break;
866 
867  case PIN_RIGHT:
868  txtpos.x -= offset;
869  hjustify = GR_TEXT_HJUSTIFY_RIGHT;
870  break;
871  }
872 
873  GRText( aDC, txtpos, color, typeName, orient, wxSize( textSize, textSize ), hjustify,
874  GR_TEXT_VJUSTIFY_CENTER, pensize, false, false );
875 }
876 
877 
878 void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrientation )
879 {
880  int MapX1, MapY1, x1, y1;
882 
883  aPlotter->SetColor( color );
884  aPlotter->SetCurrentLineWidth( GetPenSize() );
885 
886  MapX1 = MapY1 = 0;
887  x1 = aPosition.x; y1 = aPosition.y;
888 
889  switch( aOrientation )
890  {
891  case PIN_UP: y1 = aPosition.y - m_length; MapY1 = 1; break;
892  case PIN_DOWN: y1 = aPosition.y + m_length; MapY1 = -1; break;
893  case PIN_LEFT: x1 = aPosition.x - m_length; MapX1 = 1; break;
894  case PIN_RIGHT: x1 = aPosition.x + m_length; MapX1 = -1; break;
895  }
896 
898  {
899  const int radius = ExternalPinDecoSize( *this );
900  aPlotter->Circle( wxPoint( MapX1 * radius + x1, MapY1 * radius + y1 ),
901  radius * 2, NO_FILL, GetPenSize() );
902 
903  aPlotter->MoveTo( wxPoint( MapX1 * radius * 2 + x1, MapY1 * radius * 2 + y1 ) );
904  aPlotter->FinishTo( aPosition );
905  }
907  {
908  const int deco_size = InternalPinDecoSize( *this );
909  if( MapY1 == 0 ) /* MapX1 = +- 1 */
910  {
911  aPlotter->MoveTo( wxPoint( x1, y1 + deco_size ) );
912  aPlotter->LineTo( wxPoint( x1 + MapX1 * deco_size * 2, y1 ) );
913  aPlotter->FinishTo( wxPoint( x1, y1 - deco_size ) );
914  }
915  else /* MapX1 = 0 */
916  {
917  aPlotter->MoveTo( wxPoint( x1 + deco_size, y1 ) );
918  aPlotter->LineTo( wxPoint( x1, y1 + MapY1 * deco_size * 2 ) );
919  aPlotter->FinishTo( wxPoint( x1 - deco_size, y1 ) );
920  }
921 
922  aPlotter->MoveTo( wxPoint( MapX1 * deco_size * 2 + x1, MapY1 * deco_size * 2 + y1 ) );
923  aPlotter->FinishTo( aPosition );
924  }
925  else
926  {
927  aPlotter->MoveTo( wxPoint( x1, y1 ) );
928  aPlotter->FinishTo( aPosition );
929  }
930 
933  {
934  const int deco_size = InternalPinDecoSize( *this );
935  if( MapY1 == 0 ) /* MapX1 = +- 1 */
936  {
937  aPlotter->MoveTo( wxPoint( x1, y1 + deco_size ) );
938  aPlotter->LineTo( wxPoint( x1 - MapX1 * deco_size * 2, y1 ) );
939  aPlotter->FinishTo( wxPoint( x1, y1 - deco_size ) );
940  }
941  else /* MapX1 = 0 */
942  {
943  aPlotter->MoveTo( wxPoint( x1 + deco_size, y1 ) );
944  aPlotter->LineTo( wxPoint( x1, y1 - MapY1 * deco_size * 2 ) );
945  aPlotter->FinishTo( wxPoint( x1 - deco_size, y1 ) );
946  }
947  }
948 
949  if( m_shape == PINSHAPE_INPUT_LOW || m_shape == PINSHAPE_CLOCK_LOW ) /* IEEE symbol "Active Low Input" */
950  {
951  const int deco_size = ExternalPinDecoSize( *this );
952 
953  if( MapY1 == 0 ) /* MapX1 = +- 1 */
954  {
955  aPlotter->MoveTo( wxPoint( x1 + MapX1 * deco_size * 2, y1 ) );
956  aPlotter->LineTo( wxPoint( x1 + MapX1 * deco_size * 2, y1 - deco_size * 2 ) );
957  aPlotter->FinishTo( wxPoint( x1, y1 ) );
958  }
959  else /* MapX1 = 0 */
960  {
961  aPlotter->MoveTo( wxPoint( x1, y1 + MapY1 * deco_size * 2 ) );
962  aPlotter->LineTo( wxPoint( x1 - deco_size * 2, y1 + MapY1 * deco_size * 2 ) );
963  aPlotter->FinishTo( wxPoint( x1, y1 ) );
964  }
965  }
966 
967 
968  if( m_shape == PINSHAPE_OUTPUT_LOW ) /* IEEE symbol "Active Low Output" */
969  {
970  const int symbol_size = ExternalPinDecoSize( *this );
971 
972  if( MapY1 == 0 ) /* MapX1 = +- 1 */
973  {
974  aPlotter->MoveTo( wxPoint( x1, y1 - symbol_size * 2 ) );
975  aPlotter->FinishTo( wxPoint( x1 + MapX1 * symbol_size * 2, y1 ) );
976  }
977  else /* MapX1 = 0 */
978  {
979  aPlotter->MoveTo( wxPoint( x1 - symbol_size * 2, y1 ) );
980  aPlotter->FinishTo( wxPoint( x1, y1 + MapY1 * symbol_size * 2 ) );
981  }
982  }
983  else if( m_shape == PINSHAPE_NONLOGIC ) /* NonLogic pin symbol */
984  {
985  const int deco_size = ExternalPinDecoSize( *this );
986  aPlotter->MoveTo( wxPoint( x1 - (MapX1 + MapY1) * deco_size, y1 - (MapY1 - MapX1) * deco_size ) );
987  aPlotter->FinishTo( wxPoint( x1 + (MapX1 + MapY1) * deco_size, y1 + (MapY1 - MapX1) * deco_size ) );
988  aPlotter->MoveTo( wxPoint( x1 - (MapX1 - MapY1) * deco_size, y1 - (MapY1 + MapX1) * deco_size ) );
989  aPlotter->FinishTo( wxPoint( x1 + (MapX1 - MapY1) * deco_size, y1 + (MapY1 + MapX1) * deco_size ) );
990  }
991  if( m_type == PIN_NC ) // Draw a N.C. symbol
992  {
993  const int deco_size = TARGET_PIN_RADIUS;
994  const int ex1 = aPosition.x;
995  const int ey1 = aPosition.y;
996  aPlotter->MoveTo( wxPoint( ex1 - deco_size, ey1 - deco_size ) );
997  aPlotter->FinishTo( wxPoint( ex1 + deco_size, ey1 + deco_size ) );
998  aPlotter->MoveTo( wxPoint( ex1 + deco_size, ey1 - deco_size ) );
999  aPlotter->FinishTo( wxPoint( ex1 - deco_size, ey1 + deco_size ) );
1000  }
1001 }
1002 
1003 
1004 void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient,
1005  int TextInside, bool DrawPinNum,
1006  bool DrawPinName, int aWidth )
1007 {
1008  if( m_name.IsEmpty() || m_name == wxT( "~" ) )
1009  DrawPinName = false;
1010 
1011  if( m_number.IsEmpty() )
1012  DrawPinNum = false;
1013 
1014  if( !DrawPinNum && !DrawPinName )
1015  return;
1016 
1017  int x, y;
1018  wxSize PinNameSize = wxSize( m_nameTextSize, m_nameTextSize );
1019  wxSize PinNumSize = wxSize( m_numTextSize, m_numTextSize );
1020 
1021  int nameLineWidth = GetPenSize();
1022  nameLineWidth = Clamp_Text_PenSize( nameLineWidth, m_nameTextSize, false );
1023  int numLineWidth = GetPenSize();
1024  numLineWidth = Clamp_Text_PenSize( numLineWidth, m_numTextSize, false );
1025 
1026  int name_offset = PIN_TEXT_MARGIN +
1027  ( nameLineWidth + GetDefaultLineThickness() ) / 2;
1028  int num_offset = PIN_TEXT_MARGIN +
1029  ( numLineWidth + GetDefaultLineThickness() ) / 2;
1030 
1031  /* Get the num and name colors */
1032  COLOR4D NameColor = GetLayerColor( LAYER_PINNAM );
1033  COLOR4D NumColor = GetLayerColor( LAYER_PINNUM );
1034 
1035  int x1 = pin_pos.x;
1036  int y1 = pin_pos.y;
1037 
1038  switch( orient )
1039  {
1040  case PIN_UP: y1 -= m_length; break;
1041  case PIN_DOWN: y1 += m_length; break;
1042  case PIN_LEFT: x1 -= m_length; break;
1043  case PIN_RIGHT: x1 += m_length; break;
1044  }
1045 
1046  /* Draw the text inside, but the pin numbers outside. */
1047  if( TextInside )
1048  {
1049  if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) ) /* Its an horizontal line. */
1050  {
1051  if( DrawPinName )
1052  {
1053  if( orient == PIN_RIGHT )
1054  {
1055  x = x1 + TextInside;
1056  plotter->Text( wxPoint( x, y1 ), NameColor,
1057  m_name,
1059  PinNameSize,
1062  aWidth, false, false );
1063  }
1064  else // orient == PIN_LEFT
1065  {
1066  x = x1 - TextInside;
1067 
1068  if( DrawPinName )
1069  plotter->Text( wxPoint( x, y1 ),
1070  NameColor, m_name, TEXT_ANGLE_HORIZ,
1071  PinNameSize,
1074  aWidth, false, false );
1075  }
1076  }
1077  if( DrawPinNum )
1078  {
1079  plotter->Text( wxPoint( (x1 + pin_pos.x) / 2,
1080  y1 - num_offset ),
1081  NumColor, m_number,
1082  TEXT_ANGLE_HORIZ, PinNumSize,
1085  aWidth, false, false );
1086  }
1087  }
1088  else /* Its a vertical line. */
1089  {
1090  if( orient == PIN_DOWN )
1091  {
1092  y = y1 + TextInside;
1093 
1094  if( DrawPinName )
1095  plotter->Text( wxPoint( x1, y ), NameColor,
1096  m_name,
1097  TEXT_ANGLE_VERT, PinNameSize,
1100  aWidth, false, false );
1101 
1102  if( DrawPinNum )
1103  {
1104  plotter->Text( wxPoint( x1 - num_offset,
1105  (y1 + pin_pos.y) / 2 ),
1106  NumColor, m_number,
1107  TEXT_ANGLE_VERT, PinNumSize,
1110  aWidth, false, false );
1111  }
1112  }
1113  else /* PIN_UP */
1114  {
1115  y = y1 - TextInside;
1116 
1117  if( DrawPinName )
1118  plotter->Text( wxPoint( x1, y ), NameColor,
1119  m_name,
1120  TEXT_ANGLE_VERT, PinNameSize,
1123  aWidth, false, false );
1124 
1125  if( DrawPinNum )
1126  {
1127  plotter->Text( wxPoint( x1 - num_offset,
1128  (y1 + pin_pos.y) / 2 ),
1129  NumColor, m_number,
1130  TEXT_ANGLE_VERT, PinNumSize,
1133  aWidth, false, false );
1134  }
1135  }
1136  }
1137  }
1138  else /* Draw num & text pin outside */
1139  {
1140  if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
1141  {
1142  /* Its an horizontal line. */
1143  if( DrawPinName )
1144  {
1145  x = (x1 + pin_pos.x) / 2;
1146  plotter->Text( wxPoint( x, y1 - name_offset ),
1147  NameColor, m_name,
1148  TEXT_ANGLE_HORIZ, PinNameSize,
1151  aWidth, false, false );
1152  }
1153 
1154  if( DrawPinNum )
1155  {
1156  x = ( x1 + pin_pos.x ) / 2;
1157  plotter->Text( wxPoint( x, y1 + num_offset ),
1158  NumColor, m_number,
1159  TEXT_ANGLE_HORIZ, PinNumSize,
1162  aWidth, false, false );
1163  }
1164  }
1165  else /* Its a vertical line. */
1166  {
1167  if( DrawPinName )
1168  {
1169  y = ( y1 + pin_pos.y ) / 2;
1170  plotter->Text( wxPoint( x1 - name_offset, y ),
1171  NameColor, m_name,
1172  TEXT_ANGLE_VERT, PinNameSize,
1175  aWidth, false, false );
1176  }
1177 
1178  if( DrawPinNum )
1179  {
1180  plotter->Text( wxPoint( x1 + num_offset,
1181  ( y1 + pin_pos.y ) / 2 ),
1182  NumColor, m_number,
1183  TEXT_ANGLE_VERT, PinNumSize,
1186  aWidth, false, false );
1187  }
1188  }
1189  }
1190 }
1191 
1192 
1193 wxPoint LIB_PIN::PinEndPoint() const
1194 {
1195  wxPoint pos = m_position;
1196 
1197  switch( m_orientation )
1198  {
1199  case PIN_UP: pos.y += m_length; break;
1200  case PIN_DOWN: pos.y -= m_length; break;
1201  case PIN_LEFT: pos.x -= m_length; break;
1202  case PIN_RIGHT: pos.x += m_length; break;
1203  }
1204 
1205  return pos;
1206 }
1207 
1208 
1209 int LIB_PIN::PinDrawOrient( const TRANSFORM& aTransform ) const
1210 {
1211  int orient;
1212  wxPoint end; // position of pin end starting at 0,0 according to its orientation, length = 1
1213 
1214  switch( m_orientation )
1215  {
1216  case PIN_UP: end.y = 1; break;
1217  case PIN_DOWN: end.y = -1; break;
1218  case PIN_LEFT: end.x = -1; break;
1219  case PIN_RIGHT: end.x = 1; break;
1220  }
1221 
1222  // = pos of end point, according to the component orientation
1223  end = aTransform.TransformCoordinate( end );
1224  orient = PIN_UP;
1225 
1226  if( end.x == 0 )
1227  {
1228  if( end.y > 0 )
1229  orient = PIN_DOWN;
1230  }
1231  else
1232  {
1233  orient = PIN_RIGHT;
1234 
1235  if( end.x < 0 )
1236  orient = PIN_LEFT;
1237  }
1238 
1239  return orient;
1240 }
1241 
1242 
1244 {
1245  return new LIB_PIN( *this );
1246 }
1247 
1248 
1249 int LIB_PIN::compare( const LIB_ITEM& other ) const
1250 {
1251  wxASSERT( other.Type() == LIB_PIN_T );
1252 
1253  const LIB_PIN* tmp = (LIB_PIN*) &other;
1254 
1255  if( m_number != tmp->m_number )
1256  return m_number.Cmp( tmp->m_number );
1257 
1258  int result = m_name.CmpNoCase( tmp->m_name );
1259 
1260  if( result != 0 )
1261  return result;
1262 
1263  if( m_position.x != tmp->m_position.x )
1264  return m_position.x - tmp->m_position.x;
1265 
1266  if( m_position.y != tmp->m_position.y )
1267  return m_position.y - tmp->m_position.y;
1268 
1269  return 0;
1270 }
1271 
1272 
1273 void LIB_PIN::Offset( const wxPoint& aOffset )
1274 {
1275  m_position += aOffset;
1276 }
1277 
1278 
1279 bool LIB_PIN::Inside( EDA_RECT& rect ) const
1280 {
1281  wxPoint end = PinEndPoint();
1282 
1283  return rect.Contains( m_position.x, -m_position.y ) || rect.Contains( end.x, -end.y );
1284 }
1285 
1286 
1287 void LIB_PIN::MoveTo( const wxPoint& newPosition )
1288 {
1289  if( m_position != newPosition )
1290  {
1291  m_position = newPosition;
1292  SetModified();
1293  }
1294 }
1295 
1296 
1297 void LIB_PIN::MirrorHorizontal( const wxPoint& center )
1298 {
1299  m_position.x -= center.x;
1300  m_position.x *= -1;
1301  m_position.x += center.x;
1302 
1303  if( m_orientation == PIN_RIGHT )
1305  else if( m_orientation == PIN_LEFT )
1307 }
1308 
1309 void LIB_PIN::MirrorVertical( const wxPoint& center )
1310 {
1311  m_position.y -= center.y;
1312  m_position.y *= -1;
1313  m_position.y += center.y;
1314 
1315  if( m_orientation == PIN_UP )
1317  else if( m_orientation == PIN_DOWN )
1319 }
1320 
1321 void LIB_PIN::Rotate( const wxPoint& center, bool aRotateCCW )
1322 {
1323  int rot_angle = aRotateCCW ? -900 : 900;
1324 
1325  RotatePoint( &m_position, center, rot_angle );
1326 
1327  if( aRotateCCW )
1328  {
1329  switch( m_orientation )
1330  {
1331  case PIN_RIGHT: m_orientation = PIN_UP; break;
1332  case PIN_UP: m_orientation = PIN_LEFT; break;
1333  case PIN_LEFT: m_orientation = PIN_DOWN; break;
1334  case PIN_DOWN: m_orientation = PIN_RIGHT; break;
1335  }
1336  }
1337  else
1338  {
1339  switch( m_orientation )
1340  {
1341  case PIN_RIGHT: m_orientation = PIN_DOWN; break;
1342  case PIN_UP: m_orientation = PIN_RIGHT; break;
1343  case PIN_LEFT: m_orientation = PIN_UP; break;
1344  case PIN_DOWN: m_orientation = PIN_LEFT; break;
1345  }
1346  }
1347 }
1348 
1349 
1350 void LIB_PIN::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
1351  const TRANSFORM& aTransform )
1352 {
1353  if( ! IsVisible() )
1354  return;
1355 
1356  int orient = PinDrawOrient( aTransform );
1357 
1358  wxPoint pos = aTransform.TransformCoordinate( m_position ) + offset;
1359 
1360  PlotSymbol( plotter, pos, orient );
1361  PlotPinTexts( plotter, pos, orient, GetParent()->GetPinNameOffset(),
1362  GetParent()->ShowPinNumbers(), GetParent()->ShowPinNames(), GetPenSize() );
1363 }
1364 
1365 
1366 void LIB_PIN::SetWidth( int aWidth )
1367 {
1368  if( m_width != aWidth )
1369  {
1370  m_width = aWidth;
1371  SetModified();
1372  }
1373 }
1374 
1375 
1377 {
1378  wxString text = m_number.IsEmpty() ? wxT( "?" ) : m_number;
1379 
1380  LIB_ITEM::GetMsgPanelInfo( aUnits, aList );
1381 
1382  aList.push_back( MSG_PANEL_ITEM( _( "Name" ), m_name, DARKCYAN ) );
1383  aList.push_back( MSG_PANEL_ITEM( _( "Number" ), text, DARKCYAN ) );
1384  aList.push_back( MSG_PANEL_ITEM( _( "Type" ), GetText( m_type ), RED ) );
1385 
1386  text = GetText( m_shape );
1387  aList.push_back( MSG_PANEL_ITEM( _( "Style" ), text, BLUE ) );
1388 
1389  text = IsVisible() ? _( "Yes" ) : _( "No" );
1390  aList.push_back( MSG_PANEL_ITEM( _( "Visible" ), text, DARKGREEN ) );
1391 
1392  // Display pin length
1393  text = StringFromValue( aUnits, m_length, true );
1394  aList.push_back( MSG_PANEL_ITEM( _( "Length" ), text, MAGENTA ) );
1395 
1397  aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), text, DARKMAGENTA ) );
1398 }
1399 
1401 {
1402  getMsgPanelInfoBase( aUnits, aList );
1403 
1404  wxString text;
1405  wxPoint pinpos = GetPosition();
1406  pinpos.y = -pinpos.y; // Display coord are top to bottom
1407  // lib items coord are bottom to top
1408 
1409  text = MessageTextFromValue( aUnits, pinpos.x, true );
1410  aList.push_back( MSG_PANEL_ITEM( _( "Pos X" ), text, DARKMAGENTA ) );
1411 
1412  text = MessageTextFromValue( aUnits, pinpos.y, true );
1413  aList.push_back( MSG_PANEL_ITEM( _( "Pos Y" ), text, DARKMAGENTA ) );
1414 }
1415 
1416 void LIB_PIN::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList,
1417  SCH_COMPONENT* aComponent )
1418 {
1419  getMsgPanelInfoBase( aUnits, aList );
1420 
1421  if( !aComponent )
1422  return;
1423 
1424  wxString text;
1425  wxPoint pinpos = aComponent->GetTransform().TransformCoordinate( GetPosition() )
1426  + aComponent->GetPosition();
1427 
1428  text = MessageTextFromValue( aUnits, pinpos.x, true );
1429  aList.emplace_back( _( "Pos X" ), text, DARKMAGENTA );
1430 
1431  text = MessageTextFromValue( aUnits, pinpos.y, true );
1432  aList.emplace_back( _( "Pos Y" ), text, DARKMAGENTA );
1433 
1434  aList.emplace_back( aComponent->GetField( REFERENCE )->GetShownText(),
1435  aComponent->GetField( VALUE )->GetShownText(), DARKCYAN );
1436 
1437 #if defined(DEBUG)
1438 
1439  auto conn = aComponent->GetConnectionForPin( this, *g_CurrentSheet );
1440 
1441  if( conn )
1442  conn->AppendDebugInfoToMsgPanel( aList );
1443 
1444 #endif
1445 }
1446 
1447 const EDA_RECT LIB_PIN::GetBoundingBox( bool aIncludeInvisibles ) const
1448 {
1449  LIB_PART* entry = (LIB_PART* ) m_Parent;
1450  EDA_RECT bbox;
1451  wxPoint begin;
1452  wxPoint end;
1453  int nameTextOffset = 0;
1454  bool showName = !m_name.IsEmpty() && (m_name != wxT( "~" ));
1455  bool showNum = !m_number.IsEmpty();
1456  int minsizeV = TARGET_PIN_RADIUS;
1457 
1458  if( !aIncludeInvisibles && !IsVisible() )
1459  showName = false;
1460 
1461  if( entry )
1462  {
1463  if( entry->ShowPinNames() )
1464  nameTextOffset = entry->GetPinNameOffset();
1465  else
1466  showName = false;
1467 
1468  showNum = entry->ShowPinNumbers();
1469  }
1470 
1471  // First, calculate boundary box corners position
1472  int numberTextLength = showNum ? m_numTextSize * m_number.Len() : 0;
1473 
1474  // Actual text height is bigger than text size
1475  int numberTextHeight = showNum ? KiROUND( m_numTextSize * 1.1 ) : 0;
1476 
1478  minsizeV = std::max( TARGET_PIN_RADIUS, ExternalPinDecoSize( *this ) );
1479 
1480  // calculate top left corner position
1481  // for the default pin orientation (PIN_RIGHT)
1482  begin.y = std::max( minsizeV, numberTextHeight + PIN_TEXT_MARGIN );
1483  begin.x = std::min( -TARGET_PIN_RADIUS, m_length - (numberTextLength / 2) );
1484 
1485  // calculate bottom right corner position and adjust top left corner position
1486  int nameTextLength = 0;
1487  int nameTextHeight = 0;
1488 
1489  if( showName )
1490  {
1491  int length = m_name.Len();
1492 
1493  // Don't count the line over text symbol.
1494  if( m_name.Left( 1 ) == wxT( "~" ) )
1495  length -= 1;
1496 
1497  nameTextLength = ( m_nameTextSize * length ) + nameTextOffset;
1498 
1499  // Actual text height are bigger than text size
1500  nameTextHeight = KiROUND( m_nameTextSize * 1.1 ) + PIN_TEXT_MARGIN;
1501  }
1502 
1503  if( nameTextOffset ) // for values > 0, pin name is inside the body
1504  {
1505  end.x = m_length + nameTextLength;
1506  end.y = std::min( -minsizeV, -nameTextHeight / 2 );
1507  }
1508  else // if value == 0:
1509  // pin name is outside the body, and above the pin line
1510  // pin num is below the pin line
1511  {
1512  end.x = std::max(m_length, nameTextLength);
1513  end.y = -begin.y;
1514  begin.y = std::max( minsizeV, nameTextHeight );
1515  }
1516 
1517  // Now, calculate boundary box corners position for the actual pin orientation
1518  int orient = PinDrawOrient( DefaultTransform );
1519 
1520  /* Calculate the pin position */
1521  switch( orient )
1522  {
1523  case PIN_UP:
1524  // Pin is rotated and texts positions are mirrored
1525  RotatePoint( &begin, wxPoint( 0, 0 ), -900 );
1526  RotatePoint( &end, wxPoint( 0, 0 ), -900 );
1527  break;
1528 
1529  case PIN_DOWN:
1530  RotatePoint( &begin, wxPoint( 0, 0 ), 900 );
1531  RotatePoint( &end, wxPoint( 0, 0 ), 900 );
1532  begin.x = -begin.x;
1533  end.x = -end.x;
1534  break;
1535 
1536  case PIN_LEFT:
1537  begin.x = -begin.x;
1538  end.x = -end.x;
1539  break;
1540 
1541  case PIN_RIGHT:
1542  break;
1543  }
1544 
1545  begin += m_position;
1546  end += m_position;
1547 
1548  bbox.SetOrigin( begin );
1549  bbox.SetEnd( end );
1550  bbox.Normalize();
1551  bbox.Inflate( ( GetPenSize() / 2 ) + 1 );
1552 
1553  // Draw Y axis is reversed in schematic:
1554  bbox.RevertYAxis();
1555 
1556  return bbox;
1557 }
1558 
1559 
1560 wxArrayString LIB_PIN::GetOrientationNames( void )
1561 {
1562  wxArrayString tmp;
1563 
1564  for( unsigned ii = 0; ii < PIN_ORIENTATION_CNT; ii++ )
1565  tmp.Add( getPinOrientationName( ii ) );
1566 
1567  return tmp;
1568 }
1569 
1570 
1572 {
1573  if( index >= 0 && index < (int) PIN_ORIENTATION_CNT )
1574  return pin_orientation_codes[ index ];
1575 
1576  return PIN_RIGHT;
1577 }
1578 
1579 
1581 {
1582  size_t i;
1583 
1584  for( i = 0; i < PIN_ORIENTATION_CNT; i++ )
1585  {
1586  if( pin_orientation_codes[i] == code )
1587  return (int) i;
1588  }
1589 
1590  return wxNOT_FOUND;
1591 }
1592 
1593 
1595 {
1596  return iconsPinsOrientations;
1597 }
1598 
1599 
1600 BITMAP_DEF LIB_PIN::GetMenuImage() const
1601 {
1602  return GetBitmap( m_type );
1603 }
1604 
1605 
1606 wxString LIB_PIN::GetSelectMenuText( EDA_UNITS_T aUnits ) const
1607 {
1608  return wxString::Format( _( "Pin %s, %s, %s" ),
1609  m_number,
1611  GetText( m_shape ));
1612 }
1613 
1614 
1615 bool LIB_PIN::Matches( wxFindReplaceData& aSearchData, void* aAuxDat )
1616 {
1617  wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText( MILLIMETRES ) );
1618 
1619  // Note: this will have to be modified if we add find and replace capability to the
1620  // compoment library editor. Otherwise, you wont be able to replace pin text.
1621  if( !( aSearchData.GetFlags() & FR_SEARCH_ALL_PINS )
1622  || ( aSearchData.GetFlags() & FR_SEARCH_REPLACE ) )
1623  return false;
1624 
1625  wxLogTrace( traceFindItem, wxT( " child item " ) + GetSelectMenuText( MILLIMETRES ) );
1626 
1627  return EDA_ITEM::Matches( GetName(), aSearchData )
1628  || EDA_ITEM::Matches( m_number, aSearchData );
1629 }
1630 
1631 
1632 #if defined(DEBUG)
1633 
1634 void LIB_PIN::Show( int nestLevel, std::ostream& os ) const
1635 {
1636  NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
1637  << " num=\"" << m_number.mb_str()
1638  << '"' << "/>\n";
1639 
1640 // NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
1641 }
1642 
1643 #endif
1644 
1645 void LIB_PIN::CalcEdit( const wxPoint& aPosition )
1646 {
1647  if( IsMoving() )
1648  {
1649  DBG(printf("MOVEPIN\n");)
1650  MoveTo( aPosition );
1651  }
1652 }
Definition: colors.h:57
#define TEXT_ANGLE_HORIZ
void FinishTo(const wxPoint &pos)
Definition: plotter.h:264
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
Definition: base_struct.h:117
wxString GetClass() const override
Function GetClass returns the class name.
Definition: lib_pin.h:98
int compare(const LIB_ITEM &aOther) const override
Provide the draw object specific comparison called by the == and < operators.
Definition: lib_pin.cpp:1249
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.
Definition: lib_item.cpp:52
void SetModified()
Definition: base_struct.cpp:98
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:1243
EDA_ITEM * m_Parent
Linked list: Link (parent struct)
Definition: base_struct.h:180
#define IN_EDIT
Item currently edited.
Definition: base_struct.h:118
void Rotate(const wxPoint &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
Definition: lib_pin.cpp:1321
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:44
wxPoint PinEndPoint() const
Definition: lib_pin.cpp:1193
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()
bool Matches(wxFindReplaceData &aSearchData, void *aAuxData) override
Function Matches compares the item against the search criteria in aSearchData.
Definition: lib_pin.cpp:1615
#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:1580
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:1560
virtual void SetColor(COLOR4D color)=0
void PrintPinTexts(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:690
LIB_PART * GetParent() const
Definition: lib_item.h:177
std::vector< LIB_PIN * > LIB_PINS
Helper for defining a list of pin object pointers.
Definition: lib_item.h:55
void PrintPinElectricalTypeName(wxDC *aDC, wxPoint &aPosition, int aOrientation)
Draw the electrical type text of the pin (only for the footprint editor)
Definition: lib_pin.cpp:828
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: lib_pin.cpp:1600
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:230
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
static const BITMAP_DEF iconsPinsOrientations[]
Definition: lib_pin.cpp:68
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:131
void SetWidth(int aWidth) override
Definition: lib_pin.cpp:1366
int m_Unit
Unit identification for multiple parts per package.
Definition: lib_item.h:82
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:1594
Definition: lib_pin.h:55
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:206
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:1004
const EDA_RECT GetBoundingBox() const override
Definition: lib_pin.h:128
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:1209
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Definition: eeschema.cpp:167
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:209
COLOR4D GetInvisibleItemColor()
Field Reference of part, i.e. "IC21".
bool Contains(const wxPoint &aPoint) const
Function Contains.
bool draw_hidden_fields
Whether to draw "hidden" fields.
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_item.h:61
This file contains miscellaneous commonly used macros and functions.
bool IsNew() const
Definition: base_struct.h:228
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.
Definition: gr_text.cpp:215
void MirrorVertical(const wxPoint &aCenter) override
Mirror the draw object along the MirrorVertical (Y) axis about aCenter point.
Definition: lib_pin.cpp:1309
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:265
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.
bool ShowPinNames()
int GetPenSize() const override
Definition: lib_pin.cpp:549
static int GetPinNumDefaultSize()
void LineTo(const wxPoint &pos)
Definition: plotter.h:259
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:116
bool ShowPinNumbers()
Class for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Function Clamp_Text_PenSize Don't allow text to become cluttered up in its own fatness.
Definition: gr_text.cpp:64
wxString m_number
Definition: lib_pin.h:75
void PlotSymbol(PLOTTER *aPlotter, const wxPoint &aPosition, int aOrientation)
Definition: lib_pin.cpp:878
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:265
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:256
const wxString & GetName() const
Definition: lib_pin.h:149
TRANSFORM & GetTransform() const
#define PIN_INVISIBLE
Definition: lib_pin.h:46
Class LIB_PIN definition.
void SetEnd(int x, int y)
Definition: eda_rect.h:192
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:1279
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.
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:343
static const int pin_orientation_codes[]
Definition: lib_pin.cpp:54
int GetNameTextSize() const
Definition: lib_pin.h:175
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:229
#define _(s)
void CalcEdit(const wxPoint &aPosition) override
Calculates the attributes of an item at aPosition when it is being edited.
Definition: lib_pin.cpp:1645
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:1606
void SetPinPosition(wxPoint aPosition)
move this and all linked pins to the new position used in pin editing.
Definition: lib_pin.cpp:394
void GRText(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 GRText Draw a graphic text (like module texts)
Definition: gr_text.cpp:126
wxPoint GetPosition() const override
Definition: lib_pin.h:427
void MoveTo(const wxPoint &pos)
Definition: plotter.h:254
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:255
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:1287
wxPoint m_position
Position of the pin.
Definition: lib_pin.h:67
void SetPartNumber(int aPart)
Set the pin part number.
Definition: lib_pin.cpp:421
int GetNumberTextSize() const
Definition: lib_pin.h:202
see class PGM_BASE
TRANSFORM DefaultTransform
Definition: eeschema.cpp:50
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:1350
const wxChar *const traceFindItem
Flag to enable find debug tracing.
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
void print(wxDC *aDC, const wxPoint &aOffset, void *aData, const TRANSFORM &aTransform) override
Print a pin, with or without the pin texts.
Definition: lib_pin.cpp:561
#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:595
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:187
size_t i
Definition: json11.cpp:649
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.
#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:163
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
bool show_elec_type
Whether to show the pin electrical type.
int m_Convert
Shape identification for alternate body styles.
Definition: lib_item.h:88
void SetOrientation(int aOrientation, bool aTestOtherPins=true)
Set orientation on the pin.
Definition: lib_pin.cpp:270
#define DBG(x)
Definition: fctsys.h:33
virtual wxString GetShownText() const
Returns the string actually shown after processing of the base text.
Definition: eda_text.h:129
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:247
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:1273
Message panel definition file.
int m_width
Line width of the pin.
Definition: lib_pin.h:71
void PrintPinSymbol(wxDC *aDC, const wxPoint &aPos, int aOrientation)
Print the pin symbol without text.
Definition: lib_pin.cpp:585
#define PIN_ORIENTATION_CNT
Definition: lib_pin.cpp:61
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:512
EDA_UNITS_T
Definition: common.h:133
virtual void Circle(const wxPoint &pos, int diametre, FILL_T fill, int width=USE_DEFAULT_LINE_WIDTH)=0
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:1376
wxString StringFromValue(EDA_UNITS_T aUnits, double aValue, bool aAddUnitSymbol, bool aUseMils)
Function StringFromValue returns the string from aValue according to units (inch, mm ....
Definition: base_units.cpp:217
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:210
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:114
#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:1297
void RemoveDrawItem(LIB_ITEM *aItem)
Remove draw aItem from list.
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:1571
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39