KiCad PCB EDA Suite
ROUTER_TOOL Class Reference

#include <router_tool.h>

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

Public Types

enum  RESET_REASON { RUN , MODEL_RELOAD , GAL_SWITCH }
 Determine the reason of reset for a tool. More...
 

Public Member Functions

 ROUTER_TOOL ()
 
 ~ROUTER_TOOL ()
 
bool Init () override
 Init() is called once upon a registration of the tool. More...
 
void Reset (RESET_REASON aReason) override
 Bring the tool to a known, initial state. More...
 
int MainLoop (const TOOL_EVENT &aEvent)
 
int 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 highlightNet (bool aEnabled, int aNetcode=-1)
 
virtual void updateStartItem (const TOOL_EVENT &aEvent, bool aIgnorePads=false)
 
virtual void updateEndItem (const TOOL_EVENT &aEvent)
 
void doInteractiveItemPlacement (const 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
 
bool m_startHighlight
 
ITEM * m_endItem
 
VECTOR2I m_endSnapPoint
 
PCB_GRID_HELPERm_gridHelper
 
PNS_KICAD_IFACEm_iface
 
ROUTER * m_router
 
bool m_cancelled
 
bool m_isFootprintEditor
 
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.

Definition at line 77 of file tool_base.h.

78 {
79 RUN,
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 183 of file router_tool.cpp.

183 :
184 TOOL_BASE( "pcbnew.InteractiveRouter" ),
187 m_inRouterTool( false )
188{
189}
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 438 of file router_tool.cpp.

439{
440}

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Run the tool.

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

Definition at line 51 of file tool_interactive.cpp.

52{
54}
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.

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

Referenced by AUTOPLACE_TOOL::autoplace(), EDIT_TOOL::copyToClipboard(), 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(), 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::ZoneFillDirty(), BOARD_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

◆ breakTrack()

void ROUTER_TOOL::breakTrack ( )
private

Definition at line 1513 of file router_tool.cpp.

1514{
1517}
@ 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 1977 of file router_tool.cpp.

1978{
1980 const PCB_SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
1981
1982 if( selection.Size() == 1 )
1983 {
1984 const BOARD_ITEM* item = static_cast<const BOARD_ITEM*>( selection.Front() );
1985
1986 // Note: EDIT_TOOL::Drag temporarily handles items of type PCB_ARC_T on its own using
1987 // DragArcTrack(), so PCB_ARC_T should never occur here.
1989 {
1990 // Footprints cannot be dragged freely.
1991 if( item->IsType( { PCB_FOOTPRINT_T } ) )
1992 return !( aDragMode & PNS::DM_FREE_ANGLE );
1993 else
1994 return true;
1995 }
1996 }
1997
1998 return false;
1999}
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:58
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:183
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:206
int Size() const
Returns the number of selected parts.
Definition: selection.h:113
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 1472 of file router_tool.cpp.

1473{
1474 PNS::PNS_MODE mode = aEvent.Parameter<PNS::PNS_MODE>();
1476
1477 settings.SetMode( mode );
1478
1479 return 0;
1480}
ROUTING_SETTINGS & Settings()
Definition: pns_router.h:185
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 251 of file pns_tool_base.cpp.

252{
253 // Sync PNS engine settings with the general PCB editor options.
254 auto& pnss = m_router->Settings();
255
256 // If we're dragging a track segment, don't try to snap to items on the same copper layer.
257 // This way we avoid 'flickery' behaviour for short segments when the snap algo is trying to
258 // snap to the corners of the segments next to the one being dragged.
260 && aItem->Layer() == m_startItem->Layer() && aItem->OfKind( ITEM::SEGMENT_T )
262 return false;
263
264 pnss.SetSnapToPads(
265 frame()->GetMagneticItemsSettings()->pads == MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL ||
266 frame()->GetMagneticItemsSettings()->pads == MAGNETIC_OPTIONS::CAPTURE_ALWAYS );
267
268 pnss.SetSnapToTracks(
269 frame()->GetMagneticItemsSettings()->tracks == MAGNETIC_OPTIONS::CAPTURE_CURSOR_IN_TRACK_TOOL
270 || frame()->GetMagneticItemsSettings()->tracks == MAGNETIC_OPTIONS::CAPTURE_ALWAYS );
271
272 if( aItem )
273 {
274 if( aItem->OfKind( ITEM::VIA_T | ITEM::SEGMENT_T | ITEM::ARC_T ) )
275 return pnss.GetSnapToTracks();
276 else if( aItem->OfKind( ITEM::SOLID_T ) )
277 return pnss.GetSnapToPads();
278 }
279
280 return false;
281}
virtual int Layer() const
Definition: pns_item.h:160
@ SOLID_T
Definition: pns_item.h:63
RouterState GetState() const
Definition: pns_router.h:134
void SetSnapToPads(bool aSnap)

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

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

◆ controls()

◆ CustomTrackWidthDialog()

int ROUTER_TOOL::CustomTrackWidthDialog ( const TOOL_EVENT aEvent)

Definition at line 2403 of file router_tool.cpp.

2404{
2406 DIALOG_TRACK_VIA_SIZE sizeDlg( frame(), bds );
2407
2408 if( sizeDlg.ShowModal() == wxID_OK )
2409 {
2410 bds.m_TempOverrideTrackWidth = true;
2411 bds.UseCustomTrackViaSize( true );
2412
2415 }
2416
2417 return 0;
2418}
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:628
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
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:74

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

1484{
1486 PNS::PNS_MODE mode = settings.Mode();
1487
1488 switch( mode )
1489 {
1490 case PNS::RM_MarkObstacles: mode = PNS::RM_Shove; break;
1491 case PNS::RM_Shove: mode = PNS::RM_Walkaround; break;
1492 case PNS::RM_Walkaround: mode = PNS::RM_MarkObstacles; break;
1493 }
1494
1495 settings.SetMode( mode );
1496
1497 return 0;
1498}
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 auto oldFlags = newItem->GetFlags();
184 newItem->ClearFlags();
185
186 if( !aPlacer->PlaceItem( newItem.get(), commit ) )
187 {
188 newItem->SetFlags( oldFlags );
189 continue;
190 }
191
192 preview.Clear();
193 newItem.release();
194 commit.Push( aCommitMessage );
195
196 controls()->CaptureCursor( false );
197 controls()->SetAutoPan( false );
198 controls()->ShowCursor( true );
199
200 if( !( aOptions & IPO_REPEAT ) )
201 break;
202
203 if( aOptions & IPO_SINGLE_CLICK )
204 makeNewItem( controls()->GetCursorPosition() );
205
206 setCursor();
207 }
208 }
209 else if( evt->IsClick( BUT_RIGHT ) )
210 {
212 }
213 else if( evt->IsAction( &PCB_ACTIONS::trackViaSizeChanged ) )
214 {
216 }
217 else if( newItem && evt->Category() == TC_COMMAND )
218 {
219 /*
220 * Handle any events that can affect the item as we move it around
221 */
222 if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
223 {
224 EDA_ANGLE rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
225 newItem->Rotate( newItem->GetPosition(), rotationAngle );
226 view()->Update( &preview );
227 }
228 else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
229 {
230 newItem->Flip( newItem->GetPosition(), frame()->GetPcbNewSettings()->m_FlipLeftRight );
231 view()->Update( &preview );
232 }
233 else if( evt->IsAction( &PCB_ACTIONS::properties ) )
234 {
235 frame()->OnEditItemRequest( newItem.get() );
236
237 // Notify other tools of the changes
239 }
240 else if( ZONE_FILLER_TOOL::IsZoneFillAction( evt ) )
241 {
242 wxBell();
243 }
244 else if( evt->IsAction( &ACTIONS::refreshPreview ) )
245 {
246 preview.Clear();
247 newItem.release();
248
249 makeNewItem( cursorPos );
250 aPlacer->SnapItem( newItem.get() );
251 view()->Update( &preview );
252 }
253 else
254 {
255 evt->SetPassEvent();
256 }
257 }
258 else if( newItem && evt->IsMotion() )
259 {
260 // track the cursor
261 newItem->SetPosition( cursorPos );
262 aPlacer->SnapItem( newItem.get() );
263
264 // Show a preview of the item
265 view()->Update( &preview );
266 }
267 else
268 {
269 evt->SetPassEvent();
270 }
271 }
272
273 view()->Remove( &preview );
275 controls()->SetAutoPan( false );
276 controls()->CaptureCursor( false );
277 controls()->ForceCursorPosition( false );
278}
static TOOL_ACTION refreshPreview
Definition: actions.h:109
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:211
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:1365
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:330
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:145
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:32
virtual void Clear() override
Remove all the stored items from the group.
Definition: selection.h:90
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:143
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
static bool IsZoneFillAction(const TOOL_EVENT *aEvent)
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(), 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(), 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(), ZONE_FILLER_TOOL::IsZoneFillAction(), 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(), 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 1440 of file router_tool.cpp.

