diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2017-03-19 19:59:10 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2017-03-19 19:59:10 (GMT) |
commit | c60eec16458a41c3185c09abdc6ec23174ae4859 (patch) | |
tree | 67e93353834a31e489f0edab4f5028882b39131a | |
parent | fac94d1e0c1313892a0b3578e875300139f52272 (diff) | |
download | blt-c60eec16458a41c3185c09abdc6ec23174ae4859.zip blt-c60eec16458a41c3185c09abdc6ec23174ae4859.tar.gz blt-c60eec16458a41c3185c09abdc6ec23174ae4859.tar.bz2 |
clean up macosx code supporting fill
-rw-r--r-- | tkmacosx/macosxlib.h | 10 | ||||
-rw-r--r-- | tkmacosx/macosxlib.mm | 92 | ||||
-rw-r--r-- | tkmacosx/tkmacosx.h | 10 | ||||
-rw-r--r-- | tkmacosx/tkmacosx.mm | 56 | ||||
-rw-r--r-- | tksao/frame/baseellipse.C | 88 | ||||
-rw-r--r-- | tksao/frame/baseellipse.h | 6 | ||||
-rw-r--r-- | tksao/frame/circle.C | 24 | ||||
-rw-r--r-- | tksao/frame/circle.h | 6 | ||||
-rw-r--r-- | tksao/frame/ellipse.C | 24 | ||||
-rw-r--r-- | tksao/frame/ellipse.h | 6 |
10 files changed, 145 insertions, 177 deletions
diff --git a/tkmacosx/macosxlib.h b/tkmacosx/macosxlib.h index 69e779b..73c3fa3 100644 --- a/tkmacosx/macosxlib.h +++ b/tkmacosx/macosxlib.h @@ -19,15 +19,17 @@ void macosxDash(float*,int); void macosxFont(const char*, float); void macosxClip(Vector, Vector); +void macosxNewPath(); +void macosxStroke(); +void macosxFill(); +void macosxArc(Vector, float, float, float); +void macosxCurve(Vector, Vector, Vector, Vector); + void macosxDrawText(Vector, float, const char*); void macosxDrawLine(Vector, Vector); void macosxDrawLines(Vector*, int); void macosxFillPolygon(Vector*, int); void macosxDrawArc(Vector, float, float, float); -void macosxFillArc(Vector, float, float, float); -void macosxDrawCurve(Vector, Vector, Vector, Vector); -void macosxFillCurve(Vector, Vector, Vector, Vector); - void macosxBitmapCreate(void*, int, int, const Vector&, const Vector&); diff --git a/tkmacosx/macosxlib.mm b/tkmacosx/macosxlib.mm index 454d026..0c9034d 100644 --- a/tkmacosx/macosxlib.mm +++ b/tkmacosx/macosxlib.mm @@ -71,6 +71,58 @@ void macosxClip(Vector v, Vector s) */ } +void macosxNewPath() +{ +/* + if (tkmacosx) { + tkmacosx->newpath(); + } +*/ +} + +void macosxStroke() +{ +/* + if (tkmacosx) { + tkmacosx->stroke(); + } +*/ +} + +void macosxFill() +{ +/* + if (tkmacosx) { + tkmacosx->fill(); + } +*/ +} + +void macosxArc(Vector v, float rad, float ang1, float ang2) +{ +/* + if (tkmacosx) { + Vector vv = v*tkmacosx->getCanvasToPage(); + tkmacosx->arc(vv[0], vv[1], rad, ang1, ang2); + } +*/ +} + +void macosxCurve(Vector v0, Vector t0, Vector t1, Vector v1) +{ +/* + if (tkmacosx) { + Vector vv0 = v0*tkmacosx->getCanvasToPage(); + Vector tt0 = t0*tkmacosx->getCanvasToPage(); + Vector tt1 = t1*tkmacosx->getCanvasToPage(); + Vector vv1 = v1*tkmacosx->getCanvasToPage(); + + tkmacosx->curve(vv0[0], vv0[1], tt0[0], tt0[1], + tt1[0], tt1[1], vv1[0], vv1[1]); + } +*/ +} + void macosxDrawText(Vector v, float ang, const char* text) { /* @@ -150,46 +202,6 @@ void macosxDrawArc(Vector v, float rad, float ang1, float ang2) */ } -void macosxFillArc(Vector v, float rad, float ang1, float ang2) -{ -/* - if (tkmacosx) { - Vector vv = v*tkmacosx->getCanvasToPage(); - tkmacosx->fillArc(vv[0], vv[1], rad, ang1, ang2); - } -*/ -} - -void macosxDrawCurve(Vector v0, Vector t0, Vector t1, Vector v1) -{ -/* - if (tkmacosx) { - Vector vv0 = v0*tkmacosx->getCanvasToPage(); - Vector tt0 = t0*tkmacosx->getCanvasToPage(); - Vector tt1 = t1*tkmacosx->getCanvasToPage(); - Vector vv1 = v1*tkmacosx->getCanvasToPage(); - - tkmacosx->drawCurve(vv0[0], vv0[1], tt0[0], tt0[1], - tt1[0], tt1[1], vv1[0], vv1[1]); - } -*/ -} - -void macosxFillCurve(Vector v0, Vector t0, Vector t1, Vector v1) -{ -/* - if (tkmacosx) { - Vector vv0 = v0*tkmacosx->getCanvasToPage(); - Vector tt0 = t0*tkmacosx->getCanvasToPage(); - Vector tt1 = t1*tkmacosx->getCanvasToPage(); - Vector vv1 = v1*tkmacosx->getCanvasToPage(); - - tkmacosx->fillCurve(vv0[0], vv0[1], tt0[0], tt0[1], - tt1[0], tt1[1], vv1[0], vv1[1]); - } -*/ -} - void macosxBitmapCreate(void* img, int width, int height, const Vector& v, const Vector& s) { diff --git a/tkmacosx/tkmacosx.h b/tkmacosx/tkmacosx.h index 65ae6de..83810dd 100644 --- a/tkmacosx/tkmacosx.h +++ b/tkmacosx/tkmacosx.h @@ -48,12 +48,16 @@ class TkMacosx { void font(const char*, float); void clip(float, float, float, float); + void newpath(); + void stroke(); + void fill(); + void arc(float, float, float, float, float); + void curve(float, float, float, float, float, float, float, float); + void drawText(float, float, float, const char*); void drawLines(float*, float*, int); - void drawRect(float, float, float, float); - void drawArc(float, float, float, float, float); - void drawCurve(float, float, float, float, float, float, float, float); void fillPolygon(float*, float*, int); + void drawArc(float, float, float, float, float); void bitmapCreate(void*, int, int, float, float, float, float); */ diff --git a/tkmacosx/tkmacosx.mm b/tkmacosx/tkmacosx.mm index 00b8163..f6fa8d2 100644 --- a/tkmacosx/tkmacosx.mm +++ b/tkmacosx/tkmacosx.mm @@ -735,6 +735,33 @@ void TkMacosx::clip(float x, float y, float w, float h) CGContextClip(context); } +void TkMacosx::newpath() +{ + CGContextBeginPath(context); +} + +void TkMacosx::stroke() +{ + CGContextStrokePath(context); +} + +void TkMacosx::fill() +{ + CGContextEOFillPath(context); +} + +void TkMacosx::arc(float x, float y, float rad, float ang1, float ang2) +{ + CGContextAddArc(context, x, y, rad, ang1, ang2, 0); +} + +void TkMacosx::curve(float x0, float y0, float u0, float v0, + float u1, float v1, float x1, float y1) +{ + CGContextMoveToPoint(context, x0, y0); + CGContextAddCurveToPoint(context, u0, v0, u1, v1, x1, y1); +} + void TkMacosx::drawText(float x, float y, float angle, const char* text) { CGAffineTransform mm = CGAffineTransformMakeRotation(angle); @@ -770,35 +797,6 @@ void TkMacosx::drawArc(float x, float y, float rad, float ang1, float ang2) CGContextStrokePath(context); } -void TkMacosx::fillArc(float x, float y, float rad, float ang1, float ang2) -{ - CGContextBeginPath(context); - CGContextAddArc(context, x, y, rad, ang1, ang2, 0); - CGContextEOFillPath(context); -} - -void TkMacosx::drawCurve(float x0, float y0, - float u0, float v0, - float u1, float v1, - float x1, float y1) -{ - CGContextBeginPath(context); - CGContextMoveToPoint(context, x0, y0); - CGContextAddCurveToPoint(context, u0, v0, u1, v1, x1, y1); - CGContextStrokePath(context); -} - -void TkMacosx::fillCurve(float x0, float y0, - float u0, float v0, - float u1, float v1, - float x1, float y1) -{ - CGContextBeginPath(context); - CGContextMoveToPoint(context, x0, y0); - CGContextAddCurveToPoint(context, u0, v0, u1, v1, x1, y1); - CGContextEOPath(context); -} - void TkMacosx::bitmapCreate(void* data, int width, int height, float x, float y, float w, float h) { diff --git a/tksao/frame/baseellipse.C b/tksao/frame/baseellipse.C index 6e5ce53..f80c5b0 100644 --- a/tksao/frame/baseellipse.C +++ b/tksao/frame/baseellipse.C @@ -357,6 +357,20 @@ void BaseEllipse::renderPS(int mode) { renderPSEllipse(mode); } +void BaseEllipse::renderPSDraw() +{ + ostringstream str; + str << "stroke" << endl << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); +} + +void BaseEllipse::renderPSFill() +{ + ostringstream str; + str << "fill" << endl << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); +} + void BaseEllipse::renderPSCircle(int mode) { renderPSGC(mode); @@ -365,6 +379,12 @@ void BaseEllipse::renderPSCircle(int mode) double ang = calcAngle(); for (int ii=0; ii<numAnnuli_; ii++) { + { + ostringstream str; + str << "newpath" << endl << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + } + Vector r = annuli_[ii]; Vector ur = fwdMap(r,Coord::CANVAS); @@ -382,31 +402,17 @@ void BaseEllipse::renderPSCircle(int mode) if (a2<=a1) a2 += 360; - renderPSCircleDraw(cc, l, a1, a2); - } -} - -void BaseEllipse::renderPSCircleDraw(Vector& cc, double l, float a1, float a2) -{ - ostringstream str; - str << "newpath " - << cc.TkCanvasPs(parent->canvas) << ' ' - << l << ' ' - << a1 << ' ' << a2 << ' ' - << "arc stroke" << endl << ends; - Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); -} + { + ostringstream str; + str << cc.TkCanvasPs(parent->canvas) << ' ' + << l << ' ' + << a1 << ' ' << a2 << ' ' + << "arc" << endl << ends; + Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + } -void BaseEllipse::renderPSCircleFillDraw(Vector& cc, double l, - float a1, float a2) -{ - ostringstream str; - str << "newpath " - << cc.TkCanvasPs(parent->getCanvas()) << ' ' - << l << ' ' - << a1 << ' ' << a2 << ' ' - << "arc fill" << endl << ends; - Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); + renderPSDraw(); + } } void BaseEllipse::renderPSEllipse(int mode) @@ -442,24 +448,10 @@ void BaseEllipse::renderPSEllipse(int mode) s1=s2=0; } - renderPSEllipseDraw(); + renderPSDraw(); } } -void BaseEllipse::renderPSEllipseDraw() -{ - ostringstream str; - str << "stroke" << endl << ends; - Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); -} - -void BaseEllipse::renderPSEllipseFillDraw() -{ - ostringstream str; - str << "fill" << endl << ends; - Tcl_AppendResult(parent->interp, str.str().c_str(), NULL); -} - void BaseEllipse::renderPSEllipsePrep(double a1, double a2, double b1, double b2, Vector& rr) @@ -560,6 +552,8 @@ void BaseEllipse::renderMACOSXCircle() double ang = calcAngle(); for (int ii=0; ii<numAnnuli_; ii++) { + macosxNewPath(); + Vector r = annuli_[ii]; Vector ur = fwdMap(r,Coord::CANVAS); @@ -574,14 +568,15 @@ void BaseEllipse::renderMACOSXCircle() if (a2<=a1) a2 += M_TWOPI; - renderMACOSXCircleDraw(cc, l, a1, a2); + macosxArc(cc, l, a1, a2); + + renderMACOSXDraw(); } } -void BaseEllipse::renderMACOSXCircleDraw(Vector& cc, double l, - float a1, float a2) +void BaseEllipse::renderMACOSXDraw() { - macosxDrawArc(cc, l, a1, a2); + macosxStroke(); } void BaseEllipse::renderMACOSXEllipse() @@ -614,16 +609,11 @@ void BaseEllipse::renderMACOSXEllipse() if (s1&&s2) s1=s2=0; - renderMACOSXEllipseDraw(); + renderMACOSXDraw(); } } } -void BaseEllipse::renderMACOSXEllipseDraw() -{ - macosxStroke(); -} - void BaseEllipse::renderMACOSXEllipsePrep(double a1, double a2, double b1, double b2, Vector& rr) diff --git a/tksao/frame/baseellipse.h b/tksao/frame/baseellipse.h index 6d525f4..a7c88b2 100644 --- a/tksao/frame/baseellipse.h +++ b/tksao/frame/baseellipse.h @@ -56,10 +56,8 @@ class BaseEllipse : public BaseMarker { void renderXEllipseDashDraw(Drawable, GC); void renderPS(int); - virtual void renderPSCircleDraw(Vector& cc, double l, float a1, float a2); - void renderPSCircleFillDraw(Vector& cc, double l, float a1, float a2); - virtual void renderPSEllipseDraw(); - void renderPSEllipseFillDraw(); + virtual void renderPSDraw(); + void renderPSFill(); #ifdef MAC_OSX_TK void renderMACOSX(); diff --git a/tksao/frame/circle.C b/tksao/frame/circle.C index 02cfe40..4b9dad2 100644 --- a/tksao/frame/circle.C +++ b/tksao/frame/circle.C @@ -78,32 +78,16 @@ void Circle::renderXEllipseDraw(Drawable drawable, GC lgc) renderXEllipseDashDraw(drawable, lgc); } -void Circle::renderPSCircleDraw(Vector& cc, double l, float a1, float a2) +void Circle::renderPSDraw() { if (fill_) - BaseEllipse::renderPSCircleFillDraw(cc, l, a1, a2); + BaseEllipse::renderPSFill(); else - BaseEllipse::renderPSCircleDraw(cc, l, a1, a2); -} - -void Circle::renderPSEllipseDraw() -{ - if (fill_) - BaseEllipse::renderPSEllipseFillDraw(); - else - BaseEllipse::renderPSEllipseDraw(); + BaseEllipse::renderPSDraw(); } #ifdef MAC_OSX_TK -void Circle::renderMACOSXCircleDraw(Vector& cc, double l, float a1, float a2) -{ - if (fill_) - macosxFillArc(cc, l, a1, a2); - else - macosxDrawArc(cc, l, a1, a2); -} - -void Circle::renderMACOSXEllipseDraw() +void Circle::renderMACOSXDraw() { if (fill_) macosxFill(); diff --git a/tksao/frame/circle.h b/tksao/frame/circle.h index c6e6bb6..eaec029 100644 --- a/tksao/frame/circle.h +++ b/tksao/frame/circle.h @@ -15,12 +15,10 @@ class Circle : public BaseEllipse { void renderXCircleDraw(Drawable, GC, Vector&, Vector&, int, int); void renderXEllipseDraw(Drawable, GC); - void renderPSCircleDraw(Vector& cc, double l, float a1, float a2); - void renderPSEllipseDraw(); + void renderPSDraw(); #ifdef MAC_OSX_TK - void renderMACOSXCircleDraw(Vector&, double, float, float); - void renderMACOSXEllipseDraw(); + void renderMACOSXDraw(); #endif #ifdef __WIN32 diff --git a/tksao/frame/ellipse.C b/tksao/frame/ellipse.C index 1c887fc..34069a4 100644 --- a/tksao/frame/ellipse.C +++ b/tksao/frame/ellipse.C @@ -66,32 +66,16 @@ void Ellipse::renderXEllipseDraw(Drawable drawable, GC lgc) renderXEllipseDashDraw(drawable, lgc); } -void Ellipse::renderPSCircleDraw(Vector& cc, double l, float a1, float a2) +void Ellipse::renderPSDraw() { if (fill_) - BaseEllipse::renderPSCircleFillDraw(cc, l, a1, a2); + BaseEllipse::renderPSFill(); else - BaseEllipse::renderPSCircleDraw(cc, l, a1, a2); -} - -void Ellipse::renderPSEllipseDraw() -{ - if (fill_) - BaseEllipse::renderPSEllipseFillDraw(); - else - BaseEllipse::renderPSEllipseDraw(); + BaseEllipse::renderPSDraw(); } #ifdef MAC_OSX_TK -void Ellipse::renderMACOSXCircleDraw(Vector& cc, double l, float a1, float a2) -{ - if (fill_) - macosxFillArc(cc, l, a1, a2); - else - macosxDrawArc(cc, l, a1, a2); -} - -void Ellipse::renderMACOSXEllipseDraw() +void Ellipse::renderMACOSXDraw() { if (fill_) macosxFill(); diff --git a/tksao/frame/ellipse.h b/tksao/frame/ellipse.h index 44cbdec..c40a32f 100644 --- a/tksao/frame/ellipse.h +++ b/tksao/frame/ellipse.h @@ -15,12 +15,10 @@ class Ellipse : public BaseEllipse { void renderXCircleDraw(Drawable, GC, Vector&, Vector&, int, int); void renderXEllipseDraw(Drawable, GC); - void renderPSCircleDraw(Vector& cc, double l, float a1, float a2); - void renderPSEllipseDraw(); + void renderPSDraw(); #ifdef MAC_OSX_TK - void renderMACOSXCircleDraw(Vector&, double, float, float); - void renderMACOSXEllipseDraw(); + void renderMACOSXDraw(); #endif #ifdef __WIN32 |