view_controller.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef RVIZ_VIEW_CONTROLLER_H
31 #define RVIZ_VIEW_CONTROLLER_H
32 
33 #include <string>
34 
35 #include <QCursor>
36 
38 #include "rviz/rviz_export.h"
39 
40 class QKeyEvent;
41 
42 namespace Ogre
43 {
44 class Camera;
45 class SceneNode;
46 class Vector3;
47 class Quaternion;
48 } // namespace Ogre
49 
50 namespace rviz
51 {
52 class DisplayContext;
53 class EnumProperty;
54 class RenderPanel;
55 class ViewportMouseEvent;
56 class FloatProperty;
57 class BoolProperty;
58 
59 class RVIZ_EXPORT ViewController : public Property
60 {
61  Q_OBJECT
62 public:
64  ~ViewController() override;
65 
71  void initialize(DisplayContext* context);
72 
73  static QString formatClassId(const QString& class_id);
74 
77  QVariant getViewData(int column, int role) const override;
78 
80  Qt::ItemFlags getViewFlags(int column) const override;
81 
86  void activate();
87 
90  virtual void update(float dt, float ros_dt)
91  {
92  (void)dt;
93  (void)ros_dt;
94  }
95 
97  {
98  (void)evt;
99  }
100 
105  virtual void handleKeyEvent(QKeyEvent* event, RenderPanel* panel);
106 
108  void lookAt(float x, float y, float z);
109 
113  virtual void lookAt(const Ogre::Vector3& point)
114  {
115  (void)point;
116  }
117 
120  virtual void reset() = 0;
121 
129  virtual void mimic(ViewController* source_view)
130  {
131  (void)source_view;
132  }
133 
142  virtual void transitionFrom(ViewController* previous_view)
143  {
144  (void)previous_view;
145  }
146 
149  void emitConfigChanged();
150 
151  Ogre::Camera* getCamera() const
152  {
153  return camera_;
154  }
155 
159  virtual QString getClassId() const
160  {
161  return class_id_;
162  }
163 
166  virtual void setClassId(const QString& class_id)
167  {
168  class_id_ = class_id;
169  }
170 
171  void load(const Config& config) override;
172  void save(Config config) const override;
173 
174  bool isActive() const
175  {
176  return is_active_;
177  }
178 
180  virtual QCursor getCursor()
181  {
182  return cursor_;
183  }
184 
185 Q_SIGNALS:
186  void configChanged();
187 
188 private Q_SLOTS:
189 
190  void updateNearClipDistance();
191  void updateStereoProperties();
192  void updateInvertZAxis();
193 
194 protected:
198  virtual void onInitialize()
199  {
200  }
201 
206  virtual void onActivate()
207  {
208  }
209 
210  // choose a cursor from the standard set
212  {
219  Crosshair
220  };
221  void setCursor(CursorType cursor_type);
222 
223  // set a custom cursor
224  void setCursor(QCursor cursor)
225  {
226  cursor_ = cursor;
227  }
228 
230  Ogre::Camera* camera_;
231 
233 
234  // this cursor will be displayed when the mouse is within the
235  // window controlled by this view controller
236  // use SetCursor to modify.
237  QCursor cursor_;
238 
245 
246  void setStatus(const QString& message);
247 
248 private:
250  QString class_id_;
251 
252  // Default cursors for the most common actions
253  QMap<CursorType, QCursor> standard_cursors_;
254 };
255 
256 } // end namespace rviz
257 
258 #endif // RVIZ_VIEW_CONTROLLER_H
virtual void transitionFrom(ViewController *previous_view)
Called by ViewManager when this ViewController is being made current.
ROSCONSOLE_DECL void initialize()
A single element of a property tree, with a name, value, description, and possibly children...
Definition: property.h:100
config
Ogre::Camera * getCamera() const
FloatProperty * stereo_focal_distance_
EnumProperty * type_property_
BoolProperty * invert_z_
Ogre::Camera * camera_
Property specialized to enforce floating point max/min.
virtual void update(float dt, float ros_dt)
Called at 30Hz by ViewManager::update() while this view is active. Override with code that needs to r...
virtual void mimic(ViewController *source_view)
Configure the settings of this view controller to give, as much as possible, a similar view as that g...
virtual QString getClassId() const
Return the class identifier which was used to create this instance. This version just returns whateve...
Configuration data storage class.
Definition: config.h:124
Pure-virtual base class for objects which give Display subclasses context in which to work...
virtual void lookAt(const Ogre::Vector3 &point)
This should be implemented in each subclass to aim the camera at the given point in space (relative t...
FloatProperty * stereo_eye_separation_
BoolProperty * stereo_eye_swap_
virtual void onInitialize()
Do subclass-specific initialization. Called by ViewController::initialize after context_ and camera_ ...
virtual QCursor getCursor()
void setCursor(QCursor cursor)
Property specialized to provide getter for booleans.
Definition: bool_property.h:38
virtual void onActivate()
called by activate().
FloatProperty * near_clip_property_
BoolProperty * stereo_enable_
QMap< CursorType, QCursor > standard_cursors_
DisplayContext * context_
Enum property.
Definition: enum_property.h:46
virtual void handleMouseEvent(ViewportMouseEvent &evt)
virtual void setClassId(const QString &class_id)
Set the class identifier used to create this instance. Typically this will be set by the factory obje...


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Sat May 27 2023 02:06:25