; docformat = 'rst' ;+ ; Create view containing a the surface object. ; ; :Returns: ; view object ; ; :Params: ; z : in, optional, type="fltarr(m, n)" ; surface data to show ; ; :Keywords: ; datax : in, optional, type=fltarr(m) ; x-coordinate values ; datay : in, optional, type=fltarr(n) ; y-coordinate values ; model : out, optional, type=object ; model created to contain the surface ; location : in, optional, type=fltarr(2), default="[0.0, 0.0]" ; property of IDLgrView ; dimensions : in, optional, type=fltarr(2), default="[1.0, 1.0]" ; property of IDLgrView ; isotropic : in, optional, type=boolean ; set to use an isotropic scale, otherwise each dimension will be scaled ; to fill the display range ;- function mg_ogscene_example_createview, z, datax=datax, datay=datay, model=model, $ location=location, dimensions=dimensions, $ isotropic=isotropic compile_opt strictarr view = obj_new('IDLgrView', location=location, dimensions=dimensions, units=3) model = obj_new('IDLgrModel') view->add, model surf = obj_new('IDLgrSurface', z, datax=datax, datay=datay, style=2, $ color=[140, 14, 15], bottom=[60, 6, 6]) model->add, surf lightmodel = obj_new('IDLgrModel') view->add, lightmodel dirLight = obj_new('IDLgrLight', type=2, location=[-1, 1, 1]) lightmodel->add, dirLight ambLight = obj_new('IDLgrLight', type=0, intensity=0.4) lightmodel->add, ambLight m = 0.95 surf->getProperty, xrange=xr, yrange=yr, zrange=zr maxRange = (xr[1] - xr[0]) > (yr[1] - yr[0]) > (zr[1] - zr[0]) if (keyword_set(isotropic)) then begin xc = mg_linear_function([-0.5, 0.5] * maxRange + (xr[0] + xr[1]) / 2.0, [-m, m]) yc = mg_linear_function([-0.5, 0.5] * maxRange + (yr[0] + yr[1]) / 2.0, [-m, m]) zc = mg_linear_function([-0.5, 0.5] * maxRange + (zr[0] + zr[1]) / 2.0, [-m, m]) endif else begin xc = mg_linear_function(xr, [-m, m]) yc = mg_linear_function(yr, [-m, m]) zc = mg_linear_function(zr, [-m, m]) endelse surf->setProperty, xcoord_conv=xc, ycoord_conv=yc, zcoord_conv=zc return, view end ;+ ; Example of using a scene to show multiple views. ; ; :Params: ; z : in, optional, type="fltarr(m, n)" ; surface data to show ; x : in, optional, type=fltarr(m) ; x-coordinate values ; y : in, optional, type=fltarr(n) ; y-coordinate values ; ; :Keywords: ; isotropic : in, optional, type=boolean ; set to use an isotropic scale, otherwise each dimension will be scaled ; to fill the display range ;- pro mg_ogscene_example, z, x, y, isotropic=isotropic compile_opt strictarr _z = n_elements(z) eq 0L ? hanning(20, 20) : z dimensions = [0.5, 0.5] scene = obj_new('IDLgrScene') view1 = mg_ogscene_example_createview(_z, datax=x, datay=y, $ model=model1, isotropic=isotropic, $ location=[0.0, 0.5], $ dimensions=dimensions) scene->add, view1 view2 = mg_ogscene_example_createview(_z, datax=x, datay=y, $ model=model2, isotropic=isotropic, $ location=[0.5, 0.5], $ dimensions=dimensions) scene->add, view2 model2->rotate, [1, 0, 0], -90 view3 = mg_ogscene_example_createview(_z, datax=x, datay=y, $ model=model3, isotropic=isotropic, $ location=[0.0, 0.0], $ dimensions=dimensions) scene->add, view3 model3->rotate, [1, 0, 0], -90 model3->rotate, [0, 1, 0], 90 view4 = mg_ogscene_example_createview(_z, datax=x, datay=y, $ model=model4, isotropic=isotropic, $ location=[0.5, 0.0], $ dimensions=dimensions) scene->add, view4 model4->rotate, [1, 0, 0], -90 model4->rotate, [0, 1, 0], -30 model4->rotate, [1, 0, 0], 45 win = obj_new('IDLgrWindow', dimensions=[500, 500], graphics_tree=scene, $ title='Example of using a scene to show multiple views') win->draw end restore, filename=filepath('marbells.dat', subdir=['examples', 'data']), /verbose mg_ogscene_example, elev end