[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

IDLgrWindow (?) bug



Hello everyone,
I think there is a bug in the way IDL creates an independent object
graphics window. Once you change things in it, the viewport (or
something else) changes, messing the displayed axes up. Try the code at
the bottom of this message. I use  PPC IDL 5.2 and tried it in PPC IDL 5.3.

IDL> test, All_objects=All_objects, window=window, scene=scene, $
IDL> 	x_axis=x_axis, x_top=x_axis_top
IDL> mod_axis, window=window, x_axis=x_axis, scene=scene, x_top=x_axis_top

Use obj_destroy, objects toclean up after you saw the results.
After mod_axis is executed, the all axes lengthen and reach the edges of
the window. However, if you try using the widget_draw in object graphics
mode, it does not happen:

IDL> test, All_objects=All_objects, window=window, scene=scene, $
IDL> 	x_axis=x_axis, x_top=x_axis_top, /wid
IDL> mod_axis, window=window, x_axis=x_axis, scene=scene, x_top=x_axis_top

Everything looks normal, scaling changes; of course, the labels are
messed up because size recalculation is left out in the sample code.
Use obj_destroy, objects toclean up after you saw the results.
Does anyone know if this is a feature or a bug? It took me half-day
yesterday to figure out why my axes act up, until I tried to put my
development object window into a widget.

Cheers,
Pavel

pro test, All_objects=All_objects, window=window, scene=scene, $
	x_axis=x_axis, x_top=x_axis_top, wid=wid

if keyword_set(wid) then begin
	base = widget_base()
	draw = widget_draw(base, xsize=400, ysize=300, graphics=2)
	widget_control, base, /realize
	widget_control, draw, get_value=Window
endif else Window = obj_new('IDLgrWindow')

	All_objects = obj_new('IDL_Container')
	Scene = obj_new('IDLgrScene')
	
		; Fill the entire window with the default view.
	View = obj_new('IDLgrView', viewplane_rect=[-0.1, -0.1, 1.12, 1.16],
location=[0.0, 0.0])
	Model = obj_new('IDLgrModel')

		; Initialize axes.
	x_axis_top = obj_new('IDLgrAxis', 0, ticklen=0.03, tickdir=1,
loc=[1000, 1, 0], /notext, /exact)
	y_axis_top = obj_new('IDLgrAxis', 1, ticklen=0.03, tickdir=1, loc=[1,
1000, 0], /notext, /exact)
	x_axis = obj_new('IDLgrAxis', 0, ticklen=0.03, name='X_AXIS',
location=[1000, 0, 0], /exact)
	y_axis = obj_new('IDLgrAxis', 1, ticklen=0.03, name='Y_AXIS',
location=[0, 1000, 0], /exact)
	
	Model -> add, x_axis
	Model -> add, y_axis
	Model -> add, x_axis_top
	Model -> add, y_axis_top
	
	View -> add, Model
	Scene -> add, View
	
		; Put all objects in container, for easy destruction.
	All_objects -> add, Scene
	All_objects -> add, Window
 	
	window -> draw, Scene

end

pro mod_axis, window=window, x_axis=x_axis, scene=scene, x_top=x_axis_top

x_nr = normalize([20.,120.])
x_axis -> setProperty, range=[20.,120.], xcoord_conv=x_nr
x_axis_top -> setProperty, range=[20.,120.], xcoord_conv=x_nr
window -> draw, scene

end