STx 3.9 Documentation

Up

Graph Examples

Previous

Graph Examples

Next

Cursor Script Example

Graph Script Example

A basic script displaying an x/y plot.

/*++ Macro: gui_basic_example Descriptions: Creates a basic graphical user interface, Parameters: #standalone Set to 1 if the script is running on it's own (i.e. not called by another script). This is the default. Otherwise set to 0. Author: Jonnie White History: 2006-11-13 First implemented 2007-10-04 Dialog button now toggles function color --*/ [macro gui_basic_example #standalone=1] // // create display, graph and dialog // theDisplay := new display * 'Display Title' 1 /Dialog=Above if '$theDisplay[?]' != 'display' then em -1 ; display creation failed ($emsg) end theGraph := new graph * 1 $theDisplay 0 0 if '$theGraph[?]' != 'graph' then em -1 ; graph creation failed ($emsg) end theDialog := new menu * $theDisplay if '$theDialog[?]' != 'menu' then em -1 ; dialog creation failed ($emsg) end // // generate some data // #nValues := 100 #vector := eval fill($#nValues,0,1) mySpu := new spu * table2output $#vector 1 0 1 /n if '$mySpu[?]' != 'spu' then em -1 ; spu creation failed ($emsg) end // // configure graph // $theGraph xscale 0 $#nValues-1 '' 'X' $theGraph yscale 0 $#nValues-1 '' 'Y' $theGraph y 0 $mySpu.x0 xyplot 1 green lines solid 2 $theGraph x $mySpu.x0 /Apply // // run spu, sending data to graph // $mySpu run 1 // return if this is not a standalone call // caller should clean up if '$#standalone' != 1 exit 1 // // show the dialog and display // $theDialog $theDialog[!controls] button 0 0 'Toggle function color' $theDialog enabled restored $theDisplay enabled restored 100 100 800 800 // // process messages until display is close // by the user // setmsghandler display $theDisplay gui_basic_example_mh // // process dialog messages too // setmsghandler menu $theDialog gui_basic_example_mh AppMode := 1 do while '$AppMode' != '0' GetMessage end setmsghandler display $theDisplay // // clean up // delete $theGraph $theDisplay $theDialog $mySpu exit [MACRO gui_basic_example_mh #objtype #objname #msgid #msgpar] if '$#objtype' == display || '$#objtype' == shell then if '$#msgid' == Close || '$#msgId' == Exit then AppMode := 0 end else if '$#objtype' == 'menu' then if '$#msgid' == 'command' && '$#msgpar' == '0' then // toggle function color fColor := COND '$fColor' == 'green' || '$fColor' == '' ? 'blue' : 'green' $theGraph y 0 * * * $fColor * * * /Apply end end exit 1

© 2009 The Austrian Academy of Sciences Acoustics Research Institute