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 }
 

Determines the reason of reset for a tool

More...
 

Public Member Functions

 ROUTER_TOOL ()
 
 ~ROUTER_TOOL ()
 
bool Init () override
 Function Init() Init() is called once upon a registration of the tool. More...
 
void Reset (RESET_REASON aReason) override
 Function Reset() Brings the tool to a known, initial state. More...
 
int MainLoop (const TOOL_EVENT &aEvent)
 
int InlineBreakTrack (const TOOL_EVENT &aEvent)
 
bool CanInlineDrag ()
 
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 ()
 Function Activate() Runs the tool. More...
 
TOOL_MENUGetToolMenu ()
 
void SetContextMenu (ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Function SetContextMenu() More...
 
void RunMainStack (std::function< void()> aFunc)
 Function RunMainStack() More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Go() More...
 
TOOL_EVENTWait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Wait() More...
 
TOOL_TYPE GetType () const
 Function GetType() Returns the type of the tool. More...
 
TOOL_ID GetId () const
 Function GetId() Returns the unique identifier of the tool. More...
 
const std::string & GetName () const
 Function GetName() Returns the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Function GetManager() Returns 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 (bool aEnabled, ITEM *aItem, 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 PCBNEW_SELECTIONselection () const
 
PCBNEW_SELECTIONselection ()
 
void attachManager (TOOL_MANAGER *aManager)
 Function attachManager() More...
 
KIGFX::VIEWgetView () const
 Function getView() More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Function getViewControls() More...
 
template<typename T >
T * getEditFrame () const
 Function getEditFrame() More...
 
template<typename T >
T * getModel () const
 Function getModel() More...
 

Protected Attributes

SIZES_SETTINGS m_savedSizes
 
ITEM * m_startItem
 
VECTOR2I m_startSnapPoint
 
bool m_startHighlight
 
ITEM * m_endItem
 
VECTOR2I m_endSnapPoint
 
GRID_HELPERm_gridHelper
 
PNS_KICAD_IFACEm_iface
 
ROUTER * m_router
 
bool m_cancelled
 
bool m_isFootprintEditor
 
TOOL_MENU m_menu
 functions below are not yet implemented - their interface may change More...
 
TOOL_TYPE m_type
 

Stores the type of the tool.

More...
 
TOOL_ID m_toolId
 

Unique identifier for the tool, assigned by a TOOL_MANAGER instance.

More...
 
std::string m_toolName
 

Name of the tool.

More...
 
TOOL_MANAGERm_toolMgr
 

Private Member Functions

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

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

Determines 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 79 of file tool_base.h.

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

Constructor & Destructor Documentation

◆ ROUTER_TOOL()

ROUTER_TOOL::ROUTER_TOOL ( )

Definition at line 160 of file router_tool.cpp.

160  :
161  TOOL_BASE( "pcbnew.InteractiveRouter" )
162 {
163 }
TOOL_BASE(const std::string &aToolName)

◆ ~ROUTER_TOOL()

ROUTER_TOOL::~ROUTER_TOOL ( )

Definition at line 409 of file router_tool.cpp.

410 {
411 }

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs 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:219
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:214
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls 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(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), PAD_TOOL::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_INSPECTION_TOOL::HighlightNetTool(), InlineBreakTrack(), InlineDrag(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), LIB_TREE::onContextMenu(), POINT_EDITOR::OnSelectionChange(), GROUP_TOOL::PickNewMember(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Function attachManager()

Sets 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:219

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 PCBNEW_CONTROL::AppendBoard(), AUTOPLACE_TOOL::autoplace(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), EDIT_TOOL::ChangeTrackWidth(), ZONE_FILLER_TOOL::CheckAllZones(), PCB_INSPECTION_TOOL::ClearHighlight(), EDIT_TOOL::copyToClipboard(), FOOTPRINT_EDITOR_TOOLS::CreateFootprint(), MICROWAVE_TOOL::createInductorBetween(), CustomTrackWidthDialog(), PCBNEW_CONTROL::DeleteItemCursor(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), ZONE_FILLER_TOOL::FillAllZones(), EDIT_TOOL::FilletTracks(), SELECTION_TOOL::filterSelection(), PCB_TOOL_BASE::footprint(), SELECTION_TOOL::GetBoard(), SELECTION_TOOL::getCollectorsGuide(), GROUP_TOOL::Group(), PCB_INSPECTION_TOOL::highlightNet(), PCBNEW_CONTROL::LayerNext(), PCBNEW_CONTROL::LayerPrev(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), EDIT_TOOL::MoveExact(), FOOTPRINT_EDITOR_TOOLS::NewFootprint(), onViaCommand(), PCBNEW_CONTROL::Paste(), PCBNEW_CONTROL::placeBoardItems(), PCB_EDITOR_CONTROL::PlaceModule(), PAD_TOOL::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), SELECTION_TOOL::RebuildSelection(), PAD_TOOL::recombinePad(), EDIT_TOOL::Remove(), PCB_EDITOR_CONTROL::RepairBoard(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), SELECTION_TOOL::Selectable(), SELECTION_TOOL::selectAllItemsOnNet(), SELECTION_TOOL::selectAllItemsOnSheet(), SELECTION_TOOL::selectConnectedTracks(), SELECTION_TOOL::selectPoint(), PCBNEW_CONTROL::TrackDisplayMode(), GROUP_TOOL::Ungroup(), PCBNEW_CONTROL::ViaDisplayMode(), PCBNEW_CONTROL::ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

◆ breakTrack()

void ROUTER_TOOL::breakTrack ( )
private

Definition at line 1136 of file router_tool.cpp.

1137 {
1140 }
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
void BreakSegment(ITEM *aItem, const VECTOR2I &aP)
Definition: pns_router.cpp:572
ITEM * m_startItem
Definition: pns_tool_base.h:69
ROUTER * m_router
Definition: pns_tool_base.h:78
bool OfKind(int aKindMask) const
Function OfKind()
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 ( )

Definition at line 1415 of file router_tool.cpp.

1416 {
1418  const auto& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
1419 
1420  if( selection.Size() == 1 )
1421  {
1422  const BOARD_ITEM* item = static_cast<const BOARD_ITEM*>( selection.Front() );
1423 
1424  if( item->Type() == PCB_TRACE_T
1425  || item->Type() == PCB_VIA_T
1426  || item->Type() == PCB_FOOTPRINT_T )
1427  {
1428  return true;
1429  }
1430  }
1431 
1432  return false;
1433 }
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
Definition: board_item.h:86
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:141
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
const PCBNEW_SELECTION & selection() const
class FOOTPRINT, a footprint
Definition: typeinfo.h:89
static void NeighboringSegmentFilter(const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector)
int Size() const
Returns the number of selected parts.
Definition: selection.h:126
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:59
EDA_ITEM * Front() const
Definition: selection.h:201
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181

References SELECTION::Front(), TOOL_MANAGER::GetTool(), TOOL_BASE::m_toolMgr, NeighboringSegmentFilter(), PCB_FOOTPRINT_T, PCB_TRACE_T, PCB_VIA_T, TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionCursor, SELECTION::Size(), and EDA_ITEM::Type().

◆ canvas()

◆ ChangeRouterMode()

int ROUTER_TOOL::ChangeRouterMode ( const TOOL_EVENT aEvent)

Definition at line 1119 of file router_tool.cpp.

1120 {
1121  PNS::PNS_MODE mode = aEvent.Parameter<PNS::PNS_MODE>();
1122  PNS::ROUTING_SETTINGS& settings = m_router->Settings();
1123 
1124  settings.SetMode( mode );
1125 
1126  return 0;
1127 }
void SetMode(PNS_MODE aMode)
Sets the routing mode.
PNS_MODE
Routing modes
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
ROUTER * m_router
Definition: pns_tool_base.h:78
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:200

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 247 of file pns_tool_base.cpp.

248 {
249  // Sync PNS engine settings with the general PCB editor options.
250  auto& pnss = m_router->Settings();
251 
252  pnss.SetSnapToPads(
253  frame()->GetMagneticItemsSettings()->pads == MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL ||
254  frame()->GetMagneticItemsSettings()->pads == MAGNETIC_OPTIONS::CAPTURE_ALWAYS );
255 
256  pnss.SetSnapToTracks(
257  frame()->GetMagneticItemsSettings()->tracks == MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL
258  || frame()->GetMagneticItemsSettings()->tracks == MAGNETIC_OPTIONS::CAPTURE_ALWAYS );
259 
260  if( aItem )
261  {
262  if( aItem->OfKind( ITEM::VIA_T | ITEM::SEGMENT_T | ITEM::ARC_T ) )
263  return pnss.GetSnapToTracks();
264  else if( aItem->OfKind( ITEM::SOLID_T ) )
265  return pnss.GetSnapToPads();
266  }
267 
268  return false;
269 }
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:200

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 1688 of file router_tool.cpp.

1689 {
1691  DIALOG_TRACK_VIA_SIZE sizeDlg( frame(), bds );
1692 
1693  if( sizeDlg.ShowModal() )
1694  {
1695  bds.UseCustomTrackViaSize( true );
1696 
1697  TOOL_EVENT dummy;
1699  }
1700 
1701  return 0;
1702 }
BOARD * board() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:559
PCB_BASE_EDIT_FRAME * frame() const
TOOL_EVENT.
Definition: tool_event.h:171
int onTrackViaSizeChanged(const TOOL_EVENT &aEvent)
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Implementing DIALOG_TRACK_VIA_SIZE_BASE.
void UseCustomTrackViaSize(bool aEnabled)
Function UseCustomTrackViaSize Enables/disables custom track/via size settings.
BOARD_DESIGN_SETTINGS contains 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

◆ 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 36 of file pcb_tool_base.cpp.

39 {
40  using namespace std::placeholders;
41  std::unique_ptr<BOARD_ITEM> newItem;
42 
43  frame()->PushTool( aTool );
44  Activate();
45 
46  BOARD_COMMIT commit( frame() );
47 
49 
50  // do not capture or auto-pan until we start placing an item
51  controls()->ShowCursor( true );
52 
53  // Add a VIEW_GROUP that serves as a preview for the new item
54  PCBNEW_SELECTION preview;
55  view()->Add( &preview );
56 
57  aPlacer->m_board = board();
58  aPlacer->m_frame = frame();
59  aPlacer->m_modifiers = 0;
60 
61  auto makeNewItem =
62  [&]( VECTOR2I aPosition )
63  {
64  if( frame()->GetModel() )
65  newItem = aPlacer->CreateItem();
66 
67  if( newItem )
68  {
69  newItem->SetPosition( (wxPoint) aPosition );
70  preview.Add( newItem.get() );
71 
72  if( newItem->Type() == PCB_FOOTPRINT_T )
73  {
74  FOOTPRINT* fp = dyn_cast<FOOTPRINT*>( newItem.get() );
75 
76  // footprints have more drawable parts
77  fp->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
78  }
79  }
80  };
81 
82  if( aOptions & IPO_SINGLE_CLICK )
83  makeNewItem( controls()->GetCursorPosition() );
84 
85  auto setCursor =
86  [&]()
87  {
88  if( !newItem )
90  else
92  };
93 
94  // Set initial cursor
95  setCursor();
96 
97  // Main loop: keep receiving events
98  while( TOOL_EVENT* evt = Wait() )
99  {
100  setCursor();
101 
102  VECTOR2I cursorPos = controls()->GetCursorPosition();
103  aPlacer->m_modifiers = evt->Modifier();
104 
105  auto cleanup =
106  [&] ()
107  {
108  newItem = nullptr;
109  preview.Clear();
110  view()->Update( &preview );
111  controls()->SetAutoPan( false );
112  controls()->CaptureCursor( false );
113  controls()->ShowCursor( true );
114  };
115 
116  if( evt->IsCancelInteractive() )
117  {
118  if( aOptions & IPO_SINGLE_CLICK )
119  {
120  cleanup();
121  frame()->PopTool( aTool );
122  break;
123  }
124  else if( newItem )
125  cleanup();
126  else
127  {
128  frame()->PopTool( aTool );
129  break;
130  }
131  }
132  else if( evt->IsActivate() )
133  {
134  if( newItem )
135  cleanup();
136 
137  if( evt->IsPointEditor() )
138  {
139  // don't exit (the point editor runs in the background)
140  }
141  else if( evt->IsMoveTool() )
142  {
143  // leave ourselves on the stack so we come back after the move
144  break;
145  }
146  else
147  {
148  frame()->PopTool( aTool );
149  break;
150  }
151  }
152  else if( evt->IsClick( BUT_LEFT ) )
153  {
154  if( !newItem )
155  {
156  // create the item if possible
157  makeNewItem( cursorPos );
158 
159  // no item created, so wait for another click
160  if( !newItem )
161  continue;
162 
163  controls()->CaptureCursor( true );
164  controls()->SetAutoPan( true );
165  }
166  else
167  {
168  auto oldFlags = newItem->GetFlags();
169  newItem->ClearFlags();
170 
171  if( !aPlacer->PlaceItem( newItem.get(), commit ) )
172  {
173  newItem->SetFlags( oldFlags );
174  continue;
175  }
176 
177  preview.Clear();
178  newItem.release();
179  commit.Push( aCommitMessage );
180 
181  controls()->CaptureCursor( false );
182  controls()->SetAutoPan( false );
183  controls()->ShowCursor( true );
184 
185  if( !( aOptions & IPO_REPEAT ) )
186  break;
187 
188  if( aOptions & IPO_SINGLE_CLICK )
189  makeNewItem( controls()->GetCursorPosition() );
190 
191  setCursor();
192  }
193  }
194  else if( evt->IsClick( BUT_RIGHT ) )
195  {
197  }
198  else if( evt->IsAction( &PCB_ACTIONS::trackViaSizeChanged ) )
199  {
201  }
202  else if( newItem && evt->Category() == TC_COMMAND )
203  {
204  /*
205  * Handle any events that can affect the item as we move it around
206  */
207  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
208  {
209  const int rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
210  newItem->Rotate( newItem->GetPosition(), rotationAngle );
211  view()->Update( &preview );
212  }
213  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
214  {
215  newItem->Flip( newItem->GetPosition(), frame()->Settings().m_FlipLeftRight );
216  view()->Update( &preview );
217  }
218  else if( evt->IsAction( &PCB_ACTIONS::viaSizeInc )
219  || evt->IsAction( &PCB_ACTIONS::viaSizeDec ) )
220  {
221  // Refresh preview after event runs
223  }
224  else if( evt->IsAction( &ACTIONS::refreshPreview ) )
225  {
226  preview.Clear();
227  newItem.release();
228 
229  makeNewItem( (wxPoint) cursorPos );
230  aPlacer->SnapItem( newItem.get() );
231  view()->Update( &preview );
232  }
233  }
234  else if( newItem && evt->IsMotion() )
235  {
236  // track the cursor
237  newItem->SetPosition( (wxPoint) cursorPos );
238  aPlacer->SnapItem( newItem.get() );
239 
240  // Show a preview of the item
241  view()->Update( &preview );
242  }
243  else
244  {
245  evt->SetPassEvent();
246  }
247  }
248 
249  view()->Remove( &preview );
251 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:94
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
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:296
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:219
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:141
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:299
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
void SetCurrentCursor(KICURSOR cursor)
Function SetCurrentCursor Set the current cursor shape for this panel.
virtual void Remove(VIEW_ITEM *aItem) override
Function Remove() Removes a VIEW_ITEM from the view.
Definition: pcb_view.cpp:76
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:75
TOOL_MANAGER * GetManager() const
Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool.
Definition: tool_base.h:143
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, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:94
const PCBNEW_SELECTION & selection() const
Allow repeat placement of the item.
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
TOOL_EVENT.
Definition: tool_event.h:171
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)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
class FOOTPRINT, a footprint
Definition: typeinfo.h:89
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:108
Handle the rotate action in the loop by calling the item's rotate method.
KIGFX::VIEW_CONTROLS * controls() const
PCBNEW_SETTINGS & Settings()
void Activate()
Function Activate() Runs the tool.
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction) const
Function RunOnChildren.
Definition: footprint.cpp:1066
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Function Add() Adds a VIEW_ITEM to the view.
Definition: pcb_view.cpp:59
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)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:297
static TOOL_ACTION refreshPreview
Definition: actions.h:104
VECTOR2D GetCursorPosition() const
Returns 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_FOOTPRINT_T, PENCIL, PLACE, INTERACTIVE_PLACER_BASE::PlaceItem(), TOOLS_HOLDER::PopTool(), BOARD_COMMIT::Push(), TOOLS_HOLDER::PushTool(), ACTIONS::refreshPreview, KIGFX::PCB_VIEW::Remove(), TOOL_MANAGER::RunAction(), FOOTPRINT::RunOnChildren(), 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 1089 of file router_tool.cpp.

