From e77e2e02d8ab186389f86e48b1834d95f51cf68d Mon Sep 17 00:00:00 2001 From: johanengelen Date: Thu, 12 Jun 2008 20:20:51 +0000 Subject: [PATCH] change NR::Matrix to Geom:: for many sp_item_xxx_affine functions --- src/arc-context.cpp | 2 +- src/box3d.cpp | 4 +- src/conn-avoid-ref.cpp | 2 +- src/connector-context.cpp | 8 +- src/desktop-style.cpp | 10 +- src/dialogs/clonetiler.cpp | 2 +- src/dialogs/export.cpp | 2 +- src/dialogs/stroke-style.cpp | 4 +- src/dialogs/tiledialog.cpp | 16 +-- src/dialogs/unclump.cpp | 8 +- src/draw-context.cpp | 6 +- src/dyna-draw-context.cpp | 2 +- src/extension/internal/cairo-renderer.cpp | 12 +-- src/extension/internal/emf-win32-print.cpp | 2 +- src/extension/internal/odf.cpp | 3 +- src/extension/internal/pdf-cairo.cpp | 4 +- src/extension/internal/pov-out.cpp | 2 +- src/extension/internal/ps.cpp | 2 +- src/filter-chemistry.cpp | 4 +- src/flood-context.cpp | 2 +- src/gradient-chemistry.cpp | 4 +- src/interface.cpp | 2 +- src/knot-holder-entity.cpp | 2 +- src/knotholder.cpp | 6 +- src/live_effects/lpe-perp_bisector.cpp | 2 +- src/live_effects/lpegroupbbox.cpp | 2 +- .../parameter/pointparam-knotholder.cpp | 6 +- src/main.cpp | 6 +- src/node-context.cpp | 2 +- src/nodepath.cpp | 2 +- src/object-edit.cpp | 6 +- src/object-snapper.cpp | 2 +- src/selcue.cpp | 2 +- src/selection-chemistry.cpp | 24 ++--- src/selection.cpp | 2 +- src/seltrans.cpp | 8 +- src/shape-editor.cpp | 6 +- src/sp-conn-end-pair.cpp | 2 +- src/sp-conn-end.cpp | 6 +- src/sp-ellipse.cpp | 2 +- src/sp-flowregion.cpp | 12 +-- src/sp-flowtext.cpp | 2 +- src/sp-image.cpp | 2 +- src/sp-item-notify-moveto.cpp | 2 +- src/sp-item-transform.cpp | 8 +- src/sp-item.cpp | 97 +++++++++++-------- src/sp-item.h | 23 +++-- src/sp-path.cpp | 4 +- src/sp-rect.cpp | 4 +- src/sp-shape.cpp | 4 +- src/sp-text.cpp | 4 +- src/sp-tspan.cpp | 2 +- src/splivarot.cpp | 8 +- src/text-chemistry.cpp | 2 +- src/text-context.cpp | 6 +- src/text-editing.cpp | 10 +- src/tweak-context.cpp | 8 +- src/ui/clipboard.cpp | 2 +- src/ui/dialog/align-and-distribute.cpp | 4 +- src/ui/dialog/filedialogimpl-win32.cpp | 2 +- src/widgets/icon.cpp | 2 +- 61 files changed, 206 insertions(+), 193 deletions(-) diff --git a/src/arc-context.cpp b/src/arc-context.cpp index e1cbaf1cc..b8f7e30e6 100644 --- a/src/arc-context.cpp +++ b/src/arc-context.cpp @@ -450,7 +450,7 @@ static void sp_arc_drag(SPArcContext *ac, NR::Point pt, guint state) NR::Point c = r.midpoint(); if (!ctrl_save) { if (fabs(dir[NR::X]) > 1E-6 && fabs(dir[NR::Y]) > 1E-6) { - NR::Matrix const i2d (sp_item_i2d_affine (ac->item)); + NR::Matrix const i2d (from_2geom(sp_item_i2d_affine (ac->item))); NR::Point new_dir = pt * i2d - c; new_dir[NR::X] *= dir[NR::Y] / dir[NR::X]; double lambda = NR::L2(new_dir) / dir[NR::Y]; diff --git a/src/box3d.cpp b/src/box3d.cpp index f4921bc1a..2a8d24167 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -407,7 +407,7 @@ box3d_get_corner_screen (SPBox3D const *box, guint id, bool item_coords) { if (!box3d_get_perspective(box)) { return NR::Point (NR_HUGE, NR_HUGE); } - NR::Matrix const i2d (sp_item_i2d_affine (SP_ITEM(box))); + NR::Matrix const i2d (from_2geom(sp_item_i2d_affine (SP_ITEM(box)))); if (item_coords) { return box3d_get_perspective(box)->tmat.image(proj_corner).affine() * i2d.inverse(); } else { @@ -431,7 +431,7 @@ box3d_get_center_screen (SPBox3D *box) { if (!box3d_get_perspective(box)) { return NR::Point (NR_HUGE, NR_HUGE); } - NR::Matrix const i2d (sp_item_i2d_affine (SP_ITEM(box))); + NR::Matrix const i2d (from_2geom(sp_item_i2d_affine (SP_ITEM(box)))); return box3d_get_perspective(box)->tmat.image(proj_center).affine() * i2d.inverse(); } diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index e12351f75..7e764788d 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -193,7 +193,7 @@ static Avoid::Polygn avoid_item_poly(SPItem const *item) // by the sp_*_update functions, e.g., text. sp_document_ensure_up_to_date(item->document); - NR::Maybe rHull = item->getBounds(sp_item_i2doc_affine(item)); + NR::Maybe rHull = item->getBounds(from_2geom(sp_item_i2doc_affine(item))); if (!rHull) { return Avoid::newPoly(0); } diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 99eb664c0..99fcb6659 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -632,7 +632,7 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons g_assert( SP_IS_PATH(cc->clickeditem)); // Update the hidden path - NR::Matrix i2d = sp_item_i2d_affine(cc->clickeditem); + NR::Matrix i2d = from_2geom(sp_item_i2d_affine(cc->clickeditem)); NR::Matrix d2i = i2d.inverse(); SPPath *path = SP_PATH(cc->clickeditem); SPCurve *curve = (SP_SHAPE(path))->curve; @@ -930,7 +930,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 = from_2geom(i2i_affine(desktop->currentRoot(), desktop->currentLayer())); cc->newconn->updateRepr(); bool connection = false; @@ -1078,7 +1078,7 @@ endpt_handler(SPKnot */*knot*/, GdkEvent *event, SPConnectorContext *cc) // Show the red path for dragging. cc->red_curve = SP_PATH(cc->clickeditem)->curve->copy(); - NR::Matrix i2d = sp_item_i2d_affine(cc->clickeditem); + NR::Matrix i2d = from_2geom(sp_item_i2d_affine(cc->clickeditem)); cc->red_curve->transform(i2d); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(cc->red_bpath), cc->red_curve); @@ -1165,7 +1165,7 @@ cc_set_active_conn(SPConnectorContext *cc, SPItem *item) g_assert( SP_IS_PATH(item) ); SPCurve *curve = SP_SHAPE(SP_PATH(item))->curve; - NR::Matrix i2d = sp_item_i2d_affine(item); + NR::Matrix i2d = from_2geom(sp_item_i2d_affine(item)); if (cc->active_conn == item) { diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 3504dcf40..4f4344f9b 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -120,7 +120,7 @@ sp_desktop_apply_css_recursive(SPObject *o, SPCSSAttr *css, bool skip_lines) // Scale the style by the inverse of the accumulated parent transform in the paste context. { - NR::Matrix const local(sp_item_i2doc_affine(SP_ITEM(o))); + NR::Matrix const local(from_2geom(sp_item_i2doc_affine(SP_ITEM(o)))); double const ex(NR::expansion(local)); if ( ( ex != 0. ) && ( ex != 1. ) ) { @@ -394,7 +394,7 @@ stroke_average_width (GSList const *objects) if (!SP_IS_ITEM (l->data)) continue; - NR::Matrix i2d = sp_item_i2d_affine (SP_ITEM(l->data)); + NR::Matrix i2d = from_2geom(sp_item_i2d_affine (SP_ITEM(l->data))); SPObject *object = SP_OBJECT(l->data); @@ -660,7 +660,7 @@ objects_query_strokewidth (GSList *objects, SPStyle *style_res) n_stroked ++; - NR::Matrix i2d = sp_item_i2d_affine (SP_ITEM(obj)); + NR::Matrix i2d = from_2geom(sp_item_i2d_affine (SP_ITEM(obj))); double sw = style->stroke_width.computed * NR::expansion(i2d); if (prev_sw != -1 && fabs(sw - prev_sw) > 1e-3) @@ -876,7 +876,7 @@ objects_query_fontnumbers (GSList *objects, SPStyle *style_res) if (!style) continue; texts ++; - size += style->font_size.computed * NR::expansion(sp_item_i2d_affine(SP_ITEM(obj))); /// \todo FIXME: we assume non-% units here + size += style->font_size.computed * NR::expansion(from_2geom(sp_item_i2d_affine(SP_ITEM(obj)))); /// \todo FIXME: we assume non-% units here if (style->letter_spacing.normal) { if (!different && (letterspacing_prev == 0 || letterspacing_prev == letterspacing)) @@ -1211,7 +1211,7 @@ objects_query_blur (GSList *objects, SPStyle *style_res) if (!style) continue; if (!SP_IS_ITEM(obj)) continue; - NR::Matrix i2d = sp_item_i2d_affine (SP_ITEM(obj)); + NR::Matrix i2d = from_2geom(sp_item_i2d_affine (SP_ITEM(obj))); items ++; diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index 1ce08bfdf..0b433fe3b 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -1239,7 +1239,7 @@ clonetiler_apply( GtkWidget */*widget*/, void * ) x0 = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-x0", 0); y0 = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-y0", 0); } else { - NR::Maybe r = SP_ITEM(obj)->getBounds(sp_item_i2doc_affine(SP_ITEM(obj)), + NR::Maybe r = SP_ITEM(obj)->getBounds(from_2geom(sp_item_i2doc_affine(SP_ITEM(obj))), SPItem::GEOMETRIC_BBOX); /* impl: Use of GEOMETRIC_BBOX is so that the stroke of rectangles will be shared * (overlapped) rather than effectively doubled in width. diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp index b79a4150f..0e2a08eb4 100644 --- a/src/dialogs/export.cpp +++ b/src/dialogs/export.cpp @@ -1106,7 +1106,7 @@ sp_export_export_clicked (GtkButton */*button*/, GtkObject *base) } NRRect area; - sp_item_invoke_bbox(item, &area, sp_item_i2r_affine((SPItem *) item), TRUE); + sp_item_invoke_bbox(item, &area, from_2geom(sp_item_i2r_affine((SPItem *) item)), TRUE); gint width = (gint) ((area.x1 - area.x0) * dpi / PX_PER_IN + 0.5); gint height = (gint) ((area.y1 - area.y0) * dpi / PX_PER_IN + 0.5); diff --git a/src/dialogs/stroke-style.cpp b/src/dialogs/stroke-style.cpp index 70cb84a7e..f0eccb146 100644 --- a/src/dialogs/stroke-style.cpp +++ b/src/dialogs/stroke-style.cpp @@ -614,8 +614,8 @@ sp_marker_prev_new(unsigned psize, gchar const *mname, return NULL; // sandbox broken? // Find object's bbox in document - NR::Matrix const i2doc(sp_item_i2doc_affine(SP_ITEM(object))); - NR::Maybe dbox = SP_ITEM(object)->getBounds(i2doc); + Geom::Matrix const i2doc(sp_item_i2doc_affine(SP_ITEM(object))); + NR::Maybe dbox = SP_ITEM(object)->getBounds(from_2geom(i2doc)); if (!dbox) { return NULL; diff --git a/src/dialogs/tiledialog.cpp b/src/dialogs/tiledialog.cpp index 289d42c80..0c37e5ac0 100644 --- a/src/dialogs/tiledialog.cpp +++ b/src/dialogs/tiledialog.cpp @@ -49,8 +49,8 @@ sp_compare_x_position(SPItem *first, SPItem *second) using NR::X; using NR::Y; - NR::Maybe a = first->getBounds(sp_item_i2doc_affine(first)); - NR::Maybe b = second->getBounds(sp_item_i2doc_affine(second)); + NR::Maybe a = first->getBounds(from_2geom(sp_item_i2doc_affine(first))); + NR::Maybe b = second->getBounds(from_2geom(sp_item_i2doc_affine(second))); if ( !a || !b ) { // FIXME? @@ -89,8 +89,8 @@ sp_compare_x_position(SPItem *first, SPItem *second) int sp_compare_y_position(SPItem *first, SPItem *second) { - NR::Maybe a = first->getBounds(sp_item_i2doc_affine(first)); - NR::Maybe b = second->getBounds(sp_item_i2doc_affine(second)); + NR::Maybe a = first->getBounds(from_2geom(sp_item_i2doc_affine(first))); + NR::Maybe b = second->getBounds(from_2geom(sp_item_i2doc_affine(second))); if ( !a || !b ) { // FIXME? @@ -169,7 +169,7 @@ void TileDialog::Grid_Arrange () cnt=0; for (; items != NULL; items = items->next) { SPItem *item = SP_ITEM(items->data); - NR::Maybe b = item->getBounds(sp_item_i2doc_affine(item)); + NR::Maybe b = item->getBounds(from_2geom(sp_item_i2doc_affine(item))); if (!b) { continue; } @@ -211,7 +211,7 @@ void TileDialog::Grid_Arrange () const GSList *sizes = sorted; for (; sizes != NULL; sizes = sizes->next) { SPItem *item = SP_ITEM(sizes->data); - NR::Maybe b = item->getBounds(sp_item_i2doc_affine(item)); + NR::Maybe b = item->getBounds(from_2geom(sp_item_i2doc_affine(item))); if (b) { width = b->dimensions()[NR::X]; height = b->dimensions()[NR::Y]; @@ -318,7 +318,7 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h for (; current_row != NULL; current_row = current_row->next) { SPItem *item=SP_ITEM(current_row->data); Inkscape::XML::Node *repr = SP_OBJECT_REPR(item); - NR::Maybe b = item->getBounds(sp_item_i2doc_affine(item)); + NR::Maybe b = item->getBounds(from_2geom(sp_item_i2doc_affine(item))); NR::Point min; if (b) { width = b->dimensions()[NR::X]; @@ -338,7 +338,7 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h // signs are inverted between x and y due to y inversion NR::Point move = NR::Point(new_x - min[NR::X], min[NR::Y] - new_y); NR::Matrix const &affine = NR::Matrix(NR::translate(move)); - sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * affine); + sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * to_2geom(affine)); sp_item_write_transform(item, repr, item->transform, NULL); SP_OBJECT (current_row->data)->updateRepr(); cnt +=1; diff --git a/src/dialogs/unclump.cpp b/src/dialogs/unclump.cpp index eb5870d2e..73131384f 100644 --- a/src/dialogs/unclump.cpp +++ b/src/dialogs/unclump.cpp @@ -35,7 +35,7 @@ unclump_center (SPItem *item) return i->second; } - NR::Maybe r = item->getBounds(sp_item_i2d_affine(item)); + NR::Maybe r = item->getBounds(from_2geom(sp_item_i2d_affine(item))); if (r) { NR::Point const c = r->midpoint(); c_cache[SP_OBJECT_ID(item)] = c; @@ -54,7 +54,7 @@ unclump_wh (SPItem *item) if ( i != wh_cache.end() ) { wh = i->second; } else { - NR::Maybe r = item->getBounds(sp_item_i2d_affine(item)); + NR::Maybe r = item->getBounds(from_2geom(sp_item_i2d_affine(item))); if (r) { wh = r->dimensions(); wh_cache[SP_OBJECT_ID(item)] = wh; @@ -298,7 +298,7 @@ unclump_push (SPItem *from, SPItem *what, double dist) //g_print ("push %s at %g,%g from %g,%g by %g,%g, dist %g\n", SP_OBJECT_ID(what), it[NR::X],it[NR::Y], p[NR::X],p[NR::Y], by[NR::X],by[NR::Y], dist); - sp_item_set_i2d_affine(what, sp_item_i2d_affine(what) * move); + sp_item_set_i2d_affine(what, sp_item_i2d_affine(what) * to_2geom(move)); sp_item_write_transform(what, SP_OBJECT_REPR(what), what->transform, NULL); } @@ -321,7 +321,7 @@ unclump_pull (SPItem *to, SPItem *what, double dist) //g_print ("pull %s at %g,%g to %g,%g by %g,%g, dist %g\n", SP_OBJECT_ID(what), it[NR::X],it[NR::Y], p[NR::X],p[NR::Y], by[NR::X],by[NR::Y], dist); - sp_item_set_i2d_affine(what, sp_item_i2d_affine(what) * move); + sp_item_set_i2d_affine(what, sp_item_i2d_affine(what) * to_2geom(move)); sp_item_write_transform(what, SP_OBJECT_REPR(what), what->transform, NULL); } diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 7b42e2196..ce6ccc0e4 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -312,7 +312,7 @@ spdc_attach_selection(SPDrawContext *dc, Inkscape::Selection */*sel*/) /* Curve list */ /* We keep it in desktop coordinates to eliminate calculation errors */ SPCurve *norm = sp_path_get_curve_for_edit (SP_PATH(item)); - norm->transform(sp_item_i2d_affine(dc->white_item)); + norm->transform(from_2geom(sp_item_i2d_affine(dc->white_item))); g_return_if_fail( norm != NULL ); dc->white_curves = g_slist_reverse(norm->split()); norm->unref(); @@ -535,7 +535,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) + ? from_2geom(sp_item_dt2i_affine(dc->white_item)) : sp_desktop_dt2root_affine(SP_EVENT_CONTEXT_DESKTOP(dc)) )); SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(dc); @@ -569,7 +569,7 @@ spdc_flush_white(SPDrawContext *dc, SPCurve *gc) SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr)); dc->selection->set(repr); Inkscape::GC::release(repr); - item->transform = i2i_affine(desktop->currentRoot(), desktop->currentLayer()); + item->transform = from_2geom(i2i_affine(desktop->currentRoot(), desktop->currentLayer())); item->updateRepr(); } diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index c6140d17d..cd3a9158a 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -609,7 +609,7 @@ sp_dyna_draw_context_root_handler(SPEventContext *event_context, } // calculate pointer point in the guide item's coords - motion_to_curve = sp_item_dt2i_affine(selected) * sp_item_i2doc_affine(selected); + motion_to_curve = from_2geom(sp_item_dt2i_affine(selected) * sp_item_i2doc_affine(selected)); pointer = motion_dt * motion_to_curve; // calculate the nearest point on the guide path diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 7ac9b9a2a..02bbfc8a3 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -173,7 +173,7 @@ static void sp_shape_render (SPItem *item, CairoRenderContext *ctx) /* fixme: Think (Lauris) */ sp_item_invoke_bbox(item, &pbox, NR::identity(), TRUE); - NR::Matrix const i2d = sp_item_i2d_affine(item); + NR::Matrix const i2d = from_2geom(sp_item_i2d_affine(item)); SPStyle* style = SP_OBJECT_STYLE (item); CairoRenderer *renderer = ctx->getRenderer(); @@ -362,9 +362,9 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); // Get the bounding box of the selection - //NR::Maybe _bbox = item->getBounds(sp_item_i2d_affine(item)); - // NRRect bbox = item->getBounds(sp_item_i2d_affine(item)); - NRRect bbox(item->getBounds(sp_item_i2d_affine(item))); + //NR::Maybe _bbox = item->getBounds(from_2geom(sp_item_i2d_affine(item))); + // NRRect bbox = item->getBounds(from_2geom(sp_item_i2d_affine(item))); + NRRect bbox(item->getBounds(from_2geom(sp_item_i2d_affine(item)))); // List of the items to show; all others will be hidden @@ -417,7 +417,7 @@ static void sp_asbitmap_render(SPItem *item, CairoRenderContext *ctx) } */ // Calculate the matrix that will be applied to the image so that it exactly overlaps the source objects - NR::Matrix eek = sp_item_i2d_affine (SP_ITEM(parent_object)); + NR::Matrix eek = from_2geom(sp_item_i2d_affine (SP_ITEM(parent_object))); NR::Matrix t; double shift_x = bbox.x0; @@ -585,7 +585,7 @@ CairoRenderer::setupDocument(CairoRenderContext *ctx, SPDocument *doc) d.y1 = ceil(ctx->_height); } else { SPItem* doc_item = SP_ITEM(sp_document_root(doc)); - sp_item_invoke_bbox(doc_item, &d, sp_item_i2r_affine(doc_item), TRUE); + sp_item_invoke_bbox(doc_item, &d, from_2geom(sp_item_i2r_affine(doc_item)), TRUE); if (ctx->_vector_based_target) { // convert from px to pt d.x0 *= PT_PER_PX; diff --git a/src/extension/internal/emf-win32-print.cpp b/src/extension/internal/emf-win32-print.cpp index 5ee4b2f58..0e231a608 100644 --- a/src/extension/internal/emf-win32-print.cpp +++ b/src/extension/internal/emf-win32-print.cpp @@ -155,7 +155,7 @@ PrintEmfWin32::begin (Inkscape::Extension::Print *mod, SPDocument *doc) d.y1 = _height; } else { SPItem* doc_item = SP_ITEM(sp_document_root(doc)); - sp_item_invoke_bbox(doc_item, &d, sp_item_i2r_affine(doc_item), TRUE); + sp_item_invoke_bbox(doc_item, &d, from_2geom(sp_item_i2r_affine(doc_item)), TRUE); } d.x0 *= IN_PER_PX; diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index 9a570c290..33242b09e 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -940,8 +940,7 @@ static Glib::ustring formatTransform(NR::Matrix &tf) static NR::Matrix getODFTransform(const SPItem *item) { //### Get SVG-to-ODF transform - NR::Matrix tf; - tf = sp_item_i2d_affine(item); + NR::Matrix tf = from_2geom(sp_item_i2d_affine(item)); //Flip Y into document coordinates double doc_height = sp_document_height(SP_ACTIVE_DOCUMENT); NR::Matrix doc2dt_tf = NR::Matrix(NR::scale(1.0, -1.0)); diff --git a/src/extension/internal/pdf-cairo.cpp b/src/extension/internal/pdf-cairo.cpp index ed6eee546..dd6956a1e 100644 --- a/src/extension/internal/pdf-cairo.cpp +++ b/src/extension/internal/pdf-cairo.cpp @@ -335,7 +335,7 @@ PrintCairoPDF::begin(Inkscape::Extension::Print *mod, SPDocument *doc) d.y1 = _height; } else { // if not page, use our base, which is either root or the item we want to export - sp_item_invoke_bbox(doc_item, &d, sp_item_i2doc_affine (doc_item), TRUE); + sp_item_invoke_bbox(doc_item, &d, from_2geom(sp_item_i2doc_affine (doc_item)), TRUE); // convert from px to pt d.x0 *= PT_PER_PX; d.x1 *= PT_PER_PX; @@ -349,7 +349,7 @@ PrintCairoPDF::begin(Inkscape::Extension::Print *mod, SPDocument *doc) // object itself, ignoring its ancestors // complete transform, including doc_item's own transform - t = sp_item_i2doc_affine (doc_item); + t = from_2geom(sp_item_i2doc_affine (doc_item)); // subreact doc_item's transform (comes first) from it t = NR::Matrix(doc_item->transform).inverse() * t; diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp index 6dd62206c..55448a91e 100644 --- a/src/extension/internal/pov-out.cpp +++ b/src/extension/internal/pov-out.cpp @@ -286,7 +286,7 @@ void PovOutput::doCurves(SPDocument *doc) continue; SPItem *item = SP_ITEM(reprobj); - NR::Matrix tf = sp_item_i2d_affine(item); + NR::Matrix tf = from_2geom(sp_item_i2d_affine(item)); //### Get the Shape if (!SP_IS_SHAPE(reprobj))//Bulia's suggestion. Allow all shapes diff --git a/src/extension/internal/ps.cpp b/src/extension/internal/ps.cpp index 13024344d..299157555 100644 --- a/src/extension/internal/ps.cpp +++ b/src/extension/internal/ps.cpp @@ -408,7 +408,7 @@ PrintPS::begin(Inkscape::Extension::Print *mod, SPDocument *doc) d.y1 = ceil(_height); } else { SPItem* doc_item = SP_ITEM(sp_document_root(doc)); - sp_item_invoke_bbox(doc_item, &d, sp_item_i2r_affine(doc_item), TRUE); + sp_item_invoke_bbox(doc_item, &d, from_2geom(sp_item_i2r_affine(doc_item)), TRUE); // convert from px to pt d.x0 *= PT_PER_PX; d.x1 *= PT_PER_PX; diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index 0be3252a9..90151d6d2 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -330,7 +330,7 @@ new_filter_simple_from_item (SPDocument *document, SPItem *item, const char *mod width = height = 0; } - NR::Matrix i2d = sp_item_i2d_affine (item); + NR::Matrix i2d = from_2geom(sp_item_i2d_affine (item) ); return (new_filter_blend_gaussian_blur (document, mode, radius, NR::expansion(i2d), NR::expansionX(i2d), NR::expansionY(i2d), width, height)); } @@ -367,7 +367,7 @@ modify_filter_gaussian_blur_from_item(SPDocument *document, SPItem *item, } // Determine the required standard deviation value - NR::Matrix i2d = sp_item_i2d_affine (item); + NR::Matrix i2d = from_2geom(sp_item_i2d_affine (item)); double expansion = NR::expansion(i2d); double stdDeviation = radius; if (expansion != 0) diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 083b87fa2..fa1f5ae23 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -510,7 +510,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto sp_item_write_transform(SP_ITEM(reprobj), pathRepr, transform, NULL); // premultiply the item transform by the accumulated parent transform in the paste layer - NR::Matrix local = sp_item_i2doc_affine(SP_GROUP(desktop->currentLayer())); + NR::Matrix local = from_2geom(sp_item_i2doc_affine(SP_GROUP(desktop->currentLayer()))); if (!local.test_identity()) { gchar const *t_str = pathRepr->attribute("transform"); NR::Matrix item_t (NR::identity()); diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 3e6a70174..9fade37ec 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -824,7 +824,7 @@ sp_item_gradient_set_coords (SPItem *item, guint point_type, guint point_i, NR:: gradient = sp_gradient_convert_to_userspace (gradient, item, fill_or_stroke? "fill" : "stroke"); - NR::Matrix i2d = sp_item_i2d_affine (item); + NR::Matrix i2d = from_2geom(sp_item_i2d_affine (item)); NR::Point p = p_w * i2d.inverse(); p *= (gradient->gradientTransform).inverse(); // now p is in gradient's original coordinates @@ -1101,7 +1101,7 @@ sp_item_gradient_get_coords (SPItem *item, guint point_type, guint point_i, bool bbox->min()[NR::X], bbox->min()[NR::Y]); } } - p *= NR::Matrix(gradient->gradientTransform) * sp_item_i2d_affine(item); + p *= NR::Matrix(gradient->gradientTransform) * from_2geom(sp_item_i2d_affine(item)); return p; } diff --git a/src/interface.cpp b/src/interface.cpp index 2c73592f1..1ad90c58c 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1189,7 +1189,7 @@ sp_ui_drag_data_received(GtkWidget *widget, ( !SP_OBJECT_STYLE(item)->stroke.isNone() ? desktop->current_zoom() * SP_OBJECT_STYLE (item)->stroke_width.computed * - NR::expansion(sp_item_i2d_affine(item)) * 0.5 + NR::expansion(from_2geom(sp_item_i2d_affine(item))) * 0.5 : 0.0) + prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100); diff --git a/src/knot-holder-entity.cpp b/src/knot-holder-entity.cpp index 1fa721746..a587a3af0 100644 --- a/src/knot-holder-entity.cpp +++ b/src/knot-holder-entity.cpp @@ -62,7 +62,7 @@ KnotHolderEntity::~KnotHolderEntity() void KnotHolderEntity::update_knot() { - NR::Matrix const i2d(sp_item_i2d_affine(item)); + NR::Matrix const i2d(from_2geom(sp_item_i2d_affine(item))); NR::Point dp(knot_get() * i2d); diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 781d5a3bc..eeddf2eb0 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -80,7 +80,7 @@ KnotHolder::~KnotHolder() { void KnotHolder::update_knots() { - NR::Matrix const i2d(sp_item_i2d_affine(item)); + NR::Matrix const i2d(from_2geom(sp_item_i2d_affine(item))); for(std::list::iterator i = entity.begin(); i != entity.end(); ++i) { KnotHolderEntity *e = *i; @@ -141,8 +141,8 @@ KnotHolder::knot_moved_handler(SPKnot *knot, NR::Point const *p, guint state) for(std::list::iterator i = this->entity.begin(); i != this->entity.end(); ++i) { KnotHolderEntity *e = *i; if (e->knot == knot) { - NR::Point const q = *p / sp_item_i2d_affine(item); - e->knot_set(q, e->knot->drag_origin / sp_item_i2d_affine(item), state); + NR::Point const q = *p / from_2geom(sp_item_i2d_affine(item)); + e->knot_set(q, e->knot->drag_origin / from_2geom(sp_item_i2d_affine(item)), state); break; } } diff --git a/src/live_effects/lpe-perp_bisector.cpp b/src/live_effects/lpe-perp_bisector.cpp index ada321ef3..7c08bdb08 100644 --- a/src/live_effects/lpe-perp_bisector.cpp +++ b/src/live_effects/lpe-perp_bisector.cpp @@ -122,7 +122,7 @@ NR::Point path_end_get(SPItem *item) { void path_set_start_end(SPItem *item, NR::Point const &p, bool start) { SPCurve* curve = sp_path_get_curve_for_edit (SP_PATH(item)); // TODO: Should we use sp_shape_get_curve()? - NR::Matrix const i2d (sp_item_i2d_affine (SP_ITEM(item))); + Geom::Matrix const i2d (sp_item_i2d_affine (SP_ITEM(item))); Geom::Point A, B; if (start) { diff --git a/src/live_effects/lpegroupbbox.cpp b/src/live_effects/lpegroupbbox.cpp index f797d0358..1ec443a5f 100644 --- a/src/live_effects/lpegroupbbox.cpp +++ b/src/live_effects/lpegroupbbox.cpp @@ -23,7 +23,7 @@ GroupBBoxEffect::original_bbox(SPLPEItem *lpeitem, bool absolute) NR::Matrix transform; if (absolute) { - transform = sp_item_i2doc_affine(item); + transform = from_2geom(sp_item_i2doc_affine(item)); } else { transform = NR::identity(); diff --git a/src/live_effects/parameter/pointparam-knotholder.cpp b/src/live_effects/parameter/pointparam-knotholder.cpp index f59b2f7eb..651054120 100644 --- a/src/live_effects/parameter/pointparam-knotholder.cpp +++ b/src/live_effects/parameter/pointparam-knotholder.cpp @@ -91,7 +91,7 @@ PointParamKnotHolder::add_knot ( entity.push_back(e); // Move to current point. - NR::Point dp = p * sp_item_i2d_affine(item); + NR::Point dp = p * from_2geom(sp_item_i2d_affine(item)); sp_knot_set_position(e->knot, &dp, SP_KNOT_STATE_NORMAL); e->handler_id = g_signal_connect(e->knot, "moved", G_CALLBACK(pointparam_knot_moved_handler), this); @@ -112,7 +112,7 @@ static void pointparam_knot_clicked_handler(SPKnot */*knot*/, guint /*state*/, P */ static void pointparam_knot_moved_handler(SPKnot */*knot*/, NR::Point const *p, guint /*state*/, PointParamKnotHolder *kh) { - NR::Matrix const i2d(sp_item_i2d_affine(kh->item)); + NR::Matrix const i2d(from_2geom(sp_item_i2d_affine(kh->item))); NR::Point pos = (*p) / i2d; Inkscape::SVGOStringStream os; @@ -123,7 +123,7 @@ static void pointparam_knot_moved_handler(SPKnot */*knot*/, NR::Point const *p, static void pointparam_knot_ungrabbed_handler(SPKnot *knot, unsigned int /*state*/, PointParamKnotHolder *kh) { - NR::Matrix const i2d(sp_item_i2d_affine(kh->item)); + NR::Matrix const i2d(from_2geom(sp_item_i2d_affine(kh->item))); NR::Point pos = sp_knot_position(knot) / i2d; Inkscape::SVGOStringStream os; diff --git a/src/main.cpp b/src/main.cpp index 6eae51c0c..6ec0ca6b4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -920,7 +920,7 @@ do_query_dimension (SPDocument *doc, bool extent, NR::Dim2 const axis, const gch SPItem *item = ((SPItem *) o); // "true" SVG bbox for scripting - NR::Maybe area = item->getBounds(sp_item_i2doc_affine(item)); + NR::Maybe area = item->getBounds(from_2geom(sp_item_i2doc_affine(item))); if (area) { Inkscape::SVGOStringStream os; if (extent) { @@ -953,7 +953,7 @@ do_query_all_recurse (SPObject *o) { SPItem *item = ((SPItem *) o); if (o->id && SP_IS_ITEM(item)) { - NR::Maybe area = item->getBounds(sp_item_i2doc_affine(item)); + NR::Maybe area = item->getBounds(from_2geom(sp_item_i2doc_affine(item))); if (area) { Inkscape::SVGOStringStream os; os << o->id; @@ -1045,7 +1045,7 @@ sp_do_export_png(SPDocument *doc) // write object bbox to area sp_document_ensure_up_to_date (doc); - sp_item_invoke_bbox((SPItem *) o_area, &area, sp_item_i2r_affine((SPItem *) o_area), TRUE); + sp_item_invoke_bbox((SPItem *) o_area, &area, from_2geom(sp_item_i2r_affine((SPItem *) o_area)), TRUE); } else { g_warning("Object with id=\"%s\" was not found in the document. Nothing exported.", sp_export_id); return; diff --git a/src/node-context.cpp b/src/node-context.cpp index 286f55c4b..40b983360 100644 --- a/src/node-context.cpp +++ b/src/node-context.cpp @@ -182,7 +182,7 @@ sp_node_context_generate_helperpath(SPDesktop *desktop, SPPath *path) { // This should be put somewhere else under the name of "generate helperpath" or something. Because basically this is copied of code from nodepath... SPCurve *curve_new = sp_path_get_curve_for_edit(path); SPCurve *flash_curve = curve_new->copy(); - flash_curve->transform(sp_item_i2d_affine(SP_ITEM(path))); + flash_curve->transform(from_2geom(sp_item_i2d_affine(SP_ITEM(path)))); SPCanvasItem * canvasitem = sp_canvas_bpath_new(sp_desktop_tempgroup(desktop), flash_curve); // would be nice if its color could be XORed or something, now it is invisible for red stroked objects... // unless we also flash the nodes... diff --git a/src/nodepath.cpp b/src/nodepath.cpp index 634604518..7e7e19870 100644 --- a/src/nodepath.cpp +++ b/src/nodepath.cpp @@ -221,7 +221,7 @@ Inkscape::NodePath::Path *sp_nodepath_new(SPDesktop *desktop, SPObject *object, // to a change in repr by regenerating nodepath --bb sp_object_read_attr(SP_OBJECT(np->item), "transform"); - np->i2d = sp_item_i2d_affine(np->item); + np->i2d = from_2geom(sp_item_i2d_affine(np->item)); np->d2i = np->i2d.inverse(); np->repr = repr; diff --git a/src/object-edit.cpp b/src/object-edit.cpp index de7fbccec..94c3c5daf 100644 --- a/src/object-edit.cpp +++ b/src/object-edit.cpp @@ -129,7 +129,7 @@ public: static NR::Point snap_knot_position(SPItem *item, NR::Point const &p) { SPDesktop const *desktop = inkscape_active_desktop(); - NR::Matrix const i2d (sp_item_i2d_affine (item)); + NR::Matrix const i2d (from_2geom(sp_item_i2d_affine (item))); NR::Point s = p * i2d; SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop, item); @@ -464,7 +464,7 @@ Box3DKnotHolderEntity::knot_set_generic(SPItem *item, unsigned int knot_id, NR:: g_assert(item != NULL); SPBox3D *box = SP_BOX3D(item); - NR::Matrix const i2d (sp_item_i2d_affine (item)); + NR::Matrix const i2d (from_2geom(sp_item_i2d_affine (item))); Box3D::Axis movement; if ((knot_id < 4) != (state & GDK_SHIFT_MASK)) { @@ -640,7 +640,7 @@ Box3DKnotHolderEntityCenter::knot_set(NR::Point const &new_pos, NR::Point const NR::Point const s = snap_knot_position(item, new_pos); SPBox3D *box = SP_BOX3D(item); - NR::Matrix const i2d (sp_item_i2d_affine (item)); + NR::Matrix const i2d (from_2geom(sp_item_i2d_affine (item))); box3d_set_center (SP_BOX3D(item), s * i2d, origin * i2d, !(state & GDK_SHIFT_MASK) ? Box3D::XY : Box3D::Z, state & GDK_CONTROL_MASK); diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 2584d5b49..88e709b7f 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -289,7 +289,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Inkscape::Snapper::PointType const & root_item = sp_use_root(SP_USE(*i)); g_return_if_fail(root_item); } else { - i2doc = sp_item_i2doc_affine(*i); + i2doc = from_2geom(sp_item_i2doc_affine(*i)); root_item = *i; } diff --git a/src/selcue.cpp b/src/selcue.cpp index 48df1cf8a..bac12fe80 100644 --- a/src/selcue.cpp +++ b/src/selcue.cpp @@ -126,7 +126,7 @@ void Inkscape::SelCue::_updateItemBboxes() if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) { // visualize baseline Inkscape::Text::Layout const *layout = te_get_layout(item); if (layout != NULL) { - NR::Point a = layout->characterAnchorPoint(layout->begin()) * sp_item_i2d_affine(item); + NR::Point a = layout->characterAnchorPoint(layout->begin()) * from_2geom(sp_item_i2d_affine(item)); baseline_point = sp_canvas_item_new(sp_desktop_controls(_desktop), SP_TYPE_CTRL, "mode", SP_CTRL_MODE_XOR, "size", 4.0, diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 91c518766..f35e28f9a 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -130,7 +130,7 @@ void sp_selection_copy_impl (GSList const *items, GSList **clip, Inkscape::XML:: // Copy item reprs: for (GSList *i = (GSList *) sorted_items; i != NULL; i = i->next) { - sp_selection_copy_one (SP_OBJECT_REPR (i->data), sp_item_i2doc_affine(SP_ITEM (i->data)), clip, xml_doc); + sp_selection_copy_one (SP_OBJECT_REPR (i->data), from_2geom(sp_item_i2doc_affine(SP_ITEM (i->data))), clip, xml_doc); } *clip = g_slist_reverse(*clip); @@ -148,7 +148,7 @@ GSList *sp_selection_paste_impl (SPDocument *doc, SPObject *parent, GSList **cli Inkscape::XML::Node *copy = repr->duplicate(xml_doc); // premultiply the item transform by the accumulated parent transform in the paste layer - NR::Matrix local = sp_item_i2doc_affine(SP_ITEM(parent)); + NR::Matrix local = from_2geom(sp_item_i2doc_affine(SP_ITEM(parent))); if (!local.test_identity()) { gchar const *t_str = copy->attribute("transform"); NR::Matrix item_t (NR::identity()); @@ -442,7 +442,7 @@ void sp_selection_group() NR::Matrix item_t (NR::identity()); if (t_str) sp_svg_transform_read(t_str, &item_t); - item_t *= sp_item_i2doc_affine(SP_ITEM(doc->getObjectByRepr(current->parent()))); + item_t *= from_2geom(sp_item_i2doc_affine(SP_ITEM(doc->getObjectByRepr(current->parent())))); //FIXME: when moving both clone and original from a transformed group (either by //grouping into another parent, or by cut/paste) the transform from the original's //parent becomes embedded into original itself, and this affects its clones. Fix @@ -851,7 +851,7 @@ take_style_from_item (SPItem *item) } // FIXME: also transform gradient/pattern fills, by forking? NO, this must be nondestructive - double ex = NR::expansion(sp_item_i2doc_affine(item)); + double ex = NR::expansion(from_2geom(sp_item_i2doc_affine(item))); if (ex != 1.0) { css = sp_css_attr_scale (css, ex); } @@ -1172,9 +1172,9 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, NR::Matrix const 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 - NR::Matrix parent_transform = sp_item_i2root_affine(SP_ITEM(SP_OBJECT_PARENT (item))); - NR::Matrix t = parent_transform * matrix_to_desktop (matrix_from_desktop (affine, item), item) * parent_transform.inverse(); - NR::Matrix t_inv =parent_transform * matrix_to_desktop (matrix_from_desktop (affine.inverse(), item), item) * parent_transform.inverse(); + NR::Matrix parent_transform = from_2geom(sp_item_i2root_affine(SP_ITEM(SP_OBJECT_PARENT (item)))); + NR::Matrix t = parent_transform * from_2geom(matrix_to_desktop (matrix_from_desktop (to_2geom(affine), item), item)) * parent_transform.inverse(); + NR::Matrix t_inv =parent_transform * from_2geom(matrix_to_desktop (matrix_from_desktop (to_2geom(affine.inverse()), item), item)) * parent_transform.inverse(); NR::Matrix result = t_inv * item->transform * t; if ((prefs_parallel || prefs_unmoved) && affine.is_translation()) { @@ -1202,7 +1202,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, NR::Matrix const } else { if (set_i2d) { - sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * affine); + sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * to_2geom(affine)); } sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform, NULL); } @@ -2015,7 +2015,7 @@ void sp_selection_to_marker(bool apply) // bottommost object, after sorting SPObject *parent = SP_OBJECT_PARENT (items->data); - NR::Matrix parent_transform = sp_item_i2root_affine(SP_ITEM(parent)); + NR::Matrix parent_transform = from_2geom(sp_item_i2root_affine(SP_ITEM(parent))); // remember the position of the first item gint pos = SP_OBJECT_REPR (items->data)->position(); @@ -2137,7 +2137,7 @@ sp_selection_tile(bool apply) // bottommost object, after sorting SPObject *parent = SP_OBJECT_PARENT (items->data); - NR::Matrix parent_transform = sp_item_i2root_affine(SP_ITEM(parent)); + NR::Matrix parent_transform = from_2geom(sp_item_i2root_affine(SP_ITEM(parent))); // remember the position of the first item gint pos = SP_OBJECT_REPR (items->data)->position(); @@ -2463,7 +2463,7 @@ sp_selection_create_bitmap_copy () } // Calculate the matrix that will be applied to the image so that it exactly overlaps the source objects - NR::Matrix eek = sp_item_i2d_affine (SP_ITEM(parent_object)); + NR::Matrix eek = from_2geom(sp_item_i2d_affine (SP_ITEM(parent_object))); NR::Matrix t; double shift_x = bbox.x0; @@ -2780,7 +2780,7 @@ void fit_canvas_to_drawing(SPDocument *doc) { sp_document_ensure_up_to_date(doc); SPItem const *const root = SP_ITEM(doc->root); - NR::Maybe const bbox(root->getBounds(sp_item_i2r_affine(root))); + NR::Maybe const bbox(root->getBounds(from_2geom(sp_item_i2r_affine(root)))); if (bbox && !bbox->isEmpty()) { doc->fitToRect(*bbox); } diff --git a/src/selection.cpp b/src/selection.cpp index 41540c95c..acab9396c 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -407,7 +407,7 @@ NRRect *Selection::boundsInDocument(NRRect *bbox, SPItem::BBoxType type) const { for ( GSList const *iter=items ; iter != NULL ; iter = iter->next ) { SPItem *item=SP_ITEM(iter->data); - NR::Matrix i2doc(sp_item_i2doc_affine(item)); + NR::Matrix i2doc(from_2geom(sp_item_i2doc_affine(item))); sp_item_invoke_bbox(item, bbox, i2doc, FALSE, type); } diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 2c021a724..3d5c19b8c 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -269,7 +269,7 @@ void Inkscape::SelTrans::grab(NR::Point const &p, gdouble x, gdouble y, bool sho SPItem *it = (SPItem *)sp_object_ref(SP_OBJECT(l->data), NULL); _items.push_back(it); _items_const.push_back(it); - _items_affines.push_back(sp_item_i2d_affine(it)); + _items_affines.push_back(from_2geom(sp_item_i2d_affine(it))); _items_centers.push_back(it->getCenter()); // for content-dragging, we need to remember original centers } @@ -373,7 +373,7 @@ void Inkscape::SelTrans::transform(NR::Matrix const &rel_affine, NR::Point const for (unsigned i = 0; i < _items.size(); i++) { SPItem &item = *_items[i]; NR::Matrix const &prev_transform = _items_affines[i]; - sp_item_set_i2d_affine(&item, prev_transform * affine); + sp_item_set_i2d_affine(&item, to_2geom(prev_transform * affine)); } } else { if (_bbox) { @@ -526,9 +526,9 @@ void Inkscape::SelTrans::stamp() NR::Matrix const *new_affine; if (_show == SHOW_OUTLINE) { - NR::Matrix const i2d(sp_item_i2d_affine(original_item)); + NR::Matrix const i2d(from_2geom(sp_item_i2d_affine(original_item))); NR::Matrix const i2dnew( i2d * _current_relative_affine ); - sp_item_set_i2d_affine(copy_item, i2dnew); + sp_item_set_i2d_affine(copy_item, to_2geom(i2dnew)); new_affine = ©_item->transform; } else { new_affine = &original_item->transform; diff --git a/src/shape-editor.cpp b/src/shape-editor.cpp index 9cfa83af1..b975d3f79 100644 --- a/src/shape-editor.cpp +++ b/src/shape-editor.cpp @@ -298,7 +298,7 @@ bool ShapeEditor::is_over_stroke (NR::Point event_p, bool remember) { //Translate click point into proper coord system this->curvepoint_doc = desktop->w2d(event_p); - this->curvepoint_doc *= sp_item_dt2i_affine(item); + this->curvepoint_doc *= from_2geom(sp_item_dt2i_affine(item)); sp_nodepath_ensure_livarot_path(this->nodepath); @@ -316,9 +316,9 @@ bool ShapeEditor::is_over_stroke (NR::Point event_p, bool remember) { (( !SP_OBJECT_STYLE(item)->stroke.isNone() ? desktop->current_zoom() * SP_OBJECT_STYLE (item)->stroke_width.computed * 0.5 * - NR::expansion(sp_item_i2d_affine(item)) + NR::expansion(from_2geom(sp_item_i2d_affine(item))) : 0.0) - + prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100)) /NR::expansion(sp_item_i2d_affine(item)); + + prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100)) /NR::expansion(from_2geom(sp_item_i2d_affine(item))); bool close = (NR::L2 (delta) < stroke_tolerance); if (remember && close) { diff --git a/src/sp-conn-end-pair.cpp b/src/sp-conn-end-pair.cpp index 04591aaba..786209fda 100644 --- a/src/sp-conn-end-pair.cpp +++ b/src/sp-conn-end-pair.cpp @@ -167,7 +167,7 @@ SPConnEndPair::getEndpoints(NR::Point endPts[]) const { for (unsigned h = 0; h < 2; ++h) { if ( h2attItem[h] ) { - NR::Maybe bbox = h2attItem[h]->getBounds(sp_item_i2doc_affine(h2attItem[h])); + NR::Maybe bbox = h2attItem[h]->getBounds(from_2geom(sp_item_i2doc_affine(h2attItem[h]))); if (bbox) { endPts[h] = bbox->midpoint(); } else { diff --git a/src/sp-conn-end.cpp b/src/sp-conn-end.cpp index f610a8790..80ecb060f 100644 --- a/src/sp-conn-end.cpp +++ b/src/sp-conn-end.cpp @@ -61,7 +61,7 @@ sp_conn_end_move_compensate(NR::Matrix const */*mp*/, SPItem */*moved_item*/, SPItem const *const path_item = SP_ITEM(path); SPObject const *const ancestor = get_nearest_common_ancestor(path_item, h2attItem); - NR::Matrix const path2anc(i2anc_affine(path_item, ancestor)); + NR::Matrix const path2anc(from_2geom(i2anc_affine(path_item, ancestor))); if (h2attItem[0] != NULL && h2attItem[1] != NULL) { /* Initial end-points: centre of attached object. */ @@ -82,7 +82,7 @@ sp_conn_end_move_compensate(NR::Matrix const */*mp*/, SPItem */*moved_item*/, return; } h2bbox_icoordsys[h] = *bbox; - h2i2anc[h] = i2anc_affine(h2attItem[h], ancestor); + h2i2anc[h] = from_2geom(i2anc_affine(h2attItem[h], ancestor)); h2endPt_icoordsys[h] = h2bbox_icoordsys[h].midpoint(); } @@ -126,7 +126,7 @@ sp_conn_end_move_compensate(NR::Matrix const */*mp*/, SPItem */*moved_item*/, } h2bbox_icoordsys[ind] = *bbox; - h2i2anc = i2anc_affine(h2attItem[ind], ancestor); + h2i2anc = from_2geom(i2anc_affine(h2attItem[ind], ancestor)); h2endPt_icoordsys[ind] = h2bbox_icoordsys[ind].midpoint(); h2endPt_icoordsys[!ind] = other_endpt; diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index d2750b765..087c323f1 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -283,7 +283,7 @@ static void sp_genericellipse_snappoints(SPItem const *item, SnapPointsIter p) SPGenericEllipse *ellipse = SP_GENERICELLIPSE(item); sp_genericellipse_normalize(ellipse); - NR::Matrix const i2d = sp_item_i2d_affine(item); + NR::Matrix const i2d = from_2geom(sp_item_i2d_affine(item)); // figure out if we have a slice, whilst guarding against rounding errors bool slice = false; diff --git a/src/sp-flowregion.cpp b/src/sp-flowregion.cpp index 3a6cdeee3..61fcdd08c 100644 --- a/src/sp-flowregion.cpp +++ b/src/sp-flowregion.cpp @@ -188,8 +188,8 @@ void SPFlowregion::UpdateComputed(void) { SPObject* object=SP_OBJECT(this); - NR::Matrix itr_mat=sp_item_i2root_affine (SP_ITEM(object)); - itr_mat=itr_mat.inverse(); + NR::Matrix itr_mat = from_2geom(sp_item_i2root_affine (SP_ITEM(object))); + itr_mat = itr_mat.inverse(); for (std::vector::iterator it = computed.begin() ; it != computed.end() ; it++) delete *it; @@ -406,12 +406,12 @@ void SPFlowregionExclude::UpdateComputed(void) { SPObject* object=SP_OBJECT(this); - if (computed) { + if (computed) { delete computed; computed = NULL; } - NR::Matrix itr_mat=sp_item_i2root_affine (SP_ITEM(object)); - itr_mat=itr_mat.inverse(); + NR::Matrix itr_mat = from_2geom(sp_item_i2root_affine (SP_ITEM(object))); + itr_mat = itr_mat.inverse(); for (SPObject* child = sp_object_first_child(object) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) { GetDest(child,&computed,itr_mat); @@ -524,7 +524,7 @@ static void GetDest(SPObject* child,Shape **computed,NR::Matrix itr_mat) if ( curve ) { Path* temp=new Path; - NR::Matrix tr_mat=sp_item_i2root_affine (SP_ITEM(u_child)); + NR::Matrix tr_mat = from_2geom(sp_item_i2root_affine (SP_ITEM(u_child))); tr_mat=itr_mat*tr_mat; temp->LoadArtBPath(SP_CURVE_BPATH(curve),tr_mat,true); Shape* n_shp=new Shape; diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index d47d52dbe..596d47ba4 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -363,7 +363,7 @@ sp_flowtext_print(SPItem *item, SPPrintContext *ctx) dbox.y0 = 0.0; dbox.x1 = sp_document_width(SP_OBJECT_DOCUMENT(item)); dbox.y1 = sp_document_height(SP_OBJECT_DOCUMENT(item)); - NR::Matrix const ctm = sp_item_i2d_affine(item); + NR::Matrix const ctm = from_2geom(sp_item_i2d_affine(item)); group->layout.print(ctx, &pbox, &dbox, &bbox, ctm); } diff --git a/src/sp-image.cpp b/src/sp-image.cpp index 44479de12..f2f2265ea 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -1311,7 +1311,7 @@ static void sp_image_snappoints(SPItem const *item, SnapPointsIter p) double const y0 = image.y.computed; double const x1 = x0 + image.width.computed; double const y1 = y0 + image.height.computed; - NR::Matrix const i2d (sp_item_i2d_affine (item)); + NR::Matrix const i2d (from_2geom(sp_item_i2d_affine (item))); *p = NR::Point(x0, y0) * i2d; *p = NR::Point(x0, y1) * i2d; *p = NR::Point(x1, y1) * i2d; diff --git a/src/sp-item-notify-moveto.cpp b/src/sp-item-notify-moveto.cpp index 391766fb6..bf7393013 100644 --- a/src/sp-item-notify-moveto.cpp +++ b/src/sp-item-notify-moveto.cpp @@ -41,7 +41,7 @@ void sp_item_notify_moveto(SPItem &item, SPGuide const &mv_g, int const snappoin s = (position - pos0) / dot(dir, dir). */ NR::translate const tr( ( position - pos0 ) * ( dir / dir_lensq ) ); - sp_item_set_i2d_affine(&item, sp_item_i2d_affine(&item) * tr); + sp_item_set_i2d_affine(&item, sp_item_i2d_affine(&item) * to_2geom(tr)); /// \todo Reget snappoints, check satisfied. if (commit) { diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index 08c4d167b..4caf155bf 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -33,7 +33,7 @@ sp_item_rotate_rel(SPItem *item, NR::rotate const &rotation) NR::Matrix affine = NR::Matrix(inverse(s)) * NR::Matrix(rotation) * NR::Matrix(s); // Rotate item. - sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * affine); + sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * to_2geom(affine)); // Use each item's own transform writer, consistent with sp_selection_apply_affine() sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform); @@ -49,7 +49,7 @@ sp_item_scale_rel (SPItem *item, NR::scale const &scale) NR::Maybe bbox = sp_item_bbox_desktop(item); if (bbox) { NR::translate const s(bbox->midpoint()); // use getCenter? - sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * inverse(s) * scale * s); + sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * to_2geom(NR::Matrix(inverse(s)) * scale * s)); sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform); } } @@ -63,7 +63,7 @@ sp_item_skew_rel (SPItem *item, double skewX, double skewY) NR::Matrix const skew(1, skewY, skewX, 1, 0, 0); NR::Matrix affine = NR::Matrix(inverse(s)) * skew * NR::Matrix(s); - sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * affine); + sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * to_2geom(affine)); sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform); // Restore the center position (it's changed because the bbox center changed) @@ -74,7 +74,7 @@ sp_item_skew_rel (SPItem *item, double skewX, double skewY) void sp_item_move_rel(SPItem *item, NR::translate const &tr) { - sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * tr); + sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * to_2geom(tr)); sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform); } diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 8fa934278..10f2683b8 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -65,6 +65,8 @@ #include "libnr/nr-convert2geom.h" #include "algorithms/find-last-if.h" #include "util/reverse-list.h" +#include <2geom/rect.h> +#include <2geom/transforms.h> #include "xml/repr.h" #include "extract-uri.h" @@ -286,7 +288,7 @@ SPItem::setExplicitlyHidden(bool const val) { */ void SPItem::setCenter(NR::Point object_centre) { - NR::Maybe bbox = getBounds(sp_item_i2d_affine(this)); + NR::Maybe bbox = getBounds(from_2geom(sp_item_i2d_affine(this))); if (bbox) { transform_center_x = object_centre[NR::X] - bbox->midpoint()[NR::X]; if (fabs(transform_center_x) < 1e-5) // rounding error @@ -308,7 +310,7 @@ bool SPItem::isCenterSet() { } NR::Point SPItem::getCenter() const { - NR::Maybe bbox = getBounds(sp_item_i2d_affine(this)); + NR::Maybe bbox = getBounds(from_2geom(sp_item_i2d_affine(this))); if (bbox) { return bbox->midpoint() + NR::Point (this->transform_center_x, this->transform_center_y); } else { @@ -701,6 +703,15 @@ NR::Maybe SPItem::getBounds(NR::Matrix const &transform, return r; } +NR::Maybe +SPItem::getBounds(Geom::Matrix const &transform, SPItem::BBoxType type, unsigned int /*dkey*/) +const +{ + NR::Maybe r = NR::Nothing(); + sp_item_invoke_bbox_full(this, &r, from_2geom(transform), type, TRUE); + return NR::Maybe(to_2geom(*r)); +} + void sp_item_invoke_bbox(SPItem const *item, NR::Maybe *bbox, NR::Matrix const &transform, unsigned const clear, SPItem::BBoxType type) { @@ -783,7 +794,7 @@ sp_item_invoke_bbox_full(SPItem const *item, NR::Maybe *bbox, NR::Matr } // transform the expansions by the item's transform: - NR::Matrix i2d = sp_item_i2d_affine (item); + NR::Matrix i2d = from_2geom(sp_item_i2d_affine (item)); dx0 *= NR::expansionX(i2d); dx1 *= NR::expansionX(i2d); dy0 *= NR::expansionY(i2d); @@ -893,19 +904,19 @@ sp_item_bbox_desktop(SPItem *item, NRRect *bbox, SPItem::BBoxType type) g_assert(SP_IS_ITEM(item)); g_assert(bbox != NULL); - sp_item_invoke_bbox(item, bbox, sp_item_i2d_affine(item), TRUE, type); + sp_item_invoke_bbox(item, bbox, from_2geom(sp_item_i2d_affine(item)), TRUE, type); } NR::Maybe sp_item_bbox_desktop(SPItem *item, SPItem::BBoxType type) { NR::Maybe rect = NR::Nothing(); - sp_item_invoke_bbox(item, &rect, sp_item_i2d_affine(item), TRUE, type); + sp_item_invoke_bbox(item, &rect, from_2geom(sp_item_i2d_affine(item)), TRUE, type); return rect; } static void sp_item_private_snappoints(SPItem const *item, SnapPointsIter p) { - NR::Maybe bbox = item->getBounds(sp_item_i2d_affine(item)); + NR::Maybe bbox = item->getBounds(from_2geom(sp_item_i2d_affine(item))); /* Just the corners of the bounding box suffices given that we don't yet support angled guide lines. */ @@ -1456,38 +1467,38 @@ sp_item_convert_item_to_guides(SPItem *item) { * \pre \a ancestor really is an ancestor (\>=) of \a object, or NULL. * ("Ancestor (\>=)" here includes as far as \a object itself.) */ -NR::Matrix +Geom::Matrix i2anc_affine(SPObject const *object, SPObject const *const ancestor) { - NR::Matrix ret(NR::identity()); + Geom::Matrix ret(Geom::identity()); g_return_val_if_fail(object != NULL, ret); /* stop at first non-renderable ancestor */ while ( object != ancestor && SP_IS_ITEM(object) ) { if (SP_IS_ROOT(object)) { - ret *= SP_ROOT(object)->c2p; + ret *= to_2geom(SP_ROOT(object)->c2p); } - ret *= SP_ITEM(object)->transform; + ret *= to_2geom(SP_ITEM(object)->transform); object = SP_OBJECT_PARENT(object); } return ret; } -NR::Matrix +Geom::Matrix i2i_affine(SPObject const *src, SPObject const *dest) { - g_return_val_if_fail(src != NULL && dest != NULL, NR::identity()); + g_return_val_if_fail(src != NULL && dest != NULL, Geom::identity()); SPObject const *ancestor = src->nearestCommonAncestor(dest); - return i2anc_affine(src, ancestor) / i2anc_affine(dest, ancestor); + return to_2geom( from_2geom(i2anc_affine(src, ancestor)) / from_2geom(i2anc_affine(dest, ancestor)) ); } NR::Matrix SPItem::getRelativeTransform(SPObject const *dest) const { - return i2i_affine(this, dest); + return from_2geom(i2i_affine(this, dest)); } /** * Returns the accumulated transformation of the item and all its ancestors, including root's viewport. * \pre (item != NULL) and SP_IS_ITEM(item). */ -NR::Matrix sp_item_i2doc_affine(SPItem const *item) +Geom::Matrix sp_item_i2doc_affine(SPItem const *item) { return i2anc_affine(item, NULL); } @@ -1497,46 +1508,46 @@ NR::Matrix sp_item_i2doc_affine(SPItem const *item) * Used in path operations mostly. * \pre (item != NULL) and SP_IS_ITEM(item). */ -NR::Matrix sp_item_i2root_affine(SPItem const *item) +Geom::Matrix sp_item_i2root_affine(SPItem const *item) { g_assert(item != NULL); g_assert(SP_IS_ITEM(item)); - NR::Matrix ret(NR::identity()); - g_assert(ret.test_identity()); + Geom::Matrix ret(Geom::identity()); + g_assert(ret.isIdentity()); while ( NULL != SP_OBJECT_PARENT(item) ) { - ret *= item->transform; + ret *= to_2geom(item->transform); item = SP_ITEM(SP_OBJECT_PARENT(item)); } g_assert(SP_IS_ROOT(item)); - ret *= item->transform; + ret *= to_2geom(item->transform); return ret; } /* fixme: This is EVIL!!! */ - -NR::Matrix sp_item_i2d_affine(SPItem const *item) +// fix this note: why/what evil? :) +Geom::Matrix sp_item_i2d_affine(SPItem const *item) { g_assert(item != NULL); g_assert(SP_IS_ITEM(item)); - NR::Matrix const ret( sp_item_i2doc_affine(item) - * NR::scale(1, -1) - * NR::translate(0, sp_document_height(SP_OBJECT_DOCUMENT(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; } // same as i2d but with i2root instead of i2doc -NR::Matrix sp_item_i2r_affine(SPItem const *item) +Geom::Matrix sp_item_i2r_affine(SPItem const *item) { g_assert(item != NULL); g_assert(SP_IS_ITEM(item)); - NR::Matrix const ret( sp_item_i2root_affine(item) - * NR::scale(1, -1) - * NR::translate(0, sp_document_height(SP_OBJECT_DOCUMENT(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; } @@ -1544,11 +1555,11 @@ NR::Matrix sp_item_i2r_affine(SPItem const *item) * Converts a matrix \a m into the desktop coords of the \a item. * Will become a noop when we eliminate the coordinate flipping. */ -NR::Matrix matrix_to_desktop(NR::Matrix const m, SPItem const *item) +Geom::Matrix matrix_to_desktop(Geom::Matrix const m, SPItem const *item) { - NR::Matrix const ret(m - * NR::translate(0, -sp_document_height(SP_OBJECT_DOCUMENT(item))) - * NR::scale(1, -1)); + Geom::Matrix const ret(m + * Geom::Translate(0, -sp_document_height(SP_OBJECT_DOCUMENT(item))) + * Geom::Scale(1, -1)); return ret; } @@ -1556,33 +1567,33 @@ NR::Matrix matrix_to_desktop(NR::Matrix const m, SPItem const *item) * Converts a matrix \a m from the desktop coords of the \a item. * Will become a noop when we eliminate the coordinate flipping. */ -NR::Matrix matrix_from_desktop(NR::Matrix const m, SPItem const *item) +Geom::Matrix matrix_from_desktop(Geom::Matrix const m, SPItem const *item) { - NR::Matrix const ret(NR::scale(1, -1) - * NR::translate(0, sp_document_height(SP_OBJECT_DOCUMENT(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, NR::Matrix const &i2dt) +void sp_item_set_i2d_affine(SPItem *item, Geom::Matrix const &i2dt) { g_return_if_fail( item != NULL ); g_return_if_fail( SP_IS_ITEM(item) ); - NR::Matrix dt2p; /* desktop to item parent transform */ + Geom::Matrix dt2p; /* desktop to item parent transform */ if (SP_OBJECT_PARENT(item)) { dt2p = sp_item_i2d_affine((SPItem *) SP_OBJECT_PARENT(item)).inverse(); } else { - dt2p = ( NR::translate(0, -sp_document_height(SP_OBJECT_DOCUMENT(item))) - * NR::scale(1, -1) ); + dt2p = ( Geom::Translate(0, -sp_document_height(SP_OBJECT_DOCUMENT(item))) + * Geom::Scale(1, -1) ); } - NR::Matrix const i2p( i2dt * dt2p ); - sp_item_set_item_transform(item, i2p); + Geom::Matrix const i2p( i2dt * dt2p ); + sp_item_set_item_transform(item, from_2geom(i2p)); } -NR::Matrix +Geom::Matrix sp_item_dt2i_affine(SPItem const *item) { /* fixme: Implement the right way (Lauris) */ diff --git a/src/sp-item.h b/src/sp-item.h index 96981aa1d..814581a5d 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -23,6 +23,8 @@ #include "sp-object.h" #include #include +#include <2geom/forward.h> +#include class SPGuideConstraint; struct SPClipPathReference; @@ -153,6 +155,7 @@ struct SPItem : public SPObject { void lowerToBottom(); NR::Maybe getBounds(NR::Matrix const &transform, BBoxType type=APPROXIMATE_BBOX, unsigned int dkey=0) const; + NR::Maybe getBounds(Geom::Matrix const &transform, BBoxType type=APPROXIMATE_BBOX, unsigned int dkey=0) const; sigc::connection _clip_ref_connection; sigc::connection _mask_ref_connection; @@ -251,14 +254,14 @@ NRArenaItem *sp_item_get_arenaitem(SPItem *item, unsigned int key); void sp_item_bbox_desktop(SPItem *item, NRRect *bbox, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) __attribute__ ((deprecated)); NR::Maybe sp_item_bbox_desktop(SPItem *item, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX); -NR::Matrix i2anc_affine(SPObject const *item, SPObject const *ancestor); -NR::Matrix i2i_affine(SPObject const *src, SPObject const *dest); +Geom::Matrix i2anc_affine(SPObject const *item, SPObject const *ancestor); +Geom::Matrix i2i_affine(SPObject const *src, SPObject const *dest); -NR::Matrix sp_item_i2doc_affine(SPItem const *item); -NR::Matrix sp_item_i2root_affine(SPItem const *item); +Geom::Matrix sp_item_i2doc_affine(SPItem const *item); +Geom::Matrix sp_item_i2root_affine(SPItem const *item); -NR::Matrix matrix_to_desktop (NR::Matrix m, SPItem const *item); -NR::Matrix matrix_from_desktop (NR::Matrix m, 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 */ @@ -268,10 +271,10 @@ NR::Matrix matrix_from_desktop (NR::Matrix m, SPItem const *item); * * \return TRANSFORM. */ -NR::Matrix sp_item_i2d_affine(SPItem const *item); -NR::Matrix sp_item_i2r_affine(SPItem const *item); -void sp_item_set_i2d_affine(SPItem *item, NR::Matrix const &transform); -NR::Matrix sp_item_dt2i_affine(SPItem const *item); +Geom::Matrix sp_item_i2d_affine(SPItem const *item); +Geom::Matrix sp_item_i2r_affine(SPItem const *item); +void sp_item_set_i2d_affine(SPItem *item, Geom::Matrix const &transform); +Geom::Matrix sp_item_dt2i_affine(SPItem const *item); int sp_item_repr_compare_position(SPItem *first, SPItem *second); SPItem *sp_item_first_item_child (SPObject *obj); diff --git a/src/sp-path.cpp b/src/sp-path.cpp index 173e44440..16c8b85f4 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -148,7 +148,7 @@ sp_path_convert_to_guides(SPItem *item) SPDocument *doc = SP_OBJECT_DOCUMENT(path); std::list > pts; - NR::Matrix const i2d (sp_item_i2d_affine(SP_ITEM(path))); + NR::Matrix const i2d (from_2geom(sp_item_i2d_affine(SP_ITEM(path)))); SPCurve *curve = SP_SHAPE(path)->curve; if (!curve) return; @@ -514,7 +514,7 @@ void freehand_create_single_dot(SPEventContext *ec, NR::Point const &pt, char co /* put the circle where the mouse click occurred and set the diameter to the current stroke width, multiplied by the amount specified in the preferences */ - NR::Matrix const i2d (sp_item_i2d_affine (item)); + NR::Matrix const i2d (from_2geom(sp_item_i2d_affine (item))); NR::Point pp = pt * i2d; double rad = 0.5 * prefs_get_double_attribute(tool, "dot-size", 3.0); if (event_state & GDK_MOD1_MASK) { diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index 072c52199..7d3cd1c0c 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -561,7 +561,7 @@ static void sp_rect_snappoints(SPItem const *item, SnapPointsIter p) SPRect *rect = SP_RECT(item); - NR::Matrix const i2d (sp_item_i2d_affine (item)); + NR::Matrix const i2d (from_2geom(sp_item_i2d_affine (item))); *p = NR::Point(rect->x.computed, rect->y.computed) * i2d; *p = NR::Point(rect->x.computed, rect->y.computed + rect->height.computed) * i2d; @@ -581,7 +581,7 @@ sp_rect_convert_to_guides(SPItem *item) { SPDocument *doc = SP_OBJECT_DOCUMENT(rect); std::list > pts; - NR::Matrix const i2d (sp_item_i2d_affine(SP_ITEM(rect))); + NR::Matrix const i2d (from_2geom(sp_item_i2d_affine(SP_ITEM(rect)))); NR::Point A1(NR::Point(rect->x.computed, rect->y.computed) * i2d); NR::Point A2(NR::Point(rect->x.computed, rect->y.computed + rect->height.computed) * i2d); diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 2ed92c5f5..4ae2a98f8 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -726,7 +726,7 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) dbox.x1 = sp_document_width (SP_OBJECT_DOCUMENT (item)); dbox.y1 = sp_document_height (SP_OBJECT_DOCUMENT (item)); sp_item_bbox_desktop (item, &bbox); - NR::Matrix const i2d = sp_item_i2d_affine(item); + NR::Matrix const i2d = from_2geom(sp_item_i2d_affine(item)); SPStyle* style = SP_OBJECT_STYLE (item); @@ -1047,7 +1047,7 @@ static void sp_shape_snappoints(SPItem const *item, SnapPointsIter p) return; } - NR::Matrix const i2d (sp_item_i2d_affine (item)); + NR::Matrix const i2d (from_2geom(sp_item_i2d_affine (item))); NArtBpath const *b = SP_CURVE_BPATH(shape->curve); // Cycle through the nodes in the concatenated subpaths diff --git a/src/sp-text.cpp b/src/sp-text.cpp index ceb8dc5a5..8e4b732bc 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -428,7 +428,7 @@ static void sp_text_snappoints(SPItem const *item, SnapPointsIter p) // the baseline anchor of the first char Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item); if(layout != NULL) { - *p = layout->characterAnchorPoint(layout->begin()) * sp_item_i2d_affine(item); + *p = layout->characterAnchorPoint(layout->begin()) * from_2geom(sp_item_i2d_affine(item)); } } @@ -493,7 +493,7 @@ sp_text_print (SPItem *item, SPPrintContext *ctx) dbox.y0 = 0.0; dbox.x1 = sp_document_width (SP_OBJECT_DOCUMENT (item)); dbox.y1 = sp_document_height (SP_OBJECT_DOCUMENT (item)); - NR::Matrix const ctm = sp_item_i2d_affine(item); + NR::Matrix const ctm = from_2geom(sp_item_i2d_affine(item)); group->layout.print(ctx,&pbox,&dbox,&bbox,ctm); } diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index c86c852d7..0b3be7072 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -578,7 +578,7 @@ sp_textpath_to_text(SPObject *tp) SPObject *text = SP_OBJECT_PARENT(tp); NRRect bbox; - sp_item_invoke_bbox(SP_ITEM(text), &bbox, sp_item_i2doc_affine(SP_ITEM(text)), TRUE); + sp_item_invoke_bbox(SP_ITEM(text), &bbox, from_2geom(sp_item_i2doc_affine(SP_ITEM(text))), TRUE); NR::Point xy(bbox.x0, bbox.y0); // make a list of textpath children diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 382f857cf..5868140a6 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -459,7 +459,7 @@ sp_selected_path_boolop(bool_op bop, const unsigned int verb, const Glib::ustrin // adjust style properties that depend on a possible transform in the source object in order // to get a correct style attribute for the new path SPItem* item_source = SP_ITEM(source); - NR::Matrix i2root = sp_item_i2root_affine(item_source); + NR::Matrix i2root = from_2geom(sp_item_i2root_affine(item_source)); sp_item_adjust_stroke(item_source, NR::expansion(i2root)); sp_item_adjust_pattern(item_source, i2root); sp_item_adjust_gradient(item_source, i2root); @@ -491,7 +491,7 @@ sp_selected_path_boolop(bool_op bop, const unsigned int verb, const Glib::ustrin // premultiply by the inverse of parent's repr SPItem *parent_item = SP_ITEM(sp_desktop_document(desktop)->getObjectByRepr(parent)); - NR::Matrix local = sp_item_i2doc_affine(parent_item); + NR::Matrix local = from_2geom(sp_item_i2doc_affine(parent_item)); gchar *transform = sp_svg_transform_write(local.inverse()); // now that we have the result, add it on the canvas @@ -1604,7 +1604,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop, continue; if (simplifyIndividualPaths) { - NR::Maybe itemBbox = item->getBounds(sp_item_i2d_affine(item)); + NR::Maybe itemBbox = item->getBounds(from_2geom(sp_item_i2d_affine(item))); if (itemBbox) { simplifySize = L2(itemBbox->dimensions()); } else { @@ -1753,7 +1753,7 @@ bpath_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool transf NArtBpath *new_bpath; // we will get a duplicate which has to be freed at some point! if (doTransformation) { if (transformFull) { - new_bpath = nr_artpath_affine(bpath, sp_item_i2doc_affine(item)); + new_bpath = nr_artpath_affine(bpath, from_2geom(sp_item_i2doc_affine(item))); } else { new_bpath = nr_artpath_affine(bpath, item->transform); } diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index 0eeac8c4f..9cce92ef8 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -429,7 +429,7 @@ text_unflow () rtext->setAttribute("style", SP_OBJECT_REPR(flowtext)->attribute("style")); // fixme: transfer style attrs too; and from descendants NRRect bbox; - sp_item_invoke_bbox(SP_ITEM(flowtext), &bbox, sp_item_i2doc_affine(SP_ITEM(flowtext)), TRUE); + sp_item_invoke_bbox(SP_ITEM(flowtext), &bbox, from_2geom(sp_item_i2doc_affine(SP_ITEM(flowtext))), TRUE); NR::Point xy(bbox.x0, bbox.y0); if (xy[NR::X] != 1e18 && xy[NR::Y] != 1e18) { sp_repr_set_svg_double(rtext, "x", xy[NR::X]); diff --git a/src/text-context.cpp b/src/text-context.cpp index dc4de38e7..4e1fa87e1 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -1508,8 +1508,8 @@ sp_text_context_update_cursor(SPTextContext *tc, bool scroll_to_see) if (tc->text) { NR::Point p0, p1; sp_te_get_cursor_coords(tc->text, tc->text_sel_end, p0, p1); - NR::Point const d0 = p0 * sp_item_i2d_affine(SP_ITEM(tc->text)); - NR::Point const d1 = p1 * sp_item_i2d_affine(SP_ITEM(tc->text)); + NR::Point const d0 = p0 * from_2geom(sp_item_i2d_affine(SP_ITEM(tc->text))); + NR::Point const d1 = p1 * from_2geom(sp_item_i2d_affine(SP_ITEM(tc->text))); // scroll to show cursor if (scroll_to_see) { @@ -1573,7 +1573,7 @@ static void sp_text_context_update_text_selection(SPTextContext *tc) std::vector quads; if (tc->text != NULL) - quads = sp_te_create_selection_quads(tc->text, tc->text_sel_start, tc->text_sel_end, sp_item_i2d_affine(tc->text)); + quads = sp_te_create_selection_quads(tc->text, tc->text_sel_start, tc->text_sel_end, from_2geom(sp_item_i2d_affine(tc->text))); for (unsigned i = 0 ; i < quads.size() ; i += 4) { SPCanvasItem *quad_canvasitem; quad_canvasitem = sp_canvas_item_new(sp_desktop_controls(tc->desktop), SP_TYPE_CTRLQUADR, NULL); diff --git a/src/text-editing.cpp b/src/text-editing.cpp index a225c1a00..b103a0108 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -80,7 +80,7 @@ sp_te_input_is_empty (SPObject const *item) Inkscape::Text::Layout::iterator sp_te_get_position_by_coords (SPItem const *item, NR::Point &i_p) { - NR::Matrix im=sp_item_i2d_affine (item); + NR::Matrix im = from_2geom(sp_item_i2d_affine (item)); im = im.inverse(); NR::Point p = i_p * im; @@ -948,7 +948,7 @@ sp_te_adjust_kerning_screen (SPItem *item, Inkscape::Text::Layout::iterator cons // divide increment by zoom // divide increment by matrix expansion gdouble factor = 1 / desktop->current_zoom(); - NR::Matrix t = sp_item_i2doc_affine(item); + NR::Matrix t = from_2geom(sp_item_i2doc_affine(item)); factor = factor / NR::expansion(t); by = factor * by; @@ -970,7 +970,7 @@ sp_te_adjust_rotation_screen(SPItem *text, Inkscape::Text::Layout::iterator cons // divide increment by zoom // divide increment by matrix expansion gdouble factor = 1 / desktop->current_zoom(); - NR::Matrix t = sp_item_i2doc_affine(text); + NR::Matrix t = from_2geom(sp_item_i2doc_affine(text)); factor = factor / NR::expansion(t); Inkscape::Text::Layout const *layout = te_get_layout(text); if (layout == NULL) return; @@ -1055,7 +1055,7 @@ sp_te_adjust_tspan_letterspacing_screen(SPItem *text, Inkscape::Text::Layout::it gdouble const zoom = desktop->current_zoom(); gdouble const zby = (by / (zoom * (nb_let > 1 ? nb_let - 1 : 1)) - / NR::expansion(sp_item_i2doc_affine(SP_ITEM(source_obj)))); + / NR::expansion(from_2geom(sp_item_i2doc_affine(SP_ITEM(source_obj))))); val += zby; if (start == end) { @@ -1114,7 +1114,7 @@ sp_te_adjust_linespacing_screen (SPItem *text, Inkscape::Text::Layout::iterator gdouble zby = by / (desktop->current_zoom() * (line_count == 0 ? 1 : line_count)); // divide increment by matrix expansion - NR::Matrix t = sp_item_i2doc_affine (SP_ITEM(text)); + NR::Matrix t = from_2geom(sp_item_i2doc_affine (SP_ITEM(text))); zby = zby / NR::expansion(t); switch (style->line_height.unit) { diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index e4b88ffea..509194612 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -373,7 +373,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, NR::Poi // skip those paths whose bboxes are entirely out of reach with our radius - NR::Maybe bbox = item->getBounds(sp_item_i2doc_affine(item)); + NR::Maybe bbox = item->getBounds(from_2geom(sp_item_i2doc_affine(item))); if (bbox) { bbox->growBy(radius); if (!bbox->contains(p)) { @@ -391,7 +391,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, NR::Poi Shape *theShape = new Shape; Shape *theRes = new Shape; - NR::Matrix i2doc(sp_item_i2doc_affine(item)); + NR::Matrix i2doc(from_2geom(sp_item_i2doc_affine(item))); orig->ConvertWithBackData((0.08 - (0.07 * fidelity)) / NR::expansion(i2doc)); // default 0.059 orig->Fill(theShape, 0); @@ -610,7 +610,7 @@ tweak_colors_in_gradient (SPItem *item, bool fill_or_stroke, if (!gradient || !SP_IS_GRADIENT(gradient)) return; - NR::Matrix i2d = sp_item_i2doc_affine (item); + NR::Matrix i2d = from_2geom(sp_item_i2doc_affine (item)); NR::Point p = p_w * i2d.inverse(); p *= (gradient->gradientTransform).inverse(); // now p is in gradient's original coordinates @@ -743,7 +743,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, if (!style) { return false; } - NR::Maybe bbox = item->getBounds(sp_item_i2doc_affine(item), + NR::Maybe bbox = item->getBounds(from_2geom(sp_item_i2doc_affine(item)), SPItem::GEOMETRIC_BBOX); if (!bbox) { return false; diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 227d57a96..991a69911 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -496,7 +496,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) // write the complete accumulated transform passed to us // (we're dealing with unattached representations, so we write to their attributes // instead of using sp_item_set_transform) - gchar *transform_str = sp_svg_transform_write(sp_item_i2doc_affine(SP_ITEM(i->data))); + gchar *transform_str = sp_svg_transform_write(from_2geom(sp_item_i2doc_affine(SP_ITEM(i->data)))); obj_copy->setAttribute("transform", transform_str); g_free(transform_str); } diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 68c083c6f..8c154d87a 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -694,7 +694,7 @@ private : { if (SP_IS_TEXT (*it) || SP_IS_FLOWTEXT (*it)) { Inkscape::Text::Layout const *layout = te_get_layout(*it); - NR::Point base = layout->characterAnchorPoint(layout->begin()) * sp_item_i2d_affine(*it); + NR::Point base = layout->characterAnchorPoint(layout->begin()) * from_2geom(sp_item_i2d_affine(*it)); if (base[NR::X] < b_min[NR::X]) b_min[NR::X] = base[NR::X]; if (base[NR::Y] < b_min[NR::Y]) b_min[NR::Y] = base[NR::Y]; if (base[NR::X] > b_max[NR::X]) b_max[NR::X] = base[NR::X]; @@ -735,7 +735,7 @@ private : { if (SP_IS_TEXT (*it) || SP_IS_FLOWTEXT (*it)) { Inkscape::Text::Layout const *layout = te_get_layout(*it); - NR::Point base = layout->characterAnchorPoint(layout->begin()) * sp_item_i2d_affine(*it); + NR::Point base = layout->characterAnchorPoint(layout->begin()) * from_2geom(sp_item_i2d_affine(*it)); NR::Point t(0.0, 0.0); t[_orientation] = b_min[_orientation] - base[_orientation]; sp_item_move_rel(*it, NR::translate(t)); diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index ed257a49a..d26762bd3 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -863,7 +863,7 @@ bool FileOpenDialogImplWin32::set_svg_preview() NR::Maybe maybeArea(area); sp_document_ensure_up_to_date (svgDoc); sp_item_invoke_bbox((SPItem *) svgDoc->root, &maybeArea, - sp_item_i2r_affine((SPItem *)(svgDoc->root)), TRUE); + from_2geom(sp_item_i2r_affine((SPItem *)(svgDoc->root))), TRUE); NRArena *const arena = NRArena::create(); diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index 498a24998..3f398b9e6 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -609,7 +609,7 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, SPObject *object = doc->getObjectById(name); if (object && SP_IS_ITEM(object)) { /* Find bbox in document */ - NR::Matrix const i2doc(sp_item_i2doc_affine(SP_ITEM(object))); + NR::Matrix const i2doc(from_2geom(sp_item_i2doc_affine(SP_ITEM(object)))); NR::Maybe dbox = SP_ITEM(object)->getBounds(i2doc); if ( SP_OBJECT_PARENT(object) == NULL ) -- 2.30.2