summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f8a96dc)
raw | patch | inline | side by side (parent: f8a96dc)
author | cilix42 <cilix42@users.sourceforge.net> | |
Wed, 26 Dec 2007 22:35:54 +0000 (22:35 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Wed, 26 Dec 2007 22:35:54 +0000 (22:35 +0000) |
src/box3d.cpp | patch | blob | history | |
src/box3d.h | patch | blob | history | |
src/persp3d.cpp | patch | blob | history |
diff --git a/src/box3d.cpp b/src/box3d.cpp
index 0f9f8defef022a47478642686c918c858cf98c8e..3397cd6b01088ff24bc7787ff1d5ed2b85af1e49 100644 (file)
--- a/src/box3d.cpp
+++ b/src/box3d.cpp
}
void
-box3d_switch_perspectives(SPBox3D *box, Persp3D *old_persp, Persp3D *new_persp) {
+box3d_switch_perspectives(SPBox3D *box, Persp3D *old_persp, Persp3D *new_persp, bool recompute_corners) {
+ if (recompute_corners) {
+ box->orig_corner0.normalize();
+ box->orig_corner7.normalize();
+ double z0 = box->orig_corner0[Proj::Z];
+ double z7 = box->orig_corner7[Proj::Z];
+ NR::Point corner0_screen = box3d_get_corner_screen(box, 0);
+ NR::Point corner7_screen = box3d_get_corner_screen(box, 7);
+
+ box->orig_corner0 = new_persp->tmat.preimage(corner0_screen, z0, Proj::Z);
+ box->orig_corner7 = new_persp->tmat.preimage(corner7_screen, z7, Proj::Z);
+ }
+
persp3d_remove_box (old_persp, box);
persp3d_add_box (new_persp, box);
diff --git a/src/box3d.h b/src/box3d.h
index d6243d5e06c40303b0632e5fdd1c08105c633a51..d80cf038ba025c85d899dd2b161ceecf4c0dd91c 100644 (file)
--- a/src/box3d.h
+++ b/src/box3d.h
void box3d_mark_transformed(SPBox3D *box);
Persp3D *box3d_get_perspective(SPBox3D const *box);
-void box3d_switch_perspectives(SPBox3D *box, Persp3D *old_persp, Persp3D *new_persp);
+void box3d_switch_perspectives(SPBox3D *box, Persp3D *old_persp, Persp3D *new_persp, bool recompute_corners = false);
#endif /* __SP_BOX3D_H__ */
diff --git a/src/persp3d.cpp b/src/persp3d.cpp
index 05a69944693105e922a965776f7942fdb5d7fe9b..1029516f7cff016f4821e8eb1d83bbfe098264fb 100644 (file)
--- a/src/persp3d.cpp
+++ b/src/persp3d.cpp
// otherwise the loop below gets confused when perspectives are reattached.
std::list<SPBox3D *> boxes_of_persp2 = persp3d_list_of_boxes(persp2);
- Inkscape::XML::Node *persp_repr = SP_OBJECT_REPR(persp1);
- const gchar *persp_id = persp_repr->attribute("id");
- gchar *href = g_strdup_printf("#%s", persp_id);
-
for (std::list<SPBox3D *>::iterator i = boxes_of_persp2.begin(); i != boxes_of_persp2.end(); ++i) {
- SP_OBJECT_REPR(*i)->setAttribute("inkscape:perspectiveID", href);
+ box3d_switch_perspectives((*i), persp2, persp1, true);
+ SP_OBJECT(*i)->updateRepr(SP_OBJECT_WRITE_EXT); // so that undo/redo can do its job properly
}
- g_free(href);
-
- persp1->boxes.insert(persp1->boxes.begin(), persp2->boxes.begin(), persp2->boxes.end());
}
static void