Class PlaneRender

java.lang.Object
java.awt.Component
java.awt.Canvas
javax.media.j3d.Canvas3D
gov.nih.mipav.view.renderer.J3D.VolumeCanvas3D
gov.nih.mipav.view.renderer.J3D.PlaneRender
All Implemented Interfaces:
MouseBehaviorCallback, MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

public class PlaneRender extends VolumeCanvas3D implements MouseMotionListener, MouseListener, MouseBehaviorCallback
Class PlaneRender: renders a single dimension of the ModelImage data as a texture-mapped polygon. The PlaneRender class keeps track of whether it is rendering the Axial, Sagital, or Coronal view of the data. Surfaces are displayed as the intersection of the ModelTriangleMesh with the rendered z-slice.
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Use serialVersionUID for interoperability.
      See Also:
    • m_aiLocalImageExtents

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

      private javax.media.j3d.ImageComponent2D[] m_akImageComponent
      Image component 2D. Used to store the ModelImage data as textures.
    • m_akColors

      private javax.vecmath.Color3f[] m_akColors
      Set of colors used to draw the X and Y Bars and the Z box:.
    • 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_bEntryPointSelect

      private boolean m_bEntryPointSelect
      Boolean to turn on/off the RFA probe entry point selection with mouse:.
    • 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_bMemoryUsage

      private boolean m_bMemoryUsage
      Whether to store all the data in ImageComponent2D array or not:.
    • m_bPatientOrientation

      private boolean m_bPatientOrientation
      Actual image orietation.
    • m_bRightMousePressed

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

      private float m_fCenterX
      The center of the X,Y bar cross hairs, in plane coordinates:.
    • m_fCenterY

      private float m_fCenterY
      The center of the X,Y bar cross hairs, in plane coordinates:.
    • 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 dicatating the size of the plane based on the extents and resolutions of the image.
    • m_fYBox

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

      private float m_fMaxBox
      Numbers dicatating 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_fXTranslate

      private float m_fXTranslate
      X direction mouse translation.
    • 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_fYTranslate

      private float m_fYTranslate
      Y direction mouse translatioin.
    • m_fZoomScale

      private float m_fZoomScale
      Image scaling from Zoom:.
    • m_iPlaneOrientation

      private int m_iPlaneOrientation
      Which dimension of the ModelImage to render.
    • 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_kCanvas

      private VolumeCanvas3D m_kCanvas
      The Canvas3D object on which the plane is drawn.
    • m_kCurrentTransform

      private javax.media.j3d.Transform3D m_kCurrentTransform
      current zoom transformation
    • m_kDisplayedImage

      private javax.media.j3d.ImageComponent2D m_kDisplayedImage
      The current displayed texture, based on the value of m_iSlice.
    • m_kImageA

      private ModelImage m_kImageA
      Current image A.
    • m_kImageB

      private ModelImage m_kImageB
      Current image B.
    • m_kLabelX

      private String m_kLabelX
      x-axis label:
    • m_kLabelY

      private String m_kLabelY
      y-axis label:
    • m_kMouseTranslate

      private MouseTranslation m_kMouseTranslate
      Mouse translate behavior.
    • m_kMouseZoom

      private MouseZoomBehavior m_kMouseZoom
      Mouse zoom behavior.
    • m_kObjRootBG

      private javax.media.j3d.BranchGroup m_kObjRootBG
      The BranchGroup root of the scene managed by the simple universe. The root has a single child, a TransformGroup, that manages all of the actual objects.
    • m_kOrderedGroup

      private javax.media.j3d.OrderedGroup m_kOrderedGroup
      Root order group of the image scene graph.
    • m_kParent

      private ViewJFrameVolumeView m_kParent
      Reference to the parent frame:.
    • m_kRFA_BranchGroup

      private javax.media.j3d.BranchGroup m_kRFA_BranchGroup
      Branch group for the RFA indicator point.
    • m_kTextBranchGroup

      private javax.media.j3d.BranchGroup m_kTextBranchGroup
      Branch group to hold the texture image.
    • m_kTextTransformGroup

      private javax.media.j3d.TransformGroup m_kTextTransformGroup
      Transform group to hold the texture images.
    • m_kTexture

      private javax.media.j3d.Texture2D m_kTexture
      The 2D texture for the texture-mapped polygon.
    • m_kTranslationTG

      private javax.media.j3d.TransformGroup m_kTranslationTG
      Group dictating how the plane is translated.
    • m_kUniverse

      private com.sun.j3d.utils.universe.SimpleUniverse m_kUniverse
      The SimpleUniverse object which is the parent of everything else in the scene.
    • m_kPatientSlice

      private PatientSlice m_kPatientSlice
      PatientSlice contains all the Patient Coordinate System view-specific data for rendering this component:
    • m_kWinLevel

      private WindowLevel m_kWinLevel
  • Constructor Details

    • PlaneRender

      public PlaneRender(ViewJFrameVolumeView kParent, ModelImage kImageA, ModelLUT kLUTa, ModelImage kImageB, ModelLUT kLUTb, GraphicsConfiguration kConfig, int iPlane, boolean bMemory)
      Creates a new PlaneRender object.
      Parameters:
      kParent - ViewJFrameVolumeView - reference to parent frame.
      kImageA - First image to display, cannot be null.
      kLUTa - LUT of the imageA (if null grayscale LUT is constructed).
      kImageB - Second loaded image, may be null.
      kLUTb - LUT of the imageB, may be null.
      kConfig - GraphicsConfiguration
      iPlane - Image dimension to be displayed.
      bMemory - when true store all the data in memory, when false, write textues as the slices change
  • Method Details

    • close

      public void close()
      Closes the frame.
    • disposeLocal

      public void disposeLocal()
      Clean memory.
    • drawRFAPoint

      public void drawRFAPoint(javax.vecmath.Point3f kPoint)
      Given a point in FileCoordinates, transform the point to local PatientCoordinates, and draw with a red sphere:
      Parameters:
      kPoint - RFA indicator point coordinate
    • enableTargetPointPicking

      public void enableTargetPointPicking(boolean bEnable)
      Enable or disable target point for the RFA probe from within the plane renderer:
      Parameters:
      bEnable - true enable target point, false not.
    • getCanvas

      public VolumeCanvas3D getCanvas()
      Returns the VolumeCanvas3D object.
      Returns:
      the volume canvas
    • getImageA

      public ModelImage getImageA()
      Accessor that returns the reference to image A.
      Returns:
      Image A.
    • getImageB

      public ModelImage getImageB()
      Accessor that returns the reference to image B.
      Returns:
      Image B.
    • mouseClicked

      public void mouseClicked(MouseEvent kEvent)
      One of the overrides necessary to be a MouseListener. This function is called when there is a double-click event.
      Specified by:
      mouseClicked in interface MouseListener
      Parameters:
      kEvent - the mouse event generated by a mouse clicked
    • mouseDragged

      public void mouseDragged(MouseEvent kEvent)
      One of the overrides necessary to be a MouseListener. This function is invoked when a mouse button is held down and the mouse is dragged in the active window area.
      Specified by:
      mouseDragged in interface MouseMotionListener
      Parameters:
      kEvent - the mouse event generated by a mouse drag
    • mouseEntered

      public void mouseEntered(MouseEvent kEvent)
      One of the overrides necessary to be a MouseListener. This function is called when the mouse enters the active area.
      Specified by:
      mouseEntered in interface MouseListener
      Parameters:
      kEvent - the mouse event generated by a mouse entered
    • mouseExited

      public void mouseExited(MouseEvent kEvent)
      One of the overrides necessary to be a mouselistener. This function is called when the mouse leaves the active area.
      Specified by:
      mouseExited in interface MouseListener
      Parameters:
      kEvent - the mouse event generated by a mouse exit
    • mouseMoved

      public void mouseMoved(MouseEvent kEvent)
      One of the overrides necessary to be a MouseMotionListener. This function is called when the mouse is moved (without holding any buttons down).
      Specified by:
      mouseMoved in interface MouseMotionListener
      Parameters:
      kEvent - the event generated by a mouse movement
    • mousePressed

      public void mousePressed(MouseEvent kEvent)
      One of the overrides necessary to be a MouseListener.

      If the left mouse button is pressed, the function sets the m_bLeftMousePressed to be true, and records the current canvas width and height.

      Specified by:
      mousePressed in interface MouseListener
      Parameters:
      kEvent - the mouse event generated by a mouse press
    • mouseReleased

      public void mouseReleased(MouseEvent kEvent)
      One of the overrides necessary to be a MouseListener.
      Specified by:
      mouseReleased in interface MouseListener
      Parameters:
      kEvent - the mouse event generated by a mouse release
    • setBackgroundColor

      public void setBackgroundColor(Color color)
      Sets the background color for the frame and rendered image.
      Parameters:
      color - RGBA color to use as the background color.
    • setLUTa

      public void setLUTa(ModelLUT LUT)
      Accessor that sets the LUT for image A.
      Parameters:
      LUT - The LUT.
    • setLUTb

      public void setLUTb(ModelLUT LUT)
      Accessor that sets the LUT for image B.
      Parameters:
      LUT - The LUT.
    • setRGBTA

      public void setRGBTA(ModelRGB RGBT)
      Accessor that sets the RGB lookup table for image A.
      Parameters:
      RGBT - the new ModelRGB for PatientSlice.imageA
    • setRGBTB

      public void setRGBTB(ModelRGB RGBT)
      Accessor that sets the RGB lookup table for image B.
      Parameters:
      RGBT - the new ModelRGB for PatientSlice.imageB
    • setSlice

      public void setSlice(float fSlice)
      Changes the displayed texture based on the new value for m_iSlice.
      Parameters:
      fSlice - The relative position along the actual m_aiLocalImageExtents[2] dimension of the new slice.
    • setXBar

      private void setXBar(float fSlice)
      Sets the new location of the XBar.
      Parameters:
      fSlice - The new position of the XBar in plane coordinates:
    • setSliceHairColor

      public void setSliceHairColor(int iView, javax.vecmath.Color3f kColor)
      Sets the default color for the SliceHairColor.
      Parameters:
      kColor - set the hair color to this color
    • setYBar

      private void setYBar(float fSlice)
      Sets the new location of the YBar.
      Parameters:
      fSlice - The new position of the YBar in plane coordinates:
    • showAxes

      public void showAxes(boolean bShow)
      Turns displaying the Axis labes on or off:
      Parameters:
      bShow - when true display the axis lables, 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
    • transformChanged

      public void transformChanged(int type, javax.media.j3d.Transform3D transform)
      Tells the mouse dialog that the transform has changed.
      Specified by:
      transformChanged in interface MouseBehaviorCallback
      Parameters:
      type - Type of transform.
      transform - Transform that was changed to.
    • update

      public void update()
      Causes the labels to be redrawn:.
    • updateData

      public void updateData()
      Causes new data to be loaded from the ModelImage into the textures and redisplayed on the texture-mapped polygon:
    • updateLut

      public void updateLut(ModelLUT LUTa, ModelLUT LUTb)
      Causes the data to be redrawn with new LUT values:
      Parameters:
      LUTa - imageA LUT
      LUTb - imageB LUT
    • updateRGBTA

      public void updateRGBTA(ModelRGB RGBT)
      Causes the data to be redrawn with new RGBTA values:
      Parameters:
      RGBT - imageA ModelRGB
    • updateRGBTB

      public void updateRGBTB(ModelRGB RGBT)
      Causes the data to be redrawn with new RGBTA values:
      Parameters:
      RGBT - imageB ModelRGB
    • finalize

      protected void finalize() throws Throwable
      Cleans memory.
      Overrides:
      finalize in class Object
      Throws:
      Throwable - if there is a problem encountered during memory clean-up
    • createImageSceneGraph

      private void createImageSceneGraph()
      Creates the scene graph, made up of a branch group parent, a transform group under that which applies mouse behaviors to the scene, and a branch groups under the transform group for the texture-mapped polygon.
    • drawLabels

      private void drawLabels()
      Draws the Z box, the X bar and the Y bar:.
    • ScreenToLocal

      private void ScreenToLocal(int iX, int iY, WildMagic.LibFoundation.Mathematics.Vector3f kLocal, boolean bSetCenter)
      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
      bSetCenter - if true updates the position for rendering the x-bar and y-bar colored axes (for left mouse drag)
    • 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)
      Convert the position in PatientCoordinates into Local rendering coordinates:
      Parameters:
      patientPt - the current point in PatientCoordinates
      localPt - the transformed point in LocalCoordinates
    • init

      private void init()
      Creates the scene graph and initializes the SimpleUniverse and the Viewing transformations.
    • initAxes

      private void initAxes()
      Initializes the Axis labels based on the ModelImage orientation. Axes are displayed with 3D text objects and arrows drawn as polygons. They are colored and labeled to match the axes they represent.
    • processLeftMouseDrag

      private void processLeftMouseDrag(MouseEvent kEvent)
      Dragging the mouse with the left-mouse button held down changes the positions of the X and Y cross bars, and therefor the ZSlice positions of the associated PlaneRender 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
    • setCenter

      public void setCenter(WildMagic.LibFoundation.Mathematics.Vector3f center)
      setCenter sets the cursor and slice position for this PlaneRender 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.
    • getCenter

      public javax.vecmath.Vector3f getCenter()
      Returns the current center point of the 3 intersecting ModelImage planes in FileCoordinates.
      Returns:
      the current volume center point in FileCoordinates
    • processRightMouseDrag

      private void processRightMouseDrag(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
    • setOrientation

      private void setOrientation()
      Based on the orientaion 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.

    • updateViewScreenScale

      private void updateViewScreenScale(javax.media.j3d.Transform3D kTransform)
      This function calculates the scale factor for zooming in parallel projection. The scenario is to calculate the distance between the origin boxframe center and tranformed boxframe center. This distance is used to compute the screen scale factor.
      Parameters:
      kTransform - The tranformation matrix from tranformChanged().
    • writeTexture

      private void writeTexture(boolean bForceShow)
      Stores the ModelImage data as an array of texture maps, with LUT or RGBA color lookup:.