cz.cuni.jagrlib.testing
Class InteractiveProjection

java.lang.Object
  extended by cz.cuni.jagrlib.DefaultProperty
      extended by cz.cuni.jagrlib.Piece
          extended by cz.cuni.jagrlib.DefaultInputListener
              extended by cz.cuni.jagrlib.testing.InteractiveProjection
All Implemented Interfaces:
Breakable, InputListener, Property, Template

public class InteractiveProjection
extends DefaultInputListener

Computes 3D-to-2D transformation matrix from interactive mouse/keyboard events.

Since:
0.24
See Also:
InteractiveProjection.java

Field Summary
protected  double azimuth
          View reference point azimuth (0.0 .. yz plane).
protected static java.lang.String CATEGORY
          Object category.
protected  double[] center
          Point I'm always looking at..
protected  double elevation
          View reference point elevation angle (positive .. positive z-coordinate).
protected  double[] eye
          Actual eye's position (aka VRP).
static double EYE_DISTANCE
          Standard eye-center distance.
protected  boolean first
          Called for the first time?
protected  int height
          Actual window height in pixels.
protected  boolean live
          Mouse-move processing is switched on?
static java.lang.String MATRIX
           
protected  TrMatrix modelView
          Actual model-view transform.
protected  TrMatrix proj
          Actual projection matrix.
static RegPiece reg
          Static registration instance for this class.
protected  Render3D render
          Accelerator: rendering object.
protected static java.lang.String TEMPLATE_NAME
          Object template identifier.
protected  double[] transl
          Actual translation component.
protected  Trigger trigger1
          Accelerator: notification object #1.
protected  Trigger trigger2
          Accelerator: notification object #2.
static double WHEEL_ZOOM
          Zoom coefficient for one mouse-wheel "tick" minus 1.0.
protected  double wheelZoom
          Zoom factor produces by the mouse-wheel.
protected  int width
          Actual window width in pixels.
protected  double zoom
          Actual result zoom factor.
 
Fields inherited from class cz.cuni.jagrlib.Piece
channels, info, pl, plugs, TEMPLATE_TYPE, userBreak
 
Fields inherited from interface cz.cuni.jagrlib.iface.InputListener
BUTTON1, BUTTON2, BUTTON3
 
Fields inherited from interface cz.cuni.jagrlib.Template
ALL_PLUGS, C_1D, C_2D, C_3D, C_ALPHA, C_BINARY, C_BREP, C_CAMERA, C_CIRCLE, C_CLIP, C_COMPRESSION, C_CURVE, C_DATA, C_DRAW, C_EDITOR, C_ELLIPSE, C_FILL, C_FILTER, C_FLOAT, C_FUNCTION, C_IMAGE, C_INTEGER, C_IO, C_LIGHT, C_LINE, C_METRIC, C_POLYGON, C_PROJECTION, C_RADIOSITY, C_RASTER, C_RENDER, C_SAMPLE, C_SCENE, C_SET, C_SOLID, C_TEXT, C_TRANSFORM, C_VECTOR, C_VIEWER, C_WORKER, CAT_EMPTY, EMPTY, IFACE, JAGRLIB, JAGRLIB2, MANIPULATOR_COMBO, MANIPULATOR_CUSTOM, MANIPULATOR_DEFAULT, MANIPULATOR_MULTILINE, PL_ALPHAMASK, PL_BITMASK, PL_CAUSTIC, PL_CODEC, PL_COLORMAP, PL_COMPARE, PL_DATA, PL_DIRECT, PL_EDITOR, PL_FILTER, PL_FUNCTION, PL_IMAGE, PL_IMPORT, PL_INPUT, PL_INTERSECTION, PL_LIGHTSOURCE, PL_ORDER, PL_OUTPUT, PL_PALETTE, PL_PHOTON, PL_PROPERTY, PL_QUANTIZER, PL_RASTER, PL_RENDER, PL_SHADOW, PL_STREAM, PL_TRANSFORM, PL_TRIGGER, PL_VOLUME, PL_WINDOW, TYPE_BOOLEAN, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INTEGER, TYPE_LONG, TYPE_OBJECT, TYPE_STRING
 
Fields inherited from interface cz.cuni.jagrlib.iface.Property
LOGGING, STATISTICS, TEXT_DESCRIPTION
 
Constructor Summary
InteractiveProjection()
           
 
Method Summary
 java.lang.Object get(java.lang.String key)
          Gets the given property.
 void mouseButton(java.lang.Object sender, long when, int x, int y, int button, boolean press, int flags)
          Mouse button was pressed/released.
 void mouseMove(java.lang.Object sender, long when, int x, int y, int flags)
          Mouse pointer was moved.
 void mouseWheel(java.lang.Object sender, long when, int x, int y, int wheel, int amount, int flags)
          Mouse wheel was rotated.
 void set(java.lang.String key, java.lang.Object value)
          Sets the given property.
static int setTemplate(Template t, int ord)
          General-purpose registration routine.
 void setWindowSize(java.lang.Object sender, int width, int height)
          Change the window shape.
protected  void updateMatrix()
          Assembles the projection matrix and triggers the "redraw" action.
 
Methods inherited from class cz.cuni.jagrlib.DefaultInputListener
keyboard, mouseHover, windowClose
 
