diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2017-05-04 19:03:43 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2017-05-04 19:03:43 (GMT) |
commit | 3a54289e2fa00adf31513f22e5b547636aa242ee (patch) | |
tree | 745a07c8e405251a8a9b0ec7a976ae1ed5208078 /tksao/frame | |
parent | 003a4df987aa6b20bc35fa5851f5b35b2b2c5721 (diff) | |
download | blt-3a54289e2fa00adf31513f22e5b547636aa242ee.zip blt-3a54289e2fa00adf31513f22e5b547636aa242ee.tar.gz blt-3a54289e2fa00adf31513f22e5b547636aa242ee.tar.bz2 |
enhanced circle/ellipse X11 render
Diffstat (limited to 'tksao/frame')
-rw-r--r-- | tksao/frame/baseellipse.C | 61 | ||||
-rw-r--r-- | tksao/frame/baseellipse.h | 13 | ||||
-rw-r--r-- | tksao/frame/circle.C | 6 | ||||
-rw-r--r-- | tksao/frame/circle.h | 4 | ||||
-rw-r--r-- | tksao/frame/ellipse.C | 6 | ||||
-rw-r--r-- | tksao/frame/ellipse.h | 4 |
6 files changed, 64 insertions, 30 deletions
diff --git a/tksao/frame/baseellipse.C b/tksao/frame/baseellipse.C index 8a7436b..f55989a 100644 --- a/tksao/frame/baseellipse.C +++ b/tksao/frame/baseellipse.C @@ -58,8 +58,10 @@ void BaseEllipse::renderX(Drawable drawable, Coord::InternalSystem sys, if (isRound && isScale && isOrient && parent->isAzElZero()) renderXCircle(drawable, sys, ang, mode); + else if (!ang && parent->isAzElZero()) + renderXEllipse(drawable, sys, ang, mode); else - renderXEllipse(drawable, sys, mode); + renderXBezier(drawable, sys, mode); } void BaseEllipse::renderXCircle(Drawable drawable, Coord::InternalSystem sys, @@ -93,18 +95,49 @@ void BaseEllipse::renderXCircle(Drawable drawable, Coord::InternalSystem sys, if (a2<=a1) a2 += 360*64; - renderXCircleDraw(drawable, lgc, st, size, a1, (a2-a1), mode); + renderXArcDraw(drawable, lgc, st, size, a1, (a2-a1), mode); } } -void BaseEllipse::renderXCircleDraw(Drawable drawable, GC lgc, Vector& st, +void BaseEllipse::renderXArcDraw(Drawable drawable, GC lgc, Vector& st, Vector& size, int a1, int aa, RenderMode mode) { XDrawArc(display, drawable, lgc, st[0], st[1], size[0], size[1], a1, aa); } -void BaseEllipse::renderXEllipse(Drawable drawable, Coord::InternalSystem sys, +void BaseEllipse::renderXEllipse(Drawable drawable, Coord::InternalSystem sys, + double ang, RenderMode mode) +{ + GC lgc = renderXGC(mode); + + // this routine is only valid for circles with equal zoom in x & y + Vector cc = parent->mapFromRef(center,sys); + + for (int i=0; i<numAnnuli_; i++) { + Vector r = annuli_[i]; + + Vector st = cc-r; + Vector size = r*2; + + // Verify size is positive + // XDrawArc is sensative to bad data, and may hang the XServer + if (!size[0] || !size[1]) + continue; + + // Must be very sure that a1<a2 + double aa1 = startAng_ + ang; + double aa2 = stopAng_ + ang; + int a1 = radToDeg(aa1)*64; + int a2 = radToDeg(aa2)*64; + if (a2<=a1) + a2 += 360*64; + + renderXArcDraw(drawable, lgc, st, size, a1, (a2-a1), mode); + } +} + +void BaseEllipse::renderXBezier(Drawable drawable, Coord::InternalSystem sys, RenderMode mode) { double a1 = startAng_; @@ -130,7 +163,7 @@ void BaseEllipse::renderXEllipse(Drawable drawable, Coord::InternalSystem sys, s2 =1; if ((s1 && !s2) || (s1 && s2)) - renderXEllipsePrep(drawable, sys, mode, a1,a2,b1,b2,r); + renderXBezierPrep(drawable, sys, mode, a1,a2,b1,b2,r); if (s1&&s2) s1=s2=0; @@ -165,7 +198,7 @@ void BaseEllipse::renderXEllipse(Drawable drawable, Coord::InternalSystem sys, } } - renderXEllipseDraw(drawable, lgc, mode); + renderXBezierDraw(drawable, lgc, mode); if (xpoint_) free(xpoint_); @@ -175,15 +208,15 @@ void BaseEllipse::renderXEllipse(Drawable drawable, Coord::InternalSystem sys, } } -void BaseEllipse::renderXEllipseDraw(Drawable drawable, GC lgc, RenderMode mode) +void BaseEllipse::renderXBezierDraw(Drawable drawable, GC lgc, RenderMode mode) { if ((properties & SOURCE) && !(properties & DASH)) XDrawLines(display, drawable, lgc, xpoint_, xpointNum_, CoordModeOrigin); else - renderXEllipseDashDraw(drawable, lgc); + renderXBezierDashDraw(drawable, lgc); } -void BaseEllipse::renderXEllipseDashDraw(Drawable drawable, GC lgc) +void BaseEllipse::renderXBezierDashDraw(Drawable drawable, GC lgc) { // crude attempt to clip unwanted drawlines // only works for SRC @@ -195,7 +228,7 @@ void BaseEllipse::renderXEllipseDashDraw(Drawable drawable, GC lgc) } } -void BaseEllipse::renderXEllipsePrep(Drawable drawable, +void BaseEllipse::renderXBezierPrep(Drawable drawable, Coord::InternalSystem sys, RenderMode mode, double a1, double a2, @@ -208,14 +241,14 @@ void BaseEllipse::renderXEllipsePrep(Drawable drawable, a2 = b2; if (a1>a2) { - renderXEllipseArc(drawable, sys, mode, b1,a2,r); - renderXEllipseArc(drawable, sys, mode, a1,b2,r); + renderXBezierArc(drawable, sys, mode, b1,a2,r); + renderXBezierArc(drawable, sys, mode, a1,b2,r); } else - renderXEllipseArc(drawable, sys, mode, a1,a2,r); + renderXBezierArc(drawable, sys, mode, a1,a2,r); } -void BaseEllipse::renderXEllipseArc(Drawable drawable, +void BaseEllipse::renderXBezierArc(Drawable drawable, Coord::InternalSystem sys, RenderMode mode, double a1, double a2, diff --git a/tksao/frame/baseellipse.h b/tksao/frame/baseellipse.h index 778e46c..dd23bf3 100644 --- a/tksao/frame/baseellipse.h +++ b/tksao/frame/baseellipse.h @@ -20,10 +20,11 @@ class BaseEllipse : public BaseMarker { void XDrawCurve(Drawable, RenderMode, Vector&, Vector&, Vector&, Vector&); void renderXCircle(Drawable, Coord::InternalSystem, double, RenderMode); - void renderXEllipse(Drawable, Coord::InternalSystem, RenderMode); - void renderXEllipsePrep(Drawable, Coord::InternalSystem, RenderMode, + void renderXEllipse(Drawable, Coord::InternalSystem, double, RenderMode); + void renderXBezier(Drawable, Coord::InternalSystem, RenderMode); + void renderXBezierPrep(Drawable, Coord::InternalSystem, RenderMode, double, double, double, double, Vector&); - void renderXEllipseArc(Drawable, Coord::InternalSystem, RenderMode, + void renderXBezierArc(Drawable, Coord::InternalSystem, RenderMode, double, double, Vector&); void renderXInclude(Drawable, Coord::InternalSystem, RenderMode); @@ -51,10 +52,10 @@ class BaseEllipse : public BaseMarker { protected: void renderX(Drawable, Coord::InternalSystem, RenderMode); - virtual void renderXCircleDraw(Drawable, GC, Vector&, Vector&, + virtual void renderXArcDraw(Drawable, GC, Vector&, Vector&, int, int, RenderMode); - virtual void renderXEllipseDraw(Drawable, GC, RenderMode); - void renderXEllipseDashDraw(Drawable, GC); + virtual void renderXBezierDraw(Drawable, GC, RenderMode); + void renderXBezierDashDraw(Drawable, GC); void renderPS(int); virtual void renderPSDraw(); diff --git a/tksao/frame/circle.C b/tksao/frame/circle.C index a4b2aca..07093c3 100644 --- a/tksao/frame/circle.C +++ b/tksao/frame/circle.C @@ -58,7 +58,7 @@ void Circle::edit(const Vector& v, int h) doCallBack(CallBack::EDITCB); } -void Circle::renderXCircleDraw(Drawable drawable, GC lgc, +void Circle::renderXArcDraw(Drawable drawable, GC lgc, Vector& st, Vector& size, int a1, int aa, RenderMode mode) { @@ -68,14 +68,14 @@ void Circle::renderXCircleDraw(Drawable drawable, GC lgc, XDrawArc(display, drawable, lgc, st[0], st[1], size[0], size[1], a1, aa); } -void Circle::renderXEllipseDraw(Drawable drawable, GC lgc, RenderMode mode) +void Circle::renderXBezierDraw(Drawable drawable, GC lgc, RenderMode mode) { if (fill_ && mode == SRC) XFillPolygon(display, drawable, lgc, xpoint_, xpointNum_, Convex, CoordModeOrigin); else if ((properties & SOURCE) && !(properties & DASH)) XDrawLines(display, drawable, lgc, xpoint_, xpointNum_, CoordModeOrigin); else - renderXEllipseDashDraw(drawable, lgc); + renderXBezierDashDraw(drawable, lgc); } void Circle::renderPSDraw() diff --git a/tksao/frame/circle.h b/tksao/frame/circle.h index 9ebce28..eaeff1f 100644 --- a/tksao/frame/circle.h +++ b/tksao/frame/circle.h @@ -12,8 +12,8 @@ class Circle : public BaseEllipse { int fill_; protected: - void renderXCircleDraw(Drawable, GC, Vector&, Vector&, int, int, RenderMode); - void renderXEllipseDraw(Drawable, GC, RenderMode); + void renderXArcDraw(Drawable, GC, Vector&, Vector&, int, int, RenderMode); + void renderXBezierDraw(Drawable, GC, RenderMode); void renderPSDraw(); diff --git a/tksao/frame/ellipse.C b/tksao/frame/ellipse.C index 8d9b1af..47038f7 100644 --- a/tksao/frame/ellipse.C +++ b/tksao/frame/ellipse.C @@ -46,7 +46,7 @@ Ellipse::Ellipse(Base* p, const Vector& ctr, updateBBox(); } -void Ellipse::renderXCircleDraw(Drawable drawable, GC lgc, +void Ellipse::renderXArcDraw(Drawable drawable, GC lgc, Vector& st, Vector& size, int a1, int aa, RenderMode mode) { @@ -56,14 +56,14 @@ void Ellipse::renderXCircleDraw(Drawable drawable, GC lgc, XDrawArc(display, drawable, lgc, st[0], st[1], size[0], size[1], a1, aa); } -void Ellipse::renderXEllipseDraw(Drawable drawable, GC lgc, RenderMode mode) +void Ellipse::renderXBezierDraw(Drawable drawable, GC lgc, RenderMode mode) { if (fill_ && mode == SRC) XFillPolygon(display, drawable, lgc, xpoint_, xpointNum_, Convex, CoordModeOrigin); else if ((properties & SOURCE) && !(properties & DASH)) XDrawLines(display, drawable, lgc, xpoint_, xpointNum_, CoordModeOrigin); else - renderXEllipseDashDraw(drawable, lgc); + renderXBezierDashDraw(drawable, lgc); } void Ellipse::renderPSDraw() diff --git a/tksao/frame/ellipse.h b/tksao/frame/ellipse.h index fde2c0d..4b6c015 100644 --- a/tksao/frame/ellipse.h +++ b/tksao/frame/ellipse.h @@ -12,8 +12,8 @@ class Ellipse : public BaseEllipse { int fill_; protected: - void renderXCircleDraw(Drawable, GC, Vector&, Vector&, int, int, RenderMode); - void renderXEllipseDraw(Drawable, GC, RenderMode); + void renderXArcDraw(Drawable, GC, Vector&, Vector&, int, int, RenderMode); + void renderXBezierDraw(Drawable, GC, RenderMode); void renderPSDraw(); |