diff --git a/idl/gepetto/viewer/graphical-interface.idl b/idl/gepetto/viewer/graphical-interface.idl index 5646d9681c00f8656eeafe103574cc2e246a4206..cfa55f53ed7253009e38606dc08c171ea66bbb64 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 3e72a9ef876d7d3fc899acb860afc99da8fa218a..abc71a3a69e766cfa7d7586f88e71cb39d47b5a5 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 f9517a21e5e942a1e6fa27656442fe90dee81657..c7dd883b1e3ea5b7b986edc87ce9578d869beb16 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 6531ffdabce732ed80723d9e0859c9f761872c3c..a3134dbe2782762aef3fc81f315b95cc12d8417f 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);