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 , REDRAW }
 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 RouteSelected (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
 
void SetIsBoardEditor (bool aEnabled)
 
bool IsBoardEditor () 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 highlightNets (bool aEnabled, std::set< int > aNetcodes={})
 
virtual void updateStartItem (const TOOL_EVENT &aEvent, bool aIgnorePads=false)
 
virtual void updateEndItem (const TOOL_EVENT &aEvent)
 
void doInteractiveItemPlacement (const TOOL_EVENT &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
 
PCBNEW_SETTINGS::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
 
std::set< int > m_startHighlightNetcodes
 
ITEM * m_endItem
 
VECTOR2I m_endSnapPoint
 
PCB_GRID_HELPERm_gridHelper
 
PNS_KICAD_IFACEm_iface
 
ROUTER * m_router
 
bool m_cancelled
 
bool m_isFootprintEditor
 
bool m_isBoardEditor
 
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 ()
 
void updateSizesAfterLayerSwitch (PCB_LAYER_ID targetLayer)
 
bool getNearestRatnestAnchor (VECTOR2I &aPoint, LAYER_RANGE &aLayers)
 
int onLayerCommand (const TOOL_EVENT &aEvent)
 
int onViaCommand (const TOOL_EVENT &aEvent)
 
int onTrackViaSizeChanged (const TOOL_EVENT &aEvent)
 
bool prepareInteractive ()
 
bool finishInteractive ()
 
void saveRouterDebugLog ()
 
void resetTransitions ()
 Clear the current transition map and restores the default one created by setTransitions(). More...
 
void goInternal (TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)
 
EDA_ITEMgetModelInt () const
 
TOOLS_HOLDERgetToolHolderInt () const
 

Private Attributes

std::shared_ptr< ACTION_MENUm_diffPairMenu
 
std::shared_ptr< ACTION_MENUm_trackViaMenu
 
int m_lastTargetLayer
 
PCB_LAYER_ID m_originalActiveLayer
 
bool m_inRouterTool
 

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 121 of file pcb_tool_base.h.

121 {
123 IPO_ROTATE = 0x01,
124
126 IPO_FLIP = 0x02,
127
130 IPO_SINGLE_CLICK = 0x04,
131
133 IPO_REPEAT = 0x08
134 };
@ IPO_FLIP
Handle flip action in the loop by calling the item's flip method.
@ IPO_ROTATE
Handle the rotate action in the loop by calling the item's rotate method.
@ IPO_SINGLE_CLICK
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
@ IPO_REPEAT
Allow repeat placement of the item.

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

REDRAW 

Full drawing refresh.

Definition at line 77 of file tool_base.h.

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

Constructor & Destructor Documentation

◆ ROUTER_TOOL()

ROUTER_TOOL::ROUTER_TOOL ( )

Definition at line 184 of file router_tool.cpp.

184 :
185 TOOL_BASE( "pcbnew.InteractiveRouter" ),
188 m_inRouterTool( false )
189{
190}
TOOL_BASE(const std::string &aToolName)
PCB_LAYER_ID m_originalActiveLayer
Definition: router_tool.h:95
bool m_inRouterTool
Definition: router_tool.h:97
int m_lastTargetLayer
Definition: router_tool.h:94
@ UNDEFINED_LAYER
Definition: layer_ids.h:60

◆ ~ROUTER_TOOL()

ROUTER_TOOL::~ROUTER_TOOL ( )

Definition at line 439 of file router_tool.cpp.

440{
441}

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:215
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:210
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(), SCH_EDIT_TOOL::DeleteItemCursor(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_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(), SCH_DRAWING_TOOLS::DrawShape(), 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(), EE_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_POINT_EDITOR::Main(), PCB_PICKER_TOOL::Main(), LENGTH_TUNER_TOOL::MainLoop(), MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), PCB_POINT_EDITOR::OnSelectionChange(), GROUP_TOOL::PickNewMember(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), RouteSelected(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_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}

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ board()

BOARD * PCB_TOOL_BASE::board ( ) const
inlineprotectedinherited

Definition at line 170 of file pcb_tool_base.h.

170{ return getModel<BOARD>(); }

Referenced by PCB_CONTROL::AppendBoard(), BOARD_EDITOR_CONTROL::AssignNetclass(), 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::doMoveSelection(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawShape(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), BOARD_EDITOR_CONTROL::ExportNetlist(), ZONE_FILLER_TOOL::FillAllZones(), EDIT_TOOL::FilletTracks(), PCB_TOOL_BASE::footprint(), GROUP_TOOL::Group(), handleLayerSwitch(), BOARD_INSPECTION_TOOL::highlightNet(), Init(), 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(), DRAWING_TOOL::PlaceText(), PCB_CONTROL::pruneItemLayers(), EDIT_TOOL::rebuildConnectivity(), ZONE_FILLER_TOOL::rebuildConnectivity(), PAD_TOOL::RecombinePad(), BOARD_EDITOR_CONTROL::RepairBoard(), FOOTPRINT_EDITOR_CONTROL::RepairFootprint(), PNS::TOOL_BASE::Reset(), PAD_TOOL::Reset(), PCB_CONTROL::Reset(), PCB_CONTROL::TrackDisplayMode(), PCB_CONTROL::unfilledZoneCheck(), GROUP_TOOL::Ungroup(), UpdateMessagePanel(), updateSizesAfterLayerSwitch(), PCB_CONTROL::ViaDisplayMode(), PCB_CONTROL::ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), ZONE_FILLER_TOOL::ZoneFillDirty(), BOARD_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

◆ breakTrack()

void ROUTER_TOOL::breakTrack ( )
private

Definition at line 1536 of file router_tool.cpp.

1537{
1540}
@ SEGMENT_T
Definition: pns_item.h:66
bool OfKind(int aKindMask) const
Return true if the item's type matches the mask aKindMask.
Definition: pns_item.h:140
void BreakSegment(ITEM *aItem, const VECTOR2I &aP)
ITEM * m_startItem
Definition: pns_tool_base.h:70
ROUTER * m_router
Definition: pns_tool_base.h:79
VECTOR2I m_startSnapPoint
Definition: pns_tool_base.h:71

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

2001{
2003 const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
2004
2005 if( selection.Size() == 1 )
2006 {
2007 const BOARD_ITEM* item = static_cast<const BOARD_ITEM*>( selection.Front() );
2008
2009 // Note: EDIT_TOOL::Drag temporarily handles items of type PCB_ARC_T on its own using
2010 // DragArcTrack(), so PCB_ARC_T should never occur here.
2012 {
2013 // Footprints cannot be dragged freely.
2014 if( item->IsType( { PCB_FOOTPRINT_T } ) )
2015 return !( aDragMode & PNS::DM_FREE_ANGLE );
2016 else
2017 return true;
2018 }
2019 }
2020
2021 return false;
2022}
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:70
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:181
static const std::vector< KICAD_T > DraggableItems
A scan list for items that can be dragged.
Definition: collectors.h:270
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:56
The selection tool: currently supports:
const PCB_SELECTION & selection() const
static void NeighboringSegmentFilter(const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector)
EDA_ITEM * Front() const
Definition: selection.h:208
int Size() const
Returns the number of selected parts.
Definition: selection.h:115
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142
@ DM_FREE_ANGLE
Definition: pns_router.h:75

References PNS::DM_FREE_ANGLE, GENERAL_COLLECTOR::DraggableItems, SELECTION::Front(), TOOL_MANAGER::GetTool(), EDA_ITEM::IsType(), TOOL_BASE::m_toolMgr, NeighboringSegmentFilter(), 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 1495 of file router_tool.cpp.

1496{
1497 PNS::PNS_MODE mode = aEvent.Parameter<PNS::PNS_MODE>();
1499
1500 settings.SetMode( mode );
1501
1502 return 0;
1503}
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:189
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.
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:442
PNS_MODE
< Routing modes

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

264{
265 // Sync PNS engine settings with the general PCB editor options.
266 auto& pnss = m_router->Settings();
267
268 // If we're dragging a track segment, don't try to snap to items that are part of the original line.
270 && m_router->GetDragger() )
271 {
272 DRAGGER* dragger = dynamic_cast<DRAGGER*>( m_router->GetDragger() );
273 LINKED_ITEM* liItem = dynamic_cast<LINKED_ITEM*>( aItem );
274
275 if( dragger && liItem && dragger->GetOriginalLine().ContainsLink( liItem ) )
276 {
277 return false;
278 }
279 }
280
281 pnss.SetSnapToPads(
284
285 pnss.SetSnapToTracks(
288
289 if( aItem )
290 {
291 if( aItem->OfKind( ITEM::VIA_T | ITEM::SEGMENT_T | ITEM::ARC_T ) )
292 return pnss.GetSnapToTracks();
293 else if( aItem->OfKind( ITEM::SOLID_T ) )
294 return pnss.GetSnapToPads();
295 }
296
297 return false;
298}
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
@ SOLID_T
Definition: pns_item.h:63
DRAG_ALGO * GetDragger()
Definition: pns_router.h:137
RouterState GetState() const
Definition: pns_router.h:135
void SetSnapToPads(bool aSnap)
MAGNETIC_OPTIONS tracks
MAGNETIC_OPTIONS pads

References PNS::ITEM::ARC_T, CAPTURE_ALWAYS, CAPTURE_CURSOR_IN_TRACK_TOOL, PNS::LINK_HOLDER::ContainsLink(), PNS::ROUTER::DRAG_SEGMENT, PCB_TOOL_BASE::frame(), PNS::ROUTER::GetDragger(), PCB_BASE_FRAME::GetMagneticItemsSettings(), PNS::DRAGGER::GetOriginalLine(), PNS::ROUTER::GetState(), PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::ITEM::OfKind(), MAGNETIC_SETTINGS::pads, PNS::ITEM::SEGMENT_T, PNS::ROUTER::Settings(), PNS::ITEM::SOLID_T, MAGNETIC_SETTINGS::tracks, and PNS::ITEM::VIA_T.

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

◆ controls()

◆ CustomTrackWidthDialog()

int ROUTER_TOOL::CustomTrackWidthDialog ( const TOOL_EVENT aEvent)

Definition at line 2426 of file router_tool.cpp.

2427{
2429 DIALOG_TRACK_VIA_SIZE sizeDlg( frame(), bds );
2430
2431 if( sizeDlg.ShowModal() == wxID_OK )
2432 {
2433 bds.m_TempOverrideTrackWidth = true;
2434 bds.UseCustomTrackViaSize( true );
2435
2438 }
2439
2440 return 0;
2441}
Container for design settings for a BOARD object.
void UseCustomTrackViaSize(bool aEnabled)
Enables/disables custom track/via size settings.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:704
Implementing DIALOG_TRACK_VIA_SIZE_BASE.
BOARD * board() const
int onTrackViaSizeChanged(const TOOL_EVENT &aEvent)
Generic, UI-independent tool event.
Definition: tool_event.h:156
std::vector< FAB_LAYER_COLOR > dummy

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

1507{
1509 PNS::PNS_MODE mode = settings.Mode();
1510
1511 switch( mode )
1512 {
1513 case PNS::RM_MarkObstacles: mode = PNS::RM_Shove; break;
1514 case PNS::RM_Shove: mode = PNS::RM_Walkaround; break;
1515 case PNS::RM_Walkaround: mode = PNS::RM_MarkObstacles; break;
1516 }
1517
1518 settings.SetMode( mode );
1519
1520 return 0;
1521}
PNS_MODE Mode() const
Set the routing mode.
@ RM_MarkObstacles
Ignore collisions, mark obstacles.
@ RM_Walkaround
Only walk around.
@ RM_Shove
Only shove.

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

◆ doInteractiveItemPlacement()

void PCB_TOOL_BASE::doInteractiveItemPlacement ( const TOOL_EVENT 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 41 of file pcb_tool_base.cpp.

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

References TOOL_INTERACTIVE::Activate(), SELECTION::Add(), KIGFX::VIEW_GROUP::Add(), KIGFX::PCB_VIEW::Add(), ARROW, PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), EDA_ITEM::ClearFlags(), PCB_TOOL_BASE::controls(), INTERACTIVE_PLACER_BASE::CreateItem(), PCB_ACTIONS::flip, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), TOOL_EVT_UTILS::GetEventRotationAngle(), EDA_ITEM::GetFlags(), 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, 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(), EDA_ITEM::SetFlags(), 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 1463 of file router_tool.cpp.

1464{
1466 DIALOG_PNS_DIFF_PAIR_DIMENSIONS settingsDlg( frame(), sizes );
1467
1468 if( settingsDlg.ShowModal() == wxID_OK )
1469 {
1470 m_router->UpdateSizes( sizes );
1471 m_savedSizes = sizes;
1472
1475 bds.SetCustomDiffPairGap( sizes.DiffPairGap() );
1477 }
1478
1479 return 0;
1480}
void SetCustomDiffPairWidth(int aWidth)
Sets custom track width for differential pairs (i.e.
void SetCustomDiffPairGap(int aGap)
Sets custom gap for differential pairs (i.e.
void SetCustomDiffPairViaGap(int aGap)
Sets custom via gap for differential pairs (i.e.
BOARD * GetBoard() const
void UpdateSizes(const SIZES_SETTINGS &aSizes)
Applies stored settings.
Definition: pns_router.cpp:728
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:208
SIZES_SETTINGS m_savedSizes
Definition: pns_tool_base.h:69

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

1254{
1256
1257 m_startItem = nullptr;
1258 m_endItem = nullptr;
1259
1263 controls()->SetAutoPan( false );
1264 controls()->ForceCursorPosition( false );
1265 frame()->UndoRedoBlock( false );
1266 highlightNets( false );
1267
1268 return true;
1269}
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
void StopRouting()
Definition: pns_router.cpp:911
virtual void highlightNets(bool aEnabled, std::set< int > aNetcodes={})
void UpdateMessagePanel()

References ARROW, PCB_TOOL_BASE::controls(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), PNS::TOOL_BASE::highlightNets(), PNS::TOOL_BASE::m_endItem, m_originalActiveLayer, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PCB_BASE_FRAME::SetActiveLayer(), 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 165 of file pcb_tool_base.h.

166 {
167 return getEditFrame<PCB_BASE_EDIT_FRAME>();
168 }

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(), CustomTrackWidthDialog(), FOOTPRINT_EDITOR_CONTROL::DeleteFootprint(), EDIT_TOOL::DeleteItems(), PCB_TOOL_BASE::displayOptions(), BOARD_EDITOR_CONTROL::doCrossProbePcbToSch(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), DpDimensionsDialog(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawShape(), 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(), finishInteractive(), EDIT_TOOL::Flip(), PCB_CONTROL::FlipPcbView(), GLOBAL_EDIT_TOOL::GlobalDeletions(), handleLayerSwitch(), PCB_CONTROL::HighContrastMode(), PCB_CONTROL::HighContrastModeCycle(), BOARD_INSPECTION_TOOL::HighlightItem(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), BOARD_EDITOR_CONTROL::ImportSpecctraSession(), SCRIPTING_TOOL::Init(), Init(), EDIT_TOOL::Init(), InlineBreakTrack(), InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), PCB_TOOL_BASE::Is45Limited(), PCB_PICKER_TOOL::Main(), LENGTH_TUNER_TOOL::MainLoop(), MainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MoveExact(), PCB_CONTROL::NetColorModeCycle(), PCB_POINT_EDITOR::OnSelectionChange(), onViaCommand(), PCB_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), performDragging(), performRouting(), LENGTH_TUNER_TOOL::performTuning(), GROUP_TOOL::PickNewMember(), PNS::TOOL_BASE::pickSingleItem(), BOARD_EDITOR_CONTROL::PlaceFootprint(), DRAWING_TOOL::PlaceText(), prepareInteractive(), PCB_CONTROL::pruneItemLayers(), PAD_TOOL::pushPadSettings(), PCB_CONTROL::RatsnestModeCycle(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), SCRIPTING_TOOL::reloadPlugins(), PCB_POINT_EDITOR::removeCorner(), PNS::TOOL_BASE::Reset(), PAD_TOOL::Reset(), EDIT_TOOL::Rotate(), RouteSelected(), SelectCopperLayerPair(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), PCB_POINT_EDITOR::setEditedPoint(), SettingsDialog(), GLOBAL_EDIT_TOOL::swapBoardItem(), GLOBAL_EDIT_TOOL::SwapLayers(), switchLayerOnViaPlacement(), DRAWING_TOOL::ToggleHV45Mode(), PCB_CONTROL::ToggleRatsnest(), PCB_CONTROL::unfilledZoneCheck(), PCB_POINT_EDITOR::updateItem(), UpdateMessagePanel(), EDIT_TOOL::updateModificationPoint(), BOARD_EDITOR_CONTROL::UpdateSchematicFromPCB(), PCB_CONTROL::ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), ZONE_FILLER_TOOL::ZoneFillAll(), and ZONE_FILLER_TOOL::ZoneFillDirty().

◆ getEditFrame()

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

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

Definition at line 185 of file tool_base.h.

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

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone(), and ZONE_CREATE_HELPER::setUniquePriority().

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

122 {
123 return m_toolId;
124 }

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

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

References TOOL_BASE::getModelInt().

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

◆ getModelInt()

EDA_ITEM * TOOL_BASE::getModelInt ( ) const
privateinherited

Definition at line 54 of file tool_base.cpp.

55{
56 return m_toolMgr->GetModel();
57}
EDA_ITEM * GetModel() const
Definition: tool_manager.h:292

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

Referenced by TOOL_BASE::getModel().

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

135 {
136 return m_toolName;
137 }
std::string m_toolName
Definition: tool_base.h:214

References TOOL_BASE::m_toolName.

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

◆ getNearestRatnestAnchor()

bool ROUTER_TOOL::getNearestRatnestAnchor ( VECTOR2I aPoint,
LAYER_RANGE aLayers 
)
private

◆ GetRouterMode()

PNS::PNS_MODE ROUTER_TOOL::GetRouterMode ( )

Definition at line 1524 of file router_tool.cpp.

1525{
1526 return m_router->Settings().Mode();
1527}

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

661{
662 int tl = getView()->GetTopLayer();
663
664 if( m_startItem )
665 {
666 const LAYER_RANGE& ls = m_startItem->Layers();
667
668 if( ls.Overlaps( tl ) )
669 return tl;
670 else
671 return ls.Start();
672 }
673
674 return tl;
675}
virtual int GetTopLayer() const
Definition: view.cpp:816
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:32
int Start() const
Definition: pns_layerset.h:82
bool Overlaps(const LAYER_RANGE &aOther) const
Definition: pns_layerset.h:67
const LAYER_RANGE & Layers() const
Definition: pns_item.h:156

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

◆ getToolHolderInt()

TOOLS_HOLDER * TOOL_BASE::getToolHolderInt ( ) const
privateinherited

Definition at line 48 of file tool_base.cpp.

49{
50 return m_toolMgr->GetToolHolder();
51}
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:296

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

Referenced by TOOL_BASE::getEditFrame().

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Return the type of the tool.

Returns
The type of the tool.

Definition at line 109 of file tool_base.h.

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

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:285

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(), SCH_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), EDIT_TOOL::DeleteItems(), PL_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), SELECTION_TOOL::doSelectionMenu(), COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::drawShape(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), EE_SELECTION_TOOL::GetNode(), getStartLayer(), PCB_CONTROL::GridResetOrigin(), PCB_CONTROL::GridSetOrigin(), EE_SELECTION_TOOL::GuessSelectionCandidates(), PCB_SELECTION_TOOL::GuessSelectionCandidates(), handleCommonEvents(), EE_SELECTION_TOOL::highlight(), PL_SELECTION_TOOL::highlight(), PCB_SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), BOARD_INSPECTION_TOOL::highlightNet(), PNS::TOOL_BASE::highlightNets(), PCB_SELECTION_TOOL::hitTestDistance(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), InlineDrag(), EE_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), PCB_PICKER_TOOL::Main(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), PL_EDIT_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), SCH_EDITOR_CONTROL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), performRouting(), PNS::TOOL_BASE::pickSingleItem(), BOARD_EDITOR_CONTROL::PlaceFootprint(), DRAWING_TOOL::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), prepareInteractive(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EE_SELECTION_TOOL::Reset(), EE_TOOL_BASE< T >::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), PNS::TOOL_BASE::Reset(), BOARD_EDITOR_CONTROL::Reset(), DRAWING_TOOL::Reset(), PCB_CONTROL::Reset(), PCB_SELECTION_TOOL::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), PCB_SELECTION_TOOL::Selectable(), EE_SELECTION_TOOL::SelectAll(), PCB_SELECTION_TOOL::SelectAll(), EE_SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectionContains(), PCB_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), EE_SELECTION_TOOL::selectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_EDITOR_CONTROL::ToggleERCErrors(), SCH_EDITOR_CONTROL::ToggleERCExclusions(), SCH_EDITOR_CONTROL::ToggleERCWarnings(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), SCH_EDITOR_CONTROL::ToggleOPCurrents(), SCH_EDITOR_CONTROL::ToggleOPVoltages(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), EE_SELECTION_TOOL::unhighlight(), PL_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_FIND_REPLACE_TOOL::UpdateFind(), PL_POINT_EDITOR::updateItem(), PCB_POINT_EDITOR::updateItem(), EE_TOOL_BASE< T >::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_SELECTION_TOOL::view(), PCB_TOOL_BASE::view(), PCB_VIEWER_TOOLS::view(), EE_SELECTION_TOOL::ZoomFitCrossProbeBBox(), PCB_SELECTION_TOOL::ZoomFitCrossProbeBBox(), 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}
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:287

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

