Viewing contents of file '../idllib/contrib/tappin/graffer/gr_autoscale.pro'
pro Gr_autoscale, pdefs, xaxis=xaxis, yaxis=yaxis, ignore=ignore
;+
; GR_AUTOSCALE
; Autoscale a GRAFFER axis to its data.
;
; Usage:
; gr_autoscale, pdefs, [/xaxis|/yaxis]
;
; Arguments:
; pdefs struct in/out The GRAFFER data structure
;
; Keywords:
; xaxis ? input If set scale the X-axis
; yaxis ? input If set scale the Y-axis
; ignore ? input If set, then disregard the current
; settings altogther, the default is
; only to extend axis ranges.
;
; History:
; Original (borrowing much code from PLOT_OBJECT): 9/8/96; SJT
;-
widgets = pdefs.ids.graffer ne 0
if (not keyword_set(xaxis) and not keyword_set(yaxis)) then begin
graff_msg, pdefs.ids.message, "Must specify either XAXIS or YAXIS " + $
"key"
return
endif else if (keyword_set(xaxis) and keyword_set(yaxis)) then begin
graff_msg, pdefs.ids.message, "Cannot autoscale both axes at once"
return
endif
handle_value, pdefs.data, data, /no_copy
range = [!Values.f_infinity, -!Values.f_infinity]
if (keyword_set(xaxis)) then begin
if (not keyword_set(ignore)) then range = pdefs.xrange
for i = 0, pdefs.nsets-1 do begin
if (data(i).ndata eq 0) then goto, end_x ; Trying to autoscale
; on an empty data set is silly
if (data(i).mode ne 0) then gr_as_xa, data(i), pdefs.xrange, $
pdefs.yrange, range $
else gr_as_xr, data(i), pdefs.yrange, pdefs.ytype, range
End_x:
endfor
pdefs.xrange = range
if (widgets) then begin
widget_control, pdefs.ids.xmin, set_value = range(0)
widget_control, pdefs.ids.xmax, set_value = range(1)
endif
endif else begin
if (not keyword_set(ignore)) then range = pdefs.yrange
for i = 0, pdefs.nsets-1 do begin
if (data(i).ndata eq 0) then goto, end_y ; Trying to autoscale
; on an empty data set is silly
if (data(i).mode ne 0) then gr_as_ya, data(i), pdefs.xrange, $
pdefs.yrange, range $
else gr_as_yr, data(i), pdefs.xrange, pdefs.xtype, range
End_y:
endfor
pdefs.yrange = range
if (widgets) then begin
widget_control, pdefs.ids.ymin, set_value = range(0)
widget_control, pdefs.ids.ymax, set_value = range(1)
endif
endelse
handle_value, pdefs.data, data, /no_copy, /set
end