Code

replace matrix division code.
authorjohanengelen <johanengelen@users.sourceforge.net>
Fri, 1 Aug 2008 18:10:26 +0000 (18:10 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Fri, 1 Aug 2008 18:10:26 +0000 (18:10 +0000)
src/desktop.cpp
src/display/sp-canvas-util.cpp
src/knotholder.cpp
src/live_effects/parameter/pointparam-knotholder.cpp
src/object-edit.cpp
src/sp-conn-end.cpp
src/sp-gradient.cpp
src/sp-item.cpp
src/sp-rect.cpp

index 0a7f353a88daed5c50d75794dd670aaeee37aa52..b8d9ef0b036543f9b929af206ff3dce7bc1a0b4c 100644 (file)
@@ -79,7 +79,6 @@
 #include "display/sp-canvas-util.h"
 #include "display/canvas-temporary-item-list.h"
 #include "display/snap-indicator.h"
-#include "libnr/nr-matrix-div.h"
 #include "libnr/nr-rect-ops.h"
 #include "ui/dialog/dialog-manager.h"
 #include "xml/repr.h"
@@ -1680,7 +1679,7 @@ NR::Point SPDesktop::doc2dt(NR::Point const &p) const
 
 NR::Point SPDesktop::dt2doc(NR::Point const &p) const
 {
-    return p / _doc2dt;
+    return p * _doc2dt.inverse();
 }
 
 
index 28d4b0c6902b1cfac7d8d6d7d0898d41d761d8f2..9be8d5844d41a238f0d1cc89f63524e4a59f2ace 100644 (file)
@@ -13,7 +13,7 @@
  */
 
 
-#include "libnr/nr-matrix-div.h"
+#include "libnr/nr-matrix-ops.h"
 #include "libnr/nr-pixops.h"
 #include "sp-canvas-util.h"
 #include <string.h>  /* for memset */
@@ -90,14 +90,14 @@ NR::Matrix  sp_canvas_item_i2i_affine (SPCanvasItem * from, SPCanvasItem * to)
     g_assert (from != NULL);
     g_assert (to != NULL);
 
-    return sp_canvas_item_i2w_affine(from) / sp_canvas_item_i2w_affine(to);
+    return sp_canvas_item_i2w_affine(from) * sp_canvas_item_i2w_affine(to).inverse();
 }
 
 void sp_canvas_item_set_i2w_affine (SPCanvasItem * item,  NR::Matrix const &i2w)
 {
     g_assert (item != NULL);
 
-    sp_canvas_item_affine_absolute(item, i2w / sp_canvas_item_i2w_affine(item->parent));
+    sp_canvas_item_affine_absolute(item, i2w * sp_canvas_item_i2w_affine(item->parent).inverse());
 }
 
 void sp_canvas_item_move_to_z (SPCanvasItem * item, gint z)
index 629aa73684a3924d3202912261a7bf929631dc24..f4892b008c5a4892b1c2d4f9c91cc1ce33b5b1d6 100644 (file)
@@ -33,7 +33,6 @@
 
 #include "xml/repr.h" // for debugging only
 
-#include <libnr/nr-matrix-div.h>
 #include <glibmm/i18n.h>
 
 class SPDesktop;
@@ -140,8 +139,8 @@ KnotHolder::knot_moved_handler(SPKnot *knot, Geom::Point const &p, guint state)
     for(std::list<KnotHolderEntity *>::iterator i = this->entity.begin(); i != this->entity.end(); ++i) {
         KnotHolderEntity *e = *i;
         if (e->knot == knot) {
-            NR::Point const q = p / from_2geom(sp_item_i2d_affine(item));
-            e->knot_set(q, e->knot->drag_origin / from_2geom(sp_item_i2d_affine(item)), state);
+            NR::Point const q = p * sp_item_i2d_affine(item).inverse();
+            e->knot_set(q, e->knot->drag_origin * sp_item_i2d_affine(item).inverse(), state);
             break;
         }
     }
