KiCad PCB EDA Suite
ROUTER_TOOL Class Reference

#include <router_tool.h>

Inheritance diagram for ROUTER_TOOL:
PNS::TOOL_BASE PCB_TOOL_BASE TOOL_INTERACTIVE TOOL_BASE

Public Types

enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 Determine the reason of reset for a tool. More...
 

Public Member Functions

 ROUTER_TOOL ()
 
 ~ROUTER_TOOL ()
 
bool Init () override
 Init() is called once upon a registration of the tool. More...
 
void Reset (RESET_REASON aReason) override
 Bring the tool to a known, initial state. More...
 
int MainLoop (const TOOL_EVENT &aEvent)
 
int InlineBreakTrack (const TOOL_EVENT &aEvent)
 
bool CanInlineDrag (int aDragMode)
 
int InlineDrag (const TOOL_EVENT &aEvent)
 
int SelectCopperLayerPair (const TOOL_EVENT &aEvent)
 
int DpDimensionsDialog (const TOOL_EVENT &aEvent)
 
int SettingsDialog (const TOOL_EVENT &aEvent)
 
int ChangeRouterMode (const TOOL_EVENT &aEvent)
 
int CustomTrackWidthDialog (const TOOL_EVENT &aEvent)
 
PNS::PNS_MODE GetRouterMode ()
 
void setTransitions () override
 This method is meant to be overridden in order to specify handlers for events. More...
 
ROUTER * Router () const
 
void SetIsFootprintEditor (bool aEnabled)
 Function SetIsFootprintEditor() More...
 
bool IsFootprintEditor () const
 
void Activate ()
 Run the tool. More...
 
TOOL_MENUGetToolMenu ()
 
