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