diff --git a/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.cpp b/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.cpp index a338427b72b18b65f7afd1ad56818c8f59b9fd4d..04154b58ecc544c853838f2d2729f6bd105b1cd1 100644 --- a/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.cpp +++ b/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.cpp @@ -70,7 +70,7 @@ namespace armarx void DebugDrawerTopic::clearAll(bool sleep) { - if (topic) + if (enabled()) { topic->clearAll(); if (sleep) @@ -87,7 +87,7 @@ namespace armarx void DebugDrawerTopic::clearLayer(const std::string& layer, bool sleep) { - if (topic) + if (enabled()) { topic->clearLayer(layer); if (sleep) @@ -107,7 +107,7 @@ namespace armarx const Eigen::Vector3f& extents, const DrawColor& color, const std::string& name, const std::string& layer) { - if (topic) + if (enabled()) { topic->setBoxVisu(theLayer(layer), name, new Pose(new Vector3(position), new Quaternion(orientation)), new Vector3(extents), color); @@ -126,7 +126,7 @@ namespace armarx void DebugDrawerTopic::drawPose( const Eigen::Matrix4f& pose, const std::string& name, const std::string& layer) { - if (topic) + if (enabled()) { if (poseScale >= 1 && poseScale <= 1) // squelch compiler warning that == is unsafe { @@ -150,7 +150,7 @@ namespace armarx const Eigen::Vector3f& position, const Eigen::Vector3f& direction, float length, float width, const DrawColor& color, const std::string& name, const std::string& layer) { - if (topic) + if (enabled()) { topic->setArrowVisu(theLayer(layer), name, new armarx::Vector3(position), new armarx::Vector3(direction), color, length, width); diff --git a/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.h b/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.h index dd8217ed215abaa557db1fe872d0f5b971aa4f85..103e9991fd129b7d6d869df23130fd75d352f274 100644 --- a/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.h +++ b/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.h @@ -111,9 +111,15 @@ namespace armarx const DrawColor& color, const std::string& name, const std::string& layer = ""); + /// Indicate whether a topic is set, i.e. visualization is enabled. + bool enabled() const + { + return topic; + } /// Indicate whether a topic is set, i.e. visualization is enabled. operator bool() const; + /// Conversion operator to DebugDrawerInterfacePrx. operator DebugDrawerInterfacePrx& (); operator const DebugDrawerInterfacePrx& () const;