Class VOIManager

java.lang.Object
gov.nih.mipav.view.renderer.WildMagic.VOI.VOIManager
All Implemented Interfaces:
ActionListener, KeyListener, MouseListener, MouseMotionListener, EventListener
Direct Known Subclasses:
VOILatticeManager

public class VOIManager extends Object implements ActionListener, KeyListener, MouseListener, MouseMotionListener
VOIManager class performs all direct user-manipulation of VOIs. The VOIManager is a MouseListener and MouseMotionListener. It takes MouseEvent input and creates VOIs based on the MouseEvent input. This class handles creating all the VOIBase types: VOILine, VOIPoint, VOIPolyLineSlice, VOIContour, VOIText, etc. It further defines the specific types: rectangle, oval, levelset, livewire, splitline, etc. The VOIManager class handles VOI selection, moving single points in a VOI, adding new points to a VOI, and moving a VOI as a unit. This class handles the retrace function, for adjusting an existing VOI contour with the mouse. It handles the livewire and level set calculations for creating levelset and livewire VOIs. The VOIManager is responsible for drawing VOIs for the ViewJComponentEditImage class. The VOIManager interacts with the ViewJPopupPt and ViewJPopupVOI popup menus. All interaction between the VOIManager and the VOI is in local screen space. The ViewJFrameTriImage class displays a single ModelImage in three different orientations: Axial, Coronal, and Sagittal. There is a different VOIManager for each of the displayed orientations. The VOIManager operates in the local coordinate space and is linked directly to a ScreenCoordinateListener and a display Component to translate between the local screen space and the original ModelImage file coordinate space. For example the VOIManagers created for the ViewJFrameTriImage are linked to the three ViewJComponentTriImage(s) which are ScreenCoordinateListeners. The VOIManager uses the ScreenCoordinateListener to translate local MouseEvent X,Y positions into image file coordinates for drawing and storing VOI contours. Although all interaction between the VOIManager and the VOI is in local screen space, the VOI stores the contour data in ModelImage file coordinates. The VOIManager converts the local coordinates into ModelImage file coordinates when a new VOI is created. The contour data is converted as needed by the VOIManager to local space for interaction and display. This class should only be created by the VOIManagerInterface class and is contained within that class.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    class 
    Binary search tree, modified so it will work with elements that have the same cost.
    class 
    Tree node.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Livewire calculations:
    private static final int
     
    private byte[]
     
    static final String
    used in the popup menu when the user right-clicks over a voi intensity line.
    private float
     
    static final int
    chooses all the gradient cost functions
    static final int
    chooses the gradient magnitude cost
    static final int
    chooses the gradient magnitude and intensity based cost functions
    static final int
    chooses the gradient magnitude and medialness cost functions
    private float[]
     
    private int
    Contour Retrace:
    static final int
    chooses the intensity magnitude
    private boolean
     
    private boolean
     
    private int
     
    private int
     
    private int
     
    private static final int
     
    private PointStack
    Used to calculate the levelset contour.
    private static final int
     
    private static final int
     
    private float[]
     
    private static final int
     
    private boolean[]
     
    private boolean[]
     
    private boolean[]
     
    private double[]
     
    private double[]
     
    private int[]
    Local orientation of the displayed image, used in the volume renderer and tri-planar views.
    private int[]
    The image extents in the local orientation.
    private ModelImage[]
    ImageA and ImageB
    private boolean
     
    private boolean
    Set to true when the user is actively drawing or modifying a VOI contour.
    protected boolean
    Change the mouse cursor with the first mouseDrag event
    private boolean
     
    private boolean
    Calculations for the oval voi are calculated one time:
    private boolean
    Set to true when the left mouse is pressed.
    private boolean
     
    private boolean
    Whether the livewire properties (e.g. gradient magnitude) should be recalculated
    private boolean
     
    private boolean
    Set to true if the left mouse is pressed during drag.
    private boolean
    True if the user has selected the quick lut feature:
    protected boolean
    Set to true when the user has selected a VOI contour.
    protected float
    Last/current mouse position.
    protected float
     
    private int
     
    private int
     
    private int
    Type of livewire cost function, gradient magnitude, laplace, intensity.
    protected int
    The near status of the mouse, used to set the mouse cursor.
    protected int
    Set to XPLANE, YPLANE, or ZPLANE, depending on the image orientation.
    private VOIBase
     
    protected Component
    The canvas
    private VOIBase
    The contour to copy.
    protected VOIBase
    Current active voi contour.
    ScreenCoordinateListener translates between the current image dimensions, canvas size, and mouse coordinates for correct mouse interaction.
    protected ModelImage
    Current active image.
    private ModelImage
    A re-oriented version of the active image, re-oriented so it matches the currently displayed image orientations in either the tri-planar or volume render views.
    protected WildMagic.LibFoundation.Mathematics.Vector3f
    m_kMouseOffset is used to determine movements.
    A reference to the VOIManagerInterface
    protected ViewJPopupPt
    Popup Menu for VOIPoints.
    protected ViewJPopupVOI
    Popup Menu for VOIs (non-point).
    private BitSet
    Used to calculate the levelset contour.
    static final int
    chooses the medialness cost
    protected static final int
     
    protected static final int
     
    protected static final int
    VOI contour near status:
    protected static final int
     
    private static final int
     
    private VOIContour
     
    private static final int
     
    private static final double[]
     
    private static final double[]
    Used for angle searches in line VOI creation
    private static final int
     
    private static final int
     
    private static final int
     
    private BitSet
     
    private static final int
     
    private static final int
     
    private static final int
     
    private boolean
     
    private static final int
     
    private float[]
     
    private int
     
    static final String
    used in the popup menu when the user right-clicks over a voi intensity line.
    static final String
    used in the popup menu when the user right-clicks over a voi intensity line.
    private static final int
     
    private Stack<int[]>
    Used to calculate the levelset contour.
    private static final int
     
    private float[]
     
    private float[]
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    add(VOIBase kVOI, float fHue)
    Called from ViewJComponentTriImage to add the image-align protractor.
    private boolean
    add(VOIBase kVOI, int iPos, WildMagic.LibFoundation.Mathematics.Vector3f kNewPoint, boolean bIsFile)
    Add a point to the voi contour
    private boolean
    add(VOIBase kVOI, WildMagic.LibFoundation.Mathematics.Vector3f kNewPoint, boolean bIsFile)
    Add a new point to the end of the current contour.
    private void
    Link the popup menu to the input voi so the popup menu will operate on the input voi.
    private void
    addVOIPoint(int iX, int iY)
    Adds a point to the current voi.
    private void
    anchor(int iX, int iY, boolean bSeed)
    Add an anchor point to the livewire contour.
    private void
    anchorBSpline(int iX, int iY, boolean bFinished)
    Add an anchor point to the BSpline line contour.
    private void
    anchorPolyline(int iX, int iY, boolean bFinished)
    Add an anchor point to the poly line contour.
    private float
    avgPix(int index)
    This method calculates the average pixel value based on the four neighbors (N, S, E, W).
    private void
    BsplineCurve(WildMagic.LibFoundation.Mathematics.Vector3f[] BsplinePts, int numPts, int pointReduced, int degree, Vector<WildMagic.LibFoundation.Mathematics.Vector3f> result)
    Compute Bspline segment
    private void
    computeGradient(float xCoord, float yCoord, float zCoord, double[] result, double[] grad, double[] gradDir)
    With given x, y, z point coordinate, compute the gradient magnitude and gradient direction
    private void
    computeNormalLine(WildMagic.LibFoundation.Mathematics.Vector3f startPt, WildMagic.LibFoundation.Mathematics.Vector3f endPt, WildMagic.LibFoundation.Mathematics.Vector3f midPt, WildMagic.LibFoundation.Mathematics.Vector3f outNormPt, WildMagic.LibFoundation.Mathematics.Vector3f inNormPt, float stepPct, WildMagic.LibFoundation.Mathematics.Vector3f normStep, WildMagic.LibFoundation.Mathematics.Vector3f interpPt)
    When the line segment is drawn, take the mid point, create the normal line across the mid point.
    protected boolean
    contains(VOIBase kVOI, int iX, int iY, int iZ)
    Used to determine which contour is selected.
    private int
    convertGraphToInt(int next, int xDim)
    Takes a byte and gets appropriate addition from current position.
    void
    createOvalVOI(int left, int top, int width, int height, int slice)
     
    void
    createPointVOI(int[] x, int[] y, int n, int slice)
     
    void
    createPolygonVOI(int[] x, int[] y, int n, int slice)
     
    private void
    createTextVOI(int iX, int iY)
    Creates a new VOIText at the local point.
    private VOIBase
    createVOI(int iType, boolean bClosed, boolean bFixed, Vector<WildMagic.LibFoundation.Mathematics.Vector3f> kPositions)
    Creates a new VOI Contour based on the input type.
    private void
    createVOI(MouseEvent mouseEvent)
    Creates a new VOI Contour or adds a new point to the existing VOI Contour.
    private boolean
    Checks the axisOrder and axisFlip data members.
    void
    Called from ViewJComponentTriImage to delete the VOIProtractor.
    void
    Cleans up local memory.
    void
    doLevelset(WildMagic.LibFoundation.Mathematics.Vector3f point)
     
    void
    doVOI(String kCommand, boolean isDrawCommand)
    Called from VOIManagerInterface.
    void
    draw(VOIBase kVOI, float[] resolutions, int[] unitsOfMeasure, int slice, Graphics g, boolean bShowAllPoints)
    Draws the input VOI in the ViewJComponentEditImage
    private void
    drawArrow(VOIText kVOI, Graphics2D g2d, int xCenter, int yCenter, int x, int y, float stroke)
    Draw the VOIText arror on screen.
    private void
    Draws the geometric center on screen.
    private void
    drawLength(Graphics g, VOIBase kVOI, float[] resols, int[] unitsOfMeasure)
    Draws length of the open contour.
    private void
    drawNext(int iX, int iY)
    Draws the livewire from the last anchor point to the current mouse position.
    private void
    drawNextPolyline(int iX, int iY)
    Draws the open contour from the last anchor point to the current mouse point.
    private void
    drawTickMarks(VOIBase kVOI, Graphics g, int[] unitsOfMeasure, int xD, int yD, float[] res)
    Draw the tick marks for the VOIProtractor
    private void
    drawTickMarks(VOIBase kVOI, Graphics g, Color color, int[] unitsOfMeasure, int xD, int yD, float[] res)
    Draws the tick marks on the VOILine.
    private void
    drawVOI(VOIBase kVOI, float[] resols, int[] unitsOfMeasure, Graphics g)
    Draw the VOI Contour (open or closed).
    private void
    drawVOILine(VOIBase kVOI, float[] resols, int[] unitsOfMeasure, Graphics g, int thickness)
    Draw the VOILine.
    private void
    Draw the input VOIPoint.
    private void
    Draw the input VOIPoint with the input label.
    private void
    drawVOIPolyLineSlice(VOIPolyLineSlice kVOI, float[] resols, int[] unitsOfMeasure, Graphics g)
    Draws the input VOIPolyLineSlice.
    private void
    drawVOIProtractor(VOIBase kVOI, float[] resols, int[] unitsOfMeasure, Graphics g)
    Draws the input VOIProtractor.
    private void
    Draws the input VOIText.
    void
    editCircleDiameter(VOIBase kVOI, float radius)
    Called from the JDialogEditCircleDiameter.
    void
    editSquareLength(VOIBase kVOI, float length)
    Called from JDialogEditSquareLenth, changes the length of the selected square VOI.
    private WildMagic.LibFoundation.Mathematics.Vector3f
    fileCoordinatesToPatient(WildMagic.LibFoundation.Mathematics.Vector3f volumePt)
    Converts the input position from file coordinates to the local patient coordinates.
    private void
    findBestGradientChange(WildMagic.LibFoundation.Mathematics.Vector3f interpPt, WildMagic.LibFoundation.Mathematics.Vector3f normStep, float sliceZ, float[] x, float[] y)
    From the mid point of normal line, tracing both inward and outward diection along the normal line
    private WildMagic.LibFoundation.Mathematics.Vector3f
    Calculates and returns the bounding box middle left-edge point for the input VOI.
    private WildMagic.LibFoundation.Mathematics.Vector3f
    Calculates and returns the bounding box lower edge left corner for the input VOI.
    private WildMagic.LibFoundation.Mathematics.Vector3f
    Calculates and returns the bounding box lower edge middle point for the input VOI.
    private WildMagic.LibFoundation.Mathematics.Vector3f
    Calculates and returns the bounding box lower edge right corner for the input VOI.
    private WildMagic.LibFoundation.Mathematics.Vector3f
    Calculates and returns the bounding box middle right-edge point for the input VOI.
    private WildMagic.LibFoundation.Mathematics.Vector3f
    Calculates and returns the bounding box upper edge left corner for the input VOI.
    private WildMagic.LibFoundation.Mathematics.Vector3f
    Calculates and returns the bounding box upper edge middle point for the input VOI.
    private WildMagic.LibFoundation.Mathematics.Vector3f
    Calculates and returns the bounding box upper edge right corner for the input VOI.
    Called from VOIManagerInterface.
    private void
    getCoordsLine(float[] linePtsX, float[] linePtsY, double fraction, float[] coords)
    Calculates the screen coordinates for the VOILine tickmarks.
    private void
    getCoordsProtractor(float[] x, float[] y, double fraction, float[] coords)
    Calculates and returns the screen location for the angle and length display for the VOIProtractor.
     
    boolean
     
    private void
    getEndLinesLine(float[] linePtsX, float[] linePtsY, int line, float[] coords)
    Calculates and returns the inverted-arrow coordinates for the VOILine tickmark display.
    private void
    getEndLinesProtractor(float[] x, float[] y, int line, float[] coords)
    Calculates and returns the arrow-head coordinates for the VOIProtractor tickmark display.
     
    Returns a ModelImage in the local image space, if a local ModelImage has already been created it is returned.
    Called from ViewJComponentEditImage.
    int
    Returns the plane this VOIManager is drawing into.
    protected int
    Returns the slice of the input VOI in the patient coordinates displayed locally.
    private void
    Opens the VOIIntensity line drawing popup menu.
    void
    init(JFrame kFrame, ModelImage kImageA, ModelImage kImageB, Component kComponent, ScreenCoordinateListener kContext, int iOrientation)
    Initialize the VOIManager.
    private void
    initLevelSet(int iSlice)
    Initializes the Levelset VOI calculation.
    private void
    initLiveWire(int iSlice, boolean bLiveWire)
    Initializes the Livewire VOI calculation.
    boolean
    Returns true if the VOIManager is currently drawing a VOI, or if the defaultPointer button in the VOIManagerInterface is selected.
    void
     
    void
     
    void
     
    void
    liveWire(int iSelection)
    Called from VOIManagerInterface.
    void
     
    void
     
    void
     
    void
     
    void
     
    void
     
    void
     
    void
    move(VOIBase kVOI, WildMagic.LibFoundation.Mathematics.Vector3f kDiff)
    Moves the input VOI by the input Vector amount.
    private void
    Called when the left-mouse is used to drag a point on the VOI.
    protected boolean
    nearBoundPoint(VOIBase kVOI, int iX, int iY, int iZ)
    Calculates the bounding box of the voi contour and returns true if the input point is near the bounding box.
    protected boolean
    nearLine(VOIBase kVOI, int iX, int iY, int iZ)
    Called when the user is selecting a VOI or during MouseDrag to show if a VOI can be selected, or for selected VOIs, to show if the Mouse is close enough to the contour for the user to add a point to the contour line.
    protected boolean
    nearPoint(VOIBase kVOI, int iX, int iY, int iZ)
    Called when the user is selecting a VOI or during MouseDrag to show if a VOI can be selected, or for selected VOIs, to show if the Mouse is close enough to one of the points on the contour for the user to move that contour point
    void
    Called from VOIManagerInterface.
    private void
    pasteVOI(int iSlice)
     
    void
    Called from VOIManagerInterface.
    private void
    paths(int index, int i, float level)
    Generates the possible paths of the level set and pushes them onto a stack.
    private WildMagic.LibFoundation.Mathematics.Vector3f
    patientCoordinatesToFile(WildMagic.LibFoundation.Mathematics.Vector3f patientPt)
    Converts the local patient point into file coordinates.
    protected void
     
    void
    propagateVOI(VOIBase kVOI, int dir)
    Called from VOIManagerInterface.
    private void
     
    private void
    Resets all retrace variables and allows it to start anewA
    private void
    retraceContour(VOIBase kVOIIn, int x1, int y1)
     
    void
    scaleCircleVOI(VOIBase kVOI, float scale)
     
    private Polygon
     
    void
    scaleSquareVOI(VOIBase kVOI, float scale)
     
    private void
    scaleVOI(VOIBase kVOI, MouseEvent mouseEvent)
     
    private void
    seed(int iX, int iY)
    Sets up directed graph from the seed point.
    protected VOIBase
     
    boolean
    setActive(boolean active)
    Programmatically sets whether the GUI should be in a state to draw VOIs.
    void
    setActiveImage(int iActive)
    Sets the current active image.
    private void
    setCanvas(Component kComponent)
     
    private void
     
    void
    setImage(ModelImage image, int iOrientation)
     
    void
    Sets a new imageB.
    private void
    setOrientation(int iOrientation)
     
    void
    Called from VOIManagerInterface.
    void
    Called from VOIManagerInterface.
    private void
    setPosition(VOIBase kVOI, int iPos, float fX, float fY, float fZ)
     
    private void
    setPosition(VOIBase kVOI, int iPos, float fX, float fY, float fZ, boolean isCtrlDown)
     
    private void
    setPosition(VOIBase kVOI, int iPos, WildMagic.LibFoundation.Mathematics.Vector3f kPos)
     
    private void
    setPosition(VOIBase kVOI, int iPos, WildMagic.LibFoundation.Mathematics.Vector3f kPos, boolean isCtrlDown)
     
    private void
     
    protected void
     
    private VOIBase
    singleLevelSet2(float startPtX, float startPtY)
    Creates a single level set.
    private void
    Bspline smoothing
    private VOIBase
    split(VOIBase kVOI, WildMagic.LibFoundation.Mathematics.Vector3f kStartPt, WildMagic.LibFoundation.Mathematics.Vector3f kEndPt)
     
    private void
    splitVOIs(boolean bAllSlices, boolean bOnlyActive, VOIBase kSplitVOI)
     
    private WildMagic.LibFoundation.Mathematics.Vector3f
    straightenLineVOI(WildMagic.LibFoundation.Mathematics.Vector3f kPos, VOIBase kOld)
    Modifies kPos to form an angle with its origin point that is a multiple of 15 degrees.
    boolean
    testMove(WildMagic.LibFoundation.Mathematics.Vector3f kDiff, WildMagic.LibFoundation.Mathematics.Vector3f[] akMinMax, boolean bUseMouse)
    Called from VOIManagerInterface when several VOIs are selected and moved as a group.
    private void
    updateRectangle(int iX, int iMouseX, int iY, int iYStart)
     

    Methods inherited from class java.lang.Object

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

    • GRADIENT_MAG

      public static final int GRADIENT_MAG
      chooses the gradient magnitude cost
      See Also:
    • MEDIALNESS

      public static final int MEDIALNESS
      chooses the medialness cost
      See Also:
    • INTENSITY

      public static final int INTENSITY
      chooses the intensity magnitude
      See Also:
    • GRADIENT_MAG_MED

      public static final int GRADIENT_MAG_MED
      chooses the gradient magnitude and medialness cost functions
      See Also:
    • GRADIENT_MAG_INT

      public static final int GRADIENT_MAG_INT
      chooses the gradient magnitude and intensity based cost functions
      See Also:
    • GRADIENT_ALL

      public static final int GRADIENT_ALL
      chooses all the gradient cost functions
      See Also:
    • m_bDrawVOI

      private boolean m_bDrawVOI
      Set to true when the user is actively drawing or modifying a VOI contour.
    • m_bSelected

      protected boolean m_bSelected
      Set to true when the user has selected a VOI contour.
    • DELETE_INTENSITY_LINE

      public static final String DELETE_INTENSITY_LINE
      used in the popup menu when the user right-clicks over a voi intensity line.
      See Also:
    • SHOW_INTENSITY_GRAPH

      public static final String SHOW_INTENSITY_GRAPH
      used in the popup menu when the user right-clicks over a voi intensity line.
      See Also:
    • SHOW_LINE_ENDPOINTS

      public static final String SHOW_LINE_ENDPOINTS
      used in the popup menu when the user right-clicks over a voi intensity line.
      See Also:
    • PI_MULT

      private static final double[] PI_MULT
    • NONE

      private static final int NONE
      See Also:
    • TEXT

      private static final int TEXT
      See Also:
    • POINT

      private static final int POINT
      See Also:
    • POLYPOINT

      private static final int POLYPOINT
      See Also:
    • LINE

      private static final int LINE
      See Also:
    • PROTRACTOR

      private static final int PROTRACTOR
      See Also:
    • RECTANGLE

      private static final int RECTANGLE
      See Also:
    • OVAL

      private static final int OVAL
      See Also:
    • POLYLINE

      private static final int POLYLINE
      See Also:
    • LEVELSET

      private static final int LEVELSET
      See Also:
    • LIVEWIRE

      private static final int LIVEWIRE
      See Also:
    • RECTANGLE3D

      private static final int RECTANGLE3D
      See Also:
    • SPLITLINE

      private static final int SPLITLINE
      See Also:
    • LUT

      private static final int LUT
      See Also:
    • RETRACE

      private static final int RETRACE
      See Also:
    • BSPLINE

      private static final int BSPLINE
      See Also:
    • m_iDrawType

      private int m_iDrawType
    • m_kCurrentVOI

      protected VOIBase m_kCurrentVOI
      Current active voi contour.
    • m_kCopyVOI

      private VOIBase m_kCopyVOI
      The contour to copy.
    • m_kDrawingContext

      protected ScreenCoordinateListener m_kDrawingContext
      ScreenCoordinateListener translates between the current image dimensions, canvas size, and mouse coordinates for correct mouse interaction.
    • levelSetStack

      private PointStack levelSetStack
      Used to calculate the levelset contour.
    • map

      private BitSet map
      Used to calculate the levelset contour.
    • stack

      private Stack<int[]> stack
      Used to calculate the levelset contour.
    • m_bLeftMousePressed

      private boolean m_bLeftMousePressed
      Set to true when the left mouse is pressed.
    • m_bFirstDrag

      protected boolean m_bFirstDrag
      Change the mouse cursor with the first mouseDrag event
    • m_fMouseX

      protected float m_fMouseX
      Last/current mouse position.
    • m_fMouseY

      protected float m_fMouseY
    • m_aiAxisOrder

      private int[] m_aiAxisOrder
      Local orientation of the displayed image, used in the volume renderer and tri-planar views.
    • m_abAxisFlip

      private boolean[] m_abAxisFlip
    • m_akImages

      private ModelImage[] m_akImages
      ImageA and ImageB
    • m_kImageActive

      protected ModelImage m_kImageActive
      Current active image.
    • m_kLocalImage

      private ModelImage m_kLocalImage
      A re-oriented version of the active image, re-oriented so it matches the currently displayed image orientations in either the tri-planar or volume render views. This is used for level-set and livewire in the tri-planar view.
    • m_aiLocalImageExtents

      private int[] m_aiLocalImageExtents
      The image extents in the local orientation.
    • m_kParent

      protected VOIManagerInterface m_kParent
      A reference to the VOIManagerInterface
    • m_bFirstVOI

      private boolean m_bFirstVOI
      Calculations for the oval voi are calculated one time:
    • m_iCirclePts

      private int m_iCirclePts
    • m_adCos

      private double[] m_adCos
    • m_adSin

      private double[] m_adSin
    • NearNone

      protected static final int NearNone
      VOI contour near status:
      See Also:
    • NearPoint

      protected static final int NearPoint
      See Also:
    • NearLine

      protected static final int NearLine
      See Also:
    • NearBoundPoint

      protected static final int NearBoundPoint
      See Also:
    • m_iNearStatus

      protected int m_iNearStatus
      The near status of the mouse, used to set the mouse cursor.
    • m_kComponent

      protected Component m_kComponent
      The canvas
    • m_iLiveWireSelection

      private int m_iLiveWireSelection
      Type of livewire cost function, gradient magnitude, laplace, intensity.
    • activeTree

      private VOIManager.ActiveTree activeTree
      Livewire calculations:
    • costGraph

      private byte[] costGraph
    • grad_weight

      private float grad_weight
    • localCosts

      private float[] localCosts
    • processedIndicies

      private BitSet processedIndicies
    • seededCosts

      private float[] seededCosts
    • seedPoint

      private int seedPoint
    • m_bLiveWireInit

      private boolean m_bLiveWireInit
    • m_abInitLiveWire

      private boolean[] m_abInitLiveWire
    • m_bLevelSetInit

      private boolean m_bLevelSetInit
    • m_abInitLevelSet

      private boolean[] m_abInitLevelSet
    • xDirections

      private float[] xDirections
    • yDirections

      private float[] yDirections
    • imageBufferActive

      private float[] imageBufferActive
    • m_bQuickLUT

      private boolean m_bQuickLUT
      True if the user has selected the quick lut feature:
    • m_kPopupVOI

      protected ViewJPopupVOI m_kPopupVOI
      Popup Menu for VOIs (non-point).
    • m_kPopupPt

      protected ViewJPopupPt m_kPopupPt
      Popup Menu for VOIPoints.
    • m_iPlane

      protected int m_iPlane
      Set to XPLANE, YPLANE, or ZPLANE, depending on the image orientation.
    • m_kMouseOffset

      protected WildMagic.LibFoundation.Mathematics.Vector3f m_kMouseOffset
      m_kMouseOffset is used to determine movements. mousePressed() establishes the coordinates of m_kMouseOffset. mouseDragged() calculates distance from the m_kMouseOffset to the present location and uses this distance to move an object.
    • m_bMouseDrag

      private boolean m_bMouseDrag
      Set to true if the left mouse is pressed during drag.
    • m_bCtrlDown

      private boolean m_bCtrlDown
    • indexRetrace

      private int indexRetrace
      Contour Retrace:
    • oldContour

      private VOIContour oldContour
    • lastX

      private int lastX
    • lastY

      private int lastY
    • lastZ

      private int lastZ
    • knowDirection

      private boolean knowDirection
    • isFirst

      private boolean isFirst
    • resetStart

      private boolean resetStart
    • m_bLiveWire

      private boolean m_bLiveWire
      Whether the livewire properties (e.g. gradient magnitude) should be recalculated
    • m_bFirstScale

      private boolean m_bFirstScale
    • m_kBackupVOI

      private VOIBase m_kBackupVOI
  • Constructor Details

    • VOIManager

      public VOIManager(VOIManagerInterface kParent)
      Constructor. Passes in the VOIManagerInterface parent which communicates all user-interface commands to the VOIManager.
      Parameters:
      kParent - containing VOIManagerInterface.
  • Method Details

    • actionPerformed

      public void actionPerformed(ActionEvent event)
      Specified by:
      actionPerformed in interface ActionListener
    • add

      public void add(VOIBase kVOI, float fHue)
      Called from ViewJComponentTriImage to add the image-align protractor.
      Parameters:
      kVOI - the VOIProgractor
      fHue - default color for the protractor.
    • deleteVOI

      public void deleteVOI(VOIBase kVOI)
      Called from ViewJComponentTriImage to delete the VOIProtractor.
      Parameters:
      kVOI - VOIProtractor that will be deleted.
    • dispose

      public void dispose()
      Cleans up local memory.
    • doVOI

      public void doVOI(String kCommand, boolean isDrawCommand)
      Called from VOIManagerInterface.
      Parameters:
      kCommand - VOI Command
      isDrawCommand - when true this command represents a drawing command.
    • draw

      public void draw(VOIBase kVOI, float[] resolutions, int[] unitsOfMeasure, int slice, Graphics g, boolean bShowAllPoints)
      Draws the input VOI in the ViewJComponentEditImage
      Parameters:
      kVOI - input VOI to draw.
      resolutions - image resolutions.
      unitsOfMeasure - image units of measure.
      slice - current image slice in the orientation displayed in the ViewJComponentEditImage.
      g - Graphics.
      orientation - image orientation displayed in the ViewJComponentEditImage
    • editCircleDiameter

      public void editCircleDiameter(VOIBase kVOI, float radius)
      Called from the JDialogEditCircleDiameter. Changes the diameter of a circly VOI.
      Parameters:
      kVOI - the selected VOI to change.
      radius - the new diameter.
    • editSquareLength

      public void editSquareLength(VOIBase kVOI, float length)
      Called from JDialogEditSquareLenth, changes the length of the selected square VOI.
      Parameters:
      kVOI - the selected square VOI to change.
      length - the new length.
    • getComponent

      public Component getComponent()
      Called from VOIManagerInterface.
      Returns:
      returns the Component this VOIManager is attached to.
    • getImage

      public ModelImage getImage()
      Returns:
    • getLocalImage

      public ModelImage getLocalImage()
      Returns a ModelImage in the local image space, if a local ModelImage has already been created it is returned.
      Returns:
      a ModelImage in the local image space.
    • getParent

      public VOIManagerInterface getParent()
      Called from ViewJComponentEditImage. Each ViewJComponentEditImage has a VOIManager attached.
      Returns:
      the VOIManagerInterface parent of this VOIManager.
    • getPlane

      public int getPlane()
      Returns the plane this VOIManager is drawing into. From VOIBase: XPLANE, YPLANE, ZPLANE.
      Returns:
      XPLANE, YPLANE, or ZPLANE.
    • init

      public void init(JFrame kFrame, ModelImage kImageA, ModelImage kImageB, Component kComponent, ScreenCoordinateListener kContext, int iOrientation)
      Initialize the VOIManager.
      Parameters:
      kImageA - imageA.
      kImageB - imageB.
      kComponent - ViewJComponentEditImage this VOIManager is attached to.
      kContext - ScreenCoordinateListener for converting between screen coordinates and image file coordinates.
      iOrientation - orientation of the ViewJComponentEditImage.
    • isActive

      public boolean isActive()
      Returns true if the VOIManager is currently drawing a VOI, or if the defaultPointer button in the VOIManagerInterface is selected.
      Returns:
    • keyPressed

      public void keyPressed(KeyEvent e)
      Specified by:
      keyPressed in interface KeyListener
    • keyReleased

      public void keyReleased(KeyEvent e)
      Specified by:
      keyReleased in interface KeyListener
    • keyTyped

      public void keyTyped(KeyEvent e)
      Specified by:
      keyTyped in interface KeyListener
    • liveWire

      public void liveWire(int iSelection)
      Called from VOIManagerInterface. Initializes the livewire.
      Parameters:
      iSelection - livewire cost function.
    • mouseClicked

      public void mouseClicked(MouseEvent kEvent)
      Specified by:
      mouseClicked in interface MouseListener
    • mouseDragged

      public void mouseDragged(MouseEvent kEvent)
      Specified by:
      mouseDragged in interface MouseMotionListener
    • mouseEntered

      public void mouseEntered(MouseEvent arg0)
      Specified by:
      mouseEntered in interface MouseListener
    • mouseExited

      public void mouseExited(MouseEvent arg0)
      Specified by:
      mouseExited in interface MouseListener
    • mouseMoved

      public void mouseMoved(MouseEvent kEvent)
      Specified by:
      mouseMoved in interface MouseMotionListener
    • mousePressed

      public void mousePressed(MouseEvent kEvent)
      Specified by:
      mousePressed in interface MouseListener
    • mouseReleased

      public void mouseReleased(MouseEvent kEvent)
      Specified by:
      mouseReleased in interface MouseListener
    • move

      public void move(VOIBase kVOI, WildMagic.LibFoundation.Mathematics.Vector3f kDiff)
      Moves the input VOI by the input Vector amount.
      Parameters:
      kVOI - input VOIBase to move.
      kDiff - vector amount to move the input VOI, vales are in image file-coordinates.
    • pasteAllVOI

      public void pasteAllVOI(VOIBase kVOI)
      Called from VOIManagerInterface. Pastes the input VOI onto all slices.
      Parameters:
      kVOI - input VOI.
    • pasteVOI

      public void pasteVOI(VOIBase kVOI)
      Called from VOIManagerInterface. Pastes the input VOI onto the current slice.
      Parameters:
      kVOI - input VOI.
    • propagateVOI

      public void propagateVOI(VOIBase kVOI, int dir)
      Called from VOIManagerInterface. Propagates the input VOI in the input direction.
      Parameters:
      kVOI - input VOI.
      dir - +1 or -1
    • scaleCircleVOI

      public void scaleCircleVOI(VOIBase kVOI, float scale)
      Parameters:
      kVOI -
      scale -
    • scaleSquareVOI

      public void scaleSquareVOI(VOIBase kVOI, float scale)
      Parameters:
      kVOI -
      scale -
    • setActive

      public boolean setActive(boolean active)
      Programmatically sets whether the GUI should be in a state to draw VOIs. Components that are managed by this manager can use this method to indicate that VOI drawing should be stopped.
      Parameters:
      active - Whether VOI drawing should be successful.
      Returns:
      Whether this action is successful.
    • setActiveImage

      public void setActiveImage(int iActive)
      Sets the current active image.
      Parameters:
      iActive -
    • setImage

      public void setImage(ModelImage image, int iOrientation)
    • setImageB

      public void setImageB(ModelImage imageB)
      Sets a new imageB.
      Parameters:
      imageB - new ModelImage imageB.
    • setPopupPt

      public void setPopupPt(ViewJPopupPt kPopupPt)
      Called from VOIManagerInterface. Sets the ViewJPopupPt.
      Parameters:
      kPopupPt -
    • setPopupVOI

      public void setPopupVOI(ViewJPopupVOI kPopupVOI)
      Called from VOIManagerInterface. Sets the ViewJPopupVOI.
      Parameters:
      kPopupPt -
    • testMove

      public boolean testMove(WildMagic.LibFoundation.Mathematics.Vector3f kDiff, WildMagic.LibFoundation.Mathematics.Vector3f[] akMinMax, boolean bUseMouse)
      Called from VOIManagerInterface when several VOIs are selected and moved as a group. This function first tests that the move does not move any of the VOIs in the group out of bounds. If the move keeps all VOIs in-bounds, then the move is executed.
      Parameters:
      kDiff - the amount to move the VOIs.
      akMinMax - the VOI group bounding-box.
      Returns:
      true if the move remains in-bounds, false otherwise.
    • add

      private boolean add(VOIBase kVOI, int iPos, WildMagic.LibFoundation.Mathematics.Vector3f kNewPoint, boolean bIsFile)
      Add a point to the voi contour
      Parameters:
      kVOI - the voi to add to
      iPos - the position the new point will be added after
      kNewPoint - new point
      bIsFile - when true the point is already in file coordinates, when false translate the point to file coordinates.
      Returns:
    • add

      private boolean add(VOIBase kVOI, WildMagic.LibFoundation.Mathematics.Vector3f kNewPoint, boolean bIsFile)
      Add a new point to the end of the current contour.
      Parameters:
      kVOI - current contour
      kNewPoint - new point to add
      bIsFile - if true the point is in file coordinates.
      Returns:
      true if the point was added.
    • addPopup

      private void addPopup(VOIBase kVOI)
      Link the popup menu to the input voi so the popup menu will operate on the input voi.
      Parameters:
      kVOI - input voi for the popup menu.
    • addVOIPoint

      private void addVOIPoint(int iX, int iY)
      Adds a point to the current voi.
      Parameters:
      iX - x in screen coordinates.
      iY - y in screen coordinates.
    • anchor

      private void anchor(int iX, int iY, boolean bSeed)
      Add an anchor point to the livewire contour.
      Parameters:
      iX - x value of the anchor point in file coordinates.
      iY - y value of the anchor point in file coordinates.
      bSeed - when true calculate a new seed from the anchor to the current mouse point, when false the anchor is the last point to add.
    • anchorPolyline

      private void anchorPolyline(int iX, int iY, boolean bFinished)
      Add an anchor point to the poly line contour.
      Parameters:
      iX - x value of the anchor point in file coordinates.
      iY - y value of the anchor point in file coordinates.
      bFinished - when true the current voi is set to active.
    • anchorBSpline

      private void anchorBSpline(int iX, int iY, boolean bFinished)
      Add an anchor point to the BSpline line contour.
      Parameters:
      iX - x value of the anchor point in file coordinates.
      iY - y value of the anchor point in file coordinates.
      bFinished - when true the current voi is set to active.
    • SplineSmooth

      private void SplineSmooth(VOIBase voiLine)
      Bspline smoothing
      Parameters:
      voiLine - VOI contour
    • BsplineCurve

      private void BsplineCurve(WildMagic.LibFoundation.Mathematics.Vector3f[] BsplinePts, int numPts, int pointReduced, int degree, Vector<WildMagic.LibFoundation.Mathematics.Vector3f> result)
      Compute Bspline segment
      Parameters:
      BsplinePts - BSpline init line points
      numPts - number points
      pointReduced - reduced number to create control points
      degree - Bspline degree
      result - resulting smoothed Bspline curve
    • computeNormalLine

      private void computeNormalLine(WildMagic.LibFoundation.Mathematics.Vector3f startPt, WildMagic.LibFoundation.Mathematics.Vector3f endPt, WildMagic.LibFoundation.Mathematics.Vector3f midPt, WildMagic.LibFoundation.Mathematics.Vector3f outNormPt, WildMagic.LibFoundation.Mathematics.Vector3f inNormPt, float stepPct, WildMagic.LibFoundation.Mathematics.Vector3f normStep, WildMagic.LibFoundation.Mathematics.Vector3f interpPt)
      When the line segment is drawn, take the mid point, create the normal line across the mid point. The drawn normal line will be the search range of the best gradient changes.
      Parameters:
      startPt - start point
      endPt - end point
      midPt - mid point
      outNormPt - normal line outward point
      inNormPt - normal line inward point
      stepPct - normal line step percentile
      normStep - number of steps to trace the normal line
      interpPt - the interpolated point, actually just the middle point
    • computeGradient

      private void computeGradient(float xCoord, float yCoord, float zCoord, double[] result, double[] grad, double[] gradDir)
      With given x, y, z point coordinate, compute the gradient magnitude and gradient direction
      Parameters:
      xCoord - x coordinate
      yCoord - y coordinate
      zCoord - z coordinate
      result - result x, y direction gradient sum.
      grad - gradient magnitude
      gradDir - gradient direction.
    • findBestGradientChange

      private void findBestGradientChange(WildMagic.LibFoundation.Mathematics.Vector3f interpPt, WildMagic.LibFoundation.Mathematics.Vector3f normStep, float sliceZ, float[] x, float[] y)
      From the mid point of normal line, tracing both inward and outward diection along the normal line
      Parameters:
      interpPt - mid point
      normStep - normline step, which needed to compute the tracing steps
      sliceZ - z slice number
      x - best gradient change point x coordinate
      y - best gradient change point y coordinate
    • avgPix

      private float avgPix(int index)
      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.
    • contains

      protected boolean contains(VOIBase kVOI, int iX, int iY, int iZ)
      Used to determine which contour is selected. Called by selectVOI and showSelectedVOI. For a closed or open contour, the point must be entirely within the contour. If the input voi is a line or point, returns true if the input point is near the line or point.
      Parameters:
      kVOI - input contour to test.
      iX - x value in screen coordinates.
      iY - y value in screen coordinates.
      iZ - z value in screen coordinates.
      Returns:
      true if inside the contour, or true if near the VOILine or near the VOIPoint.
    • convertGraphToInt

      private int convertGraphToInt(int next, int xDim)
      Takes a byte and gets appropriate addition from current position.
      Parameters:
      next - Byte to check (0-8).
      Returns:
      Value to add to current location.
    • createTextVOI

      private void createTextVOI(int iX, int iY)
      Creates a new VOIText at the local point. Causes the JDialogAnnotation to open so the user can specify the parameters and content of the text.
      Parameters:
      iX - x position in screen coordinates.
      iY - y position in screen coordinates.
    • createVOI

      private VOIBase createVOI(int iType, boolean bClosed, boolean bFixed, Vector<WildMagic.LibFoundation.Mathematics.Vector3f> kPositions)
      Creates a new VOI Contour based on the input type.
      Parameters:
      iType - the type of contour to create.
      bClosed - when true the contour is closed.
      bFixed - when true the contour is fixed (cannot be changed).
      kPositions - the positions of the contour in screen coordinates.
      Returns:
      the new VOI Contour.
    • createPointVOI

      public void createPointVOI(int[] x, int[] y, int n, int slice)
    • createPolygonVOI

      public void createPolygonVOI(int[] x, int[] y, int n, int slice)
    • createOvalVOI

      public void createOvalVOI(int left, int top, int width, int height, int slice)
    • createVOI

      private void createVOI(MouseEvent mouseEvent)
      Creates a new VOI Contour or adds a new point to the existing VOI Contour.
      Parameters:
      iX - new x position in screen coordinates.
      iY - new y position in screen coordinates.
    • defaultOrientation

      private boolean defaultOrientation()
      Checks the axisOrder and axisFlip data members. If they do not change the volume orientation then the default orientation is true, otherwise the default orientation is false.
      Returns:
      true if this orientation matches the default image orientation, false if it changes the image orientation.
    • drawArrow

      private void drawArrow(VOIText kVOI, Graphics2D g2d, int xCenter, int yCenter, int x, int y, float stroke)
      Draw the VOIText arror on screen.
      Parameters:
      kVOI -
      g2d -
      xCenter -
      yCenter -
      x -
      y -
      stroke -
    • drawGeometricCenter

      private void drawGeometricCenter(VOIBase kVOI, Graphics g)
      Draws the geometric center on screen.
      Parameters:
      kVOI -
      g -
    • drawLength

      private void drawLength(Graphics g, VOIBase kVOI, float[] resols, int[] unitsOfMeasure)
      Draws length of the open contour.
      Parameters:
      g -
      kVOI -
      resols -
      unitsOfMeasure -
    • drawNext

      private void drawNext(int iX, int iY)
      Draws the livewire from the last anchor point to the current mouse position.
      Parameters:
      iX - current mouse x-position in screen coordinates.
      iY - current mouse y-position in screen coordinates.
    • drawNextPolyline

      private void drawNextPolyline(int iX, int iY)
      Draws the open contour from the last anchor point to the current mouse point.
      Parameters:
      iX - current mouse x-position in screen coordinates.
      iY - current mouse y-position in screen coordinates.
    • drawTickMarks

      private void drawTickMarks(VOIBase kVOI, Graphics g, Color color, int[] unitsOfMeasure, int xD, int yD, float[] res)
      Draws the tick marks on the VOILine.
      Parameters:
      kVOI -
      g -
      color -
      unitsOfMeasure -
      xD -
      yD -
      res -
    • drawTickMarks

      private void drawTickMarks(VOIBase kVOI, Graphics g, int[] unitsOfMeasure, int xD, int yD, float[] res)
      Draw the tick marks for the VOIProtractor
      Parameters:
      kVOI -
      g -
      unitsOfMeasure -
      xD -
      yD -
      res -
    • drawVOI

      private void drawVOI(VOIBase kVOI, float[] resols, int[] unitsOfMeasure, Graphics g)
      Draw the VOI Contour (open or closed).
      Parameters:
      kVOI -
      resols -
      unitsOfMeasure -
      g -
    • drawVOILine

      private void drawVOILine(VOIBase kVOI, float[] resols, int[] unitsOfMeasure, Graphics g, int thickness)
      Draw the VOILine.
      Parameters:
      kVOI - input VOILine to draw.
      resols - image resolutions.
      unitsOfMeasure - image units.
      g - Graphics for drawing.
      thickness - line thickness.
    • showLineEndPoints

      private void showLineEndPoints(VOIBase kVOI, Graphics g)
    • drawVOIPoint

      private void drawVOIPoint(VOIPoint kVOI, Graphics g)
      Draw the input VOIPoint.
      Parameters:
      kVOI - VOIPoint to draw.
      g - Graphics object.
    • drawVOIPoint

      private void drawVOIPoint(VOIPoint kVOI, Graphics g, String label)
      Draw the input VOIPoint with the input label.
      Parameters:
      kVOI - input VOIPoint.
      g - Graphics.
      label - point label.
    • drawVOIPolyLineSlice

      private void drawVOIPolyLineSlice(VOIPolyLineSlice kVOI, float[] resols, int[] unitsOfMeasure, Graphics g)
      Draws the input VOIPolyLineSlice. A PolyLineSlice voi is a set of linked points. This function calls drawVOIPoint for each VOIPoint in the PolyLine, which may be defined over multiple slices. When two contiguous points are on the same slice, the are drawn connected by a line with the line lenght displayed in the image resolutions and units.
      Parameters:
      kVOI - input VOIPolyLineSlice
      resols - image resolutions
      unitsOfMeasure - image units
      g - Graphics.
    • drawVOIProtractor

      private void drawVOIProtractor(VOIBase kVOI, float[] resols, int[] unitsOfMeasure, Graphics g)
      Draws the input VOIProtractor. Displays the angle and lengths of the protractor arms.
      Parameters:
      kVOI - input VOIProtractor.
      resols - image resolutions.
      unitsOfMeasure - image units.
      g - Graphics.
    • drawVOIText

      private void drawVOIText(VOIText kVOI, Graphics g)
      Draws the input VOIText.
      Parameters:
      kVOI - input VOIText.
      g - Graphics.
    • fileCoordinatesToPatient

      private WildMagic.LibFoundation.Mathematics.Vector3f fileCoordinatesToPatient(WildMagic.LibFoundation.Mathematics.Vector3f volumePt)
      Converts the input position from file coordinates to the local patient coordinates.
      Parameters:
      volumePt -
      Returns:
    • getBoundingBoxLeftMiddle

      private WildMagic.LibFoundation.Mathematics.Vector3f getBoundingBoxLeftMiddle(VOIBase kVOI)
      Calculates and returns the bounding box middle left-edge point for the input VOI.
      Parameters:
      kVOI - input VOI.
      Returns:
      the bounding box middle left-edge pointsfor the input VOI.
    • getBoundingBoxLowerLeft

      private WildMagic.LibFoundation.Mathematics.Vector3f getBoundingBoxLowerLeft(VOIBase kVOI)
      Calculates and returns the bounding box lower edge left corner for the input VOI.
      Parameters:
      kVOI - input VOI.
      Returns:
      the bounding box lower edge left corner for the input VOI.
    • getBoundingBoxLowerMiddle

      private WildMagic.LibFoundation.Mathematics.Vector3f getBoundingBoxLowerMiddle(VOIBase kVOI)
      Calculates and returns the bounding box lower edge middle point for the input VOI.
      Parameters:
      kVOI - input VOI.
      Returns:
      the bounding box lower edge middle point for the input VOI.
    • getBoundingBoxLowerRight

      private WildMagic.LibFoundation.Mathematics.Vector3f getBoundingBoxLowerRight(VOIBase kVOI)
      Calculates and returns the bounding box lower edge right corner for the input VOI.
      Parameters:
      kVOI - input VOI.
      Returns:
      the bounding box lower edge right corner for the input VOI.
    • getBoundingBoxRightMiddle

      private WildMagic.LibFoundation.Mathematics.Vector3f getBoundingBoxRightMiddle(VOIBase kVOI)
      Calculates and returns the bounding box middle right-edge point for the input VOI.
      Parameters:
      kVOI - input VOI.
      Returns:
      the bounding box middle right-edge pointsfor the input VOI.
    • getBoundingBoxUpperLeft

      private WildMagic.LibFoundation.Mathematics.Vector3f getBoundingBoxUpperLeft(VOIBase kVOI)
      Calculates and returns the bounding box upper edge left corner for the input VOI.
      Parameters:
      kVOI - input VOI.
      Returns:
      the bounding box upper edge left corner for the input VOI.
    • getBoundingBoxUpperMiddle

      private WildMagic.LibFoundation.Mathematics.Vector3f getBoundingBoxUpperMiddle(VOIBase kVOI)
      Calculates and returns the bounding box upper edge middle point for the input VOI.
      Parameters:
      kVOI - input VOI.
      Returns:
      the bounding box upper edge middle point for the input VOI.
    • getBoundingBoxUpperRight

      private WildMagic.LibFoundation.Mathematics.Vector3f getBoundingBoxUpperRight(VOIBase kVOI)
      Calculates and returns the bounding box upper edge right corner for the input VOI.
      Parameters:
      kVOI - input VOI.
      Returns:
      the bounding box upper edge right corner for the input VOI.
    • getCoordsLine

      private void getCoordsLine(float[] linePtsX, float[] linePtsY, double fraction, float[] coords)
      Calculates the screen coordinates for the VOILine tickmarks. The inputs are the endpoints of the VOILine and a fraction distance along that line where the perpendicular tick-mark lines will intersect the VOILine. This function returns the screen coordinates for the tickmark line at that location along the VOILine.
      Parameters:
      linePtsX - input position x-coordinates
      linePtsY - input position y-coordinates
      fraction - fraction along the VOILine for the current tick mark.
      coords - calculated tickmark xy-coordinates
    • getCoordsProtractor

      private void getCoordsProtractor(float[] x, float[] y, double fraction, float[] coords)
      Calculates and returns the screen location for the angle and length display for the VOIProtractor. The function is called with the end points along one of the protractors 'arms' and a fraction of a distance along that arm. It returns the on-screen pixel location for where to draw the annotation, which will be either the lenght of the arm or the angle the two arms make.
      Parameters:
      x - input protractor x-coordinates.
      y - input protractor x-coordinates.
      fraction -
      coords - returned screen coordinates for drawing the protractor annotation.
    • getEndLinesLine

      private void getEndLinesLine(float[] linePtsX, float[] linePtsY, int line, float[] coords)
      Calculates and returns the inverted-arrow coordinates for the VOILine tickmark display. The inputs are the coordinates of the VOILine and the component of the inverted-arrow to calculate. This function returns the coordinates of the inverted-arrow component for drawing on screen.
      Parameters:
      linePtsX -
      linePtsY -
      line -
      coords -
    • getEndLinesProtractor

      private void getEndLinesProtractor(float[] x, float[] y, int line, float[] coords)
      Calculates and returns the arrow-head coordinates for the VOIProtractor tickmark display. The inputs are the coordinates of one of the 'arms' of the VOIProtractor and the component of the arrow-head to calculate. This function returns the coordinates of the arrow-head component for drawing on screen.
      Parameters:
      line -
      coords -
      linePtsX -
      linePtsY -
    • getSlice

      protected int getSlice(VOIBase kVOI)
      Returns the slice of the input VOI in the patient coordinates displayed locally. This function is used to determine if a particular VOI should be drawn in the currently-displayed image slice. If the VOI is a VOIProtractor from the image-align toolbar, the protractor is displayed on all slices so the current slice is returned.
      Parameters:
      kVOI - input VOI.
      Returns:
      the slice that the VOI is on in local patient coordinates.
    • handleIntensityLineBtn3

      private void handleIntensityLineBtn3(MouseEvent mouseEvent)
      Opens the VOIIntensity line drawing popup menu.
      Parameters:
      mouseEvent - the MouseEvent that triggered the popup.
    • initLevelSet

      private void initLevelSet(int iSlice)
      Initializes the Levelset VOI calculation. LevelSet VOI calculations is based on image data, and uses the data from the currently-displayed image slice. This function determines if the levelset data has been initialized for the current slice. If it has, no re-initialization occurs. If the levelset has not yet been calculated for the given slice, or if the levelset has been calculated most recently for a different slice, the levelset data is initialized.
      Parameters:
      iSlice - currently displayed image slice.
    • initLiveWire

      private void initLiveWire(int iSlice, boolean bLiveWire)
      Initializes the Livewire VOI calculation. Livewire VOI calculations is based on image data, and uses the data from the currently-displayed image slice. This function determines if the Livewire data has been initialized for the current slice. If it has, no re-initialization occurs. If the Livewire has not yet been calculated for the given slice, or if the Livewire has been calculated most recently for a different slice, the Livewire data is initialized.
      Parameters:
      iSlice - currently displayed image slice.
      bLiveWire - when true this was triggered by the first livewire for the slice, so the cost calculation is calculated.
    • moveVOIPoint

      private void moveVOIPoint(MouseEvent kEvent)
      Called when the left-mouse is used to drag a point on the VOI.
      Parameters:
      kEvent - current MouseEvent.
    • nearBoundPoint

      protected boolean nearBoundPoint(VOIBase kVOI, int iX, int iY, int iZ)
      Calculates the bounding box of the voi contour and returns true if the input point is near the bounding box.
      Parameters:
      kVOI -
      iX -
      iY -
      iZ -
      Returns:
    • nearLine

      protected boolean nearLine(VOIBase kVOI, int iX, int iY, int iZ)
      Called when the user is selecting a VOI or during MouseDrag to show if a VOI can be selected, or for selected VOIs, to show if the Mouse is close enough to the contour for the user to add a point to the contour line.
      Parameters:
      kVOI - input VOI to test.
      iX - input Mouse x-position.
      iY - input MOuse y-position.
      iZ - current slice.
      Returns:
      true if the mouse is near enough to the input VOI contour for adding a point to the line or showing that the voi can be selected.
    • nearPoint

      protected boolean nearPoint(VOIBase kVOI, int iX, int iY, int iZ)
      Called when the user is selecting a VOI or during MouseDrag to show if a VOI can be selected, or for selected VOIs, to show if the Mouse is close enough to one of the points on the contour for the user to move that contour point
      Parameters:
      kVOI - input VOI to test.
      iX - input Mouse x-position.
      iY - input MOuse y-position.
      iZ - current slice.
      Returns:
      true if the mouse is near a point on the contour of the input VOI.
    • pasteVOI

      private void pasteVOI(int iSlice)
    • paths

      private void paths(int index, 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.
      Parameters:
      index - image location
      i - DOCUMENT ME!
    • patientCoordinatesToFile

      private WildMagic.LibFoundation.Mathematics.Vector3f patientCoordinatesToFile(WildMagic.LibFoundation.Mathematics.Vector3f patientPt)
      Converts the local patient point into file coordinates.
      Parameters:
      patientPt -
      Returns:
    • processLeftMouseDrag

      protected void processLeftMouseDrag(MouseEvent kEvent)
      Parameters:
      kEvent - the mouse event generated by a mouse drag
    • resetIndex

      private void resetIndex()
    • resetStart

      private void resetStart()
      Resets all retrace variables and allows it to start anewA
    • retraceContour

      private void retraceContour(VOIBase kVOIIn, int x1, int y1)
    • scalePolygon

      private Polygon scalePolygon(VOIBase kVOI)
    • scaleVOI

      private void scaleVOI(VOIBase kVOI, MouseEvent mouseEvent)
    • seed

      private void seed(int iX, int iY)
      Sets up directed graph from the seed point. A point (x,y) is mapped to its absolute value in the image, y*xDim + x. This along with its cost is stored in Node. The structure costGraph holds the "edges" of the graph. Each location has an integer associated with it which represents where that node is pointing to. Thus costGraph[7] = 8 would mean the node at 7 (really (0,7)) is pointing to position 8 (really (0,8)). The only possibilities for a location in costGraph are the 8 neighbors surrounding that node. For this reason we might use a byte array instead of an integer array. The seed point points nowhere, to indicate that it's the seed; costGraph[seed.location] = -1. We also need to know if a point has been processed, that is, expanded with the cost set. For this we use a BitSet whose size is the same as the number of pixels in the image. Once a point is processed, its location in the BitSet is set to true.

      The array seededCosts holds the costs so far for a location. If a cost has not been assigned yet, the cost is -2. ActiveList is simply a linked list of Integers; the Integer refers to the location in the seededCosts array. ActiveList is sorted by cost, so that the minimum cost in the ActiveList is the first element of the linked list. Thus finding the minimum is O(1). Finding out if an element is in the ActiveList is also O(1), because for an element to be in the list, it must have already been assigned a cost. Therefore, if seededCosts[location] != -2, it is in the ActiveList. And finding the cost of an item in the ActiveList is O(1), because it's just seededCosts[location], where location is the Integer in the ActiveList. Obviously we're winning speed at the expense of memory, but it's not too much memory in the overall scheme of things.

      The gradient direction component of the cost is added in on the fly. This is because to precalculate would mean an array of 8n, where n is the size of the image. The link from p to q is not the same as the link from q to p. Furthermore, it may never be necessary to calculate some of the links, because the graph would never look at that pair. For more information on how the gradient direction cost is calculated, look at the comments directly above the code.

      Parameters:
      pt - Point to seed with.
    • selectVOI

      protected VOIBase selectVOI(MouseEvent kEvent)
    • setCanvas

      private void setCanvas(Component kComponent)
    • setDrawingContext

      private void setDrawingContext(ScreenCoordinateListener kContext)
    • getDrawingContext

      public ScreenCoordinateListener getDrawingContext()
    • setOrientation

      private void setOrientation(int iOrientation)
    • setPosition

      private void setPosition(VOIBase kVOI, int iPos, float fX, float fY, float fZ)
    • setPosition

      private void setPosition(VOIBase kVOI, int iPos, float fX, float fY, float fZ, boolean isCtrlDown)
    • setPosition

      private void setPosition(VOIBase kVOI, int iPos, WildMagic.LibFoundation.Mathematics.Vector3f kPos)
    • setPosition

      private void setPosition(VOIBase kVOI, int iPos, WildMagic.LibFoundation.Mathematics.Vector3f kPos, boolean isCtrlDown)
    • showSelectedVOI

      protected void showSelectedVOI(MouseEvent kEvent)
    • doLevelset

      public void doLevelset(WildMagic.LibFoundation.Mathematics.Vector3f point)
    • singleLevelSet2

      private VOIBase singleLevelSet2(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
    • split

      private VOIBase split(VOIBase kVOI, WildMagic.LibFoundation.Mathematics.Vector3f kStartPt, WildMagic.LibFoundation.Mathematics.Vector3f kEndPt)
    • splitVOIs

      private void splitVOIs(boolean bAllSlices, boolean bOnlyActive, VOIBase kSplitVOI)
    • straightenLineVOI

      private WildMagic.LibFoundation.Mathematics.Vector3f straightenLineVOI(WildMagic.LibFoundation.Mathematics.Vector3f kPos, VOIBase kOld)
      Modifies kPos to form an angle with its origin point that is a multiple of 15 degrees.
    • updateRectangle

      private void updateRectangle(int iX, int iMouseX, int iY, int iYStart)
    • getDrawVOIflag

      public boolean getDrawVOIflag()