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.
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.
Examples
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
This results in the following:
Syntax
Result = CW_ARCBALL( Parent [, COLORS=array] [, /FRAME] [, LABEL=string] [, RETAIN={0 | 1 | 2}] [, SIZE=pixels] [, TAB_MODE=value] [, /UPDATE] [, UNAME=string] [, UVALUE=value] [, VALUE=array] )
Return Value
This function returns the widget ID of the newly-created ARCBALL widget.
Arguments
Parent
The widget ID of the parent widget.
Keywords
COLORS
A 6-element array containing the color indices to be used:
Value |
Description |
0 |
Disable navigation onto or off of the widget. This is the default. Child widgets automatically inherit the tab mode of the parent base as described in Inheriting the TAB_MODE Value.
|
1 |
Enable navigation onto and off of the widget.
|
2 |
Navigate only onto the widget.
|
3 |
Navigate only off of the widget.
|
Note: In widget applications on the UNIX platform, the Motif library controls what widgets are brought into and released from focus using tabbing. The TAB_MODE keyword value is always zero, and any attempt to change it is ignored when running a widget application on the UNIX platform. Tabbing behavior may vary significantly between UNIX platforms; do not rely on a particular behavior being duplicated on all UNIX systems.
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.
UNAME
Set this keyword to a string that can be used to identify the widget in your code. You can associate a name with each widget in a specific hierarchy, and then use that name to query the widget hierarchy and get the correct widget ID.
To query the widget hierarchy, use the WIDGET_INFO function with the FIND_BY_UNAME keyword. The UNAME should be unique to the widget hierarchy because the FIND_BY_UNAME keyword returns the ID of the first widget with the specified name.
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 Creating a Compound Widget 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.
Version History
Pre 4.0 |
Introduced |
6.1 |
Added TAB_MODE keyword
|
See Also
CROSSP