Class ClassificationWidget
- java.lang.Object
-
- gov.nih.mipav.view.renderer.WildMagic.Render.MultiDimensionalTransfer.ClassificationWidget
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
CircleClassificationWidget,SquareClassificationWidget,TriangleClassificationWidget
public abstract class ClassificationWidget extends java.lang.Object implements java.io.SerializableThis 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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static intBOTTOM_EDGEBottom bounding edge of the canvas in world coordinates.protected static intLEFT_EDGELeft bounding edge of the canvas in world coordinates.protected intm_iHeightCanvas width and heightprotected intm_iWidthCanvas width and heightprotected WildMagic.LibGraphics.SceneGraph.TriMeshm_kLowerSphereThe lower-sphere control point of the widget, controls the shape/size of the widgetprotected WildMagic.LibGraphics.SceneGraph.TriMeshm_kMiddleSphereThe middle-sphere control point of the widget, controls the color transfer function inside the widget.protected WildMagic.LibFoundation.Mathematics.Vector2fm_kMouseOffsetMouse offset used for dragging the widget.protected WildMagic.LibGraphics.SceneGraph.Polylinem_kOutlinePolyline outlines the widget in red when selected, or blue when non selected.protected WildMagic.LibGraphics.SceneGraph.Spatialm_kPickedCurrently picked, or active part of this widget, may be the mesh or one of the control-point spheres.protected WildMagic.LibFoundation.Mathematics.Vector2fm_kTMaxMaximum texture coordinates for the 2D histogram.protected WildMagic.LibFoundation.Mathematics.Vector2fm_kTMinMinimum texture coordinates for the 2D histogram.protected WildMagic.LibGraphics.SceneGraph.TriMeshm_kUpperSphereThe upper-sphere control point of the widget, controls the shape/size of the widgetprotected WildMagic.LibGraphics.SceneGraph.Nodem_kWidgetThe top-level node containing the widget graphic data structures (triangle meshes and transformations)protected ClassificationWidgetEffectm_kWidgetEfectThe 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.TriMeshm_kWidgetMeshThe TriMesh representing the shape of the widget.protected ClassificationWidgetStatem_kWidgetStateShader effect state, for reading from disk:protected static intRIGHT_EDGERight bounding edge of the canvas in world coordinates.private static longserialVersionUIDprotected static floatSPHERE_RADIUSRadius of the sphere control points of the widget in world coordinates.protected static intTOP_EDGETop bounding edge of the canvas in world coordinates.
-
Constructor Summary
Constructors Constructor Description ClassificationWidget()Default 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
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected 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.voidclearPicked()Clears the current picked widget.voiddispose()Dispose local memory.protected WildMagic.LibFoundation.Mathematics.Vector2fgetCenter()Calculate and return the current center of the widget in world coordinates.WildMagic.LibFoundation.Mathematics.ColorRGBAgetColor()Returns the widget current color from the widget shader.intgetLUTIndex()Returns the index of the color look-up table color map.ClassificationWidgetStategetSavedWidgetState()Returns the widget state read from file, so it can initialize a new shader effect.ClassificationWidgetStategetState()Returns the current state of the widget shader effect.intgetType()Returns the type of widget (Circle, Triangle, Square).WildMagic.LibGraphics.SceneGraph.NodegetWidget()Returns 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 voidreadObject(java.io.ObjectInputStream in)Read 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.voidsetState(ClassificationWidgetState state)Sets the ClassificationWidgetState of the widget.abstract voidsetTexture(WildMagic.LibGraphics.Rendering.Texture kTexture)Sets the histogram Texture map for the widget shader effect.abstract voidupdateDisplay()Updates the ShaderEffect parameters for this widget.private voidwriteObject(java.io.ObjectOutputStream out)Stream this object to disk.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
m_kTMin
protected WildMagic.LibFoundation.Mathematics.Vector2f m_kTMin
Minimum 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_kTMax
Maximum 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_iWidth
Canvas width and height
-
m_iHeight
protected int m_iHeight
Canvas width and height
-
m_kPicked
protected WildMagic.LibGraphics.SceneGraph.Spatial m_kPicked
Currently 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_kWidget
The top-level node containing the widget graphic data structures (triangle meshes and transformations)
-
m_kOutline
protected WildMagic.LibGraphics.SceneGraph.Polyline m_kOutline
Polyline outlines the widget in red when selected, or blue when non selected.
-
m_kWidgetMesh
protected WildMagic.LibGraphics.SceneGraph.TriMesh m_kWidgetMesh
The TriMesh representing the shape of the widget.
-
m_kWidgetEfect
protected ClassificationWidgetEffect 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_kUpperSphere
The upper-sphere control point of the widget, controls the shape/size of the widget
-
m_kMiddleSphere
protected WildMagic.LibGraphics.SceneGraph.TriMesh m_kMiddleSphere
The middle-sphere control point of the widget, controls the color transfer function inside the widget.
-
m_kLowerSphere
protected WildMagic.LibGraphics.SceneGraph.TriMesh m_kLowerSphere
The lower-sphere control point of the widget, controls the shape/size of the widget
-
LEFT_EDGE
protected static int LEFT_EDGE
Left bounding edge of the canvas in world coordinates.
-
RIGHT_EDGE
protected static int RIGHT_EDGE
Right bounding edge of the canvas in world coordinates.
-
BOTTOM_EDGE
protected static int BOTTOM_EDGE
Bottom bounding edge of the canvas in world coordinates.
-
TOP_EDGE
protected static int TOP_EDGE
Top bounding edge of the canvas in world coordinates.
-
SPHERE_RADIUS
protected static float SPHERE_RADIUS
Radius of the sphere control points of the widget in world coordinates.
-
m_kMouseOffset
protected WildMagic.LibFoundation.Mathematics.Vector2f m_kMouseOffset
Mouse offset used for dragging the widget. Stored in screen (MouseEvent) coordinates
-
m_kWidgetState
protected ClassificationWidgetState m_kWidgetState
Shader effect state, for reading from disk:
-
-
Constructor Detail
-
ClassificationWidget
public ClassificationWidget()
Default Constructor
-
ClassificationWidget
public ClassificationWidget(ClassificationWidget kWidget)
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 Detail
-
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
public ClassificationWidgetState getSavedWidgetState()
Returns the widget state read from file, so it can initialize a new shader effect.- Returns:
-
getState
public ClassificationWidgetState 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
public void setState(ClassificationWidgetState state)
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
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundExceptionRead this object from disk:- Parameters:
in-- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
writeObject
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOExceptionStream this object to disk.- Parameters:
out-- Throws:
java.io.IOException
-
-