summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2007-07-03 19:27:22 +0000
committercilix42 <cilix42@users.sourceforge.net>2007-07-03 19:27:22 +0000
commit46955243d4acb29e3edb9412946e0b2caad4dfe7 (patch)
treedd9a7f9002b5550048671546d0344dafe6b40ce6 /src
parentRefactoring of 3D box internals. (diff)
downloadinkscape-46955243d4acb29e3edb9412946e0b2caad4dfe7.tar.gz
inkscape-46955243d4acb29e3edb9412946e0b2caad4dfe7.zip
Make box resizeable (currently 3 handles: arbitrary movement in XY plane, constrained movement in Z direction)
(bzr r3172)
Diffstat (limited to 'src')
-rw-r--r--src/object-edit.cpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/object-edit.cpp b/src/object-edit.cpp
index ea0be7ef5..c597f3a26 100644
--- a/src/object-edit.cpp
+++ b/src/object-edit.cpp
@@ -18,6 +18,7 @@
#include "sp-item.h"
#include "sp-rect.h"
+#include "box3d.h"
#include "sp-ellipse.h"
#include "sp-star.h"
#include "sp-spiral.h"
@@ -48,6 +49,7 @@
#define sp_round(v,m) (((v) < 0.0) ? ((ceil((v) / (m) - 0.5)) * (m)) : ((floor((v) / (m) + 0.5)) * (m)))
static SPKnotHolder *sp_rect_knot_holder(SPItem *item, SPDesktop *desktop);
+static 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);
@@ -61,6 +63,8 @@ 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);
} else if (SP_IS_ARC(item)) {
return sp_arc_knot_holder(item, desktop);
} else if (SP_IS_STAR(item)) {
@@ -522,6 +526,83 @@ static SPKnotHolder *sp_rect_knot_holder(SPItem *item, SPDesktop *desktop)
return knot_holder;
}
+/* 3D Box */
+
+static void sp_3dbox_knot_set(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);
+
+ // FIXME: Why must the coordinates be flipped vertically???
+ SPDocument *doc = SP_OBJECT_DOCUMENT(box);
+ gdouble height = sp_document_height(doc);
+
+ if (direction == Box3D::Z) {
+ sp_3dbox_move_corner_in_constrained_Z_direction (box, knot_id,
+ NR::Point (new_pos[NR::X], height - new_pos[NR::Y]));
+ } else {
+ sp_3dbox_move_corner_in_XY_plane (box, knot_id, NR::Point (new_pos[NR::X], height - new_pos[NR::Y]));
+ }
+ sp_3dbox_update_curves (box);
+}
+
+static NR::Point sp_3dbox_knot_get(SPItem *item, guint knot_id)
+{
+ 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);
+
+ return NR::Point(sp_3dbox_get_corner(box, knot_id)[NR::X], height - sp_3dbox_get_corner(box, knot_id)[NR::Y]);
+}
+
+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::XY, new_pos, origin, state);
+}
+
+static NR::Point sp_3dbox_knot1_get(SPItem *item)
+{
+ return sp_3dbox_knot_get(item, 1);
+}
+
+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::XY, new_pos, origin, state);
+}
+
+static NR::Point sp_3dbox_knot2_get(SPItem *item)
+{
+ return sp_3dbox_knot_get(item, 2);
+}
+
+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 NR::Point sp_3dbox_knot5_get(SPItem *item)
+{
+ return sp_3dbox_knot_get(item, 5);
+}
+
+static SPKnotHolder *
+sp_3dbox_knot_holder(SPItem *item, SPDesktop *desktop)
+{
+ g_assert(item != NULL);
+ SPKnotHolder *knot_holder = sp_knot_holder_new(desktop, item, NULL);
+
+ 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);
+
+ return knot_holder;
+}
+
/* SPArc */
/*