KiCad PCB EDA Suite
ROUTER_TOOL Class Reference

#include <router_tool.h>

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

Public Types

enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 

Determines the reason of reset for a tool

More...
 

Public Member Functions

 ROUTER_TOOL ()
 
 ~ROUTER_TOOL ()
 
bool Init () override
 Function Init() Init() is called once upon a registration of the tool. More...
 
void Reset (RESET_REASON aReason) override
 Function Reset() Brings the tool to a known, initial state. More...
 
int MainLoop (const TOOL_EVENT &aEvent)
 
int InlineBreakTrack (const TOOL_EVENT &aEvent)
 
bool CanInlineDrag ()
 
int InlineDrag (const TOOL_EVENT &aEvent)
 
int SelectCopperLayerPair (const TOOL_EVENT &aEvent)
 
int DpDimensionsDialog (const TOOL_EVENT &aEvent)
 
int SettingsDialog (const TOOL_EVENT &aEvent)
 
int ChangeRouterMode (const TOOL_EVENT &aEvent)
 
int CustomTrackWidthDialog (const TOOL_EVENT &aEvent)
 
PNS::PNS_MODE GetRouterMode ()
 
void setTransitions () override
 This method is meant to be overridden in order to specify handlers for events. More...
 
ROUTER * Router () const
 
void 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 = 0x01, IPO_FLIP = 0x02, IPO_SINGLE_CLICK = 0x04, IPO_REPEAT = 0x08 }
 Options for placing items interactively. More...
 

Protected Member Functions

bool checkSnap (ITEM *aItem)
 
const VECTOR2I snapToItem (bool aEnabled, ITEM *aItem, VECTOR2I aP)
 
virtual ITEM * pickSingleItem (const VECTOR2I &aWhere, int aNet=-1, int aLayer=-1, bool aIgnorePads=false, const std::vector< ITEM * > aAvoidItems={})
 
virtual void highlightNet (bool aEnabled, int aNetcode=-1)
 
virtual void updateStartItem (const TOOL_EVENT &aEvent, bool aIgnorePads=false)
 
virtual void updateEndItem (const TOOL_EVENT &aEvent)
 
void 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

Options for placing items interactively.

Enumerator
IPO_ROTATE 

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

IPO_FLIP 

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

IPO_SINGLE_CLICK 

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

IPO_REPEAT 

Allow repeat placement of the item.

Definition at line 116 of file pcb_tool_base.h.

116  {
118  IPO_ROTATE = 0x01,
119 
121  IPO_FLIP = 0x02,
122 
125  IPO_SINGLE_CLICK = 0x04,
126 
128  IPO_REPEAT = 0x08
129  };
Handle flip action in the loop by calling the item's flip method.
Allow repeat placement of the item.
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
Handle the rotate action in the loop by calling the item's rotate method.

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

Determines the reason of reset for a tool

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

Definition at line 79 of file tool_base.h.

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

Constructor & Destructor Documentation

◆ ROUTER_TOOL()

ROUTER_TOOL::ROUTER_TOOL ( )

Definition at line 161 of file router_tool.cpp.

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

◆ ~ROUTER_TOOL()

ROUTER_TOOL::~ROUTER_TOOL ( )

Definition at line 449 of file router_tool.cpp.

450 {
451 }

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs the tool.

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

Definition at line 51 of file tool_interactive.cpp.

52 {
54 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:214
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID.

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

Referenced by AUTOPLACE_TOOL::autoplace(), EDIT_TOOL::copyToClipboard(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), PAD_TOOL::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_INSPECTION_TOOL::HighlightNetTool(), InlineBreakTrack(), InlineDrag(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), LIB_TREE::onContextMenu(), POINT_EDITOR::OnSelectionChange(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Function attachManager()

Sets the TOOL_MANAGER the tool will belong to. Called by TOOL_MANAGER::RegisterTool()

Definition at line 60 of file tool_base.cpp.

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

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ board()

BOARD* PCB_TOOL_BASE::board ( ) const
inlineprotectedinherited

Definition at line 166 of file pcb_tool_base.h.

166 { return getModel<BOARD>(); }

Referenced by PCBNEW_CONTROL::AppendBoard(), AUTOPLACE_TOOL::autoplace(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), EDIT_TOOL::ChangeTrackWidth(), ZONE_FILLER_TOOL::CheckAllZones(), checkClearancePadToPad(), checkClearanceSegmToPad(), PCB_INSPECTION_TOOL::ClearHighlight(), DRAWING_TOOL::constrainDimension(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), CustomTrackWidthDialog(), PCBNEW_CONTROL::DeleteItemCursor(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), ZONE_FILLER_TOOL::FillAllZones(), SELECTION_TOOL::filterSelection(), SELECTION_TOOL::getCollectorsGuide(), PCB_INSPECTION_TOOL::highlightNet(), PCBNEW_CONTROL::LayerNext(), PCBNEW_CONTROL::LayerPrev(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PCB_TOOL_BASE::module(), EDIT_TOOL::MoveExact(), onTrackViaSizeChanged(), onViaCommand(), PCBNEW_CONTROL::Paste(), PCBNEW_CONTROL::placeBoardItems(), PCB_EDITOR_CONTROL::PlaceModule(), PAD_TOOL::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), prepareInteractive(), SELECTION_TOOL::RebuildSelection(), PAD_TOOL::recombinePad(), EDIT_TOOL::Remove(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), SELECTION_TOOL::Selectable(), SELECTION_TOOL::selectAllItemsOnNet(), SELECTION_TOOL::selectAllItemsOnSheet(), SELECTION_TOOL::selectConnectedTracks(), SELECTION_TOOL::selectPoint(), PCBNEW_CONTROL::TrackDisplayMode(), 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 1076 of file router_tool.cpp.

1077 {
1080 }
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:69
void BreakSegment(ITEM *aItem, const VECTOR2I &aP)
Definition: pns_router.cpp:570
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 1336 of file router_tool.cpp.

1337 {
1339  const auto& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
1340 
1341  if( selection.Size() == 1 )
1342  {
1343  const BOARD_ITEM* item = static_cast<const BOARD_ITEM*>( selection.Front() );
1344 
1345  if( item->Type() == PCB_TRACE_T || item->Type() == PCB_VIA_T || item->Type() == PCB_MODULE_T )
1346  return true;
1347  }
1348 
1349  return false;
1350 }
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:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
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:127
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:59
EDA_ITEM * Front() const
Definition: selection.h:184
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

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

◆ ChangeRouterMode()

int ROUTER_TOOL::ChangeRouterMode ( const TOOL_EVENT aEvent)

Definition at line 1059 of file router_tool.cpp.

1060 {
1061  PNS::PNS_MODE mode = aEvent.Parameter<PNS::PNS_MODE>();
1062  PNS::ROUTING_SETTINGS& settings = m_router->Settings();
1063 
1064  settings.SetMode( mode );
1065 
1066  return 0;
1067 }
void SetMode(PNS_MODE aMode)
Sets the routing mode.
PNS_MODE
Routing modes
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
ROUTER * m_router
Definition: pns_tool_base.h:77
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:202

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

Referenced by setTransitions().

◆ checkSnap()

bool TOOL_BASE::checkSnap ( ITEM aItem)
protectedinherited

Definition at line 251 of file pns_tool_base.cpp.

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

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

1568 {
1570  DIALOG_TRACK_VIA_SIZE sizeDlg( frame(), bds );
1571 
1572  if( sizeDlg.ShowModal() )
1573  {
1574  bds.UseCustomTrackViaSize( true );
1575 
1576  TOOL_EVENT dummy;
1578  }
1579 
1580  return 0;
1581 }
BOARD * board() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:553
PCB_BASE_EDIT_FRAME * frame() const
TOOL_EVENT.
Definition: tool_event.h:171
int onTrackViaSizeChanged(const TOOL_EVENT &aEvent)
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
Implementing DIALOG_TRACK_VIA_SIZE_BASE.
void UseCustomTrackViaSize(bool aEnabled)
Function UseCustomTrackViaSize Enables/disables custom track/via size settings.
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.

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

Referenced by setTransitions().

◆ deleteTraces()

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

Definition at line 366 of file pns_tool_base.cpp.

367 {
368  NODE *node = m_router->GetWorld()->Branch();
369 
370  if( !aStartItem )
371  return;
372 
373  if( !aWholeTrack )
374  {
375  node->Remove( aStartItem );
376  }
377  else
378  {
379  TOPOLOGY topo( node );
380  ITEM_SET path = topo.AssembleTrivialPath( aStartItem );
381 
382  for( const auto& ent : path.Items() )
383  node->Remove( ent.item );
384  }
385 
386  m_router->CommitRouting( node );
387 }
void CommitRouting()
Definition: pns_router.cpp:443
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:147
NODE * GetWorld() const
Definition: pns_router.h:154

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

const PCB_DISPLAY_OPTIONS & PCB_TOOL_BASE::displayOptions ( ) const
protectedinherited

◆ doInteractiveItemPlacement()

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

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

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

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

Definition at line 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  if( !newItem )
90  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
91  else
92  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
93 
94  VECTOR2I cursorPos = controls()->GetCursorPosition();
95  aPlacer->m_modifiers = evt->Modifier();
96 
97  auto cleanup = [&] ()
98  {
99  newItem = nullptr;
100  preview.Clear();
101  view()->Update( &preview );
102  controls()->SetAutoPan( false );
103  controls()->CaptureCursor( false );
104  controls()->ShowCursor( true );
105  };
106 
107  if( evt->IsCancelInteractive() )
108  {
109  if( aOptions & IPO_SINGLE_CLICK )
110  {
111  cleanup();
112  frame()->PopTool( aTool );
113  break;
114  }
115  else if( newItem )
116  cleanup();
117  else
118  {
119  frame()->PopTool( aTool );
120  break;
121  }
122  }
123  else if( evt->IsActivate() )
124  {
125  if( newItem )
126  cleanup();
127 
128  if( evt->IsPointEditor() )
129  {
130  // don't exit (the point editor runs in the background)
131  }
132  else if( evt->IsMoveTool() )
133  {
134  // leave ourselves on the stack so we come back after the move
135  break;
136  }
137  else
138  {
139  frame()->PopTool( aTool );
140  break;
141  }
142  }
143  else if( evt->IsClick( BUT_LEFT ) )
144  {
145  if( !newItem )
146  {
147  // create the item if possible
148  makeNewItem( cursorPos );
149 
150  // no item created, so wait for another click
151  if( !newItem )
152  continue;
153 
154  controls()->CaptureCursor( true );
155  controls()->SetAutoPan( true );
156  }
157  else
158  {
159  auto oldFlags = newItem->GetFlags();
160  newItem->ClearFlags();
161 
162  if( !aPlacer->PlaceItem( newItem.get(), commit ) )
163  {
164  newItem->SetFlags( oldFlags );
165  continue;
166  }
167 
168  preview.Clear();
169  newItem.release();
170  commit.Push( aCommitMessage );
171 
172  controls()->CaptureCursor( false );
173  controls()->SetAutoPan( false );
174  controls()->ShowCursor( true );
175 
176  if( !( aOptions & IPO_REPEAT ) )
177  break;
178 
179  if( aOptions & IPO_SINGLE_CLICK )
180  makeNewItem( controls()->GetCursorPosition() );
181  }
182  }
183  else if( evt->IsClick( BUT_RIGHT ) )
184  {
186  }
187  else if( newItem && evt->Category() == TC_COMMAND )
188  {
189  /*
190  * Handle any events that can affect the item as we move it around
191  */
192  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
193  {
194  const int rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
195  newItem->Rotate( newItem->GetPosition(), rotationAngle );
196  view()->Update( &preview );
197  }
198  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
199  {
200  newItem->Flip( newItem->GetPosition(), frame()->Settings().m_FlipLeftRight );
201  view()->Update( &preview );
202  }
203  else if( evt->IsAction( &PCB_ACTIONS::viaSizeInc )
204  || evt->IsAction( &PCB_ACTIONS::viaSizeDec ) )
205  {
206  // Refresh preview after event runs
208  }
209  else if( evt->IsAction( &ACTIONS::refreshPreview ) )
210  {
211  preview.Clear();
212  newItem.release();
213 
214  makeNewItem( controls()->GetCursorPosition() );
215  view()->Update( &preview );
216  }
217  }
218 
219  else if( newItem && evt->IsMotion() )
220  {
221  // track the cursor
222  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
223  aPlacer->SnapItem( newItem.get() );
224 
225  // Show a preview of the item
226  view()->Update( &preview );
227  }
228 
229  else
230  evt->SetPassEvent();
231  }
232 
233  view()->Remove( &preview );
234 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:95
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)
Handle flip action in the loop by calling the item's flip method.
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:92
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:279
virtual std::unique_ptr< BOARD_ITEM > CreateItem()=0
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
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:140
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:75
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:76
TOOL_MANAGER * GetManager() const
Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool.
Definition: tool_base.h:143
PCB_BASE_EDIT_FRAME * frame() const
virtual void SnapItem(BOARD_ITEM *aItem)
class MODULE, a footprint
Definition: typeinfo.h:89
const PCBNEW_SELECTION & selection() const
Allow repeat placement of the item.
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
TOOL_EVENT.
Definition: tool_event.h:171
KIGFX::PCB_VIEW * view() const
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:103
Handle the rotate action in the loop by calling the item's rotate method.
KIGFX::VIEW_CONTROLS * controls() const
MODULE * module() const
PCBNEW_SETTINGS & Settings()
void Activate()
Function Activate() Runs the tool.
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:280
static TOOL_ACTION refreshPreview
Definition: actions.h:102
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(), PCB_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_BASE_FRAME::GetModel(), PCB_TOOL_BASE::IPO_FLIP, PCB_TOOL_BASE::IPO_REPEAT, PCB_TOOL_BASE::IPO_ROTATE, PCB_TOOL_BASE::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, PCBNEW_SETTINGS::m_FlipLeftRight, INTERACTIVE_PLACER_BASE::m_frame, TOOL_INTERACTIVE::m_menu, INTERACTIVE_PLACER_BASE::m_modifiers, TOOL_BASE::m_toolMgr, PCB_TOOL_BASE::module(), PCB_MODULE_T, INTERACTIVE_PLACER_BASE::PlaceItem(), TOOLS_HOLDER::PopTool(), BOARD_COMMIT::Push(), TOOLS_HOLDER::PushTool(), ACTIONS::refreshPreview, KIGFX::PCB_VIEW::Remove(), TOOL_MANAGER::RunAction(), MODULE::RunOnChildren(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), 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 PAD_TOOL::PlacePad().

