17 #ifndef GEPETTO_VIEWER_WINDOWMANAGERS_HH 18 #define GEPETTO_VIEWER_WINDOWMANAGERS_HH 20 #include <OpenThreads/Mutex> 21 #include <OpenThreads/ScopedLock> 59 typedef std::map <WindowID, WindowManagerPtr_t> WindowManagerMap_t;
60 WindowManagerMap_t windowManagers_;
61 std::map<std::string, NodePtr_t>
nodes_;
62 std::map<std::string, GroupNodePtr_t> groupNodes_;
63 std::map<std::string, RoadmapViewerPtr_t> roadmapNodes_;
67 static osgVector4 getColor(
const std::string& colorName);
68 static std::string parentName(
const std::string& name);
69 static VisibilityMode getVisibility(
const std::string& visibilityName);
71 static LightingMode getLight(
const std::string& lightName);
74 bool loadUDRF(
const std::string& urdfName,
const std::string& urdfPath,
75 bool visual,
bool linkFrame);
88 void refreshConfigs (
const NodeConfigurations_t& configs);
90 template <
typename Iterator,
typename NodeContainer_t>
92 (
const Iterator& begin,
const Iterator& end, NodeContainer_t& nodes);
95 void addNode (
const std::string& nodeName,
NodePtr_t node,
bool guessParent =
false);
97 void addGroup(
const std::string& groupName,
GroupNodePtr_t group,
bool guessParent =
false);
105 virtual std::vector<std::string> getNodeList();
106 virtual std::vector<std::string> getGroupNodeList(
const std::string& group);
107 virtual std::vector<std::string> getSceneList();
108 virtual std::vector<std::string> getWindowList();
115 virtual WindowID getWindowID (
const std::string& windowName);
117 virtual void createScene(
const std::string& sceneName);
118 virtual void createSceneWithFloor(
const std::string& sceneName);
119 virtual bool addSceneToWindow(
const std::string& sceneName,
const WindowID windowId);
121 virtual bool attachCameraToNode(
const std::string& nodeName,
const WindowID windowId);
122 virtual bool detachCamera(
const WindowID windowId);
124 virtual bool nodeExists (
const std::string& name);
126 virtual bool addFloor(
const std::string& floorName);
133 virtual bool addBox(
const std::string& boxName,
const float& boxSize1,
const float& boxSize2,
const float& boxSize3,
const Color_t& color);
135 virtual bool addCapsule(
const std::string& capsuleName,
float radius,
float height,
const Color_t& color);
137 virtual bool addArrow (
const std::string& arrowName,
const float radius,
const float length,
const Color_t& color);
139 virtual bool addRod (
const std::string& rodName,
const Color_t& color,
const float radius,
const float length,
short maxCapsule);
141 virtual bool resizeCapsule(
const std::string& capsuleName,
float newHeight);
142 virtual bool resizeArrow(
const std::string& arrowName ,
float newRadius,
float newLength);
144 virtual bool addMesh(
const std::string& meshName,
const std::string& meshPath);
146 virtual void removeLightSources(
const std::string& meshName);
148 virtual bool addCone(
const std::string& coneName,
float radius,
float height,
const Color_t& color);
150 virtual bool addCylinder(
const std::string& cylinderName,
float radius,
float height,
const Color_t& color);
152 virtual bool addSphere(
const std::string& sphereName,
float radius,
const Color_t& color);
154 virtual bool addLight(
const std::string& lightName,
const WindowID wid,
float radius,
const Color_t& color);
156 virtual bool addLine(
const std::string& lineName,
const osgVector3& pos1,
const osgVector3& pos2,
const Color_t& color);
157 virtual bool setLineStartPoint(
const std::string& lineName,
const osgVector3& pos1);
158 virtual bool setLineEndPoint(
const std::string& lineName,
const osgVector3& pos2);
159 virtual bool setLineExtremalPoints(
const std::string& lineName,
const osgVector3& pos1,
const osgVector3& pos2);
161 virtual bool addCurve(
const std::string& curveName,
const Vec3ArrayPtr_t& pos,
const Color_t& color);
163 virtual bool setCurvePoints(
const std::string& curveName,
const Vec3ArrayPtr_t& pos);
164 virtual bool setCurveColors(
const std::string& curveName,
const Vec4ArrayPtr_t& colors);
167 virtual bool setCurveMode (
const std::string& curveName,
const GLenum mode);
168 virtual bool setCurvePointsSubset (
const std::string& curveName,
const int first,
const std::size_t count);
169 virtual bool setCurveLineWidth (
const std::string& curveName,
const float& width);
172 virtual bool setTexture (
const std::string& nodeName,
const std::string& filename);
173 virtual bool addTriangleFace(
const std::string& faceName,
const osgVector3& pos1,
const osgVector3& pos2,
const osgVector3& pos3,
const Color_t& color);
174 virtual bool addXYZaxis (
const std::string& nodeName,
const Color_t& color,
float radius,
float sizeAxis);
176 virtual bool createRoadmap(
const std::string& name,
const Color_t& colorNode,
float radius,
float sizeAxis,
const Color_t& colorEdge);
178 virtual bool addEdgeToRoadmap(
const std::string& nameRoadmap,
const osgVector3& posFrom,
const osgVector3& posTo);
180 virtual bool addNodeToRoadmap(
const std::string& nameRoadmap,
const Configuration& configuration);
182 virtual bool addURDF(
const std::string& urdfName,
const std::string& urdfPath);
184 virtual bool addURDF(
const std::string& urdfName,
const std::string& urdfPath,
const std::string& urdfPackagePath);
186 virtual bool addUrdfCollision (
const std::string& urdfName,
187 const std::string& urdfPath) ;
189 virtual bool addUrdfCollision (
const std::string& urdfName,
190 const std::string& urdfPath,
191 const std::string& urdfPackagePath) ;
193 virtual void addUrdfObjects (
const std::string& urdfName,
194 const std::string& urdfPath,
197 virtual void addUrdfObjects (
const std::string& urdfName,
198 const std::string& urdfPath,
199 const std::string& urdfPackagePath,
202 virtual bool createGroup(
const std::string& groupName);
203 virtual bool addToGroup(
const std::string& nodeName,
const std::string& groupName);
204 virtual bool removeFromGroup (
const std::string& nodeName,
const std::string& groupName);
205 virtual bool deleteNode (
const std::string& nodeName,
bool all);
207 virtual bool applyConfiguration(
const std::string& nodeName,
const Configuration& configuration);
208 virtual bool applyConfigurations(
const std::vector<std::string>& nodeName,
const std::vector<Configuration>& configuration);
210 virtual bool addLandmark(
const std::string& nodeName,
float size);
211 virtual bool deleteLandmark(
const std::string& nodeName);
213 virtual Configuration getStaticTransform (
const std::string& nodeName)
const;
214 virtual bool setStaticTransform (
const std::string& nodeName,
const Configuration& transform);
216 virtual bool setVisibility(
const std::string& nodeName,
const std::string& visibilityMode);
217 virtual bool setScale(
const std::string& nodeName,
const osgVector3& scale);
218 virtual bool setScale(
const std::string& nodeName,
const float& scale);
219 virtual bool setScale(
const std::string& nodeName,
const int& scalePercentage);
220 virtual bool setColor(
const std::string& nodeName,
const Color_t& color);
221 virtual bool setWireFrameMode(
const std::string& nodeName,
const std::string& wireFrameMode);
222 virtual bool setLightingMode(
const std::string& nodeName,
const std::string& lightingMode);
223 virtual bool setHighlight(
const std::string& nodeName,
int state);
224 virtual bool setAlpha(
const std::string& nodeName,
const float& alpha);
225 virtual bool setAlpha(
const std::string& nodeName,
const int& alphaPercentage);
227 virtual bool setCaptureTransform (
const std::string& filename,
const std::vector<std::string>& nodename);
228 virtual void captureTransformOnRefresh (
bool autoCapture);
229 virtual void captureTransform ();
230 virtual bool writeBlenderScript (
const std::string& filename,
const std::vector<std::string>& nodename);
231 virtual bool writeNodeFile (
const std::string& nodename,
const std::string& filename);
232 virtual bool writeWindowFile (
const WindowID windowId,
const std::string& filename);
233 virtual bool setBackgroundColor1(
const WindowID windowId,
const Color_t& color);
234 virtual bool setBackgroundColor2(
const WindowID windowId,
const Color_t& color);
235 virtual Configuration getCameraTransform(
const WindowID windowId);
236 virtual bool setCameraTransform(
const WindowID windowId,
const Configuration &configuration);
238 virtual std::vector<std::string> getPropertyNames(
const std::string& nodeName)
const;
239 virtual std::vector<std::string> getPropertyTypes(
const std::string& nodeName)
const;
241 template <
typename Property_t> Property_t getProperty (
const std::string& nodeName,
const std::string& propName)
const;
242 template <
typename Property_t>
void setProperty (
const std::string& nodeName,
const std::string& propName,
const Property_t& value);
244 virtual std::string getStringProperty(
const std::string& nodeName,
const std::string& propName)
const;
245 virtual void setStringProperty(
const std::string& nodeName,
const std::string& propName,
const std::string& value);
246 virtual osgVector2 getVector2Property(
const std::string& nodeName,
const std::string& propName)
const;
247 virtual void setVector2Property(
const std::string& nodeName,
const std::string& propName,
const osgVector2& value);
248 virtual osgVector3 getVector3Property(
const std::string& nodeName,
const std::string& propName)
const;
249 virtual void setVector3Property(
const std::string& nodeName,
const std::string& propName,
const osgVector3& value);
250 virtual osgVector4 getColorProperty(
const std::string& nodeName,
const std::string& propName)
const;
251 virtual void setColorProperty(
const std::string& nodeName,
const std::string& propName,
const osgVector4& value);
252 virtual float getFloatProperty(
const std::string& nodeName,
const std::string& propName)
const;
253 virtual void setFloatProperty(
const std::string& nodeName,
const std::string& propName,
const float& value);
254 virtual bool getBoolProperty(
const std::string& nodeName,
const std::string& propName)
const;
255 virtual void setBoolProperty(
const std::string& nodeName,
const std::string& propName,
const bool& value);
256 virtual int getIntProperty(
const std::string& nodeName,
const std::string& propName)
const;
257 virtual void setIntProperty(
const std::string& nodeName,
const std::string& propName,
const int& value);
258 virtual void callVoidProperty(
const std::string& nodeName,
const std::string& propName);
260 WindowManagerPtr_t getWindowManager (
const WindowID wid,
bool throwIfDoesntExist =
false)
const;
261 GroupNodePtr_t getGroup (
const std::string groupName,
bool throwIfDoesntExist =
false)
const;
262 NodePtr_t getNode (
const std::string& nodeName,
bool throwIfDoesntExist =
false)
const;
263 Configuration getNodeGlobalTransform(
const std::string nodeName)
const;
std::vector< NodeConfiguration > NodeConfigurations_t
Definition: windows-manager.h:84
viewer::WindowManagerPtr_t WindowManagerPtr_t
Definition: osgwidget.hh:40
NodePtr_t node
Definition: windows-manager.h:36
::osg::Vec3f osgVector3
Definition: config-osg.h:109
Mutex configListMtx_
Definition: windows-manager.h:85
::osg::Vec2f osgVector2
Definition: config-osg.h:108
::osg::Vec4f osgVector4
Definition: config-osg.h:110
VisibilityMode
Definition: config-osg.h:117
osg::Vec3f::value_type value_type
Definition: windows-manager.h:52
::osg::Vec4ArrayRefPtr Vec4ArrayPtr_t
Definition: windows-manager.h:55
Mutex & osgFrameMutex()
Return the mutex to be locked before modifying the scene.
Definition: windows-manager.h:111
Definition: windows-manager.h:35
OpenThreads::ScopedLock< Mutex > ScopedLock
Definition: windows-manager.h:31
std::string WindowID
Definition: windows-manager.h:56
viewer::NodePtr_t NodePtr_t
Definition: fwd.hh:47
Definition: action-search-bar.hh:27
osg::ref_ptr< TransformWriterVisitor > writer_visitor_
Definition: windows-manager.h:41
viewer::GroupNodePtr_t GroupNodePtr_t
Definition: fwd.hh:50
Nodes_t nodes_
Definition: windows-manager.h:42
Manage a set of windows that may share 3D objects.
Definition: windows-manager.h:48
::osg::Vec3ArrayRefPtr Vec3ArrayPtr_t
Definition: windows-manager.h:54
LightingMode
Definition: config-osg.h:124
Definition: config-osg.h:144
osgVector4 Color_t
Definition: windows-manager.h:53
bool autoCaptureTransform_
Definition: windows-manager.h:87
OpenThreads::Mutex Mutex
Definition: windows-manager.h:30
std::vector< NodePtr_t > Nodes_t
Definition: windows-manager.h:40
#define DEF_CLASS_SMART_PTR(className)
Definition: macros.h:50
Definition: windows-manager.h:39
NodeConfigurations_t newNodeConfigurations_
Definition: windows-manager.h:86
WireFrameMode
Definition: config-osg.h:130
viewer::shared_ptr< WindowsManager > WindowsManagerPtr_t
Definition: fwd.hh:55
virtual ~WindowsManager()
Definition: windows-manager.h:103