diff options
| author | Diederik van Lierop <mail@diedenrezi.nl> | 2008-07-21 20:38:09 +0000 |
|---|---|---|
| committer | dvlierop2 <dvlierop2@users.sourceforge.net> | 2008-07-21 20:38:09 +0000 |
| commit | f3717986550c5c21880a7347ad02a6a9b944d76c (patch) | |
| tree | 70e2836396bac20fae25a01bcaac64e9f121ec9a /src/sp-item.cpp | |
| parent | cleanup includes (diff) | |
| download | inkscape-f3717986550c5c21880a7347ad02a6a9b944d76c.tar.gz inkscape-f3717986550c5c21880a7347ad02a6a9b944d76c.zip | |
Implement snapping of clipping paths and masks
(bzr r6386)
Diffstat (limited to '')
| -rw-r--r-- | src/sp-item.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 81e75ad7c..c888bc195 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -933,16 +933,43 @@ static void sp_item_private_snappoints(SPItem const *item, SnapPointsIter p) void sp_item_snappoints(SPItem const *item, bool includeItemCenter, SnapPointsIter p) { - g_assert (item != NULL); + g_assert (item != NULL); g_assert (SP_IS_ITEM(item)); + // Get the snappoints of the item SPItemClass const &item_class = *(SPItemClass const *) G_OBJECT_GET_CLASS(item); if (item_class.snappoints) { item_class.snappoints(item, p); } + // Get the snappoints at the item's center if (includeItemCenter) { *p = item->getCenter(); + } + + // Get the snappoints of clipping paths and mask, if any + std::list<SPObject const *> clips_and_masks; + + clips_and_masks.push_back(SP_OBJECT(item->clip_ref->getObject())); + clips_and_masks.push_back(SP_OBJECT(item->mask_ref->getObject())); + + 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 + for (SPObject *child = (*o)->children ; child ; child = child->next) { + if (SP_IS_ITEM(child)) { + std::vector<NR::Point> p_clip_or_mask; + // Please note the recursive call here! + sp_item_snappoints(SP_ITEM(child), includeItemCenter, SnapPointsIter(p_clip_or_mask)); + // Take into account the transformation of the item being clipped or masked + for (std::vector<NR::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) * from_2geom(matrix_to_desktop (matrix_from_desktop (to_2geom(item->transform), item), item)); + } + } + } + } } } |
