comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Multiple draw widget events
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Multiple draw widget events [message #60086] Thu, 01 May 2008 22:49
Jye is currently offline  Jye
Messages: 17
Registered: May 2008
Junior Member
Hi,

Another newbie here so the answer to my problem is most likely
blatently obvious.

The example below is of a draw widget which windows the displayed
image when right clicked on the draw widget and the ROI button runs
CW_DEFROI. But my problem is that the windowing events interfere when
CW_DEFROI is called! How can I stop this from happening? Im sure it
has something to do with the /no_block keyword but I have been unable
to find the solution.

Any help is greatly appreciated.

Cheers
Jye


;----------------------------------------------------------- ---------------------------------
; Windowing
;----------------------------------------------------------- ---------------------------------

PRO window_event, event
widget_control, event.top, get_uvalue=info

Widget_Control, info.draw, get_uvalue=uvalue
Window_size = uvalue[0]
Windowlocation = uvalue[1]

if event.press eq 4 then begin
Widget_Control, info.draw, Draw_Motion_Events=1
info.xstart=event.x
info.ystart=event.y
endif

if event.release eq 4 then begin
Widget_Control, info.draw, Draw_Motion_Events=0, Clear_Events=1
endif

if event.type eq 2 then begin
diffx = event.x-info.xstart
if Window_size-diffx le 255 and Window_size-diffx ge 1 then
Window_size = Window_size-diffx
if Windowlocation+Window_size gt 255 then Windowlocation = 255-
Window_size

diffy = event.y-info.ystart
if Windowlocation+Window_size-diffy le 255 and Windowlocation-diffy
ge 0 then Windowlocation = Windowlocation-diffy

info.xstart = event.x
info.ystart = event.y

Device, Decomposed=0
STRETCH, Windowlocation, Windowlocation+Window_size
wset, info.winid
TV, info.image
Device, Decomposed=1

Widget_Control, info.draw, set_uvalue=[Window_size, Windowlocation]
endif

widget_control, event.top, set_uvalue=info

END

;----------------------------------------------------------- ---------------------------------
; ROI
;----------------------------------------------------------- ---------------------------------

PRO ROI_event, event
widget_control, event.top, get_uvalue=info

Widget_Control, info.draw, Draw_Motion_Events=1

xsize=(size(info.image))[1]
ysize=(size(info.image))[2]

Result = CW_DEFROI(info.draw, IMAGE_SIZE=[xsize,ysize])

END

;----------------------------------------------------------- ---------------------------------
; Windowing and ROI program
;----------------------------------------------------------- ---------------------------------

PRO windowing_and_roi
device, get_screen_size=screen_size
xoffset = screen_size[0]/4
yoffset = screen_size[1]/4

file = Filepath(SubDirectory=['examples','data'], 'ctbone157.jpg')
READ_JPEG, file, image
xsize = (Size(image))[1]
ysize = (Size(image))[2]

tlb = widget_base(/row, xoffset=xoffset, yoffset=yoffset)
ROI = widget_button(tlb, value="ROI")
draw = widget_draw(tlb, xsize=xsize, ysize=ysize, /BUTTON_EVENTS)
widget_control, tlb, /realize

widget_control, draw, get_value=winid
wset, winid
tv, image

widget_Control, draw, set_uvalue=[(max(image)-min(image)),min(image)]

info = {draw:draw, winid:winid, image:image, xstart:0, ystart:0}
widget_control, tlb, set_uvalue=info

xmanager, 'ROI', ROI, /no_block
xmanager, 'window', draw, /no_block

END
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: HDF_SD_ADDDATA problem
Next Topic: iImage axes

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:09:49 PDT 2025

Total time taken to generate the page: 0.00518 seconds