17 #ifndef GEPETTO_VIEWER_WINDOWMANAGERS_HH
18 #define GEPETTO_VIEWER_WINDOWMANAGERS_HH
24 #include <OpenThreads/Mutex>
25 #include <OpenThreads/ScopedLock>
58 typedef std::map<WindowID, WindowManagerPtr_t> WindowManagerMap_t;
59 WindowManagerMap_t windowManagers_;
60 std::map<std::string, NodePtr_t> nodes_;
61 std::map<std::string, GroupNodePtr_t> groupNodes_;
62 std::map<std::string, RoadmapViewerPtr_t> roadmapNodes_;
66 static osgVector4 getColor(
const std::string& colorName);
67 static std::string parentName(
const std::string& name);
68 static VisibilityMode getVisibility(
const std::string& visibilityName);
70 static LightingMode getLight(
const std::string& lightName);
74 bool loadUDRF(
const std::string& urdfName,
const std::string& urdfPath,
75 bool visual,
bool linkFrame);
90 template <
typename Iterator,
typename NodeContainer_t>
91 std::size_t
getNodes(
const Iterator& begin,
const Iterator& end,
92 NodeContainer_t& nodes);
97 bool guessParent =
false);
101 bool guessParent =
false);
131 virtual bool addFloor(
const std::string& floorName);
138 virtual bool addBox(
const std::string& boxName,
const float& boxSize1,
139 const float& boxSize2,
const float& boxSize3,
142 virtual bool addCapsule(
const std::string& capsuleName,
float radius,
143 float height,
const Color_t& color);
145 virtual bool addArrow(
const std::string& arrowName,
const float radius,
146 const float length,
const Color_t& color);
149 const float radius,
const float length,
short maxCapsule);
151 virtual bool resizeCapsule(
const std::string& capsuleName,
float newHeight);
152 virtual bool resizeArrow(
const std::string& arrowName,
float newRadius,
155 virtual bool addMesh(
const std::string& meshName,
156 const std::string& meshPath);
160 virtual bool addCone(
const std::string& coneName,
float radius,
float height,
163 virtual bool addCylinder(
const std::string& cylinderName,
float radius,
164 float height,
const Color_t& color);
166 virtual bool addSphere(
const std::string& sphereName,
float radius,
170 float radius,
const Color_t& color);
191 virtual bool setCurveMode(
const std::string& curveName,
const GLenum mode);
193 const int first,
const std::size_t count);
202 const std::string& filename);
207 float radius,
float sizeAxis);
210 float radius,
float sizeAxis,
220 virtual bool addURDF(
const std::string& urdfName,
221 const std::string& urdfPath);
223 virtual bool addURDF(
const std::string& urdfName,
const std::string& urdfPath,
224 const std::string& urdfPackagePath);
227 const std::string& urdfPath);
230 const std::string& urdfPath,
231 const std::string& urdfPackagePath);
234 const std::string& urdfPath,
bool visual);
237 const std::string& urdfPath,
238 const std::string& urdfPackagePath,
bool visual);
242 const std::string& groupName);
244 const std::string& groupName);
245 virtual bool deleteNode(
const std::string& nodeName,
bool all);
251 const std::vector<std::string>& nodeName,
252 const std::vector<Configuration>& configuration);
254 virtual bool addLandmark(
const std::string& nodeName,
float size);
262 const std::string& visibilityMode);
264 virtual bool setScale(
const std::string& nodeName,
const float& scale);
266 const int& scalePercentage);
269 const std::string& wireFrameMode);
271 const std::string& lightingMode);
273 virtual bool setAlpha(
const std::string& nodeName,
const float& alpha);
275 const int& alphaPercentage);
278 const std::vector<std::string>& nodename);
282 const std::vector<std::string>& nodename);
284 const std::string& filename);
286 const std::string& filename);
297 const std::string& nodeName)
const;
299 const std::string& nodeName)
const;
301 template <
typename Property_t>
303 const std::string& propName)
const;
304 template <
typename Property_t>
305 void setProperty(
const std::string& nodeName,
const std::string& propName,
306 const Property_t& value);
309 const std::string& propName)
const;
311 const std::string& propName,
312 const std::string& value);
314 const std::string& propName)
const;
316 const std::string& propName,
319 const std::string& propName)
const;
321 const std::string& propName,
324 const std::string& propName)
const;
326 const std::string& propName,
329 const std::string& propName)
const;
331 const std::string& propName,
334 const std::string& propName)
const;
336 const std::string& propName,
const bool& value);
338 const std::string& propName)
const;
340 const std::string& propName,
const int& value);
342 const std::string& propName);
345 bool throwIfDoesntExist =
false)
const;
347 bool throwIfDoesntExist =
false)
const;
349 bool throwIfDoesntExist =
false)
const;
Manage a set of windows that may share 3D objects.
Definition: windows-manager.h:48
virtual void removeLightSources(const std::string &meshName)
See LeafNodeCollada::removeLightSources()
virtual void captureTransform()
virtual WindowID getWindowID(const std::string &windowName)
virtual bool setBackgroundColor1(const WindowID windowId, const Color_t &color)
virtual bool addURDF(const std::string &urdfName, const std::string &urdfPath)
virtual bool createGroup(const std::string &groupName)
virtual void captureTransformOnRefresh(bool autoCapture)
virtual bool setLightingMode(const std::string &nodeName, const std::string &lightingMode)
virtual bool addSquareFace(const std::string &faceName, const osgVector3 &pos1, const osgVector3 &pos2, const osgVector3 &pos3, const osgVector3 &pos4, const Color_t &color)
void refreshConfigs(const NodeConfigurations_t &configs)
virtual Configuration getCameraTransform(const WindowID windowId)
virtual bool setCaptureTransform(const std::string &filename, const std::vector< std::string > &nodename)
virtual bool addTriangleFace(const std::string &faceName, const osgVector3 &pos1, const osgVector3 &pos2, const osgVector3 &pos3, const Color_t &color)
virtual bool addUrdfCollision(const std::string &urdfName, const std::string &urdfPath)
virtual int getIntProperty(const std::string &nodeName, const std::string &propName) const
virtual bool setColor(const std::string &nodeName, const Color_t &color)
virtual bool addNodeToRoadmap(const std::string &nameRoadmap, const Configuration &configuration)
virtual bool addLight(const std::string &lightName, const WindowID wid, float radius, const Color_t &color)
virtual bool addEdgeToRoadmap(const std::string &nameRoadmap, const osgVector3 &posFrom, const osgVector3 &posTo)
virtual bool attachCameraToNode(const std::string &nodeName, const WindowID windowId)
virtual ~WindowsManager()
Definition: windows-manager.h:108
virtual bool setCurveLineWidth(const std::string &curveName, const float &width)
virtual bool setTexture(const std::string &nodeName, const std::string &filename)
virtual void setIntProperty(const std::string &nodeName, const std::string &propName, const int &value)
virtual bool addToGroup(const std::string &nodeName, const std::string &groupName)
virtual bool addCone(const std::string &coneName, float radius, float height, const Color_t &color)
Property_t getProperty(const std::string &nodeName, const std::string &propName) const
Mutex & osgFrameMutex()
Return the mutex to be locked before modifying the scene.
Definition: windows-manager.h:116
virtual bool addURDF(const std::string &urdfName, const std::string &urdfPath, const std::string &urdfPackagePath)
virtual std::string getStringProperty(const std::string &nodeName, const std::string &propName) const
virtual bool removeFromGroup(const std::string &nodeName, const std::string &groupName)
virtual bool writeBlenderScript(const std::string &filename, const std::vector< std::string > &nodename)
virtual bool addUrdfCollision(const std::string &urdfName, const std::string &urdfPath, const std::string &urdfPackagePath)
Mutex configListMtx_
Definition: windows-manager.h:85
::osg::Vec3ArrayRefPtr Vec3ArrayPtr_t
Definition: windows-manager.h:53
virtual bool nodeExists(const std::string &name)
virtual bool addLine(const std::string &lineName, const osgVector3 &pos1, const osgVector3 &pos2, const Color_t &color)
virtual bool setScale(const std::string &nodeName, const int &scalePercentage)
virtual bool addSceneToWindow(const std::string &sceneName, const WindowID windowId)
virtual bool applyConfigurations(const std::vector< std::string > &nodeName, const std::vector< Configuration > &configuration)
virtual bool setWireFrameMode(const std::string &nodeName, const std::string &wireFrameMode)
virtual Configuration getStaticTransform(const std::string &nodeName) const
virtual bool setStaticTransform(const std::string &nodeName, const Configuration &transform)
osgVector4 Color_t
Definition: windows-manager.h:52
virtual float getFloatProperty(const std::string &nodeName, const std::string &propName) const
GroupNodePtr_t getGroup(const std::string groupName, bool throwIfDoesntExist=false) const
virtual osgVector2 getVector2Property(const std::string &nodeName, const std::string &propName) const
WindowID addWindow(std::string winName, WindowManagerPtr_t newWindow)
bool autoCaptureTransform_
Definition: windows-manager.h:87
virtual bool setCurveColors(const std::string &curveName, const Vec4ArrayPtr_t &colors)
virtual bool createRoadmap(const std::string &name, const Color_t &colorNode, float radius, float sizeAxis, const Color_t &colorEdge)
virtual bool resizeArrow(const std::string &arrowName, float newRadius, float newLength)
osg::Vec3f::value_type value_type
Definition: windows-manager.h:51
virtual bool addLandmark(const std::string &nodeName, float size)
virtual bool setCurvePoints(const std::string &curveName, const Vec3ArrayPtr_t &pos)
virtual bool setHighlight(const std::string &nodeName, int state)
void setProperty(const std::string &nodeName, const std::string &propName, const Property_t &value)
virtual bool setBackgroundColor2(const WindowID windowId, const Color_t &color)
std::size_t getNodes(const Iterator &begin, const Iterator &end, NodeContainer_t &nodes)
virtual std::vector< std::string > getGroupNodeList(const std::string &group)
std::vector< NodeConfiguration > NodeConfigurations_t
Definition: windows-manager.h:84
void addGroup(const std::string &groupName, GroupNodePtr_t group, bool guessParent=false)
virtual bool deleteLandmark(const std::string &nodeName)
WindowManagerPtr_t getWindowManager(const WindowID wid, bool throwIfDoesntExist=false) const
static WindowsManagerPtr_t create()
virtual bool setCurveMode(const std::string &curveName, const GLenum mode)
virtual bool writeWindowFile(const WindowID windowId, const std::string &filename)
virtual bool addMesh(const std::string &meshName, const std::string &meshPath)
virtual bool setScale(const std::string &nodeName, const float &scale)
virtual bool addXYZaxis(const std::string &nodeName, const Color_t &color, float radius, float sizeAxis)
virtual bool setLineStartPoint(const std::string &lineName, const osgVector3 &pos1)
virtual void setBoolProperty(const std::string &nodeName, const std::string &propName, const bool &value)
virtual bool addBox(const std::string &boxName, const float &boxSize1, const float &boxSize2, const float &boxSize3, const Color_t &color)
virtual bool setCurvePointsSubset(const std::string &curveName, const int first, const std::size_t count)
virtual bool setScale(const std::string &nodeName, const osgVector3 &scale)
Configuration getNodeGlobalTransform(const std::string nodeName) const
std::string WindowID
Definition: windows-manager.h:55
virtual void addNode(const std::string &nodeName, NodePtr_t node, GroupNodePtr_t parent)
virtual void setStringProperty(const std::string &nodeName, const std::string &propName, const std::string &value)
virtual bool removeObjectFromCache(const std::string &nodeName)
virtual bool setAlpha(const std::string &nodeName, const float &alpha)
virtual void callVoidProperty(const std::string &nodeName, const std::string &propName)
virtual void addUrdfObjects(const std::string &urdfName, const std::string &urdfPath, const std::string &urdfPackagePath, bool visual)
virtual bool setVisibility(const std::string &nodeName, const std::string &visibilityMode)
NodePtr_t getNode(const std::string &nodeName, bool throwIfDoesntExist=false) const
virtual osgVector4 getColorProperty(const std::string &nodeName, const std::string &propName) const
virtual bool setLineExtremalPoints(const std::string &lineName, const osgVector3 &pos1, const osgVector3 &pos2)
virtual bool detachCamera(const WindowID windowId)
virtual void setVector3Property(const std::string &nodeName, const std::string &propName, const osgVector3 &value)
void addNode(const std::string &nodeName, NodePtr_t node, bool guessParent=false)
virtual bool resizeCapsule(const std::string &capsuleName, float newHeight)
virtual bool applyConfiguration(const std::string &nodeName, const Configuration &configuration)
virtual bool setLineEndPoint(const std::string &lineName, const osgVector3 &pos2)
virtual std::vector< std::string > getPropertyNames(const std::string &nodeName) const
virtual std::vector< std::string > getNodeList()
virtual bool addFloor(const std::string &floorName)
virtual void setColorProperty(const std::string &nodeName, const std::string &propName, const osgVector4 &value)
virtual void addGroup(const std::string &groupName, GroupNodePtr_t group, GroupNodePtr_t parent)
virtual bool setCameraToBestFit(const WindowID windowId)
virtual bool addCapsule(const std::string &capsuleName, float radius, float height, const Color_t &color)
virtual void createScene(const std::string &sceneName)
virtual bool addCylinder(const std::string &cylinderName, float radius, float height, const Color_t &color)
virtual void setVector2Property(const std::string &nodeName, const std::string &propName, const osgVector2 &value)
virtual std::vector< std::string > getSceneList()
NodeConfigurations_t newNodeConfigurations_
Definition: windows-manager.h:86
virtual std::vector< std::string > getWindowList()
virtual bool deleteNode(const std::string &nodeName, bool all)
virtual void setFloatProperty(const std::string &nodeName, const std::string &propName, const float &value)
virtual bool addSphere(const std::string &sphereName, float radius, const Color_t &color)
virtual bool addArrow(const std::string &arrowName, const float radius, const float length, const Color_t &color)
virtual bool getBoolProperty(const std::string &nodeName, const std::string &propName) const
virtual bool setCameraTransform(const WindowID windowId, const Configuration &configuration)
virtual osgVector3 getVector3Property(const std::string &nodeName, const std::string &propName) const
::osg::Vec4ArrayRefPtr Vec4ArrayPtr_t
Definition: windows-manager.h:54
virtual void addUrdfObjects(const std::string &urdfName, const std::string &urdfPath, bool visual)
virtual void createSceneWithFloor(const std::string &sceneName)
virtual std::vector< std::string > getPropertyTypes(const std::string &nodeName) const
virtual bool addRod(const std::string &rodName, const Color_t &color, const float radius, const float length, short maxCapsule)
virtual bool writeNodeFile(const std::string &nodename, const std::string &filename)
WindowsManager()
Default constructor.
virtual bool setAlpha(const std::string &nodeName, const int &alphaPercentage)
virtual bool addCurve(const std::string &curveName, const Vec3ArrayPtr_t &pos, const Color_t &color)
::osg::Vec3f osgVector3
Definition: config-osg.h:99
::osg::Vec2f osgVector2
Definition: config-osg.h:98
::osg::Vec4f osgVector4
Definition: config-osg.h:100
#define DEF_CLASS_SMART_PTR(className)
Definition: macros.h:51
viewer::NodePtr_t NodePtr_t
Definition: fwd.hh:50
viewer::shared_ptr< WindowsManager > WindowsManagerPtr_t
Definition: fwd.hh:58
viewer::GroupNodePtr_t GroupNodePtr_t
Definition: fwd.hh:53
viewer::WindowManagerPtr_t WindowManagerPtr_t
Definition: osgwidget.hh:40
LightingMode
Definition: config-osg.h:109
WireFrameMode
Definition: config-osg.h:111
OpenThreads::Mutex Mutex
Definition: windows-manager.h:30
OpenThreads::ScopedLock< Mutex > ScopedLock
Definition: windows-manager.h:31
VisibilityMode
Definition: config-osg.h:107
Definition: action-search-bar.hh:27
Definition: windows-manager.h:39
Nodes_t nodes_
Definition: windows-manager.h:42
std::vector< NodePtr_t > Nodes_t
Definition: windows-manager.h:40
osg::ref_ptr< TransformWriterVisitor > writer_visitor_
Definition: windows-manager.h:41
Definition: config-osg.h:115
Definition: windows-manager.h:35
NodePtr_t node
Definition: windows-manager.h:36