RobWorkProject  23.9.11-
Public Types | Public Member Functions | List of all members
WorkCellScene Class Reference

class for wrapping the SceneGraph interface such that it extends the scene-graph functionality to work on frames and workcells. More...

#include <WorkCellScene.hpp>

Public Types

typedef rw::core::Ptr< WorkCellScenePtr
 smart pointer to this class
 

Public Member Functions

 WorkCellScene (SceneGraph::Ptr scene)
 constructor - creates a workcell with a current SceneGraph More...
 
virtual ~WorkCellScene ()
 destructor
 
void draw (SceneGraph::RenderInfo &info)
 renders the complete scene using the settings in info. More...
 
void setWorkCell (rw::core::Ptr< rw::models::WorkCell > wc)
 set the workcell to render More...
 
rw::core::Ptr< rw::models::WorkCellgetWorkCell ()
 get the workcell that is currently being rendered.
 
void setState (const rw::kinematics::State &state)
 state changes are updated by calling this method. That includes transformations between frames, joints and stuff. More...
 
rw::graphics::GroupNode::Ptr getWorldNode ()
 gets the node of the scene graph that maps to the world frame of the workcell. More...
 
void updateSceneGraph (const rw::kinematics::State &state)
 updates the state of the scenegraph to that of state More...
 
void clearCache ()
 any cached drawables or scene nodes are deleted
 
void setVisible (bool visible, const rw::core::Ptr< rw::kinematics::Frame > f)
 sets the visibility of a frame and its drawables. More...
 
bool isVisible (const rw::core::Ptr< rw::kinematics::Frame > f) const
 test if a frame is visible or not More...
 
void setHighlighted (bool highlighted, const rw::core::Ptr< rw::kinematics::Frame > f)
 sets a frame to be highlighted or not. More...
 
bool isHighlighted (const rw::core::Ptr< rw::kinematics::Frame > f) const
 test if a frame is highlighted or not More...
 
void setFrameAxisVisible (bool visible, rw::core::Ptr< rw::kinematics::Frame > f, double size=0.25)
 enables the drawing of the frame-axis of a frame. More...
 
bool isFrameAxisVisible (const rw::core::Ptr< rw::kinematics::Frame > f) const
 test if frame-axis is visible More...
 
void setFrameLabelVisible (bool visible, rw::kinematics::Frame::Ptr f)
 enables the drawing of the frame label of a frame. More...
 
bool isFrameLabelVisible (const rw::kinematics::Frame::Ptr f) const
 test if frame-label is visible More...
 
void setDrawType (DrawableNode::DrawType type, const rw::core::Ptr< rw::kinematics::Frame > f)
 set how drawables of a specific frame should be rendered More...
 
DrawableNode::DrawType getDrawType (const rw::core::Ptr< rw::kinematics::Frame > f) const
 get how drawables of a specific frame is to be rendered More...
 
void setDrawMask (unsigned int mask, const rw::core::Ptr< rw::kinematics::Frame > f)
 set the draw mask of the drawables of a specific frame More...
 
unsigned int getDrawMask (const rw::core::Ptr< rw::kinematics::Frame > f) const
 get the draw mask of the drawables of a specific frame More...
 
void setTransparency (double alpha, const rw::core::Ptr< rw::kinematics::Frame > f)
 set drawables of a frame to be translusent More...
 
rw::core::Ptr< rw::graphics::DrawableGeometryNodeaddLines (const std::string &name, const std::vector< rw::geometry::Line > &lines, rw::core::Ptr< rw::kinematics::Frame > frame, int dmask=DrawableNode::Physical)
 create and add a drawable geometry node of line geometry to the scene More...
 
rw::core::Ptr< rw::graphics::DrawableGeometryNodeaddGeometry (const std::string &name, rw::core::Ptr< rw::geometry::Geometry > geom, rw::core::Ptr< rw::kinematics::Frame > frame, int dmask=DrawableNode::Physical)
 create and add a drawable geometry node of any type of geometry to the scene More...
 
DrawableNode::Ptr addFrameAxis (const std::string &name, double size, rw::core::Ptr< rw::kinematics::Frame > frame, int dmask=DrawableNode::Virtual)
 create and add a drawable node of a frame axis to the scene More...
 
