Class VOIManager

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener
    Direct Known Subclasses:
    VOILatticeManager

    public class VOIManager
    extends java.lang.Object
    implements java.awt.event.ActionListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.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:
    VOIManagerInterface
    • Nested Class Summary

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent event)  
      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 addPopup​(VOIBase kVOI)
      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, java.util.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, java.util.Vector<WildMagic.LibFoundation.Mathematics.Vector3f> kPositions)
      Creates a new VOI Contour based on the input type.
      private void createVOI​(java.awt.event.MouseEvent mouseEvent)
      Creates a new VOI Contour or adds a new point to the existing VOI Contour.
      private boolean defaultOrientation()
      Checks the axisOrder and axisFlip data members.
      void deleteVOI​(VOIBase kVOI)
      Called from ViewJComponentTriImage to delete the VOIProtractor.
      void dispose()
      Cleans up local memory.
      void doLevelset​(WildMagic.LibFoundation.Mathematics.Vector3f point)  
      void doVOI​(java.lang.String kCommand, boolean isDrawCommand)
      Called from VOIManagerInterface.
      void draw​(VOIBase kVOI, float[] resolutions, int[] unitsOfMeasure, int slice, java.awt.Graphics g, boolean bShowAllPoints)
      Draws the input VOI in the ViewJComponentEditImage
      private void drawArrow​(VOIText kVOI, java.awt.Graphics2D g2d, int xCenter, int yCenter, int x, int y, float stroke)
      Draw the VOIText arror on screen.
      private void drawGeometricCenter​(VOIBase kVOI, java.awt.Graphics g)
      Draws the geometric center on screen.
      private void drawLength​(java.awt.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, java.awt.Graphics g, int[] unitsOfMeasure, int xD, int yD, float[] res)
      Draw the tick marks for the VOIProtractor
      private void drawTickMarks​(VOIBase kVOI, java.awt.Graphics g, java.awt.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, java.awt.Graphics g)
      Draw the VOI Contour (open or closed).
      private void drawVOILine​(VOIBase kVOI, float[] resols, int[] unitsOfMeasure, java.awt.Graphics g, int thickness)
      Draw the VOILine.
      private void drawVOIPoint​(VOIPoint kVOI, java.awt.Graphics g)
      Draw the input VOIPoint.
      private void drawVOIPoint​(VOIPoint kVOI, java.awt.Graphics g, java.lang.String label)
      Draw the input VOIPoint with the input label.
      private void drawVOIPolyLineSlice​(VOIPolyLineSlice kVOI, float[] resols, int[] unitsOfMeasure, java.awt.Graphics g)
      Draws the input VOIPolyLineSlice.
      private void drawVOIProtractor​(VOIBase kVOI, float[] resols, int[] unitsOfMeasure, java.awt.Graphics g)
      Draws the input VOIProtractor.
      private void drawVOIText​(VOIText kVOI, java.awt.Graphics g)
      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 getBoundingBoxLeftMiddle​(VOIBase kVOI)
      Calculates and returns the bounding box middle left-edge point for the input VOI.
      private WildMagic.LibFoundation.Mathematics.Vector3f getBoundingBoxLowerLeft​(VOIBase kVOI)
      Calculates and returns the bounding box lower edge left corner for the input VOI.
      private WildMagic.LibFoundation.Mathematics.Vector3f getBoundingBoxLowerMiddle​(VOIBase kVOI)
      Calculates and returns the bounding box lower edge middle point for the input VOI.
      private WildMagic.LibFoundation.Mathematics.Vector3f getBoundingBoxLowerRight​(VOIBase kVOI)
      Calculates and returns the bounding box lower edge right corner for the input VOI.
      private WildMagic.LibFoundation.Mathematics.Vector3f getBoundingBoxRightMiddle​(VOIBase kVOI)
      Calculates and returns the bounding box middle right-edge point for the input VOI.
      private WildMagic.LibFoundation.Mathematics.Vector3f getBoundingBoxUpperLeft​(VOIBase kVOI)
      Calculates and returns the bounding box upper edge left corner for the input VOI.
      private WildMagic.LibFoundation.Mathematics.Vector3f getBoundingBoxUpperMiddle​(VOIBase kVOI)
      Calculates and returns the bounding box upper edge middle point for the input VOI.
      private WildMagic.LibFoundation.Mathematics.Vector3f getBoundingBoxUpperRight​(VOIBase kVOI)
      Calculates and returns the bounding box upper edge right corner for the input VOI.
      java.awt.Component getComponent()
      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.
      ScreenCoordinateListener getDrawingContext()  
      boolean getDrawVOIflag()  
      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.
      ModelImage getImage()  
      ModelImage getLocalImage()
      Returns a ModelImage in the local image space, if a local ModelImage has already been created it is returned.
      VOIManagerInterface getParent()
      Called from ViewJComponentEditImage.
      int getPlane()
      Returns the plane this VOIManager is drawing into.
      protected int getSlice​(VOIBase kVOI)
      Returns the slice of the input VOI in the patient coordinates displayed locally.
      private void handleIntensityLineBtn3​(java.awt.event.MouseEvent mouseEvent)
      Opens the VOIIntensity line drawing popup menu.
      void init​(javax.swing.JFrame kFrame, ModelImage kImageA, ModelImage kImageB, java.awt.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 isActive()
      Returns true if the VOIManager is currently drawing a VOI, or if the defaultPointer button in the VOIManagerInterface is selected.
      void keyPressed​(java.awt.event.KeyEvent e)  
      void keyReleased​(java.awt.event.KeyEvent e)  
      void keyTyped​(java.awt.event.KeyEvent e)  
      void liveWire​(int iSelection)
      Called from VOIManagerInterface.
      void mouseClicked​(java.awt.event.MouseEvent kEvent)  
      void mouseDragged​(java.awt.event.MouseEvent kEvent)  
      void mouseEntered​(java.awt.event.MouseEvent arg0)  
      void mouseExited​(java.awt.event.MouseEvent arg0)  
      void mouseMoved​(java.awt.event.MouseEvent kEvent)  
      void mousePressed​(java.awt.event.MouseEvent kEvent)  
      void mouseReleased​(java.awt.event.MouseEvent kEvent)  
      void move​(VOIBase kVOI, WildMagic.LibFoundation.Mathematics.Vector3f kDiff)
      Moves the input VOI by the input Vector amount.
      private void moveVOIPoint​(java.awt.event.MouseEvent kEvent)
      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 pasteAllVOI​(VOIBase kVOI)
      Called from VOIManagerInterface.
      private void pasteVOI​(int iSlice)  
      void pasteVOI​(VOIBase kVOI)
      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 processLeftMouseDrag​(java.awt.event.MouseEvent kEvent)  
      void propagateVOI​(VOIBase kVOI, int dir)
      Called from VOIManagerInterface.
      private void resetIndex()  
      private void resetStart()
      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 java.awt.Polygon scalePolygon​(VOIBase kVOI)  
      void scaleSquareVOI​(VOIBase kVOI, float scale)  
      private void scaleVOI​(VOIBase kVOI, java.awt.event.MouseEvent mouseEvent)  
      private void seed​(int iX, int iY)
      Sets up directed graph from the seed point.
      protected VOIBase selectVOI​(java.awt.event.MouseEvent kEvent)  
      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​(java.awt.Component kComponent)  
      private void setDrawingContext​(ScreenCoordinateListener kContext)  
      void setImage​(ModelImage image, int iOrientation)  
      void setImageB​(ModelImage imageB)
      Sets a new imageB.
      private void setOrientation​(int iOrientation)  
      void setPopupPt​(ViewJPopupPt kPopupPt)
      Called from VOIManagerInterface.
      void setPopupVOI​(ViewJPopupVOI kPopupVOI)
      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 showLineEndPoints​(VOIBase kVOI, java.awt.Graphics g)  
      protected void showSelectedVOI​(java.awt.event.MouseEvent kEvent)  
      private VOIBase singleLevelSet2​(float startPtX, float startPtY)
      Creates a single level set.
      private void SplineSmooth​(VOIBase voiLine)
      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 Detail

      • GRADIENT_MAG

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

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

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

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

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

        public static final int GRADIENT_ALL
        chooses all the gradient cost functions
        See Also:
        Constant Field Values
      • 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 java.lang.String DELETE_INTENSITY_LINE
        used in the popup menu when the user right-clicks over a voi intensity line.
        See Also:
        Constant Field Values
      • SHOW_INTENSITY_GRAPH

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

        public static final java.lang.String SHOW_LINE_ENDPOINTS
        used in the popup menu when the user right-clicks over a voi intensity line.
        See Also:
        Constant Field Values
      • PI_SEARCH

        private static final double[] PI_SEARCH
        Used for angle searches in line VOI creation
      • PI_MULT

        private static final double[] PI_MULT
      • 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 java.util.BitSet map
        Used to calculate the levelset contour.
      • stack

        private java.util.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_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
      • m_iNearStatus

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

        protected java.awt.Component m_kComponent
        The canvas
      • m_iLiveWireSelection

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

        private byte[] costGraph
      • grad_weight

        private float grad_weight
      • localCosts

        private float[] localCosts
      • processedIndicies

        private java.util.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:
      • 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 Detail

      • 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 Detail

      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent event)
        Specified by:
        actionPerformed in interface java.awt.event.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​(java.lang.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,
                         java.awt.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.
        orientation - image orientation displayed in the ViewJComponentEditImage
        g - Graphics.
      • 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 java.awt.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​(javax.swing.JFrame kFrame,
                         ModelImage kImageA,
                         ModelImage kImageB,
                         java.awt.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​(java.awt.event.KeyEvent e)
        Specified by:
        keyPressed in interface java.awt.event.KeyListener
      • keyReleased

        public void keyReleased​(java.awt.event.KeyEvent e)
        Specified by:
        keyReleased in interface java.awt.event.KeyListener
      • keyTyped

        public void keyTyped​(java.awt.event.KeyEvent e)
        Specified by:
        keyTyped in interface java.awt.event.KeyListener
      • liveWire

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

        public void mouseClicked​(java.awt.event.MouseEvent kEvent)
        Specified by:
        mouseClicked in interface java.awt.event.MouseListener
      • mouseDragged

        public void mouseDragged​(java.awt.event.MouseEvent kEvent)
        Specified by:
        mouseDragged in interface java.awt.event.MouseMotionListener
      • mouseEntered

        public void mouseEntered​(java.awt.event.MouseEvent arg0)
        Specified by:
        mouseEntered in interface java.awt.event.MouseListener
      • mouseExited

        public void mouseExited​(java.awt.event.MouseEvent arg0)
        Specified by:
        mouseExited in interface java.awt.event.MouseListener
      • mouseMoved

        public void mouseMoved​(java.awt.event.MouseEvent kEvent)
        Specified by:
        mouseMoved in interface java.awt.event.MouseMotionListener
      • mousePressed

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

        public void mouseReleased​(java.awt.event.MouseEvent kEvent)
        Specified by:
        mouseReleased in interface java.awt.event.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,
                                  java.util.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,
                                  java.util.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​(java.awt.event.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,
                               java.awt.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,
                                         java.awt.Graphics g)
        Draws the geometric center on screen.
        Parameters:
        kVOI -
        g -
      • drawLength

        private void drawLength​(java.awt.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,
                                   java.awt.Graphics g,
                                   java.awt.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,
                                   java.awt.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,
                             java.awt.Graphics g)
        Draw the VOI Contour (open or closed).
        Parameters:
        kVOI -
        resols -
        unitsOfMeasure -
        g -
      • drawVOILine

        private void drawVOILine​(VOIBase kVOI,
                                 float[] resols,
                                 int[] unitsOfMeasure,
                                 java.awt.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,
                                       java.awt.Graphics g)
      • drawVOIPoint

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

        private void drawVOIPoint​(VOIPoint kVOI,
                                  java.awt.Graphics g,
                                  java.lang.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,
                                          java.awt.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,
                                       java.awt.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,
                                 java.awt.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:
        linePtsX -
        linePtsY -
        line -
        coords -
      • 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​(java.awt.event.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​(java.awt.event.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​(java.awt.event.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 java.awt.Polygon scalePolygon​(VOIBase kVOI)
      • scaleVOI

        private void scaleVOI​(VOIBase kVOI,
                              java.awt.event.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​(java.awt.event.MouseEvent kEvent)
      • setCanvas

        private void setCanvas​(java.awt.Component kComponent)
      • 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​(java.awt.event.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()