1441{
1443 DIALOG_PNS_DIFF_PAIR_DIMENSIONS settingsDlg( frame(), sizes );
1444
1445 if( settingsDlg.ShowModal() == wxID_OK )
1446 {
1447 m_router->UpdateSizes( sizes );
1448 m_savedSizes = sizes;
1449
1452 bds.SetCustomDiffPairGap( sizes.DiffPairGap() );
1454 }
1455
1456 return 0;
1457}
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:719
SIZES_SETTINGS & Sizes()
Definition: pns_router.h:204
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 1230 of file router_tool.cpp.

1231{
1233
1234 m_startItem = nullptr;
1235 m_endItem = nullptr;
1236
1240 controls()->SetAutoPan( false );
1241 controls()->ForceCursorPosition( false );
1242 frame()->UndoRedoBlock( false );
1243 highlightNet( false );
1244
1245 return true;
1246}
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
void StopRouting()
Definition: pns_router.cpp:901
virtual void highlightNet(bool aEnabled, int aNetcode=-1)
void UpdateMessagePanel()

References ARROW, PCB_TOOL_BASE::controls(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), PNS::TOOL_BASE::highlightNet(), PNS::TOOL_BASE::m_endItem, 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(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), DRAWING_TOOL::PlaceText(), prepareInteractive(), PAD_TOOL::pushPadSettings(), 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::unfilledZoneCheck(), PCB_POINT_EDITOR::updateItem(), UpdateMessagePanel(), EDIT_TOOL::updateModificationPoint(), BOARD_EDITOR_CONTROL::UpdateSchematicFromPCB(), updateSizesAfterLayerSwitch(), PCB_CONTROL::ZoneDisplayMode(), 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 184 of file tool_base.h.

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

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone(), 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 120 of file tool_base.h.

121 {
122 return m_toolId;
123 }

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

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

References TOOL_BASE::m_toolName.

Referenced by TOOL_MANAGER::dispatchInternal(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::invokeTool(), TOOL_MANAGER::RegisterTool(), 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 1501 of file router_tool.cpp.

1502{
1503 return m_router->Settings().Mode();
1504}

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

660{
661 int tl = getView()->GetTopLayer();
662
663 if( m_startItem )
664 {
665 const LAYER_RANGE& ls = m_startItem->Layers();
666
667 if( ls.Overlaps( tl ) )
668 return tl;
669 else
670 return ls.Start();
671 }
672
673 return tl;
674}
virtual int GetTopLayer() const
Definition: view.cpp:813
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 108 of file tool_base.h.

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

References TOOL_BASE::m_type.

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

◆ getView()

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

Returns the instance of #VIEW object used in the application.

It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 36 of file tool_base.cpp.

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

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

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), SCH_EDITOR_CONTROL::AssignNetclass(), 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(), handleCommonEvents(), EE_SELECTION_TOOL::highlight(), PL_SELECTION_TOOL::highlight(), PCB_SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), PCB_SELECTION_TOOL::hitTestDistance(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), InlineDrag(), 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(), SCH_MOVE_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(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), 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(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_EDITOR_CONTROL::ToggleERCErrors(), SCH_EDITOR_CONTROL::ToggleERCExclusions(), SCH_EDITOR_CONTROL::ToggleERCWarnings(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), 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_EDITOR_CONTROL::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(), SCH_EDITOR_CONTROL::AssignNetclass(), EE_SELECTION_TOOL::autostartEvent(), SCH_EDIT_TOOL::BreakWire(), PCB_SELECTION_TOOL::controls(), PCB_TOOL_BASE::controls(), EDIT_TOOL::copyToClipboard(), SCH_DRAWING_TOOLS::createSheetPin(), 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_LINE_WIRE_BUS_TOOL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), SCH_NAVIGATE_TOOL::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 632 of file router_tool.cpp.

633{
634 if( aEvent.Category() == TC_VIEW || aEvent.Category() == TC_MOUSE )
635 {
636 BOX2D viewAreaD = getView()->GetGAL()->GetVisibleWorldExtents();
637 m_router->SetVisibleViewArea( BOX2I( viewAreaD.GetOrigin(), viewAreaD.GetSize() ) );
638 }
639
640 if( !aEvent.IsKeyPressed() )
641 return;
642
643 switch( aEvent.KeyCode() )
644 {
645 case '0':
646 if( !ADVANCED_CFG::GetCfg().m_ShowRouterDebugGraphics )
647 return;
648
650 aEvent.SetPassEvent( false );
651 break;
652
653 default:
654 break;
655 }
656}
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:213
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 876 of file router_tool.cpp.

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

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(), KIGFX::VIEW::ToScreen(), 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().

◆ highlightNet()

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

Definition at line 224 of file pns_tool_base.cpp.

225{
227
228 if( aNetcode >= 0 && aEnabled )
229 {
230 // If the user has previously set the current net to be highlighted,
231 // we assume they want to keep it highlighted after routing
233 && rs->GetHighlightNetCodes().count( aNetcode ) );
234
235 rs->SetHighlight( true, aNetcode );
236 }
237 else
238 {
239 if( !m_startHighlight )
240 rs->SetHighlight( false );
241
242 m_startHighlight = false;
243 }
244
245 // Do not remove this call. This is required to update the layers when we highlight a net.
246 // In this case, highlighting a net dims all other elements, so the colors need to update
248}
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:758
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:213

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

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

◆ Init()

bool ROUTER_TOOL::Init ( )
overridevirtual

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

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

Reimplemented from PCB_TOOL_BASE.

Definition at line 443 of file router_tool.cpp.

