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 ZoomFitObjects( const TOOL_EVENT& aEvent );
60  int ZoomPreset( const TOOL_EVENT& aEvent );
61 
62  int CenterContents( const TOOL_EVENT& aEvent );
63 
64  int PanControl( const TOOL_EVENT& aEvent );
65 
66  // Cursor control
67  int CursorControl( const TOOL_EVENT& aEvent );
68  int ToggleCursor( const TOOL_EVENT& aEvent );
69  int ToggleCursorStyle( const TOOL_EVENT& aEvent );
70 
71  // Units control
72  int ImperialUnits( const TOOL_EVENT& aEvent );
73  int MetricUnits( const TOOL_EVENT& aEvent );
74  int ToggleUnits( const TOOL_EVENT& aEvent );
75  int TogglePolarCoords( const TOOL_EVENT& aEvent );
76  int ResetLocalCoords( const TOOL_EVENT& aEvent );
77 
78  // Grid control
79  int GridNext( const TOOL_EVENT& aEvent );
80  int GridPrev( const TOOL_EVENT& aEvent );
81  int GridPreset( const TOOL_EVENT& aEvent );
82  int GridFast1( const TOOL_EVENT& aEvent );
83  int GridFast2( const TOOL_EVENT& aEvent );
84  int ToggleGrid( const TOOL_EVENT& aEvent );
85  int GridProperties( const TOOL_EVENT& aEvent );
86  int GridPreset( int idx );
87  int OnGridChanged();
88 
89  int SwitchCanvas( const TOOL_EVENT& aEvent );
90 
91 private:
97  {
98  ZOOM_FIT_ALL, // Zoom to fall all items in view INCLUDING page and border
99  ZOOM_FIT_OBJECTS, // Zoom to fit all items in view EXCLUDING page and border
100  };
101 
103  void setTransitions() override;
104 
107 
108  int doZoomInOut( bool aDirection, bool aCenterOnCursor );
109 
111  int doZoomToPreset( int idx, bool aCenterOnCursor );
112 
113  int doZoomFit( ZOOM_FIT_TYPE_T aFitType );
114 
115  std::vector<VECTOR2I> m_grids; // grids from APP_SETTINGS converted to internal units
116  // and with the user grid appended
117 };
118 
119 #endif
int MetricUnits(const TOOL_EVENT &aEvent)
EDA_DRAW_FRAME * m_frame
Pointer to the currently used edit frame.
Definition: common_tools.h:106
~COMMON_TOOLS() override
Definition: common_tools.h:46
int ZoomFitScreen(const TOOL_EVENT &aEvent)
int GridFast1(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 GridFast2(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)
TOOL_EVENT.
Definition: tool_event.h:171
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)
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)
std::vector< VECTOR2I > m_grids
Definition: common_tools.h:115
ZOOM_FIT_TYPE_T
Enum ZOOM_FIT_TYPE_T is the set of "Zoom to Fit" types that can be performed.
Definition: common_tools.h:96
int ZoomPreset(const TOOL_EVENT &aEvent)
int ZoomFitObjects(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)
int doZoomFit(ZOOM_FIT_TYPE_T aFitType)