From: speleo3 Date: Mon, 8 Dec 2008 21:54:37 +0000 (+0000) Subject: Make all tools consider full parent transform (up to document, not just up to root) X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8b2786c73392c85abafbd29307f50a47c98d1409;p=inkscape.git Make all tools consider full parent transform (up to document, not just up to root) See http://wiki.inkscape.org/wiki/index.php/ViewBoxToDo --- diff --git a/src/arc-context.cpp b/src/arc-context.cpp index 50d348e7b..d7982e979 100644 --- a/src/arc-context.cpp +++ b/src/arc-context.cpp @@ -429,7 +429,7 @@ static void sp_arc_drag(SPArcContext *ac, Geom::Point pt, guint state) ac->item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr)); Inkscape::GC::release(repr); - ac->item->transform = SP_ITEM(desktop->currentRoot())->getRelativeTransform(desktop->currentLayer()); + ac->item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); ac->item->updateRepr(); sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5); diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 8260456d4..372918b80 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -909,7 +909,7 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc) } /* Now we have to go back to item coordinates at last */ - c->transform(sp_desktop_dt2root_affine(SP_EVENT_CONTEXT_DESKTOP(cc))); + c->transform(sp_desktop_dt2doc_affine(SP_EVENT_CONTEXT_DESKTOP(cc))); SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); SPDocument *doc = sp_desktop_document(desktop); @@ -931,7 +931,7 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc) cc->newconn = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr)); cc->selection->set(repr); Inkscape::GC::release(repr); - cc->newconn->transform = i2i_affine(desktop->currentRoot(), desktop->currentLayer()); + cc->newconn->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); cc->newconn->updateRepr(); bool connection = false; diff --git a/src/context-fns.cpp b/src/context-fns.cpp index 399e85154..54b07a02a 100644 --- a/src/context-fns.cpp +++ b/src/context-fns.cpp @@ -207,8 +207,8 @@ Geom::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item desktop->snapindicator->set_new_snaptarget(snappoint); } - p[0] = sp_desktop_dt2root_xy_point(desktop, p[0]); - p[1] = sp_desktop_dt2root_xy_point(desktop, p[1]); + p[0] = sp_desktop_dt2doc_xy_point(desktop, p[0]); + p[1] = sp_desktop_dt2doc_xy_point(desktop, p[1]); return Geom::Rect(Geom::Point(MIN(p[0][Geom::X], p[1][Geom::X]), MIN(p[0][Geom::Y], p[1][Geom::Y])), Geom::Point(MAX(p[0][Geom::X], p[1][Geom::X]), MAX(p[0][Geom::Y], p[1][Geom::Y]))); diff --git a/src/desktop-affine.cpp b/src/desktop-affine.cpp index 25c5c99b8..95640c957 100644 --- a/src/desktop-affine.cpp +++ b/src/desktop-affine.cpp @@ -13,10 +13,21 @@ */ #include "desktop.h" -#include "document.h" -#include "sp-root.h" +//#include "document.h" +//#include "sp-root.h" //#include "libnr/nr-matrix-ops.h" +Geom::Matrix const sp_desktop_dt2doc_affine (SPDesktop const *dt) +{ + return dt->doc2dt().inverse(); +} + +Geom::Point sp_desktop_dt2doc_xy_point(SPDesktop const *dt, Geom::Point const p) +{ + return p * sp_desktop_dt2doc_affine(dt); +} + +#if 0 Geom::Matrix const sp_desktop_root2dt_affine (SPDesktop const *dt) { SPRoot const *root = SP_ROOT(SP_DOCUMENT_ROOT(dt->doc())); @@ -37,4 +48,5 @@ Geom::Point sp_desktop_dt2root_xy_point(SPDesktop const *dt, Geom::Point const p { return p * sp_desktop_dt2root_affine(dt); } +#endif diff --git a/src/desktop-affine.h b/src/desktop-affine.h index a5e84d5c7..87d31c751 100644 --- a/src/desktop-affine.h +++ b/src/desktop-affine.h @@ -16,11 +16,17 @@ #include "forward.h" #include <2geom/forward.h> +Geom::Matrix const sp_desktop_dt2doc_affine (SPDesktop const *dt); + +Geom::Point sp_desktop_dt2doc_xy_point(SPDesktop const *dt, Geom::Point const p); + +#if 0 Geom::Matrix const sp_desktop_root2dt_affine(SPDesktop const *dt); Geom::Matrix const sp_desktop_dt2root_affine(SPDesktop const *dt); Geom::Point sp_desktop_root2dt_xy_point(SPDesktop const *dt, const Geom::Point p); Geom::Point sp_desktop_dt2root_xy_point(SPDesktop const *dt, const Geom::Point p); +#endif #endif diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 74b6e8d52..7fdda437c 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -651,7 +651,7 @@ spdc_flush_white(SPDrawContext *dc, SPCurve *gc) /* Now we have to go back to item coordinates at last */ c->transform( dc->white_item ? sp_item_dt2i_affine(dc->white_item) - : to_2geom(sp_desktop_dt2root_affine(SP_EVENT_CONTEXT_DESKTOP(dc))) ); + : to_2geom(sp_desktop_dt2doc_affine(SP_EVENT_CONTEXT_DESKTOP(dc))) ); SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(dc); SPDocument *doc = sp_desktop_document(desktop); @@ -688,7 +688,7 @@ spdc_flush_white(SPDrawContext *dc, SPCurve *gc) dc->selection->set(repr); Inkscape::GC::release(repr); - item->transform = i2i_affine(desktop->currentRoot(), desktop->currentLayer()); + item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); item->updateRepr(); } diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index e22520ecb..5ad5f0f3f 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -980,10 +980,10 @@ set_to_accumulated(SPDynaDrawContext *dc, bool unionize) SPItem *item=SP_ITEM(desktop->currentLayer()->appendChildRepr(dc->repr)); Inkscape::GC::release(dc->repr); - item->transform = SP_ITEM(desktop->currentRoot())->getRelativeTransform(desktop->currentLayer()); + item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); item->updateRepr(); } - Geom::PathVector pathv = dc->accumulated->get_pathvector() * sp_desktop_dt2root_affine(desktop); + Geom::PathVector pathv = dc->accumulated->get_pathvector() * sp_desktop_dt2doc_affine(desktop); gchar *str = sp_svg_write_path(pathv); g_assert( str != NULL ); dc->repr->setAttribute("d", str); diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index 96d6b5591..17e69c6ac 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -724,10 +724,10 @@ set_to_accumulated(SPEraserContext *dc) SPItem *item=SP_ITEM(desktop->currentLayer()->appendChildRepr(dc->repr)); Inkscape::GC::release(dc->repr); - item->transform = SP_ITEM(desktop->currentRoot())->getRelativeTransform(desktop->currentLayer()); + item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); item->updateRepr(); } - Geom::PathVector pathv = dc->accumulated->get_pathvector() * sp_desktop_dt2root_affine(desktop); + Geom::PathVector pathv = dc->accumulated->get_pathvector() * sp_desktop_dt2doc_affine(desktop); gchar *str = sp_svg_write_path(pathv); g_assert( str != NULL ); dc->repr->setAttribute("d", str); diff --git a/src/rect-context.cpp b/src/rect-context.cpp index 5d2a353d9..1d8e8c12b 100644 --- a/src/rect-context.cpp +++ b/src/rect-context.cpp @@ -479,7 +479,7 @@ static void sp_rect_drag(SPRectContext &rc, Geom::Point const pt, guint state) rc.item = (SPItem *) desktop->currentLayer()->appendChildRepr(repr); Inkscape::GC::release(repr); - rc.item->transform = SP_ITEM(desktop->currentRoot())->getRelativeTransform(desktop->currentLayer()); + rc.item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); rc.item->updateRepr(); sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index f6920c2a3..4e93c4832 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -2106,7 +2106,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) // bottommost object, after sorting SPObject *parent = SP_OBJECT_PARENT (items->data); - Geom::Matrix parent_transform (sp_item_i2root_affine(SP_ITEM(parent))); + Geom::Matrix parent_transform (sp_item_i2doc_affine(SP_ITEM(parent))); // remember the position of the first item gint pos = SP_OBJECT_REPR (items->data)->position(); diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index e0f9b3472..9280b604f 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -697,8 +697,8 @@ SPItem *create_flowtext_with_internal_frame (SPDesktop *desktop, Geom::Point p0, SPObject *rect = doc->getObjectByRepr(rect_repr); - p0 = sp_desktop_dt2root_xy_point(desktop, p0); - p1 = sp_desktop_dt2root_xy_point(desktop, p1); + p0 = sp_desktop_dt2doc_xy_point(desktop, p0); + p1 = sp_desktop_dt2doc_xy_point(desktop, p1); using Geom::X; using Geom::Y; Geom::Coord const x0 = MIN(p0[X], p1[X]); @@ -724,6 +724,8 @@ SPItem *create_flowtext_with_internal_frame (SPDesktop *desktop, Geom::Point p0, Inkscape::GC::release(para_repr); Inkscape::GC::release(rect_repr); + ft_item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); + return ft_item; } diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp index 090c8d276..9944e86b4 100644 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@ -433,7 +433,7 @@ sp_spiral_drag(SPSpiralContext *sc, Geom::Point p, guint state) sc->item = (SPItem *) desktop->currentLayer()->appendChildRepr(repr); Inkscape::GC::release(repr); - sc->item->transform = SP_ITEM(desktop->currentRoot())->getRelativeTransform(desktop->currentLayer()); + sc->item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); sc->item->updateRepr(); sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5); @@ -444,8 +444,8 @@ sp_spiral_drag(SPSpiralContext *sc, Geom::Point p, guint state) Geom::Point pt2g = to_2geom(p); m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, pt2g); - Geom::Point const p0 = to_2geom(sp_desktop_dt2root_xy_point(desktop, sc->center)); - Geom::Point const p1 = to_2geom(sp_desktop_dt2root_xy_point(desktop, from_2geom(pt2g))); + Geom::Point const p0 = to_2geom(sp_desktop_dt2doc_xy_point(desktop, sc->center)); + Geom::Point const p1 = to_2geom(sp_desktop_dt2doc_xy_point(desktop, from_2geom(pt2g))); SPSpiral *spiral = SP_SPIRAL(sc->item); diff --git a/src/star-context.cpp b/src/star-context.cpp index a18170346..33224d7fd 100644 --- a/src/star-context.cpp +++ b/src/star-context.cpp @@ -444,7 +444,7 @@ static void sp_star_drag(SPStarContext *sc, Geom::Point p, guint state) sc->item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr)); Inkscape::GC::release(repr); - sc->item->transform = SP_ITEM(desktop->currentRoot())->getRelativeTransform(desktop->currentLayer()); + sc->item->transform = sp_item_i2doc_affine(SP_ITEM(desktop->currentLayer())).inverse(); sc->item->updateRepr(); sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5); @@ -456,8 +456,8 @@ static void sp_star_drag(SPStarContext *sc, Geom::Point p, guint state) Geom::Point pt2g = to_2geom(p); m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, pt2g); - Geom::Point const p0 = to_2geom(sp_desktop_dt2root_xy_point(desktop, sc->center)); - Geom::Point const p1 = to_2geom(sp_desktop_dt2root_xy_point(desktop, from_2geom(pt2g))); + Geom::Point const p0 = to_2geom(sp_desktop_dt2doc_xy_point(desktop, sc->center)); + Geom::Point const p1 = to_2geom(sp_desktop_dt2doc_xy_point(desktop, from_2geom(pt2g))); SPStar *star = SP_STAR(sc->item); diff --git a/src/text-context.cpp b/src/text-context.cpp index e87e87abe..96fa716cf 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -511,18 +511,7 @@ sp_text_context_setup_text(SPTextContext *tc) /* yes, it's immediate .. why does it matter? */ sp_desktop_selection(ec->desktop)->set(text_item); Inkscape::GC::release(rtext); - text_item->transform = SP_ITEM(ec->desktop->currentRoot())->getRelativeTransform(ec->desktop->currentLayer()); - - // bug #168777 (consider root transform and viewBox) - // TODO: more generic solution desirable - // see http://wiki.inkscape.org/wiki/index.php/ViewBoxToDo - Geom::Matrix root_transform = sp_item_i2doc_affine(SP_ITEM(ec->desktop->currentRoot())); - if (!root_transform.isIdentity()) { - text_item->transform = root_transform.inverse() * text_item->transform; - Geom::Point pdoc = tc->pdoc * root_transform; - sp_repr_set_svg_double(rtext, "x", pdoc[Geom::X]); - sp_repr_set_svg_double(rtext, "y", pdoc[Geom::Y]); - } + text_item->transform = sp_item_i2doc_affine(SP_ITEM(ec->desktop->currentLayer())).inverse(); text_item->updateRepr(); sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, @@ -697,7 +686,7 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons /* Button 1, set X & Y & new item */ sp_desktop_selection(desktop)->clear(); Geom::Point dtp = desktop->w2d(Geom::Point(event->button.x, event->button.y)); - tc->pdoc = sp_desktop_dt2root_xy_point(desktop, dtp); + tc->pdoc = sp_desktop_dt2doc_xy_point(desktop, dtp); tc->show = TRUE; tc->phase = 1;