Evgeny Turchin (evgturchin@narod.ru) writes:
> Here's the text of my program:
>
> base = WIDGET_BASE(XSIZE=650, YSIZE=400)
> draw1 = WIDGET_DRAW(base, XSIZE = 550, X_SCROLL_SIZE=200, YSIZE = 550,
> Y_SCROLL_SIZE=200, XOFFSET=5, /APP_SCROLL)
> WIDGET_CONTROL, /REALIZE, base
> WIDGET_CONTROL, draw1, GET_VALUE = index
> WSET, index
> ImageIsRead=DIALOG_READ_IMAGE(FILE=FileName, FILTER_TYPE='.tif, .tiff', $
> IMAGE=PhotoArray)
> TVSCL, PhotoArray
>
> The image is successfuly loaded in the viewport but the scrolling does not
> work.
Well, it is hard to know what "doesn't work" means,
unless this is the *entire* program, then it's pretty
obvious: most of the required code is missing. :-)
Here is a program that appears to "work".
************************************************************ ******
PRO Example_Event, event
Widget_Control, event.top, Get_UValue=image
IF event.type EQ 3 THEN BEGIN ; Scroll events
s = Size(image, /Dimensions)
xstart = 0 > event.x < (s[0]/2)
xfinish = (s[0]/2) > (event.x + (s[0]/2)) < (s[0]-1)
ystart = 0 > event.y < (s[1]/2)
yfinish = (s[1]/2) > (event.y + (s[1]/2)) < (s[1]-1)
TV, image[xstart:xfinish, ystart:yfinish]
ENDIF
IF event.type EQ 4 THEN BEGIN ; Expose events
Widget_Control, event.id, Get_Draw_View=viewport
s = Size(image, /Dimensions)
xstart = 0 > viewport[0] < (s[0]/2)
xfinish = (s[0]/2) > (viewport[0] + (s[0]/2)) < (s[0]-1)
ystart = 0 > viewport[1] < (s[1]/2)
yfinish = (s[1]/2) > (viewport[1] + (s[1]/2)) < (s[1]-1)
TV, image[xstart:xfinish, ystart:yfinish]
ENDIF
END
PRO Example, image
IF N_Elements(image) EQ 0 THEN BEGIN
image = BytArr(360,360)
filename = Filepath(SubDir=['examples', 'data'], 'worldelv.dat')
OpenR, lun, filename, /Get_Lun
ReadU, lun, image
Free_Lun, lun
ENDIF
s = Size(image, /Dimensions)
base = WIDGET_BASE()
draw1 = WIDGET_DRAW(base, XSIZE = s[0], X_SCROLL_SIZE=s[0]/2, $
YSIZE = s[1], Y_SCROLL_SIZE=s[1]/2, /APP_SCROLL)
WIDGET_CONTROL, /REALIZE, base
WIDGET_CONTROL, draw1, GET_VALUE = index
WSET, index
TV, image[0:s[0]-1, s[1]/2:*]
WIDGET_CONTROL, base, Set_UValue=image
XManager, 'example', base, /No_Block
END
************************************************************ ******
Call it with your image, like this:
IDL> ImageIsRead=DIALOG_READ_IMAGE(FILE=FileName, $
FILTER_TYPE='.tif, .tiff', IMAGE=PhotoArray)
IDL> Example, photoarray
Unfortunately, I'm afraid this is going to raise more
questions than it answers. :-(
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|