KiCad PCB EDA Suite
router_tool.cpp File Reference
#include <wx/hyperlink.h>
#include <advanced_config.h>
#include <functional>
#include <board.h>
#include <board_design_settings.h>
#include <board_item.h>
#include <footprint.h>
#include <fp_shape.h>
#include <pad.h>
#include <zone.h>
#include <pcb_edit_frame.h>
#include <pcbnew_id.h>
#include <dialogs/dialog_pns_settings.h>
#include <dialogs/dialog_pns_diff_pair_dimensions.h>
#include <dialogs/dialog_track_via_size.h>
#include <widgets/infobar.h>
#include <widgets/appearance_controls.h>
#include <connectivity/connectivity_data.h>
#include <connectivity/connectivity_algo.h>
#include <confirm.h>
#include <bitmaps.h>
#include <tool/action_menu.h>
#include <tool/tool_manager.h>
#include <tool/tool_menu.h>
#include <tools/pcb_actions.h>
#include <tools/pcb_selection_tool.h>
#include <tools/pcb_grid_helper.h>
#include "router_tool.h"
#include "pns_segment.h"
#include "pns_router.h"
#include "pns_itemset.h"
#include "pns_logger.h"
#include "pns_kicad_iface.h"
#include <plugins/kicad/pcb_plugin.h>

Go to the source code of this file.

Classes

class  TRACK_WIDTH_MENU
 
class  DIFF_PAIR_MENU
 

Macros

#define _(s)   s
 
#define _(s)   wxGetTranslation((s))
 

Enumerations

enum  VIA_ACTION_FLAGS {
  VIA_MASK = 0x03, VIA = 0x00, BLIND_VIA = 0x01, MICROVIA = 0x02,
  SELECT_LAYER = VIA_MASK + 1
}
 Flags used by via tool actions. More...
 

Functions

static VIATYPE getViaTypeFromFlags (int aFlags)
 
static PCB_LAYER_ID getTargetLayerFromEvent (const TOOL_EVENT &aEvent)
 

Variables

static const TOOL_ACTION ACT_EndTrack ("pcbnew.InteractiveRouter.EndTrack", AS_CONTEXT, WXK_END, "", _("Finish Track"), _("Stops laying the current track."), BITMAPS::checked_ok)
 
static const TOOL_ACTION ACT_AutoEndRoute ("pcbnew.InteractiveRouter.AutoEndRoute", AS_CONTEXT, 'F', "", _("Auto-finish Track"), _("Automatically finishes laying the current track."))
 
static const TOOL_ACTION ACT_PlaceThroughVia ("pcbnew.InteractiveRouter.PlaceVia", AS_CONTEXT, 'V', LEGACY_HK_NAME("Add Through Via"), _("Place Through Via"), _("Adds a through-hole via at the end of currently routed track."), BITMAPS::via, AF_NONE,(void *) VIA_ACTION_FLAGS::VIA)
 
static const TOOL_ACTION ACT_PlaceBlindVia ("pcbnew.InteractiveRouter.PlaceBlindVia", AS_CONTEXT, MD_ALT+MD_SHIFT+ 'V', LEGACY_HK_NAME("Add Blind/Buried Via"), _("Place Blind/Buried Via"), _("Adds a blind or buried via at the end of currently routed track."), BITMAPS::via_buried, AF_NONE,(void *) VIA_ACTION_FLAGS::BLIND_VIA)
 
static const TOOL_ACTION ACT_PlaceMicroVia ("pcbnew.InteractiveRouter.PlaceMicroVia", AS_CONTEXT, MD_CTRL+ 'V', LEGACY_HK_NAME("Add MicroVia"), _("Place Microvia"), _("Adds a microvia at the end of currently routed track."), BITMAPS::via_microvia, AF_NONE,(void *) VIA_ACTION_FLAGS::MICROVIA)
 
