KiCad PCB EDA Suite
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-2021 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 <base_units.h>
27 #include <bitmaps.h>
28 #include <core/mirror.h>
29 #include <math/util.h> // for KiROUND
30 #include <eda_draw_frame.h>
31 #include <geometry/shape_circle.h>
32 #include <geometry/shape_segment.h>
33 #include <geometry/shape_simple.h>
34 #include <geometry/shape_rect.h>
36 #include <kicad_string.h>
37 #include <i18n_utility.h>
38 #include <view/view.h>
39 #include <board.h>
40 #include <board_connected_item.h>
41 #include <board_design_settings.h>
42 #include <footprint.h>
43 #include <pad.h>
44 #include <pcb_shape.h>
46 #include <convert_to_biu.h>
48 #include <widgets/msgpanel.h>
49 #include <pcb_painter.h>
50 #include <wx/log.h>
51 
52 #include <memory>
53 
54 using KIGFX::PCB_PAINTER;
56 
57 
58 PAD::PAD( FOOTPRINT* parent ) :
60 {
61  m_size.x = m_size.y = Mils2iu( 60 ); // Default pad size 60 mils.
62  m_drill.x = m_drill.y = Mils2iu( 30 ); // Default drill size 30 mils.
63  m_orient = 0; // Pad rotation in 1/10 degrees.
64  m_lengthPadToDie = 0;
65 
66  if( m_parent && m_parent->Type() == PCB_FOOTPRINT_T )
67  {
69  }
70 
71  SetShape( PAD_SHAPE::CIRCLE ); // Default pad shape is PAD_CIRCLE.
72  SetAnchorPadShape( PAD_SHAPE::CIRCLE ); // Default shape for custom shaped pads
73  // is PAD_CIRCLE.
74  SetDrillShape( PAD_DRILL_SHAPE_CIRCLE ); // Default pad drill shape is a circle.
75  m_attribute = PAD_ATTRIB::PTH; // Default pad type is plated through hole
76  SetProperty( PAD_PROP::NONE ); // no special fabrication property
77  m_localClearance = 0;
81 
82  // Parameters for round rect only:
83  m_roundedCornerScale = 0.25; // from IPC-7351C standard
84 
85  // Parameters for chamfered rect only:
86  m_chamferScale = 0.2; // Size of chamfer: ratio of smallest of X,Y size
87  m_chamferPositions = RECT_NO_CHAMFER; // No chamfered corner
88 
89  m_zoneConnection = ZONE_CONNECTION::INHERITED; // Use parent setting by default
90  m_thermalWidth = 0; // Use parent setting by default
91  m_thermalGap = 0; // Use parent setting by default
92 
94 
95  // Set layers mask to default for a standard thru hole pad.
96  m_layerMask = PTHMask();
97 
98  SetSubRatsnest( 0 ); // used in ratsnest calculations
99 
100  SetDirty();
102  m_removeUnconnectedLayer = false;
103  m_keepTopBottomLayer = true;
104 }
105 
106 
107 PAD::PAD( const PAD& aOther ) :
108  BOARD_CONNECTED_ITEM( aOther.GetParent(), PCB_PAD_T )
109 {
111 
112  ImportSettingsFrom( aOther );
114  SetPosition( aOther.GetPosition() );
115  SetPos0( aOther.GetPos0() );
116  SetName( aOther.GetName() );
117  SetPinFunction( aOther.GetPinFunction() );
118  SetSubRatsnest( aOther.GetSubRatsnest() );
122  const_cast<KIID&>( m_Uuid ) = aOther.m_Uuid;
123 }
124 
125 
126 PAD& PAD::operator=( const PAD &aOther )
127 {
129 
130  ImportSettingsFrom( aOther );
132  SetPosition( aOther.GetPosition() );
133  SetPos0( aOther.GetPos0() );
134  SetName( aOther.GetName() );
135  SetPinFunction( aOther.GetPinFunction() );
136  SetSubRatsnest( aOther.GetSubRatsnest() );
140 
141  return *this;
142 }
143 
144 
145 bool PAD::IsLocked() const
146 {
147  if( GetParent() && static_cast<FOOTPRINT*>( GetParent() )->IsLocked() )
148  return true;
149 
150  return BOARD_ITEM::IsLocked();
151 };
152 
153 
155 {
156  static LSET saved = LSET::AllCuMask() | LSET( 2, F_Mask, B_Mask );
157  return saved;
158 }
159 
160 
162 {
163  static LSET saved( 3, F_Cu, F_Paste, F_Mask );
164  return saved;
165 }
166 
167 
169 {
170  static LSET saved( 2, F_Cu, F_Mask );
171  return saved;
172 }
173 
174 
176 {
177  static LSET saved = LSET( 4, F_Cu, B_Cu, F_Mask, B_Mask );
178  return saved;
179 }
180 
181 
183 {
184  static LSET saved( 1, F_Paste );
185  return saved;
186 }
187 
188 
189 bool PAD::IsFlipped() const
190 {
191  if( GetParent() && GetParent()->GetLayer() == B_Cu )
192  return true;
193  return false;
194 }
195 
196 
197 bool PAD::FlashLayer( LSET aLayers ) const
198 {
199  for( auto layer : aLayers.Seq() )
200  {
201  if( FlashLayer( layer ) )
202  return true;
203  }
204 
205  return false;
206 }
207 
208 
209 bool PAD::FlashLayer( int aLayer ) const
210 {
211  std::vector<KICAD_T> types
213 
214  // Return the "normal" shape if the caller doesn't specify a particular layer
215  if( aLayer == UNDEFINED_LAYER )
216  return true;
217 
218  BOARD* board = GetBoard();
219 
220  if( !board )
221  return false;
222 
224  if( GetAttribute() != PAD_ATTRIB::PTH )
225  return IsOnLayer( static_cast<PCB_LAYER_ID>( aLayer ) );
226 
229  return IsOnLayer( static_cast<PCB_LAYER_ID>( aLayer ) );
230 
232  return IsOnLayer( static_cast<PCB_LAYER_ID>( aLayer ) );
233 
234  // Plated through hole pads need copper on the top/bottom layers for proper soldering
235  // Unless the user has removed them in the pad dialog
236  if( m_keepTopBottomLayer && ( aLayer == F_Cu || aLayer == B_Cu ) )
237  return IsOnLayer( static_cast<PCB_LAYER_ID>( aLayer ) );
238 
239  return board->GetConnectivity()->IsConnectedOnLayer( this, static_cast<int>( aLayer ), types );
240 }
241 
242 
244 {
245  return KiROUND( std::min( m_size.x, m_size.y ) * m_roundedCornerScale );
246 }
247 
248 
249 void PAD::SetRoundRectCornerRadius( double aRadius )
250 {
251  int min_r = std::min( m_size.x, m_size.y );
252 
253  if( min_r > 0 )
254  SetRoundRectRadiusRatio( aRadius / min_r );
255 }
256 
257 
258 void PAD::SetRoundRectRadiusRatio( double aRadiusScale )
259 {
260  m_roundedCornerScale = std::max( 0.0, std::min( aRadiusScale, 0.5 ) );
261 
262  SetDirty();
263 }
264 
265 
266 void PAD::SetChamferRectRatio( double aChamferScale )
267 {
268  m_chamferScale = std::max( 0.0, std::min( aChamferScale, 0.5 ) );
269 
270  SetDirty();
271 }
272 
273 
274 const std::shared_ptr<SHAPE_POLY_SET>& PAD::GetEffectivePolygon() const
275 {
276  if( m_polyDirty )
278 
279  return m_effectivePolygon;
280 }
281 
282 
283 std::shared_ptr<SHAPE> PAD::GetEffectiveShape( PCB_LAYER_ID aLayer ) const
284 {
285  if( m_shapesDirty )
286  BuildEffectiveShapes( aLayer );
287 
288  return m_effectiveShape;
289 }
290 
291 
293 {
294  if( m_shapesDirty )
296 
297  return m_effectiveHoleShape.get();
298 }
299 
300 
302 {
303  if( m_polyDirty )
305 
307 }
308 
309 
311 {
312  std::lock_guard<std::mutex> RAII_lock( m_shapesBuildingLock );
313 
314  // If we had to wait for the lock then we were probably waiting for someone else to
315  // finish rebuilding the shapes. So check to see if they're clean now.
316  if( !m_shapesDirty )
317  return;
318 
319  BOARD* board = GetBoard();
320  int maxError = board ? board->GetDesignSettings().m_MaxError : ARC_HIGH_DEF;
321 
322  m_effectiveShape = std::make_shared<SHAPE_COMPOUND>();
323  m_effectiveHoleShape = nullptr;
324 
325  auto add = [this]( SHAPE* aShape )
326  {
327  m_effectiveShape->AddShape( aShape );
328  };
329 
330  wxPoint shapePos = ShapePos(); // Fetch only once; rotation involves trig
331  PAD_SHAPE effectiveShape = GetShape();
332 
333  if( GetShape() == PAD_SHAPE::CUSTOM )
334  effectiveShape = GetAnchorPadShape();
335 
336  switch( effectiveShape )
337  {
338  case PAD_SHAPE::CIRCLE:
339  add( new SHAPE_CIRCLE( shapePos, m_size.x / 2 ) );
340  break;
341 
342  case PAD_SHAPE::OVAL:
343  if( m_size.x == m_size.y ) // the oval pad is in fact a circle
344  {
345  add( new SHAPE_CIRCLE( shapePos, m_size.x / 2 ) );
346  }
347  else
348  {
349  wxSize half_size = m_size / 2;
350  int half_width = std::min( half_size.x, half_size.y );
351  wxPoint half_len( half_size.x - half_width, half_size.y - half_width );
352  RotatePoint( &half_len, m_orient );
353  add( new SHAPE_SEGMENT( shapePos - half_len, shapePos + half_len, half_width * 2 ) );
354  }
355 
356  break;
357 
358  case PAD_SHAPE::RECT:
361  {
362  int r = ( effectiveShape == PAD_SHAPE::ROUNDRECT ) ? GetRoundRectCornerRadius() : 0;
363  wxPoint half_size( m_size.x / 2, m_size.y / 2 );
364  wxSize trap_delta( 0, 0 );
365 
366  if( r )
367  {
368  half_size -= wxPoint( r, r );
369 
370  // Avoid degenerated shapes (0 length segments) that always create issues
371  // For roundrect pad very near a circle, use only a circle
372  const int min_len = Millimeter2iu( 0.0001);
373 
374  if( half_size.x < min_len && half_size.y < min_len )
375  {
376  add( new SHAPE_CIRCLE( shapePos, r ) );
377  break;
378  }
379  }
380  else if( effectiveShape == PAD_SHAPE::TRAPEZOID )
381  {
382  trap_delta = m_deltaSize / 2;
383  }
384 
385  SHAPE_LINE_CHAIN corners;
386 
387  corners.Append( -half_size.x - trap_delta.y, half_size.y + trap_delta.x );
388  corners.Append( half_size.x + trap_delta.y, half_size.y - trap_delta.x );
389  corners.Append( half_size.x - trap_delta.y, -half_size.y + trap_delta.x );
390  corners.Append( -half_size.x + trap_delta.y, -half_size.y - trap_delta.x );
391 
392  corners.Rotate( -DECIDEG2RAD( m_orient ) );
393  corners.Move( shapePos );
394 
395  // GAL renders rectangles faster than 4-point polygons so it's worth checking if our
396  // body shape is a rectangle.
397  if( corners.PointCount() == 4
398  &&
399  ( ( corners.CPoint( 0 ).y == corners.CPoint( 1 ).y
400  && corners.CPoint( 1 ).x == corners.CPoint( 2 ).x
401  && corners.CPoint( 2 ).y == corners.CPoint( 3 ).y
402  && corners.CPoint( 3 ).x == corners.CPoint( 0 ).x )
403  ||
404  ( corners.CPoint( 0 ).x == corners.CPoint( 1 ).x
405  && corners.CPoint( 1 ).y == corners.CPoint( 2 ).y
406  && corners.CPoint( 2 ).x == corners.CPoint( 3 ).x
407  && corners.CPoint( 3 ).y == corners.CPoint( 0 ).y )
408  )
409  )
410  {
411  int width = std::abs( corners.CPoint( 2 ).x - corners.CPoint( 0 ).x );
412  int height = std::abs( corners.CPoint( 2 ).y - corners.CPoint( 0 ).y );
413  VECTOR2I pos( std::min( corners.CPoint( 2 ).x, corners.CPoint( 0 ).x ),
414  std::min( corners.CPoint( 2 ).y, corners.CPoint( 0 ).y ) );
415 
416  add( new SHAPE_RECT( pos, width, height ) );
417  }
418  else
419  {
420  add( new SHAPE_SIMPLE( corners ) );
421  }
422 
423  if( r )
424  {
425  add( new SHAPE_SEGMENT( corners.CPoint( 0 ), corners.CPoint( 1 ), r * 2 ) );
426  add( new SHAPE_SEGMENT( corners.CPoint( 1 ), corners.CPoint( 2 ), r * 2 ) );
427  add( new SHAPE_SEGMENT( corners.CPoint( 2 ), corners.CPoint( 3 ), r * 2 ) );
428  add( new SHAPE_SEGMENT( corners.CPoint( 3 ), corners.CPoint( 0 ), r * 2 ) );
429  }
430  }
431  break;
432 
434  {
435  SHAPE_POLY_SET outline;
436 
439  GetChamferPositions(), 0, maxError, ERROR_INSIDE );
440 
441  add( new SHAPE_SIMPLE( outline.COutline( 0 ) ) );
442  }
443  break;
444 
445  default:
446  wxFAIL_MSG( "PAD::buildEffectiveShapes: Unsupported pad shape: "
447  + PAD_SHAPE_T_asString( effectiveShape ) );
448  break;
449  }
450 
451  if( GetShape() == PAD_SHAPE::CUSTOM )
452  {
453  for( const std::shared_ptr<PCB_SHAPE>& primitive : m_editPrimitives )
454  {
455  for( SHAPE* shape : primitive->MakeEffectiveShapes() )
456  {
457  shape->Rotate( -DECIDEG2RAD( m_orient ) );
458  shape->Move( shapePos );
459  add( shape );
460  }
461  }
462  }
463 
464  BOX2I bbox = m_effectiveShape->BBox();
465  m_effectiveBoundingBox = EDA_RECT( (wxPoint) bbox.GetPosition(),
466  wxSize( bbox.GetWidth(), bbox.GetHeight() ) );
467 
468  // Hole shape
469  wxSize half_size = m_drill / 2;
470  int half_width = std::min( half_size.x, half_size.y );
471  wxPoint half_len( half_size.x - half_width, half_size.y - half_width );
472 
473  RotatePoint( &half_len, m_orient );
474 
475  m_effectiveHoleShape = std::make_shared<SHAPE_SEGMENT>( m_pos - half_len, m_pos + half_len,
476  half_width * 2 );
477 
478  // All done
479  m_shapesDirty = false;
480 }
481 
482 
484 {
485  std::lock_guard<std::mutex> RAII_lock( m_polyBuildingLock );
486 
487  // If we had to wait for the lock then we were probably waiting for someone else to
488  // finish rebuilding the shapes. So check to see if they're clean now.
489  if( !m_polyDirty )
490  return;
491 
492  BOARD* board = GetBoard();
493  int maxError = board ? board->GetDesignSettings().m_MaxError : ARC_HIGH_DEF;
494 
495  // Polygon
496  m_effectivePolygon = std::make_shared<SHAPE_POLY_SET>();
498  ERROR_INSIDE );
499 
500  // Bounding radius
501  //
502  // PADSTACKS TODO: these will both need to cycle through all layers to get the largest
503  // values....
505 
506  for( int cnt = 0; cnt < m_effectivePolygon->OutlineCount(); ++cnt )
507  {
508  const SHAPE_LINE_CHAIN& poly = m_effectivePolygon->COutline( cnt );
509 
510  for( int ii = 0; ii < poly.PointCount(); ++ii )
511  {
512  int dist = KiROUND( ( poly.CPoint( ii ) - m_pos ).EuclideanNorm() );
514  }
515  }
516 
517  // All done
518  m_polyDirty = false;
519 }
520 
521 
523 {
524  if( m_shapesDirty )
526 
527  return m_effectiveBoundingBox;
528 }
529 
530 
532 {
533  FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( m_parent );
534 
535  m_pos = m_pos0;
536 
537  if( parentFootprint == nullptr )
538  return;
539 
540  double angle = parentFootprint->GetOrientation();
541 
542  RotatePoint( &m_pos.x, &m_pos.y, angle );
543  m_pos += parentFootprint->GetPosition();
544 
545  SetDirty();
546 }
547 
548 
550 {
551  FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( m_parent );
552 
553  if( parentFootprint == nullptr )
554  {
555  m_pos0 = m_pos;
556  return;
557  }
558 
559  m_pos0 = m_pos - parentFootprint->GetPosition();
560  RotatePoint( &m_pos0.x, &m_pos0.y, -parentFootprint->GetOrientation() );
561 }
562 
563 
564 void PAD::SetAttribute( PAD_ATTRIB aAttribute )
565 {
566  m_attribute = aAttribute;
567 
568  if( aAttribute == PAD_ATTRIB::SMD )
569  m_drill = wxSize( 0, 0 );
570 
571  SetDirty();
572 }
573 
574 
575 void PAD::SetProperty( PAD_PROP aProperty )
576 {
577  m_property = aProperty;
578 
579  SetDirty();
580 }
581 
582 
583 void PAD::SetOrientation( double aAngle )
584 {
585  NORMALIZE_ANGLE_POS( aAngle );
586  m_orient = aAngle;
587 
588  SetDirty();
589 }
590 
591 
592 void PAD::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
593 {
594  if( aFlipLeftRight )
595  {
596  MIRROR( m_pos.x, aCentre.x );
597  MIRROR( m_pos0.x, 0 );
598  MIRROR( m_offset.x, 0 );
599  MIRROR( m_deltaSize.x, 0 );
600  }
601  else
602  {
603  MIRROR( m_pos.y, aCentre.y );
604  MIRROR( m_pos0.y, 0 );
605  MIRROR( m_offset.y, 0 );
606  MIRROR( m_deltaSize.y, 0 );
607  }
608 
610 
611  auto mirrorBitFlags = []( int& aBitfield, int a, int b )
612  {
613  bool temp = aBitfield & a;
614 
615  if( aBitfield & b )
616  aBitfield |= a;
617  else
618  aBitfield &= ~a;
619 
620  if( temp )
621  aBitfield |= b;
622  else
623  aBitfield &= ~b;
624  };
625 
626  if( aFlipLeftRight )
627  {
630  }
631  else
632  {
635  }
636 
637  // flip pads layers
638  // PADS items are currently on all copper layers, or
639  // currently, only on Front or Back layers.
640  // So the copper layers count is not taken in account
642 
643  // Flip the basic shapes, in custom pads
644  FlipPrimitives( aFlipLeftRight );
645 
646  SetDirty();
647 }
648 
649 
650 void PAD::FlipPrimitives( bool aFlipLeftRight )
651 {
652  for( std::shared_ptr<PCB_SHAPE>& primitive : m_editPrimitives )
653  primitive->Flip( wxPoint( 0, 0 ), aFlipLeftRight );
654 
655  SetDirty();
656 }
657 
658 
659 wxPoint PAD::ShapePos() const
660 {
661  if( m_offset.x == 0 && m_offset.y == 0 )
662  return m_pos;
663 
664  wxPoint loc_offset = m_offset;
665 
666  RotatePoint( &loc_offset, m_orient );
667 
668  wxPoint shape_pos = m_pos + loc_offset;
669 
670  return shape_pos;
671 }
672 
673 
674 int PAD::GetLocalClearanceOverrides( wxString* aSource ) const
675 {
676  // A pad can have specific clearance that overrides its NETCLASS clearance value
677  if( GetLocalClearance() )
678  return GetLocalClearance( aSource );
679 
680  // A footprint can have a specific clearance value
681  if( GetParent() && GetParent()->GetLocalClearance() )
682  return GetParent()->GetLocalClearance( aSource );
683 
684  return 0;
685 }
686 
687 
688 int PAD::GetLocalClearance( wxString* aSource ) const
689 {
690  if( aSource )
691  *aSource = wxString::Format( _( "pad %s" ), GetName() );
692 
693  return m_localClearance;
694 }
695 
696 
698 {
699  // The pad inherits the margin only to calculate a default shape,
700  // therefore only if it is also a copper layer
701  // Pads defined only on mask layers (and perhaps on other tech layers) use the shape
702  // defined by the pad settings only
703  bool isOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
704 
705  if( !isOnCopperLayer )
706  return 0;
707 
708  int margin = m_localSolderMaskMargin;
709 
710  FOOTPRINT* parentFootprint = GetParent();
711 
712  if( parentFootprint )
713  {
714  if( margin == 0 )
715  {
716  if( parentFootprint->GetLocalSolderMaskMargin() )
717  margin = parentFootprint->GetLocalSolderMaskMargin();
718  }
719 
720  if( margin == 0 )
721  {
722  BOARD* brd = GetBoard();
723 
724  if( brd )
725  margin = brd->GetDesignSettings().m_SolderMaskMargin;
726  }
727  }
728 
729  // ensure mask have a size always >= 0
730  if( margin < 0 )
731  {
732  int minsize = -std::min( m_size.x, m_size.y ) / 2;
733 
734  if( margin < minsize )
735  margin = minsize;
736  }
737 
738  return margin;
739 }
740 
741 
743 {
744  // The pad inherits the margin only to calculate a default shape,
745  // therefore only if it is also a copper layer.
746  // Pads defined only on mask layers (and perhaps on other tech layers) use the shape
747  // defined by the pad settings only
748  bool isOnCopperLayer = ( m_layerMask & LSET::AllCuMask() ).any();
749 
750  if( !isOnCopperLayer )
751  return wxSize( 0, 0 );
752 
753  int margin = m_localSolderPasteMargin;
754  double mratio = m_localSolderPasteMarginRatio;
755 
756  FOOTPRINT* parentFootprint = GetParent();
757 
758  if( parentFootprint )
759  {
760  if( margin == 0 )
761  margin = parentFootprint->GetLocalSolderPasteMargin();
762 
763  auto brd = GetBoard();
764 
765  if( margin == 0 && brd )
766  margin = brd->GetDesignSettings().m_SolderPasteMargin;
767 
768  if( mratio == 0.0 )
769  mratio = parentFootprint->GetLocalSolderPasteMarginRatio();
770 
771  if( mratio == 0.0 && brd )
772  {
773  mratio = brd->GetDesignSettings().m_SolderPasteMarginRatio;
774  }
775  }
776 
777  wxSize pad_margin;
778  pad_margin.x = margin + KiROUND( m_size.x * mratio );
779  pad_margin.y = margin + KiROUND( m_size.y * mratio );
780 
781  // ensure mask have a size always >= 0
782  if( pad_margin.x < -m_size.x / 2 )
783  pad_margin.x = -m_size.x / 2;
784 
785  if( pad_margin.y < -m_size.y / 2 )
786  pad_margin.y = -m_size.y / 2;
787 
788  return pad_margin;
789 }
790 
791 
793 {
794  FOOTPRINT* parentFootprint = GetParent();
795 
796  if( m_zoneConnection == ZONE_CONNECTION::INHERITED && parentFootprint )
797  {
798  if( aSource )
799  *aSource = _( "parent footprint" );
800 
801  return parentFootprint->GetZoneConnection();
802  }
803  else
804  {
805  if( aSource )
806  *aSource = _( "pad" );
807 
808  return m_zoneConnection;
809  }
810 }
811 
812 
813 int PAD::GetEffectiveThermalSpokeWidth( wxString* aSource ) const
814 {
815  FOOTPRINT* parentFootprint = GetParent();
816 
817  if( m_thermalWidth == 0 && parentFootprint )
818  {
819  if( aSource )
820  *aSource = _( "parent footprint" );
821 
822  return parentFootprint->GetThermalWidth();
823  }
824 
825  if( aSource )
826  *aSource = _( "pad" );
827 
828  return m_thermalWidth;
829 }
830 
831 
832 int PAD::GetEffectiveThermalGap( wxString* aSource ) const
833 {
834  FOOTPRINT* parentFootprint = GetParent();
835 
836  if( m_thermalGap == 0 && parentFootprint )
837  {
838  if( aSource )
839  *aSource = _( "parent footprint" );
840 
841  return parentFootprint->GetThermalGap();
842  }
843 
844  if( aSource )
845  *aSource = _( "pad" );
846 
847  return m_thermalGap;
848 }
849 
850 
851 void PAD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
852 {
853  EDA_UNITS units = aFrame->GetUserUnits();
854  wxString msg;
855  FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( m_parent );
856 
857  if( parentFootprint )
858  aList.emplace_back( _( "Footprint" ), parentFootprint->GetReference() );
859 
860  aList.emplace_back( _( "Pad" ), m_name );
861 
862  if( !GetPinFunction().IsEmpty() )
863  aList.emplace_back( _( "Pin Name" ), GetPinFunction() );
864 
865  if( !GetPinType().IsEmpty() )
866  aList.emplace_back( _( "Pin Type" ), GetPinType() );
867 
868  aList.emplace_back( _( "Net" ), UnescapeString( GetNetname() ) );
869 
870  aList.emplace_back( _( "NetClass" ), UnescapeString( GetNetClass()->GetName() ) );
871 
872  if( IsLocked() )
873  aList.emplace_back( _( "Status" ), _( "Locked" ) );
874 
876  aList.emplace_back( _( "Layer" ), layerMaskDescribe() );
877 
878  // Show the pad shape, attribute and property
879  wxString props = ShowPadAttr();
880 
881  if( GetProperty() != PAD_PROP::NONE )
882  props += ',';
883 
884  switch( GetProperty() )
885  {
886  case PAD_PROP::NONE: break;
887  case PAD_PROP::BGA: props += _("BGA" ); break;
888  case PAD_PROP::FIDUCIAL_GLBL: props += _("Fiducial global" ); break;
889  case PAD_PROP::FIDUCIAL_LOCAL: props += _("Fiducial local" ); break;
890  case PAD_PROP::TESTPOINT: props += _("Test point" ); break;
891  case PAD_PROP::HEATSINK: props += _("Heat sink" ); break;
892  case PAD_PROP::CASTELLATED: props += _("Castellated" ); break;
893  }
894 
895  aList.emplace_back( ShowPadShape(), props );
896 
897  if( ( GetShape() == PAD_SHAPE::CIRCLE || GetShape() == PAD_SHAPE::OVAL ) &&
898  m_size.x == m_size.y )
899  {
900  aList.emplace_back( _( "Diameter" ), MessageTextFromValue( units, m_size.x ) );
901  }
902  else
903  {
904  aList.emplace_back( _( "Width" ), MessageTextFromValue( units, m_size.x ) );
905  aList.emplace_back( _( "Height" ), MessageTextFromValue( units, m_size.y ) );
906  }
907 
908  double fp_orient_degrees = parentFootprint ? parentFootprint->GetOrientationDegrees() : 0;
909  double pad_orient_degrees = GetOrientationDegrees() - fp_orient_degrees;
910  pad_orient_degrees = NormalizeAngleDegrees( pad_orient_degrees, -180.0, +180.0 );
911 
912  if( fp_orient_degrees != 0.0 )
913  msg.Printf( wxT( "%g(+ %g)" ), pad_orient_degrees, fp_orient_degrees );
914  else
915  msg.Printf( wxT( "%g" ), GetOrientationDegrees() );
916 
917  aList.emplace_back( _( "Rotation" ), msg );
918 
919  if( GetPadToDieLength() )
920  {
921  msg = MessageTextFromValue(units, GetPadToDieLength() );
922  aList.emplace_back( _( "Length in Package" ), msg );
923  }
924 
925  if( m_drill.x > 0 || m_drill.y > 0 )
926  {
928  {
929  aList.emplace_back( _( "Hole" ),
930  wxString::Format( "%s",
931  MessageTextFromValue( units, m_drill.x ) ) );
932  }
933  else
934  {
935  aList.emplace_back( _( "Hole X / Y" ),
936  wxString::Format( "%s / %s",
937  MessageTextFromValue( units, m_drill.x ),
938  MessageTextFromValue( units, m_drill.y ) ) );
939  }
940  }
941 
942  wxString source;
943  int clearance = GetOwnClearance( GetLayer(), &source );
944 
945  aList.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
946  MessageTextFromValue( units, clearance ) ),
947  wxString::Format( _( "(from %s)" ), source ) );
948 #if 0
949  // useful for debug only
950  aList.emplace_back( "UUID", m_Uuid.AsString() );
951 #endif
952 }
953 
954 
955 bool PAD::HitTest( const wxPoint& aPosition, int aAccuracy ) const
956 {
957  VECTOR2I delta = aPosition - GetPosition();
958  int boundingRadius = GetBoundingRadius() + aAccuracy;
959 
960  if( delta.SquaredEuclideanNorm() > SEG::Square( boundingRadius ) )
961  return false;
962 
963  return GetEffectivePolygon()->Contains( aPosition, -1, aAccuracy );
964 }
965 
966 
967 bool PAD::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
968 {
969  EDA_RECT arect = aRect;
970  arect.Normalize();
971  arect.Inflate( aAccuracy );
972 
973  EDA_RECT bbox = GetBoundingBox();
974 
975  if( aContained )
976  {
977  return arect.Contains( bbox );
978  }
979  else
980  {
981  // Fast test: if aRect is outside the polygon bounding box,
982  // rectangles cannot intersect
983  if( !arect.Intersects( bbox ) )
984  return false;
985 
986  const std::shared_ptr<SHAPE_POLY_SET>& poly = GetEffectivePolygon();
987 
988  int count = poly->TotalVertices();
989 
990  for( int ii = 0; ii < count; ii++ )
991  {
992  auto vertex = poly->CVertex( ii );
993  auto vertexNext = poly->CVertex(( ii + 1 ) % count );
994 
995  // Test if the point is within aRect
996  if( arect.Contains( ( wxPoint ) vertex ) )
997  return true;
998 
999  // Test if this edge intersects aRect
1000  if( arect.Intersects( ( wxPoint ) vertex, ( wxPoint ) vertexNext ) )
1001  return true;
1002  }
1003 
1004  return false;
1005  }
1006 }
1007 
1008 
1009 int PAD::Compare( const PAD* padref, const PAD* padcmp )
1010 {
1011  int diff;
1012 
1013  if( ( diff = static_cast<int>( padref->GetShape() ) -
1014  static_cast<int>( padcmp->GetShape() ) ) != 0 )
1015  return diff;
1016 
1017  if( ( diff = padref->GetDrillShape() - padcmp->GetDrillShape() ) != 0)
1018  return diff;
1019 
1020  if( ( diff = padref->m_drill.x - padcmp->m_drill.x ) != 0 )
1021  return diff;
1022 
1023  if( ( diff = padref->m_drill.y - padcmp->m_drill.y ) != 0 )
1024  return diff;
1025 
1026  if( ( diff = padref->m_size.x - padcmp->m_size.x ) != 0 )
1027  return diff;
1028 
1029  if( ( diff = padref->m_size.y - padcmp->m_size.y ) != 0 )
1030  return diff;
1031 
1032  if( ( diff = padref->m_offset.x - padcmp->m_offset.x ) != 0 )
1033  return diff;
1034 
1035  if( ( diff = padref->m_offset.y - padcmp->m_offset.y ) != 0 )
1036  return diff;
1037 
1038  if( ( diff = padref->m_deltaSize.x - padcmp->m_deltaSize.x ) != 0 )
1039  return diff;
1040 
1041  if( ( diff = padref->m_deltaSize.y - padcmp->m_deltaSize.y ) != 0 )
1042  return diff;
1043 
1044  // TODO: test custom shapes
1045 
1046  // Dick: specctra_export needs this
1047  // Lorenzo: gencad also needs it to implement padstacks!
1048 
1049 #if __cplusplus >= 201103L
1050  long long d = padref->m_layerMask.to_ullong() - padcmp->m_layerMask.to_ullong();
1051  if( d < 0 )
1052  return -1;
1053  else if( d > 0 )
1054  return 1;
1055 
1056  return 0;
1057 #else
1058  // these strings are not typically constructed, since we don't get here often.
1059  std::string s1 = padref->m_layerMask.to_string();
1060  std::string s2 = padcmp->m_layerMask.to_string();
1061  return s1.compare( s2 );
1062 #endif
1063 }
1064 
1065 
1066 void PAD::Rotate( const wxPoint& aRotCentre, double aAngle )
1067 {
1068  RotatePoint( &m_pos, aRotCentre, aAngle );
1069 
1070  m_orient = NormalizeAngle360Min( m_orient + aAngle );
1071 
1072  SetLocalCoord();
1073 
1074  SetDirty();
1075 }
1076 
1077 
1078 wxString PAD::ShowPadShape() const
1079 {
1080  switch( GetShape() )
1081  {
1082  case PAD_SHAPE::CIRCLE: return _( "Circle" );
1083  case PAD_SHAPE::OVAL: return _( "Oval" );
1084  case PAD_SHAPE::RECT: return _( "Rect" );
1085  case PAD_SHAPE::TRAPEZOID: return _( "Trap" );
1086  case PAD_SHAPE::ROUNDRECT: return _( "Roundrect" );
1087  case PAD_SHAPE::CHAMFERED_RECT: return _( "Chamferedrect" );
1088  case PAD_SHAPE::CUSTOM: return _( "CustomShape" );
1089  default: return wxT( "???" );
1090  }
1091 }
1092 
1093 
1094 wxString PAD::ShowPadAttr() const
1095 {
1096  switch( GetAttribute() )
1097  {
1098  case PAD_ATTRIB::PTH: return _( "PTH" );
1099  case PAD_ATTRIB::SMD: return _( "SMD" );
1100  case PAD_ATTRIB::CONN: return _( "Conn" );
1101  case PAD_ATTRIB::NPTH: return _( "NPTH" );
1102  default: return wxT( "???" );
1103  }
1104 }
1105 
1106 
1107 wxString PAD::GetSelectMenuText( EDA_UNITS aUnits ) const
1108 {
1109  if( GetName().IsEmpty() )
1110  {
1112  {
1113  return wxString::Format( _( "Pad of %s on %s" ),
1114  GetParent()->GetReference(),
1115  layerMaskDescribe() );
1116  }
1117  else
1118  {
1119  return wxString::Format( _( "Through hole pad of %s" ),
1120  GetParent()->GetReference() );
1121  }
1122  }
1123  else
1124  {
1126  {
1127  return wxString::Format( _( "Pad %s of %s on %s" ),
1128  GetName(),
1129  GetParent()->GetReference(),
1130  layerMaskDescribe() );
1131  }
1132  else
1133  {
1134  return wxString::Format( _( "Through hole pad %s of %s" ),
1135  GetName(),
1136  GetParent()->GetReference() );
1137  }
1138  }
1139 }
1140 
1141 
1143 {
1144  return BITMAPS::pad;
1145 }
1146 
1147 
1149 {
1150  return new PAD( *this );
1151 }
1152 
1153 
1154 void PAD::ViewGetLayers( int aLayers[], int& aCount ) const
1155 {
1156  aCount = 0;
1157 
1158  // These 2 types of pads contain a hole
1159  if( m_attribute == PAD_ATTRIB::PTH )
1160  {
1161  aLayers[aCount++] = LAYER_PAD_PLATEDHOLES;
1162  aLayers[aCount++] = LAYER_PAD_HOLEWALLS;
1163  }
1164 
1165  if( m_attribute == PAD_ATTRIB::NPTH )
1166  aLayers[aCount++] = LAYER_NON_PLATEDHOLES;
1167 
1168  if( IsOnLayer( F_Cu ) && IsOnLayer( B_Cu ) )
1169  {
1170  // Multi layer pad
1171  aLayers[aCount++] = LAYER_PADS_TH;
1172  aLayers[aCount++] = LAYER_PAD_NETNAMES;
1173  }
1174  else if( IsOnLayer( F_Cu ) )
1175  {
1176  aLayers[aCount++] = LAYER_PAD_FR;
1177 
1178  // Is this a PTH pad that has only front copper? If so, we need to also display the
1179  // net name on the PTH netname layer so that it isn't blocked by the drill hole.
1180  if( m_attribute == PAD_ATTRIB::PTH )
1181  aLayers[aCount++] = LAYER_PAD_NETNAMES;
1182  else
1183  aLayers[aCount++] = LAYER_PAD_FR_NETNAMES;
1184  }
1185  else if( IsOnLayer( B_Cu ) )
1186  {
1187  aLayers[aCount++] = LAYER_PAD_BK;
1188 
1189  // Is this a PTH pad that has only back copper? If so, we need to also display the
1190  // net name on the PTH netname layer so that it isn't blocked by the drill hole.
1191  if( m_attribute == PAD_ATTRIB::PTH )
1192  aLayers[aCount++] = LAYER_PAD_NETNAMES;
1193  else
1194  aLayers[aCount++] = LAYER_PAD_BK_NETNAMES;
1195  }
1196  else
1197  {
1198  // Internal layers only. (Not yet supported in GUI, but is being used by Python
1199  // footprint generators and will be needed anyway once pad stacks are supported.)
1200  for ( int internal = In1_Cu; internal < In30_Cu; ++internal )
1201  {
1202  if( IsOnLayer( (PCB_LAYER_ID) internal ) )
1203  aLayers[aCount++] = internal;
1204  }
1205  }
1206 
1207  // Check non-copper layers. This list should include all the layers that the
1208  // footprint editor allows a pad to be placed on.
1209  static const PCB_LAYER_ID layers_mech[] = { F_Mask, B_Mask, F_Paste, B_Paste,
1211 
1212  for( PCB_LAYER_ID each_layer : layers_mech )
1213  {
1214  if( IsOnLayer( each_layer ) )
1215  aLayers[aCount++] = each_layer;
1216  }
1217 
1218 #ifdef __WXDEBUG__
1219  if( aCount == 0 ) // Should not occur
1220  {
1221  wxString msg;
1222  msg.Printf( wxT( "footprint %s, pad %s: could not find valid layer for pad" ),
1223  GetParent() ? GetParent()->GetReference() : "<null>",
1224  GetName().IsEmpty() ? "(unnamed)" : GetName() );
1225  wxLogWarning( msg );
1226  }
1227 #endif
1228 }
1229 
1230 
1231 double PAD::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
1232 {
1233  constexpr double HIDE = std::numeric_limits<double>::max();
1234 
1235  PCB_PAINTER* painter = static_cast<PCB_PAINTER*>( aView->GetPainter() );
1236  PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
1237  BOARD* board = GetBoard();
1238  LSET visible = LSET::AllLayersMask();
1239 
1240  // Meta control for hiding all pads
1241  if( !aView->IsLayerVisible( LAYER_PADS ) )
1242  return HIDE;
1243 
1244  // Handle board visibility
1245  if( board )
1246  visible = board->GetVisibleLayers() & board->GetEnabledLayers();
1247 
1248  // Handle Render tab switches
1250  && !aView->IsLayerVisible( LAYER_PADS_TH ) )
1251  {
1252  return HIDE;
1253  }
1254 
1255  if( !IsFlipped() && !aView->IsLayerVisible( LAYER_MOD_FR ) )
1256  return HIDE;
1257 
1258  if( IsFlipped() && !aView->IsLayerVisible( LAYER_MOD_BK ) )
1259  return HIDE;
1260 
1261  if( IsFrontLayer( (PCB_LAYER_ID) aLayer ) && !aView->IsLayerVisible( LAYER_PAD_FR ) )
1262  return HIDE;
1263 
1264  if( IsBackLayer( (PCB_LAYER_ID) aLayer ) && !aView->IsLayerVisible( LAYER_PAD_BK ) )
1265  return HIDE;
1266 
1267  if( aLayer == LAYER_PADS_TH )
1268  {
1269  if( !FlashLayer( visible ) )
1270  return HIDE;
1271  }
1272  else if( IsHoleLayer( aLayer ) )
1273  {
1274  if( !( visible & LSET::PhysicalLayersMask() ).any() )
1275  return HIDE;
1276  }
1277  else if( IsNetnameLayer( aLayer ) )
1278  {
1279  if( renderSettings->GetHighContrast() )
1280  {
1281  // Hide netnames unless pad is flashed to a high-contrast layer
1282  if( !FlashLayer( renderSettings->GetPrimaryHighContrastLayer() ) )
1283  return HIDE;
1284  }
1285  else
1286  {
1287  // Hide netnames unless pad is flashed to a visible layer
1288  if( !FlashLayer( visible ) )
1289  return HIDE;
1290  }
1291 
1292  // Netnames will be shown only if zoom is appropriate
1293  int divisor = std::min( GetBoundingBox().GetWidth(), GetBoundingBox().GetHeight() );
1294 
1295  // Pad sizes can be zero briefly when someone is typing a number like "0.5"
1296  // in the pad properties dialog
1297  if( divisor == 0 )
1298  return HIDE;
1299 
1300  return ( double ) Millimeter2iu( 5 ) / divisor;
1301  }
1302 
1303  if( aLayer == LAYER_PADS_TH
1304  && GetShape() != PAD_SHAPE::CUSTOM
1305  && GetSizeX() <= GetDrillSizeX()
1306  && GetSizeY() <= GetDrillSizeY() )
1307  {
1308  // Don't tweak the drawing code with a degenerate pad
1309  return HIDE;
1310  }
1311 
1312  // Passed all tests; show.
1313  return 0.0;
1314 }
1315 
1316 
1317 const BOX2I PAD::ViewBBox() const
1318 {
1319  // Bounding box includes soldermask too. Remember mask and/or paste
1320  // margins can be < 0
1321  int solderMaskMargin = std::max( GetSolderMaskMargin(), 0 );
1322  VECTOR2I solderPasteMargin = VECTOR2D( GetSolderPasteMargin() );
1323  EDA_RECT bbox = GetBoundingBox();
1324 
1325  // get the biggest possible clearance
1326  int clearance = 0;
1327 
1328  for( PCB_LAYER_ID layer : GetLayerSet().Seq() )
1329  clearance = std::max( clearance, GetOwnClearance( layer ) );
1330 
1331  // Look for the biggest possible bounding box
1332  int xMargin = std::max( solderMaskMargin, solderPasteMargin.x ) + clearance;
1333  int yMargin = std::max( solderMaskMargin, solderPasteMargin.y ) + clearance;
1334 
1335  return BOX2I( VECTOR2I( bbox.GetOrigin() ) - VECTOR2I( xMargin, yMargin ),
1336  VECTOR2I( bbox.GetSize() ) + VECTOR2I( 2 * xMargin, 2 * yMargin ) );
1337 }
1338 
1339 
1341 {
1342  return dynamic_cast<FOOTPRINT*>( m_parent );
1343 }
1344 
1345 
1346 void PAD::ImportSettingsFrom( const PAD& aMasterPad )
1347 {
1348  SetShape( aMasterPad.GetShape() );
1349  SetLayerSet( aMasterPad.GetLayerSet() );
1350  SetAttribute( aMasterPad.GetAttribute() );
1351  SetProperty( aMasterPad.GetProperty() );
1352 
1353  // I am not sure the m_LengthPadToDie must be imported, because this is
1354  // a parameter really specific to a given pad (JPC).
1355  // So this is currently non imported
1356  #if 0
1357  SetPadToDieLength( aMasterPad.GetPadToDieLength() );
1358  #endif
1359 
1360  // The pad orientation, for historical reasons is the
1361  // pad rotation + parent rotation.
1362  // So we have to manage this parent rotation
1363  double pad_rot = aMasterPad.GetOrientation();
1364 
1365  if( aMasterPad.GetParent() )
1366  pad_rot -= aMasterPad.GetParent()->GetOrientation();
1367 
1368  if( GetParent() )
1369  pad_rot += GetParent()->GetOrientation();
1370 
1371  SetOrientation( pad_rot );
1372 
1373  SetSize( aMasterPad.GetSize() );
1374  SetDelta( wxSize( 0, 0 ) );
1375  SetOffset( aMasterPad.GetOffset() );
1376  SetDrillSize( aMasterPad.GetDrillSize() );
1377  SetDrillShape( aMasterPad.GetDrillShape() );
1379  SetChamferRectRatio( aMasterPad.GetChamferRectRatio() );
1380  SetChamferPositions( aMasterPad.GetChamferPositions() );
1381 
1382  switch( aMasterPad.GetShape() )
1383  {
1384  case PAD_SHAPE::TRAPEZOID:
1385  SetDelta( aMasterPad.GetDelta() );
1386  break;
1387 
1388  case PAD_SHAPE::CIRCLE:
1389  // ensure size.y == size.x
1390  SetSize( wxSize( GetSize().x, GetSize().x ) );
1391  break;
1392 
1393  default:
1394  ;
1395  }
1396 
1397  switch( aMasterPad.GetAttribute() )
1398  {
1399  case PAD_ATTRIB::SMD:
1400  case PAD_ATTRIB::CONN:
1401  // These pads do not have hole (they are expected to be only on one
1402  // external copper layer)
1403  SetDrillSize( wxSize( 0, 0 ) );
1404  break;
1405 
1406  default:
1407  ;
1408  }
1409 
1410  // copy also local settings:
1411  SetLocalClearance( aMasterPad.GetLocalClearance() );
1415 
1418  SetThermalGap( aMasterPad.GetThermalGap() );
1419 
1421 
1422  // Add or remove custom pad shapes:
1423  ReplacePrimitives( aMasterPad.GetPrimitives() );
1424  SetAnchorPadShape( aMasterPad.GetAnchorPadShape() );
1425 
1426  SetDirty();
1427 }
1428 
1429 
1430 void PAD::SwapData( BOARD_ITEM* aImage )
1431 {
1432  assert( aImage->Type() == PCB_PAD_T );
1433 
1434  std::swap( *((FOOTPRINT*) this), *((FOOTPRINT*) aImage) );
1435 }
1436 
1437 
1438 static struct PAD_DESC
1439 {
1441  {
1443  .Map( PAD_ATTRIB::PTH, _HKI( "Through-hole" ) )
1444  .Map( PAD_ATTRIB::SMD, _HKI( "SMD" ) )
1445  .Map( PAD_ATTRIB::CONN, _HKI( "Edge connector" ) )
1446  .Map( PAD_ATTRIB::NPTH, _HKI( "NPTH, mechanical" ) );
1447 
1449  .Map( PAD_SHAPE::CIRCLE, _HKI( "Circle" ) )
1450  .Map( PAD_SHAPE::RECT, _HKI( "Rectangle" ) )
1451  .Map( PAD_SHAPE::OVAL, _HKI( "Oval" ) )
1452  .Map( PAD_SHAPE::TRAPEZOID, _HKI( "Trapezoid" ) )
1453  .Map( PAD_SHAPE::ROUNDRECT, _HKI( "Rounded rectangle" ) )
1454  .Map( PAD_SHAPE::CHAMFERED_RECT, _HKI( "Chamfered rectangle" ) )
1455  .Map( PAD_SHAPE::CUSTOM, _HKI( "Custom" ) );
1456 
1458  .Map( PAD_PROP::NONE, _HKI( "None" ) )
1459  .Map( PAD_PROP::BGA, _HKI( "BGA pad" ) )
1460  .Map( PAD_PROP::FIDUCIAL_GLBL, _HKI( "Fiducial, global to board" ) )
1461  .Map( PAD_PROP::FIDUCIAL_LOCAL, _HKI( "Fiducial, local to footprint" ) )
1462  .Map( PAD_PROP::TESTPOINT, _HKI( "Test point pad" ) )
1463  .Map( PAD_PROP::HEATSINK, _HKI( "Heatsink pad" ) )
1464  .Map( PAD_PROP::CASTELLATED, _HKI( "Castellated pad" ) );
1465 
1467  REGISTER_TYPE( PAD );
1469 
1470  auto padType = new PROPERTY_ENUM<PAD, PAD_ATTRIB>( _HKI( "Pad Type" ),
1472  propMgr.AddProperty( padType );
1473 
1474  auto shape = new PROPERTY_ENUM<PAD, PAD_SHAPE>( _HKI( "Shape" ),
1476  propMgr.AddProperty( shape );
1477 
1478  propMgr.AddProperty( new PROPERTY<PAD, wxString>( _HKI( "Pad Number" ),
1479  &PAD::SetName, &PAD::GetName ) );
1480  propMgr.AddProperty( new PROPERTY<PAD, wxString>( _HKI( "Pin Name" ),
1482  propMgr.AddProperty( new PROPERTY<PAD, wxString>( _HKI( "Pin Type" ),
1484  propMgr.AddProperty( new PROPERTY<PAD, double>( _HKI( "Orientation" ),
1487  propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Size X" ),
1490  propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Size Y" ),
1493  propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Hole Size X" ),
1496  propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Hole Size Y" ),
1499  propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Pad To Die Length" ),
1502  propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Soldermask Margin Override" ),
1505  propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Solderpaste Margin Override" ),
1508  propMgr.AddProperty( new PROPERTY<PAD, double>( _HKI( "Solderpaste Margin Ratio Override" ),
1510  propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Thermal Relief Width" ),
1513  propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Thermal Relief Gap" ),
1516  propMgr.AddProperty( new PROPERTY_ENUM<PAD, PAD_PROP>( _HKI( "Fabrication Property" ),
1518 
1519  auto roundRadiusRatio = new PROPERTY<PAD, double>( _HKI( "Round Radius Ratio" ),
1521  roundRadiusRatio->SetAvailableFunc(
1522  [=]( INSPECTABLE* aItem ) -> bool
1523  {
1524  return aItem->Get( shape ) == static_cast<int>( PAD_SHAPE::ROUNDRECT );
1525  } );
1526  propMgr.AddProperty( roundRadiusRatio );
1527 
1528  propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Clearance Override" ),
1531  propMgr.AddProperty( new PROPERTY<PAD, wxString>( _HKI( "Parent" ),
1532  NO_SETTER( PAD, wxString ), &PAD::GetParentAsString ) );
1533 
1534  // TODO delta, drill shape offset, layer set, zone connection
1535  }
1536 } _PAD_DESC;
1537 
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:146
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:750
Display value expressed in degrees.
Definition: property.h:54
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pad.cpp:1142
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition: zones.h:41
int GetLocalSolderMaskMargin() const
Definition: pad.h:383
void FlipPrimitives(bool aFlipLeftRight)
Flip (mirror) the primitives left to right or top to bottom, around the anchor position in custom pad...
Definition: pad.cpp:650
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:479
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:104
void SetOffset(const wxPoint &aOffset)
Definition: pad.h:245
const int GetSizeY() const
Definition: pad.h:233
BOX2< VECTOR2I > BOX2I
Definition: box2.h:506
int GetLocalClearance() const
Definition: pad.h:387
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
Definition: shape_simple.h:41
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:65
bool m_shapesDirty
Definition: pad.h:690
#define TYPE_HASH(x)
Definition: property.h:59
LSET FlipLayerMask(LSET aMask, int aCopperLayersCount)
Calculate the mask layer when flipping a footprint.
Definition: lset.cpp:567
static LSET ConnSMDMask()
layer set for a SMD pad on Front layer used for edge board connectors
Definition: pad.cpp:168
static struct PAD_DESC _PAD_DESC
void SetLocalSolderPasteMarginRatio(double aRatio)
Definition: pad.h:394
int m_chamferPositions
Definition: pad.h:720
void SetAttribute(PAD_ATTRIB aAttribute)
Definition: pad.cpp:564
const int GetDrillSizeX() const
Definition: pad.h:241
std::mutex m_shapesBuildingLock
Definition: pad.h:691
std::mutex m_polyBuildingLock
Definition: pad.h:697
int GetLocalSolderPasteMargin() const
Definition: pad.h:390
double GetRoundRectRadiusRatio() const
Definition: pad.h:520
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
Definition: pad.cpp:1154
multilayer pads, usually with holes
void SetLocalClearance(int aClearance)
Definition: pad.h:388
Implementation of conversion functions that require both schematic and board internal units.
wxSize m_deltaSize
Definition: pad.h:737
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
int m_effectiveBoundingRadius
Definition: pad.h:699
void SetThermalSpokeWidth(int aWidth)
Set the width of the thermal spokes connecting the pad to a zone.
Definition: pad.h:487
void SetDrillSizeY(const int aY)
Definition: pad.h:242
PAD_PROP GetProperty() const
Definition: pad.h:371
wxSize m_drill
Definition: pad.h:711
handle color for not plated holes (holes, not pads)
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
int GetLocalClearanceOverrides(wxString *aSource) const override
Return any local clearance overrides set in the "classic" (ie: pre-rule) system.
Definition: pad.cpp:674
static int Compare(const PAD *padref, const PAD *padcmp)
Compare two pads and return 0 if they are equal.
Definition: pad.cpp:1009
virtual NETCLASS * GetNetClass() const
Return the NETCLASS for this item.
double m_roundedCornerScale
Definition: pad.h:716
LSET m_layerMask
Definition: pad.h:734
void Move(const VECTOR2I &aVector) override
Like smd, does not appear on the solder paste layer (default)
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
Definition: pad.cpp:955
void SetOrientationDegrees(double aOrientation)
Set orientation in degrees.
Definition: pad.h:340
Smd pad, appears on the solder paste layer (default)
show footprints on back
void SetName(const wxString &aName)
Set the pad name (sometimes called pad number, although it can be an array reference like AA12).
Definition: pad.h:129
bool IsLocked() const override
Definition: pad.cpp:145
void SetSubRatsnest(int aSubRatsnest)
Definition: pad.h:545
static ENUM_MAP< T > & Instance()
Definition: property.h:510
double GetOrientation() const
Definition: footprint.h:181
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:479
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition: pad.h:564
void SetSizeX(const int aX)
Definition: pad.h:230
const SHAPE_SEGMENT * GetEffectiveHoleShape() const
Return a SHAPE object representing the pad's hole.
Definition: pad.cpp:292
extended_type SquaredEuclideanNorm() const
Compute the squared euclidean norm of the vector, which is defined as (x ** 2 + y ** 2).
Definition: vector2d.h:300
wxString AsString() const
Definition: kiid.cpp:218
class PAD, a pad in a footprint
Definition: typeinfo.h:89
void SetPinType(const wxString &aType)
Set the pad electrical type.
Definition: pad.h:141
void ReplacePrimitives(const std::vector< std::shared_ptr< PCB_SHAPE >> &aPrimitivesList)
Clear the current custom shape primitives list and import a new list.
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:465
wxPoint m_pos
Definition: pad.h:678
void SetSize(const wxSize &aSize)
Definition: pad.h:228
int GetEffectiveThermalGap(wxString *aSource=nullptr) const
Return the effective thermal gap having resolved any inheritance.
Definition: pad.cpp:832
void SetDelta(const wxSize &aSize)
Definition: pad.h:235
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:290
wxPoint m_pos0
Definition: pad.h:741
The base class for create windows for drawing purpose.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
a test point pad
#define NO_SETTER(owner, type)
Definition: property.h:621
virtual bool IsLocked() const
Definition: board_item.cpp:65
int PointCount() const
Return the number of points (vertices) in this line chain.
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:411
std::shared_ptr< SHAPE_COMPOUND > m_effectiveShape
Definition: pad.h:693
static SEG::ecoord Square(int a)
Definition: seg.h:122
Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:241
int GetThermalGap() const
Definition: pad.h:496
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:588
wxString ShowPadShape() const
Definition: pad.cpp:1078
#define REGISTER_TYPE(x)
Definition: property_mgr.h:248
double m_localSolderPasteMarginRatio
Definition: pad.h:771
bool Contains(const wxPoint &aPoint) const
Definition: eda_rect.cpp:57
bool IsFlipped() const
Definition: pad.cpp:189
int m_localSolderPasteMargin
Definition: pad.h:770
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:207
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
EDA_RECT m_effectiveBoundingBox
Definition: pad.h:692
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
Plated through hole pad.
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:40
int m_localSolderMaskMargin
Definition: pad.h:769
void SetPadToDieLength(int aLength)
Definition: pad.h:380
void SetProperty(PAD_PROP aProperty)
Definition: pad.cpp:575
void TransformRoundChamferedRectToPolygon(SHAPE_POLY_SET &aCornerBuffer, const wxPoint &aPosition, const wxSize &aSize, double aRotation, int aCornerRadius, double aChamferRatio, int aChamferCorners, int aInflate, int aError, ERROR_LOC aErrorLoc)
Convert a rectangle with rounded corners and/or chamfered corners to a polygon.
void ImportSettingsFrom(const PAD &aMasterPad)
Import the pad settings from aMasterPad.
Definition: pad.cpp:1346
std::shared_ptr< SHAPE_SEGMENT > m_effectiveHoleShape
Definition: pad.h:694
show footprints on front
a pad used as heat sink, usually in SMD footprints
int GetEffectiveThermalSpokeWidth(wxString *aSource=nullptr) const
Return the effective thermal spoke width having resolved any inheritance.
Definition: pad.cpp:813
bool m_keepTopBottomLayer
Definition: pad.h:756
PCB specific render settings.
Definition: pcb_painter.h:64
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pad.cpp:1231
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
void SetLocalSolderMaskMargin(int aMargin)
Definition: pad.h:384
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape() DO NOT REORDER, legacy_plugin is dependent on ...
Definition: pad_shapes.h:33
int m_localClearance
Definition: pad.h:768
const wxPoint & GetOffset() const
Definition: pad.h:246
std::shared_ptr< SHAPE_POLY_SET > m_effectivePolygon
Definition: pad.h:698
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: pad.cpp:851
void SetDrillSizeX(const int aX)
Definition: pad.h:240
const wxSize & GetDrillSize() const
Definition: pad.h:239
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
Definition: pad.cpp:1430
virtual wxString layerMaskDescribe() const
Return a string (to be shown to the user) describing a layer mask.
Definition: board_item.cpp:86
wxPoint ShapePos() const
Definition: pad.cpp:659
like PAD_PTH, but not plated
double m_chamferScale
Definition: pad.h:718
PCB_LAYER_ID
A quick note on layer IDs:
Display value expressed in distance units (mm/inch)
Definition: property.h:53
bool FlashLayer(int aLayer) const
Check to see whether the pad should be flashed on the specific layer.
Definition: pad.cpp:209
LSET is a set of PCB_LAYER_IDs.
int m_thermalGap
Definition: pad.h:776
int GetThermalSpokeWidth() const
Definition: pad.h:488
double GetOrientation() const
Return the rotation angle of the pad in a variety of units (the basic call returns tenths of degrees)...
Definition: pad.h:346
VECTOR2< double > VECTOR2D
Definition: vector2d.h:622
void SetPos0(const wxPoint &aPos)
Definition: pad.h:222
void SetLocalCoord()
< Set relative coordinates.
Definition: pad.cpp:549
virtual PCB_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
Definition: pcb_painter.h:247
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pad.cpp:592
void SetThermalGap(int aGap)
Definition: pad.h:495
Represent a set of closed polygons.
int m_thermalWidth
Definition: pad.h:775
const wxPoint GetOrigin() const
Definition: eda_rect.h:101
coord_type GetWidth() const
Definition: box2.h:180
void SetDrillSize(const wxSize &aSize)
Definition: pad.h:238
Meta control for all pads opacity/visibility (color ignored)
const wxSize & GetSize() const
Definition: pad.h:229
wxAny Get(PROPERTY_BASE *aProperty)
Definition: inspectable.h:86
ZONE_CONNECTION GetEffectiveZoneConnection(wxString *aSource=nullptr) const
Return the zone connection in effect (either locally overridden or overridden in the parent footprint...
Definition: pad.cpp:792
virtual BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:51
Smd pad, used in BGA footprints.
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: pad.cpp:1317
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:344
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
const wxString & GetName() const
Definition: pad.h:130
static LSET PTHMask()
layer set for a through hole pad
Definition: pad.cpp:154
const EDA_RECT GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition: pad.cpp:522
double m_orient
Definition: pad.h:748
int GetLocalClearance() const
Definition: footprint.h:200
const wxString & GetPinType() const
Definition: pad.h:142
PAD_SHAPE GetShape() const
Definition: pad.h:166
const wxString & GetReference() const
Definition: footprint.h:421
a fiducial (usually a smd) local to the parent footprint
#define _(s)
PAD & operator=(const PAD &aOther)
Definition: pad.cpp:126
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: pad.cpp:283
static LSET AllLayersMask()
Definition: lset.cpp:787
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pad.h:365
class ZONE, a copper pour area
Definition: typeinfo.h:105
An abstract shape on 2D plane.
Definition: shape.h:116
void SetZoneConnection(ZONE_CONNECTION aType)
Definition: pad.h:472
void SetDrawCoord()
Definition: pad.cpp:531
ZONE_CONNECTION m_zoneConnection
Definition: pad.h:774
void SetPinFunction(const wxString &aName)
Set the pad function (pin name in schematic)
Definition: pad.h:135
void BuildEffectivePolygon() const
Definition: pad.cpp:483
void SetCustomShapeInZoneOpt(CUST_PAD_SHAPE_IN_ZONE aOption)
Set the option for the custom pad shape to use as clearance area in copper zones.
Definition: pad.h:194
Class that other classes need to inherit from, in order to be inspectable.
Definition: inspectable.h:35
void SetRoundRectRadiusRatio(double aRadiusScale)
Has meaning only for rounded rectangle pads.
Definition: pad.cpp:258
PAD_ATTRIB
The set of pad shapes, used with PAD::{Set,Get}Attribute().
Definition: pad_shapes.h:79
int GetThermalWidth() const
Definition: footprint.h:221
EDA_ITEM & operator=(const EDA_ITEM &aItem)
Assign the members of aItem to another object.
Definition: eda_item.cpp:180
int GetLocalClearance(wxString *aSource) const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition: pad.cpp:688
void SetDrillShape(PAD_DRILL_SHAPE_T aShape)
Definition: pad.h:350
void BuildEffectiveShapes(PCB_LAYER_ID aLayer) const
Rebuild the effective shape cache (and bounding box and radius) for the pad and clears the dirty bit.
Definition: pad.cpp:310
double GetLocalSolderPasteMarginRatio() const
Definition: pad.h:393
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
void SetRoundRectCornerRadius(double aRadius)
Has meaning only for rounded rectangle pads.
Definition: pad.cpp:249
const KIID m_Uuid
Definition: eda_item.h:475
const Vec & GetPosition() const
Definition: box2.h:177
Some functions to handle hotkeys in KiCad.
int GetRoundRectCornerRadius() const
Definition: pad.cpp:243
const wxSize & GetDelta() const
Definition: pad.h:236
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
wxSize m_size
Definition: pad.h:712
int GetSolderMaskMargin() const
Definition: pad.cpp:697
FOOTPRINT * GetParent() const
Definition: pad.cpp:1340
void Rotate(double aAngle, const VECTOR2I &aCenter=VECTOR2I(0, 0)) override
Rotate all vertices by a given angle.
void SetChamferPositions(int aPositions)
Has meaning only for chamfered rectangular pads.
Definition: pad.h:538
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
EDA_UNITS
Definition: eda_units.h:38
void Normalize()
Ensures that the height ant width are positive.
Definition: eda_rect.cpp:35
wxPoint m_offset
Definition: pad.h:732
const wxPoint & GetPos0() const
Definition: pad.h:223
static LSET PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
Definition: lset.cpp:849
double GetOrientationDegrees() const
Definition: footprint.h:182
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aMaxError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the pad shape to a closed polygon.
void SetSizeY(const int aY)
Definition: pad.h:232
int GetBoundingRadius() const
Return the radius of a minimum sized circle which fully encloses this pad.
Definition: pad.cpp:301
int GetLocalSolderMaskMargin() const
Definition: footprint.h:197
static LSET ApertureMask()
layer set for an aperture pad
Definition: pad.cpp:182
void SetLayerSet(LSET aLayers) override
Definition: pad.h:364
bool m_removeUnconnectedLayer
< If true, the pad copper is removed for layers that are not connected.
Definition: pad.h:753
PAD_DESC()
Definition: pad.cpp:1440
CUST_PAD_SHAPE_IN_ZONE GetCustomShapeInZoneOpt() const
Definition: pad.h:184
smd pads, front layer
a fiducial (usually a smd) for the full board
double GetChamferRectRatio() const
Definition: pad.h:529
std::vector< std::shared_ptr< PCB_SHAPE > > m_editPrimitives
Definition: pad.h:687
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32
wxSize GetSolderPasteMargin() const
Usually < 0 (mask shape smaller than pad)because the margin can be dependent on the pad size,...
Definition: pad.cpp:742
int GetSubRatsnest() const
Definition: pad.h:544
PAD_PROP
Ghe set of pad properties used in Gerber files (Draw files, and P&P files) to define some properties ...
Definition: pad_shapes.h:95
wxPoint GetPosition() const override
Definition: pad.h:174
void SetLocalSolderPasteMargin(int aMargin)
Definition: pad.h:391
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: pad.h:351
no special fabrication property
ENUM_TO_WXANY(PAD_ATTRIB)
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
const int GetDrillSizeY() const
Definition: pad.h:243
Represent a polyline (an zero-thickness chain of connected line segments).
PAD_ATTRIB GetAttribute() const
Definition: pad.h:368
double GetOrientationDegrees() const
Definition: pad.h:347
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:222
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void SetPosition(const wxPoint &aPos) override
Definition: pad.h:168
void AddProperty(PROPERTY_BASE *aProperty)
Register a property.
void SetDirty()
Definition: pad.h:358
class ZONE, managed by a footprint
Definition: typeinfo.h:94
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pad.cpp:1148
Handle the component boundary box.
Definition: eda_rect.h:42
double DECIDEG2RAD(double deg)
Definition: trigo.h:233
bool IsHoleLayer(LAYER_NUM aLayer)
const int GetSizeX() const
Definition: pad.h:231
static std::string PAD_SHAPE_T_asString(PAD_SHAPE a)
Definition: pad_shapes.h:47
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon() const
Definition: pad.cpp:274
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:73
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
coord_type GetHeight() const
Definition: box2.h:181
wxString m_name
Definition: pad.h:674
wxPoint GetPosition() const override
Definition: footprint.h:177
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: pad.cpp:1107
double NormalizeAngleDegrees(double Angle, double aMin, double aMax)
Normalize angle to be aMin < angle <= aMax angle is in degrees.
Definition: trigo.h:327
virtual int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const
Return an item's "own" clearance in internal units.
double GetLocalSolderPasteMarginRatio() const
Definition: footprint.h:214
bool Intersects(const EDA_RECT &aRect) const
Test for a common area between rectangles.
Definition: eda_rect.cpp:150
void SetShape(PAD_SHAPE aShape)
Set the new shape of this pad.
Definition: pad.h:157
int GetChamferPositions() const
Definition: pad.h:539
wxString GetParentAsString() const
Definition: pad.h:107
int m_lengthPadToDie
Definition: pad.h:750
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:62
PAD_ATTRIB m_attribute
Definition: pad.h:744
a pad with a castellated through hole
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
wxString ShowPadAttr() const
Definition: pad.cpp:1094
ZONE_CONNECTION GetZoneConnection() const
Definition: footprint.h:218
static LSET UnplatedHoleMask()
layer set for a mechanical unplated through hole pad
Definition: pad.cpp:175
CUST_PAD_SHAPE_IN_ZONE m_customShapeClearanceArea
Definition: pad.h:706
int GetLocalSolderPasteMargin() const
Definition: footprint.h:211
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
Definition: pad.h:57
void SetChamferRectRatio(double aChamferScale)
Has meaning only for chamfered rectangular pads.
Definition: pad.cpp:266
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:254
Message panel definition file.
static LSET SMDMask()
layer set for a SMD pad on Front layer
Definition: pad.cpp:161
static constexpr int Millimeter2iu(double mm)
#define _HKI(x)
int GetPadToDieLength() const
Definition: pad.h:381
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:171
PAD(FOOTPRINT *parent)
Definition: pad.cpp:58
const wxString & GetPinFunction() const
Definition: pad.h:136
bool m_polyDirty
Definition: pad.h:696
int GetThermalGap() const
Definition: footprint.h:224
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives() const
Accessor to the basic shape list for custom-shaped pads.
Definition: pad.h:298
PAD_SHAPE GetAnchorPadShape() const
Definition: pad.h:179
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
Additional netnames layers (not associated with a PCB layer)
void SetOrientation(double aAngle)
Set the rotation angle of the pad.
Definition: pad.cpp:583
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364
const wxSize GetSize() const
Definition: eda_rect.h:91
PAD_PROP m_property
Definition: pad.h:746
bool IsNetnameLayer(LAYER_NUM aLayer)
Test whether a layer is a netname layer.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
void SetAnchorPadShape(PAD_SHAPE aShape)
Set the shape of the anchor pad for custom shaped pads.
Definition: pad.h:205
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:404
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate this object.
Definition: pad.cpp:1066