DrawableNode::Ptr addModel3D (const std::string &name, rw::core::Ptr< rw::geometry::Model3D > model, rw::core::Ptr< rw::kinematics::Frame > frame, int dmask=DrawableNode::Physical)
 create and add a drawable node of a model3d to the scene More...
 
DrawableNode::Ptr addImage (const std::string &name, const rw::sensor::Image &img, rw::core::Ptr< rw::kinematics::Frame > frame, int dmask=DrawableNode::Virtual)
 create and add a drawable node of an image to the scene More...
 
DrawableNode::Ptr addScan (const std::string &name, const rw::geometry::PointCloud &scan, rw::core::Ptr< rw::kinematics::Frame > frame, int dmask=DrawableNode::Virtual)
 create and add a drawable node of a scan to the scene More...
 
DrawableNode::Ptr addText (const std::string &name, const std::string &text, rw::core::Ptr< rw::kinematics::Frame > frame, int dmask=DrawableNode::Virtual)
 create and add a drawable node of a textlabel More...
 
DrawableNode::Ptr addRender (const std::string &name, rw::core::Ptr< rw::graphics::Render > render, rw::core::Ptr< rw::kinematics::Frame > frame, int dmask=DrawableNode::Physical)
 create and add a drawable node of a render, to the scene More...
 
DrawableNode::Ptr addDrawable (const std::string &filename, rw::core::Ptr< rw::kinematics::Frame > frame, int dmask=DrawableNode::Physical)
 create and add a drawable node from a filename to the scene More...
 
void addDrawable (DrawableNode::Ptr drawable, rw::core::Ptr< rw::kinematics::Frame > frame)
 add a drawable node to the scene More...
 
std::vector< DrawableNode::PtrgetDrawables ()
 get all drawables of the WorkCellScene More...
 
std::vector< DrawableNode::PtrgetDrawables (const rw::core::Ptr< rw::kinematics::Frame > f) const
 get all drawables of a specific frame in the WorkCellScene More...
 
std::vector< DrawableNode::PtrgetDrawablesRec (rw::core::Ptr< rw::kinematics::Frame > f, rw::kinematics::State &state)
 get all drawables of a frame and all frames that kinematicly is connected to the sub-tree of f. More...
 
DrawableNode::Ptr findDrawable (const std::string &name)
 find a drawable by name name. More...
 
DrawableNode::Ptr findDrawable (const std::string &name, const rw::core::Ptr< rw::kinematics::Frame > frame)
 find a drawable by name name that is attached to frame frame More...
 
std::vector< DrawableNode::PtrfindDrawables (const std::string &name)
 find all drawables by name name. More...
 
bool removeDrawables (const rw::core::Ptr< rw::kinematics::Frame > f)
 remove all drawables on a frame More...
 
bool removeDrawables (const std::string &name)
 remove all drawables with name
name More...
 
bool removeDrawable (DrawableNode::Ptr drawable)
 remove a drawable from the scene More...
 
bool removeDrawable (DrawableNode::Ptr drawable, const rw::core::Ptr< rw::kinematics::Frame > f)
 remove a drawable from a specific frame More...
 
bool removeDrawable (const std::string &name)
 remove first drawable by name name More...
 
bool removeDrawable (const std::string &name, const rw::core::Ptr< rw::kinematics::Frame > f)
 remove drawable by name
and which is attached to frame f More...
 
rw::kinematics::FramegetFrame (DrawableNode::Ptr d) const
 get the frame that a specific drawable d is associated to More...
 
rw::graphics::GroupNode::Ptr getNode (const rw::core::Ptr< rw::kinematics::Frame > frame) const
 Get the GroupNode corresponding to the given frame. More...
 

Detailed Description

class for wrapping the SceneGraph interface such that it extends the scene-graph functionality to work on frames and workcells.

The scene graph is composed of nodes which are related to Frames. Each frame can have several Drawables attached which can be considered as leafs. Beside keeping track of the mapping from frames to scenenodes, this class also adds settings such as highlighted, adding of frameaxis(per Frame), visibility and so on.

