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.
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:
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).
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.
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.
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
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 .
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.
See the procedure
ARCBALL_TEST
, contained in the
cw_arcball.pro
file. To test CW_ARCBALL, enter the following commands:
CREATE_VIEW , SCALE3 , T3D