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 CustomTrackWidthDialog (const TOOL_EVENT &aEvent)
 
void setTransitions () override
 This method is meant to be overridden in order to specify handlers for events. More...
 
ROUTER * Router () const
 
void SetEditModules (bool aEnabled)
 Function SetEditModules() More...
 
bool EditingModules () 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...
 
TOOL_SETTINGSGetSettings ()
 
bool IsToolActive () const
 

Static Public Member Functions

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

Protected Types

enum  INTERACTIVE_PLACEMENT_OPTIONS { IPO_ROTATE = 1, IPO_FLIP = 2, IPO_SINGLE_CLICK = 4, IPO_REPEAT = 8 }
 

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 deleteTraces (ITEM *aStartItem, bool aWholeTrack)
 
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
 
MODULEmodule () 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

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
 
bool m_startHighlight
 Keeps track of whether the net was highlighted before routing. More...
 
ITEM * m_endItem
 
VECTOR2I m_endSnapPoint
 
GRID_HELPERm_gridHelper
 
PNS_KICAD_IFACEm_iface
 
ROUTER * m_router
 
bool m_cancelled
 
bool m_editModules
 
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
 
TOOL_SETTINGS m_toolSettings
 

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

Enumerator
IPO_ROTATE 
IPO_FLIP 
IPO_SINGLE_CLICK 
IPO_REPEAT 

Definition at line 109 of file pcb_tool_base.h.

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

143  :
144  TOOL_BASE( "pcbnew.InteractiveRouter" )
145 {
146 }
TOOL_BASE(const std::string &aToolName)

◆ ~ROUTER_TOOL()

ROUTER_TOOL::~ROUTER_TOOL ( )

Definition at line 429 of file router_tool.cpp.

