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