444{
447
448 PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
449
450 wxASSERT( frame );
451
452 auto& menu = m_menu.GetMenu();
453 menu.SetTitle( _( "Interactive Router" ) );
454
455 m_trackViaMenu = std::make_shared<TRACK_WIDTH_MENU>( *frame );
456 m_trackViaMenu->SetTool( this );
458
459 m_diffPairMenu = std::make_shared<DIFF_PAIR_MENU>( *frame );
460 m_diffPairMenu->SetTool( this );
462
463 auto haveHighlight =
464 [&]( const SELECTION& sel )
465 {
467
468 return !cfg->GetHighlightNetCodes().empty();
469 };
470
471 auto notRoutingCond =
472 [this]( const SELECTION& )
473 {
474 return !m_router->RoutingInProgress();
475 };
476
477 auto hasOtherEnd =
478 [&]( const SELECTION& )
479 {
480 std::vector<int> currentNets = m_router->GetCurrentNets();
481
482 // Need to have something unconnected to finish to
483 int currentNet = currentNets.empty() ? -1 : currentNets[0];
484 BOARD* board = getEditFrame<PCB_EDIT_FRAME>()->GetBoard();
485 RN_NET* ratsnest = board->GetConnectivity()->GetRatsnestForNet( currentNet );
486
487 return ratsnest && !ratsnest->GetEdges().empty();
488 };
489
491 menu.AddSeparator( 1 );
492
493 menu.AddItem( PCB_ACTIONS::clearHighlight, haveHighlight, 2 );
494 menu.AddSeparator( haveHighlight, 2 );
495
496 menu.AddItem( PCB_ACTIONS::routeSingleTrack, notRoutingCond );
497 menu.AddItem( PCB_ACTIONS::routeDiffPair, notRoutingCond );
500 menu.AddItem( PCB_ACTIONS::routerContinueFromEnd, hasOtherEnd );
501 menu.AddItem( PCB_ACTIONS::routerAttemptFinish, hasOtherEnd );
502 menu.AddItem( PCB_ACTIONS::breakTrack, notRoutingCond );
503
504 menu.AddItem( PCB_ACTIONS::drag45Degree, notRoutingCond );
505 menu.AddItem( PCB_ACTIONS::dragFreeAngle, notRoutingCond );
506
515
516 menu.AddSeparator();
517
518 auto diffPairCond =
519 [this]( const SELECTION& )
520 {
522 };
523
525 menu.AddMenu( m_diffPairMenu.get(), diffPairCond );
526
528
529 menu.AddSeparator();
530
532
533 return true;
534}
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:265
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:424
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:162
static TOOL_ACTION routerUndoLastSegment
Definition: pcb_actions.h:218
static TOOL_ACTION routerSettingsDialog
Activation of the Push and Shove settings dialogs.
Definition: pcb_actions.h:227
static TOOL_ACTION routerAttemptFinish
Definition: pcb_actions.h:221
static TOOL_ACTION routeDiffPair
Activation of the Push and Shove router (differential pair mode)
Definition: pcb_actions.h:207
static TOOL_ACTION breakTrack
Break a single track into two segments at the cursor.
Definition: pcb_actions.h:160
static TOOL_ACTION routerContinueFromEnd
Definition: pcb_actions.h:220
static TOOL_ACTION dragFreeAngle
Definition: pcb_actions.h:163
static TOOL_ACTION clearHighlight
Definition: pcb_actions.h:486
static TOOL_ACTION routeSingleTrack
Activation of the Push and Shove router.
Definition: pcb_actions.h:204
The main frame for Pcbnew.
ROUTER_MODE Mode() const
Definition: pns_router.h:132
Describe ratsnest for a single net.
Definition: ratsnest_data.h:63
const std::vector< CN_EDGE > & GetEdges() const
Definition: ratsnest_data.h:90
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 2341 of file router_tool.cpp.

2342{
2343 const SELECTION& selection = m_toolMgr->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
2344
2345 if( selection.Size() != 1 )
2346 return 0;
2347
2348 const BOARD_CONNECTED_ITEM* item =
2349 static_cast<const BOARD_CONNECTED_ITEM*>( selection.Front() );
2350
2351 if( item->Type() != PCB_TRACE_T )
2352 return 0;
2353
2355
2356 Activate();
2357
2359
2360 TOOL_MANAGER* toolManager = frame()->GetToolManager();
2361 GAL* gal = toolManager->GetView()->GetGAL();
2362
2364 m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
2365
2366 if( toolManager->IsContextMenuActive() )
2367 {
2368 // If we're here from a context menu then we need to get the position of the
2369 // cursor when the context menu was invoked. This is used to figure out the
2370 // break point on the track.
2372 }
2373 else
2374 {
2375 // If we're here from a hotkey, then get the current mouse position so we know
2376 // where to break the track.
2377 m_startSnapPoint = snapToItem( m_startItem, controls()->GetCursorPosition() );
2378 }
2379
2380 if( m_startItem && m_startItem->IsLocked() )
2381 {
2382 KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
2383 wxOK | wxCANCEL | wxICON_WARNING );
2384 dlg.SetOKLabel( _( "Break Track" ) );
2385 dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
2386
2387 if( dlg.ShowModal() == wxID_CANCEL )
2388 return 0;
2389 }
2390
2391 frame()->UndoRedoBlock( true );
2392 breakTrack();
2393
2396
2397 frame()->UndoRedoBlock( false );
2398
2399 return 0;
2400}
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:64
void SetUseGrid(bool aSnapToGrid)
Definition: grid_helper.h:67
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:1619
NODE * GetWorld() const
Definition: pns_router.h:157
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 2002 of file router_tool.cpp.

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

335{
336 SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
337
338 if( frame()->IsType( FRAME_PCB_EDITOR ) )
339 return mgr.GetAppSettings<PCBNEW_SETTINGS>()->m_Use45DegreeLimit;
340 else
341 return mgr.GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>()->m_Use45Limit;
342}
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 1644 of file router_tool.cpp.

1645{
1646 if( m_inRouterTool )
1647 return 0;
1648
1650
1652 PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
1654
1656 {
1657 if( m_router->Mode() == mode )
1658 return 0;
1659 else
1661 }
1662
1663 // Deselect all items
1665
1666 frame->PushTool( aEvent );
1667
1668 auto setCursor =
1669 [&]()
1670 {
1672 };
1673
1674 Activate();
1675 // Must be done after Activate() so that it gets set into the correct context
1676 controls->ShowCursor( true );
1677 controls->ForceCursorPosition( false );
1678 // Set initial cursor
1679 setCursor();
1680
1681 m_router->SetMode( mode );
1682 m_cancelled = false;
1683
1684 if( aEvent.HasPosition() )
1685 m_toolMgr->PrimeTool( aEvent.Position() );
1686
1687 // Main loop: keep receiving events
1688 while( TOOL_EVENT* evt = Wait() )
1689 {
1690 if( !evt->IsDrag() )
1691 setCursor();
1692
1693 if( evt->IsCancelInteractive() )
1694 {
1695 frame->PopTool( aEvent );
1696 break;
1697 }
1698 else if( evt->IsActivate() )
1699 {
1700 if( evt->IsMoveTool() || evt->IsEditorTool() )
1701 {
1702 // leave ourselves on the stack so we come back after the move
1703 break;
1704 }
1705 else
1706 {
1707 frame->PopTool( aEvent );
1708 break;
1709 }
1710 }
1711 else if( evt->Action() == TA_UNDO_REDO_PRE )
1712 {
1714 }
1715 else if( evt->Action() == TA_UNDO_REDO_POST || evt->Action() == TA_MODEL_CHANGE )
1716 {
1718 }
1719 else if( evt->IsMotion() )
1720 {
1721 updateStartItem( *evt );
1722 }
1723 else if( evt->IsAction( &PCB_ACTIONS::dragFreeAngle ) )
1724 {
1725 updateStartItem( *evt, true );
1727 }
1728 else if( evt->IsAction( &PCB_ACTIONS::drag45Degree ) )
1729 {
1730 updateStartItem( *evt, true );
1732 }
1733 else if( evt->IsAction( &PCB_ACTIONS::breakTrack ) )
1734 {
1735 updateStartItem( *evt, true );
1736 breakTrack( );
1737 evt->SetPassEvent( false );
1738 }
1739 else if( evt->IsClick( BUT_LEFT )
1740 || evt->IsAction( &PCB_ACTIONS::routeSingleTrack )
1741 || evt->IsAction( &PCB_ACTIONS::routeDiffPair ) )
1742 {
1743 updateStartItem( *evt );
1744
1745 if( evt->HasPosition() )
1746 {
1747 if( evt->Modifier( MD_SHIFT ) )
1749 else
1751 }
1752 }
1753 else if( evt->IsAction( &ACT_PlaceThroughVia ) )
1754 {
1756 }
1757 else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1758 {
1761 updateStartItem( *evt );
1762 }
1763 else if( evt->IsKeyPressed() )
1764 {
1765 // wxWidgets fails to correctly translate shifted keycodes on the wxEVT_CHAR_HOOK
1766 // event so we need to process the wxEVT_CHAR event that will follow as long as we
1767 // pass the event.
1768 evt->SetPassEvent();
1769 }
1770 else if( evt->IsClick( BUT_RIGHT ) )
1771 {
1773 }
1774 else
1775 {
1776 evt->SetPassEvent();
1777 }
1778
1779 if( m_cancelled )
1780 {
1781 frame->PopTool( aEvent );
1782 break;
1783 }
1784 }
1785
1786 // Store routing settings till the next invocation
1789
1790 return 0;
1791}
An interface for classes handling user events controlling the view behavior such as zooming,...
static TOOL_ACTION layerToggle
Definition: pcb_actions.h:318
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:320
virtual PCB_LAYER_ID GetActiveLayer() const
void SetMode(ROUTER_MODE aMode)
void ClearViewDecorations()
Definition: pns_router.cpp:929
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 1922 of file router_tool.cpp.

