From a9df372559de578ae35db1988ec4687bcf788ee2 Mon Sep 17 00:00:00 2001 From: johanengelen Date: Wed, 6 Aug 2008 22:32:41 +0000 Subject: [PATCH] add automatic conversion between Geom::Matrix and NR::Matrix. (added to NR::Matrix class). resolved some ambiguities caused by it. --- src/libnr/nr-matrix.h | 14 ++++++++++++++ src/object-edit.cpp | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/libnr/nr-matrix.h b/src/libnr/nr-matrix.h index f626377e5..b1f9d589a 100644 --- a/src/libnr/nr-matrix.h +++ b/src/libnr/nr-matrix.h @@ -25,6 +25,7 @@ #include #include #include +#include <2geom/matrix.h> namespace NR { @@ -77,6 +78,16 @@ class Matrix { } + Matrix(Geom::Matrix const &m) { + NR::Coord *dest = _c; + + *dest++ = m[0]; + *dest++ = m[1]; + *dest++ = m[2]; + *dest++ = m[3]; + *dest++ = m[4]; + *dest = m[5]; + } /** * @@ -220,6 +231,9 @@ class Matrix { return _c[i]; } + inline operator Geom::Matrix() const { + return Geom::Matrix(_c[0], _c[1], _c[2], _c[3], _c[4], _c[5]); + } /** * diff --git a/src/object-edit.cpp b/src/object-edit.cpp index 3b513fe88..400354d4a 100644 --- a/src/object-edit.cpp +++ b/src/object-edit.cpp @@ -452,7 +452,7 @@ Box3DKnotHolderEntity::knot_set_generic(SPItem *item, unsigned int knot_id, Geom g_assert(item != NULL); SPBox3D *box = SP_BOX3D(item); - NR::Matrix const i2d (from_2geom(sp_item_i2d_affine (item))); + Geom::Matrix const i2d (sp_item_i2d_affine (item)); Box3D::Axis movement; if ((knot_id < 4) != (state & GDK_SHIFT_MASK)) { @@ -628,7 +628,7 @@ Box3DKnotHolderEntityCenter::knot_set(Geom::Point const &new_pos, Geom::Point co Geom::Point const s = snap_knot_position(new_pos); SPBox3D *box = SP_BOX3D(item); - NR::Matrix const i2d (from_2geom(sp_item_i2d_affine (item))); + Geom::Matrix const i2d (sp_item_i2d_affine (item)); box3d_set_center (SP_BOX3D(item), s * i2d, origin * i2d, !(state & GDK_SHIFT_MASK) ? Box3D::XY : Box3D::Z, state & GDK_CONTROL_MASK); -- 2.30.2