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 
39 class QKeyEvent;
40 
41 namespace Ogre
42 {
43 class Camera;
44 class SceneNode;
45 class Vector3;
46 class Quaternion;
47 }
48 
49 namespace rviz
50 {
51 class DisplayContext;
52 class EnumProperty;
53 class RenderPanel;
54 class ViewportMouseEvent;
55 class FloatProperty;
56 class BoolProperty;
57 
58 class ViewController: public Property
59 {
60 Q_OBJECT
61 public:
63  virtual ~ViewController();
64 
70  void initialize( DisplayContext* context );
71 
72  static QString formatClassId( const QString& class_id );
73 
76  virtual QVariant getViewData( int column, int role ) const;
77 
79  virtual Qt::ItemFlags getViewFlags( int column ) const;
80 
85  void activate();
86 
89  virtual void update(float dt, float ros_dt)
90  {
91  (void) dt;
92  (void) ros_dt;
93  }
94 
96  {
97  (void) evt;
98  }
99 
104  virtual void handleKeyEvent( QKeyEvent* event, RenderPanel* panel );
105 
107  void lookAt( float x, float y, float z );
108 
112  virtual void lookAt( const Ogre::Vector3& point )
113  {
114  (void) point;
115  }
116 
119  virtual void reset() = 0;
120 
128  virtual void mimic( ViewController* source_view )
129  {
130  (void) source_view;
131  }
132 
141  virtual void transitionFrom( ViewController* previous_view )
142  {
143  (void) previous_view;
144  }
145 
147  void emitConfigChanged();
148 
149  Ogre::Camera* getCamera() const { return camera_; }
150 
154  virtual QString getClassId() const { return class_id_; }
155 
158  virtual void setClassId( const QString& class_id ) { class_id_ = class_id; }
159 
160  virtual void load( const Config& config );
161  virtual void save( Config config ) const;
162 
163  bool isActive() const { return is_active_; }
164 
166  virtual QCursor getCursor() { return cursor_; }
167 
168 Q_SIGNALS:
169  void configChanged();
170 
171 private Q_SLOTS:
172 
173  void updateNearClipDistance();
174  void updateStereoProperties();
175  void updateInvertZAxis();
176 
177 protected:
181  virtual void onInitialize() {}
182 
187  virtual void onActivate() {}
188 
189  // choose a cursor from the standard set
190  enum CursorType{ Default, Rotate2D, Rotate3D, MoveXY, MoveZ, Zoom, Crosshair };
191  void setCursor( CursorType cursor_type );
192 
193  // set a custom cursor
194  void setCursor( QCursor cursor ) { cursor_=cursor; }
195 
197  Ogre::Camera* camera_;
198 
200 
201  // this cursor will be displayed when the mouse is within the
202  // window controlled by this view controller
203  // use SetCursor to modify.
204  QCursor cursor_;
205 
212 
213  void setStatus( const QString & message );
214 
215 private:
216 
218  QString class_id_;
219 
220  // Default cursors for the most common actions
221  QMap<CursorType,QCursor> standard_cursors_;
222 };
223 
224 } // end namespace rviz
225 
226 #endif // RVIZ_VIEW_CONTROLLER_H
QMap< CursorType, QCursor > standard_cursors_
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
FloatProperty * stereo_focal_distance_
EnumProperty * type_property_
BoolProperty * invert_z_
Ogre::Camera * camera_
Property specialized to enforce floating point max/min.
TFSIMD_FORCE_INLINE const tfScalar & y() const
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:125
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...
Default
TFSIMD_FORCE_INLINE Vector3()
Ogre::Camera * getCamera() const
FloatProperty * stereo_eye_separation_
BoolProperty * stereo_eye_swap_
TFSIMD_FORCE_INLINE const tfScalar & x() const
virtual void onInitialize()
Do subclass-specific initialization. Called by ViewController::initialize after context_ and camera_ ...
virtual QCursor getCursor()
TFSIMD_FORCE_INLINE const tfScalar & z() const
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_
bool isActive() const
BoolProperty * stereo_enable_
DisplayContext * context_
Enum property.
Definition: enum_property.h:47
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 Wed Aug 28 2019 04:01:51