diff options
author | joye <joye> | 2014-05-30 21:07:28 (GMT) |
---|---|---|
committer | joye <joye> | 2014-05-30 21:07:28 (GMT) |
commit | 9c010915d7554efbab609e106ee67d37837111dd (patch) | |
tree | d612fe98f5428a75c2e492a470ebb862fec8ecb6 /src | |
parent | 94a928c01819a3509868f5f8b3b1f7aef91d5e42 (diff) | |
download | blt-9c010915d7554efbab609e106ee67d37837111dd.zip blt-9c010915d7554efbab609e106ee67d37837111dd.tar.gz blt-9c010915d7554efbab609e106ee67d37837111dd.tar.bz2 |
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r-- | src/bltGrAxis.C | 17 | ||||
-rw-r--r-- | src/bltGrAxis.h | 4 | ||||
-rw-r--r-- | src/bltGrElemBar.C | 14 | ||||
-rw-r--r-- | src/bltGrElemLine.C | 12 | ||||
-rw-r--r-- | src/bltGrMarker.h | 2 | ||||
-rw-r--r-- | src/bltGrMarkerLine.C | 6 | ||||
-rw-r--r-- | src/bltGrMarkerLine.h | 2 | ||||
-rw-r--r-- | src/bltGrMarkerPolygon.C | 12 | ||||
-rw-r--r-- | src/bltGrMarkerPolygon.h | 2 | ||||
-rw-r--r-- | src/bltGrMarkerText.C | 2 | ||||
-rw-r--r-- | src/bltGrMarkerText.h | 2 | ||||
-rw-r--r-- | src/bltGrMisc.C | 21 | ||||
-rw-r--r-- | src/bltGrMisc.h | 2 | ||||
-rw-r--r-- | src/bltGrPSOutput.C | 11 | ||||
-rw-r--r-- | src/bltGraph.C | 42 | ||||
-rw-r--r-- | src/bltGraph.h | 3 |
16 files changed, 81 insertions, 73 deletions
diff --git a/src/bltGrAxis.C b/src/bltGrAxis.C index 93f26b8..80caa0d 100644 --- a/src/bltGrAxis.C +++ b/src/bltGrAxis.C @@ -603,8 +603,7 @@ void Axis::draw(Drawable drawable) if ((nSegments_ > 0) && (ops->lineWidth > 0)) { GC gc = active_ ? activeTickGC_ : tickGC_; - Blt_Draw2DSegments(graphPtr_->display_, drawable, gc, segments_, - nSegments_); + graphPtr_->drawSegments(drawable, gc, segments_, nSegments_); } } @@ -615,12 +614,12 @@ void Axis::drawGrids(Drawable drawable) if (ops->hide || !ops->showGrid || !use_) return; - Blt_Draw2DSegments(graphPtr_->display_, drawable, ops->major.gc, - ops->major.segments, ops->major.nUsed); + graphPtr_->drawSegments(drawable, ops->major.gc, + ops->major.segments, ops->major.nUsed); if (ops->showGridMinor) - Blt_Draw2DSegments(graphPtr_->display_, drawable, ops->minor.gc, - ops->minor.segments, ops->minor.nUsed); + graphPtr_->drawSegments(drawable, ops->minor.gc, + ops->minor.segments, ops->minor.nUsed); } void Axis::drawLimits(Drawable drawable) @@ -1715,7 +1714,7 @@ void Axis::print(Blt_Ps ps) if ((nSegments_ > 0) && (ops->lineWidth > 0)) { Blt_Ps_XSetLineAttributes(ps, ops->tickColor, ops->lineWidth, (Blt_Dashes *)NULL, CapButt, JoinMiter); - Blt_Ps_Draw2DSegments(ps, segments_, nSegments_); + graphPtr_->printSegments(ps, segments_, nSegments_); } } @@ -1730,13 +1729,13 @@ void Axis::printGrids(Blt_Ps ps) Blt_Ps_XSetLineAttributes(ps, ops->major.color, ops->major.lineWidth, &ops->major.dashes, CapButt, JoinMiter); Blt_Ps_Format(ps, "%% Axis %s: major grid line segments\n", name_); - Blt_Ps_Draw2DSegments(ps, ops->major.segments, ops->major.nUsed); + graphPtr_->printSegments(ps, ops->major.segments, ops->major.nUsed); if (ops->showGridMinor) { Blt_Ps_XSetLineAttributes(ps, ops->minor.color, ops->minor.lineWidth, &ops->minor.dashes, CapButt, JoinMiter); Blt_Ps_Format(ps, "%% Axis %s: minor grid line segments\n", name_); - Blt_Ps_Draw2DSegments(ps, ops->minor.segments, ops->minor.nUsed); + graphPtr_->printSegments(ps, ops->minor.segments, ops->minor.nUsed); } } diff --git a/src/bltGrAxis.h b/src/bltGrAxis.h index 7b2cca0..e8c3371 100644 --- a/src/bltGrAxis.h +++ b/src/bltGrAxis.h @@ -30,8 +30,8 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef ___Blt_GrAxis_h__ -#define ___Blt_GrAxis_h__ +#ifndef ___BltGrAxis_h__ +#define ___BltGrAxis_h__ #include <tk.h> diff --git a/src/bltGrElemBar.C b/src/bltGrElemBar.C index 3b4eb1a..490305f 100644 --- a/src/bltGrElemBar.C +++ b/src/bltGrElemBar.C @@ -680,12 +680,12 @@ void BarElement::draw(Drawable drawable) drawSegments(drawable, penPtr, stylePtr->bars, stylePtr->nBars); if ((stylePtr->xeb.length > 0) && (pops->errorBarShow & SHOW_X)) - Blt_Draw2DSegments(graphPtr_->display_, drawable, penPtr->errorBarGC_, - stylePtr->xeb.segments, stylePtr->xeb.length); + graphPtr_->drawSegments(drawable, penPtr->errorBarGC_, + stylePtr->xeb.segments, stylePtr->xeb.length); if ((stylePtr->yeb.length > 0) && (pops->errorBarShow & SHOW_Y)) - Blt_Draw2DSegments(graphPtr_->display_, drawable, penPtr->errorBarGC_, - stylePtr->yeb.segments, stylePtr->yeb.length); + graphPtr_->drawSegments(drawable, penPtr->errorBarGC_, + stylePtr->yeb.segments, stylePtr->yeb.length); if (pops->valueShow != SHOW_NONE) drawValues(drawable, penPtr, stylePtr->bars, stylePtr->nBars, @@ -771,14 +771,14 @@ void BarElement::print(Blt_Ps ps) if ((stylePtr->xeb.length > 0) && (pops->errorBarShow & SHOW_X)) { Blt_Ps_XSetLineAttributes(ps, colorPtr, pops->errorBarLineWidth, NULL, CapButt, JoinMiter); - Blt_Ps_Draw2DSegments(ps, stylePtr->xeb.segments, - stylePtr->xeb.length); + graphPtr_->printSegments(ps, stylePtr->xeb.segments, + stylePtr->xeb.length); } if ((stylePtr->yeb.length > 0) && (pops->errorBarShow & SHOW_Y)) { Blt_Ps_XSetLineAttributes(ps, colorPtr, pops->errorBarLineWidth, NULL, CapButt, JoinMiter); - Blt_Ps_Draw2DSegments(ps, stylePtr->yeb.segments, + graphPtr_->printSegments(ps, stylePtr->yeb.segments, stylePtr->yeb.length); } diff --git a/src/bltGrElemLine.C b/src/bltGrElemLine.C index 8490a7d..ba0bd68 100644 --- a/src/bltGrElemLine.C +++ b/src/bltGrElemLine.C @@ -569,12 +569,12 @@ void LineElement::draw(Drawable drawable) LinePenOptions* penOps = (LinePenOptions*)penPtr->ops(); if ((stylePtr->xeb.length > 0) && (penOps->errorBarShow & SHOW_X)) - Blt_Draw2DSegments(graphPtr_->display_, drawable, penPtr->errorBarGC_, - stylePtr->xeb.segments, stylePtr->xeb.length); + graphPtr_->drawSegments(drawable, penPtr->errorBarGC_, + stylePtr->xeb.segments, stylePtr->xeb.length); if ((stylePtr->yeb.length > 0) && (penOps->errorBarShow & SHOW_Y)) - Blt_Draw2DSegments(graphPtr_->display_, drawable, penPtr->errorBarGC_, - stylePtr->yeb.segments, stylePtr->yeb.length); + graphPtr_->drawSegments(drawable, penPtr->errorBarGC_, + stylePtr->yeb.segments, stylePtr->yeb.length); if ((stylePtr->symbolPts.length > 0) && (penOps->symbol.type != SYMBOL_NONE)) @@ -699,13 +699,13 @@ void LineElement::print(Blt_Ps ps) if ((stylePtr->xeb.length > 0) && (penOps->errorBarShow & SHOW_X)) { Blt_Ps_XSetLineAttributes(ps, colorPtr, penOps->errorBarLineWidth, NULL, CapButt, JoinMiter); - Blt_Ps_Draw2DSegments(ps, stylePtr->xeb.segments, + graphPtr_->printSegments(ps, stylePtr->xeb.segments, stylePtr->xeb.length); } if ((stylePtr->yeb.length > 0) && (penOps->errorBarShow & SHOW_Y)) { Blt_Ps_XSetLineAttributes(ps, colorPtr, penOps->errorBarLineWidth, NULL, CapButt, JoinMiter); - Blt_Ps_Draw2DSegments(ps, stylePtr->yeb.segments, + graphPtr_->printSegments(ps, stylePtr->yeb.segments, stylePtr->yeb.length); } if ((stylePtr->symbolPts.length > 0) && diff --git a/src/bltGrMarker.h b/src/bltGrMarker.h index ddd2401..f71cd9b 100644 --- a/src/bltGrMarker.h +++ b/src/bltGrMarker.h @@ -93,7 +93,7 @@ namespace Blt { virtual void map() =0; virtual int pointIn(Point2d*) =0; virtual int regionIn(Region2d*, int) =0; - virtual void postscript(Blt_Ps) =0; + virtual void print(Blt_Ps) =0; virtual ClassId classId() =0; virtual const char* className() =0; diff --git a/src/bltGrMarkerLine.C b/src/bltGrMarkerLine.C index 1baf413..995e165 100644 --- a/src/bltGrMarkerLine.C +++ b/src/bltGrMarkerLine.C @@ -170,7 +170,7 @@ int LineMarker::configure() void LineMarker::draw(Drawable drawable) { if (nSegments_ > 0) - Blt_Draw2DSegments(graphPtr_->display_, drawable, gc_, segments_,nSegments_); + graphPtr_->drawSegments(drawable, gc_, segments_, nSegments_); } void LineMarker::map() @@ -303,7 +303,7 @@ int LineMarker::regionIn(Region2d *extsPtr, int enclosed) } } -void LineMarker::postscript(Blt_Ps ps) +void LineMarker::print(Blt_Ps ps) { LineMarkerOptions* ops = (LineMarkerOptions*)ops_; @@ -320,7 +320,7 @@ void LineMarker::postscript(Blt_Ps ps) else Blt_Ps_Append(ps, "/DashesProc {} def\n"); - Blt_Ps_Draw2DSegments(ps, segments_, nSegments_); + graphPtr_->printSegments(ps, segments_, nSegments_); } } diff --git a/src/bltGrMarkerLine.h b/src/bltGrMarkerLine.h index 32c4260..3cbab40 100644 --- a/src/bltGrMarkerLine.h +++ b/src/bltGrMarkerLine.h @@ -67,7 +67,7 @@ namespace Blt { void map(); int pointIn(Point2d*); int regionIn(Region2d*, int); - void postscript(Blt_Ps); + void print(Blt_Ps); int pointInSegments(Point2d *samplePtr, Segment2d *segments, int nSegments, double halo); diff --git a/src/bltGrMarkerPolygon.C b/src/bltGrMarkerPolygon.C index 2d175a7..de839f7 100644 --- a/src/bltGrMarkerPolygon.C +++ b/src/bltGrMarkerPolygon.C @@ -222,8 +222,7 @@ void PolygonMarker::draw(Drawable drawable) // outline if ((nOutlinePts_ > 0) && (ops->lineWidth > 0) && (ops->outline)) { - Blt_Draw2DSegments(graphPtr_->display_, drawable, outlineGC_, - outlinePts_, nOutlinePts_); + graphPtr_->drawSegments(drawable, outlineGC_, outlinePts_, nOutlinePts_); } } @@ -331,7 +330,7 @@ int PolygonMarker::regionIn(Region2d *extsPtr, int enclosed) return 0; } -void PolygonMarker::postscript(Blt_Ps ps) +void PolygonMarker::print(Blt_Ps ps) { PolygonMarkerOptions* ops = (PolygonMarkerOptions*)ops_; @@ -356,10 +355,11 @@ void PolygonMarker::postscript(Blt_Ps ps) Blt_Ps_Append(ps, " "); Blt_Ps_XSetDashes(ps, (Blt_Dashes *)NULL); Blt_Ps_Append(ps, "stroke\n grestore\n} def\n"); - } else { - Blt_Ps_Append(ps, "/DashesProc {} def\n"); } - Blt_Ps_Draw2DSegments(ps, outlinePts_, nOutlinePts_); + else + Blt_Ps_Append(ps, "/DashesProc {} def\n"); + + graphPtr_->printSegments(ps, outlinePts_, nOutlinePts_); } } diff --git a/src/bltGrMarkerPolygon.h b/src/bltGrMarkerPolygon.h index fee0573..2cae92b 100644 --- a/src/bltGrMarkerPolygon.h +++ b/src/bltGrMarkerPolygon.h @@ -73,7 +73,7 @@ namespace Blt { void map(); int pointIn(Point2d*); int regionIn(Region2d*, int); - void postscript(Blt_Ps); + void print(Blt_Ps); public: PolygonMarker(Graph*, const char*, Tcl_HashEntry*); diff --git a/src/bltGrMarkerText.C b/src/bltGrMarkerText.C index 93d3a96..75a6047 100644 --- a/src/bltGrMarkerText.C +++ b/src/bltGrMarkerText.C @@ -255,7 +255,7 @@ int TextMarker::regionIn(Region2d *extsPtr, int enclosed) ((anchorPt_.y + height_) <= extsPtr->top)); } -void TextMarker::postscript(Blt_Ps ps) +void TextMarker::print(Blt_Ps ps) { TextMarkerOptions* ops = (TextMarkerOptions*)ops_; diff --git a/src/bltGrMarkerText.h b/src/bltGrMarkerText.h index e2a3536..a1409de 100644 --- a/src/bltGrMarkerText.h +++ b/src/bltGrMarkerText.h @@ -68,7 +68,7 @@ namespace Blt { void map(); int pointIn(Point2d*); int regionIn(Region2d*, int); - void postscript(Blt_Ps); + void print(Blt_Ps); public: TextMarker(Graph*, const char*, Tcl_HashEntry*); diff --git a/src/bltGrMisc.C b/src/bltGrMisc.C index 6125012..b04c8c6 100644 --- a/src/bltGrMisc.C +++ b/src/bltGrMisc.C @@ -390,27 +390,6 @@ void Blt_SetDashes(Display *display, GC gc, Blt_Dashes *dashesPtr) (int)strlen((char*)dashesPtr->values)); } -void Blt_Draw2DSegments(Display *display, Drawable drawable, GC gc, - Segment2d *segments, int nSegments) -{ - Segment2d *sp, *send; - - XSegment* xsegments = (XSegment*)malloc(nSegments * sizeof(XSegment)); - if (xsegments == NULL) - return; - - XSegment* dp = xsegments; - for (sp = segments, send = sp + nSegments; sp < send; sp++) { - dp->x1 = (short int)sp->p.x; - dp->y1 = (short int)sp->p.y; - dp->x2 = (short int)sp->q.x; - dp->y2 = (short int)sp->q.y; - dp++; - } - XDrawSegments(display, drawable, gc, xsegments, nSegments); - free(xsegments); -} - long Blt_MaxRequestSize(Display *display, size_t elemSize) { static long maxSizeBytes = 0L; diff --git a/src/bltGrMisc.h b/src/bltGrMisc.h index c2ba6df..d666df5 100644 --- a/src/bltGrMisc.h +++ b/src/bltGrMisc.h @@ -98,8 +98,6 @@ extern int Blt_GetXY(Tcl_Interp* interp, Tk_Window tkwin, const char *string, int *xPtr, int *yPtr); extern int Blt_PolyRectClip(Region2d *extsPtr, Point2d *inputPts, int nInputPts, Point2d *outputPts); -extern void Blt_Draw2DSegments(Display *display, Drawable drawable, GC gc, - Segment2d *segments, int nSegments); extern int Blt_LineRectClip(Region2d *regionPtr, Point2d *p, Point2d *q); extern GC Blt_GetPrivateGC(Tk_Window tkwin, unsigned long gcMask, XGCValues *valuePtr); diff --git a/src/bltGrPSOutput.C b/src/bltGrPSOutput.C index 4aca636..aff7749 100644 --- a/src/bltGrPSOutput.C +++ b/src/bltGrPSOutput.C @@ -779,15 +779,4 @@ void Blt_Ps_DrawBitmap( Blt_Ps_Append(ps, " } imagemask\n grestore\n"); } -void Blt_Ps_Draw2DSegments(Blt_Ps ps, Segment2d *segments, int nSegments) -{ - Segment2d *sp, *send; - - Blt_Ps_Append(ps, "newpath\n"); - for (sp = segments, send = sp + nSegments; sp < send; sp++) { - Blt_Ps_Format(ps, " %g %g moveto %g %g lineto\n", - sp->p.x, sp->p.y, sp->q.x, sp->q.y); - Blt_Ps_Append(ps, "DashesProc stroke\n"); - } -} diff --git a/src/bltGraph.C b/src/bltGraph.C index 5e0d5e7..a2f289d 100644 --- a/src/bltGraph.C +++ b/src/bltGraph.C @@ -821,7 +821,7 @@ void Graph::printMarkers(Blt_Ps ps, int under) Blt_Ps_VarAppend(ps, "\n% Marker \"", markerPtr->name_, "\" is a ", markerPtr->className(), ".\n", (char*)NULL); - markerPtr->postscript(ps); + markerPtr->print(ps); } } @@ -1259,6 +1259,8 @@ Axis* Graph::nearestAxis(int x, int y) return NULL; } +// Bind + const char** Graph::getTags(ClientData object, ClassId classId, int* num) { const char** tags =NULL; @@ -1396,3 +1398,41 @@ ClientData Graph::pickEntry(int xx, int yy, ClassId* classIdPtr) return NULL; } +// Graphics + +void Graph::drawSegments(Drawable drawable, GC gc, + Segment2d* segments, int nSegments) +{ + Segment2d* sp; + Segment2d* send; + + XSegment* xsegments = new XSegment[nSegments]; + if (xsegments == NULL) + return; + + XSegment* dp = xsegments; + for (sp = segments, send = sp + nSegments; sp < send; sp++) { + dp->x1 = (short int)sp->p.x; + dp->y1 = (short int)sp->p.y; + dp->x2 = (short int)sp->q.x; + dp->y2 = (short int)sp->q.y; + dp++; + } + + XDrawSegments(display_, drawable, gc, xsegments, nSegments); + delete [] xsegments; +} + +void Graph::printSegments(Blt_Ps ps, Segment2d* segments, int nSegments) +{ + Segment2d* sp; + Segment2d* send; + + Blt_Ps_Append(ps, "newpath\n"); + for (sp = segments, send = sp + nSegments; sp < send; sp++) { + Blt_Ps_Format(ps, " %g %g moveto %g %g lineto\n", + sp->p.x, sp->p.y, sp->q.x, sp->q.y); + Blt_Ps_Append(ps, "DashesProc stroke\n"); + } +} + diff --git a/src/bltGraph.h b/src/bltGraph.h index 1ccac7b..1f233da 100644 --- a/src/bltGraph.h +++ b/src/bltGraph.h @@ -242,6 +242,9 @@ class Graph { virtual int createPen(const char*, int, Tcl_Obj* const []) =0; int getPen(Tcl_Obj*, Pen**); + void drawSegments(Drawable, GC, Segment2d*, int); + void printSegments(Blt_Ps, Segment2d*, 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); |