430 {
432 }
ROUTING_SETTINGS m_savedSettings
Stores routing settings between router invocations.
Definition: pns_tool_base.h:66
TOOL_SETTINGS & GetSettings()
Definition: tool_base.cpp:78
void Save(TOOL_SETTINGS &where) const

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

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(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), 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(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::Move(), LIB_TREE::onContextMenu(), POINT_EDITOR::OnSelectionChange(), 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::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  m_toolSettings = TOOL_SETTINGS( this );
64 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:220
friend class TOOL_SETTINGS
Definition: tool_base.h:154

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

Referenced by TOOL_MANAGER::RegisterTool().

◆ board()

BOARD* PCB_TOOL_BASE::board ( ) const
inlineprotectedinherited

Definition at line 151 of file pcb_tool_base.h.

151 { return getModel<BOARD>(); }

Referenced by PCBNEW_CONTROL::AppendBoard(), AUTOPLACE_TOOL::autoplace(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), EDIT_TOOL::changeTrackWidthOnClick(), ZONE_FILLER_TOOL::CheckAllZones(), DRC::checkClearancePadToPad(), DRC::checkClearanceSegmToPad(), PCB_INSPECTION_TOOL::ClearHighlight(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), CustomTrackWidthDialog(), PCBNEW_CONTROL::DeleteItemCursor(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), PAD_TOOL::EnumeratePads(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), ZONE_FILLER_TOOL::FillAllZones(), SELECTION_TOOL::filterSelection(), SELECTION_TOOL::getCollectorsGuide(), PCBNEW_CONTROL::GraphicDisplayMode(), PAD_TOOL::haveFootprints(), PCB_INSPECTION_TOOL::highlightNet(), PCBNEW_CONTROL::LayerNext(), PCBNEW_CONTROL::LayerPrev(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PCB_TOOL_BASE::module(), PCBNEW_CONTROL::ModuleEdgeOutlines(), onTrackViaSizeChanged(), onViaCommand(), PCBNEW_CONTROL::PadDisplayMode(), PCBNEW_CONTROL::Paste(), PCBNEW_CONTROL::placeBoardItems(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), prepareInteractive(), SELECTION_TOOL::RebuildSelection(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), SELECTION_TOOL::Selectable(), SELECTION_TOOL::selectAllItemsConnectedToItem(), SELECTION_TOOL::selectAllItemsConnectedToTrack(), SELECTION_TOOL::selectAllItemsOnNet(), SELECTION_TOOL::selectAllItemsOnSheet(), SELECTION_TOOL::selectPoint(), DRC::testDisabledLayers(), DRC::TestZoneToZoneOutline(), PCBNEW_CONTROL::TrackDisplayMode(), 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 849 of file router_tool.cpp.

850 {
853 }
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
void BreakSegment(ITEM *aItem, const VECTOR2I &aP)
Definition: pns_router.cpp:527
ITEM * m_startItem
Definition: pns_tool_base.h:68
ROUTER * m_router
Definition: pns_tool_base.h:78
bool OfKind(int aKindMask) const
Function OfKind()
Definition: pns_item.h:132

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

1110 {
1112  const auto& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
1113 
1114  if( selection.Size() == 1 )
1115  {
1116  const BOARD_CONNECTED_ITEM* item = static_cast<const BOARD_CONNECTED_ITEM*>( selection.Front() );
1117 
1118  if( item->Type() == PCB_TRACE_T || item->Type() == PCB_VIA_T )
1119  return true;
1120  }
1121 
1122  return false;
1123 }
Class 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:109
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
const PCBNEW_SELECTION & selection() const
static void NeighboringSegmentFilter(const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector)
int Size() const
Returns the number of selected parts.
Definition: selection.h:125
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:70
EDA_ITEM * Front() const
Definition: selection.h:182
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210

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

◆ canvas()

◆ checkSnap()

bool TOOL_BASE::checkSnap ( ITEM aItem)
protectedinherited

Definition at line 238 of file pns_tool_base.cpp.

239 {
240  // Sync PNS engine settings with the general PCB editor options.
241  auto& pnss = m_router->Settings();
242 
243  pnss.SetSnapToPads( frame()->Settings().m_MagneticPads == CAPTURE_CURSOR_IN_TRACK_TOOL
244  || frame()->Settings().m_MagneticPads == CAPTURE_ALWAYS );
245 
246  pnss.SetSnapToTracks( frame()->Settings().m_MagneticTracks == CAPTURE_CURSOR_IN_TRACK_TOOL
247  || frame()->Settings().m_MagneticTracks == CAPTURE_ALWAYS );
248 
249  if( aItem )
250  {
251  if( aItem->OfKind( ITEM::VIA_T ) || aItem->OfKind( ITEM::SEGMENT_T ) )
252  return pnss.GetSnapToTracks();
253  else if( aItem->OfKind( ITEM::SOLID_T ) )
254  return pnss.GetSnapToPads();
255  }
256 
257  return false;
258 }
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:189

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

1251 {
1253  DIALOG_TRACK_VIA_SIZE sizeDlg( frame(), bds );
1254 
1255  if( sizeDlg.ShowModal() )
1256  {
1257  bds.UseCustomTrackViaSize( true );
1259  }
1260 
1261  return 0;
1262 }
BOARD * board() const
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:109
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:286
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:540
PCB_BASE_EDIT_FRAME * frame() const
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.

References PCB_TOOL_BASE::board(), PCB_TOOL_BASE::frame(), BOARD::GetDesignSettings(), TOOL_BASE::m_toolMgr, TOOL_MANAGER::RunAction(), PCB_ACTIONS::trackViaSizeChanged, and BOARD_DESIGN_SETTINGS::UseCustomTrackViaSize().

Referenced by setTransitions().

◆ deleteTraces()

void TOOL_BASE::deleteTraces ( ITEM aStartItem,
bool  aWholeTrack 
)
protectedinherited

Definition at line 351 of file pns_tool_base.cpp.

352 {
353  NODE *node = m_router->GetWorld()->Branch();
354 
355  if( !aStartItem )
356  return;
357 
358  if( !aWholeTrack )
359  {
360  node->Remove( aStartItem );
361  }
362  else
363  {
364  TOPOLOGY topo( node );
365  ITEM_SET path = topo.AssembleTrivialPath( aStartItem );
366 
367  for( auto ent : path.Items() )
368  node->Remove( ent.item );
369  }
370 
371  m_router->CommitRouting( node );
372 }
NODE * Branch()
Function Branch()
Definition: pns_node.cpp:104
ROUTER * m_router
Definition: pns_tool_base.h:78
void Remove(SOLID *aSolid)
Function Remove()
Definition: pns_node.cpp:715
void CommitRouting(NODE *aNode)
Definition: pns_router.cpp:355
NODE * GetWorld() const
Definition: pns_router.h:145

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

◆ displayOptions()

◆ 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  controls()->SetSnapping( true );
53 
54  // Add a VIEW_GROUP that serves as a preview for the new item
55  PCBNEW_SELECTION preview;
56  view()->Add( &preview );
57 
58  aPlacer->m_board = board();
59  aPlacer->m_frame = frame();
60  aPlacer->m_modifiers = 0;
61 
62  auto makeNewItem = [&] ( 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_MODULE_T )
73  {
74  auto module = dyn_cast<MODULE*>( newItem.get() );
75 
76  // modules have more drawable parts
77  module->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  // Main loop: keep receiving events
86  while( TOOL_EVENT* evt = Wait() )
87  {
88  VECTOR2I cursorPos = controls()->GetCursorPosition();
89  aPlacer->m_modifiers = evt->Modifier();
90 
91  auto cleanup = [&] ()
92  {
93  newItem = nullptr;
94  preview.Clear();
95  view()->Update( &preview );
96  controls()->SetAutoPan( false );
97  controls()->CaptureCursor( false );
98  controls()->ShowCursor( true );
99  };
100 
101  if( evt->IsCancelInteractive() )
102  {
103  if( aOptions & IPO_SINGLE_CLICK )
104  {
105  cleanup();
106  frame()->PopTool( aTool );
107  break;
108  }
109  else if( newItem )
110  cleanup();
111  else
112  {
113  frame()->PopTool( aTool );
114  break;
115  }
116  }
117  else if( evt->IsActivate() )
118  {
119  if( newItem )
120  cleanup();
121 
122  if( evt->IsPointEditor() )
123  {
124  // don't exit (the point editor runs in the background)
125  }
126  else if( evt->IsMoveTool() )
127  {
128  // leave ourselves on the stack so we come back after the move
129  break;
130  }
131  else
132  {
133  frame()->PopTool( aTool );
134  break;
135  }
136  }
137  else if( evt->IsClick( BUT_LEFT ) )
138  {
139  if( !newItem )
140  {
141  // create the item if possible
142  makeNewItem( cursorPos );
143 
144  // no item created, so wait for another click
145  if( !newItem )
146  continue;
147 
148  controls()->CaptureCursor( true );
149  controls()->SetAutoPan( true );
150  }
151  else
152  {
153  auto oldFlags = newItem->GetFlags();
154  newItem->ClearFlags();
155 
156  if( !aPlacer->PlaceItem( newItem.get(), commit ) )
157  {
158  newItem->SetFlags( oldFlags );
159  continue;
160  }
161 
162  preview.Clear();
163  newItem.release();
164  commit.Push( aCommitMessage );
165 
166  controls()->CaptureCursor( false );
167  controls()->SetAutoPan( false );
168  controls()->ShowCursor( true );
169 
170  if( !( aOptions & IPO_REPEAT ) )
171  break;
172 
173  if( aOptions & IPO_SINGLE_CLICK )
174  makeNewItem( controls()->GetCursorPosition() );
175  }
176  }
177  else if( evt->IsClick( BUT_RIGHT ) )
178  {
180  }
181  else if( newItem && evt->Category() == TC_COMMAND )
182  {
183  /*
184  * Handle any events that can affect the item as we move
185  * it around, eg rotate and flip
186  */
187 
188  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
189  {
190  const int rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
191  newItem->Rotate( newItem->GetPosition(), rotationAngle );
192  view()->Update( &preview );
193  }
194  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
195  {
196  newItem->Flip( newItem->GetPosition(), frame()->Settings().m_FlipLeftRight );
197  view()->Update( &preview );
198  }
199  }
200 
201  else if( newItem && evt->IsMotion() )
202  {
203  // track the cursor
204  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
205  aPlacer->SnapItem( newItem.get() );
206 
207  // Show a preview of the item
208  view()->Update( &preview );
209  }
210 
211  else
212  evt->SetPassEvent();
213  }
214 
215  view()->Remove( &preview );
216 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
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:93
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction)
Function RunOnChildren.
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)
BOARD * board() const
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:91
virtual std::unique_ptr< BOARD_ITEM > CreateItem()=0
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
virtual void Remove(VIEW_ITEM *aItem) override
Function Remove() Removes a VIEW_ITEM from the view.
Definition: pcb_view.cpp:74
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:74
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)
class MODULE, a footprint
Definition: typeinfo.h:89
const PCBNEW_SELECTION & selection() const
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
PCB_GENERAL_SETTINGS & Settings()
Class TOOL_EVENT.
Definition: tool_event.h:168
KIGFX::PCB_VIEW * view() const
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.
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:115
KIGFX::VIEW_CONTROLS * controls() const
MODULE * module() const
virtual void PopTool(const std::string &actionName)
void Activate()
Function Activate() Runs the tool.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Function Add() Adds a VIEW_ITEM to the view.
Definition: pcb_view.cpp:58
PCB_BASE_EDIT_FRAME * m_frame
Definition: pcb_tool_base.h:58
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
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(), 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(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_BASE_EDIT_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, PCB_GENERAL_SETTINGS::m_FlipLeftRight, INTERACTIVE_PLACER_BASE::m_frame, TOOL_INTERACTIVE::m_menu, INTERACTIVE_PLACER_BASE::m_modifiers, PCB_TOOL_BASE::module(), PCB_MODULE_T, INTERACTIVE_PLACER_BASE::PlaceItem(), EDA_BASE_FRAME::PopTool(), BOARD_COMMIT::Push(), EDA_BASE_FRAME::PushTool(), KIGFX::PCB_VIEW::Remove(), TOOL_MANAGER::RunAction(), MODULE::RunOnChildren(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), KIGFX::VIEW_CONTROLS::SetSnapping(), PCB_BASE_FRAME::Settings(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), INTERACTIVE_PLACER_BASE::SnapItem(), TC_COMMAND, KIGFX::PCB_VIEW::Update(), PCB_TOOL_BASE::view(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

◆ DpDimensionsDialog()

int ROUTER_TOOL::DpDimensionsDialog ( const TOOL_EVENT aEvent)

Definition at line 818 of file router_tool.cpp.

819 {
821  DIALOG_PNS_DIFF_PAIR_DIMENSIONS settingsDlg( frame(), sizes );
822 
823  if( settingsDlg.ShowModal() == wxID_OK )
824  {
825  m_router->UpdateSizes( sizes );
826  m_savedSizes = sizes;
827 
829  bds.SetCustomDiffPairWidth( sizes.DiffPairWidth() );
830  bds.SetCustomDiffPairGap( sizes.DiffPairGap() );
832  }
833 
834  return 0;
835 }
void SetCustomDiffPairViaGap(int aGap)
Function SetCustomDiffPairViaGap Sets custom via gap for differential pairs (i.e.
SIZES_SETTINGS m_savedSizes
Stores sizes settings between router invocations.
Definition: pns_tool_base.h:67
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:540
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:208
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:316
BOARD * GetBoard() const
Class 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().

◆ EditingModules()

bool PCB_TOOL_BASE::EditingModules ( ) const
inlineinherited

◆ finishInteractive()

bool ROUTER_TOOL::finishInteractive ( )
private

Definition at line 729 of file router_tool.cpp.

730 {
732 
733  controls()->SetAutoPan( false );
734  controls()->ForceCursorPosition( false );
735  frame()->UndoRedoBlock( false );
736  highlightNet( false );
737 
738  return true;
739 }
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
PCB_BASE_EDIT_FRAME * frame() const
ROUTER * m_router
Definition: pns_tool_base.h:78
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
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:397
virtual void highlightNet(bool aEnabled, int aNetcode=-1)
KIGFX::VIEW_CONTROLS * controls() const

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

Referenced by performRouting().

◆ frame()

PCB_BASE_EDIT_FRAME* PCB_TOOL_BASE::frame ( ) const
inlineprotectedinherited

Definition at line 146 of file pcb_tool_base.h.

147  {
148  return getEditFrame<PCB_BASE_EDIT_FRAME>();
149  }

Referenced by POINT_EDITOR::addCorner(), MICROWAVE_TOOL::addMicrowaveFootprint(), AUTOPLACE_TOOL::autoplace(), PCB_TOOL_BASE::canvas(), EDIT_TOOL::changeTrackWidthOnClick(), ZONE_FILLER_TOOL::CheckAllZones(), PNS::TOOL_BASE::checkSnap(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), CustomTrackWidthDialog(), MODULE_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::EnumeratePads(), PCB_EDITOR_CONTROL::ExportSpecctraDSN(), finishInteractive(), EDIT_TOOL::Flip(), PCB_EDITOR_CONTROL::FlipPcbView(), GLOBAL_EDIT_TOOL::GlobalDeletions(), MODULE_EDITOR_TOOLS::ImportFootprint(), PCB_EDITOR_CONTROL::ImportSpecctraSession(), PAD_TOOL::Init(), SELECTION_TOOL::Init(), EDIT_TOOL::Init(), InlineBreakTrack(), InlineDrag(), PCBNEW_PICKER_TOOL::Main(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::Move(), POINT_EDITOR::OnSelectionChange(), onViaCommand(), PCBNEW_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), performDragging(), performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickCopyReferencePoint(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), prepareInteractive(), PAD_TOOL::pushPadSettings(), 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(), POINT_EDITOR::updateItem(), 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*>( getEditFrameInt() ) );
191 #endif
192  return static_cast<T*>( getEditFrameInt() );
193  }
EDA_BASE_FRAME * getEditFrameInt() const
Definition: tool_base.cpp:48

References TOOL_BASE::getEditFrameInt().

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

◆ 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(), and TOOL_MANAGER::saveViewControls().

◆ 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
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163

References TOOL_BASE::getModelInt().

Referenced by ZONE_CREATE_HELPER::commitZone(), ZONE_CREATE_HELPER::createNewZone(), 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_SETTINGS::getKeyName(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::invokeTool(), and TOOL_MANAGER::RegisterTool().

◆ GetSettings()

TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 78 of file tool_base.cpp.

79 {
80  return m_toolSettings;
81 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:220

References TOOL_BASE::m_toolSettings.

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

◆ getStartLayer()

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

Definition at line 466 of file router_tool.cpp.

467 {
468  int tl = getView()->GetTopLayer();
469 
470  if( m_startItem )
471  {
472  const LAYER_RANGE& ls = m_startItem->Layers();
473 
474  if( ls.Overlaps( tl ) )
475  return tl;
476  else
477  return ls.Start();
478  }
479 
480  return tl;
481 }
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:851
ITEM * m_startItem
Definition: pns_tool_base.h:68
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
Class LAYER_RANGE.
Definition: pns_layerset.h:32
const LAYER_RANGE & Layers() const
Definition: pns_item.h:150

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

Referenced by prepareInteractive().

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

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(), and TOOL_MANAGER::runTool().

◆ 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:241
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(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), 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(), MICROWAVE_TOOL::drawMicrowaveInductor(), PL_DRAWING_TOOLS::DrawShape(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), EE_SELECTION_TOOL::GetNode(), getStartLayer(), COMMON_TOOLS::GridPreset(), 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(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Move(), EDIT_TOOL::MoveExact(), PL_EDIT_TOOL::moveItem(), POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), LIB_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), PNS::TOOL_BASE::pickSingleItem(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_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(), SELECTION_TOOL::Selectable(), GERBVIEW_SELECTION_TOOL::selectable(), 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(), EE_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), PL_EDITOR_CONTROL::ToggleBackgroundColor(), COMMON_TOOLS::ToggleGrid(), 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(), PCBNEW_CONTROL::updateGrid(), EE_POINT_EDITOR::updateItem(), PL_POINT_EDITOR::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateView(), PCB_TOOL_BASE::view(), COMMON_TOOLS::ZoomFitScreen(), 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:246

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

Referenced by EE_POINT_EDITOR::addCorner(), POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), SCH_EDIT_TOOL::BreakWire(), PCB_TOOL_BASE::controls(), COMMON_TOOLS::CursorControl(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomToPreset(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), 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(), COMMON_TOOLS::GridPreset(), PCB_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_INSPECTION_TOOL::HighlightNetTool(), MODULE_EDITOR_TOOLS::ImportFootprint(), PL_EDIT_TOOL::Main(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), MainLoop(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::Move(), POINT_EDITOR::OnSelectionChange(), LIB_EDIT_TOOL::Paste(), performDragging(), 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::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(), LIB_MOVE_TOOL::updateModificationPoint(), 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 LENGTH_TUNER_TOOL::setTransitions(), ZOOM_TOOL::setTransitions(), AUTOPLACE_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), setTransitions(), CVPCB_FOOTPRINT_VIEWER_CONTROL::setTransitions(), LIB_PIN_TOOL::setTransitions(), PAD_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), COMMON_CONTROL::setTransitions(), LIB_DRAWING_TOOLS::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), EE_POINT_EDITOR::setTransitions(), PL_POINT_EDITOR::setTransitions(), SCH_MOVE_TOOL::setTransitions(), LIB_MOVE_TOOL::setTransitions(), GERBVIEW_CONTROL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), POINT_EDITOR::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), LIB_CONTROL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), LIB_EDIT_TOOL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), PL_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), PCB_INSPECTION_TOOL::setTransitions(), PCBNEW_CONTROL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), MODULE_EDITOR_TOOLS::setTransitions(), CVPCB_CONTROL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), PCBNEW_PICKER_TOOL::setTransitions(), PICKER_TOOL::setTransitions(), PCB_EDITOR_CONTROL::setTransitions(), DRAWING_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), SELECTION_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), EE_SELECTION_TOOL::setTransitions(), and DRC::setTransitions().

