KiCad PCB EDA Suite
editrack.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-2012 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 
31 #include <fctsys.h>
32 #include <class_drawpanel.h>
33 #include <trigo.h>
34 #include <wxPcbStruct.h>
35 
36 #include <pcbnew.h>
37 #include <drc_stuff.h>
38 #include <protos.h>
39 
40 #include <class_board.h>
41 #include <class_track.h>
42 #include <class_zone.h>
43 #include <connectivity.h>
44 
45 
46 static void Abort_Create_Track( EDA_DRAW_PANEL* panel, wxDC* DC );
47 void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
48  const wxPoint& aPosition, bool aErase );
49 static void ComputeBreakPoint( TRACK* track, int n, wxPoint end );
50 static void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList );
51 static void EnsureEndTrackOnPad( D_PAD* Pad );
52 
53 // A PICKED_ITEMS_LIST to store tracks which are modified/added/deleted
54 // during a track edition:
56 
57 
58 /* Function called to abort a track creation
59  */
60 static void Abort_Create_Track( EDA_DRAW_PANEL* Panel, wxDC* DC )
61 {
62  PCB_EDIT_FRAME* frame = (PCB_EDIT_FRAME*) Panel->GetParent();
63  BOARD* pcb = frame->GetBoard();
64  TRACK* track = dyn_cast<TRACK*>( frame->GetCurItem() );
65 
66  if( track )
67  {
68  // Erase the current drawing
69  ShowNewTrackWhenMovingCursor( Panel, DC, wxDefaultPosition, false );
70 
71  if( pcb->IsHighLightNetON() )
72  frame->HighLight( DC );
73 
74  pcb->PopHighLight();
75 
76  if( pcb->IsHighLightNetON() )
77  pcb->DrawHighLight( Panel, DC, pcb->GetHighLightNetCode() );
78 
79  frame->ClearMsgPanel();
80 
81  // Undo pending changes (mainly a lock point creation) and clear the
82  // undo picker list:
83  frame->PutDataInPreviousState( &s_ItemsListPicker, false, false );
84  s_ItemsListPicker.ClearListAndDeleteItems();
85 
86  // Delete current (new) track
88  }
89 
90  frame->SetCurItem( NULL );
91 }
92 
93 /*
94  * This function starts a new track segment.
95  * If a new track segment is in progress, ends this current new segment,
96  * and created a new one.
97  */
98 TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC )
99 {
100  TRACK* trackOnStartPoint = NULL;
101  LSET layerMask( GetScreen()->m_Active_Layer );
103 
104  BOARD_CONNECTED_ITEM* lockPoint;
105 
106  if( aTrack == NULL ) // Starting a new track segment
107  {
109 
110  // Prepare the undo command info
111  s_ItemsListPicker.ClearListAndDeleteItems(); // Should not be necessary, but...
112 
113  GetBoard()->PushHighLight();
114 
115  // erase old highlight
116  if( GetBoard()->IsHighLightNetON() )
117  HighLight( aDC );
118 
120  g_CurrentTrackSegment->SetFlags( IS_NEW );
121 
122  GetBoard()->SetHighLightNet( 0 );
123 
124  // Search for a starting point of the new track, a track or pad
125  lockPoint = GetBoard()->GetLockPoint( pos, layerMask );
126 
127  D_PAD* pad = NULL;
128  if( lockPoint ) // An item (pad or track) is found
129  {
130  if( lockPoint->Type() == PCB_PAD_T )
131  {
132  pad = (D_PAD*) lockPoint;
133 
134  // A pad is found: put the starting point on pad center
135  pos = pad->GetPosition();
136  GetBoard()->SetHighLightNet( pad->GetNetCode() );
137  }
138  else // A track segment is found
139  {
140  trackOnStartPoint = (TRACK*) lockPoint;
141  GetBoard()->SetHighLightNet( trackOnStartPoint->GetNetCode() );
142  GetBoard()->CreateLockPoint( pos, trackOnStartPoint, &s_ItemsListPicker );
143  }
144  }
145  else
146  {
147  // Not a starting point, but a filled zone area can exist. This is also a
148  // good starting point.
149  ZONE_CONTAINER* zone;
150  zone = GetBoard()->HitTestForAnyFilledArea( pos,
151  GetScreen()-> m_Active_Layer,
152  GetScreen()-> m_Active_Layer,
153  -1 );
154 
155  if( zone )
156  GetBoard()->SetHighLightNet( zone->GetNetCode() );
157  }
158 
159  DBG( g_CurrentTrackList.VerifyListIntegrity() );
160 
161  int net = -1;
162 
163  if( lockPoint )
164  net = lockPoint->GetNetCode();
165 
166  BuildAirWiresTargetsList( lockPoint, wxPoint( 0, 0 ), net );
167 
168  DBG( g_CurrentTrackList.VerifyListIntegrity() );
169 
170  GetBoard()->HighLightON();
171  GetBoard()->DrawHighLight( m_canvas, aDC, GetBoard()->GetHighLightNetCode() );
172 
173  // Display info about track Net class, and init track and vias sizes:
174  g_CurrentTrackSegment->SetNetCode( GetBoard()->GetHighLightNetCode() );
175  SetCurrentNetClass( g_CurrentTrackSegment->GetNetClassName() );
176 
177  g_CurrentTrackSegment->SetLayer( GetScreen()->m_Active_Layer );
178  g_CurrentTrackSegment->SetWidth( GetDesignSettings().GetCurrentTrackWidth() );
179 
180  if( GetDesignSettings().m_UseConnectedTrackWidth )
181  {
182  if( trackOnStartPoint && trackOnStartPoint->Type() == PCB_TRACE_T )
183  g_CurrentTrackSegment->SetWidth( trackOnStartPoint->GetWidth());
184  }
185 
186  g_CurrentTrackSegment->SetStart( pos );
187  g_CurrentTrackSegment->SetEnd( pos );
188 
189  if( pad )
190  {
191  // Useful to display track length, if the pad has a die length:
192  g_CurrentTrackSegment->SetState( BEGIN_ONPAD, true );
193  g_CurrentTrackSegment->start = pad;
194  }
195 
196  if( Settings().m_legacyUseTwoSegmentTracks )
197  {
198  // Create 2nd segment
200 
201  DBG( g_CurrentTrackList.VerifyListIntegrity(); );
202 
205 
206  g_FirstTrackSegment->SetState( BEGIN_ONPAD | END_ONPAD, false );
207  }
208 
209  DBG( g_CurrentTrackList.VerifyListIntegrity(); );
210 
213  m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
214 
215  if( Settings().m_legacyDrcOn )
216  {
217  if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) )
218  {
219  return g_CurrentTrackSegment;
220  }
221  }
222  }
223  else // Track in progress : segment coordinates are updated by ShowNewTrackWhenMovingCursor.
224  {
225  // Test for a D.R.C. error:
226  if( Settings().m_legacyDrcOn )
227  {
228  if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) )
229  return NULL;
230 
231  // We must handle 2 segments
233  {
234  if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment->Back(), GetBoard()->m_Track ) )
235  return NULL;
236  }
237  }
238 
239  /* Current track is Ok: current segment is kept, and a new one is
240  * created unless the current segment is null, or 2 last are null
241  * if this is a 2 segments track build.
242  */
243  bool CanCreateNewSegment = true;
244 
246  CanCreateNewSegment = false;
247 
249  && g_CurrentTrackSegment->Back()
250  && g_CurrentTrackSegment->Back()->IsNull() )
251  CanCreateNewSegment = false;
252 
253  if( CanCreateNewSegment )
254  {
255  // Erase old track on screen
256  DBG( g_CurrentTrackList.VerifyListIntegrity(); );
257 
258  ShowNewTrackWhenMovingCursor( m_canvas, aDC, wxDefaultPosition, false );
259 
260  DBG( g_CurrentTrackList.VerifyListIntegrity(); );
261 
262  if( g_Raccord_45_Auto )
263  Add45DegreeSegment( aDC );
264 
265  TRACK* previousTrack = g_CurrentTrackSegment;
266 
267  TRACK* newTrack = (TRACK*)g_CurrentTrackSegment->Clone();
268  g_CurrentTrackList.PushBack( newTrack );
269  newTrack->SetFlags( IS_NEW );
270 
271  newTrack->SetState( BEGIN_ONPAD | END_ONPAD, false );
272  newTrack->start = previousTrack->end;
273 
274  DBG( g_CurrentTrackList.VerifyListIntegrity(); );
275 
276  newTrack->SetStart( newTrack->GetEnd() );
277 
278  newTrack->SetLayer( GetScreen()->m_Active_Layer );
279 
280  if( !GetDesignSettings().m_UseConnectedTrackWidth )
281  newTrack->SetWidth( GetDesignSettings().GetCurrentTrackWidth() );
282 
283  DBG( g_CurrentTrackList.VerifyListIntegrity(); );
284 
285  // Show the new position
286  ShowNewTrackWhenMovingCursor( m_canvas, aDC, wxDefaultPosition, false );
287  }
288  }
289 
291  return g_CurrentTrackSegment;
292 }
293 
294 
296 {
297  int dx0, dy0, dx1, dy1;
298 
299  if( g_CurrentTrackList.GetCount() < 2 )
300  return false; // There must be 2 segments.
301 
302  TRACK* curTrack = g_CurrentTrackSegment;
303  TRACK* prevTrack = curTrack->Back();
304 
305  // Test if we have 2 consecutive track segments ( not via ) to connect.
306  if( curTrack->Type() != PCB_TRACE_T || prevTrack->Type() != PCB_TRACE_T )
307  {
308  return false;
309  }
310 
311  int segm_step_45 = KiROUND( GetScreen()->GetGridSize().x / 2 );
312 
313  if( segm_step_45 < ( curTrack->GetWidth() * 2 ) )
314  segm_step_45 = curTrack->GetWidth() * 2;
315 
316  // Test if the segments are horizontal or vertical.
317  dx0 = prevTrack->GetEnd().x - prevTrack->GetStart().x;
318  dy0 = prevTrack->GetEnd().y - prevTrack->GetStart().y;
319 
320  dx1 = curTrack->GetEnd().x - curTrack->GetStart().x;
321  dy1 = curTrack->GetEnd().y - curTrack->GetStart().y;
322 
323  // Segments should have a min length.
324  if( std::max( abs( dx0 ), abs( dy0 ) ) < ( segm_step_45 * 2 ) )
325  return false;
326 
327  if( std::max( abs( dx1 ), abs( dy1 ) ) < ( segm_step_45 * 2 ) )
328  return false;
329 
330  // Create a new segment and connect it with the previous 2 segments.
331  TRACK* newTrack = (TRACK*)curTrack->Clone();
332 
333  newTrack->SetStart( prevTrack->GetEnd() );
334  newTrack->SetEnd( curTrack->GetStart() );
335 
336  if( dx0 == 0 ) // Previous segment is Vertical
337  {
338  if( dy1 != 0 ) // 2 segments are not 90 degrees.
339  {
340  delete newTrack;
341  return false;
342  }
343 
344  /* Calculate coordinates the connection point.
345  * The new segment connects the 1st vertical segment and the 2nd
346  * horizontal segment.
347  */
348  if( dy0 > 0 )
349  newTrack->SetStart( wxPoint(newTrack->GetStart().x, newTrack->GetStart().y -segm_step_45) );
350  else
351  newTrack->SetStart( wxPoint(newTrack->GetStart().x, newTrack->GetStart().y + segm_step_45) );
352 
353  if( dx1 > 0 )
354  newTrack->SetEnd( wxPoint(newTrack->GetEnd().x + segm_step_45, newTrack->GetEnd().y) );
355  else
356  newTrack->SetEnd( wxPoint(newTrack->GetEnd().x - segm_step_45, newTrack->GetEnd().y) );
357 
358  if( Settings().m_legacyDrcOn && BAD_DRC == m_drc->Drc( curTrack, GetBoard()->m_Track ) )
359  {
360  delete newTrack;
361  return false;
362  }
363 
364  prevTrack->SetEnd( newTrack->GetStart());
365  curTrack->SetStart( newTrack->GetEnd());
366 
367  g_CurrentTrackList.Insert( newTrack, curTrack );
368  return true;
369  }
370 
371  if( dy0 == 0 ) // Previous segment is horizontal
372  {
373  if( dx1 != 0 ) // 2 segments are not 90 degrees
374  {
375  delete newTrack;
376  return false;
377  }
378 
379  /* Calculate the coordinates of the point of connection:
380  * A new segment has been created, connecting segment 1
381  * (horizontal) and segment 2 (vertical)
382  */
383  if( dx0 > 0 )
384  newTrack->SetStart( wxPoint(newTrack->GetStart().x - segm_step_45 , newTrack->GetStart().y));
385  else
386  newTrack->SetStart( wxPoint(newTrack->GetStart().x + segm_step_45, newTrack->GetStart().y) );
387 
388  if( dy1 > 0 )
389  newTrack->SetEnd( wxPoint(newTrack->GetEnd().x, newTrack->GetEnd().y + segm_step_45) );
390  else
391  newTrack->SetEnd( wxPoint(newTrack->GetEnd().x, newTrack->GetEnd().y - segm_step_45) );
392 
393  if( Settings().m_legacyDrcOn && BAD_DRC==m_drc->Drc( newTrack, GetBoard()->m_Track ) )
394  {
395  delete newTrack;
396  return false;
397  }
398 
399  prevTrack->SetEnd( newTrack->GetStart());
400  curTrack->SetStart( newTrack->GetEnd());
401 
402  g_CurrentTrackList.Insert( newTrack, curTrack );
403  return true;
404  }
405 
406  return false;
407 }
408 
409 
410 bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* aDC )
411 {
412  LSET layerMask( GetScreen()->m_Active_Layer );
413 
414  if( aTrack == NULL )
415  return false;
416 
417  if( Settings().m_legacyDrcOn && BAD_DRC == m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) )
418  return false;
419 
420  // Saving the coordinate of end point of the trace
421  wxPoint pos = g_CurrentTrackSegment->GetEnd();
422 
423  DBG( g_CurrentTrackList.VerifyListIntegrity(); );
424 
425  if( Begin_Route( aTrack, aDC ) == NULL )
426  return false;
427 
428  ShowNewTrackWhenMovingCursor( m_canvas, aDC, wxDefaultPosition, true );
429  ShowNewTrackWhenMovingCursor( m_canvas, aDC, wxDefaultPosition, false );
430  TraceAirWiresToTargets( aDC );
431 
432  /* cleanup
433  * if( g_CurrentTrackSegment->Next() != NULL )
434  * {
435  * delete g_CurrentTrackSegment->Next();
436  * g_CurrentTrackSegment->SetNext( NULL );
437  * }
438  */
439 
440  DBG( g_CurrentTrackList.VerifyListIntegrity(); );
441 
442 
443  /* The track here is now chained to the list of track segments.
444  * It must be seen in the area of net
445  * As close as possible to the segment base (or end), because
446  * This helps to reduce the computing time */
447 
448  // Attaching the end point of the new track to a pad or a track
449  BOARD_CONNECTED_ITEM* lockPoint = GetBoard()->GetLockPoint( pos, layerMask );
450 
451  if( lockPoint )
452  {
453  if( lockPoint->Type() == PCB_PAD_T ) // End of track is on a pad.
454  {
455  EnsureEndTrackOnPad( (D_PAD*) lockPoint );
456  }
457  else // If end point of is on a different track,
458  // creates a lock point if not exists
459  {
460  // Creates a lock point, if not already exists:
461  wxPoint hp = g_CurrentTrackSegment->GetEnd();
462  lockPoint = GetBoard()->CreateLockPoint( hp, (TRACK*) lockPoint, &s_ItemsListPicker );
463  g_CurrentTrackSegment->SetEnd(hp);
464  }
465  }
466 
467  // Delete null length segments:
469 
470  // Insert new segments if they exist.
471  // g_FirstTrackSegment can be NULL on a double click on the starting point
472  if( g_FirstTrackSegment != NULL )
473  {
474  int netcode = g_FirstTrackSegment->GetNetCode();
475  TRACK* firstTrack = g_FirstTrackSegment;
476  int newCount = g_CurrentTrackList.GetCount();
477 
478  // Put entire new current segment list in BOARD, and prepare undo command
479  TRACK* track;
480  TRACK* insertBeforeMe = g_CurrentTrackSegment->GetBestInsertPoint( GetBoard() );
481 
482  while( ( track = g_CurrentTrackList.PopFront() ) != NULL )
483  {
484  ITEM_PICKER picker( track, UR_NEW );
485  s_ItemsListPicker.PushItem( picker );
486  GetBoard()->m_Track.Insert( track, insertBeforeMe );
487  GetBoard()->GetConnectivity()->Add( track );
488  }
489 
490  TraceAirWiresToTargets( aDC );
491 
492  int i = 0;
493 
494  for( track = firstTrack; track && i < newCount; ++i, track = track->Next() )
495  {
496  track->ClearFlags();
497  track->SetState( BUSY, false );
498  }
499 
500  // delete the old track, if it exists and is redundant
501  if( Settings().m_legacyAutoDeleteOldTrack )
502  {
503  EraseRedundantTrack( aDC, firstTrack, newCount, &s_ItemsListPicker );
504  }
505 
506  SaveCopyInUndoList( s_ItemsListPicker, UR_UNSPECIFIED );
507  s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
508 
509  // compute the new ratsnest
510  TestNetConnection( aDC, netcode );
511  OnModify();
512  SetMsgPanel( GetBoard() );
513 
514  // Redraw the entire new track.
515  DrawTraces( m_canvas, aDC, firstTrack, newCount, GR_OR );
516  }
517 
518  wxASSERT( g_FirstTrackSegment == NULL );
519  wxASSERT( g_CurrentTrackSegment == NULL );
520  wxASSERT( g_CurrentTrackList.GetCount() == 0 );
521 
522  if( GetBoard()->IsHighLightNetON() )
523  HighLight( aDC );
524 
525  GetBoard()->PopHighLight();
526 
527  if( GetBoard()->IsHighLightNetON() )
528  GetBoard()->DrawHighLight( m_canvas, aDC, GetBoard()->GetHighLightNetCode() );
529 
530  m_canvas->SetMouseCapture( NULL, NULL );
531  SetCurItem( NULL );
532 
533  GetBoard()->GetConnectivity()->RecalculateRatsnest();
534 
535  return true;
536 }
537 
538 
539 TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack, LAYER_NUM aLayer, const wxPoint& aRef )
540 {
541  int net = aTrack->GetNetCode();
542  int width = aTrack->GetWidth();
543 
544  TRACK* found = NULL;
545 
546  for( TRACK* track = listStart; track; track = track->Next() )
547  {
548  if( track->Type() == PCB_TRACE_T ) // skip vias
549  {
550  if( track->GetState( BUSY | IS_DELETED ) )
551  continue;
552 
553  if( aLayer != track->GetLayer() )
554  continue;
555 
556  if( track->GetNetCode() == net )
557  continue;
558 
559  // TRACK::HitTest
560  int dist = (width + track->GetWidth()) / 2 + aTrack->GetClearance( track );
561 
562  if( !TestSegmentHit( aRef, track->GetStart(), track->GetEnd(), dist ) )
563  continue;
564 
565  found = track;
566 
567  // prefer intrusions from the side, not the end
568  wxPoint pos = aRef - track->GetStart();
569  wxPoint vec = track->GetEnd() - track->GetStart();
570  double tmp = (double) pos.x * vec.x + (double) pos.y * vec.y;
571 
572  if( tmp >= 0 && tmp <= (double) vec.x * vec.x + (double) vec.y * vec.y )
573  break;
574  }
575  }
576 
577  return found;
578 }
579 
580 
597 static void PushTrack( EDA_DRAW_PANEL* panel )
598 {
599  PCB_SCREEN* screen = (PCB_SCREEN*) panel->GetParent()->GetScreen();
600  BOARD* pcb = ( (PCB_BASE_FRAME*) (panel->GetParent()) )->GetBoard();
601  wxPoint cursor = panel->GetParent()->GetCrossHairPosition();
602  wxPoint cv, vec, n;
603  TRACK* track = g_CurrentTrackSegment;
604  TRACK* other;
605  double det;
606  int dist;
607  double f;
608 
609  other = LocateIntrusion( pcb->m_Track, track, screen->m_Active_Layer, panel->GetParent()->RefPos( true ) );
610 
611  // are we currently pointing into a conflicting trace ?
612  if( !other )
613  return;
614 
615  if( other->GetNetCode() == track->GetNetCode() )
616  return;
617 
618  cv = cursor - other->GetStart();
619  vec = other->GetEnd() - other->GetStart();
620 
621  det = (double) cv.x * vec.y - (double) cv.y * vec.x;
622 
623  // cursor is right at the center of the old track
624  if( !det )
625  return;
626 
627  dist = (track->GetWidth() + 1) / 2 + (other->GetWidth() + 1) / 2 + track->GetClearance( other ) + 2;
628 
629  /*
630  * DRC wants >, so +1.
631  * We may have a quantization error of 1/sqrt(2), so +1 again.
632  */
633 
634  // Vector "n" is perpendicular to "other", pointing towards the cursor.
635  if( det > 0 )
636  {
637  n.x = vec.y;
638  n.y = -vec.x;
639  }
640  else
641  {
642  n.x = -vec.y;
643  n.y = vec.x;
644  }
645 
646  f = dist / hypot( double(n.x), double(n.y) );
647  n.x = KiROUND( f * n.x );
648  n.y = KiROUND( f * n.y );
649 
650  wxPoint hp = track->GetEnd();
651  FindBestGridPointOnTrack( &hp, cursor, other );
652  track->SetEnd( hp + n );
653 }
654 
655 
656 //Helper function: Draws Via circle and Via Clearance circle.
657 inline void DrawViaCirclesWhenEditingNewTrack( EDA_RECT* aPanelClipBox,
658  wxDC* aDC, const wxPoint& aPos,
659  int aViaRadius,
660  int aViaRadiusWithClearence,
661  COLOR4D aColor)
662 {
663  //Current viasize clearance circle
664  GRCircle( aPanelClipBox, aDC, aPos.x, aPos.y, aViaRadiusWithClearence, aColor );
665  //Current viasize circle
666  GRCircle( aPanelClipBox, aDC, aPos.x, aPos.y, aViaRadius, aColor );
667 }
668 
669 /* Redraw the current track being created when the mouse cursor is moved
670  */
671 void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
672  bool aErase )
673 {
674 // DBG( g_CurrentTrackList.VerifyListIntegrity(); );
675 
676  PCB_SCREEN* screen = (PCB_SCREEN*) aPanel->GetScreen();
677  PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) aPanel->GetParent();
678  DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*) aPanel->GetDisplayOptions();
679 
680  bool tmp = displ_opts->m_DisplayPcbTrackFill;
681  displ_opts->m_DisplayPcbTrackFill = true;
682  TRACE_CLEARANCE_DISPLAY_MODE_T showTrackClearanceMode = displ_opts->m_ShowTrackClearanceMode;
683 
684  if ( g_FirstTrackSegment == NULL )
685  return;
686 
687  NETCLASSPTR netclass = g_FirstTrackSegment->GetNetClass();
688 
689  if( showTrackClearanceMode != DO_NOT_SHOW_CLEARANCE )
691 
692  // Values to Via circle
693  int boardViaRadius = frame->GetDesignSettings().GetCurrentViaSize()/2;
694  int viaRadiusWithClearence = boardViaRadius+netclass->GetClearance();
695  EDA_RECT* panelClipBox=aPanel->GetClipBox();
696 
697 #ifndef USE_WX_OVERLAY
698  // Erase old track
699  if( aErase )
700  {
702 
703  frame->TraceAirWiresToTargets( aDC );
704 
705  if( showTrackClearanceMode >= SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS )
706  {
707  COLOR4D color = frame->Settings().Colors().GetLayerColor( g_CurrentTrackSegment->GetLayer() );
708  DrawViaCirclesWhenEditingNewTrack( panelClipBox, aDC, g_CurrentTrackSegment->GetEnd(),
709  boardViaRadius, viaRadiusWithClearence, color);
710  }
711  }
712 #endif
713  // MacOSX seems to need this.
714  if( g_CurrentTrackList.GetCount() == 0 )
715  return;
716 
717  // Set track parameters, that can be modified while creating the track
718  g_CurrentTrackSegment->SetLayer( screen->m_Active_Layer );
719 
722 
724  {
725  TRACK* previous_track = g_CurrentTrackSegment->Back();
726 
727  if( previous_track && previous_track->Type()==PCB_TRACE_T )
728  {
729  previous_track->SetLayer( screen->m_Active_Layer );
730 
732  previous_track->SetWidth( frame->GetDesignSettings().GetCurrentTrackWidth() );
733  }
734  }
735 
736  if( frame->Settings().m_legacyUse45DegreeTracks )
737  {
739  {
740  g_CurrentTrackSegment->SetEnd( frame->GetCrossHairPosition() );
741 
742  if( frame->Settings().m_legacyDrcOn )
743  PushTrack( aPanel );
744 
747  g_CurrentTrackSegment->GetEnd() );
748  }
749  else
750  {
751  /* Calculate of the end of the path for the permitted directions:
752  * horizontal, vertical or 45 degrees.
753  */
754  wxPoint hp = g_CurrentTrackSegment->GetEnd();
756  g_CurrentTrackSegment->GetStart() );
757  g_CurrentTrackSegment->SetEnd(hp);
758  }
759  }
760  else // Here the angle is arbitrary
761  {
762  g_CurrentTrackSegment->SetEnd( frame->GetCrossHairPosition() );
763  }
764 
765  // Redraw the new track
766  DBG( g_CurrentTrackList.VerifyListIntegrity(); );
768 
769  if( showTrackClearanceMode >= SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS )
770  {
772 
773  //Via diameter must have taken what we are using, rather than netclass value.
774  DrawViaCirclesWhenEditingNewTrack( panelClipBox, aDC, g_CurrentTrackSegment->GetEnd(),
775  boardViaRadius, viaRadiusWithClearence, color);
776 
777  }
778 
779  /* Display info about current segment and the full new track:
780  * Choose the interesting segment: because we are using a 2 segments step,
781  * the last segment can be null, and the previous segment can be the
782  * interesting segment.
783  */
784  TRACK* isegm = g_CurrentTrackSegment;
785 
786  if( isegm->GetLength() == 0 && g_CurrentTrackSegment->Back() )
787  isegm = g_CurrentTrackSegment->Back();
788 
789  // display interesting segment info only:
790  frame->SetMsgPanel( isegm );
791 
792  // Display current track length (on board) and the the actual track len
793  // if there is an extra len due to the len die on the starting pad (if any)
794  double trackLen = 0.0;
795  double lenPadToDie = 0.0;
796  wxString msg;
797 
798  // If the starting point is on a pad, add current track length+ length die
799  if( g_FirstTrackSegment->GetState( BEGIN_ONPAD ) )
800  {
801  D_PAD* pad = (D_PAD*) g_FirstTrackSegment->start;
802  lenPadToDie = (double) pad->GetPadToDieLength();
803  }
804 
805  // calculate track len on board:
806  for( TRACK* track = g_FirstTrackSegment; track; track = track->Next() )
807  trackLen += track->GetLength();
808 
809  msg = frame->LengthDoubleToString( trackLen );
810  frame->AppendMsgPanel( _( "Track Len" ), msg, DARKCYAN );
811 
812  if( lenPadToDie != 0 ) // display the track len on board and the actual track len
813  {
814  frame->AppendMsgPanel( _( "Full Len" ), msg, DARKCYAN );
815  msg = frame->LengthDoubleToString( trackLen+lenPadToDie );
816  frame->AppendMsgPanel( _( "Pad to die" ), msg, DARKCYAN );
817  }
818 
819  // Add current segments count (number of segments in this new track):
820  msg.Printf( wxT( "%d" ), g_CurrentTrackList.GetCount() );
821  frame->AppendMsgPanel( _( "Segs Count" ), msg, DARKCYAN );
822 
823  displ_opts->m_ShowTrackClearanceMode = showTrackClearanceMode;
824  displ_opts->m_DisplayPcbTrackFill = tmp;
825 
826  frame->BuildAirWiresTargetsList( NULL, g_CurrentTrackSegment->GetEnd(), g_CurrentTrackSegment->GetNetCode() );
827  frame->TraceAirWiresToTargets( aDC );
828 }
829 
830 
831 wxPoint CalculateSegmentEndPoint( const wxPoint& aPosition, const wxPoint& aOrigin )
832 {
833  // Determine end point for a segment direction 0, 90, or 45 degrees
834  // depending on it's position from the origin \a aOrigin and \a aPosition.
835  wxPoint endPoint;
836 
837  int deltax = aPosition.x - aOrigin.x;
838  int deltay = aPosition.y - aOrigin.y;
839 
840  deltax = abs( deltax );
841  deltay = abs( deltay );
842  int angle = 45;
843 
844  if( deltax >= deltay )
845  {
846  if( deltax == 0 )
847  angle = 0;
848  else if( ( (deltay << 6 ) / deltax ) < 26 )
849  angle = 0;
850  }
851  else
852  {
853  angle = 45;
854 
855  if( deltay == 0 )
856  angle = 90;
857  else if( ( (deltax << 6 ) / deltay ) < 26 )
858  angle = 90;
859  }
860 
861  switch( angle )
862  {
863  case 0:
864  endPoint.x = aPosition.x;
865  endPoint.y = aOrigin.y;
866  break;
867 
868  case 45:
869  deltax = std::min( deltax, deltay );
870  deltay = deltax;
871 
872  // Recalculate the signs for deltax and deltaY.
873  if( ( aPosition.x - aOrigin.x ) < 0 )
874  deltax = -deltax;
875 
876  if( ( aPosition.y - aOrigin.y ) < 0 )
877  deltay = -deltay;
878 
879  endPoint.x = aOrigin.x + deltax;
880  endPoint.y = aOrigin.y + deltay;
881  break;
882 
883  case 90:
884  endPoint.x = aOrigin.x;
885  endPoint.y = aPosition.y;
886  break;
887  }
888 
889  return endPoint;
890 }
891 
892 
896 void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end )
897 {
898  int iDx = 0;
899  int iDy = 0;
900  int iAngle = 0;
901 
902  if( SegmentCount <= 0 )
903  return;
904 
905  if( track == NULL )
906  return;
907 
908  TRACK* newTrack = track;
909  track = track->Back();
910  SegmentCount--;
911 
912  if( track )
913  {
914  iDx = end.x - track->GetStart().x;
915  iDy = end.y - track->GetStart().y;
916 
917  iDx = abs( iDx );
918  iDy = abs( iDy );
919  }
920 
921  TRACK* lastTrack = track ? track->Back() : NULL;
922 
923  if( lastTrack )
924  {
925  if(( (lastTrack->GetEnd().x == lastTrack->GetStart().x)
926  || (lastTrack->GetEnd().y == lastTrack->GetStart().y) )
928  {
929  iAngle = 45;
930  }
931  }
932  else
933  {
935  {
936  iAngle = 45;
937  }
938  }
939 
940  if( iAngle == 0 )
941  {
942  if( iDx >= iDy )
943  iAngle = 0;
944  else
945  iAngle = 90;
946  }
947 
948  if( track == NULL )
949  iAngle = -1;
950 
951  switch( iAngle )
952  {
953  case -1:
954  break;
955 
956  case 0:
957  if( ( end.x - track->GetStart().x ) < 0 )
958  track->SetEnd(wxPoint( end.x + iDy, track->GetStart().y));
959  else
960  track->SetEnd(wxPoint( end.x - iDy, track->GetStart().y));
961  break;
962 
963  case 45:
964  iDx = std::min( iDx, iDy );
965  iDy = iDx;
966 
967  // Recalculate the signs for deltax and deltaY.
968  if( ( end.x - track->GetStart().x ) < 0 )
969  iDx = -iDx;
970 
971  if( ( end.y - track->GetStart().y ) < 0 )
972  iDy = -iDy;
973 
974  track->SetEnd(wxPoint(track->GetStart().x + iDx, track->GetStart().y + iDy));
975  break;
976 
977  case 90:
978  if( ( end.y - track->GetStart().y ) < 0 )
979  track->SetEnd(wxPoint(track->GetStart().x , end.y + iDx));
980  else
981  track->SetEnd(wxPoint(track->GetStart().x , end.y - iDx));
982  break;
983  }
984 
985  if( track )
986  {
987  if( track->IsNull() )
988  track->SetEnd( end );
989 
990  newTrack->SetStart( track->GetEnd() );
991  }
992 
993  newTrack->SetEnd( end );
994 }
995 
996 
997 /* Delete track segments which have len = 0 after creating a new track
998  * return a pointer on the first segment (start of track list)
999  */
1000 void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList )
1001 {
1002  if( aTrackList.GetCount() == 0 )
1003  return;
1004 
1005  TRACK* track = aTrackList.GetFirst();
1006  TRACK* firsttrack = track;
1007  TRACK* oldtrack;
1008 
1009  BOARD_CONNECTED_ITEM* lockPoint = track->start;
1010 
1011  while( track != NULL )
1012  {
1013  oldtrack = track;
1014  track = track->Next();
1015 
1016  if( !oldtrack->IsNull() )
1017  {
1018  continue;
1019  }
1020 
1021  // NULL segment, delete it
1022  if( firsttrack == oldtrack )
1023  firsttrack = track;
1024 
1025  delete aTrackList.Remove( oldtrack );
1026  }
1027 
1028  if( aTrackList.GetCount() == 0 )
1029  return; // all the new track segments have been deleted
1030 
1031  // we must set the pointers on connected items and the connection status
1032  oldtrack = track = firsttrack;
1033  firsttrack->start = NULL;
1034 
1035  while( track != NULL )
1036  {
1037  oldtrack = track;
1038  track = track->Next();
1039  oldtrack->end = track;
1040 
1041  if( track )
1042  track->start = oldtrack;
1043 
1044  oldtrack->SetStatus( 0 );
1045  }
1046 
1047  firsttrack->start = lockPoint;
1048 
1049  if( lockPoint && lockPoint->Type()==PCB_PAD_T )
1050  firsttrack->SetState( BEGIN_ONPAD, true );
1051 
1052  track = firsttrack;
1053 
1054  while( track != NULL )
1055  {
1056  TRACK* next_track = track->Next();
1057  lockPoint = pcb->GetPad( track, ENDPOINT_END );
1058 
1059  if( lockPoint )
1060  {
1061  track->end = lockPoint;
1062  track->SetState( END_ONPAD, true );
1063 
1064  if( next_track )
1065  {
1066  next_track->start = lockPoint;
1067  next_track->SetState( BEGIN_ONPAD, true );
1068  }
1069  }
1070 
1071  track = next_track;
1072  }
1073 }
1074 
1075 
1076 /* Ensure the end point of g_CurrentTrackSegment is on the pad "Pad"
1077  * if no, create a new track segment if necessary
1078  * and move current (or new) end segment on pad
1079  */
1081 {
1082  if( g_CurrentTrackSegment->GetEnd() == aPad->GetPosition() ) // Ok !
1083  {
1084  g_CurrentTrackSegment->end = aPad;
1085  g_CurrentTrackSegment->SetState( END_ONPAD, true );
1086  return;
1087  }
1088 
1089  TRACK* lasttrack = g_CurrentTrackSegment;
1090 
1091  if( !g_CurrentTrackSegment->IsNull() )
1092  {
1093  // Must create a new segment, from track end to pad center
1094  g_CurrentTrackList.PushBack( (TRACK*)lasttrack->Clone() );
1095 
1096  lasttrack->end = g_CurrentTrackSegment;
1097  }
1098 
1099  g_CurrentTrackSegment->SetEnd( aPad->GetPosition() );
1100  g_CurrentTrackSegment->SetState( END_ONPAD, false );
1101 
1102  g_CurrentTrackSegment->end = aPad;
1103  g_CurrentTrackSegment->SetState( END_ONPAD, true );
1104 }
#define g_FirstTrackSegment
first segment created
Definition: pcbnew.h:96
#define g_CurrentTrackSegment
most recently created segment
Definition: pcbnew.h:95
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
void TraceAirWiresToTargets(wxDC *aDC)
Function TraceAirWiresToTargets This functions shows airwires to nearest connecting points (pads) fro...
Definition: ratsnest.cpp:196
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Definition: pcbframe.cpp:994
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
TRACK * CreateLockPoint(wxPoint &aPosition, TRACK *aSegment, PICKED_ITEMS_LIST *aList)
Function CreateLockPoint creates an intermediate point on aSegment and break it into two segments at ...
bool IsNull()
Function IsNull returns true if segment length is zero.
T * Remove(T *aElement)
Function Remove removes aElement from the list, but does not delete it.
Definition: dlist.h:211
static void DeleteNullTrackSegments(BOARD *pcb, DLIST< TRACK > &aTrackList)
Definition: editrack.cpp:1000
bool g_Alternate_Track_Posture
Definition: pcbnew.cpp:70
#define END_ONPAD
Pcbnew: flag set for track segment ending on a pad.
Definition: base_struct.h:133
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
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
void SetEnd(const wxPoint &aEnd)
Definition: class_track.h:117
static void EnsureEndTrackOnPad(D_PAD *Pad)
Definition: editrack.cpp:1080
DLIST< TRACK > g_CurrentTrackList
Definition: pcbnew.cpp:88
void TestNetConnection(wxDC *aDC, int aNetCode)
Function TestNetConnection tests the connections relative to aNetCode.
Definition: connect.cpp:40
int GetPadToDieLength() const
Definition: class_pad.h:241
Class BOARD to handle a board.
bool Add45DegreeSegment(wxDC *aDC)
Function Add45DegreeSegment adds a track segment between 2 tracks segments if these 2 segments make a...
Definition: editrack.cpp:295
static const int dist[10][10]
Definition: dist.cpp:57
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
virtual EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
BOARD * GetBoard() const
Classes to handle copper zones.
void PushItem(const ITEM_PICKER &aItem)
Function PushItem pushes aItem to the top of the list.
class D_PAD, a pad in a footprint
Definition: typeinfo.h:102
D_PAD * GetPad(unsigned aIndex) const
Function GetPad.
#define BUSY
Pcbnew: flag indicating that the structure has.
Definition: base_struct.h:134
DRC * m_drc
the DRC controller, see drc.cpp
Definition: wxPcbStruct.h:96
void BuildAirWiresTargetsList(BOARD_CONNECTED_ITEM *aItemRef, const wxPoint &aPosition, int aNet)
Function BuildAirWiresTargetsList Build a list of candidates that can be a coonection point when a tr...
Definition: ratsnest.cpp:173
void DeleteAll()
Function DeleteAll deletes all items on the list and leaves the list empty.
Definition: dlist.cpp:41
TRACK * Begin_Route(TRACK *aTrack, wxDC *aDC)
Function Begin_Route Starts a new track and/or establish of a new track point.
Definition: editrack.cpp:98
bool SetCurrentNetClass(const wxString &aNetClassName)
Function SetCurrentNetClass Must be called after a netclass selection (or after a netclass parameter ...
Definition: pcbframe.cpp:1130
#define BEGIN_ONPAD
Pcbnew: flag set for track segment starting on a pad.
Definition: base_struct.h:132
PCB_LAYER_ID m_Active_Layer
int GetCurrentViaSize() const
Function GetCurrentViaSize.
#define abs(a)
Definition: auxiliary.h:84
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
TRACK * Back() const
Definition: class_track.h:99
bool End_Route(TRACK *aTrack, wxDC *aDC)
Function End_Route Terminates a track currently being created.
Definition: editrack.cpp:410
bool m_UseConnectedTrackWidth
if true, when creating a new track starting on an existing track, use this track width ...
BOARD_CONNECTED_ITEM * GetLockPoint(const wxPoint &aPosition, LSET aLayerMask)
Function GetLockPoint returns the item at the "attachment" point at the end of a trace at aPosition o...
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:73
const wxPoint & GetEnd() const
Definition: class_track.h:118
Functions relatives to tracks, vias and segments used to fill zones.
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:107
bool g_Raccord_45_Auto
Definition: pcbnew.cpp:71
wxPoint CalculateSegmentEndPoint(const wxPoint &aPosition, const wxPoint &aOrigin)
Determine end point for a segment direction 0, 90, or 45 degrees depending on it's position from the ...
Definition: editrack.cpp:831
void SetWidth(int aWidth)
Definition: class_track.h:114
ZONE_CONTAINER * HitTestForAnyFilledArea(const wxPoint &aRefPos, PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer, int aNetCode)
Function HitTestForAnyFilledArea tests if the given wxPoint is within the bounds of a filled area of ...
#define BAD_DRC
Definition: drc_stuff.h:36
void PushBack(T *aNewElement)
Function PushBack puts aNewElement at the end of the list sequence.
Definition: dlist.h:250
#define IS_NEW
New item, just created.
Definition: base_struct.h:113
bool m_DisplayPcbTrackFill
Definition: pcbstruct.h:71
static void PushTrack(EDA_DRAW_PANEL *panel)
Function PushTrack detects if the mouse is pointing into a conflicting track.
Definition: editrack.cpp:597
virtual BASE_SCREEN * GetScreen() const
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
Definition: draw_frame.h:309
Class LSET is a set of PCB_LAYER_IDs.
void PopHighLight()
Function PopHighLight retrieve a previously saved high light info.
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:253
void PutDataInPreviousState(PICKED_ITEMS_LIST *aList, bool aRedoCommand, bool aRebuildRatsnet=true)
Function PutDataInPreviousState Used in undo or redo command.
Definition: undo_redo.cpp:377
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Function SetMsgPanel clears the message panel and populates it with the contents of aList...
Definition: draw_frame.cpp:773
wxString LengthDoubleToString(double aValue, bool aConvertToMils=false) const
Function LengthDoubleToString is a helper to convert the double value aValue to a string in inches or...
Definition: draw_frame.cpp:817
int EraseRedundantTrack(wxDC *aDC, TRACK *aNewTrack, int aNewTrackSegmentsCount, PICKED_ITEMS_LIST *aItemsListPicker)
Function EraseRedundantTrack Called after creating a track Remove (if exists) the old track that have...
Definition: tr_modif.cpp:63
#define IS_DELETED
Definition: base_struct.h:116
PCB_GENERAL_SETTINGS & Settings()
const wxPoint & GetStart() const
Definition: class_track.h:121
const wxPoint & GetPosition() const override
Definition: class_pad.h:170
void CallMouseCapture(wxDC *aDC, const wxPoint &aPosition, bool aErase)
Function CallMouseCapture calls the mouse capture callback.
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
void HighLight(wxDC *DC)
Function HighLight.
Definition: highlight.cpp:101
EDA_RECT * GetClipBox()
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame...
EDA_DRAW_FRAME * GetParent() const
Definition: draw_panel.cpp:175
TRACK * LocateIntrusion(TRACK *listStart, TRACK *aTrack, LAYER_NUM aLayer, const wxPoint &aRef)
Definition: editrack.cpp:539
Class PICKED_ITEMS_LIST is a holder to handle information on schematic or board items.
virtual int GetClearance(BOARD_CONNECTED_ITEM *aItem=NULL) const override
Function GetClearance returns the clearance in internal units.
void SaveCopyInUndoList(BOARD_ITEM *aItemToCopy, UNDO_REDO_T aTypeCommand, const wxPoint &aTransformPoint=wxPoint(0, 0)) override
Function SaveCopyInUndoList Creates a new entry in undo list of commands.
Definition: undo_redo.cpp:172
COLORS_DESIGN_SETTINGS & Colors()
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
void HighLightON()
Function HighLightON Enable highlight.
Definition: class_board.h:394
Class DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
Definition: pcbstruct.h:62
Definition: gr_basic.h:42
bool FindBestGridPointOnTrack(wxPoint *aNearPos, wxPoint on_grid, const TRACK *track)
Finds the projection of a grid point on a track.
int GetNetCode() const
Function GetNetCode.
void SetHighLightNet(int aNetCode)
Function SetHighLightNet.
Definition: class_board.h:372
TRACE_CLEARANCE_DISPLAY_MODE_T m_ShowTrackClearanceMode
How trace clearances are displayed.
Definition: pcbstruct.h:74
wxPoint RefPos(bool useMouse) const
Function RefPos Return the reference position, coming from either the mouse position or the cursor po...
EDA_DRAW_PANEL * m_canvas
The area to draw on.
Definition: draw_frame.h:92
void AppendMsgPanel(const wxString &textUpper, const wxString &textLower, COLOR4D color, int pad=6)
Append a message to the message panel.
Definition: draw_frame.cpp:753
static void Abort_Create_Track(EDA_DRAW_PANEL *panel, wxDC *DC)
Definition: editrack.cpp:60
void DrawViaCirclesWhenEditingNewTrack(EDA_RECT *aPanelClipBox, wxDC *aDC, const wxPoint &aPos, int aViaRadius, int aViaRadiusWithClearence, COLOR4D aColor)
Definition: editrack.cpp:657
TRACK * Next() const
Definition: class_track.h:98
void SetState(int type, int state)
Definition: base_struct.h:242
#define max(a, b)
Definition: auxiliary.h:86
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
int GetWidth() const
Definition: class_track.h:115
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int xc, int yc, int r, int width, COLOR4D Color)
Definition: gr_basic.cpp:791
Class EDA_RECT handles the component boundary box.
static void ComputeBreakPoint(TRACK *track, int n, wxPoint end)
Compute new track angle based on previous track.
Definition: editrack.cpp:896
void ShowNewTrackWhenMovingCursor(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
Definition: editrack.cpp:671
BASE_SCREEN * GetScreen()
Definition: draw_panel.cpp:188
void PushHighLight()
Function PushHighLight save current high light info for later use.
void ClearItemsList()
Function ClearItemsList deletes only the list of pickers, NOT the picked data itself.
PCB_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
COLOR4D GetLayerColor(LAYER_NUM aLayer) const
Function GetLayerColor.
void SetStatus(STATUS_FLAGS aStatus)
Definition: base_struct.h:251
static PICKED_ITEMS_LIST s_ItemsListPicker
Definition: editrack.cpp:55
double GetLength() const
Function GetLength returns the length of the track using the hypotenuse calculation.
Definition: class_track.h:171
virtual BOARD * GetBoard() const
Function GetBoard returns the BOARD in which this BOARD_ITEM resides, or NULL if none.
unsigned GetCount() const
Function GetCount returns the number of elements in the list.
Definition: dlist.h:126
bool IsHighLightNetON() const
Function IsHighLightNetON.
Definition: class_board.h:381
void SetStart(const wxPoint &aStart)
Definition: class_track.h:120
int Drc(TRACK *aRefSeg, TRACK *aList)
Function Drc tests the current segment and returns the result and displays the error in the status pa...
Definition: drc.cpp:155
#define DBG(x)
Definition: fctsys.h:33
int GetHighLightNetCode() const
Function GetHighLightNetCode.
Definition: class_board.h:366
DLIST< TRACK > m_Track
Definition: class_board.h:246
void * GetDisplayOptions()
Function GetDisplayOptions A way to pass info to draw functions.
Definition: draw_panel.cpp:182
void DrawTraces(EDA_DRAW_PANEL *panel, wxDC *DC, TRACK *aStartTrace, int nbsegment, GR_DRAWMODE mode_color)
Function DrawTraces Draws n consecutive track segments in list.
Definition: tr_modif.cpp:49
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
void SetMouseCapture(MOUSE_CAPTURE_CALLBACK aMouseCaptureCallback, END_MOUSE_CAPTURE_CALLBACK aEndMouseCaptureCallback)
Function SetMouseCapture sets the mouse capture and end mouse capture callbacks to aMouseCaptureCallb...
void DrawHighLight(EDA_DRAW_PANEL *aDrawPanel, wxDC *aDC, int aNetCode)
Function DrawHighLight redraws the objects in the board that are associated with the given aNetCode a...
Definition: tracepcb.cpp:247
int GetCurrentTrackWidth() const
Function GetCurrentTrackWidth.
BOARD_ITEM * GetCurItem()
BOARD_CONNECTED_ITEM * end
Definition: class_track.h:90
wxPoint GetCrossHairPosition(bool aInvertY=false) const
Function GetCrossHairPosition return the current cross hair position in logical (drawing) coordinates...
BOARD_CONNECTED_ITEM * start
Definition: class_track.h:89
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:290
void ClearMsgPanel(void)
Clear all messages from the message panel.
Definition: draw_frame.cpp:764
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
void ClearListAndDeleteItems()
Function ClearListAndDeleteItems deletes the list of pickers, AND the data pointed by m_PickedItem or...
void Insert(T *aNewElement, T *aElementAfterMe)
Function Insert puts aNewElement just in front of aElementAfterMe in the list sequence.
Definition: dlist.h:200
T * PopFront()
Definition: dlist.h:221
#define min(a, b)
Definition: auxiliary.h:85
TRACE_CLEARANCE_DISPLAY_MODE_T
Enum TRACE_CLEARANCE_DISPLAY_MODE_T is the set of values for DISPLAY_OPTIONS.ShowTrackClearanceMode p...
Definition: pcbstruct.h:39
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39