Code

Add CMakeLists for the filters directory.
[inkscape.git] / src / sp-item.cpp
index 01f266594729dbee5f9ad93d5ba808a60701d3b8..8971c3abbd240951e11d07d2012ac7ec74589e6a 100644 (file)
@@ -33,6 +33,7 @@
 #include "document.h"
 #include "uri.h"
 #include "inkscape.h"
+#include "desktop.h"
 #include "desktop-handles.h"
 
 #include "style.h"
@@ -46,6 +47,7 @@
 #include "sp-item-rm-unsatisfied-cns.h"
 #include "sp-pattern.h"
 #include "sp-switch.h"
+#include "sp-guide-constraint.h"
 #include "gradient-chemistry.h"
 #include "preferences.h"
 #include "conn-avoid-ref.h"
@@ -175,6 +177,8 @@ void SPItem::init() {
 
     this->avoidRef = new SPAvoidRef(this);
 
+    new (&this->constraints) std::vector<SPGuideConstraint>();
+
     new (&this->_transformed_signal) sigc::signal<void, Geom::Matrix const *, SPItem *>();
 }
 
@@ -978,6 +982,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 +995,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);
                     }
                 }
             }
@@ -1045,8 +1050,14 @@ sp_item_description(SPItem *item)
             g_free (s);
             s = snew;
         }
-        if (SP_OBJECT_STYLE(item) && SP_OBJECT_STYLE(item)->filter.href) {
-            gchar *snew = g_strdup_printf (_("%s; <i>filtered</i>"), s);
+        if (SP_OBJECT_STYLE(item) && SP_OBJECT_STYLE(item)->filter.href && SP_OBJECT_STYLE(item)->filter.href->getObject()) {
+            const gchar *label = SP_OBJECT_STYLE(item)->filter.href->getObject()->label();
+            gchar *snew;
+            if (label) {
+                snew = g_strdup_printf (_("%s; <i>filtered (%s)</i>"), s, label);
+            } else {
+                snew = g_strdup_printf (_("%s; <i>filtered</i>"), s);
+            }
             g_free (s);
             s = snew;
         }
@@ -1376,19 +1387,6 @@ sp_item_adjust_livepatheffect (SPItem *item, Geom::Matrix const &postmul, bool s
     }
 }
 
-/**
- * A temporary wrapper for the next function accepting the Geom::Matrix
- * instead of Geom::Matrix
- */
-void
-sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, Geom::Matrix const *transform, Geom::Matrix const *adv)
-{
-    if (transform == NULL)
-        sp_item_write_transform(item, repr, Geom::identity(), adv);
-    else
-        sp_item_write_transform(item, repr, *transform, adv);
-}
-
 /**
  * Set a new transform on an object.
  *
@@ -1528,8 +1526,9 @@ i2anc_affine(SPObject const *object, SPObject const *const ancestor) {
     while ( object != ancestor && SP_IS_ITEM(object) ) {
         if (SP_IS_ROOT(object)) {
             ret *= SP_ROOT(object)->c2p;
+        } else {
+            ret *= SP_ITEM(object)->transform;
         }
-        ret *= SP_ITEM(object)->transform;
         object = SP_OBJECT_PARENT(object);
     }
     return ret;
@@ -1556,30 +1555,8 @@ Geom::Matrix sp_item_i2doc_affine(SPItem const *item)
 }
 
 /**
- * Returns the accumulated transformation of the item and all its ancestors, but excluding root's viewport.
- * Used in path operations mostly.
- * \pre (item != NULL) and SP_IS_ITEM(item).
+ * Returns the transformation from item to desktop coords
  */
-Geom::Matrix sp_item_i2root_affine(SPItem const *item)
-{
-    g_assert(item != NULL);
-    g_assert(SP_IS_ITEM(item));
-
-    Geom::Matrix ret(Geom::identity());
-    g_assert(ret.isIdentity());
-    while ( NULL != SP_OBJECT_PARENT(item) ) {
-        ret *= item->transform;
-        item = SP_ITEM(SP_OBJECT_PARENT(item));
-    }
-    g_assert(SP_IS_ROOT(item));
-
-    ret *= item->transform;
-
-    return ret;
-}
-
-/* fixme: This is EVIL!!! */
-// fix this note: why/what evil? :)
 Geom::Matrix sp_item_i2d_affine(SPItem const *item)
 {
     g_assert(item != NULL);
@@ -1591,42 +1568,6 @@ Geom::Matrix sp_item_i2d_affine(SPItem const *item)
     return ret;
 }
 
-// same as i2d but with i2root instead of i2doc
-Geom::Matrix sp_item_i2r_affine(SPItem const *item)
-{
-    g_assert(item != NULL);
-    g_assert(SP_IS_ITEM(item));
-
-    Geom::Matrix const ret( sp_item_i2root_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;
-}
-
 void sp_item_set_i2d_affine(SPItem *item, Geom::Matrix const &i2dt)
 {
     g_return_if_fail( item != NULL );
@@ -1645,6 +1586,9 @@ void sp_item_set_i2d_affine(SPItem *item, Geom::Matrix const &i2dt)
 }
 
 
+/**
+ * should rather be named "sp_item_d2i_affine" to match "sp_item_i2d_affine" (or vice versa)
+ */
 Geom::Matrix
 sp_item_dt2i_affine(SPItem const *item)
 {