Constructor & Destructor Documentation

◆ WorkCellScene()

constructor - creates a workcell with a current SceneGraph

Parameters
scene[in] scene graph to use.

Member Function Documentation

◆ addDrawable() [1/2]

DrawableNode::Ptr addDrawable ( const std::string &  filename,
rw::core::Ptr< rw::kinematics::Frame frame,
int  dmask = DrawableNode::Physical 
)

create and add a drawable node from a filename to the scene

Parameters
filename[in] name of drawable node
frame[in] the frame where the drawable is to be placed
dmask[in] the drawable mask
Returns
the drawable node

◆ addDrawable() [2/2]

void addDrawable ( DrawableNode::Ptr  drawable,
rw::core::Ptr< rw::kinematics::Frame frame 
)

add a drawable node to the scene

Parameters
drawable[in] the drawable
frame[in] the frame where the drawable is to be placed

◆ addFrameAxis()

DrawableNode::Ptr addFrameAxis ( const std::string &  name,
double  size,
rw::core::Ptr< rw::kinematics::Frame frame,
int  dmask = DrawableNode::Virtual 
)

create and add a drawable node of a frame axis to the scene

Parameters
name[in] name of drawable node
size[in] the length of the axis arrows in meters
frame[in] the frame where the drawable is to be placed
dmask[in] the drawable mask
Returns
the drawable node geometry

◆ addGeometry()

rw::core::Ptr<rw::graphics::DrawableGeometryNode> addGeometry ( const std::string &  name,
rw::core::Ptr< rw::geometry::Geometry geom,
rw::core::Ptr< rw::kinematics::Frame frame,
int  dmask = DrawableNode::Physical 
)

create and add a drawable geometry node of any type of geometry to the scene

Parameters
name[in] name of drawable node
geom[in] the geometry
frame[in] the frame where the drawable is to be placed
dmask[in] the drawable mask
Returns
the drawable node geometry

◆ addImage()

DrawableNode::Ptr addImage ( const std::string &  name,
const rw::sensor::Image img,
rw::core::Ptr< rw::kinematics::Frame frame,
int  dmask = DrawableNode::Virtual 
)

create and add a drawable node of an image to the scene

Parameters
name[in] name of drawable node
img[in] the image
frame[in] the frame where the drawable is to be placed
dmask[in] the drawable mask
Returns
the drawable node geometry
Note
the size of the image in the scene will be pixel/cm. To change this please use scale.

◆ addLines()

rw::core::Ptr<rw::graphics::DrawableGeometryNode> addLines ( const std::string &  name,
const std::vector< rw::geometry::Line > &  lines,
rw::core::Ptr< rw::kinematics::Frame frame,
int  dmask = DrawableNode::Physical 
)

create and add a drawable geometry node of line geometry to the scene

Parameters
name[in] name of drawable node
lines[in] the line geometry
frame[in] the frame where the drawable is to be placed
dmask[in] the drawable mask
Returns
the drawable node geometry

◆ addModel3D()

DrawableNode::Ptr addModel3D ( const std::string &  name,
rw::core::Ptr< rw::geometry::Model3D model,
rw::core::Ptr< rw::kinematics::Frame frame,
int  dmask = DrawableNode::Physical 
)

create and add a drawable node of a model3d to the scene

Parameters
name[in] name of drawable node
model[in] the model3d
frame[in] the frame where the drawable is to be placed
dmask[in] the drawable mask
Returns
the drawable node geometry

◆ addRender()

DrawableNode::Ptr addRender ( const std::string &  name,
rw::core::Ptr< rw::graphics::Render render,
rw::core::Ptr< rw::kinematics::Frame frame,
int  dmask = DrawableNode::Physical 
)

create and add a drawable node of a render, to the scene

Parameters
name[in] name of drawable node
render[in] the render
frame[in] the frame where the drawable is to be placed
dmask[in] the drawable mask
Returns
the drawable node

◆ addScan()

DrawableNode::Ptr addScan ( const std::string &  name,
const rw::geometry::PointCloud scan,
rw::core::Ptr< rw::kinematics::Frame frame,
int  dmask = DrawableNode::Virtual 
)