1923{
1924 /*
1925 * If the collection contains a trivial line corner (two connected segments)
1926 * or a non-fanout-via (a via with no more than two connected segments), then
1927 * trim the collection down to a single item (which one won't matter since
1928 * they're all connected).
1929 */
1930
1931 // First make sure we've got something that *might* match.
1932 int vias = aCollector.CountType( PCB_VIA_T );
1933 int traces = aCollector.CountType( PCB_TRACE_T );
1934 int arcs = aCollector.CountType( PCB_ARC_T );
1935
1936 if( arcs > 0 || vias > 1 || traces > 2 || vias + traces < 1 )
1937 return;
1938
1939 // Fetch first PCB_TRACK (via or trace) as our reference
1940 PCB_TRACK* reference = nullptr;
1941
1942 for( int i = 0; !reference && i < aCollector.GetCount(); i++ )
1943 reference = dynamic_cast<PCB_TRACK*>( aCollector[i] );
1944
1945 int refNet = reference->GetNetCode();
1946
1947 VECTOR2I refPoint( aPt.x, aPt.y );
1948 EDA_ITEM_FLAGS flags = reference->IsPointOnEnds( refPoint, -1 );
1949
1950 if( flags & STARTPOINT )
1951 refPoint = reference->GetStart();
1952 else if( flags & ENDPOINT )
1953 refPoint = reference->GetEnd();
1954
1955 // Check all items to ensure that any TRACKs are co-terminus with the reference and on
1956 // the same net.
1957 for( int i = 0; i < aCollector.GetCount(); i++ )
1958 {
1959 PCB_TRACK* neighbor = dynamic_cast<PCB_TRACK*>( aCollector[i] );
1960
1961 if( neighbor && neighbor != reference )
1962 {
1963 if( neighbor->GetNetCode() != refNet )
1964 return;
1965
1966 if( neighbor->GetStart() != refPoint && neighbor->GetEnd() != refPoint )
1967 return;
1968 }
1969 }
1970
1971 // Selection meets criteria; trim it to the reference item.
1972 aCollector.Empty();
1973 aCollector.Append( reference );
1974}
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:112
const VECTOR2I & GetEnd() const
Definition: pcb_track.h:109
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:207
#define ENDPOINT
ends. (Used to support dragging.)
std::uint32_t EDA_ITEM_FLAGS
#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 852 of file router_tool.cpp.

853{
854 return handleLayerSwitch( aEvent, false );
855}
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 2421 of file router_tool.cpp.

2422{
2424
2425 if( !m_router->GetCurrentNets().empty() )
2427
2428 m_router->UpdateSizes( sizes );
2429
2430 // Changing the track width can affect the placement, so call the
2431 // move routine without changing the destination
2432 // Update end item first to avoid moving to an invalid/missing item
2433 updateEndItem( aEvent );
2435
2437
2438 return 0;
2439}
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 1794 of file router_tool.cpp.

1795{
1797
1799
1800 if( m_startItem && m_startItem->IsLocked() )
1801 {
1802 KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
1803 wxOK | wxCANCEL | wxICON_WARNING );
1804 dlg.SetOKLabel( _( "Drag Anyway" ) );
1805 dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
1806
1807 if( dlg.ShowModal() == wxID_CANCEL )
1808 return;
1809 }
1810
1811 // We don't support dragging arcs inside the PNS right now
1813 {
1816
1817 m_startItem = nullptr;
1818
1819 m_gridHelper->SetAuxAxes( false );
1820 ctls->ForceCursorPosition( false );
1821 highlightNet( false );
1822
1823 m_cancelled = true;
1824
1826
1827 return;
1828 }
1829
1830 bool dragStarted = m_router->StartDragging( m_startSnapPoint, m_startItem, aMode );
1831
1832 if( !dragStarted )
1833 return;
1834
1835 if( m_startItem && m_startItem->Net() > 0 )
1836 highlightNet( true, m_startItem->Net() );
1837
1838 ctls->SetAutoPan( true );
1840 frame()->UndoRedoBlock( true );
1841
1842 while( TOOL_EVENT* evt = Wait() )
1843 {
1844 ctls->ForceCursorPosition( false );
1845
1846 if( evt->IsMotion() )
1847 {
1848 updateEndItem( *evt );
1850 }
1851 else if( evt->IsClick( BUT_LEFT ) )
1852 {
1854 break;
1855 }
1856 else if( evt->IsClick( BUT_RIGHT ) )
1857 {
1859 }
1860 else if( evt->IsCancelInteractive() || evt->IsActivate() )
1861 {
1862 if( evt->IsCancelInteractive() && !m_startItem )
1863 m_cancelled = true;
1864
1865 if( evt->IsActivate() && !evt->IsMoveTool() )
1866 m_cancelled = true;
1867
1868 break;
1869 }
1870 else if( evt->IsUndoRedo() )
1871 {
1872 // We're in an UndoRedoBlock. If we get here, something's broken.
1873 wxFAIL;
1874 break;
1875 }
1876 else if( evt->Category() == TC_COMMAND )
1877 {
1878 // TODO: It'd be nice to be able to say "don't allow any non-trivial editing actions",
1879 // but we don't at present have that, so we just knock out some of the egregious ones.
1880 if( evt->IsAction( &ACTIONS::cut )
1881 || evt->IsAction( &ACTIONS::copy )
1882 || evt->IsAction( &ACTIONS::paste )
1883 || evt->IsAction( &ACTIONS::pasteSpecial )
1885 {
1886 wxBell();
1887 }
1888 // treat an undo as an escape
1889 else if( evt->IsAction( &ACTIONS::undo ) )
1890 {
1891 if( m_startItem )
1892 break;
1893 else
1894 wxBell();
1895 }
1896 else
1897 {
1898 evt->SetPassEvent();
1899 }
1900 }
1901 else
1902 {
1903 evt->SetPassEvent();
1904 }
1905
1906 handleCommonEvents( *evt );
1907 }
1908
1911
1912 m_startItem = nullptr;
1913
1914 m_gridHelper->SetAuxAxes( false );
1915 frame()->UndoRedoBlock( false );
1916 ctls->SetAutoPan( false );
1917 ctls->ForceCursorPosition( false );
1918 highlightNet( false );
1919}
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::highlightNet(), 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 1249 of file router_tool.cpp.