◆ DpDimensionsDialog()

int ROUTER_TOOL::DpDimensionsDialog ( const TOOL_EVENT aEvent)

Definition at line 1029 of file router_tool.cpp.

1030 {
1031  PNS::SIZES_SETTINGS sizes = m_router->Sizes();
1032  DIALOG_PNS_DIFF_PAIR_DIMENSIONS settingsDlg( frame(), sizes );
1033 
1034  if( settingsDlg.ShowModal() == wxID_OK )
1035  {
1036  m_router->UpdateSizes( sizes );
1037  m_savedSizes = sizes;
1038 
1040  bds.SetCustomDiffPairWidth( sizes.DiffPairWidth() );
1041  bds.SetCustomDiffPairGap( sizes.DiffPairGap() );
1042  bds.SetCustomDiffPairViaGap( sizes.DiffPairViaGap() );
1043  }
1044 
1045  return 0;
1046 }
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:553
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:221
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:348
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 912 of file router_tool.cpp.

913 {
915 
916  controls()->SetAutoPan( false );
917  controls()->ForceCursorPosition( false );
918  frame()->UndoRedoBlock( false );
919  highlightNet( false );
920 
921  return true;
922 }
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:452
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 161 of file pcb_tool_base.h.

162  {
163  return getEditFrame<PCB_BASE_EDIT_FRAME>();
164  }

