Class ClassificationWidget

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    CircleClassificationWidget, SquareClassificationWidget, TriangleClassificationWidget

    public abstract class ClassificationWidget
    extends java.lang.Object
    implements java.io.Serializable
    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:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static int BOTTOM_EDGE
      Bottom bounding edge of the canvas in world coordinates.
      protected static int LEFT_EDGE
      Left bounding edge of the canvas in world coordinates.
      protected int m_iHeight
      Canvas width and height
      protected int m_iWidth
      Canvas width and height
      protected WildMagic.LibGraphics.SceneGraph.TriMesh m_kLowerSphere
      The lower-sphere control point of the widget, controls the shape/size of the widget
      protected WildMagic.LibGraphics.SceneGraph.TriMesh m_kMiddleSphere
      The middle-sphere control point of the widget, controls the color transfer function inside the widget.
      protected WildMagic.LibFoundation.Mathematics.Vector2f m_kMouseOffset
      Mouse offset used for dragging the widget.
      protected WildMagic.LibGraphics.SceneGraph.Polyline m_kOutline
      Polyline outlines the widget in red when selected, or blue when non selected.
      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.
      protected WildMagic.LibFoundation.Mathematics.Vector2f m_kTMax
      Maximum texture coordinates for the 2D histogram.
      protected WildMagic.LibFoundation.Mathematics.Vector2f m_kTMin
      Minimum texture coordinates for the 2D histogram.
      protected WildMagic.LibGraphics.SceneGraph.TriMesh m_kUpperSphere
      The upper-sphere control point of the widget, controls the shape/size of the widget
      protected WildMagic.LibGraphics.SceneGraph.Node m_kWidget
      The top-level node containing the widget graphic data structures (triangle meshes and transformations)
      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.
      protected WildMagic.LibGraphics.SceneGraph.TriMesh m_kWidgetMesh
      The TriMesh representing the shape of the widget.
      protected ClassificationWidgetState m_kWidgetState
      Shader effect state, for reading from disk:
      protected static int RIGHT_EDGE
      Right bounding edge of the canvas in world coordinates.
      private static long serialVersionUID  
      protected static float SPHERE_RADIUS
      Radius of the sphere control points of the widget in world coordinates.
      protected static int TOP_EDGE
      Top bounding edge of the canvas in world coordinates.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected float calcObjX​(float val)
      Calculate the world X coordinates from input MouseEvent coordinates.
      protected float calcObjY​(float val)
      Calculate the world Y coordinates from input MouseEvent coordinates.
      protected float calcScreenX​(float val)
      Calculate the screen X coordinates from input world coordinates.
      protected float calcScreenY​(float val)
      Calculate the screen Y coordinates from input world coordinates.
      protected float calcTCoordX​(float val)
      Calculate the X Texture Coordinates from world coordinates.
      protected float calcTCoordY​(float val)
      Calculate the Y Texture Coordinates from world coordinates.
      void clearPicked()
      Clears the current picked widget.
      void dispose()
      Dispose local memory.
      protected WildMagic.LibFoundation.Mathematics.Vector2f getCenter()
      Calculate and return the current center of the widget in world coordinates.
      WildMagic.LibFoundation.Mathematics.ColorRGBA getColor()
      Returns the widget current color from the widget shader.
      int getLUTIndex()
      Returns the index of the color look-up table color map.
      ClassificationWidgetState getSavedWidgetState()
      Returns the widget state read from file, so it can initialize a new shader effect.
      ClassificationWidgetState getState()
      Returns the current state of the widget shader effect.
      int getType()
      Returns the type of widget (Circle, Triangle, Square).
      WildMagic.LibGraphics.SceneGraph.Node getWidget()
      Returns the Widget scene graph Node.
      abstract boolean Pick​(WildMagic.LibGraphics.Rendering.Renderer kRenderer, int iX, int iY)
      Abstract picking.
      boolean Pick​(WildMagic.LibGraphics.Rendering.Renderer kRenderer, int iX, int iY, boolean bPicked)
      Picking.
      abstract void processMouseDrag​(int iX0ld, int iYOld, int iButton, java.awt.event.MouseEvent e)  
      private void readObject​(java.io.ObjectInputStream in)
      Read this object from disk:
      void setAlpha​(float fAlpha)
      Sets the alpha value of the widget.
      void setBoundary​(float fAlpha)
      Sets the contribution of the 2nd derivative on the volume rendering for this widget.
      void setColor​(WildMagic.LibFoundation.Mathematics.ColorRGBA kColor)
      Sets the color of the color transfer function for this widget.
      void setLUT​(WildMagic.LibGraphics.Rendering.Texture kMap, int index, boolean bReverse)
      Set the color look-up table for the widget.
      void setPicked​(boolean bPicked)
      Clears or sets the current picked object, sets the outline color to red when picked, blue when not selected.
      void setState​(ClassificationWidgetState state)
      Sets the ClassificationWidgetState of the widget.
      abstract void setTexture​(WildMagic.LibGraphics.Rendering.Texture kTexture)
      Sets the histogram Texture map for the widget shader effect.
      abstract void updateDisplay()
      Updates the ShaderEffect parameters for this widget.
      private void writeObject​(java.io.ObjectOutputStream out)
      Stream this object to disk.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • 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
    • 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,
                                              java.awt.event.MouseEvent e)
        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.ClassNotFoundException
        Read this object from disk:
        Parameters:
        in -
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • writeObject

        private void writeObject​(java.io.ObjectOutputStream out)
                          throws java.io.IOException
        Stream this object to disk.
        Parameters:
        out -
        Throws:
        java.io.IOException