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

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

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

Constructor & Destructor Documentation

◆ ROUTER_TOOL()

ROUTER_TOOL::ROUTER_TOOL ( )

Definition at line 159 of file router_tool.cpp.

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

◆ ~ROUTER_TOOL()

ROUTER_TOOL::~ROUTER_TOOL ( )

Definition at line 447 of file router_tool.cpp.

448 {
449 }

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:218
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:213
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(), 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(), 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(), SCH_MOVE_TOOL::Main(), EE_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(), 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 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:218

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ board()

BOARD* PCB_TOOL_BASE::board ( ) const
inlineprotectedinherited

Definition at line 155 of file pcb_tool_base.h.

155 { return getModel<BOARD>(); }

Referenced by PCBNEW_CONTROL::AppendBoard(), AUTOPLACE_TOOL::autoplace(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), EDIT_TOOL::ChangeTrackWidth(), ZONE_FILLER_TOOL::CheckAllZones(), DRC::checkClearancePadToPad(), DRC::checkClearanceSegmToPad(), PCB_INSPECTION_TOOL::ClearHighlight(), DRAWING_TOOL::constrainDimension(), 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(), PCB_INSPECTION_TOOL::highlightNet(), PCBNEW_CONTROL::LayerNext(), PCBNEW_CONTROL::LayerPrev(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PCB_TOOL_BASE::module(), PCBNEW_CONTROL::ModuleEdgeOutlines(), PCBNEW_CONTROL::ModuleTextOutlines(), 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::selectAllItemsOnNet(), SELECTION_TOOL::selectAllItemsOnSheet(), SELECTION_TOOL::selectConnectedTracks(), SELECTION_TOOL::selectPoint(), DRC::testDisabledLayers(), DRC::TestZoneToZoneOutlines(), PCBNEW_CONTROL::TrackDisplayMode(), POINT_EDITOR::updateItem(), 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 901 of file router_tool.cpp.

902 {
905 }
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:69
void BreakSegment(ITEM *aItem, const VECTOR2I &aP)
Definition: pns_router.cpp:567
ITEM * m_startItem
Definition: pns_tool_base.h:67
ROUTER * m_router
Definition: pns_tool_base.h:77
bool OfKind(int aKindMask) const
Function OfKind()
Definition: pns_item.h:133

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

1162 {
1164  const auto& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
1165 
1166  if( selection.Size() == 1 )
1167  {
1168  const BOARD_ITEM* item = static_cast<const BOARD_ITEM*>( selection.Front() );
1169 
1170  if( item->Type() == PCB_TRACE_T || item->Type() == PCB_VIA_T || item->Type() == PCB_MODULE_T )
1171  return true;
1172  }
1173 
1174  return false;
1175 }
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:218
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
class MODULE, a footprint
Definition: typeinfo.h:89
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:126
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:70
EDA_ITEM * Front() const
Definition: selection.h:183
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212

References SELECTION::Front(), TOOL_MANAGER::GetTool(), TOOL_BASE::m_toolMgr, NeighboringSegmentFilter(), PCB_MODULE_T, 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 248 of file pns_tool_base.cpp.

249 {
250  // Sync PNS engine settings with the general PCB editor options.
251  auto& pnss = m_router->Settings();
252 
253  pnss.SetSnapToPads(
254  frame()->Settings().m_MagneticPads == MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL ||
255  frame()->Settings().m_MagneticPads == MAGNETIC_OPTIONS::CAPTURE_ALWAYS );
256 
257  pnss.SetSnapToTracks(
258  frame()->Settings().m_MagneticTracks == MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL
259  || frame()->Settings().m_MagneticTracks == MAGNETIC_OPTIONS::CAPTURE_ALWAYS );
260 
261  if( aItem )
262  {
263  if( aItem->OfKind( ITEM::VIA_T | ITEM::SEGMENT_T | ITEM::ARC_T ) )
264  return pnss.GetSnapToTracks();
265  else if( aItem->OfKind( ITEM::SOLID_T ) )
266  return pnss.GetSnapToPads();
267  }
268 
269  return false;
270 }
PCB_BASE_EDIT_FRAME * frame() const
ROUTER * m_router
Definition: pns_tool_base.h:77
void SetSnapToPads(bool aSnap)
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:199

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

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

◆ controls()

◆ CustomTrackWidthDialog()

int ROUTER_TOOL::CustomTrackWidthDialog ( const TOOL_EVENT aEvent)

Definition at line 1327 of file router_tool.cpp.

1328 {
1330  DIALOG_TRACK_VIA_SIZE sizeDlg( frame(), bds );
1331 
1332  if( sizeDlg.ShowModal() )
1333  {
1334  bds.UseCustomTrackViaSize( true );
1336  }
1337 
1338  return 0;
1339 }
BOARD * board() const
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:218
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:287
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:512
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.
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 363 of file pns_tool_base.cpp.

364 {
365  NODE *node = m_router->GetWorld()->Branch();
366 
367  if( !aStartItem )
368  return;
369 
370  if( !aWholeTrack )
371  {
372  node->Remove( aStartItem );
373  }
374  else
375  {
376  TOPOLOGY topo( node );
377  ITEM_SET path = topo.AssembleTrivialPath( aStartItem );
378 
379  for( const auto& ent : path.Items() )
380  node->Remove( ent.item );
381  }
382 
383  m_router->CommitRouting( node );
384 }
void CommitRouting()
Definition: pns_router.cpp:422
NODE * Branch()
Function Branch()
Definition: pns_node.cpp:106
void Remove(ARC *aArc)
Function Remove()
Definition: pns_node.cpp:796
ROUTER * m_router
Definition: pns_tool_base.h:77
std::unordered_set< SCH_ITEM * > ITEM_SET
Definition: sch_item.h:138
NODE * GetWorld() const
Definition: pns_router.h:152

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

40 {
41  using namespace std::placeholders;
42  std::unique_ptr<BOARD_ITEM> newItem;
43 
44  frame()->PushTool( aTool );
45  Activate();
46 
47  BOARD_COMMIT commit( frame() );
48 
50 
51  // do not capture or auto-pan until we start placing an item
52  controls()->ShowCursor( true );
53  controls()->SetSnapping( true );
54 
55  // Add a VIEW_GROUP that serves as a preview for the new item
56  PCBNEW_SELECTION preview;
57  view()->Add( &preview );
58 
59  aPlacer->m_board = board();
60  aPlacer->m_frame = frame();
61  aPlacer->m_modifiers = 0;
62 
63  auto makeNewItem = [&] ( VECTOR2I aPosition )
64  {
65  if( frame()->GetModel() )
66  newItem = aPlacer->CreateItem();
67 
68  if( newItem )
69  {
70  newItem->SetPosition( (wxPoint) aPosition );
71  preview.Add( newItem.get() );
72 
73  if( newItem->Type() == PCB_MODULE_T )
74  {
75  auto module = dyn_cast<MODULE*>( newItem.get() );
76 
77  // modules have more drawable parts
78  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
79  }
80  }
81  };
82 
83  if( aOptions & IPO_SINGLE_CLICK )
84  makeNewItem( controls()->GetCursorPosition() );
85 
86  // Main loop: keep receiving events
87  while( TOOL_EVENT* evt = Wait() )
88  {
89  VECTOR2I cursorPos = controls()->GetCursorPosition();
90  aPlacer->m_modifiers = evt->Modifier();
91 
92  auto cleanup = [&] ()
93  {
94  newItem = nullptr;
95  preview.Clear();
96  view()->Update( &preview );
97  controls()->SetAutoPan( false );
98  controls()->CaptureCursor( false );
99  controls()->ShowCursor( true );
100  };
101 
102  if( evt->IsCancelInteractive() )
103  {
104  if( aOptions & IPO_SINGLE_CLICK )
105  {
106  cleanup();
107  frame()->PopTool( aTool );
108  break;
109  }
110  else if( newItem )
111  cleanup();
112  else
113  {
114  frame()->PopTool( aTool );
115  break;
116  }
117  }
118  else if( evt->IsActivate() )
119  {
120  if( newItem )
121  cleanup();
122 
123  if( evt->IsPointEditor() )
124  {
125  // don't exit (the point editor runs in the background)
126  }
127  else if( evt->IsMoveTool() )
128  {
129  // leave ourselves on the stack so we come back after the move
130  break;
131  }
132  else
133  {
134  frame()->PopTool( aTool );
135  break;
136  }
137  }
138  else if( evt->IsClick( BUT_LEFT ) )
139  {
140  if( !newItem )
141  {
142  // create the item if possible
143  makeNewItem( cursorPos );
144 
145  // no item created, so wait for another click
146  if( !newItem )
147  continue;
148 
149  controls()->CaptureCursor( true );
150  controls()->SetAutoPan( true );
151  }
152  else
153  {
154  auto oldFlags = newItem->GetFlags();
155  newItem->ClearFlags();
156 
157  if( !aPlacer->PlaceItem( newItem.get(), commit ) )
158  {
159  newItem->SetFlags( oldFlags );
160  continue;
161  }
162 
163  preview.Clear();
164  newItem.release();
165  commit.Push( aCommitMessage );
166 
167  controls()->CaptureCursor( false );
168  controls()->SetAutoPan( false );
169  controls()->ShowCursor( true );
170 
171  if( !( aOptions & IPO_REPEAT ) )
172  break;
173 
174  if( aOptions & IPO_SINGLE_CLICK )
175  makeNewItem( controls()->GetCursorPosition() );
176  }
177  }
178  else if( evt->IsClick( BUT_RIGHT ) )
179  {
181  }
182  else if( newItem && evt->Category() == TC_COMMAND )
183  {
184  /*
185  * Handle any events that can affect the item as we move it around
186  */
187  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
188  {
189  const int rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
190  newItem->Rotate( newItem->GetPosition(), rotationAngle );
191  view()->Update( &preview );
192  }
193  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
194  {
195  newItem->Flip( newItem->GetPosition(), frame()->Settings().m_FlipLeftRight );
196  view()->Update( &preview );
197  }
198  else if( evt->IsAction( &PCB_ACTIONS::viaSizeInc )
199  || evt->IsAction( &PCB_ACTIONS::viaSizeDec ) )
200  {
201  // Refresh preview after event runs
203  }
204  else if( evt->IsAction( &ACTIONS::refreshPreview ) )
205  {
206  preview.Clear();
207  newItem.release();
208 
209  makeNewItem( controls()->GetCursorPosition() );
210  view()->Update( &preview );
211  }
212  }
213 
214  else if( newItem && evt->IsMotion() )
215  {
216  // track the cursor
217  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
218  aPlacer->SnapItem( newItem.get() );
219 
220  // Show a preview of the item
221  view()->Update( &preview );
222  }
223 
224  else
225  evt->SetPassEvent();
226  }
227 
228  view()->Remove( &preview );
229 }
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:94
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
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:284
virtual std::unique_ptr< BOARD_ITEM > CreateItem()=0
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:218
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:139
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:75
TOOL_MANAGER * GetManager() const
Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool.
Definition: tool_base.h:142
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.
TOOL_EVENT.
Definition: tool_event.h:171
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:111
KIGFX::VIEW_CONTROLS * controls() const
MODULE * module() const
PCBNEW_SETTINGS & Settings()
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:62
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:285
static TOOL_ACTION refreshPreview
Definition: actions.h:101
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, PCBNEW_SETTINGS::m_FlipLeftRight, INTERACTIVE_PLACER_BASE::m_frame, TOOL_INTERACTIVE::m_menu, INTERACTIVE_PLACER_BASE::m_modifiers, TOOL_BASE::m_toolMgr, PCB_TOOL_BASE::module(), PCB_MODULE_T, INTERACTIVE_PLACER_BASE::PlaceItem(), EDA_BASE_FRAME::PopTool(), BOARD_COMMIT::Push(), EDA_BASE_FRAME::PushTool(), ACTIONS::refreshPreview, 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_ACTIONS::viaSizeDec, PCB_ACTIONS::viaSizeInc, 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 871 of file router_tool.cpp.

872 {
874  DIALOG_PNS_DIFF_PAIR_DIMENSIONS settingsDlg( frame(), sizes );
875 
876  if( settingsDlg.ShowModal() == wxID_OK )
877  {
878  m_router->UpdateSizes( sizes );
879  m_savedSizes = sizes;
880 
882  bds.SetCustomDiffPairWidth( sizes.DiffPairWidth() );
883  bds.SetCustomDiffPairGap( sizes.DiffPairGap() );
885  }
886 
887  return 0;
888 }
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:66
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:512
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:218
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:77
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:332
BOARD * GetBoard() const
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.

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

Referenced by setTransitions().

◆ EditingModules()

bool PCB_TOOL_BASE::EditingModules ( ) const
inlineinherited

◆ finishInteractive()

bool ROUTER_TOOL::finishInteractive ( )
private

Definition at line 756 of file router_tool.cpp.

757 {
759 
760  controls()->SetAutoPan( false );
761  controls()->ForceCursorPosition( false );
762  frame()->UndoRedoBlock( false );
763  highlightNet( false );
764 
765  return true;
766 }
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:77
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:431
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 150 of file pcb_tool_base.h.

151  {
152  return getEditFrame<PCB_BASE_EDIT_FRAME>();
153  }

Referenced by POINT_EDITOR::addCorner(), MICROWAVE_TOOL::addMicrowaveFootprint(), AUTOPLACE_TOOL::autoplace(), PCB_TOOL_BASE::canvas(), 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(), SELECTION_TOOL::Init(), EDIT_TOOL::Init(), InlineBreakTrack(), InlineDrag(), 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(), PCB_EDITOR_CONTROL::UpdateSchematicFromPCB(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillAll().

◆ getEditFrame()

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

Function getEditFrame()

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

Definition at line 186 of file tool_base.h.

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

References TOOL_BASE::getEditFrameInt().

Referenced by ZONE_CREATE_HELPER::createNewZone().

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

Function GetId() Returns the unique identifier of the tool.

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 120 of file tool_base.h.

121  {
122  return m_toolId;
123  }
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:213

References TOOL_BASE::m_toolId.

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

◆ GetManager()

TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

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

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

Definition at line 142 of file tool_base.h.

143  {
144  return m_toolMgr;
145  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:218

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

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

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

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

References TOOL_BASE::m_toolName.

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

◆ getStartLayer()

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

Definition at line 482 of file router_tool.cpp.

483 {
484  int tl = getView()->GetTopLayer();
485 
486  if( m_startItem )
487  {
488  const LAYER_RANGE& ls = m_startItem->Layers();
489 
490  if( ls.Overlaps( tl ) )
491  return tl;
492  else
493  return ls.Start();
494  }
495 
496  return tl;
497 }
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:67
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
LAYER_RANGE.
Definition: pns_layerset.h:32
const LAYER_RANGE & Layers() const
Definition: pns_item.h:151

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

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

References TOOL_BASE::m_type.

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

◆ getView()

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

Function getView()

Returns the instance of VIEW object used in the application. It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 36 of file tool_base.cpp.

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

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(), EE_SELECTION_TOOL::ClearSelection(), COMMON_TOOLS::CursorControl(), LIB_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), 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(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCB_INSPECTION_TOOL::highlightNet(), EE_POINT_EDITOR::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), LIB_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PNS::TOOL_BASE::pickSingleItem(), 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(), EE_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), COMMON_TOOLS::ToggleGrid(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), SCH_EDITOR_CONTROL::UpdateFind(), PCBNEW_CONTROL::updateGrid(), EE_POINT_EDITOR::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_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:218
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:285

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(), 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(), SCH_MOVE_TOOL::Main(), EE_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(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::RepeatDrawItem(), EE_SELECTION_TOOL::RequestSelection(), POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), 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(), POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), LIB_MOVE_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:57
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(), ZONE_FILLER_TOOL::setTransitions(), LIB_DRAWING_TOOLS::setTransitions(), EE_POINT_EDITOR::setTransitions(), COMMON_CONTROL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), LIB_MOVE_TOOL::setTransitions(), GERBVIEW_CONTROL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), POINT_EDITOR::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), EDA_3D_VIEWER_CONTROL::setTransitions(), LIB_EDIT_TOOL::setTransitions(), LIB_CONTROL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), PCB_INSPECTION_TOOL::setTransitions(), PCBNEW_CONTROL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), SCH_LINE_WIRE_BUS_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(), DRC::setTransitions(), and EE_SELECTION_TOOL::setTransitions().

