More scripts: Dialog
Syntax Highlighing:
comments, key words, predefined symbols, class members & methods, functions & classes
# Modified version of VIEW.SML to open and display RGB raster
# Dan Glasser 12June03
# Updated: Dave Breitwisch 1 November 2006
# Define class instances used in procedures.
class GRE_GROUP gp; # spatial group for display.
class XmForm vwin; # parent form for window.
class RASTER Comp;
string temppath$;
# Define procedure to close window.
# Called when user clicks on the "X" close button on the title bar.
proc OnClose(class widget widget) {
DestroyWidget(vwin);
GroupDestroy(gp);
}
# Called when dialog is destroyed.
# Can be either by the "Close" menu item or by us
# calling DestroyWidget() above.
proc OnDestroy() {
CloseRaster(Comp);
DeleteFile(temppath$);
Exit();
}
# Main program
class RASTER RED, GREEN, BLUE;
GetInputRasters(RED, GREEN, BLUE);
class RASTER R, G, B;
CreateTempRaster(R, NumLins(RED), NumCols(RED), "8-bit unsigned", 0);
CreateTempRaster(G, NumLins(GREEN), NumCols(GREEN), "8-bit unsigned", 0);
CreateTempRaster(B, NumLins(BLUE), NumCols(BLUE), "8-bit unsigned", 0);
RasterApplyContrast2(RED,R,"Normalize");
RasterApplyContrast2(GREEN,G,"Normalize");
RasterApplyContrast2(BLUE,B,"Normalize");
#string path$ = "c:/tnt/data/cb_tm.rvc";
temppath$ = CreateTempFileName();
RasterRGBToComposite(R, G, B, Comp, temppath$, "Comp", "24-bit composite rgb created in SML", 24); # 24-bit comp
CloseRaster(RED);
CloseRaster(GREEN);
CloseRaster(BLUE);
# Create group to be shown in View window.
gp = GroupCreate();
# Create parent form for View and add callbacks
# for procedures defined above.
vwin = CreateFormDialog("Sample View Window");
WidgetAddCallback(vwin.Shell.PopdownCallback, OnClose);
WidgetAddCallback(vwin.DestroyCallback, OnDestroy);
# Create view to display the group.
class GRE_VIEW view;
view = GroupCreateView(gp,vwin,"",360,280,"NoScalePosLine,DestroyOnClose");
class GRE_LAYER_RASTER layer;
layer = GroupQuickAddRasterVar(gp,Comp); # Add raster to group.
DialogOpen(vwin); # Open view and redraw full.
ViewRedrawFull(view);
WaitForExit();