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 }
 Determine the reason of reset for a tool. More...
 

Public Member Functions

 ROUTER_TOOL ()
 
 ~ROUTER_TOOL ()
 
bool Init () override
 Init() is called once upon a registration of the tool. More...
 
void Reset (RESET_REASON aReason) override
 Bring the tool to a known, initial state. More...
 
int MainLoop (const TOOL_EVENT &aEvent)
 
int InlineBreakTrack (const TOOL_EVENT &aEvent)
 
bool CanInlineDrag (int aDragMode)
 
int InlineDrag (const TOOL_EVENT &aEvent)
 
int SelectCopperLayerPair (const TOOL_EVENT &aEvent)
 
int DpDimensionsDialog (const TOOL_EVENT &aEvent)
 
int SettingsDialog (const TOOL_EVENT &aEvent)
 
int ChangeRouterMode (const TOOL_EVENT &aEvent)
 
int CycleRouterMode (const TOOL_EVENT &aEvent)
 
int CustomTrackWidthDialog (const TOOL_EVENT &aEvent)
 
PNS::PNS_MODE GetRouterMode ()
 
bool RoutingInProgress ()
 Returns whether routing is currently active. More...
 
void setTransitions () override
 This method is meant to be overridden in order to specify handlers for events. More...
 
void UpdateMessagePanel ()
 
ROUTER * Router () const
 
void SetIsFootprintEditor (bool aEnabled)
 Function SetIsFootprintEditor() More...
 
bool IsFootprintEditor () const
 
virtual bool Is45Limited () const
 Should the tool use its 45° mode option? More...
 
void Activate ()
 Run the tool. More...
 
TOOL_MENUGetToolMenu ()
 
