visualize
Class VisCanvas

java.lang.Object
  extended by visualize.VisCanvas
All Implemented Interfaces:
java.util.EventListener, javax.media.opengl.GLEventListener

public class VisCanvas
extends java.lang.Object
implements javax.media.opengl.GLEventListener

The Class VisCanvas is used for the Open-GL drawing. It defines the viewing properties and reacts on user-changes to viewing properties. Also slicing is done here directly and the functions for raycasting (in the RayCasting class) are called here.

Version:
1.37
Author:
Markus Diem

Field Summary
static int ACCUMULATE
           
static int canvasHeight
           
static int canvasPOTHeight
           
static int canvasPOTWidth
           
static int canvasWidth
           
static float EYE_X_INIT
           
static float EYE_Y_INIT
           
static float EYE_Z_INIT
           
static int GRADIENT_TEX
           
static int MIP
           
static float ROTATE_X_INIT
           
static float ROTATE_Y_INIT
           
static float ROTATE_Z_INIT
           
static int SLICING
           
static int VOLUME_TEX
           
static int X_DIR
           
static int Y_DIR
           
static int Z_DIR
           
 
Constructor Summary
VisCanvas()
          Creates a new VisCanvas - object.
 
Method Summary
 void changeDirection(int direction)
          Sets the viewing direction.
 void display(javax.media.opengl.GLAutoDrawable drawable)
          Main Open-GL-loop.
 void displayChanged(javax.media.opengl.GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)
          Empty function.
 void flushCamera()
          Resets the viewing properties to the initial values.
 Volume getVolume()
          Returns the Volume binded to the VisCanvas
 void init(javax.media.opengl.GLAutoDrawable drawable)
          Inits basic Open-GL-settings.
 void reshape(javax.media.opengl.GLAutoDrawable drawable, int x, int y, int width, int height)
          Called when the size of the VisCanvas changes and adapts the size of the rendered content corresponding to the new VisCanvas-size.
 void rotateObject(int x, int y)
          Rotates the cameraposition.
 void saveImage(java.lang.String fileName)
          Saves the current rendered Open-GL-drawing to a PNG-File.
 void setPlanarView(boolean planarView)
          Called when the user switches between planarView and not planarView.
 void setRendering(int rendering)
          Called when the user switches between slicing and raycasting.
static void setSliceShader(int sp)
          Defines the shader-program that is used for rendering the slices.
 void setTexCoord(int coord)
          Set the x coordinate.
static void setTransTex(int[] tt)
          Sets a texture containing opacity values described the transfer-function.
 void setVolume(Volume volume)
          Binds a Volume to the VisCanvas
 void translateObject(int x, int y)
          Translates the cameraposition.
 void zoomObject(int direction)
          Moves the cameraposition in the specified direction.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

X_DIR

public static final int X_DIR
See Also:
Constant Field Values

Y_DIR

public static final int Y_DIR
See Also:
Constant Field Values

Z_DIR

public static final int Z_DIR
See Also:
Constant Field Values

SLICING

public static final int SLICING
See Also:
Constant Field Values

MIP

public static final int MIP
See Also:
Constant Field Values

ACCUMULATE

public static final int ACCUMULATE
See Also:
Constant Field Values

EYE_X_INIT

public static final float EYE_X_INIT
See Also:
Constant Field Values

EYE_Y_INIT

public static final float EYE_Y_INIT
See Also:
Constant Field Values

EYE_Z_INIT

public static final float EYE_Z_INIT
See Also:
Constant Field Values

ROTATE_X_INIT

public static final float ROTATE_X_INIT
See Also:
Constant Field Values

ROTATE_Y_INIT

public static final float ROTATE_Y_INIT
See Also:
Constant Field Values

ROTATE_Z_INIT

public static final float ROTATE_Z_INIT
See Also:
Constant Field Values

VOLUME_TEX

public static final int VOLUME_TEX
See Also:
Constant Field Values

GRADIENT_TEX

public static final int GRADIENT_TEX
See Also:
Constant Field Values

canvasPOTWidth

public static int canvasPOTWidth

canvasPOTHeight

public static int canvasPOTHeight

canvasWidth

public static int canvasWidth

canvasHeight

public static int canvasHeight
Constructor Detail

VisCanvas

public VisCanvas()
Creates a new VisCanvas - object. Here the initial values of the volume-texture and the values of the camera are set.

Method Detail

setVolume

public void setVolume(Volume volume)
Binds a Volume to the VisCanvas

Parameters:
volume - Volume object that should be binded.

getVolume

public Volume getVolume()
Returns the Volume binded to the VisCanvas

Returns:
volume in Volume-form.

setTexCoord

public void setTexCoord(int coord)
Set the x coordinate.

Parameters:
xCoord - integer between 0 and 100.

setRendering

public void setRendering(int rendering)
Called when the user switches between slicing and raycasting.

Parameters:
rendering - integer describing the rendering-type.

saveImage

public void saveImage(java.lang.String fileName)
Saves the current rendered Open-GL-drawing to a PNG-File.

Parameters:
fileName - filename of the PNG-File.

flushCamera

public void flushCamera()
Resets the viewing properties to the initial values.


changeDirection

public void changeDirection(int direction)
Sets the viewing direction.

Parameters:
direction - direction in integer form. (Possible directions: x-, y- and z-direction).

display

public void display(javax.media.opengl.GLAutoDrawable drawable)
Main Open-GL-loop. Renders continuously the scene to screen. If slicing is activated it's done here directly, otherwise if raycasting is activated the render-function of RayCasting is called.

Specified by:
display in interface javax.media.opengl.GLEventListener

displayChanged

public void displayChanged(javax.media.opengl.GLAutoDrawable drawable,
                           boolean modeChanged,
                           boolean deviceChanged)
Empty function. Just added for inheritance.

Specified by:
displayChanged in interface javax.media.opengl.GLEventListener

init

public void init(javax.media.opengl.GLAutoDrawable drawable)
Inits basic Open-GL-settings. The gl variable which provides a basic interface to OpenGL is initialized here. This variable is very important and used by different functions which get the gl variable as an input parameter.

Specified by:
init in interface javax.media.opengl.GLEventListener

zoomObject

public void zoomObject(int direction)
Moves the cameraposition in the specified direction.

Parameters:
direction - direction in integer-form

translateObject

public void translateObject(int x,
                            int y)
Translates the cameraposition.

Parameters:
x - the translation-value in x-direction (in integer form).
y - the translation-value in y-direction (in integer form).

rotateObject

public void rotateObject(int x,
                         int y)
Rotates the cameraposition.

Parameters:
x - the rotation-value in x-direction (in integer form).
y - the rotation-value in y-direction (in integer form).

reshape

public void reshape(javax.media.opengl.GLAutoDrawable drawable,
                    int x,
                    int y,
                    int width,
                    int height)
Called when the size of the VisCanvas changes and adapts the size of the rendered content corresponding to the new VisCanvas-size.

Specified by:
reshape in interface javax.media.opengl.GLEventListener

setPlanarView

public void setPlanarView(boolean planarView)
Called when the user switches between planarView and not planarView. The term planarView desribes, that the shown slicing-slice should be plotted in a plane that is parallel to the screen.

Parameters:
planarView - boolean if this parameter is true the slice will be parallel to the screen.

setSliceShader

public static void setSliceShader(int sp)
Defines the shader-program that is used for rendering the slices.

Parameters:
sp - integer that identifies the shader-programe

setTransTex

public static void setTransTex(int[] tt)
Sets a texture containing opacity values described the transfer-function.

Parameters:
tt - opacity values in integer-form.