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( NULL )
44  { }
45 
46  virtual ~COMMON_TOOLS() { }
47 
49  void Reset( RESET_REASON aReason ) override;
50 
51  // View controls
52  int ZoomRedraw( const TOOL_EVENT& aEvent );
53  int ZoomInOut( const TOOL_EVENT& aEvent );
54  int ZoomInOutCenter( const TOOL_EVENT& aEvent );
55  int ZoomCenter( const TOOL_EVENT& aEvent );
56  int ZoomFitScreen( const TOOL_EVENT& aEvent );
57  int ZoomPreset( const TOOL_EVENT& aEvent );
58 
59  int CenterContents( const TOOL_EVENT& aEvent );
60 
61  int PanControl( const TOOL_EVENT& aEvent );
62 
63  // Cursor control
64  int CursorControl( const TOOL_EVENT& aEvent );
65  int ToggleCursor( const TOOL_EVENT& aEvent );
66  int ToggleCursorStyle( const TOOL_EVENT& aEvent );
67 
68  // Units control
69  int ImperialUnits( const TOOL_EVENT& aEvent );
70  int MetricUnits( const TOOL_EVENT& aEvent );
71  int ToggleUnits( const TOOL_EVENT& aEvent );
72 
73  // Grid control
74  int GridNext( const TOOL_EVENT& aEvent );
75  int GridPrev( const TOOL_EVENT& aEvent );
76  int GridPreset( const TOOL_EVENT& aEvent );
77  int ToggleGrid( const TOOL_EVENT& aEvent );
78  int GridProperties( const TOOL_EVENT& aEvent );
79 
81  void setTransitions() override;
82 
83 private:
86 
87  int doZoomInOut( bool aDirection, bool aCenterOnCursor );
88 
90  int doZoomToPreset( int idx, bool aCenterOnCursor );
91 
92  int doGridPreset( int idx );
93 };
94 
95 #endif
int MetricUnits(const TOOL_EVENT &aEvent)
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:85
int ZoomFitScreen(const TOOL_EVENT &aEvent)
int doGridPreset(int idx)
int ToggleCursorStyle(const TOOL_EVENT &aEvent)
int GridPreset(const TOOL_EVENT &aEvent)
The base class for create windows for drawing purpose.
Definition: draw_frame.h:82
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)
virtual ~COMMON_TOOLS()
Definition: common_tools.h:46
int GridPrev(const TOOL_EVENT &aEvent)
int doZoomInOut(bool aDirection, bool aCenterOnCursor)
Class TOOL_EVENT.
Definition: tool_event.h:167
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)
Class COMMON_TOOLS.
Definition: common_tools.h:38
void setTransitions() override
Sets up handlers for various events.
int CenterContents(const TOOL_EVENT &aEvent)
int ZoomPreset(const TOOL_EVENT &aEvent)
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:80
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
int PanControl(const TOOL_EVENT &aEvent)
int ZoomRedraw(const TOOL_EVENT &aEvent)
int GridProperties(const TOOL_EVENT &aEvent)