subroutine event_display_handle_mouse_event( . in_button, mouse_button) c c ********************************************************************** c c figure out what to do in response to a mouse click. c c George Gollin, CPPM (Marseille) and univerisyt of Illinois (Urbana-Champaign) c g-gollin@uiuc.edu, 1999 c c ********************************************************************** c c include files holding common blocks and parameter statements go here: c note that they're in the same directory as this file. c #include "event_display.inc" c c ********************************************************************** c c non-common type definitions and array definitions go here: c c first time this routine is called: logical first_time, debug c character*100 text c c ********************************************************************** c c data statements go here: c c first time we're entering the routine: data first_time /.true./ c c initially we aren't zoomed in, or in the process of generating a zoom: data iamzooming_x, iamzooming_y, iamzooming /3 * .false. / data x_has_been_zoomed, y_has_been_zoomed /2 * .false. / c data iprevious_click_in_x_window /.false./ data iprevious_click_in_y_window /.false./ c c turn on/off debug outputs: data debug /.false./ c c ********************************************************************** c c c initialize stuff: i_want_new_event=.false. i_want_to_stop=.false. c c c Is the click in one of my telescope view windows? Store previous values... iprevious_click_in_x_window=icurrent_click_in_x_window iprevious_click_in_y_window=icurrent_click_in_y_window c c now update present values... icurrent_click_in_x_window=.false. icurrent_click_in_y_window=.false. xdot=icurrent_click_pixel_x ydot=icurrent_click_pixel_y c if(ydot .gt. top_edge_x .and. ydot .lt. bot_edge_x .and. . xdot .gt. left_edge_z .and. xdot .lt. right_edge_z) then c icurrent_click_in_x_window=.true. end if c c if(ydot .gt. top_edge_y .and. ydot .lt. bot_edge_y .and. . xdot .gt. left_edge_z .and. xdot .lt. right_edge_z) then c icurrent_click_in_y_window=.true. end if c c c are we near the bottom of the message window? If so, invite Zippy to c comment, and then return. if(icurrent_click_pixel_y .gt. message_top .and. . icurrent_click_pixel_y .gt. message_bot-20 .and. . icurrent_click_pixel_y .lt. message_bot ) then c call event_display_zippy c return end if c c c if we got a "George button" click, decide whether or not I have mapped the c button to some function. if not mapped, I'll get zero from c map_button_inverse. if(in_button .gt. 0) then map_inverse=map_button_inverse(in_button) else map_inverse=0 end if c c c Figure out what to do in response to the mouse button click: if(in_button .gt. 0 .and. map_inverse .eq. 0) then c c It's a "george button," but not one that I've assigned a function to. In c this case, print a message about where to find documentation. call event_display_write_message( . 'Empty button... For documentation and help see:') call event_display_write_message( . ' '//web_document_url(1:lenocc(web_document_url))) c return c c else if(in_button .eq. map_button(next_event_button)) then c c time for the next event, so set a flag and return... i_want_new_event=.true. c return c else if(in_button .eq. map_button(new_dem1_phi_button)) then c left button: increase by 5 degrees; right button: decrease by 5 degrees. if(mouse_button .eq. 1) then phidem1=phidem1 + delta_angle_per_click else if(mouse_button .eq. 3) then phidem1=phidem1 - delta_angle_per_click end if if(phidem1 .ge. 360.) phidem1=phidem1-360. if(phidem1 .le. -360.) phidem1=phidem1+360. return c c else if(in_button .eq. map_button(new_dem1_psi_button)) then c left button: increase by 5 degrees; right button: decrease by 5 degrees. if(mouse_button .eq. 1) then psidem1=psidem1 + delta_angle_per_click else if(mouse_button .eq. 3) then psidem1=psidem1 - delta_angle_per_click end if if(psidem1 .ge. 360.) psidem1=psidem1-360. if(psidem1 .le. -360.) psidem1=psidem1+360. return c c else if(in_button .eq. map_button(new_dem1_theta_button)) then c left button: increase by 5 degrees; right button: decrease by 5 degrees. if(mouse_button .eq. 1) then thetadem1=thetadem1 + delta_angle_per_click else if(mouse_button .eq. 3) then thetadem1=thetadem1 - delta_angle_per_click end if if(thetadem1 .ge. 360.) thetadem1=thetadem1-360. if(thetadem1 .le. -360.) thetadem1=thetadem1+360. return c c else if(in_button .eq. map_button(new_dem2_phi_button)) then c left button: increase by 5 degrees; right button: decrease by 5 degrees. if(mouse_button .eq. 1) then phidem2=phidem2 + delta_angle_per_click else if(mouse_button .eq. 3) then phidem2=phidem2 - delta_angle_per_click end if if(phidem2 .ge. 360.) phidem2=phidem2-360. if(phidem2 .le. -360.) phidem2=phidem2+360. return c else if(in_button .eq. map_button(new_dem2_psi_button)) then c left button: increase by 5 degrees; right button: decrease by 5 degrees. if(mouse_button .eq. 1) then psidem2=psidem2 + delta_angle_per_click else if(mouse_button .eq. 3) then psidem2=psidem2 - delta_angle_per_click end if if(psidem2 .ge. 360.) psidem2=psidem2-360. if(psidem2 .le. -360.) psidem2=psidem2+360. return c c else if(in_button .eq. map_button(new_dem2_theta_button)) then c left button: increase by 5 degrees; right button: decrease by 5 degrees. if(mouse_button .eq. 1) then thetadem2=thetadem2 + delta_angle_per_click else if(mouse_button .eq. 3) then thetadem2=thetadem2 - delta_angle_per_click end if if(thetadem2 .ge. 360.) thetadem2=thetadem2-360. if(thetadem2 .le. -360.) thetadem2=thetadem2+360. return c c else if(in_button .eq. map_button(new_demm_phi_button)) then c left button: increase by 5 degrees; right button: decrease by 5 degrees. if(mouse_button .eq. 1) then phidemm=phidemm + delta_angle_per_click else if(mouse_button .eq. 3) then phidemm=phidemm - delta_angle_per_click end if if(phidemm .ge. 360.) phidemm=phidemm-360. if(phidemm .le. -360.) phidemm=phidemm+360. return c else if(in_button .eq. map_button(new_demm_psi_button)) then c left button: increase by 5 degrees; right button: decrease by 5 degrees. if(mouse_button .eq. 1) then psidemm=psidemm + delta_angle_per_click else if(mouse_button .eq. 3) then psidemm=psidemm - delta_angle_per_click end if if(psidemm .ge. 360.) psidemm=psidemm-360. if(psidemm .le. -360.) psidemm=psidemm+360. return c c else if(in_button .eq. map_button(new_demm_theta_button)) then c left button: increase by 5 degrees; right button: decrease by 5 degrees. if(mouse_button .eq. 1) then thetademm=thetademm + delta_angle_per_click else if(mouse_button .eq. 3) then thetademm=thetademm - delta_angle_per_click end if if(thetademm .ge. 360.) thetademm=thetademm-360. if(thetademm .le. -360.) thetademm=thetademm+360. return c c else if(in_button .eq. map_button(new_demd_phi_button)) then c left button: increase by 5 degrees; right button: decrease by 5 degrees. if(mouse_button .eq. 1) then phidemd=phidemd + delta_angle_per_click else if(mouse_button .eq. 3) then phidemd=phidemd - delta_angle_per_click end if if(phidemd .ge. 360.) phidemd=phidemd-360. if(phidemd .le. -360.) phidemd=phidemd+360. return c else if(in_button .eq. map_button(new_demd_psi_button)) then c left button: increase by 5 degrees; right button: decrease by 5 degrees. if(mouse_button .eq. 1) then psidemd=psidemd + delta_angle_per_click else if(mouse_button .eq. 3) then psidemd=psidemd - delta_angle_per_click end if if(psidemd .ge. 360.) psidemd=psidemd-360. if(psidemd .le. -360.) psidemd=psidemd+360. return c c else if(in_button .eq. map_button(new_demd_theta_button)) then c left button: increase by 5 degrees; right button: decrease by 5 degrees. if(mouse_button .eq. 1) then thetademd=thetademd + delta_angle_per_click else if(mouse_button .eq. 3) then thetademd=thetademd - delta_angle_per_click end if if(thetademd .ge. 360.) thetademd=thetademd-360. if(thetademd .le. -360.) thetademd=thetademd+360. return c c else if(in_button .eq. map_button(izoom_button)) then c left button: set up a zoom. right button: reset the zoom parameters. if(mouse_button .eq. 1) then iamzooming=.true. call event_display_write_message( . 'click twice on the display to define zoom ' . // 'rectangle; right-click on zoom button to reset.') c else if(mouse_button .eq. 3) then c iamzooming=.false. c pixel_at_x_0=pixel_at_x_0_default pixel_at_zx_0=pixel_at_zx_0_default pixel_at_y_0=pixel_at_y_0_default pixel_at_zy_0=pixel_at_zy_0_default c pixel_at_x_9=pixel_at_x_9_default pixel_at_zx_9=pixel_at_zx_9_default pixel_at_y_9=pixel_at_y_9_default pixel_at_zy_9=pixel_at_zy_9_default c pixels_per_x=pixels_per_x_default pixels_per_zx=pixels_per_zx_default pixels_per_y=pixels_per_y_default pixels_per_zy=pixels_per_zy_default c telescope_max_x=telescope_max_x_default telescope_max_zx=telescope_max_zx_default telescope_max_y=telescope_max_y_default telescope_max_zy=telescope_max_zy_default c telescope_min_x=telescope_min_x_default telescope_min_zx=telescope_min_zx_default telescope_min_y=telescope_min_y_default telescope_min_zy=telescope_min_zy_default c call event_display_write_message('display reset') end if return c c else if(in_button .eq. map_button(istop_button)) then c user hit the stop button: require two clicks here before stopping. if(iprevious_button .eq. map_button( istop_button)) then i_want_to_stop=.true. else call event_display_write_message('double-click to stop') end if c return c end if c c c we only get here if click was not in a mapped button. See if it's in a c detector x or y view plot... if so, we'll either report the x,y value c of the click, or set up a zoom. if(.not.iamzooming) then c if(icurrent_click_in_x_window) then call event_display_xpixels_to_lab(xdot, ydot, . telescope_x, telescope_y, telescope_z) c c 11111111112222222222333 c 12345678901234567890123456789012 text='x view click at telescope z,x = ' . // '-9999.999 mm, -9999.999 mm ' c 3333333444444444455555555556 c 3456789012345678901234567890 c write(text(33:41), '(f9.3)') telescope_z write(text(47:55), '(f9.3)') telescope_x c call event_display_write_message(text) c else if(icurrent_click_in_y_window) then c call event_display_ypixels_to_lab(xdot, ydot, . telescope_x, telescope_y, telescope_z) c c 11111111112222222222333 c 12345678901234567890123456789012 text='y view click at telescope z,y = ' . // '-9999.999 mm, -9999.999 mm ' c 3333333444444444455555555556 c 3456789012345678901234567890 c write(text(33:41), '(f9.3)') telescope_z write(text(47:55), '(f9.3)') telescope_y c call event_display_write_message(text) c else c not zooming, but click wasn't somewhere I could use so... go to 90 c end if c c end of the .not.iamzooming if-block: end if c c c if(iamzooming) then c c right-click means cancel the zoom, so check for this... if(mouse_button .eq. 3) then iamzooming=.false. return end if c c c if click wasn't in the detector display windows, ignore it: if(.not. icurrent_click_in_x_window .and. . .not. icurrent_click_in_y_window) return c c c Now record the position, then make the cursor into a rubber rectangle c cursor. c record the screen pixel: xdot_zoom1=xdot ydot_zoom1=ydot c c also calculate the telescope coordinates: if(icurrent_click_in_x_window) then c call event_display_xpixels_to_lab(xdot_zoom1, ydot_zoom1, . telescope_x_zoom1, telescope_y_zoom1, telescope_z_zoom1) c else c call event_display_ypixels_to_lab(xdot_zoom1, ydot_zoom1, . telescope_x_zoom1, telescope_y_zoom1, telescope_z_zoom1) c end if c c c now request a mouse event using a rubber rectangle cursor: mouse_button=ixreqlo(mode, irubber_cursor, ixmouse, iymouse) c c c right-click means cancel the zoom, so check for this... if(mouse_button .eq. 3) then iamzooming=.false. return end if c c c do some of my bookkeeping by hand here that normally is done in the c event_display_mouse_request routine: iprevious_mouse_button=icurrent_mouse_button iprevious_button=icurrent_button iprevious_click_pixel_x=icurrent_click_pixel_x iprevious_click_pixel_y=icurrent_click_pixel_y icurrent_mouse_button=mouse_button icurrent_click_pixel_x=ixmouse icurrent_click_pixel_y=iymouse c iprevious_click_in_x_window=icurrent_click_in_x_window iprevious_click_in_y_window=icurrent_click_in_y_window c icurrent_click_in_x_window=.false. icurrent_click_in_y_window=.false. c xdot_zoom2=icurrent_click_pixel_x ydot_zoom2=icurrent_click_pixel_y c c if(ydot_zoom2 .gt. top_edge_x .and. . ydot_zoom2 .lt. bot_edge_x .and. . xdot_zoom2 .gt. left_edge_z .and. . xdot_zoom2 .lt. right_edge_z) then c icurrent_click_in_x_window=.true. end if c c if(ydot_zoom2 .gt. top_edge_y .and. . ydot_zoom2 .lt. bot_edge_y .and. . xdot_zoom2 .gt. left_edge_z .and. . xdot_zoom2 .lt. right_edge_z) then c icurrent_click_in_y_window=.true. end if c c c also calculate the telescope coordinates: if(icurrent_click_in_x_window) then c call event_display_xpixels_to_lab(xdot_zoom2, ydot_zoom2, . telescope_x_zoom2, telescope_y_zoom2, telescope_z_zoom2) c else c call event_display_ypixels_to_lab(xdot_zoom2, ydot_zoom2, . telescope_x_zoom2, telescope_y_zoom2, telescope_z_zoom2) c end if c c c now require that we got a click in the same window, or else ignore c this click. if(.not. . ( (icurrent_click_in_x_window .and. . iprevious_click_in_x_window) .or. . (icurrent_click_in_y_window .and. . iprevious_click_in_y_window) )) then c iamzooming=.false. return end if c c c if we make it to here, we have enough information to do a rescaling c of one of the windows. c c now set the new pixel-to-telescope-coordinate translation parameters. As c always, keep in mind that telescope x (or y) maps into negative screen y, c telescope z maps into positive screen x. if(icurrent_click_in_x_window) then c telescope_min_x= . min(telescope_x_zoom1,telescope_x_zoom2) telescope_max_x= . max(telescope_x_zoom1,telescope_x_zoom2) telescope_min_zx= . min(telescope_z_zoom1,telescope_z_zoom2) telescope_max_zx= . max(telescope_z_zoom1,telescope_z_zoom2) c c protect against zooming outside area of interest: first just try to c shift, keeping the requested size, then make a final correction to keep c everything inside my plot boundaries. if(telescope_min_x .lt. telescope_min_x_default) then telescope_max_x=telescope_max_x + . (telescope_min_x_default - telescope_min_x) telescope_min_x=telescope_min_x_default end if if(telescope_min_zx .lt. telescope_min_zx_default) then telescope_max_zx=telescope_max_zx + . (telescope_min_zx_default - telescope_min_zx) telescope_min_zx=telescope_min_zx_default end if c if(telescope_max_x .gt. telescope_max_x_default) then telescope_min_x=telescope_min_x + . (telescope_max_x_default - telescope_max_x) telescope_max_x=telescope_max_x_default end if if(telescope_max_zx .gt. telescope_max_zx_default) then telescope_min_zx=telescope_min_zx + . (telescope_max_zx_default - telescope_max_zx) telescope_max_zx=telescope_max_zx_default end if c if(telescope_min_x .lt. telescope_min_x_default) then telescope_min_x=telescope_min_x_default end if if(telescope_min_zx .lt. telescope_min_zx_default) then telescope_min_zx=telescope_min_zx_default end if c if(telescope_max_x .gt. telescope_max_x_default) then telescope_max_x=telescope_max_x_default end if if(telescope_max_zx .gt. telescope_max_zx_default) then telescope_max_zx=telescope_max_zx_default end if c c protect against scales going to zero: if(telescope_max_x - telescope_min_x .lt. .001) . telescope_max_x=telescope_min_x + .001 if(telescope_max_zx - telescope_min_zx .lt. .001) . telescope_max_zx=telescope_min_zx + .001 c pixels_per_x=(pixel_at_x_0 - pixel_at_x_9) / . (telescope_max_x - telescope_min_x) pixels_per_zx=(pixel_at_zx_9 - pixel_at_zx_0) / . (telescope_max_zx - telescope_min_zx) c call event_display_write_message( . 'zoomed the x view plot') c 1111111111222222222233333333334 c 1234567890123456789012345678901234567890 text='minimum z,x = -9999.999 mm, -9999.999 mm' . // ', maximum = -9999.999 mm, -9999.999 mm.' c write(text(15:23), '(f9.3)') telescope_min_zx write(text(29:37), '(f9.3)') telescope_min_x write(text(53:61), '(f9.3)') telescope_max_zx write(text(67:75), '(f9.3)') telescope_max_x c call event_display_write_message(text) c c else c c telescope_min_y= . min(telescope_y_zoom1,telescope_y_zoom2) telescope_max_y= . max(telescope_y_zoom1,telescope_y_zoom2) telescope_min_zy= . min(telescope_z_zoom1,telescope_z_zoom2) telescope_max_zy= . max(telescope_z_zoom1,telescope_z_zoom2) c c protect against zooming outside area of interest: first just try to c shift, keeping the requested size, then make a final correction to keep c everything inside my plot boundaries. if(telescope_min_y .lt. telescope_min_y_default) then telescope_max_y=telescope_max_y + . (telescope_min_y_default - telescope_min_y) telescope_min_y=telescope_min_y_default end if if(telescope_min_zy .lt. telescope_min_zy_default) then telescope_max_zy=telescope_max_zy + . (telescope_min_zy_default - telescope_min_zy) telescope_min_zy=telescope_min_zy_default end if c if(telescope_max_y .gt. telescope_max_y_default) then telescope_min_y=telescope_min_y + . (telescope_max_y_default - telescope_max_y) telescope_max_y=telescope_max_y_default end if if(telescope_max_zy .gt. telescope_max_zy_default) then telescope_min_zy=telescope_min_zy + . (telescope_max_zy_default - telescope_max_zy) telescope_max_zy=telescope_max_zy_default end if c if(telescope_min_y .lt. telescope_min_y_default) then telescope_min_y=telescope_min_y_default end if if(telescope_min_zy .lt. telescope_min_zy_default) then telescope_min_zy=telescope_min_zy_default end if c if(telescope_max_y .gt. telescope_max_y_default) then telescope_max_y=telescope_max_y_default end if if(telescope_max_zy .gt. telescope_max_zy_default) then telescope_max_zy=telescope_max_zy_default end if c c protect against scales going to zero: if(telescope_max_y - telescope_min_y .lt. .001) . telescope_max_y=telescope_min_y + .001 if(telescope_max_zy - telescope_min_zy .lt. .001) . telescope_max_zy=telescope_min_zy + .001 c pixels_per_y=(pixel_at_y_0 - pixel_at_y_9) / . (telescope_max_y - telescope_min_y) pixels_per_zy=(pixel_at_zy_9 - pixel_at_zy_0) / . (telescope_max_zy - telescope_min_zy) c call event_display_write_message( . 'zoomed the y view plot') c 1111111111222222222233333333334 c 1234567890123456789012345678901234567890 text='minimum z,y = -9999.999 mm, -9999.999 mm' . // ', maximum = -9999.999 mm, -9999.999 mm.' c write(text(15:23), '(f9.3)') telescope_min_zy write(text(29:37), '(f9.3)') telescope_min_y write(text(53:61), '(f9.3)') telescope_max_zy write(text(67:75), '(f9.3)') telescope_max_y c call event_display_write_message(text) c end if c iamzooming=.false. c end if c c c 90 continue c return end