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