◆ handleCommonEvents()

void ROUTER_TOOL::handleCommonEvents ( const TOOL_EVENT evt)
private

Definition at line 465 of file router_tool.cpp.

466 {
467 #ifdef DEBUG
468  if( aEvent.IsKeyPressed() )
469  {
470  switch( aEvent.KeyCode() )
471  {
472  case '0':
473  wxLogTrace( "PNS", "saving drag/route log...\n" );
474  m_router->DumpLog();
475  break;
476  }
477  }
478 #endif
479 }
ROUTER * m_router
Definition: pns_tool_base.h:77
void DumpLog()
Definition: pns_router.cpp:508

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

226 {
228 
229  if( aNetcode >= 0 && aEnabled )
230  {
231  // If the user has previously set the current net to be highlighted,
232  // we assume they want to keep it highlighted after routing
233  m_startHighlight = ( rs->IsHighlightEnabled() && rs->GetHighlightNetCode() == aNetcode );
234 
235  rs->SetHighlight( true, aNetcode );
236  }
237  else
238  {
239  if( !m_startHighlight )
240  rs->SetHighlight( false );
241 
242  m_startHighlight = false;
243  }
244 
246 }
RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output surfac...
Definition: painter.h:56
bool m_startHighlight
Keeps track of whether the net was highlighted before routing.
Definition: pns_tool_base.h:70
bool IsHighlightEnabled() const
Function IsHighlightEnabled Returns current highlight setting.
Definition: painter.h:113
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:136
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:123
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 452 of file router_tool.cpp.

