From 5c6771ad614c8c281c8fcf8f6c1aa727e981a823 Mon Sep 17 00:00:00 2001 From: cilix42 Date: Thu, 18 Sep 2008 17:42:51 +0000 Subject: [PATCH] More NR ==> Geom conversion (points and some matrices/transforms) --- src/desktop-affine.cpp | 10 +- src/desktop-affine.h | 10 +- src/desktop.cpp | 84 ++++---- src/desktop.h | 34 ++-- src/dialogs/clonetiler.cpp | 258 ++++++++++++------------- src/document.cpp | 4 +- src/file.cpp | 8 +- src/graphlayout/graphlayout.cpp | 13 +- src/interface.cpp | 4 +- src/marker.cpp | 84 ++++---- src/removeoverlap/removeoverlap.cpp | 2 +- src/selection-chemistry.cpp | 99 ++++------ src/selection-chemistry.h | 15 +- src/selection.cpp | 33 +++- src/selection.h | 5 +- src/sp-item-group.cpp | 20 +- src/sp-item-group.h | 45 +++-- src/sp-item-transform.cpp | 24 +-- src/sp-item-transform.h | 8 +- src/sp-item.cpp | 6 +- src/sp-item.h | 2 +- src/spiral-context.cpp | 8 +- src/ui/clipboard.cpp | 6 +- src/ui/dialog/align-and-distribute.cpp | 12 +- src/ui/dialog/transformation.cpp | 22 +-- src/verbs.cpp | 8 +- 26 files changed, 427 insertions(+), 397 deletions(-) diff --git a/src/desktop-affine.cpp b/src/desktop-affine.cpp index 7ad2c7bfe..25c5c99b8 100644 --- a/src/desktop-affine.cpp +++ b/src/desktop-affine.cpp @@ -15,25 +15,25 @@ #include "desktop.h" #include "document.h" #include "sp-root.h" -#include "libnr/nr-matrix-ops.h" +//#include "libnr/nr-matrix-ops.h" -NR::Matrix const sp_desktop_root2dt_affine (SPDesktop const *dt) +Geom::Matrix const sp_desktop_root2dt_affine (SPDesktop const *dt) { SPRoot const *root = SP_ROOT(SP_DOCUMENT_ROOT(dt->doc())); return root->c2p * dt->doc2dt(); } -NR::Matrix const sp_desktop_dt2root_affine (SPDesktop const *dt) +Geom::Matrix const sp_desktop_dt2root_affine (SPDesktop const *dt) { return sp_desktop_root2dt_affine(dt).inverse(); } -NR::Point sp_desktop_root2dt_xy_point(SPDesktop const *dt, NR::Point const p) +Geom::Point sp_desktop_root2dt_xy_point(SPDesktop const *dt, Geom::Point const p) { return p * sp_desktop_root2dt_affine(dt); } -NR::Point sp_desktop_dt2root_xy_point(SPDesktop const *dt, NR::Point const p) +Geom::Point sp_desktop_dt2root_xy_point(SPDesktop const *dt, Geom::Point const p) { return p * sp_desktop_dt2root_affine(dt); } diff --git a/src/desktop-affine.h b/src/desktop-affine.h index 00dc9faf0..a5e84d5c7 100644 --- a/src/desktop-affine.h +++ b/src/desktop-affine.h @@ -14,13 +14,13 @@ */ #include "forward.h" -#include +#include <2geom/forward.h> -NR::Matrix const sp_desktop_root2dt_affine(SPDesktop const *dt); -NR::Matrix const sp_desktop_dt2root_affine(SPDesktop const *dt); +Geom::Matrix const sp_desktop_root2dt_affine(SPDesktop const *dt); +Geom::Matrix const sp_desktop_dt2root_affine(SPDesktop const *dt); -NR::Point sp_desktop_root2dt_xy_point(SPDesktop const *dt, const NR::Point p); -NR::Point sp_desktop_dt2root_xy_point(SPDesktop const *dt, const NR::Point p); +Geom::Point sp_desktop_root2dt_xy_point(SPDesktop const *dt, const Geom::Point p); +Geom::Point sp_desktop_dt2root_xy_point(SPDesktop const *dt, const Geom::Point p); #endif diff --git a/src/desktop.cpp b/src/desktop.cpp index 5267bca57..27f7179ed 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -158,8 +158,8 @@ SPDesktop::SPDesktop() : _doc2dt( NR::Matrix(NR::scale(1, -1)) ), grids_visible( false ) { - _d2w.set_identity(); - _w2d.set_identity(); + _d2w.setIdentity(); + _w2d.setIdentity(); selection = Inkscape::GC::release( new Inkscape::Selection(this) ); } @@ -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(NR::Point(-80000, -80000), NR::Point(80000, 80000))); + SP_CTRLRECT(table)->setRectangle(NR::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(NR::Point(0.0, 0.0), - NR::Point(sp_document_width(document), sp_document_height(document))); + NR::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); @@ -647,7 +647,7 @@ SPDesktop::push_event_context (GtkType type, const gchar *config, unsigned int k * Sets the coordinate status to a given point */ void -SPDesktop::set_coordinate_status (NR::Point p) { +SPDesktop::set_coordinate_status (Geom::Point p) { _widget->setCoordinateStatus(p); } @@ -655,7 +655,7 @@ SPDesktop::set_coordinate_status (NR::Point p) { * \see sp_document_item_from_list_at_point_bottom() */ SPItem * -SPDesktop::item_from_list_at_point_bottom (const GSList *list, NR::Point const p) const +SPDesktop::item_from_list_at_point_bottom (const GSList *list, Geom::Point const p) const { g_return_val_if_fail (doc() != NULL, NULL); return sp_document_item_from_list_at_point_bottom (dkey, SP_GROUP (doc()->root), list, p); @@ -665,7 +665,7 @@ SPDesktop::item_from_list_at_point_bottom (const GSList *list, NR::Point const p * \see sp_document_item_at_point() */ SPItem * -SPDesktop::item_at_point (NR::Point const p, bool into_groups, SPItem *upto) const +SPDesktop::item_at_point (Geom::Point const p, bool into_groups, SPItem *upto) const { g_return_val_if_fail (doc() != NULL, NULL); return sp_document_item_at_point (doc(), dkey, p, into_groups, upto); @@ -675,7 +675,7 @@ SPDesktop::item_at_point (NR::Point const p, bool into_groups, SPItem *upto) con * \see sp_document_group_at_point() */ SPItem * -SPDesktop::group_at_point (NR::Point const p) const +SPDesktop::group_at_point (Geom::Point const p) const { g_return_val_if_fail (doc() != NULL, NULL); return sp_document_group_at_point (doc(), dkey, p); @@ -685,17 +685,17 @@ SPDesktop::group_at_point (NR::Point const p) const * \brief Returns the mouse point in document coordinates; if mouse is * outside the canvas, returns the center of canvas viewpoint */ -NR::Point +Geom::Point SPDesktop::point() const { - NR::Point p = _widget->getPointer(); - NR::Point pw = sp_canvas_window_to_world (canvas, p); + Geom::Point p = _widget->getPointer(); + Geom::Point pw = sp_canvas_window_to_world (canvas, p); p = w2d(pw); NR::Rect const r = canvas->getViewbox(); - NR::Point r0 = w2d(r.min()); - NR::Point r1 = w2d(r.max()); + 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] && @@ -752,7 +752,7 @@ SPDesktop::set_display_area (double x0, double y0, double x1, double y1, double NR::Rect const viewbox = NR::expand(canvas->getViewbox(), border); - double scale = expansion(_d2w); + 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); @@ -782,7 +782,7 @@ SPDesktop::set_display_area (double x0, double y0, double x1, double y1, double sp_box3d_context_update_lines(event_context); _widget->updateRulers(); - _widget->updateScrollbars(expansion(_d2w)); + _widget->updateScrollbars(_d2w.descrim()); _widget->updateZoom(); } @@ -800,8 +800,8 @@ NR::Rect SPDesktop::get_display_area() const double const scale = _d2w[0]; - return NR::Rect(NR::Point(viewbox.min()[NR::X] / scale, viewbox.max()[NR::Y] / -scale), - NR::Point(viewbox.max()[NR::X] / scale, viewbox.min()[NR::Y] / -scale)); + 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)); } /** @@ -865,7 +865,7 @@ SPDesktop::zoom_absolute_keep_point (double cx, double cy, double px, double py, // maximum or minimum zoom reached, but there's no exact equality because of rounding errors; // this check prevents "sliding" when trying to zoom in at maximum zoom; /// \todo someone please fix calculations properly and remove this hack - if (fabs(expansion(_d2w) - zoom) < 0.0001*zoom && (fabs(SP_DESKTOP_ZOOM_MAX - zoom) < 0.01 || fabs(SP_DESKTOP_ZOOM_MIN - zoom) < 0.000001)) + 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(); @@ -910,7 +910,7 @@ SPDesktop::zoom_relative_keep_point (double cx, double cy, double zoom) cy = area.max()[NR::Y]; } - gdouble const scale = expansion(_d2w) * zoom; + gdouble const scale = _d2w.descrim() * zoom; double const px = (cx - area.min()[NR::X]) / area.dimensions()[NR::X]; double const py = (cy - area.min()[NR::Y]) / area.dimensions()[NR::Y]; @@ -923,7 +923,7 @@ SPDesktop::zoom_relative_keep_point (double cx, double cy, double zoom) void SPDesktop::zoom_relative (double cx, double cy, double zoom) { - gdouble scale = expansion(_d2w) * zoom; + gdouble scale = _d2w.descrim() * zoom; zoom_absolute (cx, cy, scale); } @@ -933,8 +933,8 @@ SPDesktop::zoom_relative (double cx, double cy, double zoom) void SPDesktop::zoom_page() { - NR::Rect d(NR::Point(0, 0), - NR::Point(sp_document_width(doc()), sp_document_height(doc()))); + NR::Rect d(Geom::Point(0, 0), + Geom::Point(sp_document_width(doc()), sp_document_height(doc()))); if (d.isEmpty(1.0)) { return; @@ -955,8 +955,8 @@ SPDesktop::zoom_page_width() return; } - NR::Rect d(NR::Point(0, a.midpoint()[NR::Y]), - NR::Point(sp_document_width(doc()), a.midpoint()[NR::Y])); + NR::Rect d(Geom::Point(0, a.midpoint()[NR::Y]), + Geom::Point(sp_document_width(doc()), a.midpoint()[NR::Y])); set_display_area(d, 10); } @@ -1013,7 +1013,7 @@ SPDesktop::zoom_drawing() void SPDesktop::scroll_world_in_svg_coords (double dx, double dy, bool is_scrolling) { - double scale = expansion(_d2w); + double scale = _d2w.descrim(); scroll_world(dx*scale, dy*scale, is_scrolling); } @@ -1033,7 +1033,7 @@ SPDesktop::scroll_world (double dx, double dy, bool is_scrolling) sp_box3d_context_update_lines(event_context); _widget->updateRulers(); - _widget->updateScrollbars(expansion(_d2w)); + _widget->updateScrollbars(_d2w.descrim()); } bool @@ -1042,13 +1042,13 @@ SPDesktop::scroll_to_point (Geom::Point const &p, gdouble autoscrollspeed) gdouble autoscrolldistance = (gdouble) prefs_get_int_attribute_limited ("options.autoscrolldistance", "value", 0, -1000, 10000); // autoscrolldistance is in screen pixels, but the display area is in document units - autoscrolldistance /= expansion(_d2w); + autoscrolldistance /= _d2w.descrim(); NR::Rect const dbox = NR::expand(get_display_area(), -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]) ) { - NR::Point const s_w( p * (Geom::Matrix)_d2w ); + Geom::Point const s_w( p * (Geom::Matrix)_d2w ); gdouble x_to; if (p[NR::X] < dbox.min()[NR::X]) @@ -1066,9 +1066,9 @@ SPDesktop::scroll_to_point (Geom::Point const &p, gdouble autoscrollspeed) else y_to = p[NR::Y]; - NR::Point const d_dt(x_to, y_to); - NR::Point const d_w( d_dt * _d2w ); - NR::Point const moved_w( d_w - s_w ); + Geom::Point const d_dt(x_to, y_to); + Geom::Point const d_w( d_dt * _d2w ); + Geom::Point const moved_w( d_w - s_w ); if (autoscrollspeed == 0) autoscrollspeed = prefs_get_double_attribute_limited ("options.autoscrollspeed", "value", 1, 0, 10); @@ -1124,7 +1124,7 @@ SPDesktop::getWindowGeometry (gint &x, gint &y, gint &w, gint &h) } void -SPDesktop::setWindowPosition (NR::Point p) +SPDesktop::setWindowPosition (Geom::Point p) { _widget->setPosition (p); } @@ -1327,7 +1327,7 @@ void SPDesktop::toggleSnapping() void SPDesktop::onPositionSet (double x, double y) { - _widget->viewSetPosition (NR::Point(x,y)); + _widget->viewSetPosition (Geom::Point(x,y)); } void @@ -1434,7 +1434,7 @@ SPDesktop::onDocumentResized (gdouble width, gdouble height) { _doc2dt[5] = height; sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (drawing), _doc2dt); - NR::Rect const a(NR::Point(0, 0), NR::Point(width, height)); + NR::Rect const a(Geom::Point(0, 0), Geom::Point(width, height)); SP_CTRLRECT(page)->setRectangle(a); SP_CTRLRECT(page_border)->setRectangle(a); } @@ -1459,7 +1459,7 @@ SPDesktop::_onSelectionModified (Inkscape::Selection */*selection*/, guint /*flags*/, SPDesktop *dt) { if (!dt->_widget) return; - dt->_widget->updateScrollbars (expansion(dt->_d2w)); + dt->_widget->updateScrollbars (dt->_d2w.descrim()); } static void @@ -1650,32 +1650,32 @@ _update_snap_distances (SPDesktop *desktop) } -NR::Matrix SPDesktop::w2d() const +Geom::Matrix SPDesktop::w2d() const { return _w2d; } -NR::Point SPDesktop::w2d(NR::Point const &p) const +Geom::Point SPDesktop::w2d(Geom::Point const &p) const { return p * _w2d; } -NR::Point SPDesktop::d2w(NR::Point const &p) const +Geom::Point SPDesktop::d2w(Geom::Point const &p) const { return p * _d2w; } -NR::Matrix SPDesktop::doc2dt() const +Geom::Matrix SPDesktop::doc2dt() const { return _doc2dt; } -NR::Point SPDesktop::doc2dt(NR::Point const &p) const +Geom::Point SPDesktop::doc2dt(Geom::Point const &p) const { return p * _doc2dt; } -NR::Point SPDesktop::dt2doc(NR::Point const &p) const +Geom::Point SPDesktop::dt2doc(Geom::Point const &p) const { return p * _doc2dt.inverse(); } diff --git a/src/desktop.h b/src/desktop.h index 8b7ecd98b..27439ebcc 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -221,11 +221,11 @@ struct SPDesktop : public Inkscape::UI::View::View void set_event_context (GtkType type, const gchar *config); void push_event_context (GtkType type, const gchar *config, unsigned int key); - void set_coordinate_status (NR::Point p); - SPItem *item_from_list_at_point_bottom (const GSList *list, NR::Point const p) const; - SPItem *item_at_point (NR::Point const p, bool into_groups, SPItem *upto = NULL) const; - SPItem *group_at_point (NR::Point const p) const; - NR::Point point() const; + void set_coordinate_status (Geom::Point p); + SPItem *item_from_list_at_point_bottom (const GSList *list, Geom::Point const p) const; + SPItem *item_at_point (Geom::Point const p, bool into_groups, SPItem *upto = NULL) const; + SPItem *group_at_point (Geom::Point const p) const; + Geom::Point point() const; NR::Rect get_display_area() const; void set_display_area (double x0, double y0, double x1, double y1, double border, bool log = true); @@ -234,7 +234,7 @@ struct SPDesktop : public Inkscape::UI::View::View 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 (NR::Point const &c, double const zoom) + void zoom_relative_keep_point (Geom::Point const &c, double const zoom) { using NR::X; using NR::Y; @@ -252,7 +252,7 @@ struct SPDesktop : public Inkscape::UI::View::View bool scroll_to_point (Geom::Point const &s_dt, gdouble autoscrollspeed = 0); void scroll_world (double dx, double dy, bool is_scrolling = false); - void scroll_world (NR::Point const scroll, bool is_scrolling = false) + void scroll_world (Geom::Point const scroll, bool is_scrolling = false) { using NR::X; using NR::Y; @@ -261,7 +261,7 @@ struct SPDesktop : public Inkscape::UI::View::View void scroll_world_in_svg_coords (double dx, double dy, bool is_scrolling = false); void getWindowGeometry (gint &x, gint &y, gint &w, gint &h); - void setWindowPosition (NR::Point p); + void setWindowPosition (Geom::Point p); void setWindowSize (gint w, gint h); void setWindowTransient (void* p, int transient_policy=1); Gtk::Window* getToplevel(); @@ -302,12 +302,12 @@ struct SPDesktop : public Inkscape::UI::View::View void registerEditWidget (Inkscape::UI::View::EditWidgetInterface *widget) { _widget = widget; } - NR::Matrix w2d() const; //transformation from window to desktop coordinates (used for zooming) - NR::Point w2d(NR::Point const &p) const; - NR::Point d2w(NR::Point const &p) const; - NR::Matrix doc2dt() const; - NR::Point doc2dt(NR::Point const &p) const; - NR::Point dt2doc(NR::Point const &p) const; + Geom::Matrix w2d() const; //transformation from window to desktop coordinates (used for zooming) + Geom::Point w2d(Geom::Point const &p) const; + Geom::Point d2w(Geom::Point const &p) const; + Geom::Matrix doc2dt() const; + Geom::Point doc2dt(Geom::Point const &p) const; + Geom::Point dt2doc(Geom::Point const &p) const; virtual void setDocument (SPDocument* doc); virtual bool shutdown(); @@ -322,9 +322,9 @@ private: Inkscape::Application *_inkscape; Inkscape::MessageContext *_guides_message_context; bool _active; - NR::Matrix _w2d; - NR::Matrix _d2w; - NR::Matrix _doc2dt; + Geom::Matrix _w2d; + Geom::Matrix _d2w; + Geom::Matrix _doc2dt; bool grids_visible; /* don't set this variable directly, use the method below */ void set_grids_visible(bool visible); diff --git a/src/dialogs/clonetiler.cpp b/src/dialogs/clonetiler.cpp index b15dfe5f4..1094571f5 100644 --- a/src/dialogs/clonetiler.cpp +++ b/src/dialogs/clonetiler.cpp @@ -221,7 +221,7 @@ enum { }; -static NR::Matrix +static Geom::Matrix clonetiler_get_transform ( // symmetry group @@ -312,7 +312,7 @@ clonetiler_get_transform ( if ( shifty_exp != 1.0 ) shiftj = pow( shiftj, shifty_exp ); // Final shift - NR::Matrix rect_translate (NR::translate (w * shifti, h * shiftj)); + Geom::Matrix rect_translate (Geom::Translate (w * shifti, h * shiftj)); // Rotation (in degrees) ------------ double delta_rotationi = 0.0; @@ -395,25 +395,25 @@ clonetiler_get_transform ( // Calculate transformation matrices, translating back to "center of tile" (rotation center) before transforming - NR::Matrix drot_c = NR::translate(-cx, -cy) * NR::rotate (M_PI*dr/180) * NR::translate(cx, cy); + Geom::Matrix drot_c = Geom::Translate(-cx, -cy) * Geom::Rotate (M_PI*dr/180) * Geom::Translate(cx, cy); - NR::Matrix dscale_c = NR::translate(-cx, -cy) * NR::scale (scalex, scaley) * NR::translate(cx, cy); + Geom::Matrix dscale_c = Geom::Translate(-cx, -cy) * Geom::Scale (scalex, scaley) * Geom::Translate(cx, cy); - NR::Matrix d_s_r = dscale_c * drot_c; + Geom::Matrix d_s_r = dscale_c * drot_c; - NR::Matrix rotate_180_c = NR::translate(-cx, -cy) * NR::rotate (M_PI) * NR::translate(cx, cy); + Geom::Matrix rotate_180_c = Geom::Translate(-cx, -cy) * Geom::Rotate (M_PI) * Geom::Translate(cx, cy); - NR::Matrix rotate_90_c = NR::translate(-cx, -cy) * NR::rotate (-M_PI/2) * NR::translate(cx, cy); - NR::Matrix rotate_m90_c = NR::translate(-cx, -cy) * NR::rotate ( M_PI/2) * NR::translate(cx, cy); + Geom::Matrix rotate_90_c = Geom::Translate(-cx, -cy) * Geom::Rotate (-M_PI/2) * Geom::Translate(cx, cy); + Geom::Matrix rotate_m90_c = Geom::Translate(-cx, -cy) * Geom::Rotate ( M_PI/2) * Geom::Translate(cx, cy); - NR::Matrix rotate_120_c = NR::translate(-cx, -cy) * NR::rotate (-2*M_PI/3) * NR::translate(cx, cy); - NR::Matrix rotate_m120_c = NR::translate(-cx, -cy) * NR::rotate ( 2*M_PI/3) * NR::translate(cx, cy); + Geom::Matrix rotate_120_c = Geom::Translate(-cx, -cy) * Geom::Rotate (-2*M_PI/3) * Geom::Translate(cx, cy); + Geom::Matrix rotate_m120_c = Geom::Translate(-cx, -cy) * Geom::Rotate ( 2*M_PI/3) * Geom::Translate(cx, cy); - NR::Matrix rotate_60_c = NR::translate(-cx, -cy) * NR::rotate (-M_PI/3) * NR::translate(cx, cy); - NR::Matrix rotate_m60_c = NR::translate(-cx, -cy) * NR::rotate ( M_PI/3) * NR::translate(cx, cy); + Geom::Matrix rotate_60_c = Geom::Translate(-cx, -cy) * Geom::Rotate (-M_PI/3) * Geom::Translate(cx, cy); + Geom::Matrix rotate_m60_c = Geom::Translate(-cx, -cy) * Geom::Rotate ( M_PI/3) * Geom::Translate(cx, cy); - NR::Matrix flip_x = NR::translate(-cx, -cy) * NR::scale (-1, 1) * NR::translate(cx, cy); - NR::Matrix flip_y = NR::translate(-cx, -cy) * NR::scale (1, -1) * NR::translate(cx, cy); + Geom::Matrix flip_x = Geom::Translate(-cx, -cy) * Geom::Scale (-1, 1) * Geom::Translate(cx, cy); + Geom::Matrix flip_y = Geom::Translate(-cx, -cy) * Geom::Scale (1, -1) * Geom::Translate(cx, cy); // Create tile with required symmetry @@ -538,9 +538,9 @@ clonetiler_get_transform ( case TILE_P4: { - NR::Matrix ori (NR::translate ((w + h) * pow((i/2), shiftx_exp) + dx, (h + w) * pow((j/2), shifty_exp) + dy)); - NR::Matrix dia1 (NR::translate (w/2 + h/2, -h/2 + w/2)); - NR::Matrix dia2 (NR::translate (-w/2 + h/2, h/2 + w/2)); + Geom::Matrix ori (Geom::Translate ((w + h) * pow((i/2), shiftx_exp) + dx, (h + w) * pow((j/2), shifty_exp) + dy)); + Geom::Matrix dia1 (Geom::Translate (w/2 + h/2, -h/2 + w/2)); + Geom::Matrix dia2 (Geom::Translate (-w/2 + h/2, h/2 + w/2)); if (j % 2 == 0) { if (i % 2 == 0) { return d_s_r * ori; @@ -560,28 +560,28 @@ clonetiler_get_transform ( case TILE_P4M: { double max = MAX(w, h); - NR::Matrix ori (NR::translate ((max + max) * pow((i/4), shiftx_exp) + dx, (max + max) * pow((j/2), shifty_exp) + dy)); - NR::Matrix dia1 (NR::translate ( w/2 - h/2, h/2 - w/2)); - NR::Matrix dia2 (NR::translate (-h/2 + w/2, w/2 - h/2)); + Geom::Matrix ori (Geom::Translate ((max + max) * pow((i/4), shiftx_exp) + dx, (max + max) * pow((j/2), shifty_exp) + dy)); + Geom::Matrix dia1 (Geom::Translate ( w/2 - h/2, h/2 - w/2)); + Geom::Matrix dia2 (Geom::Translate (-h/2 + w/2, w/2 - h/2)); if (j % 2 == 0) { if (i % 4 == 0) { return d_s_r * ori; } else if (i % 4 == 1) { return d_s_r * flip_y * rotate_m90_c * dia1 * ori; } else if (i % 4 == 2) { - return d_s_r * rotate_m90_c * dia1 * NR::translate (h, 0) * ori; + return d_s_r * rotate_m90_c * dia1 * Geom::Translate (h, 0) * ori; } else if (i % 4 == 3) { - return d_s_r * flip_x * NR::translate (w, 0) * ori; + return d_s_r * flip_x * Geom::Translate (w, 0) * ori; } } else { if (i % 4 == 0) { - return d_s_r * flip_y * NR::translate(0, h) * ori; + return d_s_r * flip_y * Geom::Translate(0, h) * ori; } else if (i % 4 == 1) { - return d_s_r * rotate_90_c * dia2 * NR::translate(0, h) * ori; + return d_s_r * rotate_90_c * dia2 * Geom::Translate(0, h) * ori; } else if (i % 4 == 2) { - return d_s_r * flip_y * rotate_90_c * dia2 * NR::translate(h, 0) * NR::translate(0, h) * ori; + return d_s_r * flip_y * rotate_90_c * dia2 * Geom::Translate(h, 0) * Geom::Translate(0, h) * ori; } else if (i % 4 == 3) { - return d_s_r * flip_y * flip_x * NR::translate(w, 0) * NR::translate(0, h) * ori; + return d_s_r * flip_y * flip_x * Geom::Translate(w, 0) * Geom::Translate(0, h) * ori; } } } @@ -590,9 +590,9 @@ clonetiler_get_transform ( case TILE_P4G: { double max = MAX(w, h); - NR::Matrix ori (NR::translate ((max + max) * pow((i/4), shiftx_exp) + dx, (max + max) * pow(j, shifty_exp) + dy)); - NR::Matrix dia1 (NR::translate ( w/2 + h/2, h/2 - w/2)); - NR::Matrix dia2 (NR::translate (-h/2 + w/2, w/2 + h/2)); + Geom::Matrix ori (Geom::Translate ((max + max) * pow((i/4), shiftx_exp) + dx, (max + max) * pow(j, shifty_exp) + dy)); + Geom::Matrix dia1 (Geom::Translate ( w/2 + h/2, h/2 - w/2)); + Geom::Matrix dia2 (Geom::Translate (-h/2 + w/2, w/2 + h/2)); if (((i/4) + j) % 2 == 0) { if (i % 4 == 0) { return d_s_r * ori; @@ -605,13 +605,13 @@ clonetiler_get_transform ( } } else { if (i % 4 == 0) { - return d_s_r * flip_y * NR::translate (0, h) * ori; + return d_s_r * flip_y * Geom::Translate (0, h) * ori; } else if (i % 4 == 1) { - return d_s_r * flip_y * rotate_m90_c * dia1 * NR::translate (-h, 0) * ori; + return d_s_r * flip_y * rotate_m90_c * dia1 * Geom::Translate (-h, 0) * ori; } else if (i % 4 == 2) { - return d_s_r * flip_y * rotate_90_c * dia2 * NR::translate (h, 0) * ori; + return d_s_r * flip_y * rotate_90_c * dia2 * Geom::Translate (h, 0) * ori; } else if (i % 4 == 3) { - return d_s_r * flip_x * NR::translate (w, 0) * ori; + return d_s_r * flip_x * Geom::Translate (w, 0) * ori; } } } @@ -621,20 +621,20 @@ clonetiler_get_transform ( { double width; double height; - NR::Matrix dia1; - NR::Matrix dia2; + Geom::Matrix dia1; + Geom::Matrix dia2; if (w > h) { width = w + w * cos60; height = 2 * w * sin60; - dia1 = NR::Matrix (NR::translate (w/2 + w/2 * cos60, -(w/2 * sin60))); - dia2 = dia1 * NR::Matrix (NR::translate (0, 2 * (w/2 * sin60))); + dia1 = Geom::Matrix (Geom::Translate (w/2 + w/2 * cos60, -(w/2 * sin60))); + dia2 = dia1 * Geom::Matrix (Geom::Translate (0, 2 * (w/2 * sin60))); } else { width = h * cos (M_PI/6); height = h; - dia1 = NR::Matrix (NR::translate (h/2 * cos30, -(h/2 * sin30))); - dia2 = dia1 * NR::Matrix (NR::translate (0, h/2)); + dia1 = Geom::Matrix (Geom::Translate (h/2 * cos30, -(h/2 * sin30))); + dia2 = dia1 * Geom::Matrix (Geom::Translate (0, h/2)); } - NR::Matrix ori (NR::translate (width * pow((2*(i/3) + j%2), shiftx_exp) + dx, (height/2) * pow(j, shifty_exp) + dy)); + Geom::Matrix ori (Geom::Translate (width * pow((2*(i/3) + j%2), shiftx_exp) + dx, (height/2) * pow(j, shifty_exp) + dy)); if (i % 3 == 0) { return d_s_r * ori; } else if (i % 3 == 1) { @@ -647,23 +647,23 @@ clonetiler_get_transform ( case TILE_P31M: { - NR::Matrix ori; - NR::Matrix dia1; - NR::Matrix dia2; - NR::Matrix dia3; - NR::Matrix dia4; + Geom::Matrix ori; + Geom::Matrix dia1; + Geom::Matrix dia2; + Geom::Matrix dia3; + Geom::Matrix dia4; if (w > h) { - ori = NR::Matrix(NR::translate (w * pow((i/6) + 0.5*(j%2), shiftx_exp) + dx, (w * cos30) * pow(j, shifty_exp) + dy)); - dia1 = NR::Matrix (NR::translate (0, h/2) * NR::translate (w/2, 0) * NR::translate (w/2 * cos60, -w/2 * sin60) * NR::translate (-h/2 * cos30, -h/2 * sin30) ); - dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, h * sin30)); - dia3 = dia2 * NR::Matrix (NR::translate (0, 2 * (w/2 * sin60 - h/2 * sin30))); - dia4 = dia3 * NR::Matrix (NR::translate (-h * cos30, h * sin30)); + ori = Geom::Matrix(Geom::Translate (w * pow((i/6) + 0.5*(j%2), shiftx_exp) + dx, (w * cos30) * pow(j, shifty_exp) + dy)); + dia1 = Geom::Matrix (Geom::Translate (0, h/2) * Geom::Translate (w/2, 0) * Geom::Translate (w/2 * cos60, -w/2 * sin60) * Geom::Translate (-h/2 * cos30, -h/2 * sin30) ); + dia2 = dia1 * Geom::Matrix (Geom::Translate (h * cos30, h * sin30)); + dia3 = dia2 * Geom::Matrix (Geom::Translate (0, 2 * (w/2 * sin60 - h/2 * sin30))); + dia4 = dia3 * Geom::Matrix (Geom::Translate (-h * cos30, h * sin30)); } else { - ori = NR::Matrix (NR::translate (2*h * cos30 * pow((i/6 + 0.5*(j%2)), shiftx_exp) + dx, (2*h - h * sin30) * pow(j, shifty_exp) + dy)); - dia1 = NR::Matrix (NR::translate (0, -h/2) * NR::translate (h/2 * cos30, h/2 * sin30)); - dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, h * sin30)); - dia3 = dia2 * NR::Matrix (NR::translate (0, h/2)); - dia4 = dia3 * NR::Matrix (NR::translate (-h * cos30, h * sin30)); + ori = Geom::Matrix (Geom::Translate (2*h * cos30 * pow((i/6 + 0.5*(j%2)), shiftx_exp) + dx, (2*h - h * sin30) * pow(j, shifty_exp) + dy)); + dia1 = Geom::Matrix (Geom::Translate (0, -h/2) * Geom::Translate (h/2 * cos30, h/2 * sin30)); + dia2 = dia1 * Geom::Matrix (Geom::Translate (h * cos30, h * sin30)); + dia3 = dia2 * Geom::Matrix (Geom::Translate (0, h/2)); + dia4 = dia3 * Geom::Matrix (Geom::Translate (-h * cos30, h * sin30)); } if (i % 6 == 0) { return d_s_r * ori; @@ -676,7 +676,7 @@ clonetiler_get_transform ( } else if (i % 6 == 4) { return d_s_r * rotate_120_c * dia4 * ori; } else if (i % 6 == 5) { - return d_s_r * flip_y * NR::translate(0, h) * ori; + return d_s_r * flip_y * Geom::Translate(0, h) * ori; } } break; @@ -685,26 +685,26 @@ clonetiler_get_transform ( { double width; double height; - NR::Matrix dia1; - NR::Matrix dia2; - NR::Matrix dia3; - NR::Matrix dia4; + Geom::Matrix dia1; + Geom::Matrix dia2; + Geom::Matrix dia3; + Geom::Matrix dia4; if (w > h) { width = w + w * cos60; height = 2 * w * sin60; - dia1 = NR::Matrix (NR::translate (0, h/2) * NR::translate (w/2, 0) * NR::translate (w/2 * cos60, -w/2 * sin60) * NR::translate (-h/2 * cos30, -h/2 * sin30) ); - dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, h * sin30)); - dia3 = dia2 * NR::Matrix (NR::translate (0, 2 * (w/2 * sin60 - h/2 * sin30))); - dia4 = dia3 * NR::Matrix (NR::translate (-h * cos30, h * sin30)); + dia1 = Geom::Matrix (Geom::Translate (0, h/2) * Geom::Translate (w/2, 0) * Geom::Translate (w/2 * cos60, -w/2 * sin60) * Geom::Translate (-h/2 * cos30, -h/2 * sin30) ); + dia2 = dia1 * Geom::Matrix (Geom::Translate (h * cos30, h * sin30)); + dia3 = dia2 * Geom::Matrix (Geom::Translate (0, 2 * (w/2 * sin60 - h/2 * sin30))); + dia4 = dia3 * Geom::Matrix (Geom::Translate (-h * cos30, h * sin30)); } else { width = 2 * h * cos (M_PI/6); height = 2 * h; - dia1 = NR::Matrix (NR::translate (0, -h/2) * NR::translate (h/2 * cos30, h/2 * sin30)); - dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, h * sin30)); - dia3 = dia2 * NR::Matrix (NR::translate (0, h/2)); - dia4 = dia3 * NR::Matrix (NR::translate (-h * cos30, h * sin30)); + dia1 = Geom::Matrix (Geom::Translate (0, -h/2) * Geom::Translate (h/2 * cos30, h/2 * sin30)); + dia2 = dia1 * Geom::Matrix (Geom::Translate (h * cos30, h * sin30)); + dia3 = dia2 * Geom::Matrix (Geom::Translate (0, h/2)); + dia4 = dia3 * Geom::Matrix (Geom::Translate (-h * cos30, h * sin30)); } - NR::Matrix ori (NR::translate (width * pow((2*(i/6) + j%2), shiftx_exp) + dx, (height/2) * pow(j, shifty_exp) + dy)); + Geom::Matrix ori (Geom::Translate (width * pow((2*(i/6) + j%2), shiftx_exp) + dx, (height/2) * pow(j, shifty_exp) + dy)); if (i % 6 == 0) { return d_s_r * ori; } else if (i % 6 == 1) { @@ -716,31 +716,31 @@ clonetiler_get_transform ( } else if (i % 6 == 4) { return d_s_r * rotate_120_c * dia4 * ori; } else if (i % 6 == 5) { - return d_s_r * flip_y * NR::translate(0, h) * ori; + return d_s_r * flip_y * Geom::Translate(0, h) * ori; } } break; case TILE_P6: { - NR::Matrix ori; - NR::Matrix dia1; - NR::Matrix dia2; - NR::Matrix dia3; - NR::Matrix dia4; - NR::Matrix dia5; + Geom::Matrix ori; + Geom::Matrix dia1; + Geom::Matrix dia2; + Geom::Matrix dia3; + Geom::Matrix dia4; + Geom::Matrix dia5; if (w > h) { - ori = NR::Matrix(NR::translate (w * pow((2*(i/6) + (j%2)), shiftx_exp) + dx, (2*w * sin60) * pow(j, shifty_exp) + dy)); - dia1 = NR::Matrix (NR::translate (w/2 * cos60, -w/2 * sin60)); - dia2 = dia1 * NR::Matrix (NR::translate (w/2, 0)); - dia3 = dia2 * NR::Matrix (NR::translate (w/2 * cos60, w/2 * sin60)); - dia4 = dia3 * NR::Matrix (NR::translate (-w/2 * cos60, w/2 * sin60)); - dia5 = dia4 * NR::Matrix (NR::translate (-w/2, 0)); + ori = Geom::Matrix(Geom::Translate (w * pow((2*(i/6) + (j%2)), shiftx_exp) + dx, (2*w * sin60) * pow(j, shifty_exp) + dy)); + dia1 = Geom::Matrix (Geom::Translate (w/2 * cos60, -w/2 * sin60)); + dia2 = dia1 * Geom::Matrix (Geom::Translate (w/2, 0)); + dia3 = dia2 * Geom::Matrix (Geom::Translate (w/2 * cos60, w/2 * sin60)); + dia4 = dia3 * Geom::Matrix (Geom::Translate (-w/2 * cos60, w/2 * sin60)); + dia5 = dia4 * Geom::Matrix (Geom::Translate (-w/2, 0)); } else { - ori = NR::Matrix(NR::translate (2*h * cos30 * pow((i/6 + 0.5*(j%2)), shiftx_exp) + dx, (h + h * sin30) * pow(j, shifty_exp) + dy)); - dia1 = NR::Matrix (NR::translate (-w/2, -h/2) * NR::translate (h/2 * cos30, -h/2 * sin30) * NR::translate (w/2 * cos60, w/2 * sin60)); - dia2 = dia1 * NR::Matrix (NR::translate (-w/2 * cos60, -w/2 * sin60) * NR::translate (h/2 * cos30, -h/2 * sin30) * NR::translate (h/2 * cos30, h/2 * sin30) * NR::translate (-w/2 * cos60, w/2 * sin60)); - dia3 = dia2 * NR::Matrix (NR::translate (w/2 * cos60, -w/2 * sin60) * NR::translate (h/2 * cos30, h/2 * sin30) * NR::translate (-w/2, h/2)); + ori = Geom::Matrix(Geom::Translate (2*h * cos30 * pow((i/6 + 0.5*(j%2)), shiftx_exp) + dx, (h + h * sin30) * pow(j, shifty_exp) + dy)); + dia1 = Geom::Matrix (Geom::Translate (-w/2, -h/2) * Geom::Translate (h/2 * cos30, -h/2 * sin30) * Geom::Translate (w/2 * cos60, w/2 * sin60)); + dia2 = dia1 * Geom::Matrix (Geom::Translate (-w/2 * cos60, -w/2 * sin60) * Geom::Translate (h/2 * cos30, -h/2 * sin30) * Geom::Translate (h/2 * cos30, h/2 * sin30) * Geom::Translate (-w/2 * cos60, w/2 * sin60)); + dia3 = dia2 * Geom::Matrix (Geom::Translate (w/2 * cos60, -w/2 * sin60) * Geom::Translate (h/2 * cos30, h/2 * sin30) * Geom::Translate (-w/2, h/2)); dia4 = dia3 * dia1.inverse(); dia5 = dia3 * dia2.inverse(); } @@ -763,28 +763,28 @@ clonetiler_get_transform ( case TILE_P6M: { - NR::Matrix ori; - NR::Matrix dia1, dia2, dia3, dia4, dia5, dia6, dia7, dia8, dia9, dia10; + Geom::Matrix ori; + Geom::Matrix dia1, dia2, dia3, dia4, dia5, dia6, dia7, dia8, dia9, dia10; if (w > h) { - ori = NR::Matrix(NR::translate (w * pow((2*(i/12) + (j%2)), shiftx_exp) + dx, (2*w * sin60) * pow(j, shifty_exp) + dy)); - dia1 = NR::Matrix (NR::translate (w/2, h/2) * NR::translate (-w/2 * cos60, -w/2 * sin60) * NR::translate (-h/2 * cos30, h/2 * sin30)); - dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, -h * sin30)); - dia3 = dia2 * NR::Matrix (NR::translate (-h/2 * cos30, h/2 * sin30) * NR::translate (w * cos60, 0) * NR::translate (-h/2 * cos30, -h/2 * sin30)); - dia4 = dia3 * NR::Matrix (NR::translate (h * cos30, h * sin30)); - dia5 = dia4 * NR::Matrix (NR::translate (-h/2 * cos30, -h/2 * sin30) * NR::translate (-w/2 * cos60, w/2 * sin60) * NR::translate (w/2, -h/2)); - dia6 = dia5 * NR::Matrix (NR::translate (0, h)); + ori = Geom::Matrix(Geom::Translate (w * pow((2*(i/12) + (j%2)), shiftx_exp) + dx, (2*w * sin60) * pow(j, shifty_exp) + dy)); + dia1 = Geom::Matrix (Geom::Translate (w/2, h/2) * Geom::Translate (-w/2 * cos60, -w/2 * sin60) * Geom::Translate (-h/2 * cos30, h/2 * sin30)); + dia2 = dia1 * Geom::Matrix (Geom::Translate (h * cos30, -h * sin30)); + dia3 = dia2 * Geom::Matrix (Geom::Translate (-h/2 * cos30, h/2 * sin30) * Geom::Translate (w * cos60, 0) * Geom::Translate (-h/2 * cos30, -h/2 * sin30)); + dia4 = dia3 * Geom::Matrix (Geom::Translate (h * cos30, h * sin30)); + dia5 = dia4 * Geom::Matrix (Geom::Translate (-h/2 * cos30, -h/2 * sin30) * Geom::Translate (-w/2 * cos60, w/2 * sin60) * Geom::Translate (w/2, -h/2)); + dia6 = dia5 * Geom::Matrix (Geom::Translate (0, h)); dia7 = dia6 * dia1.inverse(); dia8 = dia6 * dia2.inverse(); dia9 = dia6 * dia3.inverse(); dia10 = dia6 * dia4.inverse(); } else { - ori = NR::Matrix(NR::translate (4*h * cos30 * pow((i/12 + 0.5*(j%2)), shiftx_exp) + dx, (2*h + 2*h * sin30) * pow(j, shifty_exp) + dy)); - dia1 = NR::Matrix (NR::translate (-w/2, -h/2) * NR::translate (h/2 * cos30, -h/2 * sin30) * NR::translate (w/2 * cos60, w/2 * sin60)); - dia2 = dia1 * NR::Matrix (NR::translate (h * cos30, -h * sin30)); - dia3 = dia2 * NR::Matrix (NR::translate (-w/2 * cos60, -w/2 * sin60) * NR::translate (h * cos30, 0) * NR::translate (-w/2 * cos60, w/2 * sin60)); - dia4 = dia3 * NR::Matrix (NR::translate (h * cos30, h * sin30)); - dia5 = dia4 * NR::Matrix (NR::translate (w/2 * cos60, -w/2 * sin60) * NR::translate (h/2 * cos30, h/2 * sin30) * NR::translate (-w/2, h/2)); - dia6 = dia5 * NR::Matrix (NR::translate (0, h)); + ori = Geom::Matrix(Geom::Translate (4*h * cos30 * pow((i/12 + 0.5*(j%2)), shiftx_exp) + dx, (2*h + 2*h * sin30) * pow(j, shifty_exp) + dy)); + dia1 = Geom::Matrix (Geom::Translate (-w/2, -h/2) * Geom::Translate (h/2 * cos30, -h/2 * sin30) * Geom::Translate (w/2 * cos60, w/2 * sin60)); + dia2 = dia1 * Geom::Matrix (Geom::Translate (h * cos30, -h * sin30)); + dia3 = dia2 * Geom::Matrix (Geom::Translate (-w/2 * cos60, -w/2 * sin60) * Geom::Translate (h * cos30, 0) * Geom::Translate (-w/2 * cos60, w/2 * sin60)); + dia4 = dia3 * Geom::Matrix (Geom::Translate (h * cos30, h * sin30)); + dia5 = dia4 * Geom::Matrix (Geom::Translate (w/2 * cos60, -w/2 * sin60) * Geom::Translate (h/2 * cos30, h/2 * sin30) * Geom::Translate (-w/2, h/2)); + dia6 = dia5 * Geom::Matrix (Geom::Translate (0, h)); dia7 = dia6 * dia1.inverse(); dia8 = dia6 * dia2.inverse(); dia9 = dia6 * dia3.inverse(); @@ -813,7 +813,7 @@ clonetiler_get_transform ( } else if (i % 12 == 10) { return d_s_r * rotate_60_c * dia10 * ori; } else if (i % 12 == 11) { - return d_s_r * flip_y * NR::translate (0, h) * ori; + return d_s_r * flip_y * Geom::Translate (0, h) * ori; } } break; @@ -1222,7 +1222,7 @@ clonetiler_apply( GtkWidget */*widget*/, void * ) clonetiler_trace_setup (sp_desktop_document(desktop), 1.0, SP_ITEM (obj)); } - NR::Point center; + Geom::Point center; double w; double h; double x0; @@ -1238,7 +1238,7 @@ clonetiler_apply( GtkWidget */*widget*/, void * ) double cx = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-cx", 0); double cy = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-cy", 0); - center = NR::Point (cx, cy); + center = Geom::Point (cx, cy); w = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-w", 0); h = sp_repr_get_double_attribute (obj_repr, "inkscape:tile-h", 0); @@ -1257,14 +1257,14 @@ clonetiler_apply( GtkWidget */*widget*/, void * ) y0 = r->min()[NR::Y]; center = desktop->dt2doc(SP_ITEM(obj)->getCenter()); - sp_repr_set_svg_double(obj_repr, "inkscape:tile-cx", center[NR::X]); - sp_repr_set_svg_double(obj_repr, "inkscape:tile-cy", center[NR::Y]); + sp_repr_set_svg_double(obj_repr, "inkscape:tile-cx", center[Geom::X]); + sp_repr_set_svg_double(obj_repr, "inkscape:tile-cy", center[Geom::Y]); sp_repr_set_svg_double(obj_repr, "inkscape:tile-w", w); sp_repr_set_svg_double(obj_repr, "inkscape:tile-h", h); sp_repr_set_svg_double(obj_repr, "inkscape:tile-x0", x0); sp_repr_set_svg_double(obj_repr, "inkscape:tile-y0", y0); } else { - center = NR::Point(0, 0); + center = Geom::Point(0, 0); w = h = 0; x0 = y0 = 0; } @@ -1290,25 +1290,25 @@ clonetiler_apply( GtkWidget */*widget*/, void * ) // Note: We create a clone at 0,0 too, right over the original, in case our clones are colored // Get transform from symmetry, shift, scale, rotation - NR::Matrix t = clonetiler_get_transform (type, i, j, center[NR::X], center[NR::Y], w, h, - shiftx_per_i, shifty_per_i, - shiftx_per_j, shifty_per_j, - shiftx_rand, shifty_rand, - shiftx_exp, shifty_exp, - shiftx_alternate, shifty_alternate, - shiftx_cumulate, shifty_cumulate, - shiftx_excludew, shifty_excludeh, - scalex_per_i, scaley_per_i, - scalex_per_j, scaley_per_j, - scalex_rand, scaley_rand, - scalex_exp, scaley_exp, - scalex_log, scaley_log, - scalex_alternate, scaley_alternate, - scalex_cumulate, scaley_cumulate, - rotate_per_i, rotate_per_j, - rotate_rand, - rotate_alternatei, rotate_alternatej, - rotate_cumulatei, rotate_cumulatej ); + Geom::Matrix t = clonetiler_get_transform (type, i, j, center[Geom::X], center[Geom::Y], w, h, + shiftx_per_i, shifty_per_i, + shiftx_per_j, shifty_per_j, + shiftx_rand, shifty_rand, + shiftx_exp, shifty_exp, + shiftx_alternate, shifty_alternate, + shiftx_cumulate, shifty_cumulate, + shiftx_excludew, shifty_excludeh, + scalex_per_i, scaley_per_i, + scalex_per_j, scaley_per_j, + scalex_rand, scaley_rand, + scalex_exp, scaley_exp, + scalex_log, scaley_log, + scalex_alternate, scaley_alternate, + scalex_cumulate, scaley_cumulate, + rotate_per_i, rotate_per_j, + rotate_rand, + rotate_alternatei, rotate_alternatej, + rotate_cumulatei, rotate_cumulatej ); cur = center * t - center; if (fillrect) { @@ -1443,7 +1443,7 @@ clonetiler_apply( GtkWidget */*widget*/, void * ) } } if (pick_to_size) { - t = NR::translate(-center[NR::X], -center[NR::Y]) * NR::scale (val, val) * NR::translate(center[NR::X], center[NR::Y]) * t; + t = Geom::Translate(-center[Geom::X], -center[Geom::Y]) * Geom::Scale (val, val) * Geom::Translate(center[Geom::X], center[Geom::Y]) * t; } if (pick_to_opacity) { opacity *= val; @@ -1468,7 +1468,7 @@ clonetiler_apply( GtkWidget */*widget*/, void * ) clone->setAttribute("inkscape:tiled-clone-of", id_href); clone->setAttribute("xlink:href", id_href); - NR::Point new_center; + Geom::Point new_center; bool center_set = false; if (obj_repr->attribute("inkscape:transform-center-x") || obj_repr->attribute("inkscape:transform-center-y")) { new_center = desktop->dt2doc(SP_ITEM(obj)->getCenter()) * t; diff --git a/src/document.cpp b/src/document.cpp index 24b6edd20..716260b28 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -559,8 +559,8 @@ void SPDocument::fitToRect(NR::Rect const &rect) sp_document_set_width(this, w, &px); sp_document_set_height(this, h, &px); - NR::translate const tr(NR::Point(0, (old_height - h)) - - rect.min()); + Geom::Translate const tr(Geom::Point(0, (old_height - h)) + - to_2geom(rect.min())); SP_GROUP(root)->translateChildItems(tr); SPNamedView *nv = sp_document_namedview(this, 0); if(nv) { diff --git a/src/file.cpp b/src/file.cpp index dbd62a5fa..d38efb304 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -273,12 +273,12 @@ sp_file_revert_dialog() // remember current zoom and view double zoom = desktop->current_zoom(); - NR::Point c = desktop->get_display_area().midpoint(); + Geom::Point c = desktop->get_display_area().midpoint(); reverted = sp_file_open(uri,NULL); if (reverted) { // restore zoom and view - desktop->zoom_absolute(c[NR::X], c[NR::Y], zoom); + desktop->zoom_absolute(c[Geom::X], c[Geom::Y], zoom); } } else { reverted = false; @@ -990,9 +990,9 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, bool const saved_pref = prefs->getBool("options.transform", "pattern", true); prefs->setBool("options.transform", "pattern", true); sp_document_ensure_up_to_date(sp_desktop_document(desktop)); - boost::optional sel_bbox = selection->bounds(); + boost::optional sel_bbox = selection->bounds_2geom(); if (sel_bbox) { - NR::Point m( desktop->point() - sel_bbox->midpoint() ); + Geom::Point m( desktop->point() - sel_bbox->midpoint() ); sp_selection_move_relative(selection, m); } prefs->setBool("options.transform", "pattern", saved_pref); diff --git a/src/graphlayout/graphlayout.cpp b/src/graphlayout/graphlayout.cpp index ef8eaa680..2fb641316 100644 --- a/src/graphlayout/graphlayout.cpp +++ b/src/graphlayout/graphlayout.cpp @@ -230,7 +230,7 @@ void graphlayout(GSList const *const items) { if(item_box) { NR::Point const curr(item_box->midpoint()); NR::Point const dest(r->getCentreX(),r->getCentreY()); - sp_item_move_rel(u, NR::translate(dest - curr)); + sp_item_move_rel(u, Geom::Translate(dest - curr)); } } } @@ -247,3 +247,14 @@ void graphlayout(GSList const *const items) { } // vim: set cindent // vim: ts=4 sw=4 et tw=0 wm=0 + +/* + 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/interface.cpp b/src/interface.cpp index 0259ecb66..9264f4fd6 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1252,9 +1252,9 @@ sp_ui_drag_data_received(GtkWidget *widget, int const saved_pref = prefs_get_int_attribute("options.transform", "pattern", 1); prefs_set_int_attribute("options.transform", "pattern", 1); sp_document_ensure_up_to_date(sp_desktop_document(desktop)); - boost::optional sel_bbox = selection->bounds(); + boost::optional sel_bbox = selection->bounds_2geom(); if (sel_bbox) { - NR::Point m( desktop->point() - sel_bbox->midpoint() ); + Geom::Point m( desktop->point() - sel_bbox->midpoint() ); sp_selection_move_relative(selection, m); } prefs_set_int_attribute("options.transform", "pattern", saved_pref); diff --git a/src/marker.cpp b/src/marker.cpp index d77aa87d6..9f387edfb 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -24,7 +24,6 @@ #include "libnr/nr-matrix-translate-ops.h" #include "libnr/nr-scale-matrix-ops.h" #include "libnr/nr-translate-matrix-ops.h" -#include "libnr/nr-rotate-fns.h" #include "libnr/nr-convert2geom.h" #include <2geom/matrix.h> #include "svg/svg.h" @@ -635,43 +634,43 @@ sp_marker_show_instance ( SPMarker *marker, NRArenaItem *parent, unsigned int key, unsigned int pos, Geom::Matrix const &base, float linewidth) { - for (SPMarkerView *v = marker->views; v != NULL; v = v->next) { - if (v->key == key) { - if (pos >= v->size) { - return NULL; - } - if (!v->items[pos]) { - /* Parent class ::show method */ - v->items[pos] = ((SPItemClass *) parent_class)->show ((SPItem *) marker, - parent->arena, key, - SP_ITEM_REFERENCE_FLAGS); - if (v->items[pos]) { - /* 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); - } - } - if (v->items[pos]) { - NR::Matrix m; - if (marker->orient_auto) { - m = base; - } else { - /* fixme: Orient units (Lauris) */ - m = NR::Matrix(rotate_degrees(marker->orient)); - m *= NR::get_translation(base); - } - if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { - m = NR::scale(linewidth) * m; - } - - nr_arena_item_set_transform(v->items[pos], m); - } - return v->items[pos]; - } - } + for (SPMarkerView *v = marker->views; v != NULL; v = v->next) { + if (v->key == key) { + if (pos >= v->size) { + return NULL; + } + if (!v->items[pos]) { + /* Parent class ::show method */ + v->items[pos] = ((SPItemClass *) parent_class)->show ((SPItem *) marker, + parent->arena, key, + SP_ITEM_REFERENCE_FLAGS); + if (v->items[pos]) { + /* 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); + } + } + if (v->items[pos]) { + Geom::Matrix m; + if (marker->orient_auto) { + m = base; + } else { + /* fixme: Orient units (Lauris) */ + m = Geom::Matrix(Geom::Rotate::from_degrees(marker->orient)); + m *= Geom::Translate(base[4], base[5]); // TODO: this was NR::get_translation() originally; should it be extracted into a new 2geom function? + } + if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) { + m = Geom::Scale(linewidth) * m; + } + + nr_arena_item_set_transform(v->items[pos], m); + } + return v->items[pos]; + } + } - return NULL; + return NULL; } /** @@ -759,3 +758,14 @@ generate_marker (GSList *reprs, NR::Rect bounds, SPDocument *document, NR::Matri Inkscape::GC::release(repr); return mark_id; } + +/* + 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 : diff --git a/src/removeoverlap/removeoverlap.cpp b/src/removeoverlap/removeoverlap.cpp index 0562123de..c2cd6d213 100644 --- a/src/removeoverlap/removeoverlap.cpp +++ b/src/removeoverlap/removeoverlap.cpp @@ -67,7 +67,7 @@ void removeoverlap(GSList const *const items, double const xGap, double const yG NR::Point const curr = it->midpoint; NR::Point const dest(it->vspc_rect->getCentreX(), it->vspc_rect->getCentreY()); - sp_item_move_rel(it->item, NR::translate(dest - curr)); + sp_item_move_rel(it->item, Geom::Translate(dest - curr)); delete it->vspc_rect; } } diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 3bc9d6623..6bc1c54d3 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -48,7 +48,6 @@ #include #include "libnr/nr-matrix-rotate-ops.h" #include "libnr/nr-matrix-translate-ops.h" -#include "libnr/nr-rotate-fns.h" #include "libnr/nr-scale-ops.h" #include #include @@ -1144,7 +1143,7 @@ value of set_i2d==false is only used by seltrans when it's dragging objects live that case, items are already in the new position, but the repr is in the old, and this function then simply updates the repr from item->transform. */ -void sp_selection_apply_affine(Inkscape::Selection *selection, NR::Matrix const &affine, bool set_i2d) +void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix const &affine, bool set_i2d) { if (selection->isEmpty()) return; @@ -1152,7 +1151,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, NR::Matrix const for (GSList const *l = selection->itemList(); l != NULL; l = l->next) { SPItem *item = SP_ITEM(l->data); - NR::Point old_center(0,0); + Geom::Point old_center(0,0); if (set_i2d && item->isCenterSet()) old_center = item->getCenter(); @@ -1225,7 +1224,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, NR::Matrix const 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; - if ((prefs_parallel || prefs_unmoved) && affine.is_translation()) { + 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 @@ -1257,7 +1256,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, NR::Matrix const // if we're moving the actual object, not just updating the repr, we can transform the // center by the same matrix (only necessary for non-translations) - if (set_i2d && item->isCenterSet() && !affine.is_translation()) { + if (set_i2d && item->isCenterSet() && !affine.isTranslation()) { item->setCenter(old_center * affine); SP_OBJECT(item)->updateRepr(); } @@ -1306,7 +1305,7 @@ sp_selection_scale_absolute(Inkscape::Selection *selection, } -void sp_selection_scale_relative(Inkscape::Selection *selection, NR::Point const &align, NR::scale const &scale) +void sp_selection_scale_relative(Inkscape::Selection *selection, Geom::Point const &align, Geom::Scale const &scale) { if (selection->isEmpty()) return; @@ -1318,41 +1317,41 @@ void sp_selection_scale_relative(Inkscape::Selection *selection, NR::Point const } // FIXME: ARBITRARY LIMIT: don't try to scale above 1 Mpx, it won't display properly and will crash sooner or later anyway - if ( bbox->extent(NR::X) * scale[NR::X] > 1e6 || - bbox->extent(NR::Y) * scale[NR::Y] > 1e6 ) + if ( bbox->extent(NR::X) * scale[Geom::X] > 1e6 || + bbox->extent(NR::Y) * scale[Geom::Y] > 1e6 ) { return; } - NR::translate const n2d(-align); - NR::translate const d2n(align); - NR::Matrix const final( n2d * scale * d2n ); + Geom::Translate const n2d(-align); + Geom::Translate const d2n(align); + Geom::Matrix const final( n2d * scale * d2n ); sp_selection_apply_affine(selection, final); } void -sp_selection_rotate_relative(Inkscape::Selection *selection, NR::Point const ¢er, gdouble const angle_degrees) +sp_selection_rotate_relative(Inkscape::Selection *selection, Geom::Point const ¢er, gdouble const angle_degrees) { - NR::translate const d2n(center); - NR::translate const n2d(-center); - NR::rotate const rotate(rotate_degrees(angle_degrees)); - NR::Matrix const final( NR::Matrix(n2d) * rotate * d2n ); + Geom::Translate const d2n(center); + Geom::Translate const n2d(-center); + Geom::Rotate const rotate(Geom::Rotate::from_degrees(angle_degrees)); + Geom::Matrix const final( Geom::Matrix(n2d) * rotate * d2n ); sp_selection_apply_affine(selection, final); } void -sp_selection_skew_relative(Inkscape::Selection *selection, NR::Point const &align, double dx, double dy) -{ - NR::translate const d2n(align); - NR::translate const n2d(-align); - NR::Matrix const skew(1, dy, - dx, 1, - 0, 0); - NR::Matrix const final( n2d * skew * d2n ); +sp_selection_skew_relative(Inkscape::Selection *selection, Geom::Point const &align, double dx, double dy) +{ + Geom::Translate const d2n(align); + Geom::Translate const n2d(-align); + Geom::Matrix const skew(1, dy, + dx, 1, + 0, 0); + Geom::Matrix const final( n2d * skew * d2n ); sp_selection_apply_affine(selection, final); } -void sp_selection_move_relative(Inkscape::Selection *selection, NR::Point const &move) +void sp_selection_move_relative(Inkscape::Selection *selection, Geom::Point const &move) { sp_selection_apply_affine(selection, NR::Matrix(NR::translate(move))); } @@ -1362,37 +1361,10 @@ void sp_selection_move_relative(Inkscape::Selection *selection, double dx, doubl sp_selection_apply_affine(selection, NR::Matrix(NR::translate(dx, dy))); } - -/** - * \brief sp_selection_rotate_90 - * - * This function rotates selected objects 90 degrees clockwise. - * - */ - -void sp_selection_rotate_90_cw(SPDesktop *desktop) -{ - Inkscape::Selection *selection = sp_desktop_selection(desktop); - - if (selection->isEmpty()) - return; - - GSList const *l = selection->itemList(); - NR::rotate const rot_neg_90(NR::Point(0, -1)); - for (GSList const *l2 = l ; l2 != NULL ; l2 = l2->next) { - SPItem *item = SP_ITEM(l2->data); - sp_item_rotate_rel(item, rot_neg_90); - } - - sp_document_done(sp_desktop_document(desktop), SP_VERB_OBJECT_ROTATE_90_CCW, - _("Rotate 90° CW")); -} - - /** - * @brief Rotates selected objects 90 degrees counter-clockwise. + * @brief Rotates selected objects 90 degrees, either clock-wise or counter-clockwise, depending on the value of ccw */ -void sp_selection_rotate_90_ccw(SPDesktop *desktop) +void sp_selection_rotate_90(SPDesktop *desktop, bool ccw) { Inkscape::Selection *selection = sp_desktop_selection(desktop); @@ -1400,14 +1372,15 @@ void sp_selection_rotate_90_ccw(SPDesktop *desktop) return; GSList const *l = selection->itemList(); - NR::rotate const rot_neg_90(NR::Point(0, 1)); + Geom::Rotate const rot_90(NR::Point(0, ccw ? 1 : -1)); // pos. or neg. rotation, depending on the value of ccw for (GSList const *l2 = l ; l2 != NULL ; l2 = l2->next) { SPItem *item = SP_ITEM(l2->data); - sp_item_rotate_rel(item, rot_neg_90); + sp_item_rotate_rel(item, rot_90); } - sp_document_done(sp_desktop_document(desktop), SP_VERB_OBJECT_ROTATE_90_CW, - _("Rotate 90° CCW")); + sp_document_done(sp_desktop_document(desktop), + ccw ? SP_VERB_OBJECT_ROTATE_90_CCW : SP_VERB_OBJECT_ROTATE_90_CW, + ccw ? _("Rotate 90° CCW") : _("Rotate 90° CW")); } void @@ -1416,7 +1389,7 @@ sp_selection_rotate(Inkscape::Selection *selection, gdouble const angle_degrees) if (selection->isEmpty()) return; - boost::optional center = selection->center(); + boost::optional center = selection->center(); if (!center) { return; } @@ -1441,7 +1414,7 @@ sp_selection_rotate_screen(Inkscape::Selection *selection, gdouble angle) return; boost::optional const bbox(selection->bounds()); - boost::optional center = selection->center(); + boost::optional center = selection->center(); if ( !bbox || !center ) { return; @@ -1483,7 +1456,7 @@ sp_selection_scale(Inkscape::Selection *selection, gdouble grow) } double const times = 1.0 + grow / max_len; - sp_selection_scale_relative(selection, center, NR::scale(times, times)); + sp_selection_scale_relative(selection, center, Geom::Scale(times, times)); sp_document_maybe_done(sp_desktop_document(selection->desktop()), ( (grow > 0) @@ -1513,7 +1486,7 @@ sp_selection_scale_times(Inkscape::Selection *selection, gdouble times) } NR::Point const center(sel_bbox->midpoint()); - sp_selection_scale_relative(selection, center, NR::scale(times, times)); + sp_selection_scale_relative(selection, center, Geom::Scale(times, times)); sp_document_done(sp_desktop_document(selection->desktop()), SP_VERB_CONTEXT_SELECT, _("Scale by whole factor")); } @@ -2104,7 +2077,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) sp_document_ensure_up_to_date(doc); boost::optional r = selection->bounds(); - boost::optional c = selection->center(); + boost::optional c = selection->center(); if ( !r || !c || r->isEmpty() ) { return; } diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index f6e5858a8..15b6f2057 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -16,7 +16,7 @@ */ #include "forward.h" -#include "libnr/nr-forward.h" +#include "2geom/forward.h" namespace Inkscape { class Selection; } @@ -75,17 +75,16 @@ void sp_selection_paste_size_separately(SPDesktop *desktop, bool apply_x, bool a void sp_selection_to_next_layer( SPDesktop *desktop, bool suppressDone = false ); void sp_selection_to_prev_layer( SPDesktop *desktop, bool suppressDone = false ); -void sp_selection_apply_affine(Inkscape::Selection *selection, NR::Matrix const &affine, bool set_i2d = true); +void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix const &affine, bool set_i2d = true); void sp_selection_remove_transform (SPDesktop *desktop); void sp_selection_scale_absolute (Inkscape::Selection *selection, double x0, double x1, double y0, double y1); -void sp_selection_scale_relative(Inkscape::Selection *selection, NR::Point const &align, NR::scale const &scale); -void sp_selection_rotate_relative (Inkscape::Selection *selection, NR::Point const ¢er, gdouble angle); -void sp_selection_skew_relative (Inkscape::Selection *selection, NR::Point const &align, double dx, double dy); -void sp_selection_move_relative (Inkscape::Selection *selection, NR::Point const &move); +void sp_selection_scale_relative(Inkscape::Selection *selection, Geom::Point const &align, Geom::Scale const &scale); +void sp_selection_rotate_relative (Inkscape::Selection *selection, Geom::Point const ¢er, gdouble angle); +void sp_selection_skew_relative (Inkscape::Selection *selection, Geom::Point const &align, double dx, double dy); +void sp_selection_move_relative (Inkscape::Selection *selection, Geom::Point const &move); void sp_selection_move_relative (Inkscape::Selection *selection, double dx, double dy); -void sp_selection_rotate_90_cw (SPDesktop *desktop); -void sp_selection_rotate_90_ccw (SPDesktop *desktop); +void sp_selection_rotate_90 (SPDesktop *desktop, bool ccw); void sp_selection_rotate (Inkscape::Selection *selection, gdouble angle); void sp_selection_rotate_screen (Inkscape::Selection *selection, gdouble angle); diff --git a/src/selection.cpp b/src/selection.cpp index 9e134ff08..9b9b48485 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -393,6 +393,31 @@ boost::optional Selection::bounds(SPItem::BBoxType type) const return bbox; } +// TODO: This should be replaces by a proper 2geom function +inline Geom::Rect union_bounds_2geom(boost::optional const & a, Geom::Rect const &b) { + if (a) { + return union_bounds_2geom(*a, b); + } else { + return b; + } +} + +boost::optional Selection::bounds_2geom(SPItem::BBoxType type) const +{ + GSList const *items = const_cast(this)->itemList(); + + boost::optional bbox; + for ( GSList const *i = items ; i != NULL ; i = i->next ) { + bbox = union_bounds(bbox, sp_item_bbox_desktop(SP_ITEM(i->data), type)); + } + // TODO: eliminate this conversion after the switch to 2geom + boost::optional bbox_ret; + if (bbox) { + bbox_ret = to_2geom(*bbox); + } + return bbox_ret; +} + NRRect *Selection::boundsInDocument(NRRect *bbox, SPItem::BBoxType type) const { g_return_val_if_fail (bbox != NULL, NULL); @@ -420,9 +445,9 @@ boost::optional Selection::boundsInDocument(SPItem::BBoxType type) con } /** Extract the position of the center from the first selected object */ -boost::optional Selection::center() const { +boost::optional Selection::center() const { GSList *items = (GSList *) const_cast(this)->itemList(); - NR::Point center; + Geom::Point center; if (items) { SPItem *first = reinterpret_cast(g_slist_last(items)->data); // from the first item in selection if (first->isCenterSet()) { // only if set explicitly @@ -431,9 +456,9 @@ boost::optional Selection::center() const { } boost::optional bbox = bounds(); if (bbox) { - return bounds()->midpoint(); + return to_2geom(bounds()->midpoint()); } else { - return boost::optional(); + return boost::optional(); } } diff --git a/src/selection.h b/src/selection.h index f02aeb456..2e7bddf81 100644 --- a/src/selection.h +++ b/src/selection.h @@ -21,7 +21,7 @@ #include #include -#include "libnr/nr-rect.h" +//#include "libnr/nr-rect.h" #include "libnr/nr-convex-hull.h" #include "forward.h" #include "gc-managed.h" @@ -244,6 +244,7 @@ public: NRRect *bounds(NRRect *dest, SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) const; /** @brief Returns the bounding rectangle of the selection */ boost::optional bounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) const; + boost::optional bounds_2geom(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) const; /** * @brief Returns the bounding rectangle of the selection @@ -262,7 +263,7 @@ public: /** * @brief Returns the rotation/skew center of the selection */ - boost::optional center() const; + boost::optional center() const; /** * @brief Gets the selection's snap points. diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 38a9cbced..3d717e669 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -574,17 +574,17 @@ void SPGroup::_updateLayerMode(unsigned int display_key) { } } -void SPGroup::translateChildItems(NR::translate const &tr) +void SPGroup::translateChildItems(Geom::Translate const &tr) { - if (this->hasChildren()) - { - SPObject *o = NULL; - for (o = sp_object_first_child(SP_OBJECT(this)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { - if (SP_IS_ITEM (o)) { - sp_item_move_rel(static_cast(o), tr); - } - } - } + if (this->hasChildren()) + { + SPObject *o = NULL; + for (o = sp_object_first_child(SP_OBJECT(this)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) { + if (SP_IS_ITEM (o)) { + sp_item_move_rel(static_cast(o), tr); + } + } + } } CGroup::CGroup(SPGroup *group) { diff --git a/src/sp-item-group.h b/src/sp-item-group.h index 5af7a7b94..46676194c 100644 --- a/src/sp-item-group.h +++ b/src/sp-item-group.h @@ -27,34 +27,34 @@ class CGroup; namespace NR{ struct translate; } struct SPGroup : public SPLPEItem { - enum LayerMode { GROUP, LAYER }; + enum LayerMode { GROUP, LAYER }; - LayerMode _layer_mode; - std::map _display_modes; + LayerMode _layer_mode; + std::map _display_modes; - LayerMode layerMode() const { return _layer_mode; } - void setLayerMode(LayerMode mode); + LayerMode layerMode() const { return _layer_mode; } + void setLayerMode(LayerMode mode); - LayerMode effectiveLayerMode(unsigned int display_key) const { - if ( _layer_mode == LAYER ) { - return LAYER; - } else { - return layerDisplayMode(display_key); - } - } + LayerMode effectiveLayerMode(unsigned int display_key) const { + if ( _layer_mode == LAYER ) { + return LAYER; + } else { + return layerDisplayMode(display_key); + } + } - LayerMode layerDisplayMode(unsigned int display_key) const; - void setLayerDisplayMode(unsigned int display_key, LayerMode mode); - void translateChildItems(NR::translate const &tr); + LayerMode layerDisplayMode(unsigned int display_key) const; + void setLayerDisplayMode(unsigned int display_key, LayerMode mode); + void translateChildItems(Geom::Translate const &tr); CGroup *group; private: - void _updateLayerMode(unsigned int display_key=0); + void _updateLayerMode(unsigned int display_key=0); }; struct SPGroupClass { - SPLPEItemClass parent_class; + SPLPEItemClass parent_class; }; /* @@ -93,3 +93,14 @@ GSList *sp_item_group_item_list (SPGroup *group); SPObject *sp_item_group_get_child_by_name (SPGroup *group, SPObject *ref, const gchar *name); #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 : diff --git a/src/sp-item-transform.cpp b/src/sp-item-transform.cpp index fd9e9314b..0d9118ac9 100644 --- a/src/sp-item-transform.cpp +++ b/src/sp-item-transform.cpp @@ -26,11 +26,11 @@ static NR::translate inverse(NR::translate const m) } void -sp_item_rotate_rel(SPItem *item, NR::rotate const &rotation) +sp_item_rotate_rel(SPItem *item, Geom::Rotate const &rotation) { - NR::Point center = item->getCenter(); - NR::translate const s(item->getCenter()); - NR::Matrix affine = NR::Matrix(inverse(s)) * NR::Matrix(rotation) * NR::Matrix(s); + Geom::Point center = item->getCenter(); + Geom::Translate const s(item->getCenter()); + Geom::Matrix affine = Geom::Matrix(s).inverse() * Geom::Matrix(rotation) * Geom::Matrix(s); // Rotate item. sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * (Geom::Matrix)affine); @@ -44,12 +44,12 @@ sp_item_rotate_rel(SPItem *item, NR::rotate const &rotation) } void -sp_item_scale_rel (SPItem *item, NR::scale const &scale) +sp_item_scale_rel (SPItem *item, Geom::Scale const &scale) { boost::optional bbox = sp_item_bbox_desktop(item); if (bbox) { Geom::Translate const s(bbox->midpoint()); // use getCenter? - sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * s.inverse() * (Geom::Matrix)(NR::Matrix)scale * s); + sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * s.inverse() * scale * s); sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform); } } @@ -57,13 +57,13 @@ sp_item_scale_rel (SPItem *item, NR::scale const &scale) void sp_item_skew_rel (SPItem *item, double skewX, double skewY) { - NR::Point center = item->getCenter(); - NR::translate const s(item->getCenter()); + Geom::Point center = item->getCenter(); + Geom::Translate const s(item->getCenter()); - NR::Matrix const skew(1, skewY, skewX, 1, 0, 0); - NR::Matrix affine = NR::Matrix(inverse(s)) * skew * NR::Matrix(s); + Geom::Matrix const skew(1, skewY, skewX, 1, 0, 0); + Geom::Matrix affine = Geom::Matrix(s).inverse() * skew * Geom::Matrix(s); - sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * (Geom::Matrix)affine); + sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * affine); sp_item_write_transform(item, SP_OBJECT_REPR(item), item->transform); // Restore the center position (it's changed because the bbox center changed) @@ -72,7 +72,7 @@ sp_item_skew_rel (SPItem *item, double skewX, double skewY) } } -void sp_item_move_rel(SPItem *item, NR::translate const &tr) +void sp_item_move_rel(SPItem *item, Geom::Translate const &tr) { sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * tr); diff --git a/src/sp-item-transform.h b/src/sp-item-transform.h index 26258a1fe..8ce21fb32 100644 --- a/src/sp-item-transform.h +++ b/src/sp-item-transform.h @@ -2,12 +2,12 @@ #define SP_ITEM_TRANSFORM_H #include "forward.h" -#include +#include <2geom/forward.h> -void sp_item_rotate_rel(SPItem *item, NR::rotate const &rotation); -void sp_item_scale_rel (SPItem *item, NR::scale const &scale); +void sp_item_rotate_rel(SPItem *item, Geom::Rotate const &rotation); +void sp_item_scale_rel (SPItem *item, Geom::Scale const &scale); void sp_item_skew_rel (SPItem *item, double skewX, double skewY); -void sp_item_move_rel(SPItem *item, NR::translate const &tr); +void sp_item_move_rel(SPItem *item, Geom::Translate const &tr); NR::Matrix get_scale_transform_with_stroke (NR::Rect &bbox, gdouble strokewidth, bool transform_stroke, gdouble x0, gdouble y0, gdouble x1, gdouble y1); NR::Rect get_visual_bbox (boost::optional const &initial_geom_bbox, NR::Matrix const &abs_affine, gdouble const initial_strokewidth, bool const transform_stroke); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index d678200cb..cc106e8f7 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -310,12 +310,12 @@ bool SPItem::isCenterSet() { return (transform_center_x != 0 || transform_center_y != 0); } -NR::Point SPItem::getCenter() const { +Geom::Point SPItem::getCenter() const { boost::optional bbox = getBounds(sp_item_i2d_affine(this)); if (bbox) { - return bbox->midpoint() + NR::Point (this->transform_center_x, this->transform_center_y); + return to_2geom(bbox->midpoint()) + Geom::Point (this->transform_center_x, this->transform_center_y); } else { - return NR::Point (0, 0); // something's wrong! + return Geom::Point (0, 0); // something's wrong! } } diff --git a/src/sp-item.h b/src/sp-item.h index dd2a995f7..e52dbf974 100644 --- a/src/sp-item.h +++ b/src/sp-item.h @@ -141,7 +141,7 @@ struct SPItem : public SPObject { void setCenter(NR::Point object_centre); void unsetCenter(); bool isCenterSet(); - NR::Point getCenter() const; + Geom::Point getCenter() const; bool isVisibleAndUnlocked() const; diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp index 431e611c5..1e341e3d1 100644 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@ -50,7 +50,7 @@ static void sp_spiral_context_set(SPEventContext *ec, gchar const *key, gchar co static gint sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event); -static void sp_spiral_drag(SPSpiralContext *sc, NR::Point p, guint state); +static void sp_spiral_drag(SPSpiralContext *sc, Geom::Point p, guint state); static void sp_spiral_finish(SPSpiralContext *sc); static SPEventContextClass *parent_class; @@ -294,8 +294,8 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event) // motion notify coordinates as given (no snapping back to origin) event_context->within_tolerance = false; - NR::Point const motion_w(event->motion.x, event->motion.y); - Geom::Point motion_dt(to_2geom(event_context->desktop->w2d(motion_w))); + Geom::Point const motion_w(event->motion.x, event->motion.y); + Geom::Point motion_dt(event_context->desktop->w2d(motion_w)); SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop, true, sc->item); @@ -411,7 +411,7 @@ sp_spiral_context_root_handler(SPEventContext *event_context, GdkEvent *event) } static void -sp_spiral_drag(SPSpiralContext *sc, NR::Point p, guint state) +sp_spiral_drag(SPSpiralContext *sc, Geom::Point p, guint state) { SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop; diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 7bdb55d00..65cf14a95 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -142,7 +142,7 @@ private: void _createInternalClipboard(); void _discardInternalClipboard(); Inkscape::XML::Node *_createClipNode(); - NR::scale _getScale(Geom::Point const &, Geom::Point const &, Geom::Rect const &, bool, bool); + Geom::Scale _getScale(Geom::Point const &, Geom::Point const &, Geom::Rect const &, bool, bool); Glib::ustring _getBestTarget(); void _setClipboardTargets(); void _setClipboardColor(guint32); @@ -1174,7 +1174,7 @@ void ClipboardManagerImpl::_discardInternalClipboard() /** * @brief Get the scale to resize an item, based on the command and desktop state */ -NR::scale ClipboardManagerImpl::_getScale(Geom::Point const &min, Geom::Point const &max, Geom::Rect const &obj_rect, bool apply_x, bool apply_y) +Geom::Scale ClipboardManagerImpl::_getScale(Geom::Point const &min, Geom::Point const &max, Geom::Rect const &obj_rect, bool apply_x, bool apply_y) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; double scale_x = 1.0; @@ -1193,7 +1193,7 @@ NR::scale ClipboardManagerImpl::_getScale(Geom::Point const &min, Geom::Point co if (apply_y && !apply_x) scale_x = scale_y; } - return NR::scale(scale_x, scale_y); + return Geom::Scale(scale_x, scale_y); } diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index ae7f0a64b..99d3fdda3 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -232,7 +232,7 @@ private : a.sy0 * b->min()[Geom::Y] + a.sy1 * b->max()[Geom::Y]); Geom::Point const mp_rel( mp - sp ); if (LInfty(mp_rel) > 1e-9) { - sp_item_move_rel(*it, NR::translate(mp_rel)); + sp_item_move_rel(*it, Geom::Translate(mp_rel)); changed = true; } } @@ -365,7 +365,7 @@ private : if (!NR_DF_TEST_CLOSE (pos, it->bbox.min()[_orientation], 1e-6)) { Geom::Point t(0.0, 0.0); t[_orientation] = pos - it->bbox.min()[_orientation]; - sp_item_move_rel(it->item, NR::translate(t)); + sp_item_move_rel(it->item, Geom::Translate(t)); changed = true; } pos += it->bbox[_orientation].extent(); @@ -390,7 +390,7 @@ private : Geom::Point t(0.0, 0.0); t[_orientation] = pos - it.anchor; //translate - sp_item_move_rel(it.item, NR::translate(t)); + sp_item_move_rel(it.item, Geom::Translate(t)); changed = true; } } @@ -632,7 +632,7 @@ private : g_random_double_range (0, (*_dialog.randomize_bbox)[Geom::Y].extent() - (*item_box).extent(Geom::Y)); // displacement is the new center minus old: NR::Point t = NR::Point (x, y) - 0.5*(item_box->max() + item_box->min()); - sp_item_move_rel(*it, NR::translate(t)); + sp_item_move_rel(*it, Geom::Translate(t)); } } @@ -731,7 +731,7 @@ private : Geom::Point base = sorted[i]._base; Geom::Point t(0.0, 0.0); t[_orientation] = b_min[_orientation] + step * i - base[_orientation]; - sp_item_move_rel(item, NR::translate(t)); + sp_item_move_rel(item, Geom::Translate(t)); changed = true; } @@ -750,7 +750,7 @@ private : Geom::Point base = layout->characterAnchorPoint(layout->begin()) * sp_item_i2d_affine(*it); Geom::Point t(0.0, 0.0); t[_orientation] = b_min[_orientation] - base[_orientation]; - sp_item_move_rel(*it, NR::translate(t)); + sp_item_move_rel(*it, Geom::Translate(t)); changed = true; } } diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 29b6c37dd..0334b8541 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -638,7 +638,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) it < sorted.end(); it ++ ) { - sp_item_move_rel(it->item, NR::translate(move, 0)); + sp_item_move_rel(it->item, Geom::Translate(move, 0)); // move each next object by x relative to previous move += x; } @@ -662,7 +662,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) it < sorted.end(); it ++ ) { - sp_item_move_rel(it->item, NR::translate(0, move)); + sp_item_move_rel(it->item, Geom::Translate(0, move)); // move each next object by x relative to previous move += y; } @@ -689,7 +689,7 @@ Transformation::applyPageScale(Inkscape::Selection *selection) if (prefs_get_int_attribute_limited ("dialogs.transformation", "applyseparately", 0, 0, 1) == 1) { for (GSList const *l = selection->itemList(); l != NULL; l = l->next) { SPItem *item = SP_ITEM(l->data); - NR::scale scale (0,0); + Geom::Scale scale (0,0); // the values are increments! if (_units_scale.isAbsolute()) { boost::optional bbox(sp_item_bbox_desktop(item)); @@ -698,14 +698,14 @@ Transformation::applyPageScale(Inkscape::Selection *selection) if (fabs(new_width) < 1e-6) new_width = 1e-6; // not 0, as this would result in a nasty no-bbox object double new_height = scaleY; if (fabs(new_height) < 1e-6) new_height = 1e-6; - scale = NR::scale(new_width / bbox->extent(Geom::X), new_height / bbox->extent(Geom::Y)); + scale = Geom::Scale(new_width / bbox->extent(Geom::X), new_height / bbox->extent(Geom::Y)); } } else { double new_width = scaleX; if (fabs(new_width) < 1e-6) new_width = 1e-6; double new_height = scaleY; if (fabs(new_height) < 1e-6) new_height = 1e-6; - scale = NR::scale(new_width / 100.0, new_height / 100.0); + scale = Geom::Scale(new_width / 100.0, new_height / 100.0); } sp_item_scale_rel (item, scale); } @@ -713,20 +713,20 @@ Transformation::applyPageScale(Inkscape::Selection *selection) boost::optional bbox(selection->bounds()); if (bbox) { Geom::Point center(bbox->midpoint()); // use rotation center? - NR::scale scale (0,0); + Geom::Scale scale (0,0); // the values are increments! if (_units_scale.isAbsolute()) { double new_width = scaleX; if (fabs(new_width) < 1e-6) new_width = 1e-6; double new_height = scaleY; if (fabs(new_height) < 1e-6) new_height = 1e-6; - scale = NR::scale(new_width / bbox->extent(Geom::X), new_height / bbox->extent(Geom::Y)); + scale = Geom::Scale(new_width / bbox->extent(Geom::X), new_height / bbox->extent(Geom::Y)); } else { double new_width = scaleX; if (fabs(new_width) < 1e-6) new_width = 1e-6; double new_height = scaleY; if (fabs(new_height) < 1e-6) new_height = 1e-6; - scale = NR::scale(new_width / 100.0, new_height / 100.0); + scale = Geom::Scale(new_width / 100.0, new_height / 100.0); } sp_selection_scale_relative(selection, center, scale); } @@ -744,10 +744,10 @@ Transformation::applyPageRotate(Inkscape::Selection *selection) if (prefs_get_int_attribute_limited ("dialogs.transformation", "applyseparately", 0, 0, 1) == 1) { for (GSList const *l = selection->itemList(); l != NULL; l = l->next) { SPItem *item = SP_ITEM(l->data); - sp_item_rotate_rel(item, NR::rotate (angle*M_PI/180.0)); + sp_item_rotate_rel(item, Geom::Rotate (angle*M_PI/180.0)); } } else { - boost::optional center = selection->center(); + boost::optional center = selection->center(); if (center) { sp_selection_rotate_relative(selection, *center, angle); } @@ -787,7 +787,7 @@ Transformation::applyPageSkew(Inkscape::Selection *selection) } } else { // transform whole selection boost::optional bbox = selection->bounds(); - boost::optional center = selection->center(); + boost::optional center = selection->center(); if ( bbox && center ) { double width = bbox->extent(Geom::X); diff --git a/src/verbs.cpp b/src/verbs.cpp index f33019f24..be5acbd04 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1323,10 +1323,10 @@ ObjectVerb::perform( SPAction *action, void *data, void */*pdata*/ ) switch (reinterpret_cast(data)) { case SP_VERB_OBJECT_ROTATE_90_CW: - sp_selection_rotate_90_cw(dt); + sp_selection_rotate_90(dt, false); break; case SP_VERB_OBJECT_ROTATE_90_CCW: - sp_selection_rotate_90_ccw(dt); + sp_selection_rotate_90(dt, true); break; case SP_VERB_OBJECT_FLATTEN: sp_selection_remove_transform(dt); @@ -1362,7 +1362,7 @@ ObjectVerb::perform( SPAction *action, void *data, void */*pdata*/ ) // When working with the selector tool, flip the selection about its rotation center // (if it is visible) or about the center of the bounding box. } else { - sp_selection_scale_relative(sel, center, NR::scale(-1.0, 1.0)); + sp_selection_scale_relative(sel, center, Geom::Scale(-1.0, 1.0)); } sp_document_done(sp_desktop_document(dt), SP_VERB_OBJECT_FLIP_HORIZONTAL, _("Flip horizontally")); @@ -1377,7 +1377,7 @@ ObjectVerb::perform( SPAction *action, void *data, void */*pdata*/ ) SP_NODE_CONTEXT(ec)->shape_editor->flip(Geom::Y); } } else { - sp_selection_scale_relative(sel, center, NR::scale(1.0, -1.0)); + sp_selection_scale_relative(sel, center, Geom::Scale(1.0, -1.0)); } sp_document_done(sp_desktop_document(dt), SP_VERB_OBJECT_FLIP_VERTICAL, _("Flip vertically")); -- 2.30.2