summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1d0b394)
raw | patch | inline | side by side (parent: 1d0b394)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Mon, 4 Aug 2008 22:32:05 +0000 (22:32 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Mon, 4 Aug 2008 22:32:05 +0000 (22:32 +0000) |
27 files changed:
index f0eccb1464be2266414494a6c69f9776c1c73147..7d9aa84a6559d5312b03bfab0811d193a0a2360a 100644 (file)
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 f2ca1e84c0fe4882432058b1475146e32ab1c9ec..c5a653bf0ee1d152110f1762550543ac29affdf2 100644 (file)
--- 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<NR::Coord> sp_node_selected_common_coord (Inkscape::NodePath::Path *nodepath, NR::Dim2 axis)
+NR::Maybe<Geom::Coord> sp_node_selected_common_coord (Inkscape::NodePath::Path *nodepath, Geom::Dim2 axis)
{
- NR::Maybe<NR::Coord> no_coord = NR::Nothing();
+ NR::Maybe<Geom::Coord> 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<NR::Coord> 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 3f110f7083f0e104000f1602bac995841497b9ec..ac0c400d41fd8d05ee5c9380d09e496a7d4636bb 100644 (file)
--- 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<NR::Coord> 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<Geom::Coord> 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);
index a930cfc991727fdd892334daacf6eab71cdd0ea4..aa9d045e4f841a077f9fcd7ae6ac2434f410ebd7 100644 (file)
#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;
index 79ea80239808e51a32ae18ab41c47687d2065f47..0b4d5277461929a2b43e12cce864c34aa3203bca 100644 (file)
*
*/
-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 1b9968f8927ccdb037b84007c9c55578eb99da59..537277afc774b4a1a64bd1eb31b6193d6dd170d6 100644 (file)
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
#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"
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<NR::Rect> 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<NR::Rect> 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;
// 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
sp_document_ensure_up_to_date(target_document);
NR::Maybe<NR::Rect> sel_size = selection->bounds();
- NR::Point m( desktop->point() );
+ Geom::Point m( desktop->point() );
if (sel_size) {
m -= sel_size->midpoint();
}
/**
* @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
index 8c154d87a53d48e66ec589cabc39ad636d84638a..7d4820663b319e47bc1631218a1f1d5631601e75 100644 (file)
selected.insert<GSListConstIterator<SPItem *> >(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)
//Compute the anchor point
NR::Maybe<NR::Rect> 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;
}
}
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;
NR::Maybe<NR::Rect> 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;
}
{
NR::Maybe<NR::Rect> 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;
}
sp_document_ensure_up_to_date(sp_desktop_document (desktop));
NR::Maybe<NR::Rect> 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;
{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)
{
guint row, guint column,
AlignAndDistribute &dialog,
bool onInterSpace,
- NR::Dim2 orientation,
+ Geom::Dim2 orientation,
double kBegin, double kEnd
):
Action(id, tiptext, row, column,
{
NR::Maybe<NR::Rect> 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
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);
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;
}
}
//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));
guint _index;
AlignAndDistribute &_dialog;
bool _onInterSpace;
- NR::Dim2 _orientation;
+ Geom::Dim2 _orientation;
double _kBegin;
double _kEnd;
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),
{}
private :
- NR::Dim2 _orientation;
+ Geom::Dim2 _orientation;
bool _distribute;
virtual void on_button_click()
{
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);
}
};
// 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
NR::Maybe<NR::Rect> 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));
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)
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),
{}
private :
- NR::Dim2 _orientation;
+ Geom::Dim2 _orientation;
bool _distribute;
virtual void on_button_click()
{
//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<Baselines> sorted;
{
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);
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;
{
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;
//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",
//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<SPItem *>::iterator AlignAndDistribute::find_master( std::list<SPItem
for (std::list<SPItem *>::iterator it = list.begin(); it != list.end(); it++) {
NR::Maybe<NR::Rect> 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<SPItem *>::iterator AlignAndDistribute::find_master( std::list<SPItem
for (std::list<SPItem *>::iterator it = list.begin(); it != list.end(); it++) {
NR::Maybe<NR::Rect> 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;
index d6cbd377f30be593b46cd2ffacb2204e2e33c9ae..c29fd7c0d349afad99d8d4158acf424f41ccf554 100644 (file)
std::list<SPItem *>::iterator find_master(std::list <SPItem *> &list, bool horizontal);
void setMode(bool nodeEdit);
- NR::Maybe<NR::Rect> randomize_bbox;
+ NR::Maybe<Geom::Rect> 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);
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<Action *> _actionList;
Gtk::Frame _alignFrame, _distributeFrame, _removeOverlapFrame, _graphLayoutFrame, _nodesFrame;
{
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);
index d6624828cf3f9ed6da91acd41261ce097f7ecca4..c726b04549ca714953f2c3aa0cc09ca1db98b8a8 100644 (file)
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<NR::Rect> maybeArea(area);
+ NR::Maybe<NR::Rect> 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);
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);
index 8dcda8dfb5885b43ed6def500b997c94e97452c9..8c12df55849eefce08b997fbf0fc1a87d1a06f95 100644 (file)
if (!_check_move_relative.get_active()) {
NR::Maybe<NR::Rect> 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");
if (selection && !selection->isEmpty()) {
NR::Maybe<NR::Rect> 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
if (selection && !selection->isEmpty()) {
NR::Maybe<NR::Rect> 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);
{
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]);
NR::Maybe<NR::Rect> 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 {
{
NR::Maybe<NR::Rect> 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
{
NR::Maybe<NR::Rect> 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
NR::Maybe<NR::Rect> 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]);
}
}
}
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;
} else {
NR::Maybe<NR::Rect> 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()) {
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;
double skewY = _scalar_skew_vertical.getValue("px");
NR::Maybe<NR::Rect> 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);
}
}
NR::Maybe<NR::Point> 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("%");
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");
}
}
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 {
} else {
NR::Maybe<NR::Rect> 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;
index f148bb71530d89e8fa74fcb11e92cb2cf2c4ccda..7456f4adf12efb665158f48b8640c598f47d300a 100644 (file)
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;
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;
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;
index c32b5f9de0fcf18fc0e5a9a66f6fc9d2efed9576..423d8e82060d908cd79f8a22aa2377a43e6a6c94 100644 (file)
}
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()!
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
}
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?
}
/* 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();
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;
}
}
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);
}
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()));
}
index e665b2faec88682773a667cdd3e721da432cc2a5..ea32056966bbb99f0743ebb36b049ac3128a68cb 100644 (file)
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();
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();
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 6b6e0b8b629999b620fe30fa39504ff3552f2de1..75b6c453b349096e539e76ed2409252a9f4fc877 100644 (file)
--- a/src/ui/view/view.cpp
+++ b/src/ui/view/view.cpp
_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 63a138f6725f029f2ada7cca42b6b55ac050977e..882746ceace7648d3901a6df565ce4815fbbeecf 100644 (file)
--- a/src/ui/view/view.h
+++ b/src/ui/view/view.h
#include "gc-finalized.h"
#include "gc-anchored.h"
#include <libnr/nr-forward.h>
+#include <2geom/forward.h>
/**
* Iterates until true or returns false.
{ 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 088af176abdc05099d5f730d22cb12a09900a9a0..638f1a70c5b3f03449214ad7c420304914a1cbc7 100644 (file)
NR::Maybe<NR::Rect> 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;
case QUERY_STYLE_MULTIPLE_SAME:
NR::Maybe<NR::Rect> 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;
index 8615df7a97064865933626a9d38b95e6f0fdbd8a..396280aee1ab2cbde2d86353ed6b1067095fa433 100644 (file)
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;
index c6fb4395f88b47edb9468caeea931e0658d36484..0afc0da3e642da4a6d532867c1b9a9ce933dfa1d 100644 (file)
--- a/src/ui/widget/ruler.cpp
+++ b/src/ui/widget/ruler.cpp
(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);
}
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) {
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);
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);
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 74dbf028c738ea24fa10265326cf3d58fecc187a..c315418d84ef3f49af2ba37faab97ff01118f154 100644 (file)
--- a/src/ui/widget/ruler.h
+++ b/src/ui/widget/ruler.h
private:
void canvas_get_pointer (int&, int&);
- NR::Point get_event_dt();
+ Geom::Point get_event_dt();
};
/// Horizontal ruler
index e7320102c64f9c1d6ae5b0c7fc69126fb1447f50..fbe7c06421ca5b0079f1e58d1c22e751b86a295c 100644 (file)
#include "desktop.h"
#include "desktop-handles.h"
#include "widgets/spw-utilities.h"
+#include "libnr/nr-convert2geom.h"
namespace Inkscape {
namespace UI {
_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<GtkWidget*>((void*)_dt->canvas)); /// \todo this no love song
_upd_f = false;
}
index 8744a4be0aa80ae1da7242cb520ef22d3d9b16bd..4be82339140ad104cb165308dc87aebedd8f9f16 100644 (file)
@@ -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);
}
/**
}
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 {
}
void
-SPDesktopWidget::setCoordinateStatus(NR::Point p)
+SPDesktopWidget::setCoordinateStatus(Geom::Point p)
{
gchar *cstr;
- cstr = g_strdup_printf("<tt>%7.2f </tt>", dt2r * p[NR::X]);
+ cstr = g_strdup_printf("<tt>%7.2f </tt>", dt2r * p[Geom::X]);
gtk_label_set_markup( GTK_LABEL(this->coord_status_x), cstr );
g_free(cstr);
- cstr = g_strdup_printf("<tt>%7.2f </tt>", dt2r * p[NR::Y]);
+ cstr = g_strdup_printf("<tt>%7.2f </tt>", dt2r * p[Geom::Y]);
gtk_label_set_markup( GTK_LABEL(this->coord_status_y), cstr );
g_free(cstr);
}
}
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])));
}
}
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);
}
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));
}
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));
}
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());
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
/* 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;
}
index aece4f75db5ac3edfba3710e0a7522791593ceec..51c9141de1caf8a3b56890ef8c495c789bcf6d4b 100644 (file)
unsigned int _interaction_disabled_counter;
SPCanvas *canvas;
- NR::Point ruler_origin;
+ Geom::Point ruler_origin;
double dt2r;
GtkAdjustment *hadj, *vadj;
{ _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); }
{ 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); }
{ _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); }
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();
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();
index d6326791b822ba6eec02fdfb4adc108fc3d2fb0c..1faf7005f128f2a346fa9d83b505d0da20787b7c 100644 (file)
#endif
#include <libnr/nr-blit.h>
+#include <libnr/nr-convert2geom.h>
#include <libnrtype/font-instance.h>
#include <libnrtype/raster-glyph.h>
#include <libnrtype/RasterFont.h>
#include <libnrtype/one-glyph.h>
#include <libnrtype/font-lister.h>
+#include <2geom/transforms.h>
+
#include <gtk/gtk.h>
#include <gtk/gtkframe.h>
#include <gtk/gtkscrolledwindow.h>
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;
if ( curF ) {
NR::Maybe<NR::Rect> 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]);
}
}
}
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);
}*/
}
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 eb36d4c696d86e42a5a5d66365cd94d067caefe8..d89a85eaa58a36c0e3b8a252f5f786ee0e42453f 100644 (file)
--- a/src/widgets/icon.cpp
+++ b/src/widgets/icon.cpp
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<NR::Rect> dbox = SP_ITEM(object)->getBounds(i2doc);
+ Geom::Matrix const i2doc(sp_item_i2doc_affine(SP_ITEM(object)));
+ NR::Maybe<Geom::Rect> 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 */
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 );
}
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 );
index 30d52cbaeb04503559c5909ce51bf22930ee07f0..5a2adc8d20d3056e9d09c150c596c66979f51dec 100644 (file)
#include "ege-adjustment-action.h"
#include "ege-output-action.h"
#include "ink-action.h"
+#include <2geom/rect.h>
using Inkscape::UnitTracker;
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)?
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) {
index a318571016ce12c4f9d7e8976c90af46ed12b1a0..b565bd485ff59d25acc90166c3507f9ff42067a0 100644 (file)
#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;
index 9fa886d0839499987e10dffc51bb4e4742e2aaff..9ca705189d586fbc0041c2f3d30ef655bf090578 100644 (file)
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
} 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<NR::Coord> x = sp_node_selected_common_coord(nodepath, NR::X);
- NR::Maybe<NR::Coord> y = sp_node_selected_common_coord(nodepath, NR::Y);
+ NR::Maybe<Geom::Coord> x = sp_node_selected_common_coord(nodepath, Geom::X);
+ NR::Maybe<Geom::Coord> 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);
}
}