void SetContextMenu (ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Assign a context menu and tells when it should be activated. More...
 
void RunMainStack (std::function< void()> aFunc)
 Call a function using the main stack. More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Define which state (aStateFunc) to go when a certain event arrives (aConditions). More...
 
TOOL_EVENTWait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Suspend execution of the tool until an event specified in aEventList arrives. More...
 
TOOL_TYPE GetType () const
 Return the type of the tool. More...
 
TOOL_ID GetId () const
 Return the unique identifier of the tool. More...
 
const std::string & GetName () const
 Return the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Return the instance of TOOL_MANAGER that takes care of the tool. More...
 
bool IsToolActive () const
 

Static Public Member Functions

static void NeighboringSegmentFilter (const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector)
 

Protected Types

enum  INTERACTIVE_PLACEMENT_OPTIONS { IPO_ROTATE = 0x01, IPO_FLIP = 0x02, IPO_SINGLE_CLICK = 0x04, IPO_REPEAT = 0x08 }
 Options for placing items interactively. More...
 

Protected Member Functions

bool checkSnap (ITEM *aItem)
 
const VECTOR2I snapToItem (ITEM *aSnapToItem, VECTOR2I aP)
 
virtual ITEM * pickSingleItem (const VECTOR2I &aWhere, int aNet=-1, int aLayer=-1, bool aIgnorePads=false, const std::vector< ITEM * > aAvoidItems={})
 
virtual void highlightNet (bool aEnabled, int aNetcode=-1)
 
virtual void updateStartItem (const TOOL_EVENT &aEvent, bool aIgnorePads=false)
 
virtual void updateEndItem (const TOOL_EVENT &aEvent)
 
void doInteractiveItemPlacement (const std::string &aTool, INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
 Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc. More...
 
KIGFX::PCB_VIEWview () const
 
KIGFX::VIEW_CONTROLScontrols () const
 
PCB_BASE_EDIT_FRAMEframe () const
 
BOARDboard () const
 
FOOTPRINTfootprint () const
 
const PCB_DISPLAY_OPTIONSdisplayOptions () const
 
PCB_DRAW_PANEL_GALcanvas () const
 
const PCB_SELECTIONselection () const
 
PCB_SELECTIONselection ()
 
void attachManager (TOOL_MANAGER *aManager)
 Set the TOOL_MANAGER the tool will belong to. More...
 
KIGFX::VIEWgetView () const
 Returns the instance of #VIEW object used in the application. More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Return the instance of VIEW_CONTROLS object used in the application. More...
 
template<typename T >
T * getEditFrame () const
 Return the application window object, casted to requested user type. More...
 
template<typename T >
T * getModel () const
 Return the model object if it matches the requested type. More...
 

Protected Attributes

SIZES_SETTINGS m_savedSizes
 
ITEM * m_startItem
 
VECTOR2I m_startSnapPoint
 
bool m_startHighlight
 
ITEM * m_endItem
 
VECTOR2I m_endSnapPoint
 
PCB_GRID_HELPERm_gridHelper
 
PNS_KICAD_IFACEm_iface
 
ROUTER * m_router
 
bool m_cancelled
 
bool m_isFootprintEditor
 
TOOL_MENU m_menu
 The functions below are not yet implemented - their interface may change. More...
 
TOOL_TYPE m_type
 Unique identifier for the tool, assigned by a TOOL_MANAGER instance. More...
 
TOOL_ID m_toolId
 Name of the tool. More...
 
std::string m_toolName
 
TOOL_MANAGERm_toolMgr
 

Private Member Functions

void performRouting ()
 
void performDragging (int aMode=PNS::DM_ANY)
 
void breakTrack ()
 
void handleCommonEvents (TOOL_EVENT &evt)
 
int handleLayerSwitch (const TOOL_EVENT &aEvent, bool aForceVia)
 
int getStartLayer (const PNS::ITEM *aItem)
 
void switchLayerOnViaPlacement ()
 
int onLayerCommand (const TOOL_EVENT &aEvent)
 
int onViaCommand (const TOOL_EVENT &aEvent)
 
int onTrackViaSizeChanged (const TOOL_EVENT &aEvent)
 
bool prepareInteractive ()
 
bool finishInteractive ()
 
void saveRouterDebugLog ()
 

Private Attributes

std::shared_ptr< ACTION_MENUm_diffPairMenu
 
std::shared_ptr< ACTION_MENUm_trackViaMenu
 
int m_lastTargetLayer
 

Detailed Description

Definition at line 28 of file router_tool.h.

Member Enumeration Documentation

◆ INTERACTIVE_PLACEMENT_OPTIONS

Options for placing items interactively.

Enumerator
IPO_ROTATE 

Handle the rotate action in the loop by calling the item's rotate method.

IPO_FLIP 

Handle flip action in the loop by calling the item's flip method.

IPO_SINGLE_CLICK 

Create an item immediately on placement starting, otherwise show the pencil cursor until the item is created.

IPO_REPEAT 

Allow repeat placement of the item.

Definition at line 111 of file pcb_tool_base.h.

111  {
113  IPO_ROTATE = 0x01,
114 
116  IPO_FLIP = 0x02,
117 
120  IPO_SINGLE_CLICK = 0x04,
121 
123  IPO_REPEAT = 0x08
124  };
Handle flip action in the loop by calling the item's flip method.
Allow repeat placement of the item.
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
Handle the rotate action in the loop by calling the item's rotate method.

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

Determine the reason of reset for a tool.

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

Definition at line 78 of file tool_base.h.

79  {
80  RUN,
81  MODEL_RELOAD,
82  GAL_SWITCH
83  };
Model changes (required full reload)
Definition: tool_base.h:81
Tool is invoked after being inactive.
Definition: tool_base.h:80
Rendering engine changes.
Definition: tool_base.h:82

Constructor & Destructor Documentation

◆ ROUTER_TOOL()

ROUTER_TOOL::ROUTER_TOOL ( )

Definition at line 163 of file router_tool.cpp.

163  :
164  TOOL_BASE( "pcbnew.InteractiveRouter" ),
166 {
167 }
TOOL_BASE(const std::string &aToolName)
int m_lastTargetLayer
Definition: router_tool.h:80

◆ ~ROUTER_TOOL()

ROUTER_TOOL::~ROUTER_TOOL ( )

Definition at line 413 of file router_tool.cpp.

414 {
415 }

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Run the tool.

After activation, the tool starts receiving events until it is finished.

Definition at line 51 of file tool_interactive.cpp.

52 {
54 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:210
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.

References TOOL_MANAGER::InvokeTool(), TOOL_BASE::m_toolId, and TOOL_BASE::m_toolMgr.

Referenced by AUTOPLACE_TOOL::autoplace(), EDIT_TOOL::copyToClipboard(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), PAD_TOOL::EnumeratePads(), PCB_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), BOARD_INSPECTION_TOOL::HighlightNetTool(), InlineBreakTrack(), InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), PCB_PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PICKER_TOOL::Main(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), LIB_TREE::onContextMenu(), PCB_POINT_EDITOR::OnSelectionChange(), GROUP_TOOL::PickNewMember(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Set the TOOL_MANAGER the tool will belong to.

Called by TOOL_MANAGER::RegisterTool()

Definition at line 60 of file tool_base.cpp.

61 {
62  m_toolMgr = aManager;
63 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ board()

BOARD* PCB_TOOL_BASE::board ( ) const
inlineprotectedinherited

Definition at line 160 of file pcb_tool_base.h.

160 { return getModel<BOARD>(); }

Referenced by PCB_CONTROL::AppendBoard(), AUTOPLACE_TOOL::autoplace(), BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), EDIT_TOOL::ChangeTrackWidth(), ZONE_FILLER_TOOL::CheckAllZones(), BOARD_INSPECTION_TOOL::ClearHighlight(), EDIT_TOOL::copyToClipboard(), FOOTPRINT_EDITOR_CONTROL::CreateFootprint(), MICROWAVE_TOOL::createInductorBetween(), CustomTrackWidthDialog(), PCB_CONTROL::DeleteItemCursor(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), BOARD_EDITOR_CONTROL::ExportNetlist(), ZONE_FILLER_TOOL::FillAllZones(), EDIT_TOOL::FilletTracks(), PCB_SELECTION_TOOL::filterSelection(), PCB_TOOL_BASE::footprint(), PCB_SELECTION_TOOL::GetBoard(), PCB_SELECTION_TOOL::getCollectorsGuide(), GROUP_TOOL::Group(), handleLayerSwitch(), BOARD_INSPECTION_TOOL::highlightNet(), DRAWING_TOOL::InteractivePlaceWithPreview(), PCB_CONTROL::LayerNext(), PCB_CONTROL::LayerPrev(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), EDIT_TOOL::MoveExact(), FOOTPRINT_EDITOR_CONTROL::NewFootprint(), PCB_CONTROL::Paste(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PAD_TOOL::PlacePad(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PCB_SELECTION_TOOL::RebuildSelection(), PAD_TOOL::recombinePad(), BOARD_EDITOR_CONTROL::RepairBoard(), PNS::TOOL_BASE::Reset(), PCB_CONTROL::Reset(), PCB_SELECTION_TOOL::Selectable(), PCB_SELECTION_TOOL::selectAllItemsOnNet(), PCB_SELECTION_TOOL::selectAllItemsOnSheet(), PCB_SELECTION_TOOL::selectConnectedTracks(), PCB_SELECTION_TOOL::selectionContains(), PCB_SELECTION_TOOL::selectPoint(), PCB_CONTROL::TrackDisplayMode(), GROUP_TOOL::Ungroup(), PCB_CONTROL::ViaDisplayMode(), PCB_CONTROL::ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), BOARD_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

◆ breakTrack()

void ROUTER_TOOL::breakTrack ( )
private

Definition at line 1231 of file router_tool.cpp.

1232 {
1235 }
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
void BreakSegment(ITEM *aItem, const VECTOR2I &aP)
Definition: pns_router.cpp:810
ITEM * m_startItem
Definition: pns_tool_base.h:69
ROUTER * m_router
Definition: pns_tool_base.h:78
bool OfKind(int aKindMask) const
Return true if the item's type matches the mask aKindMask.
Definition: pns_item.h:134

References PNS::ROUTER::BreakSegment(), PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, PNS::ITEM::OfKind(), and PNS::ITEM::SEGMENT_T.

Referenced by InlineBreakTrack(), and MainLoop().

◆ CanInlineDrag()

bool ROUTER_TOOL::CanInlineDrag ( int  aDragMode)

Definition at line 1515 of file router_tool.cpp.

1516 {
1518  const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1519 
1520  if( selection.Size() == 1 )
1521  {
1522  const BOARD_ITEM* item = static_cast<const BOARD_ITEM*>( selection.Front() );
1523 
1524  // Note: EDIT_TOOL::Drag temporarily handles items of type PCB_ARC_T on its own using
1525  // DragArcTrack(), so PCB_ARC_T should never occur here.
1527  {
1528  static const KICAD_T footprints[] = { PCB_FOOTPRINT_T, EOT };
1529 
1530  // Footprints cannot be dragged freely.
1531  if( item->IsType( footprints ) )
1532  return !( aDragMode & PNS::DM_FREE_ANGLE );
1533  else
1534  return true;
1535  }
1536  }
1537 
1538  return false;
1539 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
const PCB_SELECTION & selection() const
virtual bool IsType(const KICAD_T aScanTypes[]) const
Check whether the item is one of the listed types.
Definition: eda_item.h:233
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
static const KICAD_T DraggableItems[]
A scan list for items that can be dragged.
Definition: collectors.h:314
static void NeighboringSegmentFilter(const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector)
int Size() const
Returns the number of selected parts.
Definition: selection.h:128
The selection tool: currently supports:
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:60
EDA_ITEM * Front() const
Definition: selection.h:203

References PNS::DM_FREE_ANGLE, GENERAL_COLLECTOR::DraggableItems, EOT, SELECTION::Front(), TOOL_MANAGER::GetTool(), EDA_ITEM::IsType(), TOOL_BASE::m_toolMgr, NeighboringSegmentFilter(), PCB_FOOTPRINT_T, TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionCursor, and SELECTION::Size().

◆ canvas()

◆ ChangeRouterMode()

int ROUTER_TOOL::ChangeRouterMode ( const TOOL_EVENT aEvent)

Definition at line 1214 of file router_tool.cpp.

1215 {
1216  PNS::PNS_MODE mode = aEvent.Parameter<PNS::PNS_MODE>();
1217  PNS::ROUTING_SETTINGS& settings = m_router->Settings();
1218 
1219  settings.SetMode( mode );
1220 
1221  return 0;
1222 }
Contain all persistent settings of the router, such as the mode, optimization effort,...
void SetMode(PNS_MODE aMode)
Return the optimizer effort. Bigger means cleaner traces, but slower routing.
PNS_MODE
< Routing modes
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:443
ROUTER * m_router
Definition: pns_tool_base.h:78
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:184

References PNS::TOOL_BASE::m_router, TOOL_EVENT::Parameter(), PNS::ROUTING_SETTINGS::SetMode(), and PNS::ROUTER::Settings().

Referenced by setTransitions().

◆ checkSnap()

bool TOOL_BASE::checkSnap ( ITEM aItem)
protectedinherited

Definition at line 235 of file pns_tool_base.cpp.

236 {
237  // Sync PNS engine settings with the general PCB editor options.
238  auto& pnss = m_router->Settings();
239 
240  pnss.SetSnapToPads(
241  frame()->GetMagneticItemsSettings()->pads == MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL ||
242  frame()->GetMagneticItemsSettings()->pads == MAGNETIC_OPTIONS::CAPTURE_ALWAYS );
243 
244  pnss.SetSnapToTracks(
245  frame()->GetMagneticItemsSettings()->tracks == MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL
246  || frame()->GetMagneticItemsSettings()->tracks == MAGNETIC_OPTIONS::CAPTURE_ALWAYS );
247 
248  if( aItem )
249  {
250  if( aItem->OfKind( ITEM::VIA_T | ITEM::SEGMENT_T | ITEM::ARC_T ) )
251  return pnss.GetSnapToTracks();
252  else if( aItem->OfKind( ITEM::SOLID_T ) )
253  return pnss.GetSnapToPads();
254  }
255 
256  return false;
257 }
PCB_BASE_EDIT_FRAME * frame() const
ROUTER * m_router
Definition: pns_tool_base.h:78
void SetSnapToPads(bool aSnap)
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:184

References PNS::ITEM::ARC_T, CAPTURE_ALWAYS, CAPTURE_CURSOR_IN_TRACK_TOOL, PCB_TOOL_BASE::frame(), PNS::TOOL_BASE::m_router, PNS::ITEM::OfKind(), PNS::ITEM::SEGMENT_T, PNS::ROUTING_SETTINGS::SetSnapToPads(), PNS::ROUTER::Settings(), PNS::ITEM::SOLID_T, and PNS::ITEM::VIA_T.

Referenced by PNS::TOOL_BASE::updateEndItem(), and PNS::TOOL_BASE::updateStartItem().

◆ controls()

◆ CustomTrackWidthDialog()

int ROUTER_TOOL::CustomTrackWidthDialog ( const TOOL_EVENT aEvent)

Definition at line 1834 of file router_tool.cpp.

1835 {
1837  DIALOG_TRACK_VIA_SIZE sizeDlg( frame(), bds );
1838 
1839  if( sizeDlg.ShowModal() == wxID_OK )
1840  {
1841  bds.UseCustomTrackViaSize( true );
1842 
1843  TOOL_EVENT dummy;
1845  }
1846 
1847  return 0;
1848 }
BOARD * board() const
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Definition: sch_symbol.cpp:69
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:593
PCB_BASE_EDIT_FRAME * frame() const
Generic, UI-independent tool event.
Definition: tool_event.h:173
int onTrackViaSizeChanged(const TOOL_EVENT &aEvent)
Implementing DIALOG_TRACK_VIA_SIZE_BASE.
void UseCustomTrackViaSize(bool aEnabled)
Enables/disables custom track/via size settings.
Container for design settings for a BOARD object.

References PCB_TOOL_BASE::board(), dummy(), PCB_TOOL_BASE::frame(), BOARD::GetDesignSettings(), onTrackViaSizeChanged(), and BOARD_DESIGN_SETTINGS::UseCustomTrackViaSize().

Referenced by setTransitions().

◆ displayOptions()

const PCB_DISPLAY_OPTIONS & PCB_TOOL_BASE::displayOptions ( ) const
protectedinherited

Definition at line 290 of file pcb_tool_base.cpp.

291 {
292  return frame()->GetDisplayOptions();
293 }
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
PCB_BASE_EDIT_FRAME * frame() const

References PCB_TOOL_BASE::frame(), and PCB_BASE_FRAME::GetDisplayOptions().

Referenced by BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), PCB_CONTROL::HighContrastMode(), PCB_CONTROL::HighContrastModeCycle(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), PNS::TOOL_BASE::pickSingleItem(), PCB_CONTROL::ToggleRatsnest(), PCB_CONTROL::TrackDisplayMode(), PCB_CONTROL::ViaDisplayMode(), and PCB_CONTROL::ZoneDisplayMode().

◆ doInteractiveItemPlacement()

void PCB_TOOL_BASE::doInteractiveItemPlacement ( const std::string &  aTool,
INTERACTIVE_PLACER_BASE aPlacer,
const wxString &  aCommitMessage,
int  aOptions = IPO_ROTATE | IPO_FLIP | IPO_REPEAT 
)
protectedinherited

Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc.

More complex interactive processes are not supported here, you should implement a customised event loop for those.

Parameters
aItemCreatorthe callable that will attempt to create the item
aCommitMessagethe message used on a successful commit

Definition at line 35 of file pcb_tool_base.cpp.

38 {
39  using namespace std::placeholders;
40  std::unique_ptr<BOARD_ITEM> newItem;
41 
42  frame()->PushTool( aTool );
43  Activate();
44 
45  BOARD_COMMIT commit( frame() );
46 
48 
49  // do not capture or auto-pan until we start placing an item
50  controls()->ShowCursor( true );
51 
52  // Add a VIEW_GROUP that serves as a preview for the new item
53  PCB_SELECTION preview;
54  view()->Add( &preview );
55 
56  aPlacer->m_board = board();
57  aPlacer->m_frame = frame();
58  aPlacer->m_modifiers = 0;
59 
60  auto makeNewItem =
61  [&]( VECTOR2I aPosition )
62  {
63  if( frame()->GetModel() )
64  newItem = aPlacer->CreateItem();
65 
66  if( newItem )
67  {
68  newItem->SetPosition( (wxPoint) aPosition );
69  preview.Add( newItem.get() );
70 
71  if( newItem->Type() == PCB_FOOTPRINT_T )
72  {
73  FOOTPRINT* fp = dyn_cast<FOOTPRINT*>( newItem.get() );
74 
75  // footprints have more drawable parts
76  fp->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
77  }
78  }
79  };
80 
81  if( aOptions & IPO_SINGLE_CLICK )
82  makeNewItem( controls()->GetCursorPosition() );
83 
84  auto setCursor =
85  [&]()
86  {
87  if( !newItem )
89  else
91  };
92 
93  // Set initial cursor
94  setCursor();
95 
96  // Main loop: keep receiving events
97  while( TOOL_EVENT* evt = Wait() )
98  {
99  setCursor();
100 
101  VECTOR2I cursorPos = controls()->GetCursorPosition();
102  aPlacer->m_modifiers = evt->Modifier();
103 
104  auto cleanup =
105  [&] ()
106  {
107  newItem = nullptr;
108  preview.Clear();
109  view()->Update( &preview );
110  controls()->SetAutoPan( false );
111  controls()->CaptureCursor( false );
112  controls()->ShowCursor( true );
113  };
114 
115  if( evt->IsCancelInteractive() )
116  {
117  if( aOptions & IPO_SINGLE_CLICK )
118  {
119  cleanup();
120  frame()->PopTool( aTool );
121  break;
122  }
123  else if( newItem )
124  cleanup();
125  else
126  {
127  frame()->PopTool( aTool );
128  break;
129  }
130  }
131  else if( evt->IsActivate() )
132  {
133  if( newItem )
134  cleanup();
135 
136  if( evt->IsPointEditor() )
137  {
138  // don't exit (the point editor runs in the background)
139  }
140  else if( evt->IsMoveTool() )
141  {
142  // leave ourselves on the stack so we come back after the move
143  break;
144  }
145  else
146  {
147  frame()->PopTool( aTool );
148  break;
149  }
150  }
151  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
152  {
153  if( !newItem )
154  {
155  // create the item if possible
156  makeNewItem( cursorPos );
157 
158  // no item created, so wait for another click
159  if( !newItem )
160  continue;
161 
162  controls()->CaptureCursor( true );
163  controls()->SetAutoPan( true );
164  }
165  else
166  {
167  auto oldFlags = newItem->GetFlags();
168  newItem->ClearFlags();
169 
170  if( !aPlacer->PlaceItem( newItem.get(), commit ) )
171  {
172  newItem->SetFlags( oldFlags );
173  continue;
174  }
175 
176  preview.Clear();
177  newItem.release();
178  commit.Push( aCommitMessage );
179 
180  controls()->CaptureCursor( false );
181  controls()->SetAutoPan( false );
182  controls()->ShowCursor( true );
183 
184  if( !( aOptions & IPO_REPEAT ) )
185  break;
186 
187  if( aOptions & IPO_SINGLE_CLICK )
188  makeNewItem( controls()->GetCursorPosition() );
189 
190  setCursor();
191  }
192  }
193  else if( evt->IsClick( BUT_RIGHT ) )
194  {
196  }
197  else if( evt->IsAction( &PCB_ACTIONS::trackViaSizeChanged ) )
198  {
200  }
201  else if( newItem && evt->Category() == TC_COMMAND )
202  {
203  /*
204  * Handle any events that can affect the item as we move it around
205  */
206  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
207  {
208  const int rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
209  newItem->Rotate( newItem->GetPosition(), rotationAngle );
210  view()->Update( &preview );
211  }
212  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
213  {
214  newItem->Flip( newItem->GetPosition(), frame()->Settings().m_FlipLeftRight );
215  view()->Update( &preview );
216  }
217  else if( evt->IsAction( &PCB_ACTIONS::viaSizeInc )
218  || evt->IsAction( &PCB_ACTIONS::viaSizeDec ) )
219  {
220  // Refresh preview after event runs
222  }
223  else if( evt->IsAction( &PCB_ACTIONS::properties ) )
224  {
225  frame()->OnEditItemRequest( newItem.get() );
226 
227  // Notify other tools of the changes
229  }
230  else if( evt->IsAction( &ACTIONS::refreshPreview ) )
231  {
232  preview.Clear();
233  newItem.release();
234 
235  makeNewItem( (wxPoint) cursorPos );
236  aPlacer->SnapItem( newItem.get() );
237  view()->Update( &preview );
238  }
239  else
240  {
241  evt->SetPassEvent();
242  }
243  }
244  else if( newItem && evt->IsMotion() )
245  {
246  // track the cursor
247  newItem->SetPosition( (wxPoint) cursorPos );
248  aPlacer->SnapItem( newItem.get() );
249 
250  // Show a preview of the item
251  view()->Update( &preview );
252  }
253  else
254  {
255  evt->SetPassEvent();
256  }
257  }
258 
259  view()->Remove( &preview );
261 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:63
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
virtual void Clear() override
Remove all the stored items from the group.
Definition: selection.h:96
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
virtual bool PlaceItem(BOARD_ITEM *aItem, BOARD_COMMIT &aCommit)
Handle flip action in the loop by calling the item's flip method.
BOARD * board() const
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:302
virtual std::unique_ptr< BOARD_ITEM > CreateItem()=0
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
virtual void OnEditItemRequest(BOARD_ITEM *aItem)=0
Install the corresponding dialog editor for the given item.
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:121
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:305
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
Definition: pcb_view.cpp:75
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:206
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:77
TOOL_MANAGER * GetManager() const
Return the instance of TOOL_MANAGER that takes care of the tool.
Definition: tool_base.h:144
PCB_BASE_EDIT_FRAME * frame() const
virtual void SnapItem(BOARD_ITEM *aItem)
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: pcb_view.cpp:92
const PCB_SELECTION & selection() const
Allow repeat placement of the item.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
Generic, UI-independent tool event.
Definition: tool_event.h:173
KIGFX::PCB_VIEW * view() const
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
virtual void Add(VIEW_ITEM *aItem)
Add an item to the group.
Definition: view_group.cpp:56
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:109
Handle the rotate action in the loop by calling the item's rotate method.
KIGFX::VIEW_CONTROLS * controls() const
PCBNEW_SETTINGS & Settings()
void Activate()
Run the tool.
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction) const
Invoke a function on all BOARD_ITEMs that belong to the footprint (pads, drawings,...
Definition: footprint.cpp:1175
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
Definition: pcb_view.cpp:58
PCB_BASE_EDIT_FRAME * m_frame
Definition: pcb_tool_base.h:65
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:303
static TOOL_ACTION refreshPreview
Definition: actions.h:109
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.

References TOOL_INTERACTIVE::Activate(), KIGFX::PCB_VIEW::Add(), KIGFX::VIEW_GROUP::Add(), SELECTION::Add(), ARROW, PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_TOOL_BASE::controls(), INTERACTIVE_PLACER_BASE::CreateItem(), PCB_ACTIONS::flip, PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_BASE_FRAME::GetModel(), PCB_TOOL_BASE::IPO_FLIP, PCB_TOOL_BASE::IPO_REPEAT, PCB_TOOL_BASE::IPO_ROTATE, PCB_TOOL_BASE::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, PCBNEW_SETTINGS::m_FlipLeftRight, INTERACTIVE_PLACER_BASE::m_frame, TOOL_INTERACTIVE::m_menu, INTERACTIVE_PLACER_BASE::m_modifiers, TOOL_BASE::m_toolMgr, PCB_BASE_EDIT_FRAME::OnEditItemRequest(), PCB_FOOTPRINT_T, PENCIL, PLACE, INTERACTIVE_PLACER_BASE::PlaceItem(), TOOLS_HOLDER::PopTool(), TOOL_MANAGER::ProcessEvent(), PCB_ACTIONS::properties, BOARD_COMMIT::Push(), TOOLS_HOLDER::PushTool(), ACTIONS::refreshPreview, KIGFX::PCB_VIEW::Remove(), TOOL_MANAGER::RunAction(), FOOTPRINT::RunOnChildren(), EVENTS::SelectedItemsModified, PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), PCB_BASE_FRAME::Settings(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), INTERACTIVE_PLACER_BASE::SnapItem(), TC_COMMAND, PCB_ACTIONS::trackViaSizeChanged, KIGFX::PCB_VIEW::Update(), PCB_ACTIONS::viaSizeDec, PCB_ACTIONS::viaSizeInc, PCB_TOOL_BASE::view(), and TOOL_INTERACTIVE::Wait().

Referenced by MICROWAVE_TOOL::addMicrowaveFootprint(), DRAWING_TOOL::DrawVia(), and PAD_TOOL::PlacePad().

◆ DpDimensionsDialog()

int ROUTER_TOOL::DpDimensionsDialog ( const TOOL_EVENT aEvent)

Definition at line 1184 of file router_tool.cpp.

1185 {
1186  PNS::SIZES_SETTINGS sizes = m_router->Sizes();
1187  DIALOG_PNS_DIFF_PAIR_DIMENSIONS settingsDlg( frame(), sizes );
1188 
1189  if( settingsDlg.ShowModal() == wxID_OK )
1190  {
1191  m_router->UpdateSizes( sizes );
1192  m_savedSizes = sizes;
1193 
1195  bds.SetCustomDiffPairWidth( sizes.DiffPairWidth() );
1196  bds.SetCustomDiffPairGap( sizes.DiffPairGap() );
1197  bds.SetCustomDiffPairViaGap( sizes.DiffPairViaGap() );
1198  }
1199 
1200  return 0;
1201 }
void SetCustomDiffPairViaGap(int aGap)
Sets custom via gap for differential pairs (i.e.
SIZES_SETTINGS m_savedSizes
Definition: pns_tool_base.h:68
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:593
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:203
PCB_BASE_EDIT_FRAME * frame() const
void SetCustomDiffPairWidth(int aWidth)
Sets custom track width for differential pairs (i.e.
ROUTER * m_router
Definition: pns_tool_base.h:78
void SetCustomDiffPairGap(int aGap)
Sets custom gap for differential pairs (i.e.
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:535
BOARD * GetBoard() const
Container for design settings for a BOARD object.

References PNS::SIZES_SETTINGS::DiffPairGap(), PNS::SIZES_SETTINGS::DiffPairViaGap(), PNS::SIZES_SETTINGS::DiffPairWidth(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetBoard(), BOARD::GetDesignSettings(), PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_savedSizes, BOARD_DESIGN_SETTINGS::SetCustomDiffPairGap(), BOARD_DESIGN_SETTINGS::SetCustomDiffPairViaGap(), BOARD_DESIGN_SETTINGS::SetCustomDiffPairWidth(), PNS::ROUTER::Sizes(), and PNS::ROUTER::UpdateSizes().

Referenced by setTransitions().

◆ finishInteractive()

bool ROUTER_TOOL::finishInteractive ( )
private

Definition at line 1050 of file router_tool.cpp.

1051 {
1052  m_router->StopRouting();
1053 
1055  controls()->SetAutoPan( false );
1056  controls()->ForceCursorPosition( false );
1057  frame()->UndoRedoBlock( false );
1058  highlightNet( false );
1059 
1060  return true;
1061 }
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
PCB_BASE_EDIT_FRAME * frame() const
ROUTER * m_router
Definition: pns_tool_base.h:78
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
void StopRouting()
Definition: pns_router.cpp:673
virtual void highlightNet(bool aEnabled, int aNetcode=-1)
KIGFX::VIEW_CONTROLS * controls() const

References ARROW, PCB_TOOL_BASE::controls(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), PNS::TOOL_BASE::highlightNet(), PNS::TOOL_BASE::m_router, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), PNS::ROUTER::StopRouting(), and PCB_BASE_EDIT_FRAME::UndoRedoBlock().

Referenced by performRouting().

◆ footprint()

◆ frame()

PCB_BASE_EDIT_FRAME* PCB_TOOL_BASE::frame ( ) const
inlineprotectedinherited

Definition at line 155 of file pcb_tool_base.h.

156  {
157  return getEditFrame<PCB_BASE_EDIT_FRAME>();
158  }

Referenced by PCB_POINT_EDITOR::addCorner(), AUTOPLACE_TOOL::autoplace(), PCB_TOOL_BASE::canvas(), ZONE_FILLER_TOOL::CheckAllZones(), PNS::TOOL_BASE::checkSnap(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), BOARD_INSPECTION_TOOL::CrossProbePcbToSch(), CustomTrackWidthDialog(), FOOTPRINT_EDITOR_CONTROL::DeleteFootprint(), PCB_TOOL_BASE::displayOptions(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), DpDimensionsDialog(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawVia(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EditPad(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), BOARD_EDITOR_CONTROL::ExportSpecctraDSN(), ZONE_FILLER_TOOL::FillAllZones(), EDIT_TOOL::FilletTracks(), finishInteractive(), EDIT_TOOL::Flip(), PCB_CONTROL::FlipPcbView(), GLOBAL_EDIT_TOOL::GlobalDeletions(), handleLayerSwitch(), BOARD_INSPECTION_TOOL::HighlightItem(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), BOARD_EDITOR_CONTROL::ImportSpecctraSession(), Init(), PCB_SELECTION_TOOL::Init(), EDIT_TOOL::Init(), InlineBreakTrack(), InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), PCB_PICKER_TOOL::Main(), PCB_SELECTION_TOOL::Main(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MoveExact(), PCB_POINT_EDITOR::OnSelectionChange(), PCB_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), performDragging(), performRouting(), LENGTH_TUNER_TOOL::performTuning(), GROUP_TOOL::PickNewMember(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), prepareInteractive(), PAD_TOOL::pushPadSettings(), PAD_TOOL::recombinePad(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), PCB_POINT_EDITOR::removeCorner(), PCB_SELECTION_TOOL::RequestSelection(), PNS::TOOL_BASE::Reset(), SelectCopperLayerPair(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), PCB_POINT_EDITOR::setEditedPoint(), SettingsDialog(), GLOBAL_EDIT_TOOL::swapBoardItem(), GLOBAL_EDIT_TOOL::SwapLayers(), switchLayerOnViaPlacement(), BOARD_EDITOR_CONTROL::UpdateSchematicFromPCB(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillAll().

◆ getEditFrame()

template<typename T >
T* TOOL_BASE::getEditFrame ( ) const
inlineprotectedinherited

Return the application window object, casted to requested user type.

Definition at line 185 of file tool_base.h.

186  {
187 #if !defined( QA_TEST ) // Dynamic casts give the linker a siezure in the test framework
188  wxASSERT( dynamic_cast<T*>( getToolHolderInt() ) );
189 #endif
190  return static_cast<T*>( getToolHolderInt() );
191  }
TOOLS_HOLDER * getToolHolderInt() const
Definition: tool_base.cpp:48

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone().

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

Return the unique identifier of the tool.

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 121 of file tool_base.h.

122  {
123  return m_toolId;
124  }
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:210

References TOOL_BASE::m_toolId.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::isActive(), TOOL_MANAGER::RegisterTool(), ACTION_MANAGER::RunHotKey(), TOOL_MANAGER::runTool(), TOOL_MANAGER::saveViewControls(), and TOOL_MANAGER::ShutdownTool().

◆ GetManager()

TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

Return the instance of TOOL_MANAGER that takes care of the tool.

Returns
Instance of the TOOL_MANAGER or NULL if there is no associated tool manager.

Definition at line 144 of file tool_base.h.

145  {
146  return m_toolMgr;
147  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215

References TOOL_BASE::m_toolMgr.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), ZONE_CREATE_HELPER::commitZone(), ZONE_CREATE_HELPER::createNewZone(), PCB_TOOL_BASE::doInteractiveItemPlacement(), ACTION_MENU::getToolManager(), LIB_TREE::onContextMenu(), ZONE_CREATE_HELPER::OnFirstPoint(), ACTION_MENU::OnMenuEvent(), and ZONE_CREATE_HELPER::performZoneCutout().

◆ getModel()

template<typename T >
T* TOOL_BASE::getModel ( ) const
inlineprotectedinherited

Return the model object if it matches the requested type.

Store the type of the tool.

Definition at line 197 of file tool_base.h.

References TOOL_BASE::getModelInt().

Referenced by ZONE_CREATE_HELPER::commitZone(), and ZONE_CREATE_HELPER::createZoneFromExisting().

◆ GetName()

const std::string& TOOL_BASE::GetName ( void  ) const
inlineinherited

Return the name of the tool.

Tool names are expected to obey the format: application.ToolName (eg. pcbnew.InteractiveSelection).

Returns
The name of the tool.

Definition at line 134 of file tool_base.h.

135  {
136  return m_toolName;
137  }
std::string m_toolName
Definition: tool_base.h:214

References TOOL_BASE::m_toolName.

Referenced by TOOL_MANAGER::dispatchInternal(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::invokeTool(), TOOL_MANAGER::RegisterTool(), and TOOL_MANAGER::runTool().

◆ GetRouterMode()

PNS::PNS_MODE ROUTER_TOOL::GetRouterMode ( )

Definition at line 1225 of file router_tool.cpp.

1226 {
1227  return m_router->Settings().Mode();
1228 }
ROUTER * m_router
Definition: pns_tool_base.h:78
PNS_MODE Mode() const
Set the routing mode.
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:184

References PNS::TOOL_BASE::m_router, PNS::ROUTING_SETTINGS::Mode(), and PNS::ROUTER::Settings().

Referenced by PCB_EDIT_FRAME::setupUIConditions().

◆ getStartLayer()

int ROUTER_TOOL::getStartLayer ( const PNS::ITEM aItem)
private

Definition at line 571 of file router_tool.cpp.

572 {
573  int tl = getView()->GetTopLayer();
574 
575  if( m_startItem )
576  {
577  const LAYER_RANGE& ls = m_startItem->Layers();
578 
579  if( ls.Overlaps( tl ) )
580  return tl;
581  else
582  return ls.Start();
583  }
584 
585  return tl;
586 }
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:67
int Start() const
Definition: pns_layerset.h:82
virtual int GetTopLayer() const
Definition: view.cpp:828
ITEM * m_startItem
Definition: pns_tool_base.h:69
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:31
const LAYER_RANGE & Layers() const
Definition: pns_item.h:150

References KIGFX::VIEW::GetTopLayer(), TOOL_BASE::getView(), PNS::ITEM::Layers(), PNS::TOOL_BASE::m_startItem, LAYER_RANGE::Overlaps(), and LAYER_RANGE::Start().

Referenced by prepareInteractive().

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Return the type of the tool.

Returns
The type of the tool.

Definition at line 109 of file tool_base.h.

110  {
111  return m_type;
112  }
TOOL_TYPE m_type
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:207

References TOOL_BASE::m_type.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InvokeTool(), TOOL_MANAGER::ResetTools(), TOOL_MANAGER::runTool(), and TOOL_MANAGER::ShutdownTool().

◆ getView()

KIGFX::VIEW * TOOL_BASE::getView ( ) const
protectedinherited

Returns the instance of #VIEW object used in the application.

It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 36 of file tool_base.cpp.

37 {
38  return m_toolMgr->GetView();
39 }
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:289
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215

References TOOL_MANAGER::GetView(), and TOOL_BASE::m_toolMgr.

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), COMMON_TOOLS::CenterContents(), SCH_EDIT_TOOL::ChangeTextType(), EE_INSPECTION_TOOL::CheckSymbol(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::CollectHits(), SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint(), COMMON_TOOLS::CursorControl(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), EDIT_TOOL::doMoveSelection(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_EDITOR_CONTROL::FindComponentAndItem(), getStartLayer(), PCB_CONTROL::GridResetOrigin(), PCB_CONTROL::GridSetOrigin(), handleCommonEvents(), PL_SELECTION_TOOL::highlight(), EE_SELECTION_TOOL::highlight(), PCB_SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), PCB_SELECTION_TOOL::hitTestDistance(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), InlineDrag(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), PL_EDIT_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PNS::TOOL_BASE::pickSingleItem(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PL_DRAWING_TOOLS::PlaceItem(), BOARD_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), BOARD_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCB_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), PCB_SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), PCB_SELECTION_TOOL::Selectable(), PCB_SELECTION_TOOL::SelectAll(), EE_SELECTION_TOOL::SelectAll(), PL_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), SCH_DRAWING_TOOLS::TwoClickPlace(), PL_SELECTION_TOOL::unhighlight(), EE_SELECTION_TOOL::unhighlight(), PCB_SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), SCH_EDITOR_CONTROL::UpdateFind(), PL_POINT_EDITOR::updateItem(), PCB_POINT_EDITOR::updateItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updateParentItem(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), PCB_POINT_EDITOR::updatePoints(), PCB_SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCB_VIEWER_TOOLS::view(), PCB_TOOL_BASE::view(), PCB_SELECTION_TOOL::zoomFitSelection(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and PCB_SELECTION_TOOL::~PCB_SELECTION_TOOL().

◆ getViewControls()

KIGFX::VIEW_CONTROLS * TOOL_BASE::getViewControls ( ) const
protectedinherited

Return the instance of VIEW_CONTROLS object used in the application.

It allows tools to read & modify user input and its settings (eg. show cursor, enable snapping to grid, etc.).

Returns
The instance of VIEW_CONTROLS.

Definition at line 42 of file tool_base.cpp.

43 {
44  return m_toolMgr->GetViewControls();
45 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:291

References TOOL_MANAGER::GetViewControls(), and TOOL_BASE::m_toolMgr.

Referenced by EE_POINT_EDITOR::addCorner(), PCB_POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), SCH_EDITOR_CONTROL::AssignNetclass(), SCH_EDIT_TOOL::BreakWire(), PCB_TOOL_BASE::controls(), EDIT_TOOL::copyToClipboard(), SCH_DRAWING_TOOLS::createSheetPin(), COMMON_TOOLS::CursorControl(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), SCH_DRAWING_TOOLS::GetCanvasFreeAreaPixels(), BOARD_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), BOARD_INSPECTION_TOOL::HighlightNetTool(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_EDIT_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), performDragging(), LENGTH_TUNER_TOOL::performTuning(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), PCB_POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), PCB_SELECTION_TOOL::selectCursor(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PCB_PICKER_TOOL::setControls(), PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), PL_POINT_EDITOR::setEditedPoint(), PCB_POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateItem(), PL_EDIT_TOOL::updateModificationPoint(), EDIT_TOOL::updateModificationPoint(), and COMMON_TOOLS::ZoomCenter().

◆ Go()

template<class T >
void TOOL_INTERACTIVE::Go ( int(T::*)(const TOOL_EVENT &)  aStateFunc,
const TOOL_EVENT_LIST aConditions = TOOL_EVENTTC_ANYTA_ANY ) 
)
inherited

Define which state (aStateFunc) to go when a certain event arrives (aConditions).

No conditions means any event.

Definition at line 128 of file tool_interactive.h.

130 {
131  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
132 
133  goInternal( sptr, aConditions );
134 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:59
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)

References TOOL_INTERACTIVE::goInternal().

Referenced by AUTOPLACE_TOOL::setTransitions(), ZOOM_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), BOARD_REANNOTATE_TOOL::setTransitions(), GERBVIEW_INSPECTION_TOOL::setTransitions(), setTransitions(), PCB_PICKER_TOOL::setTransitions(), SCH_NAVIGATE_TOOL::setTransitions(), SYMBOL_EDITOR_PIN_TOOL::setTransitions(), SYMBOL_EDITOR_MOVE_TOOL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), EE_POINT_EDITOR::setTransitions(), PL_POINT_EDITOR::setTransitions(), COMMON_CONTROL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), CONVERT_TOOL::setTransitions(), SYMBOL_EDITOR_DRAWING_TOOLS::setTransitions(), MICROWAVE_TOOL::setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), PAD_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), PCB_POINT_EDITOR::setTransitions(), GERBVIEW_CONTROL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), GROUP_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_EDIT_TOOL::setTransitions(), SYMBOL_EDITOR_CONTROL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), PL_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), FOOTPRINT_EDITOR_CONTROL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), PCB_CONTROL::setTransitions(), EDA_3D_CONTROLLER::setTransitions(), DRC_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), BOARD_EDITOR_CONTROL::setTransitions(), BOARD_INSPECTION_TOOL::setTransitions(), PICKER_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), PCB_SELECTION_TOOL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), DRAWING_TOOL::setTransitions(), and EE_SELECTION_TOOL::setTransitions().

