Package org.robwork.sdurw_graphics
Class WorkCellScene
- java.lang.Object
-
- org.robwork.sdurw_graphics.WorkCellScene
-
public class WorkCellScene extends java.lang.Objectclass 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 Summary
Constructors Constructor Description WorkCellScene(long cPtr, boolean cMemoryOwn)WorkCellScene(SceneGraphPtr scene)constructor - creates a workcell with a current SceneGraph
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DrawableNodePtraddDrawable(java.lang.String filename, FramePtr frame)create and add a drawable node from a filename to the sceneDrawableNodePtraddDrawable(java.lang.String filename, FramePtr frame, int dmask)create and add a drawable node from a filename to the scenevoidaddDrawable(DrawableNodePtr drawable, FramePtr frame)add a drawable node to the sceneDrawableNodePtraddFrameAxis(java.lang.String name, double size, FramePtr frame)create and add a drawable node of a frame axis to the sceneDrawableNodePtraddFrameAxis(java.lang.String name, double size, FramePtr frame, int dmask)create and add a drawable node of a frame axis to the sceneDrawableGeometryNodePtraddGeometry(java.lang.String name, GeometryPtr geom, FramePtr frame)create and add a drawable geometry node of any type of geometry to the sceneDrawableGeometryNodePtraddGeometry(java.lang.String name, GeometryPtr geom, FramePtr frame, int dmask)create and add a drawable geometry node of any type of geometry to the sceneDrawableNodePtraddImage(java.lang.String name, Image img, FramePtr frame)create and add a drawable node of an image to the sceneDrawableNodePtraddImage(java.lang.String name, Image img, FramePtr frame, int dmask)create and add a drawable node of an image to the sceneDrawableGeometryNodePtraddLines(java.lang.String name, VectorLine lines, FramePtr frame)create and add a drawable geometry node of line geometry to the sceneDrawableGeometryNodePtraddLines(java.lang.String name, VectorLine lines, FramePtr frame, int dmask)create and add a drawable geometry node of line geometry to the sceneDrawableNodePtraddModel3D(java.lang.String name, Model3DPtr model, FramePtr frame)create and add a drawable node of a model3d to the sceneDrawableNodePtraddModel3D(java.lang.String name, Model3DPtr model, FramePtr frame, int dmask)create and add a drawable node of a model3d to the sceneDrawableNodePtraddRender(java.lang.String name, RenderPtr render, FramePtr frame)create and add a drawable node of a render, to the sceneDrawableNodePtraddRender(java.lang.String name, RenderPtr render, FramePtr frame, int dmask)create and add a drawable node of a render, to the sceneDrawableNodePtraddScan(java.lang.String name, PointCloud scan, FramePtr frame)create and add a drawable node of a scan to the sceneDrawableNodePtraddScan(java.lang.String name, PointCloud scan, FramePtr frame, int dmask)create and add a drawable node of a scan to the sceneDrawableNodePtraddText(java.lang.String name, java.lang.String text, FramePtr frame)create and add a drawable node of a textlabelDrawableNodePtraddText(java.lang.String name, java.lang.String text, FramePtr frame, int dmask)create and add a drawable node of a textlabelvoidclearCache()any cached drawables or scene nodes are deletedvoiddelete()voiddraw(SceneGraph.SceneGraphRenderInfo info)renders the complete scene using the settings in info.
This basically forwards the call to SceneGraph::draw
DrawableNodePtrfindDrawable(java.lang.String name)find a drawable by name name.DrawableNodePtrfindDrawable(java.lang.String name, FramePtr frame)find a drawable by name name that is attached to frame frameSWIGTYPE_p_std__vectorT_rw__core__PtrT_rw__graphics__DrawableNode_t_tfindDrawables(java.lang.String name)find all drawables by name name.static longgetCPtr(WorkCellScene obj)SWIGTYPE_p_std__vectorT_rw__core__PtrT_rw__graphics__DrawableNode_t_tgetDrawables()get all drawables of the WorkCellSceneSWIGTYPE_p_std__vectorT_rw__core__PtrT_rw__graphics__DrawableNode_t_tgetDrawables(FramePtr f)get all drawables of a specific frame in the WorkCellSceneSWIGTYPE_p_std__vectorT_rw__core__PtrT_rw__graphics__DrawableNode_t_tgetDrawablesRec(FramePtr f, State state)get all drawables of a frame and all frames that kinematicly is connected to
the sub-tree of f.longgetDrawMask(FramePtr f)get the draw mask of the drawables of a specific frameDrawableNode.DrawTypegetDrawType(FramePtr f)get how drawables of a specific frame is to be renderedFramegetFrame(DrawableNodePtr d)get the frame that a specific drawable d is associated toGroupNodePtrgetNode(FramePtr frame)Get the GroupNode corresponding to the given frame.WorkCellPtrgetWorkCell()get the workcell that is currently being rendered.GroupNodePtrgetWorldNode()gets the node of the scene graph that maps to the world frame
of the workcell.booleanisFrameAxisVisible(FramePtr f)test if frame-axis is visiblebooleanisFrameLabelVisible(FramePtr f)test if frame-label is visiblebooleanisHighlighted(FramePtr f)test if a frame is highlighted or notbooleanisVisible(FramePtr f)test if a frame is visible or notbooleanremoveDrawable(java.lang.String name)remove first drawable by name namebooleanremoveDrawable(java.lang.String name, FramePtr f)remove drawable by name
and which is attached to frame fbooleanremoveDrawable(DrawableNodePtr drawable)remove a drawable from the scenebooleanremoveDrawable(DrawableNodePtr drawable, FramePtr f)remove a drawable from a specific framebooleanremoveDrawables(java.lang.String name)remove all drawables with name
namebooleanremoveDrawables(FramePtr f)remove all drawables on a framevoidsetDrawMask(long mask, FramePtr f)set the draw mask of the drawables of a specific framevoidsetDrawType(DrawableNode.DrawType type, FramePtr f)set how drawables of a specific frame should be renderedvoidsetFrameAxisVisible(boolean visible, FramePtr f)enables the drawing of the frame-axis of a frame.voidsetFrameAxisVisible(boolean visible, FramePtr f, double size)enables the drawing of the frame-axis of a frame.voidsetFrameLabelVisible(boolean visible, FramePtr f)enables the drawing of the frame label of a frame.voidsetHighlighted(boolean highlighted, FramePtr f)sets a frame to be highlighted or not.voidsetState(State state)state changes are updated by calling this method.voidsetTransparency(double alpha, FramePtr f)set drawables of a frame to be translusentvoidsetVisible(boolean visible, FramePtr f)sets the visibility of a frame and its drawables.voidsetWorkCell(WorkCellPtr wc)set the workcell to rendervoidupdateSceneGraph(State state)updates the state of the scenegraph to that of state
-
-
-
Constructor Detail
-
WorkCellScene
public WorkCellScene(long cPtr, boolean cMemoryOwn)
-
WorkCellScene
public WorkCellScene(SceneGraphPtr scene)
constructor - creates a workcell with a current SceneGraph- Parameters:
scene- [in] scene graph to use.
-
-
Method Detail
-
getCPtr
public static long getCPtr(WorkCellScene obj)
-
delete
public void delete()
-
draw
public void draw(SceneGraph.SceneGraphRenderInfo info)
renders the complete scene using the settings in info.
This basically forwards the call to SceneGraph::draw
- Parameters:
info- [in] render settings
-
setWorkCell
public void setWorkCell(WorkCellPtr wc)
set the workcell to render- Parameters:
wc- [in] the workcell that is to be rendered
-
getWorkCell
public WorkCellPtr getWorkCell()
get the workcell that is currently being rendered.
-
setState
public void setState(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
-
getWorldNode
public GroupNodePtr getWorldNode()
gets the node of the scene graph that maps to the world frame
of the workcell.- Returns:
- scene node
-
updateSceneGraph
public void updateSceneGraph(State state)
updates the state of the scenegraph to that of state- Parameters:
state-
-
clearCache
public void clearCache()
any cached drawables or scene nodes are deleted
-
setVisible
public void setVisible(boolean visible, FramePtr 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
-
isVisible
public boolean isVisible(FramePtr f)
test if a frame is visible or not- Parameters:
f- [in] the frame- Returns:
- true if frame is visible, false if not
-
setHighlighted
public void setHighlighted(boolean highlighted, FramePtr f)sets a frame to be highlighted or not.- Parameters:
f- [in] the frame.highlighted- [in] true if frame should be highlighted, false otherwise
-
isHighlighted
public boolean isHighlighted(FramePtr f)
test if a frame is highlighted or not- Parameters:
f- [in] the frame- Returns:
- true if frame is highlighted, false if not
-
setFrameAxisVisible
public void setFrameAxisVisible(boolean visible, FramePtr f, double size)enables the drawing of the frame-axis of a frame.- Parameters:
visible- [in] true if frame axis should be drawn, false otherwisef- [in] the framesize- [in] size of the frame-axis (default = 0.25)
-
setFrameAxisVisible
public void setFrameAxisVisible(boolean visible, FramePtr f)enables the drawing of the frame-axis of a frame.- Parameters:
visible- [in] true if frame axis should be drawn, false otherwisef- [in] the frame
-
isFrameAxisVisible
public boolean isFrameAxisVisible(FramePtr f)
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
-
setFrameLabelVisible
public void setFrameLabelVisible(boolean visible, FramePtr f)enables the drawing of the frame label of a frame.- Parameters:
visible- [in] true if frame label should be drawn, false otherwisef- [in] the frame
-
isFrameLabelVisible
public boolean isFrameLabelVisible(FramePtr f)
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
-
setDrawType
public void setDrawType(DrawableNode.DrawType type, FramePtr f)
set how drawables of a specific frame should be rendered- Parameters:
type- [in] the drawtypef- [in] the Frame
-
getDrawType
public DrawableNode.DrawType getDrawType(FramePtr f)
get how drawables of a specific frame is to be rendered- Parameters:
f- [in] the Frame- Returns:
- the drawtype
-
setDrawMask
public void setDrawMask(long mask, FramePtr f)set the draw mask of the drawables of a specific frame- Parameters:
mask- [in] draw maskf- [in] the frame
-
getDrawMask
public long getDrawMask(FramePtr f)
get the draw mask of the drawables of a specific frame- Parameters:
f- [in] the frame- Returns:
- the drawmask
-
setTransparency
public void setTransparency(double alpha, FramePtr f)set drawables of a frame to be translusent- Parameters:
alpha- [in] range [0-1] where 1 is fully opaque and 0 is folly transparentf- [in] frame
-
addLines
public DrawableGeometryNodePtr addLines(java.lang.String name, VectorLine lines, FramePtr frame, int dmask)
create and add a drawable geometry node of line geometry to the scene- Parameters:
name- [in] name of drawable nodelines- [in] the line geometryframe- [in] the frame where the drawable is to be placeddmask- [in] the drawable mask- Returns:
- the drawable node geometry
-
addLines
public DrawableGeometryNodePtr addLines(java.lang.String name, VectorLine lines, FramePtr frame)
create and add a drawable geometry node of line geometry to the scene- Parameters:
name- [in] name of drawable nodelines- [in] the line geometryframe- [in] the frame where the drawable is to be placed
- Returns:
- the drawable node geometry
-
addGeometry
public DrawableGeometryNodePtr addGeometry(java.lang.String name, GeometryPtr geom, FramePtr frame, int dmask)
create and add a drawable geometry node of any type of geometry to the scene- Parameters:
name- [in] name of drawable nodegeom- [in] the geometryframe- [in] the frame where the drawable is to be placeddmask- [in] the drawable mask- Returns:
- the drawable node geometry
-
addGeometry
public DrawableGeometryNodePtr addGeometry(java.lang.String name, GeometryPtr geom, FramePtr frame)
create and add a drawable geometry node of any type of geometry to the scene- Parameters:
name- [in] name of drawable nodegeom- [in] the geometryframe- [in] the frame where the drawable is to be placed
- Returns:
- the drawable node geometry
-
addFrameAxis
public DrawableNodePtr addFrameAxis(java.lang.String name, double size, FramePtr frame, int dmask)
create and add a drawable node of a frame axis to the scene- Parameters:
name- [in] name of drawable nodesize- [in] the length of the axis arrows in metersframe- [in] the frame where the drawable is to be placeddmask- [in] the drawable mask- Returns:
- the drawable node geometry
-
addFrameAxis
public DrawableNodePtr addFrameAxis(java.lang.String name, double size, FramePtr frame)
create and add a drawable node of a frame axis to the scene- Parameters:
name- [in] name of drawable nodesize- [in] the length of the axis arrows in metersframe- [in] the frame where the drawable is to be placed
- Returns:
- the drawable node geometry
-
addModel3D
public DrawableNodePtr addModel3D(java.lang.String name, Model3DPtr model, FramePtr frame, int dmask)
create and add a drawable node of a model3d to the scene- Parameters:
name- [in] name of drawable nodemodel- [in] the model3dframe- [in] the frame where the drawable is to be placeddmask- [in] the drawable mask- Returns:
- the drawable node geometry
-
addModel3D
public DrawableNodePtr addModel3D(java.lang.String name, Model3DPtr model, FramePtr frame)
create and add a drawable node of a model3d to the scene- Parameters:
name- [in] name of drawable nodemodel- [in] the model3dframe- [in] the frame where the drawable is to be placed
- Returns:
- the drawable node geometry
-
addImage
public DrawableNodePtr addImage(java.lang.String name, Image img, FramePtr frame, int dmask)
create and add a drawable node of an image to the scene- Parameters:
name- [in] name of drawable nodeimg- [in] the imageframe- [in] the frame where the drawable is to be placeddmask- [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.
-
addImage
public DrawableNodePtr addImage(java.lang.String name, Image img, FramePtr frame)
create and add a drawable node of an image to the scene- Parameters:
name- [in] name of drawable nodeimg- [in] the imageframe- [in] the frame where the drawable is to be placed
- Returns:
- the drawable node geometry
Note: the size of the image in the scene will be pixel/cm. To change this please use
scale.
-
addScan
public DrawableNodePtr addScan(java.lang.String name, PointCloud scan, FramePtr frame, int dmask)
create and add a drawable node of a scan to the scene- Parameters:
name- [in] name of drawable nodescan- [in] the scanframe- [in] the frame where the drawable is to be placeddmask- [in] the drawable mask- Returns:
- the drawable node
-
addScan
public DrawableNodePtr addScan(java.lang.String name, PointCloud scan, FramePtr frame)
create and add a drawable node of a scan to the scene- Parameters:
name- [in] name of drawable nodescan- [in] the scanframe- [in] the frame where the drawable is to be placed
- Returns:
- the drawable node
-
addText
public DrawableNodePtr addText(java.lang.String name, java.lang.String text, FramePtr frame, int dmask)
create and add a drawable node of a textlabel- Parameters:
name- [in] name of drawable nodetext- [in] the label textframe- [in] the frame where the drawable is to be placeddmask- [in] the drawable mask- Returns:
- the drawable node
-
addText
public DrawableNodePtr addText(java.lang.String name, java.lang.String text, FramePtr frame)
create and add a drawable node of a textlabel- Parameters:
name- [in] name of drawable nodetext- [in] the label textframe- [in] the frame where the drawable is to be placed
- Returns:
- the drawable node
-
addRender
public DrawableNodePtr addRender(java.lang.String name, RenderPtr render, FramePtr frame, int dmask)
create and add a drawable node of a render, to the scene- Parameters:
name- [in] name of drawable noderender- [in] the renderframe- [in] the frame where the drawable is to be placeddmask- [in] the drawable mask- Returns:
- the drawable node
-
addRender
public DrawableNodePtr addRender(java.lang.String name, RenderPtr render, FramePtr frame)
create and add a drawable node of a render, to the scene- Parameters:
name- [in] name of drawable noderender- [in] the renderframe- [in] the frame where the drawable is to be placed
- Returns:
- the drawable node
-
addDrawable
public DrawableNodePtr addDrawable(java.lang.String filename, FramePtr frame, int dmask)
create and add a drawable node from a filename to the scene- Parameters:
filename- [in] name of drawable nodeframe- [in] the frame where the drawable is to be placeddmask- [in] the drawable mask- Returns:
- the drawable node
-
addDrawable
public DrawableNodePtr addDrawable(java.lang.String filename, FramePtr frame)
create and add a drawable node from a filename to the scene- Parameters:
filename- [in] name of drawable nodeframe- [in] the frame where the drawable is to be placed
- Returns:
- the drawable node
-
addDrawable
public void addDrawable(DrawableNodePtr drawable, FramePtr frame)
add a drawable node to the scene- Parameters:
drawable- [in] the drawableframe- [in] the frame where the drawable is to be placed
-
getDrawables
public SWIGTYPE_p_std__vectorT_rw__core__PtrT_rw__graphics__DrawableNode_t_t getDrawables()
get all drawables of the WorkCellScene- Returns:
- a list of drawables
-
getDrawables
public SWIGTYPE_p_std__vectorT_rw__core__PtrT_rw__graphics__DrawableNode_t_t getDrawables(FramePtr f)
get all drawables of a specific frame in the WorkCellScene- Parameters:
f- [in] the frame- Returns:
- a list of drawables
-
getDrawablesRec
public SWIGTYPE_p_std__vectorT_rw__core__PtrT_rw__graphics__DrawableNode_t_t getDrawablesRec(FramePtr f, 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 framestate- [in] the current state- Returns:
- a list of drawables
-
findDrawable
public DrawableNodePtr findDrawable(java.lang.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
public DrawableNodePtr findDrawable(java.lang.String name, FramePtr frame)
find a drawable by name name that is attached to frame frame- Parameters:
name- [in] the name of the drawableframe- [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
public SWIGTYPE_p_std__vectorT_rw__core__PtrT_rw__graphics__DrawableNode_t_t findDrawables(java.lang.String name)
find all drawables by name name.- Parameters:
name- [in] the name of the drawable- Returns:
- all drawables with name name
-
removeDrawables
public boolean removeDrawables(FramePtr f)
remove all drawables on a frame- Parameters:
f- [in] the frame- Returns:
- true if successfull
-
removeDrawables
public boolean removeDrawables(java.lang.String name)
remove all drawables with name
name- Parameters:
name- [in] the name- Returns:
- true if successfull
-
removeDrawable
public boolean removeDrawable(DrawableNodePtr drawable)
remove a drawable from the scene- Parameters:
drawable- [in] the drawable- Returns:
- true if successfull
-
removeDrawable
public boolean removeDrawable(DrawableNodePtr drawable, FramePtr f)
remove a drawable from a specific frame- Parameters:
drawable- [in] the drawablef- [in] the frame- Returns:
- true if successfull
-
removeDrawable
public boolean removeDrawable(java.lang.String name)
remove first drawable by name name- Parameters:
name- [in] the name- Returns:
- true if successfull
-
removeDrawable
public boolean removeDrawable(java.lang.String name, FramePtr f)remove drawable by name
and which is attached to frame f- Parameters:
name- [in] name of drawablef- [in] the frame- Returns:
- true if successfull
-
getFrame
public Frame getFrame(DrawableNodePtr d)
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
public GroupNodePtr getNode(FramePtr frame)
Get the GroupNode corresponding to the given frame.- Parameters:
frame- [in] the frame.- Returns:
- group node.
-
-