KiCad PCB EDA Suite
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  * @author Maciej Suminski <maciej.suminski@cern.ch>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #ifndef _COMMON_TOOLS_H
26 #define _COMMON_TOOLS_H
27 
28 #include <tool/tool_interactive.h>
29 
30 class EDA_DRAW_FRAME;
31 
39 {
40 public:
42  TOOL_INTERACTIVE( "common.Control" ),
43  m_frame( nullptr )
44  { }
45 
46  ~COMMON_TOOLS() override { }
47 
49  void Reset( RESET_REASON aReason ) override;
50 
51  int SelectionTool( const TOOL_EVENT& aEvent );
52 
53  // View controls
54  int ZoomRedraw( const TOOL_EVENT& aEvent );
55  int ZoomInOut( const TOOL_EVENT& aEvent );
56  int ZoomInOutCenter( const TOOL_EVENT& aEvent );
57  int ZoomCenter( const TOOL_EVENT& aEvent );
58  int ZoomFitScreen( const TOOL_EVENT& aEvent );
59  int ZoomPreset( const TOOL_EVENT& aEvent );
60 
61  int CenterContents( const TOOL_EVENT& aEvent );
62 
63  int PanControl( const TOOL_EVENT& aEvent );
64 
65  // Cursor control
66  int CursorControl( const TOOL_EVENT& aEvent );
67  int ToggleCursor( const TOOL_EVENT& aEvent );
68  int ToggleCursorStyle( const TOOL_EVENT& aEvent );
69 
70  // Units control
71  int ImperialUnits( const TOOL_EVENT& aEvent );
72  int MetricUnits( const TOOL_EVENT& aEvent );
73  int ToggleUnits( const TOOL_EVENT& aEvent );
74  int TogglePolarCoords( const TOOL_EVENT& aEvent );
75  int ResetLocalCoords( const TOOL_EVENT& aEvent );
76 
77  // Grid control
78  int GridNext( const TOOL_EVENT& aEvent );
79  int GridPrev( const TOOL_EVENT& aEvent );
80  int GridPreset( const TOOL_EVENT& aEvent );
81  int ToggleGrid( const TOOL_EVENT& aEvent );
82  int GridProperties( const TOOL_EVENT& aEvent );
83  int GridPreset( int idx );
84 
85  int SwitchCanvas( const TOOL_EVENT& aEvent );
86 
87 private:
89  void setTransitions() override;
90 
93 
94  int doZoomInOut( bool aDirection, bool aCenterOnCursor );
95 
97  int doZoomToPreset( int idx, bool aCenterOnCursor );
98 };
99 
100 #endif
int MetricUnits(const TOOL_EVENT &aEvent)
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:92
~COMMON_TOOLS() override
Definition: common_tools.h:46
int ZoomFitScreen(const TOOL_EVENT &aEvent)
int ToggleCursorStyle(const TOOL_EVENT &aEvent)
int GridPreset(const TOOL_EVENT &aEvent)
int ResetLocalCoords(const TOOL_EVENT &aEvent)
The base class for create windows for drawing purpose.
int doZoomToPreset(int idx, bool aCenterOnCursor)
Note: idx == 0 is Auto; idx == 1 is first entry in zoomList
int ImperialUnits(const TOOL_EVENT &aEvent)
int GridNext(const TOOL_EVENT &aEvent)
int ToggleUnits(const TOOL_EVENT &aEvent)
int ZoomInOutCenter(const TOOL_EVENT &aEvent)
int GridPrev(const TOOL_EVENT &aEvent)
int doZoomInOut(bool aDirection, bool aCenterOnCursor)
Class TOOL_EVENT.
Definition: tool_event.h:168
int ZoomCenter(const TOOL_EVENT &aEvent)
int ToggleGrid(const TOOL_EVENT &aEvent)
int ZoomInOut(const TOOL_EVENT &aEvent)
int CursorControl(const TOOL_EVENT &aEvent)
int ToggleCursor(const TOOL_EVENT &aEvent)
int SwitchCanvas(const TOOL_EVENT &aEvent)
Class COMMON_TOOLS.
Definition: common_tools.h:38
void setTransitions() override
Sets up handlers for various events.
int CenterContents(const TOOL_EVENT &aEvent)
int SelectionTool(const TOOL_EVENT &aEvent)
int ZoomPreset(const TOOL_EVENT &aEvent)
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:79
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
int TogglePolarCoords(const TOOL_EVENT &aEvent)
int PanControl(const TOOL_EVENT &aEvent)
int ZoomRedraw(const TOOL_EVENT &aEvent)
int GridProperties(const TOOL_EVENT &aEvent)