KiCad PCB EDA Suite
ROUTER_TOOL Class Reference

#include <router_tool.h>

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

Public Types

enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 

Determines the reason of reset for a tool

More...
 

Public Member Functions

 ROUTER_TOOL ()
 
 ~ROUTER_TOOL ()
 
bool Init () override
 Function Init() Init() is called once upon a registration of the tool. More...
 
void Reset (RESET_REASON aReason) override
 Function Reset() Brings the tool to a known, initial state. More...
 
int MainLoop (const TOOL_EVENT &aEvent)
 
int InlineBreakTrack (const TOOL_EVENT &aEvent)
 
bool CanInlineDrag ()
 
int InlineDrag (const TOOL_EVENT &aEvent)
 
int SelectCopperLayerPair (const TOOL_EVENT &aEvent)
 
int DpDimensionsDialog (const TOOL_EVENT &aEvent)
 
int SettingsDialog (const TOOL_EVENT &aEvent)
 
int CustomTrackWidthDialog (const TOOL_EVENT &aEvent)
 
void setTransitions () override
 This method is meant to be overridden in order to specify handlers for events. More...
 
ROUTER * Router () const
 
void SetEditModules (bool aEnabled)
 Function SetEditModules() More...
 
bool EditingModules () const
 
void Activate ()
 Function Activate() Runs the tool. More...
 
TOOL_MENUGetToolMenu ()
 
