summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bltGrMarkerBitmap.C2
-rwxr-xr-xconfigure1
-rwxr-xr-xconfigure.in1
-rw-r--r--src/bltGrAxis.C2
-rw-r--r--src/bltGrAxisOption.C1
-rw-r--r--src/bltGrElemBar.C2
-rw-r--r--src/bltGrElemLine.C2
-rw-r--r--src/bltGrElemOption.C1
-rw-r--r--src/bltGrHairs.C1
-rw-r--r--src/bltGrLegd.C2
-rw-r--r--src/bltGrMarkerLine.C2
-rw-r--r--src/bltGrMarkerOption.C1
-rw-r--r--src/bltGrMarkerPolygon.C2
-rw-r--r--src/bltGrMarkerText.C2
-rw-r--r--src/bltGrPSOutput.C4
-rw-r--r--src/bltGrPSOutput.h39
-rw-r--r--src/bltGrPenBar.C1
-rw-r--r--src/bltGrPenLine.C1
-rw-r--r--src/bltGrPenOption.C1
-rw-r--r--src/bltGrPostscript.C86
-rw-r--r--src/bltGrPostscript.h42
-rw-r--r--src/bltGrPostscriptOp.C223
-rw-r--r--src/bltGrPostscriptOp.h5
-rw-r--r--src/bltGraph.C1
-rw-r--r--src/bltGraph.h5
25 files changed, 381 insertions, 49 deletions
diff --git a/bltGrMarkerBitmap.C b/bltGrMarkerBitmap.C
index 14b0318..d8e63b6 100644
--- a/bltGrMarkerBitmap.C
+++ b/bltGrMarkerBitmap.C
@@ -31,6 +31,8 @@
#include "bltGrMarkerOption.h"
#include "bltGrMisc.h"
#include "bltGrDef.h"
+#include "bltConfig.h"
+#include "bltPs.h"
using namespace Blt;
diff --git a/configure b/configure
index 8979ea2..0f7341f 100755
--- a/configure
+++ b/configure
@@ -5557,7 +5557,6 @@ done
bltGrPen.C
bltGrPenBar.C
bltGrPenLine.C
- bltGrPs.C
bltGraph.C
bltGraphBar.C
bltGraphLine.C
diff --git a/configure.in b/configure.in
index 5684385..44b91ec 100755
--- a/configure.in
+++ b/configure.in
@@ -102,7 +102,6 @@ TEA_ADD_SOURCES([
bltGrPen.C
bltGrPenBar.C
bltGrPenLine.C
- bltGrPs.C
bltGraph.C
bltGraphBar.C
bltGraphLine.C
diff --git a/src/bltGrAxis.C b/src/bltGrAxis.C
index c25f742..26a717b 100644
--- a/src/bltGrAxis.C
+++ b/src/bltGrAxis.C
@@ -37,6 +37,8 @@ extern "C" {
#include "bltGrAxisOption.h"
#include "bltGrMisc.h"
#include "bltGrDef.h"
+#include "bltConfig.h"
+#include "bltPs.h"
#define AXIS_PAD_TITLE 2
diff --git a/src/bltGrAxisOption.C b/src/bltGrAxisOption.C
index 678b374..9a82ccf 100644
--- a/src/bltGrAxisOption.C
+++ b/src/bltGrAxisOption.C
@@ -33,6 +33,7 @@ extern "C" {
#include "bltGrAxis.h"
#include "bltGrAxisOption.h"
+#include "bltConfig.h"
static Tk_CustomOptionSetProc AxisSetProc;
static Tk_CustomOptionGetProc AxisGetProc;
diff --git a/src/bltGrElemBar.C b/src/bltGrElemBar.C
index 6a1475d..1312519 100644
--- a/src/bltGrElemBar.C
+++ b/src/bltGrElemBar.C
@@ -41,6 +41,8 @@ extern "C" {
#include "bltGrAxisOp.h"
#include "bltGrMisc.h"
#include "bltGrDef.h"
+#include "bltConfig.h"
+#include "bltPs.h"
#define CLAMP(x,l,h) ((x) = (((x)<(l))? (l) : ((x)>(h)) ? (h) : (x)))
diff --git a/src/bltGrElemLine.C b/src/bltGrElemLine.C
index 6686f13..c156b88 100644
--- a/src/bltGrElemLine.C
+++ b/src/bltGrElemLine.C
@@ -40,6 +40,8 @@ extern "C" {
#include "bltGrAxisOp.h"
#include "bltGrMisc.h"
#include "bltGrDef.h"
+#include "bltConfig.h"
+#include "bltPs.h"
#define SEARCH_X 0
#define SEARCH_Y 1
diff --git a/src/bltGrElemOption.C b/src/bltGrElemOption.C
index 3db0761..e906f09 100644
--- a/src/bltGrElemOption.C
+++ b/src/bltGrElemOption.C
@@ -35,6 +35,7 @@ extern "C" {
#include "bltGrElem.h"
#include "bltGrElemOption.h"
#include "bltGrPenOp.h"
+#include "bltConfig.h"
#define ELEM_SOURCE_VALUES 0
#define ELEM_SOURCE_VECTOR 1
diff --git a/src/bltGrHairs.C b/src/bltGrHairs.C
index 6ed7b58..c133e5a 100644
--- a/src/bltGrHairs.C
+++ b/src/bltGrHairs.C
@@ -36,6 +36,7 @@ extern "C" {
#include "bltGrHairs.h"
#include "bltGrMisc.h"
+#include "bltConfig.h"
#define PointInGraph(g,x,y) (((x) <= (g)->right_) && ((x) >= (g)->left_) && ((y) <= (g)->bottom_) && ((y) >= (g)->top_))
diff --git a/src/bltGrLegd.C b/src/bltGrLegd.C
index e1c0e46..9339ce6 100644
--- a/src/bltGrLegd.C
+++ b/src/bltGrLegd.C
@@ -37,6 +37,8 @@ extern "C" {
#include "bltGrHairsOp.h"
#include "bltGrMisc.h"
#include "bltGrDef.h"
+#include "bltConfig.h"
+#include "bltPs.h"
static void SelectCmdProc(ClientData);
static Tcl_IdleProc DisplayProc;
diff --git a/src/bltGrMarkerLine.C b/src/bltGrMarkerLine.C
index 0a4b2eb..b3e2bc6 100644
--- a/src/bltGrMarkerLine.C
+++ b/src/bltGrMarkerLine.C
@@ -31,6 +31,8 @@
#include "bltGrMarkerOption.h"
#include "bltGrMisc.h"
#include "bltGrDef.h"
+#include "bltConfig.h"
+#include "bltPs.h"
#define BOUND(x, lo, hi) (((x) > (hi)) ? (hi) : ((x) < (lo)) ? (lo) : (x))
diff --git a/src/bltGrMarkerOption.C b/src/bltGrMarkerOption.C
index be5b7de..342171e 100644
--- a/src/bltGrMarkerOption.C
+++ b/src/bltGrMarkerOption.C
@@ -33,6 +33,7 @@ extern "C" {
#include "bltGrMarker.h"
#include "bltGrMarkerOption.h"
+#include "bltConfig.h"
using namespace Blt;
diff --git a/src/bltGrMarkerPolygon.C b/src/bltGrMarkerPolygon.C
index 5771d35..3cb7f70 100644
--- a/src/bltGrMarkerPolygon.C
+++ b/src/bltGrMarkerPolygon.C
@@ -31,6 +31,8 @@
#include "bltGrMarkerOption.h"
#include "bltGrMisc.h"
#include "bltGrDef.h"
+#include "bltConfig.h"
+#include "bltPs.h"
using namespace Blt;
diff --git a/src/bltGrMarkerText.C b/src/bltGrMarkerText.C
index 0ca45cd..93d4e8e 100644
--- a/src/bltGrMarkerText.C
+++ b/src/bltGrMarkerText.C
@@ -31,6 +31,8 @@
#include "bltGrMarkerOption.h"
#include "bltGrMisc.h"
#include "bltGrDef.h"
+#include "bltConfig.h"
+#include "bltPs.h"
using namespace Blt;
diff --git a/src/bltGrPSOutput.C b/src/bltGrPSOutput.C
index 1eedb03..72332af 100644
--- a/src/bltGrPSOutput.C
+++ b/src/bltGrPSOutput.C
@@ -43,10 +43,8 @@ extern "C" {
};
#include "bltGrMisc.h"
-
-extern "C" {
+#include "bltGrPageSetup.h"
#include "bltPs.h"
-};
#ifdef TCL_UTF_MAX
# define HAVE_UTF 1
diff --git a/src/bltGrPSOutput.h b/src/bltGrPSOutput.h
index e9a4baa..b4eb285 100644
--- a/src/bltGrPSOutput.h
+++ b/src/bltGrPSOutput.h
@@ -32,45 +32,6 @@
#include "bltConfig.h"
-typedef struct {
- Tk_OptionTable optionTable;
- int reqWidth, reqHeight; /* If greater than zero, represents the
- * requested dimensions of the printed graph */
- int reqPaperWidth;
- int reqPaperHeight; /* Requested dimensions for the PostScript
- * page. Can constrain the size of the graph
- * if the graph (plus padding) is larger than
- * the size of the page. */
- int xPad, yPad; /* Requested padding on the exterior of the
- * graph. This forms the bounding box for
- * the page. */
- const char *fontVarName; /* If non-NULL, is the name of a TCL array
- * variable containing X to output device font
- * translations */
- int level; /* PostScript Language level 1-3 */
-
- int decorations;
- int center;
- int footer;
- int greyscale;
- int landscape;
- unsigned int flags;
-
- const char **comments; /* User supplied comments to be added. */
-
- /* Computed fields */
-
- short int left, bottom; /* Bounding box of the plot in the page. */
- short int right, top;
-
- float scale; /* Scale of page. Set if "-maxpect" option
- * is set, otherwise 1.0. */
-
- int paperHeight;
- int paperWidth;
-
-} PageSetup;
-
#define POSTSCRIPT_BUFSIZ ((BUFSIZ*2)-1)
struct _Blt_Ps {
Tcl_Interp* interp;
diff --git a/src/bltGrPenBar.C b/src/bltGrPenBar.C
index 421fb13..180a1a1 100644
--- a/src/bltGrPenBar.C
+++ b/src/bltGrPenBar.C
@@ -29,6 +29,7 @@
#include "bltGrPenBar.h"
#include "bltGrDef.h"
+#include "bltConfig.h"
static Tk_OptionSpec barPenOptionSpecs[] = {
{TK_OPTION_BORDER, "-background", "background", "Background",
diff --git a/src/bltGrPenLine.C b/src/bltGrPenLine.C
index 9565a1b..7d37548 100644
--- a/src/bltGrPenLine.C
+++ b/src/bltGrPenLine.C
@@ -30,6 +30,7 @@
#include "bltGrPenLine.h"
#include "bltGrMisc.h"
#include "bltGrDef.h"
+#include "bltConfig.h"
typedef struct {
const char* name;
diff --git a/src/bltGrPenOption.C b/src/bltGrPenOption.C
index da5aee4..b4b4510 100644
--- a/src/bltGrPenOption.C
+++ b/src/bltGrPenOption.C
@@ -30,6 +30,7 @@
#include "bltGrPen.h"
#include "bltGrPenOption.h"
#include "bltGrPenOp.h"
+#include "bltConfig.h"
static Tk_CustomOptionSetProc PenSetProc;
static Tk_CustomOptionGetProc PenGetProc;
diff --git a/src/bltGrPostscript.C b/src/bltGrPostscript.C
index a7b1767..e3397c1 100644
--- a/src/bltGrPostscript.C
+++ b/src/bltGrPostscript.C
@@ -32,3 +32,89 @@ extern "C" {
};
#include "bltGrPageSetup.h"
+#include "bltConfig.h"
+
+static Tk_OptionSpec optionSpecs[] = {
+ {TK_OPTION_BOOLEAN, "-center", "center", "Center",
+ "yes", -1, Tk_Offset(PageSetup, center), 0, NULL, 0},
+ {TK_OPTION_CUSTOM, "-comments", "comments", "Comments",
+ NULL, -1, Tk_Offset(PageSetup, comments),
+ TK_OPTION_NULL_OK, &listObjOption, 0},
+ {TK_OPTION_BOOLEAN, "-decorations", "decorations", "Decorations",
+ "no", -1, Tk_Offset(PageSetup, decorations), 0, NULL, 0},
+ {TK_OPTION_BOOLEAN, "-footer", "footer", "Footer",
+ "no", -1, Tk_Offset(PageSetup, footer), 0, NULL, 0},
+ {TK_OPTION_BOOLEAN, "-greyscale", "greyscale", "Greyscale",
+ "no", -1, Tk_Offset(PageSetup, greyscale), 0, NULL, 0},
+ {TK_OPTION_PIXELS, "-height", "height", "Height",
+ "0", -1, Tk_Offset(PageSetup, reqHeight), 0, NULL, 0},
+ {TK_OPTION_BOOLEAN, "-landscape", "landscape", "Landscape",
+ "no", -1, Tk_Offset(PageSetup, landscape), 0, NULL, 0},
+ {TK_OPTION_INT, "-level", "level", "Level",
+ "2", -1, Tk_Offset(PageSetup, level), 0, NULL, 0},
+ {TK_OPTION_PIXELS, "-padx", "padX", "PadX",
+ "1.0i", -1, Tk_Offset(PageSetup, xPad), 0, NULL, 0},
+ {TK_OPTION_PIXELS, "-pady", "padY", "PadY",
+ "1.0i", -1, Tk_Offset(PageSetup, yPad), 0, NULL, 0},
+ {TK_OPTION_PIXELS, "-paperheight", "paperHeight", "PaperHeight",
+ "11.0i", -1, Tk_Offset(PageSetup, reqPaperHeight), 0, NULL, 0},
+ {TK_OPTION_PIXELS, "-paperwidth", "paperWidth", "PaperWidth",
+ "8.5i", -1, Tk_Offset(PageSetup, reqPaperWidth), 0, NULL, 0},
+ {TK_OPTION_PIXELS, "-width", "width", "Width",
+ "0", -1, Tk_Offset(PageSetup, reqWidth), 0, NULL, 0},
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0}
+};
+
+int Blt_CreatePageSetup(Graph* graphPtr)
+{
+ PageSetup* setupPtr = (PageSetup*)calloc(1, sizeof(PageSetup));
+ graphPtr->pageSetup_ = setupPtr;
+
+ setupPtr->optionTable =Tk_CreateOptionTable(graphPtr->interp_, optionSpecs);
+ return Tk_InitOptions(graphPtr->interp_, (char*)setupPtr,
+ setupPtr->optionTable, graphPtr->tkwin_);
+}
+
+void Blt_DestroyPageSetup(Graph* graphPtr)
+{
+ PageSetup* setupPtr = graphPtr->pageSetup_;
+ Tk_FreeConfigOptions((char*)setupPtr, setupPtr->optionTable, graphPtr->tkwin_);
+ free(setupPtr);
+}
+
+int PageSetupObjConfigure(Tcl_Interp* interp, Graph* graphPtr,
+ int objc, Tcl_Obj* const objv[])
+{
+ PageSetup* setupPtr = graphPtr->pageSetup_;
+ Tk_SavedOptions savedOptions;
+ int mask =0;
+ int error;
+ Tcl_Obj* errorResult;
+
+ for (error=0; error<=1; error++) {
+ if (!error) {
+ if (Tk_SetOptions(interp, (char*)setupPtr, setupPtr->optionTable,
+ objc, objv, graphPtr->tkwin_, &savedOptions, &mask)
+ != TCL_OK)
+ continue;
+ }
+ else {
+ errorResult = Tcl_GetObjResult(interp);
+ Tcl_IncrRefCount(errorResult);
+ Tk_RestoreSavedOptions(&savedOptions);
+ }
+
+ break;
+ }
+
+ if (!error) {
+ Tk_FreeSavedOptions(&savedOptions);
+ return TCL_OK;
+ }
+ else {
+ Tcl_SetObjResult(interp, errorResult);
+ Tcl_DecrRefCount(errorResult);
+ return TCL_ERROR;
+ }
+}
+
diff --git a/src/bltGrPostscript.h b/src/bltGrPostscript.h
index c253654..5851625 100644
--- a/src/bltGrPostscript.h
+++ b/src/bltGrPostscript.h
@@ -30,9 +30,43 @@
#ifndef __BltGrPageSetup_h__
#define __BltGrPageSetup_h__
-#include <iostream>
-#include <sstream>
-#include <iomanip>
-using namespace std;
+typedef struct {
+ Tk_OptionTable optionTable;
+ int reqWidth, reqHeight; /* If greater than zero, represents the
+ * requested dimensions of the printed graph */
+ int reqPaperWidth;
+ int reqPaperHeight; /* Requested dimensions for the PostScript
+ * page. Can constrain the size of the graph
+ * if the graph (plus padding) is larger than
+ * the size of the page. */
+ int xPad, yPad; /* Requested padding on the exterior of the
+ * graph. This forms the bounding box for
+ * the page. */
+ const char *fontVarName; /* If non-NULL, is the name of a TCL array
+ * variable containing X to output device font
+ * translations */
+ int level; /* PostScript Language level 1-3 */
+
+ int decorations;
+ int center;
+ int footer;
+ int greyscale;
+ int landscape;
+ unsigned int flags;
+
+ const char **comments; /* User supplied comments to be added. */
+
+ /* Computed fields */
+
+ short int left, bottom; /* Bounding box of the plot in the page. */
+ short int right, top;
+
+ float scale; /* Scale of page. Set if "-maxpect" option
+ * is set, otherwise 1.0. */
+
+ int paperHeight;
+ int paperWidth;
+
+} PageSetup;
#endif
diff --git a/src/bltGrPostscriptOp.C b/src/bltGrPostscriptOp.C
index a15e67b..ed79088 100644
--- a/src/bltGrPostscriptOp.C
+++ b/src/bltGrPostscriptOp.C
@@ -29,6 +29,229 @@
extern "C" {
#include "bltGraph.h"
+#include "bltOp.h"
};
#include "bltGrPageSetupOp.h"
+#include "bltPs.h"
+
+static int CgetOp(Graph* graphPtr, Tcl_Interp* interp,
+ int objc, Tcl_Obj* const objv[])
+{
+ if (objc != 4) {
+ Tcl_WrongNumArgs(interp, 2, objv, "cget option");
+ return TCL_ERROR;
+ }
+
+ PageSetup *setupPtr = graphPtr->pageSetup_;
+ Tcl_Obj* objPtr = Tk_GetOptionValue(interp,
+ (char*)setupPtr,
+ setupPtr->optionTable,
+ objv[3], graphPtr->tkwin_);
+ if (objPtr == NULL)
+ return TCL_ERROR;
+ else
+ Tcl_SetObjResult(interp, objPtr);
+ return TCL_OK;
+}
+
+static int ConfigureOp(Graph* graphPtr, Tcl_Interp* interp,
+ int objc, Tcl_Obj* const objv[])
+{
+ PageSetup* setupPtr = graphPtr->pageSetup_;
+ if (objc <= 4) {
+ Tcl_Obj* objPtr = Tk_GetOptionInfo(interp, (char*)setupPtr,
+ setupPtr->optionTable,
+ (objc == 4) ? objv[3] : NULL,
+ graphPtr->tkwin_);
+ if (objPtr == NULL)
+ return TCL_ERROR;
+ else
+ Tcl_SetObjResult(interp, objPtr);
+ return TCL_OK;
+ }
+ else
+ return PageSetupObjConfigure(interp, graphPtr, objc-3, objv+3);
+}
+
+static int OutputOp(Graph* graphPtr, Tcl_Interp* interp,
+ int objc, Tcl_Obj* const objv[])
+{
+ const char *fileName = NULL;
+ Tcl_Channel channel = NULL;
+ if (objc > 3) {
+ fileName = Tcl_GetString(objv[3]);
+ if (fileName[0] != '-') {
+ objv++, objc--; /* First argument is the file name. */
+ channel = Tcl_OpenFileChannel(interp, fileName, "w", 0666);
+ if (!channel)
+ return TCL_ERROR;
+
+ if (Tcl_SetChannelOption(interp, channel, "-translation", "binary")
+ != TCL_OK)
+ return TCL_ERROR;
+ }
+ }
+
+ PostScript *psPtr = Blt_Ps_Create(graphPtr->interp_, graphPtr->pageSetup_);
+
+ if (PageSetupObjConfigure(interp, graphPtr, objc-3, objv+3) != TCL_OK) {
+ if (channel)
+ Tcl_Close(interp, channel);
+ Blt_Ps_Free(psPtr);
+ return TCL_ERROR;
+ }
+
+ if (graphPtr->print(fileName, psPtr) != TCL_OK) {
+ if (channel)
+ Tcl_Close(interp, channel);
+ Blt_Ps_Free(psPtr);
+ return TCL_ERROR;
+ }
+
+ int length;
+ const char *buffer = Blt_Ps_GetValue(psPtr, &length);
+ if (channel) {
+ int nBytes = Tcl_Write(channel, buffer, length);
+ if (nBytes < 0) {
+ Tcl_AppendResult(interp, "error writing file \"", fileName, "\": ",
+ Tcl_PosixError(interp), (char *)NULL);
+ if (channel)
+ Tcl_Close(interp, channel);
+ Blt_Ps_Free(psPtr);
+ return TCL_ERROR;
+ }
+ Tcl_Close(interp, channel);
+ }
+ else
+ Tcl_SetStringObj(Tcl_GetObjResult(interp), buffer, length);
+
+ Blt_Ps_Free(psPtr);
+ return TCL_OK;
+}
+
+static Blt_OpSpec psOps[] =
+ {
+ {"cget", 2, (void*)CgetOp, 4, 4, "option",},
+ {"configure", 2, (void*)ConfigureOp, 3, 0, "?option value?...",},
+ {"output", 1, (void*)OutputOp, 3, 0, "?fileName? ?option value?...",},
+ };
+
+static int nPsOps = sizeof(psOps) / sizeof(Blt_OpSpec);
+
+typedef int (GraphPsProc)(Graph* graphPtr, Tcl_Interp* interp, int objc,
+ Tcl_Obj* const objv[]);
+
+int Blt_PostScriptOp(Graph* graphPtr, Tcl_Interp* interp, int objc,
+ Tcl_Obj* const objv[])
+{
+ GraphPsProc* proc = (GraphPsProc*)Blt_GetOpFromObj(interp, nPsOps, psOps, BLT_OP_ARG2, objc, objv, 0);
+ if (!proc)
+ return TCL_ERROR;
+
+ return (*proc)(graphPtr, interp, objc, objv);
+}
+
+// Support
+
+static void AddComments(Blt_Ps ps, const char **comments)
+{
+ const char **p;
+ for (p = comments; *p; p += 2) {
+ if (*(p+1) == NULL) {
+ break;
+ }
+ Blt_Ps_Format(ps, "%% %s: %s\n", *p, *(p+1));
+ }
+}
+
+int PostScriptPreamble(Graph* graphPtr, const char *fileName, Blt_Ps ps)
+{
+ PageSetup *setupPtr = graphPtr->pageSetup_;
+ time_t ticks;
+ char date[200]; /* Holds the date string from ctime() */
+ char *newline;
+
+ if (fileName == NULL) {
+ fileName = Tk_PathName(graphPtr->tkwin_);
+ }
+ Blt_Ps_Append(ps, "%!PS-Adobe-3.0 EPSF-3.0\n");
+
+ /*
+ * The "BoundingBox" comment is required for EPS files. The box
+ * coordinates are integers, so we need round away from the center of the
+ * box.
+ */
+ Blt_Ps_Format(ps, "%%%%BoundingBox: %d %d %d %d\n",
+ setupPtr->left, setupPtr->paperHeight - setupPtr->top,
+ setupPtr->right, setupPtr->paperHeight - setupPtr->bottom);
+
+ Blt_Ps_Append(ps, "%%Pages: 0\n");
+
+ Blt_Ps_Format(ps, "%%%%Creator: (%s %s %s)\n",
+ PACKAGE_NAME, PACKAGE_VERSION, Tk_Class(graphPtr->tkwin_));
+
+ ticks = time((time_t *) NULL);
+ strcpy(date, ctime(&ticks));
+ newline = date + strlen(date) - 1;
+ if (*newline == '\n') {
+ *newline = '\0';
+ }
+ Blt_Ps_Format(ps, "%%%%CreationDate: (%s)\n", date);
+ Blt_Ps_Format(ps, "%%%%Title: (%s)\n", fileName);
+ Blt_Ps_Append(ps, "%%DocumentData: Clean7Bit\n");
+ if (setupPtr->landscape) {
+ Blt_Ps_Append(ps, "%%Orientation: Landscape\n");
+ } else {
+ Blt_Ps_Append(ps, "%%Orientation: Portrait\n");
+ }
+ Blt_Ps_Append(ps, "%%DocumentNeededResources: font Helvetica Courier\n");
+ AddComments(ps, setupPtr->comments);
+ Blt_Ps_Append(ps, "%%EndComments\n\n");
+ if (Blt_Ps_IncludeFile(graphPtr->interp_, ps, "bltGraph.pro") != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (setupPtr->footer) {
+ const char *who;
+
+ who = getenv("LOGNAME");
+ if (who == NULL) {
+ who = "???";
+ }
+ Blt_Ps_VarAppend(ps,
+ "8 /Helvetica SetFont\n",
+ "10 30 moveto\n",
+ "(Date: ", date, ") show\n",
+ "10 20 moveto\n",
+ "(File: ", fileName, ") show\n",
+ "10 10 moveto\n",
+ "(Created by: ", who, "@", Tcl_GetHostName(), ") show\n",
+ "0 0 moveto\n",
+ (char *)NULL);
+ }
+ /*
+ * Set the conversion from PostScript to X11 coordinates. Scale pica to
+ * pixels and flip the y-axis (the origin is the upperleft corner).
+ */
+ Blt_Ps_VarAppend(ps,
+ "% Transform coordinate system to use X11 coordinates\n\n",
+ "% 1. Flip y-axis over by reversing the scale,\n",
+ "% 2. Translate the origin to the other side of the page,\n",
+ "% making the origin the upper left corner\n", (char *)NULL);
+ Blt_Ps_Format(ps, "1 -1 scale\n");
+ /* Papersize is in pixels. Translate the new origin *after* changing the
+ * scale. */
+ Blt_Ps_Format(ps, "0 %d translate\n\n", -setupPtr->paperHeight);
+ Blt_Ps_VarAppend(ps, "% User defined page layout\n\n",
+ "% Set color level\n", (char *)NULL);
+ Blt_Ps_Format(ps, "%% Set origin\n%d %d translate\n\n",
+ setupPtr->left, setupPtr->bottom);
+ if (setupPtr->landscape) {
+ Blt_Ps_Format(ps,
+ "%% Landscape orientation\n0 %g translate\n-90 rotate\n",
+ ((double)graphPtr->width_ * setupPtr->scale));
+ }
+ Blt_Ps_Append(ps, "\n%%EndSetup\n\n");
+ return TCL_OK;
+}
+
diff --git a/src/bltGrPostscriptOp.h b/src/bltGrPostscriptOp.h
index 6db3ad8..29df072 100644
--- a/src/bltGrPostscriptOp.h
+++ b/src/bltGrPostscriptOp.h
@@ -35,4 +35,9 @@
#include <iomanip>
using namespace std;
+extern int PageSetupObjConfigure(Tcl_Interp* interp, Graph* graphPtr,
+ int objc, Tcl_Obj* const objv[]);
+
+int Blt_PostScriptOp(Graph* graphPtr, Tcl_Interp* interp, int objc,
+ Tcl_Obj* const objv[]);
#endif
diff --git a/src/bltGraph.C b/src/bltGraph.C
index dbfc820..2c253be 100644
--- a/src/bltGraph.C
+++ b/src/bltGraph.C
@@ -52,6 +52,7 @@ extern "C" {
#include "bltGrHairs.h"
#include "bltGrHairsOp.h"
#include "bltGrDef.h"
+#include "bltPs.h"
using namespace Blt;
diff --git a/src/bltGraph.h b/src/bltGraph.h
index 326c5f0..ebd229e 100644
--- a/src/bltGraph.h
+++ b/src/bltGraph.h
@@ -32,7 +32,8 @@
#include "bltGrMisc.h"
#include "bltBind.h"
-#include "bltPs.h"
+#include "bltGrPageSetup.h"
+#include "bltText.h"
extern "C" {
#include "bltChain.h"
@@ -45,6 +46,8 @@ class Element;
class Legend;
class Pen;
+typedef struct _Blt_Ps *Blt_Ps;
+
namespace Blt {
class Marker;
};