KiCad PCB EDA Suite
class_track.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
5  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
6  * Copyright (C) 2012 Wayne Stambaugh <stambaughw@verizon.net>
7  * Copyright (C) 1992-2016 KiCad Developers, see AUTHORS.txt for contributors.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 2
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
27 #include <fctsys.h>
28 #include <gr_basic.h>
29 #include <common.h>
30 #include <trigo.h>
31 #include <macros.h>
32 #include <pcb_screen.h>
33 #include <gr_text.h>
34 #include <pcb_base_frame.h>
35 #include <class_board.h>
36 #include <class_track.h>
37 #include <pcbnew.h>
38 #include <base_units.h>
39 #include <msgpanel.h>
40 #include <bitmaps.h>
41 #include <view/view.h>
42 
48 static bool ShowClearance( PCB_DISPLAY_OPTIONS* aDisplOpts, const TRACK* aTrack )
49 {
50  // maybe return true for tracks and vias, not for zone segments
51  return IsCopperLayer( aTrack->GetLayer() )
52  && ( aTrack->Type() == PCB_TRACE_T || aTrack->Type() == PCB_VIA_T )
54  && ( aTrack->IsDragging() || aTrack->IsMoving() || aTrack->IsNew() ) )
56  );
57 
58 }
59 
60 
61 TRACK::TRACK( BOARD_ITEM* aParent, KICAD_T idtype ) :
62  BOARD_CONNECTED_ITEM( aParent, idtype )
63 {
64  m_Width = Millimeter2iu( 0.2 );
65 }
66 
67 
69 {
70  return new TRACK( *this );
71 }
72 
73 
74 VIA::VIA( BOARD_ITEM* aParent ) :
75  TRACK( aParent, PCB_VIA_T )
76 {
80 }
81 
82 
84 {
85  return new VIA( *this );
86 }
87 
88 
89 wxString VIA::GetSelectMenuText( EDA_UNITS_T aUnits ) const
90 {
91  wxString format;
92  BOARD* board = GetBoard();
93 
94  switch( GetViaType() )
95  {
96  case VIA_BLIND_BURIED:
97  format = _( "Blind/Buried Via %s %s on %s - %s" );
98  break;
99  case VIA_MICROVIA:
100  format = _( "Micro Via %s %s on %s - %s" );
101  break;
102  // else say nothing about normal (through) vias
103  default:
104  format = _( "Via %s %s on %s - %s" );
105  break;
106  }
107 
108  if( board )
109  {
110  // say which layers, only two for now
111  PCB_LAYER_ID topLayer;
112  PCB_LAYER_ID botLayer;
113  LayerPair( &topLayer, &botLayer );
114  return wxString::Format( format.GetData(),
115  MessageTextFromValue( aUnits, m_Width ),
116  GetNetnameMsg(),
117  board->GetLayerName( topLayer ),
118  board->GetLayerName( botLayer ) );
119 
120  }
121  else
122  {
123  return wxString::Format( format.GetData(),
124  MessageTextFromValue( aUnits, m_Width ),
125  GetNetnameMsg(),
126  wxT( "??" ),
127  wxT( "??" ) );
128  }
129 }
130 
131 
132 BITMAP_DEF VIA::GetMenuImage() const
133 {
134  return via_xpm;
135 }
136 
137 
139 {
140  // Currently tracks have no specific clearance parameter on a per track or per
141  // segment basis. The NETCLASS clearance is used.
142  return BOARD_CONNECTED_ITEM::GetClearance( aItem );
143 }
144 
145 
147 {
148  if( m_Drill > 0 ) // Use the specific value.
149  return m_Drill;
150 
151  // Use the default value from the Netclass
152  NETCLASSPTR netclass = GetNetClass();
153 
154  if( GetViaType() == VIA_MICROVIA )
155  return netclass->GetuViaDrill();
156 
157  return netclass->GetViaDrill();
158 }
159 
160 
161 STATUS_FLAGS TRACK::IsPointOnEnds( const wxPoint& point, int min_dist ) const
162 {
163  STATUS_FLAGS result = 0;
164 
165  if( min_dist < 0 )
166  min_dist = m_Width / 2;
167 
168  if( min_dist == 0 )
169  {
170  if( m_Start == point )
171  result |= STARTPOINT;
172 
173  if( m_End == point )
174  result |= ENDPOINT;
175  }
176  else
177  {
178  double dist = GetLineLength( m_Start, point );
179 
180  if( min_dist >= KiROUND( dist ) )
181  result |= STARTPOINT;
182 
183  dist = GetLineLength( m_End, point );
184 
185  if( min_dist >= KiROUND( dist ) )
186  result |= ENDPOINT;
187  }
188 
189  return result;
190 }
191 
192 
194 {
195  // end of track is round, this is its radius, rounded up
196  int radius = ( m_Width + 1 ) / 2;
197  int ymax, xmax, ymin, xmin;
198 
199  if( Type() == PCB_VIA_T )
200  {
201  ymax = m_Start.y;
202  xmax = m_Start.x;
203 
204  ymin = m_Start.y;
205  xmin = m_Start.x;
206  }
207  else
208  {
209  ymax = std::max( m_Start.y, m_End.y );
210  xmax = std::max( m_Start.x, m_End.x );
211 
212  ymin = std::min( m_Start.y, m_End.y );
213  xmin = std::min( m_Start.x, m_End.x );
214  }
215 
216  ymax += radius;
217  xmax += radius;
218 
219  ymin -= radius;
220  xmin -= radius;
221 
222  // return a rectangle which is [pos,dim) in nature. therefore the +1
223  EDA_RECT ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
224 
225  return ret;
226 }
227 
228 
229 void TRACK::Rotate( const wxPoint& aRotCentre, double aAngle )
230 {
231  RotatePoint( &m_Start, aRotCentre, aAngle );
232  RotatePoint( &m_End, aRotCentre, aAngle );
233 }
234 
235 
236 void TRACK::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
237 {
238  if( aFlipLeftRight )
239  {
240  m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
241  m_End.x = aCentre.x - ( m_End.x - aCentre.x );
242  }
243  else
244  {
245  m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
246  m_End.y = aCentre.y - ( m_End.y - aCentre.y );
247  }
248 
249  int copperLayerCount = GetBoard()->GetCopperLayerCount();
250  SetLayer( FlipLayer( GetLayer(), copperLayerCount ) );
251 }
252 
253 
254 void VIA::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
255 {
256  if( aFlipLeftRight )
257  {
258  m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
259  m_End.x = aCentre.x - ( m_End.x - aCentre.x );
260  }
261  else
262  {
263  m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
264  m_End.y = aCentre.y - ( m_End.y - aCentre.y );
265  }
266 
267  if( GetViaType() != VIA_THROUGH )
268  {
269  int copperLayerCount = GetBoard()->GetCopperLayerCount();
270  PCB_LAYER_ID top_layer;
271  PCB_LAYER_ID bottom_layer;
272  LayerPair( &top_layer, &bottom_layer );
273  top_layer = FlipLayer( top_layer, copperLayerCount );
274  bottom_layer = FlipLayer( bottom_layer, copperLayerCount );
275  SetLayerPair( top_layer, bottom_layer );
276  }
277 }
278 
279 
280 // see class_track.h
281 SEARCH_RESULT TRACK::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
282 {
283  KICAD_T stype = *scanTypes;
284 
285  // If caller wants to inspect my type
286  if( stype == Type() )
287  {
288  if( SEARCH_QUIT == inspector( this, testData ) )
289  return SEARCH_QUIT;
290  }
291 
292  return SEARCH_CONTINUE;
293 }
294 
295 
296 bool VIA::IsOnLayer( PCB_LAYER_ID layer_number ) const
297 {
298  PCB_LAYER_ID bottom_layer, top_layer;
299 
300  LayerPair( &top_layer, &bottom_layer );
301 
302  wxASSERT( top_layer <= bottom_layer );
303 
304  if( top_layer <= layer_number && layer_number <= bottom_layer )
305  return true;
306  else
307  return false;
308 }
309 
310 
312 {
313  if( GetViaType() == VIA_THROUGH )
314  return LSET::AllCuMask();
315 
316  // VIA_BLIND_BURIED or VIA_MICRVIA:
317 
318  LSET layermask;
319 
320  wxASSERT( m_Layer <= m_BottomLayer );
321 
322  // PCB_LAYER_IDs are numbered from front to back, this is top to bottom.
323  for( LAYER_NUM id = m_Layer; id <= m_BottomLayer; ++id )
324  {
325  layermask.set( id );
326  }
327 
328  return layermask;
329 }
330 
331 
332 void VIA::SetLayerPair( PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer )
333 {
334 
335  m_Layer = aTopLayer;
336  m_BottomLayer = aBottomLayer;
337  SanitizeLayers();
338 }
339 
340 
342 {
343  m_Layer = aLayer;
344 }
345 
346 
348 {
349  m_BottomLayer = aLayer;
350 }
351 
352 
353 void VIA::LayerPair( PCB_LAYER_ID* top_layer, PCB_LAYER_ID* bottom_layer ) const
354 {
355  PCB_LAYER_ID t_layer = F_Cu;
356  PCB_LAYER_ID b_layer = B_Cu;
357 
358  if( GetViaType() != VIA_THROUGH )
359  {
360  b_layer = m_BottomLayer;
361  t_layer = m_Layer;
362 
363  if( b_layer < t_layer )
364  std::swap( b_layer, t_layer );
365  }
366 
367  if( top_layer )
368  *top_layer = t_layer;
369 
370  if( bottom_layer )
371  *bottom_layer = b_layer;
372 }
373 
374 
376 {
377  return m_Layer;
378 }
379 
380 
382 {
383  return m_BottomLayer;
384 }
385 
386 
388 {
389  if( GetViaType() == VIA_THROUGH )
390  {
391  m_Layer = F_Cu;
393  }
394 
395  if( m_BottomLayer < m_Layer )
396  std::swap( m_BottomLayer, m_Layer );
397 }
398 
399 
401 {
402  TRACK* Track = this;
403  int ii = 0;
404 
405  if( NetCode == -1 )
406  NetCode = GetNetCode();
407 
408  while( Track != NULL )
409  {
410  if( Track->GetNetCode() > NetCode )
411  break;
412 
413  if( Track->GetNetCode() == NetCode )
414  {
415  ii++;
416  break;
417  }
418 
419  Track = (TRACK*) Track->Pnext;
420  }
421 
422  if( ii )
423  return Track;
424  else
425  return NULL;
426 }
427 
428 
430 {
431  TRACK* NextS, * Track = this;
432  int ii = 0;
433 
434  if( Track == NULL )
435  return NULL;
436 
437  if( NetCode == -1 )
438  NetCode = GetNetCode();
439 
440  while( Track != NULL )
441  {
442  NextS = (TRACK*) Track->Pnext;
443 
444  if( Track->GetNetCode() == NetCode )
445  ii++;
446 
447  if( NextS == NULL )
448  break;
449 
450  if( NextS->GetNetCode() > NetCode )
451  break;
452 
453  Track = NextS;
454  }
455 
456  if( ii )
457  return Track;
458  else
459  return NULL;
460 }
461 
462 void TRACK::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset )
463 {
464  BOARD* brd = GetBoard();
465  auto color = aFrame->Settings().Colors().GetLayerColor( m_Layer );
466 
467  if( !brd->IsLayerVisible( m_Layer ) || !brd->IsElementVisible( LAYER_TRACKS ) )
468  return;
469 
470  auto displ_opts = (PCB_DISPLAY_OPTIONS*)( aFrame->GetDisplayOptions() );
471 
472  color.a = 0.588;
473 
474  // Draw track as line if width <= 1pixel:
475  if( aDC->LogicalToDeviceXRel( m_Width ) <= 1 )
476  {
477  GRLine( nullptr, aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
478  return;
479  }
480 
481  if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
482  {
483  GRCSegm( nullptr, aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
484  }
485  else
486  {
487  GRFillCSegm( nullptr, aDC, m_Start.x + aOffset.x, m_Start.y + aOffset.y,
488  m_End.x + aOffset.x, m_End.y + aOffset.y, m_Width, color );
489  }
490 }
491 
492 
493 void TRACK::ViewGetLayers( int aLayers[], int& aCount ) const
494 {
495  // Show the track and its netname on different layers
496  aLayers[0] = GetLayer();
497  aLayers[1] = GetNetnameLayer( aLayers[0] );
498  aCount = 2;
499 }
500 
501 
502 unsigned int TRACK::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
503 {
504  const int HIDE = std::numeric_limits<unsigned int>::max();
505 
506  if( !aView->IsLayerVisible( LAYER_TRACKS ) )
507  return HIDE;
508 
509  // Netnames will be shown only if zoom is appropriate
510  if( IsNetnameLayer( aLayer ) )
511  {
512  return ( Millimeter2iu( 4 ) / ( m_Width + 1 ) );
513  }
514 
515  // Other layers are shown without any conditions
516  return 0;
517 }
518 
519 
520 const BOX2I TRACK::ViewBBox() const
521 {
522  BOX2I bbox = GetBoundingBox();
523  bbox.Inflate( 2 * GetClearance() );
524  return bbox;
525 }
526 
527 
528 void VIA::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset )
529 {
530  int radius;
531  int fillvia = 0;
532  PCB_SCREEN* screen = aFrame->GetScreen();
533  PCB_DISPLAY_OPTIONS* displ_opts = (PCB_DISPLAY_OPTIONS*) aFrame->GetDisplayOptions();
534  BOARD* brd = GetBoard();
536 
537  if( displ_opts->m_DisplayViaFill == FILLED )
538  fillvia = 1;
539 
540  if( !brd->IsElementVisible( LAYER_VIAS + GetViaType() ) )
541  return;
542 
543  // Only draw the via if at least one of the layers it crosses is being displayed
544  if( !( brd->GetVisibleLayers() & GetLayerSet() ).any() )
545  return;
546 
547  color.a = 0.588;
548 
549  radius = m_Width >> 1;
550  // for small via size on screen (radius < 4 pixels) draw a simplified shape
551 
552  int radius_in_pixels = aDC->LogicalToDeviceXRel( radius );
553  bool fast_draw = false;
554 
555  // Vias are drawn as a filled circle or a double circle. The hole will be drawn later
556  int drill_radius = GetDrillValue() / 2;
557  int inner_radius = radius - aDC->DeviceToLogicalXRel( 2 );
558 
559  if( radius_in_pixels < MIN_VIA_DRAW_SIZE )
560  {
561  fast_draw = true;
562  fillvia = false;
563  }
564 
565  if( fillvia )
566  {
567  GRFilledCircle( nullptr, aDC, m_Start + aOffset, radius, color );
568  }
569  else
570  {
571  GRCircle( nullptr, aDC, m_Start + aOffset, radius, 0, color );
572 
573  if ( fast_draw )
574  return;
575 
576  GRCircle( nullptr, aDC, m_Start + aOffset, inner_radius, 0, color );
577  }
578 
579  if( fillvia )
580  {
581  bool blackpenstate = false;
582 
583  if( screen->m_IsPrinting )
584  {
585  blackpenstate = GetGRForceBlackPenState();
586  GRForceBlackPen( false );
587  color = WHITE;
588  }
589  else
590  {
591  color = BLACK; // or DARKGRAY;
592  }
593 
594  // Draw hole if the radius is > 1pixel.
595  if( aDC->LogicalToDeviceXRel( drill_radius ) > 1 )
596  GRFilledCircle( nullptr, aDC, m_Start.x + aOffset.x, m_Start.y + aOffset.y,
597  drill_radius, 0, color, color );
598 
599  if( screen->m_IsPrinting )
600  GRForceBlackPen( blackpenstate );
601  }
602  else
603  {
604  if( drill_radius < inner_radius ) // We can show the via hole
605  GRCircle( nullptr, aDC, m_Start + aOffset, drill_radius, 0, color );
606  }
607 
608  if( ShowClearance( displ_opts, this ) )
609  {
610  GRCircle( nullptr, aDC, m_Start + aOffset, radius + GetClearance(), 0, color );
611  }
612 
613  // for Micro Vias, draw a partial cross : X on component layer, or + on copper layer
614  // (so we can see 2 superimposed microvias ):
615  if( GetViaType() == VIA_MICROVIA )
616  {
617  int ax, ay, bx, by;
618 
619  if( IsOnLayer( B_Cu ) )
620  {
621  ax = radius; ay = 0;
622  bx = drill_radius; by = 0;
623  }
624  else
625  {
626  ax = ay = (radius * 707) / 1000;
627  bx = by = (drill_radius * 707) / 1000;
628  }
629 
630  // lines '|' or '\'
631  GRLine( nullptr, aDC, m_Start.x + aOffset.x - ax, m_Start.y + aOffset.y - ay,
632  m_Start.x + aOffset.x - bx, m_Start.y + aOffset.y - by, 0, color );
633  GRLine( nullptr, aDC, m_Start.x + aOffset.x + bx, m_Start.y + aOffset.y + by,
634  m_Start.x + aOffset.x + ax, m_Start.y + aOffset.y + ay, 0, color );
635 
636  // lines - or '/'
637  GRLine( nullptr, aDC, m_Start.x + aOffset.x + ay, m_Start.y + aOffset.y - ax,
638  m_Start.x + aOffset.x + by, m_Start.y + aOffset.y - bx, 0, color );
639  GRLine( nullptr, aDC, m_Start.x + aOffset.x - by, m_Start.y + aOffset.y + bx,
640  m_Start.x + aOffset.x - ay, m_Start.y + aOffset.y + ax, 0, color );
641  }
642 
643  // for Buried Vias, draw a partial line : orient depending on layer pair
644  // (so we can see superimposed buried vias ):
645  if( GetViaType() == VIA_BLIND_BURIED )
646  {
647  int ax = 0, ay = radius, bx = 0, by = drill_radius;
648  PCB_LAYER_ID layer_top, layer_bottom;
649 
650  LayerPair( &layer_top, &layer_bottom );
651 
652  // lines for the top layer
653  RotatePoint( &ax, &ay, layer_top * 3600.0 / brd->GetCopperLayerCount( ) );
654  RotatePoint( &bx, &by, layer_top * 3600.0 / brd->GetCopperLayerCount( ) );
655  GRLine( nullptr, aDC, m_Start.x + aOffset.x - ax, m_Start.y + aOffset.y - ay,
656  m_Start.x + aOffset.x - bx, m_Start.y + aOffset.y - by, 0, color );
657 
658  // lines for the bottom layer
659  ax = 0; ay = radius; bx = 0; by = drill_radius;
660  RotatePoint( &ax, &ay, layer_bottom * 3600.0 / brd->GetCopperLayerCount( ) );
661  RotatePoint( &bx, &by, layer_bottom * 3600.0 / brd->GetCopperLayerCount( ) );
662  GRLine( nullptr, aDC, m_Start.x + aOffset.x - ax, m_Start.y + aOffset.y - ay,
663  m_Start.x + aOffset.x - bx, m_Start.y + aOffset.y - by, 0, color );
664  }
665 
666  // Display the short netname:
668  return;
669 
670  if( displ_opts->m_DisplayNetNamesMode == 0 || displ_opts->m_DisplayNetNamesMode == 1 )
671  return;
672 
673  NETINFO_ITEM* net = GetNet();
674 
675  if( net == NULL )
676  return;
677 
678  wxString text = UnescapeString( net->GetShortNetname() );
679  int len = text.Len();
680 
681  if( len > 0 )
682  {
683  // calculate a good size for the text
684  int tsize = m_Width / len;
685 
686  if( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE )
687  {
688  tsize = (tsize * 7) / 10; // small reduction to give a better look, inside via
689 
690  GRHaloText( aDC, m_Start, color, WHITE, BLACK, text, 0, wxSize( tsize, tsize ),
691  GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize/7, false, false );
692  }
693  }
694 }
695 
696 
697 void VIA::ViewGetLayers( int aLayers[], int& aCount ) const
698 {
699  aLayers[0] = LAYER_VIAS_HOLES;
700  aLayers[1] = LAYER_VIAS_NETNAMES;
701  aCount = 3;
702 
703  // Just show it on common via & via holes layers
704  switch( GetViaType() )
705  {
706  case VIA_THROUGH:
707  aLayers[2] = LAYER_VIA_THROUGH;
708  break;
709 
710  case VIA_BLIND_BURIED:
711  aLayers[2] = LAYER_VIA_BBLIND;
712  aLayers[3] = m_Layer;
713  aLayers[4] = m_BottomLayer;
714  aCount += 2;
715  break;
716 
717  case VIA_MICROVIA:
718  aLayers[2] = LAYER_VIA_MICROVIA;
719  break;
720 
721  default:
722  aLayers[2] = LAYER_GP_OVERLAY;
723  wxASSERT( false );
724  break;
725  }
726 }
727 
728 
729 unsigned int VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
730 {
731  constexpr unsigned int HIDE = std::numeric_limits<unsigned int>::max();
732 
733  // Netnames will be shown only if zoom is appropriate
734  if( IsNetnameLayer( aLayer ) )
735  return m_Width == 0 ? HIDE : ( Millimeter2iu( 10 ) / m_Width );
736 
737 
738  BOARD* board = GetBoard();
739 
740  // Only draw the via if at least one of the layers it crosses is being displayed
741  if( board && ( board->GetVisibleLayers() & GetLayerSet() ).any() )
742  return 0;
743 
744  return HIDE;
745 }
746 
747 
748 // see class_track.h
749 void TRACK::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList )
750 {
751  wxString msg;
752  BOARD* board = GetBoard();
753 
754  // Display basic infos
755  GetMsgPanelInfoBase( aUnits, aList );
756 
757  // Display full track length (in Pcbnew)
758  if( board )
759  {
760  int count;
761  double trackLen;
762  double lenPadToDie;
763 
764  std::tie( count, trackLen, lenPadToDie ) = board->GetTrackLength( *this );
765 
766  msg = MessageTextFromValue( aUnits, trackLen );
767  aList.push_back( MSG_PANEL_ITEM( _( "Length" ), msg, DARKCYAN ) );
768 
769  if( lenPadToDie != 0 )
770  {
771  msg = MessageTextFromValue( aUnits, trackLen + lenPadToDie );
772  aList.push_back( MSG_PANEL_ITEM( _( "Full Length" ), msg, DARKCYAN ) );
773 
774  msg = MessageTextFromValue( aUnits, lenPadToDie, true );
775  aList.push_back( MSG_PANEL_ITEM( _( "Pad To Die Length" ), msg, DARKCYAN ) );
776  }
777  }
778 
779  NETCLASSPTR netclass = GetNetClass();
780 
781  if( netclass )
782  {
783  aList.push_back( MSG_PANEL_ITEM( _( "NC Name" ), netclass->GetName(), DARKMAGENTA ) );
784 
785  msg = MessageTextFromValue( aUnits, netclass->GetClearance(), true );
786  aList.push_back( MSG_PANEL_ITEM( _( "NC Clearance" ), msg, DARKMAGENTA ) );
787 
788  msg = MessageTextFromValue( aUnits, netclass->GetTrackWidth(), true );
789  aList.push_back( MSG_PANEL_ITEM( _( "NC Width" ), msg, DARKMAGENTA ) );
790 
791  msg = MessageTextFromValue( aUnits, netclass->GetViaDiameter(), true );
792  aList.push_back( MSG_PANEL_ITEM( _( "NC Via Size" ), msg, DARKMAGENTA ) );
793 
794  msg = MessageTextFromValue( aUnits, netclass->GetViaDrill(), true );
795  aList.push_back( MSG_PANEL_ITEM( _( "NC Via Drill"), msg, DARKMAGENTA ) );
796  }
797 }
798 
799 void TRACK::GetMsgPanelInfoBase_Common( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList )
800 {
801  wxString msg;
802 
803  // Display Net Name
804  if( GetBoard() )
805  {
806  NETINFO_ITEM* net = GetNet();
807 
808  if( net )
809  msg = UnescapeString( net->GetNetname() );
810  else
811  msg = wxT( "<no name>" );
812 
813  aList.push_back( MSG_PANEL_ITEM( _( "NetName" ), msg, RED ) );
814 
815  // Display net code : (useful in test or debug)
816  msg.Printf( wxT( "%d" ), GetNetCode() );
817  aList.push_back( MSG_PANEL_ITEM( _( "NetCode" ), msg, RED ) );
818  }
819 
820 #if defined(DEBUG)
821 
822  // Display the flags
823  msg.Printf( wxT( "0x%08X" ), m_Flags );
824  aList.push_back( MSG_PANEL_ITEM( wxT( "Flags" ), msg, BLUE ) );
825 
826 #if 0
827  // Display start and end pointers:
828  msg.Printf( wxT( "%p" ), start );
829  aList.push_back( MSG_PANEL_ITEM( wxT( "start ptr" ), msg, BLUE ) );
830  msg.Printf( wxT( "%p" ), end );
831  aList.push_back( MSG_PANEL_ITEM( wxT( "end ptr" ), msg, BLUE ) );
832  // Display this ptr
833  msg.Printf( wxT( "%p" ), this );
834  aList.push_back( MSG_PANEL_ITEM( wxT( "this" ), msg, BLUE ) );
835 #endif
836 
837 #if 0
838  // Display start and end positions:
839  msg.Printf( wxT( "%d %d" ), m_Start.x, m_Start.y );
840  aList.push_back( MSG_PANEL_ITEM( wxT( "Start pos" ), msg, BLUE ) );
841  msg.Printf( wxT( "%d %d" ), m_End.x, m_End.y );
842  aList.push_back( MSG_PANEL_ITEM( wxT( "End pos" ), msg, BLUE ) );
843 #endif
844 
845 #endif // defined(DEBUG)
846 
847  // Display the State member
848  msg = wxT( ". . " );
849 
850  if( GetState( TRACK_LOCKED ) )
851  msg[0] = 'L';
852 
853  if( GetState( TRACK_AR ) )
854  msg[2] = 'A';
855 
856  aList.push_back( MSG_PANEL_ITEM( _( "Status" ), msg, MAGENTA ) );
857 }
858 
859 void TRACK::GetMsgPanelInfoBase( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList )
860 {
861  wxString msg;
862  BOARD* board = GetBoard();
863 
864  aList.push_back( MSG_PANEL_ITEM( _( "Type" ), _( "Track" ), DARKCYAN ) );
865 
866  GetMsgPanelInfoBase_Common( aUnits, aList );
867 
868  // Display layer
869  if( board )
870  msg = board->GetLayerName( m_Layer );
871  else
872  msg.Printf(wxT("%d"), m_Layer );
873 
874  aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), msg, BROWN ) );
875 
876  // Display width
877  msg = MessageTextFromValue( aUnits, m_Width, true );
878 
879  aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, DARKCYAN ) );
880 
881  // Display segment length
882  msg = ::MessageTextFromValue( aUnits, GetLength() );
883  aList.push_back( MSG_PANEL_ITEM( _( "Segment Length" ), msg, DARKCYAN ) );
884 }
885 
886 void VIA::GetMsgPanelInfoBase( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList )
887 {
888  wxString msg;
889  BOARD* board = GetBoard();
890 
891  switch( GetViaType() )
892  {
893  default:
894  case VIA_NOT_DEFINED:
895  msg = wxT( "???" ); // Not used yet, does not exist currently
896  break;
897 
898  case VIA_MICROVIA:
899  msg = _( "Micro Via" ); // from external layer (TOP or BOTTOM) from
900  // the near neighbor inner layer only
901  break;
902 
903  case VIA_BLIND_BURIED:
904  msg = _( "Blind/Buried Via" ); // from inner or external to inner
905  // or external layer (no restriction)
906  break;
907 
908  case VIA_THROUGH:
909  msg = _( "Through Via" ); // Usual via (from TOP to BOTTOM layer only )
910  break;
911  }
912 
913  aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, DARKCYAN ) );
914 
915  GetMsgPanelInfoBase_Common( aUnits, aList );
916 
917 
918  // Display layer pair
919  PCB_LAYER_ID top_layer, bottom_layer;
920 
921  LayerPair( &top_layer, &bottom_layer );
922 
923  if( board )
924  msg = board->GetLayerName( top_layer ) + wxT( "/" )
925  + board->GetLayerName( bottom_layer );
926  else
927  msg.Printf( wxT( "%d/%d" ), top_layer, bottom_layer );
928 
929  aList.push_back( MSG_PANEL_ITEM( _( "Layers" ), msg, BROWN ) );
930 
931  // Display width
932  msg = MessageTextFromValue( aUnits, m_Width, true );
933 
934  // Display diameter value:
935  aList.push_back( MSG_PANEL_ITEM( _( "Diameter" ), msg, DARKCYAN ) );
936 
937  // Display drill value
938  msg = MessageTextFromValue( aUnits, GetDrillValue() );
939 
940  wxString title = _( "Drill" );
941  title += wxT( " " );
942 
943  bool drl_specific = true;
944 
945  if( GetBoard() )
946  {
947  NETINFO_ITEM* net = GetNet();
948  int drill_class_value = 0;
949 
950  if( net )
951  {
952  if( GetViaType() == VIA_MICROVIA )
953  drill_class_value = net->GetMicroViaDrillSize();
954  else
955  drill_class_value = net->GetViaDrillSize();
956  }
957 
958  drl_specific = GetDrillValue() != drill_class_value;
959  }
960 
961 
962  if( drl_specific )
963  title += _( "(Specific)" );
964  else
965  title += _( "(NetClass)" );
966 
967  aList.push_back( MSG_PANEL_ITEM( title, msg, RED ) );
968 }
969 
970 
971 bool TRACK::HitTest( const wxPoint& aPosition, int aAccuracy ) const
972 {
973  return TestSegmentHit( aPosition, m_Start, m_End, aAccuracy + ( m_Width / 2 ) );
974 }
975 
976 bool VIA::HitTest( const wxPoint& aPosition, int aAccuracy ) const
977 {
978  int max_dist = aAccuracy + ( m_Width / 2 );
979 
980  // rel_pos is aPosition relative to m_Start (or the center of the via)
981  wxPoint rel_pos = aPosition - m_Start;
982  double dist = (double) rel_pos.x * rel_pos.x + (double) rel_pos.y * rel_pos.y;
983  return dist <= (double) max_dist * max_dist;
984 }
985 
986 
987 bool TRACK::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
988 {
989  EDA_RECT arect = aRect;
990  arect.Inflate( aAccuracy );
991 
992  if( aContained )
993  /* Tracks are a special case:
994  * they are considered inside the rect if one end is inside the rect */
995  return arect.Contains( GetStart() ) || arect.Contains( GetEnd() );
996  else
997  return arect.Intersects( GetStart(), GetEnd() );
998 }
999 
1000 bool VIA::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
1001 {
1002  EDA_RECT box;
1003  EDA_RECT arect = aRect;
1004  arect.Inflate( aAccuracy );
1005 
1006  box.SetOrigin( GetStart() );
1007  box.Inflate( GetWidth() / 2 );
1008 
1009  if( aContained )
1010  {
1011  return arect.Contains( box );
1012  }
1013  else
1014  {
1015  return arect.IntersectsCircle( GetStart(), GetWidth() / 2 );
1016  }
1017 }
1018 
1019 
1020 wxString TRACK::GetSelectMenuText( EDA_UNITS_T aUnits ) const
1021 {
1022  return wxString::Format( _("Track %s %s on %s, length: %s" ),
1023  MessageTextFromValue( aUnits, m_Width ),
1024  GetNetnameMsg(),
1025  GetLayerName(),
1026  MessageTextFromValue( aUnits, GetLength() ) );
1027 }
1028 
1029 
1030 BITMAP_DEF TRACK::GetMenuImage() const
1031 {
1032  return add_tracks_xpm;
1033 }
1034 
1036 {
1037  assert( aImage->Type() == PCB_TRACE_T );
1038 
1039  std::swap( *((TRACK*) this), *((TRACK*) aImage) );
1040 }
1041 
1042 void VIA::SwapData( BOARD_ITEM* aImage )
1043 {
1044  assert( aImage->Type() == PCB_VIA_T );
1045 
1046  std::swap( *((VIA*) this), *((VIA*) aImage) );
1047 }
1048 
1049 #if defined(DEBUG)
1050 
1051 wxString TRACK::ShowState( int stateBits )
1052 {
1053  wxString ret;
1054 
1055  if( stateBits & IS_LINKED )
1056  ret << wxT( " | IS_LINKED" );
1057 
1058  if( stateBits & TRACK_AR )
1059  ret << wxT( " | TRACK_AR" );
1060 
1061  if( stateBits & TRACK_LOCKED )
1062  ret << wxT( " | TRACK_LOCKED" );
1063 
1064  if( stateBits & IN_EDIT )
1065  ret << wxT( " | IN_EDIT" );
1066 
1067  if( stateBits & IS_DRAGGED )
1068  ret << wxT( " | IS_DRAGGED" );
1069 
1070  if( stateBits & DO_NOT_DRAW )
1071  ret << wxT( " | DO_NOT_DRAW" );
1072 
1073  if( stateBits & IS_DELETED )
1074  ret << wxT( " | IS_DELETED" );
1075 
1076  if( stateBits & BUSY )
1077  ret << wxT( " | BUSY" );
1078 
1079  if( stateBits & END_ONPAD )
1080  ret << wxT( " | END_ONPAD" );
1081 
1082  if( stateBits & BEGIN_ONPAD )
1083  ret << wxT( " | BEGIN_ONPAD" );
1084 
1085  if( stateBits & FLAG0 )
1086  ret << wxT( " | FLAG0" );
1087 
1088  if( stateBits & FLAG1 )
1089  ret << wxT( " | FLAG1" );
1090 
1091  return ret;
1092 }
1093 
1094 #endif
#define MIN_VIA_DRAW_SIZE
Definition: class_track.h:71
Definition: colors.h:57
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:676
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
Definition: base_struct.h:104
#define FLAG1
Pcbnew: flag used in local computations.
Definition: base_struct.h:123
void GetMsgPanelInfoBase_Common(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList)
void LayerPair(PCB_LAYER_ID *top_layer, PCB_LAYER_ID *bottom_layer) const
Function LayerPair Return the 2 layers used by the via (the via actually uses all layers between thes...
to draw blind/buried vias
#define IN_EDIT
Item currently edited.
Definition: base_struct.h:105
int GetNetCode() const
Function GetNetCode.
wxPoint m_Start
Line start point.
Definition: class_track.h:256
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Function GetLineLength returns the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:202
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer given by aLayer.
static const int dist[10][10]
Definition: ar_matrix.cpp:320
#define END_ONPAD
Pcbnew: flag set for track segment ending on a pad.
Definition: base_struct.h:126
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
void SetViaType(VIATYPE_T aViaType)
Definition: class_track.h:339
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:118
int GetNetnameLayer(int aLayer)
Returns a netname layer corresponding to the given layer.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
Implementation of conversion functions that require both schematic and board internal units.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
NETINFO_ITEM * GetNet() const
Function GetNet Returns NET_INFO object for a given item.
const wxPoint & GetStart() const
Definition: class_track.h:109
void GetMsgPanelInfo(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
Definition: colors.h:61
bool IsMoving() const
Definition: base_struct.h:217
int color
Definition: DXF_plotter.cpp:62
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Function FlippedLayerNumber.
Definition: lset.cpp:475
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on.
virtual EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: class_track.cpp:68
to draw via holes (pad holes do not use this layer)
LSET GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
bool IntersectsCircle(const wxPoint &aCenter, const int aRadius) const
Function IntersectsCircle tests for a common area between a circle and this rectangle.
void SetOrigin(const wxPoint &pos)
Definition: eda_rect.h:124
void Print(PCB_BASE_FRAME *aFrame, wxDC *DC, const wxPoint &aOffset=ZeroOffset) override
Function Print BOARD_ITEMs have their own color information.
void GRCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, int aPenSize, COLOR4D Color)
Definition: gr_basic.cpp:312
static bool ShowClearance(PCB_DISPLAY_OPTIONS *aDisplOpts, const TRACK *aTrack)
Function ShowClearance tests to see if the clearance border is drawn on the given track.
Definition: class_track.cpp:48
#define BUSY
Pcbnew: flag indicating that the structure has.
Definition: base_struct.h:127
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
VIA(BOARD_ITEM *aParent)
Definition: class_track.cpp:74
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
void GRFilledCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:623
#define BEGIN_ONPAD
Pcbnew: flag set for track segment starting on a pad.
Definition: base_struct.h:125
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
bool Contains(const wxPoint &aPoint) const
Function Contains.
const wxString & GetShortNetname() const
Function GetShortNetname.
Definition: netinfo.h:239
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
bool IsDragging() const
Definition: base_struct.h:218
Definitions for tracks, vias and zones.
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
double GetLength() const
Function GetLength returns the length of the track using the hypotenuse calculation.
Definition: class_track.h:149
TRACE_CLEARANCE_DISPLAY_MODE_T m_ShowTrackClearanceMode
How trace clearances are displayed.
int m_Width
Thickness of track, or via diameter.
Definition: class_track.h:255
This file contains miscellaneous commonly used macros and functions.
bool IsNew() const
Definition: base_struct.h:215
Classes used in Pcbnew, CvPcb and GerbView.
COLOR4D GetItemColor(int aItemIdx) const
Function GetItemColor.
virtual unsigned int ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Function ViewGetLOD() Returns the level of detail (LOD) of the item.
wxString MessageTextFromValue(EDA_UNITS_T aUnits, int aValue, bool aUseMils)
Definition: base_units.cpp:125
const INSPECTOR_FUNC & INSPECTOR
Definition: base_struct.h:95
#define IS_DRAGGED
Item being dragged.
Definition: base_struct.h:109
PCB_LAYER_ID m_Layer
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
PCB_LAYER_ID
A quick note on layer IDs:
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Class LSET is a set of PCB_LAYER_IDs.
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
void GRForceBlackPen(bool flagforce)
Function GRForceBlackPen.
Definition: gr_basic.cpp:201
void GRFillCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:415
#define IS_DELETED
Definition: base_struct.h:110
PCB_GENERAL_SETTINGS & Settings()
wxPoint m_End
Line end point.
Definition: class_track.h:257
to draw usual through hole vias
int m_Drill
Definition: class_track.h:386
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Function Flip Flip this object, i.e.
const wxString & GetNetname() const
Function GetNetname.
Definition: netinfo.h:233
unsigned STATUS_FLAGS
Definition: base_struct.h:143
VIATYPE_T GetViaType() const
Definition: class_track.h:338
SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[]) override
Function Visit may be re-implemented for each derived class in order to handle all the types given by...
PCB_LAYER_ID m_BottomLayer
The bottom layer of the via (the top layer is in m_Layer)
Definition: class_track.h:382
unsigned int ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Function ViewGetLOD() Returns the level of detail (LOD) of the item.
TRACK * GetEndNetCode(int NetCode)
#define MIN_TEXT_SIZE
Definition: gr_text.h:43
#define TRACK_LOCKED
Pcbnew: track locked: protected from global deletion.
Definition: base_struct.h:121
Definition: colors.h:60
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.
wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: class_track.cpp:89
const BOX2I ViewBBox() const override
Function ViewBBox() returns the bounding box of the item covering all its layers.
virtual int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const override
Function GetClearance returns the clearance in internal units.
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle)
Definition: gr_basic.cpp:230
#define _(s)
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
bool m_IsPrinting
Definition: base_screen.h:139
#define FLAG0
Pcbnew: flag used in local computations.
Definition: base_struct.h:124
void SetDrillDefault()
Function SetDrillDefault sets the drill value for vias to the default value UNDEFINED_DRILL_DIAMETER.
Definition: class_track.h:367
COLORS_DESIGN_SETTINGS & Colors()
#define TRACK_AR
Pcbnew: autorouted track.
Definition: base_struct.h:122
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
wxString GetNetnameMsg() const
Function GetNetnameMsg.
virtual void GetMsgPanelInfoBase(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList)
Function GetMsgPanelInfoBase Display info about the track segment only, and does not calculate the fu...
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Function IsElementVisible tests whether a given element category is visible.
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on.
Class NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:300
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
Function IsLayerVisible is a proxy function that calls the correspondent function in m_BoardSettings ...
Definition: class_board.h:459
void GRHaloText(wxDC *aDC, const wxPoint &aPos, const COLOR4D aBgColor, COLOR4D aColor1, COLOR4D aColor2, const wxString &aText, double aOrient, const wxSize &aSize, enum EDA_TEXT_HJUSTIFY_T aH_justify, enum EDA_TEXT_VJUSTIFY_T aV_justify, int aWidth, bool aItalic, bool aBold, void(*aCallback)(int x0, int y0, int xf, int yf, void *aData), void *aCallbackData, PLOTTER *aPlotter)
Draw graphic text with a border, so that it can be read on different backgrounds.
Definition: gr_text.cpp:169
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
int GetWidth() const
Definition: class_track.h:103
TRACK * GetStartNetCode(int NetCode)
STATUS_FLAGS IsPointOnEnds(const wxPoint &point, int min_dist=0) const
Function IsPointOnEnds returns STARTPOINT if point if near (dist = min_dist) start point,...
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
#define max(a, b)
Definition: auxiliary.h:86
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:161
virtual int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const
Function GetClearance returns the clearance in internal units.
void SetTopLayer(PCB_LAYER_ID aLayer)
std::shared_ptr< NETCLASS > GetNetClass() const
Function GetNetClass returns the NETCLASS for this item.
wxString UnescapeString(const wxString &aSource)
Definition: string.cpp:123
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
Definition: gr_basic.cpp:600
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:174
int GetCopperLayerCount() const
Function GetCopperLayerCount.
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:113
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
void GetMsgPanelInfoBase(EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfoBase Display info about the track segment only, and does not calculate the fu...
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:150
The common library.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
PCB_LAYER_ID TopLayer() const
const wxPoint & GetEnd() const
Definition: class_track.h:106
Definition: colors.h:49
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
int GetMicroViaDrillSize()
Function GetViaDrillSize returns the size of via drills used to route this net.
Definition: netinfo.h:182
void SetBottomLayer(PCB_LAYER_ID aLayer)
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
virtual wxString GetSelectMenuText(EDA_UNITS_T aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
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: class_track.cpp:61
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Function IsOnLayer tests to see if this object is on the given layer.
Definition: colors.h:45
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
Class VIEW.
Definition: view.h:61
bool TestSegmentHit(const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist)
Function TestSegmentHit test for hit on line segment i.e.
Definition: trigo.cpp:126
SEARCH_RESULT
Definition: base_struct.h:59
bool GetGRForceBlackPenState(void)
Function GetGRForceBlackPenState.
Definition: gr_basic.cpp:211
void SanitizeLayers()
Function SanitizeLayers Check so that the layers are correct dependin on the type of via,...
int GetViaDrillSize()
Function GetViaDrillSize returns the size of via drills used to route this net.
Definition: netinfo.h:172
std::tuple< int, double, double > GetTrackLength(const TRACK &aTrack) const
Returns data on the length and number of track segments connected to a given track.
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
Message panel definition file.
wxString GetLayerName() const
Function GetLayerName returns the name of the PCB layer on which the item resides.
#define FORCE_SKETCH
Definition: pcbnew.h:44
PCB_LAYER_ID BottomLayer() const
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Definition: netinfo.h:463
int GetState(int type) const
Definition: base_struct.h:236
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Function Flip Flip this object, i.e.
EDA_ITEM * Pnext
next in linked list
Definition: base_struct.h:163
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
EDA_UNITS_T
Definition: common.h:157
#define DO_NOT_DRAW
Used to disable draw function.
Definition: base_struct.h:119
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: class_track.cpp:83
bool IsNetnameLayer(LAYER_NUM aLayer)
Function IsNetnameLayer tests whether a layer is a netname layer.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:197
#define min(a, b)
Definition: auxiliary.h:85
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:112
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible() Returns information about visibility of a particular layer.
Definition: view.h:427
void Print(PCB_BASE_FRAME *aFrame, wxDC *DC, const wxPoint &aOffset=ZeroOffset) override
Function Print BOARD_ITEMs have their own color information.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
Definition: colors.h:62