CW_ARCBALL

The CW_ARCBALL function creates a compound widget for intuitively specifying three-dimensional orientations.

The user drags a simulated track-ball with the mouse to interactively obtain arbitrary rotations. Sequences of rotations may be cascaded. The rotations may be unconstrained (about any axis), constrained to the view X, Y, or Z axes, or constrained to the object's X, Y, or Z axis.

This widget is based on "ARCBALL: A User Interface for Specifying Three-Dimensional Orientation Using a Mouse," by Ken Shoemake, Computer Graphics Laboratory, University of Pennsylvania, Philadelphia, PA 19104.

This widget can generate any rotation about any axis. Note, however, that not all rotations are compatible with the IDL SURFACE procedure, which is restricted to rotations that project the object Z axis parallel to the view Y axis.

The returned value of this function is the widget ID of the newly-created ARCBALL widget.

This routine is written in the IDL language. Its source code can be found in the file cw_arcball.pro in the lib subdirectory of the IDL distribution.

Using CW_ARCBALL

Use the command:

WIDGET_CONTROL, id, GET_VALUE = matrix

to return the current 3x3 rotation matrix in the variable matrix .

You can set the arcball to new rotation matrix using the command:

WIDGET_CONTROL, id, SET_VALUE = matrix

after the widget is initially realized.

Calling Sequence

Result = CW_ARCBALL( Parent )

Arguments

Parent

The widget ID of the parent widget.

Keywords

COLORS

A 6-element array containing the color indices to be used.

The default value is [1,7,2,3,7,0] , which yields good colors with the TEK_COLOR table: (white, yellow, red, green, yellow, black).

FRAME

Set this keyword to draw a frame around the widget.

LABEL

Set this keyword to a string containing the widget's label.

RETAIN

Set this keyword to zero, one, or two to specify how backing store should be handled for the draw widget. RETAIN=0 specifies no backing store. RETAIN=1 requests that the server or window system provide backing store. RETAIN=2 specifies that IDL provide backing store directly. See Backing Store for details.

SIZE

The size of the square drawable area containing the arcball, in pixels. The default is 192.

UPDATE

Set this keyword to cause the widget will send an event each time the mouse button is released after a drag operation. By default, events are only sent when the "Update" button is pressed.

UVALUE

The "user value" to be assigned to the widget.

VALUE

Set this keyword to a 3 x 3 array that will be the initial value for the rotation matrix. VALUE must be a valid rotation matrix (no translation or perspective) where TRANSPOSE(VALUE) = INVERSE(VALUE). This can be the upper-left corner of !P.T after executing the command

T3D, /RESET, ROTATE = [x,y,z].

The default is the identity matrix.

Keywords to WIDGET_CONTROL and WIDGET_INFO

The widget ID returned by most compound widgets is actually the ID of the compound widget's base widget. This means that many keywords to the WIDGET_CONTROL and WIDGET_INFO routines that affect or return information on base widgets can be used with compound widgets.

In addition, you can use the GET_VALUE and SET_VALUE keywords to WIDGET_CONTROL to obtain or set the 3 x 3 rotation matrix in the arcball widget.

See Compound Widgets for a more complete discussion of controlling compound widgets using WIDGET_CONTROL and WIDGET_INFO .

Widget Events Returned by the CW_ARCBALL Widget

Arcball widgets generate event structures with the following definition:

event = {ID:0L, TOP:0L, HANDLER:0L, VALUE:fltarr(3,3) }

The VALUE field contains the 3 x 3 array representing the new rotation matrix.

Example

See the procedure ARCBALL_TEST , contained in the cw_arcball.pro file. To test CW_ARCBALL, enter the following commands:

.RUN cw_arcball

ARCBALL_TEST

See Also

CREATE_VIEW , SCALE3 , T3D