PLplot  5.10.0
ntk.c
Go to the documentation of this file.
00001 // Experimental tk driver using a plain "wish"
00002 //
00003 // Copyright (C) 2001  Joao Cardoso
00004 // Copyright (C) 2004  Rafael Laboissiere
00005 //
00006 // This file is part of PLplot.
00007 //
00008 // PLplot is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU Library General Public License as published
00010 // by the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // PLplot is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU Library General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU Library General Public License
00019 // along with PLplot; if not, write to the Free Software
00020 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00021 //
00022 //
00023 
00024 #include "plDevs.h"
00025 
00026 #ifdef PLD_ntk
00027 
00028 #include "plplotP.h"
00029 #include "drivers.h"
00030 #include "plevent.h"
00031 
00032 #include <tk.h>
00033 
00034 // Device info
00035 PLDLLIMPEXP_DRIVER const char* plD_DEVICE_INFO_ntk = "ntk:New tk driver:1:ntk:43:ntk\n";
00036 
00037 
00038 void plD_dispatch_init_ntk( PLDispatchTable *pdt );
00039 
00040 void plD_init_ntk( PLStream * );
00041 void plD_line_ntk( PLStream *, short, short, short, short );
00042 void plD_polyline_ntk( PLStream *, short *, short *, PLINT );
00043 void plD_eop_ntk( PLStream * );
00044 void plD_bop_ntk( PLStream * );
00045 void plD_tidy_ntk( PLStream * );
00046 void plD_state_ntk( PLStream *, PLINT );
00047 void plD_esc_ntk( PLStream *, PLINT, void * );
00048 
00049 void plD_dispatch_init_ntk( PLDispatchTable *pdt )
00050 {
00051 #ifndef ENABLE_DYNDRIVERS
00052     pdt->pl_MenuStr = "New Tk device";
00053     pdt->pl_DevName = "ntk";
00054 #endif
00055     pdt->pl_type     = plDevType_Interactive;
00056     pdt->pl_seq      = 43;
00057     pdt->pl_init     = (plD_init_fp) plD_init_ntk;
00058     pdt->pl_line     = (plD_line_fp) plD_line_ntk;
00059     pdt->pl_polyline = (plD_polyline_fp) plD_polyline_ntk;
00060     pdt->pl_eop      = (plD_eop_fp) plD_eop_ntk;
00061     pdt->pl_bop      = (plD_bop_fp) plD_bop_ntk;
00062     pdt->pl_tidy     = (plD_tidy_fp) plD_tidy_ntk;
00063     pdt->pl_state    = (plD_state_fp) plD_state_ntk;
00064     pdt->pl_esc      = (plD_esc_fp) plD_esc_ntk;
00065 }
00066 
00067 // hardwired window size
00068 #define XPIXELS    600
00069 #define YPIXELS    400
00070 
00071 static PLFLT      scale = 10.0;   // Tk canvas units are in pixels, giving corse curves, fool plplot, and scale down when sending to tk
00072 static PLFLT      ppm;            // device pixels per mm
00073 
00074 static Tcl_Interp *interp = NULL; // tcl interpreter
00075 static Tk_Window  mainw;          // tk main window
00076 
00077 static char       curcolor[80];   // current color in #rrggbb notation
00078 
00079 // 12000 is large enough to satisfy example 27 needs without
00080 // erroring out in plD_polyline_ntk.  Quadruple that to be conservative.
00081 #define PLPLOT_NTK_CMD_SIZE    48000
00082 static char cmd[PLPLOT_NTK_CMD_SIZE]; // buffer to build command to interp
00083 static int  ccanv = 0;                // current canvas number
00084 static char base[80];                 // name of frame that contains the canvas
00085 static char dash[80];                 // dash string, as <mark space>*
00086 
00087 // line buffering
00088 #define NPTS    1000
00089 static short xold = -1, yold = -1; // last point of last 2 points line
00090 static short xb[NPTS], yb[NPTS];   // buffer
00091 static int   curpts = 0;           // current number of points buffered
00092 
00093 static int   local = 1;            // "local" or "remote" interpreter
00094 static char  rem_interp[80];       // name of remote interp
00095 
00096 // physical devices coordinates
00097 static PLINT xmin = 0;
00098 static PLINT xmax = XPIXELS;
00099 static PLINT ymin = 0;
00100 static PLINT ymax = YPIXELS;
00101 
00102 // locator
00103 static PLGraphicsIn gin;
00104 
00105 static void
00106 tk_cmd( const char *gcmd )
00107 {
00108     static char scmd[PLPLOT_NTK_CMD_SIZE];
00109 
00110     if ( local )
00111         Tcl_Eval( interp, gcmd );
00112     else
00113     {
00114         // the -async option makes it block, some times! but is *much* faster!
00115         // and was working OK till now :(
00116         // sprintf(scmd, "send -async %s {%s}", rem_interp, cmd);
00117         //
00118         sprintf( scmd, "send %s {%s}", rem_interp, gcmd ); // mess! make it more efficient
00119         if ( Tcl_Eval( interp, scmd ) != TCL_OK )
00120             fprintf( stderr, "%s\n", Tcl_GetStringResult( interp ) );
00121     }
00122 }
00123 
00124 static void
00125 create_canvas( PLStream *pls )
00126 {
00127     int columnbreak;
00128 
00129     ccanv++;
00130     columnbreak = ( ccanv % 30 == 0 );
00131 
00132     // create new canvas
00133     sprintf( cmd, "set ccanv %d; canvas $plf.f2.c$ccanv -width $xmax -height $ymax -background #%02x%02x%02x -xscrollcommand \"$hs set\" -yscrollcommand \"$vs set\" -scrollregion \"0 0 $xmax $ymax\"", ccanv, pls->cmap0[0].r, pls->cmap0[0].g, pls->cmap0[0].b );
00134     tk_cmd( cmd );
00135 
00136     // add new canvas to option menu
00137     sprintf( cmd, "$plf.f1.mb.menu add command -label \"Page $ccanv\" -columnbreak %d -command {\n"
00138         "set w $plf.f2.c%d;\n"
00139         "$hs configure -command \"$w xview\";\n"
00140         "$vs configure -command \"$w yview\";\n"
00141         "set dname \"Page %d\";\n"
00142         "pack forget $ocanvas;\n"
00143         "set ocanvas $plf.f2.c%d;\n"
00144         "pack $ocanvas -fill both -expand 1;\n"
00145         "scan [$w xview] \"%%f %%f\" i j;\n"
00146         "$hs set $i $j;\n"
00147         "scan [$w yview] \"%%f %%f\" i j;\n"
00148         "$vs set $i $j;}",
00149         columnbreak, ccanv, ccanv, ccanv );
00150     tk_cmd( cmd );
00151 
00152     sprintf( cmd, "set item(%d) 0", ccanv );
00153     tk_cmd( cmd );
00154 
00155     // Shif-B1, zooms in
00156     // FIXME inform the core lib of the zoom, see plframe.c around line 2818
00157 
00158     sprintf( cmd, "bind $plf.f2.c$ccanv <Shift-Button-1> {\n"
00159         "set cc %d;\n"
00160         "incr item($cc); set tt $item($cc);\n"
00161         "if {$tt == 1} {\n"
00162         "incr scroll_use;\n"
00163         "pack $hs -side bottom -fill x;\n"
00164         "pack $vs -side right -fill y;\n"
00165         "pack forget %%W; pack %%W -fill both -expand 1}\n"
00166         "set zx($cc,$tt) %%x;\n"
00167         "set zy($cc,$tt) %%y;\n"
00168         "%%W scale all %%x %%y 1.6 1.6;\n"
00169         "%%W configure -scrollregion [%%W bbox all];\n"
00170         "}", ccanv );
00171 
00172     tk_cmd( cmd );
00173 
00174     // Shif-B3, zooms out
00175     sprintf( cmd, "bind $plf.f2.c$ccanv <Shift-Button-3> {\n"
00176         "set cc %d; set tt $item($cc);\n"
00177         "if {$tt != 0} {\n"
00178         "%%W scale all $zx($cc,$tt) $zy($cc,$tt) 0.625 0.625\n"
00179         "%%W configure -scrollregion [%%W bbox all];\n"
00180         "set item($cc) [expr $tt - 1]}\n"
00181         "if { $item($cc) == 0} {\n"
00182         "set scroll_use [expr $scroll_use - 1];\n"
00183         "if {$scroll_use == 0} {\n"
00184         "pack forget $plf.f2.hscroll $plf.f2.vscroll}\n"
00185         "%%W configure -scrollregion \"0 0 $xmax $ymax\"}}", ccanv );
00186     tk_cmd( cmd );
00187 
00188     // Shift-B2, resets
00189     sprintf( cmd, "bind $plf.f2.c$ccanv <Shift-Button-2> {\n"
00190         "set cc %d; set tt $item($cc); \n"
00191         "while {$tt != 0} {\n"
00192         "%%W scale all $zx($cc,$tt) $zy($cc,$tt) 0.625 0.625\n"
00193         "set tt [expr $tt - 1]};\n"
00194         "set item($cc) 0;\n"
00195         "%%W configure -scrollregion \"0 0 $xmax $ymax\";\n"
00196         "set scroll_use [expr $scroll_use - 1];\n"
00197         "if {$scroll_use == 0} {\n"
00198         "pack forget $plf.f2.hscroll $plf.f2.vscroll}}", ccanv );
00199     tk_cmd( cmd );
00200 
00201     // Control-B1-Motion, pan
00202     sprintf( cmd, "bind $plf.f2.c$ccanv <Control-Button-1> \"$plf.f2.c%d scan mark %%x %%y\"", ccanv );
00203     tk_cmd( cmd );
00204 
00205     sprintf( cmd, "bind $plf.f2.c$ccanv <Control-Button1-Motion> \"$plf.f2.c%d scan dragto %%x %%y\"", ccanv );
00206     tk_cmd( cmd );
00207 
00208     // Control-B2, identify and (in the far future) edit object
00209     tk_cmd( "bind $plf.f2.c$ccanv <Control-Button-2> {\n"
00210         "set xx [ expr [winfo pointerx .] - [winfo rootx %W]];\n"
00211         "set yy [ expr [winfo pointery .] - [winfo rooty %W]];\n"
00212         "set near [%W find closest $xx $yy];\n"
00213         "%W move $near 20 20;\n"
00214         "after 500 \"%W move $near -20 -20\"}" );
00215 
00216     // change view to the new canvas by invoking the menu buttom
00217     sprintf( cmd, "$plf.f1.mb.menu invoke %d", ccanv - 1 );
00218     tk_cmd( cmd );
00219 }
00220 
00221 //--------------------------------------------------------------------------
00222 // plD_init_ntk()
00223 //
00224 // Initialize device (terminal).
00225 //--------------------------------------------------------------------------
00226 
00227 void
00228 plD_init_ntk( PLStream *pls )
00229 {
00230     pls->dev_fill0   = 1;        // Handle solid fills
00231     pls->dev_fill1   = 1;        // Driver handles pattern fills
00232     pls->color       = 1;        // Is a color device
00233     pls->dev_dash    = 1;        // Handle dashed lines
00234     pls->plbuf_write = 1;        // Use plot buffer
00235 
00236     strcpy( curcolor, "black" ); // default color by name, not #rrggbb
00237 
00238     if ( pls->server_name != NULL )
00239     {
00240         local = 0;
00241         strcpy( rem_interp, pls->server_name );
00242     }
00243 
00244     if ( pls->geometry != NULL )
00245         sscanf( pls->geometry, "%dx%d", &xmax, &ymax );
00246 
00247 //  if ( pls->plwindow != NULL )
00248 //        strcpy( base, pls->plwindow );
00249 //    else
00250     strcpy( base, ".plf" );     // default frame containing the canvas
00251 
00252     interp = Tcl_CreateInterp();
00253 
00254     if ( Tcl_Init( interp ) != TCL_OK )
00255         plexit( "Unable to initialize Tcl." );
00256 
00257     if ( Tk_Init( interp ) )
00258         plexit( "Unable to initialize Tk." );
00259 
00260     mainw = Tk_MainWindow( interp );
00261     Tcl_Eval( interp, "rename exec {}" );
00262 
00263     Tcl_Eval( interp, "tk appname PLplot_ntk" ); // give interpreter a name
00264 
00265     if ( !local )
00266     {
00267         Tcl_Eval( interp, "wm withdraw ." );
00268 
00269         sprintf( cmd, "send %s \"set client [tk appname]; wm deiconify .\"", rem_interp );
00270         if ( Tcl_Eval( interp, cmd ) != TCL_OK )
00271         {
00272             fprintf( stderr, "%s\n", Tcl_GetStringResult( interp ) );
00273             plexit( "No such tk server." );
00274         }
00275     }
00276 
00277     sprintf( cmd, "set scroll_use 0; set plf %s; set vs $plf.f2.vscroll; set hs $plf.f2.hscroll; set xmax %d; set ymax %d; set ocanvas .;", base, xmax, ymax );
00278     tk_cmd( cmd );
00279 
00280     tk_cmd( "catch \"frame $plf\"; pack $plf -fill both -expand 1" );
00281 
00282     sprintf( cmd, "frame $plf.f1;\n"
00283         "frame $plf.f2 -width %d -height %d;\n"
00284         "pack $plf.f1 -fill x;\n"
00285         "pack $plf.f2 -fill both -expand 1", xmax, ymax );
00286     tk_cmd( cmd );
00287 
00288     tk_cmd( "scrollbar $plf.f2.hscroll -orient horiz;\n"
00289         "scrollbar $plf.f2.vscroll" );
00290 
00291     tk_cmd( "menubutton $plf.f1.mb -text \"Page 1\" -textvariable dname -relief raised -indicatoron 1 -menu $plf.f1.mb.menu;\n"
00292         "menu $plf.f1.mb.menu -tearoff 0;\n"
00293         "pack $plf.f1.mb -side left" );
00294 
00295     if ( local )
00296         tk_cmd( "button $plf.f1.quit -text Quit -command exit;\n"
00297             "pack $plf.f1.quit -side right" );
00298     else
00299         tk_cmd( "button $plf.f1.quit -text Quit -command {send -async $client exit;\n"
00300             "destroy $plf;\n"
00301             "wm withdraw .};\n"
00302             "pack $plf.f1.quit -side right" );
00303 
00304     // FIXME: I just discovered that Tcl_Eval is slower than Tcl_EvalObj. Fix it global-wide, `man Tcl_Eval'
00305 
00306     // Set up device parameters
00307 
00308     Tcl_Eval( interp, "tk scaling" ); // pixels per mm
00309     ppm = (PLFLT) atof( Tcl_GetStringResult( interp ) ) / ( 25.4 / 72. );
00310     plP_setpxl( ppm, ppm );
00311     plP_setphy( xmin, (PLINT) ( xmax * scale ), ymin, (PLINT) ( ymax * scale ) );
00312 
00313     tk_cmd( "update" );
00314 }
00315 
00316 static void
00317 flushbuffer( PLStream *pls )
00318 {
00319     if ( curpts )
00320     {
00321         plD_polyline_ntk( pls, xb, yb, curpts );
00322 // if (curpts != 2) fprintf(stderr,"%d ", curpts);
00323         xold = yold = -1; curpts = 0;
00324     }
00325 }
00326 
00327 void
00328 plD_line_ntk( PLStream *pls, short x1a, short y1a, short x2a, short y2a )
00329 {
00330     if ( xold == x1a && yold == y1a )
00331     {
00332         xold = xb[curpts] = x2a; yold = yb[curpts] = y2a; curpts++;
00333     }
00334     else
00335     {
00336         flushbuffer( pls );
00337         xb[curpts] = x1a; yb[curpts] = y1a; curpts++;
00338         xold       = xb[curpts] = x2a; yold = yb[curpts] = y2a; curpts++;
00339     }
00340 
00341     if ( curpts == NPTS )
00342     {
00343         //fprintf( stderr, "\nflush: %d ", curpts );
00344         flushbuffer( pls );
00345     }
00346 }
00347 
00348 void
00349 plD_polyline_ntk( PLStream * PL_UNUSED( pls ), short *xa, short *ya, PLINT npts )
00350 {
00351     PLINT i, j;
00352 
00353     // there must exist a way to code this using the tk C API
00354     j = sprintf( cmd, "$plf.f2.c%d create line ", ccanv );
00355     for ( i = 0; i < npts; i++ )
00356     {
00357         // To be completely safe, assume 5 characters to the left of the
00358         // decimal point ==> 2*(5+3) characters written per sprintf
00359         // call.
00360         if ( ( j + 16 ) > PLPLOT_NTK_CMD_SIZE )
00361             plexit( "plD_polyline_ntk: too many x, y values to hold in static cmd array" );
00362         j += sprintf( &cmd[j], "%.1f %.1f ", xa[i] / scale, ymax - ya[i] / scale );
00363     }
00364     j += sprintf( &cmd[j], " -fill %s", curcolor );
00365     if ( dash[0] == '-' )
00366         j += sprintf( &cmd[j], " %s", dash );
00367 
00368     tk_cmd( cmd );
00369 }
00370 
00371 // an event loop has to be designed, getcursor() and waitforpage() are just experimental
00372 
00373 static void
00374 waitforpage( PLStream * PL_UNUSED( pls ) )
00375 {
00376     int key = 0, st = 0;
00377     // why can't I bind to the canvas? or even any frame?
00378 //tk_cmd("bind . <KeyPress> {set keypress %N; puts \"\n%k-%A-%K-%N\"}");
00379     tk_cmd( "bind . <KeyPress> {set keypress %N}" );
00380 
00381     while ( ( key & 0xff ) != PLK_Return && ( key & 0xff ) != PLK_Linefeed && key != PLK_Next && key != 'Q' )
00382     {
00383         while ( st != 1 )
00384         {
00385             tk_cmd( "update" );
00386             tk_cmd( "info exists keypress" );
00387             sscanf( Tcl_GetStringResult( interp ), "%d", &st );
00388         }
00389 
00390         tk_cmd( "set keypress" );
00391         sscanf( Tcl_GetStringResult( interp ), "%d", &key );
00392 //fprintf(stderr,"\n%d\n", key);fflush(stderr);
00393         tk_cmd( "unset keypress" );
00394         st = 0;
00395     }
00396 
00397     tk_cmd( "bind . <Key> {};" );
00398 }
00399 
00400 void
00401 plD_eop_ntk( PLStream *pls )
00402 {
00403     flushbuffer( pls );
00404     tk_cmd( "update" );
00405 }
00406 
00407 void
00408 plD_bop_ntk( PLStream *pls )
00409 {
00410     create_canvas( pls );
00411 }
00412 
00413 void
00414 plD_tidy_ntk( PLStream *pls )
00415 {
00416     if ( !pls->nopause )
00417         waitforpage( pls );
00418 
00419     tk_cmd( "destroy $plf; wm withdraw ." );
00420 }
00421 
00422 void
00423 plD_state_ntk( PLStream *pls, PLINT op )
00424 {
00425     switch ( op )
00426     {
00427     case PLSTATE_COLOR0:
00428     case PLSTATE_COLOR1:
00429         flushbuffer( pls );
00430         sprintf( curcolor, "#%02x%02x%02x",
00431             pls->curcolor.r, pls->curcolor.g, pls->curcolor.b );
00432         break;
00433     }
00434 }
00435 
00436 static void
00437 getcursor( PLStream * PL_UNUSED( pls ), PLGraphicsIn *ptr )
00438 {
00439     int st = 0;
00440 
00441     plGinInit( &gin );
00442 
00443     if ( 0 )
00444     {
00445         while ( st != 1 )
00446         {
00447             tk_cmd( "update" );
00448             tk_cmd( "winfo exists $plf.f2.c$ccanv" );
00449             sscanf( Tcl_GetStringResult( interp ), "%d", &st );
00450         }
00451         st = 0;
00452         // this give a "Segmentation fault", even after checking for the canvas!
00453         tk_cmd( "set ocursor [lindex [$plf.f2.c$ccanv configure -cursor] 4]" );
00454     }
00455 
00456     tk_cmd( "$plf.f2.c$ccanv configure -cursor cross;\n"
00457         "bind $plf.f2.c$ccanv <Button> {set xloc %x; set yloc %y; set bloc %b; set sloc %s};\n"
00458         "bind $plf.f2.c$ccanv <B1-Motion> {set xloc %x; set yloc %y; set bloc %b; set sloc %s};\n"
00459         "bind $plf.f2.c$ccanv <B2-Motion> {set xloc %x; set yloc %y; set bloc %b; set sloc %s};\n"
00460         "bind $plf.f2.c$ccanv <B3-Motion> {set xloc %x; set yloc %y; set bloc %b; set sloc %s};" );
00461 
00462     while ( st != 1 )
00463     {
00464         tk_cmd( "update" );
00465         tk_cmd( "info exists xloc" );
00466         sscanf( Tcl_GetStringResult( interp ), "%d", &st );
00467     }
00468     tk_cmd( "set xloc" );
00469     sscanf( Tcl_GetStringResult( interp ), "%d", &gin.pX );
00470     tk_cmd( "set yloc" );
00471     sscanf( Tcl_GetStringResult( interp ), "%d", &gin.pY );
00472     tk_cmd( "set bloc" );
00473     sscanf( Tcl_GetStringResult( interp ), "%ud", &gin.button );
00474     tk_cmd( "set sloc" );
00475     sscanf( Tcl_GetStringResult( interp ), "%ud", &gin.state );
00476 
00477     gin.dX = (PLFLT) gin.pX / xmax;
00478     gin.dY = 1. - (PLFLT) gin.pY / ymax;
00479 
00480     tk_cmd( "bind $plf.f2.c$ccanv <ButtonPress> {};\n"
00481         "bind $plf.f2.c$ccanv <ButtonMotion> {};\n"
00482         "bind $plf.f2.c$ccanv <B2-Motion> {};\n"
00483         "bind $plf.f2.c$ccanv <B3-Motion> {};\n"
00484         "unset xloc" );
00485 
00486     // seg fault, see above. tk_cmd("$plf.f2.c$ccanv configure -cursor $ocursor");
00487     tk_cmd( "$plf.f2.c$ccanv configure -cursor {}" );
00488 
00489     *ptr = gin;
00490 }
00491 
00492 void
00493 plD_esc_ntk( PLStream *pls, PLINT op, void *ptr )
00494 {
00495     PLINT i, j;
00496     short *xa, *ya;
00497     //Pixmap bitmap;
00498     static const unsigned char bit_pat[] = {
00499         0x24, 0x01, 0x92, 0x00, 0x49, 0x00, 0x24, 0x00, 0x12, 0x00, 0x09, 0x00,
00500         0x04, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
00501         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff
00502     };
00503 
00504     switch ( op )
00505     {
00506     case PLESC_DASH:
00507         xa = (short *) malloc( sizeof ( short ) * (size_t) pls->dev_npts );
00508         ya = (short *) malloc( sizeof ( short ) * (size_t) pls->dev_npts );
00509         for ( i = 0; i < pls->dev_npts; i++ )
00510         {
00511             xa[i] = pls->dev_x[i];
00512             ya[i] = pls->dev_y[i];
00513         }
00514 
00515         j = sprintf( dash, "-dash {" );
00516         for ( i = 0; i < pls->nms; i++ )
00517             j += sprintf( &dash[j], " %d %d",
00518                 (int) ceil( pls->mark[i] / 1e3 * ppm ),
00519                 (int) ceil( pls->space[i] / 1e3 * ppm ) );
00520         sprintf( &dash[j], "}" );
00521         plD_polyline_ntk( pls, xa, ya, pls->dev_npts );
00522         free( xa ); free( ya );
00523         dash[0] = 0;
00524         break;
00525 
00526     case PLESC_FLUSH:
00527         tk_cmd( "update" );
00528         break;
00529 
00530     case PLESC_GETC:
00531         getcursor( pls, (PLGraphicsIn *) ptr );
00532         break;
00533 
00534     case PLESC_FILL:
00535         if ( pls->patt != 0 )
00536         {
00537             // this is a hack! The real solution is in the if(0) below
00538             pls->xpmm *= scale;
00539             pls->ypmm *= scale;
00540             plfill_soft( pls->dev_x, pls->dev_y, pls->dev_npts );
00541             pls->xpmm /= scale;
00542             pls->ypmm /= scale;
00543         }
00544         else
00545         {
00546             j = sprintf( cmd, "$plf.f2.c%d create polygon ", ccanv );
00547             for ( i = 0; i < pls->dev_npts; i++ )
00548                 j += sprintf( &cmd[j], "%.1f %.1f ", pls->dev_x[i] / scale,
00549                     ymax - pls->dev_y[i] / scale );
00550             j += sprintf( &cmd[j], " -fill %s", curcolor );
00551             tk_cmd( cmd );
00552         }
00553 
00554         if ( 0 )
00555         {
00556             if ( pls->patt != 0 )
00557             {
00558                 Tk_DefineBitmap( interp, Tk_GetUid( "foo" ), (const char *) bit_pat, 16, 16 );
00559                 //bitmap = Tk_GetBitmap( interp, mainw, Tk_GetUid( "patt" ) );
00560             }
00561             j = sprintf( cmd, "$plf.f2.c%d create polygon ", ccanv );
00562             for ( i = 0; i < pls->dev_npts; i++ )
00563                 j += sprintf( &cmd[j], "%.1f %.1f ", pls->dev_x[i] / scale,
00564                     ymax - pls->dev_y[i] / scale );
00565             j += sprintf( &cmd[j], " -fill %s", curcolor );
00566             if ( pls->patt != 0 )
00567                 sprintf( &cmd[j], " -stipple patt -outline black" );
00568 
00569             tk_cmd( cmd );
00570             //Tk_FreeBitmap(display, bitmap)
00571         }
00572         break;
00573     }
00574 }
00575 
00576 #else
00577 int
00578 pldummy_ntk()
00579 {
00580     return 0;
00581 }
00582 
00583 #endif                          // PLD_ntkdev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines