summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/bltGrPSOutput.C14
-rw-r--r--src/bltGrPSOutput.h2
-rw-r--r--src/bltGraph.C10
3 files changed, 14 insertions, 12 deletions
diff --git a/src/bltGrPSOutput.C b/src/bltGrPSOutput.C
index 246fd69..0800ba5 100644
--- a/src/bltGrPSOutput.C
+++ b/src/bltGrPSOutput.C
@@ -88,21 +88,15 @@ void PSOutput::printSegments(Segment2d* segments, int nSegments)
}
}
-void PSOutput::computeBBox(int width, int height)
+void PSOutput::computeBBox(int width, int height, float pica)
{
Postscript* setupPtr = graphPtr_->postscript_;
PostscriptOptions* pops = (PostscriptOptions*)setupPtr->ops_;
- // page size is in pica
- float pica = 25.4 / 72 *
- WidthOfScreen(Tk_Screen(graphPtr_->tkwin_)) /
- WidthMMOfScreen(Tk_Screen(graphPtr_->tkwin_));
int hBorder = 2*pops->xPad/pica;
int vBorder = 2*pops->yPad/pica;
int hSize = !pops->landscape ? width : height;
int vSize = !pops->landscape ? height : width;
- hSize /= pica;
- vSize /= pica;
// If the paper size wasn't specified, set it to the graph size plus the
// paper border.
@@ -124,9 +118,9 @@ void PSOutput::computeBBox(int width, int height)
}
int x = (paperWidth > hSize) && pops->center ?
- (paperWidth - hSize) / 2 : pops->xPad;
+ (paperWidth - hSize) / 2 : pops->xPad/pica;
int y = (paperHeight > vSize) && pops->center ?
- (paperHeight - vSize) / 2 : pops->yPad;
+ (paperHeight - vSize) / 2 : pops->yPad/pica;
setupPtr->left = x;
setupPtr->bottom = y;
@@ -465,7 +459,7 @@ int PSOutput::preamble(const char* fileName)
append("% 1. Flip y-axis over by reversing the scale,\n");
append("% 2. Translate the origin to the other side of the page,\n");
append("% making the origin the upper left corner\n");
- format("1 -1 scale\n");
+ append("1 -1 scale\n");
format("0 %d translate\n", -setupPtr->paperHeight);
// Set Origin
diff --git a/src/bltGrPSOutput.h b/src/bltGrPSOutput.h
index c54e771..f769a62 100644
--- a/src/bltGrPSOutput.h
+++ b/src/bltGrPSOutput.h
@@ -79,7 +79,7 @@ namespace Blt {
void setDashes(Dashes*);
int preamble(const char*);
- void computeBBox(int, int);
+ void computeBBox(int, int, float);
const char* getValue(int*);
void append(const char*);
void format(const char*, ...);
diff --git a/src/bltGraph.C b/src/bltGraph.C
index fc0bc86..4fbc00a 100644
--- a/src/bltGraph.C
+++ b/src/bltGraph.C
@@ -373,7 +373,15 @@ int Graph::print(const char* ident, PSOutput* psPtr)
else if (height_ < 2)
height_ = Tk_ReqHeight(tkwin_);
- psPtr->computeBBox(width_, height_);
+ // scale from points to pica
+ float pica = 25.4 / 72 *
+ WidthOfScreen(Tk_Screen(tkwin_)) /
+ WidthMMOfScreen(Tk_Screen(tkwin_));
+
+ width_ /= pica;
+ height_ /= pica;
+
+ psPtr->computeBBox(width_, height_, pica);
flags |= RESET;
// Turn on PostScript measurements when computing the graph's layout.