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( const 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 = 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  auto& displ_opts = 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  && aView->IsLayerVisible( LAYER_VIAS ) )
743  {
744  switch( m_ViaType )
745  {
746  case VIA_THROUGH:
747  if( !aView->IsLayerVisible( LAYER_VIA_THROUGH ) )
748  return HIDE;
749 
750  break;
751 
752  case VIA_BLIND_BURIED:
753  if( !aView->IsLayerVisible( LAYER_VIA_BBLIND ) )
754  return HIDE;
755 
756  break;
757 
758  case VIA_MICROVIA:
759  if( !aView->IsLayerVisible( LAYER_VIA_MICROVIA ) )
760  return HIDE;
761 
762  break;
763 
764  default:
765  break;
766  }
767 
768  return 0;
769  }
770 
771  return HIDE;
772 }
773 
774 
775 // see class_track.h
776 void TRACK::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList )
777 {
778  wxString msg;
779  BOARD* board = GetBoard();
780 
781  // Display basic infos
782  GetMsgPanelInfoBase( aUnits, aList );
783 
784  // Display full track length (in Pcbnew)
785  if( board )
786  {
787  int count;
788  double trackLen;
789  double lenPadToDie;
790 
791  std::tie( count, trackLen, lenPadToDie ) = board->GetTrackLength( *this );
792 
793  msg = MessageTextFromValue( aUnits, trackLen );
794  aList.push_back( MSG_PANEL_ITEM( _( "Length" ), msg, DARKCYAN ) );
795 
796  if( lenPadToDie != 0 )
797  {
798  msg = MessageTextFromValue( aUnits, trackLen + lenPadToDie );
799  aList.push_back( MSG_PANEL_ITEM( _( "Full Length" ), msg, DARKCYAN ) );
800 
801  msg = MessageTextFromValue( aUnits, lenPadToDie, true );
802  aList.push_back( MSG_PANEL_ITEM( _( "Pad To Die Length" ), msg, DARKCYAN ) );
803  }
804  }
805 
806  NETCLASSPTR netclass = GetNetClass();
807 
808  if( netclass )
809  {
810  aList.push_back( MSG_PANEL_ITEM( _( "NC Name" ), netclass->GetName(), DARKMAGENTA ) );
811 
812  msg = MessageTextFromValue( aUnits, netclass->GetClearance(), true );
813  aList.push_back( MSG_PANEL_ITEM( _( "NC Clearance" ), msg, DARKMAGENTA ) );
814 
815  msg = MessageTextFromValue( aUnits, netclass->GetTrackWidth(), true );
816  aList.push_back( MSG_PANEL_ITEM( _( "NC Width" ), msg, DARKMAGENTA ) );
817 
818  msg = MessageTextFromValue( aUnits, netclass->GetViaDiameter(), true );
819  aList.push_back( MSG_PANEL_ITEM( _( "NC Via Size" ), msg, DARKMAGENTA ) );
820 
821  msg = MessageTextFromValue( aUnits, netclass->GetViaDrill(), true );
822  aList.push_back( MSG_PANEL_ITEM( _( "NC Via Drill"), msg, DARKMAGENTA ) );
823  }
824 }
825 
826 void TRACK::GetMsgPanelInfoBase_Common( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList )
827 {
828  wxString msg;
829 
830  // Display Net Name
831  if( GetBoard() )
832  {
833  NETINFO_ITEM* net = GetNet();
834 
835  if( net )
836  msg = UnescapeString( net->GetNetname() );
837  else
838  msg = wxT( "<no name>" );
839 
840  aList.push_back( MSG_PANEL_ITEM( _( "NetName" ), msg, RED ) );
841 
842  // Display net code : (useful in test or debug)
843  msg.Printf( wxT( "%d" ), GetNetCode() );
844  aList.push_back( MSG_PANEL_ITEM( _( "NetCode" ), msg, RED ) );
845  }
846 
847 #if defined(DEBUG)
848 
849  // Display the flags
850  msg.Printf( wxT( "0x%08X" ), m_Flags );
851  aList.push_back( MSG_PANEL_ITEM( wxT( "Flags" ), msg, BLUE ) );
852 
853 #if 0
854  // Display start and end pointers:
855  msg.Printf( wxT( "%p" ), start );
856  aList.push_back( MSG_PANEL_ITEM( wxT( "start ptr" ), msg, BLUE ) );
857  msg.Printf( wxT( "%p" ), end );
858  aList.push_back( MSG_PANEL_ITEM( wxT( "end ptr" ), msg, BLUE ) );
859  // Display this ptr
860  msg.Printf( wxT( "%p" ), this );
861  aList.push_back( MSG_PANEL_ITEM( wxT( "this" ), msg, BLUE ) );
862 #endif
863 
864 #if 0
865  // Display start and end positions:
866  msg.Printf( wxT( "%d %d" ), m_Start.x, m_Start.y );
867  aList.push_back( MSG_PANEL_ITEM( wxT( "Start pos" ), msg, BLUE ) );
868  msg.Printf( wxT( "%d %d" ), m_End.x, m_End.y );
869  aList.push_back( MSG_PANEL_ITEM( wxT( "End pos" ), msg, BLUE ) );
870 #endif
871 
872 #endif // defined(DEBUG)
873 
874  // Display the State member
875  msg = wxT( ". . " );
876 
877  if( GetState( TRACK_LOCKED ) )
878  msg[0] = 'L';
879 
880  if( GetState( TRACK_AR ) )
881  msg[2] = 'A';
882 
883  aList.push_back( MSG_PANEL_ITEM( _( "Status" ), msg, MAGENTA ) );
884 }
885 
886 void TRACK::GetMsgPanelInfoBase( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList )
887 {
888  wxString msg;
889  BOARD* board = GetBoard();
890 
891  aList.push_back( MSG_PANEL_ITEM( _( "Type" ), _( "Track" ), DARKCYAN ) );
892 
893  GetMsgPanelInfoBase_Common( aUnits, aList );
894 
895  // Display layer
896  if( board )
897  msg = board->GetLayerName( m_Layer );
898  else
899  msg.Printf(wxT("%d"), m_Layer );
900 
901  aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), msg, BROWN ) );
902 
903  // Display width
904  msg = MessageTextFromValue( aUnits, m_Width, true );
905 
906  aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, DARKCYAN ) );
907 
908  // Display segment length
909  msg = ::MessageTextFromValue( aUnits, GetLength() );
910  aList.push_back( MSG_PANEL_ITEM( _( "Segment Length" ), msg, DARKCYAN ) );
911 }
912 
913 void VIA::GetMsgPanelInfoBase( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList )
914 {
915  wxString msg;
916  BOARD* board = GetBoard();
917 
918  switch( GetViaType() )
919  {
920  default:
921  case VIA_NOT_DEFINED:
922  msg = wxT( "???" ); // Not used yet, does not exist currently
923  break;
924 
925  case VIA_MICROVIA:
926  msg = _( "Micro Via" ); // from external layer (TOP or BOTTOM) from
927  // the near neighbor inner layer only
928  break;
929 
930  case VIA_BLIND_BURIED:
931  msg = _( "Blind/Buried Via" ); // from inner or external to inner
932  // or external layer (no restriction)
933  break;
934 
935  case VIA_THROUGH:
936  msg = _( "Through Via" ); // Usual via (from TOP to BOTTOM layer only )
937  break;
938  }
939 
940  aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, DARKCYAN ) );
941 
942  GetMsgPanelInfoBase_Common( aUnits, aList );
943 
944 
945  // Display layer pair
946  PCB_LAYER_ID top_layer, bottom_layer;
947 
948  LayerPair( &top_layer, &bottom_layer );
949 
950  if( board )
951  msg = board->GetLayerName( top_layer ) + wxT( "/" )
952  + board->GetLayerName( bottom_layer );
953  else
954  msg.Printf( wxT( "%d/%d" ), top_layer, bottom_layer );
955 
956  aList.push_back( MSG_PANEL_ITEM( _( "Layers" ), msg, BROWN ) );
957 
958  // Display width
959  msg = MessageTextFromValue( aUnits, m_Width, true );
960 
961  // Display diameter value:
962  aList.push_back( MSG_PANEL_ITEM( _( "Diameter" ), msg, DARKCYAN ) );
963 
964  // Display drill value
965  msg = MessageTextFromValue( aUnits, GetDrillValue() );
966 
967  wxString title = _( "Drill" );
968  title += wxT( " " );
969 
970  bool drl_specific = true;
971 
972  if( GetBoard() )
973  {
974  NETINFO_ITEM* net = GetNet();
975  int drill_class_value = 0;
976 
977  if( net )
978  {
979  if( GetViaType() == VIA_MICROVIA )
980  drill_class_value = net->GetMicroViaDrillSize();
981  else
982  drill_class_value = net->GetViaDrillSize();
983  }
984 
985  drl_specific = GetDrillValue() != drill_class_value;
986  }
987 
988 
989  if( drl_specific )
990  title += _( "(Specific)" );
991  else
992  title += _( "(NetClass)" );
993 
994  aList.push_back( MSG_PANEL_ITEM( title, msg, RED ) );
995 }
996 
997 
998 bool TRACK::HitTest( const wxPoint& aPosition, int aAccuracy ) const
999 {
1000  return TestSegmentHit( aPosition, m_Start, m_End, aAccuracy + ( m_Width / 2 ) );
1001 }
1002 
1003 bool VIA::HitTest( const wxPoint& aPosition, int aAccuracy ) const
1004 {
1005  int max_dist = aAccuracy + ( m_Width / 2 );
1006 
1007  // rel_pos is aPosition relative to m_Start (or the center of the via)
1008  wxPoint rel_pos = aPosition - m_Start;
1009  double dist = (double) rel_pos.x * rel_pos.x + (double) rel_pos.y * rel_pos.y;
1010  return dist <= (double) max_dist * max_dist;
1011 }
1012 
1013 
1014 bool TRACK::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
1015 {
1016  EDA_RECT arect = aRect;
1017  arect.Inflate( aAccuracy );
1018 
1019  if( aContained )
1020  /* Tracks are a special case:
1021  * they are considered inside the rect if one end is inside the rect */
1022  return arect.Contains( GetStart() ) || arect.Contains( GetEnd() );
1023  else
1024  return arect.Intersects( GetStart(), GetEnd() );
1025 }
1026 
1027 bool VIA::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
1028 {
1029  EDA_RECT box;
1030  EDA_RECT arect = aRect;
1031  arect.Inflate( aAccuracy );
1032 
1033  box.SetOrigin( GetStart() );
1034  box.Inflate( GetWidth() / 2 );
1035 
1036  if( aContained )
1037  {
1038  return arect.Contains( box );
1039  }
1040  else
1041  {
1042  return arect.IntersectsCircle( GetStart(), GetWidth() / 2 );
1043  }
1044 }
1045 
1046 
1047 wxString TRACK::GetSelectMenuText( EDA_UNITS_T aUnits ) const
1048 {
1049  return wxString::Format( _("Track %s %s on %s, length: %s" ),
1050  MessageTextFromValue( aUnits, m_Width ),
1051  GetNetnameMsg(),
1052  GetLayerName(),
1053  MessageTextFromValue( aUnits, GetLength() ) );
1054 }
1055 
1056 
1057 BITMAP_DEF TRACK::GetMenuImage() const
1058 {
1059  return add_tracks_xpm;
1060 }
1061 
1063 {
1064  assert( aImage->Type() == PCB_TRACE_T );
1065 
1066  std::swap( *((TRACK*) this), *((TRACK*) aImage) );
1067 }
1068 
1069 void VIA::SwapData( BOARD_ITEM* aImage )
1070 {
1071  assert( aImage->Type() == PCB_VIA_T );
1072 
1073  std::swap( *((VIA*) this), *((VIA*) aImage) );
1074 }
1075 
1076 #if defined(DEBUG)
1077 
1078 wxString TRACK::ShowState( int stateBits )
1079 {
1080  wxString ret;
1081 
1082  if( stateBits & IS_LINKED )
1083  ret << wxT( " | IS_LINKED" );
1084 
1085  if( stateBits & TRACK_AR )
1086  ret << wxT( " | TRACK_AR" );
1087 
1088  if( stateBits & TRACK_LOCKED )
1089  ret << wxT( " | TRACK_LOCKED" );
1090 
1091  if( stateBits & IN_EDIT )
1092  ret << wxT( " | IN_EDIT" );
1093 
1094  if( stateBits & IS_DRAGGED )
1095  ret << wxT( " | IS_DRAGGED" );
1096 
1097  if( stateBits & DO_NOT_DRAW )
1098  ret << wxT( " | DO_NOT_DRAW" );
1099 
1100  if( stateBits & IS_DELETED )
1101  ret << wxT( " | IS_DELETED" );
1102 
1103  if( stateBits & BUSY )
1104  ret << wxT( " | BUSY" );
1105 
1106  if( stateBits & END_ONPAD )
1107  ret << wxT( " | END_ONPAD" );
1108 
1109  if( stateBits & BEGIN_ONPAD )
1110  ret << wxT( " | BEGIN_ONPAD" );
1111 
1112  if( stateBits & FLAG0 )
1113  ret << wxT( " | FLAG0" );
1114 
1115  if( stateBits & FLAG1 )
1116  ret << wxT( " | FLAG1" );
1117 
1118  return ret;
1119 }
1120 
1121 #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:117
#define FLAG1
Pcbnew: flag used in local computations.
Definition: base_struct.h:136
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:118
int GetNetCode() const
Function GetNetCode.
wxPoint m_Start
Line start point.
Definition: class_track.h:264
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
VIATYPE_T m_ViaType
Definition: class_track.h:392
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:139
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:347
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:230
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:131
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
#define BUSY
Pcbnew: flag indicating that the structure has.
Definition: base_struct.h:140
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:206
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:138
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Function GetDisplayOptions returns the display options current in use Display options are relative to...
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:231
Definitions for tracks, vias and zones.
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
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:263
This file contains miscellaneous commonly used macros and functions.
bool IsNew() const
Definition: base_struct.h:228
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:108
#define IS_DRAGGED
Item being dragged.
Definition: base_struct.h:122
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:123
PCB_GENERAL_SETTINGS & Settings()
wxPoint m_End
Line end point.
Definition: class_track.h:265
to draw usual through hole vias
int m_Drill
Definition: class_track.h:394
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:156
VIATYPE_T GetViaType() const
Definition: class_track.h:346
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:390
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:134
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:137
void SetDrillDefault()
Function SetDrillDefault sets the drill value for vias to the default value UNDEFINED_DRILL_DIAMETER.
Definition: class_track.h:375
COLORS_DESIGN_SETTINGS & Colors()
#define TRACK_AR
Pcbnew: autorouted track.
Definition: base_struct.h:135
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:450
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:171
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:131
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:187
int GetCopperLayerCount() const
Function GetCopperLayerCount.
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:126
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:163
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)
static bool ShowClearance(const 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
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:97
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:127
SEARCH_RESULT
Definition: base_struct.h:54
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:249
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:176
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
EDA_UNITS_T
Definition: common.h:133
#define DO_NOT_DRAW
Used to disable draw function.
Definition: base_struct.h:132
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:210
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:114
#define min(a, b)
Definition: auxiliary.h:85
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:125
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible() Returns information about visibility of a particular layer.
Definition: view.h:416
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