static const TOOL_ACTION ACT_SelLayerAndPlaceThroughVia ("pcbnew.InteractiveRouter.SelLayerAndPlaceVia", AS_CONTEXT, '<', LEGACY_HK_NAME("Select 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."), BITMAPS::select_w_layer, AF_NONE,(void *)(VIA_ACTION_FLAGS::VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
 
static const TOOL_ACTION ACT_SelLayerAndPlaceBlindVia ("pcbnew.InteractiveRouter.SelLayerAndPlaceBlindVia", AS_CONTEXT, MD_ALT+'<', LEGACY_HK_NAME("Select 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."), BITMAPS::select_w_layer, AF_NONE,(void *)(VIA_ACTION_FLAGS::BLIND_VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
 
static const TOOL_ACTION ACT_SelLayerAndPlaceMicroVia ("pcbnew.InteractiveRouter.SelLayerAndPlaceMicroVia", AS_CONTEXT, 0, "", _("Select Layer and Place Micro Via..."), _("Select a layer, then add a micro via at the end of currently routed track."), BITMAPS::select_w_layer, AF_NONE,(void *)(VIA_ACTION_FLAGS::MICROVIA|VIA_ACTION_FLAGS::SELECT_LAYER))
 
static const TOOL_ACTION ACT_CustomTrackWidth ("pcbnew.InteractiveRouter.CustomTrackViaSize", AS_CONTEXT, 'Q', LEGACY_HK_NAME("Custom Track/Via Size"), _("Custom Track/Via Size..."), _("Shows a dialog for changing the track width and via size."), BITMAPS::width_track)
 
static const TOOL_ACTION ACT_SwitchPosture ("pcbnew.InteractiveRouter.SwitchPosture", AS_CONTEXT, '/', LEGACY_HK_NAME("Switch Track Posture"), _("Switch Track Posture"), _("Switches posture of the currently routed track."), BITMAPS::change_entry_orient)
 
static const TOOL_ACTION ACT_SwitchCornerMode ("pcbnew.InteractiveRouter.SwitchRounding", AS_CONTEXT, MD_CTRL+'/', "", _("Track Corner Mode"), _("Switches between sharp/rounded and 45°/90° corners when routing tracks."), BITMAPS::switch_corner_rounding_shape)
 

Macro Definition Documentation

◆ _ [1/2]

#define _ (   s)    s

Definition at line 168 of file router_tool.cpp.

◆ _ [2/2]

#define _ (   s)    wxGetTranslation((s))

Definition at line 168 of file router_tool.cpp.

Enumeration Type Documentation

◆ VIA_ACTION_FLAGS

Flags used by via tool actions.

Enumerator
VIA_MASK 
VIA 

Normal via.

BLIND_VIA 

blind/buried via

MICROVIA 

Microvia.

SELECT_LAYER 

Ask user to select layer before adding via.

Definition at line 68 of file router_tool.cpp.

69 {
70  // Via type
71  VIA_MASK = 0x03,
72  VIA = 0x00,
73  BLIND_VIA = 0x01,
74  MICROVIA = 0x02,
75 
76  // Select layer
77  SELECT_LAYER = VIA_MASK + 1,
78 };
blind/buried via
Definition: router_tool.cpp:73
Microvia.
Definition: router_tool.cpp:74
Ask user to select layer before adding via.
Definition: router_tool.cpp:77
Normal via.
Definition: router_tool.cpp:72

Function Documentation

◆ getTargetLayerFromEvent()

static PCB_LAYER_ID getTargetLayerFromEvent ( const TOOL_EVENT aEvent)
static

Definition at line 638 of file router_tool.cpp.

639 {
640  if( aEvent.IsAction( &PCB_ACTIONS::layerTop ) )
641  return F_Cu;
642  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner1 ) )
643  return In1_Cu;
644  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner2 ) )
645  return In2_Cu;
646  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner3 ) )
647  return In3_Cu;
648  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner4 ) )
649  return In4_Cu;
650  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner5 ) )
651  return In5_Cu;
652  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner6 ) )
653  return In6_Cu;
654  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner7 ) )
655  return In7_Cu;
656  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner8 ) )
657  return In8_Cu;
658  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner9 ) )
659  return In9_Cu;
660  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner10 ) )
661  return In10_Cu;
662  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner11 ) )
663  return In11_Cu;
664  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner12 ) )
665  return In12_Cu;
666  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner13 ) )
667  return In13_Cu;
668  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner14 ) )
669  return In14_Cu;
670  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner15 ) )
671  return In15_Cu;
672  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner16 ) )
673  return In16_Cu;
674  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner17 ) )
675  return In17_Cu;
676  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner18 ) )
677  return In18_Cu;
678  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner19 ) )
679  return In19_Cu;
680  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner20 ) )
681  return In20_Cu;
682  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner21 ) )
683  return In21_Cu;
684  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner22 ) )
685  return In22_Cu;
686  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner23 ) )
687  return In23_Cu;
688  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner24 ) )
689  return In24_Cu;
690  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner25 ) )
691  return In25_Cu;
692  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner26 ) )
693  return In26_Cu;
694  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner27 ) )
695  return In27_Cu;
696  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner28 ) )
697  return In28_Cu;
698  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner29 ) )
699  return In29_Cu;
700  else if( aEvent.IsAction( &PCB_ACTIONS::layerInner30 ) )
701  return In30_Cu;
702  else if( aEvent.IsAction( &PCB_ACTIONS::layerBottom ) )
703  return B_Cu;
704  else
705  return UNDEFINED_LAYER;
706 }
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:282
static TOOL_ACTION layerInner26
Definition: pcb_actions.h:277
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:253
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:256
static TOOL_ACTION layerInner6
Definition: pcb_actions.h:257
static TOOL_ACTION layerInner7
Definition: pcb_actions.h:258
static TOOL_ACTION layerInner8
Definition: pcb_actions.h:259
static TOOL_ACTION layerInner21
Definition: pcb_actions.h:272
static TOOL_ACTION layerInner3
Definition: pcb_actions.h:254
static TOOL_ACTION layerInner24
Definition: pcb_actions.h:275
static TOOL_ACTION layerInner11
Definition: pcb_actions.h:262
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:88
static TOOL_ACTION layerTop
Definition: pcb_actions.h:251
static TOOL_ACTION layerInner23
Definition: pcb_actions.h:274
static TOOL_ACTION layerInner13
Definition: pcb_actions.h:264
static TOOL_ACTION layerInner25
Definition: pcb_actions.h:276
static TOOL_ACTION layerInner18
Definition: pcb_actions.h:269
static TOOL_ACTION layerInner30
Definition: pcb_actions.h:281
static TOOL_ACTION layerInner29
Definition: pcb_actions.h:280
static TOOL_ACTION layerInner10
Definition: pcb_actions.h:261
static TOOL_ACTION layerInner15
Definition: pcb_actions.h:266
static TOOL_ACTION layerInner28
Definition: pcb_actions.h:279
static TOOL_ACTION layerInner27
Definition: pcb_actions.h:278
static TOOL_ACTION layerInner17
Definition: pcb_actions.h:268
static TOOL_ACTION layerInner20
Definition: pcb_actions.h:271
static TOOL_ACTION layerInner22
Definition: pcb_actions.h:273
Definition: layer_ids.h:71
static TOOL_ACTION layerInner14
Definition: pcb_actions.h:265
static TOOL_ACTION layerInner9
Definition: pcb_actions.h:260
static TOOL_ACTION layerInner16
Definition: pcb_actions.h:267
static TOOL_ACTION layerInner4
Definition: pcb_actions.h:255
static TOOL_ACTION layerInner19
Definition: pcb_actions.h:270
static TOOL_ACTION layerInner1
Definition: pcb_actions.h:252
static TOOL_ACTION layerInner12
Definition: pcb_actions.h:263

