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_layer_widget.h>
38 #include <pcb_painter.h>
42 #include <base_units.h>
43 #include <hotkeys.h>
44 #include <confirm.h>
45 #include <bitmaps.h>
46 #include <collectors.h>
47 
48 #include <tool/context_menu.h>
49 #include <tool/tool_manager.h>
50 #include <tool/tool_settings.h>
51 #include <tool/grid_menu.h>
52 
53 #include <tool/zoom_menu.h>
54 #include <tools/pcb_actions.h>
55 #include <tools/size_menu.h>
56 #include <tools/selection_tool.h>
57 #include <tools/edit_tool.h>
58 #include <tools/tool_event_utils.h>
59 
60 #include "router_tool.h"
61 #include "pns_segment.h"
62 #include "pns_router.h"
63 
64 using namespace KIGFX;
65 
70 {
71  // Via type
72  VIA_MASK = 0x03,
73  VIA = 0x00,
74  BLIND_VIA = 0x01,
75  MICROVIA = 0x02,
76 
77  // Select layer
79 };
80 
81 
82 TOOL_ACTION PCB_ACTIONS::routerActivateSingle( "pcbnew.InteractiveRouter.SingleTrack",
84  _( "Interactive Router (Single Tracks)" ),
85  _( "Run push & shove router (single tracks)" ), ps_router_xpm, AF_ACTIVATE );
86 
87 TOOL_ACTION PCB_ACTIONS::routerActivateDiffPair( "pcbnew.InteractiveRouter.DiffPair",
89  _( "Interactive Router (Differential Pairs)" ),
90  _( "Run push & shove router (differential pairs)" ), ps_diff_pair_xpm, AF_ACTIVATE );
91 
92 TOOL_ACTION PCB_ACTIONS::routerActivateSettingsDialog( "pcbnew.InteractiveRouter.SettingsDialog",
93  AS_GLOBAL, 0,
94  _( "Interactive Router Settings..." ),
95  _( "Open Interactive Router settings" ), NULL, AF_ACTIVATE );
96 
97 TOOL_ACTION PCB_ACTIONS::routerActivateDpDimensionsDialog( "pcbnew.InteractiveRouter.DpDimensionsDialog",
98  AS_GLOBAL, 0,
99  _( "Differential Pair Dimension Settings..." ),
100  _( "Open Differential Pair Dimension settings" ), ps_diff_pair_gap_xpm, AF_ACTIVATE );
101 
102 TOOL_ACTION PCB_ACTIONS::routerActivateTuneSingleTrace( "pcbnew.LengthTuner.TuneSingleTrack",
104  _( "Tune length of a single track" ), "", ps_tune_length_xpm, AF_ACTIVATE );
105 
106 TOOL_ACTION PCB_ACTIONS::routerActivateTuneDiffPair( "pcbnew.LengthTuner.TuneDiffPair",
108  _( "Tune length of a differential pair" ), "", NULL, AF_ACTIVATE );
109 
110 TOOL_ACTION PCB_ACTIONS::routerActivateTuneDiffPairSkew( "pcbnew.LengthTuner.TuneDiffPairSkew",
112  _( "Tune skew of a differential pair" ), "", NULL, AF_ACTIVATE );
113 
114 TOOL_ACTION PCB_ACTIONS::routerInlineDrag( "pcbnew.InteractiveRouter.InlineDrag",
115  AS_CONTEXT, 0,
116  _( "Drag Track/Via" ), _( "Drags tracks and vias without breaking connections" ),
117  drag_xpm );
118 
119 TOOL_ACTION PCB_ACTIONS::breakTrack( "pcbnew.InteractiveRouter.BreakTrack",
120  AS_GLOBAL, 0,
121  _( "Break Track" ),
122  _( "Splits the track segment into two segments connected at the cursor position." ),
123  break_line_xpm );
124 
125 TOOL_ACTION PCB_ACTIONS::drag45Degree( "pcbnew.InteractiveRouter.Drag45Degree",
127  _( "Drag (45 degree mode)" ),
128  _( "Drags the track segment while keeping connected tracks at 45 degrees." ),
129  drag_segment_withslope_xpm );
130 
131 TOOL_ACTION PCB_ACTIONS::dragFreeAngle( "pcbnew.InteractiveRouter.DragFreeAngle",
133  _( "Drag (free angle)" ),
134  _( "Drags the nearest joint in the track without restricting the track angle." ),
135  move_xpm );
136 
137 static const TOOL_ACTION ACT_NewTrack( "pcbnew.InteractiveRouter.NewTrack", AS_CONTEXT,
139  _( "New Track" ), _( "Starts laying a new track." ), add_tracks_xpm );
140 
141 static const TOOL_ACTION ACT_EndTrack( "pcbnew.InteractiveRouter.EndTrack", AS_CONTEXT, WXK_END,
142  _( "End Track" ), _( "Stops laying the current track." ), checked_ok_xpm );
143 
144 static const TOOL_ACTION ACT_AutoEndRoute( "pcbnew.InteractiveRouter.AutoEndRoute", AS_CONTEXT, 'F',
145  _( "Auto-end Track" ), _( "Automagically finishes currently routed track." ) );
146 
147 static const TOOL_ACTION ACT_PlaceThroughVia( "pcbnew.InteractiveRouter.PlaceVia",
149  _( "Place Through Via" ),
150  _( "Adds a through-hole via at the end of currently routed track." ),
151  via_xpm, AF_NONE,
152  (void*) VIA_ACTION_FLAGS::VIA );
153 
154 static const TOOL_ACTION ACT_PlaceBlindVia( "pcbnew.InteractiveRouter.PlaceBlindVia",
156  _( "Place Blind/Buried Via" ),
157  _( "Adds a blind or buried via at the end of currently routed track."),
158  via_buried_xpm, AF_NONE,
159  (void*) VIA_ACTION_FLAGS::BLIND_VIA );
160 
161 static const TOOL_ACTION ACT_PlaceMicroVia( "pcbnew.InteractiveRouter.PlaceMicroVia",
163  _( "Place Microvia" ), _( "Adds a microvia at the end of currently routed track." ),
164  via_microvia_xpm, AF_NONE,
165  (void*) VIA_ACTION_FLAGS::MICROVIA );
166 
168  "pcbnew.InteractiveRouter.SelLayerAndPlaceVia",
170  _( "Select Layer and Place Through Via..." ),
171  _( "Select a layer, then add a through-hole via at the end of currently routed track." ),
172  select_w_layer_xpm, AF_NONE,
174 
176  "pcbnew.InteractiveRouter.SelLayerAndPlaceBlindVia",
178  _( "Select Layer and Place Blind/Buried Via..." ),
179  _( "Select a layer, then add a blind or buried via at the end of currently routed track."),
180  select_w_layer_xpm, AF_NONE,
182 
183 static const TOOL_ACTION ACT_CustomTrackWidth( "pcbnew.InteractiveRouter.CustomTrackViaSize",
185  _( "Custom Track/Via Size..." ),
186  _( "Shows a dialog for changing the track width and via size." ),
187  width_track_xpm );
188 
189 static const TOOL_ACTION ACT_SwitchPosture( "pcbnew.InteractiveRouter.SwitchPosture", AS_CONTEXT,
191  _( "Switch Track Posture" ),
192  _( "Switches posture of the currently routed track." ),
193  change_entry_orient_xpm );
194 
195 static const TOOL_ACTION ACT_SetDpDimensions( "pcbnew.InteractiveRouter.SetDpDimensions",
197  _( "Differential Pair Dimensions..." ),
198  _( "Sets the width and gap of the currently routed differential pair." ),
199  ps_diff_pair_tune_length_xpm );
200 
202  TOOL_BASE( "pcbnew.InteractiveRouter" )
203 {
204 }
205 
206 
208 {
209 public:
210  TRACK_WIDTH_MENU( const BOARD* aBoard )
211  : TRACK_VIA_SIZE_MENU( true, true )
212  {
213  SetTitle( _( "Select Track/Via Width" ) );
214  SetBoard( aBoard );
215  }
216 
217  void SetBoard( const BOARD* aBoard )
218  {
219  m_board = aBoard;
220 
221  Clear();
222 
223  Append( ID_POPUP_PCB_SELECT_CUSTOM_WIDTH, _( "Custom Size" ),
224  wxEmptyString, wxITEM_CHECK );
225 
226  Append( ID_POPUP_PCB_SELECT_AUTO_WIDTH, _( "Use Starting Track Width" ),
227  _( "Route using the width of the starting track." ), wxITEM_CHECK );
228 
229  Append( ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES, _( "Use Net Class Values" ),
230  _( "Use track and via sizes from the net class" ), wxITEM_CHECK );
231 
232  AppendSeparator();
233 
234  // Append the list of tracks & via sizes
235  AppendSizes( aBoard );
236  }
237 
238 protected:
239  CONTEXT_MENU* create() const override
240  {
241  return new TRACK_WIDTH_MENU( m_board );
242  }
243 
244  OPT_TOOL_EVENT eventHandler( const wxMenuEvent& aEvent ) override
245  {
246  BOARD_DESIGN_SETTINGS &bds = m_board->GetDesignSettings();
247  int id = aEvent.GetId();
248 
249  // On Windows, this handler can be called with a non existing event ID not existing
250  // in any menuitem.
251  // So we keep trace of in-range/out-of-range event ID
252  bool in_range = true;
253 
254  // Initial settings, to be modified below, but only if the ID exists in this menu
255  bool useConnectedTrackWidth = false;
256  bool useCustomTrackViaSize = false;
257 
259  {
260  useCustomTrackViaSize = true;
261  }
262  else if( id == ID_POPUP_PCB_SELECT_AUTO_WIDTH )
263  {
264  useConnectedTrackWidth = true;
265  }
267  {
268  bds.SetViaSizeIndex( 0 );
269  bds.SetTrackWidthIndex( 0 );
270  }
271  else if( id >= ID_POPUP_PCB_SELECT_VIASIZE1 &&
273  {
274  // via size has changed
276  }
277  else if( id >= ID_POPUP_PCB_SELECT_WIDTH1 &&
279  {
280  // track width has changed
282  }
283  else
284  {
285  in_range = false; // This event ID does not exist in the menu
286  wxASSERT_MSG( false, "OPT_TOOL_EVENT EventHandler: unexpected id" );
287  // Fix me: How to return this error as OPT_TOOL_EVENT?
288  }
289 
290  if( in_range )
291  {
292  // Update this setup only id the event ID matches the options of this menu
293  bds.m_UseConnectedTrackWidth = useConnectedTrackWidth;
294  bds.UseCustomTrackViaSize( useCustomTrackViaSize );
295  }
296 
297  return OPT_TOOL_EVENT( PCB_ACTIONS::trackViaSizeChanged.MakeEvent() );
298  }
299 
300 private:
301  const BOARD* m_board;
302 };
303 
304 
306 {
307 public:
308  ROUTER_TOOL_MENU( const BOARD* aBoard, PCB_EDIT_FRAME& aFrame, PNS::ROUTER_MODE aMode ) :
309  m_board( aBoard ), m_frame( aFrame ), m_mode( aMode ),
310  m_widthMenu( aBoard ), m_zoomMenu( &aFrame ), m_gridMenu( &aFrame )
311  {
312  SetTitle( _( "Interactive Router" ) );
313 
315 
316  AppendSeparator();
317 
318  Add( ACT_NewTrack );
319  Add( ACT_EndTrack );
321 
324 
325 // Add( ACT_AutoEndRoute ); // fixme: not implemented yet. Sorry.
326  Add( ACT_PlaceThroughVia );
327  Add( ACT_PlaceBlindVia );
328  Add( ACT_PlaceMicroVia );
331  Add( ACT_SwitchPosture );
332 
333  AppendSeparator();
334 
335  m_widthMenu.SetBoard( aBoard );
336  Add( &m_widthMenu );
337 
338  Add( ACT_CustomTrackWidth );
339 
340  if( aMode == PNS::PNS_MODE_ROUTE_DIFF_PAIR )
341  Add( ACT_SetDpDimensions );
342 
343  AppendSeparator();
345 
346  AppendSeparator();
347  Add( &m_zoomMenu );
348  Add( &m_gridMenu );
349  }
350 
351 private:
352  CONTEXT_MENU* create() const override
353  {
354  return new ROUTER_TOOL_MENU( m_board, m_frame, m_mode );
355  }
356 
357  const BOARD* m_board;
363 };
364 
365 
367 {
369 }
370 
371 
373 {
375  return true;
376 }
377 
378 
380 {
381  TOOL_BASE::Reset( aReason );
382 }
383 
384 
385 int ROUTER_TOOL::getDefaultWidth( int aNetCode )
386 {
387  int w, d1, d2;
388 
389  getNetclassDimensions( aNetCode, w, d1, d2 );
390 
391  return w;
392 }
393 
394 
395 void ROUTER_TOOL::getNetclassDimensions( int aNetCode, int& aWidth,
396  int& aViaDiameter, int& aViaDrill )
397 {
399 
400  NETCLASSPTR netClass;
401  NETINFO_ITEM* ni = board()->FindNet( aNetCode );
402 
403  if( ni )
404  {
405  wxString netClassName = ni->GetClassName();
406  netClass = bds.m_NetClasses.Find( netClassName );
407  }
408 
409  if( !netClass )
410  netClass = bds.GetDefault();
411 
412  aWidth = netClass->GetTrackWidth();
413  aViaDiameter = netClass->GetViaDiameter();
414  aViaDrill = netClass->GetViaDrill();
415 }
416 
417 
419 {
420 #ifdef DEBUG
421  if( aEvent.IsKeyPressed() )
422  {
423  switch( aEvent.KeyCode() )
424  {
425  case '0':
426  wxLogTrace( "PNS", "saving drag/route log...\n" );
427  m_router->DumpLog();
428  break;
429  }
430  }
431 #endif
432 }
433 
434 
436 {
437  int tl = getView()->GetTopLayer();
438 
439  if( m_startItem )
440  {
441  const LAYER_RANGE& ls = m_startItem->Layers();
442 
443  if( ls.Overlaps( tl ) )
444  return tl;
445  else
446  return ls.Start();
447  }
448 
449  return tl;
450 }
451 
452 
454 {
455  int al = frame()->GetActiveLayer();
456  int cl = m_router->GetCurrentLayer();
457 
458  if( cl != al )
459  {
460  m_router->SwitchLayer( al );
461  }
462 
463  OPT<int> newLayer = m_router->Sizes().PairedLayer( cl );
464 
465  if( !newLayer )
466  newLayer = m_router->Sizes().GetLayerTop();
467 
468  m_router->SwitchLayer( *newLayer );
469  frame()->SetActiveLayer( ToLAYER_ID( *newLayer ) );
470 }
471 
472 
473 static VIATYPE_T getViaTypeFromFlags( int aFlags )
474 {
475  VIATYPE_T viaType = VIA_THROUGH;
476 
477  switch( aFlags & VIA_ACTION_FLAGS::VIA_MASK )
478  {
480  viaType = VIA_THROUGH;
481  break;
483  viaType = VIA_BLIND_BURIED;
484  break;
486  viaType = VIA_MICROVIA;
487  break;
488  default:
489  wxASSERT_MSG( false, "Unhandled via type" );
490  }
491 
492  return viaType;
493 }
494 
495 
497 {
498  const int actViaFlags = aEvent.Parameter<intptr_t>();
499 
500  VIATYPE_T viaType = getViaTypeFromFlags( actViaFlags );
501  const bool selectLayer = actViaFlags & VIA_ACTION_FLAGS::SELECT_LAYER;
502 
504 
505  const int layerCount = bds.GetCopperLayerCount();
506  int currentLayer = m_router->GetCurrentLayer();
509 
511 
512  // ask the user for a target layer
513  PCB_LAYER_ID targetLayer = UNDEFINED_LAYER;
514 
515  if( selectLayer )
516  {
517  wxPoint dlgPosition = wxGetMousePosition();
518 
519  targetLayer = frame()->SelectLayer( static_cast<PCB_LAYER_ID>( currentLayer ),
520  LSET::AllNonCuMask(), dlgPosition );
521  }
522 
523  // fixme: P&S supports more than one fixed layer pair. Update the dialog?
524  sizes.ClearLayerPairs();
525 
526  if( !m_router->IsPlacingVia() )
527  {
528  // Cannot place microvias or blind vias if not allowed (obvious)
529  if( ( viaType == VIA_BLIND_BURIED ) && ( !bds.m_BlindBuriedViaAllowed ) )
530  {
531  DisplayError( frame(), _( "Blind/buried vias have to be enabled in the design settings." ) );
532  return false;
533  }
534 
535  if( ( viaType == VIA_MICROVIA ) && ( !bds.m_MicroViasAllowed ) )
536  {
537  DisplayError( frame(), _( "Microvias have to be enabled in the design settings." ) );
538  return false;
539  }
540 
541  // Can only place through vias on 2-layer boards
542  if( ( viaType != VIA_THROUGH ) && ( layerCount <= 2 ) )
543  {
544  DisplayError( frame(), _( "Only through vias are allowed on 2 layer boards." ) );
545  return false;
546  }
547 
548  // Can only place microvias if we're on an outer layer, or directly adjacent to one
549  if( ( viaType == VIA_MICROVIA ) && ( currentLayer > In1_Cu ) && ( currentLayer < layerCount - 2 ) )
550  {
551  DisplayError( frame(), _( "Microvias can be placed only between the outer layers " \
552  "(F.Cu/B.Cu) and the ones directly adjacent to them." ) );
553  return false;
554  }
555  }
556 
557  // Convert blind/buried via to a through hole one, if it goes through all layers
558  if( viaType == VIA_BLIND_BURIED && ( ( currentLayer == B_Cu ) || ( currentLayer == F_Cu ) )
559  && ( ( pairTop == B_Cu && pairBottom == F_Cu )
560  || ( pairTop == F_Cu && pairBottom == B_Cu ) ) )
561  {
562  viaType = VIA_THROUGH;
563  }
564 
565  switch( viaType )
566  {
567  case VIA_THROUGH:
568  sizes.SetViaDiameter( bds.GetCurrentViaSize() );
569  sizes.SetViaDrill( bds.GetCurrentViaDrill() );
570 
571  if( targetLayer != UNDEFINED_LAYER )
572  {
573  // go from the current layer to the chosen layer
574  sizes.AddLayerPair( currentLayer, targetLayer );
575  }
576  else
577  {
578  // use the default layer pair
579  sizes.AddLayerPair( pairTop, pairBottom );
580  }
581  break;
582 
583  case VIA_MICROVIA:
584  sizes.SetViaDiameter( bds.GetCurrentMicroViaSize() );
585  sizes.SetViaDrill( bds.GetCurrentMicroViaDrill() );
586 
587  wxASSERT_MSG( !selectLayer, "Unexpected select layer for microvia (microvia layers are implicit)" );
588 
589  if( currentLayer == F_Cu || currentLayer == In1_Cu )
590  {
591  // front-side microvia
592  sizes.AddLayerPair( F_Cu, In1_Cu );
593  }
594  else if( currentLayer == B_Cu || currentLayer == layerCount - 2 )
595  {
596  // back-side microvia
597  sizes.AddLayerPair( B_Cu, layerCount - 2 );
598  }
599  else
600  {
601  wxASSERT_MSG( false, "Invalid layer pair for microvia (must be on or adjacent to an outer layer)" );
602  }
603  break;
604 
605  case VIA_BLIND_BURIED:
606  sizes.SetViaDiameter( bds.GetCurrentViaSize() );
607  sizes.SetViaDrill( bds.GetCurrentViaDrill() );
608 
609  if( targetLayer != UNDEFINED_LAYER )
610  {
611  // go directly to the user specified layer
612  sizes.AddLayerPair( currentLayer, targetLayer );
613  }
614  else
615  {
616  if( currentLayer == pairTop || currentLayer == pairBottom )
617  {
618  // the current layer is on the defined layer pair,
619  // swap to the other side
620  sizes.AddLayerPair( pairTop, pairBottom );
621  }
622  else
623  {
624  // the current layer is not part of the current layer pair,
625  // so fallback and swap to the top layer of the pair by default
626  sizes.AddLayerPair( pairTop, currentLayer );
627  }
628  }
629  break;
630 
631  default:
632  wxASSERT( false );
633  break;
634  }
635 
636  sizes.SetViaType( viaType );
637 
638  m_router->UpdateSizes( sizes );
640 
641  updateEndItem( aEvent );
642 
643  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
644 
645  return 0;
646 }
647 
648 
650 {
651  int routingLayer = getStartLayer( m_startItem );
652 
653  if( !IsCopperLayer( routingLayer ) )
654  {
655  DisplayError( frame(), _( "Tracks on Copper layers only" ) );
656  return false;
657  }
658 
659  frame()->SetActiveLayer( ToLAYER_ID( routingLayer ) );
660 
661  // Force layer visible
662  frame()->GetLayerManager()->SetLayerVisible( routingLayer, true );
663 
664  // for some reason I don't understand, GetNetclass() may return null sometimes...
665  if( m_startItem && m_startItem->Net() >= 0 &&
667  {
668  highlightNet( true, m_startItem->Net() );
669  // Update track width and via size shown in main toolbar comboboxes
670  frame()->SetCurrentNetClass( m_startItem->Parent()->GetNetClass()->GetName() );
671  }
672  else
674 
675  controls()->ForceCursorPosition( false );
676  controls()->SetAutoPan( true );
677 
678  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
679 
680  sizes.Init( board(), m_startItem );
681  sizes.AddLayerPair( frame()->GetScreen()->m_Route_Layer_TOP,
682  frame()->GetScreen()->m_Route_Layer_BOTTOM );
683  m_router->UpdateSizes( sizes );
684 
685  if( !m_router->StartRouting( m_startSnapPoint, m_startItem, routingLayer ) )
686  {
688  highlightNet( false );
689  controls()->SetAutoPan( false );
690  return false;
691  }
692 
693  m_endItem = NULL;
695 
696  frame()->UndoRedoBlock( true );
697 
698  return true;
699 }
700 
701 
703 {
705 
706  controls()->SetAutoPan( false );
707  controls()->ForceCursorPosition( false );
708  frame()->UndoRedoBlock( false );
709  highlightNet( false );
710 
711  return true;
712 }
713 
714 
716 {
717  if( !prepareInteractive() )
718  return;
719 
720  while( OPT_TOOL_EVENT evt = Wait() )
721  {
722  // Don't crash if we missed an operation that cancelled routing.
723  wxCHECK2( m_router->RoutingInProgress(), break );
724 
725  if( evt->IsMotion() )
726  {
727  m_router->SetOrthoMode( evt->Modifier( MD_CTRL ) );
728  updateEndItem( *evt );
730  }
731  else if( evt->IsClick( BUT_LEFT ) )
732  {
733  updateEndItem( *evt );
734  bool needLayerSwitch = m_router->IsPlacingVia();
735 
737  break;
738 
739  if( needLayerSwitch )
741 
742  // Synchronize the indicated layer
744  updateEndItem( *evt );
746  m_startItem = NULL;
747  }
748  else if( evt->IsAction( &ACT_SwitchPosture ) )
749  {
751  updateEndItem( *evt );
752  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
753  }
754  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
755  {
756  m_router->SwitchLayer( frame()->GetActiveLayer() );
757  updateEndItem( *evt );
758  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
759  }
760  else if( evt->IsAction( &ACT_EndTrack ) )
761  {
762  bool still_routing = true;
763  while( still_routing )
764  still_routing = m_router->FixRoute( m_endSnapPoint, m_endItem );
765  break;
766  }
767  else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt )
768  || evt->IsUndoRedo()
769  || evt->IsAction( &PCB_ACTIONS::routerInlineDrag ) )
770  break;
771  }
772 
774 }
775 
776 
778 {
779  Activate();
780 
782  DIALOG_PNS_DIFF_PAIR_DIMENSIONS settingsDlg( frame(), sizes );
783 
784  if( settingsDlg.ShowModal() )
785  {
786  m_router->UpdateSizes( sizes );
787  m_savedSizes = sizes;
788  }
789 
790  return 0;
791 }
792 
793 
795 {
796  Activate();
797 
798  DIALOG_PNS_SETTINGS settingsDlg( frame(), m_router->Settings() );
799 
800  if( settingsDlg.ShowModal() )
801  {
803  }
804 
805  return 0;
806 }
807 
808 
810 {
816 
822 
823  // TODO is not this redundant? the same actions can be used for menus and hotkeys
826 
829 }
830 
831 
833 {
834  frame()->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Route Track" ) );
836 }
837 
838 
840 {
841  frame()->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Router Differential Pair" ) );
843 }
844 
845 
847 {
849  {
851  }
852 }
853 
854 
856 {
857  PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
858  BOARD* board = getModel<BOARD>();
859 
860  // Deselect all items
862 
863  Activate();
864 
865  m_router->SetMode( aMode );
866 
867  VIEW_CONTROLS* ctls = getViewControls();
868  ctls->ShowCursor( true );
869  ctls->ForceCursorPosition( false );
871 
872  std::unique_ptr<ROUTER_TOOL_MENU> ctxMenu( new ROUTER_TOOL_MENU( board, *frame, aMode ) );
873  SetContextMenu( ctxMenu.get() );
874 
875  // Main loop: keep receiving events
876  while( OPT_TOOL_EVENT evt = Wait() )
877  {
879  {
880  break; // Finish
881  }
882  else if( evt->Action() == TA_UNDO_REDO_PRE )
883  {
884  m_router->ClearWorld();
885  }
886  else if( evt->Action() == TA_UNDO_REDO_POST || evt->Action() == TA_MODEL_CHANGE )
887  {
888  m_router->SyncWorld();
889  }
890  else if( evt->IsMotion() )
891  {
892  updateStartItem( *evt );
893  }
894  else if( evt->IsAction( &PCB_ACTIONS::dragFreeAngle ) )
895  {
896  updateStartItem( *evt, true );
898  }
899  else if( evt->IsAction( &PCB_ACTIONS::drag45Degree ) )
900  {
901  updateStartItem( *evt, true );
903  }
904  else if( evt->IsAction( &PCB_ACTIONS::breakTrack ) )
905  {
906  updateStartItem( *evt, true );
907  breakTrack( );
908  }
909  else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &ACT_NewTrack ) )
910  {
911  updateStartItem( *evt );
912 
913  if( evt->Modifier( MD_CTRL ) )
915  else
916  performRouting();
917  }
918  else if( evt->IsAction( &ACT_PlaceThroughVia ) )
919  {
921  }
922  }
923 
924  frame->SetNoToolSelected();
925  SetContextMenu( nullptr );
926 
927  // Store routing settings till the next invocation
930 
931  return 0;
932 }
933 
934 
936 {
937  VIEW_CONTROLS* ctls = getViewControls();
938 
939  if( m_startItem && m_startItem->IsLocked() )
940  {
941  if( !IsOK( frame(), _( "The item is locked. Do you want to continue?" ) ) )
942  return;
943  }
944 
945  bool dragStarted = m_router->StartDragging( m_startSnapPoint, m_startItem, aMode );
946 
947  if( !dragStarted )
948  return;
949 
950  if( m_startItem && m_startItem->Net() >= 0 )
951  highlightNet( true, m_startItem->Net() );
952 
953  ctls->SetAutoPan( true );
954 
955  frame()->UndoRedoBlock( true );
956 
957  while( OPT_TOOL_EVENT evt = Wait() )
958  {
959  ctls->ForceCursorPosition( false );
960 
961  if( evt->IsMotion() )
962  {
963  updateEndItem( *evt );
965  }
966  else if( evt->IsClick( BUT_LEFT ) )
967  {
969  break;
970  }
971  else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt )
972  || evt->IsUndoRedo() )
973  break;
974 
975  handleCommonEvents( *evt );
976  }
977 
978  if( m_router->RoutingInProgress() )
980 
981  m_startItem = nullptr;
982 
983  frame()->UndoRedoBlock( false );
984  ctls->SetAutoPan( false );
985  ctls->ForceCursorPosition( false );
986  highlightNet( false );
987 }
988 
989 
991 {
992  /* If the collection contains a trivial line corner (two connected segments)
993  * or a non-fanout-via (a via with no more than two connected segments), then
994  * trim the collection down to a single item (which one won't matter since
995  * they're all connected).
996  */
997 
998  // First make sure we've got something that *might* match.
999  int vias = aCollector.CountType( PCB_VIA_T );
1000  int traces = aCollector.CountType( PCB_TRACE_T );
1001 
1002  if( vias > 1 || traces > 2 || vias + traces < 1 )
1003  return;
1004 
1005  // Fetch first TRACK (via or trace) as our reference
1006  TRACK* reference = nullptr;
1007 
1008  for( int i = 0; !reference && i < aCollector.GetCount(); i++ )
1009  reference = dynamic_cast<TRACK*>( aCollector[i] );
1010 
1011  int refNet = reference->GetNetCode();
1012 
1013  wxPoint refPoint;
1014  STATUS_FLAGS flags = reference->IsPointOnEnds( wxPoint( aPt.x, aPt.y ), -1 );
1015 
1016  if( flags & STARTPOINT )
1017  refPoint = reference->GetStart();
1018  else if( flags & ENDPOINT )
1019  refPoint = reference->GetEnd();
1020  else
1021  return;
1022 
1023  // Check all items to ensure that they are TRACKs which are co-terminus
1024  // with the reference, and on the same net. Ignore markers.
1025  for( int i = 0; i < aCollector.GetCount(); i++ )
1026  {
1027  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( aCollector[i] );
1028 
1029  if( item->Type() == PCB_MARKER_T )
1030  continue;
1031 
1032  TRACK* neighbor = dynamic_cast<TRACK*>( item );
1033 
1034  if( !neighbor || neighbor->GetNetCode() != refNet )
1035  return;
1036 
1037  if( neighbor->GetStart() != refPoint && neighbor->GetEnd() != refPoint )
1038  return;
1039  }
1040 
1041  // Selection meets criteria; trim it to the reference item.
1042  for( int i = aCollector.GetCount() - 1; i >= 0; i-- )
1043  {
1044  if( dynamic_cast<TRACK*>( aCollector[i] ) != reference )
1045  aCollector.Remove( i );
1046  }
1047 }
1048 
1049 
1051 {
1053  const auto& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
1054 
1055  if( selection.Size() == 1 )
1056  {
1057  const BOARD_CONNECTED_ITEM* item = static_cast<const BOARD_CONNECTED_ITEM*>( selection.Front() );
1058 
1059  if( item->Type() == PCB_TRACE_T || item->Type() == PCB_VIA_T )
1060  return true;
1061  }
1062 
1063  return false;
1064 }
1065 
1066 
1068 {
1069  const auto& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
1070 
1071  if( selection.Empty() )
1073 
1074  if( selection.Size() != 1 )
1075  return 0;
1076 
1077  const BOARD_CONNECTED_ITEM* item = static_cast<const BOARD_CONNECTED_ITEM*>( selection.Front() );
1078 
1079  if( item->Type() != PCB_TRACE_T && item->Type() != PCB_VIA_T )
1080  return 0;
1081 
1082  Activate();
1083 
1085  m_router->SyncWorld();
1087 
1088  if( m_startItem && m_startItem->IsLocked() )
1089  {
1090  if( !IsOK( frame(), _( "The item is locked. Do you want to continue?" ) ) )
1091  return false;
1092  }
1093 
1095 
1096  int dragMode = aEvent.Parameter<int64_t> ();
1097 
1098  bool dragStarted = m_router->StartDragging( p0, m_startItem, dragMode );
1099 
1100  if( !dragStarted )
1101  return 0;
1102 
1103  controls()->ShowCursor( true );
1104  controls()->ForceCursorPosition( false );
1105  controls()->SetAutoPan( true );
1106  frame()->UndoRedoBlock( true );
1107 
1108  while( OPT_TOOL_EVENT evt = Wait() )
1109  {
1110  if( evt->IsCancel() )
1111  {
1112  break;
1113  }
1114  else if( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
1115  {
1116  updateEndItem( *evt );
1118  }
1119  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
1120  {
1121  updateEndItem( *evt );
1123  break;
1124  }
1125  }
1126 
1127  if( m_router->RoutingInProgress() )
1128  m_router->StopRouting();
1129 
1130  frame()->UndoRedoBlock( false );
1131 
1132  return 0;
1133 }
1134 
1135 
1137 {
1139  DIALOG_TRACK_VIA_SIZE sizeDlg( frame(), bds );
1140 
1141  if( sizeDlg.ShowModal() )
1142  {
1143  bds.UseCustomTrackViaSize( true );
1145  }
1146 
1147  return 0;
1148 }
1149 
1150 
1152 {
1153  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
1154  sizes.ImportCurrent( board()->GetDesignSettings() );
1155  m_router->UpdateSizes( sizes );
1156 
1157  return 0;
1158 }
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:106
static TOOL_ACTION ACT_RouterOptions
Definition: pns_tool_base.h:47
KICAD_T Type() const
Function Type()
Definition: base_struct.h:209
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:109
virtual int GetTopLayer() const
Definition: view.cpp:794
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:74
bool finishInteractive()
blind/buried via
Definition: router_tool.cpp:75
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:72
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:147
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:69
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:78
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 bool in_range(long x, long lower, long upper)
Definition: json11.cpp:581
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:257
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:135
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:134
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:135
Class TOOL_EVENT.
Definition: tool_event.h:162
PNS::ROUTER_MODE m_mode
ITEM * m_startItem
Definition: pns_tool_base.h:70
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:142
ROUTER * m_router
Definition: pns_tool_base.h:79
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.
PCB_LAYER_WIDGET * GetLayerManager()
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:219
ROUTING_SETTINGS m_savedSettings
Stores routing settings between router invocations.
Definition: pns_tool_base.h:68
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:616
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:75
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
size_t i
Definition: json11.cpp:597
bool StartDragging(const VECTOR2I &aP, ITEM *aItem, int aDragMode=DM_ANY)
Definition: pns_router.cpp:127
#define ENDPOINT
Definition: base_struct.h:115
static void NeighboringSegmentFilter(const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector)
void performDragging(int aMode=PNS::DM_ANY)
virtual void updateStartItem(TOOL_EVENT &aEvent, bool aIgnorePads=false)
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:115
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
void SetLayerVisible(LAYER_NUM aLayer, bool isVisible)
Function SetLayerVisible sets aLayer visible or not.
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:185
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:233
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:69
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:114
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:281
BOARD * board() const
Definition: pcb_tool.h:136
static TOOL_ACTION routerActivateDpDimensionsDialog
Definition: pcb_actions.h:211