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

Home » Public Forums » archive » Simple Widget Programme - Help
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
Simple Widget Programme - Help [message #34569] Wed, 02 April 2003 12:03 Go to next message
Karthikayan Balakrish is currently offline  Karthikayan Balakrish
Messages: 3
Registered: April 2003
Junior Member
Hello All,
I have some experience with writing IDL Programmes and I want to
start using widgets now. I read the examples that come with the IDL manu
al and tried my hand at one example where I would display a picture and rot
ate it by the value set by a slider. However this example does not wor
k. Can anyone fix my small programme (with comments perhaps) so that I ca
n load either file 1 or 2 and dispaly it after proper rotation. Here is the
code I was playing with:

PRO QuitProgramme,event
widget_control,event.top,/DESTROY
return
end

PRO Display1,event
READ_PPM,'flowers.pgm',array
tvscl,array
return
end

PRO Display2,event
READ_PPM,'boy.pgm',array
tvscl,array
return
end

PRO FindAngle,event
widget_control,event.top,get_uvalue=info
print,'###############',event.value
return
end

PRO slider_event,event
widget_control, ev.id, GET_UVALUE=uval
case uval of
'File1' : begin READ_PPM,'flowers.pgm',array
tvscl,array
end
'File2' : begin READ_PPM,'boy.pgm',array
tvscl,array
end
'Quit' : begin Widget_Control,ev.top,/DESTROY
end
ENDCASE
END

PRO slider

base = Widget_Base(Title='28 March 2003',MBAR=menubar,/Column)
menu1 = Widget_Button(menubar,Value='File List',/Menu)
;Create the Menu Items
button1 = Widget_Button(Menu1,Value='File 1',Event_pro='Display1')
button2 = Widget_Button(Menu1,Value='File 2',Event_pro='Display2')
button3 = Widget_Button(Menu1,Value='Quit' ,Event_pro='QuitProgramme')

rot_gp = Widget_Slider(base,max=180,min=0,value=45,Event_pro='FindAng le')
draw = Widget_Draw(base,Xsize=256,ysize=256)

;The text box to show the degrees rotated.
text_box= Widget_text(base,xsize=10)

;make the structure
;READ_PPM,'flowers.pgm',array
;pic = Ptr_new(array)
;info ={ pic:pic, $ ;the picture
; rot_gp:rot_gp } ;the rotation in degrees

Widget_Control, /REALIZE, base
Widget_Control,draw,GET_VALUE=index
WSET,index
Widget_Control, base;, SET_UVALUE=info
XMANAGER,'widget28Mar2003',base
END

Thanks in advance,
Karthik.
Re: Simple Widget Programme - Help [message #34718 is a reply to message #34569] Wed, 02 April 2003 12:34 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Karthikayan Balakrishnan (lovedale27@hotmail_NOSPAM.com) writes:

> I have some experience with writing IDL Programmes and I want to
> start using widgets now. I read the examples that come with the IDL manu
> al and tried my hand at one example where I would display a picture and rot
> ate it by the value set by a slider. However this example does not wor
> k. Can anyone fix my small programme (with comments perhaps) so that I ca
> n load either file 1 or 2 and dispaly it after proper rotation. Here is the
> code I was playing with:

I am such a sucker for this kind of thing. :-(

OK, here is a working version, just quick and dirty because
my team is playing a tennis match this afternoon.

;*********************************************************** **********
PRO TEST_QuitProgramme,event
widget_control,event.top,/DESTROY
end

PRO TEST_Display,event
Widget_Control, event.top, Get_UValue=info
Widget_Control, event.id, Get_UValue=nameOfFile
READ_JPEG, nameOfFile, image
*info.pic = image
wset, info.index
s = size(image, /dimensions)
widget_control, info.draw, draw_xsize=s[0], draw_ysize=s[1]
tv, *info.pic
end


PRO TEST_FindAngle,event
widget_control,event.top,get_uvalue=info
WSet, info.index
tv, ROT(*info.pic, event.value)
Widget_Control, info.text_box, Set_Value=StrTrim(event.value,2)
end


PRO TEST_Cleanup, base
Widget_Control, base, Get_UValue=info
Ptr_Free, info.pic
END


PRO TEST

file = Filepath('endocell.jpg', SubDirectory=['examples', 'data'])
Read_JPEG, file, image


base = Widget_Base(Title='28 March 2003',MBAR=menubar,/Column)
menu1 = Widget_Button(menubar,Value='File List',/Menu)
;Create the Menu Items

button1 = Widget_Button(Menu1,Value='File 1',Event_pro='TEST_Display', $
UValue=Filepath('endocell.jpg', SubDirectory=['examples', 'data']))

button2 = Widget_Button(Menu1,Value='File 2',Event_pro='TEST_Display', $
UValue=Filepath('muscle.jpg', SubDirectory=['examples', 'data']))
button3 = Widget_Button(Menu1,Value='Quit' ,$
Event_pro='TEST_QuitProgramme')

rot_gp = Widget_Slider(base,max=180,min=0,value=45,$
Event_pro='TEST_FindAngle')
s = size(image, /dimensions)

draw = Widget_Draw(base,Xsize=s[0],ysize=s[1])

;The text box to show the degrees rotated.
text_box= Widget_text(base,xsize=10)

;make the structure


Widget_Control, /REALIZE, base
Widget_Control,draw,GET_VALUE=index
WSET,index
tv, image
pic = Ptr_new(image, /No_Copy)
info ={ pic:pic, $ ;the picture
rot_gp:rot_gp, $ ;the slider
text_box:text_box, $ ; the text widget
draw:draw, $ ; the draw widget
index:index } ; the window index
Widget_Control, base, SET_UVALUE=info
XMANAGER,'widget28Mar2003',base, /No_Block, Cleanup='TEST_Cleanup'
END

;*********************************************************** **********

I used images from the example/data subdirectory to get it working.

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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: a question about IDL graphics under X
Next Topic: Re: CAPS -yes

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

Current Time: Wed Oct 08 16:51:51 PDT 2025

Total time taken to generate the page: 0.00386 seconds