1250{
1252
1253 if( !prepareInteractive() )
1254 return;
1255
1256 auto setCursor =
1257 [&]()
1258 {
1260 };
1261
1262 auto syncRouterAndFrameLayer =
1263 [&]()
1264 {
1265 PCB_LAYER_ID routingLayer = ToLAYER_ID( m_router->GetCurrentLayer() );
1266 PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
1267
1268 editFrame->SetActiveLayer( routingLayer );
1269
1270 if( !getView()->IsLayerVisible( routingLayer ) )
1271 {
1272 editFrame->GetAppearancePanel()->SetLayerVisible( routingLayer, true );
1273 editFrame->GetCanvas()->Refresh();
1274 }
1275 };
1276
1277 // Set initial cursor
1278 setCursor();
1279
1280 while( TOOL_EVENT* evt = Wait() )
1281 {
1282 setCursor();
1283
1284 // Don't crash if we missed an operation that canceled routing.
1285 if( !m_router->RoutingInProgress() )
1286 {
1287 if( evt->IsCancelInteractive() )
1288 m_cancelled = true;
1289
1290 break;
1291 }
1292
1293 handleCommonEvents( *evt );
1294
1295 if( evt->IsMotion() )
1296 {
1297 updateEndItem( *evt );
1299 }
1300 else if( evt->IsAction( &PCB_ACTIONS::routerUndoLastSegment ) )
1301 {
1303 updateEndItem( *evt );
1305 }
1306 else if( evt->IsAction( &PCB_ACTIONS::routerAttemptFinish ) )
1307 {
1308 bool* autoRouted = evt->Parameter<bool*>();
1309
1310 if( m_router->Finish() )
1311 {
1312 // When we're routing a group of signals automatically we want
1313 // to break up the undo stack every time we have to manually route
1314 // so the user gets nice checkpoints. Remove the APPEND_UNDO flag.
1315 if( autoRouted != nullptr )
1316 *autoRouted = true;
1317
1318 break;
1319 }
1320 else
1321 {
1322 // This acts as check if we were called by the autorouter; we don't want
1323 // to reset APPEND_UNDO if we're auto finishing after route-other-end
1324 if( autoRouted != nullptr )
1325 {
1326 *autoRouted = false;
1327 m_iface->SetCommitFlags( 0 );
1328 }
1329
1330 // Warp the mouse so the user is at the point we managed to route to
1331 controls()->WarpMouseCursor( m_router->Placer()->CurrentEnd(), true, true );
1332 }
1333 }
1334 else if( evt->IsAction( &PCB_ACTIONS::routerContinueFromEnd ) )
1335 {
1336 bool needsAppend = m_router->Placer()->HasPlacedAnything();
1337
1338 if( m_router->ContinueFromEnd() )
1339 {
1340 syncRouterAndFrameLayer();
1342
1343 // Warp the mouse to wherever we actually ended up routing to
1344 controls()->WarpMouseCursor( m_router->Placer()->CurrentEnd(), true, true );
1345
1346 // We want the next router commit to be one undo at the UI layer
1347 m_iface->SetCommitFlags( needsAppend ? APPEND_UNDO : 0 );
1348 }
1349 }
1350 else if( evt->IsClick( BUT_LEFT ) || evt->IsDrag( BUT_LEFT ) || evt->IsAction( &PCB_ACTIONS::routeSingleTrack ) )
1351 {
1352 updateEndItem( *evt );
1353 bool needLayerSwitch = m_router->IsPlacingVia();
1354 bool forceFinish = evt->Modifier( MD_SHIFT );
1355
1356 if( m_router->FixRoute( m_endSnapPoint, m_endItem, forceFinish ) )
1357 break;
1358
1359 if( needLayerSwitch )
1361
1362 // Synchronize the indicated layer
1363 syncRouterAndFrameLayer();
1364
1365 updateEndItem( *evt );
1367 m_startItem = nullptr;
1368 }
1369 else if( evt->IsAction( &ACT_SwitchCornerMode ) )
1370 {
1373 updateEndItem( *evt );
1374 m_router->Move( m_endSnapPoint, m_endItem ); // refresh
1375 }
1376 else if( evt->IsAction( &ACT_SwitchPosture ) )
1377 {
1379 updateEndItem( *evt );
1380 m_router->Move( m_endSnapPoint, m_endItem ); // refresh
1381 }
1382 else if( evt->IsAction( &PCB_ACTIONS::properties ) )
1383 {
1385 controls()->SetAutoPan( false );
1386 {
1388 }
1389 controls()->SetAutoPan( true );
1390 setCursor();
1392 }
1393 else if( evt->IsAction( &ACT_EndTrack ) || evt->IsDblClick( BUT_LEFT ) )
1394 {
1395 // Stop current routing:
1397 break;
1398 }
1399 else if( evt->IsCancelInteractive() || evt->IsActivate()
1400 || evt->IsAction( &PCB_ACTIONS::routerInlineDrag ) )
1401 {
1402 if( evt->IsCancelInteractive() && !m_router->RoutingInProgress() )
1403 m_cancelled = true;
1404
1405 if( evt->IsActivate() && !evt->IsMoveTool() )
1406 m_cancelled = true;
1407
1408 break;
1409 }
1410 else if( evt->IsUndoRedo() )
1411 {
1412 // We're in an UndoRedoBlock. If we get here, something's broken.
1413 wxFAIL;
1414 break;
1415 }
1416 else if( evt->IsClick( BUT_RIGHT ) )
1417 {
1419 }
1420 // TODO: It'd be nice to be able to say "don't allow any non-trivial editing actions",
1421 // but we don't at present have that, so we just knock out some of the egregious ones.
1422 else if( ZONE_FILLER_TOOL::IsZoneFillAction( evt ) )
1423 {
1424 wxBell();
1425 }
1426 else
1427 {
1428 evt->SetPassEvent();
1429 }
1430 }
1431
1433 // Reset to normal for next route
1434 m_iface->SetCommitFlags( 0 );
1435
1437}
#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:238
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:209
void UndoLastSegment()
Definition: pns_router.cpp:882
void CommitRouting()
Definition: pns_router.cpp:892
bool Finish()
Definition: pns_router.cpp:519
bool ContinueFromEnd()
Definition: pns_router.cpp:557
void FlipPosture()
Definition: pns_router.cpp:935
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:79
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:825
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 1166 of file router_tool.cpp.

1167{
1168 PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
1169 int routingLayer = getStartLayer( m_startItem );
1170
1171 if( !IsCopperLayer( routingLayer ) )
1172 {
1173 editFrame->ShowInfoBarError( _( "Tracks on Copper layers only." ) );
1174 return false;
1175 }
1176
1178 editFrame->SetActiveLayer( ToLAYER_ID( routingLayer ) );
1179
1180 if( !getView()->IsLayerVisible( routingLayer ) )
1181 {
1182 editFrame->GetAppearancePanel()->SetLayerVisible( routingLayer, true );
1183 editFrame->GetCanvas()->Refresh();
1184 }
1185
1186 if( m_startItem && m_startItem->Net() > 0 )
1187 highlightNet( true, m_startItem->Net() );
1188
1189 controls()->SetAutoPan( true );
1190
1192
1193 m_iface->SetStartLayer( routingLayer );
1194
1196 m_iface->ImportSizes( sizes, m_startItem, -1 );
1197 sizes.AddLayerPair( frame()->GetScreen()->m_Route_Layer_TOP,
1198 frame()->GetScreen()->m_Route_Layer_BOTTOM );
1199
1200 m_router->UpdateSizes( sizes );
1201
1202 if( !m_router->StartRouting( m_startSnapPoint, m_startItem, routingLayer ) )
1203 {
1204 // It would make more sense to leave the net highlighted as the higher-contrast mode
1205 // makes the router clearances more visible. However, since we just started routing
1206 // the conversion of the screen from low contrast to high contrast is a bit jarring and
1207 // makes the infobar coming up less noticeable.
1208 highlightNet( false );
1209
1211 [&]()
1212 {
1213 m_router->ClearViewDecorations();
1214 } );
1215
1216 controls()->SetAutoPan( false );
1217 return false;
1218 }
1219
1220 m_endItem = nullptr;
1222
1224 frame()->UndoRedoBlock( true );
1225
1226 return true;
1227}
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:207
bool StartRouting(const VECTOR2I &aP, ITEM *aItem, int aLayer)
Definition: pns_router.cpp:388
void SetStartLayer(int aLayer)
int getStartLayer(const PNS::ITEM *aItem)

References _, PNS::SIZES_SETTINGS::AddLayerPair(), PCB_TOOL_BASE::controls(), 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(), getStartLayer(), TOOL_BASE::getView(), PNS::TOOL_BASE::highlightNet(), PNS_KICAD_IFACE_BASE::ImportSizes(), IsCopperLayer(), PNS::TOOL_BASE::m_endItem, PNS::TOOL_BASE::m_endSnapPoint, PNS::TOOL_BASE::m_iface, m_originalActiveLayer, PNS::TOOL_BASE::m_router, PNS::TOOL_BASE::m_startItem, PNS::TOOL_BASE::m_startSnapPoint, BOARD_DESIGN_SETTINGS::m_TempOverrideTrackWidth, PNS::ITEM::Net(), EDA_DRAW_PANEL_GAL::Refresh(), PCB_EDIT_FRAME::SetActiveLayer(), KIGFX::VIEW_CONTROLS::SetAutoPan(), APPEARANCE_CONTROLS::SetLayerVisible(), PNS_KICAD_IFACE_BASE::SetStartLayer(), EDA_BASE_FRAME::ShowInfoBarError(), PNS::ROUTER::Sizes(), PNS::ROUTER::StartRouting(), ToLAYER_ID(), PCB_BASE_EDIT_FRAME::UndoRedoBlock(), UpdateMessagePanel(), and PNS::ROUTER::UpdateSizes().