void SetContextMenu (ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Assign a context menu and tells when it should be activated. More...
 
void RunMainStack (std::function< void()> aFunc)
 Call a function using the main stack. More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Define which state (aStateFunc) to go when a certain event arrives (aConditions). More...
 
TOOL_EVENTWait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Suspend execution of the tool until an event specified in aEventList arrives. More...
 
TOOL_TYPE GetType () const
 Return the type of the tool. More...
 
TOOL_ID GetId () const
 Return the unique identifier of the tool. More...
 
const std::string & GetName () const
 Return the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Return the instance of TOOL_MANAGER that takes care of the tool. More...
 
bool IsToolActive () const
 

Static Public Member Functions

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

Protected Types

enum  INTERACTIVE_PLACEMENT_OPTIONS { IPO_ROTATE = 0x01, IPO_FLIP = 0x02, IPO_SINGLE_CLICK = 0x04, IPO_REPEAT = 0x08 }
 Options for placing items interactively. More...
 

Protected Member Functions

bool checkSnap (ITEM *aItem)
 
const VECTOR2I snapToItem (ITEM *aSnapToItem, const 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 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
 
FOOTPRINTfootprint () const
 
const PCB_DISPLAY_OPTIONSdisplayOptions () const
 
PCB_DRAW_PANEL_GALcanvas () const
 
const PCB_SELECTIONselection () const
 
PCB_SELECTIONselection ()
 
void attachManager (TOOL_MANAGER *aManager)
 Set the TOOL_MANAGER the tool will belong to. More...
 
KIGFX::VIEWgetView () const
 Returns the instance of #VIEW object used in the application. More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Return the instance of VIEW_CONTROLS object used in the application. More...
 
template<typename T >
T * getEditFrame () const
 Return the application window object, casted to requested user type. More...
 
template<typename T >
T * getModel () const
 Return the model object if it matches the requested type. More...
 

Protected Attributes

SIZES_SETTINGS m_savedSizes
 
ITEM * m_startItem
 
VECTOR2I m_startSnapPoint
 
bool m_startHighlight
 
ITEM * m_endItem
 
VECTOR2I m_endSnapPoint
 
PCB_GRID_HELPERm_gridHelper
 
PNS_KICAD_IFACEm_iface
 
ROUTER * m_router
 
bool m_cancelled
 
bool m_isFootprintEditor
 
TOOL_MENU m_menu
 The functions below are not yet implemented - their interface may change. More...
 
TOOL_TYPE m_type
 Unique identifier for the tool, assigned by a TOOL_MANAGER instance. More...
 
TOOL_ID m_toolId
 Name of the tool. More...
 
std::string m_toolName
 
TOOL_MANAGERm_toolMgr
 

Private Member Functions

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

Private Attributes

std::shared_ptr< ACTION_MENUm_diffPairMenu
 
std::shared_ptr< ACTION_MENUm_trackViaMenu
 
int m_lastTargetLayer
 

Detailed Description

Definition at line 28 of file router_tool.h.

Member Enumeration Documentation

◆ INTERACTIVE_PLACEMENT_OPTIONS

Options for placing items interactively.

Enumerator
IPO_ROTATE 

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

IPO_FLIP 

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

IPO_SINGLE_CLICK 

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

IPO_REPEAT 

Allow repeat placement of the item.

Definition at line 116 of file pcb_tool_base.h.

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

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

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

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

Constructor & Destructor Documentation

◆ ROUTER_TOOL()

ROUTER_TOOL::ROUTER_TOOL ( )

Definition at line 171 of file router_tool.cpp.

171  :
172  TOOL_BASE( "pcbnew.InteractiveRouter" ),
174 {
175 }
TOOL_BASE(const std::string &aToolName)
int m_lastTargetLayer
Definition: router_tool.h:91

◆ ~ROUTER_TOOL()

ROUTER_TOOL::~ROUTER_TOOL ( )

Definition at line 421 of file router_tool.cpp.

422 {
423 }

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Run 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:214
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209
bool InvokeTool(TOOL_ID aToolId)
Call 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(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), PAD_TOOL::EnumeratePads(), PCB_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), InlineBreakTrack(), InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), PCB_PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PICKER_TOOL::Main(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), LIB_TREE::onContextMenu(), PCB_POINT_EDITOR::OnSelectionChange(), GROUP_TOOL::PickNewMember(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Set the TOOL_MANAGER the tool will belong to.

Called by TOOL_MANAGER::RegisterTool()

Definition at line 60 of file tool_base.cpp.

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

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ board()

BOARD* PCB_TOOL_BASE::board ( ) const
inlineprotectedinherited

Definition at line 165 of file pcb_tool_base.h.

165 { return getModel<BOARD>(); }

Referenced by PCB_CONTROL::AppendBoard(), AUTOPLACE_TOOL::autoplace(), BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), EDIT_TOOL::ChangeTrackWidth(), ZONE_FILLER_TOOL::CheckAllZones(), BOARD_INSPECTION_TOOL::ClearHighlight(), EDIT_TOOL::copyToClipboard(), FOOTPRINT_EDITOR_CONTROL::CreateFootprint(), MICROWAVE_TOOL::createInductorBetween(), CustomTrackWidthDialog(), PCB_CONTROL::DeleteItemCursor(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), BOARD_EDITOR_CONTROL::ExportNetlist(), ZONE_FILLER_TOOL::FillAllZones(), EDIT_TOOL::FilletTracks(), PCB_SELECTION_TOOL::filterSelection(), PCB_TOOL_BASE::footprint(), PCB_SELECTION_TOOL::GetBoard(), PCB_SELECTION_TOOL::getCollectorsGuide(), GROUP_TOOL::Group(), handleLayerSwitch(), BOARD_INSPECTION_TOOL::highlightNet(), InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), PCB_CONTROL::LayerNext(), PCB_CONTROL::LayerPrev(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), EDIT_TOOL::MoveExact(), FOOTPRINT_EDITOR_CONTROL::NewFootprint(), PCB_CONTROL::Paste(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PAD_TOOL::PlacePad(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PCB_SELECTION_TOOL::RebuildSelection(), PAD_TOOL::recombinePad(), BOARD_EDITOR_CONTROL::RepairBoard(), FOOTPRINT_EDITOR_CONTROL::RepairFootprint(), PNS::TOOL_BASE::Reset(), PCB_CONTROL::Reset(), PCB_SELECTION_TOOL::Selectable(), PCB_SELECTION_TOOL::selectAllItemsOnNet(), PCB_SELECTION_TOOL::selectAllItemsOnSheet(), PCB_SELECTION_TOOL::selectConnectedTracks(), PCB_SELECTION_TOOL::selectionContains(), PCB_SELECTION_TOOL::selectPoint(), PCB_CONTROL::TrackDisplayMode(), PCB_CONTROL::unfilledZoneCheck(), GROUP_TOOL::Ungroup(), UpdateMessagePanel(), PCB_CONTROL::ViaDisplayMode(), PCB_CONTROL::ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), BOARD_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

◆ breakTrack()

void ROUTER_TOOL::breakTrack ( )
private

Definition at line 1342 of file router_tool.cpp.

1343 {
1346 }
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
void BreakSegment(ITEM *aItem, const VECTOR2I &aP)
Definition: pns_router.cpp:854
ITEM * m_startItem
Definition: pns_tool_base.h:69
ROUTER * m_router
Definition: pns_tool_base.h:78
bool OfKind(int aKindMask) const
Return true if the item's type matches the mask aKindMask.
Definition: pns_item.h:138

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

Definition at line 1649 of file router_tool.cpp.

1650 {
1652  const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1653 
1654  if( selection.Size() == 1 )
1655  {
1656  const BOARD_ITEM* item = static_cast<const BOARD_ITEM*>( selection.Front() );
1657 
1658  // Note: EDIT_TOOL::Drag temporarily handles items of type PCB_ARC_T on its own using
1659  // DragArcTrack(), so PCB_ARC_T should never occur here.
1661  {
1662  static const KICAD_T footprints[] = { PCB_FOOTPRINT_T, EOT };
1663 
1664  // Footprints cannot be dragged freely.
1665  if( item->IsType( footprints ) )
1666  return !( aDragMode & PNS::DM_FREE_ANGLE );
1667  else
1668  return true;
1669  }
1670  }
1671 
1672  return false;
1673 }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
const PCB_SELECTION & selection() const
virtual bool IsType(const KICAD_T aScanTypes[]) const
Check whether the item is one of the listed types.
Definition: eda_item.h:182
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
static const KICAD_T DraggableItems[]
A scan list for items that can be dragged.
Definition: collectors.h:313
static void NeighboringSegmentFilter(const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector)
int Size() const
Returns the number of selected parts.
Definition: selection.h:104
The selection tool: currently supports:
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:56
EDA_ITEM * Front() const
Definition: selection.h:145

References PNS::DM_FREE_ANGLE, GENERAL_COLLECTOR::DraggableItems, EOT, SELECTION::Front(), TOOL_MANAGER::GetTool(), EDA_ITEM::IsType(), TOOL_BASE::m_toolMgr, NeighboringSegmentFilter(), PCB_FOOTPRINT_T, TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionCursor, and SELECTION::Size().

◆ canvas()

◆ ChangeRouterMode()

int ROUTER_TOOL::ChangeRouterMode ( const TOOL_EVENT aEvent)

Definition at line 1301 of file router_tool.cpp.

1302 {
1303  PNS::PNS_MODE mode = aEvent.Parameter<PNS::PNS_MODE>();
1304  PNS::ROUTING_SETTINGS& settings = m_router->Settings();
1305 
1306  settings.SetMode( mode );
1307 
1308  return 0;
1309 }
Contain all persistent settings of the router, such as the mode, optimization effort,...
void SetMode(PNS_MODE aMode)
Return the optimizer effort. Bigger means cleaner traces, but slower routing.
PNS_MODE
< Routing modes
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:432
ROUTER * m_router
Definition: pns_tool_base.h:78
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:182

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

Referenced by setTransitions().

◆ checkSnap()

bool TOOL_BASE::checkSnap ( ITEM aItem)
protectedinherited

Definition at line 243 of file pns_tool_base.cpp.

244 {
245  // Sync PNS engine settings with the general PCB editor options.
246  auto& pnss = m_router->Settings();
247 
248  // If we're dragging a track segment, don't try to snap to items on the same copper layer.
249  // This way we avoid 'flickery' behaviour for short segments when the snap algo is trying to
250  // snap to the corners of the segments next to the one being dragged.
251  if( m_startItem && aItem && m_router->GetState() == ROUTER::DRAG_SEGMENT
252  && aItem->Layer() == m_startItem->Layer() && aItem->OfKind( ITEM::SEGMENT_T )
254  return false;
255 
256  pnss.SetSnapToPads(
257  frame()->GetMagneticItemsSettings()->pads == MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL ||
258  frame()->GetMagneticItemsSettings()->pads == MAGNETIC_OPTIONS::CAPTURE_ALWAYS );
259 
260  pnss.SetSnapToTracks(
261  frame()->GetMagneticItemsSettings()->tracks == MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL
262  || frame()->GetMagneticItemsSettings()->tracks == MAGNETIC_OPTIONS::CAPTURE_ALWAYS );
263 
264  if( aItem )
265  {
266  if( aItem->OfKind( ITEM::VIA_T | ITEM::SEGMENT_T | ITEM::ARC_T ) )
267  return pnss.GetSnapToTracks();
268  else if( aItem->OfKind( ITEM::SOLID_T ) )
269  return pnss.GetSnapToPads();
270  }
271 
272  return false;
273 }
virtual int Layer() const
Definition: pns_item.h:158
PCB_BASE_EDIT_FRAME * frame() const
ITEM * m_startItem
Definition: pns_tool_base.h:69
ROUTER * m_router
Definition: pns_tool_base.h:78
void SetSnapToPads(bool aSnap)
bool OfKind(int aKindMask) const
Return true if the item's type matches the mask aKindMask.
Definition: pns_item.h:138
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:182
RouterState GetState() const
Definition: pns_router.h:134

References PNS::ITEM::ARC_T, CAPTURE_ALWAYS, CAPTURE_CURSOR_IN_TRACK_TOOL, PNS::ROUTER::DRAG_SEGMENT, PCB_TOOL_BASE::frame(), PNS::ROUTER::GetState(), PNS::ITEM::Layer(), PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, 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().

◆ controls()

◆ CustomTrackWidthDialog()

int ROUTER_TOOL::CustomTrackWidthDialog ( const TOOL_EVENT aEvent)

Definition at line 2037 of file router_tool.cpp.

2038 {
2040  DIALOG_TRACK_VIA_SIZE sizeDlg( frame(), bds );
2041 
2042  if( sizeDlg.ShowModal() == wxID_OK )
2043  {
2044  bds.m_TempOverrideTrackWidth = true;
2045  bds.UseCustomTrackViaSize( true );
2046 
2047  TOOL_EVENT dummy;
2049  }
2050 
2051  return 0;
2052 }
BOARD * board() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
PCB_BASE_EDIT_FRAME * frame() const
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
Generic, UI-independent tool event.
Definition: tool_event.h:152
int onTrackViaSizeChanged(const TOOL_EVENT &aEvent)
Implementing DIALOG_TRACK_VIA_SIZE_BASE.
void UseCustomTrackViaSize(bool aEnabled)
Enables/disables custom track/via size settings.
Container for design settings for a BOARD object.

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

Referenced by setTransitions().

◆ CycleRouterMode()

int ROUTER_TOOL::CycleRouterMode ( const TOOL_EVENT aEvent)

Definition at line 1312 of file router_tool.cpp.

1313 {
1314  PNS::ROUTING_SETTINGS& settings = m_router->Settings();
1315  PNS::PNS_MODE mode = settings.Mode();
1316 
1317  switch( mode )
1318  {
1319  case PNS::RM_MarkObstacles: mode = PNS::RM_Shove; break;
1320  case PNS::RM_Shove: mode = PNS::RM_Walkaround; break;
1321  case PNS::RM_Walkaround: mode = PNS::RM_MarkObstacles; break;
1322  }
1323 
1324  settings.SetMode( mode );
1325 
1326  return 0;
1327 }
Contain all persistent settings of the router, such as the mode, optimization effort,...
void SetMode(PNS_MODE aMode)
Return the optimizer effort. Bigger means cleaner traces, but slower routing.
PNS_MODE
< Routing modes
ROUTER * m_router
Definition: pns_tool_base.h:78
PNS_MODE Mode() const
Set the routing mode.
Ignore collisions, mark obstacles.
Only walk around.
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:182

References PNS::TOOL_BASE::m_router, PNS::ROUTING_SETTINGS::Mode(), PNS::RM_MarkObstacles, PNS::RM_Shove, PNS::RM_Walkaround, PNS::ROUTING_SETTINGS::SetMode(), and PNS::ROUTER::Settings().

Referenced by setTransitions().

◆ displayOptions()

const PCB_DISPLAY_OPTIONS & PCB_TOOL_BASE::displayOptions ( ) const
protectedinherited

◆ doInteractiveItemPlacement()

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

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

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

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

Definition at line 37 of file pcb_tool_base.cpp.

40 {
41  using namespace std::placeholders;
42  std::unique_ptr<BOARD_ITEM> newItem;
43 
44  frame()->PushTool( aTool );
45 
46  BOARD_COMMIT commit( frame() );
47 
49 
50  Activate();
51  // Must be done after Activate() so that it gets set into the correct context
52  controls()->ShowCursor( true );
53  // do not capture or auto-pan until we start placing an item
54 
55  PCB_GRID_HELPER grid( m_toolMgr, frame()->GetMagneticItemsSettings() );
56 
57  // Add a VIEW_GROUP that serves as a preview for the new item
58  PCB_SELECTION preview;
59  view()->Add( &preview );
60 
61  aPlacer->m_board = board();
62  aPlacer->m_frame = frame();
63  aPlacer->m_modifiers = 0;
64 
65  auto makeNewItem =
66  [&]( VECTOR2I aPosition )
67  {
68  if( frame()->GetModel() )
69  newItem = aPlacer->CreateItem();
70 
71  if( newItem )
72  {
73  newItem->SetPosition( (wxPoint) aPosition );
74  preview.Add( newItem.get() );
75 
76  if( newItem->Type() == PCB_FOOTPRINT_T )
77  {
78  FOOTPRINT* fp = dyn_cast<FOOTPRINT*>( newItem.get() );
79 
80  // footprints have more drawable parts
81  fp->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
82  }
83  }
84  };
85 
86  if( aOptions & IPO_SINGLE_CLICK )
87  makeNewItem( controls()->GetCursorPosition() );
88 
89  auto setCursor =
90  [&]()
91  {
92  if( !newItem )
94  else
96  };
97 
98  // Set initial cursor
99  setCursor();
100 
101  // Main loop: keep receiving events
102  while( TOOL_EVENT* evt = Wait() )
103  {
104  setCursor();
105 
106  grid.SetSnap( false ); // Interactive placement tools need to set their own item snaps
107  grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
108  VECTOR2I cursorPos = grid.BestSnapAnchor( controls()->GetMousePosition(), nullptr );
109 
110  aPlacer->m_modifiers = evt->Modifier();
111 
112  auto cleanup =
113  [&] ()
114  {
115  newItem = nullptr;
116  preview.Clear();
117  view()->Update( &preview );
118  controls()->SetAutoPan( false );
119  controls()->CaptureCursor( false );
120  controls()->ShowCursor( true );
121  };
122 
123  if( evt->IsCancelInteractive() )
124  {
125  if( aOptions & IPO_SINGLE_CLICK )
126  {
127  cleanup();
128  frame()->PopTool( aTool );
129  break;
130  }
131  else if( newItem )
132  {
133  cleanup();
134  }
135  else
136  {
137  frame()->PopTool( aTool );
138  break;
139  }
140  }
141  else if( evt->IsActivate() )
142  {
143  if( newItem )
144  cleanup();
145 
146  if( evt->IsPointEditor() )
147  {
148  // don't exit (the point editor runs in the background)
149  }
150  else if( evt->IsMoveTool() )
151  {
152  // leave ourselves on the stack so we come back after the move
153  break;
154  }
155  else
156  {
157  frame()->PopTool( aTool );
158  break;
159  }
160  }
161  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
162  {
163  if( !newItem )
164  {
165  // create the item if possible
166  makeNewItem( cursorPos );
167 
168  // no item created, so wait for another click
169  if( !newItem )
170  continue;
171 
172  controls()->CaptureCursor( true );
173  controls()->SetAutoPan( true );
174  }
175  else
176  {
177  auto oldFlags = newItem->GetFlags();
178  newItem->ClearFlags();
179 
180  if( !aPlacer->PlaceItem( newItem.get(), commit ) )
181  {
182  newItem->SetFlags( oldFlags );
183  continue;
184  }
185 
186  preview.Clear();
187  newItem.release();
188  commit.Push( aCommitMessage );
189 
190  controls()->CaptureCursor( false );
191  controls()->SetAutoPan( false );
192  controls()->ShowCursor( true );
193 
194  if( !( aOptions & IPO_REPEAT ) )
195  break;
196 
197  if( aOptions & IPO_SINGLE_CLICK )
198  makeNewItem( controls()->GetCursorPosition() );
199 
200  setCursor();
201  }
202  }
203  else if( evt->IsClick( BUT_RIGHT ) )
204  {
206  }
207  else if( evt->IsAction( &PCB_ACTIONS::trackViaSizeChanged ) )
208  {
210  }
211  else if( newItem && evt->Category() == TC_COMMAND )
212  {
213  /*
214  * Handle any events that can affect the item as we move it around
215  */
216  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
217  {
218  const int rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
219  newItem->Rotate( newItem->GetPosition(), rotationAngle );
220  view()->Update( &preview );
221  }
222  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
223  {
224  newItem->Flip( newItem->GetPosition(), frame()->Settings().m_FlipLeftRight );
225  view()->Update( &preview );
226  }
227  else if( evt->IsAction( &PCB_ACTIONS::properties ) )
228  {
229  frame()->OnEditItemRequest( newItem.get() );
230 
231  // Notify other tools of the changes
233  }
234  else if( evt->IsAction( &ACTIONS::refreshPreview ) )
235  {
236  preview.Clear();
237  newItem.release();
238 
239  makeNewItem( (wxPoint) cursorPos );
240  aPlacer->SnapItem( newItem.get() );
241  view()->Update( &preview );
242  }
243  else
244  {
245  evt->SetPassEvent();
246  }
247  }
248  else if( newItem && evt->IsMotion() )
249  {
250  // track the cursor
251  newItem->SetPosition( (wxPoint) cursorPos );
252  aPlacer->SnapItem( newItem.get() );
253 
254  // Show a preview of the item
255  view()->Update( &preview );
256  }
257  else
258  {
259  evt->SetPassEvent();
260  }
261  }
262 
263  view()->Remove( &preview );
265  controls()->SetAutoPan( false );
266  controls()->CaptureCursor( false );
267 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
virtual void Clear() override
Remove all the stored items from the group.
Definition: selection.h:83
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
virtual bool PlaceItem(BOARD_ITEM *aItem, BOARD_COMMIT &aCommit)
Handle flip action in the loop by calling the item's flip method.
BOARD * board() const
virtual void Add(EDA_ITEM *aItem)
Definition: selection.cpp:32
virtual std::unique_ptr< BOARD_ITEM > CreateItem()=0
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:214
virtual void OnEditItemRequest(BOARD_ITEM *aItem)=0
Install the corresponding dialog editor for the given item.
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:117
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:299
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
Definition: pcb_view.cpp:75
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:205
TOOL_MANAGER * GetManager() const
Return 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)
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: pcb_view.cpp:92
const PCB_SELECTION & selection() const
Allow repeat placement of the item.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
Generic, UI-independent tool event.
Definition: tool_event.h:152
KIGFX::PCB_VIEW * view() const
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
virtual void Add(VIEW_ITEM *aItem)
Add an item to the group.
Definition: view_group.cpp:57
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:105
Handle the rotate action in the loop by calling the item's rotate method.
KIGFX::VIEW_CONTROLS * controls() const
PCBNEW_SETTINGS & Settings()
void Activate()
Run the tool.
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction) const
Invoke a function on all BOARD_ITEMs that belong to the footprint (pads, drawings,...
Definition: footprint.cpp:1299
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
Definition: pcb_view.cpp:58
PCB_BASE_EDIT_FRAME * m_frame
Definition: pcb_tool_base.h:64
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59
static TOOL_ACTION refreshPreview
Definition: actions.h:106

References TOOL_INTERACTIVE::Activate(), KIGFX::PCB_VIEW::Add(), KIGFX::VIEW_GROUP::Add(), SELECTION::Add(), ARROW, PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_TOOL_BASE::controls(), INTERACTIVE_PLACER_BASE::CreateItem(), PCB_ACTIONS::flip, PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_BASE_FRAME::GetModel(), TOOL_BASE::getView(), grid, PCB_TOOL_BASE::IPO_FLIP, PCB_TOOL_BASE::IPO_REPEAT, PCB_TOOL_BASE::IPO_ROTATE, PCB_TOOL_BASE::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, PCBNEW_SETTINGS::m_FlipLeftRight, INTERACTIVE_PLACER_BASE::m_frame, TOOL_INTERACTIVE::m_menu, INTERACTIVE_PLACER_BASE::m_modifiers, TOOL_BASE::m_toolMgr, PCB_BASE_EDIT_FRAME::OnEditItemRequest(), PCB_FOOTPRINT_T, PENCIL, PLACE, INTERACTIVE_PLACER_BASE::PlaceItem(), TOOLS_HOLDER::PopTool(), TOOL_MANAGER::ProcessEvent(), PCB_ACTIONS::properties, BOARD_COMMIT::Push(), TOOLS_HOLDER::PushTool(), ACTIONS::refreshPreview, KIGFX::PCB_VIEW::Remove(), TOOL_MANAGER::RunAction(), FOOTPRINT::RunOnChildren(), EVENTS::SelectedItemsModified, PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), PCB_BASE_FRAME::Settings(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), INTERACTIVE_PLACER_BASE::SnapItem(), TC_COMMAND, PCB_ACTIONS::trackViaSizeChanged, KIGFX::PCB_VIEW::Update(), PCB_TOOL_BASE::view(), and TOOL_INTERACTIVE::Wait().

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

◆ DpDimensionsDialog()

int ROUTER_TOOL::DpDimensionsDialog ( const TOOL_EVENT aEvent)

Definition at line 1269 of file router_tool.cpp.

1270 {
1271  PNS::SIZES_SETTINGS sizes = m_router->Sizes();
1272  DIALOG_PNS_DIFF_PAIR_DIMENSIONS settingsDlg( frame(), sizes );
1273 
1274  if( settingsDlg.ShowModal() == wxID_OK )
1275  {
1276  m_router->UpdateSizes( sizes );
1277  m_savedSizes = sizes;
1278 
1280  bds.SetCustomDiffPairWidth( sizes.DiffPairWidth() );
1281  bds.SetCustomDiffPairGap( sizes.DiffPairGap() );
1282  bds.SetCustomDiffPairViaGap( sizes.DiffPairViaGap() );
1283  }
1284 
1285  return 0;
1286 }
void SetCustomDiffPairViaGap(int aGap)
Sets custom via gap for differential pairs (i.e.
SIZES_SETTINGS m_savedSizes
Definition: pns_tool_base.h:68
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:201
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
PCB_BASE_EDIT_FRAME * frame() const
void SetCustomDiffPairWidth(int aWidth)
Sets custom track width for differential pairs (i.e.
ROUTER * m_router
Definition: pns_tool_base.h:78
void SetCustomDiffPairGap(int aGap)
Sets custom gap for differential pairs (i.e.
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:570
BOARD * GetBoard() const
Container for 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().

◆ finishInteractive()

bool ROUTER_TOOL::finishInteractive ( )
private

Definition at line 1121 of file router_tool.cpp.

1122 {
1123  m_router->StopRouting();
1124 
1125  m_startItem = nullptr;
1126  m_endItem = nullptr;
1127 
1130  controls()->SetAutoPan( false );
1131  controls()->ForceCursorPosition( false );
1132  frame()->UndoRedoBlock( false );
1133  highlightNet( false );
1134 
1135  return true;
1136 }
void SetCurrentCursor(KICURSOR aCursor)
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.
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
PCB_BASE_EDIT_FRAME * frame() const
ITEM * m_startItem
Definition: pns_tool_base.h:69
ROUTER * m_router
Definition: pns_tool_base.h:78
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
void StopRouting()
Definition: pns_router.cpp:719
virtual void highlightNet(bool aEnabled, int aNetcode=-1)
KIGFX::VIEW_CONTROLS * controls() const
void UpdateMessagePanel()

References ARROW, PCB_TOOL_BASE::controls(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), PNS::TOOL_BASE::highlightNet(), PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), PNS::ROUTER::StopRouting(), PCB_BASE_EDIT_FRAME::UndoRedoBlock(), and UpdateMessagePanel().

Referenced by performRouting().

◆ footprint()

◆ frame()

PCB_BASE_EDIT_FRAME* PCB_TOOL_BASE::frame ( ) const
inlineprotectedinherited

Definition at line 160 of file pcb_tool_base.h.

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

Referenced by PCB_POINT_EDITOR::addCorner(), AUTOPLACE_TOOL::autoplace(), PCB_TOOL_BASE::canvas(), ZONE_FILLER_TOOL::CheckAllZones(), PNS::TOOL_BASE::checkSnap(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), BOARD_INSPECTION_TOOL::CrossProbePcbToSch(), CustomTrackWidthDialog(), FOOTPRINT_EDITOR_CONTROL::DeleteFootprint(), PCB_TOOL_BASE::displayOptions(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), DpDimensionsDialog(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawVia(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EditPad(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), BOARD_EDITOR_CONTROL::ExportSpecctraDSN(), ZONE_FILLER_TOOL::FillAllZones(), EDIT_TOOL::FilletTracks(), PCB_SELECTION_TOOL::FilterCollectorForFreePads(), finishInteractive(), EDIT_TOOL::Flip(), PCB_CONTROL::FlipPcbView(), GLOBAL_EDIT_TOOL::GlobalDeletions(), handleLayerSwitch(), BOARD_INSPECTION_TOOL::HighlightItem(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), BOARD_EDITOR_CONTROL::ImportSpecctraSession(), Init(), SCRIPTING_TOOL::Init(), PCB_SELECTION_TOOL::Init(), EDIT_TOOL::Init(), InlineBreakTrack(), InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), PCB_TOOL_BASE::Is45Limited(), PCB_PICKER_TOOL::Main(), PCB_SELECTION_TOOL::Main(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MoveExact(), PCB_POINT_EDITOR::OnSelectionChange(), PCB_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), performDragging(), performRouting(), LENGTH_TUNER_TOOL::performTuning(), GROUP_TOOL::PickNewMember(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), prepareInteractive(), PAD_TOOL::pushPadSettings(), PAD_TOOL::recombinePad(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), SCRIPTING_TOOL::reloadPlugins(), EDIT_TOOL::Remove(), PCB_POINT_EDITOR::removeCorner(), PCB_SELECTION_TOOL::RequestSelection(), PAD_TOOL::Reset(), PNS::TOOL_BASE::Reset(), EDIT_TOOL::Rotate(), SelectCopperLayerPair(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), PCB_POINT_EDITOR::setEditedPoint(), SettingsDialog(), GLOBAL_EDIT_TOOL::swapBoardItem(), GLOBAL_EDIT_TOOL::SwapLayers(), switchLayerOnViaPlacement(), PCB_CONTROL::unfilledZoneCheck(), UpdateMessagePanel(), EDIT_TOOL::updateModificationPoint(), BOARD_EDITOR_CONTROL::UpdateSchematicFromPCB(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillAll().

◆ getEditFrame()

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

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

Definition at line 184 of file tool_base.h.

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

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone().

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

Return the unique identifier of the tool.

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 120 of file tool_base.h.

121  {
122  return m_toolId;
123  }
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209

References TOOL_BASE::m_toolId.

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

◆ GetManager()

TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

Return the instance of TOOL_MANAGER that takes care of the tool.

Returns
Instance of the TOOL_MANAGER or NULL if there is no associated tool manager.

Definition at line 143 of file tool_base.h.

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

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

Return the model object if it matches the requested type.

Store the type of the tool.

Definition at line 196 of file tool_base.h.

References TOOL_BASE::getModelInt().

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

◆ GetName()

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

Return the name of the tool.

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

Returns
The name of the tool.

Definition at line 133 of file tool_base.h.

134  {
135  return m_toolName;
136  }
std::string m_toolName
Definition: tool_base.h:213

References TOOL_BASE::m_toolName.

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

◆ GetRouterMode()

PNS::PNS_MODE ROUTER_TOOL::GetRouterMode ( )

Definition at line 1330 of file router_tool.cpp.

1331 {
1332  return m_router->Settings().Mode();
1333 }
ROUTER * m_router
Definition: pns_tool_base.h:78
PNS_MODE Mode() const
Set the routing mode.
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:182

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

Referenced by PCB_EDIT_FRAME::setupUIConditions().

◆ getStartLayer()

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

Definition at line 583 of file router_tool.cpp.

584 {
585  int tl = getView()->GetTopLayer();
586 
587  if( m_startItem )
588  {
589  const LAYER_RANGE& ls = m_startItem->Layers();
590 
591  if( ls.Overlaps( tl ) )
592  return tl;
593  else
594  return ls.Start();
595  }
596 
597  return tl;
598 }
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:67
int Start() const
Definition: pns_layerset.h:82
virtual int GetTopLayer() const
Definition: view.cpp:817
ITEM * m_startItem
Definition: pns_tool_base.h:69
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:31
const LAYER_RANGE & Layers() const
Definition: pns_item.h:154

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

Return the type of the tool.

Returns
The type of the tool.

Definition at line 108 of file tool_base.h.

109  {
110  return m_type;
111  }
TOOL_TYPE m_type
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:206

References TOOL_BASE::m_type.

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

◆ getView()

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

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:283
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214

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

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), COMMON_TOOLS::CenterContents(), SCH_EDIT_TOOL::ChangeTextType(), EE_INSPECTION_TOOL::CheckSymbol(), GERBVIEW_CONTROL::ClearAllLayers(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::CollectHits(), SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint(), COMMON_TOOLS::CursorControl(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), EE_SELECTION_TOOL::GetNode(), getStartLayer(), PCB_CONTROL::GridResetOrigin(), PCB_CONTROL::GridSetOrigin(), handleCommonEvents(), PL_SELECTION_TOOL::highlight(), EE_SELECTION_TOOL::highlight(), PCB_SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), PCB_SELECTION_TOOL::hitTestDistance(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), InlineDrag(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), PL_EDIT_TOOL::moveItem(), SCH_MOVE_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), performRouting(), PNS::TOOL_BASE::pickSingleItem(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PL_DRAWING_TOOLS::PlaceItem(), BOARD_EDITOR_CONTROL::PlaceTarget(), prepareInteractive(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), BOARD_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCB_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), PCB_SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), PCB_SELECTION_TOOL::Selectable(), PCB_SELECTION_TOOL::SelectAll(), EE_SELECTION_TOOL::SelectAll(), PL_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), PL_SELECTION_TOOL::unhighlight(), EE_SELECTION_TOOL::unhighlight(), PCB_SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), SCH_EDITOR_CONTROL::UpdateFind(), PL_POINT_EDITOR::updateItem(), PCB_POINT_EDITOR::updateItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), PCB_POINT_EDITOR::updatePoints(), PCB_SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCB_VIEWER_TOOLS::view(), PCB_TOOL_BASE::view(), PCB_SELECTION_TOOL::zoomFitSelection(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and PCB_SELECTION_TOOL::~PCB_SELECTION_TOOL().

◆ getViewControls()

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

Return 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:214
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:285

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

Referenced by EE_POINT_EDITOR::addCorner(), PCB_POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), SCH_EDITOR_CONTROL::AssignNetclass(), SCH_EDIT_TOOL::BreakWire(), PCB_TOOL_BASE::controls(), EDIT_TOOL::copyToClipboard(), SCH_DRAWING_TOOLS::createSheetPin(), COMMON_TOOLS::CursorControl(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), SCH_DRAWING_TOOLS::GetCanvasFreeAreaPixels(), BOARD_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_EDIT_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), performDragging(), LENGTH_TUNER_TOOL::performTuning(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), PCB_POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), PCB_SELECTION_TOOL::selectCursor(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PCB_PICKER_TOOL::setControls(), PICKER_TOOL::setControls(), PL_POINT_EDITOR::setEditedPoint(), EE_POINT_EDITOR::setEditedPoint(), PCB_POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateItem(), PL_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

Define which state (aStateFunc) to go when a certain event arrives (aConditions).

No conditions means any event.

Definition at line 147 of file tool_interactive.h.

149 {
150  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
151 
152  goInternal( sptr, aConditions );
153 }
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 AUTOPLACE_TOOL::setTransitions(), ZOOM_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), BOARD_REANNOTATE_TOOL::setTransitions(), GERBVIEW_INSPECTION_TOOL::setTransitions(), PCB_PICKER_TOOL::setTransitions(), SCH_NAVIGATE_TOOL::setTransitions(), SYMBOL_EDITOR_PIN_TOOL::setTransitions(), SYMBOL_EDITOR_MOVE_TOOL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), EE_POINT_EDITOR::setTransitions(), PL_POINT_EDITOR::setTransitions(), setTransitions(), SCRIPTING_TOOL::setTransitions(), COMMON_CONTROL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), CONVERT_TOOL::setTransitions(), SYMBOL_EDITOR_DRAWING_TOOLS::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), MICROWAVE_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), PCB_POINT_EDITOR::setTransitions(), GERBVIEW_CONTROL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), PAD_TOOL::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), GROUP_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_EDIT_TOOL::setTransitions(), PL_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), SCH_EDIT_TOOL::setTransitions(), FOOTPRINT_EDITOR_CONTROL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), DRC_TOOL::setTransitions(), EDA_3D_CONTROLLER::setTransitions(), PCB_CONTROL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), BOARD_INSPECTION_TOOL::setTransitions(), BOARD_EDITOR_CONTROL::setTransitions(), PICKER_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), PCB_SELECTION_TOOL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), DRAWING_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), and EE_SELECTION_TOOL::setTransitions().