1090 {
1091  PNS::SIZES_SETTINGS sizes = m_router->Sizes();
1092  DIALOG_PNS_DIFF_PAIR_DIMENSIONS settingsDlg( frame(), sizes );
1093 
1094  if( settingsDlg.ShowModal() == wxID_OK )
1095  {
1096  m_router->UpdateSizes( sizes );
1097  m_savedSizes = sizes;
1098 
1100  bds.SetCustomDiffPairWidth( sizes.DiffPairWidth() );
1101  bds.SetCustomDiffPairGap( sizes.DiffPairGap() );
1102  bds.SetCustomDiffPairViaGap( sizes.DiffPairViaGap() );
1103  }
1104 
1105  return 0;
1106 }
void SetCustomDiffPairViaGap(int aGap)
Function SetCustomDiffPairViaGap 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:559
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:219
PCB_BASE_EDIT_FRAME * frame() const
void SetCustomDiffPairWidth(int aWidth)
Function SetCustomDiffPairWidth Sets custom track width for differential pairs (i....
ROUTER * m_router
Definition: pns_tool_base.h:78
void SetCustomDiffPairGap(int aGap)
Function SetCustomDiffPairGap Sets custom gap for differential pairs (i.e.
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:345
BOARD * GetBoard() const
BOARD_DESIGN_SETTINGS contains 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 961 of file router_tool.cpp.

962 {
964 
966  controls()->SetAutoPan( false );
967  controls()->ForceCursorPosition( false );
968  frame()->UndoRedoBlock( false );
969  highlightNet( false );
970 
971  return true;
972 }
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
void SetCurrentCursor(KICURSOR cursor)
Function SetCurrentCursor Set the current cursor shape for this panel.
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))
Function ForceCursorPosition() Places the cursor immediately at a given point.
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
void StopRouting()
Definition: pns_router.cpp:449
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 POINT_EDITOR::addCorner(), AUTOPLACE_TOOL::autoplace(), PCB_TOOL_BASE::canvas(), ZONE_FILLER_TOOL::CheckAllZones(), PNS::TOOL_BASE::checkSnap(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), CustomTrackWidthDialog(), FOOTPRINT_EDITOR_TOOLS::DeleteFootprint(), PCB_TOOL_BASE::displayOptions(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DpDimensionsDialog(), 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(), PCB_EDITOR_CONTROL::ExportSpecctraDSN(), ZONE_FILLER_TOOL::FillAllZones(), EDIT_TOOL::FilletTracks(), finishInteractive(), EDIT_TOOL::Flip(), PCB_EDITOR_CONTROL::FlipPcbView(), GLOBAL_EDIT_TOOL::GlobalDeletions(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), PCB_EDITOR_CONTROL::ImportSpecctraSession(), Init(), SELECTION_TOOL::Init(), EDIT_TOOL::Init(), InlineBreakTrack(), InlineDrag(), PCBNEW_PICKER_TOOL::Main(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), onViaCommand(), PCBNEW_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), performDragging(), performRouting(), LENGTH_TUNER_TOOL::performTuning(), GROUP_TOOL::PickNewMember(), PCBNEW_CONTROL::placeBoardItems(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), prepareInteractive(), PAD_TOOL::pushPadSettings(), PAD_TOOL::recombinePad(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), PNS::TOOL_BASE::Reset(), SelectCopperLayerPair(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), POINT_EDITOR::setEditedPoint(), SettingsDialog(), GLOBAL_EDIT_TOOL::swapBoardItem(), GLOBAL_EDIT_TOOL::SwapLayers(), switchLayerOnViaPlacement(), PCB_EDITOR_CONTROL::UpdateSchematicFromPCB(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillAll().

◆ getEditFrame()

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

Function getEditFrame()

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

Definition at line 187 of file tool_base.h.

188  {
189 #if !defined( QA_TEST ) // Dynamic casts give the linker a siezure in the test framework
190  wxASSERT( dynamic_cast<T*>( getToolHolderInt() ) );
191 #endif
192  return static_cast<T*>( getToolHolderInt() );
193  }
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

Function GetId() Returns 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
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:214

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

Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool.

Returns
Instance of the TOOL_MANAGER. If there is no TOOL_MANAGER associated, it returns NULL.

Definition at line 143 of file tool_base.h.

144  {
145  return m_toolMgr;
146  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219

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

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 201 of file tool_base.h.

202  {
203  EDA_ITEM* m = getModelInt();
204 #if !defined( QA_TEST ) // Dynamic casts give the linker a siezure in the test framework
205  wxASSERT( dynamic_cast<T*>( m ) );
206 #endif
207  return static_cast<T*>( m );
208  }
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:54
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148

References TOOL_BASE::getModelInt().

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

◆ GetName()

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

Function GetName() Returns 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 132 of file tool_base.h.

133  {
134  return m_toolName;
135  }
std::string m_toolName
Name of the tool.
Definition: tool_base.h:218

References TOOL_BASE::m_toolName.

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

◆ GetRouterMode()

PNS::PNS_MODE ROUTER_TOOL::GetRouterMode ( )

Definition at line 1130 of file router_tool.cpp.

1131 {
1132  return m_router->Settings().Mode();
1133 }
ROUTER * m_router
Definition: pns_tool_base.h:78
PNS_MODE Mode() const
Returns the routing mode.
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:200

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 525 of file router_tool.cpp.

526 {
527  int tl = getView()->GetTopLayer();
528 
529  if( m_startItem )
530  {
531  const LAYER_RANGE& ls = m_startItem->Layers();
532 
533  if( ls.Overlaps( tl ) )
534  return tl;
535  else
536  return ls.Start();
537  }
538 
539  return tl;
540 }
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:68
int Start() const
Definition: pns_layerset.h:83
virtual int GetTopLayer() const
Definition: view.cpp:829
ITEM * m_startItem
Definition: pns_tool_base.h:69
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
LAYER_RANGE.
Definition: pns_layerset.h:32
const LAYER_RANGE & Layers() const
Definition: pns_item.h:152

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

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 110 of file tool_base.h.

111  {
112  return m_type;
113  }
TOOL_TYPE m_type
Stores the type of the tool.
Definition: tool_base.h:211

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

Function getView()

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:290
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219

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(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_EDIT_TOOL::DoDelete(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), MICROWAVE_TOOL::drawMicrowaveInductor(), PL_DRAWING_TOOLS::DrawShape(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_EDITOR_CONTROL::FindComponentAndItem(), EE_SELECTION_TOOL::GetNode(), getStartLayer(), PCBNEW_CONTROL::GridResetOrigin(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::GuessSelectionCandidates(), PL_SELECTION_TOOL::highlight(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCB_INSPECTION_TOOL::highlightNet(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::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(), POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), LIB_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PNS::TOOL_BASE::pickSingleItem(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), PCB_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::Selectable(), SELECTION_TOOL::SelectAll(), EE_SELECTION_TOOL::SelectAll(), PL_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), PL_SELECTION_TOOL::unhighlight(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), SCH_EDITOR_CONTROL::UpdateFind(), PL_POINT_EDITOR::updateItem(), 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(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCB_VIEWER_TOOLS::view(), PCB_TOOL_BASE::view(), SELECTION_TOOL::zoomFitSelection(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and SELECTION_TOOL::~SELECTION_TOOL().

◆ getViewControls()

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

Function getViewControls()

Returns 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:219
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:292

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

Referenced by EE_POINT_EDITOR::addCorner(), 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(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), LIB_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), PCB_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_INSPECTION_TOOL::HighlightNetTool(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), COMMON_TOOLS::OnGridChanged(), POINT_EDITOR::OnSelectionChange(), LIB_EDIT_TOOL::Paste(), performDragging(), LENGTH_TUNER_TOOL::performTuning(), LIB_DRAWING_TOOLS::PlaceAnchor(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_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(), POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PICKER_TOOL::setControls(), PCBNEW_PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), PL_POINT_EDITOR::setEditedPoint(), POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), 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

Function Go()

Defines which state (aStateFunc) to go when a certain event arrives (aConditions). No conditions means any event.

Definition at line 129 of file tool_interactive.h.

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

References TOOL_INTERACTIVE::goInternal().

Referenced by ZOOM_TOOL::setTransitions(), AUTOPLACE_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), PCB_REANNOTATE_TOOL::setTransitions(), GERBVIEW_INSPECTION_TOOL::setTransitions(), setTransitions(), LIB_PIN_TOOL::setTransitions(), SCH_NAVIGATE_TOOL::setTransitions(), LIB_MOVE_TOOL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), EE_POINT_EDITOR::setTransitions(), PL_POINT_EDITOR::setTransitions(), COMMON_CONTROL::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), CONVERT_TOOL::setTransitions(), DRC_TOOL::setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), POINT_EDITOR::setTransitions(), LIB_DRAWING_TOOLS::setTransitions(), MICROWAVE_TOOL::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), GERBVIEW_CONTROL::setTransitions(), PAD_TOOL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), GROUP_TOOL::setTransitions(), LIB_CONTROL::setTransitions(), LIB_EDIT_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), PL_EDIT_TOOL::setTransitions(), FOOTPRINT_EDITOR_TOOLS::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), PCBNEW_CONTROL::setTransitions(), EDA_3D_CONTROLLER::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), CVPCB_CONTROL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), PCBNEW_PICKER_TOOL::setTransitions(), PICKER_TOOL::setTransitions(), PCB_INSPECTION_TOOL::setTransitions(), PCB_EDITOR_CONTROL::setTransitions(), DRAWING_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), SELECTION_TOOL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), and EE_SELECTION_TOOL::setTransitions().

◆ handleCommonEvents()

void ROUTER_TOOL::handleCommonEvents ( const TOOL_EVENT evt)
private

Definition at line 481 of file router_tool.cpp.

482 {
483 #ifdef DEBUG
484  if( aEvent.IsKeyPressed() )
485  {
486  switch( aEvent.KeyCode() )
487  {
488  case '0':
489  {
490  auto logger = m_router->Logger();
491  if( ! logger )
492  return;
493 
494  FILE *f = fopen("/tmp/pns.log", "wb");
495  wxLogTrace( "PNS", "saving drag/route log...\n" );
496 
497  const auto& events = logger->GetEvents();
498 
499  for( auto evt : events)
500  {
501  wxString id = "null";
502  if( evt.item && evt.item->Parent() )
503  id = evt.item->Parent()->m_Uuid.AsString();
504 
505  fprintf(f, "event %d %d %d %s\n", evt.p.x, evt.p.y, evt.type, (const char*) id.c_str() );
506  }
507 
508  fclose(f);
509 
510  // Export as *.kicad_pcb format, using a strategy which is specifically chosen
511  // as an example on how it could also be used to send it to the system clipboard.
512 
513  PCB_IO pcb_io;
514 
515  pcb_io.Save("/tmp/pns.dump", m_iface->GetBoard(), nullptr );
516 
517  break;
518  }
519  }
520  }
521 #endif
522 }
BOARD * GetBoard() const
PCB_IO is a PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
ROUTER * m_router
Definition: pns_tool_base.h:78
LOGGER * Logger()
Definition: pns_router.cpp:531
PNS_KICAD_IFACE * m_iface
Definition: pns_tool_base.h:77
virtual void Save(const wxString &aFileName, BOARD *aBoard, const PROPERTIES *aProperties=NULL) override
Function Save will write aBoard to a storage file in a format that this PLUGIN implementation knows a...

