View3d.sml

  Download

More scripts: Dialog

Syntax Highlighing:

comments, key words, predefined symbols, class members & methods, functions & classes
            
################################################################
#
#	VIEW3D.SML
#
#	Demonstration SML script 
#
#	Requires a tntdisp dated 3-Feb-98 or later
#
################################################################
class XmForm form;			# The main form dialog
raster Composite, Elevation;
class GRE_VIEW3D view;
class GRE_LAYER_RASTER layer, surflayer;		# Our base layer
class PushButtonItem button1, button2;
class XmForm button_row;
class GRE_GROUP group;
#
#	Callback for when "Exit" is pressed
#
proc cbQuit(class widget widget) {
	DialogClose(form);
	}
#
#	Callback for when "Controls" is pressed
#
proc cbControls(class widget widget) {
	ViewOpen3DControls(view);
	}
#####################################################
#
#	MAIN PROGRAM
#
GetInputRasters(Composite, Elevation);
form = CreateModalFormDialog("test");
button1 = CreatePushButtonItem("Controls", cbControls);
button2 = CreatePushButtonItem("Exit", cbQuit);
button_row = CreateButtonRow(form, button1, button2);
button_row.BottomWidget = form;
#	Create a group to display the raster in and quick-add it.
group = DispCreate2DGroup();	# It's the view that makes it 3D
surflayer = GroupQuickAddRasterVar(group, Elevation, 1);
layer = GroupQuickAddRasterVar(group, Composite);
#	Create a 3D view for this group in our form.  
numeric height, width;
height = NumLins(Composite);
width = NumCols(Composite);
while (height > 700 or width > 1000) {
	height /= 2;
	width /= 2;
	}
view = GroupCreate3DView(group, form, "view", height, width);
form.BottomWidget = button_row;
#view.ScalePosVisible = 0;
View3DReadPosIni(view, "3dpos");
#	Open the dialog.
DialogOpen(form);
ViewRedraw(view);
#	Wait for the dialog to close. 
DialogWaitForClose(form);
#
#	Destroy our form to free up its memory.  
#
View3DWritePosIni(view, "3dpos");
ViewDestroy(view);
GroupDestroy(group);
DestroyWidget(form);