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>
30 #include <class_board.h>
31 #include <class_track.h>
32 #include <base_units.h>
33 #include <bitmaps.h>
34 #include <view/view.h>
37 
38 #include <geometry/shape_segment.h>
39 #include <geometry/shape_circle.h>
40 #include <geometry/shape_arc.h>
41 #include <drc/drc_engine.h>
42 
43 TRACK::TRACK( BOARD_ITEM* aParent, KICAD_T idtype ) :
44  BOARD_CONNECTED_ITEM( aParent, idtype )
45 {
46  m_Width = Millimeter2iu( 0.2 ); // Gives a reasonable default width
47 }
48 
49 
51 {
52  return new TRACK( *this );
53 }
54 
55 
57 {
58  return new ARC( *this );
59 }
60 
61 
62 VIA::VIA( BOARD_ITEM* aParent ) :
63  TRACK( aParent, PCB_VIA_T )
64 {
69  m_KeepTopBottomLayer = true;
70 }
71 
72 
74 {
75  return new VIA( *this );
76 }
77 
78 
79 wxString VIA::GetSelectMenuText( EDA_UNITS aUnits ) const
80 {
81  wxString formatStr;
82 
83  switch( GetViaType() )
84  {
85  case VIATYPE::BLIND_BURIED: formatStr = _( "Blind/Buried Via %s on %s" ); break;
86  case VIATYPE::MICROVIA: formatStr = _( "Micro Via %s on %s" ); break;
87  default: formatStr = _( "Via %s on %s" ); break;
88  }
89 
90  return wxString::Format( formatStr,
91  GetNetnameMsg(),
93 }
94 
95 
97 {
98  return via_xpm;
99 }
100 
101 
102 int TRACK::GetLocalClearance( wxString* aSource ) const
103 {
104  // Not currently implemented
105  return 0;
106 }
107 
108 
109 void TRACK::GetWidthConstraints( int* aMin, int* aMax, wxString* aSource ) const
110 {
111  *aMin = 0;
112  *aMax = INT_MAX;
113 
114  DRC_CONSTRAINT constraint;
115 
116  if( GetBoard() && GetBoard()->GetDesignSettings().m_DRCEngine )
117  {
119 
120  constraint = bds.m_DRCEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_TRACK_WIDTH, this,
121  nullptr, GetLayer() );
122  }
123 
124  if( constraint.Value().HasMin() || constraint.Value().HasMax() )
125  {
126  if( constraint.Value().HasMin() )
127  *aMin = constraint.Value().Min();
128 
129  if( constraint.Value().HasMax() )
130  *aMax = constraint.Value().Max();
131 
132  if( aSource )
133  *aSource = constraint.GetName();
134  }
135 }
136 
137 
138 int VIA::GetMinAnnulus( PCB_LAYER_ID aLayer, wxString* aSource ) const
139 {
140  if( !IsPadOnLayer( aLayer ) )
141  {
142  if( aSource )
143  *aSource = _( "removed annular ring" );
144 
145  return 0;
146  }
147 
148  DRC_CONSTRAINT constraint;
149 
150  if( GetBoard() && GetBoard()->GetDesignSettings().m_DRCEngine )
151  {
153 
154  constraint = bds.m_DRCEngine->EvalRulesForItems( DRC_CONSTRAINT_TYPE_ANNULAR_WIDTH, this,
155  nullptr, aLayer );
156  }
157 
158  if( constraint.Value().HasMin() )
159  {
160  if( aSource )
161  *aSource = constraint.GetName();
162 
163  return constraint.Value().Min();
164  }
165 
166  return 0;
167 }
168 
169 
171 {
172  if( m_Drill > 0 ) // Use the specific value.
173  return m_Drill;
174 
175  // Use the default value from the Netclass
176  NETCLASS* netclass = GetNetClass();
177 
178  if( GetViaType() == VIATYPE::MICROVIA )
179  return netclass->GetuViaDrill();
180 
181  return netclass->GetViaDrill();
182 }
183 
184 
185 STATUS_FLAGS TRACK::IsPointOnEnds( const wxPoint& point, int min_dist ) const
186 {
187  STATUS_FLAGS result = 0;
188 
189  if( min_dist < 0 )
190  min_dist = m_Width / 2;
191 
192  if( min_dist == 0 )
193  {
194  if( m_Start == point )
195  result |= STARTPOINT;
196 
197  if( m_End == point )
198  result |= ENDPOINT;
199  }
200  else
201  {
202  double dist = GetLineLength( m_Start, point );
203 
204  if( min_dist >= KiROUND( dist ) )
205  result |= STARTPOINT;
206 
207  dist = GetLineLength( m_End, point );
208 
209  if( min_dist >= KiROUND( dist ) )
210  result |= ENDPOINT;
211  }
212 
213  return result;
214 }
215 
216 
218 {
219  // end of track is round, this is its radius, rounded up
220  int radius = ( m_Width + 1 ) / 2;
221  int ymax, xmax, ymin, xmin;
222 
223  if( Type() == PCB_VIA_T )
224  {
225  ymax = m_Start.y;
226  xmax = m_Start.x;
227 
228  ymin = m_Start.y;
229  xmin = m_Start.x;
230  }
231  else
232  {
233  ymax = std::max( m_Start.y, m_End.y );
234  xmax = std::max( m_Start.x, m_End.x );
235 
236  ymin = std::min( m_Start.y, m_End.y );
237  xmin = std::min( m_Start.x, m_End.x );
238  }
239 
240  ymax += radius;
241  xmax += radius;
242 
243  ymin -= radius;
244  xmin -= radius;
245 
246  // return a rectangle which is [pos,dim) in nature. therefore the +1
247  EDA_RECT ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
248 
249  return ret;
250 }
251 
252 
253 void TRACK::Rotate( const wxPoint& aRotCentre, double aAngle )
254 {
255  RotatePoint( &m_Start, aRotCentre, aAngle );
256  RotatePoint( &m_End, aRotCentre, aAngle );
257 }
258 
259 
260 void ARC::Rotate( const wxPoint& aRotCentre, double aAngle )
261 {
262  RotatePoint( &m_Start, aRotCentre, aAngle );
263  RotatePoint( &m_End, aRotCentre, aAngle );
264  RotatePoint( &m_Mid, aRotCentre, aAngle );
265 }
266 
267 
268 void TRACK::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
269 {
270  if( aFlipLeftRight )
271  {
272  m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
273  m_End.x = aCentre.x - ( m_End.x - aCentre.x );
274  }
275  else
276  {
277  m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
278  m_End.y = aCentre.y - ( m_End.y - aCentre.y );
279  }
280 
281  int copperLayerCount = GetBoard()->GetCopperLayerCount();
282  SetLayer( FlipLayer( GetLayer(), copperLayerCount ) );
283 }
284 
285 
286 void ARC::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
287 {
288  if( aFlipLeftRight )
289  {
290  m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
291  m_End.x = aCentre.x - ( m_End.x - aCentre.x );
292  m_Mid.x = aCentre.x - ( m_Mid.x - aCentre.x );
293  }
294  else
295  {
296  m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
297  m_End.y = aCentre.y - ( m_End.y - aCentre.y );
298  m_Mid.y = aCentre.y - ( m_Mid.y - aCentre.y );
299  }
300 
301  int copperLayerCount = GetBoard()->GetCopperLayerCount();
302  SetLayer( FlipLayer( GetLayer(), copperLayerCount ) );
303 }
304 
305 
306 void VIA::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
307 {
308  if( aFlipLeftRight )
309  {
310  m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
311  m_End.x = aCentre.x - ( m_End.x - aCentre.x );
312  }
313  else
314  {
315  m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
316  m_End.y = aCentre.y - ( m_End.y - aCentre.y );
317  }
318 
319  if( GetViaType() != VIATYPE::THROUGH )
320  {
321  int copperLayerCount = GetBoard()->GetCopperLayerCount();
322  PCB_LAYER_ID top_layer;
323  PCB_LAYER_ID bottom_layer;
324  LayerPair( &top_layer, &bottom_layer );
325  top_layer = FlipLayer( top_layer, copperLayerCount );
326  bottom_layer = FlipLayer( bottom_layer, copperLayerCount );
327  SetLayerPair( top_layer, bottom_layer );
328  }
329 }
330 
331 
332 // see class_track.h
333 SEARCH_RESULT TRACK::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
334 {
335  KICAD_T stype = *scanTypes;
336 
337  // If caller wants to inspect my type
338  if( stype == Type() )
339  {
340  if( SEARCH_RESULT::QUIT == inspector( this, testData ) )
341  return SEARCH_RESULT::QUIT;
342  }
343 
345 }
346 
347 
348 bool VIA::IsOnLayer( PCB_LAYER_ID layer_number ) const
349 {
350  PCB_LAYER_ID bottom_layer, top_layer;
351 
352  LayerPair( &top_layer, &bottom_layer );
353 
354  wxASSERT( top_layer <= bottom_layer );
355 
356  if( top_layer <= layer_number && layer_number <= bottom_layer )
357  return true;
358  else
359  return false;
360 }
361 
362 
364 {
365  if( GetViaType() == VIATYPE::THROUGH )
366  return LSET::AllCuMask();
367 
368  // VIA_BLIND_BURIED or VIA_MICRVIA:
369 
370  LSET layermask;
371 
372  wxASSERT( m_Layer <= m_BottomLayer );
373 
374  // PCB_LAYER_IDs are numbered from front to back, this is top to bottom.
375  for( LAYER_NUM id = m_Layer; id <= m_BottomLayer; ++id )
376  {
377  layermask.set( id );
378  }
379 
380  return layermask;
381 }
382 
383 
384 void VIA::SetLayerSet( LSET aLayerSet )
385 {
386  bool first = true;
387 
388  for( PCB_LAYER_ID layer : aLayerSet.Seq() )
389  {
390  if( first )
391  {
392  m_Layer = layer;
393  first = false;
394  }
395 
396  m_BottomLayer = layer;
397  }
398 }
399 
400 
401 void VIA::SetLayerPair( PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer )
402 {
403 
404  m_Layer = aTopLayer;
405  m_BottomLayer = aBottomLayer;
406  SanitizeLayers();
407 }
408 
409 
411 {
412  m_Layer = aLayer;
413 }
414 
415 
417 {
418  m_BottomLayer = aLayer;
419 }
420 
421 
422 void VIA::LayerPair( PCB_LAYER_ID* top_layer, PCB_LAYER_ID* bottom_layer ) const
423 {
424  PCB_LAYER_ID t_layer = F_Cu;
425  PCB_LAYER_ID b_layer = B_Cu;
426 
427  if( GetViaType() != VIATYPE::THROUGH )
428  {
429  b_layer = m_BottomLayer;
430  t_layer = m_Layer;
431 
432  if( b_layer < t_layer )
433  std::swap( b_layer, t_layer );
434  }
435 
436  if( top_layer )
437  *top_layer = t_layer;
438 
439  if( bottom_layer )
440  *bottom_layer = b_layer;
441 }
442 
443 
445 {
446  return m_Layer;
447 }
448 
449 
451 {
452  return m_BottomLayer;
453 }
454 
455 
457 {
458  if( GetViaType() == VIATYPE::THROUGH )
459  {
460  m_Layer = F_Cu;
462  }
463 
464  if( m_BottomLayer < m_Layer )
465  std::swap( m_BottomLayer, m_Layer );
466 }
467 
468 
469 bool VIA::IsPadOnLayer( LSET aLayers ) const
470 {
471  for( auto layer : aLayers.Seq() )
472  {
473  if( IsPadOnLayer( layer ) )
474  return true;
475  }
476 
477  return false;
478 }
479 
480 
481 bool VIA::IsPadOnLayer( int aLayer ) const
482 {
483  BOARD* board = GetBoard();
484 
485  if( !board )
486  return false;
487 
488  if( !IsOnLayer( static_cast<PCB_LAYER_ID>( aLayer ) ) )
489  return false;
490 
492  return true;
493 
494  if( m_KeepTopBottomLayer && ( aLayer == m_Layer || aLayer == m_BottomLayer ) )
495  return true;
496 
497  return board->GetConnectivity()->IsConnectedOnLayer( this, static_cast<int>( aLayer ),
499 }
500 
501 
502 void TRACK::ViewGetLayers( int aLayers[], int& aCount ) const
503 {
504  // Show the track and its netname on different layers
505  aLayers[0] = GetLayer();
506  aLayers[1] = GetNetnameLayer( aLayers[0] );
507  aCount = 2;
508 }
509 
510 
511 double TRACK::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
512 {
513  constexpr double HIDE = std::numeric_limits<double>::max();
514 
515  if( !aView->IsLayerVisible( LAYER_TRACKS ) )
516  return HIDE;
517 
518  // Netnames will be shown only if zoom is appropriate
519  if( IsNetnameLayer( aLayer ) )
520  {
521  return ( double ) Millimeter2iu( 4 ) / ( m_Width + 1 );
522  }
523 
524  // Other layers are shown without any conditions
525  return 0.0;
526 }
527 
528 
529 const BOX2I TRACK::ViewBBox() const
530 {
531  BOX2I bbox = GetBoundingBox();
532  bbox.Inflate( 2 * GetClearance( GetLayer() ) );
533  return bbox;
534 }
535 
536 
537 void VIA::ViewGetLayers( int aLayers[], int& aCount ) const
538 {
539  aLayers[0] = LAYER_VIAS_HOLES;
540  aLayers[1] = LAYER_VIAS_NETNAMES;
541  aCount = 3;
542 
543  // Just show it on common via & via holes layers
544  switch( GetViaType() )
545  {
546  case VIATYPE::THROUGH:
547  aLayers[2] = LAYER_VIA_THROUGH;
548  break;
549 
551  aLayers[2] = LAYER_VIA_BBLIND;
552  aLayers[3] = m_Layer;
553  aLayers[4] = m_BottomLayer;
554  aCount += 2;
555  break;
556 
557  case VIATYPE::MICROVIA:
558  aLayers[2] = LAYER_VIA_MICROVIA;
559  aLayers[3] = m_Layer;
560  aLayers[4] = m_BottomLayer;
561  aCount += 2;
562  break;
563 
564  default:
565  aLayers[2] = LAYER_GP_OVERLAY;
566  wxASSERT( false );
567  break;
568  }
569 }
570 
571 
572 double VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
573 {
574  constexpr double HIDE = (double)std::numeric_limits<double>::max();
575 
576  // Netnames will be shown only if zoom is appropriate
577  if( IsNetnameLayer( aLayer ) )
578  return m_Width == 0 ? HIDE : ( (double)Millimeter2iu( 10 ) / m_Width );
579 
580  bool onVisibleLayer = false;
581 
582  PCB_LAYER_ID top;
583  PCB_LAYER_ID bottom;
584  LayerPair( &top, &bottom );
585 
586  for( int layer = top; layer <= bottom; ++layer )
587  {
588  if( aView->IsLayerVisible( layer ) )
589  {
590  onVisibleLayer = true;
591  break;
592  }
593  }
594 
595  // Draw through vias unconditionally if the vias control is turned on.
596  // Draw blind/buried/microvias only if at least one of the layers crossed is enabeld.
597  if( aView->IsLayerVisible( LAYER_VIAS ) )
598  {
599  if( !onVisibleLayer && m_ViaType != VIATYPE::THROUGH )
600  return HIDE;
601 
602  return aView->IsLayerVisible( LAYER_VIAS ) ? 0.0 : HIDE;
603  }
604 
605  return HIDE;
606 }
607 
608 
609 // see class_track.h
610 void TRACK::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
611 {
612  EDA_UNITS units = aFrame->GetUserUnits();
613  wxString msg;
614  wxString msg2;
615  wxString source;
616  BOARD* board = GetBoard();
617 
618  // Display basic infos
619  aList.emplace_back( _( "Type" ), _( "Track" ), DARKCYAN );
620 
621  GetMsgPanelInfoBase_Common( aFrame, aList );
622 
623  // Display layer
624  aList.emplace_back( _( "Layer" ), LayerMaskDescribe(), DARKGREEN );
625 
626  // Display width
627  msg = MessageTextFromValue( aFrame->GetUserUnits(), m_Width, true );
628 
629  aList.emplace_back( _( "Width" ), msg, DARKCYAN );
630 
631  // Display full track length (in Pcbnew)
632  if( board )
633  {
634  int count;
635  double trackLen;
636  double lenPadToDie;
637 
638  std::tie( count, trackLen, lenPadToDie ) = board->GetTrackLength( *this );
639 
640  msg = MessageTextFromValue( aFrame->GetUserUnits(), trackLen );
641  aList.emplace_back( _( "Length" ), msg, DARKCYAN );
642 
643  if( lenPadToDie != 0 )
644  {
645  msg = MessageTextFromValue( aFrame->GetUserUnits(), lenPadToDie, true );
646  aList.emplace_back( _( "Pad To Die Length" ), msg, DARKCYAN );
647 
648  msg = MessageTextFromValue( aFrame->GetUserUnits(), trackLen + lenPadToDie );
649  aList.emplace_back( _( "Full Length" ), msg, DARKCYAN );
650  }
651  }
652 
653  int clearance = GetClearance( GetLayer(), nullptr, &source );
654 
655  msg.Printf( _( "Min Clearance: %s" ), MessageTextFromValue( units, clearance, true ) );
656  msg2.Printf( _( "(from %s)" ), source );
657  aList.emplace_back( msg, msg2, BLACK );
658 
659  int minWidth, maxWidth;
660  GetWidthConstraints( &minWidth, &maxWidth, &source );
661 
662  msg.Printf( _( "Min Width: %s" ), MessageTextFromValue( units, minWidth, true ) );
663  msg2.Printf( _( "(from %s)" ), source );
664  aList.emplace_back( msg, msg2, BLACK );
665 }
666 
667 
668 void VIA::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
669 {
670  EDA_UNITS units = aFrame->GetUserUnits();
671  wxString msg;
672  wxString msg2;
673  wxString source;
674 
675  // Display basic infos
676  switch( GetViaType() )
677  {
678  case VIATYPE::MICROVIA: msg = _( "Micro Via" ); break;
679  case VIATYPE::BLIND_BURIED: msg = _( "Blind/Buried Via" ); break;
680  case VIATYPE::THROUGH: msg = _( "Through Via" ); break;
681  default: msg = _( "Via" ); break;
682  }
683 
684  aList.emplace_back( _( "Type" ), msg, DARKCYAN );
685 
686  GetMsgPanelInfoBase_Common( aFrame, aList );
687 
688  // Display layer pair
689  aList.emplace_back( _( "Layer" ), LayerMaskDescribe(), DARKGREEN );
690 
691  // Display width
692  msg = MessageTextFromValue( aFrame->GetUserUnits(), m_Width, true );
693 
694  // Display diameter value:
695  aList.emplace_back( _( "Diameter" ), msg, DARKCYAN );
696 
697  // Display drill value
698  msg = MessageTextFromValue( aFrame->GetUserUnits(), GetDrillValue() );
699 
700  aList.emplace_back( _( "Drill" ), msg, RED );
701 
702  int clearance = GetClearance( GetLayer(), nullptr, &source );
703 
704  msg.Printf( _( "Min Clearance: %s" ), MessageTextFromValue( units, clearance, true ) );
705  msg2.Printf( _( "(from %s)" ), source );
706  aList.emplace_back( msg, msg2, BLACK );
707 
708  int minAnnulus = GetMinAnnulus( GetLayer(), &source );
709 
710  msg.Printf( _( "Min Annular Width: %s" ), MessageTextFromValue( units, minAnnulus, true ) );
711  msg2.Printf( _( "(from %s)" ), source );
712  aList.emplace_back( msg, msg2, BLACK );
713 }
714 
715 
716 void TRACK::GetMsgPanelInfoBase_Common( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
717 {
718  wxString msg;
719 
720  // Display Net Name
721  if( GetBoard() )
722  {
723  NETINFO_ITEM* net = GetNet();
724  NETCLASS* netclass = nullptr;
725 
726  if( net )
727  {
728  if( net->GetNet() )
729  netclass = GetNetClass();
730  else
731  netclass = GetBoard()->GetDesignSettings().GetDefault();
732 
733  msg = UnescapeString( net->GetNetname() );
734  }
735  else
736  {
737  msg = wxT( "<no name>" );
738  }
739 
740  aList.emplace_back( _( "Net" ), msg, RED );
741 
742  if( netclass )
743  aList.emplace_back( _( "NetClass" ), netclass->GetName(), DARKMAGENTA );
744  }
745 
746 #if 0 // Enable for debugging
747  if( GetBoard() )
748  {
749  // Display net code:
750  msg.Printf( wxT( "%d" ), GetNetCode() );
751  aList.emplace_back( _( "NetCode" ), msg, RED );
752  }
753 
754  // Display the flags:
755  msg.Printf( wxT( "0x%08X" ), m_Flags );
756  aList.emplace_back( wxT( "Flags" ), msg, BLUE );
757 
758  // Display start and end positions:
759  msg.Printf( wxT( "%d %d" ), m_Start.x, m_Start.y );
760  aList.push_back( MSG_PANEL_ITEM( wxT( "Start pos" ), msg, BLUE ) );
761  msg.Printf( wxT( "%d %d" ), m_End.x, m_End.y );
762  aList.push_back( MSG_PANEL_ITEM( wxT( "End pos" ), msg, BLUE ) );
763 #endif
764 
765  // Display the State member
766  msg = wxT( ". . " );
767 
768  if( GetState( TRACK_LOCKED ) )
769  msg[0] = 'L';
770 
771  if( GetState( TRACK_AR ) )
772  msg[2] = 'A';
773 
774  aList.emplace_back( _( "Status" ), msg, MAGENTA );
775 }
776 
777 
778 wxString VIA::LayerMaskDescribe() const
779 {
780  BOARD* board = GetBoard();
781  PCB_LAYER_ID top_layer;
782  PCB_LAYER_ID bottom_layer;
783 
784  LayerPair( &top_layer, &bottom_layer );
785 
786  return board->GetLayerName( top_layer ) + wxT( " - " ) + board->GetLayerName( bottom_layer );
787 }
788 
789 
790 bool TRACK::HitTest( const wxPoint& aPosition, int aAccuracy ) const
791 {
792  return TestSegmentHit( aPosition, m_Start, m_End, aAccuracy + ( m_Width / 2 ) );
793 }
794 
795 
796 bool ARC::HitTest( const wxPoint& aPosition, int aAccuracy ) const
797 {
798  int max_dist = aAccuracy + ( m_Width / 2 );
799  wxPoint center = GetPosition();
800  wxPoint relpos = aPosition - center;
801  double dist = EuclideanNorm( relpos );
802  double radius = GetRadius();
803 
804  if( std::abs( dist - radius ) > max_dist )
805  return false;
806 
807  double arc_angle_start = GetArcAngleStart(); // Always 0.0 ... 360 deg, in 0.1 deg
808  double arc_hittest = ArcTangente( relpos.y, relpos.x );
809 
810  // Calculate relative angle between the starting point of the arc, and the test point
811  arc_hittest -= arc_angle_start;
812 
813  // Normalise arc_hittest between 0 ... 360 deg
814  NORMALIZE_ANGLE_POS( arc_hittest );
815  double arc_angle = GetAngle();
816 
817  if( arc_angle < 0 )
818  return arc_hittest >= 3600 + arc_angle;
819 
820  return arc_hittest <= GetAngle();
821 }
822 
823 
824 bool VIA::HitTest( const wxPoint& aPosition, int aAccuracy ) const
825 {
826  int max_dist = aAccuracy + ( m_Width / 2 );
827 
828  // rel_pos is aPosition relative to m_Start (or the center of the via)
829  wxPoint rel_pos = aPosition - m_Start;
830  double dist = (double) rel_pos.x * rel_pos.x + (double) rel_pos.y * rel_pos.y;
831  return dist <= (double) max_dist * max_dist;
832 }
833 
834 
835 bool TRACK::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
836 {
837  EDA_RECT arect = aRect;
838  arect.Inflate( aAccuracy );
839 
840  if( aContained )
841  return arect.Contains( GetStart() ) && arect.Contains( GetEnd() );
842  else
843  return arect.Intersects( GetStart(), GetEnd() );
844 }
845 
846 
847 bool ARC::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
848 {
849  EDA_RECT box;
850  EDA_RECT arect = aRect;
851  arect.Inflate( aAccuracy );
852 
853  box.SetOrigin( GetStart() );
854  box.Merge( GetMid() );
855  box.Merge( GetEnd() );
856 
857  box.Inflate( GetWidth() / 2 );
858 
859  if( aContained )
860  return arect.Contains( box );
861  else
862  return arect.Intersects( box );
863 }
864 
865 
866 bool VIA::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
867 {
868  EDA_RECT box;
869  EDA_RECT arect = aRect;
870  arect.Inflate( aAccuracy );
871 
872  box.SetOrigin( GetStart() );
873  box.Inflate( GetWidth() / 2 );
874 
875  if( aContained )
876  return arect.Contains( box );
877  else
878  return arect.IntersectsCircle( GetStart(), GetWidth() / 2 );
879 }
880 
881 
882 wxString TRACK::GetSelectMenuText( EDA_UNITS aUnits ) const
883 {
884  return wxString::Format( _("Track %s on %s, length %s" ),
885  GetNetnameMsg(),
886  GetLayerName(),
887  MessageTextFromValue( aUnits, GetLength() ) );
888 }
889 
890 
892 {
893  return add_tracks_xpm;
894 }
895 
897 {
898  assert( aImage->Type() == PCB_TRACE_T );
899 
900  std::swap( *((TRACK*) this), *((TRACK*) aImage) );
901 }
902 
903 void ARC::SwapData( BOARD_ITEM* aImage )
904 {
905  assert( aImage->Type() == PCB_ARC_T );
906 
907  std::swap( *this, *static_cast<ARC*>( aImage ) );
908 }
909 
910 void VIA::SwapData( BOARD_ITEM* aImage )
911 {
912  assert( aImage->Type() == PCB_VIA_T );
913 
914  std::swap( *((VIA*) this), *((VIA*) aImage) );
915 }
916 
917 
919 {
920  auto center = GetArcCenter( VECTOR2I( m_Start ), VECTOR2I( m_Mid ), VECTOR2I( m_End ) );
921  return wxPoint( center.x, center.y );
922 }
923 
924 double ARC::GetRadius() const
925 {
926  auto center = GetArcCenter( VECTOR2I( m_Start ), VECTOR2I( m_Mid ), VECTOR2I( m_End ) );
927  return GetLineLength( wxPoint( center ), m_Start );
928 }
929 
930 double ARC::GetAngle() const
931 {
932  wxPoint center = GetPosition();
933  wxPoint p0 = m_Start - center;
934  wxPoint p1 = m_Mid - center;
935  wxPoint p2 = m_End - center;
936  double angle1 = ArcTangente( p1.y, p1.x ) - ArcTangente( p0.y, p0.x );
937  double angle2 = ArcTangente( p2.y, p2.x ) - ArcTangente( p1.y, p1.x );
938 
939  return NormalizeAngle180( angle1 ) + NormalizeAngle180( angle2 );
940 }
941 
942 double ARC::GetArcAngleStart() const
943 {
944  wxPoint center = GetPosition();
945 
946  double angleStart = ArcTangente( m_Start.y - center.y,
947  m_Start.x - center.x );
948  return NormalizeAnglePos( angleStart );
949 }
950 
951 double ARC::GetArcAngleEnd() const
952 {
953  wxPoint center = GetPosition();
954 
955  double angleEnd = ArcTangente( m_End.y - center.y,
956  m_End.x - center.x );
957  return NormalizeAnglePos( angleEnd );
958 }
959 
960 
961 bool TRACK::cmp_tracks::operator() ( const TRACK* a, const TRACK* b ) const
962 {
963  if( a->GetNetCode() != b->GetNetCode() )
964  return a->GetNetCode() < b->GetNetCode();
965 
966  if( a->GetLayer() != b->GetLayer() )
967  return a->GetLayer() < b->GetLayer();
968 
969  if( a->Type() != b->Type() )
970  return a->Type() < b->Type();
971 
972  return a->m_Uuid < b->m_Uuid;
973 }
974 
975 
976 std::shared_ptr<SHAPE> TRACK::GetEffectiveShape( PCB_LAYER_ID aLayer ) const
977 {
978  std::shared_ptr<SHAPE_SEGMENT> shape( new SHAPE_SEGMENT( m_Start, m_End, m_Width ) );
979 
980  return shape;
981 }
982 
983 
984 std::shared_ptr<SHAPE> VIA::GetEffectiveShape( PCB_LAYER_ID aLayer ) const
985 {
986  // fixme: pad stack support (depending on aLayer )
987  std::shared_ptr<SHAPE_CIRCLE> shape( new SHAPE_CIRCLE( m_Start, m_Width / 2 ) );
988 
989  return shape;
990 }
991 
992 
993 std::shared_ptr<SHAPE> ARC::GetEffectiveShape( PCB_LAYER_ID aLayer ) const
994 {
995  std::shared_ptr<SHAPE_ARC> shape( new SHAPE_ARC( GetStart(), GetMid(), GetEnd(),
996  GetWidth() ) );
997 
998  return shape;
999 }
1000 
1001 
1002 
1003 #if defined(DEBUG)
1004 
1005 wxString TRACK::ShowState( int stateBits )
1006 {
1007  wxString ret;
1008 
1009  if( stateBits & IS_LINKED )
1010  ret << wxT( " | IS_LINKED" );
1011 
1012  if( stateBits & TRACK_AR )
1013  ret << wxT( " | TRACK_AR" );
1014 
1015  if( stateBits & TRACK_LOCKED )
1016  ret << wxT( " | TRACK_LOCKED" );
1017 
1018  if( stateBits & IN_EDIT )
1019  ret << wxT( " | IN_EDIT" );
1020 
1021  if( stateBits & IS_DRAGGED )
1022  ret << wxT( " | IS_DRAGGED" );
1023 
1024  if( stateBits & DO_NOT_DRAW )
1025  ret << wxT( " | DO_NOT_DRAW" );
1026 
1027  if( stateBits & IS_DELETED )
1028  ret << wxT( " | IS_DELETED" );
1029 
1030  if( stateBits & END_ONPAD )
1031  ret << wxT( " | END_ONPAD" );
1032 
1033  if( stateBits & BEGIN_ONPAD )
1034  ret << wxT( " | BEGIN_ONPAD" );
1035 
1036  return ret;
1037 }
1038 
1039 #endif
1040 
1041 
1042 static struct TRACK_VIA_DESC
1043 {
1045  {
1047  .Undefined( VIATYPE::NOT_DEFINED )
1048  .Map( VIATYPE::THROUGH, _( "Through" ) )
1049  .Map( VIATYPE::BLIND_BURIED, _( "Blind/buried" ) )
1050  .Map( VIATYPE::MICROVIA, _( "Micro" ) );
1051 
1053 
1054  if( layerEnum.Choices().GetCount() == 0 )
1055  {
1056  layerEnum.Undefined( UNDEFINED_LAYER );
1057 
1058  for( LSEQ seq = LSET::AllLayersMask().Seq(); seq; ++seq )
1059  layerEnum.Map( *seq, LSET::Name( *seq ) );
1060  }
1061 
1063 
1064  // Track
1065  REGISTER_TYPE( TRACK );
1067 
1068  propMgr.AddProperty( new PROPERTY<TRACK, int>( _( "Width" ),
1070  propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _( "Position X" ),
1071  new PROPERTY<TRACK, int, BOARD_ITEM>( _( "Origin X" ),
1073  propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _( "Position Y" ),
1074  new PROPERTY<TRACK, int, BOARD_ITEM>( _( "Origin Y" ),
1076  propMgr.AddProperty( new PROPERTY<TRACK, int>( _( "End X" ),
1078  propMgr.AddProperty( new PROPERTY<TRACK, int>( _( "End Y" ),
1080 
1081  // Via
1082  REGISTER_TYPE( VIA );
1084 
1085  // TODO layerset for vias?
1086  // TODO test drill, use getdrillvalue?
1087  propMgr.ReplaceProperty( TYPE_HASH( TRACK ), _( "Width" ),
1088  new PROPERTY<VIA, int, TRACK>( _( "Diameter" ),
1090  propMgr.AddProperty( new PROPERTY<VIA, int>( _( "Drill" ),
1092  propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _( "Layer" ),
1093  new PROPERTY_ENUM<VIA, PCB_LAYER_ID, BOARD_ITEM>( _( "Layer Top" ),
1095  propMgr.AddProperty( new PROPERTY_ENUM<VIA, PCB_LAYER_ID>( _( "Layer Bottom" ),
1097  propMgr.AddProperty( new PROPERTY_ENUM<VIA, VIATYPE>( _( "Via Type" ),
1099  }
1100 } _TRACK_VIA_DESC;
1101 
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:133
virtual void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:749
#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:524
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:265
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:211
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
Return the name of a aLayer.
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
bool HasMin() const
Definition: drc_rule.h:78
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a std::bitset of all layers on which the item physically resides.
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,...
MINOPTMAX< int > & Value()
Definition: drc_rule.h:133
NETINFO_ITEM * GetNet() const
Function GetNet Returns NET_INFO object for a given item.
const wxPoint & GetStart() const
Definition: class_track.h:116
const wxString & GetName() const
Definition: netclass.h:96
ENUM_MAP & Undefined(T aValue)
Definition: property.h:531
NETCLASS * GetNetClass() const
Function GetNetClassPtr returns the NETCLASS for this item.
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Definition: lset.cpp:520
bool operator()(const TRACK *aFirst, const TRACK *aSecond) const
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:517
void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on.
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:50
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 m_RemoveUnconnectedLayer
Remove unconnected copper on a via.
Definition: class_track.h:528
virtual wxString LayerMaskDescribe() const
Helper function Return a string (to be shown to the user) describing a layer mask.
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:274
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: class_board.h:515
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
const BITMAP_OPAQUE add_tracks_xpm[1]
Definition: add_tracks.cpp:31
Definition: color4d.h:44
T Min() const
Definition: drc_rule.h:74
wxPGChoices & Choices()
Definition: property.h:557
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:276
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Function ViewGetLOD() Returns the level of detail (LOD) of the item.
void SetEndY(int aY)
Definition: class_track.h:119
The base class for create windows for drawing purpose.
VIA(BOARD_ITEM *aParent)
Definition: class_track.cpp:62
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
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:410
#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
T Max() const
Definition: drc_rule.h:75
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
wxString GetName() const
Definition: drc_rule.h:138
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:264
void SetWidth(int aWidth)
Definition: class_track.h:109
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
T NormalizeAngle180(T Angle)
Normalize angle to be in the -180.0 .. 180.0 range.
Definition: trigo.h:364
const INSPECTOR_FUNC & INSPECTOR
Definition: base_struct.h:105
#define IS_DRAGGED
Item being dragged.
Definition: base_struct.h:119
PCB_LAYER_ID m_Layer
virtual int GetClearance(PCB_LAYER_ID aLayer, BOARD_ITEM *aItem=nullptr, wxString *aSource=nullptr) const
Function GetClearance returns the clearance in internal units.
wxString LayerMaskDescribe() const override
Helper function Return a string (to be shown to the user) describing a layer mask.
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.
int GetMinAnnulus(PCB_LAYER_ID aLayer, wxString *aSource) const
LSET is a set of PCB_LAYER_IDs.
const wxPoint & GetMid() const
Definition: class_track.h:301
int GetY() const
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition: lset.cpp:81
void GetMsgPanelInfoBase_Common(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList)
#define IS_DELETED
Definition: base_struct.h:120
wxPoint m_End
Line end point.
Definition: class_track.h:266
to draw usual through hole vias
int GetEndY() const
Definition: class_track.h:122
int m_Drill
Definition: class_track.h:526
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
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: class_board.h:343
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:79
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:522
void SetY(int aY)
#define TRACK_LOCKED
Pcbnew: track locked: protected from global deletion.
Definition: base_struct.h:131
static LSET AllLayersMask()
Definition: lset.cpp:786
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 ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Function ViewGetLOD() Returns the level of detail (LOD) of the item.
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.
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
void SetDrillDefault()
Function SetDrillDefault sets the drill value for vias to the default value UNDEFINED_DRILL_DIAMETER.
Definition: class_track.h:504
#define TRACK_AR
Pcbnew: autorouted track.
Definition: base_struct.h:132
int LAYER_NUM
This can be replaced with int and removed.
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const override
Function GetEffectiveShape Some pad shapes can be complex (rounded/chamfered rectangle),...
wxString GetNetnameMsg() const
Function GetNetnameMsg.
const KIID m_Uuid
Definition: base_struct.h:162
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:302
Definition: color4d.h:56
virtual void SetLayerSet(LSET aLayers) override
bool HasMax() const
Definition: drc_rule.h:79
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: class_track.cpp:96
int GetX() const
int GetWidth() const
Definition: class_track.h:110
Meta control for all vias opacity/visibility.
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:201
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:56
Information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:176
#define _(s)
Definition: 3d_actions.cpp:33
void SetTopLayer(PCB_LAYER_ID aLayer)
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:152
T NormalizeAnglePos(T Angle)
Normalize angle to be in the 0.0 .
Definition: trigo.h:267
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const override
Function GetEffectiveShape Some pad shapes can be complex (rounded/chamfered rectangle),...
double GetArcAngleEnd() const
STATUS_FLAGS m_Flags
Definition: base_struct.h:176
void AddProperty(PROPERTY_BASE *aProperty)
Registers a property.
int GetCopperLayerCount() const
#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:483
NETCLASS * GetDefault() const
Function GetDefault.
VIATYPE GetViaType() const
Definition: class_track.h:381
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:113
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:151
void ReplaceProperty(size_t aBase, const wxString &aName, PROPERTY_BASE *aNew)
Replaces an existing property for a specific type.
bool m_KeepTopBottomLayer
Keep the top and bottom annular rings.
Definition: class_track.h:529
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:43
virtual std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER) const override
Function GetEffectiveShape Some pad shapes can be complex (rounded/chamfered rectangle),...
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:405
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:523
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:382
static constexpr int Millimeter2iu(double mm)
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:121
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:347
const BITMAP_OPAQUE via_xpm[1]
void SetEndX(int aX)
Definition: class_track.h:118
std::shared_ptr< DRC_ENGINE > m_DRCEngine
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
bool IsPadOnLayer(int aLayer) const
Checks to see whether the via should have a pad on the specific layer.
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:73
bool IsNetnameLayer(LAYER_NUM aLayer)
Test whether a layer is a netname layer.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
#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:400
int GetLocalClearance(wxString *aSource) const override
Function GetLocalClearance returns any local clearance overrides set in the "classic" (ie: pre-rule) ...