summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5cff59e)
raw | patch | inline | side by side (parent: 5cff59e)
author | cilix42 <cilix42@users.sourceforge.net> | |
Wed, 16 Jan 2008 00:12:43 +0000 (00:12 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Wed, 16 Jan 2008 00:12:43 +0000 (00:12 +0000) |
src/pen-context.cpp | patch | blob | history | |
src/pencil-context.cpp | patch | blob | history | |
src/sp-path.cpp | patch | blob | history |
diff --git a/src/pen-context.cpp b/src/pen-context.cpp
index 3267912752bb8378c1b0895e6f8d40173d8103a9..f56714eb79fc6ec9bfb8b453e68d606b96c26661 100644 (file)
--- a/src/pen-context.cpp
+++ b/src/pen-context.cpp
#include "desktop.h"
#include "desktop-handles.h"
#include "selection.h"
+#include "selection-chemistry.h"
#include "draw-anchor.h"
#include "message-stack.h"
#include "message-context.h"
ret = TRUE;
}
break;
+ case GDK_g:
+ case GDK_G:
+ if (MOD__SHIFT_ONLY) {
+ sp_selection_to_guides();
+ ret = true;
+ }
+ break;
case GDK_BackSpace:
case GDK_Delete:
case GDK_KP_Delete:
diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp
index 1ee39d5309f9427ccc14007eb6a1fb3b1e7783b5..f173371838c0c680d1cfa5310f0bf35eae0cd839 100644 (file)
--- a/src/pencil-context.cpp
+++ b/src/pencil-context.cpp
#include "desktop.h"
#include "desktop-handles.h"
#include "selection.h"
+#include "selection-chemistry.h"
#include "draw-anchor.h"
#include "message-stack.h"
#include "message-context.h"
#include "xml/repr.h"
#include "document.h"
#include "desktop-style.h"
+#include "macros.h"
static void sp_pencil_context_class_init(SPPencilContextClass *klass);
static void sp_pencil_context_init(SPPencilContext *pc);
@@ -509,6 +511,13 @@ pencil_handle_key_press(SPPencilContext *const pc, guint const keyval, guint con
}
}
break;
+ case GDK_g:
+ case GDK_G:
+ if (mod_shift_only(state)) {
+ sp_selection_to_guides();
+ ret = true;
+ }
+ break;
default:
break;
}
diff --git a/src/sp-path.cpp b/src/sp-path.cpp
index d97bbddb9664b6d7b3946af85a7f03b4c86d8f9e..a8e3ad6eebf74db53a4a0aacee145a22c2e186d0 100644 (file)
--- a/src/sp-path.cpp
+++ b/src/sp-path.cpp
#include "attributes.h"
#include "sp-path.h"
+#include "sp-guide.h"
#include "document.h"
static Inkscape::XML::Node *sp_path_write(SPObject *object, Inkscape::XML::Node *repr, guint flags);
static NR::Matrix sp_path_set_transform(SPItem *item, NR::Matrix const &xform);
static gchar * sp_path_description(SPItem *item);
+static void sp_path_convert_to_guides(SPItem *item);
static void sp_path_update(SPObject *object, SPCtx *ctx, guint flags);
static void sp_path_update_patheffect(SPShape *shape, bool write);
item_class->description = sp_path_description;
item_class->set_transform = sp_path_set_transform;
+ item_class->convert_to_guides = sp_path_convert_to_guides;
shape_class->update_patheffect = sp_path_update_patheffect;
}
}
}
+static void
+sp_path_convert_to_guides(SPItem *item)
+{
+ SPPath *path = SP_PATH(item);
+
+ SPDocument *doc = SP_OBJECT_DOCUMENT(path);
+ std::list<std::pair<Geom::Point, Geom::Point> > pts;
+
+ NR::Matrix const i2d (sp_item_i2d_affine(SP_ITEM(path)));
+
+ SPCurve *curve = SP_SHAPE(path)->curve;
+ if (!curve) return;
+ NArtBpath *bpath = SP_CURVE_BPATH(curve);
+
+ NR::Point last_pt;
+ NR::Point pt;
+ for (int i = 0; bpath[i].code != NR_END; i++){
+ if (bpath[i].code == NR_LINETO) {
+ /* we only convert straight line segments (converting curve segments would be unintuitive) */
+ pt = bpath[i].c(3) * i2d;
+ pts.push_back(std::make_pair(last_pt.to_2geom(), pt.to_2geom()));
+ }
+
+ /* remember current point for potential reuse in the next step
+ (e.g., in case this was an NR_MOVETO or NR_MOVETO_OPEN) */
+ last_pt = bpath[i].c(3) * i2d;
+ }
+
+ sp_guide_pt_pairs_to_guides(doc, pts);
+
+ SP_OBJECT(path)->deleteObject(true);
+}
+
/**
* Initializes an SPPath.
*/