diff --git a/source/RobotAPI/libraries/core/test/DebugDrawerTopicTest.cpp b/source/RobotAPI/libraries/core/test/DebugDrawerTopicTest.cpp index b6a2310df6ec38de4a5bb4f413636765212b5c0e..a18af95c22d8b53f97a5ab87121e5e815213a9d4 100644 --- a/source/RobotAPI/libraries/core/test/DebugDrawerTopicTest.cpp +++ b/source/RobotAPI/libraries/core/test/DebugDrawerTopicTest.cpp @@ -59,31 +59,31 @@ struct PointCloud private: /// The point container type. using VectorT = std::vector<PointT>; - + public: - + PointCloud() {} PointCloud(const VectorT& points) : points(points) {} - + // Container methods. std::size_t size() const { return points.size(); } - + PointT& operator[](std::size_t i) { return points[i]; } const PointT& operator[](std::size_t i) const { return points[i]; } - + // Iterators. typename VectorT::iterator begin() { return points.begin(); } typename VectorT::const_iterator begin() const { return points.begin(); } typename VectorT::iterator end() { return points.end(); } typename VectorT::const_iterator end() const { return points.end(); } - - + + /// The points. VectorT points; }; -/* These test do not actually check any behaviour, +/* These test do not actually check any behaviour, * but check whether this code compiles. */ @@ -93,12 +93,12 @@ struct Fixture Fixture() { } - - const DebugDrawerTopic::VisuID id {"name", "layer"}; + + const DebugDrawerTopic::VisuID id {"layer", "name"}; const int pointSize = 10; - + DebugDrawerTopic drawer; - + PointCloud<PointT> pointCloudMutable; const PointCloud<PointT>& pointCloud = pointCloudMutable; }; @@ -107,11 +107,11 @@ struct Fixture BOOST_FIXTURE_TEST_CASE(test_drawPointCloud_PointXYZ, Fixture<PointXYZ>) { pointCloudMutable.points = { {1, 2, 3}, {2, 3, 4}, {3, 4, 5} }; - + drawer.drawPointCloud(id, pointCloud); drawer.drawPointCloud(id, pointCloud.points, DrawColor {0, 0.5, 1, 1}); - - drawer.drawPointCloud(id, pointCloud, + + drawer.drawPointCloud(id, pointCloud, [](const PointXYZ&) { return DrawColor{0, 0.5, 1, 1}; }, pointSize); } @@ -120,10 +120,10 @@ BOOST_FIXTURE_TEST_CASE(test_drawPointCloud_PointXYZRGBA, Fixture<PointXYZRGBA>) { drawer.drawPointCloud(id, pointCloud); drawer.drawPointCloud(id, pointCloud.points, DrawColor {0, 0.5, 1, 1}); - - drawer.drawPointCloud(id, pointCloud, + + drawer.drawPointCloud(id, pointCloud, [](const PointXYZRGBA&) { return DrawColor{0, 0.5, 1, 1}; }, pointSize); - + drawer.drawPointCloudRGBA(id, pointCloud, pointSize); } @@ -132,10 +132,10 @@ BOOST_FIXTURE_TEST_CASE(test_drawPointCloud_PointXYZRGBL, Fixture<PointXYZRGBL>) { drawer.drawPointCloud(id, pointCloud); drawer.drawPointCloud(id, pointCloud.points, DrawColor {0, 0.5, 1, 1}); - + drawer.drawPointCloud(id, pointCloud, [](const PointXYZRGBL&) { return DrawColor{0, 0.5, 1, 1}; }, pointSize); - + drawer.drawPointCloudRGBA(id, pointCloud, pointSize); } diff --git a/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.cpp b/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.cpp index 1a75392e053c3b162321270d2e07f1a13f5434fd..4859e7c33b5eaa88753b773b66e539172ba70879 100644 --- a/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.cpp +++ b/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.cpp @@ -16,13 +16,16 @@ namespace armarx DebugDrawerTopic::VisuID::VisuID() : VisuID("", "") {} - DebugDrawerTopic::VisuID::VisuID(const std::string& name, const std::string& layer) : - name(name), layer(layer) + DebugDrawerTopic::VisuID::VisuID(const std::string& name) : VisuID("", name) + {} + + DebugDrawerTopic::VisuID::VisuID(const std::string& layer, const std::string& name) : + layer(layer), name(name) {} std::ostream& operator<<(std::ostream& os, const DebugDrawerTopic::VisuID& rhs) { - os << "Visu '" << rhs.name << "' at layer '" << rhs.layer << "'"; + os << "Visu '" << rhs.name << "' on layer '" << rhs.layer << "'"; return os; } diff --git a/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.h b/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.h index d77b4908094e30e3ebe1a5efba89aad6e2d9638c..4b68eaa8940cf13c2922e49c6259405542474c12 100644 --- a/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.h +++ b/source/RobotAPI/libraries/core/visualization/DebugDrawerTopic.h @@ -122,7 +122,7 @@ namespace armarx * Eigen::Matrix4f pose = Eigen::Matrix4f::Identity(); * std::string layer = "layer"; * std::string name = "pose"; - * debugDrawer.drawPose({name, layer}, pose); + * debugDrawer.drawPose({layer, name}, pose); * @endcode * * @@ -141,45 +141,49 @@ namespace armarx { public: + + /** + * @brief A visualisation ID. + * + * This constructor can be called in the following ways + * (with `draw(const VisuID& id, ...)` being any drawing method): + * + * @code + * std::string name = "pose"; + * std::string layer = "layer"; + * draw(name, ...); // just the name, implicit call + * draw({name}, ...); // just the name, call with initializer list + * draw({layer, name}, ...); // layer and name, with initializer list + * @endcode + * + * (And of course by an explicit call if you want to be really verbose.) + * Not passing a layer will cause DebugDrawerTopic to use the + * preset layer. + */ struct VisuID { /// Empty constructor. VisuID(); - /** - * @brief Construct a VisuID. - * - * This constructor can be called in the following ways - * (with `draw(const VisuID& id, ...)` being any drawing method): - * - * @code - * std::string name = "pose"; - * std::string layer = "layer"; - * draw(name, ...); // just the name, implicit call - * draw({name}, ...); // just the name, call with initializer list - * draw({name, layer}, ...); // name and layer, with initializer list - * @endcode - * - * (And of course by an explicit call if you want to be really verbose.) - * Not passing a layer will cause DebugDrawerTopic to use the - * preset layer. - * - * @param name the name - * @param layer the layer name - */ - VisuID(const std::string& name, const std::string& layer = ""); + /// Construct a VisuID with given name (for drawing to the preset layer). + VisuID(const std::string& name); + /// Construct a VisuID with given name and layer. + VisuID(const std::string& layer, const std::string& name); /// Construct a VisuID from a non-std::string source (e.g. char[]). template <typename Source> VisuID(const Source& name) : VisuID(std::string(name)) {} - std::string name = ""; ///< The visu name (empty by default). std::string layer = ""; ///< The layer name (empty by default). + std::string name = ""; ///< The visu name (empty by default). + /// Streams a short human-readable description of `rhs` to `os`. friend std::ostream& operator<<(std::ostream& os, const VisuID& rhs); }; + + /// Default values for drawing functions. struct Defaults { DrawColor colorText { 0, 0, 0, 1 };