On Mar 16, 9:01 pm, David Fanning <n...@dfanning.com> wrote:
> gearoi...@gmail.com writes:
>> I am designing GUI, I have multiple draw widgets on screen at one
>> time. I am able to select the desired widget and find its ID but
>> cannot get access to the image that it is showing. For example, when a
>> user clicks on a draw widget, it takes that image and displays it in a
>> larger window. I imagine the code might look something like this:
>
>> I am aware I can set the u_value to the image but this does not work
>> if I wish to use a few different images.
>
>> Any help would be greatly appreciated.
>
> Normally, ALL the information you need to run your program
> (e.g., Draw widget IDs, images, or pointers to images, etc.,
> etc., etc.) is stored in a structure in the user value of
> the top-level base, where it is easily accessible to
> all the event handler modules that require the information.
> (Sometime this structure is *itself* stored in a pointer
> so it is easier to carry around with out making copies of
> the data all the time.)
>
> If you write your programs this way, all information is
> immediately at your fingertips.
>
> Another way you could write your program is to use the
> UVALUE of the draw widget to store the image that is
> displayed there. Then, if you can find the draw widget,
> you can find the image. But this method can get messy
> very quickly and I do NOT recommend it.
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Thanks for that Dave but I'm afraid I'm still confused.
My code looks like the following (Sorry for the mess :-) ):
pro OpenFiles, Event
dir="Z:\Final Year Project\Test Images\More Tests\Stream\"
image_array = intarr(1024,1024,10)
;Open all the files in relevant folder
for i=0,9 do begin
file = string(i,format='(%"image%3.3d.jpeg")')
print, file
image=read_image(dir+file)
image_array[*,*,i]=image
CASE i OF
0:BEGIN
;The following case function adds the read in images into their
respective displays
;Find the display widget
wDISPLAY_IMAGE_1 = WIDGET_INFO(Event.top,
FIND_BY_UNAME='DISPLAY_IMAGE_1');
;Make sure something was found.
IF(wDISPLAY_IMAGE_1 GT 0)THEN BEGIN
; Make the draw widget the current, active window.
WIDGET_CONTROL, wDISPLAY_IMAGE_1, GET_VALUE=idDISPLAY_IMAGE_1
WSET,idDISPLAY_IMAGE_1
; Make sure the image exists.
IF(N_ELEMENTS(image) GT 0)THEN BEGIN
display1 = CONGRID(image, 103, 103)
; Display the noisy image.
TV, display1
ENDIF
ENDIF
END
1:BEGIN
wDISPLAY_IMAGE_2 = WIDGET_INFO(Event.top,
FIND_BY_UNAME='DISPLAY_IMAGE_2');
;Make sure something was found.
IF(wDISPLAY_IMAGE_2 GT 0)THEN BEGIN
; Make the draw widget the current, active window.
WIDGET_CONTROL, wDISPLAY_IMAGE_2, GET_VALUE=idDISPLAY_IMAGE_2
WSET,idDISPLAY_IMAGE_2
; Make sure the image exists.
IF(N_ELEMENTS(image) GT 0)THEN BEGIN
display2 = CONGRID(image, 103, 103)
; Display the noisy image.
TV, display2
ENDIF
ENDIF
END
2:BEGIN
wDISPLAY_IMAGE_3 = WIDGET_INFO(Event.top,
FIND_BY_UNAME='DISPLAY_IMAGE_3');
;Make sure something was found.
IF(wDISPLAY_IMAGE_3 GT 0)THEN BEGIN
; Make the draw widget the current, active window.
WIDGET_CONTROL, wDISPLAY_IMAGE_3, GET_VALUE=idDISPLAY_IMAGE_3
WSET,idDISPLAY_IMAGE_3
; Make sure the image exists.
IF(N_ELEMENTS(image) GT 0)THEN BEGIN
display3 = CONGRID(image, 103, 103)
; Display the noisy image.
TV, display3
ENDIF
ENDIF
END
3:BEGIN
wDISPLAY_IMAGE_4 = WIDGET_INFO(Event.top,
FIND_BY_UNAME='DISPLAY_IMAGE_4');
;Make sure something was found.
IF(wDISPLAY_IMAGE_4 GT 0)THEN BEGIN
; Make the draw widget the current, active window.
WIDGET_CONTROL, wDISPLAY_IMAGE_4,
GET_VALUE=idDISPLAY_IMAGE_4
WSET,idDISPLAY_IMAGE_4
; Make sure the image exists.
IF(N_ELEMENTS(image) GT 0)THEN BEGIN
display4 = CONGRID(image, 103, 103)
; Display the noisy image.
TV, display4
ENDIF
ENDIF
END
ELSE: t=0
ENDCASE
ENDFOR
average= FIND_AVERAGE(image_array)
wCURRENT = WIDGET_INFO(Event.top, FIND_BY_UNAME='CURRENT');
;Make sure something was found.
IF(wCURRENT GT 0)THEN BEGIN
; Make the draw widget the current, active window.
WIDGET_CONTROL, wCURRENT, GET_VALUE=idCURRENT
WSET,idCURRENT
average = CONGRID(average,512,512)
TV, average
ENDIF
end
pro OnExit, Event
WIDGET_CONTROL, Event.top, /DESTROY
end
;
; Empty stub procedure used for autoloading.
;
pro gui2_eventcb
end
pro viewNext, Event
end
********
This program takes in 10 images and displays the first 4 (image0 to
image3) in the GUI. For the final function 'viewNext', I would like
all the images (which are saved in the array 'images_array' which is
defined in the OpenFile function) to shift up by one place, such that
image1 to image4 are displayed.
Could you tell me how to do this?
Thanks again,
Ger.
|