The bottom four layers combine to make an executable program which contains an extended Tcl interpreter. Some of these extensions are general and provided by the alpha_1 library libTCL.a but others can be specific to the application.
To make an application out of this program, a set of tcl commands is interpreted at startup time. There are various ways of packaging up such applications (see below).
The most basic extension to the Tcl interpreter is the a1canvas command which creates a Tk widget that is a wrapper on the Alpha_1 display list window dl_window_type.
Other Tcl extensions are provided for the mi_type remote client interface to c_shape_edit and for applications that link the c_shape_edit library (libModel.a) directly into the application.
A1wish is the most basic and is meant to be analogous to the standard Tcl/Tk wish program. Here is the main program:
#includeA1wish is used as follows:#include #include #include /****************************************************************************** * TAG( a1wish ) */ void main( int argc, char **argv ) { /* Check for Alpha1 display device command line args first. */ override_display_device( NULL, argc, argv ); Tk_Main( argc, argv, tcl_app_init ); exit( 0 ); }
a1wish [tclfile] [-displaymode x11] [wish options] cat gui.tcl | a1wish ...By using the Tk_Main routine from the Tk library, a1wish has the same command line options that the standard wish program does. A tcl file can be provided as the first argument or on stdin (like the "cat" example above). If a tcl file is provided (by file name or on stdin), the application reads and interprets the tcl file and then closes stdin. If no tcl file is provided, the application runs the Tcl interpreter interactively on the terminal.
The -displaymode option is an Alpha_1 option provided by the override_display function. The tcl_app_init function is provided by libTCL and creates the standard a1canvas Tcl commands.
As long as the set of Tcl command extensions is sufficient, the a1wish executable can be used to implement various interfaces and applications by just providing the Tcl code that defines the interface. Such applications can be installed by checking in the tcl file and setting the makefile variable TCLPROGRAMS. This uses the install-tcl-pgms script to install a csh script that runs a1wish with the tcl file provided on the standard input. However, many applications need application specific Tcl command extensions in addition to the standard "a1canvas" related commands.
#includeThe first difference is that tk3d uses a different install strategy. Tk3d uses the libTCL functions tcl_file_to_load and create_tcl_interp to load a predetermined tcl file at startup instead of having a csh script run the interpreter and feed it a Tcl file. This looks more like a standard application. The X resource application name is the name of the executable and the class is set to "A1wish" so common X defaults can be set. This setup implements the following command line options:#include #include #include static int app_init( Tcl_Interp *interp ); /****************************************************************************** * TAG( tk3d ) */ void main( int argc, char **argv ) { /* Check for tcl file to load. Default is $b$datatcl/tk3d.tcl. */ string_type tcl_file = tcl_file_to_load( "tk3d.tcl", argc, argv ); /* Check for Alpha1 display device command line args first. */ override_display_device( NULL, argc, argv ); a1_app_init_fn = app_init; /* If there is a tcl file to read, load it. */ if ( tcl_file ) { if ( create_tcl_interp( argc, argv, tcl_file ) != TCL_OK ) { eprintf( "Error in Tcl initialization file.\n" ); exit( 1 ); } Tk_MainLoop(); /* No tcl top-loop. */ } else /* Run the tcl interpreter top-loop. */ Tk_Main( argc, argv, tcl_app_init ); exit( 0 ); } /**************************************************************** * TAG( app_init ) */ static int app_init( Tcl_Interp *interp ) { return tcl_mi_init( interp ); }
tk3d [gui.tcl | -tcl] [-displaymode x11] ... If there is no first argument (a tcl file or -tcl), then the default interface is loaded from $b$datatcl/tk3d.tcl. Does not run the Tcl toploop. tk3d -tcl ... - runs the Tcl/Tk interpreter without loading any tcl file. tk3d gui.tcl ... - Loads the file gui.tcl and does not run the Tcl/Tk toploop.This is a more flexible setup, especially for applications that might want to run their own toploop (like c_shape_edit), but still be able to run the Tcl toploop for development purposes.
The other difference from a1wish is that tk3d sets the global:
a1_app_init_fn = app_init;This is a function pointer defined in the libTCL library. If set, this function is called at the end of the library tcl_app_init function to add application specific Tcl initialization. In this case we add the Tcl dl_mi command which allows tk3d to control connections to a remote c_shape_edit process (ala motif3d).
... static int app_init( Tcl_Interp *interp ); /***************************************************************** * TAG( shape3d ) */ void main( int argc, char **argv ) { ... /* If there is a tcl file to read, load it and then run the * c_shape_edit interpreter top-loop. */ if ( tcl_file ) { if ( create_tcl_interp( argc, argv, tcl_file ) != TCL_OK ) { eprintf( "Error in Tcl initialization file.\n" ); exit( 1 ); } /* Stdin file handler feeds c_shape_edit toploop. */ Tk_CreateFileHandler( 0, TK_READABLE, scl_handle_stdin, NULL ); model_obj::print_banner(); /* Print initial prompt. */ Tk_MainLoop(); } else /* Run the tcl interpreter top-loop. */ Tk_Main( argc, argv, tcl_app_init ); /* Never returns. */ exit( 0 ); }This main program uses the command line arguments to either run the c_shape_edit toploop or the Tcl toploop. The options are the same as tk3d, but when there is a tcl file to load, it is loaded and then the c_shape_edit toploop is run (by using Tk_CreateFileHandler).
The fsketch main program is similar to shape3d but has additional application specific initializations.