◆ handleCommonEvents()

void ROUTER_TOOL::handleCommonEvents ( const TOOL_EVENT evt)
private

Definition at line 449 of file router_tool.cpp.

450 {
451 #ifdef DEBUG
452  if( aEvent.IsKeyPressed() )
453  {
454  switch( aEvent.KeyCode() )
455  {
456  case '0':
457  wxLogTrace( "PNS", "saving drag/route log...\n" );
458  m_router->DumpLog();
459  break;
460  }
461  }
462 #endif
463 }
ROUTER * m_router
Definition: pns_tool_base.h:78
void DumpLog()
Definition: pns_router.cpp:474

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

Referenced by performDragging(), and performRouting().

◆ highlightNet()

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

Definition at line 215 of file pns_tool_base.cpp.

216 {
218 
219  if( aNetcode >= 0 && aEnabled )
220  {
221  // If the user has previously set the current net to be highlighted,
222  // we assume they want to keep it highlighted after routing
223  m_startHighlight = ( rs->IsHighlightEnabled() && rs->GetHighlightNetCode() == aNetcode );
224 
225  rs->SetHighlight( true, aNetcode );
226  }
227  else
228  {
229  if( !m_startHighlight )
230  rs->SetHighlight( false );
231 
232  m_startHighlight = false;
233  }
234 
236 }
Class RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output ...
Definition: painter.h:56
bool m_startHighlight
Keeps track of whether the net was highlighted before routing.
Definition: pns_tool_base.h:71
bool IsHighlightEnabled() const
Function IsHighlightEnabled Returns current highlight setting.
Definition: painter.h:118
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aHighlightItems=false)
Function SetHighlight Turns on/off highlighting - it may be done for the active layer,...
Definition: painter.h:141
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
int GetHighlightNetCode() const
Function GetHighlightNetCode Returns netcode of currently highlighted net.
Definition: painter.h:128
void UpdateAllLayersColor()
Function UpdateAllLayersColor() Applies the new coloring scheme to all layers.
Definition: view.cpp:798

References KIGFX::RENDER_SETTINGS::GetHighlightNetCode(), 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 ( )
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 435 of file router_tool.cpp.

436 {
438  return true;
439 }
void Load(const TOOL_SETTINGS &where)
ROUTING_SETTINGS m_savedSettings
Stores routing settings between router invocations.
Definition: pns_tool_base.h:66
TOOL_SETTINGS & GetSettings()
Definition: tool_base.cpp:78

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

Referenced by InlineBreakTrack().

◆ InlineBreakTrack()

int ROUTER_TOOL::InlineBreakTrack ( const TOOL_EVENT aEvent)

Definition at line 1206 of file router_tool.cpp.

1207 {
1208  const auto& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
1209 
1210  if( selection.Size() != 1 )
1211  return 0;
1212 
1213  const BOARD_CONNECTED_ITEM* item = static_cast<const BOARD_CONNECTED_ITEM*>( selection.Front() );
1214 
1215  if( item->Type() != PCB_TRACE_T )
1216  return 0;
1217 
1218  Init();
1219  Activate();
1220 
1222  m_router->SyncWorld();
1224  m_startSnapPoint = snapToItem( true, m_startItem, controls()->GetCursorPosition() );
1225 
1226 
1227  if( m_startItem && m_startItem->IsLocked() )
1228  {
1229  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1230  wxOK | wxCANCEL | wxICON_WARNING );
1231  dlg.SetOKLabel( _( "Break Track" ) );
1232  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1233 
1234  if( dlg.ShowModal() == wxID_CANCEL )
1235  return 0;
1236  }
1237 
1238  frame()->UndoRedoBlock( true );
1239  breakTrack();
1240 
1241  if( m_router->RoutingInProgress() )
1242  m_router->StopRouting();
1243 
1244  frame()->UndoRedoBlock( false );
1245 
1246  return 0;
1247 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
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
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
void SyncWorld()
Definition: pns_router.cpp:89
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
void breakTrack()
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
const VECTOR2I snapToItem(bool aEnabled, ITEM *aItem, VECTOR2I aP)
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
PCB_BASE_EDIT_FRAME * frame() const
#define _(s)
const PCBNEW_SELECTION & selection() const
ITEM * m_startItem
Definition: pns_tool_base.h:68
ROUTER * m_router
Definition: pns_tool_base.h:78
void StopRouting()
Definition: pns_router.cpp:397
KIGFX::VIEW_CONTROLS * controls() const
int Size() const
Returns the number of selected parts.
Definition: selection.h:125
bool IsLocked() const
Definition: pns_item.h:235
ITEM * FindItemByParent(const BOARD_CONNECTED_ITEM *aParent)
Definition: pns_node.cpp:1297
void Activate()
Function Activate() Runs the tool.
bool RoutingInProgress() const
Definition: pns_router.cpp:110
NODE * GetWorld() const
Definition: pns_router.h:145
EDA_ITEM * Front() const
Definition: selection.h:182
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210

References _, TOOL_INTERACTIVE::Activate(), breakTrack(), PCB_TOOL_BASE::controls(), KIDIALOG::DoNotShowCheckbox(), PNS::NODE::FindItemByParent(), PCB_TOOL_BASE::frame(), SELECTION::Front(), TOOL_MANAGER::GetTool(), PNS::ROUTER::GetWorld(), Init(), 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 1126 of file router_tool.cpp.

