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