Referenced by EE_POINT_EDITOR::addCorner(), PCB_POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), EE_SELECTION_TOOL::autostartEvent(), SCH_EDIT_TOOL::BreakWire(), PCB_SELECTION_TOOL::controls(), PCB_TOOL_BASE::controls(), EDIT_TOOL::copyToClipboard(), COMMON_TOOLS::CursorControl(), EDIT_TOOL::DeleteItems(), 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(), SCH_DRAWING_TOOLS::DrawShape(), 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_EDITOR_CONTROL::HighlightNet(), BOARD_INSPECTION_TOOL::HighlightNet(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), EE_POINT_EDITOR::Main(), EE_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_POINT_EDITOR::Main(), PCB_PICKER_TOOL::Main(), MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), SCH_EDITOR_CONTROL::Paste(), 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(), DRAWING_TOOL::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), DRAWING_TOOL::Reset(), PCB_POINT_EDITOR::Reset(), COMMON_TOOLS::ResetLocalCoords(), RouteSelected(), PCB_SELECTION_TOOL::selectCursor(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PICKER_TOOL::setControls(), PCB_PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), PL_POINT_EDITOR::setEditedPoint(), PCB_POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_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}
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:58

References TOOL_INTERACTIVE::goInternal().

Referenced by EDA_3D_CONTROLLER::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), EE_POINT_EDITOR::setTransitions(), EE_SELECTION_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), SCH_EDIT_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), SCH_FIND_REPLACE_TOOL::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), SCH_NAVIGATE_TOOL::setTransitions(), SIMULATOR_CONTROL::setTransitions(), SYMBOL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_DRAWING_TOOLS::setTransitions(), SYMBOL_EDITOR_EDIT_TOOL::setTransitions(), SYMBOL_EDITOR_MOVE_TOOL::setTransitions(), SYMBOL_EDITOR_PIN_TOOL::setTransitions(), GERBVIEW_CONTROL::setTransitions(), GERBVIEW_INSPECTION_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), COMMON_CONTROL::setTransitions(), COMMON_TOOLS::setTransitions(), PICKER_TOOL::setTransitions(), ZOOM_TOOL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), PL_EDIT_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), PL_POINT_EDITOR::setTransitions(), PL_SELECTION_TOOL::setTransitions(), AUTOPLACE_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), SCRIPTING_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), setTransitions(), BOARD_EDITOR_CONTROL::setTransitions(), BOARD_INSPECTION_TOOL::setTransitions(), BOARD_REANNOTATE_TOOL::setTransitions(), CONVERT_TOOL::setTransitions(), DRAWING_TOOL::setTransitions(), DRC_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), FOOTPRINT_EDITOR_CONTROL::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), GROUP_TOOL::setTransitions(), PAD_TOOL::setTransitions(), PCB_CONTROL::setTransitions(), PCB_PICKER_TOOL::setTransitions(), PCB_POINT_EDITOR::setTransitions(), PCB_SELECTION_TOOL::setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), PROPERTIES_TOOL::setTransitions(), and ZONE_FILLER_TOOL::setTransitions().

◆ goInternal()

void TOOL_INTERACTIVE::goInternal ( TOOL_STATE_FUNC aState,
const TOOL_EVENT_LIST aConditions 
)
privateinherited

Definition at line 70 of file tool_interactive.cpp.

71{
72 m_toolMgr->ScheduleNextState( this, aState, aConditions );
73}
void ScheduleNextState(TOOL_BASE *aTool, TOOL_STATE_FUNC &aHandler, const TOOL_EVENT_LIST &aConditions)
Define a state transition.

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

Referenced by TOOL_INTERACTIVE::Go().

◆ handleCommonEvents()

void ROUTER_TOOL::handleCommonEvents ( TOOL_EVENT evt)
private

Definition at line 633 of file router_tool.cpp.

634{
635 if( aEvent.Category() == TC_VIEW || aEvent.Category() == TC_MOUSE )
636 {
637 BOX2D viewAreaD = getView()->GetGAL()->GetVisibleWorldExtents();
638 m_router->SetVisibleViewArea( BOX2I( viewAreaD.GetOrigin(), viewAreaD.GetSize() ) );
639 }
640
641 if( !aEvent.IsKeyPressed() )
642 return;
643
644 switch( aEvent.KeyCode() )
645 {
646 case '0':
647 if( !ADVANCED_CFG::GetCfg().m_ShowRouterDebugGraphics )
648 return;
649
651 aEvent.SetPassEvent( false );
652 break;
653
654 default:
655 break;
656 }
657}
BOX2< VECTOR2I > BOX2I
Definition: box2.h:847
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
const Vec & GetOrigin() const
Definition: box2.h:183
const Vec & GetSize() const
Definition: box2.h:179
BOX2D GetVisibleWorldExtents() const
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:195
void SetVisibleViewArea(const BOX2I &aExtents)
Definition: pns_router.h:217
void saveRouterDebugLog()
@ TC_MOUSE
Definition: tool_event.h:50
@ TC_VIEW
Definition: tool_event.h:54

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

