KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 <[email protected]>
6 * Copyright The 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, see <https://www.gnu.org/licenses/>.
20 */
21
22#include <base_units.h>
23#include <api/api_pcb_utils.h>
24#include <bitmaps.h>
25#include <math/util.h> // for KiROUND
26#include <eda_draw_frame.h>
30#include <geometry/shape_rect.h>
32#include <geometry/shape_null.h>
34#include <layer_range.h>
35#include <string_utils.h>
36#include <i18n_utility.h>
37#include <view/view.h>
38#include <board.h>
41#include <footprint.h>
42#include <lset.h>
43#include <pad.h>
44#include <pad_utils.h>
45#include <pcb_shape.h>
47#include <drc/drc_engine.h>
48#include <eda_units.h>
50#include <widgets/msgpanel.h>
51#include <pcb_painter.h>
52#include <pcbnew_settings.h>
54#include <properties/property.h>
56#include <wx/log.h>
57#include <api/api_enums.h>
58#include <api/api_utils.h>
59#include <api/api_pcb_utils.h>
60#include <api/board/board_types.pb.h>
61
62#include <memory>
63#include <macros.h>
64#include <magic_enum.hpp>
65#include "kiface_base.h"
66
67#include <pcb_group.h>
69#include <pin_type.h>
70
73
74
75PAD::PAD( FOOTPRINT* parent ) :
78 m_padStack( this )
79{
80 VECTOR2I& drill = m_padStack.Drill().size;
83 drill.x = drill.y = EDA_UNIT_UTILS::Mils2IU( pcbIUScale, 30 ); // Default drill size 30 mils.
86
87 SetShape( F_Cu, PAD_SHAPE::CIRCLE ); // Default pad shape is PAD_CIRCLE.
88 SetAnchorPadShape( F_Cu, PAD_SHAPE::CIRCLE ); // Default anchor shape for custom shaped pads is PAD_CIRCLE.
89 SetDrillShape( PAD_DRILL_SHAPE::CIRCLE ); // Default pad drill shape is a circle.
90 m_attribute = PAD_ATTRIB::PTH; // Default pad type is plated through hole
91 SetProperty( PAD_PROP::NONE ); // no special fabrication property
92
93 // Parameters for round rect only:
94 m_padStack.SetRoundRectRadiusRatio( 0.25, F_Cu ); // from IPC-7351C standard
95
96 // Parameters for chamfered rect only:
97 m_padStack.SetChamferRatio( 0.2, F_Cu );
98 m_padStack.SetChamferPositions( RECT_NO_CHAMFER, F_Cu );
99
100 // Set layers mask to default for a standard thru hole pad.
101 m_padStack.SetLayerSet( PTHMask() );
102
103 SetSubRatsnest( 0 ); // used in ratsnest calculations
104
105 SetDirty();
107
110
111}
112
113
114PAD::PAD( const PAD& aOther ) :
117 m_padStack( this )
118{
119 PAD::operator=( aOther );
120
121 SetUuidDirect( aOther.m_Uuid );
122}
123
124
125namespace
126{
127
128static int scaleLength( int aLength, double aFactor )
129{
130 return KiROUND( aLength * aFactor );
131}
132
133
135static void scaleInChildFrame( double aSx, double aSy, const EDA_ANGLE& aRelOrient, double& aLocalSx, double& aLocalSy )
136{
137 const double c = aRelOrient.Cos();
138 const double s = aRelOrient.Sin();
139 aLocalSx = aSx * c * c + aSy * s * s;
140 aLocalSy = aSx * s * s + aSy * c * c;
141}
142
143
145static VECTOR2I derivePadBoardSize( const VECTOR2I& aLibSize, PAD_SHAPE aShape, const TRANSFORM_TRS& aXform,
146 const EDA_ANGLE& aRelOrient )
147{
148 const double sx = std::abs( aXform.GetScaleX() );
149 const double sy = std::abs( aXform.GetScaleY() );
150
151 if( aShape == PAD_SHAPE::CIRCLE )
152 {
153 const double uniform = ( sx + sy ) * 0.5;
154 return { scaleLength( aLibSize.x, uniform ), scaleLength( aLibSize.y, uniform ) };
155 }
156
157 // Size is in the pad frame, so conjugate the footprint scale by the pad orientation.
158 double localSx, localSy;
159 scaleInChildFrame( sx, sy, aRelOrient, localSx, localSy );
160 return { scaleLength( aLibSize.x, localSx ), scaleLength( aLibSize.y, localSy ) };
161}
162
163
165static VECTOR2I derivePadLibSize( const VECTOR2I& aBoardSize, PAD_SHAPE aShape, const TRANSFORM_TRS& aXform,
166 const EDA_ANGLE& aRelOrient )
167{
168 const double sx = std::abs( aXform.GetScaleX() );
169 const double sy = std::abs( aXform.GetScaleY() );
170
171 if( aShape == PAD_SHAPE::CIRCLE )
172 {
173 const double uniform = ( sx + sy ) * 0.5;
174 return { scaleLength( aBoardSize.x, 1.0 / uniform ), scaleLength( aBoardSize.y, 1.0 / uniform ) };
175 }
176
177 double localSx, localSy;
178 scaleInChildFrame( sx, sy, aRelOrient, localSx, localSy );
179 return { scaleLength( aBoardSize.x, 1.0 / localSx ), scaleLength( aBoardSize.y, 1.0 / localSy ) };
180}
181
182
184static VECTOR2I derivePadBoardDrill( const VECTOR2I& aLibDrill, PAD_DRILL_SHAPE aDrillShape,
185 const TRANSFORM_TRS& aXform, const EDA_ANGLE& aRelOrient )
186{
187 const double sx = std::abs( aXform.GetScaleX() );
188 const double sy = std::abs( aXform.GetScaleY() );
189
190 if( aDrillShape == PAD_DRILL_SHAPE::CIRCLE )
191 {
192 const double uniform = ( sx + sy ) * 0.5;
193 return { scaleLength( aLibDrill.x, uniform ), scaleLength( aLibDrill.y, uniform ) };
194 }
195
196
197 double localSx, localSy;
198 scaleInChildFrame( sx, sy, aRelOrient, localSx, localSy );
199 return { scaleLength( aLibDrill.x, localSx ), scaleLength( aLibDrill.y, localSy ) };
200}
201
202
204static VECTOR2I derivePadLibDrill( const VECTOR2I& aBoardDrill, PAD_DRILL_SHAPE aDrillShape,
205 const TRANSFORM_TRS& aXform, const EDA_ANGLE& aRelOrient )
206{
207 const double sx = std::abs( aXform.GetScaleX() );
208 const double sy = std::abs( aXform.GetScaleY() );
209
210 if( aDrillShape == PAD_DRILL_SHAPE::CIRCLE )
211 {
212 const double uniform = ( sx + sy ) * 0.5;
213 return { scaleLength( aBoardDrill.x, 1.0 / uniform ), scaleLength( aBoardDrill.y, 1.0 / uniform ) };
214 }
215
216 double localSx, localSy;
217 scaleInChildFrame( sx, sy, aRelOrient, localSx, localSy );
218 return { scaleLength( aBoardDrill.x, 1.0 / localSx ), scaleLength( aBoardDrill.y, 1.0 / localSy ) };
219}
220
221
223static VECTOR2I derivePadBoardOffset( const VECTOR2I& aLibOffset, const TRANSFORM_TRS& aXform,
224 const EDA_ANGLE& aRelOrient )
225{
226 double localSx, localSy;
227 scaleInChildFrame( std::abs( aXform.GetScaleX() ), std::abs( aXform.GetScaleY() ), aRelOrient, localSx, localSy );
228 return { scaleLength( aLibOffset.x, localSx ), scaleLength( aLibOffset.y, localSy ) };
229}
230
231
233static VECTOR2I derivePadLibOffset( const VECTOR2I& aBoardOffset, const TRANSFORM_TRS& aXform,
234 const EDA_ANGLE& aRelOrient )
235{
236 double localSx, localSy;
237 scaleInChildFrame( std::abs( aXform.GetScaleX() ), std::abs( aXform.GetScaleY() ), aRelOrient, localSx, localSy );
238 return { scaleLength( aBoardOffset.x, 1.0 / localSx ), scaleLength( aBoardOffset.y, 1.0 / localSy ) };
239}
240
241} // namespace
242
243
244void PAD::SetPosition( const VECTOR2I& aPos )
245{
246 if( const FOOTPRINT* fp = GetParentFootprint() )
247 m_libPos = fp->GetTransform().InverseApply( aPos );
248 else
249 m_libPos = aPos;
250
251 SetDirty();
252}
253
254
256{
257 if( const FOOTPRINT* fp = GetParentFootprint() )
258 return fp->GetTransform().Apply( m_libPos );
259
260 return m_libPos;
261}
262
263
264void PAD::SetSize( PCB_LAYER_ID aLayer, const VECTOR2I& aSize )
265{
266 if( const FOOTPRINT* fp = GetParentFootprint() )
267 m_padStack.SetSize(
268 derivePadLibSize( aSize, GetShape( aLayer ), fp->GetTransform(), GetFPRelativeOrientation() ), aLayer );
269 else
270 m_padStack.SetSize( aSize, aLayer );
271
272 SetDirty();
273}
274
275
276void PAD::SetLibSize( PCB_LAYER_ID aLayer, const VECTOR2I& aSize )
277{
278 m_padStack.SetSize( aSize, aLayer );
279 SetDirty();
280}
281
282
283void PAD::SetLibDrillSize( const VECTOR2I& aSize )
284{
285 m_padStack.Drill().size = aSize;
286 SetDirty();
287}
288
289
290void PAD::SetLibOffset( PCB_LAYER_ID aLayer, const VECTOR2I& aOffset )
291{
292 m_padStack.Offset( aLayer ) = aOffset;
293 SetDirty();
294}
295
296
298{
299 if( const FOOTPRINT* fp = GetParentFootprint() )
300 return derivePadBoardSize( m_padStack.Size( aLayer ), GetShape( aLayer ), fp->GetTransform(),
302
303 return m_padStack.Size( aLayer );
304}
305
306
307void PAD::SetSizeXProp( int aX )
308{
309 if( aX <= 0 )
310 return;
311
312 int y = GetSize( PADSTACK::ALL_LAYERS ).y;
313
315 y = aX;
316
317 SetSize( PADSTACK::ALL_LAYERS, { aX, y } );
318}
319
320
322{
324}
325
326
327void PAD::SetSizeYProp( int aY )
328{
329 if( aY <= 0 )
330 return;
331
332 int x = GetSize( PADSTACK::ALL_LAYERS ).x;
333
335 x = aY;
336
337 SetSize( PADSTACK::ALL_LAYERS, { x, aY } );
338}
339
340
342{
344}
345
346
347PAD& PAD::operator=( const PAD &aOther )
348{
350
351 ImportSettingsFrom( aOther );
355 SetPosition( aOther.GetPosition() );
356 SetNumber( aOther.GetNumber() );
357 SetPinType( aOther.GetPinType() );
358 SetPinFunction( aOther.GetPinFunction() );
359 SetSubRatsnest( aOther.GetSubRatsnest() );
361
362 return *this;
363}
364
365
366void PAD::CopyFrom( const BOARD_ITEM* aOther )
367{
368 wxCHECK( aOther && aOther->Type() == PCB_PAD_T, /* void */ );
369 *this = *static_cast<const PAD*>( aOther );
370}
371
372
373// This should probably move elsewhere once it is needed elsewhere
374std::optional<std::pair<ELECTRICAL_PINTYPE, bool>> parsePinType( const wxString& aPinTypeString )
375{
376 // The netlister formats the pin type as "<canonical_name>[+no_connect]"
377 static std::map<wxString, ELECTRICAL_PINTYPE> map = {
378 { wxT( "input" ), ELECTRICAL_PINTYPE::PT_INPUT },
379 { wxT( "output" ), ELECTRICAL_PINTYPE::PT_OUTPUT },
380 { wxT( "bidirectional" ), ELECTRICAL_PINTYPE::PT_BIDI },
381 { wxT( "tri_state" ), ELECTRICAL_PINTYPE::PT_TRISTATE },
382 { wxT( "passive" ), ELECTRICAL_PINTYPE::PT_PASSIVE },
383 { wxT( "free" ), ELECTRICAL_PINTYPE::PT_NIC },
384 { wxT( "unspecified" ), ELECTRICAL_PINTYPE::PT_UNSPECIFIED },
385 { wxT( "power_in" ), ELECTRICAL_PINTYPE::PT_POWER_IN },
386 { wxT( "power_out" ), ELECTRICAL_PINTYPE::PT_POWER_OUT },
387 { wxT( "open_collector" ), ELECTRICAL_PINTYPE::PT_OPENCOLLECTOR },
388 { wxT( "open_emitter" ), ELECTRICAL_PINTYPE::PT_OPENEMITTER },
389 { wxT( "no_connect" ), ELECTRICAL_PINTYPE::PT_NC }
390 };
391
392 bool hasNoConnect = aPinTypeString.EndsWith( wxT( "+no_connect" ) );
393
394 if( auto it = map.find( aPinTypeString.BeforeFirst( '+' ) ); it != map.end() )
395 return std::make_pair( it->second, hasNoConnect );
396
397 return std::nullopt;
398}
399
400
401void PAD::Serialize( google::protobuf::Any &aContainer ) const
402{
403 using namespace kiapi::board::types;
404 using namespace kiapi::common::types;
405 Pad pad;
406
407 pad.mutable_id()->set_value( m_Uuid.AsStdString() );
408 kiapi::common::PackVector2( *pad.mutable_position(), GetPosition() );
409 pad.set_locked( IsLocked() ? LockedState::LS_LOCKED
410 : LockedState::LS_UNLOCKED );
411 PackNet( pad.mutable_net() );
412 pad.set_number( GetNumber().ToUTF8() );
414 pad.mutable_pad_to_die_length()->set_value_nm( GetPadToDieLength() );
415 pad.mutable_pad_to_die_delay()->set_value_as( GetPadToDieDelay() );
416
417 m_padStack.Serialize( *pad.mutable_pad_stack() );
418
419 if( GetLocalClearance().has_value() )
420 pad.mutable_copper_clearance_override()->set_value_nm( *GetLocalClearance() );
421
422 pad.mutable_symbol_pin()->set_name( m_pinFunction.ToUTF8() );
423
424 if( std::optional<std::pair<ELECTRICAL_PINTYPE, bool>> pt = parsePinType( m_pinType ) )
425 {
426 pad.mutable_symbol_pin()->set_type( ToProtoEnum<ELECTRICAL_PINTYPE, ElectricalPinType>( pt->first ) );
427 pad.mutable_symbol_pin()->set_no_connect( pt->second );
428 }
429
432
433 if( FOOTPRINT* parent = GetParentFootprint() )
434 pad.mutable_parent()->set_value( parent->m_Uuid.AsStdString() );
435
437
438 {
439 std::unique_lock lock( m_dataMutex );
440 kiapi::board::PackZoneLayerOverrides( pad.mutable_zone_layer_overrides(), m_zoneLayerOverrides );
441 }
442
443 kiapi::common::PackCustomProperties( pad.mutable_custom_properties(), *this );
444
445 if( !aContainer.PackFrom( pad ) )
446 wxFAIL_MSG( wxT( "Failed to pack PAD" ) );
447}
448
449
450bool PAD::Deserialize( const google::protobuf::Any &aContainer )
451{
452 kiapi::board::types::Pad pad;
453
454 if( !aContainer.UnpackTo( &pad ) )
455 return false;
456
457 SetUuidDirect( KIID( pad.id().value() ) );
459 UnpackNet( pad.net() );
460 SetLocked( pad.locked() == kiapi::common::types::LockedState::LS_LOCKED );
462 SetNumber( wxString::FromUTF8( pad.number() ) );
463 SetPadToDieLength( (int) pad.pad_to_die_length().value_nm() );
464 SetPadToDieDelay( (int) pad.pad_to_die_delay().value_as() );
466 SetProperty( FromProtoEnum<PAD_PROP>( pad.fab_property() ) );
467
468 google::protobuf::Any padStackWrapper;
469
470 if( !padStackWrapper.PackFrom( pad.pad_stack() ) )
471 wxFAIL_MSG( wxT( "Failed to pack PADSTACK" ) );
472
473 m_padStack.Deserialize( padStackWrapper );
474 SetOrientation( m_padStack.GetOrientation() );
475
476 SetLayer( m_padStack.StartLayer() );
477
478 if( pad.has_copper_clearance_override() )
479 SetLocalClearance( pad.copper_clearance_override().value_nm() );
480 else
481 SetLocalClearance( std::nullopt );
482
483 m_pinFunction = wxString::FromUTF8( pad.symbol_pin().name() );
484
485 if( pad.symbol_pin().type() != kiapi::common::types::EPT_UNKNOWN )
486 {
487 ELECTRICAL_PINTYPE type = FromProtoEnum<ELECTRICAL_PINTYPE>( pad.symbol_pin().type() );
489
490 if( pad.symbol_pin().no_connect() )
491 m_pinType += wxT( "+no_connect" );
492 }
493
494 if( pad.has_teardrop() )
496 else
497 SetTeardropsEnabled( false );
498
500
501 {
502 std::unique_lock lock( m_dataMutex );
504 }
505
506 kiapi::common::UnpackCustomProperties( pad.custom_properties(), *this );
507
508 return true;
509}
510
511
513{
514 std::unique_lock<std::mutex> cacheLock( m_dataMutex );
515
518}
519
520
522{
523 std::unique_lock<std::mutex> cacheLock( m_dataMutex );
524
525 static const ZONE_LAYER_OVERRIDE defaultOverride = ZLO_NONE;
526 auto it = m_zoneLayerOverrides.find( aLayer );
527 return it != m_zoneLayerOverrides.end() ? it->second : defaultOverride;
528}
529
530
532{
533 std::unique_lock<std::mutex> cacheLock( m_dataMutex );
534 m_zoneLayerOverrides[aLayer] = aOverride;
535}
536
537
539{
540 // Aperture pads don't get a number
541 if( IsAperturePad() )
542 return false;
543
544 // NPTH pads don't get numbers
546 return false;
547
548 return true;
549}
550
551
553{
555 return false;
556
557 bool hasCopper = false;
558
560 [&]( PCB_LAYER_ID layer )
561 {
562 if( GetShape( layer ) == PAD_SHAPE::CIRCLE )
563 {
564 if( GetSize( layer ).x > GetDrillSize().x )
565 hasCopper = true;
566 }
567 else if( GetShape( layer ) == PAD_SHAPE::OVAL )
568 {
569 if( GetSize( layer ).x > GetDrillSize().x || GetSize( layer ).y > GetDrillSize().y )
570 hasCopper = true;
571 }
572 else
573 {
574 hasCopper = true;
575 }
576 } );
577
578 return !hasCopper;
579}
580
581
582bool PAD::IsLocked() const
583{
584 if( GetParent() && GetParent()->IsLocked() )
585 return true;
586
587 return BOARD_ITEM::IsLocked();
588};
589
590
591bool PAD::SharesNetTieGroup( const PAD* aOther ) const
592{
593 FOOTPRINT* parentFp = GetParentFootprint();
594
595 if( parentFp && parentFp->IsNetTie() && aOther->GetParentFootprint() == parentFp )
596 {
597 std::map<wxString, int> padToNetTieGroupMap = parentFp->MapPadNumbersToNetTieGroups();
598 int thisNetTieGroup = padToNetTieGroupMap[ GetNumber() ];
599 int otherNetTieGroup = padToNetTieGroupMap[ aOther->GetNumber() ];
600
601 return thisNetTieGroup >= 0 && thisNetTieGroup == otherNetTieGroup;
602 }
603
604 return false;
605}
606
607
609{
610 return m_pinType.Contains( wxT( "no_connect" ) );
611}
612
613
614bool PAD::IsFreePad() const
615{
616 return GetShortNetname().StartsWith( wxT( "unconnected-(" ) ) && m_pinType == wxT( "free" );
617}
618
619
621{
622 static LSET saved = LSET::AllCuMask() | LSET( { F_Mask, B_Mask } );
623 return saved;
624}
625
626
628{
629 static LSET saved( { F_Cu, F_Paste, F_Mask } );
630 return saved;
631}
632
633
635{
636 static LSET saved( { F_Cu, F_Mask } );
637 return saved;
638}
639
640
642{
643 static LSET saved = LSET( { F_Cu, B_Cu, F_Mask, B_Mask } );
644 return saved;
645}
646
647
649{
650 static LSET saved( { F_Paste } );
651 return saved;
652}
653
654
655bool PAD::IsFlipped() const
656{
657 FOOTPRINT* parent = GetParentFootprint();
658
659 return ( parent && parent->GetLayer() == B_Cu );
660}
661
662
664{
665 return GetPrincipalLayer();
666}
667
668
670{
674 || GetLayerSet().none() )
675 {
676 return m_layer;
677 }
678 else
679 {
680 return GetLayerSet().Seq().front();
681 }
682}
683
684
685bool PAD::FlashLayer( const LSET& aLayers ) const
686{
687 for( PCB_LAYER_ID layer : aLayers )
688 {
689 if( FlashLayer( layer ) )
690 return true;
691 }
692
693 return false;
694}
695
696
697bool PAD::FlashLayer( int aLayer, bool aOnlyCheckIfPermitted ) const
698{
699 if( aLayer == UNDEFINED_LAYER )
700 return true;
701
702 // Sometimes this is called with GAL layers and should just return true
703 if( aLayer > PCB_LAYER_ID_COUNT )
704 return true;
705
706 PCB_LAYER_ID layer = static_cast<PCB_LAYER_ID>( aLayer );
707
708 if( !IsOnLayer( layer ) )
709 return false;
710
711 if( GetAttribute() == PAD_ATTRIB::NPTH && IsCopperLayer( aLayer ) )
712 {
714 {
715 if( GetOffset( layer ) == VECTOR2I( 0, 0 ) && GetDrillSize().x >= GetSize( layer ).x )
716 return false;
717 }
718 else if( GetShape( layer ) == PAD_SHAPE::OVAL
720 {
721 if( GetOffset( layer ) == VECTOR2I( 0, 0 )
722 && GetDrillSize().x >= GetSize( layer ).x
723 && GetDrillSize().y >= GetSize( layer ).y )
724 {
725 return false;
726 }
727 }
728 }
729
730 if( GetAttribute() == PAD_ATTRIB::PTH && ( layer == F_Mask || layer == B_Mask ) )
731 return true;
732
733 if( LSET::FrontBoardTechMask().test( aLayer ) )
734 aLayer = F_Cu;
735 else if( LSET::BackBoardTechMask().test( aLayer ) )
736 aLayer = B_Cu;
737
738 if( GetAttribute() == PAD_ATTRIB::PTH && IsCopperLayer( aLayer ) )
739 {
740 UNCONNECTED_LAYER_MODE mode = m_padStack.UnconnectedLayerMode();
741
743 return true;
744
745 // Plated through hole pads need copper on the top/bottom layers for proper soldering
746 // Unless the user has removed them in the pad dialog
748 {
749 return aLayer == m_padStack.Drill().start || aLayer == m_padStack.Drill().end;
750 }
751
753 && IsExternalCopperLayer( aLayer ) )
754 {
755 return true;
756 }
757
758 if( const BOARD* board = GetBoard() )
759 {
761 {
762 return true;
763 }
764 else if( aOnlyCheckIfPermitted )
765 {
766 return true;
767 }
768 else
769 {
770 // Must be static to keep from raising its ugly head in performance profiles
771 static std::initializer_list<KICAD_T> nonZoneTypes = { PCB_TRACE_T, PCB_ARC_T,
773
774 return board->GetConnectivity()->IsConnectedOnLayer( this, aLayer, nonZoneTypes );
775 }
776 }
777 }
778
779 return true;
780}
781
782
784{
785 if( const FOOTPRINT* fp = GetParentFootprint() )
786 m_padStack.Drill().size =
787 derivePadLibDrill( aSize, GetPrimaryDrillShape(), fp->GetTransform(), GetFPRelativeOrientation() );
788 else
789 m_padStack.Drill().size = aSize;
790
791 SetDirty();
792}
793
794
796{
797 if( const FOOTPRINT* fp = GetParentFootprint() )
798 return derivePadBoardDrill( m_padStack.Drill().size, GetPrimaryDrillShape(), fp->GetTransform(),
800
801 return m_padStack.Drill().size;
802}
803
804
805void PAD::SetPrimaryDrillSizeX( const int aX )
806{
808 drill.x = aX;
809
811 drill.y = aX;
812
813 SetPrimaryDrillSize( drill );
814}
815
816
817void PAD::SetDrillSizeXProp( const int aX )
818{
820}
821
822
823void PAD::SetPrimaryDrillSizeY( const int aY )
824{
826 drill.y = aY;
827 SetPrimaryDrillSize( drill );
828}
829
830
831void PAD::SetDrillSizeYProp( const int aY )
832{
834}
835
836
837void PAD::SetOffset( PCB_LAYER_ID aLayer, const VECTOR2I& aOffset )
838{
839 if( const FOOTPRINT* fp = GetParentFootprint() )
840 m_padStack.Offset( aLayer ) = derivePadLibOffset( aOffset, fp->GetTransform(), GetFPRelativeOrientation() );
841 else
842 m_padStack.Offset( aLayer ) = aOffset;
843
844 SetDirty();
845}
846
847
849{
850 if( const FOOTPRINT* fp = GetParentFootprint() )
851 return derivePadBoardOffset( m_padStack.Offset( aLayer ), fp->GetTransform(), GetFPRelativeOrientation() );
852
853 return m_padStack.Offset( aLayer );
854}
855
856
858{
859 m_padStack.Drill().shape = aShape;
860
861 if( aShape == PAD_DRILL_SHAPE::CIRCLE )
862 m_padStack.Drill().size.y = m_padStack.Drill().size.x;
863
864 m_shapesDirty = true;
865 SetDirty();
866}
867
868
870{
871 m_padStack.Drill().start = aLayer;
872 SetDirty();
873}
874
875
877{
878 m_padStack.Drill().end = aLayer;
879 SetDirty();
880}
881
882
884{
885 return GetBackdrillOrPostMachiningKnockout( aLayer ) > 0;
886}
887
888
890{
891 int knockout = GetBackdrillOrPostMachiningKnockout( aLayer );
892
893 return knockout > 0 && knockout >= 2LL * GetBoundingRadius();
894}
895
896
898{
899 const BOARD* board = GetBoard();
900
901 if( !IsCopperLayer( aLayer ) || !board )
902 return 0;
903
904 return m_padStack.MachiningKnockout( *board, aLayer );
905}
906
907
909{
910 const BOARD* board = GetBoard();
911
912 if( !IsCopperLayer( aLayer ) || !board )
913 return 0;
914
915 return m_padStack.PostMachiningKnockout( board->GetDesignSettings().GetStackupDescriptor(), aLayer );
916}
917
918
919void PAD::SetPrimaryDrillFilled( const std::optional<bool>& aFilled )
920{
921 m_padStack.Drill().is_filled = aFilled;
922 SetDirty();
923}
924
925
927{
928 m_padStack.Drill().is_filled = aFilled;
929 SetDirty();
930}
931
932
933void PAD::SetPrimaryDrillCapped( const std::optional<bool>& aCapped )
934{
935 m_padStack.Drill().is_capped = aCapped;
936 SetDirty();
937}
938
939
941{
942 m_padStack.Drill().is_capped = aCapped;
943 SetDirty();
944}
945
946
948{
949 m_padStack.SecondaryDrill().size = aSize;
950 SetDirty();
951}
952
953
955{
956 m_padStack.SecondaryDrill().size.x = aX;
957
959 m_padStack.SecondaryDrill().size.y = aX;
960
961 SetDirty();
962}
963
964
966{
967 m_padStack.SecondaryDrill().size.y = aY;
968 SetDirty();
969}
970
971
973{
974 m_padStack.SecondaryDrill().size = VECTOR2I( 0, 0 );
975 SetDirty();
976}
977
978
980{
981 m_padStack.SecondaryDrill().shape = aShape;
982 SetDirty();
983}
984
985
987{
988 m_padStack.SecondaryDrill().start = aLayer;
989 SetDirty();
990}
991
992
994{
995 m_padStack.SecondaryDrill().end = aLayer;
996 SetDirty();
997}
998
999
1001{
1002 m_padStack.TertiaryDrill().size = aSize;
1003 SetDirty();
1004}
1005
1006
1008{
1009 m_padStack.TertiaryDrill().size.x = aX;
1010
1012 m_padStack.TertiaryDrill().size.y = aX;
1013
1014 SetDirty();
1015}
1016
1017
1019{
1020 m_padStack.TertiaryDrill().size.y = aY;
1021 SetDirty();
1022}
1023
1024
1026{
1027 m_padStack.TertiaryDrill().size = VECTOR2I( 0, 0 );
1028 SetDirty();
1029}
1030
1031
1033{
1034 m_padStack.TertiaryDrill().shape = aShape;
1035 SetDirty();
1036}
1037
1038
1040{
1041 m_padStack.TertiaryDrill().start = aLayer;
1042 SetDirty();
1043}
1044
1045
1047{
1048 m_padStack.TertiaryDrill().end = aLayer;
1049 SetDirty();
1050}
1051
1052
1054{
1055 return m_padStack.RoundRectRadius( aLayer );
1056}
1057
1058
1059void PAD::SetRoundRectCornerRadius( PCB_LAYER_ID aLayer, double aRadius )
1060{
1061 m_padStack.SetRoundRectRadius( aRadius, aLayer );
1062}
1063
1064
1065void PAD::SetRoundRectRadiusRatio( PCB_LAYER_ID aLayer, double aRadiusScale )
1066{
1067 m_padStack.SetRoundRectRadiusRatio( std::clamp( aRadiusScale, 0.0, 0.5 ), aLayer );
1068
1069 SetDirty();
1070}
1071
1072
1073void PAD::SetFrontRoundRectRadiusRatio( double aRadiusScale )
1074{
1075 wxASSERT_MSG( m_padStack.Mode() == PADSTACK::MODE::NORMAL,
1076 "Set front radius only meaningful for normal padstacks" );
1077
1078 m_padStack.SetRoundRectRadiusRatio( std::clamp( aRadiusScale, 0.0, 0.5 ), F_Cu );
1079 SetDirty();
1080}
1081
1082
1084{
1085 const VECTOR2I size = GetSize( F_Cu );
1086 const int minSize = std::min( size.x, size.y );
1087 const double newRatio = aRadius / double( minSize );
1088
1089 SetFrontRoundRectRadiusRatio( newRatio );
1090}
1091
1092
1094{
1095 const VECTOR2I size = GetSize( F_Cu );
1096 const int minSize = std::min( size.x, size.y );
1097 const double ratio = GetFrontRoundRectRadiusRatio();
1098
1099 return KiROUND( ratio * minSize );
1100}
1101
1102
1103void PAD::SetChamferRectRatio( PCB_LAYER_ID aLayer, double aChamferScale )
1104{
1105 m_padStack.SetChamferRatio( aChamferScale, aLayer );
1106
1107 SetDirty();
1108}
1109
1110
1111const std::shared_ptr<SHAPE_POLY_SET>& PAD::GetEffectivePolygon( PCB_LAYER_ID aLayer, ERROR_LOC aErrorLoc ) const
1112{
1113 if( m_polyDirty[ aErrorLoc ] )
1114 BuildEffectivePolygon( aErrorLoc );
1115
1116 aLayer = Padstack().EffectiveLayerFor( aLayer );
1117
1118 const PAD_DRAW_CACHE_DATA& drawCache = getDrawCache();
1119
1120 return drawCache.m_effectivePolygons.at( aLayer )[ aErrorLoc ];
1121}
1122
1123
1124std::shared_ptr<SHAPE> PAD::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash, DRC_CONSTRAINT_T aUsage ) const
1125{
1126 if( aLayer == Edge_Cuts )
1127 {
1128 std::shared_ptr<SHAPE_COMPOUND> effective_compound = std::make_shared<SHAPE_COMPOUND>();
1129
1131 {
1132 effective_compound->AddShape( GetEffectiveHoleShape( aLayer, aUsage ) );
1133 return effective_compound;
1134 }
1135 else
1136 {
1137 effective_compound->AddShape( std::make_shared<SHAPE_NULL>() );
1138 return effective_compound;
1139 }
1140 }
1141
1142 if( GetAttribute() == PAD_ATTRIB::PTH )
1143 {
1144 bool flash;
1145 std::shared_ptr<SHAPE_COMPOUND> effective_compund = std::make_shared<SHAPE_COMPOUND>();
1146
1147 if( aFlash == FLASHING::NEVER_FLASHED )
1148 flash = false;
1149 else if( aFlash == FLASHING::ALWAYS_FLASHED )
1150 flash = true;
1151 else
1152 flash = FlashLayer( aLayer );
1153
1154 if( !flash )
1155 {
1156 if( GetAttribute() == PAD_ATTRIB::PTH )
1157 {
1158 effective_compund->AddShape( GetEffectiveHoleShape( aLayer, aUsage ) );
1159 return effective_compund;
1160 }
1161 else
1162 {
1163 effective_compund->AddShape( std::make_shared<SHAPE_NULL>() );
1164 return effective_compund;
1165 }
1166 }
1167 }
1168
1169 if( m_shapesDirty )
1171
1172 // A normal padstack keeps one shape, under ALL_LAYERS, so the cache accepts only the remapped
1173 // layer. The machining tests below still use the layer that the caller asked for
1174 PCB_LAYER_ID effectiveLayer = Padstack().EffectiveLayerFor( aLayer );
1175
1176 const PAD_DRAW_CACHE_DATA& drawCache = getDrawCache();
1177
1178 wxCHECK_MSG( drawCache.m_effectiveShapes.contains( effectiveLayer ), nullptr,
1179 wxString::Format( wxT( "Missing shape in PAD::GetEffectiveShape for layer %s." ),
1180 magic_enum::enum_name( effectiveLayer ) ) );
1181 wxCHECK_MSG( drawCache.m_effectiveShapes.at( effectiveLayer ), nullptr,
1182 wxString::Format( wxT( "Null shape in PAD::GetEffectiveShape for layer %s." ),
1183 magic_enum::enum_name( effectiveLayer ) ) );
1184
1185 std::shared_ptr<SHAPE> shape = drawCache.m_effectiveShapes.at( effectiveLayer );
1186
1187 if( IsSolderMaskLayer( aLayer ) )
1188 {
1189 if( int expansion = GetSolderMaskExpansion( aLayer ) )
1190 shape = getMaskShape( aLayer, expansion );
1191 }
1192
1193 // In some cases we want to add in any backdrill or post-machining
1194 if( ( aUsage == PHYSICAL_CLEARANCE_CONSTRAINT || aUsage == SILK_CLEARANCE_CONSTRAINT )
1195 && IsBackdrilledOrPostMachined( aLayer ) )
1196 {
1197 std::shared_ptr<SHAPE_COMPOUND> effective_compound = std::make_shared<SHAPE_COMPOUND>();
1198 effective_compound->AddShape( shape );
1199 effective_compound->AddShape( GetEffectiveHoleShape( aLayer, aUsage ) );
1200 return effective_compound;
1201 }
1202
1203 return shape;
1204}
1205
1206
1207std::shared_ptr<SHAPE_COMPOUND> PAD::getMaskShape( PCB_LAYER_ID aLayer, int aExpansion ) const
1208{
1209 {
1210 std::lock_guard<std::mutex> RAII_lock( m_maskShapeMutex );
1211 auto it = m_maskShapes.find( aLayer );
1212
1213 if( it != m_maskShapes.end() && it->second.first == aExpansion )
1214 return it->second.second;
1215 }
1216
1217 // Built outside the lock because this can re-enter the pad through the rule engine
1218 SHAPE_POLY_SET aperture;
1219 TransformShapeToPolygon( aperture, aLayer, aExpansion, GetMaxError(), ERROR_OUTSIDE );
1220
1221 std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
1222
1223 for( int ii = 0; ii < aperture.OutlineCount(); ++ii )
1224 shape->AddShape( new SHAPE_SIMPLE( aperture.COutline( ii ) ) );
1225
1226 std::lock_guard<std::mutex> RAII_lock( m_maskShapeMutex );
1227 m_maskShapes[aLayer] = { aExpansion, shape };
1228
1229 return shape;
1230}
1231
1232
1233std::shared_ptr<SHAPE_SEGMENT> PAD::GetEffectiveHoleShape( PCB_LAYER_ID aLayer, DRC_CONSTRAINT_T aUsage ) const
1234{
1235 if( m_shapesDirty )
1237
1238 if( aUsage == HOLE_TO_HOLE_CONSTRAINT
1239 || ( aUsage == HOLE_CLEARANCE_CONSTRAINT && IsBackdrilledOrPostMachined( aLayer ) )
1240 || ( aUsage == ANNULAR_WIDTH_CONSTRAINT && IsBackdrilledOrPostMachined( aLayer ) )
1242 || ( aUsage == SILK_CLEARANCE_CONSTRAINT && IsBackdrilledOrPostMachined( aLayer ) ) )
1243 {
1244 int maxHoleSize = Padstack().GetMaxHoleSize();
1245
1246 // If it's bigger than the pad's hole, return it
1247 if( maxHoleSize > getDrawCache().m_effectiveHoleShape->GetWidth() )
1248 return std::make_shared<SHAPE_SEGMENT>( GetPosition(), GetPosition(), maxHoleSize );
1249 }
1250
1252}
1253
1254
1262
1263
1265{
1266 if( !m_drawCache )
1267 m_drawCache = std::make_unique<PAD_DRAW_CACHE_DATA>();
1268
1269 return *m_drawCache;
1270}
1271
1272
1274{
1275 std::lock_guard<std::mutex> RAII_lock( m_dataMutex );
1276
1277 // If we had to wait for the lock then we were probably waiting for someone else to
1278 // finish rebuilding the shapes. So check to see if they're clean now.
1279 if( !m_shapesDirty )
1280 return;
1281
1282 PAD_DRAW_CACHE_DATA& drawCache = getDrawCache();
1283
1284 drawCache.m_effectiveBoundingBox = BOX2I();
1285 drawCache.m_effectiveShapes.clear();
1286
1287 {
1288 std::lock_guard<std::mutex> RAII_maskLock( m_maskShapeMutex );
1289 m_maskShapes.clear();
1290 }
1291
1293 [&]( PCB_LAYER_ID aLayer )
1294 {
1295 const SHAPE_COMPOUND& layerShape = buildEffectiveShape( aLayer );
1296 drawCache.m_effectiveBoundingBox.Merge( layerShape.BBox() );
1297 } );
1298
1299 // Hole shape
1300 drawCache.m_effectiveHoleShape = nullptr;
1301
1302 VECTOR2I half_size = GetDrillSize() / 2;
1303 int half_width;
1304 VECTOR2I half_len;
1305
1306 if( m_padStack.Drill().shape == PAD_DRILL_SHAPE::CIRCLE )
1307 {
1308 half_width = half_size.x;
1309 }
1310 else
1311 {
1312 half_width = std::min( half_size.x, half_size.y );
1313 half_len = VECTOR2I( half_size.x - half_width, half_size.y - half_width );
1314 }
1315
1316 RotatePoint( half_len, GetOrientation() );
1317
1318 VECTOR2I pos = GetPosition();
1319 drawCache.m_effectiveHoleShape = std::make_shared<SHAPE_SEGMENT>( pos - half_len, pos + half_len, half_width * 2 );
1320
1321 drawCache.m_effectiveBoundingBox.Merge( drawCache.m_effectiveHoleShape->BBox() );
1322
1323 if( m_padStack.Drill().shape == PAD_DRILL_SHAPE::CIRCLE )
1324 {
1325 int maxHole = m_padStack.GetMaxHoleSize();
1326 drawCache.m_effectiveBoundingBox.Merge( BOX2I::ByCenter( pos, VECTOR2I( maxHole, maxHole ) ) );
1327 }
1328
1329 // All done
1330 m_shapesDirty = false;
1331}
1332
1333
1335{
1336 PAD_DRAW_CACHE_DATA& drawCache = getDrawCache();
1337
1338 drawCache.m_effectiveShapes[aLayer] = std::make_shared<SHAPE_COMPOUND>();
1339
1340 auto add = [this, aLayer]( SHAPE* aShape )
1341 {
1342 getDrawCache().m_effectiveShapes[aLayer]->AddShape( aShape );
1343 };
1344
1345 VECTOR2I shapePos = ShapePos( aLayer ); // Fetch only once; rotation involves trig
1346 PAD_SHAPE effectiveShape = GetShape( aLayer );
1347 const VECTOR2I size = GetSize( aLayer );
1348
1349 if( effectiveShape == PAD_SHAPE::CUSTOM )
1350 effectiveShape = GetAnchorPadShape( aLayer );
1351
1352 switch( effectiveShape )
1353 {
1354 case PAD_SHAPE::CIRCLE:
1355 add( new SHAPE_CIRCLE( shapePos, size.x / 2 ) );
1356 break;
1357
1358 case PAD_SHAPE::OVAL:
1359 if( size.x == size.y ) // the oval pad is in fact a circle
1360 {
1361 add( new SHAPE_CIRCLE( shapePos, size.x / 2 ) );
1362 }
1363 else
1364 {
1365 VECTOR2I half_size = size / 2;
1366 int half_width = std::min( half_size.x, half_size.y );
1367 VECTOR2I half_len( half_size.x - half_width, half_size.y - half_width );
1368 RotatePoint( half_len, GetOrientation() );
1369 add( new SHAPE_SEGMENT( shapePos - half_len, shapePos + half_len, half_width * 2 ) );
1370 }
1371
1372 break;
1373
1377 {
1378 int r = ( effectiveShape == PAD_SHAPE::ROUNDRECT ) ? GetRoundRectCornerRadius( aLayer ) : 0;
1379 VECTOR2I half_size( size.x / 2, size.y / 2 );
1380 VECTOR2I trap_delta( 0, 0 );
1381
1382 if( r )
1383 {
1384 half_size -= VECTOR2I( r, r );
1385
1386 // Avoid degenerated shapes (0 length segments) that always create issues
1387 // For roundrect pad very near a circle, use only a circle
1388 const int min_len = pcbIUScale.mmToIU( 0.0001 );
1389
1390 if( half_size.x < min_len && half_size.y < min_len )
1391 {
1392 add( new SHAPE_CIRCLE( shapePos, r ) );
1393 break;
1394 }
1395 }
1396 else if( effectiveShape == PAD_SHAPE::TRAPEZOID )
1397 {
1398 trap_delta = m_padStack.TrapezoidDeltaSize( aLayer ) / 2;
1399 }
1400
1401 SHAPE_LINE_CHAIN corners;
1402
1403 corners.Append( -half_size.x - trap_delta.y, half_size.y + trap_delta.x );
1404 corners.Append( half_size.x + trap_delta.y, half_size.y - trap_delta.x );
1405 corners.Append( half_size.x - trap_delta.y, -half_size.y + trap_delta.x );
1406 corners.Append( -half_size.x + trap_delta.y, -half_size.y - trap_delta.x );
1407
1408 corners.Rotate( GetOrientation() );
1409 corners.Move( shapePos );
1410
1411 // GAL renders rectangles faster than 4-point polygons so it's worth checking if our
1412 // body shape is a rectangle.
1413 if( corners.PointCount() == 4
1414 &&
1415 ( ( corners.CPoint( 0 ).y == corners.CPoint( 1 ).y
1416 && corners.CPoint( 1 ).x == corners.CPoint( 2 ).x
1417 && corners.CPoint( 2 ).y == corners.CPoint( 3 ).y
1418 && corners.CPoint( 3 ).x == corners.CPoint( 0 ).x )
1419 ||
1420 ( corners.CPoint( 0 ).x == corners.CPoint( 1 ).x
1421 && corners.CPoint( 1 ).y == corners.CPoint( 2 ).y
1422 && corners.CPoint( 2 ).x == corners.CPoint( 3 ).x
1423 && corners.CPoint( 3 ).y == corners.CPoint( 0 ).y )
1424 )
1425 )
1426 {
1427 int width = std::abs( corners.CPoint( 2 ).x - corners.CPoint( 0 ).x );
1428 int height = std::abs( corners.CPoint( 2 ).y - corners.CPoint( 0 ).y );
1429 VECTOR2I pos( std::min( corners.CPoint( 2 ).x, corners.CPoint( 0 ).x ),
1430 std::min( corners.CPoint( 2 ).y, corners.CPoint( 0 ).y ) );
1431
1432 add( new SHAPE_RECT( pos, width, height ) );
1433 }
1434 else
1435 {
1436 add( new SHAPE_SIMPLE( corners ) );
1437 }
1438
1439 if( r )
1440 {
1441 add( new SHAPE_SEGMENT( corners.CPoint( 0 ), corners.CPoint( 1 ), r * 2 ) );
1442 add( new SHAPE_SEGMENT( corners.CPoint( 1 ), corners.CPoint( 2 ), r * 2 ) );
1443 add( new SHAPE_SEGMENT( corners.CPoint( 2 ), corners.CPoint( 3 ), r * 2 ) );
1444 add( new SHAPE_SEGMENT( corners.CPoint( 3 ), corners.CPoint( 0 ), r * 2 ) );
1445 }
1446 }
1447 break;
1448
1450 {
1451 SHAPE_POLY_SET outline;
1452
1453 TransformRoundChamferedRectToPolygon( outline, shapePos, GetSize( aLayer ),
1455 GetChamferRectRatio( aLayer ),
1456 GetChamferPositions( aLayer ), 0, GetMaxError(),
1457 ERROR_INSIDE );
1458
1459 add( new SHAPE_SIMPLE( outline.COutline( 0 ) ) );
1460 }
1461 break;
1462
1463 default:
1464 wxFAIL_MSG( wxT( "PAD::buildEffectiveShapes: Unsupported pad shape: PAD_SHAPE::" )
1465 + wxString( std::string( magic_enum::enum_name( effectiveShape ) ) ) );
1466 break;
1467 }
1468
1469 if( GetShape( aLayer ) == PAD_SHAPE::CUSTOM )
1470 {
1471 for( const std::shared_ptr<PCB_SHAPE>& primitive : m_padStack.Primitives( aLayer ) )
1472 {
1473 if( !primitive->IsProxyItem() )
1474 {
1475 for( SHAPE* shape : primitive->MakeEffectiveShapes() )
1476 {
1477 shape->Rotate( GetOrientation() );
1478 shape->Move( shapePos );
1479 add( shape );
1480 }
1481 }
1482 }
1483 }
1484
1485 return *drawCache.m_effectiveShapes[aLayer];
1486}
1487
1488
1490{
1491 std::lock_guard<std::mutex> RAII_lock( m_dataMutex );
1492
1493 // Only calculate this once, not for both ERROR_INSIDE and ERROR_OUTSIDE
1494 bool doBoundingRadius = aErrorLoc == ERROR_OUTSIDE;
1495
1496 // If we had to wait for the lock then we were probably waiting for someone else to
1497 // finish rebuilding the shapes. So check to see if they're clean now.
1498 if( !m_polyDirty[ aErrorLoc ] )
1499 return;
1500
1501 PAD_DRAW_CACHE_DATA& drawCache = getDrawCache();
1502
1504 [&]( PCB_LAYER_ID aLayer )
1505 {
1506 // Polygon
1507 std::shared_ptr<SHAPE_POLY_SET>& effectivePolygon =
1508 drawCache.m_effectivePolygons[ aLayer ][ aErrorLoc ];
1509
1510 effectivePolygon = std::make_shared<SHAPE_POLY_SET>();
1511 TransformShapeToPolygon( *effectivePolygon, aLayer, 0, GetMaxError(), aErrorLoc );
1512 } );
1513
1514 if( doBoundingRadius )
1515 {
1517
1519 [&]( PCB_LAYER_ID aLayer )
1520 {
1521 std::shared_ptr<SHAPE_POLY_SET>& effectivePolygon =
1522 drawCache.m_effectivePolygons[ aLayer ][ aErrorLoc ];
1523
1524 for( int cnt = 0; cnt < effectivePolygon->OutlineCount(); ++cnt )
1525 {
1526 const SHAPE_LINE_CHAIN& poly = effectivePolygon->COutline( cnt );
1527
1528 for( int ii = 0; ii < poly.PointCount(); ++ii )
1529 {
1530 int dist = KiROUND( ( poly.CPoint( ii ) - GetPosition() ).EuclideanNorm() );
1532 }
1533 }
1534 } );
1535
1538 }
1539
1540 // All done
1541 m_polyDirty[ aErrorLoc ] = false;
1542}
1543
1544
1546{
1547 if( m_shapesDirty )
1549
1551}
1552
1553
1554// Thermal spokes are built on the bounding box, so we must have a layer-specific version
1556{
1557 std::lock_guard<std::mutex> RAII_lock( m_dataMutex );
1558
1559 return buildEffectiveShape( aLayer ).BBox();
1560}
1561
1562
1564{
1565 if( m_attribute != aAttribute )
1566 {
1567 m_attribute = aAttribute;
1568
1569 LSET& layerMask = m_padStack.LayerSet();
1570
1571 switch( aAttribute )
1572 {
1573 case PAD_ATTRIB::PTH:
1574 // Plump up to all copper layers
1575 layerMask |= LSET::AllCuMask();
1576 break;
1577
1578 case PAD_ATTRIB::SMD:
1579 case PAD_ATTRIB::CONN:
1581 {
1582 // Trim down to no more than one copper layer
1583 const LSET copperLayers = layerMask & LSET::AllCuMask();
1584
1585 if( copperLayers.count() > 1 )
1586 {
1587 layerMask &= ~LSET::AllCuMask();
1588
1589 if( copperLayers.test( B_Cu ) )
1590 m_layer = B_Cu;
1591 else
1592 m_layer = copperLayers.Seq().front();
1593
1594 layerMask.set( m_layer );
1595 }
1596
1597 // No hole, so no drilling of any kind
1599 break;
1600 }
1601
1602 case PAD_ATTRIB::NPTH:
1603 // No number; no net
1604 m_number = wxEmptyString;
1606 break;
1607 }
1608
1609 if( !( GetFlags() & ROUTER_TRANSIENT ) )
1610 {
1611 if( BOARD* board = GetBoard() )
1612 board->InvalidateClearanceCache( m_Uuid );
1613 }
1614 }
1615
1616 SetDirty();
1617}
1618
1619
1621{
1622 const bool wasRoundable = PAD_UTILS::PadHasMeaningfulRoundingRadius( *this, F_Cu );
1623
1624 m_padStack.SetShape( aShape, F_Cu );
1625
1626 const bool isRoundable = PAD_UTILS::PadHasMeaningfulRoundingRadius( *this, F_Cu );
1627
1628 // If we have become roundable, set a sensible rounding default using the IPC rules.
1629 if( !wasRoundable && isRoundable )
1630 {
1631 const double ipcRadiusRatio = PAD_UTILS::GetDefaultIpcRoundingRatio( *this, F_Cu );
1632 m_padStack.SetRoundRectRadiusRatio( ipcRadiusRatio, F_Cu );
1633 }
1634
1635 SetDirty();
1636}
1637
1638
1640{
1641 m_property = aProperty;
1642
1643 SetDirty();
1644}
1645
1646
1647void PAD::SetOrientation( const EDA_ANGLE& aAngle )
1648{
1649 if( const FOOTPRINT* parentFP = GetParentFootprint() )
1650 m_libOrientation = aAngle - parentFP->GetOrientation();
1651 else
1652 m_libOrientation = aAngle;
1653
1654 m_padStack.SetOrientation( aAngle );
1655 SetDirty();
1656}
1657
1658
1660{
1661 m_libOrientation = aAngle;
1662
1663 if( const FOOTPRINT* parentFP = GetParentFootprint() )
1664 m_padStack.SetOrientation( aAngle + parentFP->GetOrientation() );
1665 else
1666 m_padStack.SetOrientation( aAngle );
1667
1668 SetDirty();
1669}
1670
1671
1673{
1674 if( const FOOTPRINT* parentFP = GetParentFootprint() )
1675 {
1676 EDA_ANGLE angle = m_libOrientation.GetAngle() + parentFP->GetOrientation();
1677 return angle.Normalized();
1678 }
1679
1680 return m_libOrientation.GetAngle();
1681}
1682
1683
1685{
1686 return m_libOrientation.GetAngle();
1687}
1688
1689
1690void PAD::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
1691{
1692 if( const FOOTPRINT* fp = GetParentFootprint() )
1693 {
1694 // Mirror in the footprint's library frame (rotation-independent).
1695 VECTOR2I libCentre = fp->GetTransform().InverseApply( aCentre );
1696 MIRROR( m_libPos, libCentre, aFlipDirection );
1697 }
1698 else
1699 {
1700 VECTOR2I newPos = GetPosition();
1701 MIRROR( newPos, aCentre, aFlipDirection );
1702 SetPosition( newPos );
1703 }
1704
1705 m_padStack.ForEachUniqueLayer(
1706 [&]( PCB_LAYER_ID aLayer )
1707 {
1708 MIRROR( m_padStack.Offset( aLayer ), VECTOR2I{ 0, 0 }, aFlipDirection );
1709 MIRROR( m_padStack.TrapezoidDeltaSize( aLayer ), VECTOR2I{ 0, 0 }, aFlipDirection );
1710 } );
1711
1713
1714 mirrorChamferPositions( aFlipDirection );
1715
1716 m_padStack.FlipLayers( GetBoard() );
1717
1718 // Flip pads layers after padstack geometry
1719 LSET flipped;
1720
1721 for( PCB_LAYER_ID layer : m_padStack.LayerSet() )
1722 flipped.set( GetFlippedLayer( layer ) );
1723
1724 SetLayerSet( flipped );
1725
1726 // Flip the basic shapes, in custom pads
1727 FlipPrimitives( aFlipDirection );
1728
1729 SetDirty();
1730}
1731
1732
1734{
1736 [&]( PCB_LAYER_ID aLayer )
1737 {
1738 for( std::shared_ptr<PCB_SHAPE>& primitive : m_padStack.Primitives( aLayer ) )
1739 {
1740 // Ensure the primitive parent is up to date. Flip uses GetBoard() that
1741 // imply primitive parent is valid
1742 primitive->SetParent(this);
1743 primitive->Flip( VECTOR2I( 0, 0 ), aFlipDirection );
1744 }
1745 } );
1746
1747 SetDirty();
1748}
1749
1750
1751void PAD::Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
1752{
1753 Mirror( MIRROR_AXIS( aCentre, aFlipDirection ) );
1754}
1755
1756
1757void PAD::Mirror( const SEG& aAxis )
1758{
1759 // Unlike Flip(), a mirror keeps the pad on its side, so only the geometry moves, which
1760 // is relative to the pad's own origin.
1761 const SEG padXAxis( VECTOR2I( 0, 0 ), VECTOR2I( 1, 0 ) );
1762 const EDA_ANGLE axisAngle = -EDA_ANGLE( aAxis.B - aAxis.A );
1763
1764 SetPosition( aAxis.ReflectPoint( GetPosition() ) );
1765 SetOrientation( GetOrientation().Reflect( axisAngle ) );
1766
1768
1769 m_padStack.ForEachUniqueLayer(
1770 [&]( PCB_LAYER_ID aLayer )
1771 {
1772 MIRROR( m_padStack.Offset( aLayer ), VECTOR2I{ 0, 0 }, FLIP_DIRECTION::TOP_BOTTOM );
1773 MIRROR( m_padStack.TrapezoidDeltaSize( aLayer ), VECTOR2I{ 0, 0 }, FLIP_DIRECTION::TOP_BOTTOM );
1774
1775 for( const std::shared_ptr<PCB_SHAPE>& primitive : m_padStack.Primitives( aLayer ) )
1776 {
1777 primitive->SetParent( this );
1778 primitive->Mirror( padXAxis );
1779 }
1780 } );
1781
1782 SetDirty();
1783}
1784
1785
1787{
1788 const auto mirrorBitFlags =
1789 []( int& aBitfield, int a, int b )
1790 {
1791 bool temp = aBitfield & a;
1792
1793 if( aBitfield & b )
1794 aBitfield |= a;
1795 else
1796 aBitfield &= ~a;
1797
1798 if( temp )
1799 aBitfield |= b;
1800 else
1801 aBitfield &= ~b;
1802 };
1803
1804 m_padStack.ForEachUniqueLayer(
1805 [&]( PCB_LAYER_ID aLayer )
1806 {
1807 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
1808 {
1809 mirrorBitFlags( m_padStack.ChamferPositions( aLayer ), RECT_CHAMFER_TOP_LEFT,
1811 mirrorBitFlags( m_padStack.ChamferPositions( aLayer ), RECT_CHAMFER_BOTTOM_LEFT,
1813 }
1814 else
1815 {
1816 mirrorBitFlags( m_padStack.ChamferPositions( aLayer ), RECT_CHAMFER_TOP_LEFT,
1818 mirrorBitFlags( m_padStack.ChamferPositions( aLayer ), RECT_CHAMFER_TOP_RIGHT,
1820 }
1821 } );
1822}
1823
1824
1826{
1827 VECTOR2I pos = GetPosition();
1828 VECTOR2I loc_offset = GetOffset( aLayer );
1829
1830 if( loc_offset.x == 0 && loc_offset.y == 0 )
1831 return pos;
1832
1833 RotatePoint( loc_offset, GetOrientation() );
1834
1835 return pos + loc_offset;
1836}
1837
1838
1839void PAD::SwapShapePositions( PAD* aLhs, PAD* aRhs, PCB_LAYER_ID aActiveLayer )
1840{
1841 wxCHECK( aLhs && aRhs, /* void */ );
1842
1843 // This routine favours the center of the visual copper over the center of the hole.
1844 // The downside is that said center is ill-defined when there is more than one shape
1845 // (ie: for complex padstackes). In that case we swap based on the active layer's
1846 // copper shape, following the principle of least surprise.
1847
1848 VECTOR2I lhsShapePos = aLhs->ShapePos( aActiveLayer );
1849 VECTOR2I rhsShapePos = aRhs->ShapePos( aActiveLayer );
1850
1851 VECTOR2I lhsOffset = aLhs->GetOffset( aActiveLayer );
1852 VECTOR2I rhsOffset = aRhs->GetOffset( aActiveLayer );
1853
1854 RotatePoint( lhsOffset, aLhs->GetOrientation() );
1855 RotatePoint( rhsOffset, aRhs->GetOrientation() );
1856
1857 aLhs->SetPosition( rhsShapePos - lhsOffset );
1858 aRhs->SetPosition( lhsShapePos - rhsOffset );
1859}
1860
1861
1863{
1865 {
1866 // NPTH pads have no plated hole cylinder. If their annular ring size is 0 or
1867 // negative, then they have no annular ring either.
1868 bool hasAnnularRing = true;
1869
1871 [&]( PCB_LAYER_ID aLayer )
1872 {
1873 switch( GetShape( aLayer ) )
1874 {
1875 case PAD_SHAPE::CIRCLE:
1876 if( m_padStack.Offset( aLayer ) == VECTOR2I( 0, 0 )
1877 && m_padStack.Size( aLayer ).x <= m_padStack.Drill().size.x )
1878 {
1879 hasAnnularRing = false;
1880 }
1881
1882 break;
1883
1884 case PAD_SHAPE::OVAL:
1885 if( m_padStack.Offset( aLayer ) == VECTOR2I( 0, 0 )
1886 && m_padStack.Size( aLayer ).x <= m_padStack.Drill().size.x
1887 && m_padStack.Size( aLayer ).y <= m_padStack.Drill().size.y )
1888 {
1889 hasAnnularRing = false;
1890 }
1891
1892 break;
1893
1894 default:
1895 // We could subtract the hole polygon from the shape polygon for these, but it
1896 // would be expensive and we're probably well out of the common use cases....
1897 break;
1898 }
1899 } );
1900
1901 if( !hasAnnularRing )
1902 return false;
1903 }
1904
1905 return ( m_padStack.LayerSet() & LSET::AllCuMask() ).any();
1906}
1907
1908
1909std::optional<int> PAD::GetLocalClearance( wxString* aSource ) const
1910{
1911 if( m_padStack.Clearance().has_value() && aSource )
1912 *aSource = _( "pad" );
1913
1914 return m_padStack.Clearance();
1915}
1916
1917
1918std::optional<int> PAD::GetClearanceOverrides( wxString* aSource ) const
1919{
1920 if( m_padStack.Clearance().has_value() )
1921 return GetLocalClearance( aSource );
1922
1923 if( FOOTPRINT* parentFootprint = GetParentFootprint() )
1924 return parentFootprint->GetClearanceOverrides( aSource );
1925
1926 return std::optional<int>();
1927}
1928
1929
1930void PAD::SetLayerSet( const LSET& aLayers )
1931{
1932 m_padStack.SetLayerSet( aLayers );
1933 SetDirty();
1934
1935 // In theory m_layer should never be read, but set it just to be safe.
1936 if( m_layer == UNDEFINED_LAYER || !aLayers.test( m_layer ) )
1937 {
1938 auto seq = aLayers.Seq();
1939 if( !seq.empty() )
1940 m_layer = seq.front();
1941 else
1943 }
1944
1945 if( !( GetFlags() & ROUTER_TRANSIENT ) )
1946 {
1947 if( BOARD* board = GetBoard() )
1948 board->InvalidateClearanceCache( m_Uuid );
1949 }
1950}
1951
1952
1953int PAD::GetOwnClearance( PCB_LAYER_ID aLayer, wxString* aSource ) const
1954{
1955 // The NPTH vs regular pad logic is handled in DRC_ENGINE::GetCachedOwnClearance
1956 return BOARD_CONNECTED_ITEM::GetOwnClearance( aLayer, aSource );
1957}
1958
1959
1961{
1962 // Pads defined only on mask layers (and perhaps on other tech layers) use the shape
1963 // defined by the pad settings only. ALL other pads, even those that don't actually have
1964 // any copper (such as NPTH pads with holes the same size as the pad) get mask expansion.
1965 if( ( m_padStack.LayerSet() & LSET::AllCuMask() ).none() )
1966 return 0;
1967
1968 if( IsFrontLayer( aLayer ) )
1969 aLayer = F_Mask;
1970 else if( IsBackLayer( aLayer ) )
1971 aLayer = B_Mask;
1972 else
1973 return 0;
1974
1975 std::optional<int> margin;
1976
1977 if( GetBoard() && GetBoard()->GetDesignSettings().m_DRCEngine
1978 && GetBoard()->GetDesignSettings().m_DRCEngine->HasRulesForConstraintType( SOLDER_MASK_EXPANSION_CONSTRAINT ) )
1979 {
1980 DRC_CONSTRAINT constraint;
1981 DRC_ENGINE* drcEngine = GetBoard()->GetDesignSettings().m_DRCEngine.get();
1982
1983 constraint = drcEngine->EvalRules( SOLDER_MASK_EXPANSION_CONSTRAINT, this, nullptr, aLayer );
1984
1985 if( constraint.m_Value.HasOpt() )
1986 margin = constraint.m_Value.Opt();
1987 }
1988 else
1989 {
1990 margin = m_padStack.SolderMaskMargin( aLayer );
1991
1992 if( !margin.has_value() )
1993 {
1994 if( FOOTPRINT* parentFootprint = GetParentFootprint() )
1995 margin = parentFootprint->GetLocalSolderMaskMargin();
1996 }
1997
1998 if( !margin.has_value() )
1999 {
2000 if( const BOARD* brd = GetBoard() )
2001 margin = brd->GetDesignSettings().m_SolderMaskExpansion;
2002 }
2003 }
2004
2005 int marginValue = margin.value_or( 0 );
2006
2007 PCB_LAYER_ID cuLayer = ( aLayer == B_Mask ) ? B_Cu : F_Cu;
2008
2009 // ensure mask have a size always >= 0
2010 if( marginValue < 0 )
2011 {
2012 int minsize = -std::min( m_padStack.Size( cuLayer ).x, m_padStack.Size( cuLayer ).y ) / 2;
2013
2014 if( marginValue < minsize )
2015 marginValue = minsize;
2016 }
2017
2018 return marginValue;
2019}
2020
2021
2023{
2024 // Pads defined only on mask layers (and perhaps on other tech layers) use the shape
2025 // defined by the pad settings only. ALL other pads, even those that don't actually have
2026 // any copper (such as NPTH pads with holes the same size as the pad) get paste expansion.
2027 if( ( m_padStack.LayerSet() & LSET::AllCuMask() ).none() )
2028 return VECTOR2I( 0, 0 );
2029
2030 if( IsFrontLayer( aLayer ) )
2031 aLayer = F_Paste;
2032 else if( IsBackLayer( aLayer ) )
2033 aLayer = B_Paste;
2034 else
2035 return VECTOR2I( 0, 0 );
2036
2037 std::optional<int> margin;
2038 std::optional<double> mratio;
2039
2040 std::shared_ptr<DRC_ENGINE> drcEngine;
2041
2042 if( GetBoard() )
2043 drcEngine = GetBoard()->GetDesignSettings().m_DRCEngine;
2044
2045 bool hasAbsRules = drcEngine
2046 && drcEngine->HasRulesForConstraintType( SOLDER_PASTE_ABS_MARGIN_CONSTRAINT );
2047 bool hasRelRules = drcEngine
2048 && drcEngine->HasRulesForConstraintType( SOLDER_PASTE_REL_MARGIN_CONSTRAINT );
2049
2050 if( hasAbsRules || hasRelRules )
2051 {
2052 DRC_CONSTRAINT constraint;
2053
2054 if( hasAbsRules )
2055 {
2056 constraint = drcEngine->EvalRules( SOLDER_PASTE_ABS_MARGIN_CONSTRAINT, this, nullptr,
2057 aLayer );
2058
2059 if( constraint.m_Value.HasOpt() )
2060 margin = constraint.m_Value.Opt();
2061 }
2062
2063 if( hasRelRules )
2064 {
2065 constraint = drcEngine->EvalRules( SOLDER_PASTE_REL_MARGIN_CONSTRAINT, this, nullptr,
2066 aLayer );
2067
2068 if( constraint.m_Value.HasOpt() )
2069 mratio = constraint.m_Value.Opt() / 1000.0;
2070 }
2071 }
2072
2073 if( !margin.has_value() )
2074 {
2075 margin = m_padStack.SolderPasteMargin( aLayer );
2076
2077 if( !margin.has_value() )
2078 {
2079 if( FOOTPRINT* parentFootprint = GetParentFootprint() )
2080 margin = parentFootprint->GetLocalSolderPasteMargin();
2081 }
2082
2083 if( !margin.has_value() )
2084 {
2085 if( const BOARD* brd = GetBoard() )
2086 margin = brd->GetDesignSettings().m_SolderPasteMargin;
2087 }
2088 }
2089
2090 if( !mratio.has_value() )
2091 {
2092 mratio = m_padStack.SolderPasteMarginRatio( aLayer );
2093
2094 if( !mratio.has_value() )
2095 {
2096 if( FOOTPRINT* parentFootprint = GetParentFootprint() )
2097 mratio = parentFootprint->GetLocalSolderPasteMarginRatio();
2098 }
2099
2100 if( !mratio.has_value() )
2101 {
2102 if( const BOARD* brd = GetBoard() )
2103 mratio = brd->GetDesignSettings().m_SolderPasteMarginRatio;
2104 }
2105 }
2106
2107 PCB_LAYER_ID cuLayer = ( aLayer == B_Paste ) ? B_Cu : F_Cu;
2108 VECTOR2I padSize = GetSize( cuLayer );
2109
2110 VECTOR2I pad_margin;
2111 pad_margin.x = margin.value_or( 0 ) + KiROUND( padSize.x * mratio.value_or( 0 ) );
2112 pad_margin.y = margin.value_or( 0 ) + KiROUND( padSize.y * mratio.value_or( 0 ) );
2113
2114 // ensure paste have a size always >= 0
2115 if( m_padStack.Shape( aLayer ) != PAD_SHAPE::CUSTOM )
2116 {
2117 if( pad_margin.x < -padSize.x / 2 )
2118 pad_margin.x = -padSize.x / 2;
2119
2120 if( pad_margin.y < -padSize.y / 2 )
2121 pad_margin.y = -padSize.y / 2;
2122 }
2123
2124 return pad_margin;
2125}
2126
2127
2129{
2130 ZONE_CONNECTION connection = m_padStack.ZoneConnection().value_or( ZONE_CONNECTION::INHERITED );
2131
2132 if( connection != ZONE_CONNECTION::INHERITED )
2133 {
2134 if( aSource )
2135 *aSource = _( "pad" );
2136 }
2137
2138 if( connection == ZONE_CONNECTION::INHERITED )
2139 {
2140 if( FOOTPRINT* parentFootprint = GetParentFootprint() )
2141 connection = parentFootprint->GetZoneConnectionOverrides( aSource );
2142 }
2143
2144 return connection;
2145}
2146
2147
2148int PAD::GetLocalSpokeWidthOverride( wxString* aSource ) const
2149{
2150 if( m_padStack.ThermalSpokeWidth().has_value() && aSource )
2151 *aSource = _( "pad" );
2152
2153 return m_padStack.ThermalSpokeWidth().value_or( 0 );
2154}
2155
2156
2157int PAD::GetLocalThermalGapOverride( wxString* aSource ) const
2158{
2159 if( m_padStack.ThermalGap().has_value() && aSource )
2160 *aSource = _( "pad" );
2161
2162 return GetLocalThermalGapOverride().value_or( 0 );
2163}
2164
2165
2166void PAD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
2167{
2168 wxString msg;
2169 FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( m_parent );
2170
2171 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME )
2172 {
2173 if( parentFootprint )
2174 aList.emplace_back( _( "Footprint" ), parentFootprint->GetReference() );
2175 }
2176
2177 aList.emplace_back( _( "Pad" ), m_number );
2178
2179 if( !GetPinFunction().IsEmpty() )
2180 aList.emplace_back( _( "Pin Name" ), GetPinFunction() );
2181
2182 if( !GetPinType().IsEmpty() )
2183 aList.emplace_back( _( "Pin Type" ), GetPinType() );
2184
2185 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME )
2186 {
2187 aList.emplace_back( _( "Net" ), UnescapeString( GetNetname() ) );
2188
2189 if( NETINFO_ITEM* netInfo = GetNet() )
2190 {
2191 const wxString& chainName = netInfo->GetNetChain();
2192
2193 if( !chainName.IsEmpty() )
2194 aList.emplace_back( _( "Net Chain" ), UnescapeString( chainName ) );
2195 }
2196
2197 aList.emplace_back( _( "Resolved Netclass" ),
2198 UnescapeString( GetEffectiveNetClass()->GetHumanReadableName() ) );
2199
2200 if( IsLocked() )
2201 aList.emplace_back( _( "Status" ), _( "Locked" ) );
2202 }
2203
2207 {
2208 aList.emplace_back( _( "Layer" ), LayerMaskDescribe() );
2209 }
2210
2211 if( aFrame->GetName() == FOOTPRINT_EDIT_FRAME_NAME )
2212 {
2213 if( GetAttribute() == PAD_ATTRIB::SMD )
2214 {
2215 // TOOD(JE) padstacks
2216 const std::shared_ptr<SHAPE_POLY_SET>& poly = GetEffectivePolygon( PADSTACK::TEMP_ALL_LAYERS );
2217 double area = poly->Area();
2218
2219 aList.emplace_back( _( "Area" ), aFrame->MessageTextFromValue( area, true, EDA_DATA_TYPE::AREA ) );
2220 }
2221 }
2222
2223 // Show the pad shape, attribute and property
2224 wxString props = ShowPadAttr();
2225
2226 if( GetProperty() != PAD_PROP::NONE )
2227 props += ',';
2228
2229 switch( GetProperty() )
2230 {
2231 case PAD_PROP::NONE: break;
2232 case PAD_PROP::BGA: props += _( "BGA" ); break;
2233 case PAD_PROP::FIDUCIAL_GLBL: props += _( "Fiducial global" ); break;
2234 case PAD_PROP::FIDUCIAL_LOCAL: props += _( "Fiducial local" ); break;
2235 case PAD_PROP::TESTPOINT: props += _( "Test point" ); break;
2236 case PAD_PROP::HEATSINK: props += _( "Heat sink" ); break;
2237 case PAD_PROP::CASTELLATED: props += _( "Castellated" ); break;
2238 case PAD_PROP::MECHANICAL: props += _( "Mechanical" ); break;
2239 case PAD_PROP::PRESSFIT: props += _( "Press-fit" ); break;
2240 }
2241
2242 std::set<bool> circles;
2243 std::set<PAD_SHAPE> shapes;
2244 std::set<int> widths;
2245 std::set<int> heights;
2246
2248 [&]( PCB_LAYER_ID aLayer )
2249 {
2250 PAD_SHAPE shape = GetShape( aLayer );
2251 VECTOR2I size = GetSize( aLayer );
2252
2253 circles.insert( shape == PAD_SHAPE::CIRCLE || ( shape == PAD_SHAPE::OVAL && size.x == size.y ) );
2254 shapes.insert( shape );
2255 widths.insert( size.x );
2256 heights.insert( size.y );
2257 } );
2258
2259 aList.emplace_back( shapes.size() == 1 ? ShowPadShape( *shapes.begin() ) : _( "(mixed shapes)" ), props );
2260
2261 if( circles.size() == 1 && *circles.begin() )
2262 {
2263 aList.emplace_back( _( "Diameter" ), widths.size() == 1 ? aFrame->MessageTextFromValue( *widths.begin() )
2264 : _( "(mixed)" ) );
2265 }
2266 else
2267 {
2268 aList.emplace_back( _( "Width" ), widths.size() == 1 ? aFrame->MessageTextFromValue( *widths.begin() )
2269 : _( "(mixed)" ) );
2270 aList.emplace_back( _( "Height" ), heights.size() == 1 ? aFrame->MessageTextFromValue( *heights.begin() )
2271 : _( "(mixed)" ) );
2272 }
2273
2274 EDA_ANGLE fp_orient = parentFootprint ? parentFootprint->GetOrientation() : ANGLE_0;
2275 EDA_ANGLE pad_orient = GetOrientation() - fp_orient;
2276 pad_orient.Normalize180();
2277
2278 if( !fp_orient.IsZero() )
2279 msg.Printf( wxT( "%g(+ %g)" ), pad_orient.AsDegrees(), fp_orient.AsDegrees() );
2280 else
2281 msg.Printf( wxT( "%g" ), GetOrientation().AsDegrees() );
2282
2283 aList.emplace_back( _( "Rotation" ), msg );
2284
2285 if( GetPadToDieLength() )
2286 aList.emplace_back( _( "Length in Package" ), aFrame->MessageTextFromValue( GetPadToDieLength() ) );
2287
2288 const VECTOR2I drill = GetDrillSize();
2289
2290 if( drill.x > 0 || drill.y > 0 )
2291 {
2293 {
2294 aList.emplace_back( _( "Hole" ),
2295 wxString::Format( wxT( "%s" ),
2296 aFrame->MessageTextFromValue( drill.x ) ) );
2297 }
2298 else
2299 {
2300 aList.emplace_back( _( "Hole X / Y" ),
2301 wxString::Format( wxT( "%s / %s" ),
2302 aFrame->MessageTextFromValue( drill.x ),
2303 aFrame->MessageTextFromValue( drill.y ) ) );
2304 }
2305 }
2306
2307 wxString source;
2309
2310 if( !source.IsEmpty() )
2311 {
2312 aList.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
2313 aFrame->MessageTextFromValue( clearance ) ),
2314 wxString::Format( _( "(from %s)" ),
2315 source ) );
2316 }
2317#if 0
2318 // useful for debug only
2319 aList.emplace_back( wxT( "UUID" ), m_Uuid.AsString() );
2320#endif
2321}
2322
2323
2324bool PAD::HitTest( const VECTOR2I& aPosition, int aAccuracy, PCB_LAYER_ID aLayer ) const
2325{
2326 if( !IsOnLayer( aLayer ) )
2327 return false;
2328
2329 VECTOR2I delta = aPosition - GetPosition();
2330 int boundingRadius = GetBoundingRadius() + aAccuracy;
2331
2332 if( delta.SquaredEuclideanNorm() > SEG::Square( boundingRadius ) )
2333 return false;
2334
2335 bool contains = GetEffectivePolygon( aLayer, ERROR_INSIDE )->Contains( aPosition, -1, aAccuracy );
2336
2337 return contains;
2338}
2339
2340
2341bool PAD::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
2342{
2343 VECTOR2I delta = aPosition - GetPosition();
2344 int boundingRadius = GetBoundingRadius() + aAccuracy;
2345
2346 if( delta.SquaredEuclideanNorm() > SEG::Square( boundingRadius ) )
2347 return false;
2348
2349 bool contains = false;
2350
2352 [&]( PCB_LAYER_ID l )
2353 {
2354 if( contains )
2355 return;
2356
2357 if( GetEffectivePolygon( l, ERROR_INSIDE )->Contains( aPosition, -1, aAccuracy ) )
2358 contains = true;
2359 } );
2360
2361 contains |= GetEffectiveHoleShape()->Collide( aPosition, aAccuracy );
2362
2363 return contains;
2364}
2365
2366
2367bool PAD::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
2368{
2369 BOX2I arect = aRect;
2370 arect.Normalize();
2371 arect.Inflate( aAccuracy );
2372
2373 BOX2I bbox = GetBoundingBox();
2374
2375 if( aContained )
2376 {
2377 return arect.Contains( bbox );
2378 }
2379 else
2380 {
2381 // Fast test: if aRect is outside the polygon bounding box,
2382 // rectangles cannot intersect
2383 if( !arect.Intersects( bbox ) )
2384 return false;
2385
2386 bool hit = false;
2387
2389 [&]( PCB_LAYER_ID aLayer )
2390 {
2391 if( hit )
2392 return;
2393
2394 const std::shared_ptr<SHAPE_POLY_SET>& poly = GetEffectivePolygon( aLayer, ERROR_INSIDE );
2395
2396 int count = poly->TotalVertices();
2397
2398 for( int ii = 0; ii < count; ii++ )
2399 {
2400 VECTOR2I vertex = poly->CVertex( ii );
2401 VECTOR2I vertexNext = poly->CVertex( ( ii + 1 ) % count );
2402
2403 // Test if the point is within aRect
2404 if( arect.Contains( vertex ) )
2405 {
2406 hit = true;
2407 break;
2408 }
2409
2410 // Test if this edge intersects aRect
2411 if( arect.Intersects( vertex, vertexNext ) )
2412 {
2413 hit = true;
2414 break;
2415 }
2416 }
2417 } );
2418
2419 if( !hit )
2420 {
2421 SHAPE_RECT rect( arect );
2422 hit |= GetEffectiveHoleShape()->Collide( &rect );
2423 }
2424
2425 return hit;
2426 }
2427}
2428
2429
2430bool PAD::HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const
2431{
2432 SHAPE_COMPOUND effectiveShape;
2433
2434 // Add padstack shapes
2436 [&]( PCB_LAYER_ID aLayer )
2437 {
2438 effectiveShape.AddShape( GetEffectiveShape( aLayer ) );
2439 } );
2440
2441 // Add hole shape
2442 effectiveShape.AddShape( GetEffectiveHoleShape() );
2443
2444 return KIGEOM::ShapeHitTest( aPoly, effectiveShape, aContained );
2445}
2446
2447
2448int PAD::Compare( const PAD* aPadRef, const PAD* aPadCmp )
2449{
2450 int diff;
2451
2452 if( ( diff = static_cast<int>( aPadRef->m_attribute ) - static_cast<int>( aPadCmp->m_attribute ) ) != 0 )
2453 return diff;
2454
2455 return PADSTACK::Compare( &aPadRef->Padstack(), &aPadCmp->Padstack() );
2456}
2457
2458
2459void PAD::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
2460{
2461 VECTOR2I newPos = GetPosition();
2462 RotatePoint( newPos, aRotCentre, aAngle );
2463 SetPosition( newPos );
2464
2465 SetOrientation( GetOrientation() + aAngle );
2466}
2467
2468
2469void PAD::GetPrimitiveLibScale( double& aScaleX, double& aScaleY ) const
2470{
2471 aScaleX = 1.0;
2472 aScaleY = 1.0;
2473
2474 if( const FOOTPRINT* fp = GetParentFootprint() )
2475 {
2476 const TRANSFORM_TRS& xform = fp->GetTransform();
2477 scaleInChildFrame( std::abs( xform.GetScaleX() ), std::abs( xform.GetScaleY() ), GetFPRelativeOrientation(),
2478 aScaleX, aScaleY );
2479 }
2480}
2481
2482
2484{
2485 if( !GetParentFootprint() )
2486 return;
2487
2488 double localSx, localSy;
2489 GetPrimitiveLibScale( localSx, localSy );
2490 aPrimitive->RebakeWithScale( localSx, localSy );
2491}
2492
2493
2494void PAD::OnFootprintRescaled( double aRatioX, double aRatioY, double aLinearFactor, const VECTOR2I& aAnchor,
2495 const EDA_ANGLE& aParentRotate )
2496{
2497 // Pad size, drill, and offset auto-derive from lib-frame padstack values
2498 // through the parent transform on read. Custom-shape primitives carry their
2499 // own geometry in the pad frame and are excluded from the read-time transform
2500 // (transformFp returns null for pad children), so rescale them explicitly.
2502 [&]( PCB_LAYER_ID aLayer )
2503 {
2504 for( const std::shared_ptr<PCB_SHAPE>& prim : Padstack().Primitives( aLayer ) )
2505 rebakePrimitiveToFootprint( prim.get() );
2506 } );
2507
2509}
2510
2511
2513{
2514 EDA_ANGLE parentOrient = ANGLE_0;
2515
2516 if( const FOOTPRINT* fp = GetParentFootprint() )
2517 parentOrient = fp->GetOrientation();
2518
2519 Padstack().SetOrientation( GetFPRelativeOrientation() + parentOrient );
2520 SetDirty();
2521}
2522
2523
2525{
2526 switch( aShape )
2527 {
2528 case PAD_SHAPE::CIRCLE: return _( "Circle" );
2529 case PAD_SHAPE::OVAL: return _( "Oval" );
2530 case PAD_SHAPE::RECTANGLE: return _( "Rectangle" );
2531 case PAD_SHAPE::TRAPEZOID: return _( "Trapezoid" );
2532 case PAD_SHAPE::ROUNDRECT: return _( "Rounded rectangle" );
2533 case PAD_SHAPE::CHAMFERED_RECT: return _( "Chamfered rectangle" );
2534 case PAD_SHAPE::CUSTOM: return _( "Custom shape" );
2535 default: return wxT( "???" );
2536 }
2537}
2538
2539
2540wxString PAD::ShowPadShape( PCB_LAYER_ID aLayer ) const
2541{
2542 return ShowPadShape( GetShape( aLayer ) );
2543}
2544
2545
2547{
2548 switch( GetShape( aLayer ) )
2549 {
2550 case PAD_SHAPE::CIRCLE: return _( "Circle" );
2551 case PAD_SHAPE::OVAL: return _( "Oval" );
2552 case PAD_SHAPE::RECTANGLE: return _( "Rect" );
2553 case PAD_SHAPE::TRAPEZOID: return _( "Trap" );
2554 case PAD_SHAPE::ROUNDRECT: return _( "Roundrect" );
2555 case PAD_SHAPE::CHAMFERED_RECT: return _( "Chamferedrect" );
2556 case PAD_SHAPE::CUSTOM: return _( "CustomShape" );
2557 default: return wxT( "???" );
2558 }
2559}
2560
2561
2562wxString PAD::ShowPadAttr() const
2563{
2564 switch( GetAttribute() )
2565 {
2566 case PAD_ATTRIB::PTH: return _( "PTH" );
2567 case PAD_ATTRIB::SMD: return _( "SMD" );
2568 case PAD_ATTRIB::CONN: return _( "Conn" );
2569 case PAD_ATTRIB::NPTH: return _( "NPTH" );
2570 case PAD_ATTRIB::NON_COMPONENT: return _( "Non-component" );
2571 default: return wxT( "???" );
2572 }
2573}
2574
2575
2576wxString PAD::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
2577{
2578 FOOTPRINT* parentFP = GetParentFootprint();
2579
2580 // Don't report parent footprint info from footprint editor, viewer, etc.
2581 if( GetBoard() && GetBoard()->GetBoardUse() == BOARD_USE::FPHOLDER )
2582 parentFP = nullptr;
2583
2585 {
2586 if( parentFP )
2587 return wxString::Format( _( "NPTH pad of %s" ), parentFP->GetReference() );
2588 else
2589 return _( "NPTH pad" );
2590 }
2591 else if( GetNumber().IsEmpty() )
2592 {
2596 {
2597 if( parentFP )
2598 {
2599 return wxString::Format( _( "Pad %s of %s on %s" ),
2600 GetNetnameMsg(),
2601 parentFP->GetReference(),
2603 }
2604 else
2605 {
2606 return wxString::Format( _( "Pad on %s" ),
2608 }
2609 }
2610 else
2611 {
2612 if( parentFP )
2613 {
2614 return wxString::Format( _( "PTH pad %s of %s" ),
2615 GetNetnameMsg(),
2616 parentFP->GetReference() );
2617 }
2618 else
2619 {
2620 return _( "PTH pad" );
2621 }
2622 }
2623 }
2624 else
2625 {
2629 {
2630 if( parentFP )
2631 {
2632 return wxString::Format( _( "Pad %s %s of %s on %s" ),
2633 GetNumber(),
2634 GetNetnameMsg(),
2635 parentFP->GetReference(),
2637 }
2638 else
2639 {
2640 return wxString::Format( _( "Pad %s on %s" ),
2641 GetNumber(),
2643 }
2644 }
2645 else
2646 {
2647 if( parentFP )
2648 {
2649 return wxString::Format( _( "PTH pad %s %s of %s" ),
2650 GetNumber(),
2651 GetNetnameMsg(),
2652 parentFP->GetReference() );
2653 }
2654 else
2655 {
2656 return wxString::Format( _( "PTH pad %s" ),
2657 GetNumber() );
2658 }
2659 }
2660 }
2661}
2662
2663
2665{
2666 return BITMAPS::pad;
2667}
2668
2669
2671{
2672 PAD* cloned = new PAD( *this );
2673
2674 // Ensure the cloned primitives of the pad stack have the right parent
2675 cloned->Padstack().ForEachUniqueLayer(
2676 [&]( PCB_LAYER_ID aLayer )
2677 {
2678 for( std::shared_ptr<PCB_SHAPE>& primitive : cloned->m_padStack.Primitives( aLayer ) )
2679 primitive->SetParent( cloned );
2680 } );
2681
2682 return cloned;
2683}
2684
2685
2686std::vector<int> PAD::ViewGetLayers() const
2687{
2688 std::vector<int> layers;
2689 layers.reserve( 64 );
2690
2691 // A drill map on a layer asks the holes to draw their symbols there, so the symbols stay
2692 // in the view index and one hole edit repaints one hole
2694 {
2695 if( const BOARD* drillBoard = GetBoard() )
2696 {
2697 for( PCB_LAYER_ID mapLayer : drillBoard->DrillSymbolLayers().Seq() )
2698 layers.push_back( DRILL_SYMBOL_LAYER_FOR( mapLayer ) );
2699 }
2700 }
2701
2702 // These 2 types of pads contain a hole
2704 {
2705 layers.push_back( LAYER_PAD_PLATEDHOLES );
2706 layers.push_back( LAYER_PAD_HOLEWALLS );
2707 }
2708
2710 layers.push_back( LAYER_NON_PLATEDHOLES );
2711
2712
2714 layers.push_back( LAYER_LOCKED_ITEM_SHADOW );
2715
2716 LSET cuLayers = ( m_padStack.LayerSet() & LSET::AllCuMask() );
2717
2718 // Don't spend cycles rendering layers that aren't visible
2719 if( const BOARD* board = GetBoard() )
2720 cuLayers &= board->GetEnabledLayers();
2721
2722 if( cuLayers.count() > 1 )
2723 {
2724 // Multi layer pad
2725 for( PCB_LAYER_ID layer : cuLayers.Seq() )
2726 {
2727 layers.push_back( LAYER_PAD_COPPER_START + layer );
2728 layers.push_back( LAYER_CLEARANCE_START + layer );
2729 }
2730
2731 layers.push_back( LAYER_PAD_NETNAMES );
2732 }
2733 else if( IsOnLayer( F_Cu ) )
2734 {
2735 layers.push_back( LAYER_PAD_COPPER_START );
2736 layers.push_back( LAYER_CLEARANCE_START );
2737
2738 // Is this a PTH pad that has only front copper? If so, we need to also display the
2739 // net name on the PTH netname layer so that it isn't blocked by the drill hole.
2741 layers.push_back( LAYER_PAD_NETNAMES );
2742 else
2743 layers.push_back( LAYER_PAD_FR_NETNAMES );
2744 }
2745 else if( IsOnLayer( B_Cu ) )
2746 {
2747 layers.push_back( LAYER_PAD_COPPER_START + B_Cu );
2748 layers.push_back( LAYER_CLEARANCE_START + B_Cu );
2749
2750 // Is this a PTH pad that has only back copper? If so, we need to also display the
2751 // net name on the PTH netname layer so that it isn't blocked by the drill hole.
2753 layers.push_back( LAYER_PAD_NETNAMES );
2754 else
2755 layers.push_back( LAYER_PAD_BK_NETNAMES );
2756 }
2757 else if( cuLayers.count() == 1 )
2758 {
2759 PCB_LAYER_ID layer = cuLayers.Seq().front();
2760
2761 layers.push_back( LAYER_PAD_COPPER_START + layer );
2762 layers.push_back( LAYER_CLEARANCE_START + layer );
2763 layers.push_back( LAYER_PAD_NETNAMES );
2764 }
2765
2766 // Check non-copper layers. This list should include all the layers that the
2767 // footprint editor allows a pad to be placed on.
2768 static const PCB_LAYER_ID layers_mech[] = { F_Mask, B_Mask, F_Paste, B_Paste,
2770
2771 for( PCB_LAYER_ID each_layer : layers_mech )
2772 {
2773 if( IsOnLayer( each_layer ) )
2774 layers.push_back( each_layer );
2775 }
2776
2777 return layers;
2778}
2779
2780
2781double PAD::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
2782{
2783 PCB_PAINTER& painter = static_cast<PCB_PAINTER&>( *aView->GetPainter() );
2784 PCB_RENDER_SETTINGS& renderSettings = *painter.GetSettings();
2785 const BOARD* board = GetBoard();
2786
2787 // Reviewing a drill drawing with pads hidden is normal, so the symbols answer to the
2788 // map's own layer rather than to the pads meta control
2789 if( IsDrillSymbolLayer( aLayer ) )
2790 {
2791 return aView->IsLayerVisibleCached( aLayer - LAYER_DRILL_SYMBOL_START ) ? LOD_SHOW
2792 : LOD_HIDE;
2793 }
2794
2795 // Meta control for hiding all pads
2796 if( !aView->IsLayerVisibleCached( LAYER_PADS ) )
2797 return LOD_HIDE;
2798
2799 // Handle Render tab switches
2800 //const PCB_LAYER_ID& pcbLayer = static_cast<PCB_LAYER_ID>( aLayer );
2801
2802 {
2803 const LSET padLayers = GetLayerSet();
2804 const bool onFront = ( padLayers & LSET::FrontMask() ).any();
2805 const bool onBack = ( padLayers & LSET::BackMask() ).any();
2806 const bool frVis = aView->IsLayerVisible( LAYER_FOOTPRINTS_FR );
2807 const bool bkVis = aView->IsLayerVisible( LAYER_FOOTPRINTS_BK );
2808
2809 if( onFront && !onBack && !frVis )
2810 return LOD_HIDE;
2811
2812 if( onBack && !onFront && !bkVis )
2813 return LOD_HIDE;
2814
2815 if( onFront && onBack && !frVis && !bkVis )
2816 return LOD_HIDE;
2817 }
2818
2819 // Selection and net highlight draw a pad on layers where it otherwise draws nothing
2820 const bool drawnRegardless = IsSelected() || renderSettings.IsPrinting()
2821 || ( renderSettings.IsHighlightEnabled()
2822 && renderSettings.GetHighlightNetCodes().contains( GetNetCode() ) );
2823
2824 if( !drawnRegardless )
2825 {
2826 // The painter draws a pad copper layer only where the pad flashes, plus the post-machining
2827 // indicator of a layer that has one
2828 if( IsPadCopperLayer( aLayer ) )
2829 {
2830 const PCB_LAYER_ID copperLayer = ToLAYER_ID( aLayer - LAYER_PAD_COPPER_START );
2831
2832 if( !FlashLayer( copperLayer ) && GetPostMachiningKnockout( copperLayer ) <= 0 )
2833 return LOD_HIDE;
2834 }
2835
2836 // The painter draws clearance outlines only when the pad clearance option is on
2837 if( IsClearanceLayer( aLayer ) && pcbconfig() && !pcbconfig()->m_Display.m_PadClearance )
2838 return LOD_HIDE;
2839 }
2840
2841 if( IsHoleLayer( aLayer ) )
2842 {
2843 LSET visiblePhysical = board->GetVisibleLayers();
2844 visiblePhysical &= board->GetEnabledLayers();
2845 visiblePhysical &= LSET::PhysicalLayersMask();
2846
2847 if( !visiblePhysical.any() )
2848 return LOD_HIDE;
2849 }
2850 else if( IsNetnameLayer( aLayer ) )
2851 {
2852 if( renderSettings.GetHighContrast() )
2853 {
2854 // Hide netnames unless pad is flashed to a high-contrast layer
2855 if( !FlashLayer( renderSettings.GetPrimaryHighContrastLayer() ) )
2856 return LOD_HIDE;
2857 }
2858 else
2859 {
2860 // Hide netnames unless pad is flashed to a visible layer
2861 if( !FlashLayer( viewVisibleLayers( aView ) ) )
2862 return LOD_HIDE;
2863 }
2864
2865 // Netnames will be shown only if zoom is appropriate
2866 const int minSize = std::min( GetBoundingBox().GetWidth(), GetBoundingBox().GetHeight() );
2867
2868 return lodScaleForThreshold( aView, minSize, pcbIUScale.mmToIU( 0.5 ) );
2869 }
2870
2871 VECTOR2L padSize = GetBoundingBox().GetSize();
2872 int64_t minSide = std::min( padSize.x, padSize.y );
2873
2874 if( minSide > 0 )
2875 return std::min( lodScaleForThreshold( aView, minSide, pcbIUScale.mmToIU( 0.2 ) ), 3.5 );
2876
2877 return LOD_SHOW;
2878}
2879
2880
2882{
2883 // Bounding box includes soldermask too. Remember mask and/or paste margins can be < 0
2884 int solderMaskMargin = 0;
2885 VECTOR2I solderPasteMargin;
2886
2888 [&]( PCB_LAYER_ID aLayer )
2889 {
2890 solderMaskMargin = std::max( solderMaskMargin, std::max( GetSolderMaskExpansion( aLayer ), 0 ) );
2891 VECTOR2I layerMargin = GetSolderPasteMargin( aLayer );
2892 solderPasteMargin.x = std::max( solderPasteMargin.x, layerMargin.x );
2893 solderPasteMargin.y = std::max( solderPasteMargin.y, layerMargin.y );
2894 } );
2895
2896 BOX2I bbox = GetBoundingBox();
2897 int clearance = 0;
2898
2899 // If we're drawing clearance lines then get the biggest possible clearance
2900 if( PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() ) )
2901 {
2902 if( cfg && cfg->m_Display.m_PadClearance && GetBoard() )
2904 }
2905
2906 // Look for the biggest possible bounding box
2907 int xMargin = std::max( solderMaskMargin, solderPasteMargin.x ) + clearance;
2908 int yMargin = std::max( solderMaskMargin, solderPasteMargin.y ) + clearance;
2909
2910 BOX2I viewBox( VECTOR2I( bbox.GetOrigin() ) - VECTOR2I( xMargin, yMargin ),
2911 VECTOR2I( bbox.GetSize() ) + VECTOR2I( 2 * xMargin, 2 * yMargin ) );
2912
2913 // Only a hole draws a drill symbol, so an SMD pad would just be given an oversized box
2914 if( HasHole() && GetBoard() )
2915 return GetBoard()->ExpandBoundingBoxForDrillSymbols( viewBox );
2916
2917 return viewBox;
2918}
2919
2920
2921void PAD::ImportSettingsFrom( const PAD& aMasterPad )
2922{
2923 SetPadstack( aMasterPad.Padstack() );
2924 // Layer Set should be updated before calling SetAttribute()
2925 SetLayerSet( aMasterPad.GetLayerSet() );
2926 SetAttribute( aMasterPad.GetAttribute() );
2927 // Unfortunately, SetAttribute() can change m_layerMask.
2928 // Be sure we keep the original mask by calling SetLayerSet() after SetAttribute()
2929 SetLayerSet( aMasterPad.GetLayerSet() );
2930 SetProperty( aMasterPad.GetProperty() );
2931
2932 // Must be after setting attribute and layerSet
2933 if( !CanHaveNumber() )
2934 SetNumber( wxEmptyString );
2935
2936 // I am not sure the m_LengthPadToDie should be imported, because this is a parameter
2937 // really specific to a given pad (JPC).
2938#if 0
2939 SetPadToDieLength( aMasterPad.GetPadToDieLength() );
2940 SetPadToDieDelay( aMasterPad.GetPadToDieDelay() );
2941#endif
2942
2943 // The pad orientation, for historical reasons is the pad rotation + parent rotation.
2944 EDA_ANGLE pad_rot = aMasterPad.GetOrientation();
2945
2946 if( aMasterPad.GetParentFootprint() )
2947 pad_rot -= aMasterPad.GetParentFootprint()->GetOrientation();
2948
2949 if( GetParentFootprint() )
2950 pad_rot += GetParentFootprint()->GetOrientation();
2951
2952 SetOrientation( pad_rot );
2953
2955 [&]( PCB_LAYER_ID aLayer )
2956 {
2957 // Ensure that circles are circles
2958 // Stay in the library frame, since a board-frame round trip under a scale rounds the size
2959 if( aMasterPad.GetShape( aLayer ) == PAD_SHAPE::CIRCLE )
2960 SetLibSize( aLayer, VECTOR2I( Padstack().Size( aLayer ).x, Padstack().Size( aLayer ).x ) );
2961 } );
2962
2963 switch( aMasterPad.GetAttribute() )
2964 {
2965 case PAD_ATTRIB::SMD:
2966 case PAD_ATTRIB::CONN:
2968 // These pads have no hole, or any kind of drilling.
2970 break;
2971
2972 default:
2973 ;
2974 }
2975
2976 // copy also local settings:
2977 SetLocalClearance( aMasterPad.GetLocalClearance() );
2981
2986
2988
2990
2991 SetDirty();
2992}
2993
2994
2996{
2997 assert( aImage->Type() == PCB_PAD_T );
2998
2999 std::swap( *this, *static_cast<PAD*>( aImage ) );
3000}
3001
3002
3003bool PAD::TransformHoleToPolygon( SHAPE_POLY_SET& aBuffer, int aClearance, int aError,
3004 ERROR_LOC aErrorLoc ) const
3005{
3006 VECTOR2I drillsize = GetDrillSize();
3007
3008 if( !drillsize.x || !drillsize.y )
3009 return false;
3010
3011 std::shared_ptr<SHAPE_SEGMENT> slot = GetEffectiveHoleShape();
3012
3013 TransformOvalToPolygon( aBuffer, slot->GetSeg().A, slot->GetSeg().B, slot->GetWidth() + aClearance * 2,
3014 aError, aErrorLoc );
3015
3016 return true;
3017}
3018
3019
3020double PAD::GetCoverageArea( int aTextMargin ) const
3021{
3022 SHAPE_POLY_SET poly;
3023
3025 [&]( PCB_LAYER_ID aLayer )
3026 {
3027 SHAPE_POLY_SET layerPoly;
3028 TransformShapeToPolygon( layerPoly, aLayer, 0, ARC_LOW_DEF, ERROR_OUTSIDE );
3029 poly.BooleanAdd( layerPoly );
3030 } );
3031
3032 return polygonArea( poly );
3033}
3034
3035
3036void PAD::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
3037 int aMaxError, ERROR_LOC aErrorLoc, bool ignoreLineWidth ) const
3038{
3039 wxASSERT_MSG( aLayer != UNDEFINED_LAYER,
3040 wxT( "UNDEFINED_LAYER is no longer allowed for PAD::TransformShapeToPolygon" ) );
3041
3042 // minimal segment count to approximate a circle to create the polygonal pad shape
3043 // This minimal value is mainly for very small pads, like SM0402.
3044 // Most of time pads are using the segment count given by aError value.
3045 const int pad_min_seg_per_circle_count = 16;
3046 const VECTOR2I padSize = GetSize( aLayer );
3047 int dx = padSize.x / 2;
3048 int dy = padSize.y / 2;
3049
3050 VECTOR2I padShapePos = ShapePos( aLayer ); // Note: for pad having a shape offset, the pad
3051 // position is NOT the shape position
3052
3053 switch( PAD_SHAPE shape = GetShape( aLayer ) )
3054 {
3055 case PAD_SHAPE::CIRCLE:
3056 case PAD_SHAPE::OVAL:
3057 // Note: dx == dy is not guaranteed for circle pads in legacy boards
3058 if( dx == dy || ( shape == PAD_SHAPE::CIRCLE ) )
3059 {
3060 TransformCircleToPolygon( aBuffer, padShapePos, dx + aClearance, aMaxError, aErrorLoc,
3061 pad_min_seg_per_circle_count );
3062 }
3063 else
3064 {
3065 int half_width = std::min( dx, dy );
3066 VECTOR2I delta( dx - half_width, dy - half_width );
3067
3069
3070 TransformOvalToPolygon( aBuffer, padShapePos - delta, padShapePos + delta,
3071 ( half_width + aClearance ) * 2, aMaxError, aErrorLoc,
3072 pad_min_seg_per_circle_count );
3073 }
3074
3075 break;
3076
3079 {
3080 const VECTOR2I& trapDelta = m_padStack.TrapezoidDeltaSize( aLayer );
3081 int ddx = shape == PAD_SHAPE::TRAPEZOID ? trapDelta.x / 2 : 0;
3082 int ddy = shape == PAD_SHAPE::TRAPEZOID ? trapDelta.y / 2 : 0;
3083
3084 SHAPE_POLY_SET outline;
3085 TransformTrapezoidToPolygon( outline, padShapePos, padSize, GetOrientation(), ddx, ddy, aClearance, aMaxError,
3086 aErrorLoc );
3087 aBuffer.Append( outline );
3088 break;
3089 }
3090
3093 {
3094 bool doChamfer = shape == PAD_SHAPE::CHAMFERED_RECT;
3095
3096 SHAPE_POLY_SET outline;
3098 outline, padShapePos, padSize, GetOrientation(), GetRoundRectCornerRadius( aLayer ),
3099 doChamfer ? GetChamferRectRatio( aLayer ) : 0, doChamfer ? GetChamferPositions( aLayer ) : 0,
3100 aClearance, aMaxError, aErrorLoc );
3101 aBuffer.Append( outline );
3102 break;
3103 }
3104
3105 case PAD_SHAPE::CUSTOM:
3106 {
3107 SHAPE_POLY_SET outline;
3108 MergePrimitivesAsPolygon( aLayer, &outline, aErrorLoc );
3109 outline.Rotate( GetOrientation() );
3110 outline.Move( VECTOR2I( padShapePos ) );
3111
3112 if( aClearance > 0 || aErrorLoc == ERROR_OUTSIDE )
3113 {
3114 if( aErrorLoc == ERROR_OUTSIDE )
3115 aClearance += aMaxError;
3116
3117 outline.Inflate( aClearance, CORNER_STRATEGY::ROUND_ALL_CORNERS, aMaxError );
3118 outline.Fracture();
3119 }
3120 else if( aClearance < 0 )
3121 {
3122 // Negative clearances are primarily for drawing solder paste layer, so we don't
3123 // worry ourselves overly about which side the error is on.
3124
3125 // aClearance is negative so this is actually a deflate
3126 outline.Inflate( aClearance, CORNER_STRATEGY::ALLOW_ACUTE_CORNERS, aMaxError );
3127 outline.Fracture();
3128 }
3129
3130 aBuffer.Append( outline );
3131 break;
3132 }
3133
3134 default:
3135 wxFAIL_MSG( wxT( "PAD::TransformShapeToPolygon no implementation for " )
3136 + wxString( std::string( magic_enum::enum_name( shape ) ) ) );
3137 break;
3138 }
3139}
3140
3141
3142std::vector<PCB_SHAPE*> PAD::Recombine( bool aIsDryRun, int maxError )
3143{
3144 FOOTPRINT* footprint = GetParentFootprint();
3145
3146 for( BOARD_ITEM* item : footprint->GraphicalItems() )
3147 item->ClearFlags( SKIP_STRUCT );
3148
3149 auto findNext =
3150 [&]( PCB_LAYER_ID aLayer ) -> PCB_SHAPE*
3151 {
3152 SHAPE_POLY_SET padPoly;
3153 TransformShapeToPolygon( padPoly, aLayer, 0, maxError, ERROR_INSIDE );
3154
3155 for( BOARD_ITEM* item : footprint->GraphicalItems() )
3156 {
3157 PCB_SHAPE* shape = dynamic_cast<PCB_SHAPE*>( item );
3158
3159 if( !shape || ( shape->GetFlags() & SKIP_STRUCT ) )
3160 continue;
3161
3162 if( shape->GetLayer() != aLayer )
3163 continue;
3164
3165 if( shape->IsProxyItem() ) // Pad number (and net name) box
3166 return shape;
3167
3168 SHAPE_POLY_SET drawPoly;
3169 shape->TransformShapeToPolygon( drawPoly, aLayer, 0, maxError, ERROR_INSIDE );
3170 drawPoly.BooleanIntersection( padPoly );
3171
3172 if( !drawPoly.IsEmpty() )
3173 return shape;
3174 }
3175
3176 return nullptr;
3177 };
3178
3179 auto findMatching =
3180 [&]( PCB_SHAPE* aShape ) -> std::vector<PCB_SHAPE*>
3181 {
3182 std::vector<PCB_SHAPE*> matching;
3183
3184 for( BOARD_ITEM* item : footprint->GraphicalItems() )
3185 {
3186 PCB_SHAPE* other = dynamic_cast<PCB_SHAPE*>( item );
3187
3188 if( !other || ( other->GetFlags() & SKIP_STRUCT ) )
3189 continue;
3190
3191 if( Padstack().Mode() == PADSTACK::MODE::NORMAL )
3192 {
3193 // A single layer (F_Cu) in NORMAL mode represents _all_ copper layers
3194 if( !IsCopperLayer( other->GetLayer() ) )
3195 continue;
3196 }
3197 else
3198 {
3199 if( aShape->GetLayer() != other->GetLayer() )
3200 continue;
3201 }
3202
3203 if( aShape->Compare( other ) == 0 )
3204 matching.push_back( other );
3205 }
3206
3207 return matching;
3208 };
3209
3210 std::vector<PCB_SHAPE*> mergedShapes;
3211
3212 auto recombine =
3213 [&]( PCB_LAYER_ID sourceBoardLayer, PCB_LAYER_ID padstackStorageLayer )
3214 {
3215 PAD_SHAPE origShape = GetShape( sourceBoardLayer );
3216
3217 // If there are intersecting items to combine, we need to first make sure the pad is a
3218 // custom-shape pad.
3219 if( !aIsDryRun && findNext( sourceBoardLayer ) && origShape != PAD_SHAPE::CUSTOM )
3220 {
3221 if( origShape == PAD_SHAPE::CIRCLE || origShape == PAD_SHAPE::RECTANGLE )
3222 {
3223 // Use the existing pad as an anchor
3224 SetAnchorPadShape( padstackStorageLayer, origShape );
3225 SetShape( padstackStorageLayer, PAD_SHAPE::CUSTOM );
3226 }
3227 else
3228 {
3229 // Create a new circular anchor and convert existing pad to a polygon primitive
3230 SHAPE_POLY_SET existingOutline;
3231 TransformShapeToPolygon( existingOutline, padstackStorageLayer, 0, maxError, ERROR_INSIDE );
3232
3233 VECTOR2I origin( ShapePos( padstackStorageLayer ) );
3234 VECTOR2I nearestPoint, dummyPoint;
3235 SHAPE_SEGMENT originSeg( origin, origin );
3236 existingOutline.NearestPoints( &originSeg, nearestPoint, dummyPoint );
3237 int radius = ( nearestPoint - origin ).EuclideanNorm();
3238
3239 SetAnchorPadShape( padstackStorageLayer, PAD_SHAPE::CIRCLE );
3240 SetSize( padstackStorageLayer, VECTOR2I( radius * 2, radius * 2 ) );
3241 SetShape( padstackStorageLayer, PAD_SHAPE::CUSTOM );
3242
3243 PCB_SHAPE* shape = new PCB_SHAPE( nullptr, SHAPE_T::POLY );
3244 shape->SetFilled( true );
3246 shape->SetPolyShape( existingOutline );
3247 shape->Move( - ShapePos( padstackStorageLayer ) );
3248 shape->Rotate( VECTOR2I( 0, 0 ), - GetOrientation() );
3249 AddPrimitive( padstackStorageLayer, shape );
3250 }
3251 }
3252
3253 while( PCB_SHAPE* fpShape = findNext( sourceBoardLayer ) )
3254 {
3255 fpShape->SetFlags( SKIP_STRUCT );
3256
3257 mergedShapes.push_back( fpShape );
3258
3259 if( !aIsDryRun )
3260 {
3261 // If the editor was inside a group when the pad was exploded, the added exploded shapes
3262 // will be part of the group. Remove them here before duplicating; we don't want the
3263 // primitives to wind up in a group.
3264 if( EDA_GROUP* group = fpShape->GetParentGroup(); group )
3265 group->RemoveItem( fpShape );
3266
3267 PCB_SHAPE* primitive = static_cast<PCB_SHAPE*>( fpShape->Duplicate( IGNORE_PARENT_GROUP ) );
3268
3269 primitive->SetParent( nullptr );
3270
3271 // Convert any hatched fills to solid
3272 if( primitive->IsAnyFill() )
3273 primitive->SetFillMode( FILL_T::FILLED_SHAPE );
3274
3275 primitive->Move( - ShapePos( padstackStorageLayer ) );
3276 primitive->Rotate( VECTOR2I( 0, 0 ), - GetOrientation() );
3277
3278 AddPrimitive( padstackStorageLayer, primitive );
3279 }
3280
3281 // See if there are other shapes that match and mark them for delete.
3282 for( PCB_SHAPE* other : findMatching( fpShape ) )
3283 {
3284 other->SetFlags( SKIP_STRUCT );
3285 mergedShapes.push_back( other );
3286 }
3287 }
3288 };
3289
3290 if( Padstack().Mode() == PADSTACK::MODE::NORMAL )
3291 {
3293 }
3294 else
3295 {
3297 [&]( PCB_LAYER_ID aLayer )
3298 {
3299 recombine( aLayer, aLayer );
3300 } );
3301 }
3302
3303 for( BOARD_ITEM* item : footprint->GraphicalItems() )
3304 item->ClearFlags( SKIP_STRUCT );
3305
3306 if( !aIsDryRun )
3308
3309 return mergedShapes;
3310}
3311
3312
3313bool PAD::operator==( const BOARD_ITEM& aBoardItem ) const
3314{
3315 if( Type() != aBoardItem.Type() )
3316 return false;
3317
3318 if( m_parent && aBoardItem.GetParent() && m_parent->m_Uuid != aBoardItem.GetParent()->m_Uuid )
3319 return false;
3320
3321 const PAD& other = static_cast<const PAD&>( aBoardItem );
3322
3323 return *this == other;
3324}
3325
3326
3327bool PAD::operator==( const PAD& aOther ) const
3328{
3329 if( GetNumber() != aOther.GetNumber() )
3330 return false;
3331
3332 if( Padstack() != aOther.Padstack() )
3333 return false;
3334
3335 if( GetPosition() != aOther.GetPosition() )
3336 return false;
3337
3338 if( GetAttribute() != aOther.GetAttribute() )
3339 return false;
3340
3341 return true;
3342}
3343
3344
3345double PAD::Similarity( const BOARD_ITEM& aOther ) const
3346{
3347 if( aOther.Type() != Type() )
3348 return 0.0;
3349
3350 if( m_parent->m_Uuid != aOther.GetParent()->m_Uuid )
3351 return 0.0;
3352
3353 const PAD& other = static_cast<const PAD&>( aOther );
3354
3355 double similarity = 1.0;
3356
3357 if( GetPosition() != other.GetPosition() )
3358 similarity *= 0.9;
3359
3360 if( GetAttribute() != other.GetAttribute() )
3361 similarity *= 0.9;
3362
3363 similarity *= Padstack().Similarity( other.Padstack() );
3364
3365 return similarity;
3366}
3367
3368
3369void PAD::AddPrimitivePoly( PCB_LAYER_ID aLayer, const SHAPE_POLY_SET& aPoly, int aThickness,
3370 bool aFilled )
3371{
3372 // If aPoly has holes, convert it to a polygon with no holes.
3373 SHAPE_POLY_SET poly_no_hole;
3374 poly_no_hole.Append( aPoly );
3375
3376 if( poly_no_hole.HasHoles() )
3377 poly_no_hole.Fracture();
3378
3379 // There should never be multiple shapes, but if there are, we split them into
3380 // primitives so that we can edit them both.
3381 for( int ii = 0; ii < poly_no_hole.OutlineCount(); ++ii )
3382 {
3383 SHAPE_POLY_SET poly_outline( poly_no_hole.COutline( ii ) );
3384 PCB_SHAPE* item = new PCB_SHAPE();
3385 item->SetShape( SHAPE_T::POLY );
3386 item->SetFilled( aFilled );
3387 item->SetPolyShape( poly_outline );
3388 item->SetStroke( STROKE_PARAMS( aThickness, LINE_STYLE::SOLID ) );
3389 AddPrimitive( aLayer, item );
3390 }
3391
3392 SetDirty();
3393}
3394
3395
3396void PAD::AddPrimitivePoly( PCB_LAYER_ID aLayer, const std::vector<VECTOR2I>& aPoly, int aThickness,
3397 bool aFilled )
3398{
3399 PCB_SHAPE* item = new PCB_SHAPE( nullptr, SHAPE_T::POLY );
3400 item->SetFilled( aFilled );
3401 item->SetPolyPoints( aPoly );
3402 item->SetStroke( STROKE_PARAMS( aThickness, LINE_STYLE::SOLID ) );
3403 AddPrimitive( aLayer, item );
3404 SetDirty();
3405}
3406
3407
3408void PAD::ReplacePrimitives( PCB_LAYER_ID aLayer, const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList )
3409{
3410 // clear old list
3411 DeletePrimitivesList( aLayer );
3412
3413 // Import to the given shape list
3414 if( aPrimitivesList.size() )
3415 AppendPrimitives( aLayer, aPrimitivesList );
3416
3417 SetDirty();
3418}
3419
3420
3421void PAD::AppendPrimitives( PCB_LAYER_ID aLayer, const std::vector<std::shared_ptr<PCB_SHAPE>>& aPrimitivesList )
3422{
3423 for( const std::shared_ptr<PCB_SHAPE>& prim : aPrimitivesList )
3424 {
3425 PCB_SHAPE* copy = new PCB_SHAPE( *prim );
3426
3427 copy->SetParent( this );
3429 m_padStack.AddPrimitive( copy, aLayer );
3430 }
3431
3432 SetDirty();
3433}
3434
3435
3436void PAD::AddPrimitive( PCB_LAYER_ID aLayer, PCB_SHAPE* aPrimitive )
3437{
3438 aPrimitive->SetParent( this );
3439
3440 // The primitive arrives in library coordinates. Seed lib state from its current values,
3441 // then rebake so the runtime cache reflects the parent FP transform reachable via the pad.
3442 aPrimitive->OverrideLibCoords( aPrimitive->GetStart(), aPrimitive->GetEnd(),
3443 aPrimitive->GetShape() == SHAPE_T::ARC ? aPrimitive->GetArcMid()
3444 : VECTOR2I( 0, 0 ) );
3445
3446 if( aPrimitive->GetShape() == SHAPE_T::BEZIER )
3447 aPrimitive->OverrideLibBezier( aPrimitive->GetBezierC1(), aPrimitive->GetBezierC2() );
3448
3449 if( aPrimitive->GetShape() == SHAPE_T::POLY )
3450 aPrimitive->OverrideLibPoly( aPrimitive->GetPolyShape() );
3451
3452 // Covers load, where the footprint scale is set before the primitives are parsed.
3453 rebakePrimitiveToFootprint( aPrimitive );
3454
3455 m_padStack.AddPrimitive( aPrimitive, aLayer );
3456
3457 SetDirty();
3458}
3459
3460
3462{
3463 if( aLayer == UNDEFINED_LAYER )
3464 {
3465 m_padStack.ForEachUniqueLayer(
3466 [&]( PCB_LAYER_ID l )
3467 {
3468 m_padStack.ClearPrimitives( l );
3469 } );
3470 }
3471 else
3472 {
3473 m_padStack.ClearPrimitives( aLayer);
3474 }
3475
3476 SetDirty();
3477}
3478
3479
3481 ERROR_LOC aErrorLoc ) const
3482{
3483 aMergedPolygon->RemoveAllContours();
3484
3485 // Add the anchor pad shape in aMergedPolygon, others in aux_polyset:
3486 // The anchor pad is always at 0,0
3487 VECTOR2I padSize = GetSize( aLayer );
3488
3489 switch( GetAnchorPadShape( aLayer ) )
3490 {
3492 {
3493 SHAPE_RECT rect( -padSize.x / 2, -padSize.y / 2, padSize.x, padSize.y );
3494 aMergedPolygon->AddOutline( rect.Outline() );
3495 break;
3496 }
3497
3498 default:
3499 case PAD_SHAPE::CIRCLE:
3500 TransformCircleToPolygon( *aMergedPolygon, VECTOR2I( 0, 0 ), padSize.x / 2, GetMaxError(), aErrorLoc );
3501 break;
3502 }
3503
3504 SHAPE_POLY_SET polyset;
3505
3506 for( const std::shared_ptr<PCB_SHAPE>& primitive : m_padStack.Primitives( aLayer ) )
3507 {
3508 if( !primitive->IsProxyItem() )
3509 primitive->TransformShapeToPolygon( polyset, UNDEFINED_LAYER, 0, GetMaxError(), aErrorLoc );
3510 }
3511
3512 polyset.Simplify();
3513
3514 // Merge all polygons with the initial pad anchor shape
3515 if( polyset.OutlineCount() )
3516 {
3517 aMergedPolygon->BooleanAdd( polyset );
3518 aMergedPolygon->Fracture();
3519 }
3520}
3521
3522
3523static struct PAD_DESC
3524{
3526 {
3528 .Map( PAD_ATTRIB::PTH, _HKI( "Through-hole" ) )
3529 .Map( PAD_ATTRIB::SMD, _HKI( "SMD" ) )
3530 .Map( PAD_ATTRIB::CONN, _HKI( "Edge connector" ) )
3531 .Map( PAD_ATTRIB::NPTH, _HKI( "NPTH, mechanical" ) )
3532 .Map( PAD_ATTRIB::NON_COMPONENT, _HKI( "Non-component" ) );
3533
3535 .Map( PAD_SHAPE::CIRCLE, _HKI( "Circle" ) )
3536 .Map( PAD_SHAPE::RECTANGLE, _HKI( "Rectangle" ) )
3537 .Map( PAD_SHAPE::OVAL, _HKI( "Oval" ) )
3538 .Map( PAD_SHAPE::TRAPEZOID, _HKI( "Trapezoid" ) )
3539 .Map( PAD_SHAPE::ROUNDRECT, _HKI( "Rounded rectangle" ) )
3540 .Map( PAD_SHAPE::CHAMFERED_RECT, _HKI( "Chamfered rectangle" ) )
3541 .Map( PAD_SHAPE::CUSTOM, _HKI( "Custom" ) );
3542
3544 .Map( PAD_PROP::NONE, _HKI( "None" ) )
3545 .Map( PAD_PROP::BGA, _HKI( "BGA pad" ) )
3546 .Map( PAD_PROP::FIDUCIAL_GLBL, _HKI( "Fiducial, global to board" ) )
3547 .Map( PAD_PROP::FIDUCIAL_LOCAL, _HKI( "Fiducial, local to footprint" ) )
3548 .Map( PAD_PROP::TESTPOINT, _HKI( "Test point pad" ) )
3549 .Map( PAD_PROP::HEATSINK, _HKI( "Heatsink pad" ) )
3550 .Map( PAD_PROP::CASTELLATED, _HKI( "Castellated pad" ) )
3551 .Map( PAD_PROP::MECHANICAL, _HKI( "Mechanical pad" ) )
3552 .Map( PAD_PROP::PRESSFIT, _HKI( "Press-fit pad" ) );
3553
3555 .Map( PAD_DRILL_SHAPE::UNDEFINED, _HKI( "Undefined" ) )
3556 .Map( PAD_DRILL_SHAPE::CIRCLE, _HKI( "Round" ) )
3557 .Map( PAD_DRILL_SHAPE::OBLONG, _HKI( "Oblong" ) );
3558
3560 .Map( PAD_SIM_ELECTRICAL_TYPE::NONE, _HKI( "None" ) )
3561 .Map( PAD_SIM_ELECTRICAL_TYPE::SOURCE, _HKI( "Source" ) )
3562 .Map( PAD_SIM_ELECTRICAL_TYPE::SINK, _HKI( "Sink" ) );
3563
3564 // Ensure post-machining mode enum choices are defined before properties use them
3565 {
3568
3569 if( pmMap.Choices().GetCount() == 0 )
3570 {
3575 }
3576 }
3577
3578 // Ensure backdrill mode enum choices are defined before properties use them
3579 {
3581
3582 if( bdMap.Choices().GetCount() == 0 )
3583 {
3585 .Map( BACKDRILL_MODE::NO_BACKDRILL, _HKI( "No backdrill" ) )
3586 .Map( BACKDRILL_MODE::BACKDRILL_BOTTOM, _HKI( "Backdrill bottom" ) )
3587 .Map( BACKDRILL_MODE::BACKDRILL_TOP, _HKI( "Backdrill top" ) )
3588 .Map( BACKDRILL_MODE::BACKDRILL_BOTH, _HKI( "Backdrill both" ) );
3589 }
3590 }
3591
3593
3594 if( zcMap.Choices().GetCount() == 0 )
3595 {
3597 zcMap.Map( ZONE_CONNECTION::INHERITED, _HKI( "Inherited" ) )
3598 .Map( ZONE_CONNECTION::NONE, _HKI( "None" ) )
3599 .Map( ZONE_CONNECTION::THERMAL, _HKI( "Thermal reliefs" ) )
3600 .Map( ZONE_CONNECTION::FULL, _HKI( "Solid" ) )
3601 .Map( ZONE_CONNECTION::THT_THERMAL, _HKI( "Thermal reliefs for PTH" ) );
3602 }
3603
3605 .Map( UNCONNECTED_LAYER_MODE::KEEP_ALL, _HKI( "All copper layers" ) )
3606 .Map( UNCONNECTED_LAYER_MODE::REMOVE_ALL, _HKI( "Connected layers only" ) )
3607 .Map( UNCONNECTED_LAYER_MODE::REMOVE_EXCEPT_START_AND_END, _HKI( "Front, back and connected layers" ) )
3608 .Map( UNCONNECTED_LAYER_MODE::START_END_ONLY, _HKI( "Start and end layers only" ) );
3609
3611 REGISTER_TYPE( PAD );
3616
3617 propMgr.Mask( TYPE_HASH( PAD ), TYPE_HASH( BOARD_CONNECTED_ITEM ), _HKI( "Layer" ) );
3618 propMgr.Mask( TYPE_HASH( PAD ), TYPE_HASH( BOARD_ITEM ), _HKI( "Locked" ) );
3619
3620 propMgr.AddProperty( new PROPERTY<PAD, double>( _HKI( "Orientation" ),
3622
3623 auto isCopperPad =
3624 []( INSPECTABLE* aItem ) -> bool
3625 {
3626 if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
3627 return pad->GetAttribute() != PAD_ATTRIB::NPTH;
3628
3629 return false;
3630 };
3631
3632 auto padCanHaveHole =
3633 []( INSPECTABLE* aItem ) -> bool
3634 {
3635 if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
3636 return pad->GetAttribute() == PAD_ATTRIB::PTH || pad->GetAttribute() == PAD_ATTRIB::NPTH;
3637
3638 return false;
3639 };
3640
3641 auto hasNormalPadstack =
3642 []( INSPECTABLE* aItem ) -> bool
3643 {
3644 if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
3645 return pad->Padstack().Mode() == PADSTACK::MODE::NORMAL;
3646
3647 return true;
3648 };
3649
3651 isCopperPad );
3652 propMgr.OverrideAvailability( TYPE_HASH( PAD ), TYPE_HASH( BOARD_CONNECTED_ITEM ), _HKI( "Net Class" ),
3653 isCopperPad );
3654
3655 const wxString groupPad = _HKI( "Pad Properties" );
3656 const wxString groupPostMachining = _HKI( "Post-machining Properties" );
3657 const wxString groupBackdrill = _HKI( "Backdrill Properties" );
3658
3659 propMgr.AddProperty( new PROPERTY_ENUM<PAD, PAD_ATTRIB>( _HKI( "Pad Type" ),
3661 groupPad );
3662
3663 propMgr.AddProperty( new PROPERTY_ENUM<PAD, PAD_SHAPE>( _HKI( "Pad Shape" ),
3665 groupPad )
3666 .SetAvailableFunc( hasNormalPadstack );
3667
3668 propMgr.AddProperty( new PROPERTY<PAD, wxString>( _HKI( "Pad Number" ),
3670 groupPad )
3671 .SetAvailableFunc( isCopperPad );
3672
3673 propMgr.AddProperty( new PROPERTY<PAD, wxString>( _HKI( "Pin Name" ),
3675 groupPad )
3677
3678 propMgr.AddProperty( new PROPERTY<PAD, wxString>( _HKI( "Pin Type" ),
3680 groupPad )
3682 .SetChoicesFunc( []( INSPECTABLE* aItem )
3683 {
3684 wxPGChoices choices;
3685
3686 for( int ii = 0; ii < ELECTRICAL_PINTYPES_TOTAL; ii++ )
3688
3689 return choices;
3690 } );
3691
3692 propMgr.AddProperty( new PROPERTY_ENUM<PAD, PAD_SIM_ELECTRICAL_TYPE>( _HKI( "Simulation Electrical Type" ),
3694 groupPad );
3695
3696 propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Size X" ),
3698 groupPad )
3699 .SetAvailableFunc( hasNormalPadstack );
3700 propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Size Y" ),
3702 groupPad )
3703 .SetAvailableFunc( []( INSPECTABLE* aItem ) -> bool
3704 {
3705 if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
3706 {
3707 // Custom padstacks can't have size modified through panel
3708 if( pad->Padstack().Mode() != PADSTACK::MODE::NORMAL )
3709 return false;
3710
3711 // Circle pads have no usable y-size
3712 return pad->GetShape( PADSTACK::ALL_LAYERS ) != PAD_SHAPE::CIRCLE;
3713 }
3714
3715 return true;
3716 } );
3717
3718 const auto hasRoundRadius =
3719 []( INSPECTABLE* aItem ) -> bool
3720 {
3721 if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
3722 {
3723 // Custom padstacks can't have this property modified through panel
3724 if( pad->Padstack().Mode() != PADSTACK::MODE::NORMAL )
3725 return false;
3726
3728 }
3729
3730 return false;
3731 };
3732
3733 propMgr.AddProperty( new PROPERTY<PAD, double>( _HKI( "Corner Radius Ratio" ),
3735 groupPad )
3736 .SetAvailableFunc( hasRoundRadius );
3737
3738 propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Corner Radius Size" ),
3740 groupPad )
3741 .SetAvailableFunc( hasRoundRadius );
3742
3743 propMgr.AddProperty( new PROPERTY_ENUM<PAD, PAD_DRILL_SHAPE>( _HKI( "Hole Shape" ),
3744 &PAD::SetDrillShape, &PAD::GetDrillShape ), groupPad )
3745 .SetWriteableFunc( padCanHaveHole );
3746
3747 propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Hole Size X" ),
3749 groupPad )
3750 .SetWriteableFunc( padCanHaveHole )
3752
3753 propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Hole Size Y" ),
3755 groupPad )
3756 .SetWriteableFunc( padCanHaveHole )
3758 .SetAvailableFunc( []( INSPECTABLE* aItem ) -> bool
3759 {
3760 // Circle holes have no usable y-size
3761 if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
3762 return pad->GetDrillShape() != PAD_DRILL_SHAPE::CIRCLE;
3763
3764 return true;
3765 } );
3766
3767 propMgr.AddProperty( new PROPERTY_ENUM<PAD, PAD_DRILL_POST_MACHINING_MODE>( _HKI( "Top Post-machining" ),
3769 groupPostMachining )
3770 .SetWriteableFunc( padCanHaveHole )
3771 .SetAvailableFunc( []( INSPECTABLE* aItem )
3772 {
3773 if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
3774 return pad->GetDrillShape() == PAD_DRILL_SHAPE::CIRCLE;
3775
3776 return false;
3777 } );
3778
3779 propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Top Post-machining Size" ),
3781 groupPostMachining )
3782 .SetWriteableFunc( padCanHaveHole )
3784 []( INSPECTABLE* aItem )
3785 {
3786 if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
3787 {
3788 if( pad->GetDrillShape() != PAD_DRILL_SHAPE::CIRCLE )
3789 return false;
3790
3791 std::optional<PAD_DRILL_POST_MACHINING_MODE> mode = pad->GetFrontPostMachining();
3792 return mode.has_value()
3794 || mode.value() == PAD_DRILL_POST_MACHINING_MODE::COUNTERSINK );
3795 }
3796
3797 return false;
3798 } );
3799
3800 propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Top Counterbore Depth" ),
3802 groupPostMachining )
3803 .SetWriteableFunc( padCanHaveHole )
3805 []( INSPECTABLE* aItem )
3806 {
3807 if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
3808 {
3809 if( pad->GetDrillShape() != PAD_DRILL_SHAPE::CIRCLE )
3810 return false;
3811
3812 std::optional<PAD_DRILL_POST_MACHINING_MODE> mode = pad->GetFrontPostMachining();
3813 return mode.has_value() && mode.value() == PAD_DRILL_POST_MACHINING_MODE::COUNTERBORE;
3814 }
3815
3816 return false;
3817 } );
3818
3819 propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Top Countersink Angle" ),
3821 groupPostMachining )
3822 .SetWriteableFunc( padCanHaveHole )
3824 []( INSPECTABLE* aItem )
3825 {
3826 if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
3827 {
3828 if( pad->GetDrillShape() != PAD_DRILL_SHAPE::CIRCLE )
3829 return false;
3830
3831 std::optional<PAD_DRILL_POST_MACHINING_MODE> mode = pad->GetFrontPostMachining();
3832 return mode.has_value() && mode.value() == PAD_DRILL_POST_MACHINING_MODE::COUNTERSINK;
3833 }
3834
3835 return false;
3836 } );
3837
3838 propMgr.AddProperty( new PROPERTY_ENUM<PAD, PAD_DRILL_POST_MACHINING_MODE>( _HKI( "Bottom Post-machining" ),
3840 groupPostMachining )
3841 .SetWriteableFunc( padCanHaveHole )
3842 .SetAvailableFunc( []( INSPECTABLE* aItem )
3843 {
3844 if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
3845 return pad->GetDrillShape() == PAD_DRILL_SHAPE::CIRCLE;
3846
3847 return false;
3848 } );
3849
3850 propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Bottom Post-machining Size" ),
3852 groupPostMachining )
3853 .SetWriteableFunc( padCanHaveHole )
3855 []( INSPECTABLE* aItem )
3856 {
3857 if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
3858 {
3859 if( pad->GetDrillShape() != PAD_DRILL_SHAPE::CIRCLE )
3860 return false;
3861
3862 std::optional<PAD_DRILL_POST_MACHINING_MODE> mode = pad->GetBackPostMachining();
3863 return mode.has_value()
3865 || mode.value() == PAD_DRILL_POST_MACHINING_MODE::COUNTERSINK );
3866 }
3867
3868 return false;
3869 } );
3870
3871 propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Bottom Counterbore Depth" ),
3873 groupPostMachining )
3874 .SetWriteableFunc( padCanHaveHole )
3876 []( INSPECTABLE* aItem )
3877 {
3878 if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
3879 {
3880 if( pad->GetDrillShape() != PAD_DRILL_SHAPE::CIRCLE )
3881 return false;
3882
3883 std::optional<PAD_DRILL_POST_MACHINING_MODE> mode = pad->GetBackPostMachining();
3884 return mode.has_value() && mode.value() == PAD_DRILL_POST_MACHINING_MODE::COUNTERBORE;
3885 }
3886
3887 return false;
3888 } );
3889
3890 propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Bottom Countersink Angle" ),
3892 groupPostMachining )
3893 .SetWriteableFunc( padCanHaveHole )
3895 []( INSPECTABLE* aItem )
3896 {
3897 if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
3898 {
3899 if( pad->GetDrillShape() != PAD_DRILL_SHAPE::CIRCLE )
3900 return false;
3901
3902 std::optional<PAD_DRILL_POST_MACHINING_MODE> mode = pad->GetBackPostMachining();
3903 return mode.has_value() && mode.value() == PAD_DRILL_POST_MACHINING_MODE::COUNTERSINK;
3904 }
3905
3906 return false;
3907 } );
3908
3909 propMgr.AddProperty( new PROPERTY_ENUM<PAD, BACKDRILL_MODE>( _HKI( "Backdrill Mode" ),
3911 groupBackdrill );
3912
3913 propMgr.AddProperty( new PROPERTY<PAD, std::optional<int>>( _HKI( "Bottom Backdrill Size" ),
3915 groupBackdrill )
3917 []( INSPECTABLE* aItem ) -> bool
3918 {
3919 if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
3920 {
3921 if( pad->GetDrillShape() != PAD_DRILL_SHAPE::CIRCLE )
3922 return false;
3923
3924 BACKDRILL_MODE mode = pad->GetBackdrillMode();
3927 }
3928
3929 return false;
3930 } );
3931
3932 propMgr.AddProperty( new PROPERTY_ENUM<PAD, PCB_LAYER_ID>( _HKI( "Bottom Backdrill Must-Cut" ),
3934 groupBackdrill )
3936 []( INSPECTABLE* aItem ) -> bool
3937 {
3938 if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
3939 {
3940 if( pad->GetDrillShape() != PAD_DRILL_SHAPE::CIRCLE )
3941 return false;
3942
3943 BACKDRILL_MODE mode = pad->GetBackdrillMode();
3946 }
3947
3948 return false;
3949 } );
3950
3951 propMgr.AddProperty( new PROPERTY<PAD, std::optional<int>>( _HKI( "Top Backdrill Size" ),
3953 groupBackdrill )
3955 []( INSPECTABLE* aItem ) -> bool
3956 {
3957 if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
3958 {
3959 if( pad->GetDrillShape() != PAD_DRILL_SHAPE::CIRCLE )
3960 return false;
3961
3962 BACKDRILL_MODE mode = pad->GetBackdrillMode();
3964 }
3965
3966 return false;
3967 } );
3968
3969 propMgr.AddProperty( new PROPERTY_ENUM<PAD, PCB_LAYER_ID>( _HKI( "Top Backdrill Must-Cut" ),
3971 groupBackdrill )
3973 []( INSPECTABLE* aItem ) -> bool
3974 {
3975 if( PAD* pad = dynamic_cast<PAD*>( aItem ) )
3976 {
3977 if( pad->GetDrillShape() != PAD_DRILL_SHAPE::CIRCLE )
3978 return false;
3979
3980 BACKDRILL_MODE mode = pad->GetBackdrillMode();
3982 }
3983
3984 return false;
3985 } );
3986
3987
3988 propMgr.AddProperty( new PROPERTY_ENUM<PAD, PAD_PROP>( _HKI( "Fabrication Property" ),
3990 groupPad );
3991
3992 propMgr.AddProperty( new PROPERTY_ENUM<PAD, UNCONNECTED_LAYER_MODE>( _HKI( "Copper Layers" ),
3994 groupPad );
3995
3996 propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Pad To Die Length" ),
3998 groupPad )
3999 .SetAvailableFunc( isCopperPad );
4000
4001 propMgr.AddProperty( new PROPERTY<PAD, int>( _HKI( "Pad To Die Delay" ),
4003 groupPad )
4004 .SetAvailableFunc( isCopperPad );
4005
4006 const wxString groupOverrides = _HKI( "Overrides" );
4007
4008 propMgr.AddProperty( new PROPERTY<PAD, std::optional<int>>( _HKI( "Clearance Override" ),
4010 groupOverrides )
4011 .SetIsCopyable();
4012
4013 propMgr.AddProperty( new PROPERTY<PAD, std::optional<int>>( _HKI( "Soldermask Margin Override" ),
4015 groupOverrides )
4016 .SetIsCopyable();
4017
4018 propMgr.AddProperty( new PROPERTY<PAD, std::optional<int>>( _HKI( "Solderpaste Margin Override" ),
4020 groupOverrides )
4021 .SetIsCopyable();
4022
4023 propMgr.AddProperty( new PROPERTY<PAD, std::optional<double>>( _HKI( "Solderpaste Margin Ratio Override" ),
4026 groupOverrides )
4027 .SetIsCopyable();
4028
4029 propMgr.AddProperty( new PROPERTY_ENUM<PAD, ZONE_CONNECTION>( _HKI( "Zone Connection Style" ),
4031 groupOverrides )
4032 .SetIsCopyable();
4033
4034 constexpr int minZoneWidth = pcbIUScale.mmToIU( ZONE_THICKNESS_MIN_VALUE_MM );
4035
4036 propMgr.AddProperty( new PROPERTY<PAD, std::optional<int>>( _HKI( "Thermal Relief Spoke Width" ),
4039 groupOverrides )
4041 .SetIsCopyable();
4042
4043 propMgr.AddProperty( new PROPERTY<PAD, double>( _HKI( "Thermal Relief Spoke Angle" ),
4046 groupOverrides )
4047 .SetIsCopyable();
4048
4049 propMgr.AddProperty( new PROPERTY<PAD, std::optional<int>>( _HKI( "Thermal Relief Gap" ),
4052 groupOverrides )
4054 .SetIsCopyable();
4055
4056 // TODO delta, drill shape offset, layer set
4057 }
4059
KICOMMON_API types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICOMMON_API KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
Definition api_enums.cpp:56
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
@ ERROR_OUTSIDE
@ ERROR_INSIDE
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:128
constexpr int ARC_LOW_DEF
Definition base_units.h:143
BITMAPS
A list of all bitmap identifiers.
@ FPHOLDER
Definition board.h:403
ZONE_LAYER_OVERRIDE
Conditionally flashed vias and pads that interact with zones of different priority can be very squirr...
Definition board_item.h:75
@ ZLO_NONE
Definition board_item.h:76
@ ZLO_FORCE_FLASHED
Definition board_item.h:77
SEG MIRROR_AXIS(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
Definition board_item.h:85
BOX2< VECTOR2I > BOX2I
Definition box2.h:917
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:985
BASE_SET & set(size_t pos)
Definition base_set.h:126
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
virtual NETCLASS * GetEffectiveNetClass() const
Return the NETCLASS for this item.
virtual bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
BOARD_CONNECTED_ITEM(BOARD_ITEM *aParent, KICAD_T idtype)
void PackNet(kiapi::board::types::Net *aProto) const
TEARDROP_PARAMETERS m_teardropParams
Not all BOARD_CONNECTED_ITEMs support teardrops, but we want those that do to share a single section ...
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
NETINFO_ITEM * GetNet() const
Return NETINFO_ITEM object for a given item.
const wxString & GetShortNetname() const
virtual int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const
Return an item's "own" clearance in internal units.
void UnpackNet(const kiapi::board::types::Net &aProto)
Assigns a net to this item from an API message.
TEARDROP_PARAMETERS & GetTeardropParams()
void SetTeardropsEnabled(bool aEnable)
std::shared_ptr< DRC_ENGINE > m_DRCEngine
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:99
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:101
void SetUuidDirect(const KIID &aUuid)
Raw UUID assignment.
void SetLocked(bool aLocked) override
Definition board_item.h:441
PCB_LAYER_ID GetFlippedLayer(PCB_LAYER_ID aLayer) const
Return the layer paired with aLayer on the opposite side of the board.
LSET viewVisibleLayers(const KIGFX::VIEW *aView) const
Enabled board layers that aView shows, for LOD checks on views that hide layers on their own.
static double polygonArea(SHAPE_POLY_SET &aPolySet)
Area of aPolySet with every contour closed first, holes subtracted.
PCB_LAYER_ID m_layer
Definition board_item.h:625
bool IsLocked() const override
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
FOOTPRINT * GetParentFootprint() const
virtual wxString LayerMaskDescribe() const
Return a string (to be shown to the user) describing a layer mask.
BOARD_ITEM & operator=(const BOARD_ITEM &aOther)
Definition board_item.h:118
BOARD_ITEM_CONTAINER * GetParent() const
Definition board_item.h:281
virtual int BoardCopperLayerCount() const
Return the total number of copper layers for the board that this item resides on.
int GetMaxError() const
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
int GetMaxClearanceValue() const
Returns the maximum clearance value for any object on the board.
Definition board.cpp:1353
BOX2I ExpandBoundingBoxForDrillSymbols(const BOX2I &aBoundingBox) const
Include every displaced copy of a hole-owned drill symbol in its view bounds.
Definition board.cpp:300
BOARD_DESIGN_SETTINGS & GetDesignSettings()
Definition board.cpp:1318
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition box2.h:556
constexpr BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition box2.h:149
static constexpr BOX2< VECTOR2I > ByCenter(const VECTOR2I &aCenter, const SizeVec &aSize)
Definition box2.h:72
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition box2.h:597
constexpr bool Contains(const Vec &aPoint) const
Definition box2.h:171
constexpr const Vec & GetOrigin() const
Definition box2.h:213
constexpr const SizeVec & GetSize() const
Definition box2.h:209
constexpr bool Intersects(const BOX2< Vec > &aRect) const
Definition box2.h:314
MINOPTMAX< int > m_Value
Definition drc_rule.h:206
Design Rule Checker object that performs all the DRC tests.
Definition drc_engine.h:129
DRC_CONSTRAINT EvalRules(DRC_CONSTRAINT_T aConstraintType, const BOARD_ITEM *a, const BOARD_ITEM *b, PCB_LAYER_ID aLayer, REPORTER *aReporter=nullptr)
double Sin() const
Definition eda_angle.h:177
double AsDegrees() const
Definition eda_angle.h:115
bool IsZero() const
Definition eda_angle.h:135
EDA_ANGLE Normalize180()
Definition eda_angle.h:273
double Cos() const
Definition eda_angle.h:196
EDA_ANGLE Normalized() const
Definition eda_angle.h:241
The base class for create windows for drawing purpose.
A set of EDA_ITEMs (i.e., without duplicates).
Definition eda_group.h:43
const KIID m_Uuid
Definition eda_item.h:599
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition eda_item.h:160
bool IsSelected() const
Definition eda_item.h:134
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:153
EDA_ITEM * m_parent
Owner.
Definition eda_item.h:609
EDA_ITEM_FLAGS GetFlags() const
Definition eda_item.h:167
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
const VECTOR2I & GetBezierC2() const
Definition eda_shape.h:377
SHAPE_POLY_SET & GetPolyShape()
SHAPE_T GetShape() const
Definition eda_shape.h:178
virtual void SetFilled(bool aFlag)
Definition eda_shape.h:145
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition eda_shape.h:334
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition eda_shape.h:284
bool IsAnyFill() const
Definition eda_shape.h:121
const VECTOR2I & GetBezierC1() const
Definition eda_shape.h:374
void SetPolyPoints(const std::vector< VECTOR2I > &aPoints)
void SetFillMode(FILL_T aFill)
VECTOR2I GetArcMid() const
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition property.h:817
static ENUM_MAP< T > & Instance()
Definition property.h:811
ENUM_MAP & Undefined(T aValue)
Definition property.h:824
wxPGChoices & Choices()
Definition property.h:862
EDA_ANGLE GetOrientation() const
Definition footprint.h:382
std::map< wxString, int > MapPadNumbersToNetTieGroups() const
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition footprint.h:393
bool IsNetTie() const
Definition footprint.h:525
const wxString & GetReference() const
Definition footprint.h:793
DRAWINGS & GraphicalItems()
Definition footprint.h:358
Class that other classes need to inherit from, in order to be inspectable.
Definition inspectable.h:39
Contains methods for drawing PCB-specific items.
virtual PCB_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
PCB specific render settings.
Definition pcb_painter.h:94
const std::set< int > & GetHighlightNetCodes() const
Return the netcode of currently highlighted net.
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
Return the board layer which is in high-contrast mode.
bool IsHighlightEnabled() const
Return current highlight setting.
static double lodScaleForThreshold(const KIGFX::VIEW *aView, int aWhatIu, int aThresholdIu)
Get the scale at which aWhatIu would be drawn at the same size as aThresholdIu on screen.
Definition view_item.cpp:35
static constexpr double LOD_HIDE
Return this constant from ViewGetLOD() to hide the item unconditionally.
Definition view_item.h:176
static constexpr double LOD_SHOW
Return this constant from ViewGetLOD() to show the item unconditionally.
Definition view_item.h:181
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:68
bool IsLayerVisibleCached(int aLayer) const
Definition view.h:472
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition view.h:457
PAINTER * GetPainter() const
Return the painter object used by the view for drawing VIEW_ITEM objects.
Definition view.h:242
Definition kiid.h:46
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
static const LSET & FrontMask()
Return a mask holding all technical layers and the external CU layer on front side.
Definition lset.cpp:718
static const LSET & AllCuMask()
return AllCuMask( MAX_CU_LAYERS );
Definition lset.cpp:604
static const LSET & FrontBoardTechMask()
Return a mask holding technical layers used in a board fabrication (no CU layer) on front side.
Definition lset.cpp:665
static const LSET & BackMask()
Return a mask holding all technical layers and the external CU layer on back side.
Definition lset.cpp:725
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition lset.cpp:309
static LSET AllCuMask(int aCuLayerCount)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition lset.cpp:595
static const LSET & PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
Definition lset.cpp:693
static const LSET & BackBoardTechMask()
Return a mask holding technical layers used in a board fabrication (no CU layer) on Back side.
Definition lset.cpp:651
T Opt() const
Definition minoptmax.h:31
bool HasOpt() const
Definition minoptmax.h:39
Handle the data for a net.
Definition netinfo.h:50
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Definition netinfo.h:281
double Similarity(const PADSTACK &aOther) const
Return a measure of how likely the other object is to represent the same object.
int GetMaxHoleSize() const
void ForEachUniqueLayer(const std::function< void(PCB_LAYER_ID)> &aMethod) const
Runs the given callable for each active unique copper layer in this padstack, meaning F_Cu for MODE::...
PCB_LAYER_ID EffectiveLayerFor(PCB_LAYER_ID aLayer) const
Determines which geometry layer should be used for the given input layer.
static int Compare(const PADSTACK *aPadstackRef, const PADSTACK *aPadstackCmp)
Compare two padstacks and return 0 if they are equal.
@ NORMAL
Shape is the same on all layers.
Definition padstack.h:175
void SetOrientation(const EDA_ANGLE &aAngle)
Definition padstack.h:361
static constexpr PCB_LAYER_ID ALL_LAYERS
! The layer identifier to use for the single defintion on normal padstacks
Definition padstack.h:184
static constexpr PCB_LAYER_ID TEMP_ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
Definition padstack.h:181
std::vector< std::shared_ptr< PCB_SHAPE > > & Primitives(PCB_LAYER_ID aLayer)
Definition pad.h:61
VECTOR2I GetPrimaryDrillSize() const
Definition pad.cpp:795
void SetFrontPostMachiningSize(int aSize)
Definition pad.h:458
int GetBackPostMachiningSize() const
Definition pad.h:479
void SetAnchorPadShape(PCB_LAYER_ID aLayer, PAD_SHAPE aShape)
Set the shape of the anchor pad for custom shaped pads.
Definition pad.h:249
bool IsAperturePad() const
Definition pad.h:589
void SetAttribute(PAD_ATTRIB aAttribute)
Definition pad.cpp:1563
int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const override
Return the pad's "own" clearance in internal units.
Definition pad.cpp:1953
PAD(FOOTPRINT *parent)
Definition pad.cpp:75
virtual void swapData(BOARD_ITEM *aImage) override
Definition pad.cpp:2995
PAD_PROP GetProperty() const
Definition pad.h:585
void SetFrontPostMachiningAngle(int aAngle)
Definition pad.h:462
void OnFootprintTransformed() override
Hook for items inside a footprint to refresh after the FP transform changes (translate,...
Definition pad.cpp:2512
void SetPrimaryDrillFilledFlag(bool aFilled)
Definition pad.cpp:926
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition pad.cpp:401
double GetFrontRoundRectRadiusRatio() const
Definition pad.h:844
static wxString ShowPadShape(PAD_SHAPE aShape)
Definition pad.cpp:2524
std::optional< int > GetClearanceOverrides(wxString *aSource) const override
Return any clearance overrides set in the "classic" (ie: pre-rule) system.
Definition pad.cpp:1918
void SetPinType(const wxString &aType)
Set the pad electrical type.
Definition pad.h:159
int GetBackdrillOrPostMachiningKnockout(PCB_LAYER_ID aLayer) const
Definition pad.cpp:897
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition pad.h:579
const ZONE_LAYER_OVERRIDE & GetZoneLayerOverride(PCB_LAYER_ID aLayer) const
Definition pad.cpp:521
void MergePrimitivesAsPolygon(PCB_LAYER_ID aLayer, SHAPE_POLY_SET *aMergedPolygon, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Merge all basic shapes to a SHAPE_POLY_SET.
Definition pad.cpp:3480
int GetRoundRectCornerRadius(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1053
void rebakePrimitiveToFootprint(PCB_SHAPE *aPrimitive) const
Definition pad.cpp:2483
bool FlashLayer(int aLayer, bool aOnlyCheckIfPermitted=false) const
Check to see whether the pad should be flashed on the specific layer.
Definition pad.cpp:697
void SetLocalThermalGapOverride(const std::optional< int > &aOverride)
Definition pad.h:803
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Return a SHAPE_SEGMENT object representing the pad's hole.
Definition pad.cpp:1233
double GetCoverageArea(int aTextMargin) const override
Return the board area this item covers, used to rank candidates under the cursor so a click on a smal...
Definition pad.cpp:3020
void SetPrimaryDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:783
std::mutex m_maskShapeMutex
Definition pad.h:1154
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:2166
const BOX2I GetBoundingBox() const override
The bounding box is cached, so this will be efficient most of the time.
Definition pad.cpp:1545
void SetTertiaryDrillStartLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:1039
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition pad.h:950
void AddPrimitivePoly(PCB_LAYER_ID aLayer, const SHAPE_POLY_SET &aPoly, int aThickness, bool aFilled)
Has meaning only for custom shape pads.
Definition pad.cpp:3369
std::optional< double > GetLocalSolderPasteMarginRatio() const
Definition pad.h:622
void SetFrontPostMachiningDepth(int aDepth)
Definition pad.h:460
void SetFrontShape(PAD_SHAPE aShape)
Definition pad.cpp:1620
void SetTopBackdrillLayer(PCB_LAYER_ID aLayer)
Definition pad.h:1098
const wxString & GetPinType() const
Definition pad.h:160
void SetZoneLayerOverride(PCB_LAYER_ID aLayer, ZONE_LAYER_OVERRIDE aOverride)
Definition pad.cpp:531
void SetSecondaryDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:947
void SetPrimaryDrillFilled(const std::optional< bool > &aFilled)
Definition pad.cpp:919
PAD_ATTRIB GetAttribute() const
Definition pad.h:582
static LSET PTHMask()
layer set for a through hole pad
Definition pad.cpp:620
int GetDrillSizeYProp() const
Definition pad.h:324
static int Compare(const PAD *aPadRef, const PAD *aPadCmp)
Compare two pads and return 0 if they are equal.
Definition pad.cpp:2448
const wxString & GetPinFunction() const
Definition pad.h:154
bool CanHaveNumber() const
Indicates whether or not the pad can have a number.
Definition pad.cpp:538
void SetThermalSpokeAngle(const EDA_ANGLE &aAngle)
The orientation of the thermal spokes.
Definition pad.h:775
wxString m_pinType
Definition pad.h:1141
std::optional< int > GetBottomBackdrillSize() const
Definition pad.h:1088
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition pad.cpp:450
const wxString & GetNumber() const
Definition pad.h:143
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition pad.cpp:2781
void SetSecondaryDrillSizeX(int aX)
Definition pad.cpp:954
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aMaxError, ERROR_LOC aErrorLoc=ERROR_INSIDE, bool aIgnoreLineWidth=false) const override
Convert the pad shape to a closed polygon.
Definition pad.cpp:3036
void SetFrontRoundRectRadiusRatio(double aRadiusScale)
Definition pad.cpp:1073
void SetPrimaryDrillSizeX(int aX)
Definition pad.cpp:805
PAD_DRAW_CACHE_DATA & getDrawCache() const
Definition pad.cpp:1264
std::mutex m_dataMutex
Definition pad.h:1149
void BuildEffectiveShapes() const
Rebuild the effective shape cache (and bounding box and radius) for the pad and clears the dirty bit.
Definition pad.cpp:1273
void SetPrimaryDrillEndLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:876
void SetSimElectricalType(PAD_SIM_ELECTRICAL_TYPE aType)
Definition pad.h:594
PAD_SHAPE GetFrontShape() const
Definition pad.h:210
void SetFrontPostMachiningMode(PAD_DRILL_POST_MACHINING_MODE aMode)
Definition pad.h:448
void CopyFrom(const BOARD_ITEM *aOther) override
Definition pad.cpp:366
void SetLocalSolderPasteMarginRatio(std::optional< double > aRatio)
Definition pad.h:626
PAD & operator=(const PAD &aOther)
Definition pad.cpp:347
void SetLocalThermalSpokeWidthOverride(std::optional< int > aWidth)
Set the width of the thermal spokes connecting the pad to a zone.
Definition pad.h:759
void SetShape(PCB_LAYER_ID aLayer, PAD_SHAPE aShape)
Set the new shape of this pad.
Definition pad.h:196
void SetSecondaryDrillStartLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:986
bool IsLocked() const override
Definition pad.cpp:582
wxString ShowLegacyPadShape(PCB_LAYER_ID aLayer) const
An older version still used by place file writer.
Definition pad.cpp:2546
void SetSizeXProp(int aX)
Definition pad.cpp:307
void OnFootprintRescaled(double aRatioX, double aRatioY, double aLinearFactor, const VECTOR2I &aAnchor, const EDA_ANGLE &aParentRotate) override
Apply a parent footprint scale to this item.
Definition pad.cpp:2494
VECTOR2I GetPosition() const override
Definition pad.cpp:255
void SetProperty(PAD_PROP aProperty)
Definition pad.cpp:1639
void SetThermalSpokeAngleDegrees(double aAngle)
Definition pad.h:785
void SetPrimaryDrillSizeY(int aY)
Definition pad.cpp:823
EDA_ANGLE GetThermalSpokeAngle() const
Definition pad.h:779
std::map< PCB_LAYER_ID, ZONE_LAYER_OVERRIDE > m_zoneLayerOverrides
Definition pad.h:1175
PAD_ATTRIB m_attribute
Definition pad.h:1162
void Flip(const VECTOR2I &VECTOR2I, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition pad.cpp:1690
int GetDrillSizeXProp() const
Definition pad.h:322
void SetBackPostMachiningSize(int aSize)
Definition pad.h:478
std::vector< PCB_SHAPE * > Recombine(bool aIsDryRun, int aMaxError)
Recombines the pad with other graphical shapes in the footprint.
Definition pad.cpp:3142
PCB_LAYER_ID GetPrincipalLayer() const
Definition pad.cpp:669
void ClearTertiaryDrillSize()
Definition pad.cpp:1025
void SetDirty()
Definition pad.h:571
PAD_DRILL_SHAPE GetTertiaryDrillShape() const
Definition pad.h:559
int GetSizeXProp() const
Definition pad.cpp:321
static LSET UnplatedHoleMask()
layer set for a mechanical unplated through hole pad
Definition pad.cpp:641
void SetBottomBackdrillLayer(PCB_LAYER_ID aLayer)
Definition pad.h:1092
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition pad.cpp:2670
void SetTertiaryDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.cpp:1032
VECTOR2I GetOffset(PCB_LAYER_ID aLayer) const
Definition pad.cpp:848
double GetOrientationDegrees() const
Definition pad.h:432
void SetBackdrillMode(BACKDRILL_MODE aMode)
Definition pad.h:1086
VECTOR2I GetDrillSize() const
Definition pad.h:320
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition pad.cpp:2459
int GetBackPostMachiningAngle() const
Definition pad.h:483
PADSTACK m_padStack
Definition pad.h:1146
void SetPadToDieDelay(int aDelay)
Definition pad.h:602
void FlipPrimitives(FLIP_DIRECTION aFlipDirection)
Flip (mirror) the primitives left to right or top to bottom, around the anchor position in custom pad...
Definition pad.cpp:1733
VECTOR2I m_libPos
Definition pad.h:1143
void mirrorChamferPositions(FLIP_DIRECTION aFlipDirection)
Definition pad.cpp:1786
bool IsNoConnectPad() const
Definition pad.cpp:608
PAD_PROP m_property
Definition pad.h:1164
int GetFrontPostMachiningSize() const
Definition pad.h:459
void SetTertiaryDrillSizeX(int aX)
Definition pad.cpp:1007
void DeletePrimitivesList(PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
Clear the basic shapes list.
Definition pad.cpp:3461
void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Mirror this object relative to a given horizontal axis the layer is not changed.
Definition pad.cpp:1751
void SetUnconnectedLayerMode(UNCONNECTED_LAYER_MODE aMode)
Definition pad.h:920
PAD_SHAPE GetShape(PCB_LAYER_ID aLayer) const
Definition pad.h:205
void SetNumber(const wxString &aNumber)
Set the pad number (note that it can be alphanumeric, such as the array reference "AA12").
Definition pad.h:142
BACKDRILL_MODE GetBackdrillMode() const
Definition pad.h:1085
void SetTertiaryDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:1000
void SetFrontRoundRectRadiusSize(int aRadius)
Definition pad.cpp:1083
wxString ShowPadAttr() const
Definition pad.cpp:2562
wxString m_pinFunction
Definition pad.h:1140
void SetSecondaryDrillEndLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:993
void AddPrimitive(PCB_LAYER_ID aLayer, PCB_SHAPE *aPrimitive)
Add item to the custom shape primitives list.
Definition pad.cpp:3436
int GetFrontPostMachiningDepth() const
Definition pad.h:461
void SetDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.h:437
int m_effectiveBoundingRadius
Definition pad.h:1157
void SetDrillSizeXProp(int aX)
Definition pad.cpp:817
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
Definition pad.h:609
void SetBackPostMachiningMode(PAD_DRILL_POST_MACHINING_MODE aMode)
Definition pad.h:468
void SetOffset(PCB_LAYER_ID aLayer, const VECTOR2I &aOffset)
Definition pad.cpp:837
void SetCustomShapeInZoneOpt(CUSTOM_SHAPE_ZONE_MODE aOption)
Set the option for the custom pad shape to use as clearance area in copper zones.
Definition pad.h:237
void SetLocalZoneConnection(ZONE_CONNECTION aType)
Definition pad.h:632
void SetChamferRectRatio(PCB_LAYER_ID aLayer, double aChamferScale)
Has meaning only for chamfered rectangular pads.
Definition pad.cpp:1103
void SetPrimaryDrillCappedFlag(bool aCapped)
Definition pad.cpp:940
int GetSolderMaskExpansion(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1960
VECTOR2I GetSize(PCB_LAYER_ID aLayer) const
Definition pad.cpp:297
int GetPadToDieDelay() const
Definition pad.h:603
std::optional< int > GetLocalClearance() const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition pad.h:605
void ImportSettingsFrom(const PAD &aMasterPad)
Import the pad settings from aMasterPad.
Definition pad.cpp:2921
double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
Definition pad.cpp:3345
std::unique_ptr< PAD_DRAW_CACHE_DATA > m_drawCache
Definition pad.h:1151
bool IsOnCopperLayer() const override
Definition pad.cpp:1862
void SetTertiaryDrillEndLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:1046
void SetPadstack(const PADSTACK &aPadstack)
Definition pad.h:333
void SetPosition(const VECTOR2I &aPos) override
Definition pad.cpp:244
const SHAPE_COMPOUND & buildEffectiveShape(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1334
void SetPrimaryDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.cpp:857
const PADSTACK & Padstack() const
Definition pad.h:331
PAD_DRILL_SHAPE GetSecondaryDrillShape() const
Definition pad.h:542
void BuildEffectivePolygon(ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition pad.cpp:1489
static LSET ConnSMDMask()
layer set for a SMD pad on Front layer used for edge board connectors
Definition pad.cpp:634
PAD_DRILL_POST_MACHINING_MODE GetBackPostMachiningMode() const
Definition pad.h:473
bool IsFreePad() const
Definition pad.cpp:614
int GetFrontPostMachiningAngle() const
Definition pad.h:463
void SetLibOffset(PCB_LAYER_ID aLayer, const VECTOR2I &aOffset)
Definition pad.cpp:290
PAD_DRILL_POST_MACHINING_MODE GetFrontPostMachiningMode() const
Definition pad.h:453
bool IsNPTHWithNoCopper() const
Definition pad.cpp:552
void SetLibSize(PCB_LAYER_ID aLayer, const VECTOR2I &aSize)
Definition pad.cpp:276
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition pad.cpp:1672
void SetSize(PCB_LAYER_ID aLayer, const VECTOR2I &aSize)
Definition pad.cpp:264
int m_delayPadToDie
Definition pad.h:1167
PAD_DRILL_SHAPE GetDrillShape() const
Definition pad.h:438
void SetSecondaryDrillShape(PAD_DRILL_SHAPE aShape)
Definition pad.cpp:979
void ReplacePrimitives(PCB_LAYER_ID aLayer, const std::vector< std::shared_ptr< PCB_SHAPE > > &aPrimitivesList)
Clear the current custom shape primitives list and import a new list.
Definition pad.cpp:3408
int GetChamferPositions(PCB_LAYER_ID aLayer) const
Definition pad.h:878
static LSET ApertureMask()
layer set for an aperture pad
Definition pad.cpp:648
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition pad.cpp:2881
UNCONNECTED_LAYER_MODE GetUnconnectedLayerMode() const
Definition pad.h:925
bool m_shapesDirty
Definition pad.h:1173
void SetRoundRectCornerRadius(PCB_LAYER_ID aLayer, double aRadius)
Definition pad.cpp:1059
void SetDrillSizeYProp(int aY)
Definition pad.cpp:831
static LSET SMDMask()
layer set for a SMD pad on Front layer
Definition pad.cpp:627
std::optional< int > GetLocalSolderPasteMargin() const
Definition pad.h:615
int GetFrontRoundRectRadiusSize() const
Definition pad.cpp:1093
static void SwapShapePositions(PAD *aLhs, PAD *aRhs, PCB_LAYER_ID aActiveLayer)
Swap the visible shape positions of two pads, preserving each pad's own shape offset.
Definition pad.cpp:1839
const std::shared_ptr< SHAPE_POLY_SET > & GetEffectivePolygon(PCB_LAYER_ID aLayer, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Definition pad.cpp:1111
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition pad.cpp:1124
int GetBackPostMachiningDepth() const
Definition pad.h:481
PAD_SIM_ELECTRICAL_TYPE GetSimElectricalType() const
Definition pad.h:595
std::optional< int > GetLocalSolderMaskMargin() const
Definition pad.h:608
void SetLocalSolderPasteMargin(std::optional< int > aMargin)
Definition pad.h:616
std::optional< int > GetLocalThermalGapOverride() const
Definition pad.h:799
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition pad.cpp:663
void GetPrimitiveLibScale(double &aScaleX, double &aScaleY) const
Definition pad.cpp:2469
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition pad.cpp:2576
void SetPinFunction(const wxString &aName)
Set the pad function (pin name in schematic)
Definition pad.h:153
EDA_ANGLE GetFPRelativeOrientation() const
Definition pad.cpp:1684
double GetChamferRectRatio(PCB_LAYER_ID aLayer) const
Definition pad.h:860
bool m_polyDirty[2]
Definition pad.h:1172
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition pad.cpp:2341
void SetFPRelativeOrientation(const EDA_ANGLE &aAngle)
Definition pad.cpp:1659
int GetPostMachiningKnockout(PCB_LAYER_ID aLayer) const
Get the knockout diameter for a layer affected by post-machining.
Definition pad.cpp:908
int GetBoundingRadius() const
Return the radius of a minimum sized circle which fully encloses this pad.
Definition pad.cpp:1255
std::optional< int > GetTopBackdrillSize() const
Definition pad.h:1094
void ClearZoneLayerOverrides()
Definition pad.cpp:512
void SetOrientation(const EDA_ANGLE &aAngle)
Set the rotation angle of the pad.
Definition pad.cpp:1647
std::optional< int > GetLocalThermalSpokeWidthOverride() const
Definition pad.h:763
PAD_DRILL_SHAPE GetPrimaryDrillShape() const
Definition pad.h:435
bool IsBackdrilledOrPostMachined(PCB_LAYER_ID aLayer) const
Check if a layer is affected by backdrilling or post-machining operations.
Definition pad.cpp:883
bool HasCopperRemoved(PCB_LAYER_ID aLayer) const
Check whether backdrilling or post-machining left no copper at all on a layer.
Definition pad.cpp:889
void SetSizeYProp(int aY)
Definition pad.cpp:327
VECTOR2I GetSolderPasteMargin(PCB_LAYER_ID aLayer) const
Usually < 0 (mask shape smaller than pad)because the margin can be dependent on the pad size,...
Definition pad.cpp:2022
void SetTopBackdrillSize(std::optional< int > aSize)
Definition pad.h:1095
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition pad.cpp:2664
void AppendPrimitives(PCB_LAYER_ID aLayer, const std::vector< std::shared_ptr< PCB_SHAPE > > &aPrimitivesList)
Import a custom shape primitive list (composed of basic shapes) and add items to the current list.
Definition pad.cpp:3421
wxString m_number
Definition pad.h:1139
std::map< PCB_LAYER_ID, std::pair< int, std::shared_ptr< SHAPE_COMPOUND > > > m_maskShapes
Definition pad.h:1155
void SetPrimaryDrillStartLayer(PCB_LAYER_ID aLayer)
Definition pad.cpp:869
void SetBackPostMachiningDepth(int aDepth)
Definition pad.h:480
void SetPrimaryDrillCapped(const std::optional< bool > &aCapped)
Definition pad.cpp:933
void SetLibDrillSize(const VECTOR2I &aSize)
Definition pad.cpp:283
PCB_LAYER_ID GetBottomBackdrillLayer() const
Definition pad.h:1091
void SetLocalClearance(std::optional< int > aClearance)
Definition pad.h:606
int GetSubRatsnest() const
Definition pad.h:886
ZONE_CONNECTION GetLocalZoneConnection() const
Definition pad.h:633
void SetTertiaryDrillSizeY(int aY)
Definition pad.cpp:1018
int m_lengthPadToDie
Definition pad.h:1166
bool HasHole() const override
Definition pad.h:113
int GetSizeYProp() const
Definition pad.cpp:341
double GetThermalSpokeAngleDegrees() const
Definition pad.h:789
CUSTOM_SHAPE_ZONE_MODE GetCustomShapeInZoneOpt() const
Definition pad.h:227
VECTOR2I ShapePos(PCB_LAYER_ID aLayer) const
Definition pad.cpp:1825
void SetSecondaryDrillSizeY(int aY)
Definition pad.cpp:965
PCB_LAYER_ID GetTopBackdrillLayer() const
Definition pad.h:1097
EDA_ORIENTATION m_libOrientation
Definition pad.h:1144
void SetOrientationDegrees(double aOrientation)
Definition pad.h:428
ZONE_CONNECTION GetZoneConnectionOverrides(wxString *aSource=nullptr) const
Definition pad.cpp:2128
int GetLocalThermalGapOverride(wxString *aSource) const
Definition pad.cpp:2157
void SetLayerSet(const LSET &aLayers) override
Definition pad.cpp:1930
bool SharesNetTieGroup(const PAD *aOther) const
Definition pad.cpp:591
PAD_SHAPE GetAnchorPadShape(PCB_LAYER_ID aLayer) const
Definition pad.h:219
void SetBottomBackdrillSize(std::optional< int > aSize)
Definition pad.h:1089
void SetRoundRectRadiusRatio(PCB_LAYER_ID aLayer, double aRadiusScale)
Has meaning only for rounded rectangle pads.
Definition pad.cpp:1065
void ClearSecondaryDrillSize()
Definition pad.cpp:972
void SetSubRatsnest(int aSubRatsnest)
Definition pad.h:887
int GetLocalSpokeWidthOverride(wxString *aSource=nullptr) const
Definition pad.cpp:2148
std::shared_ptr< SHAPE_COMPOUND > getMaskShape(PCB_LAYER_ID aLayer, int aExpansion) const
Definition pad.cpp:1207
bool TransformHoleToPolygon(SHAPE_POLY_SET &aBuffer, int aClearance, int aError, ERROR_LOC aErrorLoc=ERROR_INSIDE) const
Build the corner list of the polygonal drill shape in the board coordinate system.
Definition pad.cpp:3003
void SetPadToDieLength(int aLength)
Definition pad.h:599
bool IsFlipped() const
Definition pad.cpp:655
bool operator==(const PAD &aOther) const
Definition pad.cpp:3327
int GetPadToDieLength() const
Definition pad.h:600
void SetBackPostMachiningAngle(int aAngle)
Definition pad.h:482
virtual std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
Definition pad.cpp:2686
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
void OverrideLibPoly(const SHAPE_POLY_SET &aPoly)
Definition pcb_shape.h:290
void OverrideLibBezier(const VECTOR2I &aC1, const VECTOR2I &aC2)
Definition pcb_shape.h:284
void SetShape(SHAPE_T aShape) override
Definition pcb_shape.h:214
void SetPolyShape(const SHAPE_POLY_SET &aShape) override
bool IsProxyItem() const override
Definition pcb_shape.h:155
void OverrideLibCoords(const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aArcMid=VECTOR2I(0, 0))
Definition pcb_shape.h:273
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the shape to a closed polygon.
void RebakeWithScale(double aScaleX, double aScaleY)
void Move(const VECTOR2I &aMoveVector) override
Move this object.
void SetStroke(const STROKE_PARAMS &aStroke) override
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition pcb_shape.h:70
PROPERTY_BASE & SetChoicesFunc(std::function< wxPGChoices(INSPECTABLE *)> aFunc)
Definition property.h:289
PROPERTY_BASE & SetAvailableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Set a callback function to determine whether an object provides this property.
Definition property.h:275
PROPERTY_BASE & SetWriteableFunc(std::function< bool(INSPECTABLE *)> aFunc)
Definition property.h:305
PROPERTY_BASE & SetValidator(PROPERTY_VALIDATOR_FN &&aValidator)
Definition property.h:397
PROPERTY_BASE & SetIsCopyable(bool aIsCopyable=true)
Definition property.h:388
PROPERTY_BASE & SetIsHiddenFromLibraryEditors(bool aIsHidden=true)
Definition property.h:368
Provide class metadata.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
void Mask(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName)
Sets a base class property as masked in a derived class.
static PROPERTY_MANAGER & Instance()
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
void OverrideAvailability(TYPE_ID aDerived, TYPE_ID aBase, const wxString &aName, std::function< bool(INSPECTABLE *)> aFunc)
Sets an override availability functor for a base class property of a given derived class.
void AddTypeCast(TYPE_CAST_BASE *aCast)
Register a type converter.
static VALIDATOR_RESULT PositiveIntValidator(const wxAny &&aValue, EDA_ITEM *aItem)
static VALIDATOR_RESULT RangeIntValidator(const wxAny &&aValue, EDA_ITEM *aItem)
Definition seg.h:38
const VECTOR2I ReflectPoint(const VECTOR2I &aP) const
Reflect a point using this segment as axis.
Definition seg.cpp:630
VECTOR2I A
Definition seg.h:45
VECTOR2I B
Definition seg.h:46
static SEG::ecoord Square(int a)
Definition seg.h:119
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
void AddShape(SHAPE *aShape)
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void Move(const VECTOR2I &aVector) override
int PointCount() const
Return the number of points (vertices) in this line chain.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
void Rotate(const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
Represent a set of closed polygons.
void Rotate(const EDA_ANGLE &aAngle, const VECTOR2I &aCenter={ 0, 0 }) override
Rotate all vertices by a given angle.
void RemoveAllContours()
Remove all outlines & holes (clears) the polygon set.
bool HasHoles() const
Return true if the polygon set has any holes.
void BooleanAdd(const SHAPE_POLY_SET &b)
Perform boolean polyset union.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index.
bool IsEmpty() const
Return true if the set is empty (no polygons at all)
void Inflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify=false)
Perform outline inflation/deflation.
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)
void Simplify()
Simplify the polyset (merges overlapping polys, eliminates degeneracy/self-intersections)
void BooleanIntersection(const SHAPE_POLY_SET &b)
Perform boolean polyset intersection.
int OutlineCount() const
Return the number of outlines in the set.
void Move(const VECTOR2I &aVector) override
void Fracture(bool aSimplify=true)
Convert a set of polygons with holes to a single outline with "slits"/"fractures" connecting the oute...
bool Contains(const VECTOR2I &aP, int aSubpolyIndex=-1, int aAccuracy=0, bool aUseBBoxCaches=false) const
Return true if a given subpolygon contains the point aP.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
bool Collide(const SHAPE *aShape, int aClearance, VECTOR2I *aMTV) const override
Check if the boundary of shape (this) lies closer to the shape aShape than aClearance,...
Represent a simple polygon consisting of a zero-thickness closed chain of connected line segments.
An abstract shape on 2D plane.
Definition shape.h:124
bool NearestPoints(const SHAPE *aOther, VECTOR2I &aPtThis, VECTOR2I &aPtOther) const
Return the two points that mark the closest distance between this shape and aOther.
Simple container to manage line stroke parameters.
double GetScaleX() const
double GetScaleY() const
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
A type-safe container of any type.
Definition ki_any.h:92
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aBuffer, const VECTOR2I &aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a circle to a polygon, using multiple straight lines.
void TransformRoundChamferedRectToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aPosition, const VECTOR2I &aSize, const EDA_ANGLE &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 TransformOvalToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a oblong shape to a polygon, using multiple segments.
void TransformTrapezoidToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aPosition, const VECTOR2I &aSize, const EDA_ANGLE &aRotation, int aDeltaX, int aDeltaY, int aInflate, int aError, ERROR_LOC aErrorLoc)
Convert a rectangle or trapezoid to a polygon.
@ ROUND_ALL_CORNERS
All angles are rounded.
@ ALLOW_ACUTE_CORNERS
just inflate the polygon. Acute angles create spikes
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
Definition cvpcb.cpp:178
const int minSize
Push and Shove router track width and via size dialog.
@ ANNULAR_WIDTH_CONSTRAINT
@ SILK_CLEARANCE_CONSTRAINT
@ HOLE_CLEARANCE_CONSTRAINT
@ SOLDER_PASTE_ABS_MARGIN_CONSTRAINT
@ SOLDER_MASK_EXPANSION_CONSTRAINT
@ PHYSICAL_CLEARANCE_CONSTRAINT
@ SOLDER_PASTE_REL_MARGIN_CONSTRAINT
@ HOLE_TO_HOLE_CONSTRAINT
#define _(s)
static constexpr EDA_ANGLE ANGLE_0
Definition eda_angle.h:472
#define FOOTPRINT_EDIT_FRAME_NAME
#define PCB_EDIT_FRAME_NAME
@ FILLED_SHAPE
Fill with object color.
Definition eda_fill.h:31
#define IGNORE_PARENT_GROUP
Definition eda_item.h:55
#define ROUTER_TRANSIENT
transient items that should NOT be cached
#define ENTERED
indicates a group has been entered
#define SKIP_STRUCT
flag indicating that the structure should be ignored
static PCB_SHAPE * findNext(PCB_SHAPE *aShape, const VECTOR2I &aPoint, const KDTree &kdTree, const PCB_SHAPE_ENDPOINTS_ADAPTOR &adaptor, double aChainingEpsilon)
Searches for a PCB_SHAPE matching a given end point or start point in a list.
a few functions useful in geometry calculations.
Some functions to handle hotkeys in KiCad.
std::string source
bool IsSolderMaskLayer(int aLayer)
Definition layer_ids.h:815
@ LAYER_PAD_FR_NETNAMES
Additional netnames layers (not associated with a PCB layer).
Definition layer_ids.h:196
@ LAYER_PAD_BK_NETNAMES
Definition layer_ids.h:197
@ LAYER_PAD_NETNAMES
Definition layer_ids.h:198
bool IsDrillSymbolLayer(int aLayer)
Definition layer_ids.h:966
bool IsPadCopperLayer(int aLayer)
Definition layer_ids.h:948
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
Definition layer_ids.h:847
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition layer_ids.h:180
@ NEVER_FLASHED
Never flashed for connectivity.
Definition layer_ids.h:183
@ ALWAYS_FLASHED
Always flashed for connectivity.
Definition layer_ids.h:182
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
Definition layer_ids.h:870
bool IsClearanceLayer(int aLayer)
Definition layer_ids.h:960
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition layer_ids.h:744
@ LAYER_DRILL_SYMBOL_START
Drill symbols, one channel per board layer.
Definition layer_ids.h:385
@ LAYER_LOCKED_ITEM_SHADOW
Shadow layer for locked items.
Definition layer_ids.h:303
@ LAYER_PAD_COPPER_START
Virtual layers for pad copper on a given copper layer.
Definition layer_ids.h:358
@ LAYER_FOOTPRINTS_FR
Show footprints on front.
Definition layer_ids.h:255
@ LAYER_NON_PLATEDHOLES
Draw usual through hole vias.
Definition layer_ids.h:235
@ LAYER_PADS
Meta control for all pads opacity/visibility (color ignored).
Definition layer_ids.h:288
@ LAYER_PAD_PLATEDHOLES
to draw pad holes (plated)
Definition layer_ids.h:267
@ LAYER_CLEARANCE_START
Virtual layers for pad/via/track clearance outlines for a given copper layer.
Definition layer_ids.h:366
@ LAYER_FOOTPRINTS_BK
Show footprints on back.
Definition layer_ids.h:256
@ LAYER_PAD_HOLEWALLS
Definition layer_ids.h:293
#define DRILL_SYMBOL_LAYER_FOR(boardLayer)
Definition layer_ids.h:400
bool IsNetnameLayer(int aLayer)
Test whether a layer is a netname layer.
Definition layer_ids.h:936
bool IsHoleLayer(int aLayer)
Definition layer_ids.h:806
bool IsExternalCopperLayer(int aLayerId)
Test whether a layer is an external (F_Cu or B_Cu) copper layer.
Definition layer_ids.h:755
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ B_Adhes
Definition layer_ids.h:99
@ Edge_Cuts
Definition layer_ids.h:108
@ Dwgs_User
Definition layer_ids.h:103
@ F_Paste
Definition layer_ids.h:100
@ F_Adhes
Definition layer_ids.h:98
@ B_Mask
Definition layer_ids.h:94
@ B_Cu
Definition layer_ids.h:61
@ Eco1_User
Definition layer_ids.h:105
@ F_Mask
Definition layer_ids.h:93
@ B_Paste
Definition layer_ids.h:101
@ F_SilkS
Definition layer_ids.h:96
@ UNDEFINED_LAYER
Definition layer_ids.h:57
@ Eco2_User
Definition layer_ids.h:106
@ B_SilkS
Definition layer_ids.h:97
@ PCB_LAYER_ID_COUNT
Definition layer_ids.h:167
@ F_Cu
Definition layer_ids.h:60
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition lset.cpp:750
This file contains miscellaneous commonly used macros and functions.
constexpr void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition mirror.h:44
FLIP_DIRECTION
Definition mirror.h:26
@ LEFT_RIGHT
Flip left to right (around the Y axis)
Definition mirror.h:27
@ TOP_BOTTOM
Flip top to bottom (around the X axis)
Definition mirror.h:28
Message panel definition file.
constexpr int Mils2IU(const EDA_IU_SCALE &aIuScale, int mils)
Definition eda_units.h:169
bool ShapeHitTest(const SHAPE_LINE_CHAIN &aHitter, const SHAPE &aHittee, bool aHitteeContained)
Perform a shape-to-shape hit test.
bool PadHasMeaningfulRoundingRadius(const PAD &aPad, PCB_LAYER_ID aLayer)
Returns true if the pad's rounding ratio is valid (i.e.
Definition pad_utils.cpp:51
void RemoveAllDrillsFromPadstack(PADSTACK &aPadstack)
Remove the primary drill, the secondary and tertiary drills, and any post-machining operations from a...
Definition pad_utils.cpp:58
double GetDefaultIpcRoundingRatio(const PAD &aPad, PCB_LAYER_ID aLayer)
Get a sensible default for a rounded rectangle pad's rounding ratio.
Definition pad_utils.cpp:37
void PackZoneLayerOverrides(google::protobuf::RepeatedPtrField< types::ZoneLayerOverrideEntry > *aOutput, const std::map< PCB_LAYER_ID, ZONE_LAYER_OVERRIDE > &aInput)
void UnpackTeardropSettings(TEARDROP_PARAMETERS &aOutput, const types::PadTeardropSettings &aProto)
void UnpackZoneLayerOverrides(std::map< PCB_LAYER_ID, ZONE_LAYER_OVERRIDE > &aOutput, const google::protobuf::RepeatedPtrField< types::ZoneLayerOverrideEntry > &aInput)
void PackTeardropSettings(types::PadTeardropSettings &aOutput, const TEARDROP_PARAMETERS &aParams)
KICOMMON_API void PackCustomProperties(google::protobuf::RepeatedPtrField< types::CustomProperty > *aOutput, const EDA_ITEM &aItem)
KICOMMON_API VECTOR2I UnpackVector2(const types::Vector2 &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void PackVector2(types::Vector2 &aOutput, const VECTOR2I &aInput, const EDA_IU_SCALE &aScale)
KICOMMON_API void UnpackCustomProperties(const google::protobuf::RepeatedPtrField< types::CustomProperty > &aInput, EDA_ITEM &aItem)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition eda_angle.h:461
std::optional< std::pair< ELECTRICAL_PINTYPE, bool > > parsePinType(const wxString &aPinTypeString)
Definition pad.cpp:374
static struct PAD_DESC _PAD_DESC
PAD_SIM_ELECTRICAL_TYPE
The electrical type of a pad.
Definition pad.h:53
PAD_DRILL_SHAPE
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition padstack.h:70
PAD_ATTRIB
The set of pad shapes, used with PAD::{Set,Get}Attribute().
Definition padstack.h:98
@ NPTH
like PAD_PTH, but not plated mechanical use only, no connection allowed
Definition padstack.h:104
@ NON_COMPONENT
Pad with no hole that does not connect to a physical component, but rather provides a connection poin...
Definition padstack.h:106
@ SMD
Smd pad, appears on the solder paste layer (default)
Definition padstack.h:100
@ PTH
Plated through hole pad.
Definition padstack.h:99
@ CONN
Like smd, does not appear on the solder paste layer (default) Note: also has a special attribute in G...
Definition padstack.h:101
BACKDRILL_MODE
Definition padstack.h:85
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape()
Definition padstack.h:53
@ CHAMFERED_RECT
Definition padstack.h:61
@ ROUNDRECT
Definition padstack.h:58
@ TRAPEZOID
Definition padstack.h:57
@ RECTANGLE
Definition padstack.h:55
PAD_PROP
The set of pad properties used in Gerber files (Draw files, and P&P files) to define some properties ...
Definition padstack.h:118
@ FIDUCIAL_LOCAL
a fiducial (usually a smd) local to the parent footprint
Definition padstack.h:122
@ FIDUCIAL_GLBL
a fiducial (usually a smd) for the full board
Definition padstack.h:121
@ MECHANICAL
a pad used for mechanical support
Definition padstack.h:126
@ PRESSFIT
a PTH with a hole diameter with tight tolerances for press fit pin
Definition padstack.h:127
@ HEATSINK
a pad used as heat sink, usually in SMD footprints
Definition padstack.h:124
@ NONE
no special fabrication property
Definition padstack.h:119
@ TESTPOINT
a test point pad
Definition padstack.h:123
@ CASTELLATED
a pad with a castellated through hole
Definition padstack.h:125
@ BGA
Smd pad, used in BGA footprints.
Definition padstack.h:120
UNCONNECTED_LAYER_MODE
Definition padstack.h:132
#define _HKI(x)
Definition page_info.cpp:40
Class to handle a set of BOARD_ITEMs.
PCBNEW_SETTINGS * pcbconfig()
ELECTRICAL_PINTYPE
The symbol library pin object electrical types used in ERC tests.
Definition pin_type.h:32
@ PT_INPUT
usual pin input: must be connected
Definition pin_type.h:33
@ PT_NC
not connected (must be left open)
Definition pin_type.h:46
@ PT_OUTPUT
usual output
Definition pin_type.h:34
@ PT_TRISTATE
tri state bus pin
Definition pin_type.h:36
@ PT_NIC
not internally connected (may be connected to anything)
Definition pin_type.h:40
@ PT_BIDI
input or output (like port for a microprocessor)
Definition pin_type.h:35
@ PT_OPENEMITTER
pin type open emitter
Definition pin_type.h:45
@ PT_POWER_OUT
output of a regulator: intended to be connected to power input pins
Definition pin_type.h:43
@ PT_OPENCOLLECTOR
pin type open collector
Definition pin_type.h:44
@ PT_POWER_IN
power input (GND, VCC for ICs). Must be connected to a power output.
Definition pin_type.h:42
@ PT_UNSPECIFIED
unknown electrical properties: creates always a warning when connected
Definition pin_type.h:41
@ PT_PASSIVE
pin for passive symbols: must be connected, and can be connected to any pin.
Definition pin_type.h:39
wxString GetCanonicalElectricalTypeName(ELECTRICAL_PINTYPE aType)
Definition pin_type.h:54
#define ELECTRICAL_PINTYPES_TOTAL
Definition pin_type.h:52
#define TYPE_HASH(x)
Macro to generate unique identifier for a type.
Definition property.h:74
#define ENUM_TO_WXANY(type)
Definition property.h:918
@ PT_DEGREE
Angle expressed in degrees.
Definition property.h:66
@ PT_RATIO
Definition property.h:68
@ PT_DECIDEGREE
Angle expressed in decidegrees.
Definition property.h:67
@ PT_SIZE
Size expressed in distance units (mm/inch)
Definition property.h:63
@ PT_TIME
Time expressed in ps.
Definition property.h:69
#define REGISTER_TYPE(x)
Helper macro to map type hashes to names.
wxString UnescapeString(const wxString &aSource)
LAYER_POLYGON_MAP m_effectivePolygons
Definition pad.h:1130
LAYER_SHAPE_MAP m_effectiveShapes
Definition pad.h:1128
std::shared_ptr< SHAPE_SEGMENT > m_effectiveHoleShape
Definition pad.h:1129
BOX2I m_effectiveBoundingBox
Definition pad.h:1127
PAD_DESC()
Definition pad.cpp:3525
int radius
int clearance
int delta
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
Definition trigo.cpp:227
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:89
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition typeinfo.h:79
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition typeinfo.h:90
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition typeinfo.h:88
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< int64_t > VECTOR2L
Definition vector2d.h:709
static PIECE rect(double aLeft, double aTop, double aRight, double aBottom, bool aMixed=false)
ZONE_CONNECTION
How pads are covered by copper in zone.
Definition zones.h:43
@ THERMAL
Use thermal relief for pads.
Definition zones.h:46
@ THT_THERMAL
Thermal relief only for THT pads.
Definition zones.h:48
@ NONE
Pads are not covered.
Definition zones.h:45
@ FULL
pads are covered by copper
Definition zones.h:47
#define ZONE_THICKNESS_MIN_VALUE_MM
Definition zones.h:31