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
|