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