summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 76b9690)
raw | patch | inline | side by side (parent: 76b9690)
author | cilix42 <cilix42@users.sourceforge.net> | |
Mon, 20 Aug 2007 18:55:18 +0000 (18:55 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Mon, 20 Aug 2007 18:55:18 +0000 (18:55 +0000) |
src/box3d.cpp | patch | blob | history | |
src/box3d.h | patch | blob | history | |
src/object-edit.cpp | patch | blob | history |
diff --git a/src/box3d.cpp b/src/box3d.cpp
index dcbe5b531ab3abc057f43f6afa23b1d110498ef0..f822a1b201686aa66b596d6e6016b464457f73d4 100644 (file)
--- a/src/box3d.cpp
+++ b/src/box3d.cpp
@@ -181,6 +181,7 @@ sp_3dbox_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr
box->old_corner0 = box->corners[0];
box->old_corner3 = box->corners[3];
box->old_corner5 = box->corners[5];
+ box->old_corner7 = box->corners[7];
}
static void
@@ -292,6 +293,7 @@ static Inkscape::XML::Node *sp_3dbox_write(SPObject *object, Inkscape::XML::Node
box->old_corner0 = box->corners[0];
box->old_corner3 = box->corners[3];
box->old_corner5 = box->corners[5];
+ box->old_corner7 = box->corners[7];
}
if (((SPObjectClass *) (parent_class))->write) {
@@ -783,6 +785,55 @@ sp_3dbox_new_midpoints (Box3D::Perspective3D *persp, Box3D::Axis axis, NR::Point
return std::make_pair (A_new, B_new);
}
+void sp_3dbox_recompute_Z_corners_from_new_center (SP3DBox *box, NR::Point const new_center)
+{
+ // TODO: Clean this function up
+
+ Box3D::Perspective3D *persp = sp_desktop_document (inkscape_active_desktop())->get_persp_of_box (box);
+ NR::Point old_center = box->old_center;
+
+ Box3D::PerspectiveLine aux_line1 (old_center, Box3D::Z, persp);
+ Box3D::PerspectiveLine aux_line2 (new_center, Box3D::Y, persp);
+ NR::Point Z1 = aux_line1.meet (aux_line2);
+
+ NR::Point A0 (sp_3dbox_get_midpoint_in_axis_direction (box->old_corner2, box->old_corner0, Box3D::Y, persp));
+ NR::Point B0 (sp_3dbox_get_midpoint_in_axis_direction (box->old_corner7, box->old_corner5, Box3D::Y, persp));
+ Box3D::PerspectiveLine aux_line3 (A0, Box3D::X, persp);
+ Box3D::PerspectiveLine aux_line4 (B0, Box3D::X, persp);
+
+ NR::Point C0 = aux_line3.meet (aux_line1);
+ NR::Point D0 = aux_line4.meet (aux_line1);
+
+ std::pair<NR::Point, NR::Point> new_midpts = sp_3dbox_new_midpoints (persp, Box3D::Z, old_center, Z1, C0, D0);
+ NR::Point C1 (new_midpts.first);
+ NR::Point D1 (new_midpts.second);
+ Box3D::PerspectiveLine aux_line5 (C1, Box3D::X, persp);
+ Box3D::PerspectiveLine aux_line6 (D1, Box3D::X, persp);
+
+ Box3D::PerspectiveLine aux_line7 (A0, Box3D::Z, persp);
+ Box3D::PerspectiveLine aux_line8 (B0, Box3D::Z, persp);
+
+ NR::Point A1 = aux_line5.meet (aux_line7);
+ NR::Point B1 = aux_line6.meet (aux_line8);
+
+ Box3D::PerspectiveLine aux_line9 (box->old_corner2, Box3D::Z, persp);
+ Box3D::PerspectiveLine aux_line10 (box->old_corner5, Box3D::Z, persp);
+
+ Box3D::PerspectiveLine aux_line11 (A1, Box3D::Y, persp);
+ Box3D::PerspectiveLine aux_line12 (B1, Box3D::Y, persp);
+
+ NR::Point new_corner2 = aux_line9.meet (aux_line11);
+ NR::Point new_corner5 = aux_line10.meet (aux_line12);
+
+ Box3D::PerspectiveLine aux_line13 (A1, Box3D::X, persp);
+ NR::Point E1 = aux_line13.meet (aux_line8);
+ Box3D::PerspectiveLine aux_line14 (E1, Box3D::Y, persp);
+
+ NR::Point new_corner1 = aux_line10.meet (aux_line14);
+
+ sp_3dbox_set_shape_from_points (box, new_corner2, new_corner1, new_corner5);
+}
+
void sp_3dbox_recompute_XY_corners_from_new_center (SP3DBox *box, NR::Point const new_center)
{
// TODO: Clean this function up
diff --git a/src/box3d.h b/src/box3d.h
index a47b066634b43b494c27bb6e40d8c4b7013e5d8d..e1b90c3f97c0c931d1405fc3bd46766216385870 100644 (file)
--- a/src/box3d.h
+++ b/src/box3d.h
NR::Point old_corner0;
NR::Point old_corner3;
NR::Point old_corner5;
+ NR::Point old_corner7;
gint my_counter; // for testing only
};
NR::Maybe<NR::Point> sp_3dbox_get_center (SP3DBox *box);
NR::Maybe<NR::Point> sp_3dbox_get_midpoint_between_corners (SP3DBox *box, guint id_corner1, guint id_corner2);
void sp_3dbox_recompute_XY_corners_from_new_center (SP3DBox *box, NR::Point const new_center);
+void sp_3dbox_recompute_Z_corners_from_new_center (SP3DBox *box, NR::Point const new_center);
NR::Point sp_3dbox_get_midpoint_in_axis_direction (NR::Point const &C, NR::Point const &D, Box3D::Axis axis, Box3D::Perspective3D *persp);
void sp_3dbox_update_perspective_lines();
diff --git a/src/object-edit.cpp b/src/object-edit.cpp
index 2ebb2a0651bb797bb95bfffb7b9b34d11e885753..bb98c6b681715fe890f70e409a5512eaab2ea74f 100644 (file)
--- a/src/object-edit.cpp
+++ b/src/object-edit.cpp
@@ -652,7 +652,11 @@ static void sp_3dbox_knot_set(SPItem *item, guint knot_id, NR::Point const &new_
static void sp_3dbox_knot_center_set(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state)
{
NR::Matrix const i2d (sp_item_i2d_affine (item));
- sp_3dbox_recompute_XY_corners_from_new_center (SP_3DBOX (item), new_pos * i2d);
+ if (state & GDK_SHIFT_MASK) {
+ sp_3dbox_recompute_Z_corners_from_new_center (SP_3DBOX (item), new_pos * i2d);
+ } else {
+ sp_3dbox_recompute_XY_corners_from_new_center (SP_3DBOX (item), new_pos * i2d);
+ }
sp_3dbox_update_curves (SP_3DBOX(item));
}