◆ handleCommonEvents()

void ROUTER_TOOL::handleCommonEvents ( TOOL_EVENT evt)
private

Definition at line 557 of file router_tool.cpp.

558 {
559  if( aEvent.Category() == TC_VIEW || aEvent.Category() == TC_MOUSE )
560  {
561  BOX2D viewAreaD = getView()->GetGAL()->GetVisibleWorldExtents();
562  m_router->SetVisibleViewArea( BOX2I( viewAreaD.GetOrigin(), viewAreaD.GetSize() ) );
563  }
564 
565  if( !aEvent.IsKeyPressed() )
566  return;
567 
568  switch( aEvent.KeyCode() )
569  {
570  case '0':
572  return;
573 
575  aEvent.SetPassEvent( false );
576  break;
577  default:
578  break;
579  }
580 }
BOX2< VECTOR2I > BOX2I
Definition: box2.h:506
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:190
bool m_ShowRouterDebugGraphics
Show PNS router debug graphics.
void SetVisibleViewArea(const BOX2I &aExtents)
Definition: pns_router.h:210
ROUTER * m_router
Definition: pns_tool_base.h:78
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
void saveRouterDebugLog()
BOX2D GetVisibleWorldExtents() const
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
const Vec & GetSize() const
Definition: box2.h:172
const Vec & GetOrigin() const
Definition: box2.h:176

References TOOL_EVENT::Category(), ADVANCED_CFG::GetCfg(), KIGFX::VIEW::GetGAL(), BOX2< Vec >::GetOrigin(), BOX2< Vec >::GetSize(), TOOL_BASE::getView(), KIGFX::GAL::GetVisibleWorldExtents(), TOOL_EVENT::IsKeyPressed(), TOOL_EVENT::KeyCode(), PNS::TOOL_BASE::m_router, ADVANCED_CFG::m_ShowRouterDebugGraphics, saveRouterDebugLog(), TOOL_EVENT::SetPassEvent(), PNS::ROUTER::SetVisibleViewArea(), TC_MOUSE, and TC_VIEW.

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

◆ handleLayerSwitch()

int ROUTER_TOOL::handleLayerSwitch ( const TOOL_EVENT aEvent,
bool  aForceVia 
)
private

Definition at line 721 of file router_tool.cpp.

722 {
723  wxCHECK( m_router, 0 );
724 
725  if( !IsToolActive() )
726  return 0;
727 
728  // First see if this is one of the switch layer commands
729  LSEQ layers = LSET( board()->GetEnabledLayers() & LSET::AllCuMask() ).Seq();
731  PCB_LAYER_ID targetLayer = UNDEFINED_LAYER;
732 
733  if( aEvent.IsAction( &PCB_ACTIONS::layerNext ) )
734  {
736  m_lastTargetLayer = currentLayer;
737 
738  size_t idx = 0;
739 
740  for( size_t i = 0; i < layers.size(); i++ )
741  {
742  if( layers[i] == m_lastTargetLayer )
743  {
744  idx = i;
745  break;
746  }
747  }
748 
749  idx = ( idx + 1 ) % layers.size();
750  targetLayer = layers[idx];
751  }
752  else if( aEvent.IsAction( &PCB_ACTIONS::layerPrev ) )
753  {
755  m_lastTargetLayer = currentLayer;
756 
757  size_t idx = 0;
758 
759  for( size_t i = 0; i < layers.size(); i++ )
760  {
761  if( layers[i] == m_lastTargetLayer )
762  {
763  idx = i;
764  break;
765  }
766  }
767 
768  idx = ( idx > 0 ) ? ( idx - 1 ) : ( layers.size() - 1 );
769  targetLayer = layers[idx];
770  }
771  else
772  {
773  targetLayer = getTargetLayerFromEvent( aEvent );
774  }
775 
776  if( targetLayer != UNDEFINED_LAYER )
777  {
778  m_lastTargetLayer = targetLayer;
779 
780  if( targetLayer == currentLayer )
781  return 0;
782 
783  if( !aForceVia && m_router && m_router->SwitchLayer( targetLayer ) )
784  {
785  updateEndItem( aEvent );
786  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
787  return 0;
788  }
789  }
790 
792  const int layerCount = bds.GetCopperLayerCount();
793 
796 
798 
799  VIATYPE viaType = VIATYPE::THROUGH;
800  bool selectLayer = false;
801 
802  // Otherwise it is one of the router-specific via commands
803  if( targetLayer == UNDEFINED_LAYER )
804  {
805  const int actViaFlags = aEvent.Parameter<intptr_t>();
806  selectLayer = actViaFlags & VIA_ACTION_FLAGS::SELECT_LAYER;
807 
808  viaType = getViaTypeFromFlags( actViaFlags );
809 
810  // ask the user for a target layer
811  if( selectLayer )
812  {
813  wxPoint endPoint = (wxPoint) view()->ToScreen( m_endSnapPoint );
814  endPoint = frame()->GetCanvas()->ClientToScreen( endPoint );
815 
816  // Build the list of not allowed layer for the target layer
817  LSET not_allowed_ly = LSET::AllNonCuMask();
818 
819  if( viaType != VIATYPE::THROUGH )
820  {
821  not_allowed_ly.set( currentLayer );
822  }
823 
824  if( viaType == VIATYPE::MICROVIA )
825  {
826  // Allows only the previous or the next layer from the current layer
827  int previous_layer = currentLayer == B_Cu ? layerCount - 2
828  : currentLayer - 1;
829 
830  int next_layer = currentLayer >= layerCount-2 ? B_Cu
831  : currentLayer + 1;
832 
833  not_allowed_ly = LSET::AllLayersMask();
834 
835  if( previous_layer >= F_Cu && previous_layer != currentLayer )
836  not_allowed_ly.reset( previous_layer );
837 
838  if( next_layer != currentLayer )
839  not_allowed_ly.reset( next_layer );
840  }
841 
842  targetLayer = frame()->SelectOneLayer( static_cast<PCB_LAYER_ID>( currentLayer ),
843  not_allowed_ly, endPoint );
844 
845  // Reset the cursor to the end of the track
847 
848  if( targetLayer == UNDEFINED_LAYER ) // cancelled by user
849  return 0;
850 
851  // One cannot place a blind/buried via on only one layer:
852  if( viaType != VIATYPE::THROUGH )
853  {
854  if( currentLayer == targetLayer )
855  return 0;
856  }
857  }
858  }
859 
860  // fixme: P&S supports more than one fixed layer pair. Update the dialog?
861  sizes.ClearLayerPairs();
862 
863  if( !m_router->IsPlacingVia() )
864  {
865  // Cannot place microvias or blind vias if not allowed (obvious)
866  if( ( viaType == VIATYPE::BLIND_BURIED ) && ( !bds.m_BlindBuriedViaAllowed ) )
867  {
868  WX_INFOBAR* infobar = frame()->GetInfoBar();
869  wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY,
870  _( "Show board setup" ),
871  wxEmptyString );
872 
873  button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
874  [&]( wxHyperlinkEvent& aEvent )
875  {
876  getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog( _( "Constraints" ) );
877  } ) );
878 
879  infobar->RemoveAllButtons();
880  infobar->AddButton( button );
881 
882  infobar->ShowMessageFor( _( "Blind/buried vias must first be enabled in "
883  "Board Setup > Design Rules > Constraints." ),
884  10000, wxICON_ERROR, WX_INFOBAR::MESSAGE_TYPE::DRC_VIOLATION );
885  return false;
886  }
887 
888  if( ( viaType == VIATYPE::MICROVIA ) && ( !bds.m_MicroViasAllowed ) )
889  {
890  WX_INFOBAR* infobar = frame()->GetInfoBar();
891  wxHyperlinkCtrl* button = new wxHyperlinkCtrl( infobar, wxID_ANY,
892  _( "Show board setup" ), wxEmptyString );
893 
894  button->Bind( wxEVT_COMMAND_HYPERLINK, std::function<void( wxHyperlinkEvent& aEvent )>(
895  [&]( wxHyperlinkEvent& aEvent )
896  {
897  getEditFrame<PCB_EDIT_FRAME>()->ShowBoardSetupDialog( _( "Constraints" ) );
898  } ) );
899 
900  infobar->RemoveAllButtons();
901  infobar->AddButton( button );
902 
903  infobar->ShowMessageFor( _( "Microvias must first be enabled in "
904  "Board Setup > Design Rules > Constraints." ),
905  10000, wxICON_ERROR, WX_INFOBAR::MESSAGE_TYPE::DRC_VIOLATION );
906  return false;
907  }
908  }
909 
910  // Convert blind/buried via to a through hole one, if it goes through all layers
911  if( viaType == VIATYPE::BLIND_BURIED
912  && ( ( targetLayer == B_Cu && currentLayer == F_Cu )
913  || ( targetLayer == F_Cu && currentLayer == B_Cu ) ) )
914  {
915  viaType = VIATYPE::THROUGH;
916  }
917 
918  if( targetLayer == UNDEFINED_LAYER )
919  {
920  // Implicic layer selection
921 
922  switch( viaType )
923  {
924  case VIATYPE::THROUGH:
925  // use the default layer pair
926  currentLayer = pairTop;
927  targetLayer = pairBottom;
928  break;
929 
930  case VIATYPE::MICROVIA:
931  // Try to use the layer pair preset, if the layers are adjacent,
932  // because a microvia is usually restricted to 2 adjacent copper layers
933  if( pairTop > pairBottom ) std::swap( pairTop, pairBottom );
934 
935  if( currentLayer == pairTop && pairBottom == pairTop+1 )
936  {
937  targetLayer = pairBottom;
938  }
939  else if( currentLayer == pairBottom && pairBottom == pairTop+1 )
940  {
941  targetLayer = pairTop;
942  }
943  else if( currentLayer == F_Cu || currentLayer == In1_Cu )
944  {
945  // front-side microvia
946  currentLayer = F_Cu;
947 
948  if( layerCount > 2 ) // Ensure the inner layer In1_Cu exists
949  targetLayer = In1_Cu;
950  else
951  targetLayer = B_Cu;
952  }
953  else if( currentLayer == B_Cu || currentLayer == layerCount - 2 )
954  {
955  // back-side microvia
956  currentLayer = B_Cu,
957  targetLayer = (PCB_LAYER_ID) ( layerCount - 2 );
958  }
959  else
960  {
961  // This is not optimal: from an internal layer one can want to switch
962  // to the previous or the next internal layer
963  // but at this point we do not know what the user want.
964  targetLayer = PCB_LAYER_ID( currentLayer + 1 );
965  }
966  break;
967 
969  if( currentLayer == pairTop || currentLayer == pairBottom )
970  {
971  // the current layer is on the defined layer pair,
972  // swap to the other side
973  currentLayer = pairTop;
974  targetLayer = pairBottom;
975  }
976  else
977  {
978  // the current layer is not part of the current layer pair,
979  // so fallback and swap to the top layer of the pair by default
980  targetLayer = pairTop;
981  }
982 
983  // Do not create a broken via (i.e. a via on only one copper layer)
984  if( currentLayer == targetLayer )
985  {
986  WX_INFOBAR* infobar = frame()->GetInfoBar();
987  infobar->ShowMessageFor( _( "Blind/buried via need 2 different layers." ),
988  2000, wxICON_ERROR,
990  return 0;
991  }
992 
993  break;
994 
995  default:
996  wxFAIL_MSG( wxT( "unexpected via type" ) );
997  return 0;
998  break;
999  }
1000  }
1001 
1002  sizes.SetViaDiameter( bds.m_ViasMinSize );
1003  sizes.SetViaDrill( bds.m_MinThroughDrill );
1004 
1005  if( bds.UseNetClassVia() || viaType == VIATYPE::MICROVIA )
1006  {
1007  PCB_VIA dummyVia( board() );
1008  dummyVia.SetViaType( viaType );
1009  dummyVia.SetLayerPair( currentLayer, targetLayer );
1010 
1011  if( !m_router->GetCurrentNets().empty() )
1012  dummyVia.SetNetCode( m_router->GetCurrentNets()[0] );
1013 
1014  DRC_CONSTRAINT constraint;
1015 
1016  constraint = bds.m_DRCEngine->EvalRules( VIA_DIAMETER_CONSTRAINT, &dummyVia, nullptr,
1017  currentLayer );
1018 
1019  if( !constraint.IsNull() )
1020  sizes.SetViaDiameter( constraint.m_Value.Opt() );
1021 
1022  constraint = bds.m_DRCEngine->EvalRules( HOLE_SIZE_CONSTRAINT, &dummyVia, nullptr,
1023  currentLayer );
1024 
1025  if( !constraint.IsNull() )
1026  sizes.SetViaDrill( constraint.m_Value.Opt() );
1027  }
1028  else
1029  {
1030  sizes.SetViaDiameter( bds.GetCurrentViaSize() );
1031  sizes.SetViaDrill( bds.GetCurrentViaDrill() );
1032  }
1033 
1034  sizes.SetViaType( viaType );
1035  sizes.AddLayerPair( currentLayer, targetLayer );
1036 
1037  m_router->UpdateSizes( sizes );
1038 
1039  if( !m_router->IsPlacingVia() )
1041 
1042  m_lastTargetLayer = targetLayer;
1043 
1044  if( m_router->RoutingInProgress() )
1045  {
1046  updateEndItem( aEvent );
1048  }
1049  else
1050  {
1051  updateStartItem( aEvent );
1052  }
1053 
1054  return 0;
1055 }
PCB_LAYER_ID SelectOneLayer(PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask=LSET(), wxPoint aDlgPosition=wxDefaultPosition)
Show the dialog box for a layer selection.
Definition: sel_layer.cpp:274
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:759
void AddButton(wxButton *aButton)
Add an already created button to the infobar.
Definition: infobar.cpp:245
static TOOL_ACTION layerNext
Definition: pcb_actions.h:283
BOARD * board() const
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
Definition: lset.cpp:782
bool IsPlacingVia() const
Definition: pns_router.cpp:809
Ask user to select layer before adding via.
Definition: router_tool.cpp:77
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:781
T Opt() const
Definition: minoptmax.h:35
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move cursor to the requested position expressed in world coordinates.
void ShowMessageFor(const wxString &aMessage, int aTime, int aFlags=wxICON_INFORMATION, MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the infobar with the provided message and icon for a specific period of time.
Definition: infobar.cpp:128
void SetViaDrill(int aDrill)
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:201
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:411
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
void ToggleViaPlacement()
Definition: pns_router.cpp:771
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:88
PCB_BASE_EDIT_FRAME * frame() const
virtual void updateStartItem(const TOOL_EVENT &aEvent, bool aIgnorePads=false)
MINOPTMAX< int > m_Value
Definition: drc_rule.h:145
static VIATYPE getViaTypeFromFlags(int aFlags)
virtual void updateEndItem(const TOOL_EVENT &aEvent)
#define _(s)
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:516
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:284
static PCB_LAYER_ID getTargetLayerFromEvent(const TOOL_EVENT &aEvent)
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:432
bool UseNetClassVia() const
Return true if netclass values should be used to obtain appropriate via size.
KIGFX::PCB_VIEW * view() const
ROUTER * m_router
Definition: pns_tool_base.h:78
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:44
static LSET AllLayersMask()
Definition: lset.cpp:796
bool m_BlindBuriedViaAllowed
true to allow blind/buried vias
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:428
VECTOR2D ToScreen(const VECTOR2D &aCoord, bool aAbsolute=true) const
Convert a world space point/vector to a point/vector in screen space coordinates.
Definition: view.cpp:468
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
Definition: infobar.cpp:286
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:477
void SetViaType(VIATYPE aViaType)
bool IsNull() const
Definition: drc_rule.h:117
A modified version of the wxInfoBar class that allows us to:
Definition: infobar.h:73
VIATYPE
Definition: pcb_track.h:60
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:570
KIGFX::VIEW_CONTROLS * controls() const
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
Definition: layer_ids.h:71
bool IsToolActive() const
Definition: tool_base.cpp:31
bool SwitchLayer(int layer)
Definition: pns_router.cpp:762
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
WX_INFOBAR * GetInfoBar()
void AddLayerPair(int aL1, int aL2)
int m_lastTargetLayer
Definition: router_tool.h:91
bool m_MicroViasAllowed
true to allow micro vias
bool RoutingInProgress() const
Definition: pns_router.cpp:114
void SetViaDiameter(int aDiameter)
std::shared_ptr< DRC_ENGINE > m_DRCEngine
PCB_LAYER_ID m_Route_Layer_TOP
Definition: pcb_screen.h:43
Container for design settings for a BOARD object.
int GetCurrentLayer() const
Definition: pns_router.cpp:792

References _, WX_INFOBAR::AddButton(), PNS::SIZES_SETTINGS::AddLayerPair(), LSET::AllCuMask(), LSET::AllLayersMask(), LSET::AllNonCuMask(), B_Cu, BLIND_BURIED, PCB_TOOL_BASE::board(), PNS::SIZES_SETTINGS::ClearLayerPairs(), PCB_TOOL_BASE::controls(), WX_INFOBAR::DRC_VIOLATION, F_Cu, PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), BOARD_DESIGN_SETTINGS::GetCopperLayerCount(), PNS::ROUTER::GetCurrentLayer(), PNS::ROUTER::GetCurrentNets(), BOARD_DESIGN_SETTINGS::GetCurrentViaDrill(), BOARD_DESIGN_SETTINGS::GetCurrentViaSize(), BOARD::GetDesignSettings(), EDA_BASE_FRAME::GetInfoBar(), PCB_BASE_FRAME::GetScreen(), getTargetLayerFromEvent(), getViaTypeFromFlags(), HOLE_SIZE_CONSTRAINT, In1_Cu, TOOL_EVENT::IsAction(), DRC_CONSTRAINT::IsNull(), PNS::ROUTER::IsPlacingVia(), TOOL_BASE::IsToolActive(), PCB_ACTIONS::layerNext, PCB_ACTIONS::layerPrev, BOARD_DESIGN_SETTINGS::m_BlindBuriedViaAllowed, BOARD_DESIGN_SETTINGS::m_DRCEngine, PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, m_lastTargetLayer, BOARD_DESIGN_SETTINGS::m_MicroViasAllowed, BOARD_DESIGN_SETTINGS::m_MinThroughDrill, PCB_SCREEN::m_Route_Layer_BOTTOM, PCB_SCREEN::m_Route_Layer_TOP, PNS::TOOL_BASE::m_router, DRC_CONSTRAINT::m_Value, BOARD_DESIGN_SETTINGS::m_ViasMinSize, MICROVIA, PNS::ROUTER::Move(), MINOPTMAX< T >::Opt(), TOOL_EVENT::Parameter(), WX_INFOBAR::RemoveAllButtons(), PNS::ROUTER::RoutingInProgress(), SELECT_LAYER, PCB_BASE_FRAME::SelectOneLayer(), LSET::Seq(), KIGFX::VIEW_CONTROLS::SetCursorPosition(), PCB_VIA::SetLayerPair(), BOARD_CONNECTED_ITEM::SetNetCode(), PNS::SIZES_SETTINGS::SetViaDiameter(), PNS::SIZES_SETTINGS::SetViaDrill(), PNS::SIZES_SETTINGS::SetViaType(), PCB_VIA::SetViaType(), WX_INFOBAR::ShowMessageFor(), PNS::ROUTER::Sizes(), PNS::ROUTER::SwitchLayer(), THROUGH, PNS::ROUTER::ToggleViaPlacement(), KIGFX::VIEW::ToScreen(), UNDEFINED_LAYER, PNS::TOOL_BASE::updateEndItem(), PNS::ROUTER::UpdateSizes(), PNS::TOOL_BASE::updateStartItem(), BOARD_DESIGN_SETTINGS::UseNetClassVia(), VIA_DIAMETER_CONSTRAINT, and PCB_TOOL_BASE::view().

