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 
42 class QKeyEvent;
43 class QTimer;
44 
45 namespace Ogre
46 {
47 class Root;
48 class SceneManager;
49 class SceneNode;
50 class Light;
51 }
52 
53 namespace ros
54 {
55 class CallbackQueueInterface;
56 }
57 
58 namespace tf
59 {
60 class TransformListener;
61 }
62 
63 namespace rviz
64 {
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 
101 {
102 Q_OBJECT
103 public:
113 
118  virtual ~VisualizationManager();
119 
124  void initialize();
125 
130  void startUpdate();
131 
132  /*
133  * \brief Stop the update timers. No Displays will be updated and no ROS
134  * callbacks will be called during this period.
135  */
136  void stopUpdate();
137 
146  Display* createDisplay( const QString& class_lookup_name, const QString& name, bool enabled );
147 
152  void addDisplay( Display* display, bool enabled );
153 
157  void removeAllDisplays();
158 
166  void load( const Config& config );
167 
176  void save( Config config ) const;
177 
180  QString getFixedFrame() const;
181 
185  void setFixedFrame( const QString& frame );
186 
190  tf::TransformListener* getTFClient() const;
191 
195  Ogre::SceneManager* getSceneManager() const { return scene_manager_; }
196 
200  RenderPanel* getRenderPanel() const { return render_panel_; }
201 
205  double getWallClock();
206 
210  double getROSTime();
211 
215  double getWallClockElapsed();
216 
220  double getROSTimeElapsed();
221 
229  void handleChar( QKeyEvent* event, RenderPanel* panel );
230 
238  void handleMouseEvent( const ViewportMouseEvent& event );
239 
243  void resetTime();
244 
248  SelectionManager* getSelectionManager() const { return selection_manager_; }
249 
251  virtual ToolManager* getToolManager() const { return tool_manager_; }
252 
254  virtual ViewManager* getViewManager() const { return view_manager_; }
255 
259  void lockRender();
260 
264  void unlockRender();
265 
270  void queueRender();
271 
275  WindowManagerInterface* getWindowManager() const { return window_manager_; }
276 
280  ros::CallbackQueueInterface* getUpdateQueue();
281 
285  ros::CallbackQueueInterface* getThreadedQueue();
286 
288  FrameManager* getFrameManager() const { return frame_manager_; }
289 
295  uint64_t getFrameCount() const { return frame_count_; }
296 
299  void notifyConfigChanged();
300 
302  virtual DisplayFactory* getDisplayFactory() const { return display_factory_; }
303 
304  PropertyTreeModel* getDisplayTreeModel() const { return display_property_tree_model_; }
305 
307  void emitStatusUpdate( const QString& message );
308 
309  virtual DisplayGroup* getRootDisplayGroup() const { return root_display_group_; }
310 
311  virtual uint32_t getDefaultVisibilityBit() const { return default_visibility_bit_; }
312 
313  virtual BitAllocator* visibilityBits() { return &visibility_bit_allocator_; }
314 
315  virtual void setStatus( const QString & message );
316 
317  virtual void setHelpPath( const QString& help_path ) { help_path_ = help_path; }
318  virtual QString getHelpPath() const { return help_path_; }
319 
320 Q_SIGNALS:
321 
323  void preUpdate();
324 
326  void configChanged();
327 
329  void statusUpdate( const QString& message );
330 
331 protected Q_SLOTS:
341  void onUpdate();
342 
343  void onToolChanged( Tool* );
344 
345 protected:
346  void updateTime();
347  void updateFrames();
348 
349  void createColorMaterials();
350 
351  void threadedQueueThreadFunc();
352 
353  Ogre::Root* ogre_root_;
354  Ogre::SceneManager* scene_manager_;
355 
356  QTimer* update_timer_;
359 
360  volatile bool shutting_down_;
361 
364 
367 
373 
375 
380 
382 
385 
387 
389  uint64_t frame_count_;
390 
392 
394 
396 
397 private Q_SLOTS:
398  void updateFixedFrame();
399  void updateBackgroundColor();
400  void updateFps();
401  void updateDefaultLightVisible();
402 
403 private:
408  QString help_path_;
409  Ogre::Light* directional_light_;
410 };
411 
412 }
413 
414 #endif /* RVIZ_VISUALIZATION_MANAGER_H_ */
virtual QString getHelpPath() const
OgreRenderQueueClearer * ogre_render_queue_clearer_
virtual ViewManager * getViewManager() const
Return a pointer to the ViewManager.
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
Ogre::SceneManager * getSceneManager() const
Returns the Ogre::SceneManager used for the main RenderPanel.
BoolProperty * default_light_enabled_property_
RenderPanel * getRenderPanel() const
Return the main RenderPanel.
Property specialized to provide max/min enforcement for integers.
Definition: int_property.h:38
virtual BitAllocator * visibilityBits()
FrameManager * getFrameManager() const
Return the FrameManager instance.
Configuration data storage class.
Definition: config.h:125
WindowManagerInterface * getWindowManager() const
Return the window manager, if any.
QTimer * update_timer_
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:63
A Display object which stores other Displays as children.
Definition: display_group.h:47
The VisualizationManager class is the central manager class of rviz, holding all the Displays...
ros::Time last_update_ros_time_
Update stopwatch. Stores how long it&#39;s been since the last update.
uint64_t getFrameCount() const
Return the current value of the frame count.
virtual uint32_t getDefaultVisibilityBit() const
Allocation manager for bit positions within a 32-bit word.
Definition: bit_allocator.h:38
SelectionManager * getSelectionManager() const
Return a pointer to the SelectionManager.
virtual DisplayFactory * getDisplayFactory() const
Return a factory for creating Display subclasses based on a class id string.
PropertyTreeModel * getDisplayTreeModel() const
Ogre::Root * ogre_root_
Ogre Root.
Property specialized to provide getter for booleans.
Definition: bool_property.h:38
ColorProperty * background_color_property_
PropertyTreeModel * display_property_tree_model_
virtual ToolManager * getToolManager() const
Return a pointer to the ToolManager.
Ogre::SceneManager * scene_manager_
Ogre scene manager associated with this panel.
SelectionManager * selection_manager_
virtual DisplayGroup * getRootDisplayGroup() const
virtual void setHelpPath(const QString &help_path)


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