453 {
454  return true;
455 }

◆ InlineBreakTrack()

int ROUTER_TOOL::InlineBreakTrack ( const TOOL_EVENT aEvent)

Definition at line 1284 of file router_tool.cpp.

1285 {
1286  const auto& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
1287 
1288  if( selection.Size() != 1 )
1289  return 0;
1290 
1291  const BOARD_CONNECTED_ITEM* item = static_cast<const BOARD_CONNECTED_ITEM*>( selection.Front() );
1292 
1293  if( item->Type() != PCB_TRACE_T )
1294  return 0;
1295 
1296  Activate();
1297 
1299  m_router->SyncWorld();
1301  m_startSnapPoint = snapToItem( true, m_startItem, controls()->GetCursorPosition() );
1302 
1303 
1304  if( m_startItem && m_startItem->IsLocked() )
1305  {
1306  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1307  wxOK | wxCANCEL | wxICON_WARNING );
1308  dlg.SetOKLabel( _( "Break Track" ) );
1309  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1310 
1311  if( dlg.ShowModal() == wxID_CANCEL )
1312  return 0;
1313  }
1314 
1315  frame()->UndoRedoBlock( true );
1316  breakTrack();
1317 
1318  if( m_router->RoutingInProgress() )
1319  m_router->StopRouting();
1320 
1321  frame()->UndoRedoBlock( false );
1322 
1323  return 0;
1324 }
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:69
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:218
void SyncWorld()
Definition: pns_router.cpp:96
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
void breakTrack()
BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected and have...
const VECTOR2I snapToItem(bool aEnabled, ITEM *aItem, VECTOR2I aP)
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
PCB_BASE_EDIT_FRAME * frame() const
#define _(s)
const PCBNEW_SELECTION & selection() const
ITEM * m_startItem
Definition: pns_tool_base.h:67
ROUTER * m_router
Definition: pns_tool_base.h:77
void StopRouting()
Definition: pns_router.cpp:431
KIGFX::VIEW_CONTROLS * controls() const
int Size() const
Returns the number of selected parts.
Definition: selection.h:126
bool IsLocked() const
Definition: pns_item.h:236
ITEM * FindItemByParent(const BOARD_CONNECTED_ITEM *aParent)
Definition: pns_node.cpp:1443
void Activate()
Function Activate() Runs the tool.
bool RoutingInProgress() const
Definition: pns_router.cpp:117
NODE * GetWorld() const
Definition: pns_router.h:152
EDA_ITEM * Front() const
Definition: selection.h:183
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212

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(), 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 1178 of file router_tool.cpp.

1179 {
1180  const auto& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
1181 
1182  if( selection.Empty() )
1184 
1185  if( selection.Size() != 1 )
1186  return 0;
1187 
1188  const BOARD_ITEM* item = static_cast<const BOARD_ITEM*>( selection.Front() );
1189 
1190  if( item->Type() != PCB_TRACE_T && item->Type() != PCB_VIA_T && item->Type() != PCB_MODULE_T )
1191  return 0;
1192 
1193  Activate();
1194 
1196  m_router->SyncWorld();
1197  m_startItem = nullptr;
1198 
1199  PNS::ITEM* startItem = nullptr;
1200  PNS::ITEM_SET itemsToDrag;
1201 
1202  if( item->Type() == PCB_MODULE_T )
1203  {
1204  const auto mod = static_cast<const MODULE*>(item);
1205  for ( const auto p : mod->Pads() )
1206  {
1207  auto solid = m_router->GetWorld()->FindItemByParent( p );
1208 
1209  if( solid )
1210  itemsToDrag.Add( solid );
1211  }
1212  }
1213  else
1214  {
1215  startItem = m_router->GetWorld()->FindItemByParent( static_cast<const BOARD_CONNECTED_ITEM*>( item ) );
1216 
1217  if( startItem)
1218  itemsToDrag.Add( startItem );
1219  }
1220 
1221  if( startItem && startItem->IsLocked() )
1222  {
1223  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1224  wxOK | wxCANCEL | wxICON_WARNING );
1225  dlg.SetOKLabel( _( "Drag Anyway" ) );
1226  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1227 
1228  if( dlg.ShowModal() == wxID_CANCEL )
1229  return 0;
1230  }
1231 
1232  VECTOR2I p0 = controls()->GetCursorPosition( false );
1233  VECTOR2I p = p0;
1234 
1235  if( startItem )
1236  p = snapToItem( true, startItem, p0 );
1237 
1238  int dragMode = aEvent.Parameter<int64_t> ();
1239 
1240  bool dragStarted = m_router->StartDragging( p, itemsToDrag, dragMode );
1241 
1242  if( !dragStarted )
1243  return 0;
1244 
1245  m_gridHelper->SetAuxAxes( true, p );
1246  controls()->ShowCursor( true );
1247  controls()->ForceCursorPosition( false );
1248  controls()->SetAutoPan( true );
1249  frame()->UndoRedoBlock( true );
1250 
1251  while( TOOL_EVENT* evt = Wait() )
1252  {
1253  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
1254 
1255  if( evt->IsCancelInteractive() )
1256  {
1257  break;
1258  }
1259  else if( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
1260  {
1261  updateEndItem( *evt );
1263  }
1264  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
1265  {
1266  updateEndItem( *evt );
1268  break;
1269  }
1270  }
1271 
1272  if( m_router->RoutingInProgress() )
1273  m_router->StopRouting();
1274 
1275  m_gridHelper->SetAuxAxes( false );
1276  controls()->SetAutoPan( false );
1277  controls()->ForceCursorPosition( false );
1278  frame()->UndoRedoBlock( false );
1279 
1280  return 0;
1281 }
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.
ITEM.
Definition: pns_item.h:53
GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:75
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:44
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
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:218
void SyncWorld()
Definition: pns_router.cpp:96
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
void Add(const LINE &aLine)
Definition: pns_itemset.cpp:32
const VECTOR2I snapToItem(bool aEnabled, ITEM *aItem, VECTOR2I aP)
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
PCB_BASE_EDIT_FRAME * frame() const
class MODULE, a footprint
Definition: typeinfo.h:89
virtual void updateEndItem(const TOOL_EVENT &aEvent)
void SetAuxAxes(bool aEnable, const VECTOR2I &aOrigin=VECTOR2I(0, 0))
#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:435
TOOL_EVENT.
Definition: tool_event.h:171
ITEM * m_startItem
Definition: pns_tool_base.h:67
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:391
ROUTER * m_router
Definition: pns_tool_base.h:77
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:246
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:120
void StopRouting()
Definition: pns_router.cpp:431
KIGFX::VIEW_CONTROLS * controls() const
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:73
bool StartDragging(const VECTOR2I &aP, ITEM *aItem, int aDragMode=DM_ANY)
Definition: pns_router.cpp:131
static void NeighboringSegmentFilter(const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector)
int Size() const
Returns the number of selected parts.
Definition: selection.h:126
bool IsLocked() const
Definition: pns_item.h:236
ITEM * FindItemByParent(const BOARD_CONNECTED_ITEM *aParent)
Definition: pns_node.cpp:1443
void Activate()
Function Activate() Runs the tool.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
bool RoutingInProgress() const
Definition: pns_router.cpp:117
NODE * GetWorld() const
Definition: pns_router.h:152
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:183
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212

References _, TOOL_INTERACTIVE::Activate(), PNS::ITEM_SET::Add(), 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_MODULE_T, 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:218
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:213
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 908 of file router_tool.cpp.

