Code

Different resizing variant for 3D boxes (8 handles)
authorcilix42 <cilix42@users.sourceforge.net>
Tue, 10 Jul 2007 12:59:33 +0000 (12:59 +0000)
committercilix42 <cilix42@users.sourceforge.net>
Tue, 10 Jul 2007 12:59:33 +0000 (12:59 +0000)
src/object-edit.cpp
src/widgets/toolbox.cpp

index e284d6c41817f5dc1acb73922e214d731f22d468..28886173c972a93ee3e57b54a59134d913a56abd 100644 (file)
@@ -566,31 +566,24 @@ static void sp_3dbox_knot1_set(SPItem *item, NR::Point const &new_pos, NR::Point
     sp_3dbox_knot_set (item, 1, Box3D::Y, new_pos, origin, state);
 }
 
+/*
 static void sp_3dbox_knot1_set_constrained(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);
 }
-
-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::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);
 }
 
-static NR::Point sp_3dbox_knot2_get(SPItem *item)
-{
-    return sp_3dbox_knot_get(item, 2);
-}
-
 static void sp_3dbox_knot3_set(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state)
 {
     if (!(state & GDK_SHIFT_MASK)) {
@@ -599,15 +592,98 @@ static void sp_3dbox_knot3_set(SPItem *item, NR::Point const &new_pos, NR::Point
         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);
+}
+
+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);
+}
+
+static void sp_3dbox_knot1_set_uniformly(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);
+}
+
+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)
+{
+    sp_3dbox_knot_set_uniformly(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)
+{
+    sp_3dbox_knot_set_uniformly(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)
+{
+    sp_3dbox_knot_set_uniformly(item, 7, Box3D::Z, new_pos, origin, state);
+}
+
+static NR::Point sp_3dbox_knot0_get(SPItem *item)
+{
+    return sp_3dbox_knot_get(item, 0);
+}
+
+static NR::Point sp_3dbox_knot1_get(SPItem *item)
+{
+    return sp_3dbox_knot_get(item, 1);
+}
+
+static NR::Point sp_3dbox_knot2_get(SPItem *item)
+{
+    return sp_3dbox_knot_get(item, 2);
+}
 
 static NR::Point sp_3dbox_knot3_get(SPItem *item)
 {
     return sp_3dbox_knot_get(item, 3);
 }
 
-static void sp_3dbox_knot5_set(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state)
+static NR::Point sp_3dbox_knot4_get(SPItem *item)
 {
-    sp_3dbox_knot_set (item, 5, Box3D::Z, new_pos, origin, state);
+    return sp_3dbox_knot_get(item, 4);
 }
 
 static NR::Point sp_3dbox_knot5_get(SPItem *item)
@@ -615,9 +691,9 @@ static NR::Point sp_3dbox_knot5_get(SPItem *item)
     return sp_3dbox_knot_get(item, 5);
 }
 
-static void sp_3dbox_knot7_set(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state)
+static NR::Point sp_3dbox_knot6_get(SPItem *item)
 {
-    sp_3dbox_knot_set (item, 7, Box3D::Z, new_pos, origin, state);
+    return sp_3dbox_knot_get(item, 6);
 }
 
 static NR::Point sp_3dbox_knot7_get(SPItem *item)
@@ -625,6 +701,7 @@ static NR::Point sp_3dbox_knot7_get(SPItem *item)
     return sp_3dbox_knot_get(item, 7);
 }
 
+
 //static
 SPKnotHolder *
 sp_3dbox_knot_holder(SPItem *item, SPDesktop *desktop, guint number_of_handles)
@@ -640,11 +717,29 @@ sp_3dbox_knot_holder(SPItem *item, SPDesktop *desktop, guint number_of_handles)
         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:
index 95e893a349dac126515b48cc6ebb8e06b697f8fb..fee4c7da12238f1f0956d2b8c088f753ee376b36 100644 (file)
@@ -2149,7 +2149,7 @@ static void sp_3dboxtb_handles_state_changed( EgeSelectOneAction *act, GObject *
         if ( ege_select_one_action_get_active( act ) != 0 ) {
             prefs_set_string_attribute("tools.shapes.3dbox", "constrainedXYmoving", "true");
         } else {
-            prefs_set_string_attribute("tools.shapes.3dbox", "constrainedXYmoving", NULL);
+            prefs_set_string_attribute("tools.shapes.3dbox", "constrainedXYmoving", "false");
         }
     }