From ec32168b41b25a6b04c61a2d1a6f737825e5cd1d Mon Sep 17 00:00:00 2001
From: Fabian Reister <fabian.reister@kit.edu>
Date: Mon, 7 Jun 2021 08:11:43 +0200
Subject: [PATCH] arviz client: path element

---
 .../RobotAPI/components/ArViz/CMakeLists.txt  |  2 +
 .../components/ArViz/Client/elements/Path.cpp | 51 ++++++++++++++++
 .../components/ArViz/Client/elements/Path.h   | 59 +++++++++++++++++++
 3 files changed, 112 insertions(+)
 create mode 100644 source/RobotAPI/components/ArViz/Client/elements/Path.cpp
 create mode 100644 source/RobotAPI/components/ArViz/Client/elements/Path.h

diff --git a/source/RobotAPI/components/ArViz/CMakeLists.txt b/source/RobotAPI/components/ArViz/CMakeLists.txt
index 66c7aa4c3..62686bc88 100644
--- a/source/RobotAPI/components/ArViz/CMakeLists.txt
+++ b/source/RobotAPI/components/ArViz/CMakeLists.txt
@@ -15,6 +15,7 @@ set(SOURCES
     Client/elements/Mesh.cpp
     Client/elements/Robot.cpp
     Client/elements/RobotHand.cpp
+    Client/elements/Path.cpp
     Client/drawer/ArVizDrawerBase.cpp
     Client/ScopedClient.cpp
 
@@ -79,6 +80,7 @@ set(HEADERS
     Client/elements/PointCloud.h
     Client/elements/Robot.h
     Client/elements/RobotHand.h
+    Client/elements/Path.h
 
     Client/drawer/ArVizDrawerBase.h
 
diff --git a/source/RobotAPI/components/ArViz/Client/elements/Path.cpp b/source/RobotAPI/components/ArViz/Client/elements/Path.cpp
new file mode 100644
index 000000000..0a88d0893
--- /dev/null
+++ b/source/RobotAPI/components/ArViz/Client/elements/Path.cpp
@@ -0,0 +1,51 @@
+#include "Path.h"
+
+namespace armarx::viz
+{
+
+    Path& Path::clear()
+    {
+        data_->points.clear();
+        return *this;
+    }
+
+    Path& Path::lineColor(Color color)
+    {
+        data_->lineColor = color;
+
+        return *this;
+    }
+
+    Path& Path::lineColorGlasbeyLUT(std::size_t id, int alpha)
+    {
+        return lineColor(Color::fromRGBA(simox::color::GlasbeyLUT::at(id, alpha)));
+    }
+
+    Path& Path::lineWidth(float w)
+    {
+        data_->lineWidth = w;
+
+        return *this;
+    }
+
+    Path& Path::points(std::vector<Eigen::Vector3f> const& ps)
+    {
+        auto& points = data_->points;
+        points.clear();
+        points.reserve(ps.size());
+        for (auto& p : ps)
+        {
+            points.push_back(armarx::Vector3f{p.x(), p.y(), p.z()});
+        }
+
+        return *this;
+    }
+
+    Path& Path::addPoint(Eigen::Vector3f p)
+    {
+        data_->points.push_back(armarx::Vector3f{p.x(), p.y(), p.z()});
+
+        return *this;
+    }
+
+} // namespace armarx::viz
\ No newline at end of file
diff --git a/source/RobotAPI/components/ArViz/Client/elements/Path.h b/source/RobotAPI/components/ArViz/Client/elements/Path.h
new file mode 100644
index 000000000..50eec6abe
--- /dev/null
+++ b/source/RobotAPI/components/ArViz/Client/elements/Path.h
@@ -0,0 +1,59 @@
+
+
+/*
+ * This file is part of ArmarX.
+ *
+ * ArmarX is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * ArmarX is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @author     Fabian Reister ( fabian dot reister at kit dot edu )
+ * @date       2021
+ * @copyright  http://www.gnu.org/licenses/gpl-2.0.txt
+ *             GNU General Public License
+ */
+
+#pragma once
+
+#include "RobotAPI/components/ArViz/Client/elements/ElementOps.h"
+#include <RobotAPI/interface/ArViz/Elements.h>
+
+namespace armarx::viz
+{
+    class Path : public ElementOps<Path, data::ElementPath>
+    {
+    public:
+        using ElementOps::ElementOps;
+
+        Path& clear();
+
+        Path& lineColor(Color color);
+
+        template<class...Ts>
+        Path& lineColor(Ts&& ...ts)
+        {
+            return lineColor({std::forward<Ts>(ts)...});
+        }
+
+        Path& lineColorGlasbeyLUT(std::size_t id, int alpha = 255);
+
+        Path& lineWidth(float w);
+
+        Path& points(std::vector<Eigen::Vector3f> const& ps);
+
+        Path& addPoint(Eigen::Vector3f p);
+    };
+} // namespace armarx::viz
+
+
+
+
+
-- 
GitLab