summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c7f69cf)
raw | patch | inline | side by side (parent: c7f69cf)
author | cilix42 <cilix42@users.sourceforge.net> | |
Tue, 15 Jan 2008 22:09:09 +0000 (22:09 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Tue, 15 Jan 2008 22:09:09 +0000 (22:09 +0000) |
src/box3d.cpp | patch | blob | history | |
src/box3d.h | patch | blob | history | |
src/selection-chemistry.cpp | patch | blob | history | |
src/sp-item.cpp | patch | blob | history | |
src/sp-item.h | patch | blob | history | |
src/sp-rect.cpp | patch | blob | history | |
src/sp-rect.h | patch | blob | history |
diff --git a/src/box3d.cpp b/src/box3d.cpp
index f28dc8f262726dfd539dbccd5c02b2f11a3793a5..4aca24c4260add33cda3e4d6c69508cabac91b9a 100644 (file)
--- a/src/box3d.cpp
+++ b/src/box3d.cpp
static gchar *box3d_description(SPItem *item);
static NR::Matrix box3d_set_transform(SPItem *item, NR::Matrix const &xform);
+static void box3d_convert_to_guides(SPItem *item);
static void box3d_ref_changed(SPObject *old_ref, SPObject *ref, SPBox3D *box);
static void box3d_ref_modified(SPObject *href, guint flags, SPBox3D *box);
item_class->description = box3d_description;
item_class->set_transform = box3d_set_transform;
+ item_class->convert_to_guides = box3d_convert_to_guides;
}
static void
return SP_GROUP(doc->getObjectByRepr(grepr));
}
-static void
+static inline void
box3d_push_back_corner_pair(SPBox3D *box, std::list<std::pair<Geom::Point, Geom::Point> > &pts, int c1, int c2) {
pts.push_back(std::make_pair(box3d_get_corner_screen(box, c1).to_2geom(),
box3d_get_corner_screen(box, c2).to_2geom()));
}
void
-box3d_convert_to_guides(SPBox3D *box, bool write_undo) {
+box3d_convert_to_guides(SPItem *item) {
+ SPBox3D *box = SP_BOX3D(item);
+
if (prefs_get_int_attribute("tools.shapes.3dbox", "convertguides", 1) == 0) {
sp_item_convert_to_guides(SP_ITEM(box));
return;
}
SPDocument *doc = SP_OBJECT_DOCUMENT(box);
- //SPDesktop *desktop = inkscape_active_desktop();
- //Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
std::list<std::pair<Geom::Point, Geom::Point> > pts;
sp_guide_pt_pairs_to_guides(doc, pts);
SP_OBJECT(box)->deleteObject(true);
-
- if (write_undo) {
- sp_document_done(doc, SP_VERB_CONTEXT_3DBOX, _("Convert to guides"));
- }
}
/*
diff --git a/src/box3d.h b/src/box3d.h
index bcbd975c5a961288f3661780a633e78e98d4c793..fae3849d82266ff276cd522fd897a05ba84a049d 100644 (file)
--- a/src/box3d.h
+++ b/src/box3d.h
void box3d_switch_perspectives(SPBox3D *box, Persp3D *old_persp, Persp3D *new_persp, bool recompute_corners = false);
SPGroup *box3d_convert_to_group(SPBox3D *box);
-void box3d_convert_to_guides(SPBox3D *box, bool write_undo = true);
#endif /* __SP_BOX3D_H__ */
index b1a579d8b316b766301ef28fe2cffda900b6ee42..4cf34e2c565e8f84297ae574995e3797486486b2 100644 (file)
#include "gradient-drag.h"
#include "uri-references.h"
#include "live_effects/lpeobject.h"
-#include "sp-rect.h"
using NR::X;
using NR::Y;
}
static void sp_selection_to_guides_recursive(SPItem *item) {
- if (SP_IS_RECT(item)) {
- sp_rect_convert_to_guides(SP_RECT(item), false);
- } else if (SP_IS_BOX3D(item)) {
- box3d_convert_to_guides(SP_BOX3D(item), false);
- } else if (SP_IS_GROUP(item)) {
+ if (SP_IS_GROUP(item) && !SP_IS_BOX3D(item)) {
for (GSList *i = sp_item_group_item_list (SP_GROUP(item)); i != NULL; i = i->next) {
sp_selection_to_guides_recursive(SP_ITEM(i->data));
}
} else {
- sp_item_convert_to_guides(item);
+ sp_item_convert_item_to_guides(item);
}
}
diff --git a/src/sp-item.cpp b/src/sp-item.cpp
index 7b3687607d7fb3abe1806b76a1747a608c009099..078ff6c5948fffc1d573e1bd61b4850a233b916d 100644 (file)
--- a/src/sp-item.cpp
+++ b/src/sp-item.cpp
}
}
+void
+sp_item_convert_item_to_guides(SPItem *item) {
+ g_return_if_fail(item != NULL);
+ g_return_if_fail(SP_IS_ITEM(item));
+
+ /* Use derived method if present ... */
+ if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->convert_to_guides) {
+ (*((SPItemClass *) G_OBJECT_GET_CLASS(item))->convert_to_guides)(item);
+ return;
+ }
+
+ /* .. otherwise simply place the guides around the item's bounding box */
+
+ sp_item_convert_to_guides(item);
+}
+
/**
* \pre \a ancestor really is an ancestor (\>=) of \a object, or NULL.
diff --git a/src/sp-item.h b/src/sp-item.h
index 8816bd3874e4e1df35a2c2b7adbd603fdcd1de43..18a3c2df74f144107fc140114aa9578f4932b884 100644 (file)
--- a/src/sp-item.h
+++ b/src/sp-item.h
/** Apply the transform optimally, and return any residual transformation */
NR::Matrix (* set_transform)(SPItem *item, NR::Matrix const &transform);
+
+ /** Convert the item to guidelines */
+ void (* convert_to_guides)(SPItem *item);
/** Emit event, if applicable */
gint (* event) (SPItem *item, SPEvent *event);
@@ -237,6 +240,8 @@ void sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NR::Matrix
void sp_item_set_item_transform(SPItem *item, NR::Matrix const &transform);
+void sp_item_convert_item_to_guides(SPItem *item);
+
gint sp_item_event (SPItem *item, SPEvent *event);
/* Utility */
diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp
index 5770e623d753f6a8f1e12318b4c90aaf7a81187d..a26d415995d92911e917bc50f3fe2e583dac86b8 100644 (file)
--- a/src/sp-rect.cpp
+++ b/src/sp-rect.cpp
static gchar *sp_rect_description(SPItem *item);
static NR::Matrix sp_rect_set_transform(SPItem *item, NR::Matrix const &xform);
+static void sp_rect_convert_to_guides(SPItem *item);
static void sp_rect_set_shape(SPShape *shape);
static void sp_rect_snappoints(SPItem const *item, SnapPointsIter p);
item_class->description = sp_rect_description;
item_class->set_transform = sp_rect_set_transform;
+ item_class->convert_to_guides = sp_rect_convert_to_guides;
item_class->snappoints = sp_rect_snappoints; //override the default sp_shape_snappoints; see sp_rect_snappoints for details
shape_class->set_shape = sp_rect_set_shape;
}
void
-sp_rect_convert_to_guides(SPRect *rect, bool write_undo) {
+sp_rect_convert_to_guides(SPItem *item) {
+ SPRect *rect = SP_RECT(item);
+
if (prefs_get_int_attribute("tools.shapes.rect", "convertguides", 1) == 0) {
sp_item_convert_to_guides(SP_ITEM(rect));
return;
sp_guide_pt_pairs_to_guides(doc, pts);
SP_OBJECT(rect)->deleteObject(true);
-
- if (write_undo) {
- sp_document_done(doc, SP_VERB_CONTEXT_RECT, _("Convert to guides"));
- }
}
/*
diff --git a/src/sp-rect.h b/src/sp-rect.h
index 0133922e8a84e3ebce0a3f5552d6524629df23aa..4cf3b24ba07994d03559e3cd5f56251fc72c0284 100644 (file)
--- a/src/sp-rect.h
+++ b/src/sp-rect.h
void sp_rect_compensate_rxry (SPRect *rect, NR::Matrix xform);
-void sp_rect_convert_to_guides(SPRect *rect, bool write_undo = true);
-
#endif