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