References PNS_KICAD_IFACE_BASE::GetBoard(), TOOL_EVENT::IsKeyPressed(), TOOL_EVENT::KeyCode(), PNS::ROUTER::Logger(), PNS::TOOL_BASE::m_iface, PNS::TOOL_BASE::m_router, and PCB_IO::Save().

Referenced by performDragging(), and performRouting().

◆ highlightNet()

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

Definition at line 223 of file pns_tool_base.cpp.

224 {
226 
227  if( aNetcode >= 0 && aEnabled )
228  {
229  // If the user has previously set the current net to be highlighted,
230  // we assume they want to keep it highlighted after routing
232  && rs->GetHighlightNetCodes().count( aNetcode ) );
233 
234  rs->SetHighlight( true, aNetcode );
235  }
236  else
237  {
238  if( !m_startHighlight )
239  rs->SetHighlight( false );
240 
241  m_startHighlight = false;
242  }
243 
245 }
RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output surfac...
bool IsHighlightEnabled() const
Function IsHighlightEnabled Returns current highlight setting.
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:201
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
virtual RENDER_SETTINGS * GetSettings()=0
Function GetAdapter Returns pointer to current settings that are going to be used when drawing items.
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Function SetHighlight Turns on/off highlighting - it may be done for the active layer or the specifie...
const std::set< int > & GetHighlightNetCodes() const
Function GetHighlightNetCode Returns netcode of currently highlighted net.
void UpdateAllLayersColor()
Function UpdateAllLayersColor() Applies the new coloring scheme to all layers.
Definition: view.cpp:776

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

Function Init() 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 414 of file router_tool.cpp.

415 {
416  PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
417 
418  wxASSERT( frame );
419 
420  auto& menu = m_menu.GetMenu();
421  menu.SetTitle( _( "Interactive Router" ) );
422 
423  auto trackViaMenu = std::make_shared<TRACK_WIDTH_MENU>( *frame );
424  trackViaMenu->SetTool( this );
425  m_menu.AddSubMenu( trackViaMenu );
426 
427  auto diffPairMenu = std::make_shared<DIFF_PAIR_MENU>( *frame );
428  diffPairMenu->SetTool( this );
429  m_menu.AddSubMenu( diffPairMenu );
430 
432 
433  menu.AddSeparator();
434 
440 
443 
444 // Add( ACT_AutoEndRoute ); // fixme: not implemented yet. Sorry.
452 
453  menu.AddSeparator();
454 
455  auto diffPairCond =
456  [this]( const SELECTION& )
457  {
459  };
460 
461  menu.AddMenu( trackViaMenu.get(), SELECTION_CONDITIONS::ShowAlways );
462  menu.AddMenu( diffPairMenu.get(), diffPairCond );
463 
465 
466  menu.AddSeparator();
467 
469 
470  return true;
471 }
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
void AddStandardSubMenus(TOOL_MENU &aMenu)
Function CreateBasicMenu.
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
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."), via_microvia_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::MICROVIA)
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:141
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:140
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."), change_entry_orient_xpm)
static const TOOL_ACTION ACT_SwitchRounding("pcbnew.InteractiveRouter.SwitchRounding", AS_CONTEXT, 0, LEGACY_HK_NAME("Switch Corner Rounding"), _("Switch Corner Rounding"), _("Switches the corner type of the currently routed track."), switch_corner_rounding_shape_xpm)
static const TOOL_ACTION ACT_EndTrack("pcbnew.InteractiveRouter.EndTrack", AS_CONTEXT, WXK_END, "", _("Finish Track"), _("Stops laying the current track."), checked_ok_xpm)
PCB_BASE_EDIT_FRAME * frame() const
static TOOL_ACTION routerSettingsDialog
Activation of the Push and Shove settings dialogs.
Definition: pcb_actions.h:196
#define _(s)
static const TOOL_ACTION ACT_UndoLastSegment("pcbnew.InteractiveRouter.UndoLastSegment", AS_CONTEXT, WXK_BACK, "", _("Undo last segment"), _("Stops laying the current track."), checked_ok_xpm)
ROUTER * m_router
Definition: pns_tool_base.h:78
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."), select_w_layer_xpm, AF_NONE,(void *)(VIA_ACTION_FLAGS::VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
static TOOL_ACTION breakTrack
Break a single track into two segments at the cursor.
Definition: pcb_actions.h:135
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."), via_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::VIA)
void SetTitle(const wxString &aTitle) override
Sets title for the menu.
Definition: action_menu.cpp:89
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:179
void AddSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Function CreateSubMenu.
Definition: tool_menu.cpp:52
PCB_EDIT_FRAME is the main frame for Pcbnew.
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."), via_buried_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::BLIND_VIA)
ROUTER_MODE Mode() const
Definition: pns_router.h:136
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."), select_w_layer_xpm, AF_NONE,(void *)(VIA_ACTION_FLAGS::BLIND_VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:182

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(), TOOL_INTERACTIVE::m_menu, PNS::TOOL_BASE::m_router, PNS::ROUTER::Mode(), PNS::PNS_MODE_ROUTE_DIFF_PAIR, PCB_ACTIONS::routeDiffPair, PCB_ACTIONS::routerSettingsDialog, PCB_ACTIONS::routeSingleTrack, ACTION_MENU::SetTitle(), and SELECTION_CONDITIONS::ShowAlways().

◆ InlineBreakTrack()

int ROUTER_TOOL::InlineBreakTrack ( const TOOL_EVENT aEvent)

Definition at line 1630 of file router_tool.cpp.

1631 {
1632  const auto& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
1633 
1634  if( selection.Size() != 1 )
1635  return 0;
1636 
1637  const BOARD_CONNECTED_ITEM* item = static_cast<const BOARD_CONNECTED_ITEM*>( selection.Front() );
1638 
1639  if( item->Type() != PCB_TRACE_T )
1640  return 0;
1641 
1642  Activate();
1643 
1645  m_router->SyncWorld();
1647 
1648  TOOL_MANAGER* toolManager = frame()->GetToolManager();
1649 
1650  if( toolManager->IsContextMenuActive() )
1651  {
1652  // If we're here from a context menu then we need to get the position of the
1653  // cursor when the context menu was invoked. This is used to figure out the
1654  // break point on the track.
1655  VECTOR2I CurrPos = toolManager->GetMenuCursorPos();
1656  m_startSnapPoint = snapToItem( true, m_startItem, toolManager->GetMenuCursorPos() );
1657  }
1658  else
1659  {
1660  // If we're here from a hotkey, then get the current mouse position so we know
1661  // where to break the track.
1662  m_startSnapPoint = snapToItem( true, m_startItem, controls()->GetCursorPosition() );
1663  }
1664 
1665  if( m_startItem && m_startItem->IsLocked() )
1666  {
1667  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1668  wxOK | wxCANCEL | wxICON_WARNING );
1669  dlg.SetOKLabel( _( "Break Track" ) );
1670  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1671 
1672  if( dlg.ShowModal() == wxID_CANCEL )
1673  return 0;
1674  }
1675 
1676  frame()->UndoRedoBlock( true );
1677  breakTrack();
1678 
1679  if( m_router->RoutingInProgress() )
1680  m_router->StopRouting();
1681 
1682  frame()->UndoRedoBlock( false );
1683 
1684  return 0;
1685 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:44
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
void SyncWorld()
Definition: pns_router.cpp:93
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:141
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
bool IsContextMenuActive()
True while processing a context menu.
Definition: tool_manager.h:407
void breakTrack()
BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected and have...
const VECTOR2I snapToItem(bool aEnabled, ITEM *aItem, VECTOR2I aP)
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
PCB_BASE_EDIT_FRAME * frame() const
TOOL_MANAGER.
Definition: tool_manager.h:51
#define _(s)
const PCBNEW_SELECTION & selection() const
ITEM * FindItemByParent(const BOARD_ITEM *aParent)
Definition: pns_node.cpp:1455
ITEM * m_startItem
Definition: pns_tool_base.h:69
ROUTER * m_router
Definition: pns_tool_base.h:78
void StopRouting()
Definition: pns_router.cpp:449
KIGFX::VIEW_CONTROLS * controls() const
int Size() const
Returns the number of selected parts.
Definition: selection.h:126
bool IsLocked() const
Definition: pns_item.h:242
void Activate()
Function Activate() Runs the tool.
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:76
bool RoutingInProgress() const
Definition: pns_router.cpp:114
VECTOR2D GetMenuCursorPos()
Definition: tool_manager.h:436
NODE * GetWorld() const
Definition: pns_router.h:155
EDA_ITEM * Front() const
Definition: selection.h:201
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181