Referenced by performRouting().

◆ Reset()

void ROUTER_TOOL::Reset ( RESET_REASON  aReason)
overridevirtual

Bring the tool to a known, initial state.

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

Parameters
aReasoncontains information about the reason of tool reset.

Reimplemented from PNS::TOOL_BASE.

Definition at line 537 of file router_tool.cpp.

538{
540
541 if( aReason == RUN )
542 TOOL_BASE::Reset( aReason );
543}
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 1520 of file router_tool.cpp.

1521{
1523 PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
1525 PCB_LAYER_ID originalLayer = frame->GetActiveLayer();
1526 bool autoRoute = aEvent.Matches( PCB_ACTIONS::routerAutorouteSelected.MakeEvent() );
1527 bool otherEnd = aEvent.Matches( PCB_ACTIONS::routerRouteSelectedFromEnd.MakeEvent() );
1528
1530 return 0;
1531
1532 // Save selection then clear it for interactive routing
1534
1535 if( selection.Size() == 0 )
1536 return 0;
1537
1539
1540 frame->PushTool( aEvent );
1541
1542 auto setCursor =
1543 [&]()
1544 {
1546 };
1547
1548 Activate();
1549 // Must be done after Activate() so that it gets set into the correct context
1550 controls->ShowCursor( true );
1551 controls->ForceCursorPosition( false );
1552 // Set initial cursor
1553 setCursor();
1554
1555 // Get all connected board items, adding pads for any footprints selected
1556 std::vector<BOARD_CONNECTED_ITEM*> itemList;
1557
1559 {
1560 if( item->Type() == PCB_FOOTPRINT_T )
1561 {
1562 const PADS& fpPads = ( static_cast<FOOTPRINT*>( item ) )->Pads();
1563
1564 for( PAD* pad : fpPads )
1565 itemList.push_back( pad );
1566 }
1567 else if( dynamic_cast<BOARD_CONNECTED_ITEM*>( item ) != nullptr )
1568 {
1569 itemList.push_back( static_cast<BOARD_CONNECTED_ITEM*>( item ) );
1570 }
1571 }
1572
1573 std::shared_ptr<CONNECTIVITY_DATA> connectivity = frame->GetBoard()->GetConnectivity();
1574
1575 // For putting sequential tracks that successfully autoroute into one undo commit
1576 bool groupStart = true;
1577
1578 for( BOARD_CONNECTED_ITEM* item : itemList )
1579 {
1580 // This code is similar to GetRatsnestForPad() but it only adds the anchor for
1581 // the side of the connectivity on this pad. It also checks for ratsnest points
1582 // inside the pad (like a trace end) and counts them.
1583 RN_NET* net = connectivity->GetRatsnestForNet( item->GetNetCode() );
1584 std::vector<std::shared_ptr<CN_ANCHOR>> anchors;
1585
1586 for( const CN_EDGE& edge : net->GetEdges() )
1587 {
1588 std::shared_ptr<CN_ANCHOR> target = edge.GetTargetNode();
1589 std::shared_ptr<CN_ANCHOR> source = edge.GetSourceNode();
1590
1591 if( source->Parent() == item )
1592 anchors.push_back( edge.GetSourceNode() );
1593 else if( target->Parent() == item )
1594 anchors.push_back( edge.GetTargetNode() );
1595 }
1596
1597 // Route them
1598 for( std::shared_ptr<CN_ANCHOR> anchor : anchors )
1599 {
1600 // Try to return to the original layer as indicating the user's preferred
1601 // layer for autorouting tracks. The layer can be changed by the user to
1602 // finish tracks that can't complete automatically, but should be changed
1603 // back after.
1604 if( frame->GetActiveLayer() != originalLayer )
1605 frame->SetActiveLayer( originalLayer );
1606
1607 VECTOR2I ignore;
1609 m_startSnapPoint = anchor->Pos();
1610 m_router->SetMode( mode );
1611
1612 // Prime the interactive routing to attempt finish if we are autorouting
1613 bool autoRouted = false;
1614
1615 if( autoRoute )
1617 else if( otherEnd )
1619
1620 // We want autorouted tracks to all be in one undo group except for
1621 // any tracks that need to be manually finished.
1622 // The undo appending for manually finished tracks is handled in peformRouting()
1623 if( groupStart )
1624 groupStart = false;
1625 else
1627
1628 // Start interactive routing. Will automatically finish if possible.
1630
1631 // Route didn't complete automatically, need to a new undo commit
1632 // for the next line so those can group as far as they autoroute
1633 if( !autoRouted )
1634 groupStart = true;
1635 }
1636 }
1637
1638 m_iface->SetCommitFlags( 0 );
1639 frame->PopTool( aEvent );
1640 return 0;
1641}
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:223
static TOOL_ACTION routerAutorouteSelected
Definition: pcb_actions.h:224
const std::vector< EDA_ITEM * > GetItemsSortedBySelectionOrder() const
Definition: selection.cpp:202
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 1507 of file router_tool.cpp.

1508{
1509 return m_router->RoutingInProgress();
1510}

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

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

327{
329
330 return selTool->GetSelection();
331}
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 318 of file pcb_tool_base.cpp.

319{
321
322 return selTool->GetSelection();
323}

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::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(), and BOARD_EDITOR_CONTROL::ZoneMerge().

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

1461{
1462 DIALOG_PNS_SETTINGS settingsDlg( frame(), m_router->Settings() );
1463
1464 settingsDlg.ShowModal();
1465
1467
1468 return 0;
1469}

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

2562{
2564
2578
2585
2620
2623}
static TOOL_ACTION layerInner12
Definition: pcb_actions.h:294
static TOOL_ACTION layerInner8
Definition: pcb_actions.h:290
static TOOL_ACTION layerInner3
Definition: pcb_actions.h:285
static TOOL_ACTION layerInner2
Definition: pcb_actions.h:284
static TOOL_ACTION layerInner25
Definition: pcb_actions.h:307
static TOOL_ACTION routerHighlightMode
Actions to enable switching modes via hotkey assignments.
Definition: pcb_actions.h:232
static TOOL_ACTION routerWalkaroundMode
Definition: pcb_actions.h:234
static TOOL_ACTION routerShoveMode
Definition: pcb_actions.h:233
static TOOL_ACTION layerInner24
Definition: pcb_actions.h:306
static TOOL_ACTION layerInner29
Definition: pcb_actions.h:311
static TOOL_ACTION layerInner11
Definition: pcb_actions.h:293
static TOOL_ACTION routerDiffPairDialog
Definition: pcb_actions.h:228
static TOOL_ACTION layerInner16
Definition: pcb_actions.h:298
static TOOL_ACTION layerInner26
Definition: pcb_actions.h:308
static TOOL_ACTION layerInner18
Definition: pcb_actions.h:300
static TOOL_ACTION layerInner14
Definition: pcb_actions.h:296
static TOOL_ACTION selectLayerPair
Definition: pcb_actions.h:157
static TOOL_ACTION layerInner6
Definition: pcb_actions.h:288
static TOOL_ACTION layerInner22
Definition: pcb_actions.h:304
static TOOL_ACTION layerInner5
Definition: pcb_actions.h:287
static TOOL_ACTION layerInner20
Definition: pcb_actions.h:302
static TOOL_ACTION layerInner7
Definition: pcb_actions.h:289
static TOOL_ACTION layerInner27
Definition: pcb_actions.h:309
static TOOL_ACTION layerInner1
Definition: pcb_actions.h:283
static TOOL_ACTION layerInner10
Definition: pcb_actions.h:292
static TOOL_ACTION layerInner15
Definition: pcb_actions.h:297
static TOOL_ACTION layerInner17
Definition: pcb_actions.h:299
static TOOL_ACTION layerBottom
Definition: pcb_actions.h:313
static TOOL_ACTION layerInner19
Definition: pcb_actions.h:301
static TOOL_ACTION layerInner9
Definition: pcb_actions.h:291
static TOOL_ACTION layerInner30
Definition: pcb_actions.h:312
static TOOL_ACTION layerTop
Definition: pcb_actions.h:282
static TOOL_ACTION cycleRouterMode
Definition: pcb_actions.h:235
static TOOL_ACTION layerInner4
Definition: pcb_actions.h:286
static TOOL_ACTION layerInner13
Definition: pcb_actions.h:295
static TOOL_ACTION layerInner21
Definition: pcb_actions.h:303
static TOOL_ACTION routerRouteSelected
Definition: pcb_actions.h:222
static TOOL_ACTION layerInner23
Definition: pcb_actions.h:305
static TOOL_ACTION layerInner28
Definition: pcb_actions.h:310
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 386 of file pns_tool_base.cpp.