890{
891 wxCHECK( m_router, 0 );
892
893 if( !IsToolActive() )
894 return 0;
895
896 // First see if this is one of the switch layer commands
897 LSEQ layers = LSET( board()->GetEnabledLayers() & LSET::AllCuMask() ).Seq();
899 PCB_LAYER_ID targetLayer = UNDEFINED_LAYER;
900
901 if( aEvent.IsAction( &PCB_ACTIONS::layerNext ) )
902 {
904 m_lastTargetLayer = currentLayer;
905
906 size_t idx = 0;
907
908 for( size_t i = 0; i < layers.size(); i++ )
909 {
910 if( layers[i] == m_lastTargetLayer )
911 {
912 idx = i;
913 break;
914 }
915 }
916
917 idx = ( idx + 1 ) % layers.size();
918 targetLayer = layers[idx];
919 }
920 else if( aEvent.IsAction( &PCB_ACTIONS::layerPrev ) )
921 {
923 m_lastTargetLayer = currentLayer;
924
925 size_t idx = 0;
926
927 for( size_t i = 0; i < layers.size(); i++ )
928 {
929 if( layers[i] == m_lastTargetLayer )
930 {
931 idx = i;
932 break;
933 }
934 }
935
936 idx = ( idx > 0 ) ? ( idx - 1 ) : ( layers.size() - 1 );
937 targetLayer = layers[idx];
938 }
939 else
940 {
941 targetLayer = getTargetLayerFromEvent( aEvent );
942 }
943
944 if( targetLayer != UNDEFINED_LAYER )
945 {
946 m_lastTargetLayer = targetLayer;
947
948 if( targetLayer == currentLayer )
949 return 0;
950
951 if( !aForceVia && m_router && m_router->SwitchLayer( targetLayer ) )
952 {
953 updateSizesAfterLayerSwitch( targetLayer );
954 updateEndItem( aEvent );
955 m_router->Move( m_endSnapPoint, m_endItem ); // refresh
956 return 0;
957 }
958 }
959
961 const int layerCount = bds.GetCopperLayerCount();
962
965
967
968 VIATYPE viaType = VIATYPE::THROUGH;
969 bool selectLayer = false;
970
971 // Otherwise it is one of the router-specific via commands
972 if( targetLayer == UNDEFINED_LAYER )
973 {
974 const int actViaFlags = aEvent.Parameter<intptr_t>();
975 selectLayer = actViaFlags & VIA_ACTION_FLAGS::SELECT_LAYER;
976
977 viaType = getViaTypeFromFlags( actViaFlags );
978
979 // ask the user for a target layer
980 if( selectLayer )
981 {
982 wxPoint endPoint = ToWxPoint( view()->ToScreen( m_endSnapPoint ) );
983 endPoint = frame()->GetCanvas()->ClientToScreen( endPoint );
984
985 // Build the list of not allowed layer for the target layer
986 LSET not_allowed_ly = LSET::AllNonCuMask();
987
988 if( viaType != VIATYPE::THROUGH )
989 not_allowed_ly.set( currentLayer );
990
991 if( viaType == VIATYPE::MICROVIA )
992 {
993 // Allows only the previous or the next layer from the current layer
994 int previous_layer = currentLayer == B_Cu ? layerCount - 2
995 : currentLayer - 1;
996
997 int next_layer = currentLayer >= layerCount-2 ? B_Cu
998 : currentLayer + 1;
999
1000 not_allowed_ly = LSET::AllLayersMask();
1001
1002 if( previous_layer >= F_Cu && previous_layer != currentLayer )
1003 not_allowed_ly.reset( previous_layer );
1004
1005 if( next_layer != currentLayer )
1006 not_allowed_ly.reset( next_layer );
1007 }
1008
1009 targetLayer = frame()->SelectOneLayer( static_cast<PCB_LAYER_ID>( currentLayer ),
1010 not_allowed_ly, endPoint );
1011
1012 // Reset the cursor to the end of the track
1014
1015 if( targetLayer == UNDEFINED_LAYER ) // cancelled by user
1016 return 0;
1017
1018 // One cannot place a blind/buried via on only one layer:
1019 if( viaType != VIATYPE::THROUGH )
1020 {
1021 if( currentLayer == targetLayer )
1022 return 0;
1023 }
1024 }
1025 }
1026
1027 // fixme: P&S supports more than one fixed layer pair. Update the dialog?
1028 sizes.ClearLayerPairs();
1029
1030 // Convert blind/buried via to a through hole one, if it goes through all layers
1031 if( viaType == VIATYPE::BLIND_BURIED
1032 && ( ( targetLayer == B_Cu && currentLayer == F_Cu )
1033 || ( targetLayer == F_Cu && currentLayer == B_Cu ) ) )
1034 {
1035 viaType = VIATYPE::THROUGH;
1036 }
1037
1038 if( targetLayer == UNDEFINED_LAYER )
1039 {
1040 // Implicic layer selection
1041
1042 switch( viaType )
1043 {
1044 case VIATYPE::THROUGH:
1045 // use the default layer pair
1046 currentLayer = pairTop;
1047 targetLayer = pairBottom;
1048 break;
1049
1050 case VIATYPE::MICROVIA:
1051 // Try to use the layer pair preset, if the layers are adjacent,
1052 // because a microvia is usually restricted to 2 adjacent copper layers
1053 if( pairTop > pairBottom ) std::swap( pairTop, pairBottom );
1054
1055 if( currentLayer == pairTop && pairBottom == pairTop+1 )
1056 {
1057 targetLayer = pairBottom;
1058 }
1059 else if( currentLayer == pairBottom && pairBottom == pairTop+1 )
1060 {
1061 targetLayer = pairTop;
1062 }
1063 else if( currentLayer == F_Cu || currentLayer == In1_Cu )
1064 {
1065 // front-side microvia
1066 currentLayer = F_Cu;
1067
1068 if( layerCount > 2 ) // Ensure the inner layer In1_Cu exists
1069 targetLayer = In1_Cu;
1070 else
1071 targetLayer = B_Cu;
1072 }
1073 else if( currentLayer == B_Cu || currentLayer == layerCount - 2 )
1074 {
1075 // back-side microvia
1076 currentLayer = B_Cu,
1077 targetLayer = (PCB_LAYER_ID) ( layerCount - 2 );
1078 }
1079 else
1080 {
1081 // This is not optimal: from an internal layer one can want to switch
1082 // to the previous or the next internal layer
1083 // but at this point we do not know what the user want.
1084 targetLayer = PCB_LAYER_ID( currentLayer + 1 );
1085 }
1086
1087 break;
1088
1090 if( currentLayer == pairTop || currentLayer == pairBottom )
1091 {
1092 // the current layer is on the defined layer pair,
1093 // swap to the other side
1094 currentLayer = pairTop;
1095 targetLayer = pairBottom;
1096 }
1097 else
1098 {
1099 // the current layer is not part of the current layer pair,
1100 // so fallback and swap to the top layer of the pair by default
1101 targetLayer = pairTop;
1102 }
1103
1104 // Do not create a broken via (i.e. a via on only one copper layer)
1105 if( currentLayer == targetLayer )
1106 {
1107 WX_INFOBAR* infobar = frame()->GetInfoBar();
1108 infobar->ShowMessageFor( _( "Blind/buried via need 2 different layers." ),
1109 2000, wxICON_ERROR,
1111 return 0;
1112 }
1113
1114 break;
1115
1116 default:
1117 wxFAIL_MSG( wxT( "unexpected via type" ) );
1118 return 0;
1119 break;
1120 }
1121 }
1122
1123 sizes.SetViaDiameter( bds.m_ViasMinSize );
1124 sizes.SetViaDrill( bds.m_MinThroughDrill );
1125
1126 if( bds.UseNetClassVia() || viaType == VIATYPE::MICROVIA )
1127 {
1128 PCB_VIA dummyVia( board() );
1129 dummyVia.SetViaType( viaType );
1130 dummyVia.SetLayerPair( currentLayer, targetLayer );
1131
1132 if( !m_router->GetCurrentNets().empty() )
1133 dummyVia.SetNetCode( m_router->GetCurrentNets()[0] );
1134
1135 DRC_CONSTRAINT constraint;
1136
1137 constraint = bds.m_DRCEngine->EvalRules( VIA_DIAMETER_CONSTRAINT, &dummyVia, nullptr,
1138 currentLayer );
1139
1140 if( !constraint.IsNull() )
1141 sizes.SetViaDiameter( constraint.m_Value.Opt() );
1142
1143 constraint = bds.m_DRCEngine->EvalRules( HOLE_SIZE_CONSTRAINT, &dummyVia, nullptr,
1144 currentLayer );
1145
1146 if( !constraint.IsNull() )
1147 sizes.SetViaDrill( constraint.m_Value.Opt() );
1148 }
1149 else
1150 {
1151 sizes.SetViaDiameter( bds.GetCurrentViaSize() );
1152 sizes.SetViaDrill( bds.GetCurrentViaDrill() );
1153 }
1154
1155 sizes.SetViaType( viaType );
1156 sizes.AddLayerPair( currentLayer, targetLayer );
1157
1158 m_router->UpdateSizes( sizes );
1159
1160 if( !m_router->IsPlacingVia() )
1162
1163 m_lastTargetLayer = targetLayer;
1164
1166 {
1167 updateEndItem( aEvent );
1169 }
1170 else
1171 {
1172 updateStartItem( aEvent );
1173 }
1174
1175 return 0;
1176}
std::shared_ptr< DRC_ENGINE > m_DRCEngine
bool UseNetClassVia() const
Return true if netclass values should be used to obtain appropriate via size.
MINOPTMAX< int > m_Value
Definition: drc_rule.h:172
bool IsNull() const
Definition: drc_rule.h:136
WX_INFOBAR * GetInfoBar()
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.
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:493
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:532
static LSET AllLayersMask()
Definition: lset.cpp:808
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
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
Definition: lset.cpp:794
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
T Opt() const
Definition: minoptmax.h:35
static TOOL_ACTION layerPrev
Definition: pcb_actions.h:323
static TOOL_ACTION layerNext
Definition: pcb_actions.h:322
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
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
PCB_LAYER_ID m_Route_Layer_TOP
Definition: pcb_screen.h:43
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:44
bool SwitchLayer(int layer)
Definition: pns_router.cpp:954
const std::vector< int > GetCurrentNets() const
Definition: pns_router.cpp:978
bool IsPlacingVia() const
bool RoutingInProgress() const
Definition: pns_router.cpp:114
int GetCurrentLayer() const
Definition: pns_router.cpp:989
void ToggleViaPlacement()
Definition: pns_router.cpp:963
bool Move(const VECTOR2I &aP, ITEM *aItem)
Definition: pns_router.cpp:461
void SetViaType(VIATYPE aViaType)
void SetViaDrill(int aDrill)
void AddLayerPair(int aL1, int aL2)
void SetViaDiameter(int aDiameter)
virtual void updateStartItem(const TOOL_EVENT &aEvent, bool aIgnorePads=false)
virtual void updateEndItem(const TOOL_EVENT &aEvent)
VECTOR2I m_endSnapPoint
Definition: pns_tool_base.h:75
void updateSizesAfterLayerSwitch(PCB_LAYER_ID targetLayer)
bool IsToolActive() const
Definition: tool_base.cpp:31
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:81
A modified version of the wxInfoBar class that allows us to:
Definition: wx_infobar.h:75
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: wx_infobar.cpp:128
@ VIA_DIAMETER_CONSTRAINT
Definition: drc_rule.h:63
@ HOLE_SIZE_CONSTRAINT
Definition: drc_rule.h:51
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ B_Cu
Definition: layer_ids.h:95
@ In1_Cu
Definition: layer_ids.h:65
@ F_Cu
Definition: layer_ids.h:64
VIATYPE
Definition: pcb_track.h:65
@ BLIND_BURIED
static VIATYPE getViaTypeFromFlags(int aFlags)
@ SELECT_LAYER
Ask user to select layer before adding via.
Definition: router_tool.cpp:95
static PCB_LAYER_ID getTargetLayerFromEvent(const TOOL_EVENT &aEvent)
#define _(s)
wxPoint ToWxPoint(const VECTOR2I &aSize)
Definition: vector2wx.h:50

References _, 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_DRCEngine, PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, m_lastTargetLayer, 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(), 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(), PCB_VIA::SetViaType(), PNS::SIZES_SETTINGS::SetViaType(), WX_INFOBAR::ShowMessageFor(), PNS::ROUTER::Sizes(), PNS::ROUTER::SwitchLayer(), THROUGH, PNS::ROUTER::ToggleViaPlacement(), ToWxPoint(), UNDEFINED_LAYER, PNS::TOOL_BASE::updateEndItem(), PNS::ROUTER::UpdateSizes(), updateSizesAfterLayerSwitch(), PNS::TOOL_BASE::updateStartItem(), BOARD_DESIGN_SETTINGS::UseNetClassVia(), VIA_DIAMETER_CONSTRAINT, and PCB_TOOL_BASE::view().

Referenced by onLayerCommand(), and onViaCommand().

◆ highlightNets()

void TOOL_BASE::highlightNets ( bool  aEnabled,
std::set< int >  aNetcodes = {} 
)
protectedvirtualinherited

Definition at line 224 of file pns_tool_base.cpp.

225{
227
228 if( aNetcodes.size() > 0 && aEnabled )
229 {
230 // If the user has previously set some of the routed nets to be highlighted,
231 // we assume they want to keep them highlighted after routing
232
233 const std::set<int>& currentNetCodes = rs->GetHighlightNetCodes();
234 bool keep = false;
235
236 for( const int& netcode : aNetcodes )
237 {
238 if( currentNetCodes.find( netcode ) != currentNetCodes.end() )
239 {
240 keep = true;
241 break;
242 }
243 }
244
245 if( rs->IsHighlightEnabled() && keep )
246 m_startHighlightNetcodes = currentNetCodes;
247 else
249
250 rs->SetHighlight( aNetcodes, true );
251 }
252 else
253 {
255 }
256
257 // Do not remove this call. This is required to update the layers when we highlight a net.
258 // In this case, highlighting a net dims all other elements, so the colors need to update
260}
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
const std::set< int > & GetHighlightNetCodes() const
Return the netcode of currently highlighted net.
bool IsHighlightEnabled() const
Return current highlight setting.
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Turns on/off highlighting.
void UpdateAllLayersColor()
Apply the new coloring scheme to all layers.
Definition: view.cpp:761
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:213
std::set< int > m_startHighlightNetcodes
Definition: pns_tool_base.h:72

References KIGFX::RENDER_SETTINGS::GetHighlightNetCodes(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), TOOL_BASE::getView(), KIGFX::RENDER_SETTINGS::IsHighlightEnabled(), PNS::TOOL_BASE::m_startHighlightNetcodes, 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 444 of file router_tool.cpp.

445{
448
449 PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
450
451 wxASSERT( frame );
452
453 auto& menu = m_menu.GetMenu();
454 menu.SetTitle( _( "Interactive Router" ) );
455
456 m_trackViaMenu = std::make_shared<TRACK_WIDTH_MENU>( *frame );
457 m_trackViaMenu->SetTool( this );
459
460 m_diffPairMenu = std::make_shared<DIFF_PAIR_MENU>( *frame );
461 m_diffPairMenu->SetTool( this );
463
464 auto haveHighlight =
465 [&]( const SELECTION& sel )
466 {
468
469 return !cfg->GetHighlightNetCodes().empty();
470 };
471
472 auto notRoutingCond =
473 [this]( const SELECTION& )
474 {
475 return !m_router->RoutingInProgress();
476 };
477
478 auto hasOtherEnd =
479 [&]( const SELECTION& )
480 {
481 std::vector<int> currentNets = m_router->GetCurrentNets();
482
483 // Need to have something unconnected to finish to
484 int currentNet = currentNets.empty() ? -1 : currentNets[0];
485 BOARD* board = getEditFrame<PCB_EDIT_FRAME>()->GetBoard();
486 RN_NET* ratsnest = board->GetConnectivity()->GetRatsnestForNet( currentNet );
487
488 return ratsnest && !ratsnest->GetEdges().empty();
489 };
490
492 menu.AddSeparator( 1 );
493
494 menu.AddItem( PCB_ACTIONS::clearHighlight, haveHighlight, 2 );
495 menu.AddSeparator( haveHighlight, 2 );
496
497 menu.AddItem( PCB_ACTIONS::routeSingleTrack, notRoutingCond );
498 menu.AddItem( PCB_ACTIONS::routeDiffPair, notRoutingCond );
501 menu.AddItem( PCB_ACTIONS::routerContinueFromEnd, hasOtherEnd );
502 menu.AddItem( PCB_ACTIONS::routerAttemptFinish, hasOtherEnd );
503 menu.AddItem( PCB_ACTIONS::breakTrack, notRoutingCond );
504
505 menu.AddItem( PCB_ACTIONS::drag45Degree, notRoutingCond );
506 menu.AddItem( PCB_ACTIONS::dragFreeAngle, notRoutingCond );
507
516
517 menu.AddSeparator();
518
519 auto diffPairCond =
520 [this]( const SELECTION& )
521 {
523 };
524
526 menu.AddMenu( m_diffPairMenu.get(), diffPairCond );
527
529
530 menu.AddSeparator();
531
533
534 return true;
535}
static TOOL_ACTION cancelInteractive
Definition: actions.h:63
void SetTitle(const wxString &aTitle) override
Set title for the menu.
Definition: action_menu.cpp:87
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:43
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:269
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:430
void AddStandardSubMenus(TOOL_MENU &aMenu)
Construct a "basic" menu for a tool, containing only items that apply to all tools (e....
static TOOL_ACTION drag45Degree
Definition: pcb_actions.h:166
static TOOL_ACTION routerUndoLastSegment
Definition: pcb_actions.h:222
static TOOL_ACTION routerSettingsDialog
Activation of the Push and Shove settings dialogs.
Definition: pcb_actions.h:231
static TOOL_ACTION routerAttemptFinish
Definition: pcb_actions.h:225
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:211
static TOOL_ACTION breakTrack
Break a single track into two segments at the cursor.
Definition: pcb_actions.h:164
static TOOL_ACTION routerContinueFromEnd
Definition: pcb_actions.h:224
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:167
static TOOL_ACTION clearHighlight
Definition: pcb_actions.h:496
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:208
The main frame for Pcbnew.
ROUTER_MODE Mode() const
Definition: pns_router.h:133
Describe ratsnest for a single net.
Definition: ratsnest_data.h:63
const std::vector< CN_EDGE > & GetEdges() const
Definition: ratsnest_data.h:85
std::shared_ptr< ACTION_MENU > m_trackViaMenu
Definition: router_tool.h:92
std::shared_ptr< ACTION_MENU > m_diffPairMenu
Definition: router_tool.h:91
static bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:44
void RegisterSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Store a submenu of this menu model.
Definition: tool_menu.cpp:50
@ PNS_MODE_ROUTE_DIFF_PAIR
Definition: pns_router.h:64
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))
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_EndTrack("pcbnew.InteractiveRouter.EndTrack", AS_CONTEXT, WXK_END, "", _("Finish Track"), _("Stops laying the current track."), BITMAPS::checked_ok)
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 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_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 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)

References _, ACT_EndTrack, ACT_PlaceBlindVia, ACT_PlaceMicroVia, ACT_PlaceThroughVia, ACT_SelLayerAndPlaceBlindVia, ACT_SelLayerAndPlaceMicroVia, ACT_SelLayerAndPlaceThroughVia, ACT_SwitchCornerMode, ACT_SwitchPosture, EDA_DRAW_FRAME::AddStandardSubMenus(), PCB_TOOL_BASE::board(), PCB_ACTIONS::breakTrack, ACTIONS::cancelInteractive, PCB_ACTIONS::clearHighlight, PCB_ACTIONS::drag45Degree, PCB_ACTIONS::dragFreeAngle, PCB_TOOL_BASE::frame(), BOARD_ITEM::GetBoard(), BOARD::GetConnectivity(), PNS::ROUTER::GetCurrentNets(), RN_NET::GetEdges(), KIGFX::RENDER_SETTINGS::GetHighlightNetCodes(), TOOL_MENU::GetMenu(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), TOOL_MANAGER::GetView(), m_diffPairMenu, m_lastTargetLayer, TOOL_INTERACTIVE::m_menu, m_originalActiveLayer, PNS::TOOL_BASE::m_router, TOOL_BASE::m_toolMgr, m_trackViaMenu, PNS::ROUTER::Mode(), PNS::PNS_MODE_ROUTE_DIFF_PAIR, TOOL_MENU::RegisterSubMenu(), PCB_ACTIONS::routeDiffPair, PCB_ACTIONS::routerAttemptFinish, PCB_ACTIONS::routerContinueFromEnd, 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 2364 of file router_tool.cpp.

2365{
2366 const SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
2367
2368 if( selection.Size() != 1 )
2369 return 0;
2370
2371 const BOARD_CONNECTED_ITEM* item =
2372 static_cast<const BOARD_CONNECTED_ITEM*>( selection.Front() );
2373
2374 if( item->Type() != PCB_TRACE_T )
2375 return 0;
2376
2378
2379 Activate();
2380
2382
2383 TOOL_MANAGER* toolManager = frame()->GetToolManager();
2384 GAL* gal = toolManager->GetView()->GetGAL();
2385
2387 m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
2388
2389 if( toolManager->IsContextMenuActive() )
2390 {
2391 // If we're here from a context menu then we need to get the position of the
2392 // cursor when the context menu was invoked. This is used to figure out the
2393 // break point on the track.
2395 }
2396 else
2397 {
2398 // If we're here from a hotkey, then get the current mouse position so we know
2399 // where to break the track.
2400 m_startSnapPoint = snapToItem( m_startItem, controls()->GetCursorPosition() );
2401 }
2402
2403 if( m_startItem && m_startItem->IsLocked() )
2404 {
2405 KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
2406 wxOK | wxCANCEL | wxICON_WARNING );
2407 dlg.SetOKLabel( _( "Break Track" ) );
2408 dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
2409
2410 if( dlg.ShowModal() == wxID_CANCEL )
2411 return 0;
2412 }
2413
2414 frame()->UndoRedoBlock( true );
2415 breakTrack();
2416
2419
2420 frame()->UndoRedoBlock( false );
2421
2422 return 0;
2423}
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
void SetSnap(bool aSnap)
Definition: grid_helper.h:65
void SetUseGrid(bool aSnapToGrid)
Definition: grid_helper.h:68
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
Definition: confirm.h:46
Abstract interface for drawing on a 2D-surface.
bool GetGridSnapping() const
bool IsLocked() const
Definition: pns_item.h:229
ITEM * FindItemByParent(const BOARD_ITEM *aParent)
Definition: pns_node.cpp:1638
NODE * GetWorld() const
Definition: pns_router.h:161
const VECTOR2I snapToItem(ITEM *aSnapToItem, const VECTOR2I &aP)
PCB_GRID_HELPER * m_gridHelper
Definition: pns_tool_base.h:77
void breakTrack()
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
bool DisableGridSnapping() const
Definition: tool_event.h:344
int Modifier(int aMask=MD_MODIFIER_MASK) const
Definition: tool_event.h:339
Master controller class:
Definition: tool_manager.h:55
VECTOR2D GetMenuCursorPos() const
Definition: tool_manager.h:442
bool IsContextMenuActive() const
True while processing a context menu.
Definition: tool_manager.h:413
@ MD_SHIFT
Definition: tool_event.h:138
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:101

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(), EDA_ITEM::Type(), and PCB_BASE_EDIT_FRAME::UndoRedoBlock().

Referenced by setTransitions().

◆ InlineDrag()

int ROUTER_TOOL::InlineDrag ( const TOOL_EVENT aEvent)

Definition at line 2025 of file router_tool.cpp.

