Class ClassificationWidget
java.lang.Object
gov.nih.mipav.view.renderer.WildMagic.Render.MultiDimensionalTransfer.ClassificationWidget
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
CircleClassificationWidget,SquareClassificationWidget,TriangleClassificationWidget
This is the base class for the Multi-histogram widgets.
The multi-histogram widgets are objects rendered in 2D in the Multi-histogram panel.
The user can manipulate the widgets shape, size, color in the 2D histogram panel.
This class encapsulates the rendering and user-interaction with the widgets.
Based on how the widgets are rendered, they determine how the volume is renderer when
the multi-histogram rendering is enabled. The parameters that define the widget are passed
to the Volume Renderer GLSL program through the ClassificationWidgetState class, that is accessed
through this class.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static intBottom bounding edge of the canvas in world coordinates.protected static intLeft bounding edge of the canvas in world coordinates.protected intCanvas width and heightprotected intCanvas width and heightprotected WildMagic.LibGraphics.SceneGraph.TriMeshThe lower-sphere control point of the widget, controls the shape/size of the widgetprotected WildMagic.LibGraphics.SceneGraph.TriMeshThe middle-sphere control point of the widget, controls the color transfer function inside the widget.protected WildMagic.LibFoundation.Mathematics.Vector2fMouse offset used for dragging the widget.protected WildMagic.LibGraphics.SceneGraph.PolylinePolyline outlines the widget in red when selected, or blue when non selected.protected WildMagic.LibGraphics.SceneGraph.SpatialCurrently picked, or active part of this widget, may be the mesh or one of the control-point spheres.protected WildMagic.LibFoundation.Mathematics.Vector2fMaximum texture coordinates for the 2D histogram.protected WildMagic.LibFoundation.Mathematics.Vector2fMinimum texture coordinates for the 2D histogram.protected WildMagic.LibGraphics.SceneGraph.TriMeshThe upper-sphere control point of the widget, controls the shape/size of the widgetprotected WildMagic.LibGraphics.SceneGraph.NodeThe top-level node containing the widget graphic data structures (triangle meshes and transformations)protected ClassificationWidgetEffectThe shader effect used to render the inside color transfer function of the widget, based on the position of the widget and the position of the middle (green) sphere control-point.protected WildMagic.LibGraphics.SceneGraph.TriMeshThe TriMesh representing the shape of the widget.protected ClassificationWidgetStateShader effect state, for reading from disk:protected static intRight bounding edge of the canvas in world coordinates.private static final longprotected static floatRadius of the sphere control points of the widget in world coordinates.protected static intTop bounding edge of the canvas in world coordinates. -
Constructor Summary
ConstructorsConstructorDescriptionDefault ConstructorClassificationWidget(ClassificationWidget kWidget) Copy Constructor.ClassificationWidget(WildMagic.LibFoundation.Mathematics.Vector2f kTMin, WildMagic.LibFoundation.Mathematics.Vector2f kTMax, int iWidth, int iHeight) Create a new ClassificationWidget. -
Method Summary
Modifier and TypeMethodDescriptionprotected floatcalcObjX(float val) Calculate the world X coordinates from input MouseEvent coordinates.protected floatcalcObjY(float val) Calculate the world Y coordinates from input MouseEvent coordinates.protected floatcalcScreenX(float val) Calculate the screen X coordinates from input world coordinates.protected floatcalcScreenY(float val) Calculate the screen Y coordinates from input world coordinates.protected floatcalcTCoordX(float val) Calculate the X Texture Coordinates from world coordinates.protected floatcalcTCoordY(float val) Calculate the Y Texture Coordinates from world coordinates.voidClears the current picked widget.voiddispose()Dispose local memory.protected WildMagic.LibFoundation.Mathematics.Vector2fCalculate and return the current center of the widget in world coordinates.WildMagic.LibFoundation.Mathematics.ColorRGBAgetColor()Returns the widget current color from the widget shader.intReturns the index of the color look-up table color map.Returns the widget state read from file, so it can initialize a new shader effect.getState()Returns the current state of the widget shader effect.intgetType()Returns the type of widget (Circle, Triangle, Square).WildMagic.LibGraphics.SceneGraph.NodeReturns the Widget scene graph Node.abstract booleanPick(WildMagic.LibGraphics.Rendering.Renderer kRenderer, int iX, int iY) Abstract picking.booleanPick(WildMagic.LibGraphics.Rendering.Renderer kRenderer, int iX, int iY, boolean bPicked) Picking.abstract voidprocessMouseDrag(int iX0ld, int iYOld, int iButton, int iX, int iY) private voidRead this object from disk:voidsetAlpha(float fAlpha) Sets the alpha value of the widget.voidsetBoundary(float fAlpha) Sets the contribution of the 2nd derivative on the volume rendering for this widget.voidsetColor(WildMagic.LibFoundation.Mathematics.ColorRGBA kColor) Sets the color of the color transfer function for this widget.voidsetLUT(WildMagic.LibGraphics.Rendering.Texture kMap, int index, boolean bReverse) Set the color look-up table for the widget.voidsetPicked(boolean bPicked) Clears or sets the current picked object, sets the outline color to red when picked, blue when not selected.voidSets the ClassificationWidgetState of the widget.abstract voidsetTexture(WildMagic.LibGraphics.Rendering.Texture kTexture) Sets the histogram Texture map for the widget shader effect.abstract voidUpdates the ShaderEffect parameters for this widget.private voidStream this object to disk.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
m_kTMin
protected WildMagic.LibFoundation.Mathematics.Vector2f m_kTMinMinimum texture coordinates for the 2D histogram. The 2D Histogram is truncated based on a minimum threshold value, so the entire histogram may not be used depending on the data. -
m_kTMax
protected WildMagic.LibFoundation.Mathematics.Vector2f m_kTMaxMaximum texture coordinates for the 2D histogram. The 2D Histogram is truncated based on a minimum threshold value, so the entire histogram may not be used depending on the data. -
m_iWidth
protected int m_iWidthCanvas width and height -
m_iHeight
protected int m_iHeightCanvas width and height -
m_kPicked
protected WildMagic.LibGraphics.SceneGraph.Spatial m_kPickedCurrently picked, or active part of this widget, may be the mesh or one of the control-point spheres. When null no part of this widget is currently active. -
m_kWidget
protected WildMagic.LibGraphics.SceneGraph.Node m_kWidgetThe top-level node containing the widget graphic data structures (triangle meshes and transformations) -
m_kOutline
protected WildMagic.LibGraphics.SceneGraph.Polyline m_kOutlinePolyline outlines the widget in red when selected, or blue when non selected. -
m_kWidgetMesh
protected WildMagic.LibGraphics.SceneGraph.TriMesh m_kWidgetMeshThe TriMesh representing the shape of the widget. -
m_kWidgetEfect
The shader effect used to render the inside color transfer function of the widget, based on the position of the widget and the position of the middle (green) sphere control-point. -
m_kUpperSphere
protected WildMagic.LibGraphics.SceneGraph.TriMesh m_kUpperSphereThe upper-sphere control point of the widget, controls the shape/size of the widget -
m_kMiddleSphere
protected WildMagic.LibGraphics.SceneGraph.TriMesh m_kMiddleSphereThe middle-sphere control point of the widget, controls the color transfer function inside the widget. -
m_kLowerSphere
protected WildMagic.LibGraphics.SceneGraph.TriMesh m_kLowerSphereThe lower-sphere control point of the widget, controls the shape/size of the widget -
LEFT_EDGE
protected static int LEFT_EDGELeft bounding edge of the canvas in world coordinates. -
RIGHT_EDGE
protected static int RIGHT_EDGERight bounding edge of the canvas in world coordinates. -
BOTTOM_EDGE
protected static int BOTTOM_EDGEBottom bounding edge of the canvas in world coordinates. -
TOP_EDGE
protected static int TOP_EDGETop bounding edge of the canvas in world coordinates. -
SPHERE_RADIUS
protected static float SPHERE_RADIUSRadius of the sphere control points of the widget in world coordinates. -
m_kMouseOffset
protected WildMagic.LibFoundation.Mathematics.Vector2f m_kMouseOffsetMouse offset used for dragging the widget. Stored in screen (MouseEvent) coordinates -
m_kWidgetState
Shader effect state, for reading from disk:
-
-
Constructor Details
-
ClassificationWidget
public ClassificationWidget()Default Constructor -
ClassificationWidget
Copy Constructor. Copies the input ClassificationWidget- Parameters:
kWidget-
-
ClassificationWidget
public ClassificationWidget(WildMagic.LibFoundation.Mathematics.Vector2f kTMin, WildMagic.LibFoundation.Mathematics.Vector2f kTMax, int iWidth, int iHeight) Create a new ClassificationWidget.- Parameters:
kTMin- minimum texture coordinates for the 2D histogram, used for the image background. (Defaults 0-1)kTMax- maximum texture coordinates for the 2D histogram, used for the image background. (Defaults 0-1)iWidth- canvas width (default 256)iHeight- canvas height (default 256)
-
-
Method Details
-
clearPicked
public void clearPicked()Clears the current picked widget. -
dispose
public void dispose()Dispose local memory. -
getColor
public WildMagic.LibFoundation.Mathematics.ColorRGBA getColor()Returns the widget current color from the widget shader.- Returns:
- widget shader effect, constant color from the shader color transfer function.
-
getLUTIndex
public int getLUTIndex()Returns the index of the color look-up table color map.- Returns:
- the index of the color look-up table color map.
-
getSavedWidgetState
Returns the widget state read from file, so it can initialize a new shader effect.- Returns:
-
getState
Returns the current state of the widget shader effect.- Returns:
- the current state of the widget shader effect.
-
getType
public int getType()Returns the type of widget (Circle, Triangle, Square).- Returns:
- the type of widget (Circle, Triangle, Square).
-
getWidget
public WildMagic.LibGraphics.SceneGraph.Node getWidget()Returns the Widget scene graph Node.- Returns:
- the Widget scene graph Node.
-
Pick
public abstract boolean Pick(WildMagic.LibGraphics.Rendering.Renderer kRenderer, int iX, int iY) Abstract picking. Returns true if this widget, or one of it's control points was picked.- Parameters:
iX- current mouse x position (MouseEvent coordinates).iY- current mouse y position (MouseEvent coordinates).- Returns:
- true if this widget or one of it's control points was picked.
-
Pick
public boolean Pick(WildMagic.LibGraphics.Rendering.Renderer kRenderer, int iX, int iY, boolean bPicked) Picking. Returns true if this widget, or one of it's control points was picked.- Parameters:
iX- current mouse x position (MouseEvent coordinates).iY- current mouse y position (MouseEvent coordinates).bPicked- input parameter from the derived classes, when true the derived class widget shape was picked.- Returns:
- true if this widget or one of it's control points was picked.
-
processMouseDrag
public abstract void processMouseDrag(int iX0ld, int iYOld, int iButton, int iX, int iY) - Parameters:
iX0ld- old mouse x-position in MouseEvent coordinates.iYOld- old mouse y-position in MouseEvent coordinates.iButton- old mouse button.e- current MouseEvent
-
setAlpha
public void setAlpha(float fAlpha) Sets the alpha value of the widget.- Parameters:
fAlpha-
-
setBoundary
public void setBoundary(float fAlpha) Sets the contribution of the 2nd derivative on the volume rendering for this widget.- Parameters:
fAlpha- the contribution of the 2nd derivative on the volume rendering for this widget.
-
setColor
public void setColor(WildMagic.LibFoundation.Mathematics.ColorRGBA kColor) Sets the color of the color transfer function for this widget.- Parameters:
kColor- the color of the color transfer function for this widget.
-
setLUT
public void setLUT(WildMagic.LibGraphics.Rendering.Texture kMap, int index, boolean bReverse) Set the color look-up table for the widget.- Parameters:
kMap- Texture map look-up table.index- index of the look-up table.bReverse- inverts the table when true.
-
setPicked
public void setPicked(boolean bPicked) Clears or sets the current picked object, sets the outline color to red when picked, blue when not selected.- Parameters:
bPicked- when true the widget is selected.
-
setState
Sets the ClassificationWidgetState of the widget.- Parameters:
state-
-
setTexture
public abstract void setTexture(WildMagic.LibGraphics.Rendering.Texture kTexture) Sets the histogram Texture map for the widget shader effect.- Parameters:
kTexture-
-
updateDisplay
public abstract void updateDisplay()Updates the ShaderEffect parameters for this widget. -
calcObjX
protected float calcObjX(float val) Calculate the world X coordinates from input MouseEvent coordinates.- Parameters:
val- input MouseEvent Coordinates.- Returns:
- corresponding x-position in world coordinates.
-
calcObjY
protected float calcObjY(float val) Calculate the world Y coordinates from input MouseEvent coordinates.- Parameters:
val- input MouseEvent Coordinates.- Returns:
- corresponding y-position in world coordinates.
-
calcScreenX
protected float calcScreenX(float val) Calculate the screen X coordinates from input world coordinates.- Parameters:
val- input world Coordinates.- Returns:
- corresponding x-position in MouseEvent coordinates.
-
calcScreenY
protected float calcScreenY(float val) Calculate the screen Y coordinates from input world coordinates.- Parameters:
val- input world Coordinates.- Returns:
- corresponding y-position in MouseEvent coordinates.
-
calcTCoordX
protected float calcTCoordX(float val) Calculate the X Texture Coordinates from world coordinates. The texture coordinates are scaled, based on the minimum and maximum texture coordinates of the 2D histogram texture.- Parameters:
val- input world Coordinates.- Returns:
- corresponding x Texture coordinates.
-
calcTCoordY
protected float calcTCoordY(float val) Calculate the Y Texture Coordinates from world coordinates. The texture coordinates are scaled, based on the minimum and maximum texture coordinates of the 2D histogram texture.- Parameters:
val- input world Coordinates.- Returns:
- corresponding y Texture coordinates.
-
getCenter
protected WildMagic.LibFoundation.Mathematics.Vector2f getCenter()Calculate and return the current center of the widget in world coordinates.- Returns:
- the current center of the widget in world coordinates.
-
readObject
Read this object from disk:- Parameters:
in-- Throws:
IOExceptionClassNotFoundException
-
writeObject
Stream this object to disk.- Parameters:
out-- Throws:
IOException
-