38 #ifdef PL_HAVE_UNISTD_H
43 #define getcwd _getcwd
52 static int loopbackCmd( ClientData, Tcl_Interp *,
int,
const char ** );
53 static int plcolorbarCmd( ClientData, Tcl_Interp *,
int,
const char ** );
54 static int plcontCmd( ClientData, Tcl_Interp *,
int,
const char ** );
55 static int pllegendCmd( ClientData, Tcl_Interp *,
int,
const char ** );
56 static int plmeshCmd( ClientData, Tcl_Interp *,
int,
const char ** );
57 static int plmeshcCmd( ClientData, Tcl_Interp *,
int,
const char ** );
58 static int plot3dCmd( ClientData, Tcl_Interp *,
int,
const char ** );
59 static int plot3dcCmd( ClientData, Tcl_Interp *,
int,
const char ** );
60 static int plsurf3dCmd( ClientData, Tcl_Interp *,
int,
const char ** );
61 static int plsetoptCmd( ClientData, Tcl_Interp *,
int,
const char ** );
62 static int plshadeCmd( ClientData, Tcl_Interp *,
int,
const char ** );
63 static int plshadesCmd( ClientData, Tcl_Interp *,
int,
const char ** );
64 static int plmapCmd( ClientData, Tcl_Interp *,
int,
const char ** );
65 static int plmeridiansCmd( ClientData, Tcl_Interp *,
int,
const char ** );
66 static int plstransformCmd( ClientData, Tcl_Interp *,
int,
const char ** );
67 static int plsvectCmd( ClientData, Tcl_Interp *,
int,
const char ** );
68 static int plvectCmd( ClientData, Tcl_Interp *,
int,
const char ** );
69 static int plranddCmd( ClientData, Tcl_Interp *,
int,
const char ** );
70 static int plgriddataCmd( ClientData, Tcl_Interp *,
int,
const char ** );
71 static int plimageCmd( ClientData, Tcl_Interp *,
int,
const char ** );
72 static int plimagefrCmd( ClientData, Tcl_Interp *,
int,
const char ** );
73 static int plstripcCmd( ClientData, Tcl_Interp *,
int,
const char ** );
74 static int plslabelfuncCmd( ClientData, Tcl_Interp *,
int,
const char ** );
86 int ( *
proc )(
void *,
struct Tcl_Interp *, int,
const char ** );
97 int ( *proc )(
void *,
struct Tcl_Interp *, int,
const char ** );
143 #define PL_LIBRARY ""
148 #if ( !defined ( MAC_TCL ) && !defined ( __WIN32__ ) )
154 #define PLPLOT_EXTENDED_SEARCH
173 static int inited = 0;
174 static const char** namelist;
175 int i, j, ncmds =
sizeof (
Cmds ) /
sizeof (
CmdInfo );
179 namelist = (
const char **) malloc( (
size_t) ncmds *
sizeof (
char * ) );
181 for ( i = 0; i < ncmds; i++ )
182 namelist[i] = Cmds[i].
name;
186 for ( i = 0; i < ncmds - 1; i++ )
187 for ( j = i + 1; j < ncmds - 1; j++ )
189 if ( strcmp( namelist[i], namelist[j] ) > 0 )
191 const char *t = namelist[i];
192 namelist[i] = namelist[j];
200 for ( i = 0; i < ncmds; i++ )
201 Tcl_AppendResult( interp,
" ", namelist[i], (
char *) NULL );
225 Tcl_InitHashTable( &
cmdTable, TCL_STRING_KEYS );
229 for ( cmdInfoPtr = Cmds; cmdInfoPtr->
name != NULL; cmdInfoPtr++ )
234 hPtr = Tcl_CreateHashEntry( &
cmdTable, cmdInfoPtr->
name, &
new );
242 Tcl_SetHashValue( hPtr, cmdPtr );
271 register Tcl_HashEntry *hPtr;
288 Tcl_AppendResult( interp, cmdlist, (
char *) NULL );
295 hPtr = Tcl_FindHashEntry( &
cmdTable, argv[0] );
298 Tcl_AppendResult( interp,
"bad option \"", argv[0],
299 "\" to \"cmd\": must be one of ",
300 cmdlist, (
char *) NULL );
307 result = ( *cmdPtr->
proc )( cmdPtr->
clientData, interp, argc, argv );
308 if ( result == TCL_OK )
313 Tcl_AppendResult( interp,
errmsg, (
char *) NULL );
339 register Tcl_HashEntry *hPtr;
343 if ( argc == 0 || ( strcmp( argv[0],
"cmd" ) != 0 ) )
345 Tcl_AppendResult( interp,
"bad option \"", argv[0],
346 "\" to \"loopback\": must be ",
347 "\"cmd ?options?\" ", (
char *) NULL );
370 hPtr = Tcl_FindHashEntry( &
cmdTable, argv[0] );
373 Tcl_AppendResult( interp,
"bad option \"", argv[0],
374 "\" to \"loopback cmd\": must be one of ",
382 result = ( *cmdPtr->
proc )( cmdPtr->
clientData, interp, argc, argv );
400 int debug = plsc->debug;
401 const char *libDir = NULL;
402 static char initScript[] =
403 "tcl_findLibrary plplot " PLPLOT_VERSION " \"\" plplot.tcl PL_LIBRARY pllibrary";
404 #ifdef PLPLOT_EXTENDED_SEARCH
405 static char initScriptExtended[] =
406 "tcl_findLibrary plplot " PLPLOT_VERSION "/tcl \"\" plplot.tcl PL_LIBRARY pllibrary";
416 Tcl_InitStubs( interp,
"8.1", 0 );
423 fprintf( stderr,
"error in matrix init\n" );
434 #ifdef USE_MATRIX_STUBS
435 if ( Matrix_InitStubs( interp,
"0.1", 0 ) == NULL )
438 fprintf( stderr,
"error in matrix stubs init\n" );
442 Tcl_PkgRequire( interp,
"Matrix",
"0.1", 0 );
446 Tcl_SetVar( interp,
"plversion",
PLPLOT_VERSION, TCL_GLOBAL_ONLY );
449 Tcl_SetVar( interp,
"pl_itcl_package_name",
"Itcl 4", TCL_GLOBAL_ONLY );
451 Tcl_SetVar( interp,
"pl_itcl_package_name",
"Itcl 3", TCL_GLOBAL_ONLY );
456 Tcl_SetVar( interp,
"pl_itcl_package_name",
"Itcl(because_not_found_by_PLplot)", TCL_GLOBAL_ONLY );
459 Tcl_SetVar( interp,
"pl_itk_package_name",
"Itk 4", TCL_GLOBAL_ONLY );
461 Tcl_SetVar( interp,
"pl_itk_package_name",
"Itk 3", TCL_GLOBAL_ONLY );
466 Tcl_SetVar( interp,
"pl_itk_package_name",
"Itk(because_not_found_by_PLplot)", TCL_GLOBAL_ONLY );
469 Tcl_SetVar( interp,
"pl_iwidgets_package_name",
"Iwidgets 4", TCL_GLOBAL_ONLY );
476 Tcl_SetVar( interp,
"pl_iwidgets_package_name",
"Iwidgets(because_not_found_by_PLplot)", TCL_GLOBAL_ONLY );
487 fprintf( stderr,
"trying BUILD_DIR\n" );
489 Tcl_SetVar( interp,
"pllibrary", libDir, TCL_GLOBAL_ONLY );
490 if ( Tcl_Eval( interp, initScript ) != TCL_OK )
493 Tcl_UnsetVar( interp,
"pllibrary", TCL_GLOBAL_ONLY );
494 Tcl_ResetResult( interp );
499 if ( libDir == NULL )
502 fprintf( stderr,
"trying init script\n" );
503 if ( Tcl_Eval( interp, initScript ) != TCL_OK )
506 Tcl_UnsetVar( interp,
"pllibrary", TCL_GLOBAL_ONLY );
508 Tcl_ResetResult( interp );
511 libDir = Tcl_GetVar( interp,
"pllibrary", TCL_GLOBAL_ONLY );
516 if ( libDir == NULL )
519 fprintf( stderr,
"trying TCL_DIR\n" );
521 Tcl_SetVar( interp,
"pllibrary", libDir, TCL_GLOBAL_ONLY );
522 if ( Tcl_Eval( interp, initScript ) != TCL_OK )
525 Tcl_UnsetVar( interp,
"pllibrary", TCL_GLOBAL_ONLY );
526 Tcl_ResetResult( interp );
531 #ifdef PLPLOT_EXTENDED_SEARCH
533 if ( libDir == NULL )
536 fprintf( stderr,
"trying extended init script\n" );
537 if ( Tcl_Eval( interp, initScriptExtended ) != TCL_OK )
540 Tcl_UnsetVar( interp,
"pllibrary", TCL_GLOBAL_ONLY );
542 Tcl_ResetResult( interp );
545 libDir = Tcl_GetVar( interp,
"pllibrary", TCL_GLOBAL_ONLY );
549 if ( libDir == NULL )
553 fprintf( stderr,
"trying curdir\n" );
554 if ( Tcl_Access(
"plplot.tcl", 0 ) != 0 )
557 fprintf( stderr,
"couldn't find plplot.tcl in curdir\n" );
562 libDir = Tcl_GetCwd( interp, &ds );
563 if ( libDir == NULL )
566 fprintf( stderr,
"couldn't get curdir\n" );
570 Tcl_DStringFree( &ds );
571 Tcl_SetVar( interp,
"pllibrary", libDir, TCL_GLOBAL_ONLY );
573 if ( Tcl_EvalFile( interp,
"plplot.tcl" ) != TCL_OK )
576 fprintf( stderr,
"error evalling plplot.tcl\n" );
582 if ( libDir == NULL )
585 fprintf( stderr,
"libdir NULL at end of search\n" );
595 Tcl_CreateCommand( interp,
"wait_until", (Tcl_CmdProc *)
plWait_Until,
596 (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL );
619 Tcl_AppendResult( interp,
"Could not find plplot.tcl - please set \
620 environment variable PL_LIBRARY to the directory containing that file",
632 for ( cmdInfoPtr = Cmds; cmdInfoPtr->
name != NULL; cmdInfoPtr++ )
634 Tcl_CreateCommand( interp, cmdInfoPtr->
name, cmdInfoPtr->
proc,
635 (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL );
669 if ( Tcl_ExprBoolean( interp, argv[1], &result ) )
671 fprintf( stderr,
"wait_until command \"%s\" failed:\n\t %s\n",
672 argv[1], Tcl_GetStringResult( interp ) );
698 int debug = plsc->debug;
699 char *
buf, *ptr = NULL, *dn;
705 buf = (
char *) malloc( 256 *
sizeof (
char ) );
711 fprintf( stderr,
"adding %s to auto_path\n",
TCL_DIR );
712 Tcl_SetVar( interp,
"dir",
TCL_DIR, TCL_GLOBAL_ONLY );
713 if (
tcl_cmd( interp,
"set auto_path [linsert $auto_path 0 $dir]" ) == TCL_ERROR )
715 return_code = TCL_ERROR;
719 path = Tcl_GetVar( interp,
"auto_path", 0 );
720 fprintf( stderr,
"auto_path is %s\n", path );
726 if ( ( dn = getenv(
"HOME" ) ) != NULL )
729 Tcl_SetVar( interp,
"dir", ptr, 0 );
730 if (
tcl_cmd( interp,
"set auto_path [linsert $auto_path 0 $dir]" ) == TCL_ERROR )
732 return_code = TCL_ERROR;
736 fprintf( stderr,
"adding %s to auto_path\n", ptr );
737 path = Tcl_GetVar( interp,
"auto_path", 0 );
738 fprintf( stderr,
"auto_path is %s\n", path );
744 #if defined ( PL_TCL_ENV )
745 if ( ( dn = getenv( PL_TCL_ENV ) ) != NULL )
748 Tcl_SetVar( interp,
"dir", ptr, 0 );
749 if (
tcl_cmd( interp,
"set auto_path [linsert $auto_path 0 $dir]" ) == TCL_ERROR )
751 return_code = TCL_ERROR;
755 fprintf( stderr,
"adding %s to auto_path\n", ptr );
756 path = Tcl_GetVar( interp,
"auto_path", 0 );
757 fprintf( stderr,
"auto_path is %s\n", path );
764 #if defined ( PL_HOME_ENV )
765 if ( ( dn = getenv( PL_HOME_ENV ) ) != NULL )
768 Tcl_SetVar( interp,
"dir", ptr, 0 );
769 if (
tcl_cmd( interp,
"set auto_path [linsert $auto_path 0 $dir]" ) == TCL_ERROR )
771 return_code = TCL_ERROR;
775 fprintf( stderr,
"adding %s to auto_path\n", ptr );
776 path = Tcl_GetVar( interp,
"auto_path", 0 );
777 fprintf( stderr,
"auto_path is %s\n", path );
780 #endif // PL_HOME_ENV
784 if ( getcwd( buf, 256 ) == 0 )
786 Tcl_SetResult( interp,
"Problems with getcwd in pls_auto_path", TCL_STATIC );
788 return_code = TCL_ERROR;
792 Tcl_SetVar( interp,
"dir", buf, 0 );
793 if (
tcl_cmd( interp,
"set auto_path [linsert $auto_path 0 $dir]" ) == TCL_ERROR )
795 return_code = TCL_ERROR;
801 Tcl_SetVar( interp,
"dir",
BUILD_DIR "/bindings/tk", TCL_GLOBAL_ONLY );
802 if (
tcl_cmd( interp,
"set auto_path [linsert $auto_path 0 $dir]" ) == TCL_ERROR )
804 return_code = TCL_ERROR;
810 fprintf( stderr,
"adding %s to auto_path\n", buf );
811 path = Tcl_GetVar( interp,
"auto_path", 0 );
812 fprintf( stderr,
"auto_path is %s\n", path );
832 result = Tcl_VarEval( interp, cmd, (
char **) NULL );
833 if ( result != TCL_OK )
835 fprintf( stderr,
"TCL command \"%s\" failed:\n\t %s\n",
836 cmd, Tcl_GetStringResult( interp ) );
906 PLINT nx, ny, kx = 0, lx = 0, ky = 0, ly = 0, nclev;
907 const char *pltrname =
"pltr0";
908 tclMatrix *mattrx = NULL, *mattry = NULL;
909 PLFLT **z, **zused, **zwrapped;
911 int arg3_is_kx = 1, i, j;
921 Tcl_AppendResult( interp,
"wrong # args: see documentation for ",
922 argv[0], (
char *) NULL );
930 if ( matf->
dim != 2 )
932 Tcl_SetResult( interp,
"Must use 2-d data.", TCL_STATIC );
939 tclmateval_modx =
nx;
940 tclmateval_mody = ny;
945 for ( i = 0; i <
nx; i++ )
947 for ( j = 0; j < ny; j++ )
957 for ( i = 0; i < (int) strlen( argv[2] ) && arg3_is_kx; i++ )
958 if ( !isdigit( argv[2][i] ) )
966 Tcl_SetResult( interp,
"plcont, bogus syntax", TCL_STATIC );
971 kx = atoi( argv[3] );
972 lx = atoi( argv[4] );
973 ky = atoi( argv[5] );
974 ly = atoi( argv[6] );
977 argc -= 6, argv += 6;
981 argc -= 2, argv += 2;
988 Tcl_SetResult( interp,
"plcont, bogus syntax", TCL_STATIC );
993 if ( matclev == NULL )
995 nclev = matclev->
n[0];
997 if ( matclev->
dim != 1 )
999 Tcl_SetResult( interp,
"clev must be 1-d matrix.", TCL_STATIC );
1012 if ( mattrx == NULL )
1015 if ( mattry == NULL )
1018 argc -= 3, argv += 3;
1024 wrap = atoi( argv[0] );
1036 Tcl_SetResult( interp,
"plcont, bogus syntax, too many args.", TCL_STATIC );
1042 if ( !strcmp( pltrname,
"pltr0" ) )
1050 Tcl_SetResult( interp,
"Must use pltr2 if want wrapping.", TCL_STATIC );
1054 else if ( !strcmp( pltrname,
"pltr1" ) )
1059 cgrid1.
yg = mattry->fdata;
1066 Tcl_SetResult( interp,
"Must use pltr2 if want wrapping.", TCL_STATIC );
1070 if ( mattrx->
dim != 1 || mattry->dim != 1 )
1072 Tcl_SetResult( interp,
"Must use 1-d coord arrays with pltr1.", TCL_STATIC );
1076 pltr_data = &cgrid1;
1078 else if ( !strcmp( pltrname,
"pltr2" ) )
1091 for ( i = 0; i <
nx; i++ )
1092 for ( j = 0; j < ny; j++ )
1093 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
1096 for ( i = 0; i <
nx; i++ )
1097 for ( j = 0; j < ny; j++ )
1098 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
1100 else if ( wrap == 1 )
1110 for ( i = 0; i <
nx; i++ )
1111 for ( j = 0; j < ny; j++ )
1112 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
1115 for ( i = 0; i <
nx; i++ )
1117 for ( j = 0; j < ny; j++ )
1119 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
1120 zwrapped[i][j] = z[i][j];
1124 for ( j = 0; j < ny; j++ )
1126 cgrid2.
xg[
nx][j] = cgrid2.
xg[0][j];
1127 cgrid2.
yg[
nx][j] = cgrid2.
yg[0][j];
1128 zwrapped[
nx][j] = zwrapped[0][j];
1137 else if ( wrap == 2 )
1147 for ( i = 0; i <
nx; i++ )
1148 for ( j = 0; j < ny; j++ )
1149 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
1152 for ( i = 0; i <
nx; i++ )
1154 for ( j = 0; j < ny; j++ )
1156 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
1157 zwrapped[i][j] = z[i][j];
1161 for ( i = 0; i <
nx; i++ )
1163 cgrid2.
xg[i][ny] = cgrid2.
xg[i][0];
1164 cgrid2.
yg[i][ny] = cgrid2.
yg[i][0];
1165 zwrapped[i][ny] = zwrapped[i][0];
1176 Tcl_SetResult( interp,
"Invalid wrap specifier, must be <empty>, 0, 1, or 2.", TCL_STATIC );
1181 pltr_data = &cgrid2;
1185 Tcl_AppendResult( interp,
1186 "Unrecognized coordinate transformation spec:",
1187 pltrname,
", must be pltr0 pltr1 or pltr2.",
1205 plcont( (
const PLFLT *
const *) zused, nx, ny,
1207 matclev->
fdata, nclev,
1249 || ( strcmp( argv[1],
"NULL" ) == 0 ) && ( strcmp( argv[2],
"NULL" ) == 0 ) )
1255 else if ( argc != 4 )
1257 Tcl_AppendResult( interp,
"wrong # args: see documentation for ",
1258 argv[0], (
char *) NULL );
1266 if ( matx->
dim != 1 )
1268 Tcl_SetResult( interp,
"plsvect: Must use 1-d data.", TCL_STATIC );
1277 if ( maty->
dim != 1 )
1279 Tcl_SetResult( interp,
"plsvect: Must use 1-d data.", TCL_STATIC );
1283 if ( maty->
n[0] != npts )
1285 Tcl_SetResult( interp,
"plsvect: Arrays must be of equal length", TCL_STATIC );
1289 fill = (
PLBOOL) atoi( argv[3] );
1306 const char *pltrname =
"pltr0";
1307 tclMatrix *mattrx = NULL, *mattry = NULL;
1308 PLFLT **u, **v, **uused, **vused, **uwrapped, **vwrapped;
1321 Tcl_AppendResult( interp,
"wrong # args: see documentation for ",
1322 argv[0], (
char *) NULL );
1330 if ( matu->
dim != 2 )
1332 Tcl_SetResult( interp,
"Must use 2-d data.", TCL_STATIC );
1339 tclmateval_modx =
nx;
1340 tclmateval_mody = ny;
1345 for ( i = 0; i <
nx; i++ )
1347 for ( j = 0; j < ny; j++ )
1358 if ( matv->
dim != 2 )
1360 Tcl_SetResult( interp,
"Must use 2-d data.", TCL_STATIC );
1367 tclmateval_modx =
nx;
1368 tclmateval_mody = ny;
1373 for ( i = 0; i <
nx; i++ )
1375 for ( j = 0; j < ny; j++ )
1382 argc -= 3, argv += 3;
1388 Tcl_SetResult( interp,
"plvect, bogus syntax", TCL_STATIC );
1392 scaling = atof( argv[0] );
1402 if ( mattrx == NULL )
1405 if ( mattry == NULL )
1408 argc -= 3, argv += 3;
1414 wrap = atoi( argv[0] );
1426 Tcl_SetResult( interp,
"plvect, bogus syntax, too many args.", TCL_STATIC );
1432 if ( !strcmp( pltrname,
"pltr0" ) )
1441 Tcl_SetResult( interp,
"Must use pltr2 if want wrapping.", TCL_STATIC );
1445 else if ( !strcmp( pltrname,
"pltr1" ) )
1450 cgrid1.
yg = mattry->fdata;
1458 Tcl_SetResult( interp,
"Must use pltr2 if want wrapping.", TCL_STATIC );
1462 if ( mattrx->
dim != 1 || mattry->dim != 1 )
1464 Tcl_SetResult( interp,
"Must use 1-d coord arrays with pltr1.", TCL_STATIC );
1468 pltr_data = &cgrid1;
1470 else if ( !strcmp( pltrname,
"pltr2" ) )
1484 for ( i = 0; i <
nx; i++ )
1485 for ( j = 0; j < ny; j++ )
1486 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
1488 for ( i = 0; i <
nx; i++ )
1490 for ( j = 0; j < ny; j++ )
1492 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
1496 else if ( wrap == 1 )
1509 for ( i = 0; i <
nx; i++ )
1510 for ( j = 0; j < ny; j++ )
1511 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
1514 for ( i = 0; i <
nx; i++ )
1516 for ( j = 0; j < ny; j++ )
1518 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
1519 uwrapped[i][j] = u[i][j];
1520 vwrapped[i][j] = v[i][j];
1524 for ( j = 0; j < ny; j++ )
1526 cgrid2.
xg[
nx][j] = cgrid2.
xg[0][j];
1527 cgrid2.
yg[
nx][j] = cgrid2.
yg[0][j];
1528 uwrapped[
nx][j] = uwrapped[0][j];
1529 vwrapped[
nx][j] = vwrapped[0][j];
1538 else if ( wrap == 2 )
1550 for ( i = 0; i <
nx; i++ )
1551 for ( j = 0; j < ny; j++ )
1552 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
1555 for ( i = 0; i <
nx; i++ )
1557 for ( j = 0; j < ny; j++ )
1559 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
1560 uwrapped[i][j] = u[i][j];
1561 vwrapped[i][j] = v[i][j];
1565 for ( i = 0; i <
nx; i++ )
1567 cgrid2.
xg[i][ny] = cgrid2.
xg[i][0];
1568 cgrid2.
yg[i][ny] = cgrid2.
yg[i][0];
1569 uwrapped[i][ny] = uwrapped[i][0];
1570 vwrapped[i][ny] = vwrapped[i][0];
1582 Tcl_SetResult( interp,
"Invalid wrap specifier, must be <empty>, 0, 1, or 2.", TCL_STATIC );
1587 pltr_data = &cgrid2;
1591 Tcl_AppendResult( interp,
1592 "Unrecognized coordinate transformation spec:",
1593 pltrname,
", must be pltr0 pltr1 or pltr2.",
1601 plvect( (
const PLFLT *
const *) uused, (
const PLFLT *
const *) vused, nx, ny,
1602 scaling,
pltr, pltr_data );
1655 nx = atoi( argv[4] );
1656 ny = atoi( argv[5] );
1657 opt = atoi( argv[6] );
1674 Tcl_SetResult( interp,
"x y and z must all be float", TCL_STATIC );
1678 if ( matx->
dim != 1 || matx->
n[0] != nx ||
1679 maty->
dim != 1 || maty->
n[0] != ny ||
1680 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny )
1682 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
1689 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
1690 for ( i = 0; i <
nx; i++ )
1691 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
1693 else if ( argc == 5 )
1695 opt = atoi( argv[4] );
1712 Tcl_SetResult( interp,
"x y and z must all be float", TCL_STATIC );
1716 nx = matx->
n[0]; ny = maty->
n[0];
1718 if ( matx->
dim != 1 || matx->
n[0] != nx ||
1719 maty->
dim != 1 || maty->
n[0] != ny ||
1720 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny )
1722 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
1729 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
1730 for ( i = 0; i <
nx; i++ )
1731 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
1733 else if ( argc == 3 )
1735 Tcl_SetResult( interp,
"unimplemented", TCL_STATIC );
1740 Tcl_AppendResult( interp,
"wrong # args: should be \"plmesh ",
1741 "x y z nx ny opt\", or a valid contraction ",
1742 "thereof.", (
char *) NULL );
1746 plmesh( x, y, (
const PLFLT *
const *) z, nx, ny, opt );
1752 else if ( argc == 5 )
1790 tclMatrix *matx, *maty, *matz, *matPtr, *matlev;
1795 nlev = atoi( argv[8] );
1796 nx = atoi( argv[4] );
1797 ny = atoi( argv[5] );
1798 opt = atoi( argv[6] );
1812 if ( matlev == NULL )
1820 Tcl_SetResult( interp,
"x y z and clevel must all be float", TCL_STATIC );
1824 if ( matx->
dim != 1 || matx->
n[0] != nx ||
1825 maty->
dim != 1 || maty->
n[0] != ny ||
1826 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny ||
1827 matlev->
dim != 1 || matlev->
n[0] != nlev )
1829 Tcl_SetResult( interp,
"popo Inconsistent dimensions", TCL_STATIC );
1835 clev = matlev->
fdata;
1837 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
1838 for ( i = 0; i <
nx; i++ )
1839 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
1842 else if ( argc == 8 )
1844 nx = atoi( argv[4] );
1845 ny = atoi( argv[5] );
1846 opt = atoi( argv[6] );
1859 if ( matlev == NULL )
1867 Tcl_SetResult( interp,
"x y z and clevel must all be float", TCL_STATIC );
1871 if ( matx->
dim != 1 || matx->
n[0] != nx ||
1872 maty->
dim != 1 || maty->
n[0] != ny ||
1873 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny ||
1874 matlev->
dim != 1 || matlev->
n[0] != nlev )
1876 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
1882 clev = matlev->
fdata;
1883 nlev = matlev->
n[0];
1885 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
1886 for ( i = 0; i <
nx; i++ )
1887 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
1890 else if ( argc == 7 )
1892 nx = atoi( argv[4] );
1893 ny = atoi( argv[5] );
1894 opt = atoi( argv[6] );
1912 Tcl_SetResult( interp,
"x y and z must all be float", TCL_STATIC );
1916 if ( matx->
dim != 1 || matx->
n[0] != nx ||
1917 maty->
dim != 1 || maty->
n[0] != ny ||
1918 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny )
1920 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
1927 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
1928 for ( i = 0; i <
nx; i++ )
1929 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
1931 else if ( argc == 5 )
1933 opt = atoi( argv[4] );
1951 Tcl_SetResult( interp,
"x y and z must all be float", TCL_STATIC );
1955 nx = matx->
n[0]; ny = maty->
n[0];
1957 if ( matx->
dim != 1 || matx->
n[0] != nx ||
1958 maty->
dim != 1 || maty->
n[0] != ny ||
1959 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny )
1961 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
1968 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
1969 for ( i = 0; i <
nx; i++ )
1970 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
1972 else if ( argc == 3 )
1974 Tcl_SetResult( interp,
"unimplemented", TCL_STATIC );
1979 Tcl_AppendResult( interp,
"wrong # args: should be \"plmeshc ",
1980 "x y z nx ny opt clevel nlevel\", or a valid contraction ",
1981 "thereof.", (
char *) NULL );
1985 plmeshc( x, y, (
const PLFLT *
const *) z, nx, ny, opt, clev, nlev );
1991 else if ( argc == 5 )
2029 nx = atoi( argv[4] );
2030 ny = atoi( argv[5] );
2031 opt = atoi( argv[6] );
2032 side = atoi( argv[7] );
2049 Tcl_SetResult( interp,
"x y and z must all be float", TCL_STATIC );
2053 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2054 maty->
dim != 1 || maty->
n[0] != ny ||
2055 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny )
2057 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
2064 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2065 for ( i = 0; i <
nx; i++ )
2066 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2068 else if ( argc == 6 )
2070 opt = atoi( argv[4] );
2071 side = atoi( argv[5] );
2088 Tcl_SetResult( interp,
"x y and z must all be float", TCL_STATIC );
2092 nx = matx->
n[0]; ny = maty->
n[0];
2094 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2095 maty->
dim != 1 || maty->
n[0] != ny ||
2096 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny )
2098 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
2105 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2106 for ( i = 0; i <
nx; i++ )
2107 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2109 else if ( argc == 4 )
2111 Tcl_SetResult( interp,
"unimplemented", TCL_STATIC );
2116 Tcl_AppendResult( interp,
"wrong # args: should be \"plot3d ",
2117 "x y z nx ny opt side\", or a valid contraction ",
2118 "thereof.", (
char *) NULL );
2122 plot3d( x, y, (
const PLFLT *
const *) z, nx, ny, opt, side );
2128 else if ( argc == 6 )
2166 tclMatrix *matx, *maty, *matz, *matPtr, *matlev;
2171 nlev = atoi( argv[8] );
2172 nx = atoi( argv[4] );
2173 ny = atoi( argv[5] );
2174 opt = atoi( argv[6] );
2188 if ( matlev == NULL )
2196 Tcl_SetResult( interp,
"x y z and clevel must all be float", TCL_STATIC );
2200 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2201 maty->
dim != 1 || maty->
n[0] != ny ||
2202 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny ||
2203 matlev->
dim != 1 || matlev->
n[0] != nlev )
2205 Tcl_SetResult( interp,
"popo Inconsistent dimensions", TCL_STATIC );
2211 clev = matlev->
fdata;
2213 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2214 for ( i = 0; i <
nx; i++ )
2215 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2218 else if ( argc == 8 )
2220 nx = atoi( argv[4] );
2221 ny = atoi( argv[5] );
2222 opt = atoi( argv[6] );
2235 if ( matlev == NULL )
2243 Tcl_SetResult( interp,
"x y z and clevel must all be float", TCL_STATIC );
2247 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2248 maty->
dim != 1 || maty->
n[0] != ny ||
2249 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny ||
2250 matlev->
dim != 1 || matlev->
n[0] != nlev )
2252 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
2258 clev = matlev->
fdata;
2259 nlev = matlev->
n[0];
2261 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2262 for ( i = 0; i <
nx; i++ )
2263 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2266 else if ( argc == 7 )
2268 nx = atoi( argv[4] );
2269 ny = atoi( argv[5] );
2270 opt = atoi( argv[6] );
2288 Tcl_SetResult( interp,
"x y and z must all be float", TCL_STATIC );
2292 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2293 maty->
dim != 1 || maty->
n[0] != ny ||
2294 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny )
2296 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
2303 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2304 for ( i = 0; i <
nx; i++ )
2305 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2307 else if ( argc == 5 )
2309 opt = atoi( argv[4] );
2327 Tcl_SetResult( interp,
"x y and z must all be float", TCL_STATIC );
2331 nx = matx->
n[0]; ny = maty->
n[0];
2333 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2334 maty->
dim != 1 || maty->
n[0] != ny ||
2335 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny )
2337 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
2344 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2345 for ( i = 0; i <
nx; i++ )
2346 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2348 else if ( argc == 3 )
2350 Tcl_SetResult( interp,
"unimplemented", TCL_STATIC );
2355 Tcl_AppendResult( interp,
"wrong # args: should be \"plot3dc ",
2356 "x y z nx ny opt clevel nlevel\", or a valid contraction ",
2357 "thereof.", (
char *) NULL );
2361 plot3dc( x, y, (
const PLFLT *
const *) z, nx, ny, opt, clev, nlev );
2367 else if ( argc == 5 )
2405 tclMatrix *matx, *maty, *matz, *matPtr, *matlev;
2410 nlev = atoi( argv[8] );
2411 nx = atoi( argv[4] );
2412 ny = atoi( argv[5] );
2413 opt = atoi( argv[6] );
2427 if ( matlev == NULL )
2435 Tcl_SetResult( interp,
"x y z and clevel must all be float", TCL_STATIC );
2439 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2440 maty->
dim != 1 || maty->
n[0] != ny ||
2441 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny ||
2442 matlev->
dim != 1 || matlev->
n[0] != nlev )
2444 Tcl_SetResult( interp,
"popo Inconsistent dimensions", TCL_STATIC );
2450 clev = matlev->
fdata;
2452 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2453 for ( i = 0; i <
nx; i++ )
2454 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2457 else if ( argc == 8 )
2459 nx = atoi( argv[4] );
2460 ny = atoi( argv[5] );
2461 opt = atoi( argv[6] );
2474 if ( matlev == NULL )
2482 Tcl_SetResult( interp,
"x y z and clevel must all be float", TCL_STATIC );
2486 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2487 maty->
dim != 1 || maty->
n[0] != ny ||
2488 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny ||
2489 matlev->
dim != 1 || matlev->
n[0] != nlev )
2491 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
2497 clev = matlev->
fdata;
2498 nlev = matlev->
n[0];
2500 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2501 for ( i = 0; i <
nx; i++ )
2502 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2505 else if ( argc == 7 )
2507 nx = atoi( argv[4] );
2508 ny = atoi( argv[5] );
2509 opt = atoi( argv[6] );
2527 Tcl_SetResult( interp,
"x y and z must all be float", TCL_STATIC );
2531 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2532 maty->
dim != 1 || maty->
n[0] != ny ||
2533 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny )
2535 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
2542 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2543 for ( i = 0; i <
nx; i++ )
2544 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2546 else if ( argc == 5 )
2548 opt = atoi( argv[4] );
2566 Tcl_SetResult( interp,
"x y and z must all be float", TCL_STATIC );
2570 nx = matx->
n[0]; ny = maty->
n[0];
2572 if ( matx->
dim != 1 || matx->
n[0] != nx ||
2573 maty->
dim != 1 || maty->
n[0] != ny ||
2574 matz->
dim != 2 || matz->
n[0] != nx || matz->
n[1] != ny )
2576 Tcl_SetResult( interp,
"Inconsistent dimensions", TCL_STATIC );
2583 z = (
PLFLT **) malloc( (
size_t) nx *
sizeof (
PLFLT * ) );
2584 for ( i = 0; i <
nx; i++ )
2585 z[i] = &matz->
fdata[
I2D( i, 0 ) ];
2587 else if ( argc == 3 )
2589 Tcl_SetResult( interp,
"unimplemented", TCL_STATIC );
2594 Tcl_AppendResult( interp,
"wrong # args: should be \"plsurf3d ",
2595 "x y z nx ny opt clevel nlevel\", or a valid contraction ",
2596 "thereof.", (
char *) NULL );
2600 plsurf3d( x, y, (
const PLFLT *
const *) z, nx, ny, opt, clev, nlev );
2606 else if ( argc == 5 )
2630 Tcl_AppendResult( interp,
"wrong # args: ",
2631 argv[0],
" takes no arguments", (
char *) NULL );
2636 Tcl_SetObjResult( interp, Tcl_NewDoubleObj(
plrandd() ) );
2651 if ( argc < 2 || argc > 3 )
2653 Tcl_AppendResult( interp,
"wrong # args: should be \"",
2654 argv[0],
" option ?argument?\"", (
char *) NULL );
2693 tclMatrix *matPtr, *matz, *mattrx = NULL, *mattry = NULL;
2694 PLFLT **z, **zused, **zwrapped;
2699 PLINT min_col = 1, max_col = 0;
2700 PLFLT min_wid = 0., max_wid = 0.;
2702 const char *pltrname =
"pltr0";
2712 Tcl_AppendResult( interp,
"bogus syntax for plshade, see doc.",
2720 if ( matz->
dim != 2 )
2722 Tcl_SetResult( interp,
"Must plot a 2-d matrix.", TCL_STATIC );
2729 tclmateval_modx =
nx;
2730 tclmateval_mody = ny;
2735 for ( i = 0; i <
nx; i++ )
2737 for ( j = 0; j < ny; j++ )
2743 xmin = atof( argv[2] );
2744 xmax = atof( argv[3] );
2745 ymin = atof( argv[4] );
2746 ymax = atof( argv[5] );
2747 sh_min = atof( argv[6] );
2748 sh_max = atof( argv[7] );
2749 sh_cmap = atoi( argv[8] );
2750 sh_col = atof( argv[9] );
2751 sh_wid = atof( argv[10] );
2752 min_col = atoi( argv[11] );
2753 min_wid = atoi( argv[12] );
2754 max_col = atoi( argv[13] );
2755 max_wid = atof( argv[14] );
2756 rect = atoi( argv[15] );
2758 argc -= 16, argv += 16;
2764 if ( mattrx == NULL )
2767 if ( mattry == NULL )
2770 argc -= 3, argv += 3;
2772 else if ( argc && !strcmp( argv[0],
"NULL" ) )
2775 argc -= 1, argv += 1;
2780 wrap = atoi( argv[0] );
2786 Tcl_SetResult( interp,
"plshade: bogus arg list", TCL_STATIC );
2793 if ( !strcmp( pltrname,
"NULL" ) )
2801 Tcl_SetResult( interp,
"Must use pltr2 if want wrapping.", TCL_STATIC );
2805 else if ( !strcmp( pltrname,
"pltr0" ) )
2813 Tcl_SetResult( interp,
"Must use pltr2 if want wrapping.", TCL_STATIC );
2817 else if ( !strcmp( pltrname,
"pltr1" ) )
2822 cgrid1.
yg = mattry->fdata;
2829 Tcl_SetResult( interp,
"Must use pltr2 if want wrapping.", TCL_STATIC );
2833 if ( mattrx->
dim != 1 || mattry->dim != 1 )
2835 Tcl_SetResult( interp,
"Must use 1-d coord arrays with pltr1.", TCL_STATIC );
2839 pltr_data = &cgrid1;
2841 else if ( !strcmp( pltrname,
"pltr2" ) )
2854 for ( i = 0; i <
nx; i++ )
2855 for ( j = 0; j < ny; j++ )
2856 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
2859 for ( i = 0; i <
nx; i++ )
2860 for ( j = 0; j < ny; j++ )
2861 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
2863 else if ( wrap == 1 )
2873 for ( i = 0; i <
nx; i++ )
2874 for ( j = 0; j < ny; j++ )
2875 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
2878 for ( i = 0; i <
nx; i++ )
2880 for ( j = 0; j < ny; j++ )
2882 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
2883 zwrapped[i][j] = z[i][j];
2887 for ( j = 0; j < ny; j++ )
2889 cgrid2.
xg[
nx][j] = cgrid2.
xg[0][j];
2890 cgrid2.
yg[
nx][j] = cgrid2.
yg[0][j];
2891 zwrapped[
nx][j] = zwrapped[0][j];
2900 else if ( wrap == 2 )
2910 for ( i = 0; i <
nx; i++ )
2911 for ( j = 0; j < ny; j++ )
2912 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
2915 for ( i = 0; i <
nx; i++ )
2917 for ( j = 0; j < ny; j++ )
2919 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
2920 zwrapped[i][j] = z[i][j];
2924 for ( i = 0; i <
nx; i++ )
2926 cgrid2.
xg[i][ny] = cgrid2.
xg[i][0];
2927 cgrid2.
yg[i][ny] = cgrid2.
yg[i][0];
2928 zwrapped[i][ny] = zwrapped[i][0];
2939 Tcl_SetResult( interp,
"Invalid wrap specifier, must be <empty>, 0, 1, or 2.", TCL_STATIC );
2944 pltr_data = &cgrid2;
2948 Tcl_AppendResult( interp,
2949 "Unrecognized coordinate transformation spec:",
2950 pltrname,
", must be NULL, pltr0, pltr1, or pltr2.",
2957 plshade( (
const PLFLT *
const *) zused, nx, ny, NULL,
2958 xmin, xmax, ymin, ymax,
2959 sh_min, sh_max, sh_cmap, sh_col, sh_wid,
2960 min_col, min_wid, max_col, max_wid,
3016 tclMatrix *matPtr, *matz, *mattrx = NULL, *mattry = NULL;
3018 PLFLT **z, **zused, **zwrapped;
3023 const char *pltrname =
"pltr0";
3029 int nx, ny, nlevel, i, j;
3033 Tcl_AppendResult( interp,
"bogus syntax for plshades, see doc.",
3041 if ( matz->
dim != 2 )
3043 Tcl_SetResult( interp,
"Must plot a 2-d matrix.", TCL_STATIC );
3050 tclmateval_modx =
nx;
3051 tclmateval_mody = ny;
3056 for ( i = 0; i <
nx; i++ )
3058 for ( j = 0; j < ny; j++ )
3064 xmin = atof( argv[2] );
3065 xmax = atof( argv[3] );
3066 ymin = atof( argv[4] );
3067 ymax = atof( argv[5] );
3070 if ( matclevel == NULL )
3072 nlevel = matclevel->
n[0];
3073 if ( matclevel->
dim != 1 )
3075 Tcl_SetResult( interp,
"clevel must be 1-d matrix.", TCL_STATIC );
3079 fill_width = atof( argv[7] );
3080 cont_color = atoi( argv[8] );
3082 rect = atoi( argv[10] );
3084 argc -= 11, argv += 11;
3090 if ( mattrx == NULL )
3093 if ( mattry == NULL )
3096 argc -= 3, argv += 3;
3098 else if ( argc && !strcmp( argv[0],
"NULL" ) )
3101 argc -= 1, argv += 1;
3106 wrap = atoi( argv[0] );
3112 Tcl_SetResult( interp,
"plshades: bogus arg list", TCL_STATIC );
3119 if ( !strcmp( pltrname,
"NULL" ) )
3127 Tcl_SetResult( interp,
"Must use pltr2 if want wrapping.", TCL_STATIC );
3131 else if ( !strcmp( pltrname,
"pltr0" ) )
3139 Tcl_SetResult( interp,
"Must use pltr2 if want wrapping.", TCL_STATIC );
3143 else if ( !strcmp( pltrname,
"pltr1" ) )
3148 cgrid1.
yg = mattry->fdata;
3155 Tcl_SetResult( interp,
"Must use pltr2 if want wrapping.", TCL_STATIC );
3159 if ( mattrx->
dim != 1 || mattry->dim != 1 )
3161 Tcl_SetResult( interp,
"Must use 1-d coord arrays with pltr1.", TCL_STATIC );
3165 pltr_data = &cgrid1;
3167 else if ( !strcmp( pltrname,
"pltr2" ) )
3180 for ( i = 0; i <
nx; i++ )
3181 for ( j = 0; j < ny; j++ )
3182 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
3185 for ( i = 0; i <
nx; i++ )
3186 for ( j = 0; j < ny; j++ )
3187 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
3189 else if ( wrap == 1 )
3199 for ( i = 0; i <
nx; i++ )
3200 for ( j = 0; j < ny; j++ )
3201 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
3204 for ( i = 0; i <
nx; i++ )
3206 for ( j = 0; j < ny; j++ )
3208 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
3209 zwrapped[i][j] = z[i][j];
3213 for ( j = 0; j < ny; j++ )
3215 cgrid2.
xg[
nx][j] = cgrid2.
xg[0][j];
3216 cgrid2.
yg[
nx][j] = cgrid2.
yg[0][j];
3217 zwrapped[
nx][j] = zwrapped[0][j];
3226 else if ( wrap == 2 )
3236 for ( i = 0; i <
nx; i++ )
3237 for ( j = 0; j < ny; j++ )
3238 cgrid2.
xg[i][j] = mattrx->
fdata[
I2D( i, j ) ];
3241 for ( i = 0; i <
nx; i++ )
3243 for ( j = 0; j < ny; j++ )
3245 cgrid2.
yg[i][j] = mattry->fdata[
I2D( i, j ) ];
3246 zwrapped[i][j] = z[i][j];
3250 for ( i = 0; i <
nx; i++ )
3252 cgrid2.
xg[i][ny] = cgrid2.
xg[i][0];
3253 cgrid2.
yg[i][ny] = cgrid2.
yg[i][0];
3254 zwrapped[i][ny] = zwrapped[i][0];
3265 Tcl_SetResult( interp,
"Invalid wrap specifier, must be <empty>, 0, 1, or 2.", TCL_STATIC );
3270 pltr_data = &cgrid2;
3274 Tcl_AppendResult( interp,
3275 "Unrecognized coordinate transformation spec:",
3276 pltrname,
", must be NULL, pltr0, pltr1, or pltr2.",
3283 plshades( (
const PLFLT *
const *) zused, nx, ny, NULL,
3284 xmin, xmax, ymin, ymax,
3331 cmd = (
char *) malloc( strlen( transform_name ) + 40 );
3334 sprintf( cmd,
"matrix %cx f %d", (
char) 1, n );
3335 if ( Tcl_Eval( tcl_interp, cmd ) != TCL_OK )
3337 return_code = TCL_ERROR;
3341 sprintf( cmd,
"matrix %cy f %d", (
char) 1, n );
3342 if ( Tcl_Eval( tcl_interp, cmd ) != TCL_OK )
3344 return_code = TCL_ERROR;
3349 sprintf( cmd,
"%cx", (
char) 1 );
3351 sprintf( cmd,
"%cy", (
char) 1 );
3354 if ( xPtr == NULL || yPtr == NULL )
3357 for ( i = 0; i < n; i++ )
3359 xPtr->
fdata[i] = x[i];
3360 yPtr->
fdata[i] = y[i];
3364 sprintf( cmd,
"%s %d %cx %cy", transform_name, n, (
char) 1, (
char) 1 );
3365 return_code = Tcl_Eval( tcl_interp, cmd );
3366 if ( return_code != TCL_OK )
3374 for ( i = 0; i < n; i++ )
3376 x[i] = xPtr->
fdata[i];
3377 y[i] = yPtr->
fdata[i];
3383 sprintf( cmd,
"rename %cx {}; rename %cy {}", (
char) 1, (
char) 1 );
3384 return_code = Tcl_Eval( tcl_interp, cmd );
3403 PLFLT minlong, maxlong, minlat, maxlat;
3407 return_code = TCL_OK;
3408 if ( argc < 6 || argc > 7 )
3410 Tcl_AppendResult( interp,
"bogus syntax for plmap, see doc.",
3419 transform_name = NULL;
3420 minlong = atof( argv[2] );
3421 maxlong = atof( argv[3] );
3422 minlat = atof( argv[4] );
3423 maxlat = atof( argv[5] );
3429 minlong = atof( argv[3] );
3430 maxlong = atof( argv[4] );
3431 minlat = atof( argv[5] );
3432 maxlat = atof( argv[6] );
3435 transform_name = argv[1];
3436 if ( strlen( transform_name ) == 0 )
3442 if ( transform && idxname == 2 )
3444 plmap( &
mapform, argv[idxname], minlong, maxlong, minlat, maxlat );
3449 plmap( NULL, argv[idxname], minlong, maxlong, minlat, maxlat );
3470 PLFLT dlong, dlat, minlong, maxlong, minlat, maxlat;
3473 return_code = TCL_OK;
3475 if ( argc < 7 || argc > 8 )
3477 Tcl_AppendResult( interp,
"bogus syntax for plmeridians, see doc.",
3485 transform_name = NULL;
3486 dlong = atof( argv[1] );
3487 dlat = atof( argv[2] );
3488 minlong = atof( argv[3] );
3489 maxlong = atof( argv[4] );
3490 minlat = atof( argv[5] );
3491 maxlat = atof( argv[6] );
3495 dlong = atof( argv[2] );
3496 dlat = atof( argv[3] );
3497 minlong = atof( argv[4] );
3498 maxlong = atof( argv[5] );
3499 minlat = atof( argv[6] );
3500 maxlat = atof( argv[7] );
3504 transform_name = argv[1];
3505 if ( strlen( transform_name ) == 0 )
3517 plmeridians( NULL, dlong, dlat, minlong, maxlong, minlat, maxlat );
3527 #if TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION < 5
3528 "set result [%s ${_##_x} ${_##_y}] ; set _##_x [lindex $result 0] ; set _##_y [lindex $result 1]"
3530 "set result [%s ${_##_x} ${_##_y}] ; lassign $result _##_x _##_y"
3539 Tcl_Obj *objx, *objy;
3544 objx = Tcl_NewDoubleObj( x );
3545 Tcl_IncrRefCount( objx );
3546 Tcl_SetVar2Ex( tcl_xform_interp,
3547 "_##_x", NULL, objx, 0 );
3548 Tcl_DecrRefCount( objx );
3551 objy = Tcl_NewDoubleObj( y );
3552 Tcl_IncrRefCount( objy );
3553 Tcl_SetVar2Ex( tcl_xform_interp,
3554 "_##_y", NULL, objy, 0 );
3555 Tcl_DecrRefCount( objy );
3564 code = Tcl_Eval( tcl_xform_interp, tcl_xform_code );
3566 if ( code != TCL_OK )
3568 printf(
"Unable to evaluate Tcl-side coordinate transform.\n" );
3569 printf(
"code = %d\n", code );
3570 printf(
"Error result: %s\n", Tcl_GetStringResult( tcl_xform_interp ) );
3574 objx = Tcl_GetVar2Ex( tcl_xform_interp,
"_##_x", NULL, 0 );
3575 objy = Tcl_GetVar2Ex( tcl_xform_interp,
"_##_y", NULL, 0 );
3579 if ( Tcl_GetDoubleFromObj( tcl_xform_interp, objx, &dx ) != TCL_OK ||
3580 Tcl_GetDoubleFromObj( tcl_xform_interp, objy, &dy ) != TCL_OK )
3582 printf(
"Unable to extract Tcl results.\n" );
3601 || strcmp( argv[1],
"NULL" ) == 0 )
3605 tcl_xform_interp = 0;
3606 if ( tcl_xform_procname )
3608 free( tcl_xform_procname );
3609 tcl_xform_procname = 0;
3616 tcl_xform_interp =
interp;
3617 tcl_xform_procname =
plstrdup( argv[1] );
3619 len = strlen( tcl_xform_template ) + strlen( tcl_xform_procname );
3620 tcl_xform_code = malloc( len );
3621 sprintf( tcl_xform_code, tcl_xform_template, tcl_xform_procname );
3638 tclMatrix *arrx, *arry, *arrz, *xcoord, *ycoord, *zvalue;
3648 Tcl_AppendResult( interp,
"wrong # args: see documentation for ",
3649 argv[0], (
char *) NULL );
3662 sscanf( argv[7],
"%d", &alg );
3664 sscanf( argv[8],
"%lg", &value ); optalg = (
PLFLT) value;
3666 if ( arrx == NULL || arrx->
dim != 1 )
3668 Tcl_AppendResult( interp, argv[0],
": argument 1 should be a \
3669 one-dimensional matrix - ", argv[1], (
char *) NULL );
3672 if ( arry == NULL || arry->
dim != 1 )
3674 Tcl_AppendResult( interp, argv[0],
": argument 2 should be a \
3675 one-dimensional matrix - ", argv[2], (
char *) NULL );
3678 if ( arrz == NULL || arrz->
dim != 1 )
3680 Tcl_AppendResult( interp, argv[0],
": argument 3 should be a \
3681 one-dimensional matrix - ", argv[3], (
char *) NULL );
3685 if ( xcoord == NULL || xcoord->
dim != 1 )
3687 Tcl_AppendResult( interp, argv[0],
": argument 4 should be a \
3688 one-dimensional matrix - ", argv[4], (
char *) NULL );
3691 if ( ycoord == NULL || ycoord->
dim != 1 )
3693 Tcl_AppendResult( interp, argv[0],
": argument 5 should be a \
3694 one-dimensional matrix - ", argv[5], (
char *) NULL );
3697 if ( zvalue == NULL || zvalue->
dim != 2 )
3699 Tcl_AppendResult( interp, argv[0],
": argument 6 should be a \
3700 two-dimensional matrix - ", argv[6], (
char *) NULL );
3714 xcoord->
fdata, nx, ycoord->
fdata, ny, z, alg, optalg );
3717 for ( i = 0; i <
nx; i++ )
3719 for ( j = 0; j < ny; j++ )
3721 zvalue->
fdata[j + zvalue->
n[1] * i] = z[i][j];
3748 Tcl_AppendResult( interp,
"wrong # args: see documentation for ",
3749 argv[0], (
char *) NULL );
3755 if ( zvalue == NULL || zvalue->
dim != 2 )
3757 Tcl_AppendResult( interp, argv[0],
": argument 1 should be a \
3758 two-dimensional matrix - ", argv[1], (
char *) NULL );
3762 sscanf( argv[2],
"%lg", &value ); xmin = (
PLFLT) value;
3763 sscanf( argv[3],
"%lg", &value ); xmax = (
PLFLT) value;
3764 sscanf( argv[4],
"%lg", &value ); ymin = (
PLFLT) value;
3765 sscanf( argv[5],
"%lg", &value ); ymax = (
PLFLT) value;
3766 sscanf( argv[6],
"%lg", &value ); zmin = (
PLFLT) value;
3767 sscanf( argv[7],
"%lg", &value ); zmax = (
PLFLT) value;
3768 sscanf( argv[8],
"%lg", &value ); Dxmin = (
PLFLT) value;
3769 sscanf( argv[9],
"%lg", &value ); Dxmax = (
PLFLT) value;
3770 sscanf( argv[10],
"%lg", &value ); Dymin = (
PLFLT) value;
3771 sscanf( argv[11],
"%lg", &value ); Dymax = (
PLFLT) value;
3778 for ( i = 0; i <
nx; i++ )
3780 for ( j = 0; j < ny; j++ )
3782 pidata[i][j] = zvalue->
fdata[j + i * ny];
3794 c_plimage( (
const PLFLT *
const *) pidata, nx, ny, xmin, xmax, ymin, ymax, zmin, zmax,
3795 Dxmin, Dxmax, Dymin, Dymax );
3825 if ( argc != 12 && argc != 10 )
3827 Tcl_AppendResult( interp,
"wrong # args: see documentation for ",
3828 argv[0], (
char *) NULL );
3834 if ( zvalue == NULL || zvalue->
dim != 2 )
3836 Tcl_AppendResult( interp, argv[0],
": argument 1 should be a \
3837 two-dimensional matrix - ", argv[1], (
char *) NULL );
3848 if ( xg == NULL || xg->
dim != 2 )
3850 Tcl_AppendResult( interp, argv[0],
": argument 10 should be a \
3851 two-dimensional matrix - ", argv[10], (
char *) NULL );
3855 if ( yg == NULL || yg->
dim != 2 )
3857 Tcl_AppendResult( interp, argv[0],
": argument 11 should be a \
3858 two-dimensional matrix - ", argv[11], (
char *) NULL );
3863 sscanf( argv[2],
"%lg", &value ); xmin = (
PLFLT) value;
3864 sscanf( argv[3],
"%lg", &value ); xmax = (
PLFLT) value;
3865 sscanf( argv[4],
"%lg", &value ); ymin = (
PLFLT) value;
3866 sscanf( argv[5],
"%lg", &value ); ymax = (
PLFLT) value;
3867 sscanf( argv[6],
"%lg", &value ); zmin = (
PLFLT) value;
3868 sscanf( argv[7],
"%lg", &value ); zmax = (
PLFLT) value;
3869 sscanf( argv[8],
"%lg", &value ); valuemin = (
PLFLT) value;
3870 sscanf( argv[9],
"%lg", &value ); valuemax = (
PLFLT) value;
3877 for ( i = 0; i <
nx; i++ )
3879 for ( j = 0; j < ny; j++ )
3881 pidata[i][j] = zvalue->
fdata[j + i * ny];
3892 for ( i = 0; i <=
nx; i++ )
3894 for ( j = 0; j <= ny; j++ )
3896 cgrid2.
xg[i][j] = xg->
fdata[j + i * ( ny + 1 )];
3897 cgrid2.
yg[i][j] = yg->
fdata[j + i * ( ny + 1 )];
3900 c_plimagefr( (
const PLFLT *
const *) pidata, nx, ny, xmin, xmax, ymin, ymax, zmin, zmax,
3901 valuemin, valuemax,
pltr2, (
void *) &cgrid2 );
3905 c_plimagefr( (
const PLFLT *
const *) pidata, nx, ny, xmin, xmax, ymin, ymax, zmin, zmax,
3906 valuemin, valuemax,
pltr0, NULL );
3939 PLINT colbox, collab;
3940 PLINT colline[4], styline[4];
3942 const char **legline;
3950 Tcl_AppendResult( interp,
"wrong # args: see documentation for ",
3951 argv[0], (
char *) NULL );
3958 if ( colMat == NULL || colMat->
dim != 1 || colMat->
idata == NULL )
3960 Tcl_AppendResult( interp, argv[0],
": argument 15 should be a \
3961 one-dimensional integer matrix - ", argv[15], (
char *) NULL );
3965 if ( styleMat == NULL || styleMat->
dim != 1 || styleMat->
idata == NULL )
3967 Tcl_AppendResult( interp, argv[0],
": argument 16 should be a \
3968 one-dimensional integer matrix - ", argv[16], (
char *) NULL );
3976 sscanf( argv[4],
"%lg", &value ); xmin = (
PLFLT) value;
3977 sscanf( argv[5],
"%lg", &value ); xmax = (
PLFLT) value;
3978 sscanf( argv[6],
"%lg", &value ); xjump = (
PLFLT) value;
3979 sscanf( argv[7],
"%lg", &value ); ymin = (
PLFLT) value;
3980 sscanf( argv[8],
"%lg", &value ); ymax = (
PLFLT) value;
3981 sscanf( argv[9],
"%lg", &value ); xlpos = (
PLFLT) value;
3982 sscanf( argv[10],
"%lg", &value ); ylpos = (
PLFLT) value;
3983 sscanf( argv[11],
"%d", &ivalue ); y_ascl = (
PLBOOL) ivalue;
3984 sscanf( argv[12],
"%d", &ivalue ); acc = (
PLBOOL) ivalue;
3985 sscanf( argv[13],
"%d", &ivalue ); colbox = ivalue;
3986 sscanf( argv[14],
"%d", &ivalue ); collab = ivalue;
3992 for ( i = 0; i < 4; i++ )
3994 colline[i] = colMat->
idata[i];
3995 styline[i] = styleMat->
idata[i];
3998 if ( Tcl_SplitList( interp, argv[17], &nlegend, &legline ) != TCL_OK )
4004 Tcl_AppendResult( interp, argv[0],
": argument 18 should be a \
4005 list of at least four items - ", argv[17], (
char *) NULL );
4010 xmin, xmax, xjump, ymin, ymax,
4014 colline, styline, legline,
4015 labx, laby, labtop );
4017 sprintf( idvalue,
"%d",
id );
4018 Tcl_SetVar( interp, idName, idvalue, 0 );
4020 Tcl_Free( (
char *) legline );
4039 label_objs[1] = Tcl_NewIntObj( axis );
4040 label_objs[2] = Tcl_NewDoubleObj( (
double) value );
4042 Tcl_IncrRefCount( label_objs[1] );
4043 Tcl_IncrRefCount( label_objs[2] );
4047 if ( label_objs[3] != NULL )
4052 return_code = Tcl_EvalObjv( tcl_interp, objc, label_objs, 0 );
4054 if ( return_code != TCL_OK )
4056 strncpy(
string,
"ERROR", (
size_t) string_length );
4060 strncpy(
string, Tcl_GetStringResult( tcl_interp ), (
size_t) string_length );
4063 Tcl_DecrRefCount( label_objs[1] );
4064 Tcl_DecrRefCount( label_objs[2] );
4080 if ( argc < 2 || argc > 3 )
4082 Tcl_AppendResult( interp,
"bogus syntax for plslabelfunc, see doc.",
4089 if ( label_objs[0] != NULL )
4091 Tcl_DecrRefCount( label_objs[0] );
4093 if ( label_objs[3] != NULL )
4095 Tcl_DecrRefCount( label_objs[3] );
4096 label_objs[3] = NULL;
4099 if ( strlen( argv[1] ) == 0 )
4107 label_objs[0] = Tcl_NewStringObj( argv[1], (
int) strlen( argv[1] ) );
4108 Tcl_IncrRefCount( label_objs[0] );
4113 label_objs[3] = Tcl_NewStringObj( argv[2], (
int) strlen( argv[2] ) );
4114 Tcl_IncrRefCount( label_objs[3] );
4118 label_objs[3] = NULL;
4133 static int *
argv_to_ints( Tcl_Interp *interp,
const char *list_numbers,
int *number )
4140 list = Tcl_NewStringObj( list_numbers, ( -1 ) );
4142 retcode = Tcl_ListObjLength( interp, list, number );
4143 if ( retcode != TCL_OK || ( *number ) == 0 )
4150 array = (
int *) malloc(
sizeof (
int ) * (size_t) ( *number ) );
4151 for ( i = 0; i < ( *number ); i++ )
4153 Tcl_ListObjIndex( interp, list, i, &elem );
4154 Tcl_GetIntFromObj( interp, elem, &array[i] );
4160 static double *
argv_to_doubles( Tcl_Interp *interp,
const char *list_numbers,
int *number )
4167 list = Tcl_NewStringObj( list_numbers, ( -1 ) );
4169 retcode = Tcl_ListObjLength( interp, list, number );
4170 if ( retcode != TCL_OK || ( *number ) == 0 )
4177 array = (
double *) malloc(
sizeof (
double ) * (size_t) ( *number ) );
4178 for ( i = 0; i < ( *number ); i++ )
4180 Tcl_ListObjIndex( interp, list, i, &elem );
4181 Tcl_GetDoubleFromObj( interp, elem, &array[i] );
4187 static char **
argv_to_chars( Tcl_Interp *interp,
const char *list_strings,
int *number )
4197 list = Tcl_NewStringObj( list_strings, ( -1 ) );
4199 retcode = Tcl_ListObjLength( interp, list, number );
4200 if ( retcode != TCL_OK || ( *number ) == 0 )
4207 array = (
char **) malloc(
sizeof (
char* ) * (size_t) ( *number ) );
4208 array[0] = (
char *) malloc(
sizeof (
char ) * ( strlen( list_strings ) + 1 ) );
4210 for ( i = 0; i < ( *number ); i++ )
4212 Tcl_ListObjIndex( interp, list, i, &elem );
4213 string = Tcl_GetStringFromObj( elem, &length );
4215 array[i] = array[0] + idx;
4216 strncpy( array[i],
string, (
size_t) length );
4218 array[0][idx - 1] =
'\0';
4228 PLFLT legend_width, legend_height;
4232 PLINT nrow, ncolumn;
4235 PLFLT text_offset, text_scale, text_spacing, text_justification;
4237 PLINT *box_colors, *box_patterns;
4239 PLINT *line_colors, *line_styles;
4240 PLFLT *box_line_widths, *line_widths;
4241 PLINT *symbol_colors, *symbol_numbers;
4242 PLFLT *symbol_scales;
4255 Tcl_AppendResult( interp,
"bogus syntax for pllegend, see doc.",
4260 sscanf( argv[1],
"%d", &opt );
4261 sscanf( argv[2],
"%d", &position );
4262 sscanf( argv[3],
"%lg", &value ); x = (
PLFLT) value;
4263 sscanf( argv[4],
"%lg", &value ); y = (
PLFLT) value;
4264 sscanf( argv[5],
"%lg", &value ); plot_width = (
PLFLT) value;
4265 sscanf( argv[6],
"%d", &bg_color );
4266 sscanf( argv[7],
"%d", &bb_color );
4267 sscanf( argv[8],
"%d", &bb_style );
4268 sscanf( argv[9],
"%d", &nrow );
4269 sscanf( argv[10],
"%d", &ncolumn );
4270 opt_array =
argv_to_ints( interp, argv[11], &number_opts );
4271 sscanf( argv[12],
"%lg", &value ); text_offset = (
PLFLT) value;
4272 sscanf( argv[13],
"%lg", &value ); text_scale = (
PLFLT) value;
4273 sscanf( argv[14],
"%lg", &value ); text_spacing = (
PLFLT) value;
4274 sscanf( argv[15],
"%lg", &value ); text_justification = (
PLFLT) value;
4276 text_colors =
argv_to_ints( interp, argv[16], &dummy );
4279 box_patterns =
argv_to_ints( interp, argv[19], &dummy );
4282 line_colors =
argv_to_ints( interp, argv[22], &dummy );
4283 line_styles =
argv_to_ints( interp, argv[23], &dummy );
4285 symbol_colors =
argv_to_ints( interp, argv[25], &dummy );
4287 symbol_numbers =
argv_to_ints( interp, argv[27], &dummy );
4290 nlegend =
MIN( number_opts, number_texts );
4293 opt, position, x, y, plot_width,
4294 bg_color, bb_color, bb_style,
4297 text_offset, text_scale, text_spacing,
4299 text_colors, (
const char *
const *) text,
4300 box_colors, box_patterns,
4301 box_scales, box_line_widths,
4302 line_colors, line_styles,
4304 symbol_colors, symbol_scales,
4305 symbol_numbers, (
const char *
const *) symbols );
4307 if ( opt_array != NULL )
4309 if ( text_colors != NULL )
4310 free( text_colors );
4316 if ( box_colors != NULL )
4318 if ( box_patterns != NULL )
4319 free( box_patterns );
4320 if ( box_scales != NULL )
4322 if ( box_line_widths != NULL )
4323 free( box_line_widths );
4324 if ( line_colors != NULL )
4325 free( line_colors );
4326 if ( line_styles != NULL )
4327 free( line_styles );
4328 if ( line_widths != NULL )
4329 free( line_widths );
4330 if ( symbol_colors != NULL )
4331 free( symbol_colors );
4332 if ( symbol_scales != NULL )
4333 free( symbol_scales );
4334 if ( symbol_numbers != NULL )
4335 free( symbol_numbers );
4336 if ( symbols != NULL )
4342 data[0] = Tcl_NewDoubleObj( legend_width );
4343 data[1] = Tcl_NewDoubleObj( legend_height );
4344 Tcl_SetObjResult( interp, Tcl_NewListObj( 2, data ) );
4359 PLFLT colorbar_width, colorbar_height;
4377 Tcl_Obj *list_vectors;
4379 PLINT *vector_sizes;
4380 PLFLT **vector_values;
4393 Tcl_AppendResult( interp,
"bogus syntax for plcolorbar, see doc.",
4399 sscanf( argv[1],
"%d", &opt );
4400 sscanf( argv[2],
"%d", &position );
4401 sscanf( argv[3],
"%lg", &value ); x = (
PLFLT) value;
4402 sscanf( argv[4],
"%lg", &value ); y = (
PLFLT) value;
4403 sscanf( argv[5],
"%lg", &value ); x_length = (
PLFLT) value;
4404 sscanf( argv[6],
"%lg", &value ); y_length = (
PLFLT) value;
4405 sscanf( argv[7],
"%d", &bg_color );
4406 sscanf( argv[8],
"%d", &bb_color );
4407 sscanf( argv[9],
"%d", &bb_style );
4408 sscanf( argv[10],
"%lg", &value ); low_cap_color = (
PLFLT) value;
4409 sscanf( argv[11],
"%lg", &value ); high_cap_color = (
PLFLT) value;
4410 sscanf( argv[12],
"%d", &cont_color );
4411 sscanf( argv[13],
"%lg", &value ); cont_width = (
PLFLT) value;
4412 label_opts =
argv_to_ints( interp, argv[14], &n_label_opts );
4414 axis_opts =
argv_to_chars( interp, argv[16], &n_axis_opts );
4416 sub_ticks =
argv_to_ints( interp, argv[18], &n_sub_ticks );
4417 list_vectors = Tcl_NewStringObj( argv[19], ( -1 ) );
4420 if ( n_label_opts != n_labels )
4422 Tcl_AppendResult( interp,
"number of label options must equal number of labels.",
4426 if ( n_axis_opts != n_ticks || n_axis_opts != n_sub_ticks )
4428 Tcl_AppendResult( interp,
"number of axis, tick and subtick options must be equal.",
4432 n_axes = n_axis_opts;
4434 retcode = Tcl_ListObjLength( interp, list_vectors, &n_vectors );
4435 if ( retcode != TCL_OK || n_vectors == 0 )
4437 Tcl_AppendResult( interp,
"malformed list of vectors or no vector at all.",
4443 vector_sizes = (
int *) malloc(
sizeof (
int ) * (size_t) n_vectors );
4444 vector_values = (
PLFLT **) malloc(
sizeof (
PLFLT * ) * (size_t) n_vectors );
4445 for ( i = 0; i < n_vectors; i++ )
4447 Tcl_ListObjIndex( interp, list_vectors, i, &vector );
4448 vectorPtr =
Tcl_GetMatrixPtr( interp, Tcl_GetStringFromObj( vector, &length ) );
4449 if ( vectorPtr == NULL || vectorPtr->
dim != 1 )
4451 Tcl_AppendResult( interp,
"element in list of vectors is not a vector.",
4455 vector_sizes[i] = vectorPtr->
n[0];
4456 vector_values[i] = vectorPtr->
fdata;
4461 opt, position, x, y,
4463 bg_color, bb_color, bb_style,
4464 low_cap_color, high_cap_color,
4465 cont_color, cont_width,
4466 n_labels, label_opts, (
const char *
const *) labels,
4467 n_axes, (
const char *
const *) axis_opts,
4469 vector_sizes, (
const PLFLT *
const *) vector_values );
4471 if ( label_opts != NULL )
4473 if ( labels != NULL )
4478 if ( axis_opts != NULL )
4480 free( axis_opts[0] );
4483 if ( ticks != NULL )
4485 if ( sub_ticks != NULL )
4487 if ( vector_values != NULL )
4489 free( vector_sizes );
4490 free( vector_values );
4493 Tcl_DecrRefCount( list_vectors );
4495 data[0] = Tcl_NewDoubleObj( colorbar_width );
4496 data[1] = Tcl_NewDoubleObj( colorbar_height );
4497 Tcl_SetObjResult( interp, Tcl_NewListObj( 2, data ) );