2026{
2027 const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
2028
2029 if( selection.Empty() )
2031
2032 if( selection.Size() != 1 )
2033 return 0;
2034
2035 BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.Front() );
2036
2037 if( item->Type() != PCB_TRACE_T
2038 && item->Type() != PCB_VIA_T
2039 && item->Type() != PCB_FOOTPRINT_T )
2040 {
2041 return 0;
2042 }
2043
2044 // If we overrode locks, we want to clear the flag from the source item before SyncWorld is
2045 // called so that virtual vias are not generated for the (now unlocked) track segment. Note in
2046 // this case the lock can't be reliably re-applied, because there is no guarantee that the end
2047 // state of the drag results in the same number of segments so it's not clear which segment to
2048 // apply the lock state to.
2049 bool wasLocked = false;
2050
2051 if( item->IsLocked() )
2052 {
2053 wasLocked = true;
2054 item->SetLocked( false );
2055 }
2056
2058
2059 Activate();
2060
2061 m_startItem = nullptr;
2062
2063 PNS::ITEM* startItem = nullptr;
2064 PNS::ITEM_SET itemsToDrag;
2065 FOOTPRINT* footprint = nullptr;
2066
2067 bool showCourtyardConflicts = frame()->GetPcbNewSettings()->m_ShowCourtyardCollisions;
2068
2069 std::shared_ptr<DRC_ENGINE> drcEngine = m_toolMgr->GetTool<DRC_TOOL>()->GetDRCEngine();
2070 DRC_INTERACTIVE_COURTYARD_CLEARANCE courtyardClearanceDRC( drcEngine );
2071
2072 std::shared_ptr<CONNECTIVITY_DATA> connectivityData = board()->GetConnectivity();
2073 std::vector<BOARD_ITEM*> dynamicItems;
2074 std::unique_ptr<CONNECTIVITY_DATA> dynamicData = nullptr;
2075 VECTOR2I lastOffset;
2076
2077 if( item->Type() == PCB_FOOTPRINT_T )
2078 {
2079 footprint = static_cast<FOOTPRINT*>( item );
2080
2081 for( PAD* pad : footprint->Pads() )
2082 {
2084
2085 if( solid )
2086 itemsToDrag.Add( solid );
2087
2088 if( pad->GetLocalRatsnestVisible() || displayOptions().m_ShowModuleRatsnest )
2089 {
2090 if( connectivityData->GetRatsnestForPad( pad ).size() > 0 )
2091 dynamicItems.push_back( pad );
2092 }
2093 }
2094
2095 if( showCourtyardConflicts )
2096 {
2097 courtyardClearanceDRC.Init( board() );
2098 courtyardClearanceDRC.m_FpInMove.push_back( footprint );
2099 }
2100
2101 dynamicData = std::make_unique<CONNECTIVITY_DATA>( dynamicItems, true );
2102 connectivityData->BlockRatsnestItems( dynamicItems );
2103 }
2104 else
2105 {
2106 startItem = m_router->GetWorld()->FindItemByParent( item );
2107
2108 if( startItem )
2109 itemsToDrag.Add( startItem );
2110 }
2111
2112 GAL* gal = m_toolMgr->GetView()->GetGAL();
2113 VECTOR2I p0 = controls()->GetCursorPosition( false );
2114 VECTOR2I p = p0;
2115
2117 m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
2118
2119 if( startItem )
2120 {
2121 p = snapToItem( startItem, p0 );
2122 m_startItem = startItem;
2123
2124 if( m_startItem && m_startItem->Net() > 0 )
2125 highlightNets( true, { m_startItem->Net() } );
2126 }
2127 else if( footprint )
2128 {
2129 // The mouse is going to be moved on grid before dragging begins.
2130 VECTOR2I tweakedMousePos;
2131 PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
2132
2133 // Check if user wants to warp the mouse to origin of moved object
2134
2135 if( editFrame->GetMoveWarpsCursor() )
2136 tweakedMousePos = footprint->GetPosition(); // Use footprint anchor to warp mouse
2137 else
2138 tweakedMousePos = controls()->GetCursorPosition(); // Just use current mouse pos
2139
2140 // We tweak the mouse position using the value from above, and then use that as the
2141 // start position to prevent the footprint from jumping when we start dragging.
2142 // First we move the visual cross hair cursor...
2143 controls()->ForceCursorPosition( true, tweakedMousePos );
2144 controls()->SetCursorPosition( tweakedMousePos ); // ...then the mouse pointer
2145
2146 // Now that the mouse is in the right position, get a copy of the position to use later
2147 p = controls()->GetCursorPosition();
2148 }
2149
2150 int dragMode = aEvent.Parameter<int64_t> ();
2151
2152 bool dragStarted = m_router->StartDragging( p, itemsToDrag, dragMode );
2153
2154 if( !dragStarted )
2155 {
2156 if( wasLocked )
2157 item->SetLocked( true );
2158
2159 return 0;
2160 }
2161
2162 m_gridHelper->SetAuxAxes( true, p );
2163 controls()->ShowCursor( true );
2164 controls()->SetAutoPan( true );
2165 frame()->UndoRedoBlock( true );
2166
2167 view()->ClearPreview();
2168 view()->InitPreview();
2169
2170 auto setCursor =
2171 [&]()
2172 {
2174 };
2175
2176 // Set initial cursor
2177 setCursor();
2178
2179 // Set the initial visible area
2180 BOX2D viewAreaD = getView()->GetGAL()->GetVisibleWorldExtents();
2181 m_router->SetVisibleViewArea( BOX2I( viewAreaD.GetOrigin(), viewAreaD.GetSize() ) );
2182
2183 // Send an initial movement to prime the collision detection
2184 m_router->Move( p, nullptr );
2185
2186 bool hasMouseMoved = false;
2187
2188 while( TOOL_EVENT* evt = Wait() )
2189 {
2190 setCursor();
2191
2192 if( evt->IsCancelInteractive() )
2193 {
2194 if( wasLocked )
2195 item->SetLocked( true );
2196
2197 break;
2198 }
2199 else if( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
2200 {
2201 hasMouseMoved = true;
2202 updateEndItem( *evt );
2204
2205 if( footprint )
2206 {
2207 VECTOR2I offset = m_endSnapPoint - p;
2208 BOARD_ITEM* previewItem;
2209
2210 VECTOR2I fp_offset( offset );
2211 RotatePoint( fp_offset, -footprint->GetOrientation() );
2212
2213 view()->ClearPreview();
2214
2215 for( BOARD_ITEM* drawing : footprint->GraphicalItems() )
2216 {
2217 previewItem = static_cast<BOARD_ITEM*>( drawing->Clone() );
2218
2219 if( drawing->Type() == PCB_FP_SHAPE_T )
2220 {
2221 FP_SHAPE* shape = static_cast<FP_SHAPE*>( previewItem );
2222 shape->FP_SHAPE::Move( fp_offset );
2223 }
2224 else
2225 {
2226 previewItem->Move( offset );
2227 }
2228
2229 view()->AddToPreview( previewItem );
2230 view()->Hide( drawing, true );
2231 }
2232
2233 for( PAD* pad : footprint->Pads() )
2234 {
2235 if( ( pad->GetLayerSet() & LSET::AllCuMask() ).none()
2236 && pad->GetDrillSize().x == 0 )
2237 {
2238 previewItem = static_cast<BOARD_ITEM*>( pad->Clone() );
2239 previewItem->Move( offset );
2240
2241 view()->AddToPreview( previewItem );
2242 }
2243 else
2244 {
2245 // Pads with copper or holes are handled by the router
2246 }
2247
2248 view()->Hide( pad, true );
2249 }
2250
2251 previewItem = static_cast<BOARD_ITEM*>( footprint->Reference().Clone() );
2252 previewItem->Move( offset );
2253 view()->AddToPreview( previewItem );
2254 view()->Hide( &footprint->Reference() );
2255
2256 previewItem = static_cast<BOARD_ITEM*>( footprint->Value().Clone() );
2257 previewItem->Move( offset );
2258 view()->AddToPreview( previewItem );
2259 view()->Hide( &footprint->Value() );
2260
2261 for( ZONE* zone : footprint->Zones() )
2262 {
2263 previewItem = static_cast<BOARD_ITEM*>( zone->Clone() );
2264 previewItem->Move( offset );
2265 view()->AddToPreview( previewItem );
2266 view()->Hide( zone, true );
2267 }
2268
2269 if( showCourtyardConflicts )
2270 {
2271 footprint->Move( offset );
2272 courtyardClearanceDRC.Run();
2273 courtyardClearanceDRC.UpdateConflicts( getView(), false );
2274 footprint->Move( -offset );
2275 }
2276
2277 // Update ratsnest
2278 dynamicData->Move( offset - lastOffset );
2279 lastOffset = offset;
2280 connectivityData->ComputeLocalRatsnest( dynamicItems, dynamicData.get(), offset );
2281 }
2282 }
2283 else if( hasMouseMoved && ( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) )
2284 {
2285 updateEndItem( *evt );
2287 break;
2288 }
2289 else if( evt->IsUndoRedo() )
2290 {
2291 // We're in an UndoRedoBlock. If we get here, something's broken.
2292 wxFAIL;
2293 break;
2294 }
2295 else if( evt->Category() == TC_COMMAND )
2296 {
2297 // TODO: It'd be nice to be able to say "don't allow any non-trivial editing actions",
2298 // but we don't at present have that, so we just knock out some of the egregious ones.
2299 if( evt->IsAction( &ACTIONS::cut )
2300 || evt->IsAction( &ACTIONS::copy )
2301 || evt->IsAction( &ACTIONS::paste )
2302 || evt->IsAction( &ACTIONS::pasteSpecial )
2304 {
2305 wxBell();
2306 }
2307 // treat an undo as an escape
2308 else if( evt->IsAction( &ACTIONS::undo ) )
2309 {
2310 if( wasLocked )
2311 item->SetLocked( true );
2312
2313 break;
2314 }
2315 else
2316 {
2317 evt->SetPassEvent();
2318 }
2319 }
2320 else
2321 {
2322 evt->SetPassEvent();
2323 }
2324
2325 handleCommonEvents( *evt );
2326 }
2327
2328 if( footprint )
2329 {
2330 for( BOARD_ITEM* drawing : footprint->GraphicalItems() )
2331 view()->Hide( drawing, false );
2332
2333 view()->Hide( &footprint->Reference(), false );
2334 view()->Hide( &footprint->Value(), false );
2335
2336 for( ZONE* zone : footprint->Zones() )
2337 view()->Hide( zone, false );
2338
2339 for( PAD* pad : footprint->Pads() )
2340 view()->Hide( pad, false );
2341
2342 view()->ClearPreview();
2343 view()->ShowPreview( false );
2344
2345 connectivityData->ClearLocalRatsnest();
2346 }
2347
2348 // Clear temporary COURTYARD_CONFLICT flag and ensure the conflict shadow is cleared
2349 courtyardClearanceDRC.ClearConflicts( getView() );
2350
2353
2354 m_gridHelper->SetAuxAxes( false );
2355 controls()->SetAutoPan( false );
2356 controls()->ForceCursorPosition( false );
2357 frame()->UndoRedoBlock( false );
2358 highlightNets( false );
2359
2360 return 0;
2361}
static TOOL_ACTION paste
Definition: actions.h:69
static TOOL_ACTION copy
Definition: actions.h:68
static TOOL_ACTION pasteSpecial
Definition: actions.h:70
static TOOL_ACTION undo
Definition: actions.h:65
static TOOL_ACTION cut
Definition: actions.h:67
virtual void SetLocked(bool aLocked)
Definition: board_item.h:266
virtual void Move(const VECTOR2I &aMoveVector)
Move this object.
Definition: board_item.h:278
virtual bool IsLocked() const
Definition: board_item.cpp:71
EDA_ANGLE GetOrientation() const
Definition: footprint.h:191
PADS & Pads()
Definition: footprint.h:170
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition: footprint.cpp:1558
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:567
FP_ZONES & Zones()
Definition: footprint.h:176
VECTOR2I GetPosition() const override
Definition: footprint.h:188
DRAWINGS & GraphicalItems()
Definition: footprint.h:173
FP_TEXT & Reference()
Definition: footprint.h:568
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: fp_text.cpp:343
void SetAuxAxes(bool aEnable, const VECTOR2I &aOrigin=VECTOR2I(0, 0))
Definition: grid_helper.cpp:75
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
void ShowPreview(bool aShow=true)
Definition: view.cpp:1649
void AddToPreview(EDA_ITEM *aItem, bool aTakeOwnership=true)
Definition: view.cpp:1635
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hide the item in the view (e.g.
Definition: view.cpp:1550
void InitPreview()
Definition: view.cpp:1628
void ClearPreview()
Definition: view.cpp:1613
Definition: pad.h:60
bool m_ShowCourtyardCollisions
Common, abstract interface for edit frames.
PCBNEW_SETTINGS::DISPLAY_OPTIONS & displayOptions() const
FOOTPRINT * footprint() const
void Add(const LINE &aLine)
Definition: pns_itemset.cpp:32
Base class for PNS router board items.
Definition: pns_item.h:56
int Net() const
Definition: pns_item.h:154
bool FixRoute(const VECTOR2I &aP, ITEM *aItem, bool aForceFinish=false)
Definition: pns_router.cpp:866
bool StartDragging(const VECTOR2I &aP, ITEM *aItem, int aDragMode=DM_ANY)
Definition: pns_router.cpp:151
void handleCommonEvents(TOOL_EVENT &evt)
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:109
bool GetMoveWarpsCursor() const
Indicate that a move operation should warp the mouse pointer to the origin of the move object.
Definition: tools_holder.h:153
static bool IsZoneFillAction(const TOOL_EVENT *aEvent)
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102

References TOOL_INTERACTIVE::Activate(), PNS::ITEM_SET::Add(), KIGFX::VIEW::AddToPreview(), LSET::AllCuMask(), ARROW, PCB_TOOL_BASE::board(), BUT_LEFT, DRC_INTERACTIVE_COURTYARD_CLEARANCE::ClearConflicts(), 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::GetOrientation(), BOX2< Vec >::GetOrigin(), PCB_BASE_FRAME::GetPcbNewSettings(), 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::highlightNets(), DRC_INTERACTIVE_COURTYARD_CLEARANCE::Init(), KIGFX::VIEW::InitPreview(), BOARD_ITEM::IsLocked(), ZONE_FILLER_TOOL::IsZoneFillAction(), PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, DRC_INTERACTIVE_COURTYARD_CLEARANCE::m_FpInMove, PNS::TOOL_BASE::m_gridHelper, PNS::TOOL_BASE::m_router, PCBNEW_SETTINGS::m_ShowCourtyardCollisions, PCBNEW_SETTINGS::DISPLAY_OPTIONS::m_ShowModuleRatsnest, PNS::TOOL_BASE::m_startItem, TOOL_BASE::m_toolMgr, MD_SHIFT, TOOL_EVENT::Modifier(), BOARD_ITEM::Move(), FOOTPRINT::Move(), PNS::ROUTER::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(), RotatePoint(), PNS::ROUTER::RoutingInProgress(), DRC_INTERACTIVE_COURTYARD_CLEARANCE::Run(), 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(), TC_COMMAND, EDA_ITEM::Type(), ACTIONS::undo, PCB_BASE_EDIT_FRAME::UndoRedoBlock(), DRC_INTERACTIVE_COURTYARD_CLEARANCE::UpdateConflicts(), 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 332 of file pcb_tool_base.cpp.

333{
334 SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
335
336 if( frame()->IsType( FRAME_PCB_EDITOR ) )
337 return mgr.GetAppSettings<PCBNEW_SETTINGS>()->m_Use45DegreeLimit;
338 else
339 return mgr.GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>()->m_Use45Limit;
340}
T * GetAppSettings(bool aLoadNow=true)
Returns a handle to the a given settings by type If the settings have already been loaded,...
@ FRAME_PCB_EDITOR
Definition: frame_type.h:40
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111

References PCB_TOOL_BASE::frame(), FRAME_PCB_EDITOR, SETTINGS_MANAGER::GetAppSettings(), and Pgm().

Referenced by DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawShape(), DRAWING_TOOL::DrawZone(), and ZONE_CREATE_HELPER::OnFirstPoint().

◆ IsBoardEditor()

bool PCB_TOOL_BASE::IsBoardEditor ( ) const
inlineinherited

Definition at line 109 of file pcb_tool_base.h.

109{ return m_isBoardEditor; }

References PCB_TOOL_BASE::m_isBoardEditor.

Referenced by BOARD_COMMIT::BOARD_COMMIT().

◆ IsFootprintEditor()

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

32{
34}
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(), 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 1667 of file router_tool.cpp.

1668{
1669 if( m_inRouterTool )
1670 return 0;
1671
1673
1675 PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
1677
1679 {
1680 if( m_router->Mode() == mode )
1681 return 0;
1682 else
1684 }
1685
1686 // Deselect all items
1688
1689 frame->PushTool( aEvent );
1690
1691 auto setCursor =
1692 [&]()
1693 {
1695 };
1696
1697 Activate();
1698 // Must be done after Activate() so that it gets set into the correct context
1699 controls->ShowCursor( true );
1700 controls->ForceCursorPosition( false );
1701 // Set initial cursor
1702 setCursor();
1703
1704 m_router->SetMode( mode );
1705 m_cancelled = false;
1706
1707 if( aEvent.HasPosition() )
1708 m_toolMgr->PrimeTool( aEvent.Position() );
1709
1710 // Main loop: keep receiving events
1711 while( TOOL_EVENT* evt = Wait() )
1712 {
1713 if( !evt->IsDrag() )
1714 setCursor();
1715
1716 if( evt->IsCancelInteractive() )
1717 {
1718 frame->PopTool( aEvent );
1719 break;
1720 }
1721 else if( evt->IsActivate() )
1722 {
1723 if( evt->IsMoveTool() || evt->IsEditorTool() )
1724 {
1725 // leave ourselves on the stack so we come back after the move
1726 break;
1727 }
1728 else
1729 {
1730 frame->PopTool( aEvent );
1731 break;
1732 }
1733 }
1734 else if( evt->Action() == TA_UNDO_REDO_PRE )
1735 {
1737 }
1738 else if( evt->Action() == TA_UNDO_REDO_POST || evt->Action() == TA_MODEL_CHANGE )
1739 {
1741 }
1742 else if( evt->IsMotion() )
1743 {
1744 updateStartItem( *evt );
1745 }
1746 else if( evt->IsAction( &PCB_ACTIONS::dragFreeAngle ) )
1747 {
1748 updateStartItem( *evt, true );
1750 }
1751 else if( evt->IsAction( &PCB_ACTIONS::drag45Degree ) )
1752 {
1753 updateStartItem( *evt, true );
1755 }
1756 else if( evt->IsAction( &PCB_ACTIONS::breakTrack ) )
1757 {
1758 updateStartItem( *evt, true );
1759 breakTrack( );
1760 evt->SetPassEvent( false );
1761 }
1762 else if( evt->IsClick( BUT_LEFT )
1763 || evt->IsAction( &PCB_ACTIONS::routeSingleTrack )
1764 || evt->IsAction( &PCB_ACTIONS::routeDiffPair ) )
1765 {
1766 updateStartItem( *evt );
1767
1768 if( evt->HasPosition() )
1769 {
1770 if( evt->Modifier( MD_SHIFT ) )
1772 else
1774 }
1775 }
1776 else if( evt->IsAction( &ACT_PlaceThroughVia ) )
1777 {
1779 }
1780 else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1781 {
1784 updateStartItem( *evt );
1785 }
1786 else if( evt->IsKeyPressed() )
1787 {
1788 // wxWidgets fails to correctly translate shifted keycodes on the wxEVT_CHAR_HOOK
1789 // event so we need to process the wxEVT_CHAR event that will follow as long as we
1790 // pass the event.
1791 evt->SetPassEvent();
1792 }
1793 else if( evt->IsClick( BUT_RIGHT ) )
1794 {
1796 }
1797 else
1798 {
1799 evt->SetPassEvent();
1800 }
1801
1802 if( m_cancelled )
1803 {
1804 frame->PopTool( aEvent );
1805 break;
1806 }
1807 }
1808
1809 // Store routing settings till the next invocation
1812
1813 return 0;
1814}
An interface for classes handling user events controlling the view behavior such as zooming,...
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:326
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:328
virtual PCB_LAYER_ID GetActiveLayer() const
void SetMode(ROUTER_MODE aMode)
void ClearViewDecorations()
Definition: pns_router.cpp:939
void ClearWorld()
Definition: pns_router.cpp:102
void SyncWorld()
Definition: pns_router.cpp:92
void performDragging(int aMode=PNS::DM_ANY)
void performRouting()
bool HasPosition() const
Definition: tool_event.h:243
const VECTOR2D Position() const
Returns the point where dragging has started.
Definition: tool_event.h:266
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...
ROUTER_MODE
Definition: pns_router.h:62
@ DM_ANY
Definition: pns_router.h:77
@ TA_MODEL_CHANGE
Definition: tool_event.h:116
@ TA_UNDO_REDO_PRE
Definition: tool_event.h:101
@ TA_UNDO_REDO_POST
Definition: tool_event.h:104

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_BASE::getViewControls(), TOOL_EVENT::HasPosition(), PCB_ACTIONS::layerChanged, PCB_ACTIONS::layerToggle, PNS::TOOL_BASE::m_cancelled, m_inRouterTool, 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_EVENT::Position(), 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, updateSizesAfterLayerSwitch(), 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 1945 of file router_tool.cpp.

1946{
1947 /*
1948 * If the collection contains a trivial line corner (two connected segments)
1949 * or a non-fanout-via (a via with no more than two connected segments), then
1950 * trim the collection down to a single item (which one won't matter since
1951 * they're all connected).
1952 */
1953
1954 // First make sure we've got something that *might* match.
1955 int vias = aCollector.CountType( PCB_VIA_T );
1956 int traces = aCollector.CountType( PCB_TRACE_T );
1957 int arcs = aCollector.CountType( PCB_ARC_T );
1958
1959 if( arcs > 0 || vias > 1 || traces > 2 || vias + traces < 1 )
1960 return;
1961
1962 // Fetch first PCB_TRACK (via or trace) as our reference
1963 PCB_TRACK* reference = nullptr;
1964
1965 for( int i = 0; !reference && i < aCollector.GetCount(); i++ )
1966 reference = dynamic_cast<PCB_TRACK*>( aCollector[i] );
1967
1968 int refNet = reference->GetNetCode();
1969
1970 VECTOR2I refPoint( aPt.x, aPt.y );
1971 EDA_ITEM_FLAGS flags = reference->IsPointOnEnds( refPoint, -1 );
1972
1973 if( flags & STARTPOINT )
1974 refPoint = reference->GetStart();
1975 else if( flags & ENDPOINT )
1976 refPoint = reference->GetEnd();
1977
1978 // Check all items to ensure that any TRACKs are co-terminus with the reference and on
1979 // the same net.
1980 for( int i = 0; i < aCollector.GetCount(); i++ )
1981 {
1982 PCB_TRACK* neighbor = dynamic_cast<PCB_TRACK*>( aCollector[i] );
1983
1984 if( neighbor && neighbor != reference )
1985 {
1986 if( neighbor->GetNetCode() != refNet )
1987 return;
1988
1989 if( neighbor->GetStart() != refPoint && neighbor->GetEnd() != refPoint )
1990 return;
1991 }
1992 }
1993
1994 // Selection meets criteria; trim it to the reference item.
1995 aCollector.Empty();
1996 aCollector.Append( reference );
1997}
void Empty()
Clear the list.
Definition: collector.h:89
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:81
int CountType(KICAD_T aType)
Count the number of items matching aType.
Definition: collector.h:221
void Append(EDA_ITEM *item)
Add an item to the end of the list.
Definition: collector.h:99
const VECTOR2I & GetStart() const
Definition: pcb_track.h:114
const VECTOR2I & GetEnd() const
Definition: pcb_track.h:111
EDA_ITEM_FLAGS IsPointOnEnds(const VECTOR2I &point, int min_dist=0) const
Function IsPointOnEnds returns STARTPOINT if point if near (dist = min_dist) start point,...
Definition: pcb_track.cpp:236
#define ENDPOINT
ends. (Used to support dragging.)
#define STARTPOINT
When a line is selected, these flags indicate which.
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:103

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

866{
867 return handleLayerSwitch( aEvent, false );
868}
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 2444 of file router_tool.cpp.

2445{
2447
2448 if( !m_router->GetCurrentNets().empty() )
2450
2451 m_router->UpdateSizes( sizes );
2452
2453 // Changing the track width can affect the placement, so call the
2454 // move routine without changing the destination
2455 // Update end item first to avoid moving to an invalid/missing item
2456 updateEndItem( aEvent );
2458
2460
2461 return 0;
2462}
PNS_KICAD_IFACE * m_iface
Definition: pns_tool_base.h:78
bool ImportSizes(PNS::SIZES_SETTINGS &aSizes, PNS::ITEM *aStartItem, int aNet) override

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

◆ performDragging()

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

Definition at line 1817 of file router_tool.cpp.

1818{
1820
1822
1823 if( m_startItem && m_startItem->IsLocked() )
1824 {
1825 KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1826 wxOK | wxCANCEL | wxICON_WARNING );
1827 dlg.SetOKLabel( _( "Drag Anyway" ) );
1828 dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1829
1830 if( dlg.ShowModal() == wxID_CANCEL )
1831 return;
1832 }
1833
1834 // We don't support dragging arcs inside the PNS right now
1836 {
1839
1840 m_startItem = nullptr;
1841
1842 m_gridHelper->SetAuxAxes( false );
1843 ctls->ForceCursorPosition( false );
1844 highlightNets( false );
1845
1846 m_cancelled = true;
1847
1849
1850 return;
1851 }
1852
1853 bool dragStarted = m_router->StartDragging( m_startSnapPoint, m_startItem, aMode );
1854
1855 if( !dragStarted )
1856 return;
1857
1858 if( m_startItem && m_startItem->Net() > 0 )
1859 highlightNets( true, { m_startItem->Net() } );
1860
1861 ctls->SetAutoPan( true );
1863 frame()->UndoRedoBlock( true );
1864
1865 while( TOOL_EVENT* evt = Wait() )
1866 {
1867 ctls->ForceCursorPosition( false );
1868
1869 if( evt->IsMotion() )
1870 {
1871 updateEndItem( *evt );
1873 }
1874 else if( evt->IsClick( BUT_LEFT ) )
1875 {
1877 break;
1878 }
1879 else if( evt->IsClick( BUT_RIGHT ) )
1880 {
1882 }
1883 else if( evt->IsCancelInteractive() || evt->IsActivate() )
1884 {
1885 if( evt->IsCancelInteractive() && !m_startItem )
1886 m_cancelled = true;
1887
1888 if( evt->IsActivate() && !evt->IsMoveTool() )
1889 m_cancelled = true;
1890
1891 break;
1892 }
1893 else if( evt->IsUndoRedo() )
1894 {
1895 // We're in an UndoRedoBlock. If we get here, something's broken.
1896 wxFAIL;
1897 break;
1898 }
1899 else if( evt->Category() == TC_COMMAND )
1900 {
1901 // TODO: It'd be nice to be able to say "don't allow any non-trivial editing actions",
1902 // but we don't at present have that, so we just knock out some of the egregious ones.
1903 if( evt->IsAction( &ACTIONS::cut )
1904 || evt->IsAction( &ACTIONS::copy )
1905 || evt->IsAction( &ACTIONS::paste )
1906 || evt->IsAction( &ACTIONS::pasteSpecial )
1908 {
1909 wxBell();
1910 }
1911 // treat an undo as an escape
1912 else if( evt->IsAction( &ACTIONS::undo ) )
1913 {
1914 if( m_startItem )
1915 break;
1916 else
1917 wxBell();
1918 }
1919 else
1920 {
1921 evt->SetPassEvent();
1922 }
1923 }
1924 else
1925 {
1926 evt->SetPassEvent();
1927 }
1928
1929 handleCommonEvents( *evt );
1930 }
1931
1934
1935 m_startItem = nullptr;
1936
1937 m_gridHelper->SetAuxAxes( false );
1938 frame()->UndoRedoBlock( false );
1939 ctls->SetAutoPan( false );
1940 ctls->ForceCursorPosition( false );
1941 highlightNets( false );
1942}
PnsKind Kind() const
Return the type (kind) of the item.
Definition: pns_item.h:132

References _, PNS::ITEM::ARC_T, BUT_LEFT, BUT_RIGHT, PNS::ROUTER::ClearViewDecorations(), ACTIONS::copy, ACTIONS::cut, KIDIALOG::DoNotShowCheckbox(), PCB_ACTIONS::drag45Degree, PNS::ROUTER::FixRoute(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), TOOL_BASE::getViewControls(), handleCommonEvents(), PNS::TOOL_BASE::highlightNets(), PNS::ITEM::IsLocked(), ZONE_FILLER_TOOL::IsZoneFillAction(), 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(), ACTIONS::paste, ACTIONS::pasteSpecial, 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(), TC_COMMAND, ACTIONS::undo, 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 1272 of file router_tool.cpp.

1273{
1275
1276 if( !prepareInteractive() )
1277 return;
1278
1279 auto setCursor =
1280 [&]()
1281 {
1283 };
1284
1285 auto syncRouterAndFrameLayer =
1286 [&]()
1287 {
1288 PCB_LAYER_ID routingLayer = ToLAYER_ID( m_router->GetCurrentLayer() );
1289 PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
1290
1291 editFrame->SetActiveLayer( routingLayer );
1292
1293 if( !getView()->IsLayerVisible( routingLayer ) )
1294 {
1295 editFrame->GetAppearancePanel()->SetLayerVisible( routingLayer, true );
1296 editFrame->GetCanvas()->Refresh();
1297 }
1298 };
1299
1300 // Set initial cursor
1301 setCursor();
1302
1303 while( TOOL_EVENT* evt = Wait() )
1304 {
1305 setCursor();
1306
1307 // Don't crash if we missed an operation that canceled routing.
1308 if( !m_router->RoutingInProgress() )
1309 {
1310 if( evt->IsCancelInteractive() )
1311 m_cancelled = true;
1312
1313 break;
1314 }
1315
1316 handleCommonEvents( *evt );
1317
1318 if( evt->IsMotion() )
1319 {
1320 updateEndItem( *evt );
1322 }
1323 else if( evt->IsAction( &PCB_ACTIONS::routerUndoLastSegment ) )
1324 {
1326 updateEndItem( *evt );
1328 }
1329 else if( evt->IsAction( &PCB_ACTIONS::routerAttemptFinish ) )
1330 {
1331 bool* autoRouted = evt->Parameter<bool*>();
1332
1333 if( m_router->Finish() )
1334 {
1335 // When we're routing a group of signals automatically we want
1336 // to break up the undo stack every time we have to manually route
1337 // so the user gets nice checkpoints. Remove the APPEND_UNDO flag.
1338 if( autoRouted != nullptr )
1339 *autoRouted = true;
1340
1341 break;
1342 }
1343 else
1344 {
1345 // This acts as check if we were called by the autorouter; we don't want
1346 // to reset APPEND_UNDO if we're auto finishing after route-other-end
1347 if( autoRouted != nullptr )
1348 {
1349 *autoRouted = false;
1350 m_iface->SetCommitFlags( 0 );
1351 }
1352
1353 // Warp the mouse so the user is at the point we managed to route to
1354 controls()->WarpMouseCursor( m_router->Placer()->CurrentEnd(), true, true );
1355 }
1356 }
1357 else if( evt->IsAction( &PCB_ACTIONS::routerContinueFromEnd ) )
1358 {
1359 bool needsAppend = m_router->Placer()->HasPlacedAnything();
1360
1361 if( m_router->ContinueFromEnd() )
1362 {
1363 syncRouterAndFrameLayer();
1365
1366 // Warp the mouse to wherever we actually ended up routing to
1367 controls()->WarpMouseCursor( m_router->Placer()->CurrentEnd(), true, true );
1368
1369 // We want the next router commit to be one undo at the UI layer
1370 m_iface->SetCommitFlags( needsAppend ? APPEND_UNDO : 0 );
1371 }
1372 }
1373 else if( evt->IsClick( BUT_LEFT ) || evt->IsDrag( BUT_LEFT ) || evt->IsAction( &PCB_ACTIONS::routeSingleTrack ) )
1374 {
1375 updateEndItem( *evt );
1376 bool needLayerSwitch = m_router->IsPlacingVia();
1377 bool forceFinish = evt->Modifier( MD_SHIFT );
1378
1379 if( m_router->FixRoute( m_endSnapPoint, m_endItem, forceFinish ) )
1380 break;
1381
1382 if( needLayerSwitch )
1384
1385 // Synchronize the indicated layer
1386 syncRouterAndFrameLayer();
1387
1388 updateEndItem( *evt );
1390 m_startItem = nullptr;
1391 }
1392 else if( evt->IsAction( &ACT_SwitchCornerMode ) )
1393 {
1396 updateEndItem( *evt );
1397 m_router->Move( m_endSnapPoint, m_endItem ); // refresh
1398 }
1399 else if( evt->IsAction( &ACT_SwitchPosture ) )
1400 {
1402 updateEndItem( *evt );
1403 m_router->Move( m_endSnapPoint, m_endItem ); // refresh
1404 }
1405 else if( evt->IsAction( &PCB_ACTIONS::properties ) )
1406 {
1408 controls()->SetAutoPan( false );
1409 {
1411 }
1412 controls()->SetAutoPan( true );
1413 setCursor();
1415 }
1416 else if( evt->IsAction( &ACT_EndTrack ) || evt->IsDblClick( BUT_LEFT ) )
1417 {
1418 // Stop current routing:
1420 break;
1421 }
1422 else if( evt->IsCancelInteractive() || evt->IsActivate()
1423 || evt->IsAction( &PCB_ACTIONS::routerInlineDrag ) )
1424 {
1425 if( evt->IsCancelInteractive() && !m_router->RoutingInProgress() )
1426 m_cancelled = true;
1427
1428 if( evt->IsActivate() && !evt->IsMoveTool() )
1429 m_cancelled = true;
1430
1431 break;
1432 }
1433 else if( evt->IsUndoRedo() )
1434 {
1435 // We're in an UndoRedoBlock. If we get here, something's broken.
1436 wxFAIL;
1437 break;
1438 }
1439 else if( evt->IsClick( BUT_RIGHT ) )
1440 {
1442 }
1443 // TODO: It'd be nice to be able to say "don't allow any non-trivial editing actions",
1444 // but we don't at present have that, so we just knock out some of the egregious ones.
1445 else if( ZONE_FILLER_TOOL::IsZoneFillAction( evt ) )
1446 {
1447 wxBell();
1448 }
1449 else
1450 {
1451 evt->SetPassEvent();
1452 }
1453 }
1454
1456 // Reset to normal for next route
1457 m_iface->SetCommitFlags( 0 );
1458
1460}
#define APPEND_UNDO
Definition: board_commit.h:40
void SetLayerVisible(int aLayer, bool isVisible)
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...
virtual void WarpMouseCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
Definition: pcb_actions.h:242
APPEARANCE_CONTROLS * GetAppearancePanel()
void SetActiveLayer(PCB_LAYER_ID aLayer) override
Change the currently active layer to aLayer and also update the APPEARANCE_CONTROLS.
virtual const VECTOR2I & CurrentEnd() const =0
Function CurrentEnd()
virtual bool HasPlacedAnything() const
virtual const VECTOR2I & CurrentStart() const =0
Function CurrentStart()
void ToggleCornerMode()
PLACEMENT_ALGO * Placer()
Definition: pns_router.h:213
void UndoLastSegment()
Definition: pns_router.cpp:892
void CommitRouting()
Definition: pns_router.cpp:902
bool Finish()
Definition: pns_router.cpp:525
bool ContinueFromEnd()
Definition: pns_router.cpp:566
void FlipPosture()
Definition: pns_router.cpp:945
void SetCommitFlags(int aCommitFlags)
bool prepareInteractive()
void switchLayerOnViaPlacement()
bool finishInteractive()
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:932
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)

References ACT_CustomTrackWidth, ACT_EndTrack, ACT_SwitchCornerMode, ACT_SwitchPosture, APPEND_UNDO, ARROW, BUT_LEFT, BUT_RIGHT, PNS::ROUTER::ClearViewDecorations(), PNS::ROUTER::CommitRouting(), PNS::ROUTER::ContinueFromEnd(), PCB_TOOL_BASE::controls(), PNS::PLACEMENT_ALGO::CurrentEnd(), PNS::PLACEMENT_ALGO::CurrentStart(), PNS::ROUTER::Finish(), finishInteractive(), PNS::ROUTER::FixRoute(), PNS::ROUTER::FlipPosture(), PCB_TOOL_BASE::frame(), PCB_BASE_EDIT_FRAME::GetAppearancePanel(), PCB_BASE_FRAME::GetCanvas(), PNS::ROUTER::GetCurrentLayer(), TOOL_BASE::getView(), handleCommonEvents(), PNS::PLACEMENT_ALGO::HasPlacedAnything(), PNS::ROUTER::IsPlacingVia(), ZONE_FILLER_TOOL::IsZoneFillAction(), PNS::TOOL_BASE::m_cancelled, PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_iface, TOOL_INTERACTIVE::m_menu, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, TOOL_BASE::m_toolMgr, MD_SHIFT, PNS::ROUTER::Move(), PENCIL, PNS::ROUTER::Placer(), prepareInteractive(), PCB_ACTIONS::properties, EDA_DRAW_PANEL_GAL::Refresh(), PCB_ACTIONS::routerAttemptFinish, PCB_ACTIONS::routerContinueFromEnd, PCB_ACTIONS::routerInlineDrag, PCB_ACTIONS::routerUndoLastSegment, PCB_ACTIONS::routeSingleTrack, PNS::ROUTER::RoutingInProgress(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_EDIT_FRAME::SetActiveLayer(), KIGFX::VIEW_CONTROLS::SetAutoPan(), PNS_KICAD_IFACE::SetCommitFlags(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), APPEARANCE_CONTROLS::SetLayerVisible(), TOOL_MENU::ShowContextMenu(), switchLayerOnViaPlacement(), PNS::ROUTER::ToggleCornerMode(), ToLAYER_ID(), PNS::ROUTER::UndoLastSegment(), PNS::TOOL_BASE::updateEndItem(), UpdateMessagePanel(), TOOL_INTERACTIVE::Wait(), and KIGFX::VIEW_CONTROLS::WarpMouseCursor().

Referenced by MainLoop(), and RouteSelected().

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

100{
101 int tl = aLayer > 0 ? aLayer : getView()->GetTopLayer();
102
103 static const int candidateCount = 5;
104 ITEM* prioritized[candidateCount];
105 SEG::ecoord dist[candidateCount];
106
107 for( int i = 0; i < candidateCount; i++ )
108 {
109 prioritized[i] = nullptr;
110 dist[i] = VECTOR2I::ECOORD_MAX;
111 }
112
113 ITEM_SET candidates = m_router->QueryHoverItems( aWhere );
114
115 if( candidates.Empty() )
116 candidates = m_router->QueryHoverItems( aWhere, true );
117
118 for( ITEM* item : candidates.Items() )
119 {
120 if( !item->IsRoutable() )
121 continue;
122
123 if( !IsCopperLayer( item->Layers().Start() ) )
124 continue;
125
126 if( !m_iface->IsAnyLayerVisible( item->Layers() ) )
127 continue;
128
129 if( alg::contains( aAvoidItems, item ) )
130 continue;
131
132 // fixme: this causes flicker with live loop removal...
133 //if( item->Parent() && !item->Parent()->ViewIsVisible() )
134 // continue;
135
136 if( item->OfKind( ITEM::SOLID_T ) && aIgnorePads )
137 {
138 continue;
139 }
140 else if( aNet <= 0 || item->Net() == aNet )
141 {
142 if( item->OfKind( ITEM::VIA_T | ITEM::SOLID_T ) )
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->OfKind( ITEM::SOLID_T ) && item->IsFreePad() )
178 {
179 // Allow free pads only when already inside pad
180 if( item->Shape()->Collide( aWhere ) )
181 {
182 prioritized[0] = item;
183 dist[0] = 0;
184 }
185 }
186 else if ( item->Net() == 0 && m_router->Settings().Mode() == RM_MarkObstacles )
187 {
188 // Allow unconnected items as last resort in RM_MarkObstacles mode
189 if( item->Layers().Overlaps( tl ) )
190 prioritized[4] = item;
191 }
192 }
193
194 ITEM* rv = nullptr;
195
197
198 for( int i = 0; i < candidateCount; i++ )
199 {
200 ITEM* item = prioritized[i];
201
202 if( highContrast && item && !item->Layers().Overlaps( tl ) )
203 item = nullptr;
204
205 if( item && ( aLayer < 0 || item->Layers().Overlaps( aLayer ) ) )
206 {
207 rv = item;
208 break;
209 }
210 }
211
212 if( rv )
213 {
214 wxLogTrace( wxT( "PNS" ), wxT( "%s, layer : %d, tl: %d" ),
215 rv->KindStr().c_str(),
216 rv->Layers().Start(),
217 tl );
218 }
219
220 return rv;
221}
@ NORMAL
Inactive layers are shown normally (no high-contrast mode)
const PCB_DISPLAY_OPTIONS & GetDisplayOptions() const
Display options control the way tracks, vias, outlines and other things are shown (for instance solid...
HIGH_CONTRAST_MODE m_ContrastModeDisplay
How inactive layers are displayed.
const ITEM_SET QueryHoverItems(const VECTOR2I &aP, bool aUseClearance=false)
Definition: pns_router.cpp:120
bool IsAnyLayerVisible(const LAYER_RANGE &aLayer) const override
VECTOR2I::extended_type ecoord
Definition: seg.h:44
static constexpr extended_type ECOORD_MAX
Definition: vector2d.h:75
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:827
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99

References PNS::ITEM::Anchor(), alg::contains(), VECTOR2< int >::ECOORD_MAX, PNS::ITEM_SET::Empty(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetDisplayOptions(), 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 1179 of file router_tool.cpp.

1180{
1181 PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
1182 int routingLayer = getStartLayer( m_startItem );
1183
1184 if( !IsCopperLayer( routingLayer ) )
1185 {
1186 editFrame->ShowInfoBarError( _( "Tracks on Copper layers only." ) );
1187 return false;
1188 }
1189
1191 editFrame->SetActiveLayer( ToLAYER_ID( routingLayer ) );
1192
1193 if( !getView()->IsLayerVisible( routingLayer ) )
1194 {
1195 editFrame->GetAppearancePanel()->SetLayerVisible( routingLayer, true );
1196 editFrame->GetCanvas()->Refresh();
1197 }
1198
1200
1201 m_iface->SetStartLayer( routingLayer );
1202
1204 m_iface->ImportSizes( sizes, m_startItem, -1 );
1205 sizes.AddLayerPair( frame()->GetScreen()->m_Route_Layer_TOP,
1206 frame()->GetScreen()->m_Route_Layer_BOTTOM );
1207
1208 m_router->UpdateSizes( sizes );
1209
1210 if( m_startItem && m_startItem->Net() > 0 )
1211 {
1213 {
1214 if( int coupledNet = m_router->GetRuleResolver()->DpCoupledNet( m_startItem->Net() ) )
1215 highlightNets( true, { m_startItem->Net(), coupledNet } );
1216 }
1217 else
1218 {
1219 highlightNets( true, { m_startItem->Net() } );
1220 }
1221 }
1222
1223 controls()->SetAutoPan( true );
1224
1225 if( !m_router->StartRouting( m_startSnapPoint, m_startItem, routingLayer ) )
1226 {
1227 // It would make more sense to leave the net highlighted as the higher-contrast mode
1228 // makes the router clearances more visible. However, since we just started routing
1229 // the conversion of the screen from low contrast to high contrast is a bit jarring and
1230 // makes the infobar coming up less noticeable.
1231 highlightNets( false );
1232
1234 [&]()
1235 {
1236 m_router->ClearViewDecorations();
1237 } );
1238
1239 controls()->SetAutoPan( false );
1240 return false;
1241 }
1242
1243 m_endItem = nullptr;
1245
1247 frame()->UndoRedoBlock( true );
1248
1249 return true;
1250}
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...
const wxString & FailureReason() const
Definition: pns_router.h:211
RULE_RESOLVER * GetRuleResolver() const
Definition: pns_router.h:177
bool StartRouting(const VECTOR2I &aP, ITEM *aItem, int aLayer)
Definition: pns_router.cpp:392
virtual int DpCoupledNet(int aNet)=0
void SetStartLayer(int aLayer)
int getStartLayer(const PNS::ITEM *aItem)

References _, PNS::SIZES_SETTINGS::AddLayerPair(), PCB_TOOL_BASE::controls(), PNS::RULE_RESOLVER::DpCoupledNet(), PNS::ROUTER::FailureReason(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_EDIT_FRAME::GetAppearancePanel(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), BOARD::GetDesignSettings(), PNS::ROUTER::GetRuleResolver(), getStartLayer(), TOOL_BASE::getView(), PNS::TOOL_BASE::highlightNets(), PNS_KICAD_IFACE_BASE::ImportSizes(), IsCopperLayer(), PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_iface, m_originalActiveLayer, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, BOARD_DESIGN_SETTINGS::m_TempOverrideTrackWidth, PNS::ROUTER::Mode(), PNS::ITEM::Net(), PNS::PNS_MODE_ROUTE_DIFF_PAIR, 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 538 of file router_tool.cpp.

539{
541
542 if( aReason == RUN )
543 TOOL_BASE::Reset( aReason );
544}
virtual void Reset(RESET_REASON aReason)=0
Bring the tool to a known, initial state.

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

◆ resetTransitions()

void TOOL_INTERACTIVE::resetTransitions ( )
privateinherited

Clear the current transition map and restores the default one created by setTransitions().

Definition at line 63 of file tool_interactive.cpp.

64{
67}
virtual void setTransitions()=0
This method is meant to be overridden in order to specify handlers for events.
void ClearTransitions(TOOL_BASE *aTool)
Clear the state transition map for a tool.

References TOOL_MANAGER::ClearTransitions(), TOOL_BASE::m_toolMgr, and TOOL_INTERACTIVE::setTransitions().

◆ Router()

ROUTER * TOOL_BASE::Router ( ) const
inherited

◆ RouteSelected()

int ROUTER_TOOL::RouteSelected ( const TOOL_EVENT aEvent)

Definition at line 1543 of file router_tool.cpp.

1544{
1546 PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
1548 PCB_LAYER_ID originalLayer = frame->GetActiveLayer();
1549 bool autoRoute = aEvent.Matches( PCB_ACTIONS::routerAutorouteSelected.MakeEvent() );
1550 bool otherEnd = aEvent.Matches( PCB_ACTIONS::routerRouteSelectedFromEnd.MakeEvent() );
1551
1553 return 0;
1554
1555 // Save selection then clear it for interactive routing
1557
1558 if( selection.Size() == 0 )
1559 return 0;
1560
1562
1563 frame->PushTool( aEvent );
1564
1565 auto setCursor =
1566 [&]()
1567 {
1569 };
1570
1571 Activate();
1572 // Must be done after Activate() so that it gets set into the correct context
1573 controls->ShowCursor( true );
1574 controls->ForceCursorPosition( false );
1575 // Set initial cursor
1576 setCursor();
1577
1578 // Get all connected board items, adding pads for any footprints selected
1579 std::vector<BOARD_CONNECTED_ITEM*> itemList;
1580
1582 {
1583 if( item->Type() == PCB_FOOTPRINT_T )
1584 {
1585 const PADS& fpPads = ( static_cast<FOOTPRINT*>( item ) )->Pads();
1586
1587 for( PAD* pad : fpPads )
1588 itemList.push_back( pad );
1589 }
1590 else if( dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) != nullptr )
1591 {
1592 itemList.push_back( static_cast<BOARD_CONNECTED_ITEM*>( item ) );
1593 }
1594 }
1595
1596 std::shared_ptr<CONNECTIVITY_DATA> connectivity = frame->GetBoard()->GetConnectivity();
1597
1598 // For putting sequential tracks that successfully autoroute into one undo commit
1599 bool groupStart = true;
1600
1601 for( BOARD_CONNECTED_ITEM* item : itemList )
1602 {
1603 // This code is similar to GetRatsnestForPad() but it only adds the anchor for
1604 // the side of the connectivity on this pad. It also checks for ratsnest points
1605 // inside the pad (like a trace end) and counts them.
1606 RN_NET* net = connectivity->GetRatsnestForNet( item->GetNetCode() );
1607 std::vector<std::shared_ptr<const CN_ANCHOR>> anchors;
1608
1609 for( const CN_EDGE& edge : net->GetEdges() )
1610 {
1611 std::shared_ptr<const CN_ANCHOR> target = edge.GetTargetNode();
1612 std::shared_ptr<const CN_ANCHOR> source = edge.GetSourceNode();
1613
1614 if( source->Parent() == item )
1615 anchors.push_back( edge.GetSourceNode() );
1616 else if( target->Parent() == item )
1617 anchors.push_back( edge.GetTargetNode() );
1618 }
1619
1620 // Route them
1621 for( std::shared_ptr<const CN_ANCHOR> anchor : anchors )
1622 {
1623 // Try to return to the original layer as indicating the user's preferred
1624 // layer for autorouting tracks. The layer can be changed by the user to
1625 // finish tracks that can't complete automatically, but should be changed
1626 // back after.
1627 if( frame->GetActiveLayer() != originalLayer )
1628 frame->SetActiveLayer( originalLayer );
1629
1630 VECTOR2I ignore;
1632 m_startSnapPoint = anchor->Pos();
1633 m_router->SetMode( mode );
1634
1635 // Prime the interactive routing to attempt finish if we are autorouting
1636 bool autoRouted = false;
1637
1638 if( autoRoute )
1640 else if( otherEnd )
1642
1643 // We want autorouted tracks to all be in one undo group except for
1644 // any tracks that need to be manually finished.
1645 // The undo appending for manually finished tracks is handled in peformRouting()
1646 if( groupStart )
1647 groupStart = false;
1648 else
1650
1651 // Start interactive routing. Will automatically finish if possible.
1653
1654 // Route didn't complete automatically, need to a new undo commit
1655 // for the next line so those can group as far as they autoroute
1656 if( !autoRouted )
1657 groupStart = true;
1658 }
1659 }
1660
1661 m_iface->SetCommitFlags( 0 );
1662 frame->PopTool( aEvent );
1663 return 0;
1664}
CN_EDGE represents a point-to-point connection, whether realized or unrealized (ie: tracks etc.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
static TOOL_ACTION routerRouteSelectedFromEnd
Definition: pcb_actions.h:227
static TOOL_ACTION routerAutorouteSelected
Definition: pcb_actions.h:228
const std::vector< EDA_ITEM * > GetItemsSortedBySelectionOrder() const
Definition: selection.cpp:201
bool Matches(const TOOL_EVENT &aEvent) const
Test whether two events match in terms of category & action or command.
Definition: tool_event.h:365

References TOOL_INTERACTIVE::Activate(), anchor, APPEND_UNDO, PCB_TOOL_BASE::controls(), PNS::NODE::FindItemByParent(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_FRAME::GetBoard(), PCB_BASE_FRAME::GetCanvas(), BOARD::GetConnectivity(), RN_NET::GetEdges(), SELECTION::GetItemsSortedBySelectionOrder(), TOOL_MANAGER::GetTool(), TOOL_BASE::getViewControls(), PNS::ROUTER::GetWorld(), PNS::TOOL_BASE::m_iface, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, TOOL_BASE::m_toolMgr, TOOL_EVENT::Matches(), pad, TOOL_EVENT::Parameter(), PCB_FOOTPRINT_T, PENCIL, performRouting(), TOOLS_HOLDER::PopTool(), TOOLS_HOLDER::PushTool(), PCB_ACTIONS::routerAttemptFinish, PCB_ACTIONS::routerAutorouteSelected, PCB_ACTIONS::routerContinueFromEnd, PCB_ACTIONS::routerRouteSelectedFromEnd, PNS::ROUTER::RoutingInProgress(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_BASE_FRAME::SetActiveLayer(), PNS_KICAD_IFACE::SetCommitFlags(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), PNS::ROUTER::SetMode(), KIGFX::VIEW_CONTROLS::ShowCursor(), and SELECTION::Size().

Referenced by setTransitions().

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

1531{
1532 return m_router->RoutingInProgress();
1533}

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

Referenced by EDIT_TOOL::isRouterActive(), and 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}
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 549 of file router_tool.cpp.

550{
551 auto logger = m_router->Logger();
552
553 if( ! logger )
554 return;
555
556 wxString cwd = wxGetCwd();
557
558 wxFileName fname_log;
559 fname_log.SetPath( cwd );
560 fname_log.SetName( "pns.log" );
561
562 wxFileName fname_dump( cwd );
563 fname_dump.SetPath( cwd );
564 fname_dump.SetName( "pns.dump" );
565
566 wxFileName fname_settings( cwd );
567 fname_settings.SetPath( cwd );
568 fname_settings.SetName( "pns.settings" );
569
570 wxString msg = wxString::Format( _( "Event file: %s\nBoard dump: %s" ), fname_log.GetFullPath(), fname_log.GetFullPath() );
571
572 int rv = OKOrCancelDialog( nullptr, _("Save router log"), _("Would you like to save the router\nevent log for debugging purposes?"), msg, _("OK"), _("Cancel") );
573
574 if( !rv )
575 return;
576
577 FILE *f = fopen( fname_settings.GetFullPath().c_str(), "wb" );
578 std::string settingsStr = m_router->Settings().FormatAsString();
579 fprintf(f,"%s\n", settingsStr.c_str( ) );
580 fclose(f);
581
582 f = fopen( fname_log.GetFullPath().c_str(), "wb" );
583
584 fprintf(f, "mode %d\n", m_router->Mode() );
585
586 const auto& events = logger->GetEvents();
587
588 for( const auto& evt : events)
589 {
590 fprintf( f, "event %d %d %d %s %d %d %d %d %d %d %d\n", evt.p.x, evt.p.y, evt.type,
591 static_cast<const char*>( evt.uuid.AsString().c_str() ),
592 evt.sizes.TrackWidth(),
593 evt.sizes.ViaDiameter(),
594 evt.sizes.ViaDrill(),
595 evt.sizes.TrackWidthIsExplicit() ? 1: 0,
596 evt.sizes.GetLayerBottom(),
597 evt.sizes.GetLayerTop(),
598 static_cast<int>( evt.sizes.ViaType() ) );
599 }
600
601 // Export as *.kicad_pcb format, using a strategy which is specifically chosen
602 // as an example on how it could also be used to send it to the system clipboard.
603
604 PCB_PLUGIN pcb_io;
605
606 pcb_io.Save( fname_dump.GetFullPath(), m_iface->GetBoard(), nullptr );
607
608 PROJECT* prj = m_iface->GetBoard()->GetProject();
609 prj->GetProjectFile().SaveAs( cwd, "pns" );
610
611 std::vector<PNS::ITEM*> added, removed, heads;
612 m_router->GetUpdatedItems( removed, added, heads );
613
614 for( auto item : removed )
615 {
616 fprintf(f, "removed %s\n", item->Parent()->m_Uuid.AsString().c_str().AsChar() );
617 }
618
619 for( auto item : added )
620 {
621 fprintf(f, "added %s\n", item->Format().c_str() );
622 }
623
624 for( auto item : heads )
625 {
626 fprintf(f, "head %s\n", item->Format().c_str() );
627 }
628
629 fclose( f );
630}
PROJECT * GetProject() const
Definition: board.h:446
const std::string FormatAsString() const
A PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
Definition: pcb_plugin.h:261
void Save(const wxString &aFileName, BOARD *aBoard, const STRING_UTF8_MAP *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:271
LOGGER * Logger()
void GetUpdatedItems(std::vector< PNS::ITEM * > &aRemoved, std::vector< PNS::ITEM * > &aAdded, std::vector< PNS::ITEM * > &aHeads)
Definition: pns_router.cpp:778
BOARD * GetBoard() const
bool SaveAs(const wxString &aDirectory, const wxString &aFile)
Container for project specific data.
Definition: project.h:64
virtual PROJECT_FILE & GetProjectFile() const
Definition: project.h:149
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:273
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

References _, Format(), JSON_SETTINGS::FormatAsString(), PNS_KICAD_IFACE_BASE::GetBoard(), BOARD::GetProject(), PROJECT::GetProjectFile(), PNS::ROUTER::GetUpdatedItems(), PNS::ROUTER::Logger(), PNS::TOOL_BASE::m_iface, PNS::TOOL_BASE::m_router, PNS::ROUTER::Mode(), OKOrCancelDialog(), PCB_PLUGIN::Save(), PROJECT_FILE::SaveAs(), 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}
Display a pair PCB copper layers list in a dialog to select a layer pair from these lists.
Definition: sel_layer.cpp:299
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:352
#define _(s)
BOARD * GetBoard()

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]

PCB_SELECTION & PCB_TOOL_BASE::selection ( )
protectedinherited

Definition at line 324 of file pcb_tool_base.cpp.

325{
327
328 return selTool->GetSelection();
329}
PCB_SELECTION & GetSelection()

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

◆ selection() [2/2]

const PCB_SELECTION & PCB_TOOL_BASE::selection ( ) const
protectedinherited

Definition at line 316 of file pcb_tool_base.cpp.

317{
319
320 return selTool->GetSelection();
321}

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

Referenced by BOARD_EDITOR_CONTROL::AssignNetclass(), AUTOPLACE_TOOL::autoplaceSelected(), BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), CanInlineDrag(), EDIT_TOOL::ChangeTrackWidth(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), DRC_TOOL::CrossProbe(), BOARD_EDITOR_CONTROL::doCrossProbePcbToSch(), BOARD_INSPECTION_TOOL::doHideRatsnestNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::Drag(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawShape(), 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::FilletLines(), EDIT_TOOL::FilletTracks(), 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(), LENGTH_TUNER_TOOL::MainLoop(), MainLoop(), EDIT_TOOL::Mirror(), BOARD_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), PCB_POINT_EDITOR::OnSelectionChange(), EDIT_TOOL::PackAndMoveFootprints(), PAD_TOOL::pastePadProperties(), performDragging(), performRouting(), LENGTH_TUNER_TOOL::performTuning(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), DRAWING_TOOL::PlaceImportedGraphics(), 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(), RouteSelected(), DRAWING_TOOL::SetAnchor(), EDIT_TOOL::Swap(), BOARD_EDITOR_CONTROL::TrackWidthDec(), BOARD_EDITOR_CONTROL::TrackWidthInc(), GROUP_TOOL::Ungroup(), BOARD_INSPECTION_TOOL::UpdateLocalRatsnest(), PCB_CONTROL::UpdateMessagePanel(), 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().

◆ 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}
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.
@ CMENU_OFF
Definition: tool_event.h:149

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

Referenced by SELECTION_TOOL::doSelectionMenu(), TOOL_MENU::ShowContextMenu(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ SetIsBoardEditor()

void PCB_TOOL_BASE::SetIsBoardEditor ( bool  aEnabled)
inlineinherited

Definition at line 108 of file pcb_tool_base.h.

108{ m_isBoardEditor = aEnabled; }

References PCB_TOOL_BASE::m_isBoardEditor.

◆ 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 105 of file pcb_tool_base.h.

105{ m_isFootprintEditor = aEnabled; }

References PCB_TOOL_BASE::m_isFootprintEditor.

◆ SettingsDialog()

int ROUTER_TOOL::SettingsDialog ( const TOOL_EVENT aEvent)

Definition at line 1483 of file router_tool.cpp.

1484{
1485 DIALOG_PNS_SETTINGS settingsDlg( frame(), m_router->Settings() );
1486
1487 settingsDlg.ShowModal();
1488
1490
1491 return 0;
1492}

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

2585{
2587
2601
2608
2643
2646}
static TOOL_ACTION layerInner12
Definition: pcb_actions.h:302
static TOOL_ACTION layerInner8
Definition: pcb_actions.h:298
static TOOL_ACTION layerInner3
Definition: pcb_actions.h:293
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:292
static TOOL_ACTION layerInner25
Definition: pcb_actions.h:315
static TOOL_ACTION routerHighlightMode
Actions to enable switching modes via hotkey assignments.
Definition: pcb_actions.h:236
static TOOL_ACTION routerWalkaroundMode
Definition: pcb_actions.h:238
static TOOL_ACTION routerShoveMode
Definition: pcb_actions.h:237
static TOOL_ACTION layerInner24
Definition: pcb_actions.h:314
static TOOL_ACTION layerInner29
Definition: pcb_actions.h:319
static TOOL_ACTION layerInner11
Definition: pcb_actions.h:301
static TOOL_ACTION routerDiffPairDialog
Definition: pcb_actions.h:232
static TOOL_ACTION layerInner16
Definition: pcb_actions.h:306
static TOOL_ACTION layerInner26
Definition: pcb_actions.h:316
static TOOL_ACTION layerInner18
Definition: pcb_actions.h:308
static TOOL_ACTION layerInner14
Definition: pcb_actions.h:304
static TOOL_ACTION selectLayerPair
Definition: pcb_actions.h:161
static TOOL_ACTION layerInner6
Definition: pcb_actions.h:296
static TOOL_ACTION layerInner22
Definition: pcb_actions.h:312
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:295
static TOOL_ACTION layerInner20
Definition: pcb_actions.h:310
static TOOL_ACTION layerInner7
Definition: pcb_actions.h:297
static TOOL_ACTION layerInner27
Definition: pcb_actions.h:317
static TOOL_ACTION layerInner1
Definition: pcb_actions.h:291
static TOOL_ACTION layerInner10
Definition: pcb_actions.h:300
static TOOL_ACTION layerInner15
Definition: pcb_actions.h:305
static TOOL_ACTION layerInner17
Definition: pcb_actions.h:307
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:321
static TOOL_ACTION layerInner19
Definition: pcb_actions.h:309
static TOOL_ACTION layerInner9
Definition: pcb_actions.h:299
static TOOL_ACTION layerInner30
Definition: pcb_actions.h:320
static TOOL_ACTION layerTop
Definition: pcb_actions.h:290
static TOOL_ACTION cycleRouterMode
Definition: pcb_actions.h:239
static TOOL_ACTION layerInner4
Definition: pcb_actions.h:294
static TOOL_ACTION layerInner13
Definition: pcb_actions.h:303
static TOOL_ACTION layerInner21
Definition: pcb_actions.h:311
static TOOL_ACTION routerRouteSelected
Definition: pcb_actions.h:226
static TOOL_ACTION layerInner23
Definition: pcb_actions.h:313
static TOOL_ACTION layerInner28
Definition: pcb_actions.h:318
int onViaCommand(const TOOL_EVENT &aEvent)
int InlineDrag(const TOOL_EVENT &aEvent)
int CustomTrackWidthDialog(const TOOL_EVENT &aEvent)
int onLayerCommand(const TOOL_EVENT &aEvent)
int CycleRouterMode(const TOOL_EVENT &aEvent)
int RouteSelected(const TOOL_EVENT &aEvent)
int ChangeRouterMode(const TOOL_EVENT &aEvent)
int InlineBreakTrack(const TOOL_EVENT &aEvent)
int MainLoop(const TOOL_EVENT &aEvent)
int SettingsDialog(const TOOL_EVENT &aEvent)
int DpDimensionsDialog(const TOOL_EVENT &aEvent)
int SelectCopperLayerPair(const TOOL_EVENT &aEvent)
Definition: sel_layer.cpp:326
TOOL_EVENT MakeEvent() const
Return the event associated with the action (i.e.
Definition: tool_action.cpp:72
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).

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::routerAutorouteSelected, PCB_ACTIONS::routerDiffPairDialog, PCB_ACTIONS::routerHighlightMode, PCB_ACTIONS::routerInlineDrag, PCB_ACTIONS::routerRouteSelected, PCB_ACTIONS::routerRouteSelectedFromEnd, PCB_ACTIONS::routerSettingsDialog, PCB_ACTIONS::routerShoveMode, PCB_ACTIONS::routerWalkaroundMode, RouteSelected(), 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 403 of file pns_tool_base.cpp.

404{
405 if( !aItem || !m_iface->IsItemVisible( aItem ) )
406 {
407 return m_gridHelper->Align( aP );
408 }
409
410 switch( aItem->Kind() )
411 {
412 case ITEM::SOLID_T:
413 return static_cast<SOLID*>( aItem )->Pos();
414
415 case ITEM::VIA_T:
416 return static_cast<VIA*>( aItem )->Pos();
417
418 case ITEM::SEGMENT_T:
419 case ITEM::ARC_T:
420 {
421 LINKED_ITEM* li = static_cast<LINKED_ITEM*>( aItem );
422 VECTOR2I A = li->Anchor( 0 );
423 VECTOR2I B = li->Anchor( 1 );
424 SEG::ecoord w_sq = SEG::Square( li->Width() / 2 );
425 SEG::ecoord distA_sq = ( aP - A ).SquaredEuclideanNorm();
426 SEG::ecoord distB_sq = ( aP - B ).SquaredEuclideanNorm();
427
428 if( distA_sq < w_sq || distB_sq < w_sq )
429 {
430 return ( distA_sq < distB_sq ) ? A : B;
431 }
432 else if( aItem->Kind() == ITEM::SEGMENT_T )
433 {
434 // TODO(snh): Clean this up
435 SEGMENT* seg = static_cast<SEGMENT*>( li );
436 return m_gridHelper->AlignToSegment( aP, seg->Seg() );
437 }
438 else if( aItem->Kind() == ITEM::ARC_T )
439 {
440 ARC* arc = static_cast<ARC*>( li );
441 return m_gridHelper->AlignToArc( aP, *static_cast<const SHAPE_ARC*>( arc->Shape() ) );
442 }
443
444 break;
445 }
446
447 default:
448 break;
449 }
450
451 return m_gridHelper->Align( aP );
452}
virtual VECTOR2I Align(const VECTOR2I &aPoint) const
VECTOR2I AlignToArc(const VECTOR2I &aPoint, const SHAPE_ARC &aSeg)
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)
bool IsItemVisible(const PNS::ITEM *aItem) const override
static SEG::ecoord Square(int a)
Definition: seg.h:123
@ VIA
Normal via.
Definition: router_tool.cpp:90

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

679{
680 int activeLayer = frame()->GetActiveLayer();
681 int currentLayer = m_router->GetCurrentLayer();
682
683 if( currentLayer != activeLayer )
684 m_router->SwitchLayer( activeLayer );
685
686 std::optional<int> newLayer = m_router->Sizes().PairedLayer( currentLayer );
687
688 if( !newLayer )
689 newLayer = m_router->Sizes().GetLayerTop();
690
691 m_router->SwitchLayer( *newLayer );
692 m_lastTargetLayer = *newLayer;
693
695}
std::optional< int > PairedLayer(int aLayerId)

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(), PNS::ROUTER::SwitchLayer(), ToLAYER_ID(), and updateSizesAfterLayerSwitch().

Referenced by performRouting().

◆ updateEndItem()

void TOOL_BASE::updateEndItem ( const TOOL_EVENT aEvent)
protectedvirtualinherited

Definition at line 328 of file pns_tool_base.cpp.

329{
330 int layer;
331 GAL* gal = m_toolMgr->GetView()->GetGAL();
332
334 m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
335
336 controls()->ForceCursorPosition( false );
337
338 VECTOR2I mousePos = controls()->GetMousePosition();
339
340 if( m_router->GetState() == ROUTER::ROUTE_TRACK && aEvent.IsDrag() )
341 {
342 // If the user is moving the mouse quickly while routing then clicks will come in as
343 // short drags. In this case we want to use the drag origin rather than the current
344 // mouse position.
345 mousePos = aEvent.DragOrigin();
346 }
347
349 ( m_router->GetCurrentNets().empty() || m_router->GetCurrentNets().front() < 0 ) )
350 {
351 m_endSnapPoint = snapToItem( nullptr, mousePos );
353 m_endItem = nullptr;
354
355 return;
356 }
357
358 if( m_router->IsPlacingVia() )
359 layer = -1;
360 else
361 layer = m_router->GetCurrentLayer();
362
363 ITEM* endItem = nullptr;
364
365 std::vector<int> nets = m_router->GetCurrentNets();
366
367 for( int net : nets )
368 {
369 endItem = pickSingleItem( mousePos, net, layer, false, { m_startItem } );
370
371 if( endItem )
372 break;
373 }
374
375 if( m_gridHelper->GetSnap() && checkSnap( endItem ) )
376 {
377 m_endItem = endItem;
378 m_endSnapPoint = snapToItem( endItem, mousePos );
379 }
380 else
381 {
382 m_endItem = nullptr;
383 m_endSnapPoint = m_gridHelper->Align( mousePos );
384 }
385
387
388 if( m_endItem )
389 {
390 wxLogTrace( wxT( "PNS" ), wxT( "%s, layer : %d" ),
391 m_endItem->KindStr().c_str(),
392 m_endItem->Layers().Start() );
393 }
394}
bool GetSnap() const
Definition: grid_helper.h:66
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
std::string KindStr() const
Returns the kind of the item, as string.
Definition: pns_item.cpp:198
bool checkSnap(ITEM *aItem)
virtual ITEM * pickSingleItem(const VECTOR2I &aWhere, int aNet=-1, int aLayer=-1, bool aIgnorePads=false, const std::vector< ITEM * > aAvoidItems={})
bool IsDrag(int aButtonMask=BUT_ANY) const
Definition: tool_event.h:288
const VECTOR2D DragOrigin() const
Returns information about mouse buttons state.
Definition: tool_event.h:272

References GRID_HELPER::Align(), PNS::TOOL_BASE::checkSnap(), PCB_TOOL_BASE::controls(), TOOL_EVENT::DisableGridSnapping(), TOOL_EVENT::DragOrigin(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PNS::ROUTER::GetCurrentLayer(), PNS::ROUTER::GetCurrentNets(), KIGFX::VIEW::GetGAL(), KIGFX::GAL::GetGridSnapping(), KIGFX::VIEW_CONTROLS::GetMousePosition(), GRID_HELPER::GetSnap(), PNS::ROUTER::GetState(), TOOL_MANAGER::GetView(), TOOL_EVENT::IsDrag(), 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, PNS::ROUTER::ROUTE_TRACK, GRID_HELPER::SetSnap(), PNS::ROUTER::Settings(), GRID_HELPER::SetUseGrid(), PNS::TOOL_BASE::snapToItem(), and LAYER_RANGE::Start().

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

◆ UpdateMessagePanel()

void ROUTER_TOOL::UpdateMessagePanel ( )

Definition at line 2465 of file router_tool.cpp.

2466{
2467 std::vector<MSG_PANEL_ITEM> items;
2468
2470 {
2473 std::vector<int> nets = m_router->GetCurrentNets();
2474 wxString description;
2475 wxString secondary;
2476
2478 {
2479 wxASSERT( nets.size() >= 2 );
2480
2481 NETINFO_ITEM* netA = board()->FindNet( nets[0] );
2482 NETINFO_ITEM* netB = board()->FindNet( nets[1] );
2483 wxASSERT( netA );
2484 wxASSERT( netB );
2485
2486 description = wxString::Format( _( "Routing Diff Pair: %s" ),
2487 netA->GetNetname() + wxT( ", " ) + netB->GetNetname() );
2488
2489 wxString netclass;
2490 NETCLASS* netclassA = netA->GetNetClass();
2491 NETCLASS* netclassB = netB->GetNetClass();
2492
2493 if( netclassA == netclassB )
2494 netclass = netclassA->GetName();
2495 else
2496 netclass = netclassA->GetName() + wxT( ", " ) + netclassB->GetName();
2497
2498 secondary = wxString::Format( _( "Resolved Netclass: %s" ),
2499 UnescapeString( netclass ) );
2500 }
2501 else if( !nets.empty() )
2502 {
2503 NETINFO_ITEM* net = board()->FindNet( nets[0] );
2504 wxASSERT( net );
2505
2506 description = wxString::Format( _( "Routing Track: %s" ),
2507 net->GetNetname() );
2508
2509 secondary = wxString::Format( _( "Resolved Netclass: %s" ),
2510 UnescapeString( net->GetNetClass()->GetName() ) );
2511 }
2512 else
2513 {
2514 description = _( "Routing Track" );
2515 secondary = _( "(no net)" );
2516 }
2517
2518 items.emplace_back( description, secondary );
2519
2520 wxString cornerMode;
2521
2523 {
2524 cornerMode = _( "Free-angle" );
2525 }
2526 else
2527 {
2528 switch( m_router->Settings().GetCornerMode() )
2529 {
2530 case DIRECTION_45::CORNER_MODE::MITERED_45: cornerMode = _( "45-degree" ); break;
2531 case DIRECTION_45::CORNER_MODE::ROUNDED_45: cornerMode = _( "45-degree rounded" ); break;
2532 case DIRECTION_45::CORNER_MODE::MITERED_90: cornerMode = _( "90-degree" ); break;
2533 case DIRECTION_45::CORNER_MODE::ROUNDED_90: cornerMode = _( "90-degree rounded" ); break;
2534 default: break;
2535 }
2536 }
2537
2538 items.emplace_back( _( "Corner Style" ), cornerMode );
2539
2540#define FORMAT_VALUE( x ) frame()->MessageTextFromValue( x )
2541
2543 {
2544 items.emplace_back( wxString::Format( _( "Track Width: %s" ),
2545 FORMAT_VALUE( sizes.DiffPairWidth() ) ),
2546 wxString::Format( _( "(from %s)" ),
2547 sizes.GetDiffPairWidthSource() ) );
2548
2549 items.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
2550 FORMAT_VALUE( sizes.Clearance() ) ),
2551 wxString::Format( _( "(from %s)" ),
2552 sizes.GetClearanceSource() ) );
2553
2554 items.emplace_back( wxString::Format( _( "Diff Pair Gap: %s" ),
2555 FORMAT_VALUE( sizes.DiffPairGap() ) ),
2556 wxString::Format( _( "(from %s)" ),
2557 sizes.GetDiffPairGapSource() ) );
2558 }
2559 else
2560 {
2561 items.emplace_back( wxString::Format( _( "Track Width: %s" ),
2562 FORMAT_VALUE( sizes.TrackWidth() ) ),
2563 wxString::Format( _( "(from %s)" ),
2564 sizes.GetWidthSource() ) );
2565
2566 items.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
2567 FORMAT_VALUE( sizes.Clearance() ) ),
2568 wxString::Format( _( "(from %s)" ),
2569 sizes.GetClearanceSource() ) );
2570 }
2571
2572#undef FORMAT_VALUE
2573
2574 frame()->SetMsgPanel( items );
2575 }
2576 else
2577 {
2578 frame()->SetMsgPanel( board() );
2579 return;
2580 }
2581}
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1478
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
A collection of nets and the parameters used to route or test these nets.
Definition: netclass.h:47
const wxString GetName() const
Definition: netclass.h:65
Handle the data for a net.
Definition: netinfo.h:67
const wxString & GetNetname() const
Definition: netinfo.h:125
NETCLASS * GetNetClass()
Definition: netinfo.h:112
DIRECTION_45::CORNER_MODE GetCornerMode() const
PNS::RULE_RESOLVER * GetRuleResolver() override
static FILENAME_RESOLVER * resolver
Definition: export_idf.cpp:52
#define FORMAT_VALUE(x)
wxString UnescapeString(const wxString &aSource)