References _, TOOL_INTERACTIVE::Activate(), breakTrack(), PCB_TOOL_BASE::controls(), KIDIALOG::DoNotShowCheckbox(), PNS::NODE::FindItemByParent(), PCB_TOOL_BASE::frame(), SELECTION::Front(), TOOL_MANAGER::GetMenuCursorPos(), TOOL_MANAGER::GetTool(), TOOLS_HOLDER::GetToolManager(), PNS::ROUTER::GetWorld(), TOOL_MANAGER::IsContextMenuActive(), PNS::ITEM::IsLocked(), PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, TOOL_BASE::m_toolMgr, PCB_TRACE_T, PNS::ROUTER::RoutingInProgress(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, 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 1436 of file router_tool.cpp.

1437 {
1438  const auto& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
1439 
1440  if( selection.Empty() )
1442 
1443  if( selection.Size() != 1 )
1444  return 0;
1445 
1446  const BOARD_ITEM* item = static_cast<const BOARD_ITEM*>( selection.Front() );
1447 
1448  if( item->Type() != PCB_TRACE_T
1449  && item->Type() != PCB_VIA_T
1450  && item->Type() != PCB_FOOTPRINT_T )
1451  {
1452  return 0;
1453  }
1454 
1455  Activate();
1456 
1458  m_router->SyncWorld();
1459  m_startItem = nullptr;
1460 
1461  PNS::ITEM* startItem = nullptr;
1462  PNS::ITEM_SET itemsToDrag;
1463  const FOOTPRINT* footprint = nullptr;
1464 
1465  if( item->Type() == PCB_FOOTPRINT_T )
1466  {
1467  footprint = static_cast<const FOOTPRINT*>(item);
1468 
1469  for( const PAD* pad : footprint->Pads() )
1470  {
1471  PNS::ITEM* solid = m_router->GetWorld()->FindItemByParent( pad );
1472 
1473  if( solid )
1474  itemsToDrag.Add( solid );
1475  }
1476  }
1477  else
1478  {
1479  startItem = m_router->GetWorld()->FindItemByParent( item );
1480 
1481  if( startItem)
1482  itemsToDrag.Add( startItem );
1483  }
1484 
1485  if( startItem && startItem->IsLocked() )
1486  {
1487  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1488  wxOK | wxCANCEL | wxICON_WARNING );
1489  dlg.SetOKLabel( _( "Drag Anyway" ) );
1490  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1491 
1492  if( dlg.ShowModal() == wxID_CANCEL )
1493  return 0;
1494  }
1495 
1496  VECTOR2I p0 = controls()->GetCursorPosition( false );
1497  VECTOR2I p = p0;
1498 
1499  if( startItem )
1500  p = snapToItem( true, startItem, p0 );
1501 
1502  int dragMode = aEvent.Parameter<int64_t> ();
1503 
1504  bool dragStarted = m_router->StartDragging( p, itemsToDrag, dragMode );
1505 
1506  if( !dragStarted )
1507  return 0;
1508 
1509  m_gridHelper->SetAuxAxes( true, p );
1510  controls()->ShowCursor( true );
1511  controls()->ForceCursorPosition( false );
1512  controls()->SetAutoPan( true );
1513  frame()->UndoRedoBlock( true );
1514 
1515  view()->ClearPreview();
1516  view()->InitPreview();
1517 
1518  auto setCursor =
1519  [&]()
1520  {
1522  };
1523 
1524  // Set initial cursor
1525  setCursor();
1526 
1527  while( TOOL_EVENT* evt = Wait() )
1528  {
1529  setCursor();
1530 
1531  if( evt->IsCancelInteractive() )
1532  {
1533  break;
1534  }
1535  else if( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
1536  {
1537  updateEndItem( *evt );
1539 
1540  if( footprint )
1541  {
1542  VECTOR2I offset = m_endSnapPoint - p;
1543  BOARD_ITEM* previewItem;
1544 
1545  view()->ClearPreview();
1546 
1547  for( BOARD_ITEM* drawing : footprint->GraphicalItems() )
1548  {
1549  previewItem = static_cast<BOARD_ITEM*>( drawing->Clone() );
1550 
1551  if( drawing->Type() == PCB_FP_SHAPE_T )
1552  {
1553  FP_SHAPE* shape = static_cast<FP_SHAPE*>( previewItem );
1554  shape->PCB_SHAPE::Move( (wxPoint) offset );
1555  }
1556  else
1557  {
1558  previewItem->Move( offset );
1559  }
1560 
1561  view()->AddToPreview( previewItem );
1562  view()->Hide( drawing, true );
1563  }
1564 
1565  previewItem = static_cast<BOARD_ITEM*>( footprint->Reference().Clone() );
1566  previewItem->Move( offset );
1567  view()->AddToPreview( previewItem );
1568  view()->Hide( &footprint->Reference() );
1569 
1570  previewItem = static_cast<BOARD_ITEM*>( footprint->Value().Clone() );
1571  previewItem->Move( offset );
1572  view()->AddToPreview( previewItem );
1573  view()->Hide( &footprint->Value() );
1574 
1575  for( ZONE* zone : footprint->Zones() )
1576  {
1577  previewItem = static_cast<BOARD_ITEM*>( zone->Clone() );
1578  previewItem->Move( offset );
1579  view()->AddToPreview( previewItem );
1580  view()->Hide( zone, true );
1581  }
1582  }
1583  }
1584  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
1585  {
1586  updateEndItem( *evt );
1588  break;
1589  }
1590  else if( evt->Category() == TC_COMMAND )
1591  {
1592  // disallow editing commands
1593  if( evt->IsAction( &ACTIONS::cut )
1594  || evt->IsAction( &ACTIONS::copy )
1595  || evt->IsAction( &ACTIONS::paste )
1596  || evt->IsAction( &ACTIONS::pasteSpecial ) )
1597  {
1598  wxBell();
1599  }
1600  }
1601  }
1602 
1603  if( footprint )
1604  {
1605  for( BOARD_ITEM* drawing : footprint->GraphicalItems() )
1606  view()->Hide( drawing, false );
1607 
1608  view()->Hide( &footprint->Reference(), false );
1609  view()->Hide( &footprint->Value(), false );
1610 
1611  for( ZONE* zone : footprint->Zones() )
1612  view()->Hide( zone, false );
1613 
1614  view()->ClearPreview();
1615  view()->ShowPreview( false );
1616  }
1617 
1618  if( m_router->RoutingInProgress() )
1619  m_router->StopRouting();
1620 
1621  m_gridHelper->SetAuxAxes( false );
1622  controls()->SetAutoPan( false );
1623  controls()->ForceCursorPosition( false );
1624  frame()->UndoRedoBlock( false );
1625 
1626  return 0;
1627 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hides the item in the view (e.g.
Definition: view.cpp:1480
ITEM.
Definition: pns_item.h:54
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: fp_text.cpp:355
GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:44
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
Definition: board_item.h:86
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1554
SELECTION_TOOL.
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:219
void SyncWorld()
Definition: pns_router.cpp:93
void InitPreview()
Definition: view.cpp:1547
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:141
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
void Add(const LINE &aLine)
Definition: pns_itemset.cpp:32
void SetCurrentCursor(KICURSOR cursor)
Function SetCurrentCursor Set the current cursor shape for this panel.
const VECTOR2I snapToItem(bool aEnabled, ITEM *aItem, VECTOR2I aP)
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
PADS & Pads()
Definition: footprint.h:182
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:473
void ShowPreview(bool aShow=true)
Definition: view.cpp:1568
FP_TEXT & Reference()
Definition: footprint.h:474
PCB_BASE_EDIT_FRAME * frame() const
FP_ZONES & Zones()
Definition: footprint.h:188
static TOOL_ACTION copy
Definition: actions.h:70
virtual void updateEndItem(const TOOL_EVENT &aEvent)
void SetAuxAxes(bool aEnable, const VECTOR2I &aOrigin=VECTOR2I(0, 0))
#define _(s)
const PCBNEW_SELECTION & selection() const
ITEM * FindItemByParent(const BOARD_ITEM *aParent)
Definition: pns_node.cpp:1455
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.
Definition: board_item.h:292
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
TOOL_EVENT.
Definition: tool_event.h:171
ITEM * m_startItem
Definition: pns_tool_base.h:69
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:404
FOOTPRINT * footprint() const
void ClearPreview()
Definition: view.cpp:1535
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:185
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
ZONE handles a list of polygons defining a copper zone.
Definition: zone.h:57
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:256
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns 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:120
class FOOTPRINT, a footprint
Definition: typeinfo.h:89
static TOOL_ACTION pasteSpecial
Definition: actions.h:72
void StopRouting()
Definition: pns_router.cpp:449
KIGFX::VIEW_CONTROLS * controls() const
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
bool StartDragging(const VECTOR2I &aP, ITEM *aItem, int aDragMode=DM_ANY)
Definition: pns_router.cpp:128
static void NeighboringSegmentFilter(const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector)
int Size() const
Returns the number of selected parts.
Definition: selection.h:126
bool IsLocked() const
Definition: pns_item.h:242
void Activate()
Function Activate() Runs the tool.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
bool RoutingInProgress() const
Definition: pns_router.cpp:114
Definition: pad.h:59
NODE * GetWorld() const
Definition: pns_router.h:155
static TOOL_ACTION paste
Definition: actions.h:71
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:59
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:201
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181

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, KIDIALOG::DoNotShowCheckbox(), 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(), TOOL_MANAGER::GetTool(), PNS::ROUTER::GetWorld(), FOOTPRINT::GraphicalItems(), KIGFX::VIEW::Hide(), KIGFX::VIEW::InitPreview(), PNS::ITEM::IsLocked(), 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, PNS::ROUTER::Move(), BOARD_ITEM::Move(), NeighboringSegmentFilter(), FOOTPRINT::Pads(), TOOL_EVENT::Parameter(), ACTIONS::paste, ACTIONS::pasteSpecial, PCB_FOOTPRINT_T, PCB_FP_SHAPE_T, PCB_TRACE_T, PCB_VIA_T, FOOTPRINT::Reference(), 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::ShowCursor(), KIDIALOG::ShowModal(), 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()

bool PCB_TOOL_BASE::IsFootprintEditor ( ) const
inlineinherited

◆ 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:219
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:214
bool IsToolActive(TOOL_ID aId) const
Function IsToolActive() Returns 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 EDIT_TOOL::isRouterActive(), and onViaCommand().

◆ MainLoop()

int ROUTER_TOOL::MainLoop ( const TOOL_EVENT aEvent)

Definition at line 1143 of file router_tool.cpp.

1144 {
1145  PNS::ROUTER_MODE mode = aEvent.Parameter<PNS::ROUTER_MODE>();
1146  PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
1147 
1148  // Deselect all items
1150 
1151  std::string tool = aEvent.GetCommandStr().get();
1152  frame->PushTool( tool );
1153  Activate();
1154 
1155  m_router->SetMode( mode );
1156 
1157  VIEW_CONTROLS* ctls = getViewControls();
1158  ctls->ShowCursor( true );
1159  ctls->ForceCursorPosition( false );
1160  m_cancelled = false;
1161 
1162  // Prime the pump
1163  if( aEvent.HasPosition() )
1164  m_toolMgr->PrimeTool( ctls->GetCursorPosition( false ) );
1165 
1166  auto setCursor =
1167  [&]()
1168  {
1170  };
1171 
1172  // Set initial cursor
1173  setCursor();
1174 
1175  // Main loop: keep receiving events
1176  while( TOOL_EVENT* evt = Wait() )
1177  {
1178  setCursor();
1179 
1180  if( evt->IsCancelInteractive() )
1181  {
1182  frame->PopTool( tool );
1183  break;
1184  }
1185  else if( evt->IsActivate() )
1186  {
1187  if( evt->IsMoveTool() )
1188  {
1189  // leave ourselves on the stack so we come back after the move
1190  break;
1191  }
1192  else
1193  {
1194  frame->PopTool( tool );
1195  break;
1196  }
1197  }
1198  else if( evt->Action() == TA_UNDO_REDO_PRE )
1199  {
1200  m_router->ClearWorld();
1201  }
1202  else if( evt->Action() == TA_UNDO_REDO_POST || evt->Action() == TA_MODEL_CHANGE )
1203  {
1204  m_router->SyncWorld();
1205  }
1206  else if( evt->IsMotion() )
1207  {
1208  updateStartItem( *evt );
1209  }
1210  else if( evt->IsAction( &PCB_ACTIONS::dragFreeAngle ) )
1211  {
1212  updateStartItem( *evt, true );
1214  }
1215  else if( evt->IsAction( &PCB_ACTIONS::drag45Degree ) )
1216  {
1217  updateStartItem( *evt, true );
1219  }
1220  else if( evt->IsAction( &PCB_ACTIONS::breakTrack ) )
1221  {
1222  updateStartItem( *evt, true );
1223  breakTrack( );
1224  }
1225  else if( evt->IsClick( BUT_LEFT )
1226  || evt->IsAction( &PCB_ACTIONS::routeSingleTrack )
1227  || evt->IsAction( &PCB_ACTIONS::routeDiffPair ) )
1228  {
1229  if( evt->IsAction( &PCB_ACTIONS::routeSingleTrack )
1230  || evt->IsAction( &PCB_ACTIONS::routeDiffPair ) )
1231  {
1232  mode = evt->Parameter<PNS::ROUTER_MODE>();
1233  }
1234 
1235  updateStartItem( *evt );
1236 
1237  if( evt->HasPosition() )
1238  {
1239  if( evt->Modifier( MD_CTRL ) )
1241  else
1242  performRouting();
1243  }
1244  }
1245  else if( evt->IsAction( &ACT_PlaceThroughVia ) )
1246  {
1248  }
1249  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1250  {
1252  updateStartItem( *evt );
1253  }
1254  else if( evt->IsKeyPressed() )
1255  {
1256  // wxWidgets fails to correctly translate shifted keycodes on the wxEVT_CHAR_HOOK
1257  // event so we need to process the wxEVT_CHAR event that will follow as long as we
1258  // pass the event.
1259  evt->SetPassEvent();
1260  }
1261  else if( evt->IsClick( BUT_RIGHT ) )
1262  {
1264  }
1265  else
1266  {
1267  evt->SetPassEvent();
1268  }
1269 
1270  if( m_cancelled )
1271  {
1272  frame->PopTool( tool );
1273  break;
1274  }
1275  }
1276 
1277  // Store routing settings till the next invocation
1279 
1280  return 0;
1281 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:141
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
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)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:141
void PrimeTool(const VECTOR2D &aPosition)
Function PrimeTool() "Primes" a tool by sending a cursor left-click event with the mouse position set...
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:140
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:219
void SwitchLayer(int layer)
Definition: pns_router.cpp:486
void breakTrack()
void SetCurrentCursor(KICURSOR cursor)
Function SetCurrentCursor Set the current cursor shape for this panel.
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)
const PCBNEW_SELECTION & selection() const
void performRouting()
virtual void PopTool(const std::string &actionName)
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
TOOL_EVENT.
Definition: tool_event.h:171
ROUTER * m_router
Definition: pns_tool_base.h:78
VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (such a...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places 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:135
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."), via_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::VIA)
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
ROUTER_MODE
Definition: pns_router.h:68
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:289
void SetMode(ROUTER_MODE aMode)
Definition: pns_router.cpp:561
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:179
void performDragging(int aMode=PNS::DM_ANY)
PCB_EDIT_FRAME is the main frame for Pcbnew.
void Activate()
Function Activate() Runs the tool.
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition: tool_event.h:260
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:287
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:182

References ACT_PlaceThroughVia, TOOL_INTERACTIVE::Activate(), breakTrack(), PCB_ACTIONS::breakTrack, BUT_LEFT, BUT_RIGHT, 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, TOOL_EVENT::Parameter(), PENCIL, performDragging(), performRouting(), TOOLS_HOLDER::PopTool(), TOOL_MANAGER::PrimeTool(), TOOLS_HOLDER::PushTool(), PCB_ACTIONS::routeDiffPair, PCB_ACTIONS::routeSingleTrack, 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::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 1360 of file router_tool.cpp.

1361 {
1362  /*
1363  * If the collection contains a trivial line corner (two connected segments)
1364  * or a non-fanout-via (a via with no more than two connected segments), then
1365  * trim the collection down to a single item (which one won't matter since
1366  * they're all connected).
1367  */
1368 
1369  // First make sure we've got something that *might* match.
1370  int vias = aCollector.CountType( PCB_VIA_T );
1371  int traces = aCollector.CountType( PCB_TRACE_T );
1372  int arcs = aCollector.CountType( PCB_ARC_T );
1373 
1374  if( arcs > 0 || vias > 1 || traces > 2 || vias + traces < 1 )
1375  return;
1376 
1377  // Fetch first TRACK (via or trace) as our reference
1378  TRACK* reference = nullptr;
1379 
1380  for( int i = 0; !reference && i < aCollector.GetCount(); i++ )
1381  reference = dynamic_cast<TRACK*>( aCollector[i] );
1382 
1383  int refNet = reference->GetNetCode();
1384 
1385  wxPoint refPoint( aPt.x, aPt.y );
1386  STATUS_FLAGS flags = reference->IsPointOnEnds( refPoint, -1 );
1387 
1388  if( flags & STARTPOINT )
1389  refPoint = reference->GetStart();
1390  else if( flags & ENDPOINT )
1391  refPoint = reference->GetEnd();
1392 
1393  // Check all items to ensure that any TRACKs are co-terminus with the reference and on
1394  // the same net.
1395  for( int i = 0; i < aCollector.GetCount(); i++ )
1396  {
1397  TRACK* neighbor = dynamic_cast<TRACK*>( aCollector[i] );
1398 
1399  if( neighbor && neighbor != reference )
1400  {
1401  if( neighbor->GetNetCode() != refNet )
1402  return;
1403 
1404  if( neighbor->GetStart() != refPoint && neighbor->GetEnd() != refPoint )
1405  return;
1406  }
1407  }
1408 
1409  // Selection meets criteria; trim it to the reference item.
1410  aCollector.Empty();
1411  aCollector.Append( reference );
1412 }
void Empty()
Function Empty sets the list to empty.
Definition: collector.h:113
int GetNetCode() const
Function GetNetCode.
const wxPoint & GetStart() const
Definition: track.h:116
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
int CountType(KICAD_T aType)
Function CountType counts the number of items matching aType.
Definition: collector.h:252
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
void Append(EDA_ITEM *item)
Function Append adds an item to the end of the list.
Definition: collector.h:123
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:104
unsigned STATUS_FLAGS
Definition: eda_item.h:142
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: eda_item.h:111
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:185
const wxPoint & GetEnd() const
Definition: track.h:113
#define ENDPOINT
ends. (Used to support dragging.)
Definition: eda_item.h:112
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
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().

◆ onTrackViaSizeChanged()

int ROUTER_TOOL::onTrackViaSizeChanged ( const TOOL_EVENT aEvent)
private

Definition at line 1705 of file router_tool.cpp.

1706 {
1707  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
1708 
1709  if( !m_router->GetCurrentNets().empty() )
1710  m_iface->ImportSizes( sizes, nullptr, m_router->GetCurrentNets()[0] );
1711 
1712  m_router->UpdateSizes( sizes );
1713 
1714  // Changing the track width can affect the placement, so call the
1715  // move routine without changing the destination
1717 
1718  return 0;
1719 }
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:509
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:219
ROUTER * m_router
Definition: pns_tool_base.h:78
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:256
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:345
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 651 of file router_tool.cpp.

652 {
653  if( !IsToolActive() )
654  return 0;
655 
656  // First see if this is one of the switch layer commands
657  LSEQ layers = LSET( board()->GetEnabledLayers() & LSET::AllCuMask() ).Seq();
659  PCB_LAYER_ID targetLayer = UNDEFINED_LAYER;
660 
661  if( aEvent.IsAction( &PCB_ACTIONS::layerNext ) )
662  {
663  size_t idx = 0;
664 
665  for( size_t i = 0; i < layers.size(); i++ )
666  {
667  if( layers[i] == currentLayer )
668  {
669  idx = i;
670  break;
671  }
672  }
673 
674  idx = ( idx + 1 ) % layers.size();
675  targetLayer = layers[idx];
676  }
677  else if( aEvent.IsAction( &PCB_ACTIONS::layerPrev ) )
678  {
679  size_t idx = 0;
680 
681  for( size_t i = 0; i < layers.size(); i++ )
682  {
683  if( layers[i] == currentLayer )
684  {
685  idx = i;
686  break;
687  }
688  }
689 
690  idx = ( idx > 0 ) ? ( idx - 1 ) : ( layers.size() - 1 );
691  targetLayer = layers[idx];
692  }
693  else
694  {
695  targetLayer = getTargetLayerFromEvent( aEvent );
696 
697  if( targetLayer != UNDEFINED_LAYER )
698  {
699  if( targetLayer == currentLayer )
700  return 0;
701  }
702  }
703 
705  const int layerCount = bds.GetCopperLayerCount();
706 
709 
711 
712  VIATYPE viaType = VIATYPE::THROUGH;
713  bool selectLayer = false;
714 
715  // Otherwise it is one of the router-specific via commands
716  if( targetLayer == UNDEFINED_LAYER )
717  {
718  const int actViaFlags = aEvent.Parameter<intptr_t>();
719  selectLayer = actViaFlags & VIA_ACTION_FLAGS::SELECT_LAYER;
720 
721  viaType = getViaTypeFromFlags( actViaFlags );
722 
723  // ask the user for a target layer
724  if( selectLayer )
725  {
726  wxPoint dlgPosition = wxGetMousePosition();
727 
728  targetLayer = frame()->SelectLayer( static_cast<PCB_LAYER_ID>( currentLayer ),
729  LSET::AllNonCuMask(), dlgPosition );
730 
731  // Reset the cursor to the position where the event occured
732  controls()->SetCursorPosition( aEvent.HasPosition() ? aEvent.Position() : dlgPosition );
733  }
734  }
735 
736  // fixme: P&S supports more than one fixed layer pair. Update the dialog?
737  sizes.ClearLayerPairs();
738 
739  if( !m_router->IsPlacingVia() )
740  {
741  // Cannot place microvias or blind vias if not allowed (obvious)
742  if( ( viaType == VIATYPE::BLIND_BURIED ) && ( !bds.m_BlindBuriedViaAllowed ) )
743  {
744  WX_INFOBAR* infobar = frame()->GetInfoBar();
745  wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY,
746  _("Show board setup"), wxEmptyString );
747 
748  button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
749  [&]( wxHyperlinkEvent& aEvent )
750  {
751  getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog( _( "Constraints" ) );
752  } ) );
753 
754  infobar->RemoveAllButtons();
755  infobar->AddButton( button );
756 
757  infobar->ShowMessageFor( _( "Blind/buried vias have to be enabled in "
758  "Board Setup > Design Rules > Constraints." ),
759  10000, wxICON_ERROR );
760  return false;
761  }
762 
763  if( ( viaType == VIATYPE::MICROVIA ) && ( !bds.m_MicroViasAllowed ) )
764  {
765  WX_INFOBAR* infobar = frame()->GetInfoBar();
766  wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY,
767  _("Show board setup"), wxEmptyString );
768 
769  button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
770  [&]( wxHyperlinkEvent& aEvent )
771  {
772  getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog( _( "Constraints" ) );
773  } ) );
774 
775  infobar->RemoveAllButtons();
776  infobar->AddButton( button );
777 
778  infobar->ShowMessageFor( _( "Microvias have to be enabled in "
779  "Board Setup > Design Rules > Constraints." ),
780  10000, wxICON_ERROR );
781  return false;
782  }
783 
784  // Can only place through vias on 2-layer boards
785  if( ( viaType != VIATYPE::THROUGH ) && ( layerCount <= 2 ) )
786  {
787  frame()->ShowInfoBarError( _( "Only through vias are allowed on 2 layer boards." ) );
788  return false;
789  }
790 
791  // Can only place microvias if we're on an outer layer, or directly adjacent to one
792  if( ( viaType == VIATYPE::MICROVIA ) && ( currentLayer > In1_Cu )
793  && ( currentLayer < layerCount - 2 ) )
794  {
795  frame()->ShowInfoBarError( _( "Microvias can only be placed between the outer layers "
796  "(F.Cu/B.Cu) and the ones directly adjacent to them." ) );
797  return false;
798  }
799  }
800 
801  // Convert blind/buried via to a through hole one, if it goes through all layers
802  if( viaType == VIATYPE::BLIND_BURIED
803  && ( ( targetLayer == B_Cu && currentLayer == F_Cu )
804  || ( targetLayer == F_Cu && currentLayer == B_Cu ) ) )
805  {
806  viaType = VIATYPE::THROUGH;
807  }
808 
809  switch( viaType )
810  {
811  case VIATYPE::THROUGH:
812  if( targetLayer == UNDEFINED_LAYER )
813  {
814  // use the default layer pair
815  currentLayer = pairTop;
816  targetLayer = pairBottom;
817  }
818  break;
819 
820  case VIATYPE::MICROVIA:
821  wxASSERT_MSG( !selectLayer,
822  "Unexpected select layer for microvia (microvia layers are implicit)" );
823 
824  if( currentLayer == F_Cu || currentLayer == In1_Cu )
825  {
826  // front-side microvia
827  currentLayer = F_Cu;
828  targetLayer = In1_Cu;
829  }
830  else if( currentLayer == B_Cu || currentLayer == layerCount - 2 )
831  {
832  // back-side microvia
833  currentLayer = B_Cu,
834  targetLayer = (PCB_LAYER_ID) ( layerCount - 2 );
835  }
836  else
837  {
838  wxASSERT_MSG( false,
839  "Invalid layer pair for microvia (must be on or adjacent to an outer layer)" );
840  }
841  break;
842 
844  if( targetLayer == UNDEFINED_LAYER )
845  {
846  if( currentLayer == pairTop || currentLayer == pairBottom )
847  {
848  // the current layer is on the defined layer pair,
849  // swap to the other side
850  currentLayer = pairTop;
851  targetLayer = pairBottom;
852  }
853  else
854  {
855  // the current layer is not part of the current layer pair,
856  // so fallback and swap to the top layer of the pair by default
857  targetLayer = pairTop;
858  }
859  }
860  break;
861 
862  default:
863  wxASSERT( false );
864  break;
865  }
866 
867  sizes.SetViaDiameter( bds.m_ViasMinSize );
868  sizes.SetViaDrill( bds.m_MinThroughDrill );
869 
870  if( bds.UseNetClassVia() || viaType == VIATYPE::MICROVIA )
871  {
872  class VIA dummyVia( board() );
873  dummyVia.SetViaType( viaType );
874  dummyVia.SetLayerPair( currentLayer, targetLayer );
875 
876  if( !m_router->GetCurrentNets().empty() )
877  dummyVia.SetNetCode( m_router->GetCurrentNets()[0] );
878 
879  DRC_CONSTRAINT constraint;
880 
881  constraint = bds.m_DRCEngine->EvalRulesForItems( VIA_DIAMETER_CONSTRAINT, &dummyVia,
882  nullptr, currentLayer );
883 
884  if( !constraint.IsNull() )
885  sizes.SetViaDiameter( constraint.m_Value.Opt() );
886 
887  constraint = bds.m_DRCEngine->EvalRulesForItems( HOLE_SIZE_CONSTRAINT, &dummyVia, nullptr,
888  currentLayer );
889 
890  if( !constraint.IsNull() )
891  sizes.SetViaDrill( constraint.m_Value.Opt() );
892  }
893  else
894  {
895  sizes.SetViaDiameter( bds.GetCurrentViaSize() );
896  sizes.SetViaDrill( bds.GetCurrentViaDrill() );
897  }
898 
899  sizes.SetViaType( viaType );
900  sizes.AddLayerPair( currentLayer, targetLayer );
901 
902  m_router->UpdateSizes( sizes );
904 
905  if( m_router->RoutingInProgress() )
906  updateEndItem( aEvent );
907  else
908  updateStartItem( aEvent );
909 
910  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
911 
912  return 0;
913 }
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:109
Definition: track.h:354
void AddButton(wxButton *aButton)
Add an already created button to the infobar.
Definition: infobar.cpp:185
static TOOL_ACTION layerNext
Definition: pcb_actions.h:283
BOARD * board() const
int GetCurrentViaDrill() const
Function GetCurrentViaDrill.
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
Definition: lset.cpp:773
bool IsPlacingVia() const
Definition: pns_router.cpp:537
Microvia
Definition: router_tool.cpp:71
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:509
T Opt() const
Definition: minoptmax.h:33
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.h:559
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Moves cursor to the requested position expressed in world coordinates.
void SetViaDrill(int aDrill)
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:219
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:499
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
PCB_BASE_EDIT_FRAME * frame() const
virtual void updateStartItem(const TOOL_EVENT &aEvent, bool aIgnorePads=false)
MINOPTMAX< int > m_Value
Definition: drc_rule.h:141
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:284
static PCB_LAYER_ID getTargetLayerFromEvent(const TOOL_EVENT &aEvent)
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
bool UseNetClassVia() const
Function UseNetClassVia returns true if netclass values should be used to obtain appropriate via size...
ROUTER * m_router
Definition: pns_tool_base.h:78
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:39
bool m_BlindBuriedViaAllowed
true to allow blind/buried vias
void ShowInfoBarError(const wxString &aErrorMsg)
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:256
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:226
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
void SetViaType(VIATYPE aViaType)
bool IsNull() const
Definition: drc_rule.h:115
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:70
int GetCurrentViaSize() const
Function GetCurrentViaSize.
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:345
KIGFX::VIEW_CONTROLS * controls() const
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
bool IsToolActive() const
Definition: tool_base.cpp:31
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
WX_INFOBAR * GetInfoBar()
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition: tool_event.h:260
void AddLayerPair(int aL1, int aL2)
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:385
int GetCopperLayerCount() const
Function GetCopperLayerCount.
PCB_LAYER_ID SelectLayer(PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask=LSET(), wxPoint aDlgPosition=wxDefaultPosition)
Install the dialog box for layer selection.
Definition: sel_layer.cpp:204
std::shared_ptr< DRC_ENGINE > m_DRCEngine
const VECTOR2D Position() const
Returns mouse cursor position in world coordinates.
Definition: tool_event.h:274
PCB_LAYER_ID m_Route_Layer_TOP
Definition: pcb_screen.h:38
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
int GetCurrentLayer() const
Definition: pns_router.cpp:520

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(), 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(), TOOL_EVENT::HasPosition(), 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, 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(), TOOL_EVENT::Position(), WX_INFOBAR::RemoveAllButtons(), PNS::ROUTER::RoutingInProgress(), SELECT_LAYER, PCB_BASE_FRAME::SelectLayer(), 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(), THROUGH, PNS::ROUTER::ToggleViaPlacement(), UNDEFINED_LAYER, PNS::TOOL_BASE::updateEndItem(), PNS::ROUTER::UpdateSizes(), PNS::TOOL_BASE::updateStartItem(), BOARD_DESIGN_SETTINGS::UseNetClassVia(), and VIA_DIAMETER_CONSTRAINT.

