From 69f5c4dd44b76696be7d8d27f4059d420bd98bcc Mon Sep 17 00:00:00 2001 From: cilix42 Date: Wed, 26 Dec 2007 11:19:54 +0000 Subject: [PATCH] Don't show boxes as everted (i.e., always show the same sides) during initial drag, regardless of the mouse pointer position. --- src/box3d-context.cpp | 4 +++- src/box3d.cpp | 35 +++++++++++++++++++++++++++++++++++ src/box3d.h | 4 ++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp index f66647ef7..edc45e8d1 100644 --- a/src/box3d-context.cpp +++ b/src/box3d-context.cpp @@ -669,11 +669,13 @@ static void sp_box3d_drag(Box3DContext &bc, guint /*state*/) box->orig_corner0 = bc.drag_origin_proj; box->orig_corner7 = bc.drag_ptC_proj; + box3d_check_for_swapped_coords(box); + /* we need to call this from here (instead of from box3d_position_set(), for example) because z-order setting must not interfere with display updates during undo/redo */ box3d_set_z_orders (box); - box3d_position_set(SP_BOX3D(bc.item)); + box3d_position_set(box); // status text //GString *Ax = SP_PX_TO_METRIC_STRING(origin[NR::X], desktop->namedview->getDefaultMetric()); diff --git a/src/box3d.cpp b/src/box3d.cpp index 4044b5647..0f9f8defe 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -1362,6 +1362,41 @@ box3d_relabel_corners(SPBox3D *box) { box3d_swap_coords(box, Proj::Z, true); } +static void +box3d_check_for_swapped_coords(SPBox3D *box, Proj::Axis axis, bool smaller) { + box->orig_corner0.normalize(); + box->orig_corner7.normalize(); + + if ((box->orig_corner0[axis] < box->orig_corner7[axis]) != smaller) { + box->swapped = (Box3D::Axis) (box->swapped | Proj::toAffine(axis)); + } else { + box->swapped = (Box3D::Axis) (box->swapped & ~Proj::toAffine(axis)); + } +} + +static void +box3d_exchange_coords(SPBox3D *box) { + box->orig_corner0.normalize(); + box->orig_corner7.normalize(); + + for (int i = 0; i < 3; ++i) { + if (box->swapped & Box3D::axes[i]) { + double tmp = box->orig_corner0[i]; + box->orig_corner0[i] = box->orig_corner7[i]; + box->orig_corner7[i] = tmp; + } + } +} + +void +box3d_check_for_swapped_coords(SPBox3D *box) { + box3d_check_for_swapped_coords(box, Proj::X, false); + box3d_check_for_swapped_coords(box, Proj::Y, false); + box3d_check_for_swapped_coords(box, Proj::Z, true); + + box3d_exchange_coords(box); +} + void box3d_add_to_selection(SPBox3D *box) { Persp3D *persp = box3d_get_perspective(box); diff --git a/src/box3d.h b/src/box3d.h index d34ac1ae0..d6243d5e0 100644 --- a/src/box3d.h +++ b/src/box3d.h @@ -43,6 +43,8 @@ struct SPBox3D : public SPGroup { Proj::Pt3 save_corner0; Proj::Pt3 save_corner7; + Box3D::Axis swapped; // to indicate which coordinates are swapped during dragging + gint my_counter; // for debugging only }; @@ -70,6 +72,8 @@ int box3d_VP_lies_in_PL_sector (SPBox3D const *box, Proj::Axis vpdir, int id1, i /* ensures that the coordinates of corner0 and corner7 are in the correct order (to prevent everted boxes) */ void box3d_relabel_corners(SPBox3D *box); +void box3d_check_for_swapped_coords(SPBox3D *box); + void box3d_add_to_selection(SPBox3D *box); void box3d_remove_from_selection(SPBox3D *box); void box3d_mark_transformed(SPBox3D *box); -- 2.30.2