From c374713675688d5c3d082d340ea0ce592c35f6ad Mon Sep 17 00:00:00 2001
From: Rainer Kartmann <rainer.kartmann@student.kit.edu>
Date: Fri, 15 Mar 2019 16:48:27 +0100
Subject: [PATCH] Added enabled()

---
 .../libraries/core/visualization/DebugDrawerTopic.cpp  | 10 +++++-----
 .../libraries/core/visualization/DebugDrawerTopic.h    |  6 ++++++
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.cpp b/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.cpp
index a338427b7..04154b58e 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 dd8217ed2..103e9991f 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;
 
-- 
GitLab