KiCad PCB EDA Suite
ROUTER_TOOL Class Reference

#include <router_tool.h>

Inheritance diagram for ROUTER_TOOL:
PNS::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 RouteSingleTrace (const TOOL_EVENT &aEvent)
 
int RouteDiffPair (const TOOL_EVENT &aEvent)
 
int InlineDrag (const TOOL_EVENT &aEvent)
 
int DpDimensionsDialog (const TOOL_EVENT &aEvent)
 
int SettingsDialog (const TOOL_EVENT &aEvent)
 
int CustomTrackWidthDialog (const TOOL_EVENT &aEvent)
 
void SetTransitions () override
 Function SetTransitions() This method is meant to be overridden in order to specify handlers for events. More...
 
const ROUTING_SETTINGS & PNSSettings () const
 
ROUTER * Router () const
 
void Activate ()
 Function Activate() Runs the tool. More...
 
void SetContextMenu (CONTEXT_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...
 
OPT_TOOL_EVENT Wait (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...
 
TOOL_SETTINGSGetSettings ()
 

Static Public Attributes

static TOOL_ACTION ACT_RouterOptions
 

Protected Member Functions

const VECTOR2I snapToItem (bool aEnabled, ITEM *aItem, VECTOR2I aP)
 
virtual ITEM * pickSingleItem (const VECTOR2I &aWhere, int aNet=-1, int aLayer=-1)
 
virtual void highlightNet (bool aEnabled, int aNetcode=-1)
 
virtual void updateStartItem (TOOL_EVENT &aEvent)
 
virtual void updateEndItem (const TOOL_EVENT &aEvent)
 
void deleteTraces (ITEM *aStartItem, bool aWholeTrack)
 
const TOOL_EVENT evActivate (std::string aToolName="")
 functions below are not yet implemented - their interface may change More...
 
const TOOL_EVENT evCommand (int aCommandId=-1)
 
const TOOL_EVENT evCommand (std::string aCommandStr="")
 
const TOOL_EVENT evMotion ()
 
const TOOL_EVENT evClick (int aButton=BUT_ANY)
 
const TOOL_EVENT evDrag (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonUp (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonDown (int aButton=BUT_ANY)
 
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

MSG_PANEL_ITEMS m_panelItems
 
ROUTING_SETTINGS m_savedSettings
 Stores routing settings between router invocations. More...
 
SIZES_SETTINGS m_savedSizes
 Stores sizes settings between router invocations. More...
 
ITEM * m_startItem
 
int m_startLayer
 
VECTOR2I m_startSnapPoint
 
ITEM * m_endItem
 
VECTOR2I m_endSnapPoint
 
PCB_EDIT_FRAMEm_frame
 
KIGFX::VIEW_CONTROLSm_ctls
 
BOARDm_board
 
GRID_HELPERm_gridHelper
 
PNS_KICAD_IFACEm_iface
 
ROUTER * m_router
 
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
 
TOOL_SETTINGS m_toolSettings
 

Private Member Functions

int mainLoop (PNS::ROUTER_MODE aMode)
 
int getDefaultWidth (int aNetCode)
 
void performRouting ()
 
void performDragging ()
 
void getNetclassDimensions (int aNetCode, int &aWidth, int &aViaDiameter, int &aViaDrill)
 
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)
 
int onLayerChanged (const TOOL_EVENT &aEvent)
 
bool prepareInteractive ()
 
bool finishInteractive ()
 

Detailed Description

Definition at line 28 of file router_tool.h.

Member Enumeration Documentation

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

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

Constructor & Destructor Documentation

ROUTER_TOOL::ROUTER_TOOL ( )

Definition at line 184 of file router_tool.cpp.

184  :
185  TOOL_BASE( "pcbnew.InteractiveRouter" )
186 {
187 }
TOOL_BASE(const std::string &aToolName)
ROUTER_TOOL::~ROUTER_TOOL ( )

Definition at line 344 of file router_tool.cpp.

References TOOL_BASE::GetSettings(), PNS::TOOL_BASE::m_savedSettings, and PNS::ROUTING_SETTINGS::Save().

345 {
347 }
ROUTING_SETTINGS m_savedSettings
Stores routing settings between router invocations.
Definition: pns_tool_base.h:71
TOOL_SETTINGS & GetSettings()
Definition: tool_base.cpp:72
void Save(TOOL_SETTINGS &where) const

Member Function Documentation

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs the tool.

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

Definition at line 49 of file tool_interactive.cpp.

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

Referenced by MODULE_EDITOR_TOOLS::CopyItems(), PCBNEW_CONTROL::DeleteItemCursor(), PCB_TOOL::doInteractiveItemPlacement(), DpDimensionsDialog(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), InlineDrag(), EDIT_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), mainLoop(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), MODULE_EDITOR_TOOLS::PasteItems(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), SettingsDialog(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

50 {
52 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:215
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID...
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 54 of file tool_base.cpp.

References TOOL_BASE::m_toolMgr, TOOL_BASE::m_toolSettings, and TOOL_BASE::TOOL_SETTINGS.

Referenced by TOOL_MANAGER::RegisterTool().

55 {
56  m_toolMgr = aManager;
57  m_toolSettings = TOOL_SETTINGS( this );
58 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:221
friend class TOOL_SETTINGS
Definition: tool_base.h:160
int ROUTER_TOOL::CustomTrackWidthDialog ( const TOOL_EVENT aEvent)

Definition at line 1023 of file router_tool.cpp.

References BOARD::GetDesignSettings(), PNS::TOOL_BASE::m_board, PNS::TOOL_BASE::m_frame, TOOL_BASE::m_toolMgr, TOOL_MANAGER::RunAction(), PCB_ACTIONS::trackViaSizeChanged, and BOARD_DESIGN_SETTINGS::UseCustomTrackViaSize().

Referenced by SetTransitions().

1024 {
1026  DIALOG_TRACK_VIA_SIZE sizeDlg( m_frame, bds );
1027 
1028  if( sizeDlg.ShowModal() )
1029  {
1030  bds.UseCustomTrackViaSize( true );
1032  }
1033 
1034  return 0;
1035 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:267
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:533
PCB_EDIT_FRAME * m_frame
Definition: pns_tool_base.h:80
Implementing DIALOG_TRACK_VIA_SIZE_BASE.
void UseCustomTrackViaSize(bool aEnabled)
Function UseCustomTrackViaSize Enables/disables custom track/via size settings.
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
void TOOL_BASE::deleteTraces ( ITEM aStartItem,
bool  aWholeTrack 
)
protectedinherited

Definition at line 282 of file pns_tool_base.cpp.

References PNS::TOPOLOGY::AssembleTrivialPath(), PNS::NODE::Branch(), PNS::ROUTER::CommitRouting(), PNS::ROUTER::GetWorld(), PNS::ITEM_SET::Items(), PNS::TOOL_BASE::m_router, and PNS::NODE::Remove().

Referenced by mainLoop().

283 {
284  NODE *node = m_router->GetWorld()->Branch();
285 
286  if( !aStartItem )
287  return;
288 
289  if( !aWholeTrack )
290  {
291  node->Remove( aStartItem );
292  }
293  else
294  {
295  TOPOLOGY topo( node );
296  ITEM_SET path = topo.AssembleTrivialPath( aStartItem );
297 
298  for( auto ent : path.Items() )
299  node->Remove( ent.item );
300  }
301 
302  m_router->CommitRouting( node );
303 }
NODE * Branch()
Function Branch()
Definition: pns_node.cpp:109
NODE * GetWorld() const
Definition: pns_router.h:134
ROUTER * m_router
Definition: pns_tool_base.h:85
void Remove(SOLID *aSolid)
Function Remove()
Definition: pns_node.cpp:729
void CommitRouting(NODE *aNode)
Definition: pns_router.cpp:317
int ROUTER_TOOL::DpDimensionsDialog ( const TOOL_EVENT aEvent)

Definition at line 761 of file router_tool.cpp.

References TOOL_INTERACTIVE::Activate(), PNS::TOOL_BASE::m_frame, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_savedSizes, PNS::ROUTER::Sizes(), and PNS::ROUTER::UpdateSizes().

Referenced by SetTransitions().

762 {
763  Activate();
764 
766  DIALOG_PNS_DIFF_PAIR_DIMENSIONS settingsDlg( m_frame, sizes );
767 
768  if( settingsDlg.ShowModal() )
769  {
770  m_router->UpdateSizes( sizes );
771  m_savedSizes = sizes;
772  }
773 
774  return 0;
775 }
SIZES_SETTINGS m_savedSizes
Stores sizes settings between router invocations.
Definition: pns_tool_base.h:72
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:197
ROUTER * m_router
Definition: pns_tool_base.h:85
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:278
PCB_EDIT_FRAME * m_frame
Definition: pns_tool_base.h:80
void Activate()
Function Activate() Runs the tool.
const TOOL_EVENT TOOL_INTERACTIVE::evActivate ( std::string  aToolName = "")
protectedinherited

functions below are not yet implemented - their interface may change

const TOOL_EVENT TOOL_INTERACTIVE::evButtonDown ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evButtonUp ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evClick ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( int  aCommandId = -1)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( std::string  aCommandStr = "")
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evDrag ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evMotion ( )
protectedinherited
bool ROUTER_TOOL::finishInteractive ( )
private

Definition at line 686 of file router_tool.cpp.

References KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PNS::TOOL_BASE::highlightNet(), PNS::TOOL_BASE::m_ctls, PNS::TOOL_BASE::m_frame, PNS::TOOL_BASE::m_router, KIGFX::VIEW_CONTROLS::SetAutoPan(), PNS::ROUTER::StopRouting(), and PCB_BASE_EDIT_FRAME::UndoRedoBlock().

Referenced by performRouting().

687 {
689 
690  m_ctls->SetAutoPan( false );
691  m_ctls->ForceCursorPosition( false );
692  m_frame->UndoRedoBlock( false );
693  highlightNet( false );
694 
695  return true;
696 }
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
KIGFX::VIEW_CONTROLS * m_ctls
Definition: pns_tool_base.h:81
ROUTER * m_router
Definition: pns_tool_base.h:85
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:359
virtual void highlightNet(bool aEnabled, int aNetcode=-1)
PCB_EDIT_FRAME * m_frame
Definition: pns_tool_base.h:80
int ROUTER_TOOL::getDefaultWidth ( int  aNetCode)
private

Definition at line 369 of file router_tool.cpp.

References getNetclassDimensions().

370 {
371  int w, d1, d2;
372 
373  getNetclassDimensions( aNetCode, w, d1, d2 );
374 
375  return w;
376 }
void getNetclassDimensions(int aNetCode, int &aWidth, int &aViaDiameter, int &aViaDrill)
template<typename T >
T* TOOL_BASE::getEditFrame ( ) const
inlineprotectedinherited

Function getEditFrame()

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

Definition at line 193 of file tool_base.h.

References TOOL_BASE::getEditFrameInt().

Referenced by ZONE_CREATE_HELPER::commitZone(), ZONE_CREATE_HELPER::createNewZone(), TOOL_SETTINGS::getConfigBase(), and ZONE_CREATE_HELPER::performZoneCutout().

194  {
195  return static_cast<T*>( getEditFrameInt() );
196  }
T
enum T contains all this lexer's tokens.
wxWindow * getEditFrameInt() const
Definition: tool_base.cpp:42
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 122 of file tool_base.h.

References TOOL_BASE::m_toolId.

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

123  {
124  return m_toolId;
125  }
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:215
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 144 of file tool_base.h.

References TOOL_BASE::m_toolMgr.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), PCB_TOOL::doInteractiveItemPlacement(), CONTEXT_MENU::getToolManager(), EDIT_TOOL::MeasureTool(), and CONTEXT_MENU::onMenuEvent().

145  {
146  return m_toolMgr;
147  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
template<typename T >
T* TOOL_BASE::getModel ( ) const
inlineprotectedinherited

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 204 of file tool_base.h.

References TOOL_BASE::getModelInt().

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

205  {
206  EDA_ITEM* m = getModelInt();
207 
208  return static_cast<T*>( m );
209  }
T
enum T contains all this lexer's tokens.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:48
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 133 of file tool_base.h.

References TOOL_BASE::m_toolName.

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

134  {
135  return m_toolName;
136  }
std::string m_toolName
Name of the tool.
Definition: tool_base.h:219
void ROUTER_TOOL::getNetclassDimensions ( int  aNetCode,
int &  aWidth,
int &  aViaDiameter,
int &  aViaDrill 
)
private

Definition at line 379 of file router_tool.cpp.

References NETCLASSES::Find(), BOARD::FindNet(), NETINFO_ITEM::GetClassName(), BOARD_DESIGN_SETTINGS::GetDefault(), BOARD::GetDesignSettings(), PNS::TOOL_BASE::m_board, and BOARD_DESIGN_SETTINGS::m_NetClasses.

Referenced by getDefaultWidth().

381 {
383 
384  NETCLASSPTR netClass;
385  NETINFO_ITEM* ni = m_board->FindNet( aNetCode );
386 
387  if( ni )
388  {
389  wxString netClassName = ni->GetClassName();
390  netClass = bds.m_NetClasses.Find( netClassName );
391  }
392 
393  if( !netClass )
394  netClass = bds.GetDefault();
395 
396  aWidth = netClass->GetTrackWidth();
397  aViaDiameter = netClass->GetViaDiameter();
398  aViaDrill = netClass->GetViaDrill();
399 }
NETCLASSPTR Find(const wxString &aName) const
Function Find searches this container for a NETCLASS given by aName.
NETCLASSPTR GetDefault() const
Function GetDefault.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:533
Class NETINFO_ITEM handles the data for a net.
Definition: class_netinfo.h:69
const wxString & GetClassName() const
Function GetClassName returns the class name.
NETINFO_ITEM * FindNet(int aNetcode) const
Function FindNet searches for a net with the given netcode.
NETCLASSES m_NetClasses
List of current netclasses. There is always the default netclass.
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 72 of file tool_base.cpp.

References TOOL_BASE::m_toolSettings.

Referenced by Init(), SELECTION_TOOL::selectable(), and ~ROUTER_TOOL().

73 {
74  return m_toolSettings;
75 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:221
int ROUTER_TOOL::getStartLayer ( const PNS::ITEM aItem)
private

Definition at line 419 of file router_tool.cpp.

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().

420 {
421  int tl = getView()->GetTopLayer();
422 
423  if( m_startItem )
424  {
425  const LAYER_RANGE& ls = m_startItem->Layers();
426 
427  if( ls.Overlaps( tl ) )
428  return tl;
429  else
430  return ls.Start();
431  }
432 
433  return tl;
434 }
int GetTopLayer() const
Definition: view.cpp:739
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:207
ITEM * m_startItem
Definition: pns_tool_base.h:73
int Start() const
Definition: pns_layerset.h:83
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:68
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
Class LAYER_RANGE.
Definition: pns_layerset.h:32
TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 111 of file tool_base.h.

References TOOL_BASE::m_type.

Referenced by TOOL_MANAGER::InvokeTool(), and TOOL_MANAGER::runTool().

112  {
113  return m_type;
114  }
TOOL_TYPE m_type
Stores the type of the tool.
Definition: tool_base.h:212
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 30 of file tool_base.cpp.

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

Referenced by PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), SELECTION_TOOL::disambiguationMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findCallback(), getStartLayer(), PCBNEW_CONTROL::GridSetOrigin(), PCBNEW_CONTROL::HighContrastMode(), PNS::TOOL_BASE::highlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), EDIT_TOOL::Main(), EDIT_TOOL::MeasureTool(), MODULE_EDITOR_TOOLS::ModuleEdgeOutlines(), MODULE_EDITOR_TOOLS::ModuleTextOutlines(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PCBNEW_CONTROL::PadDisplayMode(), PCBNEW_CONTROL::PanControl(), PNS::TOOL_BASE::pickSingleItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PCB_EDITOR_CONTROL::Reset(), PCBNEW_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), DRAWING_TOOL::Reset(), SELECTION_TOOL::Reset(), SELECTION_TOOL::selectable(), SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), PCBNEW_CONTROL::TrackDisplayMode(), POINT_EDITOR::updateEditedPoint(), COMMON_TOOLS::updateGrid(), PCBNEW_CONTROL::updateGrid(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCBNEW_CONTROL::ViaDisplayMode(), PCB_TOOL::view(), PCBNEW_CONTROL::ZoneDisplayMode(), COMMON_TOOLS::ZoomFitScreen(), SELECTION_TOOL::zoomFitSelection(), COMMON_TOOLS::ZoomInOutCenter(), and SELECTION_TOOL::~SELECTION_TOOL().

31 {
32  return m_toolMgr->GetView();
33 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:243
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 36 of file tool_base.cpp.

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

Referenced by POINT_EDITOR::addCorner(), PCBNEW_CONTROL::AppendBoard(), PCB_TOOL::controls(), MODULE_EDITOR_TOOLS::CopyItems(), PCBNEW_CONTROL::CursorControl(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawZone(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findMove(), EDIT_TOOL::getModificationPoint(), PCB_EDITOR_CONTROL::HighlightNet(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), mainLoop(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), MODULE_EDITOR_TOOLS::PasteItems(), performDragging(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PNS::TOOL_BASE::Reset(), DRAWING_TOOL::Reset(), PCBNEW_CONTROL::ResetCoords(), DRAWING_TOOL::runPolygonEventLoop(), SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), PICKER_TOOL::setControls(), POINT_EDITOR::setEditedPoint(), COMMON_TOOLS::ZoomCenter(), and COMMON_TOOLS::ZoomInOut().

37 {
38  return m_toolMgr->GetViewControls();
39 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:248
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 122 of file tool_interactive.h.

References TOOL_INTERACTIVE::goInternal().

Referenced by LENGTH_TUNER_TOOL::Reset(), ZOOM_TOOL::SetTransitions(), LENGTH_TUNER_TOOL::SetTransitions(), SetTransitions(), PAD_TOOL::SetTransitions(), MICROWAVE_TOOL::SetTransitions(), POINT_EDITOR::SetTransitions(), COMMON_TOOLS::SetTransitions(), ALIGN_DISTRIBUTE_TOOL::SetTransitions(), PCBNEW_CONTROL::SetTransitions(), POSITION_RELATIVE_TOOL::SetTransitions(), MODULE_EDITOR_TOOLS::SetTransitions(), PICKER_TOOL::SetTransitions(), PCB_EDITOR_CONTROL::SetTransitions(), EDIT_TOOL::SetTransitions(), SELECTION_TOOL::SetTransitions(), and DRAWING_TOOL::SetTransitions().

124 {
125  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
126 
127  goInternal( sptr, aConditions );
128 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:59
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)
void ROUTER_TOOL::handleCommonEvents ( const TOOL_EVENT evt)
private

Definition at line 402 of file router_tool.cpp.

References PNS::ROUTER::DumpLog(), TOOL_EVENT::IsKeyPressed(), TOOL_EVENT::KeyCode(), and PNS::TOOL_BASE::m_router.

Referenced by performDragging().

403 {
404 #ifdef DEBUG
405  if( aEvent.IsKeyPressed() )
406  {
407  switch( aEvent.KeyCode() )
408  {
409  case '0':
410  wxLogTrace( "PNS", "saving drag/route log...\n" );
411  m_router->DumpLog();
412  break;
413  }
414  }
415 #endif
416 }
ROUTER * m_router
Definition: pns_tool_base.h:85
void DumpLog()
Definition: pns_router.cpp:436
void TOOL_BASE::highlightNet ( bool  aEnabled,
int  aNetcode = -1 
)
protectedvirtualinherited

Definition at line 197 of file pns_tool_base.cpp.

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

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

198 {
200 
201  if( aNetcode >= 0 && aEnabled )
202  rs->SetHighlight( true, aNetcode );
203  else
204  rs->SetHighlight( false );
205 
207 }
Class RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output ...
Definition: painter.h:56
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
void UpdateAllLayersColor()
Function UpdateAllLayersColor() Applies the new coloring scheme to all layers.
Definition: view.cpp:674
void SetHighlight(bool aEnabled, int aNetcode=-1)
Function SetHighlight Turns on/off highlighting - it may be done for the active layer or the specifie...
Definition: painter.h:140
bool ROUTER_TOOL::Init ( )
overridevirtual

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

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

Reimplemented from TOOL_BASE.

Definition at line 350 of file router_tool.cpp.

References CONDITIONAL_MENU::AddItem(), SELECTION_CONDITIONS::Count(), EOT, TOOL_BASE::GetSettings(), TOOL_MANAGER::GetTool(), PNS::ROUTING_SETTINGS::Load(), PNS::TOOL_BASE::m_savedSettings, TOOL_BASE::m_toolMgr, SELECTION_CONDITIONS::OnlyTypes(), PCB_TRACE_T, PCB_VIA_T, and PCB_ACTIONS::routerInlineDrag.

351 {
352  // Track & via dragging menu entry
353  auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
354  CONDITIONAL_MENU& menu = selectionTool->GetToolMenu().GetMenu();
357 
359  return true;
360 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
static SELECTION_CONDITION Count(int aNumber)
Function Count Creates a functor that tests if the number of selected items is equal to the value giv...
search types array terminator (End Of Types)
Definition: typeinfo.h:94
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:107
static SELECTION_CONDITION OnlyTypes(const std::vector< KICAD_T > &aTypes)
Function OnlyTypes Creates a functor that tests if the selected items are only of given types...
void Load(const TOOL_SETTINGS &where)
ROUTING_SETTINGS m_savedSettings
Stores routing settings between router invocations.
Definition: pns_tool_base.h:71
TOOL_SETTINGS & GetSettings()
Definition: tool_base.cpp:72
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:198
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddItem()
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:108
int ROUTER_TOOL::InlineDrag ( const TOOL_EVENT aEvent)

Definition at line 955 of file router_tool.cpp.

References TOOL_INTERACTIVE::Activate(), BUT_LEFT, PNS::NODE::FindItemByParent(), PNS::ROUTER::FixRoute(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_MANAGER::GetTool(), PNS::ROUTER::GetWorld(), PNS::ITEM::IsLocked(), IsOK(), PNS::TOOL_BASE::m_ctls, PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_frame, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, TOOL_BASE::m_toolMgr, PNS::ROUTER::Move(), PCB_TRACE_T, PCB_VIA_T, PNS::ROUTER::RoutingInProgress(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectionCursor, KIGFX::VIEW_CONTROLS::SetAutoPan(), KIGFX::VIEW_CONTROLS::ShowCursor(), PNS::ROUTER::StartDragging(), PNS::ROUTER::StopRouting(), PNS::ROUTER::SyncWorld(), EDA_ITEM::Type(), PCB_BASE_EDIT_FRAME::UndoRedoBlock(), PNS::TOOL_BASE::updateEndItem(), and TOOL_INTERACTIVE::Wait().

Referenced by SetTransitions().

956 {
957  // Get the item under the cursor
959  const auto& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
960 
961  if( selection.Size() != 1 )
962  return 0;
963 
964  const BOARD_CONNECTED_ITEM* item = static_cast<const BOARD_CONNECTED_ITEM*>( selection.Front() );
965 
966  if( item->Type() != PCB_TRACE_T && item->Type() != PCB_VIA_T )
967  return 0;
968 
969  Activate();
970 
972  m_router->SyncWorld();
974 
975  if( m_startItem && m_startItem->IsLocked() )
976  {
977  if( !IsOK( m_frame, _( "The item is locked. Do you want to continue?" ) ) )
978  return false;
979  }
980 
982 
983  bool dragStarted = m_router->StartDragging( p0, m_startItem );
984 
985  if( !dragStarted )
986  return 0;
987 
988  m_ctls->ShowCursor( true );
989  m_ctls->ForceCursorPosition( false );
990  m_ctls->SetAutoPan( true );
991  m_frame->UndoRedoBlock( true );
992 
993  while( OPT_TOOL_EVENT evt = Wait() )
994  {
995  if( evt->IsCancel() )
996  {
997  break;
998  }
999  else if( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
1000  {
1001  updateEndItem( *evt );
1003  }
1004  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
1005  {
1006  updateEndItem( *evt );
1008  break;
1009  }
1010  }
1011 
1012  if( m_router->RoutingInProgress() )
1013  m_router->StopRouting();
1014 
1015  m_ctls->SetAutoPan( false );
1016  m_ctls->ShowCursor( false );
1017  m_frame->UndoRedoBlock( false );
1018 
1019  return 0;
1020 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
Class SELECTION_TOOL.
bool StartDragging(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:127
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
void SyncWorld()
Definition: pns_router.cpp:91
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
NODE * GetWorld() const
Definition: pns_router.h:134
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:107
KIGFX::VIEW_CONTROLS * m_ctls
Definition: pns_tool_base.h:81
bool RoutingInProgress() const
Definition: pns_router.cpp:112
virtual void updateEndItem(const TOOL_EVENT &aEvent)
bool IsLocked() const
Definition: pns_item.h:336
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
ITEM * m_startItem
Definition: pns_tool_base.h:73
bool FixRoute(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:334
ROUTER * m_router
Definition: pns_tool_base.h:85
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:195
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:359
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:78
PCB_EDIT_FRAME * m_frame
Definition: pns_tool_base.h:80
ITEM * FindItemByParent(const BOARD_CONNECTED_ITEM *aParent)
Definition: pns_node.cpp:1330
void Activate()
Function Activate() Runs the tool.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:108
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:129
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:50
int ROUTER_TOOL::mainLoop ( PNS::ROUTER_MODE  aMode)
private

Definition at line 828 of file router_tool.cpp.

References ACT_NewTrack, ACT_PlaceThroughVia, TOOL_INTERACTIVE::Activate(), BUT_LEFT, PNS::ROUTER::ClearWorld(), PNS::TOOL_BASE::deleteTraces(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_BASE::getViewControls(), TOOL_EVT_UTILS::IsCancelInteractive(), PCB_ACTIONS::layerToggle, PNS::TOOL_BASE::m_ctls, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_savedSettings, PNS::TOOL_BASE::m_savedSizes, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, TOOL_BASE::m_toolMgr, MD_CTRL, performDragging(), performRouting(), PCB_ACTIONS::remove, PCB_ACTIONS::removeAlt, TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, TOOL_INTERACTIVE::SetContextMenu(), PNS::ROUTER::SetMode(), EDA_DRAW_FRAME::SetNoToolSelected(), PNS::ROUTER::Settings(), KIGFX::VIEW_CONTROLS::ShowCursor(), PNS::ROUTER::Sizes(), PNS::ROUTER::SyncWorld(), TA_MODEL_CHANGE, TA_UNDO_REDO_POST, TA_UNDO_REDO_PRE, PNS::TOOL_BASE::updateStartItem(), and TOOL_INTERACTIVE::Wait().

Referenced by RouteDiffPair(), and RouteSingleTrace().

829 {
830  PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
831  BOARD* board = getModel<BOARD>();
832 
833  // Deselect all items
835 
836  Activate();
837 
838  m_router->SetMode( aMode );
839 
840  m_ctls->ShowCursor( true );
841 
843 
844  std::unique_ptr<ROUTER_TOOL_MENU> ctxMenu( new ROUTER_TOOL_MENU( board, *frame, aMode ) );
845  SetContextMenu( ctxMenu.get() );
846 
847  // Main loop: keep receiving events
848  while( OPT_TOOL_EVENT evt = Wait() )
849  {
851  {
852  break; // Finish
853  }
854  else if( evt->Action() == TA_UNDO_REDO_PRE )
855  {
856  m_router->ClearWorld();
857  }
858  else if( evt->Action() == TA_UNDO_REDO_POST || evt->Action() == TA_MODEL_CHANGE )
859  {
860  m_router->SyncWorld();
861  }
862  else if( evt->IsMotion() )
863  {
864  updateStartItem( *evt );
865  }
866  else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &ACT_NewTrack ) )
867  {
868  updateStartItem( *evt );
869 
870  if( evt->Modifier( MD_CTRL ) )
871  performDragging();
872  else
873  performRouting();
874  }
875  else if( evt->IsAction( &ACT_PlaceThroughVia ) )
876  {
878  }
879  else if( evt->IsAction( &PCB_ACTIONS::remove ) )
880  {
881  deleteTraces( m_startItem, true );
882  }
883  else if( evt->IsAction( &PCB_ACTIONS::removeAlt ) )
884  {
885  deleteTraces( m_startItem, false );
886  }
887  }
888 
889  frame->SetNoToolSelected();
890  SetContextMenu( nullptr );
891 
892  // Store routing settings till the next invocation
895 
896  return 0;
897 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:75
static const TOOL_ACTION ACT_NewTrack("pcbnew.InteractiveRouter.NewTrack", AS_CONTEXT, TOOL_ACTION::LegacyHotKey(HK_ADD_NEW_TRACK), _("New Track"), _("Starts laying a new track."), add_tracks_xpm)
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
SIZES_SETTINGS m_savedSizes
Stores sizes settings between router invocations.
Definition: pns_tool_base.h:72
void SyncWorld()
Definition: pns_router.cpp:91
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
static TOOL_ACTION removeAlt
Definition: pcb_actions.h:121
static const TOOL_ACTION ACT_PlaceThroughVia("pcbnew.InteractiveRouter.PlaceVia", AS_CONTEXT, TOOL_ACTION::LegacyHotKey(HK_ADD_THROUGH_VIA), _("Place Through Via"), _("Adds a through-hole via at the end of currently routed track."), via_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::VIA)
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:197
void ClearWorld()
Definition: pns_router.cpp:100
KIGFX::VIEW_CONTROLS * m_ctls
Definition: pns_tool_base.h:81
void performRouting()
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
ITEM * m_startItem
Definition: pns_tool_base.h:73
ROUTER * m_router
Definition: pns_tool_base.h:85
void SetContextMenu(CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
Function SetContextMenu()
ROUTING_SETTINGS m_savedSettings
Stores routing settings between router invocations.
Definition: pns_tool_base.h:71
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
void performDragging()
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:36
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Definition: draw_frame.cpp:560
void SetMode(ROUTER_MODE aMode)
Definition: pns_router.cpp:477
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
void deleteTraces(ITEM *aStartItem, bool aWholeTrack)
void Activate()
Function Activate() Runs the tool.
static TOOL_ACTION remove
Deleting a BOARD_ITEM.
Definition: pcb_actions.h:120
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:178
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:257
virtual void updateStartItem(TOOL_EVENT &aEvent)
int ROUTER_TOOL::onLayerChanged ( const TOOL_EVENT aEvent)
private
int ROUTER_TOOL::onTrackViaSizeChanged ( const TOOL_EVENT aEvent)
private

Definition at line 1038 of file router_tool.cpp.

References BOARD::GetDesignSettings(), PNS::SIZES_SETTINGS::ImportCurrent(), PNS::TOOL_BASE::m_board, PNS::TOOL_BASE::m_router, PNS::ROUTER::Sizes(), and PNS::ROUTER::UpdateSizes().

Referenced by SetTransitions().

1039 {
1040  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
1042  m_router->UpdateSizes( sizes );
1043 
1044  return 0;
1045 }
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:197
ROUTER * m_router
Definition: pns_tool_base.h:85
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:533
void ImportCurrent(BOARD_DESIGN_SETTINGS &aSettings)
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:278
int ROUTER_TOOL::onViaCommand ( const TOOL_EVENT aEvent)
private

Definition at line 482 of file router_tool.cpp.

References PNS::SIZES_SETTINGS::AddLayerPair(), LSET::AllNonCuMask(), B_Cu, PNS::SIZES_SETTINGS::ClearLayerPairs(), DisplayError(), F_Cu, BOARD_DESIGN_SETTINGS::GetCopperLayerCount(), PNS::ROUTER::GetCurrentLayer(), BOARD_DESIGN_SETTINGS::GetCurrentMicroViaDrill(), BOARD_DESIGN_SETTINGS::GetCurrentMicroViaSize(), BOARD_DESIGN_SETTINGS::GetCurrentViaDrill(), BOARD_DESIGN_SETTINGS::GetCurrentViaSize(), BOARD::GetDesignSettings(), PCB_BASE_FRAME::GetScreen(), getViaTypeFromFlags(), In1_Cu, PNS::ROUTER::IsPlacingVia(), BOARD_DESIGN_SETTINGS::m_BlindBuriedViaAllowed, PNS::TOOL_BASE::m_board, PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_frame, BOARD_DESIGN_SETTINGS::m_MicroViasAllowed, PCB_SCREEN::m_Route_Layer_BOTTOM, PCB_SCREEN::m_Route_Layer_TOP, PNS::TOOL_BASE::m_router, PNS::ROUTER::Move(), TOOL_EVENT::Parameter(), SELECT_LAYER, PCB_BASE_FRAME::SelectLayer(), PNS::SIZES_SETTINGS::SetViaDiameter(), PNS::SIZES_SETTINGS::SetViaDrill(), PNS::SIZES_SETTINGS::SetViaType(), PNS::ROUTER::Sizes(), PNS::ROUTER::ToggleViaPlacement(), UNDEFINED_LAYER, PNS::TOOL_BASE::updateEndItem(), PNS::ROUTER::UpdateSizes(), VIA_BLIND_BURIED, VIA_MICROVIA, and VIA_THROUGH.

Referenced by SetTransitions().

483 {
484  const int actViaFlags = aEvent.Parameter<intptr_t>();
485 
486  VIATYPE_T viaType = getViaTypeFromFlags( actViaFlags );
487  const bool selectLayer = actViaFlags & VIA_ACTION_FLAGS::SELECT_LAYER;
488 
490 
491  const int layerCount = bds.GetCopperLayerCount();
492  int currentLayer = m_router->GetCurrentLayer();
495 
497 
498  // ask the user for a target layer
499  PCB_LAYER_ID targetLayer = UNDEFINED_LAYER;
500 
501  if( selectLayer )
502  {
503  wxPoint dlgPosition = wxGetMousePosition();
504 
505  targetLayer = m_frame->SelectLayer( static_cast<PCB_LAYER_ID>( currentLayer ),
506  LSET::AllNonCuMask(), dlgPosition );
507  }
508 
509  // fixme: P&S supports more than one fixed layer pair. Update the dialog?
510  sizes.ClearLayerPairs();
511 
512  if( !m_router->IsPlacingVia() )
513  {
514  // Cannot place microvias or blind vias if not allowed (obvious)
515  if( ( viaType == VIA_BLIND_BURIED ) && ( !bds.m_BlindBuriedViaAllowed ) )
516  {
517  DisplayError( m_frame, _( "Blind/buried vias have to be enabled in the design settings." ) );
518  return false;
519  }
520 
521  if( ( viaType == VIA_MICROVIA ) && ( !bds.m_MicroViasAllowed ) )
522  {
523  DisplayError( m_frame, _( "Microvias have to be enabled in the design settings." ) );
524  return false;
525  }
526 
527  // Can only place through vias on 2-layer boards
528  if( ( viaType != VIA_THROUGH ) && ( layerCount <= 2 ) )
529  {
530  DisplayError( m_frame, _( "Only through vias are allowed on 2 layer boards." ) );
531  return false;
532  }
533 
534  // Can only place microvias if we're on an outer layer, or directly adjacent to one
535  if( ( viaType == VIA_MICROVIA ) && ( currentLayer > In1_Cu ) && ( currentLayer < layerCount - 2 ) )
536  {
537  DisplayError( m_frame, _( "Microvias can be placed only between the outer layers " \
538  "(F.Cu/B.Cu) and the ones directly adjacent to them." ) );
539  return false;
540  }
541  }
542 
543  // Convert blind/buried via to a through hole one, if it goes through all layers
544  if( viaType == VIA_BLIND_BURIED && ( ( currentLayer == B_Cu ) || ( currentLayer == F_Cu ) )
545  && ( ( pairTop == B_Cu && pairBottom == F_Cu )
546  || ( pairTop == F_Cu && pairBottom == B_Cu ) ) )
547  {
548  viaType = VIA_THROUGH;
549  }
550 
551  switch( viaType )
552  {
553  case VIA_THROUGH:
554  sizes.SetViaDiameter( bds.GetCurrentViaSize() );
555  sizes.SetViaDrill( bds.GetCurrentViaDrill() );
556 
557  if( targetLayer != UNDEFINED_LAYER )
558  {
559  // go from the current layer to the chosen layer
560  sizes.AddLayerPair( currentLayer, targetLayer );
561  }
562  else
563  {
564  // use the default layer pair
565  sizes.AddLayerPair( pairTop, pairBottom );
566  }
567  break;
568 
569  case VIA_MICROVIA:
570  sizes.SetViaDiameter( bds.GetCurrentMicroViaSize() );
571  sizes.SetViaDrill( bds.GetCurrentMicroViaDrill() );
572 
573  wxASSERT_MSG( !selectLayer, "Unexpected select layer for microvia (microvia layers are implicit)" );
574 
575  if( currentLayer == F_Cu || currentLayer == In1_Cu )
576  {
577  // front-side microvia
578  sizes.AddLayerPair( F_Cu, In1_Cu );
579  }
580  else if( currentLayer == B_Cu || currentLayer == layerCount - 2 )
581  {
582  // back-side microvia
583  sizes.AddLayerPair( B_Cu, layerCount - 2 );
584  }
585  else
586  {
587  wxASSERT_MSG( false, "Invalid layer pair for microvia (must be on or adjacent to an outer layer)" );
588  }
589  break;
590 
591  case VIA_BLIND_BURIED:
592  sizes.SetViaDiameter( bds.GetCurrentViaSize() );
593  sizes.SetViaDrill( bds.GetCurrentViaDrill() );
594 
595  if( targetLayer != UNDEFINED_LAYER )
596  {
597  // go directly to the user specified layer
598  sizes.AddLayerPair( currentLayer, targetLayer );
599  }
600  else
601  {
602  if( currentLayer == pairTop || currentLayer == pairBottom )
603  {
604  // the current layer is on the defined layer pair,
605  // swap to the other side
606  sizes.AddLayerPair( pairTop, pairBottom );
607  }
608  else
609  {
610  // the current layer is not part of the current layer pair,
611  // so fallback and swap to the top layer of the pair by default
612  sizes.AddLayerPair( pairTop, currentLayer );
613  }
614  }
615  break;
616 
617  default:
618  wxASSERT( false );
619  break;
620  }
621 
622  sizes.SetViaType( viaType );
623 
624  m_router->UpdateSizes( sizes );
626 
627  updateEndItem( aEvent );
628 
629  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
630 
631  return 0;
632 }
int GetCurrentMicroViaSize()
Function GetCurrentMicroViaSize.
int GetCurrentViaDrill() const
Function GetCurrentViaDrill.
int GetCurrentMicroViaDrill()
Function GetCurrentMicroViaDrill.
static LSET AllNonCuMask()
Function AllNonCuMask returns a mask holding all layer minus CU layers.
Definition: lset.cpp:662
Microvia
Definition: router_tool.cpp:78
void SetViaDrill(int aDrill)
bool IsPlacingVia() const
Definition: pns_router.cpp:459
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:197
VIATYPE_T
Definition: class_track.h:49
int GetCurrentViaSize() const
Function GetCurrentViaSize.
void ToggleViaPlacement()
Definition: pns_router.cpp:409
virtual void updateEndItem(const TOOL_EVENT &aEvent)
PCB_LAYER_ID
A quick note on layer IDs:
int GetCopperLayerCount() const
Function GetCopperLayerCount.
ROUTER * m_router
Definition: pns_tool_base.h:85
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:533
PCB_LAYER_ID m_Route_Layer_BOTTOM
bool m_BlindBuriedViaAllowed
true to allow blind/buried vias
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:195
void SetViaType(VIATYPE_T aViaType)
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:373
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:278
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:78
PCB_EDIT_FRAME * m_frame
Definition: pns_tool_base.h:80
PCB_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
int GetCurrentLayer() const
Definition: pns_router.cpp:428
void AddLayerPair(int aL1, int aL2)
static VIATYPE_T getViaTypeFromFlags(int aFlags)
bool m_MicroViasAllowed
true to allow micro vias
void SetViaDiameter(int aDiameter)
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:71
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:220
PCB_LAYER_ID m_Route_Layer_TOP
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
void ROUTER_TOOL::performDragging ( )
private

Definition at line 900 of file router_tool.cpp.

References BUT_LEFT, PNS::ROUTER::FixRoute(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), TOOL_BASE::getViewControls(), handleCommonEvents(), PNS::TOOL_BASE::highlightNet(), TOOL_EVT_UTILS::IsCancelInteractive(), PNS::ITEM::IsLocked(), IsOK(), PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_frame, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, PNS::ROUTER::Move(), PNS::ITEM::Net(), PNS::ROUTER::RoutingInProgress(), KIGFX::VIEW_CONTROLS::SetAutoPan(), PNS::ROUTER::StartDragging(), PNS::ROUTER::StopRouting(), PCB_BASE_EDIT_FRAME::UndoRedoBlock(), PNS::TOOL_BASE::updateEndItem(), and TOOL_INTERACTIVE::Wait().

Referenced by mainLoop().

901 {
902  VIEW_CONTROLS* ctls = getViewControls();
903 
904  if( m_startItem && m_startItem->IsLocked() )
905  {
906  if( !IsOK( m_frame, _( "The item is locked. Do you want to continue?" ) ) )
907  return;
908  }
909 
910  bool dragStarted = m_router->StartDragging( m_startSnapPoint, m_startItem );
911 
912  if( !dragStarted )
913  return;
914 
915  if( m_startItem && m_startItem->Net() >= 0 )
916  highlightNet( true, m_startItem->Net() );
917 
918  ctls->SetAutoPan( true );
919 
920  m_frame->UndoRedoBlock( true );
921 
922  while( OPT_TOOL_EVENT evt = Wait() )
923  {
924  ctls->ForceCursorPosition( false );
925 
926  if( evt->IsMotion() )
927  {
928  updateEndItem( *evt );
930  }
931  else if( evt->IsClick( BUT_LEFT ) )
932  {
934  break;
935  }
936  else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt )
937  || evt->IsUndoRedo() )
938  break;
939 
940  handleCommonEvents( *evt );
941  }
942 
943  if( m_router->RoutingInProgress() )
945 
946  m_startItem = NULL;
947 
948  m_frame->UndoRedoBlock( false );
949  ctls->SetAutoPan( false );
950  ctls->ForceCursorPosition( false );
951  highlightNet( false );
952 }
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:75
bool StartDragging(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:127
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
void handleCommonEvents(const TOOL_EVENT &evt)
bool RoutingInProgress() const
Definition: pns_router.cpp:112
virtual void updateEndItem(const TOOL_EVENT &aEvent)
bool IsLocked() const
Definition: pns_item.h:336
ITEM * m_startItem
Definition: pns_tool_base.h:73
bool FixRoute(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:334
ROUTER * m_router
Definition: pns_tool_base.h:85
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
Definition: view_controls.h:94
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:195
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg...
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:36
void StopRouting()
Definition: pns_router.cpp:359
virtual void highlightNet(bool aEnabled, int aNetcode=-1)
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:78
PCB_EDIT_FRAME * m_frame
Definition: pns_tool_base.h:80
int Net() const
Function Net()
Definition: pns_item.h:177
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:129
void ROUTER_TOOL::performRouting ( )
private

Definition at line 699 of file router_tool.cpp.

References ACT_EndTrack, ACT_SwitchPosture, BUT_LEFT, finishInteractive(), PNS::ROUTER::FixRoute(), PNS::ROUTER::FlipPosture(), PCB_BASE_FRAME::GetActiveLayer(), PNS::ROUTER::GetCurrentLayer(), TOOL_EVT_UTILS::IsCancelInteractive(), PNS::ROUTER::IsPlacingVia(), PCB_ACTIONS::layerChanged, PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_frame, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, MD_CTRL, PNS::ROUTER::Move(), prepareInteractive(), PCB_ACTIONS::routerInlineDrag, PNS::ROUTER::RoutingInProgress(), PCB_EDIT_FRAME::SetActiveLayer(), PNS::ROUTER::SetOrthoMode(), PNS::ROUTER::SwitchLayer(), switchLayerOnViaPlacement(), ToLAYER_ID(), PNS::TOOL_BASE::updateEndItem(), and TOOL_INTERACTIVE::Wait().

Referenced by mainLoop().

700 {
701  if( !prepareInteractive() )
702  return;
703 
704  while( OPT_TOOL_EVENT evt = Wait() )
705  {
706  // Don't crash if we missed an operation that cancelled routing.
707  wxCHECK2( m_router->RoutingInProgress(), break );
708 
709  if( evt->IsMotion() )
710  {
711  m_router->SetOrthoMode( evt->Modifier( MD_CTRL ) );
712  updateEndItem( *evt );
714  }
715  else if( evt->IsClick( BUT_LEFT ) )
716  {
717  updateEndItem( *evt );
718  bool needLayerSwitch = m_router->IsPlacingVia();
719 
721  break;
722 
723  if( needLayerSwitch )
725 
726  // Synchronize the indicated layer
728  updateEndItem( *evt );
730  m_startItem = NULL;
731  }
732  else if( evt->IsAction( &ACT_SwitchPosture ) )
733  {
735  updateEndItem( *evt );
736  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
737  }
738  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
739  {
741  updateEndItem( *evt );
742  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
743  }
744  else if( evt->IsAction( &ACT_EndTrack ) )
745  {
746  bool still_routing = true;
747  while( still_routing )
748  still_routing = m_router->FixRoute( m_endSnapPoint, m_endItem );
749  break;
750  }
751  else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt )
752  || evt->IsUndoRedo()
753  || evt->IsAction( &PCB_ACTIONS::routerInlineDrag ) )
754  break;
755  }
756 
758 }
bool finishInteractive()
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
bool IsPlacingVia() const
Definition: pns_router.cpp:459
void SwitchLayer(int layer)
Definition: pns_router.cpp:396
void SetOrthoMode(bool aEnable)
Definition: pns_router.cpp:468
bool RoutingInProgress() const
Definition: pns_router.cpp:112
virtual void updateEndItem(const TOOL_EVENT &aEvent)
bool prepareInteractive()
ITEM * m_startItem
Definition: pns_tool_base.h:73
bool FixRoute(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:334
static const TOOL_ACTION ACT_SwitchPosture("pcbnew.InteractiveRouter.SwitchPosture", AS_CONTEXT, TOOL_ACTION::LegacyHotKey(HK_SWITCH_TRACK_POSTURE), _("Switch Track Posture"), _("Switches posture of the currently routed track."), change_entry_orient_xpm)
ROUTER * m_router
Definition: pns_tool_base.h:85
void switchLayerOnViaPlacement()
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:195
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:198
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:259
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:78
PCB_EDIT_FRAME * m_frame
Definition: pns_tool_base.h:80
int GetCurrentLayer() const
Definition: pns_router.cpp:428
static const TOOL_ACTION ACT_EndTrack("pcbnew.InteractiveRouter.EndTrack", AS_CONTEXT, WXK_END, _("End Track"), _("Stops laying the current track."), checked_ok_xpm)
void FlipPosture()
Definition: pns_router.cpp:387
virtual void SetActiveLayer(PCB_LAYER_ID aLayer) override
Function SetActiveLayer will change the currently active layer to aLayer and also update the PCB_LAYE...
Definition: pcbframe.cpp:883
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:767
ITEM * TOOL_BASE::pickSingleItem ( const VECTOR2I aWhere,
int  aNet = -1,
int  aLayer = -1 
)
protectedvirtualinherited

Definition at line 124 of file pns_tool_base.cpp.

References PCB_BASE_FRAME::GetDisplayOptions(), KIGFX::VIEW::GetTopLayer(), TOOL_BASE::getView(), IsCopperLayer(), PNS::ITEM_SET::Items(), PNS::ITEM::KindStr(), PNS::ITEM::Layers(), PNS::TOOL_BASE::m_router, LAYER_RANGE::Overlaps(), PNS::ROUTER::QueryHoverItems(), PNS::ITEM::SOLID_T, LAYER_RANGE::Start(), and PNS::ITEM::VIA_T.

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

125 {
126  int tl = getView()->GetTopLayer();
127 
128  if( aLayer > 0 )
129  tl = aLayer;
130 
131  ITEM* prioritized[4];
132 
133  for( int i = 0; i < 4; i++ )
134  prioritized[i] = 0;
135 
136  ITEM_SET candidates = m_router->QueryHoverItems( aWhere );
137 
138  for( ITEM* item : candidates.Items() )
139  {
140  if( !IsCopperLayer( item->Layers().Start() ) )
141  continue;
142 
143  // fixme: this causes flicker with live loop removal...
144  //if( item->Parent() && !item->Parent()->ViewIsVisible() )
145  // continue;
146 
147  if( aNet < 0 || item->Net() == aNet )
148  {
149  if( item->OfKind( ITEM::VIA_T | ITEM::SOLID_T ) )
150  {
151  if( !prioritized[2] )
152  prioritized[2] = item;
153  if( item->Layers().Overlaps( tl ) )
154  prioritized[0] = item;
155  }
156  else
157  {
158  if( !prioritized[3] )
159  prioritized[3] = item;
160  if( item->Layers().Overlaps( tl ) )
161  prioritized[1] = item;
162  }
163  }
164  }
165 
166  ITEM* rv = NULL;
167  PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
168  DISPLAY_OPTIONS* displ_opts = (DISPLAY_OPTIONS*)frame->GetDisplayOptions();
169 
170  for( int i = 0; i < 4; i++ )
171  {
172  ITEM* item = prioritized[i];
173 
174  if( displ_opts->m_ContrastModeDisplay )
175  if( item && !item->Layers().Overlaps( tl ) )
176  item = NULL;
177 
178  if( item )
179  {
180  rv = item;
181  break;
182  }
183  }
184 
185  if( rv && aLayer >= 0 && !rv->Layers().Overlaps( aLayer ) )
186  rv = NULL;
187 
188  if( rv )
189  {
190  wxLogTrace( "PNS", "%s, layer : %d, tl: %d", rv->KindStr().c_str(), rv->Layers().Start(), tl );
191  }
192 
193  return rv;
194 }
int GetTopLayer() const
Definition: view.cpp:739
const ITEM_SET QueryHoverItems(const VECTOR2I &aP)
Definition: pns_router.cpp:118
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
ROUTER * m_router
Definition: pns_tool_base.h:85
Class DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
Definition: pcbstruct.h:62
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
const ROUTING_SETTINGS& PNS::TOOL_BASE::PNSSettings ( ) const
inlineinherited

Definition at line 54 of file pns_tool_base.h.

Referenced by EDIT_TOOL::invokeInlineRouter().

55  {
56  return m_savedSettings;
57  }
ROUTING_SETTINGS m_savedSettings
Stores routing settings between router invocations.
Definition: pns_tool_base.h:71
bool ROUTER_TOOL::prepareInteractive ( )
private

Definition at line 635 of file router_tool.cpp.

References NETCLASS::Default, DisplayError(), PNS::ROUTER::FailureReason(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), BOARD_CONNECTED_ITEM::GetNetClass(), PCB_BASE_FRAME::GetScreen(), getStartLayer(), PNS::TOOL_BASE::highlightNet(), PNS::SIZES_SETTINGS::Init(), IsCopperLayer(), PNS::TOOL_BASE::m_board, PNS::TOOL_BASE::m_ctls, PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_frame, PCB_SCREEN::m_Route_Layer_BOTTOM, PCB_SCREEN::m_Route_Layer_TOP, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, PNS::ITEM::Net(), PNS::ITEM::Parent(), PCB_EDIT_FRAME::SetActiveLayer(), KIGFX::VIEW_CONTROLS::SetAutoPan(), PCB_EDIT_FRAME::SetCurrentNetClass(), PNS::ROUTER::Sizes(), PNS::ROUTER::StartRouting(), ToLAYER_ID(), PCB_BASE_EDIT_FRAME::UndoRedoBlock(), and PNS::ROUTER::UpdateSizes().

Referenced by performRouting().

636 {
637  int routingLayer = getStartLayer( m_startItem );
638 
639  if( !IsCopperLayer( routingLayer ) )
640  {
641  DisplayError( m_frame, _( "Tracks on Copper layers only" ) );
642  return false;
643  }
644 
645  m_frame->SetActiveLayer( ToLAYER_ID( routingLayer ) );
646 
647  // fixme: switch on invisible layer
648 
649  // for some reason I don't understand, GetNetclass() may return null sometimes...
650  if( m_startItem && m_startItem->Net() >= 0 &&
652  {
653  highlightNet( true, m_startItem->Net() );
654  // Update track width and via size shown in main toolbar comboboxes
656  }
657  else
659 
660  m_ctls->ForceCursorPosition( false );
661  m_ctls->SetAutoPan( true );
662 
663  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
664 
665  sizes.Init( m_board, m_startItem );
666  sizes.AddLayerPair( m_frame->GetScreen()->m_Route_Layer_TOP,
668  m_router->UpdateSizes( sizes );
669 
670  if( !m_router->StartRouting( m_startSnapPoint, m_startItem, routingLayer ) )
671  {
673  highlightNet( false );
674  return false;
675  }
676 
677  m_endItem = NULL;
679 
680  m_frame->UndoRedoBlock( true );
681 
682  return true;
683 }
const wxString & FailureReason() const
Definition: pns_router.h:205
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:75
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:197
bool SetCurrentNetClass(const wxString &aNetClassName)
Function SetCurrentNetClass Must be called after a netclass selection (or after a netclass parameter ...
Definition: pcbframe.cpp:1113
KIGFX::VIEW_CONTROLS * m_ctls
Definition: pns_tool_base.h:81
std::shared_ptr< NETCLASS > GetNetClass() const
Function GetNetClass returns the NETCLASS for this item.
static const char Default[]
the name of the default NETCLASS
ITEM * m_startItem
Definition: pns_tool_base.h:73
void Init(BOARD *aBoard, ITEM *aStartItem=NULL, int aNet=-1)
ROUTER * m_router
Definition: pns_tool_base.h:85
PCB_LAYER_ID m_Route_Layer_BOTTOM
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
bool StartRouting(const VECTOR2I &aP, ITEM *aItem, int aLayer)
Definition: pns_router.cpp:149
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:278
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:78
PCB_EDIT_FRAME * m_frame
Definition: pns_tool_base.h:80
int Net() const
Function Net()
Definition: pns_item.h:177
PCB_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
int getStartLayer(const PNS::ITEM *aItem)
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:71
virtual void SetActiveLayer(PCB_LAYER_ID aLayer) override
Function SetActiveLayer will change the currently active layer to aLayer and also update the PCB_LAYE...
Definition: pcbframe.cpp:883
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:767
BOARD_CONNECTED_ITEM * Parent() const
Function Parent()
Definition: pns_item.h:157
PCB_LAYER_ID m_Route_Layer_TOP
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 363 of file router_tool.cpp.

References TOOL_BASE::Reset().

364 {
365  TOOL_BASE::Reset( aReason );
366 }
virtual void Reset(RESET_REASON aReason)=0
Function Reset() Brings the tool to a known, initial state.
int ROUTER_TOOL::RouteDiffPair ( const TOOL_EVENT aEvent)

Definition at line 821 of file router_tool.cpp.

References ID_TRACK_BUTT, PNS::TOOL_BASE::m_frame, mainLoop(), PNS::PNS_MODE_ROUTE_DIFF_PAIR, and PCB_BASE_FRAME::SetToolID().

Referenced by SetTransitions().

822 {
823  m_frame->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Router Differential Pair" ) );
825 }
int mainLoop(PNS::ROUTER_MODE aMode)
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
PCB_EDIT_FRAME * m_frame
Definition: pns_tool_base.h:80
ROUTER * TOOL_BASE::Router ( ) const
inherited

Definition at line 306 of file pns_tool_base.cpp.

References PNS::TOOL_BASE::m_router.

307 {
308  return m_router;
309 }
ROUTER * m_router
Definition: pns_tool_base.h:85
int ROUTER_TOOL::RouteSingleTrace ( const TOOL_EVENT aEvent)

Definition at line 814 of file router_tool.cpp.

References ID_TRACK_BUTT, PNS::TOOL_BASE::m_frame, mainLoop(), PNS::PNS_MODE_ROUTE_SINGLE, and PCB_BASE_FRAME::SetToolID().

Referenced by SetTransitions().

815 {
816  m_frame->SetToolID( ID_TRACK_BUTT, wxCURSOR_PENCIL, _( "Route Track" ) );
818 }
int mainLoop(PNS::ROUTER_MODE aMode)
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
PCB_EDIT_FRAME * m_frame
Definition: pns_tool_base.h:80
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 78 of file tool_interactive.cpp.

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

Referenced by DRAWING_TOOL::PlaceText().

79 {
80  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
81 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)
void TOOL_INTERACTIVE::SetContextMenu ( CONTEXT_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 67 of file tool_interactive.cpp.

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

Referenced by SELECTION_TOOL::disambiguationMenu(), LENGTH_TUNER_TOOL::mainLoop(), mainLoop(), and TOOL_MENU::ShowContextMenu().

68 {
69  if( aMenu )
70  aMenu->SetTool( this );
71  else
72  aTrigger = CMENU_OFF;
73 
74  m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
75 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
void ScheduleContextMenu(TOOL_BASE *aTool, CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Sets behaviour of the tool's context popup menu.
void SetTool(TOOL_INTERACTIVE *aTool)
Function SetTool() Sets a tool that is the creator of the menu.
int ROUTER_TOOL::SettingsDialog ( const TOOL_EVENT aEvent)

Definition at line 778 of file router_tool.cpp.

References TOOL_INTERACTIVE::Activate(), PNS::TOOL_BASE::m_frame, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_savedSettings, and PNS::ROUTER::Settings().

Referenced by SetTransitions().

779 {
780  Activate();
781 
782  DIALOG_PNS_SETTINGS settingsDlg( m_frame, m_router->Settings() );
783 
784  if( settingsDlg.ShowModal() )
786 
787  return 0;
788 }
ROUTER * m_router
Definition: pns_tool_base.h:85
ROUTING_SETTINGS m_savedSettings
Stores routing settings between router invocations.
Definition: pns_tool_base.h:71
PCB_EDIT_FRAME * m_frame
Definition: pns_tool_base.h:80
void Activate()
Function Activate() Runs the tool.
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:178
void ROUTER_TOOL::SetTransitions ( )
overridevirtual

Function SetTransitions() 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 TOOL_BASE.

Definition at line 791 of file router_tool.cpp.

References ACT_CustomTrackWidth, ACT_PlaceBlindVia, ACT_PlaceMicroVia, ACT_PlaceThroughVia, PNS::TOOL_BASE::ACT_RouterOptions, ACT_SelLayerAndPlaceBlindVia, ACT_SelLayerAndPlaceThroughVia, ACT_SetDpDimensions, CustomTrackWidthDialog(), DpDimensionsDialog(), TOOL_INTERACTIVE::Go(), InlineDrag(), TOOL_ACTION::MakeEvent(), onTrackViaSizeChanged(), onViaCommand(), RouteDiffPair(), PCB_ACTIONS::routerActivateDiffPair, PCB_ACTIONS::routerActivateDpDimensionsDialog, PCB_ACTIONS::routerActivateSettingsDialog, PCB_ACTIONS::routerActivateSingle, PCB_ACTIONS::routerInlineDrag, RouteSingleTrace(), SettingsDialog(), and PCB_ACTIONS::trackViaSizeChanged.

792 {
798 
804 
805  // TODO is not this redundant? the same actions can be used for menus and hotkeys
808 
811 }
static TOOL_ACTION ACT_RouterOptions
Definition: pns_tool_base.h:47
static const TOOL_ACTION ACT_SelLayerAndPlaceBlindVia("pcbnew.InteractiveRouter.SelLayerAndPlaceBlindVia", AS_CONTEXT, TOOL_ACTION::LegacyHotKey(HK_SEL_LAYER_AND_ADD_BLIND_BURIED_VIA), _("Select Layer and Place Blind/Buried Via"), _("Select a layer, then add a blind or buried via at the end of currently routed track."), select_w_layer_xpm, AF_NONE,(void *)(VIA_ACTION_FLAGS::BLIND_VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
int DpDimensionsDialog(const TOOL_EVENT &aEvent)
int InlineDrag(const TOOL_EVENT &aEvent)
int RouteSingleTrace(const TOOL_EVENT &aEvent)
static const TOOL_ACTION ACT_PlaceBlindVia("pcbnew.InteractiveRouter.PlaceBlindVia", AS_CONTEXT, TOOL_ACTION::LegacyHotKey(HK_ADD_BLIND_BURIED_VIA), _("Place Blind/Buried Via"), _("Adds a blind or buried via at the end of currently routed track."), via_buried_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::BLIND_VIA)
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:267
static const TOOL_ACTION ACT_PlaceThroughVia("pcbnew.InteractiveRouter.PlaceVia", AS_CONTEXT, TOOL_ACTION::LegacyHotKey(HK_ADD_THROUGH_VIA), _("Place Through Via"), _("Adds a through-hole via at the end of currently routed track."), via_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::VIA)
static TOOL_ACTION routerActivateSingle
Activation of the Push and Shove router.
Definition: pcb_actions.h:178
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
int onViaCommand(const TOOL_EVENT &aEvent)
int RouteDiffPair(const TOOL_EVENT &aEvent)
int SettingsDialog(const TOOL_EVENT &aEvent)
int CustomTrackWidthDialog(const TOOL_EVENT &aEvent)
static const TOOL_ACTION ACT_PlaceMicroVia("pcbnew.InteractiveRouter.PlaceMicroVia", AS_CONTEXT, TOOL_ACTION::LegacyHotKey(HK_ADD_MICROVIA), _("Place Microvia"), _("Adds a microvia at the end of currently routed track."), via_microvia_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::MICROVIA)
int onTrackViaSizeChanged(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:198
TOOL_EVENT MakeEvent() const
Function HasHotKey() Checks if the action has a hot key assigned.
Definition: tool_action.h:104
static TOOL_ACTION routerActivateSettingsDialog
Activation of the Push and Shove settings dialogs.
Definition: pcb_actions.h:193
static const TOOL_ACTION ACT_CustomTrackWidth("pcbnew.InteractiveRouter.CustomTrackViaSize", AS_CONTEXT, TOOL_ACTION::LegacyHotKey(HK_CUSTOM_TRACK_WIDTH), _("Custom Track/Via Size"), _("Shows a dialog for changing the track width and via size."), width_track_xpm)
static const TOOL_ACTION ACT_SetDpDimensions("pcbnew.InteractiveRouter.SetDpDimensions", AS_CONTEXT, TOOL_ACTION::LegacyHotKey(HK_DP_DIMENSIONS), _("Differential Pair Dimensions..."), _("Sets the width and gap of the currently routed differential pair."), ps_diff_pair_tune_length_xpm)
static TOOL_ACTION routerActivateDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:181
static const TOOL_ACTION ACT_SelLayerAndPlaceThroughVia("pcbnew.InteractiveRouter.SelLayerAndPlaceVia", AS_CONTEXT, TOOL_ACTION::LegacyHotKey(HK_SEL_LAYER_AND_ADD_THROUGH_VIA), _("Select Layer and Place Through Via"), _("Select a layer, then add a through-hole via at the end of currently routed track."), select_w_layer_xpm, AF_NONE,(void *)(VIA_ACTION_FLAGS::VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
static TOOL_ACTION routerActivateDpDimensionsDialog
Definition: pcb_actions.h:194
const VECTOR2I TOOL_BASE::snapToItem ( bool  aEnabled,
ITEM aItem,
VECTOR2I  aP 
)
protectedinherited

Definition at line 312 of file pns_tool_base.cpp.

References SEG::A, GRID_HELPER::Align(), GRID_HELPER::AlignToSegment(), SEG::B, PNS::ITEM::Kind(), PNS::TOOL_BASE::m_gridHelper, PNS::SEGMENT::Seg(), PNS::ITEM::SEGMENT_T, PNS::ITEM::SOLID_T, PNS::ITEM::VIA_T, and PNS::SEGMENT::Width().

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

313 {
314  VECTOR2I anchor;
315 
316  if( !aItem || !aEnabled )
317  {
318  return m_gridHelper->Align( aP );
319  }
320 
321  switch( aItem->Kind() )
322  {
323  case ITEM::SOLID_T:
324  anchor = static_cast<SOLID*>( aItem )->Pos();
325  break;
326 
327  case ITEM::VIA_T:
328  anchor = static_cast<VIA*>( aItem )->Pos();
329  break;
330 
331  case ITEM::SEGMENT_T:
332  {
333  SEGMENT* seg = static_cast<SEGMENT*>( aItem );
334  const SEG& s = seg->Seg();
335  int w = seg->Width();
336 
337 
338  if( ( aP - s.A ).EuclideanNorm() < w / 2 )
339  anchor = s.A;
340  else if( ( aP - s.B ).EuclideanNorm() < w / 2 )
341  anchor = s.B;
342  else
343  anchor = m_gridHelper->AlignToSegment( aP, s );
344 
345  break;
346  }
347 
348  default:
349  break;
350  }
351 
352  return anchor;
353 }
GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:83
VECTOR2I Align(const VECTOR2I &aPoint) const
Definition: grid_helper.cpp:95
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)
Definition: seg.h:37
VECTOR2I A
Definition: seg.h:47
Struct SEGMENT is a simple container used when filling areas with segments.
Definition: class_zone.h:57
VECTOR2I B
Definition: seg.h:48
void ROUTER_TOOL::switchLayerOnViaPlacement ( )
private

Definition at line 437 of file router_tool.cpp.

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

Referenced by performRouting().

438 {
439  int al = m_frame->GetActiveLayer();
440  int cl = m_router->GetCurrentLayer();
441 
442  if( cl != al )
443  {
444  m_router->SwitchLayer( al );
445  }
446 
447  optional<int> newLayer = m_router->Sizes().PairedLayer( cl );
448 
449  if( !newLayer )
450  newLayer = m_router->Sizes().GetLayerTop();
451 
452  m_router->SwitchLayer( *newLayer );
453  m_frame->SetActiveLayer( ToLAYER_ID( *newLayer ) );
454 }
boost::optional< int > PairedLayer(int aLayerId)
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:197
void SwitchLayer(int layer)
Definition: pns_router.cpp:396
ROUTER * m_router
Definition: pns_tool_base.h:85
PCB_EDIT_FRAME * m_frame
Definition: pns_tool_base.h:80
int GetCurrentLayer() const
Definition: pns_router.cpp:428
virtual void SetActiveLayer(PCB_LAYER_ID aLayer) override
Function SetActiveLayer will change the currently active layer to aLayer and also update the PCB_LAYE...
Definition: pcbframe.cpp:883
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:767
void TOOL_BASE::updateEndItem ( const TOOL_EVENT aEvent)
protectedvirtualinherited

Definition at line 238 of file pns_tool_base.cpp.

References KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PNS::ROUTER::GetCurrentLayer(), PNS::ROUTER::GetCurrentNets(), KIGFX::VIEW_CONTROLS::GetMousePosition(), PNS::ROUTER::IsPlacingVia(), PNS::ITEM::KindStr(), PNS::ITEM::Layers(), PNS::TOOL_BASE::m_ctls, PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_router, MD_SHIFT, TOOL_EVENT::Modifier(), PNS::TOOL_BASE::pickSingleItem(), PNS::TOOL_BASE::snapToItem(), and LAYER_RANGE::Start().

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

239 {
241  int layer;
242  bool snapEnabled = !aEvent.Modifier( MD_SHIFT );
243 
244  if( m_router->GetCurrentNets().empty() || m_router->GetCurrentNets().front() < 0 )
245  {
246  m_endSnapPoint = snapToItem( snapEnabled, nullptr, p );
248  m_endItem = nullptr;
249 
250  return;
251  }
252 
253  if( m_router->IsPlacingVia() )
254  layer = -1;
255  else
256  layer = m_router->GetCurrentLayer();
257 
258  ITEM* endItem = nullptr;
259 
260  std::vector<int> nets = m_router->GetCurrentNets();
261 
262  for( int net : nets )
263  {
264  endItem = pickSingleItem( p, net, layer );
265 
266  if( endItem )
267  break;
268  }
269 
270  VECTOR2I cursorPos = snapToItem( snapEnabled, endItem, p );
271  m_ctls->ForceCursorPosition( true, cursorPos );
272  m_endItem = endItem;
273  m_endSnapPoint = cursorPos;
274 
275  if( m_endItem )
276  {
277  wxLogTrace( "PNS", "%s, layer : %d", m_endItem->KindStr().c_str(), m_endItem->Layers().Start() );
278  }
279 }
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:207
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:311
bool IsPlacingVia() const
Definition: pns_router.cpp:459
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:419
const VECTOR2I snapToItem(bool aEnabled, ITEM *aItem, VECTOR2I aP)
KIGFX::VIEW_CONTROLS * m_ctls
Definition: pns_tool_base.h:81
ROUTER * m_router
Definition: pns_tool_base.h:85
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
int Start() const
Definition: pns_layerset.h:83
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:78
virtual ITEM * pickSingleItem(const VECTOR2I &aWhere, int aNet=-1, int aLayer=-1)
int GetCurrentLayer() const
Definition: pns_router.cpp:428
const std::string KindStr() const
Function KindStr()
Definition: pns_item.cpp:63
void TOOL_BASE::updateStartItem ( TOOL_EVENT aEvent)
protectedvirtualinherited

Definition at line 210 of file pns_tool_base.cpp.

References KIGFX::VIEW_CONTROLS::ForceCursorPosition(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), KIGFX::VIEW::GetTopLayer(), TOOL_BASE::getView(), TOOL_EVENT::IsClick(), TOOL_EVENT::IsMotion(), PNS::ITEM::Layers(), PNS::TOOL_BASE::m_ctls, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, MD_SHIFT, TOOL_EVENT::Modifier(), LAYER_RANGE::Overlaps(), PNS::TOOL_BASE::pickSingleItem(), TOOL_EVENT::Position(), and PNS::TOOL_BASE::snapToItem().

Referenced by LENGTH_TUNER_TOOL::mainLoop(), and mainLoop().

211 {
212  int tl = getView()->GetTopLayer();
214  VECTOR2I p;
215 
216  bool snapEnabled = true;
217 
218  if( aEvent.IsMotion() || aEvent.IsClick() )
219  {
220  snapEnabled = !aEvent.Modifier( MD_SHIFT );
221  p = aEvent.Position();
222  }
223  else
224  {
225  p = cp;
226  }
227 
229 
230  if( !snapEnabled && m_startItem && !m_startItem->Layers().Overlaps( tl ) )
231  m_startItem = nullptr;
232 
233  m_startSnapPoint = snapToItem( snapEnabled, m_startItem, p );
235 }
int GetTopLayer() const
Definition: view.cpp:739
const LAYER_RANGE & Layers() const
Function Layers()
Definition: pns_item.h:207
bool IsMotion() const
Definition: tool_event.h:290
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:75
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:311
const VECTOR2D & Position() const
Returns mouse cursor position in world coordinates.
Definition: tool_event.h:248
const VECTOR2I snapToItem(bool aEnabled, ITEM *aItem, VECTOR2I aP)
KIGFX::VIEW_CONTROLS * m_ctls
Definition: pns_tool_base.h:81
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
ITEM * m_startItem
Definition: pns_tool_base.h:73
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:68
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
virtual ITEM * pickSingleItem(const VECTOR2I &aWhere, int aNet=-1, int aLayer=-1)
bool IsClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:268
OPT_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 55 of file tool_interactive.cpp.

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

Referenced by MODULE_EDITOR_TOOLS::CopyItems(), PCBNEW_CONTROL::DeleteItemCursor(), SELECTION_TOOL::disambiguationMenu(), PCB_TOOL::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), InlineDrag(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), mainLoop(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), MODULE_EDITOR_TOOLS::PasteItems(), performDragging(), performRouting(), LENGTH_TUNER_TOOL::performTuning(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::runPolygonEventLoop(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

56 {
57  return m_toolMgr->ScheduleWait( this, aEventList );
58 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
boost::optional< 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.

Member Data Documentation

TOOL_ACTION TOOL_BASE::ACT_RouterOptions
staticinherited
ITEM* PNS::TOOL_BASE::m_endItem
protectedinherited
VECTOR2I PNS::TOOL_BASE::m_endSnapPoint
protectedinherited
GRID_HELPER* PNS::TOOL_BASE::m_gridHelper
protectedinherited
PNS_KICAD_IFACE* PNS::TOOL_BASE::m_iface
protectedinherited
MSG_PANEL_ITEMS PNS::TOOL_BASE::m_panelItems
protectedinherited

Definition at line 69 of file pns_tool_base.h.

ROUTING_SETTINGS PNS::TOOL_BASE::m_savedSettings
protectedinherited

Stores routing settings between router invocations.

Definition at line 71 of file pns_tool_base.h.

Referenced by Init(), LENGTH_TUNER_TOOL::mainLoop(), mainLoop(), PNS::TOOL_BASE::Reset(), SettingsDialog(), and ~ROUTER_TOOL().

SIZES_SETTINGS PNS::TOOL_BASE::m_savedSizes
protectedinherited

Stores sizes settings between router invocations.

Definition at line 72 of file pns_tool_base.h.

Referenced by DpDimensionsDialog(), LENGTH_TUNER_TOOL::mainLoop(), mainLoop(), and PNS::TOOL_BASE::Reset().

int PNS::TOOL_BASE::m_startLayer
protectedinherited

Definition at line 74 of file pns_tool_base.h.

Referenced by PNS::TOOL_BASE::TOOL_BASE().

VECTOR2I PNS::TOOL_BASE::m_startSnapPoint
protectedinherited
TOOL_ID TOOL_BASE::m_toolId
protectedinherited

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

Definition at line 215 of file tool_base.h.

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

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 220 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PCBNEW_CONTROL::AppendBoard(), PAD_TOOL::applyPadSettings(), TOOL_BASE::attachManager(), SELECTION_TOOL::clearSelection(), MODULE_EDITOR_TOOLS::CopyItems(), PAD_TOOL::copyPadSettings(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), CustomTrackWidthDialog(), PCBNEW_CONTROL::DeleteItemCursor(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::findCallback(), SELECTION_TOOL::findMove(), EDIT_TOOL::Flip(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), EDIT_TOOL::getModificationPoint(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PAD_TOOL::Init(), POINT_EDITOR::Init(), PCB_EDITOR_CONTROL::Init(), EDIT_TOOL::Init(), POSITION_RELATIVE_TOOL::Init(), InlineDrag(), EDIT_TOOL::invokeInlineRouter(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), mainLoop(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), MODULE_EDITOR_TOOLS::PasteItems(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), SELECTION_TOOL::RequestSelection(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), SELECTION_TOOL::SanitizeSelection(), SELECTION_TOOL::selectConnection(), SELECTION_TOOL::selectCopper(), SELECTION_TOOL::SelectItem(), SELECTION_TOOL::SelectItems(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), SELECTION_TOOL::selectOnSheetFromEeschema(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), TOOL_INTERACTIVE::SetContextMenu(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), SELECTION_TOOL::toggleSelection(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), SELECTION_TOOL::UnselectItem(), SELECTION_TOOL::UnselectItems(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), PCB_EDITOR_CONTROL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and PCB_EDITOR_CONTROL::ZoneUnfill().

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

Referenced by TOOL_BASE::GetName().

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 221 of file tool_base.h.

Referenced by TOOL_BASE::attachManager(), and TOOL_BASE::GetSettings().

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 212 of file tool_base.h.

Referenced by TOOL_BASE::GetType().


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