summaryrefslogtreecommitdiffstats
path: root/src/box3d.cpp
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2008-01-11 19:01:50 +0000
committercilix42 <cilix42@users.sourceforge.net>2008-01-11 19:01:50 +0000
commit0e82b86bbfd6d5656431edbf20fa8b6f79515a04 (patch)
treee9c728ab9079678cf526dc228800767a2f16c5f6 /src/box3d.cpp
parentCheck for perspective in document defs (to avoid hanging/crashes after vacuum... (diff)
downloadinkscape-0e82b86bbfd6d5656431edbf20fa8b6f79515a04.tar.gz
inkscape-0e82b86bbfd6d5656431edbf20fa8b6f79515a04.zip
Add possibility to convert objects (only rectangles and 3D boxes currently) to guidelines. Also see corresponding post on the mailing list; in particular, feel free to revert it if this is inappropriate during Frost phase.
(bzr r4462)
Diffstat (limited to 'src/box3d.cpp')
-rw-r--r--src/box3d.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/box3d.cpp b/src/box3d.cpp
index 082c83bbd..631d5cfc1 100644
--- a/src/box3d.cpp
+++ b/src/box3d.cpp
@@ -32,6 +32,8 @@
#include "persp3d-reference.h"
#include "uri.h"
#include "2geom/geom.h"
+#include "sp-guide.h"
+#include "sp-namedview.h"
#include "desktop.h"
#include "macros.h"
@@ -1486,6 +1488,47 @@ box3d_convert_to_group(SPBox3D *box) {
return SP_GROUP(doc->getObjectByRepr(grepr));
}
+static 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) {
+ 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;
+
+ /* perspective lines in X direction */
+ box3d_push_back_corner_pair(box, pts, 0, 1);
+ box3d_push_back_corner_pair(box, pts, 2, 3);
+ box3d_push_back_corner_pair(box, pts, 4, 5);
+ box3d_push_back_corner_pair(box, pts, 6, 7);
+
+ /* perspective lines in Y direction */
+ box3d_push_back_corner_pair(box, pts, 0, 2);
+ box3d_push_back_corner_pair(box, pts, 1, 3);
+ box3d_push_back_corner_pair(box, pts, 4, 6);
+ box3d_push_back_corner_pair(box, pts, 5, 7);
+
+ /* perspective lines in Z direction */
+ box3d_push_back_corner_pair(box, pts, 0, 4);
+ box3d_push_back_corner_pair(box, pts, 1, 5);
+ box3d_push_back_corner_pair(box, pts, 2, 6);
+ box3d_push_back_corner_pair(box, pts, 3, 7);
+
+ 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"));
+ }
+}
+
/*
Local Variables:
mode:c++