1127 {
1128  const auto& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
1129 
1130  if( selection.Empty() )
1132 
1133  if( selection.Size() != 1 )
1134  return 0;
1135 
1136  const BOARD_CONNECTED_ITEM* item = static_cast<const BOARD_CONNECTED_ITEM*>( selection.Front() );
1137 
1138  if( item->Type() != PCB_TRACE_T && item->Type() != PCB_VIA_T )
1139  return 0;
1140 
1141  Activate();
1142 
1144  m_router->SyncWorld();
1146 
1147  if( m_startItem && m_startItem->IsLocked() )
1148  {
1149  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1150  wxOK | wxCANCEL | wxICON_WARNING );
1151  dlg.SetOKLabel( _( "Drag Anyway" ) );
1152  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1153 
1154  if( dlg.ShowModal() == wxID_CANCEL )
1155  return 0;
1156  }
1157 
1158  VECTOR2I p0 = controls()->GetCursorPosition( false );
1159  auto p = snapToItem( true, m_startItem, p0 );
1160  int dragMode = aEvent.Parameter<int64_t> ();
1161 
1162  bool dragStarted = m_router->StartDragging( p, m_startItem, dragMode );
1163 
1164  if( !dragStarted )
1165  return 0;
1166 
1167  m_gridHelper->SetAuxAxes( true, p );
1168  controls()->ShowCursor( true );
1169  controls()->ForceCursorPosition( false );
1170  controls()->SetAutoPan( true );
1171  frame()->UndoRedoBlock( true );
1172 
1173  while( TOOL_EVENT* evt = Wait() )
1174  {
1175  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
1176 
1177  if( evt->IsCancelInteractive() )
1178  {
1179  break;
1180  }
1181  else if( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
1182  {
1183  updateEndItem( *evt );
1185  }
1186  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
1187  {
1188  updateEndItem( *evt );
1190  break;
1191  }
1192  }
1193 
1194  if( m_router->RoutingInProgress() )
1195  m_router->StopRouting();
1196 
1197  m_gridHelper->SetAuxAxes( false );
1198  controls()->SetAutoPan( false );
1199  controls()->ForceCursorPosition( false );
1200  frame()->UndoRedoBlock( false );
1201 
1202  return 0;
1203 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
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
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
Class 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:89
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
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...
const VECTOR2I snapToItem(bool aEnabled, ITEM *aItem, VECTOR2I aP)
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
PCB_BASE_EDIT_FRAME * frame() const
virtual void updateEndItem(const TOOL_EVENT &aEvent)
void SetAuxAxes(bool aEnable, const VECTOR2I &aOrigin=VECTOR2I(0, 0))
Definition: grid_helper.cpp:92
#define _(s)
const PCBNEW_SELECTION & selection() const
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:427
Class TOOL_EVENT.
Definition: tool_event.h:168
ITEM * m_startItem
Definition: pns_tool_base.h:68
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:372
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 Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:229
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:119
void StopRouting()
Definition: pns_router.cpp:397
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:125
static void NeighboringSegmentFilter(const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector)
int Size() const
Returns the number of selected parts.
Definition: selection.h:125
bool IsLocked() const
Definition: pns_item.h:235
ITEM * FindItemByParent(const BOARD_CONNECTED_ITEM *aParent)
Definition: pns_node.cpp:1297
void Activate()
Function Activate() Runs the tool.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
bool RoutingInProgress() const
Definition: pns_router.cpp:110
NODE * GetWorld() const
Definition: pns_router.h:145
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:70
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:182
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210

References _, TOOL_INTERACTIVE::Activate(), BUT_LEFT, PCB_TOOL_BASE::controls(), KIDIALOG::DoNotShowCheckbox(), SELECTION::Empty(), PNS::NODE::FindItemByParent(), PNS::ROUTER::FixRoute(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), SELECTION::Front(), PCB_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_MANAGER::GetTool(), PNS::ROUTER::GetWorld(), 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(), NeighboringSegmentFilter(), TOOL_EVENT::Parameter(), PCB_TRACE_T, PCB_VIA_T, 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(), SELECTION::Size(), PNS::TOOL_BASE::snapToItem(), 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().

◆ 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.

◆ MainLoop()

int ROUTER_TOOL::MainLoop ( const TOOL_EVENT aEvent)

Definition at line 856 of file router_tool.cpp.

857 {
859  PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
860 
861  // Deselect all items
863 
864  std::string tool = aEvent.GetCommandStr().get();
865  frame->PushTool( tool );
866  Activate();
867 
868  m_router->SetMode( mode );
869 
870  VIEW_CONTROLS* ctls = getViewControls();
871  ctls->ShowCursor( true );
872  ctls->ForceCursorPosition( false );
873  m_cancelled = false;
875 
876  std::unique_ptr<ROUTER_TOOL_MENU> ctxMenu( new ROUTER_TOOL_MENU( *frame, mode ) );
877  SetContextMenu( ctxMenu.get() );
878 
879  // Prime the pump
880  if( aEvent.HasPosition() )
882 
883  // Main loop: keep receiving events
884  while( TOOL_EVENT* evt = Wait() )
885  {
886  frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
887 
888  if( evt->IsCancelInteractive() )
889  {
890  frame->PopTool( tool );
891  break;
892  }
893  else if( evt->IsActivate() )
894  {
895  if( evt->IsMoveTool() )
896  {
897  // leave ourselves on the stack so we come back after the move
898  break;
899  }
900  else
901  {
902  frame->PopTool( tool );
903  break;
904  }
905  }
906  else if( evt->Action() == TA_UNDO_REDO_PRE )
907  {
908  m_router->ClearWorld();
909  }
910  else if( evt->Action() == TA_UNDO_REDO_POST || evt->Action() == TA_MODEL_CHANGE )
911  {
912  m_router->SyncWorld();
913  }
914  else if( evt->IsMotion() )
915  {
916  updateStartItem( *evt );
917  }
918  else if( evt->IsAction( &PCB_ACTIONS::dragFreeAngle ) )
919  {
920  updateStartItem( *evt, true );
922  }
923  else if( evt->IsAction( &PCB_ACTIONS::drag45Degree ) )
924  {
925  updateStartItem( *evt, true );
927  }
928  else if( evt->IsAction( &PCB_ACTIONS::breakTrack ) )
929  {
930  updateStartItem( *evt, true );
931  breakTrack( );
932  }
933  else if( evt->IsClick( BUT_LEFT )
934  || evt->IsAction( &PCB_ACTIONS::routeSingleTrack )
935  || evt->IsAction( &PCB_ACTIONS::routeDiffPair ) )
936  {
937  if( evt->IsAction( &PCB_ACTIONS::routeSingleTrack )
938  || evt->IsAction( &PCB_ACTIONS::routeDiffPair ) )
939  {
940  mode = evt->Parameter<PNS::ROUTER_MODE>();
941  }
942 
943  updateStartItem( *evt );
944 
945  if( evt->HasPosition() )
946  {
947  if( evt->Modifier( MD_CTRL ) )
949  else
950  performRouting();
951  }
952  }
953  else if( evt->IsAction( &ACT_PlaceThroughVia ) )
954  {
956  }
957  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
958  {
960  updateStartItem( *evt );
961  }
962  else if( evt->IsKeyPressed() )
963  {
964  // wxWidgets fails to correctly translate shifted keycodes on the wxEVT_CHAR_HOOK
965  // event so we need to process the wxEVT_CHAR event that will follow as long as we
966  // pass the event.
967  evt->SetPassEvent();
968  }
969 
970  if( m_cancelled )
971  {
972  frame->PopTool( tool );
973  break;
974  }
975  }
976 
977  SetContextMenu( nullptr );
978 
979  // Store routing settings till the next invocation
982 
983  return 0;
984 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
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:145
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
SIZES_SETTINGS m_savedSizes
Stores sizes settings between router invocations.
Definition: pns_tool_base.h:67
void SyncWorld()
Definition: pns_router.cpp:89
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:144
void SetContextMenu(ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
Function SetContextMenu()
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:208
void SwitchLayer(int layer)
Definition: pns_router.cpp:434
void breakTrack()
void ClearWorld()
Definition: pns_router.cpp:98
PCB_BASE_EDIT_FRAME * frame() const
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
virtual void updateStartItem(const TOOL_EVENT &aEvent, bool aIgnorePads=false)
void performRouting()
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:427
Class TOOL_EVENT.
Definition: tool_event.h:168
ROUTER * m_router
Definition: pns_tool_base.h:78
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
ROUTING_SETTINGS m_savedSettings
Stores routing settings between router invocations.
Definition: pns_tool_base.h:66
static TOOL_ACTION breakTrack
Break a single track into two segments at the cursor.
Definition: pcb_actions.h:139
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:455
ROUTER_MODE
Definition: pns_router.h:65
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:276
void SetMode(ROUTER_MODE aMode)
Definition: pns_router.cpp:515
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:179
void performDragging(int aMode=PNS::DM_ANY)
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
virtual void PopTool(const std::string &actionName)
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:257
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:189
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
static TOOL_ACTION cursorClick
Definition: actions.h:114
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:274
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, PNS::ROUTER::ClearWorld(), ACTIONS::cursorClick, 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, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_savedSettings, PNS::TOOL_BASE::m_savedSizes, PNS::TOOL_BASE::m_startSnapPoint, TOOL_BASE::m_toolMgr, MD_CTRL, TOOL_EVENT::Parameter(), performDragging(), performRouting(), EDA_BASE_FRAME::PopTool(), EDA_BASE_FRAME::PushTool(), PCB_ACTIONS::routeDiffPair, PCB_ACTIONS::routeSingleTrack, TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, TOOL_INTERACTIVE::SetContextMenu(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), PNS::ROUTER::SetMode(), PNS::ROUTER::Settings(), 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().

◆ module()

◆ NeighboringSegmentFilter()

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

Definition at line 1055 of file router_tool.cpp.

1056 {
1057  /*
1058  * If the collection contains a trivial line corner (two connected segments)
1059  * or a non-fanout-via (a via with no more than two connected segments), then
1060  * trim the collection down to a single item (which one won't matter since
1061  * they're all connected).
1062  */
1063 
1064  // First make sure we've got something that *might* match.
1065  int vias = aCollector.CountType( PCB_VIA_T );
1066  int traces = aCollector.CountType( PCB_TRACE_T );
1067 
1068  if( vias > 1 || traces > 2 || vias + traces < 1 )
1069  return;
1070 
1071  // Fetch first TRACK (via or trace) as our reference
1072  TRACK* reference = nullptr;
1073 
1074  for( int i = 0; !reference && i < aCollector.GetCount(); i++ )
1075  reference = dynamic_cast<TRACK*>( aCollector[i] );
1076 
1077  int refNet = reference->GetNetCode();
1078 
1079  wxPoint refPoint( aPt.x, aPt.y );
1080  STATUS_FLAGS flags = reference->IsPointOnEnds( refPoint, -1 );
1081 
1082  if( flags & STARTPOINT )
1083  refPoint = reference->GetStart();
1084  else if( flags & ENDPOINT )
1085  refPoint = reference->GetEnd();
1086 
1087  // Check all items to ensure that any TRACKs are co-terminus with the reference and on
1088  // the same net.
1089  for( int i = 0; i < aCollector.GetCount(); i++ )
1090  {
1091  TRACK* neighbor = dynamic_cast<TRACK*>( aCollector[i] );
1092 
1093  if( neighbor && neighbor != reference )
1094  {
1095  if( neighbor->GetNetCode() != refNet )
1096  return;
1097 
1098  if( neighbor->GetStart() != refPoint && neighbor->GetEnd() != refPoint )
1099  return;
1100  }
1101  }
1102 
1103  // Selection meets criteria; trim it to the reference item.
1104  aCollector.Empty();
1105  aCollector.Append( reference );
1106 }
void Empty()
Function Empty sets the list to empty.
Definition: collector.h:122
int GetNetCode() const
Function GetNetCode.
const wxPoint & GetStart() const
Definition: class_track.h:109
int CountType(KICAD_T aType)
Function CountType counts the number of items matching aType.
Definition: collector.h:264
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
void Append(EDA_ITEM *item)
Function Append adds an item to the end of the list.
Definition: collector.h:132
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:113
unsigned STATUS_FLAGS
Definition: base_struct.h:156
STATUS_FLAGS IsPointOnEnds(const wxPoint &point, int min_dist=0) const
Function IsPointOnEnds returns STARTPOINT if point if near (dist = min_dist) start point,...
size_t i
Definition: json11.cpp:597
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:126
const wxPoint & GetEnd() const
Definition: class_track.h:106
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:125

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

Referenced by CanInlineDrag(), connectedTrackFilter(), and InlineDrag().

◆ onTrackViaSizeChanged()

int ROUTER_TOOL::onTrackViaSizeChanged ( const TOOL_EVENT aEvent)
private

Definition at line 1265 of file router_tool.cpp.

1266 {
1267  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
1268  sizes.ImportCurrent( board()->GetDesignSettings() );
1269  m_router->UpdateSizes( sizes );
1270 
1271  // Changing the track width can affect the placement, so call the
1272  // move routine without changing the destination
1274 
1275  return 0;
1276 }
BOARD * board() const
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:208
ROUTER * m_router
Definition: pns_tool_base.h:78
void ImportCurrent(BOARD_DESIGN_SETTINGS &aSettings)
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:229
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:316
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74

References PCB_TOOL_BASE::board(), PNS::SIZES_SETTINGS::ImportCurrent(), PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_router, PNS::ROUTER::Move(), PNS::ROUTER::Sizes(), and PNS::ROUTER::UpdateSizes().

Referenced by setTransitions().

◆ onViaCommand()

int ROUTER_TOOL::onViaCommand ( const TOOL_EVENT aEvent)
private

Definition at line 518 of file router_tool.cpp.

519 {
520  const int actViaFlags = aEvent.Parameter<intptr_t>();
521 
522  VIATYPE_T viaType = getViaTypeFromFlags( actViaFlags );
523  const bool selectLayer = actViaFlags & VIA_ACTION_FLAGS::SELECT_LAYER;
524 
526 
527  const int layerCount = bds.GetCopperLayerCount();
528  int currentLayer = m_router->GetCurrentLayer();
531 
533 
534  // ask the user for a target layer
535  PCB_LAYER_ID targetLayer = UNDEFINED_LAYER;
536 
537  if( selectLayer )
538  {
539  wxPoint dlgPosition = wxGetMousePosition();
540 
541  targetLayer = frame()->SelectLayer( static_cast<PCB_LAYER_ID>( currentLayer ),
542  LSET::AllNonCuMask(), dlgPosition );
543  }
544 
545  // fixme: P&S supports more than one fixed layer pair. Update the dialog?
546  sizes.ClearLayerPairs();
547 
548  if( !m_router->IsPlacingVia() )
549  {
550  // Cannot place microvias or blind vias if not allowed (obvious)
551  if( ( viaType == VIA_BLIND_BURIED ) && ( !bds.m_BlindBuriedViaAllowed ) )
552  {
553  DisplayError( frame(), _( "Blind/buried vias have to be enabled in the design settings." ) );
554  return false;
555  }
556 
557  if( ( viaType == VIA_MICROVIA ) && ( !bds.m_MicroViasAllowed ) )
558  {
559  DisplayError( frame(), _( "Microvias have to be enabled in the design settings." ) );
560  return false;
561  }
562 
563  // Can only place through vias on 2-layer boards
564  if( ( viaType != VIA_THROUGH ) && ( layerCount <= 2 ) )
565  {
566  DisplayError( frame(), _( "Only through vias are allowed on 2 layer boards." ) );
567  return false;
568  }
569 
570  // Can only place microvias if we're on an outer layer, or directly adjacent to one
571  if( ( viaType == VIA_MICROVIA ) && ( currentLayer > In1_Cu ) && ( currentLayer < layerCount - 2 ) )
572  {
573  DisplayError( frame(), _( "Microvias can be placed only between the outer layers " \
574  "(F.Cu/B.Cu) and the ones directly adjacent to them." ) );
575  return false;
576  }
577  }
578 
579  // Convert blind/buried via to a through hole one, if it goes through all layers
580  if( viaType == VIA_BLIND_BURIED && ( ( currentLayer == B_Cu ) || ( currentLayer == F_Cu ) )
581  && ( ( pairTop == B_Cu && pairBottom == F_Cu )
582  || ( pairTop == F_Cu && pairBottom == B_Cu ) ) )
583  {
584  viaType = VIA_THROUGH;
585  }
586 
587  switch( viaType )
588  {
589  case VIA_THROUGH:
590  sizes.SetViaDiameter( bds.GetCurrentViaSize() );
591  sizes.SetViaDrill( bds.GetCurrentViaDrill() );
592 
593  if( targetLayer != UNDEFINED_LAYER )
594  {
595  // go from the current layer to the chosen layer
596  sizes.AddLayerPair( currentLayer, targetLayer );
597  }
598  else
599  {
600  // use the default layer pair
601  sizes.AddLayerPair( pairTop, pairBottom );
602  }
603  break;
604 
605  case VIA_MICROVIA:
606  sizes.SetViaDiameter( bds.GetCurrentMicroViaSize() );
607  sizes.SetViaDrill( bds.GetCurrentMicroViaDrill() );
608 
609  wxASSERT_MSG( !selectLayer, "Unexpected select layer for microvia (microvia layers are implicit)" );
610 
611  if( currentLayer == F_Cu || currentLayer == In1_Cu )
612  {
613  // front-side microvia
614  sizes.AddLayerPair( F_Cu, In1_Cu );
615  }
616  else if( currentLayer == B_Cu || currentLayer == layerCount - 2 )
617  {
618  // back-side microvia
619  sizes.AddLayerPair( B_Cu, layerCount - 2 );
620  }
621  else
622  {
623  wxASSERT_MSG( false, "Invalid layer pair for microvia (must be on or adjacent to an outer layer)" );
624  }
625  break;
626 
627  case VIA_BLIND_BURIED:
628  sizes.SetViaDiameter( bds.GetCurrentViaSize() );
629  sizes.SetViaDrill( bds.GetCurrentViaDrill() );
630 
631  if( targetLayer != UNDEFINED_LAYER )
632  {
633  // go directly to the user specified layer
634  sizes.AddLayerPair( currentLayer, targetLayer );
635  }
636  else
637  {
638  if( currentLayer == pairTop || currentLayer == pairBottom )
639  {
640  // the current layer is on the defined layer pair,
641  // swap to the other side
642  sizes.AddLayerPair( pairTop, pairBottom );
643  }
644  else
645  {
646  // the current layer is not part of the current layer pair,
647  // so fallback and swap to the top layer of the pair by default
648  sizes.AddLayerPair( pairTop, currentLayer );
649  }
650  }
651  break;
652 
653  default:
654  wxASSERT( false );
655  break;
656  }
657 
658  sizes.SetViaType( viaType );
659 
660  m_router->UpdateSizes( sizes );
662 
663  if( m_router->RoutingInProgress() )
664  updateEndItem( aEvent );
665  else
666  updateStartItem( aEvent );
667 
668  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
669 
670  return 0;
671 }
int GetCurrentMicroViaSize()
Function GetCurrentMicroViaSize.
BOARD * board() const
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:699
bool IsPlacingVia() const
Definition: pns_router.cpp:497
Microvia
Definition: router_tool.cpp:67
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:540
void SetViaDrill(int aDrill)
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:208
VIATYPE_T
Definition: class_track.h:60
void ToggleViaPlacement()
Definition: pns_router.cpp:447
PCB_BASE_EDIT_FRAME * frame() const
virtual void updateStartItem(const TOOL_EVENT &aEvent, bool aIgnorePads=false)
virtual void updateEndItem(const TOOL_EVENT &aEvent)
PCB_LAYER_ID
A quick note on layer IDs:
#define _(s)
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:427
ROUTER * m_router
Definition: pns_tool_base.h:78
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:46
bool m_BlindBuriedViaAllowed
true to allow blind/buried vias
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:229
int GetCurrentViaSize() const
Function GetCurrentViaSize.
void SetViaType(VIATYPE_T aViaType)
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:316
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void AddLayerPair(int aL1, int aL2)
static VIATYPE_T getViaTypeFromFlags(int aFlags)
bool m_MicroViasAllowed
true to allow micro vias
bool RoutingInProgress() const
Definition: pns_router.cpp:110
void SetViaDiameter(int aDiameter)
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:243
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:205
PCB_LAYER_ID m_Route_Layer_TOP
Definition: pcb_screen.h:45
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
int GetCurrentLayer() const
Definition: pns_router.cpp:466

References _, PNS::SIZES_SETTINGS::AddLayerPair(), LSET::AllNonCuMask(), B_Cu, PCB_TOOL_BASE::board(), PNS::SIZES_SETTINGS::ClearLayerPairs(), DisplayError(), F_Cu, PCB_TOOL_BASE::frame(), 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_endItem, PNS::TOOL_BASE::m_endSnapPoint, 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(), PNS::ROUTER::RoutingInProgress(), 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(), PNS::TOOL_BASE::updateStartItem(), VIA_BLIND_BURIED, VIA_MICROVIA, and VIA_THROUGH.

Referenced by setTransitions().

◆ performDragging()

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

Definition at line 987 of file router_tool.cpp.

988 {
989  VIEW_CONTROLS* ctls = getViewControls();
990 
991  if( m_startItem && m_startItem->IsLocked() )
992  {
993  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
994  wxOK | wxCANCEL | wxICON_WARNING );
995  dlg.SetOKLabel( _( "Drag Anyway" ) );
996  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
997 
998  if( dlg.ShowModal() == wxID_CANCEL )
999  return;
1000  }
1001 
1002  bool dragStarted = m_router->StartDragging( m_startSnapPoint, m_startItem, aMode );
1003 
1004  if( !dragStarted )
1005  return;
1006 
1007  if( m_startItem && m_startItem->Net() >= 0 )
1008  highlightNet( true, m_startItem->Net() );
1009 
1010  ctls->SetAutoPan( true );
1012  frame()->UndoRedoBlock( true );
1013 
1014  while( TOOL_EVENT* evt = Wait() )
1015  {
1016  ctls->ForceCursorPosition( false );
1017 
1018  if( evt->IsMotion() )
1019  {
1020  updateEndItem( *evt );
1022  }
1023  else if( evt->IsClick( BUT_LEFT ) )
1024  {
1026  break;
1027  }
1028  else if( evt->IsCancelInteractive() || evt->IsActivate() || evt->IsUndoRedo() )
1029  {
1030  if( evt->IsCancelInteractive() && !m_startItem )
1031  m_cancelled = true;
1032 
1033  if( evt->IsActivate() && !evt->IsMoveTool() )
1034  m_cancelled = true;
1035 
1036  break;
1037  }
1038 
1039  handleCommonEvents( *evt );
1040  }
1041 
1042  if( m_router->RoutingInProgress() )
1043  m_router->StopRouting();
1044 
1045  m_startItem = nullptr;
1046 
1047  m_gridHelper->SetAuxAxes( false );
1048  frame()->UndoRedoBlock( false );
1049  ctls->SetAutoPan( false );
1050  ctls->ForceCursorPosition( false );
1051  highlightNet( false );
1052 }
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))
Definition: grid_helper.cpp:92
#define _(s)
int Net() const
Definition: pns_item.h:148
Class TOOL_EVENT.
Definition: tool_event.h:168
ITEM * m_startItem
Definition: pns_tool_base.h:68
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:372
ROUTER * m_router
Definition: pns_tool_base.h:78
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
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:229
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:397
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:125
bool IsLocked() const
Definition: pns_item.h:235
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
bool RoutingInProgress() const
Definition: pns_router.cpp:110

