EllipseSelection::EllipseSelection (Coord x0, Coord y0, int rx, int ry, Graphic* gs) : (gs) { Append(new IFillEllipse(x0, y0, rx, ry)); Append(new Ellipse(x0, y0, rx, ry)); } // EllipseSelection reads data to initialize its graphic state and // create its filled interior and outline. EllipseSelection::EllipseSelection (istream& from, State* state) : (nil) { ReadGS(from, state); Skip(from); Coord x0, y0; int rx, ry; from >> x0 >> y0 >> rx >> ry; Append(new IFillEllipse(x0, y0, rx, ry)); Append(new Ellipse(x0, y0, rx, ry)); } // Copy returns a copy of the EllipseSelection. Graphic* EllipseSelection::Copy () { Coord x0, y0; int rx, ry; GetOriginal(x0, y0, rx, ry); return new EllipseSelection(x0, y0, rx, ry, this); } // GetOriginal returns the center point and the x and y radii lengths // that were passed to the EllipseSelection's constructor. void EllipseSelection::GetOriginal (Coord& x0, Coord& y0, int& rx, int& ry) { ((Ellipse*) Last())->GetOriginal(x0, y0, rx, ry); }
boolean TextGraphic::RotatedIntersects (BoxObj& userb, Graphic* gs) { int beg, end, lineSize, nextBeg, ypos = 0; const char* s = GetOriginal(); int size = strlen(s); PSFont* f = gs->GetFont(); Coord x[4], tx[5]; Coord y[4], ty[5]; x[0] = x[1] = x[2] = x[3] = y[0] = y[1] = 0; y[2] = y[3] = f->Height(); for (beg = 0; beg < size; beg = nextBeg) { GetLine(s, size, beg, end, lineSize, nextBeg); x[1] = x[2] = f->Width(&s[beg], lineSize) - 1; transformList(x, y, 4, tx, ty, gs); tx[4] = tx[0]; ty[4] = ty[0]; FillPolygonObj fp(tx, ty, 5); if (fp.Intersects(userb)) { return true; } y[0] -= _lineHt; y[1] -= _lineHt; y[2] -= _lineHt; y[3] -= _lineHt; } return false; }
CircleSelection::CircleSelection (Coord x0, Coord y0, int r, Graphic* gs) : (gs) { Append(new IFillCircle(x0, y0, r)); Append(new Circle(x0, y0, r)); } // CircleSelection reads data to initialize its graphic state and // create its filled interior and outline. CircleSelection::CircleSelection (istream& from, State* state) : (nil) { ReadGS(from, state); Skip(from); Coord x0, y0; int r; from >> x0 >> y0 >> r; Append(new IFillCircle(x0, y0, r)); Append(new Circle(x0, y0, r)); } // Copy returns a copy of the CircleSelection. Graphic* CircleSelection::Copy () { Coord x0, y0; int r; GetOriginal(x0, y0, r); return new CircleSelection(x0, y0, r, this); } // GetOriginal returns the center point and radius length that were // passed to the CircleSelection's constructor. void CircleSelection::GetOriginal (Coord& x0, Coord& y0, int& r) { ((Circle*) Last())->GetOriginal(x0, y0, r, r); }
Graphic* SFH_ClosedBSpline::Copy () { Coord* x, *y; const Coord* cx, * cy; int count = GetOriginal(cx, cy); x = (Coord*)cx; y = (Coord*)cy; return new SFH_ClosedBSpline(x, y, count, this); }
void CircleSelection::WriteData (ostream& to) { Coord x0, y0; int r; GetOriginal(x0, y0, r); to << "Begin " << startdata << " Circ\n"; WriteGS(to); to << startdata << "\n"; to << x0 << " " << y0 << " " << r << " Circ\n"; to << "End\n\n"; }
void EllipseSelection::WriteData (ostream& to) { Coord x0, y0; int rx, ry; GetOriginal(x0, y0, rx, ry); to << "Begin " << startdata << " Elli\n"; WriteGS(to); to << startdata << "\n"; to << x0 << " " << y0 << " " << rx << " " << ry << " Elli\n"; to << "End\n\n"; }
void TextGraphic::CalcBox (Coord& l, Coord& b, Coord& r, Coord& t, PSFont* f) { int beg, end, lineSize, nextBeg; const char* s = GetOriginal(); int size = strlen(s); l = r = 0; b = _lineHt; t = f->Height(); for (beg = 0; beg < size; beg = nextBeg) { GetLine(s, size, beg, end, lineSize, nextBeg); r = max(r, f->Width(&s[beg], lineSize) - 1); b -= _lineHt; } }
bool SFH_ClosedBSpline::contains (PointObj& po, Graphic* gs) { const Coord *x, *y; int count = GetOriginal(x, y); Transformer* t = gs->GetTransformer(); if (t != nil) { t->InvTransform(po._x, po._y); } for (int i = 0; i < count; i++) { if (x[i] == po._x && y[i] == po._y) { return true; } } return SF_ClosedBSpline::contains(po, gs); }
boolean TextGraphic::UntransformedIntersects (BoxObj& userb, Graphic* gs) { int beg, end, lineSize, nextBeg, ypos = 0; const char* s = GetOriginal(); int size = strlen(s); PSFont* f = gs->GetFont(); BoxObj box(0, 0, 0, f->Height()); for (beg = 0; beg < size; beg = nextBeg) { GetLine(s, size, beg, end, lineSize, nextBeg); box._right = f->Width(&s[beg], lineSize) - 1; if (box.Intersects(userb)) { return true; } box._top -= _lineHt; box._bottom -= _lineHt; } return false; }
bool SFH_ClosedBSpline::intersects (BoxObj& userb, Graphic* gs) { PointObj po; const Coord *x, *y; int count = GetOriginal(x, y); Transformer* t = gs->GetTransformer(); for (int i = 0; i < count; i++) { po._x = x[i]; po._y = y[i]; if (t != nil) { t->Transform(po._x, po._y); } if (userb.Contains(po)) { return true; } } return SF_ClosedBSpline::intersects(userb, gs); }
ClosedBSplineSelection::ClosedBSplineSelection (Coord* x, Coord* y, int n, Graphic* gs) : (gs) { myname = "CBSpl"; Append(new IFillClosedBSpline(x, y, n)); Append(new ClosedBSpline(x, y, n)); } // ClosedBSplineSelection reads data to initialize its graphic state // and create the closed B-spline's filled interior and outline. ClosedBSplineSelection::ClosedBSplineSelection (istream& from, State* state) : (nil) { myname = "CBSpl"; ReadGS(from, state); Coord* x; Coord* y; int n; ReadPoints(from, x, y, n); Append(new IFillClosedBSpline(x, y, n)); Append(new ClosedBSpline(x, y, n)); } // Copy returns a copy of the ClosedBSplineSelection. Graphic* ClosedBSplineSelection::Copy () { Coord* x; Coord* y; int n; GetOriginal(x, y, n); Graphic* copy = new ClosedBSplineSelection(x, y, n, this); delete x; delete y; return copy; } // GetOriginal returns the control points that were passed to the // ClosedBSplineSelection's constructor. void ClosedBSplineSelection::GetOriginal (Coord*& x, Coord*& y, int& n) { ((ClosedBSpline*) Last())->GetOriginal(x, y, n); }
boolean TextGraphic::contains (PointObj& po, Graphic* gs) { PointObj pt (&po); PSFont* f = gs->GetFont(); BoxObj box(0, 0, 0, f->Height()); int beg, end, lineSize, nextBeg, ypos = 0; const char* s = GetOriginal(); int size = strlen(s); invTransform(pt._x, pt._y, gs); for (beg = 0; beg < size; beg = nextBeg) { GetLine(s, size, beg, end, lineSize, nextBeg); box._right = f->Width(&s[beg], lineSize) - 1; if (box.Contains(pt)) { return true; } box._top -= _lineHt; box._bottom -= _lineHt; } return false; }
PolygonSelection::PolygonSelection (Coord* x, Coord* y, int n, Graphic* gs) : (gs) { myname = "Poly"; Append(new IFillPolygon(x, y, n)); Append(new Polygon(x, y, n)); } // PolygonSelection reads data to initialize its graphic state and // create its filled interior and outline. PolygonSelection::PolygonSelection (istream& from, State* state) : (nil) { myname = "Poly"; ReadGS(from, state); Coord* x; Coord* y; int n; ReadPoints(from, x, y, n); Append(new IFillPolygon(x, y, n)); Append(new Polygon(x, y, n)); } // Copy returns a copy of the PolygonSelection. Graphic* PolygonSelection::Copy () { Coord* x; Coord* y; int n; GetOriginal(x, y, n); Graphic* copy = new PolygonSelection(x, y, n, this); delete x; delete y; return copy; } // GetOriginal returns the vertices that were passed to the // PolygonSelection's constructor. void PolygonSelection::GetOriginal (Coord*& x, Coord*& y, int& n) { ((Polygon*) Last())->GetOriginal(x, y, n); }
BSplineSelection::BSplineSelection (Coord* x, Coord* y, int n, Graphic* gs) : (gs) { Init(x, y, n); } // BSplineSelection reads data to initialize its graphic state and // create its components. BSplineSelection::BSplineSelection (istream& from, State* state) : (nil) { bspline = nil; ReadGS(from, state); Coord* x; Coord* y; int n; ReadPoints(from, x, y, n); Init(x, y, n); } // Copy returns a copy of the BSplineSelection. Graphic* BSplineSelection::Copy () { Coord* x; Coord* y; int n; GetOriginal(x, y, n); Graphic* copy = new BSplineSelection(x, y, n, this); delete x; delete y; return copy; } // GetOriginal returns the control points that were passed to the // BSplineSelection's constructor. void BSplineSelection::GetOriginal (Coord*& x, Coord*& y, int& n) { ((BSpline*) bspline)->GetOriginal(x, y, n); }
boolean TextGraphic::TransformedIntersects (BoxObj& userb, Graphic* gs) { int beg, end, lineSize, nextBeg, ypos = 0; const char* s = GetOriginal(); int size = strlen(s); PSFont* f = gs->GetFont(); Coord l, b, r, t = f->Height(); Coord tl, tb, tr, tt; l = b = r = 0; for (beg = 0; beg < size; beg = nextBeg) { GetLine(s, size, beg, end, lineSize, nextBeg); r = f->Width(&s[beg], lineSize) - 1; transform(l, b, tl, tb, gs); transform(r, t, tr, tt, gs); BoxObj box(tl, tb, tr, tt); if (box.Intersects(userb)) { return true; } b -= _lineHt; t -= _lineHt; } return false; }