Code

Adding two missing files. distcheck fixes.
[inkscape.git] / src / sp-ellipse.cpp
index b5f3df1cb83567d798b9c37bfdcacee0269b0c40..251620b6c96eb7c323a58844af7e8505c1864855 100644 (file)
@@ -72,7 +72,7 @@ static void sp_genericellipse_init(SPGenericEllipse *ellipse);
 
 static void sp_genericellipse_update(SPObject *object, SPCtx *ctx, guint flags);
 
-static void sp_genericellipse_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs);
+static void sp_genericellipse_snappoints(SPItem const *item, bool const target, SnapPointsWithType &p, Inkscape::SnapPreferences const *snapprefs);
 
 static void sp_genericellipse_set_shape(SPShape *shape);
 static void sp_genericellipse_update_patheffect (SPLPEItem *lpeitem, bool write);
@@ -180,9 +180,6 @@ sp_genericellipse_update_patheffect(SPLPEItem *lpeitem, bool write)
     ((SPObject *)shape)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
 }
 
-
-#define C1 0.552
-
 /* fixme: Think (Lauris) */
 /* Can't we use arcto in this method? */
 static void sp_genericellipse_set_shape(SPShape *shape)
@@ -220,7 +217,7 @@ static void sp_genericellipse_set_shape(SPShape *shape)
         e = s + M_PI_2;
         if (e > ellipse->end)
             e = ellipse->end;
-        len = C1 * (e - s) / M_PI_2;
+        len = 4*tan((e - s)/4)/3;
         x0 = cos(s);
         y0 = sin(s);
         x1 = x0 + len * cos(s + M_PI_2);
@@ -260,7 +257,7 @@ static void sp_genericellipse_set_shape(SPShape *shape)
     curve->unref();
 }
 
-static void sp_genericellipse_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs)
+static void sp_genericellipse_snappoints(SPItem const *item, bool const target, SnapPointsWithType &p, Inkscape::SnapPreferences const *snapprefs)
 {
     g_assert(item != NULL);
     g_assert(SP_IS_GENERICELLIPSE(item));
@@ -290,31 +287,37 @@ static void sp_genericellipse_snappoints(SPItem const *item, SnapPointsIter p, I
     double cx = ellipse->cx.computed;
     double cy = ellipse->cy.computed;
 
+    Geom::Point pt;
+
     // Snap to the 4 quadrant points of the ellipse, but only if the arc
     // spans far enough to include them
     if (snapprefs->getSnapToItemNode()) { //TODO: Make a separate snap option toggle for this?
                double angle = 0;
                for (angle = 0; angle < SP_2PI; angle += M_PI_2) {
                        if (angle >= ellipse->start && angle <= ellipse->end) {
-                               *p = Geom::Point(cx + cos(angle)*rx, cy + sin(angle)*ry) * i2d;
+                               pt = Geom::Point(cx + cos(angle)*rx, cy + sin(angle)*ry) * i2d;
+                               p.push_back(std::make_pair(pt, target ? int(Inkscape::SNAPTARGET_ELLIPSE_QUADRANT_POINT) : int(Inkscape::SNAPSOURCE_ELLIPSE_QUADRANT_POINT)));
                        }
                }
     }
 
     // Add the centre, if we have a closed slice or when explicitly asked for
     if ((snapprefs->getSnapToItemNode() && slice && ellipse->closed) || snapprefs->getSnapObjectMidpoints()) {
-       *p = Geom::Point(cx, cy) * i2d;
+       pt = Geom::Point(cx, cy) * i2d;
+       p.push_back(std::make_pair(pt, target ? int(Inkscape::SNAPTARGET_CENTER) : int(Inkscape::SNAPSOURCE_CENTER)));
     }
 
     // And if we have a slice, also snap to the endpoints
     if (snapprefs->getSnapToItemNode() && slice) {
         // Add the start point, if it's not coincident with a quadrant point
         if (fmod(ellipse->start, M_PI_2) != 0.0 ) {
-            *p = Geom::Point(cx + cos(ellipse->start)*rx, cy + sin(ellipse->start)*ry) * i2d;
+            pt = Geom::Point(cx + cos(ellipse->start)*rx, cy + sin(ellipse->start)*ry) * i2d;
+            p.push_back(std::make_pair(pt, target ? int(Inkscape::SNAPTARGET_NODE_CUSP) : int(Inkscape::SNAPSOURCE_NODE_CUSP)));
         }
         // Add the end point, if it's not coincident with a quadrant point
         if (fmod(ellipse->end, M_PI_2) != 0.0 ) {
-            *p = Geom::Point(cx + cos(ellipse->end)*rx, cy + sin(ellipse->end)*ry) * i2d;
+            pt = Geom::Point(cx + cos(ellipse->end)*rx, cy + sin(ellipse->end)*ry) * i2d;
+            p.push_back(std::make_pair(pt, target ? int(Inkscape::SNAPTARGET_NODE_CUSP) : int(Inkscape::SNAPSOURCE_NODE_CUSP)));
         }
     }
 }
@@ -841,7 +844,7 @@ sp_arc_set(SPObject *object, unsigned int key, gchar const *value)
 static void
 sp_arc_modified(SPObject *object, guint flags)
 {
-    if (flags & SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG) {
+    if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
         sp_shape_set_shape((SPShape *) object);
     }