Referenced by setTransitions().

◆ performDragging()

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

Definition at line 1284 of file router_tool.cpp.

1285 {
1286  VIEW_CONTROLS* ctls = getViewControls();
1287 
1288  if( m_startItem && m_startItem->IsLocked() )
1289  {
1290  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1291  wxOK | wxCANCEL | wxICON_WARNING );
1292  dlg.SetOKLabel( _( "Drag Anyway" ) );
1293  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1294 
1295  if( dlg.ShowModal() == wxID_CANCEL )
1296  return;
1297  }
1298 
1299  bool dragStarted = m_router->StartDragging( m_startSnapPoint, m_startItem, aMode );
1300 
1301  if( !dragStarted )
1302  return;
1303 
1304  if( m_startItem && m_startItem->Net() >= 0 )
1305  highlightNet( true, m_startItem->Net() );
1306 
1307  ctls->SetAutoPan( true );
1309  frame()->UndoRedoBlock( true );
1310 
1311  while( TOOL_EVENT* evt = Wait() )
1312  {
1313  ctls->ForceCursorPosition( false );
1314 
1315  if( evt->IsMotion() )
1316  {
1317  updateEndItem( *evt );
1319  }
1320  else if( evt->IsClick( BUT_LEFT ) )
1321  {
1323  break;
1324  }
1325  else if( evt->IsClick( BUT_RIGHT ) )
1326  {
1328  }
1329  else if( evt->IsCancelInteractive() || evt->IsActivate() || evt->IsUndoRedo() )
1330  {
1331  if( evt->IsCancelInteractive() && !m_startItem )
1332  m_cancelled = true;
1333 
1334  if( evt->IsActivate() && !evt->IsMoveTool() )
1335  m_cancelled = true;
1336 
1337  break;
1338  }
1339  else
1340  {
1341  evt->SetPassEvent();
1342  }
1343 
1344  handleCommonEvents( *evt );
1345  }
1346 
1347  if( m_router->RoutingInProgress() )
1348  m_router->StopRouting();
1349 
1350  m_startItem = nullptr;
1351 
1352  m_gridHelper->SetAuxAxes( false );
1353  frame()->UndoRedoBlock( false );
1354  ctls->SetAutoPan( false );
1355  ctls->ForceCursorPosition( false );
1356  highlightNet( false );
1357 }
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:44
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
void handleCommonEvents(const TOOL_EVENT &evt)
PCB_BASE_EDIT_FRAME * frame() const
virtual void updateEndItem(const TOOL_EVENT &aEvent)
void SetAuxAxes(bool aEnable, const VECTOR2I &aOrigin=VECTOR2I(0, 0))
#define _(s)
const PCBNEW_SELECTION & selection() const
int Net() const
Definition: pns_item.h:150
TOOL_EVENT.
Definition: tool_event.h:171
ITEM * m_startItem
Definition: pns_tool_base.h:69
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:404
ROUTER * m_router
Definition: pns_tool_base.h:78
VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (such a...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:256
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
void StopRouting()
Definition: pns_router.cpp:449
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:128
bool IsLocked() const
Definition: pns_item.h:242
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
bool RoutingInProgress() const
Definition: pns_router.cpp:114
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59

References _, BUT_LEFT, BUT_RIGHT, 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 975 of file router_tool.cpp.

976 {
977  if( !prepareInteractive() )
978  return;
979 
980  auto setCursor =
981  [&]()
982  {
984  };
985 
986  // Set initial cursor
987  setCursor();
988 
989  while( TOOL_EVENT* evt = Wait() )
990  {
991  setCursor();
992 
993  // Don't crash if we missed an operation that cancelled routing.
994  if( !m_router->RoutingInProgress() )
995  {
996  if( evt->IsCancelInteractive() )
997  m_cancelled = true;
998 
999  break;
1000  }
1001 
1002  handleCommonEvents( *evt );
1003 
1004  if( evt->IsMotion() )
1005  {
1006  m_router->SetOrthoMode( evt->Modifier( MD_CTRL ) );
1007  updateEndItem( *evt );
1009  }
1010  else if( evt->IsAction( &ACT_UndoLastSegment ) )
1011  {
1013  updateEndItem( *evt );
1015  }
1016  else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &PCB_ACTIONS::routeSingleTrack ) )
1017  {
1018  updateEndItem( *evt );
1019  bool needLayerSwitch = m_router->IsPlacingVia();
1020  bool forceFinish = evt->Modifier( MD_SHIFT );
1021 
1022  if( m_router->FixRoute( m_endSnapPoint, m_endItem, forceFinish ) )
1023  {
1024  break;
1025  }
1026 
1027  if( needLayerSwitch )
1029 
1030  // Synchronize the indicated layer
1032  updateEndItem( *evt );
1034  m_startItem = nullptr;
1035  }
1036  else if( evt->IsAction( &ACT_SwitchRounding ) )
1037  {
1039  updateEndItem( *evt );
1040  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
1041  }
1042  else if( evt->IsAction( &ACT_SwitchPosture ) )
1043  {
1044  m_router->FlipPosture();
1045  updateEndItem( *evt );
1046  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
1047  }
1048  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1049  {
1050  m_router->SwitchLayer( frame()->GetActiveLayer() );
1051  updateEndItem( *evt );
1052  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
1053  }
1054  else if( evt->IsAction( &ACT_EndTrack ) || evt->IsDblClick( BUT_LEFT ) )
1055  {
1056  // Stop current routing:
1058  break;
1059  }
1060  else if( evt->IsCancelInteractive() || evt->IsActivate()
1061  || evt->IsUndoRedo()
1062  || evt->IsAction( &PCB_ACTIONS::routerInlineDrag ) )
1063  {
1064  if( evt->IsCancelInteractive() && !m_router->RoutingInProgress() )
1065  m_cancelled = true;
1066 
1067  if( evt->IsActivate() && !evt->IsMoveTool() )
1068  m_cancelled = true;
1069 
1070  break;
1071  }
1072  else if( evt->IsClick( BUT_RIGHT ) )
1073  {
1075  }
1076  else
1077  {
1078  evt->SetPassEvent();
1079  }
1080  }
1081 
1083  m_router->StopRouting();
1084 
1086 }
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
bool finishInteractive()
void CommitRouting()
Definition: pns_router.cpp:440
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
bool IsPlacingVia() const
Definition: pns_router.cpp:537
void ToggleRounded()
Definition: pns_router.cpp:546
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."), change_entry_orient_xpm)
static const TOOL_ACTION ACT_SwitchRounding("pcbnew.InteractiveRouter.SwitchRounding", AS_CONTEXT, 0, LEGACY_HK_NAME("Switch Corner Rounding"), _("Switch Corner Rounding"), _("Switches the corner type of the currently routed track."), switch_corner_rounding_shape_xpm)
void SwitchLayer(int layer)
Definition: pns_router.cpp:486
void SetOrthoMode(bool aEnable)
Definition: pns_router.cpp:552
void SetCurrentCursor(KICURSOR cursor)
Function SetCurrentCursor Set the current cursor shape for this panel.
static const TOOL_ACTION ACT_EndTrack("pcbnew.InteractiveRouter.EndTrack", AS_CONTEXT, WXK_END, "", _("Finish Track"), _("Stops laying the current track."), checked_ok_xpm)
void handleCommonEvents(const TOOL_EVENT &evt)
PCB_BASE_EDIT_FRAME * frame() const
void UndoLastSegment()
Definition: pns_router.cpp:431
virtual void updateEndItem(const TOOL_EVENT &aEvent)
bool prepareInteractive()
const PCBNEW_SELECTION & selection() const
static const TOOL_ACTION ACT_UndoLastSegment("pcbnew.InteractiveRouter.UndoLastSegment", AS_CONTEXT, WXK_BACK, "", _("Undo last segment"), _("Stops laying the current track."), checked_ok_xpm)
TOOL_EVENT.
Definition: tool_event.h:171
ITEM * m_startItem
Definition: pns_tool_base.h:69
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:404
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:256
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:205
void StopRouting()
Definition: pns_router.cpp:449
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:289
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:179
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
void FlipPosture()
Definition: pns_router.cpp:477
bool RoutingInProgress() const
Definition: pns_router.cpp:114
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:898
int GetCurrentLayer() const
Definition: pns_router.cpp:520