References _, BUT_LEFT, 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, 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(), GRID_HELPER::SetAuxAxes(), 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 742 of file router_tool.cpp.

743 {
744  if( !prepareInteractive() )
745  return;
746 
747  while( TOOL_EVENT* evt = Wait() )
748  {
749  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
750 
751  // Don't crash if we missed an operation that cancelled routing.
752  wxCHECK2( m_router->RoutingInProgress(), break );
753 
754  handleCommonEvents( *evt );
755 
756  if( evt->IsMotion() )
757  {
758  m_router->SetOrthoMode( evt->Modifier( MD_CTRL ) );
759  updateEndItem( *evt );
761  }
762  else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &PCB_ACTIONS::routeSingleTrack ) )
763  {
764  updateEndItem( *evt );
765  bool needLayerSwitch = m_router->IsPlacingVia();
766  bool forceFinish = evt->Modifier( MD_SHIFT );
767 
768 
769  if( m_router->FixRoute( m_endSnapPoint, m_endItem, forceFinish ) )
770  break;
771 
772  if( needLayerSwitch )
774 
775  // Synchronize the indicated layer
777  updateEndItem( *evt );
779  m_startItem = nullptr;
780  }
781  else if( evt->IsAction( &ACT_SwitchPosture ) )
782  {
784  updateEndItem( *evt );
785  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
786  }
787  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
788  {
789  m_router->SwitchLayer( frame()->GetActiveLayer() );
790  updateEndItem( *evt );
791  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
792  }
793  else if( evt->IsAction( &ACT_EndTrack ) )
794  {
795  bool still_routing = true;
796  while( still_routing )
797  still_routing = m_router->FixRoute( m_endSnapPoint, m_endItem );
798  break;
799  }
800  else if( evt->IsCancelInteractive() || evt->IsActivate()
801  || evt->IsUndoRedo()
802  || evt->IsAction( &PCB_ACTIONS::routerInlineDrag ) )
803  {
804  if( evt->IsCancelInteractive() && !m_router->RoutingInProgress() )
805  m_cancelled = true;
806 
807  if( evt->IsActivate() && !evt->IsMoveTool() )
808  m_cancelled = true;
809 
810  break;
811  }
812  }
813 
815 }
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
bool finishInteractive()
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
bool IsPlacingVia() const
Definition: pns_router.cpp:497
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)
void SwitchLayer(int layer)
Definition: pns_router.cpp:434
void SetOrthoMode(bool aEnable)
Definition: pns_router.cpp:506
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
virtual void updateEndItem(const TOOL_EVENT &aEvent)
bool prepareInteractive()
Class TOOL_EVENT.
Definition: tool_event.h:168
ITEM * m_startItem
Definition: pns_tool_base.h:68
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:372
ROUTER * m_router
Definition: pns_tool_base.h:78
void switchLayerOnViaPlacement()
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
Function SetActiveLayer will change the currently active layer to aLayer.
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:229
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:199
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:276
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:425
bool RoutingInProgress() const
Definition: pns_router.cpp:110
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:813
int GetCurrentLayer() const
Definition: pns_router.cpp:466

