Go to the documentation of this file.
32 #include <QApplication>
38 #include <boost/bind/bind.hpp>
41 #include <OgreSceneManager.h>
42 #include <OgreSceneNode.h>
43 #include <OgreLight.h>
44 #include <OgreViewport.h>
45 #include <OgreMaterialManager.h>
46 #include <OgreMaterial.h>
47 #include <OgreRenderWindow.h>
48 #include <OgreSharedPtr.h>
49 #include <OgreCamera.h>
51 #include <boost/filesystem.hpp>
91 const QVariant& default_value = QVariant(),
92 const QString& description = QString(),
121 std::shared_ptr<tf2_ros::Buffer> tf_buffer,
122 std::shared_ptr<tf2_ros::TransformListener> tf_listener)
123 : ogre_root_(
Ogre::Root::getSingletonPtr())
124 , update_timer_(nullptr)
125 , shutting_down_(false)
126 , render_panel_(render_panel)
127 , time_update_timer_(0.0
f)
128 , frame_update_timer_(0.0
f)
129 , render_requested_(1)
131 , window_manager_(wm)
143 #if (OGRE_VERSION < OGRE_VERSION_CHECK(13, 0, 0))
149 rviz::RenderSystem::RenderSystem::get()->prepareOverlays(
scene_manager_);
176 "Fixed Frame",
"map",
"Frame into which all data is transformed before being displayed.",
180 new ColorProperty(
"Background Color", QColor(48, 48, 48),
"Background color for the 3D view.",
184 new IntProperty(
"Frame Rate", 30,
"RViz will try to render this many frames per second.",
188 new BoolProperty(
"Default Light",
true,
"Light source attached to the current 3D view.",
290 const Ogre::ColourValue& color,
291 bool use_self_illumination)
293 Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create(
294 name, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
295 mat->setAmbient(color * 0.5
f);
296 mat->setDiffuse(color);
297 if (use_self_illumination)
299 mat->setSelfIllumination(color);
301 mat->setLightingEnabled(
true);
302 mat->setReceiveShadows(
false);
326 float wall_dt = wall_diff.
toSec();
327 float ros_dt = ros_diff.
toSec();
409 no_frames ? QString(
"No TF data") :
476 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
480 QApplication::restoreOverrideCursor();
533 QWindow* window = vme.
panel->windowHandle();
536 double pixel_ratio = window->devicePixelRatio();
537 _vme.
x =
static_cast<int>(pixel_ratio * _vme.
x);
538 _vme.
y =
static_cast<int>(pixel_ratio * _vme.
y);
539 _vme.
last_x =
static_cast<int>(pixel_ratio * _vme.
last_x);
540 _vme.
last_y =
static_cast<int>(pixel_ratio * _vme.
last_y);
547 vme.
panel->setCursor(QCursor(Qt::ArrowCursor));
563 if (event->key() == Qt::Key_Escape)
const std::shared_ptr< tf2_ros::Buffer > getTF2BufferPtr()
double getROSTimeElapsed()
Return the ROS time in seconds since the last reset.
virtual bool getBool() const
Helper class for transforming data into Ogre's world frame (the fixed frame).
void reset() override
Reset this and all child Displays.
VisualizationManager(RenderPanel *render_panel, WindowManagerInterface *wm=nullptr, std::shared_ptr< tf2_ros::Buffer > tf_buffer=std::shared_ptr< tf2_ros::Buffer >(), std::shared_ptr< tf2_ros::TransformListener > tf_listener=std::shared_ptr< tf2_ros::TransformListener >())
Constructor Creates managers and sets up global properties.
virtual void removeAllDisplays()
Remove and destroy all child Displays, but preserve any non-Display children.
uint32_t allocBit()
Return a uint32 with a single bit "on" (previously unused), or a 0 if all bits are already allocated.
ros::Time last_update_ros_time_
Stores how long it's been since the last update.
void onToolChanged(Tool *)
void save(Config config) const override
Save subproperties and the list of displays in this group to the given Config node.
double getROSTime()
Return the ROS time, in seconds.
virtual QColor getColor() const
void setStatus(const QString &message) override
void statusUpdate(const QString &message)
Emitted during file-loading and initialization to indicate progress.
Ogre::ColourValue qtToOgre(const QColor &c)
void setFixedFrame(const std::string &frame)
Set the frame to consider "fixed", into which incoming data is transformed.
void setFixedFrame(const QString &fixed_frame)
Set the fixed frame in this display.
void initialize(DisplayContext *context)
Main initialization, called after constructor, before load() or setEnabled().
ros::CallbackQueue threaded_queue_
void handleChar(QKeyEvent *event, RenderPanel *panel) override
Handle a single key event for a given RenderPanel.
void update(float wall_dt, float ros_dt)
ros::WallTime wall_clock_begin_
ros::Time ros_time_begin_
ros::CallbackQueueInterface * getUpdateQueue() override
Return the CallbackQueue using the main GUI thread.
Ogre::Root * ogre_root_
Ogre Root.
Property * global_options_
virtual QVariant getViewData(int column, int role) const
Return data appropriate for the given column (0 or 1) and role for this Property.
void escapePressed()
Emitted when ESC key is pressed.
void queueRender() override
Queues a render. Multiple calls before a render happens will only cause a single render.
void load(const Config &config)
Load the properties of each Display and most editable rviz data.
void createColorMaterial(const std::string &name, const Ogre::ColourValue &color, bool use_self_illumination)
void handleMouseEvent(const ViewportMouseEvent &event) override
Handle a mouse event.
uint32_t render_requested_
Property specialized to provide getter for booleans.
ROSCPP_DECL void spinOnce()
void removeAllDisplays()
Remove and delete all displays.
FrameManager * frame_manager_
void createColorMaterials()
ros::NodeHandle update_nh_
void notifyConfigChanged()
Notify this VisualizationManager that something about its display configuration has changed.
bool setValue(const QVariant &new_value) override
Override from Property to resolve the frame name on the way in.
void load(const Config &config)
double getWallClockElapsed()
Return the wall clock time in seconds since the last reset.
QPixmap loadPixmap(const QString &url, bool fill_cache)
Display * createDisplay(const QString &class_id)
float frame_update_timer_
DisplayFactory * display_factory_
void update(float wall_dt, float ros_dt) override
Call update() on all child Displays.
ros::Duration ros_time_elapsed_
ColorProperty * background_color_property_
ros::Time getTime()
Get current time, depending on the sync mode.
A single element of a property tree, with a name, value, description, and possibly children.
PropertyTreeModel * display_property_tree_model_
SelectionManager * selection_manager_
void threadedQueueThreadFunc()
uint32_t default_visibility_bit_
void startUpdate()
Start timers. Creates and starts the update and idle timers, both set to 30Hz (33ms).
Ogre::SceneManager * scene_manager_
Ogre scene manager associated with this panel.
void setEnabled(bool enabled)
Enable or disable this Display.
ros::WallTime last_update_wall_time_
void resetTime()
Resets the wall and ROS elapsed time to zero and calls resetDisplays().
QString getFixedFrame() const override
Return the fixed frame name.
ros::WallDuration wall_clock_elapsed_
void configChanged()
Emitted when a Property which should be saved changes.
void setStatus(Level level, const QString &name, const QString &text)
void load(const Config &config) override
Load subproperties and the list of displays in this group from the given Config node,...
OgreRenderQueueClearer * ogre_render_queue_clearer_
ViewController * getCurrent() const
Return the current ViewController in use for the main RenderWindow.
void initialize()
Do initialization that wasn't done in constructor. Initializes tool manager, view manager,...
RenderPanel * render_panel_
boost::mutex render_mutex_
void updateBackgroundColor()
void setBackgroundColor(Ogre::ColourValue color)
void setCallbackQueue(CallbackQueueInterface *queue)
void onUpdate()
Call update() on all managed objects.
IntProperty * fps_property_
void setName(const QString &name) override
Overridden from Property to set associated widget title to the new name.
virtual void addDisplay(Display *child)
Add a child Display to the end of the list of Displays.
DisplayGroup * root_display_group_
void setFixedFrame(const QString &frame)
Set the coordinate frame we should be transforming all fixed data into.
boost::thread_group threaded_queue_threads_
Ogre::Camera * getCamera() const
void setIcon(const QIcon &icon) override
Set the icon to be displayed next to the property.
void unlockRender()
Unlock a mutex, allowing calls to Ogre::Root::renderOneFrame().
VisualizationManagerPrivate * private_
volatile bool shutting_down_
tf2_ros::Buffer * tf_buffer
void configChanged()
Emitted whenever the display configuration changes.
Display * createDisplay(const QString &class_lookup_name, const QString &name, bool enabled)
Create and add a display to this panel, by class lookup name.
ros::CallbackQueueInterface * getThreadedQueue() override
Return a CallbackQueue using a different thread than the main GUI one.
void save(Config config) const
Ogre::Light * directional_light_
TfFrameProperty * fixed_frame_property_
Frame to transform fixed data to.
void lockRender()
Lock a mutex to delay calls to Ogre::Root::renderOneFrame().
BitAllocator visibility_bit_allocator_
StatusList * global_status_
void setSelection(const M_Picked &objs)
~VisualizationManager() override
Destructor Stops update timers and destroys all displays, tools, and managers.
ToolManager * tool_manager_
void preUpdate()
Emitted before updating all Displays.
virtual int getInt() const
Return the internal property value as an integer.
void update()
Clear the internal cache.
BoolProperty * default_light_enabled_property_
IconizedProperty(const QString &name=QString(), const QVariant &default_value=QVariant(), const QString &description=QString(), Property *parent=nullptr)
void setAutoRender(bool auto_render)
void setRenderPanel(RenderPanel *render_panel)
Set the 3D view widget whose view will be controlled by ViewController instances from by this ViewMan...
ViewManager * view_manager_
double getWallClock()
Return the wall clock time, in seconds since 1970.
void emitStatusUpdate(const QString &message)
Emits statusUpdate() signal with the given message.
void addDisplay(Display *display, bool enabled)
Add a display to be managed by this panel.
boost::unordered_map< CollObjectHandle, Picked > M_Picked
void save(Config config) const
Save the properties of each Display and most editable rviz data.
void updateDefaultLightVisible()
Configuration data storage class.
A Display object which stores other Displays as children.
void setDragDropClass(const QString &drag_drop_class)
std::shared_ptr< tf2_ros::Buffer > getTF2BufferPtr() const
Convenience function: returns getFrameManager()->getTF2BufferPtr().
ros::NodeHandle threaded_nh_
QVariant getViewData(int column, int role) const override
Return data appropriate for the given column (0 or 1) and role for this Property.
ROSCPP_DECL CallbackQueue * getGlobalCallbackQueue()
Property specialized to provide max/min enforcement for integers.
QTimer * update_timer_
Display::update is called on each display whenever this timer fires.
rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Fri Aug 2 2024 08:43:10