KiCad PCB EDA Suite
Loading...
Searching...
No Matches
padstack.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) 2024 Jon Evans <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <utility> // std::as_const
22
23#include <convert_basic_shapes_to_polygon.h> // RECT_CHAMFER_POSITIONS
24#include "padstack.h"
25#include <api/api_enums.h>
26#include <api/api_utils.h>
27#include <api/api_pcb_utils.h>
28#include <api/board/board_types.pb.h>
29#include <layer_range.h>
30#include <macros.h>
31#include <magic_enum.hpp>
32#include <pad.h>
33#include <board.h>
34#include <pcb_shape.h>
35#include <properties/property.h>
37
38
42
43
69
70
72{
73 m_parent = aOther.m_parent;
74 *this = aOther;
75
77 [&]( PCB_LAYER_ID aLayer )
78 {
79 for( std::shared_ptr<PCB_SHAPE>& shape : CopperLayer( aLayer ).custom_shapes )
80 shape->SetParent( m_parent );
81 } );
82}
83
84
86{
87 // NOTE: m_parent is not copied from operator=, because this operator is commonly used to
88 // update the padstack properties, and such an update must not change the parent PAD to point to
89 // the parent of some different padstack.
90
91 m_mode = aOther.m_mode;
92 m_layerSet = aOther.m_layerSet;
93 SetCustomName( aOther.CustomName() );
100 m_drill = aOther.m_drill;
105
106 // Data consistency enforcement logic that used to live in the pad properties dialog.
107 // While it might be tempting to put these in the individual property setters, there's no
108 // well-defined order in which they're called, and many of the consistency checks are
109 // between multiple properties.
110
112 [&]( PCB_LAYER_ID aLayer )
113 {
114 PAD_SHAPE shape = Shape( aLayer );
115
116 // Make sure leftover primitives don't stick around
117 ClearPrimitives( aLayer );
118
119 // For custom pad shape, duplicate primitives of the pad to copy
120 if( shape == PAD_SHAPE::CUSTOM )
121 ReplacePrimitives( aOther.Primitives( aLayer ), aLayer );
122
123 // rounded rect pads with radius ratio = 0 are in fact rect pads.
124 // So set the right shape (and perhaps issues with a radius = 0)
125 if( shape == PAD_SHAPE::ROUNDRECT && RoundRectRadiusRatio( aLayer ) == 0.0 )
127 } );
128
129 return *this;
130}
131
132
133bool PADSTACK::operator==( const PADSTACK& aOther ) const
134{
135 if( m_mode != aOther.m_mode )
136 return false;
137
138 if( m_layerSet != aOther.m_layerSet )
139 return false;
140
141 if( CustomName() != aOther.CustomName() )
142 return false;
143
144 if( m_orientation != aOther.m_orientation )
145 return false;
146
147 if( m_frontMaskProps != aOther.m_frontMaskProps )
148 return false;
149
150 if( m_backMaskProps != aOther.m_backMaskProps )
151 return false;
152
154 return false;
155
157 return false;
158
159 if( m_drill != aOther.m_drill )
160 return false;
161
162 if( m_secondaryDrill != aOther.m_secondaryDrill )
163 return false;
164
165 if( m_tertiaryDrill != aOther.m_tertiaryDrill )
166 return false;
167
169 return false;
170
172 return false;
173
174 bool copperMatches = true;
175
177 [&]( PCB_LAYER_ID aLayer )
178 {
179 if( CopperLayer( aLayer ) != aOther.CopperLayer( aLayer ) )
180 copperMatches = false;
181 } );
182
183 return copperMatches;
184}
185
186
187bool PADSTACK::unpackCopperLayer( const kiapi::board::types::PadStackLayer& aProto )
188{
189 using namespace kiapi::board::types;
191
192 if( m_mode == MODE::NORMAL && layer != ALL_LAYERS )
193 return false;
194
195 if( m_mode == MODE::FRONT_INNER_BACK && layer != F_Cu && layer != INNER_LAYERS && layer != B_Cu )
196 return false;
197
198 SetSize( kiapi::common::UnpackVector2( aProto.size() ), layer );
199 SetShape( FromProtoEnum<PAD_SHAPE>( aProto.shape() ), layer );
200 Offset( layer ) = kiapi::common::UnpackVector2( aProto.offset() );
201 SetAnchorShape( FromProtoEnum<PAD_SHAPE>( aProto.custom_anchor_shape() ), layer );
202
203 SHAPE_PROPS& props = CopperLayer( layer ).shape;
204 props.chamfered_rect_ratio = aProto.chamfer_ratio();
205 props.round_rect_radius_ratio = aProto.corner_rounding_ratio();
206
207 if( Shape( layer ) == PAD_SHAPE::TRAPEZOID && aProto.has_trapezoid_delta() )
208 TrapezoidDeltaSize( layer ) = kiapi::common::UnpackVector2( aProto.trapezoid_delta() );
209
210 if( aProto.chamfered_corners().top_left() )
212
213 if( aProto.chamfered_corners().top_right() )
215
216 if( aProto.chamfered_corners().bottom_left() )
218
219 if( aProto.chamfered_corners().bottom_right() )
221
222 ClearPrimitives( layer );
223 google::protobuf::Any a;
224
225 for( const BoardGraphicShape& shapeProto : aProto.custom_shapes() )
226 {
227 a.PackFrom( shapeProto );
228 std::unique_ptr<PCB_SHAPE> shape = std::make_unique<PCB_SHAPE>( m_parent );
229
230 if( shape->Deserialize( a ) )
231 AddPrimitive( shape.release(), layer );
232 }
233
234 return true;
235}
236
237
238bool PADSTACK::Deserialize( const kiapi::board::types::PadStack& padstack )
239{
240 using namespace kiapi::board::types;
241
242 auto unpackOptional = []<typename ProtoEnum>( const ProtoEnum& aProto,
243 std::optional<bool>& aDest, ProtoEnum aTrueValue,
244 ProtoEnum aFalseValue )
245 {
246 if( aProto == aTrueValue )
247 aDest = true;
248 else if( aProto == aFalseValue )
249 aDest = false;
250 else
251 aDest = std::nullopt;
252 };
253
254 auto unpackPostMachining = []( const PostMachiningProperties& aProto,
256 {
257 switch( aProto.mode() )
258 {
259 case VDPM_NOT_POST_MACHINED: aDest.mode = PAD_DRILL_POST_MACHINING_MODE::NOT_POST_MACHINED; break;
260 case VDPM_COUNTERBORE: aDest.mode = PAD_DRILL_POST_MACHINING_MODE::COUNTERBORE; break;
261 case VDPM_COUNTERSINK: aDest.mode = PAD_DRILL_POST_MACHINING_MODE::COUNTERSINK; break;
262 default: aDest.mode = std::nullopt; break;
263 }
264
265 aDest.size = aProto.size();
266 aDest.depth = aProto.depth();
267 aDest.angle = aProto.angle();
268 };
269
270
271 m_mode = FromProtoEnum<MODE>( padstack.type() );
272 SetLayerSet( kiapi::board::UnpackLayerSet( padstack.layers() ) );
273 m_orientation = EDA_ANGLE( padstack.angle().value_degrees(), DEGREES_T );
274
275 Drill().size = kiapi::common::UnpackVector2( padstack.drill().diameter() );
276 Drill().start = FromProtoEnum<PCB_LAYER_ID>( padstack.drill().start_layer() );
277 Drill().end = FromProtoEnum<PCB_LAYER_ID>( padstack.drill().end_layer() );
278 unpackOptional( padstack.drill().capped(), Drill().is_capped, VDCM_CAPPED, VDCM_UNCAPPED );
279 unpackOptional( padstack.drill().filled(), Drill().is_filled, VDFM_FILLED, VDFM_UNFILLED );
280
281 if( padstack.has_front_post_machining() )
282 unpackPostMachining( padstack.front_post_machining(), FrontPostMachining() );
283
284 if( padstack.has_back_post_machining() )
285 unpackPostMachining( padstack.back_post_machining(), BackPostMachining() );
286
287 Drill().shape = FromProtoEnum<PAD_DRILL_SHAPE>( padstack.drill().shape() );
288
289 if( padstack.has_secondary_drill() )
290 {
291 const DrillProperties& secondary = padstack.secondary_drill();
292
293 SecondaryDrill().size = kiapi::common::UnpackVector2( secondary.diameter() );
294 SecondaryDrill().start = FromProtoEnum<PCB_LAYER_ID>( secondary.start_layer() );
295 SecondaryDrill().end = FromProtoEnum<PCB_LAYER_ID>( secondary.end_layer() );
296 SecondaryDrill().shape = FromProtoEnum<PAD_DRILL_SHAPE>( secondary.shape() );
297
298 unpackOptional( secondary.capped(), SecondaryDrill().is_capped, VDCM_CAPPED, VDCM_UNCAPPED );
299 unpackOptional( secondary.filled(), SecondaryDrill().is_filled, VDFM_FILLED, VDFM_UNFILLED );
300 }
301 else
302 {
303 SecondaryDrill().size = { 0, 0 };
307 SecondaryDrill().is_capped = std::nullopt;
308 SecondaryDrill().is_filled = std::nullopt;
309 }
310
311 if( padstack.has_tertiary_drill() )
312 {
313 const DrillProperties& tertiary = padstack.tertiary_drill();
314
315 TertiaryDrill().size = kiapi::common::UnpackVector2( tertiary.diameter() );
316 TertiaryDrill().start = FromProtoEnum<PCB_LAYER_ID>( tertiary.start_layer() );
317 TertiaryDrill().end = FromProtoEnum<PCB_LAYER_ID>( tertiary.end_layer() );
318 TertiaryDrill().shape = FromProtoEnum<PAD_DRILL_SHAPE>( tertiary.shape() );
319
320 unpackOptional( tertiary.capped(), TertiaryDrill().is_capped, VDCM_CAPPED, VDCM_UNCAPPED );
321 unpackOptional( tertiary.filled(), TertiaryDrill().is_filled, VDFM_FILLED, VDFM_UNFILLED );
322 }
323 else
324 {
325 TertiaryDrill().size = { 0, 0 };
329 TertiaryDrill().is_capped = std::nullopt;
330 TertiaryDrill().is_filled = std::nullopt;
331 }
332
333 for( const PadStackLayer& layer : padstack.copper_layers() )
334 {
335 if( !unpackCopperLayer( layer ) )
336 return false;
337 }
338
339 CopperLayer( ALL_LAYERS ).thermal_gap = std::nullopt;
341
342 if( padstack.has_zone_settings() )
343 {
345 FromProtoEnum<ZONE_CONNECTION>( padstack.zone_settings().zone_connection() );
346
347 if( padstack.zone_settings().has_thermal_spokes() )
348 {
349 const ThermalSpokeSettings& thermals = padstack.zone_settings().thermal_spokes();
350
351 if( thermals.has_gap() )
352 CopperLayer( ALL_LAYERS ).thermal_gap = thermals.gap().value_nm();
353
354 if( thermals.has_width() )
355 CopperLayer( ALL_LAYERS ).thermal_spoke_width = thermals.width().value_nm();
356
357 SetThermalSpokeAngle( EDA_ANGLE( thermals.angle().value_degrees(), DEGREES_T ), F_Cu );
358 }
359 }
360 else
361 {
364 }
365
367 FromProtoEnum<UNCONNECTED_LAYER_MODE>( padstack.unconnected_layer_removal() ) );
368
369 unpackOptional( padstack.front_outer_layers().solder_mask_mode(),
370 FrontOuterLayers().has_solder_mask, SMM_MASKED, SMM_UNMASKED );
371
372 unpackOptional( padstack.back_outer_layers().solder_mask_mode(),
373 BackOuterLayers().has_solder_mask, SMM_MASKED, SMM_UNMASKED );
374
375 unpackOptional( padstack.front_outer_layers().covering_mode(), FrontOuterLayers().has_covering,
376 VCM_COVERED, VCM_UNCOVERED );
377
378 unpackOptional( padstack.back_outer_layers().covering_mode(), BackOuterLayers().has_covering,
379 VCM_COVERED, VCM_UNCOVERED );
380
381 unpackOptional( padstack.front_outer_layers().plugging_mode(), FrontOuterLayers().has_plugging,
382 VPM_PLUGGED, VPM_UNPLUGGED );
383
384 unpackOptional( padstack.back_outer_layers().plugging_mode(), BackOuterLayers().has_plugging,
385 VPM_PLUGGED, VPM_UNPLUGGED );
386
387 unpackOptional( padstack.front_outer_layers().solder_paste_mode(),
388 FrontOuterLayers().has_solder_paste, SPM_PASTE, SPM_NO_PASTE );
389
390 unpackOptional( padstack.back_outer_layers().solder_paste_mode(),
391 BackOuterLayers().has_solder_paste, SPM_PASTE, SPM_NO_PASTE );
392
393 if( padstack.front_outer_layers().has_solder_mask_settings()
394 && padstack.front_outer_layers().solder_mask_settings().has_solder_mask_margin() )
395 {
397 padstack.front_outer_layers().solder_mask_settings().solder_mask_margin().value_nm();
398 }
399 else
400 {
401 FrontOuterLayers().solder_mask_margin = std::nullopt;
402 }
403
404 if( padstack.back_outer_layers().has_solder_mask_settings()
405 && padstack.back_outer_layers().solder_mask_settings().has_solder_mask_margin() )
406 {
408 padstack.back_outer_layers().solder_mask_settings().solder_mask_margin().value_nm();
409 }
410 else
411 {
412 BackOuterLayers().solder_mask_margin = std::nullopt;
413 }
414
415 if( padstack.front_outer_layers().has_solder_paste_settings()
416 && padstack.front_outer_layers().solder_paste_settings().has_solder_paste_margin() )
417 {
419 padstack.front_outer_layers().solder_paste_settings().solder_paste_margin().value_nm();
420 }
421 else
422 {
423 FrontOuterLayers().solder_paste_margin = std::nullopt;
424 }
425
426 if( padstack.back_outer_layers().has_solder_paste_settings()
427 && padstack.back_outer_layers().solder_paste_settings().has_solder_paste_margin() )
428 {
430 padstack.back_outer_layers().solder_paste_settings().solder_paste_margin().value_nm();
431 }
432 else
433 {
434 BackOuterLayers().solder_paste_margin = std::nullopt;
435 }
436
437 if( padstack.front_outer_layers().has_solder_paste_settings()
438 && padstack.front_outer_layers().solder_paste_settings().has_solder_paste_margin_ratio() )
439 {
441 padstack.front_outer_layers().solder_paste_settings().solder_paste_margin_ratio().value();
442 }
443 else
444 {
446 }
447
448 if( padstack.back_outer_layers().has_solder_paste_settings()
449 && padstack.back_outer_layers().solder_paste_settings().has_solder_paste_margin_ratio() )
450 {
452 padstack.back_outer_layers().solder_paste_settings().solder_paste_margin_ratio().value();
453 }
454 else
455 {
457 }
458
459
460 return true;
461}
462
463
464bool PADSTACK::Deserialize( const google::protobuf::Any& aContainer )
465{
466 kiapi::board::types::PadStack padstack;
467
468 if( !aContainer.UnpackTo( &padstack ) )
469 return false;
470
471 return Deserialize( padstack );
472}
473
474
475// A backdrill's side is identified by its start layer (F_Cu = top, B_Cu = bottom), not by which
476// drill slot it occupies. Reads scan both slots so a board written by KiCad 10.0 - which stored the
477// top backdrill in the tertiary slot - is understood, and writes always stamp the start layer so a
478// backdrill saved here is read back correctly by older KiCad. Presence is keyed on the drill size.
480{
481 PCB_LAYER_ID side = aTop ? F_Cu : B_Cu;
482
483 if( m_secondaryDrill.size.x > 0 && m_secondaryDrill.start == side )
484 return &m_secondaryDrill;
485
486 if( m_tertiaryDrill.size.x > 0 && m_tertiaryDrill.start == side )
487 return &m_tertiaryDrill;
488
489 return nullptr;
490}
491
492
494{
495 return const_cast<DRILL_PROPS*>( std::as_const( *this ).findBackdrillDrill( aTop ) );
496}
497
498
500{
501 if( DRILL_PROPS* existing = findBackdrillDrill( aTop ) )
502 return *existing;
503
506 PCB_LAYER_ID otherSide = aTop ? B_Cu : F_Cu;
507
508 // Displace to the other slot only when the canonical home is already taken by the opposite
509 // side, which happens when extending a backdrill on a board written by KiCad 10.0.
510 if( home.size.x > 0 && home.start == otherSide )
511 return other;
512
513 return home;
514}
515
516
518{
519 PCB_LAYER_ID side = aTop ? F_Cu : B_Cu;
520
521 if( m_secondaryDrill.start == side )
522 m_secondaryDrill.size = { 0, 0 };
523
524 if( m_tertiaryDrill.start == side )
525 m_tertiaryDrill.size = { 0, 0 };
526}
527
528
530{
531 bool hasTop = findBackdrillDrill( true ) != nullptr;
532 bool hasBottom = findBackdrillDrill( false ) != nullptr;
533
534 if( hasTop && hasBottom )
536
537 if( hasTop )
539
540 if( hasBottom )
542
544}
545
546
548{
549 auto apply = [this]( bool aTop, bool aWant )
550 {
551 if( aWant )
552 {
553 DRILL_PROPS& drill = backdrillWriteSlot( aTop );
554 drill.start = aTop ? F_Cu : B_Cu;
556
557 if( drill.size.x <= 0 )
558 drill.size = m_drill.size * 1.1; // Backdrill slightly larger than main drill
559 }
560 else
561 {
562 clearBackdrillSide( aTop );
563 }
564 };
565
566 apply( true, aMode == BACKDRILL_MODE::BACKDRILL_TOP || aMode == BACKDRILL_MODE::BACKDRILL_BOTH );
567 apply( false, aMode == BACKDRILL_MODE::BACKDRILL_BOTTOM || aMode == BACKDRILL_MODE::BACKDRILL_BOTH );
568}
569
570
571std::optional<int> PADSTACK::GetBackdrillSize( bool aTop ) const
572{
573 if( const DRILL_PROPS* drill = findBackdrillDrill( aTop ) )
574 return drill->size.x;
575
576 return std::nullopt;
577}
578
579
580void PADSTACK::SetBackdrillSize( bool aTop, std::optional<int> aSize )
581{
582 if( aSize.has_value() )
583 {
584 DRILL_PROPS& target = backdrillWriteSlot( aTop );
585 target.size = { *aSize, *aSize };
587 target.start = aTop ? F_Cu : B_Cu;
588 }
589 else
590 {
591 clearBackdrillSide( aTop );
592 }
593}
594
595
597{
598 if( const DRILL_PROPS* drill = findBackdrillDrill( aTop ) )
599 return drill->end;
600
601 return UNDEFINED_LAYER;
602}
603
604
606{
607 // A backdrill with no must-cut layer does not exist (matching the via layer sanitizer), so
608 // clearing the must-cut clears the side rather than leaving a sizeful drill with no end.
609 if( aLayer == UNDEFINED_LAYER )
610 {
611 clearBackdrillSide( aTop );
612 return;
613 }
614
615 DRILL_PROPS& target = backdrillWriteSlot( aTop );
616
617 target.end = aLayer;
618 target.start = aTop ? F_Cu : B_Cu;
619}
620
621void PADSTACK::Serialize( kiapi::board::types::PadStack& padstack ) const
622{
623 using namespace kiapi::board::types;
624
625 padstack.set_type( ToProtoEnum<MODE, PadStackType>( m_mode ) );
626 kiapi::board::PackLayerSet( *padstack.mutable_layers(), m_layerSet );
627 padstack.mutable_angle()->set_value_degrees( m_orientation.AsDegrees() );
628
629 kiapi::common::PackVector2( *padstack.mutable_drill()->mutable_diameter(), m_drill.size );
630 padstack.mutable_drill()->set_start_layer( ToProtoEnum<PCB_LAYER_ID, BoardLayer>( m_drill.start ) );
631 padstack.mutable_drill()->set_end_layer( ToProtoEnum<PCB_LAYER_ID, BoardLayer>( m_drill.end ) );
632 padstack.mutable_drill()->set_shape( ToProtoEnum<PAD_DRILL_SHAPE, kiapi::board::types::DrillShape>( m_drill.shape ) );
633
634 if( m_drill.is_capped.has_value() )
635 padstack.mutable_drill()->set_capped( m_drill.is_capped.value() ? VDCM_CAPPED : VDCM_UNCAPPED );
636
637 if( m_drill.is_filled.has_value() )
638 padstack.mutable_drill()->set_filled( m_drill.is_filled.value() ? VDFM_FILLED : VDFM_UNFILLED );
639
640 if( m_secondaryDrill.size.x > 0 )
641 {
642 DrillProperties* secondary = padstack.mutable_secondary_drill();
643 kiapi::common::PackVector2( *secondary->mutable_diameter(), m_secondaryDrill.size );
644 secondary->set_start_layer( ToProtoEnum<PCB_LAYER_ID, BoardLayer>( m_secondaryDrill.start ) );
645 secondary->set_end_layer( ToProtoEnum<PCB_LAYER_ID, BoardLayer>( m_secondaryDrill.end ) );
647
648 if( m_secondaryDrill.is_capped.has_value() )
649 secondary->set_capped( m_secondaryDrill.is_capped.value() ? VDCM_CAPPED : VDCM_UNCAPPED );
650
651 if( m_secondaryDrill.is_filled.has_value() )
652 secondary->set_filled( m_secondaryDrill.is_filled.value() ? VDFM_FILLED : VDFM_UNFILLED );
653 }
654
655 if( m_tertiaryDrill.size.x > 0 )
656 {
657 DrillProperties* tertiary = padstack.mutable_tertiary_drill();
658 kiapi::common::PackVector2( *tertiary->mutable_diameter(), m_tertiaryDrill.size );
659 tertiary->set_start_layer( ToProtoEnum<PCB_LAYER_ID, BoardLayer>( m_tertiaryDrill.start ) );
660 tertiary->set_end_layer( ToProtoEnum<PCB_LAYER_ID, BoardLayer>( m_tertiaryDrill.end ) );
662
663 if( m_tertiaryDrill.is_capped.has_value() )
664 tertiary->set_capped( m_tertiaryDrill.is_capped.value() ? VDCM_CAPPED : VDCM_UNCAPPED );
665
666 if( m_tertiaryDrill.is_filled.has_value() )
667 tertiary->set_filled( m_tertiaryDrill.is_filled.value() ? VDFM_FILLED : VDFM_UNFILLED );
668 }
669
670 auto packPostMachining = []( const PADSTACK::POST_MACHINING_PROPS& aProps,
671 PostMachiningProperties* aProto )
672 {
673 if( aProps.mode.has_value() )
674 {
675 switch( aProps.mode.value() )
676 {
677 case PAD_DRILL_POST_MACHINING_MODE::NOT_POST_MACHINED: aProto->set_mode( VDPM_NOT_POST_MACHINED ); break;
678 case PAD_DRILL_POST_MACHINING_MODE::COUNTERBORE: aProto->set_mode( VDPM_COUNTERBORE ); break;
679 case PAD_DRILL_POST_MACHINING_MODE::COUNTERSINK: aProto->set_mode( VDPM_COUNTERSINK ); break;
680 default: break;
681 }
682 }
683
684 aProto->set_size( aProps.size );
685 aProto->set_depth( aProps.depth );
686 aProto->set_angle( aProps.angle );
687 };
688
689 if( m_frontPostMachining.mode.has_value() || m_frontPostMachining.size > 0 )
690 packPostMachining( m_frontPostMachining, padstack.mutable_front_post_machining() );
691
692 if( m_backPostMachining.mode.has_value() || m_backPostMachining.size > 0 )
693 packPostMachining( m_backPostMachining, padstack.mutable_back_post_machining() );
694
696 [&]( PCB_LAYER_ID aLayer )
697 {
698 PadStackLayer* layer = padstack.add_copper_layers();
699 const COPPER_LAYER_PROPS& props = CopperLayer( aLayer );
700
701 layer->set_layer( ToProtoEnum<PCB_LAYER_ID, BoardLayer>( aLayer ) );
702 kiapi::common::PackVector2( *layer->mutable_size(), props.shape.size );
704 kiapi::common::PackVector2( *layer->mutable_offset(), props.shape.offset );
705 layer->set_custom_anchor_shape( ToProtoEnum<PAD_SHAPE, kiapi::board::types::PadStackShape>( props.shape.anchor_shape ) );
706 layer->set_chamfer_ratio( props.shape.chamfered_rect_ratio );
707 layer->set_corner_rounding_ratio( props.shape.round_rect_radius_ratio );
708
709 if( props.shape.shape == PAD_SHAPE::TRAPEZOID )
710 kiapi::common::PackVector2( *layer->mutable_trapezoid_delta(), props.shape.trapezoid_delta_size );
711
713 layer->mutable_chamfered_corners()->set_top_left( true );
714
716 layer->mutable_chamfered_corners()->set_top_right( true );
717
719 layer->mutable_chamfered_corners()->set_bottom_left( true );
720
722 layer->mutable_chamfered_corners()->set_bottom_right( true );
723
724 for( const std::shared_ptr<PCB_SHAPE>& shape : props.custom_shapes )
725 {
726 google::protobuf::Any a;
727 shape->Serialize( a );
728 a.UnpackTo( layer->add_custom_shapes() );
729 }
730 } );
731
732 if( CopperLayer( ALL_LAYERS ).zone_connection.has_value() )
733 {
734 padstack.mutable_zone_settings()->set_zone_connection(
736 }
737
738 if( CopperLayer( ALL_LAYERS ).thermal_gap.has_value() )
739 {
740 padstack.mutable_zone_settings()->mutable_thermal_spokes()->mutable_gap()->set_value_nm(
741 CopperLayer( ALL_LAYERS ).thermal_gap.value() );
742 }
743
744 if( CopperLayer( ALL_LAYERS ).thermal_spoke_width.has_value() )
745 {
746 padstack.mutable_zone_settings()->mutable_thermal_spokes()->mutable_width()->set_value_nm(
747 CopperLayer( ALL_LAYERS ).thermal_spoke_width.value() );
748 }
749
750 if( CopperLayer( ALL_LAYERS ).thermal_spoke_angle.has_value() )
751 {
752 padstack.mutable_zone_settings()->mutable_thermal_spokes()->mutable_angle()->set_value_degrees(
753 CopperLayer( ALL_LAYERS ).thermal_spoke_angle.value().AsDegrees() );
754 }
755
756 padstack.set_unconnected_layer_removal( ToProtoEnum<UNCONNECTED_LAYER_MODE,
757 kiapi::board::types::UnconnectedLayerRemoval>( m_unconnectedLayerMode ) );
758
759 if( FrontOuterLayers().has_solder_mask.has_value() )
760 {
761 padstack.mutable_front_outer_layers()->set_solder_mask_mode(
762 FrontOuterLayers().has_solder_mask.value() ? SMM_MASKED : SMM_UNMASKED );
763 }
764
765 if( BackOuterLayers().has_solder_mask.has_value() )
766 {
767 padstack.mutable_back_outer_layers()->set_solder_mask_mode(
768 BackOuterLayers().has_solder_mask.value() ? SMM_MASKED : SMM_UNMASKED );
769 }
770
771 if( FrontOuterLayers().has_covering.has_value() )
772 {
773 padstack.mutable_front_outer_layers()->set_covering_mode(
774 FrontOuterLayers().has_covering.value() ? VCM_COVERED : VCM_UNCOVERED );
775 }
776
777 if( BackOuterLayers().has_covering.has_value() )
778 {
779 padstack.mutable_back_outer_layers()->set_covering_mode(
780 BackOuterLayers().has_covering.value() ? VCM_COVERED : VCM_UNCOVERED );
781 }
782
783 if( FrontOuterLayers().has_plugging.has_value() )
784 {
785 padstack.mutable_front_outer_layers()->set_plugging_mode(
786 FrontOuterLayers().has_plugging.value() ? VPM_PLUGGED : VPM_UNPLUGGED );
787 }
788
789 if( BackOuterLayers().has_plugging.has_value() )
790 {
791 padstack.mutable_back_outer_layers()->set_plugging_mode(
792 BackOuterLayers().has_plugging.value() ? VPM_PLUGGED : VPM_UNPLUGGED );
793 }
794
795 if( FrontOuterLayers().has_solder_paste.has_value() )
796 {
797 padstack.mutable_front_outer_layers()->set_solder_paste_mode(
798 FrontOuterLayers().has_solder_paste.value() ? SPM_PASTE : SPM_NO_PASTE );
799 }
800
801 if( BackOuterLayers().has_solder_paste.has_value() )
802 {
803 padstack.mutable_back_outer_layers()->set_solder_paste_mode(
804 BackOuterLayers().has_solder_paste.value() ? SPM_PASTE : SPM_NO_PASTE );
805 }
806
807 if( FrontOuterLayers().solder_mask_margin.has_value() )
808 {
809 padstack.mutable_front_outer_layers()->mutable_solder_mask_settings()->mutable_solder_mask_margin()->set_value_nm(
810 FrontOuterLayers().solder_mask_margin.value() );
811 }
812
813 if( BackOuterLayers().solder_mask_margin.has_value() )
814 {
815 padstack.mutable_back_outer_layers()->mutable_solder_mask_settings()->mutable_solder_mask_margin()->set_value_nm(
816 BackOuterLayers().solder_mask_margin.value() );
817 }
818
819 if( FrontOuterLayers().solder_paste_margin.has_value() )
820 {
821 padstack.mutable_front_outer_layers()->mutable_solder_paste_settings()->mutable_solder_paste_margin()->set_value_nm(
822 FrontOuterLayers().solder_paste_margin.value() );
823 }
824
825 if( BackOuterLayers().solder_paste_margin.has_value() )
826 {
827 padstack.mutable_back_outer_layers()->mutable_solder_paste_settings()->mutable_solder_paste_margin()->set_value_nm(
828 BackOuterLayers().solder_paste_margin.value() );
829 }
830
831 if( FrontOuterLayers().solder_paste_margin_ratio.has_value() )
832 {
833 padstack.mutable_front_outer_layers()->mutable_solder_paste_settings()->mutable_solder_paste_margin_ratio()->set_value(
834 FrontOuterLayers().solder_paste_margin_ratio.value() );
835 }
836
837 if( BackOuterLayers().solder_paste_margin_ratio.has_value() )
838 {
839 padstack.mutable_back_outer_layers()->mutable_solder_paste_settings()->mutable_solder_paste_margin_ratio()->set_value(
840 BackOuterLayers().solder_paste_margin_ratio.value() );
841 }
842
843}
844
845
846void PADSTACK::Serialize( google::protobuf::Any& aContainer ) const
847{
848 kiapi::board::types::PadStack padstack;
849 Serialize( padstack );
850 aContainer.PackFrom( padstack );
851}
852
853
854void PADSTACK::SetSize( const VECTOR2I& aSize, PCB_LAYER_ID aLayer )
855{
856 VECTOR2I size = aSize;
857
858 if( size.x < 0 )
859 size.x = 0;
860
861 if( size.y < 0 )
862 size.y = 0;
863
864 CopperLayer( aLayer ).shape.size = size;
865}
866
867
869{
870 return CopperLayer( aLayer ).shape.size;
871}
872
873
875{
876 return CopperLayer( aLayer ).shape.shape;
877}
878
879
881{
882 CopperLayer( aLayer ).shape.shape = aShape;
883}
884
885
887{
888 return m_drill.shape;
889}
890
891
893{
894 m_drill.shape = aShape;
895}
896
897
899{
900 return CopperLayer( aLayer ).shape.offset;
901}
902
903
905{
906 return CopperLayer( aLayer ).shape.offset;
907}
908
909
910void PADSTACK::SetOffset( const VECTOR2I& aOffset, PCB_LAYER_ID aLayer )
911{
912 CopperLayer( aLayer ).shape.offset = aOffset;
913}
914
915
917{
918 return CopperLayer( aLayer ).shape.anchor_shape;
919}
920
921
923{
924 CopperLayer( aLayer ).shape.anchor_shape = aShape;
925}
926
927
932
933
935{
936 return CopperLayer( aLayer ).shape.trapezoid_delta_size;
937}
938
939
941{
943}
944
945
947{
948 CopperLayer( aLayer ).shape.round_rect_radius_ratio = aRatio;
949}
950
951
953{
954 const VECTOR2I& size = Size( aLayer );
955 return KiROUND( std::min( size.x, size.y ) * RoundRectRadiusRatio( aLayer ) );
956}
957
958
959void PADSTACK::SetRoundRectRadius( double aRadius, PCB_LAYER_ID aLayer )
960{
961 const VECTOR2I& size = Size( aLayer );
962 int min_r = std::min( size.x, size.y );
963
964 if( min_r > 0 )
965 SetRoundRectRadiusRatio( aRadius / min_r, aLayer );
966}
967
968
970{
971 return CopperLayer( aLayer ).shape.chamfered_rect_ratio;
972}
973
974
975void PADSTACK::SetChamferRatio( double aRatio, PCB_LAYER_ID aLayer )
976{
977 CopperLayer( aLayer ).shape.chamfered_rect_ratio = aRatio;
978}
979
980
985
986
987const int& PADSTACK::ChamferPositions( PCB_LAYER_ID aLayer ) const
988{
990}
991
992
993void PADSTACK::SetChamferPositions( int aPositions, PCB_LAYER_ID aLayer )
994{
995 CopperLayer( aLayer ).shape.chamfered_rect_positions = aPositions;
996}
997
998
999std::optional<int>& PADSTACK::Clearance( PCB_LAYER_ID aLayer )
1000{
1001 return CopperLayer( aLayer ).clearance;
1002}
1003
1004
1005const std::optional<int>& PADSTACK::Clearance( PCB_LAYER_ID aLayer ) const
1006{
1007 return CopperLayer( aLayer ).clearance;
1008}
1009
1010
1011std::optional<int>& PADSTACK::SolderMaskMargin( PCB_LAYER_ID aLayer )
1012{
1013 if( IsFrontLayer( aLayer ) )
1015 else if( IsBackLayer( aLayer ) )
1017 else
1018 return FrontOuterLayers().solder_mask_margin; // Should not happen
1019}
1020
1021
1022const std::optional<int>& PADSTACK::SolderMaskMargin( PCB_LAYER_ID aLayer ) const
1023{
1024 if( IsFrontLayer( aLayer ) )
1026 else if( IsBackLayer( aLayer ) )
1028 else
1029 return FrontOuterLayers().solder_mask_margin; // Should not happen
1030}
1031
1032
1033std::optional<int>& PADSTACK::SolderPasteMargin( PCB_LAYER_ID aLayer )
1034{
1035 if( IsFrontLayer( aLayer ) )
1037 else if( IsBackLayer( aLayer ) )
1039 else
1040 return FrontOuterLayers().solder_paste_margin; // Should not happen
1041}
1042
1043
1044const std::optional<int>& PADSTACK::SolderPasteMargin( PCB_LAYER_ID aLayer ) const
1045{
1046 if( IsFrontLayer( aLayer ) )
1048 else if( IsBackLayer( aLayer ) )
1050 else
1051 return FrontOuterLayers().solder_paste_margin; // Should not happen
1052}
1053
1054
1055std::optional<double>& PADSTACK::SolderPasteMarginRatio( PCB_LAYER_ID aLayer )
1056{
1057 if( IsFrontLayer( aLayer ) )
1059 else if( IsBackLayer( aLayer ) )
1061 else
1062 return FrontOuterLayers().solder_paste_margin_ratio; // Should not happen
1063}
1064
1065
1066const std::optional<double>& PADSTACK::SolderPasteMarginRatio( PCB_LAYER_ID aLayer ) const
1067{
1068 if( IsFrontLayer( aLayer ) )
1070 else if( IsBackLayer( aLayer ) )
1072 else
1073 return FrontOuterLayers().solder_paste_margin_ratio; // Should not happen
1074}
1075
1076
1077std::optional<ZONE_CONNECTION>& PADSTACK::ZoneConnection( PCB_LAYER_ID aLayer )
1078{
1079 return CopperLayer( aLayer ).zone_connection;
1080}
1081
1082
1083const std::optional<ZONE_CONNECTION>& PADSTACK::ZoneConnection( PCB_LAYER_ID aLayer ) const
1084{
1085 return CopperLayer( aLayer ).zone_connection;
1086}
1087
1088
1089std::optional<int>& PADSTACK::ThermalSpokeWidth( PCB_LAYER_ID aLayer )
1090{
1091 return CopperLayer( aLayer ).thermal_spoke_width;
1092}
1093
1094
1095const std::optional<int>& PADSTACK::ThermalSpokeWidth( PCB_LAYER_ID aLayer ) const
1096{
1097 return CopperLayer( aLayer ).thermal_spoke_width;
1098}
1099
1100
1101std::optional<int>& PADSTACK::ThermalGap( PCB_LAYER_ID aLayer )
1102{
1103 return CopperLayer( aLayer ).thermal_gap;
1104}
1105
1106
1107const std::optional<int>& PADSTACK::ThermalGap( PCB_LAYER_ID aLayer ) const
1108{
1109 return CopperLayer( aLayer ).thermal_gap;
1110}
1111
1112
1114{
1115 PAD_SHAPE shape = Shape( aLayer );
1116
1117 if( shape == PAD_SHAPE::CUSTOM )
1118 shape = AnchorShape( aLayer );
1119
1120 return shape == PAD_SHAPE::CIRCLE ? ANGLE_45 : ANGLE_90;
1121}
1122
1123
1125{
1126 if( CopperLayer( aLayer ).thermal_spoke_angle.has_value() )
1127 return CopperLayer( aLayer ).thermal_spoke_angle.value();
1128
1129 return DefaultThermalSpokeAngleForShape( aLayer );
1130}
1131
1132
1134{
1135 CopperLayer( aLayer ).thermal_spoke_angle = aAngle;
1136}
1137
1138
1139std::vector<std::shared_ptr<PCB_SHAPE>>& PADSTACK::Primitives( PCB_LAYER_ID aLayer )
1140{
1141 return CopperLayer( aLayer ).custom_shapes;
1142}
1143
1144
1145const std::vector<std::shared_ptr<PCB_SHAPE>>& PADSTACK::Primitives( PCB_LAYER_ID aLayer ) const
1146{
1147 return CopperLayer( aLayer ).custom_shapes;
1148}
1149
1150
1152{
1153 CopperLayer( aLayer ).custom_shapes.emplace_back( aShape );
1154}
1155
1156
1157void PADSTACK::AppendPrimitives( const std::vector<std::shared_ptr<PCB_SHAPE>>& aList,
1158 PCB_LAYER_ID aLayer )
1159{
1160 std::vector<std::shared_ptr<PCB_SHAPE>>& list = CopperLayer( aLayer ).custom_shapes;
1161
1162 for( const std::shared_ptr<PCB_SHAPE>& item : aList )
1163 {
1164 PCB_SHAPE* new_shape = static_cast<PCB_SHAPE*>( item->Clone() );
1165 new_shape->SetParent( m_parent );
1166 list.emplace_back( new_shape );
1167 }
1168}
1169
1170
1171void PADSTACK::ReplacePrimitives( const std::vector<std::shared_ptr<PCB_SHAPE>>& aList,
1172 PCB_LAYER_ID aLayer )
1173{
1174 ClearPrimitives( aLayer );
1175 AppendPrimitives( aList, aLayer );
1176}
1177
1178
1180{
1181 CopperLayer( aLayer ).custom_shapes.clear();
1182}
1183
1184
1186{
1187 if( m_mode == MODE::NORMAL )
1188 return m_copperProps[ALL_LAYERS];
1189
1191 {
1192 if( IsFrontLayer( aLayer ) )
1193 return m_copperProps[F_Cu];
1194 else if( IsBackLayer( aLayer ) )
1195 return m_copperProps[B_Cu];
1196 else
1198 }
1199
1200 return m_copperProps[aLayer];
1201}
1202
1203
1205{
1207 {
1208 if( IsFrontLayer( aLayer ) && m_copperProps.contains( F_Cu ) )
1209 return m_copperProps.at( F_Cu );
1210 else if( IsBackLayer( aLayer ) && m_copperProps.contains( B_Cu ) )
1211 return m_copperProps.at( B_Cu );
1212 else if( m_copperProps.contains( INNER_LAYERS ) )
1213 return m_copperProps.at( INNER_LAYERS );
1214 }
1215 else if( m_mode == MODE::CUSTOM )
1216 {
1217 if( IsFrontLayer( aLayer ) && m_copperProps.contains( F_Cu ) )
1218 return m_copperProps.at( F_Cu );
1219 else if( IsBackLayer( aLayer ) && m_copperProps.contains( B_Cu ) )
1220 return m_copperProps.at( B_Cu );
1221
1222 if( m_copperProps.count( aLayer ) )
1223 return m_copperProps.at( aLayer );
1224
1225 // For CUSTOM mode, fall back to ALL_LAYERS if available (e.g. for layers not yet
1226 // explicitly defined). If ALL_LAYERS is also absent (e.g. after a FlipLayers()
1227 // that renamed the only entry from F_Cu to B_Cu), return whatever entry is first.
1228 if( m_copperProps.count( ALL_LAYERS ) )
1229 return m_copperProps.at( ALL_LAYERS );
1230
1231 wxASSERT( !m_copperProps.empty() );
1232 return m_copperProps.begin()->second;
1233 }
1234
1235 return m_copperProps.at( ALL_LAYERS );
1236}
1237
1238
1239void PADSTACK::ForEachUniqueLayer( const std::function<void( PCB_LAYER_ID )>& aMethod ) const
1240{
1241 if( m_mode == MODE::NORMAL )
1242 {
1243 aMethod( ALL_LAYERS );
1244 }
1245 else if( m_mode == MODE::FRONT_INNER_BACK )
1246 {
1247 aMethod( F_Cu );
1248 aMethod( INNER_LAYERS );
1249 aMethod( B_Cu );
1250 }
1251 else
1252 {
1253 for( const auto& [layer, props] : m_copperProps )
1254 aMethod( layer );
1255 }
1256}
1257
1258
1259std::vector<PCB_LAYER_ID> PADSTACK::UniqueLayers() const
1260{
1261 std::vector<PCB_LAYER_ID> layers;
1262
1264 [&]( PCB_LAYER_ID layer )
1265 {
1266 layers.push_back( layer );
1267 } );
1268
1269 return layers;
1270}
1271
1272
1274{
1275 if( m_mode == MODE::NORMAL )
1276 return ALL_LAYERS;
1277
1278 if( m_mode == MODE::FRONT_INNER_BACK || IsNonCopperLayer( aLayer ) )
1279 {
1280 PCB_LAYER_ID candidate;
1281
1282 if( IsFrontLayer( aLayer ) )
1283 candidate = F_Cu;
1284 else if( IsBackLayer( aLayer ) )
1285 candidate = B_Cu;
1286 else
1287 candidate = INNER_LAYERS;
1288
1289 // FRONT_INNER_BACK always has all three sides.
1290 // In CUSTOM mode only return the side if the pad actually defines it.
1291 if( m_mode == MODE::FRONT_INNER_BACK || m_copperProps.count( candidate ) )
1292 return candidate;
1293 }
1294
1295 if( m_copperProps.count( aLayer ) )
1296 return aLayer;
1297
1298 // For CUSTOM mode, if ALL_LAYERS is present use it as the default; otherwise return the
1299 // first available layer (e.g. after FlipLayers renamed ALL_LAYERS from F_Cu to B_Cu).
1300 if( m_copperProps.count( ALL_LAYERS ) )
1301 return ALL_LAYERS;
1302
1303 wxASSERT( !m_copperProps.empty() );
1304 return m_copperProps.begin()->first;
1305}
1306
1307
1309{
1310 LSET layers;
1311
1312 if( m_mode == MODE::NORMAL && aOther.m_mode == MODE::NORMAL )
1313 {
1314 layers.set( ALL_LAYERS );
1315 }
1316 else
1317 {
1319 [&]( PCB_LAYER_ID layer )
1320 {
1321 layers.set( layer );
1322 } );
1323 aOther.ForEachUniqueLayer(
1324 [&]( PCB_LAYER_ID layer )
1325 {
1326 layers.set( layer );
1327 } );
1328 }
1329
1330 return layers;
1331}
1332
1333
1335{
1336 int maxHoleSize = Drill().size.x;
1337
1340
1343 {
1344 maxHoleSize = std::max( maxHoleSize, frontPM.size );
1345 }
1346
1349 {
1350 maxHoleSize = std::max( maxHoleSize, backPM.size );
1351 }
1352
1353 const PADSTACK::DRILL_PROPS& secondaryDrill = SecondaryDrill();
1354 const PADSTACK::DRILL_PROPS& tertiaryDrill = TertiaryDrill();
1355
1356 if( secondaryDrill.start != UNDEFINED_LAYER && secondaryDrill.end != UNDEFINED_LAYER )
1357 maxHoleSize = std::max( maxHoleSize, secondaryDrill.size.x );
1358
1359 if( tertiaryDrill.start != UNDEFINED_LAYER && tertiaryDrill.end != UNDEFINED_LAYER )
1360 maxHoleSize = std::max( maxHoleSize, tertiaryDrill.size.x );
1361
1362 return maxHoleSize;
1363}
1364
1365
1366std::optional<bool> PADSTACK::IsTented( PCB_LAYER_ID aSide ) const
1367{
1368 if( IsFrontLayer( aSide ) )
1370 else if( IsBackLayer( aSide ) )
1372 else
1373 return std::nullopt;
1374}
1375
1376
1377std::optional<bool> PADSTACK::IsCovered( PCB_LAYER_ID aSide ) const
1378{
1379 if( IsFrontLayer( aSide ) )
1381 else if( IsBackLayer( aSide ) )
1383 else
1384 return std::nullopt;
1385}
1386
1387
1388std::optional<bool> PADSTACK::IsPlugged( PCB_LAYER_ID aSide ) const
1389{
1390 if( IsFrontLayer( aSide ) )
1392 else if( IsBackLayer( aSide ) )
1394 else
1395 return std::nullopt;
1396}
1397
1398
1399std::optional<bool> PADSTACK::IsCapped() const
1400{
1401 return m_drill.is_capped;
1402}
1403
1404
1405std::optional<bool> PADSTACK::IsFilled() const
1406{
1407 return m_drill.is_filled;
1408}
1409
1410
1411#define TEST( a, b ) { if( a != b ) return a - b; }
1412
1413
1414int PADSTACK::Compare( const PADSTACK* aLeft, const PADSTACK* aRight )
1415{
1416 int diff;
1417
1418 TEST( (int) aLeft->m_mode, (int) aRight->m_mode );
1419
1420 if( aLeft->m_layerSet != aRight->m_layerSet )
1421 return aLeft->m_layerSet.Seq() < aRight->m_layerSet.Seq();
1422
1423 if( ( diff = wxString( aLeft->CustomName() ).Cmp( aRight->CustomName() ) ) != 0 )
1424 return diff;
1425
1427
1428 if( ( diff = aLeft->m_frontMaskProps.Compare( aRight->m_frontMaskProps ) ) != 0 )
1429 return diff;
1430
1431 if( ( diff = aLeft->m_backMaskProps.Compare( aRight->m_backMaskProps ) ) != 0 )
1432 return diff;
1433
1434 TEST( (int) aLeft->m_unconnectedLayerMode, (int) aRight->m_unconnectedLayerMode );
1435 TEST( (int) aLeft->m_customShapeInZoneMode, (int) aRight->m_customShapeInZoneMode );
1436
1437 if( ( diff = aLeft->m_drill.Compare( aRight->m_drill ) ) != 0 )
1438 return diff;
1439
1440 if( ( diff = aLeft->m_secondaryDrill.Compare( aRight->m_secondaryDrill ) ) != 0 )
1441 return diff;
1442
1443 if( ( diff = aLeft->m_tertiaryDrill.Compare( aRight->m_tertiaryDrill ) ) != 0 )
1444 return diff;
1445
1446 if( ( diff = aLeft->m_frontPostMachining.Compare( aRight->m_frontPostMachining ) ) != 0 )
1447 return diff;
1448
1449 if( ( diff = aLeft->m_backPostMachining.Compare( aRight->m_backPostMachining ) ) != 0 )
1450 return diff;
1451
1452 aLeft->ForEachUniqueLayer(
1453 [&]( PCB_LAYER_ID aLayer )
1454 {
1455 if( diff != 0 ) // we want to return the first non-matching layer
1456 return;
1457
1458 diff = aLeft->CopperLayer( aLayer ).Compare( aRight->CopperLayer( aLayer ) );
1459 } );
1460
1461 if( diff != 0 )
1462 return diff;
1463
1464 return 0;
1465}
1466
1467
1469{
1470 return m_copperProps.count( aLayer ) > 0;
1471}
1472
1473
1474double PADSTACK::Similarity( const PADSTACK& aOther ) const
1475{
1476 double similarity = 1.0;
1477
1478 if( m_mode != aOther.m_mode )
1479 similarity *= 0.9;
1480
1481 if( m_layerSet != aOther.m_layerSet )
1482 similarity *= 0.9;
1483
1484 if( CustomName() != aOther.CustomName() )
1485 similarity *= 0.9;
1486
1487 if( m_orientation != aOther.m_orientation )
1488 similarity *= 0.9;
1489
1490 if( m_frontMaskProps != aOther.m_frontMaskProps )
1491 similarity *= 0.9;
1492
1493 if( m_backMaskProps != aOther.m_backMaskProps )
1494 similarity *= 0.9;
1495
1497 similarity *= 0.9;
1498
1500 similarity *= 0.9;
1501
1502 if( m_drill != aOther.m_drill )
1503 similarity *= 0.9;
1504
1505 if( m_secondaryDrill != aOther.m_secondaryDrill )
1506 similarity *= 0.9;
1507
1508 if( m_tertiaryDrill != aOther.m_tertiaryDrill )
1509 similarity *= 0.9;
1510
1512 similarity *= 0.9;
1513
1515 similarity *= 0.9;
1516
1518 [&]( PCB_LAYER_ID aLayer )
1519 {
1520 similarity *= CopperLayer( aLayer ).Similarity( aOther.CopperLayer( aLayer ) );
1521 } );
1522
1523 return similarity;
1524}
1525
1526
1528{
1530 {
1531 std::unordered_map<PCB_LAYER_ID, COPPER_LAYER_PROPS> oldCopperProps = m_copperProps;
1532 m_copperProps.clear();
1533
1534 m_copperProps[aBoard->FlipLayer( F_Cu )] = oldCopperProps[F_Cu];
1535 m_copperProps[INNER_LAYERS] = oldCopperProps[INNER_LAYERS];
1536 m_copperProps[aBoard->FlipLayer( B_Cu )] = oldCopperProps[B_Cu];
1537 }
1538 else if( m_mode == MODE::CUSTOM )
1539 {
1540 std::unordered_map<PCB_LAYER_ID, COPPER_LAYER_PROPS> oldCopperProps = m_copperProps;
1541 m_copperProps.clear();
1542
1543 for( const auto& [layer, props] : oldCopperProps )
1544 m_copperProps[aBoard->FlipLayer( layer )] = props;
1545 }
1546
1547 std::swap( m_frontMaskProps, m_backMaskProps );
1548
1549 m_drill.start = aBoard->FlipLayer( m_drill.start );
1550 m_drill.end = aBoard->FlipLayer( m_drill.end );
1551
1552 m_secondaryDrill.start = aBoard->FlipLayer( m_secondaryDrill.start );
1553 m_secondaryDrill.end = aBoard->FlipLayer( m_secondaryDrill.end );
1554
1555 m_tertiaryDrill.start = aBoard->FlipLayer( m_tertiaryDrill.start );
1556 m_tertiaryDrill.end = aBoard->FlipLayer( m_tertiaryDrill.end );
1557
1559}
1560
1561
1563{
1564 return m_drill.start;
1565}
1566
1567
1569{
1570 return m_drill.end;
1571}
1572
1573
1574wxString PADSTACK::Name() const
1575{
1576 return CustomName();
1577}
1578
1579
1580const wxChar* PADSTACK::CustomName() const
1581{
1582 if( m_customName )
1583 return m_customName->wx_str();
1584
1585 return wxEmptyString;
1586}
1587
1588
1589void PADSTACK::SetCustomName( const wxString& aCustomName )
1590{
1591 if( aCustomName.IsEmpty() )
1592 {
1593 m_customName.reset();
1594 }
1595 else if( m_customName )
1596 {
1597 *m_customName = aCustomName;
1598 }
1599 else
1600 {
1601 m_customName = std::make_unique<wxString>( aCustomName );
1602 }
1603}
1604
1605
1609 size( 0, 0 ),
1610 offset( 0, 0 ),
1612 chamfered_rect_ratio( 0.0 ),
1614 trapezoid_delta_size( 0, 0 )
1615{
1616}
1617
1618
1620{
1621 return shape == aOther.shape &&
1622 anchor_shape == aOther.anchor_shape &&
1623 size == aOther.size &&
1624 offset == aOther.offset &&
1629}
1630
1631
1633{
1634 TEST( (int) shape, (int) aOther.shape );
1635 TEST( (int) anchor_shape, (int) aOther.anchor_shape );
1636 TEST( size.x, aOther.size.x );
1637
1639 TEST( size.y, aOther.size.y );
1640
1641 TEST( offset.x, aOther.offset.x );
1642 TEST( offset.y, aOther.offset.y );
1643
1644 if( abs( round_rect_radius_ratio - aOther.round_rect_radius_ratio ) > 0.0001 )
1645 return round_rect_radius_ratio > aOther.round_rect_radius_ratio ? 1 : -1;
1646
1647 if( abs( chamfered_rect_ratio - aOther.chamfered_rect_ratio ) > 0.0001 )
1648 return chamfered_rect_ratio > aOther.chamfered_rect_ratio ? 1 : -1;
1649
1651
1652 return 0;
1653}
1654
1655
1657{
1658 if( !( shape == aOther.shape ) ) return false;
1659 if( zone_connection != aOther.zone_connection ) return false;
1660 if( thermal_spoke_width != aOther.thermal_spoke_width ) return false;
1661 if( thermal_spoke_angle != aOther.thermal_spoke_angle ) return false;
1662 if( thermal_gap != aOther.thermal_gap ) return false;
1663 if( clearance != aOther.clearance ) return false;
1664
1665 if( custom_shapes.size() != aOther.custom_shapes.size() ) return false;
1666
1667 // Deep compare of shapes?
1668 // For now, just check pointers or size
1669 return true;
1670}
1671
1672
1674{
1675 double similarity = 1.0;
1676
1677 if( shape != aOther.shape )
1678 similarity *= 0.5;
1679
1680 if( zone_connection != aOther.zone_connection )
1681 similarity *= 0.9;
1682
1684 similarity *= 0.9;
1685
1687 similarity *= 0.9;
1688
1689 if( thermal_gap != aOther.thermal_gap )
1690 similarity *= 0.9;
1691
1692 if( clearance != aOther.clearance )
1693 similarity *= 0.9;
1694
1695 if( custom_shapes != aOther.custom_shapes )
1696 similarity *= 0.5;
1697
1698 return similarity;
1699}
1700
1701
1702#define TEST_OPT( a, b, v ) \
1703 { \
1704 if( a.has_value() != b.has_value() ) \
1705 return a.has_value() - b.has_value(); \
1706 if( (int) a.value_or( v ) - (int) b.value_or( v ) != 0 ) \
1707 return (int) a.value_or( v ) - (int) b.value_or( v ); \
1708 }
1709
1710#define TEST_OPT_ANGLE( a, b, v ) \
1711 { \
1712 if( a.has_value() != b.has_value() ) \
1713 return a.has_value() - b.has_value(); \
1714 if( abs( a.value_or( v ).AsDegrees() - b.value_or( v ).AsDegrees() ) > 0.001 ) \
1715 return a.value_or( v ).AsDegrees() > b.value_or( v ).AsDegrees() ? 1 : -1; \
1716 }
1717
1718
1720{
1721 int diff;
1722
1723 if( ( diff = shape.Compare( aOther.shape ) ) != 0 )
1724 return diff;
1725
1729 TEST_OPT( thermal_gap, aOther.thermal_gap, 0 );
1730 TEST_OPT( clearance, aOther.clearance, 0 );
1731
1732 if( ( diff = (int) custom_shapes.size() - (int) aOther.custom_shapes.size() ) != 0 )
1733 return diff;
1734
1735 for( int ii = 0; ii < (int) custom_shapes.size(); ++ii )
1736 {
1737 if( ( diff = custom_shapes[ii]->Compare( aOther.custom_shapes[ii].get() ) ) != 0 )
1738 return diff;
1739 }
1740
1741 return 0;
1742}
1743
1744
1755
1756
1758{
1761
1762 if( solder_paste_margin_ratio.has_value() != aOther.solder_paste_margin_ratio.has_value() )
1763 return solder_paste_margin_ratio.has_value() - aOther.solder_paste_margin_ratio.has_value();
1764 if( abs( solder_paste_margin_ratio.value_or( 0.0 ) - aOther.solder_paste_margin_ratio.value_or( 0.0 ) ) > 0.0001 )
1765 return solder_paste_margin_ratio.value_or( 0.0 ) > aOther.solder_paste_margin_ratio.value_or( 0.0 ) ? 1 : -1;
1766
1767 TEST_OPT( has_solder_mask, aOther.has_solder_mask, false );
1768 TEST_OPT( has_solder_paste, aOther.has_solder_paste, false );
1769 TEST_OPT( has_covering, aOther.has_covering, false );
1770 TEST_OPT( has_plugging, aOther.has_plugging, false );
1771
1772 return 0;
1773}
1774
1775
1777{
1778 return size == aOther.size &&
1779 shape == aOther.shape &&
1780 start == aOther.start &&
1781 end == aOther.end &&
1782 is_filled == aOther.is_filled &&
1783 is_capped == aOther.is_capped;
1784}
1785
1786
1788{
1789 TEST( (int) shape, (int) aOther.shape );
1790
1791 TEST( size.x, aOther.size.x );
1792
1794 TEST( size.y, aOther.size.y );
1795
1796 TEST( (int) start, (int) aOther.start );
1797 TEST( (int) end, (int) aOther.end );
1798
1799 TEST_OPT( is_filled, aOther.is_filled, false );
1800 TEST_OPT( is_capped, aOther.is_capped, false );
1801
1802 return 0;
1803}
1804
1805
1807{
1808 return mode == aOther.mode &&
1809 size == aOther.size &&
1810 depth == aOther.depth &&
1811 angle == aOther.angle;
1812}
1813
1814
1816{
1818 TEST( size, aOther.size );
1819 TEST( depth, aOther.depth );
1820 TEST( angle, aOther.angle );
1821
1822 return 0;
1823}
1824
1825
1827{
1828 m_mode = aMode;
1829}
KICOMMON_API types::KiCadObjectType ToProtoEnum(KICAD_T aValue)
KICOMMON_API KICAD_T FromProtoEnum(types::KiCadObjectType aValue)
Definition api_enums.cpp:55
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:995
BASE_SET & set(size_t pos)
Definition base_set.h:126
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:409
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayer) const
Definition board.cpp:1124
int AsTenthsOfADegree() const
Definition eda_angle.h:118
virtual void SetParent(EDA_ITEM *aParent)
Definition eda_item.cpp:153
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition lset.cpp:309
std::optional< bool > IsFilled() const
bool operator==(const PADSTACK &aOther) const
Definition padstack.cpp:133
std::optional< int > & Clearance(PCB_LAYER_ID aLayer=F_Cu)
Definition padstack.cpp:999
void AddPrimitive(PCB_SHAPE *aShape, PCB_LAYER_ID aLayer)
Adds a custom shape primitive to the padstack.
void ReplacePrimitives(const std::vector< std::shared_ptr< PCB_SHAPE > > &aPrimitivesList, PCB_LAYER_ID aLayer)
Clears the existing primitive list (freeing the owned shapes) and adds copies of the given shapes to ...
void SetBackdrillMode(BACKDRILL_MODE aMode)
Definition padstack.cpp:547
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition padstack.cpp:464
MASK_LAYER_PROPS & FrontOuterLayers()
Definition padstack.h:384
double Similarity(const PADSTACK &aOther) const
Return a measure of how likely the other object is to represent the same object.
int RoundRectRadius(PCB_LAYER_ID aLayer) const
Definition padstack.cpp:952
void SetDrillShape(PAD_DRILL_SHAPE aShape)
Definition padstack.cpp:892
int GetMaxHoleSize() const
std::optional< double > & SolderPasteMarginRatio(PCB_LAYER_ID aLayer=F_Cu)
void SetBackdrillSize(bool aTop, std::optional< int > aSize)
Definition padstack.cpp:580
DRILL_PROPS m_drill
!
Definition padstack.h:588
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::...
void SetThermalSpokeAngle(EDA_ANGLE aAngle, PCB_LAYER_ID aLayer=F_Cu)
void SetRoundRectRadiusRatio(double aRatio, PCB_LAYER_ID aLayer)
Definition padstack.cpp:946
UNCONNECTED_LAYER_MODE m_unconnectedLayerMode
Definition padstack.h:577
void ClearPrimitives(PCB_LAYER_ID aLayer)
void SetUnconnectedLayerMode(UNCONNECTED_LAYER_MODE aMode)
Definition padstack.h:379
void SetCustomName(const wxString &aCustomName)
bool HasExplicitDefinitionForLayer(PCB_LAYER_ID aLayer) const
Check if the padstack has an explicit definition for the given layer.
std::optional< bool > IsTented(PCB_LAYER_ID aSide) const
Checks if this padstack is tented (covered in soldermask) on the given side.
void SetMode(MODE aMode)
std::optional< int > & ThermalSpokeWidth(PCB_LAYER_ID aLayer=F_Cu)
std::optional< int > & SolderPasteMargin(PCB_LAYER_ID aLayer=F_Cu)
void FlipLayers(BOARD *aBoard)
Flips the padstack layers in the case that the pad's parent footprint is flipped to the other side of...
POST_MACHINING_PROPS m_backPostMachining
Definition padstack.h:597
std::optional< int > & SolderMaskMargin(PCB_LAYER_ID aLayer=F_Cu)
const DRILL_PROPS * findBackdrillDrill(bool aTop) const
Return the drill slot holding the top (aTop true) or bottom backdrill, identified by its start layer ...
Definition padstack.cpp:479
void SetChamferRatio(double aRatio, PCB_LAYER_ID aLayer)
Definition padstack.cpp:975
PCB_LAYER_ID EffectiveLayerFor(PCB_LAYER_ID aLayer) const
Determines which geometry layer should be used for the given input layer.
PADSTACK & operator=(const PADSTACK &aOther)
Definition padstack.cpp:85
void SetOffset(const VECTOR2I &aOffset, PCB_LAYER_ID aLayer)
Definition padstack.cpp:910
void SetShape(PAD_SHAPE aShape, PCB_LAYER_ID aLayer)
Definition padstack.cpp:880
EDA_ANGLE DefaultThermalSpokeAngleForShape(PCB_LAYER_ID aLayer=F_Cu) const
VECTOR2I & TrapezoidDeltaSize(PCB_LAYER_ID aLayer)
Definition padstack.cpp:928
DRILL_PROPS m_secondaryDrill
! Secondary drill, used to define back-drilling starting from the bottom side
Definition padstack.h:591
void clearBackdrillSide(bool aTop)
Clear every slot whose start layer marks it as the given backdrill side, so a malformed padstack with...
Definition padstack.cpp:517
VECTOR2I & Offset(PCB_LAYER_ID aLayer)
Definition padstack.cpp:898
MASK_LAYER_PROPS m_backMaskProps
! The overrides applied to back outer technical layers
Definition padstack.h:575
COPPER_LAYER_PROPS & CopperLayer(PCB_LAYER_ID aLayer)
EDA_ANGLE ThermalSpokeAngle(PCB_LAYER_ID aLayer=F_Cu) const
CUSTOM_SHAPE_ZONE_MODE m_customShapeInZoneMode
How to build the custom shape in zone, to create the clearance area: CUSTOM_SHAPE_ZONE_MODE::OUTLINE ...
Definition padstack.h:584
bool unpackCopperLayer(const kiapi::board::types::PadStackLayer &aProto)
Definition padstack.cpp:187
PAD_DRILL_SHAPE DrillShape() const
Definition padstack.cpp:886
void SetChamferPositions(int aPositions, PCB_LAYER_ID aLayer)
Definition padstack.cpp:993
POST_MACHINING_PROPS & FrontPostMachining()
Definition padstack.h:370
DRILL_PROPS m_tertiaryDrill
! Tertiary drill, used to define back-drilling starting from the top side
Definition padstack.h:594
void SetRoundRectRadius(double aRadius, PCB_LAYER_ID aLayer)
Definition padstack.cpp:959
std::optional< bool > IsPlugged(PCB_LAYER_ID aSide) const
LSET RelevantShapeLayers(const PADSTACK &aOther) const
Returns the set of layers that must be considered if checking one padstack against another.
std::optional< int > & ThermalGap(PCB_LAYER_ID aLayer=F_Cu)
DRILL_PROPS & TertiaryDrill()
Definition padstack.h:367
PAD_SHAPE Shape(PCB_LAYER_ID aLayer) const
Definition padstack.cpp:874
DRILL_PROPS & Drill()
Definition padstack.h:361
void SetAnchorShape(PAD_SHAPE aShape, PCB_LAYER_ID aLayer)
Definition padstack.cpp:922
BOARD_ITEM * m_parent
! The BOARD_ITEM this PADSTACK belongs to; will be used as the parent for owned shapes
Definition padstack.h:555
PADSTACK(BOARD_ITEM *aParent)
Definition padstack.cpp:44
std::optional< bool > IsCapped() const
std::vector< PCB_LAYER_ID > UniqueLayers() const
void SetBackdrillEndLayer(bool aTop, PCB_LAYER_ID aLayer)
Definition padstack.cpp:605
LSET m_layerSet
! The board layers that this padstack is active on
Definition padstack.h:561
std::optional< int > GetBackdrillSize(bool aTop) const
Definition padstack.cpp:571
std::unordered_map< PCB_LAYER_ID, COPPER_LAYER_PROPS > m_copperProps
Definition padstack.h:569
BACKDRILL_MODE GetBackdrillMode() const
Definition padstack.cpp:529
static int Compare(const PADSTACK *aPadstackRef, const PADSTACK *aPadstackCmp)
Compare two padstacks and return 0 if they are equal.
PCB_LAYER_ID EndLayer() const
std::optional< bool > IsCovered(PCB_LAYER_ID aSide) const
DRILL_PROPS & backdrillWriteSlot(bool aTop)
Return the slot to write a backdrill side into, reusing the slot already holding that side or otherwi...
Definition padstack.cpp:499
int & ChamferPositions(PCB_LAYER_ID aLayer)
Definition padstack.cpp:981
MASK_LAYER_PROPS m_frontMaskProps
! The overrides applied to front outer technical layers
Definition padstack.h:572
const VECTOR2I & Size(PCB_LAYER_ID aLayer) const
Definition padstack.cpp:868
MODE
! Copper geometry mode: controls how many unique copper layer shapes this padstack has
Definition padstack.h:169
@ NORMAL
Shape is the same on all layers.
Definition padstack.h:170
@ CUSTOM
Shapes can be defined on arbitrary layers.
Definition padstack.h:172
@ FRONT_INNER_BACK
Up to three shapes can be defined (F_Cu, inner copper layers, B_Cu)
Definition padstack.h:171
void AppendPrimitives(const std::vector< std::shared_ptr< PCB_SHAPE > > &aPrimitivesList, PCB_LAYER_ID aLayer)
Appends a copy of each shape in the given list to this padstack's custom shape list.
DRILL_PROPS & SecondaryDrill()
Definition padstack.h:364
double RoundRectRadiusRatio(PCB_LAYER_ID aLayer) const
Definition padstack.cpp:940
PCB_LAYER_ID GetBackdrillEndLayer(bool aTop) const
Definition padstack.cpp:596
PCB_LAYER_ID StartLayer() const
POST_MACHINING_PROPS & BackPostMachining()
Definition padstack.h:373
POST_MACHINING_PROPS m_frontPostMachining
Definition padstack.h:596
std::unique_ptr< wxString > m_customName
! An override for the IPC-7351 padstack name
Definition padstack.h:564
PAD_SHAPE AnchorShape(PCB_LAYER_ID aLayer) const
Definition padstack.cpp:916
MASK_LAYER_PROPS & BackOuterLayers()
Definition padstack.h:387
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition padstack.cpp:846
wxString Name() const
! Returns the name of this padstack in IPC-7351 format
void SetSize(const VECTOR2I &aSize, PCB_LAYER_ID aLayer)
Definition padstack.cpp:854
double ChamferRatio(PCB_LAYER_ID aLayer) const
Definition padstack.cpp:969
static constexpr PCB_LAYER_ID ALL_LAYERS
! The layer identifier to use for the single defintion on normal padstacks
Definition padstack.h:179
const wxChar * CustomName() const
static constexpr PCB_LAYER_ID INNER_LAYERS
! The layer identifier to use for "inner layers" on top/inner/bottom padstacks
Definition padstack.h:182
void SetLayerSet(const LSET &aSet)
Definition padstack.h:333
std::optional< ZONE_CONNECTION > & ZoneConnection(PCB_LAYER_ID aLayer=F_Cu)
@ NORMAL
Padstack for a footprint pad.
Definition padstack.h:162
MODE m_mode
! The copper layer variation mode this padstack is in
Definition padstack.h:558
EDA_ANGLE m_orientation
! The rotation of the pad relative to an outer reference frame
Definition padstack.h:567
std::vector< std::shared_ptr< PCB_SHAPE > > & Primitives(PCB_LAYER_ID aLayer)
static constexpr EDA_ANGLE ANGLE_0
Definition eda_angle.h:422
static constexpr EDA_ANGLE ANGLE_90
Definition eda_angle.h:424
@ DEGREES_T
Definition eda_angle.h:31
static constexpr EDA_ANGLE ANGLE_45
Definition eda_angle.h:423
#define TEST(a, b)
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
Definition layer_ids.h:806
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
Definition layer_ids.h:829
bool IsNonCopperLayer(int aLayerId)
Test whether a layer is a non copper layer.
Definition layer_ids.h:736
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ B_Cu
Definition layer_ids.h:61
@ UNDEFINED_LAYER
Definition layer_ids.h:57
@ F_Cu
Definition layer_ids.h:60
This file contains miscellaneous commonly used macros and functions.
void PackLayerSet(google::protobuf::RepeatedField< int > &aOutput, const LSET &aLayerSet)
LSET UnpackLayerSet(const google::protobuf::RepeatedField< int > &aProtoLayerSet)
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)
#define TEST_OPT_ANGLE(a, b, v)
#define TEST_OPT(a, b, v)
PAD_DRILL_POST_MACHINING_MODE
Definition padstack.h:75
PAD_DRILL_SHAPE
The set of pad drill shapes, used with PAD::{Set,Get}DrillShape()
Definition padstack.h:68
CUSTOM_SHAPE_ZONE_MODE
Definition padstack.h:136
BACKDRILL_MODE
Definition padstack.h:83
PAD_SHAPE
The set of pad shapes, used with PAD::{Set,Get}Shape()
Definition padstack.h:51
@ ROUNDRECT
Definition padstack.h:56
@ TRAPEZOID
Definition padstack.h:55
@ RECTANGLE
Definition padstack.h:53
UNCONNECTED_LAYER_MODE
Definition padstack.h:127
#define IMPLEMENT_ENUM_TO_WXANY(type)
Definition property.h:875
The features of a padstack that can vary between copper layers All parameters are optional; leaving t...
Definition padstack.h:229
double Similarity(const COPPER_LAYER_PROPS &aOther) const
std::optional< ZONE_CONNECTION > zone_connection
Definition padstack.h:231
int Compare(const COPPER_LAYER_PROPS &aOther) const
std::optional< int > thermal_spoke_width
Definition padstack.h:232
std::vector< std::shared_ptr< PCB_SHAPE > > custom_shapes
Definition padstack.h:241
bool operator==(const COPPER_LAYER_PROPS &aOther) const
std::optional< EDA_ANGLE > thermal_spoke_angle
Definition padstack.h:233
std::optional< int > clearance
Definition padstack.h:235
std::optional< int > thermal_gap
Definition padstack.h:234
The properties of a padstack drill.
Definition padstack.h:272
PCB_LAYER_ID start
Definition padstack.h:275
PCB_LAYER_ID end
Definition padstack.h:276
bool operator==(const DRILL_PROPS &aOther) const
VECTOR2I size
Drill diameter (x == y) or slot dimensions (x != y)
Definition padstack.h:273
std::optional< bool > is_capped
True if the drill hole should be capped.
Definition padstack.h:279
std::optional< bool > is_filled
True if the drill hole should be filled completely.
Definition padstack.h:278
PAD_DRILL_SHAPE shape
Definition padstack.h:274
int Compare(const DRILL_PROPS &aOther) const
The features of a padstack that can vary on outer layers.
Definition padstack.h:254
bool operator==(const MASK_LAYER_PROPS &aOther) const
std::optional< int > solder_mask_margin
Definition padstack.h:255
int Compare(const MASK_LAYER_PROPS &aOther) const
std::optional< bool > has_covering
True if the pad on this side should have covering.
Definition padstack.h:261
std::optional< int > solder_paste_margin
Definition padstack.h:256
std::optional< double > solder_paste_margin_ratio
Definition padstack.h:257
std::optional< bool > has_solder_mask
True if this outer layer has mask (is not tented)
Definition padstack.h:259
std::optional< bool > has_solder_paste
True if this outer layer has solder paste.
Definition padstack.h:260
std::optional< bool > has_plugging
True if the drill hole should be plugged on this side.
Definition padstack.h:262
std::optional< PAD_DRILL_POST_MACHINING_MODE > mode
Definition padstack.h:287
bool operator==(const POST_MACHINING_PROPS &aOther) const
int Compare(const POST_MACHINING_PROPS &aOther) const
VECTOR2I trapezoid_delta_size
Delta for PAD_SHAPE::TRAPEZOID; half the delta squeezes one end and half expands the other.
Definition padstack.h:209
int Compare(const SHAPE_PROPS &aOther) const
VECTOR2I offset
Offset of the shape center from the pad center.
Definition padstack.h:199
bool operator==(const SHAPE_PROPS &aOther) const
VECTOR2I size
Size of the shape, or of the anchor pad for custom shape pads.
Definition padstack.h:190
double chamfered_rect_ratio
Size of chamfer: ratio of smallest of X,Y size.
Definition padstack.h:202
double round_rect_radius_ratio
Definition padstack.h:201
PAD_SHAPE shape
Shape of the pad.
Definition padstack.h:188
PAD_SHAPE anchor_shape
Shape of the anchor when shape == PAD_SHAPE::CUSTOM.
Definition padstack.h:189
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683
@ NONE
Pads are not covered.
Definition zones.h:45