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