909 {
911  PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
912 
913  // Deselect all items
915 
916  std::string tool = aEvent.GetCommandStr().get();
917  frame->PushTool( tool );
918  Activate();
919 
920  m_router->SetMode( mode );
921 
922  VIEW_CONTROLS* ctls = getViewControls();
923  ctls->ShowCursor( true );
924  ctls->ForceCursorPosition( false );
925  m_cancelled = false;
927 
928  std::unique_ptr<ROUTER_TOOL_MENU> ctxMenu( new ROUTER_TOOL_MENU( *frame, mode ) );
929  SetContextMenu( ctxMenu.get() );
930 
931  // Prime the pump
932  if( aEvent.HasPosition() )
934 
935  // Main loop: keep receiving events
936  while( TOOL_EVENT* evt = Wait() )
937  {
938  frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
939 
940  if( evt->IsCancelInteractive() )
941  {
942  frame->PopTool( tool );
943  break;
944  }
945  else if( evt->IsActivate() )
946  {
947  if( evt->IsMoveTool() )
948  {
949  // leave ourselves on the stack so we come back after the move
950  break;
951  }
952  else
953  {
954  frame->PopTool( tool );
955  break;
956  }
957  }
958  else if( evt->Action() == TA_UNDO_REDO_PRE )
959  {
960  m_router->ClearWorld();
961  }
962  else if( evt->Action() == TA_UNDO_REDO_POST || evt->Action() == TA_MODEL_CHANGE )
963  {
964  m_router->SyncWorld();
965  }
966  else if( evt->IsMotion() )
967  {
968  updateStartItem( *evt );
969  }
970  else if( evt->IsAction( &PCB_ACTIONS::dragFreeAngle ) )
971  {
972  updateStartItem( *evt, true );
974  }
975  else if( evt->IsAction( &PCB_ACTIONS::drag45Degree ) )
976  {
977  updateStartItem( *evt, true );
979  }
980  else if( evt->IsAction( &PCB_ACTIONS::breakTrack ) )
981  {
982  updateStartItem( *evt, true );
983  breakTrack( );
984  }
985  else if( evt->IsClick( BUT_LEFT )
986  || evt->IsAction( &PCB_ACTIONS::routeSingleTrack )
987  || evt->IsAction( &PCB_ACTIONS::routeDiffPair ) )
988  {
989  if( evt->IsAction( &PCB_ACTIONS::routeSingleTrack )
990  || evt->IsAction( &PCB_ACTIONS::routeDiffPair ) )
991  {
992  mode = evt->Parameter<PNS::ROUTER_MODE>();
993  }
994 
995  updateStartItem( *evt );
996 
997  if( evt->HasPosition() )
998  {
999  if( evt->Modifier( MD_CTRL ) )
1001  else
1002  performRouting();
1003  }
1004  }
1005  else if( evt->IsAction( &ACT_PlaceThroughVia ) )
1006  {
1008  }
1009  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1010  {
1012  updateStartItem( *evt );
1013  }
1014  else if( evt->IsKeyPressed() )
1015  {
1016  // wxWidgets fails to correctly translate shifted keycodes on the wxEVT_CHAR_HOOK
1017  // event so we need to process the wxEVT_CHAR event that will follow as long as we
1018  // pass the event.
1019  evt->SetPassEvent();
1020  }
1021 
1022  if( m_cancelled )
1023  {
1024  frame->PopTool( tool );
1025  break;
1026  }
1027  }
1028 
1029  SetContextMenu( nullptr );
1030 
1031  // Store routing settings till the next invocation
1033 
1034  return 0;
1035 }
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:69
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:144
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:218
SIZES_SETTINGS m_savedSizes
Stores sizes settings between router invocations.
Definition: pns_tool_base.h:66
void SyncWorld()
Definition: pns_router.cpp:96
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:139
void PrimeTool(const VECTOR2D &aPosition)
Function PrimeTool() "Primes" a tool by sending a cursor left-click event with the mouse position set...
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:143
void SetContextMenu(ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
Function SetContextMenu()
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:218
void SwitchLayer(int layer)
Definition: pns_router.cpp:468
void breakTrack()
void ClearWorld()
Definition: pns_router.cpp:105
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:435
TOOL_EVENT.
Definition: tool_event.h:171
ROUTER * m_router
Definition: pns_tool_base.h:77
VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (such a...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
static TOOL_ACTION breakTrack
Break a single track into two segments at the cursor.
Definition: pcb_actions.h:138
static const TOOL_ACTION ACT_PlaceThroughVia("pcbnew.InteractiveRouter.PlaceVia", AS_CONTEXT, 'V', LEGACY_HK_NAME("Add Through Via"), _("Place Through Via"), _("Adds a through-hole via at the end of currently routed track."), via_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::VIA)
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
ROUTER_MODE
Definition: pns_router.h:67
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:277
void SetMode(ROUTER_MODE aMode)
Definition: pns_router.cpp:555
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:178
void performDragging(int aMode=PNS::DM_ANY)
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:260
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:275
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:181

References ACT_PlaceThroughVia, TOOL_INTERACTIVE::Activate(), breakTrack(), PCB_ACTIONS::breakTrack, BUT_LEFT, PNS::ROUTER::ClearWorld(), PNS::DM_ANY, PNS::DM_FREE_ANGLE, PCB_ACTIONS::drag45Degree, PCB_ACTIONS::dragFreeAngle, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_BASE::getViewControls(), TOOL_EVENT::HasPosition(), PCB_ACTIONS::layerChanged, PCB_ACTIONS::layerToggle, PNS::TOOL_BASE::m_cancelled, PNS::TOOL_BASE::m_router, 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(), TOOL_MANAGER::PrimeTool(), 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(), 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 1106 of file router_tool.cpp.

1107 {
1108  /*
1109  * If the collection contains a trivial line corner (two connected segments)
1110  * or a non-fanout-via (a via with no more than two connected segments), then
1111  * trim the collection down to a single item (which one won't matter since
1112  * they're all connected).
1113  */
1114 
1115  // First make sure we've got something that *might* match.
1116  int vias = aCollector.CountType( PCB_VIA_T );
1117  int traces = aCollector.CountType( PCB_TRACE_T );
1118  int arcs = aCollector.CountType( PCB_ARC_T );
1119 
1120  if( arcs > 0 || vias > 1 || traces > 2 || vias + traces < 1 )
1121  return;
1122 
1123  // Fetch first TRACK (via or trace) as our reference
1124  TRACK* reference = nullptr;
1125 
1126  for( int i = 0; !reference && i < aCollector.GetCount(); i++ )
1127  reference = dynamic_cast<TRACK*>( aCollector[i] );
1128 
1129  int refNet = reference->GetNetCode();
1130 
1131  wxPoint refPoint( aPt.x, aPt.y );
1132  STATUS_FLAGS flags = reference->IsPointOnEnds( refPoint, -1 );
1133 
1134  if( flags & STARTPOINT )
1135  refPoint = reference->GetStart();
1136  else if( flags & ENDPOINT )
1137  refPoint = reference->GetEnd();
1138 
1139  // Check all items to ensure that any TRACKs are co-terminus with the reference and on
1140  // the same net.
1141  for( int i = 0; i < aCollector.GetCount(); i++ )
1142  {
1143  TRACK* neighbor = dynamic_cast<TRACK*>( aCollector[i] );
1144 
1145  if( neighbor && neighbor != reference )
1146  {
1147  if( neighbor->GetNetCode() != refNet )
1148  return;
1149 
1150  if( neighbor->GetStart() != refPoint && neighbor->GetEnd() != refPoint )
1151  return;
1152  }
1153  }
1154 
1155  // Selection meets criteria; trim it to the reference item.
1156  aCollector.Empty();
1157  aCollector.Append( reference );
1158 }
void Empty()
Function Empty sets the list to empty.
Definition: collector.h:109
int GetNetCode() const
Function GetNetCode.
const wxPoint & GetStart() const
Definition: class_track.h:111
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
int CountType(KICAD_T aType)
Function CountType counts the number of items matching aType.
Definition: collector.h:216
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
void Append(EDA_ITEM *item)
Function Append adds an item to the end of the list.
Definition: collector.h:119
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:100
unsigned STATUS_FLAGS
Definition: base_struct.h:159
STATUS_FLAGS IsPointOnEnds(const wxPoint &point, int min_dist=0) const
Function IsPointOnEnds returns STARTPOINT if point if near (dist = min_dist) start point,...
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:126
const wxPoint & GetEnd() const
Definition: class_track.h:108
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
#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(), TRACK::IsPointOnEnds(), PCB_ARC_T, PCB_TRACE_T, PCB_VIA_T, STARTPOINT, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by CanInlineDrag(), and InlineDrag().

◆ onTrackViaSizeChanged()

int ROUTER_TOOL::onTrackViaSizeChanged ( const TOOL_EVENT aEvent)
private

Definition at line 1342 of file router_tool.cpp.

1343 {
1344  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
1345  sizes.ImportCurrent( board()->GetDesignSettings() );
1346  m_router->UpdateSizes( sizes );
1347 
1348  // Changing the track width can affect the placement, so call the
1349  // move routine without changing the destination
1351 
1352  return 0;
1353 }
BOARD * board() const
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:218
ROUTER * m_router
Definition: pns_tool_base.h:77
void ImportCurrent(BOARD_DESIGN_SETTINGS &aSettings)
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:246
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:332
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:73

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

538 {
539  const int actViaFlags = aEvent.Parameter<intptr_t>();
540 
541  VIATYPE viaType = getViaTypeFromFlags( actViaFlags );
542  const bool selectLayer = actViaFlags & VIA_ACTION_FLAGS::SELECT_LAYER;
543 
545 
546  const int layerCount = bds.GetCopperLayerCount();
547  int currentLayer = m_router->GetCurrentLayer();
550 
552 
553  // ask the user for a target layer
554  PCB_LAYER_ID targetLayer = UNDEFINED_LAYER;
555 
556  if( selectLayer )
557  {
558  wxPoint dlgPosition = wxGetMousePosition();
559 
560  targetLayer = frame()->SelectLayer(
561  static_cast<PCB_LAYER_ID>( currentLayer ), LSET::AllNonCuMask(), dlgPosition );
562 
563  // Reset the cursor to the position where the event occured
564  controls()->SetCursorPosition( aEvent.HasPosition() ? aEvent.Position() : dlgPosition );
565  }
566 
567  // fixme: P&S supports more than one fixed layer pair. Update the dialog?
568  sizes.ClearLayerPairs();
569 
570  if( !m_router->IsPlacingVia() )
571  {
572  // Cannot place microvias or blind vias if not allowed (obvious)
573  if( ( viaType == VIATYPE::BLIND_BURIED ) && ( !bds.m_BlindBuriedViaAllowed ) )
574  {
575  DisplayError( frame(),
576  _( "Blind/buried vias have to be enabled in Board Setup > Design Rules > Constraints." ) );
577  return false;
578  }
579 
580  if( ( viaType == VIATYPE::MICROVIA ) && ( !bds.m_MicroViasAllowed ) )
581  {
582  DisplayError( frame(),
583  _( "Microvias have to be enabled in Board Setup > Design Rules > Constraints." ) );
584  return false;
585  }
586 
587  // Can only place through vias on 2-layer boards
588  if( ( viaType != VIATYPE::THROUGH ) && ( layerCount <= 2 ) )
589  {
590  DisplayError( frame(), _( "Only through vias are allowed on 2 layer boards." ) );
591  return false;
592  }
593 
594  // Can only place microvias if we're on an outer layer, or directly adjacent to one
595  if( ( viaType == VIATYPE::MICROVIA ) && ( currentLayer > In1_Cu )
596  && ( currentLayer < layerCount - 2 ) )
597  {
598  DisplayError( frame(), _( "Microvias can be placed only between the outer layers "
599  "(F.Cu/B.Cu) and the ones directly adjacent to them." ) );
600  return false;
601  }
602  }
603 
604  // Convert blind/buried via to a through hole one, if it goes through all layers
605  if( viaType == VIATYPE::BLIND_BURIED
606  && ( ( targetLayer == B_Cu && currentLayer == F_Cu )
607  || ( targetLayer == F_Cu && currentLayer == B_Cu ) ) )
608  {
609  viaType = VIATYPE::THROUGH;
610  }
611 
612  switch( viaType )
613  {
614  case VIATYPE::THROUGH:
615  sizes.SetViaDiameter( bds.GetCurrentViaSize() );
616  sizes.SetViaDrill( bds.GetCurrentViaDrill() );
617 
618  if( targetLayer != UNDEFINED_LAYER )
619  {
620  // go from the current layer to the chosen layer
621  sizes.AddLayerPair( currentLayer, targetLayer );
622  }
623  else
624  {
625  // use the default layer pair
626  sizes.AddLayerPair( pairTop, pairBottom );
627  }
628  break;
629 
630  case VIATYPE::MICROVIA:
631  sizes.SetViaDiameter( bds.GetCurrentMicroViaSize() );
632  sizes.SetViaDrill( bds.GetCurrentMicroViaDrill() );
633 
634  wxASSERT_MSG( !selectLayer,
635  "Unexpected select layer for microvia (microvia layers are implicit)" );
636 
637  if( currentLayer == F_Cu || currentLayer == In1_Cu )
638  {
639  // front-side microvia
640  sizes.AddLayerPair( F_Cu, In1_Cu );
641  }
642  else if( currentLayer == B_Cu || currentLayer == layerCount - 2 )
643  {
644  // back-side microvia
645  sizes.AddLayerPair( B_Cu, layerCount - 2 );
646  }
647  else
648  {
649  wxASSERT_MSG( false,
650  "Invalid layer pair for microvia (must be on or adjacent to an outer layer)" );
651  }
652  break;
653 
655  sizes.SetViaDiameter( bds.GetCurrentViaSize() );
656  sizes.SetViaDrill( bds.GetCurrentViaDrill() );
657 
658  if( targetLayer != UNDEFINED_LAYER )
659  {
660  // go directly to the user specified layer
661  sizes.AddLayerPair( currentLayer, targetLayer );
662  }
663  else
664  {
665  if( currentLayer == pairTop || currentLayer == pairBottom )
666  {
667  // the current layer is on the defined layer pair,
668  // swap to the other side
669  sizes.AddLayerPair( pairTop, pairBottom );
670  }
671  else
672  {
673  // the current layer is not part of the current layer pair,
674  // so fallback and swap to the top layer of the pair by default
675  sizes.AddLayerPair( pairTop, currentLayer );
676  }
677  }
678  break;
679 
680  default:
681  wxASSERT( false );
682  break;
683  }
684 
685  sizes.SetViaType( viaType );
686 
687  m_router->UpdateSizes( sizes );
689 
690  if( m_router->RoutingInProgress() )
691  updateEndItem( aEvent );
692  else
693  updateStartItem( aEvent );
694 
695  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
696 
697  return 0;
698 }
int GetCurrentMicroViaSize()
Function GetCurrentMicroViaSize.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
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:709
bool IsPlacingVia() const
Definition: pns_router.cpp:531
Microvia
Definition: router_tool.cpp:71
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:512
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Moves cursor to the requested position expressed in world coordinates.
void SetViaDrill(int aDrill)
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:218
void ToggleViaPlacement()
Definition: pns_router.cpp:481
PCB_BASE_EDIT_FRAME * frame() const
virtual void updateStartItem(const TOOL_EVENT &aEvent, bool aIgnorePads=false)
static VIATYPE getViaTypeFromFlags(int aFlags)
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:435
VIATYPE
Definition: class_track.h:62
ROUTER * m_router
Definition: pns_tool_base.h:77
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:246
void SetViaType(VIATYPE aViaType)
int GetCurrentViaSize() const
Function GetCurrentViaSize.
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:332
KIGFX::VIEW_CONTROLS * controls() const
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:73
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition: tool_event.h:260
void AddLayerPair(int aL1, int aL2)
bool m_MicroViasAllowed
true to allow micro vias
bool RoutingInProgress() const
Definition: pns_router.cpp:117
void SetViaDiameter(int aDiameter)
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:206
const VECTOR2D Position() const
Returns mouse cursor position in world coordinates.
Definition: tool_event.h:274
PCB_LAYER_ID m_Route_Layer_TOP
Definition: pcb_screen.h:45
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
int GetCurrentLayer() const
Definition: pns_router.cpp:500

References _, PNS::SIZES_SETTINGS::AddLayerPair(), LSET::AllNonCuMask(), B_Cu, BLIND_BURIED, PCB_TOOL_BASE::board(), PNS::SIZES_SETTINGS::ClearLayerPairs(), PCB_TOOL_BASE::controls(), 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(), TOOL_EVENT::HasPosition(), 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, MICROVIA, PNS::ROUTER::Move(), TOOL_EVENT::Parameter(), TOOL_EVENT::Position(), PNS::ROUTER::RoutingInProgress(), SELECT_LAYER, PCB_BASE_FRAME::SelectLayer(), KIGFX::VIEW_CONTROLS::SetCursorPosition(), PNS::SIZES_SETTINGS::SetViaDiameter(), PNS::SIZES_SETTINGS::SetViaDrill(), PNS::SIZES_SETTINGS::SetViaType(), PNS::ROUTER::Sizes(), THROUGH, PNS::ROUTER::ToggleViaPlacement(), UNDEFINED_LAYER, PNS::TOOL_BASE::updateEndItem(), PNS::ROUTER::UpdateSizes(), and PNS::TOOL_BASE::updateStartItem().

Referenced by setTransitions().

◆ performDragging()

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

Definition at line 1038 of file router_tool.cpp.

1039 {
1040  VIEW_CONTROLS* ctls = getViewControls();
1041 
1042  if( m_startItem && m_startItem->IsLocked() )
1043  {
1044  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1045  wxOK | wxCANCEL | wxICON_WARNING );
1046  dlg.SetOKLabel( _( "Drag Anyway" ) );
1047  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1048 
1049  if( dlg.ShowModal() == wxID_CANCEL )
1050  return;
1051  }
1052 
1053  bool dragStarted = m_router->StartDragging( m_startSnapPoint, m_startItem, aMode );
1054 
1055  if( !dragStarted )
1056  return;
1057 
1058  if( m_startItem && m_startItem->Net() >= 0 )
1059  highlightNet( true, m_startItem->Net() );
1060 
1061  ctls->SetAutoPan( true );
1063  frame()->UndoRedoBlock( true );
1064 
1065  while( TOOL_EVENT* evt = Wait() )
1066  {
1067  ctls->ForceCursorPosition( false );
1068 
1069  if( evt->IsMotion() )
1070  {
1071  updateEndItem( *evt );
1073  }
1074  else if( evt->IsClick( BUT_LEFT ) )
1075  {
1077  break;
1078  }
1079  else if( evt->IsCancelInteractive() || evt->IsActivate() || evt->IsUndoRedo() )
1080  {
1081  if( evt->IsCancelInteractive() && !m_startItem )
1082  m_cancelled = true;
1083 
1084  if( evt->IsActivate() && !evt->IsMoveTool() )
1085  m_cancelled = true;
1086 
1087  break;
1088  }
1089 
1090  handleCommonEvents( *evt );
1091  }
1092 
1093  if( m_router->RoutingInProgress() )
1094  m_router->StopRouting();
1095 
1096  m_startItem = nullptr;
1097 
1098  m_gridHelper->SetAuxAxes( false );
1099  frame()->UndoRedoBlock( false );
1100  ctls->SetAutoPan( false );
1101  ctls->ForceCursorPosition( false );
1102  highlightNet( false );
1103 }
GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:75
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:69
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
void handleCommonEvents(const TOOL_EVENT &evt)
PCB_BASE_EDIT_FRAME * frame() const
virtual void updateEndItem(const TOOL_EVENT &aEvent)
void SetAuxAxes(bool aEnable, const VECTOR2I &aOrigin=VECTOR2I(0, 0))
#define _(s)
int Net() const
Definition: pns_item.h:149
TOOL_EVENT.
Definition: tool_event.h:171
ITEM * m_startItem
Definition: pns_tool_base.h:67
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:391
ROUTER * m_router
Definition: pns_tool_base.h:77
VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (such a...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:246
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:431
virtual void highlightNet(bool aEnabled, int aNetcode=-1)
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:73
bool StartDragging(const VECTOR2I &aP, ITEM *aItem, int aDragMode=DM_ANY)
Definition: pns_router.cpp:131
bool IsLocked() const
Definition: pns_item.h:236
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
bool RoutingInProgress() const
Definition: pns_router.cpp:117

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

770 {
771  if( !prepareInteractive() )
772  return;
773 
774  while( TOOL_EVENT* evt = Wait() )
775  {
776  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
777 
778  // Don't crash if we missed an operation that cancelled routing.
779  wxCHECK2( m_router->RoutingInProgress(), break );
780 
781  handleCommonEvents( *evt );
782 
783  if( evt->IsMotion() )
784  {
785  m_router->SetOrthoMode( evt->Modifier( MD_CTRL ) );
786  updateEndItem( *evt );
788  }
789  else if( evt->IsAction( &ACT_UndoLastSegment ) )
790  {
792  updateEndItem( *evt );
794  }
795  else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &PCB_ACTIONS::routeSingleTrack ) )
796  {
797  updateEndItem( *evt );
798  bool needLayerSwitch = m_router->IsPlacingVia();
799  bool forceFinish = evt->Modifier( MD_SHIFT );
800 
801 
802  if( m_router->FixRoute( m_endSnapPoint, m_endItem, forceFinish ) )
803  {
804  break;
805  }
806 
807  if( needLayerSwitch )
809 
810  // Synchronize the indicated layer
812  updateEndItem( *evt );
814  m_startItem = nullptr;
815  }
816  else if( evt->IsAction( &ACT_SwitchRounding ) )
817  {
819  updateEndItem( *evt );
820  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
821  }
822  else if( evt->IsAction( &ACT_SwitchPosture ) )
823  {
825  updateEndItem( *evt );
826  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
827  }
828  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
829  {
830  m_router->SwitchLayer( frame()->GetActiveLayer() );
831  updateEndItem( *evt );
832  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
833  }
834  else if( evt->IsAction( &ACT_EndTrack ) )
835  {
836  bool still_routing = true;
837 
838  while( still_routing )
839  still_routing = m_router->FixRoute( m_endSnapPoint, m_endItem );
840 
841  break;
842  }
843  else if( evt->IsCancelInteractive() || evt->IsActivate()
844  || evt->IsUndoRedo()
845  || evt->IsAction( &PCB_ACTIONS::routerInlineDrag ) )
846  {
847  if( evt->IsCancelInteractive() && !m_router->RoutingInProgress() )
848  m_cancelled = true;
849 
850  if( evt->IsActivate() && !evt->IsMoveTool() )
851  m_cancelled = true;
852 
853  break;
854  }
855  else if( evt->IsKeyPressed() )
856  {
857  // wxWidgets fails to correctly translate shifted keycodes on the wxEVT_CHAR_HOOK
858  // event so we need to process the wxEVT_CHAR event that will follow as long as we
859  // pass the event.
860  evt->SetPassEvent();
861  }
862  }
863 
866 
868 }
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.
void CommitRouting()
Definition: pns_router.cpp:422
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:531
void ToggleRounded()
Definition: pns_router.cpp:540
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:468
void SetOrthoMode(bool aEnable)
Definition: pns_router.cpp:546
static const TOOL_ACTION ACT_EndTrack("pcbnew.InteractiveRouter.EndTrack", AS_CONTEXT, WXK_END, "", _("Finish Track"), _("Stops laying the current track."), checked_ok_xpm)
void handleCommonEvents(const TOOL_EVENT &evt)
PCB_BASE_EDIT_FRAME * frame() const
void UndoLastSegment()
Definition: pns_router.cpp:413
virtual void updateEndItem(const TOOL_EVENT &aEvent)
bool prepareInteractive()
static const TOOL_ACTION ACT_UndoLastSegment("pcbnew.InteractiveRouter.UndoLastSegment", AS_CONTEXT, WXK_BACK, "", _("Undo last segment"), _("Stops laying the current track."), checked_ok_xpm)
TOOL_EVENT.
Definition: tool_event.h:171
ITEM * m_startItem
Definition: pns_tool_base.h:67
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:391
ROUTER * m_router
Definition: pns_tool_base.h:77
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:246
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:200
void StopRouting()
Definition: pns_router.cpp:431
static const TOOL_ACTION ACT_SwitchRounding("pcbnew.InteractiveRouter.SwitchRounding", AS_CONTEXT, 0, LEGACY_HK_NAME("Switch Rounding"), _("Switch Rounding"), _("Switches the corner type of the currently routed track."))
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:277
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:178
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:73
void FlipPosture()
Definition: pns_router.cpp:459
bool RoutingInProgress() const
Definition: pns_router.cpp:117
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:823
int GetCurrentLayer() const
Definition: pns_router.cpp:500

