MIRA
Visualization3DContainer.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 
49 #ifndef _MIRA_VISUALIZATION3DCONTAINER_H_
50 #define _MIRA_VISUALIZATION3DCONTAINER_H_
51 
52 #include <list>
53 
54 #include <widgets/OgreWidgetEx.h>
55 
58 
59 namespace mira {
60 
61 class PropertyEditor;
62 
64 
71 {
72 public:
73  Visualization3DContainer(QWidget* parent=NULL, bool enableOrbitTool = true);
74  virtual ~Visualization3DContainer();
75 
76 public:
77 
82  Visualization3D* addVisualization(const std::string& visualizationClassName);
83 
88  void addVisualization(Visualization3D* vis);
89 
91  std::string getPropertyString(Visualization3D* vis, const std::string& property);
92 
94  template <typename T>
95  T getProperty(Visualization3D* vis, const std::string& property) {
96  return fromString<T>(getPropertyString(vis,property));
97  }
98 
100  void setPropertyString(Visualization3D* vis, const std::string& property, const std::string& value);
101 
103  template <typename T>
104  void setProperty(Visualization3D* vis, const std::string& property, const T& value) {
105  setPropertyString(vis,property,toString<T>(value));
106  }
107 
114  PropertyEditor* getPropertyEditor(QWidget* parent = NULL);
115 
116 public:
117  // implementation of IVisualization3DSite
118  virtual Ogre::SceneManager* getSceneManager();
119 
120  virtual void registerInteractionListener(InteractionListener3D* listener);
121  virtual void removeInteractionListener(InteractionListener3D* listener);
122  virtual std::set<InteractionListener3D*> getInteractionListeners();
123 
124  virtual const Camera& getCamera() const;
125 
126  virtual void setCamera(const Camera& camera);
127 
128  virtual Ogre::Camera* acquireCamera(boost::function<void()> lostCameraCallback = boost::function<void()>());
129 
130  virtual void releaseCamera();
131 
132  virtual const std::string& getFixedFrame() const;
133  virtual const std::string& getCameraFrame() const;
134 
135  void setFixedFrame(const std::string& frame);
136  void setCameraFrame(const std::string& frame);
137 
138 public:
139 
140  virtual void mousePressEvent(QMouseEvent* e);
141  virtual void mouseReleaseEvent(QMouseEvent* e);
142  virtual void mouseMoveEvent(QMouseEvent* e);
143  virtual void wheelEvent(QWheelEvent* e);
144 
145  virtual void timerEvent(QTimerEvent* e);
146 
147 protected:
148 
149  virtual void initOgre();
150 
151 private:
152 
153  void setupVisualizations(bool enableOrbitTool = true);
154 
155 private:
156 
157  mutable Camera mCameraSettings;
158 
159  bool mCameraAcquired;
160  boost::function<void()> mLostCameraCallback;
161 
162  bool mEnableOrbitTool;
163  boost::shared_ptr<VisualizationTool3D> mActiveTool;
164 
165  Time mLastUpdateTime;
166 
167  boost::shared_ptr<PropertyNode> mGeneralProperties;
168  std::map<Visualization3D*, boost::shared_ptr<PropertyNode>> mVisualizations;
169 
170  PropertyEditor* mEditor;
171 
172  std::string mFixedFrame;
173  std::string mCameraFrame;
174 
175  boost::mutex mListenerMutex;
176  std::set<InteractionListener3D*> mListeners;
177 };
178 
180 
181 } // namespace
182 
183 #endif
The interface of a Visualization3DSite.
Definition: Visualization3D.h:84
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
Wrapper class for boost::posix_time::ptime for adding more functionality to it.
Definition: Time.h:416
Declaration of Visualization3D and related classes.
void setProperty(Visualization3D *vis, const std::string &property, const T &value)
Sets the value of the specified property for the specified visualization.
Definition: Visualization3DContainer.h:104
A standalone container for 3D visualizations, similar to Visualization3DView but as lightweight stand...
Definition: Visualization3DContainer.h:70
T getProperty(Visualization3D *vis, const std::string &property)
Returns the value of the specified property for the specified visualization.
Definition: Visualization3DContainer.h:95
#define MIRA_GUI_VISUALIZATION_EXPORT
Definition: GuiVisualizationExports.h:61
Listener for mouse events on movable objects in a 3D view.
Definition: InteractionListener3D.h:66
Extended more advanced derived class of OgreWidget.
Abstract base class for all 3D visualization that are used by Visualization3DView.
Definition: Visualization3D.h:169
Provides display and editing facilities for property items in the editor.
Definition: PropertyEditor.h:74
Extended version of OgreWidget that provides default setup of Ogre components (scene manager...
Definition: OgreWidgetEx.h:80