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 The 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 // Padstack layerset is not used for vias right now
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_TRACK& aOther ) const
231{
232 if( aOther.Type() != Type() )
233 return false;
234
235 const PCB_ARC& other = static_cast<const PCB_ARC&>( aOther );
236
237 return *this == other;
238}
239
240
241bool PCB_ARC::operator==( const PCB_ARC& aOther ) const
242{
243 return m_Start == aOther.m_Start
244 && m_End == aOther.m_End
245 && m_Mid == aOther.m_Mid
246 && m_layer == aOther.m_layer
247 && GetWidth() == aOther.GetWidth()
250}
251
252
253double PCB_ARC::Similarity( const BOARD_ITEM& aOther ) const
254{
255 if( aOther.Type() != Type() )
256 return 0.0;
257
258 const PCB_ARC& other = static_cast<const PCB_ARC&>( aOther );
259
260 double similarity = 1.0;
261
262 if( m_layer != other.m_layer )
263 similarity *= 0.9;
264
265 if( GetWidth() != other.GetWidth() )
266 similarity *= 0.9;
267
268 if( m_Start != other.m_Start )
269 similarity *= 0.9;
270
271 if( m_End != other.m_End )
272 similarity *= 0.9;
273
274 if( m_Mid != other.m_Mid )
275 similarity *= 0.9;
276
277 if( m_hasSolderMask != other.m_hasSolderMask )
278 similarity *= 0.9;
279
281 similarity *= 0.9;
282
283 return similarity;
284}
285
286
287bool PCB_VIA::operator==( const BOARD_ITEM& aBoardItem ) const
288{
289 if( aBoardItem.Type() != Type() )
290 return false;
291
292 const PCB_VIA& other = static_cast<const PCB_VIA&>( aBoardItem );
293
294 return *this == other;
295}
296
297
298bool PCB_VIA::operator==( const PCB_TRACK& aOther ) const
299{
300 if( aOther.Type() != Type() )
301 return false;
302
303 const PCB_VIA& other = static_cast<const PCB_VIA&>( aOther );
304
305 return *this == other;
306}
307
308
309bool PCB_VIA::operator==( const PCB_VIA& aOther ) const
310{
311 return m_Start == aOther.m_Start
312 && m_End == aOther.m_End
313 && m_layer == aOther.m_layer
314 && m_padStack == aOther.m_padStack
315 && m_viaType == aOther.m_viaType
317}
318
319
320double PCB_VIA::Similarity( const BOARD_ITEM& aOther ) const
321{
322 if( aOther.Type() != Type() )
323 return 0.0;
324
325 const PCB_VIA& other = static_cast<const PCB_VIA&>( aOther );
326
327 double similarity = 1.0;
328
329 if( m_layer != other.m_layer )
330 similarity *= 0.9;
331
332 if( m_Start != other.m_Start )
333 similarity *= 0.9;
334
335 if( m_End != other.m_End )
336 similarity *= 0.9;
337
338 if( m_padStack != other.m_padStack )
339 similarity *= 0.9;
340
341 if( m_viaType != other.m_viaType )
342 similarity *= 0.9;
343
345 similarity *= 0.9;
346
347 return similarity;
348}
349
350
351void PCB_VIA::SetWidth( int aWidth )
352{
353 // This is present because of the parent class. It should never be actually called on a via.
354 wxASSERT_MSG( false, "Warning: PCB_VIA::SetWidth called without a layer argument" );
355 m_padStack.SetSize( { aWidth, aWidth }, PADSTACK::ALL_LAYERS );
356}
357
358
360{
361 // This is present because of the parent class. It should never be actually called on a via.
362 wxASSERT_MSG( false, "Warning: PCB_VIA::GetWidth called without a layer argument" );
364}
365
366
367void PCB_VIA::SetWidth( PCB_LAYER_ID aLayer, int aWidth )
368{
369 m_padStack.SetSize( { aWidth, aWidth }, aLayer );
370}
371
372
374{
375 return m_padStack.Size( aLayer ).x;
376}
377
378
379void PCB_TRACK::Serialize( google::protobuf::Any &aContainer ) const
380{
381 kiapi::board::types::Track track;
382
383 track.mutable_id()->set_value( m_Uuid.AsStdString() );
384 track.mutable_start()->set_x_nm( GetStart().x );
385 track.mutable_start()->set_y_nm( GetStart().y );
386 track.mutable_end()->set_x_nm( GetEnd().x );
387 track.mutable_end()->set_y_nm( GetEnd().y );
388 track.mutable_width()->set_value_nm( GetWidth() );
389 track.set_layer( ToProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( GetLayer() ) );
390 track.set_locked( IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
391 : kiapi::common::types::LockedState::LS_UNLOCKED );
392 track.mutable_net()->mutable_code()->set_value( GetNetCode() );
393 track.mutable_net()->set_name( GetNetname() );
394 // TODO m_hasSolderMask and m_solderMaskMargin
395
396 aContainer.PackFrom( track );
397}
398
399
400bool PCB_TRACK::Deserialize( const google::protobuf::Any &aContainer )
401{
402 kiapi::board::types::Track track;
403
404 if( !aContainer.UnpackTo( &track ) )
405 return false;
406
407 const_cast<KIID&>( m_Uuid ) = KIID( track.id().value() );
408 SetStart( VECTOR2I( track.start().x_nm(), track.start().y_nm() ) );
409 SetEnd( VECTOR2I( track.end().x_nm(), track.end().y_nm() ) );
410 SetWidth( track.width().value_nm() );
411 SetLayer( FromProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( track.layer() ) );
412 SetNetCode( track.net().code().value() );
413 SetLocked( track.locked() == kiapi::common::types::LockedState::LS_LOCKED );
414 // TODO m_hasSolderMask and m_solderMaskMargin
415
416 return true;
417}
418
419
420void PCB_ARC::Serialize( google::protobuf::Any &aContainer ) const
421{
422 kiapi::board::types::Arc arc;
423
424 arc.mutable_id()->set_value( m_Uuid.AsStdString() );
425 arc.mutable_start()->set_x_nm( GetStart().x );
426 arc.mutable_start()->set_y_nm( GetStart().y );
427 arc.mutable_mid()->set_x_nm( GetMid().x );
428 arc.mutable_mid()->set_y_nm( GetMid().y );
429 arc.mutable_end()->set_x_nm( GetEnd().x );
430 arc.mutable_end()->set_y_nm( GetEnd().y );
431 arc.mutable_width()->set_value_nm( GetWidth() );
432 arc.set_layer( ToProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( GetLayer() ) );
433 arc.set_locked( IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
434 : kiapi::common::types::LockedState::LS_UNLOCKED );
435 arc.mutable_net()->mutable_code()->set_value( GetNetCode() );
436 arc.mutable_net()->set_name( GetNetname() );
437 // TODO m_hasSolderMask and m_solderMaskMargin
438
439 aContainer.PackFrom( arc );
440}
441
442
443bool PCB_ARC::Deserialize( const google::protobuf::Any &aContainer )
444{
445 kiapi::board::types::Arc arc;
446
447 if( !aContainer.UnpackTo( &arc ) )
448 return false;
449
450 const_cast<KIID&>( m_Uuid ) = KIID( arc.id().value() );
451 SetStart( VECTOR2I( arc.start().x_nm(), arc.start().y_nm() ) );
452 SetMid( VECTOR2I( arc.mid().x_nm(), arc.mid().y_nm() ) );
453 SetEnd( VECTOR2I( arc.end().x_nm(), arc.end().y_nm() ) );
454 SetWidth( arc.width().value_nm() );
455 SetLayer( FromProtoEnum<PCB_LAYER_ID, kiapi::board::types::BoardLayer>( arc.layer() ) );
456 SetNetCode( arc.net().code().value() );
457 SetLocked( arc.locked() == kiapi::common::types::LockedState::LS_LOCKED );
458 // TODO m_hasSolderMask and m_solderMaskMargin
459
460 return true;
461}
462
463
464void PCB_VIA::Serialize( google::protobuf::Any &aContainer ) const
465{
466 kiapi::board::types::Via via;
467
468 via.mutable_id()->set_value( m_Uuid.AsStdString() );
469 via.mutable_position()->set_x_nm( GetPosition().x );
470 via.mutable_position()->set_y_nm( GetPosition().y );
471
472 PADSTACK padstack = Padstack();
473
474 google::protobuf::Any padStackWrapper;
475 padstack.Serialize( padStackWrapper );
476 padStackWrapper.UnpackTo( via.mutable_pad_stack() );
477
478 // PADSTACK::m_layerSet is not used by vias
479 via.mutable_pad_stack()->clear_layers();
480 kiapi::board::PackLayerSet( *via.mutable_pad_stack()->mutable_layers(), GetLayerSet() );
481
482 via.set_type( ToProtoEnum<VIATYPE, kiapi::board::types::ViaType>( GetViaType() ) );
483 via.set_locked( IsLocked() ? kiapi::common::types::LockedState::LS_LOCKED
484 : kiapi::common::types::LockedState::LS_UNLOCKED );
485 via.mutable_net()->mutable_code()->set_value( GetNetCode() );
486 via.mutable_net()->set_name( GetNetname() );
487
488 aContainer.PackFrom( via );
489}
490
491
492bool PCB_VIA::Deserialize( const google::protobuf::Any &aContainer )
493{
494 kiapi::board::types::Via via;
495
496 if( !aContainer.UnpackTo( &via ) )
497 return false;
498
499 const_cast<KIID&>( m_Uuid ) = KIID( via.id().value() );
500 SetStart( VECTOR2I( via.position().x_nm(), via.position().y_nm() ) );
501 SetEnd( GetStart() );
502
503 google::protobuf::Any padStackWrapper;
504 padStackWrapper.PackFrom( via.pad_stack() );
505
506 if( !m_padStack.Deserialize( padStackWrapper ) )
507 return false;
508
509 // PADSTACK::m_layerSet is not used by vias
511
512 SetViaType( FromProtoEnum<VIATYPE>( via.type() ) );
513 SetNetCode( via.net().code().value() );
514 SetLocked( via.locked() == kiapi::common::types::LockedState::LS_LOCKED );
515
516 return true;
517}
518
519
521{
522 SEG a( m_Start, m_End );
523 SEG b( aTrack.GetStart(), aTrack.GetEnd() );
524 return a.ApproxCollinear( b );
525}
526
527
529{
530 DRC_CONSTRAINT constraint;
531
532 if( GetBoard() && GetBoard()->GetDesignSettings().m_DRCEngine )
533 {
535
536 constraint = bds.m_DRCEngine->EvalRules( TRACK_WIDTH_CONSTRAINT, this, nullptr, m_layer );
537 }
538
539 if( aSource )
540 *aSource = constraint.GetName();
541
542 return constraint.Value();
543}
544
545
547{
548 DRC_CONSTRAINT constraint;
549
550 if( GetBoard() && GetBoard()->GetDesignSettings().m_DRCEngine )
551 {
553
554 constraint = bds.m_DRCEngine->EvalRules( VIA_DIAMETER_CONSTRAINT, this, nullptr, m_layer );
555 }
556
557 if( aSource )
558 *aSource = constraint.GetName();
559
560 return constraint.Value();
561}
562
563
565{
566 DRC_CONSTRAINT constraint;
567
568 if( GetBoard() && GetBoard()->GetDesignSettings().m_DRCEngine )
569 {
571
572 constraint = bds.m_DRCEngine->EvalRules( HOLE_SIZE_CONSTRAINT, this, nullptr, m_layer );
573 }
574
575 if( aSource )
576 *aSource = constraint.GetName();
577
578 return constraint.Value();
579}
580
581
582int PCB_VIA::GetMinAnnulus( PCB_LAYER_ID aLayer, wxString* aSource ) const
583{
584 if( !FlashLayer( aLayer ) )
585 {
586 if( aSource )
587 *aSource = _( "removed annular ring" );
588
589 return 0;
590 }
591
592 DRC_CONSTRAINT constraint;
593
594 if( GetBoard() && GetBoard()->GetDesignSettings().m_DRCEngine )
595 {
597
598 constraint = bds.m_DRCEngine->EvalRules( ANNULAR_WIDTH_CONSTRAINT, this, nullptr, aLayer );
599 }
600
601 if( constraint.Value().HasMin() )
602 {
603 if( aSource )
604 *aSource = constraint.GetName();
605
606 return constraint.Value().Min();
607 }
608
609 return 0;
610}
611
612
614{
615 if( m_padStack.Drill().size.x > 0 ) // Use the specific value.
616 return m_padStack.Drill().size.x;
617
618 // Use the default value from the Netclass
619 NETCLASS* netclass = GetEffectiveNetClass();
620
621 if( GetViaType() == VIATYPE::MICROVIA )
622 return netclass->GetuViaDrill();
623
624 return netclass->GetViaDrill();
625}
626
627
628EDA_ITEM_FLAGS PCB_TRACK::IsPointOnEnds( const VECTOR2I& point, int min_dist ) const
629{
630 EDA_ITEM_FLAGS result = 0;
631
632 if( min_dist < 0 )
633 min_dist = m_width / 2;
634
635 if( min_dist == 0 )
636 {
637 if( m_Start == point )
638 result |= STARTPOINT;
639
640 if( m_End == point )
641 result |= ENDPOINT;
642 }
643 else
644 {
645 double dist = m_Start.Distance( point );
646
647 if( min_dist >= dist )
648 result |= STARTPOINT;
649
650 dist = m_End.Distance( point );
651
652 if( min_dist >= dist )
653 result |= ENDPOINT;
654 }
655
656 return result;
657}
658
659
661{
662 // end of track is round, this is its radius, rounded up
663 int radius = ( m_width + 1 ) / 2;
664 int ymax, xmax, ymin, xmin;
665
666 if( Type() == PCB_VIA_T )
667 {
668 ymax = m_Start.y;
669 xmax = m_Start.x;
670
671 ymin = m_Start.y;
672 xmin = m_Start.x;
673 }
674 else if( Type() == PCB_ARC_T )
675 {
676 std::shared_ptr<SHAPE> arc = GetEffectiveShape();
677 BOX2I bbox = arc->BBox();
678
679 xmin = bbox.GetLeft();
680 xmax = bbox.GetRight();
681 ymin = bbox.GetTop();
682 ymax = bbox.GetBottom();
683 }
684 else
685 {
686 ymax = std::max( m_Start.y, m_End.y );
687 xmax = std::max( m_Start.x, m_End.x );
688
689 ymin = std::min( m_Start.y, m_End.y );
690 xmin = std::min( m_Start.x, m_End.x );
691 }
692
693 ymax += radius;
694 xmax += radius;
695
696 ymin -= radius;
697 xmin -= radius;
698
699 // return a rectangle which is [pos,dim) in nature. therefore the +1
700 return BOX2ISafe( VECTOR2I( xmin, ymin ),
701 VECTOR2L( (int64_t) xmax - xmin + 1, (int64_t) ymax - ymin + 1 ) );
702}
703
704
706{
707 int radius = 0;
708
710 [&]( PCB_LAYER_ID aLayer )
711 {
712 radius = std::max( radius, GetWidth( aLayer ) );
713 } );
714
715 // via is round, this is its radius, rounded up
716 radius = ( radius + 1 ) / 2;
717
718 int ymax = m_Start.y + radius;
719 int xmax = m_Start.x + radius;
720
721 int ymin = m_Start.y - radius;
722 int xmin = m_Start.x - radius;
723
724 // return a rectangle which is [pos,dim) in nature. therefore the +1
725 return BOX2ISafe( VECTOR2I( xmin, ymin ),
726 VECTOR2L( (int64_t) xmax - xmin + 1, (int64_t) ymax - ymin + 1 ) );
727}
728
729
731{
732 return m_Start.Distance( m_End );
733}
734
735
736void PCB_TRACK::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
737{
738 RotatePoint( m_Start, aRotCentre, aAngle );
739 RotatePoint( m_End, aRotCentre, aAngle );
740}
741
742
743void PCB_ARC::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
744{
745 RotatePoint( m_Start, aRotCentre, aAngle );
746 RotatePoint( m_End, aRotCentre, aAngle );
747 RotatePoint( m_Mid, aRotCentre, aAngle );
748}
749
750
751void PCB_TRACK::Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
752{
753 MIRROR( m_Start, aCentre, aFlipDirection );
754 MIRROR( m_End, aCentre, aFlipDirection );
755}
756
757
758void PCB_ARC::Mirror( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
759{
760 MIRROR( m_Start, aCentre, aFlipDirection );
761 MIRROR( m_End, aCentre, aFlipDirection );
762 MIRROR( m_Mid, aCentre, aFlipDirection );
763}
764
765
766void PCB_TRACK::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
767{
768 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
769 {
770 m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
771 m_End.x = aCentre.x - ( m_End.x - aCentre.x );
772 }
773 else
774 {
775 m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
776 m_End.y = aCentre.y - ( m_End.y - aCentre.y );
777 }
778
780}
781
782
783void PCB_ARC::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
784{
785 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
786 {
787 m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
788 m_End.x = aCentre.x - ( m_End.x - aCentre.x );
789 m_Mid.x = aCentre.x - ( m_Mid.x - aCentre.x );
790 }
791 else
792 {
793 m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
794 m_End.y = aCentre.y - ( m_End.y - aCentre.y );
795 m_Mid.y = aCentre.y - ( m_Mid.y - aCentre.y );
796 }
797
799}
800
801
802bool PCB_ARC::IsCCW() const
803{
804 VECTOR2L start = m_Start;
805 VECTOR2L start_end = m_End - start;
806 VECTOR2L start_mid = m_Mid - start;
807
808 return start_end.Cross( start_mid ) < 0;
809}
810
811
812void PCB_VIA::Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection )
813{
814 if( aFlipDirection == FLIP_DIRECTION::LEFT_RIGHT )
815 {
816 m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
817 m_End.x = aCentre.x - ( m_End.x - aCentre.x );
818 }
819 else
820 {
821 m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
822 m_End.y = aCentre.y - ( m_End.y - aCentre.y );
823 }
824
825 if( GetViaType() != VIATYPE::THROUGH )
826 {
827 PCB_LAYER_ID top_layer;
828 PCB_LAYER_ID bottom_layer;
829 LayerPair( &top_layer, &bottom_layer );
830 top_layer = GetBoard()->FlipLayer( top_layer );
831 bottom_layer = GetBoard()->FlipLayer( bottom_layer );
832 SetLayerPair( top_layer, bottom_layer );
833 }
834}
835
836
837INSPECT_RESULT PCB_TRACK::Visit( INSPECTOR inspector, void* testData,
838 const std::vector<KICAD_T>& aScanTypes )
839{
840 for( KICAD_T scanType : aScanTypes )
841 {
842 if( scanType == Type() )
843 {
844 if( INSPECT_RESULT::QUIT == inspector( this, testData ) )
845 return INSPECT_RESULT::QUIT;
846 }
847 }
848
849 return INSPECT_RESULT::CONTINUE;
850}
851
852
853std::shared_ptr<SHAPE_SEGMENT> PCB_VIA::GetEffectiveHoleShape() const
854{
855 return std::make_shared<SHAPE_SEGMENT>( SEG( m_Start, m_Start ), Padstack().Drill().size.x );
856}
857
858// clang-format off: the suggestion is slightly less readable
860{
861 switch( aMode )
862 {
863 case TENTING_MODE::FROM_RULES: m_padStack.FrontOuterLayers().has_solder_mask.reset(); break;
864 case TENTING_MODE::TENTED: m_padStack.FrontOuterLayers().has_solder_mask = true; break;
865 case TENTING_MODE::NOT_TENTED: m_padStack.FrontOuterLayers().has_solder_mask = false; break;
866 }
867}
868
869
871{
873 {
875 TENTING_MODE::TENTED : TENTING_MODE::NOT_TENTED;
876 }
877
878 return TENTING_MODE::FROM_RULES;
879}
880
881
883{
884 switch( aMode )
885 {
886 case TENTING_MODE::FROM_RULES: m_padStack.BackOuterLayers().has_solder_mask.reset(); break;
887 case TENTING_MODE::TENTED: m_padStack.BackOuterLayers().has_solder_mask = true; break;
888 case TENTING_MODE::NOT_TENTED: m_padStack.BackOuterLayers().has_solder_mask = false; break;
889 }
890}
891
892
894{
895 if( m_padStack.BackOuterLayers().has_solder_mask.has_value() )
896 {
898 TENTING_MODE::TENTED : TENTING_MODE::NOT_TENTED;
899 }
900
901 return TENTING_MODE::FROM_RULES;
902}
903
904
906{
907 switch( aMode )
908 {
909 case COVERING_MODE::FROM_RULES: m_padStack.FrontOuterLayers().has_covering.reset(); break;
910 case COVERING_MODE::COVERED: m_padStack.FrontOuterLayers().has_covering = true; break;
911 case COVERING_MODE::NOT_COVERED: m_padStack.FrontOuterLayers().has_covering = false; break;
912 }
913}
914
915
917{
918 if( m_padStack.FrontOuterLayers().has_covering.has_value() )
919 {
921 COVERING_MODE::COVERED : COVERING_MODE::NOT_COVERED;
922 }
923
924 return COVERING_MODE::FROM_RULES;
925}
926
927
929{
930 switch( aMode )
931 {
932 case COVERING_MODE::FROM_RULES: m_padStack.BackOuterLayers().has_covering.reset(); break;
933 case COVERING_MODE::COVERED: m_padStack.BackOuterLayers().has_covering = true; break;
934 case COVERING_MODE::NOT_COVERED: m_padStack.BackOuterLayers().has_covering = false; break;
935 }
936}
937
938
940{
941 if( m_padStack.BackOuterLayers().has_covering.has_value() )
942 {
944 COVERING_MODE::COVERED : COVERING_MODE::NOT_COVERED;
945 }
946
947 return COVERING_MODE::FROM_RULES;
948}
949
950
952{
953 switch( aMode )
954 {
955 case PLUGGING_MODE::FROM_RULES: m_padStack.FrontOuterLayers().has_plugging.reset(); break;
956 case PLUGGING_MODE::PLUGGED: m_padStack.FrontOuterLayers().has_plugging = true; break;
957 case PLUGGING_MODE::NOT_PLUGGED: m_padStack.FrontOuterLayers().has_plugging = false; break;
958 }
959}
960
961
963{
964 if( m_padStack.FrontOuterLayers().has_plugging.has_value() )
965 {
967 PLUGGING_MODE::PLUGGED : PLUGGING_MODE::NOT_PLUGGED;
968 }
969
970 return PLUGGING_MODE::FROM_RULES;
971}
972
973
975{
976 switch( aMode )
977 {
978 case PLUGGING_MODE::FROM_RULES: m_padStack.BackOuterLayers().has_plugging.reset(); break;
979 case PLUGGING_MODE::PLUGGED: m_padStack.BackOuterLayers().has_plugging = true; break;
980 case PLUGGING_MODE::NOT_PLUGGED: m_padStack.BackOuterLayers().has_plugging = false; break;
981 }
982}
983
984
986{
987 if( m_padStack.BackOuterLayers().has_plugging.has_value() )
988 {
990 PLUGGING_MODE::PLUGGED : PLUGGING_MODE::NOT_PLUGGED;
991 }
992
993 return PLUGGING_MODE::FROM_RULES;
994}
995
996
998{
999 switch( aMode )
1000 {
1001 case CAPPING_MODE::FROM_RULES: m_padStack.Drill().is_capped.reset(); break;
1002 case CAPPING_MODE::CAPPED: m_padStack.Drill().is_capped = true; break;
1003 case CAPPING_MODE::NOT_CAPPED: m_padStack.Drill().is_capped = false; break;
1004 }
1005}
1006
1007
1009{
1010 if( m_padStack.Drill().is_capped.has_value() )
1011 {
1012 return *m_padStack.Drill().is_capped ?
1013 CAPPING_MODE::CAPPED : CAPPING_MODE::NOT_CAPPED;
1014 }
1015
1016 return CAPPING_MODE::FROM_RULES;
1017}
1018
1019
1021{
1022 switch( aMode )
1023 {
1024 case FILLING_MODE::FROM_RULES: m_padStack.Drill().is_filled.reset(); break;
1025 case FILLING_MODE::FILLED: m_padStack.Drill().is_filled = true; break;
1026 case FILLING_MODE::NOT_FILLED: m_padStack.Drill().is_filled = false; break;
1027 }
1028}
1029
1030
1032{
1033 if( m_padStack.Drill().is_filled.has_value() )
1034 {
1035 return *m_padStack.Drill().is_filled ?
1036 FILLING_MODE::FILLED : FILLING_MODE::NOT_FILLED;
1037 }
1038
1039 return FILLING_MODE::FROM_RULES;
1040}
1041// clang-format on: the suggestion is slightly less readable
1042
1043
1045{
1046 wxCHECK_MSG( IsFrontLayer( aLayer ) || IsBackLayer( aLayer ), true,
1047 "Invalid layer passed to IsTented" );
1048
1049 bool front = IsFrontLayer( aLayer );
1050
1051 if( front && m_padStack.FrontOuterLayers().has_solder_mask.has_value() )
1053
1054 if( !front && m_padStack.BackOuterLayers().has_solder_mask.has_value() )
1056
1057 if( const BOARD* board = GetBoard() )
1058 {
1059 return front ? board->GetDesignSettings().m_TentViasFront
1060 : board->GetDesignSettings().m_TentViasBack;
1061 }
1062
1063 return true;
1064}
1065
1066
1068{
1069 if( const BOARD* board = GetBoard() )
1070 return board->GetDesignSettings().m_SolderMaskExpansion;
1071 else
1072 return 0;
1073}
1074
1075
1077{
1078 int margin = m_solderMaskMargin.value_or( 0 );
1079
1080 // If no local margin is set, get the board's solder mask expansion value
1081 if( !m_solderMaskMargin.has_value() )
1082 {
1083 const BOARD* board = GetBoard();
1084
1085 if( board )
1086 margin = board->GetDesignSettings().m_SolderMaskExpansion;
1087 }
1088
1089 // Ensure the resulting mask opening has a non-negative size
1090 if( margin < 0 )
1091 margin = std::max( margin, -m_width / 2 );
1092
1093 return margin;
1094}
1095
1096
1098{
1099 if( aLayer == m_layer )
1100 {
1101 return true;
1102 }
1103
1104 if( m_hasSolderMask
1105 && ( ( aLayer == F_Mask && m_layer == F_Cu )
1106 || ( aLayer == B_Mask && m_layer == B_Cu ) ) )
1107 {
1108 return true;
1109 }
1110
1111 return false;
1112}
1113
1114
1116{
1117#if 0
1118 // Nice and simple, but raises its ugly head in performance profiles....
1119 return GetLayerSet().test( aLayer );
1120#endif
1121 if( IsCopperLayer( aLayer ) &&
1122 LAYER_RANGE::Contains( Padstack().Drill().start, Padstack().Drill().end, aLayer ) )
1123 {
1124 return true;
1125 }
1126
1127 // Test for via on mask layers: a via on on a mask layer if not tented and if
1128 // it is on the corresponding external copper layer
1129 if( aLayer == F_Mask )
1130 return Padstack().Drill().start == F_Cu && !IsTented( F_Mask );
1131 else if( aLayer == B_Mask )
1132 return Padstack().Drill().end == B_Cu && !IsTented( B_Mask );
1133
1134 return false;
1135}
1136
1137
1138bool PCB_VIA::HasValidLayerPair( int aCopperLayerCount )
1139{
1140 // return true if top and bottom layers are valid, depending on the copper layer count
1141 // aCopperLayerCount is expected >= 2
1142
1143 int layer_id = aCopperLayerCount*2;
1144
1145 if( Padstack().Drill().start > B_Cu )
1146 {
1147 if( Padstack().Drill().start > layer_id )
1148 return false;
1149 }
1150 if( Padstack().Drill().end > B_Cu )
1151 {
1152 if( Padstack().Drill().end > layer_id )
1153 return false;
1154 }
1155
1156 return true;
1157}
1158
1159
1161{
1162 return Padstack().Drill().start;
1163}
1164
1165
1167{
1168 Padstack().Drill().start = aLayer;
1169}
1170
1171
1172void PCB_TRACK::SetLayerSet( const LSET& aLayerSet )
1173{
1174 aLayerSet.RunOnLayers(
1175 [&]( PCB_LAYER_ID layer )
1176 {
1177 if( IsCopperLayer( layer ) )
1178 SetLayer( layer );
1179 else if( IsSolderMaskLayer( layer ) )
1180 SetHasSolderMask( true );
1181 } );
1182}
1183
1184
1186{
1187 LSET layermask( { m_layer } );
1188
1189 if( m_hasSolderMask )
1190 {
1191 if( layermask.test( F_Cu ) )
1192 layermask.set( F_Mask );
1193 else if( layermask.test( B_Cu ) )
1194 layermask.set( B_Mask );
1195 }
1196
1197 return layermask;
1198}
1199
1200
1202{
1203 LSET layermask;
1204
1205 if( Padstack().Drill().start < PCBNEW_LAYER_ID_START )
1206 return layermask;
1207
1208 if( GetViaType() == VIATYPE::THROUGH )
1209 {
1210 layermask = LSET::AllCuMask( BoardCopperLayerCount() );
1211 }
1212 else
1213 {
1214 LAYER_RANGE range( Padstack().Drill().start, Padstack().Drill().end, BoardCopperLayerCount() );
1215
1216 int cnt = BoardCopperLayerCount();
1217 // PCB_LAYER_IDs are numbered from front to back, this is top to bottom.
1218 for( PCB_LAYER_ID id : range )
1219 {
1220 layermask.set( id );
1221
1222 if( --cnt <= 0 )
1223 break;
1224 }
1225 }
1226
1227 if( !IsTented( F_Mask ) && layermask.test( F_Cu ) )
1228 layermask.set( F_Mask );
1229
1230 if( !IsTented( B_Mask ) && layermask.test( B_Cu ) )
1231 layermask.set( B_Mask );
1232
1233 return layermask;
1234}
1235
1236
1237void PCB_VIA::SetLayerSet( const LSET& aLayerSet )
1238{
1239 // Vias do not use a LSET, just a top and bottom layer pair
1240 // So we need to set these 2 layers according to the allowed layers in aLayerSet
1241
1242 // For via through, only F_Cu and B_Cu are allowed. aLayerSet is ignored
1243 if( GetViaType() == VIATYPE::THROUGH )
1244 {
1245 Padstack().Drill().start = F_Cu;
1246 Padstack().Drill().end = B_Cu;
1247 return;
1248 }
1249
1250 // For blind buried vias, find the top and bottom layers
1251 bool top_found = false;
1252 bool bottom_found = false;
1253
1254 aLayerSet.RunOnLayers(
1255 [&]( PCB_LAYER_ID layer )
1256 {
1257 // tpo layer and bottom Layer are copper layers, so consider only copper layers
1258 if( IsCopperLayer( layer ) )
1259 {
1260 // The top layer is the first layer found in list and
1261 // cannot the B_Cu
1262 if( !top_found && layer != B_Cu )
1263 {
1264 Padstack().Drill().start = layer;
1265 top_found = true;
1266 }
1267
1268 // The bottom layer is the last layer found in list or B_Cu
1269 if( !bottom_found )
1270 Padstack().Drill().end = layer;
1271
1272 if( layer == B_Cu )
1273 bottom_found = true;
1274 }
1275 } );
1276}
1277
1278
1279void PCB_VIA::SetLayerPair( PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer )
1280{
1281
1282 Padstack().Drill().start = aTopLayer;
1283 Padstack().Drill().end = aBottomLayer;
1285}
1286
1287
1289{
1290 Padstack().Drill().start = aLayer;
1291}
1292
1293
1295{
1296 Padstack().Drill().end = aLayer;
1297}
1298
1299
1300void PCB_VIA::LayerPair( PCB_LAYER_ID* top_layer, PCB_LAYER_ID* bottom_layer ) const
1301{
1302 PCB_LAYER_ID t_layer = F_Cu;
1303 PCB_LAYER_ID b_layer = B_Cu;
1304
1305 if( GetViaType() != VIATYPE::THROUGH )
1306 {
1307 b_layer = Padstack().Drill().end;
1308 t_layer = Padstack().Drill().start;
1309
1310 if( !IsCopperLayerLowerThan( b_layer, t_layer ) )
1311 std::swap( b_layer, t_layer );
1312 }
1313
1314 if( top_layer )
1315 *top_layer = t_layer;
1316
1317 if( bottom_layer )
1318 *bottom_layer = b_layer;
1319}
1320
1321
1323{
1324 return Padstack().Drill().start;
1325}
1326
1327
1329{
1330 return Padstack().Drill().end;
1331}
1332
1333
1335{
1336 if( GetViaType() == VIATYPE::THROUGH )
1337 {
1338 Padstack().Drill().start = F_Cu;
1339 Padstack().Drill().end = B_Cu;
1340 }
1341
1342 if( !IsCopperLayerLowerThan( Padstack().Drill().end, Padstack().Drill().start) )
1343 std::swap( Padstack().Drill().end, Padstack().Drill().start );
1344}
1345
1346
1347bool PCB_VIA::FlashLayer( LSET aLayers ) const
1348{
1349 for( size_t ii = 0; ii < aLayers.size(); ++ii )
1350 {
1351 if( aLayers.test( ii ) )
1352 {
1353 PCB_LAYER_ID layer = PCB_LAYER_ID( ii );
1354
1355 if( FlashLayer( layer ) )
1356 return true;
1357 }
1358 }
1359
1360 return false;
1361}
1362
1363
1364bool PCB_VIA::FlashLayer( int aLayer ) const
1365{
1366 // Return the "normal" shape if the caller doesn't specify a particular layer
1367 if( aLayer == UNDEFINED_LAYER )
1368 return true;
1369
1370 const BOARD* board = GetBoard();
1371 PCB_LAYER_ID layer = static_cast<PCB_LAYER_ID>( aLayer );
1372
1373 if( !board )
1374 return true;
1375
1376 if( !IsOnLayer( layer ) )
1377 return false;
1378
1379 if( !IsCopperLayer( layer ) )
1380 return true;
1381
1382 switch( Padstack().UnconnectedLayerMode() )
1383 {
1385 return true;
1386
1388 {
1389 if( layer == Padstack().Drill().start || layer == Padstack().Drill().end )
1390 return true;
1391
1392 // Check for removal below
1393 break;
1394 }
1395
1397 // Check for removal below
1398 break;
1399 }
1400
1401 if( GetZoneLayerOverride( layer ) == ZLO_FORCE_FLASHED )
1402 {
1403 return true;
1404 }
1405 else
1406 {
1407 // Must be static to keep from raising its ugly head in performance profiles
1408 static std::initializer_list<KICAD_T> nonZoneTypes = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T,
1409 PCB_PAD_T };
1410
1411 return board->GetConnectivity()->IsConnectedOnLayer( this, layer, nonZoneTypes );
1412 }
1413}
1414
1415
1417{
1418 std::unique_lock<std::mutex> cacheLock( m_zoneLayerOverridesMutex );
1419
1422}
1423
1424
1426{
1427 static const ZONE_LAYER_OVERRIDE defaultOverride = ZLO_NONE;
1428 auto it = m_zoneLayerOverrides.find( aLayer );
1429 return it != m_zoneLayerOverrides.end() ? it->second : defaultOverride;
1430}
1431
1432
1434{
1435 std::unique_lock<std::mutex> cacheLock( m_zoneLayerOverridesMutex );
1436 m_zoneLayerOverrides[aLayer] = aOverride;
1437}
1438
1439
1441 PCB_LAYER_ID* aBottommost ) const
1442{
1443 *aTopmost = UNDEFINED_LAYER;
1444 *aBottommost = UNDEFINED_LAYER;
1445
1446 static std::initializer_list<KICAD_T> nonZoneTypes = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T,
1447 PCB_PAD_T };
1448
1449 for( int layer = TopLayer(); layer <= BottomLayer(); ++layer )
1450 {
1451 bool connected = false;
1452
1453 if( GetZoneLayerOverride( static_cast<PCB_LAYER_ID>( layer ) ) == ZLO_FORCE_FLASHED )
1454 {
1455 connected = true;
1456 }
1457 else if( GetBoard()->GetConnectivity()->IsConnectedOnLayer( this, layer, nonZoneTypes ) )
1458 {
1459 connected = true;
1460 }
1461
1462 if( connected )
1463 {
1464 if( *aTopmost == UNDEFINED_LAYER )
1465 *aTopmost = ToLAYER_ID( layer );
1466
1467 *aBottommost = ToLAYER_ID( layer );
1468 }
1469 }
1470
1471}
1472
1473
1474std::vector<int> PCB_TRACK::ViewGetLayers() const
1475{
1476 // Show the track and its netname on different layers
1477 const PCB_LAYER_ID layer = GetLayer();
1478 std::vector<int> layers{
1479 layer,
1480 GetNetnameLayer( layer ),
1481 LAYER_CLEARANCE_START + layer,
1482 };
1483
1484 layers.reserve( 6 );
1485
1486 if( m_hasSolderMask )
1487 {
1488 if( m_layer == F_Cu )
1489 layers.push_back( F_Mask );
1490 else if( m_layer == B_Cu )
1491 layers.push_back( B_Mask );
1492 }
1493
1494 if( IsLocked() )
1495 layers.push_back( LAYER_LOCKED_ITEM_SHADOW );
1496
1497 return layers;
1498}
1499
1500
1501double PCB_TRACK::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
1502{
1503 PCB_PAINTER* painter = static_cast<PCB_PAINTER*>( aView->GetPainter() );
1504 PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
1505
1506 if( !aView->IsLayerVisible( LAYER_TRACKS ) )
1507 return LOD_HIDE;
1508
1509 if( IsNetnameLayer( aLayer ) )
1510 {
1512 return LOD_HIDE;
1513
1514 // Hide netnames on dimmed tracks
1515 if( renderSettings->GetHighContrast() )
1516 {
1517 if( m_layer != renderSettings->GetPrimaryHighContrastLayer() )
1518 return LOD_HIDE;
1519 }
1520
1521 VECTOR2I start( GetStart() );
1522 VECTOR2I end( GetEnd() );
1523
1524 // Calc the approximate size of the netname (assume square chars)
1525 SEG::ecoord nameSize = GetDisplayNetname().size() * GetWidth();
1526
1527 if( VECTOR2I( end - start ).SquaredEuclideanNorm() < nameSize * nameSize )
1528 return LOD_HIDE;
1529
1530 BOX2I clipBox = BOX2ISafe( aView->GetViewport() );
1531
1532 ClipLine( &clipBox, start.x, start.y, end.x, end.y );
1533
1534 if( VECTOR2I( end - start ).SquaredEuclideanNorm() == 0 )
1535 return LOD_HIDE;
1536
1537 // Netnames will be shown only if zoom is appropriate
1538 return lodScaleForThreshold( aView, m_width, pcbIUScale.mmToIU( 4.0 ) );
1539 }
1540
1541 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
1542 {
1543 // Hide shadow if the main layer is not shown
1544 if( !aView->IsLayerVisible( m_layer ) )
1545 return LOD_HIDE;
1546
1547 // Hide shadow on dimmed tracks
1548 if( renderSettings->GetHighContrast() )
1549 {
1550 if( m_layer != renderSettings->GetPrimaryHighContrastLayer() )
1551 return LOD_HIDE;
1552 }
1553 }
1554
1555 // Other layers are shown without any conditions
1556 return LOD_SHOW;
1557}
1558
1559
1561{
1562 BOX2I bbox = GetBoundingBox();
1563
1564 if( const BOARD* board = GetBoard() )
1565 bbox.Inflate( 2 * board->GetDesignSettings().GetBiggestClearanceValue() );
1566 else
1567 bbox.Inflate( GetWidth() ); // Add a bit extra for safety
1568
1569 return bbox;
1570}
1571
1572
1573std::vector<int> PCB_VIA::ViewGetLayers() const
1574{
1575 LAYER_RANGE layers( Padstack().Drill().start, Padstack().Drill().end, MAX_CU_LAYERS );
1576 std::vector<int> ret_layers{ LAYER_VIA_HOLES, LAYER_VIA_HOLEWALLS, LAYER_VIA_NETNAMES };
1577 ret_layers.reserve( MAX_CU_LAYERS + 6 );
1578
1579 // TODO(JE) Rendering order issue
1580#if 0
1581 // Blind/buried vias (and microvias) use a different net name layer
1582 PCB_LAYER_ID layerTop, layerBottom;
1583 LayerPair( &layerTop, &layerBottom );
1584
1585 bool isBlindBuried =
1586 m_viaType == VIATYPE::BLIND_BURIED
1587 || ( m_viaType == VIATYPE::MICROVIA && ( layerTop != F_Cu || layerBottom != B_Cu ) );
1588#endif
1589 LSET cuMask = LSET::AllCuMask();
1590
1591 if( const BOARD* board = GetBoard() )
1592 cuMask = board->GetEnabledLayers();
1593
1594 for( PCB_LAYER_ID layer : layers )
1595 {
1596 if( !cuMask.Contains( layer ) )
1597 continue;
1598
1599 ret_layers.push_back( LAYER_VIA_COPPER_START + layer );
1600 ret_layers.push_back( LAYER_CLEARANCE_START + layer );
1601 }
1602
1603 if( IsLocked() )
1604 ret_layers.push_back( LAYER_LOCKED_ITEM_SHADOW );
1605
1606 // Vias can also be on a solder mask layer. They are on these layers or not,
1607 // depending on the plot and solder mask options
1608 if( IsOnLayer( F_Mask ) )
1609 ret_layers.push_back( F_Mask );
1610
1611 if( IsOnLayer( B_Mask ) )
1612 ret_layers.push_back( B_Mask );
1613
1614 return ret_layers;
1615}
1616
1617
1618double PCB_VIA::ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const
1619{
1620 PCB_PAINTER* painter = static_cast<PCB_PAINTER*>( aView->GetPainter() );
1621 PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
1622 LSET visible = LSET::AllLayersMask();
1623
1624 // Meta control for hiding all vias
1625 if( !aView->IsLayerVisible( LAYER_VIAS ) )
1626 return LOD_HIDE;
1627
1628 // Handle board visibility
1629 if( const BOARD* board = GetBoard() )
1630 visible = board->GetVisibleLayers() & board->GetEnabledLayers();
1631
1632 int width = GetWidth( ToLAYER_ID( aLayer ) );
1633
1634 // In high contrast mode don't show vias that don't cross the high-contrast layer
1635 if( renderSettings->GetHighContrast() )
1636 {
1637 PCB_LAYER_ID highContrastLayer = renderSettings->GetPrimaryHighContrastLayer();
1638
1639 if( LSET::FrontTechMask().Contains( highContrastLayer ) )
1640 highContrastLayer = F_Cu;
1641 else if( LSET::BackTechMask().Contains( highContrastLayer ) )
1642 highContrastLayer = B_Cu;
1643
1644 if( IsCopperLayer( highContrastLayer ) && GetViaType() != VIATYPE::THROUGH )
1645 {
1646 if( IsCopperLayerLowerThan( Padstack().Drill().start, highContrastLayer )
1647 || IsCopperLayerLowerThan( highContrastLayer, Padstack().Drill().end ) )
1648 {
1649 return LOD_HIDE;
1650 }
1651 }
1652 }
1653
1654 if( IsHoleLayer( aLayer ) )
1655 {
1656 if( m_viaType == VIATYPE::THROUGH )
1657 {
1658 // Show a through via's hole if any physical layer is shown
1659 if( !( visible & LSET::PhysicalLayersMask() ).any() )
1660 return LOD_HIDE;
1661 }
1662 else
1663 {
1664 // Show a blind or micro via's hole if it crosses a visible layer
1665 if( !( visible & GetLayerSet() ).any() )
1666 return LOD_HIDE;
1667 }
1668
1669 // The hole won't be visible anyway at this scale
1670 return (double) pcbIUScale.mmToIU( 0.25 ) / GetDrillValue();
1671 }
1672 else if( IsNetnameLayer( aLayer ) )
1673 {
1674 if( renderSettings->GetHighContrast() )
1675 {
1676 // Hide netnames unless via is flashed to a high-contrast layer
1677 if( !FlashLayer( renderSettings->GetPrimaryHighContrastLayer() ) )
1678 return LOD_HIDE;
1679 }
1680 else
1681 {
1682 // Hide netnames unless pad is flashed to a visible layer
1683 if( !FlashLayer( visible ) )
1684 return LOD_HIDE;
1685 }
1686
1687 // Netnames will be shown only if zoom is appropriate
1688 return lodScaleForThreshold( aView, width, pcbIUScale.mmToIU( 10 ) );
1689 }
1690
1691 if( !IsCopperLayer( aLayer ) )
1692 return lodScaleForThreshold( aView, width, pcbIUScale.mmToIU( 0.6 ) );
1693
1694 return LOD_SHOW;
1695}
1696
1697
1699{
1700 switch( Type() )
1701 {
1702 case PCB_ARC_T: return _( "Track (arc)" );
1703 case PCB_VIA_T: return _( "Via" );
1704 case PCB_TRACE_T:
1705 default: return _( "Track" );
1706 }
1707}
1708
1709
1710void PCB_TRACK::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
1711{
1712 wxString msg;
1713 BOARD* board = GetBoard();
1714
1715 aList.emplace_back( _( "Type" ), GetFriendlyName() );
1716
1717 GetMsgPanelInfoBase_Common( aFrame, aList );
1718
1719 aList.emplace_back( _( "Layer" ), layerMaskDescribe() );
1720
1721 aList.emplace_back( _( "Width" ), aFrame->MessageTextFromValue( m_width ) );
1722
1723 if( Type() == PCB_ARC_T )
1724 {
1725 double radius = static_cast<PCB_ARC*>( this )->GetRadius();
1726 aList.emplace_back( _( "Radius" ), aFrame->MessageTextFromValue( radius ) );
1727 }
1728
1729 aList.emplace_back( _( "Segment Length" ), aFrame->MessageTextFromValue( GetLength() ) );
1730
1731 // Display full track length (in Pcbnew)
1732 if( board && GetNetCode() > 0 )
1733 {
1734 int count;
1735 double trackLen;
1736 double lenPadToDie;
1737
1738 std::tie( count, trackLen, lenPadToDie ) = board->GetTrackLength( *this );
1739
1740 aList.emplace_back( _( "Routed Length" ), aFrame->MessageTextFromValue( trackLen ) );
1741
1742 if( lenPadToDie != 0 )
1743 {
1744 msg = aFrame->MessageTextFromValue( lenPadToDie );
1745 aList.emplace_back( _( "Pad To Die Length" ), msg );
1746
1747 msg = aFrame->MessageTextFromValue( trackLen + lenPadToDie );
1748 aList.emplace_back( _( "Full Length" ), msg );
1749 }
1750 }
1751
1752 wxString source;
1753 int clearance = GetOwnClearance( GetLayer(), &source );
1754
1755 aList.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
1756 aFrame->MessageTextFromValue( clearance ) ),
1757 wxString::Format( _( "(from %s)" ), source ) );
1758
1759 MINOPTMAX<int> constraintValue = GetWidthConstraint( &source );
1760 msg = aFrame->MessageTextFromMinOptMax( constraintValue );
1761
1762 if( !msg.IsEmpty() )
1763 {
1764 aList.emplace_back( wxString::Format( _( "Width Constraints: %s" ), msg ),
1765 wxString::Format( _( "(from %s)" ), source ) );
1766 }
1767}
1768
1769
1770void PCB_VIA::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
1771{
1772 wxString msg;
1773
1774 switch( GetViaType() )
1775 {
1776 case VIATYPE::MICROVIA: msg = _( "Micro Via" ); break;
1777 case VIATYPE::BLIND_BURIED: msg = _( "Blind/Buried Via" ); break;
1778 case VIATYPE::THROUGH: msg = _( "Through Via" ); break;
1779 default: msg = _( "Via" ); break;
1780 }
1781
1782 aList.emplace_back( _( "Type" ), msg );
1783
1784 GetMsgPanelInfoBase_Common( aFrame, aList );
1785
1786 aList.emplace_back( _( "Layer" ), layerMaskDescribe() );
1787 // TODO(JE) padstacks
1788 aList.emplace_back( _( "Diameter" ),
1790 aList.emplace_back( _( "Hole" ), aFrame->MessageTextFromValue( GetDrillValue() ) );
1791
1792 wxString source;
1793 int clearance = GetOwnClearance( GetLayer(), &source );
1794
1795 aList.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
1796 aFrame->MessageTextFromValue( clearance ) ),
1797 wxString::Format( _( "(from %s)" ), source ) );
1798
1799 int minAnnulus = GetMinAnnulus( GetLayer(), &source );
1800
1801 aList.emplace_back( wxString::Format( _( "Min Annular Width: %s" ),
1802 aFrame->MessageTextFromValue( minAnnulus ) ),
1803 wxString::Format( _( "(from %s)" ), source ) );
1804}
1805
1806
1808 std::vector<MSG_PANEL_ITEM>& aList ) const
1809{
1810 aList.emplace_back( _( "Net" ), UnescapeString( GetNetname() ) );
1811
1812 aList.emplace_back( _( "Resolved Netclass" ),
1813 UnescapeString( GetEffectiveNetClass()->GetHumanReadableName() ) );
1814
1815#if 0 // Enable for debugging
1816 if( GetBoard() )
1817 aList.emplace_back( _( "NetCode" ), wxString::Format( wxT( "%d" ), GetNetCode() ) );
1818
1819 aList.emplace_back( wxT( "Flags" ), wxString::Format( wxT( "0x%08X" ), m_flags ) );
1820
1821 aList.emplace_back( wxT( "Start pos" ), wxString::Format( wxT( "%d %d" ),
1822 m_Start.x,
1823 m_Start.y ) );
1824 aList.emplace_back( wxT( "End pos" ), wxString::Format( wxT( "%d %d" ),
1825 m_End.x,
1826 m_End.y ) );
1827#endif
1828
1829 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
1830 aList.emplace_back( _( "Status" ), _( "Locked" ) );
1831}
1832
1833
1835{
1836 const BOARD* board = GetBoard();
1837 PCB_LAYER_ID top_layer;
1838 PCB_LAYER_ID bottom_layer;
1839
1840 LayerPair( &top_layer, &bottom_layer );
1841
1842 return board->GetLayerName( top_layer ) + wxT( " - " ) + board->GetLayerName( bottom_layer );
1843}
1844
1845
1846bool PCB_TRACK::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
1847{
1848 return TestSegmentHit( aPosition, m_Start, m_End, aAccuracy + ( m_width / 2 ) );
1849}
1850
1851
1852bool PCB_ARC::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
1853{
1854 double max_dist = aAccuracy + ( GetWidth() / 2.0 );
1855
1856 // Short-circuit common cases where the arc is connected to a track or via at an endpoint
1857 if( GetStart().Distance( aPosition ) <= max_dist || GetEnd().Distance( aPosition ) <= max_dist )
1858 {
1859 return true;
1860 }
1861
1863 VECTOR2L relpos = aPosition - center;
1864 int64_t dist = relpos.EuclideanNorm();
1865 double radius = GetRadius();
1866
1867 if( std::abs( dist - radius ) > max_dist )
1868 return false;
1869
1870 EDA_ANGLE arc_angle = GetAngle();
1871 EDA_ANGLE arc_angle_start = GetArcAngleStart(); // Always 0.0 ... 360 deg
1872 EDA_ANGLE arc_hittest( relpos );
1873
1874 // Calculate relative angle between the starting point of the arc, and the test point
1875 arc_hittest -= arc_angle_start;
1876
1877 // Normalise arc_hittest between 0 ... 360 deg
1878 arc_hittest.Normalize();
1879
1880 if( arc_angle < ANGLE_0 )
1881 return arc_hittest >= ANGLE_360 + arc_angle;
1882
1883 return arc_hittest <= arc_angle;
1884}
1885
1886
1887bool PCB_VIA::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
1888{
1889 bool hit = false;
1890
1892 [&]( PCB_LAYER_ID aLayer )
1893 {
1894 if( hit )
1895 return;
1896
1897 int max_dist = aAccuracy + ( GetWidth( aLayer ) / 2 );
1898
1899 // rel_pos is aPosition relative to m_Start (or the center of the via)
1900 VECTOR2D rel_pos = aPosition - m_Start;
1901 double dist = rel_pos.x * rel_pos.x + rel_pos.y * rel_pos.y;
1902
1903 if( dist <= static_cast<double>( max_dist ) * max_dist )
1904 hit = true;
1905 } );
1906
1907 return hit;
1908}
1909
1910
1911bool PCB_TRACK::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
1912{
1913 BOX2I arect = aRect;
1914 arect.Inflate( aAccuracy );
1915
1916 if( aContained )
1917 return arect.Contains( GetStart() ) && arect.Contains( GetEnd() );
1918 else
1919 return arect.Intersects( GetStart(), GetEnd() );
1920}
1921
1922
1923bool PCB_ARC::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
1924{
1925 BOX2I arect = aRect;
1926 arect.Inflate( aAccuracy );
1927
1928 BOX2I box( GetStart() );
1929 box.Merge( GetMid() );
1930 box.Merge( GetEnd() );
1931
1932 box.Inflate( GetWidth() / 2 );
1933
1934 if( aContained )
1935 return arect.Contains( box );
1936 else
1937 return arect.Intersects( box );
1938}
1939
1940
1941bool PCB_VIA::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
1942{
1943 BOX2I arect = aRect;
1944 arect.Inflate( aAccuracy );
1945
1946 bool hit = false;
1947
1949 [&]( PCB_LAYER_ID aLayer )
1950 {
1951 if( hit )
1952 return;
1953
1954 BOX2I box( GetStart() );
1955 box.Inflate( GetWidth( aLayer ) / 2 );
1956
1957 if( aContained )
1958 hit = arect.Contains( box );
1959 else
1960 hit = arect.IntersectsCircle( GetStart(), GetWidth( aLayer ) / 2 );
1961 } );
1962
1963 return hit;
1964}
1965
1966
1967wxString PCB_TRACK::GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const
1968{
1969 return wxString::Format( Type() == PCB_ARC_T ? _("Track (arc) %s on %s, length %s" )
1970 : _("Track %s on %s, length %s" ),
1971 GetNetnameMsg(),
1972 GetLayerName(),
1973 aUnitsProvider->MessageTextFromValue( GetLength() ) );
1974}
1975
1976
1978{
1979 return BITMAPS::add_tracks;
1980}
1981
1983{
1984 assert( aImage->Type() == PCB_TRACE_T );
1985
1986 std::swap( *((PCB_TRACK*) this), *((PCB_TRACK*) aImage) );
1987}
1988
1990{
1991 assert( aImage->Type() == PCB_ARC_T );
1992
1993 std::swap( *this, *static_cast<PCB_ARC*>( aImage ) );
1994}
1995
1997{
1998 assert( aImage->Type() == PCB_VIA_T );
1999
2000 std::swap( *((PCB_VIA*) this), *((PCB_VIA*) aImage) );
2001}
2002
2003
2005{
2007 return center;
2008}
2009
2010
2012{
2013 auto center = CalcArcCenter( m_Start, m_Mid , m_End );
2014 return center.Distance( m_Start );
2015}
2016
2017
2019{
2021 EDA_ANGLE angle1 = EDA_ANGLE( m_Mid - center ) - EDA_ANGLE( m_Start - center );
2022 EDA_ANGLE angle2 = EDA_ANGLE( m_End - center ) - EDA_ANGLE( m_Mid - center );
2023
2024 return angle1.Normalize180() + angle2.Normalize180();
2025}
2026
2027
2029{
2030 VECTOR2D pos( GetPosition() );
2031 EDA_ANGLE angleStart( m_Start - pos );
2032
2033 return angleStart.Normalize();
2034}
2035
2036
2037// Note: used in python tests. Ignore CLion's claim that it's unused....
2039{
2040 VECTOR2D pos( GetPosition() );
2041 EDA_ANGLE angleEnd( m_End - pos );
2042
2043 return angleEnd.Normalize();
2044}
2045
2046bool PCB_ARC::IsDegenerated( int aThreshold ) const
2047{
2048 // Too small arcs cannot be really handled: arc center (and arc radius)
2049 // cannot be safely computed if the distance between mid and end points
2050 // is too small (a few internal units)
2051
2052 // len of both segments must be < aThreshold to be a very small degenerated arc
2053 return ( GetMid() - GetStart() ).EuclideanNorm() < aThreshold
2054 && ( GetMid() - GetEnd() ).EuclideanNorm() < aThreshold;
2055}
2056
2057
2059{
2060 if( a->GetNetCode() != b->GetNetCode() )
2061 return a->GetNetCode() < b->GetNetCode();
2062
2063 if( a->GetLayer() != b->GetLayer() )
2064 return a->GetLayer() < b->GetLayer();
2065
2066 if( a->Type() != b->Type() )
2067 return a->Type() < b->Type();
2068
2069 if( a->m_Uuid != b->m_Uuid )
2070 return a->m_Uuid < b->m_Uuid;
2071
2072 return a < b;
2073}
2074
2075
2076std::shared_ptr<SHAPE> PCB_TRACK::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
2077{
2078 int width = m_width;
2079
2080 if( IsSolderMaskLayer( aLayer ) )
2081 width += 2 * GetSolderMaskExpansion();
2082
2083 return std::make_shared<SHAPE_SEGMENT>( m_Start, m_End, width );
2084}
2085
2086
2087std::shared_ptr<SHAPE> PCB_VIA::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
2088{
2089 if( aFlash == FLASHING::ALWAYS_FLASHED
2090 || ( aFlash == FLASHING::DEFAULT && FlashLayer( aLayer ) ) )
2091 {
2092 int width = 0;
2093
2094 if( aLayer == UNDEFINED_LAYER )
2095 {
2096 Padstack().ForEachUniqueLayer(
2097 [&]( PCB_LAYER_ID layer )
2098 {
2099 width = std::max( width, GetWidth( layer ) );
2100 } );
2101
2102 width /= 2;
2103 }
2104 else
2105 {
2106 PCB_LAYER_ID cuLayer = m_padStack.EffectiveLayerFor( aLayer );
2107 width = GetWidth( cuLayer ) / 2;
2108 }
2109
2110 return std::make_shared<SHAPE_CIRCLE>( m_Start, width );
2111 }
2112 else
2113 {
2114 return std::make_shared<SHAPE_CIRCLE>( m_Start, GetDrillValue() / 2 );
2115 }
2116}
2117
2118
2119std::shared_ptr<SHAPE> PCB_ARC::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
2120{
2121 int width = GetWidth();
2122
2123 if( IsSolderMaskLayer( aLayer ) )
2124 width += 2 * GetSolderMaskExpansion();
2125
2126 SHAPE_ARC arc( GetStart(), GetMid(), GetEnd(), width );
2127
2128 if( arc.IsEffectiveLine() )
2129 return std::make_shared<SHAPE_SEGMENT>( GetStart(), GetEnd(), width );
2130
2131 return std::make_shared<SHAPE_ARC>( arc );
2132}
2133
2134
2136 int aClearance, int aError, ERROR_LOC aErrorLoc,
2137 bool ignoreLineWidth ) const
2138{
2139 wxASSERT_MSG( !ignoreLineWidth, wxT( "IgnoreLineWidth has no meaning for tracks." ) );
2140
2141
2142 switch( Type() )
2143 {
2144 case PCB_VIA_T:
2145 {
2146 int radius = ( static_cast<const PCB_VIA*>( this )->GetWidth( aLayer ) / 2 ) + aClearance;
2147 TransformCircleToPolygon( aBuffer, m_Start, radius, aError, aErrorLoc );
2148 break;
2149 }
2150
2151 case PCB_ARC_T:
2152 {
2153 const PCB_ARC* arc = static_cast<const PCB_ARC*>( this );
2154 int width = m_width + ( 2 * aClearance );
2155
2156 if( IsSolderMaskLayer( aLayer ) )
2157 width += 2 * GetSolderMaskExpansion();
2158
2159 TransformArcToPolygon( aBuffer, arc->GetStart(), arc->GetMid(), arc->GetEnd(), width,
2160 aError, aErrorLoc );
2161 break;
2162 }
2163
2164 default:
2165 {
2166 int width = m_width + ( 2 * aClearance );
2167
2168 if( IsSolderMaskLayer( aLayer ) )
2169 width += 2 * GetSolderMaskExpansion();
2170
2171 TransformOvalToPolygon( aBuffer, m_Start, m_End, width, aError, aErrorLoc );
2172
2173 break;
2174 }
2175 }
2176}
2177
2178
2179static struct TRACK_VIA_DESC
2180{
2182 {
2183 // clang-format off: the suggestion is less readable
2185 .Undefined( VIATYPE::NOT_DEFINED )
2186 .Map( VIATYPE::THROUGH, _HKI( "Through" ) )
2187 .Map( VIATYPE::BLIND_BURIED, _HKI( "Blind/buried" ) )
2188 .Map( VIATYPE::MICROVIA, _HKI( "Micro" ) );
2189
2191 .Undefined( TENTING_MODE::FROM_RULES )
2192 .Map( TENTING_MODE::FROM_RULES, _HKI( "From design rules" ) )
2193 .Map( TENTING_MODE::TENTED, _HKI( "Tented" ) )
2194 .Map( TENTING_MODE::NOT_TENTED, _HKI( "Not tented" ) );
2195
2197 .Undefined( COVERING_MODE::FROM_RULES )
2198 .Map( COVERING_MODE::FROM_RULES, _HKI( "From design rules" ) )
2199 .Map( COVERING_MODE::COVERED, _HKI( "Covered" ) )
2200 .Map( COVERING_MODE::NOT_COVERED, _HKI( "Not covered" ) );
2201
2203 .Undefined( PLUGGING_MODE::FROM_RULES )
2204 .Map( PLUGGING_MODE::FROM_RULES, _HKI( "From design rules" ) )
2205 .Map( PLUGGING_MODE::PLUGGED, _HKI( "Plugged" ) )
2206 .Map( PLUGGING_MODE::NOT_PLUGGED, _HKI( "Not plugged" ) );
2207
2209 .Undefined( CAPPING_MODE::FROM_RULES )
2210 .Map( CAPPING_MODE::FROM_RULES, _HKI( "From design rules" ) )
2211 .Map( CAPPING_MODE::CAPPED, _HKI( "Capped" ) )
2212 .Map( CAPPING_MODE::NOT_CAPPED, _HKI( "Not capped" ) );
2213
2215 .Undefined( FILLING_MODE::FROM_RULES )
2216 .Map( FILLING_MODE::FROM_RULES, _HKI( "From design rules" ) )
2217 .Map( FILLING_MODE::FILLED, _HKI( "Filled" ) )
2218 .Map( FILLING_MODE::NOT_FILLED, _HKI( "Not filled" ) );
2219 // clang-format on: the suggestion is less readable
2220
2222
2223 if( layerEnum.Choices().GetCount() == 0 )
2224 {
2225 layerEnum.Undefined( UNDEFINED_LAYER );
2226
2227 for( PCB_LAYER_ID layer : LSET::AllLayersMask().Seq() )
2228 layerEnum.Map( layer, LSET::Name( layer ) );
2229 }
2230
2232
2233 // Track
2236
2237 propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "Width" ),
2238 &PCB_TRACK::SetWidth, &PCB_TRACK::GetWidth, PROPERTY_DISPLAY::PT_SIZE ) );
2239 propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position X" ),
2240 new PROPERTY<PCB_TRACK, int>( _HKI( "Start X" ),
2241 &PCB_TRACK::SetStartX, &PCB_TRACK::GetStartX, PROPERTY_DISPLAY::PT_COORD,
2243 propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position Y" ),
2244 new PROPERTY<PCB_TRACK, int>( _HKI( "Start Y" ),
2245 &PCB_TRACK::SetStartY, &PCB_TRACK::GetStartY, PROPERTY_DISPLAY::PT_COORD,
2247 propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "End X" ),
2248 &PCB_TRACK::SetEndX, &PCB_TRACK::GetEndX, PROPERTY_DISPLAY::PT_COORD,
2250 propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "End Y" ),
2251 &PCB_TRACK::SetEndY, &PCB_TRACK::GetEndY, PROPERTY_DISPLAY::PT_COORD,
2253
2254 const wxString groupTechLayers = _HKI( "Technical Layers" );
2255
2256 auto isExternalLayerTrack =
2257 []( INSPECTABLE* aItem )
2258 {
2259 if( auto track = dynamic_cast<PCB_TRACK*>( aItem ) )
2260 return track->GetLayer() == F_Cu || track->GetLayer() == B_Cu;
2261
2262 return false;
2263 };
2264
2265 propMgr.AddProperty( new PROPERTY<PCB_TRACK, bool>( _HKI( "Soldermask" ),
2267 .SetAvailableFunc( isExternalLayerTrack );
2268 propMgr.AddProperty( new PROPERTY<PCB_TRACK, std::optional<int>>( _HKI( "Soldermask Margin Override" ),
2270 PROPERTY_DISPLAY::PT_SIZE ), groupTechLayers )
2271 .SetAvailableFunc( isExternalLayerTrack );
2272
2273 // Arc
2276
2277 // Via
2280
2281 // TODO test drill, use getdrillvalue?
2282 const wxString groupVia = _HKI( "Via Properties" );
2283
2284 propMgr.Mask( TYPE_HASH( PCB_VIA ), TYPE_HASH( BOARD_CONNECTED_ITEM ), _HKI( "Layer" ) );
2285
2286 // clang-format off: the suggestion is less readable
2287 propMgr.AddProperty( new PROPERTY<PCB_VIA, int>( _HKI( "Diameter" ),
2288 &PCB_VIA::SetFrontWidth, &PCB_VIA::GetFrontWidth, PROPERTY_DISPLAY::PT_SIZE ), groupVia );
2289 propMgr.AddProperty( new PROPERTY<PCB_VIA, int>( _HKI( "Hole" ),
2290 &PCB_VIA::SetDrill, &PCB_VIA::GetDrillValue, PROPERTY_DISPLAY::PT_SIZE ), groupVia );
2291 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, PCB_LAYER_ID>( _HKI( "Layer Top" ),
2292 &PCB_VIA::SetLayer, &PCB_VIA::GetLayer ), groupVia );
2293 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, PCB_LAYER_ID>( _HKI( "Layer Bottom" ),
2295 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, VIATYPE>( _HKI( "Via Type" ),
2297 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, TENTING_MODE>( _HKI( "Front tenting" ),
2299 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, TENTING_MODE>( _HKI( "Back tenting" ),
2301 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, COVERING_MODE>( _HKI( "Front covering" ),
2303 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, COVERING_MODE>( _HKI( "Back covering" ),
2305 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, PLUGGING_MODE>( _HKI( "Front plugging" ),
2307 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, PLUGGING_MODE>( _HKI( "Back plugging" ),
2309 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, CAPPING_MODE>( _HKI( "Capping" ),
2311 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, FILLING_MODE>( _HKI( "Filling" ),
2313 // clang-format on: the suggestion is less readable
2314 }
2316
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:143
BASE_SET & set(size_t pos)
Definition: base_set.h:116
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:239
virtual void SetLocked(bool aLocked)
Definition: board_item.h:330
PCB_LAYER_ID m_layer
Definition: board_item.h:455
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:290
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:296
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayer) const
Definition: board.cpp:776
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:616
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:2385
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:948
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:495
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:297
const KIID m_Uuid
Definition: eda_item.h:488
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:686
static ENUM_MAP< T > & Instance()
Definition: property.h:680
ENUM_MAP & Undefined(T aValue)
Definition: property.h:693
wxPGChoices & Choices()
Definition: property.h:729
Class that other classes need to inherit from, in order to be inspectable.
Definition: inspectable.h:37
Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:181
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:186
PCB specific render settings.
Definition: pcb_painter.h:79
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
Return the board layer which is in high-contrast mode.
bool GetHighContrast() const
static double lodScaleForThreshold(const KIGFX::VIEW *aView, int aWhatIu, int aThresholdIu)
Get the scale at which aWhatIu would be drawn at the same size as aThresholdIu on screen.
Definition: view_item.cpp:39
static constexpr double LOD_HIDE
Return this constant from ViewGetLOD() to hide the item unconditionally.
Definition: view_item.h:174
static constexpr double LOD_SHOW
Return this constant from ViewGetLOD() to show the item unconditionally.
Definition: view_item.h:179
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition: view.cpp:520
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:216
Definition: kiid.h:49
std::string AsStdString() const
Definition: kiid.cpp:252
static bool Contains(int aStart_layer, int aEnd_layer, int aTest_layer)
Definition: layer_range.h:133
LSET is a set of PCB_LAYER_IDs.
Definition: lset.h:37
static LSET AllLayersMask()
Definition: lset.cpp:601
void RunOnLayers(const std::function< void(PCB_LAYER_ID)> &aFunction) const
Execute a function on each layer of the LSET.
Definition: lset.h:255
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:572
static LSET PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
Definition: lset.cpp:658
static LSET FrontTechMask()
Return a mask holding all technical layers (no CU layer) on front side.
Definition: lset.cpp:622
static LSET BackTechMask()
Return a mask holding all technical layers (no CU layer) on back side.
Definition: lset.cpp:608
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition: lset.cpp:188
bool Contains(PCB_LAYER_ID aLayer) const
See if the layer set contains a PCB layer.
Definition: lset.h:63
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:45
int GetViaDrill() const
Definition: netclass.h:138
int GetuViaDrill() const
Definition: netclass.h:154
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:124
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: padstack.cpp:211
MASK_LAYER_PROPS & FrontOuterLayers()
Definition: padstack.h:318
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:879
void SetUnconnectedLayerMode(UNCONNECTED_LAYER_MODE aMode)
Definition: padstack.h:313
const LSET & LayerSet() const
Definition: padstack.h:280
void SetShape(PAD_SHAPE aShape, PCB_LAYER_ID aLayer)
Definition: padstack.cpp:1053
UNCONNECTED_LAYER_MODE UnconnectedLayerMode() const
Definition: padstack.h:312
DRILL_PROPS & Drill()
Definition: padstack.h:306
const VECTOR2I & Size(PCB_LAYER_ID aLayer) const
Definition: padstack.cpp:1068
MASK_LAYER_PROPS & BackOuterLayers()
Definition: padstack.h:321
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: padstack.cpp:413
void SetSize(const VECTOR2I &aSize, PCB_LAYER_ID aLayer)
Definition: padstack.cpp:1059
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
Definition: padstack.h:144
virtual VECTOR2I GetPosition() const override
Definition: pcb_track.cpp:2004
bool IsDegenerated(int aThreshold=5) const
Definition: pcb_track.cpp:2046
virtual void swapData(BOARD_ITEM *aImage) override
Definition: pcb_track.cpp:1989
bool IsCCW() const
Definition: pcb_track.cpp:802
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: pcb_track.cpp:420
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:783
EDA_ANGLE GetArcAngleStart() const
Definition: pcb_track.cpp:2028
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:758
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:1852
EDA_ANGLE GetArcAngleEnd() const
Definition: pcb_track.cpp:2038
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: pcb_track.cpp:443
void SetMid(const VECTOR2I &aMid)
Definition: pcb_track.h:332
double GetRadius() const
Definition: pcb_track.cpp:2011
EDA_ANGLE GetAngle() const
Definition: pcb_track.cpp:2018
const VECTOR2I & GetMid() const
Definition: pcb_track.h:333
PCB_ARC(BOARD_ITEM *aParent)
Definition: pcb_track.h:308
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:253
VECTOR2I m_Mid
Arc mid point, halfway between start and end.
Definition: pcb_track.h:397
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_track.cpp:743
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:2119
bool operator==(const PCB_ARC &aOther) const
Definition: pcb_track.cpp:241
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pcb_track.cpp:1185
virtual void SetLayerSet(const LSET &aLayers) override
Definition: pcb_track.cpp:1172
int GetSolderMaskExpansion() const
Definition: pcb_track.cpp:1076
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_track.cpp:736
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: pcb_track.cpp:379
void SetEndY(int aY)
Definition: pcb_track.h:159
void SetHasSolderMask(bool aVal)
Definition: pcb_track.h:173
virtual double GetLength() const
Get the length of the track using the hypotenuse calculation.
Definition: pcb_track.cpp:730
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pcb_track.cpp:1501
virtual void swapData(BOARD_ITEM *aImage) override
Definition: pcb_track.cpp:1982
void SetEnd(const VECTOR2I &aEnd)
Definition: pcb_track.h:146
bool HasSolderMask() const
Definition: pcb_track.h:174
void SetStart(const VECTOR2I &aStart)
Definition: pcb_track.h:149
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: pcb_track.cpp:1560
int GetStartY() const
Definition: pcb_track.h:156
int GetEndX() const
Definition: pcb_track.h:161
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: pcb_track.cpp:1967
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:751
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: pcb_track.cpp:400
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:837
bool ApproxCollinear(const PCB_TRACK &aTrack)
Definition: pcb_track.cpp:520
VECTOR2I m_End
Line end point.
Definition: pcb_track.h:295
void SetLocalSolderMaskMargin(std::optional< int > aMargin)
Definition: pcb_track.h:176
std::optional< int > m_solderMaskMargin
Definition: pcb_track.h:298
std::optional< int > GetLocalSolderMaskMargin() const
Definition: pcb_track.h:177
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:1710
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:660
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:2135
const VECTOR2I & GetStart() const
Definition: pcb_track.h:150
virtual bool operator==(const BOARD_ITEM &aOther) const override
Definition: pcb_track.cpp:166
VECTOR2I m_Start
Line start point.
Definition: pcb_track.h:294
int GetEndY() const
Definition: pcb_track.h:162
wxString GetFriendlyName() const override
Definition: pcb_track.cpp:1698
virtual std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
Definition: pcb_track.cpp:1474
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pcb_track.cpp:1977
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:1846
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition: pcb_track.cpp:766
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:297
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:2076
void SetStartX(int aX)
Definition: pcb_track.h:152
const VECTOR2I & GetEnd() const
Definition: pcb_track.h:147
PCB_TRACK(BOARD_ITEM *aParent, KICAD_T idtype=PCB_TRACE_T)
Definition: pcb_track.cpp:60
void SetStartY(int aY)
Definition: pcb_track.h:153
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition: pcb_track.cpp:1097
virtual MINOPTMAX< int > GetWidthConstraint(wxString *aSource=nullptr) const
Definition: pcb_track.cpp:528
void SetEndX(int aX)
Definition: pcb_track.h:158
int GetStartX() const
Definition: pcb_track.h:155
int m_width
Thickness of track (or arc) – no longer the width of a via.
Definition: pcb_track.h:301
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:628
virtual void SetWidth(int aWidth)
Definition: pcb_track.h:143
virtual int GetWidth() const
Definition: pcb_track.h:144
void GetMsgPanelInfoBase_Common(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) const
Definition: pcb_track.cpp:1807
PCB_LAYER_ID BottomLayer() const
Definition: pcb_track.cpp:1328
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pcb_track.cpp:160
PLUGGING_MODE GetFrontPluggingMode() const
Definition: pcb_track.cpp:962
VECTOR2I GetPosition() const override
Definition: pcb_track.h:537
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:1044
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:2087
void SetCappingMode(CAPPING_MODE aMode)
Definition: pcb_track.cpp:997
void SetFrontCoveringMode(COVERING_MODE aMode)
Definition: pcb_track.cpp:905
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
Definition: pcb_track.cpp:492
COVERING_MODE GetBackCoveringMode() const
Definition: pcb_track.cpp:939
bool FlashLayer(int aLayer) const
Check to see whether the via should have a pad on the specific layer.
Definition: pcb_track.cpp:1364
void SetDrillDefault()
Set the drill value for vias to the default value UNDEFINED_DRILL_DIAMETER.
Definition: pcb_track.h:674
std::map< PCB_LAYER_ID, ZONE_LAYER_OVERRIDE > m_zoneLayerOverrides
Definition: pcb_track.h:723
void ClearZoneLayerOverrides()
Definition: pcb_track.cpp:1416
CAPPING_MODE GetCappingMode() const
Definition: pcb_track.cpp:1008
const PADSTACK & Padstack() const
Definition: pcb_track.h:440
void SetFrontTentingMode(TENTING_MODE aMode)
Definition: pcb_track.cpp:859
bool m_isFree
"Free" vias don't get their nets auto-updated
Definition: pcb_track.h:720
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:1887
TENTING_MODE GetFrontTentingMode() const
Definition: pcb_track.cpp:870
void SetBottomLayer(PCB_LAYER_ID aLayer)
Definition: pcb_track.cpp:1294
int GetSolderMaskExpansion() const
Definition: pcb_track.cpp:1067
void SetDrill(int aDrill)
Set the drill value for vias.
Definition: pcb_track.h:652
PLUGGING_MODE GetBackPluggingMode() const
Definition: pcb_track.cpp:985
void SetBackPluggingMode(PLUGGING_MODE aMode)
Definition: pcb_track.cpp:974
MINOPTMAX< int > GetDrillConstraint(wxString *aSource=nullptr) const
Definition: pcb_track.cpp:564
void SetBackTentingMode(TENTING_MODE aMode)
Definition: pcb_track.cpp:882
void SetFrontPluggingMode(PLUGGING_MODE aMode)
Definition: pcb_track.cpp:951
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
Definition: pcb_track.cpp:812
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:1770
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:309
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: pcb_track.cpp:1160
std::mutex m_zoneLayerOverridesMutex
Definition: pcb_track.h:722
void SetTopLayer(PCB_LAYER_ID aLayer)
Definition: pcb_track.cpp:1288
FILLING_MODE GetFillingMode() const
Definition: pcb_track.cpp:1031
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Definition: pcb_track.cpp:853
int GetFrontWidth() const
Definition: pcb_track.h:454
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:1279
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:320
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition: pcb_track.cpp:1166
virtual void SetLayerSet(const LSET &aLayers) override
Note SetLayerSet() initialize the first and last copper layers connected by the via.
Definition: pcb_track.cpp:1237
void GetOutermostConnectedLayers(PCB_LAYER_ID *aTopmost, PCB_LAYER_ID *aBottommost) const
Return the top-most and bottom-most connected layers.
Definition: pcb_track.cpp:1440
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:1334
int GetWidth() const override
Definition: pcb_track.cpp:359
PCB_VIA & operator=(const PCB_VIA &aOther)
Definition: pcb_track.cpp:124
void swapData(BOARD_ITEM *aImage) override
Definition: pcb_track.cpp:1996
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
Definition: pcb_track.cpp:464
void SetFillingMode(FILLING_MODE aMode)
Definition: pcb_track.cpp:1020
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:1834
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
Definition: pcb_track.cpp:1573
void SetViaType(VIATYPE aViaType)
Definition: pcb_track.h:438
int GetMinAnnulus(PCB_LAYER_ID aLayer, wxString *aSource) const
Definition: pcb_track.cpp:582
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition: pcb_track.cpp:1115
TENTING_MODE GetBackTentingMode() const
Definition: pcb_track.cpp:893
PCB_LAYER_ID TopLayer() const
Definition: pcb_track.cpp:1322
VIATYPE m_viaType
through, blind/buried or micro
Definition: pcb_track.h:716
PADSTACK m_padStack
Definition: pcb_track.h:718
COVERING_MODE GetFrontCoveringMode() const
Definition: pcb_track.cpp:916
int GetDrillValue() const
Calculate the drill value for vias (m_drill if > 0, or default drill value for the board).
Definition: pcb_track.cpp:613
void SetZoneLayerOverride(PCB_LAYER_ID aLayer, ZONE_LAYER_OVERRIDE aOverride)
Definition: pcb_track.cpp:1433
void SetFrontWidth(int aWidth)
Definition: pcb_track.h:453
VIATYPE GetViaType() const
Definition: pcb_track.h:437
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pcb_track.cpp:1618
MINOPTMAX< int > GetWidthConstraint(wxString *aSource=nullptr) const override
Definition: pcb_track.cpp:546
void SetWidth(int aWidth) override
Definition: pcb_track.cpp:351
void SetBackCoveringMode(COVERING_MODE aMode)
Definition: pcb_track.cpp:928
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pcb_track.cpp:1201
const ZONE_LAYER_OVERRIDE & GetZoneLayerOverride(PCB_LAYER_ID aLayer) const
Definition: pcb_track.cpp:1425
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:1300
bool HasValidLayerPair(int aCopperLayerCount)
Definition: pcb_track.cpp:1138
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_track.cpp:705
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:118
const VECTOR2I & GetP1() const
Definition: shape_arc.h:117
bool IsEffectiveLine() const
Definition: shape_arc.cpp:245
const VECTOR2I & GetP0() const
Definition: shape_arc.h:116
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:546
double Distance(const VECTOR2< extended_type > &aVector) const
Compute the distance between two vectors.
Definition: vector2d.h:561
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
std::function passed to nested users by ref, avoids copying std::function.
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.
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:169
bool IsSolderMaskLayer(int aLayer)
Definition: layer_ids.h:688
@ LAYER_VIA_NETNAMES
Definition: layer_ids.h:203
bool IsCopperLayerLowerThan(PCB_LAYER_ID aLayerA, PCB_LAYER_ID aLayerB)
Return true if copper aLayerA is placed lower than aLayerB, false otherwise.
Definition: layer_ids.h:764
constexpr PCB_LAYER_ID PCBNEW_LAYER_ID_START
Definition: layer_ids.h:174
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
Definition: layer_ids.h:720
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:184
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
Definition: layer_ids.h:743
#define MAX_CU_LAYERS
Definition: layer_ids.h:176
int GetNetnameLayer(int aLayer)
Return a netname layer corresponding to the given layer.
Definition: layer_ids.h:794
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition: layer_ids.h:618
@ LAYER_LOCKED_ITEM_SHADOW
Shadow layer for locked items.
Definition: layer_ids.h:306
@ LAYER_VIA_HOLEWALLS
Definition: layer_ids.h:297
@ LAYER_VIA_COPPER_START
Virtual layers for via copper on a given copper layer.
Definition: layer_ids.h:335
@ LAYER_TRACKS
Definition: layer_ids.h:266
@ LAYER_CLEARANCE_START
Virtual layers for pad/via/track clearance outlines for a given copper layer.
Definition: layer_ids.h:339
@ LAYER_VIA_HOLES
Draw via holes (pad holes do not use this layer).
Definition: layer_ids.h:273
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
Definition: layer_ids.h:232
bool IsNetnameLayer(int aLayer)
Test whether a layer is a netname layer.
Definition: layer_ids.h:809
bool IsHoleLayer(int aLayer)
Definition: layer_ids.h:679
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:722
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
void PackLayerSet(google::protobuf::RepeatedField< int > &aOutput, const LSET &aLayerSet)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:390
static struct TRACK_VIA_DESC _TRACK_VIA_DESC
FILLING_MODE
Definition: pcb_track.h:103
VIATYPE
Definition: pcb_track.h:66
TENTING_MODE
Definition: pcb_track.h:75
COVERING_MODE
Definition: pcb_track.h:82
PLUGGING_MODE
Definition: pcb_track.h:89
CAPPING_MODE
Definition: pcb_track.h:96
#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:782
#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:245
PCB_LAYER_ID end
Definition: padstack.h:246
VECTOR2I size
Drill diameter (x == y) or slot dimensions (x != y)
Definition: padstack.h:243
std::optional< bool > is_capped
True if the drill hole should be capped.
Definition: padstack.h:249
std::optional< bool > is_filled
True if the drill hole should be filled completely.
Definition: padstack.h:248
std::optional< bool > has_covering
True if the pad on this side should have covering.
Definition: padstack.h:234
std::optional< bool > has_solder_mask
True if this outer layer has mask (is not tented)
Definition: padstack.h:232
std::optional< bool > has_plugging
True if the drill hole should be plugged on this side.
Definition: padstack.h:235
bool operator()(const PCB_TRACK *aFirst, const PCB_TRACK *aSecond) const
Definition: pcb_track.cpp:2058
VECTOR2I center
int radius
VECTOR2I end
int clearance
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:695
VECTOR2< int64_t > VECTOR2L
Definition: vector2d.h:696