Code

now that selection description includes style (filtered, clipped), we need to update...
[inkscape.git] / src / splivarot.cpp
index a3a4ce59ff1d9d28fbf17ea98ba3dd37eaca25bc..f6ae9baa003904eb6058b8d8e8fdd023cf4512f0 100644 (file)
@@ -452,11 +452,11 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb
     // adjust style properties that depend on a possible transform in the source object in order
     // to get a correct style attribute for the new path
     SPItem* item_source = SP_ITEM(source);
-    NR::Matrix i2root(sp_item_i2root_affine(item_source));
-    sp_item_adjust_stroke(item_source, i2root.descrim());
-    sp_item_adjust_pattern(item_source, i2root);
-    sp_item_adjust_gradient(item_source, i2root);
-    sp_item_adjust_livepatheffect(item_source, i2root);
+    Geom::Matrix i2doc(sp_item_i2doc_affine(item_source));
+    sp_item_adjust_stroke(item_source, i2doc.descrim());
+    sp_item_adjust_pattern(item_source, i2doc);
+    sp_item_adjust_gradient(item_source, i2doc);
+    sp_item_adjust_livepatheffect(item_source, i2doc);
 
     Inkscape::XML::Node *repr_source = SP_OBJECT_REPR(source);
 
@@ -485,7 +485,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb
 
     // premultiply by the inverse of parent's repr
     SPItem *parent_item = SP_ITEM(sp_desktop_document(desktop)->getObjectByRepr(parent));
-    NR::Matrix local (sp_item_i2doc_affine(parent_item));
+    Geom::Matrix local (sp_item_i2doc_affine(parent_item));
     gchar *transform = sp_svg_transform_write(local.inverse());
 
     // now that we have the result, add it on the canvas
@@ -685,7 +685,7 @@ sp_selected_path_outline(SPDesktop *desktop)
             sp_repr_css_unset_property(ncss, "marker-end");
         }
 
-        NR::Matrix const transform(item->transform);
+        Geom::Matrix const transform(item->transform);
         float const scale = transform.descrim();
         gchar const *mask = SP_OBJECT_REPR(item)->attribute("mask");
         gchar const *clip_path = SP_OBJECT_REPR(item)->attribute("clip-path");
@@ -858,46 +858,52 @@ sp_selected_path_outline(SPDesktop *desktop)
 
                 Geom::PathVector const & pathv = curve->get_pathvector();
                 for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) {
-                    if ( SPObject *marker_obj = shape->marker[SP_MARKER_LOC_START] ) {
-                        Geom::Matrix const m (sp_shape_marker_get_transform_at_start(path_it->front()));
-                        sp_selected_path_outline_add_marker( marker_obj, m,
-                                                             Geom::Scale(i_style->stroke_width.computed), transform,
-                                                             g_repr, xml_doc, doc );
+                    for (int i = 0; i < 2; i++) {  // SP_MARKER_LOC and SP_MARKER_LOC_START
+                        if ( SPObject *marker_obj = shape->marker[i] ) {
+                            Geom::Matrix const m (sp_shape_marker_get_transform_at_start(path_it->front()));
+                            sp_selected_path_outline_add_marker( marker_obj, m,
+                                                                 Geom::Scale(i_style->stroke_width.computed), transform,
+                                                                 g_repr, xml_doc, doc );
+                        }
                     }
 
-                    SPObject *midmarker_obj = shape->marker[SP_MARKER_LOC_MID];
-                    if ( midmarker_obj && (path_it->size_default() > 1) ) {
-                        Geom::Path::const_iterator curve_it1 = path_it->begin();      // incoming curve
-                        Geom::Path::const_iterator curve_it2 = ++(path_it->begin());  // outgoing curve
-                        while (curve_it2 != path_it->end_default())
-                        {
-                            /* Put marker between curve_it1 and curve_it2.
-                             * Loop to end_default (so including closing segment), because when a path is closed,
-                             * there should be a midpoint marker between last segment and closing straight line segment
-                             */
-                            Geom::Matrix const m (sp_shape_marker_get_transform(*curve_it1, *curve_it2));
-                            sp_selected_path_outline_add_marker(midmarker_obj, m,
-                                                                Geom::Scale(i_style->stroke_width.computed), transform,
-                                                                g_repr, xml_doc, doc);
-
-                            ++curve_it1;
-                            ++curve_it2;
+                    for (int i = 0; i < 3; i += 2) {  // SP_MARKER_LOC and SP_MARKER_LOC_MID
+                        SPObject *midmarker_obj = shape->marker[i];
+                        if ( midmarker_obj && (path_it->size_default() > 1) ) {
+                            Geom::Path::const_iterator curve_it1 = path_it->begin();      // incoming curve
+                            Geom::Path::const_iterator curve_it2 = ++(path_it->begin());  // outgoing curve
+                            while (curve_it2 != path_it->end_default())
+                            {
+                                /* Put marker between curve_it1 and curve_it2.
+                                 * Loop to end_default (so including closing segment), because when a path is closed,
+                                 * there should be a midpoint marker between last segment and closing straight line segment
+                                 */
+                                Geom::Matrix const m (sp_shape_marker_get_transform(*curve_it1, *curve_it2));
+                                sp_selected_path_outline_add_marker(midmarker_obj, m,
+                                                                    Geom::Scale(i_style->stroke_width.computed), transform,
+                                                                    g_repr, xml_doc, doc);
+
+                                ++curve_it1;
+                                ++curve_it2;
+                            }
                         }
                     }
 
-                    if ( SPObject *marker_obj = shape->marker[SP_MARKER_LOC_END] ) {
-                        /* Get reference to last curve in the path.
-                         * For moveto-only path, this returns the "closing line segment". */
-                        unsigned int index = path_it->size_default();
-                        if (index > 0) {
-                            index--;
-                        }
-                        Geom::Curve const &lastcurve = (*path_it)[index];
+                    for (int i = 0; i < 4; i += 3) {  // SP_MARKER_LOC and SP_MARKER_LOC_END
+                        if ( SPObject *marker_obj = shape->marker[i] ) {
+                            /* Get reference to last curve in the path.
+                             * For moveto-only path, this returns the "closing line segment". */
+                            unsigned int index = path_it->size_default();
+                            if (index > 0) {
+                                index--;
+                            }
+                            Geom::Curve const &lastcurve = (*path_it)[index];
 
-                        Geom::Matrix const m = sp_shape_marker_get_transform_at_end(lastcurve);
-                        sp_selected_path_outline_add_marker( marker_obj, m,
-                                                             Geom::Scale(i_style->stroke_width.computed), transform,
-                                                             g_repr, xml_doc, doc );
+                            Geom::Matrix const m = sp_shape_marker_get_transform_at_end(lastcurve);
+                            sp_selected_path_outline_add_marker( marker_obj, m,
+                                                                 Geom::Scale(i_style->stroke_width.computed), transform,
+                                                                 g_repr, xml_doc, doc );
+                        }
                     }
                 }
 
@@ -1048,7 +1054,7 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat
             return;
     }
 
-    NR::Matrix const transform(item->transform);
+    Geom::Matrix const transform(item->transform);
 
     sp_item_write_transform(item, SP_OBJECT_REPR(item), Geom::identity());
 
@@ -1273,7 +1279,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset)
                 continue;
         }
 
-        NR::Matrix const transform(item->transform);
+        Geom::Matrix const transform(item->transform);
 
         sp_item_write_transform(item, SP_OBJECT_REPR(item), Geom::identity());
 
@@ -1516,8 +1522,11 @@ sp_selected_path_simplify_item(SPDesktop *desktop,
             return false;
     }
 
+    // correct virtual size by full transform (bug #166937)
+    size /= sp_item_i2doc_affine(item).descrim();
+
     // save the transform, to re-apply it after simplification
-    NR::Matrix const transform(item->transform);
+    Geom::Matrix const transform(item->transform);
 
     /*
        reset the transform, effectively transforming the item by transform.inverse();
@@ -1648,7 +1657,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop,
 
     bool didSomething = false;
 
-    boost::optional<Geom::Rect> selectionBbox = selection->bounds();
+    Geom::OptRect selectionBbox = selection->bounds();
     if (!selectionBbox) {
         return false;
     }
@@ -1669,7 +1678,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop,
           continue;
 
         if (simplifyIndividualPaths) {
-            boost::optional<Geom::Rect> itemBbox = item->getBounds(sp_item_i2d_affine(item));
+            Geom::OptRect itemBbox = item->getBounds(sp_item_i2d_affine(item));
             if (itemBbox) {
                 simplifySize      = L2(itemBbox->dimensions());
             } else {
@@ -1850,16 +1859,16 @@ SPCurve* curve_for_item(SPItem *item)
     return curve; // do not forget to unref the curve at some point!
 }
 
-boost::optional<Path::cut_position> get_nearest_position_on_Path(Path *path, NR::Point p, unsigned seg)
+boost::optional<Path::cut_position> get_nearest_position_on_Path(Path *path, Geom::Point p, unsigned seg)
 {
     //get nearest position on path
     Path::cut_position pos = path->PointToCurvilignPosition(p, seg);
     return pos;
 }
 
-NR::Point get_point_on_Path(Path *path, int piece, double t)
+Geom::Point get_point_on_Path(Path *path, int piece, double t)
 {
-    NR::Point p;
+    Geom::Point p;
     path->PointAt(piece, t, p);
     return p;
 }