References _, PCB_TOOL_BASE::board(), PNS::SIZES_SETTINGS::Clearance(), PNS::SIZES_SETTINGS::DiffPairGap(), PNS::SIZES_SETTINGS::DiffPairWidth(), BOARD::FindNet(), Format(), FORMAT_VALUE, PCB_TOOL_BASE::frame(), PNS::SIZES_SETTINGS::GetClearanceSource(), PNS::ROUTING_SETTINGS::GetCornerMode(), PNS::ROUTER::GetCurrentNets(), PNS::SIZES_SETTINGS::GetDiffPairGapSource(), PNS::SIZES_SETTINGS::GetDiffPairWidthSource(), PNS::ROUTING_SETTINGS::GetFreeAngleMode(), NETCLASS::GetName(), NETINFO_ITEM::GetNetClass(), NETINFO_ITEM::GetNetname(), PNS_KICAD_IFACE_BASE::GetRuleResolver(), PNS::ROUTER::GetState(), PNS::SIZES_SETTINGS::GetWidthSource(), PNS::TOOL_BASE::m_iface, PNS::TOOL_BASE::m_router, PNS::ROUTER::Mode(), PNS::PNS_MODE_ROUTE_DIFF_PAIR, resolver, PNS::ROUTER::ROUTE_TRACK, EDA_DRAW_FRAME::SetMsgPanel(), PNS::ROUTER::Settings(), PNS::ROUTER::Sizes(), PNS::SIZES_SETTINGS::TrackWidth(), and UnescapeString().

