KiCad PCB EDA Suite
class_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, jean-pierre.charras@ujf-grenoble.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
7  * Copyright (C) 1992-2019 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 <fctsys.h>
28 #include <pcb_base_frame.h>
29 #include <class_board.h>
30 #include <class_track.h>
31 #include <base_units.h>
32 #include <bitmaps.h>
33 #include <view/view.h>
36 
37 
38 TRACK::TRACK( BOARD_ITEM* aParent, KICAD_T idtype ) :
39  BOARD_CONNECTED_ITEM( aParent, idtype )
40 {
41  m_Width = Millimeter2iu( 0.2 ); // Gives a reasonable default width
42 }
43 
44 
46 {
47  return new TRACK( *this );
48 }
49 
50 
52 {
53  return new ARC( *this );
54 }
55 
56 
57 VIA::VIA( BOARD_ITEM* aParent ) :
58  TRACK( aParent, PCB_VIA_T )
59 {
63 }
64 
65 
67 {
68  return new VIA( *this );
69 }
70 
71 
72 wxString VIA::GetSelectMenuText( EDA_UNITS aUnits ) const
73 {
74  wxString format;
75  BOARD* board = GetBoard();
76 
77  switch( GetViaType() )
78  {
80  format = _( "Blind/Buried Via %s %s on %s - %s" );
81  break;
82  case VIATYPE::MICROVIA:
83  format = _( "Micro Via %s %s on %s - %s" );
84  break;
85  // else say nothing about normal (through) vias
86  default:
87  format = _( "Via %s %s on %s - %s" );
88  break;
89  }
90 
91  if( board )
92  {
93  // say which layers, only two for now
94  PCB_LAYER_ID topLayer;
95  PCB_LAYER_ID botLayer;
96  LayerPair( &topLayer, &botLayer );
97  return wxString::Format( format.GetData(), MessageTextFromValue( aUnits, m_Width ),
98  GetNetnameMsg(), board->GetLayerName( topLayer ), board->GetLayerName( botLayer ) );
99  }
100  else
101  {
102  return wxString::Format( format.GetData(), MessageTextFromValue( aUnits, m_Width ),
103  GetNetnameMsg(), wxT( "??" ), wxT( "??" ) );
104  }
105 }
106 
107 
109 {
110  return via_xpm;
111 }
112 
113 
114 int TRACK::GetLocalClearance( wxString* aSource ) const
115 {
116  // Not currently implemented
117  return 0;
118 }
119 
120 
121 /*
122  * Width constraints exist in a hiearchy. If a given level is specified then the remaining
123  * levels are NOT consulted.
124  *
125  * LEVEL 1: (highest priority) local overrides (not currently implemented.)
126  * LEVEL 2: Rules
127  * LEVEL 3: Accumulated local settings, netclass settings, & board design settings
128  */
129 void TRACK::GetWidthConstraints( int* aMin, int* aMax, wxString* aSource ) const
130 {
131  // LEVEL 1: local overrides
132  //
133  // Not currently implemented
134 
135  // LEVEL 2: Rules
136  DRC_RULE* rule = GetRule( this, nullptr, TRACK_CONSTRAINT );
137 
138  if( rule )
139  {
140  *aMin = rule->m_TrackConstraint.Min;
141  *aMax = rule->m_TrackConstraint.Max;
142 
143  if( aSource )
144  *aSource = wxString::Format( _( "'%s' rule" ), rule->m_Name );
145 
146  return;
147  }
148 
149  // LEVEL 3: Netclasses & board design settings
150  //
151  // Note that local settings aren't currently implemented, and netclasses don't contain a
152  // minimum width (only a default width), so only the board design settings are relevant
153  // here.
154  //
156  *aMax = INT_MAX / 2;
157 
158  if( aSource )
159  *aSource = _( "board minimum" );
160 }
161 
162 
163 int VIA::GetMinAnnulus( wxString* aSource ) const
164 {
165  DRC_RULE* rule = GetRule( this, nullptr, ANNULUS_CONSTRAINT );
166 
167  if( rule )
168  {
169  if( aSource )
170  *aSource = wxString::Format( _( "'%s' rule" ), rule->m_Name );
171 
172  return rule->m_MinAnnulusWidth;
173  }
174  else
175  {
176  if( aSource )
177  *aSource = _( "board minimum" );
178 
180  }
181 }
182 
183 
185 {
186  if( m_Drill > 0 ) // Use the specific value.
187  return m_Drill;
188 
189  // Use the default value from the Netclass
190  NETCLASS* netclass = GetNetClass();
191 
192  if( GetViaType() == VIATYPE::MICROVIA )
193  return netclass->GetuViaDrill();
194 
195  return netclass->GetViaDrill();
196 }
197 
198 
199 STATUS_FLAGS TRACK::IsPointOnEnds( const wxPoint& point, int min_dist ) const
200 {
201  STATUS_FLAGS result = 0;
202 
203  if( min_dist < 0 )
204  min_dist = m_Width / 2;
205 
206  if( min_dist == 0 )
207  {
208  if( m_Start == point )
209  result |= STARTPOINT;
210 
211  if( m_End == point )
212  result |= ENDPOINT;
213  }
214  else
215  {
216  double dist = GetLineLength( m_Start, point );
217 
218  if( min_dist >= KiROUND( dist ) )
219  result |= STARTPOINT;
220 
221  dist = GetLineLength( m_End, point );
222 
223  if( min_dist >= KiROUND( dist ) )
224  result |= ENDPOINT;
225  }
226 
227  return result;
228 }
229 
230 
232 {
233  // end of track is round, this is its radius, rounded up
234  int radius = ( m_Width + 1 ) / 2;
235  int ymax, xmax, ymin, xmin;
236 
237  if( Type() == PCB_VIA_T )
238  {
239  ymax = m_Start.y;
240  xmax = m_Start.x;
241 
242  ymin = m_Start.y;
243  xmin = m_Start.x;
244  }
245  else
246  {
247  ymax = std::max( m_Start.y, m_End.y );
248  xmax = std::max( m_Start.x, m_End.x );
249 
250  ymin = std::min( m_Start.y, m_End.y );
251  xmin = std::min( m_Start.x, m_End.x );
252  }
253 
254  ymax += radius;
255  xmax += radius;
256 
257  ymin -= radius;
258  xmin -= radius;
259 
260  // return a rectangle which is [pos,dim) in nature. therefore the +1
261  EDA_RECT ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
262 
263  return ret;
264 }
265 
266 
267 void TRACK::Rotate( const wxPoint& aRotCentre, double aAngle )
268 {
269  RotatePoint( &m_Start, aRotCentre, aAngle );
270  RotatePoint( &m_End, aRotCentre, aAngle );
271 }
272 
273 
274 void ARC::Rotate( const wxPoint& aRotCentre, double aAngle )
275 {
276  RotatePoint( &m_Start, aRotCentre, aAngle );
277  RotatePoint( &m_End, aRotCentre, aAngle );
278  RotatePoint( &m_Mid, aRotCentre, aAngle );
279 }
280 
281 
282 void TRACK::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
283 {
284  if( aFlipLeftRight )
285  {
286  m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
287  m_End.x = aCentre.x - ( m_End.x - aCentre.x );
288  }
289  else
290  {
291  m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
292  m_End.y = aCentre.y - ( m_End.y - aCentre.y );
293  }
294 
295  int copperLayerCount = GetBoard()->GetCopperLayerCount();
296  SetLayer( FlipLayer( GetLayer(), copperLayerCount ) );
297 }
298 
299 
300 void ARC::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
301 {
302  if( aFlipLeftRight )
303  {
304  m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
305  m_End.x = aCentre.x - ( m_End.x - aCentre.x );
306  m_Mid.x = aCentre.x - ( m_Mid.x - aCentre.x );
307  }
308  else
309  {
310  m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
311  m_End.y = aCentre.y - ( m_End.y - aCentre.y );
312  m_Mid.y = aCentre.y - ( m_Mid.y - aCentre.y );
313  }
314 
315  int copperLayerCount = GetBoard()->GetCopperLayerCount();
316  SetLayer( FlipLayer( GetLayer(), copperLayerCount ) );
317 }
318 
319 
320 void VIA::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
321 {
322  if( aFlipLeftRight )
323  {
324  m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
325  m_End.x = aCentre.x - ( m_End.x - aCentre.x );
326  }
327  else
328  {
329  m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
330  m_End.y = aCentre.y - ( m_End.y - aCentre.y );
331  }
332 
333  if( GetViaType() != VIATYPE::THROUGH )
334  {
335  int copperLayerCount = GetBoard()->GetCopperLayerCount();
336  PCB_LAYER_ID top_layer;
337  PCB_LAYER_ID bottom_layer;
338  LayerPair( &top_layer, &bottom_layer );
339  top_layer = FlipLayer( top_layer, copperLayerCount );
340  bottom_layer = FlipLayer( bottom_layer, copperLayerCount );
341  SetLayerPair( top_layer, bottom_layer );
342  }
343 }
344 
345 
346 // see class_track.h
347 SEARCH_RESULT TRACK::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
348 {
349  KICAD_T stype = *scanTypes;
350 
351  // If caller wants to inspect my type
352  if( stype == Type() )
353  {
354  if( SEARCH_RESULT::QUIT == inspector( this, testData ) )
355  return SEARCH_RESULT::QUIT;
356  }
357 
359 }
360 
361 
362 bool VIA::IsOnLayer( PCB_LAYER_ID layer_number ) const
363 {
364  PCB_LAYER_ID bottom_layer, top_layer;
365 
366  LayerPair( &top_layer, &bottom_layer );
367 
368  wxASSERT( top_layer <= bottom_layer );
369 
370  if( top_layer <= layer_number && layer_number <= bottom_layer )
371  return true;
372  else
373  return false;
374 }
375 
376 
378 {
379  if( GetViaType() == VIATYPE::THROUGH )
380  return LSET::AllCuMask();
381 
382  // VIA_BLIND_BURIED or VIA_MICRVIA:
383 
384  LSET layermask;
385 
386  wxASSERT( m_Layer <= m_BottomLayer );
387 
388  // PCB_LAYER_IDs are numbered from front to back, this is top to bottom.
389  for( LAYER_NUM id = m_Layer; id <= m_BottomLayer; ++id )
390  {
391  layermask.set( id );
392  }
393 
394  return layermask;
395 }
396 
397 
398 void VIA::SetLayerPair( PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer )
399 {
400 
401  m_Layer = aTopLayer;
402  m_BottomLayer = aBottomLayer;
403  SanitizeLayers();
404 }
405 
406 
408 {
409  m_Layer = aLayer;
410 }
411 
412 
414 {
415  m_BottomLayer = aLayer;
416 }
417 
418 
419 void VIA::LayerPair( PCB_LAYER_ID* top_layer, PCB_LAYER_ID* bottom_layer ) const
420 {
421  PCB_LAYER_ID t_layer = F_Cu;
422  PCB_LAYER_ID b_layer = B_Cu;
423 
424  if( GetViaType() != VIATYPE::THROUGH )
425  {
426  b_layer = m_BottomLayer;
427  t_layer = m_Layer;
428 
429  if( b_layer < t_layer )
430  std::swap( b_layer, t_layer );
431  }
432 
433  if( top_layer )
434  *top_layer = t_layer;
435 
436  if( bottom_layer )
437  *bottom_layer = b_layer;
438 }
439 
440 
442 {
443  return m_Layer;
444 }
445 
446 
448 {
449  return m_BottomLayer;
450 }
451 
452 
454 {
455  if( GetViaType() == VIATYPE::THROUGH )
456  {
457  m_Layer = F_Cu;
459  }
460 
461  if( m_BottomLayer < m_Layer )
462  std::swap( m_BottomLayer, m_Layer );
463 }
464 
465 
466 void TRACK::ViewGetLayers( int aLayers[], int& aCount ) const
467 {
468  // Show the track and its netname on different layers
469  aLayers[0] = GetLayer();
470  aLayers[1] = GetNetnameLayer( aLayers[0] );
471  aCount = 2;
472 }
473 
474 
475 unsigned int TRACK::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
476 {
477  const int HIDE = std::numeric_limits<unsigned int>::max();
478 
479  if( !aView->IsLayerVisible( LAYER_TRACKS ) )
480  return HIDE;
481 
482  // Netnames will be shown only if zoom is appropriate
483  if( IsNetnameLayer( aLayer ) )
484  {
485  return ( Millimeter2iu( 4 ) / ( m_Width + 1 ) );
486  }
487 
488  // Other layers are shown without any conditions
489  return 0;
490 }
491 
492 
493 const BOX2I TRACK::ViewBBox() const
494 {
495  BOX2I bbox = GetBoundingBox();
496  bbox.Inflate( 2 * GetClearance() );
497  return bbox;
498 }
499 
500 
501 void VIA::ViewGetLayers( int aLayers[], int& aCount ) const
502 {
503  aLayers[0] = LAYER_VIAS_HOLES;
504  aLayers[1] = LAYER_VIAS_NETNAMES;
505  aCount = 3;
506 
507  // Just show it on common via & via holes layers
508  switch( GetViaType() )
509  {
510  case VIATYPE::THROUGH:
511  aLayers[2] = LAYER_VIA_THROUGH;
512  break;
513 
515  aLayers[2] = LAYER_VIA_BBLIND;
516  aLayers[3] = m_Layer;
517  aLayers[4] = m_BottomLayer;
518  aCount += 2;
519  break;
520 
521  case VIATYPE::MICROVIA:
522  aLayers[2] = LAYER_VIA_MICROVIA;
523  aLayers[3] = m_Layer;
524  aLayers[4] = m_BottomLayer;
525  aCount += 2;
526  break;
527 
528  default:
529  aLayers[2] = LAYER_GP_OVERLAY;
530  wxASSERT( false );
531  break;
532  }
533 }
534 
535 
536 unsigned int VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
537 {
538  constexpr unsigned int HIDE = std::numeric_limits<unsigned int>::max();
539 
540  // Netnames will be shown only if zoom is appropriate
541  if( IsNetnameLayer( aLayer ) )
542  return m_Width == 0 ? HIDE : ( Millimeter2iu( 10 ) / m_Width );
543 
544  LSET visibleLayers;
545 
546  for( int i = 0; i < PCB_LAYER_ID_COUNT; ++i )
547  {
548  if( aView->IsLayerVisible( i ) )
549  visibleLayers.set( i );
550  }
551 
552  // Only draw the via if at least one of the layers it crosses is being displayed
553  if( ( visibleLayers & GetLayerSet() ).any() && aView->IsLayerVisible( LAYER_VIAS ) )
554  {
555  switch( m_ViaType )
556  {
557  case VIATYPE::THROUGH: return aView->IsLayerVisible( LAYER_VIA_THROUGH ) ? 0 : HIDE;
558  case VIATYPE::BLIND_BURIED: return aView->IsLayerVisible( LAYER_VIA_BBLIND ) ? 0 : HIDE;
559  case VIATYPE::MICROVIA: return aView->IsLayerVisible( LAYER_VIA_MICROVIA ) ? 0 : HIDE;
560  default: return 0;
561  }
562  }
563 
564  return HIDE;
565 }
566 
567 
568 // see class_track.h
569 void TRACK::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
570 {
571  EDA_UNITS units = aFrame->GetUserUnits();
572  wxString msg;
573  wxString msg2;
574  wxString source;
575  BOARD* board = GetBoard();
576 
577  // Display basic infos
578  aList.emplace_back( _( "Type" ), _( "Track" ), DARKCYAN );
579 
580  GetMsgPanelInfoBase_Common( aFrame, aList );
581 
582  // Display layer
583  if( board )
584  msg = board->GetLayerName( m_Layer );
585  else
586  msg.Printf(wxT("%d"), m_Layer );
587 
588  // Display width
589  msg = MessageTextFromValue( aFrame->GetUserUnits(), m_Width, true );
590 
591  aList.emplace_back( _( "Width" ), msg, DARKCYAN );
592 
593  // Display full track length (in Pcbnew)
594  if( board )
595  {
596  int count;
597  double trackLen;
598  double lenPadToDie;
599 
600  std::tie( count, trackLen, lenPadToDie ) = board->GetTrackLength( *this );
601 
602  msg = MessageTextFromValue( aFrame->GetUserUnits(), trackLen );
603  aList.emplace_back( _( "Length" ), msg, DARKCYAN );
604 
605  if( lenPadToDie != 0 )
606  {
607  msg = MessageTextFromValue( aFrame->GetUserUnits(), lenPadToDie, true );
608  aList.emplace_back( _( "Pad To Die Length" ), msg, DARKCYAN );
609 
610  msg = MessageTextFromValue( aFrame->GetUserUnits(), trackLen + lenPadToDie );
611  aList.emplace_back( _( "Full Length" ), msg, DARKCYAN );
612  }
613  }
614 
615  int clearance = GetClearance( nullptr, &source );
616 
617  msg.Printf( _( "Min Clearance: %s" ), MessageTextFromValue( units, clearance, true ) );
618  msg2.Printf( _( "(from %s)" ), source );
619  aList.emplace_back( msg, msg2, BLACK );
620 
621  int minWidth, maxWidth;
622  GetWidthConstraints( &minWidth, &maxWidth, &source );
623 
624  msg.Printf( _( "Min Width: %s" ), MessageTextFromValue( units, minWidth, true ) );
625  msg2.Printf( _( "(from %s)" ), source );
626  aList.emplace_back( msg, msg2, BLACK );
627 }
628 
629 
630 void VIA::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
631 {
632  EDA_UNITS units = aFrame->GetUserUnits();
633  wxString msg;
634  wxString msg2;
635  wxString source;
636  BOARD* board = GetBoard();
637 
638  // Display basic infos
639  switch( GetViaType() )
640  {
641  default:
642  case VIATYPE::MICROVIA:
643  msg = _( "Micro Via" ); // from external layer (TOP or BOTTOM) from
644  // the near neighbor inner layer only
645  break;
646 
648  msg = _( "Blind/Buried Via" ); // from inner or external to inner
649  // or external layer (no restriction)
650  break;
651 
652  case VIATYPE::THROUGH:
653  msg = _( "Through Via" ); // Usual via (from TOP to BOTTOM layer only )
654  break;
655 
657  msg = wxT( "???" ); // Not used yet, does not exist currently
658  break;
659  }
660 
661  aList.emplace_back( _( "Type" ), msg, DARKCYAN );
662 
663  GetMsgPanelInfoBase_Common( aFrame, aList );
664 
665  // Display layer pair
666  PCB_LAYER_ID top_layer, bottom_layer;
667 
668  LayerPair( &top_layer, &bottom_layer );
669 
670  if( board )
671  msg = board->GetLayerName( top_layer ) + wxT( "/" ) + board->GetLayerName( bottom_layer );
672  else
673  msg.Printf( wxT( "%d/%d" ), top_layer, bottom_layer );
674 
675  aList.emplace_back( _( "Layers" ), msg, BROWN );
676 
677  // Display width
678  msg = MessageTextFromValue( aFrame->GetUserUnits(), m_Width, true );
679 
680  // Display diameter value:
681  aList.emplace_back( _( "Diameter" ), msg, DARKCYAN );
682 
683  // Display drill value
684  msg = MessageTextFromValue( aFrame->GetUserUnits(), GetDrillValue() );
685 
686  aList.emplace_back( _( "Drill" ), msg, RED );
687 
688  int clearance = GetClearance( nullptr, &source );
689 
690  msg.Printf( _( "Min Clearance: %s" ), MessageTextFromValue( units, clearance, true ) );
691  msg2.Printf( _( "(from %s)" ), source );
692  aList.emplace_back( msg, msg2, BLACK );
693 
694  int minAnnulus = GetMinAnnulus( &source );
695 
696  msg.Printf( _( "Min Annulus: %s" ), MessageTextFromValue( units, minAnnulus, true ) );
697  msg2.Printf( _( "(from %s)" ), source );
698  aList.emplace_back( msg, msg2, BLACK );
699 }
700 
701 
702 void TRACK::GetMsgPanelInfoBase_Common( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
703 {
704  wxString msg;
705 
706  // Display Net Name
707  if( GetBoard() )
708  {
709  NETINFO_ITEM* net = GetNet();
710  NETCLASS* netclass = nullptr;
711 
712  if( net )
713  {
714  if( net->GetNet() )
715  netclass = GetNetClass();
716  else
717  netclass = GetBoard()->GetDesignSettings().GetDefault();
718 
719  msg = UnescapeString( net->GetNetname() );
720  }
721  else
722  {
723  msg = wxT( "<no name>" );
724  }
725 
726  aList.emplace_back( _( "Net" ), msg, RED );
727 
728  if( netclass )
729  aList.emplace_back( _( "NetClass" ), netclass->GetName(), DARKMAGENTA );
730  }
731 
732 #if 0 // Enable for debugging
733  if( GetBoard() )
734  {
735  // Display net code:
736  msg.Printf( wxT( "%d" ), GetNetCode() );
737  aList.emplace_back( _( "NetCode" ), msg, RED );
738  }
739 
740  // Display the flags:
741  msg.Printf( wxT( "0x%08X" ), m_Flags );
742  aList.emplace_back( wxT( "Flags" ), msg, BLUE );
743 
744  // Display start and end positions:
745  msg.Printf( wxT( "%d %d" ), m_Start.x, m_Start.y );
746  aList.push_back( MSG_PANEL_ITEM( wxT( "Start pos" ), msg, BLUE ) );
747  msg.Printf( wxT( "%d %d" ), m_End.x, m_End.y );
748  aList.push_back( MSG_PANEL_ITEM( wxT( "End pos" ), msg, BLUE ) );
749 #endif
750 
751  // Display the State member
752  msg = wxT( ". . " );
753 
754  if( GetState( TRACK_LOCKED ) )
755  msg[0] = 'L';
756 
757  if( GetState( TRACK_AR ) )
758  msg[2] = 'A';
759 
760  aList.emplace_back( _( "Status" ), msg, MAGENTA );
761 }
762 
763 
764 bool TRACK::HitTest( const wxPoint& aPosition, int aAccuracy ) const
765 {
766  return TestSegmentHit( aPosition, m_Start, m_End, aAccuracy + ( m_Width / 2 ) );
767 }
768 
769 
770 bool ARC::HitTest( const wxPoint& aPosition, int aAccuracy ) const
771 {
772  int max_dist = aAccuracy + ( m_Width / 2 );
773  wxPoint center = GetPosition();
774  wxPoint relpos = aPosition - center;
775  double dist = EuclideanNorm( relpos );
776  double radius = GetRadius();
777 
778  if( std::abs( dist - radius ) > max_dist )
779  return false;
780 
781  double arc_angle_start = GetArcAngleStart(); // Always 0.0 ... 360 deg, in 0.1 deg
782  double arc_hittest = ArcTangente( relpos.y, relpos.x );
783 
784  // Calculate relative angle between the starting point of the arc, and the test point
785  arc_hittest -= arc_angle_start;
786 
787  // Normalise arc_hittest between 0 ... 360 deg
788  NORMALIZE_ANGLE_POS( arc_hittest );
789  double arc_angle = GetAngle();
790 
791  if( arc_angle < 0 )
792  return arc_hittest >= 3600 + arc_angle;
793 
794  return arc_hittest <= GetAngle();
795 }
796 
797 
798 bool VIA::HitTest( const wxPoint& aPosition, int aAccuracy ) const
799 {
800  int max_dist = aAccuracy + ( m_Width / 2 );
801 
802  // rel_pos is aPosition relative to m_Start (or the center of the via)
803  wxPoint rel_pos = aPosition - m_Start;
804  double dist = (double) rel_pos.x * rel_pos.x + (double) rel_pos.y * rel_pos.y;
805  return dist <= (double) max_dist * max_dist;
806 }
807 
808 
809 bool TRACK::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
810 {
811  EDA_RECT arect = aRect;
812  arect.Inflate( aAccuracy );
813 
814  if( aContained )
815  /* Tracks are a special case:
816  * they are considered inside the rect if one end is inside the rect */
817  return arect.Contains( GetStart() ) || arect.Contains( GetEnd() );
818  else
819  return arect.Intersects( GetStart(), GetEnd() );
820 }
821 
822 
823 bool ARC::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
824 {
825  EDA_RECT box;
826  EDA_RECT arect = aRect;
827  arect.Inflate( aAccuracy );
828 
829  box.SetOrigin( GetStart() );
830  box.Merge( GetMid() );
831  box.Merge( GetEnd() );
832 
833  box.Inflate( GetWidth() / 2 );
834 
835  if( aContained )
836  return arect.Contains( box );
837  else
838  return arect.Intersects( box );
839 }
840 
841 
842 bool VIA::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
843 {
844  EDA_RECT box;
845  EDA_RECT arect = aRect;
846  arect.Inflate( aAccuracy );
847 
848  box.SetOrigin( GetStart() );
849  box.Inflate( GetWidth() / 2 );
850 
851  if( aContained )
852  {
853  return arect.Contains( box );
854  }
855  else
856  {
857  return arect.IntersectsCircle( GetStart(), GetWidth() / 2 );
858  }
859 }
860 
861 
862 wxString TRACK::GetSelectMenuText( EDA_UNITS aUnits ) const
863 {
864  return wxString::Format( _("Track %s %s on %s, length: %s" ),
865  MessageTextFromValue( aUnits, m_Width ),
866  GetNetnameMsg(),
867  GetLayerName(),
868  MessageTextFromValue( aUnits, GetLength() ) );
869 }
870 
871 
873 {
874  return add_tracks_xpm;
875 }
876 
878 {
879  assert( aImage->Type() == PCB_TRACE_T );
880 
881  std::swap( *((TRACK*) this), *((TRACK*) aImage) );
882 }
883 
884 void ARC::SwapData( BOARD_ITEM* aImage )
885 {
886  assert( aImage->Type() == PCB_ARC_T );
887 
888  std::swap( *this, *static_cast<ARC*>( aImage ) );
889 }
890 
891 void VIA::SwapData( BOARD_ITEM* aImage )
892 {
893  assert( aImage->Type() == PCB_VIA_T );
894 
895  std::swap( *((VIA*) this), *((VIA*) aImage) );
896 }
897 
898 
900 {
901  auto center = GetArcCenter( VECTOR2I( m_Start ), VECTOR2I( m_Mid ), VECTOR2I( m_End ) );
902  return wxPoint( center.x, center.y );
903 }
904 
905 double ARC::GetRadius() const
906 {
907  auto center = GetArcCenter( VECTOR2I( m_Start ), VECTOR2I( m_Mid ), VECTOR2I( m_End ) );
908  return GetLineLength( wxPoint( center ), m_Start );
909 }
910 
911 double ARC::GetAngle() const
912 {
913  wxPoint center = GetPosition();
914  wxPoint p0 = m_Start - center;
915  wxPoint p1 = m_Mid - center;
916  wxPoint p2 = m_End - center;
917  double angle1 = ArcTangente( p1.y, p1.x ) - ArcTangente( p0.y, p0.x );
918  double angle2 = ArcTangente( p2.y, p2.x ) - ArcTangente( p1.y, p1.x );
919 
920  return NormalizeAngle180( angle1 ) + NormalizeAngle180( angle2 );
921 }
922 
923 double ARC::GetArcAngleStart() const
924 {
925  wxPoint center = GetPosition();
926 
927  double angleStart = ArcTangente( m_Start.y - center.y,
928  m_Start.x - center.x );
929  return NormalizeAnglePos( angleStart );
930 }
931 
932 double ARC::GetArcAngleEnd() const
933 {
934  wxPoint center = GetPosition();
935 
936  double angleEnd = ArcTangente( m_End.y - center.y,
937  m_End.x - center.x );
938  return NormalizeAnglePos( angleEnd );
939 }
940 
941 
942 #if defined(DEBUG)
943 
944 wxString TRACK::ShowState( int stateBits )
945 {
946  wxString ret;
947 
948  if( stateBits & IS_LINKED )
949  ret << wxT( " | IS_LINKED" );
950 
951  if( stateBits & TRACK_AR )
952  ret << wxT( " | TRACK_AR" );
953 
954  if( stateBits & TRACK_LOCKED )
955  ret << wxT( " | TRACK_LOCKED" );
956 
957  if( stateBits & IN_EDIT )
958  ret << wxT( " | IN_EDIT" );
959 
960  if( stateBits & IS_DRAGGED )
961  ret << wxT( " | IS_DRAGGED" );
962 
963  if( stateBits & DO_NOT_DRAW )
964  ret << wxT( " | DO_NOT_DRAW" );
965 
966  if( stateBits & IS_DELETED )
967  ret << wxT( " | IS_DELETED" );
968 
969  if( stateBits & END_ONPAD )
970  ret << wxT( " | END_ONPAD" );
971 
972  if( stateBits & BEGIN_ONPAD )
973  ret << wxT( " | BEGIN_ONPAD" );
974 
975  return ret;
976 }
977 
978 #endif
979 
980 
981 static struct TRACK_VIA_DESC
982 {
984  {
986  .Map( VIATYPE::THROUGH, _( "Through" ) )
987  .Map( VIATYPE::BLIND_BURIED, _( "Blind/Buried" ) )
988  .Map( VIATYPE::MICROVIA, _( "Microvia" ) );
989 
991 
992  // Track
993  REGISTER_TYPE( TRACK );
995 
996  propMgr.AddProperty( new PROPERTY<TRACK, int>( _( "Width" ),
998  propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _( "Position X" ),
999  new PROPERTY<TRACK, int, BOARD_ITEM>( _( "Origin X" ),
1001  propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _( "Position Y" ),
1002  new PROPERTY<TRACK, int, BOARD_ITEM>( _( "Origin Y" ),
1004  propMgr.AddProperty( new PROPERTY<TRACK, int>( _( "End X" ),
1006  propMgr.AddProperty( new PROPERTY<TRACK, int>( _( "End Y" ),
1008 
1009  // Via
1010  REGISTER_TYPE( VIA );
1012 
1013  // TODO layerset for vias?
1014  // TODO test drill, use getdrillvalue?
1015  propMgr.ReplaceProperty( TYPE_HASH( TRACK ), _( "Width" ),
1016  new PROPERTY<VIA, int, TRACK>( _( "Diameter" ), &VIA::SetWidth, &VIA::GetWidth,
1018  propMgr.AddProperty( new PROPERTY<VIA, int>( _( "Drill" ),
1020  propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _( "Layer" ),
1021  new PROPERTY_ENUM<VIA, PCB_LAYER_ID, BOARD_ITEM>( _( "Layer Top" ),
1023  propMgr.AddProperty( new PROPERTY_ENUM<VIA, PCB_LAYER_ID>( _( "Layer Bottom" ),
1025  propMgr.AddProperty( new PROPERTY_ENUM<VIA, VIATYPE>( _( "Via Type" ),
1027  }
1028 } _TRACK_VIA_DESC;
1029 
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:128
virtual void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
int GetMinAnnulus(wxString *aSource) const
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:712
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
Definition: base_struct.h:114
EDA_UNITS
Definition: common.h:198
void GetWidthConstraints(int *aMin, int *aMax, wxString *aSource) const
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...
to draw blind/buried vias
VIATYPE m_ViaType
Definition: class_track.h:482
static PROPERTY_MANAGER & Instance()
Definition: property_mgr.h:61
#define IN_EDIT
Item currently edited.
Definition: base_struct.h:115
#define TYPE_HASH(x)
Macro to generate unique identifier for a type
Definition: property.h:53
int GetNetCode() const
Function GetNetCode.
wxPoint m_Start
Line start point.
Definition: class_track.h:257
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:206
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
void Merge(const EDA_RECT &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer.
PNG memory record (file in memory).
Definition: bitmap_def.h:29
#define END_ONPAD
Pcbnew: flag set for track segment ending on a pad.
Definition: base_struct.h:136
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
Implementation of conversion functions that require both schematic and board internal units.
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
NETINFO_ITEM * GetNet() const
Function GetNet Returns NET_INFO object for a given item.
wxString m_Name
const wxPoint & GetStart() const
Definition: class_track.h:118
const wxString & GetName() const
Definition: netclass.h:96
NETCLASS * GetNetClass() const
Function GetNetClassPtr returns the NETCLASS for this item.
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Function FlippedLayerNumber.
Definition: lset.cpp:485
virtual void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Function Flip Flip this object, i.e.
virtual wxPoint GetPosition() const override
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
static struct TRACK_VIA_DESC _TRACK_VIA_DESC
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
static ENUM_MAP< T > & Instance()
Definition: property.h:515
void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on.
Definition: color4d.h:61
virtual EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: class_track.cpp:45
to draw via holes (pad holes do not use this layer)
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
bool IntersectsCircle(const wxPoint &aCenter, const int aRadius) const
Function IntersectsCircle tests for a common area between a circle and this rectangle.
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:131
ARC(BOARD_ITEM *aParent)
Definition: class_track.h:266
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:551
int GetLocalClearance(wxString *aSource=nullptr) const override
Function GetLocalClearance returns any local clearance overrides set in the "classic" (ie: pre-rule) ...
#define TRACK_CONSTRAINT
const BITMAP_OPAQUE add_tracks_xpm[1]
Definition: add_tracks.cpp:31
Definition: color4d.h:44
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:257
MINOPTMAX m_TrackConstraint
void SetEndY(int aY)
Definition: class_track.h:121
The base class for create windows for drawing purpose.
VIA(BOARD_ITEM *aParent)
Definition: class_track.cpp:57
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
#define BEGIN_ONPAD
Pcbnew: flag set for track segment starting on a pad.
Definition: base_struct.h:135
BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected and have...
#define REGISTER_TYPE(x)
Helper macro to map type hashes to names
Definition: property_mgr.h:244
bool Contains(const wxPoint &aPoint) const
Function Contains.
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
A single base class (TRACK) represents both tracks and vias, with subclasses for curved tracks (ARC) ...
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
int m_Width
Thickness of track, or via diameter.
Definition: class_track.h:256
void SetWidth(int aWidth)
Definition: class_track.h:111
Classes used in Pcbnew, CvPcb and GerbView.
bool TestSegmentHit(const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
Definition: trigo.cpp:129
virtual unsigned int ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Function ViewGetLOD() Returns the level of detail (LOD) of the item.
T NormalizeAngle180(T Angle)
Normalize angle to be in the -180.0 .. 180.0 range.
Definition: trigo.h:345
const INSPECTOR_FUNC & INSPECTOR
Definition: base_struct.h:105
double dist(const double ax, const double ay, const double bx, const double by)
Definition: delauney.h:168
#define IS_DRAGGED
Item being dragged.
Definition: base_struct.h:119
PCB_LAYER_ID m_Layer
PCB_LAYER_ID
A quick note on layer IDs:
Display value expressed in distance units (mm/inch)
Definition: property.h:47
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
LSET is a set of PCB_LAYER_IDs.
const wxPoint & GetMid() const
Definition: class_track.h:293
int GetY() const
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
void GetMsgPanelInfoBase_Common(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
#define ANNULUS_CONSTRAINT
#define IS_DELETED
Definition: base_struct.h:120
wxPoint m_End
Line end point.
Definition: class_track.h:258
DRC_RULE * GetRule(const BOARD_ITEM *aItem, const BOARD_ITEM *bItem, int aConstraint)
to draw usual through hole vias
int GetEndY() const
Definition: class_track.h:124
int m_Drill
Definition: class_track.h:484
NETCLASS handles a collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:49
VIATYPE
Definition: class_track.h:68
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
int GetViaDrill() const
Definition: netclass.h:174
void InheritsAfter(TYPE_ID aDerived, TYPE_ID aBase)
Declares an inheritance relationship between types.
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Function Flip Flip this object, i.e.
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: class_track.cpp:72
const wxString & GetNetname() const
Function GetNetname.
Definition: netinfo.h:231
unsigned STATUS_FLAGS
Definition: base_struct.h:152
SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[]) override
Function Visit may be re-implemented for each derived class in order to handle all the types given by...
PCB_LAYER_ID m_BottomLayer
The bottom layer of the via (the top layer is in m_Layer)
Definition: class_track.h:480
void SetY(int aY)
unsigned int ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Function ViewGetLOD() Returns the level of detail (LOD) of the item.
#define TRACK_LOCKED
Pcbnew: track locked: protected from global deletion.
Definition: base_struct.h:131
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.
double GetRadius() const
const BOX2I ViewBBox() const override
Function ViewBBox() returns the bounding box of the item covering all its layers.
void SetX(int aX)
Definition: color4d.h:59
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
void SetDrillDefault()
Function SetDrillDefault sets the drill value for vias to the default value UNDEFINED_DRILL_DIAMETER.
Definition: class_track.h:468
#define TRACK_AR
Pcbnew: autorouted track.
Definition: base_struct.h:132
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
wxString GetNetnameMsg() const
Function GetNetnameMsg.
virtual int GetClearance(BOARD_ITEM *aItem=nullptr, wxString *aSource=nullptr) const
Function GetClearance returns the clearance in internal units.
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aUseMils, EDA_DATA_TYPE aType)
Definition: base_units.cpp:124
double GetAngle() const
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on.
NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:301
Definition: color4d.h:56
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
int GetX() const
int GetWidth() const
Definition: class_track.h:112
STATUS_FLAGS IsPointOnEnds(const wxPoint &point, int min_dist=0) const
Function IsPointOnEnds returns STARTPOINT if point if near (dist = min_dist) start point,...
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
int GetNet() const
Function GetNet.
Definition: netinfo.h:223
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: class_track.cpp:51
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:180
#define _(s)
Definition: 3d_actions.cpp:33
void SetTopLayer(PCB_LAYER_ID aLayer)
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:131
T NormalizeAnglePos(T Angle)
Normalize angle to be in the 0.0 .
Definition: trigo.h:248
double GetArcAngleEnd() const
STATUS_FLAGS m_Flags
Definition: base_struct.h:176
void AddProperty(PROPERTY_BASE *aProperty)
Registers a property.
int GetCopperLayerCount() const
Function GetCopperLayerCount.
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:123
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: class_track.h:447
NETCLASS * GetDefault() const
Function GetDefault.
VIATYPE GetViaType() const
Definition: class_track.h:373
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:68
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
PCB_LAYER_ID TopLayer() const
const wxPoint & GetEnd() const
Definition: class_track.h:115
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
void SetBottomLayer(PCB_LAYER_ID aLayer)
virtual double GetLength() const
Function GetLength returns the length of the track using the hypotenuse calculation.
Definition: class_track.h:153
void ReplaceProperty(size_t aBase, const wxString &aName, PROPERTY_BASE *aNew)
Replaces an existing property for a specific type.
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
int GetuViaDrill() const
Definition: netclass.h:180
Provides class metadata.
Definition: property_mgr.h:58
double GetArcAngleStart() const
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
TRACK(BOARD_ITEM *aParent, KICAD_T idtype=PCB_TRACE_T)
Definition: class_track.cpp:38
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Function IsOnLayer tests to see if this object is on the given layer.
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:162
EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
VIEW.
Definition: view.h:61
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:397
SEARCH_RESULT
Definition: base_struct.h:51
void SanitizeLayers()
Function SanitizeLayers Check so that the layers are correct dependin on the type of via,...
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
std::tuple< int, double, double > GetTrackLength(const TRACK &aTrack) const
Returns data on the length and number of track segments connected to a given track.
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
ENUM_TO_WXANY(VIATYPE)
wxString GetLayerName() const
Function GetLayerName returns the name of the PCB layer on which the item resides.
void SetViaType(VIATYPE aViaType)
Definition: class_track.h:374
PCB_LAYER_ID BottomLayer() const
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
int GetState(int type) const
Definition: base_struct.h:216
int GetEndX() const
Definition: class_track.h:123
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Function Flip Flip this object, i.e.
wxPoint m_Mid
Arc mid point, halfway between start and end.
Definition: class_track.h:339
const BITMAP_OPAQUE via_xpm[1]
void SetEndX(int aX)
Definition: class_track.h:120
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
virtual bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
#define DO_NOT_DRAW
Used to disable draw function.
Definition: base_struct.h:129
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: class_track.cpp:66
bool IsNetnameLayer(LAYER_NUM aLayer)
Function IsNetnameLayer tests whether a layer is a netname layer.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:122
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible() Returns information about visibility of a particular layer.
Definition: view.h:416