References ACT_EndTrack, ACT_SwitchPosture, ACT_SwitchRounding, ACT_UndoLastSegment, BUT_LEFT, BUT_RIGHT, PNS::ROUTER::CommitRouting(), finishInteractive(), PNS::ROUTER::FixRoute(), PNS::ROUTER::FlipPosture(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), PNS::ROUTER::GetCurrentLayer(), handleCommonEvents(), PNS::ROUTER::IsPlacingVia(), PCB_ACTIONS::layerChanged, 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, MD_CTRL, MD_SHIFT, PNS::ROUTER::Move(), PENCIL, prepareInteractive(), PCB_ACTIONS::routerInlineDrag, PCB_ACTIONS::routeSingleTrack, PNS::ROUTER::RoutingInProgress(), PCB_TOOL_BASE::selection(), PCB_BASE_FRAME::SetActiveLayer(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), PNS::ROUTER::SetOrthoMode(), TOOL_MENU::ShowContextMenu(), PNS::ROUTER::StopRouting(), PNS::ROUTER::SwitchLayer(), 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 110 of file pns_tool_base.cpp.

112 {
113  int tl = aLayer > 0 ? aLayer : getView()->GetTopLayer();
114 
115  static const int candidateCount = 5;
116  ITEM* prioritized[candidateCount];
117  SEG::ecoord dist[candidateCount];
118 
119  for( int i = 0; i < candidateCount; i++ )
120  {
121  prioritized[i] = nullptr;
122  dist[i] = VECTOR2I::ECOORD_MAX;
123  }
124 
125  ITEM_SET candidates = m_router->QueryHoverItems( aWhere );
126 
127  for( ITEM* item : candidates.Items() )
128  {
129  if( !item->IsRoutable() )
130  continue;
131 
132  if( !IsCopperLayer( item->Layers().Start() ) )
133  continue;
134 
135  if( !m_iface->IsAnyLayerVisible( item->Layers() ) )
136  continue;
137 
138  if( alg::contains( aAvoidItems, item ) )
139  continue;
140 
141  // fixme: this causes flicker with live loop removal...
142  //if( item->Parent() && !item->Parent()->ViewIsVisible() )
143  // continue;
144 
145  if( aNet <= 0 || item->Net() == aNet )
146  {
147  if( item->OfKind( ITEM::VIA_T | ITEM::SOLID_T ) )
148  {
149  if( item->OfKind( ITEM::SOLID_T ) && aIgnorePads )
150  continue;
151 
152  SEG::ecoord d = ( item->Shape()->Centre() - aWhere ).SquaredEuclideanNorm();
153 
154  if( d < dist[2] )
155  {
156  prioritized[2] = item;
157  dist[2] = d;
158  }
159 
160  if( item->Layers().Overlaps( tl ) && d < dist[0] )
161  {
162  prioritized[0] = item;
163  dist[0] = d;
164  }
165  }
166  else // ITEM::SEGMENT_T | ITEM::ARC_T
167  {
168  LINKED_ITEM* li = static_cast<LINKED_ITEM*>( item );
169  SEG::ecoord d = std::min( ( li->Anchor( 0 ) - aWhere ).SquaredEuclideanNorm(),
170  ( li->Anchor( 1 ) - aWhere ).SquaredEuclideanNorm() );
171 
172  if( d < dist[3] )
173  {
174  prioritized[3] = item;
175  dist[3] = d;
176  }
177 
178  if( item->Layers().Overlaps( tl ) && d < dist[1] )
179  {
180  prioritized[1] = item;
181  dist[1] = d;
182  }
183  }
184  }
185  // Allow unconnected items as last resort in RM_MarkObstacles mode
186  else if ( item->Net() == 0 && m_router->Settings().Mode() == RM_MarkObstacles )
187  {
188  if( item->OfKind( ITEM::SOLID_T ) && aIgnorePads )
189  continue;
190 
191  if( item->Layers().Overlaps( tl ) )
192  prioritized[4] = item;
193  }
194  }
195 
196  ITEM* rv = NULL;
197 
199 
200  for( int i = 0; i < candidateCount; i++ )
201  {
202  ITEM* item = prioritized[i];
203 
204  if( highContrast && item && !item->Layers().Overlaps( tl ) )
205  item = nullptr;
206 
207  if( item && ( aLayer < 0 || item->Layers().Overlaps( aLayer ) ) )
208  {
209  rv = item;
210  break;
211  }
212  }
213 
214  if( rv )
215  {
216  wxLogTrace( "PNS", "%s, layer : %d, tl: %d", rv->KindStr().c_str(), rv->Layers().Start(), tl );
217  }
218 
219  return rv;
220 }
const ITEM_SET QueryHoverItems(const VECTOR2I &aP)
Definition: pns_router.cpp:120
VECTOR2I::extended_type ecoord
Definition: seg.h:42
static constexpr extended_type ECOORD_MAX
Definition: vector2d.h:80
#define NULL
virtual int GetTopLayer() const
Definition: view.cpp:829
ROUTER * m_router
Definition: pns_tool_base.h:78
PNS_MODE Mode() const
Returns 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
Function getView()
Definition: tool_base.cpp:36
const PCB_DISPLAY_OPTIONS & displayOptions() const
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:200
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 916 of file router_tool.cpp.