Referenced by finishInteractive(), onTrackViaSizeChanged(), performRouting(), prepareInteractive(), and SettingsDialog().

◆ updateSizesAfterLayerSwitch()

void ROUTER_TOOL::updateSizesAfterLayerSwitch ( PCB_LAYER_ID  targetLayer)
private

Definition at line 698 of file router_tool.cpp.

699{
700 std::vector<int> nets = m_router->GetCurrentNets();
701
704 std::shared_ptr<DRC_ENGINE>& drcEngine = bds.m_DRCEngine;
705 DRC_CONSTRAINT constraint;
706
707 PCB_TRACK dummyTrack( board() );
708 dummyTrack.SetLayer( targetLayer );
709 dummyTrack.SetNetCode( nets.empty() ? 0 : nets[0] );
710
711 if( bds.UseNetClassTrack() || !sizes.TrackWidthIsExplicit() )
712 {
713 constraint = drcEngine->EvalRules( TRACK_WIDTH_CONSTRAINT, &dummyTrack, nullptr,
714 targetLayer );
715
716 if( !constraint.IsNull() )
717 {
718 int width = sizes.TrackWidth();
719
720 // Only change the size if we're explicitly using the net class, or we're out of range
721 // for our new constraints. Otherwise, just leave the track width alone so we don't
722 // change for no reason.
723 if( bds.UseNetClassTrack()
724 || ( width < bds.m_TrackMinWidth )
725 || ( width < constraint.m_Value.Min() )
726 || ( width > constraint.m_Value.Max() ) )
727 {
728 sizes.SetTrackWidth( std::max( bds.m_TrackMinWidth, constraint.m_Value.Opt() ) );
729 }
730
731 if( sizes.TrackWidth() == constraint.m_Value.Opt() )
732 sizes.SetWidthSource( constraint.GetName() );
733 else if( sizes.TrackWidth() == bds.m_TrackMinWidth )
734 sizes.SetWidthSource( _( "board minimum track width" ) );
735 else
736 sizes.SetWidthSource( _( "existing track" ) );
737 }
738 }
739
740 if( nets.size() >= 2 && ( bds.UseNetClassDiffPair() || !sizes.TrackWidthIsExplicit() ) )
741 {
742 PCB_TRACK dummyTrackB( board() );
743 dummyTrackB.SetLayer( targetLayer );
744 dummyTrackB.SetNetCode( nets[1] );
745
746 constraint = drcEngine->EvalRules( TRACK_WIDTH_CONSTRAINT, &dummyTrack, &dummyTrackB,
747 targetLayer );
748
749 if( !constraint.IsNull() )
750 {
751 sizes.SetDiffPairWidth( std::max( bds.m_TrackMinWidth, constraint.m_Value.Opt() ) );
752
753 if( sizes.DiffPairWidth() == constraint.m_Value.Opt() )
754 sizes.SetDiffPairWidthSource( constraint.GetName() );
755 else
756 sizes.SetDiffPairWidthSource( _( "board minimum track width" ) );
757 }
758
759 constraint = drcEngine->EvalRules( DIFF_PAIR_GAP_CONSTRAINT, &dummyTrack, &dummyTrackB,
760 targetLayer );
761
762 if( !constraint.IsNull() )
763 {
764 sizes.SetDiffPairGap( std::max( bds.m_MinClearance, constraint.m_Value.Opt() ) );
765
766 if( sizes.DiffPairGap() == constraint.m_Value.Opt() )
767 sizes.SetDiffPairGapSource( constraint.GetName() );
768 else
769 sizes.SetDiffPairGapSource( _( "board minimum clearance" ) );
770 }
771 }
772
773 m_router->UpdateSizes( sizes );
774}
bool UseNetClassTrack() const
Return true if netclass values should be used to obtain appropriate track width.
bool UseNetClassDiffPair() const
Return true if netclass values should be used to obtain appropriate diff pair dimensions.
wxString GetName() const
Definition: drc_rule.h:149
T Min() const
Definition: minoptmax.h:33
T Max() const
Definition: minoptmax.h:34
void SetTrackWidth(int aWidth)
void SetDiffPairWidth(int aWidth)
void SetDiffPairWidthSource(const wxString &aSource)
void SetDiffPairGapSource(const wxString &aSource)
void SetDiffPairGap(int aGap)
bool TrackWidthIsExplicit() const
void SetWidthSource(const wxString &aSource)
@ DIFF_PAIR_GAP_CONSTRAINT
Definition: drc_rule.h:66
@ TRACK_WIDTH_CONSTRAINT
Definition: drc_rule.h:56

