KiCad PCB EDA Suite
Loading...
Searching...
No Matches
common_tools.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2014-2016 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Maciej Suminski <[email protected]>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
23#ifndef _COMMON_TOOLS_H
24#define _COMMON_TOOLS_H
25
27
28class EDA_DRAW_FRAME;
29
34{
35public:
37
38 ~COMMON_TOOLS() override { }
39
41 void Reset( RESET_REASON aReason ) override;
42
43 int SelectionTool( const TOOL_EVENT& aEvent );
44
45 // View controls
46 int ZoomRedraw( const TOOL_EVENT& aEvent );
47 int ZoomInOut( const TOOL_EVENT& aEvent );
48 int ZoomInOutCenter( const TOOL_EVENT& aEvent );
49 int ZoomCenter( const TOOL_EVENT& aEvent );
50 int ZoomFitScreen( const TOOL_EVENT& aEvent );
51 int ZoomFitObjects( const TOOL_EVENT& aEvent );
52 int ZoomFitSelection( const TOOL_EVENT& aEvent );
53 int ZoomPreset( const TOOL_EVENT& aEvent );
54
55 int CenterContents( const TOOL_EVENT& aEvent );
56 int CenterSelection( const TOOL_EVENT& aEvent );
57
58 int PanControl( const TOOL_EVENT& aEvent );
59
60 // Cursor control
61 int CursorControl( const TOOL_EVENT& aEvent );
62 int ToggleCursor( const TOOL_EVENT& aEvent );
63 int CursorSmallCrosshairs( const TOOL_EVENT& aEvent );
64 int CursorFullCrosshairs( const TOOL_EVENT& aEvent );
65 int Cursor45Crosshairs( const TOOL_EVENT& aEvent );
66
67 int ToggleBoundingBoxes( const TOOL_EVENT& aEvent );
68
69 // Units control
70 int SwitchUnits( const TOOL_EVENT& aEvent );
71 int ToggleUnits( const TOOL_EVENT& aEvent );
72 int TogglePolarCoords( const TOOL_EVENT& aEvent );
73 int ResetLocalCoords( const TOOL_EVENT& aEvent );
74
75 void SetLastUnits( EDA_UNITS aUnit );
78
79 // Grid control
80 int GridNext( const TOOL_EVENT& aEvent );
81 int GridPrev( const TOOL_EVENT& aEvent );
82 int GridPreset( const TOOL_EVENT& aEvent );
83 int GridFast1( const TOOL_EVENT& aEvent );
84 int GridFast2( const TOOL_EVENT& aEvent );
85 int GridFastCycle( const TOOL_EVENT& aEvent );
86 int ToggleGrid( const TOOL_EVENT& aEvent );
87 int ToggleGridOverrides( const TOOL_EVENT& aEvent );
88 int GridProperties( const TOOL_EVENT& aEvent );
89 int GridPreset( int idx, bool aFromHotkey );
90 int GridOrigin( const TOOL_EVENT& aEvent );
91 int OnGridChanged( bool aFromHotkey );
92
93 const std::vector<VECTOR2I> Grids() const { return m_grids; }
94
95private:
105
111
113 void setTransitions() override;
114
117
118 int doZoomInOut( bool aDirection, bool aCenterOnCursor );
119
121 int doZoomToPreset( int idx, bool aCenterOnCursor );
122
123 int doZoomFit( ZOOM_FIT_TYPE_T aFitType );
124
125 int doCenter( CENTER_TYPE aCenterType );
126
127 std::vector<VECTOR2I> m_grids;
129
130 // The last used units in each system (used for toggling between metric and imperial)
133};
134
135#endif
int ZoomFitSelection(const TOOL_EVENT &aEvent)
~COMMON_TOOLS() override
int ZoomCenter(const TOOL_EVENT &aEvent)
int doCenter(CENTER_TYPE aCenterType)
int GridProperties(const TOOL_EVENT &aEvent)
int GridFastCycle(const TOOL_EVENT &aEvent)
int GridOrigin(const TOOL_EVENT &aEvent)
int doZoomToPreset(int idx, bool aCenterOnCursor)
int PanControl(const TOOL_EVENT &aEvent)
EDA_UNITS m_metricUnit
EDA_UNITS m_imperialUnit
int SwitchUnits(const TOOL_EVENT &aEvent)
int CursorSmallCrosshairs(const TOOL_EVENT &aEvent)
int ToggleGrid(const TOOL_EVENT &aEvent)
int GridFast1(const TOOL_EVENT &aEvent)
int Cursor45Crosshairs(const TOOL_EVENT &aEvent)
void SetLastUnits(EDA_UNITS aUnit)
int ToggleUnits(const TOOL_EVENT &aEvent)
int GridFast2(const TOOL_EVENT &aEvent)
int GridNext(const TOOL_EVENT &aEvent)
int OnGridChanged(bool aFromHotkey)
const std::vector< VECTOR2I > Grids() const
void setTransitions() override
Pointer to the currently used edit frame.
int CenterSelection(const TOOL_EVENT &aEvent)
int ZoomPreset(const TOOL_EVENT &aEvent)
int ZoomFitScreen(const TOOL_EVENT &aEvent)
int ToggleBoundingBoxes(const TOOL_EVENT &aEvent)
EDA_UNITS GetLastImperialUnits()
int ToggleGridOverrides(const TOOL_EVENT &aEvent)
std::vector< VECTOR2I > m_grids
Grids from #APP_SETTINGS converted to internal units and with the user grid appended.
int ToggleCursor(const TOOL_EVENT &aEvent)
int CursorFullCrosshairs(const TOOL_EVENT &aEvent)
int ZoomFitObjects(const TOOL_EVENT &aEvent)
int CenterContents(const TOOL_EVENT &aEvent)
int TogglePolarCoords(const TOOL_EVENT &aEvent)
int GridPrev(const TOOL_EVENT &aEvent)
int ZoomInOutCenter(const TOOL_EVENT &aEvent)
int ZoomRedraw(const TOOL_EVENT &aEvent)
int ResetLocalCoords(const TOOL_EVENT &aEvent)
EDA_DRAW_FRAME * m_frame
int doZoomFit(ZOOM_FIT_TYPE_T aFitType)
int CursorControl(const TOOL_EVENT &aEvent)
ZOOM_FIT_TYPE_T
The set of "Zoom to Fit" types that can be performed.
@ ZOOM_FIT_SELECTION
Zoom to fit selected items in view.
@ ZOOM_FIT_ALL
Zoom to fall all items in view INCLUDING page and border.
@ ZOOM_FIT_OBJECTS
Zoom to fit all items in view EXCLUDING page and border.
int SelectionTool(const TOOL_EVENT &aEvent)
EDA_UNITS GetLastMetricUnits()
int GridPreset(const TOOL_EVENT &aEvent)
int ZoomInOut(const TOOL_EVENT &aEvent)
int doZoomInOut(bool aDirection, bool aCenterOnCursor)
Note: idx == 0 is Auto; idx == 1 is first entry in zoomList.
The base class for create windows for drawing purpose.
RESET_REASON
Determine the reason of reset for a tool.
Definition tool_base.h:74
Generic, UI-independent tool event.
Definition tool_event.h:167
TOOL_INTERACTIVE(TOOL_ID aId, const std::string &aName)
Create a tool with given id & name.
EDA_UNITS
Definition eda_units.h:44
void Reset() override