387{
388 if( !aItem || !m_iface->IsItemVisible( aItem ) )
389 {
390 return m_gridHelper->Align( aP );
391 }
392
393 switch( aItem->Kind() )
394 {
395 case ITEM::SOLID_T:
396 return static_cast<SOLID*>( aItem )->Pos();
397
398 case ITEM::VIA_T:
399 return static_cast<VIA*>( aItem )->Pos();
400
401 case ITEM::SEGMENT_T:
402 case ITEM::ARC_T:
403 {
404 LINKED_ITEM* li = static_cast<LINKED_ITEM*>( aItem );
405 VECTOR2I A = li->Anchor( 0 );
406 VECTOR2I B = li->Anchor( 1 );
407 SEG::ecoord w_sq = SEG::Square( li->Width() / 2 );
408 SEG::ecoord distA_sq = ( aP - A ).SquaredEuclideanNorm();
409 SEG::ecoord distB_sq = ( aP - B ).SquaredEuclideanNorm();
410
411 if( distA_sq < w_sq || distB_sq < w_sq )
412 {
413 return ( distA_sq < distB_sq ) ? A : B;
414 }
415 else if( aItem->Kind() == ITEM::SEGMENT_T )
416 {
417 // TODO(snh): Clean this up
418 SEGMENT* seg = static_cast<SEGMENT*>( li );
419 return m_gridHelper->AlignToSegment( aP, seg->Seg() );
420 }
421 else if( aItem->Kind() == ITEM::ARC_T )
422 {
423 ARC* arc = static_cast<ARC*>( li );
424 return m_gridHelper->AlignToArc( aP, *static_cast<const SHAPE_ARC*>( arc->Shape() ) );
425 }
426
427 break;
428 }
429
430 default:
431 break;
432 }
433
434 return m_gridHelper->Align( aP );
435}
virtual VECTOR2I Align(const VECTOR2I &aPoint) const
Definition: grid_helper.cpp:95
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:89

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

678{
679 int activeLayer = frame()->GetActiveLayer();
680 int currentLayer = m_router->GetCurrentLayer();
681
682 if( currentLayer != activeLayer )
683 m_router->SwitchLayer( activeLayer );
684
685 std::optional<int> newLayer = m_router->Sizes().PairedLayer( currentLayer );
686
687 if( !newLayer )
688 newLayer = m_router->Sizes().GetLayerTop();
689
690 m_router->SwitchLayer( *newLayer );
691 m_lastTargetLayer = *newLayer;
692
694}
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 311 of file pns_tool_base.cpp.

312{
313 int layer;
314 GAL* gal = m_toolMgr->GetView()->GetGAL();
315
317 m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
318
319 controls()->ForceCursorPosition( false );
320
321 VECTOR2I mousePos = controls()->GetMousePosition();
322
323 if( m_router->GetState() == ROUTER::ROUTE_TRACK && aEvent.IsDrag() )
324 {
325 // If the user is moving the mouse quickly while routing then clicks will come in as
326 // short drags. In this case we want to use the drag origin rather than the current
327 // mouse position.
328 mousePos = aEvent.DragOrigin();
329 }
330
332 ( m_router->GetCurrentNets().empty() || m_router->GetCurrentNets().front() < 0 ) )
333 {
334 m_endSnapPoint = snapToItem( nullptr, mousePos );
336 m_endItem = nullptr;
337
338 return;
339 }
340
341 if( m_router->IsPlacingVia() )
342 layer = -1;
343 else
344 layer = m_router->GetCurrentLayer();
345
346 ITEM* endItem = nullptr;
347
348 std::vector<int> nets = m_router->GetCurrentNets();
349
350 for( int net : nets )
351 {
352 endItem = pickSingleItem( mousePos, net, layer, false, { m_startItem } );
353
354 if( endItem )
355 break;
356 }
357
358 if( m_gridHelper->GetSnap() && checkSnap( endItem ) )
359 {
360 m_endItem = endItem;
361 m_endSnapPoint = snapToItem( endItem, mousePos );
362 }
363 else
364 {
365 m_endItem = nullptr;
366 m_endSnapPoint = m_gridHelper->Align( mousePos );
367 }
368
370
371 if( m_endItem )
372 {
373 wxLogTrace( wxT( "PNS" ), wxT( "%s, layer : %d" ),
374 m_endItem->KindStr().c_str(),
375 m_endItem->Layers().Start() );
376 }
377}
bool GetSnap() const
Definition: grid_helper.h:65
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 2442 of file router_tool.cpp.

2443{
2444 std::vector<MSG_PANEL_ITEM> items;
2445
2447 {
2450 std::vector<int> nets = m_router->GetCurrentNets();
2451 wxString description;
2452 wxString secondary;
2453
2455 {
2456 wxASSERT( nets.size() >= 2 );
2457
2458 NETINFO_ITEM* netA = board()->FindNet( nets[0] );
2459 NETINFO_ITEM* netB = board()->FindNet( nets[1] );
2460 wxASSERT( netA );
2461 wxASSERT( netB );
2462
2463 description = wxString::Format( _( "Routing Diff Pair: %s" ),
2464 netA->GetNetname() + wxT( ", " ) + netB->GetNetname() );
2465
2466 wxString netclass;
2467 NETCLASS* netclassA = netA->GetNetClass();
2468 NETCLASS* netclassB = netB->GetNetClass();
2469
2470 if( netclassA == netclassB )
2471 netclass = netclassA->GetName();
2472 else
2473 netclass = netclassA->GetName() + wxT( ", " ) + netclassB->GetName();
2474
2475 secondary = wxString::Format( _( "Resolved Netclass: %s" ),
2476 UnescapeString( netclass ) );
2477 }
2478 else if( !nets.empty() )
2479 {
2480 NETINFO_ITEM* net = board()->FindNet( nets[0] );
2481 wxASSERT( net );
2482
2483 description = wxString::Format( _( "Routing Track: %s" ),
2484 net->GetNetname() );
2485
2486 secondary = wxString::Format( _( "Resolved Netclass: %s" ),
2487 UnescapeString( net->GetNetClass()->GetName() ) );
2488 }
2489 else
2490 {
2491 description = _( "Routing Track" );
2492 secondary = _( "(no net)" );
2493 }
2494
2495 items.emplace_back( description, secondary );
2496
2497 wxString cornerMode;
2498
2500 {
2501 cornerMode = _( "Free-angle" );
2502 }
2503 else
2504 {
2505 switch( m_router->Settings().GetCornerMode() )
2506 {
2507 case DIRECTION_45::CORNER_MODE::MITERED_45: cornerMode = _( "45-degree" ); break;
2508 case DIRECTION_45::CORNER_MODE::ROUNDED_45: cornerMode = _( "45-degree rounded" ); break;
2509 case DIRECTION_45::CORNER_MODE::MITERED_90: cornerMode = _( "90-degree" ); break;
2510 case DIRECTION_45::CORNER_MODE::ROUNDED_90: cornerMode = _( "90-degree rounded" ); break;
2511 default: break;
2512 }
2513 }
2514
2515 items.emplace_back( _( "Corner Style" ), cornerMode );
2516
2517#define FORMAT_VALUE( x ) frame()->MessageTextFromValue( x )
2518
2520 {
2521 items.emplace_back( wxString::Format( _( "Track Width: %s" ),
2522 FORMAT_VALUE( sizes.DiffPairWidth() ) ),
2523 wxString::Format( _( "(from %s)" ),
2524 sizes.GetDiffPairWidthSource() ) );
2525
2526 items.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
2527 FORMAT_VALUE( sizes.MinClearance() ) ),
2528 wxString::Format( _( "(from %s)" ),
2529 sizes.GetClearanceSource() ) );
2530
2531 items.emplace_back( wxString::Format( _( "Diff Pair Gap: %s" ),
2532 FORMAT_VALUE( sizes.DiffPairGap() ) ),
2533 wxString::Format( _( "(from %s)" ),
2534 sizes.GetDiffPairGapSource() ) );
2535 }
2536 else
2537 {
2538 items.emplace_back( wxString::Format( _( "Track Width: %s" ),
2539 FORMAT_VALUE( sizes.TrackWidth() ) ),
2540 wxString::Format( _( "(from %s)" ),
2541 sizes.GetWidthSource() ) );
2542
2543 items.emplace_back( wxString::Format( _( "Min Clearance: %s" ),
2544 FORMAT_VALUE( sizes.MinClearance() ) ),
2545 wxString::Format( _( "(from %s)" ),
2546 sizes.GetClearanceSource() ) );
2547 }
2548
2549#undef FORMAT_VALUE
2550
2551 frame()->SetMsgPanel( items );
2552 }
2553 else
2554 {
2555 frame()->SetMsgPanel( board() );
2556 return;
2557 }
2558}
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
Definition: board.cpp:1402
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:66
const wxString & GetNetname() const
Definition: netinfo.h:119
NETCLASS * GetNetClass()
Definition: netinfo.h:111
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::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::SIZES_SETTINGS::MinClearance(), 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 697 of file router_tool.cpp.