917 {
918  int routingLayer = getStartLayer( m_startItem );
919 
920  if( !IsCopperLayer( routingLayer ) )
921  {
922  frame()->ShowInfoBarError( _( "Tracks on Copper layers only" ) );
923  return false;
924  }
925 
926  PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
927 
928  editFrame->SetActiveLayer( ToLAYER_ID( routingLayer ) );
929 
930  if( m_startItem && m_startItem->Net() >= 0 )
931  highlightNet( true, m_startItem->Net() );
932 
933  controls()->ForceCursorPosition( false );
934  controls()->SetAutoPan( true );
935 
936  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
937 
938  m_iface->ImportSizes( sizes, m_startItem, -1 );
939  sizes.AddLayerPair( frame()->GetScreen()->m_Route_Layer_TOP,
940  frame()->GetScreen()->m_Route_Layer_BOTTOM );
941 
942  m_router->UpdateSizes( sizes );
943 
944  if( !m_router->StartRouting( m_startSnapPoint, m_startItem, routingLayer ) )
945  {
947  highlightNet( false );
948  controls()->SetAutoPan( false );
949  return false;
950  }
951 
952  m_endItem = nullptr;
954 
955  frame()->UndoRedoBlock( true );
956 
957  return true;
958 }
const wxString & FailureReason() const
Definition: pns_router.h:227
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:219
PCB_BASE_EDIT_FRAME * frame() const
#define _(s)
int Net() const
Definition: pns_item.h:150
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))
Function ForceCursorPosition() Places the cursor immediately at a given point.
void ShowInfoBarError(const wxString &aErrorMsg)
bool StartRouting(const VECTOR2I &aP, ITEM *aItem, int aLayer)
Definition: pns_router.cpp:205
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns 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:345
KIGFX::VIEW_CONTROLS * controls() const
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
PCB_EDIT_FRAME is the main frame for Pcbnew.
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
Function SetActiveLayer will change the currently active layer to aLayer and also update the APPEARAN...
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:898

References _, 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

Function Reset() Brings 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 474 of file router_tool.cpp.

475 {
476  if( aReason == RUN )
477  TOOL_BASE::Reset( aReason );
478 }
Tool is invoked after being inactive.
Definition: tool_base.h:81
virtual void Reset(RESET_REASON aReason)=0
Function Reset() Brings the tool to a known, initial state.

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

◆ Router()

ROUTER * TOOL_BASE::Router ( ) const
inherited

Definition at line 366 of file pns_tool_base.cpp.

367 {
368  return m_router;
369 }
ROUTER * m_router
Definition: pns_tool_base.h:78

References PNS::TOOL_BASE::m_router.

Referenced by EDIT_TOOL::isInteractiveDragEnabled().

◆ RunMainStack()

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

Function RunMainStack()

Calls 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:219
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)

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

Referenced by DRAWING_TOOL::PlaceText().

◆ SelectCopperLayerPair()

int ROUTER_TOOL::SelectCopperLayerPair ( const TOOL_EVENT aEvent)

Definition at line 259 of file sel_layer.cpp.

260 {
261  PCB_SCREEN* screen = frame()->GetScreen();
262 
264  screen->m_Route_Layer_BOTTOM );
265 
266  if( dlg.ShowModal() == wxID_OK )
267  {
268  dlg.GetLayerPair( screen->m_Route_Layer_TOP, screen->m_Route_Layer_BOTTOM );
269 
270  // select the same layer for both layers is allowed (normal in some boards)
271  // but could be a mistake. So display an info message
272  if( screen->m_Route_Layer_TOP == screen->m_Route_Layer_BOTTOM )
273  DisplayInfoMessage( frame(), _( "Warning: top and bottom layers are same." ) );
274  }
275 
276  return 0;
277 }
PCB_BASE_EDIT_FRAME * frame() const
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:39
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:268
PCB_LAYER_ID m_Route_Layer_TOP
Definition: pcb_screen.h:38
SELECT_COPPER_LAYERS_PAIR_DIALOG displays a double pcb copper layers list in a dialog,...
Definition: sel_layer.cpp:229

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 PCBNEW_SELECTION & PCB_TOOL_BASE::selection ( ) const
protectedinherited

Definition at line 291 of file pcb_tool_base.cpp.

292 {
294 
295  return selTool->GetSelection();
296 }
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
PCBNEW_SELECTION & GetSelection()
Function GetSelection()

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

Referenced by AUTOPLACE_TOOL::autoplaceSelected(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), CanInlineDrag(), EDIT_TOOL::ChangeTrackWidth(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), PCB_INSPECTION_TOOL::doHideNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawZone(), EDIT_TOOL::Duplicate(), PCB_EDITOR_CONTROL::EditFpInFpEditor(), PAD_TOOL::EditPad(), GROUP_TOOL::EnterGroup(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), EDIT_TOOL::FilletTracks(), SELECTION_TOOL::filterSelection(), EDIT_TOOL::Flip(), DRAWING_TOOL::getSourceZoneForAction(), GROUP_TOOL::Group(), PCB_INSPECTION_TOOL::highlightNet(), InlineBreakTrack(), InlineDrag(), PCB_INSPECTION_TOOL::InspectClearance(), PCB_INSPECTION_TOOL::InspectConstraints(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PAD_TOOL::pastePadProperties(), performDragging(), performRouting(), LENGTH_TUNER_TOOL::performTuning(), PCBNEW_CONTROL::placeBoardItems(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_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(), SELECTION_TOOL::selectNet(), DRAWING_TOOL::SetAnchor(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), GROUP_TOOL::Ungroup(), PCBNEW_CONTROL::UpdateMessagePanel(), PCB_INSPECTION_TOOL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), PCB_EDITOR_CONTROL::ZoneDuplicate(), ZONE_FILLER_TOOL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfill().

◆ selection() [2/2]

PCBNEW_SELECTION & PCB_TOOL_BASE::selection ( )
protectedinherited

Definition at line 299 of file pcb_tool_base.cpp.

300 {
302 
303  return selTool->GetSelection();
304 }
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
PCBNEW_SELECTION & GetSelection()
Function GetSelection()

References 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

Function SetContextMenu()

Assigns 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:219
void SetTool(TOOL_INTERACTIVE *aTool)
Sets a tool that is the creator of the menu.
void ScheduleContextMenu(TOOL_BASE *aTool, ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Sets behaviour 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(), 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 1109 of file router_tool.cpp.

1110 {
1111  DIALOG_PNS_SETTINGS settingsDlg( frame(), m_router->Settings() );
1112 
1113  settingsDlg.ShowModal();
1114 
1115  return 0;
1116 }
PCB_BASE_EDIT_FRAME * frame() const
ROUTER * m_router
Definition: pns_tool_base.h:78
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:200

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 1722 of file router_tool.cpp.

1723 {
1725 
1735 
1741 
1776 
1779 }
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:282
static TOOL_ACTION layerInner26
Definition: pcb_actions.h:277
static TOOL_ACTION layerNext
Definition: pcb_actions.h:283
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:253
int MainLoop(const TOOL_EVENT &aEvent)
static TOOL_ACTION selectLayerPair
Definition: pcb_actions.h:132
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."), via_microvia_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::MICROVIA)
int DpDimensionsDialog(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:256
static TOOL_ACTION layerInner6
Definition: pcb_actions.h:257
static TOOL_ACTION routerDiffPairDialog
Definition: pcb_actions.h:197
static TOOL_ACTION layerInner7
Definition: pcb_actions.h:258
static TOOL_ACTION layerInner8
Definition: pcb_actions.h:259
static TOOL_ACTION layerInner21
Definition: pcb_actions.h:272
int InlineDrag(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerHighlightMode
Actions to enable switching modes via hotkey assignments.
Definition: pcb_actions.h:200
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:299
static TOOL_ACTION layerInner3
Definition: pcb_actions.h:254
static TOOL_ACTION layerInner24
Definition: pcb_actions.h:275
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
int ChangeRouterMode(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner11
Definition: pcb_actions.h:262
static TOOL_ACTION layerTop
Definition: pcb_actions.h:251
static TOOL_ACTION layerInner23
Definition: pcb_actions.h:274
int onViaCommand(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerSettingsDialog
Activation of the Push and Shove settings dialogs.
Definition: pcb_actions.h:196
static TOOL_ACTION layerInner13
Definition: pcb_actions.h:264
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:284
static TOOL_ACTION layerInner25
Definition: pcb_actions.h:276
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."), width_track_xpm)
static TOOL_ACTION layerInner18
Definition: pcb_actions.h:269
static TOOL_ACTION layerInner30
Definition: pcb_actions.h:281
static TOOL_ACTION layerInner29
Definition: pcb_actions.h:280
static TOOL_ACTION layerInner10
Definition: pcb_actions.h:261
int SettingsDialog(const TOOL_EVENT &aEvent)
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."), select_w_layer_xpm, AF_NONE,(void *)(VIA_ACTION_FLAGS::VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
int CustomTrackWidthDialog(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerWalkaroundMode
Definition: pcb_actions.h:202
static TOOL_ACTION layerInner15
Definition: pcb_actions.h:266
int onTrackViaSizeChanged(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:205
static TOOL_ACTION layerInner28
Definition: pcb_actions.h:279
static TOOL_ACTION layerInner27
Definition: pcb_actions.h:278
static TOOL_ACTION inlineBreakTrack
Breaks track when router is not activated.
Definition: pcb_actions.h:138
static TOOL_ACTION layerInner17
Definition: pcb_actions.h:268
static TOOL_ACTION layerInner20
Definition: pcb_actions.h:271
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."), via_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::VIA)
static TOOL_ACTION layerInner22
Definition: pcb_actions.h:273
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:179
static TOOL_ACTION layerInner14
Definition: pcb_actions.h:265
static TOOL_ACTION layerInner9
Definition: pcb_actions.h:260
TOOL_EVENT MakeEvent() const
Returns the event associated with the action (i.e.
Definition: tool_action.h:113
int InlineBreakTrack(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner16
Definition: pcb_actions.h:267
int SelectCopperLayerPair(const TOOL_EVENT &aEvent)
Definition: sel_layer.cpp:259
static TOOL_ACTION layerInner4
Definition: pcb_actions.h:255
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."), via_buried_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::BLIND_VIA)
static TOOL_ACTION layerInner19
Definition: pcb_actions.h:270
static TOOL_ACTION layerInner1
Definition: pcb_actions.h:252
static TOOL_ACTION routerShoveMode
Definition: pcb_actions.h:201
static TOOL_ACTION layerInner12
Definition: pcb_actions.h:263
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."), select_w_layer_xpm, AF_NONE,(void *)(VIA_ACTION_FLAGS::BLIND_VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:182

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(), 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 ( bool  aEnabled,
ITEM aItem,
VECTOR2I  aP 
)
protectedinherited

Definition at line 372 of file pns_tool_base.cpp.

373 {
374  VECTOR2I anchor;
375 
376  if( !aItem || !aEnabled || !m_iface->IsItemVisible( aItem ) )
377  {
378  return m_gridHelper->Align( aP );
379  }
380 
381  switch( aItem->Kind() )
382  {
383  case ITEM::SOLID_T:
384  anchor = static_cast<SOLID*>( aItem )->Pos();
385  break;
386 
387  case ITEM::VIA_T:
388  anchor = static_cast<VIA*>( aItem )->Pos();
389  break;
390 
391  case ITEM::SEGMENT_T:
392  case ITEM::ARC_T:
393  {
394  LINKED_ITEM* li = static_cast<LINKED_ITEM*>( aItem );
395  VECTOR2I A = li->Anchor( 0 );
396  VECTOR2I B = li->Anchor( 1 );
397  SEG::ecoord w_sq = SEG::Square( li->Width() / 2 );
398  SEG::ecoord distA_sq = ( aP - A ).SquaredEuclideanNorm();
399  SEG::ecoord distB_sq = ( aP - B ).SquaredEuclideanNorm();
400 
401  if( distA_sq < w_sq || distB_sq < w_sq )
402  {
403  anchor = distA_sq < distB_sq ? A : B;
404  }
405  else // TODO(snh): Clean this up
406  {
407  if( aItem->Kind() == ITEM::SEGMENT_T )
408  {
409  anchor = m_gridHelper->AlignToSegment( aP, static_cast<SEGMENT*>( li )->Seg() );
410  }
411  else if( aItem->Kind() == ITEM::ARC_T )
412  {
413  anchor = m_gridHelper->AlignToArc( aP,
414  *static_cast<const SHAPE_ARC*>( static_cast<ARC*>( li )->Shape() ) );
415  }
416  }
417 
418  break;
419  }
420 
421  default:
422  break;
423  }
424 
425  return anchor;
426 }
GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
VECTOR2I::extended_type ecoord
Definition: seg.h:42
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)
static SEG::ecoord Square(int a)
Definition: seg.h:116
bool IsItemVisible(const PNS::ITEM *aItem) const override
VECTOR2I AlignToArc(const VECTOR2I &aPoint, const SHAPE_ARC &aSeg)
VECTOR2I Align(const VECTOR2I &aPoint) const
PNS_KICAD_IFACE * m_iface
Definition: pns_tool_base.h:77

References GRID_HELPER::Align(), GRID_HELPER::AlignToArc(), 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::ITEM::SEGMENT_T, 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 543 of file router_tool.cpp.

544 {
545  int al = frame()->GetActiveLayer();
546  int cl = m_router->GetCurrentLayer();
547 
548  if( cl != al )
549  {
550  m_router->SwitchLayer( al );
551  }
552 
553  OPT<int> newLayer = m_router->Sizes().PairedLayer( cl );
554 
555  if( !newLayer )
556  newLayer = m_router->Sizes().GetLayerTop();
557 
558  m_router->SwitchLayer( *newLayer );
559  frame()->SetActiveLayer( ToLAYER_ID( *newLayer ) );
560 }
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:219
void SwitchLayer(int layer)
Definition: pns_router.cpp:486
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)
boost::optional< T > OPT
Definition: optional.h:7
OPT< int > PairedLayer(int aLayerId)
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:898
int GetCurrentLayer() const
Definition: pns_router.cpp:520

References PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetActiveLayer(), PNS::ROUTER::GetCurrentLayer(), PNS::SIZES_SETTINGS::GetLayerTop(), 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 307 of file pns_tool_base.cpp.

308 {
309  int layer;
310  bool snapEnabled = !aEvent.Modifier( MD_SHIFT );
312  m_gridHelper->SetSnap( snapEnabled );
313 
314  controls()->ForceCursorPosition( false );
315  VECTOR2I mousePos = controls()->GetMousePosition();
316 
317  if( m_router->Settings().Mode() != RM_MarkObstacles &&
318  ( m_router->GetCurrentNets().empty() || m_router->GetCurrentNets().front() < 0 ) )
319  {
320  m_endSnapPoint = snapToItem( snapEnabled, nullptr, mousePos );
322  m_endItem = nullptr;
323 
324  return;
325  }
326 
327  if( m_router->IsPlacingVia() )
328  layer = -1;
329  else
330  layer = m_router->GetCurrentLayer();
331 
332  ITEM* endItem = nullptr;
333 
334  std::vector<int> nets = m_router->GetCurrentNets();
335 
336  for( int net : nets )
337  {
338  endItem = pickSingleItem( mousePos, net, layer, false, { m_startItem } );
339 
340  if( endItem )
341  break;
342  }
343 
344  if( checkSnap( endItem ) )
345  {
346  m_endItem = endItem;
347  m_endSnapPoint = snapToItem( snapEnabled, endItem, mousePos );
348  }
349  else
350  {
351  m_endItem = nullptr;
352  m_endSnapPoint = m_gridHelper->Align( mousePos );
353  }
354 
356 
357  if( m_endItem )
358  {
359  wxLogTrace( "PNS", "%s, layer : %d",
360  m_endItem->KindStr().c_str(),
361  m_endItem->Layers().Start() );
362  }
363 }
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:290
GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool IsPlacingVia() const
Definition: pns_router.cpp:537
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:509
GAL * GetGAL() const
Function GetGAL() Returns the GAL this view is using to draw graphical primitives.
Definition: view.h:182
const VECTOR2I snapToItem(bool aEnabled, ITEM *aItem, VECTOR2I aP)
int Start() const
Definition: pns_layerset.h:83
std::string KindStr() const
Function KindStr()
Definition: pns_item.cpp:108
bool GetGridSnapping() const
bool checkSnap(ITEM *aItem)
ITEM * m_startItem
Definition: pns_tool_base.h:69
ROUTER * m_router
Definition: pns_tool_base.h:78
PNS_MODE Mode() const
Returns the routing mode.
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
void SetSnap(bool aSnap)
Definition: grid_helper.h:82
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:342
VECTOR2I Align(const VECTOR2I &aPoint) const
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={})
void SetUseGrid(bool aGrid=true)
Definition: grid_helper.h:92
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:200
const LAYER_RANGE & Layers() const
Definition: pns_item.h:152
int GetCurrentLayer() const
Definition: pns_router.cpp:520

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(), 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_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 InlineDrag(), onViaCommand(), performDragging(), and performRouting().

◆ updateStartItem()

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

Definition at line 271 of file pns_tool_base.cpp.

272 {
273  int tl = getView()->GetTopLayer();
274  VECTOR2I cp = controls()->GetCursorPosition( !aEvent.Modifier( MD_SHIFT ) );
275  VECTOR2I p;
276 
277  controls()->ForceCursorPosition( false );
279  m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
280 
281  bool snapEnabled = true;
282 
283  if( aEvent.IsMotion() || aEvent.IsClick() )
284  {
285  snapEnabled = !aEvent.Modifier( MD_SHIFT );
286  p = aEvent.Position();
287  }
288  else
289  {
290  p = cp;
291  }
292 
293  m_startItem = pickSingleItem( p, -1, -1, aIgnorePads );
294 
295  if( !snapEnabled && m_startItem && !m_startItem->Layers().Overlaps( tl ) )
296  m_startItem = nullptr;
297 
298  m_startSnapPoint = snapToItem( snapEnabled, m_startItem, p );
299 
300  if( checkSnap( m_startItem ) )
301  {
303  }
304 }
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:290
GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
bool IsClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.cpp:178
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool IsMotion() const
Definition: tool_event.h:306
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:68
GAL * GetGAL() const
Function GetGAL() Returns the GAL this view is using to draw graphical primitives.
Definition: view.h:182
const VECTOR2I snapToItem(bool aEnabled, ITEM *aItem, VECTOR2I aP)
bool GetGridSnapping() const
bool checkSnap(ITEM *aItem)
virtual int GetTopLayer() const
Definition: view.cpp:829
ITEM * m_startItem
Definition: pns_tool_base.h:69
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
void SetSnap(bool aSnap)
Definition: grid_helper.h:82
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:342
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={})
void SetUseGrid(bool aGrid=true)
Definition: grid_helper.h:92
const VECTOR2D Position() const
Returns mouse cursor position in world coordinates.
Definition: tool_event.h:274
const LAYER_RANGE & Layers() const
Definition: pns_item.h:152
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.

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(), 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_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 MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), and onViaCommand().

◆ view()

◆ Wait()

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

Function Wait()

Suspends 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:219
TOOL_EVENT * ScheduleWait(TOOL_BASE *aTool, const TOOL_EVENT_LIST &aConditions)
Pauses 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(), SELECTION_TOOL::doSelectionMenu(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), InlineDrag(), ZOOM_TOOL::Main(), PL_EDIT_TOOL::Main(), CVPCB_CONTROL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), EDA_3D_CONTROLLER::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), POINT_EDITOR::OnSelectionChange(), performDragging(), performRouting(), LENGTH_TUNER_TOOL::performTuning(), GROUP_TOOL::PickNewMember(), EDIT_TOOL::pickReferencePoint(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_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_endItem

◆ m_endSnapPoint

VECTOR2I PNS::TOOL_BASE::m_endSnapPoint
protectedinherited

◆ m_gridHelper

◆ m_iface

◆ m_isFootprintEditor

◆ m_menu

TOOL_MENU TOOL_INTERACTIVE::m_menu
protectedinherited

functions below are not yet implemented - their interface may change

Definition at line 108 of file tool_interactive.h.

Referenced by SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), TOOL_INTERACTIVE::GetToolMenu(), Init(), LENGTH_TUNER_TOOL::Init(), PL_EDIT_TOOL::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init(), SCH_EDIT_TOOL::Init(), PICKER_TOOL::Init(), LIB_CONTROL::Init(), LIB_DRAWING_TOOLS::Init(), FOOTPRINT_EDITOR_TOOLS::Init(), PCB_VIEWER_TOOLS::Init(), PL_DRAWING_TOOLS::Init(), PCB_EDITOR_CONTROL::Init(), SCH_DRAWING_TOOLS::Init(), EDA_3D_CONTROLLER::Init(), GERBVIEW_SELECTION_TOOL::Init(), PL_SELECTION_TOOL::Init(), DRAWING_TOOL::Init(), EE_SELECTION_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), SELECTION_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), PCB_TOOL_BASE::Init(), PL_EDIT_TOOL::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), EDA_3D_CONTROLLER::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), performDragging(), performRouting(), LENGTH_TUNER_TOOL::performTuning(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ m_router

◆ m_savedSizes

SIZES_SETTINGS PNS::TOOL_BASE::m_savedSizes
protectedinherited

◆ m_startHighlight

bool PNS::TOOL_BASE::m_startHighlight
protectedinherited

Definition at line 71 of file pns_tool_base.h.

Referenced by PNS::TOOL_BASE::highlightNet(), and PNS::TOOL_BASE::TOOL_BASE().

◆ m_startItem

◆ m_startSnapPoint

VECTOR2I PNS::TOOL_BASE::m_startSnapPoint
protectedinherited

◆ m_toolId

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

Unique identifier for the tool, assigned by a TOOL_MANAGER instance.

Definition at line 214 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), TOOL_BASE::GetId(), and TOOL_BASE::IsToolActive().

