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