32 #include <QApplication> 36 #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) 40 #include <boost/bind.hpp> 43 #include <OgreSceneManager.h> 44 #include <OgreSceneNode.h> 45 #include <OgreLight.h> 46 #include <OgreViewport.h> 47 #include <OgreMaterialManager.h> 48 #include <OgreMaterial.h> 49 #include <OgreRenderWindow.h> 50 #include <OgreSharedPtr.h> 51 #include <OgreCamera.h> 53 #include <boost/filesystem.hpp> 94 const QVariant default_value = QVariant(),
95 const QString& description = QString(),
97 const char* changed_slot =
nullptr,
98 QObject* receiver =
nullptr)
124 #pragma GCC diagnostic push 125 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 132 #pragma GCC diagnostic pop 154 #pragma GCC diagnostic push 155 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 161 #pragma GCC diagnostic pop 170 rviz::RenderSystem::RenderSystem::get()->prepareOverlays(
scene_manager_);
197 "Frame into which all data is transformed before being displayed.",
201 new ColorProperty(
"Background Color", QColor(48, 48, 48),
"Background color for the 3D view.",
205 new IntProperty(
"Frame Rate", 30,
"RViz will try to render this many frames per second.",
209 new BoolProperty(
"Default Light",
true,
"Light source attached to the current 3D view.",
311 const Ogre::ColourValue& color,
312 bool use_self_illumination)
314 Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create(name,
ROS_PACKAGE_NAME);
315 mat->setAmbient(color * 0.5
f);
316 mat->setDiffuse(color);
317 if (use_self_illumination)
319 mat->setSelfIllumination(color);
321 mat->setLightingEnabled(
true);
322 mat->setReceiveShadows(
false);
346 float wall_dt = wall_diff.
toSec();
347 float ros_dt = ros_diff.
toSec();
425 typedef std::vector<std::string>
V_string;
428 #pragma GCC diagnostic push 429 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 433 #pragma GCC diagnostic pop 443 std::stringstream ss;
444 ss <<
"No tf data. Actual error: " << error;
463 #pragma GCC diagnostic push 464 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 468 #pragma GCC diagnostic pop 481 #pragma GCC diagnostic push 482 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 486 #pragma GCC diagnostic pop 538 QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
542 QApplication::restoreOverrideCursor();
595 #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) 596 QWindow* window = vme.
panel->windowHandle();
599 double pixel_ratio = window->devicePixelRatio();
600 _vme.
x =
static_cast<int>(pixel_ratio * _vme.
x);
601 _vme.
y =
static_cast<int>(pixel_ratio * _vme.
y);
602 _vme.
last_x =
static_cast<int>(pixel_ratio * _vme.
last_x);
603 _vme.
last_y =
static_cast<int>(pixel_ratio * _vme.
last_y);
611 vme.
panel->setCursor(QCursor(Qt::ArrowCursor));
627 if (event->key() == Qt::Key_Escape)
RenderPanel * render_panel_
ros::WallTime last_update_wall_time_
void updateBackgroundColor()
void initialize()
Do initialization that wasn't done in constructor. Initializes tool manager, view manager...
ros::WallDuration wall_clock_elapsed_
ViewController * getCurrent() const
Return the current ViewController in use for the main RenderWindow.
OgreRenderQueueClearer * ogre_render_queue_clearer_
VisualizationManager(RenderPanel *render_panel, WindowManagerInterface *wm=nullptr)
Constructor Creates managers and sets up global properties.
std::shared_ptr< tf2_ros::Buffer > getTF2BufferPtr() const override
Convenience function: returns getFrameManager()->getTF2BufferPtr().
IntProperty * fps_property_
ros::NodeHandle update_nh_
ros::NodeHandle threaded_nh_
DisplayGroup * root_display_group_
void load(const Config &config) override
Load subproperties and the list of displays in this group from the given Config node, which must be a map.
boost::unordered_map< CollObjectHandle, Picked > M_Picked
VisualizationManagerPrivate * private_
virtual QColor getColor() const
void update()
Clear the internal cache.
void onUpdate()
Call update() on all managed objects.
void configChanged()
Emitted whenever the display configuration changes.
void setAutoRender(bool auto_render)
Display * createDisplay(const QString &class_lookup_name, const QString &name, bool enabled)
Create and add a display to this panel, by class lookup name.
Ogre::Light * directional_light_
TfFrameProperty * fixed_frame_property_
Frame to transform fixed data to.
void setSelection(const M_Picked &objs)
StatusList * global_status_
A single element of a property tree, with a name, value, description, and possibly children...
void preUpdate()
Emitted before updating all Displays.
Ogre::Camera * getCamera() const
void setFixedFrame(const QString &frame)
Set the coordinate frame we should be transforming all fixed data into.
ros::CallbackQueue threaded_queue_
void unlockRender()
Unlock a mutex, allowing calls to Ogre::Root::renderOneFrame().
BoolProperty * default_light_enabled_property_
volatile bool shutting_down_
ViewManager * view_manager_
Config mapGetChild(const QString &key) const
If the referenced Node is a Map and it has a child with the given key, return a reference to the chil...
ros::CallbackQueueInterface * getThreadedQueue() override
Return a CallbackQueue using a different thread than the main GUI one.
void update(float wall_dt, float ros_dt) override
Call update() on all child Displays.
ros::Time getTime()
Get current time, depending on the sync mode.
void lockRender()
Lock a mutex to delay calls to Ogre::Root::renderOneFrame().
BitAllocator visibility_bit_allocator_
bool setValue(const QVariant &new_value) override
Override from Property to resolve the frame name on the way in.
~VisualizationManager() override
Destructor Stops update timers and destroys all displays, tools, and managers.
ToolManager * tool_manager_
Property specialized to provide max/min enforcement for integers.
void emitStatusUpdate(const QString &message)
Emits statusUpdate() signal with the given message.
Display * createDisplay(const QString &class_id)
Configuration data storage class.
Ogre::ColourValue qtToOgre(const QColor &c)
ROSCPP_DECL CallbackQueue * getGlobalCallbackQueue()
void createColorMaterial(const std::string &name, const Ogre::ColourValue &color, bool use_self_illumination)
double getWallClock()
Return the wall clock time, in seconds since 1970.
QTimer * update_timer_
Display::update is called on each display whenever this timer fires.
WindowManagerInterface * window_manager_
Helper class for transforming data into Ogre's world frame (the fixed frame).
double getROSTimeElapsed()
Return the ROS time in seconds since the last reset.
void save(Config config) const
Save the properties of each Display and most editable rviz data.
void updateDefaultLightVisible()
void addDisplay(Display *display, bool enabled)
Add a display to be managed by this panel.
A Display object which stores other Displays as children.
void statusUpdate(const QString &message)
Emitted during file-loading and initialization to indicate progress.
virtual QVariant getViewData(int column, int role) const
Return data appropriate for the given column (0 or 1) and role for this Property. ...
void onToolChanged(Tool *tool)
void setStatus(const QString &message) override
void setCallbackQueue(CallbackQueueInterface *queue)
void setRenderPanel(RenderPanel *render_panel)
Set the 3D view widget whose view will be controlled by ViewController instances from by this ViewMan...
boost::thread_group threaded_queue_threads_
Config mapMakeChild(const QString &key)
Create a child node stored with the given key, and return the child.
ros::Time ros_time_begin_
The VisualizationManager class is the central manager class of rviz, holding all the Displays...
ros::CallbackQueueInterface * getUpdateQueue() override
Return the CallbackQueue using the main GUI thread.
virtual void removeAllDisplays()
Remove and destroy all child Displays, but preserve any non-Display children.
ros::Time last_update_ros_time_
Stores how long it's been since the last update.
double getROSTime()
Return the ROS time, in seconds.
void setIcon(const QIcon &icon) override
Set the icon to be displayed next to the property.
tf::TransformListener * getTFClient()
Return the tf::TransformListener used to receive transform data.
Property * global_options_
void update(float wall_dt, float ros_dt)
void setBackgroundColor(Ogre::ColourValue color)
void handleMouseEvent(const ViewportMouseEvent &event) override
Handle a mouse event.
void load(const Config &config)
Load the properties of each Display and most editable rviz data.
void setFixedFrame(const QString &fixed_frame)
Set the fixed frame in this display.
uint32_t render_requested_
std::vector< std::string > V_string
void handleChar(QKeyEvent *event, RenderPanel *panel) override
Handle a single key event for a given RenderPanel.
ros::WallTime wall_clock_begin_
virtual int getInt() const
Return the internal property value as an integer.
void escapePressed()
Emitted when ESC key is pressed.
Ogre::Root * ogre_root_
Ogre Root.
void setDragDropClass(const QString &drag_drop_class)
void queueRender() override
Queues a render. Multiple calls before a render happens will only cause a single render.
FrameManager * frame_manager_
void reset() override
Reset this and all child Displays.
void createColorMaterials()
void setFixedFrame(const std::string &frame)
Set the frame to consider "fixed", into which incoming data is transformed.
void setEnabled(bool enabled)
Enable or disable this Display.
void setStatus(Level level, const QString &name, const QString &text)
boost::mutex render_mutex_
Property specialized to provide getter for booleans.
double getWallClockElapsed()
Return the wall clock time in seconds since the last reset.
void removeAllDisplays()
Remove and delete all displays.
tf::TransformListener * getTFClient() const override
Convenience function: returns getFrameManager()->getTFClient().
bool frameHasProblems(const std::string &frame, ros::Time time, std::string &error)
Check to see if a frame exists in the tf::TransformListener.
DisplayFactory * display_factory_
void setName(const QString &name) override
Overridden from Property to set associated widget title to the new name.
QVariant getViewData(int column, int role) const override
Return data appropriate for the given column (0 or 1) and role for this Property. ...
void notifyConfigChanged()
Notify this VisualizationManager that something about its display configuration has changed...
ColorProperty * background_color_property_
void initialize(DisplayContext *context)
Main initialization, called after constructor, before load() or setEnabled().
IconizedProperty(const QString &name=QString(), const QVariant default_value=QVariant(), const QString &description=QString(), Property *parent=nullptr, const char *changed_slot=nullptr, QObject *receiver=nullptr)
PropertyTreeModel * display_property_tree_model_
void save(Config config) const
virtual bool getBool() const
ROSCPP_DECL void spinOnce()
virtual void addDisplay(Display *child)
Add a child Display to the end of the list of Displays.
float frame_update_timer_
Ogre::SceneManager * scene_manager_
Ogre scene manager associated with this panel.
void startUpdate()
Start timers. Creates and starts the update and idle timers, both set to 30Hz (33ms).
ros::Duration ros_time_elapsed_
QPixmap loadPixmap(QString url, bool fill_cache)
void resetTime()
Resets the wall and ROS elapsed time to zero and calls resetDisplays().
QString getFixedFrame() const override
Return the fixed frame name.
const std::shared_ptr< tf2_ros::Buffer > getTF2BufferPtr()
SelectionManager * selection_manager_
void save(Config config) const override
Save subproperties and the list of displays in this group to the given Config node.
uint32_t default_visibility_bit_
void load(const Config &config)
uint32_t allocBit()
Return a uint32 with a single bit "on" (previously unused), or a 0 if all bits are already allocated...
void threadedQueueThreadFunc()