From: johanengelen Date: Mon, 4 Aug 2008 22:32:05 +0000 (+0000) Subject: NR:: => Geom:: for much of src/ui and src/widgets X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=690d37ddd3470e494dde1e3ee20b942736e734d2;p=inkscape.git NR:: => Geom:: for much of src/ui and src/widgets --- diff --git a/src/dialogs/stroke-style.cpp b/src/dialogs/stroke-style.cpp index f0eccb146..7d9aa84a6 100644 --- a/src/dialogs/stroke-style.cpp +++ b/src/dialogs/stroke-style.cpp @@ -631,7 +631,7 @@ sp_marker_prev_new(unsigned psize, gchar const *mname, pixbuf = svg_preview_cache.get_preview_from_cache(key); if (pixbuf == NULL) { - pixbuf = render_pixbuf(root, sf, *dbox, psize); + pixbuf = render_pixbuf(root, sf, to_2geom(*dbox), psize); svg_preview_cache.set_preview_in_cache(key, pixbuf); } diff --git a/src/nodepath.cpp b/src/nodepath.cpp index f2ca1e84c..c5a653bf0 100644 --- a/src/nodepath.cpp +++ b/src/nodepath.cpp @@ -1602,11 +1602,11 @@ sp_node_selected_move_screen(Inkscape::NodePath::Path *nodepath, gdouble dx, gdo /** * Move selected nodes to the absolute position given */ -void sp_node_selected_move_absolute(Inkscape::NodePath::Path *nodepath, NR::Coord val, NR::Dim2 axis) +void sp_node_selected_move_absolute(Inkscape::NodePath::Path *nodepath, Geom::Coord val, Geom::Dim2 axis) { for (GList *l = nodepath->selected; l != NULL; l = l->next) { Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data; - NR::Point npos(axis == NR::X ? val : n->pos[NR::X], axis == NR::Y ? val : n->pos[NR::Y]); + Geom::Point npos(axis == Geom::X ? val : n->pos[Geom::X], axis == Geom::Y ? val : n->pos[Geom::Y]); sp_node_moveto(n, npos); } @@ -1616,9 +1616,9 @@ void sp_node_selected_move_absolute(Inkscape::NodePath::Path *nodepath, NR::Coor /** * If the coordinates of all selected nodes coincide, return the common coordinate; otherwise return NR::Nothing */ -NR::Maybe sp_node_selected_common_coord (Inkscape::NodePath::Path *nodepath, NR::Dim2 axis) +NR::Maybe sp_node_selected_common_coord (Inkscape::NodePath::Path *nodepath, Geom::Dim2 axis) { - NR::Maybe no_coord = NR::Nothing(); + NR::Maybe no_coord = NR::Nothing(); g_return_val_if_fail(nodepath->selected, no_coord); // determine coordinate of first selected node @@ -1637,7 +1637,7 @@ NR::Maybe sp_node_selected_common_coord (Inkscape::NodePath::Path *no if (coincide) { return coord; } else { - NR::Rect bbox = sp_node_selected_bbox(nodepath); + Geom::Rect bbox = sp_node_selected_bbox(nodepath); // currently we return the coordinate of the bounding box midpoint because I don't know how // to erase the spin button entry field :), but maybe this can be useful behaviour anyway return bbox.midpoint()[axis]; @@ -4285,9 +4285,9 @@ void sp_nodepath_flip (Inkscape::NodePath::Path *nodepath, NR::Dim2 axis, NR::Ma } else { // scale nodes as an "object": - NR::Rect box = sp_node_selected_bbox (nodepath); + Geom::Rect box = sp_node_selected_bbox (nodepath); if (!center) { - center = box.midpoint(); + center = from_2geom(box.midpoint()); } NR::Matrix t = NR::Matrix (NR::translate(- *center)) * @@ -4306,12 +4306,12 @@ void sp_nodepath_flip (Inkscape::NodePath::Path *nodepath, NR::Dim2 axis, NR::Ma sp_nodepath_update_repr(nodepath, _("Flip nodes")); } -NR::Rect sp_node_selected_bbox (Inkscape::NodePath::Path *nodepath) +Geom::Rect sp_node_selected_bbox (Inkscape::NodePath::Path *nodepath) { g_assert (nodepath->selected); 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 diff --git a/src/nodepath.h b/src/nodepath.h index 3f110f708..ac0c400d4 100644 --- a/src/nodepath.h +++ b/src/nodepath.h @@ -311,9 +311,9 @@ void sp_node_selected_set_type (Inkscape::NodePath::Path *nodepath, Inkscape::No void sp_node_selected_set_line_type (Inkscape::NodePath::Path *nodepath, NRPathcode code); void sp_node_selected_move (Inkscape::NodePath::Path *nodepath, gdouble dx, gdouble dy); void sp_node_selected_move_screen (Inkscape::NodePath::Path *nodepath, gdouble dx, gdouble dy); -void sp_node_selected_move_absolute (Inkscape::NodePath::Path *nodepath, NR::Coord val, NR::Dim2 axis); -NR::Rect sp_node_selected_bbox (Inkscape::NodePath::Path *nodepath); -NR::Maybe sp_node_selected_common_coord (Inkscape::NodePath::Path *nodepath, NR::Dim2 axis); +void sp_node_selected_move_absolute (Inkscape::NodePath::Path *nodepath, Geom::Coord val, Geom::Dim2 axis); +Geom::Rect sp_node_selected_bbox (Inkscape::NodePath::Path *nodepath); +NR::Maybe sp_node_selected_common_coord (Inkscape::NodePath::Path *nodepath, Geom::Dim2 axis); void sp_nodepath_show_handles(Inkscape::NodePath::Path *nodepath, bool show); //SPCanvasItem *sp_nodepath_generate_helperpath(SPDesktop *desktop, SPCurve *curve, const SPItem *item, guint32 color); diff --git a/src/ui/cache/svg_preview_cache.cpp b/src/ui/cache/svg_preview_cache.cpp index a930cfc99..aa9d045e4 100644 --- a/src/ui/cache/svg_preview_cache.cpp +++ b/src/ui/cache/svg_preview_cache.cpp @@ -32,11 +32,11 @@ #include "ui/cache/svg_preview_cache.h" -GdkPixbuf* render_pixbuf(NRArenaItem* root, double scale_factor, const NR::Rect& dbox, unsigned psize) { +GdkPixbuf* render_pixbuf(NRArenaItem* root, double scale_factor, const Geom::Rect& dbox, unsigned psize) { NRGC gc(NULL); - NR::Matrix t(NR::scale(scale_factor, scale_factor)); - nr_arena_item_set_transform(root, t); + Geom::Matrix t(Geom::Scale(scale_factor, scale_factor)); + nr_arena_item_set_transform(root, from_2geom(t)); gc.transform.set_identity(); nr_arena_item_invoke_update( root, NULL, &gc, @@ -45,10 +45,10 @@ GdkPixbuf* render_pixbuf(NRArenaItem* root, double scale_factor, const NR::Rect& /* Item integer bbox in points */ NRRectL ibox; - ibox.x0 = (int) floor(scale_factor * dbox.min()[NR::X] + 0.5); - ibox.y0 = (int) floor(scale_factor * dbox.min()[NR::Y] + 0.5); - ibox.x1 = (int) floor(scale_factor * dbox.max()[NR::X] + 0.5); - ibox.y1 = (int) floor(scale_factor * dbox.max()[NR::Y] + 0.5); + ibox.x0 = (int) floor(scale_factor * dbox.min()[Geom::X] + 0.5); + ibox.y0 = (int) floor(scale_factor * dbox.min()[Geom::Y] + 0.5); + ibox.x1 = (int) floor(scale_factor * dbox.max()[Geom::X] + 0.5); + ibox.y1 = (int) floor(scale_factor * dbox.max()[Geom::Y] + 0.5); /* Find visible area */ int width = ibox.x1 - ibox.x0; diff --git a/src/ui/cache/svg_preview_cache.h b/src/ui/cache/svg_preview_cache.h index 79ea80239..0b4d52774 100644 --- a/src/ui/cache/svg_preview_cache.h +++ b/src/ui/cache/svg_preview_cache.h @@ -11,7 +11,7 @@ * */ -GdkPixbuf* render_pixbuf(NRArenaItem* root, double scale_factor, const NR::Rect& dbox, unsigned psize); +GdkPixbuf* render_pixbuf(NRArenaItem* root, double scale_factor, const Geom::Rect& dbox, unsigned psize); namespace Inkscape { namespace UI { diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 1b9968f89..537277afc 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -44,6 +44,9 @@ #include "extension/output.h" #include "selection-chemistry.h" #include "libnr/nr-rect.h" +#include "libnr/nr-convert2geom.h" +#include <2geom/rect.h> +#include <2geom/transforms.h> #include "box3d.h" #include "gradient-drag.h" #include "sp-item.h" @@ -137,7 +140,7 @@ private: void _createInternalClipboard(); void _discardInternalClipboard(); Inkscape::XML::Node *_createClipNode(); - NR::scale _getScale(Geom::Point &, Geom::Point &, NR::Rect &, bool, bool); + NR::scale _getScale(Geom::Point const &, Geom::Point const &, Geom::Rect const &, bool, bool); Glib::ustring _getBestTarget(); void _setClipboardTargets(); void _setClipboardColor(guint32); @@ -404,7 +407,7 @@ bool ClipboardManagerImpl::pasteSize(bool separately, bool apply_x, bool apply_y SPItem *item = SP_ITEM(i->data); NR::Maybe obj_size = sp_item_bbox_desktop(item); if ( !obj_size || obj_size->isEmpty() ) continue; - sp_item_scale_rel(item, _getScale(min, max, *obj_size, apply_x, apply_y)); + sp_item_scale_rel(item, _getScale(min, max, to_2geom(*obj_size), apply_x, apply_y)); } } // resize the selection as a whole @@ -412,7 +415,7 @@ bool ClipboardManagerImpl::pasteSize(bool separately, bool apply_x, bool apply_y NR::Maybe sel_size = selection->bounds(); if ( sel_size && !sel_size->isEmpty() ) { sp_selection_scale_relative(selection, sel_size->midpoint(), - _getScale(min, max, *sel_size, apply_x, apply_y)); + _getScale(min, max, to_2geom(*sel_size), apply_x, apply_y)); } } pasted = true; @@ -765,7 +768,7 @@ void ClipboardManagerImpl::_pasteDocument(SPDocument *clipdoc, bool in_place) // this formula was discovered empyrically min[Geom::Y] += ((max[Geom::Y] - min[Geom::Y]) - sp_document_height(target_document)); - sp_selection_move_relative(selection, NR::Point(min)); + sp_selection_move_relative(selection, Geom::Point(min)); } } // copied from former sp_selection_paste in selection-chemistry.cpp @@ -773,7 +776,7 @@ void ClipboardManagerImpl::_pasteDocument(SPDocument *clipdoc, bool in_place) sp_document_ensure_up_to_date(target_document); NR::Maybe sel_size = selection->bounds(); - NR::Point m( desktop->point() ); + Geom::Point m( desktop->point() ); if (sel_size) { m -= sel_size->midpoint(); } @@ -1135,17 +1138,17 @@ void ClipboardManagerImpl::_discardInternalClipboard() /** * @brief Get the scale to resize an item, based on the command and desktop state */ -NR::scale ClipboardManagerImpl::_getScale(Geom::Point &min, Geom::Point &max, NR::Rect &obj_rect, bool apply_x, bool apply_y) +NR::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; double scale_y = 1.0; if (apply_x) { - scale_x = (max[Geom::X] - min[Geom::X]) / obj_rect.extent(NR::X); + scale_x = (max[Geom::X] - min[Geom::X]) / obj_rect[Geom::X].extent(); } if (apply_y) { - scale_y = (max[Geom::Y] - min[Geom::Y]) / obj_rect.extent(NR::Y); + scale_y = (max[Geom::Y] - min[Geom::Y]) / obj_rect[Geom::Y].extent(); } // If the "lock aspect ratio" button is pressed and we paste only a single coordinate, // resize the second one by the same ratio too diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 8c154d87a..7d4820663 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -127,7 +127,7 @@ private : selected.insert >(selected.end(), selection->itemList(), NULL); if (selected.empty()) return; - NR::Point mp; //Anchor point + Geom::Point mp; //Anchor point AlignAndDistribute::AlignTarget target = _dialog.getAlignTarget(); const Coeffs &a= _allCoeffs[_index]; switch (target) @@ -155,8 +155,8 @@ private : //Compute the anchor point NR::Maybe b = sp_item_bbox_desktop (thing); if (b) { - mp = NR::Point(a.mx0 * b->min()[NR::X] + a.mx1 * b->max()[NR::X], - a.my0 * b->min()[NR::Y] + a.my1 * b->max()[NR::Y]); + mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X], + a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]); } else { return; } @@ -164,7 +164,7 @@ private : } case AlignAndDistribute::PAGE: - mp = NR::Point(a.mx1 * sp_document_width(sp_desktop_document(desktop)), + mp = Geom::Point(a.mx1 * sp_document_width(sp_desktop_document(desktop)), a.my1 * sp_document_height(sp_desktop_document(desktop))); break; @@ -173,8 +173,8 @@ private : NR::Maybe b = sp_item_bbox_desktop ( (SPItem *) sp_document_root (sp_desktop_document (desktop)) ); if (b) { - mp = NR::Point(a.mx0 * b->min()[NR::X] + a.mx1 * b->max()[NR::X], - a.my0 * b->min()[NR::Y] + a.my1 * b->max()[NR::Y]); + mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X], + a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]); } else { return; } @@ -185,8 +185,8 @@ private : { NR::Maybe b = selection->bounds(); if (b) { - mp = NR::Point(a.mx0 * b->min()[NR::X] + a.mx1 * b->max()[NR::X], - a.my0 * b->min()[NR::Y] + a.my1 * b->max()[NR::Y]); + mp = Geom::Point(a.mx0 * b->min()[Geom::X] + a.mx1 * b->max()[Geom::X], + a.my0 * b->min()[Geom::Y] + a.my1 * b->max()[Geom::Y]); } else { return; } @@ -216,9 +216,9 @@ private : sp_document_ensure_up_to_date(sp_desktop_document (desktop)); NR::Maybe b = sp_item_bbox_desktop (*it); if (b) { - NR::Point const sp(a.sx0 * b->min()[NR::X] + a.sx1 * b->max()[NR::X], - a.sy0 * b->min()[NR::Y] + a.sy1 * b->max()[NR::Y]); - NR::Point const mp_rel( mp - sp ); + Geom::Point const sp(a.sx0 * b->min()[Geom::X] + a.sx1 * b->max()[Geom::X], + 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)); changed = true; @@ -255,7 +255,7 @@ ActionAlign::Coeffs const ActionAlign::_allCoeffs[10] = { {0., 0., 1., 0., 0., 0., 0., 1.} }; -BBoxSort::BBoxSort(SPItem *pItem, NR::Rect bounds, NR::Dim2 orientation, double kBegin, double kEnd) : +BBoxSort::BBoxSort(SPItem *pItem, Geom::Rect bounds, Geom::Dim2 orientation, double kBegin, double kEnd) : item(pItem), bbox (bounds) { @@ -281,7 +281,7 @@ public : guint row, guint column, AlignAndDistribute &dialog, bool onInterSpace, - NR::Dim2 orientation, + Geom::Dim2 orientation, double kBegin, double kEnd ): Action(id, tiptext, row, column, @@ -320,7 +320,7 @@ private : { NR::Maybe bbox = sp_item_bbox_desktop(*it); if (bbox) { - sorted.push_back(BBoxSort(*it, *bbox, _orientation, _kBegin, _kEnd)); + sorted.push_back(BBoxSort(*it, to_2geom(*bbox), _orientation, _kBegin, _kEnd)); } } //sort bbox by anchors @@ -341,7 +341,7 @@ private : float span = 0; for (unsigned int i = 0; i < len; i++) { - span += sorted[i].bbox.extent(_orientation); + span += sorted[i].bbox[_orientation].extent(); } //new distance between each bbox float step = (dist - span) / (len - 1); @@ -351,12 +351,12 @@ private : it ++ ) { if (!NR_DF_TEST_CLOSE (pos, it->bbox.min()[_orientation], 1e-6)) { - NR::Point t(0.0, 0.0); + Geom::Point t(0.0, 0.0); t[_orientation] = pos - it->bbox.min()[_orientation]; sp_item_move_rel(it->item, NR::translate(t)); changed = true; } - pos += it->bbox.extent(_orientation); + pos += it->bbox[_orientation].extent(); pos += step; } } @@ -375,7 +375,7 @@ private : //Don't move if we are really close if (!NR_DF_TEST_CLOSE (pos, it.anchor, 1e-6)) { //Compute translation - NR::Point t(0.0, 0.0); + Geom::Point t(0.0, 0.0); t[_orientation] = pos - it.anchor; //translate sp_item_move_rel(it.item, NR::translate(t)); @@ -395,7 +395,7 @@ private : guint _index; AlignAndDistribute &_dialog; bool _onInterSpace; - NR::Dim2 _orientation; + Geom::Dim2 _orientation; double _kBegin; double _kEnd; @@ -409,7 +409,7 @@ public : const Glib::ustring &tiptext, guint column, AlignAndDistribute &dialog, - NR::Dim2 orientation, bool distribute): + Geom::Dim2 orientation, bool distribute): Action(id, tiptext, 0, column, dialog.nodes_table(), dialog.tooltips(), dialog), _orientation(orientation), @@ -417,7 +417,7 @@ public : {} private : - NR::Dim2 _orientation; + Geom::Dim2 _orientation; bool _distribute; virtual void on_button_click() { @@ -427,9 +427,9 @@ private : if (!SP_IS_NODE_CONTEXT (event_context)) return ; if (_distribute) - SP_NODE_CONTEXT (event_context)->shape_editor->distribute(_orientation); + SP_NODE_CONTEXT (event_context)->shape_editor->distribute((NR::Dim2)_orientation); else - SP_NODE_CONTEXT (event_context)->shape_editor->align(_orientation); + SP_NODE_CONTEXT (event_context)->shape_editor->align((NR::Dim2)_orientation); } }; @@ -599,7 +599,7 @@ private : // nor drift on sequential randomizations. Discard cache on global (or better active // desktop's) selection_change signal. if (!_dialog.randomize_bbox) { - _dialog.randomize_bbox = *sel_bbox; + _dialog.randomize_bbox = to_2geom(*sel_bbox); } // see comment in ActionAlign above @@ -614,10 +614,10 @@ private : NR::Maybe item_box = sp_item_bbox_desktop (*it); if (item_box) { // find new center, staying within bbox - double x = _dialog.randomize_bbox->min()[NR::X] + item_box->extent(NR::X)/2 + - g_random_double_range (0, _dialog.randomize_bbox->extent(NR::X) - item_box->extent(NR::X)); - double y = _dialog.randomize_bbox->min()[NR::Y] + item_box->extent(NR::Y)/2 + - g_random_double_range (0, _dialog.randomize_bbox->extent(NR::Y) - item_box->extent(NR::Y)); + double x = _dialog.randomize_bbox->min()[Geom::X] + (*item_box).extent(Geom::X)/2 + + g_random_double_range (0, (*_dialog.randomize_bbox)[Geom::X].extent() - (*item_box).extent(Geom::X)); + double y = _dialog.randomize_bbox->min()[Geom::Y] + (*item_box).extent(Geom::Y)/2 + + 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)); @@ -635,9 +635,9 @@ private : struct Baselines { SPItem *_item; - NR::Point _base; - NR::Dim2 _orientation; - Baselines(SPItem *item, NR::Point base, NR::Dim2 orientation) : + Geom::Point _base; + Geom::Dim2 _orientation; + Baselines(SPItem *item, Geom::Point base, Geom::Dim2 orientation) : _item (item), _base (base), _orientation (orientation) @@ -657,7 +657,7 @@ public : guint column, AlignAndDistribute &dialog, Gtk::Table &table, - NR::Dim2 orientation, bool distribute): + Geom::Dim2 orientation, bool distribute): Action(id, tiptext, row, column, table, dialog.tooltips(), dialog), _orientation(orientation), @@ -665,7 +665,7 @@ public : {} private : - NR::Dim2 _orientation; + Geom::Dim2 _orientation; bool _distribute; virtual void on_button_click() { @@ -683,8 +683,8 @@ private : //Check 2 or more selected objects if (selected.size() < 2) return; - NR::Point b_min = NR::Point (HUGE_VAL, HUGE_VAL); - NR::Point b_max = NR::Point (-HUGE_VAL, -HUGE_VAL); + Geom::Point b_min = Geom::Point (HUGE_VAL, HUGE_VAL); + Geom::Point b_max = Geom::Point (-HUGE_VAL, -HUGE_VAL); std::vector sorted; @@ -694,11 +694,11 @@ private : { if (SP_IS_TEXT (*it) || SP_IS_FLOWTEXT (*it)) { Inkscape::Text::Layout const *layout = te_get_layout(*it); - NR::Point base = layout->characterAnchorPoint(layout->begin()) * from_2geom(sp_item_i2d_affine(*it)); - if (base[NR::X] < b_min[NR::X]) b_min[NR::X] = base[NR::X]; - if (base[NR::Y] < b_min[NR::Y]) b_min[NR::Y] = base[NR::Y]; - if (base[NR::X] > b_max[NR::X]) b_max[NR::X] = base[NR::X]; - if (base[NR::Y] > b_max[NR::Y]) b_max[NR::Y] = base[NR::Y]; + Geom::Point base = layout->characterAnchorPoint(layout->begin()) * from_2geom(sp_item_i2d_affine(*it)); + if (base[Geom::X] < b_min[Geom::X]) b_min[Geom::X] = base[Geom::X]; + if (base[Geom::Y] < b_min[Geom::Y]) b_min[Geom::Y] = base[Geom::Y]; + if (base[Geom::X] > b_max[Geom::X]) b_max[Geom::X] = base[Geom::X]; + if (base[Geom::Y] > b_max[Geom::Y]) b_max[Geom::Y] = base[Geom::Y]; Baselines b (*it, base, _orientation); sorted.push_back(b); @@ -716,8 +716,8 @@ private : double step = (b_max[_orientation] - b_min[_orientation])/(sorted.size() - 1); for (unsigned int i = 0; i < sorted.size(); i++) { SPItem *item = sorted[i]._item; - NR::Point base = sorted[i]._base; - NR::Point t(0.0, 0.0); + 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)); changed = true; @@ -735,8 +735,8 @@ private : { if (SP_IS_TEXT (*it) || SP_IS_FLOWTEXT (*it)) { Inkscape::Text::Layout const *layout = te_get_layout(*it); - NR::Point base = layout->characterAnchorPoint(layout->begin()) * from_2geom(sp_item_i2d_affine(*it)); - NR::Point t(0.0, 0.0); + Geom::Point base = layout->characterAnchorPoint(layout->begin()) * from_2geom(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)); changed = true; @@ -821,47 +821,47 @@ AlignAndDistribute::AlignAndDistribute() //Baseline aligns addBaselineButton("al_baselines_vert", _("Align baseline anchors of texts vertically"), - 0, 5, this->align_table(), NR::X, false); + 0, 5, this->align_table(), Geom::X, false); addBaselineButton("al_baselines_hor", _("Align baseline anchors of texts horizontally"), - 1, 5, this->align_table(), NR::Y, false); + 1, 5, this->align_table(), Geom::Y, false); //The distribute buttons addDistributeButton("distribute_hdist", _("Make horizontal gaps between objects equal"), - 0, 4, true, NR::X, .5, .5); + 0, 4, true, Geom::X, .5, .5); addDistributeButton("distribute_left", _("Distribute left sides equidistantly"), - 0, 1, false, NR::X, 1., 0.); + 0, 1, false, Geom::X, 1., 0.); addDistributeButton("distribute_hcentre", _("Distribute centers equidistantly horizontally"), - 0, 2, false, NR::X, .5, .5); + 0, 2, false, Geom::X, .5, .5); addDistributeButton("distribute_right", _("Distribute right sides equidistantly"), - 0, 3, false, NR::X, 0., 1.); + 0, 3, false, Geom::X, 0., 1.); addDistributeButton("distribute_vdist", _("Make vertical gaps between objects equal"), - 1, 4, true, NR::Y, .5, .5); + 1, 4, true, Geom::Y, .5, .5); addDistributeButton("distribute_top", _("Distribute tops equidistantly"), - 1, 1, false, NR::Y, 0, 1); + 1, 1, false, Geom::Y, 0, 1); addDistributeButton("distribute_vcentre", _("Distribute centers equidistantly vertically"), - 1, 2, false, NR::Y, .5, .5); + 1, 2, false, Geom::Y, .5, .5); addDistributeButton("distribute_bottom", _("Distribute bottoms equidistantly"), - 1, 3, false, NR::Y, 1., 0.); + 1, 3, false, Geom::Y, 1., 0.); //Baseline distribs addBaselineButton("distribute_baselines_hor", _("Distribute baseline anchors of texts horizontally"), - 0, 5, this->distribute_table(), NR::X, true); + 0, 5, this->distribute_table(), Geom::X, true); addBaselineButton("distribute_baselines_vert", _("Distribute baseline anchors of texts vertically"), - 1, 5, this->distribute_table(), NR::Y, true); + 1, 5, this->distribute_table(), Geom::Y, true); //Randomize & Unclump addRandomizeButton("distribute_randomize", @@ -883,16 +883,16 @@ AlignAndDistribute::AlignAndDistribute() //Node Mode buttons addNodeButton("node_halign", _("Align selected nodes horizontally"), - 0, NR::X, false); + 0, Geom::X, false); addNodeButton("node_valign", _("Align selected nodes vertically"), - 1, NR::Y, false); + 1, Geom::Y, false); addNodeButton("node_hdistribute", _("Distribute selected nodes horizontally"), - 2, NR::X, true); + 2, Geom::X, true); addNodeButton("node_vdistribute", _("Distribute selected nodes vertically"), - 3, NR::Y, true); + 3, Geom::Y, true); //Rest of the widgetry @@ -990,7 +990,7 @@ void AlignAndDistribute::addAlignButton(const Glib::ustring &id, const Glib::ust } void AlignAndDistribute::addDistributeButton(const Glib::ustring &id, const Glib::ustring tiptext, guint row, guint col, bool onInterSpace, - NR::Dim2 orientation, float kBegin, float kEnd) + Geom::Dim2 orientation, float kBegin, float kEnd) { _actionList.push_back( new ActionDistribute( @@ -1002,7 +1002,7 @@ void AlignAndDistribute::addDistributeButton(const Glib::ustring &id, const Glib } void AlignAndDistribute::addNodeButton(const Glib::ustring &id, const Glib::ustring tiptext, - guint col, NR::Dim2 orientation, bool distribute) + guint col, Geom::Dim2 orientation, bool distribute) { _actionList.push_back( new ActionNode( @@ -1047,7 +1047,7 @@ void AlignAndDistribute::addRandomizeButton(const Glib::ustring &id, const Glib: } void AlignAndDistribute::addBaselineButton(const Glib::ustring &id, const Glib::ustring tiptext, - guint row, guint col, Gtk::Table &table, NR::Dim2 orientation, bool distribute) + guint row, guint col, Gtk::Table &table, Geom::Dim2 orientation, bool distribute) { _actionList.push_back( new ActionBaseline( @@ -1075,7 +1075,7 @@ std::list::iterator AlignAndDistribute::find_master( std::list::iterator it = list.begin(); it != list.end(); it++) { NR::Maybe b = sp_item_bbox_desktop (*it); if (b) { - gdouble dim = b->extent(horizontal ? NR::X : NR::Y); + gdouble dim = (*b).extent(horizontal ? Geom::X : Geom::Y); if (dim > max) { max = dim; master = it; @@ -1092,7 +1092,7 @@ std::list::iterator AlignAndDistribute::find_master( std::list::iterator it = list.begin(); it != list.end(); it++) { NR::Maybe b = sp_item_bbox_desktop (*it); if (b) { - gdouble dim = b->extent(horizontal ? NR::X : NR::Y); + gdouble dim = (*b).extent(horizontal ? Geom::X : Geom::Y); if (dim < max) { max = dim; master = it; diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h index d6cbd377f..c29fd7c0d 100644 --- a/src/ui/dialog/align-and-distribute.h +++ b/src/ui/dialog/align-and-distribute.h @@ -65,18 +65,18 @@ public: std::list::iterator find_master(std::list &list, bool horizontal); void setMode(bool nodeEdit); - NR::Maybe randomize_bbox; + NR::Maybe randomize_bbox; protected: void on_ref_change(); void addDistributeButton(const Glib::ustring &id, const Glib::ustring tiptext, guint row, guint col, bool onInterSpace, - NR::Dim2 orientation, float kBegin, float kEnd); + Geom::Dim2 orientation, float kBegin, float kEnd); void addAlignButton(const Glib::ustring &id, const Glib::ustring tiptext, guint row, guint col); void addNodeButton(const Glib::ustring &id, const Glib::ustring tiptext, - guint col, NR::Dim2 orientation, bool distribute); + guint col, Geom::Dim2 orientation, bool distribute); void addRemoveOverlapsButton(const Glib::ustring &id, const Glib::ustring tiptext, guint row, guint col); @@ -88,7 +88,7 @@ protected: void addRandomizeButton(const Glib::ustring &id, const Glib::ustring tiptext, guint row, guint col); void addBaselineButton(const Glib::ustring &id, const Glib::ustring tiptext, - guint row, guint col, Gtk::Table &table, NR::Dim2 orientation, bool distribute); + guint row, guint col, Gtk::Table &table, Geom::Dim2 orientation, bool distribute); std::list _actionList; Gtk::Frame _alignFrame, _distributeFrame, _removeOverlapFrame, _graphLayoutFrame, _nodesFrame; @@ -109,8 +109,8 @@ struct BBoxSort { SPItem *item; float anchor; - NR::Rect bbox; - BBoxSort(SPItem *pItem, NR::Rect bounds, NR::Dim2 orientation, double kBegin, double kEnd); + Geom::Rect bbox; + BBoxSort(SPItem *pItem, Geom::Rect bounds, Geom::Dim2 orientation, double kBegin, double kEnd); BBoxSort(const BBoxSort &rhs); }; bool operator< (const BBoxSort &a, const BBoxSort &b); diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index d6624828c..c726b0454 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -861,12 +861,12 @@ bool FileOpenDialogImplWin32::set_svg_preview() const double scaledSvgWidth = scaleFactor * svgWidth; const double scaledSvgHeight = scaleFactor * svgHeight; - NR::Rect area(NR::Point(0, 0), NR::Point(scaledSvgWidth, scaledSvgHeight)); + Geom::Rect area(Geom::Point(0, 0), Geom::Point(scaledSvgWidth, scaledSvgHeight)); NRRectL areaL = {0, 0, scaledSvgWidth, scaledSvgHeight}; NRRectL bbox = {0, 0, scaledSvgWidth, scaledSvgHeight}; // write object bbox to area - NR::Maybe maybeArea(area); + NR::Maybe maybeArea(from_2geom(area)); sp_document_ensure_up_to_date (svgDoc); sp_item_invoke_bbox((SPItem *) svgDoc->root, &maybeArea, from_2geom(sp_item_i2r_affine((SPItem *)(svgDoc->root))), TRUE); @@ -879,7 +879,7 @@ bool FileOpenDialogImplWin32::set_svg_preview() arena, key, SP_ITEM_SHOW_DISPLAY); NRGC gc(NULL); - gc.transform = NR::Matrix(NR::scale(scaleFactor, scaleFactor)); + gc.transform = from_2geom(Geom::Matrix(Geom::Scale(scaleFactor, scaleFactor))); nr_arena_item_invoke_update (root, NULL, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE); diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 8dcda8dfb..8c12df558 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -459,8 +459,8 @@ Transformation::updatePageMove(Inkscape::Selection *selection) if (!_check_move_relative.get_active()) { NR::Maybe bbox = selection->bounds(); if (bbox) { - double x = bbox->min()[NR::X]; - double y = bbox->min()[NR::Y]; + double x = bbox->min()[Geom::X]; + double y = bbox->min()[Geom::Y]; _scalar_move_horizontal.setValue(x, "px"); _scalar_move_vertical.setValue(y, "px"); @@ -480,8 +480,8 @@ Transformation::updatePageScale(Inkscape::Selection *selection) if (selection && !selection->isEmpty()) { NR::Maybe bbox = selection->bounds(); if (bbox) { - double w = bbox->extent(NR::X); - double h = bbox->extent(NR::Y); + double w = bbox->extent(Geom::X); + double h = bbox->extent(Geom::Y); _scalar_scale_horizontal.setHundredPercent(w); _scalar_scale_vertical.setHundredPercent(h); onScaleXValueChanged(); // to update x/y proportionality if switch is on @@ -510,8 +510,8 @@ Transformation::updatePageSkew(Inkscape::Selection *selection) if (selection && !selection->isEmpty()) { NR::Maybe bbox = selection->bounds(); if (bbox) { - double w = bbox->extent(NR::X); - double h = bbox->extent(NR::Y); + double w = bbox->extent(Geom::X); + double h = bbox->extent(Geom::Y); _scalar_skew_vertical.setHundredPercent(w); _scalar_skew_horizontal.setHundredPercent(h); _page_skew.set_sensitive(true); @@ -528,9 +528,9 @@ Transformation::updatePageTransform(Inkscape::Selection *selection) { if (selection && !selection->isEmpty()) { if (_check_replace_matrix.get_active()) { - NR::Matrix current (SP_ITEM(selection->itemList()->data)->transform); // take from the first item in selection + Geom::Matrix current (to_2geom(SP_ITEM(selection->itemList()->data)->transform)); // take from the first item in selection - NR::Matrix new_displayed = current; + Geom::Matrix new_displayed = current; _scalar_transform_a.setValue(new_displayed[0]); _scalar_transform_b.setValue(new_displayed[1]); @@ -607,7 +607,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) NR::Maybe bbox = selection->bounds(); if (bbox) { sp_selection_move_relative(selection, - x - bbox->min()[NR::X], y - bbox->min()[NR::Y]); + x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]); } } } else { @@ -627,7 +627,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) { NR::Maybe bbox = sp_item_bbox_desktop(*it); if (bbox) { - sorted.push_back(BBoxSort(*it, *bbox, NR::X, x > 0? 1. : 0., x > 0? 0. : 1.)); + sorted.push_back(BBoxSort(*it, to_2geom(*bbox), Geom::X, x > 0? 1. : 0., x > 0? 0. : 1.)); } } //sort bbox by anchors @@ -651,7 +651,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) { NR::Maybe bbox = sp_item_bbox_desktop(*it); if (bbox) { - sorted.push_back(BBoxSort(*it, *bbox, NR::Y, y > 0? 1. : 0., y > 0? 0. : 1.)); + sorted.push_back(BBoxSort(*it, to_2geom(*bbox), Geom::Y, y > 0? 1. : 0., y > 0? 0. : 1.)); } } //sort bbox by anchors @@ -671,7 +671,7 @@ Transformation::applyPageMove(Inkscape::Selection *selection) NR::Maybe bbox = selection->bounds(); if (bbox) { sp_selection_move_relative(selection, - x - bbox->min()[NR::X], y - bbox->min()[NR::Y]); + x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]); } } } @@ -698,7 +698,7 @@ 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(NR::X), new_height / bbox->extent(NR::Y)); + scale = NR::scale(new_width / bbox->extent(Geom::X), new_height / bbox->extent(Geom::Y)); } } else { double new_width = scaleX; @@ -712,7 +712,7 @@ Transformation::applyPageScale(Inkscape::Selection *selection) } else { NR::Maybe bbox(selection->bounds()); if (bbox) { - NR::Point center(bbox->midpoint()); // use rotation center? + Geom::Point center(bbox->midpoint()); // use rotation center? NR::scale scale (0,0); // the values are increments! if (_units_scale.isAbsolute()) { @@ -720,7 +720,7 @@ Transformation::applyPageScale(Inkscape::Selection *selection) 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(NR::X), new_height / bbox->extent(NR::Y)); + scale = NR::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; @@ -779,8 +779,8 @@ Transformation::applyPageSkew(Inkscape::Selection *selection) double skewY = _scalar_skew_vertical.getValue("px"); NR::Maybe bbox(sp_item_bbox_desktop(item)); if (bbox) { - double width = bbox->extent(NR::X); - double height = bbox->extent(NR::Y); + double width = bbox->extent(Geom::X); + double height = bbox->extent(Geom::Y); sp_item_skew_rel (item, skewX/height, skewY/width); } } @@ -790,8 +790,8 @@ Transformation::applyPageSkew(Inkscape::Selection *selection) NR::Maybe center = selection->center(); if ( bbox && center ) { - double width = bbox->extent(NR::X); - double height = bbox->extent(NR::Y); + double width = bbox->extent(Geom::X); + double height = bbox->extent(Geom::Y); if (!_units_skew.isAbsolute()) { // percentage double skewX = _scalar_skew_horizontal.getValue("%"); @@ -874,12 +874,12 @@ Transformation::onMoveRelativeToggled() if (bbox) { if (_check_move_relative.get_active()) { // From absolute to relative - _scalar_move_horizontal.setValue(x - bbox->min()[NR::X], "px"); - _scalar_move_vertical.setValue( y - bbox->min()[NR::Y], "px"); + _scalar_move_horizontal.setValue(x - bbox->min()[Geom::X], "px"); + _scalar_move_vertical.setValue( y - bbox->min()[Geom::Y], "px"); } else { // From relative to absolute - _scalar_move_horizontal.setValue(bbox->min()[NR::X] + x, "px"); - _scalar_move_vertical.setValue( bbox->min()[NR::Y] + y, "px"); + _scalar_move_horizontal.setValue(bbox->min()[Geom::X] + x, "px"); + _scalar_move_vertical.setValue( bbox->min()[Geom::Y] + y, "px"); } } @@ -972,10 +972,10 @@ Transformation::onReplaceMatrixToggled() double e = _scalar_transform_e.getValue(); double f = _scalar_transform_f.getValue(); - NR::Matrix displayed (a, b, c, d, e, f); - NR::Matrix current (SP_ITEM(selection->itemList()->data)->transform); // take from the first item in selection + Geom::Matrix displayed (a, b, c, d, e, f); + Geom::Matrix current = to_2geom(SP_ITEM(selection->itemList()->data)->transform); // take from the first item in selection - NR::Matrix new_displayed; + Geom::Matrix new_displayed; if (_check_replace_matrix.get_active()) { new_displayed = current; } else { @@ -1011,8 +1011,8 @@ Transformation::onClear() } else { NR::Maybe bbox = selection->bounds(); if (bbox) { - _scalar_move_horizontal.setValue(bbox->min()[NR::X], "px"); - _scalar_move_vertical.setValue(bbox->min()[NR::Y], "px"); + _scalar_move_horizontal.setValue(bbox->min()[Geom::X], "px"); + _scalar_move_vertical.setValue(bbox->min()[Geom::Y], "px"); } } break; diff --git a/src/ui/view/edit-widget-interface.h b/src/ui/view/edit-widget-interface.h index f148bb715..7456f4adf 100644 --- a/src/ui/view/edit-widget-interface.h +++ b/src/ui/view/edit-widget-interface.h @@ -50,13 +50,13 @@ struct EditWidgetInterface virtual void setSize (gint w, gint h) = 0; /// Move widget to specified position - virtual void setPosition (NR::Point p) = 0; + virtual void setPosition (Geom::Point p) = 0; /// Transientize widget virtual void setTransient (void*, int) = 0; /// Return mouse position in widget - virtual NR::Point getPointer() = 0; + virtual Geom::Point getPointer() = 0; /// Make widget iconified virtual void setIconified() = 0; @@ -96,7 +96,7 @@ struct EditWidgetInterface virtual void deactivateDesktop() = 0; /// Set rulers to position - virtual void viewSetPosition (NR::Point p) = 0; + virtual void viewSetPosition (Geom::Point p) = 0; /// Update rulers from current values virtual void updateRulers() = 0; @@ -132,7 +132,7 @@ struct EditWidgetInterface virtual bool isToolboxButtonActive (gchar const*) = 0; /// Set the coordinate display - virtual void setCoordinateStatus (NR::Point p) = 0; + virtual void setCoordinateStatus (Geom::Point p) = 0; /// Message widget will get no content virtual void setMessage (Inkscape::MessageType type, gchar const* msg) = 0; diff --git a/src/ui/view/edit-widget.cpp b/src/ui/view/edit-widget.cpp index c32b5f9de..423d8e820 100644 --- a/src/ui/view/edit-widget.cpp +++ b/src/ui/view/edit-widget.cpp @@ -1149,9 +1149,9 @@ EditWidget::setSize (gint w, gint h) } void -EditWidget::setPosition (NR::Point p) +EditWidget::setPosition (Geom::Point p) { - move (int(p[NR::X]), int(p[NR::Y])); + move (int(p[Geom::X]), int(p[Geom::Y])); } /// \param p is already gobj()! @@ -1163,12 +1163,12 @@ EditWidget::setTransient (void* p, int i) this->Gtk::Window::present(); } -NR::Point +Geom::Point EditWidget::getPointer() { int x, y; get_pointer (x, y); - return NR::Point (x, y); + return Geom::Point (x, y); } void @@ -1357,34 +1357,34 @@ EditWidget::deactivateDesktop() } void -EditWidget::viewSetPosition (NR::Point p) +EditWidget::viewSetPosition (Geom::Point p) { // p -= _namedview->gridorigin; /// \todo Why was the origin corrected for the grid origin? (johan) double lo, up, pos, max; _top_ruler.get_range (lo, up, pos, max); - _top_ruler.set_range (lo, up, p[NR::X], max); + _top_ruler.set_range (lo, up, p[Geom::X], max); _left_ruler.get_range (lo, up, pos, max); - _left_ruler.set_range (lo, up, p[NR::Y], max); + _left_ruler.set_range (lo, up, p[Geom::Y], max); } void EditWidget::updateRulers() { - //NR::Point gridorigin = _namedview->gridorigin; + //Geom::Point gridorigin = _namedview->gridorigin; /// \todo Why was the origin corrected for the grid origin? (johan) - NR::Rect const viewbox = _svg_canvas.spobj()->getViewbox(); + Geom::Rect const viewbox = to_2geom(_svg_canvas.spobj()->getViewbox()); double lo, up, pos, max; double const scale = _desktop->current_zoom(); - double s = viewbox.min()[NR::X] / scale; //- gridorigin[NR::X]; - double e = viewbox.max()[NR::X] / scale; //- gridorigin[NR::X]; + double s = viewbox.min()[Geom::X] / scale; //- gridorigin[Geom::X]; + double e = viewbox.max()[Geom::X] / scale; //- gridorigin[Geom::X]; _top_ruler.get_range(lo, up, pos, max); _top_ruler.set_range(s, e, pos, e); - s = viewbox.min()[NR::Y] / -scale; //- gridorigin[NR::Y]; - e = viewbox.max()[NR::Y] / -scale; //- gridorigin[NR::Y]; - _left_ruler.set_range(s, e, 0 /*gridorigin[NR::Y]*/, e); + s = viewbox.min()[Geom::Y] / -scale; //- gridorigin[Geom::Y]; + e = viewbox.max()[Geom::Y] / -scale; //- gridorigin[Geom::Y]; + _left_ruler.set_range(s, e, 0 /*gridorigin[Geom::Y]*/, e); /// \todo is that correct? } @@ -1400,17 +1400,13 @@ EditWidget::updateScrollbars (double scale) /* The desktop region we always show unconditionally */ SPDocument *doc = _desktop->doc(); - NR::Rect darea = NR::Rect(NR::Point(-sp_document_width(doc), - -sp_document_height(doc)), - NR::Point(2 * sp_document_width(doc), - 2 * sp_document_height(doc))); + NR::Rect darea ( Geom::Point(-sp_document_width(doc), -sp_document_height(doc)), + Geom::Point(2 * sp_document_width(doc), 2 * sp_document_height(doc)) ); darea = NR::union_bounds(darea, sp_item_bbox_desktop(SP_ITEM(SP_DOCUMENT_ROOT(doc)))); /* Canvas region we always show unconditionally */ - NR::Rect carea(NR::Point(darea.min()[NR::X] * scale - 64, - darea.max()[NR::Y] * -scale - 64), - NR::Point(darea.max()[NR::X] * scale + 64, - darea.min()[NR::Y] * -scale + 64)); + 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(); @@ -1418,20 +1414,20 @@ EditWidget::updateScrollbars (double scale) carea = NR::union_bounds(carea, viewbox); Gtk::Adjustment *adj = _bottom_scrollbar.get_adjustment(); - adj->set_value(viewbox.min()[NR::X]); - adj->set_lower(carea.min()[NR::X]); - adj->set_upper(carea.max()[NR::X]); - adj->set_page_increment(viewbox.dimensions()[NR::X]); - adj->set_step_increment(0.1 * (viewbox.dimensions()[NR::X])); - adj->set_page_size(viewbox.dimensions()[NR::X]); + adj->set_value(viewbox.min()[Geom::X]); + adj->set_lower(carea.min()[Geom::X]); + adj->set_upper(carea.max()[Geom::X]); + adj->set_page_increment(viewbox.dimensions()[Geom::X]); + adj->set_step_increment(0.1 * (viewbox.dimensions()[Geom::X])); + adj->set_page_size(viewbox.dimensions()[Geom::X]); adj = _right_scrollbar.get_adjustment(); - adj->set_value(viewbox.min()[NR::Y]); - adj->set_lower(carea.min()[NR::Y]); - adj->set_upper(carea.max()[NR::Y]); - adj->set_page_increment(viewbox.dimensions()[NR::Y]); - adj->set_step_increment(0.1 * viewbox.dimensions()[NR::Y]); - adj->set_page_size(viewbox.dimensions()[NR::Y]); + adj->set_value(viewbox.min()[Geom::Y]); + adj->set_lower(carea.min()[Geom::Y]); + adj->set_upper(carea.max()[Geom::Y]); + adj->set_page_increment(viewbox.dimensions()[Geom::Y]); + adj->set_step_increment(0.1 * viewbox.dimensions()[Geom::Y]); + adj->set_page_size(viewbox.dimensions()[Geom::Y]); _update_s_f = false; } @@ -1509,12 +1505,12 @@ EditWidget::isToolboxButtonActive (gchar const*) } void -EditWidget::setCoordinateStatus (NR::Point p) +EditWidget::setCoordinateStatus (Geom::Point p) { - gchar *cstr = g_strdup_printf ("%6.2f", _dt2r * p[NR::X]); + gchar *cstr = g_strdup_printf ("%6.2f", _dt2r * p[Geom::X]); _coord_status_x.property_label() = cstr; g_free (cstr); - cstr = g_strdup_printf ("%6.2f", _dt2r * p[NR::Y]); + cstr = g_strdup_printf ("%6.2f", _dt2r * p[Geom::Y]); _coord_status_y.property_label() = cstr; g_free (cstr); } @@ -1646,32 +1642,32 @@ EditWidget::onWindowSizeAllocate (Gtk::Allocation &newall) return; } - NR::Rect const area = _desktop->get_display_area(); + Geom::Rect const area = to_2geom(_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()[NR::X], area.dimensions()[NR::Y]); + double const zpsp = zoom / hypot(area.dimensions()[Geom::X], area.dimensions()[Geom::Y]); /* Find new visible area */ - NR::Rect const newarea = _desktop->get_display_area(); + Geom::Rect const newarea = to_2geom(_desktop->get_display_area()); /* Calculate adjusted zoom */ - zoom = zpsp * hypot(newarea.dimensions()[NR::X], newarea.dimensions()[NR::Y]); + zoom = zpsp * hypot(newarea.dimensions()[Geom::X], newarea.dimensions()[Geom::Y]); } - _desktop->zoom_absolute(area.midpoint()[NR::X], area.midpoint()[NR::Y], zoom); + _desktop->zoom_absolute(area.midpoint()[Geom::X], area.midpoint()[Geom::Y], zoom); } void EditWidget::onWindowRealize() { - NR::Rect d(NR::Point(0, 0), - NR::Point(sp_document_width(_desktop->doc()), sp_document_height(_desktop->doc()))); + NR::Rect d(Geom::Point(0, 0), + Geom::Point(sp_document_width(_desktop->doc()), sp_document_height(_desktop->doc()))); if (d.isEmpty(1.0)) { return; } - _desktop->set_display_area(d.min()[NR::X], d.min()[NR::Y], d.max()[NR::X], d.max()[NR::Y], 10); + _desktop->set_display_area(d.min()[Geom::X], d.min()[Geom::Y], d.max()[Geom::X], d.max()[Geom::Y], 10); _namedview_modified(_desktop->namedview, SP_OBJECT_MODIFIED_FLAG); setTitle (SP_DOCUMENT_NAME(_desktop->doc())); } diff --git a/src/ui/view/edit-widget.h b/src/ui/view/edit-widget.h index e665b2fae..ea3205696 100644 --- a/src/ui/view/edit-widget.h +++ b/src/ui/view/edit-widget.h @@ -104,9 +104,9 @@ public: virtual void present(); virtual void getGeometry (gint &x, gint &y, gint &w, gint &h); virtual void setSize (gint w, gint h); - virtual void setPosition (NR::Point p); + virtual void setPosition (Geom::Point p); virtual void setTransient (void*, int); - virtual NR::Point getPointer(); + virtual Geom::Point getPointer(); virtual void setIconified(); virtual void setMaximized(); virtual void setFullscreen(); @@ -118,7 +118,7 @@ public: virtual void disableInteraction(); virtual void activateDesktop(); virtual void deactivateDesktop(); - virtual void viewSetPosition (NR::Point p); + virtual void viewSetPosition (Geom::Point p); virtual void updateRulers(); virtual void updateScrollbars (double scale); virtual void toggleRulers(); @@ -130,7 +130,7 @@ public: virtual void setToolboxAdjustmentValue (const gchar *, double); virtual void setToolboxSelectOneValue (const gchar *, gint); virtual bool isToolboxButtonActive (gchar const*); - virtual void setCoordinateStatus (NR::Point p); + virtual void setCoordinateStatus (Geom::Point p); virtual void setMessage (Inkscape::MessageType type, gchar const* msg); virtual bool warnDialog (gchar*); diff --git a/src/ui/view/view.cpp b/src/ui/view/view.cpp index 6b6e0b8b6..75b6c453b 100644 --- a/src/ui/view/view.cpp +++ b/src/ui/view/view.cpp @@ -112,9 +112,9 @@ void View::setPosition (double x, double y) _position_set_signal.emit (x,y); } -void View::setPosition(NR::Point const &p) +void View::setPosition(Geom::Point const &p) { - setPosition (double(p[NR::X]), double(p[NR::Y])); + setPosition (double(p[Geom::X]), double(p[Geom::Y])); } void View::emitResized (double width, double height) diff --git a/src/ui/view/view.h b/src/ui/view/view.h index 63a138f67..882746cea 100644 --- a/src/ui/view/view.h +++ b/src/ui/view/view.h @@ -21,6 +21,7 @@ #include "gc-finalized.h" #include "gc-anchored.h" #include +#include <2geom/forward.h> /** * Iterates until true or returns false. @@ -89,7 +90,7 @@ public: { return _tips_message_context; } void setPosition(gdouble x, gdouble y); - void setPosition(NR::Point const &p); + void setPosition(Geom::Point const &p); void emitResized(gdouble width, gdouble height); void requestRedraw(); diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp index 088af176a..638f1a70c 100644 --- a/src/ui/widget/object-composite-settings.cpp +++ b/src/ui/widget/object-composite-settings.cpp @@ -117,7 +117,7 @@ ObjectCompositeSettings::_blendBlurValueChanged() NR::Maybe bbox = _subject->getBounds(SPItem::GEOMETRIC_BBOX); double radius; if (bbox) { - double perimeter = bbox->extent(NR::X) + bbox->extent(NR::Y); + double perimeter = bbox->extent(Geom::X) + bbox->extent(Geom::Y); radius = _fe_cb.get_blur_value() * perimeter / 400; } else { radius = 0; @@ -262,7 +262,7 @@ ObjectCompositeSettings::_subjectChanged() { case QUERY_STYLE_MULTIPLE_SAME: NR::Maybe bbox = _subject->getBounds(SPItem::GEOMETRIC_BBOX); if (bbox) { - double perimeter = bbox->extent(NR::X) + bbox->extent(NR::Y); + double perimeter = bbox->extent(Geom::X) + bbox->extent(Geom::Y); _fe_cb.set_blur_sensitive(true); //update blur widget value float radius = query->filter_gaussianBlur_deviation.value; diff --git a/src/ui/widget/rotateable.cpp b/src/ui/widget/rotateable.cpp index 8615df7a9..396280aee 100644 --- a/src/ui/widget/rotateable.cpp +++ b/src/ui/widget/rotateable.cpp @@ -86,7 +86,7 @@ guint Rotateable::get_single_modifier(guint old, guint state) { bool Rotateable::on_motion(GdkEventMotion *event) { if (dragging) { - double dist = NR::L2(NR::Point(event->x, event->y) - NR::Point(drag_started_x, drag_started_y)); + double dist = Geom::L2(Geom::Point(event->x, event->y) - Geom::Point(drag_started_x, drag_started_y)); double angle = atan2(event->y - drag_started_y, event->x - drag_started_x); if (dist > 20) { working = true; diff --git a/src/ui/widget/ruler.cpp b/src/ui/widget/ruler.cpp index c6fb4395f..0afc0da3e 100644 --- a/src/ui/widget/ruler.cpp +++ b/src/ui/widget/ruler.cpp @@ -84,13 +84,13 @@ Ruler::canvas_get_pointer(int &x, int &y) (void) _canvas_widget->get_window()->get_pointer(x, y, mask); } -NR::Point +Geom::Point Ruler::get_event_dt() { int wx, wy; canvas_get_pointer(wx, wy); - NR::Point const event_win(wx, wy); - NR::Point const event_w(sp_canvas_window_to_world(_dt->canvas, event_win)); + Geom::Point const event_win(wx, wy); + Geom::Point const event_w(sp_canvas_window_to_world(_dt->canvas, event_win)); return _dt->w2d(event_w); } @@ -98,7 +98,7 @@ bool Ruler::on_button_press_event(GdkEventButton *evb) { g_assert(_dt); - NR::Point const &event_dt = get_event_dt(); + Geom::Point const &event_dt = get_event_dt(); Inkscape::XML::Node *repr = SP_OBJECT_REPR(_dt->namedview); if (evb->button == 1) { @@ -120,7 +120,7 @@ bool Ruler::on_motion_notify_event(GdkEventMotion *) { g_assert(_dt); - NR::Point const &event_dt = get_event_dt(); + Geom::Point const &event_dt = get_event_dt(); if (_dragging) { sp_guideline_set_position(SP_GUIDELINE(_guide), event_dt); @@ -136,7 +136,7 @@ Ruler::on_button_release_event(GdkEventButton *evb) g_assert(_dt); int wx, wy; canvas_get_pointer(wx, wy); - NR::Point const &event_dt = get_event_dt(); + Geom::Point const &event_dt = get_event_dt(); if (_dragging && evb->button == 1) { Gdk::Window::pointer_ungrab(evb->time); @@ -148,7 +148,7 @@ Ruler::on_button_release_event(GdkEventButton *evb) Inkscape::XML::Document *xml_doc = sp_document_repr_doc(_dt->doc()); Inkscape::XML::Node *repr = xml_doc->createElement("sodipodi:guide"); repr->setAttribute("orientation", _horiz_f ? "horizontal" : "vertical"); - double const guide_pos_dt = event_dt[ _horiz_f ? NR::Y : NR::X ]; + double const guide_pos_dt = event_dt[ _horiz_f ? Geom::Y : Geom::X ]; sp_repr_set_svg_double(repr, "position", guide_pos_dt); SP_OBJECT_REPR(_dt->namedview)->appendChild(repr); Inkscape::GC::release(repr); diff --git a/src/ui/widget/ruler.h b/src/ui/widget/ruler.h index 74dbf028c..c315418d8 100644 --- a/src/ui/widget/ruler.h +++ b/src/ui/widget/ruler.h @@ -49,7 +49,7 @@ protected: private: void canvas_get_pointer (int&, int&); - NR::Point get_event_dt(); + Geom::Point get_event_dt(); }; /// Horizontal ruler diff --git a/src/ui/widget/zoom-status.cpp b/src/ui/widget/zoom-status.cpp index e7320102c..fbe7c0642 100644 --- a/src/ui/widget/zoom-status.cpp +++ b/src/ui/widget/zoom-status.cpp @@ -20,6 +20,7 @@ #include "desktop.h" #include "desktop-handles.h" #include "widgets/spw-utilities.h" +#include "libnr/nr-convert2geom.h" namespace Inkscape { namespace UI { @@ -107,8 +108,8 @@ ZoomStatus::on_value_changed() _upd_f = true; g_assert(_dt); double zoom_factor = pow(2, get_value()); - NR::Rect const d =_dt->get_display_area(); - _dt->zoom_absolute(d.midpoint()[NR::X], d.midpoint()[NR::Y], zoom_factor); + Geom::Rect const d = to_2geom(_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/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 8744a4be0..4be823391 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -233,12 +233,12 @@ SPDesktopWidget::setMessage (Inkscape::MessageType type, const gchar *message) gtk_tooltips_set_tip (this->tt, this->select_status_eventbox, gtk_label_get_text (sb) , NULL); } -NR::Point +Geom::Point SPDesktopWidget::window_get_pointer() { gint x,y; gdk_window_get_pointer (GTK_WIDGET (canvas)->window, &x, &y, NULL); - return NR::Point(x,y); + return Geom::Point(x,y); } /** @@ -657,7 +657,7 @@ sp_desktop_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation) } if (GTK_WIDGET_REALIZED (widget)) { - NR::Rect const area = dtw->desktop->get_display_area(); + Geom::Rect const area = to_2geom(dtw->desktop->get_display_area()); double zoom = dtw->desktop->current_zoom(); if (GTK_WIDGET_CLASS(dtw_parent_class)->size_allocate) { @@ -666,14 +666,14 @@ sp_desktop_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation) if (SP_BUTTON_IS_DOWN(dtw->sticky_zoom)) { /* Calculate zoom per pixel */ - double const zpsp = zoom / hypot (area.dimensions()[NR::X], area.dimensions()[NR::Y]); + double const zpsp = zoom / hypot (area.dimensions()[Geom::X], area.dimensions()[Geom::Y]); /* Find new visible area */ - NR::Rect newarea = dtw->desktop->get_display_area(); + Geom::Rect newarea = to_2geom(dtw->desktop->get_display_area()); /* Calculate adjusted zoom */ - zoom = zpsp * hypot(newarea.dimensions()[NR::X], newarea.dimensions()[NR::Y]); - dtw->desktop->zoom_absolute(newarea.midpoint()[NR::X], newarea.midpoint()[NR::Y], 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); } else { - dtw->desktop->zoom_absolute(area.midpoint()[NR::X], area.midpoint()[NR::Y], zoom); + dtw->desktop->zoom_absolute(area.midpoint()[Geom::X], area.midpoint()[Geom::Y], zoom); } } else { @@ -1010,14 +1010,14 @@ SPDesktopWidget::disableInteraction() } void -SPDesktopWidget::setCoordinateStatus(NR::Point p) +SPDesktopWidget::setCoordinateStatus(Geom::Point p) { gchar *cstr; - cstr = g_strdup_printf("%7.2f ", dt2r * p[NR::X]); + cstr = g_strdup_printf("%7.2f ", dt2r * p[Geom::X]); gtk_label_set_markup( GTK_LABEL(this->coord_status_x), cstr ); g_free(cstr); - cstr = g_strdup_printf("%7.2f ", dt2r * p[NR::Y]); + cstr = g_strdup_printf("%7.2f ", dt2r * p[Geom::Y]); gtk_label_set_markup( GTK_LABEL(this->coord_status_y), cstr ); g_free(cstr); } @@ -1045,13 +1045,13 @@ SPDesktopWidget::getWindowGeometry (gint &x, gint &y, gint &w, gint &h) } void -SPDesktopWidget::setWindowPosition (NR::Point p) +SPDesktopWidget::setWindowPosition (Geom::Point p) { Gtk::Window *window = (Gtk::Window*)gtk_object_get_data (GTK_OBJECT(this), "window"); if (window) { - window->move (gint(round(p[NR::X])), gint(round(p[NR::Y]))); + window->move (gint(round(p[Geom::X])), gint(round(p[Geom::Y]))); } } @@ -1312,7 +1312,7 @@ sp_desktop_widget_new (SPNamedView *namedview) dtw->dt2r = 1.0 / namedview->doc_units->unittobase; - dtw->ruler_origin = NR::Point(0,0); //namedview->gridorigin; Why was the grid origin used here? + dtw->ruler_origin = Geom::Point(0,0); //namedview->gridorigin; Why was the grid origin used here? dtw->desktop = new SPDesktop(); dtw->stub = new SPDesktopWidget::WidgetStub (dtw); @@ -1350,14 +1350,14 @@ sp_desktop_widget_new (SPNamedView *namedview) } void -SPDesktopWidget::viewSetPosition (NR::Point p) +SPDesktopWidget::viewSetPosition (Geom::Point p) { - NR::Point const origin = ( p - ruler_origin ); + Geom::Point const origin = ( p - ruler_origin ); /// \todo fixme: - GTK_RULER(hruler)->position = origin[NR::X]; + GTK_RULER(hruler)->position = origin[Geom::X]; gtk_ruler_draw_pos (GTK_RULER (hruler)); - GTK_RULER(vruler)->position = origin[NR::Y]; + GTK_RULER(vruler)->position = origin[Geom::Y]; gtk_ruler_draw_pos (GTK_RULER (vruler)); } @@ -1379,8 +1379,8 @@ sp_desktop_widget_update_hruler (SPDesktopWidget *dtw) NR::IRect viewbox = dtw->canvas->getViewboxIntegers(); double const scale = dtw->desktop->current_zoom(); - double s = viewbox.min()[NR::X] / scale - dtw->ruler_origin[NR::X]; - double e = viewbox.max()[NR::X] / scale - dtw->ruler_origin[NR::X]; + double s = viewbox.min()[Geom::X] / scale - dtw->ruler_origin[Geom::X]; + double e = viewbox.max()[Geom::X] / scale - dtw->ruler_origin[Geom::X]; gtk_ruler_set_range(GTK_RULER(dtw->hruler), s, e, GTK_RULER(dtw->hruler)->position, (e - s)); } @@ -1395,8 +1395,8 @@ sp_desktop_widget_update_vruler (SPDesktopWidget *dtw) NR::IRect viewbox = dtw->canvas->getViewboxIntegers(); double const scale = dtw->desktop->current_zoom(); - double s = viewbox.min()[NR::Y] / -scale - dtw->ruler_origin[NR::Y]; - double e = viewbox.max()[NR::Y] / -scale - dtw->ruler_origin[NR::Y]; + double s = viewbox.min()[Geom::Y] / -scale - dtw->ruler_origin[Geom::Y]; + double e = viewbox.max()[Geom::Y] / -scale - dtw->ruler_origin[Geom::Y]; gtk_ruler_set_range(GTK_RULER(dtw->vruler), s, e, GTK_RULER(dtw->vruler)->position, (e - s)); } @@ -1407,7 +1407,7 @@ sp_desktop_widget_namedview_modified (SPObject *obj, guint flags, SPDesktopWidge SPNamedView *nv=SP_NAMEDVIEW(obj); if (flags & SP_OBJECT_MODIFIED_FLAG) { dtw->dt2r = 1.0 / nv->doc_units->unittobase; - dtw->ruler_origin = NR::Point(0,0); //nv->gridorigin; Why was the grid origin used here? + dtw->ruler_origin = Geom::Point(0,0); //nv->gridorigin; Why was the grid origin used here? sp_ruler_set_metric (GTK_RULER (dtw->vruler), nv->getDefaultMetric()); sp_ruler_set_metric (GTK_RULER (dtw->hruler), nv->getDefaultMetric()); @@ -1503,9 +1503,9 @@ sp_dtw_zoom_value_changed (GtkSpinButton *spin, gpointer data) SPDesktopWidget *dtw = SP_DESKTOP_WIDGET (data); SPDesktop *desktop = dtw->desktop; - NR::Rect const d = desktop->get_display_area(); + Geom::Rect const d = to_2geom(desktop->get_display_area()); g_signal_handler_block (spin, dtw->zoom_update); - desktop->zoom_absolute (d.midpoint()[NR::X], d.midpoint()[NR::Y], zoom_factor); + desktop->zoom_absolute (d.midpoint()[Geom::X], d.midpoint()[Geom::Y], zoom_factor); g_signal_handler_unblock (spin, dtw->zoom_update); spinbutton_defocus (GTK_OBJECT (spin)); @@ -1558,8 +1558,8 @@ sp_dtw_zoom_populate_popup (GtkEntry */*entry*/, GtkMenu *menu, gpointer data) static void sp_dtw_zoom_menu_handler (SPDesktop *dt, gdouble factor) { - NR::Rect const d = dt->get_display_area(); - dt->zoom_absolute(d.midpoint()[NR::X], d.midpoint()[NR::Y], factor); + Geom::Rect const d = to_2geom(dt->get_display_area()); + dt->zoom_absolute(d.midpoint()[Geom::X], d.midpoint()[Geom::Y], factor); } static void @@ -1693,32 +1693,32 @@ sp_desktop_widget_update_scrollbars (SPDesktopWidget *dtw, double scale) /* The desktop region we always show unconditionally */ SPDocument *doc = dtw->desktop->doc(); - NR::Rect darea(NR::Point(-sp_document_width(doc), -sp_document_height(doc)), - NR::Point(2 * sp_document_width(doc), 2 * sp_document_height(doc))); + NR::Rect darea(Geom::Point(-sp_document_width(doc), -sp_document_height(doc)), + Geom::Point(2 * sp_document_width(doc), 2 * sp_document_height(doc))); darea = NR::union_bounds(darea, sp_item_bbox_desktop(SP_ITEM(SP_DOCUMENT_ROOT(doc)))); /* Canvas region we always show unconditionally */ - NR::Rect carea(NR::Point(darea.min()[NR::X] * scale - 64, - darea.max()[NR::Y] * -scale - 64), - NR::Point(darea.max()[NR::X] * scale + 64, - darea.min()[NR::Y] * -scale + 64)); + 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 viewbox = dtw->canvas->getViewbox(); /* Viewbox is always included into scrollable region */ carea = NR::union_bounds(carea, viewbox); - set_adjustment(dtw->hadj, carea.min()[NR::X], carea.max()[NR::X], - viewbox.dimensions()[NR::X], - 0.1 * viewbox.dimensions()[NR::X], - viewbox.dimensions()[NR::X]); - gtk_adjustment_set_value(dtw->hadj, viewbox.min()[NR::X]); - - set_adjustment(dtw->vadj, carea.min()[NR::Y], carea.max()[NR::Y], - viewbox.dimensions()[NR::Y], - 0.1 * viewbox.dimensions()[NR::Y], - viewbox.dimensions()[NR::Y]); - gtk_adjustment_set_value(dtw->vadj, viewbox.min()[NR::Y]); + set_adjustment(dtw->hadj, carea.min()[Geom::X], carea.max()[Geom::X], + viewbox.dimensions()[Geom::X], + 0.1 * viewbox.dimensions()[Geom::X], + viewbox.dimensions()[Geom::X]); + gtk_adjustment_set_value(dtw->hadj, viewbox.min()[Geom::X]); + + set_adjustment(dtw->vadj, carea.min()[Geom::Y], carea.max()[Geom::Y], + viewbox.dimensions()[Geom::Y], + 0.1 * viewbox.dimensions()[Geom::Y], + viewbox.dimensions()[Geom::Y]); + gtk_adjustment_set_value(dtw->vadj, viewbox.min()[Geom::Y]); dtw->update = 0; } diff --git a/src/widgets/desktop-widget.h b/src/widgets/desktop-widget.h index aece4f75d..51c9141de 100644 --- a/src/widgets/desktop-widget.h +++ b/src/widgets/desktop-widget.h @@ -109,7 +109,7 @@ struct SPDesktopWidget { unsigned int _interaction_disabled_counter; SPCanvas *canvas; - NR::Point ruler_origin; + Geom::Point ruler_origin; double dt2r; GtkAdjustment *hadj, *vadj; @@ -135,11 +135,11 @@ struct SPDesktopWidget { { _dtw->getWindowGeometry (x, y, w, h); } virtual void setSize (gint w, gint h) { _dtw->setWindowSize (w, h); } - virtual void setPosition (NR::Point p) + virtual void setPosition (Geom::Point p) { _dtw->setWindowPosition (p); } virtual void setTransient (void* p, int transient_policy) { _dtw->setWindowTransient (p, transient_policy); } - virtual NR::Point getPointer() + virtual Geom::Point getPointer() { return _dtw->window_get_pointer(); } virtual void setIconified() { sp_desktop_widget_iconify (_dtw); } @@ -168,7 +168,7 @@ struct SPDesktopWidget { { sp_dtw_desktop_activate (_dtw); } virtual void deactivateDesktop() { sp_dtw_desktop_deactivate (_dtw); } - virtual void viewSetPosition (NR::Point p) + virtual void viewSetPosition (Geom::Point p) { _dtw->viewSetPosition (p); } virtual void updateRulers() { sp_desktop_widget_update_rulers (_dtw); } @@ -192,7 +192,7 @@ struct SPDesktopWidget { { _dtw->setToolboxSelectOneValue (id, val); } virtual bool isToolboxButtonActive (gchar const* id) { return _dtw->isToolboxButtonActive (id); } - virtual void setCoordinateStatus (NR::Point p) + virtual void setCoordinateStatus (Geom::Point p) { _dtw->setCoordinateStatus (p); } virtual void setMessage (Inkscape::MessageType type, gchar const* msg) { _dtw->setMessage (type, msg); } @@ -205,12 +205,12 @@ struct SPDesktopWidget { WidgetStub *stub; void setMessage(Inkscape::MessageType type, gchar const *message); - NR::Point window_get_pointer(); + Geom::Point window_get_pointer(); bool shutdown(); - void viewSetPosition (NR::Point p); + void viewSetPosition (Geom::Point p); void letZoomGrabFocus(); 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); void presentWindow(); @@ -219,7 +219,7 @@ struct SPDesktopWidget { void setToolboxAdjustmentValue (gchar const * id, double value); void setToolboxSelectOneValue (gchar const * id, gint value); bool isToolboxButtonActive (gchar const *id); - void setCoordinateStatus(NR::Point p); + void setCoordinateStatus(Geom::Point p); void requestCanvasUpdate(); void requestCanvasUpdateAndWait(); void enableInteraction(); diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index d6326791b..1faf7005f 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -21,6 +21,7 @@ #endif #include +#include #include #include #include @@ -28,6 +29,8 @@ #include #include +#include <2geom/transforms.h> + #include #include #include @@ -661,7 +664,7 @@ static gint sp_font_preview_expose(GtkWidget *widget, GdkEventExpose *event) pango_font_description_free(pfd); } } - NR::Point base_pt(str_text->glyph_text[i].x, str_text->glyph_text[i].y); + Geom::Point base_pt(str_text->glyph_text[i].x, str_text->glyph_text[i].y); base_pt *= theSize; glyphs[len] = str_text->glyph_text[i].gl; @@ -670,10 +673,10 @@ static gint sp_font_preview_expose(GtkWidget *widget, GdkEventExpose *event) if ( curF ) { NR::Maybe nbbox = curF->BBox(str_text->glyph_text[i].gl); if (nbbox) { - bbox.x0 = MIN(bbox.x0, base_pt[NR::X] + theSize * (nbbox->min())[0]); - bbox.y0 = MIN(bbox.y0, base_pt[NR::Y] - theSize * (nbbox->max())[1]); - bbox.x1 = MAX(bbox.x1, base_pt[NR::X] + theSize * (nbbox->max())[0]); - bbox.y1 = MAX(bbox.y1, base_pt[NR::Y] - theSize * (nbbox->min())[1]); + bbox.x0 = MIN(bbox.x0, base_pt[Geom::X] + theSize * (nbbox->min())[0]); + bbox.y0 = MIN(bbox.y0, base_pt[Geom::Y] - theSize * (nbbox->max())[1]); + bbox.x1 = MAX(bbox.x1, base_pt[Geom::X] + theSize * (nbbox->max())[0]); + bbox.y1 = MAX(bbox.y1, base_pt[Geom::Y] - theSize * (nbbox->min())[1]); } } } @@ -690,13 +693,13 @@ static gint sp_font_preview_expose(GtkWidget *widget, GdkEventExpose *event) unival = g_utf8_get_char (p); glyphs[len] = tface->MapUnicodeChar( unival); hpos[len] = (int)px; - NR::Point adv = fprev->rfont->Advance(glyphs[len]); + Geom::Point adv = fprev->rfont->Advance(glyphs[len]); fprev->rfont->BBox( glyphs[len], &gbox); bbox.x0 = MIN (px + gbox.x0, bbox.x0); bbox.y0 = MIN (py + gbox.y0, bbox.y0); bbox.x1 = MAX (px + gbox.x1, bbox.x1); bbox.y1 = MAX (py + gbox.y1, bbox.y1); - px += adv[NR::X]; + px += adv[Geom::X]; len += 1; p = g_utf8_next_char (p); }*/ @@ -741,7 +744,7 @@ static gint sp_font_preview_expose(GtkWidget *widget, GdkEventExpose *event) } raster_glyph *g = (curRF) ? curRF->GetGlyph(glyphs[i]) : NULL; if ( g ) { - g->Blit(NR::Point(hpos[i] + startx, starty), m); + g->Blit(Geom::Point(hpos[i] + startx, starty), m); } } if (curRF) { @@ -802,8 +805,8 @@ void sp_font_preview_set_font(SPFontPreview *fprev, font_instance *font, SPFontS if (fprev->font) { - NR::Matrix flip(NR::scale(fsel->fontsize, -fsel->fontsize)); - fprev->rfont = fprev->font->RasterFont(flip, 0); + Geom::Matrix flip(Geom::Scale(fsel->fontsize, -fsel->fontsize)); + fprev->rfont = fprev->font->RasterFont(from_2geom(flip), 0); } if (GTK_WIDGET_DRAWABLE (fprev)) gtk_widget_queue_draw (GTK_WIDGET (fprev)); diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index eb36d4c69..d89a85eaa 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -622,13 +622,13 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, SPObject *object = doc->getObjectById(name); if (object && SP_IS_ITEM(object)) { /* Find bbox in document */ - NR::Matrix const i2doc(from_2geom(sp_item_i2doc_affine(SP_ITEM(object)))); - NR::Maybe dbox = SP_ITEM(object)->getBounds(i2doc); + Geom::Matrix const i2doc(sp_item_i2doc_affine(SP_ITEM(object))); + NR::Maybe dbox = SP_ITEM(object)->getBounds(i2doc); if ( SP_OBJECT_PARENT(object) == NULL ) { - dbox = NR::Rect(NR::Point(0, 0), - NR::Point(sp_document_width(doc), sp_document_height(doc))); + dbox = Geom::Rect(Geom::Point(0, 0), + Geom::Point(sp_document_width(doc), sp_document_height(doc))); } /* This is in document coordinates, i.e. pixels */ @@ -636,17 +636,17 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, NRGC gc(NULL); /* Update to renderable state */ double sf = 1.0; - nr_arena_item_set_transform(root, NR::Matrix(NR::scale(sf, sf))); + nr_arena_item_set_transform(root, from_2geom(Geom::Scale(sf, sf))); gc.transform.set_identity(); nr_arena_item_invoke_update( root, NULL, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE ); /* Item integer bbox in points */ NRRectL ibox; - ibox.x0 = (int) floor(sf * dbox->min()[NR::X] + 0.5); - ibox.y0 = (int) floor(sf * dbox->min()[NR::Y] + 0.5); - ibox.x1 = (int) floor(sf * dbox->max()[NR::X] + 0.5); - ibox.y1 = (int) floor(sf * dbox->max()[NR::Y] + 0.5); + ibox.x0 = (int) floor(sf * dbox->min()[Geom::X] + 0.5); + ibox.y0 = (int) floor(sf * dbox->min()[Geom::Y] + 0.5); + ibox.x1 = (int) floor(sf * dbox->max()[Geom::X] + 0.5); + ibox.y1 = (int) floor(sf * dbox->max()[Geom::Y] + 0.5); if ( dump ) { g_message( " box --'%s' (%f,%f)-(%f,%f)", name, (double)ibox.x0, (double)ibox.y0, (double)ibox.x1, (double)ibox.y1 ); @@ -668,16 +668,16 @@ sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root, } sf = (double)psize / (double)block; - nr_arena_item_set_transform(root, NR::Matrix(NR::scale(sf, sf))); + nr_arena_item_set_transform(root, from_2geom(Geom::Scale(sf, sf))); gc.transform.set_identity(); nr_arena_item_invoke_update( root, NULL, &gc, NR_ARENA_ITEM_STATE_ALL, NR_ARENA_ITEM_STATE_NONE ); /* Item integer bbox in points */ - ibox.x0 = (int) floor(sf * dbox->min()[NR::X] + 0.5); - ibox.y0 = (int) floor(sf * dbox->min()[NR::Y] + 0.5); - ibox.x1 = (int) floor(sf * dbox->max()[NR::X] + 0.5); - ibox.y1 = (int) floor(sf * dbox->max()[NR::Y] + 0.5); + ibox.x0 = (int) floor(sf * dbox->min()[Geom::X] + 0.5); + ibox.y0 = (int) floor(sf * dbox->min()[Geom::Y] + 0.5); + ibox.x1 = (int) floor(sf * dbox->max()[Geom::X] + 0.5); + ibox.y1 = (int) floor(sf * dbox->max()[Geom::Y] + 0.5); if ( dump ) { g_message( " box2 --'%s' (%f,%f)-(%f,%f)", name, (double)ibox.x0, (double)ibox.y0, (double)ibox.x1, (double)ibox.y1 ); diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 30d52cbae..5a2adc8d2 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -49,6 +49,7 @@ #include "ege-adjustment-action.h" #include "ege-output-action.h" #include "ink-action.h" +#include <2geom/rect.h> using Inkscape::UnitTracker; @@ -61,8 +62,8 @@ sp_selection_layout_widget_update(SPWidget *spw, Inkscape::Selection *sel) g_object_set_data(G_OBJECT(spw), "update", GINT_TO_POINTER(TRUE)); - using NR::X; - using NR::Y; + using Geom::X; + using Geom::Y; if ( sel && !sel->isEmpty() ) { int prefs_bbox = prefs_get_int_attribute("tools", "bounding_box", 0); SPItem::BBoxType bbox_type = (prefs_bbox ==0)? @@ -181,35 +182,35 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, SPWidget *spw) x0 = sp_units_get_pixels (a_x->value, unit); y0 = sp_units_get_pixels (a_y->value, unit); x1 = x0 + sp_units_get_pixels (a_w->value, unit); - xrel = sp_units_get_pixels (a_w->value, unit) / bbox->extent(NR::X); + xrel = sp_units_get_pixels (a_w->value, unit) / bbox->extent(Geom::X); y1 = y0 + sp_units_get_pixels (a_h->value, unit); - yrel = sp_units_get_pixels (a_h->value, unit) / bbox->extent(NR::Y); + yrel = sp_units_get_pixels (a_h->value, unit) / bbox->extent(Geom::Y); } else { double const x0_propn = a_x->value * unit.unittobase; - x0 = bbox->min()[NR::X] * x0_propn; + x0 = bbox->min()[Geom::X] * x0_propn; double const y0_propn = a_y->value * unit.unittobase; - y0 = y0_propn * bbox->min()[NR::Y]; + y0 = y0_propn * bbox->min()[Geom::Y]; xrel = a_w->value * unit.unittobase; - x1 = x0 + xrel * bbox->extent(NR::X); + x1 = x0 + xrel * bbox->extent(Geom::X); yrel = a_h->value * unit.unittobase; - y1 = y0 + yrel * bbox->extent(NR::Y); + y1 = y0 + yrel * bbox->extent(Geom::Y); } // Keep proportions if lock is on GtkToggleAction *lock = GTK_TOGGLE_ACTION( g_object_get_data(G_OBJECT(spw), "lock") ); if ( gtk_toggle_action_get_active(lock) ) { if (adj == a_h) { - x1 = x0 + yrel * bbox->extent(NR::X); + x1 = x0 + yrel * bbox->extent(Geom::X); } else if (adj == a_w) { - y1 = y0 + xrel * bbox->extent(NR::Y); + y1 = y0 + xrel * bbox->extent(Geom::Y); } } // scales and moves, in px - double mh = fabs(x0 - bbox->min()[NR::X]); - double sh = fabs(x1 - bbox->max()[NR::X]); - double mv = fabs(y0 - bbox->min()[NR::Y]); - double sv = fabs(y1 - bbox->max()[NR::Y]); + double mh = fabs(x0 - bbox->min()[Geom::X]); + double sh = fabs(x1 - bbox->max()[Geom::X]); + double mv = fabs(y0 - bbox->min()[Geom::Y]); + double sv = fabs(y1 - bbox->max()[Geom::Y]); // unless the unit is %, convert the scales and moves to the unit if (unit.base == SP_UNIT_ABSOLUTE || unit.base == SP_UNIT_DEVICE) { diff --git a/src/widgets/sp-color-wheel.cpp b/src/widgets/sp-color-wheel.cpp index a31857101..b565bd485 100644 --- a/src/widgets/sp-color-wheel.cpp +++ b/src/widgets/sp-color-wheel.cpp @@ -21,6 +21,7 @@ #include "sp-color-wheel.h" #include "libnr/nr-rotate-ops.h" +#include <2geom/transforms.h> #define WHEEL_SIZE 96 @@ -1131,17 +1132,17 @@ static void sp_color_wheel_process_in_triangle( SPColorWheel *wheel, gdouble x, { // njh: dot(rot90(B-C), x) = saturation // njh: dot(B-C, x) = value - NR::Point delta( x - (((gdouble)(wheel->_triPoints[1].x + wheel->_triPoints[2].x)) / 2.0), + Geom::Point delta( x - (((gdouble)(wheel->_triPoints[1].x + wheel->_triPoints[2].x)) / 2.0), y - (((gdouble)(wheel->_triPoints[1].y + wheel->_triPoints[2].y)) / 2.0) ); gdouble rot = (M_PI * 2 * wheel->_hue ); - NR::Point result = delta * NR::rotate(rot); + Geom::Point result = delta * Geom::Rotate(rot); - gdouble sat = CLAMP( result[NR::X] / (wheel->_inner * 1.5), 0.0, 1.0 ); + gdouble sat = CLAMP( result[Geom::X] / (wheel->_inner * 1.5), 0.0, 1.0 ); gdouble halfHeight = (wheel->_inner * sin(M_PI/3.0)) * (1.0 - sat); - gdouble value = CLAMP( ((result[NR::Y]+ halfHeight) / (2.0*halfHeight)), 0.0, 1.0 ); + gdouble value = CLAMP( ((result[Geom::Y]+ halfHeight) / (2.0*halfHeight)), 0.0, 1.0 ); wheel->_triDirty = TRUE; diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 9fa886d08..9ca705189 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -1097,18 +1097,18 @@ sp_node_toolbox_coord_changed(gpointer /*shape_editor*/, GObject *tbl) } else { gtk_action_set_sensitive(xact, TRUE); gtk_action_set_sensitive(yact, TRUE); - NR::Coord oldx = sp_units_get_pixels(gtk_adjustment_get_value(xadj), *unit); - NR::Coord oldy = sp_units_get_pixels(gtk_adjustment_get_value(xadj), *unit); + Geom::Coord oldx = sp_units_get_pixels(gtk_adjustment_get_value(xadj), *unit); + Geom::Coord oldy = sp_units_get_pixels(gtk_adjustment_get_value(xadj), *unit); if (n_selected == 1) { - NR::Point sel_node = nodepath->singleSelectedCoords(); - if (oldx != sel_node[NR::X] || oldy != sel_node[NR::Y]) { - gtk_adjustment_set_value(xadj, sp_pixels_get_units(sel_node[NR::X], *unit)); - gtk_adjustment_set_value(yadj, sp_pixels_get_units(sel_node[NR::Y], *unit)); + Geom::Point sel_node = nodepath->singleSelectedCoords(); + if (oldx != sel_node[Geom::X] || oldy != sel_node[Geom::Y]) { + gtk_adjustment_set_value(xadj, sp_pixels_get_units(sel_node[Geom::X], *unit)); + gtk_adjustment_set_value(yadj, sp_pixels_get_units(sel_node[Geom::Y], *unit)); } } else { - NR::Maybe x = sp_node_selected_common_coord(nodepath, NR::X); - NR::Maybe y = sp_node_selected_common_coord(nodepath, NR::Y); + NR::Maybe x = sp_node_selected_common_coord(nodepath, Geom::X); + NR::Maybe y = sp_node_selected_common_coord(nodepath, Geom::Y); if ((x && ((*x) != oldx)) || (y && ((*y) != oldy))) { /* Note: Currently x and y will always have a value, even if the coordinates of the selected nodes don't coincide (in this case we use the coordinates of the center @@ -1153,10 +1153,10 @@ sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *value_ if (shape_editor && shape_editor->has_nodepath()) { double val = sp_units_get_pixels(gtk_adjustment_get_value(adj), *unit); if (!strcmp(value_name, "x")) { - sp_node_selected_move_absolute(shape_editor->get_nodepath(), val, NR::X); + sp_node_selected_move_absolute(shape_editor->get_nodepath(), val, Geom::X); } if (!strcmp(value_name, "y")) { - sp_node_selected_move_absolute(shape_editor->get_nodepath(), val, NR::Y); + sp_node_selected_move_absolute(shape_editor->get_nodepath(), val, Geom::Y); } }