References ACT_EndTrack, ACT_SwitchPosture, BUT_LEFT, 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, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, MD_CTRL, MD_SHIFT, PNS::ROUTER::Move(), prepareInteractive(), PCB_ACTIONS::routerInlineDrag, PCB_ACTIONS::routeSingleTrack, PNS::ROUTER::RoutingInProgress(), PCB_BASE_FRAME::SetActiveLayer(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), PNS::ROUTER::SetOrthoMode(), PNS::ROUTER::SwitchLayer(), switchLayerOnViaPlacement(), ToLAYER_ID(), 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 112 of file pns_tool_base.cpp.

114 {
115  int tl = getView()->GetTopLayer();
116 
117  if( aLayer > 0 )
118  tl = aLayer;
119 
120  static const int candidateCount = 5;
121  ITEM* prioritized[candidateCount];
122  int dist[candidateCount];
123 
124  for( int i = 0; i < candidateCount; i++ )
125  {
126  prioritized[i] = 0;
128  }
129 
130  ITEM_SET candidates = m_router->QueryHoverItems( aWhere );
131 
132  for( ITEM* item : candidates.Items() )
133  {
134  if( !item->IsRoutable() )
135  continue;
136 
137  if( !IsCopperLayer( item->Layers().Start() ) )
138  continue;
139 
140  if( !m_iface->IsAnyLayerVisible( item->Layers() ) )
141  continue;
142 
143  if( std::find( aAvoidItems.begin(), aAvoidItems.end(), item ) != aAvoidItems.end() )
144  continue;
145 
146  // fixme: this causes flicker with live loop removal...
147  //if( item->Parent() && !item->Parent()->ViewIsVisible() )
148  // continue;
149 
150  if( aNet <= 0 || item->Net() == aNet )
151  {
152  if( item->OfKind( ITEM::VIA_T | ITEM::SOLID_T ) )
153  {
154  if( item->OfKind( ITEM::SOLID_T ) && aIgnorePads )
155  continue;
156 
157  int itemDist = ( item->Shape()->Centre() - aWhere ).SquaredEuclideanNorm();
158 
159  if( !prioritized[2] || itemDist < dist[2] )
160  {
161  prioritized[2] = item;
162  dist[2] = itemDist;
163  }
164  if( item->Layers().Overlaps( tl ) && itemDist < dist[0] )
165  {
166  prioritized[0] = item;
167  dist[0] = itemDist;
168  }
169  }
170  else
171  {
172  if( !prioritized[3] )
173  prioritized[3] = item;
174  if( item->Layers().Overlaps( tl ) )
175  prioritized[1] = item;
176  }
177  }
178  // Allow unconnected items as last resort in RM_MarkObstacles mode
179  else if ( item->Net() == 0 && m_router->Settings().Mode() == RM_MarkObstacles )
180  {
181  if( item->OfKind( ITEM::SOLID_T ) && aIgnorePads )
182  continue;
183 
184  if( item->Layers().Overlaps( tl ) )
185  prioritized[4] = item;
186  }
187  }
188 
189  ITEM* rv = NULL;
190 
191  for( int i = 0; i < candidateCount; i++ )
192  {
193  ITEM* item = prioritized[i];
194 
196  if( item && !item->Layers().Overlaps( tl ) )
197  item = NULL;
198 
199  if( item && ( aLayer < 0 || item->Layers().Overlaps( aLayer ) ) )
200  {
201  rv = item;
202  break;
203  }
204  }
205 
206  if( rv )
207  {
208  wxLogTrace( "PNS", "%s, layer : %d, tl: %d", rv->KindStr().c_str(), rv->Layers().Start(), tl );
209  }
210 
211  return rv;
212 }
PCB_DISPLAY_OPTIONS * displayOptions() const
static const int dist[10][10]
Definition: ar_matrix.cpp:320
const ITEM_SET QueryHoverItems(const VECTOR2I &aP)
Definition: pns_router.cpp:116
bool IsAnyLayerVisible(const LAYER_RANGE &aLayer) override
virtual int GetTopLayer() const
Definition: view.cpp:851
ROUTER * m_router
Definition: pns_tool_base.h:78
PNS_MODE Mode() const
Returns the routing mode.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
#define max(a, b)
Definition: auxiliary.h:86
size_t i
Definition: json11.cpp:597
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer 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:189

References PCB_TOOL_BASE::displayOptions(), dist, KIGFX::VIEW::GetTopLayer(), TOOL_BASE::getView(), i, 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, max, PNS::ROUTING_SETTINGS::Mode(), 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 674 of file router_tool.cpp.