References _, PCB_TOOL_BASE::board(), DIFF_PAIR_GAP_CONSTRAINT, PNS::SIZES_SETTINGS::DiffPairGap(), PNS::SIZES_SETTINGS::DiffPairWidth(), PNS::ROUTER::GetCurrentNets(), BOARD::GetDesignSettings(), DRC_CONSTRAINT::GetName(), DRC_CONSTRAINT::IsNull(), BOARD_DESIGN_SETTINGS::m_DRCEngine, BOARD_DESIGN_SETTINGS::m_MinClearance, PNS::TOOL_BASE::m_router, BOARD_DESIGN_SETTINGS::m_TrackMinWidth, DRC_CONSTRAINT::m_Value, MINOPTMAX< T >::Max(), MINOPTMAX< T >::Min(), MINOPTMAX< T >::Opt(), PNS::SIZES_SETTINGS::SetDiffPairGap(), PNS::SIZES_SETTINGS::SetDiffPairGapSource(), PNS::SIZES_SETTINGS::SetDiffPairWidth(), PNS::SIZES_SETTINGS::SetDiffPairWidthSource(), BOARD_ITEM::SetLayer(), BOARD_CONNECTED_ITEM::SetNetCode(), PNS::SIZES_SETTINGS::SetTrackWidth(), PNS::SIZES_SETTINGS::SetWidthSource(), PNS::ROUTER::Sizes(), TRACK_WIDTH_CONSTRAINT, PNS::SIZES_SETTINGS::TrackWidth(), PNS::SIZES_SETTINGS::TrackWidthIsExplicit(), PNS::ROUTER::UpdateSizes(), BOARD_DESIGN_SETTINGS::UseNetClassDiffPair(), and BOARD_DESIGN_SETTINGS::UseNetClassTrack().