index 42601c170b8fa27f8130085bfe84560007e9bc8d..434eff4f4e574818b9f93585265bfc69f5309170 100644 (file)
@@ -19,7 +19,6 @@
 #include "knotholder.h"
 #include "knot-holder-entity.h"
 
-#include <libnr/nr-matrix-div.h>
 #include <glibmm/i18n.h>
 #include <2geom/point.h>
 #include <2geom/matrix.h>
@@ -92,7 +91,7 @@ PointParamKnotHolder::add_knot (
     entity.push_back(e);
 
     // Move to current point.
-    NR::Point dp = p * from_2geom(sp_item_i2d_affine(item));
+    Geom::Point dp = p * sp_item_i2d_affine(item);
     sp_knot_set_position(e->knot, dp, SP_KNOT_STATE_NORMAL);
 
     e->handler_id = g_signal_connect(e->knot, "moved", G_CALLBACK(pointparam_knot_moved_handler), this);
@@ -113,22 +112,22 @@ static void pointparam_knot_clicked_handler(SPKnot */*knot*/, guint /*state*/, P
  */
 static void pointparam_knot_moved_handler(SPKnot */*knot*/, NR::Point const *p, guint /*state*/, PointParamKnotHolder *kh)
 {
-    NR::Matrix const i2d(from_2geom(sp_item_i2d_affine(kh->getItem())));
-    NR::Point pos = (*p) / i2d;
+    Geom::Matrix const i2d(sp_item_i2d_affine(kh->getItem()));
+    Geom::Point pos = (*p) * i2d.inverse();
 
     Inkscape::SVGOStringStream os;
-    os << pos.to_2geom();
+    os << pos;
 
     kh->lpeobject->lpe->setParameter(kh->repr_key, os.str().c_str());
 }
 
 static void pointparam_knot_ungrabbed_handler(SPKnot *knot, unsigned int /*state*/, PointParamKnotHolder *kh)
 {
-    NR::Matrix const i2d(from_2geom(sp_item_i2d_affine(kh->getItem())));
-    NR::Point pos = sp_knot_position(knot) / i2d;
+    Geom::Matrix const i2d(sp_item_i2d_affine(kh->getItem()));
+    Geom::Point pos = sp_knot_position(knot) * i2d.inverse();
 
     Inkscape::SVGOStringStream os;
-    os << pos.to_2geom();
+    os << pos;
 
     kh->repr->setAttribute(kh->repr_key , os.str().c_str());
 
index ea0291159bfd896ad9bb4224a5ed4b66f1ee37e0..1d72b9b29d1ad27054e792c8c64854d99be3811f 100644 (file)
@@ -41,7 +41,6 @@
 #include "object-edit.h"
 
 #include <libnr/nr-scale-ops.h>
-#include <libnr/nr-matrix-div.h>
 
 #include "xml/repr.h"
 
index 80ecb060f23704ff292382c080b45a00bc35d72e..a4ecf1f65917fd34560998908f5b91ad06954c8d 100644 (file)
@@ -3,7 +3,6 @@
 #include <string>
 
 #include "display/curve.h"
-#include "libnr/nr-matrix-div.h"
 #include "libnr/nr-matrix-fns.h"
 #include "xml/repr.h"
 #include "sp-conn-end.h"
@@ -91,8 +90,8 @@ sp_conn_end_move_compensate(NR::Matrix const */*mp*/, SPItem */*moved_item*/,
         NR::Point h2endPt_pcoordsys[2];
         for (unsigned h = 0; h < 2; ++h) {
             h2endPt_icoordsys[h] = calc_bbox_conn_pt(h2bbox_icoordsys[h],
-                                         ( last_seg_endPt[h] / h2i2anc[h] ));
-            h2endPt_pcoordsys[h] = h2endPt_icoordsys[h] * h2i2anc[h] / path2anc;
+                                         ( last_seg_endPt[h] * h2i2anc[h].inverse() ));
+            h2endPt_pcoordsys[h] = h2endPt_icoordsys[h] * h2i2anc[h] * path2anc.inverse();
         }
         change_endpts(path->curve, h2endPt_pcoordsys);
     } else {
@@ -135,8 +134,8 @@ sp_conn_end_move_compensate(NR::Matrix const */*mp*/, SPItem */*moved_item*/,
         // on the edge of the bbox.
         NR::Point h2endPt_pcoordsys[2];
         h2endPt_icoordsys[ind] = calc_bbox_conn_pt(h2bbox_icoordsys[ind],
-                                                 ( last_seg_pt / h2i2anc ));
-        h2endPt_pcoordsys[ind] = h2endPt_icoordsys[ind] * h2i2anc / path2anc;
+                                                 ( last_seg_pt * h2i2anc.inverse() ));
+        h2endPt_pcoordsys[ind] = h2endPt_icoordsys[ind] * h2i2anc * path2anc.inverse();
 
         // Leave the other where it is.
         h2endPt_pcoordsys[!ind] = other_endpt;
index 82724303fcf03e12769f933342ad20239a169dfc..1fe0d221837195a6e7ccbcb661545c77e9b3078c 100644 (file)
@@ -21,7 +21,6 @@
 #include <cstring>
 #include <string>
 
-#include <libnr/nr-matrix-div.h>
 #include <libnr/nr-matrix-fns.h>
 #include <libnr/nr-matrix-ops.h>
 #include <libnr/nr-matrix-scale-ops.h>
@@ -1279,7 +1278,7 @@ void
 sp_gradient_set_gs2d_matrix(SPGradient *gr, NR::Matrix const &ctm,
                             NR::Rect const &bbox, NR::Matrix const &gs2d)
 {
-    gr->gradientTransform = gs2d / ctm;
+    gr->gradientTransform = gs2d * ctm.inverse();
     if (gr->units == SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX ) {
         gr->gradientTransform = ( gr->gradientTransform
                                   / NR::translate(bbox.min())
index c888bc195eaf99009e415bc6116bc6a4f646614e..422ea1195c455023f9aae0959cb2a93bbb1be63b 100644 (file)
@@ -56,7 +56,6 @@
 #include "filter-chemistry.h"
 #include "sp-guide.h"
 
-#include "libnr/nr-matrix-div.h"
 #include "libnr/nr-matrix-fns.h"
 #include "libnr/nr-matrix-scale-ops.h"
 #include "libnr/nr-matrix-translate-ops.h"
@@ -1514,7 +1513,7 @@ Geom::Matrix
 i2i_affine(SPObject const *src, SPObject const *dest) {
     g_return_val_if_fail(src != NULL && dest != NULL, Geom::identity());
     SPObject const *ancestor = src->nearestCommonAncestor(dest);
-    return to_2geom( from_2geom(i2anc_affine(src, ancestor)) / from_2geom(i2anc_affine(dest, ancestor)) );
+    return i2anc_affine(src, ancestor) * i2anc_affine(dest, ancestor).inverse();
 }
 
 NR::Matrix SPItem::getRelativeTransform(SPObject const *dest) const {
index e5ffa8b396a16f8ed1c74a11a60b7f090370894a..ad8ba38a93cac607d3c8f1c734405aae8c3e25c1 100644 (file)
@@ -19,7 +19,7 @@
 
 
 #include <display/curve.h>
-#include <libnr/nr-matrix-div.h>
+#include <libnr/nr-matrix-ops.h>
 #include <libnr/nr-matrix-fns.h>
 
 #include "inkscape.h"
@@ -385,10 +385,10 @@ sp_rect_set_transform(SPItem *item, NR::Matrix const &xform)
     sp_item_adjust_stroke(item, sqrt(fabs(sw * sh)));
 
     // Adjust pattern fill
-    sp_item_adjust_pattern(item, xform / ret);
+    sp_item_adjust_pattern(item, xform * ret.inverse());
 
     // Adjust gradient fill
-    sp_item_adjust_gradient(item, xform / ret);
+    sp_item_adjust_gradient(item, xform * ret.inverse());
 
     item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);