summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0831ba3)
raw | patch | inline | side by side (parent: 0831ba3)
author | speleo3 <speleo3@users.sourceforge.net> | |
Sat, 20 Dec 2008 10:12:04 +0000 (10:12 +0000) | ||
committer | speleo3 <speleo3@users.sourceforge.net> | |
Sat, 20 Dec 2008 10:12:04 +0000 (10:12 +0000) |
* fix snapping to clip/mask with parent transform
* replace matrix_to_desktop call
sp-item.h
sp-item.cpp
* improve snapping to clip/mask with parent transform
* remove matrix_to_desktop/matrix_from_desktop
* use desktop->doc2dt() with sp_item_i2d_affine(...)
desktop.h
desktop.cpp
* new method: dt2doc()
selection-chemistry.cpp
* remove awkward matrix_to_desktop(matrix_from_desktop(...)) calls
* replace matrix_to_desktop call
sp-item.h
sp-item.cpp
* improve snapping to clip/mask with parent transform
* remove matrix_to_desktop/matrix_from_desktop
* use desktop->doc2dt() with sp_item_i2d_affine(...)
desktop.h
desktop.cpp
* new method: dt2doc()
selection-chemistry.cpp
* remove awkward matrix_to_desktop(matrix_from_desktop(...)) calls
diff --git a/src/desktop.cpp b/src/desktop.cpp
index cd39e77aeb7ff4944fc76fb6811a74d884e0fd1a..85c53be6fe91d8fe96de847cd4d2b85a1979384c 100644 (file)
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
return _doc2dt;
}
+Geom::Matrix SPDesktop::dt2doc() const
+{
+ // doc2dt is its own inverse
+ return _doc2dt;
+}
+
Geom::Point SPDesktop::doc2dt(Geom::Point const &p) const
{
return p * _doc2dt;
Geom::Point SPDesktop::dt2doc(Geom::Point const &p) const
{
- return p * _doc2dt.inverse();
+ return p * dt2doc();
}
diff --git a/src/desktop.h b/src/desktop.h
index ce82f4ea6aee265ea7f6eac2bf1c348e1e7d782b..b55d9da01fd674f5f905b9709cd77a20a4dce881 100644 (file)
--- a/src/desktop.h
+++ b/src/desktop.h
Geom::Point w2d(Geom::Point const &p) const;
Geom::Point d2w(Geom::Point const &p) const;
Geom::Matrix doc2dt() const;
+ Geom::Matrix dt2doc() const;
Geom::Point doc2dt(Geom::Point const &p) const;
Geom::Point dt2doc(Geom::Point const &p) const;
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index 922c35bcbe545689f53e1de49a075dd009ea797f..cf10ab5e27bc0e66ff65b5c2f1a6c6fceb9c6c16 100644 (file)
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
if (it == NULL || i == it->end()) {
SPItem *item = SP_ITEM(o);
- Geom::Matrix transform = Geom::identity();
if (item) {
SPObject *obj = NULL;
- if (clip_or_mask) { // If the current item is a clipping path or a mask
- // then store the transformation of the clipped path or mask itself
- // but also take into account the additional affine of the object
- // being clipped / masked
- transform = to_2geom(item->transform) * additional_affine;
- } else { // cannot clip or mask more than once
+ if (!clip_or_mask) { // cannot clip or mask more than once
// The current item is not a clipping path or a mask, but might
// still be the subject of clipping or masking itself ; if so, then
// we should also consider that path or mask for snapping to
obj = SP_OBJECT(item->clip_ref->getObject());
if (obj) {
- _findCandidates(obj, it, false, bbox_to_snap, snap_dim, true, item->transform);
+ _findCandidates(obj, it, false, bbox_to_snap, snap_dim, true, sp_item_i2doc_affine(item));
}
obj = SP_OBJECT(item->mask_ref->getObject());
if (obj) {
- _findCandidates(obj, it, false, bbox_to_snap, snap_dim, true, item->transform);
+ _findCandidates(obj, it, false, bbox_to_snap, snap_dim, true, sp_item_i2doc_affine(item));
}
}
}
// insert an additional transformation in document coordinates (code copied from sp_item_i2d_affine)
sp_item_invoke_bbox(item,
bbox_of_item,
- sp_item_i2doc_affine(item) * matrix_to_desktop(additional_affine, item),
+ sp_item_i2doc_affine(item) * additional_affine * _snapmanager->getDesktop()->doc2dt(),
true);
} else {
sp_item_invoke_bbox(item, bbox_of_item, sp_item_i2d_affine(item), true);
index b6a194d9a9fcb86915ff826f617f47fdab62fee8..92f751e85673b288c80a3a26fefe02d12a5526ec 100644 (file)
@@ -1216,9 +1216,9 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix cons
sp_object_read_attr (SP_OBJECT (item), "transform");
// calculate the matrix we need to apply to the clone to cancel its induced transform from its original
- Geom::Matrix parent_transform = sp_item_i2doc_affine(SP_ITEM(SP_OBJECT_PARENT (item)));
- Geom::Matrix t = parent_transform * matrix_to_desktop (matrix_from_desktop (affine, item), item) * parent_transform.inverse();
- Geom::Matrix t_inv =parent_transform * matrix_to_desktop (matrix_from_desktop (affine.inverse(), item), item) * parent_transform.inverse();
+ Geom::Matrix parent2dt = sp_item_i2d_affine(SP_ITEM(SP_OBJECT_PARENT (item)));
+ Geom::Matrix t = parent2dt * affine * parent2dt.inverse();
+ Geom::Matrix t_inv = t.inverse();
Geom::Matrix result = t_inv * item->transform * t;
if ((prefs_parallel || prefs_unmoved) && affine.isTranslation()) {
diff --git a/src/sp-item.cpp b/src/sp-item.cpp
index 519ed2a45f79bcbfae4169c7515e362cb7e2f3d2..fb13b1770bf1d36e4fca810003d960c9f7b2110e 100644 (file)
--- a/src/sp-item.cpp
+++ b/src/sp-item.cpp
#include "document.h"
#include "uri.h"
#include "inkscape.h"
+#include "desktop.h"
#include "desktop-handles.h"
#include "style.h"
@@ -978,6 +979,7 @@ void sp_item_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPref
clips_and_masks.push_back(SP_OBJECT(item->clip_ref->getObject()));
clips_and_masks.push_back(SP_OBJECT(item->mask_ref->getObject()));
+ SPDesktop *desktop = inkscape_active_desktop();
for (std::list<SPObject const *>::const_iterator o = clips_and_masks.begin(); o != clips_and_masks.end(); o++) {
if (*o) {
// obj is a group object, the children are the actual clippers
@@ -990,7 +992,7 @@ void sp_item_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPref
for (std::vector<Geom::Point>::const_iterator p_orig = p_clip_or_mask.begin(); p_orig != p_clip_or_mask.end(); p_orig++) {
// All snappoints are in desktop coordinates, but the item's transformation is
// in document coordinates. Hence the awkward construction below
- *p = (*p_orig) * matrix_to_desktop (matrix_from_desktop (item->transform, item), item);
+ *p = desktop->dt2doc(*p_orig) * sp_item_i2d_affine(item);
}
}
}
g_assert(item != NULL);
g_assert(SP_IS_ITEM(item));
- Geom::Matrix const ret( sp_item_i2doc_affine(item)
- * Geom::Scale(1, -1)
- * Geom::Translate(0, sp_document_height(SP_OBJECT_DOCUMENT(item))) );
- return ret;
-}
-
-/**
- * Converts a matrix \a m into the desktop coords of the \a item.
- * Will become a noop when we eliminate the coordinate flipping.
- */
-Geom::Matrix matrix_to_desktop(Geom::Matrix const m, SPItem const *item)
-{
- Geom::Matrix const ret(m
- * Geom::Translate(0, -sp_document_height(SP_OBJECT_DOCUMENT(item)))
- * Geom::Scale(1, -1));
- return ret;
-}
-
-/**
- * Converts a matrix \a m from the desktop coords of the \a item.
- * Will become a noop when we eliminate the coordinate flipping.
- */
-Geom::Matrix matrix_from_desktop(Geom::Matrix const m, SPItem const *item)
-{
- Geom::Matrix const ret(Geom::Scale(1, -1)
- * Geom::Translate(0, sp_document_height(SP_OBJECT_DOCUMENT(item)))
- * m);
- return ret;
+ SPDesktop *desktop = inkscape_active_desktop();
+ return sp_item_i2doc_affine(item) * desktop->doc2dt();
}
void sp_item_set_i2d_affine(SPItem *item, Geom::Matrix const &i2dt)
diff --git a/src/sp-item.h b/src/sp-item.h
index 03fec93e62892be3fd4d3c7df14b5ca109967103..f1ec6f434522e1c90e1952601e292c90221ac80b 100644 (file)
--- a/src/sp-item.h
+++ b/src/sp-item.h
Geom::Matrix sp_item_i2doc_affine(SPItem const *item);
-Geom::Matrix matrix_to_desktop (Geom::Matrix m, SPItem const *item);
-Geom::Matrix matrix_from_desktop (Geom::Matrix m, SPItem const *item);
-
/* fixme: - these are evil, but OK */
/* Fill *TRANSFORM with the item-to-desktop transform. See doc/coordinates.txt