References ACT_EndTrack, ACT_SwitchPosture, ACT_SwitchRounding, ACT_UndoLastSegment, BUT_LEFT, PNS::ROUTER::CommitRouting(), finishInteractive(), PNS::ROUTER::FixRoute(), PNS::ROUTER::FlipPosture(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), PNS::ROUTER::GetCurrentLayer(), handleCommonEvents(), PNS::ROUTER::IsPlacingVia(), PCB_ACTIONS::layerChanged, PNS::TOOL_BASE::m_cancelled, PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, 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::StopRouting(), PNS::ROUTER::SwitchLayer(), switchLayerOnViaPlacement(), PNS::ROUTER::ToggleRounded(), ToLAYER_ID(), PNS::ROUTER::UndoLastSegment(), PNS::TOOL_BASE::updateEndItem(), and TOOL_INTERACTIVE::Wait().

Referenced by MainLoop().

◆ pickSingleItem()

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

Definition at line 122 of file pns_tool_base.cpp.

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

References PCB_TOOL_BASE::displayOptions(), dist, KIGFX::VIEW::GetTopLayer(), TOOL_BASE::getView(), PNS_KICAD_IFACE::IsAnyLayerVisible(), IsCopperLayer(), PNS::ITEM_SET::Items(), PNS::ITEM::KindStr(), PNS::ITEM::Layers(), PCB_DISPLAY_OPTIONS::m_ContrastModeDisplay, PNS::TOOL_BASE::m_iface, PNS::TOOL_BASE::m_router, PNS::ROUTING_SETTINGS::Mode(), NULL, LAYER_RANGE::Overlaps(), PNS::ROUTER::QueryHoverItems(), PNS::RM_MarkObstacles, PNS::ROUTER::Settings(), PNS::ITEM::SOLID_T, LAYER_RANGE::Start(), and PNS::ITEM::VIA_T.

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

