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