KiCad PCB EDA Suite
picker_tool.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) 2015 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 PICKER_TOOL_H
26 #define PICKER_TOOL_H
27 
28 #include <boost/optional/optional.hpp>
29 
30 #include "pcb_tool.h"
34 class PICKER_TOOL : public PCB_TOOL
35 {
36 public:
37  PICKER_TOOL();
39 
41  typedef std::function<bool(const VECTOR2D&)> CLICK_HANDLER;
42  typedef std::function<void(void)> CANCEL_HANDLER;
43 
45  void Reset( RESET_REASON aReason ) override {}
46 
48  int Main( const TOOL_EVENT& aEvent );
49 
54  inline void SetSnapping( bool aEnable ) { m_cursorSnapping = aEnable; }
55 
60  inline void SetCursorVisible( bool aEnable ) { m_cursorVisible = aEnable; }
61 
66  inline void SetAutoPanning( bool aEnable ) { m_autoPanning = aEnable; }
67 
72  inline void SetCursorCapture( bool aEnable ) { m_cursorCapture = aEnable; }
73 
78  inline void SetLayerSet( LSET aLayerSet ) { m_layerMask = aLayerSet; }
79 
85  inline void SetClickHandler( CLICK_HANDLER aHandler )
86  {
87  assert( !m_clickHandler );
88  m_clickHandler = aHandler;
89  }
90 
95  inline void SetCancelHandler( CANCEL_HANDLER aHandler )
96  {
97  assert( !m_cancelHandler );
98  m_cancelHandler = aHandler;
99  }
100 
102  void setTransitions() override;
103 
104 private:
105  // Tool settings.
110 
113 
117 
120 
122  void reset();
123 
125  void setControls();
126 };
127 
128 #endif /* PICKER_TOOL_H */
void SetSnapping(bool aEnable)
Function SetSnapping() Sets cursor snapping to grid for the period when the tool is active...
Definition: picker_tool.h:54
bool m_autoPanning
Definition: picker_tool.h:109
int Main(const TOOL_EVENT &aEvent)
Main event loop.
Definition: picker_tool.cpp:43
void SetClickHandler(CLICK_HANDLER aHandler)
Function SetClickHandler() Sets a handler for mouse click event.
Definition: picker_tool.h:85
bool m_cursorSnapping
Definition: picker_tool.h:106
void Reset(RESET_REASON aReason) override
>
Definition: picker_tool.h:45
std::function< void(void)> CANCEL_HANDLER
Definition: picker_tool.h:42
std::function< bool(const VECTOR2D &)> CLICK_HANDLER
Event handler types.
Definition: picker_tool.h:41
bool m_cursorVisible
Definition: picker_tool.h:107
void SetAutoPanning(bool aEnable)
Function SetAutoPanning() Sets autopanning mode for the period when the tool is active.
Definition: picker_tool.h:66
Generic tool for picking a point.
Definition: picker_tool.h:34
OPT< VECTOR2D > m_picked
Picked point (if any).
Definition: picker_tool.h:119
LSET m_layerMask
The layer set to use for optional snapping
Definition: picker_tool.h:112
Class LSET is a set of PCB_LAYER_IDs.
void setTransitions() override
>
bool m_cursorCapture
Definition: picker_tool.h:108
Class TOOL_EVENT.
Definition: tool_event.h:168
void reset()
Reinitializes tool to its initial state.
OPT< CLICK_HANDLER > m_clickHandler
Optional event handlers.
Definition: picker_tool.h:115
void setControls()
Applies the requested VIEW_CONTROLS settings.
void SetCancelHandler(CANCEL_HANDLER aHandler)
Function SetCancelHandler() Sets a handler for cancel events (ESC or context-menu Cancel)...
Definition: picker_tool.h:95
void SetLayerSet(LSET aLayerSet)
Function SetLayerSet() Sets the tool&#39;s snap layer set.
Definition: picker_tool.h:78
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:80
boost::optional< T > OPT
Definition: optional.h:7
OPT< CANCEL_HANDLER > m_cancelHandler
Definition: picker_tool.h:116
void SetCursorVisible(bool aEnable)
Function SetCursorVisible() Sets cursor visibility for the period when the tool is active...
Definition: picker_tool.h:60
void SetCursorCapture(bool aEnable)
Function SetAutoPanning() Toggles cursor capture mode for the period when the tool is active...
Definition: picker_tool.h:72