Mercurial > hg > minc-tools
changeset 45:a9d27a511517
*** empty log message ***
author | david <david> |
---|---|
date | Thu, 10 Dec 1992 14:58:42 +0000 |
parents | e584bb49a591 |
children | 9b28acf45ca2 |
files | volume_io/Testing/test_graphics.c |
diffstat | 1 files changed, 38 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/volume_io/Testing/test_graphics.c +++ b/volume_io/Testing/test_graphics.c @@ -31,12 +31,13 @@ int current_mouse_x, current_mouse_y; int x_position, y_position, x_size, y_size; int x_pixel, y_pixel; + Boolean in_rotation_mode; + int prev_rotation_mouse_x; + Real angle_in_radians; int i, j, pixels_x_size, pixels_y_size; int pixels_x_position, pixels_y_position; Real x, y; - Transform modeling_transform; - Transform rotate_clockwise_transform; - Transform rotate_counter_clockwise_transform; + Transform modeling_transform, rotation_transform; void make_identity_transform(); void make_rotation_transform(); void concat_transforms(); @@ -144,24 +145,19 @@ /* ------------ do main loop ------------- */ /* --------------------------------------- */ + current_mouse_x = 0; + current_mouse_y = 0; + make_identity_transform( &modeling_transform ); - make_rotation_transform( 5.0 * DEG_TO_RAD, Y, &rotate_clockwise_transform ); - make_rotation_transform( -5.0 * DEG_TO_RAD, Y, - &rotate_counter_clockwise_transform ); + update_required = TRUE; - fill_Point( centre_of_rotation, 0.5, 0.5, 0.0 ); - make_transform_relative_to_point( ¢re_of_rotation, - &rotate_clockwise_transform, - &rotate_clockwise_transform ); - make_transform_relative_to_point( ¢re_of_rotation, - &rotate_counter_clockwise_transform, - &rotate_counter_clockwise_transform ); + in_rotation_mode = FALSE; - update_required = TRUE; + (void) printf( "Hold down left button and move mouse to rotate\n" ); + (void) printf( "Hit middle mouse button to exit\n" ); + done = FALSE; - (void) printf( "Hit middle mouse button to exit\n" ); - do { do @@ -178,20 +174,16 @@ break; case LEFT_MOUSE_DOWN_EVENT: - concat_transforms( &modeling_transform, &modeling_transform, - &rotate_clockwise_transform ); - G_set_modeling_transform( window, &modeling_transform ); - update_required = TRUE; + prev_rotation_mouse_x = current_mouse_x; + in_rotation_mode = TRUE; break; case LEFT_MOUSE_UP_EVENT: + in_rotation_mode = FALSE; + update_required = TRUE; break; case RIGHT_MOUSE_DOWN_EVENT: - concat_transforms( &modeling_transform, &modeling_transform, - &rotate_counter_clockwise_transform ); - G_set_modeling_transform( window, &modeling_transform ); - update_required = TRUE; break; case RIGHT_MOUSE_UP_EVENT: @@ -231,6 +223,28 @@ } /* break to do update when no events */ while( event_type != NO_EVENT ); + /* check if in rotation mode and moved mouse horizontally */ + + if( in_rotation_mode && current_mouse_x != prev_rotation_mouse_x ) + { + angle_in_radians = (prev_rotation_mouse_x - current_mouse_x); + + make_rotation_transform( angle_in_radians * DEG_TO_RAD, Y, + &rotation_transform ); + + fill_Point( centre_of_rotation, 0.5, 0.5, 0.0 ); + make_transform_relative_to_point( ¢re_of_rotation, + &rotation_transform, + &rotation_transform ); + concat_transforms( &modeling_transform, &modeling_transform, + &rotation_transform ); + G_set_modeling_transform( window, &modeling_transform ); + + prev_rotation_mouse_x = current_mouse_x; + + update_required = TRUE; + } + /* if one or more events caused an update, redraw the screen */ if( update_required )