◆ handleCommonEvents()

void ROUTER_TOOL::handleCommonEvents ( TOOL_EVENT evt)
private

Definition at line 545 of file router_tool.cpp.

546 {
547  if( aEvent.Category() == TC_VIEW || aEvent.Category() == TC_MOUSE )
548  {
549  BOX2D viewAreaD = getView()->GetGAL()->GetVisibleWorldExtents();
550  m_router->SetVisibleViewArea( BOX2I( viewAreaD.GetOrigin(), viewAreaD.GetSize() ) );
551  }
552 
553  if( !aEvent.IsKeyPressed() )
554  return;
555 
556  switch( aEvent.KeyCode() )
557  {
558  case '0':
560  return;
561 
563  aEvent.SetPassEvent( false );
564  break;
565  default:
566  break;
567  }
568 }
BOX2< VECTOR2I > BOX2I
Definition: box2.h:522
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:189
bool m_ShowRouterDebugGraphics
Show PNS router debug graphics.
void SetVisibleViewArea(const BOX2I &aExtents)
Definition: pns_router.h:215
ROUTER * m_router
Definition: pns_tool_base.h:78
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
void saveRouterDebugLog()
BOX2D GetVisibleWorldExtents() const
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
const Vec & GetSize() const
Definition: box2.h:189
const Vec & GetOrigin() const
Definition: box2.h:193

References TOOL_EVENT::Category(), ADVANCED_CFG::GetCfg(), KIGFX::VIEW::GetGAL(), BOX2< Vec >::GetOrigin(), BOX2< Vec >::GetSize(), TOOL_BASE::getView(), KIGFX::GAL::GetVisibleWorldExtents(), TOOL_EVENT::IsKeyPressed(), TOOL_EVENT::KeyCode(), PNS::TOOL_BASE::m_router, ADVANCED_CFG::m_ShowRouterDebugGraphics, saveRouterDebugLog(), TOOL_EVENT::SetPassEvent(), PNS::ROUTER::SetVisibleViewArea(), TC_MOUSE, and TC_VIEW.

Referenced by InlineDrag(), performDragging(), and performRouting().

◆ handleLayerSwitch()

int ROUTER_TOOL::handleLayerSwitch ( const TOOL_EVENT aEvent,
bool  aForceVia 
)
private

Definition at line 710 of file router_tool.cpp.

711 {
712  wxCHECK( m_router, 0 );
713 
714  if( !IsToolActive() )
715  return 0;
716 
717  // First see if this is one of the switch layer commands
718  LSEQ layers = LSET( board()->GetEnabledLayers() & LSET::AllCuMask() ).Seq();
720  PCB_LAYER_ID targetLayer = UNDEFINED_LAYER;
721 
722  if( aEvent.IsAction( &PCB_ACTIONS::layerNext ) )
723  {
724  size_t idx = 0;
725 
726  for( size_t i = 0; i < layers.size(); i++ )
727  {
728  if( layers[i] == m_lastTargetLayer )
729  {
730  idx = i;
731  break;
732  }
733  }
734 
735  idx = ( idx + 1 ) % layers.size();
736  targetLayer = layers[idx];
737  }
738  else if( aEvent.IsAction( &PCB_ACTIONS::layerPrev ) )
739  {
740  size_t idx = 0;
741 
742  for( size_t i = 0; i < layers.size(); i++ )
743  {
744  if( layers[i] == m_lastTargetLayer )
745  {
746  idx = i;
747  break;
748  }
749  }
750 
751  idx = ( idx > 0 ) ? ( idx - 1 ) : ( layers.size() - 1 );
752  targetLayer = layers[idx];
753  }
754  else
755  {
756  targetLayer = getTargetLayerFromEvent( aEvent );
757  }
758 
759  if( targetLayer != UNDEFINED_LAYER )
760  {
761  m_lastTargetLayer = targetLayer;
762 
763  if( targetLayer == currentLayer )
764  return 0;
765 
766  if( !aForceVia && m_router && m_router->SwitchLayer( targetLayer ) )
767  {
768  updateEndItem( aEvent );
769  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
770  return 0;
771  }
772  }
773 
775  const int layerCount = bds.GetCopperLayerCount();
776 
779 
781 
782  VIATYPE viaType = VIATYPE::THROUGH;
783  bool selectLayer = false;
784 
785  // Otherwise it is one of the router-specific via commands
786  if( targetLayer == UNDEFINED_LAYER )
787  {
788  const int actViaFlags = aEvent.Parameter<intptr_t>();
789  selectLayer = actViaFlags & VIA_ACTION_FLAGS::SELECT_LAYER;
790 
791  viaType = getViaTypeFromFlags( actViaFlags );
792 
793  // ask the user for a target layer
794  if( selectLayer )
795  {
796  wxPoint endPoint = (wxPoint) view()->ToScreen( m_endSnapPoint );
797  endPoint = frame()->GetCanvas()->ClientToScreen( endPoint );
798 
799  targetLayer = frame()->SelectOneLayer( static_cast<PCB_LAYER_ID>( currentLayer ),
800  LSET::AllNonCuMask(), endPoint );
801 
802  // Reset the cursor to the end of the track
804 
805  if( targetLayer == UNDEFINED_LAYER ) // cancelled by user
806  return 0;
807  }
808  }
809 
810  // fixme: P&S supports more than one fixed layer pair. Update the dialog?
811  sizes.ClearLayerPairs();
812 
813  if( !m_router->IsPlacingVia() )
814  {
815  // Cannot place microvias or blind vias if not allowed (obvious)
816  if( ( viaType == VIATYPE::BLIND_BURIED ) && ( !bds.m_BlindBuriedViaAllowed ) )
817  {
818  WX_INFOBAR* infobar = frame()->GetInfoBar();
819  wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY,
820  _( "Show board setup" ),
821  wxEmptyString );
822 
823  button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
824  [&]( wxHyperlinkEvent& aEvent )
825  {
826  getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog( _( "Constraints" ) );
827  } ) );
828 
829  infobar->RemoveAllButtons();
830  infobar->AddButton( button );
831 
832  infobar->ShowMessageFor( _( "Blind/buried vias must first be enabled in "
833  "Board Setup > Design Rules > Constraints." ),
834  10000, wxICON_ERROR );
835  return false;
836  }
837 
838  if( ( viaType == VIATYPE::MICROVIA ) && ( !bds.m_MicroViasAllowed ) )
839  {
840  WX_INFOBAR* infobar = frame()->GetInfoBar();
841  wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY,
842  _( "Show board setup" ), wxEmptyString );
843 
844  button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
845  [&]( wxHyperlinkEvent& aEvent )
846  {
847  getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog( _( "Constraints" ) );
848  } ) );
849 
850  infobar->RemoveAllButtons();
851  infobar->AddButton( button );
852 
853  infobar->ShowMessageFor( _( "Microvias must first be enabled in "
854  "Board Setup > Design Rules > Constraints." ),
855  10000, wxICON_ERROR );
856  return false;
857  }
858 
859  // Can only place through vias on 2-layer boards
860  if( ( viaType != VIATYPE::THROUGH ) && ( layerCount <= 2 ) )
861  {
862  frame()->ShowInfoBarError( _( "Only through vias are allowed on 2 layer boards." ) );
863  return false;
864  }
865 
866  // Can only place microvias if we're on an outer layer, or directly adjacent to one
867  if( ( viaType == VIATYPE::MICROVIA ) && ( currentLayer > In1_Cu )
868  && ( currentLayer < layerCount - 2 ) )
869  {
870  frame()->ShowInfoBarError( _( "Microvias can only be placed between the outer layers "
871  "(F.Cu/B.Cu) and the ones directly adjacent to them." ) );
872  return false;
873  }
874  }
875 
876  // Convert blind/buried via to a through hole one, if it goes through all layers
877  if( viaType == VIATYPE::BLIND_BURIED
878  && ( ( targetLayer == B_Cu && currentLayer == F_Cu )
879  || ( targetLayer == F_Cu && currentLayer == B_Cu ) ) )
880  {
881  viaType = VIATYPE::THROUGH;
882  }
883 
884  switch( viaType )
885  {
886  case VIATYPE::THROUGH:
887  if( targetLayer == UNDEFINED_LAYER )
888  {
889  // use the default layer pair
890  currentLayer = pairTop;
891  targetLayer = pairBottom;
892  }
893  break;
894 
895  case VIATYPE::MICROVIA:
896  wxASSERT_MSG( !selectLayer, "Unexpected select layer for microvia (microvia layers are "
897  "implicit)" );
898 
899  if( currentLayer == F_Cu || currentLayer == In1_Cu )
900  {
901  // front-side microvia
902  currentLayer = F_Cu;
903  targetLayer = In1_Cu;
904  }
905  else if( currentLayer == B_Cu || currentLayer == layerCount - 2 )
906  {
907  // back-side microvia
908  currentLayer = B_Cu,
909  targetLayer = (PCB_LAYER_ID) ( layerCount - 2 );
910  }
911  else
912  {
913  wxASSERT_MSG( false, "Invalid layer pair for microvia (must be on or adjacent to an "
914  "outer layer)" );
915  }
916  break;
917 
919  if( targetLayer == UNDEFINED_LAYER )
920  {
921  if( currentLayer == pairTop || currentLayer == pairBottom )
922  {
923  // the current layer is on the defined layer pair,
924  // swap to the other side
925  currentLayer = pairTop;
926  targetLayer = pairBottom;
927  }
928  else
929  {
930  // the current layer is not part of the current layer pair,
931  // so fallback and swap to the top layer of the pair by default
932  targetLayer = pairTop;
933  }
934  }
935  break;
936 
937  default:
938  wxASSERT( false );
939  break;
940  }
941 
942  sizes.SetViaDiameter( bds.m_ViasMinSize );
943  sizes.SetViaDrill( bds.m_MinThroughDrill );
944 
945  if( bds.UseNetClassVia() || viaType == VIATYPE::MICROVIA )
946  {
947  class VIA dummyVia( board() );
948  dummyVia.SetViaType( viaType );
949  dummyVia.SetLayerPair( currentLayer, targetLayer );
950 
951  if( !m_router->GetCurrentNets().empty() )
952  dummyVia.SetNetCode( m_router->GetCurrentNets()[0] );
953 
954  DRC_CONSTRAINT constraint;
955 
956  constraint = bds.m_DRCEngine->EvalRules( VIA_DIAMETER_CONSTRAINT, &dummyVia, nullptr,
957  currentLayer );
958 
959  if( !constraint.IsNull() )
960  sizes.SetViaDiameter( constraint.m_Value.Opt() );
961 
962  constraint = bds.m_DRCEngine->EvalRules( HOLE_SIZE_CONSTRAINT, &dummyVia, nullptr,
963  currentLayer );
964 
965  if( !constraint.IsNull() )
966  sizes.SetViaDrill( constraint.m_Value.Opt() );
967  }
968  else
969  {
970  sizes.SetViaDiameter( bds.GetCurrentViaSize() );
971  sizes.SetViaDrill( bds.GetCurrentViaDrill() );
972  }
973 
974  sizes.SetViaType( viaType );
975  sizes.AddLayerPair( currentLayer, targetLayer );
976 
977  m_router->UpdateSizes( sizes );
978 
979  if( !m_router->IsPlacingVia() )
981 
982  m_lastTargetLayer = targetLayer;
983 
984  if( m_router->RoutingInProgress() )
985  updateEndItem( aEvent );
986  else
987  updateStartItem( aEvent );
988 
989  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
990 
991  return 0;
992 }
PCB_LAYER_ID SelectOneLayer(PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask=LSET(), wxPoint aDlgPosition=wxDefaultPosition)
Show the dialog box for a layer selection.
Definition: sel_layer.cpp:225
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:750
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION)
Show the infobar with the provided message and icon for a specific period of time.
Definition: infobar.cpp:118
Definition: track.h:343
void AddButton(wxButton *aButton)
Add an already created button to the infobar.
Definition: infobar.cpp:241
static TOOL_ACTION layerNext
Definition: pcb_actions.h:289
BOARD * board() const
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
Definition: lset.cpp:773
bool IsPlacingVia() const
Definition: pns_router.cpp:763
Ask user to select layer before adding via.
Definition: router_tool.cpp:72
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:735
T Opt() const
Definition: minoptmax.h:35
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:593
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move cursor to the requested position expressed in world coordinates.
void SetViaDrill(int aDrill)
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:203
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:411
void ToggleViaPlacement()
Definition: pns_router.cpp:725
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:70
PCB_BASE_EDIT_FRAME * frame() const
virtual void updateStartItem(const TOOL_EVENT &aEvent, bool aIgnorePads=false)
MINOPTMAX< int > m_Value
Definition: drc_rule.h:142
static VIATYPE getViaTypeFromFlags(int aFlags)
virtual void updateEndItem(const TOOL_EVENT &aEvent)
PCB_LAYER_ID
A quick note on layer IDs:
#define _(s)
LSET is a set of PCB_LAYER_IDs.
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:290
static PCB_LAYER_ID getTargetLayerFromEvent(const TOOL_EVENT &aEvent)
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:443
bool UseNetClassVia() const
Return true if netclass values should be used to obtain appropriate via size.
KIGFX::PCB_VIEW * view() const
ROUTER * m_router
Definition: pns_tool_base.h:78
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:44
bool m_BlindBuriedViaAllowed
true to allow blind/buried vias
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:406
VECTOR2D ToScreen(const VECTOR2D &aCoord, bool aAbsolute=true) const
Convert a world space point/vector to a point/vector in screen space coordinates.
Definition: view.cpp:470
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:282
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
void SetViaType(VIATYPE aViaType)
bool IsNull() const
Definition: drc_rule.h:116
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:71
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:535
KIGFX::VIEW_CONTROLS * controls() const
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
bool IsToolActive() const
Definition: tool_base.cpp:31
bool SwitchLayer(int layer)
Definition: pns_router.cpp:716
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
WX_INFOBAR * GetInfoBar()
void AddLayerPair(int aL1, int aL2)
int m_lastTargetLayer
Definition: router_tool.h:80
bool m_MicroViasAllowed
true to allow micro vias
bool RoutingInProgress() const
Definition: pns_router.cpp:114
VIATYPE
Definition: track.h:68
void SetViaDiameter(int aDiameter)
void SetViaType(VIATYPE aViaType)
Definition: track.h:374
std::shared_ptr< DRC_ENGINE > m_DRCEngine
PCB_LAYER_ID m_Route_Layer_TOP
Definition: pcb_screen.h:43
Container for design settings for a BOARD object.
int GetCurrentLayer() const
Definition: pns_router.cpp:746

References _, WX_INFOBAR::AddButton(), PNS::SIZES_SETTINGS::AddLayerPair(), LSET::AllCuMask(), LSET::AllNonCuMask(), B_Cu, BLIND_BURIED, PCB_TOOL_BASE::board(), PNS::SIZES_SETTINGS::ClearLayerPairs(), PCB_TOOL_BASE::controls(), F_Cu, PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), BOARD_DESIGN_SETTINGS::GetCopperLayerCount(), PNS::ROUTER::GetCurrentLayer(), PNS::ROUTER::GetCurrentNets(), BOARD_DESIGN_SETTINGS::GetCurrentViaDrill(), BOARD_DESIGN_SETTINGS::GetCurrentViaSize(), BOARD::GetDesignSettings(), EDA_BASE_FRAME::GetInfoBar(), PCB_BASE_FRAME::GetScreen(), getTargetLayerFromEvent(), getViaTypeFromFlags(), HOLE_SIZE_CONSTRAINT, In1_Cu, TOOL_EVENT::IsAction(), DRC_CONSTRAINT::IsNull(), PNS::ROUTER::IsPlacingVia(), TOOL_BASE::IsToolActive(), PCB_ACTIONS::layerNext, PCB_ACTIONS::layerPrev, BOARD_DESIGN_SETTINGS::m_BlindBuriedViaAllowed, BOARD_DESIGN_SETTINGS::m_DRCEngine, PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, m_lastTargetLayer, BOARD_DESIGN_SETTINGS::m_MicroViasAllowed, BOARD_DESIGN_SETTINGS::m_MinThroughDrill, PCB_SCREEN::m_Route_Layer_BOTTOM, PCB_SCREEN::m_Route_Layer_TOP, PNS::TOOL_BASE::m_router, DRC_CONSTRAINT::m_Value, BOARD_DESIGN_SETTINGS::m_ViasMinSize, MICROVIA, PNS::ROUTER::Move(), MINOPTMAX< T >::Opt(), TOOL_EVENT::Parameter(), WX_INFOBAR::RemoveAllButtons(), PNS::ROUTER::RoutingInProgress(), SELECT_LAYER, PCB_BASE_FRAME::SelectOneLayer(), LSET::Seq(), KIGFX::VIEW_CONTROLS::SetCursorPosition(), VIA::SetLayerPair(), BOARD_CONNECTED_ITEM::SetNetCode(), PNS::SIZES_SETTINGS::SetViaDiameter(), PNS::SIZES_SETTINGS::SetViaDrill(), PNS::SIZES_SETTINGS::SetViaType(), VIA::SetViaType(), EDA_BASE_FRAME::ShowInfoBarError(), WX_INFOBAR::ShowMessageFor(), PNS::ROUTER::Sizes(), PNS::ROUTER::SwitchLayer(), THROUGH, PNS::ROUTER::ToggleViaPlacement(), KIGFX::VIEW::ToScreen(), UNDEFINED_LAYER, PNS::TOOL_BASE::updateEndItem(), PNS::ROUTER::UpdateSizes(), PNS::TOOL_BASE::updateStartItem(), BOARD_DESIGN_SETTINGS::UseNetClassVia(), VIA_DIAMETER_CONSTRAINT, and PCB_TOOL_BASE::view().

Referenced by onLayerCommand(), and onViaCommand().

◆ highlightNet()

void TOOL_BASE::highlightNet ( bool  aEnabled,
int  aNetcode = -1 
)
protectedvirtualinherited

Definition at line 211 of file pns_tool_base.cpp.

212 {
214 
215  if( aNetcode >= 0 && aEnabled )
216  {
217  // If the user has previously set the current net to be highlighted,
218  // we assume they want to keep it highlighted after routing
220  && rs->GetHighlightNetCodes().count( aNetcode ) );
221 
222  rs->SetHighlight( true, aNetcode );
223  }
224  else
225  {
226  if( !m_startHighlight )
227  rs->SetHighlight( false );
228 
229  m_startHighlight = false;
230  }
231 
233 }
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
bool IsHighlightEnabled() const
Return current highlight setting.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:207
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Turns on/off highlighting.
const std::set< int > & GetHighlightNetCodes() const
Return the netcode of currently highlighted net.
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
Definition: view.cpp:773

References KIGFX::RENDER_SETTINGS::GetHighlightNetCodes(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), TOOL_BASE::getView(), KIGFX::RENDER_SETTINGS::IsHighlightEnabled(), PNS::TOOL_BASE::m_startHighlight, KIGFX::RENDER_SETTINGS::SetHighlight(), and KIGFX::VIEW::UpdateAllLayersColor().

Referenced by finishInteractive(), performDragging(), LENGTH_TUNER_TOOL::performTuning(), and prepareInteractive().

◆ Init()

bool ROUTER_TOOL::Init ( void  )
overridevirtual

Init() is called once upon a registration of the tool.

Returns
True if the initialization went fine, false - otherwise.

Reimplemented from PCB_TOOL_BASE.

Definition at line 418 of file router_tool.cpp.

419 {
421 
422  PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
423 
424  wxASSERT( frame );
425 
426  auto& menu = m_menu.GetMenu();
427  menu.SetTitle( _( "Interactive Router" ) );
428 
429  m_trackViaMenu = std::make_shared<TRACK_WIDTH_MENU>( *frame );
430  m_trackViaMenu->SetTool( this );
432 
433  m_diffPairMenu = std::make_shared<DIFF_PAIR_MENU>( *frame );
434  m_diffPairMenu->SetTool( this );
436 
438 
439  menu.AddSeparator();
440 
446 
449 
450 // Add( ACT_AutoEndRoute ); // fixme: not implemented yet. Sorry.
458 
459  menu.AddSeparator();
460 
461  auto diffPairCond =
462  [this]( const SELECTION& )
463  {
465  };
466 
467  menu.AddMenu( m_trackViaMenu.get(), SELECTION_CONDITIONS::ShowAlways );
468  menu.AddMenu( m_diffPairMenu.get(), diffPairCond );
469 
471 
472  menu.AddSeparator();
473 
475 
476  return true;
477 }
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
void AddStandardSubMenus(TOOL_MENU &aMenu)
Construct a "basic" menu for a tool, containing only items that apply to all tools (e....
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
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_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)
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:142
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:141
static const TOOL_ACTION ACT_EndTrack("pcbnew.InteractiveRouter.EndTrack", AS_CONTEXT, WXK_END, "", _("Finish Track"), _("Stops laying the current track."), BITMAPS::checked_ok)
PCB_BASE_EDIT_FRAME * frame() const
static TOOL_ACTION routerSettingsDialog
Activation of the Push and Shove settings dialogs.
Definition: pcb_actions.h:202
#define _(s)
static const TOOL_ACTION ACT_UndoLastSegment("pcbnew.InteractiveRouter.UndoLastSegment", AS_CONTEXT, WXK_BACK, "", _("Undo last segment"), _("Stops laying the current track."), BITMAPS::checked_ok)
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)
ROUTER * m_router
Definition: pns_tool_base.h:78
static const TOOL_ACTION ACT_SwitchRounding("pcbnew.InteractiveRouter.SwitchRounding", AS_CONTEXT, MD_CTRL+'/', "", _("Track Corner Mode"), _("Switches between sharp and rounded corners when routing tracks."), BITMAPS::switch_corner_rounding_shape)
static TOOL_ACTION breakTrack
Break a single track into two segments at the cursor.
Definition: pcb_actions.h:136
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_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)
void SetTitle(const wxString &aTitle) override
Set title for the menu.
Definition: action_menu.cpp:90
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:185
void AddSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Store a submenu of this menu model.
Definition: tool_menu.cpp:52
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))
The main frame for Pcbnew.
std::shared_ptr< ACTION_MENU > m_trackViaMenu
Definition: router_tool.h:78
int m_lastTargetLayer
Definition: router_tool.h:80
std::shared_ptr< ACTION_MENU > m_diffPairMenu
Definition: router_tool.h:77
ROUTER_MODE Mode() const
Definition: pns_router.h:131
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:188

References _, ACT_EndTrack, ACT_PlaceBlindVia, ACT_PlaceMicroVia, ACT_PlaceThroughVia, ACT_SelLayerAndPlaceBlindVia, ACT_SelLayerAndPlaceThroughVia, ACT_SwitchPosture, ACT_SwitchRounding, ACT_UndoLastSegment, EDA_DRAW_FRAME::AddStandardSubMenus(), TOOL_MENU::AddSubMenu(), PCB_ACTIONS::breakTrack, ACTIONS::cancelInteractive, PCB_ACTIONS::drag45Degree, PCB_ACTIONS::dragFreeAngle, PCB_TOOL_BASE::frame(), TOOL_MENU::GetMenu(), m_diffPairMenu, m_lastTargetLayer, TOOL_INTERACTIVE::m_menu, PNS::TOOL_BASE::m_router, m_trackViaMenu, PNS::ROUTER::Mode(), PNS::PNS_MODE_ROUTE_DIFF_PAIR, PCB_ACTIONS::routeDiffPair, PCB_ACTIONS::routerSettingsDialog, PCB_ACTIONS::routeSingleTrack, ACTION_MENU::SetTitle(), SELECTION_CONDITIONS::ShowAlways(), and UNDEFINED_LAYER.

◆ InlineBreakTrack()

int ROUTER_TOOL::InlineBreakTrack ( const TOOL_EVENT aEvent)

Definition at line 1772 of file router_tool.cpp.

1773 {
1774  const SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1775 
1776  if( selection.Size() != 1 )
1777  return 0;
1778 
1779  const BOARD_CONNECTED_ITEM* item =
1780  static_cast<const BOARD_CONNECTED_ITEM*>( selection.Front() );
1781 
1782  if( item->Type() != PCB_TRACE_T )
1783  return 0;
1784 
1785  Activate();
1786 
1788  m_router->SyncWorld();
1790 
1791  TOOL_MANAGER* toolManager = frame()->GetToolManager();
1792  GAL* gal = toolManager->GetView()->GetGAL();
1793 
1794  m_gridHelper->SetUseGrid( gal->GetGridSnapping() && !aEvent.Modifier( MD_ALT ) );
1795  m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
1796 
1797  if( toolManager->IsContextMenuActive() )
1798  {
1799  // If we're here from a context menu then we need to get the position of the
1800  // cursor when the context menu was invoked. This is used to figure out the
1801  // break point on the track.
1803  }
1804  else
1805  {
1806  // If we're here from a hotkey, then get the current mouse position so we know
1807  // where to break the track.
1808  m_startSnapPoint = snapToItem( m_startItem, controls()->GetCursorPosition() );
1809  }
1810 
1811  if( m_startItem && m_startItem->IsLocked() )
1812  {
1813  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1814  wxOK | wxCANCEL | wxICON_WARNING );
1815  dlg.SetOKLabel( _( "Break Track" ) );
1816  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1817 
1818  if( dlg.ShowModal() == wxID_CANCEL )
1819  return 0;
1820  }
1821 
1822  frame()->UndoRedoBlock( true );
1823  breakTrack();
1824 
1825  if( m_router->RoutingInProgress() )
1826  m_router->StopRouting();
1827 
1828  frame()->UndoRedoBlock( false );
1829 
1830  return 0;
1831 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:63
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:289
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:45
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void SyncWorld()
Definition: pns_router.cpp:93
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:189
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
void breakTrack()
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
PCB_BASE_EDIT_FRAME * frame() const
Master controller class:
Definition: tool_manager.h:52
bool GetGridSnapping() const
PCB_GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
#define _(s)
const PCB_SELECTION & selection() const
ITEM * FindItemByParent(const BOARD_ITEM *aParent)
Definition: pns_node.cpp:1479
ITEM * m_startItem
Definition: pns_tool_base.h:69
bool IsContextMenuActive() const
True while processing a context menu.
Definition: tool_manager.h:417
ROUTER * m_router
Definition: pns_tool_base.h:78
void SetSnap(bool aSnap)
Definition: grid_helper.h:64
void StopRouting()
Definition: pns_router.cpp:673
int Modifier(int aMask=MD_MODIFIER_MASK) const
Definition: tool_event.h:352
const VECTOR2I snapToItem(ITEM *aSnapToItem, VECTOR2I aP)
void SetUseGrid(bool aSnapToGrid)
Definition: grid_helper.h:67
KIGFX::VIEW_CONTROLS * controls() const
int Size() const
Returns the number of selected parts.
Definition: selection.h:128
The selection tool: currently supports:
bool IsLocked() const
Definition: pns_item.h:223
void Activate()
Run the tool.
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
bool RoutingInProgress() const
Definition: pns_router.cpp:114
VECTOR2D GetMenuCursorPos() const
Definition: tool_manager.h:446
NODE * GetWorld() const
Definition: pns_router.h:153
EDA_ITEM * Front() const
Definition: selection.h:203
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:163
Abstract interface for drawing on a 2D-surface.

