Next: Clearing Up and Closing Down
Up: Transforming 2-Dimensional Coordinate Data
Previous: Transforming 2-Dimensional Coordinate Data
The following shows TRN_TR2R being used to transform 2-dimensional
coordinate data obtained by reading a cursor.
It is assumed that the identifier ID is associated with a compiled
{
} mapping which has been established to convert
cursor coordinates into ``user'' coordinates:
* Declare variables.
INTEGER STATUS, N, ID
REAL XCUR( 1 ), YCUR( 1 ), XUSER( 1 ), YUSER( 1 )
* Set up cursor choice device.
CALL SGS_SELCH( 0 )
CALL SGS_DEFCH( '.' )
* Loop to read cursor positions.
DO WHILE ( STATUS .EQ. SAI__OK )
CALL SGS_REQCU( XCUR( 1 ), YCUR( 1 ), N ) [1]
IF( N .NE. 0 ) GO TO 1
* Transform the cursor coordinates.
CALL TRN_TR2R( .FALSE., 1, XCUR, YCUR, ID, [2]
: XUSER, YUSER, STATUS )
* Display the position in user coordinates.
CALL MSG_SETR( 'X', XUSER( 1 ) )
CALL MSG_SETR( 'Y', YUSER( 1 ) )
CALL MSG_OUT( ' ', 'X = ^X ; Y = ^Y', STATUS ) [3]
ENDDO
1 CONTINUE
Programming notes:
- The SGS cursor position is read repeatedly until the user
terminates interaction (by pressing the keyboard `.' key in this case).
- TRN_TR2R is used to transform each cursor position in turn
into ``user'' coordinates.
Only a single data point is transformed here, but in a non-interactive
application it would be more efficient to transform a whole set of data
points in a single call to this routine.
- The transformed positions are displayed in ``user'' coordinates.
Next: Clearing Up and Closing Down
Up: Transforming 2-Dimensional Coordinate Data
Previous: Transforming 2-Dimensional Coordinate Data
TRANSFORM Coordinate Transformation Facility
Starlink User Note 61
R.F. Warren-Smith
12th January 2006
E-mail:ussc@star.rl.ac.uk
Copyright © 2000 Council for the Central Laboratory of the Research Councils