KiCad PCB EDA Suite
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-2022 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_base_frame.h>
28#include <core/mirror.h>
30#include <board.h>
33#include <pcb_track.h>
34#include <base_units.h>
35#include <bitmaps.h>
36#include <string_utils.h>
37#include <view/view.h>
40#include <i18n_utility.h>
41#include <geometry/seg.h>
44#include <geometry/shape_arc.h>
45#include <drc/drc_engine.h>
46#include <pcb_painter.h>
47#include <trigo.h>
48
51
53 BOARD_CONNECTED_ITEM( aParent, idtype )
54{
55 m_Width = pcbIUScale.mmToIU( 0.2 ); // Gives a reasonable default width
56}
57
58
60{
61 return new PCB_TRACK( *this );
62}
63
64
65PCB_ARC::PCB_ARC( BOARD_ITEM* aParent, const SHAPE_ARC* aArc ) :
66 PCB_TRACK( aParent, PCB_ARC_T )
67{
68 m_Start = aArc->GetP0();
69 m_End = aArc->GetP1();
70 m_Mid = aArc->GetArcMid();
71}
72
73
75{
76 return new PCB_ARC( *this );
77}
78
79
81 PCB_TRACK( aParent, PCB_VIA_T )
82{
88 m_isFree = false;
89}
90
91
93{
94 return new PCB_VIA( *this );
95}
96
97
98wxString PCB_VIA::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const
99{
100 wxString formatStr;
101
102 switch( GetViaType() )
103 {
104 case VIATYPE::BLIND_BURIED: formatStr = _( "Blind/Buried Via %s on %s" ); break;
105 case VIATYPE::MICROVIA: formatStr = _( "Micro Via %s on %s" ); break;
106 default: formatStr = _( "Via %s on %s" ); break;
107 }
108
109 return wxString::Format( formatStr,
112}
113
114
116{
117 return BITMAPS::via;
118}
119
120
122{
123 SEG a( m_Start, m_End );
124 SEG b( aTrack.GetStart(), aTrack.GetEnd() );
125 return a.ApproxCollinear( b );
126}
127
128
129int PCB_TRACK::GetLocalClearance( wxString* aSource ) const
130{
131 // Not currently implemented
132 return 0;
133}
134
135
137{
138 DRC_CONSTRAINT constraint;
139
140 if( GetBoard() && GetBoard()->GetDesignSettings().m_DRCEngine )
141 {
143
144 constraint = bds.m_DRCEngine->EvalRules( TRACK_WIDTH_CONSTRAINT, this, nullptr, m_layer );
145 }
146
147 if( aSource )
148 *aSource = constraint.GetName();
149
150 return constraint.Value();
151}
152
153
154int PCB_VIA::GetMinAnnulus( PCB_LAYER_ID aLayer, wxString* aSource ) const
155{
156 if( !FlashLayer( aLayer ) )
157 {
158 if( aSource )
159 *aSource = _( "removed annular ring" );
160
161 return 0;
162 }
163
164 DRC_CONSTRAINT constraint;
165
166 if( GetBoard() && GetBoard()->GetDesignSettings().m_DRCEngine )
167 {
169
170 constraint = bds.m_DRCEngine->EvalRules( ANNULAR_WIDTH_CONSTRAINT, this, nullptr, aLayer );
171 }
172
173 if( constraint.Value().HasMin() )
174 {
175 if( aSource )
176 *aSource = constraint.GetName();
177
178 return constraint.Value().Min();
179 }
180
181 return 0;
182}
183
184
186{
187 if( m_drill > 0 ) // Use the specific value.
188 return m_drill;
189
190 // Use the default value from the Netclass
191 NETCLASS* netclass = GetEffectiveNetClass();
192
194 return netclass->GetuViaDrill();
195
196 return netclass->GetViaDrill();
197}
198
199
200EDA_ITEM_FLAGS PCB_TRACK::IsPointOnEnds( const VECTOR2I& point, int min_dist ) const
201{
202 EDA_ITEM_FLAGS result = 0;
203
204 if( min_dist < 0 )
205 min_dist = m_Width / 2;
206
207 if( min_dist == 0 )
208 {
209 if( m_Start == point )
210 result |= STARTPOINT;
211
212 if( m_End == point )
213 result |= ENDPOINT;
214 }
215 else
216 {
217 double dist = GetLineLength( m_Start, point );
218
219 if( min_dist >= KiROUND( dist ) )
220 result |= STARTPOINT;
221
222 dist = GetLineLength( m_End, point );
223
224 if( min_dist >= KiROUND( dist ) )
225 result |= ENDPOINT;
226 }
227
228 return result;
229}
230
231
233{
234 // end of track is round, this is its radius, rounded up
235 int radius = ( m_Width + 1 ) / 2;
236 int ymax, xmax, ymin, xmin;
237
238 if( Type() == PCB_VIA_T )
239 {
240 ymax = m_Start.y;
241 xmax = m_Start.x;
242
243 ymin = m_Start.y;
244 xmin = m_Start.x;
245 }
246 else if( Type() == PCB_ARC_T )
247 {
248 std::shared_ptr<SHAPE> arc = GetEffectiveShape();
249 BOX2I bbox = arc->BBox();
250
251 xmin = bbox.GetLeft();
252 xmax = bbox.GetRight();
253 ymin = bbox.GetTop();
254 ymax = bbox.GetBottom();
255 }
256 else
257 {
258 ymax = std::max( m_Start.y, m_End.y );
259 xmax = std::max( m_Start.x, m_End.x );
260
261 ymin = std::min( m_Start.y, m_End.y );
262 xmin = std::min( m_Start.x, m_End.x );
263 }
264
265 ymax += radius;
266 xmax += radius;
267
268 ymin -= radius;
269 xmin -= radius;
270
271 // return a rectangle which is [pos,dim) in nature. therefore the +1
272 BOX2I ret( VECTOR2I( xmin, ymin ), VECTOR2I( xmax - xmin + 1, ymax - ymin + 1 ) );
273
274 return ret;
275}
276
277
279{
280 return GetLineLength( m_Start, m_End );
281}
282
283
284void PCB_TRACK::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
285{
286 RotatePoint( m_Start, aRotCentre, aAngle );
287 RotatePoint( m_End, aRotCentre, aAngle );
288}
289
290
291void PCB_ARC::Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle )
292{
293 RotatePoint( m_Start, aRotCentre, aAngle );
294 RotatePoint( m_End, aRotCentre, aAngle );
295 RotatePoint( m_Mid, aRotCentre, aAngle );
296}
297
298
299void PCB_TRACK::Mirror( const VECTOR2I& aCentre, bool aMirrorAroundXAxis )
300{
301 if( aMirrorAroundXAxis )
302 {
303 MIRROR( m_Start.y, aCentre.y );
304 MIRROR( m_End.y, aCentre.y );
305 }
306 else
307 {
308 MIRROR( m_Start.x, aCentre.x );
309 MIRROR( m_End.x, aCentre.x );
310 }
311}
312
313
314void PCB_ARC::Mirror( const VECTOR2I& aCentre, bool aMirrorAroundXAxis )
315{
316 if( aMirrorAroundXAxis )
317 {
318 MIRROR( m_Start.y, aCentre.y );
319 MIRROR( m_End.y, aCentre.y );
320 MIRROR( m_Mid.y, aCentre.y );
321 }
322 else
323 {
324 MIRROR( m_Start.x, aCentre.x );
325 MIRROR( m_End.x, aCentre.x );
326 MIRROR( m_Mid.x, aCentre.x );
327 }
328}
329
330
331void PCB_TRACK::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
332{
333 if( aFlipLeftRight )
334 {
335 m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
336 m_End.x = aCentre.x - ( m_End.x - aCentre.x );
337 }
338 else
339 {
340 m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
341 m_End.y = aCentre.y - ( m_End.y - aCentre.y );
342 }
343
344 int copperLayerCount = GetBoard()->GetCopperLayerCount();
345 SetLayer( FlipLayer( GetLayer(), copperLayerCount ) );
346}
347
348
349void PCB_ARC::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
350{
351 if( aFlipLeftRight )
352 {
353 m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
354 m_End.x = aCentre.x - ( m_End.x - aCentre.x );
355 m_Mid.x = aCentre.x - ( m_Mid.x - aCentre.x );
356 }
357 else
358 {
359 m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
360 m_End.y = aCentre.y - ( m_End.y - aCentre.y );
361 m_Mid.y = aCentre.y - ( m_Mid.y - aCentre.y );
362 }
363
364 int copperLayerCount = GetBoard()->GetCopperLayerCount();
365 SetLayer( FlipLayer( GetLayer(), copperLayerCount ) );
366}
367
368
369bool PCB_ARC::IsCCW() const
370{
371 VECTOR2I start_end = m_End - m_Start;
372 VECTOR2I start_mid = m_Mid - m_Start;
373
374 return start_end.Cross( start_mid ) < 0;
375}
376
377
378void PCB_VIA::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
379{
380 if( aFlipLeftRight )
381 {
382 m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
383 m_End.x = aCentre.x - ( m_End.x - aCentre.x );
384 }
385 else
386 {
387 m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
388 m_End.y = aCentre.y - ( m_End.y - aCentre.y );
389 }
390
392 {
393 int copperLayerCount = GetBoard()->GetCopperLayerCount();
394 PCB_LAYER_ID top_layer;
395 PCB_LAYER_ID bottom_layer;
396 LayerPair( &top_layer, &bottom_layer );
397 top_layer = FlipLayer( top_layer, copperLayerCount );
398 bottom_layer = FlipLayer( bottom_layer, copperLayerCount );
399 SetLayerPair( top_layer, bottom_layer );
400 }
401}
402
403
404// see class_track.h
405INSPECT_RESULT PCB_TRACK::Visit( INSPECTOR inspector, void* testData,
406 const std::vector<KICAD_T>& aScanTypes )
407{
408 for( KICAD_T scanType : aScanTypes )
409 {
410 if( scanType == Type() )
411 {
412 if( INSPECT_RESULT::QUIT == inspector( this, testData ) )
414 }
415 }
416
418}
419
420
421std::shared_ptr<SHAPE_SEGMENT> PCB_VIA::GetEffectiveHoleShape() const
422{
423 return std::make_shared<SHAPE_SEGMENT>( SEG( m_Start, m_Start ), m_drill );
424}
425
426
428{
429 const BOARD* board = GetBoard();
430
431 if( board )
432 return board->GetTentVias();
433 else
434 return true;
435}
436
437
439{
440 const BOARD* board = GetBoard();
441
442 if( board )
444 else
445 return 0;
446}
447
448
450{
451#if 0
452 // Nice and simple, but raises its ugly head in performance profiles....
453 return GetLayerSet().test( aLayer );
454#endif
455
456 if( aLayer >= m_layer && aLayer <= m_bottomLayer )
457 return true;
458
459 if( !IsTented() )
460 {
461 if( aLayer == F_Mask )
462 return IsOnLayer( F_Cu );
463 else if( aLayer == B_Mask )
464 return IsOnLayer( B_Cu );
465 }
466
467 return false;
468}
469
470
472{
473 LSET layermask;
474
476 layermask = LSET::AllCuMask();
477 else
478 wxASSERT( m_layer <= m_bottomLayer );
479
480 // PCB_LAYER_IDs are numbered from front to back, this is top to bottom.
481 for( int id = m_layer; id <= m_bottomLayer; ++id )
482 layermask.set( id );
483
484 if( !IsTented() )
485 {
486 if( layermask.test( F_Cu ) )
487 layermask.set( F_Mask );
488
489 if( layermask.test( B_Cu ) )
490 layermask.set( B_Mask );
491 }
492
493 return layermask;
494}
495
496
497void PCB_VIA::SetLayerSet( LSET aLayerSet )
498{
499 bool first = true;
500
501 for( PCB_LAYER_ID layer : aLayerSet.Seq() )
502 {
503 if( first )
504 {
505 m_layer = layer;
506 first = false;
507 }
508
509 m_bottomLayer = layer;
510 }
511}
512
513
514void PCB_VIA::SetLayerPair( PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer )
515{
516
517 m_layer = aTopLayer;
518 m_bottomLayer = aBottomLayer;
520}
521
522
524{
525 m_layer = aLayer;
526}
527
528
530{
531 m_bottomLayer = aLayer;
532}
533
534
535void PCB_VIA::LayerPair( PCB_LAYER_ID* top_layer, PCB_LAYER_ID* bottom_layer ) const
536{
537 PCB_LAYER_ID t_layer = F_Cu;
538 PCB_LAYER_ID b_layer = B_Cu;
539
541 {
542 b_layer = m_bottomLayer;
543 t_layer = m_layer;
544
545 if( b_layer < t_layer )
546 std::swap( b_layer, t_layer );
547 }
548
549 if( top_layer )
550 *top_layer = t_layer;
551
552 if( bottom_layer )
553 *bottom_layer = b_layer;
554}
555
556
558{
559 return m_layer;
560}
561
562
564{
565 return m_bottomLayer;
566}
567
568
570{
572 {
573 m_layer = F_Cu;
575 }
576
577 if( m_bottomLayer < m_layer )
578 std::swap( m_bottomLayer, m_layer );
579}
580
581
582bool PCB_VIA::FlashLayer( LSET aLayers ) const
583{
584 for( auto layer : aLayers.Seq() )
585 {
586 if( FlashLayer( layer ) )
587 return true;
588 }
589
590 return false;
591}
592
593
594bool PCB_VIA::FlashLayer( int aLayer ) const
595{
596 // Return the "normal" shape if the caller doesn't specify a particular layer
597 if( aLayer == UNDEFINED_LAYER )
598 return true;
599
600 const BOARD* board = GetBoard();
601
602 if( !board )
603 return true;
604
605 if( !IsOnLayer( static_cast<PCB_LAYER_ID>( aLayer ) ) )
606 return false;
607
609 return true;
610
611 if( m_keepTopBottomLayer && ( aLayer == m_layer || aLayer == m_bottomLayer ) )
612 return true;
613
614 // Must be static to keep from raising its ugly head in performance profiles
615 static std::initializer_list<KICAD_T> connectedTypes = { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T,
616 PCB_PAD_T };
617
618 // Do not check zones. Doing so results in race conditions when the via collides with
619 // two different zones of different priorities.
620 // See https://gitlab.com/kicad/code/kicad/-/issues/11299.
621
622 return board->GetConnectivity()->IsConnectedOnLayer( this, aLayer, connectedTypes, true );
623}
624
625
626void PCB_TRACK::ViewGetLayers( int aLayers[], int& aCount ) const
627{
628 // Show the track and its netname on different layers
629 aLayers[0] = GetLayer();
630 aLayers[1] = GetNetnameLayer( aLayers[0] );
631 aCount = 2;
632
633 if( IsLocked() )
634 aLayers[ aCount++ ] = LAYER_LOCKED_ITEM_SHADOW;
635}
636
637
638double PCB_TRACK::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
639{
640 constexpr double HIDE = std::numeric_limits<double>::max();
641
642 PCB_PAINTER* painter = static_cast<PCB_PAINTER*>( aView->GetPainter() );
643 PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
644
645 if( !aView->IsLayerVisible( LAYER_TRACKS ) )
646 return HIDE;
647
648 if( IsNetnameLayer( aLayer ) )
649 {
651 return HIDE;
652
653 // Hide netnames on dimmed tracks
654 if( renderSettings->GetHighContrast() )
655 {
656 if( m_layer != renderSettings->GetPrimaryHighContrastLayer() )
657 return HIDE;
658 }
659
660 // When drawing netnames, clip the track to the viewport
661 VECTOR2I start( GetStart() );
662 VECTOR2I end( GetEnd() );
663 BOX2D viewport = aView->GetViewport();
664 BOX2I clipBox( viewport.GetOrigin(), viewport.GetSize() );
665
666 ClipLine( &clipBox, start.x, start.y, end.x, end.y );
667
668 VECTOR2I line = ( end - start );
669 double length = line.EuclideanNorm();
670
671 // Check if the track is long enough to have a netname displayed
672 if( length < 6 * GetWidth() )
673 return HIDE;
674
675 // Netnames will be shown only if zoom is appropriate
676 return ( double ) pcbIUScale.mmToIU( 4 ) / ( m_Width + 1 );
677 }
678
679 if( aLayer == LAYER_LOCKED_ITEM_SHADOW )
680 {
681 // Hide shadow if the main layer is not shown
682 if( !aView->IsLayerVisible( m_layer ) )
683 return HIDE;
684
685 // Hide shadow on dimmed tracks
686 if( renderSettings->GetHighContrast() )
687 {
688 if( m_layer != renderSettings->GetPrimaryHighContrastLayer() )
689 return HIDE;
690 }
691 }
692
693 // Other layers are shown without any conditions
694 return 0.0;
695}
696
697
699{
700 BOX2I bbox = GetBoundingBox();
701 const BOARD* board = GetBoard();
702
703 if( board )
705 else
706 bbox.Inflate( GetWidth() ); // Add a bit extra for safety
707
708 return bbox;
709}
710
711
712void PCB_VIA::ViewGetLayers( int aLayers[], int& aCount ) const
713{
714 aLayers[0] = LAYER_VIA_HOLES;
715 aLayers[1] = LAYER_VIA_HOLEWALLS;
716 aLayers[2] = LAYER_VIA_NETNAMES;
717
718 // Just show it on common via & via holes layers
719 switch( GetViaType() )
720 {
721 case VIATYPE::THROUGH: aLayers[3] = LAYER_VIA_THROUGH; break;
722 case VIATYPE::BLIND_BURIED: aLayers[3] = LAYER_VIA_BBLIND; break;
723 case VIATYPE::MICROVIA: aLayers[3] = LAYER_VIA_MICROVIA; break;
724 default: aLayers[3] = LAYER_GP_OVERLAY; break;
725 }
726
727 aCount = 4;
728
729 if( IsLocked() )
730 aLayers[ aCount++ ] = LAYER_LOCKED_ITEM_SHADOW;
731}
732
733
734double PCB_VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
735{
736 constexpr double HIDE = (double)std::numeric_limits<double>::max();
737
738 PCB_PAINTER* painter = static_cast<PCB_PAINTER*>( aView->GetPainter() );
739 PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
740 const BOARD* board = GetBoard();
741 LSET visible = LSET::AllLayersMask();
742
743 // Meta control for hiding all vias
744 if( !aView->IsLayerVisible( LAYER_VIAS ) )
745 return HIDE;
746
747 // Handle board visibility
748 if( board )
749 visible = board->GetVisibleLayers() & board->GetEnabledLayers();
750
751 // In high contrast mode don't show vias that don't cross the high-contrast layer
752 if( renderSettings->GetHighContrast() )
753 {
754 PCB_LAYER_ID highContrastLayer = renderSettings->GetPrimaryHighContrastLayer();
755
756 if( LSET::FrontTechMask().Contains( highContrastLayer ) )
757 highContrastLayer = F_Cu;
758 else if( LSET::BackTechMask().Contains( highContrastLayer ) )
759 highContrastLayer = B_Cu;
760
761 if( !GetLayerSet().Contains( highContrastLayer ) )
762 return HIDE;
763 }
764
765 if( IsViaPadLayer( aLayer ) )
766 {
767 if( !FlashLayer( visible ) )
768 return HIDE;
769 }
770 else if( IsHoleLayer( aLayer ) )
771 {
773 {
774 // Show a blind or micro via's hole if it crosses a visible layer
775 if( !( visible & GetLayerSet() ).any() )
776 return HIDE;
777 }
778 else
779 {
780 // Show a through via's hole if any physical layer is shown
781 if( !( visible & LSET::PhysicalLayersMask() ).any() )
782 return HIDE;
783 }
784 }
785 else if( IsNetnameLayer( aLayer ) )
786 {
787 if( renderSettings->GetHighContrast() )
788 {
789 // Hide netnames unless via is flashed to a high-contrast layer
790 if( !FlashLayer( renderSettings->GetPrimaryHighContrastLayer() ) )
791 return HIDE;
792 }
793 else
794 {
795 // Hide netnames unless pad is flashed to a visible layer
796 if( !FlashLayer( visible ) )
797 return HIDE;
798 }
799
800 // Netnames will be shown only if zoom is appropriate
801 return m_Width == 0 ? HIDE : ( (double)pcbIUScale.mmToIU( 10 ) / m_Width );
802 }
803
804 // Passed all tests; show.
805 return 0.0;
806}
807
808
809// see class_track.h
810void PCB_TRACK::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
811{
812 wxString msg;
813 BOARD* board = GetBoard();
814
815 aList.emplace_back( _( "Type" ),
816 Type() == PCB_ARC_T ? _( "Track (arc)" ) : _( "Track" ) );
817
818
819 GetMsgPanelInfoBase_Common( aFrame, aList );
820
821 aList.emplace_back( _( "Layer" ), layerMaskDescribe() );
822
823 aList.emplace_back( _( "Width" ), aFrame->MessageTextFromValue( m_Width ) );
824
825 if( Type() == PCB_ARC_T )
826 {
827 double radius = static_cast<PCB_ARC*>( this )->GetRadius();
828 aList.emplace_back( _( "Radius" ), aFrame->MessageTextFromValue( radius ) );
829 }
830
831 aList.emplace_back( _( "Segment Length" ), aFrame->MessageTextFromValue( GetLength() ) );
832
833 // Display full track length (in Pcbnew)
834 if( board && GetNetCode() > 0 )
835 {
836 int count;
837 double trackLen;
838 double lenPadToDie;
839
840 std::tie( count, trackLen, lenPadToDie ) = board->GetTrackLength( *this );
841
842 aList.emplace_back( _( "Routed Length" ), aFrame->MessageTextFromValue( trackLen ) );
843
844 if( lenPadToDie != 0 )
845 {
846 msg = aFrame->MessageTextFromValue( lenPadToDie );
847 aList.emplace_back( _( "Pad To Die Length" ), msg );
848
849 msg = aFrame->MessageTextFromValue( trackLen + lenPadToDie );
850 aList.emplace_back( _( "Full Length" ), msg );
851 }
852 }
853
854 wxString source;
855 int clearance = GetOwnClearance( GetLayer(), &source );
856
857 aList.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
858 aFrame->MessageTextFromValue( clearance ) ),
859 wxString::Format( _( "(from %s)" ), source ) );
860
861 MINOPTMAX<int> c = GetWidthConstraint( &source );
862
863 if( c.HasMax() )
864 {
865 aList.emplace_back( wxString::Format( _( "Width Constraints: min %s, max %s" ),
866 aFrame->MessageTextFromValue( c.Min() ),
867 aFrame->MessageTextFromValue( c.Max() ) ),
868 wxString::Format( _( "(from %s)" ), source ) );
869 }
870 else
871 {
872 aList.emplace_back( wxString::Format( _( "Width Constraints: min %s" ),
873 aFrame->MessageTextFromValue( c.Min() ) ),
874 wxString::Format( _( "(from %s)" ), source ) );
875 }
876}
877
878
879void PCB_VIA::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
880{
881 wxString msg;
882
883 switch( GetViaType() )
884 {
885 case VIATYPE::MICROVIA: msg = _( "Micro Via" ); break;
886 case VIATYPE::BLIND_BURIED: msg = _( "Blind/Buried Via" ); break;
887 case VIATYPE::THROUGH: msg = _( "Through Via" ); break;
888 default: msg = _( "Via" ); break;
889 }
890
891 aList.emplace_back( _( "Type" ), msg );
892
893 GetMsgPanelInfoBase_Common( aFrame, aList );
894
895 aList.emplace_back( _( "Layer" ), layerMaskDescribe() );
896 aList.emplace_back( _( "Diameter" ), aFrame->MessageTextFromValue( m_Width ) );
897 aList.emplace_back( _( "Hole" ), aFrame->MessageTextFromValue( GetDrillValue() ) );
898
899 wxString source;
900 int clearance = GetOwnClearance( GetLayer(), &source );
901
902 aList.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
903 aFrame->MessageTextFromValue( clearance ) ),
904 wxString::Format( _( "(from %s)" ), source ) );
905
906 int minAnnulus = GetMinAnnulus( GetLayer(), &source );
907
908 aList.emplace_back( wxString::Format( _( "Min Annular Width: %s" ),
909 aFrame->MessageTextFromValue( minAnnulus ) ),
910 wxString::Format( _( "(from %s)" ), source ) );
911}
912
913
915 std::vector<MSG_PANEL_ITEM>& aList ) const
916{
917 aList.emplace_back( _( "Net" ), UnescapeString( GetNetname() ) );
918
919 aList.emplace_back( _( "Resolved Netclass" ),
920 UnescapeString( GetEffectiveNetClass()->GetName() ) );
921
922#if 0 // Enable for debugging
923 if( GetBoard() )
924 aList.emplace_back( _( "NetCode" ), wxString::Format( wxT( "%d" ), GetNetCode() ) );
925
926 aList.emplace_back( wxT( "Flags" ), wxString::Format( wxT( "0x%08X" ), m_flags ) );
927
928 aList.emplace_back( wxT( "Start pos" ), wxString::Format( wxT( "%d %d" ),
929 m_Start.x,
930 m_Start.y ) );
931 aList.emplace_back( wxT( "End pos" ), wxString::Format( wxT( "%d %d" ),
932 m_End.x,
933 m_End.y ) );
934#endif
935
936 if( aFrame->GetName() == PCB_EDIT_FRAME_NAME && IsLocked() )
937 aList.emplace_back( _( "Status" ), _( "Locked" ) );
938}
939
940
942{
943 const BOARD* board = GetBoard();
944 PCB_LAYER_ID top_layer;
945 PCB_LAYER_ID bottom_layer;
946
947 LayerPair( &top_layer, &bottom_layer );
948
949 return board->GetLayerName( top_layer ) + wxT( " - " ) + board->GetLayerName( bottom_layer );
950}
951
952
953bool PCB_TRACK::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
954{
955 return TestSegmentHit( aPosition, m_Start, m_End, aAccuracy + ( m_Width / 2 ) );
956}
957
958
959bool PCB_ARC::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
960{
961 int max_dist = aAccuracy + ( m_Width / 2 );
962
963 // Short-circuit common cases where the arc is connected to a track or via at an endpoint
964 if( EuclideanNorm( GetStart() - aPosition ) <= max_dist ||
965 EuclideanNorm( GetEnd() - aPosition ) <= max_dist )
966 {
967 return true;
968 }
969
970 VECTOR2I center = GetPosition();
971 VECTOR2I relpos = aPosition - center;
972 double dist = EuclideanNorm( relpos );
973 double radius = GetRadius();
974
975 if( std::abs( dist - radius ) > max_dist )
976 return false;
977
978 EDA_ANGLE arc_angle = GetAngle();
979 EDA_ANGLE arc_angle_start = GetArcAngleStart(); // Always 0.0 ... 360 deg
980 EDA_ANGLE arc_hittest( relpos );
981
982 // Calculate relative angle between the starting point of the arc, and the test point
983 arc_hittest -= arc_angle_start;
984
985 // Normalise arc_hittest between 0 ... 360 deg
986 arc_hittest.Normalize();
987
988 if( arc_angle < ANGLE_0 )
989 return arc_hittest >= ANGLE_360 + arc_angle;
990
991 return arc_hittest <= arc_angle;
992}
993
994
995bool PCB_VIA::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
996{
997 int max_dist = aAccuracy + ( m_Width / 2 );
998
999 // rel_pos is aPosition relative to m_Start (or the center of the via)
1000 VECTOR2I rel_pos = aPosition - m_Start;
1001 double dist = (double) rel_pos.x * rel_pos.x + (double) rel_pos.y * rel_pos.y;
1002 return dist <= (double) max_dist * max_dist;
1003}
1004
1005
1006bool PCB_TRACK::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
1007{
1008 BOX2I arect = aRect;
1009 arect.Inflate( aAccuracy );
1010
1011 if( aContained )
1012 return arect.Contains( GetStart() ) && arect.Contains( GetEnd() );
1013 else
1014 return arect.Intersects( GetStart(), GetEnd() );
1015}
1016
1017
1018bool PCB_ARC::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
1019{
1020 BOX2I arect = aRect;
1021 arect.Inflate( aAccuracy );
1022
1023 BOX2I box( GetStart() );
1024 box.Merge( GetMid() );
1025 box.Merge( GetEnd() );
1026
1027 box.Inflate( GetWidth() / 2 );
1028
1029 if( aContained )
1030 return arect.Contains( box );
1031 else
1032 return arect.Intersects( box );
1033}
1034
1035
1036bool PCB_VIA::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
1037{
1038 BOX2I arect = aRect;
1039 arect.Inflate( aAccuracy );
1040
1041 BOX2I box( GetStart() );
1042 box.Inflate( GetWidth() / 2 );
1043
1044 if( aContained )
1045 return arect.Contains( box );
1046 else
1047 return arect.IntersectsCircle( GetStart(), GetWidth() / 2 );
1048}
1049
1050
1051wxString PCB_TRACK::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const
1052{
1053 return wxString::Format( Type() == PCB_ARC_T ? _("Track (arc) %s on %s, length %s" )
1054 : _("Track %s on %s, length %s" ),
1055 GetNetnameMsg(),
1056 GetLayerName(),
1057 aUnitsProvider->MessageTextFromValue( GetLength() ) );
1058}
1059
1060
1062{
1063 return BITMAPS::add_tracks;
1064}
1065
1067{
1068 assert( aImage->Type() == PCB_TRACE_T );
1069
1070 std::swap( *((PCB_TRACK*) this), *((PCB_TRACK*) aImage) );
1071}
1072
1074{
1075 assert( aImage->Type() == PCB_ARC_T );
1076
1077 std::swap( *this, *static_cast<PCB_ARC*>( aImage ) );
1078}
1079
1081{
1082 assert( aImage->Type() == PCB_VIA_T );
1083
1084 std::swap( *((PCB_VIA*) this), *((PCB_VIA*) aImage) );
1085}
1086
1087
1089{
1091 return center;
1092}
1093
1095{
1096 auto center = CalcArcCenter( m_Start, m_Mid , m_End );
1097 return GetLineLength( center, m_Start );
1098}
1099
1101{
1102 VECTOR2I center = GetPosition();
1103 EDA_ANGLE angle1 = EDA_ANGLE( m_Mid - center ) - EDA_ANGLE( m_Start - center );
1104 EDA_ANGLE angle2 = EDA_ANGLE( m_End - center ) - EDA_ANGLE( m_Mid - center );
1105
1106 return angle1.Normalize180() + angle2.Normalize180();
1107}
1108
1110{
1111 EDA_ANGLE angleStart( m_Start - GetPosition() );
1112 return angleStart.Normalize();
1113}
1114
1116{
1117 EDA_ANGLE angleEnd( m_End - GetPosition() );
1118 return angleEnd.Normalize();
1119}
1120
1121
1123{
1124 if( a->GetNetCode() != b->GetNetCode() )
1125 return a->GetNetCode() < b->GetNetCode();
1126
1127 if( a->GetLayer() != b->GetLayer() )
1128 return a->GetLayer() < b->GetLayer();
1129
1130 if( a->Type() != b->Type() )
1131 return a->Type() < b->Type();
1132
1133 if( a->m_Uuid != b->m_Uuid )
1134 return a->m_Uuid < b->m_Uuid;
1135
1136 return a < b;
1137}
1138
1139
1140std::shared_ptr<SHAPE> PCB_TRACK::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
1141{
1142 return std::make_shared<SHAPE_SEGMENT>( m_Start, m_End, m_Width );
1143}
1144
1145
1146std::shared_ptr<SHAPE> PCB_VIA::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
1147{
1148 if( aFlash == FLASHING::ALWAYS_FLASHED
1149 || ( aFlash == FLASHING::DEFAULT && FlashLayer( aLayer ) ) )
1150 {
1151 return std::make_shared<SHAPE_CIRCLE>( m_Start, m_Width / 2 );
1152 }
1153 else
1154 {
1155 int radius = GetDrillValue() / 2;
1156
1157 if( GetBoard() )
1159
1160 return std::make_shared<SHAPE_CIRCLE>( m_Start, radius );
1161 }
1162}
1163
1164
1165std::shared_ptr<SHAPE> PCB_ARC::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
1166{
1167 return std::make_shared<SHAPE_ARC>( GetStart(), GetMid(), GetEnd(), GetWidth() );
1168}
1169
1170
1172 PCB_LAYER_ID aLayer, int aClearanceValue,
1173 int aError, ERROR_LOC aErrorLoc,
1174 bool ignoreLineWidth ) const
1175{
1176 wxASSERT_MSG( !ignoreLineWidth, wxT( "IgnoreLineWidth has no meaning for tracks." ) );
1177
1178
1179 switch( Type() )
1180 {
1181 case PCB_VIA_T:
1182 {
1183 int radius = ( m_Width / 2 ) + aClearanceValue;
1184 TransformCircleToPolygon( aCornerBuffer, m_Start, radius, aError, aErrorLoc );
1185 break;
1186 }
1187
1188 case PCB_ARC_T:
1189 {
1190 const PCB_ARC* arc = static_cast<const PCB_ARC*>( this );
1191 int width = m_Width + ( 2 * aClearanceValue );
1192
1193 TransformArcToPolygon( aCornerBuffer, arc->GetStart(), arc->GetMid(),
1194 arc->GetEnd(), width, aError, aErrorLoc );
1195 break;
1196 }
1197
1198 default:
1199 {
1200 int width = m_Width + ( 2 * aClearanceValue );
1201
1202 TransformOvalToPolygon( aCornerBuffer, m_Start, m_End, width, aError, aErrorLoc );
1203 break;
1204 }
1205 }
1206}
1207
1208
1209static struct TRACK_VIA_DESC
1210{
1212 {
1214 .Undefined( VIATYPE::NOT_DEFINED )
1215 .Map( VIATYPE::THROUGH, _HKI( "Through" ) )
1216 .Map( VIATYPE::BLIND_BURIED, _HKI( "Blind/buried" ) )
1217 .Map( VIATYPE::MICROVIA, _HKI( "Micro" ) );
1218
1220
1221 if( layerEnum.Choices().GetCount() == 0 )
1222 {
1223 layerEnum.Undefined( UNDEFINED_LAYER );
1224
1225 for( LSEQ seq = LSET::AllLayersMask().Seq(); seq; ++seq )
1226 layerEnum.Map( *seq, LSET::Name( *seq ) );
1227 }
1228
1230
1231 // Track
1234
1235 propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "Width" ),
1237 propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position X" ),
1238 new PROPERTY<PCB_TRACK, int, BOARD_ITEM>( _HKI( "Origin X" ),
1240 propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position Y" ),
1241 new PROPERTY<PCB_TRACK, int, BOARD_ITEM>( _HKI( "Origin Y" ),
1243 propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "End X" ),
1245 propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "End Y" ),
1247
1248 // Arc
1251
1252 propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "Width" ),
1254 propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position X" ),
1255 new PROPERTY<PCB_ARC, int, BOARD_ITEM>( _HKI( "Origin X" ),
1257 propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position Y" ),
1258 new PROPERTY<PCB_ARC, int, BOARD_ITEM>( _HKI( "Origin Y" ),
1260 propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "End X" ),
1262 propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "End Y" ),
1264
1265 // Via
1268
1269 // TODO layerset for vias?
1270 // TODO test drill, use getdrillvalue?
1271 propMgr.ReplaceProperty( TYPE_HASH( PCB_TRACK ), _HKI( "Width" ),
1272 new PROPERTY<PCB_VIA, int, PCB_TRACK>( _HKI( "Diameter" ),
1274 propMgr.AddProperty( new PROPERTY<PCB_VIA, int>( _HKI( "Hole" ),
1276 propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Layer" ),
1279 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, PCB_LAYER_ID>( _HKI( "Layer Bottom" ),
1281 propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, VIATYPE>( _HKI( "Via Type" ),
1283 }
1285
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
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.
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.
int GetHolePlatingThickness() const
Pad & via drills are finish size.
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:50
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:167
int GetY() const
Definition: board_item.h:72
PCB_LAYER_ID m_layer
Definition: board_item.h:317
int GetX() const
Definition: board_item.h:66
void SetX(int aX)
Definition: board_item.h:88
void SetY(int aY)
Definition: board_item.h:94
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:201
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:37
virtual bool IsLocked() const
Definition: board_item.cpp:65
virtual wxString layerMaskDescribe() const
Return a string (to be shown to the user) describing a layer mask.
Definition: board_item.cpp:100
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Definition: board_item.cpp:88
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:501
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:515
int GetCopperLayerCount() const
Definition: board.cpp:489
bool GetTentVias() const
Definition: board.h:621
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:400
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:1701
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:618
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:424
const Vec & GetOrigin() const
Definition: box2.h:183
bool Intersects(const BOX2< Vec > &aRect) const
Definition: box2.h:269
coord_type GetTop() const
Definition: box2.h:194
bool IntersectsCircle(const Vec &aCenter, const int aRadius) const
Definition: box2.h:452
bool Contains(const Vec &aPoint) const
Definition: box2.h:141
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:506
coord_type GetRight() const
Definition: box2.h:189
coord_type GetLeft() const
Definition: box2.h:193
const Vec & GetSize() const
Definition: box2.h:179
coord_type GetBottom() const
Definition: box2.h:190
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: box2.h:588
wxString GetName() const
Definition: drc_rule.h:147
MINOPTMAX< int > & Value()
Definition: drc_rule.h:140
EDA_ANGLE Normalize()
Definition: eda_angle.h:249
EDA_ANGLE Normalize180()
Definition: eda_angle.h:271
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:85
const KIID m_Uuid
Definition: eda_item.h:492
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:498
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:518
static ENUM_MAP< T > & Instance()
Definition: property.h:512
ENUM_MAP & Undefined(T aValue)
Definition: property.h:525
wxPGChoices & Choices()
Definition: property.h:561
Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:156
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:161
PCB specific render settings.
Definition: pcb_painter.h:71
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:69
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition: view.cpp:508
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:410
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:213
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:491
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:530
static LSET AllLayersMask()
Definition: lset.cpp:808
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:411
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
static LSET PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
Definition: lset.cpp:870
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition: lset.cpp:82
static LSET FrontTechMask()
Return a mask holding all technical layers (no CU layer) on front side.
Definition: lset.cpp:827
static LSET BackTechMask()
Return a mask holding all technical layers (no CU layer) on back side.
Definition: lset.cpp:815
T Min() const
Definition: minoptmax.h:33
bool HasMax() const
Definition: minoptmax.h:38
bool HasMin() const
Definition: minoptmax.h:37
T Max() const
Definition: minoptmax.h:34
A collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:47
int GetViaDrill() const
Definition: netclass.h:84
int GetuViaDrill() const
Definition: netclass.h:92
static const int UNCONNECTED
Constant that forces initialization of a netinfo item to the NETINFO_ITEM ORPHANED (typically -1) whe...
Definition: netinfo.h:373
virtual VECTOR2I GetPosition() const override
Definition: pcb_track.cpp:1088
bool IsCCW() const
Definition: pcb_track.cpp:369
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pcb_track.cpp:74
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
Definition: pcb_track.cpp:1073
EDA_ANGLE GetArcAngleStart() const
Definition: pcb_track.cpp:1109
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:959
EDA_ANGLE GetArcAngleEnd() const
Definition: pcb_track.cpp:1115
double GetRadius() const
Definition: pcb_track.cpp:1094
EDA_ANGLE GetAngle() const
Definition: pcb_track.cpp:1100
const VECTOR2I & GetMid() const
Definition: pcb_track.h:274
PCB_ARC(BOARD_ITEM *aParent)
Definition: pcb_track.h:248
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pcb_track.cpp:349
VECTOR2I m_Mid
Arc mid point, halfway between start and end.
Definition: pcb_track.h:319
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_track.cpp:291
virtual 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:1165
void Mirror(const VECTOR2I &aCentre, bool aMirrorAroundXAxis) override
Definition: pcb_track.cpp:314
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
Definition: pcb_track.cpp:284
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:626
int GetLocalClearance(wxString *aSource) const override
Function GetLocalClearance returns any local clearance overrides set in the "classic" (ie: pre-rule) ...
Definition: pcb_track.cpp:129
void SetEndY(int aY)
Definition: pcb_track.h:114
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
Definition: pcb_track.cpp:1066
void SetWidth(int aWidth)
Definition: pcb_track.h:104
MINOPTMAX< int > GetWidthConstraint(wxString *aSource) const
Definition: pcb_track.cpp:136
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pcb_track.cpp:638
virtual double GetLength() const
Function GetLength returns the length of the track using the hypotenuse calculation.
Definition: pcb_track.cpp:278
int GetWidth() const
Definition: pcb_track.h:105
wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: pcb_track.cpp:1051
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Function TransformShapeWithClearanceToPolygon Convert the track shape to a closed polygon Used in fil...
Definition: pcb_track.cpp:1171
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: pcb_track.cpp:698
int GetEndX() const
Definition: pcb_track.h:116
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:405
bool ApproxCollinear(const PCB_TRACK &aTrack)
Definition: pcb_track.cpp:121
VECTOR2I m_End
Line end point.
Definition: pcb_track.h:241
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:810
virtual EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pcb_track.cpp:59
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_track.cpp:232
const VECTOR2I & GetStart() const
Definition: pcb_track.h:111
VECTOR2I m_Start
Line start point.
Definition: pcb_track.h:240
int GetEndY() const
Definition: pcb_track.h:117
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pcb_track.cpp:1061
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pcb_track.cpp:331
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:953
virtual 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:1140
const VECTOR2I & GetEnd() const
Definition: pcb_track.h:108
PCB_TRACK(BOARD_ITEM *aParent, KICAD_T idtype=PCB_TRACE_T)
Definition: pcb_track.cpp:52
int m_Width
Thickness of track, or via diameter.
Definition: pcb_track.h:239
void SetEndX(int aX)
Definition: pcb_track.h:113
virtual void Mirror(const VECTOR2I &aCentre, bool aMirrorAroundXAxis)
Definition: pcb_track.cpp:299
EDA_ITEM_FLAGS IsPointOnEnds(const VECTOR2I &point, int min_dist=0) const
Function IsPointOnEnds returns STARTPOINT if point if near (dist = min_dist) start point,...
Definition: pcb_track.cpp:200
void GetMsgPanelInfoBase_Common(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) const
Definition: pcb_track.cpp:914
bool IsTented() const override
Definition: pcb_track.cpp:427
PCB_LAYER_ID BottomLayer() const
Definition: pcb_track.cpp:563
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pcb_track.cpp:115
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:1146
bool FlashLayer(int aLayer) const
Checks to see whether the via should have a pad on the specific layer.
Definition: pcb_track.cpp:594
void SetDrillDefault()
Function SetDrillDefault sets the drill value for vias to the default value UNDEFINED_DRILL_DIAMETER.
Definition: pcb_track.h:485
PCB_LAYER_ID m_bottomLayer
The bottom layer of the via (the top layer is in m_layer)
Definition: pcb_track.h:512
bool m_isFree
"Free" vias don't get their nets auto-updated
Definition: pcb_track.h:520
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:995
virtual void SetLayerSet(LSET aLayers) override
Definition: pcb_track.cpp:497
void SetBottomLayer(PCB_LAYER_ID aLayer)
Definition: pcb_track.cpp:529
int GetSolderMaskExpansion() const
Definition: pcb_track.cpp:438
wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: pcb_track.cpp:98
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: pcb_track.h:464
void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
Definition: pcb_track.cpp:1080
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:879
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pcb_track.cpp:92
int m_drill
for vias: via drill (- 1 for default value)
Definition: pcb_track.h:516
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pcb_track.cpp:734
void SetTopLayer(PCB_LAYER_ID aLayer)
Definition: pcb_track.cpp:523
std::shared_ptr< SHAPE_SEGMENT > GetEffectiveHoleShape() const override
Definition: pcb_track.cpp:421
void SetLayerPair(PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer)
Function SetLayerPair For a via m_layer contains the top layer, the other layer is in m_bottomLayer.
Definition: pcb_track.cpp:514
bool m_removeUnconnectedLayer
Remove unconnected copper on a via.
Definition: pcb_track.h:518
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:712
void SanitizeLayers()
Function SanitizeLayers Check so that the layers are correct dependin on the type of via,...
Definition: pcb_track.cpp:569
PCB_VIA(BOARD_ITEM *aParent)
Definition: pcb_track.cpp:80
wxString layerMaskDescribe() const override
Return a string (to be shown to the user) describing a layer mask.
Definition: pcb_track.cpp:941
void SetViaType(VIATYPE aViaType)
Definition: pcb_track.h:354
int GetMinAnnulus(PCB_LAYER_ID aLayer, wxString *aSource) const
Definition: pcb_track.cpp:154
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition: pcb_track.cpp:449
PCB_LAYER_ID TopLayer() const
Definition: pcb_track.cpp:557
VIATYPE m_viaType
through, blind/buried or micro
Definition: pcb_track.h:514
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
Definition: pcb_track.cpp:185
bool m_keepTopBottomLayer
Keep the top and bottom annular rings.
Definition: pcb_track.h:519
VIATYPE GetViaType() const
Definition: pcb_track.h:353
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pcb_track.cpp:471
void LayerPair(PCB_LAYER_ID *top_layer, PCB_LAYER_ID *bottom_layer) const
Function LayerPair Return the 2 layers used by the via (the via actually uses all layers between thes...
Definition: pcb_track.cpp:535
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pcb_track.cpp:378
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:63
void AddProperty(PROPERTY_BASE *aProperty)
Register a property.
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:65
void ReplaceProperty(size_t aBase, const wxString &aName, PROPERTY_BASE *aNew)
Replace an existing property for a specific type.
Definition: seg.h:42
bool ApproxCollinear(const SEG &aSeg) const
Definition: seg.h:280
const VECTOR2I & GetArcMid() const
Definition: shape_arc.h:114
const VECTOR2I & GetP1() const
Definition: shape_arc.h:113
const VECTOR2I & GetP0() const
Definition: shape_arc.h:112
Represent a set of closed polygons.
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
Definition: vector2d.h:293
extended_type Cross(const VECTOR2< T > &aVector) const
Compute cross product of self with aVector.
Definition: vector2d.h:487
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aCornerBuffer, 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 &aCornerBuffer, 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 &aCornerBuffer, 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:56
@ TRACK_WIDTH_CONSTRAINT
Definition: drc_rule.h:55
#define _(s)
static constexpr EDA_ANGLE & ANGLE_360
Definition: eda_angle.h:418
static constexpr EDA_ANGLE & ANGLE_0
Definition: eda_angle.h:412
#define PCB_EDIT_FRAME_NAME
INSPECT_RESULT
Definition: eda_item.h:42
const INSPECTOR_FUNC & INSPECTOR
Definition: eda_item.h:78
#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
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
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.
Some functions to handle hotkeys in KiCad.
@ LAYER_VIA_NETNAMES
Definition: layer_ids.h:168
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:147
@ ALWAYS_FLASHED
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
Definition: layer_ids.h:966
@ LAYER_LOCKED_ITEM_SHADOW
shadow layer for locked items
Definition: layer_ids.h:239
@ LAYER_VIA_HOLEWALLS
Definition: layer_ids.h:234
@ LAYER_GP_OVERLAY
general purpose overlay
Definition: layer_ids.h:218
@ LAYER_TRACKS
Definition: layer_ids.h:212
@ LAYER_VIA_HOLES
to draw via holes (pad holes do not use this layer)
Definition: layer_ids.h:215
@ LAYER_VIA_MICROVIA
to draw micro vias
Definition: layer_ids.h:194
@ LAYER_VIA_THROUGH
to draw usual through hole vias
Definition: layer_ids.h:196
@ LAYER_VIAS
Meta control for all vias opacity/visibility.
Definition: layer_ids.h:193
@ LAYER_VIA_BBLIND
to draw blind/buried vias
Definition: layer_ids.h:195
bool IsNetnameLayer(int aLayer)
Test whether a layer is a netname layer.
Definition: layer_ids.h:989
bool IsHoleLayer(int aLayer)
Definition: layer_ids.h:862
bool IsViaPadLayer(int aLayer)
Definition: layer_ids.h:855
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ B_Mask
Definition: layer_ids.h:106
@ B_Cu
Definition: layer_ids.h:95
@ F_Mask
Definition: layer_ids.h:107
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
@ F_Cu
Definition: layer_ids.h:64
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Definition: lset.cpp:544
void MIRROR(T &aPoint, const T &aMirrorRef)
Updates aPoint with the mirror of aPoint relative to the aMirrorRef.
Definition: mirror.h:40
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:401
ENUM_TO_WXANY(VIATYPE)
static struct TRACK_VIA_DESC _TRACK_VIA_DESC
VIATYPE
Definition: pcb_track.h:62
@ BLIND_BURIED
#define TYPE_HASH(x)
Definition: property.h:60
@ PT_COORD
Coordinate expressed in distance units (mm/inch)
Definition: property.h:54
@ PT_SIZE
Size expressed in distance units (mm/inch)
Definition: property.h:53
#define REGISTER_TYPE(x)
Definition: property_mgr.h:248
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
wxString UnescapeString(const wxString &aSource)
constexpr int mmToIU(double mm) const
Definition: base_units.h:89
bool operator()(const PCB_TRACK *aFirst, const PCB_TRACK *aSecond) const
Definition: pcb_track.cpp:1122
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:129
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183
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:472
double GetLineLength(const VECTOR2I &aPointA, const VECTOR2I &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:188
double EuclideanNorm(const VECTOR2I &vector)
Definition: trigo.h:129
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:102
@ 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:103
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:101
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:80
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618