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 #include "rviz/rviz_export.h"
41 
42 #include <QIcon>
43 #include <QSet>
44 
45 class QDockWidget;
46 class QWidget;
47 
48 namespace Ogre
49 {
50 class SceneManager;
51 class SceneNode;
52 } // namespace Ogre
53 
54 // needed for timeSignal
56 
57 namespace rviz
58 {
59 class StatusList;
60 class DisplayContext;
61 class PanelDockWidget;
62 
63 class RVIZ_EXPORT Display : public BoolProperty
64 {
65  Q_OBJECT
66 public:
67  Display();
68  ~Display() override;
69 
71  void initialize(DisplayContext* context);
72 
76  QVariant getViewData(int column, int role) const override;
77 
80  Qt::ItemFlags getViewFlags(int column) const override;
81 
85  virtual QString getClassId() const
86  {
87  return class_id_;
88  }
89 
92  virtual void setClassId(const QString& class_id)
93  {
94  class_id_ = class_id;
95  }
96 
104  void load(const Config& config) override;
105 
109  void save(Config config) const override;
110 
122  virtual void setTopic(const QString& topic, const QString& datatype)
123  {
124  (void)topic;
125  (void)datatype;
126  }
127 
129  bool isEnabled() const;
130 
132  void setFixedFrame(const QString& fixed_frame);
133 
137  virtual void update(float wall_dt, float ros_dt)
138  {
139  (void)wall_dt;
140  (void)ros_dt;
141  }
142 
144  virtual void reset();
145 
158  virtual void setStatus(StatusProperty::Level level, const QString& name, const QString& text);
159 
163  void setStatusStd(StatusProperty::Level level, const std::string& name, const std::string& text)
164  {
165  setStatus(level, QString::fromStdString(name), QString::fromStdString(text));
166  }
167 
169  virtual void deleteStatus(const QString& name);
170 
172  void deleteStatusStd(const std::string& name)
173  {
174  deleteStatus(QString::fromStdString(name));
175  }
176 
178  void setVisibilityBits(uint32_t bits);
179  void unsetVisibilityBits(uint32_t bits);
180  uint32_t getVisibilityBits()
181  {
182  return visibility_bits_;
183  }
184 
186  Ogre::SceneNode* getSceneNode() const
187  {
188  return scene_node_;
189  }
190 
204  void setAssociatedWidget(QWidget* widget);
205 
208  QWidget* getAssociatedWidget() const
209  {
210  return associated_widget_;
211  }
212 
216  {
217  return associated_widget_panel_;
218  }
219 
221  void setName(const QString& name) override;
222 
224  void emitTimeSignal(ros::Time time);
225 
226 Q_SIGNALS:
227 
228  void timeSignal(ros::Time time, QPrivateSignal);
229 
230 public Q_SLOTS:
235  void setEnabled(bool enabled);
236 
238  void queueRender();
239 
241  void setIcon(const QIcon& icon) override;
242 
243 protected:
250  virtual void onInitialize()
251  {
252  }
253 
255  virtual void onEnable()
256  {
257  }
258 
260  virtual void onDisable()
261  {
262  }
263 
267  virtual void clearStatuses();
268 
270  virtual void fixedFrameChanged()
271  {
272  }
273 
275  bool initialized() const
276  {
277  return initialized_;
278  }
279 
288 
292  Ogre::SceneManager* scene_manager_;
293 
295  Ogre::SceneNode* scene_node_;
296 
301 
306 
312  QString fixed_frame_;
313 
314 public Q_SLOTS:
315  virtual void onEnableChanged();
316 
317 private Q_SLOTS:
318  void setStatusInternal(int level, const QString& name, const QString& text);
319  void deleteStatusInternal(const QString& name);
320  void clearStatusesInternal();
321  void associatedPanelVisibilityChange(bool visible);
322  void disable();
323 
324 private:
326  QString class_id_;
331 };
332 
333 } // end namespace rviz
334 
335 #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:163
void deleteStatusStd(const std::string &name)
Delete the status entry with the given std::string name. This is thread-safe.
Definition: display.h:172
PanelDockWidget * associated_widget_panel_
Definition: display.h:330
ROSCONSOLE_DECL void initialize()
DisplayContext * context_
This DisplayContext pointer is the main connection a Display has into the rest of rviz...
Definition: display.h:287
ros::NodeHandle update_nh_
A NodeHandle whose CallbackQueue is run from the main GUI thread (the "update" thread).
Definition: display.h:300
config
virtual void setTopic(const QString &topic, const QString &datatype)
Set the ROS topic to listen to for this display.
Definition: display.h:122
uint32_t getVisibilityBits()
Definition: display.h:180
Q_DECLARE_METATYPE(ros::Time)
QWidget * getAssociatedWidget() const
Return the current associated widget, or NULL if there is none.
Definition: display.h:208
uint32_t visibility_bits_
Definition: display.h:328
Ogre::SceneNode * scene_node_
The Ogre::SceneNode to hold all 3D scene elements shown by this Display.
Definition: display.h:295
PanelDockWidget * getAssociatedWidgetPanel()
Return the panel containing the associated widget, or NULL if there is none.
Definition: display.h:215
Configuration data storage class.
Definition: config.h:124
QString fixed_frame_
A convenience variable equal to context_->getFixedFrame().
Definition: display.h:312
QString class_id_
Definition: display.h:326
Pure-virtual base class for objects which give Display subclasses context in which to work...
Ogre::SceneNode * getSceneNode() const
Return the Ogre::SceneNode holding all 3D scene elements shown by this Display.
Definition: display.h:186
QWidget * associated_widget_
Definition: display.h:329
virtual void onEnable()
Derived classes override this to do the actual work of enabling themselves.
Definition: display.h:255
StatusList * status_
Definition: display.h:325
Ogre::SceneManager * scene_manager_
A convenience variable equal to context_->getSceneManager().
Definition: display.h:292
ros::NodeHandle threaded_nh_
A NodeHandle whose CallbackQueue is run from a different thread than the GUI.
Definition: display.h:305
virtual void onDisable()
Derived classes override this to do the actual work of disabling themselves.
Definition: display.h:260
virtual void fixedFrameChanged()
Called by setFixedFrame(). Override to respond to changes to fixed_frame_.
Definition: display.h:270
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:92
virtual void onInitialize()
Override this function to do subclass-specific initialization.
Definition: display.h:250
virtual void update(float wall_dt, float ros_dt)
Called periodically by the visualization manager.
Definition: display.h:137
bool initialized() const
Returns true if the display has been initialized.
Definition: display.h:275
virtual QString getClassId() const
Return the class identifier which was used to create this instance. This version just returns whateve...
Definition: display.h:85
Dock widget class for docking widgets into VisualizationFrame.
bool initialized_
Definition: display.h:327


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