create and add a drawable node of a scan to the scene

Parameters
name[in] name of drawable node
scan[in] the scan
frame[in] the frame where the drawable is to be placed
dmask[in] the drawable mask
Returns
the drawable node

◆ addText()

DrawableNode::Ptr addText ( const std::string &  name,
const std::string &  text,
rw::core::Ptr< rw::kinematics::Frame frame,
int  dmask = DrawableNode::Virtual 
)

create and add a drawable node of a textlabel

Parameters
name[in] name of drawable node
text[in] the label text
frame[in] the frame where the drawable is to be placed
dmask[in] the drawable mask
Returns
the drawable node

◆ draw()

void draw ( SceneGraph::RenderInfo info)

renders the complete scene using the settings in info.

This basically forwards the call to SceneGraph::draw

Parameters
info[in] render settings

◆ findDrawable() [1/2]

DrawableNode::Ptr findDrawable ( const std::string &  name)

find a drawable by name name.

Parameters
name[in] the name of the drawable
Returns
a drawable with name name or NULL if no such drawable exist in the scene

◆ findDrawable() [2/2]

DrawableNode::Ptr findDrawable ( const std::string &  name,
const rw::core::Ptr< rw::kinematics::Frame frame 
)

find a drawable by name name that is attached to frame frame

Parameters
name[in] the name of the drawable
frame[in] search only the subtree beginning from this frame.
Returns
a drawable with name name or NULL if no such drawable exist in the scene

◆ findDrawables()

std::vector<DrawableNode::Ptr> findDrawables ( const std::string &  name)

find all drawables by name name.

Parameters
name[in] the name of the drawable
Returns
all drawables with name name

◆ getDrawables() [1/2]

std::vector<DrawableNode::Ptr> getDrawables ( )

get all drawables of the WorkCellScene

Returns
a list of drawables

◆ getDrawables() [2/2]

std::vector<DrawableNode::Ptr> getDrawables ( const rw::core::Ptr< rw::kinematics::Frame f) const

get all drawables of a specific frame in the WorkCellScene

Parameters
f[in] the frame
Returns
a list of drawables

◆ getDrawablesRec()

std::vector<DrawableNode::Ptr> getDrawablesRec ( rw::core::Ptr< rw::kinematics::Frame f,
rw::kinematics::State state 
)

get all drawables of a frame and all frames that kinematicly is connected to the sub-tree of f.

Parameters
f[in] the frame
state[in] the current state
Returns
a list of drawables

◆ getDrawMask()

unsigned int getDrawMask ( const rw::core::Ptr< rw::kinematics::Frame f) const

get the draw mask of the drawables of a specific frame

Parameters
f[in] the frame
Returns
the drawmask

◆ getDrawType()

DrawableNode::DrawType getDrawType ( const rw::core::Ptr< rw::kinematics::Frame f) const

get how drawables of a specific frame is to be rendered

Parameters
f[in] the Frame
Returns
the drawtype

◆ getFrame()

rw::kinematics::Frame* getFrame ( DrawableNode::Ptr  d) const

get the frame that a specific drawable d is associated to

Parameters
d[in] the drawable
Returns
the first frame that the drawable is associated to, or NULL if there are no associations

◆ getNode()

Get the GroupNode corresponding to the given frame.

Parameters
frame[in] the frame.
Returns
group node.

◆ getWorldNode()

rw::graphics::GroupNode::Ptr getWorldNode ( )

gets the node of the scene graph that maps to the world frame of the workcell.

Returns
scene node

◆ isFrameAxisVisible()

bool isFrameAxisVisible ( const rw::core::Ptr< rw::kinematics::Frame f) const

test if frame-axis is visible

Parameters
f[in] the frame
Returns
true if frame axis of frame is set to be drawn, false otherwise

◆ isFrameLabelVisible()

bool isFrameLabelVisible ( const rw::kinematics::Frame::Ptr  f) const

test if frame-label is visible

Parameters
f[in] the frame
Returns
true if frame label of frame is set to be drawn, false otherwise

◆ isHighlighted()

bool isHighlighted ( const rw::core::Ptr< rw::kinematics::Frame f) const

test if a frame is highlighted or not