Referenced by onLayerCommand(), and onViaCommand().

◆ highlightNet()

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

Definition at line 218 of file pns_tool_base.cpp.

219 {
221 
222  if( aNetcode >= 0 && aEnabled )
223  {
224  // If the user has previously set the current net to be highlighted,
225  // we assume they want to keep it highlighted after routing
227  && rs->GetHighlightNetCodes().count( aNetcode ) );
228 
229  rs->SetHighlight( true, aNetcode );
230  }
231  else
232  {
233  if( !m_startHighlight )
234  rs->SetHighlight( false );
235 
236  m_startHighlight = false;
237  }
238 
240 }
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
bool IsHighlightEnabled() const
Return current highlight setting.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:208
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Turns on/off highlighting.
const std::set< int > & GetHighlightNetCodes() const
Return the netcode of currently highlighted net.
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
Definition: view.cpp:762

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

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

◆ Init()

bool ROUTER_TOOL::Init ( )
overridevirtual

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

427 {
429 
430  PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
431 
432  wxASSERT( frame );
433 
434  auto& menu = m_menu.GetMenu();
435  menu.SetTitle( _( "Interactive Router" ) );
436 
437  m_trackViaMenu = std::make_shared<TRACK_WIDTH_MENU>( *frame );
438  m_trackViaMenu->SetTool( this );
440 
441  m_diffPairMenu = std::make_shared<DIFF_PAIR_MENU>( *frame );
442  m_diffPairMenu->SetTool( this );
444 
445  auto notRoutingCond =
446  [this]( const SELECTION& )
447  {
448  return !m_router->RoutingInProgress();
449  };
450 
452 
453  menu.AddSeparator();
454 
455  menu.AddItem( PCB_ACTIONS::routeSingleTrack, notRoutingCond );
456  menu.AddItem( PCB_ACTIONS::routeDiffPair, notRoutingCond );
459  menu.AddItem( PCB_ACTIONS::breakTrack, notRoutingCond );
460 
461  menu.AddItem( PCB_ACTIONS::drag45Degree, notRoutingCond );
462  menu.AddItem( PCB_ACTIONS::dragFreeAngle, notRoutingCond );
463 
464 // Add( ACT_AutoEndRoute ); // fixme: not implemented yet. Sorry.
473 
474  menu.AddSeparator();
475 
476  auto diffPairCond =
477  [this]( const SELECTION& )
478  {
480  };
481 
482  menu.AddMenu( m_trackViaMenu.get(), SELECTION_CONDITIONS::ShowAlways );
483  menu.AddMenu( m_diffPairMenu.get(), diffPairCond );
484 
486 
487  menu.AddSeparator();
488 
490 
491  return true;
492 }
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
void AddStandardSubMenus(TOOL_MENU &aMenu)
Construct a "basic" menu for a tool, containing only items that apply to all tools (e....
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
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."), BITMAPS::select_w_layer, AF_NONE,(void *)(VIA_ACTION_FLAGS::BLIND_VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
static const TOOL_ACTION ACT_SwitchCornerMode("pcbnew.InteractiveRouter.SwitchRounding", AS_CONTEXT, MD_CTRL+'/', "", _("Track Corner Mode"), _("Switches between sharp/rounded and 45°/90° corners when routing tracks."), BITMAPS::switch_corner_rounding_shape)
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."), BITMAPS::change_entry_orient)
static TOOL_ACTION routerUndoLastSegment
Definition: pcb_actions.h:189
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:135
static TOOL_ACTION cancelInteractive
Definition: actions.h:62
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:134
static const TOOL_ACTION ACT_EndTrack("pcbnew.InteractiveRouter.EndTrack", AS_CONTEXT, WXK_END, "", _("Finish Track"), _("Stops laying the current track."), BITMAPS::checked_ok)
PCB_BASE_EDIT_FRAME * frame() const
static TOOL_ACTION routerSettingsDialog
Activation of the Push and Shove settings dialogs.
Definition: pcb_actions.h:192
#define _(s)
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."), BITMAPS::via_buried, AF_NONE,(void *) VIA_ACTION_FLAGS::BLIND_VIA)
ROUTER * m_router
Definition: pns_tool_base.h:78
static TOOL_ACTION breakTrack
Break a single track into two segments at the cursor.
Definition: pcb_actions.h:132
static const TOOL_ACTION ACT_SelLayerAndPlaceMicroVia("pcbnew.InteractiveRouter.SelLayerAndPlaceMicroVia", AS_CONTEXT, 0, "", _("Select Layer and Place Micro Via..."), _("Select a layer, then add a micro via at the end of currently routed track."), BITMAPS::select_w_layer, AF_NONE,(void *)(VIA_ACTION_FLAGS::MICROVIA|VIA_ACTION_FLAGS::SELECT_LAYER))
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."), BITMAPS::via_microvia, AF_NONE,(void *) VIA_ACTION_FLAGS::MICROVIA)
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."), BITMAPS::via, AF_NONE,(void *) VIA_ACTION_FLAGS::VIA)
void SetTitle(const wxString &aTitle) override
Set title for the menu.
Definition: action_menu.cpp:87
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:175
void AddSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Store a submenu of this menu model.
Definition: tool_menu.cpp:52
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."), BITMAPS::select_w_layer, AF_NONE,(void *)(VIA_ACTION_FLAGS::VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
The main frame for Pcbnew.
std::shared_ptr< ACTION_MENU > m_trackViaMenu
Definition: router_tool.h:89
int m_lastTargetLayer
Definition: router_tool.h:91
std::shared_ptr< ACTION_MENU > m_diffPairMenu
Definition: router_tool.h:88
bool RoutingInProgress() const
Definition: pns_router.cpp:114
ROUTER_MODE Mode() const
Definition: pns_router.h:132
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:178

References _, ACT_EndTrack, ACT_PlaceBlindVia, ACT_PlaceMicroVia, ACT_PlaceThroughVia, ACT_SelLayerAndPlaceBlindVia, ACT_SelLayerAndPlaceMicroVia, ACT_SelLayerAndPlaceThroughVia, ACT_SwitchCornerMode, ACT_SwitchPosture, EDA_DRAW_FRAME::AddStandardSubMenus(), TOOL_MENU::AddSubMenu(), PCB_ACTIONS::breakTrack, ACTIONS::cancelInteractive, PCB_ACTIONS::drag45Degree, PCB_ACTIONS::dragFreeAngle, PCB_TOOL_BASE::frame(), TOOL_MENU::GetMenu(), m_diffPairMenu, m_lastTargetLayer, TOOL_INTERACTIVE::m_menu, PNS::TOOL_BASE::m_router, m_trackViaMenu, PNS::ROUTER::Mode(), PNS::PNS_MODE_ROUTE_DIFF_PAIR, PCB_ACTIONS::routeDiffPair, PCB_ACTIONS::routerSettingsDialog, PCB_ACTIONS::routerUndoLastSegment, PCB_ACTIONS::routeSingleTrack, PNS::ROUTER::RoutingInProgress(), ACTION_MENU::SetTitle(), SELECTION_CONDITIONS::ShowAlways(), and UNDEFINED_LAYER.

◆ InlineBreakTrack()

int ROUTER_TOOL::InlineBreakTrack ( const TOOL_EVENT aEvent)

Definition at line 1975 of file router_tool.cpp.

1976 {
1977  const SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1978 
1979  if( selection.Size() != 1 )
1980  return 0;
1981 
1982  const BOARD_CONNECTED_ITEM* item =
1983  static_cast<const BOARD_CONNECTED_ITEM*>( selection.Front() );
1984 
1985  if( item->Type() != PCB_TRACE_T )
1986  return 0;
1987 
1988  Activate();
1989 
1991  m_router->SyncWorld();
1993 
1994  TOOL_MANAGER* toolManager = frame()->GetToolManager();
1995  GAL* gal = toolManager->GetView()->GetGAL();
1996 
1998  m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
1999 
2000  if( toolManager->IsContextMenuActive() )
2001  {
2002  // If we're here from a context menu then we need to get the position of the
2003  // cursor when the context menu was invoked. This is used to figure out the
2004  // break point on the track.
2006  }
2007  else
2008  {
2009  // If we're here from a hotkey, then get the current mouse position so we know
2010  // where to break the track.
2011  m_startSnapPoint = snapToItem( m_startItem, controls()->GetCursorPosition() );
2012  }
2013 
2014  if( m_startItem && m_startItem->IsLocked() )
2015  {
2016  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
2017  wxOK | wxCANCEL | wxICON_WARNING );
2018  dlg.SetOKLabel( _( "Break Track" ) );
2019  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
2020 
2021  if( dlg.ShowModal() == wxID_CANCEL )
2022  return 0;
2023  }
2024 
2025  frame()->UndoRedoBlock( true );
2026  breakTrack();
2027 
2028  if( m_router->RoutingInProgress() )
2029  m_router->StopRouting();
2030 
2031  frame()->UndoRedoBlock( false );
2032 
2033  return 0;
2034 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:283
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:45
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
void SyncWorld()
Definition: pns_router.cpp:92
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:190
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
void breakTrack()
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
PCB_BASE_EDIT_FRAME * frame() const
Master controller class:
Definition: tool_manager.h:54
bool GetGridSnapping() const
const VECTOR2I snapToItem(ITEM *aSnapToItem, const VECTOR2I &aP)
PCB_GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
#define _(s)
const PCB_SELECTION & selection() const
ITEM * FindItemByParent(const BOARD_ITEM *aParent)
Definition: pns_node.cpp:1580
ITEM * m_startItem
Definition: pns_tool_base.h:69
bool IsContextMenuActive() const
True while processing a context menu.
Definition: tool_manager.h:411
ROUTER * m_router
Definition: pns_tool_base.h:78
bool DisableGridSnapping() const
Definition: tool_event.h:341
void SetSnap(bool aSnap)
Definition: grid_helper.h:64
void StopRouting()
Definition: pns_router.cpp:719
int Modifier(int aMask=MD_MODIFIER_MASK) const
Definition: tool_event.h:336
void SetUseGrid(bool aSnapToGrid)
Definition: grid_helper.h:67
KIGFX::VIEW_CONTROLS * controls() const
int Size() const
Returns the number of selected parts.
Definition: selection.h:104
The selection tool: currently supports:
bool IsLocked() const
Definition: pns_item.h:227
void Activate()
Run the tool.
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
bool RoutingInProgress() const
Definition: pns_router.cpp:114
VECTOR2D GetMenuCursorPos() const
Definition: tool_manager.h:440
NODE * GetWorld() const
Definition: pns_router.h:154
EDA_ITEM * Front() const
Definition: selection.h:145
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
Abstract interface for drawing on a 2D-surface.

References _, TOOL_INTERACTIVE::Activate(), breakTrack(), PCB_TOOL_BASE::controls(), TOOL_EVENT::DisableGridSnapping(), KIDIALOG::DoNotShowCheckbox(), PNS::NODE::FindItemByParent(), PCB_TOOL_BASE::frame(), SELECTION::Front(), KIGFX::VIEW::GetGAL(), KIGFX::GAL::GetGridSnapping(), TOOL_MANAGER::GetMenuCursorPos(), TOOL_MANAGER::GetTool(), TOOLS_HOLDER::GetToolManager(), TOOL_MANAGER::GetView(), PNS::ROUTER::GetWorld(), TOOL_MANAGER::IsContextMenuActive(), PNS::ITEM::IsLocked(), PNS::TOOL_BASE::m_gridHelper, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, TOOL_BASE::m_toolMgr, MD_SHIFT, TOOL_EVENT::Modifier(), PCB_TRACE_T, PNS::ROUTER::RoutingInProgress(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, GRID_HELPER::SetSnap(), GRID_HELPER::SetUseGrid(), 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 1676 of file router_tool.cpp.

1677 {
1678  const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1679 
1680  if( selection.Empty() )
1682 
1683  if( selection.Size() != 1 )
1684  return 0;
1685 
1686  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.Front() );
1687 
1688  if( item->Type() != PCB_TRACE_T
1689  && item->Type() != PCB_VIA_T
1690  && item->Type() != PCB_FOOTPRINT_T )
1691  {
1692  return 0;
1693  }
1694 
1695  // If we overrode locks, we want to clear the flag from the source item before SyncWorld is
1696  // called so that virtual vias are not generated for the (now unlocked) track segment. Note in
1697  // this case the lock can't be reliably re-applied, because there is no guarantee that the end
1698  // state of the drag results in the same number of segments so it's not clear which segment to
1699  // apply the lock state to.
1700  bool wasLocked = false;
1701 
1702  if( item->IsLocked() )
1703  {
1704  wasLocked = true;
1705  item->SetLocked( false );
1706  }
1707 
1708  Activate();
1709 
1711  m_router->SyncWorld();
1712  m_startItem = nullptr;
1713 
1714  PNS::ITEM* startItem = nullptr;
1715  PNS::ITEM_SET itemsToDrag;
1716  const FOOTPRINT* footprint = nullptr;
1717 
1718  std::shared_ptr<CONNECTIVITY_DATA> connectivityData = board()->GetConnectivity();
1719  std::vector<BOARD_ITEM*> dynamicItems;
1720  std::unique_ptr<CONNECTIVITY_DATA> dynamicData = nullptr;
1721  VECTOR2I lastOffset;
1722 
1723  if( item->Type() == PCB_FOOTPRINT_T )
1724  {
1725  footprint = static_cast<const FOOTPRINT*>(item);
1726 
1727  for( PAD* pad : footprint->Pads() )
1728  {
1730 
1731  if( solid )
1732  itemsToDrag.Add( solid );
1733 
1734  if( pad->GetLocalRatsnestVisible() || displayOptions().m_ShowModuleRatsnest )
1735  {
1736  if( connectivityData->GetRatsnestForPad( pad ).size() > 0 )
1737  dynamicItems.push_back( pad );
1738  }
1739  }
1740 
1741  dynamicData = std::make_unique<CONNECTIVITY_DATA>( dynamicItems, true );
1742  connectivityData->BlockRatsnestItems( dynamicItems );
1743  }
1744  else
1745  {
1746  startItem = m_router->GetWorld()->FindItemByParent( item );
1747 
1748  if( startItem )
1749  itemsToDrag.Add( startItem );
1750  }
1751 
1752  GAL* gal = m_toolMgr->GetView()->GetGAL();
1753  VECTOR2I p0 = controls()->GetCursorPosition( false );
1754  VECTOR2I p = p0;
1755 
1757  m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
1758 
1759  if( startItem )
1760  {
1761  p = snapToItem( startItem, p0 );
1762  m_startItem = startItem;
1763 
1764  if( m_startItem && m_startItem->Net() > 0 )
1765  highlightNet( true, m_startItem->Net() );
1766  }
1767  else if( footprint )
1768  {
1769  // The mouse is going to be moved on grid before dragging begins.
1770  VECTOR2I tweakedMousePos;
1771  PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1772 
1773  // Check if user wants to warp the mouse to origin of moved object
1774 
1775  if( editFrame->GetMoveWarpsCursor() )
1776  tweakedMousePos = footprint->GetPosition(); // Use footprint anchor to warp mouse
1777  else
1778  tweakedMousePos = controls()->GetCursorPosition(); // Just use current mouse pos
1779 
1780  // We tweak the mouse position using the value from above, and then use that as the
1781  // start position to prevent the footprint from jumping when we start dragging.
1782  // First we move the visual cross hair cursor...
1783  controls()->ForceCursorPosition( true, tweakedMousePos );
1784  controls()->SetCursorPosition( tweakedMousePos ); // ...then the mouse pointer
1785 
1786  // Now that the mouse is in the right position, get a copy of the position to use later
1787  p = controls()->GetCursorPosition();
1788  }
1789 
1790  int dragMode = aEvent.Parameter<int64_t> ();
1791 
1792  bool dragStarted = m_router->StartDragging( p, itemsToDrag, dragMode );
1793 
1794  if( !dragStarted )
1795  {
1796  if( wasLocked )
1797  item->SetLocked( true );
1798 
1799  return 0;
1800  }
1801 
1802  m_gridHelper->SetAuxAxes( true, p );
1803  controls()->ShowCursor( true );
1804  controls()->SetAutoPan( true );
1805  frame()->UndoRedoBlock( true );
1806 
1807  view()->ClearPreview();
1808  view()->InitPreview();
1809 
1810  auto setCursor =
1811  [&]()
1812  {
1814  };
1815 
1816  // Set initial cursor
1817  setCursor();
1818 
1819  // Set the initial visible area
1820  BOX2D viewAreaD = getView()->GetGAL()->GetVisibleWorldExtents();
1821  m_router->SetVisibleViewArea( BOX2I( viewAreaD.GetOrigin(), viewAreaD.GetSize() ) );
1822 
1823  // Send an initial movement to prime the collision detection
1824  m_router->Move( p, nullptr );
1825 
1826  bool hasMouseMoved = false;
1827 
1828  while( TOOL_EVENT* evt = Wait() )
1829  {
1830  setCursor();
1831 
1832  if( evt->IsCancelInteractive() )
1833  {
1834  if( wasLocked )
1835  item->SetLocked( true );
1836 
1837  break;
1838  }
1839  else if( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
1840  {
1841  hasMouseMoved = true;
1842  updateEndItem( *evt );
1844 
1845  if( footprint )
1846  {
1847  VECTOR2I offset = m_endSnapPoint - p;
1848  BOARD_ITEM* previewItem;
1849  wxPoint fp_offset = wxPoint( offset.Rotate( footprint->GetOrientationRadians() ) );
1850 
1851  view()->ClearPreview();
1852 
1853  for( BOARD_ITEM* drawing : footprint->GraphicalItems() )
1854  {
1855  previewItem = static_cast<BOARD_ITEM*>( drawing->Clone() );
1856 
1857  if( drawing->Type() == PCB_FP_SHAPE_T )
1858  {
1859  FP_SHAPE* shape = static_cast<FP_SHAPE*>( previewItem );
1860  shape->FP_SHAPE::Move( fp_offset );
1861  }
1862  else
1863  {
1864  previewItem->Move( offset );
1865  }
1866 
1867  view()->AddToPreview( previewItem );
1868  view()->Hide( drawing, true );
1869  }
1870 
1871  for( PAD* pad : footprint->Pads() )
1872  {
1873  if( ( pad->GetLayerSet() & LSET::AllCuMask() ).none()
1874  && pad->GetDrillSize().x == 0 )
1875  {
1876  previewItem = static_cast<BOARD_ITEM*>( pad->Clone() );
1877  previewItem->Move( offset );
1878 
1879  view()->AddToPreview( previewItem );
1880  }
1881  else
1882  {
1883  // Pads with copper or holes are handled by the router
1884  }
1885 
1886  view()->Hide( pad, true );
1887  }
1888 
1889  previewItem = static_cast<BOARD_ITEM*>( footprint->Reference().Clone() );
1890  previewItem->Move( offset );
1891  view()->AddToPreview( previewItem );
1892  view()->Hide( &footprint->Reference() );
1893 
1894  previewItem = static_cast<BOARD_ITEM*>( footprint->Value().Clone() );
1895  previewItem->Move( offset );
1896  view()->AddToPreview( previewItem );
1897  view()->Hide( &footprint->Value() );
1898 
1899  for( ZONE* zone : footprint->Zones() )
1900  {
1901  previewItem = static_cast<BOARD_ITEM*>( zone->Clone() );
1902  previewItem->Move( offset );
1903  view()->AddToPreview( previewItem );
1904  view()->Hide( zone, true );
1905  }
1906 
1907  // Update ratsnest
1908  dynamicData->Move( offset - lastOffset );
1909  lastOffset = offset;
1910  connectivityData->ComputeDynamicRatsnest( dynamicItems, dynamicData.get(), offset );
1911  }
1912  }
1913  else if( hasMouseMoved && ( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) )
1914  {
1915  updateEndItem( *evt );
1917  break;
1918  }
1919  else if( evt->Category() == TC_COMMAND )
1920  {
1921  // disallow editing commands
1922  if( evt->IsAction( &ACTIONS::cut )
1923  || evt->IsAction( &ACTIONS::copy )
1924  || evt->IsAction( &ACTIONS::paste )
1925  || evt->IsAction( &ACTIONS::pasteSpecial ) )
1926  {
1927  wxBell();
1928  }
1929  else
1930  {
1931  evt->SetPassEvent();
1932  }
1933  }
1934  else
1935  {
1936  evt->SetPassEvent();
1937  }
1938 
1939  handleCommonEvents( *evt );
1940  }
1941 
1942  if( footprint )
1943  {
1944  for( BOARD_ITEM* drawing : footprint->GraphicalItems() )
1945  view()->Hide( drawing, false );
1946 
1947  view()->Hide( &footprint->Reference(), false );
1948  view()->Hide( &footprint->Value(), false );
1949 
1950  for( ZONE* zone : footprint->Zones() )
1951  view()->Hide( zone, false );
1952 
1953  for( PAD* pad : footprint->Pads() )
1954  view()->Hide( pad, false );
1955 
1956  view()->ClearPreview();
1957  view()->ShowPreview( false );
1958 
1959  connectivityData->ClearDynamicRatsnest();
1960  }
1961 
1962  if( m_router->RoutingInProgress() )
1963  m_router->StopRouting();
1964 
1965  m_gridHelper->SetAuxAxes( false );
1966  controls()->SetAutoPan( false );
1967  controls()->ForceCursorPosition( false );
1968  frame()->UndoRedoBlock( false );
1969  highlightNet( false );
1970 
1971  return 0;
1972 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:759
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hide the item in the view (e.g.
Definition: view.cpp:1537
Base class for PNS router board items.
Definition: pns_item.h:55
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: fp_text.cpp:339
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:283
BOX2< VECTOR2I > BOX2I
Definition: box2.h:506
double GetOrientationRadians() const
Definition: footprint.h:193
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
BOARD * board() const
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1614
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:214
void SyncWorld()
Definition: pns_router.cpp:92
void InitPreview()
Definition: view.cpp:1607
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:190
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move cursor to the requested position expressed in world coordinates.
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
virtual void SetLocked(bool aLocked)
Modify the 'lock' status for of the item.
Definition: board_item.h:218
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
virtual bool IsLocked() const
Definition: board_item.cpp:64
void Add(const LINE &aLine)
Definition: pns_itemset.cpp:32
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
PADS & Pads()
Definition: footprint.h:169
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:499
void ShowPreview(bool aShow=true)
Definition: view.cpp:1628
FP_TEXT & Reference()
Definition: footprint.h:500
PCB_BASE_EDIT_FRAME * frame() const
FP_ZONES & Zones()
Definition: footprint.h:175
static TOOL_ACTION copy
Definition: actions.h:67
virtual void updateEndItem(const TOOL_EVENT &aEvent)
bool GetGridSnapping() const
void SetAuxAxes(bool aEnable, const VECTOR2I &aOrigin=VECTOR2I(0, 0))
Definition: grid_helper.cpp:67
const VECTOR2I snapToItem(ITEM *aSnapToItem, const VECTOR2I &aP)
PCB_GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
const PCB_SELECTION & selection() const
ITEM * FindItemByParent(const BOARD_ITEM *aParent)
Definition: pns_node.cpp:1580
virtual void Move(const wxPoint &aMoveVector)
Move this object.
Definition: board_item.h:233
int Net() const
Definition: pns_item.h:152
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:432
void handleCommonEvents(TOOL_EVENT &evt)
Generic, UI-independent tool event.
Definition: tool_event.h:152
ITEM * m_startItem
Definition: pns_tool_base.h:69
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:675
FOOTPRINT * footprint() const
void SetVisibleViewArea(const BOX2I &aExtents)
Definition: pns_router.h:210
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:345
void ClearPreview()
Definition: view.cpp:1592
static TOOL_ACTION cut
Definition: actions.h:66
KIGFX::PCB_VIEW * view() const
ROUTER * m_router
Definition: pns_tool_base.h:78
DRAWINGS & GraphicalItems()
Definition: footprint.h:172
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
bool DisableGridSnapping() const
Definition: tool_event.h:341
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:428
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void SetAutoPan(bool aEnabled)
Turn 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:98
const PCB_DISPLAY_OPTIONS & displayOptions() const
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
void SetSnap(bool aSnap)
Definition: grid_helper.h:64
static TOOL_ACTION pasteSpecial
Definition: actions.h:69
void StopRouting()
Definition: pns_router.cpp:719
virtual void highlightNet(bool aEnabled, int aNetcode=-1)
int Modifier(int aMask=MD_MODIFIER_MASK) const
Definition: tool_event.h:336
VECTOR2< T > Rotate(double aAngle) const
Rotate the vector by a given angle.
Definition: vector2d.h:371
void SetUseGrid(bool aSnapToGrid)
Definition: grid_helper.h:67
KIGFX::VIEW_CONTROLS * controls() const
Common, abstract interface for edit frames.
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
bool StartDragging(const VECTOR2I &aP, ITEM *aItem, int aDragMode=DM_ANY)
Definition: pns_router.cpp:149
static void NeighboringSegmentFilter(const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector)
int Size() const
Returns the number of selected parts.
Definition: selection.h:104
The selection tool: currently supports:
wxPoint GetPosition() const override
Definition: footprint.h:187
BOX2D GetVisibleWorldExtents() const
bool GetMoveWarpsCursor() const
Indicate that a move operation should warp the mouse pointer to the origin of the move object.
Definition: tools_holder.h:141
void Activate()
Run the tool.
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
const Vec & GetSize() const
Definition: box2.h:172
const Vec & GetOrigin() const
Definition: box2.h:176
bool RoutingInProgress() const
Definition: pns_router.cpp:114
Definition: pad.h:57
NODE * GetWorld() const
Definition: pns_router.h:154
static TOOL_ACTION paste
Definition: actions.h:68
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:56
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:145
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
Abstract interface for drawing on a 2D-surface.

References TOOL_INTERACTIVE::Activate(), PNS::ITEM_SET::Add(), KIGFX::VIEW::AddToPreview(), LSET::AllCuMask(), ARROW, PCB_TOOL_BASE::board(), BUT_LEFT, KIGFX::VIEW::ClearPreview(), FP_TEXT::Clone(), PCB_TOOL_BASE::controls(), ACTIONS::copy, ACTIONS::cut, TOOL_EVENT::DisableGridSnapping(), PCB_TOOL_BASE::displayOptions(), SELECTION::Empty(), PNS::NODE::FindItemByParent(), PNS::ROUTER::FixRoute(), PCB_TOOL_BASE::footprint(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), SELECTION::Front(), PCB_BASE_FRAME::GetCanvas(), BOARD::GetConnectivity(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), KIGFX::VIEW::GetGAL(), KIGFX::GAL::GetGridSnapping(), TOOLS_HOLDER::GetMoveWarpsCursor(), FOOTPRINT::GetOrientationRadians(), BOX2< Vec >::GetOrigin(), FOOTPRINT::GetPosition(), BOX2< Vec >::GetSize(), TOOL_MANAGER::GetTool(), TOOL_BASE::getView(), TOOL_MANAGER::GetView(), KIGFX::GAL::GetVisibleWorldExtents(), PNS::ROUTER::GetWorld(), FOOTPRINT::GraphicalItems(), handleCommonEvents(), KIGFX::VIEW::Hide(), PNS::TOOL_BASE::highlightNet(), KIGFX::VIEW::InitPreview(), BOARD_ITEM::IsLocked(), PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_gridHelper, PNS::TOOL_BASE::m_router, PCB_DISPLAY_OPTIONS::m_ShowModuleRatsnest, PNS::TOOL_BASE::m_startItem, TOOL_BASE::m_toolMgr, MD_SHIFT, TOOL_EVENT::Modifier(), PNS::ROUTER::Move(), BOARD_ITEM::Move(), NeighboringSegmentFilter(), PNS::ITEM::Net(), pad, FOOTPRINT::Pads(), TOOL_EVENT::Parameter(), ACTIONS::paste, ACTIONS::pasteSpecial, PCB_FOOTPRINT_T, PCB_FP_SHAPE_T, PCB_TRACE_T, PCB_VIA_T, FOOTPRINT::Reference(), VECTOR2< T >::Rotate(), 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::SetCursorPosition(), BOARD_ITEM::SetLocked(), GRID_HELPER::SetSnap(), GRID_HELPER::SetUseGrid(), PNS::ROUTER::SetVisibleViewArea(), KIGFX::VIEW_CONTROLS::ShowCursor(), KIGFX::VIEW::ShowPreview(), SELECTION::Size(), PNS::TOOL_BASE::snapToItem(), PNS::ROUTER::StartDragging(), PNS::ROUTER::StopRouting(), PNS::ROUTER::SyncWorld(), TC_COMMAND, EDA_ITEM::Type(), PCB_BASE_EDIT_FRAME::UndoRedoBlock(), PNS::TOOL_BASE::updateEndItem(), FOOTPRINT::Value(), PCB_TOOL_BASE::view(), TOOL_INTERACTIVE::Wait(), and FOOTPRINT::Zones().

Referenced by setTransitions().

◆ Is45Limited()

bool PCB_TOOL_BASE::Is45Limited ( ) const
virtualinherited

Should the tool use its 45° mode option?

Returns
True if set to use 45°

Definition at line 323 of file pcb_tool_base.cpp.

324 {
325  if( frame()->IsType( FRAME_PCB_EDITOR ) )
327  else
329 }
PCB_BASE_EDIT_FRAME * frame() const
PCBNEW_SETTINGS & Settings()

References PCB_TOOL_BASE::frame(), FRAME_PCB_EDITOR, PCBNEW_SETTINGS::m_FpeditUse45DegreeLimit, PCBNEW_SETTINGS::m_PcbUse45DegreeLimit, and PCB_BASE_FRAME::Settings().

Referenced by DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), and DRAWING_TOOL::DrawZone().

◆ IsFootprintEditor()

◆ 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:214
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209
bool IsToolActive(TOOL_ID aId) const
Return true if a tool with given id is active (executing)

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

Referenced by EDIT_TOOL::Drag(), handleLayerSwitch(), EDIT_TOOL::isRouterActive(), PCB_SELECTION_TOOL::Main(), BOARD_EDITOR_CONTROL::TrackWidthDec(), and BOARD_EDITOR_CONTROL::TrackWidthInc().

◆ MainLoop()

int ROUTER_TOOL::MainLoop ( const TOOL_EVENT aEvent)

Definition at line 1349 of file router_tool.cpp.

1350 {
1351  PNS::ROUTER_MODE mode = aEvent.Parameter<PNS::ROUTER_MODE>();
1352  PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
1354 
1355  if( m_router->RoutingInProgress() )
1356  {
1357  if( m_router->Mode() == mode )
1358  return 0;
1359  else
1360  m_router->StopRouting();
1361  }
1362 
1363  // Deselect all items
1365 
1366  std::string tool = aEvent.GetCommandStr().get();
1367  frame->PushTool( tool );
1368 
1369  auto setCursor =
1370  [&]()
1371  {
1373  };
1374 
1375  Activate();
1376  // Must be done after Activate() so that it gets set into the correct context
1377  controls->ShowCursor( true );
1378  controls->ForceCursorPosition( false );
1379  // Set initial cursor
1380  setCursor();
1381 
1382  m_router->SetMode( mode );
1383  m_cancelled = false;
1384 
1385  // Prime the pump
1386  if( aEvent.HasPosition() )
1388 
1389  // Main loop: keep receiving events
1390  while( TOOL_EVENT* evt = Wait() )
1391  {
1392  if( !evt->IsDrag() )
1393  setCursor();
1394 
1395  if( evt->IsCancelInteractive() )
1396  {
1397  frame->PopTool( tool );
1398  break;
1399  }
1400  else if( evt->IsActivate() )
1401  {
1402  if( evt->IsMoveTool() )
1403  {
1404  // leave ourselves on the stack so we come back after the move
1405  break;
1406  }
1407  else
1408  {
1409  frame->PopTool( tool );
1410  break;
1411  }
1412  }
1413  else if( evt->Action() == TA_UNDO_REDO_PRE )
1414  {
1415  m_router->ClearWorld();
1416  }
1417  else if( evt->Action() == TA_UNDO_REDO_POST || evt->Action() == TA_MODEL_CHANGE )
1418  {
1419  m_router->SyncWorld();
1420  }
1421  else if( evt->IsMotion() )
1422  {
1423  updateStartItem( *evt );
1424  }
1425  else if( evt->IsAction( &PCB_ACTIONS::dragFreeAngle ) )
1426  {
1427  updateStartItem( *evt, true );
1429  }
1430  else if( evt->IsAction( &PCB_ACTIONS::drag45Degree ) )
1431  {
1432  updateStartItem( *evt, true );
1434  }
1435  else if( evt->IsAction( &PCB_ACTIONS::breakTrack ) )
1436  {
1437  updateStartItem( *evt, true );
1438  breakTrack( );
1439  evt->SetPassEvent( false );
1440  }
1441  else if( evt->IsClick( BUT_LEFT )
1442  || evt->IsAction( &PCB_ACTIONS::routeSingleTrack )
1443  || evt->IsAction( &PCB_ACTIONS::routeDiffPair ) )
1444  {
1445  updateStartItem( *evt );
1446 
1447  if( evt->HasPosition() )
1448  {
1449  if( evt->Modifier( MD_SHIFT ) )
1451  else
1452  performRouting();
1453  }
1454  }
1455  else if( evt->IsAction( &ACT_PlaceThroughVia ) )
1456  {
1458  }
1459  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1460  {
1462  updateStartItem( *evt );
1463  }
1464  else if( evt->IsKeyPressed() )
1465  {
1466  // wxWidgets fails to correctly translate shifted keycodes on the wxEVT_CHAR_HOOK
1467  // event so we need to process the wxEVT_CHAR event that will follow as long as we
1468  // pass the event.
1469  evt->SetPassEvent();
1470  }
1471  else if( evt->IsClick( BUT_RIGHT ) )
1472  {
1474  }
1475  else
1476  {
1477  evt->SetPassEvent();
1478  }
1479 
1480  if( m_cancelled )
1481  {
1482  frame->PopTool( tool );
1483  break;
1484  }
1485  }
1486 
1487  // Store routing settings till the next invocation
1490 
1491  return 0;
1492 }
static TOOL_ACTION selectionClear
Clear the current selection.
Definition: pcb_actions.h:59
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void ClearViewDecorations()
Definition: pns_router.cpp:747
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:135
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
SIZES_SETTINGS m_savedSizes
Definition: pns_tool_base.h:68
void SyncWorld()
Definition: pns_router.cpp:92
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void PrimeTool(const VECTOR2D &aPosition)
"Prime" a tool by sending a cursor left-click event with the mouse position set to the passed in posi...
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:134
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:201
void breakTrack()
void ClearWorld()
Definition: pns_router.cpp:102
PCB_BASE_EDIT_FRAME * frame() const
virtual PCB_LAYER_ID GetActiveLayer() const
virtual void updateStartItem(const TOOL_EVENT &aEvent, bool aIgnorePads=false)
void performRouting()
const PCB_SELECTION & selection() const
virtual void PopTool(const std::string &actionName)
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:432
Generic, UI-independent tool event.
Definition: tool_event.h:152
ROUTER * m_router
Definition: pns_tool_base.h:78
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
static TOOL_ACTION breakTrack
Break a single track into two segments at the cursor.
Definition: pcb_actions.h:132
void StopRouting()
Definition: pns_router.cpp:719
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:460
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."), BITMAPS::via, AF_NONE,(void *) VIA_ACTION_FLAGS::VIA)
ROUTER_MODE
Definition: pns_router.h:62
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:289
KIGFX::VIEW_CONTROLS * controls() const
void SetMode(ROUTER_MODE aMode)
Definition: pns_router.cpp:843
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:175
void performDragging(int aMode=PNS::DM_ANY)
bool SwitchLayer(int layer)
Definition: pns_router.cpp:762
The main frame for Pcbnew.
void Activate()
Run the tool.
bool HasPosition() const
Definition: tool_event.h:240
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
bool RoutingInProgress() const
Definition: pns_router.cpp:114
ROUTER_MODE Mode() const
Definition: pns_router.h:132
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:287
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:178

References ACT_PlaceThroughVia, TOOL_INTERACTIVE::Activate(), breakTrack(), PCB_ACTIONS::breakTrack, BUT_LEFT, BUT_RIGHT, PNS::ROUTER::ClearViewDecorations(), PNS::ROUTER::ClearWorld(), PCB_TOOL_BASE::controls(), 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, TOOL_INTERACTIVE::m_menu, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_savedSizes, TOOL_BASE::m_toolMgr, MD_SHIFT, PNS::ROUTER::Mode(), TOOL_EVENT::Parameter(), PENCIL, performDragging(), performRouting(), TOOLS_HOLDER::PopTool(), TOOL_MANAGER::PrimeTool(), TOOLS_HOLDER::PushTool(), PCB_ACTIONS::routeDiffPair, PCB_ACTIONS::routeSingleTrack, PNS::ROUTER::RoutingInProgress(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, EDA_DRAW_PANEL_GAL::SetCurrentCursor(), PNS::ROUTER::SetMode(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), PNS::ROUTER::Sizes(), PNS::ROUTER::StopRouting(), 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().

◆ NeighboringSegmentFilter()

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

Definition at line 1594 of file router_tool.cpp.

1595 {
1596  /*
1597  * If the collection contains a trivial line corner (two connected segments)
1598  * or a non-fanout-via (a via with no more than two connected segments), then
1599  * trim the collection down to a single item (which one won't matter since
1600  * they're all connected).
1601  */
1602 
1603  // First make sure we've got something that *might* match.
1604  int vias = aCollector.CountType( PCB_VIA_T );
1605  int traces = aCollector.CountType( PCB_TRACE_T );
1606  int arcs = aCollector.CountType( PCB_ARC_T );
1607 
1608  if( arcs > 0 || vias > 1 || traces > 2 || vias + traces < 1 )
1609  return;
1610 
1611  // Fetch first PCB_TRACK (via or trace) as our reference
1612  PCB_TRACK* reference = nullptr;
1613 
1614  for( int i = 0; !reference && i < aCollector.GetCount(); i++ )
1615  reference = dynamic_cast<PCB_TRACK*>( aCollector[i] );
1616 
1617  int refNet = reference->GetNetCode();
1618 
1619  wxPoint refPoint( aPt.x, aPt.y );
1620  EDA_ITEM_FLAGS flags = reference->IsPointOnEnds( refPoint, -1 );
1621 
1622  if( flags & STARTPOINT )
1623  refPoint = reference->GetStart();
1624  else if( flags & ENDPOINT )
1625  refPoint = reference->GetEnd();
1626 
1627  // Check all items to ensure that any TRACKs are co-terminus with the reference and on
1628  // the same net.
1629  for( int i = 0; i < aCollector.GetCount(); i++ )
1630  {
1631  PCB_TRACK* neighbor = dynamic_cast<PCB_TRACK*>( aCollector[i] );
1632 
1633  if( neighbor && neighbor != reference )
1634  {
1635  if( neighbor->GetNetCode() != refNet )
1636  return;
1637 
1638  if( neighbor->GetStart() != refPoint && neighbor->GetEnd() != refPoint )
1639  return;
1640  }
1641  }
1642 
1643  // Selection meets criteria; trim it to the reference item.
1644  aCollector.Empty();
1645  aCollector.Append( reference );
1646 }
void Empty()
Clear the list.
Definition: collector.h:90
#define STARTPOINT
When a line is selected, these flags indicate which.
const wxPoint & GetEnd() const
Definition: pcb_track.h:105
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
std::uint32_t EDA_ITEM_FLAGS
#define ENDPOINT
ends. (Used to support dragging.)
int CountType(KICAD_T aType)
Count the number of items matching aType.
Definition: collector.h:228
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
void Append(EDA_ITEM *item)
Add an item to the end of the list.
Definition: collector.h:100
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:82
EDA_ITEM_FLAGS IsPointOnEnds(const wxPoint &point, int min_dist=0) const
Function IsPointOnEnds returns STARTPOINT if point if near (dist = min_dist) start point,...
Definition: pcb_track.cpp:181
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
const wxPoint & GetStart() const
Definition: pcb_track.h:108

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

Referenced by CanInlineDrag(), and InlineDrag().

◆ onLayerCommand()

int ROUTER_TOOL::onLayerCommand ( const TOOL_EVENT aEvent)
private

Definition at line 709 of file router_tool.cpp.

710 {
711  return handleLayerSwitch( aEvent, false );
712 }
int handleLayerSwitch(const TOOL_EVENT &aEvent, bool aForceVia)

References handleLayerSwitch().

Referenced by setTransitions().

◆ onTrackViaSizeChanged()

int ROUTER_TOOL::onTrackViaSizeChanged ( const TOOL_EVENT aEvent)
private

Definition at line 2055 of file router_tool.cpp.

2056 {
2057  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
2058 
2059  if( !m_router->GetCurrentNets().empty() )
2061 
2062  m_router->UpdateSizes( sizes );
2063 
2064  // Changing the track width can affect the placement, so call the
2065  // move routine without changing the destination
2066  // Update end item first to avoid moving to an invalid/missing item
2067  updateEndItem( aEvent );
2069 
2071 
2072  return 0;
2073 }
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:781
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:201
virtual void updateEndItem(const TOOL_EVENT &aEvent)
ITEM * m_startItem
Definition: pns_tool_base.h:69
ROUTER * m_router
Definition: pns_tool_base.h:78
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:428
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:570
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
void UpdateMessagePanel()
bool ImportSizes(PNS::SIZES_SETTINGS &aSizes, PNS::ITEM *aStartItem, int aNet) override
PNS_KICAD_IFACE * m_iface
Definition: pns_tool_base.h:77

References PNS::ROUTER::GetCurrentNets(), PNS_KICAD_IFACE_BASE::ImportSizes(), PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_iface, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::ROUTER::Move(), PNS::ROUTER::Sizes(), PNS::TOOL_BASE::updateEndItem(), UpdateMessagePanel(), and PNS::ROUTER::UpdateSizes().

Referenced by CustomTrackWidthDialog(), and setTransitions().

◆ onViaCommand()

int ROUTER_TOOL::onViaCommand ( const TOOL_EVENT aEvent)
private

Definition at line 715 of file router_tool.cpp.

716 {
717  return handleLayerSwitch( aEvent, true );
718 }
int handleLayerSwitch(const TOOL_EVENT &aEvent, bool aForceVia)

References handleLayerSwitch().

Referenced by setTransitions().

◆ performDragging()

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

Definition at line 1495 of file router_tool.cpp.

1496 {
1498 
1499  VIEW_CONTROLS* ctls = getViewControls();
1500 
1501  if( m_startItem && m_startItem->IsLocked() )
1502  {
1503  KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1504  wxOK | wxCANCEL | wxICON_WARNING );
1505  dlg.SetOKLabel( _( "Drag Anyway" ) );
1506  dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1507 
1508  if( dlg.ShowModal() == wxID_CANCEL )
1509  return;
1510  }
1511 
1512  // We don't support dragging arcs inside the PNS right now
1514  {
1515  if( m_router->RoutingInProgress() )
1516  m_router->StopRouting();
1517 
1518  m_startItem = nullptr;
1519 
1520  m_gridHelper->SetAuxAxes( false );
1521  frame()->UndoRedoBlock( false );
1522  ctls->SetAutoPan( false );
1523  ctls->ForceCursorPosition( false );
1524  highlightNet( false );
1525 
1526  m_cancelled = true;
1527 
1529 
1530  return;
1531  }
1532 
1533  bool dragStarted = m_router->StartDragging( m_startSnapPoint, m_startItem, aMode );
1534 
1535  if( !dragStarted )
1536  return;
1537 
1538  if( m_startItem && m_startItem->Net() > 0 )
1539  highlightNet( true, m_startItem->Net() );
1540 
1541  ctls->SetAutoPan( true );
1543  frame()->UndoRedoBlock( true );
1544 
1545  while( TOOL_EVENT* evt = Wait() )
1546  {
1547  ctls->ForceCursorPosition( false );
1548 
1549  if( evt->IsMotion() )
1550  {
1551  updateEndItem( *evt );
1553  }
1554  else if( evt->IsClick( BUT_LEFT ) )
1555  {
1557  break;
1558  }
1559  else if( evt->IsClick( BUT_RIGHT ) )
1560  {
1562  }
1563  else if( evt->IsCancelInteractive() || evt->IsActivate() || evt->IsUndoRedo() )
1564  {
1565  if( evt->IsCancelInteractive() && !m_startItem )
1566  m_cancelled = true;
1567 
1568  if( evt->IsActivate() && !evt->IsMoveTool() )
1569  m_cancelled = true;
1570 
1571  break;
1572  }
1573  else
1574  {
1575  evt->SetPassEvent();
1576  }
1577 
1578  handleCommonEvents( *evt );
1579  }
1580 
1581  if( m_router->RoutingInProgress() )
1582  m_router->StopRouting();
1583 
1584  m_startItem = nullptr;
1585 
1586  m_gridHelper->SetAuxAxes( false );
1587  frame()->UndoRedoBlock( false );
1588  ctls->SetAutoPan( false );
1589  ctls->ForceCursorPosition( false );
1590  highlightNet( false );
1591 }
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:45
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:70
void ClearViewDecorations()
Definition: pns_router.cpp:747
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:134
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
PCB_BASE_EDIT_FRAME * frame() const
virtual void updateEndItem(const TOOL_EVENT &aEvent)
void SetAuxAxes(bool aEnable, const VECTOR2I &aOrigin=VECTOR2I(0, 0))
Definition: grid_helper.cpp:67
PCB_GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
#define _(s)
const PCB_SELECTION & selection() const
int Net() const
Definition: pns_item.h:152
void handleCommonEvents(TOOL_EVENT &evt)
Generic, UI-independent tool event.
Definition: tool_event.h:152
ITEM * m_startItem
Definition: pns_tool_base.h:69
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:675
ROUTER * m_router
Definition: pns_tool_base.h:78
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:428
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
void StopRouting()
Definition: pns_router.cpp:719
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:149
bool IsLocked() const
Definition: pns_item.h:227
PnsKind Kind() const
Return the type (kind) of the item.
Definition: pns_item.h:130
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
bool RoutingInProgress() const
Definition: pns_router.cpp:114
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59

References _, PNS::ITEM::ARC_T, BUT_LEFT, BUT_RIGHT, PNS::ROUTER::ClearViewDecorations(), KIDIALOG::DoNotShowCheckbox(), PCB_ACTIONS::drag45Degree, PNS::ROUTER::FixRoute(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), TOOL_BASE::getViewControls(), handleCommonEvents(), PNS::TOOL_BASE::highlightNet(), PNS::ITEM::IsLocked(), PNS::ITEM::Kind(), PNS::TOOL_BASE::m_cancelled, PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_gridHelper, TOOL_INTERACTIVE::m_menu, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, TOOL_BASE::m_toolMgr, PNS::ROUTER::Move(), PNS::ITEM::Net(), PNS::ROUTER::RoutingInProgress(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), KIGFX::VIEW_CONTROLS::SetAutoPan(), GRID_HELPER::SetAuxAxes(), TOOL_MENU::ShowContextMenu(), 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 1139 of file router_tool.cpp.

1140 {
1142 
1143  if( !prepareInteractive() )
1144  return;
1145 
1146  auto setCursor =
1147  [&]()
1148  {
1150  };
1151 
1152  // Set initial cursor
1153  setCursor();
1154 
1155  while( TOOL_EVENT* evt = Wait() )
1156  {
1157  setCursor();
1158 
1159  // Don't crash if we missed an operation that canceled routing.
1160  if( !m_router->RoutingInProgress() )
1161  {
1162  if( evt->IsCancelInteractive() )
1163  m_cancelled = true;
1164 
1165  break;
1166  }
1167 
1168  handleCommonEvents( *evt );
1169 
1170  if( evt->IsMotion() )
1171  {
1172  updateEndItem( *evt );
1174  }
1175  else if( evt->IsAction( &PCB_ACTIONS::routerUndoLastSegment ) )
1176  {
1178  updateEndItem( *evt );
1180  }
1181  else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &PCB_ACTIONS::routeSingleTrack ) )
1182  {
1183  updateEndItem( *evt );
1184  bool needLayerSwitch = m_router->IsPlacingVia();
1185  bool forceFinish = evt->Modifier( MD_SHIFT );
1186 
1187  if( m_router->FixRoute( m_endSnapPoint, m_endItem, forceFinish ) )
1188  {
1189  break;
1190  }
1191 
1192  if( needLayerSwitch )
1194 
1195  // Synchronize the indicated layer
1196  PCB_LAYER_ID routingLayer = ToLAYER_ID( m_router->GetCurrentLayer() );
1197  PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
1198 
1199  editFrame->SetActiveLayer( routingLayer );
1200 
1201  if( !getView()->IsLayerVisible( routingLayer ) )
1202  {
1203  editFrame->GetAppearancePanel()->SetLayerVisible( routingLayer, true );
1204  editFrame->GetCanvas()->Refresh();
1205  }
1206 
1207  updateEndItem( *evt );
1209  m_startItem = nullptr;
1210  }
1211  else if( evt->IsAction( &ACT_SwitchCornerMode ) )
1212  {
1215  updateEndItem( *evt );
1216  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
1217  }
1218  else if( evt->IsAction( &ACT_SwitchPosture ) )
1219  {
1220  m_router->FlipPosture();
1221  updateEndItem( *evt );
1222  m_router->Move( m_endSnapPoint, m_endItem ); // refresh
1223  }
1224  else if( evt->IsAction( &PCB_ACTIONS::properties ) )
1225  {
1227  controls()->SetAutoPan( false );
1228  {
1230  }
1231  controls()->SetAutoPan( true );
1232  setCursor();
1234  }
1235  else if( evt->IsAction( &ACT_EndTrack ) || evt->IsDblClick( BUT_LEFT ) )
1236  {
1237  // Stop current routing:
1239  break;
1240  }
1241  else if( evt->IsCancelInteractive() || evt->IsActivate()
1242  || evt->IsUndoRedo()
1243  || evt->IsAction( &PCB_ACTIONS::routerInlineDrag ) )
1244  {
1245  if( evt->IsCancelInteractive() && !m_router->RoutingInProgress() )
1246  m_cancelled = true;
1247 
1248  if( evt->IsActivate() && !evt->IsMoveTool() )
1249  m_cancelled = true;
1250 
1251  break;
1252  }
1253  else if( evt->IsClick( BUT_RIGHT ) )
1254  {
1256  }
1257  else
1258  {
1259  evt->SetPassEvent();
1260  }
1261  }
1262 
1264 
1266 }
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
bool finishInteractive()
static const TOOL_ACTION ACT_SwitchCornerMode("pcbnew.InteractiveRouter.SwitchRounding", AS_CONTEXT, MD_CTRL+'/', "", _("Track Corner Mode"), _("Switches between sharp/rounded and 45°/90° corners when routing tracks."), BITMAPS::switch_corner_rounding_shape)
void ToggleCornerMode()
Definition: pns_router.cpp:818
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."), BITMAPS::change_entry_orient)
static TOOL_ACTION routerUndoLastSegment
Definition: pcb_actions.h:189
void CommitRouting()
Definition: pns_router.cpp:710
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void ClearViewDecorations()
Definition: pns_router.cpp:747
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:117
bool IsPlacingVia() const
Definition: pns_router.cpp:809
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
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."), BITMAPS::width_track)
static const TOOL_ACTION ACT_EndTrack("pcbnew.InteractiveRouter.EndTrack", AS_CONTEXT, WXK_END, "", _("Finish Track"), _("Stops laying the current track."), BITMAPS::checked_ok)
PCB_BASE_EDIT_FRAME * frame() const
void UndoLastSegment()
Definition: pns_router.cpp:701
virtual void updateEndItem(const TOOL_EVENT &aEvent)
bool prepareInteractive()
const PCB_SELECTION & selection() const
void handleCommonEvents(TOOL_EVENT &evt)
Generic, UI-independent tool event.
Definition: tool_event.h:152
ITEM * m_startItem
Definition: pns_tool_base.h:69
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:675
ROUTER * m_router
Definition: pns_tool_base.h:78
void switchLayerOnViaPlacement()
void Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:428
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:203
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
KIGFX::VIEW_CONTROLS * controls() const
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:175
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
void UpdateMessagePanel()
The main frame for Pcbnew.
void FlipPosture()
Definition: pns_router.cpp:753
bool RoutingInProgress() const
Definition: pns_router.cpp:114
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:914
int GetCurrentLayer() const
Definition: pns_router.cpp:792

References ACT_CustomTrackWidth, ACT_EndTrack, ACT_SwitchCornerMode, ACT_SwitchPosture, ARROW, BUT_LEFT, BUT_RIGHT, PNS::ROUTER::ClearViewDecorations(), PNS::ROUTER::CommitRouting(), PCB_TOOL_BASE::controls(), finishInteractive(), PNS::ROUTER::FixRoute(), PNS::ROUTER::FlipPosture(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), PNS::ROUTER::GetCurrentLayer(), TOOL_BASE::getView(), handleCommonEvents(), PNS::ROUTER::IsPlacingVia(), PNS::TOOL_BASE::m_cancelled, PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, TOOL_INTERACTIVE::m_menu, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, TOOL_BASE::m_toolMgr, MD_SHIFT, PNS::ROUTER::Move(), PENCIL, prepareInteractive(), PCB_ACTIONS::properties, PCB_ACTIONS::routerInlineDrag, PCB_ACTIONS::routerUndoLastSegment, PCB_ACTIONS::routeSingleTrack, PNS::ROUTER::RoutingInProgress(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), TOOL_MENU::ShowContextMenu(), switchLayerOnViaPlacement(), PNS::ROUTER::ToggleCornerMode(), ToLAYER_ID(), PNS::ROUTER::UndoLastSegment(), PNS::TOOL_BASE::updateEndItem(), UpdateMessagePanel(), 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 99 of file pns_tool_base.cpp.

101 {
102  int tl = aLayer > 0 ? aLayer : getView()->GetTopLayer();
103 
104  static const int candidateCount = 5;
105  ITEM* prioritized[candidateCount];
106  SEG::ecoord dist[candidateCount];
107 
108  for( int i = 0; i < candidateCount; i++ )
109  {
110  prioritized[i] = nullptr;
111  dist[i] = VECTOR2I::ECOORD_MAX;
112  }
113 
114  ITEM_SET candidates = m_router->QueryHoverItems( aWhere );
115 
116  if( candidates.Empty() )
117  candidates = m_router->QueryHoverItems( aWhere, true );
118 
119  for( ITEM* item : candidates.Items() )
120  {
121  if( !item->IsRoutable() )
122  continue;
123 
124  if( !IsCopperLayer( item->Layers().Start() ) )
125  continue;
126 
127  if( !m_iface->IsAnyLayerVisible( item->Layers() ) )
128  continue;
129 
130  if( alg::contains( aAvoidItems, item ) )
131  continue;
132 
133  // fixme: this causes flicker with live loop removal...
134  //if( item->Parent() && !item->Parent()->ViewIsVisible() )
135  // continue;
136 
137  if( aNet <= 0 || item->Net() == aNet )
138  {
139  if( item->OfKind( ITEM::VIA_T | ITEM::SOLID_T ) )
140  {
141  if( item->OfKind( ITEM::SOLID_T ) && aIgnorePads )
142  continue;
143 
144  SEG::ecoord d = ( item->Shape()->Centre() - aWhere ).SquaredEuclideanNorm();
145 
146  if( d < dist[2] )
147  {
148  prioritized[2] = item;
149  dist[2] = d;
150  }
151 
152  if( item->Layers().Overlaps( tl ) && d < dist[0] )
153  {
154  prioritized[0] = item;
155  dist[0] = d;
156  }
157  }
158  else // ITEM::SEGMENT_T | ITEM::ARC_T
159  {
160  LINKED_ITEM* li = static_cast<LINKED_ITEM*>( item );
161  SEG::ecoord d = std::min( ( li->Anchor( 0 ) - aWhere ).SquaredEuclideanNorm(),
162  ( li->Anchor( 1 ) - aWhere ).SquaredEuclideanNorm() );
163 
164  if( d < dist[3] )
165  {
166  prioritized[3] = item;
167  dist[3] = d;
168  }
169 
170  if( item->Layers().Overlaps( tl ) && d < dist[1] )
171  {
172  prioritized[1] = item;
173  dist[1] = d;
174  }
175  }
176  }
177  else if ( item->Net() == 0 && m_router->Settings().Mode() == RM_MarkObstacles )
178  {
179  // Allow unconnected items as last resort in RM_MarkObstacles mode
180  if( item->OfKind( ITEM::SOLID_T ) && aIgnorePads )
181  continue;
182 
183  if( item->Layers().Overlaps( tl ) )
184  prioritized[4] = item;
185  }
186  }
187 
188  ITEM* rv = nullptr;
189 
191 
192  for( int i = 0; i < candidateCount; i++ )
193  {
194  ITEM* item = prioritized[i];
195 
196  if( highContrast && item && !item->Layers().Overlaps( tl ) )
197  item = nullptr;
198 
199  if( item && ( aLayer < 0 || item->Layers().Overlaps( aLayer ) ) )
200  {
201  rv = item;
202  break;
203  }
204  }
205 
206  if( rv )
207  {
208  wxLogTrace( wxT( "PNS" ), wxT( "%s, layer : %d, tl: %d" ),
209  rv->KindStr().c_str(),
210  rv->Layers().Start(),
211  tl );
212  }
213 
214  return rv;
215 }
const ITEM_SET QueryHoverItems(const VECTOR2I &aP, bool aUseClearance=false)
Definition: pns_router.cpp:120
VECTOR2I::extended_type ecoord
Definition: seg.h:43
static constexpr extended_type ECOORD_MAX
Definition: vector2d.h:79
virtual int GetTopLayer() const
Definition: view.cpp:817
Inactive layers are shown normally (no high-contrast mode)
ROUTER * m_router
Definition: pns_tool_base.h:78
PNS_MODE Mode() const
Set the routing mode.
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:808
const PCB_DISPLAY_OPTIONS & displayOptions() const
Ignore collisions, mark obstacles.
PNS_KICAD_IFACE * m_iface
Definition: pns_tool_base.h:77
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:182
bool IsAnyLayerVisible(const LAYER_RANGE &aLayer) const override

References PNS::ITEM::Anchor(), alg::contains(), PCB_TOOL_BASE::displayOptions(), VECTOR2< T >::ECOORD_MAX, PNS::ITEM_SET::Empty(), KIGFX::VIEW::GetTopLayer(), TOOL_BASE::getView(), PNS_KICAD_IFACE::IsAnyLayerVisible(), IsCopperLayer(), PNS::ITEM_SET::Items(), PNS::ITEM::KindStr(), PNS::ITEM::Layers(), PCB_DISPLAY_OPTIONS::m_ContrastModeDisplay, PNS::TOOL_BASE::m_iface, PNS::TOOL_BASE::m_router, PNS::ROUTING_SETTINGS::Mode(), NORMAL, 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 1058 of file router_tool.cpp.

1059 {
1060  PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
1061  int routingLayer = getStartLayer( m_startItem );
1062 
1063  if( !IsCopperLayer( routingLayer ) )
1064  {
1065  editFrame->ShowInfoBarError( _( "Tracks on Copper layers only." ) );
1066  return false;
1067  }
1068 
1069  editFrame->SetActiveLayer( ToLAYER_ID( routingLayer ) );
1070 
1071  if( !getView()->IsLayerVisible( routingLayer ) )
1072  {
1073  editFrame->GetAppearancePanel()->SetLayerVisible( routingLayer, true );
1074  editFrame->GetCanvas()->Refresh();
1075  }
1076 
1077  if( m_startItem && m_startItem->Net() > 0 )
1078  highlightNet( true, m_startItem->Net() );
1079 
1080  controls()->SetAutoPan( true );
1081 
1082  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
1083 
1084  m_iface->SetStartLayer( routingLayer );
1085 
1087  m_iface->ImportSizes( sizes, m_startItem, -1 );
1088  sizes.AddLayerPair( frame()->GetScreen()->m_Route_Layer_TOP,
1089  frame()->GetScreen()->m_Route_Layer_BOTTOM );
1090 
1091  m_router->UpdateSizes( sizes );
1092 
1093  if( !m_router->StartRouting( m_startSnapPoint, m_startItem, routingLayer ) )
1094  {
1095  // It would make more sense to leave the net highlighted as the higher-contrast mode
1096  // makes the router clearances more visible. However, since we just started routing
1097  // the conversion of the screen from low contrast to high contrast is a bit jarring and
1098  // makes the infobar coming up less noticeable.
1099  highlightNet( false );
1100 
1102  [&]()
1103  {
1105  } );
1106 
1107  controls()->SetAutoPan( false );
1108  return false;
1109  }
1110 
1111  m_endItem = nullptr;
1113 
1115  frame()->UndoRedoBlock( true );
1116 
1117  return true;
1118 }
const wxString & FailureReason() const
Definition: pns_router.h:204
void SetStartLayer(int aLayer)
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.
void ClearViewDecorations()
Definition: pns_router.cpp:747
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:201
APPEARANCE_CONTROLS * GetAppearancePanel()
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
PCB_BASE_EDIT_FRAME * frame() const
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
#define _(s)
int Net() const
Definition: pns_item.h:152
ITEM * m_startItem
Definition: pns_tool_base.h:69
ROUTER * m_router
Definition: pns_tool_base.h:78
bool StartRouting(const VECTOR2I &aP, ITEM *aItem, int aLayer)
Definition: pns_router.cpp:371
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:808
virtual void highlightNet(bool aEnabled, int aNetcode=-1)
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:570
KIGFX::VIEW_CONTROLS * controls() const
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:74
void UpdateMessagePanel()
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
The main frame for Pcbnew.
void SetLayerVisible(LAYER_NUM aLayer, bool isVisible)
BOARD * GetBoard() const
int getStartLayer(const PNS::ITEM *aItem)
bool ImportSizes(PNS::SIZES_SETTINGS &aSizes, PNS::ITEM *aStartItem, int aNet) override
PNS_KICAD_IFACE * m_iface
Definition: pns_tool_base.h:77
void SetActiveLayer(PCB_LAYER_ID aLayer) override
Change the currently active layer to aLayer and also update the APPEARANCE_CONTROLS.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:914

References _, PNS::ROUTER::ClearViewDecorations(), PCB_TOOL_BASE::controls(), PNS::ROUTER::FailureReason(), PCB_TOOL_BASE::frame(), PCB_BASE_EDIT_FRAME::GetAppearancePanel(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), BOARD::GetDesignSettings(), getStartLayer(), TOOL_BASE::getView(), PNS::TOOL_BASE::highlightNet(), PNS_KICAD_IFACE_BASE::ImportSizes(), IsCopperLayer(), PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_iface, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, BOARD_DESIGN_SETTINGS::m_TempOverrideTrackWidth, PNS::ITEM::Net(), EDA_DRAW_PANEL_GAL::Refresh(), PCB_EDIT_FRAME::SetActiveLayer(), KIGFX::VIEW_CONTROLS::SetAutoPan(), APPEARANCE_CONTROLS::SetLayerVisible(), PNS_KICAD_IFACE_BASE::SetStartLayer(), EDA_BASE_FRAME::ShowInfoBarError(), PNS::ROUTER::Sizes(), PNS::ROUTER::StartRouting(), ToLAYER_ID(), PCB_BASE_EDIT_FRAME::UndoRedoBlock(), UpdateMessagePanel(), and PNS::ROUTER::UpdateSizes().

Referenced by performRouting().

◆ Reset()

void ROUTER_TOOL::Reset ( RESET_REASON  aReason)
overridevirtual

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

496 {
498 
499  if( aReason == RUN )
500  TOOL_BASE::Reset( aReason );
501 }
Tool is invoked after being inactive.
Definition: tool_base.h:79
virtual void Reset(RESET_REASON aReason)=0
Bring the tool to a known, initial state.
int m_lastTargetLayer
Definition: router_tool.h:91

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

◆ Router()

ROUTER * TOOL_BASE::Router ( ) const
inherited

◆ RoutingInProgress()

bool ROUTER_TOOL::RoutingInProgress ( )

Returns whether routing is currently active.

Returns
True if actively routing, false if not routing or tool is activated and idle.

Definition at line 1336 of file router_tool.cpp.

1337 {
1338  return m_router->RoutingInProgress();
1339 }
ROUTER * m_router
Definition: pns_tool_base.h:78
bool RoutingInProgress() const
Definition: pns_router.cpp:114

References PNS::TOOL_BASE::m_router, and PNS::ROUTER::RoutingInProgress().

Referenced by PCB_SELECTION_TOOL::Main().

◆ RunMainStack()

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

Call 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:214
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)

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

Referenced by DRAWING_TOOL::PlaceText().

◆ saveRouterDebugLog()

void ROUTER_TOOL::saveRouterDebugLog ( )
private

Definition at line 506 of file router_tool.cpp.

507 {
508  auto logger = m_router->Logger();
509 
510  if( ! logger )
511  return;
512 
513  wxString cwd = wxGetCwd();
514 
515  wxFileName fname_log( cwd );
516  fname_log.SetName( "pns.log" );
517 
518  wxFileName fname_dump( cwd );
519  fname_dump.SetName( "pns.dump" );
520 
521  wxString msg = wxString::Format( _( "Event file: %s\nBoard dump: %s" ), fname_log.GetFullPath(), fname_log.GetFullPath() );
522 
523  int rv = OKOrCancelDialog( nullptr, _("Save router log"), _("Would you like to save the router\nevent log for debugging purposes?"), msg, _("OK"), _("Cancel") );
524 
525  if( !rv )
526  return;
527 
528  FILE *f = fopen( fname_log.GetFullPath().c_str(), "wb" );
529 
530  // save base router configuration (mode, etc.)
531  fprintf(f, "config %d %d %d %d\n",
532  m_router->Settings().Mode(),
533  m_router->Settings().RemoveLoops() ? 1 : 0,
534  m_router->Settings().GetFixAllSegments() ? 1 : 0,
535  static_cast<int>( m_router->Settings().GetCornerMode() )
536  );
537 
538  const auto& events = logger->GetEvents();
539 
540  for( auto evt : events)
541  {
542  fprintf( f, "event %d %d %d %s\n", evt.p.x, evt.p.y, evt.type,
543  static_cast<const char*>( evt.uuid.AsString().c_str() ) );
544  }
545 
546  fclose( f );
547 
548  // Export as *.kicad_pcb format, using a strategy which is specifically chosen
549  // as an example on how it could also be used to send it to the system clipboard.
550 
551  PCB_PLUGIN pcb_io;
552 
553  pcb_io.Save( fname_dump.GetFullPath(), m_iface->GetBoard(), nullptr );
554 }
BOARD * GetBoard() const
DIRECTION_45::CORNER_MODE GetCornerMode() const
virtual void Save(const wxString &aFileName, BOARD *aBoard, const PROPERTIES *aProperties=nullptr) override
Write aBoard to a storage file in a format that this PLUGIN implementation knows about or it can be u...
Definition: pcb_plugin.cpp:338
A PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
Definition: pcb_plugin.h:141
bool RemoveLoops() const
Enable/disable loop (redundant track) removal.
#define _(s)
ROUTER * m_router
Definition: pns_tool_base.h:78
PNS_MODE Mode() const
Set the routing mode.
int OKOrCancelDialog(wxWindow *aParent, const wxString &aWarning, const wxString &aMessage, const wxString &aDetailedMessage, const wxString &aOKLabel, const wxString &aCancelLabel, bool *aApplyToAll)
Display a warning dialog with aMessage and returns the user response.
Definition: confirm.cpp:252
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
LOGGER * Logger()
Definition: pns_router.cpp:803
PNS_KICAD_IFACE * m_iface
Definition: pns_tool_base.h:77
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:182

References _, Format(), PNS_KICAD_IFACE_BASE::GetBoard(), PNS::ROUTING_SETTINGS::GetCornerMode(), PNS::ROUTING_SETTINGS::GetFixAllSegments(), PNS::ROUTER::Logger(), PNS::TOOL_BASE::m_iface, PNS::TOOL_BASE::m_router, PNS::ROUTING_SETTINGS::Mode(), OKOrCancelDialog(), PNS::ROUTING_SETTINGS::RemoveLoops(), PCB_PLUGIN::Save(), and PNS::ROUTER::Settings().

Referenced by handleCommonEvents().

◆ SelectCopperLayerPair()

int ROUTER_TOOL::SelectCopperLayerPair ( const TOOL_EVENT aEvent)

Definition at line 326 of file sel_layer.cpp.

327 {
328  PCB_SCREEN* screen = frame()->GetScreen();
329 
331  screen->m_Route_Layer_BOTTOM );
332 
333  if( dlg.ShowModal() == wxID_OK )
334  {
335  dlg.GetLayerPair( screen->m_Route_Layer_TOP, screen->m_Route_Layer_BOTTOM );
336 
337  // select the same layer for both layers is allowed (normal in some boards)
338  // but could be a mistake. So display an info message
339  if( screen->m_Route_Layer_TOP == screen->m_Route_Layer_BOTTOM )
340  DisplayInfoMessage( frame(), _( "Warning: top and bottom layers are same." ) );
341  }
342 
343  return 0;
344 }
PCB_BASE_EDIT_FRAME * frame() const
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:44
#define _(s)
BOARD * GetBoard()
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:307
PCB_LAYER_ID m_Route_Layer_TOP
Definition: pcb_screen.h:43
Display a pair PCB copper layers list in a dialog to select a layer pair from these lists.
Definition: sel_layer.cpp:297

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 PCB_SELECTION & PCB_TOOL_BASE::selection ( ) const
protectedinherited

Definition at line 307 of file pcb_tool_base.cpp.

308 {
310 
311  return selTool->GetSelection();
312 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
PCB_SELECTION & GetSelection()
Return the set of currently selected items.
The selection tool: currently supports:

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

Referenced by AUTOPLACE_TOOL::autoplaceSelected(), BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), CanInlineDrag(), EDIT_TOOL::ChangeTrackWidth(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), DRC_TOOL::CrossProbe(), BOARD_INSPECTION_TOOL::CrossProbePcbToSch(), BOARD_INSPECTION_TOOL::doHideNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::Drag(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawZone(), EDIT_TOOL::Duplicate(), BOARD_EDITOR_CONTROL::EditFpInFpEditor(), PAD_TOOL::EditPad(), GROUP_TOOL::EnterGroup(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), EDIT_TOOL::FilletTracks(), PCB_SELECTION_TOOL::filterSelection(), EDIT_TOOL::Flip(), DRAWING_TOOL::getSourceZoneForAction(), GROUP_TOOL::Group(), BOARD_INSPECTION_TOOL::highlightNet(), InlineBreakTrack(), InlineDrag(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectConstraints(), DRAWING_TOOL::InteractivePlaceWithPreview(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), EDIT_TOOL::Mirror(), BOARD_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), PCB_POINT_EDITOR::OnSelectionChange(), PAD_TOOL::pastePadProperties(), performDragging(), performRouting(), LENGTH_TUNER_TOOL::performTuning(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), DRAWING_TOOL::PlaceImportedGraphics(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), BOARD_REANNOTATE_TOOL::ReannotateDuplicatesInSelection(), GROUP_TOOL::RemoveFromGroup(), GLOBAL_EDIT_TOOL::RemoveUnusedPads(), EDIT_TOOL::Rotate(), PCB_SELECTION_TOOL::selectNet(), DRAWING_TOOL::SetAnchor(), BOARD_EDITOR_CONTROL::TrackWidthDec(), BOARD_EDITOR_CONTROL::TrackWidthInc(), GROUP_TOOL::Ungroup(), PCB_CONTROL::UpdateMessagePanel(), BOARD_INSPECTION_TOOL::UpdateSelectionRatsnest(), BOARD_EDITOR_CONTROL::ViaSizeDec(), BOARD_EDITOR_CONTROL::ViaSizeInc(), BOARD_EDITOR_CONTROL::ZoneDuplicate(), ZONE_FILLER_TOOL::ZoneFill(), BOARD_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfill().

◆ selection() [2/2]

PCB_SELECTION & PCB_TOOL_BASE::selection ( )
protectedinherited

Definition at line 315 of file pcb_tool_base.cpp.

316 {
318 
319  return selTool->GetSelection();
320 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
PCB_SELECTION & GetSelection()
Return the set of currently selected items.
The selection tool: currently supports:

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

◆ SetContextMenu()

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

Assign 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:214
void SetTool(TOOL_INTERACTIVE *aTool)
Set a tool that is the creator of the menu.
void ScheduleContextMenu(TOOL_BASE *aTool, ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Set behavior of the tool's context popup menu.

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

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

◆ SetIsFootprintEditor()

void PCB_TOOL_BASE::SetIsFootprintEditor ( bool  aEnabled)
inlineinherited

Function SetIsFootprintEditor()

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

Parameters
aEnableddecides if the mode should be enabled.

Definition at line 103 of file pcb_tool_base.h.

103 { m_isFootprintEditor = aEnabled; }
bool m_isFootprintEditor

References PCB_TOOL_BASE::m_isFootprintEditor.

◆ SettingsDialog()

int ROUTER_TOOL::SettingsDialog ( const TOOL_EVENT aEvent)

Definition at line 1289 of file router_tool.cpp.

1290 {
1291  DIALOG_PNS_SETTINGS settingsDlg( frame(), m_router->Settings() );
1292 
1293  settingsDlg.ShowModal();
1294 
1296 
1297  return 0;
1298 }
PCB_BASE_EDIT_FRAME * frame() const
ROUTER * m_router
Definition: pns_tool_base.h:78
void UpdateMessagePanel()
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:182

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

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

2158 {
2160 
2171 
2178 
2213 
2216 }
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:282
static TOOL_ACTION layerInner26
Definition: pcb_actions.h:277
int onLayerCommand(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerNext
Definition: pcb_actions.h:283
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:253
int MainLoop(const TOOL_EVENT &aEvent)
static TOOL_ACTION selectLayerPair
Definition: pcb_actions.h:129
int DpDimensionsDialog(const TOOL_EVENT &aEvent)
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."), BITMAPS::select_w_layer, AF_NONE,(void *)(VIA_ACTION_FLAGS::BLIND_VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:256
static TOOL_ACTION layerInner6
Definition: pcb_actions.h:257
static TOOL_ACTION routerDiffPairDialog
Definition: pcb_actions.h:193
static TOOL_ACTION layerInner7
Definition: pcb_actions.h:258
static TOOL_ACTION layerInner8
Definition: pcb_actions.h:259
static TOOL_ACTION layerInner21
Definition: pcb_actions.h:272
int InlineDrag(const TOOL_EVENT &aEvent)
int CycleRouterMode(const TOOL_EVENT &aEvent)
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."), BITMAPS::width_track)
static TOOL_ACTION routerHighlightMode
Actions to enable switching modes via hotkey assignments.
Definition: pcb_actions.h:197
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:299
static TOOL_ACTION layerInner3
Definition: pcb_actions.h:254
static TOOL_ACTION layerInner24
Definition: pcb_actions.h:275
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
int ChangeRouterMode(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner11
Definition: pcb_actions.h:262
static TOOL_ACTION layerTop
Definition: pcb_actions.h:251
static TOOL_ACTION layerInner23
Definition: pcb_actions.h:274
int onViaCommand(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerSettingsDialog
Activation of the Push and Shove settings dialogs.
Definition: pcb_actions.h:192
static TOOL_ACTION layerInner13
Definition: pcb_actions.h:264
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:284
static TOOL_ACTION layerInner25
Definition: pcb_actions.h:276
static TOOL_ACTION layerInner18
Definition: pcb_actions.h:269
static TOOL_ACTION layerInner30
Definition: pcb_actions.h:281
static TOOL_ACTION layerInner29
Definition: pcb_actions.h:280
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."), BITMAPS::via_buried, AF_NONE,(void *) VIA_ACTION_FLAGS::BLIND_VIA)
static TOOL_ACTION layerInner10
Definition: pcb_actions.h:261
int SettingsDialog(const TOOL_EVENT &aEvent)
int CustomTrackWidthDialog(const TOOL_EVENT &aEvent)
static TOOL_ACTION cycleRouterMode
Definition: pcb_actions.h:200
static TOOL_ACTION routerWalkaroundMode
Definition: pcb_actions.h:199
static TOOL_ACTION layerInner15
Definition: pcb_actions.h:266
int onTrackViaSizeChanged(const TOOL_EVENT &aEvent)
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:203
static TOOL_ACTION layerInner28
Definition: pcb_actions.h:279
static TOOL_ACTION layerInner27
Definition: pcb_actions.h:278
static TOOL_ACTION layerInner17
Definition: pcb_actions.h:268
static TOOL_ACTION breakTrack
Break a single track into two segments at the cursor.
Definition: pcb_actions.h:132
static TOOL_ACTION layerInner20
Definition: pcb_actions.h:271
static const TOOL_ACTION ACT_SelLayerAndPlaceMicroVia("pcbnew.InteractiveRouter.SelLayerAndPlaceMicroVia", AS_CONTEXT, 0, "", _("Select Layer and Place Micro Via..."), _("Select a layer, then add a micro via at the end of currently routed track."), BITMAPS::select_w_layer, AF_NONE,(void *)(VIA_ACTION_FLAGS::MICROVIA|VIA_ACTION_FLAGS::SELECT_LAYER))
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."), BITMAPS::via_microvia, AF_NONE,(void *) VIA_ACTION_FLAGS::MICROVIA)
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."), BITMAPS::via, AF_NONE,(void *) VIA_ACTION_FLAGS::VIA)
static TOOL_ACTION layerInner22
Definition: pcb_actions.h:273
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:175
static TOOL_ACTION layerInner14
Definition: pcb_actions.h:265
static TOOL_ACTION layerInner9
Definition: pcb_actions.h:260
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."), BITMAPS::select_w_layer, AF_NONE,(void *)(VIA_ACTION_FLAGS::VIA|VIA_ACTION_FLAGS::SELECT_LAYER))
TOOL_EVENT MakeEvent() const
Return the event associated with the action (i.e.
Definition: tool_action.cpp:72
int InlineBreakTrack(const TOOL_EVENT &aEvent)
static TOOL_ACTION layerInner16
Definition: pcb_actions.h:267
int SelectCopperLayerPair(const TOOL_EVENT &aEvent)
Definition: sel_layer.cpp:326
static TOOL_ACTION layerInner4
Definition: pcb_actions.h:255
static TOOL_ACTION layerInner19
Definition: pcb_actions.h:270
static TOOL_ACTION layerInner1
Definition: pcb_actions.h:252
static TOOL_ACTION routerShoveMode
Definition: pcb_actions.h:198
static TOOL_ACTION layerInner12
Definition: pcb_actions.h:263
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:178

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

◆ snapToItem()

const VECTOR2I TOOL_BASE::snapToItem ( ITEM aSnapToItem,
const VECTOR2I aP 
)
protectedinherited

Definition at line 369 of file pns_tool_base.cpp.

370 {
371  if( !aItem || !m_iface->IsItemVisible( aItem ) )
372  {
373  return m_gridHelper->Align( aP );
374  }
375 
376  switch( aItem->Kind() )
377  {
378  case ITEM::SOLID_T:
379  return static_cast<SOLID*>( aItem )->Pos();
380 
381  case ITEM::VIA_T:
382  return static_cast<VIA*>( aItem )->Pos();
383 
384  case ITEM::SEGMENT_T:
385  case ITEM::ARC_T:
386  {
387  LINKED_ITEM* li = static_cast<LINKED_ITEM*>( aItem );
388  VECTOR2I A = li->Anchor( 0 );
389  VECTOR2I B = li->Anchor( 1 );
390  SEG::ecoord w_sq = SEG::Square( li->Width() / 2 );
391  SEG::ecoord distA_sq = ( aP - A ).SquaredEuclideanNorm();
392  SEG::ecoord distB_sq = ( aP - B ).SquaredEuclideanNorm();
393 
394  if( distA_sq < w_sq || distB_sq < w_sq )
395  {
396  return ( distA_sq < distB_sq ) ? A : B;
397  }
398  else if( aItem->Kind() == ITEM::SEGMENT_T )
399  {
400  // TODO(snh): Clean this up
401  SEGMENT* seg = static_cast<SEGMENT*>( li );
402  return m_gridHelper->AlignToSegment( aP, seg->Seg() );
403  }
404  else if( aItem->Kind() == ITEM::ARC_T )
405  {
406  ARC* arc = static_cast<ARC*>( li );
407  return m_gridHelper->AlignToArc( aP, *static_cast<const SHAPE_ARC*>( arc->Shape() ) );
408  }
409 
410  break;
411  }
412 
413  default:
414  break;
415  }
416 
417  return m_gridHelper->Align( aP );
418 }
VECTOR2I::extended_type ecoord
Definition: seg.h:43
static SEG::ecoord Square(int a)
Definition: seg.h:122
VECTOR2I AlignToArc(const VECTOR2I &aPoint, const SHAPE_ARC &aSeg)
PCB_GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
bool IsItemVisible(const PNS::ITEM *aItem) const override
virtual VECTOR2I Align(const VECTOR2I &aPoint) const
Definition: grid_helper.cpp:95
PNS_KICAD_IFACE * m_iface
Definition: pns_tool_base.h:77
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)

References GRID_HELPER::Align(), PCB_GRID_HELPER::AlignToArc(), PCB_GRID_HELPER::AlignToSegment(), PNS::ITEM::Anchor(), PNS::ITEM::ARC_T, 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::ARC::Shape(), PNS::ITEM::SOLID_T, SEG::Square(), PNS::ITEM::VIA_T, and PNS::LINKED_ITEM::Width().

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

◆ switchLayerOnViaPlacement()

void ROUTER_TOOL::switchLayerOnViaPlacement ( )
private

Definition at line 601 of file router_tool.cpp.

602 {
603  int al = frame()->GetActiveLayer();
604  int cl = m_router->GetCurrentLayer();
605 
606  if( cl != al )
607  {
608  m_router->SwitchLayer( al );
609  }
610 
611  OPT<int> newLayer = m_router->Sizes().PairedLayer( cl );
612 
613  if( !newLayer )
614  newLayer = m_router->Sizes().GetLayerTop();
615 
616  m_router->SwitchLayer( *newLayer );
617  m_lastTargetLayer = *newLayer;
618 }
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:201
PCB_BASE_EDIT_FRAME * frame() const
virtual PCB_LAYER_ID GetActiveLayer() const
ROUTER * m_router
Definition: pns_tool_base.h:78
bool SwitchLayer(int layer)
Definition: pns_router.cpp:762
boost::optional< T > OPT
Definition: optional.h:7
int m_lastTargetLayer
Definition: router_tool.h:91
OPT< int > PairedLayer(int aLayerId)
int GetCurrentLayer() const
Definition: pns_router.cpp:792

References PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetActiveLayer(), PNS::ROUTER::GetCurrentLayer(), PNS::SIZES_SETTINGS::GetLayerTop(), m_lastTargetLayer, PNS::TOOL_BASE::m_router, PNS::SIZES_SETTINGS::PairedLayer(), PNS::ROUTER::Sizes(), and PNS::ROUTER::SwitchLayer().

Referenced by performRouting().

◆ updateEndItem()

void TOOL_BASE::updateEndItem ( const TOOL_EVENT aEvent)
protectedvirtualinherited

Definition at line 303 of file pns_tool_base.cpp.

304 {
305  int layer;
306  GAL* gal = m_toolMgr->GetView()->GetGAL();
307 
309  m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
310 
311  controls()->ForceCursorPosition( false );
312  VECTOR2I mousePos = controls()->GetMousePosition();
313 
314  if( m_router->Settings().Mode() != RM_MarkObstacles &&
315  ( m_router->GetCurrentNets().empty() || m_router->GetCurrentNets().front() < 0 ) )
316  {
317  m_endSnapPoint = snapToItem( nullptr, mousePos );
319  m_endItem = nullptr;
320 
321  return;
322  }
323 
324  if( m_router->IsPlacingVia() )
325  layer = -1;
326  else
327  layer = m_router->GetCurrentLayer();
328 
329  ITEM* endItem = nullptr;
330 
331  std::vector<int> nets = m_router->GetCurrentNets();
332 
333  for( int net : nets )
334  {
335  endItem = pickSingleItem( mousePos, net, layer, false, { m_startItem } );
336 
337  if( endItem )
338  break;
339  }
340 
341  if( m_gridHelper->GetSnap() && checkSnap( endItem ) )
342  {
343  m_endItem = endItem;
344  m_endSnapPoint = snapToItem( endItem, mousePos );
345  }
346  else
347  {
348  m_endItem = nullptr;
349  m_endSnapPoint = m_gridHelper->Align( mousePos );
350  }
351 
353 
354  if( m_endItem )
355  {
356  wxLogTrace( wxT( "PNS" ), wxT( "%s, layer : %d" ),
357  m_endItem->KindStr().c_str(),
358  m_endItem->Layers().Start() );
359  }
360 }
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:283
bool GetSnap() const
Definition: grid_helper.h:65
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool IsPlacingVia() const
Definition: pns_router.cpp:809
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:781
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:190
int Start() const
Definition: pns_layerset.h:82
std::string KindStr() const
Returns the kind of the item, as string.
Definition: pns_item.cpp:160
bool GetGridSnapping() const
const VECTOR2I snapToItem(ITEM *aSnapToItem, const VECTOR2I &aP)
bool checkSnap(ITEM *aItem)
PCB_GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:76
ITEM * m_startItem
Definition: pns_tool_base.h:69
ROUTER * m_router
Definition: pns_tool_base.h:78
PNS_MODE Mode() const
Set the routing mode.
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
bool DisableGridSnapping() const
Definition: tool_event.h:341
void SetSnap(bool aSnap)
Definition: grid_helper.h:64
int Modifier(int aMask=MD_MODIFIER_MASK) const
Definition: tool_event.h:336
virtual VECTOR2I Align(const VECTOR2I &aPoint) const
Definition: grid_helper.cpp:95
void SetUseGrid(bool aSnapToGrid)
Definition: grid_helper.h:67
Ignore collisions, mark obstacles.
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={})
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:182
const LAYER_RANGE & Layers() const
Definition: pns_item.h:154
Abstract interface for drawing on a 2D-surface.
int GetCurrentLayer() const
Definition: pns_router.cpp:792

References GRID_HELPER::Align(), PNS::TOOL_BASE::checkSnap(), PCB_TOOL_BASE::controls(), TOOL_EVENT::DisableGridSnapping(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PNS::ROUTER::GetCurrentLayer(), PNS::ROUTER::GetCurrentNets(), KIGFX::VIEW::GetGAL(), KIGFX::GAL::GetGridSnapping(), KIGFX::VIEW_CONTROLS::GetMousePosition(), GRID_HELPER::GetSnap(), TOOL_MANAGER::GetView(), 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, TOOL_BASE::m_toolMgr, 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 handleLayerSwitch(), InlineDrag(), onTrackViaSizeChanged(), performDragging(), and performRouting().

◆ UpdateMessagePanel()

void ROUTER_TOOL::UpdateMessagePanel ( )

Definition at line 2076 of file router_tool.cpp.

2077 {
2078  if( !m_router->RoutingInProgress() )
2079  {
2080  frame()->SetMsgPanel( board() );
2081  return;
2082  }
2083 
2084  std::vector<MSG_PANEL_ITEM> items;
2085  PNS::SIZES_SETTINGS sizes( m_router->Sizes() );
2088