KiCad PCB EDA Suite
Loading...
Searching...
No Matches
router_tool.h
Go to the documentation of this file.
1/*
2 * KiRouter - a push-and-(sometimes-)shove PCB router
3 *
4 * Copyright (C) 2013-2017 CERN
5 * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
6 * Author: Tomasz Wlostowski <[email protected]>
7 * Author: Maciej Suminski <[email protected]>
8 *
9 * This program is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation, either version 3 of the License, or (at your
12 * option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23#ifndef __ROUTER_TOOL_H
24#define __ROUTER_TOOL_H
25
26#include "pns_tool_base.h"
27
29
31{
32public:
35
36 bool Init() override;
37 void Reset( RESET_REASON aReason ) override;
38
39 int MainLoop( const TOOL_EVENT& aEvent );
40 int RouteSelected( const TOOL_EVENT& aEvent );
41
42 int InlineBreakTrack( const TOOL_EVENT& aEvent );
43 bool CanInlineDrag( int aDragMode );
44 int InlineDrag( const TOOL_EVENT& aEvent );
45
46 int SelectCopperLayerPair( const TOOL_EVENT& aEvent );
47 int DpDimensionsDialog( const TOOL_EVENT& aEvent );
48 int SettingsDialog( const TOOL_EVENT& aEvent );
49 int ChangeRouterMode( const TOOL_EVENT& aEvent );
50 int CycleRouterMode( const TOOL_EVENT& aEvent );
51 int CustomTrackWidthDialog( const TOOL_EVENT& aEvent );
52
54
61 bool RoutingInProgress();
62
63 void setTransitions() override;
64
65 // A filter for narrowing a collection representing a simple corner
66 // or a non-fanout-via to a single PCB_TRACK item.
67 static void NeighboringSegmentFilter( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector,
68 PCB_SELECTION_TOOL* aSelTool );
69
70 void UpdateMessagePanel();
71
72private:
73 void performRouting( VECTOR2D aStartPosition );
74 void performDragging( int aMode = PNS::DM_ANY );
75 void breakTrack();
76 void restoreSelection( const PCB_SELECTION& aOriginalSelection );
77
78 void handleCommonEvents( TOOL_EVENT& evt );
79 int handleLayerSwitch( const TOOL_EVENT& aEvent, bool aForceVia );
80
81 // Returns the board layer ID for the start layer of the router
82 PCB_LAYER_ID getStartLayer( const PNS::ITEM* aItem );
83
85 void updateSizesAfterRouterEvent( int targetLayer, const VECTOR2I& aPos );
86
87 int onLayerCommand( const TOOL_EVENT& aEvent );
88 int onViaCommand( const TOOL_EVENT& aEvent );
89 int onTrackViaSizeChanged( const TOOL_EVENT& aEvent );
90
91 bool prepareInteractive( VECTOR2D aStartPosition );
92 bool finishInteractive();
93 void saveRouterDebugLog();
94
95private:
96 std::shared_ptr<ACTION_MENU> m_diffPairMenu;
97 std::shared_ptr<ACTION_MENU> m_trackViaMenu;
98
99 // Both of these are in board layer ID format and must be converted to PNS layer ID format
100 // when used with the PNS interface.
103
104 bool m_inRouterTool; // Re-entrancy guard
105};
106
107#endif
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:202
The selection tool: currently supports:
Base class for PNS router board items.
Definition: pns_item.h:97
int onViaCommand(const TOOL_EVENT &aEvent)
int InlineDrag(const TOOL_EVENT &aEvent)
std::shared_ptr< ACTION_MENU > m_trackViaMenu
Definition: router_tool.h:97
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
int onTrackViaSizeChanged(const TOOL_EVENT &aEvent)
int CustomTrackWidthDialog(const TOOL_EVENT &aEvent)
static void NeighboringSegmentFilter(const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector, PCB_SELECTION_TOOL *aSelTool)
PNS::PNS_MODE GetRouterMode()
void saveRouterDebugLog()
void performDragging(int aMode=PNS::DM_ANY)
PCB_LAYER_ID m_originalActiveLayer
Definition: router_tool.h:102
int onLayerCommand(const TOOL_EVENT &aEvent)
PCB_LAYER_ID getStartLayer(const PNS::ITEM *aItem)
int CycleRouterMode(const TOOL_EVENT &aEvent)
void updateSizesAfterRouterEvent(int targetLayer, const VECTOR2I &aPos)
bool m_inRouterTool
Definition: router_tool.h:104
int handleLayerSwitch(const TOOL_EVENT &aEvent, bool aForceVia)
void switchLayerOnViaPlacement()
int RouteSelected(const TOOL_EVENT &aEvent)
bool finishInteractive()
int ChangeRouterMode(const TOOL_EVENT &aEvent)
std::shared_ptr< ACTION_MENU > m_diffPairMenu
Definition: router_tool.h:96
PCB_LAYER_ID m_lastTargetLayer
Definition: router_tool.h:101
void handleCommonEvents(TOOL_EVENT &evt)
void performRouting(VECTOR2D aStartPosition)
bool Init() override
Init() is called once upon a registration of the tool.
int InlineBreakTrack(const TOOL_EVENT &aEvent)
bool prepareInteractive(VECTOR2D aStartPosition)
void restoreSelection(const PCB_SELECTION &aOriginalSelection)
bool RoutingInProgress()
Returns whether routing is currently active.
void breakTrack()
void UpdateMessagePanel()
int MainLoop(const TOOL_EVENT &aEvent)
bool CanInlineDrag(int aDragMode)
int SettingsDialog(const TOOL_EVENT &aEvent)
int DpDimensionsDialog(const TOOL_EVENT &aEvent)
int SelectCopperLayerPair(const TOOL_EVENT &aEvent)
Definition: sel_layer.cpp:748
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
Generic, UI-independent tool event.
Definition: tool_event.h:167
void Reset() override
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
PNS_MODE
< Routing modes
@ DM_ANY
Definition: pns_router.h:77