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 
26 #include <fctsys.h>
27 #include <pgm_base.h>
28 #include <sch_draw_panel.h>
29 #include <sch_edit_frame.h>
30 #include <base_units.h>
31 #include <msgpanel.h>
32 #include <general.h>
33 #include <lib_edit_frame.h>
34 #include <class_libentry.h>
35 #include <lib_pin.h>
38 #include "sch_painter.h"
39 
40 // small margin in internal units between the pin text and the pin line
41 #define PIN_TEXT_MARGIN 4
42 
44 {
45  // These strings are the canonical name of the electrictal type
46  // Not translated, no space in name, only ASCII chars.
47  // to use when the string name must be known and well defined
48  // must have same order than enum ELECTRICAL_PINTYPE (see lib_pin.h)
49  static const wxChar* msgPinElectricType[] =
50  {
51  wxT( "input" ),
52  wxT( "output" ),
53  wxT( "BiDi" ),
54  wxT( "3state" ),
55  wxT( "passive" ),
56  wxT( "unspc" ),
57  wxT( "power_in" ),
58  wxT( "power_out" ),
59  wxT( "openCol" ),
60  wxT( "openEm" ),
61  wxT( "NotConnected" )
62  };
63 
64  return msgPinElectricType[static_cast<int>( aType )];
65 }
66 
67 
69 // i.e. the clock symbols (falling clock is actually external but is of
70 // the same kind)
71 
72 static int internalPinDecoSize( RENDER_SETTINGS* aSettings, const LIB_PIN &aPin )
73 {
74  KIGFX::SCH_RENDER_SETTINGS* settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( aSettings );
75 
76  if( settings && settings->m_PinSymbolSize )
77  return settings->m_PinSymbolSize;
78 
79  return aPin.GetNameTextSize() != 0 ? aPin.GetNameTextSize() / 2 : aPin.GetNumberTextSize() / 2;
80 }
81 
83 // i.e. the negation circle, the polarity 'slopes' and the nonlogic
84 // marker
85 static int externalPinDecoSize( RENDER_SETTINGS* aSettings, const LIB_PIN &aPin )
86 {
87  KIGFX::SCH_RENDER_SETTINGS* settings = static_cast<KIGFX::SCH_RENDER_SETTINGS*>( aSettings );
88 
89  if( settings && settings->m_PinSymbolSize )
90  return settings->m_PinSymbolSize;
91 
92  return aPin.GetNumberTextSize() / 2;
93 }
94 
95 
97  LIB_ITEM( LIB_PIN_T, aParent )
98 {
99  m_orientation = PIN_RIGHT; // Pin orient: Up, Down, Left, Right
100  m_type = ELECTRICAL_PINTYPE::PT_UNSPECIFIED; // electrical type of pin
102  m_attributes = 0; // bit 0 != 0: pin invisible
103 
104  // Use the application settings for pin sizes if exists.
105  // pgm can be nullptr when running a shared lib from a script, not from a kicad appl
106  PGM_BASE* pgm = PgmOrNull();
107 
108  if( pgm )
109  {
111  m_length = Mils2iu( settings->m_Defaults.pin_length );
112  m_numTextSize = Mils2iu( settings->m_Defaults.pin_num_size );
113  m_nameTextSize = Mils2iu( settings->m_Defaults.pin_name_size );
114  }
115  else // Use hardcoded eeschema defaults: libedit settings are not existing.
116  {
117  m_length = Mils2iu( DEFAULT_PIN_LENGTH );
118  m_numTextSize = Mils2iu( DEFAULT_PINNUM_SIZE );
120  }
121 }
122 
123 
124 bool LIB_PIN::HitTest( const wxPoint& aPosition, int aAccuracy ) const
125 {
126  EDA_RECT rect = GetBoundingBox();
127 
128  return rect.Inflate( aAccuracy ).Contains( aPosition );
129 }
130 
131 
132 bool LIB_PIN::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
133 {
134  if( m_Flags & ( STRUCT_DELETED | SKIP_STRUCT ) )
135  return false;
136 
137  EDA_RECT sel = aRect;
138 
139  if ( aAccuracy )
140  sel.Inflate( aAccuracy );
141 
142  if( aContained )
143  return sel.Contains( GetBoundingBox( false, true ) );
144 
145  return sel.Intersects( GetBoundingBox( false, true ) );
146 }
147 
148 
150 {
151  return 1;
152 }
153 
154 
155 void LIB_PIN::print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset, void* aData,
156  const TRANSFORM& aTransform )
157 {
158  PART_DRAW_OPTIONS* opts = (PART_DRAW_OPTIONS*) aData;
159  bool drawHiddenFields = opts ? opts->draw_hidden_fields : false;
160  bool showPinType = opts ? opts->show_elec_type : false;
161 
162  LIB_PART* part = GetParent();
163 
164  /* Calculate pin orient taking in account the component orientation. */
165  int orient = PinDrawOrient( aTransform );
166 
167  /* Calculate the pin position */
168  wxPoint pos1 = aTransform.TransformCoordinate( m_position ) + aOffset;
169 
170  if( IsVisible() || drawHiddenFields )
171  {
172  printPinSymbol( aSettings, pos1, orient );
173 
174  printPinTexts( aSettings, pos1, orient, part->GetPinNameOffset(), part->ShowPinNumbers(),
175  part->ShowPinNames() );
176 
177  if( showPinType )
178  printPinElectricalTypeName( aSettings, pos1, orient );
179  }
180 }
181 
182 
183 void LIB_PIN::printPinSymbol( RENDER_SETTINGS* aSettings, const wxPoint& aPos, int aOrient )
184 {
185  wxDC* DC = aSettings->GetPrintDC();
186  int MapX1, MapY1, x1, y1;
187  int width = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
188  int posX = aPos.x, posY = aPos.y, len = m_length;
190 
191  MapX1 = MapY1 = 0;
192  x1 = posX;
193  y1 = posY;
194 
195  switch( aOrient )
196  {
197  case PIN_UP: y1 = posY - len; MapY1 = 1; break;
198  case PIN_DOWN: y1 = posY + len; MapY1 = -1; break;
199  case PIN_LEFT: x1 = posX - len; MapX1 = 1; break;
200  case PIN_RIGHT: x1 = posX + len; MapX1 = -1; break;
201  }
202 
204  {
205  const int radius = externalPinDecoSize( aSettings, *this );
206  GRCircle( nullptr, DC, MapX1 * radius + x1, MapY1 * radius + y1, radius, width, color );
207 
208  GRMoveTo( MapX1 * radius * 2 + x1, MapY1 * radius * 2 + y1 );
209  GRLineTo( nullptr, DC, posX, posY, width, color );
210  }
211  else
212  {
213  GRMoveTo( x1, y1 );
214  GRLineTo( nullptr, DC, posX, posY, width, color );
215  }
216 
217  // Draw the clock shape (>)inside the symbol
221  {
222  const int clock_size = internalPinDecoSize( aSettings, *this );
223  if( MapY1 == 0 ) /* MapX1 = +- 1 */
224  {
225  GRMoveTo( x1, y1 + clock_size );
226  GRLineTo( nullptr, DC, x1 - MapX1 * clock_size * 2, y1, width, color );
227  GRLineTo( nullptr, DC, x1, y1 - clock_size, width, color );
228  }
229  else /* MapX1 = 0 */
230  {
231  GRMoveTo( x1 + clock_size, y1 );
232  GRLineTo( nullptr, DC, x1, y1 - MapY1 * clock_size * 2, width, color );
233  GRLineTo( nullptr, DC, x1 - clock_size, y1, width, color );
234  }
235  }
236 
237  // Draw the active low (or H to L active transition)
240  {
241  const int deco_size = externalPinDecoSize( aSettings, *this );
242  if( MapY1 == 0 ) /* MapX1 = +- 1 */
243  {
244  GRMoveTo( x1 + MapX1 * deco_size * 2, y1 );
245  GRLineTo( nullptr, DC, x1 + MapX1 * deco_size * 2, y1 - deco_size * 2, width, color );
246  GRLineTo( nullptr, DC, x1, y1, width, color );
247  }
248  else /* MapX1 = 0 */
249  {
250  GRMoveTo( x1, y1 + MapY1 * deco_size * 2 );
251  GRLineTo( nullptr, DC, x1 - deco_size * 2, y1 + MapY1 * deco_size * 2, width, color );
252  GRLineTo( nullptr, DC, x1, y1, width, color );
253  }
254  }
255 
256  if( m_shape == GRAPHIC_PINSHAPE::OUTPUT_LOW ) /* IEEE symbol "Active Low Output" */
257  {
258  const int deco_size = externalPinDecoSize( aSettings, *this );
259  if( MapY1 == 0 ) /* MapX1 = +- 1 */
260  {
261  GRMoveTo( x1, y1 - deco_size * 2 );
262  GRLineTo( nullptr, DC, x1 + MapX1 * deco_size * 2, y1, width, color );
263  }
264  else /* MapX1 = 0 */
265  {
266  GRMoveTo( x1 - deco_size * 2, y1 );
267  GRLineTo( nullptr, DC, x1, y1 + MapY1 * deco_size * 2, width, color );
268  }
269  }
270  else if( m_shape == GRAPHIC_PINSHAPE::NONLOGIC ) /* NonLogic pin symbol */
271  {
272  const int deco_size = externalPinDecoSize( aSettings, *this );
273  GRMoveTo( x1 - (MapX1 + MapY1) * deco_size, y1 - (MapY1 - MapX1) * deco_size );
274  GRLineTo( nullptr, DC, x1 + (MapX1 + MapY1) * deco_size,
275  y1 + ( MapY1 - MapX1 ) * deco_size, width, color );
276  GRMoveTo( x1 - (MapX1 - MapY1) * deco_size, y1 - (MapY1 + MapX1) * deco_size );
277  GRLineTo( nullptr, DC, x1 + (MapX1 - MapY1) * deco_size,
278  y1 + ( MapY1 + MapX1 ) * deco_size, width, color );
279  }
280 
281  if( m_type == ELECTRICAL_PINTYPE::PT_NC ) // Draw a N.C. symbol
282  {
283  const int deco_size = TARGET_PIN_RADIUS;
284  GRLine( nullptr, DC, posX - deco_size, posY - deco_size, posX + deco_size,
285  posY + deco_size, width, color );
286  GRLine( nullptr, DC, posX + deco_size, posY - deco_size, posX - deco_size,
287  posY + deco_size, width, color );
288  }
289 }
290 
291 
292 void LIB_PIN::printPinTexts( RENDER_SETTINGS* aSettings, wxPoint& pin_pos, int orient,
293  int TextInside, bool DrawPinNum, bool DrawPinName )
294 {
295  if( !DrawPinName && !DrawPinNum )
296  return;
297 
298  int x, y;
299  wxDC* DC = aSettings->GetPrintDC();
300  wxSize PinNameSize( m_nameTextSize, m_nameTextSize );
301  wxSize PinNumSize( m_numTextSize, m_numTextSize );
302 
303  int namePenWidth = std::max( Clamp_Text_PenSize( GetPenWidth(), m_nameTextSize, false ),
304  aSettings->GetDefaultPenWidth() );
305  int numPenWidth = std::max( Clamp_Text_PenSize( GetPenWidth(), m_numTextSize, false ),
306  aSettings->GetDefaultPenWidth() );
307 
308  int name_offset = Mils2iu( PIN_TEXT_MARGIN ) + namePenWidth;
309  int num_offset = Mils2iu( PIN_TEXT_MARGIN ) + numPenWidth;
310 
311  /* Get the num and name colors */
312  COLOR4D NameColor = aSettings->GetLayerColor( IsVisible() ? LAYER_PINNAM : LAYER_HIDDEN );
313  COLOR4D NumColor = aSettings->GetLayerColor( IsVisible() ? LAYER_PINNUM : LAYER_HIDDEN );
314 
315  int x1 = pin_pos.x;
316  int y1 = pin_pos.y;
317 
318  switch( orient )
319  {
320  case PIN_UP: y1 -= m_length; break;
321  case PIN_DOWN: y1 += m_length; break;
322  case PIN_LEFT: x1 -= m_length; break;
323  case PIN_RIGHT: x1 += m_length; break;
324  }
325 
326  if( m_name.IsEmpty() )
327  DrawPinName = false;
328 
329  if( TextInside ) // Draw the text inside, but the pin numbers outside.
330  {
331  if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
332  {
333  // It is an horizontal line
334  if( DrawPinName )
335  {
336  if( orient == PIN_RIGHT )
337  {
338  x = x1 + TextInside;
339  GRText( DC, wxPoint( x, y1 ), NameColor, m_name, TEXT_ANGLE_HORIZ,
341  namePenWidth, false, false );
342  }
343  else // Orient == PIN_LEFT
344  {
345  x = x1 - TextInside;
346  GRText( DC, wxPoint( x, y1 ), NameColor, m_name, TEXT_ANGLE_HORIZ,
348  namePenWidth, false, false );
349  }
350  }
351 
352  if( DrawPinNum )
353  {
354  GRText( DC, wxPoint( (x1 + pin_pos.x) / 2, y1 - num_offset ), NumColor, m_number,
356  GR_TEXT_VJUSTIFY_BOTTOM, numPenWidth, false, false );
357  }
358  }
359  else /* Its a vertical line. */
360  {
361  // Text is drawn from bottom to top (i.e. to negative value for Y axis)
362  if( orient == PIN_DOWN )
363  {
364  y = y1 + TextInside;
365 
366  if( DrawPinName )
367  GRText( DC, wxPoint( x1, y ), NameColor, m_name, TEXT_ANGLE_VERT, PinNameSize,
368  GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_CENTER, namePenWidth, false,
369  false );
370 
371  if( DrawPinNum )
372  GRText( DC, wxPoint( x1 - num_offset, (y1 + pin_pos.y) / 2 ), NumColor,
374  GR_TEXT_VJUSTIFY_BOTTOM, numPenWidth, false, false );
375  }
376  else /* PIN_UP */
377  {
378  y = y1 - TextInside;
379 
380  if( DrawPinName )
381  GRText( DC, wxPoint( x1, y ), NameColor, m_name, TEXT_ANGLE_VERT, PinNameSize,
382  GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_CENTER, namePenWidth, false,
383  false );
384 
385  if( DrawPinNum )
386  GRText( DC, wxPoint( x1 - num_offset, (y1 + pin_pos.y) / 2 ), NumColor,
388  GR_TEXT_VJUSTIFY_BOTTOM, numPenWidth, false, false );
389  }
390  }
391  }
392  else /**** Draw num & text pin outside ****/
393  {
394  if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
395  {
396  /* Its an horizontal line. */
397  if( DrawPinName )
398  {
399  x = (x1 + pin_pos.x) / 2;
400  GRText( DC, wxPoint( x, y1 - name_offset ), NameColor, m_name, TEXT_ANGLE_HORIZ,
402  namePenWidth, false, false );
403  }
404  if( DrawPinNum )
405  {
406  x = (x1 + pin_pos.x) / 2;
407  GRText( DC, wxPoint( x, y1 + num_offset ), NumColor, m_number, TEXT_ANGLE_HORIZ,
408  PinNumSize, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_TOP, numPenWidth,
409  false, false );
410  }
411  }
412  else /* Its a vertical line. */
413  {
414  if( DrawPinName )
415  {
416  y = (y1 + pin_pos.y) / 2;
417  GRText( DC, wxPoint( x1 - name_offset, y ), NameColor, m_name, TEXT_ANGLE_VERT,
419  namePenWidth, false, false );
420  }
421 
422  if( DrawPinNum )
423  {
424  GRText( DC, wxPoint( x1 + num_offset, (y1 + pin_pos.y) / 2 ), NumColor, m_number,
426  numPenWidth, false, false );
427  }
428  }
429  }
430 }
431 
432 
433 
435  int aOrientation )
436 {
437  wxDC* DC = aSettings->GetPrintDC();
438  wxString typeName = GetElectricalTypeName();
439 
440  // Use a reasonable (small) size to draw the text
441  int textSize = ( m_nameTextSize * 3 ) / 4;
442 
443  #define ETXT_MAX_SIZE Millimeter2iu( 0.7 )
444  if( textSize > ETXT_MAX_SIZE )
445  textSize = ETXT_MAX_SIZE;
446 
447  // Use a reasonable pen size to draw the text
448  int pensize = textSize/6;
449 
450  // Get a suitable color
452 
453  wxPoint txtpos = aPosition;
454  int offset = Millimeter2iu( 0.4 );
456  int orient = TEXT_ANGLE_HORIZ;
457 
458  switch( aOrientation )
459  {
460  case PIN_UP:
461  txtpos.y += offset;
462  orient = TEXT_ANGLE_VERT;
463  hjustify = GR_TEXT_HJUSTIFY_RIGHT;
464  break;
465 
466  case PIN_DOWN:
467  txtpos.y -= offset;
468  orient = TEXT_ANGLE_VERT;
469  break;
470 
471  case PIN_LEFT:
472  txtpos.x += offset;
473  break;
474 
475  case PIN_RIGHT:
476  txtpos.x -= offset;
477  hjustify = GR_TEXT_HJUSTIFY_RIGHT;
478  break;
479  }
480 
481  GRText( DC, txtpos, color, typeName, orient, wxSize( textSize, textSize ), hjustify,
482  GR_TEXT_VJUSTIFY_CENTER, pensize, false, false, 0 );
483 }
484 
485 
486 void LIB_PIN::PlotSymbol( PLOTTER* aPlotter, const wxPoint& aPosition, int aOrientation )
487 {
488  int MapX1, MapY1, x1, y1;
490  int penWidth = std::max( GetPenWidth(), aPlotter->RenderSettings()->GetDefaultPenWidth() );
491 
492  aPlotter->SetColor( color );
493  aPlotter->SetCurrentLineWidth( penWidth );
494 
495  MapX1 = MapY1 = 0;
496  x1 = aPosition.x; y1 = aPosition.y;
497 
498  switch( aOrientation )
499  {
500  case PIN_UP: y1 = aPosition.y - m_length; MapY1 = 1; break;
501  case PIN_DOWN: y1 = aPosition.y + m_length; MapY1 = -1; break;
502  case PIN_LEFT: x1 = aPosition.x - m_length; MapX1 = 1; break;
503  case PIN_RIGHT: x1 = aPosition.x + m_length; MapX1 = -1; break;
504  }
505 
507  {
508  const int radius = externalPinDecoSize( aPlotter->RenderSettings(), *this );
509  aPlotter->Circle( wxPoint( MapX1 * radius + x1, MapY1 * radius + y1 ), radius * 2,
510  NO_FILL, penWidth );
511 
512  aPlotter->MoveTo( wxPoint( MapX1 * radius * 2 + x1, MapY1 * radius * 2 + y1 ) );
513  aPlotter->FinishTo( aPosition );
514  }
516  {
517  const int deco_size = internalPinDecoSize( aPlotter->RenderSettings(), *this );
518  if( MapY1 == 0 ) /* MapX1 = +- 1 */
519  {
520  aPlotter->MoveTo( wxPoint( x1, y1 + deco_size ) );
521  aPlotter->LineTo( wxPoint( x1 + MapX1 * deco_size * 2, y1 ) );
522  aPlotter->FinishTo( wxPoint( x1, y1 - deco_size ) );
523  }
524  else /* MapX1 = 0 */
525  {
526  aPlotter->MoveTo( wxPoint( x1 + deco_size, y1 ) );
527  aPlotter->LineTo( wxPoint( x1, y1 + MapY1 * deco_size * 2 ) );
528  aPlotter->FinishTo( wxPoint( x1 - deco_size, y1 ) );
529  }
530 
531  aPlotter->MoveTo( wxPoint( MapX1 * deco_size * 2 + x1, MapY1 * deco_size * 2 + y1 ) );
532  aPlotter->FinishTo( aPosition );
533  }
534  else
535  {
536  aPlotter->MoveTo( wxPoint( x1, y1 ) );
537  aPlotter->FinishTo( aPosition );
538  }
539 
542  {
543  const int deco_size = internalPinDecoSize( aPlotter->RenderSettings(), *this );
544  if( MapY1 == 0 ) /* MapX1 = +- 1 */
545  {
546  aPlotter->MoveTo( wxPoint( x1, y1 + deco_size ) );
547  aPlotter->LineTo( wxPoint( x1 - MapX1 * deco_size * 2, y1 ) );
548  aPlotter->FinishTo( wxPoint( x1, y1 - deco_size ) );
549  }
550  else /* MapX1 = 0 */
551  {
552  aPlotter->MoveTo( wxPoint( x1 + deco_size, y1 ) );
553  aPlotter->LineTo( wxPoint( x1, y1 - MapY1 * deco_size * 2 ) );
554  aPlotter->FinishTo( wxPoint( x1 - deco_size, y1 ) );
555  }
556  }
557 
559  || m_shape == GRAPHIC_PINSHAPE::CLOCK_LOW ) /* IEEE symbol "Active Low Input" */
560  {
561  const int deco_size = externalPinDecoSize( aPlotter->RenderSettings(), *this );
562 
563  if( MapY1 == 0 ) /* MapX1 = +- 1 */
564  {
565  aPlotter->MoveTo( wxPoint( x1 + MapX1 * deco_size * 2, y1 ) );
566  aPlotter->LineTo( wxPoint( x1 + MapX1 * deco_size * 2, y1 - deco_size * 2 ) );
567  aPlotter->FinishTo( wxPoint( x1, y1 ) );
568  }
569  else /* MapX1 = 0 */
570  {
571  aPlotter->MoveTo( wxPoint( x1, y1 + MapY1 * deco_size * 2 ) );
572  aPlotter->LineTo( wxPoint( x1 - deco_size * 2, y1 + MapY1 * deco_size * 2 ) );
573  aPlotter->FinishTo( wxPoint( x1, y1 ) );
574  }
575  }
576 
577 
578  if( m_shape == GRAPHIC_PINSHAPE::OUTPUT_LOW ) /* IEEE symbol "Active Low Output" */
579  {
580  const int symbol_size = externalPinDecoSize( aPlotter->RenderSettings(), *this );
581 
582  if( MapY1 == 0 ) /* MapX1 = +- 1 */
583  {
584  aPlotter->MoveTo( wxPoint( x1, y1 - symbol_size * 2 ) );
585  aPlotter->FinishTo( wxPoint( x1 + MapX1 * symbol_size * 2, y1 ) );
586  }
587  else /* MapX1 = 0 */
588  {
589  aPlotter->MoveTo( wxPoint( x1 - symbol_size * 2, y1 ) );
590  aPlotter->FinishTo( wxPoint( x1, y1 + MapY1 * symbol_size * 2 ) );
591  }
592  }
593  else if( m_shape == GRAPHIC_PINSHAPE::NONLOGIC ) /* NonLogic pin symbol */
594  {
595  const int deco_size = externalPinDecoSize( aPlotter->RenderSettings(), *this );
596  aPlotter->MoveTo( wxPoint( x1 - (MapX1 + MapY1) * deco_size, y1 - (MapY1 - MapX1) * deco_size ) );
597  aPlotter->FinishTo( wxPoint( x1 + (MapX1 + MapY1) * deco_size, y1 + (MapY1 - MapX1) * deco_size ) );
598  aPlotter->MoveTo( wxPoint( x1 - (MapX1 - MapY1) * deco_size, y1 - (MapY1 + MapX1) * deco_size ) );
599  aPlotter->FinishTo( wxPoint( x1 + (MapX1 - MapY1) * deco_size, y1 + (MapY1 + MapX1) * deco_size ) );
600  }
601  if( m_type == ELECTRICAL_PINTYPE::PT_NC ) // Draw a N.C. symbol
602  {
603  const int deco_size = TARGET_PIN_RADIUS;
604  const int ex1 = aPosition.x;
605  const int ey1 = aPosition.y;
606  aPlotter->MoveTo( wxPoint( ex1 - deco_size, ey1 - deco_size ) );
607  aPlotter->FinishTo( wxPoint( ex1 + deco_size, ey1 + deco_size ) );
608  aPlotter->MoveTo( wxPoint( ex1 + deco_size, ey1 - deco_size ) );
609  aPlotter->FinishTo( wxPoint( ex1 - deco_size, ey1 + deco_size ) );
610  }
611 }
612 
613 
614 void LIB_PIN::PlotPinTexts( PLOTTER* plotter, wxPoint& pin_pos, int orient, int TextInside,
615  bool DrawPinNum, bool DrawPinName )
616 {
617  if( m_name.IsEmpty() || m_name == wxT( "~" ) )
618  DrawPinName = false;
619 
620  if( m_number.IsEmpty() )
621  DrawPinNum = false;
622 
623  if( !DrawPinNum && !DrawPinName )
624  return;
625 
626  int x, y;
627  wxSize PinNameSize = wxSize( m_nameTextSize, m_nameTextSize );
628  wxSize PinNumSize = wxSize( m_numTextSize, m_numTextSize );
629 
630  int namePenWidth = std::max( Clamp_Text_PenSize( GetPenWidth(), m_nameTextSize, false ),
631  plotter->RenderSettings()->GetDefaultPenWidth() );
632  int numPenWidth = std::max( Clamp_Text_PenSize( GetPenWidth(), m_numTextSize, false ),
633  plotter->RenderSettings()->GetDefaultPenWidth() );
634 
635  int name_offset = Mils2iu( PIN_TEXT_MARGIN ) + namePenWidth;
636  int num_offset = Mils2iu( PIN_TEXT_MARGIN ) + numPenWidth;
637 
638  /* Get the num and name colors */
639  COLOR4D NameColor = plotter->RenderSettings()->GetLayerColor( LAYER_PINNAM );
640  COLOR4D NumColor = plotter->RenderSettings()->GetLayerColor( LAYER_PINNUM );
641 
642  int x1 = pin_pos.x;
643  int y1 = pin_pos.y;
644 
645  switch( orient )
646  {
647  case PIN_UP: y1 -= m_length; break;
648  case PIN_DOWN: y1 += m_length; break;
649  case PIN_LEFT: x1 -= m_length; break;
650  case PIN_RIGHT: x1 += m_length; break;
651  }
652 
653  /* Draw the text inside, but the pin numbers outside. */
654  if( TextInside )
655  {
656  if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) ) /* Its an horizontal line. */
657  {
658  if( DrawPinName )
659  {
660  if( orient == PIN_RIGHT )
661  {
662  x = x1 + TextInside;
663  plotter->Text( wxPoint( x, y1 ), NameColor,
664  m_name,
666  PinNameSize,
669  namePenWidth, false, false );
670  }
671  else // orient == PIN_LEFT
672  {
673  x = x1 - TextInside;
674 
675  if( DrawPinName )
676  plotter->Text( wxPoint( x, y1 ),
677  NameColor, m_name, TEXT_ANGLE_HORIZ,
678  PinNameSize,
681  namePenWidth, false, false );
682  }
683  }
684  if( DrawPinNum )
685  {
686  plotter->Text( wxPoint( (x1 + pin_pos.x) / 2,
687  y1 - num_offset ),
688  NumColor, m_number,
689  TEXT_ANGLE_HORIZ, PinNumSize,
692  numPenWidth, false, false );
693  }
694  }
695  else /* Its a vertical line. */
696  {
697  if( orient == PIN_DOWN )
698  {
699  y = y1 + TextInside;
700 
701  if( DrawPinName )
702  plotter->Text( wxPoint( x1, y ), NameColor,
703  m_name,
704  TEXT_ANGLE_VERT, PinNameSize,
707  namePenWidth, false, false );
708 
709  if( DrawPinNum )
710  {
711  plotter->Text( wxPoint( x1 - num_offset,
712  (y1 + pin_pos.y) / 2 ),
713  NumColor, m_number,
714  TEXT_ANGLE_VERT, PinNumSize,
717  numPenWidth, false, false );
718  }
719  }
720  else /* PIN_UP */
721  {
722  y = y1 - TextInside;
723 
724  if( DrawPinName )
725  plotter->Text( wxPoint( x1, y ), NameColor,
726  m_name,
727  TEXT_ANGLE_VERT, PinNameSize,
730  namePenWidth, false, false );
731 
732  if( DrawPinNum )
733  {
734  plotter->Text( wxPoint( x1 - num_offset,
735  (y1 + pin_pos.y) / 2 ),
736  NumColor, m_number,
737  TEXT_ANGLE_VERT, PinNumSize,
740  numPenWidth, false, false );
741  }
742  }
743  }
744  }
745  else /* Draw num & text pin outside */
746  {
747  if( (orient == PIN_LEFT) || (orient == PIN_RIGHT) )
748  {
749  /* Its an horizontal line. */
750  if( DrawPinName )
751  {
752  x = (x1 + pin_pos.x) / 2;
753  plotter->Text( wxPoint( x, y1 - name_offset ),
754  NameColor, m_name,
755  TEXT_ANGLE_HORIZ, PinNameSize,
758  namePenWidth, false, false );
759  }
760 
761  if( DrawPinNum )
762  {
763  x = ( x1 + pin_pos.x ) / 2;
764  plotter->Text( wxPoint( x, y1 + num_offset ),
765  NumColor, m_number,
766  TEXT_ANGLE_HORIZ, PinNumSize,
769  numPenWidth, false, false );
770  }
771  }
772  else /* Its a vertical line. */
773  {
774  if( DrawPinName )
775  {
776  y = ( y1 + pin_pos.y ) / 2;
777  plotter->Text( wxPoint( x1 - name_offset, y ),
778  NameColor, m_name,
779  TEXT_ANGLE_VERT, PinNameSize,
782  namePenWidth, false, false );
783  }
784 
785  if( DrawPinNum )
786  {
787  plotter->Text( wxPoint( x1 + num_offset,
788  ( y1 + pin_pos.y ) / 2 ),
789  NumColor, m_number,
790  TEXT_ANGLE_VERT, PinNumSize,
793  numPenWidth, false, false );
794  }
795  }
796  }
797 }
798 
799 
800 int LIB_PIN::PinDrawOrient( const TRANSFORM& aTransform ) const
801 {
802  int orient;
803  wxPoint end; // position of pin end starting at 0,0 according to its orientation, length = 1
804 
805  switch( m_orientation )
806  {
807  case PIN_UP: end.y = 1; break;
808  case PIN_DOWN: end.y = -1; break;
809  case PIN_LEFT: end.x = -1; break;
810  case PIN_RIGHT: end.x = 1; break;
811  }
812 
813  // = pos of end point, according to the component orientation
814  end = aTransform.TransformCoordinate( end );
815  orient = PIN_UP;
816 
817  if( end.x == 0 )
818  {
819  if( end.y > 0 )
820  orient = PIN_DOWN;
821  }
822  else
823  {
824  orient = PIN_RIGHT;
825 
826  if( end.x < 0 )
827  orient = PIN_LEFT;
828  }
829 
830  return orient;
831 }
832 
833 
835 {
836  return new LIB_PIN( *this );
837 }
838 
839 
840 int LIB_PIN::compare( const LIB_ITEM& aOther, LIB_ITEM::COMPARE_FLAGS aCompareFlags ) const
841 {
842  wxASSERT( aOther.Type() == LIB_PIN_T );
843 
844  int retv = LIB_ITEM::compare( aOther, aCompareFlags );
845 
846  if( retv )
847  return retv;
848 
849  const LIB_PIN* tmp = (LIB_PIN*) &aOther;
850 
851  // When comparing units, we do not compare the part numbers. If everything else is
852  // identical, then we can just renumber the parts for the inherited symbol.
853  if( !( aCompareFlags & COMPARE_FLAGS::UNIT ) && m_number != tmp->m_number )
854  return m_number.Cmp( tmp->m_number );
855 
856  int result = m_name.CmpNoCase( tmp->m_name );
857 
858  if( result )
859  return result;
860 
861  if( m_position.x != tmp->m_position.x )
862  return m_position.x - tmp->m_position.x;
863 
864  if( m_position.y != tmp->m_position.y )
865  return m_position.y - tmp->m_position.y;
866 
867  if( m_length != tmp->m_length )
868  return m_length - tmp->m_length;
869 
870  if( m_orientation != tmp->m_orientation )
871  return m_orientation - tmp->m_orientation;
872 
873  if( m_shape != tmp->m_shape )
874  return static_cast<int>( m_shape ) - static_cast<int>( tmp->m_shape );
875 
876  if( m_type != tmp->m_type )
877  return static_cast<int>( m_type ) - static_cast<int>( tmp->m_type );
878 
879  if( m_attributes != tmp->m_attributes )
880  return m_attributes - tmp->m_attributes;
881 
882  if( m_numTextSize != tmp->m_numTextSize )
883  return m_numTextSize - tmp->m_numTextSize;
884 
885  if( m_nameTextSize != tmp->m_nameTextSize )
886  return m_nameTextSize - tmp->m_nameTextSize;
887 
888  return 0;
889 }
890 
891 
892 void LIB_PIN::Offset( const wxPoint& aOffset )
893 {
894  m_position += aOffset;
895 }
896 
897 
898 void LIB_PIN::MoveTo( const wxPoint& newPosition )
899 {
900  if( m_position != newPosition )
901  {
902  m_position = newPosition;
903  SetModified();
904  }
905 }
906 
907 
908 void LIB_PIN::MirrorHorizontal( const wxPoint& center )
909 {
910  m_position.x -= center.x;
911  m_position.x *= -1;
912  m_position.x += center.x;
913 
914  if( m_orientation == PIN_RIGHT )
916  else if( m_orientation == PIN_LEFT )
918 }
919 
920 
921 void LIB_PIN::MirrorVertical( const wxPoint& center )
922 {
923  m_position.y -= center.y;
924  m_position.y *= -1;
925  m_position.y += center.y;
926 
927  if( m_orientation == PIN_UP )
929  else if( m_orientation == PIN_DOWN )
931 }
932 
933 
934 void LIB_PIN::Rotate( const wxPoint& center, bool aRotateCCW )
935 {
936  int rot_angle = aRotateCCW ? -900 : 900;
937 
938  RotatePoint( &m_position, center, rot_angle );
939 
940  if( aRotateCCW )
941  {
942  switch( m_orientation )
943  {
944  case PIN_RIGHT: m_orientation = PIN_UP; break;
945  case PIN_UP: m_orientation = PIN_LEFT; break;
946  case PIN_LEFT: m_orientation = PIN_DOWN; break;
947  case PIN_DOWN: m_orientation = PIN_RIGHT; break;
948  }
949  }
950  else
951  {
952  switch( m_orientation )
953  {
954  case PIN_RIGHT: m_orientation = PIN_DOWN; break;
955  case PIN_UP: m_orientation = PIN_RIGHT; break;
956  case PIN_LEFT: m_orientation = PIN_UP; break;
957  case PIN_DOWN: m_orientation = PIN_LEFT; break;
958  }
959  }
960 }
961 
962 
963 void LIB_PIN::Plot( PLOTTER* plotter, const wxPoint& offset, bool fill,
964  const TRANSFORM& aTransform )
965 {
966  if( ! IsVisible() )
967  return;
968 
969  int orient = PinDrawOrient( aTransform );
970  wxPoint pos = aTransform.TransformCoordinate( m_position ) + offset;
971 
972  PlotSymbol( plotter, pos, orient );
973  PlotPinTexts( plotter, pos, orient, GetParent()->GetPinNameOffset(),
974  GetParent()->ShowPinNumbers(), GetParent()->ShowPinNames() );
975 }
976 
977 
979 {
980  wxString text = m_number.IsEmpty() ? wxT( "?" ) : m_number;
981 
982  LIB_ITEM::GetMsgPanelInfo( aFrame, aList );
983 
984  aList.push_back( MSG_PANEL_ITEM( _( "Name" ), m_name, DARKCYAN ) );
985  aList.push_back( MSG_PANEL_ITEM( _( "Number" ), text, DARKCYAN ) );
986  aList.push_back( MSG_PANEL_ITEM( _( "Type" ), ElectricalPinTypeGetText( m_type ), RED ) );
987 
988  text = PinShapeGetText( m_shape );
989  aList.push_back( MSG_PANEL_ITEM( _( "Style" ), text, BLUE ) );
990 
991  text = IsVisible() ? _( "Yes" ) : _( "No" );
992  aList.push_back( MSG_PANEL_ITEM( _( "Visible" ), text, DARKGREEN ) );
993 
994  // Display pin length
995  text = StringFromValue( aFrame->GetUserUnits(), m_length, true );
996  aList.push_back( MSG_PANEL_ITEM( _( "Length" ), text, MAGENTA ) );
997 
998  text = PinOrientationName( (unsigned) PinOrientationIndex( m_orientation ) );
999  aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), text, DARKMAGENTA ) );
1000 
1001  wxPoint pinpos = GetPosition();
1002  pinpos.y = -pinpos.y; // Display coord are top to bottom
1003  // lib items coord are bottom to top
1004 
1005  text = MessageTextFromValue( aFrame->GetUserUnits(), pinpos.x, true );
1006  aList.push_back( MSG_PANEL_ITEM( _( "Pos X" ), text, DARKMAGENTA ) );
1007 
1008  text = MessageTextFromValue( aFrame->GetUserUnits(), pinpos.y, true );
1009  aList.push_back( MSG_PANEL_ITEM( _( "Pos Y" ), text, DARKMAGENTA ) );
1010 }
1011 
1012 
1013 const EDA_RECT LIB_PIN::GetBoundingBox( bool aIncludeInvisibles, bool aPinOnly ) const
1014 {
1015  EDA_RECT bbox;
1016  wxPoint begin;
1017  wxPoint end;
1018  int nameTextOffset = 0;
1019  bool showName = !m_name.IsEmpty() && (m_name != wxT( "~" ));
1020  bool showNum = !m_number.IsEmpty();
1021  int minsizeV = TARGET_PIN_RADIUS;
1022 
1023  if( !aIncludeInvisibles && !IsVisible() )
1024  showName = false;
1025 
1026  if( GetParent() )
1027  {
1028  if( GetParent()->ShowPinNames() )
1029  nameTextOffset = GetParent()->GetPinNameOffset();
1030  else
1031  showName = false;
1032 
1033  if( !GetParent()->ShowPinNumbers() )
1034  showNum = false;
1035  }
1036 
1037  if( aPinOnly )
1038  {
1039  showName = false;
1040  showNum = false;
1041  }
1042 
1043  // First, calculate boundary box corners position
1044  int numberTextLength = showNum ? m_numTextSize * m_number.Len() : 0;
1045 
1046  // Actual text height is bigger than text size
1047  int numberTextHeight = showNum ? KiROUND( m_numTextSize * 1.1 ) : 0;
1048 
1050  minsizeV = std::max( TARGET_PIN_RADIUS, externalPinDecoSize( nullptr, *this ) );
1051 
1052  // calculate top left corner position
1053  // for the default pin orientation (PIN_RIGHT)
1054  begin.y = std::max( minsizeV, numberTextHeight + Mils2iu( PIN_TEXT_MARGIN ) );
1055  begin.x = std::min( -TARGET_PIN_RADIUS, m_length - (numberTextLength / 2) );
1056 
1057  // calculate bottom right corner position and adjust top left corner position
1058  int nameTextLength = 0;
1059  int nameTextHeight = 0;
1060 
1061  if( showName )
1062  {
1063  int length = m_name.Len();
1064 
1065  // Don't count the line over text symbol.
1066  if( m_name.Left( 1 ) == wxT( "~" ) )
1067  length -= 1;
1068 
1069  nameTextLength = ( m_nameTextSize * length ) + nameTextOffset;
1070 
1071  // Actual text height are bigger than text size
1072  nameTextHeight = KiROUND( m_nameTextSize * 1.1 ) + Mils2iu( PIN_TEXT_MARGIN );
1073  }
1074 
1075  if( nameTextOffset ) // for values > 0, pin name is inside the body
1076  {
1077  end.x = m_length + nameTextLength + TARGET_PIN_RADIUS;
1078  end.y = std::min( -minsizeV, -nameTextHeight / 2 );
1079  }
1080  else // if value == 0:
1081  // pin name is outside the body, and above the pin line
1082  // pin num is below the pin line
1083  {
1084  end.x = std::max( m_length + TARGET_PIN_RADIUS, nameTextLength );
1085  end.y = -begin.y;
1086  begin.y = std::max( minsizeV, nameTextHeight );
1087  }
1088 
1089  // Now, calculate boundary box corners position for the actual pin orientation
1090  int orient = PinDrawOrient( DefaultTransform );
1091 
1092  /* Calculate the pin position */
1093  switch( orient )
1094  {
1095  case PIN_UP:
1096  // Pin is rotated and texts positions are mirrored
1097  RotatePoint( &begin, wxPoint( 0, 0 ), -900 );
1098  RotatePoint( &end, wxPoint( 0, 0 ), -900 );
1099  break;
1100 
1101  case PIN_DOWN:
1102  RotatePoint( &begin, wxPoint( 0, 0 ), 900 );
1103  RotatePoint( &end, wxPoint( 0, 0 ), 900 );
1104  begin.x = -begin.x;
1105  end.x = -end.x;
1106  break;
1107 
1108  case PIN_LEFT:
1109  begin.x = -begin.x;
1110  end.x = -end.x;
1111  break;
1112 
1113  case PIN_RIGHT:
1114  break;
1115  }
1116 
1117  begin += m_position;
1118  end += m_position;
1119 
1120  bbox.SetOrigin( begin );
1121  bbox.SetEnd( end );
1122  bbox.Normalize();
1123  bbox.Inflate( ( GetPenWidth() / 2 ) + 1 );
1124 
1125  // Draw Y axis is reversed in schematic:
1126  bbox.RevertYAxis();
1127 
1128  return bbox;
1129 }
1130 
1131 
1133 {
1135 }
1136 
1137 
1138 wxString LIB_PIN::GetSelectMenuText( EDA_UNITS aUnits ) const
1139 {
1140  if( !m_name.IsEmpty() )
1141  {
1142  return wxString::Format( _( "Pin %s [%s, %s, %s]" ),
1143  m_number,
1144  m_name,
1147  }
1148  else
1149  {
1150  return wxString::Format( _( "Pin %s [%s, %s]" ),
1151  m_number,
1154  }
1155 }
1156 
1157 
1158 #if defined(DEBUG)
1159 
1160 void LIB_PIN::Show( int nestLevel, std::ostream& os ) const
1161 {
1162  NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
1163  << " num=\"" << m_number.mb_str()
1164  << '"' << "/>\n";
1165 
1166 // NestedSpace( nestLevel, os ) << "</" << GetClass().Lower().mb_str() << ">\n";
1167 }
1168 
1169 #endif
1170 
1171 void LIB_PIN::CalcEdit( const wxPoint& aPosition )
1172 {
1173  if( IsMoving() )
1174  {
1175  MoveTo( aPosition );
1176  }
1177 }
void FinishTo(const wxPoint &pos)
Definition: plotter.h:267
wxString GetClass() const override
Function GetClass returns the class name.
Definition: lib_pin.h:115
EDA_UNITS
Definition: common.h:198
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:434
#define TEXT_ANGLE_HORIZ
Frequent text rotations, used with {Set,Get}TextAngle(), in 0.1 degrees for now, hoping to migrate to...
Definition: common.h:185
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:1138
void SetModified()
Definition: base_struct.cpp:87
int m_nameTextSize
Definition: lib_pin.h:75
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: lib_pin.cpp:834
void Rotate(const wxPoint &aCenter, bool aRotateCCW=true) override
Rotate the object about aCenter point.
Definition: lib_pin.cpp:934
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:48
PNG memory record (file in memory).
Definition: bitmap_def.h:29
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:292
GRAPHIC_PINSHAPE m_shape
Definition: lib_pin.h:69
int GetPinNameOffset()
VTBL_ENTRY SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:175
#define ETXT_MAX_SIZE
RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output surfac...
Implementation of conversion functions that require both schematic and board internal units.
int m_numTextSize
Definition: lib_pin.h:74
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
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: lib_pin.cpp:1132
wxString ElectricalPinTypeGetText(ELECTRICAL_PINTYPE aType)
Definition: pin_type.cpp:239
#define SKIP_STRUCT
flag indicating that the structure should be ignored
Definition: base_struct.h:128
bool IsMoving() const
Definition: base_struct.h:200
int color
Definition: DXF_plotter.cpp:61
void printPinSymbol(RENDER_SETTINGS *aSettings, const wxPoint &aPos, int aOrientation)
Print the pin symbol without text.
Definition: lib_pin.cpp:183
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
TRANSFORM DefaultTransform
unknown electrical properties: creates always a warning when connected
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:131
int PinOrientationIndex(int code)
Definition: pin_type.cpp:149
wxString m_name
Definition: lib_pin.h:72
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:124
#define DEFAULT_PIN_LENGTH
The default pin number size when creating pins(can be changed in preference menu)
wxString PinShapeGetText(GRAPHIC_PINSHAPE aShape)
Definition: pin_type.cpp:259
Definition: lib_pin.h:50
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
const EDA_RECT GetBoundingBox() const override
Definition: lib_pin.h:218
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:800
int m_length
Definition: lib_pin.h:67
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:614
#define TEXT_ANGLE_VERT
Definition: common.h:186
bool Contains(const wxPoint &aPoint) const
Function Contains.
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
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:921
void GRLineTo(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int width, COLOR4D Color)
Definition: gr_basic.cpp:268
bool ShowPinNames()
wxString PinOrientationName(unsigned aPinOrientationCode)
Definition: pin_type.cpp:118
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:72
void LineTo(const wxPoint &pos)
Definition: plotter.h:262
int m_orientation
Definition: lib_pin.h:68
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:73
void PlotSymbol(PLOTTER *aPlotter, const wxPoint &aPosition, int aOrientation)
Definition: lib_pin.cpp:486
wxString const GetElectricalTypeName() const
Definition: lib_pin.h:142
COMPARE_FLAGS
The list of flags used by the compare function.
Definition: lib_item.h:116
void SetEnd(int x, int y)
Definition: eda_rect.h:192
Define a library symbol object.
#define STRUCT_DELETED
flag indication structures to be erased
Definition: base_struct.h:126
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:149
bool IsVisible() const
Definition: lib_pin.h:147
#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:840
int GetNameTextSize() const
Definition: lib_pin.h:174
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:155
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:232
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.
Definition: lib_pin.cpp:978
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:1171
LIB_PIN(LIB_PART *aParent)
Definition: lib_pin.cpp:96
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
wxPoint GetPosition() const override
Definition: lib_pin.h:254
void MoveTo(const wxPoint &pos)
Definition: plotter.h:257
int m_attributes
Definition: lib_pin.h:71
void GRMoveTo(int x, int y)
Definition: gr_basic.cpp:258
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
BITMAP_DEF ElectricalPinTypeGetBitmap(ELECTRICAL_PINTYPE aType)
Definition: pin_type.cpp:249
Base plotter engine class.
Definition: plotter.h:114
void MoveTo(const wxPoint &aPosition) override
Move a draw object to aPosition.
Definition: lib_pin.cpp:898
Definition: color4d.h:56
wxPoint m_position
Definition: lib_pin.h:66
RENDER_SETTINGS * RenderSettings()
Definition: plotter.h:147
int GetNumberTextSize() const
Definition: lib_pin.h:177
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:963
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:201
ELECTRICAL_PINTYPE
The component library pin object electrical types used in ERC tests.
Definition: pin_type.h:34
#define _(s)
Definition: 3d_actions.cpp:33
#define PIN_TEXT_MARGIN
Definition: lib_pin.cpp:41
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
Definition: gr_basic.cpp:598
STATUS_FLAGS m_Flags
Definition: base_struct.h:176
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
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:38
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:70
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
SCH_RENDER_SETTINGS Stores schematic-specific render settings.
Definition: sch_painter.h:70
int GetDefaultPenWidth() const
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:85
EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
wxString const GetCanonicalElectricalTypeName() const
Definition: lib_pin.h:137
PGM_BASE * PgmOrNull()
similat to PGM_BASE& Pgm(), but return a reference that can be nullptr when running a shared lib from...
not connected (must be left open)
void Offset(const wxPoint &aOffset) override
Set the drawing object by aOffset from the current position.
Definition: lib_pin.cpp:892
Message panel definition file.
static constexpr int Millimeter2iu(double mm)
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
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.
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
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:908
virtual void SetCurrentLineWidth(int width, void *aData=NULL)=0
Set the line width for the next drawing.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99