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-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 <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 #include <math/util.h> // for KiROUND
43 #include <pgm_base.h>
46 
52 static bool ShowClearance( const PCB_DISPLAY_OPTIONS& aDisplOpts, const TRACK* aTrack )
53 {
54  // maybe return true for tracks and vias, not for zone segments
55  return IsCopperLayer( aTrack->GetLayer() )
56  && ( aTrack->Type() == PCB_TRACE_T || aTrack->Type() == PCB_VIA_T
57  || aTrack->Type() == PCB_ARC_T )
59  && ( aTrack->IsDragging() || aTrack->IsMoving() || aTrack->IsNew() ) )
61  );
62 
63 }
64 
65 
66 TRACK::TRACK( BOARD_ITEM* aParent, KICAD_T idtype ) :
67  BOARD_CONNECTED_ITEM( aParent, idtype )
68 {
69  m_Width = Millimeter2iu( 0.2 );
70 }
71 
72 
74 {
75  return new TRACK( *this );
76 }
77 
78 
80 {
81  return new ARC( *this );
82 }
83 
84 
85 VIA::VIA( BOARD_ITEM* aParent ) :
86  TRACK( aParent, PCB_VIA_T )
87 {
91 }
92 
93 
95 {
96  return new VIA( *this );
97 }
98 
99 
100 wxString VIA::GetSelectMenuText( EDA_UNITS aUnits ) const
101 {
102  wxString format;
103  BOARD* board = GetBoard();
104 
105  switch( GetViaType() )
106  {
108  format = _( "Blind/Buried Via %s %s on %s - %s" );
109  break;
110  case VIATYPE::MICROVIA:
111  format = _( "Micro Via %s %s on %s - %s" );
112  break;
113  // else say nothing about normal (through) vias
114  default:
115  format = _( "Via %s %s on %s - %s" );
116  break;
117  }
118 
119  if( board )
120  {
121  // say which layers, only two for now
122  PCB_LAYER_ID topLayer;
123  PCB_LAYER_ID botLayer;
124  LayerPair( &topLayer, &botLayer );
125  return wxString::Format( format.GetData(), MessageTextFromValue( aUnits, m_Width ),
126  GetNetnameMsg(), board->GetLayerName( topLayer ), board->GetLayerName( botLayer ) );
127  }
128  else
129  {
130  return wxString::Format( format.GetData(), MessageTextFromValue( aUnits, m_Width ),
131  GetNetnameMsg(), wxT( "??" ), wxT( "??" ) );
132  }
133 }
134 
135 
137 {
138  return via_xpm;
139 }
140 
141 
143 {
144  // Currently tracks have no specific clearance parameter on a per track or per
145  // segment basis. The NETCLASS clearance is used.
146  return BOARD_CONNECTED_ITEM::GetClearance( aItem );
147 }
148 
149 
151 {
152  if( m_Drill > 0 ) // Use the specific value.
153  return m_Drill;
154 
155  // Use the default value from the Netclass
156  NETCLASSPTR netclass = GetNetClass();
157 
158  if( GetViaType() == VIATYPE::MICROVIA )
159  return netclass->GetuViaDrill();
160 
161  return netclass->GetViaDrill();
162 }
163 
164 
165 STATUS_FLAGS TRACK::IsPointOnEnds( const wxPoint& point, int min_dist ) const
166 {
167  STATUS_FLAGS result = 0;
168 
169  if( min_dist < 0 )
170  min_dist = m_Width / 2;
171 
172  if( min_dist == 0 )
173  {
174  if( m_Start == point )
175  result |= STARTPOINT;
176 
177  if( m_End == point )
178  result |= ENDPOINT;
179  }
180  else
181  {
182  double dist = GetLineLength( m_Start, point );
183 
184  if( min_dist >= KiROUND( dist ) )
185  result |= STARTPOINT;
186 
187  dist = GetLineLength( m_End, point );
188 
189  if( min_dist >= KiROUND( dist ) )
190  result |= ENDPOINT;
191  }
192 
193  return result;
194 }
195 
196 
198 {
199  // end of track is round, this is its radius, rounded up
200  int radius = ( m_Width + 1 ) / 2;
201  int ymax, xmax, ymin, xmin;
202 
203  if( Type() == PCB_VIA_T )
204  {
205  ymax = m_Start.y;
206  xmax = m_Start.x;
207 
208  ymin = m_Start.y;
209  xmin = m_Start.x;
210  }
211  else
212  {
213  ymax = std::max( m_Start.y, m_End.y );
214  xmax = std::max( m_Start.x, m_End.x );
215 
216  ymin = std::min( m_Start.y, m_End.y );
217  xmin = std::min( m_Start.x, m_End.x );
218  }
219 
220  ymax += radius;
221  xmax += radius;
222 
223  ymin -= radius;
224  xmin -= radius;
225 
226  // return a rectangle which is [pos,dim) in nature. therefore the +1
227  EDA_RECT ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
228 
229  return ret;
230 }
231 
232 
233 void TRACK::Rotate( const wxPoint& aRotCentre, double aAngle )
234 {
235  RotatePoint( &m_Start, aRotCentre, aAngle );
236  RotatePoint( &m_End, aRotCentre, aAngle );
237 }
238 
239 
240 void ARC::Rotate( const wxPoint& aRotCentre, double aAngle )
241 {
242  RotatePoint( &m_Start, aRotCentre, aAngle );
243  RotatePoint( &m_End, aRotCentre, aAngle );
244  RotatePoint( &m_Mid, aRotCentre, aAngle );
245 }
246 
247 
248 void TRACK::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
249 {
250  if( aFlipLeftRight )
251  {
252  m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
253  m_End.x = aCentre.x - ( m_End.x - aCentre.x );
254  }
255  else
256  {
257  m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
258  m_End.y = aCentre.y - ( m_End.y - aCentre.y );
259  }
260 
261  int copperLayerCount = GetBoard()->GetCopperLayerCount();
262  SetLayer( FlipLayer( GetLayer(), copperLayerCount ) );
263 }
264 
265 
266 void ARC::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
267 {
268  if( aFlipLeftRight )
269  {
270  m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
271  m_End.x = aCentre.x - ( m_End.x - aCentre.x );
272  m_Mid.x = aCentre.x - ( m_Mid.x - aCentre.x );
273  }
274  else
275  {
276  m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
277  m_End.y = aCentre.y - ( m_End.y - aCentre.y );
278  m_Mid.y = aCentre.y - ( m_Mid.y - aCentre.y );
279  }
280 
281  int copperLayerCount = GetBoard()->GetCopperLayerCount();
282  SetLayer( FlipLayer( GetLayer(), copperLayerCount ) );
283 }
284 
285 
286 void VIA::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
287 {
288  if( aFlipLeftRight )
289  {
290  m_Start.x = aCentre.x - ( m_Start.x - aCentre.x );
291  m_End.x = aCentre.x - ( m_End.x - aCentre.x );
292  }
293  else
294  {
295  m_Start.y = aCentre.y - ( m_Start.y - aCentre.y );
296  m_End.y = aCentre.y - ( m_End.y - aCentre.y );
297  }
298 
299  if( GetViaType() != VIATYPE::THROUGH )
300  {
301  int copperLayerCount = GetBoard()->GetCopperLayerCount();
302  PCB_LAYER_ID top_layer;
303  PCB_LAYER_ID bottom_layer;
304  LayerPair( &top_layer, &bottom_layer );
305  top_layer = FlipLayer( top_layer, copperLayerCount );
306  bottom_layer = FlipLayer( bottom_layer, copperLayerCount );
307  SetLayerPair( top_layer, bottom_layer );
308  }
309 }
310 
311 
312 // see class_track.h
313 SEARCH_RESULT TRACK::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
314 {
315  KICAD_T stype = *scanTypes;
316 
317  // If caller wants to inspect my type
318  if( stype == Type() )
319  {
320  if( SEARCH_RESULT::QUIT == inspector( this, testData ) )
321  return SEARCH_RESULT::QUIT;
322  }
323 
325 }
326 
327 
328 bool VIA::IsOnLayer( PCB_LAYER_ID layer_number ) const
329 {
330  PCB_LAYER_ID bottom_layer, top_layer;
331 
332  LayerPair( &top_layer, &bottom_layer );
333 
334  wxASSERT( top_layer <= bottom_layer );
335 
336  if( top_layer <= layer_number && layer_number <= bottom_layer )
337  return true;
338  else
339  return false;
340 }
341 
342 
344 {
345  if( GetViaType() == VIATYPE::THROUGH )
346  return LSET::AllCuMask();
347 
348  // VIA_BLIND_BURIED or VIA_MICRVIA:
349 
350  LSET layermask;
351 
352  wxASSERT( m_Layer <= m_BottomLayer );
353 
354  // PCB_LAYER_IDs are numbered from front to back, this is top to bottom.
355  for( LAYER_NUM id = m_Layer; id <= m_BottomLayer; ++id )
356  {
357  layermask.set( id );
358  }
359 
360  return layermask;
361 }
362 
363 
364 void VIA::SetLayerPair( PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer )
365 {
366 
367  m_Layer = aTopLayer;
368  m_BottomLayer = aBottomLayer;
369  SanitizeLayers();
370 }
371 
372 
374 {
375  m_Layer = aLayer;
376 }
377 
378 
380 {
381  m_BottomLayer = aLayer;
382 }
383 
384 
385 void VIA::LayerPair( PCB_LAYER_ID* top_layer, PCB_LAYER_ID* bottom_layer ) const
386 {
387  PCB_LAYER_ID t_layer = F_Cu;
388  PCB_LAYER_ID b_layer = B_Cu;
389 
390  if( GetViaType() != VIATYPE::THROUGH )
391  {
392  b_layer = m_BottomLayer;
393  t_layer = m_Layer;
394 
395  if( b_layer < t_layer )
396  std::swap( b_layer, t_layer );
397  }
398 
399  if( top_layer )
400  *top_layer = t_layer;
401 
402  if( bottom_layer )
403  *bottom_layer = b_layer;
404 }
405 
406 
408 {
409  return m_Layer;
410 }
411 
412 
414 {
415  return m_BottomLayer;
416 }
417 
418 
420 {
421  if( GetViaType() == VIATYPE::THROUGH )
422  {
423  m_Layer = F_Cu;
425  }
426 
427  if( m_BottomLayer < m_Layer )
428  std::swap( m_BottomLayer, m_Layer );
429 }
430 
431 
432 void TRACK::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset )
433 {
434  BOARD* brd = GetBoard();
435  auto color = Pgm().GetSettingsManager().GetColorSettings()->GetColor( m_Layer );
436 
437  if( !brd->IsLayerVisible( m_Layer ) || !brd->IsElementVisible( LAYER_TRACKS ) )
438  return;
439 
440  auto displ_opts = aFrame->GetDisplayOptions();
441 
442  color.a = 0.588;
443 
444  // Draw track as line if width <= 1pixel:
445  if( aDC->LogicalToDeviceXRel( m_Width ) <= 1 )
446  {
447  GRLine( nullptr, aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
448  return;
449  }
450 
451  if( !displ_opts.m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
452  {
453  GRCSegm( nullptr, aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
454  }
455  else
456  {
457  GRFillCSegm( nullptr, aDC, m_Start.x + aOffset.x, m_Start.y + aOffset.y,
458  m_End.x + aOffset.x, m_End.y + aOffset.y, m_Width, color );
459  }
460 }
461 
462 
463 void TRACK::ViewGetLayers( int aLayers[], int& aCount ) const
464 {
465  // Show the track and its netname on different layers
466  aLayers[0] = GetLayer();
467  aLayers[1] = GetNetnameLayer( aLayers[0] );
468  aCount = 2;
469 }
470 
471 
472 unsigned int TRACK::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
473 {
474  const int HIDE = std::numeric_limits<unsigned int>::max();
475 
476  if( !aView->IsLayerVisible( LAYER_TRACKS ) )
477  return HIDE;
478 
479  // Netnames will be shown only if zoom is appropriate
480  if( IsNetnameLayer( aLayer ) )
481  {
482  return ( Millimeter2iu( 4 ) / ( m_Width + 1 ) );
483  }
484 
485  // Other layers are shown without any conditions
486  return 0;
487 }
488 
489 
490 const BOX2I TRACK::ViewBBox() const
491 {
492  BOX2I bbox = GetBoundingBox();
493  bbox.Inflate( 2 * GetClearance() );
494  return bbox;
495 }
496 
497 
498 void VIA::Print( PCB_BASE_FRAME* aFrame, wxDC* aDC, const wxPoint& aOffset )
499 {
500  int radius;
501  int fillvia = 0;
502  PCB_SCREEN* screen = aFrame->GetScreen();
503  auto& displ_opts = aFrame->GetDisplayOptions();
504  BOARD* brd = GetBoard();
505  COLOR4D color = Pgm().GetSettingsManager().GetColorSettings()->GetColor(
506  LAYER_VIAS + static_cast<int>( GetViaType() ) );
507 
508  if( displ_opts.m_DisplayViaFill == FILLED )
509  fillvia = 1;
510 
511  if( !brd->IsElementVisible( LAYER_VIAS + static_cast<int>( GetViaType() ) ) )
512  return;
513 
514  // Only draw the via if at least one of the layers it crosses is being displayed
515  if( !( brd->GetVisibleLayers() & GetLayerSet() ).any() )
516  return;
517 
518  color.a = 0.588;
519 
520  radius = m_Width >> 1;
521  // for small via size on screen (radius < 4 pixels) draw a simplified shape
522 
523  int radius_in_pixels = aDC->LogicalToDeviceXRel( radius );
524  bool fast_draw = false;
525 
526  // Vias are drawn as a filled circle or a double circle. The hole will be drawn later
527  int drill_radius = GetDrillValue() / 2;
528  int inner_radius = radius - aDC->DeviceToLogicalXRel( 2 );
529 
530  if( radius_in_pixels < MIN_VIA_DRAW_SIZE )
531  {
532  fast_draw = true;
533  fillvia = false;
534  }
535 
536  if( fillvia )
537  {
538  GRFilledCircle( nullptr, aDC, m_Start + aOffset, radius, color );
539  }
540  else
541  {
542  GRCircle( nullptr, aDC, m_Start + aOffset, radius, 0, color );
543 
544  if ( fast_draw )
545  return;
546 
547  GRCircle( nullptr, aDC, m_Start + aOffset, inner_radius, 0, color );
548  }
549 
550  if( fillvia )
551  {
552  bool blackpenstate = false;
553 
554  if( screen->m_IsPrinting )
555  {
556  blackpenstate = GetGRForceBlackPenState();
557  GRForceBlackPen( false );
558  color = WHITE;
559  }
560  else
561  {
562  color = BLACK; // or DARKGRAY;
563  }
564 
565  // Draw hole if the radius is > 1pixel.
566  if( aDC->LogicalToDeviceXRel( drill_radius ) > 1 )
567  GRFilledCircle( nullptr, aDC, m_Start.x + aOffset.x, m_Start.y + aOffset.y,
568  drill_radius, 0, color, color );
569 
570  if( screen->m_IsPrinting )
571  GRForceBlackPen( blackpenstate );
572  }
573  else
574  {
575  if( drill_radius < inner_radius ) // We can show the via hole
576  GRCircle( nullptr, aDC, m_Start + aOffset, drill_radius, 0, color );
577  }
578 
579  if( ShowClearance( displ_opts, this ) )
580  {
581  GRCircle( nullptr, aDC, m_Start + aOffset, radius + GetClearance(), 0, color );
582  }
583 
584  // for Micro Vias, draw a partial cross : X on component layer, or + on copper layer
585  // (so we can see 2 superimposed microvias ):
586  if( GetViaType() == VIATYPE::MICROVIA )
587  {
588  int ax, ay, bx, by;
589 
590  if( IsOnLayer( B_Cu ) )
591  {
592  ax = radius; ay = 0;
593  bx = drill_radius; by = 0;
594  }
595  else
596  {
597  ax = ay = (radius * 707) / 1000;
598  bx = by = (drill_radius * 707) / 1000;
599  }
600 
601  // lines '|' or '\'
602  GRLine( nullptr, aDC, m_Start.x + aOffset.x - ax, m_Start.y + aOffset.y - ay,
603  m_Start.x + aOffset.x - bx, m_Start.y + aOffset.y - by, 0, color );
604  GRLine( nullptr, aDC, m_Start.x + aOffset.x + bx, m_Start.y + aOffset.y + by,
605  m_Start.x + aOffset.x + ax, m_Start.y + aOffset.y + ay, 0, color );
606 
607  // lines - or '/'
608  GRLine( nullptr, aDC, m_Start.x + aOffset.x + ay, m_Start.y + aOffset.y - ax,
609  m_Start.x + aOffset.x + by, m_Start.y + aOffset.y - bx, 0, color );
610  GRLine( nullptr, aDC, m_Start.x + aOffset.x - by, m_Start.y + aOffset.y + bx,
611  m_Start.x + aOffset.x - ay, m_Start.y + aOffset.y + ax, 0, color );
612  }
613 
614  // for Buried Vias, draw a partial line : orient depending on layer pair
615  // (so we can see superimposed buried vias ):
617  {
618  int ax = 0, ay = radius, bx = 0, by = drill_radius;
619  PCB_LAYER_ID layer_top, layer_bottom;
620 
621  LayerPair( &layer_top, &layer_bottom );
622 
623  // lines for the top layer
624  RotatePoint( &ax, &ay, layer_top * 3600.0 / brd->GetCopperLayerCount( ) );
625  RotatePoint( &bx, &by, layer_top * 3600.0 / brd->GetCopperLayerCount( ) );
626  GRLine( nullptr, aDC, m_Start.x + aOffset.x - ax, m_Start.y + aOffset.y - ay,
627  m_Start.x + aOffset.x - bx, m_Start.y + aOffset.y - by, 0, color );
628 
629  // lines for the bottom layer
630  ax = 0; ay = radius; bx = 0; by = drill_radius;
631  RotatePoint( &ax, &ay, layer_bottom * 3600.0 / brd->GetCopperLayerCount( ) );
632  RotatePoint( &bx, &by, layer_bottom * 3600.0 / brd->GetCopperLayerCount( ) );
633  GRLine( nullptr, aDC, m_Start.x + aOffset.x - ax, m_Start.y + aOffset.y - ay,
634  m_Start.x + aOffset.x - bx, m_Start.y + aOffset.y - by, 0, color );
635  }
636 
637  // Display the short netname:
639  return;
640 
641  if( displ_opts.m_DisplayNetNamesMode == 0 || displ_opts.m_DisplayNetNamesMode == 1 )
642  return;
643 
644  NETINFO_ITEM* net = GetNet();
645 
646  if( net == NULL )
647  return;
648 
649  wxString text = UnescapeString( net->GetShortNetname() );
650  int len = text.Len();
651 
652  if( len > 0 )
653  {
654  // calculate a good size for the text
655  int tsize = m_Width / len;
656 
657  if( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE )
658  {
659  tsize = (tsize * 7) / 10; // small reduction to give a better look, inside via
660 
661  GRHaloText( aDC, m_Start, color, WHITE, BLACK, text, 0, wxSize( tsize, tsize ),
662  GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize/7, false, false );
663  }
664  }
665 }
666 
667 
668 void VIA::ViewGetLayers( int aLayers[], int& aCount ) const
669 {
670  aLayers[0] = LAYER_VIAS_HOLES;
671  aLayers[1] = LAYER_VIAS_NETNAMES;
672  aCount = 3;
673 
674  // Just show it on common via & via holes layers
675  switch( GetViaType() )
676  {
677  case VIATYPE::THROUGH:
678  aLayers[2] = LAYER_VIA_THROUGH;
679  break;
680 
682  aLayers[2] = LAYER_VIA_BBLIND;
683  aLayers[3] = m_Layer;
684  aLayers[4] = m_BottomLayer;
685  aCount += 2;
686  break;
687 
688  case VIATYPE::MICROVIA:
689  aLayers[2] = LAYER_VIA_MICROVIA;
690  break;
691 
692  default:
693  aLayers[2] = LAYER_GP_OVERLAY;
694  wxASSERT( false );
695  break;
696  }
697 }
698 
699 
700 unsigned int VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
701 {
702  constexpr unsigned int HIDE = std::numeric_limits<unsigned int>::max();
703 
704  // Netnames will be shown only if zoom is appropriate
705  if( IsNetnameLayer( aLayer ) )
706  return m_Width == 0 ? HIDE : ( Millimeter2iu( 10 ) / m_Width );
707 
708 
709  BOARD* board = GetBoard();
710 
711  // Only draw the via if at least one of the layers it crosses is being displayed
712  if( board && ( board->GetVisibleLayers() & GetLayerSet() ).any()
713  && aView->IsLayerVisible( LAYER_VIAS ) )
714  {
715  switch( m_ViaType )
716  {
717  case VIATYPE::THROUGH:
718  if( !aView->IsLayerVisible( LAYER_VIA_THROUGH ) )
719  return HIDE;
720 
721  break;
722 
724  if( !aView->IsLayerVisible( LAYER_VIA_BBLIND ) )
725  return HIDE;
726 
727  break;
728 
729  case VIATYPE::MICROVIA:
730  if( !aView->IsLayerVisible( LAYER_VIA_MICROVIA ) )
731  return HIDE;
732 
733  break;
734 
735  default:
736  break;
737  }
738 
739  return 0;
740  }
741 
742  return HIDE;
743 }
744 
745 
746 // see class_track.h
747 void TRACK::GetMsgPanelInfo( EDA_UNITS aUnits, std::vector<MSG_PANEL_ITEM>& aList )
748 {
749  wxString msg;
750  BOARD* board = GetBoard();
751 
752  // Display basic infos
753  GetMsgPanelInfoBase( aUnits, aList );
754 
755  // Display full track length (in Pcbnew)
756  if( board )
757  {
758  int count;
759  double trackLen;
760  double lenPadToDie;
761 
762  std::tie( count, trackLen, lenPadToDie ) = board->GetTrackLength( *this );
763 
764  msg = MessageTextFromValue( aUnits, trackLen );
765  aList.emplace_back( _( "Length" ), msg, DARKCYAN );
766 
767  if( lenPadToDie != 0 )
768  {
769  msg = MessageTextFromValue( aUnits, trackLen + lenPadToDie );
770  aList.emplace_back( _( "Full Length" ), msg, DARKCYAN );
771 
772  msg = MessageTextFromValue( aUnits, lenPadToDie, true );
773  aList.emplace_back( _( "Pad To Die Length" ), msg, DARKCYAN );
774  }
775  }
776 
777  NETCLASSPTR netclass = GetNetClass();
778 
779  if( netclass )
780  {
781  aList.emplace_back( _( "NC Name" ), netclass->GetName(), DARKMAGENTA );
782 
783  msg = MessageTextFromValue( aUnits, netclass->GetClearance(), true );
784  aList.emplace_back( _( "NC Clearance" ), msg, DARKMAGENTA );
785 
786  msg = MessageTextFromValue( aUnits, netclass->GetTrackWidth(), true );
787  aList.emplace_back( _( "NC Width" ), msg, DARKMAGENTA );
788 
789  msg = MessageTextFromValue( aUnits, netclass->GetViaDiameter(), true );
790  aList.emplace_back( _( "NC Via Size" ), msg, DARKMAGENTA );
791 
792  msg = MessageTextFromValue( aUnits, netclass->GetViaDrill(), true );
793  aList.emplace_back( _( "NC Via Drill"), msg, DARKMAGENTA );
794  }
795 }
796 
797 void TRACK::GetMsgPanelInfoBase_Common( EDA_UNITS aUnits, std::vector<MSG_PANEL_ITEM>& aList )
798 {
799  wxString msg;
800 
801  // Display Net Name
802  if( GetBoard() )
803  {
804  NETINFO_ITEM* net = GetNet();
805 
806  if( net )
807  msg = UnescapeString( net->GetNetname() );
808  else
809  msg = wxT( "<no name>" );
810 
811  aList.emplace_back( _( "NetName" ), msg, RED );
812 
813  // Display net code : (useful in test or debug)
814  msg.Printf( wxT( "%d" ), GetNetCode() );
815  aList.emplace_back( _( "NetCode" ), msg, RED );
816  }
817 
818 #if defined(DEBUG)
819 
820  // Display the flags
821  msg.Printf( wxT( "0x%08X" ), m_Flags );
822  aList.emplace_back( wxT( "Flags" ), msg, BLUE );
823 
824 #if 0
825  // Display start and end pointers:
826  msg.Printf( wxT( "%p" ), start );
827  aList.push_back( MSG_PANEL_ITEM( wxT( "start ptr" ), msg, BLUE ) );
828  msg.Printf( wxT( "%p" ), end );
829  aList.push_back( MSG_PANEL_ITEM( wxT( "end ptr" ), msg, BLUE ) );
830  // Display this ptr
831  msg.Printf( wxT( "%p" ), this );
832  aList.push_back( MSG_PANEL_ITEM( wxT( "this" ), msg, BLUE ) );
833 #endif
834 
835 #if 0
836  // Display start and end positions:
837  msg.Printf( wxT( "%d %d" ), m_Start.x, m_Start.y );
838  aList.push_back( MSG_PANEL_ITEM( wxT( "Start pos" ), msg, BLUE ) );
839  msg.Printf( wxT( "%d %d" ), m_End.x, m_End.y );
840  aList.push_back( MSG_PANEL_ITEM( wxT( "End pos" ), msg, BLUE ) );
841 #endif
842 
843 #endif // defined(DEBUG)
844 
845  // Display the State member
846  msg = wxT( ". . " );
847 
848  if( GetState( TRACK_LOCKED ) )
849  msg[0] = 'L';
850 
851  if( GetState( TRACK_AR ) )
852  msg[2] = 'A';
853 
854  aList.emplace_back( _( "Status" ), msg, MAGENTA );
855 }
856 
857 
858 void TRACK::GetMsgPanelInfoBase( EDA_UNITS aUnits, std::vector<MSG_PANEL_ITEM>& aList )
859 {
860  wxString msg;
861  BOARD* board = GetBoard();
862 
863  aList.emplace_back( _( "Type" ), _( "Track" ), DARKCYAN );
864 
865  GetMsgPanelInfoBase_Common( aUnits, aList );
866 
867  // Display layer
868  if( board )
869  msg = board->GetLayerName( m_Layer );
870  else
871  msg.Printf(wxT("%d"), m_Layer );
872 
873  aList.emplace_back( _( "Layer" ), msg, BROWN );
874 
875  // Display width
876  msg = MessageTextFromValue( aUnits, m_Width, true );
877 
878  aList.emplace_back( _( "Width" ), msg, DARKCYAN );
879 
880  // Display segment length
881  msg = ::MessageTextFromValue( aUnits, GetLength() );
882  aList.emplace_back( _( "Segment Length" ), msg, DARKCYAN );
883 }
884 
885 
886 void VIA::GetMsgPanelInfoBase( EDA_UNITS aUnits, std::vector<MSG_PANEL_ITEM>& aList )
887 {
888  wxString msg;
889  BOARD* board = GetBoard();
890 
891  switch( GetViaType() )
892  {
893  default:
895  msg = wxT( "???" ); // Not used yet, does not exist currently
896  break;
897 
898  case VIATYPE::MICROVIA:
899  msg = _( "Micro Via" ); // from external layer (TOP or BOTTOM) from
900  // the near neighbor inner layer only
901  break;
902 
904  msg = _( "Blind/Buried Via" ); // from inner or external to inner
905  // or external layer (no restriction)
906  break;
907 
908  case VIATYPE::THROUGH:
909  msg = _( "Through Via" ); // Usual via (from TOP to BOTTOM layer only )
910  break;
911  }
912 
913  aList.emplace_back( _( "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.emplace_back( _( "Layers" ), msg, BROWN );
930 
931  // Display width
932  msg = MessageTextFromValue( aUnits, m_Width, true );
933 
934  // Display diameter value:
935  aList.emplace_back( _( "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() == VIATYPE::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.emplace_back( 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 
977 bool ARC::HitTest( const wxPoint& aPosition, int aAccuracy ) const
978 {
979  int max_dist = aAccuracy + ( m_Width / 2 );
980  wxPoint center = GetPosition();
981  wxPoint relpos = aPosition - center;
982  double dist = EuclideanNorm( relpos );
983  double radius = GetRadius();
984 
985  if( std::abs( dist - radius ) > max_dist )
986  return false;
987 
988  double arc_angle_start = GetArcAngleStart(); // Always 0.0 ... 360 deg, in 0.1 deg
989  double arc_hittest = ArcTangente( relpos.y, relpos.x );
990 
991  // Calculate relative angle between the starting point of the arc, and the test point
992  arc_hittest -= arc_angle_start;
993 
994  // Normalise arc_hittest between 0 ... 360 deg
995  NORMALIZE_ANGLE_POS( arc_hittest );
996  double arc_angle = GetAngle();
997 
998  if( arc_angle < 0 )
999  return arc_hittest >= 3600 + arc_angle;
1000 
1001  return arc_hittest <= GetAngle();
1002 }
1003 
1004 
1005 bool VIA::HitTest( const wxPoint& aPosition, int aAccuracy ) const
1006 {
1007  int max_dist = aAccuracy + ( m_Width / 2 );
1008 
1009  // rel_pos is aPosition relative to m_Start (or the center of the via)
1010  wxPoint rel_pos = aPosition - m_Start;
1011  double dist = (double) rel_pos.x * rel_pos.x + (double) rel_pos.y * rel_pos.y;
1012  return dist <= (double) max_dist * max_dist;
1013 }
1014 
1015 
1016 bool TRACK::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
1017 {
1018  EDA_RECT arect = aRect;
1019  arect.Inflate( aAccuracy );
1020 
1021  if( aContained )
1022  /* Tracks are a special case:
1023  * they are considered inside the rect if one end is inside the rect */
1024  return arect.Contains( GetStart() ) || arect.Contains( GetEnd() );
1025  else
1026  return arect.Intersects( GetStart(), GetEnd() );
1027 }
1028 
1029 
1030 bool ARC::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
1031 {
1032  EDA_RECT box;
1033  EDA_RECT arect = aRect;
1034  arect.Inflate( aAccuracy );
1035 
1036  box.SetOrigin( GetStart() );
1037  box.Merge( GetMid() );
1038  box.Merge( GetEnd() );
1039 
1040  box.Inflate( GetWidth() / 2 );
1041 
1042  if( aContained )
1043  return arect.Contains( box );
1044  else
1045  return arect.Intersects( box );
1046 }
1047 
1048 
1049 bool VIA::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
1050 {
1051  EDA_RECT box;
1052  EDA_RECT arect = aRect;
1053  arect.Inflate( aAccuracy );
1054 
1055  box.SetOrigin( GetStart() );
1056  box.Inflate( GetWidth() / 2 );
1057 
1058  if( aContained )
1059  {
1060  return arect.Contains( box );
1061  }
1062  else
1063  {
1064  return arect.IntersectsCircle( GetStart(), GetWidth() / 2 );
1065  }
1066 }
1067 
1068 
1069 wxString TRACK::GetSelectMenuText( EDA_UNITS aUnits ) const
1070 {
1071  return wxString::Format( _("Track %s %s on %s, length: %s" ),
1072  MessageTextFromValue( aUnits, m_Width ),
1073  GetNetnameMsg(),
1074  GetLayerName(),
1075  MessageTextFromValue( aUnits, GetLength() ) );
1076 }
1077 
1078 
1080 {
1081  return add_tracks_xpm;
1082 }
1083 
1085 {
1086  assert( aImage->Type() == PCB_TRACE_T );
1087 
1088  std::swap( *((TRACK*) this), *((TRACK*) aImage) );
1089 }
1090 
1091 void ARC::SwapData( BOARD_ITEM* aImage )
1092 {
1093  assert( aImage->Type() == PCB_ARC_T );
1094 
1095  std::swap( *this, *static_cast<ARC*>( aImage ) );
1096 }
1097 
1098 void VIA::SwapData( BOARD_ITEM* aImage )
1099 {
1100  assert( aImage->Type() == PCB_VIA_T );
1101 
1102  std::swap( *((VIA*) this), *((VIA*) aImage) );
1103 }
1104 
1105 
1107 {
1108  auto center = GetArcCenter( VECTOR2I( m_Start ), VECTOR2I( m_Mid ), VECTOR2I( m_End ) );
1109  return wxPoint( center.x, center.y );
1110 }
1111 
1112 double ARC::GetRadius() const
1113 {
1114  auto center = GetArcCenter( VECTOR2I( m_Start ), VECTOR2I( m_Mid ), VECTOR2I( m_End ) );
1115  return GetLineLength( wxPoint( center ), m_Start );
1116 }
1117 
1118 double ARC::GetAngle() const
1119 {
1120  wxPoint center = GetPosition();
1121  wxPoint p0 = m_Start - center;
1122  wxPoint p1 = m_Mid - center;
1123  wxPoint p2 = m_End - center;
1124  double angle1 = ArcTangente( p1.y, p1.x ) - ArcTangente( p0.y, p0.x );
1125  double angle2 = ArcTangente( p2.y, p2.x ) - ArcTangente( p1.y, p1.x );
1126 
1127  return NormalizeAngle180( angle1 ) + NormalizeAngle180( angle2 );
1128 }
1129 
1131 {
1132  wxPoint center = GetPosition();
1133 
1134  double angleStart = ArcTangente( m_Start.y - center.y,
1135  m_Start.x - center.x );
1136  return NormalizeAnglePos( angleStart );
1137 }
1138 
1139 double ARC::GetArcAngleEnd() const
1140 {
1141  wxPoint center = GetPosition();
1142 
1143  double angleEnd = ArcTangente( m_End.y - center.y,
1144  m_End.x - center.x );
1145  return NormalizeAnglePos( angleEnd );
1146 }
1147 
1148 
1149 #if defined(DEBUG)
1150 
1151 wxString TRACK::ShowState( int stateBits )
1152 {
1153  wxString ret;
1154 
1155  if( stateBits & IS_LINKED )
1156  ret << wxT( " | IS_LINKED" );
1157 
1158  if( stateBits & TRACK_AR )
1159  ret << wxT( " | TRACK_AR" );
1160 
1161  if( stateBits & TRACK_LOCKED )
1162  ret << wxT( " | TRACK_LOCKED" );
1163 
1164  if( stateBits & IN_EDIT )
1165  ret << wxT( " | IN_EDIT" );
1166 
1167  if( stateBits & IS_DRAGGED )
1168  ret << wxT( " | IS_DRAGGED" );
1169 
1170  if( stateBits & DO_NOT_DRAW )
1171  ret << wxT( " | DO_NOT_DRAW" );
1172 
1173  if( stateBits & IS_DELETED )
1174  ret << wxT( " | IS_DELETED" );
1175 
1176  if( stateBits & BUSY )
1177  ret << wxT( " | BUSY" );
1178 
1179  if( stateBits & END_ONPAD )
1180  ret << wxT( " | END_ONPAD" );
1181 
1182  if( stateBits & BEGIN_ONPAD )
1183  ret << wxT( " | BEGIN_ONPAD" );
1184 
1185  if( stateBits & FLAG0 )
1186  ret << wxT( " | FLAG0" );
1187 
1188  if( stateBits & FLAG1 )
1189  ret << wxT( " | FLAG1" );
1190 
1191  return ret;
1192 }
1193 
1194 #endif
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:128
virtual void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
#define MIN_VIA_DRAW_SIZE
Definition: class_track.h:73
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:686
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
Definition: base_struct.h:117
EDA_UNITS
Definition: common.h:184
#define FLAG1
Pcbnew: flag used in local computations.
Definition: base_struct.h:136
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
VIATYPE m_ViaType
Definition: class_track.h:469
#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:256
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:103
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:206
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
void Merge(const EDA_RECT &aRect)
Function Merge modifies the position and size of the rectangle in order to contain aRect.
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer given by aLayer.
PNG memory record (file in memory).
Definition: bitmap_def.h:29
static const int dist[10][10]
Definition: ar_matrix.cpp:326
#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...
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.
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:111
Definition: colors.h:61
void GetMsgPanelInfo(EDA_UNITS aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
bool IsMoving() const
Definition: base_struct.h:222
int color
Definition: DXF_plotter.cpp:61
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Function FlippedLayerNumber.
Definition: lset.cpp:485
virtual void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Function Flip Flip this object, i.e.
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:73
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...
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
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
ARC(BOARD_ITEM *aParent)
Definition: class_track.h:265
#define BUSY
Pcbnew: flag indicating that the structure has.
Definition: base_struct.h:140
const BITMAP_OPAQUE add_tracks_xpm[1]
Definition: add_tracks.cpp:31
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:257
VIA(BOARD_ITEM *aParent)
Definition: class_track.cpp:85
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
void GRFilledCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:619
#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...
BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected and have...
bool Contains(const wxPoint &aPoint) const
Function Contains.
const wxString & GetShortNetname() const
Function GetShortNetname.
Definition: netinfo.h:238
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:223
Definitions for tracks, vias and zones.
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
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:220
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
virtual unsigned int ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Function ViewGetLOD() Returns the level of detail (LOD) of the item.
T NormalizeAngle180(T Angle)
Normalize angle to be in the -180.0 .. 180.0 range.
Definition: trigo.h:345
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
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.
LSET is a set of PCB_LAYER_IDs.
const wxPoint & GetMid() const
Definition: class_track.h:292
#define NULL
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
virtual void GetMsgPanelInfoBase(EDA_UNITS aUnits, std::vector< MSG_PANEL_ITEM > &aList)
Function GetMsgPanelInfoBase Display info about the track segment only, and does not calculate the fu...
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
wxPoint m_End
Line end point.
Definition: class_track.h:257
to draw usual through hole vias
int m_Drill
Definition: class_track.h:471
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.
virtual wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
const wxString & GetNetname() const
Function GetNetname.
Definition: netinfo.h:232
unsigned STATUS_FLAGS
Definition: base_struct.h:159
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:467
unsigned int ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Function ViewGetLOD() Returns the level of detail (LOD) of the item.
#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.
double GetRadius() const
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
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:452
#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.
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Function IsElementVisible tests whether a given element category is visible.
virtual const wxPoint GetPosition() const override
wxString MessageTextFromValue(EDA_UNITS aUnits, int aValue, bool aUseMils, EDA_DATA_TYPE aType)
Definition: base_units.cpp:127
double GetAngle() const
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on.
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:301
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:431
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:188
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
see class PGM_BASE
int GetWidth() const
Definition: class_track.h:105
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
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: class_track.cpp:79
BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:163
#define _(s)
Definition: 3d_actions.cpp:33
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
T NormalizeAnglePos(T Angle)
Normalize angle to be in the 0.0 .
Definition: trigo.h:248
double GetArcAngleEnd() const
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
Definition: gr_basic.cpp:596
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:189
int GetCopperLayerCount() const
Function GetCopperLayerCount.
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:126
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
VIATYPE GetViaType() const
Definition: class_track.h:416
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:61
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:166
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:108
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)
virtual double GetLength() const
Function GetLength returns the length of the track using the hypotenuse calculation.
Definition: class_track.h:141
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:52
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
void GetMsgPanelInfoBase_Common(EDA_UNITS aUnits, std::vector< MSG_PANEL_ITEM > &aList)
double GetArcAngleStart() const
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:66
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Function IsOnLayer tests to see if this object is on the given layer.
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:162
Definition: colors.h:45
EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
VIEW.
Definition: view.h:61
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:397
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.
void GetMsgPanelInfoBase(EDA_UNITS aUnits, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfoBase Display info about the track segment only, and does not calculate the fu...
wxString GetLayerName() const
Function GetLayerName returns the name of the PCB layer on which the item resides.
void SetViaType(VIATYPE aViaType)
Definition: class_track.h:421
#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:462
int GetState(int type) const
Definition: base_struct.h:241
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Function Flip Flip this object, i.e.
wxPoint m_Mid
Arc mid point, halfway between start and end.
Definition: class_track.h:336
const BITMAP_OPAQUE via_xpm[1]
PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
virtual 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.
#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:94
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:212
#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.
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:40
Definition: colors.h:62