References _, TOOL_INTERACTIVE::Activate(), breakTrack(), PCB_TOOL_BASE::controls(), KIDIALOG::DoNotShowCheckbox(), PNS::NODE::FindItemByParent(), PCB_TOOL_BASE::frame(), SELECTION::Front(), KIGFX::VIEW::GetGAL(), KIGFX::GAL::GetGridSnapping(), TOOL_MANAGER::GetMenuCursorPos(), TOOL_MANAGER::GetTool(), TOOLS_HOLDER::GetToolManager(), TOOL_MANAGER::GetView(), PNS::ROUTER::GetWorld(), TOOL_MANAGER::IsContextMenuActive(), PNS::ITEM::IsLocked(), PNS::TOOL_BASE::m_gridHelper, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, TOOL_BASE::m_toolMgr, MD_ALT, MD_SHIFT, TOOL_EVENT::Modifier(), PCB_TRACE_T, PNS::ROUTER::RoutingInProgress(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, GRID_HELPER::SetSnap(), GRID_HELPER::SetUseGrid(), KIDIALOG::ShowModal(), SELECTION::Size(), PNS::TOOL_BASE::snapToItem(), PNS::ROUTER::StopRouting(), PNS::ROUTER::SyncWorld(), EDA_ITEM::Type(), and PCB_BASE_EDIT_FRAME::UndoRedoBlock().

Referenced by setTransitions().

◆ InlineDrag()

int ROUTER_TOOL::InlineDrag ( const TOOL_EVENT aEvent)

Definition at line 1542 of file router_tool.cpp.

1543 {
1544  const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1545 
1546  if( selection.Empty() )
1548 
1549  if( selection.Size() != 1 )
1550  return 0;
1551 
1552  const BOARD_ITEM* item = static_cast<const BOARD_ITEM*>( selection.Front() );
1553 
1554  if( item->Type() != PCB_TRACE_T
1555  && item->Type() != PCB_VIA_T
1556  && item->Type() != PCB_FOOTPRINT_T )
1557  {
1558  return 0;
1559  }
1560 
1561  Activate();
1562 
1564  m_router->SyncWorld();
1565  m_startItem = nullptr;
1566 
1567  PNS::ITEM* startItem = nullptr;
1568  PNS::ITEM_SET itemsToDrag;
1569  const FOOTPRINT* footprint = nullptr;
1570 
1571  if( item->Type() == PCB_FOOTPRINT_T )
1572  {
1573  footprint = static_cast<const FOOTPRINT*>(item);
1574 
1575  for( const PAD* pad : footprint->Pads() )
1576  {
1578 
1579  if( solid )
1580  itemsToDrag.Add( solid );
1581  }
1582  }
1583  else
1584  {
1585  startItem = m_router->GetWorld()->FindItemByParent( item );
1586 
1587  if( startItem )
1588  itemsToDrag.Add( startItem );
1589  }
1590 
1591  GAL* gal = m_toolMgr->GetView()->GetGAL();
1592  VECTOR2I p0 = controls()->GetCursorPosition( false );
1593  VECTOR2I p = p0;
1594 
1595  m_gridHelper->SetUseGrid( gal->GetGridSnapping() && !aEvent.Modifier( MD_ALT ) );
1596  m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
1597 
1598  if( startItem )
1599  {
1600  p = snapToItem( startItem, p0 );
1601  m_startItem = startItem;
1602  }
1603  else if( footprint )
1604  {
1605  // The mouse is going to be moved on grid before dragging begins.
1606  VECTOR2I tweakedMousePos;
1607  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1608 
1609  // Check if user wants to warp the mouse to origin of moved object
1610 
1611  if( editFrame->GetMoveWarpsCursor() )
1612  tweakedMousePos = footprint->GetPosition(); // Use footprint anchor to warp mouse
1613  else
1614  tweakedMousePos = controls()->GetCursorPosition(); // Just use current mouse pos
1615 
1616  // We tweak the mouse position using the value from above, and then use that as the
1617  // start position to prevent the footprint from jumping when we start dragging.
1618  // First we move the visual cross hair cursor...
1619  controls()->ForceCursorPosition( true, tweakedMousePos );
1620  controls()->SetCursorPosition( tweakedMousePos ); // ...then the mouse pointer
1621 
1622  // Now that the mouse is in the right position, get a copy of the position to use later
1623  p = controls()->GetCursorPosition();
1624  }
1625 
1626  int dragMode = aEvent.Parameter<int64_t> ();
1627 
1628  bool dragStarted = m_router->StartDragging( p, itemsToDrag, dragMode );
1629 
1630  if( !dragStarted )
1631  return 0;
1632 
1633  m_gridHelper->SetAuxAxes( true, p );
1634  controls()->ShowCursor( true );
1635  controls()->ForceCursorPosition( false );
1636  controls()->SetAutoPan( true );
1637  frame()->UndoRedoBlock( true );
1638 
1639  view()->ClearPreview();
1640  view()->InitPreview();
1641 
1642  auto setCursor =
1643  [&]()
1644  {
1646  };
1647 
1648  // Set initial cursor
1649  setCursor();
1650 
1651  // Set the initial visible area
1652  BOX2D viewAreaD = getView()->GetGAL()->GetVisibleWorldExtents();
1653  m_router->SetVisibleViewArea( BOX2I( viewAreaD.GetOrigin(), viewAreaD.GetSize() ) );
1654 
1655  // Send an initial movement to prime the collision detection
1656  m_router->Move( p, nullptr );
1657 
1658  while( TOOL_EVENT* evt = Wait() )
1659  {
1660  setCursor();
1661 
1662  if( evt->IsCancelInteractive() )
1663  {
1664  break;
1665  }
1666  else if( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
1667  {
1668  updateEndItem( *evt );
1670 
1671  if( footprint )
1672  {
1673  VECTOR2I offset = m_endSnapPoint - p;
1674  BOARD_ITEM* previewItem;
1675 
1676  view()->ClearPreview();
1677 
1678  for( BOARD_ITEM* drawing : footprint->GraphicalItems() )
1679  {
1680  previewItem = static_cast<BOARD_ITEM*>( drawing->Clone() );
1681 
1682  if( drawing->Type() == PCB_FP_SHAPE_T )
1683  {
1684  FP_SHAPE* shape = static_cast<FP_SHAPE*>( previewItem );
1685  wxPoint fp_offset = wxPoint( offset.Rotate( footprint->GetOrientationRadians() ) );
1686  shape->FP_SHAPE::Move( fp_offset );
1687  }
1688  else
1689  {
1690  previewItem->Move( offset );
1691  }
1692 
1693  view()->AddToPreview( previewItem );
1694  view()->Hide( drawing, true );
1695  }
1696 
1697  previewItem = static_cast<BOARD_ITEM*>( footprint->Reference().Clone() );
1698  previewItem->Move( offset );
1699  view()->AddToPreview( previewItem );
1700  view()->Hide( &footprint->Reference() );
1701 
1702  previewItem = static_cast<BOARD_ITEM*>( footprint->Value().Clone() );
1703  previewItem->Move( offset );
1704  view()->AddToPreview( previewItem );
1705  view()->Hide( &footprint->Value() );
1706 
1707  for( ZONE* zone : footprint->Zones() )
1708  {
1709  previewItem = static_cast<BOARD_ITEM*>( zone->Clone() );
1710  previewItem->Move( offset );
1711  view()->AddToPreview( previewItem );
1712  view()->Hide( zone, true );
1713  }
1714  }
1715  }
1716  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
1717  {
1718  updateEndItem( *evt );
1720  break;
1721  }
1722  else if( evt->Category() == TC_COMMAND )
1723  {
1724  // disallow editing commands
1725  if( evt->IsAction( &ACTIONS::cut )
1726  || evt->IsAction( &ACTIONS::copy )
1727  || evt->IsAction( &ACTIONS::paste )
1728  || evt->IsAction( &ACTIONS::pasteSpecial ) )
1729  {
1730  wxBell();
1731  }
1732  else
1733  {
1734  evt->SetPassEvent();
1735  }
1736  }
1737  else
1738  {
1739  evt->SetPassEvent();
1740  }
1741 
1742  handleCommonEvents( *evt );
1743  }
1744 
1745  if( footprint )
1746  {
1747  for( BOARD_ITEM* drawing : footprint->GraphicalItems() )
1748  view()->Hide( drawing, false );
1749 
1750  view()->Hide( &footprint->Reference(), false );
1751  view()->Hide( &footprint->Value(), false );
1752 
1753  for( ZONE* zone : footprint->Zones() )
1754  view()->Hide( zone, false );
1755 
1756  view()->ClearPreview();
1757  view()->ShowPreview( false );
1758  }
1759 
1760  if( m_router->RoutingInProgress() )
1761  m_router->StopRouting();
1762 
1763  m_gridHelper->SetAuxAxes( false );
1764  controls()->SetAutoPan( false );
1765  controls()->ForceCursorPosition( false );
1766  frame()->UndoRedoBlock( false );
1767 
1768  return 0;
1769 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:63
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hide the item in the view (e.g.
Definition: view.cpp:1470
Base class for PNS router board items.
Definition: pns_item.h:55
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: fp_text.cpp:331
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:289
BOX2< VECTOR2I > BOX2I
Definition: box2.h:522
double GetOrientationRadians() const
Definition: footprint.h:188
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1547
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void SyncWorld()
Definition: pns_router.cpp:93
void InitPreview()
Definition: view.cpp:1540
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:189
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move cursor to the requested position expressed in world coordinates.
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
void Add(const LINE &aLine)
Definition: pns_itemset.cpp:32
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
PADS & Pads()
Definition: footprint.h:164
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:462
void ShowPreview(bool aShow=true)
Definition: view.cpp:1561
FP_TEXT & Reference()
Definition: footprint.h:463
PCB_BASE_EDIT_FRAME * frame() const
FP_ZONES & Zones()
Definition: footprint.h:170
static TOOL_ACTION copy
Definition: actions.h:70
virtual void updateEndItem(const TOOL_EVENT &aEvent)
bool GetGridSnapping() const
void SetAuxAxes(bool aEnable, const VECTOR2I &aOrigin=VECTOR2I(0, 0))
Definition: grid_helper.cpp:67
PCB_GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
const PCB_SELECTION & selection() const
ITEM * FindItemByParent(const BOARD_ITEM *aParent)
Definition: pns_node.cpp:1479
virtual void Move(const wxPoint &aMoveVector)
Move this object.
Definition: board_item.h:277
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:443
void handleCommonEvents(TOOL_EVENT &evt)
Generic, UI-independent tool event.
Definition: tool_event.h:173
ITEM * m_startItem
Definition: pns_tool_base.h:69
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:630
FOOTPRINT * footprint() const
void SetVisibleViewArea(const BOX2I &aExtents)
Definition: pns_router.h:215
void ClearPreview()
Definition: view.cpp:1525
static TOOL_ACTION cut
Definition: actions.h:69
KIGFX::PCB_VIEW * view() const
ROUTER * m_router
Definition: pns_tool_base.h:78
DRAWINGS & GraphicalItems()
Definition: footprint.h:167
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:406
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:122
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
void SetSnap(bool aSnap)
Definition: grid_helper.h:64
static TOOL_ACTION pasteSpecial
Definition: actions.h:72
void StopRouting()
Definition: pns_router.cpp:673
int Modifier(int aMask=MD_MODIFIER_MASK) const
Definition: tool_event.h:352
const VECTOR2I snapToItem(ITEM *aSnapToItem, VECTOR2I aP)
VECTOR2< T > Rotate(double aAngle) const
Rotate the vector by a given angle.
Definition: vector2d.h:371
void SetUseGrid(bool aSnapToGrid)
Definition: grid_helper.h:67
KIGFX::VIEW_CONTROLS * controls() const
Common, abstract interface for edit frames.
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
bool StartDragging(const VECTOR2I &aP, ITEM *aItem, int aDragMode=DM_ANY)
Definition: pns_router.cpp:129
static void NeighboringSegmentFilter(const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector)
int Size() const
Returns the number of selected parts.
Definition: selection.h:128
The selection tool: currently supports:
wxPoint GetPosition() const override
Definition: footprint.h:182
BOX2D GetVisibleWorldExtents() const
bool GetMoveWarpsCursor() const
Indicate that a move operation should warp the mouse pointer to the origin of the move object.
Definition: tools_holder.h:140
void Activate()
Run the tool.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
const Vec & GetSize() const
Definition: box2.h:189
const Vec & GetOrigin() const
Definition: box2.h:193
bool RoutingInProgress() const
Definition: pns_router.cpp:114
Definition: pad.h:60
NODE * GetWorld() const
Definition: pns_router.h:153
static TOOL_ACTION paste
Definition: actions.h:71
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:60
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:203
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:163
Abstract interface for drawing on a 2D-surface.

References TOOL_INTERACTIVE::Activate(), PNS::ITEM_SET::Add(), KIGFX::VIEW::AddToPreview(), ARROW, BUT_LEFT, KIGFX::VIEW::ClearPreview(), FP_TEXT::Clone(), PCB_TOOL_BASE::controls(), ACTIONS::copy, ACTIONS::cut, SELECTION::Empty(), PNS::NODE::FindItemByParent(), PNS::ROUTER::FixRoute(), PCB_TOOL_BASE::footprint(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), SELECTION::Front(), PCB_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), KIGFX::VIEW::GetGAL(), KIGFX::GAL::GetGridSnapping(), TOOLS_HOLDER::GetMoveWarpsCursor(), FOOTPRINT::GetOrientationRadians(), BOX2< Vec >::GetOrigin(), FOOTPRINT::GetPosition(), BOX2< Vec >::GetSize(), TOOL_MANAGER::GetTool(), TOOL_BASE::getView(), TOOL_MANAGER::GetView(), KIGFX::GAL::GetVisibleWorldExtents(), PNS::ROUTER::GetWorld(), FOOTPRINT::GraphicalItems(), handleCommonEvents(), KIGFX::VIEW::Hide(), KIGFX::VIEW::InitPreview(), PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_gridHelper, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, TOOL_BASE::m_toolMgr, MD_ALT, MD_SHIFT, TOOL_EVENT::Modifier(), PNS::ROUTER::Move(), BOARD_ITEM::Move(), NeighboringSegmentFilter(), pad, FOOTPRINT::Pads(), TOOL_EVENT::Parameter(), ACTIONS::paste, ACTIONS::pasteSpecial, PCB_FOOTPRINT_T, PCB_FP_SHAPE_T, PCB_TRACE_T, PCB_VIA_T, FOOTPRINT::Reference(), VECTOR2< T >::Rotate(), PNS::ROUTER::RoutingInProgress(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectionCursor, KIGFX::VIEW_CONTROLS::SetAutoPan(), GRID_HELPER::SetAuxAxes(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), KIGFX::VIEW_CONTROLS::SetCursorPosition(), GRID_HELPER::SetSnap(), GRID_HELPER::SetUseGrid(), PNS::ROUTER::SetVisibleViewArea(), KIGFX::VIEW_CONTROLS::ShowCursor(), KIGFX::VIEW::ShowPreview(), SELECTION::Size(), PNS::TOOL_BASE::snapToItem(), PNS::ROUTER::StartDragging(), PNS::ROUTER::StopRouting(), PNS::ROUTER::SyncWorld(), TC_COMMAND, EDA_ITEM::Type(), PCB_BASE_EDIT_FRAME::UndoRedoBlock(), PNS::TOOL_BASE::updateEndItem(), FOOTPRINT::Value(), PCB_TOOL_BASE::view(), TOOL_INTERACTIVE::Wait(), and FOOTPRINT::Zones().

Referenced by setTransitions().

◆ IsFootprintEditor()

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

32 {
33  return m_toolMgr->IsToolActive( m_toolId );
34 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:210
bool IsToolActive(TOOL_ID aId) const
Return true if a tool with given id is active (executing)

References TOOL_MANAGER::IsToolActive(), TOOL_BASE::m_toolId, and TOOL_BASE::m_toolMgr.

Referenced by handleLayerSwitch(), EDIT_TOOL::isRouterActive(), PCB_SELECTION_TOOL::Main(), BOARD_EDITOR_CONTROL::TrackWidthDec(), and BOARD_EDITOR_CONTROL::TrackWidthInc().

◆ MainLoop()

int ROUTER_TOOL::MainLoop ( const TOOL_EVENT aEvent)

Definition at line 1238 of file router_tool.cpp.

1239 {
1240  PNS::ROUTER_MODE mode = aEvent.Parameter<PNS::ROUTER_MODE>();
1241  PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
1242 
1243  if( m_router->RoutingInProgress() )
1244  {
1245  if( m_router->Mode() == mode )
1246  return 0;
1247  else
1248  m_router->StopRouting();
1249  }
1250 
1251  // Deselect all items
1253 
1254  std::string tool = aEvent.GetCommandStr().get();
1255  frame->PushTool( tool );
1256  Activate();
1257 
1258  m_router->SetMode( mode );
1259 
1260  VIEW_CONTROLS* ctls = getViewControls();
1261  ctls->ShowCursor( true );
1262  ctls->ForceCursorPosition( false );
1263  m_cancelled = false;
1264 
1265  // Prime the pump
1266  if( aEvent.HasPosition() )
1267  m_toolMgr->PrimeTool( ctls->GetCursorPosition( false ) );
1268 
1269  auto setCursor =
1270  [&]()
1271  {
1273  };
1274 
1275  // Set initial cursor
1276  setCursor();
1277 
1278  // Main loop: keep receiving events
1279  while( TOOL_EVENT* evt = Wait() )
1280  {
1281  setCursor();
1282 
1283  if( evt->IsCancelInteractive() )
1284  {
1285  frame->PopTool( tool );
1286  break;
1287  }
1288  else if( evt->IsActivate() )
1289  {
1290  if( evt->IsMoveTool() )
1291  {
1292  // leave ourselves on the stack so we come back after the move
1293  break;
1294  }
1295  else
1296  {
1297  frame->PopTool( tool );
1298  break;
1299  }
1300  }
1301  else if( evt->Action() == TA_UNDO_REDO_PRE )
1302  {
1303  m_router->ClearWorld();
1304  }
1305  else if( evt->Action() == TA_UNDO_REDO_POST || evt->Action() == TA_MODEL_CHANGE )
1306  {
1307  m_router->SyncWorld();
1308  }
1309  else if( evt->IsMotion() )
1310  {
1311  updateStartItem( *evt );
1312  }
1313  else if( evt->IsAction( &PCB_ACTIONS::dragFreeAngle ) )
1314  {
1315  updateStartItem( *evt, true );
1317  }
1318  else if( evt->IsAction( &PCB_ACTIONS::drag45Degree ) )
1319  {
1320  updateStartItem( *evt, true );
1322  }
1323  else if( evt->IsAction( &PCB_ACTIONS::breakTrack ) )
1324  {
1325  updateStartItem( *evt, true );
1326  breakTrack( );
1327  }
1328  else if( evt->IsClick( BUT_LEFT )
1329  || evt->IsAction( &PCB_ACTIONS::routeSingleTrack )
1330  || evt->IsAction( &PCB_ACTIONS::routeDiffPair ) )
1331  {
1332  updateStartItem( *evt );
1333 
1334  if( evt->HasPosition() )
1335  {
1336  if( evt->Modifier( MD_CTRL ) )
1338  else
1339  performRouting();
1340  }
1341  }
1342  else if( evt->IsAction( &ACT_PlaceThroughVia ) )
1343  {
1345  }
1346  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1347  {
1349  updateStartItem( *evt );
1350  }
1351  else if( evt->IsKeyPressed() )
1352  {
1353  // wxWidgets fails to correctly translate shifted keycodes on the wxEVT_CHAR_HOOK
1354  // event so we need to process the wxEVT_CHAR event that will follow as long as we
1355  // pass the event.
1356  evt->SetPassEvent();
1357  }
1358  else if( evt->IsClick( BUT_RIGHT ) )
1359  {
1361  }
1362  else
1363  {
1364  evt->SetPassEvent();
1365  }
1366 
1367  if( m_cancelled )
1368  {
1369  frame->PopTool( tool );
1370  break;
1371  }
1372  }
1373 
1374  // Store routing settings till the next invocation
1377 
1378  return 0;
1379 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:63
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void ClearViewDecorations()
Definition: pns_router.cpp:701
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:142
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
SIZES_SETTINGS m_savedSizes
Definition: pns_tool_base.h:68
void SyncWorld()
Definition: pns_router.cpp:93
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
void PrimeTool(const VECTOR2D &aPosition)
"Prime" a tool by sending a cursor left-click event with the mouse position set to the passed in posi...
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:141
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:203
void breakTrack()
void ClearWorld()
Definition: pns_router.cpp:102
PCB_BASE_EDIT_FRAME * frame() const
virtual PCB_LAYER_ID GetActiveLayer() const
virtual void updateStartItem(const TOOL_EVENT &aEvent, bool aIgnorePads=false)
void performRouting()
const PCB_SELECTION & selection() const
virtual void PopTool(const std::string &actionName)
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:443
Generic, UI-independent tool event.
Definition: tool_event.h:173
ROUTER * m_router
Definition: pns_tool_base.h:78
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
static TOOL_ACTION breakTrack
Break a single track into two segments at the cursor.
Definition: pcb_actions.h:136
void StopRouting()
Definition: pns_router.cpp:673
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:471
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)
ROUTER_MODE
Definition: pns_router.h:62
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:295
void SetMode(ROUTER_MODE aMode)
Definition: pns_router.cpp:799
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:185
void performDragging(int aMode=PNS::DM_ANY)
bool SwitchLayer(int layer)
Definition: pns_router.cpp:716
The main frame for Pcbnew.
void Activate()
Run the tool.
bool HasPosition() const
Definition: tool_event.h:261
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
bool RoutingInProgress() const
Definition: pns_router.cpp:114
ROUTER_MODE Mode() const
Definition: pns_router.h:131
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:293
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:188

References ACT_PlaceThroughVia, TOOL_INTERACTIVE::Activate(), breakTrack(), PCB_ACTIONS::breakTrack, BUT_LEFT, BUT_RIGHT, PNS::ROUTER::ClearViewDecorations(), PNS::ROUTER::ClearWorld(), PNS::DM_ANY, PNS::DM_FREE_ANGLE, PCB_ACTIONS::drag45Degree, PCB_ACTIONS::dragFreeAngle, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_BASE::getViewControls(), TOOL_EVENT::HasPosition(), PCB_ACTIONS::layerChanged, PCB_ACTIONS::layerToggle, PNS::TOOL_BASE::m_cancelled, TOOL_INTERACTIVE::m_menu, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_savedSizes, TOOL_BASE::m_toolMgr, MD_CTRL, PNS::ROUTER::Mode(), TOOL_EVENT::Parameter(), PENCIL, performDragging(), performRouting(), TOOLS_HOLDER::PopTool(), TOOL_MANAGER::PrimeTool(), TOOLS_HOLDER::PushTool(), PCB_ACTIONS::routeDiffPair, PCB_ACTIONS::routeSingleTrack, PNS::ROUTER::RoutingInProgress(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, EDA_DRAW_PANEL_GAL::SetCurrentCursor(), PNS::ROUTER::SetMode(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), PNS::ROUTER::Sizes(), PNS::ROUTER::StopRouting(), PNS::ROUTER::SwitchLayer(), PNS::ROUTER::SyncWorld(), TA_MODEL_CHANGE, TA_UNDO_REDO_POST, TA_UNDO_REDO_PRE, PNS::TOOL_BASE::updateStartItem(), and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

◆ NeighboringSegmentFilter()

void ROUTER_TOOL::NeighboringSegmentFilter ( const VECTOR2I aPt,
GENERAL_COLLECTOR aCollector 
)
static

Definition at line 1460 of file router_tool.cpp.

1461 {
1462  /*
1463  * If the collection contains a trivial line corner (two connected segments)
1464  * or a non-fanout-via (a via with no more than two connected segments), then
1465  * trim the collection down to a single item (which one won't matter since
1466  * they're all connected).
1467  */
1468 
1469  // First make sure we've got something that *might* match.
1470  int vias = aCollector.CountType( PCB_VIA_T );
1471  int traces = aCollector.CountType( PCB_TRACE_T );
1472  int arcs = aCollector.CountType( PCB_ARC_T );
1473 
1474  if( arcs > 0 || vias > 1 || traces > 2 || vias + traces < 1 )
1475  return;
1476 
1477  // Fetch first TRACK (via or trace) as our reference
1478  TRACK* reference = nullptr;
1479 
1480  for( int i = 0; !reference && i < aCollector.GetCount(); i++ )
1481  reference = dynamic_cast<TRACK*>( aCollector[i] );
1482 
1483  int refNet = reference->GetNetCode();
1484 
1485  wxPoint refPoint( aPt.x, aPt.y );
1486  STATUS_FLAGS flags = reference->IsPointOnEnds( refPoint, -1 );
1487 
1488  if( flags & STARTPOINT )
1489  refPoint = reference->GetStart();
1490  else if( flags & ENDPOINT )
1491  refPoint = reference->GetEnd();
1492 
1493  // Check all items to ensure that any TRACKs are co-terminus with the reference and on
1494  // the same net.
1495  for( int i = 0; i < aCollector.GetCount(); i++ )
1496  {
1497  TRACK* neighbor = dynamic_cast<TRACK*>( aCollector[i] );
1498 
1499  if( neighbor && neighbor != reference )
1500  {
1501  if( neighbor->GetNetCode() != refNet )
1502  return;
1503 
1504  if( neighbor->GetStart() != refPoint && neighbor->GetEnd() != refPoint )
1505  return;
1506  }
1507  }
1508 
1509  // Selection meets criteria; trim it to the reference item.
1510  aCollector.Empty();
1511  aCollector.Append( reference );
1512 }
void Empty()
Clear the list.
Definition: collector.h:95
const wxPoint & GetStart() const
Definition: track.h:116
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
int CountType(KICAD_T aType)
Count the number of items matching aType.
Definition: collector.h:235
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
void Append(EDA_ITEM *item)
Add an item to the end of the list.
Definition: collector.h:105
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
unsigned STATUS_FLAGS
Definition: eda_item.h:145
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: eda_item.h:112
STATUS_FLAGS IsPointOnEnds(const wxPoint &point, int min_dist=0) const
Function IsPointOnEnds returns STARTPOINT if point if near (dist = min_dist) start point,...
Definition: track.cpp:188
const wxPoint & GetEnd() const
Definition: track.h:113
#define ENDPOINT
ends. (Used to support dragging.)
Definition: eda_item.h:113
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
Definition: track.h:83

References COLLECTOR::Append(), COLLECTOR::CountType(), COLLECTOR::Empty(), ENDPOINT, COLLECTOR::GetCount(), TRACK::GetEnd(), BOARD_CONNECTED_ITEM::GetNetCode(), TRACK::GetStart(), TRACK::IsPointOnEnds(), PCB_ARC_T, PCB_TRACE_T, PCB_VIA_T, STARTPOINT, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by CanInlineDrag(), and InlineDrag().

◆ onLayerCommand()

int ROUTER_TOOL::onLayerCommand ( const TOOL_EVENT aEvent)
private

Definition at line 698 of file router_tool.cpp.

699 {
700  return handleLayerSwitch( aEvent, false );
701 }
int handleLayerSwitch(const TOOL_EVENT &aEvent, bool aForceVia)

References handleLayerSwitch().

Referenced by setTransitions().

◆ onTrackViaSizeChanged()

int ROUTER_TOOL::onTrackViaSizeChanged ( const TOOL_EVENT aEvent)
private

Definition at line 1851 of file router_tool.cpp.

1852 {
1853  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
1854 
1855  if( !m_router->GetCurrentNets().empty() )
1856  m_iface->ImportSizes( sizes, nullptr, m_router->GetCurrentNets()[0] );
1857 
1858  m_router->UpdateSizes( sizes );
1859 
1860  // Changing the track width can affect the placement, so call the
1861  // move routine without changing the destination
1863 
1864  return 0;
1865 }
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:735
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:203
ROUTER * m_router
Definition: pns_tool_base.h:78
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:406
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:535
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
bool ImportSizes(PNS::SIZES_SETTINGS &aSizes, PNS::ITEM *aStartItem, int aNet) override
PNS_KICAD_IFACE * m_iface
Definition: pns_tool_base.h:77

References PNS::ROUTER::GetCurrentNets(), PNS_KICAD_IFACE_BASE::ImportSizes(), PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_iface, PNS::TOOL_BASE::m_router, PNS::ROUTER::Move(), PNS::ROUTER::Sizes(), and PNS::ROUTER::UpdateSizes().

Referenced by CustomTrackWidthDialog(), and setTransitions().

◆ onViaCommand()

int ROUTER_TOOL::onViaCommand ( const TOOL_EVENT aEvent)
private

Definition at line 704 of file router_tool.cpp.

705 {
706  return handleLayerSwitch( aEvent, true );
707 }
int handleLayerSwitch(const TOOL_EVENT &aEvent, bool aForceVia)

References handleLayerSwitch().

Referenced by setTransitions().

◆ performDragging()

void ROUTER_TOOL::performDragging ( int  aMode = PNS::DM_ANY)
private

Definition at line 1382 of file router_tool.cpp.

1383 {
1385 
1386  VIEW_CONTROLS* ctls = getViewControls();
1387 
1388  if( m_startItem && m_startItem->IsLocked() )
1389  {
1390  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1391  wxOK | wxCANCEL | wxICON_WARNING );
1392  dlg.SetOKLabel( _( "Drag Anyway" ) );
1393  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1394 
1395  if( dlg.ShowModal() == wxID_CANCEL )
1396  return;
1397  }
1398 
1399  bool dragStarted = m_router->StartDragging( m_startSnapPoint, m_startItem, aMode );
1400 
1401  if( !dragStarted )
1402  return;
1403 
1404  if( m_startItem && m_startItem->Net() > 0 )
1405  highlightNet( true, m_startItem->Net() );
1406 
1407  ctls->SetAutoPan( true );
1409  frame()->UndoRedoBlock( true );
1410 
1411  while( TOOL_EVENT* evt = Wait() )
1412  {
1413  ctls->ForceCursorPosition( false );
1414 
1415  if( evt->IsMotion() )
1416  {
1417  updateEndItem( *evt );
1419  }
1420  else if( evt->IsClick( BUT_LEFT ) )
1421  {
1423  break;
1424  }
1425  else if( evt->IsClick( BUT_RIGHT ) )
1426  {
1428  }
1429  else if( evt->IsCancelInteractive() || evt->IsActivate() || evt->IsUndoRedo() )
1430  {
1431  if( evt->IsCancelInteractive() && !m_startItem )
1432  m_cancelled = true;
1433 
1434  if( evt->IsActivate() && !evt->IsMoveTool() )
1435  m_cancelled = true;
1436 
1437  break;
1438  }
1439  else
1440  {
1441  evt->SetPassEvent();
1442  }
1443 
1444  handleCommonEvents( *evt );
1445  }
1446 
1447  if( m_router->RoutingInProgress() )
1448  m_router->StopRouting();
1449 
1450  m_startItem = nullptr;
1451 
1452  m_gridHelper->SetAuxAxes( false );
1453  frame()->UndoRedoBlock( false );
1454  ctls->SetAutoPan( false );
1455  ctls->ForceCursorPosition( false );
1456  highlightNet( false );
1457 }
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:45
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
void ClearViewDecorations()
Definition: pns_router.cpp:701
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
PCB_BASE_EDIT_FRAME * frame() const
virtual void updateEndItem(const TOOL_EVENT &aEvent)
void SetAuxAxes(bool aEnable, const VECTOR2I &aOrigin=VECTOR2I(0, 0))
Definition: grid_helper.cpp:67
PCB_GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
#define _(s)
const PCB_SELECTION & selection() const
int Net() const
Definition: pns_item.h:148
void handleCommonEvents(TOOL_EVENT &evt)
Generic, UI-independent tool event.
Definition: tool_event.h:173
ITEM * m_startItem
Definition: pns_tool_base.h:69
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:630
ROUTER * m_router
Definition: pns_tool_base.h:78
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:406
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
void StopRouting()
Definition: pns_router.cpp:673
virtual void highlightNet(bool aEnabled, int aNetcode=-1)
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
bool StartDragging(const VECTOR2I &aP, ITEM *aItem, int aDragMode=DM_ANY)
Definition: pns_router.cpp:129
bool IsLocked() const
Definition: pns_item.h:223
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
bool RoutingInProgress() const
Definition: pns_router.cpp:114
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59

References _, BUT_LEFT, BUT_RIGHT, PNS::ROUTER::ClearViewDecorations(), KIDIALOG::DoNotShowCheckbox(), PNS::ROUTER::FixRoute(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), TOOL_BASE::getViewControls(), handleCommonEvents(), PNS::TOOL_BASE::highlightNet(), PNS::ITEM::IsLocked(), PNS::TOOL_BASE::m_cancelled, PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_gridHelper, TOOL_INTERACTIVE::m_menu, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, PNS::ROUTER::Move(), PNS::ITEM::Net(), PNS::ROUTER::RoutingInProgress(), PCB_TOOL_BASE::selection(), KIGFX::VIEW_CONTROLS::SetAutoPan(), GRID_HELPER::SetAuxAxes(), TOOL_MENU::ShowContextMenu(), KIDIALOG::ShowModal(), PNS::ROUTER::StartDragging(), PNS::ROUTER::StopRouting(), PCB_BASE_EDIT_FRAME::UndoRedoBlock(), PNS::TOOL_BASE::updateEndItem(), and TOOL_INTERACTIVE::Wait().

Referenced by MainLoop().

◆ performRouting()

void ROUTER_TOOL::performRouting ( )
private

Definition at line 1064 of file router_tool.cpp.

1065 {
1067 
1068  if( !prepareInteractive() )
1069  return;
1070 
1071  auto setCursor =
1072  [&]()
1073  {
1075  };
1076 
1077  // Set initial cursor
1078  setCursor();
1079 
1080  while( TOOL_EVENT* evt = Wait() )
1081  {
1082  setCursor();
1083 
1084  // Don't crash if we missed an operation that canceled routing.
1085  if( !m_router->RoutingInProgress() )
1086  {
1087  if( evt->IsCancelInteractive() )
1088  m_cancelled = true;
1089 
1090  break;
1091  }
1092 
1093  handleCommonEvents( *evt );
1094 
1095  if( evt->IsMotion() )
1096  {
1097  m_router->SetOrthoMode( evt->Modifier( MD_CTRL ) );
1098  updateEndItem( *evt );
1100  }
1101  else if( evt->IsAction( &ACT_UndoLastSegment ) )
1102  {
1104  updateEndItem( *evt );
1106  }
1107  else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &PCB_ACTIONS::routeSingleTrack ) )
1108  {
1109  updateEndItem( *evt );
1110  bool needLayerSwitch = m_router->IsPlacingVia();
1111  bool forceFinish = evt->Modifier( MD_SHIFT );
1112 
1113  if( m_router->FixRoute( m_endSnapPoint, m_endItem, forceFinish ) )
1114  {
1115  break;
1116  }
1117 
1118  if( needLayerSwitch )
1120 
1121  // Synchronize the indicated layer
1123  updateEndItem( *evt );
1125  m_startItem = nullptr;
1126  }
1127  else if( evt->IsAction( &ACT_SwitchRounding ) )
1128  {
1130  updateEndItem( *evt );
1131  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
1132  }
1133  else if( evt->IsAction( &ACT_SwitchPosture ) )
1134  {
1135  m_router->FlipPosture();
1136  updateEndItem( *evt );
1137  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
1138  }
1139  else if( evt->IsAction( &PCB_ACTIONS::properties ) )
1140  {
1142  controls()->SetAutoPan( false );
1143  {
1145  }
1146  controls()->SetAutoPan( true );
1147  setCursor();
1148  }
1149  else if( evt->IsAction( &ACT_EndTrack ) || evt->IsDblClick( BUT_LEFT ) )
1150  {
1151  // Stop current routing:
1153  break;
1154  }
1155  else if( evt->IsCancelInteractive() || evt->IsActivate()
1156  || evt->IsUndoRedo()
1157  || evt->IsAction( &PCB_ACTIONS::routerInlineDrag ) )
1158  {
1159  if( evt->IsCancelInteractive() && !m_router->RoutingInProgress() )
1160  m_cancelled = true;
1161 
1162  if( evt->IsActivate() && !evt->IsMoveTool() )
1163  m_cancelled = true;
1164 
1165  break;
1166  }
1167  else if( evt->IsClick( BUT_RIGHT ) )
1168  {
1170  }
1171  else
1172  {
1173  evt->SetPassEvent();
1174  }
1175  }
1176 
1178  m_router->StopRouting();
1179 
1181 }
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
bool finishInteractive()
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)
void CommitRouting()
Definition: pns_router.cpp:664
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void ClearViewDecorations()
Definition: pns_router.cpp:701
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:121
bool IsPlacingVia() const
Definition: pns_router.cpp:763
void ToggleRounded()
Definition: pns_router.cpp:772
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
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)
void SetOrthoMode(bool aEnable)
Definition: pns_router.cpp:790
static const TOOL_ACTION ACT_EndTrack("pcbnew.InteractiveRouter.EndTrack", AS_CONTEXT, WXK_END, "", _("Finish Track"), _("Stops laying the current track."), BITMAPS::checked_ok)
PCB_BASE_EDIT_FRAME * frame() const
void UndoLastSegment()
Definition: pns_router.cpp:655
virtual void updateEndItem(const TOOL_EVENT &aEvent)
bool prepareInteractive()
const PCB_SELECTION & selection() const
void handleCommonEvents(TOOL_EVENT &evt)
Generic, UI-independent tool event.
Definition: tool_event.h:173
ITEM * m_startItem
Definition: pns_tool_base.h:69
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:630
static const TOOL_ACTION ACT_UndoLastSegment("pcbnew.InteractiveRouter.UndoLastSegment", AS_CONTEXT, WXK_BACK, "", _("Undo last segment"), _("Stops laying the current track."), BITMAPS::checked_ok)
ROUTER * m_router
Definition: pns_tool_base.h:78
void switchLayerOnViaPlacement()
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:406
static const TOOL_ACTION ACT_SwitchRounding("pcbnew.InteractiveRouter.SwitchRounding", AS_CONTEXT, MD_CTRL+'/', "", _("Track Corner Mode"), _("Switches between sharp and rounded corners when routing tracks."), BITMAPS::switch_corner_rounding_shape)
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:211
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
void StopRouting()
Definition: pns_router.cpp:673
KIGFX::VIEW_CONTROLS * controls() const
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:185
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
void FlipPosture()
Definition: pns_router.cpp:707
bool RoutingInProgress() const
Definition: pns_router.cpp:114
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:905
int GetCurrentLayer() const
Definition: pns_router.cpp:746

References ACT_CustomTrackWidth, ACT_EndTrack, ACT_SwitchPosture, ACT_SwitchRounding, ACT_UndoLastSegment, ARROW, BUT_LEFT, BUT_RIGHT, PNS::ROUTER::ClearViewDecorations(), PNS::ROUTER::CommitRouting(), PCB_TOOL_BASE::controls(), finishInteractive(), PNS::ROUTER::FixRoute(), PNS::ROUTER::FlipPosture(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), PNS::ROUTER::GetCurrentLayer(), handleCommonEvents(), PNS::ROUTER::IsPlacingVia(), PNS::TOOL_BASE::m_cancelled, PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, TOOL_INTERACTIVE::m_menu, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, TOOL_BASE::m_toolMgr, MD_CTRL, MD_SHIFT, PNS::ROUTER::Move(), PENCIL, prepareInteractive(), PCB_ACTIONS::properties, PCB_ACTIONS::routerInlineDrag, PCB_ACTIONS::routeSingleTrack, PNS::ROUTER::RoutingInProgress(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_BASE_FRAME::SetActiveLayer(), KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), PNS::ROUTER::SetOrthoMode(), TOOL_MENU::ShowContextMenu(), PNS::ROUTER::StopRouting(), switchLayerOnViaPlacement(), PNS::ROUTER::ToggleRounded(), ToLAYER_ID(), PNS::ROUTER::UndoLastSegment(), PNS::TOOL_BASE::updateEndItem(), and TOOL_INTERACTIVE::Wait().

Referenced by MainLoop().

◆ pickSingleItem()

ITEM * TOOL_BASE::pickSingleItem ( const VECTOR2I aWhere,
int  aNet = -1,
int  aLayer = -1,
bool  aIgnorePads = false,
const std::vector< ITEM * >  aAvoidItems = {} 
)
protectedvirtualinherited

Definition at line 98 of file pns_tool_base.cpp.

100 {
101  int tl = aLayer > 0 ? aLayer : getView()->GetTopLayer();
102 
103  static const int candidateCount = 5;
104  ITEM* prioritized[candidateCount];
105  SEG::ecoord dist[candidateCount];
106 
107  for( int i = 0; i < candidateCount; i++ )
108  {
109  prioritized[i] = nullptr;
110  dist[i] = VECTOR2I::ECOORD_MAX;
111  }
112 
113  ITEM_SET candidates = m_router->QueryHoverItems( aWhere );
114 
115  for( ITEM* item : candidates.Items() )
116  {
117  if( !item->IsRoutable() )
118  continue;
119 
120  if( !IsCopperLayer( item->Layers().Start() ) )
121  continue;
122 
123  if( !m_iface->IsAnyLayerVisible( item->Layers() ) )
124  continue;
125 
126  if( alg::contains( aAvoidItems, item ) )
127  continue;
128 
129  // fixme: this causes flicker with live loop removal...
130  //if( item->Parent() && !item->Parent()->ViewIsVisible() )
131  // continue;
132 
133  if( aNet <= 0 || item->Net() == aNet )
134  {
135  if( item->OfKind( ITEM::VIA_T | ITEM::SOLID_T ) )
136  {
137  if( item->OfKind( ITEM::SOLID_T ) && aIgnorePads )
138  continue;
139 
140  SEG::ecoord d = ( item->Shape()->Centre() - aWhere ).SquaredEuclideanNorm();
141 
142  if( d < dist[2] )
143  {
144  prioritized[2] = item;
145  dist[2] = d;
146  }
147 
148  if( item->Layers().Overlaps( tl ) && d < dist[0] )
149  {
150  prioritized[0] = item;
151  dist[0] = d;
152  }
153  }
154  else // ITEM::SEGMENT_T | ITEM::ARC_T
155  {
156  LINKED_ITEM* li = static_cast<LINKED_ITEM*>( item );
157  SEG::ecoord d = std::min( ( li->Anchor( 0 ) - aWhere ).SquaredEuclideanNorm(),
158  ( li->Anchor( 1 ) - aWhere ).SquaredEuclideanNorm() );
159 
160  if( d < dist[3] )
161  {
162  prioritized[3] = item;
163  dist[3] = d;
164  }
165 
166  if( item->Layers().Overlaps( tl ) && d < dist[1] )
167  {
168  prioritized[1] = item;
169  dist[1] = d;
170  }
171  }
172  }
173  // Allow unconnected items as last resort in RM_MarkObstacles mode
174  else if ( item->Net() == 0 && m_router->Settings().Mode() == RM_MarkObstacles )
175  {
176  if( item->OfKind( ITEM::SOLID_T ) && aIgnorePads )
177  continue;
178 
179  if( item->Layers().Overlaps( tl ) )
180  prioritized[4] = item;
181  }
182  }
183 
184  ITEM* rv = NULL;
185 
187 
188  for( int i = 0; i < candidateCount; i++ )
189  {
190  ITEM* item = prioritized[i];
191 
192  if( highContrast && item && !item->Layers().Overlaps( tl ) )
193  item = nullptr;
194 
195  if( item && ( aLayer < 0 || item->Layers().Overlaps( aLayer ) ) )
196  {
197  rv = item;
198  break;
199  }
200  }
201 
202  if( rv )
203  {
204  wxLogTrace( "PNS", "%s, layer : %d, tl: %d", rv->KindStr().c_str(), rv->Layers().Start(), tl );
205  }
206 
207  return rv;
208 }
const ITEM_SET QueryHoverItems(const VECTOR2I &aP)
Definition: pns_router.cpp:120
VECTOR2I::extended_type ecoord
Definition: seg.h:44
static constexpr extended_type ECOORD_MAX
Definition: vector2d.h:79
#define NULL
virtual int GetTopLayer() const
Definition: view.cpp:828
Inactive layers are shown normally (no high-contrast mode)
ROUTER * m_router
Definition: pns_tool_base.h:78
PNS_MODE Mode() const
Set the routing mode.
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:81
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
const PCB_DISPLAY_OPTIONS & displayOptions() const
Ignore collisions, mark obstacles.
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
PNS_KICAD_IFACE * m_iface
Definition: pns_tool_base.h:77
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:184
bool IsAnyLayerVisible(const LAYER_RANGE &aLayer) const override

References PNS::ITEM::Anchor(), alg::contains(), PCB_TOOL_BASE::displayOptions(), VECTOR2< T >::ECOORD_MAX, KIGFX::VIEW::GetTopLayer(), TOOL_BASE::getView(), PNS_KICAD_IFACE::IsAnyLayerVisible(), IsCopperLayer(), PNS::ITEM_SET::Items(), PNS::ITEM::KindStr(), PNS::ITEM::Layers(), PCB_DISPLAY_OPTIONS::m_ContrastModeDisplay, PNS::TOOL_BASE::m_iface, PNS::TOOL_BASE::m_router, PNS::ROUTING_SETTINGS::Mode(), NORMAL, NULL, LAYER_RANGE::Overlaps(), PNS::ROUTER::QueryHoverItems(), PNS::RM_MarkObstacles, PNS::ROUTER::Settings(), PNS::ITEM::SOLID_T, LAYER_RANGE::Start(), and PNS::ITEM::VIA_T.

Referenced by PNS::TOOL_BASE::updateEndItem(), and PNS::TOOL_BASE::updateStartItem().

◆ prepareInteractive()

bool ROUTER_TOOL::prepareInteractive ( )
private

Definition at line 995 of file router_tool.cpp.

996 {
997  int routingLayer = getStartLayer( m_startItem );
998 
999  if( !IsCopperLayer( routingLayer ) )
1000  {
1001  frame()->ShowInfoBarError( _( "Tracks on Copper layers only." ) );
1002  return false;
1003  }
1004 
1005  PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
1006 
1007  editFrame->SetActiveLayer( ToLAYER_ID( routingLayer ) );
1008 
1009  if( m_startItem && m_startItem->Net() > 0 )
1010  highlightNet( true, m_startItem->Net() );
1011 
1012  controls()->ForceCursorPosition( false );
1013  controls()->SetAutoPan( true );
1014 
1015  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
1016 
1017  m_iface->ImportSizes( sizes, m_startItem, -1 );
1018  sizes.AddLayerPair( frame()->GetScreen()->m_Route_Layer_TOP,
1019  frame()->GetScreen()->m_Route_Layer_BOTTOM );
1020 
1021  m_router->UpdateSizes( sizes );
1022 
1023  if( !m_router->StartRouting( m_startSnapPoint, m_startItem, routingLayer ) )
1024  {
1025  // It would make more sense to leave the net highlighted as the higher-contrast mode
1026  // makes the router clearances more visible. However, since we just started routing
1027  // the conversion of the screen from low contrast to high contrast is a bit jarring and
1028  // makes the infobar coming up less noticeable.
1029  highlightNet( false );
1030 
1032  [&]()
1033  {
1035  } );
1036 
1037  controls()->SetAutoPan( false );
1038  return false;
1039  }
1040 
1041  m_endItem = nullptr;
1043 
1044  frame()->UndoRedoBlock( true );
1045 
1046  return true;
1047 }
const wxString & FailureReason() const
Definition: pns_router.h:206
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
void ClearViewDecorations()
Definition: pns_router.cpp:701
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:203
PCB_BASE_EDIT_FRAME * frame() const
#define _(s)
int Net() const
Definition: pns_item.h:148
ITEM * m_startItem
Definition: pns_tool_base.h:69
ROUTER * m_router
Definition: pns_tool_base.h:78
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
bool StartRouting(const VECTOR2I &aP, ITEM *aItem, int aLayer)
Definition: pns_router.cpp:351
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
virtual void highlightNet(bool aEnabled, int aNetcode=-1)
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:535
KIGFX::VIEW_CONTROLS * controls() const
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
The main frame for Pcbnew.
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
int getStartLayer(const PNS::ITEM *aItem)
bool ImportSizes(PNS::SIZES_SETTINGS &aSizes, PNS::ITEM *aStartItem, int aNet) override
PNS_KICAD_IFACE * m_iface
Definition: pns_tool_base.h:77
void SetActiveLayer(PCB_LAYER_ID aLayer) override
Change the currently active layer to aLayer and also update the APPEARANCE_CONTROLS.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:905

