summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjoye <joye>2014-04-22 14:33:54 (GMT)
committerjoye <joye>2014-04-22 14:33:54 (GMT)
commit8688607b0ef7796ca7d3a53eef855490cd2b847b (patch)
treecc8ec2b939a0d10524534976287a763f3ec8af37 /src
parent13c75b2c6d01c22f1c82fd8ec8815175ba35daea (diff)
downloadblt-8688607b0ef7796ca7d3a53eef855490cd2b847b.zip
blt-8688607b0ef7796ca7d3a53eef855490cd2b847b.tar.gz
blt-8688607b0ef7796ca7d3a53eef855490cd2b847b.tar.bz2
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r--src/bltGrLegd.C5
-rw-r--r--src/bltGrPSOutput.C25
-rw-r--r--src/bltGrPostscript.C74
-rw-r--r--src/bltGrPostscript.h49
-rw-r--r--src/bltGrPostscriptOp.C55
-rw-r--r--src/bltGrPostscriptOp.h5
-rw-r--r--src/bltGraph.C15
-rw-r--r--src/bltGraphOp.C7
8 files changed, 119 insertions, 116 deletions
diff --git a/src/bltGrLegd.C b/src/bltGrLegd.C
index 9339ce6..628b3f3 100644
--- a/src/bltGrLegd.C
+++ b/src/bltGrLegd.C
@@ -35,6 +35,8 @@ extern "C" {
#include "bltGrElem.h"
#include "bltGrElemOp.h"
#include "bltGrHairsOp.h"
+#include "bltGrPageSetup.h"
+#include "bltGrPageSetupOp.h"
#include "bltGrMisc.h"
#include "bltGrDef.h"
#include "bltConfig.h"
@@ -541,6 +543,7 @@ void Legend::print(Blt_Ps ps)
{
LegendOptions* ops = (LegendOptions*)ops_;
GraphOptions* gops = (GraphOptions*)graphPtr_->ops_;
+ PageSetupOptions* pops = (PageSetupOptions*)graphPtr_->pageSetup_->ops_;
if ((ops->hide) || (nEntries_ == 0))
return;
@@ -553,7 +556,7 @@ void Legend::print(Blt_Ps ps)
int height = height_ - 2*ops->yPad;
Blt_Ps_Append(ps, "% Legend\n");
- if (graphPtr_->pageSetup_->decorations) {
+ if (pops->decorations) {
if (ops->normalBg)
Blt_Ps_Fill3DRectangle(ps, ops->normalBg, x, y, width, height,
ops->borderWidth, ops->relief);
diff --git a/src/bltGrPSOutput.C b/src/bltGrPSOutput.C
index 72332af..5dbe3c8 100644
--- a/src/bltGrPSOutput.C
+++ b/src/bltGrPSOutput.C
@@ -62,17 +62,18 @@ static Tcl_Interp *psInterp = NULL;
int Blt_Ps_ComputeBoundingBox(PageSetup *setupPtr, int width, int height)
{
+ PageSetupOptions* pops = (PageSetupOptions*)setupPtr->ops_;
int paperWidth, paperHeight;
- int x, y, hSize, vSize, hBorder, vBorder;
float hScale, vScale, scale;
- x = setupPtr->xPad;
- y = setupPtr->yPad;
+ int x = pops->xPad;
+ int y = pops->yPad;
- hBorder = 2*setupPtr->xPad;
- vBorder = 2*setupPtr->yPad;
+ int hBorder = 2*pops->xPad;
+ int vBorder = 2*pops->yPad;
- if (setupPtr->landscape) {
+ int hSize, vSize;
+ if (pops->landscape) {
hSize = height;
vSize = width;
} else {
@@ -83,9 +84,9 @@ int Blt_Ps_ComputeBoundingBox(PageSetup *setupPtr, int width, int height)
* If the paper size wasn't specified, set it to the graph size plus the
* paper border.
*/
- paperWidth = (setupPtr->reqPaperWidth > 0) ? setupPtr->reqPaperWidth :
+ paperWidth = (pops->reqPaperWidth > 0) ? pops->reqPaperWidth :
hSize + hBorder;
- paperHeight = (setupPtr->reqPaperHeight > 0) ? setupPtr->reqPaperHeight :
+ paperHeight = (pops->reqPaperHeight > 0) ? pops->reqPaperHeight :
vSize + vBorder;
/*
@@ -105,7 +106,7 @@ int Blt_Ps_ComputeBoundingBox(PageSetup *setupPtr, int width, int height)
vSize = (int)((vSize * scale) + 0.5f);
}
setupPtr->scale = scale;
- if (setupPtr->center) {
+ if (pops->center) {
if (paperWidth > hSize) {
x = (paperWidth - hSize) / 2;
}
@@ -301,18 +302,20 @@ static void XColorToPostScript(Blt_Ps ps, XColor* colorPtr)
void Blt_Ps_XSetBackground(PostScript *psPtr, XColor* colorPtr)
{
+ PageSetupOptions* pops = (PageSetupOptions*)psPtr->setupPtr->ops_;
XColorToPostScript(psPtr, colorPtr);
Blt_Ps_Append(psPtr, " setrgbcolor\n");
- if (psPtr->setupPtr->greyscale) {
+ if (pops->greyscale) {
Blt_Ps_Append(psPtr, " currentgray setgray\n");
}
}
void Blt_Ps_XSetForeground(PostScript *psPtr, XColor* colorPtr)
{
+ PageSetupOptions* pops = (PageSetupOptions*)psPtr->setupPtr->ops_;
XColorToPostScript(psPtr, colorPtr);
Blt_Ps_Append(psPtr, " setrgbcolor\n");
- if (psPtr->setupPtr->greyscale) {
+ if (pops->greyscale) {
Blt_Ps_Append(psPtr, " currentgray setgray\n");
}
}
diff --git a/src/bltGrPostscript.C b/src/bltGrPostscript.C
index e3397c1..f9d4612 100644
--- a/src/bltGrPostscript.C
+++ b/src/bltGrPostscript.C
@@ -36,32 +36,32 @@ extern "C" {
static Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_BOOLEAN, "-center", "center", "Center",
- "yes", -1, Tk_Offset(PageSetup, center), 0, NULL, 0},
+ "yes", -1, Tk_Offset(PageSetupOptions, center), 0, NULL, 0},
{TK_OPTION_CUSTOM, "-comments", "comments", "Comments",
- NULL, -1, Tk_Offset(PageSetup, comments),
+ NULL, -1, Tk_Offset(PageSetupOptions, comments),
TK_OPTION_NULL_OK, &listObjOption, 0},
{TK_OPTION_BOOLEAN, "-decorations", "decorations", "Decorations",
- "no", -1, Tk_Offset(PageSetup, decorations), 0, NULL, 0},
+ "no", -1, Tk_Offset(PageSetupOptions, decorations), 0, NULL, 0},
{TK_OPTION_BOOLEAN, "-footer", "footer", "Footer",
- "no", -1, Tk_Offset(PageSetup, footer), 0, NULL, 0},
+ "no", -1, Tk_Offset(PageSetupOptions, footer), 0, NULL, 0},
{TK_OPTION_BOOLEAN, "-greyscale", "greyscale", "Greyscale",
- "no", -1, Tk_Offset(PageSetup, greyscale), 0, NULL, 0},
+ "no", -1, Tk_Offset(PageSetupOptions, greyscale), 0, NULL, 0},
{TK_OPTION_PIXELS, "-height", "height", "Height",
- "0", -1, Tk_Offset(PageSetup, reqHeight), 0, NULL, 0},
+ "0", -1, Tk_Offset(PageSetupOptions, reqHeight), 0, NULL, 0},
{TK_OPTION_BOOLEAN, "-landscape", "landscape", "Landscape",
- "no", -1, Tk_Offset(PageSetup, landscape), 0, NULL, 0},
+ "no", -1, Tk_Offset(PageSetupOptions, landscape), 0, NULL, 0},
{TK_OPTION_INT, "-level", "level", "Level",
- "2", -1, Tk_Offset(PageSetup, level), 0, NULL, 0},
+ "2", -1, Tk_Offset(PageSetupOptions, level), 0, NULL, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "PadX",
- "1.0i", -1, Tk_Offset(PageSetup, xPad), 0, NULL, 0},
+ "1.0i", -1, Tk_Offset(PageSetupOptions, xPad), 0, NULL, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "PadY",
- "1.0i", -1, Tk_Offset(PageSetup, yPad), 0, NULL, 0},
+ "1.0i", -1, Tk_Offset(PageSetupOptions, yPad), 0, NULL, 0},
{TK_OPTION_PIXELS, "-paperheight", "paperHeight", "PaperHeight",
- "11.0i", -1, Tk_Offset(PageSetup, reqPaperHeight), 0, NULL, 0},
+ "11.0i", -1, Tk_Offset(PageSetupOptions, reqPaperHeight), 0, NULL, 0},
{TK_OPTION_PIXELS, "-paperwidth", "paperWidth", "PaperWidth",
- "8.5i", -1, Tk_Offset(PageSetup, reqPaperWidth), 0, NULL, 0},
+ "8.5i", -1, Tk_Offset(PageSetupOptions, reqPaperWidth), 0, NULL, 0},
{TK_OPTION_PIXELS, "-width", "width", "Width",
- "0", -1, Tk_Offset(PageSetup, reqWidth), 0, NULL, 0},
+ "0", -1, Tk_Offset(PageSetupOptions, reqWidth), 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, -1, 0, 0, NULL, 0}
};
@@ -69,52 +69,22 @@ int Blt_CreatePageSetup(Graph* graphPtr)
{
PageSetup* setupPtr = (PageSetup*)calloc(1, sizeof(PageSetup));
graphPtr->pageSetup_ = setupPtr;
+ setupPtr->ops_ = (PageSetupOptions*)calloc(1, sizeof(PageSetupOptions));
- setupPtr->optionTable =Tk_CreateOptionTable(graphPtr->interp_, optionSpecs);
- return Tk_InitOptions(graphPtr->interp_, (char*)setupPtr,
- setupPtr->optionTable, graphPtr->tkwin_);
+ setupPtr->optionTable_ =Tk_CreateOptionTable(graphPtr->interp_, optionSpecs);
+ return Tk_InitOptions(graphPtr->interp_, (char*)setupPtr->ops_,
+ setupPtr->optionTable_, graphPtr->tkwin_);
}
void Blt_DestroyPageSetup(Graph* graphPtr)
{
PageSetup* setupPtr = graphPtr->pageSetup_;
- Tk_FreeConfigOptions((char*)setupPtr, setupPtr->optionTable, graphPtr->tkwin_);
- free(setupPtr);
-}
+ Tk_FreeConfigOptions((char*)setupPtr->ops_, setupPtr->optionTable_,
+ graphPtr->tkwin_);
-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;
+ if(setupPtr->ops_)
+ free(setupPtr->ops_);
- 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;
- }
+ free(setupPtr);
}
diff --git a/src/bltGrPostscript.h b/src/bltGrPostscript.h
index 5851625..53dffd6 100644
--- a/src/bltGrPostscript.h
+++ b/src/bltGrPostscript.h
@@ -30,43 +30,34 @@
#ifndef __BltGrPageSetup_h__
#define __BltGrPageSetup_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;
+typedef struct {
int center;
+ const char **comments;
+ int decorations;
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;
+ int level;
+ int xPad;
+ int yPad;
+ int reqPaperWidth;
+ int reqPaperHeight;
+ int reqWidth;
+ int reqHeight;
+} PageSetupOptions;
- float scale; /* Scale of page. Set if "-maxpect" option
- * is set, otherwise 1.0. */
+typedef struct {
+ Tk_OptionTable optionTable_;
+ void* ops_;
+ unsigned int flags;
+ short int left;
+ short int bottom;
+ short int right;
+ short int top;
+ float scale;
int paperHeight;
int paperWidth;
-
} PageSetup;
#endif
diff --git a/src/bltGrPostscriptOp.C b/src/bltGrPostscriptOp.C
index ed79088..2c81984 100644
--- a/src/bltGrPostscriptOp.C
+++ b/src/bltGrPostscriptOp.C
@@ -35,6 +35,42 @@ extern "C" {
#include "bltGrPageSetupOp.h"
#include "bltPs.h"
+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->ops_, 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;
+ }
+}
+
static int CgetOp(Graph* graphPtr, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
@@ -45,8 +81,8 @@ static int CgetOp(Graph* graphPtr, Tcl_Interp* interp,
PageSetup *setupPtr = graphPtr->pageSetup_;
Tcl_Obj* objPtr = Tk_GetOptionValue(interp,
- (char*)setupPtr,
- setupPtr->optionTable,
+ (char*)setupPtr->ops_,
+ setupPtr->optionTable_,
objv[3], graphPtr->tkwin_);
if (objPtr == NULL)
return TCL_ERROR;
@@ -60,8 +96,8 @@ static int ConfigureOp(Graph* graphPtr, Tcl_Interp* interp,
{
PageSetup* setupPtr = graphPtr->pageSetup_;
if (objc <= 4) {
- Tcl_Obj* objPtr = Tk_GetOptionInfo(interp, (char*)setupPtr,
- setupPtr->optionTable,
+ Tcl_Obj* objPtr = Tk_GetOptionInfo(interp, (char*)setupPtr->ops_,
+ setupPtr->optionTable_,
(objc == 4) ? objv[3] : NULL,
graphPtr->tkwin_);
if (objPtr == NULL)
@@ -142,7 +178,7 @@ 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,
+int Blt_PsOp(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);
@@ -168,6 +204,7 @@ static void AddComments(Blt_Ps ps, const char **comments)
int PostScriptPreamble(Graph* graphPtr, const char *fileName, Blt_Ps ps)
{
PageSetup *setupPtr = graphPtr->pageSetup_;
+ PageSetupOptions* ops = (PageSetupOptions*)setupPtr->ops_;
time_t ticks;
char date[200]; /* Holds the date string from ctime() */
char *newline;
@@ -200,18 +237,18 @@ int PostScriptPreamble(Graph* graphPtr, const char *fileName, Blt_Ps ps)
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) {
+ if (ops->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);
+ AddComments(ps, ops->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) {
+ if (ops->footer) {
const char *who;
who = getenv("LOGNAME");
@@ -246,7 +283,7 @@ int PostScriptPreamble(Graph* graphPtr, const char *fileName, Blt_Ps ps)
"% 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) {
+ if (ops->landscape) {
Blt_Ps_Format(ps,
"%% Landscape orientation\n0 %g translate\n-90 rotate\n",
((double)graphPtr->width_ * setupPtr->scale));
diff --git a/src/bltGrPostscriptOp.h b/src/bltGrPostscriptOp.h
index 29df072..02abee5 100644
--- a/src/bltGrPostscriptOp.h
+++ b/src/bltGrPostscriptOp.h
@@ -37,7 +37,6 @@ 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[]);
+extern int Blt_PsOp(Graph* graphPtr, Tcl_Interp* interp, int objc,
+ Tcl_Obj* const objv[]);
#endif
diff --git a/src/bltGraph.C b/src/bltGraph.C
index d4fa67d..b5f5c17 100644
--- a/src/bltGraph.C
+++ b/src/bltGraph.C
@@ -386,18 +386,19 @@ int Graph::print(const char *ident, Blt_Ps ps)
{
GraphOptions* ops = (GraphOptions*)ops_;
PageSetup *setupPtr = pageSetup_;
+ PageSetupOptions* pops = (PageSetupOptions*)pageSetup_->ops_;
// We need to know how big a graph to print. If the graph hasn't been drawn
// yet, the width and height will be 1. Instead use the requested size of
// the widget. The user can still override this with the -width and -height
// postscript options.
- if (setupPtr->reqWidth > 0)
- width_ = setupPtr->reqWidth;
+ if (pops->reqWidth > 0)
+ width_ = pops->reqWidth;
else if (width_ < 2)
width_ = Tk_ReqWidth(tkwin_);
- if (setupPtr->reqHeight > 0)
- height_ = setupPtr->reqHeight;
+ if (pops->reqHeight > 0)
+ height_ = pops->reqHeight;
else if (height_ < 2)
height_ = Tk_ReqHeight(tkwin_);
@@ -420,7 +421,7 @@ int Graph::print(const char *ident, Blt_Ps ps)
goto error;
Blt_Ps_XSetFont(ps, ops->titleTextStyle.font);
- if (pageSetup_->decorations)
+ if (pops->decorations)
Blt_Ps_XSetBackground(ps, Tk_3DBorderColor(ops->plotBg));
else
Blt_Ps_SetClearBackground(ps);
@@ -576,7 +577,7 @@ void Graph::drawMargins(Drawable drawable)
void Graph::printMargins(Blt_Ps ps)
{
GraphOptions* ops = (GraphOptions*)ops_;
- PageSetup *setupPtr = pageSetup_;
+ PageSetupOptions* pops = (PageSetupOptions*)pageSetup_->ops_;
XRectangle margin[4];
margin[0].x = margin[0].y = margin[3].x = margin[1].x = 0;
@@ -591,7 +592,7 @@ void Graph::printMargins(Blt_Ps ps)
margin[2].width = width_ - right_;
// Clear the surrounding margins and clip the plotting surface
- if (setupPtr->decorations)
+ if (pops->decorations)
Blt_Ps_XSetBackground(ps, Tk_3DBorderColor(ops->normalBg));
else
Blt_Ps_SetClearBackground(ps);
diff --git a/src/bltGraphOp.C b/src/bltGraphOp.C
index 3de03aa..db05fd4 100644
--- a/src/bltGraphOp.C
+++ b/src/bltGraphOp.C
@@ -52,15 +52,14 @@ extern "C" {
#include "bltGrLegdOp.h"
#include "bltGrHairs.h"
#include "bltGrHairsOp.h"
+#include "bltGrPageSetup.h"
+#include "bltGrPageSetupOp.h"
using namespace Blt;
static Tcl_ObjCmdProc BarchartObjCmd;
static Tcl_ObjCmdProc GraphObjCmd;
-extern int Blt_PostScriptOp(Graph* graphPtr, Tcl_Interp* interp, int objc,
- Tcl_Obj* const objv[]);
-
int Blt_GraphCmdInitProc(Tcl_Interp* interp)
{
static Blt_InitCmdSpec graphSpec =
@@ -400,7 +399,7 @@ static Blt_OpSpec graphOps[] =
{"line", 2, (void*)ElementOp, 2, 0, "oper ?args?",},
{"marker", 2, (void*)Blt::MarkerOp, 2, 0, "oper ?args?",},
{"pen", 2, (void*)Blt_PenOp, 2, 0, "oper ?args?",},
- {"postscript", 2, (void*)Blt_PostScriptOp, 2, 0, "oper ?args?",},
+ {"postscript", 2, (void*)Blt_PsOp, 2, 0, "oper ?args?",},
{"transform", 1, (void*)TransformOp, 4, 4, "x y",},
{"x2axis", 2, (void*)X2AxisOp, 2, 0, "oper ?args?",},
{"xaxis", 2, (void*)XAxisOp, 2, 0, "oper ?args?",},