]> Shamusworld >> Repos - architektonas/blobdiff - src/structs.cpp
More polyline upgrading: points and arcs are now editable with the GUI.
[architektonas] / src / structs.cpp
index b731fae75a767c99d05962e639190ff863875caa..883e934e20e0d5629b7f664649721ecd8fbdf78f 100644 (file)
@@ -97,9 +97,30 @@ Arc::Arc(): type(OTArc), id(Global::objectID++)
 {
 }
 
-Arc::Arc(Vector pt1, double r, double a1, double a2, float th/*= 1.0*/, uint32_t c/*= 0*/, int l/*= LSSolid*/): type(OTArc), id(Global::objectID++), layer(0), color(c), thickness(th), style(l), selected(false), hovered(false), hitObject(false)
+Arc::Arc(Vector ctr, double r, double a1, double a2, float th/*= 1.0*/, uint32_t c/*= 0*/, int l/*= LSSolid*/): type(OTArc), id(Global::objectID++), layer(0), color(c), thickness(th), style(l), selected(false), hovered(false), hitObject(false)
 {
-       p[0] = pt1; radius[0] = r; angle[0] = a1, angle[1] = a2; hitPoint[0] = hitPoint[1] = hitPoint[2] = false;
+       p[0] = ctr;
+       radius[0] = r;
+       angle[0] = a1;
+       angle[1] = a2;
+       hitPoint[0] = hitPoint[1] = hitPoint[2] = false;
+}
+
+Arc::Arc(Vector ctr, double r, Point p1, Point p2, float th/*= 1.0*/, uint32_t c/*= 0*/, int l/*= LSSolid*/): type(OTArc), id(Global::objectID++), layer(0), color(c), thickness(th), style(l), selected(false), hovered(false), hitObject(false)
+{
+       p[0] = ctr;
+       radius[0] = r;
+       angle[0] = Vector::Angle(ctr, p1);
+/*
+s =  10, e =  20, span = 10 (why not -350?)
+s =  20, e =  10, span = -10 (why not 350?)
+s =  10, e = 350, span = 340 (why not -20?)
+s = 350, e =  10, span = -340 (why not 20?)
+
+below is still not right, we need one more point to disambiguate this...
+*/
+       angle[1] = Vector::Angle(ctr, p2) - angle[0];
+       hitPoint[0] = hitPoint[1] = hitPoint[2] = false;
 }
 
 Rect Arc::Bounds(void)