MIRA
Visualization2DContainer.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 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 #ifndef _MIRA_VISUALIZATION2DCONTAINER_H_
48 #define _MIRA_VISUALIZATION2DCONTAINER_H_
49 
51 
52 #include <QEvent>
53 #include <QGraphicsScene>
54 #include <QGraphicsView>
55 #include <QtGui/QMouseEvent>
56 
58 
59 namespace mira {
60 
61 class PropertyEditor;
62 
64 
66 {
67  Q_OBJECT
68 public:
69  Visualization2DContainer(QWidget* parent = NULL, bool enableOrbitTool = true);
70  virtual ~Visualization2DContainer();
71 
72  Visualization2D* addVisualization(const std::string& visualizationClassName);
73  void addVisualization(Visualization2D* vis);
74 
75  void removeVisualization(Visualization2D* vis);
76 
77 public:
78  virtual QGraphicsScene* getSceneManager();
79  virtual QGraphicsView* getViewManager();
80 
81  virtual const Camera& getCamera() const;
82  virtual void setCamera(const Camera& camera);
83 
84  virtual float getToolBaseZValue() const;
85 
86  virtual const std::string& getFixedFrame() const;
87  virtual const std::string& getCameraFrame() const;
88 
89  virtual void setFixedFrame(const std::string& frame);
90  virtual void setCameraFrame(const std::string& frame);
91 
92  virtual void setBackgroundColor(const QColor& color);
93  virtual void fitRectInView(const QRectF& rect);
94 
95 public: // Access properties of visualizations
96  std::string getPropertyString(Visualization2D* vis, const std::string& property);
97  template <typename T> T getProperty(Visualization2D* vis, const std::string& property) {
98  return fromString<T>(getPropertyString(vis,property));
99  }
100 
101  void setPropertyString(Visualization2D* vis, const std::string& property, const std::string& value);
102  template <typename T> void setProperty(Visualization2D* vis, const std::string& property, const T& value) {
103  setPropertyString(vis,property,toString<T>(value));
104  }
105 
106  // Create an editor widget (hidden, parentless) or return the existing one
107  PropertyEditor* getPropertyEditor(QWidget* parent = NULL);
108 
109 protected: // Interface for derived classes
110  virtual void processUpdate(Duration d) {}
111 
112 protected:
113  virtual void mousePressEvent(QMouseEvent* event);
114  virtual void mouseMoveEvent(QMouseEvent* event);
115  virtual void mouseReleaseEvent(QMouseEvent* event);
116  virtual void wheelEvent (QWheelEvent* event);
117  virtual void timerEvent(QTimerEvent* e);
118 
119 protected:
120  virtual void updateCamera();
121  virtual void setupVisualizations(bool enableOrbitTool = true);
122 
124 
125  QGraphicsScene* mScene;
127 
128  boost::shared_ptr<VisualizationTool2D> mActiveTool;
129 
131 
132  boost::shared_ptr<PropertyNode> mGeneralProperties;
133  std::map<Visualization2D*, boost::shared_ptr<PropertyNode>> mVisualizations;
134 
136 
137  std::string mFixedFrame;
138  std::string mCameraFrame;
139 };
140 
142 
143 }
144 
145 #endif
std::map< Visualization2D *, boost::shared_ptr< PropertyNode > > mVisualizations
Definition: Visualization2DContainer.h:133
PropertyEditor * mEditor
Definition: Visualization2DContainer.h:135
Definition: Visualization2D.h:73
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
void setProperty(Visualization2D *vis, const std::string &property, const T &value)
Definition: Visualization2DContainer.h:102
Abstract base class for all 2D visualization that are used by Visualization2DView.
Definition: Visualization2D.h:120
boost::shared_ptr< PropertyNode > mGeneralProperties
Definition: Visualization2DContainer.h:132
std::string mCameraFrame
Definition: Visualization2DContainer.h:138
Wrapper class for boost::posix_time::ptime for adding more functionality to it.
Definition: Time.h:418
boost::shared_ptr< VisualizationTool2D > mActiveTool
Definition: Visualization2DContainer.h:128
QGraphicsScene * mScene
Definition: Visualization2DContainer.h:125
Camera mCameraSettings
Definition: Visualization2DContainer.h:123
virtual void processUpdate(Duration d)
Definition: Visualization2DContainer.h:110
Use this class to represent time durations.
Definition: Time.h:106
Declaration of VisualizationTool2D.
#define MIRA_GUI_VISUALIZATION_EXPORT
Definition: GuiVisualizationExports.h:61
Definition: Visualization2D.h:64
Time mLastUpdateTime
Definition: Visualization2DContainer.h:130
std::string mFixedFrame
Definition: Visualization2DContainer.h:137
Declaration of Visualization2D and related classes.
Provides display and editing facilities for property items in the editor.
Definition: PropertyEditor.h:74
QColor mBackgroundColor
Definition: Visualization2DContainer.h:126
T getProperty(Visualization2D *vis, const std::string &property)
Definition: Visualization2DContainer.h:97
Definition: Visualization2DContainer.h:65