diff options
Diffstat (limited to 'src/object-edit.cpp')
| -rw-r--r-- | src/object-edit.cpp | 159 |
1 files changed, 36 insertions, 123 deletions
diff --git a/src/object-edit.cpp b/src/object-edit.cpp index bd3bd1902..b15646520 100644 --- a/src/object-edit.cpp +++ b/src/object-edit.cpp @@ -50,7 +50,7 @@ static SPKnotHolder *sp_rect_knot_holder(SPItem *item, SPDesktop *desktop); //static -SPKnotHolder *sp_3dbox_knot_holder(SPItem *item, SPDesktop *desktop, guint number_of_handles); +SPKnotHolder *sp_3dbox_knot_holder(SPItem *item, SPDesktop *desktop); static SPKnotHolder *sp_arc_knot_holder(SPItem *item, SPDesktop *desktop); static SPKnotHolder *sp_star_knot_holder(SPItem *item, SPDesktop *desktop); static SPKnotHolder *sp_spiral_knot_holder(SPItem *item, SPDesktop *desktop); @@ -65,7 +65,7 @@ sp_item_knot_holder(SPItem *item, SPDesktop *desktop) if (SP_IS_RECT(item)) { return sp_rect_knot_holder(item, desktop); } else if (SP_IS_3DBOX(item)) { - return sp_3dbox_knot_holder(item, desktop, SP3DBoxContext::number_of_handles); + return sp_3dbox_knot_holder(item, desktop); } else if (SP_IS_ARC(item)) { return sp_arc_knot_holder(item, desktop); } else if (SP_IS_STAR(item)) { @@ -535,15 +535,11 @@ static void sp_3dbox_knot_set(SPItem *item, guint knot_id, Box3D::Axis direction g_assert(item != NULL); SP3DBox *box = SP_3DBOX(item); - // FIXME: Why must the coordinates be flipped vertically??? - SPDocument *doc = SP_OBJECT_DOCUMENT(box); - gdouble height = sp_document_height(doc); - NR::Matrix const i2d (sp_item_i2d_affine (item)); if (direction == Box3D::Z) { - sp_3dbox_move_corner_in_Z_direction (box, knot_id, new_pos * i2d, !(state & GDK_SHIFT_MASK)); + sp_3dbox_move_corner_in_Z_direction (box, knot_id, new_pos * i2d, !(state & GDK_SHIFT_MASK)); } else { - sp_3dbox_move_corner_in_XY_plane (box, knot_id, new_pos * i2d, (state & GDK_SHIFT_MASK) ? direction : Box3D::XY); + sp_3dbox_move_corner_in_Z_direction (box, knot_id, new_pos * i2d, (state & GDK_SHIFT_MASK)); } sp_3dbox_update_curves (box); sp_3dbox_set_ratios (box); @@ -560,107 +556,44 @@ static NR::Point sp_3dbox_knot_get(SPItem *item, guint knot_id) return sp_3dbox_get_corner(box, knot_id) * i2d; } -static void sp_3dbox_knot1_set(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) +static void sp_3dbox_knot0_set(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) { - sp_3dbox_knot_set (item, 1, Box3D::Y, new_pos, origin, state); + sp_3dbox_knot_set(item, 0, Box3D::XY, new_pos, origin, state); } -/* -static void sp_3dbox_knot1_set_constrained(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) +static void sp_3dbox_knot1_set(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) { - sp_3dbox_knot_set (item, 1, Box3D::Y, new_pos, origin, state ^ GDK_SHIFT_MASK); + sp_3dbox_knot_set(item, 1, Box3D::XY, new_pos, origin, state); } -*/ static void sp_3dbox_knot2_set(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) { - sp_3dbox_knot_set (item, 2, Box3D::X, new_pos, origin, state); -} - -/* -static void sp_3dbox_knot2_set_constrained(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) -{ - sp_3dbox_knot_set (item, 2, Box3D::X, new_pos, origin, state ^ GDK_SHIFT_MASK); + sp_3dbox_knot_set(item, 2, Box3D::XY, new_pos, origin, state); } static void sp_3dbox_knot3_set(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) { - if (!(state & GDK_SHIFT_MASK)) { - sp_3dbox_knot_set (item, 3, Box3D::Y, new_pos, origin, state); - } else { - sp_3dbox_knot_set (item, 3, Box3D::Z, new_pos, origin, state ^ GDK_SHIFT_MASK); - } -} -*/ - -static void sp_3dbox_knot5_set(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) -{ - sp_3dbox_knot_set (item, 5, Box3D::Z, new_pos, origin, state); -} - -/* -static void sp_3dbox_knot7_set(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) -{ - sp_3dbox_knot_set (item, 7, Box3D::Z, new_pos, origin, state); -} -*/ - -// defined a uniform behaviour for all knots -static void sp_3dbox_knot_set_uniformly(SPItem *item, guint knot_id, Box3D::Axis direction, NR::Point const &new_pos, NR::Point const &origin, guint state) -{ - g_assert(item != NULL); - SP3DBox *box = SP_3DBOX(item); - - NR::Matrix const i2d (sp_item_i2d_affine (item)); - if (direction == Box3D::Z) { - sp_3dbox_move_corner_in_Z_direction (box, knot_id, new_pos * i2d, !(state & GDK_SHIFT_MASK)); - } else { - sp_3dbox_move_corner_in_Z_direction (box, knot_id, new_pos * i2d, (state & GDK_SHIFT_MASK)); - } - sp_3dbox_update_curves (box); - sp_3dbox_set_ratios (box); - sp_3dbox_update_perspective_lines (); - sp_3dbox_set_z_orders (box); -} - -static void sp_3dbox_knot0_set_uniformly(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) -{ - sp_3dbox_knot_set_uniformly(item, 0, Box3D::XY, new_pos, origin, state); + sp_3dbox_knot_set(item, 3, Box3D::XY, new_pos, origin, state); } -static void sp_3dbox_knot1_set_uniformly(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) +static void sp_3dbox_knot4_set(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) { - sp_3dbox_knot_set_uniformly(item, 1, Box3D::XY, new_pos, origin, state); + sp_3dbox_knot_set(item, 4, Box3D::Z, new_pos, origin, state); } -static void sp_3dbox_knot2_set_uniformly(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) -{ - sp_3dbox_knot_set_uniformly(item, 2, Box3D::XY, new_pos, origin, state); -} - -static void sp_3dbox_knot3_set_uniformly(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) -{ - sp_3dbox_knot_set_uniformly(item, 3, Box3D::XY, new_pos, origin, state); -} - -static void sp_3dbox_knot4_set_uniformly(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) -{ - sp_3dbox_knot_set_uniformly(item, 4, Box3D::Z, new_pos, origin, state); -} - -static void sp_3dbox_knot5_set_uniformly(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) +static void sp_3dbox_knot5_set(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) { - sp_3dbox_knot_set_uniformly(item, 5, Box3D::Z, new_pos, origin, state); + sp_3dbox_knot_set(item, 5, Box3D::Z, new_pos, origin, state); } -static void sp_3dbox_knot6_set_uniformly(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) +static void sp_3dbox_knot6_set(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) { - sp_3dbox_knot_set_uniformly(item, 6, Box3D::Z, new_pos, origin, state); + sp_3dbox_knot_set(item, 6, Box3D::Z, new_pos, origin, state); } -static void sp_3dbox_knot7_set_uniformly(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) +static void sp_3dbox_knot7_set(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) { - sp_3dbox_knot_set_uniformly(item, 7, Box3D::Z, new_pos, origin, state); + sp_3dbox_knot_set(item, 7, Box3D::Z, new_pos, origin, state); } static NR::Point sp_3dbox_knot0_get(SPItem *item) @@ -706,48 +639,28 @@ static NR::Point sp_3dbox_knot7_get(SPItem *item) //static SPKnotHolder * -sp_3dbox_knot_holder(SPItem *item, SPDesktop *desktop, guint number_of_handles) +sp_3dbox_knot_holder(SPItem *item, SPDesktop *desktop) { g_assert(item != NULL); SPKnotHolder *knot_holder = sp_knot_holder_new(desktop, item, NULL); - switch (number_of_handles) { - case 3: - sp_knot_holder_add(knot_holder, sp_3dbox_knot1_set, sp_3dbox_knot1_get, NULL,_("Resize box in X/Y direction")); - sp_knot_holder_add(knot_holder, sp_3dbox_knot2_set, sp_3dbox_knot2_get, NULL,_("Resize box in X/Y direction")); - sp_knot_holder_add(knot_holder, sp_3dbox_knot5_set, sp_3dbox_knot5_get, NULL,_("Resize box in Z direction")); - sp_pat_knot_holder(item, knot_holder); - break; - case 4: - /*** - sp_knot_holder_add(knot_holder, sp_3dbox_knot1_set_constrained, sp_3dbox_knot1_get, NULL,_("Resize box in X/Y direction")); - sp_knot_holder_add(knot_holder, sp_3dbox_knot2_set_constrained, sp_3dbox_knot2_get, NULL,_("Resize box in X/Y direction")); - sp_knot_holder_add_full(knot_holder, sp_3dbox_knot3_set, sp_3dbox_knot3_get, NULL, - SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR, _("Resize box in Y direction")); - sp_knot_holder_add(knot_holder, sp_3dbox_knot7_set, sp_3dbox_knot7_get, NULL,_("Resize box in Z direction")); - ***/ - sp_knot_holder_add(knot_holder, sp_3dbox_knot0_set_uniformly, sp_3dbox_knot0_get, NULL, - _("Resize box in X/Y direction; with <b>Shift</b> along the Z axis")); - sp_knot_holder_add(knot_holder, sp_3dbox_knot1_set_uniformly, sp_3dbox_knot1_get, NULL, - _("Resize box in X/Y direction; with <b>Shift</b> along the Z axis")); - sp_knot_holder_add(knot_holder, sp_3dbox_knot2_set_uniformly, sp_3dbox_knot2_get, NULL, - _("Resize box in X/Y direction; with <b>Shift</b> along the Z axis")); - sp_knot_holder_add(knot_holder, sp_3dbox_knot3_set_uniformly, sp_3dbox_knot3_get, NULL, - _("Resize box in X/Y direction; with <b>Shift</b> along the Z axis")); - sp_knot_holder_add(knot_holder, sp_3dbox_knot4_set_uniformly, sp_3dbox_knot4_get, NULL, - _("Resize box along the Z axis; with <b>Shift</b> in X/Y direction")); - sp_knot_holder_add(knot_holder, sp_3dbox_knot5_set_uniformly, sp_3dbox_knot5_get, NULL, - _("Resize box along the Z axis; with <b>Shift</b> in X/Y direction")); - sp_knot_holder_add(knot_holder, sp_3dbox_knot6_set_uniformly, sp_3dbox_knot6_get, NULL, - _("Resize box along the Z axis; with <b>Shift</b> in X/Y direction")); - sp_knot_holder_add(knot_holder, sp_3dbox_knot7_set_uniformly, sp_3dbox_knot7_get, NULL, - _("Resize box along the Z axis; with <b>Shift</b> in X/Y direction")); - sp_pat_knot_holder(item, knot_holder); - break; - default: - g_print ("Wrong number of handles (%d): Not implemented yet.\n", number_of_handles); - break; - } + sp_knot_holder_add(knot_holder, sp_3dbox_knot0_set, sp_3dbox_knot0_get, NULL, + _("Resize box in X/Y direction; with <b>Shift</b> along the Z axis")); + sp_knot_holder_add(knot_holder, sp_3dbox_knot1_set, sp_3dbox_knot1_get, NULL, + _("Resize box in X/Y direction; with <b>Shift</b> along the Z axis")); + sp_knot_holder_add(knot_holder, sp_3dbox_knot2_set, sp_3dbox_knot2_get, NULL, + _("Resize box in X/Y direction; with <b>Shift</b> along the Z axis")); + sp_knot_holder_add(knot_holder, sp_3dbox_knot3_set, sp_3dbox_knot3_get, NULL, + _("Resize box in X/Y direction; with <b>Shift</b> along the Z axis")); + sp_knot_holder_add(knot_holder, sp_3dbox_knot4_set, sp_3dbox_knot4_get, NULL, + _("Resize box along the Z axis; with <b>Shift</b> in X/Y direction")); + sp_knot_holder_add(knot_holder, sp_3dbox_knot5_set, sp_3dbox_knot5_get, NULL, + _("Resize box along the Z axis; with <b>Shift</b> in X/Y direction")); + sp_knot_holder_add(knot_holder, sp_3dbox_knot6_set, sp_3dbox_knot6_get, NULL, + _("Resize box along the Z axis; with <b>Shift</b> in X/Y direction")); + sp_knot_holder_add(knot_holder, sp_3dbox_knot7_set, sp_3dbox_knot7_get, NULL, + _("Resize box along the Z axis; with <b>Shift</b> in X/Y direction")); + sp_pat_knot_holder(item, knot_holder); return knot_holder; } |
