PLplot
5.10.0
|
00001 // Maurice LeBrun 00002 // 6-May-93 00003 // 00004 // A miscellaneous assortment of Tcl support functions. 00005 // 00006 // 00007 // Copyright (C) 2004 Joao Cardoso 00008 // 00009 // This file is part of PLplot. 00010 // 00011 // PLplot is free software; you can redistribute it and/or modify 00012 // it under the terms of the GNU Library General Public License as published 00013 // by the Free Software Foundation; either version 2 of the License, or 00014 // (at your option) any later version. 00015 // 00016 // PLplot is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU Library General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU Library General Public License 00022 // along with PLplot; if not, write to the Free Software 00023 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00024 // 00025 00026 #include "plserver.h" 00027 00028 //-------------------------------------------------------------------------- 00029 // Pltk_Init 00030 // 00031 // Initialization routine for extended wish'es. 00032 // Creates the plframe, matrix, wait_until, and host_id (w/Tcl-DP only) 00033 // commands. Also sets the auto_path variable. 00034 //-------------------------------------------------------------------------- 00035 00036 int 00037 Pltk_Init( Tcl_Interp *interp ) 00038 { 00039 Tk_Window main; 00040 00041 main = Tk_MainWindow( interp ); 00042 00043 // plframe -- PLplot graphing widget 00044 00045 Tcl_CreateCommand( interp, "plframe", (Tcl_CmdProc *) plFrameCmd, 00046 (ClientData) main, (Tcl_CmdDeleteProc *) NULL ); 00047 00048 // matrix -- matrix support command 00049 00050 Tcl_CreateCommand( interp, "matrix", (Tcl_CmdProc *) Tcl_MatrixCmd, 00051 (ClientData) main, (Tcl_CmdDeleteProc *) NULL ); 00052 00053 // wait_until -- waits for a specific condition to arise 00054 // Can be used with either Tcl-DP or TK 00055 00056 Tcl_CreateCommand( interp, "wait_until", (Tcl_CmdProc *) plWait_Until, 00057 (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL ); 00058 00059 // host_id -- returns host IP number. Only for use with Tcl-DP 00060 00061 #ifdef PLD_dp 00062 Tcl_CreateCommand( interp, "host_id", (Tcl_CmdProc *) plHost_ID, 00063 (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL ); 00064 #endif 00065 00066 // Set up auto_path 00067 00068 if ( pls_auto_path( interp ) == TCL_ERROR ) 00069 return TCL_ERROR; 00070 00071 // Save initial RGB colormap components 00072 // Disabled for now 00073 00074 #if 0 00075 { 00076 Display *display; 00077 Colormap map; 00078 00079 display = Tk_Display( main ); 00080 map = DefaultColormap( display, DefaultScreen( display ) ); 00081 00082 // Convert this to use esc function if it's going to be used 00083 // SaveColormap(display, map); 00084 } 00085 #endif 00086 return TCL_OK; 00087 } 00088 00089 //-------------------------------------------------------------------------- 00090 // plWait_Until 00091 // 00092 // Tcl command -- wait until the specified condition is satisfied. 00093 // Processes all events while waiting. 00094 // 00095 // This command is more capable than tkwait, and has the added benefit 00096 // of working with Tcl-DP as well. Example usage: 00097 // 00098 // wait_until {[info exists foobar]} 00099 // 00100 // Note the [info ...] command must be protected by braces so that it 00101 // isn't actually evaluated until passed into this routine. 00102 //-------------------------------------------------------------------------- 00103 00104 int 00105 plWait_Until( ClientData clientData, Tcl_Interp *interp, int argc, char **argv ) 00106 { 00107 int result = 0; 00108 00109 dbug_enter( "plWait_Until" ); 00110 00111 for (;; ) 00112 { 00113 if ( Tcl_ExprBoolean( interp, argv[1], &result ) ) 00114 { 00115 fprintf( stderr, "wait_until command \"%s\" failed:\n\t %s\n", 00116 argv[1], Tcl_GetStringResult( interp ) ); 00117 break; 00118 } 00119 if ( result ) 00120 break; 00121 00122 Tk_DoOneEvent( 0 ); 00123 } 00124 return TCL_OK; 00125 }