diff --git a/idl/gepetto/viewer/graphical-interface.idl b/idl/gepetto/viewer/graphical-interface.idl index a589289dacc78524eb8c0330e08071c32cd2f030..609856d053572fe7f3ec01e28624320d5950c546 100644 --- a/idl/gepetto/viewer/graphical-interface.idl +++ b/idl/gepetto/viewer/graphical-interface.idl @@ -24,6 +24,7 @@ typedef unsigned long WindowID; typedef sequence <string> Names_t; /// Sequence of names typedef sequence<float> floatSeq; typedef sequence<Position> PositionSeq; +typedef sequence<Transform> TransformSeq; /// IDL of the graphical interface. /// It contains the following groups: @@ -348,6 +349,10 @@ typedef sequence<Position> PositionSeq; /// \param input configuration : Float[7] new configuration. boolean applyConfiguration(in string nodeName, in Transform configuration) raises (Error); + /// Same as \ref applyConfiguration on a list of node name and configuration. + /// Both input list should be of same length. + boolean applyConfigurations(in Names_t nodeName, in TransformSeq configuration) raises (Error); + /// Change configurations according to the last applyConfigurations.d void refresh() raises (Error); diff --git a/include/gepetto/viewer/corba/windows-manager.hh b/include/gepetto/viewer/corba/windows-manager.hh index 21874f70a6450ba8d6d2dc8f54fd59246a4c0c08..a2de9af3f2647d93e9a31a63b8ebc584f0775984 100644 --- a/include/gepetto/viewer/corba/windows-manager.hh +++ b/include/gepetto/viewer/corba/windows-manager.hh @@ -223,6 +223,7 @@ namespace graphics { virtual bool deleteNode (const std::string& nodeName, bool all); virtual bool applyConfiguration(const std::string& nodeName, const Configuration& configuration); + virtual bool applyConfigurations(const std::vector<std::string>& nodeName, const std::vector<Configuration>& configuration); virtual bool addLandmark(const std::string& nodeName, float size); virtual bool deleteLandmark(const std::string& nodeName); diff --git a/src/graphical-interface.impl.cpp b/src/graphical-interface.impl.cpp index 8b93272434d85f9a99b717e73d1c2c62c97e36b9..4cfa29e163418f02bda716e88b232e449b97dfc4 100644 --- a/src/graphical-interface.impl.cpp +++ b/src/graphical-interface.impl.cpp @@ -46,7 +46,7 @@ namespace graphics { } enum ArgType { STRING, STRING_LIST, OUT_STRING_LIST, COLOR, - TRANSFORM, POSITION, POSITION_SEQ, + TRANSFORM, TRANSFORM_SEQ, POSITION, POSITION_SEQ, FLOAT, SHORT, LONG, WINDOW_ID, BOOL, VOID, GLMODE }; @@ -71,6 +71,16 @@ namespace graphics { return ret; } }; + template <> struct traits<TRANSFORM_SEQ> { + typedef const GraphicalInterface::TransformSeq& In_t; + typedef std::vector<Configuration> Out_t; + static Out_t op (In_t in) { + Out_t out (in.length()); + for (CORBA::ULong i = 0; i < in.length (); ++i) + out[i] = traits<TRANSFORM>::op (in[i]); + return out; + } + }; template <> struct traits<POSITION> { typedef osgVector3 Out_t; typedef const GraphicalInterface::Position In_t; @@ -369,6 +379,8 @@ namespace graphics { BIND_TO_WINDOWS_MANAGER_2(BOOL, applyConfiguration, STRING, TRANSFORM) + BIND_TO_WINDOWS_MANAGER_2(BOOL, applyConfigurations, STRING_LIST, TRANSFORM_SEQ) + BIND_TO_WINDOWS_MANAGER_2(BOOL, addLandmark, STRING, FLOAT) BIND_TO_WINDOWS_MANAGER_1(BOOL, deleteLandmark, STRING) diff --git a/src/graphical-interface.impl.hh b/src/graphical-interface.impl.hh index 62d56e03ba0f8bbb10d3c845218373edb515e3b4..76f94a6631f96b76fdd64a8e06293cb9023d0b82 100644 --- a/src/graphical-interface.impl.hh +++ b/src/graphical-interface.impl.hh @@ -37,6 +37,7 @@ private: public: typedef CORBA::ULong WindowID; typedef gepetto::corbaserver::Transform Transform; + typedef gepetto::corbaserver::TransformSeq TransformSeq; typedef gepetto::corbaserver::PositionSeq PositionSeq; typedef gepetto::corbaserver::Position Position; typedef gepetto::corbaserver::Position_slice Position_slice; @@ -136,6 +137,7 @@ public: virtual bool removeFromGroup (const char* nodeNameCorba,const char* groupNameCorba) throw (Error); virtual bool applyConfiguration(const char* nodeNameCorba, const value_type* configuration) throw (Error); + virtual bool applyConfigurations(const Names_t& nodeNameCorba, const TransformSeq& configuration) throw (Error); virtual bool addLandmark(const char* nodeNameCorba, float size) throw (Error); virtual bool deleteLandmark(const char* nodeNameCorba) throw (Error); diff --git a/src/windows-manager.cpp b/src/windows-manager.cpp index 34be9af17b77be0b1ca6ce8010e7c140c9f218b1..8ec5df35c46322565bba7b805b4180d2acbc4bd8 100644 --- a/src/windows-manager.cpp +++ b/src/windows-manager.cpp @@ -956,6 +956,35 @@ namespace graphics { return true; } + bool WindowsManager::applyConfigurations (const std::vector<std::string>& nodeNames, + const std::vector<Configuration>& configurations) + { + if (nodeNames.size() != configurations.size()) + throw std::invalid_argument ("Number of node names and configurations must be equal."); + + newNodeConfigurations_.reserve ( + newNodeConfigurations_.capacity() + nodeNames.size()); + + bool success = true; + scoped_lock lock(configListMtx_); + for (std::size_t i = 0; i < nodeNames.size(); ++i) { + NodePtr_t updatedNode = getNode (nodeNames[i], false); + if (!updatedNode) { + success = false; + continue; + } + + NodeConfiguration newNodeConfiguration; + newNodeConfiguration.node = updatedNode; + newNodeConfiguration.position = configurations[i].position; + newNodeConfiguration.quat = configurations[i].quat; + + newNodeConfigurations_.push_back (newNodeConfiguration); + } + + return success; + } + bool WindowsManager::addLandmark (const std::string& nodeName, float size) {