KiCad PCB EDA Suite
class_pad.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) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
31 #include <fctsys.h>
32 #include <trigo.h>
33 #include <macros.h>
34 #include <msgpanel.h>
35 #include <base_units.h>
36 #include <bitmaps.h>
37 #include <math/util.h> // for KiROUND
38 #include <eda_draw_frame.h>
39 #include <geometry/shape_circle.h>
40 #include <geometry/shape_segment.h>
41 #include <geometry/shape_simple.h>
42 #include <geometry/shape_rect.h>
43 #include <pcbnew.h>
44 #include <view/view.h>
45 #include <class_board.h>
46 #include <class_module.h>
47 #include <class_drawsegment.h>
49 #include <convert_to_biu.h>
51 
52 #include <memory>
53 
54 D_PAD::D_PAD( MODULE* parent ) :
56 {
57  m_Size.x = m_Size.y = Mils2iu( 60 ); // Default pad size 60 mils.
58  m_Drill.x = m_Drill.y = Mils2iu( 30 ); // Default drill size 30 mils.
59  m_Orient = 0; // Pad rotation in 1/10 degrees.
60  m_LengthPadToDie = 0;
61 
62  if( m_Parent && m_Parent->Type() == PCB_MODULE_T )
63  {
65  }
66 
67  SetShape( PAD_SHAPE_CIRCLE ); // Default pad shape is PAD_CIRCLE.
68  SetAnchorPadShape( PAD_SHAPE_CIRCLE ); // Default shape for custom shaped pads
69  // is PAD_CIRCLE.
70  SetDrillShape( PAD_DRILL_SHAPE_CIRCLE ); // Default pad drill shape is a circle.
71  m_Attribute = PAD_ATTRIB_STANDARD; // Default pad type is NORMAL (thru hole)
72  SetProperty( PAD_PROP_NONE ); // no special fabrication property
73  m_LocalClearance = 0;
77  // Parameters for round rect only:
78  m_padRoundRectRadiusScale = 0.25; // from IPC-7351C standard
79  // Parameters for chamfered rect only:
80  m_padChamferRectScale = 0.2; // Size of chamfer: ratio of smallest of X,Y size
81  m_chamferPositions = RECT_NO_CHAMFER; // No chamfered corner
82 
83  m_ZoneConnection = ZONE_CONNECTION::INHERITED; // Use parent setting by default
84  m_ThermalWidth = 0; // Use parent setting by default
85  m_ThermalGap = 0; // Use parent setting by default
86 
88 
89  // Set layers mask to default for a standard thru hole pad.
91 
92  SetSubRatsnest( 0 ); // used in ratsnest calculations
93 
94  m_shapesDirty = true;
96 }
97 
98 
100 {
101  static LSET saved = LSET::AllCuMask() | LSET( 2, B_Mask, F_Mask );
102  return saved;
103 }
104 
105 
107 {
108  static LSET saved( 3, F_Cu, F_Paste, F_Mask );
109  return saved;
110 }
111 
112 
114 {
115  static LSET saved( 2, F_Cu, F_Mask );
116  return saved;
117 }
118 
119 
121 {
122  static LSET saved = LSET::AllCuMask() | LSET( 2, B_Mask, F_Mask );
123  return saved;
124 }
125 
126 
128 {
129  static LSET saved( 1, F_Paste );
130  return saved;
131 }
132 
133 
134 bool D_PAD::IsFlipped() const
135 {
136  if( GetParent() && GetParent()->GetLayer() == B_Cu )
137  return true;
138  return false;
139 }
140 
141 
143 {
144  int radius = 0;
145  SHAPE_POLY_SET polygons;
147 
148  for( int cnt = 0; cnt < polygons.OutlineCount(); ++cnt )
149  {
150  const SHAPE_LINE_CHAIN& poly = polygons.COutline( cnt );
151 
152  for( int ii = 0; ii < poly.PointCount(); ++ii )
153  {
154  int dist = KiROUND( ( poly.CPoint( ii ) - m_Pos ).EuclideanNorm() );
155  radius = std::max( radius, dist );
156  }
157  }
158 
159  return radius + 1;
160 }
161 
162 
164 {
165  return KiROUND( std::min( m_Size.x, m_Size.y ) * m_padRoundRectRadiusScale );
166 }
167 
168 
169 void D_PAD::SetRoundRectCornerRadius( double aRadius )
170 {
171  int min_r = std::min( m_Size.x, m_Size.y );
172 
173  if( min_r > 0 )
174  SetRoundRectRadiusRatio( aRadius / min_r );
175 }
176 
177 
178 void D_PAD::SetRoundRectRadiusRatio( double aRadiusScale )
179 {
180  m_padRoundRectRadiusScale = std::max( 0.0, std::min( aRadiusScale, 0.5 ) );
181 
182  m_shapesDirty = true;
183 }
184 
185 
186 void D_PAD::SetChamferRectRatio( double aChamferScale )
187 {
188  m_padChamferRectScale = std::max( 0.0, std::min( aChamferScale, 0.5 ) );
189 
190  m_shapesDirty = true;
191 }
192 
193 
194 const std::vector<std::shared_ptr<SHAPE>>& D_PAD::GetEffectiveShapes() const
195 {
196  if( m_shapesDirty )
198 
199  return m_effectiveShapes;
200 }
201 
202 
203 const std::shared_ptr<SHAPE_SEGMENT>& D_PAD::GetEffectiveHoleShape() const
204 {
205  if( m_shapesDirty )
207 
208  return m_effectiveHoleShape;
209 }
210 
211 
213 {
214  if( m_shapesDirty )
216 
218 }
219 
220 
222 {
223  m_effectiveShapes.clear();
224  m_effectiveHoleShape = nullptr;
225 
226  auto add = [this]( SHAPE* aShape )
227  {
228  m_effectiveShapes.emplace_back( aShape );
229  };
230 
231  wxPoint shapePos = ShapePos(); // Fetch only once; rotation involves trig
232  PAD_SHAPE_T effectiveShape = GetShape();
233 
234  if( GetShape() == PAD_SHAPE_CUSTOM )
235  effectiveShape = GetAnchorPadShape();
236 
237  switch( effectiveShape )
238  {
239  case PAD_SHAPE_CIRCLE:
240  add( new SHAPE_CIRCLE( shapePos, m_Size.x / 2 ) );
241  break;
242 
243  case PAD_SHAPE_OVAL:
244  {
245  wxSize half_size = m_Size / 2;
246  int half_width = std::min( half_size.x, half_size.y );
247  wxPoint half_len( half_size.x - half_width, half_size.y - half_width );
248 
249  RotatePoint( &half_len, m_Orient );
250 
251  add( new SHAPE_SEGMENT( shapePos - half_len, shapePos + half_len, half_width * 2 ) );
252  }
253  break;
254 
255  case PAD_SHAPE_RECT:
256  if( m_Orient == 0 || m_Orient == 1800 )
257  {
258  add( new SHAPE_RECT( shapePos - m_Size / 2, m_Size.x, m_Size.y ) );
259  break;
260  }
261  else if( m_Orient == 900 || m_Orient == -900 )
262  {
263  wxSize rot_size( m_Size.y, m_Size.x );
264  add( new SHAPE_RECT( shapePos - rot_size / 2, rot_size.x, rot_size.y ) );
265  break;
266  }
267 
268  // Not at a cartesian angle; fall through to general case
270 
271  case PAD_SHAPE_TRAPEZOID:
272  case PAD_SHAPE_ROUNDRECT:
273  {
274  int r = GetRoundRectCornerRadius();
275  wxPoint half_size( m_Size.x / 2, m_Size.y / 2 );
276  wxSize trap_delta( 0, 0 );
277 
278  if( effectiveShape == PAD_SHAPE_ROUNDRECT )
279  half_size -= wxPoint( r, r );
280  else if( effectiveShape == PAD_SHAPE_TRAPEZOID )
281  trap_delta = m_DeltaSize / 2;
282 
283  SHAPE_LINE_CHAIN corners;
284 
285  corners.Append( -half_size.x + trap_delta.y, -half_size.y - trap_delta.x );
286  corners.Append( half_size.x - trap_delta.y, -half_size.y + trap_delta.x );
287  corners.Append( half_size.x + trap_delta.y, half_size.y - trap_delta.x );
288  corners.Append( -half_size.x - trap_delta.y, half_size.y + trap_delta.x );
289 
290  corners.Rotate( -DECIDEG2RAD( m_Orient ) );
291  corners.Move( shapePos );
292 
293  add( new SHAPE_SIMPLE( corners ) );
294 
295  if( effectiveShape == PAD_SHAPE_ROUNDRECT )
296  {
297  add( new SHAPE_SEGMENT( corners.CPoint( 0 ), corners.CPoint( 1 ), r * 2 ) );
298  add( new SHAPE_SEGMENT( corners.CPoint( 1 ), corners.CPoint( 2 ), r * 2 ) );
299  add( new SHAPE_SEGMENT( corners.CPoint( 2 ), corners.CPoint( 3 ), r * 2 ) );
300  add( new SHAPE_SEGMENT( corners.CPoint( 3 ), corners.CPoint( 0 ), r * 2 ) );
301  }
302  }
303  break;
304 
306  {
307  SHAPE_POLY_SET outline;
308  auto board = GetBoard();
309  int maxError = ARC_HIGH_DEF;
310 
311  if( board )
312  maxError = board->GetDesignSettings().m_MaxError;
313 
316  GetChamferPositions(), maxError );
317 
318  add( new SHAPE_SIMPLE( outline.COutline( 0 ) ) );
319  }
320  break;
321 
322  default:
323  wxFAIL_MSG( "D_PAD::buildEffectiveShapes: Unsupported pad shape: "
324  + PAD_SHAPE_T_asString( effectiveShape ) );
325  break;
326  }
327 
328  if( GetShape() == PAD_SHAPE_CUSTOM )
329  {
330  for( const std::shared_ptr<DRAWSEGMENT>& primitive : m_editPrimitives )
331  {
332  for( SHAPE* shape : primitive->MakeEffectiveShapes() )
333  {
334  shape->Rotate( -DECIDEG2RAD( m_Orient ) );
335  shape->Move( shapePos );
336  add( shape );
337  }
338  }
339  }
340 
341  // Bounding box and radius
342  //
344 
345  // reset the bbox to uninitialized state to prepare for merging
347 
348  for( const std::shared_ptr<SHAPE>& shape : m_effectiveShapes )
349  {
350  BOX2I r = shape->BBox();
352  wxSize( r.GetWidth(), r.GetHeight() ) ) );
353  }
354  // Hole shape
355  //
356  wxSize half_size = m_Drill / 2;
357  int half_width = std::min( half_size.x, half_size.y );
358  wxPoint half_len( half_size.x - half_width, half_size.y - half_width );
359 
360  RotatePoint( &half_len, m_Orient );
361 
362  m_effectiveHoleShape = std::make_shared<SHAPE_SEGMENT>( m_Pos - half_len, m_Pos + half_len,
363  half_width * 2 );
364 
365  // All done
366  //
367  m_shapesDirty = false;
368 }
369 
370 
372 {
373  if( m_shapesDirty )
375 
376  return m_effectiveBoundingBox;
377 }
378 
379 
381 {
382  MODULE* module = (MODULE*) m_Parent;
383 
384  m_Pos = m_Pos0;
385 
386  if( module == NULL )
387  return;
388 
389  double angle = module->GetOrientation();
390 
391  RotatePoint( &m_Pos.x, &m_Pos.y, angle );
392  m_Pos += module->GetPosition();
393 }
394 
395 
397 {
398  MODULE* module = (MODULE*) m_Parent;
399 
400  if( module == NULL )
401  {
402  m_Pos0 = m_Pos;
403  return;
404  }
405 
406  m_Pos0 = m_Pos - module->GetPosition();
407  RotatePoint( &m_Pos0.x, &m_Pos0.y, -module->GetOrientation() );
408 }
409 
410 
411 void D_PAD::SetAttribute( PAD_ATTR_T aAttribute )
412 {
413  m_Attribute = aAttribute;
414 
415  if( aAttribute == PAD_ATTRIB_SMD )
416  m_Drill = wxSize( 0, 0 );
417 
418  m_shapesDirty = true;
419 }
420 
421 
423 {
424  m_Property = aProperty;
425 
426  m_shapesDirty = true;
427 }
428 
429 
430 void D_PAD::SetOrientation( double aAngle )
431 {
432  NORMALIZE_ANGLE_POS( aAngle );
433  m_Orient = aAngle;
434 
435  m_shapesDirty = true;
436 }
437 
438 
439 void D_PAD::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
440 {
441  if( aFlipLeftRight )
442  {
443  MIRROR( m_Pos.x, aCentre.x );
444  MIRROR( m_Pos0.x, 0 );
445  MIRROR( m_Offset.x, 0 );
446  MIRROR( m_DeltaSize.x, 0 );
447  }
448  else
449  {
450  MIRROR( m_Pos.y, aCentre.y );
451  MIRROR( m_Pos0.y, 0 );
452  MIRROR( m_Offset.y, 0 );
453  MIRROR( m_DeltaSize.y, 0 );
454  }
455 
457 
458  // flip pads layers
459  // PADS items are currently on all copper layers, or
460  // currently, only on Front or Back layers.
461  // So the copper layers count is not taken in account
463 
464  // Flip the basic shapes, in custom pads
465  FlipPrimitives();
466 
467  m_shapesDirty = true;
468 }
469 
470 
471 // Flip the basic shapes, in custom pads
473 {
474  for( std::shared_ptr<DRAWSEGMENT>& primitive : m_editPrimitives )
475  primitive->Flip( wxPoint( 0, 0 ), false );
476 
477  m_shapesDirty = true;
478 }
479 
480 
482 {
483  for( std::shared_ptr<DRAWSEGMENT>& primitive : m_editPrimitives )
484  primitive->Flip( wxPoint( aX, 0 ), true );
485 
486  m_shapesDirty = true;
487 }
488 
489 
490 // Returns the position of the pad.
492 {
493  if( m_Offset.x == 0 && m_Offset.y == 0 )
494  return m_Pos;
495 
496  wxPoint loc_offset = m_Offset;
497 
498  RotatePoint( &loc_offset, m_Orient );
499 
500  wxPoint shape_pos = m_Pos + loc_offset;
501 
502  return shape_pos;
503 }
504 
505 
506 int D_PAD::GetLocalClearanceOverrides( wxString* aSource ) const
507 {
508  // A pad can have specific clearance that overrides its NETCLASS clearance value
509  if( GetLocalClearance() )
510  return GetLocalClearance( aSource );
511 
512  // A footprint can have a specific clearance value
513  if( GetParent() && GetParent()->GetLocalClearance() )
514  return GetParent()->GetLocalClearance( aSource );
515 
516  return 0;
517 }
518 
519 
520 int D_PAD::GetLocalClearance( wxString* aSource ) const
521 {
522  if( aSource )
523  *aSource = wxString::Format( _( "pad %s" ), GetName() );
524 
525  return m_LocalClearance;
526 }
527 
528 
529 // Mask margins handling:
530 
532 {
533  // The pad inherits the margin only to calculate a default shape,
534  // therefore only if it is also a copper layer
535  // Pads defined only on mask layers (and perhaps on other tech layers) use the shape
536  // defined by the pad settings only
537  bool isOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
538 
539  if( !isOnCopperLayer )
540  return 0;
541 
542  int margin = m_LocalSolderMaskMargin;
543 
544  MODULE* module = GetParent();
545 
546  if( module )
547  {
548  if( margin == 0 )
549  {
550  if( module->GetLocalSolderMaskMargin() )
551  margin = module->GetLocalSolderMaskMargin();
552  }
553 
554  if( margin == 0 )
555  {
556  BOARD* brd = GetBoard();
557 
558  if( brd )
559  margin = brd->GetDesignSettings().m_SolderMaskMargin;
560  }
561  }
562 
563  // ensure mask have a size always >= 0
564  if( margin < 0 )
565  {
566  int minsize = -std::min( m_Size.x, m_Size.y ) / 2;
567 
568  if( margin < minsize )
569  margin = minsize;
570  }
571 
572  return margin;
573 }
574 
575 
577 {
578  // The pad inherits the margin only to calculate a default shape,
579  // therefore only if it is also a copper layer.
580  // Pads defined only on mask layers (and perhaps on other tech layers) use the shape
581  // defined by the pad settings only
582  bool isOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
583 
584  if( !isOnCopperLayer )
585  return wxSize( 0, 0 );
586 
587  int margin = m_LocalSolderPasteMargin;
588  double mratio = m_LocalSolderPasteMarginRatio;
589 
590  MODULE* module = GetParent();
591 
592  if( module )
593  {
594  if( margin == 0 )
595  margin = module->GetLocalSolderPasteMargin();
596 
597  auto brd = GetBoard();
598 
599  if( margin == 0 && brd )
600  {
601  margin = brd->GetDesignSettings().m_SolderPasteMargin;
602  }
603 
604  if( mratio == 0.0 )
605  mratio = module->GetLocalSolderPasteMarginRatio();
606 
607  if( mratio == 0.0 && brd )
608  {
609  mratio = brd->GetDesignSettings().m_SolderPasteMarginRatio;
610  }
611  }
612 
613  wxSize pad_margin;
614  pad_margin.x = margin + KiROUND( m_Size.x * mratio );
615  pad_margin.y = margin + KiROUND( m_Size.y * mratio );
616 
617  // ensure mask have a size always >= 0
618  if( pad_margin.x < -m_Size.x / 2 )
619  pad_margin.x = -m_Size.x / 2;
620 
621  if( pad_margin.y < -m_Size.y / 2 )
622  pad_margin.y = -m_Size.y / 2;
623 
624  return pad_margin;
625 }
626 
627 
629 {
630  MODULE* module = GetParent();
631 
633  return module->GetZoneConnection();
634  else
635  return m_ZoneConnection;
636 }
637 
638 
640 {
641  MODULE* module = GetParent();
642 
643  if( m_ThermalWidth == 0 && module )
644  return module->GetThermalWidth();
645  else
646  return m_ThermalWidth;
647 }
648 
649 
651 {
652  MODULE* module = GetParent();
653 
654  if( m_ThermalGap == 0 && module )
655  return module->GetThermalGap();
656  else
657  return m_ThermalGap;
658 }
659 
660 
661 void D_PAD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
662 {
663  EDA_UNITS units = aFrame->GetUserUnits();
664  wxString msg, msg2;
665  BOARD* board = GetBoard();
667  MODULE* module = (MODULE*) m_Parent;
668 
669  if( module )
670  aList.emplace_back( _( "Footprint" ), module->GetReference(), DARKCYAN );
671 
672  aList.emplace_back( _( "Pad" ), m_name, BROWN );
673 
674  if( !GetPinFunction().IsEmpty() )
675  aList.emplace_back( _( "Pin Name" ), GetPinFunction(), BROWN );
676 
677  aList.emplace_back( _( "Net" ), UnescapeString( GetNetname() ), DARKCYAN );
678 
679  // Display the netclass name (a pad having a netcode = 0 (no net) use the
680  // default netclass for clearance):
681  if( m_netinfo->GetNet() <= 0 )
682  msg = bds.GetDefault()->GetName();
683  else
684  msg = GetNetClassName();
685 
686  aList.emplace_back( _( "NetClass" ), msg, CYAN );
687 
688  aList.emplace_back( _( "Layer" ), LayerMaskDescribe( board, m_layerMask ), DARKGREEN );
689 
690  // Show the pad shape, attribute and property
691  wxString props = ShowPadAttr();
692 
693  if( GetProperty() != PAD_PROP_NONE )
694  props += ',';
695 
696  switch( GetProperty() )
697  {
698  case PAD_PROP_NONE: break;
699  case PAD_PROP_BGA: props += _("BGA" ); break;
700  case PAD_PROP_FIDUCIAL_GLBL: props += _("Fiducial global" ); break;
701  case PAD_PROP_FIDUCIAL_LOCAL: props += _("Fiducial local" ); break;
702  case PAD_PROP_TESTPOINT: props += _("Test point" ); break;
703  case PAD_PROP_HEATSINK: props += _("Heat sink" ); break;
704  case PAD_PROP_CASTELLATED: props += _("Castellated" ); break;
705  }
706 
707  aList.emplace_back( ShowPadShape(), props, DARKGREEN );
708 
710  && m_Size.x == m_Size.y )
711  {
712  msg = MessageTextFromValue( units, m_Size.x, true );
713  aList.emplace_back( _( "Diameter" ), msg, RED );
714  }
715  else
716  {
717  msg = MessageTextFromValue( units, m_Size.x, true );
718  aList.emplace_back( _( "Width" ), msg, RED );
719 
720  msg = MessageTextFromValue( units, m_Size.y, true );
721  aList.emplace_back( _( "Height" ), msg, RED );
722  }
723 
724  if( GetPadToDieLength() )
725  {
726  msg = MessageTextFromValue(units, GetPadToDieLength(), true );
727  aList.emplace_back( _( "Length in Package" ), msg, CYAN );
728  }
729 
730  msg = MessageTextFromValue( units, m_Drill.x, true );
731 
733  {
734  aList.emplace_back( _( "Drill" ), msg, RED );
735  }
736  else
737  {
738  msg = MessageTextFromValue( units, m_Drill.x, true )
739  + wxT( "/" )
740  + MessageTextFromValue( units, m_Drill.y, true );
741  aList.emplace_back( _( "Drill X / Y" ), msg, RED );
742  }
743 
744  wxString source;
745  int clearance = GetClearance( nullptr, &source );
746 
747  msg.Printf( _( "Min Clearance: %s" ), MessageTextFromValue( units, clearance, true ) );
748  msg2.Printf( _( "(from %s)" ), source );
749  aList.emplace_back( msg, msg2, BLACK );
750 }
751 
752 
753 void D_PAD::GetOblongGeometry( const wxSize& aDrillOrPadSize,
754  wxPoint* aStartPoint, wxPoint* aEndPoint, int* aWidth ) const
755 {
756  // calculates the start point, end point and width
757  // of an equivalent segment which have the same position and width as the pad or hole
758  int delta_cx, delta_cy;
759 
760  wxSize halfsize = aDrillOrPadSize / 2;
761  wxPoint offset;
762 
763  if( aDrillOrPadSize.x > aDrillOrPadSize.y ) // horizontal
764  {
765  delta_cx = halfsize.x - halfsize.y;
766  delta_cy = 0;
767  *aWidth = aDrillOrPadSize.y;
768  }
769  else // vertical
770  {
771  delta_cx = 0;
772  delta_cy = halfsize.y - halfsize.x;
773  *aWidth = aDrillOrPadSize.x;
774  }
775 
776  RotatePoint( &delta_cx, &delta_cy, m_Orient );
777 
778  aStartPoint->x = delta_cx + offset.x;
779  aStartPoint->y = delta_cy + offset.y;
780 
781  aEndPoint->x = - delta_cx + offset.x;
782  aEndPoint->y = - delta_cy + offset.y;
783 }
784 
785 
786 bool D_PAD::HitTest( const wxPoint& aPosition, int aAccuracy ) const
787 {
788  VECTOR2I delta = aPosition - GetPosition();
789  int boundingRadius = GetBoundingRadius() + aAccuracy;
790 
791  if( delta.SquaredEuclideanNorm() > SEG::Square( boundingRadius ) )
792  return false;
793 
794  SHAPE_POLY_SET polySet;
795  TransformShapeWithClearanceToPolygon( polySet, aAccuracy );
796 
797  return polySet.Contains( aPosition );
798 }
799 
800 
801 bool D_PAD::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
802 {
803  EDA_RECT arect = aRect;
804  arect.Normalize();
805  arect.Inflate( aAccuracy );
806 
807  EDA_RECT bbox = GetBoundingBox();
808 
809  if( !arect.Intersects( bbox ) )
810  return false;
811 
812  // This covers total containment for all test cases
813  if( arect.Contains( bbox ) )
814  return true;
815 
816  SHAPE_POLY_SET selRect;
817  selRect.NewOutline();
818  selRect.Append( arect.GetOrigin() );
819  selRect.Append( VECTOR2I( arect.GetRight(), arect.GetTop() ) );
820  selRect.Append( VECTOR2I( arect.GetRight(), arect.GetBottom() ) );
821  selRect.Append( VECTOR2I( arect.GetLeft(), arect.GetBottom() ) );
822 
823  SHAPE_POLY_SET padPoly;
824  TransformShapeWithClearanceToPolygon( padPoly, aAccuracy );
825 
826  selRect.BooleanIntersection( padPoly, SHAPE_POLY_SET::PM_FAST );
827 
828  double padArea = padPoly.Outline( 0 ).Area();
829  double intersection = selRect.Outline( 0 ).Area();
830 
831  if( intersection > ( padArea * 0.99 ) )
832  return true;
833  else
834  return !aContained && intersection > 0;
835 }
836 
837 
838 int D_PAD::Compare( const D_PAD* padref, const D_PAD* padcmp )
839 {
840  int diff;
841 
842  if( ( diff = padref->GetShape() - padcmp->GetShape() ) != 0 )
843  return diff;
844 
845  if( ( diff = padref->GetDrillShape() - padcmp->GetDrillShape() ) != 0)
846  return diff;
847 
848  if( ( diff = padref->m_Drill.x - padcmp->m_Drill.x ) != 0 )
849  return diff;
850 
851  if( ( diff = padref->m_Drill.y - padcmp->m_Drill.y ) != 0 )
852  return diff;
853 
854  if( ( diff = padref->m_Size.x - padcmp->m_Size.x ) != 0 )
855  return diff;
856 
857  if( ( diff = padref->m_Size.y - padcmp->m_Size.y ) != 0 )
858  return diff;
859 
860  if( ( diff = padref->m_Offset.x - padcmp->m_Offset.x ) != 0 )
861  return diff;
862 
863  if( ( diff = padref->m_Offset.y - padcmp->m_Offset.y ) != 0 )
864  return diff;
865 
866  if( ( diff = padref->m_DeltaSize.x - padcmp->m_DeltaSize.x ) != 0 )
867  return diff;
868 
869  if( ( diff = padref->m_DeltaSize.y - padcmp->m_DeltaSize.y ) != 0 )
870  return diff;
871 
872 // TODO: test custom shapes
873 
874  // Dick: specctra_export needs this
875  // Lorenzo: gencad also needs it to implement padstacks!
876 
877 #if __cplusplus >= 201103L
878  long long d = padref->m_layerMask.to_ullong() - padcmp->m_layerMask.to_ullong();
879  if( d < 0 )
880  return -1;
881  else if( d > 0 )
882  return 1;
883 
884  return 0;
885 #else
886  // these strings are not typically constructed, since we don't get here often.
887  std::string s1 = padref->m_layerMask.to_string();
888  std::string s2 = padcmp->m_layerMask.to_string();
889  return s1.compare( s2 );
890 #endif
891 }
892 
893 
894 void D_PAD::Rotate( const wxPoint& aRotCentre, double aAngle )
895 {
896  RotatePoint( &m_Pos, aRotCentre, aAngle );
897 
898  m_Orient = NormalizeAngle360Min( m_Orient + aAngle );
899 
900  SetLocalCoord();
901 
902  m_shapesDirty = true;
903 }
904 
905 
906 wxString D_PAD::ShowPadShape() const
907 {
908  switch( GetShape() )
909  {
910  case PAD_SHAPE_CIRCLE: return _( "Circle" );
911  case PAD_SHAPE_OVAL: return _( "Oval" );
912  case PAD_SHAPE_RECT: return _( "Rect" );
913  case PAD_SHAPE_TRAPEZOID: return _( "Trap" );
914  case PAD_SHAPE_ROUNDRECT: return _( "Roundrect" );
915  case PAD_SHAPE_CHAMFERED_RECT: return _( "Chamferedrect" );
916  case PAD_SHAPE_CUSTOM: return _( "CustomShape" );
917  default: return wxT( "???" );
918  }
919 }
920 
921 
922 wxString D_PAD::ShowPadAttr() const
923 {
924  switch( GetAttribute() )
925  {
926  case PAD_ATTRIB_STANDARD: return _( "Std" );
927  case PAD_ATTRIB_SMD: return _( "SMD" );
928  case PAD_ATTRIB_CONN: return _( "Conn" );
929  case PAD_ATTRIB_HOLE_NOT_PLATED: return _( "Not Plated" );
930  default: return wxT( "???" );
931  }
932 }
933 
934 
935 wxString D_PAD::GetSelectMenuText( EDA_UNITS aUnits ) const
936 {
937  if( GetName().IsEmpty() )
938  {
939  return wxString::Format( _( "Pad of %s on %s" ),
940  GetParent()->GetReference(),
942  }
943  else
944  {
945  return wxString::Format( _( "Pad %s of %s on %s" ),
946  GetName(),
947  GetParent()->GetReference(),
949  }
950 }
951 
952 
954 {
955  return pad_xpm;
956 }
957 
958 
960 {
961  return new D_PAD( *this );
962 }
963 
964 
966 {
968  && m_Drill.x >= m_Size.x && m_Drill.y >= m_Size.y );
969 }
970 
971 
972 void D_PAD::ViewGetLayers( int aLayers[], int& aCount ) const
973 {
974  aCount = 0;
975 
976  // These 2 types of pads contain a hole
978  aLayers[aCount++] = LAYER_PADS_PLATEDHOLES;
979 
981  aLayers[aCount++] = LAYER_NON_PLATEDHOLES;
982 
983  if( IsOnLayer( F_Cu ) && IsOnLayer( B_Cu ) )
984  {
985  // Multi layer pad
986  aLayers[aCount++] = LAYER_PADS_TH;
987  aLayers[aCount++] = LAYER_PADS_NETNAMES;
988  }
989  else if( IsOnLayer( F_Cu ) )
990  {
991  aLayers[aCount++] = LAYER_PAD_FR;
992 
993  // Is this a PTH pad that has only front copper? If so, we need to also display the
994  // net name on the PTH netname layer so that it isn't blocked by the drill hole.
996  aLayers[aCount++] = LAYER_PADS_NETNAMES;
997  else
998  aLayers[aCount++] = LAYER_PAD_FR_NETNAMES;
999  }
1000  else if( IsOnLayer( B_Cu ) )
1001  {
1002  aLayers[aCount++] = LAYER_PAD_BK;
1003 
1004  // Is this a PTH pad that has only back copper? If so, we need to also display the
1005  // net name on the PTH netname layer so that it isn't blocked by the drill hole.
1007  aLayers[aCount++] = LAYER_PADS_NETNAMES;
1008  else
1009  aLayers[aCount++] = LAYER_PAD_BK_NETNAMES;
1010  }
1011  else
1012  {
1013  // Internal layers only. (Not yet supported in GUI, but is being used by Python
1014  // footprint generators and will be needed anyway once pad stacks are supported.)
1015  for ( int internal = In1_Cu; internal < In30_Cu; ++internal )
1016  {
1017  if( IsOnLayer( (PCB_LAYER_ID) internal ) )
1018  aLayers[aCount++] = internal;
1019  }
1020  }
1021 
1022  // Check non-copper layers. This list should include all the layers that the
1023  // footprint editor allows a pad to be placed on.
1024  static const PCB_LAYER_ID layers_mech[] = { F_Mask, B_Mask, F_Paste, B_Paste,
1026 
1027  for( PCB_LAYER_ID each_layer : layers_mech )
1028  {
1029  if( IsOnLayer( each_layer ) )
1030  aLayers[aCount++] = each_layer;
1031  }
1032 
1033 #ifdef __WXDEBUG__
1034  if( aCount == 0 ) // Should not occur
1035  {
1036  wxString msg;
1037  msg.Printf( wxT( "footprint %s, pad %s: could not find valid layer for pad" ),
1038  GetParent() ? GetParent()->GetReference() : "<null>",
1039  GetName().IsEmpty() ? "(unnamed)" : GetName() );
1040  wxLogWarning( msg );
1041  }
1042 #endif
1043 }
1044 
1045 
1046 unsigned int D_PAD::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
1047 {
1048  if( aView->GetPrintMode() > 0 ) // In printing mode the pad is always drawable
1049  return 0;
1050 
1051  const int HIDE = std::numeric_limits<unsigned int>::max();
1052  BOARD* board = GetBoard();
1053 
1054  // Handle Render tab switches
1056  && !aView->IsLayerVisible( LAYER_PADS_TH ) )
1057  return HIDE;
1058 
1059  if( !IsFlipped() && !aView->IsLayerVisible( LAYER_MOD_FR ) )
1060  return HIDE;
1061 
1062  if( IsFlipped() && !aView->IsLayerVisible( LAYER_MOD_BK ) )
1063  return HIDE;
1064 
1065  if( IsFrontLayer( ( PCB_LAYER_ID )aLayer ) && !aView->IsLayerVisible( LAYER_PAD_FR ) )
1066  return HIDE;
1067 
1068  if( IsBackLayer( ( PCB_LAYER_ID )aLayer ) && !aView->IsLayerVisible( LAYER_PAD_BK ) )
1069  return HIDE;
1070 
1071  // Only draw the pad if at least one of the layers it crosses is being displayed
1072  if( board && !( board->GetVisibleLayers() & GetLayerSet() ).any() )
1073  return HIDE;
1074 
1075  // Netnames will be shown only if zoom is appropriate
1076  if( IsNetnameLayer( aLayer ) )
1077  {
1078  int divisor = std::min( GetBoundingBox().GetWidth(), GetBoundingBox().GetHeight() );
1079 
1080  // Pad sizes can be zero briefly when someone is typing a number like "0.5"
1081  // in the pad properties dialog
1082  if( divisor == 0 )
1083  return HIDE;
1084 
1085  return ( Millimeter2iu( 5 ) / divisor );
1086  }
1087 
1088  // Other layers are shown without any conditions
1089  return 0;
1090 }
1091 
1092 
1093 const BOX2I D_PAD::ViewBBox() const
1094 {
1095  // Bounding box includes soldermask too
1096  int solderMaskMargin = GetSolderMaskMargin();
1097  VECTOR2I solderPasteMargin = VECTOR2D( GetSolderPasteMargin() );
1098  EDA_RECT bbox = GetBoundingBox();
1099 
1100  // Look for the biggest possible bounding box
1101  int xMargin = std::max( solderMaskMargin, solderPasteMargin.x );
1102  int yMargin = std::max( solderMaskMargin, solderPasteMargin.y );
1103 
1104  return BOX2I( VECTOR2I( bbox.GetOrigin() ) - VECTOR2I( xMargin, yMargin ),
1105  VECTOR2I( bbox.GetSize() ) + VECTOR2I( 2 * xMargin, 2 * yMargin ) );
1106 }
1107 
1108 
1109 void D_PAD::ImportSettingsFrom( const D_PAD& aMasterPad )
1110 {
1111  SetShape( aMasterPad.GetShape() );
1112  SetLayerSet( aMasterPad.GetLayerSet() );
1113  SetAttribute( aMasterPad.GetAttribute() );
1114  SetProperty( aMasterPad.GetProperty() );
1115 
1116  // The pad orientation, for historical reasons is the
1117  // pad rotation + parent rotation.
1118  // So we have to manage this parent rotation
1119  double pad_rot = aMasterPad.GetOrientation();
1120 
1121  if( aMasterPad.GetParent() )
1122  pad_rot -= aMasterPad.GetParent()->GetOrientation();
1123 
1124  if( GetParent() )
1125  pad_rot += GetParent()->GetOrientation();
1126 
1127  SetOrientation( pad_rot );
1128 
1129  SetSize( aMasterPad.GetSize() );
1130  SetDelta( wxSize( 0, 0 ) );
1131  SetOffset( aMasterPad.GetOffset() );
1132  SetDrillSize( aMasterPad.GetDrillSize() );
1133  SetDrillShape( aMasterPad.GetDrillShape() );
1135  SetChamferRectRatio( aMasterPad.GetChamferRectRatio() );
1136  SetChamferPositions( aMasterPad.GetChamferPositions() );
1137 
1138  switch( aMasterPad.GetShape() )
1139  {
1140  case PAD_SHAPE_TRAPEZOID:
1141  SetDelta( aMasterPad.GetDelta() );
1142  break;
1143 
1144  case PAD_SHAPE_CIRCLE:
1145  // ensure size.y == size.x
1146  SetSize( wxSize( GetSize().x, GetSize().x ) );
1147  break;
1148 
1149  default:
1150  ;
1151  }
1152 
1153  switch( aMasterPad.GetAttribute() )
1154  {
1155  case PAD_ATTRIB_SMD:
1156  case PAD_ATTRIB_CONN:
1157  // These pads do not have hole (they are expected to be only on one
1158  // external copper layer)
1159  SetDrillSize( wxSize( 0, 0 ) );
1160  break;
1161 
1162  default:
1163  ;
1164  }
1165 
1166  // copy also local settings:
1167  SetLocalClearance( aMasterPad.GetLocalClearance() );
1171 
1173  SetThermalWidth( aMasterPad.GetThermalWidth() );
1174  SetThermalGap( aMasterPad.GetThermalGap() );
1175 
1176  // Add or remove custom pad shapes:
1177  SetPrimitives( aMasterPad.GetPrimitives() );
1178  SetAnchorPadShape( aMasterPad.GetAnchorPadShape() );
1179 
1180  m_shapesDirty = true;
1181 }
1182 
1183 
1185 {
1186  assert( aImage->Type() == PCB_PAD_T );
1187 
1188  std::swap( *((MODULE*) this), *((MODULE*) aImage) );
1189 }
int m_LocalClearance
Local clearance.
Definition: class_pad.h:683
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:128
int m_ThermalGap
Definition: class_pad.h:696
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:712
EDA_UNITS
Definition: common.h:198
int m_LocalSolderMaskMargin
Local mask margins: when 0, the parent footprint design values are used.
Definition: class_pad.h:687
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: class_pad.cpp:953
int m_SolderMaskMargin
Solder mask margin.
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:41
std::vector< std::shared_ptr< DRAWSEGMENT > > m_editPrimitives
Definition: class_pad.h:611
double m_padRoundRectRadiusScale
scaling factor from smallest m_Size coord to corner radius, default 0.25
Definition: class_pad.h:638
int GetLocalSolderMaskMargin() const
Definition: class_pad.h:344
double GetOrientation() const
Definition: class_module.h:211
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: class_pad.cpp:959
BOX2< VECTOR2I > BOX2I
Definition: box2.h:521
SHAPE_SIMPLE.
Definition: shape_simple.h:42
EDA_ITEM * m_Parent
Linked list: Link (parent struct)
Definition: base_struct.h:174
LSET FlipLayerMask(LSET aMask, int aCopperLayersCount)
Calculate the mask layer when flipping a footprint BACK and FRONT copper layers, mask,...
Definition: lset.cpp:531
#define KI_FALLTHROUGH
double m_padChamferRectScale
scaling factor from smallest m_Size coord to chamfer value, default 0.25
Definition: class_pad.h:640
int OutlineCount() const
Returns the number of outlines in the set
static LSET StandardMask()
layer set for a through hole pad
Definition: class_pad.cpp:99
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: class_pad.cpp:786
void Merge(const EDA_RECT &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
void FlipPrimitives()
Flip the basic shapes, in custom pads.
Definition: class_pad.cpp:472
PNG memory record (file in memory).
Definition: bitmap_def.h:29
int calcBoundingRadius() const
Function calcBoundingRadius returns a calculated radius of a bounding circle for this pad.
Definition: class_pad.cpp:142
no special fabrication property
Definition: pad_shapes.h:97
like PAD_STANDARD, but not plated mechanical use only, no connection allowed
Definition: pad_shapes.h:85
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
Definition: class_pad.cpp:894
PAD_ATTR_T
Enum PAD_ATTR_T is the set of pad shapes, used with D_PAD::{Set,Get}Attribute() The double name is fo...
Definition: pad_shapes.h:78
static std::string PAD_SHAPE_T_asString(PAD_SHAPE_T a)
Definition: pad_shapes.h:45
const BITMAP_OPAQUE pad_xpm[1]
Definition: pad.cpp:41
int m_LocalSolderPasteMargin
Local solder paste margin absolute value.
Definition: class_pad.h:688
multilayer pads, usually with holes
Implementation of conversion functions that require both schematic and board internal units.
static LSET UnplatedHoleMask()
layer set for a mechanical unplated through hole pad
Definition: class_pad.cpp:120
std::vector< std::shared_ptr< SHAPE > > m_effectiveShapes
Definition: class_pad.h:616
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
PAD_SHAPE_T GetAnchorPadShape() const
Function GetAnchorPadShape.
Definition: class_pad.h:167
static LSET SMDMask()
layer set for a SMD pad on Front layer
Definition: class_pad.cpp:106
int GetTop() const
Definition: eda_rect.h:123
const wxString & GetName() const
Definition: netclass.h:96
handle color for not plated holes (holes, not pads)
int GetLocalClearance(wxString *aSource=nullptr) const override
Function GetLocalClearance returns any local clearances set in the "classic" (ie: pre-rule) system.
Definition: class_pad.cpp:520
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
bool m_shapesDirty
Definition: class_pad.h:613
D_PAD(MODULE *parent)
Definition: class_pad.cpp:54
a fiducial (usually a smd) for the full board
Definition: pad_shapes.h:99
int GetLeft() const
Definition: eda_rect.h:122
void Move(const VECTOR2I &aVector) override
ZONE_CONNECTION GetZoneConnection() const
Definition: class_module.h:247
void SetChamferPositions(int aPositions)
has meaning only for chamfered rect pads set the position of the chamfer for a 0 orientation,...
Definition: class_pad.h:487
int GetLocalClearance(wxString *aSource=nullptr) const
Definition: class_module.h:230
bool IsFlipped() const
Definition: class_pad.cpp:134
wxSize m_Size
X and Y size ( relative to orient 0)
Definition: class_pad.h:634
int GetPadToDieLength() const
Definition: class_pad.h:342
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:81
void BuildEffectiveShapes() const
Rebuilds the shape cache for the pad and clears the dirty bit.
Definition: class_pad.cpp:221
Definition: color4d.h:61
LSET GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
std::shared_ptr< SHAPE_SEGMENT > m_effectiveHoleShape
Definition: class_pad.h:617
Smd pad, used in BGA footprints.
Definition: pad_shapes.h:98
extended_type SquaredEuclideanNorm() const
Function Squared Euclidean Norm computes the squared euclidean norm of the vector,...
Definition: vector2d.h:306
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:551
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
void SetSubRatsnest(int aSubRatsnest)
Definition: class_pad.h:495
void SetDrillSize(const wxSize &aSize)
Definition: class_pad.h:225
static wxString LayerMaskDescribe(const BOARD *aBoard, LSET aMask)
Helper function Return a string (to be shown to the user) describing a layer mask.
bool Contains(const VECTOR2I &aP, int aSubpolyIndex=-1, int aAccuracy=0, bool aUseBBoxCaches=false) const
Returns true if a given subpolygon contains the point aP.
Definition: color4d.h:44
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:257
a pad used as heat sink, usually in SMD footprints
Definition: pad_shapes.h:102
void SetRoundRectRadiusRatio(double aRadiusScale)
has meaning only for rounded rect pads
Definition: class_pad.cpp:178
const wxString & GetPinFunction() const
Definition: class_pad.h:134
wxString ShowPadAttr() const
Function ShowPadAttr.
Definition: class_pad.cpp:922
The base class for create windows for drawing purpose.
PAD_PROP_T m_Property
property in fab files (BGA, FIDUCIAL, TEST POINT, CASTELLATED)
Definition: class_pad.h:674
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
int GetThermalGap() const
Definition: class_pad.cpp:650
const std::vector< std::shared_ptr< SHAPE > > & GetEffectiveShapes() const
Function GetEffectiveShapes Returns a list of SHAPE objects representing the pad's copper.
Definition: class_pad.cpp:194
int GetLocalSolderMaskMargin() const
Definition: class_module.h:227
int PointCount() const
Function PointCount()
static SEG::ecoord Square(int a)
Definition: seg.h:116
BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected and have...
bool Contains(const wxPoint &aPoint) const
Function Contains.
wxString GetNetClassName() const
Function GetNetClassName returns a pointer to the netclass of the zone.
PAD_SHAPE_T
Enum PAD_SHAPE_T is the set of pad shapes, used with D_PAD::{Set,Get}Shape()
Definition: pad_shapes.h:33
void SetLocalCoord()
Set relative coordinates.
Definition: class_pad.cpp:396
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:332
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
This file contains miscellaneous commonly used macros and functions.
int GetBottom() const
Definition: eda_rect.h:124
const wxString GetReference() const
Function GetReference.
Definition: class_module.h:433
int GetChamferPositions() const
Definition: class_pad.h:488
a pad with a castellated through hole
Definition: pad_shapes.h:103
show modules on front
ZONE_CONNECTION m_ZoneConnection
how the connection to zone is made: no connection, thermal relief ...
Definition: class_pad.h:693
double dist(const double ax, const double ay, const double bx, const double by)
Definition: delauney.h:168
void MIRROR(T &aPoint, const T &aMirrorRef)
Definition: macros.h:175
const VECTOR2I & CPoint(int aIndex) const
Function Point()
class MODULE, a footprint
Definition: typeinfo.h:89
void SetAnchorPadShape(PAD_SHAPE_T aShape)
Function SetAnchorPadShape Set the shape of the anchor pad for custm shped pads.
Definition: class_pad.h:194
int GetSolderMaskMargin() const
Function GetSolderMaskMargin.
Definition: class_pad.cpp:531
PCB_LAYER_ID
A quick note on layer IDs:
wxString m_name
pad name (pin number in schematic)
Definition: class_pad.h:600
virtual const BOX2I ViewBBox() const override
Function ViewBBox() returns the bounding box of the item covering all its layers.
Definition: class_pad.cpp:1093
LSET is a set of PCB_LAYER_IDs.
int GetLocalClearanceOverrides(wxString *aSource=nullptr) const override
Function GetLocalClearanceOverrides returns any local clearance overrides set in the "classic" (ie: p...
Definition: class_pad.cpp:506
#define NULL
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
SHAPE_POLY_SET.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
const wxPoint GetOrigin() const
Definition: eda_rect.h:114
wxString ShowPadShape() const
Function ShowPadShape.
Definition: class_pad.cpp:906
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: class_pad.cpp:935
coord_type GetWidth() const
Definition: box2.h:196
static int Compare(const D_PAD *padref, const D_PAD *padcmp)
Function Compare compares two pads and return 0 if they are equal.
Definition: class_pad.cpp:838
const wxPoint & GetOffset() const
Definition: class_pad.h:229
const std::shared_ptr< SHAPE_SEGMENT > & GetEffectiveHoleShape() const
Function GetEffectiveHoleShape Returns a list of SHAPE objects representing the pad's hole.
Definition: class_pad.cpp:203
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: class_pad.h:318
double GetChamferRectRatio() const
Definition: class_pad.h:479
int GetThermalWidth() const
Definition: class_pad.cpp:639
LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_pad.h:329
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
int GetRight() const
Definition: eda_rect.h:121
CUST_PAD_SHAPE_IN_ZONE m_customShapeClearanceArea
How to build the custom shape in zone, to create the clearance area: CUST_PAD_SHAPE_IN_ZONE_OUTLINE =...
Definition: class_pad.h:625
int m_effectiveBoundingRadius
Definition: class_pad.h:614
void SetThermalWidth(int aWidth)
Definition: class_pad.h:446
const wxString & GetName() const
Definition: class_pad.h:128
void SetSize(const wxSize &aSize)
Definition: class_pad.h:219
int GetBoundingRadius() const
Function GetBoundingRadius returns the radius of a minimum sized circle which fully encloses this pad...
Definition: class_pad.cpp:212
Definition: color4d.h:58
int m_ThermalWidth
Definition: class_pad.h:695
void SetRoundRectCornerRadius(double aRadius)
Function SetRoundRectCornerRadius Has meaning only for rounded rect pads.
Definition: class_pad.cpp:169
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on.
Definition: class_pad.cpp:972
PAD_PROP_T
Enum PAD_PROP_T is the set of pad properties used in Gerber files (Draw files, and P&P files) to defi...
Definition: pad_shapes.h:95
SHAPE.
Definition: shape.h:74
void SetZoneConnection(ZONE_CONNECTION aType)
Definition: class_pad.h:437
PAD_PROP_T GetProperty() const
Definition: class_pad.h:335
virtual unsigned int ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Function ViewGetLOD() Returns the level of detail (LOD) of the item.
Definition: class_pad.cpp:1046
const wxSize & GetDelta() const
Definition: class_pad.h:223
const wxString & GetNetname() const
Function GetNetname.
void SetDrawCoord()
Set absolute coordinates.
Definition: class_pad.cpp:380
wxSize m_DeltaSize
delta on rectangular shapes
Definition: class_pad.h:667
void BooleanIntersection(const SHAPE_POLY_SET &b, POLYGON_MODE aFastMode)
Performs boolean polyset intersection For aFastMode meaning, see function booleanOp
Like smd, does not appear on the solder paste layer (default) note also has a special attribute in Ge...
Definition: pad_shapes.h:82
int NewOutline()
Creates a new empty polygon in the set and returns its index
Definition: color4d.h:59
void SetAttribute(PAD_ATTR_T aAttribute)
Definition: class_pad.cpp:411
int GetLocalSolderPasteMargin() const
Definition: class_module.h:240
void SetLocalClearance(int aClearance)
Definition: class_pad.h:348
int m_chamferPositions
the positions of the chamfers for a 0 orientation
Definition: class_pad.h:642
ZONE_CONNECTION GetEffectiveZoneConnection() const
Return the zone connection in effect (either locally overridden or overridden in the parent module).
Definition: class_pad.cpp:628
MODULE * GetParent() const
Definition: class_pad.h:107
void SetLocalSolderPasteMarginRatio(double aRatio)
Definition: class_pad.h:354
virtual int GetClearance(BOARD_ITEM *aItem=nullptr, wxString *aSource=nullptr) const
Function GetClearance returns the clearance in internal units.
void Rotate(double aAngle, const VECTOR2I &aCenter=VECTOR2I(0, 0)) override
Function Rotate rotates all vertices by a given angle.
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
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
void SetDrillShape(PAD_DRILL_SHAPE_T aShape)
Definition: class_pad.h:317
LSET m_layerMask
Bitwise layer :1= copper layer, 15= cmp, 2..14 = internal layers 16 .
Definition: class_pad.h:663
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, int aClearanceValue, int aMaxError=ARC_HIGH_DEF, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the pad shape to a closed polygon.
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
Definition: class_pad.cpp:1184
int GetPrintMode()
Definition: view.h:692
void SetLayerSet(LSET aLayerMask)
Definition: class_pad.h:328
double GetLocalSolderPasteMarginRatio() const
Definition: class_module.h:243
smd pads, front layer
a fiducial (usually a smd) local to the parent footprint
Definition: pad_shapes.h:100
Class to handle a graphic segment.
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
wxSize GetSolderPasteMargin() const
Function GetSolderPasteMargin.
Definition: class_pad.cpp:576
wxPoint m_Pos0
Initial Pad position (i.e.
Definition: class_pad.h:669
int GetNet() const
Function GetNet.
Definition: netinfo.h:223
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
void SetLocalSolderMaskMargin(int aMargin)
Definition: class_pad.h:345
#define _(s)
Definition: 3d_actions.cpp:33
SHAPE_LINE_CHAIN.
int m_LengthPadToDie
Length net from pad to die, inside the package.
Definition: class_pad.h:678
double GetOrientation() const
Function GetOrientation returns the rotation angle of the pad in tenths of degrees,...
Definition: class_pad.h:313
NETINFO_ITEM * m_netinfo
Stores all informations about the net that item belongs to.
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:131
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
void ImportSettingsFrom(const D_PAD &aMasterPad)
Imports the pad settings from aMasterPad.
Definition: class_pad.cpp:1109
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
const wxSize & GetDrillSize() const
Definition: class_pad.h:226
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Function Flip Flip this object, i.e.
Definition: class_pad.cpp:439
wxPoint ShapePos() const
Definition: class_pad.cpp:491
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
double DECIDEG2RAD(double deg)
Definition: trigo.h:218
NETCLASS * GetDefault() const
Function GetDefault.
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
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
Definition: class_pad.cpp:661
coord_type GetHeight() const
Definition: box2.h:197
void SetShape(PAD_SHAPE_T aShape)
Set the new shape of this pad.
Definition: class_pad.h:144
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
int GetRoundRectCornerRadius() const
Definition: class_pad.cpp:163
void SetOrientation(double aAngle)
Function SetOrientation sets the rotation angle of the pad.
Definition: class_pad.cpp:430
double GetRoundRectRadiusRatio() const
Definition: class_pad.h:470
PAD_ATTR_T m_Attribute
PAD_ATTRIB_NORMAL, PAD_ATTRIB_SMD, PAD_ATTRIB_CONN, PAD_ATTRIB_HOLE_NOT_PLATED.
Definition: class_pad.h:672
void SetChamferRectRatio(double aChamferScale)
has meaning only for chamfered rect pads Set the ratio between the smaller Y or Y size and the radius...
Definition: class_pad.cpp:186
void SetLocalSolderPasteMargin(int aMargin)
Definition: class_pad.h:351
EDA_RECT m_effectiveBoundingBox
Definition: class_pad.h:615
static LSET ConnSMDMask()
layer set for a SMD pad on Front layer used for edge board connectors
Definition: class_pad.cpp:113
void SetPrimitives(const std::vector< std::shared_ptr< DRAWSEGMENT >> &aPrimitivesList)
Import to the basic shape list.
wxSize m_Drill
Drill diam (drill shape = PAD_CIRCLE) or drill size (shape = OVAL) for drill shape = PAD_CIRCLE,...
Definition: class_pad.h:630
PAD_SHAPE_T GetShape() const
Definition: class_pad.h:153
double m_Orient
in 1/10 degrees
Definition: class_pad.h:676
static LSET ApertureMask()
layer set for an aperture pad
Definition: class_pad.cpp:127
double m_LocalSolderPasteMarginRatio
Local solder mask margin ratio value of pad size The final margin is the sum of these 2 values.
Definition: class_pad.h:690
wxPoint m_Offset
m_Offset is useful only for oblong and rect pads (it can be used for other shapes,...
Definition: class_pad.h:661
const Vec & GetOrigin() const
Definition: box2.h:192
VIEW.
Definition: view.h:61
const std::vector< std::shared_ptr< DRAWSEGMENT > > & GetPrimitives() const
Accessor to the basic shape list.
Definition: class_pad.h:268
const wxSize & GetSize() const
Definition: class_pad.h:220
void SetProperty(PAD_PROP_T aProperty)
Definition: class_pad.cpp:422
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Function IsOnLayer tests to see if this object is on the given layer.
Definition: class_pad.h:499
const wxPoint GetPosition() const override
Definition: class_pad.h:161
int GetThermalWidth() const
Definition: class_module.h:250
T NormalizeAngle360Min(T Angle)
Normalize angle to be > -360.0 and < 360.0 Angle equal to -360 or +360 are set to 0.
Definition: trigo.h:237
int GetLocalSolderPasteMargin() const
Definition: class_pad.h:350
void TransformRoundChamferedRectToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aPosition, const wxSize &aSize, double aRotation, int aCornerRadius, double aChamferRatio, int aChamferCorners, int aError)
convert a rectangle with rounded corners and/or chamfered corners to a polygon Convert rounded corner...
Message panel definition file.
void SetOffset(const wxPoint &aOffset)
Definition: class_pad.h:228
a test point pad
Definition: pad_shapes.h:101
bool PadShouldBeNPTH() const
A pad whose hole is the same size as the pad is a NPTH.
Definition: class_pad.cpp:965
void GetOblongGeometry(const wxSize &aDrillOrPadSize, wxPoint *aStartPoint, wxPoint *aEndPoint, int *aWidth) const
JEY TODO: temporary until Tom is done with DRC stuff....
Definition: class_pad.cpp:753
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
void SetThermalGap(int aGap)
Definition: class_pad.h:449
const wxPoint GetPosition() const override
Definition: class_module.h:206
int GetThermalGap() const
Definition: class_module.h:253
void MirrorXPrimitives(int aX)
Mirror the primitives about a coordinate.
Definition: class_pad.cpp:481
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: class_pad.cpp:371
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
double GetLocalSolderPasteMarginRatio() const
Definition: class_pad.h:353
Additional netnames layers (not associated with a PCB layer)
void SetDelta(const wxSize &aSize)
Definition: class_pad.h:222
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
const wxSize GetSize() const
Definition: eda_rect.h:103
bool IsNetnameLayer(LAYER_NUM aLayer)
Function IsNetnameLayer tests whether a layer is a netname layer.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible() Returns information about visibility of a particular layer.
Definition: view.h:416
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
wxPoint m_Pos
pad Position on board
Definition: class_pad.h:603