Referenced by handleLayerSwitch(), MainLoop(), and switchLayerOnViaPlacement().

◆ updateStartItem()

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

Definition at line 301 of file pns_tool_base.cpp.

302{
303 int tl = getView()->GetTopLayer();
304 VECTOR2I cp = aEvent.IsPrime() ? aEvent.Position()
305 : controls()->GetCursorPosition( !aEvent.Modifier( MD_SHIFT ) );
306 VECTOR2I p;
307 GAL* gal = m_toolMgr->GetView()->GetGAL();
308
309 controls()->ForceCursorPosition( false );
311 m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
312
313 if( aEvent.IsMotion() || aEvent.IsClick() )
314 p = aEvent.Position();
315 else
316 p = cp;
317
318 m_startItem = pickSingleItem( aEvent.IsClick() ? cp : p, -1, -1, aIgnorePads );
319
321 m_startItem = nullptr;
322
325}
bool GetUseGrid() const
Definition: grid_helper.h:69
bool IsPrime() const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:333
bool IsClick(int aButtonMask=BUT_ANY) const
Definition: tool_event.cpp:193
bool IsMotion() const
Definition: tool_event.h:303

References PCB_TOOL_BASE::controls(), TOOL_EVENT::DisableGridSnapping(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), KIGFX::VIEW::GetGAL(), KIGFX::GAL::GetGridSnapping(), KIGFX::VIEW::GetTopLayer(), GRID_HELPER::GetUseGrid(), TOOL_BASE::getView(), TOOL_MANAGER::GetView(), TOOL_EVENT::IsClick(), TOOL_EVENT::IsMotion(), TOOL_EVENT::IsPrime(), PNS::ITEM::Layers(), PNS::TOOL_BASE::m_gridHelper, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, TOOL_BASE::m_toolMgr, MD_SHIFT, TOOL_EVENT::Modifier(), LAYER_RANGE::Overlaps(), PNS::TOOL_BASE::pickSingleItem(), TOOL_EVENT::Position(), GRID_HELPER::SetSnap(), GRID_HELPER::SetUseGrid(), and PNS::TOOL_BASE::snapToItem().

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

◆ view()

◆ Wait()

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

Suspend execution of the tool until an event specified in aEventList arrives.

No parameters means waiting for any event.

Definition at line 57 of file tool_interactive.cpp.

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

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

Referenced by SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), SELECTION_TOOL::doSelectionMenu(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::drawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), EDA_3D_CONTROLLER::Main(), CVPCB_CONTROL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), EE_POINT_EDITOR::Main(), EE_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ZOOM_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_POINT_EDITOR::Main(), PL_SELECTION_TOOL::Main(), PCB_PICKER_TOOL::Main(), PCB_SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::MainLoop(), MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), PCB_POINT_EDITOR::OnSelectionChange(), performDragging(), performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickReferencePoint(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

Member Data Documentation

◆ m_cancelled

bool PNS::TOOL_BASE::m_cancelled
protectedinherited

◆ m_diffPairMenu

std::shared_ptr<ACTION_MENU> ROUTER_TOOL::m_diffPairMenu
private

Definition at line 91 of file router_tool.h.

Referenced by Init().

◆ m_endItem

◆ m_endSnapPoint

◆ m_gridHelper

◆ m_iface

◆ m_inRouterTool

bool ROUTER_TOOL::m_inRouterTool
private

Definition at line 97 of file router_tool.h.

Referenced by MainLoop().

◆ m_isBoardEditor

bool PCB_TOOL_BASE::m_isBoardEditor
protectedinherited

◆ m_isFootprintEditor

<
bool PCB_TOOL_BASE::m_isFootprintEditor
protectedinherited