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 #include <utility>
37 
38 
39 #include <OgrePrerequisites.h>
40 
42 #include <rviz/rviz_export.h>
43 
44 class QKeyEvent;
45 
46 namespace rviz
47 {
48 class DisplayContext;
49 class EnumProperty;
50 class RenderPanel;
51 class ViewportMouseEvent;
52 class FloatProperty;
53 class BoolProperty;
54 
55 class RVIZ_EXPORT ViewController : public Property
56 {
57  Q_OBJECT
58 public:
60  ~ViewController() override;
61 
67  void initialize(DisplayContext* context);
68 
69  static QString formatClassId(const QString& class_id);
70 
73  QVariant getViewData(int column, int role) const override;
74 
76  Qt::ItemFlags getViewFlags(int column) const override;
77 
82  void activate();
83 
86  virtual void update(float dt, float ros_dt)
87  {
88  (void)dt;
89  (void)ros_dt;
90  }
91 
93  {
94  (void)evt;
95  }
96 
101  virtual void handleKeyEvent(QKeyEvent* event, RenderPanel* panel);
102 
104  void lookAt(float x, float y, float z);
105 
109  virtual void lookAt(const Ogre::Vector3& point)
110  {
111  (void)point;
112  }
113 
116  virtual void reset() = 0;
117 
125  virtual void mimic(ViewController* source_view)
126  {
127  (void)source_view;
128  }
129 
138  virtual void transitionFrom(ViewController* previous_view)
139  {
140  (void)previous_view;
141  }
142 
145  void emitConfigChanged();
146 
147  Ogre::Camera* getCamera() const
148  {
149  return camera_;
150  }
151 
155  virtual QString getClassId() const
156  {
157  return class_id_;
158  }
159 
162  virtual void setClassId(const QString& class_id)
163  {
164  class_id_ = class_id;
165  }
166 
167  void load(const Config& config) override;
168  void save(Config config) const override;
169 
170  bool isActive() const
171  {
172  return is_active_;
173  }
174 
176  virtual QCursor getCursor()
177  {
178  return cursor_;
179  }
180 
181 Q_SIGNALS:
182  void configChanged();
183 
184 private Q_SLOTS:
185 
186  void updateNearClipDistance();
187  void updateStereoProperties();
188  void updateInvertZAxis();
189 
190 protected:
194  virtual void onInitialize()
195  {
196  }
197 
202  virtual void onActivate()
203  {
204  }
205 
206  // choose a cursor from the standard set
208  {
215  Crosshair
216  };
217  void setCursor(CursorType cursor_type);
218 
219  // set a custom cursor
220  void setCursor(QCursor cursor)
221  {
222  cursor_ = std::move(cursor);
223  }
224 
226  Ogre::Camera* camera_;
227 
229 
230  // this cursor will be displayed when the mouse is within the
231  // window controlled by this view controller
232  // use SetCursor to modify.
233  QCursor cursor_;
234 
241 
242  void setStatus(const QString& message);
243 
244 private:
246  QString class_id_;
247 
248  // Default cursors for the most common actions
249  QMap<CursorType, QCursor> standard_cursors_;
250 };
251 
252 } // end namespace rviz
253 
254 #endif // RVIZ_VIEW_CONTROLLER_H
rviz::ViewController::is_active_
bool is_active_
Definition: view_controller.h:228
rviz::ViewController::onInitialize
virtual void onInitialize()
Do subclass-specific initialization. Called by ViewController::initialize after context_ and camera_ ...
Definition: view_controller.h:194
rviz::ViewController::lookAt
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...
Definition: view_controller.h:109
rviz::ViewController::setCursor
void setCursor(QCursor cursor)
Definition: view_controller.h:220
rviz::ViewController::onActivate
virtual void onActivate()
called by activate().
Definition: view_controller.h:202
rviz::ViewController::near_clip_property_
FloatProperty * near_clip_property_
Definition: view_controller.h:235
property.h
rviz::BoolProperty
Property specialized to provide getter for booleans.
Definition: bool_property.h:38
rviz::ViewportMouseEvent
Definition: viewport_mouse_event.h:45
rviz::ViewController::getCursor
virtual QCursor getCursor()
Definition: view_controller.h:176
rviz::ViewController::Rotate2D
@ Rotate2D
Definition: view_controller.h:210
rviz::ViewController::handleMouseEvent
virtual void handleMouseEvent(ViewportMouseEvent &evt)
Definition: view_controller.h:92
rviz::ViewController::CursorType
CursorType
Definition: view_controller.h:207
rviz::ViewController::context_
DisplayContext * context_
Definition: view_controller.h:225
rviz::ViewController::stereo_enable_
BoolProperty * stereo_enable_
Definition: view_controller.h:236
rviz::EnumProperty
Enum property.
Definition: enum_property.h:46
rviz::FloatProperty
Property specialized to enforce floating point max/min.
Definition: float_property.h:37
rviz::Property
A single element of a property tree, with a name, value, description, and possibly children.
Definition: property.h:100
rviz
Definition: add_display_dialog.cpp:54
rviz::ViewController::standard_cursors_
QMap< CursorType, QCursor > standard_cursors_
Definition: view_controller.h:249
rviz::ViewController::class_id_
QString class_id_
Definition: view_controller.h:246
rviz::ViewController::transitionFrom
virtual void transitionFrom(ViewController *previous_view)
Called by ViewManager when this ViewController is being made current.
Definition: view_controller.h:138
rviz::DisplayContext
Pure-virtual base class for objects which give Display subclasses context in which to work.
Definition: display_context.h:81
rviz::ViewController::setClassId
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...
Definition: view_controller.h:162
rviz::ViewController::invert_z_
BoolProperty * invert_z_
Definition: view_controller.h:240
rviz::ViewController::update
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...
Definition: view_controller.h:86
rviz::ViewController::getCamera
Ogre::Camera * getCamera() const
Definition: view_controller.h:147
rviz::ViewController::type_property_
EnumProperty * type_property_
Definition: view_controller.h:245
rviz::ViewController
Definition: view_controller.h:55
rviz::ViewController::camera_
Ogre::Camera * camera_
Definition: view_controller.h:226
initialize
ROSCONSOLE_DECL void initialize()
rviz::ViewController::stereo_focal_distance_
FloatProperty * stereo_focal_distance_
Definition: view_controller.h:239
rviz::ViewController::Zoom
@ Zoom
Definition: view_controller.h:214
rviz::ViewController::Default
@ Default
Definition: view_controller.h:209
rviz::RenderPanel
Definition: render_panel.h:74
rviz::ViewController::MoveXY
@ MoveXY
Definition: view_controller.h:212
rviz::ViewController::stereo_eye_separation_
FloatProperty * stereo_eye_separation_
Definition: view_controller.h:238
rviz::ViewController::Rotate3D
@ Rotate3D
Definition: view_controller.h:211
rviz::ViewController::getClassId
virtual QString getClassId() const
Return the class identifier which was used to create this instance. This version just returns whateve...
Definition: view_controller.h:155
rviz::ViewController::stereo_eye_swap_
BoolProperty * stereo_eye_swap_
Definition: view_controller.h:237
rviz::Config
Configuration data storage class.
Definition: config.h:124
rviz::ViewController::cursor_
QCursor cursor_
Definition: view_controller.h:233
rviz::ViewController::MoveZ
@ MoveZ
Definition: view_controller.h:213
rviz::ViewController::mimic
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...
Definition: view_controller.h:125
rviz::ViewController::isActive
bool isActive() const
Definition: view_controller.h:170


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Tue May 28 2024 02:33:17