MIRA
VisualizationTool.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 by
3  * MetraLabs GmbH (MLAB), GERMANY
4  * and
5  * Neuroinformatics and Cognitive Robotics Labs (NICR) at TU Ilmenau, GERMANY
6  * All rights reserved.
7  *
8  * Contact: info@mira-project.org
9  *
10  * Commercial Usage:
11  * Licensees holding valid commercial licenses may use this file in
12  * accordance with the commercial license agreement provided with the
13  * software or, alternatively, in accordance with the terms contained in
14  * a written agreement between you and MLAB or NICR.
15  *
16  * GNU General Public License Usage:
17  * Alternatively, this file may be used under the terms of the GNU
18  * General Public License version 3.0 as published by the Free Software
19  * Foundation and appearing in the file LICENSE.GPL3 included in the
20  * packaging of this file. Please review the following information to
21  * ensure the GNU General Public License version 3.0 requirements will be
22  * met: http://www.gnu.org/copyleft/gpl.html.
23  * Alternatively you may (at your option) use any later version of the GNU
24  * General Public License if such license has been publicly approved by
25  * MLAB and NICR (or its successors, if any).
26  *
27  * IN NO EVENT SHALL "MLAB" OR "NICR" BE LIABLE TO ANY PARTY FOR DIRECT,
28  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
29  * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLAB" OR
30  * "NICR" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * "MLAB" AND "NICR" SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
33  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
34  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
35  * ON AN "AS IS" BASIS, AND "MLAB" AND "NICR" HAVE NO OBLIGATION TO
36  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
37  */
38 
47 #include <QtGui/QIcon>
48 
50 
51 
52 #ifndef _MIRA_VISUALIZATIONTOOL_H_
53 #define _MIRA_VISUALIZATIONTOOL_H_
54 
55 namespace mira {
56 
58 
60  : public Object, public IAuthorityProvider, public Authority
61 {
63 public:
64 
66  virtual ~VisualizationTool() {};
67 
68 public:
69 
70  template <typename Reflector>
71  void reflect(Reflector& r)
72  {
73  r.itemName(this->getClass().getMetaInfo("Name"));
74  }
75 
76 public:
77 
82  virtual void init(IVisualizationSite* site);
83 
89  virtual IVisualizationSite* getSite() = 0;
90 
91 public:
92 
96  virtual QIcon getIcon() = 0;
97 
98 
107  virtual int getDisplaceShortCut() const { return 0; }
108 
109 
110 
111 public:
112 
114  virtual void activate() {}
115 
117  virtual void deactivate() {}
118 
119 public:
120 
127  virtual void processUpdate(Duration dt) { update(dt); }
128 
129 protected:
134  virtual void update(Duration dt) {
135  onUpdate(dt); // Only for backward compatibility
136  }
137 
142  virtual void onUpdate(Duration dt) {}
143 
144 public:
145 
147  virtual void onMousePressed(QMouseEvent* e) {}
148  virtual void onMousePressed(QMouseEvent* e, float devicePixelRatio) { onMousePressed(e); }
150  virtual void onMouseReleased(QMouseEvent* e) {}
151  virtual void onMouseReleased(QMouseEvent* e, float devicePixelRatio) { onMouseReleased(e); }
153  virtual void onMouseDoubleClick(QMouseEvent* e) {}
154  virtual void onMouseDoubleClick(QMouseEvent* e, float devicePixelRatio) { onMouseDoubleClick(e); }
156  virtual void onMouseMoved(QMouseEvent* e) {}
157  virtual void onMouseMoved(QMouseEvent* e, float devicePixelRatio) { onMouseMoved(e); }
159  virtual void onMouseWheel(QWheelEvent * e) {}
160  virtual void onMouseWheel(QWheelEvent * e, float devicePixelRatio) { onMouseWheel(e); }
161 
162 protected:
163 
164  void updateToolTip(QMouseEvent* e, const QString& text);
165 
166 public: // implementation of IAuthorityProvider
167 
168  virtual Authority& getAuthority();
169 
170 protected:
171 
172  QString mLastToolTip;
173 };
174 
176 
177 }
178 
179 #endif
QString mLastToolTip
Definition: VisualizationTool.h:172
void reflect(Reflector &r)
Definition: VisualizationTool.h:71
Definition: VisualizationTool.h:59
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
virtual void onMouseReleased(QMouseEvent *e, float devicePixelRatio)
Definition: VisualizationTool.h:151
virtual void onMouseWheel(QWheelEvent *e)
Called if the tool is active and the mouse wheel was moved.
Definition: VisualizationTool.h:159
virtual void deactivate()
called when the user has deactivated the tool by selecting another one.
Definition: VisualizationTool.h:117
virtual void onMouseDoubleClick(QMouseEvent *e)
Called if the tool is active and a double click as occurred.
Definition: VisualizationTool.h:153
#define MIRA_ABSTRACT_OBJECT(classIdentifier)
Use this MACRO instead of MIRA_OBJECT to declare the class as abstract.
Definition: FactoryMacros.h:235
The primary interface between a Visualization and the container of the visualization (e...
Definition: Visualization.h:65
Declaration of Visualization and related classes.
Abstract interface for classes that can provide an authority via the getAuthority() method...
Definition: AuthorityProvider.h:61
Use this class to represent time durations.
Definition: Time.h:104
The object class acts as a generic base class for classes which should be used with the classFactory...
Definition: Object.h:144
Authorities act as a facade to the framework.
Definition: Authority.h:94
virtual void onUpdate(Duration dt)
Definition: VisualizationTool.h:142
#define MIRA_GUI_VISUALIZATION_EXPORT
Definition: GuiVisualizationExports.h:61
virtual void onMouseReleased(QMouseEvent *e)
Called if the tool is active and a mouse button was released.
Definition: VisualizationTool.h:150
virtual int getDisplaceShortCut() const
A tool may return a shortcut key that temporarily activates the tool.
Definition: VisualizationTool.h:107
virtual void onMousePressed(QMouseEvent *e, float devicePixelRatio)
Definition: VisualizationTool.h:148
virtual ~VisualizationTool()
Definition: VisualizationTool.h:66
virtual void onMouseMoved(QMouseEvent *e)
Called if the tool is active and the mouse was moved.
Definition: VisualizationTool.h:156
virtual void processUpdate(Duration dt)
Is called regularly by the VisualizationView if the tool is active to update the tool.
Definition: VisualizationTool.h:127
virtual void onMousePressed(QMouseEvent *e)
Called if the tool is active and a mouse button was pressed.
Definition: VisualizationTool.h:147
virtual void update(Duration dt)
This method can be implemented in the derived classes.
Definition: VisualizationTool.h:134
virtual void onMouseWheel(QWheelEvent *e, float devicePixelRatio)
Definition: VisualizationTool.h:160
virtual void onMouseMoved(QMouseEvent *e, float devicePixelRatio)
Definition: VisualizationTool.h:157
virtual void onMouseDoubleClick(QMouseEvent *e, float devicePixelRatio)
Definition: VisualizationTool.h:154
virtual void activate()
called when the user has activated the tool.
Definition: VisualizationTool.h:114