Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Idl-pvware > Multiple draw w...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 5697 of 5728
Post > Topic >>

Multiple draw widget events

by Jye <jye.smith@[EMAIL PROTECTED] > May 1, 2008 at 10:49 PM

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




 5 Posts in Topic:
Multiple draw widget events
Jye <jye.smith@[EMAIL   2008-05-01 22:49:53 
Re: Multiple draw widget events
"ben.bighair" &  2008-05-02 06:54:09 
Re: Multiple draw widget events
David Fanning <news@[E  2008-05-02 08:21:43 
Re: Multiple draw widget events
David Fanning <news@[E  2008-05-02 09:09:33 
Re: Multiple draw widget events
Jye <jye.smith@[EMAIL   2008-05-05 18:07:07 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun May 11 23:04:25 CDT 2008.