KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_track.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) 2012 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright (C) 2012 Wayne Stambaugh <[email protected]>
7 * Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, you may find one here:
21 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22 * or you may search the http://www.gnu.org website for the version 2 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 */
26
27#include "pcb_track.h"
28
29#include <pcb_base_frame.h>
30#include <core/mirror.h>
32#include <board.h>
35#include <base_units.h>
36#include <layer_range.h>
37#include <lset.h>
38#include <string_utils.h>
39#include <view/view.h>
43#include <geometry/seg.h>
46#include <geometry/shape_arc.h>
47#include <drc/drc_engine.h>
48#include <pcb_painter.h>
49#include <trigo.h>
50
51#include <google/protobuf/any.pb.h>
52#include <api/api_enums.h>
53#include <api/api_utils.h>
54#include <api/api_pcb_utils.h>
55#include <api/board/board_types.pb.h>
56
59
61 BOARD_CONNECTED_ITEM( aParent, idtype )
62{
63 m_Width = pcbIUScale.mmToIU( 0.2 ); // Gives a reasonable default width
64 m_hasSolderMask = false;
65}
66
67
69{
70 return new PCB_TRACK( *this );
71}
72
73
74PCB_ARC::PCB_ARC( BOARD_ITEM* aParent, const SHAPE_ARC* aArc ) :
75 PCB_TRACK( aParent, PCB_ARC_T )
76{
77 m_Start = aArc->GetP0();
78 m_End = aArc->GetP1();
79 m_Mid = aArc->GetArcMid();
80}
81
82
84{
85 return new PCB_ARC( *this );
86}
87
88
90 PCB_TRACK( aParent, PCB_VIA_T ),
91 m_padStack( this )
92{
93 SetViaType( VIATYPE::THROUGH );
95 Padstack().Drill().end = B_Cu;
97
99
100 // Until vias support custom padstack; their layer set should always be cleared
102
103 // For now, vias are always circles
104 m_padStack.SetShape( PAD_SHAPE::CIRCLE, PADSTACK::ALL_LAYERS );
105
108
109 m_isFree = false;
110}
111
112
113PCB_VIA::PCB_VIA( const PCB_VIA& aOther ) :
114 PCB_TRACK( aOther.GetParent(), PCB_VIA_T ),
115 m_padStack( this )
116{
117 PCB_VIA::operator=( aOther );
118
119 const_cast<KIID&>( m_Uuid ) = aOther.m_Uuid;
121}
122
123
125{
127
128 m_Start = aOther.m_Start;
129 m_End = aOther.m_End;
130
131 m_viaType = aOther.m_viaType;
132 m_padStack = aOther.m_padStack;
133 m_isFree = aOther.m_isFree;
134
135 return *this;
136}
137
138
140{
141 return new PCB_VIA( *this );
142}
143
144
145wxString PCB_VIA::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
146{
147 wxString formatStr;
148
149 switch( GetViaType() )
150 {
151 case VIATYPE::BLIND_BURIED: formatStr = _( "Blind/Buried Via %s on %s" ); break;
152 case VIATYPE::MICROVIA: formatStr = _( "Micro Via %s on %s" ); break;
153 default: formatStr = _( "Via %s on %s" ); break;
154 }
155
156 return wxString::Format( formatStr, GetNetnameMsg(), layerMaskDescribe() );
157}
158
159
161{
162 return BITMAPS::via;
163}
164
165
166bool PCB_TRACK::operator==( const BOARD_ITEM& aBoardItem ) const
167{
168 if( aBoardItem.Type() != Type() )
169 return false;
170
171 const PCB_TRACK& other = static_cast<const PCB_TRACK&>( aBoardItem );
172
173 return *this == other;
174}
175
176
177bool PCB_TRACK::operator==( const PCB_TRACK& aOther ) const
178{
179 return m_Start == aOther.m_Start
180 && m_End == aOther.m_End
181 && m_layer == aOther.m_layer
182 && m_Width == aOther.m_Width
185}
186
187
188double PCB_TRACK::Similarity( const BOARD_ITEM& aOther ) const
189{
190 if( aOther.Type() != Type() )
191 return 0.0;
192
193 const PCB_TRACK& other = static_cast<const PCB_TRACK&>( aOther );
194
195 double similarity = 1.0;
196
197 if( m_layer != other.m_layer )
198 similarity *= 0.9;
199
200 if( m_Width != other.m_Width )
201 similarity *= 0.9;
202
203 if( m_Start != other.m_Start )
204 similarity *= 0.9;
205
206 if( m_End != other.m_End )
207 similarity *= 0.9;
208
209 if( m_hasSolderMask != other.m_hasSolderMask )
210 similarity *= 0.9;
211
213 similarity *= 0.9;
214
215 return similarity;
216}
217
218
219bool PCB_ARC::operator==( const BOARD_ITEM& aBoardItem ) const
220{
221 if( aBoardItem.Type() != Type() )
222 return false;
223
224 const PCB_ARC& other = static_cast<const PCB_ARC&>( aBoardItem );
225
226 return *this == other;
227}
228
229
230bool PCB_ARC::operator==( const PCB_ARC& aOther ) const
231{
232 return m_Start == aOther.m_Start
233 && m_End == aOther.m_End
234 && m_Mid == aOther.m_Mid
235 && m_layer == aOther.m_layer
236 && m_Width == aOther.m_Width
239}
240
241
242double PCB_ARC::Similarity( const BOARD_ITEM& aOther ) const
243{
244 if( aOther.Type() != Type() )
245 return 0.0;
246
247 const PCB_ARC& other = static_cast<const PCB_ARC&>( aOther );
248
249 double similarity = 1.0;
250
251 if( m_layer != other.m_layer )
252 similarity *= 0.9;
253
254 if( m_Width != other.m_Width )
255 similarity *= 0.9;
256
257 if( m_Start != other.m_Start )
258 similarity *= 0.9;
259
260 if( m_End != other.m_End )
261 similarity *= 0.9;
262
263 if( m_Mid != other.m_Mid )
264 similarity *= 0.9;
265
266 if( m_hasSolderMask != other.m_hasSolderMask )
267 similarity *= 0.9;
268
270 similarity *= 0.9;
271
272 return similarity;
273}
274
275
276bool PCB_VIA::operator==( const BOARD_ITEM& aBoardItem ) const
277{
278 if( aBoardItem.Type() != Type() )
279 return false;
280
281 const PCB_VIA& other = static_cast<const PCB_VIA&>( aBoardItem );
282
283 return *this == other;
284}
285
286
287bool PCB_VIA::operator==( const PCB_VIA& aOther ) const
288{
289 return m_Start == aOther.m_Start
290 && m_End == aOther.m_End
291 && m_layer == aOther.m_layer
292 && m_padStack == aOther.m_padStack
293 && m_viaType == aOther.m_viaType
295}
296
297
298double PCB_VIA::Similarity( const BOARD_ITEM& aOther ) const
299{
300 if( aOther.Type() != Type() )
301 return 0.0;
302
303 const PCB_VIA& other = static_cast<const PCB_VIA&>( aOther );
304
305 double similarity = 1.0;
306
307 if( m_layer != other.m_layer )
308 similarity *= 0.9;
309
310 if( m_Start != other.m_Start )
311 similarity *= 0.9;
312
313 if( m_End != other.m_End )
314 similarity *= 0.9;
315
316 if( m_padStack != other.m_padStack )
317 similarity *= 0.9;
318
319 if( m_viaType != other.m_viaType )
320 similarity *= 0.9;
321
323 similarity *= 0.9;
324
325 return similarity;
326}
327
328
329void PCB_VIA::SetWidth( int aWidth )
330{
331 // This is present because of the parent class. It should never be actually called on a via.
332 wxASSERT_MSG( false, "Warning: PCB_VIA::SetWidth called without a layer argument" );
333 m_padStack.SetSize( { aWidth, aWidth }, PADSTACK::ALL_LAYERS );
334}
335
336
338{
339 // This is present because of the parent class. It should never be actually called on a via.
340 wxASSERT_MSG( false, "Warning: PCB_VIA::GetWidth called without a layer argument" );
342}
343
344
345void PCB_VIA::SetWidth( PCB_LAYER_ID aLayer, int aWidth )
346{
347 m_padStack.SetSize( { aWidth, aWidth }, aLayer );
348}
349
350
352{
353 return m_padStack.Size( aLayer ).x;
354}
355
356
357void PCB_TRACK::Serialize( google::protobuf::Any &aContainer ) const
358{
359 kiapi::board::types::Track track;
360
361 track.mutable_id()->set_value( m_Uuid.AsStdString() );
362 track.mutable_start()->set_x_nm( GetStart().x );
363 track.mutable_start()->set_y_nm( GetStart().y );
364 track.mutable_end()->set_x_nm( GetEnd().x );
365 track.mutable_end()->set_y_nm( GetEnd().y );
366 track.mutable_width()->set_value_nm( GetWidth() );
367 track.set_layer( ToProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( GetLayer() ) );
368 track.set_locked( IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
369 : kiapi::common::types::LockedState::LS_UNLOCKED );
370 track.mutable_net()->mutable_code()->set_value( GetNetCode() );
371 track.mutable_net()->set_name( GetNetname() );
372 // TODO m_hasSolderMask and m_solderMaskMargin
373
374 aContainer.PackFrom( track );
375}
376
377
378bool PCB_TRACK::Deserialize( const google::protobuf::Any &aContainer )
379{
380 kiapi::board::types::Track track;
381
382 if( !aContainer.UnpackTo( &track ) )
383 return false;
384
385 const_cast<KIID&>( m_Uuid ) = KIID( track.id().value() );
386 SetStart( VECTOR2I( track.start().x_nm(), track.start().y_nm() ) );
387 SetEnd( VECTOR2I( track.end().x_nm(), track.end().y_nm() ) );
388 SetWidth( track.width().value_nm() );
389 SetLayer( FromProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( track.layer() ) );
390 SetNetCode( track.net().code().value() );
391 SetLocked( track.locked() == kiapi::common::types::LockedState::LS_LOCKED );
392 // TODO m_hasSolderMask and m_solderMaskMargin
393
394 return true;
395}
396
397
398void PCB_ARC::Serialize( google::protobuf::Any &aContainer ) const
399{
400 kiapi::board::types::Arc arc;
401
402 arc.mutable_id()->set_value( m_Uuid.AsStdString() );
403 arc.mutable_start()->set_x_nm( GetStart().x );
404 arc.mutable_start()->set_y_nm( GetStart().y );
405 arc.mutable_mid()->set_x_nm( GetMid().x );
406 arc.mutable_mid()->set_y_nm( GetMid().y );
407 arc.mutable_end()->set_x_nm( GetEnd().x );
408 arc.mutable_end()->set_y_nm( GetEnd().y );
409 arc.mutable_width()->set_value_nm( GetWidth() );
410 arc.set_layer( ToProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( GetLayer() ) );
411 arc.set_locked( IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
412 : kiapi::common::types::LockedState::LS_UNLOCKED );
413 arc.mutable_net()->mutable_code()->set_value( GetNetCode() );
414 arc.mutable_net()->set_name( GetNetname() );
415 // TODO m_hasSolderMask and m_solderMaskMargin
416
417 aContainer.PackFrom( arc );
418}
419
420
421bool PCB_ARC::Deserialize( const google::protobuf::Any &aContainer )
422{
423 kiapi::board::types::Arc arc;
424
425 if( !aContainer.UnpackTo( &arc ) )
426 return false;
427
428 const_cast<KIID&>( m_Uuid ) = KIID( arc.id().value() );
429 SetStart( VECTOR2I( arc.start().x_nm(), arc.start().y_nm() ) );
430 SetMid( VECTOR2I( arc.mid().x_nm(), arc.mid().y_nm() ) );
431 SetEnd( VECTOR2I( arc.end().x_nm(), arc.end().y_nm() ) );
432 SetWidth( arc.width().value_nm() );
433 SetLayer( FromProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( arc.layer() ) );
434 SetNetCode( arc.net().code().value() );
435 SetLocked( arc.locked() == kiapi::common::types::LockedState::LS_LOCKED );
436 // TODO m_hasSolderMask and m_solderMaskMargin
437
438 return true;
439}
440
441
442void PCB_VIA::Serialize( google::protobuf::Any &aContainer ) const
443{
444 kiapi::board::types::Via via;
445
446 via.mutable_id()->set_value( m_Uuid.AsStdString() );
447 via.mutable_position()->set_x_nm( GetPosition().x );
448 via.mutable_position()->set_y_nm( GetPosition().y );
449
450 PADSTACK padstack = Padstack();
451
452 google::protobuf::Any padStackWrapper;
453 padstack.Serialize( padStackWrapper );
454 padStackWrapper.UnpackTo( via.mutable_pad_stack() );
455
456
457
458 via.set_type( ToProtoEnum<VIATYPE, kiapi::board::types::ViaType>( GetViaType() ) );
459 via.set_locked( IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
460 : kiapi::common::types::LockedState::LS_UNLOCKED );
461 via.mutable_net()->mutable_code()->set_value( GetNetCode() );
462 via.mutable_net()->set_name( GetNetname() );
463
464 aContainer.PackFrom( via );
465}
466
467
468bool PCB_VIA::Deserialize( const google::protobuf::Any &aContainer )
469{
470 kiapi::board::types::Via via;
471
472 if( !aContainer.UnpackTo( &via ) )
473 return false;
474
475 const_cast<KIID&>( m_Uuid ) = KIID( via.id().value() );
476 SetStart( VECTOR2I( via.position().x_nm(), via.position().y_nm() ) );
477 SetEnd( GetStart() );
478 SetDrill( via.pad_stack().drill_diameter().x_nm() );
479
480 google::protobuf::Any padStackWrapper;
481 padStackWrapper.PackFrom( via.pad_stack() );
482
483 if( !m_padStack.Deserialize( padStackWrapper ) )
484 return false;
485
486 // We don't yet support complex padstacks for vias
488 SetViaType( FromProtoEnum<VIATYPE>( via.type() ) );
489 SetNetCode( via.net().code().value() );
490 SetLocked( via.locked() == kiapi::common::types::LockedState::LS_LOCKED );
491
492 return true;
493}
494
495
497{
498 SEG a( m_Start, m_End );
499 SEG b( aTrack.GetStart(), aTrack.GetEnd() );
500 return a.ApproxCollinear( b );
501}
502
503
505{
506 DRC_CONSTRAINT constraint;
507
508 if( GetBoard() && GetBoard()->GetDesignSettings().m_DRCEngine )
509 {
511
512 constraint = bds.m_DRCEngine->EvalRules( TRACK_WIDTH_CONSTRAINT, this, nullptr, m_layer );
513 }
514
515 if( aSource )
516 *aSource = constraint.GetName();
517
518 return constraint.Value();
519}
520
521
523{
524 DRC_CONSTRAINT constraint;
525
526 if( GetBoard() && GetBoard()->GetDesignSettings().m_DRCEngine )
527 {
529
530 constraint = bds.m_DRCEngine->EvalRules( VIA_DIAMETER_CONSTRAINT, this, nullptr, m_layer );
531 }
532
533 if( aSource )
534 *aSource = constraint.GetName();
535
536 return constraint.Value();
537}
538
539
541{
542 DRC_CONSTRAINT constraint;
543
544 if( GetBoard() && GetBoard()->GetDesignSettings().m_DRCEngine )
545 {
547
548 constraint = bds.m_DRCEngine->EvalRules( HOLE_SIZE_CONSTRAINT, this, nullptr, m_layer );
549 }
550
551 if( aSource )
552 *aSource = constraint.GetName();
553
554 return constraint.Value();
555}
556
557
558int PCB_VIA::GetMinAnnulus( PCB_LAYER_ID aLayer, wxString* aSource ) const
559{
560 if( !FlashLayer( aLayer ) )
561 {
562 if( aSource )
563 *aSource = _( "removed annular ring" );
564
565 return 0;
566 }
567
568 DRC_CONSTRAINT constraint;
569
570 if( GetBoard() && GetBoard()->GetDesignSettings().m_DRCEngine )
571 {
573
574 constraint = bds.m_DRCEngine->EvalRules( ANNULAR_WIDTH_CONSTRAINT, this, nullptr, aLayer );
575 }
576
577 if( constraint.Value().HasMin() )
578 {
579 if( aSource )
580 *aSource = constraint.GetName();
581
582 return constraint.Value().Min();
583 }
584
585 return 0;
586}
587
588
590{
591 if( m_padStack.Drill().size.x > 0 ) // Use the specific value.
592 return m_padStack.Drill().size.x;
593
594 // Use the default value from the Netclass
595 NETCLASS* netclass = GetEffectiveNetClass();
596
597 if( GetViaType() == VIATYPE::MICROVIA )
598 return netclass->GetuViaDrill();
599
600 return netclass->GetViaDrill();
601}
602
603
604EDA_ITEM_FLAGS PCB_TRACK::IsPointOnEnds( const VECTOR2I& point, int min_dist ) const
605{
606 EDA_ITEM_FLAGS result = 0;
607
608 if( min_dist < 0 )
609 min_dist = m_Width / 2;
610
611 if( min_dist == 0 )
612 {
613 if( m_Start == point )
614 result |= STARTPOINT;
615
616 if( m_End == point )
617 result |= ENDPOINT;
618 }
619 else
620 {
621 double dist = m_Start.Distance( point );
622
623 if( min_dist >= dist )
624 result |= STARTPOINT;
625
626 dist = m_End.Distance( point );
627
628 if( min_dist >= dist )
629 result |= ENDPOINT;
630 }
631
632 return result;
633}
634
635
637{
638 // end of track is round, this is its radius, rounded up
639 int radius = ( m_Width + 1 ) / 2;
640 int ymax, xmax, ymin, xmin;
641
642 if( Type() == PCB_VIA_T )
643 {
644 ymax = m_Start.y;
645 xmax = m_Start.x;
646
647 ymin = m_Start.y;
648 xmin = m_Start.x;
649 }
650 else if( Type() == PCB_ARC_T )
651 {
652 std::shared_ptr<SHAPE> arc = GetEffectiveShape();
653 BOX2I bbox = arc->BBox();
654
655 xmin = bbox.GetLeft();
656 xmax = bbox.GetRight();
657 ymin = bbox.GetTop();
658 ymax = bbox.GetBottom();
659 }
660 else
661 {
662 ymax = std::max( m_Start.y, m_End.y );
663 xmax = std::max( m_Start.x, m_End.x );
664
665 ymin = std::min( m_Start.y, m_End.y );
666 xmin = std::min( m_Start.x, m_End.x );
667 }
668
669 ymax += radius;
670 xmax += radius;
671
672 ymin -= radius;
673 xmin -= radius;
674
675 // return a rectangle which is [pos,dim) in nature. therefore the +1
676 return BOX2ISafe( VECTOR2I( xmin, ymin ),
677 VECTOR2L( (int64_t) xmax - xmin + 1, (int64_t) ymax - ymin + 1 ) );
678}
679
680
682{
683 return m_Start.Distance( m_End );
684}
685
686
687void PCB_TRACK::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
688{
689 RotatePoint( m_Start, aRotCentre, aAngle );
690 RotatePoint( m_End, aRotCentre, aAngle );
691}
692
693
694void PCB_ARC::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
695{
696 RotatePoint( m_Start, aRotCentre, aAngle );
697 RotatePoint( m_End, aRotCentre, aAngle );
698 RotatePoint( m_Mid, aRotCentre, aAngle );
699}
700
701
702void PCB_TRACK::Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
703{
704 MIRROR( m_Start, aCentre, aFlipDirection );
705 MIRROR( m_End, aCentre, aFlipDirection );
706}
707
708
709void PCB_ARC::Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
710{
711 MIRROR( m_Start, aCentre, aFlipDirection );
712 MIRROR( m_End, aCentre, aFlipDirection );
713 MIRROR( m_Mid, aCentre, aFlipDirection );
714}
715
716
717void PCB_TRACK::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
718{
719 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
720 {
721 m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
722 m_End.x = aCentre.x - ( m_End.x - aCentre.x );
723 }
724 else
725 {
726 m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
727 m_End.y = aCentre.y - ( m_End.y - aCentre.y );
728 }
729
731}
732
733
734void PCB_ARC::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
735{
736 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
737 {
738 m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
739 m_End.x = aCentre.x - ( m_End.x - aCentre.x );
740 m_Mid.x = aCentre.x - ( m_Mid.x - aCentre.x );
741 }
742 else
743 {
744 m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
745 m_End.y = aCentre.y - ( m_End.y - aCentre.y );
746 m_Mid.y = aCentre.y - ( m_Mid.y - aCentre.y );
747 }
748
750}
751
752
753bool PCB_ARC::IsCCW() const
754{
755 VECTOR2L start = m_Start;
756 VECTOR2L start_end = m_End - start;
757 VECTOR2L start_mid = m_Mid - start;
758
759 return start_end.Cross( start_mid ) < 0;
760}
761
762
763void PCB_VIA::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
764{
765 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
766 {
767 m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
768 m_End.x = aCentre.x - ( m_End.x - aCentre.x );
769 }
770 else
771 {
772 m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
773 m_End.y = aCentre.y - ( m_End.y - aCentre.y );
774 }
775
776 if( GetViaType() != VIATYPE::THROUGH )
777 {
778 PCB_LAYER_ID top_layer;
779 PCB_LAYER_ID bottom_layer;
780 LayerPair( &top_layer, &bottom_layer );
781 top_layer = GetBoard()->FlipLayer( top_layer );
782 bottom_layer = GetBoard()->FlipLayer( bottom_layer );
783 SetLayerPair( top_layer, bottom_layer );
784 }
785}
786
787
788INSPECT_RESULT PCB_TRACK::Visit( INSPECTOR inspector, void* testData,
789 const std::vector<KICAD_T>& aScanTypes )
790{
791 for( KICAD_T scanType : aScanTypes )
792 {
793 if( scanType == Type() )
794 {
795 if( INSPECT_RESULT::QUIT == inspector( this, testData ) )
796 return INSPECT_RESULT::QUIT;
797 }
798 }
799
800 return INSPECT_RESULT::CONTINUE;
801}
802
803
804std::shared_ptr<SHAPE_SEGMENT> PCB_VIA::GetEffectiveHoleShape() const
805{
806 return std::make_shared<SHAPE_SEGMENT>( SEG( m_Start, m_Start ), Padstack().Drill().size.x );
807}
808
809
811{
812 switch( aMode )
813 {
814 case TENTING_MODE::FROM_RULES: m_padStack.FrontOuterLayers().has_solder_mask.reset(); break;
815 case TENTING_MODE::TENTED: m_padStack.FrontOuterLayers().has_solder_mask = true; break;
816 case TENTING_MODE::NOT_TENTED: m_padStack.FrontOuterLayers().has_solder_mask = false; break;
817 }
818}
819
820
822{
824 {
826 TENTING_MODE::TENTED : TENTING_MODE::NOT_TENTED;
827 }
828
829 return TENTING_MODE::FROM_RULES;
830}
831
832
834{
835 switch( aMode )
836 {
837 case TENTING_MODE::FROM_RULES: m_padStack.BackOuterLayers().has_solder_mask.reset(); break;
838 case TENTING_MODE::TENTED: m_padStack.BackOuterLayers().has_solder_mask = true; break;
839 case TENTING_MODE::NOT_TENTED: m_padStack.BackOuterLayers().has_solder_mask = false; break;
840 }
841}
842
843
845{
846 if( m_padStack.BackOuterLayers().has_solder_mask.has_value() )
847 {
849 TENTING_MODE::TENTED : TENTING_MODE::NOT_TENTED;
850 }
851
852 return TENTING_MODE::FROM_RULES;
853}
854
855
856bool PCB_VIA::IsTented( PCB_LAYER_ID aLayer ) const
857{
858 wxCHECK_MSG( IsFrontLayer( aLayer ) || IsBackLayer( aLayer ), true,
859 "Invalid layer passed to IsTented" );
860
861 bool front = IsFrontLayer( aLayer );
862
863 if( front && m_padStack.FrontOuterLayers().has_solder_mask.has_value() )
865
866 if( !front && m_padStack.BackOuterLayers().has_solder_mask.has_value() )
868
869 if( const BOARD* board = GetBoard() )
870 {
871 return front ? board->GetDesignSettings().m_TentViasFront
872 : board->GetDesignSettings().m_TentViasBack;
873 }
874
875 return true;
876}
877
878
880{
881 if( const BOARD* board = GetBoard() )
882 return board->GetDesignSettings().m_SolderMaskExpansion;
883 else
884 return 0;
885}
886
887
889{
890 int margin = m_solderMaskMargin.value_or( 0 );
891
892 // If no local margin is set, get the board's solder mask expansion value
893 if( !m_solderMaskMargin.has_value() )
894 {
895 const BOARD* board = GetBoard();
896
897 if( board )
899 }
900
901 // Ensure the resulting mask opening has a non-negative size
902 if( margin < 0 )
903 margin = std::max( margin, -m_Width / 2 );
904
905 return margin;
906}
907
908
910{
911 if( aLayer == m_layer )
912 {
913 return true;
914 }
915
917 && ( ( aLayer == F_Mask && m_layer == F_Cu )
918 || ( aLayer == B_Mask && m_layer == B_Cu ) ) )
919 {
920 return true;
921 }
922
923 return false;
924}
925
926
928{
929#if 0
930 // Nice and simple, but raises its ugly head in performance profiles....
931 return GetLayerSet().test( aLayer );
932#endif
933 if( IsCopperLayer( aLayer ) &&
934 LAYER_RANGE::Contains( Padstack().Drill().start, Padstack().Drill().end, aLayer ) )
935 {
936 return true;
937 }
938
939 // Test for via on mask layers: a via on on a mask layer if not tented and if
940 // it is on the corresponding external copper layer
941 if( aLayer == F_Mask )
942 return Padstack().Drill().start == F_Cu && !IsTented( F_Mask );
943 else if( aLayer == B_Mask )
944 return Padstack().Drill().end == B_Cu && !IsTented( B_Mask );
945
946 return false;
947}
948
949
950bool PCB_VIA::HasValidLayerPair( int aCopperLayerCount )
951{
952 // return true if top and bottom layers are valid, depending on the copper layer count
953 // aCopperLayerCount is expected >= 2
954
955 int layer_id = aCopperLayerCount*2;
956
957 if( Padstack().Drill().start > B_Cu )
958 {
959 if( Padstack().Drill().start > layer_id )
960 return false;
961 }
962 if( Padstack().Drill().end > B_Cu )
963 {
964 if( Padstack().Drill().end > layer_id )
965 return false;
966 }
967
968 return true;
969}
970
971
973{
974 return Padstack().Drill().start;
975}
976
977
979{
980 Padstack().Drill().start = aLayer;
981}
982
983
984void PCB_TRACK::SetLayerSet( const LSET& aLayerSet )
985{
986 aLayerSet.RunOnLayers(
987 [&]( PCB_LAYER_ID layer )
988 {
989 if( IsCopperLayer( layer ) )
990 SetLayer( layer );
991 else if( IsSolderMaskLayer( layer ) )
992 SetHasSolderMask( true );
993 } );
994}
995
996
998{
999 LSET layermask( { m_layer } );
1000
1001 if( m_hasSolderMask )
1002 {
1003 if( layermask.test( F_Cu ) )
1004 layermask.set( F_Mask );
1005 else if( layermask.test( B_Cu ) )
1006 layermask.set( B_Mask );
1007 }
1008
1009 return layermask;
1010}
1011
1012
1014{
1015 LSET layermask;
1016
1017 if( Padstack().Drill().start < PCBNEW_LAYER_ID_START )
1018 return layermask;
1019
1020 if( GetViaType() == VIATYPE::THROUGH )
1021 {
1022 layermask = LSET::AllCuMask( BoardCopperLayerCount() );
1023 }
1024 else
1025 {
1026 LAYER_RANGE range( Padstack().Drill().start, Padstack().Drill().end, BoardCopperLayerCount() );
1027
1028 int cnt = BoardCopperLayerCount();
1029 // PCB_LAYER_IDs are numbered from front to back, this is top to bottom.
1030 for( PCB_LAYER_ID id : range )
1031 {
1032 layermask.set( id );
1033
1034 if( --cnt <= 0 )
1035 break;
1036 }
1037 }
1038
1039 if( !IsTented( F_Mask ) && layermask.test( F_Cu ) )
1040 layermask.set( F_Mask );
1041
1042 if( !IsTented( B_Mask ) && layermask.test( B_Cu ) )
1043 layermask.set( B_Mask );
1044
1045 return layermask;
1046}
1047
1048
1049void PCB_VIA::SetLayerSet( const LSET& aLayerSet )
1050{
1051 // Vias do not use a LSET, just a top and bottom layer pair
1052 // So we need to set these 2 layers according to the allowed layers in aLayerSet
1053
1054 // For via through, only F_Cu and B_Cu are allowed. aLayerSet is ignored
1055 if( GetViaType() == VIATYPE::THROUGH )
1056 {
1057 Padstack().Drill().start = F_Cu;
1058 Padstack().Drill().end = B_Cu;
1059 return;
1060 }
1061
1062 // For blind buried vias, find the top and bottom layers
1063 bool top_found = false;
1064 bool bottom_found = false;
1065
1066 aLayerSet.RunOnLayers(
1067 [&]( PCB_LAYER_ID layer )
1068 {
1069 // tpo layer and bottom Layer are copper layers, so consider only copper layers
1070 if( IsCopperLayer( layer ) )
1071 {
1072 // The top layer is the first layer found in list and
1073 // cannot the B_Cu
1074 if( !top_found && layer != B_Cu )
1075 {
1076 Padstack().Drill().start = layer;
1077 top_found = true;
1078 }
1079
1080 // The bottom layer is the last layer found in list or B_Cu
1081 if( !bottom_found )
1082 Padstack().Drill().end = layer;
1083
1084 if( layer == B_Cu )
1085 bottom_found = true;
1086 }
1087 } );
1088}
1089
1090
1091void PCB_VIA::SetLayerPair( PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer )
1092{
1093
1094 Padstack().Drill().start = aTopLayer;
1095 Padstack().Drill().end = aBottomLayer;
1097}
1098
1099
1101{
1102 Padstack().Drill().start = aLayer;
1103}
1104
1105
1107{
1108 Padstack().Drill().end = aLayer;
1109}
1110
1111
1112void PCB_VIA::LayerPair( PCB_LAYER_ID* top_layer, PCB_LAYER_ID* bottom_layer ) const
1113{
1114 PCB_LAYER_ID t_layer = F_Cu;
1115 PCB_LAYER_ID b_layer = B_Cu;
1116
1117 if( GetViaType() != VIATYPE::THROUGH )
1118 {
1119 b_layer = Padstack().Drill().end;
1120 t_layer = Padstack().Drill().start;
1121
1122 if( !IsCopperLayerLowerThan( b_layer, t_layer ) )
1123 std::swap( b_layer, t_layer );
1124 }
1125
1126 if( top_layer )
1127 *top_layer = t_layer;
1128
1129 if( bottom_layer )
1130 *bottom_layer = b_layer;
1131}
1132
1133
1135{
1136 return Padstack().Drill().start;
1137}
1138
1139
1141{
1142 return Padstack().Drill().end;
1143}
1144
1145
1147{
1148 if( GetViaType() == VIATYPE::THROUGH )
1149 {
1150 Padstack().Drill().start = F_Cu;
1151 Padstack().Drill().end = B_Cu;
1152 }
1153
1154 if( !IsCopperLayerLowerThan( Padstack().Drill().end, Padstack().Drill().start) )
1155 std::swap( Padstack().Drill().end, Padstack().Drill().start );
1156}
1157
1158
1159bool PCB_VIA::FlashLayer( LSET aLayers ) const
1160{
1161 for( size_t ii = 0; ii < aLayers.size(); ++ii )
1162 {
1163 if( aLayers.test( ii ) )
1164 {
1165 PCB_LAYER_ID layer = PCB_LAYER_ID( ii );
1166
1167 if( FlashLayer( layer ) )
1168 return true;
1169 }
1170 }
1171
1172 return false;
1173}
1174
1175
1176bool PCB_VIA::FlashLayer( int aLayer ) const
1177{
1178 // Return the "normal" shape if the caller doesn't specify a particular layer
1179 if( aLayer == UNDEFINED_LAYER )
1180 return true;
1181
1182 const BOARD* board = GetBoard();
1183
1184 if( !board )
1185 return true;
1186
1187 if( !IsOnLayer( static_cast<PCB_LAYER_ID>( aLayer ) ) )
1188 return false;
1189
1190 if( !IsCopperLayer( aLayer ) )
1191 return true;
1192
1193 switch( Padstack().UnconnectedLayerMode() )
1194 {
1196 return true;
1197
1199 {
1200 if( aLayer == Padstack().Drill().start || aLayer == Padstack().Drill().end )
1201 return true;
1202
1203 // Check for removal below
1204 break;
1205 }
1206
1208 // Check for removal below
1209 break;
1210 }
1211
1212 // Must be static to keep from raising its ugly head in performance profiles
1213 static std::initializer_list<KICAD_T> connectedTypes = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T,
1214 PCB_PAD_T };
1215
1216 if( GetZoneLayerOverride( static_cast<PCB_LAYER_ID>( aLayer ) ) == ZLO_FORCE_FLASHED )
1217 return true;
1218 else
1219 return board->GetConnectivity()->IsConnectedOnLayer( this, static_cast<PCB_LAYER_ID>( aLayer ), connectedTypes );
1220}
1221
1222
1224{
1225 std::unique_lock<std::mutex> cacheLock( m_zoneLayerOverridesMutex );
1226
1229}
1230
1231
1233{
1234 static const ZONE_LAYER_OVERRIDE defaultOverride = ZLO_NONE;
1235 auto it = m_zoneLayerOverrides.find( aLayer );
1236 return it != m_zoneLayerOverrides.end() ? it->second : defaultOverride;
1237}
1238
1239
1241{
1242 std::unique_lock<std::mutex> cacheLock( m_zoneLayerOverridesMutex );
1243 m_zoneLayerOverrides[aLayer] = aOverride;
1244}
1245
1246
1248 PCB_LAYER_ID* aBottommost ) const
1249{
1250 *aTopmost = UNDEFINED_LAYER;
1251 *aBottommost = UNDEFINED_LAYER;
1252
1253 static std::initializer_list<KICAD_T> connectedTypes = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T,
1254 PCB_PAD_T };
1255
1256 for( int layer = TopLayer(); layer <= BottomLayer(); ++layer )
1257 {
1258 bool connected = false;
1259
1260 if( GetZoneLayerOverride( static_cast<PCB_LAYER_ID>( layer ) ) == ZLO_FORCE_FLASHED )
1261 connected = true;
1262 else if( GetBoard()->GetConnectivity()->IsConnectedOnLayer( this, layer, connectedTypes ) )
1263 connected = true;
1264
1265 if( connected )
1266 {
1267 if( *aTopmost == UNDEFINED_LAYER )
1268 *aTopmost = ToLAYER_ID( layer );
1269
1270 *aBottommost = ToLAYER_ID( layer );
1271 }
1272 }
1273
1274}
1275
1276
1277void PCB_TRACK::ViewGetLayers( int aLayers[], int& aCount ) const
1278{
1279 // Show the track and its netname on different layers
1280 aLayers[0] = GetLayer();
1281 aLayers[1] = GetNetnameLayer( aLayers[0] );
1282 aCount = 2;
1283
1284 if( m_hasSolderMask )
1285 {
1286 if( m_layer == F_Cu )
1287 aLayers[ aCount++ ] = F_Mask;
1288 else if( m_layer == B_Cu )
1289 aLayers[ aCount++ ] = B_Mask;
1290 }
1291
1292 if( IsLocked() )
1293 aLayers[ aCount++ ] = LAYER_LOCKED_ITEM_SHADOW;
1294}
1295
1296
1297double PCB_TRACK::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
1298{
1299 constexpr double HIDE = std::numeric_limits<double>::max();
1300
1301 PCB_PAINTER* painter = static_cast<PCB_PAINTER*>( aView->GetPainter() );
1302 PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
1303
1304 if( !aView->IsLayerVisible( LAYER_TRACKS ) )
1305 return HIDE;
1306
1307 if( IsNetnameLayer( aLayer ) )
1308 {
1310 return HIDE;
1311
1312 // Hide netnames on dimmed tracks
1313 if( renderSettings->GetHighContrast() )
1314 {
1315 if( m_layer != renderSettings->GetPrimaryHighContrastLayer() )
1316 return HIDE;
1317 }
1318
1319 VECTOR2I start( GetStart() );
1320 VECTOR2I end( GetEnd() );
1321
1322 // Calc the approximate size of the netname (assume square chars)
1323 SEG::ecoord nameSize = GetDisplayNetname().size() * GetWidth();
1324
1325 if( VECTOR2I( end - start ).SquaredEuclideanNorm() < nameSize * nameSize )
1326 return HIDE;
1327
1328 BOX2I clipBox = BOX2ISafe( aView->GetViewport() );
1329
1330 ClipLine( &clipBox, start.x, start.y, end.x, end.y );
1331
1332 if( VECTOR2I( end - start ).SquaredEuclideanNorm() == 0 )
1333 return HIDE;
1334
1335 // Netnames will be shown only if zoom is appropriate
1336 return ( double ) pcbIUScale.mmToIU( 4 ) / ( m_Width + 1 );
1337 }
1338
1339 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
1340 {
1341 // Hide shadow if the main layer is not shown
1342 if( !aView->IsLayerVisible( m_layer ) )
1343 return HIDE;
1344
1345 // Hide shadow on dimmed tracks
1346 if( renderSettings->GetHighContrast() )
1347 {
1348 if( m_layer != renderSettings->GetPrimaryHighContrastLayer() )
1349 return HIDE;
1350 }
1351 }
1352
1353 // Other layers are shown without any conditions
1354 return 0.0;
1355}
1356
1357
1359{
1360 BOX2I bbox = GetBoundingBox();
1361
1362 if( const BOARD* board = GetBoard() )
1363 bbox.Inflate( 2 * board->GetDesignSettings().GetBiggestClearanceValue() );
1364 else
1365 bbox.Inflate( GetWidth() ); // Add a bit extra for safety
1366
1367 return bbox;
1368}
1369
1370
1371void PCB_VIA::ViewGetLayers( int aLayers[], int& aCount ) const
1372{
1373 // TODO(JE) Rendering order issue
1374#if 0
1375 // Blind/buried vias (and microvias) use a different net name layer
1376 PCB_LAYER_ID layerTop, layerBottom;
1377 LayerPair( &layerTop, &layerBottom );
1378
1379 bool isBlindBuried =
1380 m_viaType == VIATYPE::BLIND_BURIED
1381 || ( m_viaType == VIATYPE::MICROVIA && ( layerTop != F_Cu || layerBottom != B_Cu ) );
1382#endif
1383
1384 aLayers[0] = LAYER_VIA_HOLES;
1385 aLayers[1] = LAYER_VIA_HOLEWALLS;
1386 aLayers[2] = LAYER_VIA_NETNAMES;
1387 aCount = 3;
1388
1389 LAYER_RANGE layers( Padstack().Drill().start, Padstack().Drill().end, MAX_CU_LAYERS );
1390
1391 for( PCB_LAYER_ID layer : layers )
1392 aLayers[aCount++] = layer;
1393
1394 if( IsLocked() )
1395 aLayers[ aCount++ ] = LAYER_LOCKED_ITEM_SHADOW;
1396
1397 // Vias can also be on a solder mask layer. They are on these layers or not,
1398 // depending on the plot and solder mask options
1399 if( IsOnLayer( F_Mask ) )
1400 aLayers[ aCount++ ] = F_Mask;
1401
1402 if( IsOnLayer( B_Mask ) )
1403 aLayers[ aCount++ ] = B_Mask;
1404}
1405
1406
1407double PCB_VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
1408{
1409 constexpr double HIDE = (double)std::numeric_limits<double>::max();
1410
1411 PCB_PAINTER* painter = static_cast<PCB_PAINTER*>( aView->GetPainter() );
1412 PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
1413 LSET visible = LSET::AllLayersMask();
1414
1415 // Meta control for hiding all vias
1416 if( !aView->IsLayerVisible( LAYER_VIAS ) )
1417 return HIDE;
1418
1419 // Handle board visibility
1420 if( const BOARD* board = GetBoard() )
1421 visible = board->GetVisibleLayers() & board->GetEnabledLayers();
1422
1423 int width = GetWidth( ToLAYER_ID( aLayer ) );
1424
1425 // In high contrast mode don't show vias that don't cross the high-contrast layer
1426 if( renderSettings->GetHighContrast() )
1427 {
1428 PCB_LAYER_ID highContrastLayer = renderSettings->GetPrimaryHighContrastLayer();
1429
1430 if( LSET::FrontTechMask().Contains( highContrastLayer ) )
1431 highContrastLayer = F_Cu;
1432 else if( LSET::BackTechMask().Contains( highContrastLayer ) )
1433 highContrastLayer = B_Cu;
1434
1435 if( !IsCopperLayer( highContrastLayer ) )
1436 return HIDE;
1437
1438 if( GetViaType() != VIATYPE::THROUGH )
1439 {
1440 if( IsCopperLayerLowerThan( Padstack().Drill().start, highContrastLayer )
1441 || IsCopperLayerLowerThan( highContrastLayer, Padstack().Drill().end ) )
1442 {
1443 return HIDE;
1444 }
1445 }
1446 }
1447
1448 if( IsHoleLayer( aLayer ) )
1449 {
1450 if( m_viaType == VIATYPE::THROUGH )
1451 {
1452 // Show a through via's hole if any physical layer is shown
1453 if( !( visible & LSET::PhysicalLayersMask() ).any() )
1454 return HIDE;
1455 }
1456 else
1457 {
1458 // Show a blind or micro via's hole if it crosses a visible layer
1459 if( !( visible & GetLayerSet() ).any() )
1460 return HIDE;
1461 }
1462
1463 // The hole won't be visible anyway at this scale
1464 return (double) pcbIUScale.mmToIU( 0.25 ) / GetDrillValue();
1465 }
1466 else if( IsNetnameLayer( aLayer ) )
1467 {
1468 if( renderSettings->GetHighContrast() )
1469 {
1470 // Hide netnames unless via is flashed to a high-contrast layer
1471 if( !FlashLayer( renderSettings->GetPrimaryHighContrastLayer() ) )
1472 return HIDE;
1473 }
1474 else
1475 {
1476 // Hide netnames unless pad is flashed to a visible layer
1477 if( !FlashLayer( visible ) )
1478 return HIDE;
1479 }
1480
1481 // Netnames will be shown only if zoom is appropriate
1482 return width == 0 ? HIDE : ( (double)pcbIUScale.mmToIU( 10 ) / width );
1483 }
1484
1485 if( !IsCopperLayer( aLayer ) )
1486 return (double) pcbIUScale.mmToIU( 0.6 ) / width;
1487
1488 return 0.0;
1489}
1490
1491
1493{
1494 switch( Type() )
1495 {
1496 case PCB_ARC_T: return _( "Track (arc)" );
1497 case PCB_VIA_T: return _( "Via" );
1498 case PCB_TRACE_T:
1499 default: return _( "Track" );
1500 }
1501}
1502
1503
1504void PCB_TRACK::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
1505{
1506 wxString msg;
1507 BOARD* board = GetBoard();
1508
1509 aList.emplace_back( _( "Type" ), GetFriendlyName() );
1510
1511 GetMsgPanelInfoBase_Common( aFrame, aList );
1512
1513 aList.emplace_back( _( "Layer" ), layerMaskDescribe() );
1514
1515 aList.emplace_back( _( "Width" ), aFrame->MessageTextFromValue( m_Width ) );
1516
1517 if( Type() == PCB_ARC_T )
1518 {
1519 double radius = static_cast<PCB_ARC*>( this )->GetRadius();
1520 aList.emplace_back( _( "Radius" ), aFrame->MessageTextFromValue( radius ) );
1521 }
1522
1523 aList.emplace_back( _( "Segment Length" ), aFrame->MessageTextFromValue( GetLength() ) );
1524
1525 // Display full track length (in Pcbnew)
1526 if( board && GetNetCode() > 0 )
1527 {
1528 int count;
1529 double trackLen;
1530 double lenPadToDie;
1531
1532 std::tie( count, trackLen, lenPadToDie ) = board->GetTrackLength( *this );
1533
1534 aList.emplace_back( _( "Routed Length" ), aFrame->MessageTextFromValue( trackLen ) );
1535
1536 if( lenPadToDie != 0 )
1537 {
1538 msg = aFrame->MessageTextFromValue( lenPadToDie );
1539 aList.emplace_back( _( "Pad To Die Length" ), msg );
1540
1541 msg = aFrame->MessageTextFromValue( trackLen + lenPadToDie );
1542 aList.emplace_back( _( "Full Length" ), msg );
1543 }
1544 }
1545
1546 wxString source;
1547 int clearance = GetOwnClearance( GetLayer(), &source );
1548
1549 aList.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
1550 aFrame->MessageTextFromValue( clearance ) ),
1551 wxString::Format( _( "(from %s)" ), source ) );
1552
1553 MINOPTMAX<int> constraintValue = GetWidthConstraint( &source );
1554 msg = aFrame->MessageTextFromMinOptMax( constraintValue );
1555
1556 if( !msg.IsEmpty() )
1557 {
1558 aList.emplace_back( wxString::Format( _( "Width Constraints: %s" ), msg ),
1559 wxString::Format( _( "(from %s)" ), source ) );
1560 }
1561}
1562
1563
1564void PCB_VIA::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
1565{
1566 wxString msg;
1567
1568 switch( GetViaType() )
1569 {
1570 case VIATYPE::MICROVIA: msg = _( "Micro Via" ); break;
1571 case VIATYPE::BLIND_BURIED: msg = _( "Blind/Buried Via" ); break;
1572 case VIATYPE::THROUGH: msg = _( "Through Via" ); break;
1573 default: msg = _( "Via" ); break;
1574 }
1575
1576 aList.emplace_back( _( "Type" ), msg );
1577
1578 GetMsgPanelInfoBase_Common( aFrame, aList );
1579
1580 aList.emplace_back( _( "Layer" ), layerMaskDescribe() );
1581 // TODO(JE) padstacks
1582 aList.emplace_back( _( "Diameter" ),
1584 aList.emplace_back( _( "Hole" ), aFrame->MessageTextFromValue( GetDrillValue() ) );
1585
1586 wxString source;
1587 int clearance = GetOwnClearance( GetLayer(), &source );
1588
1589 aList.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
1590 aFrame->MessageTextFromValue( clearance ) ),
1591 wxString::Format( _( "(from %s)" ), source ) );
1592
1593 int minAnnulus = GetMinAnnulus( GetLayer(), &source );
1594
1595 aList.emplace_back( wxString::Format( _( "Min Annular Width: %s" ),
1596 aFrame->MessageTextFromValue( minAnnulus ) ),
1597 wxString::Format( _( "(from %s)" ), source ) );
1598}
1599
1600
1602 std::vector<MSG_PANEL_ITEM>& aList ) const
1603{
1604 aList.emplace_back( _( "Net" ), UnescapeString( GetNetname() ) );
1605
1606 aList.emplace_back( _( "Resolved Netclass" ),
1607 UnescapeString( GetEffectiveNetClass()->GetName() ) );
1608
1609#if 0 // Enable for debugging
1610 if( GetBoard() )
1611 aList.emplace_back( _( "NetCode" ), wxString::Format( wxT( "%d" ), GetNetCode() ) );
1612
1613 aList.emplace_back( wxT( "Flags" ), wxString::Format( wxT( "0x%08X" ), m_flags ) );
1614
1615 aList.emplace_back( wxT( "Start pos" ), wxString::Format( wxT( "%d %d" ),
1616 m_Start.x,
1617 m_Start.y ) );
1618 aList.emplace_back( wxT( "End pos" ), wxString::Format( wxT( "%d %d" ),
1619 m_End.x,
1620 m_End.y ) );
1621#endif
1622
1623 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
1624 aList.emplace_back( _( "Status" ), _( "Locked" ) );
1625}
1626
1627
1629{
1630 const BOARD* board = GetBoard();
1631 PCB_LAYER_ID top_layer;
1632 PCB_LAYER_ID bottom_layer;
1633
1634 LayerPair( &top_layer, &bottom_layer );
1635
1636 return board->GetLayerName( top_layer ) + wxT( " - " ) + board->GetLayerName( bottom_layer );
1637}
1638
1639
1640bool PCB_TRACK::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
1641{
1642 return TestSegmentHit( aPosition, m_Start, m_End, aAccuracy + ( m_Width / 2 ) );
1643}
1644
1645
1646bool PCB_ARC::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
1647{
1648 double max_dist = aAccuracy + ( m_Width / 2.0 );
1649
1650 // Short-circuit common cases where the arc is connected to a track or via at an endpoint
1651 if( GetStart().Distance( aPosition ) <= max_dist || GetEnd().Distance( aPosition ) <= max_dist )
1652 {
1653 return true;
1654 }
1655
1656 VECTOR2L center = GetPosition();
1657 VECTOR2L relpos = aPosition - center;
1658 int64_t dist = relpos.EuclideanNorm();
1659 double radius = GetRadius();
1660
1661 if( std::abs( dist - radius ) > max_dist )
1662 return false;
1663
1664 EDA_ANGLE arc_angle = GetAngle();
1665 EDA_ANGLE arc_angle_start = GetArcAngleStart(); // Always 0.0 ... 360 deg
1666 EDA_ANGLE arc_hittest( relpos );
1667
1668 // Calculate relative angle between the starting point of the arc, and the test point
1669 arc_hittest -= arc_angle_start;
1670
1671 // Normalise arc_hittest between 0 ... 360 deg
1672 arc_hittest.Normalize();
1673
1674 if( arc_angle < ANGLE_0 )
1675 return arc_hittest >= ANGLE_360 + arc_angle;
1676
1677 return arc_hittest <= arc_angle;
1678}
1679
1680
1681bool PCB_VIA::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
1682{
1683 bool hit = false;
1684
1686 [&]( PCB_LAYER_ID aLayer )
1687 {
1688 if( hit )
1689 return;
1690
1691 int max_dist = aAccuracy + ( GetWidth( aLayer ) / 2 );
1692
1693 // rel_pos is aPosition relative to m_Start (or the center of the via)
1694 VECTOR2D rel_pos = aPosition - m_Start;
1695 double dist = rel_pos.x * rel_pos.x + rel_pos.y * rel_pos.y;
1696
1697 if( dist <= static_cast<double>( max_dist ) * max_dist )
1698 hit = true;
1699 } );
1700
1701 return hit;
1702}
1703
1704
1705bool PCB_TRACK::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
1706{
1707 BOX2I arect = aRect;
1708 arect.Inflate( aAccuracy );
1709
1710 if( aContained )
1711 return arect.Contains( GetStart() ) && arect.Contains( GetEnd() );
1712 else
1713 return arect.Intersects( GetStart(), GetEnd() );
1714}
1715
1716
1717bool PCB_ARC::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
1718{
1719 BOX2I arect = aRect;
1720 arect.Inflate( aAccuracy );
1721
1722 BOX2I box( GetStart() );
1723 box.Merge( GetMid() );
1724 box.Merge( GetEnd() );
1725
1726 box.Inflate( GetWidth() / 2 );
1727
1728 if( aContained )
1729 return arect.Contains( box );
1730 else
1731 return arect.Intersects( box );
1732}
1733
1734
1735bool PCB_VIA::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
1736{
1737 BOX2I arect = aRect;
1738 arect.Inflate( aAccuracy );
1739
1740 bool hit = false;
1741
1743 [&]( PCB_LAYER_ID aLayer )
1744 {
1745 if( hit )
1746 return;
1747
1748 BOX2I box( GetStart() );
1749 box.Inflate( GetWidth( aLayer ) / 2 );
1750
1751 if( aContained )
1752 hit = arect.Contains( box );
1753 else
1754 hit = arect.IntersectsCircle( GetStart(), GetWidth( aLayer ) / 2 );
1755 } );
1756
1757 return hit;
1758}
1759
1760
1761wxString PCB_TRACK::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
1762{
1763 return wxString::Format( Type() == PCB_ARC_T ? _("Track (arc) %s on %s, length %s" )
1764 : _("Track %s on %s, length %s" ),
1765 GetNetnameMsg(),
1766 GetLayerName(),
1767 aUnitsProvider->MessageTextFromValue( GetLength() ) );
1768}
1769
1770
1772{
1773 return BITMAPS::add_tracks;
1774}
1775
1777{
1778 assert( aImage->Type() == PCB_TRACE_T );
1779
1780 std::swap( *((PCB_TRACK*) this), *((PCB_TRACK*) aImage) );
1781}
1782
1784{
1785 assert( aImage->Type() == PCB_ARC_T );
1786
1787 std::swap( *this, *static_cast<PCB_ARC*>( aImage ) );
1788}
1789
1791{
1792 assert( aImage->Type() == PCB_VIA_T );
1793
1794 std::swap( *((PCB_VIA*) this), *((PCB_VIA*) aImage) );
1795}
1796
1797
1799{
1801 return center;
1802}
1803
1804
1806{
1807 auto center = CalcArcCenter( m_Start, m_Mid , m_End );
1808 return center.Distance( m_Start );
1809}
1810
1811
1813{
1814 VECTOR2D center = GetPosition();
1815 EDA_ANGLE angle1 = EDA_ANGLE( m_Mid - center ) - EDA_ANGLE( m_Start - center );
1816 EDA_ANGLE angle2 = EDA_ANGLE( m_End - center ) - EDA_ANGLE( m_Mid - center );
1817
1818 return angle1.Normalize180() + angle2.Normalize180();
1819}
1820
1821
1823{
1824 VECTOR2D pos( GetPosition() );
1825 EDA_ANGLE angleStart( m_Start - pos );
1826
1827 return angleStart.Normalize();
1828}
1829
1830
1831// Note: used in python tests. Ignore CLion's claim that it's unused....
1833{
1834 VECTOR2D pos( GetPosition() );
1835 EDA_ANGLE angleEnd( m_End - pos );
1836
1837 return angleEnd.Normalize();
1838}
1839
1840bool PCB_ARC::IsDegenerated( int aThreshold ) const
1841{
1842 // Too small arcs cannot be really handled: arc center (and arc radius)
1843 // cannot be safely computed if the distance between mid and end points
1844 // is too small (a few internal units)
1845
1846 // len of both segments must be < aThreshold to be a very small degenerated arc
1847 return ( GetMid() - GetStart() ).EuclideanNorm() < aThreshold
1848 && ( GetMid() - GetEnd() ).EuclideanNorm() < aThreshold;
1849}
1850
1851
1853{
1854 if( a->GetNetCode() != b->GetNetCode() )
1855 return a->GetNetCode() < b->GetNetCode();
1856
1857 if( a->GetLayer() != b->GetLayer() )
1858 return a->GetLayer() < b->GetLayer();
1859
1860 if( a->Type() != b->Type() )
1861 return a->Type() < b->Type();
1862
1863 if( a->m_Uuid != b->m_Uuid )
1864 return a->m_Uuid < b->m_Uuid;
1865
1866 return a < b;
1867}
1868
1869
1870std::shared_ptr<SHAPE> PCB_TRACK::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
1871{
1872 int width = m_Width;
1873
1874 if( IsSolderMaskLayer( aLayer ) )
1875 width += 2 * GetSolderMaskExpansion();
1876
1877 return std::make_shared<SHAPE_SEGMENT>( m_Start, m_End, width );
1878}
1879
1880
1881std::shared_ptr<SHAPE> PCB_VIA::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
1882{
1883 if( aFlash == FLASHING::ALWAYS_FLASHED
1884 || ( aFlash == FLASHING::DEFAULT && FlashLayer( aLayer ) ) )
1885 {
1886 PCB_LAYER_ID cuLayer = m_padStack.EffectiveLayerFor( aLayer );
1887 return std::make_shared<SHAPE_CIRCLE>( m_Start, GetWidth( cuLayer ) / 2 );
1888 }
1889 else
1890 {
1891 return std::make_shared<SHAPE_CIRCLE>( m_Start, GetDrillValue() / 2 );
1892 }
1893}
1894
1895
1896std::shared_ptr<SHAPE> PCB_ARC::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
1897{
1898 int width = GetWidth();
1899
1900 if( IsSolderMaskLayer( aLayer ) )
1901 width += 2 * GetSolderMaskExpansion();
1902
1903 return std::make_shared<SHAPE_ARC>( GetStart(), GetMid(), GetEnd(), width );
1904}
1905
1906
1908 int aClearance, int aError, ERROR_LOC aErrorLoc,
1909 bool ignoreLineWidth ) const
1910{
1911 wxASSERT_MSG( !ignoreLineWidth, wxT( "IgnoreLineWidth has no meaning for tracks." ) );
1912
1913
1914 switch( Type() )
1915 {
1916 case PCB_VIA_T:
1917 {
1918 int radius = ( static_cast<const PCB_VIA*>( this )->GetWidth( aLayer ) / 2 ) + aClearance;
1919 TransformCircleToPolygon( aBuffer, m_Start, radius, aError, aErrorLoc );
1920 break;
1921 }
1922
1923 case PCB_ARC_T:
1924 {
1925 const PCB_ARC* arc = static_cast<const PCB_ARC*>( this );
1926 int width = m_Width + ( 2 * aClearance );
1927
1928 if( IsSolderMaskLayer( aLayer ) )
1929 width += 2 * GetSolderMaskExpansion();
1930
1931 TransformArcToPolygon( aBuffer, arc->GetStart(), arc->GetMid(), arc->GetEnd(), width,
1932 aError, aErrorLoc );
1933 break;
1934 }
1935
1936 default:
1937 {
1938 int width = m_Width + ( 2 * aClearance );
1939
1940 if( IsSolderMaskLayer( aLayer ) )
1941 width += 2 * GetSolderMaskExpansion();
1942
1943 TransformOvalToPolygon( aBuffer, m_Start, m_End, width, aError, aErrorLoc );
1944
1945 break;
1946 }
1947 }
1948}
1949
1950
1951static struct TRACK_VIA_DESC
1952{
1954 {
1956 .Undefined( VIATYPE::NOT_DEFINED )
1957 .Map( VIATYPE::THROUGH, _HKI( "Through" ) )
1958 .Map( VIATYPE::BLIND_BURIED, _HKI( "Blind/buried" ) )
1959 .Map( VIATYPE::MICROVIA, _HKI( "Micro" ) );
1960
1962 .Undefined( TENTING_MODE::FROM_RULES )
1963 .Map( TENTING_MODE::FROM_RULES, _HKI( "From design rules" ) )
1964 .Map( TENTING_MODE::TENTED, _HKI( "Tented" ) )
1965 .Map( TENTING_MODE::NOT_TENTED, _HKI( "Not tented" ) );
1966
1968
1969 if( layerEnum.Choices().GetCount() == 0 )
1970 {
1971 layerEnum.Undefined( UNDEFINED_LAYER );
1972
1973 for( PCB_LAYER_ID layer : LSET::AllLayersMask().Seq() )
1974 layerEnum.Map( layer, LSET::Name( layer ) );
1975 }
1976
1978
1979 // Track
1982
1983 propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "Width" ),
1984 &PCB_TRACK::SetWidth, &PCB_TRACK::GetWidth, PROPERTY_DISPLAY::PT_SIZE ) );
1985 propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position X" ),
1987 &PCB_TRACK::SetX, &PCB_TRACK::GetX, PROPERTY_DISPLAY::PT_COORD,
1989 propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position Y" ),
1991 &PCB_TRACK::SetY, &PCB_TRACK::GetY, PROPERTY_DISPLAY::PT_COORD,
1993 propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "End X" ),
1994 &PCB_TRACK::SetEndX, &PCB_TRACK::GetEndX, PROPERTY_DISPLAY::PT_COORD,
1996 propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "End Y" ),
1997 &PCB_TRACK::SetEndY, &PCB_TRACK::GetEndY, PROPERTY_DISPLAY::PT_COORD,
1999
2000 const wxString groupTechLayers = _HKI( "Technical Layers" );
2001
2002 auto isExternalLayerTrack =
2003 []( INSPECTABLE* aItem )
2004 {
2005 if( auto track = dynamic_cast<PCB_TRACK*>( aItem ) )
2006 return track->GetLayer() == F_Cu || track->GetLayer() == B_Cu;
2007
2008 return false;
2009 };
2010
2011 propMgr.AddProperty( new PROPERTY<PCB_TRACK, bool>( _HKI( "Soldermask" ),
2013 .SetAvailableFunc( isExternalLayerTrack );
2014 propMgr.AddProperty( new PROPERTY<PCB_TRACK, std::optional<int>>( _HKI( "Soldermask Margin Override" ),
2016 PROPERTY_DISPLAY::PT_SIZE ), groupTechLayers )
2017 .SetAvailableFunc( isExternalLayerTrack );
2018
2019 // Arc
2022
2023 // Via
2026
2027 // TODO test drill, use getdrillvalue?
2028 const wxString groupVia = _HKI( "Via Properties" );
2029
2030 propMgr.Mask( TYPE_HASH( PCB_VIA ), TYPE_HASH( BOARD_CONNECTED_ITEM ), _HKI( "Layer" ) );
2031
2032 propMgr.AddProperty( new PROPERTY<PCB_VIA, int>( _HKI( "Diameter" ),
2033 &PCB_VIA::SetFrontWidth, &PCB_VIA::GetFrontWidth, PROPERTY_DISPLAY::PT_SIZE ), groupVia );
2034 propMgr.AddProperty( new PROPERTY<PCB_VIA, int>( _HKI( "Hole" ),
2035 &PCB_VIA::SetDrill, &PCB_VIA::GetDrillValue, PROPERTY_DISPLAY::PT_SIZE ), groupVia );
2036 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, PCB_LAYER_ID>( _HKI( "Layer Top" ),
2037 &PCB_VIA::SetLayer, &PCB_VIA::GetLayer ), groupVia );
2038 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, PCB_LAYER_ID>( _HKI( "Layer Bottom" ),
2040 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, VIATYPE>( _HKI( "Via Type" ),
2042 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, TENTING_MODE>( _HKI( "Front tenting" ),
2044 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, TENTING_MODE>( _HKI( "Back tenting" ),
2046 }
2048
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
Definition: approximation.h:32
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:108
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
ZONE_LAYER_OVERRIDE
Conditionally flashed vias and pads that interact with zones of different priority can be very squirr...
Definition: board_item.h:67
@ ZLO_NONE
Definition: board_item.h:68
@ ZLO_FORCE_FLASHED
Definition: board_item.h:69
constexpr BOX2I BOX2ISafe(const BOX2D &aInput)
Definition: box2.h:929
BASE_SET & reset(size_t pos)
Definition: base_set.h:142
BASE_SET & set(size_t pos)
Definition: base_set.h:115
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
wxString GetNetnameMsg() const
virtual NETCLASS * GetEffectiveNetClass() const
Return the NETCLASS for this item.
bool SetNetCode(int aNetCode, bool aNoAssert)
Set net using a net code.
const wxString & GetDisplayNetname() const
virtual int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const
Return an item's "own" clearance in internal units.
Container for design settings for a BOARD object.
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:80
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:238
int GetY() const
Definition: board_item.h:101
virtual void SetLocked(bool aLocked)
Definition: board_item.h:329
PCB_LAYER_ID m_layer
Definition: board_item.h:435
int GetX() const
Definition: board_item.h:95
void SetX(int aX)
Definition: board_item.h:117
void SetY(int aY)
Definition: board_item.h:123
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:289
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:47
virtual bool IsLocked() const
Definition: board_item.cpp:75
virtual int BoardCopperLayerCount() const
Return the total number of copper layers for the board that this item resides on.
Definition: board_item.cpp:117
virtual wxString layerMaskDescribe() const
Return a string (to be shown to the user) describing a layer mask.
Definition: board_item.cpp:166
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Definition: board_item.cpp:139
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:290
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayer) const
Definition: board.cpp:730
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:577
std::tuple< int, double, double > GetTrackLength(const PCB_TRACK &aTrack) const
Return data on the length and number of track segments connected to a given track.
Definition: board.cpp:2296
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:890
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:475
constexpr BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:558
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h:658
bool IntersectsCircle(const Vec &aCenter, const int aRadius) const
Definition: box2.h:504
constexpr coord_type GetLeft() const
Definition: box2.h:228
constexpr bool Contains(const Vec &aPoint) const
Definition: box2.h:168
constexpr coord_type GetRight() const
Definition: box2.h:217
constexpr coord_type GetTop() const
Definition: box2.h:229
constexpr bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:311
constexpr coord_type GetBottom() const
Definition: box2.h:222
wxString GetName() const
Definition: drc_rule.h:156
MINOPTMAX< int > & Value()
Definition: drc_rule.h:149
EDA_ANGLE Normalize()
Definition: eda_angle.h:221
EDA_ANGLE Normalize180()
Definition: eda_angle.h:260
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
EDA_ITEM & operator=(const EDA_ITEM &aItem)
Assign the members of aItem to another object.
Definition: eda_item.cpp:261
const KIID m_Uuid
Definition: eda_item.h:489
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:499
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:669
static ENUM_MAP< T > & Instance()
Definition: property.h:663
ENUM_MAP & Undefined(T aValue)
Definition: property.h:676
wxPGChoices & Choices()
Definition: property.h:712
Class that other classes need to inherit from, in order to be inspectable.
Definition: inspectable.h:36
Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:173
virtual PCB_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
Definition: pcb_painter.h:178
PCB specific render settings.
Definition: pcb_painter.h:78
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
Return the board layer which is in high-contrast mode.
bool GetHighContrast() const
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition: view.cpp:547
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:418
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:221
Definition: kiid.h:49
std::string AsStdString() const
Definition: kiid.cpp:244
static bool Contains(int aStart_layer, int aEnd_layer, int aTest_layer)
Definition: layer_range.h:130
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:36
static LSET AllLayersMask()
Definition: lset.cpp:701
void RunOnLayers(const std::function< void(PCB_LAYER_ID)> &aFunction) const
Execute a function on each layer of the LSET.
Definition: lset.h:241
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:676
static LSET PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
Definition: lset.cpp:756
static LSET FrontTechMask()
Return a mask holding all technical layers (no CU layer) on front side.
Definition: lset.cpp:720
static LSET BackTechMask()
Return a mask holding all technical layers (no CU layer) on back side.
Definition: lset.cpp:708
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition: lset.cpp:183
T Min() const
Definition: minoptmax.h:33
bool HasMin() const
Definition: minoptmax.h:37
A collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:44
int GetViaDrill() const
Definition: netclass.h:128
int GetuViaDrill() const
Definition: netclass.h:144
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Definition: netinfo.h:381
A PADSTACK defines the characteristics of a single or multi-layer pad, in the IPC sense of the word.
Definition: padstack.h:118
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: padstack.cpp:144
MASK_LAYER_PROPS & FrontOuterLayers()
Definition: padstack.h:300
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::...
Definition: padstack.cpp:763
void SetUnconnectedLayerMode(UNCONNECTED_LAYER_MODE aMode)
Definition: padstack.h:295
const LSET & LayerSet() const
Definition: padstack.h:268
void SetShape(PAD_SHAPE aShape, PCB_LAYER_ID aLayer)
Definition: padstack.cpp:862
DRILL_PROPS & Drill()
Definition: padstack.h:288
const VECTOR2I & Size(PCB_LAYER_ID aLayer) const
Definition: padstack.cpp:877
MASK_LAYER_PROPS & BackOuterLayers()
Definition: padstack.h:303
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: padstack.cpp:350
void SetSize(const VECTOR2I &aSize, PCB_LAYER_ID aLayer)
Definition: padstack.cpp:868
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
Definition: padstack.h:138
virtual VECTOR2I GetPosition() const override
Definition: pcb_track.cpp:1798
bool IsDegenerated(int aThreshold=5) const
Definition: pcb_track.cpp:1840
virtual void swapData(BOARD_ITEM *aImage) override
Definition: pcb_track.cpp:1783
bool IsCCW() const
Definition: pcb_track.cpp:753
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: pcb_track.cpp:398
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pcb_track.cpp:83
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition: pcb_track.cpp:734
EDA_ANGLE GetArcAngleStart() const
Definition: pcb_track.cpp:1822
void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Definition: pcb_track.cpp:709
virtual bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: pcb_track.cpp:1646
EDA_ANGLE GetArcAngleEnd() const
Definition: pcb_track.cpp:1832
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: pcb_track.cpp:421
void SetMid(const VECTOR2I &aMid)
Definition: pcb_track.h:296
double GetRadius() const
Definition: pcb_track.cpp:1805
EDA_ANGLE GetAngle() const
Definition: pcb_track.cpp:1812
const VECTOR2I & GetMid() const
Definition: pcb_track.h:297
PCB_ARC(BOARD_ITEM *aParent)
Definition: pcb_track.h:272
double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
Definition: pcb_track.cpp:242
VECTOR2I m_Mid
Arc mid point, halfway between start and end.
Definition: pcb_track.h:358
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_track.cpp:694
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: pcb_track.cpp:1896
bool operator==(const PCB_ARC &aOther) const
Definition: pcb_track.cpp:230
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pcb_track.cpp:997
virtual void SetLayerSet(const LSET &aLayers) override
Definition: pcb_track.cpp:984
int GetSolderMaskExpansion() const
Definition: pcb_track.cpp:888
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_track.cpp:687
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
Definition: pcb_track.cpp:1277
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: pcb_track.cpp:357
void SetEndY(int aY)
Definition: pcb_track.h:125
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pcb_track.cpp:1297
void SetHasSolderMask(bool aVal)
Definition: pcb_track.h:139
virtual double GetLength() const
Get the length of the track using the hypotenuse calculation.
Definition: pcb_track.cpp:681
virtual void swapData(BOARD_ITEM *aImage) override
Definition: pcb_track.cpp:1776
void SetEnd(const VECTOR2I &aEnd)
Definition: pcb_track.h:118
bool HasSolderMask() const
Definition: pcb_track.h:140
void SetStart(const VECTOR2I &aStart)
Definition: pcb_track.h:121
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: pcb_track.cpp:1358
int GetEndX() const
Definition: pcb_track.h:127
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: pcb_track.cpp:1761
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: pcb_track.cpp:378
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
Definition: pcb_track.cpp:788
bool ApproxCollinear(const PCB_TRACK &aTrack)
Definition: pcb_track.cpp:496
VECTOR2I m_End
Line end point.
Definition: pcb_track.h:262
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
Definition: pcb_track.h:142
std::optional< int > m_solderMaskMargin
Definition: pcb_track.h:265
std::optional< int > GetLocalSolderMaskMargin() const
Definition: pcb_track.h:143
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: pcb_track.cpp:1504
virtual EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pcb_track.cpp:68
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_track.cpp:636
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the track shape to a closed polygon.
Definition: pcb_track.cpp:1907
const VECTOR2I & GetStart() const
Definition: pcb_track.h:122
virtual bool operator==(const BOARD_ITEM &aOther) const override
Definition: pcb_track.cpp:166
VECTOR2I m_Start
Line start point.
Definition: pcb_track.h:261
int GetEndY() const
Definition: pcb_track.h:128
wxString GetFriendlyName() const override
Definition: pcb_track.cpp:1492
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pcb_track.cpp:1771
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: pcb_track.cpp:1640
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition: pcb_track.cpp:717
virtual double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
Definition: pcb_track.cpp:188
bool m_hasSolderMask
Definition: pcb_track.h:264
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: pcb_track.cpp:1870
const VECTOR2I & GetEnd() const
Definition: pcb_track.h:119
PCB_TRACK(BOARD_ITEM *aParent, KICAD_T idtype=PCB_TRACE_T)
Definition: pcb_track.cpp:60
int m_Width
Thickness of track.
Definition: pcb_track.h:260
virtual void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection)
Definition: pcb_track.cpp:702
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition: pcb_track.cpp:909
virtual MINOPTMAX< int > GetWidthConstraint(wxString *aSource=nullptr) const
Definition: pcb_track.cpp:504
void SetEndX(int aX)
Definition: pcb_track.h:124
EDA_ITEM_FLAGS IsPointOnEnds(const VECTOR2I &point, int min_dist=0) const
Return STARTPOINT if point if near (dist = min_dist) start point, ENDPOINT if point if near (dist = m...
Definition: pcb_track.cpp:604
virtual void SetWidth(int aWidth)
Definition: pcb_track.h:115
virtual int GetWidth() const
Definition: pcb_track.h:116
void GetMsgPanelInfoBase_Common(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) const
Definition: pcb_track.cpp:1601
PCB_LAYER_ID BottomLayer() const
Definition: pcb_track.cpp:1140
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pcb_track.cpp:160
VECTOR2I GetPosition() const override
Definition: pcb_track.h:480
bool IsTented(PCB_LAYER_ID aLayer) const override
Checks if the given object is tented (its copper shape is covered by solder mask) on a given side of ...
Definition: pcb_track.cpp:856
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: pcb_track.cpp:1881
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: pcb_track.cpp:468
bool FlashLayer(int aLayer) const
Check to see whether the via should have a pad on the specific layer.
Definition: pcb_track.cpp:1176
void SetDrillDefault()
Set the drill value for vias to the default value UNDEFINED_DRILL_DIAMETER.
Definition: pcb_track.h:617
std::map< PCB_LAYER_ID, ZONE_LAYER_OVERRIDE > m_zoneLayerOverrides
Definition: pcb_track.h:663
void ClearZoneLayerOverrides()
Definition: pcb_track.cpp:1223
const PADSTACK & Padstack() const
Definition: pcb_track.h:401
void SetFrontTentingMode(TENTING_MODE aMode)
Definition: pcb_track.cpp:810
bool m_isFree
"Free" vias don't get their nets auto-updated
Definition: pcb_track.h:660
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: pcb_track.cpp:1681
TENTING_MODE GetFrontTentingMode() const
Definition: pcb_track.cpp:821
void SetBottomLayer(PCB_LAYER_ID aLayer)
Definition: pcb_track.cpp:1106
int GetSolderMaskExpansion() const
Definition: pcb_track.cpp:879
void SetDrill(int aDrill)
Set the drill value for vias.
Definition: pcb_track.h:595
MINOPTMAX< int > GetDrillConstraint(wxString *aSource=nullptr) const
Definition: pcb_track.cpp:540
void SetBackTentingMode(TENTING_MODE aMode)
Definition: pcb_track.cpp:833
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition: pcb_track.cpp:763
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: pcb_track.cpp:1564
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pcb_track.cpp:139
bool operator==(const PCB_VIA &aOther) const
Definition: pcb_track.cpp:287
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: pcb_track.cpp:972
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pcb_track.cpp:1407
std::mutex m_zoneLayerOverridesMutex
Definition: pcb_track.h:662
void SetTopLayer(PCB_LAYER_ID aLayer)
Definition: pcb_track.cpp:1100
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Definition: pcb_track.cpp:804
int GetFrontWidth() const
Definition: pcb_track.h:413
void SetLayerPair(PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer)
For a via m_layer contains the top layer, the other layer is in m_bottomLayer/.
Definition: pcb_track.cpp:1091
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: pcb_track.cpp:145
double Similarity(const BOARD_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
Definition: pcb_track.cpp:298
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition: pcb_track.cpp:978
virtual void SetLayerSet(const LSET &aLayers) override
Note SetLayerSet() initialize the first and last copper layers connected by the via.
Definition: pcb_track.cpp:1049
void GetOutermostConnectedLayers(PCB_LAYER_ID *aTopmost, PCB_LAYER_ID *aBottommost) const
Return the top-most and bottom-most connected layers.
Definition: pcb_track.cpp:1247
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the all the layers within the VIEW the object is painted on.
Definition: pcb_track.cpp:1371
void SanitizeLayers()
Check so that the layers are correct depending on the type of via, and so that the top actually is on...
Definition: pcb_track.cpp:1146
int GetWidth() const override
Definition: pcb_track.cpp:337
PCB_VIA & operator=(const PCB_VIA &aOther)
Definition: pcb_track.cpp:124
void swapData(BOARD_ITEM *aImage) override
Definition: pcb_track.cpp:1790
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: pcb_track.cpp:442
PCB_VIA(BOARD_ITEM *aParent)
Definition: pcb_track.cpp:89
wxString layerMaskDescribe() const override
Return a string (to be shown to the user) describing a layer mask.
Definition: pcb_track.cpp:1628
void SetViaType(VIATYPE aViaType)
Definition: pcb_track.h:399
int GetMinAnnulus(PCB_LAYER_ID aLayer, wxString *aSource) const
Definition: pcb_track.cpp:558
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition: pcb_track.cpp:927
TENTING_MODE GetBackTentingMode() const
Definition: pcb_track.cpp:844
PCB_LAYER_ID TopLayer() const
Definition: pcb_track.cpp:1134
VIATYPE m_viaType
through, blind/buried or micro
Definition: pcb_track.h:656
PADSTACK m_padStack
Definition: pcb_track.h:658
int GetDrillValue() const
Calculate the drill value for vias (m_drill if > 0, or default drill value for the board).
Definition: pcb_track.cpp:589
void SetZoneLayerOverride(PCB_LAYER_ID aLayer, ZONE_LAYER_OVERRIDE aOverride)
Definition: pcb_track.cpp:1240
void SetFrontWidth(int aWidth)
Definition: pcb_track.h:412
VIATYPE GetViaType() const
Definition: pcb_track.h:398
MINOPTMAX< int > GetWidthConstraint(wxString *aSource=nullptr) const override
Definition: pcb_track.cpp:522
void SetWidth(int aWidth) override
Definition: pcb_track.cpp:329
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pcb_track.cpp:1013
const ZONE_LAYER_OVERRIDE & GetZoneLayerOverride(PCB_LAYER_ID aLayer) const
Definition: pcb_track.cpp:1232
void LayerPair(PCB_LAYER_ID *top_layer, PCB_LAYER_ID *bottom_layer) const
Return the 2 layers used by the via (the via actually uses all layers between these 2 layers)
Definition: pcb_track.cpp:1112
bool HasValidLayerPair(int aCopperLayerCount)
Definition: pcb_track.cpp:950
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:85
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()
Definition: property_mgr.h:87
PROPERTY_BASE & AddProperty(PROPERTY_BASE *aProperty, const wxString &aGroup=wxEmptyString)
Register a property.
PROPERTY_BASE & ReplaceProperty(size_t aBase, const wxString &aName, PROPERTY_BASE *aNew, const wxString &aGroup=wxEmptyString)
Replace an existing property for a specific type.
Definition: seg.h:42
VECTOR2I::extended_type ecoord
Definition: seg.h:44
bool ApproxCollinear(const SEG &aSeg, int aDistanceThreshold=1) const
Definition: seg.cpp:477
const VECTOR2I & GetArcMid() const
Definition: shape_arc.h:116
const VECTOR2I & GetP1() const
Definition: shape_arc.h:115
const VECTOR2I & GetP0() const
Definition: shape_arc.h:114
Represent a set of closed polygons.
wxString MessageTextFromMinOptMax(const MINOPTMAX< int > &aValue) const
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE) const
A lower-precision version of StringFromValue().
constexpr extended_type Cross(const VECTOR2< T > &aVector) const
Compute cross product of self with aVector.
Definition: vector2d.h:542
double Distance(const VECTOR2< extended_type > &aVector) const
Compute the distance between two vectors.
Definition: vector2d.h:557
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
Definition: vector2d.h:283
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 TransformArcToPolygon(SHAPE_POLY_SET &aBuffer, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd, int aWidth, int aError, ERROR_LOC aErrorLoc)
Convert arc to multiple straight segments.
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.
#define _HKI(x)
@ ANNULAR_WIDTH_CONSTRAINT
Definition: drc_rule.h:59
@ VIA_DIAMETER_CONSTRAINT
Definition: drc_rule.h:65
@ TRACK_WIDTH_CONSTRAINT
Definition: drc_rule.h:58
@ HOLE_SIZE_CONSTRAINT
Definition: drc_rule.h:53
#define _(s)
static constexpr EDA_ANGLE ANGLE_0
Definition: eda_angle.h:401
static constexpr EDA_ANGLE ANGLE_360
Definition: eda_angle.h:407
#define PCB_EDIT_FRAME_NAME
INSPECT_RESULT
Definition: eda_item.h:43
const INSPECTOR_FUNC & INSPECTOR
Definition: eda_item.h:82
#define ENDPOINT
ends. (Used to support dragging.)
std::uint32_t EDA_ITEM_FLAGS
#define STARTPOINT
When a line is selected, these flags indicate which.
static std::vector< KICAD_T > connectedTypes
a few functions useful in geometry calculations.
bool ClipLine(const BOX2I *aClipBox, int &x1, int &y1, int &x2, int &y2)
Test if any part of a line falls within the bounds of a rectangle.
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Definition: layer_id.cpp:209
bool IsSolderMaskLayer(int aLayer)
Definition: layer_ids.h:589
@ LAYER_VIA_NETNAMES
Definition: layer_ids.h:168
bool IsCopperLayerLowerThan(PCB_LAYER_ID aLayerA, PCB_LAYER_ID aLayerB)
Returns true if copper aLayerA is placed lower than aLayerB, false otherwise.
Definition: layer_ids.h:664
constexpr PCB_LAYER_ID PCBNEW_LAYER_ID_START
Definition: layer_ids.h:138
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
Definition: layer_ids.h:620
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:147
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
Definition: layer_ids.h:643
#define MAX_CU_LAYERS
Definition: layer_ids.h:140
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
Definition: layer_ids.h:694
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:530
@ LAYER_LOCKED_ITEM_SHADOW
shadow layer for locked items
Definition: layer_ids.h:241
@ LAYER_VIA_HOLEWALLS
Definition: layer_ids.h:236
@ LAYER_TRACKS
Definition: layer_ids.h:214
@ LAYER_VIA_HOLES
to draw via holes (pad holes do not use this layer)
Definition: layer_ids.h:217
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
Definition: layer_ids.h:195
bool IsNetnameLayer(int aLayer)
Test whether a layer is a netname layer.
Definition: layer_ids.h:717
bool IsHoleLayer(int aLayer)
Definition: layer_ids.h:580
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ B_Mask
Definition: layer_ids.h:98
@ B_Cu
Definition: layer_ids.h:65
@ F_Mask
Definition: layer_ids.h:97
@ UNDEFINED_LAYER
Definition: layer_ids.h:61
@ F_Cu
Definition: layer_ids.h:64
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:810
constexpr void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:45
FLIP_DIRECTION
Definition: mirror.h:27
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:390
static struct TRACK_VIA_DESC _TRACK_VIA_DESC
VIATYPE
Definition: pcb_track.h:66
TENTING_MODE
Definition: pcb_track.h:75
#define TYPE_HASH(x)
Definition: property.h:71
#define ENUM_TO_WXANY(type)
Macro to define read-only fields (no setter method available)
Definition: property.h:765
#define REGISTER_TYPE(x)
Definition: property_mgr.h:371
wxString UnescapeString(const wxString &aSource)
constexpr int mmToIU(double mm) const
Definition: base_units.h:88
PCB_LAYER_ID start
Definition: padstack.h:236
PCB_LAYER_ID end
Definition: padstack.h:237
VECTOR2I size
Drill diameter (x == y) or slot dimensions (x != y)
Definition: padstack.h:234
std::optional< bool > has_solder_mask
True if this outer layer has mask (is not tented)
Definition: padstack.h:225
bool operator()(const PCB_TRACK *aFirst, const PCB_TRACK *aSecond) const
Definition: pcb_track.cpp:1852
bool TestSegmentHit(const VECTOR2I &aRefPoint, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
Definition: trigo.cpp:175
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:229
const VECTOR2I CalcArcCenter(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Determine the center of an arc or circle given three points on its circumference.
Definition: trigo.cpp:521
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:691
VECTOR2< int64_t > VECTOR2L
Definition: vector2d.h:692