698{
699 std::vector<int> nets = m_router->GetCurrentNets();
700
703 std::shared_ptr<DRC_ENGINE>& drcEngine = bds.m_DRCEngine;
704 DRC_CONSTRAINT constraint;
705
706 PCB_TRACK dummyTrack( board() );
707 dummyTrack.SetLayer( targetLayer );
708 dummyTrack.SetNetCode( nets.empty() ? 0 : nets[0] );
709
710 if( bds.UseNetClassTrack() || !sizes.TrackWidthIsExplicit() )
711 {
712 constraint = drcEngine->EvalRules( TRACK_WIDTH_CONSTRAINT, &dummyTrack, nullptr,
713 targetLayer );
714
715 if( !constraint.IsNull() )
716 {
717 sizes.SetTrackWidth( std::max( bds.m_TrackMinWidth, constraint.m_Value.Opt() ) );
718
719 if( sizes.TrackWidth() == constraint.m_Value.Opt() )
720 sizes.SetWidthSource( constraint.GetName() );
721 else
722 sizes.SetWidthSource( _( "board minimum track width" ) );
723 }
724 }
725
726 if( nets.size() >= 2 && ( bds.UseNetClassDiffPair() || !sizes.TrackWidthIsExplicit() ) )
727 {
728 PCB_TRACK dummyTrackB( board() );
729 dummyTrackB.SetLayer( targetLayer );
730 dummyTrackB.SetNetCode( nets[1] );
731
732 constraint = drcEngine->EvalRules( TRACK_WIDTH_CONSTRAINT, &dummyTrack, &dummyTrackB,
733 targetLayer );
734
735 if( !constraint.IsNull() )
736 {
737 sizes.SetDiffPairWidth( std::max( bds.m_TrackMinWidth, constraint.m_Value.Opt() ) );
738
739 if( sizes.DiffPairWidth() == constraint.m_Value.Opt() )
740 sizes.SetDiffPairWidthSource( constraint.GetName() );
741 else
742 sizes.SetDiffPairWidthSource( _( "board minimum track width" ) );
743 }
744
745 constraint = drcEngine->EvalRules( DIFF_PAIR_GAP_CONSTRAINT, &dummyTrack, &dummyTrackB,
746 targetLayer );
747
748 if( !constraint.IsNull() )
749 {
750 sizes.SetDiffPairGap( std::max( bds.m_MinClearance, constraint.m_Value.Opt() ) );
751
752 if( sizes.DiffPairGap() == constraint.m_Value.Opt() )
753 sizes.SetDiffPairGapSource( constraint.GetName() );
754 else
755 sizes.SetDiffPairGapSource( _( "board minimum clearance" ) );
756 }
757 }
758
759 m_router->UpdateSizes( sizes );
761}
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:147
virtual void UpdateMsgPanel()
Redraw the message panel.
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:65
@ TRACK_WIDTH_CONSTRAINT
Definition: drc_rule.h:55

References _, PCB_TOOL_BASE::board(), DIFF_PAIR_GAP_CONSTRAINT, PNS::SIZES_SETTINGS::DiffPairGap(), PNS::SIZES_SETTINGS::DiffPairWidth(), PCB_TOOL_BASE::frame(), 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 >::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(), EDA_DRAW_FRAME::UpdateMsgPanel(), 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 284 of file pns_tool_base.cpp.

285{
286 int tl = getView()->GetTopLayer();
287 VECTOR2I cp = aEvent.IsPrime() ? aEvent.Position()
288 : controls()->GetCursorPosition( !aEvent.Modifier( MD_SHIFT ) );
289 VECTOR2I p;
290 GAL* gal = m_toolMgr->GetView()->GetGAL();
291
292 controls()->ForceCursorPosition( false );
294 m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
295
296 if( aEvent.IsMotion() || aEvent.IsClick() )
297 p = aEvent.Position();
298 else
299 p = cp;
300
301 m_startItem = pickSingleItem( aEvent.IsClick() ? cp : p, -1, -1, aIgnorePads );
302
304 m_startItem = nullptr;
305
308}
bool GetUseGrid() const
Definition: grid_helper.h:68
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:200
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(), GROUP_TOOL::PickNewMember(), 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

◆ m_lastTargetLayer

int ROUTER_TOOL::m_lastTargetLayer
private

Definition at line 94 of file router_tool.h.

Referenced by handleLayerSwitch(), Init(), Reset(), and switchLayerOnViaPlacement().

◆ m_menu

TOOL_MENU TOOL_INTERACTIVE::m_menu
protectedinherited

The functions below are not yet implemented - their interface may change.

Definition at line 125 of file tool_interactive.h.

Referenced by SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), 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(), TOOL_INTERACTIVE::GetToolMenu(), EDA_3D_CONTROLLER::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init(), EE_SELECTION_TOOL::Init(), EE_TOOL_BASE< T >::Init(), SCH_DRAWING_TOOLS::Init(), SCH_EDIT_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), SYMBOL_EDITOR_CONTROL::Init(), SYMBOL_EDITOR_DRAWING_TOOLS::Init(), GERBVIEW_SELECTION_TOOL::Init(), PICKER_TOOL::Init(), ZOOM_TOOL::Init(), PL_DRAWING_TOOLS::Init(), PL_EDIT_TOOL::Init(), PL_SELECTION_TOOL::Init(), LENGTH_TUNER_TOOL::Init(), Init(), BOARD_EDITOR_CONTROL::Init(), DRAWING_TOOL::Init(), FOOTPRINT_EDITOR_CONTROL::Init(), PAD_TOOL::Init(), PCB_SELECTION_TOOL::Init(), PCB_TOOL_BASE::Init(), PCB_VIEWER_TOOLS::Init(), DRAWING_TOOL::InteractivePlaceWithPreview(), EDA_3D_CONTROLLER::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::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_SELECTION_TOOL::Main(), PCB_PICKER_TOOL::Main(), PCB_SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::MainLoop(), MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), performDragging(), performRouting(), LENGTH_TUNER_TOOL::performTuning(), 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(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace().

◆ m_originalActiveLayer

PCB_LAYER_ID ROUTER_TOOL::m_originalActiveLayer
private

Definition at line 95 of file router_tool.h.

Referenced by finishInteractive(), Init(), and prepareInteractive().

◆ m_router

ROUTER* PNS::TOOL_BASE::m_router
protectedinherited

Definition at line 79 of file pns_tool_base.h.