References B_Cu, F_Cu, In10_Cu, In11_Cu, In12_Cu, In13_Cu, In14_Cu, In15_Cu, In16_Cu, In17_Cu, In18_Cu, In19_Cu, In1_Cu, In20_Cu, In21_Cu, In22_Cu, In23_Cu, In24_Cu, In25_Cu, In26_Cu, In27_Cu, In28_Cu, In29_Cu, In2_Cu, In30_Cu, In3_Cu, In4_Cu, In5_Cu, In6_Cu, In7_Cu, In8_Cu, In9_Cu, TOOL_EVENT::IsAction(), PCB_ACTIONS::layerBottom, PCB_ACTIONS::layerInner1, PCB_ACTIONS::layerInner10, PCB_ACTIONS::layerInner11, PCB_ACTIONS::layerInner12, PCB_ACTIONS::layerInner13, PCB_ACTIONS::layerInner14, PCB_ACTIONS::layerInner15, PCB_ACTIONS::layerInner16, PCB_ACTIONS::layerInner17, PCB_ACTIONS::layerInner18, PCB_ACTIONS::layerInner19, PCB_ACTIONS::layerInner2, PCB_ACTIONS::layerInner20, PCB_ACTIONS::layerInner21, PCB_ACTIONS::layerInner22, PCB_ACTIONS::layerInner23, PCB_ACTIONS::layerInner24, PCB_ACTIONS::layerInner25, PCB_ACTIONS::layerInner26, PCB_ACTIONS::layerInner27, PCB_ACTIONS::layerInner28, PCB_ACTIONS::layerInner29, PCB_ACTIONS::layerInner3, PCB_ACTIONS::layerInner30, PCB_ACTIONS::layerInner4, PCB_ACTIONS::layerInner5, PCB_ACTIONS::layerInner6, PCB_ACTIONS::layerInner7, PCB_ACTIONS::layerInner8, PCB_ACTIONS::layerInner9, PCB_ACTIONS::layerTop, and UNDEFINED_LAYER.

Referenced by ROUTER_TOOL::handleLayerSwitch().

◆ getViaTypeFromFlags()

static VIATYPE getViaTypeFromFlags ( int  aFlags)
static

Definition at line 621 of file router_tool.cpp.

622 {
623  switch( aFlags & VIA_ACTION_FLAGS::VIA_MASK )
624  {
626  return VIATYPE::THROUGH;
628  return VIATYPE::BLIND_BURIED;
630  return VIATYPE::MICROVIA;
631  default:
632  wxASSERT_MSG( false, "Unhandled via type" );
633  return VIATYPE::THROUGH;
634  }
635 }
blind/buried via
Definition: router_tool.cpp:73
Microvia.
Definition: router_tool.cpp:74
Normal via.
Definition: router_tool.cpp:72

