visualization_manager.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 
31 #ifndef RVIZ_VISUALIZATION_MANAGER_H_
32 #define RVIZ_VISUALIZATION_MANAGER_H_
33 
34 #include <deque>
35 
36 #include <ros/time.h>
38 
39 #include <rviz/bit_allocator.h>
40 #include <rviz/config.h>
41 #include <rviz/display_context.h>
42 #include <rviz/rviz_export.h>
43 
44 class QKeyEvent;
45 class QTimer;
46 
47 namespace Ogre
48 {
49 class Root;
50 class SceneManager;
51 class SceneNode;
52 class Light;
53 } // namespace Ogre
54 
55 namespace ros
56 {
57 class CallbackQueueInterface;
58 }
59 
60 namespace rviz
61 {
62 class ColorProperty;
63 class Display;
64 class DisplayFactory;
65 class DisplayGroup;
66 class FrameManager;
67 class Property;
68 class BoolProperty;
69 class IntProperty;
70 class PropertyTreeModel;
71 class RenderPanel;
72 class SelectionManager;
73 class StatusList;
74 class TfFrameProperty;
75 class ViewportMouseEvent;
76 class WindowManagerInterface;
77 class Tool;
78 class OgreRenderQueueClearer;
79 
80 class VisualizationManagerPrivate;
81 
96 class RVIZ_EXPORT VisualizationManager : public DisplayContext
97 {
98  Q_OBJECT
99 public:
111  explicit VisualizationManager(
112  RenderPanel* render_panel,
113  WindowManagerInterface* wm = nullptr,
114  std::shared_ptr<tf2_ros::Buffer> tf_buffer = std::shared_ptr<tf2_ros::Buffer>(),
115  std::shared_ptr<tf2_ros::TransformListener> tf_listener =
116  std::shared_ptr<tf2_ros::TransformListener>());
117 
122  ~VisualizationManager() override;
123 
128  void initialize();
129 
134  void startUpdate();
135 
136  /*
137  * \brief Stop the update timers. No Displays will be updated and no ROS
138  * callbacks will be called during this period.
139  */
140  void stopUpdate();
141 
150  Display* createDisplay(const QString& class_lookup_name, const QString& name, bool enabled);
151 
156  void addDisplay(Display* display, bool enabled);
157 
161  void removeAllDisplays();
162 
170  void load(const Config& config);
171 
180  void save(Config config) const;
181 
184  QString getFixedFrame() const override;
185 
189  void setFixedFrame(const QString& frame);
190 
194  std::shared_ptr<tf2_ros::Buffer> getTF2BufferPtr() const;
195 
199  Ogre::SceneManager* getSceneManager() const override
200  {
201  return scene_manager_;
202  }
203 
208  {
209  return render_panel_;
210  }
211 
215  double getWallClock();
216 
220  double getROSTime();
221 
225  double getWallClockElapsed();
226 
230  double getROSTimeElapsed();
231 
239  void handleChar(QKeyEvent* event, RenderPanel* panel) override;
240 
248  void handleMouseEvent(const ViewportMouseEvent& event) override;
249 
253  void resetTime();
254 
259  {
260  return selection_manager_;
261  }
262 
264  ToolManager* getToolManager() const override
265  {
266  return tool_manager_;
267  }
268 
270  ViewManager* getViewManager() const override
271  {
272  return view_manager_;
273  }
274 
278  void lockRender();
279 
283  void unlockRender();
284 
289  void queueRender() override;
290 
295  {
296  return window_manager_;
297  }
298 
302  ros::CallbackQueueInterface* getUpdateQueue() override;
303 
307  ros::CallbackQueueInterface* getThreadedQueue() override;
308 
310  FrameManager* getFrameManager() const override
311  {
312  return frame_manager_;
313  }
314 
320  uint64_t getFrameCount() const override
321  {
322  return frame_count_;
323  }
324 
327  void notifyConfigChanged();
328 
331  {
332  return display_factory_;
333  }
334 
336  {
337  return display_property_tree_model_;
338  }
339 
341  void emitStatusUpdate(const QString& message);
342 
344  {
345  return root_display_group_;
346  }
347 
348  uint32_t getDefaultVisibilityBit() const override
349  {
350  return default_visibility_bit_;
351  }
352 
354  {
355  return &visibility_bit_allocator_;
356  }
357 
358  void setStatus(const QString& message) override;
359 
360  virtual void setHelpPath(const QString& help_path)
361  {
362  help_path_ = help_path;
363  }
364  virtual QString getHelpPath() const
365  {
366  return help_path_;
367  }
368 
369 Q_SIGNALS:
370 
372  void preUpdate();
373 
375  void configChanged();
376 
378  void statusUpdate(const QString& message);
379 
381  void escapePressed();
382 
383 protected Q_SLOTS:
393  void onUpdate();
394 
395  void onToolChanged(Tool* /*unused*/);
396 
397 protected:
398  void updateTime();
399  void updateFrames();
400 
401  void createColorMaterials();
402 
403  void threadedQueueThreadFunc();
404 
405  Ogre::Root* ogre_root_;
406  Ogre::SceneManager* scene_manager_;
407 
408  QTimer* update_timer_;
411 
412  volatile bool shutting_down_;
413 
416 
419 
425 
427 
432 
434 
437 
439 
441  uint64_t frame_count_;
442 
444 
446 
448 
449 private Q_SLOTS:
450  void updateFixedFrame();
451  void updateBackgroundColor();
452  void updateFps();
453  void updateDefaultLightVisible();
454 
455 private:
460  QString help_path_;
461  Ogre::Light* directional_light_;
462 };
463 
464 } // namespace rviz
465 
466 #endif /* RVIZ_VISUALIZATION_MANAGER_H_ */
rviz::VisualizationManager::window_manager_
WindowManagerInterface * window_manager_
Definition: visualization_manager.h:443
bit_allocator.h
rviz::FrameManager
Helper class for transforming data into Ogre's world frame (the fixed frame).
Definition: frame_manager.h:64
rviz::VisualizationManager::last_update_ros_time_
ros::Time last_update_ros_time_
Stores how long it's been since the last update.
Definition: visualization_manager.h:409
Ogre
Definition: axes_display.h:35
rviz::VisualizationManager::visibilityBits
BitAllocator * visibilityBits() override
Definition: visualization_manager.h:353
rviz::VisualizationManager::getRootDisplayGroup
DisplayGroup * getRootDisplayGroup() const override
Definition: visualization_manager.h:343
rviz::ToolManager
Definition: tool_manager.h:48
rviz::VisualizationManager::getWindowManager
WindowManagerInterface * getWindowManager() const override
Return the window manager, if any.
Definition: visualization_manager.h:294
rviz::Tool
Definition: tool.h:56
rviz::VisualizationManager::getHelpPath
virtual QString getHelpPath() const
Definition: visualization_manager.h:364
rviz::VisualizationManager::getFrameCount
uint64_t getFrameCount() const override
Return the current value of the frame count.
Definition: visualization_manager.h:320
rviz::VisualizationManager::wall_clock_begin_
ros::WallTime wall_clock_begin_
Definition: visualization_manager.h:428
rviz::VisualizationManager::ros_time_begin_
ros::Time ros_time_begin_
Definition: visualization_manager.h:429
rviz::VisualizationManager
The VisualizationManager class is the central manager class of rviz, holding all the Displays,...
Definition: visualization_manager.h:96
rviz::PropertyTreeModel
Definition: property_tree_model.h:38
rviz::VisualizationManager::ogre_root_
Ogre::Root * ogre_root_
Ogre Root.
Definition: visualization_manager.h:405
rviz::VisualizationManager::global_options_
Property * global_options_
Definition: visualization_manager.h:420
ros
time.h
rviz::VisualizationManager::getSelectionManager
SelectionManager * getSelectionManager() const override
Return a pointer to the SelectionManager.
Definition: visualization_manager.h:258
rviz::VisualizationManager::render_requested_
uint32_t render_requested_
Definition: visualization_manager.h:440
rviz::BoolProperty
Property specialized to provide getter for booleans.
Definition: bool_property.h:38
rviz::ViewportMouseEvent
Definition: viewport_mouse_event.h:45
rviz::VisualizationManager::frame_manager_
FrameManager * frame_manager_
Definition: visualization_manager.h:445
rviz::BitAllocator
Allocation manager for bit positions within a 32-bit word.
Definition: bit_allocator.h:37
rviz::VisualizationManager::getDefaultVisibilityBit
uint32_t getDefaultVisibilityBit() const override
Definition: visualization_manager.h:348
rviz::VisualizationManager::frame_update_timer_
float frame_update_timer_
Definition: visualization_manager.h:436
rviz::VisualizationManager::display_factory_
DisplayFactory * display_factory_
Definition: visualization_manager.h:456
rviz::ColorProperty
Definition: color_property.h:40
rviz::VisualizationManager::ros_time_elapsed_
ros::Duration ros_time_elapsed_
Definition: visualization_manager.h:431
rviz::Display
Definition: display.h:63
rviz::VisualizationManager::getToolManager
ToolManager * getToolManager() const override
Return a pointer to the ToolManager.
Definition: visualization_manager.h:264
rviz::VisualizationManager::background_color_property_
ColorProperty * background_color_property_
Definition: visualization_manager.h:433
rviz::Property
A single element of a property tree, with a name, value, description, and possibly children.
Definition: property.h:100
rviz::StatusList
Definition: status_list.h:36
rviz::VisualizationManager::display_property_tree_model_
PropertyTreeModel * display_property_tree_model_
Definition: visualization_manager.h:414
rviz::VisualizationManager::selection_manager_
SelectionManager * selection_manager_
Definition: visualization_manager.h:438
rviz::VisualizationManager::setHelpPath
virtual void setHelpPath(const QString &help_path)
Definition: visualization_manager.h:360
rviz::VisualizationManager::default_visibility_bit_
uint32_t default_visibility_bit_
Definition: visualization_manager.h:458
rviz::VisualizationManager::getViewManager
ViewManager * getViewManager() const override
Return a pointer to the ViewManager.
Definition: visualization_manager.h:270
rviz::VisualizationManager::getDisplayFactory
DisplayFactory * getDisplayFactory() const override
Return a factory for creating Display subclasses based on a class id string.
Definition: visualization_manager.h:330
rviz::VisualizationManager::scene_manager_
Ogre::SceneManager * scene_manager_
Ogre scene manager associated with this panel.
Definition: visualization_manager.h:406
rviz
Definition: add_display_dialog.cpp:54
rviz::VisualizationManager::last_update_wall_time_
ros::WallTime last_update_wall_time_
Definition: visualization_manager.h:410
rviz::VisualizationManager::wall_clock_elapsed_
ros::WallDuration wall_clock_elapsed_
Definition: visualization_manager.h:430
rviz::VisualizationManager::ogre_render_queue_clearer_
OgreRenderQueueClearer * ogre_render_queue_clearer_
Definition: visualization_manager.h:447
rviz::VisualizationManager::render_panel_
RenderPanel * render_panel_
Definition: visualization_manager.h:426
rviz::VisualizationManager::help_path_
QString help_path_
Definition: visualization_manager.h:460
rviz::DisplayContext
Pure-virtual base class for objects which give Display subclasses context in which to work.
Definition: display_context.h:81
rviz::VisualizationManager::getFrameManager
FrameManager * getFrameManager() const override
Return the FrameManager instance.
Definition: visualization_manager.h:310
ros::WallTime
rviz::ViewManager
Definition: view_manager.h:53
rviz::OgreRenderQueueClearer
Definition: ogre_render_queue_clearer.h:42
rviz::TfFrameProperty
Definition: tf_frame_property.h:41
rviz::VisualizationManager::fps_property_
IntProperty * fps_property_
Definition: visualization_manager.h:423
transform_listener.h
rviz::DisplayFactory
Definition: display_factory.h:42
rviz::VisualizationManager::root_display_group_
DisplayGroup * root_display_group_
Definition: visualization_manager.h:415
rviz::VisualizationManager::private_
VisualizationManagerPrivate * private_
Definition: visualization_manager.h:457
ros::Time
rviz::VisualizationManagerPrivate
Definition: visualization_manager.cpp:109
rviz::VisualizationManager::shutting_down_
volatile bool shutting_down_
Definition: visualization_manager.h:412
tf_buffer
tf2_ros::Buffer * tf_buffer
rviz::SelectionManager
Definition: selection_manager.h:81
rviz::VisualizationManager::directional_light_
Ogre::Light * directional_light_
Definition: visualization_manager.h:461
rviz::VisualizationManager::fixed_frame_property_
TfFrameProperty * fixed_frame_property_
Frame to transform fixed data to.
Definition: visualization_manager.h:421
rviz::VisualizationManager::visibility_bit_allocator_
BitAllocator visibility_bit_allocator_
Definition: visualization_manager.h:459
rviz::VisualizationManager::global_status_
StatusList * global_status_
Definition: visualization_manager.h:422
initialize
ROSCONSOLE_DECL void initialize()
rviz::VisualizationManager::frame_count_
uint64_t frame_count_
Definition: visualization_manager.h:441
rviz::VisualizationManager::tool_manager_
ToolManager * tool_manager_
Definition: visualization_manager.h:417
config.h
rviz::VisualizationManager::default_light_enabled_property_
BoolProperty * default_light_enabled_property_
Definition: visualization_manager.h:424
rviz::VisualizationManager::view_manager_
ViewManager * view_manager_
Definition: visualization_manager.h:418
display_context.h
rviz::WindowManagerInterface
Definition: window_manager_interface.h:40
rviz::RenderPanel
Definition: render_panel.h:74
ros::WallDuration
rviz::VisualizationManager::getSceneManager
Ogre::SceneManager * getSceneManager() const override
Returns the Ogre::SceneManager used for the main RenderPanel.
Definition: visualization_manager.h:199
config
config
rviz::VisualizationManager::time_update_timer_
float time_update_timer_
Definition: visualization_manager.h:435
ros::Duration
rviz::VisualizationManager::getRenderPanel
RenderPanel * getRenderPanel() const
Return the main RenderPanel.
Definition: visualization_manager.h:207
rviz::Config
Configuration data storage class.
Definition: config.h:124
rviz::DisplayGroup
A Display object which stores other Displays as children.
Definition: display_group.h:47
ros::CallbackQueueInterface
rviz::VisualizationManager::getDisplayTreeModel
PropertyTreeModel * getDisplayTreeModel() const
Definition: visualization_manager.h:335
rviz::IntProperty
Property specialized to provide max/min enforcement for integers.
Definition: int_property.h:37
rviz::VisualizationManager::update_timer_
QTimer * update_timer_
Display::update is called on each display whenever this timer fires.
Definition: visualization_manager.h:408


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Fri Dec 13 2024 03:31:03