References _, PNS::ROUTER::ClearViewDecorations(), PCB_TOOL_BASE::controls(), PNS::ROUTER::FailureReason(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), getStartLayer(), PNS::TOOL_BASE::highlightNet(), PNS_KICAD_IFACE_BASE::ImportSizes(), IsCopperLayer(), PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_iface, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, PNS::ITEM::Net(), PCB_EDIT_FRAME::SetActiveLayer(), KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_BASE_FRAME::ShowInfoBarError(), PNS::ROUTER::Sizes(), PNS::ROUTER::StartRouting(), ToLAYER_ID(), PCB_BASE_EDIT_FRAME::UndoRedoBlock(), and PNS::ROUTER::UpdateSizes().

Referenced by performRouting().

◆ Reset()

void ROUTER_TOOL::Reset ( RESET_REASON  aReason)
overridevirtual

Bring the tool to a known, initial state.

If the tool claimed anything from the model or the view, it must release it when its reset.

Parameters
aReasoncontains information about the reason of tool reset.

Reimplemented from PNS::TOOL_BASE.

Definition at line 480 of file router_tool.cpp.

481 {
483 
484  if( aReason == RUN )
485  TOOL_BASE::Reset( aReason );
486 }
Tool is invoked after being inactive.
Definition: tool_base.h:80
virtual void Reset(RESET_REASON aReason)=0
Bring the tool to a known, initial state.
int m_lastTargetLayer
Definition: router_tool.h:80