Referenced by POINT_EDITOR::addCorner(), AUTOPLACE_TOOL::autoplace(), PCB_TOOL_BASE::canvas(), ZONE_FILLER_TOOL::CheckAllZones(), PNS::TOOL_BASE::checkSnap(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), CustomTrackWidthDialog(), FOOTPRINT_EDITOR_TOOLS::DeleteFootprint(), PCB_TOOL_BASE::displayOptions(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), DpDimensionsDialog(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawVia(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EditPad(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), PCB_EDITOR_CONTROL::ExportSpecctraDSN(), finishInteractive(), EDIT_TOOL::Flip(), PCB_EDITOR_CONTROL::FlipPcbView(), GLOBAL_EDIT_TOOL::GlobalDeletions(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), PCB_EDITOR_CONTROL::ImportSpecctraSession(), SELECTION_TOOL::Init(), EDIT_TOOL::Init(), InlineBreakTrack(), InlineDrag(), PCBNEW_PICKER_TOOL::Main(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), onViaCommand(), PCBNEW_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), performDragging(), performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickReferencePoint(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), prepareInteractive(), PAD_TOOL::pushPadSettings(), PAD_TOOL::recombinePad(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), PNS::TOOL_BASE::Reset(), SelectCopperLayerPair(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), POINT_EDITOR::setEditedPoint(), SettingsDialog(), GLOBAL_EDIT_TOOL::swapBoardItem(), GLOBAL_EDIT_TOOL::SwapLayers(), switchLayerOnViaPlacement(), 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 187 of file tool_base.h.

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

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone().

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

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

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 121 of file tool_base.h.

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

References TOOL_BASE::m_toolId.

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

◆ GetManager()

TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

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

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

Definition at line 143 of file tool_base.h.

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

References TOOL_BASE::m_toolMgr.

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

◆ getModel()

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

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 201 of file tool_base.h.

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

References TOOL_BASE::getModelInt().

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

◆ GetName()

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

Function GetName() Returns the name of the tool.

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

Returns
The name of the tool.

Definition at line 132 of file tool_base.h.

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

References TOOL_BASE::m_toolName.

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

◆ GetRouterMode()

PNS::PNS_MODE ROUTER_TOOL::GetRouterMode ( )

Definition at line 1070 of file router_tool.cpp.

1071 {
1072  return m_router->Settings().Mode();
1073 }
ROUTER * m_router
Definition: pns_tool_base.h:77
PNS_MODE Mode() const
Returns the routing mode.
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:202

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

Referenced by PCB_EDIT_FRAME::ReCreateVToolbar().

◆ getStartLayer()

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

Definition at line 511 of file router_tool.cpp.

512 {
513  int tl = getView()->GetTopLayer();
514 
515  if( m_startItem )
516  {
517  const LAYER_RANGE& ls = m_startItem->Layers();
518 
519  if( ls.Overlaps( tl ) )
520  return tl;
521  else
522  return ls.Start();
523  }
524 
525  return tl;
526 }
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:855
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 110 of file tool_base.h.

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

References TOOL_BASE::m_type.

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

◆ getView()

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

Function getView()

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

Returns
The instance of VIEW.

Definition at line 36 of file tool_base.cpp.

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

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

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), COMMON_TOOLS::CenterContents(), SCH_EDIT_TOOL::ChangeTextType(), EE_INSPECTION_TOOL::checkPart(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint(), COMMON_TOOLS::CursorControl(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_EDIT_TOOL::DoDelete(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), MICROWAVE_TOOL::drawMicrowaveInductor(), PL_DRAWING_TOOLS::DrawShape(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_EDITOR_CONTROL::FindComponentAndItem(), EE_SELECTION_TOOL::GetNode(), getStartLayer(), PCBNEW_CONTROL::GridResetOrigin(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::GuessSelectionCandidates(), PL_SELECTION_TOOL::highlight(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCB_INSPECTION_TOOL::highlightNet(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), PL_EDIT_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), LIB_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PNS::TOOL_BASE::pickSingleItem(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), PCB_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::Selectable(), PL_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), EE_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), PL_EDITOR_CONTROL::ToggleBackgroundColor(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), PL_SELECTION_TOOL::unhighlight(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), SCH_EDITOR_CONTROL::UpdateFind(), EE_POINT_EDITOR::updateItem(), PL_POINT_EDITOR::updateItem(), POINT_EDITOR::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateView(), PCB_VIEWER_TOOLS::view(), PCB_TOOL_BASE::view(), COMMON_TOOLS::ZoomFitScreen(), SELECTION_TOOL::zoomFitSelection(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and SELECTION_TOOL::~SELECTION_TOOL().

◆ getViewControls()

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

Function getViewControls()

Returns the instance of VIEW_CONTROLS object used in the application. It allows tools to read & modify user input and its settings (eg. show cursor, enable snapping to grid, etc.)

Returns
The instance of VIEW_CONTROLS.

Definition at line 42 of file tool_base.cpp.

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

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

Referenced by EE_POINT_EDITOR::addCorner(), POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), SCH_EDITOR_CONTROL::AssignNetclass(), SCH_EDIT_TOOL::BreakWire(), PCB_TOOL_BASE::controls(), COMMON_TOOLS::CursorControl(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomToPreset(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), LIB_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), PCB_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_INSPECTION_TOOL::HighlightNetTool(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), COMMON_TOOLS::OnGridChanged(), POINT_EDITOR::OnSelectionChange(), LIB_EDIT_TOOL::Paste(), performDragging(), LIB_DRAWING_TOOLS::PlaceAnchor(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PICKER_TOOL::setControls(), PCBNEW_PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), PL_POINT_EDITOR::setEditedPoint(), POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), LIB_MOVE_TOOL::updateModificationPoint(), PL_EDIT_TOOL::updateModificationPoint(), EDIT_TOOL::updateModificationPoint(), and COMMON_TOOLS::ZoomCenter().

◆ Go()

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

Function Go()

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

Definition at line 129 of file tool_interactive.h.

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

References TOOL_INTERACTIVE::goInternal().

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

◆ handleCommonEvents()

void ROUTER_TOOL::handleCommonEvents ( const TOOL_EVENT evt)
private

Definition at line 467 of file router_tool.cpp.

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

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

Referenced by performDragging(), and performRouting().

◆ highlightNet()

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

Definition at line 227 of file pns_tool_base.cpp.

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

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

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

◆ Init()

bool ROUTER_TOOL::Init ( void  )
overridevirtual

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

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

Reimplemented from PCB_TOOL_BASE.

Definition at line 454 of file router_tool.cpp.

455 {
456  return true;
457 }

◆ InlineBreakTrack()

int ROUTER_TOOL::InlineBreakTrack ( const TOOL_EVENT aEvent)

Definition at line 1524 of file router_tool.cpp.

1525 {
1526  const auto& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
1527 
1528  if( selection.Size() != 1 )
1529  return 0;
1530 
1531  const BOARD_CONNECTED_ITEM* item = static_cast<const BOARD_CONNECTED_ITEM*>( selection.Front() );
1532 
1533  if( item->Type() != PCB_TRACE_T )
1534  return 0;
1535 
1536  Activate();
1537 
1539  m_router->SyncWorld();
1541  m_startSnapPoint = snapToItem( true, m_startItem, controls()->GetCursorPosition() );
1542 
1543 
1544  if( m_startItem && m_startItem->IsLocked() )
1545  {
1546  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1547  wxOK | wxCANCEL | wxICON_WARNING );
1548  dlg.SetOKLabel( _( "Break Track" ) );
1549  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1550 
1551  if( dlg.ShowModal() == wxID_CANCEL )
1552  return 0;
1553  }
1554 
1555  frame()->UndoRedoBlock( true );
1556  breakTrack();
1557 
1558  if( m_router->RoutingInProgress() )
1559  m_router->StopRouting();
1560 
1561  frame()->UndoRedoBlock( false );
1562 
1563  return 0;
1564 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:44
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:69
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
void SyncWorld()
Definition: pns_router.cpp:99
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
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:452
KIGFX::VIEW_CONTROLS * controls() const
int Size() const
Returns the number of selected parts.
Definition: selection.h:127
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:120
NODE * GetWorld() const
Definition: pns_router.h:154
EDA_ITEM * Front() const
Definition: selection.h:184
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

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

1354 {
1355  const auto& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
1356 
1357  if( selection.Empty() )
1359 
1360  if( selection.Size() != 1 )
1361  return 0;
1362 
1363  const BOARD_ITEM* item = static_cast<const BOARD_ITEM*>( selection.Front() );
1364 
1365  if( item->Type() != PCB_TRACE_T && item->Type() != PCB_VIA_T && item->Type() != PCB_MODULE_T )
1366  return 0;
1367 
1368  Activate();
1369 
1371  m_router->SyncWorld();
1372  m_startItem = nullptr;
1373 
1374  PNS::ITEM* startItem = nullptr;
1375  PNS::ITEM_SET itemsToDrag;
1376  const MODULE* module = nullptr;
1377 
1378  if( item->Type() == PCB_MODULE_T )
1379  {
1380  module = static_cast<const MODULE*>(item);
1381 
1382  for( const D_PAD* pad : module->Pads() )
1383  {
1384  PNS::ITEM* solid = m_router->GetWorld()->FindItemByParent( pad );
1385 
1386  if( solid )
1387  itemsToDrag.Add( solid );
1388  }
1389  }
1390  else
1391  {
1392  startItem = m_router->GetWorld()->FindItemByParent( static_cast<const BOARD_CONNECTED_ITEM*>( item ) );
1393 
1394  if( startItem)
1395  itemsToDrag.Add( startItem );
1396  }
1397 
1398  if( startItem && startItem->IsLocked() )
1399  {
1400  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1401  wxOK | wxCANCEL | wxICON_WARNING );
1402  dlg.SetOKLabel( _( "Drag Anyway" ) );
1403  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1404 
1405  if( dlg.ShowModal() == wxID_CANCEL )
1406  return 0;
1407  }
1408 
1409  VECTOR2I p0 = controls()->GetCursorPosition( false );
1410  VECTOR2I p = p0;
1411 
1412  if( startItem )
1413  p = snapToItem( true, startItem, p0 );
1414 
1415  int dragMode = aEvent.Parameter<int64_t> ();
1416 
1417  bool dragStarted = m_router->StartDragging( p, itemsToDrag, dragMode );
1418 
1419  if( !dragStarted )
1420  return 0;
1421 
1422  m_gridHelper->SetAuxAxes( true, p );
1423  controls()->ShowCursor( true );
1424  controls()->ForceCursorPosition( false );
1425  controls()->SetAutoPan( true );
1426  frame()->UndoRedoBlock( true );
1427 
1428  while( TOOL_EVENT* evt = Wait() )
1429  {
1430  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
1431 
1432  if( evt->IsCancelInteractive() )
1433  {
1434  break;
1435  }
1436  else if( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
1437  {
1438  updateEndItem( *evt );
1440 
1441  if( module )
1442  {
1443  VECTOR2I offset = m_endSnapPoint - p;
1444  BOARD_ITEM* previewItem;
1445 
1446  view()->ClearPreview();
1447 
1448  for( BOARD_ITEM* drawing : module->GraphicalItems() )
1449  {
1450  previewItem = static_cast<BOARD_ITEM*>( drawing->Clone() );
1451 
1452  if( drawing->Type() == PCB_MODULE_EDGE_T )
1453  {
1454  EDGE_MODULE* edge = static_cast<EDGE_MODULE*>( previewItem );
1455  edge->DRAWSEGMENT::Move( (wxPoint) offset );
1456  }
1457  else
1458  {
1459  previewItem->Move( offset );
1460  }
1461 
1462  view()->Add( previewItem );
1463  view()->AddToPreview( previewItem );
1464  view()->Hide( drawing, true );
1465  }
1466 
1467  previewItem = static_cast<BOARD_ITEM*>( module->Reference().Clone() );
1468  previewItem->Move( offset );
1469  view()->Add( previewItem );
1470  view()->AddToPreview( previewItem );
1471  view()->Hide( &module->Reference() );
1472 
1473  previewItem = static_cast<BOARD_ITEM*>( module->Value().Clone() );
1474  previewItem->Move( offset );
1475  view()->Add( previewItem );
1476  view()->AddToPreview( previewItem );
1477  view()->Hide( &module->Value() );
1478  }
1479  }
1480  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
1481  {
1482  updateEndItem( *evt );
1484  break;
1485  }
1486  else if( evt->Category() == TC_COMMAND )
1487  {
1488  // disallow editing commands
1489  if( evt->IsAction( &ACTIONS::cut )
1490  || evt->IsAction( &ACTIONS::copy )
1491  || evt->IsAction( &ACTIONS::paste )
1492  || evt->IsAction( &ACTIONS::pasteSpecial ) )
1493  {
1494  wxBell();
1495  }
1496  }
1497 
1498  }
1499 
1500  if( module )
1501  {
1502  for( BOARD_ITEM* drawing : module->GraphicalItems() )
1503  view()->Hide( drawing, false );
1504 
1505  view()->Hide( &module->Reference(), false );
1506  view()->Hide( &module->Value(), false );
1507 
1508  view()->ClearPreview();
1509  view()->ShowPreview( false );
1510  }
1511 
1512  if( m_router->RoutingInProgress() )
1513  m_router->StopRouting();
1514 
1515  m_gridHelper->SetAuxAxes( false );
1516  controls()->SetAutoPan( false );
1517  controls()->ForceCursorPosition( false );
1518  frame()->UndoRedoBlock( false );
1519 
1520  return 0;
1521 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hides the item in the view (e.g.
Definition: view.cpp:1511
ITEM.
Definition: pns_item.h:53
TEXTE_MODULE & Reference()
Definition: class_module.h:485
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.
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1578
SELECTION_TOOL.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
void SyncWorld()
Definition: pns_router.cpp:99
PADS & Pads()
Definition: class_module.h:173
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
DRAWINGS & GraphicalItems()
Definition: class_module.h:183
void Add(const LINE &aLine)
Definition: pns_itemset.cpp:32
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
const VECTOR2I snapToItem(bool aEnabled, ITEM *aItem, VECTOR2I aP)
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
void ShowPreview(bool aShow=true)
Definition: view.cpp:1592
PCB_BASE_EDIT_FRAME * frame() const
class MODULE, a footprint
Definition: typeinfo.h:89
static TOOL_ACTION copy
Definition: actions.h:70
virtual void updateEndItem(const TOOL_EVENT &aEvent)
void SetAuxAxes(bool aEnable, const VECTOR2I &aOrigin=VECTOR2I(0, 0))
#define _(s)
const PCBNEW_SELECTION & selection() const
virtual void Move(const wxPoint &aMoveVector)
Function Move move this object.
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:484
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:407
void ClearPreview()
Definition: view.cpp:1566
static TOOL_ACTION cut
Definition: actions.h:69
KIGFX::PCB_VIEW * view() 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.
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:257
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:121
static TOOL_ACTION pasteSpecial
Definition: actions.h:72
void StopRouting()
Definition: pns_router.cpp:452
KIGFX::VIEW_CONTROLS * controls() const
MODULE * module() 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:134
static void NeighboringSegmentFilter(const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector)
int Size() const
Returns the number of selected parts.
Definition: selection.h:127
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
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Function Add() Adds a VIEW_ITEM to the view.
Definition: pcb_view.cpp:58
bool RoutingInProgress() const
Definition: pns_router.cpp:120
NODE * GetWorld() const
Definition: pns_router.h:154
static TOOL_ACTION paste
Definition: actions.h:71
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:59
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:184
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

References _, TOOL_INTERACTIVE::Activate(), KIGFX::PCB_VIEW::Add(), PNS::ITEM_SET::Add(), KIGFX::VIEW::AddToPreview(), BUT_LEFT, KIGFX::VIEW::ClearPreview(), TEXTE_MODULE::Clone(), PCB_TOOL_BASE::controls(), ACTIONS::copy, ACTIONS::cut, 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(), MODULE::GraphicalItems(), KIGFX::VIEW::Hide(), 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, PCB_TOOL_BASE::module(), PNS::ROUTER::Move(), BOARD_ITEM::Move(), NeighboringSegmentFilter(), MODULE::Pads(), TOOL_EVENT::Parameter(), ACTIONS::paste, ACTIONS::pasteSpecial, PCB_MODULE_EDGE_T, PCB_MODULE_T, PCB_TRACE_T, PCB_VIA_T, MODULE::Reference(), PNS::ROUTER::RoutingInProgress(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectionCursor, KIGFX::VIEW_CONTROLS::SetAutoPan(), GRID_HELPER::SetAuxAxes(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), KIGFX::VIEW_CONTROLS::ShowCursor(), KIDIALOG::ShowModal(), KIGFX::VIEW::ShowPreview(), SELECTION::Size(), PNS::TOOL_BASE::snapToItem(), PNS::ROUTER::StartDragging(), PNS::ROUTER::StopRouting(), PNS::ROUTER::SyncWorld(), TC_COMMAND, EDA_ITEM::Type(), PCB_BASE_EDIT_FRAME::UndoRedoBlock(), PNS::TOOL_BASE::updateEndItem(), MODULE::Value(), PCB_TOOL_BASE::view(), and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

32 {
33  return m_toolMgr->IsToolActive( m_toolId );
34 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:214
bool IsToolActive(TOOL_ID aId) const
Function IsToolActive() Returns true if a tool with given id is active (executing)

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

Referenced by EDIT_TOOL::isRouterActive(), and onViaCommand().

◆ MainLoop()

int ROUTER_TOOL::MainLoop ( const TOOL_EVENT aEvent)

Definition at line 1083 of file router_tool.cpp.

1084 {
1085  PNS::ROUTER_MODE mode = aEvent.Parameter<PNS::ROUTER_MODE>();
1086  PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
1087 
1088  // Deselect all items
1090 
1091  std::string tool = aEvent.GetCommandStr().get();
1092  frame->PushTool( tool );
1093  Activate();
1094 
1095  m_router->SetMode( mode );
1096 
1097  VIEW_CONTROLS* ctls = getViewControls();
1098  ctls->ShowCursor( true );
1099  ctls->ForceCursorPosition( false );
1100  m_cancelled = false;
1102 
1103  std::unique_ptr<ROUTER_TOOL_MENU> ctxMenu( new ROUTER_TOOL_MENU( *frame, mode ) );
1104  SetContextMenu( ctxMenu.get() );
1105 
1106  // Prime the pump
1107  if( aEvent.HasPosition() )
1109 
1110  // Main loop: keep receiving events
1111  while( TOOL_EVENT* evt = Wait() )
1112  {
1113  frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
1114 
1115  if( evt->IsCancelInteractive() )
1116  {
1117  frame->PopTool( tool );
1118  break;
1119  }
1120  else if( evt->IsActivate() )
1121  {
1122  if( evt->IsMoveTool() )
1123  {
1124  // leave ourselves on the stack so we come back after the move
1125  break;
1126  }
1127  else
1128  {
1129  frame->PopTool( tool );
1130  break;
1131  }
1132  }
1133  else if( evt->Action() == TA_UNDO_REDO_PRE )
1134  {
1135  m_router->ClearWorld();
1136  }
1137  else if( evt->Action() == TA_UNDO_REDO_POST || evt->Action() == TA_MODEL_CHANGE )
1138  {
1139  m_router->SyncWorld();
1140  }
1141  else if( evt->IsMotion() )
1142  {
1143  updateStartItem( *evt );
1144  }
1145  else if( evt->IsAction( &PCB_ACTIONS::dragFreeAngle ) )
1146  {
1147  updateStartItem( *evt, true );
1149  }
1150  else if( evt->IsAction( &PCB_ACTIONS::drag45Degree ) )
1151  {
1152  updateStartItem( *evt, true );
1154  }
1155  else if( evt->IsAction( &PCB_ACTIONS::breakTrack ) )
1156  {
1157  updateStartItem( *evt, true );
1158  breakTrack( );
1159  }
1160  else if( evt->IsClick( BUT_LEFT )
1161  || evt->IsAction( &PCB_ACTIONS::routeSingleTrack )
1162  || evt->IsAction( &PCB_ACTIONS::routeDiffPair ) )
1163  {
1164  if( evt->IsAction( &PCB_ACTIONS::routeSingleTrack )
1165  || evt->IsAction( &PCB_ACTIONS::routeDiffPair ) )
1166  {
1167  mode = evt->Parameter<PNS::ROUTER_MODE>();
1168  }
1169 
1170  updateStartItem( *evt );
1171 
1172  if( evt->HasPosition() )
1173  {
1174  if( evt->Modifier( MD_CTRL ) )
1176  else
1177  performRouting();
1178  }
1179  }
1180  else if( evt->IsAction( &ACT_PlaceThroughVia ) )
1181  {
1183  }
1184  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1185  {
1187  updateStartItem( *evt );
1188  }
1189  else if( evt->IsKeyPressed() )
1190  {
1191  // wxWidgets fails to correctly translate shifted keycodes on the wxEVT_CHAR_HOOK
1192  // event so we need to process the wxEVT_CHAR event that will follow as long as we
1193  // pass the event.
1194  evt->SetPassEvent();
1195  }
1196 
1197  if( m_cancelled )
1198  {
1199  frame->PopTool( tool );
1200  break;
1201  }
1202  }
1203 
1204  SetContextMenu( nullptr );
1205 
1206  // Store routing settings till the next invocation
1208 
1209  return 0;
1210 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
TOOL_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:133
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
SIZES_SETTINGS m_savedSizes
Stores sizes settings between router invocations.
Definition: pns_tool_base.h:66
void SyncWorld()
Definition: pns_router.cpp:99
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
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:132
void SetContextMenu(ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
Function SetContextMenu()
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:221
void SwitchLayer(int layer)
Definition: pns_router.cpp:489
void breakTrack()
void ClearWorld()
Definition: pns_router.cpp:108
PCB_BASE_EDIT_FRAME * frame() const
virtual PCB_LAYER_ID GetActiveLayer() const
virtual void updateStartItem(const TOOL_EVENT &aEvent, bool aIgnorePads=false)
void performRouting()
virtual void PopTool(const std::string &actionName)
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
TOOL_EVENT.
Definition: tool_event.h:171
ROUTER * m_router
Definition: pns_tool_base.h: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:127
static const TOOL_ACTION ACT_PlaceThroughVia("pcbnew.InteractiveRouter.PlaceVia", AS_CONTEXT, 'V', LEGACY_HK_NAME("Add Through Via"), _("Place Through Via"), _("Adds a through-hole via at the end of currently routed track."), via_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::VIA)
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
ROUTER_MODE
Definition: pns_router.h:68
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:272
void SetMode(ROUTER_MODE aMode)
Definition: pns_router.cpp:559
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:168
void performDragging(int aMode=PNS::DM_ANY)
PCB_EDIT_FRAME is the main frame for Pcbnew.
void Activate()
Function Activate() Runs the tool.
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition: tool_event.h:260
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:270
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:171

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(), TOOLS_HOLDER::PopTool(), TOOL_MANAGER::PrimeTool(), TOOLS_HOLDER::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 1281 of file router_tool.cpp.

1282 {
1283  /*
1284  * If the collection contains a trivial line corner (two connected segments)
1285  * or a non-fanout-via (a via with no more than two connected segments), then
1286  * trim the collection down to a single item (which one won't matter since
1287  * they're all connected).
1288  */
1289 
1290  // First make sure we've got something that *might* match.
1291  int vias = aCollector.CountType( PCB_VIA_T );
1292  int traces = aCollector.CountType( PCB_TRACE_T );
1293  int arcs = aCollector.CountType( PCB_ARC_T );
1294 
1295  if( arcs > 0 || vias > 1 || traces > 2 || vias + traces < 1 )
1296  return;
1297 
1298  // Fetch first TRACK (via or trace) as our reference
1299  TRACK* reference = nullptr;
1300 
1301  for( int i = 0; !reference && i < aCollector.GetCount(); i++ )
1302  reference = dynamic_cast<TRACK*>( aCollector[i] );
1303 
1304  int refNet = reference->GetNetCode();
1305 
1306  wxPoint refPoint( aPt.x, aPt.y );
1307  STATUS_FLAGS flags = reference->IsPointOnEnds( refPoint, -1 );
1308 
1309  if( flags & STARTPOINT )
1310  refPoint = reference->GetStart();
1311  else if( flags & ENDPOINT )
1312  refPoint = reference->GetEnd();
1313 
1314  // Check all items to ensure that any TRACKs are co-terminus with the reference and on
1315  // the same net.
1316  for( int i = 0; i < aCollector.GetCount(); i++ )
1317  {
1318  TRACK* neighbor = dynamic_cast<TRACK*>( aCollector[i] );
1319 
1320  if( neighbor && neighbor != reference )
1321  {
1322  if( neighbor->GetNetCode() != refNet )
1323  return;
1324 
1325  if( neighbor->GetStart() != refPoint && neighbor->GetEnd() != refPoint )
1326  return;
1327  }
1328  }
1329 
1330  // Selection meets criteria; trim it to the reference item.
1331  aCollector.Empty();
1332  aCollector.Append( reference );
1333 }
void Empty()
Function Empty sets the list to empty.
Definition: collector.h:110
int GetNetCode() const
Function GetNetCode.
const wxPoint & GetStart() const
Definition: class_track.h:118
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:262
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:120
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:101
unsigned STATUS_FLAGS
Definition: base_struct.h:152
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:123
const wxPoint & GetEnd() const
Definition: class_track.h:115
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:122

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

1585 {
1586  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
1587  sizes.ImportCurrent( board()->GetDesignSettings() );
1588  m_router->UpdateSizes( sizes );
1589 
1590  // Changing the track width can affect the placement, so call the
1591  // move routine without changing the destination
1593 
1594  return 0;
1595 }
BOARD * board() const
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:221
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:257
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:348
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 CustomTrackWidthDialog(), and setTransitions().

◆ onViaCommand()

int ROUTER_TOOL::onViaCommand ( const TOOL_EVENT aEvent)
private

Definition at line 637 of file router_tool.cpp.

638 {
639  if( !IsToolActive() )
640  return 0;
641 
642  // First see if this is one of the switch layer commands
643  LSEQ layers = LSET( board()->GetEnabledLayers() & LSET::AllCuMask() ).Seq();
644  int currentLayer = m_router->GetCurrentLayer();
645 
646  PCB_LAYER_ID targetLayer = UNDEFINED_LAYER;
647 
648  if( aEvent.IsAction( &PCB_ACTIONS::layerNext ) )
649  {
650  size_t idx = 0;
651 
652  for( size_t i = 0; i < layers.size(); i++ )
653  {
654  if( layers[i] == currentLayer )
655  {
656  idx = i;
657  break;
658  }
659  }
660 
661  idx = ( idx + 1 ) % layers.size();
662  targetLayer = layers[idx];
663  }
664  else if( aEvent.IsAction( &PCB_ACTIONS::layerPrev ) )
665  {
666  size_t idx = 0;
667 
668  for( size_t i = 0; i < layers.size(); i++ )
669  {
670  if( layers[i] == currentLayer )
671  {
672  idx = i;
673  break;
674  }
675  }
676 
677  idx = ( idx > 0 ) ? ( idx - 1 ) : ( layers.size() - 1 );
678  targetLayer = layers[idx];
679  }
680  else
681  {
682  targetLayer = getTargetLayerFromEvent( aEvent );
683 
684  if( targetLayer != UNDEFINED_LAYER )
685  {
686  if( targetLayer == currentLayer )
687  return 0;
688  }
689  }
690 
692  const int layerCount = bds.GetCopperLayerCount();
693 
696 
698 
699  VIATYPE viaType = VIATYPE::THROUGH;
700  bool selectLayer = false;
701 
702  // Otherwise it is one of the router-specific via commands
703  if( targetLayer == UNDEFINED_LAYER )
704  {
705  const int actViaFlags = aEvent.Parameter<intptr_t>();
706  selectLayer = actViaFlags & VIA_ACTION_FLAGS::SELECT_LAYER;
707 
708  viaType = getViaTypeFromFlags( actViaFlags );
709 
710  // ask the user for a target layer
711  if( selectLayer )
712  {
713  wxPoint dlgPosition = wxGetMousePosition();
714 
715  targetLayer = frame()->SelectLayer(
716  static_cast<PCB_LAYER_ID>( currentLayer ), LSET::AllNonCuMask(), dlgPosition );
717 
718  // Reset the cursor to the position where the event occured
719  controls()->SetCursorPosition( aEvent.HasPosition() ? aEvent.Position() : dlgPosition );
720  }
721  }
722 
723  // fixme: P&S supports more than one fixed layer pair. Update the dialog?
724  sizes.ClearLayerPairs();
725 
726  if( !m_router->IsPlacingVia() )
727  {
728  // Cannot place microvias or blind vias if not allowed (obvious)
729  if( ( viaType == VIATYPE::BLIND_BURIED ) && ( !bds.m_BlindBuriedViaAllowed ) )
730  {
731  DisplayError( frame(),
732  _( "Blind/buried vias have to be enabled in Board Setup > Design Rules > Constraints." ) );
733  return false;
734  }
735 
736  if( ( viaType == VIATYPE::MICROVIA ) && ( !bds.m_MicroViasAllowed ) )
737  {
738  DisplayError( frame(),
739  _( "Microvias have to be enabled in Board Setup > Design Rules > Constraints." ) );
740  return false;
741  }
742 
743  // Can only place through vias on 2-layer boards
744  if( ( viaType != VIATYPE::THROUGH ) && ( layerCount <= 2 ) )
745  {
746  DisplayError( frame(), _( "Only through vias are allowed on 2 layer boards." ) );
747  return false;
748  }
749 
750  // Can only place microvias if we're on an outer layer, or directly adjacent to one
751  if( ( viaType == VIATYPE::MICROVIA ) && ( currentLayer > In1_Cu )
752  && ( currentLayer < layerCount - 2 ) )
753  {
754  DisplayError( frame(), _( "Microvias can be placed only between the outer layers "
755  "(F.Cu/B.Cu) and the ones directly adjacent to them." ) );
756  return false;
757  }
758  }
759 
760  // Convert blind/buried via to a through hole one, if it goes through all layers
761  if( viaType == VIATYPE::BLIND_BURIED
762  && ( ( targetLayer == B_Cu && currentLayer == F_Cu )
763  || ( targetLayer == F_Cu && currentLayer == B_Cu ) ) )
764  {
765  viaType = VIATYPE::THROUGH;
766  }
767 
768  switch( viaType )
769  {
770  case VIATYPE::THROUGH:
771  sizes.SetViaDiameter( bds.GetCurrentViaSize() );
772  sizes.SetViaDrill( bds.GetCurrentViaDrill() );
773 
774  if( targetLayer != UNDEFINED_LAYER )
775  {
776  // go from the current layer to the chosen layer
777  sizes.AddLayerPair( currentLayer, targetLayer );
778  }
779  else
780  {
781  // use the default layer pair
782  sizes.AddLayerPair( pairTop, pairBottom );
783  }
784  break;
785 
786  case VIATYPE::MICROVIA:
787  sizes.SetViaDiameter( bds.GetCurrentMicroViaSize() );
788  sizes.SetViaDrill( bds.GetCurrentMicroViaDrill() );
789 
790  wxASSERT_MSG( !selectLayer,
791  "Unexpected select layer for microvia (microvia layers are implicit)" );
792 
793  if( currentLayer == F_Cu || currentLayer == In1_Cu )
794  {
795  // front-side microvia
796  sizes.AddLayerPair( F_Cu, In1_Cu );
797  }
798  else if( currentLayer == B_Cu || currentLayer == layerCount - 2 )
799  {
800  // back-side microvia
801  sizes.AddLayerPair( B_Cu, layerCount - 2 );
802  }
803  else
804  {
805  wxASSERT_MSG( false,
806  "Invalid layer pair for microvia (must be on or adjacent to an outer layer)" );
807  }
808  break;
809 
811  sizes.SetViaDiameter( bds.GetCurrentViaSize() );
812  sizes.SetViaDrill( bds.GetCurrentViaDrill() );
813 
814  if( targetLayer != UNDEFINED_LAYER )
815  {
816  // go directly to the user specified layer
817  sizes.AddLayerPair( currentLayer, targetLayer );
818  }
819  else
820  {
821  if( currentLayer == pairTop || currentLayer == pairBottom )
822  {
823  // the current layer is on the defined layer pair,
824  // swap to the other side
825  sizes.AddLayerPair( pairTop, pairBottom );
826  }
827  else
828  {
829  // the current layer is not part of the current layer pair,
830  // so fallback and swap to the top layer of the pair by default
831  sizes.AddLayerPair( pairTop, currentLayer );
832  }
833  }
834  break;
835 
836  default:
837  wxASSERT( false );
838  break;
839  }
840 
841  sizes.SetViaType( viaType );
842 
843  m_router->UpdateSizes( sizes );
845 
846  if( m_router->RoutingInProgress() )
847  updateEndItem( aEvent );
848  else
849  updateStartItem( aEvent );
850 
851  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
852 
853  return 0;
854 }
int GetCurrentMicroViaSize()
Function GetCurrentMicroViaSize.
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Function AllCuMask returns a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:712
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
static TOOL_ACTION layerNext
Definition: pcb_actions.h:266
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:735
bool IsPlacingVia() const
Definition: pns_router.cpp:535
Microvia
Definition: router_tool.cpp:72
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:553
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:221
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Function Seq returns an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:377
void ToggleViaPlacement()
Definition: pns_router.cpp:502
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
PCB_BASE_EDIT_FRAME * frame() const
virtual void updateStartItem(const TOOL_EVENT &aEvent, bool aIgnorePads=false)
static VIATYPE getViaTypeFromFlags(int aFlags)
virtual void updateEndItem(const TOOL_EVENT &aEvent)
PCB_LAYER_ID
A quick note on layer IDs:
#define _(s)
LSET is a set of PCB_LAYER_IDs.
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:267
static PCB_LAYER_ID getTargetLayerFromEvent(const TOOL_EVENT &aEvent)
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
VIATYPE
Definition: class_track.h:68
ROUTER * m_router
Definition: pns_tool_base.h:77
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:39
bool m_BlindBuriedViaAllowed
true to allow blind/buried vias
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:257
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
void SetViaType(VIATYPE aViaType)
int GetCurrentViaSize() const
Function GetCurrentViaSize.
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:348
KIGFX::VIEW_CONTROLS * controls() const
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:73
bool IsToolActive() const
Definition: tool_base.cpp:31
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
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:120
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:38
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
int GetCurrentLayer() const
Definition: pns_router.cpp:521

References _, PNS::SIZES_SETTINGS::AddLayerPair(), LSET::AllCuMask(), 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(), getTargetLayerFromEvent(), getViaTypeFromFlags(), TOOL_EVENT::HasPosition(), In1_Cu, TOOL_EVENT::IsAction(), PNS::ROUTER::IsPlacingVia(), TOOL_BASE::IsToolActive(), PCB_ACTIONS::layerNext, PCB_ACTIONS::layerPrev, 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(), LSET::Seq(), 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 1213 of file router_tool.cpp.

1214 {
1215  VIEW_CONTROLS* ctls = getViewControls();
1216 
1217  if( m_startItem && m_startItem->IsLocked() )
1218  {
1219  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1220  wxOK | wxCANCEL | wxICON_WARNING );
1221  dlg.SetOKLabel( _( "Drag Anyway" ) );
1222  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1223 
1224  if( dlg.ShowModal() == wxID_CANCEL )
1225  return;
1226  }
1227 
1228  bool dragStarted = m_router->StartDragging( m_startSnapPoint, m_startItem, aMode );
1229 
1230  if( !dragStarted )
1231  return;
1232 
1233  if( m_startItem && m_startItem->Net() >= 0 )
1234  highlightNet( true, m_startItem->Net() );
1235 
1236  ctls->SetAutoPan( true );
1238  frame()->UndoRedoBlock( true );
1239 
1240  while( TOOL_EVENT* evt = Wait() )
1241  {
1242  ctls->ForceCursorPosition( false );
1243 
1244  if( evt->IsMotion() )
1245  {
1246  updateEndItem( *evt );
1248  }
1249  else if( evt->IsClick( BUT_LEFT ) )
1250  {
1252  break;
1253  }
1254  else if( evt->IsCancelInteractive() || evt->IsActivate() || evt->IsUndoRedo() )
1255  {
1256  if( evt->IsCancelInteractive() && !m_startItem )
1257  m_cancelled = true;
1258 
1259  if( evt->IsActivate() && !evt->IsMoveTool() )
1260  m_cancelled = true;
1261 
1262  break;
1263  }
1264 
1265  handleCommonEvents( *evt );
1266  }
1267 
1268  if( m_router->RoutingInProgress() )
1269  m_router->StopRouting();
1270 
1271  m_startItem = nullptr;
1272 
1273  m_gridHelper->SetAuxAxes( false );
1274  frame()->UndoRedoBlock( false );
1275  ctls->SetAutoPan( false );
1276  ctls->ForceCursorPosition( false );
1277  highlightNet( false );
1278 }
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:407
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:257
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:452
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:134
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:120

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

926 {
927  if( !prepareInteractive() )
928  return;
929 
930  while( TOOL_EVENT* evt = Wait() )
931  {
932  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
933 
934  // Don't crash if we missed an operation that cancelled routing.
935  if( !m_router->RoutingInProgress() )
936  {
937  if( evt->IsCancelInteractive() )
938  m_cancelled = true;
939 
940  break;
941  }
942 
943  handleCommonEvents( *evt );
944 
945  if( evt->IsMotion() )
946  {
947  m_router->SetOrthoMode( evt->Modifier( MD_CTRL ) );
948  updateEndItem( *evt );
950  }
951  else if( evt->IsAction( &ACT_UndoLastSegment ) )
952  {
954  updateEndItem( *evt );
956  }
957  else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &PCB_ACTIONS::routeSingleTrack ) )
958  {
959  updateEndItem( *evt );
960  bool needLayerSwitch = m_router->IsPlacingVia();
961  bool forceFinish = evt->Modifier( MD_SHIFT );
962 
963  if( m_router->FixRoute( m_endSnapPoint, m_endItem, forceFinish ) )
964  {
965  break;
966  }
967 
968  if( needLayerSwitch )
970 
971  // Synchronize the indicated layer
973  updateEndItem( *evt );
975  m_startItem = nullptr;
976  }
977  else if( evt->IsAction( &ACT_SwitchRounding ) )
978  {
980  updateEndItem( *evt );
981  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
982  }
983  else if( evt->IsAction( &ACT_SwitchPosture ) )
984  {
986  updateEndItem( *evt );
987  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
988  }
989  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
990  {
991  m_router->SwitchLayer( frame()->GetActiveLayer() );
992  updateEndItem( *evt );
993  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
994  }
995  else if( evt->IsAction( &ACT_EndTrack ) || evt->IsDblClick( BUT_LEFT ) )
996  {
997  // Stop current routing:
999  break;
1000  }
1001  else if( evt->IsCancelInteractive() || evt->IsActivate()
1002  || evt->IsUndoRedo()
1003  || evt->IsAction( &PCB_ACTIONS::routerInlineDrag ) )
1004  {
1005  if( evt->IsCancelInteractive() && !m_router->RoutingInProgress() )
1006  m_cancelled = true;
1007 
1008  if( evt->IsActivate() && !evt->IsMoveTool() )
1009  m_cancelled = true;
1010 
1011  break;
1012  }
1013  else if( evt->IsKeyPressed() )
1014  {
1015  // wxWidgets fails to correctly translate shifted keycodes on the wxEVT_CHAR_HOOK
1016  // event so we need to process the wxEVT_CHAR event that will follow as long as we
1017  // pass the event.
1018  evt->SetPassEvent();
1019  }
1020  }
1021 
1023  m_router->StopRouting();
1024 
1026 }
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:443
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:535
void ToggleRounded()
Definition: pns_router.cpp:544
static const TOOL_ACTION ACT_SwitchPosture("pcbnew.InteractiveRouter.SwitchPosture", AS_CONTEXT, '/', LEGACY_HK_NAME("Switch Track Posture"), _("Switch Track Posture"), _("Switches posture of the currently routed track."), change_entry_orient_xpm)
static const TOOL_ACTION ACT_SwitchRounding("pcbnew.InteractiveRouter.SwitchRounding", AS_CONTEXT, 0, LEGACY_HK_NAME("Switch Corner Rounding"), _("Switch Corner Rounding"), _("Switches the corner type of the currently routed track."), switch_corner_rounding_shape_xpm)
void SwitchLayer(int layer)
Definition: pns_router.cpp:489
void SetOrthoMode(bool aEnable)
Definition: pns_router.cpp:550
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:434
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:407
ROUTER * m_router
Definition: pns_tool_base.h:77
void switchLayerOnViaPlacement()
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:257
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:194
void StopRouting()
Definition: pns_router.cpp:452
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:272
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:168
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:73
void FlipPosture()
Definition: pns_router.cpp:480
bool RoutingInProgress() const
Definition: pns_router.cpp:120
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:849
int GetCurrentLayer() const
Definition: pns_router.cpp:521

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  SEG::ecoord dist[candidateCount];
133 
134  for( int i = 0; i < candidateCount; i++ )
135  {
136  prioritized[i] = nullptr;
137  dist[i] = VECTOR2I::ECOORD_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  SEG::ecoord 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  bool highContrast = ( displayOptions().m_ContrastModeDisplay !=
203 
204  for( int i = 0; i < candidateCount; i++ )
205  {
206  ITEM* item = prioritized[i];
207 
208  if( highContrast && item && !item->Layers().Overlaps( tl ) )
209  item = nullptr;
210 
211  if( item && ( aLayer < 0 || item->Layers().Overlaps( aLayer ) ) )
212  {
213  rv = item;
214  break;
215  }
216  }
217 
218  if( rv )
219  {
220  wxLogTrace( "PNS", "%s, layer : %d, tl: %d", rv->KindStr().c_str(), rv->Layers().Start(), tl );
221  }
222 
223  return rv;
224 }
const ITEM_SET QueryHoverItems(const VECTOR2I &aP)
Definition: pns_router.cpp:126
VECTOR2I::extended_type ecoord
Definition: seg.h:42
bool IsAnyLayerVisible(const LAYER_RANGE &aLayer) override
static constexpr extended_type ECOORD_MAX
Definition: vector2d.h:80
#define NULL
virtual int GetTopLayer() const
Definition: view.cpp:855
ROUTER * m_router
Definition: pns_tool_base.h:77
PNS_MODE Mode() const
Returns the routing mode.
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
std::unordered_set< SCH_ITEM * > ITEM_SET
Definition: sch_item.h:147
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:202

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

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

◆ prepareInteractive()

bool ROUTER_TOOL::prepareInteractive ( )
private

Definition at line 857 of file router_tool.cpp.

858 {
859  int routingLayer = getStartLayer( m_startItem );
860 
861  if( !IsCopperLayer( routingLayer ) )
862  {
863  DisplayError( frame(), _( "Tracks on Copper layers only" ) );
864  return false;
865  }
866 
867  PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
868 
869  editFrame->SetActiveLayer( ToLAYER_ID( routingLayer ) );
870 
871  // Force layer visible
872  editFrame->GetLayerManager()->SetLayerVisible( routingLayer, true );
873 
874  // for some reason I don't understand, GetNetclass() may return null sometimes...
875  if( m_startItem && m_startItem->Net() >= 0 &&
877  {
878  highlightNet( true, m_startItem->Net() );
879  // Update track width and via size shown in main toolbar comboboxes
881  }
882  else
884 
885  controls()->ForceCursorPosition( false );
886  controls()->SetAutoPan( true );
887 
888  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
889 
890  sizes.Init( board(), m_startItem );
891  sizes.AddLayerPair( frame()->GetScreen()->m_Route_Layer_TOP,
892  frame()->GetScreen()->m_Route_Layer_BOTTOM );
893  m_router->UpdateSizes( sizes );
894 
895  if( !m_router->StartRouting( m_startSnapPoint, m_startItem, routingLayer ) )
896  {
898  highlightNet( false );
899  controls()->SetAutoPan( false );
900  return false;
901  }
902 
903  m_endItem = nullptr;
905 
906  frame()->UndoRedoBlock( true );
907 
908  return true;
909 }
const wxString & FailureReason() const
Definition: pns_router.h:229
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
const wxString & GetName() const
Definition: netclass.h:96
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:69
NETCLASS * GetNetClass() const
Function GetNetClassPtr returns the NETCLASS for this item.
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:221
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:195
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:348
KIGFX::VIEW_CONTROLS * controls() const
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:73
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:849

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(), NETCLASS::GetName(), 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 460 of file router_tool.cpp.

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

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

◆ Router()

ROUTER * TOOL_BASE::Router ( ) const
inherited

Definition at line 390 of file pns_tool_base.cpp.

391 {
392  return m_router;
393 }
ROUTER * m_router
Definition: pns_tool_base.h:77

References PNS::TOOL_BASE::m_router.

Referenced by EDIT_TOOL::isInteractiveDragEnabled(), and EDIT_TOOL::Remove().

◆ RunMainStack()

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

Function RunMainStack()

Calls a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 87 of file tool_interactive.cpp.

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

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

Referenced by DRAWING_TOOL::PlaceText().

◆ SelectCopperLayerPair()

int ROUTER_TOOL::SelectCopperLayerPair ( const TOOL_EVENT aEvent)

Definition at line 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:39
BOARD * GetBoard()
#define _(s)
Definition: 3d_actions.cpp:33
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:267
PCB_LAYER_ID m_Route_Layer_TOP
Definition: pcb_screen.h:38
SELECT_COPPER_LAYERS_PAIR_DIALOG displays a double pcb copper layers list in a dialog,...
Definition: sel_layer.cpp: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 275 of file pcb_tool_base.cpp.

276 {
277  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
278  const auto& selection = selTool->GetSelection();
279  return selection;
280 }
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
const PCBNEW_SELECTION & selection() const

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

Referenced by AUTOPLACE_TOOL::autoplaceSelected(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), CanInlineDrag(), EDIT_TOOL::ChangeTrackWidth(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), PCB_INSPECTION_TOOL::doHideNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawZone(), EDIT_TOOL::Duplicate(), PCB_EDITOR_CONTROL::EditFpInFpEditor(), PAD_TOOL::EditPad(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), 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::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 283 of file pcb_tool_base.cpp.

284 {
285  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
286  auto& selection = selTool->GetSelection();
287  return selection;
288 }
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
const PCBNEW_SELECTION & selection() const

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

◆ SetContextMenu()

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

Function SetContextMenu()

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

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

Definition at line 76 of file tool_interactive.cpp.

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

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

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

◆ SetEditModules()

void PCB_TOOL_BASE::SetEditModules ( bool  aEnabled)
inlineinherited

Function SetEditModules()

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

Parameters
aEnableddecides if the mode should be enabled.

Definition at line 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 1049 of file router_tool.cpp.

1050 {
1051  DIALOG_PNS_SETTINGS settingsDlg( frame(), m_router->Settings() );
1052 
1053  settingsDlg.ShowModal();
1054 
1055  return 0;
1056 }
PCB_BASE_EDIT_FRAME * frame() const
ROUTER * m_router
Definition: pns_tool_base.h:77
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:202

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

1599 {
1601 
1611 
1617 
1652 
1655 }
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:265
static TOOL_ACTION layerInner26
Definition: pcb_actions.h:260
static TOOL_ACTION layerNext
Definition: pcb_actions.h:266
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:236
int MainLoop(const TOOL_EVENT &aEvent)
static TOOL_ACTION selectLayerPair
Definition: pcb_actions.h:124
static const TOOL_ACTION ACT_PlaceMicroVia("pcbnew.InteractiveRouter.PlaceMicroVia", AS_CONTEXT, MD_CTRL+ 'V', LEGACY_HK_NAME("Add MicroVia"), _("Place Microvia"), _("Adds a microvia at the end of currently routed track."), via_microvia_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::MICROVIA)
int DpDimensionsDialog(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:239
static TOOL_ACTION layerInner6
Definition: pcb_actions.h:240
static TOOL_ACTION routerDiffPairDialog
Definition: pcb_actions.h:186
static TOOL_ACTION layerInner7
Definition: pcb_actions.h:241
static TOOL_ACTION layerInner8
Definition: pcb_actions.h:242
static TOOL_ACTION layerInner21
Definition: pcb_actions.h:255
int InlineDrag(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerHighlightMode
Actions to enable switching modes via hotkey assignments.
Definition: pcb_actions.h:189
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:282
static TOOL_ACTION layerInner3
Definition: pcb_actions.h:237
static TOOL_ACTION layerInner24
Definition: pcb_actions.h:258
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
int ChangeRouterMode(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner11
Definition: pcb_actions.h:245
static TOOL_ACTION layerTop
Definition: pcb_actions.h:234
static TOOL_ACTION layerInner23
Definition: pcb_actions.h:257
int onViaCommand(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerSettingsDialog
Activation of the Push and Shove settings dialogs.
Definition: pcb_actions.h:185
static TOOL_ACTION layerInner13
Definition: pcb_actions.h:247
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:267
static TOOL_ACTION layerInner25
Definition: pcb_actions.h:259
static const TOOL_ACTION ACT_CustomTrackWidth("pcbnew.InteractiveRouter.CustomTrackViaSize", AS_CONTEXT, 'Q', LEGACY_HK_NAME("Custom Track/Via Size"), _("Custom Track/Via Size..."), _("Shows a dialog for changing the track width and via size."), width_track_xpm)
static TOOL_ACTION layerInner18
Definition: pcb_actions.h:252
static TOOL_ACTION layerInner30
Definition: pcb_actions.h:264
static TOOL_ACTION layerInner29
Definition: pcb_actions.h:263
static TOOL_ACTION layerInner10
Definition: pcb_actions.h:244
int SettingsDialog(const TOOL_EVENT &aEvent)
static const TOOL_ACTION ACT_SelLayerAndPlaceThroughVia("pcbnew.InteractiveRouter.SelLayerAndPlaceVia", AS_CONTEXT, '<', LEGACY_HK_NAME("Select Layer and Add Through Via"), _("Select Layer and Place Through Via..."), _("Select a layer, then add a through-hole via at the end of currently routed track."), select_w_layer_xpm, AF_NONE,(void *)(VIA_ACTION_FLAGS::VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
int CustomTrackWidthDialog(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerWalkaroundMode
Definition: pcb_actions.h:191
static TOOL_ACTION layerInner15
Definition: pcb_actions.h:249
int onTrackViaSizeChanged(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:194
static TOOL_ACTION layerInner28
Definition: pcb_actions.h:262
static TOOL_ACTION layerInner27
Definition: pcb_actions.h:261
static TOOL_ACTION inlineBreakTrack
Breaks track when router is not activated.
Definition: pcb_actions.h:130
static TOOL_ACTION layerInner17
Definition: pcb_actions.h:251
static TOOL_ACTION layerInner20
Definition: pcb_actions.h:254
static const TOOL_ACTION ACT_PlaceThroughVia("pcbnew.InteractiveRouter.PlaceVia", AS_CONTEXT, 'V', LEGACY_HK_NAME("Add Through Via"), _("Place Through Via"), _("Adds a through-hole via at the end of currently routed track."), via_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::VIA)
static TOOL_ACTION layerInner22
Definition: pcb_actions.h:256
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:168
static TOOL_ACTION layerInner14
Definition: pcb_actions.h:248
static TOOL_ACTION layerInner9
Definition: pcb_actions.h:243
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)
static TOOL_ACTION layerInner16
Definition: pcb_actions.h:250
int SelectCopperLayerPair(const TOOL_EVENT &aEvent)
Definition: sel_layer.cpp:261
static TOOL_ACTION layerInner4
Definition: pcb_actions.h:238
static const TOOL_ACTION ACT_PlaceBlindVia("pcbnew.InteractiveRouter.PlaceBlindVia", AS_CONTEXT, MD_ALT+MD_SHIFT+ 'V', LEGACY_HK_NAME("Add Blind/Buried Via"), _("Place Blind/Buried Via"), _("Adds a blind or buried via at the end of currently routed track."), via_buried_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::BLIND_VIA)
static TOOL_ACTION layerInner19
Definition: pcb_actions.h:253
static TOOL_ACTION layerInner1
Definition: pcb_actions.h:235
static TOOL_ACTION routerShoveMode
Definition: pcb_actions.h:190
static TOOL_ACTION layerInner12
Definition: pcb_actions.h:246
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:171

References ACT_CustomTrackWidth, ACT_PlaceBlindVia, ACT_PlaceMicroVia, ACT_PlaceThroughVia, ACT_SelLayerAndPlaceBlindVia, ACT_SelLayerAndPlaceThroughVia, ChangeRouterMode(), CustomTrackWidthDialog(), DpDimensionsDialog(), TOOL_INTERACTIVE::Go(), InlineBreakTrack(), PCB_ACTIONS::inlineBreakTrack, InlineDrag(), PCB_ACTIONS::layerBottom, PCB_ACTIONS::layerInner1, PCB_ACTIONS::layerInner10, PCB_ACTIONS::layerInner11, PCB_ACTIONS::layerInner12, PCB_ACTIONS::layerInner13, PCB_ACTIONS::layerInner14, PCB_ACTIONS::layerInner15, PCB_ACTIONS::layerInner16, PCB_ACTIONS::layerInner17, PCB_ACTIONS::layerInner18, PCB_ACTIONS::layerInner19, PCB_ACTIONS::layerInner2, PCB_ACTIONS::layerInner20, PCB_ACTIONS::layerInner21, PCB_ACTIONS::layerInner22, PCB_ACTIONS::layerInner23, PCB_ACTIONS::layerInner24, PCB_ACTIONS::layerInner25, PCB_ACTIONS::layerInner26, PCB_ACTIONS::layerInner27, PCB_ACTIONS::layerInner28, PCB_ACTIONS::layerInner29, PCB_ACTIONS::layerInner3, PCB_ACTIONS::layerInner30, PCB_ACTIONS::layerInner4, PCB_ACTIONS::layerInner5, PCB_ACTIONS::layerInner6, PCB_ACTIONS::layerInner7, PCB_ACTIONS::layerInner8, PCB_ACTIONS::layerInner9, PCB_ACTIONS::layerNext, PCB_ACTIONS::layerPrev, PCB_ACTIONS::layerTop, MainLoop(), TOOL_ACTION::MakeEvent(), onTrackViaSizeChanged(), onViaCommand(), PCB_ACTIONS::routeDiffPair, PCB_ACTIONS::routerDiffPairDialog, PCB_ACTIONS::routerHighlightMode, PCB_ACTIONS::routerInlineDrag, PCB_ACTIONS::routerSettingsDialog, PCB_ACTIONS::routerShoveMode, PCB_ACTIONS::routerWalkaroundMode, PCB_ACTIONS::routeSingleTrack, SelectCopperLayerPair(), PCB_ACTIONS::selectLayerPair, SettingsDialog(), and PCB_ACTIONS::trackViaSizeChanged.

◆ snapToItem()

const VECTOR2I TOOL_BASE::snapToItem ( bool  aEnabled,
ITEM aItem,
VECTOR2I  aP 
)
protectedinherited

Definition at line 396 of file pns_tool_base.cpp.

397 {
398  VECTOR2I anchor;
399 
400  if( !aItem || !aEnabled || !m_iface->IsItemVisible( aItem ) )
401  {
402  return m_gridHelper->Align( aP );
403  }
404 
405  switch( aItem->Kind() )
406  {
407  case ITEM::SOLID_T:
408  anchor = static_cast<SOLID*>( aItem )->Pos();
409  break;
410 
411  case ITEM::VIA_T:
412  anchor = static_cast<VIA*>( aItem )->Pos();
413  break;
414 
415  case ITEM::SEGMENT_T:
416  case ITEM::ARC_T:
417  {
418  LINKED_ITEM* li = static_cast<LINKED_ITEM*>( aItem );
419  int w = li->Width();
420  auto A = li->Anchor( 0 );
421  auto B = li->Anchor( 1 );
422 
423  if( ( aP - A ).EuclideanNorm() < w / 2 )
424  anchor = A;
425  else if( ( aP - B ).EuclideanNorm() < w / 2 )
426  anchor = B;
427  else // TODO(snh): Clean this up
428  if( aItem->Kind() == ITEM::SEGMENT_T )
429  anchor = m_gridHelper->AlignToSegment( aP, static_cast<SEGMENT*>( li )->Seg() );
430  else if( aItem->Kind() == ITEM::ARC_T )
431  anchor = m_gridHelper->AlignToArc( aP,
432  *static_cast<const SHAPE_ARC*>( static_cast<ARC*>( li )->Shape() ) );
433 
434  break;
435  }
436 
437  default:
438  break;
439  }
440 
441  return anchor;
442 }
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 529 of file router_tool.cpp.

530 {
531  int al = frame()->GetActiveLayer();
532  int cl = m_router->GetCurrentLayer();
533 
534  if( cl != al )
535  {
536  m_router->SwitchLayer( al );
537  }
538 
539  OPT<int> newLayer = m_router->Sizes().PairedLayer( cl );
540 
541  if( !newLayer )
542  newLayer = m_router->Sizes().GetLayerTop();
543 
544  m_router->SwitchLayer( *newLayer );
545  frame()->SetActiveLayer( ToLAYER_ID( *newLayer ) );
546 }
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:221
void SwitchLayer(int layer)
Definition: pns_router.cpp:489
PCB_BASE_EDIT_FRAME * frame() const
virtual PCB_LAYER_ID GetActiveLayer() const
ROUTER * m_router
Definition: pns_tool_base.h:77
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
boost::optional< T > OPT
Definition: optional.h:7
OPT< int > PairedLayer(int aLayerId)
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:849
int GetCurrentLayer() const
Definition: pns_router.cpp:521

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

312 {
313  int layer;
314  bool snapEnabled = !aEvent.Modifier( MD_SHIFT );
315  m_gridHelper->SetUseGrid( !aEvent.Modifier( MD_ALT ) );
316  m_gridHelper->SetSnap( snapEnabled );
317 
318  controls()->ForceCursorPosition( false );
319  VECTOR2I mousePos = controls()->GetMousePosition();
320 
321  if( m_router->Settings().Mode() != RM_MarkObstacles &&
322  ( m_router->GetCurrentNets().empty() || m_router->GetCurrentNets().front() < 0 ) )
323  {
324  m_endSnapPoint = snapToItem( snapEnabled, nullptr, mousePos );
326  m_endItem = nullptr;
327 
328  return;
329  }
330 
331  if( m_router->IsPlacingVia() )
332  layer = -1;
333  else
334  layer = m_router->GetCurrentLayer();
335 
336  ITEM* endItem = nullptr;
337 
338  std::vector<int> nets = m_router->GetCurrentNets();
339 
340  for( int net : nets )
341  {
342  endItem = pickSingleItem( mousePos, net, layer, false, { m_startItem } );
343 
344  if( endItem )
345  break;
346  }
347 
348  if( checkSnap( endItem ) )
349  {
350  m_endItem = endItem;
351  m_endSnapPoint = snapToItem( snapEnabled, endItem, mousePos );
352  } else {
353  m_endItem = nullptr;
354  m_endSnapPoint = m_gridHelper->Align( mousePos );
355  }
356 
358 
359  if( m_endItem )
360  {
361  wxLogTrace( "PNS", "%s, layer : %d", m_endItem->KindStr().c_str(), m_endItem->Layers().Start() );
362  }
363 }
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:535
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:512
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:83
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:93
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:202
const LAYER_RANGE & Layers() const
Definition: pns_item.h:151
int GetCurrentLayer() const
Definition: pns_router.cpp:521

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

276 {
277  int tl = getView()->GetTopLayer();
278  VECTOR2I cp = controls()->GetCursorPosition( !aEvent.Modifier( MD_SHIFT ) );
279  VECTOR2I p;
280 
281  controls()->ForceCursorPosition( false );
282  m_gridHelper->SetUseGrid( !aEvent.Modifier( MD_ALT ) );
283  m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
284 
285  bool snapEnabled = true;
286 
287  if( aEvent.IsMotion() || aEvent.IsClick() )
288  {
289  snapEnabled = !aEvent.Modifier( MD_SHIFT );
290  p = aEvent.Position();
291  }
292  else
293  {
294  p = cp;
295  }
296 
297  m_startItem = pickSingleItem( p, -1, -1, aIgnorePads );
298 
299  if( !snapEnabled && m_startItem && !m_startItem->Layers().Overlaps( tl ) )
300  m_startItem = nullptr;
301 
302  m_startSnapPoint = snapToItem( snapEnabled, m_startItem, p );
303 
304  if( checkSnap( m_startItem ) )
305  {
307  }
308 }
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:855
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:83
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:93
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:219
TOOL_EVENT * ScheduleWait(TOOL_BASE *aTool, const TOOL_EVENT_LIST &aConditions)
Pauses execution of a given tool until one or more events matching aConditions arrives.

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

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), InlineDrag(), ZOOM_TOOL::Main(), PL_EDIT_TOOL::Main(), CVPCB_CONTROL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), EDA_3D_CONTROLLER::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), performDragging(), performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickReferencePoint(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

Member Data Documentation

◆ m_cancelled

bool PNS::TOOL_BASE::m_cancelled
protectedinherited

◆ m_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(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), TOOL_INTERACTIVE::GetToolMenu(), PICKER_TOOL::Init(), PL_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init(), LIB_DRAWING_TOOLS::Init(), PCB_VIEWER_TOOLS::Init(), FOOTPRINT_EDITOR_TOOLS::Init(), PL_DRAWING_TOOLS::Init(), LIB_CONTROL::Init(), PCB_EDITOR_CONTROL::Init(), SCH_DRAWING_TOOLS::Init(), EDA_3D_CONTROLLER::Init(), GERBVIEW_SELECTION_TOOL::Init(), PL_SELECTION_TOOL::Init(), DRAWING_TOOL::Init(), EE_SELECTION_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), SELECTION_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), PCB_TOOL_BASE::Init(), PL_EDIT_TOOL::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), EDA_3D_CONTROLLER::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ m_panelItems

MSG_PANEL_ITEMS PNS::TOOL_BASE::m_panelItems
protectedinherited

Definition at line 64 of file pns_tool_base.h.

◆ m_router

◆ m_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 214 of file tool_base.h.

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

◆ m_toolMgr

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 219 of file tool_base.h.

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

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Name of the tool.

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

Definition at line 218 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 211 of file tool_base.h.

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


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