summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjoye <joye>2014-06-04 18:02:03 (GMT)
committerjoye <joye>2014-06-04 18:02:03 (GMT)
commite2945e411ee4faf8f91166a2f98febd2892d0b8b (patch)
treec5588077c0560a23bd3a3dbabee34ade809079d4 /src
parent6b0d697c9848b65a016ebfb12abd1cdb50aa7927 (diff)
downloadblt-e2945e411ee4faf8f91166a2f98febd2892d0b8b.zip
blt-e2945e411ee4faf8f91166a2f98febd2892d0b8b.tar.gz
blt-e2945e411ee4faf8f91166a2f98febd2892d0b8b.tar.bz2
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r--src/bltGrAxis.C9
-rw-r--r--src/bltGrElemBar.C6
-rw-r--r--src/bltGrElemLine.C14
-rw-r--r--src/bltGrLegd.C6
-rw-r--r--src/bltGrMarkerLine.C2
-rw-r--r--src/bltGrMarkerPolygon.C4
-rw-r--r--src/bltGrMisc.C34
-rw-r--r--src/bltGrPSOutput.C28
-rw-r--r--src/bltGrPSOutput.h16
-rw-r--r--src/bltGrText.C2
-rw-r--r--src/bltGraph.C42
-rw-r--r--src/bltGraph.h1
12 files changed, 84 insertions, 80 deletions
diff --git a/src/bltGrAxis.C b/src/bltGrAxis.C
index a06f3f0..65bdd69 100644
--- a/src/bltGrAxis.C
+++ b/src/bltGrAxis.C
@@ -1682,12 +1682,11 @@ void Axis::print(PostScript* psPtr)
tops->angle = titleAngle_;
tops->font = ops->titleFont;
tops->anchor = titleAnchor_;
- tops->justify = ops->titleJustify;
tops->color = ops->titleColor;
+ tops->justify = ops->titleJustify;
ts.xPad_ = 1;
ts.yPad_ = 0;
-
ts.printText(psPtr, ops->title, titlePos_.x, titlePos_.y);
}
@@ -1714,7 +1713,7 @@ void Axis::print(PostScript* psPtr)
if ((nSegments_ > 0) && (ops->lineWidth > 0)) {
psPtr->setLineAttributes(ops->tickColor, ops->lineWidth,
(Dashes*)NULL, CapButt, JoinMiter);
- psPtr->drawSegments(segments_, nSegments_);
+ psPtr->printSegments(segments_, nSegments_);
}
}
@@ -1729,13 +1728,13 @@ void Axis::printGrids(PostScript* psPtr)
psPtr->setLineAttributes(ops->major.color, ops->major.lineWidth,
&ops->major.dashes, CapButt, JoinMiter);
psPtr->format("%% Axis %s: major grid line segments\n", name_);
- psPtr->drawSegments(ops->major.segments, ops->major.nUsed);
+ psPtr->printSegments(ops->major.segments, ops->major.nUsed);
if (ops->showGridMinor) {
psPtr->setLineAttributes(ops->minor.color, ops->minor.lineWidth,
&ops->minor.dashes, CapButt, JoinMiter);
psPtr->format("%% Axis %s: minor grid line segments\n", name_);
- psPtr->drawSegments(ops->minor.segments, ops->minor.nUsed);
+ psPtr->printSegments(ops->minor.segments, ops->minor.nUsed);
}
}
diff --git a/src/bltGrElemBar.C b/src/bltGrElemBar.C
index 09cd1fb..310fabf 100644
--- a/src/bltGrElemBar.C
+++ b/src/bltGrElemBar.C
@@ -771,13 +771,13 @@ void BarElement::print(PostScript* psPtr)
if ((stylePtr->xeb.length > 0) && (pops->errorBarShow & SHOW_X)) {
psPtr->setLineAttributes(colorPtr, pops->errorBarLineWidth,
NULL, CapButt, JoinMiter);
- psPtr->drawSegments(stylePtr->xeb.segments, stylePtr->xeb.length);
+ psPtr->printSegments(stylePtr->xeb.segments, stylePtr->xeb.length);
}
if ((stylePtr->yeb.length > 0) && (pops->errorBarShow & SHOW_Y)) {
psPtr->setLineAttributes(colorPtr, pops->errorBarLineWidth,
NULL, CapButt, JoinMiter);
- psPtr->drawSegments(stylePtr->yeb.segments, stylePtr->yeb.length);
+ psPtr->printSegments(stylePtr->yeb.segments, stylePtr->yeb.length);
}
if (pops->valueShow != SHOW_NONE)
@@ -1273,7 +1273,7 @@ void BarElement::printSegments(PostScript* psPtr, BarPen* penPtr,
}
if ((pops->fill) && (pops->borderWidth > 0) &&
(pops->relief != TK_RELIEF_FLAT))
- psPtr->draw3DRectangle(pops->fill, (double)rp->x, (double)rp->y,
+ psPtr->print3DRectangle(pops->fill, (double)rp->x, (double)rp->y,
(int)rp->width, (int)rp->height,
pops->borderWidth, pops->relief);
}
diff --git a/src/bltGrElemLine.C b/src/bltGrElemLine.C
index 58c8980..1a08eb7 100644
--- a/src/bltGrElemLine.C
+++ b/src/bltGrElemLine.C
@@ -668,7 +668,7 @@ void LineElement::print(PostScript* psPtr)
if (fillPts_) {
// Create a path to use for both the polygon and its outline
psPtr->append("% start fill area\n");
- psPtr->drawPolyline(fillPts_, nFillPts_);
+ psPtr->printPolyline(fillPts_, nFillPts_);
// If the background fill color was specified, draw the polygon in a
// solid fashion with that color
@@ -699,12 +699,12 @@ void LineElement::print(PostScript* psPtr)
if ((stylePtr->xeb.length > 0) && (penOps->errorBarShow & SHOW_X)) {
psPtr->setLineAttributes(colorPtr, penOps->errorBarLineWidth,
NULL, CapButt, JoinMiter);
- psPtr->drawSegments(stylePtr->xeb.segments, stylePtr->xeb.length);
+ psPtr->printSegments(stylePtr->xeb.segments, stylePtr->xeb.length);
}
if ((stylePtr->yeb.length > 0) && (penOps->errorBarShow & SHOW_Y)) {
psPtr->setLineAttributes(colorPtr, penOps->errorBarLineWidth,
NULL, CapButt, JoinMiter);
- psPtr->drawSegments(stylePtr->yeb.segments, stylePtr->yeb.length);
+ psPtr->printSegments(stylePtr->yeb.segments, stylePtr->yeb.length);
}
if ((stylePtr->symbolPts.length > 0) &&
(penOps->symbol.type != SYMBOL_NONE)) {
@@ -2671,13 +2671,15 @@ void LineElement::getSymbolPostScriptInfo(PostScript* psPtr, LinePen* penPtr, in
Tk_NameOfBitmap(graphPtr_->display_,pops->symbol.mask),
"\"\n\n ", NULL);
psPtr->setBackground(fillColor);
- psPtr->drawBitmap(graphPtr_->display_, pops->symbol.mask, scale, scale);
+ psPtr->printBitmap(graphPtr_->display_, pops->symbol.mask, scale,
+ scale);
}
psPtr->varAppend("\n % Bitmap symbol is \"",
Tk_NameOfBitmap(graphPtr_->display_,pops->symbol.bitmap),
"\"\n\n ", NULL);
psPtr->setForeground(outlineColor);
- psPtr->drawBitmap(graphPtr_->display_, pops->symbol.bitmap, scale, scale);
+ psPtr->printBitmap(graphPtr_->display_, pops->symbol.bitmap, scale,
+ scale);
}
break;
default:
@@ -2762,7 +2764,7 @@ void LineElement::printTraces(PostScript* psPtr, LinePen* penPtr)
bltTrace *tracePtr = (bltTrace*)Blt_Chain_GetValue(link);
if (tracePtr->screenPts.length > 0) {
psPtr->append("% start trace\n");
- psPtr->drawMaxPolyline(tracePtr->screenPts.points,
+ psPtr->printMaxPolyline(tracePtr->screenPts.points,
tracePtr->screenPts.length);
psPtr->append("% end trace\n");
}
diff --git a/src/bltGrLegd.C b/src/bltGrLegd.C
index 73ec682..bfd8bab 100644
--- a/src/bltGrLegd.C
+++ b/src/bltGrLegd.C
@@ -565,7 +565,7 @@ void Legend::print(PostScript* psPtr)
psPtr->fill3DRectangle(ops->normalBg, x, y, width, height,
ops->borderWidth, ops->relief);
else
- psPtr->draw3DRectangle(gops->normalBg, x, y, width, height,
+ psPtr->print3DRectangle(gops->normalBg, x, y, width, height,
ops->borderWidth, ops->relief);
}
@@ -611,7 +611,7 @@ void Legend::print(PostScript* psPtr)
else {
ops->style.color = ops->fgColor;
if (elemOps->legendRelief != TK_RELIEF_FLAT) {
- psPtr->draw3DRectangle(gops->normalBg, x, y, entryWidth_, entryHeight_,
+ psPtr->print3DRectangle(gops->normalBg, x, y, entryWidth_, entryHeight_,
ops->entryBW, elemOps->legendRelief);
}
}
@@ -868,7 +868,7 @@ int Legend::getElementFromObj(Tcl_Obj* objPtr, Element** elemPtrPtr)
elemPtr = getPreviousColumn(focusPtr_);
else if (string[0] == '@') {
int x, y;
- if (Blt_GetXY(graphPtr_->interp_, graphPtr_->tkwin_, string, &x, &y) != TCL_OK)
+ if (graphPtr_->getXY(string, &x, &y) != TCL_OK)
return TCL_ERROR;
ClassId classId;
diff --git a/src/bltGrMarkerLine.C b/src/bltGrMarkerLine.C
index b973e97..22b788f 100644
--- a/src/bltGrMarkerLine.C
+++ b/src/bltGrMarkerLine.C
@@ -318,7 +318,7 @@ void LineMarker::print(PostScript* psPtr)
else
psPtr->append("/DashesProc {} def\n");
- psPtr->drawSegments(segments_, nSegments_);
+ psPtr->printSegments(segments_, nSegments_);
}
}
diff --git a/src/bltGrMarkerPolygon.C b/src/bltGrMarkerPolygon.C
index 6618851..61c0a71 100644
--- a/src/bltGrMarkerPolygon.C
+++ b/src/bltGrMarkerPolygon.C
@@ -332,7 +332,7 @@ void PolygonMarker::print(PostScript* psPtr)
PolygonMarkerOptions* ops = (PolygonMarkerOptions*)ops_;
if (ops->fill) {
- psPtr->drawPolyline(fillPts_, nFillPts_);
+ psPtr->printPolyline(fillPts_, nFillPts_);
if (ops->fillBg) {
psPtr->setBackground(ops->fillBg);
psPtr->append("gsave fill grestore\n");
@@ -355,7 +355,7 @@ void PolygonMarker::print(PostScript* psPtr)
else
psPtr->append("/DashesProc {} def\n");
- psPtr->drawSegments(outlinePts_, nOutlinePts_);
+ psPtr->printSegments(outlinePts_, nOutlinePts_);
}
}
diff --git a/src/bltGrMisc.C b/src/bltGrMisc.C
index 22688cd..e0a313e 100644
--- a/src/bltGrMisc.C
+++ b/src/bltGrMisc.C
@@ -56,40 +56,6 @@ char* Blt::dupstr(const char* str)
return copy;
}
-int Blt_GetXY(Tcl_Interp* interp, Tk_Window tkwin, const char* string,
- int* xPtr, int* yPtr)
-{
- if ((string == NULL) || (*string == '\0')) {
- *xPtr = *yPtr = -SHRT_MAX;
- return TCL_OK;
- }
-
- if (*string != '@') {
- Tcl_AppendResult(interp, "bad position \"", string,
- "\": should be \"@x,y\"", (char *)NULL);
- return TCL_ERROR;
- }
-
- char *comma = (char*)strchr(string + 1, ',');
- if (comma == NULL) {
- }
-
- *comma = '\0';
- int x, y;
- int result = ((Tk_GetPixels(interp, tkwin, string + 1, &x) == TCL_OK) &&
- (Tk_GetPixels(interp, tkwin, comma + 1, &y) == TCL_OK));
- *comma = ',';
- if (!result) {
- Tcl_AppendResult(interp, ": can't parse position \"", string, "\"",
- (char *)NULL);
- return TCL_ERROR;
- }
-
- *xPtr = x;
- *yPtr = y;
- return TCL_OK;
-}
-
int Blt_PointInPolygon(Point2d *s, Point2d *points, int nPoints)
{
Point2d *p, *q, *qend;
diff --git a/src/bltGrPSOutput.C b/src/bltGrPSOutput.C
index c50ee18..a91c1bc 100644
--- a/src/bltGrPSOutput.C
+++ b/src/bltGrPSOutput.C
@@ -62,7 +62,7 @@ PostScript::~PostScript()
Tcl_DStringFree(&dString_);
}
-void PostScript::drawPolyline(Point2d* screenPts, int nScreenPts)
+void PostScript::printPolyline(Point2d* screenPts, int nScreenPts)
{
Point2d* pp = screenPts;
append("newpath\n");
@@ -73,20 +73,20 @@ void PostScript::drawPolyline(Point2d* screenPts, int nScreenPts)
format(" %g %g lineto\n", pp->x, pp->y);
}
-void PostScript::drawMaxPolyline(Point2d* points, int nPoints)
+void PostScript::printMaxPolyline(Point2d* points, int nPoints)
{
if (nPoints <= 0)
return;
for (int nLeft = nPoints; nLeft > 0; nLeft -= 1500) {
int length = MIN(1500, nLeft);
- drawPolyline(points, length);
+ printPolyline(points, length);
append("DashesProc stroke\n");
points += length;
}
}
-void PostScript::drawSegments(Segment2d* segments, int nSegments)
+void PostScript::printSegments(Segment2d* segments, int nSegments)
{
append("newpath\n");
@@ -201,7 +201,7 @@ void PostScript::setLineWidth(int lineWidth)
format("%d setlinewidth\n", lineWidth);
}
-void PostScript::drawRectangle(int x, int y, int width, int height)
+void PostScript::printRectangle(int x, int y, int width, int height)
{
append("newpath\n");
format(" %d %d moveto\n", x, y);
@@ -213,7 +213,7 @@ void PostScript::drawRectangle(int x, int y, int width, int height)
void PostScript::fillRectangle(double x, double y, int width, int height)
{
- drawRectangle((int)x, (int)y, width, height);
+ printRectangle((int)x, (int)y, width, height);
append("fill\n");
}
@@ -280,7 +280,7 @@ void PostScript::fill3DRectangle(Tk_3DBorder border, double x, double y,
setBackground(borderPtr->bgColorPtr);
fillRectangle(x, y, width, height);
- draw3DRectangle(border, x, y, width, height, borderWidth, relief);
+ print3DRectangle(border, x, y, width, height, borderWidth, relief);
}
void PostScript::setClearBackground()
@@ -301,11 +301,11 @@ void PostScript::setDashes(Dashes* dashesPtr)
void PostScript::fillPolygon(Point2d *screenPts, int nScreenPts)
{
- drawPolygon(screenPts, nScreenPts);
+ printPolygon(screenPts, nScreenPts);
append("fill\n");
}
-void PostScript::drawBitmap(Display *display, Pixmap bitmap,
+void PostScript::printBitmap(Display *display, Pixmap bitmap,
double xScale, double yScale)
{
int width, height;
@@ -338,7 +338,7 @@ void PostScript::setCapStyle(int capStyle)
format("%d setlinecap\n", capStyle);
}
-void PostScript::drawPolygon(Point2d *screenPts, int nScreenPts)
+void PostScript::printPolygon(Point2d *screenPts, int nScreenPts)
{
Point2d* pp = screenPts;
append("newpath\n");
@@ -352,7 +352,7 @@ void PostScript::drawPolygon(Point2d *screenPts, int nScreenPts)
append("closepath\n");
}
-void PostScript::draw3DRectangle(Tk_3DBorder border, double x, double y,
+void PostScript::print3DRectangle(Tk_3DBorder border, double x, double y,
int width, int height, int borderWidth,
int relief)
{
@@ -387,10 +387,10 @@ void PostScript::draw3DRectangle(Tk_3DBorder border, double x, double y,
if ((relief == TK_RELIEF_GROOVE) || (relief == TK_RELIEF_RIDGE)) {
int halfWidth = borderWidth / 2;
int insideOffset = borderWidth - halfWidth;
- draw3DRectangle(border, (double)x, (double)y, width, height, halfWidth,
+ print3DRectangle(border, (double)x, (double)y, width, height, halfWidth,
(relief == TK_RELIEF_GROOVE) ?
TK_RELIEF_SUNKEN : TK_RELIEF_RAISED);
- draw3DRectangle(border, (double)(x + insideOffset),
+ print3DRectangle(border, (double)(x + insideOffset),
(double)(y + insideOffset), width - insideOffset * 2,
height - insideOffset * 2, halfWidth,
(relief == TK_RELIEF_GROOVE) ?
@@ -586,7 +586,7 @@ void PostScript::byteToHex(unsigned char byte, char* string)
string[1] = hexDigits[byte & 0x0F];
}
-void PostScript::drawText(const char* string, double x, double y)
+void PostScript::printText(const char* string, double x, double y)
{
if (!string || !(*string))
return;
diff --git a/src/bltGrPSOutput.h b/src/bltGrPSOutput.h
index 04a0803..d16da97 100644
--- a/src/bltGrPSOutput.h
+++ b/src/bltGrPSOutput.h
@@ -56,14 +56,14 @@ class PostScript {
PostScript(Graph*);
virtual ~PostScript();
- void drawPolyline(Point2d*, int);
- void drawMaxPolyline(Point2d*, int);
- void drawSegments(Segment2d*, int);
- void drawBitmap(Display*, Pixmap, double, double);
- void drawRectangle(int, int, int, int);
- void drawPolygon(Point2d*, int);
- void draw3DRectangle(Tk_3DBorder, double, double, int, int, int, int);
- void drawText(const char*, double, double);
+ void printPolyline(Point2d*, int);
+ void printMaxPolyline(Point2d*, int);
+ void printSegments(Segment2d*, int);
+ void printBitmap(Display*, Pixmap, double, double);
+ void printRectangle(int, int, int, int);
+ void printPolygon(Point2d*, int);
+ void print3DRectangle(Tk_3DBorder, double, double, int, int, int, int);
+ void printText(const char*, double, double);
void fillRectangle(double, double, int, int);
void fillRectangles(XRectangle*, int);
diff --git a/src/bltGrText.C b/src/bltGrText.C
index e81da01..bfbaed3 100644
--- a/src/bltGrText.C
+++ b/src/bltGrText.C
@@ -137,7 +137,7 @@ void TextStyle::printText(PostScript* psPtr, const char *text, int x, int y)
if (!text || !(*text))
return;
- psPtr->drawText(text, x, y);
+ psPtr->printText(text, x, y);
}
void TextStyle::resetStyle()
diff --git a/src/bltGraph.C b/src/bltGraph.C
index c5e5a88..6857100 100644
--- a/src/bltGraph.C
+++ b/src/bltGraph.C
@@ -390,7 +390,7 @@ int Graph::print(const char* ident, PostScript* psPtr)
psPtr->setClearBackground();
psPtr->fillRectangle(x, y, w, h);
- psPtr->drawRectangle(x, y, w, h);
+ psPtr->printRectangle(x, y, w, h);
psPtr->append("gsave clip\n\n");
// Start
@@ -585,7 +585,7 @@ void Graph::printMargins(PostScript* psPtr)
int y = top_ - ops->plotBW;
int w = (right_ - left_) + (2*ops->plotBW);
int h = (bottom_ - top_) + (2*ops->plotBW);
- psPtr->draw3DRectangle(ops->normalBg, (double)x, (double)y, w, h,
+ psPtr->print3DRectangle(ops->normalBg, (double)x, (double)y, w, h,
ops->plotBW, ops->plotRelief);
}
@@ -1394,6 +1394,43 @@ ClientData Graph::pickEntry(int xx, int yy, ClassId* classIdPtr)
return NULL;
}
+int Graph::getXY(const char* string, int* xPtr, int* yPtr)
+{
+ if (!string || !*string) {
+ *xPtr = -SHRT_MAX;
+ *yPtr = -SHRT_MAX;
+ return TCL_OK;
+ }
+
+ if (*string != '@') {
+ Tcl_AppendResult(interp_, "bad position \"", string,
+ "\": should be \"@x,y\"", (char *)NULL);
+ return TCL_ERROR;
+ }
+
+ char* comma = (char*)strchr(string + 1, ',');
+ if (!comma) {
+ Tcl_AppendResult(interp_, "bad position \"", string,
+ "\": should be \"@x,y\"", (char *)NULL);
+ return TCL_ERROR;
+ }
+
+ *comma = '\0';
+ int x, y;
+ int result = ((Tk_GetPixels(interp_, tkwin_, string + 1, &x) == TCL_OK) &&
+ (Tk_GetPixels(interp_, tkwin_, comma + 1, &y) == TCL_OK));
+ *comma = ',';
+ if (!result) {
+ Tcl_AppendResult(interp_, ": can't parse position \"", string, "\"",
+ (char *)NULL);
+ return TCL_ERROR;
+ }
+
+ *xPtr = x;
+ *yPtr = y;
+ return TCL_OK;
+}
+
// Graphics
void Graph::drawSegments(Drawable drawable, GC gc,
@@ -1445,4 +1482,3 @@ void Graph::setDashes(GC gc, Dashes* dashesPtr)
XSetDashes(display_, gc, dashesPtr->offset, (const char*)dashesPtr->values,
(int)strlen((char*)dashesPtr->values));
}
-
diff --git a/src/bltGraph.h b/src/bltGraph.h
index 8f58222..bc02c8d 100644
--- a/src/bltGraph.h
+++ b/src/bltGraph.h
@@ -246,6 +246,7 @@ class Graph : public Pick {
virtual int createPen(const char*, int, Tcl_Obj* const []) =0;
int getPen(Tcl_Obj*, Pen**);
+ int getXY(const char*, int*, int*);
void getTextExtents(Tk_Font, const char*, int, int*, int*);
void getBoundingBox(int, int, float, double*, double*, Point2d*);
Point2d anchorPoint(double, double, double, double, Tk_Anchor);