References m_lastTargetLayer, TOOL_BASE::Reset(), TOOL_BASE::RUN, and UNDEFINED_LAYER.

◆ Router()

ROUTER * TOOL_BASE::Router ( ) const
inherited

◆ RunMainStack()

void TOOL_INTERACTIVE::RunMainStack ( std::function< void()>  aFunc)
inherited

Call a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 87 of file tool_interactive.cpp.

88 {
89  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
90 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)

References TOOL_BASE::m_toolMgr, and TOOL_MANAGER::RunMainStack().

Referenced by DRAWING_TOOL::PlaceText().

◆ saveRouterDebugLog()

void ROUTER_TOOL::saveRouterDebugLog ( )
private

Definition at line 491 of file router_tool.cpp.

492 {
493  auto logger = m_router->Logger();
494 
495  if( ! logger )
496  return;
497 
498  wxString cwd = wxGetCwd();
499 
500  wxFileName fname_log( cwd );
501  fname_log.SetName( "pns.log" );
502 
503  wxFileName fname_dump( cwd );
504  fname_dump.SetName( "pns.dump" );
505 
506  wxString msg = wxString::Format( _( "Event file: %s\nBoard dump: %s" ), fname_log.GetFullPath(), fname_log.GetFullPath() );
507 
508  int rv = OKOrCancelDialog( nullptr, _("Save router log"), _("Would you like to save the router\nevent log for debugging purposes?"), msg, _("OK"), _("Cancel") );
509 
510  if( !rv )
511  return;
512 
513  FILE *f = fopen( fname_log.GetFullPath().c_str(), "wb" );
514 
515  // save base router configuration (mode, etc.)
516  fprintf(f, "config %d %d %d\n",
517  m_router->Settings().Mode(),
518  m_router->Settings().RemoveLoops() ? 1 : 0,
519  m_router->Settings().GetFixAllSegments() ? 1 : 0
520  );
521 
522  const auto& events = logger->GetEvents();
523 
524  for( auto evt : events)
525  {
526  wxString id = "null";
527  if( evt.item && evt.item->Parent() )
528  id = evt.item->Parent()->m_Uuid.AsString();
529 
530  fprintf( f, "event %d %d %d %s\n", evt.p.x, evt.p.y, evt.type,
531  (const char*) id.c_str() );
532  }
533 
534  fclose( f );
535 
536  // Export as *.kicad_pcb format, using a strategy which is specifically chosen
537  // as an example on how it could also be used to send it to the system clipboard.
538 
539  PCB_IO pcb_io;
540 
541  pcb_io.Save( fname_dump.GetFullPath(), m_iface->GetBoard(), nullptr );
542 }
BOARD * GetBoard() const
A PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
bool RemoveLoops() const
Enable/disable loop (redundant track) removal.
#define _(s)
ROUTER * m_router
Definition: pns_tool_base.h:78
PNS_MODE Mode() const
Set the routing mode.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
int OKOrCancelDialog(wxWindow *aParent, const wxString &aWarning, const wxString &aMessage, wxString aDetailedMessage, wxString aOKLabel, wxString aCancelLabel, bool *aApplyToAll)
Display a warning dialog with aMessage and returns the user response.
Definition: confirm.cpp:220
LOGGER * Logger()
Definition: pns_router.cpp:757
virtual void Save(const wxString &aFileName, BOARD *aBoard, const PROPERTIES *aProperties=nullptr) override
Write aBoard to a storage file in a format that this PLUGIN implementation knows about or it can be u...
PNS_KICAD_IFACE * m_iface
Definition: pns_tool_base.h:77
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:184

References _, Format(), PNS_KICAD_IFACE_BASE::GetBoard(), PNS::ROUTING_SETTINGS::GetFixAllSegments(), PNS::ROUTER::Logger(), PNS::TOOL_BASE::m_iface, PNS::TOOL_BASE::m_router, PNS::ROUTING_SETTINGS::Mode(), OKOrCancelDialog(), PNS::ROUTING_SETTINGS::RemoveLoops(), PCB_IO::Save(), and PNS::ROUTER::Settings().

Referenced by handleCommonEvents().

◆ SelectCopperLayerPair()

int ROUTER_TOOL::SelectCopperLayerPair ( const TOOL_EVENT aEvent)

Definition at line 280 of file sel_layer.cpp.

281 {
282  PCB_SCREEN* screen = frame()->GetScreen();
283 
285  screen->m_Route_Layer_BOTTOM );
286 
287  if( dlg.ShowModal() == wxID_OK )
288  {
289  dlg.GetLayerPair( screen->m_Route_Layer_TOP, screen->m_Route_Layer_BOTTOM );
290 
291  // select the same layer for both layers is allowed (normal in some boards)
292  // but could be a mistake. So display an info message
293  if( screen->m_Route_Layer_TOP == screen->m_Route_Layer_BOTTOM )
294  DisplayInfoMessage( frame(), _( "Warning: top and bottom layers are same." ) );
295  }
296 
297  return 0;
298 }
PCB_BASE_EDIT_FRAME * frame() const
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:44
BOARD * GetBoard()
#define _(s)
Definition: 3d_actions.cpp:33
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:280
PCB_LAYER_ID m_Route_Layer_TOP
Definition: pcb_screen.h:43
SELECT_COPPER_LAYERS_PAIR_DIALOG displays a double pcb copper layers list in a dialog,...
Definition: sel_layer.cpp:250

References _, DisplayInfoMessage(), PCB_TOOL_BASE::frame(), GetBoard(), SELECT_COPPER_LAYERS_PAIR_DIALOG::GetLayerPair(), PCB_BASE_FRAME::GetScreen(), PCB_SCREEN::m_Route_Layer_BOTTOM, and PCB_SCREEN::m_Route_Layer_TOP.

Referenced by setTransitions().

◆ selection() [1/2]

const PCB_SELECTION & PCB_TOOL_BASE::selection ( ) const
protectedinherited

Definition at line 301 of file pcb_tool_base.cpp.

302 {
304 
305  return selTool->GetSelection();
306 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
PCB_SELECTION & GetSelection()
Return the set of currently selected items.
The selection tool: currently supports:

References PCB_SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), and TOOL_BASE::m_toolMgr.

