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 && GetWidth() == aOther.GetWidth()
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( GetWidth() != other.GetWidth() )
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 int radius = 0;
684
686 [&]( PCB_LAYER_ID aLayer )
687 {
688 radius = std::max( radius, GetWidth( aLayer ) );
689 } );
690
691 // via is round, this is its radius, rounded up
692 radius = ( radius + 1 ) / 2;
693
694 int ymax = m_Start.y + radius;
695 int xmax = m_Start.x + radius;
696
697 int ymin = m_Start.y - radius;
698 int xmin = m_Start.x - radius;
699
700 // return a rectangle which is [pos,dim) in nature. therefore the +1
701 return BOX2ISafe( VECTOR2I( xmin, ymin ),
702 VECTOR2L( (int64_t) xmax - xmin + 1, (int64_t) ymax - ymin + 1 ) );
703}
704
705
707{
708 return m_Start.Distance( m_End );
709}
710
711
712void PCB_TRACK::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
713{
714 RotatePoint( m_Start, aRotCentre, aAngle );
715 RotatePoint( m_End, aRotCentre, aAngle );
716}
717
718
719void PCB_ARC::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
720{
721 RotatePoint( m_Start, aRotCentre, aAngle );
722 RotatePoint( m_End, aRotCentre, aAngle );
723 RotatePoint( m_Mid, aRotCentre, aAngle );
724}
725
726
727void PCB_TRACK::Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
728{
729 MIRROR( m_Start, aCentre, aFlipDirection );
730 MIRROR( m_End, aCentre, aFlipDirection );
731}
732
733
734void PCB_ARC::Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
735{
736 MIRROR( m_Start, aCentre, aFlipDirection );
737 MIRROR( m_End, aCentre, aFlipDirection );
738 MIRROR( m_Mid, aCentre, aFlipDirection );
739}
740
741
742void PCB_TRACK::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
743{
744 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
745 {
746 m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
747 m_End.x = aCentre.x - ( m_End.x - aCentre.x );
748 }
749 else
750 {
751 m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
752 m_End.y = aCentre.y - ( m_End.y - aCentre.y );
753 }
754
756}
757
758
759void PCB_ARC::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
760{
761 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
762 {
763 m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
764 m_End.x = aCentre.x - ( m_End.x - aCentre.x );
765 m_Mid.x = aCentre.x - ( m_Mid.x - aCentre.x );
766 }
767 else
768 {
769 m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
770 m_End.y = aCentre.y - ( m_End.y - aCentre.y );
771 m_Mid.y = aCentre.y - ( m_Mid.y - aCentre.y );
772 }
773
775}
776
777
778bool PCB_ARC::IsCCW() const
779{
780 VECTOR2L start = m_Start;
781 VECTOR2L start_end = m_End - start;
782 VECTOR2L start_mid = m_Mid - start;
783
784 return start_end.Cross( start_mid ) < 0;
785}
786
787
788void PCB_VIA::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
789{
790 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
791 {
792 m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
793 m_End.x = aCentre.x - ( m_End.x - aCentre.x );
794 }
795 else
796 {
797 m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
798 m_End.y = aCentre.y - ( m_End.y - aCentre.y );
799 }
800
801 if( GetViaType() != VIATYPE::THROUGH )
802 {
803 PCB_LAYER_ID top_layer;
804 PCB_LAYER_ID bottom_layer;
805 LayerPair( &top_layer, &bottom_layer );
806 top_layer = GetBoard()->FlipLayer( top_layer );
807 bottom_layer = GetBoard()->FlipLayer( bottom_layer );
808 SetLayerPair( top_layer, bottom_layer );
809 }
810}
811
812
813INSPECT_RESULT PCB_TRACK::Visit( INSPECTOR inspector, void* testData,
814 const std::vector<KICAD_T>& aScanTypes )
815{
816 for( KICAD_T scanType : aScanTypes )
817 {
818 if( scanType == Type() )
819 {
820 if( INSPECT_RESULT::QUIT == inspector( this, testData ) )
821 return INSPECT_RESULT::QUIT;
822 }
823 }
824
825 return INSPECT_RESULT::CONTINUE;
826}
827
828
829std::shared_ptr<SHAPE_SEGMENT> PCB_VIA::GetEffectiveHoleShape() const
830{
831 return std::make_shared<SHAPE_SEGMENT>( SEG( m_Start, m_Start ), Padstack().Drill().size.x );
832}
833
834
836{
837 switch( aMode )
838 {
839 case TENTING_MODE::FROM_RULES: m_padStack.FrontOuterLayers().has_solder_mask.reset(); break;
840 case TENTING_MODE::TENTED: m_padStack.FrontOuterLayers().has_solder_mask = true; break;
841 case TENTING_MODE::NOT_TENTED: m_padStack.FrontOuterLayers().has_solder_mask = false; break;
842 }
843}
844
845
847{
849 {
851 TENTING_MODE::TENTED : TENTING_MODE::NOT_TENTED;
852 }
853
854 return TENTING_MODE::FROM_RULES;
855}
856
857
859{
860 switch( aMode )
861 {
862 case TENTING_MODE::FROM_RULES: m_padStack.BackOuterLayers().has_solder_mask.reset(); break;
863 case TENTING_MODE::TENTED: m_padStack.BackOuterLayers().has_solder_mask = true; break;
864 case TENTING_MODE::NOT_TENTED: m_padStack.BackOuterLayers().has_solder_mask = false; break;
865 }
866}
867
868
870{
871 if( m_padStack.BackOuterLayers().has_solder_mask.has_value() )
872 {
874 TENTING_MODE::TENTED : TENTING_MODE::NOT_TENTED;
875 }
876
877 return TENTING_MODE::FROM_RULES;
878}
879
880
881bool PCB_VIA::IsTented( PCB_LAYER_ID aLayer ) const
882{
883 wxCHECK_MSG( IsFrontLayer( aLayer ) || IsBackLayer( aLayer ), true,
884 "Invalid layer passed to IsTented" );
885
886 bool front = IsFrontLayer( aLayer );
887
888 if( front && m_padStack.FrontOuterLayers().has_solder_mask.has_value() )
890
891 if( !front && m_padStack.BackOuterLayers().has_solder_mask.has_value() )
893
894 if( const BOARD* board = GetBoard() )
895 {
896 return front ? board->GetDesignSettings().m_TentViasFront
897 : board->GetDesignSettings().m_TentViasBack;
898 }
899
900 return true;
901}
902
903
905{
906 if( const BOARD* board = GetBoard() )
907 return board->GetDesignSettings().m_SolderMaskExpansion;
908 else
909 return 0;
910}
911
912
914{
915 int margin = m_solderMaskMargin.value_or( 0 );
916
917 // If no local margin is set, get the board's solder mask expansion value
918 if( !m_solderMaskMargin.has_value() )
919 {
920 const BOARD* board = GetBoard();
921
922 if( board )
924 }
925
926 // Ensure the resulting mask opening has a non-negative size
927 if( margin < 0 )
928 margin = std::max( margin, -m_width / 2 );
929
930 return margin;
931}
932
933
935{
936 if( aLayer == m_layer )
937 {
938 return true;
939 }
940
942 && ( ( aLayer == F_Mask && m_layer == F_Cu )
943 || ( aLayer == B_Mask && m_layer == B_Cu ) ) )
944 {
945 return true;
946 }
947
948 return false;
949}
950
951
953{
954#if 0
955 // Nice and simple, but raises its ugly head in performance profiles....
956 return GetLayerSet().test( aLayer );
957#endif
958 if( IsCopperLayer( aLayer ) &&
959 LAYER_RANGE::Contains( Padstack().Drill().start, Padstack().Drill().end, aLayer ) )
960 {
961 return true;
962 }
963
964 // Test for via on mask layers: a via on on a mask layer if not tented and if
965 // it is on the corresponding external copper layer
966 if( aLayer == F_Mask )
967 return Padstack().Drill().start == F_Cu && !IsTented( F_Mask );
968 else if( aLayer == B_Mask )
969 return Padstack().Drill().end == B_Cu && !IsTented( B_Mask );
970
971 return false;
972}
973
974
975bool PCB_VIA::HasValidLayerPair( int aCopperLayerCount )
976{
977 // return true if top and bottom layers are valid, depending on the copper layer count
978 // aCopperLayerCount is expected >= 2
979
980 int layer_id = aCopperLayerCount*2;
981
982 if( Padstack().Drill().start > B_Cu )
983 {
984 if( Padstack().Drill().start > layer_id )
985 return false;
986 }
987 if( Padstack().Drill().end > B_Cu )
988 {
989 if( Padstack().Drill().end > layer_id )
990 return false;
991 }
992
993 return true;
994}
995
996
998{
999 return Padstack().Drill().start;
1000}
1001
1002
1004{
1005 Padstack().Drill().start = aLayer;
1006}
1007
1008
1009void PCB_TRACK::SetLayerSet( const LSET& aLayerSet )
1010{
1011 aLayerSet.RunOnLayers(
1012 [&]( PCB_LAYER_ID layer )
1013 {
1014 if( IsCopperLayer( layer ) )
1015 SetLayer( layer );
1016 else if( IsSolderMaskLayer( layer ) )
1017 SetHasSolderMask( true );
1018 } );
1019}
1020
1021
1023{
1024 LSET layermask( { m_layer } );
1025
1026 if( m_hasSolderMask )
1027 {
1028 if( layermask.test( F_Cu ) )
1029 layermask.set( F_Mask );
1030 else if( layermask.test( B_Cu ) )
1031 layermask.set( B_Mask );
1032 }
1033
1034 return layermask;
1035}
1036
1037
1039{
1040 LSET layermask;
1041
1042 if( Padstack().Drill().start < PCBNEW_LAYER_ID_START )
1043 return layermask;
1044
1045 if( GetViaType() == VIATYPE::THROUGH )
1046 {
1047 layermask = LSET::AllCuMask( BoardCopperLayerCount() );
1048 }
1049 else
1050 {
1051 LAYER_RANGE range( Padstack().Drill().start, Padstack().Drill().end, BoardCopperLayerCount() );
1052
1053 int cnt = BoardCopperLayerCount();
1054 // PCB_LAYER_IDs are numbered from front to back, this is top to bottom.
1055 for( PCB_LAYER_ID id : range )
1056 {
1057 layermask.set( id );
1058
1059 if( --cnt <= 0 )
1060 break;
1061 }
1062 }
1063
1064 if( !IsTented( F_Mask ) && layermask.test( F_Cu ) )
1065 layermask.set( F_Mask );
1066
1067 if( !IsTented( B_Mask ) && layermask.test( B_Cu ) )
1068 layermask.set( B_Mask );
1069
1070 return layermask;
1071}
1072
1073
1074void PCB_VIA::SetLayerSet( const LSET& aLayerSet )
1075{
1076 // Vias do not use a LSET, just a top and bottom layer pair
1077 // So we need to set these 2 layers according to the allowed layers in aLayerSet
1078
1079 // For via through, only F_Cu and B_Cu are allowed. aLayerSet is ignored
1080 if( GetViaType() == VIATYPE::THROUGH )
1081 {
1082 Padstack().Drill().start = F_Cu;
1083 Padstack().Drill().end = B_Cu;
1084 return;
1085 }
1086
1087 // For blind buried vias, find the top and bottom layers
1088 bool top_found = false;
1089 bool bottom_found = false;
1090
1091 aLayerSet.RunOnLayers(
1092 [&]( PCB_LAYER_ID layer )
1093 {
1094 // tpo layer and bottom Layer are copper layers, so consider only copper layers
1095 if( IsCopperLayer( layer ) )
1096 {
1097 // The top layer is the first layer found in list and
1098 // cannot the B_Cu
1099 if( !top_found && layer != B_Cu )
1100 {
1101 Padstack().Drill().start = layer;
1102 top_found = true;
1103 }
1104
1105 // The bottom layer is the last layer found in list or B_Cu
1106 if( !bottom_found )
1107 Padstack().Drill().end = layer;
1108
1109 if( layer == B_Cu )
1110 bottom_found = true;
1111 }
1112 } );
1113}
1114
1115
1116void PCB_VIA::SetLayerPair( PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer )
1117{
1118
1119 Padstack().Drill().start = aTopLayer;
1120 Padstack().Drill().end = aBottomLayer;
1122}
1123
1124
1126{
1127 Padstack().Drill().start = aLayer;
1128}
1129
1130
1132{
1133 Padstack().Drill().end = aLayer;
1134}
1135
1136
1137void PCB_VIA::LayerPair( PCB_LAYER_ID* top_layer, PCB_LAYER_ID* bottom_layer ) const
1138{
1139 PCB_LAYER_ID t_layer = F_Cu;
1140 PCB_LAYER_ID b_layer = B_Cu;
1141
1142 if( GetViaType() != VIATYPE::THROUGH )
1143 {
1144 b_layer = Padstack().Drill().end;
1145 t_layer = Padstack().Drill().start;
1146
1147 if( !IsCopperLayerLowerThan( b_layer, t_layer ) )
1148 std::swap( b_layer, t_layer );
1149 }
1150
1151 if( top_layer )
1152 *top_layer = t_layer;
1153
1154 if( bottom_layer )
1155 *bottom_layer = b_layer;
1156}
1157
1158
1160{
1161 return Padstack().Drill().start;
1162}
1163
1164
1166{
1167 return Padstack().Drill().end;
1168}
1169
1170
1172{
1173 if( GetViaType() == VIATYPE::THROUGH )
1174 {
1175 Padstack().Drill().start = F_Cu;
1176 Padstack().Drill().end = B_Cu;
1177 }
1178
1179 if( !IsCopperLayerLowerThan( Padstack().Drill().end, Padstack().Drill().start) )
1180 std::swap( Padstack().Drill().end, Padstack().Drill().start );
1181}
1182
1183
1184bool PCB_VIA::FlashLayer( LSET aLayers ) const
1185{
1186 for( size_t ii = 0; ii < aLayers.size(); ++ii )
1187 {
1188 if( aLayers.test( ii ) )
1189 {
1190 PCB_LAYER_ID layer = PCB_LAYER_ID( ii );
1191
1192 if( FlashLayer( layer ) )
1193 return true;
1194 }
1195 }
1196
1197 return false;
1198}
1199
1200
1201bool PCB_VIA::FlashLayer( int aLayer ) const
1202{
1203 // Return the "normal" shape if the caller doesn't specify a particular layer
1204 if( aLayer == UNDEFINED_LAYER )
1205 return true;
1206
1207 const BOARD* board = GetBoard();
1208
1209 if( !board )
1210 return true;
1211
1212 if( !IsOnLayer( static_cast<PCB_LAYER_ID>( aLayer ) ) )
1213 return false;
1214
1215 if( !IsCopperLayer( aLayer ) )
1216 return true;
1217
1218 switch( Padstack().UnconnectedLayerMode() )
1219 {
1221 return true;
1222
1224 {
1225 if( aLayer == Padstack().Drill().start || aLayer == Padstack().Drill().end )
1226 return true;
1227
1228 // Check for removal below
1229 break;
1230 }
1231
1233 // Check for removal below
1234 break;
1235 }
1236
1237 // Must be static to keep from raising its ugly head in performance profiles
1238 static std::initializer_list<KICAD_T> connectedTypes = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T,
1239 PCB_PAD_T };
1240
1241 if( GetZoneLayerOverride( static_cast<PCB_LAYER_ID>( aLayer ) ) == ZLO_FORCE_FLASHED )
1242 return true;
1243 else
1244 return board->GetConnectivity()->IsConnectedOnLayer( this, static_cast<PCB_LAYER_ID>( aLayer ), connectedTypes );
1245}
1246
1247
1249{
1250 std::unique_lock<std::mutex> cacheLock( m_zoneLayerOverridesMutex );
1251
1254}
1255
1256
1258{
1259 static const ZONE_LAYER_OVERRIDE defaultOverride = ZLO_NONE;
1260 auto it = m_zoneLayerOverrides.find( aLayer );
1261 return it != m_zoneLayerOverrides.end() ? it->second : defaultOverride;
1262}
1263
1264
1266{
1267 std::unique_lock<std::mutex> cacheLock( m_zoneLayerOverridesMutex );
1268 m_zoneLayerOverrides[aLayer] = aOverride;
1269}
1270
1271
1273 PCB_LAYER_ID* aBottommost ) const
1274{
1275 *aTopmost = UNDEFINED_LAYER;
1276 *aBottommost = UNDEFINED_LAYER;
1277
1278 static std::initializer_list<KICAD_T> connectedTypes = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T,
1279 PCB_PAD_T };
1280
1281 for( int layer = TopLayer(); layer <= BottomLayer(); ++layer )
1282 {
1283 bool connected = false;
1284
1285 if( GetZoneLayerOverride( static_cast<PCB_LAYER_ID>( layer ) ) == ZLO_FORCE_FLASHED )
1286 connected = true;
1287 else if( GetBoard()->GetConnectivity()->IsConnectedOnLayer( this, layer, connectedTypes ) )
1288 connected = true;
1289
1290 if( connected )
1291 {
1292 if( *aTopmost == UNDEFINED_LAYER )
1293 *aTopmost = ToLAYER_ID( layer );
1294
1295 *aBottommost = ToLAYER_ID( layer );
1296 }
1297 }
1298
1299}
1300
1301
1302void PCB_TRACK::ViewGetLayers( int aLayers[], int& aCount ) const
1303{
1304 // Show the track and its netname on different layers
1305 aLayers[0] = GetLayer();
1306 aLayers[1] = GetNetnameLayer( aLayers[0] );
1307 aCount = 2;
1308
1309 if( m_hasSolderMask )
1310 {
1311 if( m_layer == F_Cu )
1312 aLayers[ aCount++ ] = F_Mask;
1313 else if( m_layer == B_Cu )
1314 aLayers[ aCount++ ] = B_Mask;
1315 }
1316
1317 if( IsLocked() )
1318 aLayers[ aCount++ ] = LAYER_LOCKED_ITEM_SHADOW;
1319}
1320
1321
1322double PCB_TRACK::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
1323{
1324 constexpr double HIDE = std::numeric_limits<double>::max();
1325
1326 PCB_PAINTER* painter = static_cast<PCB_PAINTER*>( aView->GetPainter() );
1327 PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
1328
1329 if( !aView->IsLayerVisible( LAYER_TRACKS ) )
1330 return HIDE;
1331
1332 if( IsNetnameLayer( aLayer ) )
1333 {
1335 return HIDE;
1336
1337 // Hide netnames on dimmed tracks
1338 if( renderSettings->GetHighContrast() )
1339 {
1340 if( m_layer != renderSettings->GetPrimaryHighContrastLayer() )
1341 return HIDE;
1342 }
1343
1344 VECTOR2I start( GetStart() );
1345 VECTOR2I end( GetEnd() );
1346
1347 // Calc the approximate size of the netname (assume square chars)
1348 SEG::ecoord nameSize = GetDisplayNetname().size() * GetWidth();
1349
1350 if( VECTOR2I( end - start ).SquaredEuclideanNorm() < nameSize * nameSize )
1351 return HIDE;
1352
1353 BOX2I clipBox = BOX2ISafe( aView->GetViewport() );
1354
1355 ClipLine( &clipBox, start.x, start.y, end.x, end.y );
1356
1357 if( VECTOR2I( end - start ).SquaredEuclideanNorm() == 0 )
1358 return HIDE;
1359
1360 // Netnames will be shown only if zoom is appropriate
1361 return ( double ) pcbIUScale.mmToIU( 4 ) / ( m_width + 1 );
1362 }
1363
1364 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
1365 {
1366 // Hide shadow if the main layer is not shown
1367 if( !aView->IsLayerVisible( m_layer ) )
1368 return HIDE;
1369
1370 // Hide shadow on dimmed tracks
1371 if( renderSettings->GetHighContrast() )
1372 {
1373 if( m_layer != renderSettings->GetPrimaryHighContrastLayer() )
1374 return HIDE;
1375 }
1376 }
1377
1378 // Other layers are shown without any conditions
1379 return 0.0;
1380}
1381
1382
1384{
1385 BOX2I bbox = GetBoundingBox();
1386
1387 if( const BOARD* board = GetBoard() )
1388 bbox.Inflate( 2 * board->GetDesignSettings().GetBiggestClearanceValue() );
1389 else
1390 bbox.Inflate( GetWidth() ); // Add a bit extra for safety
1391
1392 return bbox;
1393}
1394
1395
1396void PCB_VIA::ViewGetLayers( int aLayers[], int& aCount ) const
1397{
1398 // TODO(JE) Rendering order issue
1399#if 0
1400 // Blind/buried vias (and microvias) use a different net name layer
1401 PCB_LAYER_ID layerTop, layerBottom;
1402 LayerPair( &layerTop, &layerBottom );
1403
1404 bool isBlindBuried =
1405 m_viaType == VIATYPE::BLIND_BURIED
1406 || ( m_viaType == VIATYPE::MICROVIA && ( layerTop != F_Cu || layerBottom != B_Cu ) );
1407#endif
1408
1409 aLayers[0] = LAYER_VIA_HOLES;
1410 aLayers[1] = LAYER_VIA_HOLEWALLS;
1411 aLayers[2] = LAYER_VIA_NETNAMES;
1412 aCount = 3;
1413
1414 LAYER_RANGE layers( Padstack().Drill().start, Padstack().Drill().end, MAX_CU_LAYERS );
1415
1416 for( PCB_LAYER_ID layer : layers )
1417 aLayers[aCount++] = layer;
1418
1419 if( IsLocked() )
1420 aLayers[ aCount++ ] = LAYER_LOCKED_ITEM_SHADOW;
1421
1422 // Vias can also be on a solder mask layer. They are on these layers or not,
1423 // depending on the plot and solder mask options
1424 if( IsOnLayer( F_Mask ) )
1425 aLayers[ aCount++ ] = F_Mask;
1426
1427 if( IsOnLayer( B_Mask ) )
1428 aLayers[ aCount++ ] = B_Mask;
1429}
1430
1431
1432double PCB_VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
1433{
1434 constexpr double HIDE = (double)std::numeric_limits<double>::max();
1435
1436 PCB_PAINTER* painter = static_cast<PCB_PAINTER*>( aView->GetPainter() );
1437 PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
1438 LSET visible = LSET::AllLayersMask();
1439
1440 // Meta control for hiding all vias
1441 if( !aView->IsLayerVisible( LAYER_VIAS ) )
1442 return HIDE;
1443
1444 // Handle board visibility
1445 if( const BOARD* board = GetBoard() )
1446 visible = board->GetVisibleLayers() & board->GetEnabledLayers();
1447
1448 int width = GetWidth( ToLAYER_ID( aLayer ) );
1449
1450 // In high contrast mode don't show vias that don't cross the high-contrast layer
1451 if( renderSettings->GetHighContrast() )
1452 {
1453 PCB_LAYER_ID highContrastLayer = renderSettings->GetPrimaryHighContrastLayer();
1454
1455 if( LSET::FrontTechMask().Contains( highContrastLayer ) )
1456 highContrastLayer = F_Cu;
1457 else if( LSET::BackTechMask().Contains( highContrastLayer ) )
1458 highContrastLayer = B_Cu;
1459
1460 if( !IsCopperLayer( highContrastLayer ) )
1461 return HIDE;
1462
1463 if( GetViaType() != VIATYPE::THROUGH )
1464 {
1465 if( IsCopperLayerLowerThan( Padstack().Drill().start, highContrastLayer )
1466 || IsCopperLayerLowerThan( highContrastLayer, Padstack().Drill().end ) )
1467 {
1468 return HIDE;
1469 }
1470 }
1471 }
1472
1473 if( IsHoleLayer( aLayer ) )
1474 {
1475 if( m_viaType == VIATYPE::THROUGH )
1476 {
1477 // Show a through via's hole if any physical layer is shown
1478 if( !( visible & LSET::PhysicalLayersMask() ).any() )
1479 return HIDE;
1480 }
1481 else
1482 {
1483 // Show a blind or micro via's hole if it crosses a visible layer
1484 if( !( visible & GetLayerSet() ).any() )
1485 return HIDE;
1486 }
1487
1488 // The hole won't be visible anyway at this scale
1489 return (double) pcbIUScale.mmToIU( 0.25 ) / GetDrillValue();
1490 }
1491 else if( IsNetnameLayer( aLayer ) )
1492 {
1493 if( renderSettings->GetHighContrast() )
1494 {
1495 // Hide netnames unless via is flashed to a high-contrast layer
1496 if( !FlashLayer( renderSettings->GetPrimaryHighContrastLayer() ) )
1497 return HIDE;
1498 }
1499 else
1500 {
1501 // Hide netnames unless pad is flashed to a visible layer
1502 if( !FlashLayer( visible ) )
1503 return HIDE;
1504 }
1505
1506 // Netnames will be shown only if zoom is appropriate
1507 return width == 0 ? HIDE : ( (double)pcbIUScale.mmToIU( 10 ) / width );
1508 }
1509
1510 if( !IsCopperLayer( aLayer ) )
1511 return (double) pcbIUScale.mmToIU( 0.6 ) / width;
1512
1513 return 0.0;
1514}
1515
1516
1518{
1519 switch( Type() )
1520 {
1521 case PCB_ARC_T: return _( "Track (arc)" );
1522 case PCB_VIA_T: return _( "Via" );
1523 case PCB_TRACE_T:
1524 default: return _( "Track" );
1525 }
1526}
1527
1528
1529void PCB_TRACK::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
1530{
1531 wxString msg;
1532 BOARD* board = GetBoard();
1533
1534 aList.emplace_back( _( "Type" ), GetFriendlyName() );
1535
1536 GetMsgPanelInfoBase_Common( aFrame, aList );
1537
1538 aList.emplace_back( _( "Layer" ), layerMaskDescribe() );
1539
1540 aList.emplace_back( _( "Width" ), aFrame->MessageTextFromValue( m_width ) );
1541
1542 if( Type() == PCB_ARC_T )
1543 {
1544 double radius = static_cast<PCB_ARC*>( this )->GetRadius();
1545 aList.emplace_back( _( "Radius" ), aFrame->MessageTextFromValue( radius ) );
1546 }
1547
1548 aList.emplace_back( _( "Segment Length" ), aFrame->MessageTextFromValue( GetLength() ) );
1549
1550 // Display full track length (in Pcbnew)
1551 if( board && GetNetCode() > 0 )
1552 {
1553 int count;
1554 double trackLen;
1555 double lenPadToDie;
1556
1557 std::tie( count, trackLen, lenPadToDie ) = board->GetTrackLength( *this );
1558
1559 aList.emplace_back( _( "Routed Length" ), aFrame->MessageTextFromValue( trackLen ) );
1560
1561 if( lenPadToDie != 0 )
1562 {
1563 msg = aFrame->MessageTextFromValue( lenPadToDie );
1564 aList.emplace_back( _( "Pad To Die Length" ), msg );
1565
1566 msg = aFrame->MessageTextFromValue( trackLen + lenPadToDie );
1567 aList.emplace_back( _( "Full Length" ), msg );
1568 }
1569 }
1570
1571 wxString source;
1572 int clearance = GetOwnClearance( GetLayer(), &source );
1573
1574 aList.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
1575 aFrame->MessageTextFromValue( clearance ) ),
1576 wxString::Format( _( "(from %s)" ), source ) );
1577
1578 MINOPTMAX<int> constraintValue = GetWidthConstraint( &source );
1579 msg = aFrame->MessageTextFromMinOptMax( constraintValue );
1580
1581 if( !msg.IsEmpty() )
1582 {
1583 aList.emplace_back( wxString::Format( _( "Width Constraints: %s" ), msg ),
1584 wxString::Format( _( "(from %s)" ), source ) );
1585 }
1586}
1587
1588
1589void PCB_VIA::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
1590{
1591 wxString msg;
1592
1593 switch( GetViaType() )
1594 {
1595 case VIATYPE::MICROVIA: msg = _( "Micro Via" ); break;
1596 case VIATYPE::BLIND_BURIED: msg = _( "Blind/Buried Via" ); break;
1597 case VIATYPE::THROUGH: msg = _( "Through Via" ); break;
1598 default: msg = _( "Via" ); break;
1599 }
1600
1601 aList.emplace_back( _( "Type" ), msg );
1602
1603 GetMsgPanelInfoBase_Common( aFrame, aList );
1604
1605 aList.emplace_back( _( "Layer" ), layerMaskDescribe() );
1606 // TODO(JE) padstacks
1607 aList.emplace_back( _( "Diameter" ),
1609 aList.emplace_back( _( "Hole" ), aFrame->MessageTextFromValue( GetDrillValue() ) );
1610
1611 wxString source;
1612 int clearance = GetOwnClearance( GetLayer(), &source );
1613
1614 aList.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
1615 aFrame->MessageTextFromValue( clearance ) ),
1616 wxString::Format( _( "(from %s)" ), source ) );
1617
1618 int minAnnulus = GetMinAnnulus( GetLayer(), &source );
1619
1620 aList.emplace_back( wxString::Format( _( "Min Annular Width: %s" ),
1621 aFrame->MessageTextFromValue( minAnnulus ) ),
1622 wxString::Format( _( "(from %s)" ), source ) );
1623}
1624
1625
1627 std::vector<MSG_PANEL_ITEM>& aList ) const
1628{
1629 aList.emplace_back( _( "Net" ), UnescapeString( GetNetname() ) );
1630
1631 aList.emplace_back( _( "Resolved Netclass" ),
1632 UnescapeString( GetEffectiveNetClass()->GetName() ) );
1633
1634#if 0 // Enable for debugging
1635 if( GetBoard() )
1636 aList.emplace_back( _( "NetCode" ), wxString::Format( wxT( "%d" ), GetNetCode() ) );
1637
1638 aList.emplace_back( wxT( "Flags" ), wxString::Format( wxT( "0x%08X" ), m_flags ) );
1639
1640 aList.emplace_back( wxT( "Start pos" ), wxString::Format( wxT( "%d %d" ),
1641 m_Start.x,
1642 m_Start.y ) );
1643 aList.emplace_back( wxT( "End pos" ), wxString::Format( wxT( "%d %d" ),
1644 m_End.x,
1645 m_End.y ) );
1646#endif
1647
1648 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
1649 aList.emplace_back( _( "Status" ), _( "Locked" ) );
1650}
1651
1652
1654{
1655 const BOARD* board = GetBoard();
1656 PCB_LAYER_ID top_layer;
1657 PCB_LAYER_ID bottom_layer;
1658
1659 LayerPair( &top_layer, &bottom_layer );
1660
1661 return board->GetLayerName( top_layer ) + wxT( " - " ) + board->GetLayerName( bottom_layer );
1662}
1663
1664
1665bool PCB_TRACK::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
1666{
1667 return TestSegmentHit( aPosition, m_Start, m_End, aAccuracy + ( m_width / 2 ) );
1668}
1669
1670
1671bool PCB_ARC::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
1672{
1673 double max_dist = aAccuracy + ( GetWidth() / 2.0 );
1674
1675 // Short-circuit common cases where the arc is connected to a track or via at an endpoint
1676 if( GetStart().Distance( aPosition ) <= max_dist || GetEnd().Distance( aPosition ) <= max_dist )
1677 {
1678 return true;
1679 }
1680
1681 VECTOR2L center = GetPosition();
1682 VECTOR2L relpos = aPosition - center;
1683 int64_t dist = relpos.EuclideanNorm();
1684 double radius = GetRadius();
1685
1686 if( std::abs( dist - radius ) > max_dist )
1687 return false;
1688
1689 EDA_ANGLE arc_angle = GetAngle();
1690 EDA_ANGLE arc_angle_start = GetArcAngleStart(); // Always 0.0 ... 360 deg
1691 EDA_ANGLE arc_hittest( relpos );
1692
1693 // Calculate relative angle between the starting point of the arc, and the test point
1694 arc_hittest -= arc_angle_start;
1695
1696 // Normalise arc_hittest between 0 ... 360 deg
1697 arc_hittest.Normalize();
1698
1699 if( arc_angle < ANGLE_0 )
1700 return arc_hittest >= ANGLE_360 + arc_angle;
1701
1702 return arc_hittest <= arc_angle;
1703}
1704
1705
1706bool PCB_VIA::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
1707{
1708 bool hit = false;
1709
1711 [&]( PCB_LAYER_ID aLayer )
1712 {
1713 if( hit )
1714 return;
1715
1716 int max_dist = aAccuracy + ( GetWidth( aLayer ) / 2 );
1717
1718 // rel_pos is aPosition relative to m_Start (or the center of the via)
1719 VECTOR2D rel_pos = aPosition - m_Start;
1720 double dist = rel_pos.x * rel_pos.x + rel_pos.y * rel_pos.y;
1721
1722 if( dist <= static_cast<double>( max_dist ) * max_dist )
1723 hit = true;
1724 } );
1725
1726 return hit;
1727}
1728
1729
1730bool PCB_TRACK::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
1731{
1732 BOX2I arect = aRect;
1733 arect.Inflate( aAccuracy );
1734
1735 if( aContained )
1736 return arect.Contains( GetStart() ) && arect.Contains( GetEnd() );
1737 else
1738 return arect.Intersects( GetStart(), GetEnd() );
1739}
1740
1741
1742bool PCB_ARC::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
1743{
1744 BOX2I arect = aRect;
1745 arect.Inflate( aAccuracy );
1746
1747 BOX2I box( GetStart() );
1748 box.Merge( GetMid() );
1749 box.Merge( GetEnd() );
1750
1751 box.Inflate( GetWidth() / 2 );
1752
1753 if( aContained )
1754 return arect.Contains( box );
1755 else
1756 return arect.Intersects( box );
1757}
1758
1759
1760bool PCB_VIA::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
1761{
1762 BOX2I arect = aRect;
1763 arect.Inflate( aAccuracy );
1764
1765 bool hit = false;
1766
1768 [&]( PCB_LAYER_ID aLayer )
1769 {
1770 if( hit )
1771 return;
1772
1773 BOX2I box( GetStart() );
1774 box.Inflate( GetWidth( aLayer ) / 2 );
1775
1776 if( aContained )
1777 hit = arect.Contains( box );
1778 else
1779 hit = arect.IntersectsCircle( GetStart(), GetWidth( aLayer ) / 2 );
1780 } );
1781
1782 return hit;
1783}
1784
1785
1786wxString PCB_TRACK::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
1787{
1788 return wxString::Format( Type() == PCB_ARC_T ? _("Track (arc) %s on %s, length %s" )
1789 : _("Track %s on %s, length %s" ),
1790 GetNetnameMsg(),
1791 GetLayerName(),
1792 aUnitsProvider->MessageTextFromValue( GetLength() ) );
1793}
1794
1795
1797{
1798 return BITMAPS::add_tracks;
1799}
1800
1802{
1803 assert( aImage->Type() == PCB_TRACE_T );
1804
1805 std::swap( *((PCB_TRACK*) this), *((PCB_TRACK*) aImage) );
1806}
1807
1809{
1810 assert( aImage->Type() == PCB_ARC_T );
1811
1812 std::swap( *this, *static_cast<PCB_ARC*>( aImage ) );
1813}
1814
1816{
1817 assert( aImage->Type() == PCB_VIA_T );
1818
1819 std::swap( *((PCB_VIA*) this), *((PCB_VIA*) aImage) );
1820}
1821
1822
1824{
1826 return center;
1827}
1828
1829
1831{
1832 auto center = CalcArcCenter( m_Start, m_Mid , m_End );
1833 return center.Distance( m_Start );
1834}
1835
1836
1838{
1839 VECTOR2D center = GetPosition();
1840 EDA_ANGLE angle1 = EDA_ANGLE( m_Mid - center ) - EDA_ANGLE( m_Start - center );
1841 EDA_ANGLE angle2 = EDA_ANGLE( m_End - center ) - EDA_ANGLE( m_Mid - center );
1842
1843 return angle1.Normalize180() + angle2.Normalize180();
1844}
1845
1846
1848{
1849 VECTOR2D pos( GetPosition() );
1850 EDA_ANGLE angleStart( m_Start - pos );
1851
1852 return angleStart.Normalize();
1853}
1854
1855
1856// Note: used in python tests. Ignore CLion's claim that it's unused....
1858{
1859 VECTOR2D pos( GetPosition() );
1860 EDA_ANGLE angleEnd( m_End - pos );
1861
1862 return angleEnd.Normalize();
1863}
1864
1865bool PCB_ARC::IsDegenerated( int aThreshold ) const
1866{
1867 // Too small arcs cannot be really handled: arc center (and arc radius)
1868 // cannot be safely computed if the distance between mid and end points
1869 // is too small (a few internal units)
1870
1871 // len of both segments must be < aThreshold to be a very small degenerated arc
1872 return ( GetMid() - GetStart() ).EuclideanNorm() < aThreshold
1873 && ( GetMid() - GetEnd() ).EuclideanNorm() < aThreshold;
1874}
1875
1876
1878{
1879 if( a->GetNetCode() != b->GetNetCode() )
1880 return a->GetNetCode() < b->GetNetCode();
1881
1882 if( a->GetLayer() != b->GetLayer() )
1883 return a->GetLayer() < b->GetLayer();
1884
1885 if( a->Type() != b->Type() )
1886 return a->Type() < b->Type();
1887
1888 if( a->m_Uuid != b->m_Uuid )
1889 return a->m_Uuid < b->m_Uuid;
1890
1891 return a < b;
1892}
1893
1894
1895std::shared_ptr<SHAPE> PCB_TRACK::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
1896{
1897 int width = m_width;
1898
1899 if( IsSolderMaskLayer( aLayer ) )
1900 width += 2 * GetSolderMaskExpansion();
1901
1902 return std::make_shared<SHAPE_SEGMENT>( m_Start, m_End, width );
1903}
1904
1905
1906std::shared_ptr<SHAPE> PCB_VIA::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
1907{
1908 if( aFlash == FLASHING::ALWAYS_FLASHED
1909 || ( aFlash == FLASHING::DEFAULT && FlashLayer( aLayer ) ) )
1910 {
1911 int width = 0;
1912
1913 if( aLayer == UNDEFINED_LAYER )
1914 {
1915 Padstack().ForEachUniqueLayer(
1916 [&]( PCB_LAYER_ID layer )
1917 {
1918 width = std::max( width, GetWidth( layer ) );
1919 } );
1920
1921 width /= 2;
1922 }
1923 else
1924 {
1925 PCB_LAYER_ID cuLayer = m_padStack.EffectiveLayerFor( aLayer );
1926 width = GetWidth( cuLayer ) / 2;
1927 }
1928
1929 return std::make_shared<SHAPE_CIRCLE>( m_Start, width );
1930 }
1931 else
1932 {
1933 return std::make_shared<SHAPE_CIRCLE>( m_Start, GetDrillValue() / 2 );
1934 }
1935}
1936
1937
1938std::shared_ptr<SHAPE> PCB_ARC::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
1939{
1940 int width = GetWidth();
1941
1942 if( IsSolderMaskLayer( aLayer ) )
1943 width += 2 * GetSolderMaskExpansion();
1944
1945 return std::make_shared<SHAPE_ARC>( GetStart(), GetMid(), GetEnd(), width );
1946}
1947
1948
1950 int aClearance, int aError, ERROR_LOC aErrorLoc,
1951 bool ignoreLineWidth ) const
1952{
1953 wxASSERT_MSG( !ignoreLineWidth, wxT( "IgnoreLineWidth has no meaning for tracks." ) );
1954
1955
1956 switch( Type() )
1957 {
1958 case PCB_VIA_T:
1959 {
1960 int radius = ( static_cast<const PCB_VIA*>( this )->GetWidth( aLayer ) / 2 ) + aClearance;
1961 TransformCircleToPolygon( aBuffer, m_Start, radius, aError, aErrorLoc );
1962 break;
1963 }
1964
1965 case PCB_ARC_T:
1966 {
1967 const PCB_ARC* arc = static_cast<const PCB_ARC*>( this );
1968 int width = m_width + ( 2 * aClearance );
1969
1970 if( IsSolderMaskLayer( aLayer ) )
1971 width += 2 * GetSolderMaskExpansion();
1972
1973 TransformArcToPolygon( aBuffer, arc->GetStart(), arc->GetMid(), arc->GetEnd(), width,
1974 aError, aErrorLoc );
1975 break;
1976 }
1977
1978 default:
1979 {
1980 int width = m_width + ( 2 * aClearance );
1981
1982 if( IsSolderMaskLayer( aLayer ) )
1983 width += 2 * GetSolderMaskExpansion();
1984
1985 TransformOvalToPolygon( aBuffer, m_Start, m_End, width, aError, aErrorLoc );
1986
1987 break;
1988 }
1989 }
1990}
1991
1992
1993static struct TRACK_VIA_DESC
1994{
1996 {
1998 .Undefined( VIATYPE::NOT_DEFINED )
1999 .Map( VIATYPE::THROUGH, _HKI( "Through" ) )
2000 .Map( VIATYPE::BLIND_BURIED, _HKI( "Blind/buried" ) )
2001 .Map( VIATYPE::MICROVIA, _HKI( "Micro" ) );
2002
2004 .Undefined( TENTING_MODE::FROM_RULES )
2005 .Map( TENTING_MODE::FROM_RULES, _HKI( "From design rules" ) )
2006 .Map( TENTING_MODE::TENTED, _HKI( "Tented" ) )
2007 .Map( TENTING_MODE::NOT_TENTED, _HKI( "Not tented" ) );
2008
2010
2011 if( layerEnum.Choices().GetCount() == 0 )
2012 {
2013 layerEnum.Undefined( UNDEFINED_LAYER );
2014
2015 for( PCB_LAYER_ID layer : LSET::AllLayersMask().Seq() )
2016 layerEnum.Map( layer, LSET::Name( layer ) );
2017 }
2018
2020
2021 // Track
2024
2025 propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "Width" ),
2026 &PCB_TRACK::SetWidth, &PCB_TRACK::GetWidth, PROPERTY_DISPLAY::PT_SIZE ) );
2027 propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position X" ),
2029 &PCB_TRACK::SetX, &PCB_TRACK::GetX, PROPERTY_DISPLAY::PT_COORD,
2031 propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position Y" ),
2033 &PCB_TRACK::SetY, &PCB_TRACK::GetY, PROPERTY_DISPLAY::PT_COORD,
2035 propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "End X" ),
2036 &PCB_TRACK::SetEndX, &PCB_TRACK::GetEndX, PROPERTY_DISPLAY::PT_COORD,
2038 propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "End Y" ),
2039 &PCB_TRACK::SetEndY, &PCB_TRACK::GetEndY, PROPERTY_DISPLAY::PT_COORD,
2041
2042 const wxString groupTechLayers = _HKI( "Technical Layers" );
2043
2044 auto isExternalLayerTrack =
2045 []( INSPECTABLE* aItem )
2046 {
2047 if( auto track = dynamic_cast<PCB_TRACK*>( aItem ) )
2048 return track->GetLayer() == F_Cu || track->GetLayer() == B_Cu;
2049
2050 return false;
2051 };
2052
2053 propMgr.AddProperty( new PROPERTY<PCB_TRACK, bool>( _HKI( "Soldermask" ),
2055 .SetAvailableFunc( isExternalLayerTrack );
2056 propMgr.AddProperty( new PROPERTY<PCB_TRACK, std::optional<int>>( _HKI( "Soldermask Margin Override" ),
2058 PROPERTY_DISPLAY::PT_SIZE ), groupTechLayers )
2059 .SetAvailableFunc( isExternalLayerTrack );
2060
2061 // Arc
2064
2065 // Via
2068
2069 // TODO test drill, use getdrillvalue?
2070 const wxString groupVia = _HKI( "Via Properties" );
2071
2072 propMgr.Mask( TYPE_HASH( PCB_VIA ), TYPE_HASH( BOARD_CONNECTED_ITEM ), _HKI( "Layer" ) );
2073
2074 propMgr.AddProperty( new PROPERTY<PCB_VIA, int>( _HKI( "Diameter" ),
2075 &PCB_VIA::SetFrontWidth, &PCB_VIA::GetFrontWidth, PROPERTY_DISPLAY::PT_SIZE ), groupVia );
2076 propMgr.AddProperty( new PROPERTY<PCB_VIA, int>( _HKI( "Hole" ),
2077 &PCB_VIA::SetDrill, &PCB_VIA::GetDrillValue, PROPERTY_DISPLAY::PT_SIZE ), groupVia );
2078 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, PCB_LAYER_ID>( _HKI( "Layer Top" ),
2079 &PCB_VIA::SetLayer, &PCB_VIA::GetLayer ), groupVia );
2080 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, PCB_LAYER_ID>( _HKI( "Layer Bottom" ),
2082 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, VIATYPE>( _HKI( "Via Type" ),
2084 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, TENTING_MODE>( _HKI( "Front tenting" ),
2086 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, TENTING_MODE>( _HKI( "Back tenting" ),
2088 }
2090
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:66
@ ZLO_NONE
Definition: board_item.h:67
@ ZLO_FORCE_FLASHED
Definition: board_item.h:68
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:79
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:237
int GetY() const
Definition: board_item.h:100
virtual void SetLocked(bool aLocked)
Definition: board_item.h:328
PCB_LAYER_ID m_layer
Definition: board_item.h:436
int GetX() const
Definition: board_item.h:94
void SetX(int aX)
Definition: board_item.h:116
void SetY(int aY)
Definition: board_item.h:122
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:288
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:160
MINOPTMAX< int > & Value()
Definition: drc_rule.h:153
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:148
MASK_LAYER_PROPS & FrontOuterLayers()
Definition: padstack.h:306
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:807
void SetUnconnectedLayerMode(UNCONNECTED_LAYER_MODE aMode)
Definition: padstack.h:301
const LSET & LayerSet() const
Definition: padstack.h:268
void SetShape(PAD_SHAPE aShape, PCB_LAYER_ID aLayer)
Definition: padstack.cpp:906
DRILL_PROPS & Drill()
Definition: padstack.h:294
const VECTOR2I & Size(PCB_LAYER_ID aLayer) const
Definition: padstack.cpp:921
MASK_LAYER_PROPS & BackOuterLayers()
Definition: padstack.h:309
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: padstack.cpp:354
void SetSize(const VECTOR2I &aSize, PCB_LAYER_ID aLayer)
Definition: padstack.cpp:912
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:1823
bool IsDegenerated(int aThreshold=5) const
Definition: pcb_track.cpp:1865
virtual void swapData(BOARD_ITEM *aImage) override
Definition: pcb_track.cpp:1808
bool IsCCW() const
Definition: pcb_track.cpp:778
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:759
EDA_ANGLE GetArcAngleStart() const
Definition: pcb_track.cpp:1847
void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Mirror this object relative to a given horizontal axis the layer is not changed.
Definition: pcb_track.cpp:734
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:1671
EDA_ANGLE GetArcAngleEnd() const
Definition: pcb_track.cpp:1857
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:298
double GetRadius() const
Definition: pcb_track.cpp:1830
EDA_ANGLE GetAngle() const
Definition: pcb_track.cpp:1837
const VECTOR2I & GetMid() const
Definition: pcb_track.h:299
PCB_ARC(BOARD_ITEM *aParent)
Definition: pcb_track.h:274
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:360
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_track.cpp:719
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:1938
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:1022
virtual void SetLayerSet(const LSET &aLayers) override
Definition: pcb_track.cpp:1009
int GetSolderMaskExpansion() const
Definition: pcb_track.cpp:913
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_track.cpp:712
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:1302
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:1322
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:706
virtual void swapData(BOARD_ITEM *aImage) override
Definition: pcb_track.cpp:1801
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:1383
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:1786
virtual void Mirror(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Mirror this object relative to a given horizontal axis the layer is not changed.
Definition: pcb_track.cpp:727
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:813
bool ApproxCollinear(const PCB_TRACK &aTrack)
Definition: pcb_track.cpp:496
VECTOR2I m_End
Line end point.
Definition: pcb_track.h:261
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
Definition: pcb_track.h:142
std::optional< int > m_solderMaskMargin
Definition: pcb_track.h:264
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:1529
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:1949
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:260
int GetEndY() const
Definition: pcb_track.h:128
wxString GetFriendlyName() const override
Definition: pcb_track.cpp:1517
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pcb_track.cpp:1796
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:1665
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition: pcb_track.cpp:742
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:263
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:1895
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
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition: pcb_track.cpp:934
virtual MINOPTMAX< int > GetWidthConstraint(wxString *aSource=nullptr) const
Definition: pcb_track.cpp:504
void SetEndX(int aX)
Definition: pcb_track.h:124
int m_width
Thickness of track (or arc) – no longer the width of a via.
Definition: pcb_track.h:267
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:1626
PCB_LAYER_ID BottomLayer() const
Definition: pcb_track.cpp:1165
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:484
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:881
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:1906
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:1201
void SetDrillDefault()
Set the drill value for vias to the default value UNDEFINED_DRILL_DIAMETER.
Definition: pcb_track.h:621
std::map< PCB_LAYER_ID, ZONE_LAYER_OVERRIDE > m_zoneLayerOverrides
Definition: pcb_track.h:667
void ClearZoneLayerOverrides()
Definition: pcb_track.cpp:1248
const PADSTACK & Padstack() const
Definition: pcb_track.h:403
void SetFrontTentingMode(TENTING_MODE aMode)
Definition: pcb_track.cpp:835
bool m_isFree
"Free" vias don't get their nets auto-updated
Definition: pcb_track.h:664
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:1706
TENTING_MODE GetFrontTentingMode() const
Definition: pcb_track.cpp:846
void SetBottomLayer(PCB_LAYER_ID aLayer)
Definition: pcb_track.cpp:1131
int GetSolderMaskExpansion() const
Definition: pcb_track.cpp:904
void SetDrill(int aDrill)
Set the drill value for vias.
Definition: pcb_track.h:599
MINOPTMAX< int > GetDrillConstraint(wxString *aSource=nullptr) const
Definition: pcb_track.cpp:540
void SetBackTentingMode(TENTING_MODE aMode)
Definition: pcb_track.cpp:858
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition: pcb_track.cpp:788
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:1589
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:997
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pcb_track.cpp:1432
std::mutex m_zoneLayerOverridesMutex
Definition: pcb_track.h:666
void SetTopLayer(PCB_LAYER_ID aLayer)
Definition: pcb_track.cpp:1125
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Definition: pcb_track.cpp:829
int GetFrontWidth() const
Definition: pcb_track.h:417
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:1116
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:1003
virtual void SetLayerSet(const LSET &aLayers) override
Note SetLayerSet() initialize the first and last copper layers connected by the via.
Definition: pcb_track.cpp:1074
void GetOutermostConnectedLayers(PCB_LAYER_ID *aTopmost, PCB_LAYER_ID *aBottommost) const
Return the top-most and bottom-most connected layers.
Definition: pcb_track.cpp:1272
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:1396
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:1171
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:1815
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:1653
void SetViaType(VIATYPE aViaType)
Definition: pcb_track.h:401
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:952
TENTING_MODE GetBackTentingMode() const
Definition: pcb_track.cpp:869
PCB_LAYER_ID TopLayer() const
Definition: pcb_track.cpp:1159
VIATYPE m_viaType
through, blind/buried or micro
Definition: pcb_track.h:660
PADSTACK m_padStack
Definition: pcb_track.h:662
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:1265
void SetFrontWidth(int aWidth)
Definition: pcb_track.h:416
VIATYPE GetViaType() const
Definition: pcb_track.h:400
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:1038
const ZONE_LAYER_OVERRIDE & GetZoneLayerOverride(PCB_LAYER_ID aLayer) const
Definition: pcb_track.cpp:1257
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:1137
bool HasValidLayerPair(int aCopperLayerCount)
Definition: pcb_track.cpp:975
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_track.cpp:681
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:61
@ VIA_DIAMETER_CONSTRAINT
Definition: drc_rule.h:67
@ TRACK_WIDTH_CONSTRAINT
Definition: drc_rule.h:59
@ HOLE_SIZE_CONSTRAINT
Definition: drc_rule.h:54
#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:211
bool IsSolderMaskLayer(int aLayer)
Definition: layer_ids.h:591
@ 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:666
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:622
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:645
#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:696
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:532
@ 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:719
bool IsHoleLayer(int aLayer)
Definition: layer_ids.h:582
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:1877
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