From: cilix42 Date: Thu, 18 Sep 2008 17:48:42 +0000 (+0000) Subject: Next roud of NR ==> Geom conversion X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=6b76ef6bb3e9b4e1cc83e01cd81a55bbd0450989;p=inkscape.git Next roud of NR ==> Geom conversion --- diff --git a/src/box3d.cpp b/src/box3d.cpp index 6f4253cab..3a2c09438 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -19,6 +19,7 @@ #include "attributes.h" #include "xml/document.h" #include "xml/repr.h" +#include "libnr/nr-matrix-fns.h" #include "box3d.h" #include "box3d-side.h" diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index b8af828ad..23b2e07a5 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -120,8 +120,8 @@ 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))); - double const ex(NR::expansion(local)); + Geom::Matrix const local(sp_item_i2doc_affine(SP_ITEM(o))); + double const ex(local.descrim()); if ( ( ex != 0. ) && ( ex != 1. ) ) { sp_css_attr_scale(css_set, 1/ex); @@ -405,7 +405,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)); + Geom::Matrix i2d = sp_item_i2d_affine (SP_ITEM(l->data)); SPObject *object = SP_OBJECT(l->data); @@ -416,7 +416,7 @@ stroke_average_width (GSList const *objects) notstroked = false; } - avgwidth += SP_OBJECT_STYLE (object)->stroke_width.computed * NR::expansion(i2d); + avgwidth += SP_OBJECT_STYLE (object)->stroke_width.computed * i2d.descrim(); } if (notstroked) @@ -671,8 +671,8 @@ objects_query_strokewidth (GSList *objects, SPStyle *style_res) n_stroked ++; - NR::Matrix i2d = sp_item_i2d_affine (SP_ITEM(obj)); - double sw = style->stroke_width.computed * NR::expansion(i2d); + Geom::Matrix i2d = sp_item_i2d_affine (SP_ITEM(obj)); + double sw = style->stroke_width.computed * i2d.descrim(); if (prev_sw != -1 && fabs(sw - prev_sw) > 1e-3) same_sw = false; @@ -887,7 +887,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 * Geom::Matrix(sp_item_i2d_affine(SP_ITEM(obj))).descrim(); /// \todo FIXME: we assume non-% units here if (style->letter_spacing.normal) { if (!different && (letterspacing_prev == 0 || letterspacing_prev == letterspacing)) @@ -1222,7 +1222,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)); + Geom::Matrix i2d = sp_item_i2d_affine (SP_ITEM(obj)); items ++; @@ -1238,7 +1238,7 @@ objects_query_blur (GSList *objects, SPStyle *style_res) if(SP_IS_GAUSSIANBLUR(primitive)) { SPGaussianBlur * spblur = SP_GAUSSIANBLUR(primitive); float num = spblur->stdDeviation.getNumber(); - blur_sum += num * NR::expansion(i2d); + blur_sum += num * i2d.descrim(); if (blur_prev != -1 && fabs (num - blur_prev) > 1e-2) // rather low tolerance because difference in blur radii is much harder to notice than e.g. difference in sizes same_blur = false; blur_prev = num; diff --git a/src/desktop.cpp b/src/desktop.cpp index 27f7179ed..92946cb7d 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -57,6 +57,7 @@ #include #include +#include <2geom/rect.h> #include "macros.h" #include "inkscape-private.h" #include "desktop.h" @@ -79,7 +80,6 @@ #include "display/sp-canvas-util.h" #include "display/canvas-temporary-item-list.h" #include "display/snap-indicator.h" -#include "libnr/nr-rect-ops.h" #include "ui/dialog/dialog-manager.h" #include "xml/repr.h" #include "message-context.h" @@ -204,7 +204,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas) g_signal_connect (G_OBJECT (main), "event", G_CALLBACK (sp_desktop_root_handler), this); table = sp_canvas_item_new (main, SP_TYPE_CTRLRECT, NULL); - SP_CTRLRECT(table)->setRectangle(NR::Rect(Geom::Point(-80000, -80000), Geom::Point(80000, 80000))); + SP_CTRLRECT(table)->setRectangle(Geom::Rect(Geom::Point(-80000, -80000), Geom::Point(80000, 80000))); SP_CTRLRECT(table)->setColor(0x00000000, true, 0x00000000); sp_canvas_item_move_to_z (table, 0); @@ -241,8 +241,8 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas) // display rect and zoom are now handled in sp_desktop_widget_realize() - NR::Rect const d(Geom::Point(0.0, 0.0), - Geom::Point(sp_document_width(document), sp_document_height(document))); + Geom::Rect const d(Geom::Point(0.0, 0.0), + Geom::Point(sp_document_width(document), sp_document_height(document))); SP_CTRLRECT(page)->setRectangle(d); SP_CTRLRECT(page_border)->setRectangle(d); @@ -527,10 +527,10 @@ bool SPDesktop::isLayer(SPObject *object) const { */ bool SPDesktop::isWithinViewport (SPItem *item) const { - NR::Rect const viewport = get_display_area(); + Geom::Rect const viewport = get_display_area(); boost::optional const bbox = sp_item_bbox_desktop(item); if (bbox) { - return viewport.contains(*bbox); + return viewport.contains(to_2geom(*bbox)); } else { return true; } @@ -692,15 +692,15 @@ SPDesktop::point() const Geom::Point pw = sp_canvas_window_to_world (canvas, p); p = w2d(pw); - NR::Rect const r = canvas->getViewbox(); + Geom::Rect const r = canvas->getViewbox(); Geom::Point r0 = w2d(r.min()); Geom::Point r1 = w2d(r.max()); - if (p[NR::X] >= r0[NR::X] && - p[NR::X] <= r1[NR::X] && - p[NR::Y] >= r1[NR::Y] && - p[NR::Y] <= r0[NR::Y]) + if (p[Geom::X] >= r0[Geom::X] && + p[Geom::X] <= r1[Geom::X] && + p[Geom::Y] >= r1[Geom::Y] && + p[Geom::Y] <= r0[Geom::Y]) { return p; } else { @@ -714,7 +714,7 @@ SPDesktop::point() const void SPDesktop::push_current_zoom (GList **history) { - NR::Rect const area = get_display_area(); + Geom::Rect const area = get_display_area(); NRRect *old_zoom = g_new(NRRect, 1); old_zoom->x0 = area.min()[NR::X]; @@ -750,14 +750,16 @@ SPDesktop::set_display_area (double x0, double y0, double x1, double y1, double double const cx = 0.5 * (x0 + x1); double const cy = 0.5 * (y0 + y1); - NR::Rect const viewbox = NR::expand(canvas->getViewbox(), border); + // FIXME: This 2geom idiom doesn't allow us to declare dbox const + Geom::Rect viewbox = canvas->getViewbox(); + viewbox.expandBy(border); double scale = _d2w.descrim(); double newscale; - if (((x1 - x0) * viewbox.dimensions()[NR::Y]) > ((y1 - y0) * viewbox.dimensions()[NR::X])) { - newscale = viewbox.dimensions()[NR::X] / (x1 - x0); + if (((x1 - x0) * viewbox.dimensions()[Geom::Y]) > ((y1 - y0) * viewbox.dimensions()[Geom::X])) { + newscale = viewbox.dimensions()[Geom::X] / (x1 - x0); } else { - newscale = viewbox.dimensions()[NR::Y] / (y1 - y0); + newscale = viewbox.dimensions()[Geom::Y] / (y1 - y0); } newscale = CLAMP(newscale, SP_DESKTOP_ZOOM_MIN, SP_DESKTOP_ZOOM_MAX); // unit: 'screen pixels' per 'document pixels' @@ -786,22 +788,22 @@ SPDesktop::set_display_area (double x0, double y0, double x1, double y1, double _widget->updateZoom(); } -void SPDesktop::set_display_area(NR::Rect const &a, NR::Coord b, bool log) +void SPDesktop::set_display_area(Geom::Rect const &a, Geom::Coord b, bool log) { - set_display_area(a.min()[NR::X], a.min()[NR::Y], a.max()[NR::X], a.max()[NR::Y], b, log); + set_display_area(a.min()[Geom::X], a.min()[Geom::Y], a.max()[Geom::X], a.max()[Geom::Y], b, log); } /** * Return viewbox dimensions. */ -NR::Rect SPDesktop::get_display_area() const +Geom::Rect SPDesktop::get_display_area() const { - NR::Rect const viewbox = canvas->getViewbox(); + Geom::Rect const viewbox = canvas->getViewbox(); double const scale = _d2w[0]; - return NR::Rect(Geom::Point(viewbox.min()[NR::X] / scale, viewbox.max()[NR::Y] / -scale), - Geom::Point(viewbox.max()[NR::X] / scale, viewbox.min()[NR::Y] / -scale)); + return Geom::Rect(Geom::Point(viewbox.min()[Geom::X] / scale, viewbox.max()[Geom::Y] / -scale), + Geom::Point(viewbox.max()[Geom::X] / scale, viewbox.min()[Geom::Y] / -scale)); } /** @@ -868,7 +870,7 @@ SPDesktop::zoom_absolute_keep_point (double cx, double cy, double px, double py, if (fabs(_d2w.descrim() - zoom) < 0.0001*zoom && (fabs(SP_DESKTOP_ZOOM_MAX - zoom) < 0.01 || fabs(SP_DESKTOP_ZOOM_MIN - zoom) < 0.000001)) return; - NR::Rect const viewbox = canvas->getViewbox(); + Geom::Rect const viewbox = canvas->getViewbox(); double const width2 = viewbox.dimensions()[NR::X] / zoom; double const height2 = viewbox.dimensions()[NR::Y] / zoom; @@ -895,7 +897,7 @@ SPDesktop::zoom_absolute (double cx, double cy, double zoom) void SPDesktop::zoom_relative_keep_point (double cx, double cy, double zoom) { - NR::Rect const area = get_display_area(); + Geom::Rect const area = get_display_area(); if (cx < area.min()[NR::X]) { cx = area.min()[NR::X]; @@ -933,10 +935,11 @@ SPDesktop::zoom_relative (double cx, double cy, double zoom) void SPDesktop::zoom_page() { - NR::Rect d(Geom::Point(0, 0), - Geom::Point(sp_document_width(doc()), sp_document_height(doc()))); + Geom::Rect d(Geom::Point(0, 0), + Geom::Point(sp_document_width(doc()), sp_document_height(doc()))); - if (d.isEmpty(1.0)) { + // FIXME: the original NR::Rect::isEmpty call contained an additional threshold of 1.0; is it safe to ignore it? + if (d.isEmpty()) { return; } @@ -949,14 +952,14 @@ SPDesktop::zoom_page() void SPDesktop::zoom_page_width() { - NR::Rect const a = get_display_area(); + Geom::Rect const a = get_display_area(); if (sp_document_width(doc()) < 1.0) { return; } - NR::Rect d(Geom::Point(0, a.midpoint()[NR::Y]), - Geom::Point(sp_document_width(doc()), a.midpoint()[NR::Y])); + Geom::Rect d(Geom::Point(0, a.midpoint()[Geom::Y]), + Geom::Point(sp_document_width(doc()), a.midpoint()[Geom::Y])); set_display_area(d, 10); } @@ -967,9 +970,10 @@ SPDesktop::zoom_page_width() void SPDesktop::zoom_selection() { - boost::optional const d = selection->bounds(); + boost::optional const d = to_2geom(selection->bounds()); - if ( !d || d->isEmpty(0.1) ) { + // FIXME: the original NR::Rect::isEmpty call contained an additional threshold of 0.1; is it safe to ignore it? + if ( !d || d->isEmpty() ) { return; } @@ -995,12 +999,13 @@ SPDesktop::zoom_drawing() SPItem *docitem = SP_ITEM (sp_document_root (doc())); g_return_if_fail (docitem != NULL); - boost::optional d = sp_item_bbox_desktop(docitem); + boost::optional d = to_2geom(sp_item_bbox_desktop(docitem)); /* Note that the second condition here indicates that ** there are no items in the drawing. */ - if ( !d || d->isEmpty(1.0) ) { + // FIXME: the original NR::Rect::isEmpty call contained an additional threshold of 1.0; is it safe to ignore it? + if ( !d || d->isEmpty() ) { return; } @@ -1025,9 +1030,9 @@ SPDesktop::scroll_world (double dx, double dy, bool is_scrolling) { g_assert(_widget); - NR::Rect const viewbox = canvas->getViewbox(); + Geom::Rect const viewbox = canvas->getViewbox(); - sp_canvas_scroll_to(canvas, viewbox.min()[NR::X] - dx, viewbox.min()[NR::Y] - dy, FALSE, is_scrolling); + sp_canvas_scroll_to(canvas, viewbox.min()[Geom::X] - dx, viewbox.min()[Geom::Y] - dy, FALSE, is_scrolling); /* update perspective lines if we are in the 3D box tool (so that infinite ones are shown correctly) */ sp_box3d_context_update_lines(event_context); @@ -1043,7 +1048,9 @@ SPDesktop::scroll_to_point (Geom::Point const &p, gdouble autoscrollspeed) // autoscrolldistance is in screen pixels, but the display area is in document units autoscrolldistance /= _d2w.descrim(); - NR::Rect const dbox = NR::expand(get_display_area(), -autoscrolldistance); + // FIXME: This 2geom idiom doesn't allow us to declare dbox const + Geom::Rect dbox = get_display_area(); + dbox.expandBy(-autoscrolldistance); if (!(p[NR::X] > dbox.min()[NR::X] && p[NR::X] < dbox.max()[NR::X]) || !(p[NR::Y] > dbox.min()[NR::Y] && p[NR::Y] < dbox.max()[NR::Y]) ) { @@ -1434,7 +1441,7 @@ SPDesktop::onDocumentResized (gdouble width, gdouble height) { _doc2dt[5] = height; sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (drawing), _doc2dt); - NR::Rect const a(Geom::Point(0, 0), Geom::Point(width, height)); + Geom::Rect const a(Geom::Point(0, 0), Geom::Point(width, height)); SP_CTRLRECT(page)->setRectangle(a); SP_CTRLRECT(page_border)->setRectangle(a); } diff --git a/src/desktop.h b/src/desktop.h index 27439ebcc..f02f5556c 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -29,9 +29,8 @@ #include #include -#include "libnr/nr-matrix.h" -#include "libnr/nr-matrix-fns.h" -#include "libnr/nr-rect.h" +#include <2geom/matrix.h> + #include "ui/view/view.h" #include "ui/view/edit-widget-interface.h" @@ -227,18 +226,16 @@ struct SPDesktop : public Inkscape::UI::View::View SPItem *group_at_point (Geom::Point const p) const; Geom::Point point() const; - NR::Rect get_display_area() const; + Geom::Rect get_display_area() const; void set_display_area (double x0, double y0, double x1, double y1, double border, bool log = true); - void set_display_area(NR::Rect const &a, NR::Coord border, bool log = true); + void set_display_area(Geom::Rect const &a, Geom::Coord border, bool log = true); void zoom_absolute (double cx, double cy, double zoom); void zoom_relative (double cx, double cy, double zoom); void zoom_absolute_keep_point (double cx, double cy, double px, double py, double zoom); void zoom_relative_keep_point (double cx, double cy, double zoom); void zoom_relative_keep_point (Geom::Point const &c, double const zoom) { - using NR::X; - using NR::Y; - zoom_relative_keep_point (c[X], c[Y], zoom); + zoom_relative_keep_point (c[Geom::X], c[Geom::Y], zoom); } void zoom_page(); @@ -246,7 +243,7 @@ struct SPDesktop : public Inkscape::UI::View::View void zoom_drawing(); void zoom_selection(); void zoom_grab_focus(); - double current_zoom() const { return NR::expansion(_d2w); } + double current_zoom() const { return _d2w.descrim(); } void prev_zoom(); void next_zoom(); @@ -254,9 +251,7 @@ struct SPDesktop : public Inkscape::UI::View::View void scroll_world (double dx, double dy, bool is_scrolling = false); void scroll_world (Geom::Point const scroll, bool is_scrolling = false) { - using NR::X; - using NR::Y; - scroll_world(scroll[X], scroll[Y], is_scrolling); + scroll_world(scroll[Geom::X], scroll[Geom::Y], is_scrolling); } void scroll_world_in_svg_coords (double dx, double dy, bool is_scrolling = false); diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index e06c2a3b0..e01958c9f 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -32,9 +32,9 @@ static void sp_canvas_arena_class_init(SPCanvasArenaClass *klass); static void sp_canvas_arena_init(SPCanvasArena *group); static void sp_canvas_arena_destroy(GtkObject *object); -static void sp_canvas_arena_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags); +static void sp_canvas_arena_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags); static void sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf); -static double sp_canvas_arena_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item); +static double sp_canvas_arena_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item); static gint sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event); static gint sp_canvas_arena_send_event (SPCanvasArena *arena, GdkEvent *event); @@ -137,7 +137,7 @@ sp_canvas_arena_destroy (GtkObject *object) } static void -sp_canvas_arena_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags) +sp_canvas_arena_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags) { SPCanvasArena *arena = SP_CANVAS_ARENA (item); @@ -165,8 +165,8 @@ sp_canvas_arena_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned i ec.send_event = TRUE; ec.subwindow = ec.window; ec.time = GDK_CURRENT_TIME; - ec.x = arena->c[NR::X]; - ec.y = arena->c[NR::Y]; + ec.x = arena->c[Geom::X]; + ec.y = arena->c[Geom::Y]; /* fixme: */ if (arena->active) { ec.type = GDK_LEAVE_NOTIFY; @@ -227,7 +227,7 @@ sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf) } static double -sp_canvas_arena_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item) +sp_canvas_arena_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item) { SPCanvasArena *arena = SP_CANVAS_ARENA (item); @@ -267,7 +267,7 @@ sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event) arena->cursor = TRUE; /* TODO ... event -> arena transform? */ - arena->c = NR::Point(event->crossing.x, event->crossing.y); + arena->c = Geom::Point(event->crossing.x, event->crossing.y); /* fixme: Not sure abut this, but seems the right thing (Lauris) */ nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, NR_ARENA_ITEM_STATE_PICK, NR_ARENA_ITEM_STATE_NONE); @@ -288,7 +288,7 @@ sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event) case GDK_MOTION_NOTIFY: /* TODO ... event -> arena transform? */ - arena->c = NR::Point(event->motion.x, event->motion.y); + arena->c = Geom::Point(event->motion.x, event->motion.y); /* fixme: Not sure abut this, but seems the right thing (Lauris) */ nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, NR_ARENA_ITEM_STATE_PICK, NR_ARENA_ITEM_STATE_NONE); diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index df402831e..0f5045c4d 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -197,8 +197,8 @@ CanvasAxonomGrid::CanvasAxonomGrid (SPNamedView * nv, Inkscape::XML::Node * in_r gridunit = sp_unit_get_by_abbreviation( prefs->getString("options.grids.axonom", "units").data() ); if (!gridunit) gridunit = &sp_unit_get_by_id(SP_UNIT_PX); - origin[NR::X] = sp_units_get_pixels( prefs->getDouble("options.grids.axonom", "origin_x", 0.0), *gridunit ); - origin[NR::Y] = sp_units_get_pixels( prefs->getDouble("options.grids.axonom", "origin_y", 0.0), *gridunit ); + origin[Geom::X] = sp_units_get_pixels( prefs->getDouble("options.grids.axonom", "origin_x", 0.0), *gridunit ); + origin[Geom::Y] = sp_units_get_pixels( prefs->getDouble("options.grids.axonom", "origin_y", 0.0), *gridunit ); color = prefs->getInt("options.grids.axonom", "color", 0x0000ff20); empcolor = prefs->getInt("options.grids.axonom", "empcolor", 0x0000ff40); empspacing = prefs->getInt("options.grids.axonom", "empspacing", 5); @@ -301,12 +301,12 @@ CanvasAxonomGrid::readRepr() /// @todo Replace direct XML preference node manipulation with calls to public prefs API gchar const *value; if ( (value = repr->attribute("originx")) ) { - sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[NR::X], &gridunit); - origin[NR::X] = sp_units_get_pixels(origin[NR::X], *(gridunit)); + sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[Geom::X], &gridunit); + origin[Geom::X] = sp_units_get_pixels(origin[Geom::X], *(gridunit)); } if ( (value = repr->attribute("originy")) ) { - sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[NR::Y], &gridunit); - origin[NR::Y] = sp_units_get_pixels(origin[NR::Y], *(gridunit)); + sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[Geom::Y], &gridunit); + origin[Geom::Y] = sp_units_get_pixels(origin[Geom::Y], *(gridunit)); } if ( (value = repr->attribute("spacingy")) ) { @@ -445,10 +445,10 @@ _wr.setUpdating (false); _rumg->setUnit (gridunit); gdouble val; - val = origin[NR::X]; + val = origin[Geom::X]; val = sp_pixels_get_units (val, *(gridunit)); _rsu_ox->setValue (val); - val = origin[NR::Y]; + val = origin[Geom::Y]; val = sp_pixels_get_units (val, *(gridunit)); _rsu_oy->setValue (val); val = lengthy; @@ -484,10 +484,10 @@ CanvasAxonomGrid::updateWidgets() _rumg.setUnit (gridunit); gdouble val; - val = origin[NR::X]; + val = origin[Geom::X]; val = sp_pixels_get_units (val, *(gridunit)); _rsu_ox.setValue (val); - val = origin[NR::Y]; + val = origin[Geom::Y]; val = sp_pixels_get_units (val, *(gridunit)); _rsu_oy.setValue (val); val = lengthy; @@ -510,10 +510,10 @@ CanvasAxonomGrid::updateWidgets() void -CanvasAxonomGrid::Update (NR::Matrix const &affine, unsigned int /*flags*/) +CanvasAxonomGrid::Update (Geom::Matrix const &affine, unsigned int /*flags*/) { ow = origin * affine; - sw = NR::Point(fabs(affine[0]),fabs(affine[3])); + sw = Geom::Point(fabs(affine[0]),fabs(affine[3])); for(int dim = 0; dim < 2; dim++) { gint scaling_factor = empspacing; @@ -534,10 +534,10 @@ CanvasAxonomGrid::Update (NR::Matrix const &affine, unsigned int /*flags*/) } - spacing_ylines = sw[NR::X] * lengthy /(tan_angle[X] + tan_angle[Z]); - lyw = sw[NR::Y] * lengthy; - lxw_x = (lengthy / tan_angle[X]) * sw[NR::X]; - lxw_z = (lengthy / tan_angle[Z]) * sw[NR::X]; + spacing_ylines = sw[Geom::X] * lengthy /(tan_angle[X] + tan_angle[Z]); + lyw = sw[Geom::Y] * lengthy; + lxw_x = (lengthy / tan_angle[X]) * sw[Geom::X]; + lxw_z = (lengthy / tan_angle[Z]) * sw[Geom::X]; if (empspacing == 0) { scaled = TRUE; @@ -563,12 +563,12 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) // bc = buffer patch coordinates // tl = topleft ; br = bottomright - NR::Point buf_tl_gc; - NR::Point buf_br_gc; - buf_tl_gc[NR::X] = buf->rect.x0 - ow[NR::X]; - buf_tl_gc[NR::Y] = buf->rect.y0 - ow[NR::Y]; - buf_br_gc[NR::X] = buf->rect.x1 - ow[NR::X]; - buf_br_gc[NR::Y] = buf->rect.y1 - ow[NR::Y]; + Geom::Point buf_tl_gc; + Geom::Point buf_br_gc; + buf_tl_gc[Geom::X] = buf->rect.x0 - ow[Geom::X]; + buf_tl_gc[Geom::Y] = buf->rect.y0 - ow[Geom::Y]; + buf_br_gc[Geom::X] = buf->rect.x1 - ow[Geom::X]; + buf_br_gc[Geom::Y] = buf->rect.y1 - ow[Geom::Y]; gdouble x; gdouble y; @@ -576,9 +576,9 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) // render the three separate line groups representing the main-axes // x-axis always goes from topleft to bottomright. (0,0) - (1,1) - gdouble const xintercept_y_bc = (buf_tl_gc[NR::X] * tan_angle[X]) - buf_tl_gc[NR::Y] ; + gdouble const xintercept_y_bc = (buf_tl_gc[Geom::X] * tan_angle[X]) - buf_tl_gc[Geom::Y] ; gdouble const xstart_y_sc = ( xintercept_y_bc - floor(xintercept_y_bc/lyw)*lyw ) + buf->rect.y0; - gint const xlinestart = (gint) Inkscape::round( (xstart_y_sc - buf->rect.x0*tan_angle[X] -ow[NR::Y]) / lyw ); + gint const xlinestart = (gint) Inkscape::round( (xstart_y_sc - buf->rect.x0*tan_angle[X] -ow[Geom::Y]) / lyw ); gint xlinenum = xlinestart; // lines starting on left side. for (y = xstart_y_sc; y < buf->rect.y1; y += lyw, xlinenum++) { @@ -610,8 +610,8 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) } // y-axis lines (vertical) - gdouble const ystart_x_sc = floor (buf_tl_gc[NR::X] / spacing_ylines) * spacing_ylines + ow[NR::X]; - gint const ylinestart = (gint) Inkscape::round((ystart_x_sc - ow[NR::X]) / spacing_ylines); + gdouble const ystart_x_sc = floor (buf_tl_gc[Geom::X] / spacing_ylines) * spacing_ylines + ow[Geom::X]; + gint const ylinestart = (gint) Inkscape::round((ystart_x_sc - ow[Geom::X]) / spacing_ylines); gint ylinenum = ylinestart; for (x = ystart_x_sc; x < buf->rect.x1; x += spacing_ylines, ylinenum++) { gint const x0 = (gint) Inkscape::round(x); @@ -624,9 +624,9 @@ CanvasAxonomGrid::Render (SPCanvasBuf *buf) } // z-axis always goes from bottomleft to topright. (0,1) - (1,0) - gdouble const zintercept_y_bc = (buf_tl_gc[NR::X] * -tan_angle[Z]) - buf_tl_gc[NR::Y] ; + gdouble const zintercept_y_bc = (buf_tl_gc[Geom::X] * -tan_angle[Z]) - buf_tl_gc[Geom::Y] ; gdouble const zstart_y_sc = ( zintercept_y_bc - floor(zintercept_y_bc/lyw)*lyw ) + buf->rect.y0; - gint const zlinestart = (gint) Inkscape::round( (zstart_y_sc + buf->rect.x0*tan_angle[Z] - ow[NR::Y]) / lyw ); + gint const zlinestart = (gint) Inkscape::round( (zstart_y_sc + buf->rect.x0*tan_angle[Z] - ow[Geom::Y]) / lyw ); gint zlinenum = zlinestart; // lines starting from left side for (y = zstart_y_sc; y < buf->rect.y1; y += lyw, zlinenum++) { diff --git a/src/display/canvas-axonomgrid.h b/src/display/canvas-axonomgrid.h index f8dc8e25a..1d255d798 100644 --- a/src/display/canvas-axonomgrid.h +++ b/src/display/canvas-axonomgrid.h @@ -7,7 +7,6 @@ */ #include -#include #include "xml/repr.h" #include @@ -35,7 +34,7 @@ public: CanvasAxonomGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc); virtual ~CanvasAxonomGrid(); - void Update (NR::Matrix const &affine, unsigned int flags); + void Update (Geom::Matrix const &affine, unsigned int flags); void Render (SPCanvasBuf *buf); void readRepr(); @@ -48,13 +47,13 @@ public: bool scaled; /**< Whether the grid is in scaled mode */ - NR::Point ow; /**< Transformed origin by the affine for the zoom */ + Geom::Point ow; /**< Transformed origin by the affine for the zoom */ double lyw; /**< Transformed length y by the affine for the zoom */ double lxw_x; double lxw_z; double spacing_ylines; - NR::Point sw; /**< the scaling factors of the affine transform */ + Geom::Point sw; /**< the scaling factors of the affine transform */ protected: virtual Gtk::Widget * newSpecificWidget(); diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp index 74b69b9c0..8342ff7ff 100644 --- a/src/display/canvas-bpath.cpp +++ b/src/display/canvas-bpath.cpp @@ -59,9 +59,9 @@ static void sp_canvas_bpath_class_init (SPCanvasBPathClass *klass); static void sp_canvas_bpath_init (SPCanvasBPath *path); static void sp_canvas_bpath_destroy (GtkObject *object); -static void sp_canvas_bpath_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags); +static void sp_canvas_bpath_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags); static void sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf); -static double sp_canvas_bpath_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item); +static double sp_canvas_bpath_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item); static SPCanvasItemClass *parent_class; @@ -128,7 +128,7 @@ sp_canvas_bpath_destroy (GtkObject *object) } static void -sp_canvas_bpath_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags) +sp_canvas_bpath_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags) { SPCanvasBPath *cbp = SP_CANVAS_BPATH (item); @@ -204,7 +204,7 @@ sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf) } static double -sp_canvas_bpath_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item) +sp_canvas_bpath_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item) { SPCanvasBPath *cbp = SP_CANVAS_BPATH (item); @@ -214,7 +214,7 @@ sp_canvas_bpath_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_it return NR_HUGE; double width = 0.5; - Geom::Rect viewbox = to_2geom(item->canvas->getViewbox()); + Geom::Rect viewbox = item->canvas->getViewbox(); viewbox.expandBy (width); double dist = NR_HUGE; pathv_matrix_point_bbox_wind_distance(cbp->curve->get_pathvector(), cbp->affine, p, NULL, NULL, &dist, 0.5, &viewbox); @@ -295,7 +295,7 @@ static void sp_canvastext_class_init (SPCanvasTextClass *klass); static void sp_canvastext_init (SPCanvasText *canvastext); static void sp_canvastext_destroy (GtkObject *object); -static void sp_canvastext_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags); +static void sp_canvastext_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags); static void sp_canvastext_render (SPCanvasItem *item, SPCanvasBuf *buf); static SPCanvasItemClass *parent_class_ct; @@ -337,8 +337,8 @@ static void sp_canvastext_init (SPCanvasText *canvastext) { canvastext->rgba = 0x0000ff7f; - canvastext->s[NR::X] = canvastext->s[NR::Y] = 0.0; - canvastext->affine = NR::identity(); + canvastext->s[Geom::X] = canvastext->s[Geom::Y] = 0.0; + canvastext->affine = Geom::identity(); canvastext->fontsize = 10.0; canvastext->item = NULL; canvastext->desktop = NULL; @@ -377,9 +377,9 @@ sp_canvastext_render (SPCanvasItem *item, SPCanvasBuf *buf) guint32 rgba = cl->rgba; cairo_set_source_rgba(buf->ct, SP_RGBA32_B_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_R_F(rgba), SP_RGBA32_A_F(rgba)); - NR::Point s = cl->s * cl->affine; - double offsetx = s[NR::X] - buf->rect.x0; - double offsety = s[NR::Y] - buf->rect.y0; + Geom::Point s = cl->s * cl->affine; + double offsetx = s[Geom::X] - buf->rect.x0; + double offsety = s[Geom::Y] - buf->rect.y0; offsetx -= anchor_offset_x; offsety += anchor_offset_y; @@ -392,7 +392,7 @@ sp_canvastext_render (SPCanvasItem *item, SPCanvasBuf *buf) } static void -sp_canvastext_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags) +sp_canvastext_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags) { SPCanvasText *cl = SP_CANVASTEXT (item); @@ -405,7 +405,7 @@ sp_canvastext_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int cl->affine = affine; - NR::Point s = cl->s * affine; + Geom::Point s = cl->s * affine; // set up a temporary cairo_t to measure the text extents; it would be better to compute this in the render() // method but update() seems to be called before so we don't have the information available when we need it @@ -414,10 +414,10 @@ sp_canvastext_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int cairo_text_extents_t bbox; cairo_text_extents(&tmp_buf, cl->text, &bbox); **/ - item->x1 = s[NR::X] + 0; - item->y1 = s[NR::Y] - cl->fontsize; - item->x2 = s[NR::X] + cl->fontsize * strlen(cl->text); - item->y2 = s[NR::Y] + cl->fontsize * 0.5; // for letters below the baseline + item->x1 = s[Geom::X] + 0; + item->y1 = s[Geom::Y] - cl->fontsize; + item->x2 = s[Geom::X] + cl->fontsize * strlen(cl->text); + item->y2 = s[Geom::Y] + cl->fontsize * 0.5; // for letters below the baseline // adjust update region according to anchor shift // FIXME: use the correct text extent @@ -471,20 +471,20 @@ sp_canvastext_set_rgba32 (SPCanvasText *ct, guint32 rgba) void sp_canvastext_set_coords (SPCanvasText *ct, gdouble x0, gdouble y0) { - sp_canvastext_set_coords(ct, NR::Point(x0, y0)); + sp_canvastext_set_coords(ct, Geom::Point(x0, y0)); } void -sp_canvastext_set_coords (SPCanvasText *ct, const NR::Point start) +sp_canvastext_set_coords (SPCanvasText *ct, const Geom::Point start) { - NR::Point pos = ct->desktop->doc2dt(start); + Geom::Point pos = ct->desktop->doc2dt(start); g_return_if_fail (ct != NULL); g_return_if_fail (SP_IS_CANVASTEXT (ct)); - if (DIFFER (pos[0], ct->s[NR::X]) || DIFFER (pos[1], ct->s[NR::Y])) { - ct->s[NR::X] = pos[0]; - ct->s[NR::Y] = pos[1]; + if (DIFFER (pos[0], ct->s[Geom::X]) || DIFFER (pos[1], ct->s[Geom::Y])) { + ct->s[Geom::X] = pos[0]; + ct->s[Geom::Y] = pos[1]; sp_canvas_item_request_update (SP_CANVAS_ITEM (ct)); } sp_canvas_item_request_update (SP_CANVAS_ITEM (ct)); diff --git a/src/display/canvas-bpath.h b/src/display/canvas-bpath.h index d6382b651..2001bfa7d 100644 --- a/src/display/canvas-bpath.h +++ b/src/display/canvas-bpath.h @@ -64,7 +64,7 @@ struct SPCanvasBPath { /* Line def */ SPCurve *curve; - NR::Matrix affine; + Geom::Matrix affine; /* Fill attributes */ guint32 fill_rgba; @@ -114,8 +114,8 @@ struct SPCanvasText : public SPCanvasItem{ SPDesktop *desktop; // the desktop to which this text is attached; needed for coordinate transforms (TODO: these should be eliminated) gchar* text; - NR::Point s; - NR::Matrix affine; + Geom::Point s; + Geom::Matrix affine; double fontsize; double anchor_x; double anchor_y; @@ -128,7 +128,7 @@ SPCanvasItem *sp_canvastext_new(SPCanvasGroup *parent, SPDesktop *desktop, Geom: void sp_canvastext_set_rgba32 (SPCanvasText *ct, guint32 rgba); void sp_canvastext_set_coords (SPCanvasText *ct, gdouble x0, gdouble y0); -void sp_canvastext_set_coords (SPCanvasText *ct, const NR::Point start); +void sp_canvastext_set_coords (SPCanvasText *ct, const Geom::Point start); void sp_canvastext_set_text (SPCanvasText *ct, gchar const* new_text); void sp_canvastext_set_number_as_text (SPCanvasText *ct, int num); void sp_canvastext_set_fontsize (SPCanvasText *ct, double size); diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 948b89e6a..9b6b512b0 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -52,7 +52,7 @@ static void grid_canvasitem_class_init (GridCanvasItemClass *klass); static void grid_canvasitem_init (GridCanvasItem *grid); static void grid_canvasitem_destroy (GtkObject *object); -static void grid_canvasitem_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags); +static void grid_canvasitem_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags); static void grid_canvasitem_render (SPCanvasItem *item, SPCanvasBuf *buf); static SPCanvasItemClass * parent_class; @@ -124,7 +124,7 @@ grid_canvasitem_render (SPCanvasItem * item, SPCanvasBuf * buf) } static void -grid_canvasitem_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags) +grid_canvasitem_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags) { GridCanvasItem *gridcanvasitem = INKSCAPE_GRID_CANVASITEM (item); @@ -419,13 +419,13 @@ CanvasXYGrid::CanvasXYGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr, SPD gridunit = sp_unit_get_by_abbreviation( prefs->getString("options.grids.xy", "units").data() ); if (!gridunit) gridunit = &sp_unit_get_by_id(SP_UNIT_PX); - origin[NR::X] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "origin_x", 0.0), *gridunit); - origin[NR::Y] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "origin_y", 0.0), *gridunit); + origin[Geom::X] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "origin_x", 0.0), *gridunit); + origin[Geom::Y] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "origin_y", 0.0), *gridunit); color = prefs->getInt("options.grids.xy", "color", 0x0000ff20); empcolor = prefs->getInt("options.grids.xy", "empcolor", 0x0000ff40); empspacing = prefs->getInt("options.grids.xy", "empspacing", 5); - spacing[NR::X] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "spacing_x", 0.0), *gridunit); - spacing[NR::Y] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "spacing_y", 0.0), *gridunit); + spacing[Geom::X] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "spacing_x", 0.0), *gridunit); + spacing[Geom::Y] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "spacing_y", 0.0), *gridunit); render_dotted = prefs->getBool("options.grids.xy", "dotted", false); snapper = new CanvasXYGridSnapper(this, &namedview->snap_manager, 0); @@ -568,27 +568,27 @@ CanvasXYGrid::readRepr() { gchar const *value; if ( (value = repr->attribute("originx")) ) { - sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[NR::X], &gridunit); - origin[NR::X] = sp_units_get_pixels(origin[NR::X], *(gridunit)); + sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[Geom::X], &gridunit); + origin[Geom::X] = sp_units_get_pixels(origin[Geom::X], *(gridunit)); } if ( (value = repr->attribute("originy")) ) { - sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[NR::Y], &gridunit); - origin[NR::Y] = sp_units_get_pixels(origin[NR::Y], *(gridunit)); + sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[Geom::Y], &gridunit); + origin[Geom::Y] = sp_units_get_pixels(origin[Geom::Y], *(gridunit)); } if ( (value = repr->attribute("spacingx")) ) { - double oldVal = spacing[NR::X]; - sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &spacing[NR::X], &gridunit); - validateScalar( oldVal, &spacing[NR::X]); - spacing[NR::X] = sp_units_get_pixels(spacing[NR::X], *(gridunit)); + double oldVal = spacing[Geom::X]; + sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &spacing[Geom::X], &gridunit); + validateScalar( oldVal, &spacing[Geom::X]); + spacing[Geom::X] = sp_units_get_pixels(spacing[Geom::X], *(gridunit)); } if ( (value = repr->attribute("spacingy")) ) { - double oldVal = spacing[NR::Y]; - sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &spacing[NR::Y], &gridunit); - validateScalar( oldVal, &spacing[NR::Y]); - spacing[NR::Y] = sp_units_get_pixels(spacing[NR::Y], *(gridunit)); + double oldVal = spacing[Geom::Y]; + sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &spacing[Geom::Y], &gridunit); + validateScalar( oldVal, &spacing[Geom::Y]); + spacing[Geom::Y] = sp_units_get_pixels(spacing[Geom::Y], *(gridunit)); } @@ -719,16 +719,16 @@ _wr.setUpdating (false); _rumg->setUnit (gridunit); gdouble val; - val = origin[NR::X]; + val = origin[Geom::X]; val = sp_pixels_get_units (val, *(gridunit)); _rsu_ox->setValue (val); - val = origin[NR::Y]; + val = origin[Geom::Y]; val = sp_pixels_get_units (val, *(gridunit)); _rsu_oy->setValue (val); - val = spacing[NR::X]; + val = spacing[Geom::X]; double gridx = sp_pixels_get_units (val, *(gridunit)); _rsu_sx->setValue (gridx); - val = spacing[NR::Y]; + val = spacing[Geom::Y]; double gridy = sp_pixels_get_units (val, *(gridunit)); _rsu_sy->setValue (gridy); @@ -761,16 +761,16 @@ CanvasXYGrid::updateWidgets() _rumg.setUnit (gridunit); gdouble val; - val = origin[NR::X]; + val = origin[Geom::X]; val = sp_pixels_get_units (val, *(gridunit)); _rsu_ox.setValue (val); - val = origin[NR::Y]; + val = origin[Geom::Y]; val = sp_pixels_get_units (val, *(gridunit)); _rsu_oy.setValue (val); - val = spacing[NR::X]; + val = spacing[Geom::X]; double gridx = sp_pixels_get_units (val, *(gridunit)); _rsu_sx.setValue (gridx); - val = spacing[NR::Y]; + val = spacing[Geom::Y]; double gridy = sp_pixels_get_units (val, *(gridunit)); _rsu_sy.setValue (gridy); @@ -789,11 +789,11 @@ CanvasXYGrid::updateWidgets() void -CanvasXYGrid::Update (NR::Matrix const &affine, unsigned int /*flags*/) +CanvasXYGrid::Update (Geom::Matrix const &affine, unsigned int /*flags*/) { ow = origin * affine; sw = spacing * affine; - sw -= NR::Point(affine[4], affine[5]); + sw -= Geom::Point(affine[4], affine[5]); for(int dim = 0; dim < 2; dim++) { gint scaling_factor = empspacing; @@ -881,16 +881,16 @@ grid_dot (SPCanvasBuf *buf, gint x, gint y, guint32 rgba) void CanvasXYGrid::Render (SPCanvasBuf *buf) { - gdouble const sxg = floor ((buf->rect.x0 - ow[NR::X]) / sw[NR::X]) * sw[NR::X] + ow[NR::X]; - gint const xlinestart = (gint) Inkscape::round((sxg - ow[NR::X]) / sw[NR::X]); - gdouble const syg = floor ((buf->rect.y0 - ow[NR::Y]) / sw[NR::Y]) * sw[NR::Y] + ow[NR::Y]; - gint const ylinestart = (gint) Inkscape::round((syg - ow[NR::Y]) / sw[NR::Y]); + gdouble const sxg = floor ((buf->rect.x0 - ow[Geom::X]) / sw[Geom::X]) * sw[Geom::X] + ow[Geom::X]; + gint const xlinestart = (gint) Inkscape::round((sxg - ow[Geom::X]) / sw[Geom::X]); + gdouble const syg = floor ((buf->rect.y0 - ow[Geom::Y]) / sw[Geom::Y]) * sw[Geom::Y] + ow[Geom::Y]; + gint const ylinestart = (gint) Inkscape::round((syg - ow[Geom::Y]) / sw[Geom::Y]); //set correct coloring, depending preference (when zoomed out, always major coloring or minor coloring) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); guint32 _empcolor; bool no_emp_when_zoomed_out = prefs->getBool("options.grids", "no_emphasize_when_zoomedout", false); - if( (scaled[NR::X] || scaled[NR::Y]) && no_emp_when_zoomed_out ) { + if( (scaled[Geom::X] || scaled[Geom::Y]) && no_emp_when_zoomed_out ) { _empcolor = color; } else { _empcolor = empcolor; @@ -899,9 +899,9 @@ CanvasXYGrid::Render (SPCanvasBuf *buf) if (!render_dotted) { gint ylinenum; gdouble y; - for (y = syg, ylinenum = ylinestart; y < buf->rect.y1; y += sw[NR::Y], ylinenum++) { + for (y = syg, ylinenum = ylinestart; y < buf->rect.y1; y += sw[Geom::Y], ylinenum++) { gint const y0 = (gint) Inkscape::round(y); - if (!scaled[NR::Y] && (ylinenum % empspacing) != 0) { + if (!scaled[Geom::Y] && (ylinenum % empspacing) != 0) { grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, color); } else { grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, _empcolor); @@ -910,9 +910,9 @@ CanvasXYGrid::Render (SPCanvasBuf *buf) gint xlinenum; gdouble x; - for (x = sxg, xlinenum = xlinestart; x < buf->rect.x1; x += sw[NR::X], xlinenum++) { + for (x = sxg, xlinenum = xlinestart; x < buf->rect.x1; x += sw[Geom::X], xlinenum++) { gint const ix = (gint) Inkscape::round(x); - if (!scaled[NR::X] && (xlinenum % empspacing) != 0) { + if (!scaled[Geom::X] && (xlinenum % empspacing) != 0) { grid_vline (buf, ix, buf->rect.y0, buf->rect.y1, color); } else { grid_vline (buf, ix, buf->rect.y0, buf->rect.y1, _empcolor); @@ -921,16 +921,16 @@ CanvasXYGrid::Render (SPCanvasBuf *buf) } else { gint ylinenum; gdouble y; - for (y = syg, ylinenum = ylinestart; y < buf->rect.y1; y += sw[NR::Y], ylinenum++) { + for (y = syg, ylinenum = ylinestart; y < buf->rect.y1; y += sw[Geom::Y], ylinenum++) { gint const iy = (gint) Inkscape::round(y); gint xlinenum; gdouble x; - for (x = sxg, xlinenum = xlinestart; x < buf->rect.x1; x += sw[NR::X], xlinenum++) { + for (x = sxg, xlinenum = xlinestart; x < buf->rect.x1; x += sw[Geom::X], xlinenum++) { gint const ix = (gint) Inkscape::round(x); - if ( (!scaled[NR::X] && (xlinenum % empspacing) != 0) - || (!scaled[NR::Y] && (ylinenum % empspacing) != 0) - || ((scaled[NR::X] || scaled[NR::Y]) && no_emp_when_zoomed_out) ) + if ( (!scaled[Geom::X] && (xlinenum % empspacing) != 0) + || (!scaled[Geom::Y] && (ylinenum % empspacing) != 0) + || ((scaled[Geom::X] || scaled[Geom::Y]) && no_emp_when_zoomed_out) ) { grid_dot (buf, ix, iy, color | (guint32)0x000000FF); // put alpha to max value } else { @@ -949,7 +949,7 @@ CanvasXYGrid::Render (SPCanvasBuf *buf) } } -CanvasXYGridSnapper::CanvasXYGridSnapper(CanvasXYGrid *grid, SnapManager const *sm, NR::Coord const d) : LineSnapper(sm, d) +CanvasXYGridSnapper::CanvasXYGridSnapper(CanvasXYGrid *grid, SnapManager const *sm, Geom::Coord const d) : LineSnapper(sm, d) { this->grid = grid; } diff --git a/src/display/canvas-grid.h b/src/display/canvas-grid.h index 20cb31473..66f3bc43c 100644 --- a/src/display/canvas-grid.h +++ b/src/display/canvas-grid.h @@ -81,7 +81,7 @@ public: GridCanvasItem * createCanvasItem(SPDesktop * desktop); - virtual void Update (NR::Matrix const &affine, unsigned int flags) = 0; + virtual void Update (Geom::Matrix const &affine, unsigned int flags) = 0; virtual void Render (SPCanvasBuf *buf) = 0; virtual void readRepr() = 0; @@ -89,7 +89,7 @@ public: Gtk::Widget * newWidget(); - NR::Point origin; /**< Origin of the grid */ + Geom::Point origin; /**< Origin of the grid */ guint32 color; /**< Color for normal lines */ guint32 empcolor; /**< Color for emphasis lines */ gint empspacing; /**< Spacing between emphasis lines */ @@ -131,18 +131,18 @@ public: CanvasXYGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc); virtual ~CanvasXYGrid(); - void Update (NR::Matrix const &affine, unsigned int flags); + void Update (Geom::Matrix const &affine, unsigned int flags); void Render (SPCanvasBuf *buf); void readRepr(); void onReprAttrChanged (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive); - NR::Point spacing; /**< Spacing between elements of the grid */ + Geom::Point spacing; /**< Spacing between elements of the grid */ bool scaled[2]; /**< Whether the grid is in scaled mode, which can be different in the X or Y direction, hense two variables */ - NR::Point ow; /**< Transformed origin by the affine for the zoom */ - NR::Point sw; /**< Transformed spacing by the affine for the zoom */ + Geom::Point ow; /**< Transformed origin by the affine for the zoom */ + Geom::Point sw; /**< Transformed spacing by the affine for the zoom */ protected: virtual Gtk::Widget * newSpecificWidget(); diff --git a/src/display/gnome-canvas-acetate.cpp b/src/display/gnome-canvas-acetate.cpp index ee6834075..fdb137e27 100644 --- a/src/display/gnome-canvas-acetate.cpp +++ b/src/display/gnome-canvas-acetate.cpp @@ -21,8 +21,8 @@ static void sp_canvas_acetate_class_init (SPCanvasAcetateClass *klass); static void sp_canvas_acetate_init (SPCanvasAcetate *acetate); static void sp_canvas_acetate_destroy (GtkObject *object); -static void sp_canvas_acetate_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags); -static double sp_canvas_acetate_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item); +static void sp_canvas_acetate_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags); +static double sp_canvas_acetate_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item); static SPCanvasItemClass *parent_class; @@ -82,7 +82,7 @@ sp_canvas_acetate_destroy (GtkObject *object) } static void -sp_canvas_acetate_update( SPCanvasItem *item, NR::Matrix const &/*affine*/, unsigned int /*flags*/ ) +sp_canvas_acetate_update( SPCanvasItem *item, Geom::Matrix const &/*affine*/, unsigned int /*flags*/ ) { item->x1 = -G_MAXINT; item->y1 = -G_MAXINT; @@ -91,7 +91,7 @@ sp_canvas_acetate_update( SPCanvasItem *item, NR::Matrix const &/*affine*/, unsi } static double -sp_canvas_acetate_point( SPCanvasItem *item, NR::Point /*p*/, SPCanvasItem **actual_item ) +sp_canvas_acetate_point( SPCanvasItem *item, Geom::Point /*p*/, SPCanvasItem **actual_item ) { *actual_item = item; diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp index e2e014eff..cd1a12213 100644 --- a/src/display/guideline.cpp +++ b/src/display/guideline.cpp @@ -15,6 +15,7 @@ #include +#include <2geom/transforms.h> #include "display-forward.h" #include "sp-canvas-util.h" #include "guideline.h" @@ -23,10 +24,10 @@ static void sp_guideline_class_init(SPGuideLineClass *c); static void sp_guideline_init(SPGuideLine *guideline); static void sp_guideline_destroy(GtkObject *object); -static void sp_guideline_update(SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags); +static void sp_guideline_update(SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags); static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf); -static double sp_guideline_point(SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item); +static double sp_guideline_point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item); static void sp_guideline_drawline (SPCanvasBuf *buf, gint x0, gint y0, gint x1, gint y1, guint32 rgba); @@ -168,7 +169,7 @@ static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf) } } -static void sp_guideline_update(SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags) +static void sp_guideline_update(SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags) { SPGuideLine *gl = SP_GUIDELINE(item); @@ -189,7 +190,7 @@ static void sp_guideline_update(SPCanvasItem *item, NR::Matrix const &affine, un } // Returns 0.0 if point is on the guideline -static double sp_guideline_point(SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item) +static double sp_guideline_point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item) { SPGuideLine *gl = SP_GUIDELINE (item); @@ -221,7 +222,7 @@ SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, Geom::Point point_on_line, void sp_guideline_set_position(SPGuideLine *gl, Geom::Point point_on_line) { sp_canvas_item_affine_absolute(SP_CANVAS_ITEM (gl), - NR::Matrix(NR::translate(point_on_line))); + Geom::Matrix(Geom::Translate(point_on_line))); } void sp_guideline_set_normal(SPGuideLine *gl, Geom::Point normal_to_line) diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index 554ea2dc9..751801c7e 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -1094,7 +1094,7 @@ nr_arena_shape_pick(NRArenaItem *item, NR::Point p, double delta, unsigned int / && shape->_fill.opacity > 1e-3 && !outline); if (item->arena->canvasarena) { - Geom::Rect viewbox = to_2geom(item->arena->canvasarena->item.canvas->getViewbox()); + Geom::Rect viewbox = item->arena->canvasarena->item.canvas->getViewbox(); viewbox.expandBy (width); pathv_matrix_point_bbox_wind_distance(shape->curve->get_pathvector(), shape->ctm, p, NULL, needfill? &wind : NULL, &dist, 0.5, &viewbox); } else { diff --git a/src/display/sodipodi-ctrl.cpp b/src/display/sodipodi-ctrl.cpp index db199d3a5..1bed9355d 100644 --- a/src/display/sodipodi-ctrl.cpp +++ b/src/display/sodipodi-ctrl.cpp @@ -8,6 +8,7 @@ * */ +#include <2geom/transforms.h> #include "sp-canvas-util.h" #include "display-forward.h" #include "sodipodi-ctrl.h" @@ -31,10 +32,10 @@ static void sp_ctrl_init (SPCtrl *ctrl); static void sp_ctrl_destroy (GtkObject *object); static void sp_ctrl_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void sp_ctrl_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags); +static void sp_ctrl_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags); static void sp_ctrl_render (SPCanvasItem *item, SPCanvasBuf *buf); -static double sp_ctrl_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item); +static double sp_ctrl_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item); static SPCanvasItemClass *parent_class; @@ -202,7 +203,7 @@ sp_ctrl_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) } static void -sp_ctrl_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags) +sp_ctrl_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags) { SPCtrl *ctrl; gint x, y; @@ -272,14 +273,14 @@ sp_ctrl_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags } static double -sp_ctrl_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item) +sp_ctrl_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item) { SPCtrl *ctrl = SP_CTRL (item); *actual_item = item; - double const x = p[NR::X]; - double const y = p[NR::Y]; + double const x = p[Geom::X]; + double const y = p[Geom::Y]; if ((x >= ctrl->box.x0) && (x <= ctrl->box.x1) && (y >= ctrl->box.y0) && (y <= ctrl->box.y1)) return 0.0; @@ -540,8 +541,8 @@ sp_ctrl_render (SPCanvasItem *item, SPCanvasBuf *buf) ctrl->shown = TRUE; } -void SPCtrl::moveto (NR::Point const p) { - sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (this), NR::Matrix(NR::translate (p))); +void SPCtrl::moveto (Geom::Point const p) { + sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (this), Geom::Matrix(Geom::Translate (p))); _moved = true; } diff --git a/src/display/sodipodi-ctrl.h b/src/display/sodipodi-ctrl.h index 2a68d1943..634e9ff3e 100644 --- a/src/display/sodipodi-ctrl.h +++ b/src/display/sodipodi-ctrl.h @@ -53,7 +53,7 @@ struct SPCtrl : public SPCanvasItem{ guchar *cache; GdkPixbuf * pixbuf; - void moveto(NR::Point const p); + void moveto(Geom::Point const p); }; struct SPCtrlClass : public SPCanvasItemClass{ diff --git a/src/display/sodipodi-ctrlrect.cpp b/src/display/sodipodi-ctrlrect.cpp index 28c76e704..682488efc 100644 --- a/src/display/sodipodi-ctrlrect.cpp +++ b/src/display/sodipodi-ctrlrect.cpp @@ -31,7 +31,7 @@ static void sp_ctrlrect_class_init(SPCtrlRectClass *c); static void sp_ctrlrect_init(CtrlRect *ctrlrect); static void sp_ctrlrect_destroy(GtkObject *object); -static void sp_ctrlrect_update(SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags); +static void sp_ctrlrect_update(SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags); static void sp_ctrlrect_render(SPCanvasItem *item, SPCanvasBuf *buf); static SPCanvasItemClass *parent_class; @@ -161,7 +161,7 @@ static void sp_ctrlrect_render(SPCanvasItem *item, SPCanvasBuf *buf) } -static void sp_ctrlrect_update(SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags) +static void sp_ctrlrect_update(SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags) { SP_CTRLRECT(item)->update(affine, flags); } @@ -177,7 +177,7 @@ void CtrlRect::init() _area.x0 = _area.y0 = 0; _area.x1 = _area.y1 = 0; - _rect = NR::Rect(NR::Point(0,0),NR::Point(0,0)); + _rect = Geom::Rect(Geom::Point(0,0),Geom::Point(0,0)); _shadow_size = 0; @@ -221,7 +221,7 @@ void CtrlRect::render(SPCanvasBuf *buf) } -void CtrlRect::update(NR::Matrix const &affine, unsigned int flags) +void CtrlRect::update(Geom::Matrix const &affine, unsigned int flags) { if (((SPCanvasItemClass *) parent_class)->update) { ((SPCanvasItemClass *) parent_class)->update(this, affine, flags); @@ -255,12 +255,12 @@ void CtrlRect::update(NR::Matrix const &affine, unsigned int flags) } } - NR::Rect bbox(_rect.min() * affine, _rect.max() * affine); + Geom::Rect bbox(_rect.min() * affine, _rect.max() * affine); - _area.x0 = (int) floor(bbox.min()[NR::X] + 0.5); - _area.y0 = (int) floor(bbox.min()[NR::Y] + 0.5); - _area.x1 = (int) floor(bbox.max()[NR::X] + 0.5); - _area.y1 = (int) floor(bbox.max()[NR::Y] + 0.5); + _area.x0 = (int) floor(bbox.min()[Geom::X] + 0.5); + _area.y0 = (int) floor(bbox.min()[Geom::Y] + 0.5); + _area.x1 = (int) floor(bbox.max()[Geom::X] + 0.5); + _area.y1 = (int) floor(bbox.max()[Geom::Y] + 0.5); _shadow_size = _shadow; @@ -312,7 +312,7 @@ void CtrlRect::setShadow(int s, guint c) _requestUpdate(); } -void CtrlRect::setRectangle(NR::Rect const &r) +void CtrlRect::setRectangle(Geom::Rect const &r) { _rect = r; _requestUpdate(); diff --git a/src/display/sodipodi-ctrlrect.h b/src/display/sodipodi-ctrlrect.h index dc931b7dc..7e5f5157e 100644 --- a/src/display/sodipodi-ctrlrect.h +++ b/src/display/sodipodi-ctrlrect.h @@ -32,16 +32,16 @@ public: void init(); void setColor(guint32 b, bool h, guint f); void setShadow(int s, guint c); - void setRectangle(NR::Rect const &r); + void setRectangle(Geom::Rect const &r); void setDashed(bool d); void render(SPCanvasBuf *buf); - void update(NR::Matrix const &affine, unsigned int flags); + void update(Geom::Matrix const &affine, unsigned int flags); private: void _requestUpdate(); - NR::Rect _rect; + Geom::Rect _rect; bool _has_fill; bool _dashed; NRRectL _area; diff --git a/src/display/sp-canvas-util.cpp b/src/display/sp-canvas-util.cpp index 9be8d5844..4badb6c3e 100644 --- a/src/display/sp-canvas-util.cpp +++ b/src/display/sp-canvas-util.cpp @@ -76,7 +76,7 @@ sp_canvas_clear_buffer (SPCanvasBuf *buf) } } -NR::Matrix sp_canvas_item_i2p_affine (SPCanvasItem * item) +Geom::Matrix sp_canvas_item_i2p_affine (SPCanvasItem * item) { g_assert (item != NULL); /* this may be overly zealous - it is * plausible that this gets called @@ -85,7 +85,7 @@ NR::Matrix sp_canvas_item_i2p_affine (SPCanvasItem * item) return item->xform; } -NR::Matrix sp_canvas_item_i2i_affine (SPCanvasItem * from, SPCanvasItem * to) +Geom::Matrix sp_canvas_item_i2i_affine (SPCanvasItem * from, SPCanvasItem * to) { g_assert (from != NULL); g_assert (to != NULL); @@ -93,7 +93,7 @@ NR::Matrix sp_canvas_item_i2i_affine (SPCanvasItem * from, SPCanvasItem * to) return sp_canvas_item_i2w_affine(from) * sp_canvas_item_i2w_affine(to).inverse(); } -void sp_canvas_item_set_i2w_affine (SPCanvasItem * item, NR::Matrix const &i2w) +void sp_canvas_item_set_i2w_affine (SPCanvasItem * item, Geom::Matrix const &i2w) { g_assert (item != NULL); diff --git a/src/display/sp-canvas-util.h b/src/display/sp-canvas-util.h index 0b2ec40d7..4708126e5 100644 --- a/src/display/sp-canvas-util.h +++ b/src/display/sp-canvas-util.h @@ -28,15 +28,15 @@ sp_canvas_clear_buffer (SPCanvasBuf * buf); /* get i2p (item to parent) affine transformation as general 6-element array */ -NR::Matrix sp_canvas_item_i2p_affine (SPCanvasItem * item); +Geom::Matrix sp_canvas_item_i2p_affine (SPCanvasItem * item); /* get i2i (item to item) affine transformation as general 6-element array */ -NR::Matrix sp_canvas_item_i2i_affine (SPCanvasItem * from, SPCanvasItem * to); +Geom::Matrix sp_canvas_item_i2i_affine (SPCanvasItem * from, SPCanvasItem * to); /* set item affine matrix to achieve given i2w matrix */ -void sp_canvas_item_set_i2w_affine (SPCanvasItem * item, NR::Matrix const & aff); +void sp_canvas_item_set_i2w_affine (SPCanvasItem * item, Geom::Matrix const & aff); void sp_canvas_item_move_to_z (SPCanvasItem * item, gint z); diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 3beb26b72..fd124aa1e 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -171,7 +171,7 @@ static void sp_canvas_item_init (SPCanvasItem *item) { item->flags |= SP_CANVAS_ITEM_VISIBLE; - item->xform = NR::Matrix(NR::identity()); + item->xform = Geom::Matrix(Geom::identity()); } /** @@ -246,7 +246,7 @@ sp_canvas_item_dispose (GObject *object) // this redraws only the stroke of the rect to be deleted, // avoiding redraw of the entire area if (SP_IS_CTRLRECT(item)) { - SP_CTRLRECT(object)->setRectangle(NR::Rect(NR::Point(0,0),NR::Point(0,0))); + SP_CTRLRECT(object)->setRectangle(Geom::Rect(Geom::Point(0,0),Geom::Point(0,0))); SP_CTRLRECT(object)->update(item->xform, 0); } else { redraw_if_visible (item); @@ -284,10 +284,10 @@ sp_canvas_item_dispose (GObject *object) * NB! affine is parent2canvas. */ static void -sp_canvas_item_invoke_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags) +sp_canvas_item_invoke_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags) { /* Apply the child item's transform */ - NR::Matrix child_affine = item->xform * affine; + Geom::Matrix child_affine = item->xform * affine; /* apply object flags to child flags */ int child_flags = flags & ~SP_CANVAS_UPDATE_REQUESTED; @@ -331,7 +331,7 @@ sp_canvas_item_invoke_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **a * @affine: An affine transformation matrix. */ void -sp_canvas_item_affine_absolute (SPCanvasItem *item, NR::Matrix const &affine) +sp_canvas_item_affine_absolute (SPCanvasItem *item, Geom::Matrix const &affine) { item->xform = affine; @@ -586,11 +586,11 @@ sp_canvas_item_ungrab (SPCanvasItem *item, guint32 etime) * Returns the product of all transformation matrices from the root item down * to the item. */ -NR::Matrix sp_canvas_item_i2w_affine(SPCanvasItem const *item) +Geom::Matrix sp_canvas_item_i2w_affine(SPCanvasItem const *item) { g_assert (SP_IS_CANVAS_ITEM (item)); // should we get this? - NR::Matrix affine = NR::identity(); + Geom::Matrix affine = Geom::identity(); while (item) { affine *= item->xform; @@ -685,8 +685,8 @@ static void sp_canvas_group_class_init (SPCanvasGroupClass *klass); static void sp_canvas_group_init (SPCanvasGroup *group); static void sp_canvas_group_destroy (GtkObject *object); -static void sp_canvas_group_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags); -static double sp_canvas_group_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item); +static void sp_canvas_group_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags); +static double sp_canvas_group_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item); static void sp_canvas_group_render (SPCanvasItem *item, SPCanvasBuf *buf); static SPCanvasItemClass *group_parent_class; @@ -770,10 +770,10 @@ sp_canvas_group_destroy (GtkObject *object) * Update handler for canvas groups */ static void -sp_canvas_group_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags) +sp_canvas_group_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags) { SPCanvasGroup const *group = SP_CANVAS_GROUP (item); - NR::ConvexHull corners(NR::Point(0, 0)); + NR::ConvexHull corners(Geom::Point(0, 0)); bool empty=true; for (GList *list = group->items; list; list = list->next) { @@ -783,12 +783,12 @@ sp_canvas_group_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned i if ( i->x2 > i->x1 && i->y2 > i->y1 ) { if (empty) { - corners = NR::ConvexHull(NR::Point(i->x1, i->y1)); + corners = NR::ConvexHull(Geom::Point(i->x1, i->y1)); empty = false; } else { - corners.add(NR::Point(i->x1, i->y1)); + corners.add(Geom::Point(i->x1, i->y1)); } - corners.add(NR::Point(i->x2, i->y2)); + corners.add(Geom::Point(i->x2, i->y2)); } } @@ -808,11 +808,11 @@ sp_canvas_group_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned i * Point handler for canvas groups. */ static double -sp_canvas_group_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item) +sp_canvas_group_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item) { SPCanvasGroup const *group = SP_CANVAS_GROUP (item); - double const x = p[NR::X]; - double const y = p[NR::Y]; + double const x = p[Geom::X]; + double const y = p[Geom::Y]; int x1 = (int)(x - item->canvas->close_enough); int y1 = (int)(y - item->canvas->close_enough); int x2 = (int)(x + item->canvas->close_enough); @@ -1821,7 +1821,7 @@ The default for now is the strips mode. lo.x1 = mid; hi.x0 = mid; - if (setup->mouse_loc[NR::X] < mid) { + if (setup->mouse_loc[Geom::X] < mid) { // Always paint towards the mouse first return sp_canvas_paint_rect_internal(setup, lo) && sp_canvas_paint_rect_internal(setup, hi); @@ -1838,7 +1838,7 @@ The default for now is the strips mode. lo.y1 = mid; hi.y0 = mid; - if (setup->mouse_loc[NR::Y] < mid) { + if (setup->mouse_loc[Geom::Y] < mid) { // Always paint towards the mouse first return sp_canvas_paint_rect_internal(setup, lo) && sp_canvas_paint_rect_internal(setup, hi); @@ -2029,7 +2029,7 @@ static int paint (SPCanvas *canvas) { if (canvas->need_update) { - sp_canvas_item_invoke_update (canvas->root, NR::identity(), 0); + sp_canvas_item_invoke_update (canvas->root, Geom::identity(), 0); canvas->need_update = FALSE; } @@ -2086,7 +2086,7 @@ do_update (SPCanvas *canvas) /* Cause the update if necessary */ if (canvas->need_update) { - sp_canvas_item_invoke_update (canvas->root, NR::identity(), 0); + sp_canvas_item_invoke_update (canvas->root, Geom::identity(), 0); canvas->need_update = FALSE; } @@ -2296,23 +2296,21 @@ bool sp_canvas_world_pt_inside_window(SPCanvas const *canvas, Geom::Point const g_assert( canvas != NULL ); g_assert(SP_IS_CANVAS(canvas)); - using NR::X; - using NR::Y; GtkWidget const &w = *GTK_WIDGET(canvas); - return ( ( canvas->x0 <= world[X] ) && - ( canvas->y0 <= world[Y] ) && - ( world[X] < canvas->x0 + w.allocation.width ) && - ( world[Y] < canvas->y0 + w.allocation.height ) ); + return ( ( canvas->x0 <= world[Geom::X] ) && + ( canvas->y0 <= world[Geom::Y] ) && + ( world[Geom::X] < canvas->x0 + w.allocation.width ) && + ( world[Geom::Y] < canvas->y0 + w.allocation.height ) ); } /** - * Return canvas window coordinates as NR::Rect. + * Return canvas window coordinates as Geom::Rect. */ -NR::Rect SPCanvas::getViewbox() const +Geom::Rect SPCanvas::getViewbox() const { GtkWidget const *w = GTK_WIDGET(this); - return NR::Rect(Geom::Point(dx0, dy0), - Geom::Point(dx0 + w->allocation.width, dy0 + w->allocation.height)); + return Geom::Rect(Geom::Point(dx0, dy0), + Geom::Point(dx0 + w->allocation.width, dy0 + w->allocation.height)); } /** diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index 8f743436f..60bda5818 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -36,9 +36,10 @@ #include #include -#include #include +#include <2geom/rect.h> + G_BEGIN_DECLS struct SPCanvas; @@ -75,17 +76,17 @@ struct SPCanvasItem : public GtkObject { double x1, y1, x2, y2; NR::Rect bounds; - NR::Matrix xform; + Geom::Matrix xform; }; /** * The vtable of an SPCanvasItem. */ struct _SPCanvasItemClass : public GtkObjectClass { - void (* update) (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags); + void (* update) (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags); void (* render) (SPCanvasItem *item, SPCanvasBuf *buf); - double (* point) (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item); + double (* point) (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item); int (* event) (SPCanvasItem *item, GdkEvent *event); }; @@ -96,7 +97,7 @@ G_END_DECLS #define sp_canvas_item_set gtk_object_set -void sp_canvas_item_affine_absolute(SPCanvasItem *item, NR::Matrix const &aff); +void sp_canvas_item_affine_absolute(SPCanvasItem *item, Geom::Matrix const &aff); void sp_canvas_item_raise(SPCanvasItem *item, int positions); void sp_canvas_item_lower(SPCanvasItem *item, int positions); @@ -105,7 +106,7 @@ void sp_canvas_item_hide(SPCanvasItem *item); int sp_canvas_item_grab(SPCanvasItem *item, unsigned int event_mask, GdkCursor *cursor, guint32 etime); void sp_canvas_item_ungrab(SPCanvasItem *item, guint32 etime); -NR::Matrix sp_canvas_item_i2w_affine(SPCanvasItem const *item); +Geom::Matrix sp_canvas_item_i2w_affine(SPCanvasItem const *item); void sp_canvas_item_grab_focus(SPCanvasItem *item); @@ -190,7 +191,7 @@ struct SPCanvas { bool is_scrolling; - NR::Rect getViewbox() const; + Geom::Rect getViewbox() const; NR::IRect getViewboxIntegers() const; }; diff --git a/src/display/sp-ctrlline.cpp b/src/display/sp-ctrlline.cpp index 8f71a0cc0..be0b8d1c6 100644 --- a/src/display/sp-ctrlline.cpp +++ b/src/display/sp-ctrlline.cpp @@ -34,7 +34,7 @@ static void sp_ctrlline_class_init (SPCtrlLineClass *klass); static void sp_ctrlline_init (SPCtrlLine *ctrlline); static void sp_ctrlline_destroy (GtkObject *object); -static void sp_ctrlline_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags); +static void sp_ctrlline_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags); static void sp_ctrlline_render (SPCanvasItem *item, SPCanvasBuf *buf); static SPCanvasItemClass *parent_class; @@ -77,7 +77,7 @@ static void sp_ctrlline_init (SPCtrlLine *ctrlline) { ctrlline->rgba = 0x0000ff7f; - ctrlline->s[NR::X] = ctrlline->s[NR::Y] = ctrlline->e[NR::X] = ctrlline->e[NR::Y] = 0.0; + ctrlline->s[Geom::X] = ctrlline->s[Geom::Y] = ctrlline->e[Geom::X] = ctrlline->e[Geom::Y] = 0.0; ctrlline->item=NULL; } @@ -111,17 +111,17 @@ sp_ctrlline_render (SPCanvasItem *item, SPCanvasBuf *buf) cairo_set_line_width(buf->ct, 1); cairo_new_path(buf->ct); - NR::Point s = cl->s * cl->affine; - NR::Point e = cl->e * cl->affine; + Geom::Point s = cl->s * cl->affine; + Geom::Point e = cl->e * cl->affine; - cairo_move_to (buf->ct, s[NR::X] - buf->rect.x0, s[NR::Y] - buf->rect.y0); - cairo_line_to (buf->ct, e[NR::X] - buf->rect.x0, e[NR::Y] - buf->rect.y0); + cairo_move_to (buf->ct, s[Geom::X] - buf->rect.x0, s[Geom::Y] - buf->rect.y0); + cairo_line_to (buf->ct, e[Geom::X] - buf->rect.x0, e[Geom::Y] - buf->rect.y0); cairo_stroke(buf->ct); } static void -sp_ctrlline_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags) +sp_ctrlline_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags) { SPCtrlLine *cl = SP_CTRLLINE (item); @@ -134,13 +134,13 @@ sp_ctrlline_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int f cl->affine = affine; - NR::Point s = cl->s * affine; - NR::Point e = cl->e * affine; + Geom::Point s = cl->s * affine; + Geom::Point e = cl->e * affine; - item->x1 = round(MIN(s[NR::X], e[NR::X]) - 1); - item->y1 = round(MIN(s[NR::Y], e[NR::Y]) - 1); - item->x2 = round(MAX(s[NR::X], e[NR::X]) + 1); - item->y2 = round(MAX(s[NR::Y], e[NR::Y]) + 1); + item->x1 = round(MIN(s[Geom::X], e[Geom::X]) - 1); + item->y1 = round(MIN(s[Geom::Y], e[Geom::Y]) - 1); + item->x2 = round(MAX(s[Geom::X], e[Geom::X]) + 1); + item->y2 = round(MAX(s[Geom::Y], e[Geom::Y]) + 1); sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2); } @@ -168,17 +168,17 @@ sp_ctrlline_set_coords (SPCtrlLine *cl, gdouble x0, gdouble y0, gdouble x1, gdou g_return_if_fail (cl != NULL); g_return_if_fail (SP_IS_CTRLLINE (cl)); - if (DIFFER (x0, cl->s[NR::X]) || DIFFER (y0, cl->s[NR::Y]) || DIFFER (x1, cl->e[NR::X]) || DIFFER (y1, cl->e[NR::Y])) { - cl->s[NR::X] = x0; - cl->s[NR::Y] = y0; - cl->e[NR::X] = x1; - cl->e[NR::Y] = y1; + if (DIFFER (x0, cl->s[Geom::X]) || DIFFER (y0, cl->s[Geom::Y]) || DIFFER (x1, cl->e[Geom::X]) || DIFFER (y1, cl->e[Geom::Y])) { + cl->s[Geom::X] = x0; + cl->s[Geom::Y] = y0; + cl->e[Geom::X] = x1; + cl->e[Geom::Y] = y1; sp_canvas_item_request_update (SP_CANVAS_ITEM (cl)); } } void -sp_ctrlline_set_coords (SPCtrlLine *cl, const NR::Point start, const NR::Point end) +sp_ctrlline_set_coords (SPCtrlLine *cl, const Geom::Point start, const Geom::Point end) { sp_ctrlline_set_coords(cl, start[0], start[1], end[0], end[1]); } diff --git a/src/display/sp-ctrlline.h b/src/display/sp-ctrlline.h index 88bebe601..696fb52ee 100644 --- a/src/display/sp-ctrlline.h +++ b/src/display/sp-ctrlline.h @@ -25,8 +25,8 @@ struct SPItem; struct SPCtrlLine : public SPCanvasItem{ SPItem *item; // the item to which this line belongs in some sense; may be NULL for some users guint32 rgba; - NR::Point s, e; - NR::Matrix affine; + Geom::Point s, e; + Geom::Matrix affine; }; struct SPCtrlLineClass : public SPCanvasItemClass{}; @@ -34,7 +34,7 @@ GType sp_ctrlline_get_type (void); void sp_ctrlline_set_rgba32 (SPCtrlLine *cl, guint32 rgba); void sp_ctrlline_set_coords (SPCtrlLine *cl, gdouble x0, gdouble y0, gdouble x1, gdouble y1); -void sp_ctrlline_set_coords (SPCtrlLine *cl, const NR::Point start, const NR::Point end); +void sp_ctrlline_set_coords (SPCtrlLine *cl, const Geom::Point start, const Geom::Point end); diff --git a/src/display/sp-ctrlquadr.cpp b/src/display/sp-ctrlquadr.cpp index c8a71512d..31766c3c2 100644 --- a/src/display/sp-ctrlquadr.cpp +++ b/src/display/sp-ctrlquadr.cpp @@ -23,8 +23,8 @@ struct SPCtrlQuadr : public SPCanvasItem{ guint32 rgba; - NR::Point p1, p2, p3, p4; - NR::Matrix affine; + Geom::Point p1, p2, p3, p4; + Geom::Matrix affine; }; struct SPCtrlQuadrClass : public SPCanvasItemClass{}; @@ -33,7 +33,7 @@ static void sp_ctrlquadr_class_init (SPCtrlQuadrClass *klass); static void sp_ctrlquadr_init (SPCtrlQuadr *ctrlquadr); static void sp_ctrlquadr_destroy (GtkObject *object); -static void sp_ctrlquadr_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags); +static void sp_ctrlquadr_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags); static void sp_ctrlquadr_render (SPCanvasItem *item, SPCanvasBuf *buf); static SPCanvasItemClass *parent_class; @@ -76,10 +76,10 @@ static void sp_ctrlquadr_init (SPCtrlQuadr *ctrlquadr) { ctrlquadr->rgba = 0x000000ff; - ctrlquadr->p1 = NR::Point(0, 0); - ctrlquadr->p2 = NR::Point(0, 0); - ctrlquadr->p3 = NR::Point(0, 0); - ctrlquadr->p4 = NR::Point(0, 0); + ctrlquadr->p1 = Geom::Point(0, 0); + ctrlquadr->p2 = Geom::Point(0, 0); + ctrlquadr->p3 = Geom::Point(0, 0); + ctrlquadr->p4 = Geom::Point(0, 0); } static void @@ -97,7 +97,7 @@ sp_ctrlquadr_render (SPCanvasItem *item, SPCanvasBuf *buf) { SPCtrlQuadr *cq = SP_CTRLQUADR (item); - NR::Rect area (NR::Point(buf->rect.x0, buf->rect.y0), NR::Point(buf->rect.x1, buf->rect.y1)); + //NR::Rect area (NR::Point(buf->rect.x0, buf->rect.y0), NR::Point(buf->rect.x1, buf->rect.y1)); if (!buf->ct) return; @@ -105,18 +105,18 @@ sp_ctrlquadr_render (SPCanvasItem *item, SPCanvasBuf *buf) // RGB / BGR cairo_new_path(buf->ct); - NR::Point min = NR::Point(buf->rect.x0, buf->rect.y0); + Geom::Point min = Geom::Point(buf->rect.x0, buf->rect.y0); - NR::Point p1 = (cq->p1 * cq->affine) - min; - NR::Point p2 = (cq->p2 * cq->affine) - min; - NR::Point p3 = (cq->p3 * cq->affine) - min; - NR::Point p4 = (cq->p4 * cq->affine) - min; + Geom::Point p1 = (cq->p1 * cq->affine) - min; + Geom::Point p2 = (cq->p2 * cq->affine) - min; + Geom::Point p3 = (cq->p3 * cq->affine) - min; + Geom::Point p4 = (cq->p4 * cq->affine) - min; - cairo_move_to(buf->ct, p1[NR::X], p1[NR::Y]); - cairo_line_to(buf->ct, p2[NR::X], p2[NR::Y]); - cairo_line_to(buf->ct, p3[NR::X], p3[NR::Y]); - cairo_line_to(buf->ct, p4[NR::X], p4[NR::Y]); - cairo_line_to(buf->ct, p1[NR::X], p1[NR::Y]); + cairo_move_to(buf->ct, p1[Geom::X], p1[Geom::Y]); + cairo_line_to(buf->ct, p2[Geom::X], p2[Geom::Y]); + cairo_line_to(buf->ct, p3[Geom::X], p3[Geom::Y]); + cairo_line_to(buf->ct, p4[Geom::X], p4[Geom::Y]); + cairo_line_to(buf->ct, p1[Geom::X], p1[Geom::Y]); // FIXME: this is supposed to draw inverse but cairo apparently is unable of this trick :( //cairo_set_operator (buf->ct, CAIRO_OPERATOR_XOR); @@ -139,7 +139,7 @@ sp_ctrlquadr_render (SPCanvasItem *item, SPCanvasBuf *buf) static void -sp_ctrlquadr_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags) +sp_ctrlquadr_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags) { SPCtrlQuadr *cq = SP_CTRLQUADR (item); @@ -152,15 +152,15 @@ sp_ctrlquadr_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int cq->affine = affine; - NR::Point p1(cq->p1 * affine); - NR::Point p2(cq->p2 * affine); - NR::Point p3(cq->p3 * affine); - NR::Point p4(cq->p4 * affine); + Geom::Point p1(cq->p1 * affine); + Geom::Point p2(cq->p2 * affine); + Geom::Point p3(cq->p3 * affine); + Geom::Point p4(cq->p4 * affine); - item->x1 = (int)(MIN4(p1[NR::X], p2[NR::X], p3[NR::X], p4[NR::X])); - item->y1 = (int)(MIN4(p1[NR::Y], p2[NR::Y], p3[NR::Y], p4[NR::Y])); - item->x2 = (int)(MAX4(p1[NR::X], p2[NR::X], p3[NR::X], p4[NR::X])); - item->y2 = (int)(MAX4(p1[NR::Y], p2[NR::Y], p3[NR::Y], p4[NR::Y])); + item->x1 = (int)(MIN4(p1[Geom::X], p2[Geom::X], p3[Geom::X], p4[Geom::X])); + item->y1 = (int)(MIN4(p1[Geom::Y], p2[Geom::Y], p3[Geom::Y], p4[Geom::Y])); + item->x2 = (int)(MAX4(p1[Geom::X], p2[Geom::X], p3[Geom::X], p4[Geom::X])); + item->y2 = (int)(MAX4(p1[Geom::Y], p2[Geom::Y], p3[Geom::Y], p4[Geom::Y])); sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2); } @@ -180,7 +180,7 @@ sp_ctrlquadr_set_rgba32 (SPCtrlQuadr *cl, guint32 rgba) } void -sp_ctrlquadr_set_coords (SPCtrlQuadr *cl, NR::Point p1, NR::Point p2, NR::Point p3, NR::Point p4) +sp_ctrlquadr_set_coords (SPCtrlQuadr *cl, Geom::Point p1, Geom::Point p2, Geom::Point p3, Geom::Point p4) { g_return_if_fail (cl != NULL); g_return_if_fail (SP_IS_CTRLQUADR (cl)); diff --git a/src/display/sp-ctrlquadr.h b/src/display/sp-ctrlquadr.h index c32d2c376..996c02295 100644 --- a/src/display/sp-ctrlquadr.h +++ b/src/display/sp-ctrlquadr.h @@ -26,7 +26,7 @@ struct SPCtrlQuadrClass; GType sp_ctrlquadr_get_type (void); void sp_ctrlquadr_set_rgba32 (SPCtrlQuadr *cl, guint32 rgba); -void sp_ctrlquadr_set_coords (SPCtrlQuadr *cl, const NR::Point p1, const NR::Point p2, const NR::Point p3, const NR::Point p4); +void sp_ctrlquadr_set_coords (SPCtrlQuadr *cl, const Geom::Point p1, const Geom::Point p2, const Geom::Point p3, const Geom::Point p4); #endif diff --git a/src/document.cpp b/src/document.cpp index 716260b28..57ac0f1f1 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -546,13 +546,12 @@ gdouble sp_document_height(SPDocument *document) * this function fits the canvas to that rect by resizing the canvas * and translating the document root into position. */ -void SPDocument::fitToRect(NR::Rect const &rect) +void SPDocument::fitToRect(Geom::Rect const &rect) { g_return_if_fail(!rect.isEmpty()); - using NR::X; using NR::Y; - double const w = rect.extent(X); - double const h = rect.extent(Y); + double const w = rect.width(); + double const h = rect.height(); double const old_height = sp_document_height(this); SPUnit const &px(sp_unit_get_by_id(SP_UNIT_PX)); @@ -564,7 +563,7 @@ void SPDocument::fitToRect(NR::Rect const &rect) SP_GROUP(root)->translateChildItems(tr); SPNamedView *nv = sp_document_namedview(this, 0); if(nv) { - NR::translate tr2(-rect.min()); + Geom::Translate tr2(-rect.min()); nv->translateGuides(tr2); // update the viewport so the drawing appears to stay where it was @@ -877,18 +876,18 @@ sp_document_idle_handler(gpointer data) } } -static bool is_within(NR::Rect const &area, NR::Rect const &box) +static bool is_within(Geom::Rect const &area, Geom::Rect const &box) { return area.contains(box); } -static bool overlaps(NR::Rect const &area, NR::Rect const &box) +static bool overlaps(Geom::Rect const &area, Geom::Rect const &box) { return area.intersects(box); } -static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey, NR::Rect const &area, - bool (*test)(NR::Rect const &, NR::Rect const &), bool take_insensitive = false) +static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey, Geom::Rect const &area, + bool (*test)(Geom::Rect const &, Geom::Rect const &), bool take_insensitive = false) { g_return_val_if_fail(SP_IS_GROUP(group), s); @@ -900,7 +899,7 @@ static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey, s = find_items_in_area(s, SP_GROUP(o), dkey, area, test); } else { SPItem *child = SP_ITEM(o); - boost::optional box = sp_item_bbox_desktop(child); + boost::optional box = to_2geom(sp_item_bbox_desktop(child)); if ( box && test(area, *box) && (take_insensitive || child->isVisibleAndUnlocked(dkey))) { s = g_slist_append(s, child); } @@ -931,7 +930,7 @@ Returns the bottommost item from the list which is at the point, or NULL if none */ SPItem* sp_document_item_from_list_at_point_bottom(unsigned int dkey, SPGroup *group, GSList const *list, - NR::Point const p, bool take_insensitive) + Geom::Point const p, bool take_insensitive) { g_return_val_if_fail(group, NULL); @@ -968,7 +967,7 @@ upwards in z-order and returns what it has found so far (i.e. the found item is guaranteed to be lower than upto). */ SPItem* -find_item_at_point(unsigned int dkey, SPGroup *group, NR::Point const p, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL) +find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL) { SPItem *seen = NULL, *newseen = NULL; @@ -1010,7 +1009,7 @@ Returns the topmost non-layer group from the descendants of group which is at po p, or NULL if none. Recurses into layers but not into groups. */ SPItem* -find_group_at_point(unsigned int dkey, SPGroup *group, NR::Point const p) +find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p) { SPItem *seen = NULL; @@ -1044,7 +1043,7 @@ find_group_at_point(unsigned int dkey, SPGroup *group, NR::Point const p) * */ -GSList *sp_document_items_in_box(SPDocument *document, unsigned int dkey, NR::Rect const &box) +GSList *sp_document_items_in_box(SPDocument *document, unsigned int dkey, Geom::Rect const &box) { g_return_val_if_fail(document != NULL, NULL); g_return_val_if_fail(document->priv != NULL, NULL); @@ -1059,7 +1058,7 @@ GSList *sp_document_items_in_box(SPDocument *document, unsigned int dkey, NR::Re * */ -GSList *sp_document_partial_items_in_box(SPDocument *document, unsigned int dkey, NR::Rect const &box) +GSList *sp_document_partial_items_in_box(SPDocument *document, unsigned int dkey, Geom::Rect const &box) { g_return_val_if_fail(document != NULL, NULL); g_return_val_if_fail(document->priv != NULL, NULL); @@ -1068,7 +1067,7 @@ GSList *sp_document_partial_items_in_box(SPDocument *document, unsigned int dkey } GSList * -sp_document_items_at_points(SPDocument *document, unsigned const key, std::vector points) +sp_document_items_at_points(SPDocument *document, unsigned const key, std::vector points) { GSList *items = NULL; @@ -1080,7 +1079,7 @@ sp_document_items_at_points(SPDocument *document, unsigned const key, std::vecto for(unsigned int i = 0; i < points.size(); i++) { SPItem *item = sp_document_item_at_point(document, key, points[i], - false, NULL); + false, NULL); if (item && !g_slist_find(items, item)) items = g_slist_prepend (items, item); } @@ -1092,7 +1091,7 @@ sp_document_items_at_points(SPDocument *document, unsigned const key, std::vecto } SPItem * -sp_document_item_at_point(SPDocument *document, unsigned const key, NR::Point const p, +sp_document_item_at_point(SPDocument *document, unsigned const key, Geom::Point const p, gboolean const into_groups, SPItem *upto) { g_return_val_if_fail(document != NULL, NULL); @@ -1102,7 +1101,7 @@ sp_document_item_at_point(SPDocument *document, unsigned const key, NR::Point co } SPItem* -sp_document_group_at_point(SPDocument *document, unsigned int key, NR::Point const p) +sp_document_group_at_point(SPDocument *document, unsigned int key, Geom::Point const p) { g_return_val_if_fail(document != NULL, NULL); g_return_val_if_fail(document->priv != NULL, NULL); diff --git a/src/document.h b/src/document.h index a5cc3b855..fff3289dd 100644 --- a/src/document.h +++ b/src/document.h @@ -21,7 +21,7 @@ #include #include "libcroco/cr-cascade.h" -#include "libnr/nr-forward.h" +#include <2geom/rect.h> #include "gc-managed.h" #include "gc-finalized.h" @@ -41,6 +41,10 @@ struct SPItem; struct SPObject; struct SPGroup; +namespace Geom { + class Point; +} + namespace Inkscape { struct Application; class Selection; @@ -160,7 +164,7 @@ public: sigc::connection _selection_changed_connection; sigc::connection _desktop_activated_connection; - void fitToRect(NR::Rect const &rect); + void fitToRect(Geom::Rect const &rect); }; SPDocument *sp_document_new (const gchar *uri, unsigned int keepalive, bool make_new = false); @@ -254,12 +258,12 @@ sigc::connection sp_document_resources_changed_connect(SPDocument *document, con * Misc */ -GSList * sp_document_items_in_box(SPDocument *document, unsigned int dkey, NR::Rect const &box); -GSList * sp_document_partial_items_in_box(SPDocument *document, unsigned int dkey, NR::Rect const &box); -SPItem* sp_document_item_from_list_at_point_bottom (unsigned int dkey, SPGroup *group, const GSList *list, NR::Point const p, bool take_insensitive = false); -SPItem * sp_document_item_at_point (SPDocument *document, unsigned int key, NR::Point const p, gboolean into_groups, SPItem *upto = NULL); -GSList *sp_document_items_at_points(SPDocument *document, unsigned const key, std::vector points); -SPItem *sp_document_group_at_point (SPDocument *document, unsigned int key, NR::Point const p); +GSList * sp_document_items_in_box(SPDocument *document, unsigned int dkey, Geom::Rect const &box); +GSList * sp_document_partial_items_in_box(SPDocument *document, unsigned int dkey, Geom::Rect const &box); +SPItem* sp_document_item_from_list_at_point_bottom (unsigned int dkey, SPGroup *group, const GSList *list, Geom::Point const p, bool take_insensitive = false); +SPItem * sp_document_item_at_point (SPDocument *document, unsigned int key, Geom::Point const p, gboolean into_groups, SPItem *upto = NULL); +GSList *sp_document_items_at_points(SPDocument *document, unsigned const key, std::vector points); +SPItem *sp_document_group_at_point (SPDocument *document, unsigned int key, Geom::Point const p); void sp_document_set_uri (SPDocument *document, const gchar *uri); void sp_document_resized_signal_emit (SPDocument *doc, gdouble width, gdouble height); diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp index 5c9e45521..0e30acf1b 100644 --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@ -41,7 +41,7 @@ #include "dropper-context.h" #include "message-context.h" -#include "libnr/nr-scale-translate-ops.h" +//#include "libnr/nr-scale-translate-ops.h" static void sp_dropper_context_class_init(SPDropperContextClass *klass); static void sp_dropper_context_init(SPDropperContext *dc); @@ -164,7 +164,7 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv switch (event->type) { case GDK_BUTTON_PRESS: if (event->button.button == 1 && !event_context->space_panning) { - dc->centre = NR::Point(event->button.x, event->button.y); + dc->centre = Geom::Point(event->button.x, event->button.y); dc->dragging = TRUE; ret = TRUE; } @@ -184,24 +184,24 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv // calculate average // radius - rw = std::min(NR::L2(NR::Point(event->button.x, event->button.y) - dc->centre), 400.0); + rw = std::min(Geom::L2(Geom::Point(event->button.x, event->button.y) - dc->centre), 400.0); if (rw == 0) { // happens sometimes, little idea why... break; } - NR::Point const cd = desktop->w2d(dc->centre); - NR::Matrix const w2dt = desktop->w2d(); - const double scale = rw * NR::expansion(w2dt); - NR::Matrix const sm( NR::scale(scale, scale) * NR::translate(cd) ); + Geom::Point const cd = desktop->w2d(dc->centre); + Geom::Matrix const w2dt = desktop->w2d(); + const double scale = rw * w2dt.descrim(); + Geom::Matrix const sm( Geom::Scale(scale, scale) * Geom::Translate(cd) ); sp_canvas_item_affine_absolute(dc->area, sm); sp_canvas_item_show(dc->area); /* Get buffer */ - const int x0 = (int) floor(dc->centre[NR::X] - rw); - const int y0 = (int) floor(dc->centre[NR::Y] - rw); - const int x1 = (int) ceil(dc->centre[NR::X] + rw); - const int y1 = (int) ceil(dc->centre[NR::Y] + rw); + const int x0 = (int) floor(dc->centre[Geom::X] - rw); + const int y0 = (int) floor(dc->centre[Geom::Y] - rw); + const int x1 = (int) ceil(dc->centre[Geom::X] + rw); + const int y1 = (int) ceil(dc->centre[Geom::Y] + rw); if ((x1 > x0) && (y1 > y0)) { NRPixBlock pb; @@ -211,8 +211,8 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv for (int y = y0; y < y1; y++) { const unsigned char *s = NR_PIXBLOCK_PX(&pb) + (y - y0) * pb.rs; for (int x = x0; x < x1; x++) { - const double dx = x - dc->centre[NR::X]; - const double dy = y - dc->centre[NR::Y]; + const double dx = x - dc->centre[Geom::X]; + const double dy = y - dc->centre[Geom::Y]; const double w = exp(-((dx * dx) + (dy * dy)) / (rw * rw)); W += w; R += w * s[0]; diff --git a/src/dropper-context.h b/src/dropper-context.h index 80b25ad26..678ab6b47 100644 --- a/src/dropper-context.h +++ b/src/dropper-context.h @@ -12,8 +12,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include - #include "display/display-forward.h" #include "event-context.h" @@ -30,21 +28,21 @@ enum { }; struct SPDropperContext { - SPEventContext event_context; + SPEventContext event_context; - unsigned int dragging : 1; + unsigned int dragging : 1; - SPCanvasItem *area; - NR::Point centre; + SPCanvasItem *area; + Geom::Point centre; - double R; - double G; - double B; - double alpha; + double R; + double G; + double B; + double alpha; }; struct SPDropperContextClass { - SPEventContextClass parent_class; + SPEventContextClass parent_class; }; GType sp_dropper_context_get_type (void); @@ -52,3 +50,14 @@ GType sp_dropper_context_get_type (void); guint32 sp_dropper_context_get_color(SPEventContext *ec); #endif + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index 0cffd4bc5..b8f069073 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -273,18 +273,18 @@ flerp(double f0, double f1, double p) static Geom::Point sp_dyna_draw_get_npoint(SPDynaDrawContext const *dc, Geom::Point v) { - NR::Rect drect = SP_EVENT_CONTEXT(dc)->desktop->get_display_area(); - double const max = MAX ( drect.dimensions()[NR::X], drect.dimensions()[NR::Y] ); - return Geom::Point(( v[NR::X] - drect.min()[NR::X] ) / max, ( v[NR::Y] - drect.min()[NR::Y] ) / max); + Geom::Rect drect = SP_EVENT_CONTEXT(dc)->desktop->get_display_area(); + double const max = MAX ( drect.dimensions()[Geom::X], drect.dimensions()[Geom::Y] ); + return Geom::Point(( v[Geom::X] - drect.min()[Geom::X] ) / max, ( v[Geom::Y] - drect.min()[Geom::Y] ) / max); } /* Get view point */ static Geom::Point sp_dyna_draw_get_vpoint(SPDynaDrawContext const *dc, Geom::Point n) { - NR::Rect drect = SP_EVENT_CONTEXT(dc)->desktop->get_display_area(); - double const max = MAX ( drect.dimensions()[NR::X], drect.dimensions()[NR::Y] ); - return Geom::Point(n[NR::X] * max + drect.min()[NR::X], n[NR::Y] * max + drect.min()[NR::Y]); + Geom::Rect drect = SP_EVENT_CONTEXT(dc)->desktop->get_display_area(); + double const max = MAX ( drect.dimensions()[Geom::X], drect.dimensions()[Geom::Y] ); + return Geom::Point(n[Geom::X] * max + drect.min()[Geom::X], n[Geom::Y] * max + drect.min()[Geom::Y]); } static void @@ -1095,7 +1095,7 @@ fit_and_split(SPDynaDrawContext *dc, gboolean release) { SPDesktop *desktop = SP_EVENT_CONTEXT(dc)->desktop; - double const tolerance_sq = square( NR::expansion(desktop->w2d()) * TOLERANCE_CALLIGRAPHIC ); + double const tolerance_sq = square( desktop->w2d().descrim() * TOLERANCE_CALLIGRAPHIC ); #ifdef DYNA_DRAW_VERBOSE g_print("[F&S:R=%c]", release?'T':'F'); diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp index 86d5e66dc..382a50edc 100644 --- a/src/eraser-context.cpp +++ b/src/eraser-context.cpp @@ -231,18 +231,18 @@ flerp(double f0, double f1, double p) static Geom::Point sp_eraser_get_npoint(SPEraserContext const *dc, Geom::Point v) { - NR::Rect drect = SP_EVENT_CONTEXT(dc)->desktop->get_display_area(); - double const max = MAX ( drect.dimensions()[NR::X], drect.dimensions()[NR::Y] ); - return Geom::Point(( v[NR::X] - drect.min()[NR::X] ) / max, ( v[NR::Y] - drect.min()[NR::Y] ) / max); + Geom::Rect drect = SP_EVENT_CONTEXT(dc)->desktop->get_display_area(); + double const max = MAX ( drect.dimensions()[Geom::X], drect.dimensions()[Geom::Y] ); + return Geom::Point(( v[Geom::X] - drect.min()[Geom::X] ) / max, ( v[Geom::Y] - drect.min()[Geom::Y] ) / max); } /* Get view point */ static Geom::Point sp_eraser_get_vpoint(SPEraserContext const *dc, Geom::Point n) { - NR::Rect drect = SP_EVENT_CONTEXT(dc)->desktop->get_display_area(); - double const max = MAX ( drect.dimensions()[NR::X], drect.dimensions()[NR::Y] ); - return Geom::Point(n[NR::X] * max + drect.min()[NR::X], n[NR::Y] * max + drect.min()[NR::Y]); + Geom::Rect drect = SP_EVENT_CONTEXT(dc)->desktop->get_display_area(); + double const max = MAX ( drect.dimensions()[Geom::X], drect.dimensions()[Geom::Y] ); + return Geom::Point(n[Geom::X] * max + drect.min()[Geom::X], n[Geom::Y] * max + drect.min()[Geom::Y]); } static void @@ -555,8 +555,6 @@ sp_eraser_context_root_handler(SPEventContext *event_context, if (dc->dragging && event->button.button == 1 && !event_context->space_panning) { dc->dragging = FALSE; - boost::optional const b = Inkscape::Rubberband::get(desktop)->getRectangle(); - sp_eraser_apply(dc, motion_dt); /* Remove all temporary line segments */ @@ -741,8 +739,8 @@ set_to_accumulated(SPEraserContext *dc) Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc()); SPItem* acid = SP_ITEM(desktop->doc()->getObjectByRepr(dc->repr)); - boost::optional eraserBbox = acid->getBounds(NR::identity()); - NR::Rect bounds = (*eraserBbox) * desktop->doc2dt(); + boost::optional eraserBbox = to_2geom(acid->getBounds(Geom::identity())); + Geom::Rect bounds = (*eraserBbox) * desktop->doc2dt(); std::vector remainingItems; GSList* toWorkOn = 0; if (selection->isEmpty()) { @@ -763,7 +761,7 @@ set_to_accumulated(SPEraserContext *dc) for (GSList *i = toWorkOn ; i ; i = i->next ) { SPItem *item = SP_ITEM(i->data); if ( eraserMode ) { - boost::optional bbox = item->getBounds(NR::identity()); + boost::optional bbox = to_2geom(item->getBounds(Geom::identity())); if (bbox && bbox->intersects(*eraserBbox)) { Inkscape::XML::Node* dup = dc->repr->duplicate(xml_doc); dc->repr->parent()->appendChild(dup); @@ -911,7 +909,7 @@ fit_and_split(SPEraserContext *dc, gboolean release) { SPDesktop *desktop = SP_EVENT_CONTEXT(dc)->desktop; - double const tolerance_sq = square( NR::expansion(desktop->w2d()) * TOLERANCE_ERASER ); + double const tolerance_sq = square( desktop->w2d().descrim() * TOLERANCE_ERASER ); #ifdef ERASER_VERBOSE g_print("[F&S:R=%c]", release?'T':'F'); diff --git a/src/event-context.cpp b/src/event-context.cpp index 16fbe1f60..9df171146 100644 --- a/src/event-context.cpp +++ b/src/event-context.cpp @@ -499,7 +499,7 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context, ret = TRUE; } else if (zoom_rb == event->button.button) { zoom_rb = 0; - boost::optional const b = Inkscape::Rubberband::get(desktop)->getRectangle(); + boost::optional const b = Inkscape::Rubberband::get(desktop)->getRectangle(); Inkscape::Rubberband::get(desktop)->stop(); if (b && !within_tolerance) { desktop->set_display_area(*b, 10); diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 22eee6468..d2e6290b2 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -380,8 +380,8 @@ struct bitmap_coords_info { PaintBucketChannels method; unsigned char *dtc; unsigned char *merged_orig_pixel; - NR::Rect bbox; - NR::Rect screen; + Geom::Rect bbox; + Geom::Rect screen; unsigned int max_queue_size; unsigned int current_step; }; @@ -417,7 +417,7 @@ inline static bool check_if_pixel_is_paintable(guchar *px, unsigned char *trace_ * \param transform The transform to apply to the final SVG path. * \param union_with_selection If true, merge the final SVG path with the current selection. */ -static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *desktop, NR::Matrix transform, unsigned int min_x, unsigned int max_x, unsigned int min_y, unsigned int max_y, bool union_with_selection) { +static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *desktop, Geom::Matrix transform, unsigned int min_x, unsigned int max_x, unsigned int min_y, unsigned int max_y, bool union_with_selection) { SPDocument *document = sp_desktop_document(desktop); unsigned char *trace_t; @@ -510,10 +510,10 @@ 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()))); - if (!local.test_identity()) { + Geom::Matrix local (sp_item_i2doc_affine(SP_GROUP(desktop->currentLayer()))); + if (!local.isIdentity()) { gchar const *t_str = pathRepr->attribute("transform"); - NR::Matrix item_t (NR::identity()); + Geom::Matrix item_t (Geom::identity()); if (t_str) sp_svg_transform_read(t_str, &item_t); item_t *= local.inverse(); @@ -625,10 +625,10 @@ inline static unsigned int paint_pixel(guchar *px, guchar *trace_px, unsigned ch * \param x The X coordinate. * \param y The Y coordinate. */ -static void push_point_onto_queue(std::deque *fill_queue, unsigned int max_queue_size, unsigned char *trace_t, unsigned int x, unsigned int y) { +static void push_point_onto_queue(std::deque *fill_queue, unsigned int max_queue_size, unsigned char *trace_t, unsigned int x, unsigned int y) { if (!is_pixel_queued(trace_t)) { if ((fill_queue->size() < max_queue_size)) { - fill_queue->push_back(NR::Point(x, y)); + fill_queue->push_back(Geom::Point(x, y)); mark_pixel_queued(trace_t); } } @@ -642,10 +642,10 @@ static void push_point_onto_queue(std::deque *fill_queue, unsigned in * \param x The X coordinate. * \param y The Y coordinate. */ -static void shift_point_onto_queue(std::deque *fill_queue, unsigned int max_queue_size, unsigned char *trace_t, unsigned int x, unsigned int y) { +static void shift_point_onto_queue(std::deque *fill_queue, unsigned int max_queue_size, unsigned char *trace_t, unsigned int x, unsigned int y) { if (!is_pixel_queued(trace_t)) { if ((fill_queue->size() < max_queue_size)) { - fill_queue->push_front(NR::Point(x, y)); + fill_queue->push_front(Geom::Point(x, y)); mark_pixel_queued(trace_t); } } @@ -659,7 +659,7 @@ static void shift_point_onto_queue(std::deque *fill_queue, unsigned i * \param orig_color The original selected pixel to use as the fill target color. * \param bci The bitmap_coords_info structure. */ -static ScanlineCheckResult perform_bitmap_scanline_check(std::deque *fill_queue, guchar *px, guchar *trace_px, unsigned char *orig_color, bitmap_coords_info bci, unsigned int *min_x, unsigned int *max_x) { +static ScanlineCheckResult perform_bitmap_scanline_check(std::deque *fill_queue, guchar *px, guchar *trace_px, unsigned char *orig_color, bitmap_coords_info bci, unsigned int *min_x, unsigned int *max_x) { bool aborted = false; bool reached_screen_boundary = false; bool ok; @@ -679,7 +679,7 @@ static ScanlineCheckResult perform_bitmap_scanline_check(std::deque * bool can_paint_top = (top_ty > 0); bool can_paint_bottom = (bottom_ty < bci.height); - NR::Point t = fill_queue->front(); + Geom::Point t = fill_queue->front(); do { ok = false; @@ -697,7 +697,7 @@ static ScanlineCheckResult perform_bitmap_scanline_check(std::deque * paint_directions = paint_pixel(px, trace_px, orig_color, bci, current_trace_t); if (bci.radius == 0) { mark_pixel_checked(current_trace_t); - if ((t[NR::X] == bci.x) && (t[NR::Y] == bci.y)) { + if ((t[Geom::X] == bci.x) && (t[Geom::Y] == bci.y)) { fill_queue->pop_front(); t = fill_queue->front(); } } @@ -755,7 +755,7 @@ static ScanlineCheckResult perform_bitmap_scanline_check(std::deque * initial_paint = false; } } else { - if (bci.bbox.min()[NR::X] > bci.screen.min()[NR::X]) { + if (bci.bbox.min()[Geom::X] > bci.screen.min()[Geom::X]) { aborted = true; break; } else { reached_screen_boundary = true; @@ -771,15 +771,15 @@ static ScanlineCheckResult perform_bitmap_scanline_check(std::deque * /** * \brief Sort the rendered pixel buffer check queue vertically. */ -static bool sort_fill_queue_vertical(NR::Point a, NR::Point b) { - return a[NR::Y] > b[NR::Y]; +static bool sort_fill_queue_vertical(Geom::Point a, Geom::Point b) { + return a[Geom::Y] > b[Geom::Y]; } /** * \brief Sort the rendered pixel buffer check queue horizontally. */ -static bool sort_fill_queue_horizontal(NR::Point a, NR::Point b) { - return a[NR::X] > b[NR::X]; +static bool sort_fill_queue_horizontal(Geom::Point a, Geom::Point b) { + return a[Geom::X] > b[Geom::X]; } /** @@ -801,7 +801,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even sp_document_ensure_up_to_date (document); SPItem *document_root = SP_ITEM(SP_DOCUMENT_ROOT(document)); - boost::optional bbox = document_root->getBounds(NR::identity()); + boost::optional bbox = to_2geom(document_root->getBounds(Geom::identity())); if (!bbox) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Area is not bounded, cannot fill.")); @@ -814,19 +814,19 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even // fill areas off the screen can be included in the fill. double padding = 1.6; - NR::Rect screen = desktop->get_display_area(); + Geom::Rect screen = desktop->get_display_area(); - unsigned int width = (int)ceil(screen.extent(NR::X) * zoom_scale * padding); - unsigned int height = (int)ceil(screen.extent(NR::Y) * zoom_scale * padding); + unsigned int width = (int)ceil(screen.width() * zoom_scale * padding); + unsigned int height = (int)ceil(screen.height() * zoom_scale * padding); - NR::Point origin(screen.min()[NR::X], - sp_document_height(document) - screen.extent(NR::Y) - screen.min()[NR::Y]); + Geom::Point origin(screen.min()[Geom::X], + sp_document_height(document) - screen.height() - screen.min()[Geom::Y]); - origin[NR::X] = origin[NR::X] + (screen.extent(NR::X) * ((1 - padding) / 2)); - origin[NR::Y] = origin[NR::Y] + (screen.extent(NR::Y) * ((1 - padding) / 2)); + origin[Geom::X] = origin[Geom::X] + (screen.width() * ((1 - padding) / 2)); + origin[Geom::Y] = origin[Geom::Y] + (screen.height() * ((1 - padding) / 2)); - NR::scale scale(zoom_scale, zoom_scale); - NR::Matrix affine = scale * NR::translate(-origin * scale); + Geom::Scale scale(zoom_scale, zoom_scale); + Geom::Matrix affine = scale * Geom::Translate(-origin * scale); /* Create ArenaItems and set transform */ NRArenaItem *root = sp_item_invoke_show(SP_ITEM(sp_document_root(document)), arena, dkey, SP_ITEM_SHOW_DISPLAY); @@ -879,10 +879,10 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even guchar *trace_px = g_new(guchar, width * height); memset(trace_px, 0x00, width * height); - std::deque fill_queue; - std::queue color_queue; + std::deque fill_queue; + std::queue color_queue; - std::vector fill_points; + std::vector fill_points; bool aborted = false; int y_limit = height - 1; @@ -919,24 +919,24 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even bci.current_step = 0; if (is_point_fill) { - fill_points.push_back(NR::Point(event->button.x, event->button.y)); + fill_points.push_back(Geom::Point(event->button.x, event->button.y)); } else { Inkscape::Rubberband::Rubberband *r = Inkscape::Rubberband::get(desktop); fill_points = r->getPoints(); } for (unsigned int i = 0; i < fill_points.size(); i++) { - NR::Point pw = NR::Point(fill_points[i][NR::X] / zoom_scale, sp_document_height(document) + (fill_points[i][NR::Y] / zoom_scale)) * affine; + Geom::Point pw = Geom::Point(fill_points[i][Geom::X] / zoom_scale, sp_document_height(document) + (fill_points[i][Geom::Y] / zoom_scale)) * affine; - pw[NR::X] = (int)MIN(width - 1, MAX(0, pw[NR::X])); - pw[NR::Y] = (int)MIN(height - 1, MAX(0, pw[NR::Y])); + pw[Geom::X] = (int)MIN(width - 1, MAX(0, pw[Geom::X])); + pw[Geom::Y] = (int)MIN(height - 1, MAX(0, pw[Geom::Y])); if (is_touch_fill) { if (i == 0) { color_queue.push(pw); } else { - unsigned char *trace_t = get_trace_pixel(trace_px, (int)pw[NR::X], (int)pw[NR::Y], width); - push_point_onto_queue(&fill_queue, bci.max_queue_size, trace_t, (int)pw[NR::X], (int)pw[NR::Y]); + unsigned char *trace_t = get_trace_pixel(trace_px, (int)pw[Geom::X], (int)pw[Geom::Y], width); + push_point_onto_queue(&fill_queue, bci.max_queue_size, trace_t, (int)pw[Geom::X], (int)pw[Geom::Y]); } } else { color_queue.push(pw); @@ -955,11 +955,11 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even unsigned int max_x = 0; while (!color_queue.empty() && !aborted) { - NR::Point color_point = color_queue.front(); + Geom::Point color_point = color_queue.front(); color_queue.pop(); - int cx = (int)color_point[NR::X]; - int cy = (int)color_point[NR::Y]; + int cx = (int)color_point[Geom::X]; + int cy = (int)color_point[Geom::Y]; unsigned char *orig_px = get_pixel(px, cx, cy, width); unsigned char orig_color[4]; @@ -992,7 +992,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even unsigned long old_fill_queue_size = fill_queue.size(); while (!fill_queue.empty() && !aborted) { - NR::Point cp = fill_queue.front(); + Geom::Point cp = fill_queue.front(); if (bci.radius == 0) { unsigned long new_fill_queue_size = fill_queue.size(); @@ -1009,14 +1009,14 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even if (new_fill_queue_size > old_fill_queue_size) { std::sort(fill_queue.begin(), fill_queue.end(), sort_fill_queue_vertical); - std::deque::iterator start_sort = fill_queue.begin(); - std::deque::iterator end_sort = fill_queue.begin(); - unsigned int sort_y = (unsigned int)cp[NR::Y]; + std::deque::iterator start_sort = fill_queue.begin(); + std::deque::iterator end_sort = fill_queue.begin(); + unsigned int sort_y = (unsigned int)cp[Geom::Y]; unsigned int current_y = sort_y; - for (std::deque::iterator i = fill_queue.begin(); i != fill_queue.end(); i++) { - NR::Point current = *i; - current_y = (unsigned int)current[NR::Y]; + for (std::deque::iterator i = fill_queue.begin(); i != fill_queue.end(); i++) { + Geom::Point current = *i; + current_y = (unsigned int)current[Geom::Y]; if (current_y != sort_y) { if (start_sort != end_sort) { std::sort(start_sort, end_sort, sort_fill_queue_horizontal); @@ -1039,8 +1039,8 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even fill_queue.pop_front(); - int x = (int)cp[NR::X]; - int y = (int)cp[NR::Y]; + int x = (int)cp[Geom::X]; + int y = (int)cp[Geom::Y]; min_y = MIN((unsigned int)y, min_y); max_y = MAX((unsigned int)y, max_y); @@ -1050,7 +1050,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even mark_pixel_checked(trace_t); if (y == 0) { - if (bbox->min()[NR::Y] > screen.min()[NR::Y]) { + if (bbox->min()[Geom::Y] > screen.min()[Geom::Y]) { aborted = true; break; } else { reached_screen_boundary = true; @@ -1058,7 +1058,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even } if (y == y_limit) { - if (bbox->max()[NR::Y] < screen.max()[NR::Y]) { + if (bbox->max()[Geom::Y] < screen.max()[Geom::Y]) { aborted = true; break; } else { reached_screen_boundary = true; @@ -1131,10 +1131,10 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even if (min_x > trace_padding) { min_x -= trace_padding; } if (max_x < (width - 1 - trace_padding)) { max_x += trace_padding; } - NR::Point min_start = NR::Point(min_x, min_y); + Geom::Point min_start = Geom::Point(min_x, min_y); - affine = scale * NR::translate(-origin * scale - min_start); - NR::Matrix inverted_affine = NR::Matrix(affine).inverse(); + affine = scale * Geom::Translate(-origin * scale - min_start); + Geom::Matrix inverted_affine = Geom::Matrix(affine).inverse(); do_trace(bci, trace_px, desktop, inverted_affine, min_x, max_x, min_y, max_y, union_with_selection); @@ -1152,8 +1152,8 @@ static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem switch (event->type) { case GDK_BUTTON_PRESS: if ((event->button.state & GDK_CONTROL_MASK) && event->button.button == 1 && !event_context->space_panning) { - NR::Point const button_w(event->button.x, - event->button.y); + Geom::Point const button_w(event->button.x, + event->button.y); SPItem *item = sp_event_context_find_item (desktop, button_w, TRUE, TRUE); @@ -1186,18 +1186,18 @@ static gint sp_flood_context_root_handler(SPEventContext *event_context, GdkEven case GDK_BUTTON_PRESS: if (event->button.button == 1 && !event_context->space_panning) { if (!(event->button.state & GDK_CONTROL_MASK)) { - NR::Point const button_w(event->button.x, - event->button.y); + Geom::Point const button_w(event->button.x, + event->button.y); if (Inkscape::have_viable_layer(desktop, event_context->defaultMessageContext())) { // save drag origin - event_context->xp = (gint) button_w[NR::X]; - event_context->yp = (gint) button_w[NR::Y]; + event_context->xp = (gint) button_w[Geom::X]; + event_context->yp = (gint) button_w[Geom::Y]; event_context->within_tolerance = true; dragging = true; - NR::Point const p(desktop->w2d(button_w)); + Geom::Point const p(desktop->w2d(button_w)); Inkscape::Rubberband::get(desktop)->setMode(RUBBERBAND_MODE_TOUCHPATH); Inkscape::Rubberband::get(desktop)->start(desktop, p); } @@ -1215,8 +1215,8 @@ static gint sp_flood_context_root_handler(SPEventContext *event_context, GdkEven event_context->within_tolerance = false; - NR::Point const motion_pt(event->motion.x, event->motion.y); - NR::Point const p(desktop->w2d(motion_pt)); + Geom::Point const motion_pt(event->motion.x, event->motion.y); + Geom::Point const p(desktop->w2d(motion_pt)); if (Inkscape::Rubberband::get(desktop)->is_started()) { Inkscape::Rubberband::get(desktop)->move(p); event_context->defaultMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Draw over areas to add to fill, hold Alt for touch fill")); diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index 400661ce2..7181fab4e 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -249,8 +249,8 @@ sp_gradient_context_is_over_line (SPGradientContext *rc, SPItem *item, NR::Point SPCtrlLine* line = SP_CTRLLINE(item); - NR::Point nearest = snap_vector_midpoint (rc->mousepoint_doc, line->s, line->e, 0); - double dist_screen = NR::L2 (rc->mousepoint_doc - nearest) * desktop->current_zoom(); + Geom::Point nearest = snap_vector_midpoint (rc->mousepoint_doc, line->s, line->e, 0); + double dist_screen = Geom::L2 (rc->mousepoint_doc - nearest) * desktop->current_zoom(); double tolerance = (double) SP_EVENT_CONTEXT(rc)->tolerance; @@ -641,7 +641,7 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) if (r->is_started() && !event_context->within_tolerance) { // this was a rubberband drag if (r->getMode() == RUBBERBAND_MODE_RECT) { - boost::optional const b = r->getRectangle(); + boost::optional const b = r->getRectangle(); drag->selectRect(*b); } } diff --git a/src/gradient-context.h b/src/gradient-context.h index ac4682636..f4d8c572a 100644 --- a/src/gradient-context.h +++ b/src/gradient-context.h @@ -16,7 +16,6 @@ #include #include "event-context.h" -#include "libnr/nr-point.h" #define SP_TYPE_GRADIENT_CONTEXT (sp_gradient_context_get_type()) #define SP_GRADIENT_CONTEXT(obj) (GTK_CHECK_CAST((obj), SP_TYPE_GRADIENT_CONTEXT, SPGradientContext)) @@ -29,13 +28,13 @@ class SPGradientContextClass; struct SPGradientContext : public SPEventContext { - NR::Point origin; + Geom::Point origin; bool cursor_addnode; bool node_added; - NR::Point mousepoint_doc; // stores mousepoint when over_line in doc coords + Geom::Point mousepoint_doc; // stores mousepoint when over_line in doc coords Inkscape::MessageContext *_message_context; diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 5bf2b2575..1caaf1d11 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -1447,7 +1447,7 @@ GrDrag::selectByCoords(std::vector coords) \brief Select all stops/draggers that fall within the rect */ void -GrDrag::selectRect(NR::Rect const &r) +GrDrag::selectRect(Geom::Rect const &r) { for (GList *l = this->draggers; l != NULL; l = l->next) { GrDragger *d = ((GrDragger *) l->data); diff --git a/src/gradient-drag.h b/src/gradient-drag.h index ed0887e98..acc2dd48f 100644 --- a/src/gradient-drag.h +++ b/src/gradient-drag.h @@ -121,7 +121,7 @@ public: // FIXME: make more of this private! void deselectAll(); void selectAll(); void selectByCoords(std::vector coords); - void selectRect(NR::Rect const &r); + void selectRect(Geom::Rect const &r); bool dropColor(SPItem *item, gchar *c, NR::Point p); diff --git a/src/interface.cpp b/src/interface.cpp index 9264f4fd6..5abf8d8db 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -201,7 +201,7 @@ sp_create_window(SPViewWidget *vw, gboolean editable) if (x>0 && y>0) { SPDesktop *active_desktop = SP_ACTIVE_DESKTOP; if (active_desktop == desktop || active_desktop==NULL) { - desktop->setWindowPosition(NR::Point(x, y)); + desktop->setWindowPosition(Geom::Point(x, y)); } } } @@ -1062,7 +1062,7 @@ sp_ui_drag_data_received(GtkWidget *widget, int destX = 0; int destY = 0; gtk_widget_translate_coordinates( widget, &(desktop->canvas->widget), x, y, &destX, &destY ); - NR::Point where( sp_canvas_window_to_world( desktop->canvas, NR::Point( destX, destY ) ) ); + Geom::Point where( sp_canvas_window_to_world( desktop->canvas, Geom::Point( destX, destY ) ) ); SPItem *item = desktop->item_at_point( where, true ); if ( item ) @@ -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 + to_2geom(sp_item_i2d_affine(item)).descrim() * 0.5 : 0.0) + prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100); diff --git a/src/libnr/nr-convert2geom.h b/src/libnr/nr-convert2geom.h index 95b9eb6f0..c8a139aa2 100644 --- a/src/libnr/nr-convert2geom.h +++ b/src/libnr/nr-convert2geom.h @@ -45,6 +45,14 @@ inline NR::Rect from_2geom(Geom::Rect const & rect2geom) { NR::Rect rect(rect2geom.min(), rect2geom.max()); return rect; } +inline boost::optional to_2geom(boost::optional const & rect) { + boost::optional rect2geom; + if (!rect) { + return rect2geom; + } + rect2geom = to_2geom(*rect); + return rect2geom; +} inline NR::scale from_2geom(Geom::Scale const & in) { return NR::scale(in[Geom::X], in[Geom::Y]); diff --git a/src/line-geometry.cpp b/src/line-geometry.cpp index 056bfb71a..d01b5db82 100644 --- a/src/line-geometry.cpp +++ b/src/line-geometry.cpp @@ -26,14 +26,14 @@ namespace Box3D { * of the segment. Otherwise interpret it as the direction of the line. * FIXME: Think of a better way to distinguish between the two constructors of lines. */ -Line::Line(NR::Point const &start, NR::Point const &vec, bool is_endpoint) { +Line::Line(Geom::Point const &start, Geom::Point const &vec, bool is_endpoint) { pt = start; if (is_endpoint) v_dir = vec - start; else v_dir = vec; normal = v_dir.ccw(); - d0 = NR::dot(normal, pt); + d0 = Geom::dot(normal, pt); } Line::Line(Line const &line) { @@ -52,38 +52,38 @@ Line &Line::operator=(Line const &line) { return *this; } -boost::optional Line::intersect(Line const &line) { - NR::Coord denom = NR::dot(v_dir, line.normal); - boost::optional no_point; +boost::optional Line::intersect(Line const &line) { + Geom::Coord denom = Geom::dot(v_dir, line.normal); + boost::optional no_point; if (fabs(denom) < 1e-6) return no_point; - NR::Coord lambda = (line.d0 - NR::dot(pt, line.normal)) / denom; + Geom::Coord lambda = (line.d0 - Geom::dot(pt, line.normal)) / denom; return pt + lambda * v_dir; } -void Line::set_direction(NR::Point const &dir) +void Line::set_direction(Geom::Point const &dir) { v_dir = dir; normal = v_dir.ccw(); - d0 = NR::dot(normal, pt); + d0 = Geom::dot(normal, pt); } -NR::Point Line::closest_to(NR::Point const &pt) +Geom::Point Line::closest_to(Geom::Point const &pt) { /* return the intersection of this line with a perpendicular line passing through pt */ - boost::optional result = this->intersect(Line(pt, (this->v_dir).ccw(), false)); - g_return_val_if_fail (result, NR::Point (0.0, 0.0)); + boost::optional result = this->intersect(Line(pt, (this->v_dir).ccw(), false)); + g_return_val_if_fail (result, Geom::Point (0.0, 0.0)); return *result; } -double Line::lambda (NR::Point const pt) +double Line::lambda (Geom::Point const pt) { - double sign = (NR::dot (pt - this->pt, this->v_dir) > 0) ? 1.0 : -1.0; - double lambda = sign * NR::L2 (pt - this->pt); + double sign = (Geom::dot (pt - this->pt, this->v_dir) > 0) ? 1.0 : -1.0; + double lambda = sign * Geom::L2 (pt - this->pt); // FIXME: It may speed things up (but how much?) if we assume that // pt lies on the line and thus skip the following test - NR::Point test = point_from_lambda (lambda); + Geom::Point test = point_from_lambda (lambda); if (!pts_coincide (pt, test)) { g_warning ("Point does not lie on line.\n"); return 0; @@ -92,7 +92,7 @@ double Line::lambda (NR::Point const pt) } /* The coordinates of w with respect to the basis {v1, v2} */ -std::pair coordinates (NR::Point const &v1, NR::Point const &v2, NR::Point const &w) +std::pair coordinates (Geom::Point const &v1, Geom::Point const &v2, Geom::Point const &w) { double det = determinant (v1, v2);; if (fabs (det) < epsilon) { @@ -106,25 +106,25 @@ std::pair coordinates (NR::Point const &v1, NR::Point const &v2, } /* whether w lies inside the sector spanned by v1 and v2 */ -bool lies_in_sector (NR::Point const &v1, NR::Point const &v2, NR::Point const &w) +bool lies_in_sector (Geom::Point const &v1, Geom::Point const &v2, Geom::Point const &w) { std::pair coords = coordinates (v1, v2, w); if (coords.first == HUGE_VAL) { // catch the case that the vectors are not linearly independent // FIXME: Can we assume that it's safe to return true if the vectors point in different directions? - return (NR::dot (v1, v2) < 0); + return (Geom::dot (v1, v2) < 0); } return (coords.first >= 0 and coords.second >= 0); } -bool lies_in_quadrangle (NR::Point const &A, NR::Point const &B, NR::Point const &C, NR::Point const &D, NR::Point const &pt) +bool lies_in_quadrangle (Geom::Point const &A, Geom::Point const &B, Geom::Point const &C, Geom::Point const &D, Geom::Point const &pt) { return (lies_in_sector (D - A, B - A, pt - A) && lies_in_sector (D - C, B - C, pt - C)); } -static double pos_angle (NR::Point v, NR::Point w) +static double pos_angle (Geom::Point v, Geom::Point w) { - return fabs (NR::atan2 (v) - NR::atan2 (w)); + return fabs (Geom::atan2 (v) - Geom::atan2 (w)); } /* @@ -132,16 +132,16 @@ static double pos_angle (NR::Point v, NR::Point w) * starting at pt and going into direction dir. * If none of the sides is hit, it returns a pair containing two identical points. */ -std::pair -side_of_intersection (NR::Point const &A, NR::Point const &B, NR::Point const &C, NR::Point const &D, - NR::Point const &pt, NR::Point const &dir) +std::pair +side_of_intersection (Geom::Point const &A, Geom::Point const &B, Geom::Point const &C, Geom::Point const &D, + Geom::Point const &pt, Geom::Point const &dir) { - NR::Point dir_A (A - pt); - NR::Point dir_B (B - pt); - NR::Point dir_C (C - pt); - NR::Point dir_D (D - pt); + Geom::Point dir_A (A - pt); + Geom::Point dir_B (B - pt); + Geom::Point dir_C (C - pt); + Geom::Point dir_D (D - pt); - std::pair result; + std::pair result; double angle = -1; double tmp_angle; @@ -178,24 +178,24 @@ side_of_intersection (NR::Point const &A, NR::Point const &B, NR::Point const &C } } -boost::optional Line::intersection_with_viewbox (SPDesktop *desktop) +boost::optional Line::intersection_with_viewbox (SPDesktop *desktop) { - NR::Rect vb = desktop->get_display_area(); + Geom::Rect vb = desktop->get_display_area(); /* remaining viewbox corners */ - NR::Point ul (vb.min()[NR::X], vb.max()[NR::Y]); - NR::Point lr (vb.max()[NR::X], vb.min()[NR::Y]); + Geom::Point ul (vb.min()[Geom::X], vb.max()[Geom::Y]); + Geom::Point lr (vb.max()[Geom::X], vb.min()[Geom::Y]); - std::pair e = side_of_intersection (vb.min(), lr, vb.max(), ul, this->pt, this->v_dir); + std::pair e = side_of_intersection (vb.min(), lr, vb.max(), ul, this->pt, this->v_dir); if (e.first == e.second) { // perspective line lies outside the canvas - return boost::optional(); + return boost::optional(); } Line line (e.first, e.second); return this->intersect (line); } -void create_canvas_point(NR::Point const &pos, double size, guint32 rgba) +void create_canvas_point(Geom::Point const &pos, double size, guint32 rgba) { SPDesktop *desktop = inkscape_active_desktop(); SPCanvasItem * canvas_pt = sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRL, @@ -208,7 +208,7 @@ void create_canvas_point(NR::Point const &pos, double size, guint32 rgba) SP_CTRL(canvas_pt)->moveto(pos); } -void create_canvas_line(NR::Point const &p1, NR::Point const &p2, guint32 rgba) +void create_canvas_line(Geom::Point const &p1, Geom::Point const &p2, guint32 rgba) { SPDesktop *desktop = inkscape_active_desktop(); SPCanvasItem *line = sp_canvas_item_new(sp_desktop_controls(desktop), diff --git a/src/line-geometry.h b/src/line-geometry.h index 86ed9ee8a..472478e3b 100644 --- a/src/line-geometry.h +++ b/src/line-geometry.h @@ -12,8 +12,6 @@ #ifndef SEEN_LINE_GEOMETRY_H #define SEEN_LINE_GEOMETRY_H -#include "libnr/nr-point.h" -#include "libnr/nr-point-fns.h" #include #include "glib.h" #include "display/sp-ctrlline.h" @@ -26,57 +24,57 @@ namespace Box3D { class Line { public: - Line(NR::Point const &start, NR::Point const &vec, bool is_endpoint = true); + Line(Geom::Point const &start, Geom::Point const &vec, bool is_endpoint = true); Line(Line const &line); virtual ~Line() {} Line &operator=(Line const &line); - virtual boost::optional intersect(Line const &line); - inline NR::Point direction () { return v_dir; } + virtual boost::optional intersect(Line const &line); + inline Geom::Point direction () { return v_dir; } - NR::Point closest_to(NR::Point const &pt); // returns the point on the line closest to pt + Geom::Point closest_to(Geom::Point const &pt); // returns the point on the line closest to pt friend inline std::ostream &operator<< (std::ostream &out_file, const Line &in_line); - boost::optional intersection_with_viewbox (SPDesktop *desktop); - inline bool lie_on_same_side (NR::Point const &A, NR::Point const &B) { + boost::optional intersection_with_viewbox (SPDesktop *desktop); + inline bool lie_on_same_side (Geom::Point const &A, Geom::Point const &B) { /* If A is a point in the plane and n is the normal vector of the line then the sign of dot(A, n) specifies the half-plane in which A lies. Thus A and B lie on the same side if the dot products have equal sign. */ - return ((NR::dot(A, normal) - d0) * (NR::dot(B, normal) - d0)) > 0; + return ((Geom::dot(A, normal) - d0) * (Geom::dot(B, normal) - d0)) > 0; } - double lambda (NR::Point const pt); - inline NR::Point point_from_lambda (double const lambda) { - return (pt + lambda * NR::unit_vector (v_dir)); } + double lambda (Geom::Point const pt); + inline Geom::Point point_from_lambda (double const lambda) { + return (pt + lambda * Geom::unit_vector (v_dir)); } protected: - void set_direction(NR::Point const &dir); - inline static bool pts_coincide (NR::Point const pt1, NR::Point const pt2) + void set_direction(Geom::Point const &dir); + inline static bool pts_coincide (Geom::Point const pt1, Geom::Point const pt2) { - return (NR::L2 (pt2 - pt1) < epsilon); + return (Geom::L2 (pt2 - pt1) < epsilon); } - NR::Point pt; - NR::Point v_dir; - NR::Point normal; - NR::Coord d0; + Geom::Point pt; + Geom::Point v_dir; + Geom::Point normal; + Geom::Coord d0; }; -inline double determinant (NR::Point const &a, NR::Point const &b) +inline double determinant (Geom::Point const &a, Geom::Point const &b) { - return (a[NR::X] * b[NR::Y] - a[NR::Y] * b[NR::X]); + return (a[Geom::X] * b[Geom::Y] - a[Geom::Y] * b[Geom::X]); } -std::pair coordinates (NR::Point const &v1, NR::Point const &v2, NR::Point const &w); -bool lies_in_sector (NR::Point const &v1, NR::Point const &v2, NR::Point const &w); -bool lies_in_quadrangle (NR::Point const &A, NR::Point const &B, NR::Point const &C, NR::Point const &D, NR::Point const &pt); -std::pair side_of_intersection (NR::Point const &A, NR::Point const &B, - NR::Point const &C, NR::Point const &D, - NR::Point const &pt, NR::Point const &dir); +std::pair coordinates (Geom::Point const &v1, Geom::Point const &v2, Geom::Point const &w); +bool lies_in_sector (Geom::Point const &v1, Geom::Point const &v2, Geom::Point const &w); +bool lies_in_quadrangle (Geom::Point const &A, Geom::Point const &B, Geom::Point const &C, Geom::Point const &D, Geom::Point const &pt); +std::pair side_of_intersection (Geom::Point const &A, Geom::Point const &B, + Geom::Point const &C, Geom::Point const &D, + Geom::Point const &pt, Geom::Point const &dir); /*** For debugging purposes: Draw a knot/node of specified size and color at the given position ***/ -void create_canvas_point(NR::Point const &pos, double size = 4.0, guint32 rgba = 0xff00007f); +void create_canvas_point(Geom::Point const &pos, double size = 4.0, guint32 rgba = 0xff00007f); /*** For debugging purposes: Draw a line between the specified points ***/ -void create_canvas_line(NR::Point const &p1, NR::Point const &p2, guint32 rgba = 0xff00007f); +void create_canvas_line(Geom::Point const &p1, Geom::Point const &p2, guint32 rgba = 0xff00007f); /** A function to print out the Line. It just prints out the coordinates of start point and diff --git a/src/livarot/Shape.h b/src/livarot/Shape.h index d1ba63a54..73199a313 100644 --- a/src/livarot/Shape.h +++ b/src/livarot/Shape.h @@ -290,7 +290,7 @@ public: // the result is NOT a polygon; you need a subsequent call to ConvertToShape to get a real polygon int MakeOffset(Shape *of, double dec, JoinType join, double miter, bool do_profile=false, double cx = 0, double cy = 0, double radius = 0, NR::Matrix *i2doc = NULL); - int MakeTweak (int mode, Shape *a, double dec, JoinType join, double miter, bool do_profile, NR::Point c, NR::Point vector, double radius, NR::Matrix *i2doc); + int MakeTweak (int mode, Shape *a, double dec, JoinType join, double miter, bool do_profile, Geom::Point c, Geom::Point vector, double radius, Geom::Matrix *i2doc); int PtWinding(const NR::Point px) const; // plus rapide int Winding(const NR::Point px) const; diff --git a/src/livarot/ShapeMisc.cpp b/src/livarot/ShapeMisc.cpp index cacf4c997..824f04a88 100644 --- a/src/livarot/ShapeMisc.cpp +++ b/src/livarot/ShapeMisc.cpp @@ -528,7 +528,7 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,in int -Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter, bool do_profile, NR::Point c, NR::Point vector, double radius, NR::Matrix *i2doc) +Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter, bool do_profile, Geom::Point c, Geom::Point vector, double radius, Geom::Matrix *i2doc) { Reset (0, 0); MakeBackData(a->_has_back_data); @@ -584,7 +584,7 @@ Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter, enB = a->CyclePrevAt (a->getEdge(i).en, i); } - NR::Point stD, seD, enD; + Geom::Point stD, seD, enD; double stL, seL, enL; stD = a->getEdge(stB).dx; seD = a->getEdge(i).dx; @@ -597,21 +597,21 @@ Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter, MiscNormalize (enD); MiscNormalize (seD); - NR::Point ptP; + Geom::Point ptP; int stNo, enNo; ptP = a->getPoint(a->getEdge(i).st).x; - NR::Point to_center = ptP * (*i2doc) - c; - NR::Point to_center_normalized = (1/NR::L2(to_center)) * to_center; + Geom::Point to_center = ptP * (*i2doc) - c; + Geom::Point to_center_normalized = (1/Geom::L2(to_center)) * to_center; double this_power; if (do_profile && i2doc) { double alpha = 1; double x; if (mode == tweak_mode_repel) { - x = (NR::L2(to_center)/radius); + x = (Geom::L2(to_center)/radius); } else { - x = (NR::L2(ptP * (*i2doc) - c)/radius); + x = (Geom::L2(ptP * (*i2doc) - c)/radius); } if (x > 1) { this_power = 0; @@ -635,11 +635,11 @@ Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter, if (this_power != 0) done_something = true; - double scaler = 1 / NR::expansion(*i2doc); + double scaler = 1 / (*i2doc).descrim(); - NR::Point this_vec(0,0); + Geom::Point this_vec(0,0); if (mode == tweak_mode_push) { - NR::Matrix tovec (*i2doc); + Geom::Matrix tovec (*i2doc); tovec[4] = tovec[5] = 0; tovec = tovec.inverse(); this_vec = this_power * (vector * tovec) ; @@ -647,7 +647,7 @@ Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter, this_vec = this_power * scaler * to_center_normalized; } else if (mode == tweak_mode_roughen) { double angle = g_random_double_range(0, 2*M_PI); - this_vec = g_random_double_range(0, 1) * this_power * scaler * NR::Point(sin(angle), cos(angle)); + this_vec = g_random_double_range(0, 1) * this_power * scaler * Geom::Point(sin(angle), cos(angle)); } int usePathID=-1; diff --git a/src/marker.cpp b/src/marker.cpp index 9f387edfb..49486476d 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -52,7 +52,7 @@ static Inkscape::XML::Node *sp_marker_write (SPObject *object, Inkscape::XML::Do static NRArenaItem *sp_marker_private_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); static void sp_marker_private_hide (SPItem *item, unsigned int key); -static void sp_marker_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags); +static void sp_marker_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); static void sp_marker_print (SPItem *item, SPPrintContext *ctx); static void sp_marker_view_remove (SPMarker *marker, SPMarkerView *view, unsigned int destroyitems); @@ -120,7 +120,7 @@ sp_marker_init (SPMarker *marker) { marker->viewBox_set = FALSE; - marker->c2p.set_identity(); + marker->c2p.setIdentity(); } /** @@ -376,7 +376,7 @@ sp_marker_update (SPObject *object, SPCtx *ctx, guint flags) rctx.vp.y1 = marker->markerHeight.computed; /* Start with identity transform */ - marker->c2p.set_identity(); + marker->c2p.setIdentity(); /* Viewbox is always present, either implicitly or explicitly */ if (marker->viewBox_set) { @@ -445,7 +445,7 @@ sp_marker_update (SPObject *object, SPCtx *ctx, guint flags) } { - NR::Matrix q; + Geom::Matrix q; /* Compose additional transformation from scale and position */ q[0] = width / (vb->x1 - vb->x0); q[1] = 0.0; @@ -459,18 +459,18 @@ sp_marker_update (SPObject *object, SPCtx *ctx, guint flags) /* Append reference translation */ /* fixme: lala (Lauris) */ - marker->c2p = NR::translate(-marker->refX.computed, -marker->refY.computed) * marker->c2p; + marker->c2p = Geom::Translate(-marker->refX.computed, -marker->refY.computed) * marker->c2p; rctx.i2doc = marker->c2p * rctx.i2doc; /* If viewBox is set reinitialize child viewport */ /* Otherwise it already correct */ if (marker->viewBox_set) { - rctx.vp.x0 = marker->viewBox.x0; - rctx.vp.y0 = marker->viewBox.y0; - rctx.vp.x1 = marker->viewBox.x1; - rctx.vp.y1 = marker->viewBox.y1; - rctx.i2vp = NR::identity(); + rctx.vp.x0 = marker->viewBox.x0; + rctx.vp.y0 = marker->viewBox.y0; + rctx.vp.x1 = marker->viewBox.x1; + rctx.vp.y1 = marker->viewBox.y1; + rctx.i2vp = Geom::identity(); } /* And invoke parent method */ @@ -479,11 +479,12 @@ sp_marker_update (SPObject *object, SPCtx *ctx, guint flags) /* As last step set additional transform of arena group */ for (v = marker->views; v != NULL; v = v->next) { - for (unsigned i = 0 ; i < v->size ; i++) { - if (v->items[i]) { - nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->items[i]), &marker->c2p); - } - } + for (unsigned i = 0 ; i < v->size ; i++) { + if (v->items[i]) { + NR::Matrix tmp = from_2geom(marker->c2p); + nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->items[i]), &tmp); + } + } } } @@ -572,7 +573,7 @@ sp_marker_private_hide (SPItem */*item*/, unsigned int /*key*/) * This routine is disabled to break propagation. */ static void -sp_marker_bbox(SPItem const *, NRRect *, NR::Matrix const &, unsigned const) +sp_marker_bbox(SPItem const *, NRRect *, Geom::Matrix const &, unsigned const) { /* Break propagation */ } @@ -648,7 +649,8 @@ sp_marker_show_instance ( SPMarker *marker, NRArenaItem *parent, /* fixme: Position (Lauris) */ nr_arena_item_add_child (parent, v->items[pos], NULL); /* nr_arena_item_unref (v->items[pos]); */ - nr_arena_group_set_child_transform((NRArenaGroup *) v->items[pos], &marker->c2p); + NR::Matrix tmp = from_2geom(marker->c2p); + nr_arena_group_set_child_transform((NRArenaGroup *) v->items[pos], &tmp); } } if (v->items[pos]) { @@ -722,7 +724,7 @@ sp_marker_view_remove (SPMarker *marker, SPMarkerView *view, unsigned int destro } const gchar * -generate_marker (GSList *reprs, NR::Rect bounds, SPDocument *document, NR::Matrix /*transform*/, NR::Matrix move) +generate_marker (GSList *reprs, NR::Rect bounds, SPDocument *document, Geom::Matrix /*transform*/, Geom::Matrix move) { Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document); Inkscape::XML::Node *defsrepr = SP_OBJECT_REPR (SP_DOCUMENT_DEFS (document)); @@ -747,9 +749,9 @@ generate_marker (GSList *reprs, NR::Rect bounds, SPDocument *document, NR::Matri Inkscape::XML::Node *node = (Inkscape::XML::Node *)(i->data); SPItem *copy = SP_ITEM(mark_object->appendChildRepr(node)); - NR::Matrix dup_transform; + Geom::Matrix dup_transform; if (!sp_svg_transform_read (node->attribute("transform"), &dup_transform)) - dup_transform = NR::identity(); + dup_transform = Geom::identity(); dup_transform *= move; sp_item_write_transform(copy, SP_OBJECT_REPR(copy), dup_transform); diff --git a/src/marker.h b/src/marker.h index f2db5a6c6..cc7924486 100644 --- a/src/marker.h +++ b/src/marker.h @@ -26,7 +26,6 @@ class SPMarker; class SPMarkerClass; class SPMarkerView; -#include #include #include <2geom/forward.h> #include "svg/svg-length.h" @@ -63,7 +62,7 @@ struct SPMarker : public SPGroup { unsigned int aspect_clip : 1; /* Child to parent additional transform */ - NR::Matrix c2p; + Geom::Matrix c2p; /* Private views */ SPMarkerView *views; @@ -91,7 +90,7 @@ NRArenaItem *sp_marker_show_instance (SPMarker *marker, NRArenaItem *parent, unsigned int key, unsigned int pos, Geom::Matrix const &base, float linewidth); void sp_marker_hide (SPMarker *marker, unsigned int key); -const gchar *generate_marker (GSList *reprs, NR::Rect bounds, SPDocument *document, NR::Matrix transform, NR::Matrix move); +const gchar *generate_marker (GSList *reprs, NR::Rect bounds, SPDocument *document, Geom::Matrix transform, Geom::Matrix move); #endif diff --git a/src/node-context.cpp b/src/node-context.cpp index 17243b1b2..f16af7035 100644 --- a/src/node-context.cpp +++ b/src/node-context.cpp @@ -442,7 +442,7 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) if (event->type == GDK_BUTTON_RELEASE) { event_context->xp = event_context->yp = 0; if (event->button.button == 1) { - boost::optional b = Inkscape::Rubberband::get(desktop)->getRectangle(); + boost::optional b = Inkscape::Rubberband::get(desktop)->getRectangle(); if (nc->shape_editor->hits_curve() && !event_context->within_tolerance) { //drag curve nc->shape_editor->finish_drag(); @@ -625,7 +625,7 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) break; case GDK_Escape: { - boost::optional const b = Inkscape::Rubberband::get(desktop)->getRectangle(); + boost::optional const b = Inkscape::Rubberband::get(desktop)->getRectangle(); if (b) { Inkscape::Rubberband::get(desktop)->stop(); nc->current_state = SP_NODE_CONTEXT_INACTIVE; diff --git a/src/nodepath.cpp b/src/nodepath.cpp index 7a6276dde..c3242ccc1 100644 --- a/src/nodepath.cpp +++ b/src/nodepath.cpp @@ -63,7 +63,7 @@ #include "display/snap-indicator.h" #include "snapped-point.h" -class NR::Matrix; +class Geom::Matrix; /// \todo /// evil evil evil. FIXME: conflict of two different Path classes! @@ -533,7 +533,7 @@ static void subpaths_from_pathvector(Inkscape::NodePath::Path *np, Geom::PathVec Inkscape::NodePath::SubPath *sp = sp_nodepath_subpath_new(np); - Geom::Point ppos = pit->initialPoint() * (Geom::Matrix)np->i2d; + Geom::Point ppos = pit->initialPoint() * np->i2d; NRPathcode pcode = NR_MOVETO; /* Johan: Note that this is pretty arcane code. I am pretty sure it is working correctly, be very certain to change it! (better to just rewrite this whole method)*/ @@ -890,16 +890,16 @@ static void sp_nodepath_line_midpoint(Inkscape::NodePath::Node *new_path,Inkscap new_path->code = NR_CURVETO; gdouble s = 1 - t; for (int dim = 0; dim < 2; dim++) { - NR::Coord const f000 = start->pos[dim]; - NR::Coord const f001 = start->n.pos[dim]; - NR::Coord const f011 = end->p.pos[dim]; - NR::Coord const f111 = end->pos[dim]; - NR::Coord const f00t = s * f000 + t * f001; - NR::Coord const f01t = s * f001 + t * f011; - NR::Coord const f11t = s * f011 + t * f111; - NR::Coord const f0tt = s * f00t + t * f01t; - NR::Coord const f1tt = s * f01t + t * f11t; - NR::Coord const fttt = s * f0tt + t * f1tt; + Geom::Coord const f000 = start->pos[dim]; + Geom::Coord const f001 = start->n.pos[dim]; + Geom::Coord const f011 = end->p.pos[dim]; + Geom::Coord const f111 = end->pos[dim]; + Geom::Coord const f00t = s * f000 + t * f001; + Geom::Coord const f01t = s * f001 + t * f011; + Geom::Coord const f11t = s * f011 + t * f111; + Geom::Coord const f0tt = s * f00t + t * f01t; + Geom::Coord const f1tt = s * f01t + t * f11t; + Geom::Coord const fttt = s * f0tt + t * f1tt; start->n.pos[dim] = f00t; new_path->p.pos[dim] = f0tt; new_path->pos[dim] = fttt; @@ -1118,8 +1118,8 @@ sp_node_side_is_line (Inkscape::NodePath::Node *node, Inkscape::NodePath::NodeSi if (!other_to_me) return false; bool is_line = - (NR::L2(othernode->pos - other_to_me->pos) < 1e-6 && - NR::L2(node->pos - side->pos) < 1e-6); + (Geom::L2(othernode->pos - other_to_me->pos) < 1e-6 && + Geom::L2(node->pos - side->pos) < 1e-6); return is_line; } @@ -1156,8 +1156,8 @@ void sp_nodepath_convert_node_type(Inkscape::NodePath::Node *node, Inkscape::Nod } } */ - bool p_has_handle = (NR::L2(node->pos - node->p.pos) > 1e-6); - bool n_has_handle = (NR::L2(node->pos - node->n.pos) > 1e-6); + bool p_has_handle = (Geom::L2(node->pos - node->p.pos) > 1e-6); + bool n_has_handle = (Geom::L2(node->pos - node->n.pos) > 1e-6); bool p_is_line = sp_node_side_is_line(node, &node->p); bool n_is_line = sp_node_side_is_line(node, &node->n); @@ -1186,16 +1186,16 @@ void sp_nodepath_convert_node_type(Inkscape::NodePath::Node *node, Inkscape::Nod // pull n handle node->n.other->code = NR_CURVETO; double len = (type == Inkscape::NodePath::NODE_SYMM)? - NR::L2(node->p.pos - node->pos) : - NR::L2(node->n.other->pos - node->pos) / 3; - node->n.pos = node->pos - (len / NR::L2(node->p.pos - node->pos)) * (node->p.pos - node->pos); + Geom::L2(node->p.pos - node->pos) : + Geom::L2(node->n.other->pos - node->pos) / 3; + node->n.pos = node->pos - (len / Geom::L2(node->p.pos - node->pos)) * (node->p.pos - node->pos); } else if (n_has_handle && node->p.other) { // pull p handle node->code = NR_CURVETO; double len = (type == Inkscape::NodePath::NODE_SYMM)? - NR::L2(node->n.pos - node->pos) : - NR::L2(node->p.other->pos - node->pos) / 3; - node->p.pos = node->pos - (len / NR::L2(node->n.pos - node->pos)) * (node->n.pos - node->pos); + Geom::L2(node->n.pos - node->pos) : + Geom::L2(node->p.other->pos - node->pos) / 3; + node->p.pos = node->pos - (len / Geom::L2(node->n.pos - node->pos)) * (node->n.pos - node->pos); } } else if (!p_has_handle && !n_has_handle) { if ((p_is_line && n_is_line) || (!p_is_line && node->p.other && !n_is_line && node->n.other)) { @@ -1234,15 +1234,15 @@ void sp_nodepath_convert_node_type(Inkscape::NodePath::Node *node, Inkscape::Nod if (type != Inkscape::NodePath::NODE_SYMM) { // pull n handle node->n.other->code = NR_CURVETO; - double len = NR::L2(node->n.other->pos - node->pos) / 3; - node->n.pos = node->pos + (len / NR::L2(node->p.other->pos - node->pos)) * (node->p.other->pos - node->pos); + double len = Geom::L2(node->n.other->pos - node->pos) / 3; + node->n.pos = node->pos + (len / Geom::L2(node->p.other->pos - node->pos)) * (node->p.other->pos - node->pos); } } else if (n_is_line && node->p.other) { if (type != Inkscape::NodePath::NODE_SYMM) { // pull p handle node->code = NR_CURVETO; - double len = NR::L2(node->p.other->pos - node->pos) / 3; - node->p.pos = node->pos + (len / NR::L2(node->n.other->pos - node->pos)) * (node->n.other->pos - node->pos); + double len = Geom::L2(node->p.other->pos - node->pos) / 3; + node->p.pos = node->pos + (len / Geom::L2(node->n.other->pos - node->pos)) * (node->n.other->pos - node->pos); } } } @@ -1299,11 +1299,11 @@ void sp_node_moveto(Inkscape::NodePath::Node *node, Geom::Point p) /** * Call sp_node_moveto() for node selection and handle possible snapping. */ -static void sp_nodepath_selected_nodes_move(Inkscape::NodePath::Path *nodepath, NR::Coord dx, NR::Coord dy, +static void sp_nodepath_selected_nodes_move(Inkscape::NodePath::Path *nodepath, Geom::Coord dx, Geom::Coord dy, bool const snap, bool constrained = false, Inkscape::Snapper::ConstraintLine const &constraint = Geom::Point()) { - NR::Coord best = NR_HUGE; + Geom::Coord best = NR_HUGE; Geom::Point delta(dx, dy); Geom::Point best_pt = delta; Inkscape::SnappedPoint best_abs; @@ -1398,8 +1398,8 @@ double bezier_length (Geom::Point a, Geom::Point ah, Geom::Point bh, Geom::Point b) { // extremely primitive for now, don't have time to look for the real one - double lower = NR::L2(b - a); - double upper = NR::L2(ah - a) + NR::L2(bh - ah) + NR::L2(bh - b); + double lower = Geom::L2(b - a); + double upper = Geom::L2(ah - a) + Geom::L2(bh - ah) + Geom::L2(bh - b); return (lower + upper)/2; } @@ -1505,8 +1505,8 @@ sp_nodepath_selected_nodes_sculpt(Inkscape::NodePath::Path *nodepath, Inkscape:: if (n_node->selected) { sp_nodepath_move_node_and_handles (n_node, sculpt_profile (n_range / n_sel_range, alpha, profile) * delta, - sculpt_profile ((n_range + NR::L2(n_node->n.origin - n_node->origin)) / n_sel_range, alpha, profile) * delta, - sculpt_profile ((n_range - NR::L2(n_node->p.origin - n_node->origin)) / n_sel_range, alpha, profile) * delta); + sculpt_profile ((n_range + Geom::L2(n_node->n.origin - n_node->origin)) / n_sel_range, alpha, profile) * delta, + sculpt_profile ((n_range - Geom::L2(n_node->p.origin - n_node->origin)) / n_sel_range, alpha, profile) * delta); } if (n_node == p_node) { n_going = false; @@ -1522,8 +1522,8 @@ sp_nodepath_selected_nodes_sculpt(Inkscape::NodePath::Path *nodepath, Inkscape:: if (p_node->selected) { sp_nodepath_move_node_and_handles (p_node, sculpt_profile (p_range / p_sel_range, alpha, profile) * delta, - sculpt_profile ((p_range - NR::L2(p_node->n.origin - p_node->origin)) / p_sel_range, alpha, profile) * delta, - sculpt_profile ((p_range + NR::L2(p_node->p.origin - p_node->origin)) / p_sel_range, alpha, profile) * delta); + sculpt_profile ((p_range - Geom::L2(p_node->n.origin - p_node->origin)) / p_sel_range, alpha, profile) * delta, + sculpt_profile ((p_range + Geom::L2(p_node->p.origin - p_node->origin)) / p_sel_range, alpha, profile) * delta); } if (p_node == n_node) { n_going = false; @@ -1535,7 +1535,7 @@ sp_nodepath_selected_nodes_sculpt(Inkscape::NodePath::Path *nodepath, Inkscape:: } else { // Multiple subpaths have selected nodes: - // use spatial mode, where the distance from n to node being dragged is measured directly as NR::L2. + // use spatial mode, where the distance from n to node being dragged is measured directly as Geom::L2. // TODO: correct these distances taking into account their angle relative to the bisector, so as to // fix the pear-like shape when sculpting e.g. a ring @@ -1546,7 +1546,7 @@ sp_nodepath_selected_nodes_sculpt(Inkscape::NodePath::Path *nodepath, Inkscape:: for (GList *nl = subpath->nodes; nl != NULL; nl = nl->next) { Inkscape::NodePath::Node *node = (Inkscape::NodePath::Node *) nl->data; if (node->selected) { - direct_range = MAX(direct_range, NR::L2(node->origin - n->origin)); + direct_range = MAX(direct_range, Geom::L2(node->origin - n->origin)); } } } @@ -1559,9 +1559,9 @@ sp_nodepath_selected_nodes_sculpt(Inkscape::NodePath::Path *nodepath, Inkscape:: if (node->selected) { if (direct_range > 1e-6) { sp_nodepath_move_node_and_handles (node, - sculpt_profile (NR::L2(node->origin - n->origin) / direct_range, alpha, profile) * delta, - sculpt_profile (NR::L2(node->n.origin - n->origin) / direct_range, alpha, profile) * delta, - sculpt_profile (NR::L2(node->p.origin - n->origin) / direct_range, alpha, profile) * delta); + sculpt_profile (Geom::L2(node->origin - n->origin) / direct_range, alpha, profile) * delta, + sculpt_profile (Geom::L2(node->n.origin - n->origin) / direct_range, alpha, profile) * delta, + sculpt_profile (Geom::L2(node->p.origin - n->origin) / direct_range, alpha, profile) * delta); } else { sp_nodepath_move_node_and_handles (node, delta, delta, delta); } @@ -1637,7 +1637,7 @@ void sp_node_selected_move_absolute(Inkscape::NodePath::Path *nodepath, Geom::Co } /** - * If the coordinates of all selected nodes coincide, return the common coordinate; otherwise return NR::Nothing + * If the coordinates of all selected nodes coincide, return the common coordinate; otherwise return Geom::Nothing */ boost::optional sp_node_selected_common_coord (Inkscape::NodePath::Path *nodepath, Geom::Dim2 axis) { @@ -1647,7 +1647,7 @@ boost::optional sp_node_selected_common_coord (Inkscape::NodePath:: // determine coordinate of first selected node GList *nsel = nodepath->selected; Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) nsel->data; - NR::Coord coord = n->pos[axis]; + Geom::Coord coord = n->pos[axis]; bool coincide = true; // compare it to the coordinates of all the other selected nodes @@ -1704,7 +1704,7 @@ static void sp_node_update_handle(Inkscape::NodePath::Node *node, gint which, gb Inkscape::NodePath::NodeSide *side = sp_node_get_side(node, which); NRPathcode code = sp_node_path_code_from_side(node, side); - show_handle = show_handle && (code == NR_CURVETO) && (NR::L2(side->pos - node->pos) > 1e-6); + show_handle = show_handle && (code == NR_CURVETO) && (Geom::L2(side->pos - node->pos) > 1e-6); if (show_handle) { if (!side->knot) { // No handle knot at all @@ -1848,7 +1848,7 @@ void sp_nodepath_selected_align(Inkscape::NodePath::Path *nodepath, Geom::Dim2 a struct NodeSort { Inkscape::NodePath::Node *_node; - NR::Coord _coord; + Geom::Coord _coord; /// \todo use vectorof pointers instead of calling copy ctor NodeSort(Inkscape::NodePath::Node *node, Geom::Dim2 axis) : _node(node), _coord(node->pos[axis]) @@ -2997,7 +2997,7 @@ void sp_nodepath_select_prev(Inkscape::NodePath::Path *nodepath) /** * \brief Select all nodes that are within the rectangle. */ -void sp_nodepath_select_rect(Inkscape::NodePath::Path *nodepath, NR::Rect const &b, gboolean incremental) +void sp_nodepath_select_rect(Inkscape::NodePath::Path *nodepath, Geom::Rect const &b, gboolean incremental) { if (!incremental) { sp_nodepath_deselect(nodepath); @@ -3131,13 +3131,13 @@ nodepath_grow_selection_spatially (Inkscape::NodePath::Path *nodepath, Inkscape: if (node == n) continue; if (node->selected) { - if (NR::L2(node->pos - n->pos) > farthest_dist) { - farthest_dist = NR::L2(node->pos - n->pos); + if (Geom::L2(node->pos - n->pos) > farthest_dist) { + farthest_dist = Geom::L2(node->pos - n->pos); farthest_selected = node; } } else { - if (NR::L2(node->pos - n->pos) < closest_dist) { - closest_dist = NR::L2(node->pos - n->pos); + if (Geom::L2(node->pos - n->pos) < closest_dist) { + closest_dist = Geom::L2(node->pos - n->pos); closest_unselected = node; } } @@ -3245,9 +3245,9 @@ static void sp_node_adjust_handle(Inkscape::NodePath::Node *node, gint which_adj if (sp_node_side_is_line(node, other)) { // other is a line, and we are either smooth or symm Inkscape::NodePath::Node *othernode = other->other; - double len = NR::L2(me->pos - node->pos); + double len = Geom::L2(me->pos - node->pos); Geom::Point delta = node->pos - othernode->pos; - double linelen = NR::L2(delta); + double linelen = Geom::L2(delta); if (linelen < 1e-18) return; me->pos = node->pos + (len / linelen)*delta; @@ -3260,9 +3260,9 @@ static void sp_node_adjust_handle(Inkscape::NodePath::Node *node, gint which_adj return; } else { // smoothify - double len = NR::L2(me->pos - node->pos); + double len = Geom::L2(me->pos - node->pos); Geom::Point delta = other->pos - node->pos; - double otherlen = NR::L2(delta); + double otherlen = Geom::L2(delta); if (otherlen < 1e-18) return; me->pos = node->pos - (len / otherlen) * delta; } @@ -3302,9 +3302,9 @@ static void sp_node_adjust_handles(Inkscape::NodePath::Node *node) } /* We are smooth */ - double plen = NR::L2(node->p.pos - node->pos); + double plen = Geom::L2(node->p.pos - node->pos); if (plen < 1e-18) return; - double nlen = NR::L2(node->n.pos - node->pos); + double nlen = Geom::L2(node->n.pos - node->pos); if (nlen < 1e-18) return; node->p.pos = node->pos - (plen / (plen + nlen)) * delta; node->n.pos = node->pos + (nlen / (plen + nlen)) * delta; @@ -3500,10 +3500,10 @@ static void node_ungrabbed(SPKnot */*knot*/, guint /*state*/, gpointer data) static void point_line_closest(Geom::Point *p, double a, Geom::Point *closest) { if (a == HUGE_VAL) { // vertical - *closest = Geom::Point(0, (*p)[NR::Y]); + *closest = Geom::Point(0, (*p)[Geom::Y]); } else { - (*closest)[NR::X] = ( a * (*p)[NR::Y] + (*p)[NR::X]) / (a*a + 1); - (*closest)[NR::Y] = a * (*closest)[NR::X]; + (*closest)[Geom::X] = ( a * (*p)[Geom::Y] + (*p)[Geom::X]) / (a*a + 1); + (*closest)[Geom::Y] = a * (*closest)[Geom::X]; } } @@ -3516,7 +3516,7 @@ static double point_line_distance(Geom::Point *p, double a) { Geom::Point c; point_line_closest(p, a, &c); - return sqrt(((*p)[NR::X] - c[NR::X])*((*p)[NR::X] - c[NR::X]) + ((*p)[NR::Y] - c[NR::Y])*((*p)[NR::Y] - c[NR::Y])); + return sqrt(((*p)[Geom::X] - c[Geom::X])*((*p)[Geom::X] - c[Geom::X]) + ((*p)[Geom::Y] - c[Geom::Y])*((*p)[Geom::Y] - c[Geom::Y])); } /** @@ -3546,8 +3546,8 @@ node_request(SPKnot */*knot*/, Geom::Point *p, guint state, gpointer data) if (!n->dragging_out) { // This is the first drag-out event; find out which handle to drag out - double appr_n = (n->n.other ? NR::L2(n->n.other->pos - n->pos) - NR::L2(n->n.other->pos - (*p)) : -HUGE_VAL); - double appr_p = (n->p.other ? NR::L2(n->p.other->pos - n->pos) - NR::L2(n->p.other->pos - (*p)) : -HUGE_VAL); + double appr_n = (n->n.other ? Geom::L2(n->n.other->pos - n->pos) - Geom::L2(n->n.other->pos - (*p)) : -HUGE_VAL); + double appr_p = (n->p.other ? Geom::L2(n->p.other->pos - n->pos) - Geom::L2(n->p.other->pos - (*p)) : -HUGE_VAL); if (appr_p == -HUGE_VAL && appr_n == -HUGE_VAL) // orphan node? return FALSE; @@ -3571,8 +3571,8 @@ node_request(SPKnot */*knot*/, Geom::Point *p, guint state, gpointer data) opposite = &n->p; n->n.other->code = NR_CURVETO; } else { // find out to which handle of the adjacent node we're closer; note that n->n.other == n->p.other - double appr_other_n = (n->n.other ? NR::L2(n->n.other->n.pos - n->pos) - NR::L2(n->n.other->n.pos - (*p)) : -HUGE_VAL); - double appr_other_p = (n->n.other ? NR::L2(n->n.other->p.pos - n->pos) - NR::L2(n->n.other->p.pos - (*p)) : -HUGE_VAL); + double appr_other_n = (n->n.other ? Geom::L2(n->n.other->n.pos - n->pos) - Geom::L2(n->n.other->n.pos - (*p)) : -HUGE_VAL); + double appr_other_p = (n->n.other ? Geom::L2(n->n.other->p.pos - n->pos) - Geom::L2(n->n.other->p.pos - (*p)) : -HUGE_VAL); if (appr_other_p > appr_other_n) { // closer to other's p handle n->dragging_out = &n->n; opposite = &n->p; @@ -3605,28 +3605,28 @@ node_request(SPKnot */*knot*/, Geom::Point *p, guint state, gpointer data) // calculate relative distances of handles // n handle: - yn = n->n.pos[NR::Y] - n->pos[NR::Y]; - xn = n->n.pos[NR::X] - n->pos[NR::X]; + yn = n->n.pos[Geom::Y] - n->pos[Geom::Y]; + xn = n->n.pos[Geom::X] - n->pos[Geom::X]; // if there's no n handle (straight line), see if we can use the direction to the next point on path if ((n->n.other && n->n.other->code == NR_LINETO) || fabs(yn) + fabs(xn) < 1e-6) { if (n->n.other) { // if there is the next point if (L2(n->n.other->p.pos - n->n.other->pos) < 1e-6) // and the next point has no handle either - yn = n->n.other->origin[NR::Y] - n->origin[NR::Y]; // use origin because otherwise the direction will change as you drag - xn = n->n.other->origin[NR::X] - n->origin[NR::X]; + yn = n->n.other->origin[Geom::Y] - n->origin[Geom::Y]; // use origin because otherwise the direction will change as you drag + xn = n->n.other->origin[Geom::X] - n->origin[Geom::X]; } } if (xn < 0) { xn = -xn; yn = -yn; } // limit the angle to between 0 and pi if (yn < 0) { xn = -xn; yn = -yn; } // p handle: - yp = n->p.pos[NR::Y] - n->pos[NR::Y]; - xp = n->p.pos[NR::X] - n->pos[NR::X]; + yp = n->p.pos[Geom::Y] - n->pos[Geom::Y]; + xp = n->p.pos[Geom::X] - n->pos[Geom::X]; // if there's no p handle (straight line), see if we can use the direction to the prev point on path if (n->code == NR_LINETO || fabs(yp) + fabs(xp) < 1e-6) { if (n->p.other) { if (L2(n->p.other->n.pos - n->p.other->pos) < 1e-6) - yp = n->p.other->origin[NR::Y] - n->origin[NR::Y]; - xp = n->p.other->origin[NR::X] - n->origin[NR::X]; + yp = n->p.other->origin[Geom::Y] - n->origin[Geom::Y]; + xp = n->p.other->origin[Geom::X] - n->origin[Geom::X]; } } if (xp < 0) { xp = -xp; yp = -yp; } // limit the angle to between 0 and pi @@ -3680,24 +3680,24 @@ node_request(SPKnot */*knot*/, Geom::Point *p, guint state, gpointer data) // move the node to the closest point sp_nodepath_selected_nodes_move(n->subpath->nodepath, - n->origin[NR::X] + c[NR::X] - n->pos[NR::X], - n->origin[NR::Y] + c[NR::Y] - n->pos[NR::Y], + n->origin[Geom::X] + c[Geom::X] - n->pos[Geom::X], + n->origin[Geom::Y] + c[Geom::Y] - n->pos[Geom::Y], true); } else { // constraining to hor/vert - if (fabs((*p)[NR::X] - n->origin[NR::X]) > fabs((*p)[NR::Y] - n->origin[NR::Y])) { // snap to hor + if (fabs((*p)[Geom::X] - n->origin[Geom::X]) > fabs((*p)[Geom::Y] - n->origin[Geom::Y])) { // snap to hor sp_nodepath_selected_nodes_move(n->subpath->nodepath, - (*p)[NR::X] - n->pos[NR::X], - n->origin[NR::Y] - n->pos[NR::Y], + (*p)[Geom::X] - n->pos[Geom::X], + n->origin[Geom::Y] - n->pos[Geom::Y], true, - true, Inkscape::Snapper::ConstraintLine(component_vectors[NR::X])); + true, Inkscape::Snapper::ConstraintLine(component_vectors[Geom::X])); } else { // snap to vert sp_nodepath_selected_nodes_move(n->subpath->nodepath, - n->origin[NR::X] - n->pos[NR::X], - (*p)[NR::Y] - n->pos[NR::Y], + n->origin[Geom::X] - n->pos[Geom::X], + (*p)[Geom::Y] - n->pos[Geom::Y], true, - true, Inkscape::Snapper::ConstraintLine(component_vectors[NR::Y])); + true, Inkscape::Snapper::ConstraintLine(component_vectors[Geom::Y])); } } } else { // move freely @@ -3706,8 +3706,8 @@ node_request(SPKnot */*knot*/, Geom::Point *p, guint state, gpointer data) sp_nodepath_selected_nodes_sculpt(n->subpath->nodepath, n, (*p) - n->origin); } else { sp_nodepath_selected_nodes_move(n->subpath->nodepath, - (*p)[NR::X] - n->pos[NR::X], - (*p)[NR::Y] - n->pos[NR::Y], + (*p)[Geom::X] - n->pos[Geom::X], + (*p)[Geom::Y] - n->pos[Geom::Y], (state & GDK_SHIFT_MASK) == 0); } } @@ -3824,12 +3824,12 @@ static gboolean node_handle_request(SPKnot *knot, Geom::Point *p, guint state, g if ((n->type != Inkscape::NodePath::NODE_CUSP) && sp_node_side_is_line(n, opposite)) { /* We are smooth node adjacent with line */ Geom::Point const delta = *p - n->pos; - NR::Coord const len = NR::L2(delta); + Geom::Coord const len = Geom::L2(delta); Inkscape::NodePath::Node *othernode = opposite->other; Geom::Point const ndelta = n->pos - othernode->pos; - NR::Coord const linelen = NR::L2(ndelta); + Geom::Coord const linelen = Geom::L2(ndelta); if (len > NR_EPSILON && linelen > NR_EPSILON) { - NR::Coord const scal = dot(delta, ndelta) / linelen; + Geom::Coord const scal = dot(delta, ndelta) / linelen; (*p) = n->pos + (scal / linelen) * ndelta; } if ((state & GDK_SHIFT_MASK) == 0) { @@ -3908,7 +3908,7 @@ static void node_handle_moved(SPKnot *knot, Geom::Point *p, guint state, gpointe } else { other_to_snap = other->pos - n->pos; } - if (NR::L2(other_to_snap) > 1e-3) { + if (Geom::L2(other_to_snap) > 1e-3) { Radial rother_to_snap(other_to_snap); /* The closest PI/2 angle, starting from the angle of the opposite line segment */ double const a_oppo = rother_to_snap.a + floor((rnew.a - rother_to_snap.a)/(M_PI/2) + 0.5) * (M_PI/2); @@ -3994,12 +3994,12 @@ static gboolean node_handle_event(SPKnot *knot, GdkEvent *event,Inkscape::NodePa break; case GDK_ENTER_NOTIFY: // we use an experimentally determined threshold that seems to work fine - if (NR::L2(n->pos - knot->pos) < 0.75) + if (Geom::L2(n->pos - knot->pos) < 0.75) Inkscape::NodePath::Path::active_node = n; break; case GDK_LEAVE_NOTIFY: // we use an experimentally determined threshold that seems to work fine - if (NR::L2(n->pos - knot->pos) < 0.75) + if (Geom::L2(n->pos - knot->pos) < 0.75) Inkscape::NodePath::Path::active_node = NULL; break; default: @@ -4058,8 +4058,8 @@ static void node_rotate_one (Inkscape::NodePath::Node *n, gdouble angle, int whi Inkscape::NodePath::NodeSide *me, *other; bool both = false; - double xn = n->n.other? n->n.other->pos[NR::X] : n->pos[NR::X]; - double xp = n->p.other? n->p.other->pos[NR::X] : n->pos[NR::X]; + double xn = n->n.other? n->n.other->pos[Geom::X] : n->pos[Geom::X]; + double xp = n->p.other? n->p.other->pos[Geom::X] : n->pos[Geom::X]; if (!n->n.other) { // if this is an endnode, select its single handle regardless of "which" me = &(n->p); @@ -4125,7 +4125,7 @@ void sp_nodepath_selected_nodes_rotate(Inkscape::NodePath::Path *nodepath, gdoub // rotate as an object: Inkscape::NodePath::Node *n0 = (Inkscape::NodePath::Node *) nodepath->selected->data; - NR::Rect box (n0->pos, n0->pos); // originally includes the first selected node + Geom::Rect box (n0->pos, n0->pos); // originally includes the first selected node for (GList *l = nodepath->selected; l != NULL; l = l->next) { Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data; box.expandTo (n->pos); // contain all selected nodes @@ -4135,7 +4135,7 @@ void sp_nodepath_selected_nodes_rotate(Inkscape::NodePath::Path *nodepath, gdoub if (screen) { gdouble const zoom = nodepath->desktop->current_zoom(); gdouble const zmove = angle / zoom; - gdouble const r = NR::L2(box.max() - box.midpoint()); + gdouble const r = Geom::L2(box.max() - box.midpoint()); rot = atan2(zmove, r); } else { rot = angle; @@ -4147,10 +4147,10 @@ void sp_nodepath_selected_nodes_rotate(Inkscape::NodePath::Path *nodepath, gdoub else rot_center = Inkscape::NodePath::Path::active_node->pos; - NR::Matrix t = - NR::Matrix (NR::translate(-rot_center)) * - NR::Matrix (NR::rotate(rot)) * - NR::Matrix (NR::translate(rot_center)); + Geom::Matrix t = + Geom::Matrix (Geom::Translate(-rot_center)) * + Geom::Matrix (Geom::Rotate(rot)) * + Geom::Matrix (Geom::Translate(rot_center)); for (GList *l = nodepath->selected; l != NULL; l = l->next) { Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data; @@ -4172,8 +4172,8 @@ static void node_scale_one (Inkscape::NodePath::Node *n, gdouble grow, int which bool both = false; Inkscape::NodePath::NodeSide *me, *other; - double xn = n->n.other? n->n.other->pos[NR::X] : n->pos[NR::X]; - double xp = n->p.other? n->p.other->pos[NR::X] : n->pos[NR::X]; + double xn = n->n.other? n->n.other->pos[Geom::X] : n->pos[Geom::X]; + double xp = n->p.other? n->p.other->pos[Geom::X] : n->pos[Geom::X]; if (!n->n.other) { // if this is an endnode, select its single handle regardless of "which" me = &(n->p); @@ -4264,7 +4264,7 @@ void sp_nodepath_selected_nodes_scale(Inkscape::NodePath::Path *nodepath, gdoubl // scale nodes as an "object": Inkscape::NodePath::Node *n0 = (Inkscape::NodePath::Node *) nodepath->selected->data; - NR::Rect box (n0->pos, n0->pos); // originally includes the first selected node + Geom::Rect box (n0->pos, n0->pos); // originally includes the first selected node for (GList *l = nodepath->selected; l != NULL; l = l->next) { Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data; box.expandTo (n->pos); // contain all selected nodes @@ -4278,10 +4278,10 @@ void sp_nodepath_selected_nodes_scale(Inkscape::NodePath::Path *nodepath, gdoubl else scale_center = Inkscape::NodePath::Path::active_node->pos; - NR::Matrix t = - NR::Matrix (NR::translate(-scale_center)) * - NR::Matrix (NR::scale(scale, scale)) * - NR::Matrix (NR::translate(scale_center)); + Geom::Matrix t = + Geom::Matrix (Geom::Translate(-scale_center)) * + Geom::Matrix (Geom::Scale(scale, scale)) * + Geom::Matrix (Geom::Translate(scale_center)); for (GList *l = nodepath->selected; l != NULL; l = l->next) { Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data; @@ -4322,10 +4322,10 @@ void sp_nodepath_flip (Inkscape::NodePath::Path *nodepath, Geom::Dim2 axis, boos if (!center) { center = box.midpoint(); } - NR::Matrix t = - NR::Matrix (NR::translate(- *center)) * - NR::Matrix ((axis == Geom::X)? NR::scale(-1, 1) : NR::scale(1, -1)) * - NR::Matrix (NR::translate(*center)); + Geom::Matrix t = + Geom::Matrix (Geom::Translate(- *center)) * + Geom::Matrix ((axis == Geom::X)? Geom::Scale(-1, 1) : Geom::Scale(1, -1)) * + Geom::Matrix (Geom::Translate(*center)); for (GList *l = nodepath->selected; l != NULL; l = l->next) { Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data; @@ -4465,7 +4465,7 @@ sp_nodepath_node_new(Inkscape::NodePath::SubPath *sp, Inkscape::NodePath::Node * } else { if (fabs (Inkscape::Util::triangle_area (*pos, *ppos, *npos)) < 1e-2) { // points are (almost) collinear - if (NR::L2(*pos - *ppos) < 1e-6 || NR::L2(*pos - *npos) < 1e-6) { + if (Geom::L2(*pos - *ppos) < 1e-6 || Geom::L2(*pos - *npos) < 1e-6) { // endnode, or a node with a retracted handle n->type = Inkscape::NodePath::NODE_CUSP; } else { @@ -4730,7 +4730,7 @@ static gchar const *sp_node_type_description(Inkscape::NodePath::Node *node) for (int which = -1; which <= 1; which += 2) { Inkscape::NodePath::NodeSide *side = sp_node_get_side(node, which); - if (side->other && NR::L2(side->pos - node->pos) < 1e-6) + if (side->other && Geom::L2(side->pos - node->pos) < 1e-6) retracted ++; if (!side->other) endnode = true; diff --git a/src/nodepath.h b/src/nodepath.h index 551bf7df1..907d47be4 100644 --- a/src/nodepath.h +++ b/src/nodepath.h @@ -19,6 +19,9 @@ #include #include #include +#include <2geom/forward.h> +#include + struct SPCanvasItem; class SPCurve; @@ -61,9 +64,9 @@ class Radial{ */ Radial(Geom::Point const &p) { - r = NR::L2(p); + r = Geom::L2(p); if (r > 0) { - a = NR::atan2 (p); + a = Geom::atan2 (p); } else { a = HUGE_VAL; //undefined } @@ -283,7 +286,7 @@ void sp_nodepath_select_all (Inkscape::NodePath::Path *nodepath, bool invert); void sp_nodepath_select_all_from_subpath(Inkscape::NodePath::Path *nodepath, bool invert); void sp_nodepath_select_next (Inkscape::NodePath::Path *nodepath); void sp_nodepath_select_prev (Inkscape::NodePath::Path *nodepath); -void sp_nodepath_select_rect (Inkscape::NodePath::Path * nodepath, NR::Rect const &b, gboolean incremental); +void sp_nodepath_select_rect (Inkscape::NodePath::Path * nodepath, Geom::Rect const &b, gboolean incremental); GList *save_nodepath_selection (Inkscape::NodePath::Path *nodepath); void restore_nodepath_selection (Inkscape::NodePath::Path *nodepath, GList *r); gboolean nodepath_repr_d_changed (Inkscape::NodePath::Path * np, const char *newd); diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index cfc1fc010..96313ab37 100644 --- a/src/pencil-context.cpp +++ b/src/pencil-context.cpp @@ -634,7 +634,7 @@ fit_and_split(SPPencilContext *pc) g_assert( pc->npoints > 1 ); double const tol = prefs_get_double_attribute_limited("tools.freehand.pencil", "tolerance", 10.0, 1.0, 100.0); - double const tolerance_sq = 0.02 * square( NR::expansion(pc->desktop->w2d()) * tol) + double const tolerance_sq = 0.02 * square( pc->desktop->w2d().descrim() * tol) * exp(0.2*tol - 2); Geom::Point b[4]; diff --git a/src/rubberband.cpp b/src/rubberband.cpp index 97a260f0f..7c43da9ea 100644 --- a/src/rubberband.cpp +++ b/src/rubberband.cpp @@ -18,7 +18,6 @@ #include "rubberband.h" #include "display/canvas-bpath.h" #include "display/curve.h" -#include "libnr/nr-point.h" Inkscape::Rubberband *Inkscape::Rubberband::_instance = NULL; @@ -45,7 +44,7 @@ void Inkscape::Rubberband::delete_canvas_items() } -void Inkscape::Rubberband::start(SPDesktop *d, NR::Point const &p) +void Inkscape::Rubberband::start(SPDesktop *d, Geom::Point const &p) { _points.clear(); _touchpath_curve->reset(); @@ -73,7 +72,7 @@ void Inkscape::Rubberband::stop() sp_canvas_end_forced_full_redraws(_desktop->canvas); } -void Inkscape::Rubberband::move(NR::Point const &p) +void Inkscape::Rubberband::move(Geom::Point const &p) { if (!_started) return; @@ -82,13 +81,13 @@ void Inkscape::Rubberband::move(NR::Point const &p) _desktop->scroll_to_point(p); _touchpath_curve->lineto(p); - NR::Point next = _desktop->d2w(p); + Geom::Point next = _desktop->d2w(p); // we want the points to be at most 0.5 screen pixels apart, // so that we don't lose anything small; // if they are farther apart, we interpolate more points - if (_points.size() > 0 && NR::L2(next-_points.back()) > 0.5) { - NR::Point prev = _points.back(); - int subdiv = 2 * (int) round(NR::L2(next-prev) + 0.5); + if (_points.size() > 0 && Geom::L2(next-_points.back()) > 0.5) { + Geom::Point prev = _points.back(); + int subdiv = 2 * (int) round(Geom::L2(next-prev) + 0.5); for (int i = 1; i <= subdiv; i ++) { _points.push_back(prev + ((double)i/subdiv) * (next - prev)); } @@ -100,7 +99,7 @@ void Inkscape::Rubberband::move(NR::Point const &p) if (_rect == NULL) { _rect = static_cast(sp_canvas_item_new(sp_desktop_controls(_desktop), SP_TYPE_CTRLRECT, NULL)); } - _rect->setRectangle(NR::Rect(_start, _end)); + _rect->setRectangle(Geom::Rect(_start, _end)); sp_canvas_item_show(_rect); if (_touchpath) @@ -125,13 +124,13 @@ void Inkscape::Rubberband::setMode(int mode) _mode = mode; } -boost::optional Inkscape::Rubberband::getRectangle() const +boost::optional Inkscape::Rubberband::getRectangle() const { if (!_started) { - return boost::optional(); + return boost::optional(); } - return NR::Rect(_start, _end); + return Geom::Rect(_start, _end); } Inkscape::Rubberband *Inkscape::Rubberband::get(SPDesktop *desktop) diff --git a/src/rubberband.h b/src/rubberband.h index f9adc7b3b..6da1ddd8d 100644 --- a/src/rubberband.h +++ b/src/rubberband.h @@ -15,10 +15,10 @@ */ #include "forward.h" -#include "libnr/nr-forward.h" -#include "libnr/nr-point.h" #include #include +#include <2geom/point.h> +#include <2geom/rect.h> /* fixme: do multidocument safe */ @@ -38,14 +38,14 @@ class Rubberband { public: - void start(SPDesktop *desktop, NR::Point const &p); - void move(NR::Point const &p); - boost::optional getRectangle() const; + void start(SPDesktop *desktop, Geom::Point const &p); + void move(Geom::Point const &p); + boost::optional getRectangle() const; void stop(); bool is_started(); inline int getMode() {return _mode;} - inline std::vector getPoints() {return _points;} + inline std::vector getPoints() {return _points;} void setMode(int mode); @@ -57,10 +57,10 @@ private: static Rubberband* _instance; SPDesktop *_desktop; - NR::Point _start; - NR::Point _end; + Geom::Point _start; + Geom::Point _end; - std::vector _points; + std::vector _points; CtrlRect *_rect; SPCanvasItem *_touchpath; diff --git a/src/selcue.cpp b/src/selcue.cpp index d8d624e94..418db8e74 100644 --- a/src/selcue.cpp +++ b/src/selcue.cpp @@ -84,7 +84,7 @@ void Inkscape::SelCue::_updateItemBboxes() for (GSList const *l = _selection->itemList(); l != NULL; l = l->next) { SPItem *item = (SPItem *) l->data; - boost::optional const b = sp_item_bbox_desktop(item, bbox_type); + boost::optional const b = to_2geom(sp_item_bbox_desktop(item, bbox_type)); SPCanvasItem* box = NULL; diff --git a/src/select-context.cpp b/src/select-context.cpp index acbeb2c18..374bf0810 100644 --- a/src/select-context.cpp +++ b/src/select-context.cpp @@ -594,7 +594,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) // this was a rubberband drag GSList *items = NULL; if (r->getMode() == RUBBERBAND_MODE_RECT) { - boost::optional const b = r->getRectangle(); + boost::optional const b = r->getRectangle(); items = sp_document_items_in_box(sp_desktop_document(desktop), desktop->dkey, *b); } else if (r->getMode() == RUBBERBAND_MODE_TOUCHPATH) { items = sp_document_items_at_points(sp_desktop_document(desktop), desktop->dkey, r->getPoints()); diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 6bc1c54d3..5e089a87a 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -153,7 +153,7 @@ GSList *sp_selection_paste_impl (SPDocument *doc, SPObject *parent, GSList **cli NR::Matrix local (sp_item_i2doc_affine(SP_ITEM(parent))); if (!local.test_identity()) { gchar const *t_str = copy->attribute("transform"); - Geom::Matrix item_t (NR::identity()); + Geom::Matrix item_t (Geom::identity()); if (t_str) sp_svg_transform_read(t_str, &item_t); item_t *= local.inverse(); @@ -492,7 +492,7 @@ void sp_selection_group(SPDesktop *desktop) // At this point, current may already have no item, due to its being a clone whose original is already moved away // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform gchar const *t_str = current->attribute("transform"); - Geom::Matrix item_t (NR::identity()); + Geom::Matrix item_t (Geom::identity()); if (t_str) sp_svg_transform_read(t_str, &item_t); item_t *= sp_item_i2doc_affine(SP_ITEM(doc->getObjectByRepr(current->parent()))); @@ -899,7 +899,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 = to_2geom(sp_item_i2doc_affine(item)).descrim(); if (ex != 1.0) { css = sp_css_attr_scale (css, ex); } @@ -1219,32 +1219,34 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix cons 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 * from_2geom(matrix_to_desktop (matrix_from_desktop (affine, item), item)) * parent_transform.inverse(); - NR::Matrix t_inv =parent_transform * from_2geom(matrix_to_desktop (matrix_from_desktop (affine.inverse(), item), item)) * parent_transform.inverse(); - NR::Matrix result = t_inv * item->transform * t; + Geom::Matrix parent_transform = sp_item_i2root_affine(SP_ITEM(SP_OBJECT_PARENT (item))); + Geom::Matrix t = parent_transform * matrix_to_desktop (matrix_from_desktop (affine, item), item) * parent_transform.inverse(); + NR::Matrix t_nr = from_2geom(t); + Geom::Matrix t_inv =parent_transform * matrix_to_desktop (matrix_from_desktop (affine.inverse(), item), item) * parent_transform.inverse(); + Geom::Matrix result = t_inv * item->transform * t; if ((prefs_parallel || prefs_unmoved) && affine.isTranslation()) { // we need to cancel out the move compensation, too // find out the clone move, same as in sp_use_move_compensate - NR::Matrix parent = sp_use_get_parent_transform (SP_USE(item)); - NR::Matrix clone_move = parent.inverse() * t * parent; + Geom::Matrix parent = sp_use_get_parent_transform (SP_USE(item)); + Geom::Matrix clone_move = parent.inverse() * t * parent; if (prefs_parallel) { - NR::Matrix move = result * clone_move * t_inv; - sp_item_write_transform(item, SP_OBJECT_REPR(item), move, &move); + Geom::Matrix move = result * clone_move * t_inv; + NR::Matrix move_nr = from_2geom(move); + sp_item_write_transform(item, SP_OBJECT_REPR(item), from_2geom(move), &move_nr); } else if (prefs_unmoved) { //if (SP_IS_USE(sp_use_get_original(SP_USE(item)))) // clone_move = NR::identity(); - NR::Matrix move = result * clone_move; - sp_item_write_transform(item, SP_OBJECT_REPR(item), move, &t); + Geom::Matrix move = result * clone_move; + sp_item_write_transform(item, SP_OBJECT_REPR(item), from_2geom(move), &t_nr); } } else { // just apply the result - sp_item_write_transform(item, SP_OBJECT_REPR(item), result, &t); + sp_item_write_transform(item, SP_OBJECT_REPR(item), result, &t_nr); } } else { @@ -1802,15 +1804,15 @@ SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root, */ void scroll_to_show_item(SPDesktop *desktop, SPItem *item) { - NR::Rect dbox = desktop->get_display_area(); - boost::optional sbox = sp_item_bbox_desktop(item); + Geom::Rect dbox = desktop->get_display_area(); + boost::optional sbox = to_2geom(sp_item_bbox_desktop(item)); if ( sbox && dbox.contains(*sbox) == false ) { - NR::Point const s_dt = sbox->midpoint(); - NR::Point const s_w = desktop->d2w(s_dt); - NR::Point const d_dt = dbox.midpoint(); - NR::Point const d_w = desktop->d2w(d_dt); - NR::Point const moved_w( d_w - s_w ); + Geom::Point const s_dt = sbox->midpoint(); + Geom::Point const s_w = desktop->d2w(s_dt); + Geom::Point const d_dt = dbox.midpoint(); + Geom::Point const d_w = desktop->d2w(d_dt); + Geom::Point const moved_w( d_w - s_w ); gint const dx = (gint) moved_w[X]; gint const dy = (gint) moved_w[Y]; desktop->scroll_world(dx, dy); @@ -2083,9 +2085,9 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) } // calculate the transform to be applied to objects to move them to 0,0 - NR::Point move_p = NR::Point(0, sp_document_height(doc)) - *c; - move_p[NR::Y] = -move_p[NR::Y]; - NR::Matrix move = NR::Matrix (NR::translate (move_p)); + Geom::Point move_p = Geom::Point(0, sp_document_height(doc)) - *c; + move_p[Geom::Y] = -move_p[Geom::Y]; + Geom::Matrix move = Geom::Matrix (Geom::Translate (move_p)); GSList *items = g_slist_copy((GSList *) selection->itemList()); @@ -2094,7 +2096,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) // bottommost object, after sorting SPObject *parent = SP_OBJECT_PARENT (items->data); - NR::Matrix parent_transform (sp_item_i2root_affine(SP_ITEM(parent))); + Geom::Matrix parent_transform (sp_item_i2root_affine(SP_ITEM(parent))); // remember the position of the first item gint pos = SP_OBJECT_REPR (items->data)->position(); @@ -2125,8 +2127,9 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) prefs->setInt("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED); gchar const *mark_id = generate_marker(repr_copies, bounds, doc, - ( NR::Matrix(NR::translate(desktop->dt2doc(NR::Point(r->min()[NR::X], - r->max()[NR::Y])))) + ( Geom::Matrix(Geom::Translate(desktop->dt2doc( + Geom::Point(r->min()[Geom::X], + r->max()[Geom::Y])))) * parent_transform.inverse() ), parent_transform * move); (void)mark_id; @@ -2326,7 +2329,7 @@ sp_selection_untile(SPDesktop *desktop) SPPattern *pattern = pattern_getroot (SP_PATTERN (server)); - NR::Matrix pat_transform = pattern_patternTransform (SP_PATTERN (server)); + Geom::Matrix pat_transform = to_2geom(pattern_patternTransform (SP_PATTERN (server))); pat_transform *= item->transform; for (SPObject *child = sp_object_first_child(SP_OBJECT(pattern)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) { @@ -2339,7 +2342,7 @@ sp_selection_untile(SPDesktop *desktop) // this is needed to make sure the new item has curve (simply requestDisplayUpdate does not work) sp_document_ensure_up_to_date (doc); - NR::Matrix transform( i->transform * pat_transform ); + Geom::Matrix transform( i->transform * pat_transform ); sp_item_write_transform(i, SP_OBJECT_REPR(i), transform); new_select = g_slist_prepend(new_select, i); @@ -2858,7 +2861,7 @@ fit_canvas_to_selection(SPDesktop *desktop) desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select object(s) to fit canvas to.")); return false; } - boost::optional const bbox(desktop->selection->bounds()); + boost::optional const bbox(to_2geom(desktop->selection->bounds())); if (bbox && !bbox->isEmpty()) { doc->fitToRect(*bbox); return true; @@ -2886,7 +2889,7 @@ fit_canvas_to_drawing(SPDocument *doc) sp_document_ensure_up_to_date(doc); SPItem const *const root = SP_ITEM(doc->root); - boost::optional const bbox(root->getBounds(sp_item_i2r_affine(root))); + boost::optional const bbox(to_2geom(root->getBounds(sp_item_i2r_affine(root)))); if (bbox && !bbox->isEmpty()) { doc->fitToRect(*bbox); return true; diff --git a/src/seltrans.cpp b/src/seltrans.cpp index d5e6afd8a..f5572796d 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -525,7 +525,7 @@ void Inkscape::SelTrans::stamp() SPItem *copy_item = (SPItem *) sp_desktop_document(_desktop)->getObjectByRepr(copy_repr); - NR::Matrix const *new_affine; + Geom::Matrix const *new_affine; if (_show == SHOW_OUTLINE) { NR::Matrix const i2d(sp_item_i2d_affine(original_item)); NR::Matrix const i2dnew( i2d * _current_relative_affine ); @@ -902,7 +902,7 @@ gboolean Inkscape::SelTrans::scaleRequest(NR::Point &pt, guint state) NR::Point pt_geom = _getGeomHandlePos(pt); NR::scale geom_scale = calcScaleFactors(_point_geom, pt_geom, _origin_for_specpoints); - _absolute_affine = NR::identity(); //Initialize the scaler + _absolute_affine = Geom::identity(); //Initialize the scaler if (state & GDK_MOD1_MASK) { // scale by an integer multiplier/divider // We're scaling either the visual or the geometric bbox here (see the comment above) @@ -1017,7 +1017,7 @@ gboolean Inkscape::SelTrans::stretchRequest(SPSelTransHandle const &handle, NR:: NR::scale geom_scale = calcScaleFactors(_point_geom, pt_geom, _origin_for_specpoints); geom_scale[perp] = 1; - _absolute_affine = NR::identity(); //Initialize the scaler + _absolute_affine = Geom::identity(); //Initialize the scaler if (state & GDK_MOD1_MASK) { // stretch by an integer multiplier/divider if (fabs(default_scale[axis]) > 1) { @@ -1184,7 +1184,7 @@ gboolean Inkscape::SelTrans::skewRequest(SPSelTransHandle const &handle, NR::Poi pt[dim_a] = initial_delta[dim_a] * scale[dim_a] + _origin[dim_a]; // Calculate the relative affine - _relative_affine = NR::identity(); + _relative_affine = Geom::identity(); _relative_affine[2*dim_a + dim_a] = (pt[dim_a] - _origin[dim_a]) / initial_delta[dim_a]; _relative_affine[2*dim_a + (dim_b)] = (pt[dim_b] - _point[dim_b]) / initial_delta[dim_a]; _relative_affine[2*(dim_b) + (dim_a)] = 0; diff --git a/src/shape-editor.cpp b/src/shape-editor.cpp index 6cf1182ee..4fe1130bc 100644 --- a/src/shape-editor.cpp +++ b/src/shape-editor.cpp @@ -381,10 +381,10 @@ bool ShapeEditor::is_over_stroke (Geom::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)) + to_2geom(sp_item_i2d_affine(item)).descrim() : 0.0) - + prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100)) /NR::expansion(sp_item_i2d_affine(item)); - bool close = (NR::L2 (delta) < stroke_tolerance); + + prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100)) / to_2geom(sp_item_i2d_affine(item)).descrim(); + bool close = (Geom::L2 (delta) < stroke_tolerance); if (remember && close) { // calculate index for nodepath's representation. @@ -475,7 +475,7 @@ void ShapeEditor::finish_drag() { } } -void ShapeEditor::select_rect(NR::Rect const &rect, bool add) { +void ShapeEditor::select_rect(Geom::Rect const &rect, bool add) { if (this->nodepath) { sp_nodepath_select_rect(this->nodepath, rect, add); } diff --git a/src/shape-editor.h b/src/shape-editor.h index 9ce64355f..8780586c4 100644 --- a/src/shape-editor.h +++ b/src/shape-editor.h @@ -75,7 +75,7 @@ public: void finish_drag (); - void select_rect (NR::Rect const &rect, bool add); + void select_rect (Geom::Rect const &rect, bool add); bool has_selection (); void deselect (); diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index 5c3ff8a95..ec60251fc 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -47,7 +47,7 @@ static Inkscape::XML::Node *sp_flowtext_write(SPObject *object, Inkscape::XML::D static void sp_flowtext_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr); static void sp_flowtext_set(SPObject *object, unsigned key, gchar const *value); -static void sp_flowtext_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags); +static void sp_flowtext_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); static void sp_flowtext_print(SPItem *item, SPPrintContext *ctx); static gchar *sp_flowtext_description(SPItem *item); static NRArenaItem *sp_flowtext_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags); @@ -176,7 +176,7 @@ sp_flowtext_update(SPObject *object, SPCtx *ctx, unsigned flags) group->rebuildLayout(); NRRect paintbox; - sp_item_invoke_bbox(group, &paintbox, NR::identity(), TRUE); + sp_item_invoke_bbox(group, &paintbox, Geom::identity(), TRUE); for (SPItemView *v = group->display; v != NULL; v = v->next) { group->_clearFlow(NR_ARENA_GROUP(v->arenaitem)); nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object)); @@ -198,7 +198,7 @@ sp_flowtext_modified(SPObject *object, guint flags) if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG )) { SPFlowtext *text = SP_FLOWTEXT(object); NRRect paintbox; - sp_item_invoke_bbox(text, &paintbox, NR::identity(), TRUE); + sp_item_invoke_bbox(text, &paintbox, Geom::identity(), TRUE); for (SPItemView* v = text->display; v != NULL; v = v->next) { text->_clearFlow(NR_ARENA_GROUP(v->arenaitem)); nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object)); @@ -323,7 +323,7 @@ sp_flowtext_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape:: } static void -sp_flowtext_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const /*flags*/) +sp_flowtext_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const /*flags*/) { SPFlowtext *group = SP_FLOWTEXT(item); group->layout.getBoundingBox(bbox, transform); @@ -331,7 +331,7 @@ sp_flowtext_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, // Add stroke width SPStyle* style=SP_OBJECT_STYLE (item); if ( !style->stroke.isNone() ) { - double const scale = expansion(transform); + double const scale = transform.descrim(); if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord double const width = MAX(0.125, style->stroke_width.computed * scale); if ( fabs(bbox->x1 - bbox->x0) > -0.00001 && fabs(bbox->y1 - bbox->y0) > -0.00001 ) { @@ -350,7 +350,7 @@ sp_flowtext_print(SPItem *item, SPPrintContext *ctx) SPFlowtext *group = SP_FLOWTEXT(item); NRRect pbox; - sp_item_invoke_bbox(item, &pbox, NR::identity(), TRUE); + sp_item_invoke_bbox(item, &pbox, Geom::identity(), TRUE); NRRect bbox; boost::optional bbox_maybe = sp_item_bbox_desktop(item); if (!bbox_maybe) { @@ -390,7 +390,7 @@ sp_flowtext_show(SPItem *item, NRArena *arena, unsigned/* key*/, unsigned /*flag // pass the bbox of the flowtext object as paintbox (used for paintserver fills) NRRect paintbox; - sp_item_invoke_bbox(item, &paintbox, NR::identity(), TRUE); + sp_item_invoke_bbox(item, &paintbox, Geom::identity(), TRUE); group->layout.show(flowed, &paintbox); return flowed; @@ -556,7 +556,7 @@ SPFlowtext::getAsText() // set x,y attributes only when we need to bool set_x = false; bool set_y = false; - if (!item->transform.test_identity()) { + if (!item->transform.isIdentity()) { set_x = set_y = true; } else { Inkscape::Text::Layout::iterator it_chunk_start = it; diff --git a/src/sp-image.cpp b/src/sp-image.cpp index f49812ac7..a3112bd03 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -71,7 +71,7 @@ static void sp_image_set (SPObject *object, unsigned int key, const gchar *value static void sp_image_update (SPObject *object, SPCtx *ctx, unsigned int flags); static Inkscape::XML::Node *sp_image_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static void sp_image_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags); +static void sp_image_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); static void sp_image_print (SPItem * item, SPPrintContext *ctx); static gchar * sp_image_description (SPItem * item); static void sp_image_snappoints(SPItem const *item, SnapPointsIter p); @@ -1033,7 +1033,7 @@ sp_image_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XM } static void -sp_image_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const /*flags*/) +sp_image_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const /*flags*/) { SPImage const &image = *SP_IMAGE(item); @@ -1043,10 +1043,10 @@ sp_image_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, uns double const x1 = x0 + image.width.computed; double const y1 = y0 + image.height.computed; - nr_rect_union_pt(bbox, NR::Point(x0, y0) * transform); - nr_rect_union_pt(bbox, NR::Point(x1, y0) * transform); - nr_rect_union_pt(bbox, NR::Point(x1, y1) * transform); - nr_rect_union_pt(bbox, NR::Point(x0, y1) * transform); + nr_rect_union_pt(bbox, Geom::Point(x0, y0) * transform); + nr_rect_union_pt(bbox, Geom::Point(x1, y0) * transform); + nr_rect_union_pt(bbox, Geom::Point(x1, y1) * transform); + nr_rect_union_pt(bbox, Geom::Point(x0, y1) * transform); } } diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 3d717e669..123fe7330 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -63,7 +63,7 @@ static void sp_group_modified (SPObject *object, guint flags); static Inkscape::XML::Node *sp_group_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static void sp_group_set(SPObject *object, unsigned key, char const *value); -static void sp_group_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags); +static void sp_group_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); static void sp_group_print (SPItem * item, SPPrintContext *ctx); static gchar * sp_group_description (SPItem * item); static NR::Matrix sp_group_set_transform(SPItem *item, NR::Matrix const &xform); @@ -274,7 +274,7 @@ sp_group_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XM } static void -sp_group_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags) +sp_group_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags) { SP_GROUP(item)->group->calculateBBox(bbox, transform, flags); } @@ -422,8 +422,8 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) Inkscape::XML::Node *nrepr = SP_OBJECT_REPR (child)->duplicate(prepr->document()); // Merging transform - NR::Matrix ctrans; - NR::Matrix const g(gitem->transform); + Geom::Matrix ctrans; + Geom::Matrix const g(gitem->transform); if (SP_IS_USE(citem) && sp_use_get_original (SP_USE(citem)) && SP_OBJECT_PARENT (sp_use_get_original (SP_USE(citem))) == SP_OBJECT(group)) { // make sure a clone's effective transform is the same as was under group @@ -700,7 +700,7 @@ void CGroup::onModified(guint flags) { } } -void CGroup::calculateBBox(NRRect *bbox, NR::Matrix const &transform, unsigned const flags) { +void CGroup::calculateBBox(NRRect *bbox, Geom::Matrix const &transform, unsigned const flags) { boost::optional dummy_bbox; @@ -709,7 +709,7 @@ void CGroup::calculateBBox(NRRect *bbox, NR::Matrix const &transform, unsigned c SPObject *o = SP_OBJECT (l->data); if (SP_IS_ITEM(o) && !SP_ITEM(o)->isHidden()) { SPItem *child = SP_ITEM(o); - NR::Matrix const ct(child->transform * transform); + Geom::Matrix const ct(to_2geom(child->transform) * transform); sp_item_invoke_bbox_full(child, dummy_bbox, ct, flags, FALSE); } l = g_slist_remove (l, o); diff --git a/src/sp-item-group.h b/src/sp-item-group.h index 46676194c..1cf4e9912 100644 --- a/src/sp-item-group.h +++ b/src/sp-item-group.h @@ -24,8 +24,6 @@ class CGroup; -namespace NR{ struct translate; } - struct SPGroup : public SPLPEItem { enum LayerMode { GROUP, LAYER }; @@ -69,7 +67,7 @@ public: virtual void onChildRemoved(Inkscape::XML::Node *child); virtual void onUpdate(SPCtx *ctx, unsigned int flags); virtual void onModified(guint flags); - virtual void calculateBBox(NRRect *bbox, NR::Matrix const &transform, unsigned const flags); + virtual void calculateBBox(NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); virtual void onPrint(SPPrintContext *ctx); virtual void onOrderChanged(Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref); virtual gchar *getDescription(); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index cc106e8f7..b412353e1 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -997,7 +997,7 @@ sp_item_invoke_print(SPItem *item, SPPrintContext *ctx) { if (!item->isHidden()) { if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->print) { - if (!item->transform.test_identity() + if (!item->transform.isIdentity() || SP_OBJECT_STYLE(item)->opacity.value != SP_SCALE24_MAX) { sp_print_bind(ctx, item->transform, SP_SCALE24_TO_FLOAT(SP_OBJECT_STYLE(item)->opacity.value)); diff --git a/src/sp-item.h b/src/sp-item.h index e52dbf974..76e07e88e 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -84,11 +84,11 @@ class SPItemCtx; struct SPItemCtx { SPCtx ctx; /** Item to document transformation */ - NR::Matrix i2doc; + Geom::Matrix i2doc; /** Viewport size */ NRRect vp; /** Item to viewport transformation */ - NR::Matrix i2vp; + Geom::Matrix i2vp; }; /** Abstract base class for all visible shapes. */ @@ -107,7 +107,7 @@ struct SPItem : public SPObject { double transform_center_x; double transform_center_y; - NR::Matrix transform; + Geom::Matrix transform; SPClipPathReference *clip_ref; SPMaskReference *mask_ref; @@ -180,7 +180,7 @@ struct SPItemClass { SPObjectClass parent_class; /** BBox union in given coordinate system */ - void (* bbox) (SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags); + void (* bbox) (SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); /** Printing method. Assumes ctm is set to item affine matrix */ /* \todo Think about it, and maybe implement generic export method instead (Lauris) */ diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 7783c334d..006e3a140 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -759,7 +759,7 @@ void sp_namedview_window_from_document(SPDesktop *desktop) desktop->setWindowSize(w, h); } if (x>0 && y>0) { - desktop->setWindowPosition(NR::Point(x, y)); + desktop->setWindowPosition(Geom::Point(x, y)); } } @@ -813,15 +813,15 @@ void sp_namedview_document_from_window(SPDesktop *desktop) gint save_geometry_in_file = (1==prefs_get_int_attribute("options.savewindowgeometry", "value", 0)); Inkscape::XML::Node *view = SP_OBJECT_REPR(desktop->namedview); - NR::Rect const r = desktop->get_display_area(); + Geom::Rect const r = desktop->get_display_area(); // saving window geometry is not undoable bool saved = sp_document_get_undo_sensitive(sp_desktop_document(desktop)); sp_document_set_undo_sensitive(sp_desktop_document(desktop), false); sp_repr_set_svg_double(view, "inkscape:zoom", desktop->current_zoom()); - sp_repr_set_svg_double(view, "inkscape:cx", r.midpoint()[NR::X]); - sp_repr_set_svg_double(view, "inkscape:cy", r.midpoint()[NR::Y]); + sp_repr_set_svg_double(view, "inkscape:cx", r.midpoint()[Geom::X]); + sp_repr_set_svg_double(view, "inkscape:cy", r.midpoint()[Geom::Y]); if (save_geometry_in_file) { gint w, h, x, y; @@ -1061,7 +1061,7 @@ Inkscape::CanvasGrid * sp_namedview_get_first_enabled_grid(SPNamedView *namedvie return NULL; } -void SPNamedView::translateGuides(NR::translate const &tr) { +void SPNamedView::translateGuides(Geom::Translate const &tr) { for (GSList *l = guides; l != NULL; l = l->next) { SPGuide &guide = *SP_GUIDE(l->data); Geom::Point point_on_line = guide.point_on_line; diff --git a/src/sp-namedview.h b/src/sp-namedview.h index cfc57d1c4..3ed02bf59 100644 --- a/src/sp-namedview.h +++ b/src/sp-namedview.h @@ -21,7 +21,6 @@ #include "helper/helper-forward.h" #include "sp-object-group.h" -#include "libnr/nr-point.h" #include "sp-metric.h" #include "snap.h" @@ -88,7 +87,7 @@ struct SPNamedView : public SPObjectGroup { GSList const *getViewList() const; SPMetric getDefaultMetric() const; - void translateGuides(NR::translate const &translation); + void translateGuides(Geom::Translate const &translation); void scrollAllDesktops(double dx, double dy, bool is_scrolling); }; diff --git a/src/sp-root.cpp b/src/sp-root.cpp index 0ff3b48b6..80c04c59f 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -51,7 +51,7 @@ static void sp_root_modified(SPObject *object, guint flags); static Inkscape::XML::Node *sp_root_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static NRArenaItem *sp_root_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); -static void sp_root_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags); +static void sp_root_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); static void sp_root_print(SPItem *item, SPPrintContext *ctx); static SPGroupClass *parent_class; @@ -131,7 +131,7 @@ sp_root_init(SPRoot *root) /* root->viewbox.set_identity(); */ root->viewBox_set = FALSE; - root->c2p.set_identity(); + root->c2p.setIdentity(); root->defs = NULL; } @@ -434,7 +434,7 @@ sp_root_update(SPObject *object, SPCtx *ctx, guint flags) SPItemCtx rctx = *ictx; /* Calculate child to parent transformation */ - root->c2p.set_identity(); + root->c2p.setIdentity(); if (object->parent) { /* @@ -444,8 +444,8 @@ sp_root_update(SPObject *object, SPCtx *ctx, guint flags) * fixme: height seems natural, as this makes the inner svg element * fixme: self-contained. The spec is vague here. */ - root->c2p = NR::Matrix(NR::translate(root->x.computed, - root->y.computed)); + root->c2p = Geom::Matrix(Geom::Translate(root->x.computed, + root->y.computed)); } if (root->viewBox_set) { @@ -512,17 +512,17 @@ sp_root_update(SPObject *object, SPCtx *ctx, guint flags) } /* Compose additional transformation from scale and position */ - NR::Point const viewBox_min(root->viewBox.x0, + Geom::Point const viewBox_min(root->viewBox.x0, root->viewBox.y0); - NR::Point const viewBox_max(root->viewBox.x1, + Geom::Point const viewBox_max(root->viewBox.x1, root->viewBox.y1); - NR::scale const viewBox_length( viewBox_max - viewBox_min ); - NR::scale const new_length(width, height); + Geom::Scale const viewBox_length( viewBox_max - viewBox_min ); + Geom::Scale const new_length(width, height); /* Append viewbox transformation */ /* TODO: The below looks suspicious to me (pjrm): I wonder whether the RHS expression should have c2p at the beginning rather than at the end. Test it. */ - root->c2p = NR::translate(-viewBox_min) * ( new_length / viewBox_length ) * NR::translate(x, y) * root->c2p; + root->c2p = Geom::Translate(-viewBox_min) * ( new_length * viewBox_length.inverse() ) * Geom::Translate(x, y) * root->c2p; } rctx.i2doc = root->c2p * rctx.i2doc; @@ -644,12 +644,12 @@ sp_root_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags) * Virtual bbox callback. */ static void -sp_root_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags) +sp_root_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags) { SPRoot const *root = SP_ROOT(item); if (((SPItemClass *) (parent_class))->bbox) { - NR::Matrix const product( root->c2p * transform ); + Geom::Matrix const product( to_2geom(root->c2p) * transform ); ((SPItemClass *) (parent_class))->bbox(item, bbox, product, flags); diff --git a/src/sp-root.h b/src/sp-root.h index c298223f1..655bc3caf 100644 --- a/src/sp-root.h +++ b/src/sp-root.h @@ -20,7 +20,6 @@ #define SP_IS_ROOT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_ROOT)) #define SP_IS_ROOT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_ROOT)) -#include #include "version.h" #include "svg/svg-length.h" #include "enums.h" @@ -49,7 +48,7 @@ struct SPRoot : public SPGroup { unsigned int aspect_clip : 1; /** Child to parent additional transform. */ - NR::Matrix c2p; + Geom::Matrix c2p; gchar *onload; diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index e22f8b785..fbb9a60f6 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -63,7 +63,7 @@ static void sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags); static void sp_shape_modified (SPObject *object, unsigned int flags); static Inkscape::XML::Node *sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static void sp_shape_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags); +static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); void sp_shape_print (SPItem * item, SPPrintContext * ctx); static NRArenaItem *sp_shape_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); static void sp_shape_hide (SPItem *item, unsigned int key); @@ -484,7 +484,7 @@ sp_shape_modified (SPObject *object, unsigned int flags) * Calculates the bounding box for item, storing it into bbox. * This also includes the bounding boxes of any markers included in the shape. */ -static void sp_shape_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags) +static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags) { SPShape const *shape = SP_SHAPE (item); @@ -502,7 +502,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &tr SPStyle* style=SP_OBJECT_STYLE (item); if (!style->stroke.isNone()) { - double const scale = expansion(transform); + double const scale = transform.descrim(); if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord double const width = MAX(0.125, style->stroke_width.computed * scale); if ( fabs(cbbox.x1-cbbox.x0) > -0.00001 && fabs(cbbox.y1-cbbox.y0) > -0.00001 ) { @@ -523,10 +523,10 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &tr SPMarker* marker = SP_MARKER (shape->marker[SP_MARKER_LOC_START]); SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (shape->marker[SP_MARKER_LOC_START])); - NR::Matrix tr(sp_shape_marker_get_transform_at_start(path_it->front())); + Geom::Matrix tr(sp_shape_marker_get_transform_at_start(path_it->front())); if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = NR::scale(style->stroke_width.computed) * tr; + tr = Geom::Scale(style->stroke_width.computed) * tr; } // total marker transform @@ -534,7 +534,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &tr // get bbox of the marker with that transform NRRect marker_bbox; - sp_item_invoke_bbox (marker_item, &marker_bbox, tr, true); + sp_item_invoke_bbox (marker_item, &marker_bbox, from_2geom(tr), true); // union it with the shape bbox nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); } @@ -551,10 +551,10 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &tr SPMarker* marker = SP_MARKER (shape->marker[SP_MARKER_LOC_MID]); SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (shape->marker[SP_MARKER_LOC_MID])); - NR::Matrix tr(sp_shape_marker_get_transform(*curve_it1, *curve_it2)); + Geom::Matrix tr(sp_shape_marker_get_transform(*curve_it1, *curve_it2)); if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = NR::scale(style->stroke_width.computed) * tr; + tr = Geom::Scale(style->stroke_width.computed) * tr; } // total marker transform @@ -562,7 +562,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &tr // get bbox of the marker with that transform NRRect marker_bbox; - sp_item_invoke_bbox (marker_item, &marker_bbox, tr, true); + sp_item_invoke_bbox (marker_item, &marker_bbox, from_2geom(tr), true); // union it with the shape bbox nr_rect_d_union (&cbbox, &cbbox, &marker_bbox); @@ -583,10 +583,10 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &tr } Geom::Curve const &lastcurve = (*path_it)[index]; - NR::Matrix tr = sp_shape_marker_get_transform_at_end(lastcurve); + Geom::Matrix tr = sp_shape_marker_get_transform_at_end(lastcurve); if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = NR::scale(style->stroke_width.computed) * tr; + tr = Geom::Scale(style->stroke_width.computed) * tr; } // total marker transform @@ -656,10 +656,10 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) SPMarker* marker = SP_MARKER (shape->marker[SP_MARKER_LOC_START]); SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (shape->marker[SP_MARKER_LOC_START])); - NR::Matrix tr(sp_shape_marker_get_transform_at_start(path_it->front())); + Geom::Matrix tr(sp_shape_marker_get_transform_at_start(path_it->front())); if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = NR::scale(style->stroke_width.computed) * tr; + tr = Geom::Scale(style->stroke_width.computed) * tr; } tr = marker_item->transform * marker->c2p * tr; @@ -682,10 +682,10 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) SPMarker* marker = SP_MARKER (shape->marker[SP_MARKER_LOC_MID]); SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (shape->marker[SP_MARKER_LOC_MID])); - NR::Matrix tr(sp_shape_marker_get_transform(*curve_it1, *curve_it2)); + Geom::Matrix tr(sp_shape_marker_get_transform(*curve_it1, *curve_it2)); if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = NR::scale(style->stroke_width.computed) * tr; + tr = Geom::Scale(style->stroke_width.computed) * tr; } tr = marker_item->transform * marker->c2p * tr; @@ -712,10 +712,10 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) } Geom::Curve const &lastcurve = (*path_it)[index]; - NR::Matrix tr = sp_shape_marker_get_transform_at_end(lastcurve); + Geom::Matrix tr = sp_shape_marker_get_transform_at_end(lastcurve); if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - tr = NR::scale(style->stroke_width.computed) * tr; + tr = Geom::Scale(style->stroke_width.computed) * tr; } tr = marker_item->transform * marker->c2p * tr; diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 064c43442..06f8bfb49 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -40,7 +40,7 @@ static Inkscape::XML::Node *sp_symbol_write (SPObject *object, Inkscape::XML::Do static NRArenaItem *sp_symbol_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags); static void sp_symbol_hide (SPItem *item, unsigned int key); -static void sp_symbol_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags); +static void sp_symbol_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); static void sp_symbol_print (SPItem *item, SPPrintContext *ctx); static SPGroupClass *parent_class; @@ -441,7 +441,7 @@ sp_symbol_hide (SPItem *item, unsigned int key) } static void -sp_symbol_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags) +sp_symbol_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags) { SPSymbol const *symbol = SP_SYMBOL(item); @@ -449,7 +449,7 @@ sp_symbol_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, un /* Cloned is actually renderable */ if (((SPItemClass *) (parent_class))->bbox) { - Geom::Matrix const a( symbol->c2p * (Geom::Matrix)transform ); + Geom::Matrix const a( symbol->c2p * transform ); ((SPItemClass *) (parent_class))->bbox(item, bbox, a, flags); } } diff --git a/src/sp-text.cpp b/src/sp-text.cpp index fcfb84968..754cc24f9 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -69,7 +69,7 @@ static void sp_text_update (SPObject *object, SPCtx *ctx, guint flags); static void sp_text_modified (SPObject *object, guint flags); static Inkscape::XML::Node *sp_text_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static void sp_text_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags); +static void sp_text_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); static NRArenaItem *sp_text_show (SPItem *item, NRArena *arena, unsigned key, unsigned flags); static void sp_text_hide (SPItem *item, unsigned key); static char *sp_text_description (SPItem *item); @@ -353,14 +353,14 @@ sp_text_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML } static void -sp_text_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const /*flags*/) +sp_text_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const /*flags*/) { SP_TEXT(item)->layout.getBoundingBox(bbox, transform); // Add stroke width SPStyle* style=SP_OBJECT_STYLE (item); if (!style->stroke.isNone()) { - double const scale = expansion(transform); + double const scale = transform.descrim(); if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord double const width = MAX(0.125, style->stroke_width.computed * scale); if ( fabs(bbox->x1 - bbox->x0) > -0.00001 && fabs(bbox->y1 - bbox->y0) > -0.00001 ) { diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index ad85b4d85..00244c122 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -65,7 +65,7 @@ static void sp_tref_update(SPObject *object, SPCtx *ctx, guint flags); static void sp_tref_modified(SPObject *object, guint flags); static Inkscape::XML::Node *sp_tref_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); -static void sp_tref_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags); +static void sp_tref_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); static gchar *sp_tref_description(SPItem *item); static void sp_tref_href_changed(SPObject *old_ref, SPObject *ref, SPTRef *tref); @@ -320,7 +320,7 @@ sp_tref_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML: * The code for this function is swiped from the tspan bbox code, since tref should work pretty much the same way */ static void -sp_tref_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const /*flags*/) +sp_tref_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const /*flags*/) { // find out the ancestor text which holds our layout SPObject *parent_text = SP_OBJECT(item); @@ -334,7 +334,7 @@ sp_tref_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsi // Add stroke width SPStyle* style=SP_OBJECT_STYLE (item); if (!style->stroke.isNone()) { - double const scale = expansion(transform); + double const scale = transform.descrim(); if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord double const width = MAX(0.125, style->stroke_width.computed * scale); if ( fabs(bbox->x1 - bbox->x0) > -0.00001 && fabs(bbox->y1 - bbox->y0) > -0.00001 ) { diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index c86c852d7..2496fc6e0 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -57,7 +57,7 @@ static void sp_tspan_release(SPObject *object); static void sp_tspan_set(SPObject *object, unsigned key, gchar const *value); static void sp_tspan_update(SPObject *object, SPCtx *ctx, guint flags); static void sp_tspan_modified(SPObject *object, unsigned flags); -static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags); +static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags); static Inkscape::XML::Node *sp_tspan_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags); static char *sp_tspan_description (SPItem *item); @@ -203,7 +203,7 @@ sp_tspan_modified(SPObject *object, unsigned flags) } } -static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const /*flags*/) +static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const /*flags*/) { // find out the ancestor text which holds our layout SPObject *parent_text = SP_OBJECT(item); @@ -216,7 +216,7 @@ static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &tr // Add stroke width SPStyle* style=SP_OBJECT_STYLE (item); if (!style->stroke.isNone()) { - double const scale = expansion(transform); + double const scale = transform.descrim(); if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord double const width = MAX(0.125, style->stroke_width.computed * scale); if ( fabs(bbox->x1 - bbox->x0) > -0.00001 && fabs(bbox->y1 - bbox->y0) > -0.00001 ) { diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 50b657728..213f827ef 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -51,7 +51,7 @@ static Inkscape::XML::Node *sp_use_write(SPObject *object, Inkscape::XML::Docume 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, NR::Matrix const &transform, unsigned const 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_print(SPItem *item, SPPrintContext *ctx); static gchar *sp_use_description(SPItem *item); @@ -269,15 +269,15 @@ sp_use_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML:: } static void -sp_use_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags) +sp_use_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags) { SPUse const *use = SP_USE(item); if (use->child && SP_IS_ITEM(use->child)) { SPItem *child = SP_ITEM(use->child); - NR::Matrix const ct( child->transform - * NR::translate(use->x.computed, - use->y.computed) + Geom::Matrix const ct( child->transform + * Geom::Translate(use->x.computed, + use->y.computed) * transform ); sp_item_invoke_bbox_full(child, bbox, ct, flags, FALSE); } diff --git a/src/splivarot.cpp b/src/splivarot.cpp index b65e6c239..f44cba46d 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -453,7 +453,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb // 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)); - sp_item_adjust_stroke(item_source, NR::expansion(i2root)); + sp_item_adjust_stroke(item_source, i2root.descrim()); sp_item_adjust_pattern(item_source, i2root); sp_item_adjust_gradient(item_source, i2root); sp_item_adjust_livepatheffect(item_source, i2root); @@ -601,13 +601,14 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb } static -void sp_selected_path_outline_add_marker( SPObject *marker_object, Geom::Matrix marker_transform, NR::scale stroke_scale, NR::Matrix transform, - Inkscape::XML::Node *g_repr, Inkscape::XML::Document *xml_doc, SPDocument * doc ) +void sp_selected_path_outline_add_marker( SPObject *marker_object, Geom::Matrix marker_transform, + Geom::Scale stroke_scale, Geom::Matrix transform, + Inkscape::XML::Node *g_repr, Inkscape::XML::Document *xml_doc, SPDocument * doc ) { SPMarker* marker = SP_MARKER (marker_object); SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (marker_object)); - NR::Matrix tr(marker_transform); + Geom::Matrix tr(marker_transform); if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { tr = stroke_scale * tr; @@ -685,7 +686,7 @@ sp_selected_path_outline(SPDesktop *desktop) } NR::Matrix const transform(item->transform); - float const scale = NR::expansion(transform); + float const scale = transform.descrim(); gchar const *mask = SP_OBJECT_REPR(item)->attribute("mask"); gchar const *clip_path = SP_OBJECT_REPR(item)->attribute("clip-path"); @@ -860,7 +861,7 @@ sp_selected_path_outline(SPDesktop *desktop) if ( SPObject *marker_obj = shape->marker[SP_MARKER_LOC_START] ) { Geom::Matrix const m (sp_shape_marker_get_transform_at_start(path_it->front())); sp_selected_path_outline_add_marker( marker_obj, m, - NR::scale(i_style->stroke_width.computed), transform, + Geom::Scale(i_style->stroke_width.computed), transform, g_repr, xml_doc, doc ); } @@ -875,9 +876,9 @@ sp_selected_path_outline(SPDesktop *desktop) * there should be a midpoint marker between last segment and closing straight line segment */ Geom::Matrix const m (sp_shape_marker_get_transform(*curve_it1, *curve_it2)); - sp_selected_path_outline_add_marker( midmarker_obj, m, - NR::scale(i_style->stroke_width.computed), transform, - g_repr, xml_doc, doc ); + sp_selected_path_outline_add_marker(midmarker_obj, m, + Geom::Scale(i_style->stroke_width.computed), transform, + g_repr, xml_doc, doc); ++curve_it1; ++curve_it2; @@ -895,7 +896,7 @@ sp_selected_path_outline(SPDesktop *desktop) Geom::Matrix const m = sp_shape_marker_get_transform_at_end(lastcurve); sp_selected_path_outline_add_marker( marker_obj, m, - NR::scale(i_style->stroke_width.computed), transform, + Geom::Scale(i_style->stroke_width.computed), transform, g_repr, xml_doc, doc ); } } @@ -1047,7 +1048,7 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat NR::Matrix const transform(item->transform); - sp_item_write_transform(item, SP_OBJECT_REPR(item), NR::identity()); + sp_item_write_transform(item, SP_OBJECT_REPR(item), Geom::identity()); style = g_strdup(SP_OBJECT(item)->repr->attribute("style")); @@ -1273,7 +1274,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) NR::Matrix const transform(item->transform); - sp_item_write_transform(item, SP_OBJECT_REPR(item), NR::identity()); + sp_item_write_transform(item, SP_OBJECT_REPR(item), Geom::identity()); gchar *style = g_strdup(SP_OBJECT_REPR(item)->attribute("style")); @@ -1522,7 +1523,7 @@ sp_selected_path_simplify_item(SPDesktop *desktop, this is necessary so that the item is transformed twice back and forth, allowing all compensations to cancel out regardless of the preferences */ - sp_item_write_transform(item, SP_OBJECT_REPR(item), NR::identity()); + sp_item_write_transform(item, SP_OBJECT_REPR(item), Geom::identity()); gchar *style = g_strdup(SP_OBJECT_REPR(item)->attribute("style")); gchar *mask = g_strdup(SP_OBJECT_REPR(item)->attribute("mask")); diff --git a/src/text-context.cpp b/src/text-context.cpp index 2a804dfbd..28384b620 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -215,12 +215,12 @@ sp_text_context_setup(SPEventContext *ec) sp_canvas_item_hide(tc->cursor); tc->indicator = sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRLRECT, NULL); - SP_CTRLRECT(tc->indicator)->setRectangle(NR::Rect(NR::Point(0, 0), NR::Point(100, 100))); + SP_CTRLRECT(tc->indicator)->setRectangle(Geom::Rect(Geom::Point(0, 0), Geom::Point(100, 100))); SP_CTRLRECT(tc->indicator)->setColor(0x0000ff7f, false, 0); sp_canvas_item_hide(tc->indicator); tc->frame = sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRLRECT, NULL); - SP_CTRLRECT(tc->frame)->setRectangle(NR::Rect(NR::Point(0, 0), NR::Point(100, 100))); + SP_CTRLRECT(tc->frame)->setRectangle(Geom::Rect(Geom::Point(0, 0), Geom::Point(100, 100))); SP_CTRLRECT(tc->frame)->setColor(0x0000ff7f, false, 0); sp_canvas_item_hide(tc->frame); @@ -437,7 +437,7 @@ sp_text_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve item_ungrouped = desktop->item_at_point(NR::Point(event->button.x, event->button.y), TRUE); if (SP_IS_TEXT(item_ungrouped) || SP_IS_FLOWTEXT(item_ungrouped)) { sp_canvas_item_show(tc->indicator); - boost::optional ibbox = sp_item_bbox_desktop(item_ungrouped); + boost::optional ibbox = to_2geom(sp_item_bbox_desktop(item_ungrouped)); if (ibbox) { SP_CTRLRECT(tc->indicator)->setRectangle(*ibbox); } @@ -815,8 +815,8 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons int screenlines = 1; if (tc->text) { double spacing = sp_te_get_average_linespacing(tc->text); - NR::Rect const d = desktop->get_display_area(); - screenlines = (int) floor(fabs(d.min()[NR::Y] - d.max()[NR::Y])/spacing) - 1; + Geom::Rect const d = desktop->get_display_area(); + screenlines = (int) floor(fabs(d.min()[Geom::Y] - d.max()[Geom::Y])/spacing) - 1; if (screenlines <= 0) screenlines = 1; } @@ -1599,7 +1599,7 @@ sp_text_context_update_cursor(SPTextContext *tc, bool scroll_to_see) SPItem *frame = SP_FLOWTEXT(tc->text)->get_frame (NULL); // first frame only if (frame) { sp_canvas_item_show(tc->frame); - boost::optional frame_bbox = sp_item_bbox_desktop(frame); + boost::optional frame_bbox = to_2geom(sp_item_bbox_desktop(frame)); if (frame_bbox) { SP_CTRLRECT(tc->frame)->setRectangle(*frame_bbox); } diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 48266cfce..11b0f0fe4 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -948,8 +948,8 @@ 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)); - factor = factor / NR::expansion(t); + Geom::Matrix t (sp_item_i2doc_affine(item)); + factor = factor / t.descrim(); by = factor * by; unsigned char_index; @@ -970,8 +970,8 @@ 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)); - factor = factor / NR::expansion(t); + Geom::Matrix t (sp_item_i2doc_affine(text)); + factor = factor / t.descrim(); Inkscape::Text::Layout const *layout = te_get_layout(text); if (layout == NULL) return; SPObject *source_item = 0; @@ -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)))); + / to_2geom(sp_item_i2doc_affine(SP_ITEM(source_obj))).descrim()); val += zby; if (start == end) { @@ -1127,8 +1127,8 @@ 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))); - zby = zby / NR::expansion(t); + Geom::Matrix t (sp_item_i2doc_affine (SP_ITEM(text))); + zby = zby / t.descrim(); switch (style->line_height.unit) { case SP_CSS_UNIT_NONE: diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index 9c6981128..56a36aba6 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -384,9 +384,9 @@ 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)); + Geom::Matrix i2doc(sp_item_i2doc_affine(item)); - orig->ConvertWithBackData((0.08 - (0.07 * fidelity)) / NR::expansion(i2doc)); // default 0.059 + orig->ConvertWithBackData((0.08 - (0.07 * fidelity)) / i2doc.descrim()); // default 0.059 orig->Fill(theShape, 0); SPCSSAttr *css = sp_repr_css_attr(SP_OBJECT_REPR(item), "style"); @@ -441,7 +441,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, NR::Poi res->Reset(); theRes->ConvertToForme(res); - double th_max = (0.6 - 0.59*sqrt(fidelity)) / NR::expansion(i2doc); + double th_max = (0.6 - 0.59*sqrt(fidelity)) / i2doc.descrim(); double threshold = MAX(th_max, th_max*force); res->ConvertEvenLines(threshold); res->Simplify(threshold / (selection->desktop()->current_zoom())); diff --git a/src/ui/view/edit-widget.cpp b/src/ui/view/edit-widget.cpp index 423d8e820..bd6c5032c 100644 --- a/src/ui/view/edit-widget.cpp +++ b/src/ui/view/edit-widget.cpp @@ -1375,7 +1375,7 @@ EditWidget::updateRulers() //Geom::Point gridorigin = _namedview->gridorigin; /// \todo Why was the origin corrected for the grid origin? (johan) - Geom::Rect const viewbox = to_2geom(_svg_canvas.spobj()->getViewbox()); + Geom::Rect const viewbox = _svg_canvas.spobj()->getViewbox(); double lo, up, pos, max; double const scale = _desktop->current_zoom(); double s = viewbox.min()[Geom::X] / scale; //- gridorigin[Geom::X]; @@ -1408,10 +1408,10 @@ EditWidget::updateScrollbars (double scale) NR::Rect carea( Geom::Point(darea.min()[Geom::X] * scale - 64, darea.max()[Geom::Y] * -scale - 64), Geom::Point(darea.max()[Geom::X] * scale + 64, darea.min()[Geom::Y] * -scale + 64) ); - NR::Rect const viewbox = _svg_canvas.spobj()->getViewbox(); + Geom::Rect const viewbox = _svg_canvas.spobj()->getViewbox(); /* Viewbox is always included into scrollable region */ - carea = NR::union_bounds(carea, viewbox); + carea = NR::union_bounds(carea, from_2geom(viewbox)); Gtk::Adjustment *adj = _bottom_scrollbar.get_adjustment(); adj->set_value(viewbox.min()[Geom::X]); @@ -1642,14 +1642,14 @@ EditWidget::onWindowSizeAllocate (Gtk::Allocation &newall) return; } - Geom::Rect const area = to_2geom(_desktop->get_display_area()); + Geom::Rect const area = _desktop->get_display_area(); double zoom = _desktop->current_zoom(); if (_sticky_zoom.get_active()) { /* Calculate zoom per pixel */ double const zpsp = zoom / hypot(area.dimensions()[Geom::X], area.dimensions()[Geom::Y]); /* Find new visible area */ - Geom::Rect const newarea = to_2geom(_desktop->get_display_area()); + Geom::Rect const newarea = _desktop->get_display_area(); /* Calculate adjusted zoom */ zoom = zpsp * hypot(newarea.dimensions()[Geom::X], newarea.dimensions()[Geom::Y]); } diff --git a/src/ui/widget/zoom-status.cpp b/src/ui/widget/zoom-status.cpp index fbe7c0642..7c1cf72d7 100644 --- a/src/ui/widget/zoom-status.cpp +++ b/src/ui/widget/zoom-status.cpp @@ -108,7 +108,7 @@ ZoomStatus::on_value_changed() _upd_f = true; g_assert(_dt); double zoom_factor = pow(2, get_value()); - Geom::Rect const d = to_2geom(_dt->get_display_area()); + Geom::Rect const d = _dt->get_display_area(); _dt->zoom_absolute(d.midpoint()[Geom::X], d.midpoint()[Geom::Y], zoom_factor); gtk_widget_grab_focus(static_cast((void*)_dt->canvas)); /// \todo this no love song _upd_f = false; diff --git a/src/verbs.cpp b/src/verbs.cpp index be5acbd04..71ec33b3f 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1621,8 +1621,8 @@ ZoomVerb::perform(SPAction *action, void *data, void */*pdata*/) } } - NR::Rect const d = dt->get_display_area(); - dt->zoom_relative( d.midpoint()[NR::X], d.midpoint()[NR::Y], mul*zoom_inc); + Geom::Rect const d = dt->get_display_area(); + dt->zoom_relative( d.midpoint()[Geom::X], d.midpoint()[Geom::Y], mul*zoom_inc); break; } case SP_VERB_ZOOM_OUT: @@ -1639,29 +1639,29 @@ ZoomVerb::perform(SPAction *action, void *data, void */*pdata*/) } } - NR::Rect const d = dt->get_display_area(); - dt->zoom_relative( d.midpoint()[NR::X], d.midpoint()[NR::Y], 1 / (mul*zoom_inc) ); + Geom::Rect const d = dt->get_display_area(); + dt->zoom_relative( d.midpoint()[Geom::X], d.midpoint()[Geom::Y], 1 / (mul*zoom_inc) ); break; } case SP_VERB_ZOOM_1_1: { double zcorr = prefs_get_double_attribute ("options.zoomcorrection", "value", 1.0); - NR::Rect const d = dt->get_display_area(); - dt->zoom_absolute( d.midpoint()[NR::X], d.midpoint()[NR::Y], 1.0 * zcorr ); + Geom::Rect const d = dt->get_display_area(); + dt->zoom_absolute( d.midpoint()[Geom::X], d.midpoint()[Geom::Y], 1.0 * zcorr ); break; } case SP_VERB_ZOOM_1_2: { double zcorr = prefs_get_double_attribute ("options.zoomcorrection", "value", 1.0); - NR::Rect const d = dt->get_display_area(); - dt->zoom_absolute( d.midpoint()[NR::X], d.midpoint()[NR::Y], 0.5 * zcorr ); + Geom::Rect const d = dt->get_display_area(); + dt->zoom_absolute( d.midpoint()[Geom::X], d.midpoint()[Geom::Y], 0.5 * zcorr ); break; } case SP_VERB_ZOOM_2_1: { double zcorr = prefs_get_double_attribute ("options.zoomcorrection", "value", 1.0); - NR::Rect const d = dt->get_display_area(); - dt->zoom_absolute( d.midpoint()[NR::X], d.midpoint()[NR::Y], 2.0 * zcorr ); + Geom::Rect const d = dt->get_display_area(); + dt->zoom_absolute( d.midpoint()[Geom::X], d.midpoint()[Geom::Y], 2.0 * zcorr ); break; } case SP_VERB_ZOOM_PAGE: diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index c182fe017..8f7d56c76 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -652,7 +652,7 @@ sp_desktop_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation) } if (GTK_WIDGET_REALIZED (widget)) { - Geom::Rect const area = to_2geom(dtw->desktop->get_display_area()); + Geom::Rect const area = dtw->desktop->get_display_area(); double zoom = dtw->desktop->current_zoom(); if (GTK_WIDGET_CLASS(dtw_parent_class)->size_allocate) { @@ -663,7 +663,7 @@ sp_desktop_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation) /* Calculate zoom per pixel */ double const zpsp = zoom / hypot (area.dimensions()[Geom::X], area.dimensions()[Geom::Y]); /* Find new visible area */ - Geom::Rect newarea = to_2geom(dtw->desktop->get_display_area()); + Geom::Rect newarea = dtw->desktop->get_display_area(); /* Calculate adjusted zoom */ zoom = zpsp * hypot(newarea.dimensions()[Geom::X], newarea.dimensions()[Geom::Y]); dtw->desktop->zoom_absolute(newarea.midpoint()[Geom::X], newarea.midpoint()[Geom::Y], zoom); @@ -1503,7 +1503,7 @@ sp_dtw_zoom_value_changed (GtkSpinButton *spin, gpointer data) SPDesktopWidget *dtw = SP_DESKTOP_WIDGET (data); SPDesktop *desktop = dtw->desktop; - Geom::Rect const d = to_2geom(desktop->get_display_area()); + Geom::Rect const d = desktop->get_display_area(); g_signal_handler_block (spin, dtw->zoom_update); desktop->zoom_absolute (d.midpoint()[Geom::X], d.midpoint()[Geom::Y], zoom_factor); g_signal_handler_unblock (spin, dtw->zoom_update); @@ -1558,7 +1558,7 @@ sp_dtw_zoom_populate_popup (GtkEntry */*entry*/, GtkMenu *menu, gpointer data) static void sp_dtw_zoom_menu_handler (SPDesktop *dt, gdouble factor) { - Geom::Rect const d = to_2geom(dt->get_display_area()); + Geom::Rect const d = dt->get_display_area(); dt->zoom_absolute(d.midpoint()[Geom::X], d.midpoint()[Geom::Y], factor); } @@ -1706,10 +1706,10 @@ sp_desktop_widget_update_scrollbars (SPDesktopWidget *dtw, double scale) Geom::Point(darea.max()[Geom::X] * scale + 64, darea.min()[Geom::Y] * -scale + 64)); - NR::Rect viewbox = dtw->canvas->getViewbox(); + Geom::Rect viewbox = dtw->canvas->getViewbox(); /* Viewbox is always included into scrollable region */ - carea = NR::union_bounds(carea, viewbox); + carea = NR::union_bounds(carea, from_2geom(viewbox)); set_adjustment(dtw->hadj, carea.min()[Geom::X], carea.max()[Geom::X], viewbox.dimensions()[Geom::X], diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index 577efe7c1..49a35b5cb 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -626,7 +626,7 @@ static gint sp_font_preview_expose(GtkWidget *widget, GdkEventExpose *event) font_instance *tface = fprev->rfont->daddy; - double theSize = NR::expansion(fprev->rfont->style.transform); + double theSize = fprev->rfont->style.transform.descrim(); gchar const *p; if (fprev->phrase) { diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index c21a32748..aa0593f85 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -6372,8 +6372,9 @@ static void connector_spacing_changed(GtkAdjustment *adj, GObject* tbl) GSList *items = get_avoided_items(NULL, desktop->currentRoot(), desktop); for ( GSList const *iter = items ; iter != NULL ; iter = iter->next ) { SPItem *item = reinterpret_cast(iter->data); - NR::Matrix m = NR::identity(); - avoid_item_move(&m, item); + Geom::Matrix m = Geom::identity(); + NR::Matrix m_NR = from_2geom(m); + avoid_item_move(&m_NR, item); } if (items) { diff --git a/src/zoom-context.cpp b/src/zoom-context.cpp index 8c6400189..1d14d20cd 100644 --- a/src/zoom-context.cpp +++ b/src/zoom-context.cpp @@ -174,7 +174,7 @@ static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent NR::Point const button_w(event->button.x, event->button.y); NR::Point const button_dt(desktop->w2d(button_w)); if ( event->button.button == 1 && !event_context->space_panning) { - boost::optional const b = Inkscape::Rubberband::get(desktop)->getRectangle(); + boost::optional const b = Inkscape::Rubberband::get(desktop)->getRectangle(); if (b && !within_tolerance) { desktop->set_display_area(*b, 10); } else if (!escaped) {