PLplot  5.10.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Plplotter_Init.c
Go to the documentation of this file.
1 // $Id: Plplotter_Init.c 12688 2013-11-13 06:30:19Z airwin $
2 //
3 // Copyright (C) 2004 Joao Cardoso
4 //
5 // This file is part of PLplot.
6 //
7 // PLplot is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU Library General Public License as published
9 // by the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
11 //
12 // PLplot is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Library General Public License for more details.
16 //
17 // You should have received a copy of the GNU Library General Public License
18 // along with PLplot; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 //
21 // This file is derived from the old tkshell.c, and implements the Pltk init
22 // function. It can be loaded into any Tcl7.5 interpreter, and requires some
23 // .tcl library files to be in known places. Set your environment variables
24 // to make sure of this.
25 //
26 // Old changes see 'tkshell.c'. This file should be used _instead_ of
27 // tkshell.c, if building the 'libPltk.so' shared library for dynamic loading
28 // into Tcl.
29 //
30 
31 //
32 // tkshell.c
33 // Maurice LeBrun
34 // 6-May-93
35 //
36 // A miscellaneous assortment of Tcl support functions.
37 //
38 
39 #include "plserver.h"
40 
41 #ifdef BUILD_Plplot
42 #undef TCL_STORAGE_CLASS
43 #define TCL_STORAGE_CLASS DLLEXPORT
44 #endif // BUILD_Vfs
45 
46 //--------------------------------------------------------------------------
47 // Plplotter_Init
48 //
49 // Initialization routine for extended wish'es.
50 // Creates the plframe, wait_until, and host_id (w/Tcl-DP only)
51 // commands. The more basic Plplot-Tcl initialization is handled by
52 // the Plbasicinit function called from here.
53 //--------------------------------------------------------------------------
54 
55 PLDLLIMPEXP_DRIVER EXTERN int
56 Plplotter_Init( Tcl_Interp *interp )
57 {
58  // This must be before any other Tcl related calls
59  if ( PlbasicInit( interp ) != TCL_OK )
60  {
61  return TCL_ERROR;
62  }
63 
64 #ifdef USE_TK_STUBS
65  //
66  // We hard-wire 8.1 here (as is done for the USE_TCL_STUBS case in
67  // PlbasisInit above) rather than TK_VERSION because we really don't
68  // mind which version of Tcl, Tk we use as long as it is 8.1 or
69  // newer. Otherwise if we compiled against 8.2, we couldn't be
70  // loaded into 8.1
71  //
72  Tk_InitStubs( interp, "8.1", 0 );
73 #endif
74  //
75  // Note, the old technique of:
76  // main = Tk_MainWindow(interp);
77  // and then passing main to 'plframe' as the clientdata can
78  // cause unusual problems, probably due to bugs in Tk on
79  // some platforms, when the 'main window' doesn't yet exist
80  // properly by the time we are called. Since plframe only
81  // uses the value in one place (each time a new frame is
82  // created), we simply use 'Tk_MainWindow' in plframe, and
83  // avoid the startup problems.
84  //
85 
86 // plframe -- PLplot graphing widget
87 
88  Tcl_CreateCommand( interp, "plframe", (Tcl_CmdProc *) plPlotterCmd,
89  (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL );
90 
91  Tcl_PkgProvide( interp, "Plplotter", PLPLOT_VERSION );
92  return TCL_OK;
93 }
94