summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b27df1f)
raw | patch | inline | side by side (parent: b27df1f)
author | cilix42 <cilix42@users.sourceforge.net> | |
Wed, 26 Dec 2007 11:19:54 +0000 (11:19 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Wed, 26 Dec 2007 11:19:54 +0000 (11:19 +0000) |
src/box3d-context.cpp | patch | blob | history | |
src/box3d.cpp | patch | blob | history | |
src/box3d.h | patch | blob | history |
diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp
index f66647ef7cd5fea87fef58ee95d5d4adfbde056f..edc45e8d153fdc487ac9157f70a262235b4ffe9f 100644 (file)
--- a/src/box3d-context.cpp
+++ b/src/box3d-context.cpp
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 4044b5647350bdfe772d67a09fbdb5080c5ae509..0f9f8defef022a47478642686c918c858cf98c8e 100644 (file)
--- a/src/box3d.cpp
+++ b/src/box3d.cpp
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 d34ac1ae042629e29e2efe3491eaec942c811440..d6243d5e06c40303b0632e5fdd1c08105c633a51 100644 (file)
--- a/src/box3d.h
+++ b/src/box3d.h
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
};
/* 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);