71 #define XSynchronize( display, bool ) { display->request++; }
72 #define XSync( display, bool ) { display->request++; }
73 #define XFlush( display )
79 #define dbug_enter( a ) if ( plsc->debug ) { \
80 Tcl_Write( Tcl_GetStdChannel( TCL_STDERR ), a, -1 ); }
84 #ifdef PL_HAVE_UNISTD_H
93 #define NDEV 100 // Max number of output device types
206 #define REFRESH_PENDING 1
207 #define RESIZE_PENDING 2
208 #define REDRAW_PENDING 4
209 #define UPDATE_V_SCROLLBAR 8
210 #define UPDATE_H_SCROLLBAR 16
214 #define DEF_PLFRAME_BG_COLOR "Black"
215 #define DEF_PLFRAME_BG_MONO "White"
216 #define DEF_PLFRAME_BORDER_WIDTH "0"
217 #define DEF_PLFRAME_CURSOR ( (char *) NULL )
218 #define DEF_PLFRAME_HEIGHT "250"
219 #define DEF_PLFRAME_RELIEF "flat"
220 #define DEF_PLFRAME_WIDTH "250"
225 { TK_CONFIG_BOOLEAN,
"-activeplot", (
char *) NULL, (
char *) NULL,
226 "1", Tk_Offset(
PlPlotter, active_plot ), TK_CONFIG_DONT_SET_DEFAULT },
227 { TK_CONFIG_BORDER,
"-background",
"background",
"Background",
229 TK_CONFIG_COLOR_ONLY },
230 { TK_CONFIG_BORDER,
"-background",
"background",
"Background",
232 TK_CONFIG_MONO_ONLY },
233 { TK_CONFIG_SYNONYM,
"-bd",
"borderWidth", (
char *) NULL,
234 (
char *) NULL, 0, 0 },
235 { TK_CONFIG_SYNONYM,
"-bg",
"background", (
char *) NULL,
236 (
char *) NULL, 0, 0 },
237 { TK_CONFIG_STRING,
"-bopcmd",
"bopcmd",
"PgCommand",
238 (
char *) NULL, Tk_Offset(
PlPlotter, bopCmd ), TK_CONFIG_NULL_OK },
239 { TK_CONFIG_PIXELS,
"-borderwidth",
"borderWidth",
"BorderWidth",
241 { TK_CONFIG_BOOLEAN,
"-doublebuffer", (
char *) NULL, (
char *) NULL,
242 "0", Tk_Offset(
PlPlotter, double_buffer ), TK_CONFIG_DONT_SET_DEFAULT },
243 { TK_CONFIG_ACTIVE_CURSOR,
"-cursor",
"cursor",
"Cursor",
245 { TK_CONFIG_STRING,
"-eopcmd",
"eopcmd",
"PgCommand",
246 (
char *) NULL, Tk_Offset(
PlPlotter, eopCmd ), TK_CONFIG_NULL_OK },
247 { TK_CONFIG_PIXELS,
"-height",
"height",
"Height",
249 { TK_CONFIG_RELIEF,
"-relief",
"relief",
"Relief",
251 { TK_CONFIG_PIXELS,
"-width",
"width",
"Width",
253 { TK_CONFIG_BOOLEAN,
"-xhairs", (
char *) NULL, (
char *) NULL,
254 "0", Tk_Offset(
PlPlotter, xhairs ), TK_CONFIG_DONT_SET_DEFAULT },
255 { TK_CONFIG_BOOLEAN,
"-rubberband", (
char *) NULL, (
char *) NULL,
256 "0", Tk_Offset(
PlPlotter, rband ), TK_CONFIG_DONT_SET_DEFAULT },
257 { TK_CONFIG_STRING,
"-xscrollcommand",
"xScrollCommand",
"ScrollCommand",
258 (
char *) NULL, Tk_Offset(
PlPlotter, xScrollCmd ), TK_CONFIG_NULL_OK },
259 { TK_CONFIG_STRING,
"-yscrollcommand",
"yScrollCommand",
"ScrollCommand",
260 (
char *) NULL, Tk_Offset(
PlPlotter, yScrollCmd ), TK_CONFIG_NULL_OK },
261 { TK_CONFIG_END, (
char *) NULL, (
char *) NULL, (
char *) NULL,
262 (
char *) NULL, 0, 0 }
269 int plPlotterCmd( ClientData, Tcl_Interp *,
int,
const char ** );
286 static int ReadData( ClientData,
int );
292 static int Cmd( Tcl_Interp *,
PlPlotter *,
int, CONST
char ** );
294 static int Draw( Tcl_Interp *,
PlPlotter *,
int, CONST
char ** );
295 static int Info( Tcl_Interp *,
PlPlotter *,
int, CONST
char ** );
298 static int Page( Tcl_Interp *,
PlPlotter *,
int, CONST
char ** );
300 static int Print( Tcl_Interp *,
PlPlotter *,
int, CONST
char ** );
302 static int Save( Tcl_Interp *,
PlPlotter *,
int, CONST
char ** );
303 static int View( Tcl_Interp *,
PlPlotter *,
int, CONST
char ** );
359 Tcl_AppendResult( interp,
"wrong # args: should be \"",
360 argv[0],
" pathName ?options?\"", (
char *) NULL );
366 tkwin = Tk_CreateWindowFromPath( interp, Tk_MainWindow( interp ), argv[1], (
char *) NULL );
371 Tk_SetClass( tkwin,
"Plframe" );
377 plPlotterPtr->
tkwin = tkwin;
378 plPlotterPtr->
display = Tk_Display( tkwin );
381 Tcl_CreateCommand( interp, Tk_PathName( plPlotterPtr->
tkwin ),
383 (Tcl_CmdDeleteProc *) NULL );
384 plPlotterPtr->border = NULL;
387 plPlotterPtr->width = Tk_Width( plPlotterPtr->tkwin );
388 plPlotterPtr->height = Tk_Height( plPlotterPtr->tkwin );
389 plPlotterPtr->cursor = None;
390 plPlotterPtr->flags = 0;
391 plPlotterPtr->tkwin_initted = 0;
394 plgpls( &plPlotterPtr->pls );
395 plPlotterPtr->ipls_save = 0;
396 plPlotterPtr->plr = (
PLRDev *) malloc(
sizeof (
PLRDev ) );
397 plPlotterPtr->plpr_cmd = NULL;
398 plPlotterPtr->active_plot = 1;
399 plPlotterPtr->isActive = 0;
400 plPlotterPtr->pldis.x = 0;
401 plPlotterPtr->pldis.y = 0;
402 plPlotterPtr->pldis.width = 0;
403 plPlotterPtr->pldis.height = 0;
404 plPlotterPtr->prevWidth = 0;
405 plPlotterPtr->prevHeight = 0;
406 plPlotterPtr->SaveFnam = NULL;
409 plPlotterPtr->xorGC = NULL;
411 plPlotterPtr->continue_draw = 0;
412 plPlotterPtr->xhair_cursor = None;
413 plPlotterPtr->xl = 0.;
414 plPlotterPtr->yl = 0.;
415 plPlotterPtr->xr = 1.;
416 plPlotterPtr->yr = 1.;
417 plPlotterPtr->xScrollCmd = NULL;
418 plPlotterPtr->yScrollCmd = NULL;
419 plPlotterPtr->bopCmd = NULL;
420 plPlotterPtr->eopCmd = NULL;
421 plPlotterPtr->xhairs = 0;
422 plPlotterPtr->drawing_xhairs = 0;
425 plPlotterPtr->rband = 0;
426 plPlotterPtr->drawing_rband = 0;
428 plPlotterPtr->double_buffer = 1;
430 plr = plPlotterPtr->plr;
436 plPlotterPtr->pls->plPlotterPtr = plPlotterPtr;
440 plPlotterPtr->xhair_cursor =
441 Tk_GetCursor( plPlotterPtr->interp, plPlotterPtr->tkwin,
"crosshair" );
449 plPlotterPtr->devDesc = (
const char **) malloc( (
size_t)
NDEV *
sizeof (
char ** ) );
450 plPlotterPtr->devName = (
const char **) malloc( (
size_t)
NDEV *
sizeof (
char ** ) );
451 for ( i = 0; i <
NDEV; i++ )
453 plPlotterPtr->devDesc[i] = NULL;
454 plPlotterPtr->devName[i] = NULL;
457 plgFileDevs( &plPlotterPtr->devDesc, &plPlotterPtr->devName, &ndev );
461 Tk_CreateEventHandler( plPlotterPtr->tkwin, StructureNotifyMask,
464 Tk_CreateEventHandler( plPlotterPtr->tkwin, ExposureMask,
470 if (
ConfigurePlPlotter( interp, plPlotterPtr, argc - 2, (CONST
char **) argv + 2, 0 ) != TCL_OK )
472 Tk_DestroyWindow( plPlotterPtr->tkwin );
475 Tk_MakeWindowExist( plPlotterPtr->tkwin );
477 Tk_GeometryRequest( plPlotterPtr->tkwin, 200, 200 );
479 Tcl_SetResult( interp, Tk_PathName( plPlotterPtr->tkwin ), TCL_VOLATILE );
515 Tcl_AppendResult( interp,
"wrong # args: should be \"",
516 argv[0],
" option ?arg arg ...?\"", (
char *) NULL );
519 Tk_Preserve( (ClientData) plPlotterPtr );
521 length = (int) strlen( argv[1] );
525 if ( ( c ==
'c' ) && ( strncmp( argv[1],
"cmd", (
size_t) length ) == 0 ) )
527 result =
Cmd( interp, plPlotterPtr, argc - 2, argv + 2 );
532 else if ( ( c ==
'c' ) && ( strncmp( argv[1],
"cget", (
size_t) length ) == 0 )
537 Tcl_AppendResult( interp,
"wrong # args: should be \"",
538 argv[0],
" cget option\"",
543 result = Tk_ConfigureValue( interp, plPlotterPtr->tkwin,
configSpecs,
544 (
char *) plPlotterPtr, argv[2], 0 );
546 else if ( ( c ==
'c' ) && ( strncmp( argv[1],
"configure", (
size_t) length ) == 0 ) )
550 result = Tk_ConfigureInfo( interp, plPlotterPtr->tkwin,
configSpecs,
551 (
char *) plPlotterPtr, (
char *) NULL, 0 );
553 else if ( argc == 3 )
555 result = Tk_ConfigureInfo( interp, plPlotterPtr->tkwin,
configSpecs,
556 (
char *) plPlotterPtr, argv[2], 0 );
561 TK_CONFIG_ARGV_ONLY );
567 else if ( ( c ==
'c' ) && ( strncmp( argv[1],
"closelink", (
size_t) length ) == 0 ) )
571 Tcl_AppendResult( interp,
"wrong # args: should be \"",
572 argv[0], (
char *) NULL );
578 result =
Closelink( interp, plPlotterPtr, argc - 2, argv + 2 );
584 else if ( ( c ==
'd' ) && ( strncmp( argv[1],
"draw", (
size_t) length ) == 0 ) )
588 Tcl_AppendResult( interp,
"wrong # args: should be \"",
589 argv[0],
" draw op ?options?\"", (
char *) NULL );
595 result =
Draw( interp, plPlotterPtr, argc - 2, argv + 2 );
601 else if ( ( c ==
'i' ) && ( strncmp( argv[1],
"info", (
size_t) length ) == 0 ) )
603 result =
Info( interp, plPlotterPtr, argc - 2, argv + 2 );
608 else if ( ( c ==
'n' ) && ( strncmp( argv[1],
"nextpage", (
size_t) length ) == 0 ) )
610 result =
NextPage( interp, plPlotterPtr, argc - 2, argv + 2 );
615 else if ( ( c ==
'o' ) && ( strncmp( argv[1],
"orient", (
size_t) length ) == 0 ) )
617 result =
Orient( interp, plPlotterPtr, argc - 2, argv + 2 );
622 else if ( ( c ==
'o' ) && ( strncmp( argv[1],
"openlink", (
size_t) length ) == 0 ) )
626 Tcl_AppendResult( interp,
"wrong # args: should be \"",
627 argv[0],
" option ?arg arg ...?\"", (
char *) NULL );
633 result =
Openlink( interp, plPlotterPtr, argc - 2, argv + 2 );
639 else if ( ( c ==
'p' ) && ( strncmp( argv[1],
"page", (
size_t) length ) == 0 ) )
641 result =
Page( interp, plPlotterPtr, argc - 2, argv + 2 );
646 else if ( ( c ==
'p' ) && ( strncmp( argv[1],
"print", (
size_t) length ) == 0 ) )
648 result =
Print( interp, plPlotterPtr, argc - 2, argv + 2 );
653 else if ( ( c ==
'r' ) && ( strncmp( argv[1],
"redraw", (
size_t) length ) == 0 ) )
657 Tcl_AppendResult( interp,
"wrong # args: should be \"",
658 argv[0],
" redraw\"", (
char *) NULL );
664 result =
Redraw( interp, plPlotterPtr, argc - 2, argv + 2 );
670 else if ( ( c ==
'r' ) && ( strncmp( argv[1],
"report", (
size_t) length ) == 0 ) )
672 result =
report( interp, plPlotterPtr, argc - 2, argv + 2 );
677 else if ( ( c ==
's' ) && ( strncmp( argv[1],
"save", (
size_t) length ) == 0 ) )
679 result =
Save( interp, plPlotterPtr, argc - 2, argv + 2 );
684 else if ( ( c ==
'v' ) && ( strncmp( argv[1],
"view", (
size_t) length ) == 0 ) )
686 result =
View( interp, plPlotterPtr, argc - 2, argv + 2 );
691 else if ( ( c ==
'x' ) && ( strncmp( argv[1],
"xview", (
size_t) length ) == 0 ) )
694 double width = (double) ( plPlotterPtr->xr - plPlotterPtr->xl );
698 type = Tk_GetScrollInfo( interp, argc, argv, &fraction, &count );
701 case TK_SCROLL_ERROR:
704 case TK_SCROLL_MOVETO:
705 plPlotterPtr->xl = (
PLFLT) fraction;
706 plPlotterPtr->xr = (
PLFLT) ( fraction + width );
708 case TK_SCROLL_PAGES:
709 plPlotterPtr->xl += (
PLFLT) ( count * width * .9 );
710 plPlotterPtr->xr += (
PLFLT) ( count * width * .9 );
712 case TK_SCROLL_UNITS:
713 plPlotterPtr->xl += (
PLFLT) ( count * width / 50 );
714 plPlotterPtr->xr += (
PLFLT) ( count * width / 50 );
717 if ( plPlotterPtr->xr > 1.0 )
719 plPlotterPtr->xr = 1.0;
720 plPlotterPtr->xl = (
PLFLT) ( 1.0 - width );
722 else if ( plPlotterPtr->xl < 0.0 )
724 plPlotterPtr->xl = 0.0;
725 plPlotterPtr->xr = (
PLFLT) width;
727 Scroll( interp, plPlotterPtr );
732 else if ( ( c ==
'y' ) && ( strncmp( argv[1],
"yview", (
size_t) length ) == 0 ) )
735 double height = plPlotterPtr->yr - plPlotterPtr->yl;
739 type = Tk_GetScrollInfo( interp, argc, argv, &fraction, &count );
742 case TK_SCROLL_ERROR:
745 case TK_SCROLL_MOVETO:
746 plPlotterPtr->yl = (
PLFLT) ( 1.0 - fraction - height );
747 plPlotterPtr->yr = (
PLFLT) ( 1.0 - fraction );
749 case TK_SCROLL_PAGES:
750 plPlotterPtr->yl -= (
PLFLT) ( count * height * .9 );
751 plPlotterPtr->yr -= (
PLFLT) ( count * height * .9 );
753 case TK_SCROLL_UNITS:
754 plPlotterPtr->yl -= (
PLFLT) ( count * height / 50 );
755 plPlotterPtr->yr -= (
PLFLT) ( count * height / 50 );
758 if ( plPlotterPtr->yr > 1.0 )
760 plPlotterPtr->yr = 1.0;
761 plPlotterPtr->yl = (
PLFLT) ( 1.0 - height );
763 else if ( plPlotterPtr->yl < 0.0 )
765 plPlotterPtr->yl = 0.0;
766 plPlotterPtr->yr = (
PLFLT) height;
768 Scroll( interp, plPlotterPtr );
775 Tcl_AppendResult( interp,
"bad option \"", argv[1],
776 "\": must be closelink, cmd, configure, draw, info, nextpage ",
777 "openlink, orient, page, print, redraw, save, view, ",
778 "xview, or yview", (
char *) NULL );
784 Tk_Release( (ClientData) plPlotterPtr );
809 register PLRDev *plr = plPlotterPtr->
plr;
816 if ( plPlotterPtr->
border != NULL )
818 Tk_Free3DBorder( plPlotterPtr->
border );
820 if ( plPlotterPtr->
plpr_cmd != NULL )
822 free( (
char *) plPlotterPtr->
plpr_cmd );
824 if ( plPlotterPtr->
cursor != None )
826 Tk_FreeCursor( plPlotterPtr->
display, plPlotterPtr->
cursor );
832 if ( plPlotterPtr->
xorGC != NULL )
834 Tk_FreeGC( plPlotterPtr->
display, plPlotterPtr->
xorGC );
844 if ( plPlotterPtr->
SaveFnam != NULL )
846 free( (
char *) plPlotterPtr->
SaveFnam );
848 if ( plPlotterPtr->
devDesc != NULL )
850 free( (
char *) plPlotterPtr->
devDesc );
852 if ( plPlotterPtr->
devName != NULL )
854 free( (
char *) plPlotterPtr->
devName );
860 free( (
char *) plPlotterPtr->
plr->
iodev );
869 free( (
char *) plPlotterPtr->
plr );
870 free( (
char *) plPlotterPtr );
894 register Tk_Window tkwin = plPlotterPtr->
tkwin;
898 switch ( eventPtr->type )
900 case ConfigureNotify:
901 pldebug(
"PLFrameConfigureEH",
"ConfigureNotify\n" );
903 plPlotterPtr->
width = Tk_Width( tkwin );
904 plPlotterPtr->
height = Tk_Height( tkwin );
914 pldebug(
"PLFrameConfigureEH",
"DestroyNotify\n" );
915 Tcl_DeleteCommand( plPlotterPtr->
interp, Tk_PathName( tkwin ) );
916 plPlotterPtr->
tkwin = NULL;
921 Tk_EventuallyFree( (ClientData) plPlotterPtr, (Tcl_FreeProc *)
DestroyPlPlotter );
925 pldebug(
"PLFrameConfigureEH",
"MapNotify\n" );
939 if ( !plPlotterPtr->tkwin_initted )
941 Tcl_VarEval( plPlotterPtr->interp,
"update", (
char *) NULL );
976 XExposeEvent *
event = (XExposeEvent *) eventPtr;
977 register Tk_Window tkwin = plPlotterPtr->
tkwin;
981 pldebug(
"PLFrameExposeEH",
"Expose\n" );
987 int x0_old, x1_old, y0_old, y1_old, x0_new, x1_new, y0_new, y1_new;
989 x0_old = (int) plPlotterPtr->
pldis.
x;
990 y0_old = (
int) plPlotterPtr->
pldis.
y;
991 x1_old = x0_old + (int) plPlotterPtr->
pldis.
width;
992 y1_old = y0_old + (
int) plPlotterPtr->
pldis.
height;
996 x1_new = x0_new +
event->width;
997 y1_new = y0_new +
event->height;
999 plPlotterPtr->
pldis.
x = (
unsigned int)
MIN( x0_old, x0_new );
1000 plPlotterPtr->
pldis.
y = (
unsigned int)
MIN( y0_old, y0_new );
1007 if ( event->count == 0 )
1012 plPlotterPtr->width = Tk_Width( tkwin );
1013 plPlotterPtr->height = Tk_Height( tkwin );
1040 XMotionEvent *
event = (XMotionEvent *) eventPtr;
1046 DrawXhairs( plPlotterPtr, event->x, event->y );
1050 DrawRband( plPlotterPtr, event->x, event->y );
1074 XCrossingEvent *crossingEvent = (XCrossingEvent *) eventPtr;
1078 if ( plPlotterPtr->
xhairs )
1080 DrawXhairs( plPlotterPtr, crossingEvent->x, crossingEvent->y );
1083 if ( plPlotterPtr->
rband )
1087 DrawRband( plPlotterPtr, crossingEvent->x, crossingEvent->y );
1130 XButtonEvent *
event = (XButtonEvent *) eventPtr;
1133 switch ( event->state )
1140 if ( plPlotterPtr->
rband )
1155 register Tk_Window tkwin = plPlotterPtr->
tkwin;
1157 int root_x, root_y, win_x, win_y;
1164 if ( XQueryPointer( plPlotterPtr->
display, Tk_WindowId( tkwin ),
1165 &root, &child, &root_x, &root_y, &win_x, &win_y,
1171 Tk_GetRootCoords( tkwin, &win_x, &win_y );
1172 win_x = root_x - win_x;
1173 win_y = root_y - win_y;
1175 if ( win_x >= 0 && win_x < Tk_Width( tkwin ) &&
1176 win_y >= 0 && win_y < Tk_Height( tkwin ) )
1208 register Tk_Window tkwin = plPlotterPtr->
tkwin;
1209 int xmin = 0, xmax = Tk_Width( tkwin ) - 1;
1210 int ymin = 0, ymax = Tk_Height( tkwin ) - 1;
1215 plPlotterPtr->
xhair_x[0].x = (short) xmin; plPlotterPtr->
xhair_x[0].y = (short) y0;
1216 plPlotterPtr->
xhair_x[1].x = (short) xmax; plPlotterPtr->
xhair_x[1].y = (short) y0;
1218 plPlotterPtr->
xhair_y[0].x = (short) x0; plPlotterPtr->
xhair_y[0].y = (short) ymin;
1219 plPlotterPtr->
xhair_y[1].x = (short) x0; plPlotterPtr->
xhair_y[1].y = (short) ymax;
1233 register Tk_Window tkwin = plPlotterPtr->
tkwin;
1235 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
1239 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
1253 register Tk_Window tkwin = plPlotterPtr->
tkwin;
1255 int root_x, root_y, win_x, win_y;
1260 if ( XQueryPointer( plPlotterPtr->
display, Tk_WindowId( tkwin ),
1261 &root, &child, &root_x, &root_y, &win_x, &win_y,
1267 Tk_GetRootCoords( tkwin, &win_x, &win_y );
1268 win_x = root_x - win_x;
1269 win_y = root_y - win_y;
1271 if ( win_x >= 0 && win_x < Tk_Width( tkwin ) &&
1272 win_y >= 0 && win_y < Tk_Height( tkwin ) )
1275 plPlotterPtr->
rband_pt[0].x = (short) win_x;
1276 plPlotterPtr->
rband_pt[0].y = (short) win_y;
1278 DrawRband( plPlotterPtr, win_x, win_y );
1290 DrawRband( plPlotterPtr, win_x, win_y );
1325 plPlotterPtr->
rband_pt[1].x = (short) x0; plPlotterPtr->
rband_pt[1].y = (short) y0;
1339 register Tk_Window tkwin = plPlotterPtr->
tkwin;
1341 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
1350 register Tk_Window tkwin = plPlotterPtr->
tkwin;
1365 plPlotterPtr->
width = Tk_Width( tkwin );
1366 plPlotterPtr->
height = Tk_Height( tkwin );
1401 if ( plPlotterPtr->
xhairs )
1404 if ( plPlotterPtr->
rband )
1430 #define INSTALL_COLORMAP_IN_TK
1431 #ifdef INSTALL_COLORMAP_IN_TK
1433 Tk_SetWindowColormap( Tk_MainWindow( plPlotterPtr->
interp ), dev->
tkwd->
map );
1445 Window top, colormap_windows[5];
1447 top = Tk_WindowId( Tk_MainWindow( plPlotterPtr->
interp ) );
1449 colormap_windows[count++] = Tk_WindowId( plPlotterPtr->
tkwin );
1450 colormap_windows[count++] = top;
1452 if ( !XSetWMColormapWindows( plPlotterPtr->
display,
1453 top, colormap_windows, count ) )
1454 fprintf( stderr,
"Unable to set color map property!\n" );
1479 register Tk_Window tkwin = plPlotterPtr->
tkwin;
1497 if ( ( plPlotterPtr->
tkwin == NULL ) || !Tk_IsMapped( tkwin ) )
1522 if ( ( plPlotterPtr->
border != NULL ) &&
1523 ( plPlotterPtr->
relief != TK_RELIEF_FLAT ) )
1525 Tk_Draw3DRectangle( plPlotterPtr->
tkwin, Tk_WindowId( tkwin ),
1526 plPlotterPtr->
border, 0, 0, Tk_Width( tkwin ), Tk_Height( tkwin ),
1561 Tk_Draw3DRectangle( plPlotterPtr->
tkwin, Tk_WindowId( tkwin ),
1562 plPlotterPtr->
border, 0, 0, Tk_Width( tkwin ), Tk_Height( tkwin ),
1565 XClearWindow( plPlotterPtr->
display, Tk_WindowId( tkwin ) );
1567 XFlush( plPlotterPtr->
display );
1579 plPlotterPtr->
pldis.
x = (
unsigned int) ( Tk_X( tkwin ) + Tk_Width( tkwin ) );
1580 plPlotterPtr->
pldis.
y = (
unsigned int) ( Tk_Y( tkwin ) + Tk_Height( tkwin ) );
1581 plPlotterPtr->
pldis.
width = (
unsigned int) -Tk_Width( tkwin );
1582 plPlotterPtr->
pldis.
height = (
unsigned int) -Tk_Height( tkwin );
1613 int i, CONST
char *col,
int *p_changed )
1621 Tcl_AppendResult( interp,
"color value not specified",
1626 if ( !XParseColor( plPlotterPtr->
display,
1627 Tk_Colormap( plPlotterPtr->
tkwin ), col, &xcol ) )
1629 Tcl_AppendResult( interp,
"Couldn't parse color ", col,
1634 r = (unsigned) ( xcol.red & 0xFF00 ) >> 8;
1635 g = (unsigned) ( xcol.green & 0xFF00 ) >> 8;
1636 b = (unsigned) ( xcol.blue & 0xFF00 ) >> 8;
1638 if ( ( pls->
cmap0[i].
r != r ) ||
1639 ( pls->
cmap0[i].
g != g ) ||
1640 ( pls->
cmap0[i].
b != b ) )
1642 pls->
cmap0[i].
r = (
unsigned char) r;
1643 pls->
cmap0[i].
g = (
unsigned char) g;
1644 pls->
cmap0[i].
b = (
unsigned char) b;
1659 int i, CONST
char *col, CONST
char *pos, CONST
char *rev,
int *p_changed )
1663 PLFLT h, l, s, r, g, b, p;
1668 Tcl_AppendResult( interp,
"color value not specified",
1675 Tcl_AppendResult( interp,
"control point position not specified",
1682 Tcl_AppendResult( interp,
"interpolation sense not specified",
1687 if ( !XParseColor( plPlotterPtr->
display,
1688 Tk_Colormap( plPlotterPtr->
tkwin ), col, &xcol ) )
1690 Tcl_AppendResult( interp,
"Couldn't parse color ", col,
1695 r = (
PLFLT) ( ( (
unsigned) ( xcol.red & 0xFF00 ) >> 8 ) / 255.0 );
1696 g = (
PLFLT) ( ( (
unsigned) ( xcol.green & 0xFF00 ) >> 8 ) / 255.0 );
1697 b = (
PLFLT) ( ( (
unsigned) ( xcol.blue & 0xFF00 ) >> 8 ) / 255.0 );
1701 p = (
PLFLT) ( atof( pos ) / 100.0 );
1702 reverse = atoi( rev );
1735 int result = TCL_OK;
1736 char cmdlist[] =
"plgcmap0 plgcmap1 plscmap0 plscmap1 plscol0 plscol1";
1743 fprintf( stderr,
"There are %d arguments to Cmd:", argc );
1744 for ( i = 0; i <
argc; i++ )
1746 fprintf( stderr,
" %s", argv[i] );
1748 fprintf( stderr,
"\n" );
1755 return plTclCmd( cmdlist, interp, argc, argv );
1761 Tcl_VarEval( plPlotterPtr->
interp,
"update", (
char *) NULL );
1769 length = (int) strlen( argv[0] );
1774 if ( ( c3 ==
'g' ) && ( strncmp( argv[0],
"plgcmap0", (
size_t) length ) == 0 ) )
1777 unsigned long plcolor;
1780 sprintf( str,
"%d", (
int) pls->
ncol0 );
1781 Tcl_AppendElement( interp, str );
1782 for ( i = 0; i < pls->
ncol0; i++ )
1784 plcolor = (
unsigned long) ( ( pls->
cmap0[i].
r << 16 ) |
1785 ( pls->
cmap0[i].
g << 8 ) |
1788 sprintf( str,
"#%06lx", ( plcolor & 0xFFFFFF ) );
1789 Tcl_AppendElement( interp, str );
1798 else if ( ( c3 ==
'g' ) && ( strncmp( argv[0],
"plgcmap1", (
size_t) length ) == 0 ) )
1801 unsigned long plcolor;
1803 PLFLT h, l, s, r, g, b;
1806 sprintf( str,
"%d", (
int) pls->
ncp1 );
1807 Tcl_AppendElement( interp, str );
1808 for ( i = 0; i < pls->
ncp1; i++ )
1816 r1 =
MAX( 0,
MIN( 255, (
int) ( 256. * r ) ) );
1817 g1 =
MAX( 0,
MIN( 255, (
int) ( 256. * g ) ) );
1818 b1 =
MAX( 0,
MIN( 255, (
int) ( 256. * b ) ) );
1820 plcolor = (
unsigned long) ( ( r1 << 16 ) | ( g1 << 8 ) | ( b1 ) );
1822 sprintf( str,
"#%06lx", ( plcolor & 0xFFFFFF ) );
1823 Tcl_AppendElement( interp, str );
1825 sprintf( str,
"%02d", (
int) ( 100 * pls->
cmap1cp[i].
p ) );
1826 Tcl_AppendElement( interp, str );
1829 Tcl_AppendElement( interp, str );
1837 else if ( ( c3 ==
's' ) && ( strncmp( argv[0],
"plscmap0", (
size_t) length ) == 0 ) )
1839 int i, changed = 1, ncol0 = atoi( argv[1] );
1842 if ( ncol0 > 16 || ncol0 < 1 )
1844 Tcl_AppendResult( interp,
"illegal number of colors in cmap0: ",
1845 argv[1], (
char *) NULL );
1850 for ( i = 0; i < pls->
ncol0; i++ )
1853 col = strtok( argv_cp,
" " );
1857 if (
scol0( interp, plPlotterPtr, i, col, &changed ) != TCL_OK )
1869 else if ( ( c3 ==
's' ) && ( strncmp( argv[0],
"plscmap1", (
size_t) length ) == 0 ) )
1871 int i, changed = 1, ncp1 = atoi( argv[1] );
1872 char *col, *pos, *rev;
1874 if ( ncp1 > 32 || ncp1 < 1 )
1876 Tcl_AppendResult( interp,
1877 "illegal number of control points in cmap1: ",
1878 argv[1], (
char *) NULL );
1883 col = strtok( argv_cp,
" " );
1884 pos = strtok( NULL,
" " );
1885 rev = strtok( NULL,
" " );
1886 for ( i = 0; i < ncp1; i++ )
1891 if (
scol1( interp, plPlotterPtr,
1892 i, col, pos, rev, &changed ) != TCL_OK )
1895 col = strtok( NULL,
" " );
1896 pos = strtok( NULL,
" " );
1897 rev = strtok( NULL,
" " );
1912 else if ( ( c3 ==
's' ) && ( strncmp( argv[0],
"plscol0", (
size_t) length ) == 0 ) )
1914 int i = atoi( argv[1] ), changed = 1;
1916 if ( i > pls->
ncol0 || i < 0 )
1918 Tcl_AppendResult( interp,
"illegal color number in cmap0: ",
1919 argv[1], (
char *) NULL );
1923 if (
scol0( interp, plPlotterPtr, i, argv[2], &changed ) != TCL_OK )
1933 else if ( ( c3 ==
's' ) && ( strncmp( argv[0],
"plscol1", (
size_t) length ) == 0 ) )
1935 int i = atoi( argv[1] ), changed = 1;
1937 if ( i > pls->
ncp1 || i < 0 )
1939 Tcl_AppendResult( interp,
"illegal control point number in cmap1: ",
1940 argv[1], (
char *) NULL );
1944 if (
scol1( interp, plPlotterPtr,
1945 i, argv[2], argv[3], argv[4], &changed ) != TCL_OK )
1953 #ifdef USING_PLESC_COPY
1957 else if ( ( c3 ==
'c' ) && ( strncmp( argv[0],
"plcopy", (
size_t) length ) == 0 ) )
1962 Tcl_AppendResult( interp,
"Need exactly 6 arguments to copy.",
1966 xx[0] = atof( argv[1] );
1967 yy[0] = atof( argv[2] );
1968 xx[1] = atof( argv[3] );
1969 yy[1] = atof( argv[4] );
1970 xx[2] = atof( argv[5] );
1971 yy[2] = atof( argv[6] );
1979 result =
plTclCmd( cmdlist, interp, argc, argv );
1991 Tk_CreateEventHandler( plPlotterPtr->
tkwin, ButtonPressMask,
1994 Tk_CreateEventHandler( plPlotterPtr->tkwin, PointerMotionMask,
1997 Tk_CreateEventHandler( plPlotterPtr->tkwin, EnterWindowMask,
2000 Tk_CreateEventHandler( plPlotterPtr->tkwin, LeaveWindowMask,
2004 Tk_DefineCursor( plPlotterPtr->tkwin, plPlotterPtr->xhair_cursor );
2011 Tk_DeleteEventHandler( plPlotterPtr->
tkwin, ButtonPressMask,
2013 Tk_DeleteEventHandler( plPlotterPtr->tkwin, PointerMotionMask,
2016 Tk_DeleteEventHandler( plPlotterPtr->tkwin, EnterWindowMask,
2019 Tk_DeleteEventHandler( plPlotterPtr->tkwin, LeaveWindowMask,
2023 Tk_DefineCursor( plPlotterPtr->tkwin, plPlotterPtr->cursor );
2052 int argc, CONST
char **
argv,
int flags )
2054 register Tk_Window tkwin = plPlotterPtr->
tkwin;
2060 int need_redisplay = 0;
2066 fprintf( stderr,
"Arguments to configure are:" );
2067 for ( i = 0; i <
argc; i++ )
2069 fprintf( stderr,
" %s", argv[i] );
2071 fprintf( stderr,
"\n" );
2077 if ( Tk_ConfigureWidget( interp, tkwin,
configSpecs,
2078 argc, argv, (
char *) plPlotterPtr, flags ) != TCL_OK )
2091 Tk_3DBorderColor( plPlotterPtr->
border ) ) )
2099 Tk_SetWindowBackground( tkwin, tkwd->cmap0[0].pixel );
2100 Tk_SetWindowBorder( tkwin, tkwd->cmap0[0].pixel );
2104 gcValues.background = tkwd->cmap0[0].pixel;
2105 gcValues.foreground = 0xFF;
2106 gcValues.function = GXxor;
2107 mask = GCForeground | GCBackground | GCFunction;
2109 if ( plPlotterPtr->
xorGC != NULL )
2110 Tk_FreeGC( plPlotterPtr->
display, plPlotterPtr->
xorGC );
2112 plPlotterPtr->
xorGC = Tk_GetGC( plPlotterPtr->
tkwin, mask, &gcValues );
2116 Tk_SetInternalBorder( tkwin, plPlotterPtr->
borderWidth );
2117 if ( ( plPlotterPtr->
width > 0 ) || ( plPlotterPtr->
height > 0 ) )
2119 Tk_GeometryRequest( tkwin, plPlotterPtr->
width, plPlotterPtr->
height );
2127 if ( Tk_IsMapped( tkwin ) )
2129 if ( plPlotterPtr->
xhairs )
2143 if ( Tk_IsMapped( tkwin ) )
2145 if ( plPlotterPtr->
rband )
2175 if ( need_redisplay && Tk_IsMapped( tkwin )
2197 register Tk_Window tkwin = plPlotterPtr->
tkwin;
2198 int result = TCL_OK;
2199 char c = argv[0][0];
2200 int length = (int) strlen( argv[0] );
2206 Tcl_VarEval( plPlotterPtr->
interp,
"update", (
char *) NULL );
2211 if ( ( c ==
'i' ) && ( strncmp( argv[0],
"init", (
size_t) length ) == 0 ) )
2218 else if ( ( c ==
'e' ) && ( strncmp( argv[0],
"end", (
size_t) length ) == 0 ) )
2220 Tk_DefineCursor( tkwin, plPlotterPtr->
cursor );
2223 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
2224 plPlotterPtr->
xorGC, plPlotterPtr->
pts, 5,
2226 XSync( Tk_Display( tkwin ), 0 );
2235 else if ( ( c ==
'r' ) && ( strncmp( argv[0],
"rect", (
size_t) length ) == 0 ) )
2239 Tcl_AppendResult( interp,
"wrong # args: should be \"",
2240 " draw rect x0 y0 x1 y1\"", (
char *) NULL );
2246 int xmin = 0, xmax = Tk_Width( tkwin ) - 1;
2247 int ymin = 0, ymax = Tk_Height( tkwin ) - 1;
2249 x0 = atoi( argv[1] );
2250 y0 = atoi( argv[2] );
2251 x1 = atoi( argv[3] );
2252 y1 = atoi( argv[4] );
2254 x0 =
MAX( xmin,
MIN( xmax, x0 ) );
2255 y0 =
MAX( ymin,
MIN( ymax, y0 ) );
2256 x1 =
MAX( xmin,
MIN( xmax, x1 ) );
2257 y1 =
MAX( ymin,
MIN( ymax, y1 ) );
2261 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
2262 plPlotterPtr->
xorGC, plPlotterPtr->
pts, 5,
2264 XSync( Tk_Display( tkwin ), 0 );
2267 plPlotterPtr->
pts[0].x = (short) x0; plPlotterPtr->
pts[0].y = (short) y0;
2268 plPlotterPtr->
pts[1].x = (short) x1; plPlotterPtr->
pts[1].y = (short) y0;
2269 plPlotterPtr->
pts[2].x = (short) x1; plPlotterPtr->
pts[2].y = (short) y1;
2270 plPlotterPtr->
pts[3].x = (short) x0; plPlotterPtr->
pts[3].y = (short) y1;
2271 plPlotterPtr->
pts[4].x = (short) x0; plPlotterPtr->
pts[4].y = (short) y0;
2273 XDrawLines( Tk_Display( tkwin ), Tk_WindowId( tkwin ),
2274 plPlotterPtr->
xorGC, plPlotterPtr->
pts, 5,
2276 XSync( Tk_Display( tkwin ), 0 );
2298 int result = TCL_OK;
2304 Tcl_SetResult( interp,
"devkeys devnames", TCL_STATIC );
2309 length = (int) strlen( argv[0] );
2313 if ( ( c ==
'd' ) && ( strncmp( argv[0],
"devkeys", (
size_t) length ) == 0 ) )
2316 while ( plPlotterPtr->
devName[i] != NULL )
2317 Tcl_AppendElement( interp, plPlotterPtr->
devName[i++] );
2324 else if ( ( c ==
'd' ) && ( strncmp( argv[0],
"devnames", (
size_t) length ) == 0 ) )
2327 while ( plPlotterPtr->
devDesc[i] != NULL )
2328 Tcl_AppendElement( interp, plPlotterPtr->
devDesc[i++] );
2337 Tcl_AppendResult( interp,
"bad option to \"info\": must be ",
2338 "devkeys, devnames", (
char *) NULL );
2358 #if !defined ( MAC_TCL ) && !defined ( __WIN32__ )
2359 register PLRDev *plr = plPlotterPtr->
plr;
2362 char c = argv[0][0];
2363 int length = (int) strlen( argv[0] );
2369 if ( ( c ==
'f' ) && ( strncmp( argv[0],
"fifo", (
size_t) length ) == 0 ) )
2373 Tcl_AppendResult( interp,
"bad command -- must be: ",
2374 "openlink fifo <pathname>",
2378 if ( ( iodev->
fd = open( argv[1], O_RDONLY ) ) == -1 )
2380 Tcl_AppendResult( interp,
"cannot open fifo ", argv[1],
2381 " for read", (
char *) NULL );
2386 iodev->
file = fdopen( iodev->
fd,
"rb" );
2391 else if ( ( c ==
's' ) && ( strncmp( argv[0],
"socket", (
size_t) length ) == 0 ) )
2395 Tcl_AppendResult( interp,
"bad command -- must be: ",
2396 "openlink socket <sock-id>",
2404 if ( Tcl_GetOpenFile( interp, iodev->
fileHandle,
2405 0, 1, ( ClientData ) & iodev->
file ) != TCL_OK )
2409 iodev->
fd = fileno( iodev->
file );
2416 Tcl_AppendResult( interp,
"bad option to \"openlink\": must be ",
2417 "fifo or socket", (
char *) NULL );
2423 Tcl_CreateFileHandler( iodev->
fd,
2424 TK_READABLE, (Tk_FileProc *)
ReadData,
2425 (ClientData) plPlotterPtr );
2443 #if !defined ( MAC_TCL ) && !defined ( __WIN32__ )
2444 register PLRDev *plr = plPlotterPtr->
plr;
2449 if ( iodev->
fd == 0 )
2451 Tcl_AppendResult( interp,
"no link currently open", (
char *) NULL );
2455 Tcl_DeleteFileHandler( iodev->
fd );
2471 register PLRDev *plr = plPlotterPtr->
plr;
2473 int result = TCL_OK;
2479 Tcl_AppendResult( interp,
"unable to read from ", iodev->
typeName,
2489 if ( Tcl_Eval( interp, plPlotterPtr->
bopCmd ) != TCL_OK )
2490 fprintf( stderr,
"Command \"%s\" failed:\n\t %s\n",
2491 plPlotterPtr->
bopCmd, Tcl_GetStringResult( interp ) );
2499 if ( Tcl_Eval( interp, plPlotterPtr->
eopCmd ) != TCL_OK )
2500 fprintf( stderr,
"Command \"%s\" failed:\n\t %s\n",
2501 plPlotterPtr->
eopCmd, Tcl_GetStringResult( interp ) );
2509 if ( plPlotterPtr->
eopCmd != NULL )
2511 if ( Tcl_Eval( interp, plPlotterPtr->
eopCmd ) != TCL_OK )
2512 fprintf( stderr,
"Command \"%s\" failed:\n\t %s\n",
2513 plPlotterPtr->
eopCmd, Tcl_GetStringResult( interp ) );
2519 if ( plPlotterPtr->
bopCmd != NULL )
2521 if ( Tcl_Eval( interp, plPlotterPtr->
bopCmd ) != TCL_OK )
2522 fprintf( stderr,
"Command \"%s\" failed:\n\t %s\n",
2523 plPlotterPtr->
bopCmd, Tcl_GetStringResult( interp ) );
2538 register Tcl_Interp *interp = plPlotterPtr->
interp;
2540 register PLRDev *plr = plPlotterPtr->
plr;
2543 int result = TCL_OK;
2545 if ( mask & TK_READABLE )
2557 Tcl_AppendResult( interp,
"Packet receive failed:\n\t %s\n",
2558 Tcl_GetStringResult( interp ), (
char *) NULL );
2566 if ( pdfs->
bp == 0 )
2588 int result = TCL_OK;
2597 char result_str[128];
2599 sprintf( result_str,
"%f", rot );
2600 Tcl_SetResult( interp, result_str, TCL_VOLATILE );
2608 result =
Redraw( interp, plPlotterPtr, argc - 1, argv + 1 );
2632 int result = TCL_OK;
2635 #if !defined ( MAC_TCL ) && !defined ( __WIN32__ )
2643 Tcl_AppendResult( interp,
"Error -- widget not plotted to yet",
2653 Tcl_AppendResult( interp,
"Error -- cannot create stream",
2664 Tcl_AppendResult( interp,
2665 "Error -- cannot open plot file for writing",
2668 if ( sfnam != NULL )
2688 if ( plPlotterPtr->
plpr_cmd == NULL )
2691 #if !defined ( MAC_TCL ) && !defined ( __WIN32__ )
2692 if ( ( plPlotterPtr->
plpr_cmd == NULL ) || ( pid = fork() ) < 0 )
2694 Tcl_AppendResult( interp,
2695 "Error -- cannot fork print process",
2699 else if ( pid == 0 )
2704 fprintf( stderr,
"Unable to exec print command.\n" );
2731 Tcl_AppendResult( interp,
"wrong # args: should be \"",
2732 " nextpage\"", (
char *) NULL );
2748 int argc, CONST
char **
argv )
2756 PLFLT mar, aspect, jx, jy;
2757 char result_str[128];
2759 plgdidev( &mar, &aspect, &jx, &jy );
2760 sprintf( result_str,
"%g %g %g %g", mar, aspect, jx, jy );
2761 Tcl_SetResult( interp, result_str, TCL_VOLATILE );
2769 Tcl_AppendResult( interp,
"wrong # args: should be \"",
2770 " page mar aspect jx jy\"", (
char *) NULL );
2775 (
PLFLT) atof( argv[2] ), (
PLFLT) atof( argv[3] ) );
2776 return (
Redraw( interp, plPlotterPtr, argc - 1, argv + 1 ) );
2794 if ( ( plPlotterPtr->
tkwin != NULL ) &&
2813 int argc, CONST
char **
argv )
2823 Tcl_AppendResult( interp,
"Error -- widget not plotted to yet",
2834 Tcl_AppendResult( interp,
"Error -- no current save file",
2848 length = (int) strlen( argv[0] );
2852 if ( ( c ==
'a' ) && ( strncmp( argv[0],
"as", (
size_t) length ) == 0 ) )
2856 Tcl_AppendResult( interp,
"wrong # args: should be \"",
2857 " save as device file\"", (
char *) NULL );
2874 Tcl_AppendResult( interp,
"Error -- cannot create stream",
2882 if ( ( sfile = fopen( argv[2],
"wb+" ) ) == NULL )
2884 Tcl_AppendResult( interp,
"Error -- cannot open file ", argv[2],
2885 " for writing", (
char *) NULL );
2907 else if ( ( c ==
'c' ) && ( strncmp( argv[0],
"close", (
size_t) length ) == 0 ) )
2911 Tcl_AppendResult( interp,
"Error -- no current save file",
2927 Tcl_AppendResult( interp,
"bad option to \"save\": must be ",
2928 "as or close", (
char *) NULL );
2945 int argc, CONST
char **
argv )
2950 PLFLT xl, xr, yl, yr;
2958 char result_str[128];
2960 sprintf( result_str,
"%g %g %g %g", xl, yl, xr, yr );
2961 Tcl_SetResult( interp, result_str, TCL_VOLATILE );
2966 length = (int) strlen( argv[0] );
2971 if ( ( c ==
'b' ) && ( strncmp( argv[0],
"bounds", (
size_t) length ) == 0 ) )
2973 char result_str[128];
2977 sprintf( result_str,
"%g %g %g %g", xl, yl, xr, yr );
2978 Tcl_SetResult( interp, result_str, TCL_VOLATILE );
2984 if ( ( c ==
'r' ) && ( strncmp( argv[0],
"reset", (
size_t) length ) == 0 ) )
2989 if ( argc > 1 && ( strcmp( argv[1],
"wait" ) == 0 ) )
2999 else if ( ( c ==
's' ) && ( strncmp( argv[0],
"select", (
size_t) length ) == 0 ) )
3003 Tcl_AppendResult( interp,
"wrong # args: should be \"",
3004 " view select xmin ymin xmax ymax\"",
3010 gbox( &xl, &yl, &xr, &yr, argv + 1 );
3018 else if ( ( c ==
'z' ) && ( strncmp( argv[0],
"zoom", (
size_t) length ) == 0 ) )
3022 Tcl_AppendResult( interp,
"wrong # args: should be \"",
3023 " view zoom xmin ymin xmax ymax\"",
3029 gbox( &xl, &yl, &xr, &yr, argv + 1 );
3032 if ( argc > 5 && ( strcmp( argv[5],
"wait" ) == 0 ) )
3044 Tcl_AppendResult( interp,
"bad option \"", argv[1],
3045 "\": options to \"view\" are: bounds, reset, select, or zoom",
3054 plPlotterPtr->
xl = xl;
3055 plPlotterPtr->
yl = yl;
3056 plPlotterPtr->
xr = xr;
3057 plPlotterPtr->
yr = yr;
3066 return Redraw( interp, plPlotterPtr, argc, argv );
3081 plsdiplt( plPlotterPtr->
xl, plPlotterPtr->
yl, plPlotterPtr->
xr, plPlotterPtr->
yr );
3084 return (
Redraw( interp, plPlotterPtr, 0, NULL ) );
3097 int argc, CONST
char **
argv )
3105 Tcl_SetResult( interp,
"report what?", TCL_STATIC );
3109 if ( !strcmp( argv[0],
"wc" ) )
3116 Tcl_SetResult( interp,
"Wrong # of args: report wc x y", TCL_STATIC );
3120 x = (
PLFLT) atof( argv[1] );
3121 y = (
PLFLT) atof( argv[2] );
3130 snprintf( res, 40,
"%f %f", gin->wX, gin->wY );
3131 Tcl_SetResult( interp, res, TCL_VOLATILE );
3135 Tcl_SetResult( interp,
"Cannot locate", TCL_STATIC );
3139 Tcl_SetResult( interp,
"nonsensical request.", TCL_STATIC );
3162 sprintf(
string,
" %f %f", 1. - plPlotterPtr->
yr, 1. - plPlotterPtr->
yl );
3164 result = Tcl_VarEval( plPlotterPtr->
interp, plPlotterPtr->
yScrollCmd,
string,
3167 if ( result != TCL_OK )
3169 Tcl_BackgroundError( plPlotterPtr->
interp );
3188 sprintf(
string,
" %f %f", plPlotterPtr->
xl, plPlotterPtr->
xr );
3190 result = Tcl_VarEval( plPlotterPtr->
interp, plPlotterPtr->
xScrollCmd,
string,
3193 if ( result != TCL_OK )
3195 Tcl_BackgroundError( plPlotterPtr->
interp );
3209 PLFLT x0, y0, x1, y1;
3211 x0 = (
PLFLT) atof( argv[0] );
3212 y0 = (
PLFLT) atof( argv[1] );
3213 x1 = (
PLFLT) atof( argv[2] );
3214 y1 = (
PLFLT) atof( argv[3] );
3223 *xl =
MIN( x0, x1 );
3224 *yl =
MIN( y0, y1 );
3225 *xr =
MAX( x0, x1 );
3226 *yr =
MAX( y0, y1 );
PLDLLIMPEXP_TCLTK int plTclCmd(char *cmdlist, Tcl_Interp *interp, int argc, const char **argv)
static int PlPlotterWidgetCmd(ClientData, Tcl_Interp *, int, CONST char **)
PLControlPt cmap1cp[PL_MAX_CMAP1CP]
static int Redraw(Tcl_Interp *, PlPlotter *, int, CONST char **)
static int Page(Tcl_Interp *, PlPlotter *, int, CONST char **)
int plr_process(PLRDev *plr)
static int scol0(Tcl_Interp *interp, register PlPlotter *plPlotterPtr, int i, CONST char *col, int *p_changed)
static int plplot_tkwin_ccmap
PDFstrm * pdf_bopen(U_CHAR *buffer, size_t bufmax)
static void PlPlotterConfigureEH(ClientData, XEvent *)
static void DrawRband(PlPlotter *, int, int)
static void PlPlotterLeaveEH(ClientData, register XEvent *)
void pldid2pc(PLFLT *xmin, PLFLT *ymin, PLFLT *xmax, PLFLT *ymax)
static int report(Tcl_Interp *, PlPlotter *, int, CONST char **)
FILE * pl_create_tempfile(char **fname)
static void DestroyXhairs(PlPlotter *)
static void DrawXhairs(PlPlotter *, int, int)
static void DestroyPlPlotter(ClientData)
#define DEF_PLFRAME_BORDER_WIDTH
static int Cmd(Tcl_Interp *, PlPlotter *, int, CONST char **)
void plr_start(PLRDev *plr)
PLINT plTranslateCursor(PLGraphicsIn *plg)
static int scol1(Tcl_Interp *interp, register PlPlotter *plPlotterPtr, int i, CONST char *col, CONST char *pos, CONST char *rev, int *p_changed)
void PlplotterAtBop(Tcl_Interp *interp, register PlPlotter *plPlotterPtr)
int plPlotterCmd(ClientData, Tcl_Interp *, int, const char **)
void pldip2dc(PLFLT *xmin, PLFLT *ymin, PLFLT *xmax, PLFLT *ymax)
#define DEF_PLFRAME_WIDTH
#define UPDATE_V_SCROLLBAR
static int NextPage(Tcl_Interp *, PlPlotter *, int, CONST char **)
static int process_data(Tcl_Interp *interp, register PlPlotter *plPlotterPtr)
void plD_open_tkwin(PLStream *pls)
static void DisplayPlPlotter(ClientData)
#define DEF_PLFRAME_BG_MONO
static int Closelink(Tcl_Interp *, PlPlotter *, int, CONST char **)
#define DEF_PLFRAME_CURSOR
int PLColor_from_TkColor_Changed(PLColor *plcolor, XColor *xcolor)
static void PlPlotterMotionEH(ClientData, register XEvent *)
static int Draw(Tcl_Interp *, PlPlotter *, int, CONST char **)
static Tk_ConfigSpec configSpecs[]
#define UPDATE_H_SCROLLBAR
char * plFindCommand(PLCHAR_VECTOR fn)
static int Info(Tcl_Interp *, PlPlotter *, int, CONST char **)
struct PlPlotter PlPlotter
static int Orient(Tcl_Interp *, PlPlotter *, int, CONST char **)
#define DEF_PLFRAME_HEIGHT
static void UpdateHScrollbar(register PlPlotter *)
void PlplotterAtEop(Tcl_Interp *interp, register PlPlotter *plPlotterPtr)
void pl_cmd(PLINT op, void *ptr)
void plgFileDevs(const char ***p_menustr, const char ***p_devname, int *p_ndev)
static int View(Tcl_Interp *, PlPlotter *, int, CONST char **)
static void CreateXhairs(PlPlotter *)
static PLStream * pls[PL_NSTREAMS]
static int ConfigurePlPlotter(Tcl_Interp *, PlPlotter *, int, CONST char **, int)
static int ReadData(ClientData, int)
#define DEF_PLFRAME_RELIEF
PLDLLIMPEXP_TCLTK int pl_PacketReceive(Tcl_Interp *interp, PLiodev *iodev, PDFstrm *pdfs)
static void PlPlotterFirstInit(ClientData clientData)
char PLDLLIMPEXP * plstrdup(PLCHAR_VECTOR src)
static void UpdateVScrollbar(register PlPlotter *)
static void UpdateXhairs(PlPlotter *)
static void gbox(PLFLT *, PLFLT *, PLFLT *, PLFLT *, CONST char **)
static int Scroll(Tcl_Interp *, PlPlotter *)
int pdf_close(PDFstrm *pdfs)
static int Save(Tcl_Interp *, PlPlotter *, int, CONST char **)
static void UpdateRband(PlPlotter *)
#define DEF_PLFRAME_BG_COLOR
static void DestroyRband(PlPlotter *)
void pltkwin_setBGFG(PLStream *pls)
static Tcl_Interp * interp
static void PlPlotterEnterEH(ClientData, register XEvent *)
static void CreateRband(PlPlotter *)
static void PlPlotterButtonPressEH(ClientData clientData, register XEvent *)
static void PlPlotterInit(ClientData)
static void ActiveState(register PlPlotter *plPlotterPtr, int on)
static void PlPlotterExposeEH(ClientData, XEvent *)
void plgpls(PLStream **p_pls)
static int Openlink(Tcl_Interp *, PlPlotter *, int, CONST char **)
static void Install_cmap(PlPlotter *plPlotterPtr)
static int Print(Tcl_Interp *, PlPlotter *, int, CONST char **)