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

Home » Public Forums » archive » Re: Scrolling in draw widgets - newbie's question
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
Re: Scrolling in draw widgets - newbie's question [message #31676] Tue, 13 August 2002 09:29
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
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
Re: Scrolling in draw widgets - newbie's question [message #31677 is a reply to message #31676] Tue, 13 August 2002 07:24 Go to previous message
Liam E. Gumley is currently offline  Liam E. Gumley
Messages: 378
Registered: January 2000
Senior Member
Evgeny Turchin wrote:
>
> Hello, All !
> 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. Does anybody know
> how to solve the problem and create the widget where scrolling is possible
> in graphic viewport?
> I'm using IDL 5.4 for Win32.

Try this instead:

base = widget_base()
draw = widget_draw(base, xsize=1024, ysize=1024, $
x_scroll_size=512, y_scroll_size=512)
widget_control, base, /realize
plot, indgen(10)

Also see the SWINDOW procedure:

http://www.astro.washington.edu/deutsch-bin/idllibsrch?keywo rd=swindow

Cheers,
Liam.
Practical IDL Programming
http://www.gumley.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: dataminer - where to start
Next Topic: Re: Return the name of the last (newest) file ?

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

Current Time: Wed Oct 08 19:37:51 PDT 2025

Total time taken to generate the page: 0.00647 seconds