675 {
676  int routingLayer = getStartLayer( m_startItem );
677 
678  if( !IsCopperLayer( routingLayer ) )
679  {
680  DisplayError( frame(), _( "Tracks on Copper layers only" ) );
681  return false;
682  }
683 
684  PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
685 
686  editFrame->SetActiveLayer( ToLAYER_ID( routingLayer ) );
687 
688  // Force layer visible
689  editFrame->GetLayerManager()->SetLayerVisible( routingLayer, true );
690 
691  // for some reason I don't understand, GetNetclass() may return null sometimes...
692  if( m_startItem && m_startItem->Net() >= 0 &&
694  {
695  highlightNet( true, m_startItem->Net() );
696  // Update track width and via size shown in main toolbar comboboxes
697  editFrame->SetCurrentNetClass( m_startItem->Parent()->GetNetClass()->GetName() );
698  }
699  else
701 
702  controls()->ForceCursorPosition( false );
703  controls()->SetAutoPan( true );
704 
705  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
706 
707  sizes.Init( board(), m_startItem );
708  sizes.AddLayerPair( frame()->GetScreen()->m_Route_Layer_TOP,
709  frame()->GetScreen()->m_Route_Layer_BOTTOM );
710  m_router->UpdateSizes( sizes );
711 
712  if( !m_router->StartRouting( m_startSnapPoint, m_startItem, routingLayer ) )
713  {
715  highlightNet( false );
716  controls()->SetAutoPan( false );
717  return false;
718  }
719 
720  m_endItem = nullptr;
722 
723  frame()->UndoRedoBlock( true );
724 
725  return true;
726 }
const wxString & FailureReason() const
Definition: pns_router.h:216
BOARD_CONNECTED_ITEM * Parent() const
Definition: pns_item.h:145
BOARD * board() const
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:208
bool SetCurrentNetClass(const wxString &aNetClassName)
Function SetCurrentNetClass Must be called after a netclass selection (or after a netclass parameter ...
PCB_BASE_EDIT_FRAME * frame() const
#define _(s)
static const char Default[]
the name of the default NETCLASS
Definition: netclass.h:80
int Net() const
Definition: pns_item.h:148
ITEM * m_startItem
Definition: pns_tool_base.h:68
void Init(BOARD *aBoard, ITEM *aStartItem=NULL, int aNet=-1)
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.
PCB_LAYER_WIDGET * GetLayerManager()
bool StartRouting(const VECTOR2I &aP, ITEM *aItem, int aLayer)
Definition: pns_router.cpp:174
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:316
KIGFX::VIEW_CONTROLS * controls() const
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
std::shared_ptr< NETCLASS > GetNetClass() const
Function GetNetClass returns the NETCLASS for this item.
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
void SetLayerVisible(LAYER_NUM aLayer, bool isVisible)
Function SetLayerVisible sets aLayer visible or not.
int getStartLayer(const PNS::ITEM *aItem)
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:243
void SetActiveLayer(PCB_LAYER_ID aLayer) override
Function SetActiveLayer will change the currently active layer to aLayer and also update the PCB_LAYE...
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:813

References _, PCB_TOOL_BASE::board(), PCB_TOOL_BASE::controls(), NETCLASS::Default, DisplayError(), PNS::ROUTER::FailureReason(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_EDIT_FRAME::GetLayerManager(), BOARD_CONNECTED_ITEM::GetNetClass(), getStartLayer(), PNS::TOOL_BASE::highlightNet(), PNS::SIZES_SETTINGS::Init(), IsCopperLayer(), PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, 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(), LAYER_WIDGET::SetLayerVisible(), 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 442 of file router_tool.cpp.

443 {
444  if( aReason == RUN )
445  TOOL_BASE::Reset( aReason );
446 }
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 375 of file pns_tool_base.cpp.

376 {
377  return m_router;
378 }
ROUTER * m_router
Definition: pns_tool_base.h:78

References PNS::TOOL_BASE::m_router.

Referenced by EDIT_TOOL::Remove().

◆ 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 260 of file sel_layer.cpp.

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

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

258 {
259  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
260  const auto& selection = selTool->GetSelection();
261  return selection;
262 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
const PCBNEW_SELECTION & selection() const

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

Referenced by AUTOPLACE_TOOL::autoplaceSelected(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), CanInlineDrag(), EDIT_TOOL::changeTrackWidthOnClick(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawZone(), EDIT_TOOL::Duplicate(), EDIT_TOOL::EditFpInFpEditor(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), EDIT_TOOL::Flip(), DRAWING_TOOL::getSourceZoneForAction(), PCB_INSPECTION_TOOL::highlightNet(), InlineBreakTrack(), InlineDrag(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::Move(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PAD_TOOL::pastePadProperties(), 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(), EDIT_TOOL::Rotate(), SELECTION_TOOL::selectCopper(), PCB_TOOL_BASE::selection(), SELECTION_TOOL::selectNet(), DRAWING_TOOL::SetAnchor(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), 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 265 of file pcb_tool_base.cpp.

266 {
267  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
268  auto& selection = selTool->GetSelection();
269  return selection;
270 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
const PCBNEW_SELECTION & selection() const

References TOOL_MANAGER::GetTool(), TOOL_BASE::m_toolMgr, and PCB_TOOL_BASE::selection().

◆ 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)
Function SetTool() 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(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), TOOL_MENU::ShowContextMenu(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ SetEditModules()

void PCB_TOOL_BASE::SetEditModules ( bool  aEnabled)
inlineinherited

Function SetEditModules()

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

Parameters
aEnableddecides if the mode should be enabled.

Definition at line 97 of file pcb_tool_base.h.

98  {
99  m_editModules = aEnabled;
100  }

References PCB_TOOL_BASE::m_editModules.

◆ SettingsDialog()

int ROUTER_TOOL::SettingsDialog ( const TOOL_EVENT aEvent)

Definition at line 838 of file router_tool.cpp.

839 {
840  DIALOG_PNS_SETTINGS settingsDlg( frame(), m_router->Settings() );
841 
842  if( settingsDlg.ShowModal() == wxID_OK )
844 
845  return 0;
846 }
PCB_BASE_EDIT_FRAME * frame() const
ROUTER * m_router
Definition: pns_tool_base.h:78
ROUTING_SETTINGS m_savedSettings
Stores routing settings between router invocations.
Definition: pns_tool_base.h:66
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:189

References PCB_TOOL_BASE::frame(), PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_savedSettings, 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 1279 of file router_tool.cpp.

1280 {
1282 
1289 
1295 
1298 }
int MainLoop(const TOOL_EVENT &aEvent)
static TOOL_ACTION selectLayerPair
Definition: pcb_actions.h:136
static const TOOL_ACTION ACT_PlaceMicroVia("pcbnew.InteractiveRouter.PlaceMicroVia", AS_CONTEXT, MD_CTRL+ 'V', LEGACY_HK_NAME("Add MicroVia"), _("Place Microvia"), _("Adds a microvia at the end of currently routed track."), via_microvia_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::MICROVIA)
int DpDimensionsDialog(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerDiffPairDialog
Definition: pcb_actions.h:195
int InlineDrag(const TOOL_EVENT &aEvent)
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:286
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)
static TOOL_ACTION routerSettingsDialog
Activation of the Push and Shove settings dialogs.
Definition: pcb_actions.h:194
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)
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)
int onTrackViaSizeChanged(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:199
static TOOL_ACTION inlineBreakTrack
Breaks track when router is not activated.
Definition: pcb_actions.h:142
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 routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:179
TOOL_EVENT MakeEvent() const
Function MakeEvent() Returns the event associated with the action (i.e.
Definition: tool_action.h:107
int InlineBreakTrack(const TOOL_EVENT &aEvent)
int SelectCopperLayerPair(const TOOL_EVENT &aEvent)
Definition: sel_layer.cpp:260
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 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, CustomTrackWidthDialog(), DpDimensionsDialog(), TOOL_INTERACTIVE::Go(), InlineBreakTrack(), PCB_ACTIONS::inlineBreakTrack, InlineDrag(), MainLoop(), TOOL_ACTION::MakeEvent(), onTrackViaSizeChanged(), onViaCommand(), PCB_ACTIONS::routeDiffPair, PCB_ACTIONS::routerDiffPairDialog, PCB_ACTIONS::routerInlineDrag, PCB_ACTIONS::routerSettingsDialog, 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 381 of file pns_tool_base.cpp.

382 {
383  VECTOR2I anchor;
384 
385  if( !aItem || !aEnabled )
386  {
387  return m_gridHelper->Align( aP );
388  }
389 
390  switch( aItem->Kind() )
391  {
392  case ITEM::SOLID_T:
393  anchor = static_cast<SOLID*>( aItem )->Pos();
394  break;
395 
396  case ITEM::VIA_T:
397  anchor = static_cast<VIA*>( aItem )->Pos();
398  break;
399 
400  case ITEM::SEGMENT_T:
401  {
402  SEGMENT* seg = static_cast<SEGMENT*>( aItem );
403  const SEG& s = seg->Seg();
404  int w = seg->Width();
405 
406 
407  if( ( aP - s.A ).EuclideanNorm() < w / 2 )
408  anchor = s.A;
409  else if( ( aP - s.B ).EuclideanNorm() < w / 2 )
410  anchor = s.B;
411  else
412  anchor = m_gridHelper->AlignToSegment( aP, s );
413 
414  break;
415  }
416 
417  default:
418  break;
419  }
420 
421  return anchor;
422 }
GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)
Definition: seg.h:36
VECTOR2I Align(const VECTOR2I &aPoint) const
VECTOR2I A
Definition: seg.h:44
VECTOR2I B
Definition: seg.h:45

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 InlineBreakTrack(), InlineDrag(), PNS::TOOL_BASE::updateEndItem(), and PNS::TOOL_BASE::updateStartItem().

◆ switchLayerOnViaPlacement()

void ROUTER_TOOL::switchLayerOnViaPlacement ( )
private

Definition at line 484 of file router_tool.cpp.

485 {
486  int al = frame()->GetActiveLayer();
487  int cl = m_router->GetCurrentLayer();
488 
489  if( cl != al )
490  {
491  m_router->SwitchLayer( al );
492  }
493 
494  OPT<int> newLayer = m_router->Sizes().PairedLayer( cl );
495 
496  if( !newLayer )
497  newLayer = m_router->Sizes().GetLayerTop();
498 
499  m_router->SwitchLayer( *newLayer );
500  frame()->SetActiveLayer( ToLAYER_ID( *newLayer ) );
501 }
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:208
void SwitchLayer(int layer)
Definition: pns_router.cpp:434
PCB_BASE_EDIT_FRAME * frame() const
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
ROUTER * m_router
Definition: pns_tool_base.h:78
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
Function SetActiveLayer will change the currently active layer to aLayer.
boost::optional< T > OPT
Definition: optional.h:7
OPT< int > PairedLayer(int aLayerId)
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:813
int GetCurrentLayer() const
Definition: pns_router.cpp:466

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

297 {
298  int layer;
299  bool snapEnabled = !aEvent.Modifier( MD_SHIFT );
300  m_gridHelper->SetUseGrid( !aEvent.Modifier( MD_ALT ) );
301  m_gridHelper->SetSnap( snapEnabled );
302 
303  controls()->ForceCursorPosition( false );
304  VECTOR2I mousePos = controls()->GetMousePosition();
305 
306  if( m_router->Settings().Mode() != RM_MarkObstacles &&
307  ( m_router->GetCurrentNets().empty() || m_router->GetCurrentNets().front() < 0 ) )
308  {
309  m_endSnapPoint = snapToItem( snapEnabled, nullptr, mousePos );
311  m_endItem = nullptr;
312 
313  return;
314  }
315 
316  if( m_router->IsPlacingVia() )
317  layer = -1;
318  else
319  layer = m_router->GetCurrentLayer();
320 
321  ITEM* endItem = nullptr;
322 
323  std::vector<int> nets = m_router->GetCurrentNets();
324 
325  for( int net : nets )
326  {
327  endItem = pickSingleItem( mousePos, net, layer, false, { m_startItem } );
328 
329  if( endItem )
330  break;
331  }
332 
333  if( checkSnap( endItem ) )
334  {
335  m_endItem = endItem;
336  m_endSnapPoint = snapToItem( snapEnabled, endItem, mousePos );
337  } else {
338  m_endItem = nullptr;
339  m_endSnapPoint = m_gridHelper->Align( mousePos );
340  }
341 
343 
344  if( m_endItem )
345  {
346  wxLogTrace( "PNS", "%s, layer : %d", m_endItem->KindStr().c_str(), m_endItem->Layers().Start() );
347  }
348 }
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.
bool IsPlacingVia() const
Definition: pns_router.cpp:497
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:457
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:71
bool checkSnap(ITEM *aItem)
ITEM * m_startItem
Definition: pns_tool_base.h:68
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:66
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:334
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:71
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:189
const LAYER_RANGE & Layers() const
Definition: pns_item.h:150
int GetCurrentLayer() const
Definition: pns_router.cpp:466

References GRID_HELPER::Align(), PNS::TOOL_BASE::checkSnap(), PCB_TOOL_BASE::controls(), 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_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_gridHelper, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, MD_ALT, MD_SHIFT, PNS::ROUTING_SETTINGS::Mode(), TOOL_EVENT::Modifier(), PNS::TOOL_BASE::pickSingleItem(), PNS::RM_MarkObstacles, GRID_HELPER::SetSnap(), PNS::ROUTER::Settings(), GRID_HELPER::SetUseGrid(), PNS::TOOL_BASE::snapToItem(), and LAYER_RANGE::Start().

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

◆ updateStartItem()

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

Definition at line 260 of file pns_tool_base.cpp.

261 {
262  int tl = getView()->GetTopLayer();
263  VECTOR2I cp = controls()->GetCursorPosition( !aEvent.Modifier( MD_SHIFT ) );
264  VECTOR2I p;
265 
266  controls()->ForceCursorPosition( false );
267  m_gridHelper->SetUseGrid( !aEvent.Modifier( MD_ALT ) );
268  m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
269 
270  bool snapEnabled = true;
271 
272  if( aEvent.IsMotion() || aEvent.IsClick() )
273  {
274  snapEnabled = !aEvent.Modifier( MD_SHIFT );
275  p = aEvent.Position();
276  }
277  else
278  {
279  p = cp;
280  }
281 
282  m_startItem = pickSingleItem( p, -1, -1, aIgnorePads );
283 
284  if( !snapEnabled && m_startItem && !m_startItem->Layers().Overlaps( tl ) )
285  m_startItem = nullptr;
286 
287  m_startSnapPoint = snapToItem( snapEnabled, m_startItem, p );
288 
289  if( checkSnap( m_startItem ) )
290  {
292  }
293 }
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:174
bool IsMotion() const
Definition: tool_event.h:303
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:68
const VECTOR2I snapToItem(bool aEnabled, ITEM *aItem, VECTOR2I aP)
bool checkSnap(ITEM *aItem)
virtual int GetTopLayer() const
Definition: view.cpp:851
ITEM * m_startItem
Definition: pns_tool_base.h:68
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:66
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:334
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:71
const VECTOR2D Position() const
Returns mouse cursor position in world coordinates.
Definition: tool_event.h:271
const LAYER_RANGE & Layers() const
Definition: pns_item.h:150
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::GetTopLayer(), TOOL_BASE::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, MD_ALT, MD_SHIFT, TOOL_EVENT::Modifier(), LAYER_RANGE::Overlaps(), PNS::TOOL_BASE::pickSingleItem(), TOOL_EVENT::Position(), GRID_HELPER::SetSnap(), GRID_HELPER::SetUseGrid(), and PNS::TOOL_BASE::snapToItem().

Referenced by 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(), 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(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::Move(), POINT_EDITOR::OnSelectionChange(), performDragging(), performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickCopyReferencePoint(), 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

Definition at line 80 of file pns_tool_base.h.

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

◆ m_editModules

◆ m_endItem

◆ m_endSnapPoint

VECTOR2I PNS::TOOL_BASE::m_endSnapPoint
protectedinherited

◆ m_gridHelper

◆ m_iface

PNS_KICAD_IFACE* PNS::TOOL_BASE::m_iface
protectedinherited

◆ 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(), PICKER_TOOL::Init(), SCH_EDIT_TOOL::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init(), PL_EDIT_TOOL::Init(), LIB_DRAWING_TOOLS::Init(), MODULE_EDITOR_TOOLS::Init(), PL_DRAWING_TOOLS::Init(), LIB_CONTROL::Init(), PCB_EDITOR_CONTROL::Init(), SCH_DRAWING_TOOLS::Init(), GERBVIEW_SELECTION_TOOL::Init(), DRAWING_TOOL::Init(), PL_SELECTION_TOOL::Init(), EE_SELECTION_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), SELECTION_TOOL::Init(), EDIT_TOOL::Init(), PCB_TOOL_BASE::Init(), PL_EDIT_TOOL::Main(), SCH_MOVE_TOOL::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), 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_panelItems

MSG_PANEL_ITEMS PNS::TOOL_BASE::m_panelItems
protectedinherited

Definition at line 64 of file pns_tool_base.h.

◆ m_router

◆ m_savedSettings

ROUTING_SETTINGS PNS::TOOL_BASE::m_savedSettings
protectedinherited

Stores routing settings between router invocations.

Definition at line 66 of file pns_tool_base.h.

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

◆ m_savedSizes

SIZES_SETTINGS PNS::TOOL_BASE::m_savedSizes
protectedinherited

Stores sizes settings between router invocations.

Definition at line 67 of file pns_tool_base.h.

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

◆ m_startHighlight

bool PNS::TOOL_BASE::m_startHighlight
protectedinherited

Keeps track of whether the net was highlighted before routing.

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_startLayer

int PNS::TOOL_BASE::m_startLayer
protectedinherited

Definition at line 69 of file pns_tool_base.h.

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

◆ 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(), EE_SELECTION_TOOL::AddItemToSel(), SELECTION_TOOL::AddItemToSel(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), CanInlineDrag(), PCB_INSPECTION_TOOL::ClearHighlight(), SCH_EDITOR_CONTROL::ClearHighlight(), PL_SELECTION_TOOL::ClearSelection(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::ClearSelection(), SELECTION_TOOL::clearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), LIB_EDIT_TOOL::Copy(), PL_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), COMMON_TOOLS::CursorControl(), CustomTrackWidthDialog(), 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(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), 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::editComponentFieldText(), EDIT_TOOL::EditFpInFpEditor(), LIB_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithLibEdit(), SCH_EDITOR_CONTROL::EnterSheet(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::findCallback(), SCH_EDITOR_CONTROL::FindComponentAndItem(), POINT_EDITOR::finishItem(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), EDIT_TOOL::GetAndPlace(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), 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(), MODULE_EDITOR_TOOLS::ImportFootprint(), PL_EDIT_TOOL::ImportWorksheetContent(), LIB_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), PL_EDIT_TOOL::Init(), PAD_TOOL::Init(), GLOBAL_EDIT_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PL_DRAWING_TOOLS::Init(), LIB_CONTROL::Init(), PL_POINT_EDITOR::Init(), POINT_EDITOR::Init(), PCB_EDITOR_CONTROL::Init(), POSITION_RELATIVE_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), EDIT_TOOL::Init(), InlineBreakTrack(), InlineDrag(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), TOOL_BASE::IsToolActive(), SCH_EDITOR_CONTROL::LeaveSheet(), COMMON_CONTROL::ListHotKeys(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PL_EDIT_TOOL::Main(), SCH_MOVE_TOOL::Main(), CVPCB_CONTROL::Main(), LIB_MOVE_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::Move(), EDIT_TOOL::MoveExact(), LIB_CONTROL::OnDeMorgan(), LIB_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), EDIT_TOOL::pickCopyReferencePoint(), 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(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), PL_SELECTION_TOOL::RemoveItemFromSel(), EE_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::ResetLocalCoords(), TOOL_INTERACTIVE::resetTransitions(), LIB_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), DRC::RunTests(), EE_SELECTION_TOOL::SelectConnection(), SELECTION_TOOL::selectCopper(), 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(), DRC::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), LIB_EDIT_TOOL::Undo(), SCH_EDITOR_CONTROL::Undo(), SCH_LINE_WIRE_BUS_TOOL::UnfoldBus(), GERBVIEW_SELECTION_TOOL::UnselectItem(), SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PL_EDITOR_CONTROL::UpdateMessagePanel(), PCBNEW_CONTROL::UpdateMessagePanel(), PCB_INSPECTION_TOOL::UpdateSelectionRatsnest(), 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_toolSettings

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 220 of file tool_base.h.

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

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


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