PRO qImage_cw_Mouse, state, event ;+ ; NAME: ; qImage_cw_Mouse ; PURPOSE: ; Processes mouse press, release and motion messages from the draw widget. ; CATEGORY: ; Compound widget qImage_cw ; CALLING SEQUENCE: ; qImage_cw_Mouse, state, event ; INPUTS: ; state scalar, structure ; contains IDs for all qView widgets ; event scalar, structure ; event structure passed to qView_Event by XManager ; OUTPUTS: ; Updates the current box in the X,Y widgets, and update the user value ; of the state.wid_blowup widget ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; IsType, qImage_cw_Transform, qImage_cw_Box, qImage_cw_Update ; PROCEDURE: ; First mouse click defines the first corner of a box, ; The box boundary changes tracking dragging of the mouse. ; The second click defines the second corner. ; Roam mode: ; when the box is completed (2nd click), then continued dragging ; causes the current box to track the mouse motion ; NOT in roam mode: ; fixes the box and leaves in the same position until the ; next click (which starts a new box). ; STATE INFO USED: ; widget_control, state.wid_tool, get_uvalue=tool, /no_copy ; widget_control, state.wid_smei, get_uvalue=set ; STATE INFO MODIFIED: ; widget_control, state.wid_tool, set_uvalue=tool, /no_copy ; MODIFICATION HISTORY: ; JAN-1999, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- widget_control, state.wid_tool, get_uvalue=tool_state, /no_copy mouse = tool_state.mouse m = tool_state.send.mouse widget_control, state.wid_tool, set_uvalue=tool_state, /no_copy IF mouse[0] EQ -1 THEN mouse = [0, event.x, event.y, event.x, event.y] m_box = m EQ 0 m_pixel = m EQ 1 m_roam_box = m EQ 2 m_roam_pix = m EQ 3 CASE event.type OF 0: BEGIN ; Button press CASE mouse[0] OF 0: mouse = [1, event.x, event.y, event.x, event.y] 1: IF m_box OR m_roam_box THEN mouse = [0,mouse[1:2],event.x, event.y] ENDCASE END 1: IF m_pixel OR m_roam_pix THEN mouse[0] = 0 ; Button release 2: BEGIN ; MOTION CASE mouse[0] OF 0: BEGIN CASE 1 OF m_roam_pix: mouse[1:4] = [event.x, event.y, event.x, event.y] m_roam_box: BEGIN mouse[1:4] = [event.x, event.y, event.x, event.y] qImage_cw_Box, state, box, /get, p_box=p_box widget_control, state.wid_smei, get_uvalue=set CASE set OF 0: BEGIN box = qImage_cw_Transform(state, fromimage=box, /toscreen) box = round([box[2]-box[0], box[3]-box[1]]/2) mouse[1:4] = mouse[1:4]+box[0:1]#[-1,1] END 1: BEGIN qImage_cw_Box, state, img_center, /center track = qImage_cw_Transform(state, fromscreen=mouse[1:2], /toimage) track = cv_coord(from_rect=track-img_center, /to_polar) track = (track-total(p_box,2)/2)#[1,1]+p_box track = img_center#[1,1]+cv_coord(from_polar=track, /to_rect) mouse[1:4] = qImage_cw_Transform(state, fromimage=track, /toscreen) END ENDCASE END ELSE: ENDCASE END 1: IF m_box OR m_roam_box THEN mouse = [1,mouse[1:2],event.x, event.y] ENDCASE END 3: ; Viewport moved 4: ; Expose ENDCASE widget_control, state.wid_tool, get_uvalue=tool_state, /no_copy tool_state.mouse = mouse widget_control, state.wid_tool, set_uvalue=tool_state, /no_copy IF event.type EQ 0 OR $ ; Button press (event.type EQ 2 AND (m_roam_box OR m_roam_pix OR (m_box AND mouse[0] EQ 1))) THEN BEGIN qImage_cw_Box , state, /put, qImage_cw_Transform(state, fromscreen=[[mouse[1:2]],[mouse[3:4]]], /toimage, /parent) qImage_cw_Update, state ENDIF RETURN & END