◆ prepareInteractive()

bool ROUTER_TOOL::prepareInteractive ( )
private

Definition at line 701 of file router_tool.cpp.

702 {
703  int routingLayer = getStartLayer( m_startItem );
704 
705  if( !IsCopperLayer( routingLayer ) )
706  {
707  DisplayError( frame(), _( "Tracks on Copper layers only" ) );
708  return false;
709  }
710 
711  PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
712 
713  editFrame->SetActiveLayer( ToLAYER_ID( routingLayer ) );
714 
715  // Force layer visible
716  editFrame->GetLayerManager()->SetLayerVisible( routingLayer, true );
717 
718  // for some reason I don't understand, GetNetclass() may return null sometimes...
719  if( m_startItem && m_startItem->Net() >= 0 &&
721  {
722  highlightNet( true, m_startItem->Net() );
723  // Update track width and via size shown in main toolbar comboboxes
724  editFrame->SetCurrentNetClass( m_startItem->Parent()->GetNetClass()->GetName() );
725  }
726  else
728 
729  controls()->ForceCursorPosition( false );
730  controls()->SetAutoPan( true );
731 
732  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
733 
734  sizes.Init( board(), m_startItem );
735  sizes.AddLayerPair( frame()->GetScreen()->m_Route_Layer_TOP,
736  frame()->GetScreen()->m_Route_Layer_BOTTOM );
737  m_router->UpdateSizes( sizes );
738 
739  if( !m_router->StartRouting( m_startSnapPoint, m_startItem, routingLayer ) )
740  {
742  highlightNet( false );
743  controls()->SetAutoPan( false );
744  return false;
745  }
746 
747  m_endItem = nullptr;
749 
750  frame()->UndoRedoBlock( true );
751 
752  return true;
753 }
const wxString & FailureReason() const
Definition: pns_router.h:226
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
BOARD_CONNECTED_ITEM * Parent() const
Definition: pns_item.h:146
BOARD * board() const
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:69
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:218
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:149
ITEM * m_startItem
Definition: pns_tool_base.h:67
void Init(BOARD *aBoard, ITEM *aStartItem=NULL, int aNet=-1)
ROUTER * m_router
Definition: pns_tool_base.h:77
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:191
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:332
KIGFX::VIEW_CONTROLS * controls() const
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:73
std::shared_ptr< NETCLASS > GetNetClass() const
Function GetNetClass returns the NETCLASS for this item.
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 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:823

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

459 {
460  if( aReason == RUN )
461  TOOL_BASE::Reset( aReason );
462 }
Tool is invoked after being inactive.
Definition: tool_base.h:80
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 387 of file pns_tool_base.cpp.

388 {
389  return m_router;
390 }
ROUTER * m_router
Definition: pns_tool_base.h:77

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:218
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 261 of file sel_layer.cpp.

262 {
263  PCB_SCREEN* screen = frame()->GetScreen();
264 
266  screen->m_Route_Layer_BOTTOM );
267 
268  if( dlg.ShowModal() == wxID_OK )
269  {
270  dlg.GetLayerPair( screen->m_Route_Layer_TOP, screen->m_Route_Layer_BOTTOM );
271 
272  // select the same layer for both layers is allowed (normal in some boards)
273  // but could be a mistake. So display an info message
274  if( screen->m_Route_Layer_TOP == screen->m_Route_Layer_BOTTOM )
275  DisplayInfoMessage( frame(), _( "Warning: top and bottom layers are same." ) );
276  }
277 
278  return 0;
279 }
PCB_BASE_EDIT_FRAME * frame() const
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:46
BOARD * GetBoard()
#define _(s)
Definition: 3d_actions.cpp:33
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:267
PCB_LAYER_ID m_Route_Layer_TOP
Definition: pcb_screen.h:45
SELECT_COPPER_LAYERS_PAIR_DIALOG displays a double pcb copper layers list in a dialog,...
Definition: sel_layer.cpp:231

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