Referenced by AUTOPLACE_TOOL::autoplaceSelected(), BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), CanInlineDrag(), EDIT_TOOL::ChangeTrackWidth(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), BOARD_INSPECTION_TOOL::CrossProbePcbToSch(), BOARD_INSPECTION_TOOL::doHideNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::Drag(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawZone(), EDIT_TOOL::Duplicate(), BOARD_EDITOR_CONTROL::EditFpInFpEditor(), PAD_TOOL::EditPad(), GROUP_TOOL::EnterGroup(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), EDIT_TOOL::FilletTracks(), PCB_SELECTION_TOOL::filterSelection(), EDIT_TOOL::Flip(), DRAWING_TOOL::getSourceZoneForAction(), GROUP_TOOL::Group(), BOARD_INSPECTION_TOOL::highlightNet(), InlineBreakTrack(), InlineDrag(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectConstraints(), DRAWING_TOOL::InteractivePlaceWithPreview(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), EDIT_TOOL::Mirror(), BOARD_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), PCB_POINT_EDITOR::OnSelectionChange(), PAD_TOOL::pastePadProperties(), performDragging(), performRouting(), LENGTH_TUNER_TOOL::performTuning(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), DRAWING_TOOL::PlaceImportedGraphics(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), GROUP_TOOL::RemoveFromGroup(), GLOBAL_EDIT_TOOL::RemoveUnusedPads(), EDIT_TOOL::Rotate(), PCB_SELECTION_TOOL::selectNet(), DRAWING_TOOL::SetAnchor(), BOARD_EDITOR_CONTROL::TrackWidthDec(), BOARD_EDITOR_CONTROL::TrackWidthInc(), GROUP_TOOL::Ungroup(), PCB_CONTROL::UpdateMessagePanel(), BOARD_INSPECTION_TOOL::UpdateSelectionRatsnest(), BOARD_EDITOR_CONTROL::ViaSizeDec(), BOARD_EDITOR_CONTROL::ViaSizeInc(), BOARD_EDITOR_CONTROL::ZoneDuplicate(), ZONE_FILLER_TOOL::ZoneFill(), BOARD_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfill().

◆ selection() [2/2]

PCB_SELECTION & PCB_TOOL_BASE::selection ( )
protectedinherited

Definition at line 309 of file pcb_tool_base.cpp.

310 {
312 
313  return selTool->GetSelection();
314 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
PCB_SELECTION & GetSelection()
Return the set of currently selected items.
The selection tool: currently supports:

References PCB_SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), and TOOL_BASE::m_toolMgr.

◆ SetContextMenu()

void TOOL_INTERACTIVE::SetContextMenu ( ACTION_MENU aMenu,
CONTEXT_MENU_TRIGGER  aTrigger = CMENU_BUTTON 
)
inherited

Assign a context menu and tells when it should be activated.

Parameters
aMenuis the menu to be assigned.
aTriggerdetermines conditions upon which the context menu is activated.

Definition at line 76 of file tool_interactive.cpp.

77 {
78  if( aMenu )
79  aMenu->SetTool( this );
80  else
81  aTrigger = CMENU_OFF;
82 
83  m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
84 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void SetTool(TOOL_INTERACTIVE *aTool)
Set a tool that is the creator of the menu.
void ScheduleContextMenu(TOOL_BASE *aTool, ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Set behavior of the tool's context popup menu.

References CMENU_OFF, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ScheduleContextMenu(), and ACTION_MENU::SetTool().

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), TOOL_MENU::ShowContextMenu(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ SetIsFootprintEditor()

void PCB_TOOL_BASE::SetIsFootprintEditor ( bool  aEnabled)
inlineinherited

Function SetIsFootprintEditor()

Toggles edit footprint mode. When enabled, one may select parts of footprints individually (graphics, pads, etc.), so they can be modified.

Parameters
aEnableddecides if the mode should be enabled.

Definition at line 104 of file pcb_tool_base.h.

104 { m_isFootprintEditor = aEnabled; }
bool m_isFootprintEditor

References PCB_TOOL_BASE::m_isFootprintEditor.

◆ SettingsDialog()

int ROUTER_TOOL::SettingsDialog ( const TOOL_EVENT aEvent)

Definition at line 1204 of file router_tool.cpp.

1205 {
1206  DIALOG_PNS_SETTINGS settingsDlg( frame(), m_router->Settings() );
1207 
1208  settingsDlg.ShowModal();
1209 
1210  return 0;
1211 }
PCB_BASE_EDIT_FRAME * frame() const
ROUTER * m_router
Definition: pns_tool_base.h:78
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:184

References PCB_TOOL_BASE::frame(), PNS::TOOL_BASE::m_router, and PNS::ROUTER::Settings().

Referenced by setTransitions().

◆ setTransitions()

void ROUTER_TOOL::setTransitions ( )
overridevirtual

This method is meant to be overridden in order to specify handlers for events.

It is called every time tool is reset or finished.

Reimplemented from PCB_TOOL_BASE.

Definition at line 1868 of file router_tool.cpp.

1869 {
1871 
1881 
1887 
1922 
1925 }
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:288
static TOOL_ACTION layerInner26
Definition: pcb_actions.h:283
int onLayerCommand(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerNext
Definition: pcb_actions.h:289
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:259
int MainLoop(const TOOL_EVENT &aEvent)
static TOOL_ACTION selectLayerPair
Definition: pcb_actions.h:133
int DpDimensionsDialog(const TOOL_EVENT &aEvent)
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 TOOL_ACTION layerInner5
Definition: pcb_actions.h:262
static TOOL_ACTION layerInner6
Definition: pcb_actions.h:263
static TOOL_ACTION routerDiffPairDialog
Definition: pcb_actions.h:203
static TOOL_ACTION layerInner7
Definition: pcb_actions.h:264
static TOOL_ACTION layerInner8
Definition: pcb_actions.h:265
static TOOL_ACTION layerInner21
Definition: pcb_actions.h:278
int InlineDrag(const TOOL_EVENT &aEvent)
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 TOOL_ACTION routerHighlightMode
Actions to enable switching modes via hotkey assignments.
Definition: pcb_actions.h:206
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:305
static TOOL_ACTION layerInner3
Definition: pcb_actions.h:260
static TOOL_ACTION layerInner24
Definition: pcb_actions.h:281
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
int ChangeRouterMode(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner11
Definition: pcb_actions.h:268
static TOOL_ACTION layerTop
Definition: pcb_actions.h:257
static TOOL_ACTION layerInner23
Definition: pcb_actions.h:280
int onViaCommand(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerSettingsDialog
Activation of the Push and Shove settings dialogs.
Definition: pcb_actions.h:202
static TOOL_ACTION layerInner13
Definition: pcb_actions.h:270
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:290
static TOOL_ACTION layerInner25
Definition: pcb_actions.h:282
static TOOL_ACTION layerInner18
Definition: pcb_actions.h:275
static TOOL_ACTION layerInner30
Definition: pcb_actions.h:287
static TOOL_ACTION layerInner29
Definition: pcb_actions.h:286
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 TOOL_ACTION layerInner10
Definition: pcb_actions.h:267
int SettingsDialog(const TOOL_EVENT &aEvent)
int CustomTrackWidthDialog(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerWalkaroundMode
Definition: pcb_actions.h:208
static TOOL_ACTION layerInner15
Definition: pcb_actions.h:272
int onTrackViaSizeChanged(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:211
static TOOL_ACTION layerInner28
Definition: pcb_actions.h:285
static TOOL_ACTION layerInner27
Definition: pcb_actions.h:284
static TOOL_ACTION inlineBreakTrack
Breaks track when router is not activated.
Definition: pcb_actions.h:139
static TOOL_ACTION layerInner17
Definition: pcb_actions.h:274
static TOOL_ACTION layerInner20
Definition: pcb_actions.h:277
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_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 TOOL_ACTION layerInner22
Definition: pcb_actions.h:279
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:185
static TOOL_ACTION layerInner14
Definition: pcb_actions.h:271
static TOOL_ACTION layerInner9
Definition: pcb_actions.h:266
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))
TOOL_EVENT MakeEvent() const
Return the event associated with the action (i.e.
Definition: tool_action.h:123
int InlineBreakTrack(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner16
Definition: pcb_actions.h:273
int SelectCopperLayerPair(const TOOL_EVENT &aEvent)
Definition: sel_layer.cpp:280
static TOOL_ACTION layerInner4
Definition: pcb_actions.h:261
static TOOL_ACTION layerInner19
Definition: pcb_actions.h:276
static TOOL_ACTION layerInner1
Definition: pcb_actions.h:258
static TOOL_ACTION routerShoveMode
Definition: pcb_actions.h:207
static TOOL_ACTION layerInner12
Definition: pcb_actions.h:269
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:188

References ACT_CustomTrackWidth, ACT_PlaceBlindVia, ACT_PlaceMicroVia, ACT_PlaceThroughVia, ACT_SelLayerAndPlaceBlindVia, ACT_SelLayerAndPlaceThroughVia, ChangeRouterMode(), CustomTrackWidthDialog(), DpDimensionsDialog(), TOOL_INTERACTIVE::Go(), InlineBreakTrack(), PCB_ACTIONS::inlineBreakTrack, InlineDrag(), 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::layerNext, PCB_ACTIONS::layerPrev, PCB_ACTIONS::layerTop, MainLoop(), TOOL_ACTION::MakeEvent(), onLayerCommand(), onTrackViaSizeChanged(), onViaCommand(), PCB_ACTIONS::routeDiffPair, PCB_ACTIONS::routerDiffPairDialog, PCB_ACTIONS::routerHighlightMode, PCB_ACTIONS::routerInlineDrag, PCB_ACTIONS::routerSettingsDialog, PCB_ACTIONS::routerShoveMode, PCB_ACTIONS::routerWalkaroundMode, PCB_ACTIONS::routeSingleTrack, SelectCopperLayerPair(), PCB_ACTIONS::selectLayerPair, SettingsDialog(), and PCB_ACTIONS::trackViaSizeChanged.

◆ snapToItem()

const VECTOR2I TOOL_BASE::snapToItem ( ITEM aSnapToItem,
VECTOR2I  aP 
)
protectedinherited

Definition at line 353 of file pns_tool_base.cpp.

354 {
355  if( !aItem || !m_iface->IsItemVisible( aItem ) )
356  {
357  return m_gridHelper->Align( aP );
358  }
359 
360  switch( aItem->Kind() )
361  {
362  case ITEM::SOLID_T:
363  return static_cast<SOLID*>( aItem )->Pos();
364 
365  case ITEM::VIA_T:
366  return static_cast<VIA*>( aItem )->Pos();
367 
368  case ITEM::SEGMENT_T:
369  case ITEM::ARC_T:
370  {
371  LINKED_ITEM* li = static_cast<LINKED_ITEM*>( aItem );
372  VECTOR2I A = li->Anchor( 0 );
373  VECTOR2I B = li->Anchor( 1 );
374  SEG::ecoord w_sq = SEG::Square( li->Width() / 2 );
375  SEG::ecoord distA_sq = ( aP - A ).SquaredEuclideanNorm();
376  SEG::ecoord distB_sq = ( aP - B ).SquaredEuclideanNorm();
377 
378  if( distA_sq < w_sq || distB_sq < w_sq )
379  {
380  return ( distA_sq < distB_sq ) ? A : B;
381  }
382  // TODO(snh): Clean this up
383  else if( aItem->Kind() == ITEM::SEGMENT_T )
384  {
385  SEGMENT* seg = static_cast<SEGMENT*>( li );
386  return m_gridHelper->AlignToSegment( aP, seg->Seg() );
387  }
388  else if( aItem->Kind() == ITEM::ARC_T )
389  {
390  ARC* arc = static_cast<ARC*>( li );
391  return m_gridHelper->AlignToArc( aP, *static_cast<const SHAPE_ARC*>( arc->Shape() ) );
392  }
393  }
394  break;
395 
396  default:
397  break;
398  }
399 
400  return m_gridHelper->Align( aP );
401 }
VECTOR2I::extended_type ecoord
Definition: seg.h:44
static SEG::ecoord Square(int a)
Definition: seg.h:123
VECTOR2I AlignToArc(const VECTOR2I &aPoint, const SHAPE_ARC &aSeg)
PCB_GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
bool IsItemVisible(const PNS::ITEM *aItem) const override
virtual VECTOR2I Align(const VECTOR2I &aPoint) const
Definition: grid_helper.cpp:95
Definition: track.h:262
PNS_KICAD_IFACE * m_iface
Definition: pns_tool_base.h:77
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)

References GRID_HELPER::Align(), PCB_GRID_HELPER::AlignToArc(), PCB_GRID_HELPER::AlignToSegment(), PNS::ITEM::Anchor(), PNS::ITEM::ARC_T, PNS_KICAD_IFACE::IsItemVisible(), PNS::ITEM::Kind(), PNS::TOOL_BASE::m_gridHelper, PNS::TOOL_BASE::m_iface, PNS::SEGMENT::Seg(), PNS::ITEM::SEGMENT_T, PNS::ARC::Shape(), PNS::ITEM::SOLID_T, SEG::Square(), PNS::ITEM::VIA_T, and PNS::LINKED_ITEM::Width().

Referenced by InlineBreakTrack(), InlineDrag(), PNS::TOOL_BASE::updateEndItem(), and PNS::TOOL_BASE::updateStartItem().

◆ switchLayerOnViaPlacement()

void ROUTER_TOOL::switchLayerOnViaPlacement ( )
private

Definition at line 589 of file router_tool.cpp.

590 {
591  int al = frame()->GetActiveLayer();
592  int cl = m_router->GetCurrentLayer();
593 
594  if( cl != al )
595  {
596  m_router->SwitchLayer( al );
597  }
598 
599  OPT<int> newLayer = m_router->Sizes().PairedLayer( cl );
600 
601  if( !newLayer )
602  newLayer = m_router->Sizes().GetLayerTop();
603 
604  m_router->SwitchLayer( *newLayer );
605  m_lastTargetLayer = *newLayer;
606  frame()->SetActiveLayer( ToLAYER_ID( *newLayer ) );
607 }
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:203
PCB_BASE_EDIT_FRAME * frame() const
virtual PCB_LAYER_ID GetActiveLayer() const
ROUTER * m_router
Definition: pns_tool_base.h:78
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
bool SwitchLayer(int layer)
Definition: pns_router.cpp:716
boost::optional< T > OPT
Definition: optional.h:7
int m_lastTargetLayer
Definition: router_tool.h:80
OPT< int > PairedLayer(int aLayerId)
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:905
int GetCurrentLayer() const
Definition: pns_router.cpp:746

References PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetActiveLayer(), PNS::ROUTER::GetCurrentLayer(), PNS::SIZES_SETTINGS::GetLayerTop(), m_lastTargetLayer, PNS::TOOL_BASE::m_router, PNS::SIZES_SETTINGS::PairedLayer(), PCB_BASE_FRAME::SetActiveLayer(), PNS::ROUTER::Sizes(), PNS::ROUTER::SwitchLayer(), and ToLAYER_ID().

Referenced by performRouting().

◆ updateEndItem()

void TOOL_BASE::updateEndItem ( const TOOL_EVENT aEvent)
protectedvirtualinherited

Definition at line 287 of file pns_tool_base.cpp.

288 {
289  int layer;
290  GAL* gal = m_toolMgr->GetView()->GetGAL();
291 
292  m_gridHelper->SetUseGrid( gal->GetGridSnapping() && !aEvent.Modifier( MD_ALT ) );
293  m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
294 
295  controls()->ForceCursorPosition( false );
296  VECTOR2I mousePos = controls()->GetMousePosition();
297 
298  if( m_router->Settings().Mode() != RM_MarkObstacles &&
299  ( m_router->GetCurrentNets().empty() || m_router->GetCurrentNets().front() < 0 ) )
300  {
301  m_endSnapPoint = snapToItem( nullptr, mousePos );
303  m_endItem = nullptr;
304 
305  return;
306  }
307 
308  if( m_router->IsPlacingVia() )
309  layer = -1;
310  else
311  layer = m_router->GetCurrentLayer();
312 
313  ITEM* endItem = nullptr;
314 
315  std::vector<int> nets = m_router->GetCurrentNets();
316 
317  for( int net : nets )
318  {
319  endItem = pickSingleItem( mousePos, net, layer, false, { m_startItem } );
320 
321  if( endItem )
322  break;
323  }
324 
325  if( m_gridHelper->GetSnap() && checkSnap( endItem ) )
326  {
327  m_endItem = endItem;
328  m_endSnapPoint = snapToItem( endItem, mousePos );
329  }
330  else
331  {
332  m_endItem = nullptr;
333  m_endSnapPoint = m_gridHelper->Align( mousePos );
334  }
335 
337 
338  if( m_endItem )
339  {
340  wxLogTrace( "PNS", "%s, layer : %d",
341  m_endItem->KindStr().c_str(),
342  m_endItem->Layers().Start() );
343  }
344 }
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:289
bool GetSnap() const
Definition: grid_helper.h:65
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool IsPlacingVia() const
Definition: pns_router.cpp:763
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:735
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:189
int Start() const
Definition: pns_layerset.h:82
std::string KindStr() const
Returns the kind of the item, as string.
Definition: pns_item.cpp:126
bool GetGridSnapping() const
bool checkSnap(ITEM *aItem)
PCB_GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
ITEM * m_startItem
Definition: pns_tool_base.h:69
ROUTER * m_router
Definition: pns_tool_base.h:78
PNS_MODE Mode() const
Set the routing mode.
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
void SetSnap(bool aSnap)
Definition: grid_helper.h:64
int Modifier(int aMask=MD_MODIFIER_MASK) const
Definition: tool_event.h:352
virtual VECTOR2I Align(const VECTOR2I &aPoint) const
Definition: grid_helper.cpp:95
const VECTOR2I snapToItem(ITEM *aSnapToItem, VECTOR2I aP)
void SetUseGrid(bool aSnapToGrid)
Definition: grid_helper.h:67
Ignore collisions, mark obstacles.
KIGFX::VIEW_CONTROLS * controls() const
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
virtual ITEM * pickSingleItem(const VECTOR2I &aWhere, int aNet=-1, int aLayer=-1, bool aIgnorePads=false, const std::vector< ITEM * > aAvoidItems={})
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:184
const LAYER_RANGE & Layers() const
Definition: pns_item.h:150
Abstract interface for drawing on a 2D-surface.
int GetCurrentLayer() const
Definition: pns_router.cpp:746

References GRID_HELPER::Align(), PNS::TOOL_BASE::checkSnap(), PCB_TOOL_BASE::controls(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PNS::ROUTER::GetCurrentLayer(), PNS::ROUTER::GetCurrentNets(), KIGFX::VIEW::GetGAL(), KIGFX::GAL::GetGridSnapping(), KIGFX::VIEW_CONTROLS::GetMousePosition(), GRID_HELPER::GetSnap(), TOOL_MANAGER::GetView(), PNS::ROUTER::IsPlacingVia(), PNS::ITEM::KindStr(), PNS::ITEM::Layers(), PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_gridHelper, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, TOOL_BASE::m_toolMgr, MD_ALT, MD_SHIFT, PNS::ROUTING_SETTINGS::Mode(), TOOL_EVENT::Modifier(), PNS::TOOL_BASE::pickSingleItem(), PNS::RM_MarkObstacles, GRID_HELPER::SetSnap(), PNS::ROUTER::Settings(), GRID_HELPER::SetUseGrid(), PNS::TOOL_BASE::snapToItem(), and LAYER_RANGE::Start().

Referenced by handleLayerSwitch(), InlineDrag(), performDragging(), and performRouting().

◆ updateStartItem()

void TOOL_BASE::updateStartItem ( const TOOL_EVENT aEvent,
bool  aIgnorePads = false 
)
protectedvirtualinherited

Definition at line 259 of file pns_tool_base.cpp.

260 {
261  int tl = getView()->GetTopLayer();
262  VECTOR2I cp = controls()->GetCursorPosition( !aEvent.Modifier( MD_SHIFT ) );
263  VECTOR2I p;
264  GAL* gal = m_toolMgr->GetView()->GetGAL();
265 
266  controls()->ForceCursorPosition( false );
267  m_gridHelper->SetUseGrid( gal->GetGridSnapping() && !aEvent.Modifier( MD_ALT ) );
268  m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
269 
270  if( aEvent.IsMotion() || aEvent.IsClick() )
271  p = aEvent.Position();
272  else
273  p = cp;
274 
275  m_startItem = pickSingleItem( p, -1, -1, aIgnorePads );
276 
278  m_startItem = nullptr;
279 
281 
282  if( checkSnap( m_startItem ) )
284 }
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:289
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
bool IsClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.cpp:181
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool IsMotion() const
Definition: tool_event.h:316
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:67
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:189
bool GetUseGrid() const
Definition: grid_helper.h:68
bool GetGridSnapping() const
bool checkSnap(ITEM *aItem)
PCB_GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
virtual int GetTopLayer() const
Definition: view.cpp:828
ITEM * m_startItem
Definition: pns_tool_base.h:69
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
void SetSnap(bool aSnap)
Definition: grid_helper.h:64
int Modifier(int aMask=MD_MODIFIER_MASK) const
Definition: tool_event.h:352
const VECTOR2I snapToItem(ITEM *aSnapToItem, VECTOR2I aP)
void SetUseGrid(bool aSnapToGrid)
Definition: grid_helper.h:67
KIGFX::VIEW_CONTROLS * controls() const
virtual ITEM * pickSingleItem(const VECTOR2I &aWhere, int aNet=-1, int aLayer=-1, bool aIgnorePads=false, const std::vector< ITEM * > aAvoidItems={})
const VECTOR2D Position() const
Returns the point where dragging has started.
Definition: tool_event.h:284
const LAYER_RANGE & Layers() const
Definition: pns_item.h:150
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
Abstract interface for drawing on a 2D-surface.

References PNS::TOOL_BASE::checkSnap(), PCB_TOOL_BASE::controls(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), KIGFX::VIEW::GetGAL(), KIGFX::GAL::GetGridSnapping(), KIGFX::VIEW::GetTopLayer(), GRID_HELPER::GetUseGrid(), TOOL_BASE::getView(), TOOL_MANAGER::GetView(), TOOL_EVENT::IsClick(), TOOL_EVENT::IsMotion(), PNS::ITEM::Layers(), PNS::TOOL_BASE::m_gridHelper, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, TOOL_BASE::m_toolMgr, MD_ALT, MD_SHIFT, TOOL_EVENT::Modifier(), LAYER_RANGE::Overlaps(), PNS::TOOL_BASE::pickSingleItem(), TOOL_EVENT::Position(), GRID_HELPER::SetSnap(), GRID_HELPER::SetUseGrid(), and PNS::TOOL_BASE::snapToItem().

Referenced by handleLayerSwitch(), MainLoop(), and LENGTH_TUNER_TOOL::MainLoop().

◆ view()

◆ Wait()

TOOL_EVENT * TOOL_INTERACTIVE::Wait ( const TOOL_EVENT_LIST aEventList = TOOL_EVENTTC_ANYTA_ANY ))
inherited

Suspend execution of the tool until an event specified in aEventList arrives.

No parameters means waiting for any event.

Definition at line 57 of file tool_interactive.cpp.

58 {
59  return m_toolMgr->ScheduleWait( this, aEventList );
60 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_EVENT * ScheduleWait(TOOL_BASE *aTool, const TOOL_EVENT_LIST &aConditions)
Pause execution of a given tool until one or more events matching aConditions arrives.

References TOOL_BASE::m_toolMgr, and TOOL_MANAGER::ScheduleWait().

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), ZOOM_TOOL::Main(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_EDIT_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), CVPCB_CONTROL::Main(), PL_POINT_EDITOR::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), PL_SELECTION_TOOL::Main(), EDA_3D_CONTROLLER::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), PCB_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), PCB_POINT_EDITOR::OnSelectionChange(), performDragging(), performRouting(), LENGTH_TUNER_TOOL::performTuning(), GROUP_TOOL::PickNewMember(), EDIT_TOOL::pickReferencePoint(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), PCB_SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

Member Data Documentation

◆ m_cancelled

bool PNS::TOOL_BASE::m_cancelled
protectedinherited

◆ m_diffPairMenu

std::shared_ptr<ACTION_MENU> ROUTER_TOOL::m_diffPairMenu
private

Definition at line 77 of file router_tool.h.

Referenced by Init().

◆ m_endItem

◆ m_endSnapPoint

VECTOR2I PNS::TOOL_BASE::m_endSnapPoint
protectedinherited

◆ m_gridHelper

◆ m_iface

◆ m_isFootprintEditor

◆ m_lastTargetLayer

int ROUTER_TOOL::m_lastTargetLayer
private

Definition at line 80 of file router_tool.h.

Referenced by handleLayerSwitch(), Init(), Reset(), and switchLayerOnViaPlacement().

◆ m_menu