display.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 #ifndef DISPLAY_H
30 #define DISPLAY_H
31 
32 #include <string>
33 
34 #ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829
35 # include <ros/ros.h>
36 #endif
37 
40 
41 #include <QIcon>
42 #include <QSet>
43 
44 class QDockWidget;
45 class QWidget;
46 
47 namespace Ogre
48 {
49 class SceneManager;
50 class SceneNode;
51 }
52 
53 // needed for timeSignal
55 
56 namespace rviz
57 {
58 
59 class StatusList;
60 class DisplayContext;
61 class PanelDockWidget;
62 
63 class Display: public BoolProperty
64 {
65 Q_OBJECT
66 public:
67  Display();
68  virtual ~Display();
69 
71  void initialize( DisplayContext* context );
72 
76  virtual QVariant getViewData( int column, int role ) const;
77 
80  virtual Qt::ItemFlags getViewFlags( int column ) const;
81 
85  virtual QString getClassId() const { return class_id_; }
86 
89  virtual void setClassId( const QString& class_id ) { class_id_ = class_id; }
90 
98  virtual void load( const Config& config );
99 
103  virtual void save( Config config ) const;
104 
116  virtual void setTopic( const QString &topic, const QString &datatype )
117  {
118  (void) topic;
119  (void) datatype;
120  }
121 
123  bool isEnabled() const;
124 
126  void setFixedFrame( const QString& fixed_frame );
127 
131  virtual void update( float wall_dt, float ros_dt )
132  {
133  (void) wall_dt;
134  (void) ros_dt;
135  }
136 
138  virtual void reset();
139 
152  virtual void setStatus( StatusProperty::Level level, const QString& name, const QString& text );
153 
157  void setStatusStd( StatusProperty::Level level, const std::string& name, const std::string& text )
158  {
159  setStatus( level, QString::fromStdString( name ), QString::fromStdString( text ));
160  }
161 
163  virtual void deleteStatus( const QString& name );
164 
166  void deleteStatusStd( const std::string& name ) { deleteStatus( QString::fromStdString( name )); }
167 
169  void setVisibilityBits( uint32_t bits );
170  void unsetVisibilityBits( uint32_t bits );
171  uint32_t getVisibilityBits() { return visibility_bits_; }
172 
174  Ogre::SceneNode* getSceneNode() const { return scene_node_; }
175 
189  void setAssociatedWidget( QWidget* widget );
190 
193  QWidget* getAssociatedWidget() const { return associated_widget_; }
194 
197  PanelDockWidget* getAssociatedWidgetPanel() { return associated_widget_panel_; }
198 
200  void setName( const QString& name );
201 
203  void emitTimeSignal( ros::Time time );
204 
205 Q_SIGNALS:
206 
207  void timeSignal( rviz::Display* display, ros::Time time );
208 
209 public Q_SLOTS:
214  void setEnabled( bool enabled );
215 
217  void queueRender();
218 
220  virtual void setIcon( const QIcon& icon );
221 
222 protected:
223 
230  virtual void onInitialize() {}
231 
233  virtual void onEnable() {}
234 
236  virtual void onDisable() {}
237 
241  virtual void clearStatuses();
242 
244  virtual void fixedFrameChanged() {}
245 
247  bool initialized() const { return initialized_; }
248 
257 
261  Ogre::SceneManager* scene_manager_;
262 
264  Ogre::SceneNode* scene_node_;
265 
270 
275 
281  QString fixed_frame_;
282 
283 public Q_SLOTS:
284  virtual void onEnableChanged();
285 
286 private Q_SLOTS:
287  void setStatusInternal( int level, const QString& name, const QString& text );
288  void deleteStatusInternal( const QString& name );
289  void clearStatusesInternal();
290  void associatedPanelVisibilityChange( bool visible );
291  void disable();
292 
293 private:
295  QString class_id_;
300 };
301 
302 } // end namespace rviz
303 
304 #endif // DISPLAY_H
void setStatusStd(StatusProperty::Level level, const std::string &name, const std::string &text)
Show status level and text, using a std::string. Convenience function which converts std::string to Q...
Definition: display.h:157
void deleteStatusStd(const std::string &name)
Delete the status entry with the given std::string name. This is thread-safe.
Definition: display.h:166
PanelDockWidget * associated_widget_panel_
Definition: display.h:299
ROSCONSOLE_DECL void initialize()
DisplayContext * context_
This DisplayContext pointer is the main connection a Display has into the rest of rviz...
Definition: display.h:256
Ogre::SceneNode * getSceneNode() const
Return the Ogre::SceneNode holding all 3D scene elements shown by this Display.
Definition: display.h:174
ros::NodeHandle update_nh_
A NodeHandle whose CallbackQueue is run from the main GUI thread (the "update" thread).
Definition: display.h:269
config
virtual void setTopic(const QString &topic, const QString &datatype)
Set the ROS topic to listen to for this display.
Definition: display.h:116
uint32_t getVisibilityBits()
Definition: display.h:171
Q_DECLARE_METATYPE(ros::Time)
uint32_t visibility_bits_
Definition: display.h:297
Ogre::SceneNode * scene_node_
The Ogre::SceneNode to hold all 3D scene elements shown by this Display.
Definition: display.h:264
PanelDockWidget * getAssociatedWidgetPanel()
Return the panel containing the associated widget, or NULL if there is none.
Definition: display.h:197
Configuration data storage class.
Definition: config.h:125
QString fixed_frame_
A convenience variable equal to context_->getFixedFrame().
Definition: display.h:281
QString class_id_
Definition: display.h:295
Pure-virtual base class for objects which give Display subclasses context in which to work...
virtual QString getClassId() const
Return the class identifier which was used to create this instance. This version just returns whateve...
Definition: display.h:85
QWidget * associated_widget_
Definition: display.h:298
virtual void onEnable()
Derived classes override this to do the actual work of enabling themselves.
Definition: display.h:233
StatusList * status_
Definition: display.h:294
Ogre::SceneManager * scene_manager_
A convenience variable equal to context_->getSceneManager().
Definition: display.h:261
ros::NodeHandle threaded_nh_
A NodeHandle whose CallbackQueue is run from a different thread than the GUI.
Definition: display.h:274
virtual void onDisable()
Derived classes override this to do the actual work of disabling themselves.
Definition: display.h:236
virtual void fixedFrameChanged()
Called by setFixedFrame(). Override to respond to changes to fixed_frame_.
Definition: display.h:244
Property specialized to provide getter for booleans.
Definition: bool_property.h:38
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: display.h:89
virtual void onInitialize()
Override this function to do subclass-specific initialization.
Definition: display.h:230
virtual void update(float wall_dt, float ros_dt)
Called periodically by the visualization manager.
Definition: display.h:131
bool initialized() const
Returns true if the display has been initialized.
Definition: display.h:247
Dock widget class for docking widgets into VisualizationFrame.
bool initialized_
Definition: display.h:296
QWidget * getAssociatedWidget() const
Return the current associated widget, or NULL if there is none.
Definition: display.h:193


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Wed Aug 28 2019 04:01:50