summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2017-03-12 19:42:51 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2017-03-12 19:42:51 (GMT)
commit91d550b39033a5527170f822b7bb01611b0179be (patch)
treefd2de610874d5a9796983d4055543b142dfd83c5
parenteef1b4e01cc3c5307188e1497e6b095081eef378 (diff)
downloadblt-91d550b39033a5527170f822b7bb01611b0179be.zip
blt-91d550b39033a5527170f822b7bb01611b0179be.tar.gz
blt-91d550b39033a5527170f822b7bb01611b0179be.tar.bz2
add fill option circle, box
-rw-r--r--tksao/frame/basebox.C40
-rw-r--r--tksao/frame/basebox.h3
-rw-r--r--tksao/frame/baseellipse.C19
-rw-r--r--tksao/frame/baseellipse.h1
-rw-r--r--tksao/frame/box.C27
-rw-r--r--tksao/frame/box.h2
-rw-r--r--tksao/frame/circle.C36
-rw-r--r--tksao/frame/circle.h1
8 files changed, 109 insertions, 20 deletions
diff --git a/tksao/frame/basebox.C b/tksao/frame/basebox.C
index 6fb3b8b..b7edb22 100644
--- a/tksao/frame/basebox.C
+++ b/tksao/frame/basebox.C
@@ -37,7 +37,8 @@ BaseBox::~BaseBox()
deleteVertices();
}
-void BaseBox::renderX(Drawable drawable, Coord::InternalSystem sys, RenderMode mode)
+void BaseBox::renderX(Drawable drawable, Coord::InternalSystem sys,
+ RenderMode mode)
{
GC lgc = renderXGC(mode);
@@ -49,33 +50,42 @@ void BaseBox::renderX(Drawable drawable, Coord::InternalSystem sys, RenderMode m
pp[jj].x = (short)v[0];
pp[jj].y = (short)v[1];
}
- XDrawLines(display, drawable, lgc, pp, numPoints_, CoordModeOrigin);
+ renderXDraw(drawable, lgc, pp);
delete [] pp;
}
deleteVertices();
}
+void BaseBox::renderXDraw(Drawable drawable, GC lgc, XPoint* pp)
+{
+ XDrawLines(display, drawable, lgc, pp, numPoints_, CoordModeOrigin);
+}
+
void BaseBox::renderPS(int mode)
{
renderPSGC(mode);
newVertices();
- for (int ii=0; ii<numAnnuli_; ii++) {
- ostringstream str;
- for (int jj=0; jj<numPoints_; jj++) {
- Vector v = parent->mapFromRef(vertices_[ii][jj],Coord::CANVAS);
- if (jj==0)
- str << "newpath "
- << v.TkCanvasPs(parent->canvas) << " moveto" << endl;
- else
- str << v.TkCanvasPs(parent->canvas) << " lineto" << endl;
- }
- str << "stroke" << endl << ends;
- Tcl_AppendResult(parent->interp, str.str().c_str(), NULL);
- }
+ for (int ii=0; ii<numAnnuli_; ii++)
+ renderPSDraw(ii);
deleteVertices();
}
+void BaseBox::renderPSDraw(int ii)
+{
+ ostringstream str;
+ for (int jj=0; jj<numPoints_; jj++) {
+ Vector v = parent->mapFromRef(vertices_[ii][jj],Coord::CANVAS);
+ if (jj==0)
+ str << "newpath "
+ << v.TkCanvasPs(parent->canvas) << " moveto" << endl;
+ else
+ str << v.TkCanvasPs(parent->canvas) << " lineto" << endl;
+ }
+ str << "stroke" << endl << ends;
+ Tcl_AppendResult(parent->interp, str.str().c_str(), NULL);
+}
+
#ifdef MAC_OSX_TK
void BaseBox::renderMACOSX()
{
diff --git a/tksao/frame/basebox.h b/tksao/frame/basebox.h
index f8ffd43..b3919f9 100644
--- a/tksao/frame/basebox.h
+++ b/tksao/frame/basebox.h
@@ -30,7 +30,10 @@ protected:
Vector intersect(Vector, double);
void renderX(Drawable, Coord::InternalSystem, RenderMode);
+ virtual void renderXDraw(Drawable drawable, GC lgc, XPoint* pp);
void renderPS(int);
+ virtual void renderPSDraw(int);
+
#ifdef MAC_OSX_TK
void renderMACOSX();
#endif
diff --git a/tksao/frame/baseellipse.C b/tksao/frame/baseellipse.C
index 6b9a2a5..3d1897d 100644
--- a/tksao/frame/baseellipse.C
+++ b/tksao/frame/baseellipse.C
@@ -119,7 +119,8 @@ void BaseEllipse::renderXEllipseCurve(Drawable drawable,
}
}
-void BaseEllipse::renderXEllipsePrep(Drawable drawable, Coord::InternalSystem sys,
+void BaseEllipse::renderXEllipsePrep(Drawable drawable,
+ Coord::InternalSystem sys,
RenderMode mode,
double a1, double a2,
double b1, double b2,
@@ -138,9 +139,11 @@ void BaseEllipse::renderXEllipsePrep(Drawable drawable, Coord::InternalSystem sy
renderXEllipseArc(drawable, sys, mode, a1,a2,r);
}
-void BaseEllipse::renderXEllipseArc(Drawable drawable, Coord::InternalSystem sys,
+void BaseEllipse::renderXEllipseArc(Drawable drawable,
+ Coord::InternalSystem sys,
RenderMode mode,
- double a1, double a2, Vector& rr)
+ double a1, double a2,
+ Vector& rr)
{
// don't render if zero angle
if (a1==a2)
@@ -170,7 +173,8 @@ void BaseEllipse::renderXEllipseArc(Drawable drawable, Coord::InternalSystem sys
XDrawCurve(drawable, mode, tt0, xx1, xx2, tt1);
}
-void BaseEllipse::renderXInclude(Drawable drawable, Coord::InternalSystem sys,
+void BaseEllipse::renderXInclude(Drawable drawable,
+ Coord::InternalSystem sys,
RenderMode mode)
{
if (!(properties & INCLUDE)) {
@@ -297,7 +301,6 @@ void BaseEllipse::renderPSEllipsePrep(double a1, double a2,
}
void BaseEllipse::renderPSEllipseArc(double a1, double a2, Vector& rr)
-
{
// don't render zero length arcs
if (a1 == a2)
@@ -323,6 +326,12 @@ void BaseEllipse::renderPSEllipseArc(double a1, double a2, Vector& rr)
Vector xx2 = fwdMap(x2*FlipY(),Coord::CANVAS);
Vector tt1 = fwdMap(t1*FlipY(),Coord::CANVAS);
+ renderPSEllipseArcDraw(tt0, xx1, xx2, tt1);
+}
+
+void BaseEllipse::renderPSEllipseArcDraw(Vector& tt0, Vector& xx1,
+ Vector& xx2, Vector& tt1)
+{
ostringstream str;
str << "newpath "
<< tt0.TkCanvasPs(parent->canvas) << ' '
diff --git a/tksao/frame/baseellipse.h b/tksao/frame/baseellipse.h
index 30a59d3..990b3aa 100644
--- a/tksao/frame/baseellipse.h
+++ b/tksao/frame/baseellipse.h
@@ -47,6 +47,7 @@ class BaseEllipse : public BaseMarker {
virtual void renderXCircleDraw(Drawable, GC, Vector&, Vector&, int, int);
void renderPS(int);
virtual void renderPSCircleDraw(Vector& cc, double l, float a1, float a2);
+ virtual void renderPSEllipseArcDraw(Vector&, Vector&, Vector&, Vector&);
#ifdef MAC_OSX_TK
void renderMACOSX();
diff --git a/tksao/frame/box.C b/tksao/frame/box.C
index e6362b7..a6ca971 100644
--- a/tksao/frame/box.C
+++ b/tksao/frame/box.C
@@ -42,6 +42,33 @@ Box::Box(Base* p, const Vector& ctr,
updateBBox();
}
+void Box::renderXDraw(Drawable drawable, GC lgc, XPoint* pp)
+{
+ if (fill_)
+ XFillPolygon(display, drawable, lgc, pp, numPoints_, Convex, CoordModeOrigin);
+ else
+ XDrawLines(display, drawable, lgc, pp, numPoints_, CoordModeOrigin);
+}
+
+void Box::renderPSDraw(int ii)
+{
+ ostringstream str;
+ for (int jj=0; jj<numPoints_; jj++) {
+ Vector v = parent->mapFromRef(vertices_[ii][jj],Coord::CANVAS);
+ if (jj==0)
+ str << "newpath "
+ << v.TkCanvasPs(parent->canvas) << " moveto" << endl;
+ else
+ str << v.TkCanvasPs(parent->canvas) << " lineto" << endl;
+ }
+ if (fill_)
+ str << "fill" << endl << ends;
+ else
+ str << "stroke" << endl << ends;
+
+ Tcl_AppendResult(parent->interp, str.str().c_str(), NULL);
+}
+
void Box::editBegin(int h)
{
switch (h) {
diff --git a/tksao/frame/box.h b/tksao/frame/box.h
index 1c9423f..ba7460e 100644
--- a/tksao/frame/box.h
+++ b/tksao/frame/box.h
@@ -11,6 +11,8 @@
class Box : public BaseBox, public BaseFill {
protected:
void listNonCel(FitsImage*, ostream&, Coord::CoordSystem);
+ void renderXDraw(Drawable drawable, GC lgc, XPoint* pp);
+ void renderPSDraw(int);
public:
Box(Base* p, const Vector& ctr, const Vector& seg, double ang, int fill);
diff --git a/tksao/frame/circle.C b/tksao/frame/circle.C
index ddac80a..02c0927 100644
--- a/tksao/frame/circle.C
+++ b/tksao/frame/circle.C
@@ -83,6 +83,42 @@ void Circle::renderPSCircleDraw(Vector& cc, double l, float a1, float a2)
Tcl_AppendResult(parent->interp, str.str().c_str(), NULL);
}
+void Circle::renderPSEllipseArcDraw(Vector& tt0, Vector& xx1,
+ Vector& xx2, Vector& tt1)
+{
+ ostringstream str;
+ if (fill_) {
+ Vector cc = parent->mapFromRef(center,Coord::CANVAS);
+
+ str << "newpath "
+ << tt0.TkCanvasPs(parent->canvas) << ' '
+ << "moveto "
+ << xx1.TkCanvasPs(parent->canvas) << ' '
+ << xx2.TkCanvasPs(parent->canvas) << ' '
+ << tt1.TkCanvasPs(parent->canvas) << ' '
+ << "curveto fill" << endl
+ << "newpath "
+ << cc.TkCanvasPs(parent->canvas) << ' '
+ << "moveto "
+ << tt0.TkCanvasPs(parent->canvas) << ' '
+ << "lineto "
+ << tt1.TkCanvasPs(parent->canvas) << ' '
+ << "lineto closepath gsave" << endl
+ << "1 setlinejoin .5 setlinewidth stroke" << endl
+ << "grestore fill" << endl << ends;
+ }
+ else
+ str << "newpath "
+ << tt0.TkCanvasPs(parent->canvas) << ' '
+ << "moveto "
+ << xx1.TkCanvasPs(parent->canvas) << ' '
+ << xx2.TkCanvasPs(parent->canvas) << ' '
+ << tt1.TkCanvasPs(parent->canvas) << ' '
+ << "curveto stroke" << endl << ends;
+
+ Tcl_AppendResult(parent->interp, str.str().c_str(), NULL);
+}
+
void Circle::analysis(AnalysisTask mm, int which)
{
switch (mm) {
diff --git a/tksao/frame/circle.h b/tksao/frame/circle.h
index cc58e85..c59de03 100644
--- a/tksao/frame/circle.h
+++ b/tksao/frame/circle.h
@@ -12,6 +12,7 @@ class Circle : public BaseEllipse, public BaseFill {
protected:
void renderXCircleDraw(Drawable, GC, Vector&, Vector&, int, int);
void renderPSCircleDraw(Vector& cc, double l, float a1, float a2);
+ void renderPSEllipseArcDraw(Vector&, Vector&, Vector&, Vector&);
void listNonCel(FitsImage*, ostream&, Coord::CoordSystem);