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 
32 #include <fctsys.h>
33 #include <gr_basic.h>
34 #include <common.h>
35 #include <trigo.h>
36 #include <macros.h>
37 #include <class_drawpanel.h>
38 #include <class_pcb_screen.h>
39 #include <drawtxt.h>
40 #include <wxstruct.h>
41 #include <wxBasePcbFrame.h>
42 #include <class_board.h>
43 #include <class_track.h>
44 #include <pcbnew.h>
45 #include <base_units.h>
46 #include <msgpanel.h>
47 #include <bitmaps.h>
48 
54 static bool ShowClearance( DISPLAY_OPTIONS* aDisplOpts, const TRACK* aTrack )
55 {
56  // maybe return true for tracks and vias, not for zone segments
57  return IsCopperLayer( aTrack->GetLayer() )
58  && ( aTrack->Type() == PCB_TRACE_T || aTrack->Type() == PCB_VIA_T )
60  && ( aTrack->IsDragging() || aTrack->IsMoving() || aTrack->IsNew() ) )
62  );
63 
64 }
65 
66 
67 TRACK* GetTrack( TRACK* aStartTrace, const TRACK* aEndTrace,
68  const wxPoint& aPosition, LSET aLayerMask )
69 {
70  for( TRACK* seg = aStartTrace; seg; seg = seg->Next() )
71  {
72  if( seg->GetState( IS_DELETED | BUSY ) == 0 )
73  {
74  if( aPosition == seg->GetStart() )
75  {
76  if( ( aLayerMask & seg->GetLayerSet() ).any() )
77  return seg;
78  }
79 
80  if( aPosition == seg->GetEnd() )
81  {
82  if( ( aLayerMask & seg->GetLayerSet() ).any() )
83  return seg;
84  }
85  }
86 
87  if( seg == aEndTrace )
88  break;
89  }
90 
91  return NULL;
92 }
93 
94 
95 TRACK::TRACK( BOARD_ITEM* aParent, KICAD_T idtype ) :
96  BOARD_CONNECTED_ITEM( aParent, idtype )
97 {
98  m_Width = Millimeter2iu( 0.2 );
99  start = end = NULL;
100  m_Param = 0;
101 }
102 
103 
105 {
106  return new TRACK( *this );
107 }
108 
109 
110 wxString TRACK::ShowWidth() const
111 {
112  wxString msg = ::CoordinateToString( m_Width );
113  return msg;
114 }
115 
116 
118  TRACK( aParent, PCB_ZONE_T )
119 {
120 }
121 
122 
124 {
125  return new SEGZONE( *this );
126 }
127 
128 
130 {
131  wxString text, nettxt;
132  BOARD* board = GetBoard();
133 
134  if( board )
135  {
136  nettxt = GetNetname();
137  }
138  else
139  {
140  wxFAIL_MSG( wxT( "SEGZONE::GetSelectMenuText: BOARD is NULL" ) );
141  nettxt = wxT( "???" );
142  }
143 
144  text.Printf( _( "Zone (%08lX) [%s] on %s" ),
145  m_TimeStamp, GetChars( nettxt ), GetChars( GetLayerName() ) );
146 
147  return text;
148 }
149 
150 
152 {
153  return add_zone_xpm;
154 }
155 
156 
157 VIA::VIA( BOARD_ITEM* aParent ) :
158  TRACK( aParent, PCB_VIA_T )
159 {
162  SetDrillDefault();
163 }
164 
165 
167 {
168  return new VIA( *this );
169 }
170 
171 
172 wxString VIA::GetSelectMenuText() const
173 {
174  wxString text;
175  wxString format;
176  BOARD* board = GetBoard();
177 
178  switch( GetViaType() )
179  {
180  case VIA_BLIND_BURIED:
181  format = _( "Blind/Buried Via %s, net[%s] (%d) on layers %s/%s" );
182  break;
183  case VIA_MICROVIA:
184  format = _( "Micro Via %s, Net [%s] (%d) on layers %s/%s" );
185  break;
186  // else say nothing about normal (through) vias
187  default:
188  format = _( "Via %s net [%s] (%d) on layers %s/%s" );
189  break;
190  }
191 
192 
193  if( board )
194  {
195  wxString netname = GetNetname();
196 
197  // say which layers, only two for now
198  PCB_LAYER_ID topLayer;
199  PCB_LAYER_ID botLayer;
200  LayerPair( &topLayer, &botLayer );
201  text.Printf( format.GetData(), GetChars( ShowWidth() ),
202  GetChars( netname ), GetNetCode(),
203  GetChars( board->GetLayerName( topLayer ) ),
204  GetChars( board->GetLayerName( botLayer ) ) );
205 
206  }
207  else
208  {
209  wxFAIL_MSG( wxT( "VIA::GetSelectMenuText: BOARD is NULL" ) );
210  text.Printf( format.GetData(), GetChars( ShowWidth() ),
211  wxT( "???" ), 0,
212  wxT( "??" ), wxT( "??" ) );
213  }
214 
215  return text;
216 }
217 
218 
220 {
221  return via_sketch_xpm;
222 }
223 
224 
226 {
227  // Currently tracks have no specific clearance parameter on a per track or per
228  // segment basis. The NETCLASS clearance is used.
229  return BOARD_CONNECTED_ITEM::GetClearance( aItem );
230 }
231 
232 
234 {
235  if( m_Drill > 0 ) // Use the specific value.
236  return m_Drill;
237 
238  // Use the default value from the Netclass
239  NETCLASSPTR netclass = GetNetClass();
240 
241  if( GetViaType() == VIA_MICROVIA )
242  return netclass->GetuViaDrill();
243 
244  return netclass->GetViaDrill();
245 }
246 
247 
249 {
250  if( ( Type() != PCB_VIA_T ) && ( m_Start == m_End ) )
251  return true;
252  else
253  return false;
254 }
255 
256 
257 STATUS_FLAGS TRACK::IsPointOnEnds( const wxPoint& point, int min_dist )
258 {
259  STATUS_FLAGS result = 0;
260 
261  if( min_dist < 0 )
262  min_dist = m_Width / 2;
263 
264  if( min_dist == 0 )
265  {
266  if( m_Start == point )
267  result |= STARTPOINT;
268 
269  if( m_End == point )
270  result |= ENDPOINT;
271  }
272  else
273  {
274  double dist = GetLineLength( m_Start, point );
275 
276  if( min_dist >= KiROUND( dist ) )
277  result |= STARTPOINT;
278 
279  dist = GetLineLength( m_End, point );
280 
281  if( min_dist >= KiROUND( dist ) )
282  result |= ENDPOINT;
283  }
284 
285  return result;
286 }
287 
288 
290 {
291  // end of track is round, this is its radius, rounded up
292  int radius;
293 
294  int ymax;
295  int xmax;
296 
297  int ymin;
298  int xmin;
299 
300  if( Type() == PCB_VIA_T )
301  {
302  // Because vias are sometimes drawn larger than their m_Width would
303  // provide, erasing them using a dirty rect must also compensate for this
304  // possibility (that the via is larger on screen than its m_Width would provide).
305  // Because it is cheap to return a larger BoundingBox, do it so that
306  // the via gets erased properly. Do not divide width by 2 for this reason.
307  radius = m_Width;
308 
309  ymax = m_Start.y;
310  xmax = m_Start.x;
311 
312  ymin = m_Start.y;
313  xmin = m_Start.x;
314  }
315  else
316  {
317  radius = ( m_Width + 1 ) / 2;
318 
319  ymax = std::max( m_Start.y, m_End.y );
320  xmax = std::max( m_Start.x, m_End.x );
321 
322  ymin = std::min( m_Start.y, m_End.y );
323  xmin = std::min( m_Start.x, m_End.x );
324  }
325 
326  // + 1 is for the clearance line itself.
327  radius += GetClearance() + 1;
328 
329  ymax += radius;
330  xmax += radius;
331 
332  ymin -= radius;
333  xmin -= radius;
334 
335  // return a rectangle which is [pos,dim) in nature. therefore the +1
336  EDA_RECT ret( wxPoint( xmin, ymin ), wxSize( xmax - xmin + 1, ymax - ymin + 1 ) );
337 
338  return ret;
339 }
340 
341 
342 void TRACK::Rotate( const wxPoint& aRotCentre, double aAngle )
343 {
344  RotatePoint( &m_Start, aRotCentre, aAngle );
345  RotatePoint( &m_End, aRotCentre, aAngle );
346 }
347 
348 
349 void TRACK::Flip( const wxPoint& aCentre )
350 {
351  m_Start.y = aCentre.y - (m_Start.y - aCentre.y);
352  m_End.y = aCentre.y - (m_End.y - aCentre.y);
353  int copperLayerCount = GetBoard()->GetCopperLayerCount();
354  SetLayer( FlipLayer( GetLayer(), copperLayerCount ) );
355 }
356 
357 
358 void VIA::Flip( const wxPoint& aCentre )
359 {
360  m_Start.y = aCentre.y - (m_Start.y - aCentre.y);
361  m_End.y = aCentre.y - (m_End.y - aCentre.y);
362 
363  if( GetViaType() != VIA_THROUGH )
364  {
365  int copperLayerCount = GetBoard()->GetCopperLayerCount();
366  PCB_LAYER_ID top_layer;
367  PCB_LAYER_ID bottom_layer;
368  LayerPair( &top_layer, &bottom_layer );
369  top_layer = FlipLayer( top_layer, copperLayerCount );
370  bottom_layer = FlipLayer( bottom_layer, copperLayerCount );
371  SetLayerPair( top_layer, bottom_layer );
372  }
373 }
374 
375 
376 // see class_track.h
377 SEARCH_RESULT TRACK::Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] )
378 {
379  KICAD_T stype = *scanTypes;
380 
381  // If caller wants to inspect my type
382  if( stype == Type() )
383  {
384  if( SEARCH_QUIT == inspector( this, testData ) )
385  return SEARCH_QUIT;
386  }
387 
388  return SEARCH_CONTINUE;
389 }
390 
391 
392 bool VIA::IsOnLayer( PCB_LAYER_ID layer_number ) const
393 {
394  PCB_LAYER_ID bottom_layer, top_layer;
395 
396  LayerPair( &top_layer, &bottom_layer );
397 
398  wxASSERT( top_layer <= bottom_layer );
399 
400  if( top_layer <= layer_number && layer_number <= bottom_layer )
401  return true;
402  else
403  return false;
404 }
405 
406 
408 {
409  if( GetViaType() == VIA_THROUGH )
410  return LSET::AllCuMask();
411 
412  // VIA_BLIND_BURIED or VIA_MICRVIA:
413 
414  LSET layermask;
415 
416  wxASSERT( m_Layer <= m_BottomLayer );
417 
418  // PCB_LAYER_IDs are numbered from front to back, this is top to bottom.
419  for( LAYER_NUM id = m_Layer; id <= m_BottomLayer; ++id )
420  {
421  layermask.set( id );
422  }
423 
424  return layermask;
425 }
426 
427 
428 void VIA::SetLayerPair( PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer )
429 {
430  if( GetViaType() == VIA_THROUGH )
431  {
432  aTopLayer = F_Cu;
433  aBottomLayer = B_Cu;
434  }
435 
436  if( aBottomLayer < aTopLayer )
437  std::swap( aBottomLayer, aTopLayer );
438 
439  m_Layer = aTopLayer;
440  m_BottomLayer = aBottomLayer;
441 }
442 
443 
444 void VIA::LayerPair( PCB_LAYER_ID* top_layer, PCB_LAYER_ID* bottom_layer ) const
445 {
446  PCB_LAYER_ID t_layer = F_Cu;
447  PCB_LAYER_ID b_layer = B_Cu;
448 
449  if( GetViaType() != VIA_THROUGH )
450  {
451  b_layer = m_BottomLayer;
452  t_layer = m_Layer;
453 
454  if( b_layer < t_layer )
455  std::swap( b_layer, t_layer );
456  }
457 
458  if( top_layer )
459  *top_layer = t_layer;
460 
461  if( bottom_layer )
462  *bottom_layer = b_layer;
463 }
464 
465 
467 {
468  TRACK* track;
469 
470  if( Type() == PCB_ZONE_T )
471  track = aPcb->m_Zone;
472  else
473  track = aPcb->m_Track;
474 
475  for( ; track; track = track->Next() )
476  {
477  if( GetNetCode() <= track->GetNetCode() )
478  return track;
479  }
480 
481  return NULL;
482 }
483 
484 
486 {
487  TRACK* Track = this;
488  int ii = 0;
489 
490  if( NetCode == -1 )
491  NetCode = GetNetCode();
492 
493  while( Track != NULL )
494  {
495  if( Track->GetNetCode() > NetCode )
496  break;
497 
498  if( Track->GetNetCode() == NetCode )
499  {
500  ii++;
501  break;
502  }
503 
504  Track = (TRACK*) Track->Pnext;
505  }
506 
507  if( ii )
508  return Track;
509  else
510  return NULL;
511 }
512 
513 
515 {
516  TRACK* NextS, * Track = this;
517  int ii = 0;
518 
519  if( Track == NULL )
520  return NULL;
521 
522  if( NetCode == -1 )
523  NetCode = GetNetCode();
524 
525  while( Track != NULL )
526  {
527  NextS = (TRACK*) Track->Pnext;
528 
529  if( Track->GetNetCode() == NetCode )
530  ii++;
531 
532  if( NextS == NULL )
533  break;
534 
535  if( NextS->GetNetCode() > NetCode )
536  break;
537 
538  Track = NextS;
539  }
540 
541  if( ii )
542  return Track;
543  else
544  return NULL;
545 }
546 
548  wxDC* aDC, GR_DRAWMODE aDrawMode, COLOR4D aBgColor )
549 {
550  if( ! panel )
551  return;
552 
553  /* we must filter tracks, to avoid a lot of texts.
554  * - only tracks with a length > 10 * thickness are eligible
555  * and, of course, if we are not printing the board
556  */
557  DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions();
558 
559  if( displ_opts->m_DisplayNetNamesMode == 0 || displ_opts->m_DisplayNetNamesMode == 1 )
560  return;
561 
562  #define THRESHOLD 10
563 
564  int len = KiROUND( GetLineLength( m_Start, m_End ) );
565 
566  if( len < THRESHOLD * m_Width )
567  return;
568 
569  // no room to display a text inside track
570  if( aDC->LogicalToDeviceXRel( m_Width ) < MIN_TEXT_SIZE )
571  return;
572 
574  return;
575 
576  NETINFO_ITEM* net = GetNet();
577 
578  if( net == NULL )
579  return;
580 
581  int textlen = net->GetShortNetname().Len();
582 
583  if( textlen > 0 )
584  {
585  // calculate a good size for the text
586  int tsize = std::min( m_Width, len / textlen );
587  int dx = m_End.x - m_Start.x ;
588  int dy = m_End.y - m_Start.y ;
589  wxPoint tpos = m_Start + m_End;
590  tpos.x /= 2;
591  tpos.y /= 2;
592 
593  // Calculate angle: if the track segment is vertical, angle = 90 degrees
594  // If horizontal 0 degrees, otherwise compute it
595  double angle; // angle is in 0.1 degree
596 
597  if( dy == 0 ) // Horizontal segment
598  {
599  angle = 0;
600  }
601  else
602  {
603  if( dx == 0 ) // Vertical segment
604  {
605  angle = 900;
606  }
607  else
608  {
609  /* atan2 is *not* the solution here, since it can give upside
610  down text. We want to work only in the first and fourth quadrant */
611  angle = RAD2DECIDEG( -atan( double( dy ) / double( dx ) ) );
612  }
613  }
614 
615  PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
616 
617  if( ( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE )
618  && ( !(!IsOnLayer( curr_layer )&& displ_opts->m_ContrastModeDisplay) ) )
619  {
620  if( (aDrawMode & GR_XOR) == 0 )
621  GRSetDrawMode( aDC, GR_COPY );
622 
623  tsize = (tsize * 7) / 10; // small reduction to give a better look
624  DrawGraphicHaloText( panel->GetClipBox(), aDC, tpos,
625  aBgColor, BLACK, WHITE, net->GetShortNetname(), angle,
626  wxSize( tsize, tsize ),
628  tsize / 7,
629  false, false );
630  }
631  }
632 }
633 
634 
635 void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
636  const wxPoint& aOffset )
637 {
638  BOARD* brd = GetBoard();
639 
640  auto frame = static_cast<PCB_BASE_FRAME*> ( panel->GetParent() );
641  auto color = frame->Settings().Colors().GetLayerColor( m_Layer );
642 
643  if( brd->IsLayerVisible( m_Layer ) == false && !( aDrawMode & GR_HIGHLIGHT ) )
644  return;
645 
646 #ifdef USE_WX_OVERLAY
647  // If dragged not draw in OnPaint otherwise remains impressed in wxOverlay
648  if( (m_Flags & IS_DRAGGED) && aDC->IsKindOf(wxCLASSINFO(wxPaintDC)))
649  return;
650 #endif
651 
652  DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*) panel->GetDisplayOptions();
653 
654  if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts->m_ContrastModeDisplay )
655  {
656  PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
657 
658  if( !IsOnLayer( curr_layer ) )
660  }
661 
662  if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) )
663  color.SetToLegacyHighlightColor();
664 
665  color.a = 0.588;
666 
667  GRSetDrawMode( aDC, aDrawMode );
668 
669  // Draw track as line if width <= 1pixel:
670  if( aDC->LogicalToDeviceXRel( m_Width ) <= 1 )
671  {
672  GRLine( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
673  return;
674  }
675 
676  if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
677  {
678  GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
679  }
680  else
681  {
682  GRFillCSegm( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
683  m_Start.y + aOffset.y,
684  m_End.x + aOffset.x, m_End.y + aOffset.y, m_Width, color );
685  }
686 
687  if( panel->GetScreen()->m_IsPrinting )
688  return;
689 
690  // Show clearance for tracks, not for zone segments
691  if( ShowClearance( displ_opts, this ) )
692  {
693  GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset,
694  m_Width + (GetClearance() * 2), color );
695  }
696 
697  DrawShortNetname( panel, aDC, aDrawMode, color );
698 }
699 
700 
701 void SEGZONE::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
702  const wxPoint& aOffset )
703 {
704  DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)panel->GetDisplayOptions();
705 
706  if( displ_opts->m_DisplayZonesMode != 0 )
707  return;
708 
709  BOARD* brd = GetBoard();
710 
711  auto frame = static_cast<PCB_BASE_FRAME*> ( panel->GetParent() );
712  auto color = frame->Settings().Colors().GetLayerColor( m_Layer );
713 
714  if( brd->IsLayerVisible( m_Layer ) == false && !( aDrawMode & GR_HIGHLIGHT ) )
715  return;
716 
717 #ifdef USE_WX_OVERLAY
718  // If dragged not draw in OnPaint otherwise remains impressed in wxOverlay
719  if( (m_Flags & IS_DRAGGED) && aDC->IsKindOf(wxCLASSINFO(wxPaintDC)))
720  return;
721 #endif
722 
723  if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && displ_opts->m_ContrastModeDisplay )
724  {
725  PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
726 
727  if( !IsOnLayer( curr_layer ) )
729  }
730 
731  if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) )
732  color.SetToLegacyHighlightColor();
733 
734  color.a = 0.588;
735 
736  GRSetDrawMode( aDC, aDrawMode );
737 
738  // Draw track as line if width <= 1pixel:
739  if( aDC->LogicalToDeviceXRel( m_Width ) <= 1 )
740  {
741  GRLine( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
742  return;
743  }
744 
745  if( !displ_opts->m_DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
746  {
747  GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
748  }
749  else
750  {
751  GRFillCSegm( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
752  m_Start.y + aOffset.y,
753  m_End.x + aOffset.x, m_End.y + aOffset.y, m_Width, color );
754  }
755 
756  // No clearance or netnames for zones
757 }
758 
759 
760 void TRACK::ViewGetLayers( int aLayers[], int& aCount ) const
761 {
762  // Show the track and its netname on different layers
763  aLayers[0] = GetLayer();
764  aLayers[1] = GetNetnameLayer( aLayers[0] );
765  aCount = 2;
766 }
767 
768 
769 unsigned int TRACK::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
770 {
771  // Netnames will be shown only if zoom is appropriate
772  if( IsNetnameLayer( aLayer ) )
773  {
774  return ( 40000000 / ( m_Width + 1 ) );
775  }
776 
777  // Other layers are shown without any conditions
778  return 0;
779 }
780 
781 
782 void VIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, const wxPoint& aOffset )
783 {
784  wxCHECK_RET( panel != NULL, wxT( "VIA::Draw panel cannot be NULL." ) );
785 
786  int radius;
787  PCB_LAYER_ID curr_layer = ( (PCB_SCREEN*) panel->GetScreen() )->m_Active_Layer;
788 
789  int fillvia = 0;
790  PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent();
791  PCB_SCREEN* screen = frame->GetScreen();
792  DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)frame->GetDisplayOptions();
793 
794  if( displ_opts->m_DisplayViaFill == FILLED )
795  fillvia = 1;
796 
797  GRSetDrawMode( aDC, aDrawMode );
798 
799  BOARD * brd = GetBoard();
801 
802  if( brd->IsElementVisible( LAYER_VIAS + GetViaType() ) == false
803  && !( aDrawMode & GR_HIGHLIGHT ) )
804  return;
805 
806  // Only draw the via if at least one of the layers it crosses is being displayed
807  if( !( brd->GetVisibleLayers() & GetLayerSet() ).any() )
808  return;
809 
810  if( displ_opts->m_ContrastModeDisplay )
811  {
812  if( !IsOnLayer( curr_layer ) )
813  color = COLOR4D( DARKDARKGRAY );
814  }
815 
816  if( ( aDrawMode & GR_HIGHLIGHT ) && !( aDrawMode & GR_AND ) )
817  color.SetToLegacyHighlightColor();
818 
819  color.a = 0.588;
820 
821 
822  radius = m_Width >> 1;
823  // for small via size on screen (radius < 4 pixels) draw a simplified shape
824 
825  int radius_in_pixels = aDC->LogicalToDeviceXRel( radius );
826 
827  bool fast_draw = false;
828 
829  // Vias are drawn as a filled circle or a double circle. The hole will be drawn later
830  int drill_radius = GetDrillValue() / 2;
831 
832  int inner_radius = radius - aDC->DeviceToLogicalXRel( 2 );
833 
834  if( radius_in_pixels < MIN_VIA_DRAW_SIZE )
835  {
836  fast_draw = true;
837  fillvia = false;
838  }
839 
840  if( fillvia )
841  {
842  GRFilledCircle( panel->GetClipBox(), aDC, m_Start + aOffset, radius, color );
843  }
844  else
845  {
846  GRCircle( panel->GetClipBox(), aDC, m_Start + aOffset, radius, 0, color );
847 
848  if ( fast_draw )
849  return;
850 
851  GRCircle( panel->GetClipBox(), aDC, m_Start + aOffset, inner_radius, 0, color );
852  }
853 
854  if( fillvia )
855  {
856  bool blackpenstate = false;
857 
858  if( screen->m_IsPrinting )
859  {
860  blackpenstate = GetGRForceBlackPenState();
861  GRForceBlackPen( false );
862  color = WHITE;
863  }
864  else
865  {
866  color = BLACK; // or DARKGRAY;
867  }
868 
869  if( (aDrawMode & GR_XOR) == 0)
870  GRSetDrawMode( aDC, GR_COPY );
871 
872  // Draw hole if the radius is > 1pixel.
873  if( aDC->LogicalToDeviceXRel( drill_radius ) > 1 )
874  GRFilledCircle( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
875  m_Start.y + aOffset.y, drill_radius, 0, color, color );
876 
877  if( screen->m_IsPrinting )
878  GRForceBlackPen( blackpenstate );
879  }
880  else
881  {
882  if( drill_radius < inner_radius ) // We can show the via hole
883  GRCircle( panel->GetClipBox(), aDC, m_Start + aOffset, drill_radius, 0, color );
884  }
885 
886  if( ShowClearance( displ_opts, this ) )
887  {
888  GRCircle( panel->GetClipBox(), aDC, m_Start + aOffset, radius + GetClearance(), 0, color );
889  }
890 
891  // for Micro Vias, draw a partial cross : X on component layer, or + on copper layer
892  // (so we can see 2 superimposed microvias ):
893  if( GetViaType() == VIA_MICROVIA )
894  {
895  int ax, ay, bx, by;
896 
897  if( IsOnLayer( B_Cu ) )
898  {
899  ax = radius; ay = 0;
900  bx = drill_radius; by = 0;
901  }
902  else
903  {
904  ax = ay = (radius * 707) / 1000;
905  bx = by = (drill_radius * 707) / 1000;
906  }
907 
908  // lines '|' or '\'
909  GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x - ax,
910  m_Start.y + aOffset.y - ay,
911  m_Start.x + aOffset.x - bx,
912  m_Start.y + aOffset.y - by, 0, color );
913  GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x + bx,
914  m_Start.y + aOffset.y + by,
915  m_Start.x + aOffset.x + ax,
916  m_Start.y + aOffset.y + ay, 0, color );
917 
918  // lines - or '/'
919  GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x + ay,
920  m_Start.y + aOffset.y - ax,
921  m_Start.x + aOffset.x + by,
922  m_Start.y + aOffset.y - bx, 0, color );
923  GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x - by,
924  m_Start.y + aOffset.y + bx,
925  m_Start.x + aOffset.x - ay,
926  m_Start.y + aOffset.y + ax, 0, color );
927  }
928 
929  // for Buried Vias, draw a partial line : orient depending on layer pair
930  // (so we can see superimposed buried vias ):
931  if( GetViaType() == VIA_BLIND_BURIED )
932  {
933  int ax = 0, ay = radius, bx = 0, by = drill_radius;
934  PCB_LAYER_ID layer_top, layer_bottom;
935 
936  LayerPair( &layer_top, &layer_bottom );
937 
938  // lines for the top layer
939  RotatePoint( &ax, &ay, layer_top * 3600.0 / brd->GetCopperLayerCount( ) );
940  RotatePoint( &bx, &by, layer_top * 3600.0 / brd->GetCopperLayerCount( ) );
941  GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x - ax,
942  m_Start.y + aOffset.y - ay,
943  m_Start.x + aOffset.x - bx,
944  m_Start.y + aOffset.y - by, 0, color );
945 
946  // lines for the bottom layer
947  ax = 0; ay = radius; bx = 0; by = drill_radius;
948  RotatePoint( &ax, &ay, layer_bottom * 3600.0 / brd->GetCopperLayerCount( ) );
949  RotatePoint( &bx, &by, layer_bottom * 3600.0 / brd->GetCopperLayerCount( ) );
950  GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x - ax,
951  m_Start.y + aOffset.y - ay,
952  m_Start.x + aOffset.x - bx,
953  m_Start.y + aOffset.y - by, 0, color );
954  }
955 
956  // Display the short netname:
958  return;
959 
960  if( displ_opts->m_DisplayNetNamesMode == 0 || displ_opts->m_DisplayNetNamesMode == 1 )
961  return;
962 
963  NETINFO_ITEM* net = GetNet();
964 
965  if( net == NULL )
966  return;
967 
968  int len = net->GetShortNetname().Len();
969 
970  if( len > 0 )
971  {
972  // calculate a good size for the text
973  int tsize = m_Width / len;
974 
975  if( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE )
976  {
977  tsize = (tsize * 7) / 10; // small reduction to give a better look, inside via
978 
979  if( (aDrawMode & GR_XOR) == 0 )
980  GRSetDrawMode( aDC, GR_COPY );
981 
982  EDA_RECT* clipbox = panel->GetClipBox();
983  DrawGraphicHaloText( clipbox, aDC, m_Start,
984  color, WHITE, BLACK, net->GetShortNetname(), 0,
985  wxSize( tsize, tsize ),
987  tsize / 7, false, false );
988  }
989  }
990 }
991 
992 
993 void VIA::ViewGetLayers( int aLayers[], int& aCount ) const
994 {
995  aLayers[0] = LAYER_VIAS_HOLES;
996  aLayers[1] = LAYER_VIAS_NETNAMES;
997  aCount = 3;
998 
999  // Just show it on common via & via holes layers
1000  switch( GetViaType() )
1001  {
1002  case VIA_THROUGH:
1003  aLayers[2] = LAYER_VIA_THROUGH;
1004  break;
1005 
1006  case VIA_BLIND_BURIED:
1007  aLayers[2] = LAYER_VIA_BBLIND;
1008  aLayers[3] = m_Layer;
1009  aLayers[4] = m_BottomLayer;
1010  aCount += 2;
1011  break;
1012 
1013  case VIA_MICROVIA:
1014  aLayers[2] = LAYER_VIA_MICROVIA;
1015  break;
1016 
1017  default:
1018  aLayers[2] = LAYER_GP_OVERLAY;
1019  wxASSERT( false );
1020  break;
1021  }
1022 }
1023 
1024 
1025 unsigned int VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
1026 {
1027  BOARD* board = GetBoard();
1028 
1029  // Only draw the via if at least one of the layers it crosses is being displayed
1030  if( board && ( board->GetVisibleLayers() & GetLayerSet() ).any() )
1031  return 0;
1032 
1034 }
1035 
1036 
1037 // see class_track.h
1038 void TRACK::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
1039 {
1040  wxString msg;
1041  BOARD* board = GetBoard();
1042 
1043  // Display basic infos
1044  GetMsgPanelInfoBase( aList );
1045 
1046  // Display full track length (in Pcbnew)
1047  if( board )
1048  {
1049  double trackLen = 0;
1050  double lenPadToDie = 0;
1051  board->MarkTrace( this, NULL, &trackLen, &lenPadToDie, false );
1052  msg = ::LengthDoubleToString( trackLen );
1053  aList.push_back( MSG_PANEL_ITEM( _( "Length" ), msg, DARKCYAN ) );
1054 
1055  if( lenPadToDie != 0 )
1056  {
1057  msg = ::LengthDoubleToString( trackLen + lenPadToDie );
1058  aList.push_back( MSG_PANEL_ITEM( _( "Full Length" ), msg, DARKCYAN ) );
1059 
1060  msg = ::LengthDoubleToString( lenPadToDie );
1061  aList.push_back( MSG_PANEL_ITEM( _( "Pad To Die Length" ), msg, DARKCYAN ) );
1062  }
1063  }
1064 
1065  NETCLASSPTR netclass = GetNetClass();
1066 
1067  if( netclass )
1068  {
1069  aList.push_back( MSG_PANEL_ITEM( _( "NC Name" ), netclass->GetName(), DARKMAGENTA ) );
1070  aList.push_back( MSG_PANEL_ITEM( _( "NC Clearance" ),
1071  ::CoordinateToString( netclass->GetClearance(), true ),
1072  DARKMAGENTA ) );
1073  aList.push_back( MSG_PANEL_ITEM( _( "NC Width" ),
1074  ::CoordinateToString( netclass->GetTrackWidth(), true ),
1075  DARKMAGENTA ) );
1076  aList.push_back( MSG_PANEL_ITEM( _( "NC Via Size" ),
1077  ::CoordinateToString( netclass->GetViaDiameter(), true ),
1078  DARKMAGENTA ) );
1079  aList.push_back( MSG_PANEL_ITEM( _( "NC Via Drill"),
1080  ::CoordinateToString( netclass->GetViaDrill(), true ),
1081  DARKMAGENTA ) );
1082  }
1083 }
1084 
1085 void TRACK::GetMsgPanelInfoBase_Common( std::vector< MSG_PANEL_ITEM >& aList )
1086 {
1087  wxString msg;
1088 
1089  // Display Net Name
1090  if( GetBoard() )
1091  {
1092  NETINFO_ITEM* net = GetNet();
1093 
1094  if( net )
1095  msg = net->GetNetname();
1096  else
1097  msg = wxT( "<noname>" );
1098 
1099  aList.push_back( MSG_PANEL_ITEM( _( "NetName" ), msg, RED ) );
1100 
1101  // Display net code : (useful in test or debug)
1102  msg.Printf( wxT( "%d" ), GetNetCode() );
1103  aList.push_back( MSG_PANEL_ITEM( _( "NetCode" ), msg, RED ) );
1104  }
1105 
1106 #if defined(DEBUG)
1107 
1108  // Display the flags
1109  msg.Printf( wxT( "0x%08X" ), m_Flags );
1110  aList.push_back( MSG_PANEL_ITEM( wxT( "Flags" ), msg, BLUE ) );
1111 
1112 #if 0
1113  // Display start and end pointers:
1114  msg.Printf( wxT( "%p" ), start );
1115  aList.push_back( MSG_PANEL_ITEM( wxT( "start ptr" ), msg, BLUE ) );
1116  msg.Printf( wxT( "%p" ), end );
1117  aList.push_back( MSG_PANEL_ITEM( wxT( "end ptr" ), msg, BLUE ) );
1118  // Display this ptr
1119  msg.Printf( wxT( "%p" ), this );
1120  aList.push_back( MSG_PANEL_ITEM( wxT( "this" ), msg, BLUE ) );
1121 #endif
1122 
1123 #if 0
1124  // Display start and end positions:
1125  msg.Printf( wxT( "%d %d" ), m_Start.x, m_Start.y );
1126  aList.push_back( MSG_PANEL_ITEM( wxT( "Start pos" ), msg, BLUE ) );
1127  msg.Printf( wxT( "%d %d" ), m_End.x, m_End.y );
1128  aList.push_back( MSG_PANEL_ITEM( wxT( "End pos" ), msg, BLUE ) );
1129 #endif
1130 
1131 #endif // defined(DEBUG)
1132 
1133  // Display the State member
1134  msg = wxT( ". . " );
1135 
1136  if( GetState( TRACK_LOCKED ) )
1137  msg[0] = 'L';
1138 
1139  if( GetState( TRACK_AR ) )
1140  msg[2] = 'A';
1141 
1142  aList.push_back( MSG_PANEL_ITEM( _( "Status" ), msg, MAGENTA ) );
1143 }
1144 
1145 void TRACK::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList )
1146 {
1147  wxString msg;
1148  BOARD* board = GetBoard();
1149 
1150  aList.push_back( MSG_PANEL_ITEM( _( "Type" ), _( "Track" ), DARKCYAN ) );
1151 
1152  GetMsgPanelInfoBase_Common( aList );
1153 
1154  // Display layer
1155  if( board )
1156  msg = board->GetLayerName( m_Layer );
1157  else
1158  msg.Printf(wxT("%d"), m_Layer );
1159 
1160  aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), msg, BROWN ) );
1161 
1162  // Display width
1163  msg = ::CoordinateToString( (unsigned) m_Width );
1164 
1165  aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, DARKCYAN ) );
1166 
1167  // Display segment length
1168  msg = ::LengthDoubleToString( GetLength() );
1169  aList.push_back( MSG_PANEL_ITEM( _( "Segment Length" ), msg, DARKCYAN ) );
1170 }
1171 
1172 void SEGZONE::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList )
1173 {
1174  wxString msg;
1175  BOARD* board = GetBoard();
1176 
1177  aList.push_back( MSG_PANEL_ITEM( _( "Type" ), _( "Zone " ), DARKCYAN ) );
1178 
1179  GetMsgPanelInfoBase_Common( aList );
1180 
1181  // Display layer
1182  if( board )
1183  msg = board->GetLayerName( m_Layer );
1184  else
1185  msg.Printf( wxT( "%d" ), m_Layer );
1186 
1187  aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), msg, BROWN ) );
1188 
1189  // Display width
1190  msg = ::CoordinateToString( (unsigned) m_Width );
1191 
1192  aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, DARKCYAN ) );
1193 
1194  // Display segment length
1195  msg = ::LengthDoubleToString( GetLength() );
1196  aList.push_back( MSG_PANEL_ITEM( _( "Segment Length" ), msg, DARKCYAN ) );
1197 }
1198 
1199 void VIA::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList )
1200 {
1201  wxString msg;
1202  BOARD* board = GetBoard();
1203 
1204  switch( GetViaType() )
1205  {
1206  default:
1207  case VIA_NOT_DEFINED:
1208  msg = wxT( "???" ); // Not used yet, does not exist currently
1209  break;
1210 
1211  case VIA_MICROVIA:
1212  msg = _( "Micro Via" ); // from external layer (TOP or BOTTOM) from
1213  // the near neighbor inner layer only
1214  break;
1215 
1216  case VIA_BLIND_BURIED:
1217  msg = _( "Blind/Buried Via" ); // from inner or external to inner
1218  // or external layer (no restriction)
1219  break;
1220 
1221  case VIA_THROUGH:
1222  msg = _( "Through Via" ); // Usual via (from TOP to BOTTOM layer only )
1223  break;
1224  }
1225 
1226  aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, DARKCYAN ) );
1227 
1228  GetMsgPanelInfoBase_Common( aList );
1229 
1230 
1231  // Display layer pair
1232  PCB_LAYER_ID top_layer, bottom_layer;
1233 
1234  LayerPair( &top_layer, &bottom_layer );
1235 
1236  if( board )
1237  msg = board->GetLayerName( top_layer ) + wxT( "/" )
1238  + board->GetLayerName( bottom_layer );
1239  else
1240  msg.Printf( wxT( "%d/%d" ), top_layer, bottom_layer );
1241 
1242  aList.push_back( MSG_PANEL_ITEM( _( "Layers" ), msg, BROWN ) );
1243 
1244  // Display width
1245  msg = ::CoordinateToString( (unsigned) m_Width );
1246 
1247  // Display diameter value:
1248  aList.push_back( MSG_PANEL_ITEM( _( "Diameter" ), msg, DARKCYAN ) );
1249 
1250  // Display drill value
1251  int drill_value = GetDrillValue();
1252 
1253  msg = ::CoordinateToString( drill_value );
1254 
1255  wxString title = _( "Drill" );
1256  title += wxT( " " );
1257 
1258  bool drl_specific = true;
1259 
1260  if( GetBoard() )
1261  {
1262  NETINFO_ITEM* net = GetNet();
1263  int drill_class_value = 0;
1264 
1265  if( net )
1266  {
1267  if( GetViaType() == VIA_MICROVIA )
1268  drill_class_value = net->GetMicroViaDrillSize();
1269  else
1270  drill_class_value = net->GetViaDrillSize();
1271  }
1272 
1273  drl_specific = drill_value != drill_class_value;
1274  }
1275 
1276 
1277  if( drl_specific )
1278  title += _( "(Specific)" );
1279  else
1280  title += _( "(NetClass)" );
1281 
1282  aList.push_back( MSG_PANEL_ITEM( title, msg, RED ) );
1283 }
1284 
1285 
1286 bool TRACK::HitTest( const wxPoint& aPosition ) const
1287 {
1288  return TestSegmentHit( aPosition, m_Start, m_End, m_Width / 2 );
1289 }
1290 
1291 bool VIA::HitTest( const wxPoint& aPosition ) const
1292 {
1293  int max_dist = m_Width / 2;
1294 
1295  // rel_pos is aPosition relative to m_Start (or the center of the via)
1296  wxPoint rel_pos = aPosition - m_Start;
1297  double dist = (double) rel_pos.x * rel_pos.x + (double) rel_pos.y * rel_pos.y;
1298  return dist <= (double) max_dist * max_dist;
1299 }
1300 
1301 
1302 bool TRACK::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
1303 {
1304  EDA_RECT arect = aRect;
1305  arect.Inflate( aAccuracy );
1306 
1307  if( aContained )
1308  /* Tracks are a special case:
1309  * they are considered inside the rect if one end is inside the rect */
1310  return arect.Contains( GetStart() ) || arect.Contains( GetEnd() );
1311  else
1312  return arect.Intersects( GetStart(), GetEnd() );
1313 }
1314 
1315 bool VIA::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy ) const
1316 {
1317  EDA_RECT box;
1318  EDA_RECT arect = aRect;
1319  arect.Inflate( aAccuracy );
1320 
1321  box.SetOrigin( GetStart() );
1322  box.Inflate( GetWidth() / 2 );
1323 
1324  if( aContained )
1325  {
1326  return arect.Contains( box );
1327  }
1328  else
1329  {
1330  return arect.IntersectsCircle( GetStart(), GetWidth() / 2 );
1331  }
1332 }
1333 
1334 
1335 VIA* TRACK::GetVia( const wxPoint& aPosition, PCB_LAYER_ID aLayer)
1336 {
1337  for( VIA* via = GetFirstVia( this ); via; via = GetFirstVia( via->Next() ) )
1338  {
1339  if( via->HitTest( aPosition ) &&
1340  !via->GetState( BUSY | IS_DELETED ) &&
1341  ((aLayer == UNDEFINED_LAYER) || (via->IsOnLayer( aLayer ))) )
1342  return via;
1343  }
1344 
1345  return NULL;
1346 }
1347 
1348 
1349 VIA* TRACK::GetVia( TRACK* aEndTrace, const wxPoint& aPosition, LSET aLayerMask )
1350 {
1351  for( VIA* via = GetFirstVia( this, aEndTrace ); via; via = GetFirstVia( via->Next() ) )
1352  {
1353  if( via->HitTest( aPosition ) &&
1354  !via->GetState( BUSY | IS_DELETED ) &&
1355  ( aLayerMask & via->GetLayerSet() ).any()
1356  )
1357  {
1358  return via;
1359  }
1360  }
1361 
1362  return NULL;
1363 }
1364 
1365 
1366 TRACK* TRACK::GetTrack( TRACK* aStartTrace, TRACK* aEndTrace, ENDPOINT_T aEndPoint,
1367  bool aSameNetOnly, bool aSequential )
1368 {
1369  const wxPoint& position = GetEndPoint( aEndPoint );
1370  LSET refLayers = GetLayerSet();
1371  TRACK* previousSegment;
1372  TRACK* nextSegment;
1373 
1374  if( aSequential )
1375  {
1376  // Simple sequential search: from aStartTrace forward to aEndTrace
1377  previousSegment = NULL;
1378  nextSegment = aStartTrace;
1379  }
1380  else
1381  {
1382  /* Local bidirectional search: from this backward to aStartTrace
1383  * AND forward to aEndTrace. The idea is that nearest segments
1384  * are found (on average) faster in this way. In fact same-net
1385  * segments are almost guaranteed to be found faster, in a global
1386  * search, since they are grouped together in the track list */
1387  previousSegment = this;
1388  nextSegment = this;
1389  }
1390 
1391  while( nextSegment || previousSegment )
1392  {
1393  // Terminate the search in the direction if the netcode mis-matches
1394  if( aSameNetOnly )
1395  {
1396  if( nextSegment && (nextSegment->GetNetCode() != GetNetCode()) )
1397  nextSegment = NULL;
1398  if( previousSegment && (previousSegment->GetNetCode() != GetNetCode()) )
1399  previousSegment = NULL;
1400  }
1401 
1402  if( nextSegment )
1403  {
1404  if ( (nextSegment != this) &&
1405  !nextSegment->GetState( BUSY | IS_DELETED ) &&
1406  ( refLayers & nextSegment->GetLayerSet() ).any() )
1407  {
1408  if( (position == nextSegment->m_Start) ||
1409  (position == nextSegment->m_End) )
1410  return nextSegment;
1411  }
1412 
1413  // Keep looking forward
1414  if( nextSegment == aEndTrace )
1415  nextSegment = NULL;
1416  else
1417  nextSegment = nextSegment->Next();
1418  }
1419 
1420  // Same as above, looking back. During sequential search this branch is inactive
1421  if( previousSegment )
1422  {
1423  if( (previousSegment != this) &&
1424  !previousSegment->GetState( BUSY | IS_DELETED ) &&
1425  ( refLayers & previousSegment->GetLayerSet() ).any()
1426  )
1427  {
1428  if( (position == previousSegment->m_Start) ||
1429  (position == previousSegment->m_End) )
1430  return previousSegment;
1431  }
1432 
1433  if( previousSegment == aStartTrace )
1434  previousSegment = NULL;
1435  else
1436  previousSegment = previousSegment->Back();
1437  }
1438  }
1439 
1440  return NULL;
1441 }
1442 
1443 
1444 int TRACK::GetEndSegments( int aCount, TRACK** aStartTrace, TRACK** aEndTrace )
1445 {
1446  TRACK* Track, * via, * segm, * TrackListEnd;
1447  int NbEnds, ii, ok = 0;
1448  LSET layerMask;
1449 
1450  if( aCount <= 1 )
1451  {
1452  *aStartTrace = *aEndTrace = this;
1453  return 1;
1454  }
1455 
1456  // Calculation of the limit analysis.
1457  *aStartTrace = *aEndTrace = NULL;
1458  TrackListEnd = Track = this;
1459  ii = 0;
1460 
1461  for( ; ( Track != NULL ) && ( ii < aCount ); ii++, Track = Track->Next() )
1462  {
1463  TrackListEnd = Track;
1464  Track->m_Param = 0;
1465  }
1466 
1467  // Calculate the extremes.
1468  NbEnds = 0;
1469  Track = this;
1470  ii = 0;
1471 
1472  for( ; ( Track != NULL ) && ( ii < aCount ); ii++, Track = Track->Next() )
1473  {
1474  if( Track->Type() == PCB_VIA_T )
1475  continue;
1476 
1477  layerMask = Track->GetLayerSet();
1478  via = GetVia( TrackListEnd, Track->m_Start, layerMask );
1479 
1480  if( via )
1481  {
1482  layerMask |= via->GetLayerSet();
1483  via->SetState( BUSY, true );
1484  }
1485 
1486  Track->SetState( BUSY, true );
1487  segm = ::GetTrack( this, TrackListEnd, Track->m_Start, layerMask );
1488  Track->SetState( BUSY, false );
1489 
1490  if( via )
1491  via->SetState( BUSY, false );
1492 
1493  if( segm == NULL )
1494  {
1495  switch( NbEnds )
1496  {
1497  case 0:
1498  *aStartTrace = Track; NbEnds++;
1499  break;
1500 
1501  case 1:
1502  int BeginPad, EndPad;
1503  *aEndTrace = Track;
1504 
1505  // Swap ox, oy with fx, fy
1506  BeginPad = Track->GetState( BEGIN_ONPAD );
1507  EndPad = Track->GetState( END_ONPAD );
1508 
1509  Track->SetState( BEGIN_ONPAD | END_ONPAD, false );
1510 
1511  if( BeginPad )
1512  Track->SetState( END_ONPAD, true );
1513 
1514  if( EndPad )
1515  Track->SetState( BEGIN_ONPAD, true );
1516 
1517  std::swap( Track->m_Start, Track->m_End );
1518  std::swap( Track->start, Track->end );
1519  ok = 1;
1520  return ok;
1521  }
1522  }
1523 
1524  layerMask = Track->GetLayerSet();
1525  via = GetVia( TrackListEnd, Track->m_End, layerMask );
1526 
1527  if( via )
1528  {
1529  layerMask |= via->GetLayerSet();
1530  via->SetState( BUSY, true );
1531  }
1532 
1533  Track->SetState( BUSY, true );
1534  segm = ::GetTrack( this, TrackListEnd, Track->m_End, layerMask );
1535  Track->SetState( BUSY, false );
1536 
1537  if( via )
1538  via->SetState( BUSY, false );
1539 
1540  if( segm == NULL )
1541  {
1542  switch( NbEnds )
1543  {
1544  case 0:
1545  int BeginPad, EndPad;
1546  *aStartTrace = Track;
1547  NbEnds++;
1548 
1549  // Swap ox, oy with fx, fy
1550  BeginPad = Track->GetState( BEGIN_ONPAD );
1551  EndPad = Track->GetState( END_ONPAD );
1552 
1553  Track->SetState( BEGIN_ONPAD | END_ONPAD, false );
1554 
1555  if( BeginPad )
1556  Track->SetState( END_ONPAD, true );
1557 
1558  if( EndPad )
1559  Track->SetState( BEGIN_ONPAD, true );
1560 
1561  std::swap( Track->m_Start, Track->m_End );
1562  std::swap( Track->start, Track->end );
1563  break;
1564 
1565  case 1:
1566  *aEndTrace = Track;
1567  ok = 1;
1568  return ok;
1569  }
1570  }
1571  }
1572 
1573  return ok;
1574 }
1575 
1576 
1578 {
1579  wxString text;
1580  wxString netname;
1581  NETINFO_ITEM* net;
1582  BOARD* board = GetBoard();
1583 
1584  // deleting tracks requires all the information we can get to
1585  // disambiguate all the choices under the cursor!
1586  if( board )
1587  {
1588  net = GetNet();
1589 
1590  if( net )
1591  netname = net->GetNetname();
1592  else
1593  netname = _("Not found");
1594  }
1595  else
1596  {
1597  wxFAIL_MSG( wxT( "TRACK::GetSelectMenuText: BOARD is NULL" ) );
1598  netname = wxT( "???" );
1599  }
1600 
1601  text.Printf( _("Track %s, net [%s] (%d) on layer %s, length: %s" ),
1602  GetChars( ShowWidth() ), GetChars( netname ),
1605 
1606  return text;
1607 }
1608 
1609 
1611 {
1612  return showtrack_xpm;
1613 }
1614 
1615 
1616 #if defined(DEBUG)
1617 
1618 wxString TRACK::ShowState( int stateBits )
1619 {
1620  wxString ret;
1621 
1622  if( stateBits & IS_LINKED )
1623  ret << wxT( " | IS_LINKED" );
1624 
1625  if( stateBits & TRACK_AR )
1626  ret << wxT( " | TRACK_AR" );
1627 
1628  if( stateBits & TRACK_LOCKED )
1629  ret << wxT( " | TRACK_LOCKED" );
1630 
1631  if( stateBits & IN_EDIT )
1632  ret << wxT( " | IN_EDIT" );
1633 
1634  if( stateBits & IS_DRAGGED )
1635  ret << wxT( " | IS_DRAGGED" );
1636 
1637  if( stateBits & DO_NOT_DRAW )
1638  ret << wxT( " | DO_NOT_DRAW" );
1639 
1640  if( stateBits & IS_DELETED )
1641  ret << wxT( " | IS_DELETED" );
1642 
1643  if( stateBits & BUSY )
1644  ret << wxT( " | BUSY" );
1645 
1646  if( stateBits & END_ONPAD )
1647  ret << wxT( " | END_ONPAD" );
1648 
1649  if( stateBits & BEGIN_ONPAD )
1650  ret << wxT( " | BEGIN_ONPAD" );
1651 
1652  if( stateBits & FLAG0 )
1653  ret << wxT( " | FLAG0" );
1654 
1655  if( stateBits & FLAG1 )
1656  ret << wxT( " | FLAG1" );
1657 
1658  return ret;
1659 }
1660 
1661 #endif
#define MIN_VIA_DRAW_SIZE
Definition: class_track.h:60
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:646
#define IS_LINKED
Used in calculation to mark linked items (temporary use)
Definition: base_struct.h:124
wxString CoordinateToString(int aValue, bool aConvertToMils)
Function CoordinateToString is a helper to convert the integer coordinate aValue to a string in inche...
Definition: base_units.cpp:117
#define FLAG1
Pcbnew: flag used in local computations.
Definition: base_struct.h:144
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
void DrawGraphicHaloText(EDA_RECT *aClipBox, 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), PLOTTER *aPlotter)
Draw graphic text with a border, so that it can be read on different backgrounds. ...
Definition: drawtxt.cpp:176
to draw blind/buried vias
TRACK * GetTrack(TRACK *aStartTrace, TRACK *aEndTrace, ENDPOINT_T aEndPoint, bool aSameNetOnly, bool aSequential)
Function GetTrack returns the trace segment connected to the segment at aEndPoint from aStartTrace to...
bool IsNull()
Function IsNull returns true if segment length is zero.
TRACK * GetTrack(TRACK *aStartTrace, const TRACK *aEndTrace, const wxPoint &aPosition, LSET aLayerMask)
Function GetTrack is a helper function to locate a trace segment having an end point at aPosition on ...
Definition: class_track.cpp:67
bool IsMoving() const
Definition: base_struct.h:232
#define IN_EDIT
Item currently edited.
Definition: base_struct.h:125
static bool ShowClearance(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:54
wxPoint m_Start
Line start point.
Definition: class_track.h:334
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:191
PNG memory record (file in memory).
Definition: bitmap_types.h:38
#define END_ONPAD
Pcbnew: flag set for track segment ending on a pad.
Definition: base_struct.h:147
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE draw_mode)
Definition: gr_basic.cpp:290
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:440
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Function IsOnLayer tests to see if this object is on the given layer.
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...
bool IsNew() const
Definition: base_struct.h:230
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
time_t m_TimeStamp
Time stamp used for logical links.
Definition: base_struct.h:183
bool Contains(const wxPoint &aPoint) const
Function Contains.
void GRLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:352
virtual void Flip(const wxPoint &aCentre) override
Function Flip Flip this object, i.e.
bool IntersectsCircle(const wxPoint &aCenter, const int aRadius) const
Function IntersectsCircle tests for a common area between a circle and this rectangle.
Class BOARD to handle a board.
Definition: colors.h:61
STATUS_FLAGS IsPointOnEnds(const wxPoint &point, int min_dist=0)
Function IsPointOnEnds returns STARTPOINT if point if near (dist = min_dist) start point...
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Function FlippedLayerNumber.
Definition: lset.cpp:445
int GetCopperLayerCount() const
Function GetCopperLayerCount.
static const int dist[10][10]
Definition: dist.cpp:57
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
virtual 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.
to draw via holes (pad holes do not use this layer)
double RAD2DECIDEG(double rad)
Definition: trigo.h:204
void SetOrigin(const wxPoint &pos)
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:481
int GetEndSegments(int NbSegm, TRACK **StartTrack, TRACK **EndTrack)
Function GetEndSegments get the segments connected to the end point of the track. ...
DLIST< SEGZONE > m_Zone
Definition: class_board.h:247
void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
#define BUSY
Pcbnew: flag indicating that the structure has.
Definition: base_struct.h:148
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
VIA(BOARD_ITEM *aParent)
virtual void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
int GetState(int type) const
Definition: base_struct.h:251
void GRFilledCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:833
#define BEGIN_ONPAD
Pcbnew: flag set for track segment starting on a pad.
Definition: base_struct.h:146
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
TRACK * Back() const
Definition: class_track.h:99
wxString GetLayerName() const
Function GetLayerName returns the name of the PCB layer on which the item resides.
const wxPoint & GetEnd() const
Definition: class_track.h:118
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:90
Functions relatives to tracks, vias and segments used to fill zones.
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:107
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
double m_Param
Definition: class_track.h:92
int m_Width
Thickness of track, or via diameter.
Definition: class_track.h:333
This file contains miscellaneous commonly used macros and functions.
ENDPOINT_T
Flag used in locate routines (from which endpoint work)
Definition: pcbnew.h:54
virtual void GetMsgPanelInfoBase(std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfoBase Display info about the track segment only, and does not calculate the fu...
virtual unsigned int ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Function ViewGetLOD() Returns the level of detail of the item.
#define THRESHOLD
COLOR4D GetItemColor(int aItemIdx) const
Function GetItemColor.
const INSPECTOR_FUNC & INSPECTOR
Definition: base_struct.h:118
#define IS_DRAGGED
Item being dragged.
Definition: base_struct.h:129
PCB_LAYER_ID m_Layer
const wxString & GetShortNetname() const
Function GetShortNetname.
VIA * GetVia(const wxPoint &aPosition, PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
Function GetVia finds the first VIA object at aPosition on aLayer starting at the trace...
bool m_DisplayPcbTrackFill
Definition: pcbstruct.h:71
PCB_LAYER_ID
A quick note on layer IDs:
virtual bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if aPosition is contained within or on the bounding area of an item...
double a
Alpha component.
Definition: color4d.h:289
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.
Classes used in Pcbnew, CvPcb and GerbView.
VIATYPE_T GetViaType() const
Definition: class_track.h:439
#define MIN_TEXT_SIZE
Definition: drawtxt.h:43
std::shared_ptr< NETCLASS > GetNetClass() const
Function GetNetClass returns the NETCLASS for this item.
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
void GRForceBlackPen(bool flagforce)
Function GRForceBlackPen.
Definition: gr_basic.cpp:271
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
Base window classes and related definitions.
void GRFillCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:584
#define IS_DELETED
Definition: base_struct.h:130
PCB_GENERAL_SETTINGS & Settings()
virtual bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if aPosition is contained within or on the bounding area of an item...
const wxPoint & GetStart() const
Definition: class_track.h:121
virtual void Flip(const wxPoint &aCentre) override
Function Flip Flip this object, i.e.
wxPoint m_End
Line end point.
Definition: class_track.h:335
to draw usual through hole vias
int m_Drill
Definition: class_track.h:485
void DrawShortNetname(EDA_DRAW_PANEL *panel, wxDC *aDC, GR_DRAWMODE aDrawMode, COLOR4D aBgColor)
Helper for drawing the short netname in tracks.
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Function GetLayerName returns the name of a layer given by aLayer.
const wxPoint & GetEndPoint(ENDPOINT_T aEndPoint) const
Return the selected endpoint (start or end)
Definition: class_track.h:125
bool m_ContrastModeDisplay
Definition: pcbstruct.h:85
virtual LSET GetLayerSet() const
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
unsigned STATUS_FLAGS
Definition: base_struct.h:158
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:481
EDA_RECT * GetClipBox()
virtual unsigned int ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Function ViewGetLOD() Returns the level of detail of the item.
TRACK * GetEndNetCode(int NetCode)
wxString LengthDoubleToString(double aValue, bool aConvertToMils)
Function LengthDoubleToString is a helper to convert the double length aValue to a string in inches...
Definition: base_units.cpp:122
general purpose overlay
int m_DisplayZonesMode
Definition: pcbstruct.h:77
#define TRACK_LOCKED
Pcbnew: track locked: protected from global deletion.
Definition: base_struct.h:142
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...
class SEGZONE, a segment used to fill a zone area (segment on a copper layer)
Definition: typeinfo.h:109
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:174
TRACK * MarkTrace(TRACK *aTrace, int *aCount, double *aTraceLength, double *aInPackageLength, bool aReorder)
Function MarkTrace marks a chain of trace segments, connected to aTrace.
virtual int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const
Function GetClearance returns the clearance in internal units.
virtual int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const override
Function GetClearance returns the clearance in internal units.
virtual wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
#define FLAG0
Pcbnew: flag used in local computations.
Definition: base_struct.h:145
SEGZONE(BOARD_ITEM *aParent)
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, GR_DRAWMODE aDrawMode, const wxPoint &aOffset=ZeroOffset) override
Function Draw BOARD_ITEMs have their own color information.
void SetDrillDefault()
Function SetDrillDefault sets the drill value for vias to the default value UNDEFINED_DRILL_DIAMETER...
Definition: class_track.h:468
COLORS_DESIGN_SETTINGS & Colors()
#define TRACK_AR
Pcbnew: autorouted track.
Definition: base_struct.h:143
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...
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
Class DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
Definition: pcbstruct.h:62
int GetNetCode() const
Function GetNetCode.
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, GR_DRAWMODE aDrawMode, const wxPoint &aOffset=ZeroOffset) override
Function Draw BOARD_ITEMs have their own color information.
TRACE_CLEARANCE_DISPLAY_MODE_T m_ShowTrackClearanceMode
How trace clearances are displayed.
Definition: pcbstruct.h:74
void Draw(EDA_DRAW_PANEL *panel, wxDC *DC, GR_DRAWMODE aDrawMode, const wxPoint &aOffset=ZeroOffset) override
Function Draw BOARD_ITEMs have their own color information.
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on...
bool Intersects(const EDA_RECT &aRect) const
Function Intersects tests for a common area between rectangles.
Class NETINFO_ITEM handles the data for a net.
Definition: class_netinfo.h:69
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Function IsElementVisible tests whether a given element category is visible.
wxString ShowWidth() const
Function ShowWidth returns the width of the track in displayable user units.
TRACK * GetBestInsertPoint(BOARD *aPcb)
Function GetBestInsertPoint searches the "best" insertion point within the track linked list...
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
TRACK * Next() const
Definition: class_track.h:98
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
const wxString & GetNetname() const
Function GetNetname.
void SetState(int type, int state)
Definition: base_struct.h:256
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
TRACK * GetStartNetCode(int NetCode)
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
#define max(a, b)
Definition: auxiliary.h:86
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
void GetMsgPanelInfoBase_Common(std::vector< MSG_PANEL_ITEM > &aList)
Helper function for the common panel info.
int GetWidth() const
Definition: class_track.h:115
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
LSET GetVisibleLayers() const
Function GetVisibleLayers is a proxy function that calls the correspondent function in m_BoardSetting...
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
Definition: gr_basic.cpp:791
STATUS_FLAGS m_Flags
Flag bits for editing and other uses.
Definition: base_struct.h:189
#define ENDPOINT
Definition: base_struct.h:133
Class EDA_RECT handles the component boundary box.
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:187
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:165
The common library.
int m_DisplayNetNamesMode
Definition: pcbstruct.h:78
PCB_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
virtual void GetMsgPanelInfoBase(std::vector< MSG_PANEL_ITEM > &aList)
Function GetMsgPanelInfoBase Display info about the track segment only, and does not calculate the fu...
Definition: colors.h:49
int GetMicroViaDrillSize()
Function GetViaDrillSize returns the size of via drills used to route this net.
double GetLength() const
Function GetLength returns the length of the track using the hypotenuse calculation.
Definition: class_track.h:171
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
This file is part of the common libary.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:108
TRACK(BOARD_ITEM *aParent, KICAD_T idtype=PCB_TRACE_T)
Definition: class_track.cpp:95
DLIST< TRACK > m_Track
Definition: class_board.h:246
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
const wxString & GetNetname() const
Function GetNetname.
void * GetDisplayOptions()
Function GetDisplayOptions A way to pass info to draw functions.
Definition: draw_panel.cpp:181
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:58
bool TestSegmentHit(const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist)
Function TestSegmentHit test for hit on line segment i.e.
Definition: trigo.cpp:142
SEARCH_RESULT
Definition: base_struct.h:82
bool GetGRForceBlackPenState(void)
Function GetGRForceBlackPenState.
Definition: gr_basic.cpp:281
int GetViaDrillSize()
Function GetViaDrillSize returns the size of via drills used to route this net.
Message panel definition file.
bool m_DisplayViaFill
Definition: pcbstruct.h:66
#define FORCE_SKETCH
Definition: pcbnew.h:68
BOARD_CONNECTED_ITEM * end
Definition: class_track.h:90
virtual void GetMsgPanelInfoBase(std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfoBase Display info about the track segment only, and does not calculate the fu...
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
BOARD_CONNECTED_ITEM * start
Definition: class_track.h:89
EDA_ITEM * Pnext
next in linked list
Definition: base_struct.h:178
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
NETINFO_ITEM * GetNet() const
Function GetNet Returns NET_INFO object for a given item.
#define DO_NOT_DRAW
Used to disable draw function.
Definition: base_struct.h:139
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.
bool IsNetnameLayer(LAYER_NUM aLayer)
Function IsNetnameLayer tests whether a layer is a netname layer.
#define min(a, b)
Definition: auxiliary.h:85
#define STARTPOINT
Definition: base_struct.h:132
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:451
bool IsDragging() const
Definition: base_struct.h:233
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39
Definition: colors.h:62
VIA * GetFirstVia(TRACK *aTrk, const TRACK *aStopPoint=NULL)
Scan a track list for the first VIA o NULL if not found (or NULL passed)
Definition: class_track.h:490