Parameters
f[in] the frame
Returns
true if frame is highlighted, false if not

◆ isVisible()

bool isVisible ( const rw::core::Ptr< rw::kinematics::Frame f) const

test if a frame is visible or not

Parameters
f[in] the frame
Returns
true if frame is visible, false if not

◆ removeDrawable() [1/4]

bool removeDrawable ( const std::string &  name)

remove first drawable by name name

Parameters
name[in] the name
Returns
true if successfull

◆ removeDrawable() [2/4]

bool removeDrawable ( const std::string &  name,
const rw::core::Ptr< rw::kinematics::Frame f 
)

remove drawable by name
and which is attached to frame f

Parameters
name[in] name of drawable
f[in] the frame
Returns
true if successfull

◆ removeDrawable() [3/4]

bool removeDrawable ( DrawableNode::Ptr  drawable)

remove a drawable from the scene

Parameters
drawable[in] the drawable
Returns
true if successfull

◆ removeDrawable() [4/4]

bool removeDrawable ( DrawableNode::Ptr  drawable,
const rw::core::Ptr< rw::kinematics::Frame f 
)

remove a drawable from a specific frame

Parameters
drawable[in] the drawable
f[in] the frame
Returns
true if successfull

◆ removeDrawables() [1/2]

bool removeDrawables ( const rw::core::Ptr< rw::kinematics::Frame f)

remove all drawables on a frame

Parameters
f[in] the frame
Returns
true if successfull

◆ removeDrawables() [2/2]

bool removeDrawables ( const std::string &  name)

remove all drawables with name
name

Parameters
name[in] the name
Returns
true if successfull

◆ setDrawMask()

void setDrawMask ( unsigned int  mask,
const rw::core::Ptr< rw::kinematics::Frame f 
)

set the draw mask of the drawables of a specific frame

Parameters
mask[in] draw mask
f[in] the frame

◆ setDrawType()

void setDrawType ( DrawableNode::DrawType  type,
const rw::core::Ptr< rw::kinematics::Frame f 
)

set how drawables of a specific frame should be rendered

Parameters
type[in] the drawtype
f[in] the Frame

◆ setFrameAxisVisible()

void setFrameAxisVisible ( bool  visible,
rw::core::Ptr< rw::kinematics::Frame f,
double  size = 0.25 
)

enables the drawing of the frame-axis of a frame.

Parameters
visible[in] true if frame axis should be drawn, false otherwise
f[in] the frame
size[in] size of the frame-axis (default = 0.25)

◆ setFrameLabelVisible()

void setFrameLabelVisible ( bool  visible,
rw::kinematics::Frame::Ptr  f 
)

enables the drawing of the frame label of a frame.

Parameters
visible[in] true if frame label should be drawn, false otherwise
f[in] the frame

◆ setHighlighted()

void setHighlighted ( bool  highlighted,
const rw::core::Ptr< rw::kinematics::Frame f 
)

sets a frame to be highlighted or not.

Parameters
f[in] the frame.
highlighted[in] true if frame should be highlighted, false otherwise

◆ setState()

void setState ( const rw::kinematics::State state)

state changes are updated by calling this method. That includes transformations between frames, joints and stuff.

Parameters
state[in] the new state that is to be rendered

◆ setTransparency()

void setTransparency ( double  alpha,
const rw::core::Ptr< rw::kinematics::Frame f 
)

set drawables of a frame to be translusent

Parameters
alpha[in] range [0-1] where 1 is fully opaque and 0 is folly transparent
f[in] frame

◆ setVisible()

void setVisible ( bool  visible,
const rw::core::Ptr< rw::kinematics::Frame f 
)

sets the visibility of a frame and its drawables.

Parameters
f[in] the frame.
visible[in] true if frame should be visible, false otherwise

◆ setWorkCell()

void setWorkCell ( rw::core::Ptr< rw::models::WorkCell wc)

set the workcell to render

Parameters
wc[in] the workcell that is to be rendered

◆ updateSceneGraph()

void updateSceneGraph ( const rw::kinematics::State state)

updates the state of the scenegraph to that of state

Parameters
state

The documentation for this class was generated from the following file: