IDLgrAxis question. [message #38076] |
Thu, 19 February 2004 12:26  |
savoie
Messages: 68 Registered: September 1996
|
Member |
|
|
Gurus,
O.k. I've been pulling hair and beating my head over this for a while, and I
think if I ask, someone here will probably be able to tell me right away. I
want to be able to change the range of an axis from within a widget program.
I am doing this with the setProperty procedures of the axis and plot. After
I do this, the yfonts get all screwy. (that's the technical term.)
I'm running into this problem on IDL Version 6.0 (linux x86 m32).
I have just taken Ronn Kling's example program and hacked it to show you what
I mean.
Please tell me what I'm doing wrong before I get any balder?
Thanks so much
Matt
;; Here it is ....
pro plot_axis_weirdness
;; example program for plot objects from Kling's book originally, modified
;; to ask a question
array = findgen(180)
x = array
y = Sin(array/5.) / Exp(array/50.)
theFont = Obj_New('IDLgrFont', size = 8)
oWindow = obj_new('IDLgrWindow', dimension = [400, 400], renderer = 1, $
retain = 2, title = 'Plot Object example')
oView = obj_new('IDLgrView', $
VIEWPLANE_RECT = [-.3, -.3, 1.4, 1.6], $
color = [255, 255, 255])
oModel = obj_new('IDLgrModel')
oPlot = obj_new('IDLgrPlot', x, y)
oPlot -> getProperty, xrange = xrange, yrange = yrange
print, yrange, xrange
xs = normalize(xrange)
ys = normalize(yrange)
oPlot -> setProperty, xcoord_conv = xs, ycoord_conv = ys
oModel -> add, oPlot
oView -> add, oModel
oTextX = obj_new('IDLgrText', 'X Axis', FONT=theFont)
oAxisX = obj_new('IDLgrAxis', 0, range = xrange, xcoord_conv = xs, /EXACT, $
title = oTextX)
;;add it to the model
oModel -> add, oAxisX
;;create a text object
oTextY = obj_new('IDLgrText', 'Y Axis', FONT = theFont)
;;create an axis object
oAxisY = obj_new('IDLgrAxis', 1, range = yrange, $
ycoord_conv = ys, exact = 1, $
title = oTextY)
;;add it to the model
oModel -> add, oAxisY
oWindow -> draw, oView ;;have to redraw the view to see the changes
oWindow -> show, 1 ;;now push it to the top
print, 'press return to change the yrange'
r = get_kbrd(1)
oAxisY -> GetProperty, crange = range
print, range
new_range = [range[0]-4, range[0]+4]
oAxisY -> SetProperty, range = new_range, /EXACT
;; just to verify
oAxisY -> GetProperty, crange = range
print, range
new_Yscale = normalize(range)
oAxisY -> SetProperty, YCOORD_CONV = new_Yscale
oPlot -> SetProperty, YCOORD_CONV = new_Yscale
oWindow -> draw, oView
oWindow -> show, 1
print, 'press return to end the program'
r = get_kbrd(1)
;clean up the objects
obj_destroy, oWindow
obj_destroy, oView
obj_destroy, oModel
obj_destroy, oPlot
obj_destroy, oAxisX
obj_destroy, oAxisY
obj_destroy, oTextX
obj_destroy, oTextY
return
end
--
Matthew Savoie - Scientific Programmer
National Snow and Ice Data Center
(303) 735-0785 http://nsidc.org
|
|
|