36 #ifdef PL_HAVE_UNISTD_H
41 #define getcwd _getcwd
50 static int loopbackCmd( ClientData, Tcl_Interp *,
int,
const char ** );
51 static int plcolorbarCmd( ClientData, Tcl_Interp *,
int,
const char ** );
52 static int plcontCmd( ClientData, Tcl_Interp *,
int,
const char ** );
53 static int pllegendCmd( ClientData, Tcl_Interp *,
int,
const char ** );
54 static int plmeshCmd( ClientData, Tcl_Interp *,
int,
const char ** );
55 static int plmeshcCmd( ClientData, Tcl_Interp *,
int,
const char ** );
56 static int plot3dCmd( ClientData, Tcl_Interp *,
int,
const char ** );
57 static int plot3dcCmd( ClientData, Tcl_Interp *,
int,
const char ** );
58 static int plsurf3dCmd( ClientData, Tcl_Interp *,
int,
const char ** );
59 static int plsurf3dlCmd( ClientData, Tcl_Interp *,
int,
const char ** );
60 static int plsetoptCmd( ClientData, Tcl_Interp *,
int,
const char ** );
61 static int plshadeCmd( ClientData, Tcl_Interp *,
int,
const char ** );
62 static int plshadesCmd( ClientData, Tcl_Interp *,
int,
const char ** );
63 static int plmapCmd( ClientData, Tcl_Interp *,
int,
const char ** );
64 static int plmapfillCmd( ClientData, Tcl_Interp *,
int,
const char ** );
65 static int plmaplineCmd( ClientData, Tcl_Interp *,
int,
const char ** );
66 static int plmapstringCmd( ClientData, Tcl_Interp *,
int,
const char ** );
67 static int plmaptexCmd( ClientData, Tcl_Interp *,
int,
const char ** );
68 static int plmeridiansCmd( ClientData, Tcl_Interp *,
int,
const char ** );
69 static int plstransformCmd( ClientData, Tcl_Interp *,
int,
const char ** );
70 static int plsvectCmd( ClientData, Tcl_Interp *,
int,
const char ** );
71 static int plvectCmd( ClientData, Tcl_Interp *,
int,
const char ** );
72 static int plranddCmd( ClientData, Tcl_Interp *,
int,
const char ** );
73 static int plgriddataCmd( ClientData, Tcl_Interp *,
int,
const char ** );
74 static int plimageCmd( ClientData, Tcl_Interp *,
int,
const char ** );
75 static int plimagefrCmd( ClientData, Tcl_Interp *,
int,
const char ** );
76 static int plstripcCmd( ClientData, Tcl_Interp *,
int,
const char ** );
77 static int plslabelfuncCmd( ClientData, Tcl_Interp *,
int,
const char ** );
89 int ( *
proc )(
void *,
struct Tcl_Interp *, int,
const char ** );
100 int ( *proc )(
void *,
struct Tcl_Interp *, int,
const char ** );
151 #define PL_LIBRARY ""
156 #if ( !defined ( MAC_TCL ) && !defined ( __WIN32__ ) )
162 #define PLPLOT_EXTENDED_SEARCH
181 static int inited = 0;
182 static const char** namelist;
183 int i, j, ncmds =
sizeof (
Cmds ) /
sizeof (
CmdInfo );
187 namelist = (
const char **) malloc( (
size_t) ncmds *
sizeof (
char * ) );
189 for ( i = 0; i < ncmds; i++ )
190 namelist[i] = Cmds[i].
name;
194 for ( i = 0; i < ncmds - 1; i++ )
195 for ( j = i + 1; j < ncmds - 1; j++ )
197 if ( strcmp( namelist[i], namelist[j] ) > 0 )
199 const char *t = namelist[i];
200 namelist[i] = namelist[j];
208 for ( i = 0; i < ncmds; i++ )
209 Tcl_AppendResult( interp,
" ", namelist[i], (
char *) NULL );
233 Tcl_InitHashTable( &
cmdTable, TCL_STRING_KEYS );
237 for ( cmdInfoPtr = Cmds; cmdInfoPtr->
name != NULL; cmdInfoPtr++ )
242 hPtr = Tcl_CreateHashEntry( &
cmdTable, cmdInfoPtr->
name, &
new );
250 Tcl_SetHashValue( hPtr, cmdPtr );
279 register Tcl_HashEntry *hPtr;
296 Tcl_AppendResult( interp, cmdlist, (
char *) NULL );
303 hPtr = Tcl_FindHashEntry( &
cmdTable, argv[0] );
306 Tcl_AppendResult( interp,
"bad option \"", argv[0],
307 "\" to \"cmd\": must be one of ",
308 cmdlist, (
char *) NULL );
315 result = ( *cmdPtr->
proc )( cmdPtr->
clientData, interp, argc, argv );
316 if ( result == TCL_OK )
321 Tcl_AppendResult( interp,
errmsg, (
char *) NULL );
347 register Tcl_HashEntry *hPtr;
351 if ( argc == 0 || ( strcmp( argv[0],
"cmd" ) != 0 ) )
353 Tcl_AppendResult( interp,
"bad option \"", argv[0],
354 "\" to \"loopback\": must be ",
355 "\"cmd ?options?\" ", (
char *) NULL );
378 hPtr = Tcl_FindHashEntry( &
cmdTable, argv[0] );
381 Tcl_AppendResult( interp,
"bad option \"", argv[0],
382 "\" to \"loopback cmd\": must be one of ",
390 result = ( *cmdPtr->
proc )( cmdPtr->
clientData, interp, argc, argv );
408 int debug = plsc->debug;
409 const char *libDir = NULL;
410 static char initScript[] =
411 "tcl_findLibrary plplot " PLPLOT_VERSION " \"\" plplot.tcl PL_LIBRARY pllibrary";
412 #ifdef PLPLOT_EXTENDED_SEARCH
413 static char initScriptExtended[] =
414 "tcl_findLibrary plplot " PLPLOT_VERSION "/tcl \"\" plplot.tcl PL_LIBRARY pllibrary";
424 Tcl_InitStubs( interp,
"8.1", 0 );
431 fprintf( stderr,
"error in matrix init\n" );
442 #ifdef USE_MATRIX_STUBS
443 if ( Matrix_InitStubs( interp,
"0.1", 0 ) == NULL )
446 fprintf( stderr,
"error in matrix stubs init\n" );
450 Tcl_PkgRequire( interp,
"Matrix",
"0.1", 0 );
454 Tcl_SetVar( interp,
"plversion",
PLPLOT_VERSION, TCL_GLOBAL_ONLY );
457 Tcl_SetVar( interp,
"pl_itcl_package_name",
"Itcl 4", TCL_GLOBAL_ONLY );
459 Tcl_SetVar( interp,
"pl_itcl_package_name",
"Itcl 3", TCL_GLOBAL_ONLY );
464 Tcl_SetVar( interp,
"pl_itcl_package_name",
"Itcl(because_not_found_by_PLplot)", TCL_GLOBAL_ONLY );
467 Tcl_SetVar( interp,
"pl_itk_package_name",
"Itk 4", TCL_GLOBAL_ONLY );
469 Tcl_SetVar( interp,
"pl_itk_package_name",
"Itk 3", TCL_GLOBAL_ONLY );
474 Tcl_SetVar( interp,
"pl_itk_package_name",
"Itk(because_not_found_by_PLplot)", TCL_GLOBAL_ONLY );
477 Tcl_SetVar( interp,
"pl_iwidgets_package_name",
"Iwidgets 4", TCL_GLOBAL_ONLY );
484 Tcl_SetVar( interp,
"pl_iwidgets_package_name",
"Iwidgets(because_not_found_by_PLplot)", TCL_GLOBAL_ONLY );
495 fprintf( stderr,
"trying BUILD_DIR\n" );
497 Tcl_SetVar( interp,
"pllibrary", libDir, TCL_GLOBAL_ONLY );
498 if ( Tcl_Eval( interp, initScript ) != TCL_OK )
501 Tcl_UnsetVar( interp,
"pllibrary", TCL_GLOBAL_ONLY );
502 Tcl_ResetResult( interp );
507 if ( libDir == NULL )
510 fprintf( stderr,
"trying init script\n" );
511 if ( Tcl_Eval( interp, initScript ) != TCL_OK )
514 Tcl_UnsetVar( interp,
"pllibrary", TCL_GLOBAL_ONLY );
516 Tcl_ResetResult( interp );
519 libDir = Tcl_GetVar( interp,
"pllibrary", TCL_GLOBAL_ONLY );
524 if ( libDir == NULL )
527 fprintf( stderr,
"trying TCL_DIR\n" );
529 Tcl_SetVar( interp,
"pllibrary", libDir, TCL_GLOBAL_ONLY );
530 if ( Tcl_Eval( interp, initScript ) != TCL_OK )
533 Tcl_UnsetVar( interp,
"pllibrary", TCL_GLOBAL_ONLY );
534 Tcl_ResetResult( interp );
539 #ifdef PLPLOT_EXTENDED_SEARCH
541 if ( libDir == NULL )
544 fprintf( stderr,
"trying extended init script\n" );
545 if ( Tcl_Eval( interp, initScriptExtended ) != TCL_OK )
548 Tcl_UnsetVar( interp,
"pllibrary", TCL_GLOBAL_ONLY );
550 Tcl_ResetResult( interp );
553 libDir = Tcl_GetVar( interp,
"pllibrary", TCL_GLOBAL_ONLY );
557 if ( libDir == NULL )
561 fprintf( stderr,
"trying curdir\n" );
562 if ( Tcl_Access(
"plplot.tcl", 0 ) != 0 )
565 fprintf( stderr,
"couldn't find plplot.tcl in curdir\n" );
570 libDir = Tcl_GetCwd( interp, &ds );
571 if ( libDir == NULL )
574 fprintf( stderr,
"couldn't get curdir\n" );
578 Tcl_DStringFree( &ds );
579 Tcl_SetVar( interp,
"pllibrary", libDir, TCL_GLOBAL_ONLY );
581 if ( Tcl_EvalFile( interp,
"plplot.tcl" ) != TCL_OK )
584 fprintf( stderr,
"error evalling plplot.tcl\n" );
590 if ( libDir == NULL )
593 fprintf( stderr,
"libdir NULL at end of search\n" );
603 Tcl_CreateCommand( interp,
"wait_until", (Tcl_CmdProc *)
plWait_Until,
604 (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL );
627 Tcl_AppendResult( interp,
"Could not find plplot.tcl - please set \
628 environment variable PL_LIBRARY to the directory containing that file",
640 for ( cmdInfoPtr = Cmds; cmdInfoPtr->
name != NULL; cmdInfoPtr++ )
642 Tcl_CreateCommand( interp, cmdInfoPtr->
name, cmdInfoPtr->
proc,
643 (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL );
677 if ( Tcl_ExprBoolean( interp, argv[1], &result ) )
679 fprintf( stderr,
"wait_until command \"%s\" failed:\n\t %s\n",
680 argv[1], Tcl_GetStringResult( interp ) );
706 int debug = plsc->debug;
707 char *
buf, *ptr = NULL, *dn;
713 buf = (
char *) malloc( 256 *
sizeof (
char ) );
719 fprintf( stderr,
"adding %s to auto_path\n",
TCL_DIR );
720 Tcl_SetVar( interp,
"dir",
TCL_DIR, TCL_GLOBAL_ONLY );
721 if (
tcl_cmd( interp,
"set auto_path [linsert $auto_path 0 $dir]" ) == TCL_ERROR )
723 return_code = TCL_ERROR;
727 path = Tcl_GetVar( interp,
"auto_path", 0 );
728 fprintf( stderr,
"auto_path is %s\n", path );
734 if ( ( dn = getenv(
"HOME" ) ) != NULL )
737 Tcl_SetVar( interp,
"dir", ptr, 0 );
738 if (
tcl_cmd( interp,
"set auto_path [linsert $auto_path 0 $dir]" ) == TCL_ERROR )
740 return_code = TCL_ERROR;
744 fprintf( stderr,
"adding %s to auto_path\n", ptr );
745 path = Tcl_GetVar( interp,
"auto_path", 0 );
746 fprintf( stderr,
"auto_path is %s\n", path );
752 #if defined ( PL_TCL_ENV )
753 if ( ( dn = getenv( PL_TCL_ENV ) ) != NULL )
756 Tcl_SetVar( interp,
"dir", ptr, 0 );
757 if (
tcl_cmd( interp,
"set auto_path [linsert $auto_path 0 $dir]" ) == TCL_ERROR )
759 return_code = TCL_ERROR;
763 fprintf( stderr,
"adding %s to auto_path\n", ptr );
764 path = Tcl_GetVar( interp,
"auto_path", 0 );
765 fprintf( stderr,
"auto_path is %s\n", path );
772 #if defined ( PL_HOME_ENV )
773 if ( ( dn = getenv( PL_HOME_ENV ) ) != NULL )
776 Tcl_SetVar( interp,
"dir", ptr, 0 );
777 if (
tcl_cmd( interp,
"set auto_path [linsert $auto_path 0 $dir]" ) == TCL_ERROR )
779 return_code = TCL_ERROR;
783 fprintf( stderr,
"adding %s to auto_path\n", ptr );
784 path = Tcl_GetVar( interp,
"auto_path", 0 );
785 fprintf( stderr,
"auto_path is %s\n", path );
788 #endif // PL_HOME_ENV
792 if ( getcwd( buf, 256 ) == 0 )
794 Tcl_SetResult( interp,
"Problems with getcwd in pls_auto_path", TCL_STATIC );
796 return_code = TCL_ERROR;
800 Tcl_SetVar( interp,
"dir", buf, 0 );
801 if (
tcl_cmd( interp,
"set auto_path [linsert $auto_path 0 $dir]" ) == TCL_ERROR )
803 return_code = TCL_ERROR;
809 Tcl_SetVar( interp,
"dir",
BUILD_DIR "/bindings/tk", TCL_GLOBAL_ONLY );
810 if (
tcl_cmd( interp,
"set auto_path [linsert $auto_path 0 $dir]" ) == TCL_ERROR )
812 return_code = TCL_ERROR;
818 fprintf( stderr,
"adding %s to auto_path\n", buf );
819 path = Tcl_GetVar( interp,
"auto_path", 0 );
820 fprintf( stderr,
"auto_path is %s\n", path );
840 result = Tcl_VarEval( interp, cmd, (
char **) NULL );
841 if ( result != TCL_OK )
843 fprintf( stderr,
"TCL command \"%s\" failed:\n\t %s\n",
844 cmd, Tcl_GetStringResult( interp ) );
914 PLINT nx, ny, kx = 0, lx = 0, ky = 0, ly = 0, nclev;
915 const char *pltrname =
"pltr0";
916 tclMatrix *mattrx = NULL, *mattry = NULL;
917 PLFLT **z, **zused, **zwrapped;
919 int arg3_is_kx = 1, i, j;
929 Tcl_AppendResult( interp,
"wrong # args: see documentation for ",
930 argv[0], (
char *) NULL );
938 if ( matf->
dim != 2 )
940 Tcl_SetResult( interp,
"Must use 2-d data.", TCL_STATIC );
947 tclmateval_modx = nx;
948 tclmateval_mody = ny;
953 for ( i = 0; i < nx; i++ )
955 for ( j = 0; j < ny; j++ )
965 for ( i = 0; i < (int) strlen( argv[2] ) && arg3_is_kx; i++ )
966 if ( !isdigit( argv[2][i] ) )
974 Tcl_SetResult( interp,
"plcont, bogus syntax", TCL_STATIC );
979 kx = atoi( argv[3] );
980 lx = atoi( argv[4] );
981 ky = atoi( argv[5] );
982 ly = atoi( argv[6] );
985 argc -= 6, argv += 6;
989 argc -= 2, argv += 2;
996 Tcl_SetResult( interp,
"plcont, bogus syntax", TCL_STATIC );
1001 if ( matclev == NULL )
1003 nclev = matclev->
n[0];
1005 if ( matclev->
dim != 1 )
1007 Tcl_SetResult( interp,
"clev must be 1-d matrix.", TCL_STATIC );
1020 if ( mattrx == NULL )
1023 if ( mattry == NULL )
1026 argc -= 3, argv += 3;
1032 wrap = atoi( argv[0] );
1044 Tcl_SetResult( interp,
"plcont, bogus syntax, too many args.", TCL_STATIC );
1050 if ( !strcmp( pltrname,
"pltr0" ) )
1058 Tcl_SetResult( interp,
"Must use pltr2 if want wrapping.", TCL_STATIC );
1062 else if ( !strcmp( pltrname,
"pltr1" ) )
1067 cgrid1.
yg = mattry->fdata;
1074 Tcl_SetResult( interp,
"Must use pltr2 if want wrapping.", TCL_STATIC );
1078 if ( mattrx->
dim != 1 || mattry->dim != 1 )
1080 Tcl_SetResult( interp,
"Must use 1-d coord arrays with pltr1.", TCL_STATIC );
1084 pltr_data = &cgrid1;
1086 else if ( !strcmp( pltrname,
"pltr2" ) )
1099 for ( i = 0; i < nx; i++ )
1100 for ( j = 0; j < ny; j++ )
1101 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
1104 for ( i = 0; i < nx; i++ )
1105 for ( j = 0; j < ny; j++ )
1106 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
1108 else if ( wrap == 1 )
1118 for ( i = 0; i < nx; i++ )
1119 for ( j = 0; j < ny; j++ )
1120 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
1123 for ( i = 0; i < nx; i++ )
1125 for ( j = 0; j < ny; j++ )
1127 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
1128 zwrapped[i][j] = z[i][j];
1132 for ( j = 0; j < ny; j++ )
1134 cgrid2.
xg[nx][j] = cgrid2.
xg[0][j];
1135 cgrid2.
yg[nx][j] = cgrid2.
yg[0][j];
1136 zwrapped[nx][j] = zwrapped[0][j];
1145 else if ( wrap == 2 )
1155 for ( i = 0; i < nx; i++ )
1156 for ( j = 0; j < ny; j++ )
1157 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
1160 for ( i = 0; i < nx; i++ )
1162 for ( j = 0; j < ny; j++ )
1164 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
1165 zwrapped[i][j] = z[i][j];
1169 for ( i = 0; i < nx; i++ )
1171 cgrid2.
xg[i][ny] = cgrid2.
xg[i][0];
1172 cgrid2.
yg[i][ny] = cgrid2.
yg[i][0];
1173 zwrapped[i][ny] = zwrapped[i][0];
1184 Tcl_SetResult( interp,
"Invalid wrap specifier, must be <empty>, 0, 1, or 2.", TCL_STATIC );
1189 pltr_data = &cgrid2;
1193 Tcl_AppendResult( interp,
1194 "Unrecognized coordinate transformation spec:",
1195 pltrname,
", must be pltr0 pltr1 or pltr2.",
1213 plcont( (
const PLFLT *
const *) zused, nx, ny,
1215 matclev->
fdata, nclev,
1257 || ( strcmp( argv[1],
"NULL" ) == 0 ) && ( strcmp( argv[2],
"NULL" ) == 0 ) )
1263 else if ( argc != 4 )
1265 Tcl_AppendResult( interp,
"wrong # args: see documentation for ",
1266 argv[0], (
char *) NULL );
1274 if ( matx->
dim != 1 )
1276 Tcl_SetResult( interp,
"plsvect: Must use 1-d data.", TCL_STATIC );
1285 if ( maty->
dim != 1 )
1287 Tcl_SetResult( interp,
"plsvect: Must use 1-d data.", TCL_STATIC );
1291 if ( maty->
n[0] != npts )
1293 Tcl_SetResult( interp,
"plsvect: Arrays must be of equal length", TCL_STATIC );
1297 fill = (
PLBOOL) atoi( argv[3] );
1314 const char *pltrname =
"pltr0";
1315 tclMatrix *mattrx = NULL, *mattry = NULL;
1316 PLFLT **u, **v, **uused, **vused, **uwrapped, **vwrapped;
1329 Tcl_AppendResult( interp,
"wrong # args: see documentation for ",
1330 argv[0], (
char *) NULL );
1338 if ( matu->
dim != 2 )
1340 Tcl_SetResult( interp,
"Must use 2-d data.", TCL_STATIC );
1347 tclmateval_modx = nx;
1348 tclmateval_mody = ny;
1353 for ( i = 0; i < nx; i++ )
1355 for ( j = 0; j < ny; j++ )
1366 if ( matv->
dim != 2 )
1368 Tcl_SetResult( interp,
"Must use 2-d data.", TCL_STATIC );
1375 tclmateval_modx = nx;
1376 tclmateval_mody = ny;
1381 for ( i = 0; i < nx; i++ )
1383 for ( j = 0; j < ny; j++ )
1390 argc -= 3, argv += 3;
1396 Tcl_SetResult( interp,
"plvect, bogus syntax", TCL_STATIC );
1400 scaling = atof( argv[0] );
1410 if ( mattrx == NULL )
1413 if ( mattry == NULL )
1416 argc -= 3, argv += 3;
1422 wrap = atoi( argv[0] );
1434 Tcl_SetResult( interp,
"plvect, bogus syntax, too many args.", TCL_STATIC );
1440 if ( !strcmp( pltrname,
"pltr0" ) )
1449 Tcl_SetResult( interp,
"Must use pltr2 if want wrapping.", TCL_STATIC );
1453 else if ( !strcmp( pltrname,
"pltr1" ) )
1458 cgrid1.
yg = mattry->fdata;
1466 Tcl_SetResult( interp,
"Must use pltr2 if want wrapping.", TCL_STATIC );
1470 if ( mattrx->
dim != 1 || mattry->dim != 1 )
1472 Tcl_SetResult( interp,
"Must use 1-d coord arrays with pltr1.", TCL_STATIC );
1476 pltr_data = &cgrid1;
1478 else if ( !strcmp( pltrname,
"pltr2" ) )
1492 for ( i = 0; i < nx; i++ )
1493 for ( j = 0; j < ny; j++ )
1494 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
1496 for ( i = 0; i < nx; i++ )
1498 for ( j = 0; j < ny; j++ )
1500 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
1504 else if ( wrap == 1 )
1517 for ( i = 0; i < nx; i++ )
1518 for ( j = 0; j < ny; j++ )
1519 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
1522 for ( i = 0; i < nx; i++ )
1524 for ( j = 0; j < ny; j++ )
1526 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
1527 uwrapped[i][j] = u[i][j];
1528 vwrapped[i][j] = v[i][j];
1532 for ( j = 0; j < ny; j++ )
1534 cgrid2.
xg[nx][j] = cgrid2.
xg[0][j];
1535 cgrid2.
yg[nx][j] = cgrid2.
yg[0][j];
1536 uwrapped[nx][j] = uwrapped[0][j];
1537 vwrapped[nx][j] = vwrapped[0][j];
1546 else if ( wrap == 2 )
1558 for ( i = 0; i < nx; i++ )
1559 for ( j = 0; j < ny; j++ )
1560 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
1563 for ( i = 0; i < nx; i++ )
1565 for ( j = 0; j < ny; j++ )
1567 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
1568 uwrapped[i][j] = u[i][j];
1569 vwrapped[i][j] = v[i][j];
1573 for ( i = 0; i < nx; i++ )
1575 cgrid2.
xg[i][ny] = cgrid2.
xg[i][0];
1576 cgrid2.
yg[i][ny] = cgrid2.
yg[i][0];
1577 uwrapped[i][ny] = uwrapped[i][0];
1578 vwrapped[i][ny] = vwrapped[i][0];
1590 Tcl_SetResult( interp,
"Invalid wrap specifier, must be <empty>, 0, 1, or 2.", TCL_STATIC );
1595 pltr_data = &cgrid2;
1599 Tcl_AppendResult( interp,
1600 "Unrecognized coordinate transformation spec:",
1601 pltrname,
", must be pltr0 pltr1 or pltr2.",
1609 plvect( (
const PLFLT *
const *) uused, (
const PLFLT *
const *) vused, nx, ny,
1610 scaling,
pltr, pltr_data );
1663 nx = atoi( argv[4] );
1664 ny = atoi( argv[5] );
1665 opt = atoi( argv[6] );
1682 Tcl_SetResult( interp,
"x y and z must all be float", TCL_STATIC );
1686 if ( matx->
dim != 1 || matx->
n[0] != nx ||
1687 maty->
dim != 1 || maty->
n[0] != ny ||
1688 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny )
1690 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
1697 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
1698 for ( i = 0; i < nx; i++ )
1699 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
1701 else if ( argc == 5 )
1703 opt = atoi( argv[4] );
1720 Tcl_SetResult( interp,
"x y and z must all be float", TCL_STATIC );
1724 nx = matx->
n[0]; ny = maty->
n[0];
1726 if ( matx->
dim != 1 || matx->
n[0] != nx ||
1727 maty->
dim != 1 || maty->
n[0] != ny ||
1728 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny )
1730 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
1737 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
1738 for ( i = 0; i < nx; i++ )
1739 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
1741 else if ( argc == 3 )
1743 Tcl_SetResult( interp,
"unimplemented", TCL_STATIC );
1748 Tcl_AppendResult( interp,
"wrong # args: should be \"plmesh ",
1749 "x y z nx ny opt\", or a valid contraction ",
1750 "thereof.", (
char *) NULL );
1754 plmesh( x, y, (
const PLFLT *
const *) z, nx, ny, opt );
1760 else if ( argc == 5 )
1794 PLINT nx, ny, opt, nlev = 10;
1798 tclMatrix *matx, *maty, *matz, *matPtr, *matlev;
1803 nlev = atoi( argv[8] );
1804 nx = atoi( argv[4] );
1805 ny = atoi( argv[5] );
1806 opt = atoi( argv[6] );
1820 if ( matlev == NULL )
1828 Tcl_SetResult( interp,
"x y z and clevel must all be float", TCL_STATIC );
1832 if ( matx->
dim != 1 || matx->
n[0] != nx ||
1833 maty->
dim != 1 || maty->
n[0] != ny ||
1834 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny ||
1835 matlev->
dim != 1 || matlev->
n[0] != nlev )
1837 Tcl_SetResult( interp,
"popo Inconsistent dimensions", TCL_STATIC );
1843 clev = matlev->
fdata;
1845 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
1846 for ( i = 0; i < nx; i++ )
1847 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
1850 else if ( argc == 8 )
1852 nx = atoi( argv[4] );
1853 ny = atoi( argv[5] );
1854 opt = atoi( argv[6] );
1867 if ( matlev == NULL )
1875 Tcl_SetResult( interp,
"x y z and clevel must all be float", TCL_STATIC );
1879 if ( matx->
dim != 1 || matx->
n[0] != nx ||
1880 maty->
dim != 1 || maty->
n[0] != ny ||
1881 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny ||
1882 matlev->
dim != 1 || matlev->
n[0] != nlev )
1884 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
1890 clev = matlev->
fdata;
1891 nlev = matlev->
n[0];
1893 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
1894 for ( i = 0; i < nx; i++ )
1895 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
1898 else if ( argc == 7 )
1900 nx = atoi( argv[4] );
1901 ny = atoi( argv[5] );
1902 opt = atoi( argv[6] );
1920 Tcl_SetResult( interp,
"x y and z must all be float", TCL_STATIC );
1924 if ( matx->
dim != 1 || matx->
n[0] != nx ||
1925 maty->
dim != 1 || maty->
n[0] != ny ||
1926 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny )
1928 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
1935 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
1936 for ( i = 0; i < nx; i++ )
1937 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
1939 else if ( argc == 5 )
1941 opt = atoi( argv[4] );
1959 Tcl_SetResult( interp,
"x y and z must all be float", TCL_STATIC );
1963 nx = matx->
n[0]; ny = maty->
n[0];
1965 if ( matx->
dim != 1 || matx->
n[0] != nx ||
1966 maty->
dim != 1 || maty->
n[0] != ny ||
1967 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny )
1969 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
1976 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
1977 for ( i = 0; i < nx; i++ )
1978 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
1980 else if ( argc == 3 )
1982 Tcl_SetResult( interp,
"unimplemented", TCL_STATIC );
1987 Tcl_AppendResult( interp,
"wrong # args: should be \"plmeshc ",
1988 "x y z nx ny opt clevel nlevel\", or a valid contraction ",
1989 "thereof.", (
char *) NULL );
1993 plmeshc( x, y, (
const PLFLT *
const *) z, nx, ny, opt, clev, nlev );
1999 else if ( argc == 5 )
2030 PLINT nx, ny, opt, side;
2037 nx = atoi( argv[4] );
2038 ny = atoi( argv[5] );
2039 opt = atoi( argv[6] );
2040 side = atoi( argv[7] );
2057 Tcl_SetResult( interp,
"x y and z must all be float", TCL_STATIC );
2061 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2062 maty->
dim != 1 || maty->
n[0] != ny ||
2063 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny )
2065 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
2072 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2073 for ( i = 0; i < nx; i++ )
2074 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2076 else if ( argc == 6 )
2078 opt = atoi( argv[4] );
2079 side = atoi( argv[5] );
2096 Tcl_SetResult( interp,
"x y and z must all be float", TCL_STATIC );
2100 nx = matx->
n[0]; ny = maty->
n[0];
2102 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2103 maty->
dim != 1 || maty->
n[0] != ny ||
2104 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny )
2106 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
2113 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2114 for ( i = 0; i < nx; i++ )
2115 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2117 else if ( argc == 4 )
2119 Tcl_SetResult( interp,
"unimplemented", TCL_STATIC );
2124 Tcl_AppendResult( interp,
"wrong # args: should be \"plot3d ",
2125 "x y z nx ny opt side\", or a valid contraction ",
2126 "thereof.", (
char *) NULL );
2130 plot3d( x, y, (
const PLFLT *
const *) z, nx, ny, opt, side );
2136 else if ( argc == 6 )
2170 PLINT nx, ny, opt, nlev = 10;
2174 tclMatrix *matx, *maty, *matz, *matPtr, *matlev;
2179 nlev = atoi( argv[8] );
2180 nx = atoi( argv[4] );
2181 ny = atoi( argv[5] );
2182 opt = atoi( argv[6] );
2196 if ( matlev == NULL )
2204 Tcl_SetResult( interp,
"x y z and clevel must all be float", TCL_STATIC );
2208 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2209 maty->
dim != 1 || maty->
n[0] != ny ||
2210 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny ||
2211 matlev->
dim != 1 || matlev->
n[0] != nlev )
2213 Tcl_SetResult( interp,
"popo Inconsistent dimensions", TCL_STATIC );
2219 clev = matlev->
fdata;
2221 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2222 for ( i = 0; i < nx; i++ )
2223 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2226 else if ( argc == 8 )
2228 nx = atoi( argv[4] );
2229 ny = atoi( argv[5] );
2230 opt = atoi( argv[6] );
2243 if ( matlev == NULL )
2251 Tcl_SetResult( interp,
"x y z and clevel must all be float", TCL_STATIC );
2255 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2256 maty->
dim != 1 || maty->
n[0] != ny ||
2257 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny ||
2258 matlev->
dim != 1 || matlev->
n[0] != nlev )
2260 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
2266 clev = matlev->
fdata;
2267 nlev = matlev->
n[0];
2269 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2270 for ( i = 0; i < nx; i++ )
2271 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2274 else if ( argc == 7 )
2276 nx = atoi( argv[4] );
2277 ny = atoi( argv[5] );
2278 opt = atoi( argv[6] );
2296 Tcl_SetResult( interp,
"x y and z must all be float", TCL_STATIC );
2300 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2301 maty->
dim != 1 || maty->
n[0] != ny ||
2302 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny )
2304 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
2311 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2312 for ( i = 0; i < nx; i++ )
2313 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2315 else if ( argc == 5 )
2317 opt = atoi( argv[4] );
2335 Tcl_SetResult( interp,
"x y and z must all be float", TCL_STATIC );
2339 nx = matx->
n[0]; ny = maty->
n[0];
2341 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2342 maty->
dim != 1 || maty->
n[0] != ny ||
2343 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny )
2345 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
2352 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2353 for ( i = 0; i < nx; i++ )
2354 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2356 else if ( argc == 3 )
2358 Tcl_SetResult( interp,
"unimplemented", TCL_STATIC );
2363 Tcl_AppendResult( interp,
"wrong # args: should be \"plot3dc ",
2364 "x y z nx ny opt clevel nlevel\", or a valid contraction ",
2365 "thereof.", (
char *) NULL );
2369 plot3dc( x, y, (
const PLFLT *
const *) z, nx, ny, opt, clev, nlev );
2375 else if ( argc == 5 )
2409 PLINT nx, ny, opt, nlev = 10;
2413 tclMatrix *matx, *maty, *matz, *matPtr, *matlev;
2418 nlev = atoi( argv[8] );
2419 nx = atoi( argv[4] );
2420 ny = atoi( argv[5] );
2421 opt = atoi( argv[6] );
2435 if ( matlev == NULL )
2443 Tcl_SetResult( interp,
"x y z and clevel must all be float", TCL_STATIC );
2447 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2448 maty->
dim != 1 || maty->
n[0] != ny ||
2449 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny ||
2450 matlev->
dim != 1 || matlev->
n[0] != nlev )
2452 Tcl_SetResult( interp,
"popo Inconsistent dimensions", TCL_STATIC );
2458 clev = matlev->
fdata;
2460 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2461 for ( i = 0; i < nx; i++ )
2462 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2465 else if ( argc == 8 )
2467 nx = atoi( argv[4] );
2468 ny = atoi( argv[5] );
2469 opt = atoi( argv[6] );
2482 if ( matlev == NULL )
2490 Tcl_SetResult( interp,
"x y z and clevel must all be float", TCL_STATIC );
2494 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2495 maty->
dim != 1 || maty->
n[0] != ny ||
2496 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny ||
2497 matlev->
dim != 1 || matlev->
n[0] != nlev )
2499 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
2505 clev = matlev->
fdata;
2506 nlev = matlev->
n[0];
2508 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2509 for ( i = 0; i < nx; i++ )
2510 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2513 else if ( argc == 7 )
2515 nx = atoi( argv[4] );
2516 ny = atoi( argv[5] );
2517 opt = atoi( argv[6] );
2535 Tcl_SetResult( interp,
"x y and z must all be float", TCL_STATIC );
2539 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2540 maty->
dim != 1 || maty->
n[0] != ny ||
2541 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny )
2543 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
2550 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2551 for ( i = 0; i < nx; i++ )
2552 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2554 else if ( argc == 5 )
2556 opt = atoi( argv[4] );
2574 Tcl_SetResult( interp,
"x y and z must all be float", TCL_STATIC );
2578 nx = matx->
n[0]; ny = maty->
n[0];
2580 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2581 maty->
dim != 1 || maty->
n[0] != ny ||
2582 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny )
2584 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
2591 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2592 for ( i = 0; i < nx; i++ )
2593 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2595 else if ( argc == 3 )
2597 Tcl_SetResult( interp,
"unimplemented", TCL_STATIC );
2602 Tcl_AppendResult( interp,
"wrong # args: should be \"plsurf3d ",
2603 "x y z nx ny opt clevel nlevel\", or a valid contraction ",
2604 "thereof.", (
char *) NULL );
2608 plsurf3d( x, y, (
const PLFLT *
const *) z, nx, ny, opt, clev, nlev );
2614 else if ( argc == 5 )
2648 PLINT nx, ny, opt, nlev = 10;
2651 PLINT indexxmin, indexxmax;
2653 tclMatrix *matx, *maty, *matz, *matPtr, *matlev;
2655 PLINT *idxymin, *idxymax;
2661 nlev = atoi( argv[8] );
2662 nx = atoi( argv[4] );
2663 ny = atoi( argv[5] );
2664 opt = atoi( argv[6] );
2666 indexxmin = atoi( argv[9] );
2667 indexxmax = atoi( argv[10] );
2670 if ( indexymin == NULL || indexymin == NULL )
2675 Tcl_SetResult( interp,
"indexymin and indexymax must be integer matrices", TCL_STATIC );
2691 if ( matlev == NULL )
2699 Tcl_SetResult( interp,
"x y z and clevel must all be float matrices", TCL_STATIC );
2703 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2704 maty->
dim != 1 || maty->
n[0] != ny ||
2705 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny ||
2706 matlev->
dim != 1 || matlev->
n[0] != nlev )
2708 Tcl_SetResult( interp,
"popo Inconsistent dimensions", TCL_STATIC );
2714 clev = matlev->
fdata;
2716 idxymin = indexymin->
idata;
2717 idxymax = indexymax->
idata;
2719 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2720 for ( i = 0; i < nx; i++ )
2721 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2724 else if ( argc == 12 )
2726 nx = atoi( argv[4] );
2727 ny = atoi( argv[5] );
2728 opt = atoi( argv[6] );
2730 indexxmin = atoi( argv[8] );
2731 indexxmax = atoi( argv[9] );
2734 if ( indexymin == NULL || indexymin == NULL )
2739 Tcl_SetResult( interp,
"indexymin and indexymax must be integer matrices", TCL_STATIC );
2754 if ( matlev == NULL )
2762 Tcl_SetResult( interp,
"x y z and clevel must all be float matrices", TCL_STATIC );
2766 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2767 maty->
dim != 1 || maty->
n[0] != ny ||
2768 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny ||
2769 matlev->
dim != 1 || matlev->
n[0] != nlev )
2771 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
2777 clev = matlev->
fdata;
2778 nlev = matlev->
n[0];
2780 idxymin = indexymin->
idata;
2781 idxymax = indexymax->
idata;
2783 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2784 for ( i = 0; i < nx; i++ )
2785 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2788 else if ( argc == 11 )
2790 nx = atoi( argv[4] );
2791 ny = atoi( argv[5] );
2792 opt = atoi( argv[6] );
2795 indexxmin = atoi( argv[7] );
2796 indexxmax = atoi( argv[8] );
2799 if ( indexymin == NULL || indexymin == NULL )
2804 Tcl_SetResult( interp,
"indexymin and indexymax must be integer matrices", TCL_STATIC );
2823 Tcl_SetResult( interp,
"x y and z must all be float matrices", TCL_STATIC );
2827 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2828 maty->
dim != 1 || maty->
n[0] != ny ||
2829 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny )
2831 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
2838 idxymin = indexymin->
idata;
2839 idxymax = indexymax->
idata;
2841 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2842 for ( i = 0; i < nx; i++ )
2843 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2845 else if ( argc == 9 )
2847 opt = atoi( argv[4] );
2850 indexxmin = atoi( argv[5] );
2851 indexxmax = atoi( argv[6] );
2854 if ( indexymin == NULL || indexymin == NULL )
2859 Tcl_SetResult( interp,
"indexymin and indexymax must be integer matrices", TCL_STATIC );
2878 Tcl_SetResult( interp,
"x y and z must all be float", TCL_STATIC );
2882 nx = matx->
n[0]; ny = maty->
n[0];
2884 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2885 maty->
dim != 1 || maty->
n[0] != ny ||
2886 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny )
2888 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
2895 idxymin = indexymin->
idata;
2896 idxymax = indexymax->
idata;
2898 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2899 for ( i = 0; i < nx; i++ )
2900 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2902 else if ( argc == 3 )
2904 Tcl_SetResult( interp,
"unimplemented", TCL_STATIC );
2909 Tcl_AppendResult( interp,
"wrong # args: should be \"plsurf3d ",
2910 "x y z nx ny opt clevel nlevel\", or a valid contraction ",
2911 "thereof.", (
char *) NULL );
2915 plsurf3dl( x, y, (
const PLFLT *
const *) z, nx, ny, opt, clev, nlev, indexxmin, indexxmax, idxymin, idxymax );
2921 else if ( argc == 9 )
2945 Tcl_AppendResult( interp,
"wrong # args: ",
2946 argv[0],
" takes no arguments", (
char *) NULL );
2951 Tcl_SetObjResult( interp, Tcl_NewDoubleObj(
plrandd() ) );
2966 if ( argc < 2 || argc > 3 )
2968 Tcl_AppendResult( interp,
"wrong # args: should be \"",
2969 argv[0],
" option ?argument?\"", (
char *) NULL );
3008 tclMatrix *matPtr, *matz, *mattrx = NULL, *mattry = NULL;
3009 PLFLT **z, **zused, **zwrapped;
3014 PLINT min_col = 1, max_col = 0;
3015 PLFLT min_wid = 0., max_wid = 0.;
3017 const char *pltrname =
"pltr0";
3027 Tcl_AppendResult( interp,
"bogus syntax for plshade, see doc.",
3035 if ( matz->
dim != 2 )
3037 Tcl_SetResult( interp,
"Must plot a 2-d matrix.", TCL_STATIC );
3044 tclmateval_modx = nx;
3045 tclmateval_mody = ny;
3050 for ( i = 0; i < nx; i++ )
3052 for ( j = 0; j < ny; j++ )
3058 xmin = atof( argv[2] );
3059 xmax = atof( argv[3] );
3060 ymin = atof( argv[4] );
3061 ymax = atof( argv[5] );
3062 sh_min = atof( argv[6] );
3063 sh_max = atof( argv[7] );
3064 sh_cmap = atoi( argv[8] );
3065 sh_col = atof( argv[9] );
3066 sh_wid = atof( argv[10] );
3067 min_col = atoi( argv[11] );
3068 min_wid = atoi( argv[12] );
3069 max_col = atoi( argv[13] );
3070 max_wid = atof( argv[14] );
3071 rect = atoi( argv[15] );
3073 argc -= 16, argv += 16;
3079 if ( mattrx == NULL )
3082 if ( mattry == NULL )
3085 argc -= 3, argv += 3;
3087 else if ( argc && !strcmp( argv[0],
"NULL" ) )
3090 argc -= 1, argv += 1;
3095 wrap = atoi( argv[0] );
3101 Tcl_SetResult( interp,
"plshade: bogus arg list", TCL_STATIC );
3108 if ( !strcmp( pltrname,
"NULL" ) )
3116 Tcl_SetResult( interp,
"Must use pltr2 if want wrapping.", TCL_STATIC );
3120 else if ( !strcmp( pltrname,
"pltr0" ) )
3128 Tcl_SetResult( interp,
"Must use pltr2 if want wrapping.", TCL_STATIC );
3132 else if ( !strcmp( pltrname,
"pltr1" ) )
3137 cgrid1.
yg = mattry->fdata;
3144 Tcl_SetResult( interp,
"Must use pltr2 if want wrapping.", TCL_STATIC );
3148 if ( mattrx->
dim != 1 || mattry->dim != 1 )
3150 Tcl_SetResult( interp,
"Must use 1-d coord arrays with pltr1.", TCL_STATIC );
3154 pltr_data = &cgrid1;
3156 else if ( !strcmp( pltrname,
"pltr2" ) )
3169 for ( i = 0; i < nx; i++ )
3170 for ( j = 0; j < ny; j++ )
3171 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
3174 for ( i = 0; i < nx; i++ )
3175 for ( j = 0; j < ny; j++ )
3176 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
3178 else if ( wrap == 1 )
3188 for ( i = 0; i < nx; i++ )
3189 for ( j = 0; j < ny; j++ )
3190 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
3193 for ( i = 0; i < nx; i++ )
3195 for ( j = 0; j < ny; j++ )
3197 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
3198 zwrapped[i][j] = z[i][j];
3202 for ( j = 0; j < ny; j++ )
3204 cgrid2.
xg[nx][j] = cgrid2.
xg[0][j];
3205 cgrid2.
yg[nx][j] = cgrid2.
yg[0][j];
3206 zwrapped[nx][j] = zwrapped[0][j];
3215 else if ( wrap == 2 )
3225 for ( i = 0; i < nx; i++ )
3226 for ( j = 0; j < ny; j++ )
3227 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
3230 for ( i = 0; i < nx; i++ )
3232 for ( j = 0; j < ny; j++ )
3234 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
3235 zwrapped[i][j] = z[i][j];
3239 for ( i = 0; i < nx; i++ )
3241 cgrid2.
xg[i][ny] = cgrid2.
xg[i][0];
3242 cgrid2.
yg[i][ny] = cgrid2.
yg[i][0];
3243 zwrapped[i][ny] = zwrapped[i][0];
3254 Tcl_SetResult( interp,
"Invalid wrap specifier, must be <empty>, 0, 1, or 2.", TCL_STATIC );
3259 pltr_data = &cgrid2;
3263 Tcl_AppendResult( interp,
3264 "Unrecognized coordinate transformation spec:",
3265 pltrname,
", must be NULL, pltr0, pltr1, or pltr2.",
3272 plshade( (
const PLFLT *
const *) zused, nx, ny, NULL,
3273 xmin, xmax, ymin, ymax,
3274 sh_min, sh_max, sh_cmap, sh_col, sh_wid,
3275 min_col, min_wid, max_col, max_wid,
3331 tclMatrix *matPtr, *matz, *mattrx = NULL, *mattry = NULL;
3333 PLFLT **z, **zused, **zwrapped;
3335 PLINT cont_color = 0;
3336 PLFLT fill_width = 0., cont_width = 0.;
3338 const char *pltrname =
"pltr0";
3344 int nx, ny, nlevel, i, j;
3348 Tcl_AppendResult( interp,
"bogus syntax for plshades, see doc.",
3356 if ( matz->
dim != 2 )
3358 Tcl_SetResult( interp,
"Must plot a 2-d matrix.", TCL_STATIC );
3365 tclmateval_modx = nx;
3366 tclmateval_mody = ny;
3371 for ( i = 0; i < nx; i++ )
3373 for ( j = 0; j < ny; j++ )
3379 xmin = atof( argv[2] );
3380 xmax = atof( argv[3] );
3381 ymin = atof( argv[4] );
3382 ymax = atof( argv[5] );
3385 if ( matclevel == NULL )
3387 nlevel = matclevel->
n[0];
3388 if ( matclevel->
dim != 1 )
3390 Tcl_SetResult( interp,
"clevel must be 1-d matrix.", TCL_STATIC );
3394 fill_width = atof( argv[7] );
3395 cont_color = atoi( argv[8] );
3396 cont_width = atof( argv[9] );
3397 rect = atoi( argv[10] );
3399 argc -= 11, argv += 11;
3405 if ( mattrx == NULL )
3408 if ( mattry == NULL )
3411 argc -= 3, argv += 3;
3413 else if ( argc && !strcmp( argv[0],
"NULL" ) )
3416 argc -= 1, argv += 1;
3421 wrap = atoi( argv[0] );
3427 Tcl_SetResult( interp,
"plshades: bogus arg list", TCL_STATIC );
3434 if ( !strcmp( pltrname,
"NULL" ) )
3442 Tcl_SetResult( interp,
"Must use pltr2 if want wrapping.", TCL_STATIC );
3446 else if ( !strcmp( pltrname,
"pltr0" ) )
3454 Tcl_SetResult( interp,
"Must use pltr2 if want wrapping.", TCL_STATIC );
3458 else if ( !strcmp( pltrname,
"pltr1" ) )
3463 cgrid1.
yg = mattry->fdata;
3470 Tcl_SetResult( interp,
"Must use pltr2 if want wrapping.", TCL_STATIC );
3474 if ( mattrx->
dim != 1 || mattry->dim != 1 )
3476 Tcl_SetResult( interp,
"Must use 1-d coord arrays with pltr1.", TCL_STATIC );
3480 pltr_data = &cgrid1;
3482 else if ( !strcmp( pltrname,
"pltr2" ) )
3495 for ( i = 0; i < nx; i++ )
3496 for ( j = 0; j < ny; j++ )
3497 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
3500 for ( i = 0; i < nx; i++ )
3501 for ( j = 0; j < ny; j++ )
3502 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
3504 else if ( wrap == 1 )
3514 for ( i = 0; i < nx; i++ )
3515 for ( j = 0; j < ny; j++ )
3516 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
3519 for ( i = 0; i < nx; i++ )
3521 for ( j = 0; j < ny; j++ )
3523 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
3524 zwrapped[i][j] = z[i][j];
3528 for ( j = 0; j < ny; j++ )
3530 cgrid2.
xg[nx][j] = cgrid2.
xg[0][j];
3531 cgrid2.
yg[nx][j] = cgrid2.
yg[0][j];
3532 zwrapped[nx][j] = zwrapped[0][j];
3541 else if ( wrap == 2 )
3551 for ( i = 0; i < nx; i++ )
3552 for ( j = 0; j < ny; j++ )
3553 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
3556 for ( i = 0; i < nx; i++ )
3558 for ( j = 0; j < ny; j++ )
3560 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
3561 zwrapped[i][j] = z[i][j];
3565 for ( i = 0; i < nx; i++ )
3567 cgrid2.
xg[i][ny] = cgrid2.
xg[i][0];
3568 cgrid2.
yg[i][ny] = cgrid2.
yg[i][0];
3569 zwrapped[i][ny] = zwrapped[i][0];
3580 Tcl_SetResult( interp,
"Invalid wrap specifier, must be <empty>, 0, 1, or 2.", TCL_STATIC );
3585 pltr_data = &cgrid2;
3589 Tcl_AppendResult( interp,
3590 "Unrecognized coordinate transformation spec:",
3591 pltrname,
", must be NULL, pltr0, pltr1, or pltr2.",
3598 plshades( (
const PLFLT *
const *) zused, nx, ny, NULL,
3599 xmin, xmax, ymin, ymax,
3600 matclevel->
fdata, nlevel, fill_width, cont_color, cont_width,
3646 cmd = (
char *) malloc( strlen( transform_name ) + 40 );
3649 sprintf( cmd,
"matrix %cx f %d", (
char) 1, n );
3650 if ( Tcl_Eval( tcl_interp, cmd ) != TCL_OK )
3652 return_code = TCL_ERROR;
3656 sprintf( cmd,
"matrix %cy f %d", (
char) 1, n );
3657 if ( Tcl_Eval( tcl_interp, cmd ) != TCL_OK )
3659 return_code = TCL_ERROR;
3664 sprintf( cmd,
"%cx", (
char) 1 );
3666 sprintf( cmd,
"%cy", (
char) 1 );
3669 if ( xPtr == NULL || yPtr == NULL )
3672 for ( i = 0; i < n; i++ )
3674 xPtr->
fdata[i] = x[i];
3675 yPtr->
fdata[i] = y[i];
3679 sprintf( cmd,
"%s %d %cx %cy", transform_name, n, (
char) 1, (
char) 1 );
3680 return_code = Tcl_Eval( tcl_interp, cmd );
3681 if ( return_code != TCL_OK )
3689 for ( i = 0; i < n; i++ )
3691 x[i] = xPtr->
fdata[i];
3692 y[i] = yPtr->
fdata[i];
3698 sprintf( cmd,
"rename %cx {}; rename %cy {}", (
char) 1, (
char) 1 );
3699 return_code = Tcl_Eval( tcl_interp, cmd );
3718 PLFLT minlong, maxlong, minlat, maxlat;
3722 return_code = TCL_OK;
3723 if ( argc < 6 || argc > 7 )
3725 Tcl_AppendResult( interp,
"bogus syntax for plmap, see doc.",
3734 transform_name = NULL;
3735 minlong = atof( argv[2] );
3736 maxlong = atof( argv[3] );
3737 minlat = atof( argv[4] );
3738 maxlat = atof( argv[5] );
3744 minlong = atof( argv[3] );
3745 maxlong = atof( argv[4] );
3746 minlat = atof( argv[5] );
3747 maxlat = atof( argv[6] );
3750 transform_name = argv[1];
3751 if ( strlen( transform_name ) == 0 )
3757 if ( transform && idxname == 2 )
3759 plmap( &
mapform, argv[idxname], minlong, maxlong, minlat, maxlat );
3764 plmap( NULL, argv[idxname], minlong, maxlong, minlat, maxlat );
3789 if ( Tcl_SplitList( interp,
string, n, (
const char ***) &argv ) == TCL_OK )
3791 entries = (
int *) malloc( ( *n ) *
sizeof ( int ) );
3792 for ( i = 0; i < *n; i++ )
3794 entries[i] = atoi( argv[i] );
3796 Tcl_Free( (
char *) argv );
3802 entries = (
int *) malloc( ( *n ) *
sizeof ( int ) );
3803 for ( i = 0; i < *n; i++ )
3805 entries[i] = mati->
idata[i];
3826 PLFLT minlong, maxlong, minlat, maxlat;
3832 return_code = TCL_OK;
3833 if ( argc < 6 || argc > 8 )
3835 Tcl_AppendResult( interp,
"bogus syntax for plmapfill, see doc.",
3848 transform_name = NULL;
3849 minlong = atof( argv[2] );
3850 maxlong = atof( argv[3] );
3851 minlat = atof( argv[4] );
3852 maxlat = atof( argv[5] );
3861 minlong = atof( argv[3] );
3862 maxlong = atof( argv[4] );
3863 minlat = atof( argv[5] );
3864 maxlat = atof( argv[6] );
3867 transform_name = argv[1];
3868 if ( strlen( transform_name ) == 0 )
3874 if ( Tcl_GetDouble( interp, argv[2], &minlong ) == TCL_OK )
3877 minlong = atof( argv[2] );
3878 maxlong = atof( argv[3] );
3879 minlat = atof( argv[4] );
3880 maxlat = atof( argv[5] );
3882 entries =
GetEntries( interp, argv[6], &nentries );
3889 entries =
GetEntries( interp, argv[7], &nentries );
3891 minlong = atof( argv[3] );
3892 maxlong = atof( argv[4] );
3893 minlat = atof( argv[5] );
3894 maxlat = atof( argv[6] );
3897 transform_name = argv[1];
3898 if ( strlen( transform_name ) == 0 )
3904 if ( transform && idxname == 2 )
3906 plmapfill( &
mapform, argv[idxname], minlong, maxlong, minlat, maxlat, entries, nentries );
3911 plmapfill( NULL, argv[idxname], minlong, maxlong, minlat, maxlat, entries, nentries );
3914 if ( entries != NULL )
3937 PLFLT minlong, maxlong, minlat, maxlat;
3943 return_code = TCL_OK;
3944 if ( argc < 6 || argc > 8 )
3946 Tcl_AppendResult( interp,
"bogus syntax for plmapline, see doc.",
3959 transform_name = NULL;
3960 minlong = atof( argv[2] );
3961 maxlong = atof( argv[3] );
3962 minlat = atof( argv[4] );
3963 maxlat = atof( argv[5] );
3972 minlong = atof( argv[3] );
3973 maxlong = atof( argv[4] );
3974 minlat = atof( argv[5] );
3975 maxlat = atof( argv[6] );
3978 transform_name = argv[1];
3979 if ( strlen( transform_name ) == 0 )
3985 if ( Tcl_GetDouble( interp, argv[2], &minlong ) == TCL_OK )
3988 minlong = atof( argv[2] );
3989 maxlong = atof( argv[3] );
3990 minlat = atof( argv[4] );
3991 maxlat = atof( argv[5] );
3993 entries =
GetEntries( interp, argv[6], &nentries );
4000 entries =
GetEntries( interp, argv[7], &nentries );
4002 minlong = atof( argv[3] );
4003 maxlong = atof( argv[4] );
4004 minlat = atof( argv[5] );
4005 maxlat = atof( argv[6] );
4008 transform_name = argv[1];
4009 if ( strlen( transform_name ) == 0 )
4015 if ( transform && idxname == 2 )
4017 plmapline( &
mapform, argv[idxname], minlong, maxlong, minlat, maxlat, entries, nentries );
4022 plmapline( NULL, argv[idxname], minlong, maxlong, minlat, maxlat, entries, nentries );
4025 if ( entries != NULL )
4048 PLFLT minlong, maxlong, minlat, maxlat;
4055 return_code = TCL_OK;
4056 if ( argc < 7 || argc > 9 )
4058 Tcl_AppendResult( interp,
"bogus syntax for plmapstring, see doc.",
4071 transform_name = NULL;
4073 minlong = atof( argv[3] );
4074 maxlong = atof( argv[4] );
4075 minlat = atof( argv[5] );
4076 maxlat = atof( argv[6] );
4086 minlong = atof( argv[4] );
4087 maxlong = atof( argv[5] );
4088 minlat = atof( argv[6] );
4089 maxlat = atof( argv[7] );
4092 transform_name = argv[1];
4093 if ( strlen( transform_name ) == 0 )
4099 if ( Tcl_GetDouble( interp, argv[3], &minlong ) == TCL_OK )
4104 minlong = atof( argv[3] );
4105 maxlong = atof( argv[4] );
4106 minlat = atof( argv[5] );
4107 maxlat = atof( argv[6] );
4108 entries =
GetEntries( interp, argv[7], &nentries );
4115 entries =
GetEntries( interp, argv[8], &nentries );
4118 minlong = atof( argv[4] );
4119 maxlong = atof( argv[5] );
4120 minlat = atof( argv[6] );
4121 maxlat = atof( argv[7] );
4124 transform_name = argv[1];
4125 if ( strlen( transform_name ) == 0 )
4131 if ( transform && idxname == 2 )
4133 plmapstring( &
mapform, argv[idxname],
string, minlong, maxlong, minlat, maxlat, entries, nentries );
4138 plmapstring( NULL, argv[idxname],
string, minlong, maxlong, minlat, maxlat, entries, nentries );
4141 if ( entries != NULL )
4164 PLFLT minlong, maxlong, minlat, maxlat;
4172 return_code = TCL_OK;
4173 if ( argc < 10 || argc > 12 )
4175 Tcl_AppendResult( interp,
"bogus syntax for plmaptex, see doc.",
4188 transform_name = NULL;
4189 dx = atof( argv[2] );
4190 dy = atof( argv[3] );
4191 just = atof( argv[4] );
4193 minlong = atof( argv[6] );
4194 maxlong = atof( argv[7] );
4195 minlat = atof( argv[8] );
4196 maxlat = atof( argv[9] );
4205 dx = atof( argv[3] );
4206 dy = atof( argv[4] );
4207 just = atof( argv[5] );
4209 minlong = atof( argv[7] );
4210 maxlong = atof( argv[8] );
4211 minlat = atof( argv[9] );
4212 maxlat = atof( argv[10] );
4215 transform_name = argv[1];
4216 if ( strlen( transform_name ) == 0 )
4222 if ( Tcl_GetDouble( interp, argv[2], &minlong ) == TCL_OK )
4226 dx = atof( argv[2] );
4227 dy = atof( argv[3] );
4228 just = atof( argv[4] );
4230 minlong = atof( argv[6] );
4231 maxlong = atof( argv[7] );
4232 minlat = atof( argv[8] );
4233 maxlat = atof( argv[9] );
4234 entries =
GetEntries( interp, argv[10], &nentries );
4241 entries =
GetEntries( interp, argv[11], &nentries );
4243 dx = atof( argv[3] );
4244 dy = atof( argv[4] );
4245 just = atof( argv[5] );
4247 minlong = atof( argv[7] );
4248 maxlong = atof( argv[8] );
4249 minlat = atof( argv[9] );
4250 maxlat = atof( argv[10] );
4253 transform_name = argv[1];
4254 if ( strlen( transform_name ) == 0 )
4260 if ( transform && idxname == 2 )
4262 plmaptex( &
mapform, argv[idxname], dx, dy, just, text, minlong, maxlong, minlat, maxlat, entries[0] );
4267 plmaptex( NULL, argv[idxname], dx, dy, just, text, minlong, maxlong, minlat, maxlat, entries[0] );
4270 if ( entries != NULL )
4293 PLFLT dlong, dlat, minlong, maxlong, minlat, maxlat;
4296 return_code = TCL_OK;
4298 if ( argc < 7 || argc > 8 )
4300 Tcl_AppendResult( interp,
"bogus syntax for plmeridians, see doc.",
4308 transform_name = NULL;
4309 dlong = atof( argv[1] );
4310 dlat = atof( argv[2] );
4311 minlong = atof( argv[3] );
4312 maxlong = atof( argv[4] );
4313 minlat = atof( argv[5] );
4314 maxlat = atof( argv[6] );
4318 dlong = atof( argv[2] );
4319 dlat = atof( argv[3] );
4320 minlong = atof( argv[4] );
4321 maxlong = atof( argv[5] );
4322 minlat = atof( argv[6] );
4323 maxlat = atof( argv[7] );
4327 transform_name = argv[1];
4328 if ( strlen( transform_name ) == 0 )
4340 plmeridians( NULL, dlong, dlat, minlong, maxlong, minlat, maxlat );
4350 #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 5
4351 "set result [%s ${_##_x} ${_##_y}] ; set _##_x [lindex $result 0] ; set _##_y [lindex $result 1]"
4353 "set result [%s ${_##_x} ${_##_y}] ; lassign $result _##_x _##_y"
4362 Tcl_Obj *objx, *objy;
4367 objx = Tcl_NewDoubleObj( x );
4368 Tcl_IncrRefCount( objx );
4369 Tcl_SetVar2Ex( tcl_xform_interp,
4370 "_##_x", NULL, objx, 0 );
4371 Tcl_DecrRefCount( objx );
4374 objy = Tcl_NewDoubleObj( y );
4375 Tcl_IncrRefCount( objy );
4376 Tcl_SetVar2Ex( tcl_xform_interp,
4377 "_##_y", NULL, objy, 0 );
4378 Tcl_DecrRefCount( objy );
4387 code = Tcl_Eval( tcl_xform_interp, tcl_xform_code );
4389 if ( code != TCL_OK )
4391 printf(
"Unable to evaluate Tcl-side coordinate transform.\n" );
4392 printf(
"code = %d\n", code );
4393 printf(
"Error result: %s\n", Tcl_GetStringResult( tcl_xform_interp ) );
4397 objx = Tcl_GetVar2Ex( tcl_xform_interp,
"_##_x", NULL, 0 );
4398 objy = Tcl_GetVar2Ex( tcl_xform_interp,
"_##_y", NULL, 0 );
4402 if ( Tcl_GetDoubleFromObj( tcl_xform_interp, objx, &dx ) != TCL_OK ||
4403 Tcl_GetDoubleFromObj( tcl_xform_interp, objy, &dy ) != TCL_OK )
4405 printf(
"Unable to extract Tcl results.\n" );
4424 || strcmp( argv[1],
"NULL" ) == 0 )
4428 tcl_xform_interp = 0;
4429 if ( tcl_xform_procname )
4431 free( tcl_xform_procname );
4432 tcl_xform_procname = 0;
4439 tcl_xform_interp =
interp;
4440 tcl_xform_procname =
plstrdup( argv[1] );
4442 len = strlen( tcl_xform_template ) + strlen( tcl_xform_procname );
4443 tcl_xform_code = malloc( len );
4444 sprintf( tcl_xform_code, tcl_xform_template, tcl_xform_procname );
4461 tclMatrix *arrx, *arry, *arrz, *xcoord, *ycoord, *zvalue;
4462 PLINT pts, nx, ny, alg;
4471 Tcl_AppendResult( interp,
"wrong # args: see documentation for ",
4472 argv[0], (
char *) NULL );
4485 sscanf( argv[7],
"%d", &alg );
4487 sscanf( argv[8],
"%lg", &value ); optalg = (
PLFLT) value;
4489 if ( arrx == NULL || arrx->
dim != 1 )
4491 Tcl_AppendResult( interp, argv[0],
": argument 1 should be a \
4492 one-dimensional matrix - ", argv[1], (
char *) NULL );
4495 if ( arry == NULL || arry->
dim != 1 )
4497 Tcl_AppendResult( interp, argv[0],
": argument 2 should be a \
4498 one-dimensional matrix - ", argv[2], (
char *) NULL );
4501 if ( arrz == NULL || arrz->
dim != 1 )
4503 Tcl_AppendResult( interp, argv[0],
": argument 3 should be a \
4504 one-dimensional matrix - ", argv[3], (
char *) NULL );
4508 if ( xcoord == NULL || xcoord->
dim != 1 )
4510 Tcl_AppendResult( interp, argv[0],
": argument 4 should be a \
4511 one-dimensional matrix - ", argv[4], (
char *) NULL );
4514 if ( ycoord == NULL || ycoord->
dim != 1 )
4516 Tcl_AppendResult( interp, argv[0],
": argument 5 should be a \
4517 one-dimensional matrix - ", argv[5], (
char *) NULL );
4520 if ( zvalue == NULL || zvalue->
dim != 2 )
4522 Tcl_AppendResult( interp, argv[0],
": argument 6 should be a \
4523 two-dimensional matrix - ", argv[6], (
char *) NULL );
4537 xcoord->
fdata, nx, ycoord->
fdata, ny, z, alg, optalg );
4540 for ( i = 0; i < nx; i++ )
4542 for ( j = 0; j < ny; j++ )
4544 zvalue->
fdata[j + zvalue->
n[1] * i] = z[i][j];
4571 Tcl_AppendResult( interp,
"wrong # args: see documentation for ",
4572 argv[0], (
char *) NULL );
4578 if ( zvalue == NULL || zvalue->
dim != 2 )
4580 Tcl_AppendResult( interp, argv[0],
": argument 1 should be a \
4581 two-dimensional matrix - ", argv[1], (
char *) NULL );
4585 sscanf( argv[2],
"%lg", &value ); xmin = (
PLFLT) value;
4586 sscanf( argv[3],
"%lg", &value ); xmax = (
PLFLT) value;
4587 sscanf( argv[4],
"%lg", &value ); ymin = (
PLFLT) value;
4588 sscanf( argv[5],
"%lg", &value ); ymax = (
PLFLT) value;
4589 sscanf( argv[6],
"%lg", &value ); zmin = (
PLFLT) value;
4590 sscanf( argv[7],
"%lg", &value ); zmax = (
PLFLT) value;
4591 sscanf( argv[8],
"%lg", &value ); Dxmin = (
PLFLT) value;
4592 sscanf( argv[9],
"%lg", &value ); Dxmax = (
PLFLT) value;
4593 sscanf( argv[10],
"%lg", &value ); Dymin = (
PLFLT) value;
4594 sscanf( argv[11],
"%lg", &value ); Dymax = (
PLFLT) value;
4601 for ( i = 0; i < nx; i++ )
4603 for ( j = 0; j < ny; j++ )
4605 pidata[i][j] = zvalue->
fdata[j + i * ny];
4617 c_plimage( (
const PLFLT *
const *) pidata, nx, ny, xmin, xmax, ymin, ymax, zmin, zmax,
4618 Dxmin, Dxmax, Dymin, Dymax );
4648 if ( argc != 12 && argc != 10 )
4650 Tcl_AppendResult( interp,
"wrong # args: see documentation for ",
4651 argv[0], (
char *) NULL );
4657 if ( zvalue == NULL || zvalue->
dim != 2 )
4659 Tcl_AppendResult( interp, argv[0],
": argument 1 should be a \
4660 two-dimensional matrix - ", argv[1], (
char *) NULL );
4671 if ( xg == NULL || xg->
dim != 2 )
4673 Tcl_AppendResult( interp, argv[0],
": argument 10 should be a \
4674 two-dimensional matrix - ", argv[10], (
char *) NULL );
4678 if ( yg == NULL || yg->
dim != 2 )
4680 Tcl_AppendResult( interp, argv[0],
": argument 11 should be a \
4681 two-dimensional matrix - ", argv[11], (
char *) NULL );
4686 sscanf( argv[2],
"%lg", &value ); xmin = (
PLFLT) value;
4687 sscanf( argv[3],
"%lg", &value ); xmax = (
PLFLT) value;
4688 sscanf( argv[4],
"%lg", &value ); ymin = (
PLFLT) value;
4689 sscanf( argv[5],
"%lg", &value ); ymax = (
PLFLT) value;
4690 sscanf( argv[6],
"%lg", &value ); zmin = (
PLFLT) value;
4691 sscanf( argv[7],
"%lg", &value ); zmax = (
PLFLT) value;
4692 sscanf( argv[8],
"%lg", &value ); valuemin = (
PLFLT) value;
4693 sscanf( argv[9],
"%lg", &value ); valuemax = (
PLFLT) value;
4700 for ( i = 0; i < nx; i++ )
4702 for ( j = 0; j < ny; j++ )
4704 pidata[i][j] = zvalue->
fdata[j + i * ny];
4715 for ( i = 0; i <= nx; i++ )
4717 for ( j = 0; j <= ny; j++ )
4719 cgrid2.
xg[i][j] = xg->
fdata[j + i * ( ny + 1 )];
4720 cgrid2.
yg[i][j] = yg->
fdata[j + i * ( ny + 1 )];
4723 c_plimagefr( (
const PLFLT *
const *) pidata, nx, ny, xmin, xmax, ymin, ymax, zmin, zmax,
4724 valuemin, valuemax,
pltr2, (
void *) &cgrid2 );
4728 c_plimagefr( (
const PLFLT *
const *) pidata, nx, ny, xmin, xmax, ymin, ymax, zmin, zmax,
4729 valuemin, valuemax,
pltr0, NULL );
4762 PLINT colbox, collab;
4763 PLINT colline[4], styline[4];
4765 const char **legline;
4773 Tcl_AppendResult( interp,
"wrong # args: see documentation for ",
4774 argv[0], (
char *) NULL );
4781 if ( colMat == NULL || colMat->
dim != 1 || colMat->
idata == NULL )
4783 Tcl_AppendResult( interp, argv[0],
": argument 15 should be a \
4784 one-dimensional integer matrix - ", argv[15], (
char *) NULL );
4788 if ( styleMat == NULL || styleMat->
dim != 1 || styleMat->
idata == NULL )
4790 Tcl_AppendResult( interp, argv[0],
": argument 16 should be a \
4791 one-dimensional integer matrix - ", argv[16], (
char *) NULL );
4799 sscanf( argv[4],
"%lg", &value ); xmin = (
PLFLT) value;
4800 sscanf( argv[5],
"%lg", &value ); xmax = (
PLFLT) value;
4801 sscanf( argv[6],
"%lg", &value ); xjump = (
PLFLT) value;
4802 sscanf( argv[7],
"%lg", &value ); ymin = (
PLFLT) value;
4803 sscanf( argv[8],
"%lg", &value ); ymax = (
PLFLT) value;
4804 sscanf( argv[9],
"%lg", &value ); xlpos = (
PLFLT) value;
4805 sscanf( argv[10],
"%lg", &value ); ylpos = (
PLFLT) value;
4806 sscanf( argv[11],
"%d", &ivalue ); y_ascl = (
PLBOOL) ivalue;
4807 sscanf( argv[12],
"%d", &ivalue ); acc = (
PLBOOL) ivalue;
4808 sscanf( argv[13],
"%d", &ivalue ); colbox = ivalue;
4809 sscanf( argv[14],
"%d", &ivalue ); collab = ivalue;
4815 for ( i = 0; i < 4; i++ )
4817 colline[i] = colMat->
idata[i];
4818 styline[i] = styleMat->
idata[i];
4821 if ( Tcl_SplitList( interp, argv[17], &nlegend, &legline ) != TCL_OK )
4827 Tcl_AppendResult( interp, argv[0],
": argument 18 should be a \
4828 list of at least four items - ", argv[17], (
char *) NULL );
4833 xmin, xmax, xjump, ymin, ymax,
4837 colline, styline, legline,
4838 labx, laby, labtop );
4840 sprintf( idvalue,
"%d",
id );
4841 Tcl_SetVar( interp, idName, idvalue, 0 );
4843 Tcl_Free( (
char *) legline );
4862 label_objs[1] = Tcl_NewIntObj( axis );
4863 label_objs[2] = Tcl_NewDoubleObj( (
double) value );
4865 Tcl_IncrRefCount( label_objs[1] );
4866 Tcl_IncrRefCount( label_objs[2] );
4870 if ( label_objs[3] != NULL )
4875 return_code = Tcl_EvalObjv( tcl_interp, objc, label_objs, 0 );
4877 if ( return_code != TCL_OK )
4879 strncpy(
string,
"ERROR", (
size_t) string_length );
4883 strncpy(
string, Tcl_GetStringResult( tcl_interp ), (
size_t) string_length );
4886 Tcl_DecrRefCount( label_objs[1] );
4887 Tcl_DecrRefCount( label_objs[2] );
4903 if ( argc < 2 || argc > 3 )
4905 Tcl_AppendResult( interp,
"bogus syntax for plslabelfunc, see doc.",
4912 if ( label_objs[0] != NULL )
4914 Tcl_DecrRefCount( label_objs[0] );
4916 if ( label_objs[3] != NULL )
4918 Tcl_DecrRefCount( label_objs[3] );
4919 label_objs[3] = NULL;
4922 if ( strlen( argv[1] ) == 0 )
4930 label_objs[0] = Tcl_NewStringObj( argv[1], (
int) strlen( argv[1] ) );
4931 Tcl_IncrRefCount( label_objs[0] );
4936 label_objs[3] = Tcl_NewStringObj( argv[2], (
int) strlen( argv[2] ) );
4937 Tcl_IncrRefCount( label_objs[3] );
4941 label_objs[3] = NULL;
4956 static int *
argv_to_ints( Tcl_Interp *interp,
const char *list_numbers,
int *number )
4963 list = Tcl_NewStringObj( list_numbers, ( -1 ) );
4965 retcode = Tcl_ListObjLength( interp, list, number );
4966 if ( retcode != TCL_OK || ( *number ) == 0 )
4973 array = (
int *) malloc(
sizeof (
int ) * (size_t) ( *number ) );
4974 for ( i = 0; i < ( *number ); i++ )
4976 Tcl_ListObjIndex( interp, list, i, &elem );
4977 Tcl_GetIntFromObj( interp, elem, &array[i] );
4983 static double *
argv_to_doubles( Tcl_Interp *interp,
const char *list_numbers,
int *number )
4990 list = Tcl_NewStringObj( list_numbers, ( -1 ) );
4992 retcode = Tcl_ListObjLength( interp, list, number );
4993 if ( retcode != TCL_OK || ( *number ) == 0 )
5000 array = (
double *) malloc(
sizeof (
double ) * (size_t) ( *number ) );
5001 for ( i = 0; i < ( *number ); i++ )
5003 Tcl_ListObjIndex( interp, list, i, &elem );
5004 Tcl_GetDoubleFromObj( interp, elem, &array[i] );
5010 static char **
argv_to_chars( Tcl_Interp *interp,
const char *list_strings,
int *number )
5020 list = Tcl_NewStringObj( list_strings, ( -1 ) );
5022 retcode = Tcl_ListObjLength( interp, list, number );
5023 if ( retcode != TCL_OK || ( *number ) == 0 )
5030 array = (
char **) malloc(
sizeof (
char* ) * (size_t) ( *number ) );
5031 array[0] = (
char *) malloc(
sizeof (
char ) * ( strlen( list_strings ) + 1 ) );
5033 for ( i = 0; i < ( *number ); i++ )
5035 Tcl_ListObjIndex( interp, list, i, &elem );
5036 string = Tcl_GetStringFromObj( elem, &length );
5038 array[i] = array[0] + idx;
5039 strncpy( array[i],
string, (
size_t) length );
5041 array[0][idx - 1] =
'\0';
5051 PLFLT legend_width, legend_height;
5052 PLFLT x, y, plot_width;
5053 PLINT opt, position;
5054 PLINT bg_color, bb_color, bb_style;
5055 PLINT nrow, ncolumn;
5058 PLFLT text_offset, text_scale, text_spacing, text_justification;
5060 PLINT *box_colors, *box_patterns;
5062 PLINT *line_colors, *line_styles;
5063 PLFLT *box_line_widths, *line_widths;
5064 PLINT *symbol_colors, *symbol_numbers;
5065 PLFLT *symbol_scales;
5078 Tcl_AppendResult( interp,
"bogus syntax for pllegend, see doc.",
5083 sscanf( argv[1],
"%d", &opt );
5084 sscanf( argv[2],
"%d", &position );
5085 sscanf( argv[3],
"%lg", &value ); x = (
PLFLT) value;
5086 sscanf( argv[4],
"%lg", &value ); y = (
PLFLT) value;
5087 sscanf( argv[5],
"%lg", &value ); plot_width = (
PLFLT) value;
5088 sscanf( argv[6],
"%d", &bg_color );
5089 sscanf( argv[7],
"%d", &bb_color );
5090 sscanf( argv[8],
"%d", &bb_style );
5091 sscanf( argv[9],
"%d", &nrow );
5092 sscanf( argv[10],
"%d", &ncolumn );
5093 opt_array =
argv_to_ints( interp, argv[11], &number_opts );
5094 sscanf( argv[12],
"%lg", &value ); text_offset = (
PLFLT) value;
5095 sscanf( argv[13],
"%lg", &value ); text_scale = (
PLFLT) value;
5096 sscanf( argv[14],
"%lg", &value ); text_spacing = (
PLFLT) value;
5097 sscanf( argv[15],
"%lg", &value ); text_justification = (
PLFLT) value;
5099 text_colors =
argv_to_ints( interp, argv[16], &dummy );
5102 box_patterns =
argv_to_ints( interp, argv[19], &dummy );
5105 line_colors =
argv_to_ints( interp, argv[22], &dummy );
5106 line_styles =
argv_to_ints( interp, argv[23], &dummy );
5108 symbol_colors =
argv_to_ints( interp, argv[25], &dummy );
5110 symbol_numbers =
argv_to_ints( interp, argv[27], &dummy );
5113 nlegend =
MIN( number_opts, number_texts );
5116 opt, position, x, y, plot_width,
5117 bg_color, bb_color, bb_style,
5120 text_offset, text_scale, text_spacing,
5122 text_colors, (
const char *
const *) text,
5123 box_colors, box_patterns,
5124 box_scales, box_line_widths,
5125 line_colors, line_styles,
5127 symbol_colors, symbol_scales,
5128 symbol_numbers, (
const char *
const *) symbols );
5130 if ( opt_array != NULL )
5132 if ( text_colors != NULL )
5133 free( text_colors );
5139 if ( box_colors != NULL )
5141 if ( box_patterns != NULL )
5142 free( box_patterns );
5143 if ( box_scales != NULL )
5145 if ( box_line_widths != NULL )
5146 free( box_line_widths );
5147 if ( line_colors != NULL )
5148 free( line_colors );
5149 if ( line_styles != NULL )
5150 free( line_styles );
5151 if ( line_widths != NULL )
5152 free( line_widths );
5153 if ( symbol_colors != NULL )
5154 free( symbol_colors );
5155 if ( symbol_scales != NULL )
5156 free( symbol_scales );
5157 if ( symbol_numbers != NULL )
5158 free( symbol_numbers );
5159 if ( symbols != NULL )
5165 data[0] = Tcl_NewDoubleObj( legend_width );
5166 data[1] = Tcl_NewDoubleObj( legend_height );
5167 Tcl_SetObjResult( interp, Tcl_NewListObj( 2, data ) );
5182 PLFLT colorbar_width, colorbar_height;
5183 PLINT opt, position;
5184 PLFLT x, y, x_length, y_length;
5185 PLINT bg_color, bb_color, bb_style;
5186 PLFLT low_cap_color, high_cap_color;
5200 Tcl_Obj *list_vectors;
5202 PLINT *vector_sizes;
5203 PLFLT **vector_values;
5216 Tcl_AppendResult( interp,
"bogus syntax for plcolorbar, see doc.",
5222 sscanf( argv[1],
"%d", &opt );
5223 sscanf( argv[2],
"%d", &position );
5224 sscanf( argv[3],
"%lg", &value ); x = (
PLFLT) value;
5225 sscanf( argv[4],
"%lg", &value ); y = (
PLFLT) value;
5226 sscanf( argv[5],
"%lg", &value ); x_length = (
PLFLT) value;
5227 sscanf( argv[6],
"%lg", &value ); y_length = (
PLFLT) value;
5228 sscanf( argv[7],
"%d", &bg_color );
5229 sscanf( argv[8],
"%d", &bb_color );
5230 sscanf( argv[9],
"%d", &bb_style );
5231 sscanf( argv[10],
"%lg", &value ); low_cap_color = (
PLFLT) value;
5232 sscanf( argv[11],
"%lg", &value ); high_cap_color = (
PLFLT) value;
5233 sscanf( argv[12],
"%d", &cont_color );
5234 sscanf( argv[13],
"%lg", &value ); cont_width = (
PLFLT) value;
5235 label_opts =
argv_to_ints( interp, argv[14], &n_label_opts );
5237 axis_opts =
argv_to_chars( interp, argv[16], &n_axis_opts );
5239 sub_ticks =
argv_to_ints( interp, argv[18], &n_sub_ticks );
5240 list_vectors = Tcl_NewStringObj( argv[19], ( -1 ) );
5243 if ( n_label_opts != n_labels )
5245 Tcl_AppendResult( interp,
"number of label options must equal number of labels.",
5249 if ( n_axis_opts != n_ticks || n_axis_opts != n_sub_ticks )
5251 Tcl_AppendResult( interp,
"number of axis, tick and subtick options must be equal.",
5255 n_axes = n_axis_opts;
5257 retcode = Tcl_ListObjLength( interp, list_vectors, &n_vectors );
5258 if ( retcode != TCL_OK || n_vectors == 0 )
5260 Tcl_AppendResult( interp,
"malformed list of vectors or no vector at all.",
5266 vector_sizes = (
int *) malloc(
sizeof (
int ) * (size_t) n_vectors );
5267 vector_values = (
PLFLT **) malloc(
sizeof (
PLFLT * ) * (size_t) n_vectors );
5268 for ( i = 0; i < n_vectors; i++ )
5270 Tcl_ListObjIndex( interp, list_vectors, i, &vector );
5271 vectorPtr =
Tcl_GetMatrixPtr( interp, Tcl_GetStringFromObj( vector, &length ) );
5272 if ( vectorPtr == NULL || vectorPtr->
dim != 1 )
5274 Tcl_AppendResult( interp,
"element in list of vectors is not a vector.",
5278 vector_sizes[i] = vectorPtr->
n[0];
5279 vector_values[i] = vectorPtr->
fdata;
5284 opt, position, x, y,
5286 bg_color, bb_color, bb_style,
5287 low_cap_color, high_cap_color,
5288 cont_color, cont_width,
5289 n_labels, label_opts, (
const char *
const *) labels,
5290 n_axes, (
const char *
const *) axis_opts,
5292 vector_sizes, (
const PLFLT *
const *) vector_values );
5294 if ( label_opts != NULL )
5296 if ( labels != NULL )
5301 if ( axis_opts != NULL )
5303 free( axis_opts[0] );
5306 if ( ticks != NULL )
5308 if ( sub_ticks != NULL )
5310 if ( vector_values != NULL )
5312 free( vector_sizes );
5313 free( vector_values );
5316 Tcl_DecrRefCount( list_vectors );
5318 data[0] = Tcl_NewDoubleObj( colorbar_width );
5319 data[1] = Tcl_NewDoubleObj( colorbar_height );
5320 Tcl_SetObjResult( interp, Tcl_NewListObj( 2, data ) );