From 7c1b9f3edcc591cece8fc2fb55379e47e17ac641 Mon Sep 17 00:00:00 2001 From: dvlierop2 Date: Sun, 31 May 2009 20:45:39 +0000 Subject: [PATCH] Patch by Adonis Papaderos to create only a single guide line from a SVG:line element, instead of creating four guidelines from its boundingbox (fixes bug #381871) --- src/sp-line.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/sp-line.cpp b/src/sp-line.cpp index 946d5d0e6..d0ce32397 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -17,11 +17,13 @@ #include "attributes.h" #include "style.h" #include "sp-line.h" +#include "sp-guide.h" #include "display/curve.h" #include #include #include #include "document.h" +#include "inkscape.h" static void sp_line_class_init (SPLineClass *klass); static void sp_line_init (SPLine *line); @@ -35,6 +37,7 @@ static Geom::Matrix sp_line_set_transform(SPItem *item, Geom::Matrix const &xfor static void sp_line_update (SPObject *object, SPCtx *ctx, guint flags); static void sp_line_set_shape (SPShape *shape); +static void sp_line_convert_to_guides(SPItem *item); static SPShapeClass *parent_class; @@ -74,6 +77,7 @@ sp_line_class_init (SPLineClass *klass) SPItemClass *item_class = (SPItemClass *) klass; item_class->description = sp_line_description; item_class->set_transform = sp_line_set_transform; + item_class->convert_to_guides = sp_line_convert_to_guides; sp_object_class->update = sp_line_update; @@ -190,6 +194,20 @@ sp_line_description(SPItem */*item*/) return g_strdup(_("Line")); } +static void +sp_line_convert_to_guides(SPItem *item) +{ + SPLine *line = SP_LINE(item); + Geom::Point points[2]; + + Geom::Matrix const i2d (sp_item_i2d_affine(item)); + + points[0] = Geom::Point(line->x1.computed, line->y1.computed)*i2d; + points[1] = Geom::Point(line->x2.computed, line->y2.computed)*i2d; + + sp_guide_create(inkscape_active_desktop(), points[0], points[1]); +} + static Geom::Matrix sp_line_set_transform (SPItem *item, Geom::Matrix const &xform) { -- 2.30.2