Methods inherited from class cz.cuni.jagrlib.Piece
className, connect, findPlug, findPlug, getInfo, getInterface, getInterface, getPlug, getReg, init, isCompatible, isCompatible, isConnected, logError, logWarning, myInterface, newInputPlug, newOptOutputPlug, newOutputPlug, newPlug, noTemplates, propBegin, propBounds, propDefault, propEnd, propEnum, propManipulator, propManipulator, setProgressListener, setRegStrings, setTemplateDynamic, stop
 
Methods inherited from class cz.cuni.jagrlib.DefaultProperty
booleanProperty, booleanProperty, colorDoubleProperty, colorProperty, commit, doubleProperty, doubleProperty, doubleProperty, enumProperty, floatProperty, floatProperty, floatProperty, intProperty, intProperty, intProperty, longProperty, longProperty, longProperty, set, stringProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WHEEL_ZOOM

public static final double WHEEL_ZOOM
Zoom coefficient for one mouse-wheel "tick" minus 1.0.

See Also:
Constant Field Values

EYE_DISTANCE

public static final double EYE_DISTANCE
Standard eye-center distance.

See Also:
Constant Field Values

width

protected int width
Actual window width in pixels.


height

protected int height
Actual window height in pixels.


modelView

protected TrMatrix modelView
Actual model-view transform.


proj

protected TrMatrix proj
Actual projection matrix.


azimuth

protected double azimuth
View reference point azimuth (0.0 .. yz plane).


elevation

protected double elevation
View reference point elevation angle (positive .. positive z-coordinate).


zoom

protected double zoom
Actual result zoom factor.


wheelZoom

protected double wheelZoom
Zoom factor produces by the mouse-wheel.


live

protected boolean live
Mouse-move processing is switched on?


transl

protected double[] transl
Actual translation component.


first

protected boolean first
Called for the first time?


trigger1

protected Trigger trigger1
Accelerator: notification object #1.


trigger2

protected Trigger trigger2
Accelerator: notification object #2.


render

protected Render3D render
Accelerator: rendering object.


center

protected double[] center
Point I'm always looking at..


eye

protected double[] eye
Actual eye's position (aka VRP).


MATRIX

public static final java.lang.String MATRIX
See Also:
Constant Field Values

TEMPLATE_NAME

protected static final java.lang.String TEMPLATE_NAME
Object template identifier.

See Also:
Constant Field Values

CATEGORY

protected static final java.lang.String CATEGORY
Object category.

See Also:
Constant Field Values

reg

public static final RegPiece reg
Static registration instance for this class. Automatically initialized in class-loading time.

Constructor Detail

InteractiveProjection

public InteractiveProjection()
Method Detail

updateMatrix

protected void updateMatrix()
Assembles the projection matrix and triggers the "redraw" action.


setWindowSize

public void setWindowSize(java.lang.Object sender,
                          int width,
                          int height)
Change the window shape.

Specified by:
setWindowSize in interface InputListener
Overrides:
setWindowSize in class DefaultInputListener
Parameters:
width - Horizontal window size in pixels.
height - Vertical window size in pixels.
sender - Originator of the event

mouseButton

public void mouseButton(java.lang.Object sender,
                        long when,
                        int x,
                        int y,
                        int button,
                        boolean press,
                        int flags)
Mouse button was pressed/released.

Specified by:
mouseButton in interface InputListener
Overrides:
mouseButton in class DefaultInputListener
Parameters:
when - System time in milliseconds.
x - Horizontal screen position in pixels.
y - Vertical screen position in pixels.
button - Button number (InputListener.BUTTON1, etc.).
press - Was it press or release?
flags - Input system status (key shifts/alts, ..).
sender - Originator of the event

mouseMove

public void mouseMove(java.lang.Object sender,
                      long when,
                      int x,
                      int y,
                      int flags)
Mouse pointer was moved.

Specified by:
mouseMove in interface InputListener
Overrides:
mouseMove in class DefaultInputListener
Parameters:
sender - Originator of the event
when - System time in milliseconds.
x - Horizontal screen position in pixels.
y - Vertical screen position in pixels.
flags - Input system status (key shifts/alts, ..).

mouseWheel

public void mouseWheel(java.lang.Object sender,
                       long when,
                       int x,
                       int y,
                       int wheel,
                       int amount,
                       int flags)
Mouse wheel was rotated.

Specified by:
mouseWheel in interface InputListener
Overrides:
mouseWheel in class DefaultInputListener
Parameters:
sender - Originator of the event
when - System time in milliseconds.
x - Horizontal screen position in pixels.
y - Vertical screen position in pixels.
wheel - Wheel number (InputListener.BUTTON1, etc.).
amount - Rotation angle (positive number means down - or towards the user).
flags - Input system status (key shifts/alts, ..).

set

public void set(java.lang.String key,
                java.lang.Object value)
Sets the given property.

Specified by:
set in interface Property
Overrides:
set in class DefaultProperty
Parameters:
key - Key string.
value - The new value.
See Also:
Property.commit()

get

public java.lang.Object get(java.lang.String key)
Gets the given property.

Specified by:
get in interface Property
Overrides:
get in class DefaultProperty
Parameters:
key - Key string.
Returns:
The actual value or null>.

setTemplate

public static int setTemplate(Template t,
                              int ord)
General-purpose registration routine. Sets all plugs, strings, etc. to the given Template.