271 {
272  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
273  const auto& selection = selTool->GetSelection();
274  return selection;
275 }
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:218
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::ChangeTrackWidth(), 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(), 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(), 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 278 of file pcb_tool_base.cpp.

279 {
280  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
281  auto& selection = selTool->GetSelection();
282  return selection;
283 }
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:218
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:218
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(), 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 101 of file pcb_tool_base.h.

102  {
103  m_editModules = aEnabled;
104  }

References PCB_TOOL_BASE::m_editModules.

◆ SettingsDialog()

int ROUTER_TOOL::SettingsDialog ( const TOOL_EVENT aEvent)

Definition at line 891 of file router_tool.cpp.

892 {
893  DIALOG_PNS_SETTINGS settingsDlg( frame(), m_router->Settings() );
894 
895  settingsDlg.ShowModal();
896 
897  return 0;
898 }
PCB_BASE_EDIT_FRAME * frame() const
ROUTER * m_router
Definition: pns_tool_base.h:77
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:199

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

Referenced by setTransitions().

◆ setTransitions()

void ROUTER_TOOL::setTransitions ( )
overridevirtual

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

It is called every time tool is reset or finished.

Reimplemented from PCB_TOOL_BASE.

Definition at line 1356 of file router_tool.cpp.

1357 {
1359 
1366 
1372 
1375 }
int MainLoop(const TOOL_EVENT &aEvent)
static TOOL_ACTION selectLayerPair
Definition: pcb_actions.h:135
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:196
int InlineDrag(const TOOL_EVENT &aEvent)
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:287
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:195
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:200
static TOOL_ACTION inlineBreakTrack
Breaks track when router is not activated.
Definition: pcb_actions.h:141
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:178
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:261
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:181

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

394 {
395  VECTOR2I anchor;
396 
397  if( !aItem || !aEnabled || !m_iface->IsItemVisible( aItem ) )
398  {
399  return m_gridHelper->Align( aP );
400  }
401 
402  switch( aItem->Kind() )
403  {
404  case ITEM::SOLID_T:
405  anchor = static_cast<SOLID*>( aItem )->Pos();
406  break;
407 
408  case ITEM::VIA_T:
409  anchor = static_cast<VIA*>( aItem )->Pos();
410  break;
411 
412  case ITEM::SEGMENT_T:
413  case ITEM::ARC_T:
414  {
415  LINKED_ITEM* li = static_cast<LINKED_ITEM*>( aItem );
416  int w = li->Width();
417  auto A = li->Anchor( 0 );
418  auto B = li->Anchor( 1 );
419 
420  if( ( aP - A ).EuclideanNorm() < w / 2 )
421  anchor = A;
422  else if( ( aP - B ).EuclideanNorm() < w / 2 )
423  anchor = B;
424  else // TODO(snh): Clean this up
425  if( aItem->Kind() == ITEM::SEGMENT_T )
426  anchor = m_gridHelper->AlignToSegment( aP, static_cast<SEGMENT*>( li )->Seg() );
427  else if( aItem->Kind() == ITEM::ARC_T )
428  anchor = m_gridHelper->AlignToArc( aP,
429  *static_cast<const SHAPE_ARC*>( static_cast<ARC*>( li )->Shape() ) );
430 
431  break;
432  }
433 
434  default:
435  break;
436  }
437 
438  return anchor;
439 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:128
GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:75
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)
VECTOR2I AlignToArc(const VECTOR2I &aPoint, const SHAPE_ARC &aSeg)
bool IsItemVisible(const PNS::ITEM *aItem) override
VECTOR2I Align(const VECTOR2I &aPoint) const
PNS_KICAD_IFACE * m_iface
Definition: pns_tool_base.h:76

