X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fsp-use.cpp;h=36372e67b4f3f8a5a0c7fadb0d98a6e994cb93b9;hb=ea479a317d3fb2890308a1cc99ee730dd7b76de8;hp=8b63217455f280c7f4d4452967cdc8302126d689;hpb=fdde98ebc36d9a07a021cf1b7d1b90ebbd6dbe6e;p=inkscape.git diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 8b6321745..36372e67b 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -22,7 +22,7 @@ #include #include -#include "libnr/nr-matrix-translate-ops.h" +#include <2geom/transforms.h> #include #include "display/nr-arena-group.h" #include "attributes.h" @@ -32,7 +32,7 @@ #include "uri.h" #include "print.h" #include "xml/repr.h" -#include "prefs-utils.h" +#include "preferences.h" #include "style.h" #include "sp-symbol.h" #include "sp-use.h" @@ -52,7 +52,7 @@ static void sp_use_update(SPObject *object, SPCtx *ctx, guint flags); static void sp_use_modified(SPObject *object, guint flags); static void sp_use_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); -static void sp_use_snappoints(SPItem const *item, SnapPointsIter p); +static void sp_use_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs); static void sp_use_print(SPItem *item, SPPrintContext *ctx); static gchar *sp_use_description(SPItem *item); static NRArenaItem *sp_use_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags); @@ -64,7 +64,7 @@ static void sp_use_delete_self(SPObject *deleted, SPUse *self); static SPItemClass *parent_class; -//void m_print(gchar *say, NR::Matrix m) +//void m_print(gchar *say, Geom::Matrix m) //{ g_print("%s %g %g %g %g %g %g\n", say, m[0], m[1], m[2], m[3], m[4], m[5]); } GType @@ -299,7 +299,7 @@ sp_use_print(SPItem *item, SPPrintContext *ctx) SPUse *use = SP_USE(item); if ((use->x._set && use->x.computed != 0) || (use->y._set && use->y.computed != 0)) { - NR::Matrix tp(NR::translate(use->x.computed, use->y.computed)); + Geom::Matrix tp(Geom::Translate(use->x.computed, use->y.computed)); sp_print_bind(ctx, tp, 1.0); translated = true; } @@ -354,9 +354,9 @@ sp_use_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags) if (ac) { nr_arena_item_add_child(ai, ac, NULL); } - NR::translate t(use->x.computed, + Geom::Translate t(use->x.computed, use->y.computed); - nr_arena_group_set_child_transform(NR_ARENA_GROUP(ai), NR::Matrix(t)); + nr_arena_group_set_child_transform(NR_ARENA_GROUP(ai), Geom::Matrix(t)); } return ai; @@ -399,7 +399,7 @@ sp_use_root(SPUse *use) * Returns the effective transform that goes from the ultimate original to given SPUse, both ends * included. */ -NR::Matrix +Geom::Matrix sp_use_get_root_transform(SPUse *use) { //track the ultimate source of a chain of uses @@ -414,7 +414,7 @@ sp_use_get_root_transform(SPUse *use) //calculate the accummulated transform, starting from the original - NR::Matrix t(NR::identity()); + Geom::Matrix t(Geom::identity()); for (GSList *i = chain; i != NULL; i = i->next) { SPItem *i_tem = SP_ITEM(i->data); @@ -424,7 +424,7 @@ sp_use_get_root_transform(SPUse *use) if (SP_IS_USE(i_tem)) { SPUse *i_use = SP_USE(i_tem); if ((i_use->x._set && i_use->x.computed != 0) || (i_use->y._set && i_use->y.computed != 0)) { - t = t * NR::translate(i_use->x._set ? i_use->x.computed : 0, i_use->y._set ? i_use->y.computed : 0); + t = t * Geom::Translate(i_use->x._set ? i_use->x.computed : 0, i_use->y._set ? i_use->y.computed : 0); } } @@ -439,12 +439,12 @@ sp_use_get_root_transform(SPUse *use) * Returns the transform that leads to the use from its immediate original. * Does not inlcude the original's transform if any. */ -NR::Matrix +Geom::Matrix sp_use_get_parent_transform(SPUse *use) { - NR::Matrix t(NR::identity()); + Geom::Matrix t(Geom::identity()); if ((use->x._set && use->x.computed != 0) || (use->y._set && use->y.computed != 0)) { - t *= NR::translate(use->x._set ? use->x.computed : 0, + t *= Geom::Translate(use->x._set ? use->x.computed : 0, use->y._set ? use->y.computed : 0); } @@ -458,7 +458,7 @@ sp_use_get_parent_transform(SPUse *use) * clone's transform. */ static void -sp_use_move_compensate(NR::Matrix const *mp, SPItem */*original*/, SPUse *self) +sp_use_move_compensate(Geom::Matrix const *mp, SPItem */*original*/, SPUse *self) { // the clone is orphaned; or this is not a real use, but a clone of another use; // we skip it, otherwise duplicate compensation will occur @@ -471,31 +471,32 @@ sp_use_move_compensate(NR::Matrix const *mp, SPItem */*original*/, SPUse *self) return; } - guint mode = prefs_get_int_attribute("options.clonecompensation", "value", SP_CLONE_COMPENSATION_PARALLEL); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + guint mode = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_PARALLEL); // user wants no compensation if (mode == SP_CLONE_COMPENSATION_NONE) return; - NR::Matrix m(*mp); + Geom::Matrix m(*mp); // this is not a simple move, do not try to compensate - if (!(m.is_translation())) + if (!(m.isTranslation())) return; // restore item->transform field from the repr, in case it was changed by seltrans sp_object_read_attr (SP_OBJECT (self), "transform"); - NR::Matrix t = sp_use_get_parent_transform(self); - NR::Matrix clone_move = t.inverse() * m * t; + Geom::Matrix t = sp_use_get_parent_transform(self); + Geom::Matrix clone_move = t.inverse() * m * t; // calculate the compensation matrix and the advertized movement matrix - NR::Matrix advertized_move; + Geom::Matrix advertized_move; if (mode == SP_CLONE_COMPENSATION_PARALLEL) { clone_move = clone_move.inverse() * m; advertized_move = m; } else if (mode == SP_CLONE_COMPENSATION_UNMOVED) { clone_move = clone_move.inverse(); - advertized_move.set_identity(); + advertized_move.setIdentity(); } else { g_assert_not_reached(); } @@ -556,7 +557,8 @@ sp_use_delete_self(SPObject */*deleted*/, SPUse *self) return; } - guint const mode = prefs_get_int_attribute("options.cloneorphans", "value", + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + guint const mode = prefs->getInt("/options/cloneorphans/value", SP_CLONE_ORPHANS_UNLINK); if (mode == SP_CLONE_ORPHANS_UNLINK) { @@ -603,7 +605,7 @@ sp_use_update(SPObject *object, SPCtx *ctx, unsigned flags) cctx.vp.y0 = 0.0; cctx.vp.x1 = use->width.computed; cctx.vp.y1 = use->height.computed; - cctx.i2vp = NR::identity(); + cctx.i2vp = Geom::identity(); flags&=~SP_OBJECT_USER_MODIFIED_FLAG_B; if (use->child) { @@ -623,7 +625,7 @@ sp_use_update(SPObject *object, SPCtx *ctx, unsigned flags) /* As last step set additional transform of arena group */ for (SPItemView *v = item->display; v != NULL; v = v->next) { - NR::Matrix t(NR::translate(use->x.computed, use->y.computed)); + Geom::Matrix t(Geom::Translate(use->x.computed, use->y.computed)); nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->arenaitem), t); } } @@ -671,7 +673,7 @@ sp_use_unlink(SPUse *use) g_return_val_if_fail(orig, NULL); // Calculate the accumulated transform, starting from the original. - NR::Matrix t = sp_use_get_root_transform(use); + Geom::Matrix t = sp_use_get_root_transform(use); Inkscape::XML::Node *copy = NULL; if (SP_IS_SYMBOL(orig)) { // make a group, copy children @@ -724,7 +726,7 @@ sp_use_unlink(SPUse *use) SPItem *item = SP_ITEM(unlinked); // Set the accummulated transform. { - NR::Matrix nomove(NR::identity()); + Geom::Matrix nomove(Geom::identity()); // Advertise ourselves as not moving. sp_item_write_transform(item, SP_OBJECT_REPR(item), t, &nomove); } @@ -739,7 +741,7 @@ sp_use_get_original(SPUse *use) } static void -sp_use_snappoints(SPItem const *item, SnapPointsIter p) +sp_use_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::SnapPreferences const *snapprefs) { g_assert (item != NULL); g_assert (SP_IS_ITEM(item)); @@ -751,7 +753,7 @@ sp_use_snappoints(SPItem const *item, SnapPointsIter p) SPItemClass const &item_class = *(SPItemClass const *) G_OBJECT_GET_CLASS(root); if (item_class.snappoints) { - item_class.snappoints(root, p); + item_class.snappoints(root, p, snapprefs); } }