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 <dick@softplc.com>
6  * Copyright (C) 2012 Wayne Stambaugh <stambaughw@gmail.com>
7  * Copyright (C) 1992-2021 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>
29 #include <board.h>
30 #include <board_design_settings.h>
31 #include <pcb_track.h>
32 #include <base_units.h>
33 #include <bitmaps.h>
34 #include <string_utils.h>
35 #include <view/view.h>
38 #include <i18n_utility.h>
39 #include <geometry/seg.h>
40 #include <geometry/shape_segment.h>
41 #include <geometry/shape_circle.h>
42 #include <geometry/shape_arc.h>
43 #include <drc/drc_engine.h>
44 #include <pcb_painter.h>
45 #include <trigo.h>
46 
47 using KIGFX::PCB_PAINTER;
49 
51  BOARD_CONNECTED_ITEM( aParent, idtype )
52 {
53  m_Width = Millimeter2iu( 0.2 ); // Gives a reasonable default width
54 }
55 
56 
58 {
59  return new PCB_TRACK( *this );
60 }
61 
62 
63 PCB_ARC::PCB_ARC( BOARD_ITEM* aParent, const SHAPE_ARC* aArc ) :
64  PCB_TRACK( aParent, PCB_ARC_T )
65 {
66  m_Start = wxPoint( aArc->GetP0() );
67  m_End = wxPoint( aArc->GetP1() );
68  m_Mid = wxPoint( aArc->GetArcMid() );
69 }
70 
71 
73 {
74  return new PCB_ARC( *this );
75 }
76 
77 
79  PCB_TRACK( aParent, PCB_VIA_T )
80 {
85  m_keepTopBottomLayer = true;
86  m_isFree = false;
87 }
88 
89 
91 {
92  return new PCB_VIA( *this );
93 }
94 
95 
96 wxString PCB_VIA::GetSelectMenuText( EDA_UNITS aUnits ) const
97 {
98  wxString formatStr;
99 
100  switch( GetViaType() )
101  {
102  case VIATYPE::BLIND_BURIED: formatStr = _( "Blind/Buried Via %s on %s" ); break;
103  case VIATYPE::MICROVIA: formatStr = _( "Micro Via %s on %s" ); break;
104  default: formatStr = _( "Via %s on %s" ); break;
105  }
106 
107  return wxString::Format( formatStr,
108  GetNetnameMsg(),
109  layerMaskDescribe() );
110 }
111 
112 
114 {
115  return BITMAPS::via;
116 }
117 
118 
120 {
121  SEG a( m_Start, m_End );
122  SEG b( aTrack.GetStart(), aTrack.GetEnd() );
123  return a.ApproxCollinear( b );
124 }
125 
126 
127 int PCB_TRACK::GetLocalClearance( wxString* aSource ) const
128 {
129  // Not currently implemented
130  return 0;
131 }
132 
133 
134 void PCB_TRACK::GetWidthConstraints( int* aMin, int* aMax, wxString* aSource ) const
135 {
136  *aMin = 0;
137  *aMax = INT_MAX;
138 
139  DRC_CONSTRAINT constraint;
140 
141  if( GetBoard() && GetBoard()->GetDesignSettings().m_DRCEngine )
142  {
144 
145  constraint = bds.m_DRCEngine->EvalRules( TRACK_WIDTH_CONSTRAINT, this, nullptr, GetLayer() );
146  }
147 
148  if( constraint.Value().HasMin() || constraint.Value().HasMax() )
149  {
150  if( constraint.Value().HasMin() )
151  *aMin = constraint.Value().Min();
152 
153  if( constraint.Value().HasMax() )
154  *aMax = constraint.Value().Max();
155 
156  if( aSource )
157  *aSource = constraint.GetName();
158  }
159 }
160 
161 
162 int PCB_VIA::GetMinAnnulus( PCB_LAYER_ID aLayer, wxString* aSource ) const
163 {
164  if( !FlashLayer( aLayer ) )
165  {
166  if( aSource )
167  *aSource = _( "removed annular ring" );
168 
169  return 0;
170  }
171 
172  DRC_CONSTRAINT constraint;
173 
174  if( GetBoard() && GetBoard()->GetDesignSettings().m_DRCEngine )
175  {
177 
178  constraint = bds.m_DRCEngine->EvalRules( ANNULAR_WIDTH_CONSTRAINT, this, nullptr, aLayer );
179  }
180 
181  if( constraint.Value().HasMin() )
182  {
183  if( aSource )
184  *aSource = constraint.GetName();
185 
186  return constraint.Value().Min();
187  }
188 
189  return 0;
190 }
191 
192 
194 {
195  if( m_drill > 0 ) // Use the specific value.
196  return m_drill;
197 
198  // Use the default value from the Netclass
199  NETCLASS* netclass = GetNetClass();
200 
201  if( GetViaType() == VIATYPE::MICROVIA )
202  return netclass->GetuViaDrill();
203 
204  return netclass->GetViaDrill();
205 }
206 
207 
208 EDA_ITEM_FLAGS PCB_TRACK::IsPointOnEnds( const wxPoint& point, int min_dist ) const
209 {
210  EDA_ITEM_FLAGS result = 0;
211 
212  if( min_dist < 0 )
213  min_dist = m_Width / 2;
214 
215  if( min_dist == 0 )
216  {
217  if( m_Start == point )
218  result |= STARTPOINT;
219 
220  if( m_End == point )
221  result |= ENDPOINT;
222  }
223  else
224  {
225  double dist = GetLineLength( m_Start, point );
226 
227  if( min_dist >= KiROUND( dist ) )
228  result |= STARTPOINT;
229 
230  dist = GetLineLength( m_End, point );
231 
232  if( min_dist >= KiROUND( dist ) )
233  result |= ENDPOINT;
234  }
235 
236  return result;
237 }
238 
239 
241 {
242  // end of track is round, this is its radius, rounded up
243  int radius = ( m_Width + 1 ) / 2;
244  int ymax, xmax, ymin, xmin;
245 
246  if( Type() == PCB_VIA_T )
247  {
248  ymax = m_Start.y;
249  xmax = m_Start.x;
250 
251  ymin = m_Start.y;
252  xmin = m_Start.x;
253  }
254  else if( Type() == PCB_ARC_T )
255  {
256  std::shared_ptr<SHAPE> arc = GetEffectiveShape();
257  auto bbox = arc->BBox();
258 
259  xmin = bbox.GetLeft();
260  xmax = bbox.GetRight();
261  ymin = bbox.GetTop();
262  ymax = bbox.GetBottom();
263  }
264  else
265  {
266  ymax = std::max( m_Start.y, m_End.y );
267  xmax = std::max( m_Start.x, m_End.x );
268 
269  ymin = std::min( m_Start.y, m_End.y );
270  xmin = std::min( m_Start.x, m_End.x );
271  }
272 
273  ymax += radius;
274  xmax += radius;
275 
276  ymin -= radius;
277  xmin -= radius;
278 
279  // return a rectangle which is [pos,dim) in nature. therefore the +1
280  EDA_RECT ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
281 
282  return ret;
283 }
284 
285 
286 double PCB_TRACK::GetLength() const
287 {
288  return GetLineLength( m_Start, m_End );
289 }
290 
291 
292 void PCB_TRACK::Rotate( const wxPoint& aRotCentre, double aAngle )
293 {
294  RotatePoint( &m_Start, aRotCentre, aAngle );
295  RotatePoint( &m_End, aRotCentre, aAngle );
296 }
297 
298 
299 void PCB_ARC::Rotate( const wxPoint& aRotCentre, double aAngle )
300 {
301  RotatePoint( &m_Start, aRotCentre, aAngle );
302  RotatePoint( &m_End, aRotCentre, aAngle );
303  RotatePoint( &m_Mid, aRotCentre, aAngle );
304 }
305 
306 
307 void PCB_TRACK::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
308 {
309  if( aFlipLeftRight )
310  {
311  m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
312  m_End.x = aCentre.x - ( m_End.x - aCentre.x );
313  }
314  else
315  {
316  m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
317  m_End.y = aCentre.y - ( m_End.y - aCentre.y );
318  }
319 
320  int copperLayerCount = GetBoard()->GetCopperLayerCount();
321  SetLayer( FlipLayer( GetLayer(), copperLayerCount ) );
322 }
323 
324 
325 void PCB_ARC::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
326 {
327  if( aFlipLeftRight )
328  {
329  m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
330  m_End.x = aCentre.x - ( m_End.x - aCentre.x );
331  m_Mid.x = aCentre.x - ( m_Mid.x - aCentre.x );
332  }
333  else
334  {
335  m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
336  m_End.y = aCentre.y - ( m_End.y - aCentre.y );
337  m_Mid.y = aCentre.y - ( m_Mid.y - aCentre.y );
338  }
339 
340  int copperLayerCount = GetBoard()->GetCopperLayerCount();
341  SetLayer( FlipLayer( GetLayer(), copperLayerCount ) );
342 }
343 
344 
345 void PCB_VIA::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
346 {
347  if( aFlipLeftRight )
348  {
349  m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
350  m_End.x = aCentre.x - ( m_End.x - aCentre.x );
351  }
352  else
353  {
354  m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
355  m_End.y = aCentre.y - ( m_End.y - aCentre.y );
356  }
357 
358  if( GetViaType() != VIATYPE::THROUGH )
359  {
360  int copperLayerCount = GetBoard()->GetCopperLayerCount();
361  PCB_LAYER_ID top_layer;
362  PCB_LAYER_ID bottom_layer;
363  LayerPair( &top_layer, &bottom_layer );
364  top_layer = FlipLayer( top_layer, copperLayerCount );
365  bottom_layer = FlipLayer( bottom_layer, copperLayerCount );
366  SetLayerPair( top_layer, bottom_layer );
367  }
368 }
369 
370 
371 // see class_track.h
372 SEARCH_RESULT PCB_TRACK::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
373 {
374  KICAD_T stype = *scanTypes;
375 
376  // If caller wants to inspect my type
377  if( stype == Type() )
378  {
379  if( SEARCH_RESULT::QUIT == inspector( this, testData ) )
380  return SEARCH_RESULT::QUIT;
381  }
382 
384 }
385 
386 
387 bool PCB_VIA::IsOnLayer( PCB_LAYER_ID layer_number ) const
388 {
389  PCB_LAYER_ID bottom_layer, top_layer;
390 
391  LayerPair( &top_layer, &bottom_layer );
392 
393  wxASSERT( top_layer <= bottom_layer );
394 
395  if( top_layer <= layer_number && layer_number <= bottom_layer )
396  return true;
397  else
398  return false;
399 }
400 
401 
403 {
404  if( GetViaType() == VIATYPE::THROUGH )
405  return LSET::AllCuMask();
406 
407  // VIA_BLIND_BURIED or VIA_MICRVIA:
408 
409  LSET layermask;
410 
411  wxASSERT( m_layer <= m_bottomLayer );
412 
413  // PCB_LAYER_IDs are numbered from front to back, this is top to bottom.
414  for( LAYER_NUM id = m_layer; id <= m_bottomLayer; ++id )
415  {
416  layermask.set( id );
417  }
418 
419  return layermask;
420 }
421 
422 
423 void PCB_VIA::SetLayerSet( LSET aLayerSet )
424 {
425  bool first = true;
426 
427  for( PCB_LAYER_ID layer : aLayerSet.Seq() )
428  {
429  if( first )
430  {
431  m_layer = layer;
432  first = false;
433  }
434 
435  m_bottomLayer = layer;
436  }
437 }
438 
439 
440 void PCB_VIA::SetLayerPair( PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer )
441 {
442 
443  m_layer = aTopLayer;
444  m_bottomLayer = aBottomLayer;
445  SanitizeLayers();
446 }
447 
448 
450 {
451  m_layer = aLayer;
452 }
453 
454 
456 {
457  m_bottomLayer = aLayer;
458 }
459 
460 
461 void PCB_VIA::LayerPair( PCB_LAYER_ID* top_layer, PCB_LAYER_ID* bottom_layer ) const
462 {
463  PCB_LAYER_ID t_layer = F_Cu;
464  PCB_LAYER_ID b_layer = B_Cu;
465 
466  if( GetViaType() != VIATYPE::THROUGH )
467  {
468  b_layer = m_bottomLayer;
469  t_layer = m_layer;
470 
471  if( b_layer < t_layer )
472  std::swap( b_layer, t_layer );
473  }
474 
475  if( top_layer )
476  *top_layer = t_layer;
477 
478  if( bottom_layer )
479  *bottom_layer = b_layer;
480 }
481 
482 
484 {
485  return m_layer;
486 }
487 
488 
490 {
491  return m_bottomLayer;
492 }
493 
494 
496 {
497  if( GetViaType() == VIATYPE::THROUGH )
498  {
499  m_layer = F_Cu;
501  }
502 
503  if( m_bottomLayer < m_layer )
504  std::swap( m_bottomLayer, m_layer );
505 }
506 
507 
508 bool PCB_VIA::FlashLayer( LSET aLayers ) const
509 {
510  for( auto layer : aLayers.Seq() )
511  {
512  if( FlashLayer( layer ) )
513  return true;
514  }
515 
516  return false;
517 }
518 
519 
520 bool PCB_VIA::FlashLayer( int aLayer ) const
521 {
522  std::vector<KICAD_T> types
524 
525  // Return the "normal" shape if the caller doesn't specify a particular layer
526  if( aLayer == UNDEFINED_LAYER )
527  return true;
528 
529  BOARD* board = GetBoard();
530 
531  if( !board )
532  return false;
533 
534  if( !IsOnLayer( static_cast<PCB_LAYER_ID>( aLayer ) ) )
535  return false;
536 
538  return true;
539 
540  if( m_keepTopBottomLayer && ( aLayer == m_layer || aLayer == m_bottomLayer ) )
541  return true;
542 
543  return board->GetConnectivity()->IsConnectedOnLayer( this, static_cast<int>( aLayer ),
544  types );
545 }
546 
547 
548 void PCB_TRACK::ViewGetLayers( int aLayers[], int& aCount ) const
549 {
550  // Show the track and its netname on different layers
551  aLayers[0] = GetLayer();
552  aLayers[1] = GetNetnameLayer( aLayers[0] );
553  aCount = 2;
554 }
555 
556 
557 double PCB_TRACK::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
558 {
559  constexpr double HIDE = std::numeric_limits<double>::max();
560 
561  PCB_PAINTER* painter = static_cast<PCB_PAINTER*>( aView->GetPainter() );
562  PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
563 
564  if( !aView->IsLayerVisible( LAYER_TRACKS ) )
565  return HIDE;
566 
567  if( IsNetnameLayer( aLayer ) )
568  {
569  // Hide netnames on dimmed tracks
570  if( renderSettings->GetHighContrast() )
571  {
572  if( m_layer != renderSettings->GetPrimaryHighContrastLayer() )
573  return HIDE;
574  }
575 
576  // Netnames will be shown only if zoom is appropriate
577  return ( double ) Millimeter2iu( 4 ) / ( m_Width + 1 );
578  }
579 
580  // Other layers are shown without any conditions
581  return 0.0;
582 }
583 
584 
586 {
587  BOX2I bbox = GetBoundingBox();
588 
589  BOARD* board = GetBoard();
590 
591  if( board )
592  bbox.Inflate( 2 * board->GetDesignSettings().GetBiggestClearanceValue() );
593 
594  return bbox;
595 }
596 
597 
598 void PCB_VIA::ViewGetLayers( int aLayers[], int& aCount ) const
599 {
600  aLayers[0] = LAYER_VIA_HOLES;
601  aLayers[1] = LAYER_VIA_HOLEWALLS;
602  aLayers[2] = LAYER_VIA_NETNAMES;
603 
604  // Just show it on common via & via holes layers
605  switch( GetViaType() )
606  {
607  case VIATYPE::THROUGH: aLayers[3] = LAYER_VIA_THROUGH; break;
608  case VIATYPE::BLIND_BURIED: aLayers[3] = LAYER_VIA_BBLIND; break;
609  case VIATYPE::MICROVIA: aLayers[3] = LAYER_VIA_MICROVIA; break;
610  default: aLayers[3] = LAYER_GP_OVERLAY; break;
611  }
612 
613  aCount = 4;
614 }
615 
616 
617 double PCB_VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
618 {
619  constexpr double HIDE = (double)std::numeric_limits<double>::max();
620 
621  PCB_PAINTER* painter = static_cast<PCB_PAINTER*>( aView->GetPainter() );
622  PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
623  BOARD* board = GetBoard();
624  LSET visible = LSET::AllLayersMask();
625 
626  // Meta control for hiding all vias
627  if( !aView->IsLayerVisible( LAYER_VIAS ) )
628  return HIDE;
629 
630  // Handle board visibility
631  if( board )
632  visible = board->GetVisibleLayers() & board->GetEnabledLayers();
633 
634  if( IsViaPadLayer( aLayer ) )
635  {
636  if( !FlashLayer( visible ) )
637  return HIDE;
638  }
639  else if( IsHoleLayer( aLayer ) )
640  {
642  {
643  // Show a blind or micro via's hole if it crosses a visible layer
644  if( !( visible & GetLayerSet() ).any() )
645  return HIDE;
646  }
647  else
648  {
649  // Show a through via's hole if any physical layer is shown
650  if( !( visible & LSET::PhysicalLayersMask() ).any() )
651  return HIDE;
652  }
653  }
654  else if( IsNetnameLayer( aLayer ) )
655  {
656  if( renderSettings->GetHighContrast() )
657  {
658  // Hide netnames unless via is flashed to a high-contrast layer
659  if( !FlashLayer( renderSettings->GetPrimaryHighContrastLayer() ) )
660  return HIDE;
661  }
662  else
663  {
664  // Hide netnames unless pad is flashed to a visible layer
665  if( !FlashLayer( visible ) )
666  return HIDE;
667  }
668 
669  // Netnames will be shown only if zoom is appropriate
670  return m_Width == 0 ? HIDE : ( (double)Millimeter2iu( 10 ) / m_Width );
671  }
672 
673  // Passed all tests; show.
674  return 0.0;
675 }
676 
677 
678 // see class_track.h
679 void PCB_TRACK::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
680 {
681  EDA_UNITS units = aFrame->GetUserUnits();
682  wxString msg;
683  BOARD* board = GetBoard();
684 
685  aList.emplace_back( _( "Type" ),
686  Type() == PCB_ARC_T ? ( "Track (arc)" ) : _( "Track" ) );
687 
688 
689  GetMsgPanelInfoBase_Common( aFrame, aList );
690 
691  aList.emplace_back( _( "Layer" ), layerMaskDescribe() );
692 
693  aList.emplace_back( _( "Width" ), MessageTextFromValue( units, m_Width ) );
694 
695  if( Type() == PCB_ARC_T )
696  {
697  double radius = static_cast<PCB_ARC*>( this )->GetRadius();
698  aList.emplace_back( _( "Radius" ), MessageTextFromValue( units, radius ) );
699  }
700 
701  aList.emplace_back( _( "Segment Length" ), MessageTextFromValue( units, GetLength() ) );
702 
703  // Display full track length (in Pcbnew)
704  if( board && GetNetCode() > 0 )
705  {
706  int count;
707  double trackLen;
708  double lenPadToDie;
709 
710  std::tie( count, trackLen, lenPadToDie ) = board->GetTrackLength( *this );
711 
712  aList.emplace_back( _( "Routed Length" ), MessageTextFromValue( units, trackLen ) );
713 
714  if( lenPadToDie != 0 )
715  {
716  msg = MessageTextFromValue( units, lenPadToDie );
717  aList.emplace_back( _( "Pad To Die Length" ), msg );
718 
719  msg = MessageTextFromValue( units, trackLen + lenPadToDie );
720  aList.emplace_back( _( "Full Length" ), msg );
721  }
722  }
723 
724  wxString source;
725  int clearance = GetOwnClearance( GetLayer(), &source );
726 
727  aList.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
728  MessageTextFromValue( units, clearance ) ),
729  wxString::Format( _( "(from %s)" ), source ) );
730 
731  int minWidth, maxWidth;
732  GetWidthConstraints( &minWidth, &maxWidth, &source );
733 
734  aList.emplace_back( wxString::Format( _( "Min Width: %s" ),
735  MessageTextFromValue( units, minWidth ) ),
736  wxString::Format( _( "(from %s)" ), source ) );
737 }
738 
739 
740 void PCB_VIA::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
741 {
742  EDA_UNITS units = aFrame->GetUserUnits();
743  wxString msg;
744 
745  switch( GetViaType() )
746  {
747  case VIATYPE::MICROVIA: msg = _( "Micro Via" ); break;
748  case VIATYPE::BLIND_BURIED: msg = _( "Blind/Buried Via" ); break;
749  case VIATYPE::THROUGH: msg = _( "Through Via" ); break;
750  default: msg = _( "Via" ); break;
751  }
752 
753  aList.emplace_back( _( "Type" ), msg );
754 
755  GetMsgPanelInfoBase_Common( aFrame, aList );
756 
757  aList.emplace_back( _( "Layer" ), layerMaskDescribe() );
758 
759  msg = MessageTextFromValue( aFrame->GetUserUnits(), m_Width );
760 
761  aList.emplace_back( _( "Diameter" ), msg );
762 
763  msg = MessageTextFromValue( aFrame->GetUserUnits(), GetDrillValue() );
764 
765  aList.emplace_back( _( "Drill" ), msg );
766 
767  wxString source;
768  int clearance = GetOwnClearance( GetLayer(), &source );
769 
770  aList.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
771  MessageTextFromValue( units, clearance ) ),
772  wxString::Format( _( "(from %s)" ), source ) );
773 
774  int minAnnulus = GetMinAnnulus( GetLayer(), &source );
775 
776  aList.emplace_back( wxString::Format( _( "Min Annular Width: %s" ),
777  MessageTextFromValue( units, minAnnulus ) ),
778  wxString::Format( _( "(from %s)" ), source ) );
779 }
780 
781 
783  std::vector<MSG_PANEL_ITEM>& aList ) const
784 {
785  wxString msg;
786 
787  aList.emplace_back( _( "Net" ), UnescapeString( GetNetname() ) );
788 
789  aList.emplace_back( _( "NetClass" ), UnescapeString( GetNetClass()->GetName() ) );
790 
791  #if 0 // Enable for debugging
792  if( GetBoard() )
793  {
794  // Display net code:
795  msg.Printf( wxT( "%d" ), GetNetCode() );
796  aList.emplace_back( _( "NetCode" ), msg );
797  }
798 
799  // Display the flags:
800  msg.Printf( wxT( "0x%08X" ), m_flags );
801  aList.emplace_back( wxT( "Flags" ), msg );
802 
803  // Display start and end positions:
804  msg.Printf( wxT( "%d %d" ), m_Start.x, m_Start.y );
805  aList.push_back( MSG_PANEL_ITEM( wxT( "Start pos" ), msg ) );
806  msg.Printf( wxT( "%d %d" ), m_End.x, m_End.y );
807  aList.push_back( MSG_PANEL_ITEM( wxT( "End pos" ), msg ) );
808 #endif
809 
810  // Display the State member
811  aList.emplace_back( _( "Status" ), IsLocked() ? _( "Locked" ) : wxT( "" ) );
812 }
813 
814 
816 {
817  BOARD* board = GetBoard();
818  PCB_LAYER_ID top_layer;
819  PCB_LAYER_ID bottom_layer;
820 
821  LayerPair( &top_layer, &bottom_layer );
822 
823  return board->GetLayerName( top_layer ) + wxT( " - " ) + board->GetLayerName( bottom_layer );
824 }
825 
826 
827 bool PCB_TRACK::HitTest( const wxPoint& aPosition, int aAccuracy ) const
828 {
829  return TestSegmentHit( aPosition, m_Start, m_End, aAccuracy + ( m_Width / 2 ) );
830 }
831 
832 
833 bool PCB_ARC::HitTest( const wxPoint& aPosition, int aAccuracy ) const
834 {
835  int max_dist = aAccuracy + ( m_Width / 2 );
836 
837  // Short-circuit common cases where the arc is connected to a track or via at an endpoint
838  if( EuclideanNorm( GetStart() - aPosition ) <= max_dist ||
839  EuclideanNorm( GetEnd() - aPosition ) <= max_dist )
840  {
841  return true;
842  }
843 
844  wxPoint center = GetPosition();
845  wxPoint relpos = aPosition - center;
846  double dist = EuclideanNorm( relpos );
847  double radius = GetRadius();
848 
849  if( std::abs( dist - radius ) > max_dist )
850  return false;
851 
852  double arc_angle_start = GetArcAngleStart(); // Always 0.0 ... 360 deg, in 0.1 deg
853  double arc_hittest = ArcTangente( relpos.y, relpos.x );
854 
855  // Calculate relative angle between the starting point of the arc, and the test point
856  arc_hittest -= arc_angle_start;
857 
858  // Normalise arc_hittest between 0 ... 360 deg
859  NORMALIZE_ANGLE_POS( arc_hittest );
860  double arc_angle = GetAngle();
861 
862  if( arc_angle < 0 )
863  return arc_hittest >= 3600 + arc_angle;
864 
865  return arc_hittest <= arc_angle;
866 }
867 
868 
869 bool PCB_VIA::HitTest( const wxPoint& aPosition, int aAccuracy ) const
870 {
871  int max_dist = aAccuracy + ( m_Width / 2 );
872 
873  // rel_pos is aPosition relative to m_Start (or the center of the via)
874  wxPoint rel_pos = aPosition - m_Start;
875  double dist = (double) rel_pos.x * rel_pos.x + (double) rel_pos.y * rel_pos.y;
876  return dist <= (double) max_dist * max_dist;
877 }
878 
879 
880 bool PCB_TRACK::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
881 {
882  EDA_RECT arect = aRect;
883  arect.Inflate( aAccuracy );
884 
885  if( aContained )
886  return arect.Contains( GetStart() ) && arect.Contains( GetEnd() );
887  else
888  return arect.Intersects( GetStart(), GetEnd() );
889 }
890 
891 
892 bool PCB_ARC::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
893 {
894  EDA_RECT box;
895  EDA_RECT arect = aRect;
896  arect.Inflate( aAccuracy );
897 
898  box.SetOrigin( GetStart() );
899  box.Merge( GetMid() );
900  box.Merge( GetEnd() );
901 
902  box.Inflate( GetWidth() / 2 );
903 
904  if( aContained )
905  return arect.Contains( box );
906  else
907  return arect.Intersects( box );
908 }
909 
910 
911 bool PCB_VIA::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
912 {
913  EDA_RECT box;
914  EDA_RECT arect = aRect;
915  arect.Inflate( aAccuracy );
916 
917  box.SetOrigin( GetStart() );
918  box.Inflate( GetWidth() / 2 );
919 
920  if( aContained )
921  return arect.Contains( box );
922  else
923  return arect.IntersectsCircle( GetStart(), GetWidth() / 2 );
924 }
925 
926 
927 wxString PCB_TRACK::GetSelectMenuText( EDA_UNITS aUnits ) const
928 {
929  return wxString::Format( Type() == PCB_ARC_T ? _("Track (arc) %s on %s, length %s" )
930  : _("Track %s on %s, length %s" ),
931  GetNetnameMsg(),
932  GetLayerName(),
933  MessageTextFromValue( aUnits, GetLength() ) );
934 }
935 
936 
938 {
939  return BITMAPS::add_tracks;
940 }
941 
943 {
944  assert( aImage->Type() == PCB_TRACE_T );
945 
946  std::swap( *((PCB_TRACK*) this), *((PCB_TRACK*) aImage) );
947 }
948 
950 {
951  assert( aImage->Type() == PCB_ARC_T );
952 
953  std::swap( *this, *static_cast<PCB_ARC*>( aImage ) );
954 }
955 
957 {
958  assert( aImage->Type() == PCB_VIA_T );
959 
960  std::swap( *((PCB_VIA*) this), *((PCB_VIA*) aImage) );
961 }
962 
963 
964 wxPoint PCB_ARC::GetPosition() const
965 {
966  auto center = GetArcCenter( VECTOR2I( m_Start ), VECTOR2I( m_Mid ), VECTOR2I( m_End ) );
967  return wxPoint( center.x, center.y );
968 }
969 
970 double PCB_ARC::GetRadius() const
971 {
972  auto center = GetArcCenter( VECTOR2I( m_Start ), VECTOR2I( m_Mid ), VECTOR2I( m_End ) );
973  return GetLineLength( wxPoint( center ), m_Start );
974 }
975 
976 double PCB_ARC::GetAngle() const
977 {
978  wxPoint center = GetPosition();
979  wxPoint p0 = m_Start - center;
980  wxPoint p1 = m_Mid - center;
981  wxPoint p2 = m_End - center;
982  double angle1 = ArcTangente( p1.y, p1.x ) - ArcTangente( p0.y, p0.x );
983  double angle2 = ArcTangente( p2.y, p2.x ) - ArcTangente( p1.y, p1.x );
984 
985  return NormalizeAngle180( angle1 ) + NormalizeAngle180( angle2 );
986 }
987 
989 {
990  wxPoint center = GetPosition();
991 
992  double angleStart = ArcTangente( m_Start.y - center.y,
993  m_Start.x - center.x );
994  return NormalizeAnglePos( angleStart );
995 }
996 
998 {
999  wxPoint center = GetPosition();
1000 
1001  double angleEnd = ArcTangente( m_End.y - center.y,
1002  m_End.x - center.x );
1003  return NormalizeAnglePos( angleEnd );
1004 }
1005 
1006 
1008 {
1009  if( a->GetNetCode() != b->GetNetCode() )
1010  return a->GetNetCode() < b->GetNetCode();
1011 
1012  if( a->GetLayer() != b->GetLayer() )
1013  return a->GetLayer() < b->GetLayer();
1014 
1015  if( a->Type() != b->Type() )
1016  return a->Type() < b->Type();
1017 
1018  if( a->m_Uuid != b->m_Uuid )
1019  return a->m_Uuid < b->m_Uuid;
1020 
1021  return a < b;
1022 }
1023 
1024 
1025 std::shared_ptr<SHAPE> PCB_TRACK::GetEffectiveShape( PCB_LAYER_ID aLayer ) const
1026 {
1027  return std::make_shared<SHAPE_SEGMENT>( m_Start, m_End, m_Width );
1028 }
1029 
1030 
1031 std::shared_ptr<SHAPE> PCB_VIA::GetEffectiveShape( PCB_LAYER_ID aLayer ) const
1032 {
1033  if( FlashLayer( aLayer ) )
1034  return std::make_shared<SHAPE_CIRCLE>( m_Start, m_Width / 2 );
1035  else
1036  return std::make_shared<SHAPE_CIRCLE>( m_Start, GetDrillValue() / 2 );
1037 }
1038 
1039 
1040 std::shared_ptr<SHAPE> PCB_ARC::GetEffectiveShape( PCB_LAYER_ID aLayer ) const
1041 {
1042  return std::make_shared<SHAPE_ARC>( GetStart(), GetMid(), GetEnd(), GetWidth() );
1043 }
1044 
1045 
1046 
1047 #if defined(DEBUG)
1048 
1049 wxString PCB_TRACK::ShowState( int stateBits )
1050 {
1051  wxString ret;
1052 
1053  if( stateBits & IS_LINKED )
1054  ret << wxT( " | IS_LINKED" );
1055 
1056  if( stateBits & LOCKED )
1057  ret << wxT( " | LOCKED" );
1058 
1059  if( stateBits & IN_EDIT )
1060  ret << wxT( " | IN_EDIT" );
1061 
1062  if( stateBits & IS_DRAGGING )
1063  ret << wxT( " | IS_DRAGGING" );
1064 
1065  if( stateBits & DO_NOT_DRAW )
1066  ret << wxT( " | DO_NOT_DRAW" );
1067 
1068  if( stateBits & IS_DELETED )
1069  ret << wxT( " | IS_DELETED" );
1070 
1071  if( stateBits & END_ONPAD )
1072  ret << wxT( " | END_ONPAD" );
1073 
1074  if( stateBits & BEGIN_ONPAD )
1075  ret << wxT( " | BEGIN_ONPAD" );
1076 
1077  return ret;
1078 }
1079 
1080 #endif
1081 
1082 
1083 static struct TRACK_VIA_DESC
1084 {
1086  {
1088  .Undefined( VIATYPE::NOT_DEFINED )
1089  .Map( VIATYPE::THROUGH, _HKI( "Through" ) )
1090  .Map( VIATYPE::BLIND_BURIED, _HKI( "Blind/buried" ) )
1091  .Map( VIATYPE::MICROVIA, _HKI( "Micro" ) );
1092 
1094 
1095  if( layerEnum.Choices().GetCount() == 0 )
1096  {
1097  layerEnum.Undefined( UNDEFINED_LAYER );
1098 
1099  for( LSEQ seq = LSET::AllLayersMask().Seq(); seq; ++seq )
1100  layerEnum.Map( *seq, LSET::Name( *seq ) );
1101  }
1102 
1104 
1105  // Track
1108 
1109  propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "Width" ),
1111  propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position X" ),
1112  new PROPERTY<PCB_TRACK, int, BOARD_ITEM>( _HKI( "Origin X" ),
1114  propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position Y" ),
1115  new PROPERTY<PCB_TRACK, int, BOARD_ITEM>( _HKI( "Origin Y" ),
1117  propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "End X" ),
1119  propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "End Y" ),
1121 
1122  // Arc
1125 
1126  propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "Width" ),
1128  propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position X" ),
1129  new PROPERTY<PCB_ARC, int, BOARD_ITEM>( _HKI( "Origin X" ),
1131  propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position Y" ),
1132  new PROPERTY<PCB_ARC, int, BOARD_ITEM>( _HKI( "Origin Y" ),
1134  propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "End X" ),
1136  propMgr.AddProperty( new PROPERTY<PCB_TRACK, int>( _HKI( "End Y" ),
1138 
1139  // Via
1142 
1143  // TODO layerset for vias?
1144  // TODO test drill, use getdrillvalue?
1145  propMgr.ReplaceProperty( TYPE_HASH( PCB_TRACK ), _HKI( "Width" ),
1146  new PROPERTY<PCB_VIA, int, PCB_TRACK>( _HKI( "Diameter" ),
1148  propMgr.AddProperty( new PROPERTY<PCB_VIA, int>( _HKI( "Drill" ),
1150  propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Layer" ),
1153  propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, PCB_LAYER_ID>( _HKI( "Layer Bottom" ),
1155  propMgr.AddProperty( new PROPERTY_ENUM<PCB_VIA, VIATYPE>( _HKI( "Via Type" ),
1157  }
1158 } _TRACK_VIA_DESC;
1159 
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:146
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:750
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Test to see if this object is on the given layer.
Definition: pcb_track.cpp:387
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: pcb_track.cpp:96
bool operator()(const PCB_TRACK *aFirst, const PCB_TRACK *aSecond) const
Definition: pcb_track.cpp:1007
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, EDA_DATA_TYPE aType)
Convert a value to a string using double notation.
Definition: base_units.cpp:104
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_track.cpp:240
to draw micro vias
Definition: layer_ids.h:189
wxPoint m_Start
Line start point.
Definition: pcb_track.h:240
#define DO_NOT_DRAW
Used to disable draw function.
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:65
#define TYPE_HASH(x)
Definition: property.h:59
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:222
#define STARTPOINT
When a line is selected, these flags indicate which.
void Merge(const EDA_RECT &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Definition: eda_rect.cpp:432
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:360
PCB_ARC(BOARD_ITEM *aParent)
Definition: pcb_track.h:249
bool HasMin() const
Definition: minoptmax.h:37
void SetBottomLayer(PCB_LAYER_ID aLayer)
Definition: pcb_track.cpp:455
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pcb_track.cpp:345
virtual bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
Definition: pcb_track.cpp:833
bool FlashLayer(int aLayer) const
Checks to see whether the via should have a pad on the specific layer.
Definition: pcb_track.cpp:520
const wxPoint & GetEnd() const
Definition: pcb_track.h:105
virtual EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pcb_track.cpp:57
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:192
Implementation of conversion functions that require both schematic and board internal units.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
MINOPTMAX< int > & Value()
Definition: drc_rule.h:123
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: pcb_track.h:455
VIATYPE GetViaType() const
Definition: pcb_track.h:354
virtual double GetLength() const
Function GetLength returns the length of the track using the hypotenuse calculation.
Definition: pcb_track.cpp:286
ENUM_MAP & Undefined(T aValue)
Definition: property.h:523
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
Definition: pcb_track.cpp:869
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:440
virtual NETCLASS * GetNetClass() const
Return the NETCLASS for this item.
PCB_TRACK(BOARD_ITEM *aParent, KICAD_T idtype=PCB_TRACE_T)
Definition: pcb_track.cpp:50
ENUM_TO_WXANY(VIATYPE)
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Definition: lset.cpp:521
int m_drill
for vias: via drill (- 1 for default value)
Definition: pcb_track.h:506
int GetMinAnnulus(PCB_LAYER_ID aLayer, wxString *aSource) const
Definition: pcb_track.cpp:162
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pcb_track.cpp:90
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: pcb_track.cpp:927
static ENUM_MAP< T > & Instance()
Definition: property.h:510
#define IS_DRAGGING
Item being dragged.
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
Definition: board.cpp:479
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
bool IntersectsCircle(const wxPoint &aCenter, const int aRadius) const
Test for a common area between a circle and this rectangle.
Definition: eda_rect.cpp:315
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: pcb_track.cpp:1031
int LAYER_NUM
This can be replaced with int and removed.
Definition: layer_ids.h:40
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:121
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pcb_track.cpp:402
class PAD, a pad in a footprint
Definition: typeinfo.h:89
std::uint32_t EDA_ITEM_FLAGS
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:465
int GetWidth() const
Definition: pcb_track.h:102
#define ENDPOINT
ends. (Used to support dragging.)
T Min() const
Definition: minoptmax.h:33
EDA_ITEM_FLAGS m_flags
Definition: eda_item.h:481
wxPGChoices & Choices()
Definition: property.h:559
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:290
VIATYPE m_viaType
through, blind/buried or micro
Definition: pcb_track.h:504
The base class for create windows for drawing purpose.
void GetMsgPanelInfoBase_Common(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) const
Definition: pcb_track.cpp:782
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
PCB_LAYER_ID BottomLayer() const
Definition: pcb_track.cpp:489
virtual bool IsLocked() const
Definition: board_item.cpp:65
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
Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:241
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:588
#define REGISTER_TYPE(x)
Definition: property_mgr.h:248
T Max() const
Definition: minoptmax.h:34
void SetEndY(int aY)
Definition: pcb_track.h:111
bool Contains(const wxPoint &aPoint) const
Definition: eda_rect.cpp:57
to draw via holes (pad holes do not use this layer)
Definition: layer_ids.h:210
const INSPECTOR_FUNC & INSPECTOR
Definition: eda_item.h:94
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
wxString GetName() const
Definition: drc_rule.h:128
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:207
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
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:679
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
Definition: pcb_track.cpp:956
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:598
wxPoint m_End
Line end point.
Definition: pcb_track.h:241
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
Definition: layer_ids.h:932
Classes used in Pcbnew, CvPcb and GerbView.
to draw usual through hole vias
Definition: layer_ids.h:191
T NormalizeAngle180(T Angle)
Normalize angle to be in the -180.0 .. 180.0 range.
Definition: trigo.h:387
PCB specific render settings.
Definition: pcb_painter.h:64
int GetEndY() const
Definition: pcb_track.h:114
double GetArcAngleEnd() const
Definition: pcb_track.cpp:997
virtual wxString layerMaskDescribe() const
Return a string (to be shown to the user) describing a layer mask.
Definition: board_item.cpp:86
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pcb_track.cpp:937
bool IsHoleLayer(LAYER_NUM aLayer)
Definition: layer_ids.h:826
Display value expressed in distance units (mm/inch)
Definition: property.h:53
PCB_LAYER_ID TopLayer() const
Definition: pcb_track.cpp:483
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:502
bool ApproxCollinear(const PCB_TRACK &aTrack)
Definition: pcb_track.cpp:119
#define IS_DELETED
int GetY() const
Definition: board_item.h:101
int GetLocalClearance(wxString *aSource) const override
Function GetLocalClearance returns any local clearance overrides set in the "classic" (ie: pre-rule) ...
Definition: pcb_track.cpp:127
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pcb_track.cpp:72
void SetDrillDefault()
Function SetDrillDefault sets the drill value for vias to the default value UNDEFINED_DRILL_DIAMETER.
Definition: pcb_track.h:476
Meta control for all vias opacity/visibility.
Definition: layer_ids.h:188
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:247
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition: lset.cpp:82
double GetArcAngleStart() const
Definition: pcb_track.cpp:988
double GetRadius() const
Definition: pcb_track.cpp:970
const VECTOR2I & GetP0() const
Definition: shape_arc.h:111
virtual wxPoint GetPosition() const override
Definition: pcb_track.cpp:964
A collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:46
bool m_keepTopBottomLayer
Keep the top and bottom annular rings.
Definition: pcb_track.h:509
virtual BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:51
bool TestSegmentHit(const wxPoint &aRefPoint, const wxPoint &aStart, const wxPoint &aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
Definition: trigo.cpp:129
virtual void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate this object.
Definition: pcb_track.cpp:299
int GetViaDrill() const
Definition: netclass.h:136
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:344
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declare an inheritance relationship between types.
const VECTOR2I & GetArcMid() const
Definition: shape_arc.h:113
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: pcb_track.cpp:1025
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:461
#define LOCKED
Pcbnew: locked from movement and deletion.
void SetY(int aY)
Definition: board_item.h:123
bool ApproxCollinear(const SEG &aSeg) const
Definition: seg.h:279
#define _(s)
static LSET AllLayersMask()
Definition: lset.cpp:787
static struct TRACK_VIA_DESC _TRACK_VIA_DESC
class ZONE, a copper pour area
Definition: typeinfo.h:105
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
Definition: pcb_track.cpp:827
void SetViaType(VIATYPE aViaType)
Definition: pcb_track.h:355
bool m_removeUnconnectedLayer
Remove unconnected copper on a via.
Definition: pcb_track.h:508
void SetX(int aX)
Definition: board_item.h:117
virtual void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pcb_track.cpp:325
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pcb_track.cpp:113
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:463
virtual void SetLayerSet(LSET aLayers) override
Definition: pcb_track.cpp:423
void SetTopLayer(PCB_LAYER_ID aLayer)
Definition: pcb_track.cpp:449
wxString UnescapeString(const wxString &aSource)
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:740
wxString GetNetnameMsg() const
const KIID m_Uuid
Definition: eda_item.h:475
Some functions to handle hotkeys in KiCad.
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
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: pcb_track.cpp:1040
Definition: seg.h:40
EDA_UNITS
Definition: eda_units.h:38
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: pcb_track.cpp:585
static LSET PhysicalLayersMask()
Return a mask holding all layers which are physically realized.
Definition: lset.cpp:849
void SetWidth(int aWidth)
Definition: pcb_track.h:101
SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[]) 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:372
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pcb_track.cpp:307
#define BEGIN_ONPAD
Pcbnew: flag set for track segment starting on a pad.
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:281
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
Definition: pcb_track.cpp:942
int m_Width
Thickness of track, or via diameter.
Definition: pcb_track.h:239
PCB_LAYER_ID m_bottomLayer
The bottom layer of the via (the top layer is in m_layer)
Definition: pcb_track.h:502
VIATYPE
Definition: pcb_track.h:60
double GetAngle() const
Definition: pcb_track.cpp:976
bool HasMax() const
Definition: minoptmax.h:38
int GetX() const
Definition: board_item.h:95
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pcb_track.cpp:617
to draw blind/buried vias
Definition: layer_ids.h:190
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: pcb_track.cpp:557
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
int GetEndX() const
Definition: pcb_track.h:113
general purpose overlay
Definition: layer_ids.h:213
bool IsNetnameLayer(LAYER_NUM aLayer)
Test whether a layer is a netname layer.
Definition: layer_ids.h:955
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:64
EDA_ITEM_FLAGS IsPointOnEnds(const wxPoint &point, int min_dist=0) const
Function IsPointOnEnds returns STARTPOINT if point if near (dist = min_dist) start point,...
Definition: pcb_track.cpp:208
T NormalizeAnglePos(T Angle)
Normalize angle to be in the 0.0 .. 360.0 range: angle is in 1/10 degrees.
Definition: trigo.h:281
Definition: layer_ids.h:70
void AddProperty(PROPERTY_BASE *aProperty)
Register a property.
int GetCopperLayerCount() const
Definition: board.cpp:453
bool IsViaPadLayer(LAYER_NUM aLayer)
Definition: layer_ids.h:819
class ZONE, managed by a footprint
Definition: typeinfo.h:94
Handle the component boundary box.
Definition: eda_rect.h:42
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:73
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
virtual int GetOwnClearance(PCB_LAYER_ID aLayer, wxString *aSource=nullptr) const
Return an item's "own" clearance in internal units.
bool Intersects(const EDA_RECT &aRect) const
Test for a common area between rectangles.
Definition: eda_rect.cpp:150
PCB_LAYER_ID m_layer
Definition: board_item.h:352
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
Definition: pcb_track.cpp:949
void ReplaceProperty(size_t aBase, const wxString &aName, PROPERTY_BASE *aNew)
Replace an existing property for a specific type.
int GetuViaDrill() const
Definition: netclass.h:144
Provide class metadata.Helper macro to map type hashes to names.
Definition: property_mgr.h:62
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
Definition: pcb_track.cpp:193
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
#define IN_EDIT
Item currently edited.
void GetWidthConstraints(int *aMin, int *aMax, wxString *aSource) const
Definition: pcb_track.cpp:134
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:548
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:183
EDA_MSG_PANEL items for displaying messages.
Definition: msgpanel.h:53
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
const VECTOR2I GetArcCenter(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:454
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:516
void SanitizeLayers()
Function SanitizeLayers Check so that the layers are correct dependin on the type of via,...
Definition: pcb_track.cpp:495
void SetEndX(int aX)
Definition: pcb_track.h:110
SEARCH_RESULT
Definition: eda_item.h:41
#define END_ONPAD
Pcbnew: flag set for track segment ending on a pad.
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
Definition: board_item.cpp:74
static constexpr int Millimeter2iu(double mm)
#define _HKI(x)
wxPoint m_Mid
Arc mid point, halfway between start and end.
Definition: pcb_track.h:320
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:171
const wxPoint & GetMid() const
Definition: pcb_track.h:273
const VECTOR2I & GetP1() const
Definition: shape_arc.h:112
bool m_isFree
"Free" vias don't get their nets auto-updated
Definition: pcb_track.h:510
std::shared_ptr< DRC_ENGINE > m_DRCEngine
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate this object.
Definition: pcb_track.cpp:292
const wxPoint & GetStart() const
Definition: pcb_track.h:108
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364
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:1658
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
Container for design settings for a BOARD object.
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
Definition: view.h:404
PCB_VIA(BOARD_ITEM *aParent)
Definition: pcb_track.cpp:78
wxString layerMaskDescribe() const override
Return a string (to be shown to the user) describing a layer mask.
Definition: pcb_track.cpp:815