References GRID_HELPER::Align(), GRID_HELPER::AlignToArc(), GRID_HELPER::AlignToSegment(), PNS::ITEM::Anchor(), PNS::ITEM::ARC_T, EuclideanNorm(), PNS_KICAD_IFACE::IsItemVisible(), PNS::ITEM::Kind(), PNS::TOOL_BASE::m_gridHelper, PNS::TOOL_BASE::m_iface, PNS::ITEM::SEGMENT_T, PNS::ITEM::SOLID_T, PNS::ITEM::VIA_T, and PNS::LINKED_ITEM::Width().

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

◆ switchLayerOnViaPlacement()

void ROUTER_TOOL::switchLayerOnViaPlacement ( )
private

Definition at line 500 of file router_tool.cpp.

501 {
502  int al = frame()->GetActiveLayer();
503  int cl = m_router->GetCurrentLayer();
504 
505  if( cl != al )
506  {
507  m_router->SwitchLayer( al );
508  }
509 
510  OPT<int> newLayer = m_router->Sizes().PairedLayer( cl );
511 
512  if( !newLayer )
513  newLayer = m_router->Sizes().GetLayerTop();
514 
515  m_router->SwitchLayer( *newLayer );
516  frame()->SetActiveLayer( ToLAYER_ID( *newLayer ) );
517 }
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:218
void SwitchLayer(int layer)
Definition: pns_router.cpp:468
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:77
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:823
int GetCurrentLayer() const
Definition: pns_router.cpp:500

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

309 {
310  int layer;
311  bool snapEnabled = !aEvent.Modifier( MD_SHIFT );
312  m_gridHelper->SetUseGrid( !aEvent.Modifier( MD_ALT ) );
313  m_gridHelper->SetSnap( snapEnabled );
314 
315  controls()->ForceCursorPosition( false );
316  VECTOR2I mousePos = controls()->GetMousePosition();
317 
318  if( m_router->Settings().Mode() != RM_MarkObstacles &&
319  ( m_router->GetCurrentNets().empty() || m_router->GetCurrentNets().front() < 0 ) )
320  {
321  m_endSnapPoint = snapToItem( snapEnabled, nullptr, mousePos );
323  m_endItem = nullptr;
324 
325  return;
326  }
327 
328  if( m_router->IsPlacingVia() )
329  layer = -1;
330  else
331  layer = m_router->GetCurrentLayer();
332 
333  ITEM* endItem = nullptr;
334 
335  std::vector<int> nets = m_router->GetCurrentNets();
336 
337  for( int net : nets )
338  {
339  endItem = pickSingleItem( mousePos, net, layer, false, { m_startItem } );
340 
341  if( endItem )
342  break;
343  }
344 
345  if( checkSnap( endItem ) )
346  {
347  m_endItem = endItem;
348  m_endSnapPoint = snapToItem( snapEnabled, endItem, mousePos );
349  } else {
350  m_endItem = nullptr;
351  m_endSnapPoint = m_gridHelper->Align( mousePos );
352  }
353 
355 
356  if( m_endItem )
357  {
358  wxLogTrace( "PNS", "%s, layer : %d", m_endItem->KindStr().c_str(), m_endItem->Layers().Start() );
359  }
360 }
GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:75
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
bool IsPlacingVia() const
Definition: pns_router.cpp:531
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:491
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:67
ROUTER * m_router
Definition: pns_tool_base.h:77
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:84
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:342
VECTOR2I Align(const VECTOR2I &aPoint) const
KIGFX::VIEW_CONTROLS * controls() const
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:73
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:94
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:199
const LAYER_RANGE & Layers() const
Definition: pns_item.h:151
int GetCurrentLayer() const
Definition: pns_router.cpp:500

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

273 {
274  int tl = getView()->GetTopLayer();
275  VECTOR2I cp = controls()->GetCursorPosition( !aEvent.Modifier( MD_SHIFT ) );
276  VECTOR2I p;
277 
278  controls()->ForceCursorPosition( false );
279  m_gridHelper->SetUseGrid( !aEvent.Modifier( MD_ALT ) );
280  m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
281 
282  bool snapEnabled = true;
283 
284  if( aEvent.IsMotion() || aEvent.IsClick() )
285  {
286  snapEnabled = !aEvent.Modifier( MD_SHIFT );
287  p = aEvent.Position();
288  }
289  else
290  {
291  p = cp;
292  }
293 
294  m_startItem = pickSingleItem( p, -1, -1, aIgnorePads );
295 
296  if( !snapEnabled && m_startItem && !m_startItem->Layers().Overlaps( tl ) )
297  m_startItem = nullptr;
298 
299  m_startSnapPoint = snapToItem( snapEnabled, m_startItem, p );
300 
301  if( checkSnap( m_startItem ) )
302  {
304  }
305 }
GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:75
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:69
bool IsClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.cpp:178
bool IsMotion() const
Definition: tool_event.h:306
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:67
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:84
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:342
KIGFX::VIEW_CONTROLS * controls() const
virtual ITEM * pickSingleItem(const VECTOR2I &aWhere, int aNet=-1, int aLayer=-1, bool aIgnorePads=false, const std::vector< ITEM * > aAvoidItems={})
void SetUseGrid(bool aGrid=true)
Definition: grid_helper.h:94
const VECTOR2D Position() const
Returns mouse cursor position in world coordinates.
Definition: tool_event.h:274
const LAYER_RANGE & Layers() const
Definition: pns_item.h:151
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:218
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(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), InlineDrag(), ZOOM_TOOL::Main(), CVPCB_CONTROL::Main(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), EDA_3D_VIEWER_CONTROL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), GERBVIEW_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(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

Member Data Documentation

◆ m_cancelled

bool PNS::TOOL_BASE::m_cancelled
protectedinherited

◆ m_editModules

◆ m_endItem

◆ m_endSnapPoint

VECTOR2I PNS::TOOL_BASE::m_endSnapPoint
protectedinherited

◆ m_gridHelper

◆ m_iface

◆ 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(), 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(), LIB_DRAWING_TOOLS::Init(), EDA_3D_VIEWER_CONTROL::Init(), MODULE_EDITOR_TOOLS::Init(), LIB_CONTROL::Init(), PCB_EDITOR_CONTROL::Init(), SCH_DRAWING_TOOLS::Init(), GERBVIEW_SELECTION_TOOL::Init(), DRAWING_TOOL::Init(), EE_SELECTION_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), SELECTION_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), EDIT_TOOL::Init(), PCB_TOOL_BASE::Init(), SCH_MOVE_TOOL::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), EDA_3D_VIEWER_CONTROL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), GERBVIEW_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(), 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_savedSizes

SIZES_SETTINGS PNS::TOOL_BASE::m_savedSizes
protectedinherited

Stores sizes settings between router invocations.

Definition at line 66 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 70 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 68 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 213 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 218 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), EE_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemToSel(), SELECTION_TOOL::AddItemToSel(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), CanInlineDrag(), EDIT_TOOL::ChangeTrackWidth(), PCB_INSPECTION_TOOL::ClearHighlight(), SCH_EDITOR_CONTROL::ClearHighlight(), SELECTION_TOOL::ClearSelection(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), LIB_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(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), LIB_EDIT_TOOL::DoDelete(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), LIB_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::editFieldText(), 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::filterSelection(), SELECTION_TOOL::findCallback(), SCH_EDITOR_CONTROL::FindComponentAndItem(), POINT_EDITOR::finishItem(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), EDIT_TOOL::GetAndPlace(), TOOL_BASE::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(), LIB_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), PAD_TOOL::Init(), GLOBAL_EDIT_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), LIB_CONTROL::Init(), PCB_EDITOR_CONTROL::Init(), POINT_EDITOR::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(), SCH_MOVE_TOOL::Main(), CVPCB_CONTROL::Main(), LIB_MOVE_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(), 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(), 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(), EE_SELECTION_TOOL::RemoveItemFromSel(), SELECTION_TOOL::RemoveItemFromSel(), 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(), PCB_TOOL_BASE::selection(), COMMON_TOOLS::SelectionTool(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), 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(), GERBVIEW_SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_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 217 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 210 of file tool_base.h.

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


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