From 15b2b6ac07fd9ccae4bcb08c627245a50ed69dee Mon Sep 17 00:00:00 2001 From: Joseph Mirabel <jmirabel@laas.fr> Date: Mon, 16 Mar 2020 18:36:48 +0100 Subject: [PATCH] Expose setCurveColors --- idl/gepetto/viewer/graphical-interface.idl | 6 ++++++ src/conversions.hh | 16 +++++++++++++--- src/graphical-interface.impl.cpp | 1 + src/graphical-interface.impl.hh | 1 + 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/idl/gepetto/viewer/graphical-interface.idl b/idl/gepetto/viewer/graphical-interface.idl index 5646d96..cfa55f5 100644 --- a/idl/gepetto/viewer/graphical-interface.idl +++ b/idl/gepetto/viewer/graphical-interface.idl @@ -25,6 +25,7 @@ typedef string WindowID; typedef sequence <string> Names_t; /// Sequence of names typedef sequence<float> floatSeq; typedef sequence<Position> PositionSeq; +typedef sequence<Color> ColorSeq; typedef sequence<Transform> TransformSeq; interface NodeCallback { @@ -181,6 +182,11 @@ typedef sequence<Transform> TransformSeq; /// \param pos : waypoints of the curve. boolean setCurvePoints(in string name, in PositionSeq pos) raises (Error); + /// set colors of a curve called curveName (there should be one color per points). + /// \param name : name of the line. + /// \param color : color of each point. + boolean setCurveColors(in string name, in ColorSeq pos) raises (Error); + /// \param mode The list of possible GL modes is provided in /// gepetto::viewer::WindowsManager::setCurveMode. /// From the GL modes, remove "GL_" and put it lower case. diff --git a/src/conversions.hh b/src/conversions.hh index 3e72a9e..abc71a3 100644 --- a/src/conversions.hh +++ b/src/conversions.hh @@ -47,7 +47,7 @@ namespace gepetto { return names; } - enum ArgType { STRING, STRING_LIST, OUT_STRING_LIST, COLOR, + enum ArgType { STRING, STRING_LIST, OUT_STRING_LIST, COLOR, COLOR_SEQ, TRANSFORM, TRANSFORM_SEQ, POSITION, POSITION_SEQ, FLOAT, SHORT, LONG, BOOL, VOID, GLMODE, VECTOR2, WINDOW_ID = STRING @@ -61,6 +61,16 @@ namespace gepetto { static Out_t op (In_t color) { return Out_t (color[0], color[1], color[2], color[3]); } static Ret_t ret (Out_t in) { Ret_t r = gepetto::corbaserver::Color_alloc(); to(in, r, 4); return r; } }; + template <> struct traits<COLOR_SEQ> { + typedef const ColorSeq& In_t; + typedef ::osg::Vec4ArrayRefPtr Out_t; + static inline Out_t op (In_t in) { + Out_t out = new ::osg::Vec4Array(in.length()); + for (CORBA::ULong i = 0; i < in.length (); ++i) + (*out)[i] = ::osg::Vec4 (in[i][0],in[i][1],in[i][2],in[i][3]); + return out; + } + }; template <> struct traits<TRANSFORM> { typedef const Transform In_t; typedef Configuration Out_t; @@ -101,9 +111,9 @@ namespace gepetto { typedef const PositionSeq& In_t; typedef ::osg::Vec3ArrayRefPtr Out_t; static inline Out_t op (In_t in) { - Out_t out = new ::osg::Vec3Array; + Out_t out = new ::osg::Vec3Array(in.length()); for (CORBA::ULong i = 0; i < in.length (); ++i) - out->push_back (::osg::Vec3 (in[i][0],in[i][1],in[i][2])); + (*out)[i] = ::osg::Vec3 (in[i][0],in[i][1],in[i][2]); return out; } }; diff --git a/src/graphical-interface.impl.cpp b/src/graphical-interface.impl.cpp index f9517a2..c7dd883 100644 --- a/src/graphical-interface.impl.cpp +++ b/src/graphical-interface.impl.cpp @@ -188,6 +188,7 @@ namespace gepetto { BIND_TO_WINDOWS_MANAGER_3(BOOL, addCurve, STRING, POSITION_SEQ, COLOR) BIND_TO_WINDOWS_MANAGER_2(BOOL, setCurvePoints, STRING, POSITION_SEQ) + BIND_TO_WINDOWS_MANAGER_2(BOOL, setCurveColors, STRING, COLOR_SEQ) BIND_TO_WINDOWS_MANAGER_2(BOOL, setCurveMode, STRING, GLMODE) diff --git a/src/graphical-interface.impl.hh b/src/graphical-interface.impl.hh index 6531ffd..a3134db 100644 --- a/src/graphical-interface.impl.hh +++ b/src/graphical-interface.impl.hh @@ -93,6 +93,7 @@ public: virtual bool addCurve(const char* curveName, const PositionSeq& pos, const Color color); virtual bool setCurvePoints(const char* curveName, const PositionSeq& pos); + virtual bool setCurveColors(const char* curveName, const ColorSeq& colors); virtual bool setCurveMode(const char* curveName, const char* modeName); virtual bool setCurvePointsSubset(const char* curveName, CORBA::Long first, CORBA::Long count); -- GitLab