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>
37 
38 #include "rviz/bit_allocator.h"
39 #include "rviz/config.h"
40 #include "rviz/display_context.h"
41 #include "rviz/rviz_export.h"
42 
43 class QKeyEvent;
44 class QTimer;
45 
46 namespace Ogre
47 {
48 class Root;
49 class SceneManager;
50 class SceneNode;
51 class Light;
52 } // namespace Ogre
53 
54 namespace ros
55 {
56 class CallbackQueueInterface;
57 }
58 
59 namespace tf
60 {
61 class TransformListener;
62 }
63 
64 namespace rviz
65 {
66 class ColorProperty;
67 class Display;
68 class DisplayFactory;
69 class DisplayGroup;
70 class FrameManager;
71 class Property;
72 class BoolProperty;
73 class IntProperty;
74 class PropertyTreeModel;
75 class RenderPanel;
76 class SelectionManager;
77 class StatusList;
78 class TfFrameProperty;
79 class ViewportMouseEvent;
80 class WindowManagerInterface;
81 class Tool;
82 class OgreRenderQueueClearer;
83 
84 class VisualizationManagerPrivate;
85 
100 class RVIZ_EXPORT VisualizationManager : public DisplayContext
101 {
102  Q_OBJECT
103 public:
112  explicit VisualizationManager(RenderPanel* render_panel, WindowManagerInterface* wm = nullptr);
113 
114  [[deprecated("This constructor signature will be removed in the next version. "
115  "If you still need to pass a boost::shared_ptr<tf::TransformListener>, "
116  "disable the warning explicitly. "
117  "When this constructor is removed, a new optional argument will added to "
118  "the other constructor and it will take a std::pair<> containing a "
119  "std::shared_ptr<tf2_ros::Buffer> and a "
120  "std::shared_ptr<tf2_ros::TransformListener>. "
121  "However, that cannot occur until the use of tf::TransformListener is "
122  "removed internally.")]] VisualizationManager(RenderPanel* render_panel,
125 
130  ~VisualizationManager() override;
131 
136  void initialize();
137 
142  void startUpdate();
143 
144  /*
145  * \brief Stop the update timers. No Displays will be updated and no ROS
146  * callbacks will be called during this period.
147  */
148  void stopUpdate();
149 
158  Display* createDisplay(const QString& class_lookup_name, const QString& name, bool enabled);
159 
164  void addDisplay(Display* display, bool enabled);
165 
169  void removeAllDisplays();
170 
178  void load(const Config& config);
179 
188  void save(Config config) const;
189 
192  QString getFixedFrame() const override;
193 
197  void setFixedFrame(const QString& frame);
198 
202  [[deprecated("use getTF2BufferPtr() instead")]] tf::TransformListener* getTFClient() const override;
203 
207  std::shared_ptr<tf2_ros::Buffer> getTF2BufferPtr() const override;
208 
212  Ogre::SceneManager* getSceneManager() const override
213  {
214  return scene_manager_;
215  }
216 
221  {
222  return render_panel_;
223  }
224 
228  double getWallClock();
229 
233  double getROSTime();
234 
238  double getWallClockElapsed();
239 
243  double getROSTimeElapsed();
244 
252  void handleChar(QKeyEvent* event, RenderPanel* panel) override;
253 
261  void handleMouseEvent(const ViewportMouseEvent& event) override;
262 
266  void resetTime();
267 
272  {
273  return selection_manager_;
274  }
275 
277  ToolManager* getToolManager() const override
278  {
279  return tool_manager_;
280  }
281 
283  ViewManager* getViewManager() const override
284  {
285  return view_manager_;
286  }
287 
291  void lockRender();
292 
296  void unlockRender();
297 
302  void queueRender() override;
303 
308  {
309  return window_manager_;
310  }
311 
315  ros::CallbackQueueInterface* getUpdateQueue() override;
316 
320  ros::CallbackQueueInterface* getThreadedQueue() override;
321 
323  FrameManager* getFrameManager() const override
324  {
325  return frame_manager_;
326  }
327 
333  uint64_t getFrameCount() const override
334  {
335  return frame_count_;
336  }
337 
340  void notifyConfigChanged();
341 
344  {
345  return display_factory_;
346  }
347 
349  {
350  return display_property_tree_model_;
351  }
352 
354  void emitStatusUpdate(const QString& message);
355 
357  {
358  return root_display_group_;
359  }
360 
361  uint32_t getDefaultVisibilityBit() const override
362  {
363  return default_visibility_bit_;
364  }
365 
367  {
368  return &visibility_bit_allocator_;
369  }
370 
371  void setStatus(const QString& message) override;
372 
373  virtual void setHelpPath(const QString& help_path)
374  {
375  help_path_ = help_path;
376  }
377  virtual QString getHelpPath() const
378  {
379  return help_path_;
380  }
381 
382 Q_SIGNALS:
383 
385  void preUpdate();
386 
388  void configChanged();
389 
391  void statusUpdate(const QString& message);
392 
394  void escapePressed();
395 
396 protected Q_SLOTS:
406  void onUpdate();
407 
408  void onToolChanged(Tool* tool);
409 
410 protected:
411  void updateTime();
412  void updateFrames();
413 
414  void createColorMaterials();
415 
416  void threadedQueueThreadFunc();
417 
418  Ogre::Root* ogre_root_;
419  Ogre::SceneManager* scene_manager_;
420 
421  QTimer* update_timer_;
424 
425  volatile bool shutting_down_;
426 
429 
432 
438 
440 
445 
447 
450 
452 
454  uint64_t frame_count_;
455 
457 
459 
461 
462 private Q_SLOTS:
463  void updateFixedFrame();
464  void updateBackgroundColor();
465  void updateFps();
466  void updateDefaultLightVisible();
467 
468 private:
473  QString help_path_;
474  Ogre::Light* directional_light_;
475 };
476 
477 } // namespace rviz
478 
479 #endif /* RVIZ_VISUALIZATION_MANAGER_H_ */
OgreRenderQueueClearer * ogre_render_queue_clearer_
FrameManager * getFrameManager() const override
Return the FrameManager instance.
ROSCONSOLE_DECL void initialize()
VisualizationManagerPrivate * private_
TfFrameProperty * fixed_frame_property_
Frame to transform fixed data to.
A single element of a property tree, with a name, value, description, and possibly children...
Definition: property.h:100
config
BoolProperty * default_light_enabled_property_
Ogre::SceneManager * getSceneManager() const override
Returns the Ogre::SceneManager used for the main RenderPanel.
Property specialized to provide max/min enforcement for integers.
Definition: int_property.h:37
Configuration data storage class.
Definition: config.h:124
PropertyTreeModel * getDisplayTreeModel() const
QTimer * update_timer_
Display::update is called on each display whenever this timer fires.
WindowManagerInterface * window_manager_
Pure-virtual base class for objects which give Display subclasses context in which to work...
Helper class for transforming data into Ogre&#39;s world frame (the fixed frame).
Definition: frame_manager.h:70
RenderPanel * getRenderPanel() const
Return the main RenderPanel.
A Display object which stores other Displays as children.
Definition: display_group.h:47
DisplayGroup * getRootDisplayGroup() const override
BitAllocator * visibilityBits() override
WindowManagerInterface * getWindowManager() const override
Return the window manager, if any.
virtual QString getHelpPath() const
uint64_t getFrameCount() const override
Return the current value of the frame count.
The VisualizationManager class is the central manager class of rviz, holding all the Displays...
ros::Time last_update_ros_time_
Stores how long it&#39;s been since the last update.
Allocation manager for bit positions within a 32-bit word.
Definition: bit_allocator.h:37
Ogre::Root * ogre_root_
Ogre Root.
SelectionManager * getSelectionManager() const override
Return a pointer to the SelectionManager.
Property specialized to provide getter for booleans.
Definition: bool_property.h:38
ColorProperty * background_color_property_
uint32_t getDefaultVisibilityBit() const override
PropertyTreeModel * display_property_tree_model_
ViewManager * getViewManager() const override
Return a pointer to the ViewManager.
Ogre::SceneManager * scene_manager_
Ogre scene manager associated with this panel.
ToolManager * getToolManager() const override
Return a pointer to the ToolManager.
SelectionManager * selection_manager_
virtual void setHelpPath(const QString &help_path)
DisplayFactory * getDisplayFactory() const override
Return a factory for creating Display subclasses based on a class id string.


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Sat Nov 6 2021 02:06:35