Class PlaneRenderProstate

  • All Implemented Interfaces:
    com.jogamp.opengl.GLEventListener, SpaceNavigatorListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.io.Serializable, java.util.EventListener

    public class PlaneRenderProstate
    extends GPURenderBase
    implements com.jogamp.opengl.GLEventListener
    Class PlaneRenderWM: renders a single dimension of the ModelImage data as a texture-mapped polygon. The PlaneRenderWM class keeps track of whether it is rendering the Axial, Sagittal, or Coronal view of the data.
    See Also:
    Serialized Form
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        Use serialVersionUID for interoperability.
        See Also:
        Constant Field Values
      • m_akCLoc

        WildMagic.LibFoundation.Mathematics.Vector3f[] m_akCLoc
        Camera Locations, for rendering the different Axial, Sagittal and Coronal views.
      • m_akCoords

        WildMagic.LibFoundation.Mathematics.Vector3f[] m_akCoords
        Camera Direction, UP, and Right vectors, for rendering the different Axial, Sagittal and Coronal views.
      • m_bPatientOrientation

        protected boolean m_bPatientOrientation
        Actual image orientation.
      • m_iPlaneOrientation

        protected int m_iPlaneOrientation
        Which dimension of the ModelImage to render.
      • m_kWinLevel

        protected WindowLevel m_kWinLevel
        Window-level interface.
      • m_aiLocalImageExtents

        private int[] m_aiLocalImageExtents
        The image dimensions in x,y,z:.
      • m_aiLocalImageFactors

        private int[] m_aiLocalImageFactors
        The image dimension factors in x,y,z:.
      • m_aakColors

        private WildMagic.LibFoundation.Mathematics.ColorRGB[][] m_aakColors
        Set of colors used to draw the axis labels.
      • m_aaiColorSwap

        private int[][] m_aaiColorSwap
        Axis labels color assignments.
      • m_bDrawAxes

        private boolean m_bDrawAxes
        when true, the axis labels (P-> L-> S->) will be drawn
      • m_bDrawXHairs

        private boolean m_bDrawXHairs
        Turns on drawing of the X,Y bars and the Axis labels:.
      • m_bFirstDrag

        private boolean m_bFirstDrag
        Change the mouse cursor with the first mouseDrag event
      • m_bLeftMousePressed

        private boolean m_bLeftMousePressed
        True when the left mouse has been pressed, set to false when the left mouse button is released.
      • m_bRightMousePressed

        private boolean m_bRightMousePressed
        Flag indicating if the right mouse button is currently pressed down:
      • m_kActiveLookupTable

        private ModelStorageBase m_kActiveLookupTable
        The current active lookup table:
      • m_fX0

        private float m_fX0
        lower x-bound of the texture-mapped polygon:
      • m_fX1

        private float m_fX1
        upper x-bound of the texture-mapped polygon:
      • m_fXBox

        private float m_fXBox
        Numbers dictating the size of the plane based on the extents and resolutions of the image.
      • m_fYBox

        private float m_fYBox
        Numbers dictating the size of the plane based on the extents and resolutions of the image.
      • m_fMaxBox

        private float m_fMaxBox
        Numbers dictating the size of the plane based on the extents and resolutions of the image.
      • m_fXRange

        private float m_fXRange
        Width of the texture-mapped polygon:
      • m_fY0

        private float m_fY0
        lower y-bound of the texture-mapped polygon:
      • m_fY1

        private float m_fY1
        upper y-bound of the texture-mapped polygon:
      • m_fYRange

        private float m_fYRange
        Height of the texture-mapped polygon:
      • m_fZoomScale

        private float m_fZoomScale
        Image scaling from Zoom:.
      • m_iSlice

        private int m_iSlice
        Which slice is currently displayed in the XY plane.
      • m_kActiveImage

        private ModelImage m_kActiveImage
        Current active image for manipulating the LUT by dragging with the right-mouse down.
      • m_kLabelX

        private java.lang.String m_kLabelX
        x-axis label:
      • m_kLabelXDisplay

        private java.lang.String m_kLabelXDisplay
      • m_kLabelY

        private java.lang.String m_kLabelY
        y-axis label:
      • m_kXArrow

        private WildMagic.LibGraphics.SceneGraph.TriMesh[] m_kXArrow
        x-axis arrow
      • m_kYArrow

        private WildMagic.LibGraphics.SceneGraph.TriMesh[] m_kYArrow
        y-axis arrow
      • m_spkScreenCamera

        private WildMagic.LibGraphics.Rendering.Camera m_spkScreenCamera
        Drawing the axis arrows in screen-space.
      • m_iLabelX_SpacingX

        private int m_iLabelX_SpacingX
      • m_iLabelX_SpacingY

        private int m_iLabelX_SpacingY
      • m_iLabelY_SpacingX

        private int m_iLabelY_SpacingX
      • m_iLabelY_SpacingY

        private int m_iLabelY_SpacingY
      • m_bUpdateSpacing

        private boolean m_bUpdateSpacing
      • m_aiAxisOrder

        private int[] m_aiAxisOrder
        ModelImage axis orientation.
      • m_abAxisFlip

        private boolean[] m_abAxisFlip
        ModelImage axis flip.
      • m_fMouseX

        private float m_fMouseX
        For zooming with the mouse.
      • m_fMouseY

        private float m_fMouseY
      • m_bShowSurface

        private boolean m_bShowSurface
      • m_bDrawVOI

        private boolean m_bDrawVOI
      • m_bDrawRect

        private boolean m_bDrawRect
      • m_bDrawOval

        private boolean m_bDrawOval
      • m_bDrawPolyline

        private boolean m_bDrawPolyline
      • m_bDrawLevelSet

        private boolean m_bDrawLevelSet
      • m_bUpdateVOI

        private boolean m_bUpdateVOI
      • m_bPointer

        private boolean m_bPointer
      • m_bSelected

        private boolean m_bSelected
      • m_adCos

        private final double[] m_adCos
      • m_adSin

        private final double[] m_adSin
      • m_kBallPoint

        private WildMagic.LibGraphics.SceneGraph.TriMesh m_kBallPoint
      • m_kZState

        private WildMagic.LibGraphics.Rendering.ZBufferState m_kZState
      • m_kVOIAttr

        private WildMagic.LibGraphics.SceneGraph.Attributes m_kVOIAttr
      • m_iCurrentVOIPoint

        private int m_iCurrentVOIPoint
      • m_kPatientPt

        private final WildMagic.LibFoundation.Mathematics.Vector3f m_kPatientPt
      • m_kVolumeScale

        private final WildMagic.LibFoundation.Mathematics.Vector3f m_kVolumeScale
      • m_kVolumeScaleInv

        private final WildMagic.LibFoundation.Mathematics.Vector3f m_kVolumeScaleInv
      • m_bFirstVOI

        private boolean m_bFirstVOI
      • m_iVOICount

        private int m_iVOICount
      • m_kCenter

        private final WildMagic.LibFoundation.Mathematics.Vector3f m_kCenter
      • levelSetStack

        private final PointStack levelSetStack
      • map

        private java.util.BitSet map
      • stack

        private final java.util.Stack<int[]> stack
      • m_aucData

        private byte[] m_aucData
      • m_akSteps

        private final WildMagic.LibFoundation.Mathematics.Vector2f[][] m_akSteps
      • m_aiIndexValues

        private final int[][] m_aiIndexValues
      • m_afAverages

        private final float[][] m_afAverages
    • Constructor Detail

      • PlaneRenderProstate

        public PlaneRenderProstate()
        Default PlaneRender interface.
      • PlaneRenderProstate

        public PlaneRenderProstate​(VolumeTriPlanarInterface kParent,
                                   com.jogamp.opengl.util.Animator kAnimator,
                                   VolumeImage kVolumeImageA,
                                   VolumeImage kVolumeImageB,
                                   int iPlane)
        Parameters:
        kParent -
        kAnimator -
        kVolumeImageA -
        iPlane -
    • Method Detail

      • testDistance

        public static boolean testDistance​(int x,
                                           int x1,
                                           int x2,
                                           int y,
                                           int y1,
                                           int y2,
                                           double tol)
        Tests the distance for closeness; finds the length of the normal from (x,y) to the line (x1,y1) (x2,y2). Returns true if the distance is shorter than tol.
        Parameters:
        x - x coordinate of point to be tested
        x1 - x coordinate of first point in line
        x2 - x coordinate of second point in line
        y - y coordinate of point to be tested
        y1 - y coordinate of first point in line
        y2 - y coordinate of second point in line
        tol - distance to test against
        Returns:
        true if the distance is shorter than tol.
      • addSlices

        public void addSlices​(VolumeSlices kVolumeSlice)
        Adds the VolumeSlices object to the display list for rendering.
        Parameters:
        kVolumeSlice - .
      • close

        public void close()
        Closes the frame.
      • contains

        public boolean contains​(int iX,
                                int iY,
                                WildMagic.LibGraphics.SceneGraph.VertexBuffer kVBuffer)
        Determines if the supplied point can be found within the points that define the contour.
        Returns:
        true if point is within the contour
      • display

        public void display​(com.jogamp.opengl.GLAutoDrawable arg0)
        Specified by:
        display in interface com.jogamp.opengl.GLEventListener
      • displayChanged

        public void displayChanged​(com.jogamp.opengl.GLAutoDrawable arg0,
                                   boolean arg1,
                                   boolean arg2)
      • displaySurface

        public void displaySurface​(boolean bOn)
      • disposeLocal

        public void disposeLocal()
        Clean memory.
      • doVOI

        public void doVOI​(java.lang.String kCommand)
      • GetCanvas

        public com.jogamp.opengl.awt.GLCanvas GetCanvas()
        Description copied from class: GPURenderBase
        Returns the GLCanvas in the m_pkRenderer object.
        Overrides:
        GetCanvas in class GPURenderBase
        Returns:
        OpenGLRenderer.GLCanvas
      • init

        public void init​(com.jogamp.opengl.GLAutoDrawable arg0)
        Specified by:
        init in interface com.jogamp.opengl.GLEventListener
      • keyPressed

        public void keyPressed​(java.awt.event.KeyEvent kKey)
        keyPressed callback.
        Specified by:
        keyPressed in interface java.awt.event.KeyListener
        Overrides:
        keyPressed in class GPURenderBase
        Parameters:
        kKey - the KeyEvent triggering the callback.
      • make3DVOI

        public void make3DVOI​(boolean bIntersection,
                              ModelImage kVolume,
                              int iValue)
      • mouseDragged

        public void mouseDragged​(java.awt.event.MouseEvent kEvent)
        Specified by:
        mouseDragged in interface java.awt.event.MouseMotionListener
        Overrides:
        mouseDragged in class WildMagic.LibApplications.OpenGLApplication.JavaApplication3D
      • mouseMoved

        public void mouseMoved​(java.awt.event.MouseEvent kEvent)
        Specified by:
        mouseMoved in interface java.awt.event.MouseMotionListener
        Overrides:
        mouseMoved in class WildMagic.LibApplications.OpenGLApplication.JavaApplication3D
      • mousePressed

        public void mousePressed​(java.awt.event.MouseEvent kEvent)
        Specified by:
        mousePressed in interface java.awt.event.MouseListener
        Overrides:
        mousePressed in class GPURenderBase
      • mouseReleased

        public void mouseReleased​(java.awt.event.MouseEvent kEvent)
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
        Overrides:
        mouseReleased in class WildMagic.LibApplications.OpenGLApplication.JavaApplication3D
      • mouseWheelMoved

        public void mouseWheelMoved​(java.awt.event.MouseWheelEvent e)
        Specified by:
        mouseWheelMoved in interface java.awt.event.MouseWheelListener
        Overrides:
        mouseWheelMoved in class WildMagic.LibApplications.OpenGLApplication.JavaApplication3D
      • nearLine

        public boolean nearLine​(int iX,
                                int iY,
                                WildMagic.LibGraphics.SceneGraph.VertexBuffer kVBuffer)
        Tests if a point is near the curve.
        Parameters:
        x - x coordinate of point
        y - y coordinate of point
        tol - tolerance indicating the capture range to the line the point.
        Returns:
        returns boolean result of test
      • reshape

        public void reshape​(com.jogamp.opengl.GLAutoDrawable arg0,
                            int iX,
                            int iY,
                            int iWidth,
                            int iHeight)
        Description copied from class: GPURenderBase
        Part of the GLEventListener interface. Called when the GLCanvas is resized.
        Specified by:
        reshape in interface com.jogamp.opengl.GLEventListener
        Overrides:
        reshape in class GPURenderBase
        Parameters:
        arg0 - the GLCanvas
        iX - the new x-position in screen coordinates.
        iY - the new y-position in screen coordinates.
        iWidth - the new width
        iHeight - the new height
      • setBackgroundColor

        public void setBackgroundColor​(WildMagic.LibFoundation.Mathematics.ColorRGBA kColor)
        Sets the background color for the frame and rendered image.
        Parameters:
        color - RGBA color to use as the background color.
      • setCenter

        public void setCenter​(WildMagic.LibFoundation.Mathematics.Vector3f center)
        setCenter sets the cursor and slice position for this PlaneRenderWM object, based on the 3D location of the three intersecting ModelImage planes.
        Parameters:
        center - the 3D center in FileCoordinates of the three intersecting ModelImage planes.
      • SetModified

        public void SetModified​(boolean bModified)
        Causes re-display.
        Parameters:
        bModified -
      • setRadiologicalView

        public void setRadiologicalView​(boolean bOn)
        Sets the view to Radiological (true) or Neurological (false) view.
        Parameters:
        bOn -
      • setSliceHairColor

        public void setSliceHairColor​(int iView,
                                      WildMagic.LibFoundation.Mathematics.ColorRGB kColor)
        Sets the color for the PlaneRender iView (AXIAL, SAGITTAL, CORONAL) slice.
        Parameters:
        iView - (AXIAL, SAGITTAL, CORONAL)
        kColor - the new axis color attribute.
      • showAxes

        public void showAxes​(boolean bShow)
        Turns displaying the Axis labels on or off:
        Parameters:
        bShow - when true display the axis lablels, when false hide the axis labels
      • showXHairs

        public void showXHairs​(boolean bShow)
        Turns displaying the X and Y bars on or off:
        Parameters:
        bShow - when true show the cross-hairs when false hide the cross-hairs
      • fill

        protected void fill​(int[][] aaiCrossingPoints,
                            int[] aiNumCrossings,
                            int iXMin,
                            int iYMin,
                            int iXMax,
                            int iYMax,
                            int iZ,
                            ModelImage kVolume,
                            boolean bIntersection,
                            int iValue)
        fill: fill the sculpt outline drawn by the user. Pixels are determined to be inside or outside the sculpt region based on the parameters, aaiCrossingPoints and aiNumCrossings, using a scan-conversion algorithm that traverses each row and column of the bounding box of the sculpt region coloring inside points as it goes.
        Parameters:
        aaiCrossingPoints - DOCUMENT ME!
        aiNumCrossings - DOCUMENT ME!
      • outlineRegion

        protected void outlineRegion​(int[][] aaiCrossingPoints,
                                     int[] aiNumCrossings,
                                     int iXMin,
                                     int iYMin,
                                     int iXMax,
                                     int iYMax,
                                     WildMagic.LibFoundation.Mathematics.Vector3f[] kVolumePts,
                                     ModelImage kVolume)
        This function computes the set of spans indicated by column crossings for the sculpt outline drawn by the user, by doing a polygon scan conversion in gridded space. The outline must be closed with last point = first point.
        Parameters:
        aaiCrossingPoints - DOCUMENT ME!
        aiNumCrossings - DOCUMENT ME!
      • setOrientation

        protected void setOrientation()
        Based on the orientation of the ModelImage, sets up the index parameters, m_aiLocalImageExtents[0], m_aiLocalImageExtents[1], and m_aiLocalImageExtents[2], the drawing colors for the z box, x and y bars, and the invert flags.

        Once setup everything is rendered into an x,y plane where x,y may be any of the original x,y, or z dimensions in the original ModelImage.

      • sortCrossingPoints

        protected void sortCrossingPoints​(int[] aiList,
                                          int iNumElements)
        Sorts the edge crossing points in place.
        Parameters:
        aiList - list of positions
        iNumElements - number of positions.
      • addVOIPoint

        private void addVOIPoint​(int iX,
                                 int iY)
      • areaTwice

        private float areaTwice​(float ptAx,
                                float ptAy,
                                float ptBx,
                                float ptBy,
                                float ptCx,
                                float ptCy)
        Calculates twice the area (cross product of two vectors) of a triangle given three points. This is a private function only called by the function "contains".
        Parameters:
        ptAx - x-coordinate of the first point of the triangle
        ptAy - y-coordinate of the first point of the triangle
        ptBx - x-coordinate of the second point of the triangle
        ptBy - y-coordinate of the second point of the triangle
        ptCx - x-coordinate of the third point of the triangle
        ptCy - y-coordinate of the third point of the triangle
        Returns:
        twice the area of the triangle if CCw or -2*area if CW
      • copyVOI

        private void copyVOI()
      • CreateLabels

        private void CreateLabels()
        Creates the TriMesh data structures for the axis arrows.
      • createPolyline

        private WildMagic.LibGraphics.SceneGraph.Polyline createPolyline​(WildMagic.LibGraphics.SceneGraph.VertexBuffer kVBuffer,
                                                                         int iZ)
      • CreateScene

        private void CreateScene()
        Initializes the display parameters.
      • createVOI

        private void createVOI​(int iX,
                               int iY)
      • deleteAllVOI

        private void deleteAllVOI()
      • deleteVOI

        private void deleteVOI()
      • drawAxes

        private void drawAxes​(com.jogamp.opengl.GLAutoDrawable arg0)
        Called from the display function. Draws the axis arrows.
      • drawVOI

        private void drawVOI()
      • fillVolume

        private void fillVolume​(int iSlice,
                                WildMagic.LibGraphics.SceneGraph.Polyline kPoly,
                                ModelImage kVolume,
                                boolean bIntersection,
                                int iValue)
      • LocalToPatient

        private void LocalToPatient​(WildMagic.LibFoundation.Mathematics.Vector3f localPt,
                                    WildMagic.LibFoundation.Mathematics.Vector3f patientPt)
      • PatientToLocal

        private void PatientToLocal​(WildMagic.LibFoundation.Mathematics.Vector3f patientPt,
                                    WildMagic.LibFoundation.Mathematics.Vector3f localPt)
      • moveVOI

        private void moveVOI​(int iX,
                             int iY)
      • moveVOIPoint

        private void moveVOIPoint​(int iX,
                                  int iY)
      • nearPoint

        private boolean nearPoint​(int iX,
                                  int iY,
                                  WildMagic.LibGraphics.SceneGraph.VertexBuffer kVBuffer)
      • pasteVOI

        private void pasteVOI​(int iSlice)
      • processLeftMouseDrag

        private void processLeftMouseDrag​(java.awt.event.MouseEvent kEvent)
        Dragging the mouse with the left-mouse button held down changes the positions of the X and Y cross bars, and therefore the ZSlice positions of the associated PlaneRenderWM objects and the TriPlanar Surface. The new positions are calculated and passed onto the parent frame.
        Parameters:
        kEvent - the mouse event generated by a mouse drag
      • processRightMouseDrag

        private void processRightMouseDrag​(java.awt.event.MouseEvent kEvent)
        If the right mouse button is pressed and dragged. processRightMouseDrag updates the HistoLUT window and level (contrast and brightness)
        Parameters:
        kEvent - the mouse event generated by a mouse drag
      • saveVOI

        private void saveVOI​(int iX,
                             int iY,
                             int iSlice)
      • ScreenToLocal

        private void ScreenToLocal​(int iX,
                                   int iY,
                                   int iZ,
                                   WildMagic.LibFoundation.Mathematics.Vector3f kLocal)
        Calculate the position of the mouse in the Local Coordinates, taking into account zoom and translate:
        Parameters:
        iX - mouse x coordinate value
        iY - mouse y coordinate value
        kLocal - mouse position in Local Coordinates
      • LocalToScreen

        private void LocalToScreen​(WildMagic.LibFoundation.Mathematics.Vector3f kLocal,
                                   WildMagic.LibFoundation.Mathematics.Vector3f kScreen)
      • selectVOI

        private void selectVOI​(int iX,
                               int iY)
      • setSlice

        private void setSlice​(float fSlice)
        Sets the local slice value.
        Parameters:
        fSlice -
      • showSelectedVOI

        private void showSelectedVOI​(int iX,
                                     int iY)
      • VOIToFileCoordinates

        private WildMagic.LibFoundation.Mathematics.Vector3f VOIToFileCoordinates​(WildMagic.LibFoundation.Mathematics.Vector3f kVOIPt,
                                                                                  boolean bScale)
      • FileCoordinatesToVOI

        private WildMagic.LibFoundation.Mathematics.Vector3f FileCoordinatesToVOI​(WildMagic.LibFoundation.Mathematics.Vector3f volumePt,
                                                                                  boolean bScale)
      • zoom

        private void zoom()
      • avgPix

        private float avgPix​(int iX,
                             int iY)
        This method calculates the average pixel value based on the four neighbors (N, S, E, W).
        Parameters:
        index - the center pixel where the average pixel value is to be calculated.
        Returns:
        the average pixel value as a float.
      • paths

        private void paths​(int iX,
                           int iY,
                           int iZ,
                           int i,
                           float level)
        Generates the possible paths of the level set and pushes them onto a stack. Looks in the 8 neighborhood directions for the possible paths.
      • singleLevelSet

        private PlaneRenderProstate.LocalVolumeVOI singleLevelSet​(float startPtX,
                                                                  float startPtY)
        Creates a single level set. Takes a starting point and finds a closed path along the levelset back to the starting point.
        Parameters:
        startPtX - the start point
        startPtY - the start point
        level - the level of the level set
      • initDataBuffer

        private void initDataBuffer()
      • setIndices

        private void setIndices​(int iX,
                                int iY,
                                int iZ)