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 #include <colors_selection.h>
36 
37 #include <pcbnew.h>
38 #include <drc_stuff.h>
39 #include <protos.h>
40 
41 #include <class_board.h>
42 #include <class_track.h>
43 #include <class_zone.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  BuildAirWiresTargetsList( lockPoint, wxPoint( 0, 0 ), true );
162 
163  DBG( g_CurrentTrackList.VerifyListIntegrity() );
164 
165  GetBoard()->HighLightON();
166  GetBoard()->DrawHighLight( m_canvas, aDC, GetBoard()->GetHighLightNetCode() );
167 
168  // Display info about track Net class, and init track and vias sizes:
169  g_CurrentTrackSegment->SetNetCode( GetBoard()->GetHighLightNetCode() );
170  SetCurrentNetClass( g_CurrentTrackSegment->GetNetClassName() );
171 
172  g_CurrentTrackSegment->SetLayer( GetScreen()->m_Active_Layer );
173  g_CurrentTrackSegment->SetWidth( GetDesignSettings().GetCurrentTrackWidth() );
174 
175  if( GetDesignSettings().m_UseConnectedTrackWidth )
176  {
177  if( trackOnStartPoint && trackOnStartPoint->Type() == PCB_TRACE_T )
178  g_CurrentTrackSegment->SetWidth( trackOnStartPoint->GetWidth());
179  }
180 
181  g_CurrentTrackSegment->SetStart( pos );
182  g_CurrentTrackSegment->SetEnd( pos );
183 
184  if( pad )
185  {
186  g_CurrentTrackSegment->m_PadsConnected.push_back( pad );
187  // Useful to display track length, if the pad has a die length:
188  g_CurrentTrackSegment->SetState( BEGIN_ONPAD, true );
189  g_CurrentTrackSegment->start = pad;
190  }
191 
193  {
194  // Create 2nd segment
196 
197  DBG( g_CurrentTrackList.VerifyListIntegrity(); );
198 
201 
202  g_FirstTrackSegment->SetState( BEGIN_ONPAD | END_ONPAD, false );
203  }
204 
205  DBG( g_CurrentTrackList.VerifyListIntegrity(); );
206 
209  m_canvas->CallMouseCapture( aDC, wxDefaultPosition, false );
210 
211  if( g_Drc_On )
212  {
213  if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) )
214  {
215  return g_CurrentTrackSegment;
216  }
217  }
218  }
219  else // Track in progress : segment coordinates are updated by ShowNewTrackWhenMovingCursor.
220  {
221  // Test for a D.R.C. error:
222  if( g_Drc_On )
223  {
224  if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) )
225  return NULL;
226 
227  // We must handle 2 segments
229  {
230  if( BAD_DRC == m_drc->Drc( g_CurrentTrackSegment->Back(), GetBoard()->m_Track ) )
231  return NULL;
232  }
233  }
234 
235  /* Current track is Ok: current segment is kept, and a new one is
236  * created unless the current segment is null, or 2 last are null
237  * if this is a 2 segments track build.
238  */
239  bool CanCreateNewSegment = true;
240 
242  CanCreateNewSegment = false;
243 
245  && g_CurrentTrackSegment->Back()
246  && g_CurrentTrackSegment->Back()->IsNull() )
247  CanCreateNewSegment = false;
248 
249  if( CanCreateNewSegment )
250  {
251  // Erase old track on screen
252  DBG( g_CurrentTrackList.VerifyListIntegrity(); );
253 
254  ShowNewTrackWhenMovingCursor( m_canvas, aDC, wxDefaultPosition, false );
255 
256  DBG( g_CurrentTrackList.VerifyListIntegrity(); );
257 
258  if( g_Raccord_45_Auto )
259  Add45DegreeSegment( aDC );
260 
261  TRACK* previousTrack = g_CurrentTrackSegment;
262 
263  TRACK* newTrack = (TRACK*)g_CurrentTrackSegment->Clone();
264  g_CurrentTrackList.PushBack( newTrack );
265  newTrack->SetFlags( IS_NEW );
266 
267  newTrack->SetState( BEGIN_ONPAD | END_ONPAD, false );
268 
269  D_PAD* pad = GetBoard()->GetPad( previousTrack, ENDPOINT_END );
270 
271  if( pad )
272  {
273  newTrack->m_PadsConnected.push_back( pad );
274  previousTrack->m_PadsConnected.push_back( pad );
275  }
276 
277  newTrack->start = previousTrack->end;
278 
279  DBG( g_CurrentTrackList.VerifyListIntegrity(); );
280 
281  newTrack->SetStart( newTrack->GetEnd() );
282 
283  newTrack->SetLayer( GetScreen()->m_Active_Layer );
284 
285  if( !GetDesignSettings().m_UseConnectedTrackWidth )
286  newTrack->SetWidth( GetDesignSettings().GetCurrentTrackWidth() );
287 
288  DBG( g_CurrentTrackList.VerifyListIntegrity(); );
289 
290  // Show the new position
291  ShowNewTrackWhenMovingCursor( m_canvas, aDC, wxDefaultPosition, false );
292  }
293  }
294 
296  return g_CurrentTrackSegment;
297 }
298 
299 
301 {
302  int dx0, dy0, dx1, dy1;
303 
304  if( g_CurrentTrackList.GetCount() < 2 )
305  return false; // There must be 2 segments.
306 
307  TRACK* curTrack = g_CurrentTrackSegment;
308  TRACK* prevTrack = curTrack->Back();
309 
310  // Test if we have 2 consecutive track segments ( not via ) to connect.
311  if( curTrack->Type() != PCB_TRACE_T || prevTrack->Type() != PCB_TRACE_T )
312  {
313  return false;
314  }
315 
316  int segm_step_45 = KiROUND( GetScreen()->GetGridSize().x / 2 );
317 
318  if( segm_step_45 < ( curTrack->GetWidth() * 2 ) )
319  segm_step_45 = curTrack->GetWidth() * 2;
320 
321  // Test if the segments are horizontal or vertical.
322  dx0 = prevTrack->GetEnd().x - prevTrack->GetStart().x;
323  dy0 = prevTrack->GetEnd().y - prevTrack->GetStart().y;
324 
325  dx1 = curTrack->GetEnd().x - curTrack->GetStart().x;
326  dy1 = curTrack->GetEnd().y - curTrack->GetStart().y;
327 
328  // Segments should have a min length.
329  if( std::max( abs( dx0 ), abs( dy0 ) ) < ( segm_step_45 * 2 ) )
330  return false;
331 
332  if( std::max( abs( dx1 ), abs( dy1 ) ) < ( segm_step_45 * 2 ) )
333  return false;
334 
335  // Create a new segment and connect it with the previous 2 segments.
336  TRACK* newTrack = (TRACK*)curTrack->Clone();
337 
338  newTrack->SetStart( prevTrack->GetEnd() );
339  newTrack->SetEnd( curTrack->GetStart() );
340 
341  if( dx0 == 0 ) // Previous segment is Vertical
342  {
343  if( dy1 != 0 ) // 2 segments are not 90 degrees.
344  {
345  delete newTrack;
346  return false;
347  }
348 
349  /* Calculate coordinates the connection point.
350  * The new segment connects the 1st vertical segment and the 2nd
351  * horizontal segment.
352  */
353  if( dy0 > 0 )
354  newTrack->SetStart( wxPoint(newTrack->GetStart().x, newTrack->GetStart().y -segm_step_45) );
355  else
356  newTrack->SetStart( wxPoint(newTrack->GetStart().x, newTrack->GetStart().y + segm_step_45) );
357 
358  if( dx1 > 0 )
359  newTrack->SetEnd( wxPoint(newTrack->GetEnd().x + segm_step_45, newTrack->GetEnd().y) );
360  else
361  newTrack->SetEnd( wxPoint(newTrack->GetEnd().x - segm_step_45, newTrack->GetEnd().y) );
362 
363  if( g_Drc_On && BAD_DRC == m_drc->Drc( curTrack, GetBoard()->m_Track ) )
364  {
365  delete newTrack;
366  return false;
367  }
368 
369  prevTrack->SetEnd( newTrack->GetStart());
370  curTrack->SetStart( newTrack->GetEnd());
371 
372  g_CurrentTrackList.Insert( newTrack, curTrack );
373  return true;
374  }
375 
376  if( dy0 == 0 ) // Previous segment is horizontal
377  {
378  if( dx1 != 0 ) // 2 segments are not 90 degrees
379  {
380  delete newTrack;
381  return false;
382  }
383 
384  /* Calculate the coordinates of the point of connection:
385  * A new segment has been created, connecting segment 1
386  * (horizontal) and segment 2 (vertical)
387  */
388  if( dx0 > 0 )
389  newTrack->SetStart( wxPoint(newTrack->GetStart().x - segm_step_45 , newTrack->GetStart().y));
390  else
391  newTrack->SetStart( wxPoint(newTrack->GetStart().x + segm_step_45, newTrack->GetStart().y) );
392 
393  if( dy1 > 0 )
394  newTrack->SetEnd( wxPoint(newTrack->GetEnd().x, newTrack->GetEnd().y + segm_step_45) );
395  else
396  newTrack->SetEnd( wxPoint(newTrack->GetEnd().x, newTrack->GetEnd().y - segm_step_45) );
397 
398  if( g_Drc_On && BAD_DRC==m_drc->Drc( newTrack, GetBoard()->m_Track ) )
399  {
400  delete newTrack;
401  return false;
402  }
403 
404  prevTrack->SetEnd( newTrack->GetStart());
405  curTrack->SetStart( newTrack->GetEnd());
406 
407  g_CurrentTrackList.Insert( newTrack, curTrack );
408  return true;
409  }
410 
411  return false;
412 }
413 
414 
415 bool PCB_EDIT_FRAME::End_Route( TRACK* aTrack, wxDC* aDC )
416 {
417  LSET layerMask( GetScreen()->m_Active_Layer );
418 
419  if( aTrack == NULL )
420  return false;
421 
422  if( g_Drc_On && BAD_DRC == m_drc->Drc( g_CurrentTrackSegment, GetBoard()->m_Track ) )
423  return false;
424 
425  // Saving the coordinate of end point of the trace
426  wxPoint pos = g_CurrentTrackSegment->GetEnd();
427 
428  DBG( g_CurrentTrackList.VerifyListIntegrity(); );
429 
430  if( Begin_Route( aTrack, aDC ) == NULL )
431  return false;
432 
433  ShowNewTrackWhenMovingCursor( m_canvas, aDC, wxDefaultPosition, true );
434  ShowNewTrackWhenMovingCursor( m_canvas, aDC, wxDefaultPosition, false );
435  TraceAirWiresToTargets( aDC );
436 
437  /* cleanup
438  * if( g_CurrentTrackSegment->Next() != NULL )
439  * {
440  * delete g_CurrentTrackSegment->Next();
441  * g_CurrentTrackSegment->SetNext( NULL );
442  * }
443  */
444 
445  DBG( g_CurrentTrackList.VerifyListIntegrity(); );
446 
447 
448  /* The track here is now chained to the list of track segments.
449  * It must be seen in the area of net
450  * As close as possible to the segment base (or end), because
451  * This helps to reduce the computing time */
452 
453  // Attaching the end point of the new track to a pad or a track
454  BOARD_CONNECTED_ITEM* lockPoint = GetBoard()->GetLockPoint( pos, layerMask );
455 
456  if( lockPoint )
457  {
458  if( lockPoint->Type() == PCB_PAD_T ) // End of track is on a pad.
459  {
460  EnsureEndTrackOnPad( (D_PAD*) lockPoint );
461  }
462  else // If end point of is on a different track,
463  // creates a lock point if not exists
464  {
465  // Creates a lock point, if not already exists:
466  wxPoint hp = g_CurrentTrackSegment->GetEnd();
467  lockPoint = GetBoard()->CreateLockPoint( hp, (TRACK*) lockPoint, &s_ItemsListPicker );
468  g_CurrentTrackSegment->SetEnd(hp);
469  }
470  }
471 
472  // Delete null length segments:
474 
475  // Insert new segments if they exist.
476  // g_FirstTrackSegment can be NULL on a double click on the starting point
477  if( g_FirstTrackSegment != NULL )
478  {
479  int netcode = g_FirstTrackSegment->GetNetCode();
480  TRACK* firstTrack = g_FirstTrackSegment;
481  int newCount = g_CurrentTrackList.GetCount();
482 
483  // Put entire new current segment list in BOARD, and prepare undo command
484  TRACK* track;
485  TRACK* insertBeforeMe = g_CurrentTrackSegment->GetBestInsertPoint( GetBoard() );
486 
487  while( ( track = g_CurrentTrackList.PopFront() ) != NULL )
488  {
489  ITEM_PICKER picker( track, UR_NEW );
490  s_ItemsListPicker.PushItem( picker );
491  GetBoard()->m_Track.Insert( track, insertBeforeMe );
492  }
493 
494  TraceAirWiresToTargets( aDC );
495 
496  int i = 0;
497 
498  for( track = firstTrack; track && i < newCount; ++i, track = track->Next() )
499  {
500  track->ClearFlags();
501  track->SetState( BUSY, false );
502  }
503 
504  // delete the old track, if it exists and is redundant
506  {
507  EraseRedundantTrack( aDC, firstTrack, newCount, &s_ItemsListPicker );
508  }
509 
510  SaveCopyInUndoList( s_ItemsListPicker, UR_UNSPECIFIED );
511  s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items
512 
513  // compute the new ratsnest
514  TestNetConnection( aDC, netcode );
515  OnModify();
516  SetMsgPanel( GetBoard() );
517 
518  // Redraw the entire new track.
519  DrawTraces( m_canvas, aDC, firstTrack, newCount, GR_OR );
520  }
521 
522  wxASSERT( g_FirstTrackSegment == NULL );
523  wxASSERT( g_CurrentTrackSegment == NULL );
524  wxASSERT( g_CurrentTrackList.GetCount() == 0 );
525 
526  if( GetBoard()->IsHighLightNetON() )
527  HighLight( aDC );
528 
529  GetBoard()->PopHighLight();
530 
531  if( GetBoard()->IsHighLightNetON() )
532  GetBoard()->DrawHighLight( m_canvas, aDC, GetBoard()->GetHighLightNetCode() );
533 
534  m_canvas->SetMouseCapture( NULL, NULL );
535  SetCurItem( NULL );
536 
537  return true;
538 }
539 
540 
541 TRACK* LocateIntrusion( TRACK* listStart, TRACK* aTrack, LAYER_NUM aLayer, const wxPoint& aRef )
542 {
543  int net = aTrack->GetNetCode();
544  int width = aTrack->GetWidth();
545 
546  TRACK* found = NULL;
547 
548  for( TRACK* track = listStart; track; track = track->Next() )
549  {
550  if( track->Type() == PCB_TRACE_T ) // skip vias
551  {
552  if( track->GetState( BUSY | IS_DELETED ) )
553  continue;
554 
555  if( aLayer != track->GetLayer() )
556  continue;
557 
558  if( track->GetNetCode() == net )
559  continue;
560 
561  // TRACK::HitTest
562  int dist = (width + track->GetWidth()) / 2 + aTrack->GetClearance( track );
563 
564  if( !TestSegmentHit( aRef, track->GetStart(), track->GetEnd(), dist ) )
565  continue;
566 
567  found = track;
568 
569  // prefer intrusions from the side, not the end
570  wxPoint pos = aRef - track->GetStart();
571  wxPoint vec = track->GetEnd() - track->GetStart();
572  double tmp = (double) pos.x * vec.x + (double) pos.y * vec.y;
573 
574  if( tmp >= 0 && tmp <= (double) vec.x * vec.x + (double) vec.y * vec.y )
575  break;
576  }
577  }
578 
579  return found;
580 }
581 
582 
599 static void PushTrack( EDA_DRAW_PANEL* panel )
600 {
601  PCB_SCREEN* screen = (PCB_SCREEN*) panel->GetParent()->GetScreen();
602  BOARD* pcb = ( (PCB_BASE_FRAME*) (panel->GetParent()) )->GetBoard();
603  wxPoint cursor = panel->GetParent()->GetCrossHairPosition();
604  wxPoint cv, vec, n;
605  TRACK* track = g_CurrentTrackSegment;
606  TRACK* other;
607  double det;
608  int dist;
609  double f;
610 
611  other = LocateIntrusion( pcb->m_Track, track, screen->m_Active_Layer, panel->GetParent()->RefPos( true ) );
612 
613  // are we currently pointing into a conflicting trace ?
614  if( !other )
615  return;
616 
617  if( other->GetNetCode() == track->GetNetCode() )
618  return;
619 
620  cv = cursor - other->GetStart();
621  vec = other->GetEnd() - other->GetStart();
622 
623  det = (double) cv.x * vec.y - (double) cv.y * vec.x;
624 
625  // cursor is right at the center of the old track
626  if( !det )
627  return;
628 
629  dist = (track->GetWidth() + 1) / 2 + (other->GetWidth() + 1) / 2 + track->GetClearance( other ) + 2;
630 
631  /*
632  * DRC wants >, so +1.
633  * We may have a quantization error of 1/sqrt(2), so +1 again.
634  */
635 
636  // Vector "n" is perpendicular to "other", pointing towards the cursor.
637  if( det > 0 )
638  {
639  n.x = vec.y;
640  n.y = -vec.x;
641  }
642  else
643  {
644  n.x = -vec.y;
645  n.y = vec.x;
646  }
647 
648  f = dist / hypot( double(n.x), double(n.y) );
649  n.x = KiROUND( f * n.x );
650  n.y = KiROUND( f * n.y );
651 
652  wxPoint hp = track->GetEnd();
653  FindBestGridPointOnTrack( &hp, cursor, other );
654  track->SetEnd( hp + n );
655 }
656 
657 
658 //Helper function: Draws Via circle and Via Clearance circle.
659 inline void DrawViaCirclesWhenEditingNewTrack( EDA_RECT* aPanelClipBox,
660  wxDC* aDC, const wxPoint& aPos,
661  int aViaRadius,
662  int aViaRadiusWithClearence,
663  COLOR4D aColor)
664 {
665  //Current viasize clearance circle
666  GRCircle( aPanelClipBox, aDC, aPos.x, aPos.y, aViaRadiusWithClearence, aColor );
667  //Current viasize circle
668  GRCircle( aPanelClipBox, aDC, aPos.x, aPos.y, aViaRadius, aColor );
669 }
670 
671 /* Redraw the current track being created when the mouse cursor is moved
672  */
673 void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aPosition,
674  bool aErase )
675 {
676 // DBG( g_CurrentTrackList.VerifyListIntegrity(); );
677 
678  PCB_SCREEN* screen = (PCB_SCREEN*) aPanel->GetScreen();
679  PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) aPanel->GetParent();
680  DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*) aPanel->GetDisplayOptions();
681 
682  bool tmp = displ_opts->m_DisplayPcbTrackFill;
683  displ_opts->m_DisplayPcbTrackFill = true;
684  TRACE_CLEARANCE_DISPLAY_MODE_T showTrackClearanceMode = displ_opts->m_ShowTrackClearanceMode;
685 
686  if ( g_FirstTrackSegment == NULL )
687  return;
688 
689  NETCLASSPTR netclass = g_FirstTrackSegment->GetNetClass();
690 
691  if( showTrackClearanceMode != DO_NOT_SHOW_CLEARANCE )
693 
694  // Values to Via circle
695  int boardViaRadius = frame->GetDesignSettings().GetCurrentViaSize()/2;
696  int viaRadiusWithClearence = boardViaRadius+netclass->GetClearance();
697  EDA_RECT* panelClipBox=aPanel->GetClipBox();
698 
699 #ifndef USE_WX_OVERLAY
700  // Erase old track
701  if( aErase )
702  {
704 
705  frame->TraceAirWiresToTargets( aDC );
706 
707  if( showTrackClearanceMode >= SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS )
708  {
710  DrawViaCirclesWhenEditingNewTrack( panelClipBox, aDC, g_CurrentTrackSegment->GetEnd(),
711  boardViaRadius, viaRadiusWithClearence, color);
712  }
713  }
714 #endif
715  // MacOSX seems to need this.
716  if( g_CurrentTrackList.GetCount() == 0 )
717  return;
718 
719  // Set track parameters, that can be modified while creating the track
720  g_CurrentTrackSegment->SetLayer( screen->m_Active_Layer );
721 
724 
726  {
727  TRACK* previous_track = g_CurrentTrackSegment->Back();
728 
729  if( previous_track && previous_track->Type()==PCB_TRACE_T )
730  {
731  previous_track->SetLayer( screen->m_Active_Layer );
732 
734  previous_track->SetWidth( frame->GetDesignSettings().GetCurrentTrackWidth() );
735  }
736  }
737 
739  {
741  {
742  g_CurrentTrackSegment->SetEnd( frame->GetCrossHairPosition() );
743 
744  if( g_Drc_On )
745  PushTrack( aPanel );
746 
749  g_CurrentTrackSegment->GetEnd() );
750  }
751  else
752  {
753  /* Calculate of the end of the path for the permitted directions:
754  * horizontal, vertical or 45 degrees.
755  */
756  wxPoint hp = g_CurrentTrackSegment->GetEnd();
758  g_CurrentTrackSegment->GetStart() );
759  g_CurrentTrackSegment->SetEnd(hp);
760  }
761  }
762  else // Here the angle is arbitrary
763  {
764  g_CurrentTrackSegment->SetEnd( frame->GetCrossHairPosition() );
765  }
766 
767  // Redraw the new track
768  DBG( g_CurrentTrackList.VerifyListIntegrity(); );
770 
771  if( showTrackClearanceMode >= SHOW_CLEARANCE_NEW_TRACKS_AND_VIA_AREAS )
772  {
774 
775  //Via diameter must have taken what we are using, rather than netclass value.
776  DrawViaCirclesWhenEditingNewTrack( panelClipBox, aDC, g_CurrentTrackSegment->GetEnd(),
777  boardViaRadius, viaRadiusWithClearence, color);
778 
779  }
780 
781  /* Display info about current segment and the full new track:
782  * Choose the interesting segment: because we are using a 2 segments step,
783  * the last segment can be null, and the previous segment can be the
784  * interesting segment.
785  */
786  TRACK* isegm = g_CurrentTrackSegment;
787 
788  if( isegm->GetLength() == 0 && g_CurrentTrackSegment->Back() )
789  isegm = g_CurrentTrackSegment->Back();
790 
791  // display interesting segment info only:
792  frame->SetMsgPanel( isegm );
793 
794  // Display current track length (on board) and the the actual track len
795  // if there is an extra len due to the len die on the starting pad (if any)
796  double trackLen = 0.0;
797  double lenPadToDie = 0.0;
798  wxString msg;
799 
800  // If the starting point is on a pad, add current track length+ length die
801  if( g_FirstTrackSegment->GetState( BEGIN_ONPAD ) )
802  {
803  D_PAD * pad = (D_PAD *) g_FirstTrackSegment->start;
804  lenPadToDie = (double) pad->GetPadToDieLength();
805  }
806 
807  // calculate track len on board:
808  for( TRACK* track = g_FirstTrackSegment; track; track = track->Next() )
809  trackLen += track->GetLength();
810 
811  msg = frame->LengthDoubleToString( trackLen );
812  frame->AppendMsgPanel( _( "Track Len" ), msg, DARKCYAN );
813 
814  if( lenPadToDie != 0 ) // display the track len on board and the actual track len
815  {
816  frame->AppendMsgPanel( _( "Full Len" ), msg, DARKCYAN );
817  msg = frame->LengthDoubleToString( trackLen+lenPadToDie );
818  frame->AppendMsgPanel( _( "Pad to die" ), msg, DARKCYAN );
819  }
820 
821  // Add current segments count (number of segments in this new track):
822  msg.Printf( wxT( "%d" ), g_CurrentTrackList.GetCount() );
823  frame->AppendMsgPanel( _( "Segs Count" ), msg, DARKCYAN );
824 
825  displ_opts->m_ShowTrackClearanceMode = showTrackClearanceMode;
826  displ_opts->m_DisplayPcbTrackFill = tmp;
827 
828  frame->BuildAirWiresTargetsList( NULL, g_CurrentTrackSegment->GetEnd(), false );
829  frame->TraceAirWiresToTargets( aDC );
830 }
831 
832 
833 wxPoint CalculateSegmentEndPoint( const wxPoint& aPosition, const wxPoint& aOrigin )
834 {
835  // Determine end point for a segment direction 0, 90, or 45 degrees
836  // depending on it's position from the origin \a aOrigin and \a aPosition.
837  wxPoint endPoint;
838 
839  int deltax = aPosition.x - aOrigin.x;
840  int deltay = aPosition.y - aOrigin.y;
841 
842  deltax = abs( deltax );
843  deltay = abs( deltay );
844  int angle = 45;
845 
846  if( deltax >= deltay )
847  {
848  if( deltax == 0 )
849  angle = 0;
850  else if( ( (deltay << 6 ) / deltax ) < 26 )
851  angle = 0;
852  }
853  else
854  {
855  angle = 45;
856 
857  if( deltay == 0 )
858  angle = 90;
859  else if( ( (deltax << 6 ) / deltay ) < 26 )
860  angle = 90;
861  }
862 
863  switch( angle )
864  {
865  case 0:
866  endPoint.x = aPosition.x;
867  endPoint.y = aOrigin.y;
868  break;
869 
870  case 45:
871  deltax = std::min( deltax, deltay );
872  deltay = deltax;
873 
874  // Recalculate the signs for deltax and deltaY.
875  if( ( aPosition.x - aOrigin.x ) < 0 )
876  deltax = -deltax;
877 
878  if( ( aPosition.y - aOrigin.y ) < 0 )
879  deltay = -deltay;
880 
881  endPoint.x = aOrigin.x + deltax;
882  endPoint.y = aOrigin.y + deltay;
883  break;
884 
885  case 90:
886  endPoint.x = aOrigin.x;
887  endPoint.y = aPosition.y;
888  break;
889  }
890 
891  return endPoint;
892 }
893 
894 
898 void ComputeBreakPoint( TRACK* track, int SegmentCount, wxPoint end )
899 {
900  int iDx = 0;
901  int iDy = 0;
902  int iAngle = 0;
903 
904  if( SegmentCount <= 0 )
905  return;
906 
907  if( track == NULL )
908  return;
909 
910  TRACK* newTrack = track;
911  track = track->Back();
912  SegmentCount--;
913 
914  if( track )
915  {
916  iDx = end.x - track->GetStart().x;
917  iDy = end.y - track->GetStart().y;
918 
919  iDx = abs( iDx );
920  iDy = abs( iDy );
921  }
922 
923  TRACK* lastTrack = track ? track->Back() : NULL;
924 
925  if( lastTrack )
926  {
927  if(( (lastTrack->GetEnd().x == lastTrack->GetStart().x)
928  || (lastTrack->GetEnd().y == lastTrack->GetStart().y) )
930  {
931  iAngle = 45;
932  }
933  }
934  else
935  {
937  {
938  iAngle = 45;
939  }
940  }
941 
942  if( iAngle == 0 )
943  {
944  if( iDx >= iDy )
945  iAngle = 0;
946  else
947  iAngle = 90;
948  }
949 
950  if( track == NULL )
951  iAngle = -1;
952 
953  switch( iAngle )
954  {
955  case -1:
956  break;
957 
958  case 0:
959  if( ( end.x - track->GetStart().x ) < 0 )
960  track->SetEnd(wxPoint( end.x + iDy, track->GetStart().y));
961  else
962  track->SetEnd(wxPoint( end.x - iDy, track->GetStart().y));
963  break;
964 
965  case 45:
966  iDx = std::min( iDx, iDy );
967  iDy = iDx;
968 
969  // Recalculate the signs for deltax and deltaY.
970  if( ( end.x - track->GetStart().x ) < 0 )
971  iDx = -iDx;
972 
973  if( ( end.y - track->GetStart().y ) < 0 )
974  iDy = -iDy;
975 
976  track->SetEnd(wxPoint(track->GetStart().x + iDx, track->GetStart().y + iDy));
977  break;
978 
979  case 90:
980  if( ( end.y - track->GetStart().y ) < 0 )
981  track->SetEnd(wxPoint(track->GetStart().x , end.y + iDx));
982  else
983  track->SetEnd(wxPoint(track->GetStart().x , end.y - iDx));
984  break;
985  }
986 
987  if( track )
988  {
989  if( track->IsNull() )
990  track->SetEnd( end );
991 
992  newTrack->SetStart( track->GetEnd() );
993  }
994 
995  newTrack->SetEnd( end );
996 }
997 
998 
999 /* Delete track segments which have len = 0 after creating a new track
1000  * return a pointer on the first segment (start of track list)
1001  */
1002 void DeleteNullTrackSegments( BOARD* pcb, DLIST<TRACK>& aTrackList )
1003 {
1004  if( aTrackList.GetCount() == 0 )
1005  return;
1006 
1007  TRACK* track = aTrackList.GetFirst();
1008  TRACK* firsttrack = track;
1009  TRACK* oldtrack;
1010 
1011  BOARD_CONNECTED_ITEM* lockPoint = track->start;
1012 
1013  while( track != NULL )
1014  {
1015  oldtrack = track;
1016  track = track->Next();
1017 
1018  if( !oldtrack->IsNull() )
1019  {
1020  continue;
1021  }
1022 
1023  // NULL segment, delete it
1024  if( firsttrack == oldtrack )
1025  firsttrack = track;
1026 
1027  delete aTrackList.Remove( oldtrack );
1028  }
1029 
1030  if( aTrackList.GetCount() == 0 )
1031  return; // all the new track segments have been deleted
1032 
1033  // we must set the pointers on connected items and the connection status
1034  oldtrack = track = firsttrack;
1035  firsttrack->start = NULL;
1036 
1037  while( track != NULL )
1038  {
1039  oldtrack = track;
1040  track = track->Next();
1041  oldtrack->end = track;
1042 
1043  if( track )
1044  track->start = oldtrack;
1045 
1046  oldtrack->SetStatus( 0 );
1047  }
1048 
1049  firsttrack->start = lockPoint;
1050 
1051  if( lockPoint && lockPoint->Type()==PCB_PAD_T )
1052  firsttrack->SetState( BEGIN_ONPAD, true );
1053 
1054  track = firsttrack;
1055 
1056  while( track != NULL )
1057  {
1058  TRACK* next_track = track->Next();
1059  lockPoint = pcb->GetPad( track, ENDPOINT_END );
1060 
1061  if( lockPoint )
1062  {
1063  track->end = lockPoint;
1064  track->SetState( END_ONPAD, true );
1065 
1066  if( next_track )
1067  {
1068  next_track->start = lockPoint;
1069  next_track->SetState( BEGIN_ONPAD, true );
1070  }
1071  }
1072 
1073  track = next_track;
1074  }
1075 }
1076 
1077 
1078 /* Ensure the end point of g_CurrentTrackSegment is on the pad "Pad"
1079  * if no, create a new track segment if necessary
1080  * and move current (or new) end segment on pad
1081  */
1083 {
1084  if( g_CurrentTrackSegment->GetEnd() == aPad->GetPosition() ) // Ok !
1085  {
1086  g_CurrentTrackSegment->end = aPad;
1087  g_CurrentTrackSegment->SetState( END_ONPAD, true );
1088  return;
1089  }
1090 
1091  TRACK* lasttrack = g_CurrentTrackSegment;
1092 
1093  if( !g_CurrentTrackSegment->IsNull() )
1094  {
1095  // Must create a new segment, from track end to pad center
1096  g_CurrentTrackList.PushBack( (TRACK*)lasttrack->Clone() );
1097 
1098  lasttrack->end = g_CurrentTrackSegment;
1099  }
1100 
1101  g_CurrentTrackSegment->SetEnd( aPad->GetPosition() );
1102  g_CurrentTrackSegment->SetState( END_ONPAD, false );
1103 
1104  g_CurrentTrackSegment->end = aPad;
1105  g_CurrentTrackSegment->SetState( END_ONPAD, true );
1106 }
#define g_FirstTrackSegment
first segment created
Definition: pcbnew.h:101
#define g_CurrentTrackSegment
most recently created segment
Definition: pcbnew.h:100
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:915
virtual void OnModify() override
Function OnModify must be called after a board change to set the modified flag.
Definition: pcbframe.cpp:996
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
bool g_Drc_On
Definition: pcbnew.cpp:70
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:1002
bool g_Alternate_Track_Posture
Definition: pcbnew.cpp:73
#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
bool g_AutoDeleteOldTrack
Definition: pcbnew.cpp:71
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:1082
DLIST< TRACK > g_CurrentTrackList
Definition: pcbnew.cpp:98
void TestNetConnection(wxDC *aDC, int aNetCode)
Function TestNetConnection tests the connections relative to aNetCode.
Definition: connect.cpp:786
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:300
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
#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 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:1115
#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:415
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:72
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:833
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:599
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:754
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:798
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:62
#define IS_DELETED
Definition: base_struct.h:116
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 BuildAirWiresTargetsList(BOARD_CONNECTED_ITEM *aItemRef, const wxPoint &aPosition, bool aInit)
Function BuildAirWiresTargetsList Build a list of candidates that can be a coonection point when a tr...
Definition: ratsnest.cpp:836
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:541
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
D_PAD * GetPad(unsigned aIndex) const
Function GetPad.
Definition: class_board.h:750
std::vector< D_PAD * > m_PadsConnected
COLORS_DESIGN_SETTINGS g_ColorsSettings
Definition: pcbnew.cpp:68
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
void HighLightON()
Function HighLightON Enable highlight.
Definition: class_board.h:383
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:361
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:734
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:659
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:166
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
bool g_Track_45_Only_Allowed
Definition: pcbnew.cpp:74
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:898
void ShowNewTrackWhenMovingCursor(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aPosition, bool aErase)
Definition: editrack.cpp:673
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:370
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:153
#define DBG(x)
Definition: fctsys.h:33
int GetHighLightNetCode() const
Function GetHighLightNetCode.
Definition: class_board.h:355
DLIST< TRACK > m_Track
Definition: class_board.h:244
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:48
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
bool g_TwoSegmentTrackBuild
Definition: pcbnew.cpp:76
void ClearMsgPanel(void)
Clear all messages from the message panel.
Definition: draw_frame.cpp:745
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