KiCad PCB EDA Suite
router_tool.cpp
Go to the documentation of this file.
1 /*
2  * KiRouter - a push-and-(sometimes-)shove PCB router
3  *
4  * Copyright (C) 2013-2017 CERN
5  * Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
6  * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
7  *
8  * This program is free software: you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License as published by the
10  * Free Software Foundation, either version 3 of the License, or (at your
11  * option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #include <wx/numdlg.h>
23 
24 #include <core/optional.h>
25 #include <functional>
26 using namespace std::placeholders;
27 
28 #include "class_draw_panel_gal.h"
29 #include "class_board.h"
30 
31 #include <pcb_edit_frame.h>
32 #include <id.h>
33 #include <macros.h>
34 #include <pcbnew_id.h>
35 #include <view/view.h>
36 #include <view/view_controls.h>
37 #include <pcb_painter.h>
41 #include <base_units.h>
42 #include <hotkeys.h>
43 #include <confirm.h>
44 #include <bitmaps.h>
45 #include <collectors.h>
46 
47 #include <tool/context_menu.h>
48 #include <tool/tool_manager.h>
49 #include <tool/tool_settings.h>
50 #include <tool/grid_menu.h>
51 
52 #include <tool/zoom_menu.h>
53 #include <tools/pcb_actions.h>
54 #include <tools/size_menu.h>
55 #include <tools/selection_tool.h>
56 #include <tools/edit_tool.h>
57 #include <tools/tool_event_utils.h>
58 
59 #include "router_tool.h"
60 #include "pns_segment.h"
61 #include "pns_router.h"
62 
63 using namespace KIGFX;
64 
69 {
70  // Via type
71  VIA_MASK = 0x03,
72  VIA = 0x00,
73  BLIND_VIA = 0x01,
74  MICROVIA = 0x02,
75 
76  // Select layer
78 };
79 
80 
81 TOOL_ACTION PCB_ACTIONS::routerActivateSingle( "pcbnew.InteractiveRouter.SingleTrack",
83  _( "Interactive Router (Single Tracks)" ),
84  _( "Run push & shove router (single tracks)" ), ps_router_xpm, AF_ACTIVATE );
85 
86 TOOL_ACTION PCB_ACTIONS::routerActivateDiffPair( "pcbnew.InteractiveRouter.DiffPair",
87  AS_GLOBAL, '6',
88  _( "Interactive Router (Differential Pairs)" ),
89  _( "Run push & shove router (differential pairs)" ), ps_diff_pair_xpm, AF_ACTIVATE );
90 
91 TOOL_ACTION PCB_ACTIONS::routerActivateSettingsDialog( "pcbnew.InteractiveRouter.SettingsDialog",
92  AS_GLOBAL, 0,
93  _( "Interactive Router Settings..." ),
94  _( "Open Interactive Router settings" ), NULL, AF_ACTIVATE );
95 
96 TOOL_ACTION PCB_ACTIONS::routerActivateDpDimensionsDialog( "pcbnew.InteractiveRouter.DpDimensionsDialog",
97  AS_GLOBAL, 0,
98  _( "Differential Pair Dimension Settings..." ),
99  _( "Open Differential Pair Dimension settings" ), ps_diff_pair_gap_xpm, AF_ACTIVATE );
100 
101 TOOL_ACTION PCB_ACTIONS::routerActivateTuneSingleTrace( "pcbnew.LengthTuner.TuneSingleTrack",
102  AS_GLOBAL, '7',
103  _( "Tune length of a single track" ), "", ps_tune_length_xpm, AF_ACTIVATE );
104 
105 TOOL_ACTION PCB_ACTIONS::routerActivateTuneDiffPair( "pcbnew.LengthTuner.TuneDiffPair",
106  AS_GLOBAL, '8',
107  _( "Tune length of a differential pair" ), "", NULL, AF_ACTIVATE );
108 
109 TOOL_ACTION PCB_ACTIONS::routerActivateTuneDiffPairSkew( "pcbnew.LengthTuner.TuneDiffPairSkew",
110  AS_GLOBAL, '9',
111  _( "Tune skew of a differential pair" ), "", NULL, AF_ACTIVATE );
112 
113 TOOL_ACTION PCB_ACTIONS::routerInlineDrag( "pcbnew.InteractiveRouter.InlineDrag",
114  AS_CONTEXT, 0,
115  _( "Drag Track/Via" ), _( "Drags tracks and vias without breaking connections" ),
116  drag_xpm );
117 
118 TOOL_ACTION PCB_ACTIONS::breakTrack( "pcbnew.InteractiveRouter.BreakTrack",
119  AS_GLOBAL, 0,
120  _( "Break Track" ),
121  _( "Splits the track segment into two segments connected at the cursor position." ),
122  break_line_xpm );
123 
124 TOOL_ACTION PCB_ACTIONS::drag45Degree( "pcbnew.InteractiveRouter.Drag45Degree",
126  _( "Drag (45 degree mode)" ),
127  _( "todo" ),
128  drag_segment_withslope_xpm );
129 
130 TOOL_ACTION PCB_ACTIONS::dragFreeAngle( "pcbnew.InteractiveRouter.DragFreeAngle",
132  _( "Drag (free angle)" ),
133  _( "todo" ),
134  move_xpm );
135 
136 static const TOOL_ACTION ACT_NewTrack( "pcbnew.InteractiveRouter.NewTrack", AS_CONTEXT,
138  _( "New Track" ), _( "Starts laying a new track." ), add_tracks_xpm );
139 
140 static const TOOL_ACTION ACT_EndTrack( "pcbnew.InteractiveRouter.EndTrack", AS_CONTEXT, WXK_END,
141  _( "End Track" ), _( "Stops laying the current track." ), checked_ok_xpm );
142 
143 static const TOOL_ACTION ACT_AutoEndRoute( "pcbnew.InteractiveRouter.AutoEndRoute", AS_CONTEXT, 'F',
144  _( "Auto-end Track" ), _( "Automagically finishes currently routed track." ) );
145 
146 static const TOOL_ACTION ACT_PlaceThroughVia( "pcbnew.InteractiveRouter.PlaceVia",
148  _( "Place Through Via" ),
149  _( "Adds a through-hole via at the end of currently routed track." ),
150  via_xpm, AF_NONE,
151  (void*) VIA_ACTION_FLAGS::VIA );
152 
153 static const TOOL_ACTION ACT_PlaceBlindVia( "pcbnew.InteractiveRouter.PlaceBlindVia",
155  _( "Place Blind/Buried Via" ),
156  _( "Adds a blind or buried via at the end of currently routed track."),
157  via_buried_xpm, AF_NONE,
158  (void*) VIA_ACTION_FLAGS::BLIND_VIA );
159 
160 static const TOOL_ACTION ACT_PlaceMicroVia( "pcbnew.InteractiveRouter.PlaceMicroVia",
162  _( "Place Microvia" ), _( "Adds a microvia at the end of currently routed track." ),
163  via_microvia_xpm, AF_NONE,
164  (void*) VIA_ACTION_FLAGS::MICROVIA );
165 
167  "pcbnew.InteractiveRouter.SelLayerAndPlaceVia",
169  _( "Select Layer and Place Through Via..." ),
170  _( "Select a layer, then add a through-hole via at the end of currently routed track." ),
171  select_w_layer_xpm, AF_NONE,
173 
175  "pcbnew.InteractiveRouter.SelLayerAndPlaceBlindVia",
177  _( "Select Layer and Place Blind/Buried Via..." ),
178  _( "Select a layer, then add a blind or buried via at the end of currently routed track."),
179  select_w_layer_xpm, AF_NONE,
181 
182 static const TOOL_ACTION ACT_CustomTrackWidth( "pcbnew.InteractiveRouter.CustomTrackViaSize",
184  _( "Custom Track/Via Size..." ),
185  _( "Shows a dialog for changing the track width and via size." ),
186  width_track_xpm );
187 
188 static const TOOL_ACTION ACT_SwitchPosture( "pcbnew.InteractiveRouter.SwitchPosture", AS_CONTEXT,
190  _( "Switch Track Posture" ),
191  _( "Switches posture of the currently routed track." ),
192  change_entry_orient_xpm );
193 
194 static const TOOL_ACTION ACT_SetDpDimensions( "pcbnew.InteractiveRouter.SetDpDimensions",
196  _( "Differential Pair Dimensions..." ),
197  _( "Sets the width and gap of the currently routed differential pair." ),
198  ps_diff_pair_tune_length_xpm );
199 
201  TOOL_BASE( "pcbnew.InteractiveRouter" )
202 {
203 }
204 
205 
207 {
208 public:
209  TRACK_WIDTH_MENU( const BOARD* aBoard )
210  : TRACK_VIA_SIZE_MENU( true, true )
211  {
212  SetTitle( _( "Select Track/Via Width" ) );
213  SetBoard( aBoard );
214  }
215 
216  void SetBoard( const BOARD* aBoard )
217  {
218  m_board = aBoard;
219 
220  Clear();
221 
222  Append( ID_POPUP_PCB_SELECT_CUSTOM_WIDTH, _( "Custom Size" ),
223  wxEmptyString, wxITEM_CHECK );
224 
225  Append( ID_POPUP_PCB_SELECT_AUTO_WIDTH, _( "Use Starting Track Width" ),
226  _( "Route using the width of the starting track." ), wxITEM_CHECK );
227 
228  Append( ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES, _( "Use Net Class Values" ),
229  _( "Use track and via sizes from the net class" ), wxITEM_CHECK );
230 
231  AppendSeparator();
232 
233  // Append the list of tracks & via sizes
234  AppendSizes( aBoard );
235  }
236 
237 protected:
238  CONTEXT_MENU* create() const override
239  {
240  return new TRACK_WIDTH_MENU( m_board );
241  }
242 
243  OPT_TOOL_EVENT eventHandler( const wxMenuEvent& aEvent ) override
244  {
245  BOARD_DESIGN_SETTINGS &bds = m_board->GetDesignSettings();
246  int id = aEvent.GetId();
247 
248  // On Windows, this handler can be called with a non existing event ID not existing
249  // in any menuitem.
250  // So we keep trace of in-range/out-of-range event ID
251  bool in_range = true;
252 
253  // Initial settings, to be modified below, but only if the ID exists in this menu
254  bool useConnectedTrackWidth = false;
255  bool useCustomTrackViaSize = false;
256 
258  {
259  useCustomTrackViaSize = true;
260  }
261  else if( id == ID_POPUP_PCB_SELECT_AUTO_WIDTH )
262  {
263  useConnectedTrackWidth = true;
264  }
266  {
267  bds.SetViaSizeIndex( 0 );
268  bds.SetTrackWidthIndex( 0 );
269  }
270  else if( id >= ID_POPUP_PCB_SELECT_VIASIZE1 &&
272  {
273  // via size has changed
275  }
276  else if( id >= ID_POPUP_PCB_SELECT_WIDTH1 &&
278  {
279  // track width has changed
281  }
282  else
283  {
284  in_range = false; // This event ID does not exist in the menu
285  wxASSERT_MSG( false, "OPT_TOOL_EVENT EventHandler: unexpected id" );
286  // Fix me: How to return this error as OPT_TOOL_EVENT?
287  }
288 
289  if( in_range )
290  {
291  // Update this setup only id the event ID matches the options of this menu
292  bds.m_UseConnectedTrackWidth = useConnectedTrackWidth;
293  bds.UseCustomTrackViaSize( useCustomTrackViaSize );
294  }
295 
296  return OPT_TOOL_EVENT( PCB_ACTIONS::trackViaSizeChanged.MakeEvent() );
297  }
298 
299 private:
300  const BOARD* m_board;
301 };
302 
303 
305 {
306 public:
307  ROUTER_TOOL_MENU( const BOARD* aBoard, PCB_EDIT_FRAME& aFrame, PNS::ROUTER_MODE aMode ) :
308  m_board( aBoard ), m_frame( aFrame ), m_mode( aMode ),
309  m_widthMenu( aBoard ), m_zoomMenu( &aFrame ), m_gridMenu( &aFrame )
310  {
311  SetTitle( _( "Interactive Router" ) );
312 
314 
315  AppendSeparator();
316 
317  Add( ACT_NewTrack );
318  Add( ACT_EndTrack );
320 
323 
324 // Add( ACT_AutoEndRoute ); // fixme: not implemented yet. Sorry.
325  Add( ACT_PlaceThroughVia );
326  Add( ACT_PlaceBlindVia );
327  Add( ACT_PlaceMicroVia );
330  Add( ACT_SwitchPosture );
331 
332  AppendSeparator();
333 
334  m_widthMenu.SetBoard( aBoard );
335  Add( &m_widthMenu );
336 
337  Add( ACT_CustomTrackWidth );
338 
339  if( aMode == PNS::PNS_MODE_ROUTE_DIFF_PAIR )
340  Add( ACT_SetDpDimensions );
341 
342  AppendSeparator();
344 
345  AppendSeparator();
346  Add( &m_zoomMenu );
347  Add( &m_gridMenu );
348  }
349 
350 private:
351  CONTEXT_MENU* create() const override
352  {
353  return new ROUTER_TOOL_MENU( m_board, m_frame, m_mode );
354  }
355 
356  const BOARD* m_board;
362 };
363 
364 
366 {
368 }
369 
370 
372 {
374  return true;
375 }
376 
377 
379 {
380  TOOL_BASE::Reset( aReason );
381 }
382 
383 
384 int ROUTER_TOOL::getDefaultWidth( int aNetCode )
385 {
386  int w, d1, d2;
387 
388  getNetclassDimensions( aNetCode, w, d1, d2 );
389 
390  return w;
391 }
392 
393 
394 void ROUTER_TOOL::getNetclassDimensions( int aNetCode, int& aWidth,
395  int& aViaDiameter, int& aViaDrill )
396 {
398 
399  NETCLASSPTR netClass;
400  NETINFO_ITEM* ni = board()->FindNet( aNetCode );
401 
402  if( ni )
403  {
404  wxString netClassName = ni->GetClassName();
405  netClass = bds.m_NetClasses.Find( netClassName );
406  }
407 
408  if( !netClass )
409  netClass = bds.GetDefault();
410 
411  aWidth = netClass->GetTrackWidth();
412  aViaDiameter = netClass->GetViaDiameter();
413  aViaDrill = netClass->GetViaDrill();
414 }
415 
416 
418 {
419 #ifdef DEBUG
420  if( aEvent.IsKeyPressed() )
421  {
422  switch( aEvent.KeyCode() )
423  {
424  case '0':
425  wxLogTrace( "PNS", "saving drag/route log...\n" );
426  m_router->DumpLog();
427  break;
428  }
429  }
430 #endif
431 }
432 
433 
435 {
436  int tl = getView()->GetTopLayer();
437 
438  if( m_startItem )
439  {
440  const LAYER_RANGE& ls = m_startItem->Layers();
441 
442  if( ls.Overlaps( tl ) )
443  return tl;
444  else
445  return ls.Start();
446  }
447 
448  return tl;
449 }
450 
451 
453 {
454  int al = frame()->GetActiveLayer();
455  int cl = m_router->GetCurrentLayer();
456 
457  if( cl != al )
458  {
459  m_router->SwitchLayer( al );
460  }
461 
462  OPT<int> newLayer = m_router->Sizes().PairedLayer( cl );
463 
464  if( !newLayer )
465  newLayer = m_router->Sizes().GetLayerTop();
466 
467  m_router->SwitchLayer( *newLayer );
468  frame()->SetActiveLayer( ToLAYER_ID( *newLayer ) );
469 }
470 
471 
472 static VIATYPE_T getViaTypeFromFlags( int aFlags )
473 {
474  VIATYPE_T viaType = VIA_THROUGH;
475 
476  switch( aFlags & VIA_ACTION_FLAGS::VIA_MASK )
477  {
479  viaType = VIA_THROUGH;
480  break;
482  viaType = VIA_BLIND_BURIED;
483  break;
485  viaType = VIA_MICROVIA;
486  break;
487  default:
488  wxASSERT_MSG( false, "Unhandled via type" );
489  }
490 
491  return viaType;
492 }
493 
494 
496 {
497  const int actViaFlags = aEvent.Parameter<intptr_t>();
498 
499  VIATYPE_T viaType = getViaTypeFromFlags( actViaFlags );
500  const bool selectLayer = actViaFlags & VIA_ACTION_FLAGS::SELECT_LAYER;
501 
503 
504  const int layerCount = bds.GetCopperLayerCount();
505  int currentLayer = m_router->GetCurrentLayer();
508 
510 
511  // ask the user for a target layer
512  PCB_LAYER_ID targetLayer = UNDEFINED_LAYER;
513 
514  if( selectLayer )
515  {
516  wxPoint dlgPosition = wxGetMousePosition();
517 
518  targetLayer = frame()->SelectLayer( static_cast<PCB_LAYER_ID>( currentLayer ),
519  LSET::AllNonCuMask(), dlgPosition );
520  }
521 
522  // fixme: P&S supports more than one fixed layer pair. Update the dialog?
523  sizes.ClearLayerPairs();
524 
525  if( !m_router->IsPlacingVia() )
526  {
527  // Cannot place microvias or blind vias if not allowed (obvious)
528  if( ( viaType == VIA_BLIND_BURIED ) && ( !bds.m_BlindBuriedViaAllowed ) )
529  {
530  DisplayError( frame(), _( "Blind/buried vias have to be enabled in the design settings." ) );
531  return false;
532  }
533 
534  if( ( viaType == VIA_MICROVIA ) && ( !bds.m_MicroViasAllowed ) )
535  {
536  DisplayError( frame(), _( "Microvias have to be enabled in the design settings." ) );
537  return false;
538  }
539 
540  // Can only place through vias on 2-layer boards
541  if( ( viaType != VIA_THROUGH ) && ( layerCount <= 2 ) )
542  {
543  DisplayError( frame(), _( "Only through vias are allowed on 2 layer boards." ) );
544  return false;
545  }
546 
547  // Can only place microvias if we're on an outer layer, or directly adjacent to one
548  if( ( viaType == VIA_MICROVIA ) && ( currentLayer > In1_Cu ) && ( currentLayer < layerCount - 2 ) )
549  {
550  DisplayError( frame(), _( "Microvias can be placed only between the outer layers " \
551  "(F.Cu/B.Cu) and the ones directly adjacent to them." ) );
552  return false;
553  }
554  }
555 
556  // Convert blind/buried via to a through hole one, if it goes through all layers
557  if( viaType == VIA_BLIND_BURIED && ( ( currentLayer == B_Cu ) || ( currentLayer == F_Cu ) )
558  && ( ( pairTop == B_Cu && pairBottom == F_Cu )
559  || ( pairTop == F_Cu && pairBottom == B_Cu ) ) )
560  {
561  viaType = VIA_THROUGH;
562  }
563 
564  switch( viaType )
565  {
566  case VIA_THROUGH:
567  sizes.SetViaDiameter( bds.GetCurrentViaSize() );
568  sizes.SetViaDrill( bds.GetCurrentViaDrill() );
569 
570  if( targetLayer != UNDEFINED_LAYER )
571  {
572  // go from the current layer to the chosen layer
573  sizes.AddLayerPair( currentLayer, targetLayer );
574  }
575  else
576  {
577  // use the default layer pair
578  sizes.AddLayerPair( pairTop, pairBottom );
579  }
580  break;
581 
582  case VIA_MICROVIA:
583  sizes.SetViaDiameter( bds.GetCurrentMicroViaSize() );
584  sizes.SetViaDrill( bds.GetCurrentMicroViaDrill() );
585 
586  wxASSERT_MSG( !selectLayer, "Unexpected select layer for microvia (microvia layers are implicit)" );
587 
588  if( currentLayer == F_Cu || currentLayer == In1_Cu )
589  {
590  // front-side microvia
591  sizes.AddLayerPair( F_Cu, In1_Cu );
592  }
593  else if( currentLayer == B_Cu || currentLayer == layerCount - 2 )
594  {
595  // back-side microvia
596  sizes.AddLayerPair( B_Cu, layerCount - 2 );
597  }
598  else
599  {
600  wxASSERT_MSG( false, "Invalid layer pair for microvia (must be on or adjacent to an outer layer)" );
601  }
602  break;
603 
604  case VIA_BLIND_BURIED:
605  sizes.SetViaDiameter( bds.GetCurrentViaSize() );
606  sizes.SetViaDrill( bds.GetCurrentViaDrill() );
607 
608  if( targetLayer != UNDEFINED_LAYER )
609  {
610  // go directly to the user specified layer
611  sizes.AddLayerPair( currentLayer, targetLayer );
612  }
613  else
614  {
615  if( currentLayer == pairTop || currentLayer == pairBottom )
616  {
617  // the current layer is on the defined layer pair,
618  // swap to the other side
619  sizes.AddLayerPair( pairTop, pairBottom );
620  }
621  else
622  {
623  // the current layer is not part of the current layer pair,
624  // so fallback and swap to the top layer of the pair by default
625  sizes.AddLayerPair( pairTop, currentLayer );
626  }
627  }
628  break;
629 
630  default:
631  wxASSERT( false );
632  break;
633  }
634 
635  sizes.SetViaType( viaType );
636 
637  m_router->UpdateSizes( sizes );
639 
640  updateEndItem( aEvent );
641 
642  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
643 
644  return 0;
645 }
646 
647 
649 {
650  int routingLayer = getStartLayer( m_startItem );
651 
652  if( !IsCopperLayer( routingLayer ) )
653  {
654  DisplayError( frame(), _( "Tracks on Copper layers only" ) );
655  return false;
656  }
657 
658  frame()->SetActiveLayer( ToLAYER_ID( routingLayer ) );
659 
660  // fixme: switch on invisible layer
661 
662  // for some reason I don't understand, GetNetclass() may return null sometimes...
663  if( m_startItem && m_startItem->Net() >= 0 &&
665  {
666  highlightNet( true, m_startItem->Net() );
667  // Update track width and via size shown in main toolbar comboboxes
668  frame()->SetCurrentNetClass( m_startItem->Parent()->GetNetClass()->GetName() );
669  }
670  else
672 
673  controls()->ForceCursorPosition( false );
674  controls()->SetAutoPan( true );
675 
676  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
677 
678  sizes.Init( board(), m_startItem );
679  sizes.AddLayerPair( frame()->GetScreen()->m_Route_Layer_TOP,
680  frame()->GetScreen()->m_Route_Layer_BOTTOM );
681  m_router->UpdateSizes( sizes );
682 
683  if( !m_router->StartRouting( m_startSnapPoint, m_startItem, routingLayer ) )
684  {
686  highlightNet( false );
687  controls()->SetAutoPan( false );
688  return false;
689  }
690 
691  m_endItem = NULL;
693 
694  frame()->UndoRedoBlock( true );
695 
696  return true;
697 }
698 
699 
701 {
703 
704  controls()->SetAutoPan( false );
705  controls()->ForceCursorPosition( false );
706  frame()->UndoRedoBlock( false );
707  highlightNet( false );
708 
709  return true;
710 }
711 
712 
714 {
715  if( !prepareInteractive() )
716  return;
717 
718  while( OPT_TOOL_EVENT evt = Wait() )
719  {
720  // Don't crash if we missed an operation that cancelled routing.
721  wxCHECK2( m_router->RoutingInProgress(), break );
722 
723  if( evt->IsMotion() )
724  {
725  m_router->SetOrthoMode( evt->Modifier( MD_CTRL ) );
726  updateEndItem( *evt );
728  }
729  else if( evt->IsClick( BUT_LEFT ) )
730  {
731  updateEndItem( *evt );
732  bool needLayerSwitch = m_router->IsPlacingVia();
733 
735  break;
736 
737  if( needLayerSwitch )
739 
740  // Synchronize the indicated layer
742  updateEndItem( *evt );
744  m_startItem = NULL;
745  }
746  else if( evt->IsAction( &ACT_SwitchPosture ) )
747  {
749  updateEndItem( *evt );
750  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
751  }
752  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
753  {
754  m_router->SwitchLayer( frame()->GetActiveLayer() );
755  updateEndItem( *evt );
756  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
757  }
758  else if( evt->IsAction( &ACT_EndTrack ) )
759  {
760  bool still_routing = true;
761  while( still_routing )
762  still_routing = m_router->FixRoute( m_endSnapPoint, m_endItem );
763  break;
764  }
765  else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt )
766  || evt->IsUndoRedo()
767  || evt->IsAction( &PCB_ACTIONS::routerInlineDrag ) )
768  break;
769  }
770 
772 }
773 
774 
776 {
777  Activate();
778 
780  DIALOG_PNS_DIFF_PAIR_DIMENSIONS settingsDlg( frame(), sizes );
781 
782  if( settingsDlg.ShowModal() )
783  {
784  m_router->UpdateSizes( sizes );
785  m_savedSizes = sizes;
786  }
787 
788  return 0;
789 }
790 
791 
793 {
794  Activate();
795 
796  DIALOG_PNS_SETTINGS settingsDlg( frame(), m_router->Settings() );
797 
798  if( settingsDlg.ShowModal() )
799  {
801  }
802 
803  return 0;
804 }
805 
806 
808 {
814 
820 
821  // TODO is not this redundant? the same actions can be used for menus and hotkeys
824 
827 }
828 
829 
831 {
832  frame()->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Route Track" ) );
834 }
835 
836 
838 {
839  frame()->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Router Differential Pair" ) );
841 }
842 
844 {
846  {
848  }
849 }
850 
852 {
853  PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
854  BOARD* board = getModel<BOARD>();
855 
856  // Deselect all items
858 
859  Activate();
860 
861  m_router->SetMode( aMode );
862 
863  VIEW_CONTROLS* ctls = getViewControls();
864  ctls->ShowCursor( true );
865  ctls->ForceCursorPosition( false );
867 
868  std::unique_ptr<ROUTER_TOOL_MENU> ctxMenu( new ROUTER_TOOL_MENU( board, *frame, aMode ) );
869  SetContextMenu( ctxMenu.get() );
870 
871  // Main loop: keep receiving events
872  while( OPT_TOOL_EVENT evt = Wait() )
873  {
875  {
876  break; // Finish
877  }
878  else if( evt->Action() == TA_UNDO_REDO_PRE )
879  {
880  m_router->ClearWorld();
881  }
882  else if( evt->Action() == TA_UNDO_REDO_POST || evt->Action() == TA_MODEL_CHANGE )
883  {
884  m_router->SyncWorld();
885  }
886  else if( evt->IsMotion() )
887  {
888  updateStartItem( *evt );
889  }
890  else if( evt->IsAction( &PCB_ACTIONS::dragFreeAngle ) )
891  {
892  updateStartItem( *evt );
894  }
895  else if( evt->IsAction( &PCB_ACTIONS::drag45Degree ) )
896  {
897  updateStartItem( *evt );
899  }
900  else if( evt->IsAction( &PCB_ACTIONS::breakTrack ) )
901  {
902  updateStartItem( *evt );
903  breakTrack( );
904  }
905  else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &ACT_NewTrack ) )
906  {
907  updateStartItem( *evt );
908 
909  if( evt->Modifier( MD_CTRL ) )
911  else
912  performRouting();
913  }
914  else if( evt->IsAction( &ACT_PlaceThroughVia ) )
915  {
917  }
918  }
919 
920  frame->SetNoToolSelected();
921  SetContextMenu( nullptr );
922 
923  // Store routing settings till the next invocation
926 
927  return 0;
928 }
929 
930 
932 {
933  VIEW_CONTROLS* ctls = getViewControls();
934 
935  if( m_startItem && m_startItem->IsLocked() )
936  {
937  if( !IsOK( frame(), _( "The item is locked. Do you want to continue?" ) ) )
938  return;
939  }
940 
941  bool dragStarted = m_router->StartDragging( m_startSnapPoint, m_startItem, aMode );
942 
943  if( !dragStarted )
944  return;
945 
946  if( m_startItem && m_startItem->Net() >= 0 )
947  highlightNet( true, m_startItem->Net() );
948 
949  ctls->SetAutoPan( true );
950 
951  frame()->UndoRedoBlock( true );
952 
953  while( OPT_TOOL_EVENT evt = Wait() )
954  {
955  ctls->ForceCursorPosition( false );
956 
957  if( evt->IsMotion() )
958  {
959  updateEndItem( *evt );
961  }
962  else if( evt->IsClick( BUT_LEFT ) )
963  {
965  break;
966  }
967  else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt )
968  || evt->IsUndoRedo() )
969  break;
970 
971  handleCommonEvents( *evt );
972  }
973 
974  if( m_router->RoutingInProgress() )
976 
977  m_startItem = nullptr;
978 
979  frame()->UndoRedoBlock( false );
980  ctls->SetAutoPan( false );
981  ctls->ForceCursorPosition( false );
982  highlightNet( false );
983 }
984 
985 
987 {
988  /* If the collection contains a trivial line corner (two connected segments)
989  * or a non-fanout-via (a via with no more than two connected segments), then
990  * trim the collection down to a single item (which one won't matter since
991  * they're all connected).
992  */
993 
994  // First make sure we've got something that *might* match.
995  int vias = aCollector.CountType( PCB_VIA_T );
996  int traces = aCollector.CountType( PCB_TRACE_T );
997 
998  if( vias > 1 || traces > 2 || vias + traces < 1 )
999  return;
1000 
1001  // Fetch first TRACK (via or trace) as our reference
1002  TRACK* reference = nullptr;
1003 
1004  for( int i = 0; !reference && i < aCollector.GetCount(); i++ )
1005  reference = dynamic_cast<TRACK*>( aCollector[i] );
1006 
1007  int refNet = reference->GetNetCode();
1008 
1009  wxPoint refPoint;
1010  STATUS_FLAGS flags = reference->IsPointOnEnds( wxPoint( aPt.x, aPt.y ), -1 );
1011 
1012  if( flags & STARTPOINT )
1013  refPoint = reference->GetStart();
1014  else if( flags & ENDPOINT )
1015  refPoint = reference->GetEnd();
1016  else
1017  return;
1018 
1019  // Check all items to ensure that they are TRACKs which are co-terminus
1020  // with the reference, and on the same net. Ignore markers.
1021  for( int i = 0; i < aCollector.GetCount(); i++ )
1022  {
1023  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( aCollector[i] );
1024 
1025  if( item->Type() == PCB_MARKER_T )
1026  continue;
1027 
1028  TRACK* neighbor = dynamic_cast<TRACK*>( item );
1029 
1030  if( !neighbor || neighbor->GetNetCode() != refNet )
1031  return;
1032 
1033  if( neighbor->GetStart() != refPoint && neighbor->GetEnd() != refPoint )
1034  return;
1035  }
1036 
1037  // Selection meets criteria; trim it to the reference item.
1038  for( int i = aCollector.GetCount() - 1; i >= 0; i-- )
1039  {
1040  if( dynamic_cast<TRACK*>( aCollector[i] ) != reference )
1041  aCollector.Remove( i );
1042  }
1043 }
1044 
1045 
1047 {
1049  const auto& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
1050 
1051  if( selection.Size() == 1 )
1052  {
1053  const BOARD_CONNECTED_ITEM* item = static_cast<const BOARD_CONNECTED_ITEM*>( selection.Front() );
1054 
1055  if( item->Type() == PCB_TRACE_T || item->Type() == PCB_VIA_T )
1056  return true;
1057  }
1058 
1059  return false;
1060 }
1061 
1062 
1064 {
1065  const auto& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
1066 
1067  if( selection.Empty() )
1069 
1070  if( selection.Size() != 1 )
1071  return 0;
1072 
1073  const BOARD_CONNECTED_ITEM* item = static_cast<const BOARD_CONNECTED_ITEM*>( selection.Front() );
1074 
1075  if( item->Type() != PCB_TRACE_T && item->Type() != PCB_VIA_T )
1076  return 0;
1077 
1078  Activate();
1079 
1081  m_router->SyncWorld();
1083 
1084  if( m_startItem && m_startItem->IsLocked() )
1085  {
1086  if( !IsOK( frame(), _( "The item is locked. Do you want to continue?" ) ) )
1087  return false;
1088  }
1089 
1091 
1092  int dragMode = aEvent.Parameter<int64_t> ();
1093 
1094  bool dragStarted = m_router->StartDragging( p0, m_startItem, dragMode );
1095 
1096  if( !dragStarted )
1097  return 0;
1098 
1099  controls()->ShowCursor( true );
1100  controls()->ForceCursorPosition( false );
1101  controls()->SetAutoPan( true );
1102  frame()->UndoRedoBlock( true );
1103 
1104  while( OPT_TOOL_EVENT evt = Wait() )
1105  {
1106  if( evt->IsCancel() )
1107  {
1108  break;
1109  }
1110  else if( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
1111  {
1112  updateEndItem( *evt );
1114  }
1115  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
1116  {
1117  updateEndItem( *evt );
1119  break;
1120  }
1121  }
1122 
1123  if( m_router->RoutingInProgress() )
1124  m_router->StopRouting();
1125 
1126  frame()->UndoRedoBlock( false );
1127 
1128  return 0;
1129 }
1130 
1131 
1133 {
1135  DIALOG_TRACK_VIA_SIZE sizeDlg( frame(), bds );
1136 
1137  if( sizeDlg.ShowModal() )
1138  {
1139  bds.UseCustomTrackViaSize( true );
1141  }
1142 
1143  return 0;
1144 }
1145 
1146 
1148 {
1149  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
1150  sizes.ImportCurrent( board()->GetDesignSettings() );
1151  m_router->UpdateSizes( sizes );
1152 
1153  return 0;
1154 }
CONTEXT_MENU * create() const override
Returns an instance of this class. It has to be overridden in inheriting classes. ...
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
int mainLoop(PNS::ROUTER_MODE aMode)
int GetCurrentMicroViaSize()
Function GetCurrentMicroViaSize.
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
ROUTER_TOOL_MENU(const BOARD *aBoard, PCB_EDIT_FRAME &aFrame, PNS::ROUTER_MODE aMode)
Class ITEM.
Definition: pns_item.h:53
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:107
static TOOL_ACTION ACT_RouterOptions
Definition: pns_tool_base.h:47
KICAD_T Type() const
Function Type()
Definition: base_struct.h:227
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:106
virtual int GetTopLayer() const
Definition: view.cpp:718
void SetTrackWidthIndex(unsigned aIndex)
Function SetTrackWidthIndex sets the current track width list index to aIndex.
int GetCurrentViaDrill() const
Function GetCurrentViaDrill.
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
Context menu that displays track and/or via sizes basing on the board design settings of a BOARD obje...
Definition: size_menu.h:31
NETCLASSPTR Find(const wxString &aName) const
Function Find searches this container for a NETCLASS given by aName.
Definition: netclass.cpp:144
NETCLASSPTR GetDefault() const
Function GetDefault.
void SetBoard(const BOARD *aBoard)
int DpDimensionsDialog(const TOOL_EVENT &aEvent)
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:58
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:209
TRACK_WIDTH_MENU m_widthMenu
Normal via
Definition: router_tool.cpp:73
bool finishInteractive()
blind/buried via
Definition: router_tool.cpp:74
Implementation of conversion functions that require both schematic and board internal units...
This file is part of the common library.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
const wxString & FailureReason() const
Definition: pns_router.h:214
Class CONTEXT_MENU.
Definition: context_menu.h:44
int GetCurrentMicroViaDrill()
Function GetCurrentMicroViaDrill.
VIEW_CONTROLS class definition.
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:71
int InlineDrag(const TOOL_EVENT &aEvent)
Class SELECTION_TOOL.
static const TOOL_ACTION ACT_NewTrack("pcbnew.InteractiveRouter.NewTrack", AS_CONTEXT, TOOL_ACTION::LegacyHotKey(HK_ADD_NEW_TRACK), _("New Track"), _("Starts laying a new track."), add_tracks_xpm)
Class BOARD to handle a board.
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
STATUS_FLAGS IsPointOnEnds(const wxPoint &point, int min_dist=0)
Function IsPointOnEnds returns STARTPOINT if point if near (dist = min_dist) start point...
int RouteSingleTrace(const TOOL_EVENT &aEvent)
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:134
wxString GetClassName() const
Function GetClassName returns the class name.
Definition: netinfo.h:131
EDA_ITEM * Front() const
Definition: selection.h:144
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
static LSET AllNonCuMask()
Function AllNonCuMask returns a mask holding all layer minus CU layers.
Definition: lset.cpp:696
static TOOL_ACTION cancelInteractive
Definition: actions.h:45
SIZES_SETTINGS m_savedSizes
Stores sizes settings between router invocations.
Definition: pns_tool_base.h:68
void SyncWorld()
Definition: pns_router.cpp:91
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
Microvia
Definition: router_tool.cpp:77
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
static int LegacyHotKey(int aHotKey)
Creates a hot key code that refers to a legacy hot key setting, instead of a particular key...
Definition: tool_action.h:174
static const TOOL_ACTION ACT_PlaceBlindVia("pcbnew.InteractiveRouter.PlaceBlindVia", AS_CONTEXT, TOOL_ACTION::LegacyHotKey(HK_ADD_BLIND_BURIED_VIA), _("Place Blind/Buried Via"), _("Adds a blind or buried via at the end of currently routed track."), via_buried_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::BLIND_VIA)
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:291
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:133
static const TOOL_ACTION ACT_PlaceThroughVia("pcbnew.InteractiveRouter.PlaceVia", AS_CONTEXT, TOOL_ACTION::LegacyHotKey(HK_ADD_THROUGH_VIA), _("Place Through Via"), _("Adds a through-hole via at the end of currently routed track."), via_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::VIA)
static TOOL_ACTION routerActivateSingle
Activation of the Push and Shove router.
Definition: pcb_actions.h:195
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
const BOARD * m_board
void SetViaDrill(int aDrill)
bool IsPlacingVia() const
Definition: pns_router.cpp:489
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:206
VIATYPE_T
Definition: class_track.h:50
bool IsKeyPressed() const
Definition: tool_event.h:326
int KeyCode() const
Definition: tool_event.h:321
bool SetCurrentNetClass(const wxString &aNetClassName)
Function SetCurrentNetClass Must be called after a netclass selection (or after a netclass parameter ...
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
void SwitchLayer(int layer)
Definition: pns_router.cpp:426
int CountType(KICAD_T aType)
Function CountType counts the number of items matching aType.
Definition: collector.h:258
void breakTrack()
int GetCurrentViaSize() const
Function GetCurrentViaSize.
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
static TOOL_ACTION routerActivateTuneSingleTrace
Activation of the Push and Shove router (tune single line mode)
Definition: pcb_actions.h:201
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
bool m_UseConnectedTrackWidth
if true, when creating a new track starting on an existing track, use this track width ...
void SetOrthoMode(bool aEnable)
Definition: pns_router.cpp:498
void Remove(int aIndex)
Function Remove removes the item at aIndex (first position is 0);.
Definition: collector.h:136
const wxPoint & GetEnd() const
Definition: class_track.h:119
NODE * GetWorld() const
Definition: pns_router.h:143
void ToggleViaPlacement()
Definition: pns_router.cpp:439
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
void handleCommonEvents(const TOOL_EVENT &evt)
Pcbnew hotkeys.
GRID_MENU m_gridMenu
This file contains miscellaneous commonly used macros and functions.
void ClearWorld()
Definition: pns_router.cpp:100
bool RoutingInProgress() const
Definition: pns_router.cpp:112
bool OfKind(int aKindMask) const
Function OfKind()
Definition: pns_item.h:132
void SetViaSizeIndex(unsigned aIndex)
Function SetViaSizeIndex sets the current via size list index to aIndex.
int onViaCommand(const TOOL_EVENT &aEvent)
KIGFX::VIEW_CONTROLS * controls() const
Definition: pcb_tool.h:133
virtual void Reset(RESET_REASON aReason)=0
Function Reset() Brings the tool to a known, initial state.
int RouteDiffPair(const TOOL_EVENT &aEvent)
virtual void updateEndItem(const TOOL_EVENT &aEvent)
bool prepareInteractive()
PCB_LAYER_ID
A quick note on layer IDs:
bool IsLocked() const
Definition: pns_item.h:338
int GetCopperLayerCount() const
Function GetCopperLayerCount.
void performRouting()
CONTEXT_MENU * create() const override
Returns an instance of this class. It has to be overridden in inheriting classes. ...
void BreakSegment(ITEM *aItem, const VECTOR2I &aP)
Definition: pns_router.cpp:519
static TOOL_ACTION routerActivateTuneDiffPairSkew
Activation of the Push and Shove router (skew tuning mode)
Definition: pcb_actions.h:207
std::shared_ptr< NETCLASS > GetNetClass() const
Function GetNetClass returns the NETCLASS for this item.
static const char Default[]
the name of the default NETCLASS
Definition: netclass.h:90
const wxPoint & GetStart() const
Definition: class_track.h:122
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:134
Class TOOL_EVENT.
Definition: tool_event.h:162
PNS::ROUTER_MODE m_mode
ITEM * m_startItem
Definition: pns_tool_base.h:69
OPT_TOOL_EVENT eventHandler(const wxMenuEvent &aEvent) override
Event handler stub.
bool FixRoute(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:364
static const TOOL_ACTION ACT_SwitchPosture("pcbnew.InteractiveRouter.SwitchPosture", AS_CONTEXT, TOOL_ACTION::LegacyHotKey(HK_SWITCH_TRACK_POSTURE), _("Switch Track Posture"), _("Switches posture of the currently routed track."), change_entry_orient_xpm)
ZOOM_MENU m_zoomMenu
void Init(BOARD *aBoard, ITEM *aStartItem=NULL, int aNet=-1)
unsigned STATUS_FLAGS
Definition: base_struct.h:160
ROUTER * m_router
Definition: pns_tool_base.h:78
void SetContextMenu(CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
Function SetContextMenu()
bool CanInlineDrag()
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
void Load(const TOOL_SETTINGS &where)
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:46
void switchLayerOnViaPlacement()
PCB_EDIT_FRAME & m_frame
void getNetclassDimensions(int aNetCode, int &aWidth, int &aViaDiameter, int &aViaDrill)
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
static TOOL_ACTION routerActivateTuneDiffPair
Activation of the Push and Shove router (diff pair tuning mode)
Definition: pcb_actions.h:204
bool m_BlindBuriedViaAllowed
true to allow blind/buried vias
const BOARD * m_board
const SELECTION & selection() const
Definition: pcb_tool.cpp:218
ROUTING_SETTINGS m_savedSettings
Stores routing settings between router invocations.
Definition: pns_tool_base.h:67
int SettingsDialog(const TOOL_EVENT &aEvent)
int CustomTrackWidthDialog(const TOOL_EVENT &aEvent)
void ImportCurrent(BOARD_DESIGN_SETTINGS &aSettings)
int Start() const
Definition: pns_layerset.h:83
static const TOOL_ACTION ACT_PlaceMicroVia("pcbnew.InteractiveRouter.PlaceMicroVia", AS_CONTEXT, TOOL_ACTION::LegacyHotKey(HK_ADD_MICROVIA), _("Place Microvia"), _("Adds a microvia at the end of currently routed track."), via_microvia_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::MICROVIA)
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
All active tools
Definition: tool_event.h:138
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:225
TOOL_SETTINGS & GetSettings()
Definition: tool_base.cpp:77
int onTrackViaSizeChanged(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:215
bool StartRouting(const VECTOR2I &aP, ITEM *aItem, int aLayer)
Definition: pns_router.cpp:170
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:68
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg...
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
TRACK_WIDTH_MENU(const BOARD *aBoard)
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
static TOOL_ACTION breakTrack
Definition: pcb_actions.h:132
void StopRouting()
Definition: pns_router.cpp:389
int GetNetCode() const
Function GetNetCode.
virtual void highlightNet(bool aEnabled, int aNetcode=-1)
static const TOOL_ACTION ACT_CustomTrackWidth("pcbnew.InteractiveRouter.CustomTrackViaSize", AS_CONTEXT, TOOL_ACTION::LegacyHotKey(HK_CUSTOM_TRACK_WIDTH), _("Custom Track/Via Size..."), _("Shows a dialog for changing the track width and via size."), width_track_xpm)
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Definition: draw_frame.cpp:574
ROUTER_MODE
Definition: pns_router.h:64
Class NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:69
void SetViaType(VIATYPE_T aViaType)
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:283
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
TOOL_EVENT MakeEvent() const
Function HasHotKey() Checks if the action has a hot key assigned.
Definition: tool_action.h:104
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:99
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:308
void SetMode(ROUTER_MODE aMode)
Definition: pns_router.cpp:507
int getDefaultWidth(int aNetCode)
static TOOL_ACTION routerActivateSettingsDialog
Activation of the Push and Shove settings dialogs.
Definition: pcb_actions.h:210
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
static const TOOL_ACTION ACT_SelLayerAndPlaceThroughVia("pcbnew.InteractiveRouter.SelLayerAndPlaceVia", AS_CONTEXT, TOOL_ACTION::LegacyHotKey(HK_SEL_LAYER_AND_ADD_THROUGH_VIA), _("Select Layer and Place Through Via..."), _("Select a layer, then add a through-hole via at the end of currently routed track."), select_w_layer_xpm, AF_NONE,(void *)(VIA_ACTION_FLAGS::VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:232
Class TOOL_BASE.
Definition: tool_base.h:68
Class TOOL_ACTION.
Definition: tool_action.h:46
bool StartDragging(const VECTOR2I &aP, ITEM *aItem, int aDragMode=DM_ANY)
Definition: pns_router.cpp:127
#define ENDPOINT
Definition: base_struct.h:133
static void NeighboringSegmentFilter(const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector)
void performDragging(int aMode=PNS::DM_ANY)
NETINFO_ITEM * FindNet(int aNetcode) const
Function FindNet searches for a net with the given netcode.
int Net() const
Function Net()
Definition: pns_item.h:179
PCB_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
ITEM * FindItemByParent(const BOARD_CONNECTED_ITEM *aParent)
Definition: pns_node.cpp:1330
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:80
boost::optional< T > OPT
Definition: optional.h:7
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
void Activate()
Function Activate() Runs the tool.
Implementing DIALOG_TRACK_VIA_SIZE_BASE.
int GetCurrentLayer() const
Definition: pns_router.cpp:458
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
void AddLayerPair(int aL1, int aL2)
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
static const TOOL_ACTION ACT_EndTrack("pcbnew.InteractiveRouter.EndTrack", AS_CONTEXT, WXK_END, _("End Track"), _("Stops laying the current track."), checked_ok_xpm)
void DumpLog()
Definition: pns_router.cpp:466
static const TOOL_ACTION ACT_SelLayerAndPlaceBlindVia("pcbnew.InteractiveRouter.SelLayerAndPlaceBlindVia", AS_CONTEXT, TOOL_ACTION::LegacyHotKey(HK_SEL_LAYER_AND_ADD_BLIND_BURIED_VIA), _("Select Layer and Place Blind/Buried Via..."), _("Select a layer, then add a blind or buried via at the end of currently routed track."), select_w_layer_xpm, AF_NONE,(void *)(VIA_ACTION_FLAGS::BLIND_VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
static VIATYPE_T getViaTypeFromFlags(int aFlags)
static const TOOL_ACTION ACT_SetDpDimensions("pcbnew.InteractiveRouter.SetDpDimensions", AS_CONTEXT, TOOL_ACTION::LegacyHotKey(HK_DP_DIMENSIONS), _("Differential Pair Dimensions..."), _("Sets the width and gap of the currently routed differential pair."), ps_diff_pair_tune_length_xpm)
void Save(TOOL_SETTINGS &where) const
bool m_MicroViasAllowed
true to allow micro vias
static const TOOL_ACTION ACT_AutoEndRoute("pcbnew.InteractiveRouter.AutoEndRoute", AS_CONTEXT, 'F', _("Auto-end Track"), _("Automagically finishes currently routed track."))
void FlipPosture()
Definition: pns_router.cpp:417
void SetViaDiameter(int aDiameter)
int getStartLayer(const PNS::ITEM *aItem)
static TOOL_ACTION routerActivateDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:198
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:241
OPT< int > PairedLayer(int aLayerId)
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:289
PCB_LAYER_ID SelectLayer(PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask=LSET(), wxPoint aDlgPosition=wxDefaultPosition)
Install the dialog box for layer selection.
Definition: sel_layer.cpp:221
virtual void SetActiveLayer(PCB_LAYER_ID aLayer) override
Function SetActiveLayer will change the currently active layer to aLayer and also update the PCB_LAYE...
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:187
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:796
VIA_ACTION_FLAGS
Flags used by via tool actions.
Definition: router_tool.cpp:68
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:50
BOARD_CONNECTED_ITEM * Parent() const
Function Parent()
Definition: pns_item.h:159
Class LAYER_RANGE.
Definition: pns_layerset.h:32
PCB_LAYER_ID m_Route_Layer_TOP
Definition: pcb_screen.h:45
void UseCustomTrackViaSize(bool aEnabled)
Function UseCustomTrackViaSize Enables/disables custom track/via size settings.
NETCLASSES m_NetClasses
List of current netclasses. There is always the default netclass.
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:465
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
#define STARTPOINT
Definition: base_struct.h:132
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:281
BOARD * board() const
Definition: pcb_tool.h:135
static TOOL_ACTION routerActivateDpDimensionsDialog
Definition: pcb_actions.h:211
virtual void updateStartItem(TOOL_EVENT &aEvent)