void SetContextMenu (ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Function SetContextMenu() More...
 
void RunMainStack (std::function< void()> aFunc)
 Function RunMainStack() More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Go() More...
 
TOOL_EVENTWait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Wait() More...
 
TOOL_TYPE GetType () const
 Function GetType() Returns the type of the tool. More...
 
TOOL_ID GetId () const
 Function GetId() Returns the unique identifier of the tool. More...
 
const std::string & GetName () const
 Function GetName() Returns the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool. More...
 
TOOL_SETTINGSGetSettings ()
 
bool IsToolActive () const
 

Static Public Member Functions

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

Protected Types

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

Protected Member Functions

bool checkSnap (ITEM *aItem)
 
const VECTOR2I snapToItem (bool aEnabled, ITEM *aItem, VECTOR2I aP)
 
virtual ITEM * pickSingleItem (const VECTOR2I &aWhere, int aNet=-1, int aLayer=-1, bool aIgnorePads=false, const std::vector< ITEM * > aAvoidItems={})
 
virtual void highlightNet (bool aEnabled, int aNetcode=-1)
 
virtual void updateStartItem (const TOOL_EVENT &aEvent, bool aIgnorePads=false)
 
virtual void updateEndItem (const TOOL_EVENT &aEvent)
 
void deleteTraces (ITEM *aStartItem, bool aWholeTrack)
 
void doInteractiveItemPlacement (const std::string &aTool, INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
 Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc. More...
 
KIGFX::PCB_VIEWview () const
 
KIGFX::VIEW_CONTROLScontrols () const
 
PCB_BASE_EDIT_FRAMEframe () const
 
BOARDboard () const
 
MODULEmodule () const
 
const PCB_DISPLAY_OPTIONSdisplayOptions () const
 
PCB_DRAW_PANEL_GALcanvas () const
 
const PCBNEW_SELECTIONselection () const
 
PCBNEW_SELECTIONselection ()
 
void attachManager (TOOL_MANAGER *aManager)
 Function attachManager() More...
 
KIGFX::VIEWgetView () const
 Function getView() More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Function getViewControls() More...
 
template<typename T >
T * getEditFrame () const
 Function getEditFrame() More...
 
template<typename T >
T * getModel () const
 Function getModel() More...
 

Protected Attributes

MSG_PANEL_ITEMS m_panelItems
 
ROUTING_SETTINGS m_savedSettings
 Stores routing settings between router invocations. More...
 
SIZES_SETTINGS m_savedSizes
 Stores sizes settings between router invocations. More...
 
ITEM * m_startItem
 
int m_startLayer
 
VECTOR2I m_startSnapPoint
 
bool m_startHighlight
 Keeps track of whether the net was highlighted before routing. More...
 
ITEM * m_endItem
 
VECTOR2I m_endSnapPoint
 
GRID_HELPERm_gridHelper
 
PNS_KICAD_IFACEm_iface
 
ROUTER * m_router
 
bool m_cancelled
 
bool m_editModules
 
TOOL_MENU m_menu
 functions below are not yet implemented - their interface may change More...
 
TOOL_TYPE m_type
 

Stores the type of the tool.

More...
 
TOOL_ID m_toolId
 

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

More...
 
std::string m_toolName
 

Name of the tool.

More...
 
TOOL_MANAGERm_toolMgr
 
TOOL_SETTINGS m_toolSettings
 

Private Member Functions

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

Detailed Description

Definition at line 28 of file router_tool.h.

Member Enumeration Documentation

◆ INTERACTIVE_PLACEMENT_OPTIONS

Enumerator
IPO_ROTATE 
IPO_FLIP 
IPO_SINGLE_CLICK 
IPO_REPEAT 

Definition at line 109 of file pcb_tool_base.h.

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

Determines the reason of reset for a tool

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

Definition at line 79 of file tool_base.h.

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

Constructor & Destructor Documentation

◆ ROUTER_TOOL()

ROUTER_TOOL::ROUTER_TOOL ( )

Definition at line 143 of file router_tool.cpp.

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

◆ ~ROUTER_TOOL()

ROUTER_TOOL::~ROUTER_TOOL ( )

Definition at line 429 of file router_tool.cpp.

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

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

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs the tool.

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

Definition at line 51 of file tool_interactive.cpp.

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

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

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

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Function attachManager()

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

Definition at line 60 of file tool_base.cpp.

61 {
62  m_toolMgr = aManager;
63  m_toolSettings = TOOL_SETTINGS( this );
64 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:220
friend class TOOL_SETTINGS
Definition: tool_base.h:154

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

Referenced by TOOL_MANAGER::RegisterTool().

◆ board()

BOARD* PCB_TOOL_BASE::board ( ) const
inlineprotectedinherited

Definition at line 151 of file pcb_tool_base.h.

151 { return getModel<BOARD>(); }

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

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

References PNS::ROUTER::BreakSegment(), PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, PNS::ITEM::OfKind(), and PNS::ITEM::SEGMENT_T.

Referenced by InlineBreakTrack(), and MainLoop().

◆ CanInlineDrag()

bool ROUTER_TOOL::CanInlineDrag ( )

Definition at line 1127 of file router_tool.cpp.

1128 {
1130  const auto& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
1131 
1132  if( selection.Size() == 1 )
1133  {
1134  const BOARD_CONNECTED_ITEM* item = static_cast<const BOARD_CONNECTED_ITEM*>( selection.Front() );
1135 
1136  if( item->Type() == PCB_TRACE_T || item->Type() == PCB_VIA_T )
1137  return true;
1138  }
1139 
1140  return false;
1141 }
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected and have...
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
const PCBNEW_SELECTION & selection() const
static void NeighboringSegmentFilter(const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector)
int Size() const
Returns the number of selected parts.
Definition: selection.h:126
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:70
EDA_ITEM * Front() const
Definition: selection.h:183
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207

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

◆ canvas()

◆ checkSnap()

bool TOOL_BASE::checkSnap ( ITEM aItem)
protectedinherited

Definition at line 239 of file pns_tool_base.cpp.

240 {
241  // Sync PNS engine settings with the general PCB editor options.
242  auto& pnss = m_router->Settings();
243 
244  pnss.SetSnapToPads( frame()->Settings().m_MagneticPads == CAPTURE_CURSOR_IN_TRACK_TOOL
245  || frame()->Settings().m_MagneticPads == CAPTURE_ALWAYS );
246 
247  pnss.SetSnapToTracks( frame()->Settings().m_MagneticTracks == CAPTURE_CURSOR_IN_TRACK_TOOL
248  || frame()->Settings().m_MagneticTracks == CAPTURE_ALWAYS );
249 
250  if( aItem )
251  {
252  if( aItem->OfKind( ITEM::VIA_T ) || aItem->OfKind( ITEM::SEGMENT_T ) )
253  return pnss.GetSnapToTracks();
254  else if( aItem->OfKind( ITEM::SOLID_T ) )
255  return pnss.GetSnapToPads();
256  }
257 
258  return false;
259 }
PCB_BASE_EDIT_FRAME * frame() const
ROUTER * m_router
Definition: pns_tool_base.h:78
void SetSnapToPads(bool aSnap)
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:190

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

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

◆ controls()

◆ CustomTrackWidthDialog()

int ROUTER_TOOL::CustomTrackWidthDialog ( const TOOL_EVENT aEvent)

Definition at line 1267 of file router_tool.cpp.

1268 {
1270  DIALOG_TRACK_VIA_SIZE sizeDlg( frame(), bds );
1271 
1272  if( sizeDlg.ShowModal() )
1273  {
1274  bds.UseCustomTrackViaSize( true );
1276  }
1277 
1278  return 0;
1279 }
BOARD * board() const
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:285
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:530
PCB_BASE_EDIT_FRAME * frame() const
Implementing DIALOG_TRACK_VIA_SIZE_BASE.
void UseCustomTrackViaSize(bool aEnabled)
Function UseCustomTrackViaSize Enables/disables custom track/via size settings.
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.

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

Referenced by setTransitions().

◆ deleteTraces()

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

Definition at line 352 of file pns_tool_base.cpp.

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

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

◆ displayOptions()

◆ doInteractiveItemPlacement()

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

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

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

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

Definition at line 36 of file pcb_tool_base.cpp.

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

References TOOL_INTERACTIVE::Activate(), KIGFX::PCB_VIEW::Add(), KIGFX::VIEW_GROUP::Add(), SELECTION::Add(), PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_TOOL_BASE::controls(), INTERACTIVE_PLACER_BASE::CreateItem(), PCB_ACTIONS::flip, PCB_TOOL_BASE::frame(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_BASE_EDIT_FRAME::GetModel(), PCB_TOOL_BASE::IPO_FLIP, PCB_TOOL_BASE::IPO_REPEAT, PCB_TOOL_BASE::IPO_ROTATE, PCB_TOOL_BASE::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, PCB_GENERAL_SETTINGS::m_FlipLeftRight, INTERACTIVE_PLACER_BASE::m_frame, TOOL_INTERACTIVE::m_menu, INTERACTIVE_PLACER_BASE::m_modifiers, TOOL_BASE::m_toolMgr, PCB_TOOL_BASE::module(), PCB_MODULE_T, INTERACTIVE_PLACER_BASE::PlaceItem(), EDA_BASE_FRAME::PopTool(), BOARD_COMMIT::Push(), EDA_BASE_FRAME::PushTool(), ACTIONS::refreshPreview, KIGFX::PCB_VIEW::Remove(), TOOL_MANAGER::RunAction(), MODULE::RunOnChildren(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), KIGFX::VIEW_CONTROLS::SetSnapping(), PCB_BASE_FRAME::Settings(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), INTERACTIVE_PLACER_BASE::SnapItem(), TC_COMMAND, KIGFX::PCB_VIEW::Update(), PCB_ACTIONS::viaSizeDec, PCB_ACTIONS::viaSizeInc, PCB_TOOL_BASE::view(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

◆ DpDimensionsDialog()

int ROUTER_TOOL::DpDimensionsDialog ( const TOOL_EVENT aEvent)

Definition at line 836 of file router_tool.cpp.

837 {
839  DIALOG_PNS_DIFF_PAIR_DIMENSIONS settingsDlg( frame(), sizes );
840 
841  if( settingsDlg.ShowModal() == wxID_OK )
842  {
843  m_router->UpdateSizes( sizes );
844  m_savedSizes = sizes;
845 
847  bds.SetCustomDiffPairWidth( sizes.DiffPairWidth() );
848  bds.SetCustomDiffPairGap( sizes.DiffPairGap() );
850  }
851 
852  return 0;
853 }
void SetCustomDiffPairViaGap(int aGap)
Function SetCustomDiffPairViaGap Sets custom via gap for differential pairs (i.e.
SIZES_SETTINGS m_savedSizes
Stores sizes settings between router invocations.
Definition: pns_tool_base.h:67
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:530
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:209
PCB_BASE_EDIT_FRAME * frame() const
void SetCustomDiffPairWidth(int aWidth)
Function SetCustomDiffPairWidth Sets custom track width for differential pairs (i....
ROUTER * m_router
Definition: pns_tool_base.h:78
void SetCustomDiffPairGap(int aGap)
Function SetCustomDiffPairGap Sets custom gap for differential pairs (i.e.
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:317
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 740 of file router_tool.cpp.

741 {
743 
744  controls()->SetAutoPan( false );
745  controls()->ForceCursorPosition( false );
746  frame()->UndoRedoBlock( false );
747  highlightNet( false );
748 
749  return true;
750 }
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
PCB_BASE_EDIT_FRAME * frame() const
ROUTER * m_router
Definition: pns_tool_base.h:78
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
void StopRouting()
Definition: pns_router.cpp:398
virtual void highlightNet(bool aEnabled, int aNetcode=-1)
KIGFX::VIEW_CONTROLS * controls() const

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

Referenced by performRouting().

◆ frame()

PCB_BASE_EDIT_FRAME* PCB_TOOL_BASE::frame ( ) const
inlineprotectedinherited

Definition at line 146 of file pcb_tool_base.h.

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

Referenced by POINT_EDITOR::addCorner(), MICROWAVE_TOOL::addMicrowaveFootprint(), AUTOPLACE_TOOL::autoplace(), PCB_TOOL_BASE::canvas(), ZONE_FILLER_TOOL::CheckAllZones(), PNS::TOOL_BASE::checkSnap(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), CustomTrackWidthDialog(), MODULE_EDITOR_TOOLS::DeleteFootprint(), PCB_TOOL_BASE::displayOptions(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DpDimensionsDialog(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawVia(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), PCB_EDITOR_CONTROL::ExportSpecctraDSN(), finishInteractive(), EDIT_TOOL::Flip(), PCB_EDITOR_CONTROL::FlipPcbView(), GLOBAL_EDIT_TOOL::GlobalDeletions(), MODULE_EDITOR_TOOLS::ImportFootprint(), PCB_EDITOR_CONTROL::ImportSpecctraSession(), SELECTION_TOOL::Init(), EDIT_TOOL::Init(), InlineBreakTrack(), InlineDrag(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::Move(), POINT_EDITOR::OnSelectionChange(), onViaCommand(), PCBNEW_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), performDragging(), performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickCopyReferencePoint(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), prepareInteractive(), PAD_TOOL::pushPadSettings(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), PNS::TOOL_BASE::Reset(), SelectCopperLayerPair(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), POINT_EDITOR::setEditedPoint(), SettingsDialog(), GLOBAL_EDIT_TOOL::swapBoardItem(), GLOBAL_EDIT_TOOL::SwapLayers(), switchLayerOnViaPlacement(), POINT_EDITOR::updateItem(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillAll().

◆ getEditFrame()

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

Function getEditFrame()

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

Definition at line 187 of file tool_base.h.

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

References TOOL_BASE::getEditFrameInt().

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

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

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

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 121 of file tool_base.h.

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

References TOOL_BASE::m_toolId.

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

◆ GetManager()

TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

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

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

Definition at line 143 of file tool_base.h.

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

References TOOL_BASE::m_toolMgr.

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

◆ getModel()

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

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 201 of file tool_base.h.

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

References TOOL_BASE::getModelInt().

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

◆ GetName()

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

Function GetName() Returns the name of the tool.

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

Returns
The name of the tool.

Definition at line 132 of file tool_base.h.

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

References TOOL_BASE::m_toolName.

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

◆ GetSettings()

TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 78 of file tool_base.cpp.

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

References TOOL_BASE::m_toolSettings.

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

◆ getStartLayer()

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

Definition at line 466 of file router_tool.cpp.

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

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

Referenced by prepareInteractive().

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 110 of file tool_base.h.

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

References TOOL_BASE::m_type.

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

◆ getView()

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

Function getView()

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

Returns
The instance of VIEW.

Definition at line 36 of file tool_base.cpp.

37 {
38  return m_toolMgr->GetView();
39 }
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:250
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(), EE_SELECTION_TOOL::ClearSelection(), COMMON_TOOLS::CursorControl(), LIB_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), EE_SELECTION_TOOL::GetNode(), getStartLayer(), COMMON_TOOLS::GridPreset(), PCBNEW_CONTROL::GridResetOrigin(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::GuessSelectionCandidates(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCB_INSPECTION_TOOL::highlightNet(), EE_POINT_EDITOR::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), LIB_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PNS::TOOL_BASE::pickSingleItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), PCB_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::Selectable(), EE_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), COMMON_TOOLS::ToggleGrid(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), SCH_EDITOR_CONTROL::UpdateFind(), PCBNEW_CONTROL::updateGrid(), EE_POINT_EDITOR::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateView(), PCB_TOOL_BASE::view(), COMMON_TOOLS::ZoomFitScreen(), SELECTION_TOOL::zoomFitSelection(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and SELECTION_TOOL::~SELECTION_TOOL().

◆ getViewControls()

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

Function getViewControls()

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

Returns
The instance of VIEW_CONTROLS.

Definition at line 42 of file tool_base.cpp.

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

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

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

◆ Go()

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

Function Go()

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

Definition at line 129 of file tool_interactive.h.

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

References TOOL_INTERACTIVE::goInternal().

Referenced by LENGTH_TUNER_TOOL::setTransitions(), ZOOM_TOOL::setTransitions(), AUTOPLACE_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), setTransitions(), CVPCB_FOOTPRINT_VIEWER_CONTROL::setTransitions(), LIB_PIN_TOOL::setTransitions(), PAD_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), COMMON_CONTROL::setTransitions(), LIB_DRAWING_TOOLS::setTransitions(), EE_POINT_EDITOR::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), LIB_MOVE_TOOL::setTransitions(), GERBVIEW_CONTROL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), POINT_EDITOR::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), LIB_CONTROL::setTransitions(), LIB_EDIT_TOOL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), PCB_INSPECTION_TOOL::setTransitions(), PCBNEW_CONTROL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), MODULE_EDITOR_TOOLS::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(), DRAWING_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), SELECTION_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), EE_SELECTION_TOOL::setTransitions(), and DRC::setTransitions().

◆ handleCommonEvents()

void ROUTER_TOOL::handleCommonEvents ( const TOOL_EVENT evt)
private

Definition at line 449 of file router_tool.cpp.

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

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

Referenced by performDragging(), and performRouting().

◆ highlightNet()

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

Definition at line 216 of file pns_tool_base.cpp.

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

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

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

◆ Init()

bool ROUTER_TOOL::Init ( )
overridevirtual

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

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

Reimplemented from PCB_TOOL_BASE.

Definition at line 435 of file router_tool.cpp.

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

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

◆ InlineBreakTrack()

int ROUTER_TOOL::InlineBreakTrack ( const TOOL_EVENT aEvent)

Definition at line 1224 of file router_tool.cpp.

1225 {
1226  const auto& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
1227 
1228  if( selection.Size() != 1 )
1229  return 0;
1230 
1231  const BOARD_CONNECTED_ITEM* item = static_cast<const BOARD_CONNECTED_ITEM*>( selection.Front() );
1232 
1233  if( item->Type() != PCB_TRACE_T )
1234  return 0;
1235 
1236  Activate();
1237 
1239  m_router->SyncWorld();
1241  m_startSnapPoint = snapToItem( true, m_startItem, controls()->GetCursorPosition() );
1242 
1243 
1244  if( m_startItem && m_startItem->IsLocked() )
1245  {
1246  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1247  wxOK | wxCANCEL | wxICON_WARNING );
1248  dlg.SetOKLabel( _( "Break Track" ) );
1249  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1250 
1251  if( dlg.ShowModal() == wxID_CANCEL )
1252  return 0;
1253  }
1254 
1255  frame()->UndoRedoBlock( true );
1256  breakTrack();
1257 
1258  if( m_router->RoutingInProgress() )
1259  m_router->StopRouting();
1260 
1261  frame()->UndoRedoBlock( false );
1262 
1263  return 0;
1264 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:44
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
void SyncWorld()
Definition: pns_router.cpp:90
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
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:68
ROUTER * m_router
Definition: pns_tool_base.h:78
void StopRouting()
Definition: pns_router.cpp:398
KIGFX::VIEW_CONTROLS * controls() const
int Size() const
Returns the number of selected parts.
Definition: selection.h:126
bool IsLocked() const
Definition: pns_item.h:235
ITEM * FindItemByParent(const BOARD_CONNECTED_ITEM *aParent)
Definition: pns_node.cpp:1297
void Activate()
Function Activate() Runs the tool.
bool RoutingInProgress() const
Definition: pns_router.cpp:111
NODE * GetWorld() const
Definition: pns_router.h:146
EDA_ITEM * Front() const
Definition: selection.h:183
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207

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

1145 {
1146  const auto& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
1147 
1148  if( selection.Empty() )
1150 
1151  if( selection.Size() != 1 )
1152  return 0;
1153 
1154  const BOARD_CONNECTED_ITEM* item = static_cast<const BOARD_CONNECTED_ITEM*>( selection.Front() );
1155 
1156  if( item->Type() != PCB_TRACE_T && item->Type() != PCB_VIA_T )
1157  return 0;
1158 
1159  Activate();
1160 
1162  m_router->SyncWorld();
1164 
1165  if( m_startItem && m_startItem->IsLocked() )
1166  {
1167  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1168  wxOK | wxCANCEL | wxICON_WARNING );
1169  dlg.SetOKLabel( _( "Drag Anyway" ) );
1170  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1171 
1172  if( dlg.ShowModal() == wxID_CANCEL )
1173  return 0;
1174  }
1175 
1176  VECTOR2I p0 = controls()->GetCursorPosition( false );
1177  auto p = snapToItem( true, m_startItem, p0 );
1178  int dragMode = aEvent.Parameter<int64_t> ();
1179 
1180  bool dragStarted = m_router->StartDragging( p, m_startItem, dragMode );
1181 
1182  if( !dragStarted )
1183  return 0;
1184 
1185  m_gridHelper->SetAuxAxes( true, p );
1186  controls()->ShowCursor( true );
1187  controls()->ForceCursorPosition( false );
1188  controls()->SetAutoPan( true );
1189  frame()->UndoRedoBlock( true );
1190 
1191  while( TOOL_EVENT* evt = Wait() )
1192  {
1193  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
1194 
1195  if( evt->IsCancelInteractive() )
1196  {
1197  break;
1198  }
1199  else if( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
1200  {
1201  updateEndItem( *evt );
1203  }
1204  else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
1205  {
1206  updateEndItem( *evt );
1208  break;
1209  }
1210  }
1211 
1212  if( m_router->RoutingInProgress() )
1213  m_router->StopRouting();
1214 
1215  m_gridHelper->SetAuxAxes( false );
1216  controls()->SetAutoPan( false );
1217  controls()->ForceCursorPosition( false );
1218  frame()->UndoRedoBlock( false );
1219 
1220  return 0;
1221 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:44
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
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:90
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
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
virtual void updateEndItem(const TOOL_EVENT &aEvent)
void SetAuxAxes(bool aEnable, const VECTOR2I &aOrigin=VECTOR2I(0, 0))
#define _(s)
const PCBNEW_SELECTION & selection() const
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
TOOL_EVENT.
Definition: tool_event.h:171
ITEM * m_startItem
Definition: pns_tool_base.h:68
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:373
ROUTER * m_router
Definition: pns_tool_base.h:78
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:230
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:120
void StopRouting()
Definition: pns_router.cpp:398
KIGFX::VIEW_CONTROLS * controls() const
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
bool StartDragging(const VECTOR2I &aP, ITEM *aItem, int aDragMode=DM_ANY)
Definition: pns_router.cpp:126
static void NeighboringSegmentFilter(const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector)
int Size() const
Returns the number of selected parts.
Definition: selection.h:126
bool IsLocked() const
Definition: pns_item.h:235
ITEM * FindItemByParent(const BOARD_CONNECTED_ITEM *aParent)
Definition: pns_node.cpp:1297
void Activate()
Function Activate() Runs the tool.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
bool RoutingInProgress() const
Definition: pns_router.cpp:111
NODE * GetWorld() const
Definition: pns_router.h:146
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:70
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:183
KICAD_T Type() const
Function Type()
Definition: base_struct.h:207

References _, TOOL_INTERACTIVE::Activate(), BUT_LEFT, PCB_TOOL_BASE::controls(), KIDIALOG::DoNotShowCheckbox(), SELECTION::Empty(), PNS::NODE::FindItemByParent(), PNS::ROUTER::FixRoute(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), SELECTION::Front(), PCB_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_MANAGER::GetTool(), PNS::ROUTER::GetWorld(), PNS::ITEM::IsLocked(), PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_gridHelper, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, TOOL_BASE::m_toolMgr, PNS::ROUTER::Move(), NeighboringSegmentFilter(), TOOL_EVENT::Parameter(), PCB_TRACE_T, PCB_VIA_T, PNS::ROUTER::RoutingInProgress(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectionCursor, KIGFX::VIEW_CONTROLS::SetAutoPan(), GRID_HELPER::SetAuxAxes(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), KIGFX::VIEW_CONTROLS::ShowCursor(), KIDIALOG::ShowModal(), SELECTION::Size(), PNS::TOOL_BASE::snapToItem(), PNS::ROUTER::StartDragging(), PNS::ROUTER::StopRouting(), PNS::ROUTER::SyncWorld(), EDA_ITEM::Type(), PCB_BASE_EDIT_FRAME::UndoRedoBlock(), PNS::TOOL_BASE::updateEndItem(), and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

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

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

◆ MainLoop()

int ROUTER_TOOL::MainLoop ( const TOOL_EVENT aEvent)

Definition at line 874 of file router_tool.cpp.

875 {
877  PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
878 
879  // Deselect all items
881 
882  std::string tool = aEvent.GetCommandStr().get();
883  frame->PushTool( tool );
884  Activate();
885 
886  m_router->SetMode( mode );
887 
888  VIEW_CONTROLS* ctls = getViewControls();
889  ctls->ShowCursor( true );
890  ctls->ForceCursorPosition( false );
891  m_cancelled = false;
893 
894  std::unique_ptr<ROUTER_TOOL_MENU> ctxMenu( new ROUTER_TOOL_MENU( *frame, mode ) );
895  SetContextMenu( ctxMenu.get() );
896 
897  // Prime the pump
898  if( aEvent.HasPosition() )
900 
901  // Main loop: keep receiving events
902  while( TOOL_EVENT* evt = Wait() )
903  {
904  frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
905 
906  if( evt->IsCancelInteractive() )
907  {
908  frame->PopTool( tool );
909  break;
910  }
911  else if( evt->IsActivate() )
912  {
913  if( evt->IsMoveTool() )
914  {
915  // leave ourselves on the stack so we come back after the move
916  break;
917  }
918  else
919  {
920  frame->PopTool( tool );
921  break;
922  }
923  }
924  else if( evt->Action() == TA_UNDO_REDO_PRE )
925  {
926  m_router->ClearWorld();
927  }
928  else if( evt->Action() == TA_UNDO_REDO_POST || evt->Action() == TA_MODEL_CHANGE )
929  {
930  m_router->SyncWorld();
931  }
932  else if( evt->IsMotion() )
933  {
934  updateStartItem( *evt );
935  }
936  else if( evt->IsAction( &PCB_ACTIONS::dragFreeAngle ) )
937  {
938  updateStartItem( *evt, true );
940  }
941  else if( evt->IsAction( &PCB_ACTIONS::drag45Degree ) )
942  {
943  updateStartItem( *evt, true );
945  }
946  else if( evt->IsAction( &PCB_ACTIONS::breakTrack ) )
947  {
948  updateStartItem( *evt, true );
949  breakTrack( );
950  }
951  else if( evt->IsClick( BUT_LEFT )
952  || evt->IsAction( &PCB_ACTIONS::routeSingleTrack )
953  || evt->IsAction( &PCB_ACTIONS::routeDiffPair ) )
954  {
955  if( evt->IsAction( &PCB_ACTIONS::routeSingleTrack )
956  || evt->IsAction( &PCB_ACTIONS::routeDiffPair ) )
957  {
958  mode = evt->Parameter<PNS::ROUTER_MODE>();
959  }
960 
961  updateStartItem( *evt );
962 
963  if( evt->HasPosition() )
964  {
965  if( evt->Modifier( MD_CTRL ) )
967  else
968  performRouting();
969  }
970  }
971  else if( evt->IsAction( &ACT_PlaceThroughVia ) )
972  {
974  }
975  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
976  {
978  updateStartItem( *evt );
979  }
980  else if( evt->IsKeyPressed() )
981  {
982  // wxWidgets fails to correctly translate shifted keycodes on the wxEVT_CHAR_HOOK
983  // event so we need to process the wxEVT_CHAR event that will follow as long as we
984  // pass the event.
985  evt->SetPassEvent();
986  }
987 
988  if( m_cancelled )
989  {
990  frame->PopTool( tool );
991  break;
992  }
993  }
994 
995  SetContextMenu( nullptr );
996 
997  // Store routing settings till the next invocation
1000 
1001  return 0;
1002 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:144
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
SIZES_SETTINGS m_savedSizes
Stores sizes settings between router invocations.
Definition: pns_tool_base.h:67
void SyncWorld()
Definition: pns_router.cpp:90
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
void PrimeTool(const VECTOR2D &aPosition)
Function PrimeTool() "Primes" a tool by sending a cursor left-click event with the mouse position set...
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:143
void SetContextMenu(ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
Function SetContextMenu()
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:209
void SwitchLayer(int layer)
Definition: pns_router.cpp:435
void breakTrack()
void ClearWorld()
Definition: pns_router.cpp:99
PCB_BASE_EDIT_FRAME * frame() const
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
virtual void updateStartItem(const TOOL_EVENT &aEvent, bool aIgnorePads=false)
void performRouting()
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
TOOL_EVENT.
Definition: tool_event.h:171
ROUTER * m_router
Definition: pns_tool_base.h:78
VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (such a...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
ROUTING_SETTINGS m_savedSettings
Stores routing settings between router invocations.
Definition: pns_tool_base.h:66
static TOOL_ACTION breakTrack
Break a single track into two segments at the cursor.
Definition: pcb_actions.h:138
static const TOOL_ACTION ACT_PlaceThroughVia("pcbnew.InteractiveRouter.PlaceVia", AS_CONTEXT, 'V', LEGACY_HK_NAME("Add Through Via"), _("Place Through Via"), _("Adds a through-hole via at the end of currently routed track."), via_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::VIA)
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
ROUTER_MODE
Definition: pns_router.h:65
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:275
void SetMode(ROUTER_MODE aMode)
Definition: pns_router.cpp:516
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:178
void performDragging(int aMode=PNS::DM_ANY)
PCB_EDIT_FRAME is the main frame for Pcbnew.
virtual void PopTool(const std::string &actionName)
void Activate()
Function Activate() Runs the tool.
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition: tool_event.h:260
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:190
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:273
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:181

References ACT_PlaceThroughVia, TOOL_INTERACTIVE::Activate(), breakTrack(), PCB_ACTIONS::breakTrack, BUT_LEFT, PNS::ROUTER::ClearWorld(), PNS::DM_ANY, PNS::DM_FREE_ANGLE, PCB_ACTIONS::drag45Degree, PCB_ACTIONS::dragFreeAngle, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_BASE::getViewControls(), TOOL_EVENT::HasPosition(), PCB_ACTIONS::layerChanged, PCB_ACTIONS::layerToggle, PNS::TOOL_BASE::m_cancelled, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_savedSettings, PNS::TOOL_BASE::m_savedSizes, PNS::TOOL_BASE::m_startSnapPoint, TOOL_BASE::m_toolMgr, MD_CTRL, TOOL_EVENT::Parameter(), performDragging(), performRouting(), EDA_BASE_FRAME::PopTool(), TOOL_MANAGER::PrimeTool(), EDA_BASE_FRAME::PushTool(), PCB_ACTIONS::routeDiffPair, PCB_ACTIONS::routeSingleTrack, TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, TOOL_INTERACTIVE::SetContextMenu(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), PNS::ROUTER::SetMode(), PNS::ROUTER::Settings(), KIGFX::VIEW_CONTROLS::ShowCursor(), PNS::ROUTER::Sizes(), PNS::ROUTER::SwitchLayer(), PNS::ROUTER::SyncWorld(), TA_MODEL_CHANGE, TA_UNDO_REDO_POST, TA_UNDO_REDO_PRE, PNS::TOOL_BASE::updateStartItem(), and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

◆ module()

◆ NeighboringSegmentFilter()

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

Definition at line 1073 of file router_tool.cpp.

1074 {
1075  /*
1076  * If the collection contains a trivial line corner (two connected segments)
1077  * or a non-fanout-via (a via with no more than two connected segments), then
1078  * trim the collection down to a single item (which one won't matter since
1079  * they're all connected).
1080  */
1081 
1082  // First make sure we've got something that *might* match.
1083  int vias = aCollector.CountType( PCB_VIA_T );
1084  int traces = aCollector.CountType( PCB_TRACE_T );
1085 
1086  if( vias > 1 || traces > 2 || vias + traces < 1 )
1087  return;
1088 
1089  // Fetch first TRACK (via or trace) as our reference
1090  TRACK* reference = nullptr;
1091 
1092  for( int i = 0; !reference && i < aCollector.GetCount(); i++ )
1093  reference = dynamic_cast<TRACK*>( aCollector[i] );
1094 
1095  int refNet = reference->GetNetCode();
1096 
1097  wxPoint refPoint( aPt.x, aPt.y );
1098  STATUS_FLAGS flags = reference->IsPointOnEnds( refPoint, -1 );
1099 
1100  if( flags & STARTPOINT )
1101  refPoint = reference->GetStart();
1102  else if( flags & ENDPOINT )
1103  refPoint = reference->GetEnd();
1104 
1105  // Check all items to ensure that any TRACKs are co-terminus with the reference and on
1106  // the same net.
1107  for( int i = 0; i < aCollector.GetCount(); i++ )
1108  {
1109  TRACK* neighbor = dynamic_cast<TRACK*>( aCollector[i] );
1110 
1111  if( neighbor && neighbor != reference )
1112  {
1113  if( neighbor->GetNetCode() != refNet )
1114  return;
1115 
1116  if( neighbor->GetStart() != refPoint && neighbor->GetEnd() != refPoint )
1117  return;
1118  }
1119  }
1120 
1121  // Selection meets criteria; trim it to the reference item.
1122  aCollector.Empty();
1123  aCollector.Append( reference );
1124 }
void Empty()
Function Empty sets the list to empty.
Definition: collector.h:125
int GetNetCode() const
Function GetNetCode.
const wxPoint & GetStart() const
Definition: class_track.h:109
int CountType(KICAD_T aType)
Function CountType counts the number of items matching aType.
Definition: collector.h:267
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:135
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:116
unsigned STATUS_FLAGS
Definition: base_struct.h:156
STATUS_FLAGS IsPointOnEnds(const wxPoint &point, int min_dist=0) const
Function IsPointOnEnds returns STARTPOINT if point if near (dist = min_dist) start point,...
#define ENDPOINT
ends. (Used to support dragging.)
Definition: base_struct.h:126
const wxPoint & GetEnd() const
Definition: class_track.h:106
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: base_struct.h:125

References COLLECTOR::Append(), COLLECTOR::CountType(), COLLECTOR::Empty(), ENDPOINT, COLLECTOR::GetCount(), TRACK::GetEnd(), BOARD_CONNECTED_ITEM::GetNetCode(), TRACK::GetStart(), TRACK::IsPointOnEnds(), PCB_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 1282 of file router_tool.cpp.

1283 {
1284  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
1285  sizes.ImportCurrent( board()->GetDesignSettings() );
1286  m_router->UpdateSizes( sizes );
1287 
1288  // Changing the track width can affect the placement, so call the
1289  // move routine without changing the destination
1291 
1292  return 0;
1293 }
BOARD * board() const
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:209
ROUTER * m_router
Definition: pns_tool_base.h:78
void ImportCurrent(BOARD_DESIGN_SETTINGS &aSettings)
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:230
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:317
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74

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

Referenced by setTransitions().

◆ onViaCommand()

int ROUTER_TOOL::onViaCommand ( const TOOL_EVENT aEvent)
private

Definition at line 521 of file router_tool.cpp.

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

References _, PNS::SIZES_SETTINGS::AddLayerPair(), LSET::AllNonCuMask(), B_Cu, BLIND_BURIED, PCB_TOOL_BASE::board(), PNS::SIZES_SETTINGS::ClearLayerPairs(), PCB_TOOL_BASE::controls(), DisplayError(), F_Cu, PCB_TOOL_BASE::frame(), BOARD_DESIGN_SETTINGS::GetCopperLayerCount(), PNS::ROUTER::GetCurrentLayer(), BOARD_DESIGN_SETTINGS::GetCurrentMicroViaDrill(), BOARD_DESIGN_SETTINGS::GetCurrentMicroViaSize(), BOARD_DESIGN_SETTINGS::GetCurrentViaDrill(), BOARD_DESIGN_SETTINGS::GetCurrentViaSize(), BOARD::GetDesignSettings(), PCB_BASE_FRAME::GetScreen(), getViaTypeFromFlags(), TOOL_EVENT::HasPosition(), In1_Cu, PNS::ROUTER::IsPlacingVia(), BOARD_DESIGN_SETTINGS::m_BlindBuriedViaAllowed, PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, BOARD_DESIGN_SETTINGS::m_MicroViasAllowed, PCB_SCREEN::m_Route_Layer_BOTTOM, PCB_SCREEN::m_Route_Layer_TOP, PNS::TOOL_BASE::m_router, MICROVIA, PNS::ROUTER::Move(), TOOL_EVENT::Parameter(), TOOL_EVENT::Position(), PNS::ROUTER::RoutingInProgress(), SELECT_LAYER, PCB_BASE_FRAME::SelectLayer(), KIGFX::VIEW_CONTROLS::SetCursorPosition(), PNS::SIZES_SETTINGS::SetViaDiameter(), PNS::SIZES_SETTINGS::SetViaDrill(), PNS::SIZES_SETTINGS::SetViaType(), PNS::ROUTER::Sizes(), THROUGH, PNS::ROUTER::ToggleViaPlacement(), UNDEFINED_LAYER, PNS::TOOL_BASE::updateEndItem(), PNS::ROUTER::UpdateSizes(), and PNS::TOOL_BASE::updateStartItem().

Referenced by setTransitions().

◆ performDragging()

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

Definition at line 1005 of file router_tool.cpp.

1006 {
1007  VIEW_CONTROLS* ctls = getViewControls();
1008 
1009  if( m_startItem && m_startItem->IsLocked() )
1010  {
1011  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1012  wxOK | wxCANCEL | wxICON_WARNING );
1013  dlg.SetOKLabel( _( "Drag Anyway" ) );
1014  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1015 
1016  if( dlg.ShowModal() == wxID_CANCEL )
1017  return;
1018  }
1019 
1020  bool dragStarted = m_router->StartDragging( m_startSnapPoint, m_startItem, aMode );
1021 
1022  if( !dragStarted )
1023  return;
1024 
1025  if( m_startItem && m_startItem->Net() >= 0 )
1026  highlightNet( true, m_startItem->Net() );
1027 
1028  ctls->SetAutoPan( true );
1030  frame()->UndoRedoBlock( true );
1031 
1032  while( TOOL_EVENT* evt = Wait() )
1033  {
1034  ctls->ForceCursorPosition( false );
1035 
1036  if( evt->IsMotion() )
1037  {
1038  updateEndItem( *evt );
1040  }
1041  else if( evt->IsClick( BUT_LEFT ) )
1042  {
1044  break;
1045  }
1046  else if( evt->IsCancelInteractive() || evt->IsActivate() || evt->IsUndoRedo() )
1047  {
1048  if( evt->IsCancelInteractive() && !m_startItem )
1049  m_cancelled = true;
1050 
1051  if( evt->IsActivate() && !evt->IsMoveTool() )
1052  m_cancelled = true;
1053 
1054  break;
1055  }
1056 
1057  handleCommonEvents( *evt );
1058  }
1059 
1060  if( m_router->RoutingInProgress() )
1061  m_router->StopRouting();
1062 
1063  m_startItem = nullptr;
1064 
1065  m_gridHelper->SetAuxAxes( false );
1066  frame()->UndoRedoBlock( false );
1067  ctls->SetAutoPan( false );
1068  ctls->ForceCursorPosition( false );
1069  highlightNet( false );
1070 }
GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:44
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
void handleCommonEvents(const TOOL_EVENT &evt)
PCB_BASE_EDIT_FRAME * frame() const
virtual void updateEndItem(const TOOL_EVENT &aEvent)
void SetAuxAxes(bool aEnable, const VECTOR2I &aOrigin=VECTOR2I(0, 0))
#define _(s)
int Net() const
Definition: pns_item.h:148
TOOL_EVENT.
Definition: tool_event.h:171
ITEM * m_startItem
Definition: pns_tool_base.h:68
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:373
ROUTER * m_router
Definition: pns_tool_base.h:78
VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (such a...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:230
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:398
virtual void highlightNet(bool aEnabled, int aNetcode=-1)
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
bool StartDragging(const VECTOR2I &aP, ITEM *aItem, int aDragMode=DM_ANY)
Definition: pns_router.cpp:126
bool IsLocked() const
Definition: pns_item.h:235
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
bool RoutingInProgress() const
Definition: pns_router.cpp:111

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

754 {
755  if( !prepareInteractive() )
756  return;
757 
758  while( TOOL_EVENT* evt = Wait() )
759  {
760  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
761 
762  // Don't crash if we missed an operation that cancelled routing.
763  wxCHECK2( m_router->RoutingInProgress(), break );
764 
765  handleCommonEvents( *evt );
766 
767  if( evt->IsMotion() )
768  {
769  m_router->SetOrthoMode( evt->Modifier( MD_CTRL ) );
770  updateEndItem( *evt );
772  }
773  else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &PCB_ACTIONS::routeSingleTrack ) )
774  {
775  updateEndItem( *evt );
776  bool needLayerSwitch = m_router->IsPlacingVia();
777  bool forceFinish = evt->Modifier( MD_SHIFT );
778 
779 
780  if( m_router->FixRoute( m_endSnapPoint, m_endItem, forceFinish ) )
781  break;
782 
783  if( needLayerSwitch )
785 
786  // Synchronize the indicated layer
788  updateEndItem( *evt );
790  m_startItem = nullptr;
791  }
792  else if( evt->IsAction( &ACT_SwitchPosture ) )
793  {
795  updateEndItem( *evt );
796  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
797  }
798  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
799  {
800  m_router->SwitchLayer( frame()->GetActiveLayer() );
801  updateEndItem( *evt );
802  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
803  }
804  else if( evt->IsAction( &ACT_EndTrack ) )
805  {
806  bool still_routing = true;
807  while( still_routing )
808  still_routing = m_router->FixRoute( m_endSnapPoint, m_endItem );
809  break;
810  }
811  else if( evt->IsCancelInteractive() || evt->IsActivate()
812  || evt->IsUndoRedo()
813  || evt->IsAction( &PCB_ACTIONS::routerInlineDrag ) )
814  {
815  if( evt->IsCancelInteractive() && !m_router->RoutingInProgress() )
816  m_cancelled = true;
817 
818  if( evt->IsActivate() && !evt->IsMoveTool() )
819  m_cancelled = true;
820 
821  break;
822  }
823  else if( evt->IsKeyPressed() )
824  {
825  // wxWidgets fails to correctly translate shifted keycodes on the wxEVT_CHAR_HOOK
826  // event so we need to process the wxEVT_CHAR event that will follow as long as we
827  // pass the event.
828  evt->SetPassEvent();
829  }
830  }
831 
833 }
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
bool finishInteractive()
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
bool IsPlacingVia() const
Definition: pns_router.cpp:498
static const TOOL_ACTION ACT_SwitchPosture("pcbnew.InteractiveRouter.SwitchPosture", AS_CONTEXT, '/', LEGACY_HK_NAME("Switch Track Posture"), _("Switch Track Posture"), _("Switches posture of the currently routed track."), change_entry_orient_xpm)
void SwitchLayer(int layer)
Definition: pns_router.cpp:435
void SetOrthoMode(bool aEnable)
Definition: pns_router.cpp:507
static const TOOL_ACTION ACT_EndTrack("pcbnew.InteractiveRouter.EndTrack", AS_CONTEXT, WXK_END, "", _("Finish Track"), _("Stops laying the current track."), checked_ok_xpm)
void handleCommonEvents(const TOOL_EVENT &evt)
PCB_BASE_EDIT_FRAME * frame() const
virtual void updateEndItem(const TOOL_EVENT &aEvent)
bool prepareInteractive()
TOOL_EVENT.
Definition: tool_event.h:171
ITEM * m_startItem
Definition: pns_tool_base.h:68
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:373
ROUTER * m_router
Definition: pns_tool_base.h:78
void switchLayerOnViaPlacement()
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
Function SetActiveLayer will change the currently active layer to aLayer.
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:230
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:198
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:275
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:178
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
void FlipPosture()
Definition: pns_router.cpp:426
bool RoutingInProgress() const
Definition: pns_router.cpp:111
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:823
int GetCurrentLayer() const
Definition: pns_router.cpp:467

References ACT_EndTrack, ACT_SwitchPosture, BUT_LEFT, finishInteractive(), PNS::ROUTER::FixRoute(), PNS::ROUTER::FlipPosture(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), PNS::ROUTER::GetCurrentLayer(), handleCommonEvents(), PNS::ROUTER::IsPlacingVia(), PCB_ACTIONS::layerChanged, PNS::TOOL_BASE::m_cancelled, PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, MD_CTRL, MD_SHIFT, PNS::ROUTER::Move(), prepareInteractive(), PCB_ACTIONS::routerInlineDrag, PCB_ACTIONS::routeSingleTrack, PNS::ROUTER::RoutingInProgress(), PCB_BASE_FRAME::SetActiveLayer(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), PNS::ROUTER::SetOrthoMode(), PNS::ROUTER::SwitchLayer(), switchLayerOnViaPlacement(), ToLAYER_ID(), PNS::TOOL_BASE::updateEndItem(), and TOOL_INTERACTIVE::Wait().

Referenced by MainLoop().

◆ pickSingleItem()

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

Definition at line 113 of file pns_tool_base.cpp.

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

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

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

◆ prepareInteractive()

bool ROUTER_TOOL::prepareInteractive ( )
private

Definition at line 685 of file router_tool.cpp.

686 {
687  int routingLayer = getStartLayer( m_startItem );
688 
689  if( !IsCopperLayer( routingLayer ) )
690  {
691  DisplayError( frame(), _( "Tracks on Copper layers only" ) );
692  return false;
693  }
694 
695  PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
696 
697  editFrame->SetActiveLayer( ToLAYER_ID( routingLayer ) );
698 
699  // Force layer visible
700  editFrame->GetLayerManager()->SetLayerVisible( routingLayer, true );
701 
702  // for some reason I don't understand, GetNetclass() may return null sometimes...
703  if( m_startItem && m_startItem->Net() >= 0 &&
705  {
706  highlightNet( true, m_startItem->Net() );
707  // Update track width and via size shown in main toolbar comboboxes
708  editFrame->SetCurrentNetClass( m_startItem->Parent()->GetNetClass()->GetName() );
709  }
710  else
712 
713  controls()->ForceCursorPosition( false );
714  controls()->SetAutoPan( true );
715 
716  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
717 
718  sizes.Init( board(), m_startItem );
719  sizes.AddLayerPair( frame()->GetScreen()->m_Route_Layer_TOP,
720  frame()->GetScreen()->m_Route_Layer_BOTTOM );
721  m_router->UpdateSizes( sizes );
722 
723  if( !m_router->StartRouting( m_startSnapPoint, m_startItem, routingLayer ) )
724  {
726  highlightNet( false );
727  controls()->SetAutoPan( false );
728  return false;
729  }
730 
731  m_endItem = nullptr;
733 
734  frame()->UndoRedoBlock( true );
735 
736  return true;
737 }
const wxString & FailureReason() const
Definition: pns_router.h:217
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:236
BOARD_CONNECTED_ITEM * Parent() const
Definition: pns_item.h:145
BOARD * board() const
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
void UndoRedoBlock(bool aBlock=true)
Function UndoRedoBlock Enables/disable undo and redo operations.
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:209
bool SetCurrentNetClass(const wxString &aNetClassName)
Function SetCurrentNetClass Must be called after a netclass selection (or after a netclass parameter ...
PCB_BASE_EDIT_FRAME * frame() const
#define _(s)
static const char Default[]
the name of the default NETCLASS
Definition: netclass.h:80
int Net() const
Definition: pns_item.h:148
ITEM * m_startItem
Definition: pns_tool_base.h:68
void Init(BOARD *aBoard, ITEM *aStartItem=NULL, int aNet=-1)
ROUTER * m_router
Definition: pns_tool_base.h:78
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
PCB_LAYER_WIDGET * GetLayerManager()
bool StartRouting(const VECTOR2I &aP, ITEM *aItem, int aLayer)
Definition: pns_router.cpp:175
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:317
KIGFX::VIEW_CONTROLS * controls() const
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
std::shared_ptr< NETCLASS > GetNetClass() const
Function GetNetClass returns the NETCLASS for this item.
PCB_EDIT_FRAME is the main frame for Pcbnew.
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
void SetLayerVisible(LAYER_NUM aLayer, bool isVisible)
Function SetLayerVisible sets aLayer visible or not.
int getStartLayer(const PNS::ITEM *aItem)
void SetActiveLayer(PCB_LAYER_ID aLayer) override
Function SetActiveLayer will change the currently active layer to aLayer and also update the PCB_LAYE...
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:823

References _, PCB_TOOL_BASE::board(), PCB_TOOL_BASE::controls(), NETCLASS::Default, DisplayError(), PNS::ROUTER::FailureReason(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_EDIT_FRAME::GetLayerManager(), BOARD_CONNECTED_ITEM::GetNetClass(), getStartLayer(), PNS::TOOL_BASE::highlightNet(), PNS::SIZES_SETTINGS::Init(), IsCopperLayer(), PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, PNS::ITEM::Net(), PNS::ITEM::Parent(), PCB_EDIT_FRAME::SetActiveLayer(), KIGFX::VIEW_CONTROLS::SetAutoPan(), PCB_EDIT_FRAME::SetCurrentNetClass(), LAYER_WIDGET::SetLayerVisible(), PNS::ROUTER::Sizes(), PNS::ROUTER::StartRouting(), ToLAYER_ID(), PCB_BASE_EDIT_FRAME::UndoRedoBlock(), and PNS::ROUTER::UpdateSizes().

Referenced by performRouting().

◆ Reset()

void ROUTER_TOOL::Reset ( RESET_REASON  aReason)
overridevirtual

Function Reset() Brings the tool to a known, initial state.

If the tool claimed anything from the model or the view, it must release it when its reset.

Parameters
aReasoncontains information about the reason of tool reset.

Reimplemented from PNS::TOOL_BASE.

Definition at line 442 of file router_tool.cpp.

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

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

◆ Router()

ROUTER * TOOL_BASE::Router ( ) const
inherited

Definition at line 376 of file pns_tool_base.cpp.

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

References PNS::TOOL_BASE::m_router.

Referenced by EDIT_TOOL::Remove().

◆ RunMainStack()

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

Function RunMainStack()

Calls a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 87 of file tool_interactive.cpp.

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

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

Referenced by DRAWING_TOOL::PlaceText().

◆ SelectCopperLayerPair()

int ROUTER_TOOL::SelectCopperLayerPair ( const TOOL_EVENT aEvent)

Definition at line 260 of file sel_layer.cpp.

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

References _, DisplayInfoMessage(), PCB_TOOL_BASE::frame(), GetBoard(), SELECT_COPPER_LAYERS_PAIR_DIALOG::GetLayerPair(), PCB_BASE_FRAME::GetScreen(), PCB_SCREEN::m_Route_Layer_BOTTOM, and PCB_SCREEN::m_Route_Layer_TOP.

Referenced by setTransitions().

◆ selection() [1/2]

const PCBNEW_SELECTION & PCB_TOOL_BASE::selection ( ) const
protectedinherited

Definition at line 269 of file pcb_tool_base.cpp.

270 {
271  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
272  const auto& selection = selTool->GetSelection();
273  return selection;
274 }
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(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawZone(), EDIT_TOOL::Duplicate(), EDIT_TOOL::EditFpInFpEditor(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), EDIT_TOOL::Flip(), DRAWING_TOOL::getSourceZoneForAction(), PCB_INSPECTION_TOOL::highlightNet(), InlineBreakTrack(), InlineDrag(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::Move(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PAD_TOOL::pastePadProperties(), PCBNEW_CONTROL::placeBoardItems(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EDIT_TOOL::Rotate(), PCB_TOOL_BASE::selection(), SELECTION_TOOL::selectNet(), DRAWING_TOOL::SetAnchor(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), PCBNEW_CONTROL::UpdateMessagePanel(), PCB_INSPECTION_TOOL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), PCB_EDITOR_CONTROL::ZoneDuplicate(), ZONE_FILLER_TOOL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfill().

◆ selection() [2/2]

PCBNEW_SELECTION & PCB_TOOL_BASE::selection ( )
protectedinherited

Definition at line 277 of file pcb_tool_base.cpp.

278 {
279  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
280  auto& selection = selTool->GetSelection();
281  return selection;
282 }
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(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), TOOL_MENU::ShowContextMenu(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ SetEditModules()

void PCB_TOOL_BASE::SetEditModules ( bool  aEnabled)
inlineinherited

Function SetEditModules()

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

Parameters
aEnableddecides if the mode should be enabled.

Definition at line 97 of file pcb_tool_base.h.

98  {
99  m_editModules = aEnabled;
100  }

References PCB_TOOL_BASE::m_editModules.

◆ SettingsDialog()

int ROUTER_TOOL::SettingsDialog ( const TOOL_EVENT aEvent)

Definition at line 856 of file router_tool.cpp.

857 {
858  DIALOG_PNS_SETTINGS settingsDlg( frame(), m_router->Settings() );
859 
860  if( settingsDlg.ShowModal() == wxID_OK )
862 
863  return 0;
864 }
PCB_BASE_EDIT_FRAME * frame() const
ROUTER * m_router
Definition: pns_tool_base.h:78
ROUTING_SETTINGS m_savedSettings
Stores routing settings between router invocations.
Definition: pns_tool_base.h:66
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:190

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

Referenced by setTransitions().

◆ setTransitions()

void ROUTER_TOOL::setTransitions ( )
overridevirtual

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

It is called every time tool is reset or finished.

Reimplemented from PCB_TOOL_BASE.

Definition at line 1296 of file router_tool.cpp.

1297 {
1299 
1306 
1312 
1315 }
int MainLoop(const TOOL_EVENT &aEvent)
static TOOL_ACTION selectLayerPair
Definition: pcb_actions.h:135
static const TOOL_ACTION ACT_PlaceMicroVia("pcbnew.InteractiveRouter.PlaceMicroVia", AS_CONTEXT, MD_CTRL+ 'V', LEGACY_HK_NAME("Add MicroVia"), _("Place Microvia"), _("Adds a microvia at the end of currently routed track."), via_microvia_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::MICROVIA)
int DpDimensionsDialog(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerDiffPairDialog
Definition: pcb_actions.h:194
int InlineDrag(const TOOL_EVENT &aEvent)
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:285
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
int onViaCommand(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerSettingsDialog
Activation of the Push and Shove settings dialogs.
Definition: pcb_actions.h:193
static const TOOL_ACTION ACT_CustomTrackWidth("pcbnew.InteractiveRouter.CustomTrackViaSize", AS_CONTEXT, 'Q', LEGACY_HK_NAME("Custom Track/Via Size"), _("Custom Track/Via Size..."), _("Shows a dialog for changing the track width and via size."), width_track_xpm)
int SettingsDialog(const TOOL_EVENT &aEvent)
static const TOOL_ACTION ACT_SelLayerAndPlaceThroughVia("pcbnew.InteractiveRouter.SelLayerAndPlaceVia", AS_CONTEXT, '<', LEGACY_HK_NAME("Select Layer and Add Through Via"), _("Select Layer and Place Through Via..."), _("Select a layer, then add a through-hole via at the end of currently routed track."), select_w_layer_xpm, AF_NONE,(void *)(VIA_ACTION_FLAGS::VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
int CustomTrackWidthDialog(const TOOL_EVENT &aEvent)
int onTrackViaSizeChanged(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:198
static TOOL_ACTION inlineBreakTrack
Breaks track when router is not activated.
Definition: pcb_actions.h:141
static const TOOL_ACTION ACT_PlaceThroughVia("pcbnew.InteractiveRouter.PlaceVia", AS_CONTEXT, 'V', LEGACY_HK_NAME("Add Through Via"), _("Place Through Via"), _("Adds a through-hole via at the end of currently routed track."), via_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::VIA)
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:178
TOOL_EVENT MakeEvent() const
Function MakeEvent() Returns the event associated with the action (i.e.
Definition: tool_action.h:107
int InlineBreakTrack(const TOOL_EVENT &aEvent)
int SelectCopperLayerPair(const TOOL_EVENT &aEvent)
Definition: sel_layer.cpp:260
static const TOOL_ACTION ACT_PlaceBlindVia("pcbnew.InteractiveRouter.PlaceBlindVia", AS_CONTEXT, MD_ALT+MD_SHIFT+ 'V', LEGACY_HK_NAME("Add Blind/Buried Via"), _("Place Blind/Buried Via"), _("Adds a blind or buried via at the end of currently routed track."), via_buried_xpm, AF_NONE,(void *) VIA_ACTION_FLAGS::BLIND_VIA)
static const TOOL_ACTION ACT_SelLayerAndPlaceBlindVia("pcbnew.InteractiveRouter.SelLayerAndPlaceBlindVia", AS_CONTEXT, MD_ALT+'<', LEGACY_HK_NAME("Select Layer and Add Blind/Buried Via"), _("Select Layer and Place Blind/Buried Via..."), _("Select a layer, then add a blind or buried via at the end of currently routed track."), select_w_layer_xpm, AF_NONE,(void *)(VIA_ACTION_FLAGS::BLIND_VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:181

References ACT_CustomTrackWidth, ACT_PlaceBlindVia, ACT_PlaceMicroVia, ACT_PlaceThroughVia, ACT_SelLayerAndPlaceBlindVia, ACT_SelLayerAndPlaceThroughVia, CustomTrackWidthDialog(), DpDimensionsDialog(), TOOL_INTERACTIVE::Go(), InlineBreakTrack(), PCB_ACTIONS::inlineBreakTrack, InlineDrag(), MainLoop(), TOOL_ACTION::MakeEvent(), onTrackViaSizeChanged(), onViaCommand(), PCB_ACTIONS::routeDiffPair, PCB_ACTIONS::routerDiffPairDialog, PCB_ACTIONS::routerInlineDrag, PCB_ACTIONS::routerSettingsDialog, PCB_ACTIONS::routeSingleTrack, SelectCopperLayerPair(), PCB_ACTIONS::selectLayerPair, SettingsDialog(), and PCB_ACTIONS::trackViaSizeChanged.

◆ snapToItem()

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

Definition at line 382 of file pns_tool_base.cpp.

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

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

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

◆ switchLayerOnViaPlacement()

void ROUTER_TOOL::switchLayerOnViaPlacement ( )
private

Definition at line 484 of file router_tool.cpp.

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

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

298 {
299  int layer;
300  bool snapEnabled = !aEvent.Modifier( MD_SHIFT );
301  m_gridHelper->SetUseGrid( !aEvent.Modifier( MD_ALT ) );
302  m_gridHelper->SetSnap( snapEnabled );
303 
304  controls()->ForceCursorPosition( false );
305  VECTOR2I mousePos = controls()->GetMousePosition();
306 
307  if( m_router->Settings().Mode() != RM_MarkObstacles &&
308  ( m_router->GetCurrentNets().empty() || m_router->GetCurrentNets().front() < 0 ) )
309  {
310  m_endSnapPoint = snapToItem( snapEnabled, nullptr, mousePos );
312  m_endItem = nullptr;
313 
314  return;
315  }
316 
317  if( m_router->IsPlacingVia() )
318  layer = -1;
319  else
320  layer = m_router->GetCurrentLayer();
321 
322  ITEM* endItem = nullptr;
323 
324  std::vector<int> nets = m_router->GetCurrentNets();
325 
326  for( int net : nets )
327  {
328  endItem = pickSingleItem( mousePos, net, layer, false, { m_startItem } );
329 
330  if( endItem )
331  break;
332  }
333 
334  if( checkSnap( endItem ) )
335  {
336  m_endItem = endItem;
337  m_endSnapPoint = snapToItem( snapEnabled, endItem, mousePos );
338  } else {
339  m_endItem = nullptr;
340  m_endSnapPoint = m_gridHelper->Align( mousePos );
341  }
342 
344 
345  if( m_endItem )
346  {
347  wxLogTrace( "PNS", "%s, layer : %d", m_endItem->KindStr().c_str(), m_endItem->Layers().Start() );
348  }
349 }
GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
bool IsPlacingVia() const
Definition: pns_router.cpp:498
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:458
const VECTOR2I snapToItem(bool aEnabled, ITEM *aItem, VECTOR2I aP)
int Start() const
Definition: pns_layerset.h:83
std::string KindStr() const
Function KindStr()
Definition: pns_item.cpp:71
bool checkSnap(ITEM *aItem)
ITEM * m_startItem
Definition: pns_tool_base.h:68
ROUTER * m_router
Definition: pns_tool_base.h:78
PNS_MODE Mode() const
Returns the routing mode.
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
void SetSnap(bool aSnap)
Definition: grid_helper.h:80
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:342
VECTOR2I Align(const VECTOR2I &aPoint) const
KIGFX::VIEW_CONTROLS * controls() const
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
virtual ITEM * pickSingleItem(const VECTOR2I &aWhere, int aNet=-1, int aLayer=-1, bool aIgnorePads=false, const std::vector< ITEM * > aAvoidItems={})
void SetUseGrid(bool aGrid=true)
Definition: grid_helper.h:90
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:190
const LAYER_RANGE & Layers() const
Definition: pns_item.h:150
int GetCurrentLayer() const
Definition: pns_router.cpp:467

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

262 {
263  int tl = getView()->GetTopLayer();
264  VECTOR2I cp = controls()->GetCursorPosition( !aEvent.Modifier( MD_SHIFT ) );
265  VECTOR2I p;
266 
267  controls()->ForceCursorPosition( false );
268  m_gridHelper->SetUseGrid( !aEvent.Modifier( MD_ALT ) );
269  m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
270 
271  bool snapEnabled = true;
272 
273  if( aEvent.IsMotion() || aEvent.IsClick() )
274  {
275  snapEnabled = !aEvent.Modifier( MD_SHIFT );
276  p = aEvent.Position();
277  }
278  else
279  {
280  p = cp;
281  }
282 
283  m_startItem = pickSingleItem( p, -1, -1, aIgnorePads );
284 
285  if( !snapEnabled && m_startItem && !m_startItem->Layers().Overlaps( tl ) )
286  m_startItem = nullptr;
287 
288  m_startSnapPoint = snapToItem( snapEnabled, m_startItem, p );
289 
290  if( checkSnap( m_startItem ) )
291  {
293  }
294 }
GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
bool IsClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.cpp:178
bool IsMotion() const
Definition: tool_event.h:306
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:68
const VECTOR2I snapToItem(bool aEnabled, ITEM *aItem, VECTOR2I aP)
bool checkSnap(ITEM *aItem)
virtual int GetTopLayer() const
Definition: view.cpp:851
ITEM * m_startItem
Definition: pns_tool_base.h:68
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
void SetSnap(bool aSnap)
Definition: grid_helper.h:80
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:90
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:150
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.

References PNS::TOOL_BASE::checkSnap(), PCB_TOOL_BASE::controls(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), KIGFX::VIEW::GetTopLayer(), TOOL_BASE::getView(), TOOL_EVENT::IsClick(), TOOL_EVENT::IsMotion(), PNS::ITEM::Layers(), PNS::TOOL_BASE::m_gridHelper, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, MD_ALT, MD_SHIFT, TOOL_EVENT::Modifier(), LAYER_RANGE::Overlaps(), PNS::TOOL_BASE::pickSingleItem(), TOOL_EVENT::Position(), GRID_HELPER::SetSnap(), GRID_HELPER::SetUseGrid(), and PNS::TOOL_BASE::snapToItem().

Referenced by MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), and onViaCommand().

◆ view()

◆ Wait()

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

Function Wait()

Suspends execution of the tool until an event specified in aEventList arrives. No parameters means waiting for any event.

Definition at line 57 of file tool_interactive.cpp.

58 {
59  return m_toolMgr->ScheduleWait( this, aEventList );
60 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
TOOL_EVENT * ScheduleWait(TOOL_BASE *aTool, const TOOL_EVENT_LIST &aConditions)
Pauses execution of a given tool until one or more events matching aConditions arrives.

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

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

Member Data Documentation

◆ m_cancelled

bool PNS::TOOL_BASE::m_cancelled
protectedinherited

◆ m_editModules

◆ m_endItem

◆ m_endSnapPoint

VECTOR2I PNS::TOOL_BASE::m_endSnapPoint
protectedinherited

◆ m_gridHelper

◆ m_iface

◆ m_menu

TOOL_MENU TOOL_INTERACTIVE::m_menu
protectedinherited

functions below are not yet implemented - their interface may change

Definition at line 108 of file tool_interactive.h.

Referenced by SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), TOOL_INTERACTIVE::GetToolMenu(), PICKER_TOOL::Init(), SCH_EDIT_TOOL::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init(), LIB_DRAWING_TOOLS::Init(), MODULE_EDITOR_TOOLS::Init(), LIB_CONTROL::Init(), PCB_EDITOR_CONTROL::Init(), SCH_DRAWING_TOOLS::Init(), GERBVIEW_SELECTION_TOOL::Init(), DRAWING_TOOL::Init(), EE_SELECTION_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), SELECTION_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), EDIT_TOOL::Init(), PCB_TOOL_BASE::Init(), SCH_MOVE_TOOL::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ m_panelItems

MSG_PANEL_ITEMS PNS::TOOL_BASE::m_panelItems
protectedinherited

Definition at line 64 of file pns_tool_base.h.

◆ m_router

◆ m_savedSettings

ROUTING_SETTINGS PNS::TOOL_BASE::m_savedSettings
protectedinherited

Stores routing settings between router invocations.

Definition at line 66 of file pns_tool_base.h.

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

◆ m_savedSizes

SIZES_SETTINGS PNS::TOOL_BASE::m_savedSizes
protectedinherited

Stores sizes settings between router invocations.

Definition at line 67 of file pns_tool_base.h.

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

◆ m_startHighlight

bool PNS::TOOL_BASE::m_startHighlight
protectedinherited

Keeps track of whether the net was highlighted before routing.

Definition at line 71 of file pns_tool_base.h.

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

◆ m_startItem

◆ m_startLayer

int PNS::TOOL_BASE::m_startLayer
protectedinherited

Definition at line 69 of file pns_tool_base.h.

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

◆ m_startSnapPoint

VECTOR2I PNS::TOOL_BASE::m_startSnapPoint
protectedinherited

◆ m_toolId

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

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

Definition at line 214 of file tool_base.h.

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

◆ m_toolMgr

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 219 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), EE_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemToSel(), SELECTION_TOOL::AddItemToSel(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), CanInlineDrag(), EDIT_TOOL::ChangeTrackWidth(), PCB_INSPECTION_TOOL::ClearHighlight(), SCH_EDITOR_CONTROL::ClearHighlight(), SELECTION_TOOL::ClearSelection(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), LIB_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), COMMON_TOOLS::CursorControl(), CustomTrackWidthDialog(), SCH_EDITOR_CONTROL::Cut(), LIB_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), LIB_EDIT_TOOL::DoDelete(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::editComponentFieldText(), EDIT_TOOL::EditFpInFpEditor(), LIB_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithLibEdit(), SCH_EDITOR_CONTROL::EnterSheet(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), SELECTION_TOOL::findCallback(), SCH_EDITOR_CONTROL::FindComponentAndItem(), POINT_EDITOR::finishItem(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), EDIT_TOOL::GetAndPlace(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), GERBVIEW_CONTROL::HighlightControl(), PCB_INSPECTION_TOOL::HighlightItem(), PCB_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_INSPECTION_TOOL::highlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_INSPECTION_TOOL::HighlightNetTool(), MODULE_EDITOR_TOOLS::ImportFootprint(), LIB_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), PAD_TOOL::Init(), GLOBAL_EDIT_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), LIB_CONTROL::Init(), PCB_EDITOR_CONTROL::Init(), POINT_EDITOR::Init(), POSITION_RELATIVE_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), EDIT_TOOL::Init(), InlineBreakTrack(), InlineDrag(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), TOOL_BASE::IsToolActive(), SCH_EDITOR_CONTROL::LeaveSheet(), COMMON_CONTROL::ListHotKeys(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), SCH_MOVE_TOOL::Main(), CVPCB_CONTROL::Main(), LIB_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::Move(), EDIT_TOOL::MoveExact(), LIB_CONTROL::OnDeMorgan(), LIB_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), EDIT_TOOL::pickCopyReferencePoint(), LIB_EDIT_TOOL::PinTable(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PCBNEW_CONTROL::Print(), GERBVIEW_CONTROL::Print(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EE_SELECTION_TOOL::RebuildSelection(), LIB_EDIT_TOOL::Redo(), SCH_EDITOR_CONTROL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), EE_SELECTION_TOOL::RemoveItemFromSel(), SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_DRAWING_TOOLS::RepeatDrawItem(), EE_SELECTION_TOOL::RequestSelection(), SELECTION_TOOL::RequestSelection(), COMMON_TOOLS::ResetLocalCoords(), TOOL_INTERACTIVE::resetTransitions(), LIB_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), DRC::RunTests(), EE_SELECTION_TOOL::SelectConnection(), PCB_TOOL_BASE::selection(), COMMON_TOOLS::SelectionTool(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), GERBVIEW_SELECTION_TOOL::selectPoint(), EE_SELECTION_TOOL::SelectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), SELECTION_TOOL::selectSheetContents(), DRAWING_TOOL::SetAnchor(), TOOL_INTERACTIVE::SetContextMenu(), DRC::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), LIB_EDIT_TOOL::Undo(), SCH_EDITOR_CONTROL::Undo(), GERBVIEW_SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PCBNEW_CONTROL::UpdateMessagePanel(), PCB_INSPECTION_TOOL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), and PCB_EDITOR_CONTROL::ZoneMerge().

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Name of the tool.

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

Definition at line 218 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_toolSettings

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 220 of file tool_base.h.

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

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 211 of file tool_base.h.

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


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