References BLIND_BURIED, BLIND_VIA, MICROVIA, THROUGH, VIA, and VIA_MASK.

Referenced by ROUTER_TOOL::handleLayerSwitch().

Variable Documentation

◆ ACT_AutoEndRoute

const TOOL_ACTION ACT_AutoEndRoute("pcbnew.InteractiveRouter.AutoEndRoute", AS_CONTEXT, 'F', "", _("Auto-finish Track"), _("Automatically finishes laying the current track."))
static

◆ ACT_CustomTrackWidth

const TOOL_ACTION ACT_CustomTrackWidth("pcbnew.InteractiveRouter.CustomTrackViaSize", AS_CONTEXT, 'Q', LEGACY_HK_NAME("Custom Track/Via Size"), _("Custom Track/Via Size..."), _("Shows a dialog for changing the track width and via size."), BITMAPS::width_track)
static

◆ ACT_EndTrack

const TOOL_ACTION ACT_EndTrack("pcbnew.InteractiveRouter.EndTrack", AS_CONTEXT, WXK_END, "", _("Finish Track"), _("Stops laying the current track."), BITMAPS::checked_ok)
static

◆ ACT_PlaceBlindVia

const TOOL_ACTION ACT_PlaceBlindVia("pcbnew.InteractiveRouter.PlaceBlindVia", AS_CONTEXT, MD_ALT+MD_SHIFT+'V', LEGACY_HK_NAME("Add Blind/Buried Via"), _("Place Blind/Buried Via"), _("Adds a blind or buried via at the end of currently routed track."), BITMAPS::via_buried, AF_NONE,(void *) VIA_ACTION_FLAGS::BLIND_VIA)
static

◆ ACT_PlaceMicroVia

const TOOL_ACTION ACT_PlaceMicroVia("pcbnew.InteractiveRouter.PlaceMicroVia", AS_CONTEXT, MD_CTRL+'V', LEGACY_HK_NAME("Add MicroVia"), _("Place Microvia"), _("Adds a microvia at the end of currently routed track."), BITMAPS::via_microvia, AF_NONE,(void *) VIA_ACTION_FLAGS::MICROVIA)
static

◆ ACT_PlaceThroughVia

const TOOL_ACTION ACT_PlaceThroughVia("pcbnew.InteractiveRouter.PlaceVia", AS_CONTEXT, 'V', LEGACY_HK_NAME("Add Through Via"), _("Place Through Via"), _("Adds a through-hole via at the end of currently routed track."), BITMAPS::via, AF_NONE,(void *) VIA_ACTION_FLAGS::VIA)
static

◆ ACT_SelLayerAndPlaceBlindVia

const TOOL_ACTION ACT_SelLayerAndPlaceBlindVia("pcbnew.InteractiveRouter.SelLayerAndPlaceBlindVia", AS_CONTEXT, MD_ALT+'<', LEGACY_HK_NAME("Select 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."), BITMAPS::select_w_layer, AF_NONE,(void *)(VIA_ACTION_FLAGS::BLIND_VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
static

◆ ACT_SelLayerAndPlaceMicroVia

const TOOL_ACTION ACT_SelLayerAndPlaceMicroVia("pcbnew.InteractiveRouter.SelLayerAndPlaceMicroVia", AS_CONTEXT, 0, "", _("Select Layer and Place Micro Via..."), _("Select a layer, then add a micro via at the end of currently routed track."), BITMAPS::select_w_layer, AF_NONE,(void *)(VIA_ACTION_FLAGS::MICROVIA|VIA_ACTION_FLAGS::SELECT_LAYER))
static

◆ ACT_SelLayerAndPlaceThroughVia

const TOOL_ACTION ACT_SelLayerAndPlaceThroughVia("pcbnew.InteractiveRouter.SelLayerAndPlaceVia", AS_CONTEXT, '<', LEGACY_HK_NAME("Select 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."), BITMAPS::select_w_layer, AF_NONE,(void *)(VIA_ACTION_FLAGS::VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
static

◆ ACT_SwitchCornerMode

const TOOL_ACTION ACT_SwitchCornerMode("pcbnew.InteractiveRouter.SwitchRounding", AS_CONTEXT, MD_CTRL+'/', "", _("Track Corner Mode"), _("Switches between sharp/rounded and 45°/90° corners when routing tracks."), BITMAPS::switch_corner_rounding_shape)
static

◆ ACT_SwitchPosture

const TOOL_ACTION ACT_SwitchPosture("pcbnew.InteractiveRouter.SwitchPosture", AS_CONTEXT, '/', LEGACY_HK_NAME("Switch Track Posture"), _("Switch Track Posture"), _("Switches posture of the currently routed track."), BITMAPS::change_entry_orient)
static