◆ m_toolMgr

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 219 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PL_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemsToSel(), PL_SELECTION_TOOL::AddItemToSel(), SELECTION_TOOL::AddItemToSel(), EE_SELECTION_TOOL::AddItemToSel(), SCH_MOVE_TOOL::AlignElements(), SCH_EDITOR_CONTROL::AssignNetclass(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), SCH_EDIT_TOOL::AutoplaceFields(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), CanInlineDrag(), SCH_EDIT_TOOL::ChangeTextType(), EDIT_TOOL::ChangeTrackWidth(), SCH_EDIT_TOOL::CleanupSheetPins(), GERBVIEW_CONTROL::ClearAllLayers(), PCB_INSPECTION_TOOL::ClearHighlight(), SCH_EDITOR_CONTROL::ClearHighlight(), SELECTION_TOOL::ClearSelection(), PL_SELECTION_TOOL::ClearSelection(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), LIB_EDIT_TOOL::Copy(), PL_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), COMMON_TOOLS::CursorControl(), SCH_EDITOR_CONTROL::Cut(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), LIB_EDIT_TOOL::DoDelete(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_INSPECTION_TOOL::doHideNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawRectangle(), DRAWING_TOOL::drawSegment(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::EditField(), SCH_EDIT_TOOL::editFieldText(), PCB_EDITOR_CONTROL::EditFpInFpEditor(), LIB_EDIT_TOOL::editGraphicProperties(), PAD_TOOL::EditPad(), LIB_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithLibEdit(), GROUP_TOOL::EnterGroup(), SCH_NAVIGATE_TOOL::EnterSheet(), SCH_EDITOR_CONTROL::EnterSheet(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandConnection(), PAD_TOOL::explodePad(), SELECTION_TOOL::filterSelection(), SELECTION_TOOL::findCallback(), SCH_EDITOR_CONTROL::FindComponentAndItem(), POINT_EDITOR::finishItem(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), EDIT_TOOL::GetAndPlace(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getToolHolderInt(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), COMMON_TOOLS::GridNext(), COMMON_TOOLS::GridPreset(), COMMON_TOOLS::GridPrev(), PCBNEW_CONTROL::GridSetOrigin(), GROUP_TOOL::Group(), EE_SELECTION_TOOL::GuessSelectionCandidates(), GERBVIEW_CONTROL::HighlightControl(), PCB_INSPECTION_TOOL::HighlightItem(), PCB_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_INSPECTION_TOOL::highlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_INSPECTION_TOOL::HighlightNetTool(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), PL_EDIT_TOOL::ImportWorksheetContent(), LIB_EDIT_TOOL::Init(), PL_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), GROUP_TOOL::Init(), CONVERT_TOOL::Init(), GLOBAL_EDIT_TOOL::Init(), LIB_CONTROL::Init(), PAD_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PL_DRAWING_TOOLS::Init(), PL_POINT_EDITOR::Init(), PCB_EDITOR_CONTROL::Init(), POINT_EDITOR::Init(), POSITION_RELATIVE_TOOL::Init(), PCB_INSPECTION_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), EDIT_TOOL::Init(), InlineBreakTrack(), InlineDrag(), PCB_INSPECTION_TOOL::InspectClearance(), PCB_INSPECTION_TOOL::InspectConstraints(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), EDIT_TOOL::isRouterActive(), TOOL_BASE::IsToolActive(), GROUP_TOOL::LeaveGroup(), SCH_NAVIGATE_TOOL::LeaveSheet(), SCH_EDITOR_CONTROL::LeaveSheet(), COMMON_CONTROL::ListHotKeys(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PL_EDIT_TOOL::Main(), CVPCB_CONTROL::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), LIB_CONTROL::OnDeMorgan(), COMMON_TOOLS::OnGridChanged(), POINT_EDITOR::OnSelectionChange(), LIB_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), GROUP_TOOL::PickNewMember(), EDIT_TOOL::pickReferencePoint(), LIB_EDIT_TOOL::PinTable(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PCBNEW_CONTROL::Print(), GERBVIEW_CONTROL::Print(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EE_SELECTION_TOOL::RebuildSelection(), LIB_EDIT_TOOL::Redo(), SCH_EDITOR_CONTROL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), GERBVIEW_CONTROL::ReloadAllLayers(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), GROUP_TOOL::RemoveFromGroup(), PL_SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemFromSel(), SELECTION_TOOL::RemoveItemFromSel(), PL_SELECTION_TOOL::RemoveItemsFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_DRAWING_TOOLS::RepeatDrawItem(), EE_SELECTION_TOOL::RequestSelection(), SELECTION_TOOL::RequestSelection(), COMMON_TOOLS::Reset(), PNS::TOOL_BASE::Reset(), EDA_3D_CONTROLLER::Reset(), COMMON_TOOLS::ResetLocalCoords(), TOOL_INTERACTIVE::resetTransitions(), LIB_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), DRC_TOOL::RunTests(), EE_SELECTION_TOOL::SelectConnection(), PCB_TOOL_BASE::selection(), COMMON_TOOLS::SelectionTool(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), PL_SELECTION_TOOL::SelectPoint(), GERBVIEW_SELECTION_TOOL::selectPoint(), EE_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), SELECTION_TOOL::selectSheetContents(), DRAWING_TOOL::SetAnchor(), TOOL_INTERACTIVE::SetContextMenu(), EDA_3D_CONTROLLER::SetMaterial(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), EDA_3D_CONTROLLER::ToggleVisibility(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), LIB_EDIT_TOOL::Undo(), SCH_EDITOR_CONTROL::Undo(), GROUP_TOOL::Ungroup(), GERBVIEW_SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), PNS::TOOL_BASE::updateEndItem(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PL_EDITOR_CONTROL::UpdateMessagePanel(), PCBNEW_CONTROL::UpdateMessagePanel(), PCB_INSPECTION_TOOL::UpdateSelectionRatsnest(), PNS::TOOL_BASE::updateStartItem(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), and PCB_EDITOR_CONTROL::ZoneMerge().

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Name of the tool.

Names are expected to obey the format application.ToolName (eg. pcbnew.InteractiveSelection).

Definition at line 218 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 211 of file tool_base.h.

Referenced by TOOL_BASE::GetType(), and BOARD_COMMIT::Push().


The documentation for this class was generated from the following files: