Class SurfacePaint
- java.lang.Object
-
- gov.nih.mipav.view.renderer.J3D.surfaceview.SurfacePaint
-
- All Implemented Interfaces:
java.awt.event.ActionListener,java.awt.event.MouseListener,java.awt.event.MouseMotionListener,java.util.EventListener
public class SurfacePaint extends java.lang.Object implements java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener
-
-
Field Summary
Fields Modifier and Type Field Description private javax.vecmath.Vector3dkPickDirectionPickDirection, the direction of the PickShape.private booleanm_bEnabledEnables paintingprivate JPanelSurfacem_kPanelReference to the JPanelSurface:private com.sun.j3d.utils.picking.PickCanvasm_kPickCanvasPickCanvas, for triangle picking.private intm_PaintModeCurent paint mode.private intmBrushSizecurrent paint brush sizeprivate javax.swing.JTextFieldmBrushSizeTextPaint brush size text fieldprivate javax.swing.ButtonGroupmButtonGroupButton group for paint functions:private javax.swing.JColorChoosermColorChooserColor Chooser dialog.private javax.swing.JButtonmColorPaintButtonColor selection buttonprivate javax.swing.JToggleButtonmDropperButtonPaint dropper buttonprivate javax.swing.JButtonmEraseAllButtonErase all buttonprivate javax.swing.JToggleButtonmEraserButtonEraser paint buttonprivate javax.media.j3d.TransformGroupmMouseRotateRotation transform for transforming the triangle normal into world coordinates.private floatmOpacityCurrent paint opacityprivate javax.swing.JButtonmOpacityPaintButtonOpacity paint buttonprivate javax.swing.JToggleButtonmPaintBrushButtonPaint brush buttonprivate javax.swing.JToggleButtonmPaintCanButtonPaint can buttonprivate javax.vecmath.Color4fmPaintColorCurrent paint colorprivate JDialogPaintGrowmPaintGrowDialogPaint Grow Dialog.private javax.swing.JToolBarmPaintToolBarPaint user-interface ToolBarprivate javax.media.j3d.PickShapemPickShapePickShape, for pickingstatic intTEXTUREPaint into the 3D texture map:static intVERTEXPaint the ModelTriangleMesh vertex color:
-
Constructor Summary
Constructors Constructor Description SurfacePaint(JPanelSurface parent, SurfaceRender parentScene)Default Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactionPerformed(java.awt.event.ActionEvent event)actionPerformed, listens for interface events.voiddispose()Deletes all member variables, clean memory.voidenableSurfacePaint(boolean flag)Enables/disables the Surface per-vertex paint user-interfacevoidenableSurfacePaintCan(boolean flag)Enables/disables the Paint Can user-interfacebooleangetEnabled()Returns true if the user has enabled the paint brush.private voidgetModelColor(javax.vecmath.Point3f kPickPoint)Display the ModelImage color in the JDialogPaintGrow interface.ModelImagegetPaintImage()Returns the ModelImage to paint into.private com.sun.j3d.utils.picking.PickResultgetPickResult(java.awt.event.MouseEvent kMouseEvent)Returns the pick result based on the input mouse event.javax.swing.JToolBargetToolBar()private voidinit()voidmouseClicked(java.awt.event.MouseEvent kMouseEvent)One of the overrides necessary to be a MouseListener.voidmouseDragged(java.awt.event.MouseEvent kMouseEvent)mouseDragged.voidmouseEntered(java.awt.event.MouseEvent kMouseEvent)One of the overrides necessary to be a MouseListener.voidmouseExited(java.awt.event.MouseEvent kMouseEvent)One of the overrides necessary to be a MouseListener.voidmouseMoved(java.awt.event.MouseEvent kMouseEvent)Invoked when the mouse moves.voidmousePressed(java.awt.event.MouseEvent kMouseEvent)One of the overrides necessary to be a MouseListener.voidmouseReleased(java.awt.event.MouseEvent kMouseEvent)One of the overrides necessary to be a MouseListener.voidregionGrow(ModelImage kImage, javax.vecmath.Point3f kSeedPoint)Grows a region based on a starting point supplied.voidsetEnabled(boolean flag)Enables/disables the user-interfacevoidsetOpacity(float opacity)Sets the opacity of the paint.voidsetPaintMode(int mode)Sets the type of paint, either vertex-color or texture value:voidsetPickCanvas(com.sun.j3d.utils.picking.PickCanvas kPickCanvas)Access function to set the pickCanvas.
-
-
-
Field Detail
-
VERTEX
public static final int VERTEX
Paint the ModelTriangleMesh vertex color:- See Also:
- Constant Field Values
-
TEXTURE
public static final int TEXTURE
Paint into the 3D texture map:- See Also:
- Constant Field Values
-
m_PaintMode
private int m_PaintMode
Curent paint mode.
-
m_bEnabled
private boolean m_bEnabled
Enables painting
-
m_kPickCanvas
private com.sun.j3d.utils.picking.PickCanvas m_kPickCanvas
PickCanvas, for triangle picking.
-
mPickShape
private javax.media.j3d.PickShape mPickShape
PickShape, for picking
-
kPickDirection
private javax.vecmath.Vector3d kPickDirection
PickDirection, the direction of the PickShape.
-
m_kPanel
private JPanelSurface m_kPanel
Reference to the JPanelSurface:
-
mPaintToolBar
private javax.swing.JToolBar mPaintToolBar
Paint user-interface ToolBar
-
mButtonGroup
private javax.swing.ButtonGroup mButtonGroup
Button group for paint functions:
-
mPaintBrushButton
private javax.swing.JToggleButton mPaintBrushButton
Paint brush button
-
mDropperButton
private javax.swing.JToggleButton mDropperButton
Paint dropper button
-
mPaintCanButton
private javax.swing.JToggleButton mPaintCanButton
Paint can button
-
mEraserButton
private javax.swing.JToggleButton mEraserButton
Eraser paint button
-
mEraseAllButton
private javax.swing.JButton mEraseAllButton
Erase all button
-
mBrushSizeText
private javax.swing.JTextField mBrushSizeText
Paint brush size text field
-
mBrushSize
private int mBrushSize
current paint brush size
-
mColorPaintButton
private javax.swing.JButton mColorPaintButton
Color selection button
-
mPaintColor
private javax.vecmath.Color4f mPaintColor
Current paint color
-
mOpacityPaintButton
private javax.swing.JButton mOpacityPaintButton
Opacity paint button
-
mOpacity
private float mOpacity
Current paint opacity
-
mColorChooser
private javax.swing.JColorChooser mColorChooser
Color Chooser dialog.
-
mPaintGrowDialog
private JDialogPaintGrow mPaintGrowDialog
Paint Grow Dialog.
-
mMouseRotate
private javax.media.j3d.TransformGroup mMouseRotate
Rotation transform for transforming the triangle normal into world coordinates.
-
-
Constructor Detail
-
SurfacePaint
public SurfacePaint(JPanelSurface parent, SurfaceRender parentScene)
Default Constructor
-
-
Method Detail
-
init
private void init()
-
setEnabled
public void setEnabled(boolean flag)
Enables/disables the user-interface- Parameters:
flag- when true the user-interface is enabled, when false the user-interface is disabled.
-
enableSurfacePaintCan
public void enableSurfacePaintCan(boolean flag)
Enables/disables the Paint Can user-interface- Parameters:
flag- when true Paint Can is enabled, when false the Paint Can is disabled.
-
enableSurfacePaint
public void enableSurfacePaint(boolean flag)
Enables/disables the Surface per-vertex paint user-interface- Parameters:
flag- when true per-vertex paint is enabled, when false the per-vertex paint is disabled is disabled.
-
getEnabled
public boolean getEnabled()
Returns true if the user has enabled the paint brush.- Returns:
- the enabled/disbled status of the paint brush.
-
getPaintImage
public ModelImage getPaintImage()
Returns the ModelImage to paint into.- Returns:
- paint/texture ModelImage
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent event)
actionPerformed, listens for interface events.- Specified by:
actionPerformedin interfacejava.awt.event.ActionListener- Parameters:
event- ActionEvent generated by the interface.
-
getToolBar
public javax.swing.JToolBar getToolBar()
-
setPaintMode
public void setPaintMode(int mode)
Sets the type of paint, either vertex-color or texture value:- Parameters:
mode- SurfacePaint.TEXTURE or SurfacePaint.VERTEX
-
dispose
public void dispose()
Deletes all member variables, clean memory.
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent kMouseEvent)
One of the overrides necessary to be a MouseListener. This function is invoked when a button has been pressed and released.- Specified by:
mouseClickedin interfacejava.awt.event.MouseListener- Parameters:
kMouseEvent- the mouse event generated by a mouse clicked
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent kMouseEvent)
mouseDragged.- Specified by:
mouseDraggedin interfacejava.awt.event.MouseMotionListener- Parameters:
kMouseEvent- MouseEvent
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent kMouseEvent)
One of the overrides necessary to be a MouseListener. Invoked when the mouse enters a component.- Specified by:
mouseEnteredin interfacejava.awt.event.MouseListener- Parameters:
kMouseEvent- the mouse event generated by a mouse entered
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent kMouseEvent)
One of the overrides necessary to be a MouseListener. Invoked when the mouse leaves a component.- Specified by:
mouseExitedin interfacejava.awt.event.MouseListener- Parameters:
kMouseEvent- the mouse event generated by a mouse exit
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent kMouseEvent)
Invoked when the mouse moves.- Specified by:
mouseMovedin interfacejava.awt.event.MouseMotionListener- Parameters:
kMouseEvent- MouseEvent
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent kMouseEvent)
One of the overrides necessary to be a MouseListener. Invoked when a mouse button is pressed.- Specified by:
mousePressedin interfacejava.awt.event.MouseListener- Parameters:
kMouseEvent- the mouse event generated by a mouse press
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent kMouseEvent)
One of the overrides necessary to be a MouseListener. Invoked when a mouse button is released.- Specified by:
mouseReleasedin interfacejava.awt.event.MouseListener- Parameters:
kMouseEvent- the mouse event generated by a mouse release
-
getPickResult
private com.sun.j3d.utils.picking.PickResult getPickResult(java.awt.event.MouseEvent kMouseEvent)
Returns the pick result based on the input mouse event.- Parameters:
kMouseEvent- the current mouse position.- Returns:
- kPickResult, the picked object.
-
setPickCanvas
public void setPickCanvas(com.sun.j3d.utils.picking.PickCanvas kPickCanvas)
Access function to set the pickCanvas.- Parameters:
kPickCanvas- PickCanvas
-
setOpacity
public void setOpacity(float opacity)
Sets the opacity of the paint.- Parameters:
opacity- paint opacity.
-
getModelColor
private void getModelColor(javax.vecmath.Point3f kPickPoint)
Display the ModelImage color in the JDialogPaintGrow interface.- Parameters:
kPickPoint- the model triangle mesh point under the mouse.
-
regionGrow
public void regionGrow(ModelImage kImage, javax.vecmath.Point3f kSeedPoint)
Grows a region based on a starting point supplied. A voxel is added to the the paintMask mask if its intensity is between the the bounds which are also supplied.- Parameters:
kImage- the image to grow the region inkSeedPoint- the starting point in the image
-
-