MIRA
Visualization3D.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 #ifndef _MIRA_VISUALIZATION3D_H_
48 #define _MIRA_VISUALIZATION3D_H_
49 
50 #include <math/Angle.h>
51 #include <geometry/Point.h>
53 
55 
56 // Ogre forward decls
57 namespace Ogre {
58  class SceneManager;
59  class Camera;
60  class SceneNode;
61 }
62 
63 class QMouseEvent;
64 
66 
67 namespace mira {
68 
69 class InteractionListener3D;
70 
72 
85 {
86 public:
87  virtual ~IVisualization3DSite() {}
88 
89  virtual Ogre::SceneManager* getSceneManager() = 0;
90 
91  virtual void registerInteractionListener(InteractionListener3D* listener) = 0;
92  virtual void removeInteractionListener(InteractionListener3D* listener) = 0;
93  virtual std::set<InteractionListener3D*> getInteractionListeners() = 0;
94 
95 public:
96 
98  {
99  public:
100 
101  Camera();
102 
103  template <typename Reflector>
104  void reflect(Reflector& r)
105  {
106  r.property("X", position.x(), "the position of the camera");
107  r.property("Y", position.y(), "the position of the camera");
108  r.property("Z", position.z(), "the position of the camera");
109  r.property("Yaw",
110  rad2degGetter(yaw),
111  deg2radSetter(yaw),
112  "the orientation of the camera");
113  r.property("Pitch",
114  rad2degGetter(pitch),
115  deg2radSetter(pitch),
116  "the orientation of the camera");
117  r.property("Roll",
118  rad2degGetter(roll),
119  deg2radSetter(roll),
120  "the orientation of the camera");
121  r.property("Distance", distance, "the zoom or distance");
122  }
123 
124  void lookAt(const Point3f& from, const Point3f& to);
125 
126  // The camera rotation and translation, specified by mouse interaction
127 
129  float yaw, pitch, roll;
130  float distance;
131  };
132 
137  virtual const Camera& getCamera() const = 0;
138 
143  virtual void setCamera(const Camera& camera) = 0;
144 
155  virtual Ogre::Camera* acquireCamera(boost::function<void()> lostCameraCallback = boost::function<void()>()) = 0;
156 
160  virtual void releaseCamera() = 0;
161 };
162 
164 
170  public Visualization
171 {
173 public:
174 
175  Visualization3D();
176  virtual ~Visualization3D() {}
177 
178 public:
179 
191  virtual void init(IVisualizationSite* site);
192 
193 public:
194 
200  virtual IVisualization3DSite* getSite();
201 
202 public:
203 
211  virtual void setupScene(IVisualization3DSite* site) = 0;
212 
217  virtual Ogre::SceneNode* getNode() = 0;
218 
219 private:
220 
221  IVisualization3DSite* mSite;
222 
223 };
224 
226 
227 }
228 
229 #endif
The interface of a Visualization3DSite.
Definition: Visualization3D.h:84
Definition: Visualization3D.h:97
virtual void setCamera(const Camera &camera)=0
Sets the current camera settings (position, orientation, etc.) of the views own camera.
Getter< T > rad2degGetter(const T &cref)
Create a getter for serializing radians as degrees.
Definition: Angle.h:969
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
virtual const Camera & getCamera() const =0
Obtains the current camera settings (position, orientation, etc.) of the views own camera...
float distance
Definition: Visualization3D.h:130
Abstract base class for all derived visualizations, namely Visualization3D and Visualization2D.
Definition: Visualization.h:90
Class for 2D, 3D and N-dimensional points.
The interface between a Visualization and the container of the visualization (e.g.
Definition: Visualization.h:75
#define MIRA_ABSTRACT_OBJECT(classIdentifier)
Use this MACRO instead of MIRA_OBJECT to declare the class as abstract.
Definition: FactoryMacros.h:235
Setter< T > deg2radSetter(T &ref)
Create setter for deserializing radians from degrees. See rad2degGetter.
Definition: Angle.h:988
The primary interface between a Visualization and the container of the visualization (e...
Definition: Visualization.h:65
Declaration of Visualization and related classes.
virtual Ogre::Camera * acquireCamera(boost::function< void()> lostCameraCallback=boost::function< void()>())=0
Requests the camera of the visualization site.
virtual void removeInteractionListener(InteractionListener3D *listener)=0
Implementations of angles (values in periodic interval of width 2*pi) with arbitrary base type...
virtual void releaseCamera()=0
Releases a camera that previously was acquired.
virtual std::set< InteractionListener3D * > getInteractionListeners()=0
#define MIRA_GUI_VISUALIZATION_EXPORT
Definition: GuiVisualizationExports.h:61
Listener for mouse events on movable objects in a 3D view.
Definition: InteractionListener3D.h:66
float yaw
Definition: Visualization3D.h:129
virtual void registerInteractionListener(InteractionListener3D *listener)=0
Point3f position
Definition: Visualization3D.h:128
void reflect(Reflector &r)
Definition: Visualization3D.h:104
virtual ~Visualization3D()
Definition: Visualization3D.h:176
Definition: ImageObject.h:60
Abstract base class for all 3D visualization that are used by Visualization3DView.
Definition: Visualization3D.h:169
virtual ~IVisualization3DSite()
Definition: Visualization3D.h:87
virtual Ogre::SceneManager * getSceneManager()=0