summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5818b61)
raw | patch | inline | side by side (parent: 5818b61)
author | cilix42 <cilix42@users.sourceforge.net> | |
Thu, 18 Sep 2008 17:48:42 +0000 (17:48 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Thu, 18 Sep 2008 17:48:42 +0000 (17:48 +0000) |
85 files changed:
diff --git a/src/box3d.cpp b/src/box3d.cpp
index 6f4253cab8683046f350e5eb6637637b6cdcd46b..3a2c09438f2f568c105389668adc9d4a2903926b 100644 (file)
--- a/src/box3d.cpp
+++ b/src/box3d.cpp
#include "attributes.h"
#include "xml/document.h"
#include "xml/repr.h"
+#include "libnr/nr-matrix-fns.h"
#include "box3d.h"
#include "box3d-side.h"
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index b8af828ad4b58edc62deae647e0594cc008ce23e..23b2e07a5d945be9277d4aebdb765fa49d306dba 100644 (file)
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
// Scale the style by the inverse of the accumulated parent transform in the paste context.
{
- NR::Matrix const local(sp_item_i2doc_affine(SP_ITEM(o)));
- double const ex(NR::expansion(local));
+ Geom::Matrix const local(sp_item_i2doc_affine(SP_ITEM(o)));
+ double const ex(local.descrim());
if ( ( ex != 0. )
&& ( ex != 1. ) ) {
sp_css_attr_scale(css_set, 1/ex);
if (!SP_IS_ITEM (l->data))
continue;
- NR::Matrix i2d = sp_item_i2d_affine (SP_ITEM(l->data));
+ Geom::Matrix i2d = sp_item_i2d_affine (SP_ITEM(l->data));
SPObject *object = SP_OBJECT(l->data);
notstroked = false;
}
- avgwidth += SP_OBJECT_STYLE (object)->stroke_width.computed * NR::expansion(i2d);
+ avgwidth += SP_OBJECT_STYLE (object)->stroke_width.computed * i2d.descrim();
}
if (notstroked)
n_stroked ++;
- NR::Matrix i2d = sp_item_i2d_affine (SP_ITEM(obj));
- double sw = style->stroke_width.computed * NR::expansion(i2d);
+ Geom::Matrix i2d = sp_item_i2d_affine (SP_ITEM(obj));
+ double sw = style->stroke_width.computed * i2d.descrim();
if (prev_sw != -1 && fabs(sw - prev_sw) > 1e-3)
same_sw = false;
if (!style) continue;
texts ++;
- size += style->font_size.computed * NR::expansion(sp_item_i2d_affine(SP_ITEM(obj))); /// \todo FIXME: we assume non-% units here
+ size += style->font_size.computed * Geom::Matrix(sp_item_i2d_affine(SP_ITEM(obj))).descrim(); /// \todo FIXME: we assume non-% units here
if (style->letter_spacing.normal) {
if (!different && (letterspacing_prev == 0 || letterspacing_prev == letterspacing))
if (!style) continue;
if (!SP_IS_ITEM(obj)) continue;
- NR::Matrix i2d = sp_item_i2d_affine (SP_ITEM(obj));
+ Geom::Matrix i2d = sp_item_i2d_affine (SP_ITEM(obj));
items ++;
if(SP_IS_GAUSSIANBLUR(primitive)) {
SPGaussianBlur * spblur = SP_GAUSSIANBLUR(primitive);
float num = spblur->stdDeviation.getNumber();
- blur_sum += num * NR::expansion(i2d);
+ blur_sum += num * i2d.descrim();
if (blur_prev != -1 && fabs (num - blur_prev) > 1e-2) // rather low tolerance because difference in blur radii is much harder to notice than e.g. difference in sizes
same_blur = false;
blur_prev = num;
diff --git a/src/desktop.cpp b/src/desktop.cpp
index 27f7179eda170c3fe3626e845afc6cc162508ffb..92946cb7dfa5e04e6261452849753f674fb2e441 100644 (file)
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
#include <sigc++/functors/mem_fun.h>
#include <gtkmm.h>
+#include <2geom/rect.h>
#include "macros.h"
#include "inkscape-private.h"
#include "desktop.h"
#include "display/sp-canvas-util.h"
#include "display/canvas-temporary-item-list.h"
#include "display/snap-indicator.h"
-#include "libnr/nr-rect-ops.h"
#include "ui/dialog/dialog-manager.h"
#include "xml/repr.h"
#include "message-context.h"
g_signal_connect (G_OBJECT (main), "event", G_CALLBACK (sp_desktop_root_handler), this);
table = sp_canvas_item_new (main, SP_TYPE_CTRLRECT, NULL);
- SP_CTRLRECT(table)->setRectangle(NR::Rect(Geom::Point(-80000, -80000), Geom::Point(80000, 80000)));
+ SP_CTRLRECT(table)->setRectangle(Geom::Rect(Geom::Point(-80000, -80000), Geom::Point(80000, 80000)));
SP_CTRLRECT(table)->setColor(0x00000000, true, 0x00000000);
sp_canvas_item_move_to_z (table, 0);
// display rect and zoom are now handled in sp_desktop_widget_realize()
- NR::Rect const d(Geom::Point(0.0, 0.0),
- Geom::Point(sp_document_width(document), sp_document_height(document)));
+ Geom::Rect const d(Geom::Point(0.0, 0.0),
+ Geom::Point(sp_document_width(document), sp_document_height(document)));
SP_CTRLRECT(page)->setRectangle(d);
SP_CTRLRECT(page_border)->setRectangle(d);
*/
bool SPDesktop::isWithinViewport (SPItem *item) const
{
- NR::Rect const viewport = get_display_area();
+ Geom::Rect const viewport = get_display_area();
boost::optional<NR::Rect> const bbox = sp_item_bbox_desktop(item);
if (bbox) {
- return viewport.contains(*bbox);
+ return viewport.contains(to_2geom(*bbox));
} else {
return true;
}
Geom::Point pw = sp_canvas_window_to_world (canvas, p);
p = w2d(pw);
- NR::Rect const r = canvas->getViewbox();
+ Geom::Rect const r = canvas->getViewbox();
Geom::Point r0 = w2d(r.min());
Geom::Point r1 = w2d(r.max());
- if (p[NR::X] >= r0[NR::X] &&
- p[NR::X] <= r1[NR::X] &&
- p[NR::Y] >= r1[NR::Y] &&
- p[NR::Y] <= r0[NR::Y])
+ if (p[Geom::X] >= r0[Geom::X] &&
+ p[Geom::X] <= r1[Geom::X] &&
+ p[Geom::Y] >= r1[Geom::Y] &&
+ p[Geom::Y] <= r0[Geom::Y])
{
return p;
} else {
void
SPDesktop::push_current_zoom (GList **history)
{
- NR::Rect const area = get_display_area();
+ Geom::Rect const area = get_display_area();
NRRect *old_zoom = g_new(NRRect, 1);
old_zoom->x0 = area.min()[NR::X];
@@ -750,14 +750,16 @@ SPDesktop::set_display_area (double x0, double y0, double x1, double y1, double
double const cx = 0.5 * (x0 + x1);
double const cy = 0.5 * (y0 + y1);
- NR::Rect const viewbox = NR::expand(canvas->getViewbox(), border);
+ // FIXME: This 2geom idiom doesn't allow us to declare dbox const
+ Geom::Rect viewbox = canvas->getViewbox();
+ viewbox.expandBy(border);
double scale = _d2w.descrim();
double newscale;
- if (((x1 - x0) * viewbox.dimensions()[NR::Y]) > ((y1 - y0) * viewbox.dimensions()[NR::X])) {
- newscale = viewbox.dimensions()[NR::X] / (x1 - x0);
+ if (((x1 - x0) * viewbox.dimensions()[Geom::Y]) > ((y1 - y0) * viewbox.dimensions()[Geom::X])) {
+ newscale = viewbox.dimensions()[Geom::X] / (x1 - x0);
} else {
- newscale = viewbox.dimensions()[NR::Y] / (y1 - y0);
+ newscale = viewbox.dimensions()[Geom::Y] / (y1 - y0);
}
newscale = CLAMP(newscale, SP_DESKTOP_ZOOM_MIN, SP_DESKTOP_ZOOM_MAX); // unit: 'screen pixels' per 'document pixels'
@@ -786,22 +788,22 @@ SPDesktop::set_display_area (double x0, double y0, double x1, double y1, double
_widget->updateZoom();
}
-void SPDesktop::set_display_area(NR::Rect const &a, NR::Coord b, bool log)
+void SPDesktop::set_display_area(Geom::Rect const &a, Geom::Coord b, bool log)
{
- set_display_area(a.min()[NR::X], a.min()[NR::Y], a.max()[NR::X], a.max()[NR::Y], b, log);
+ set_display_area(a.min()[Geom::X], a.min()[Geom::Y], a.max()[Geom::X], a.max()[Geom::Y], b, log);
}
/**
* Return viewbox dimensions.
*/
-NR::Rect SPDesktop::get_display_area() const
+Geom::Rect SPDesktop::get_display_area() const
{
- NR::Rect const viewbox = canvas->getViewbox();
+ Geom::Rect const viewbox = canvas->getViewbox();
double const scale = _d2w[0];
- return NR::Rect(Geom::Point(viewbox.min()[NR::X] / scale, viewbox.max()[NR::Y] / -scale),
- Geom::Point(viewbox.max()[NR::X] / scale, viewbox.min()[NR::Y] / -scale));
+ return Geom::Rect(Geom::Point(viewbox.min()[Geom::X] / scale, viewbox.max()[Geom::Y] / -scale),
+ Geom::Point(viewbox.max()[Geom::X] / scale, viewbox.min()[Geom::Y] / -scale));
}
/**
@@ -868,7 +870,7 @@ SPDesktop::zoom_absolute_keep_point (double cx, double cy, double px, double py,
if (fabs(_d2w.descrim() - zoom) < 0.0001*zoom && (fabs(SP_DESKTOP_ZOOM_MAX - zoom) < 0.01 || fabs(SP_DESKTOP_ZOOM_MIN - zoom) < 0.000001))
return;
- NR::Rect const viewbox = canvas->getViewbox();
+ Geom::Rect const viewbox = canvas->getViewbox();
double const width2 = viewbox.dimensions()[NR::X] / zoom;
double const height2 = viewbox.dimensions()[NR::Y] / zoom;
void
SPDesktop::zoom_relative_keep_point (double cx, double cy, double zoom)
{
- NR::Rect const area = get_display_area();
+ Geom::Rect const area = get_display_area();
if (cx < area.min()[NR::X]) {
cx = area.min()[NR::X];
void
SPDesktop::zoom_page()
{
- NR::Rect d(Geom::Point(0, 0),
- Geom::Point(sp_document_width(doc()), sp_document_height(doc())));
+ Geom::Rect d(Geom::Point(0, 0),
+ Geom::Point(sp_document_width(doc()), sp_document_height(doc())));
- if (d.isEmpty(1.0)) {
+ // FIXME: the original NR::Rect::isEmpty call contained an additional threshold of 1.0; is it safe to ignore it?
+ if (d.isEmpty()) {
return;
}
void
SPDesktop::zoom_page_width()
{
- NR::Rect const a = get_display_area();
+ Geom::Rect const a = get_display_area();
if (sp_document_width(doc()) < 1.0) {
return;
}
- NR::Rect d(Geom::Point(0, a.midpoint()[NR::Y]),
- Geom::Point(sp_document_width(doc()), a.midpoint()[NR::Y]));
+ Geom::Rect d(Geom::Point(0, a.midpoint()[Geom::Y]),
+ Geom::Point(sp_document_width(doc()), a.midpoint()[Geom::Y]));
set_display_area(d, 10);
}
void
SPDesktop::zoom_selection()
{
- boost::optional<NR::Rect> const d = selection->bounds();
+ boost::optional<Geom::Rect> const d = to_2geom(selection->bounds());
- if ( !d || d->isEmpty(0.1) ) {
+ // FIXME: the original NR::Rect::isEmpty call contained an additional threshold of 0.1; is it safe to ignore it?
+ if ( !d || d->isEmpty() ) {
return;
}
SPItem *docitem = SP_ITEM (sp_document_root (doc()));
g_return_if_fail (docitem != NULL);
- boost::optional<NR::Rect> d = sp_item_bbox_desktop(docitem);
+ boost::optional<Geom::Rect> d = to_2geom(sp_item_bbox_desktop(docitem));
/* Note that the second condition here indicates that
** there are no items in the drawing.
*/
- if ( !d || d->isEmpty(1.0) ) {
+ // FIXME: the original NR::Rect::isEmpty call contained an additional threshold of 1.0; is it safe to ignore it?
+ if ( !d || d->isEmpty() ) {
return;
}
{
g_assert(_widget);
- NR::Rect const viewbox = canvas->getViewbox();
+ Geom::Rect const viewbox = canvas->getViewbox();
- sp_canvas_scroll_to(canvas, viewbox.min()[NR::X] - dx, viewbox.min()[NR::Y] - dy, FALSE, is_scrolling);
+ sp_canvas_scroll_to(canvas, viewbox.min()[Geom::X] - dx, viewbox.min()[Geom::Y] - dy, FALSE, is_scrolling);
/* update perspective lines if we are in the 3D box tool (so that infinite ones are shown correctly) */
sp_box3d_context_update_lines(event_context);
// autoscrolldistance is in screen pixels, but the display area is in document units
autoscrolldistance /= _d2w.descrim();
- NR::Rect const dbox = NR::expand(get_display_area(), -autoscrolldistance);
+ // FIXME: This 2geom idiom doesn't allow us to declare dbox const
+ Geom::Rect dbox = get_display_area();
+ dbox.expandBy(-autoscrolldistance);
if (!(p[NR::X] > dbox.min()[NR::X] && p[NR::X] < dbox.max()[NR::X]) ||
!(p[NR::Y] > dbox.min()[NR::Y] && p[NR::Y] < dbox.max()[NR::Y]) ) {
{
_doc2dt[5] = height;
sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (drawing), _doc2dt);
- NR::Rect const a(Geom::Point(0, 0), Geom::Point(width, height));
+ Geom::Rect const a(Geom::Point(0, 0), Geom::Point(width, height));
SP_CTRLRECT(page)->setRectangle(a);
SP_CTRLRECT(page_border)->setRectangle(a);
}
diff --git a/src/desktop.h b/src/desktop.h
index 27439ebccd91c71fa0613fd9f05b80429d4bf7df..f02f5556ca0d6e81086b90dffea368a97e4355c4 100644 (file)
--- a/src/desktop.h
+++ b/src/desktop.h
#include <gtk/gtktypeutils.h>
#include <sigc++/sigc++.h>
-#include "libnr/nr-matrix.h"
-#include "libnr/nr-matrix-fns.h"
-#include "libnr/nr-rect.h"
+#include <2geom/matrix.h>
+
#include "ui/view/view.h"
#include "ui/view/edit-widget-interface.h"
SPItem *group_at_point (Geom::Point const p) const;
Geom::Point point() const;
- NR::Rect get_display_area() const;
+ Geom::Rect get_display_area() const;
void set_display_area (double x0, double y0, double x1, double y1, double border, bool log = true);
- void set_display_area(NR::Rect const &a, NR::Coord border, bool log = true);
+ void set_display_area(Geom::Rect const &a, Geom::Coord border, bool log = true);
void zoom_absolute (double cx, double cy, double zoom);
void zoom_relative (double cx, double cy, double zoom);
void zoom_absolute_keep_point (double cx, double cy, double px, double py, double zoom);
void zoom_relative_keep_point (double cx, double cy, double zoom);
void zoom_relative_keep_point (Geom::Point const &c, double const zoom)
{
- using NR::X;
- using NR::Y;
- zoom_relative_keep_point (c[X], c[Y], zoom);
+ zoom_relative_keep_point (c[Geom::X], c[Geom::Y], zoom);
}
void zoom_page();
void zoom_drawing();
void zoom_selection();
void zoom_grab_focus();
- double current_zoom() const { return NR::expansion(_d2w); }
+ double current_zoom() const { return _d2w.descrim(); }
void prev_zoom();
void next_zoom();
void scroll_world (double dx, double dy, bool is_scrolling = false);
void scroll_world (Geom::Point const scroll, bool is_scrolling = false)
{
- using NR::X;
- using NR::Y;
- scroll_world(scroll[X], scroll[Y], is_scrolling);
+ scroll_world(scroll[Geom::X], scroll[Geom::Y], is_scrolling);
}
void scroll_world_in_svg_coords (double dx, double dy, bool is_scrolling = false);
index e06c2a3b070c25905072942fbe8a3205f27eb4e8..e01958c9fa87a89bb9085f1c63f185b7a61dbc88 100644 (file)
static void sp_canvas_arena_init(SPCanvasArena *group);
static void sp_canvas_arena_destroy(GtkObject *object);
-static void sp_canvas_arena_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags);
+static void sp_canvas_arena_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags);
static void sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf);
-static double sp_canvas_arena_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item);
+static double sp_canvas_arena_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item);
static gint sp_canvas_arena_event (SPCanvasItem *item, GdkEvent *event);
static gint sp_canvas_arena_send_event (SPCanvasArena *arena, GdkEvent *event);
}
static void
-sp_canvas_arena_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags)
+sp_canvas_arena_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags)
{
SPCanvasArena *arena = SP_CANVAS_ARENA (item);
@@ -165,8 +165,8 @@ sp_canvas_arena_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned i
ec.send_event = TRUE;
ec.subwindow = ec.window;
ec.time = GDK_CURRENT_TIME;
- ec.x = arena->c[NR::X];
- ec.y = arena->c[NR::Y];
+ ec.x = arena->c[Geom::X];
+ ec.y = arena->c[Geom::Y];
/* fixme: */
if (arena->active) {
ec.type = GDK_LEAVE_NOTIFY;
}
static double
-sp_canvas_arena_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item)
+sp_canvas_arena_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item)
{
SPCanvasArena *arena = SP_CANVAS_ARENA (item);
arena->cursor = TRUE;
/* TODO ... event -> arena transform? */
- arena->c = NR::Point(event->crossing.x, event->crossing.y);
+ arena->c = Geom::Point(event->crossing.x, event->crossing.y);
/* fixme: Not sure abut this, but seems the right thing (Lauris) */
nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, NR_ARENA_ITEM_STATE_PICK, NR_ARENA_ITEM_STATE_NONE);
case GDK_MOTION_NOTIFY:
/* TODO ... event -> arena transform? */
- arena->c = NR::Point(event->motion.x, event->motion.y);
+ arena->c = Geom::Point(event->motion.x, event->motion.y);
/* fixme: Not sure abut this, but seems the right thing (Lauris) */
nr_arena_item_invoke_update (arena->root, NULL, &arena->gc, NR_ARENA_ITEM_STATE_PICK, NR_ARENA_ITEM_STATE_NONE);
index df402831ece261eea64ea12b31d4fb1f19d51be3..0f5045c4d25699cef177c262dff528731d1ebc60 100644 (file)
@@ -197,8 +197,8 @@ CanvasAxonomGrid::CanvasAxonomGrid (SPNamedView * nv, Inkscape::XML::Node * in_r
gridunit = sp_unit_get_by_abbreviation( prefs->getString("options.grids.axonom", "units").data() );
if (!gridunit)
gridunit = &sp_unit_get_by_id(SP_UNIT_PX);
- origin[NR::X] = sp_units_get_pixels( prefs->getDouble("options.grids.axonom", "origin_x", 0.0), *gridunit );
- origin[NR::Y] = sp_units_get_pixels( prefs->getDouble("options.grids.axonom", "origin_y", 0.0), *gridunit );
+ origin[Geom::X] = sp_units_get_pixels( prefs->getDouble("options.grids.axonom", "origin_x", 0.0), *gridunit );
+ origin[Geom::Y] = sp_units_get_pixels( prefs->getDouble("options.grids.axonom", "origin_y", 0.0), *gridunit );
color = prefs->getInt("options.grids.axonom", "color", 0x0000ff20);
empcolor = prefs->getInt("options.grids.axonom", "empcolor", 0x0000ff40);
empspacing = prefs->getInt("options.grids.axonom", "empspacing", 5);
/// @todo Replace direct XML preference node manipulation with calls to public prefs API
gchar const *value;
if ( (value = repr->attribute("originx")) ) {
- sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[NR::X], &gridunit);
- origin[NR::X] = sp_units_get_pixels(origin[NR::X], *(gridunit));
+ sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[Geom::X], &gridunit);
+ origin[Geom::X] = sp_units_get_pixels(origin[Geom::X], *(gridunit));
}
if ( (value = repr->attribute("originy")) ) {
- sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[NR::Y], &gridunit);
- origin[NR::Y] = sp_units_get_pixels(origin[NR::Y], *(gridunit));
+ sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[Geom::Y], &gridunit);
+ origin[Geom::Y] = sp_units_get_pixels(origin[Geom::Y], *(gridunit));
}
if ( (value = repr->attribute("spacingy")) ) {
_rumg->setUnit (gridunit);
gdouble val;
- val = origin[NR::X];
+ val = origin[Geom::X];
val = sp_pixels_get_units (val, *(gridunit));
_rsu_ox->setValue (val);
- val = origin[NR::Y];
+ val = origin[Geom::Y];
val = sp_pixels_get_units (val, *(gridunit));
_rsu_oy->setValue (val);
val = lengthy;
_rumg.setUnit (gridunit);
gdouble val;
- val = origin[NR::X];
+ val = origin[Geom::X];
val = sp_pixels_get_units (val, *(gridunit));
_rsu_ox.setValue (val);
- val = origin[NR::Y];
+ val = origin[Geom::Y];
val = sp_pixels_get_units (val, *(gridunit));
_rsu_oy.setValue (val);
val = lengthy;
void
-CanvasAxonomGrid::Update (NR::Matrix const &affine, unsigned int /*flags*/)
+CanvasAxonomGrid::Update (Geom::Matrix const &affine, unsigned int /*flags*/)
{
ow = origin * affine;
- sw = NR::Point(fabs(affine[0]),fabs(affine[3]));
+ sw = Geom::Point(fabs(affine[0]),fabs(affine[3]));
for(int dim = 0; dim < 2; dim++) {
gint scaling_factor = empspacing;
}
- spacing_ylines = sw[NR::X] * lengthy /(tan_angle[X] + tan_angle[Z]);
- lyw = sw[NR::Y] * lengthy;
- lxw_x = (lengthy / tan_angle[X]) * sw[NR::X];
- lxw_z = (lengthy / tan_angle[Z]) * sw[NR::X];
+ spacing_ylines = sw[Geom::X] * lengthy /(tan_angle[X] + tan_angle[Z]);
+ lyw = sw[Geom::Y] * lengthy;
+ lxw_x = (lengthy / tan_angle[X]) * sw[Geom::X];
+ lxw_z = (lengthy / tan_angle[Z]) * sw[Geom::X];
if (empspacing == 0) {
scaled = TRUE;
// bc = buffer patch coordinates
// tl = topleft ; br = bottomright
- NR::Point buf_tl_gc;
- NR::Point buf_br_gc;
- buf_tl_gc[NR::X] = buf->rect.x0 - ow[NR::X];
- buf_tl_gc[NR::Y] = buf->rect.y0 - ow[NR::Y];
- buf_br_gc[NR::X] = buf->rect.x1 - ow[NR::X];
- buf_br_gc[NR::Y] = buf->rect.y1 - ow[NR::Y];
+ Geom::Point buf_tl_gc;
+ Geom::Point buf_br_gc;
+ buf_tl_gc[Geom::X] = buf->rect.x0 - ow[Geom::X];
+ buf_tl_gc[Geom::Y] = buf->rect.y0 - ow[Geom::Y];
+ buf_br_gc[Geom::X] = buf->rect.x1 - ow[Geom::X];
+ buf_br_gc[Geom::Y] = buf->rect.y1 - ow[Geom::Y];
gdouble x;
gdouble y;
// render the three separate line groups representing the main-axes
// x-axis always goes from topleft to bottomright. (0,0) - (1,1)
- gdouble const xintercept_y_bc = (buf_tl_gc[NR::X] * tan_angle[X]) - buf_tl_gc[NR::Y] ;
+ gdouble const xintercept_y_bc = (buf_tl_gc[Geom::X] * tan_angle[X]) - buf_tl_gc[Geom::Y] ;
gdouble const xstart_y_sc = ( xintercept_y_bc - floor(xintercept_y_bc/lyw)*lyw ) + buf->rect.y0;
- gint const xlinestart = (gint) Inkscape::round( (xstart_y_sc - buf->rect.x0*tan_angle[X] -ow[NR::Y]) / lyw );
+ gint const xlinestart = (gint) Inkscape::round( (xstart_y_sc - buf->rect.x0*tan_angle[X] -ow[Geom::Y]) / lyw );
gint xlinenum = xlinestart;
// lines starting on left side.
for (y = xstart_y_sc; y < buf->rect.y1; y += lyw, xlinenum++) {
}
// y-axis lines (vertical)
- gdouble const ystart_x_sc = floor (buf_tl_gc[NR::X] / spacing_ylines) * spacing_ylines + ow[NR::X];
- gint const ylinestart = (gint) Inkscape::round((ystart_x_sc - ow[NR::X]) / spacing_ylines);
+ gdouble const ystart_x_sc = floor (buf_tl_gc[Geom::X] / spacing_ylines) * spacing_ylines + ow[Geom::X];
+ gint const ylinestart = (gint) Inkscape::round((ystart_x_sc - ow[Geom::X]) / spacing_ylines);
gint ylinenum = ylinestart;
for (x = ystart_x_sc; x < buf->rect.x1; x += spacing_ylines, ylinenum++) {
gint const x0 = (gint) Inkscape::round(x);
}
// z-axis always goes from bottomleft to topright. (0,1) - (1,0)
- gdouble const zintercept_y_bc = (buf_tl_gc[NR::X] * -tan_angle[Z]) - buf_tl_gc[NR::Y] ;
+ gdouble const zintercept_y_bc = (buf_tl_gc[Geom::X] * -tan_angle[Z]) - buf_tl_gc[Geom::Y] ;
gdouble const zstart_y_sc = ( zintercept_y_bc - floor(zintercept_y_bc/lyw)*lyw ) + buf->rect.y0;
- gint const zlinestart = (gint) Inkscape::round( (zstart_y_sc + buf->rect.x0*tan_angle[Z] - ow[NR::Y]) / lyw );
+ gint const zlinestart = (gint) Inkscape::round( (zstart_y_sc + buf->rect.x0*tan_angle[Z] - ow[Geom::Y]) / lyw );
gint zlinenum = zlinestart;
// lines starting from left side
for (y = zstart_y_sc; y < buf->rect.y1; y += lyw, zlinenum++) {
index f8dc8e25a983ae81454185c14f414378d865e643..1d255d798a49396c2a2d14838b69f1a9e796e53c 100644 (file)
*/
#include <display/sp-canvas.h>
-#include <libnr/nr-coord.h>
#include "xml/repr.h"
#include <gtkmm/box.h>
CanvasAxonomGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc);
virtual ~CanvasAxonomGrid();
- void Update (NR::Matrix const &affine, unsigned int flags);
+ void Update (Geom::Matrix const &affine, unsigned int flags);
void Render (SPCanvasBuf *buf);
void readRepr();
bool scaled; /**< Whether the grid is in scaled mode */
- NR::Point ow; /**< Transformed origin by the affine for the zoom */
+ Geom::Point ow; /**< Transformed origin by the affine for the zoom */
double lyw; /**< Transformed length y by the affine for the zoom */
double lxw_x;
double lxw_z;
double spacing_ylines;
- NR::Point sw; /**< the scaling factors of the affine transform */
+ Geom::Point sw; /**< the scaling factors of the affine transform */
protected:
virtual Gtk::Widget * newSpecificWidget();
index 74b69b9c0b0ba2a2b7fb9bd68b52edfbf0931fb2..8342ff7ff4bdbb57d344f39f886e200d2b8add26 100644 (file)
static void sp_canvas_bpath_init (SPCanvasBPath *path);
static void sp_canvas_bpath_destroy (GtkObject *object);
-static void sp_canvas_bpath_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags);
+static void sp_canvas_bpath_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags);
static void sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf);
-static double sp_canvas_bpath_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item);
+static double sp_canvas_bpath_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item);
static SPCanvasItemClass *parent_class;
}
static void
-sp_canvas_bpath_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags)
+sp_canvas_bpath_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags)
{
SPCanvasBPath *cbp = SP_CANVAS_BPATH (item);
}
static double
-sp_canvas_bpath_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item)
+sp_canvas_bpath_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item)
{
SPCanvasBPath *cbp = SP_CANVAS_BPATH (item);
@@ -214,7 +214,7 @@ sp_canvas_bpath_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_it
return NR_HUGE;
double width = 0.5;
- Geom::Rect viewbox = to_2geom(item->canvas->getViewbox());
+ Geom::Rect viewbox = item->canvas->getViewbox();
viewbox.expandBy (width);
double dist = NR_HUGE;
pathv_matrix_point_bbox_wind_distance(cbp->curve->get_pathvector(), cbp->affine, p, NULL, NULL, &dist, 0.5, &viewbox);
static void sp_canvastext_init (SPCanvasText *canvastext);
static void sp_canvastext_destroy (GtkObject *object);
-static void sp_canvastext_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags);
+static void sp_canvastext_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags);
static void sp_canvastext_render (SPCanvasItem *item, SPCanvasBuf *buf);
static SPCanvasItemClass *parent_class_ct;
sp_canvastext_init (SPCanvasText *canvastext)
{
canvastext->rgba = 0x0000ff7f;
- canvastext->s[NR::X] = canvastext->s[NR::Y] = 0.0;
- canvastext->affine = NR::identity();
+ canvastext->s[Geom::X] = canvastext->s[Geom::Y] = 0.0;
+ canvastext->affine = Geom::identity();
canvastext->fontsize = 10.0;
canvastext->item = NULL;
canvastext->desktop = NULL;
guint32 rgba = cl->rgba;
cairo_set_source_rgba(buf->ct, SP_RGBA32_B_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_R_F(rgba), SP_RGBA32_A_F(rgba));
- NR::Point s = cl->s * cl->affine;
- double offsetx = s[NR::X] - buf->rect.x0;
- double offsety = s[NR::Y] - buf->rect.y0;
+ Geom::Point s = cl->s * cl->affine;
+ double offsetx = s[Geom::X] - buf->rect.x0;
+ double offsety = s[Geom::Y] - buf->rect.y0;
offsetx -= anchor_offset_x;
offsety += anchor_offset_y;
}
static void
-sp_canvastext_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags)
+sp_canvastext_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags)
{
SPCanvasText *cl = SP_CANVASTEXT (item);
@@ -405,7 +405,7 @@ sp_canvastext_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int
cl->affine = affine;
- NR::Point s = cl->s * affine;
+ Geom::Point s = cl->s * affine;
// set up a temporary cairo_t to measure the text extents; it would be better to compute this in the render()
// method but update() seems to be called before so we don't have the information available when we need it
@@ -414,10 +414,10 @@ sp_canvastext_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int
cairo_text_extents_t bbox;
cairo_text_extents(&tmp_buf, cl->text, &bbox);
**/
- item->x1 = s[NR::X] + 0;
- item->y1 = s[NR::Y] - cl->fontsize;
- item->x2 = s[NR::X] + cl->fontsize * strlen(cl->text);
- item->y2 = s[NR::Y] + cl->fontsize * 0.5; // for letters below the baseline
+ item->x1 = s[Geom::X] + 0;
+ item->y1 = s[Geom::Y] - cl->fontsize;
+ item->x2 = s[Geom::X] + cl->fontsize * strlen(cl->text);
+ item->y2 = s[Geom::Y] + cl->fontsize * 0.5; // for letters below the baseline
// adjust update region according to anchor shift
// FIXME: use the correct text extent
void
sp_canvastext_set_coords (SPCanvasText *ct, gdouble x0, gdouble y0)
{
- sp_canvastext_set_coords(ct, NR::Point(x0, y0));
+ sp_canvastext_set_coords(ct, Geom::Point(x0, y0));
}
void
-sp_canvastext_set_coords (SPCanvasText *ct, const NR::Point start)
+sp_canvastext_set_coords (SPCanvasText *ct, const Geom::Point start)
{
- NR::Point pos = ct->desktop->doc2dt(start);
+ Geom::Point pos = ct->desktop->doc2dt(start);
g_return_if_fail (ct != NULL);
g_return_if_fail (SP_IS_CANVASTEXT (ct));
- if (DIFFER (pos[0], ct->s[NR::X]) || DIFFER (pos[1], ct->s[NR::Y])) {
- ct->s[NR::X] = pos[0];
- ct->s[NR::Y] = pos[1];
+ if (DIFFER (pos[0], ct->s[Geom::X]) || DIFFER (pos[1], ct->s[Geom::Y])) {
+ ct->s[Geom::X] = pos[0];
+ ct->s[Geom::Y] = pos[1];
sp_canvas_item_request_update (SP_CANVAS_ITEM (ct));
}
sp_canvas_item_request_update (SP_CANVAS_ITEM (ct));
index d6382b65145655b117b7771158eb4a78cfd5c457..2001bfa7d12ce8887eb9b4d66c534801679192b9 100644 (file)
/* Line def */
SPCurve *curve;
- NR::Matrix affine;
+ Geom::Matrix affine;
/* Fill attributes */
guint32 fill_rgba;
SPDesktop *desktop; // the desktop to which this text is attached; needed for coordinate transforms (TODO: these should be eliminated)
gchar* text;
- NR::Point s;
- NR::Matrix affine;
+ Geom::Point s;
+ Geom::Matrix affine;
double fontsize;
double anchor_x;
double anchor_y;
@@ -128,7 +128,7 @@ SPCanvasItem *sp_canvastext_new(SPCanvasGroup *parent, SPDesktop *desktop, Geom:
void sp_canvastext_set_rgba32 (SPCanvasText *ct, guint32 rgba);
void sp_canvastext_set_coords (SPCanvasText *ct, gdouble x0, gdouble y0);
-void sp_canvastext_set_coords (SPCanvasText *ct, const NR::Point start);
+void sp_canvastext_set_coords (SPCanvasText *ct, const Geom::Point start);
void sp_canvastext_set_text (SPCanvasText *ct, gchar const* new_text);
void sp_canvastext_set_number_as_text (SPCanvasText *ct, int num);
void sp_canvastext_set_fontsize (SPCanvasText *ct, double size);
index 948b89e6afd03eb8a3099af51a89f5d500ad6e6a..9b6b512b01b856bc7e4a94474bcff040895ca3c0 100644 (file)
static void grid_canvasitem_init (GridCanvasItem *grid);
static void grid_canvasitem_destroy (GtkObject *object);
-static void grid_canvasitem_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags);
+static void grid_canvasitem_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags);
static void grid_canvasitem_render (SPCanvasItem *item, SPCanvasBuf *buf);
static SPCanvasItemClass * parent_class;
}
static void
-grid_canvasitem_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags)
+grid_canvasitem_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags)
{
GridCanvasItem *gridcanvasitem = INKSCAPE_GRID_CANVASITEM (item);
@@ -419,13 +419,13 @@ CanvasXYGrid::CanvasXYGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr, SPD
gridunit = sp_unit_get_by_abbreviation( prefs->getString("options.grids.xy", "units").data() );
if (!gridunit)
gridunit = &sp_unit_get_by_id(SP_UNIT_PX);
- origin[NR::X] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "origin_x", 0.0), *gridunit);
- origin[NR::Y] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "origin_y", 0.0), *gridunit);
+ origin[Geom::X] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "origin_x", 0.0), *gridunit);
+ origin[Geom::Y] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "origin_y", 0.0), *gridunit);
color = prefs->getInt("options.grids.xy", "color", 0x0000ff20);
empcolor = prefs->getInt("options.grids.xy", "empcolor", 0x0000ff40);
empspacing = prefs->getInt("options.grids.xy", "empspacing", 5);
- spacing[NR::X] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "spacing_x", 0.0), *gridunit);
- spacing[NR::Y] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "spacing_y", 0.0), *gridunit);
+ spacing[Geom::X] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "spacing_x", 0.0), *gridunit);
+ spacing[Geom::Y] = sp_units_get_pixels(prefs->getDouble("options.grids.xy", "spacing_y", 0.0), *gridunit);
render_dotted = prefs->getBool("options.grids.xy", "dotted", false);
snapper = new CanvasXYGridSnapper(this, &namedview->snap_manager, 0);
{
gchar const *value;
if ( (value = repr->attribute("originx")) ) {
- sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[NR::X], &gridunit);
- origin[NR::X] = sp_units_get_pixels(origin[NR::X], *(gridunit));
+ sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[Geom::X], &gridunit);
+ origin[Geom::X] = sp_units_get_pixels(origin[Geom::X], *(gridunit));
}
if ( (value = repr->attribute("originy")) ) {
- sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[NR::Y], &gridunit);
- origin[NR::Y] = sp_units_get_pixels(origin[NR::Y], *(gridunit));
+ sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[Geom::Y], &gridunit);
+ origin[Geom::Y] = sp_units_get_pixels(origin[Geom::Y], *(gridunit));
}
if ( (value = repr->attribute("spacingx")) ) {
- double oldVal = spacing[NR::X];
- sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &spacing[NR::X], &gridunit);
- validateScalar( oldVal, &spacing[NR::X]);
- spacing[NR::X] = sp_units_get_pixels(spacing[NR::X], *(gridunit));
+ double oldVal = spacing[Geom::X];
+ sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &spacing[Geom::X], &gridunit);
+ validateScalar( oldVal, &spacing[Geom::X]);
+ spacing[Geom::X] = sp_units_get_pixels(spacing[Geom::X], *(gridunit));
}
if ( (value = repr->attribute("spacingy")) ) {
- double oldVal = spacing[NR::Y];
- sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &spacing[NR::Y], &gridunit);
- validateScalar( oldVal, &spacing[NR::Y]);
- spacing[NR::Y] = sp_units_get_pixels(spacing[NR::Y], *(gridunit));
+ double oldVal = spacing[Geom::Y];
+ sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &spacing[Geom::Y], &gridunit);
+ validateScalar( oldVal, &spacing[Geom::Y]);
+ spacing[Geom::Y] = sp_units_get_pixels(spacing[Geom::Y], *(gridunit));
}
_rumg->setUnit (gridunit);
gdouble val;
- val = origin[NR::X];
+ val = origin[Geom::X];
val = sp_pixels_get_units (val, *(gridunit));
_rsu_ox->setValue (val);
- val = origin[NR::Y];
+ val = origin[Geom::Y];
val = sp_pixels_get_units (val, *(gridunit));
_rsu_oy->setValue (val);
- val = spacing[NR::X];
+ val = spacing[Geom::X];
double gridx = sp_pixels_get_units (val, *(gridunit));
_rsu_sx->setValue (gridx);
- val = spacing[NR::Y];
+ val = spacing[Geom::Y];
double gridy = sp_pixels_get_units (val, *(gridunit));
_rsu_sy->setValue (gridy);
_rumg.setUnit (gridunit);
gdouble val;
- val = origin[NR::X];
+ val = origin[Geom::X];
val = sp_pixels_get_units (val, *(gridunit));
_rsu_ox.setValue (val);
- val = origin[NR::Y];
+ val = origin[Geom::Y];
val = sp_pixels_get_units (val, *(gridunit));
_rsu_oy.setValue (val);
- val = spacing[NR::X];
+ val = spacing[Geom::X];
double gridx = sp_pixels_get_units (val, *(gridunit));
_rsu_sx.setValue (gridx);
- val = spacing[NR::Y];
+ val = spacing[Geom::Y];
double gridy = sp_pixels_get_units (val, *(gridunit));
_rsu_sy.setValue (gridy);
void
-CanvasXYGrid::Update (NR::Matrix const &affine, unsigned int /*flags*/)
+CanvasXYGrid::Update (Geom::Matrix const &affine, unsigned int /*flags*/)
{
ow = origin * affine;
sw = spacing * affine;
- sw -= NR::Point(affine[4], affine[5]);
+ sw -= Geom::Point(affine[4], affine[5]);
for(int dim = 0; dim < 2; dim++) {
gint scaling_factor = empspacing;
void
CanvasXYGrid::Render (SPCanvasBuf *buf)
{
- gdouble const sxg = floor ((buf->rect.x0 - ow[NR::X]) / sw[NR::X]) * sw[NR::X] + ow[NR::X];
- gint const xlinestart = (gint) Inkscape::round((sxg - ow[NR::X]) / sw[NR::X]);
- gdouble const syg = floor ((buf->rect.y0 - ow[NR::Y]) / sw[NR::Y]) * sw[NR::Y] + ow[NR::Y];
- gint const ylinestart = (gint) Inkscape::round((syg - ow[NR::Y]) / sw[NR::Y]);
+ gdouble const sxg = floor ((buf->rect.x0 - ow[Geom::X]) / sw[Geom::X]) * sw[Geom::X] + ow[Geom::X];
+ gint const xlinestart = (gint) Inkscape::round((sxg - ow[Geom::X]) / sw[Geom::X]);
+ gdouble const syg = floor ((buf->rect.y0 - ow[Geom::Y]) / sw[Geom::Y]) * sw[Geom::Y] + ow[Geom::Y];
+ gint const ylinestart = (gint) Inkscape::round((syg - ow[Geom::Y]) / sw[Geom::Y]);
//set correct coloring, depending preference (when zoomed out, always major coloring or minor coloring)
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
guint32 _empcolor;
bool no_emp_when_zoomed_out = prefs->getBool("options.grids", "no_emphasize_when_zoomedout", false);
- if( (scaled[NR::X] || scaled[NR::Y]) && no_emp_when_zoomed_out ) {
+ if( (scaled[Geom::X] || scaled[Geom::Y]) && no_emp_when_zoomed_out ) {
_empcolor = color;
} else {
_empcolor = empcolor;
if (!render_dotted) {
gint ylinenum;
gdouble y;
- for (y = syg, ylinenum = ylinestart; y < buf->rect.y1; y += sw[NR::Y], ylinenum++) {
+ for (y = syg, ylinenum = ylinestart; y < buf->rect.y1; y += sw[Geom::Y], ylinenum++) {
gint const y0 = (gint) Inkscape::round(y);
- if (!scaled[NR::Y] && (ylinenum % empspacing) != 0) {
+ if (!scaled[Geom::Y] && (ylinenum % empspacing) != 0) {
grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, color);
} else {
grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, _empcolor);
gint xlinenum;
gdouble x;
- for (x = sxg, xlinenum = xlinestart; x < buf->rect.x1; x += sw[NR::X], xlinenum++) {
+ for (x = sxg, xlinenum = xlinestart; x < buf->rect.x1; x += sw[Geom::X], xlinenum++) {
gint const ix = (gint) Inkscape::round(x);
- if (!scaled[NR::X] && (xlinenum % empspacing) != 0) {
+ if (!scaled[Geom::X] && (xlinenum % empspacing) != 0) {
grid_vline (buf, ix, buf->rect.y0, buf->rect.y1, color);
} else {
grid_vline (buf, ix, buf->rect.y0, buf->rect.y1, _empcolor);
} else {
gint ylinenum;
gdouble y;
- for (y = syg, ylinenum = ylinestart; y < buf->rect.y1; y += sw[NR::Y], ylinenum++) {
+ for (y = syg, ylinenum = ylinestart; y < buf->rect.y1; y += sw[Geom::Y], ylinenum++) {
gint const iy = (gint) Inkscape::round(y);
gint xlinenum;
gdouble x;
- for (x = sxg, xlinenum = xlinestart; x < buf->rect.x1; x += sw[NR::X], xlinenum++) {
+ for (x = sxg, xlinenum = xlinestart; x < buf->rect.x1; x += sw[Geom::X], xlinenum++) {
gint const ix = (gint) Inkscape::round(x);
- if ( (!scaled[NR::X] && (xlinenum % empspacing) != 0)
- || (!scaled[NR::Y] && (ylinenum % empspacing) != 0)
- || ((scaled[NR::X] || scaled[NR::Y]) && no_emp_when_zoomed_out) )
+ if ( (!scaled[Geom::X] && (xlinenum % empspacing) != 0)
+ || (!scaled[Geom::Y] && (ylinenum % empspacing) != 0)
+ || ((scaled[Geom::X] || scaled[Geom::Y]) && no_emp_when_zoomed_out) )
{
grid_dot (buf, ix, iy, color | (guint32)0x000000FF); // put alpha to max value
} else {
}
}
-CanvasXYGridSnapper::CanvasXYGridSnapper(CanvasXYGrid *grid, SnapManager const *sm, NR::Coord const d) : LineSnapper(sm, d)
+CanvasXYGridSnapper::CanvasXYGridSnapper(CanvasXYGrid *grid, SnapManager const *sm, Geom::Coord const d) : LineSnapper(sm, d)
{
this->grid = grid;
}
index 20cb314730a366125c37be7567764c451a007359..66f3bc43cbce0562ec4de9f6caa697052243270b 100644 (file)
GridCanvasItem * createCanvasItem(SPDesktop * desktop);
- virtual void Update (NR::Matrix const &affine, unsigned int flags) = 0;
+ virtual void Update (Geom::Matrix const &affine, unsigned int flags) = 0;
virtual void Render (SPCanvasBuf *buf) = 0;
virtual void readRepr() = 0;
Gtk::Widget * newWidget();
- NR::Point origin; /**< Origin of the grid */
+ Geom::Point origin; /**< Origin of the grid */
guint32 color; /**< Color for normal lines */
guint32 empcolor; /**< Color for emphasis lines */
gint empspacing; /**< Spacing between emphasis lines */
CanvasXYGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc);
virtual ~CanvasXYGrid();
- void Update (NR::Matrix const &affine, unsigned int flags);
+ void Update (Geom::Matrix const &affine, unsigned int flags);
void Render (SPCanvasBuf *buf);
void readRepr();
void onReprAttrChanged (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive);
- NR::Point spacing; /**< Spacing between elements of the grid */
+ Geom::Point spacing; /**< Spacing between elements of the grid */
bool scaled[2]; /**< Whether the grid is in scaled mode, which can
be different in the X or Y direction, hense two
variables */
- NR::Point ow; /**< Transformed origin by the affine for the zoom */
- NR::Point sw; /**< Transformed spacing by the affine for the zoom */
+ Geom::Point ow; /**< Transformed origin by the affine for the zoom */
+ Geom::Point sw; /**< Transformed spacing by the affine for the zoom */
protected:
virtual Gtk::Widget * newSpecificWidget();
index ee6834075ab1156b4aa032639748488a5cfb2eb9..fdb137e2722dd0e7fa744769b9d8d30b74e7ebf7 100644 (file)
static void sp_canvas_acetate_init (SPCanvasAcetate *acetate);
static void sp_canvas_acetate_destroy (GtkObject *object);
-static void sp_canvas_acetate_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags);
-static double sp_canvas_acetate_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item);
+static void sp_canvas_acetate_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags);
+static double sp_canvas_acetate_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item);
static SPCanvasItemClass *parent_class;
}
static void
-sp_canvas_acetate_update( SPCanvasItem *item, NR::Matrix const &/*affine*/, unsigned int /*flags*/ )
+sp_canvas_acetate_update( SPCanvasItem *item, Geom::Matrix const &/*affine*/, unsigned int /*flags*/ )
{
item->x1 = -G_MAXINT;
item->y1 = -G_MAXINT;
}
static double
-sp_canvas_acetate_point( SPCanvasItem *item, NR::Point /*p*/, SPCanvasItem **actual_item )
+sp_canvas_acetate_point( SPCanvasItem *item, Geom::Point /*p*/, SPCanvasItem **actual_item )
{
*actual_item = item;
index e2e014eff97162ff9b016c16e8e12a3a35bae381..cd1a122131f33dbb1a3ea1c34513878c4614dd2a 100644 (file)
#include <libnr/nr-pixops.h>
+#include <2geom/transforms.h>
#include "display-forward.h"
#include "sp-canvas-util.h"
#include "guideline.h"
static void sp_guideline_init(SPGuideLine *guideline);
static void sp_guideline_destroy(GtkObject *object);
-static void sp_guideline_update(SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags);
+static void sp_guideline_update(SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags);
static void sp_guideline_render(SPCanvasItem *item, SPCanvasBuf *buf);
-static double sp_guideline_point(SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item);
+static double sp_guideline_point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item);
static void sp_guideline_drawline (SPCanvasBuf *buf, gint x0, gint y0, gint x1, gint y1, guint32 rgba);
}
}
-static void sp_guideline_update(SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags)
+static void sp_guideline_update(SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags)
{
SPGuideLine *gl = SP_GUIDELINE(item);
@@ -189,7 +190,7 @@ static void sp_guideline_update(SPCanvasItem *item, NR::Matrix const &affine, un
}
// Returns 0.0 if point is on the guideline
-static double sp_guideline_point(SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item)
+static double sp_guideline_point(SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item)
{
SPGuideLine *gl = SP_GUIDELINE (item);
@@ -221,7 +222,7 @@ SPCanvasItem *sp_guideline_new(SPCanvasGroup *parent, Geom::Point point_on_line,
void sp_guideline_set_position(SPGuideLine *gl, Geom::Point point_on_line)
{
sp_canvas_item_affine_absolute(SP_CANVAS_ITEM (gl),
- NR::Matrix(NR::translate(point_on_line)));
+ Geom::Matrix(Geom::Translate(point_on_line)));
}
void sp_guideline_set_normal(SPGuideLine *gl, Geom::Point normal_to_line)
index 554ea2dc9d67477a0677775d88962b07cba1bef4..751801c7efa90c48a51f5bf76f86dd2d171d1a22 100644 (file)
@@ -1094,7 +1094,7 @@ nr_arena_shape_pick(NRArenaItem *item, NR::Point p, double delta, unsigned int /
&& shape->_fill.opacity > 1e-3 && !outline);
if (item->arena->canvasarena) {
- Geom::Rect viewbox = to_2geom(item->arena->canvasarena->item.canvas->getViewbox());
+ Geom::Rect viewbox = item->arena->canvasarena->item.canvas->getViewbox();
viewbox.expandBy (width);
pathv_matrix_point_bbox_wind_distance(shape->curve->get_pathvector(), shape->ctm, p, NULL, needfill? &wind : NULL, &dist, 0.5, &viewbox);
} else {
index db199d3a51e2421a0d6a72fe1414689506f2420f..1bed9355d234ee3b94c1a8dcd0bf5167074db971 100644 (file)
*
*/
+#include <2geom/transforms.h>
#include "sp-canvas-util.h"
#include "display-forward.h"
#include "sodipodi-ctrl.h"
static void sp_ctrl_destroy (GtkObject *object);
static void sp_ctrl_set_arg (GtkObject *object, GtkArg *arg, guint arg_id);
-static void sp_ctrl_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags);
+static void sp_ctrl_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags);
static void sp_ctrl_render (SPCanvasItem *item, SPCanvasBuf *buf);
-static double sp_ctrl_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item);
+static double sp_ctrl_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item);
static SPCanvasItemClass *parent_class;
}
static void
-sp_ctrl_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags)
+sp_ctrl_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags)
{
SPCtrl *ctrl;
gint x, y;
@@ -272,14 +273,14 @@ sp_ctrl_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags
}
static double
-sp_ctrl_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item)
+sp_ctrl_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item)
{
SPCtrl *ctrl = SP_CTRL (item);
*actual_item = item;
- double const x = p[NR::X];
- double const y = p[NR::Y];
+ double const x = p[Geom::X];
+ double const y = p[Geom::Y];
if ((x >= ctrl->box.x0) && (x <= ctrl->box.x1) && (y >= ctrl->box.y0) && (y <= ctrl->box.y1)) return 0.0;
ctrl->shown = TRUE;
}
-void SPCtrl::moveto (NR::Point const p) {
- sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (this), NR::Matrix(NR::translate (p)));
+void SPCtrl::moveto (Geom::Point const p) {
+ sp_canvas_item_affine_absolute (SP_CANVAS_ITEM (this), Geom::Matrix(Geom::Translate (p)));
_moved = true;
}
index 2a68d19431debe0ceb9eb645d3bcd41417565e3c..634e9ff3ecad7271d802c1dbf7231ae6d4bf1e24 100644 (file)
guchar *cache;
GdkPixbuf * pixbuf;
- void moveto(NR::Point const p);
+ void moveto(Geom::Point const p);
};
struct SPCtrlClass : public SPCanvasItemClass{
index 28c76e7045e1f869dc529b74c233b02f47b10a65..682488efc8d2b28a27dd4d687891e282134e2b20 100644 (file)
static void sp_ctrlrect_init(CtrlRect *ctrlrect);
static void sp_ctrlrect_destroy(GtkObject *object);
-static void sp_ctrlrect_update(SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags);
+static void sp_ctrlrect_update(SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags);
static void sp_ctrlrect_render(SPCanvasItem *item, SPCanvasBuf *buf);
static SPCanvasItemClass *parent_class;
}
-static void sp_ctrlrect_update(SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags)
+static void sp_ctrlrect_update(SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags)
{
SP_CTRLRECT(item)->update(affine, flags);
}
_area.x0 = _area.y0 = 0;
_area.x1 = _area.y1 = 0;
- _rect = NR::Rect(NR::Point(0,0),NR::Point(0,0));
+ _rect = Geom::Rect(Geom::Point(0,0),Geom::Point(0,0));
_shadow_size = 0;
}
-void CtrlRect::update(NR::Matrix const &affine, unsigned int flags)
+void CtrlRect::update(Geom::Matrix const &affine, unsigned int flags)
{
if (((SPCanvasItemClass *) parent_class)->update) {
((SPCanvasItemClass *) parent_class)->update(this, affine, flags);
}
}
- NR::Rect bbox(_rect.min() * affine, _rect.max() * affine);
+ Geom::Rect bbox(_rect.min() * affine, _rect.max() * affine);
- _area.x0 = (int) floor(bbox.min()[NR::X] + 0.5);
- _area.y0 = (int) floor(bbox.min()[NR::Y] + 0.5);
- _area.x1 = (int) floor(bbox.max()[NR::X] + 0.5);
- _area.y1 = (int) floor(bbox.max()[NR::Y] + 0.5);
+ _area.x0 = (int) floor(bbox.min()[Geom::X] + 0.5);
+ _area.y0 = (int) floor(bbox.min()[Geom::Y] + 0.5);
+ _area.x1 = (int) floor(bbox.max()[Geom::X] + 0.5);
+ _area.y1 = (int) floor(bbox.max()[Geom::Y] + 0.5);
_shadow_size = _shadow;
_requestUpdate();
}
-void CtrlRect::setRectangle(NR::Rect const &r)
+void CtrlRect::setRectangle(Geom::Rect const &r)
{
_rect = r;
_requestUpdate();
index dc931b7dc1caedeb0101919fa0d57eb4a5f7e757..7e5f5157e13c0df1636209fa48f7ce42126d2031 100644 (file)
void init();
void setColor(guint32 b, bool h, guint f);
void setShadow(int s, guint c);
- void setRectangle(NR::Rect const &r);
+ void setRectangle(Geom::Rect const &r);
void setDashed(bool d);
void render(SPCanvasBuf *buf);
- void update(NR::Matrix const &affine, unsigned int flags);
+ void update(Geom::Matrix const &affine, unsigned int flags);
private:
void _requestUpdate();
- NR::Rect _rect;
+ Geom::Rect _rect;
bool _has_fill;
bool _dashed;
NRRectL _area;
index 9be8d5844d41a238f0d1cc89f63524e4a59f2ace..4badb6c3e4056eadcee5947afb96699553627d2c 100644 (file)
}
}
-NR::Matrix sp_canvas_item_i2p_affine (SPCanvasItem * item)
+Geom::Matrix sp_canvas_item_i2p_affine (SPCanvasItem * item)
{
g_assert (item != NULL); /* this may be overly zealous - it is
* plausible that this gets called
return item->xform;
}
-NR::Matrix sp_canvas_item_i2i_affine (SPCanvasItem * from, SPCanvasItem * to)
+Geom::Matrix sp_canvas_item_i2i_affine (SPCanvasItem * from, SPCanvasItem * to)
{
g_assert (from != NULL);
g_assert (to != NULL);
return sp_canvas_item_i2w_affine(from) * sp_canvas_item_i2w_affine(to).inverse();
}
-void sp_canvas_item_set_i2w_affine (SPCanvasItem * item, NR::Matrix const &i2w)
+void sp_canvas_item_set_i2w_affine (SPCanvasItem * item, Geom::Matrix const &i2w)
{
g_assert (item != NULL);
index 0b2ec40d74ad747677d92be7725d192fefd4c252..4708126e5e182baa2c6a5724c75cec0c5df750cf 100644 (file)
/* get i2p (item to parent) affine transformation as general 6-element array */
-NR::Matrix sp_canvas_item_i2p_affine (SPCanvasItem * item);
+Geom::Matrix sp_canvas_item_i2p_affine (SPCanvasItem * item);
/* get i2i (item to item) affine transformation as general 6-element array */
-NR::Matrix sp_canvas_item_i2i_affine (SPCanvasItem * from, SPCanvasItem * to);
+Geom::Matrix sp_canvas_item_i2i_affine (SPCanvasItem * from, SPCanvasItem * to);
/* set item affine matrix to achieve given i2w matrix */
-void sp_canvas_item_set_i2w_affine (SPCanvasItem * item, NR::Matrix const & aff);
+void sp_canvas_item_set_i2w_affine (SPCanvasItem * item, Geom::Matrix const & aff);
void sp_canvas_item_move_to_z (SPCanvasItem * item, gint z);
index 3beb26b72733503103c65831a4dfd62df06706f0..fd124aa1e42c03db01909db7b10cc231c7a131a5 100644 (file)
sp_canvas_item_init (SPCanvasItem *item)
{
item->flags |= SP_CANVAS_ITEM_VISIBLE;
- item->xform = NR::Matrix(NR::identity());
+ item->xform = Geom::Matrix(Geom::identity());
}
/**
// this redraws only the stroke of the rect to be deleted,
// avoiding redraw of the entire area
if (SP_IS_CTRLRECT(item)) {
- SP_CTRLRECT(object)->setRectangle(NR::Rect(NR::Point(0,0),NR::Point(0,0)));
+ SP_CTRLRECT(object)->setRectangle(Geom::Rect(Geom::Point(0,0),Geom::Point(0,0)));
SP_CTRLRECT(object)->update(item->xform, 0);
} else {
redraw_if_visible (item);
* NB! affine is parent2canvas.
*/
static void
-sp_canvas_item_invoke_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags)
+sp_canvas_item_invoke_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags)
{
/* Apply the child item's transform */
- NR::Matrix child_affine = item->xform * affine;
+ Geom::Matrix child_affine = item->xform * affine;
/* apply object flags to child flags */
int child_flags = flags & ~SP_CANVAS_UPDATE_REQUESTED;
@@ -331,7 +331,7 @@ sp_canvas_item_invoke_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **a
* @affine: An affine transformation matrix.
*/
void
-sp_canvas_item_affine_absolute (SPCanvasItem *item, NR::Matrix const &affine)
+sp_canvas_item_affine_absolute (SPCanvasItem *item, Geom::Matrix const &affine)
{
item->xform = affine;
* Returns the product of all transformation matrices from the root item down
* to the item.
*/
-NR::Matrix sp_canvas_item_i2w_affine(SPCanvasItem const *item)
+Geom::Matrix sp_canvas_item_i2w_affine(SPCanvasItem const *item)
{
g_assert (SP_IS_CANVAS_ITEM (item)); // should we get this?
- NR::Matrix affine = NR::identity();
+ Geom::Matrix affine = Geom::identity();
while (item) {
affine *= item->xform;
static void sp_canvas_group_init (SPCanvasGroup *group);
static void sp_canvas_group_destroy (GtkObject *object);
-static void sp_canvas_group_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags);
-static double sp_canvas_group_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item);
+static void sp_canvas_group_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags);
+static double sp_canvas_group_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item);
static void sp_canvas_group_render (SPCanvasItem *item, SPCanvasBuf *buf);
static SPCanvasItemClass *group_parent_class;
* Update handler for canvas groups
*/
static void
-sp_canvas_group_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags)
+sp_canvas_group_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags)
{
SPCanvasGroup const *group = SP_CANVAS_GROUP (item);
- NR::ConvexHull corners(NR::Point(0, 0));
+ NR::ConvexHull corners(Geom::Point(0, 0));
bool empty=true;
for (GList *list = group->items; list; list = list->next) {
@@ -783,12 +783,12 @@ sp_canvas_group_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned i
if ( i->x2 > i->x1 && i->y2 > i->y1 ) {
if (empty) {
- corners = NR::ConvexHull(NR::Point(i->x1, i->y1));
+ corners = NR::ConvexHull(Geom::Point(i->x1, i->y1));
empty = false;
} else {
- corners.add(NR::Point(i->x1, i->y1));
+ corners.add(Geom::Point(i->x1, i->y1));
}
- corners.add(NR::Point(i->x2, i->y2));
+ corners.add(Geom::Point(i->x2, i->y2));
}
}
@@ -808,11 +808,11 @@ sp_canvas_group_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned i
* Point handler for canvas groups.
*/
static double
-sp_canvas_group_point (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item)
+sp_canvas_group_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item)
{
SPCanvasGroup const *group = SP_CANVAS_GROUP (item);
- double const x = p[NR::X];
- double const y = p[NR::Y];
+ double const x = p[Geom::X];
+ double const y = p[Geom::Y];
int x1 = (int)(x - item->canvas->close_enough);
int y1 = (int)(y - item->canvas->close_enough);
int x2 = (int)(x + item->canvas->close_enough);
lo.x1 = mid;
hi.x0 = mid;
- if (setup->mouse_loc[NR::X] < mid) {
+ if (setup->mouse_loc[Geom::X] < mid) {
// Always paint towards the mouse first
return sp_canvas_paint_rect_internal(setup, lo)
&& sp_canvas_paint_rect_internal(setup, hi);
lo.y1 = mid;
hi.y0 = mid;
- if (setup->mouse_loc[NR::Y] < mid) {
+ if (setup->mouse_loc[Geom::Y] < mid) {
// Always paint towards the mouse first
return sp_canvas_paint_rect_internal(setup, lo)
&& sp_canvas_paint_rect_internal(setup, hi);
paint (SPCanvas *canvas)
{
if (canvas->need_update) {
- sp_canvas_item_invoke_update (canvas->root, NR::identity(), 0);
+ sp_canvas_item_invoke_update (canvas->root, Geom::identity(), 0);
canvas->need_update = FALSE;
}
/* Cause the update if necessary */
if (canvas->need_update) {
- sp_canvas_item_invoke_update (canvas->root, NR::identity(), 0);
+ sp_canvas_item_invoke_update (canvas->root, Geom::identity(), 0);
canvas->need_update = FALSE;
}
@@ -2296,23 +2296,21 @@ bool sp_canvas_world_pt_inside_window(SPCanvas const *canvas, Geom::Point const
g_assert( canvas != NULL );
g_assert(SP_IS_CANVAS(canvas));
- using NR::X;
- using NR::Y;
GtkWidget const &w = *GTK_WIDGET(canvas);
- return ( ( canvas->x0 <= world[X] ) &&
- ( canvas->y0 <= world[Y] ) &&
- ( world[X] < canvas->x0 + w.allocation.width ) &&
- ( world[Y] < canvas->y0 + w.allocation.height ) );
+ return ( ( canvas->x0 <= world[Geom::X] ) &&
+ ( canvas->y0 <= world[Geom::Y] ) &&
+ ( world[Geom::X] < canvas->x0 + w.allocation.width ) &&
+ ( world[Geom::Y] < canvas->y0 + w.allocation.height ) );
}
/**
- * Return canvas window coordinates as NR::Rect.
+ * Return canvas window coordinates as Geom::Rect.
*/
-NR::Rect SPCanvas::getViewbox() const
+Geom::Rect SPCanvas::getViewbox() const
{
GtkWidget const *w = GTK_WIDGET(this);
- return NR::Rect(Geom::Point(dx0, dy0),
- Geom::Point(dx0 + w->allocation.width, dy0 + w->allocation.height));
+ return Geom::Rect(Geom::Point(dx0, dy0),
+ Geom::Point(dx0 + w->allocation.width, dy0 + w->allocation.height));
}
/**
index 8f743436fcd661186e17867841f630dbdcca59ee..60bda581825c7aa94017cee1279bd891c9934a92 100644 (file)
--- a/src/display/sp-canvas.h
+++ b/src/display/sp-canvas.h
#include <glibmm/ustring.h>
#include <libnr/nr-matrix.h>
-#include <libnr/nr-rect.h>
#include <libnr/nr-rect-l.h>
+#include <2geom/rect.h>
+
G_BEGIN_DECLS
struct SPCanvas;
double x1, y1, x2, y2;
NR::Rect bounds;
- NR::Matrix xform;
+ Geom::Matrix xform;
};
/**
* The vtable of an SPCanvasItem.
*/
struct _SPCanvasItemClass : public GtkObjectClass {
- void (* update) (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags);
+ void (* update) (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags);
void (* render) (SPCanvasItem *item, SPCanvasBuf *buf);
- double (* point) (SPCanvasItem *item, NR::Point p, SPCanvasItem **actual_item);
+ double (* point) (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item);
int (* event) (SPCanvasItem *item, GdkEvent *event);
};
#define sp_canvas_item_set gtk_object_set
-void sp_canvas_item_affine_absolute(SPCanvasItem *item, NR::Matrix const &aff);
+void sp_canvas_item_affine_absolute(SPCanvasItem *item, Geom::Matrix const &aff);
void sp_canvas_item_raise(SPCanvasItem *item, int positions);
void sp_canvas_item_lower(SPCanvasItem *item, int positions);
int sp_canvas_item_grab(SPCanvasItem *item, unsigned int event_mask, GdkCursor *cursor, guint32 etime);
void sp_canvas_item_ungrab(SPCanvasItem *item, guint32 etime);
-NR::Matrix sp_canvas_item_i2w_affine(SPCanvasItem const *item);
+Geom::Matrix sp_canvas_item_i2w_affine(SPCanvasItem const *item);
void sp_canvas_item_grab_focus(SPCanvasItem *item);
bool is_scrolling;
- NR::Rect getViewbox() const;
+ Geom::Rect getViewbox() const;
NR::IRect getViewboxIntegers() const;
};
index 8f71a0cc0b130d2bb758f31d4a90e7d88c5a6cb7..be0b8d1c6e24ceff78fe284d0a81174ccb39831c 100644 (file)
static void sp_ctrlline_init (SPCtrlLine *ctrlline);
static void sp_ctrlline_destroy (GtkObject *object);
-static void sp_ctrlline_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags);
+static void sp_ctrlline_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags);
static void sp_ctrlline_render (SPCanvasItem *item, SPCanvasBuf *buf);
static SPCanvasItemClass *parent_class;
sp_ctrlline_init (SPCtrlLine *ctrlline)
{
ctrlline->rgba = 0x0000ff7f;
- ctrlline->s[NR::X] = ctrlline->s[NR::Y] = ctrlline->e[NR::X] = ctrlline->e[NR::Y] = 0.0;
+ ctrlline->s[Geom::X] = ctrlline->s[Geom::Y] = ctrlline->e[Geom::X] = ctrlline->e[Geom::Y] = 0.0;
ctrlline->item=NULL;
}
cairo_set_line_width(buf->ct, 1);
cairo_new_path(buf->ct);
- NR::Point s = cl->s * cl->affine;
- NR::Point e = cl->e * cl->affine;
+ Geom::Point s = cl->s * cl->affine;
+ Geom::Point e = cl->e * cl->affine;
- cairo_move_to (buf->ct, s[NR::X] - buf->rect.x0, s[NR::Y] - buf->rect.y0);
- cairo_line_to (buf->ct, e[NR::X] - buf->rect.x0, e[NR::Y] - buf->rect.y0);
+ cairo_move_to (buf->ct, s[Geom::X] - buf->rect.x0, s[Geom::Y] - buf->rect.y0);
+ cairo_line_to (buf->ct, e[Geom::X] - buf->rect.x0, e[Geom::Y] - buf->rect.y0);
cairo_stroke(buf->ct);
}
static void
-sp_ctrlline_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags)
+sp_ctrlline_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags)
{
SPCtrlLine *cl = SP_CTRLLINE (item);
@@ -134,13 +134,13 @@ sp_ctrlline_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int f
cl->affine = affine;
- NR::Point s = cl->s * affine;
- NR::Point e = cl->e * affine;
+ Geom::Point s = cl->s * affine;
+ Geom::Point e = cl->e * affine;
- item->x1 = round(MIN(s[NR::X], e[NR::X]) - 1);
- item->y1 = round(MIN(s[NR::Y], e[NR::Y]) - 1);
- item->x2 = round(MAX(s[NR::X], e[NR::X]) + 1);
- item->y2 = round(MAX(s[NR::Y], e[NR::Y]) + 1);
+ item->x1 = round(MIN(s[Geom::X], e[Geom::X]) - 1);
+ item->y1 = round(MIN(s[Geom::Y], e[Geom::Y]) - 1);
+ item->x2 = round(MAX(s[Geom::X], e[Geom::X]) + 1);
+ item->y2 = round(MAX(s[Geom::Y], e[Geom::Y]) + 1);
sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
}
@@ -168,17 +168,17 @@ sp_ctrlline_set_coords (SPCtrlLine *cl, gdouble x0, gdouble y0, gdouble x1, gdou
g_return_if_fail (cl != NULL);
g_return_if_fail (SP_IS_CTRLLINE (cl));
- if (DIFFER (x0, cl->s[NR::X]) || DIFFER (y0, cl->s[NR::Y]) || DIFFER (x1, cl->e[NR::X]) || DIFFER (y1, cl->e[NR::Y])) {
- cl->s[NR::X] = x0;
- cl->s[NR::Y] = y0;
- cl->e[NR::X] = x1;
- cl->e[NR::Y] = y1;
+ if (DIFFER (x0, cl->s[Geom::X]) || DIFFER (y0, cl->s[Geom::Y]) || DIFFER (x1, cl->e[Geom::X]) || DIFFER (y1, cl->e[Geom::Y])) {
+ cl->s[Geom::X] = x0;
+ cl->s[Geom::Y] = y0;
+ cl->e[Geom::X] = x1;
+ cl->e[Geom::Y] = y1;
sp_canvas_item_request_update (SP_CANVAS_ITEM (cl));
}
}
void
-sp_ctrlline_set_coords (SPCtrlLine *cl, const NR::Point start, const NR::Point end)
+sp_ctrlline_set_coords (SPCtrlLine *cl, const Geom::Point start, const Geom::Point end)
{
sp_ctrlline_set_coords(cl, start[0], start[1], end[0], end[1]);
}
index 88bebe601b3105f978ef2ca15d365abdf68bdff6..696fb52eeaac77610644317f9188f8ac9c4854f1 100644 (file)
struct SPCtrlLine : public SPCanvasItem{
SPItem *item; // the item to which this line belongs in some sense; may be NULL for some users
guint32 rgba;
- NR::Point s, e;
- NR::Matrix affine;
+ Geom::Point s, e;
+ Geom::Matrix affine;
};
struct SPCtrlLineClass : public SPCanvasItemClass{};
void sp_ctrlline_set_rgba32 (SPCtrlLine *cl, guint32 rgba);
void sp_ctrlline_set_coords (SPCtrlLine *cl, gdouble x0, gdouble y0, gdouble x1, gdouble y1);
-void sp_ctrlline_set_coords (SPCtrlLine *cl, const NR::Point start, const NR::Point end);
+void sp_ctrlline_set_coords (SPCtrlLine *cl, const Geom::Point start, const Geom::Point end);
index c8a71512dda99319371ea50d21d7e6bbb316c887..31766c3c277bd5dce1b8d8ca84bd37611a9b732d 100644 (file)
struct SPCtrlQuadr : public SPCanvasItem{
guint32 rgba;
- NR::Point p1, p2, p3, p4;
- NR::Matrix affine;
+ Geom::Point p1, p2, p3, p4;
+ Geom::Matrix affine;
};
struct SPCtrlQuadrClass : public SPCanvasItemClass{};
static void sp_ctrlquadr_init (SPCtrlQuadr *ctrlquadr);
static void sp_ctrlquadr_destroy (GtkObject *object);
-static void sp_ctrlquadr_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags);
+static void sp_ctrlquadr_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags);
static void sp_ctrlquadr_render (SPCanvasItem *item, SPCanvasBuf *buf);
static SPCanvasItemClass *parent_class;
sp_ctrlquadr_init (SPCtrlQuadr *ctrlquadr)
{
ctrlquadr->rgba = 0x000000ff;
- ctrlquadr->p1 = NR::Point(0, 0);
- ctrlquadr->p2 = NR::Point(0, 0);
- ctrlquadr->p3 = NR::Point(0, 0);
- ctrlquadr->p4 = NR::Point(0, 0);
+ ctrlquadr->p1 = Geom::Point(0, 0);
+ ctrlquadr->p2 = Geom::Point(0, 0);
+ ctrlquadr->p3 = Geom::Point(0, 0);
+ ctrlquadr->p4 = Geom::Point(0, 0);
}
static void
{
SPCtrlQuadr *cq = SP_CTRLQUADR (item);
- NR::Rect area (NR::Point(buf->rect.x0, buf->rect.y0), NR::Point(buf->rect.x1, buf->rect.y1));
+ //NR::Rect area (NR::Point(buf->rect.x0, buf->rect.y0), NR::Point(buf->rect.x1, buf->rect.y1));
if (!buf->ct)
return;
// RGB / BGR
cairo_new_path(buf->ct);
- NR::Point min = NR::Point(buf->rect.x0, buf->rect.y0);
+ Geom::Point min = Geom::Point(buf->rect.x0, buf->rect.y0);
- NR::Point p1 = (cq->p1 * cq->affine) - min;
- NR::Point p2 = (cq->p2 * cq->affine) - min;
- NR::Point p3 = (cq->p3 * cq->affine) - min;
- NR::Point p4 = (cq->p4 * cq->affine) - min;
+ Geom::Point p1 = (cq->p1 * cq->affine) - min;
+ Geom::Point p2 = (cq->p2 * cq->affine) - min;
+ Geom::Point p3 = (cq->p3 * cq->affine) - min;
+ Geom::Point p4 = (cq->p4 * cq->affine) - min;
- cairo_move_to(buf->ct, p1[NR::X], p1[NR::Y]);
- cairo_line_to(buf->ct, p2[NR::X], p2[NR::Y]);
- cairo_line_to(buf->ct, p3[NR::X], p3[NR::Y]);
- cairo_line_to(buf->ct, p4[NR::X], p4[NR::Y]);
- cairo_line_to(buf->ct, p1[NR::X], p1[NR::Y]);
+ cairo_move_to(buf->ct, p1[Geom::X], p1[Geom::Y]);
+ cairo_line_to(buf->ct, p2[Geom::X], p2[Geom::Y]);
+ cairo_line_to(buf->ct, p3[Geom::X], p3[Geom::Y]);
+ cairo_line_to(buf->ct, p4[Geom::X], p4[Geom::Y]);
+ cairo_line_to(buf->ct, p1[Geom::X], p1[Geom::Y]);
// FIXME: this is supposed to draw inverse but cairo apparently is unable of this trick :(
//cairo_set_operator (buf->ct, CAIRO_OPERATOR_XOR);
static void
-sp_ctrlquadr_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags)
+sp_ctrlquadr_update (SPCanvasItem *item, Geom::Matrix const &affine, unsigned int flags)
{
SPCtrlQuadr *cq = SP_CTRLQUADR (item);
@@ -152,15 +152,15 @@ sp_ctrlquadr_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int
cq->affine = affine;
- NR::Point p1(cq->p1 * affine);
- NR::Point p2(cq->p2 * affine);
- NR::Point p3(cq->p3 * affine);
- NR::Point p4(cq->p4 * affine);
+ Geom::Point p1(cq->p1 * affine);
+ Geom::Point p2(cq->p2 * affine);
+ Geom::Point p3(cq->p3 * affine);
+ Geom::Point p4(cq->p4 * affine);
- item->x1 = (int)(MIN4(p1[NR::X], p2[NR::X], p3[NR::X], p4[NR::X]));
- item->y1 = (int)(MIN4(p1[NR::Y], p2[NR::Y], p3[NR::Y], p4[NR::Y]));
- item->x2 = (int)(MAX4(p1[NR::X], p2[NR::X], p3[NR::X], p4[NR::X]));
- item->y2 = (int)(MAX4(p1[NR::Y], p2[NR::Y], p3[NR::Y], p4[NR::Y]));
+ item->x1 = (int)(MIN4(p1[Geom::X], p2[Geom::X], p3[Geom::X], p4[Geom::X]));
+ item->y1 = (int)(MIN4(p1[Geom::Y], p2[Geom::Y], p3[Geom::Y], p4[Geom::Y]));
+ item->x2 = (int)(MAX4(p1[Geom::X], p2[Geom::X], p3[Geom::X], p4[Geom::X]));
+ item->y2 = (int)(MAX4(p1[Geom::Y], p2[Geom::Y], p3[Geom::Y], p4[Geom::Y]));
sp_canvas_request_redraw (item->canvas, (int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2);
}
}
void
-sp_ctrlquadr_set_coords (SPCtrlQuadr *cl, NR::Point p1, NR::Point p2, NR::Point p3, NR::Point p4)
+sp_ctrlquadr_set_coords (SPCtrlQuadr *cl, Geom::Point p1, Geom::Point p2, Geom::Point p3, Geom::Point p4)
{
g_return_if_fail (cl != NULL);
g_return_if_fail (SP_IS_CTRLQUADR (cl));
index c32d2c376e8a51b812aecd4b03a5a3829eaf1f42..996c02295aded72f2534541a4d22815d16ee5792 100644 (file)
GType sp_ctrlquadr_get_type (void);
void sp_ctrlquadr_set_rgba32 (SPCtrlQuadr *cl, guint32 rgba);
-void sp_ctrlquadr_set_coords (SPCtrlQuadr *cl, const NR::Point p1, const NR::Point p2, const NR::Point p3, const NR::Point p4);
+void sp_ctrlquadr_set_coords (SPCtrlQuadr *cl, const Geom::Point p1, const Geom::Point p2, const Geom::Point p3, const Geom::Point p4);
#endif
diff --git a/src/document.cpp b/src/document.cpp
index 716260b28a4b2ab0df3b0bce13bab8b0b934b803..57ac0f1f15ffde8c4ebb5e37bcf61d90dcae7830 100644 (file)
--- a/src/document.cpp
+++ b/src/document.cpp
* this function fits the canvas to that rect by resizing the canvas
* and translating the document root into position.
*/
-void SPDocument::fitToRect(NR::Rect const &rect)
+void SPDocument::fitToRect(Geom::Rect const &rect)
{
g_return_if_fail(!rect.isEmpty());
- using NR::X; using NR::Y;
- double const w = rect.extent(X);
- double const h = rect.extent(Y);
+ double const w = rect.width();
+ double const h = rect.height();
double const old_height = sp_document_height(this);
SPUnit const &px(sp_unit_get_by_id(SP_UNIT_PX));
SP_GROUP(root)->translateChildItems(tr);
SPNamedView *nv = sp_document_namedview(this, 0);
if(nv) {
- NR::translate tr2(-rect.min());
+ Geom::Translate tr2(-rect.min());
nv->translateGuides(tr2);
// update the viewport so the drawing appears to stay where it was
}
}
-static bool is_within(NR::Rect const &area, NR::Rect const &box)
+static bool is_within(Geom::Rect const &area, Geom::Rect const &box)
{
return area.contains(box);
}
-static bool overlaps(NR::Rect const &area, NR::Rect const &box)
+static bool overlaps(Geom::Rect const &area, Geom::Rect const &box)
{
return area.intersects(box);
}
-static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey, NR::Rect const &area,
- bool (*test)(NR::Rect const &, NR::Rect const &), bool take_insensitive = false)
+static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey, Geom::Rect const &area,
+ bool (*test)(Geom::Rect const &, Geom::Rect const &), bool take_insensitive = false)
{
g_return_val_if_fail(SP_IS_GROUP(group), s);
s = find_items_in_area(s, SP_GROUP(o), dkey, area, test);
} else {
SPItem *child = SP_ITEM(o);
- boost::optional<NR::Rect> box = sp_item_bbox_desktop(child);
+ boost::optional<Geom::Rect> box = to_2geom(sp_item_bbox_desktop(child));
if ( box && test(area, *box) && (take_insensitive || child->isVisibleAndUnlocked(dkey))) {
s = g_slist_append(s, child);
}
@@ -931,7 +930,7 @@ Returns the bottommost item from the list which is at the point, or NULL if none
*/
SPItem*
sp_document_item_from_list_at_point_bottom(unsigned int dkey, SPGroup *group, GSList const *list,
- NR::Point const p, bool take_insensitive)
+ Geom::Point const p, bool take_insensitive)
{
g_return_val_if_fail(group, NULL);
guaranteed to be lower than upto).
*/
SPItem*
-find_item_at_point(unsigned int dkey, SPGroup *group, NR::Point const p, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL)
+find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL)
{
SPItem *seen = NULL, *newseen = NULL;
@@ -1010,7 +1009,7 @@ Returns the topmost non-layer group from the descendants of group which is at po
p, or NULL if none. Recurses into layers but not into groups.
*/
SPItem*
-find_group_at_point(unsigned int dkey, SPGroup *group, NR::Point const p)
+find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Point const p)
{
SPItem *seen = NULL;
*
*/
-GSList *sp_document_items_in_box(SPDocument *document, unsigned int dkey, NR::Rect const &box)
+GSList *sp_document_items_in_box(SPDocument *document, unsigned int dkey, Geom::Rect const &box)
{
g_return_val_if_fail(document != NULL, NULL);
g_return_val_if_fail(document->priv != NULL, NULL);
@@ -1059,7 +1058,7 @@ GSList *sp_document_items_in_box(SPDocument *document, unsigned int dkey, NR::Re
*
*/
-GSList *sp_document_partial_items_in_box(SPDocument *document, unsigned int dkey, NR::Rect const &box)
+GSList *sp_document_partial_items_in_box(SPDocument *document, unsigned int dkey, Geom::Rect const &box)
{
g_return_val_if_fail(document != NULL, NULL);
g_return_val_if_fail(document->priv != NULL, NULL);
@@ -1068,7 +1067,7 @@ GSList *sp_document_partial_items_in_box(SPDocument *document, unsigned int dkey
}
GSList *
-sp_document_items_at_points(SPDocument *document, unsigned const key, std::vector<NR::Point> points)
+sp_document_items_at_points(SPDocument *document, unsigned const key, std::vector<Geom::Point> points)
{
GSList *items = NULL;
@@ -1080,7 +1079,7 @@ sp_document_items_at_points(SPDocument *document, unsigned const key, std::vecto
for(unsigned int i = 0; i < points.size(); i++) {
SPItem *item = sp_document_item_at_point(document, key, points[i],
- false, NULL);
+ false, NULL);
if (item && !g_slist_find(items, item))
items = g_slist_prepend (items, item);
}
@@ -1092,7 +1091,7 @@ sp_document_items_at_points(SPDocument *document, unsigned const key, std::vecto
}
SPItem *
-sp_document_item_at_point(SPDocument *document, unsigned const key, NR::Point const p,
+sp_document_item_at_point(SPDocument *document, unsigned const key, Geom::Point const p,
gboolean const into_groups, SPItem *upto)
{
g_return_val_if_fail(document != NULL, NULL);
@@ -1102,7 +1101,7 @@ sp_document_item_at_point(SPDocument *document, unsigned const key, NR::Point co
}
SPItem*
-sp_document_group_at_point(SPDocument *document, unsigned int key, NR::Point const p)
+sp_document_group_at_point(SPDocument *document, unsigned int key, Geom::Point const p)
{
g_return_val_if_fail(document != NULL, NULL);
g_return_val_if_fail(document->priv != NULL, NULL);
diff --git a/src/document.h b/src/document.h
index a5cc3b855bf794efe47e31fb4d4a248417ea0b52..fff3289ddbfc5489924fdafbad1d73001e756e66 100644 (file)
--- a/src/document.h
+++ b/src/document.h
#include <sigc++/class_slot.h>
#include "libcroco/cr-cascade.h"
-#include "libnr/nr-forward.h"
+#include <2geom/rect.h>
#include "gc-managed.h"
#include "gc-finalized.h"
struct SPObject;
struct SPGroup;
+namespace Geom {
+ class Point;
+}
+
namespace Inkscape {
struct Application;
class Selection;
sigc::connection _selection_changed_connection;
sigc::connection _desktop_activated_connection;
- void fitToRect(NR::Rect const &rect);
+ void fitToRect(Geom::Rect const &rect);
};
SPDocument *sp_document_new (const gchar *uri, unsigned int keepalive, bool make_new = false);
@@ -254,12 +258,12 @@ sigc::connection sp_document_resources_changed_connect(SPDocument *document, con
* Misc
*/
-GSList * sp_document_items_in_box(SPDocument *document, unsigned int dkey, NR::Rect const &box);
-GSList * sp_document_partial_items_in_box(SPDocument *document, unsigned int dkey, NR::Rect const &box);
-SPItem* sp_document_item_from_list_at_point_bottom (unsigned int dkey, SPGroup *group, const GSList *list, NR::Point const p, bool take_insensitive = false);
-SPItem * sp_document_item_at_point (SPDocument *document, unsigned int key, NR::Point const p, gboolean into_groups, SPItem *upto = NULL);
-GSList *sp_document_items_at_points(SPDocument *document, unsigned const key, std::vector<NR::Point> points);
-SPItem *sp_document_group_at_point (SPDocument *document, unsigned int key, NR::Point const p);
+GSList * sp_document_items_in_box(SPDocument *document, unsigned int dkey, Geom::Rect const &box);
+GSList * sp_document_partial_items_in_box(SPDocument *document, unsigned int dkey, Geom::Rect const &box);
+SPItem* sp_document_item_from_list_at_point_bottom (unsigned int dkey, SPGroup *group, const GSList *list, Geom::Point const p, bool take_insensitive = false);
+SPItem * sp_document_item_at_point (SPDocument *document, unsigned int key, Geom::Point const p, gboolean into_groups, SPItem *upto = NULL);
+GSList *sp_document_items_at_points(SPDocument *document, unsigned const key, std::vector<Geom::Point> points);
+SPItem *sp_document_group_at_point (SPDocument *document, unsigned int key, Geom::Point const p);
void sp_document_set_uri (SPDocument *document, const gchar *uri);
void sp_document_resized_signal_emit (SPDocument *doc, gdouble width, gdouble height);
index 5c9e45521600c12ac0581e454287b39698b3a44b..0e30acf1bd002581a4d8c9ea950aee3082bc4284 100644 (file)
--- a/src/dropper-context.cpp
+++ b/src/dropper-context.cpp
#include "dropper-context.h"
#include "message-context.h"
-#include "libnr/nr-scale-translate-ops.h"
+//#include "libnr/nr-scale-translate-ops.h"
static void sp_dropper_context_class_init(SPDropperContextClass *klass);
static void sp_dropper_context_init(SPDropperContext *dc);
@@ -164,7 +164,7 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv
switch (event->type) {
case GDK_BUTTON_PRESS:
if (event->button.button == 1 && !event_context->space_panning) {
- dc->centre = NR::Point(event->button.x, event->button.y);
+ dc->centre = Geom::Point(event->button.x, event->button.y);
dc->dragging = TRUE;
ret = TRUE;
}
@@ -184,24 +184,24 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv
// calculate average
// radius
- rw = std::min(NR::L2(NR::Point(event->button.x, event->button.y) - dc->centre), 400.0);
+ rw = std::min(Geom::L2(Geom::Point(event->button.x, event->button.y) - dc->centre), 400.0);
if (rw == 0) { // happens sometimes, little idea why...
break;
}
- NR::Point const cd = desktop->w2d(dc->centre);
- NR::Matrix const w2dt = desktop->w2d();
- const double scale = rw * NR::expansion(w2dt);
- NR::Matrix const sm( NR::scale(scale, scale) * NR::translate(cd) );
+ Geom::Point const cd = desktop->w2d(dc->centre);
+ Geom::Matrix const w2dt = desktop->w2d();
+ const double scale = rw * w2dt.descrim();
+ Geom::Matrix const sm( Geom::Scale(scale, scale) * Geom::Translate(cd) );
sp_canvas_item_affine_absolute(dc->area, sm);
sp_canvas_item_show(dc->area);
/* Get buffer */
- const int x0 = (int) floor(dc->centre[NR::X] - rw);
- const int y0 = (int) floor(dc->centre[NR::Y] - rw);
- const int x1 = (int) ceil(dc->centre[NR::X] + rw);
- const int y1 = (int) ceil(dc->centre[NR::Y] + rw);
+ const int x0 = (int) floor(dc->centre[Geom::X] - rw);
+ const int y0 = (int) floor(dc->centre[Geom::Y] - rw);
+ const int x1 = (int) ceil(dc->centre[Geom::X] + rw);
+ const int y1 = (int) ceil(dc->centre[Geom::Y] + rw);
if ((x1 > x0) && (y1 > y0)) {
NRPixBlock pb;
@@ -211,8 +211,8 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv
for (int y = y0; y < y1; y++) {
const unsigned char *s = NR_PIXBLOCK_PX(&pb) + (y - y0) * pb.rs;
for (int x = x0; x < x1; x++) {
- const double dx = x - dc->centre[NR::X];
- const double dy = y - dc->centre[NR::Y];
+ const double dx = x - dc->centre[Geom::X];
+ const double dy = y - dc->centre[Geom::Y];
const double w = exp(-((dx * dx) + (dy * dy)) / (rw * rw));
W += w;
R += w * s[0];
diff --git a/src/dropper-context.h b/src/dropper-context.h
index 80b25ad2689642156414e5920068af26b450d6e1..678ab6b47f875abe861cbec70545bee93c37e36e 100644 (file)
--- a/src/dropper-context.h
+++ b/src/dropper-context.h
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include <libnr/nr-point.h>
-
#include "display/display-forward.h"
#include "event-context.h"
};
struct SPDropperContext {
- SPEventContext event_context;
+ SPEventContext event_context;
- unsigned int dragging : 1;
+ unsigned int dragging : 1;
- SPCanvasItem *area;
- NR::Point centre;
+ SPCanvasItem *area;
+ Geom::Point centre;
- double R;
- double G;
- double B;
- double alpha;
+ double R;
+ double G;
+ double B;
+ double alpha;
};
struct SPDropperContextClass {
- SPEventContextClass parent_class;
+ SPEventContextClass parent_class;
};
GType sp_dropper_context_get_type (void);
guint32 sp_dropper_context_get_color(SPEventContext *ec);
#endif
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
index 0cffd4bc55801faa5dbe2a6886c87d9148c8b793..b8f06907391c4d7b4f6e6527cb9a4635e3708f3c 100644 (file)
static Geom::Point
sp_dyna_draw_get_npoint(SPDynaDrawContext const *dc, Geom::Point v)
{
- NR::Rect drect = SP_EVENT_CONTEXT(dc)->desktop->get_display_area();
- double const max = MAX ( drect.dimensions()[NR::X], drect.dimensions()[NR::Y] );
- return Geom::Point(( v[NR::X] - drect.min()[NR::X] ) / max, ( v[NR::Y] - drect.min()[NR::Y] ) / max);
+ Geom::Rect drect = SP_EVENT_CONTEXT(dc)->desktop->get_display_area();
+ double const max = MAX ( drect.dimensions()[Geom::X], drect.dimensions()[Geom::Y] );
+ return Geom::Point(( v[Geom::X] - drect.min()[Geom::X] ) / max, ( v[Geom::Y] - drect.min()[Geom::Y] ) / max);
}
/* Get view point */
static Geom::Point
sp_dyna_draw_get_vpoint(SPDynaDrawContext const *dc, Geom::Point n)
{
- NR::Rect drect = SP_EVENT_CONTEXT(dc)->desktop->get_display_area();
- double const max = MAX ( drect.dimensions()[NR::X], drect.dimensions()[NR::Y] );
- return Geom::Point(n[NR::X] * max + drect.min()[NR::X], n[NR::Y] * max + drect.min()[NR::Y]);
+ Geom::Rect drect = SP_EVENT_CONTEXT(dc)->desktop->get_display_area();
+ double const max = MAX ( drect.dimensions()[Geom::X], drect.dimensions()[Geom::Y] );
+ return Geom::Point(n[Geom::X] * max + drect.min()[Geom::X], n[Geom::Y] * max + drect.min()[Geom::Y]);
}
static void
{
SPDesktop *desktop = SP_EVENT_CONTEXT(dc)->desktop;
- double const tolerance_sq = square( NR::expansion(desktop->w2d()) * TOLERANCE_CALLIGRAPHIC );
+ double const tolerance_sq = square( desktop->w2d().descrim() * TOLERANCE_CALLIGRAPHIC );
#ifdef DYNA_DRAW_VERBOSE
g_print("[F&S:R=%c]", release?'T':'F');
diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp
index 86d5e66dc831aa60d1c11ea76580c9f9ece65a02..382a50edc5d25478d18c4004c6960361a6e90f15 100644 (file)
--- a/src/eraser-context.cpp
+++ b/src/eraser-context.cpp
static Geom::Point
sp_eraser_get_npoint(SPEraserContext const *dc, Geom::Point v)
{
- NR::Rect drect = SP_EVENT_CONTEXT(dc)->desktop->get_display_area();
- double const max = MAX ( drect.dimensions()[NR::X], drect.dimensions()[NR::Y] );
- return Geom::Point(( v[NR::X] - drect.min()[NR::X] ) / max, ( v[NR::Y] - drect.min()[NR::Y] ) / max);
+ Geom::Rect drect = SP_EVENT_CONTEXT(dc)->desktop->get_display_area();
+ double const max = MAX ( drect.dimensions()[Geom::X], drect.dimensions()[Geom::Y] );
+ return Geom::Point(( v[Geom::X] - drect.min()[Geom::X] ) / max, ( v[Geom::Y] - drect.min()[Geom::Y] ) / max);
}
/* Get view point */
static Geom::Point
sp_eraser_get_vpoint(SPEraserContext const *dc, Geom::Point n)
{
- NR::Rect drect = SP_EVENT_CONTEXT(dc)->desktop->get_display_area();
- double const max = MAX ( drect.dimensions()[NR::X], drect.dimensions()[NR::Y] );
- return Geom::Point(n[NR::X] * max + drect.min()[NR::X], n[NR::Y] * max + drect.min()[NR::Y]);
+ Geom::Rect drect = SP_EVENT_CONTEXT(dc)->desktop->get_display_area();
+ double const max = MAX ( drect.dimensions()[Geom::X], drect.dimensions()[Geom::Y] );
+ return Geom::Point(n[Geom::X] * max + drect.min()[Geom::X], n[Geom::Y] * max + drect.min()[Geom::Y]);
}
static void
if (dc->dragging && event->button.button == 1 && !event_context->space_panning) {
dc->dragging = FALSE;
- boost::optional<NR::Rect> const b = Inkscape::Rubberband::get(desktop)->getRectangle();
-
sp_eraser_apply(dc, motion_dt);
/* Remove all temporary line segments */
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
SPItem* acid = SP_ITEM(desktop->doc()->getObjectByRepr(dc->repr));
- boost::optional<NR::Rect> eraserBbox = acid->getBounds(NR::identity());
- NR::Rect bounds = (*eraserBbox) * desktop->doc2dt();
+ boost::optional<Geom::Rect> eraserBbox = to_2geom(acid->getBounds(Geom::identity()));
+ Geom::Rect bounds = (*eraserBbox) * desktop->doc2dt();
std::vector<SPItem*> remainingItems;
GSList* toWorkOn = 0;
if (selection->isEmpty()) {
for (GSList *i = toWorkOn ; i ; i = i->next ) {
SPItem *item = SP_ITEM(i->data);
if ( eraserMode ) {
- boost::optional<NR::Rect> bbox = item->getBounds(NR::identity());
+ boost::optional<Geom::Rect> bbox = to_2geom(item->getBounds(Geom::identity()));
if (bbox && bbox->intersects(*eraserBbox)) {
Inkscape::XML::Node* dup = dc->repr->duplicate(xml_doc);
dc->repr->parent()->appendChild(dup);
{
SPDesktop *desktop = SP_EVENT_CONTEXT(dc)->desktop;
- double const tolerance_sq = square( NR::expansion(desktop->w2d()) * TOLERANCE_ERASER );
+ double const tolerance_sq = square( desktop->w2d().descrim() * TOLERANCE_ERASER );
#ifdef ERASER_VERBOSE
g_print("[F&S:R=%c]", release?'T':'F');
diff --git a/src/event-context.cpp b/src/event-context.cpp
index 16fbe1f60a5d408c22a99fef106c48427f76b4af..9df17114631543479188ed8cb0a2eb1b777156d3 100644 (file)
--- a/src/event-context.cpp
+++ b/src/event-context.cpp
@@ -499,7 +499,7 @@ static gint sp_event_context_private_root_handler(SPEventContext *event_context,
ret = TRUE;
} else if (zoom_rb == event->button.button) {
zoom_rb = 0;
- boost::optional<NR::Rect> const b = Inkscape::Rubberband::get(desktop)->getRectangle();
+ boost::optional<Geom::Rect> const b = Inkscape::Rubberband::get(desktop)->getRectangle();
Inkscape::Rubberband::get(desktop)->stop();
if (b && !within_tolerance) {
desktop->set_display_area(*b, 10);
diff --git a/src/flood-context.cpp b/src/flood-context.cpp
index 22eee64681cb1a8a1f8cdcecebfca618f84e2676..d2e6290b26c88343542b3d165385d6f8806ac6f1 100644 (file)
--- a/src/flood-context.cpp
+++ b/src/flood-context.cpp
PaintBucketChannels method;
unsigned char *dtc;
unsigned char *merged_orig_pixel;
- NR::Rect bbox;
- NR::Rect screen;
+ Geom::Rect bbox;
+ Geom::Rect screen;
unsigned int max_queue_size;
unsigned int current_step;
};
@@ -417,7 +417,7 @@ inline static bool check_if_pixel_is_paintable(guchar *px, unsigned char *trace_
* \param transform The transform to apply to the final SVG path.
* \param union_with_selection If true, merge the final SVG path with the current selection.
*/
-static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *desktop, NR::Matrix transform, unsigned int min_x, unsigned int max_x, unsigned int min_y, unsigned int max_y, bool union_with_selection) {
+static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *desktop, Geom::Matrix transform, unsigned int min_x, unsigned int max_x, unsigned int min_y, unsigned int max_y, bool union_with_selection) {
SPDocument *document = sp_desktop_document(desktop);
unsigned char *trace_t;
@@ -510,10 +510,10 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto
sp_item_write_transform(SP_ITEM(reprobj), pathRepr, transform, NULL);
// premultiply the item transform by the accumulated parent transform in the paste layer
- NR::Matrix local (sp_item_i2doc_affine(SP_GROUP(desktop->currentLayer())));
- if (!local.test_identity()) {
+ Geom::Matrix local (sp_item_i2doc_affine(SP_GROUP(desktop->currentLayer())));
+ if (!local.isIdentity()) {
gchar const *t_str = pathRepr->attribute("transform");
- NR::Matrix item_t (NR::identity());
+ Geom::Matrix item_t (Geom::identity());
if (t_str)
sp_svg_transform_read(t_str, &item_t);
item_t *= local.inverse();
@@ -625,10 +625,10 @@ inline static unsigned int paint_pixel(guchar *px, guchar *trace_px, unsigned ch
* \param x The X coordinate.
* \param y The Y coordinate.
*/
-static void push_point_onto_queue(std::deque<NR::Point> *fill_queue, unsigned int max_queue_size, unsigned char *trace_t, unsigned int x, unsigned int y) {
+static void push_point_onto_queue(std::deque<Geom::Point> *fill_queue, unsigned int max_queue_size, unsigned char *trace_t, unsigned int x, unsigned int y) {
if (!is_pixel_queued(trace_t)) {
if ((fill_queue->size() < max_queue_size)) {
- fill_queue->push_back(NR::Point(x, y));
+ fill_queue->push_back(Geom::Point(x, y));
mark_pixel_queued(trace_t);
}
}
@@ -642,10 +642,10 @@ static void push_point_onto_queue(std::deque<NR::Point> *fill_queue, unsigned in
* \param x The X coordinate.
* \param y The Y coordinate.
*/
-static void shift_point_onto_queue(std::deque<NR::Point> *fill_queue, unsigned int max_queue_size, unsigned char *trace_t, unsigned int x, unsigned int y) {
+static void shift_point_onto_queue(std::deque<Geom::Point> *fill_queue, unsigned int max_queue_size, unsigned char *trace_t, unsigned int x, unsigned int y) {
if (!is_pixel_queued(trace_t)) {
if ((fill_queue->size() < max_queue_size)) {
- fill_queue->push_front(NR::Point(x, y));
+ fill_queue->push_front(Geom::Point(x, y));
mark_pixel_queued(trace_t);
}
}
@@ -659,7 +659,7 @@ static void shift_point_onto_queue(std::deque<NR::Point> *fill_queue, unsigned i
* \param orig_color The original selected pixel to use as the fill target color.
* \param bci The bitmap_coords_info structure.
*/
-static ScanlineCheckResult perform_bitmap_scanline_check(std::deque<NR::Point> *fill_queue, guchar *px, guchar *trace_px, unsigned char *orig_color, bitmap_coords_info bci, unsigned int *min_x, unsigned int *max_x) {
+static ScanlineCheckResult perform_bitmap_scanline_check(std::deque<Geom::Point> *fill_queue, guchar *px, guchar *trace_px, unsigned char *orig_color, bitmap_coords_info bci, unsigned int *min_x, unsigned int *max_x) {
bool aborted = false;
bool reached_screen_boundary = false;
bool ok;
@@ -679,7 +679,7 @@ static ScanlineCheckResult perform_bitmap_scanline_check(std::deque<NR::Point> *
bool can_paint_top = (top_ty > 0);
bool can_paint_bottom = (bottom_ty < bci.height);
- NR::Point t = fill_queue->front();
+ Geom::Point t = fill_queue->front();
do {
ok = false;
@@ -697,7 +697,7 @@ static ScanlineCheckResult perform_bitmap_scanline_check(std::deque<NR::Point> *
paint_directions = paint_pixel(px, trace_px, orig_color, bci, current_trace_t);
if (bci.radius == 0) {
mark_pixel_checked(current_trace_t);
- if ((t[NR::X] == bci.x) && (t[NR::Y] == bci.y)) {
+ if ((t[Geom::X] == bci.x) && (t[Geom::Y] == bci.y)) {
fill_queue->pop_front(); t = fill_queue->front();
}
}
@@ -755,7 +755,7 @@ static ScanlineCheckResult perform_bitmap_scanline_check(std::deque<NR::Point> *
initial_paint = false;
}
} else {
- if (bci.bbox.min()[NR::X] > bci.screen.min()[NR::X]) {
+ if (bci.bbox.min()[Geom::X] > bci.screen.min()[Geom::X]) {
aborted = true; break;
} else {
reached_screen_boundary = true;
@@ -771,15 +771,15 @@ static ScanlineCheckResult perform_bitmap_scanline_check(std::deque<NR::Point> *
/**
* \brief Sort the rendered pixel buffer check queue vertically.
*/
-static bool sort_fill_queue_vertical(NR::Point a, NR::Point b) {
- return a[NR::Y] > b[NR::Y];
+static bool sort_fill_queue_vertical(Geom::Point a, Geom::Point b) {
+ return a[Geom::Y] > b[Geom::Y];
}
/**
* \brief Sort the rendered pixel buffer check queue horizontally.
*/
-static bool sort_fill_queue_horizontal(NR::Point a, NR::Point b) {
- return a[NR::X] > b[NR::X];
+static bool sort_fill_queue_horizontal(Geom::Point a, Geom::Point b) {
+ return a[Geom::X] > b[Geom::X];
}
/**
@@ -801,7 +801,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
sp_document_ensure_up_to_date (document);
SPItem *document_root = SP_ITEM(SP_DOCUMENT_ROOT(document));
- boost::optional<NR::Rect> bbox = document_root->getBounds(NR::identity());
+ boost::optional<Geom::Rect> bbox = to_2geom(document_root->getBounds(Geom::identity()));
if (!bbox) {
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("<b>Area is not bounded</b>, cannot fill."));
@@ -814,19 +814,19 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
// fill areas off the screen can be included in the fill.
double padding = 1.6;
- NR::Rect screen = desktop->get_display_area();
+ Geom::Rect screen = desktop->get_display_area();
- unsigned int width = (int)ceil(screen.extent(NR::X) * zoom_scale * padding);
- unsigned int height = (int)ceil(screen.extent(NR::Y) * zoom_scale * padding);
+ unsigned int width = (int)ceil(screen.width() * zoom_scale * padding);
+ unsigned int height = (int)ceil(screen.height() * zoom_scale * padding);
- NR::Point origin(screen.min()[NR::X],
- sp_document_height(document) - screen.extent(NR::Y) - screen.min()[NR::Y]);
+ Geom::Point origin(screen.min()[Geom::X],
+ sp_document_height(document) - screen.height() - screen.min()[Geom::Y]);
- origin[NR::X] = origin[NR::X] + (screen.extent(NR::X) * ((1 - padding) / 2));
- origin[NR::Y] = origin[NR::Y] + (screen.extent(NR::Y) * ((1 - padding) / 2));
+ origin[Geom::X] = origin[Geom::X] + (screen.width() * ((1 - padding) / 2));
+ origin[Geom::Y] = origin[Geom::Y] + (screen.height() * ((1 - padding) / 2));
- NR::scale scale(zoom_scale, zoom_scale);
- NR::Matrix affine = scale * NR::translate(-origin * scale);
+ Geom::Scale scale(zoom_scale, zoom_scale);
+ Geom::Matrix affine = scale * Geom::Translate(-origin * scale);
/* Create ArenaItems and set transform */
NRArenaItem *root = sp_item_invoke_show(SP_ITEM(sp_document_root(document)), arena, dkey, SP_ITEM_SHOW_DISPLAY);
@@ -879,10 +879,10 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
guchar *trace_px = g_new(guchar, width * height);
memset(trace_px, 0x00, width * height);
- std::deque<NR::Point> fill_queue;
- std::queue<NR::Point> color_queue;
+ std::deque<Geom::Point> fill_queue;
+ std::queue<Geom::Point> color_queue;
- std::vector<NR::Point> fill_points;
+ std::vector<Geom::Point> fill_points;
bool aborted = false;
int y_limit = height - 1;
@@ -919,24 +919,24 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
bci.current_step = 0;
if (is_point_fill) {
- fill_points.push_back(NR::Point(event->button.x, event->button.y));
+ fill_points.push_back(Geom::Point(event->button.x, event->button.y));
} else {
Inkscape::Rubberband::Rubberband *r = Inkscape::Rubberband::get(desktop);
fill_points = r->getPoints();
}
for (unsigned int i = 0; i < fill_points.size(); i++) {
- NR::Point pw = NR::Point(fill_points[i][NR::X] / zoom_scale, sp_document_height(document) + (fill_points[i][NR::Y] / zoom_scale)) * affine;
+ Geom::Point pw = Geom::Point(fill_points[i][Geom::X] / zoom_scale, sp_document_height(document) + (fill_points[i][Geom::Y] / zoom_scale)) * affine;
- pw[NR::X] = (int)MIN(width - 1, MAX(0, pw[NR::X]));
- pw[NR::Y] = (int)MIN(height - 1, MAX(0, pw[NR::Y]));
+ pw[Geom::X] = (int)MIN(width - 1, MAX(0, pw[Geom::X]));
+ pw[Geom::Y] = (int)MIN(height - 1, MAX(0, pw[Geom::Y]));
if (is_touch_fill) {
if (i == 0) {
color_queue.push(pw);
} else {
- unsigned char *trace_t = get_trace_pixel(trace_px, (int)pw[NR::X], (int)pw[NR::Y], width);
- push_point_onto_queue(&fill_queue, bci.max_queue_size, trace_t, (int)pw[NR::X], (int)pw[NR::Y]);
+ unsigned char *trace_t = get_trace_pixel(trace_px, (int)pw[Geom::X], (int)pw[Geom::Y], width);
+ push_point_onto_queue(&fill_queue, bci.max_queue_size, trace_t, (int)pw[Geom::X], (int)pw[Geom::Y]);
}
} else {
color_queue.push(pw);
@@ -955,11 +955,11 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
unsigned int max_x = 0;
while (!color_queue.empty() && !aborted) {
- NR::Point color_point = color_queue.front();
+ Geom::Point color_point = color_queue.front();
color_queue.pop();
- int cx = (int)color_point[NR::X];
- int cy = (int)color_point[NR::Y];
+ int cx = (int)color_point[Geom::X];
+ int cy = (int)color_point[Geom::Y];
unsigned char *orig_px = get_pixel(px, cx, cy, width);
unsigned char orig_color[4];
@@ -992,7 +992,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
unsigned long old_fill_queue_size = fill_queue.size();
while (!fill_queue.empty() && !aborted) {
- NR::Point cp = fill_queue.front();
+ Geom::Point cp = fill_queue.front();
if (bci.radius == 0) {
unsigned long new_fill_queue_size = fill_queue.size();
@@ -1009,14 +1009,14 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
if (new_fill_queue_size > old_fill_queue_size) {
std::sort(fill_queue.begin(), fill_queue.end(), sort_fill_queue_vertical);
- std::deque<NR::Point>::iterator start_sort = fill_queue.begin();
- std::deque<NR::Point>::iterator end_sort = fill_queue.begin();
- unsigned int sort_y = (unsigned int)cp[NR::Y];
+ std::deque<Geom::Point>::iterator start_sort = fill_queue.begin();
+ std::deque<Geom::Point>::iterator end_sort = fill_queue.begin();
+ unsigned int sort_y = (unsigned int)cp[Geom::Y];
unsigned int current_y = sort_y;
- for (std::deque<NR::Point>::iterator i = fill_queue.begin(); i != fill_queue.end(); i++) {
- NR::Point current = *i;
- current_y = (unsigned int)current[NR::Y];
+ for (std::deque<Geom::Point>::iterator i = fill_queue.begin(); i != fill_queue.end(); i++) {
+ Geom::Point current = *i;
+ current_y = (unsigned int)current[Geom::Y];
if (current_y != sort_y) {
if (start_sort != end_sort) {
std::sort(start_sort, end_sort, sort_fill_queue_horizontal);
@@ -1039,8 +1039,8 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
fill_queue.pop_front();
- int x = (int)cp[NR::X];
- int y = (int)cp[NR::Y];
+ int x = (int)cp[Geom::X];
+ int y = (int)cp[Geom::Y];
min_y = MIN((unsigned int)y, min_y);
max_y = MAX((unsigned int)y, max_y);
@@ -1050,7 +1050,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
mark_pixel_checked(trace_t);
if (y == 0) {
- if (bbox->min()[NR::Y] > screen.min()[NR::Y]) {
+ if (bbox->min()[Geom::Y] > screen.min()[Geom::Y]) {
aborted = true; break;
} else {
reached_screen_boundary = true;
@@ -1058,7 +1058,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
}
if (y == y_limit) {
- if (bbox->max()[NR::Y] < screen.max()[NR::Y]) {
+ if (bbox->max()[Geom::Y] < screen.max()[Geom::Y]) {
aborted = true; break;
} else {
reached_screen_boundary = true;
@@ -1131,10 +1131,10 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
if (min_x > trace_padding) { min_x -= trace_padding; }
if (max_x < (width - 1 - trace_padding)) { max_x += trace_padding; }
- NR::Point min_start = NR::Point(min_x, min_y);
+ Geom::Point min_start = Geom::Point(min_x, min_y);
- affine = scale * NR::translate(-origin * scale - min_start);
- NR::Matrix inverted_affine = NR::Matrix(affine).inverse();
+ affine = scale * Geom::Translate(-origin * scale - min_start);
+ Geom::Matrix inverted_affine = Geom::Matrix(affine).inverse();
do_trace(bci, trace_px, desktop, inverted_affine, min_x, max_x, min_y, max_y, union_with_selection);
@@ -1152,8 +1152,8 @@ static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem
switch (event->type) {
case GDK_BUTTON_PRESS:
if ((event->button.state & GDK_CONTROL_MASK) && event->button.button == 1 && !event_context->space_panning) {
- NR::Point const button_w(event->button.x,
- event->button.y);
+ Geom::Point const button_w(event->button.x,
+ event->button.y);
SPItem *item = sp_event_context_find_item (desktop, button_w, TRUE, TRUE);
@@ -1186,18 +1186,18 @@ static gint sp_flood_context_root_handler(SPEventContext *event_context, GdkEven
case GDK_BUTTON_PRESS:
if (event->button.button == 1 && !event_context->space_panning) {
if (!(event->button.state & GDK_CONTROL_MASK)) {
- NR::Point const button_w(event->button.x,
- event->button.y);
+ Geom::Point const button_w(event->button.x,
+ event->button.y);
if (Inkscape::have_viable_layer(desktop, event_context->defaultMessageContext())) {
// save drag origin
- event_context->xp = (gint) button_w[NR::X];
- event_context->yp = (gint) button_w[NR::Y];
+ event_context->xp = (gint) button_w[Geom::X];
+ event_context->yp = (gint) button_w[Geom::Y];
event_context->within_tolerance = true;
dragging = true;
- NR::Point const p(desktop->w2d(button_w));
+ Geom::Point const p(desktop->w2d(button_w));
Inkscape::Rubberband::get(desktop)->setMode(RUBBERBAND_MODE_TOUCHPATH);
Inkscape::Rubberband::get(desktop)->start(desktop, p);
}
@@ -1215,8 +1215,8 @@ static gint sp_flood_context_root_handler(SPEventContext *event_context, GdkEven
event_context->within_tolerance = false;
- NR::Point const motion_pt(event->motion.x, event->motion.y);
- NR::Point const p(desktop->w2d(motion_pt));
+ Geom::Point const motion_pt(event->motion.x, event->motion.y);
+ Geom::Point const p(desktop->w2d(motion_pt));
if (Inkscape::Rubberband::get(desktop)->is_started()) {
Inkscape::Rubberband::get(desktop)->move(p);
event_context->defaultMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Draw over</b> areas to add to fill, hold <b>Alt</b> for touch fill"));
index 400661ce23901c673beb5dd09fe81c44ff60edd0..7181fab4e7a0fbe25971743869fb83a0ce8b6cd5 100644 (file)
--- a/src/gradient-context.cpp
+++ b/src/gradient-context.cpp
@@ -249,8 +249,8 @@ sp_gradient_context_is_over_line (SPGradientContext *rc, SPItem *item, NR::Point
SPCtrlLine* line = SP_CTRLLINE(item);
- NR::Point nearest = snap_vector_midpoint (rc->mousepoint_doc, line->s, line->e, 0);
- double dist_screen = NR::L2 (rc->mousepoint_doc - nearest) * desktop->current_zoom();
+ Geom::Point nearest = snap_vector_midpoint (rc->mousepoint_doc, line->s, line->e, 0);
+ double dist_screen = Geom::L2 (rc->mousepoint_doc - nearest) * desktop->current_zoom();
double tolerance = (double) SP_EVENT_CONTEXT(rc)->tolerance;
@@ -641,7 +641,7 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event)
if (r->is_started() && !event_context->within_tolerance) {
// this was a rubberband drag
if (r->getMode() == RUBBERBAND_MODE_RECT) {
- boost::optional<NR::Rect> const b = r->getRectangle();
+ boost::optional<Geom::Rect> const b = r->getRectangle();
drag->selectRect(*b);
}
}
diff --git a/src/gradient-context.h b/src/gradient-context.h
index ac46826361b717ac3f0f075cdf6f8cfed52c2fe3..f4d8c572a66e70ad848906b09909fee28a1a2386 100644 (file)
--- a/src/gradient-context.h
+++ b/src/gradient-context.h
#include <sigc++/sigc++.h>
#include "event-context.h"
-#include "libnr/nr-point.h"
#define SP_TYPE_GRADIENT_CONTEXT (sp_gradient_context_get_type())
#define SP_GRADIENT_CONTEXT(obj) (GTK_CHECK_CAST((obj), SP_TYPE_GRADIENT_CONTEXT, SPGradientContext))
struct SPGradientContext : public SPEventContext {
- NR::Point origin;
+ Geom::Point origin;
bool cursor_addnode;
bool node_added;
- NR::Point mousepoint_doc; // stores mousepoint when over_line in doc coords
+ Geom::Point mousepoint_doc; // stores mousepoint when over_line in doc coords
Inkscape::MessageContext *_message_context;
diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp
index 5bf2b25756d90305f355e9ac2810350b60a1234e..1caaf1d115466a19bce60abf51d61ceb9299c0a3 100644 (file)
--- a/src/gradient-drag.cpp
+++ b/src/gradient-drag.cpp
\brief Select all stops/draggers that fall within the rect
*/
void
-GrDrag::selectRect(NR::Rect const &r)
+GrDrag::selectRect(Geom::Rect const &r)
{
for (GList *l = this->draggers; l != NULL; l = l->next) {
GrDragger *d = ((GrDragger *) l->data);
diff --git a/src/gradient-drag.h b/src/gradient-drag.h
index ed0887e9810ab2ab4c8b6272ef5ac0f78c6ddcee..acc2dd48f52fee39cb5ab4589e9270d1d0c74629 100644 (file)
--- a/src/gradient-drag.h
+++ b/src/gradient-drag.h
void deselectAll();
void selectAll();
void selectByCoords(std::vector<NR::Point> coords);
- void selectRect(NR::Rect const &r);
+ void selectRect(Geom::Rect const &r);
bool dropColor(SPItem *item, gchar *c, NR::Point p);
diff --git a/src/interface.cpp b/src/interface.cpp
index 9264f4fd6fe6b7d64be9a6a0ddaa5a2d5ee1b4a6..5abf8d8db4370e8f28584c860bc61fa13d205ecd 100644 (file)
--- a/src/interface.cpp
+++ b/src/interface.cpp
if (x>0 && y>0) {
SPDesktop *active_desktop = SP_ACTIVE_DESKTOP;
if (active_desktop == desktop || active_desktop==NULL) {
- desktop->setWindowPosition(NR::Point(x, y));
+ desktop->setWindowPosition(Geom::Point(x, y));
}
}
}
int destX = 0;
int destY = 0;
gtk_widget_translate_coordinates( widget, &(desktop->canvas->widget), x, y, &destX, &destY );
- NR::Point where( sp_canvas_window_to_world( desktop->canvas, NR::Point( destX, destY ) ) );
+ Geom::Point where( sp_canvas_window_to_world( desktop->canvas, Geom::Point( destX, destY ) ) );
SPItem *item = desktop->item_at_point( where, true );
if ( item )
( !SP_OBJECT_STYLE(item)->stroke.isNone() ?
desktop->current_zoom() *
SP_OBJECT_STYLE (item)->stroke_width.computed *
- NR::expansion(sp_item_i2d_affine(item)) * 0.5
+ to_2geom(sp_item_i2d_affine(item)).descrim() * 0.5
: 0.0)
+ prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
index 95b9eb6f0918bb7efc2d32ffd2e02e00b30f0475..c8a139aa2b1dfe0097de08bd650f292e594b104c 100644 (file)
NR::Rect rect(rect2geom.min(), rect2geom.max());
return rect;
}
+inline boost::optional<Geom::Rect> to_2geom(boost::optional<NR::Rect> const & rect) {
+ boost::optional<Geom::Rect> rect2geom;
+ if (!rect) {
+ return rect2geom;
+ }
+ rect2geom = to_2geom(*rect);
+ return rect2geom;
+}
inline NR::scale from_2geom(Geom::Scale const & in) {
return NR::scale(in[Geom::X], in[Geom::Y]);
diff --git a/src/line-geometry.cpp b/src/line-geometry.cpp
index 056bfb71a964db081c7bfac0b2c409f9dbea4da5..d01b5db828dfc6c0375eada362f52d51777fb820 100644 (file)
--- a/src/line-geometry.cpp
+++ b/src/line-geometry.cpp
* of the segment. Otherwise interpret it as the direction of the line.
* FIXME: Think of a better way to distinguish between the two constructors of lines.
*/
-Line::Line(NR::Point const &start, NR::Point const &vec, bool is_endpoint) {
+Line::Line(Geom::Point const &start, Geom::Point const &vec, bool is_endpoint) {
pt = start;
if (is_endpoint)
v_dir = vec - start;
else
v_dir = vec;
normal = v_dir.ccw();
- d0 = NR::dot(normal, pt);
+ d0 = Geom::dot(normal, pt);
}
Line::Line(Line const &line) {
return *this;
}
-boost::optional<NR::Point> Line::intersect(Line const &line) {
- NR::Coord denom = NR::dot(v_dir, line.normal);
- boost::optional<NR::Point> no_point;
+boost::optional<Geom::Point> Line::intersect(Line const &line) {
+ Geom::Coord denom = Geom::dot(v_dir, line.normal);
+ boost::optional<Geom::Point> no_point;
if (fabs(denom) < 1e-6)
return no_point;
- NR::Coord lambda = (line.d0 - NR::dot(pt, line.normal)) / denom;
+ Geom::Coord lambda = (line.d0 - Geom::dot(pt, line.normal)) / denom;
return pt + lambda * v_dir;
}
-void Line::set_direction(NR::Point const &dir)
+void Line::set_direction(Geom::Point const &dir)
{
v_dir = dir;
normal = v_dir.ccw();
- d0 = NR::dot(normal, pt);
+ d0 = Geom::dot(normal, pt);
}
-NR::Point Line::closest_to(NR::Point const &pt)
+Geom::Point Line::closest_to(Geom::Point const &pt)
{
/* return the intersection of this line with a perpendicular line passing through pt */
- boost::optional<NR::Point> result = this->intersect(Line(pt, (this->v_dir).ccw(), false));
- g_return_val_if_fail (result, NR::Point (0.0, 0.0));
+ boost::optional<Geom::Point> result = this->intersect(Line(pt, (this->v_dir).ccw(), false));
+ g_return_val_if_fail (result, Geom::Point (0.0, 0.0));
return *result;
}
-double Line::lambda (NR::Point const pt)
+double Line::lambda (Geom::Point const pt)
{
- double sign = (NR::dot (pt - this->pt, this->v_dir) > 0) ? 1.0 : -1.0;
- double lambda = sign * NR::L2 (pt - this->pt);
+ double sign = (Geom::dot (pt - this->pt, this->v_dir) > 0) ? 1.0 : -1.0;
+ double lambda = sign * Geom::L2 (pt - this->pt);
// FIXME: It may speed things up (but how much?) if we assume that
// pt lies on the line and thus skip the following test
- NR::Point test = point_from_lambda (lambda);
+ Geom::Point test = point_from_lambda (lambda);
if (!pts_coincide (pt, test)) {
g_warning ("Point does not lie on line.\n");
return 0;
}
/* The coordinates of w with respect to the basis {v1, v2} */
-std::pair<double, double> coordinates (NR::Point const &v1, NR::Point const &v2, NR::Point const &w)
+std::pair<double, double> coordinates (Geom::Point const &v1, Geom::Point const &v2, Geom::Point const &w)
{
double det = determinant (v1, v2);;
if (fabs (det) < epsilon) {
@@ -106,25 +106,25 @@ std::pair<double, double> coordinates (NR::Point const &v1, NR::Point const &v2,
}
/* whether w lies inside the sector spanned by v1 and v2 */
-bool lies_in_sector (NR::Point const &v1, NR::Point const &v2, NR::Point const &w)
+bool lies_in_sector (Geom::Point const &v1, Geom::Point const &v2, Geom::Point const &w)
{
std::pair<double, double> coords = coordinates (v1, v2, w);
if (coords.first == HUGE_VAL) {
// catch the case that the vectors are not linearly independent
// FIXME: Can we assume that it's safe to return true if the vectors point in different directions?
- return (NR::dot (v1, v2) < 0);
+ return (Geom::dot (v1, v2) < 0);
}
return (coords.first >= 0 and coords.second >= 0);
}
-bool lies_in_quadrangle (NR::Point const &A, NR::Point const &B, NR::Point const &C, NR::Point const &D, NR::Point const &pt)
+bool lies_in_quadrangle (Geom::Point const &A, Geom::Point const &B, Geom::Point const &C, Geom::Point const &D, Geom::Point const &pt)
{
return (lies_in_sector (D - A, B - A, pt - A) && lies_in_sector (D - C, B - C, pt - C));
}
-static double pos_angle (NR::Point v, NR::Point w)
+static double pos_angle (Geom::Point v, Geom::Point w)
{
- return fabs (NR::atan2 (v) - NR::atan2 (w));
+ return fabs (Geom::atan2 (v) - Geom::atan2 (w));
}
/*
* starting at pt and going into direction dir.
* If none of the sides is hit, it returns a pair containing two identical points.
*/
-std::pair<NR::Point, NR::Point>
-side_of_intersection (NR::Point const &A, NR::Point const &B, NR::Point const &C, NR::Point const &D,
- NR::Point const &pt, NR::Point const &dir)
+std::pair<Geom::Point, Geom::Point>
+side_of_intersection (Geom::Point const &A, Geom::Point const &B, Geom::Point const &C, Geom::Point const &D,
+ Geom::Point const &pt, Geom::Point const &dir)
{
- NR::Point dir_A (A - pt);
- NR::Point dir_B (B - pt);
- NR::Point dir_C (C - pt);
- NR::Point dir_D (D - pt);
+ Geom::Point dir_A (A - pt);
+ Geom::Point dir_B (B - pt);
+ Geom::Point dir_C (C - pt);
+ Geom::Point dir_D (D - pt);
- std::pair<NR::Point, NR::Point> result;
+ std::pair<Geom::Point, Geom::Point> result;
double angle = -1;
double tmp_angle;
@@ -178,24 +178,24 @@ side_of_intersection (NR::Point const &A, NR::Point const &B, NR::Point const &C
}
}
-boost::optional<NR::Point> Line::intersection_with_viewbox (SPDesktop *desktop)
+boost::optional<Geom::Point> Line::intersection_with_viewbox (SPDesktop *desktop)
{
- NR::Rect vb = desktop->get_display_area();
+ Geom::Rect vb = desktop->get_display_area();
/* remaining viewbox corners */
- NR::Point ul (vb.min()[NR::X], vb.max()[NR::Y]);
- NR::Point lr (vb.max()[NR::X], vb.min()[NR::Y]);
+ Geom::Point ul (vb.min()[Geom::X], vb.max()[Geom::Y]);
+ Geom::Point lr (vb.max()[Geom::X], vb.min()[Geom::Y]);
- std::pair <NR::Point, NR::Point> e = side_of_intersection (vb.min(), lr, vb.max(), ul, this->pt, this->v_dir);
+ std::pair <Geom::Point, Geom::Point> e = side_of_intersection (vb.min(), lr, vb.max(), ul, this->pt, this->v_dir);
if (e.first == e.second) {
// perspective line lies outside the canvas
- return boost::optional<NR::Point>();
+ return boost::optional<Geom::Point>();
}
Line line (e.first, e.second);
return this->intersect (line);
}
-void create_canvas_point(NR::Point const &pos, double size, guint32 rgba)
+void create_canvas_point(Geom::Point const &pos, double size, guint32 rgba)
{
SPDesktop *desktop = inkscape_active_desktop();
SPCanvasItem * canvas_pt = sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRL,
SP_CTRL(canvas_pt)->moveto(pos);
}
-void create_canvas_line(NR::Point const &p1, NR::Point const &p2, guint32 rgba)
+void create_canvas_line(Geom::Point const &p1, Geom::Point const &p2, guint32 rgba)
{
SPDesktop *desktop = inkscape_active_desktop();
SPCanvasItem *line = sp_canvas_item_new(sp_desktop_controls(desktop),
diff --git a/src/line-geometry.h b/src/line-geometry.h
index 86ed9ee8aa1c3f8ef7a2489c413ee55074b26390..472478e3b908620505309eb503f989bb28b3ec9d 100644 (file)
--- a/src/line-geometry.h
+++ b/src/line-geometry.h
#ifndef SEEN_LINE_GEOMETRY_H
#define SEEN_LINE_GEOMETRY_H
-#include "libnr/nr-point.h"
-#include "libnr/nr-point-fns.h"
#include <boost/optional.hpp>
#include "glib.h"
#include "display/sp-ctrlline.h"
class Line {
public:
- Line(NR::Point const &start, NR::Point const &vec, bool is_endpoint = true);
+ Line(Geom::Point const &start, Geom::Point const &vec, bool is_endpoint = true);
Line(Line const &line);
virtual ~Line() {}
Line &operator=(Line const &line);
- virtual boost::optional<NR::Point> intersect(Line const &line);
- inline NR::Point direction () { return v_dir; }
+ virtual boost::optional<Geom::Point> intersect(Line const &line);
+ inline Geom::Point direction () { return v_dir; }
- NR::Point closest_to(NR::Point const &pt); // returns the point on the line closest to pt
+ Geom::Point closest_to(Geom::Point const &pt); // returns the point on the line closest to pt
friend inline std::ostream &operator<< (std::ostream &out_file, const Line &in_line);
- boost::optional<NR::Point> intersection_with_viewbox (SPDesktop *desktop);
- inline bool lie_on_same_side (NR::Point const &A, NR::Point const &B) {
+ boost::optional<Geom::Point> intersection_with_viewbox (SPDesktop *desktop);
+ inline bool lie_on_same_side (Geom::Point const &A, Geom::Point const &B) {
/* If A is a point in the plane and n is the normal vector of the line then
the sign of dot(A, n) specifies the half-plane in which A lies.
Thus A and B lie on the same side if the dot products have equal sign. */
- return ((NR::dot(A, normal) - d0) * (NR::dot(B, normal) - d0)) > 0;
+ return ((Geom::dot(A, normal) - d0) * (Geom::dot(B, normal) - d0)) > 0;
}
- double lambda (NR::Point const pt);
- inline NR::Point point_from_lambda (double const lambda) {
- return (pt + lambda * NR::unit_vector (v_dir)); }
+ double lambda (Geom::Point const pt);
+ inline Geom::Point point_from_lambda (double const lambda) {
+ return (pt + lambda * Geom::unit_vector (v_dir)); }
protected:
- void set_direction(NR::Point const &dir);
- inline static bool pts_coincide (NR::Point const pt1, NR::Point const pt2)
+ void set_direction(Geom::Point const &dir);
+ inline static bool pts_coincide (Geom::Point const pt1, Geom::Point const pt2)
{
- return (NR::L2 (pt2 - pt1) < epsilon);
+ return (Geom::L2 (pt2 - pt1) < epsilon);
}
- NR::Point pt;
- NR::Point v_dir;
- NR::Point normal;
- NR::Coord d0;
+ Geom::Point pt;
+ Geom::Point v_dir;
+ Geom::Point normal;
+ Geom::Coord d0;
};
-inline double determinant (NR::Point const &a, NR::Point const &b)
+inline double determinant (Geom::Point const &a, Geom::Point const &b)
{
- return (a[NR::X] * b[NR::Y] - a[NR::Y] * b[NR::X]);
+ return (a[Geom::X] * b[Geom::Y] - a[Geom::Y] * b[Geom::X]);
}
-std::pair<double, double> coordinates (NR::Point const &v1, NR::Point const &v2, NR::Point const &w);
-bool lies_in_sector (NR::Point const &v1, NR::Point const &v2, NR::Point const &w);
-bool lies_in_quadrangle (NR::Point const &A, NR::Point const &B, NR::Point const &C, NR::Point const &D, NR::Point const &pt);
-std::pair<NR::Point, NR::Point> side_of_intersection (NR::Point const &A, NR::Point const &B,
- NR::Point const &C, NR::Point const &D,
- NR::Point const &pt, NR::Point const &dir);
+std::pair<double, double> coordinates (Geom::Point const &v1, Geom::Point const &v2, Geom::Point const &w);
+bool lies_in_sector (Geom::Point const &v1, Geom::Point const &v2, Geom::Point const &w);
+bool lies_in_quadrangle (Geom::Point const &A, Geom::Point const &B, Geom::Point const &C, Geom::Point const &D, Geom::Point const &pt);
+std::pair<Geom::Point, Geom::Point> side_of_intersection (Geom::Point const &A, Geom::Point const &B,
+ Geom::Point const &C, Geom::Point const &D,
+ Geom::Point const &pt, Geom::Point const &dir);
/*** For debugging purposes: Draw a knot/node of specified size and color at the given position ***/
-void create_canvas_point(NR::Point const &pos, double size = 4.0, guint32 rgba = 0xff00007f);
+void create_canvas_point(Geom::Point const &pos, double size = 4.0, guint32 rgba = 0xff00007f);
/*** For debugging purposes: Draw a line between the specified points ***/
-void create_canvas_line(NR::Point const &p1, NR::Point const &p2, guint32 rgba = 0xff00007f);
+void create_canvas_line(Geom::Point const &p1, Geom::Point const &p2, guint32 rgba = 0xff00007f);
/** A function to print out the Line. It just prints out the coordinates of start point and
diff --git a/src/livarot/Shape.h b/src/livarot/Shape.h
index d1ba63a54d09dcf18f8dec6cdcdc98a23a6374f8..73199a313969feb4295125c46ce994d8fdba9308 100644 (file)
--- a/src/livarot/Shape.h
+++ b/src/livarot/Shape.h
// the result is NOT a polygon; you need a subsequent call to ConvertToShape to get a real polygon
int MakeOffset(Shape *of, double dec, JoinType join, double miter, bool do_profile=false, double cx = 0, double cy = 0, double radius = 0, NR::Matrix *i2doc = NULL);
- int MakeTweak (int mode, Shape *a, double dec, JoinType join, double miter, bool do_profile, NR::Point c, NR::Point vector, double radius, NR::Matrix *i2doc);
+ int MakeTweak (int mode, Shape *a, double dec, JoinType join, double miter, bool do_profile, Geom::Point c, Geom::Point vector, double radius, Geom::Matrix *i2doc);
int PtWinding(const NR::Point px) const; // plus rapide
int Winding(const NR::Point px) const;
index cacf4c997a7f765e636f0d4e8b0b08416b245f5d..824f04a88ff0bb72bf494819b2f0d575c2b453b5 100644 (file)
@@ -528,7 +528,7 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,in
int
-Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter, bool do_profile, NR::Point c, NR::Point vector, double radius, NR::Matrix *i2doc)
+Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter, bool do_profile, Geom::Point c, Geom::Point vector, double radius, Geom::Matrix *i2doc)
{
Reset (0, 0);
MakeBackData(a->_has_back_data);
@@ -584,7 +584,7 @@ Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter,
enB = a->CyclePrevAt (a->getEdge(i).en, i);
}
- NR::Point stD, seD, enD;
+ Geom::Point stD, seD, enD;
double stL, seL, enL;
stD = a->getEdge(stB).dx;
seD = a->getEdge(i).dx;
@@ -597,21 +597,21 @@ Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter,
MiscNormalize (enD);
MiscNormalize (seD);
- NR::Point ptP;
+ Geom::Point ptP;
int stNo, enNo;
ptP = a->getPoint(a->getEdge(i).st).x;
- NR::Point to_center = ptP * (*i2doc) - c;
- NR::Point to_center_normalized = (1/NR::L2(to_center)) * to_center;
+ Geom::Point to_center = ptP * (*i2doc) - c;
+ Geom::Point to_center_normalized = (1/Geom::L2(to_center)) * to_center;
double this_power;
if (do_profile && i2doc) {
double alpha = 1;
double x;
if (mode == tweak_mode_repel) {
- x = (NR::L2(to_center)/radius);
+ x = (Geom::L2(to_center)/radius);
} else {
- x = (NR::L2(ptP * (*i2doc) - c)/radius);
+ x = (Geom::L2(ptP * (*i2doc) - c)/radius);
}
if (x > 1) {
this_power = 0;
@@ -635,11 +635,11 @@ Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter,
if (this_power != 0)
done_something = true;
- double scaler = 1 / NR::expansion(*i2doc);
+ double scaler = 1 / (*i2doc).descrim();
- NR::Point this_vec(0,0);
+ Geom::Point this_vec(0,0);
if (mode == tweak_mode_push) {
- NR::Matrix tovec (*i2doc);
+ Geom::Matrix tovec (*i2doc);
tovec[4] = tovec[5] = 0;
tovec = tovec.inverse();
this_vec = this_power * (vector * tovec) ;
@@ -647,7 +647,7 @@ Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter,
this_vec = this_power * scaler * to_center_normalized;
} else if (mode == tweak_mode_roughen) {
double angle = g_random_double_range(0, 2*M_PI);
- this_vec = g_random_double_range(0, 1) * this_power * scaler * NR::Point(sin(angle), cos(angle));
+ this_vec = g_random_double_range(0, 1) * this_power * scaler * Geom::Point(sin(angle), cos(angle));
}
int usePathID=-1;
diff --git a/src/marker.cpp b/src/marker.cpp
index 9f387edfb571cb6855c7340a73baa653ee8c9221..49486476d2ef13a5e11bcee16e1cb15d67de6064 100644 (file)
--- a/src/marker.cpp
+++ b/src/marker.cpp
static NRArenaItem *sp_marker_private_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags);
static void sp_marker_private_hide (SPItem *item, unsigned int key);
-static void sp_marker_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
+static void sp_marker_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
static void sp_marker_print (SPItem *item, SPPrintContext *ctx);
static void sp_marker_view_remove (SPMarker *marker, SPMarkerView *view, unsigned int destroyitems);
{
marker->viewBox_set = FALSE;
- marker->c2p.set_identity();
+ marker->c2p.setIdentity();
}
/**
rctx.vp.y1 = marker->markerHeight.computed;
/* Start with identity transform */
- marker->c2p.set_identity();
+ marker->c2p.setIdentity();
/* Viewbox is always present, either implicitly or explicitly */
if (marker->viewBox_set) {
}
{
- NR::Matrix q;
+ Geom::Matrix q;
/* Compose additional transformation from scale and position */
q[0] = width / (vb->x1 - vb->x0);
q[1] = 0.0;
/* Append reference translation */
/* fixme: lala (Lauris) */
- marker->c2p = NR::translate(-marker->refX.computed, -marker->refY.computed) * marker->c2p;
+ marker->c2p = Geom::Translate(-marker->refX.computed, -marker->refY.computed) * marker->c2p;
rctx.i2doc = marker->c2p * rctx.i2doc;
/* If viewBox is set reinitialize child viewport */
/* Otherwise it already correct */
if (marker->viewBox_set) {
- rctx.vp.x0 = marker->viewBox.x0;
- rctx.vp.y0 = marker->viewBox.y0;
- rctx.vp.x1 = marker->viewBox.x1;
- rctx.vp.y1 = marker->viewBox.y1;
- rctx.i2vp = NR::identity();
+ rctx.vp.x0 = marker->viewBox.x0;
+ rctx.vp.y0 = marker->viewBox.y0;
+ rctx.vp.x1 = marker->viewBox.x1;
+ rctx.vp.y1 = marker->viewBox.y1;
+ rctx.i2vp = Geom::identity();
}
/* And invoke parent method */
/* As last step set additional transform of arena group */
for (v = marker->views; v != NULL; v = v->next) {
- for (unsigned i = 0 ; i < v->size ; i++) {
- if (v->items[i]) {
- nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->items[i]), &marker->c2p);
- }
- }
+ for (unsigned i = 0 ; i < v->size ; i++) {
+ if (v->items[i]) {
+ NR::Matrix tmp = from_2geom(marker->c2p);
+ nr_arena_group_set_child_transform(NR_ARENA_GROUP(v->items[i]), &tmp);
+ }
+ }
}
}
* This routine is disabled to break propagation.
*/
static void
-sp_marker_bbox(SPItem const *, NRRect *, NR::Matrix const &, unsigned const)
+sp_marker_bbox(SPItem const *, NRRect *, Geom::Matrix const &, unsigned const)
{
/* Break propagation */
}
/* fixme: Position (Lauris) */
nr_arena_item_add_child (parent, v->items[pos], NULL);
/* nr_arena_item_unref (v->items[pos]); */
- nr_arena_group_set_child_transform((NRArenaGroup *) v->items[pos], &marker->c2p);
+ NR::Matrix tmp = from_2geom(marker->c2p);
+ nr_arena_group_set_child_transform((NRArenaGroup *) v->items[pos], &tmp);
}
}
if (v->items[pos]) {
@@ -722,7 +724,7 @@ sp_marker_view_remove (SPMarker *marker, SPMarkerView *view, unsigned int destro
}
const gchar *
-generate_marker (GSList *reprs, NR::Rect bounds, SPDocument *document, NR::Matrix /*transform*/, NR::Matrix move)
+generate_marker (GSList *reprs, NR::Rect bounds, SPDocument *document, Geom::Matrix /*transform*/, Geom::Matrix move)
{
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(document);
Inkscape::XML::Node *defsrepr = SP_OBJECT_REPR (SP_DOCUMENT_DEFS (document));
@@ -747,9 +749,9 @@ generate_marker (GSList *reprs, NR::Rect bounds, SPDocument *document, NR::Matri
Inkscape::XML::Node *node = (Inkscape::XML::Node *)(i->data);
SPItem *copy = SP_ITEM(mark_object->appendChildRepr(node));
- NR::Matrix dup_transform;
+ Geom::Matrix dup_transform;
if (!sp_svg_transform_read (node->attribute("transform"), &dup_transform))
- dup_transform = NR::identity();
+ dup_transform = Geom::identity();
dup_transform *= move;
sp_item_write_transform(copy, SP_OBJECT_REPR(copy), dup_transform);
diff --git a/src/marker.h b/src/marker.h
index f2db5a6c683047db04e62b94c5dce79f7e8b0d45..cc792448644c1be5606d24551d6372751646a978 100644 (file)
--- a/src/marker.h
+++ b/src/marker.h
class SPMarkerClass;
class SPMarkerView;
-#include <libnr/nr-matrix.h>
#include <libnr/nr-rect.h>
#include <2geom/forward.h>
#include "svg/svg-length.h"
unsigned int aspect_clip : 1;
/* Child to parent additional transform */
- NR::Matrix c2p;
+ Geom::Matrix c2p;
/* Private views */
SPMarkerView *views;
unsigned int key, unsigned int pos,
Geom::Matrix const &base, float linewidth);
void sp_marker_hide (SPMarker *marker, unsigned int key);
-const gchar *generate_marker (GSList *reprs, NR::Rect bounds, SPDocument *document, NR::Matrix transform, NR::Matrix move);
+const gchar *generate_marker (GSList *reprs, NR::Rect bounds, SPDocument *document, Geom::Matrix transform, Geom::Matrix move);
#endif
diff --git a/src/node-context.cpp b/src/node-context.cpp
index 17243b1b27b7296389a340dab7f9f016e7eb3068..f16af703567f7339a0ef5aeb6841e035949ccb9e 100644 (file)
--- a/src/node-context.cpp
+++ b/src/node-context.cpp
if (event->type == GDK_BUTTON_RELEASE) {
event_context->xp = event_context->yp = 0;
if (event->button.button == 1) {
- boost::optional<NR::Rect> b = Inkscape::Rubberband::get(desktop)->getRectangle();
+ boost::optional<Geom::Rect> b = Inkscape::Rubberband::get(desktop)->getRectangle();
if (nc->shape_editor->hits_curve() && !event_context->within_tolerance) { //drag curve
nc->shape_editor->finish_drag();
break;
case GDK_Escape:
{
- boost::optional<NR::Rect> const b = Inkscape::Rubberband::get(desktop)->getRectangle();
+ boost::optional<Geom::Rect> const b = Inkscape::Rubberband::get(desktop)->getRectangle();
if (b) {
Inkscape::Rubberband::get(desktop)->stop();
nc->current_state = SP_NODE_CONTEXT_INACTIVE;
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index 7a6276dde05d20d930b35269c7c7063ea7093b30..c3242ccc16c4c6c47715c2d1cb7bb47474957dd6 100644 (file)
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
#include "display/snap-indicator.h"
#include "snapped-point.h"
-class NR::Matrix;
+class Geom::Matrix;
/// \todo
/// evil evil evil. FIXME: conflict of two different Path classes!
@@ -533,7 +533,7 @@ static void subpaths_from_pathvector(Inkscape::NodePath::Path *np, Geom::PathVec
Inkscape::NodePath::SubPath *sp = sp_nodepath_subpath_new(np);
- Geom::Point ppos = pit->initialPoint() * (Geom::Matrix)np->i2d;
+ Geom::Point ppos = pit->initialPoint() * np->i2d;
NRPathcode pcode = NR_MOVETO;
/* Johan: Note that this is pretty arcane code. I am pretty sure it is working correctly, be very certain to change it! (better to just rewrite this whole method)*/
@@ -890,16 +890,16 @@ static void sp_nodepath_line_midpoint(Inkscape::NodePath::Node *new_path,Inkscap
new_path->code = NR_CURVETO;
gdouble s = 1 - t;
for (int dim = 0; dim < 2; dim++) {
- NR::Coord const f000 = start->pos[dim];
- NR::Coord const f001 = start->n.pos[dim];
- NR::Coord const f011 = end->p.pos[dim];
- NR::Coord const f111 = end->pos[dim];
- NR::Coord const f00t = s * f000 + t * f001;
- NR::Coord const f01t = s * f001 + t * f011;
- NR::Coord const f11t = s * f011 + t * f111;
- NR::Coord const f0tt = s * f00t + t * f01t;
- NR::Coord const f1tt = s * f01t + t * f11t;
- NR::Coord const fttt = s * f0tt + t * f1tt;
+ Geom::Coord const f000 = start->pos[dim];
+ Geom::Coord const f001 = start->n.pos[dim];
+ Geom::Coord const f011 = end->p.pos[dim];
+ Geom::Coord const f111 = end->pos[dim];
+ Geom::Coord const f00t = s * f000 + t * f001;
+ Geom::Coord const f01t = s * f001 + t * f011;
+ Geom::Coord const f11t = s * f011 + t * f111;
+ Geom::Coord const f0tt = s * f00t + t * f01t;
+ Geom::Coord const f1tt = s * f01t + t * f11t;
+ Geom::Coord const fttt = s * f0tt + t * f1tt;
start->n.pos[dim] = f00t;
new_path->p.pos[dim] = f0tt;
new_path->pos[dim] = fttt;
@@ -1118,8 +1118,8 @@ sp_node_side_is_line (Inkscape::NodePath::Node *node, Inkscape::NodePath::NodeSi
if (!other_to_me)
return false;
bool is_line =
- (NR::L2(othernode->pos - other_to_me->pos) < 1e-6 &&
- NR::L2(node->pos - side->pos) < 1e-6);
+ (Geom::L2(othernode->pos - other_to_me->pos) < 1e-6 &&
+ Geom::L2(node->pos - side->pos) < 1e-6);
return is_line;
}
@@ -1156,8 +1156,8 @@ void sp_nodepath_convert_node_type(Inkscape::NodePath::Node *node, Inkscape::Nod
}
}
*/
- bool p_has_handle = (NR::L2(node->pos - node->p.pos) > 1e-6);
- bool n_has_handle = (NR::L2(node->pos - node->n.pos) > 1e-6);
+ bool p_has_handle = (Geom::L2(node->pos - node->p.pos) > 1e-6);
+ bool n_has_handle = (Geom::L2(node->pos - node->n.pos) > 1e-6);
bool p_is_line = sp_node_side_is_line(node, &node->p);
bool n_is_line = sp_node_side_is_line(node, &node->n);
@@ -1186,16 +1186,16 @@ void sp_nodepath_convert_node_type(Inkscape::NodePath::Node *node, Inkscape::Nod
// pull n handle
node->n.other->code = NR_CURVETO;
double len = (type == Inkscape::NodePath::NODE_SYMM)?
- NR::L2(node->p.pos - node->pos) :
- NR::L2(node->n.other->pos - node->pos) / 3;
- node->n.pos = node->pos - (len / NR::L2(node->p.pos - node->pos)) * (node->p.pos - node->pos);
+ Geom::L2(node->p.pos - node->pos) :
+ Geom::L2(node->n.other->pos - node->pos) / 3;
+ node->n.pos = node->pos - (len / Geom::L2(node->p.pos - node->pos)) * (node->p.pos - node->pos);
} else if (n_has_handle && node->p.other) {
// pull p handle
node->code = NR_CURVETO;
double len = (type == Inkscape::NodePath::NODE_SYMM)?
- NR::L2(node->n.pos - node->pos) :
- NR::L2(node->p.other->pos - node->pos) / 3;
- node->p.pos = node->pos - (len / NR::L2(node->n.pos - node->pos)) * (node->n.pos - node->pos);
+ Geom::L2(node->n.pos - node->pos) :
+ Geom::L2(node->p.other->pos - node->pos) / 3;
+ node->p.pos = node->pos - (len / Geom::L2(node->n.pos - node->pos)) * (node->n.pos - node->pos);
}
} else if (!p_has_handle && !n_has_handle) {
if ((p_is_line && n_is_line) || (!p_is_line && node->p.other && !n_is_line && node->n.other)) {
@@ -1234,15 +1234,15 @@ void sp_nodepath_convert_node_type(Inkscape::NodePath::Node *node, Inkscape::Nod
if (type != Inkscape::NodePath::NODE_SYMM) {
// pull n handle
node->n.other->code = NR_CURVETO;
- double len = NR::L2(node->n.other->pos - node->pos) / 3;
- node->n.pos = node->pos + (len / NR::L2(node->p.other->pos - node->pos)) * (node->p.other->pos - node->pos);
+ double len = Geom::L2(node->n.other->pos - node->pos) / 3;
+ node->n.pos = node->pos + (len / Geom::L2(node->p.other->pos - node->pos)) * (node->p.other->pos - node->pos);
}
} else if (n_is_line && node->p.other) {
if (type != Inkscape::NodePath::NODE_SYMM) {
// pull p handle
node->code = NR_CURVETO;
- double len = NR::L2(node->p.other->pos - node->pos) / 3;
- node->p.pos = node->pos + (len / NR::L2(node->n.other->pos - node->pos)) * (node->n.other->pos - node->pos);
+ double len = Geom::L2(node->p.other->pos - node->pos) / 3;
+ node->p.pos = node->pos + (len / Geom::L2(node->n.other->pos - node->pos)) * (node->n.other->pos - node->pos);
}
}
}
/**
* Call sp_node_moveto() for node selection and handle possible snapping.
*/
-static void sp_nodepath_selected_nodes_move(Inkscape::NodePath::Path *nodepath, NR::Coord dx, NR::Coord dy,
+static void sp_nodepath_selected_nodes_move(Inkscape::NodePath::Path *nodepath, Geom::Coord dx, Geom::Coord dy,
bool const snap, bool constrained = false,
Inkscape::Snapper::ConstraintLine const &constraint = Geom::Point())
{
- NR::Coord best = NR_HUGE;
+ Geom::Coord best = NR_HUGE;
Geom::Point delta(dx, dy);
Geom::Point best_pt = delta;
Inkscape::SnappedPoint best_abs;
bezier_length (Geom::Point a, Geom::Point ah, Geom::Point bh, Geom::Point b)
{
// extremely primitive for now, don't have time to look for the real one
- double lower = NR::L2(b - a);
- double upper = NR::L2(ah - a) + NR::L2(bh - ah) + NR::L2(bh - b);
+ double lower = Geom::L2(b - a);
+ double upper = Geom::L2(ah - a) + Geom::L2(bh - ah) + Geom::L2(bh - b);
return (lower + upper)/2;
}
@@ -1505,8 +1505,8 @@ sp_nodepath_selected_nodes_sculpt(Inkscape::NodePath::Path *nodepath, Inkscape::
if (n_node->selected) {
sp_nodepath_move_node_and_handles (n_node,
sculpt_profile (n_range / n_sel_range, alpha, profile) * delta,
- sculpt_profile ((n_range + NR::L2(n_node->n.origin - n_node->origin)) / n_sel_range, alpha, profile) * delta,
- sculpt_profile ((n_range - NR::L2(n_node->p.origin - n_node->origin)) / n_sel_range, alpha, profile) * delta);
+ sculpt_profile ((n_range + Geom::L2(n_node->n.origin - n_node->origin)) / n_sel_range, alpha, profile) * delta,
+ sculpt_profile ((n_range - Geom::L2(n_node->p.origin - n_node->origin)) / n_sel_range, alpha, profile) * delta);
}
if (n_node == p_node) {
n_going = false;
@@ -1522,8 +1522,8 @@ sp_nodepath_selected_nodes_sculpt(Inkscape::NodePath::Path *nodepath, Inkscape::
if (p_node->selected) {
sp_nodepath_move_node_and_handles (p_node,
sculpt_profile (p_range / p_sel_range, alpha, profile) * delta,
- sculpt_profile ((p_range - NR::L2(p_node->n.origin - p_node->origin)) / p_sel_range, alpha, profile) * delta,
- sculpt_profile ((p_range + NR::L2(p_node->p.origin - p_node->origin)) / p_sel_range, alpha, profile) * delta);
+ sculpt_profile ((p_range - Geom::L2(p_node->n.origin - p_node->origin)) / p_sel_range, alpha, profile) * delta,
+ sculpt_profile ((p_range + Geom::L2(p_node->p.origin - p_node->origin)) / p_sel_range, alpha, profile) * delta);
}
if (p_node == n_node) {
n_going = false;
@@ -1535,7 +1535,7 @@ sp_nodepath_selected_nodes_sculpt(Inkscape::NodePath::Path *nodepath, Inkscape::
} else {
// Multiple subpaths have selected nodes:
- // use spatial mode, where the distance from n to node being dragged is measured directly as NR::L2.
+ // use spatial mode, where the distance from n to node being dragged is measured directly as Geom::L2.
// TODO: correct these distances taking into account their angle relative to the bisector, so as to
// fix the pear-like shape when sculpting e.g. a ring
@@ -1546,7 +1546,7 @@ sp_nodepath_selected_nodes_sculpt(Inkscape::NodePath::Path *nodepath, Inkscape::
for (GList *nl = subpath->nodes; nl != NULL; nl = nl->next) {
Inkscape::NodePath::Node *node = (Inkscape::NodePath::Node *) nl->data;
if (node->selected) {
- direct_range = MAX(direct_range, NR::L2(node->origin - n->origin));
+ direct_range = MAX(direct_range, Geom::L2(node->origin - n->origin));
}
}
}
@@ -1559,9 +1559,9 @@ sp_nodepath_selected_nodes_sculpt(Inkscape::NodePath::Path *nodepath, Inkscape::
if (node->selected) {
if (direct_range > 1e-6) {
sp_nodepath_move_node_and_handles (node,
- sculpt_profile (NR::L2(node->origin - n->origin) / direct_range, alpha, profile) * delta,
- sculpt_profile (NR::L2(node->n.origin - n->origin) / direct_range, alpha, profile) * delta,
- sculpt_profile (NR::L2(node->p.origin - n->origin) / direct_range, alpha, profile) * delta);
+ sculpt_profile (Geom::L2(node->origin - n->origin) / direct_range, alpha, profile) * delta,
+ sculpt_profile (Geom::L2(node->n.origin - n->origin) / direct_range, alpha, profile) * delta,
+ sculpt_profile (Geom::L2(node->p.origin - n->origin) / direct_range, alpha, profile) * delta);
} else {
sp_nodepath_move_node_and_handles (node, delta, delta, delta);
}
@@ -1637,7 +1637,7 @@ void sp_node_selected_move_absolute(Inkscape::NodePath::Path *nodepath, Geom::Co
}
/**
- * If the coordinates of all selected nodes coincide, return the common coordinate; otherwise return NR::Nothing
+ * If the coordinates of all selected nodes coincide, return the common coordinate; otherwise return Geom::Nothing
*/
boost::optional<Geom::Coord> sp_node_selected_common_coord (Inkscape::NodePath::Path *nodepath, Geom::Dim2 axis)
{
@@ -1647,7 +1647,7 @@ boost::optional<Geom::Coord> sp_node_selected_common_coord (Inkscape::NodePath::
// determine coordinate of first selected node
GList *nsel = nodepath->selected;
Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) nsel->data;
- NR::Coord coord = n->pos[axis];
+ Geom::Coord coord = n->pos[axis];
bool coincide = true;
// compare it to the coordinates of all the other selected nodes
@@ -1704,7 +1704,7 @@ static void sp_node_update_handle(Inkscape::NodePath::Node *node, gint which, gb
Inkscape::NodePath::NodeSide *side = sp_node_get_side(node, which);
NRPathcode code = sp_node_path_code_from_side(node, side);
- show_handle = show_handle && (code == NR_CURVETO) && (NR::L2(side->pos - node->pos) > 1e-6);
+ show_handle = show_handle && (code == NR_CURVETO) && (Geom::L2(side->pos - node->pos) > 1e-6);
if (show_handle) {
if (!side->knot) { // No handle knot at all
@@ -1848,7 +1848,7 @@ void sp_nodepath_selected_align(Inkscape::NodePath::Path *nodepath, Geom::Dim2 a
struct NodeSort
{
Inkscape::NodePath::Node *_node;
- NR::Coord _coord;
+ Geom::Coord _coord;
/// \todo use vectorof pointers instead of calling copy ctor
NodeSort(Inkscape::NodePath::Node *node, Geom::Dim2 axis) :
_node(node), _coord(node->pos[axis])
/**
* \brief Select all nodes that are within the rectangle.
*/
-void sp_nodepath_select_rect(Inkscape::NodePath::Path *nodepath, NR::Rect const &b, gboolean incremental)
+void sp_nodepath_select_rect(Inkscape::NodePath::Path *nodepath, Geom::Rect const &b, gboolean incremental)
{
if (!incremental) {
sp_nodepath_deselect(nodepath);
@@ -3131,13 +3131,13 @@ nodepath_grow_selection_spatially (Inkscape::NodePath::Path *nodepath, Inkscape:
if (node == n)
continue;
if (node->selected) {
- if (NR::L2(node->pos - n->pos) > farthest_dist) {
- farthest_dist = NR::L2(node->pos - n->pos);
+ if (Geom::L2(node->pos - n->pos) > farthest_dist) {
+ farthest_dist = Geom::L2(node->pos - n->pos);
farthest_selected = node;
}
} else {
- if (NR::L2(node->pos - n->pos) < closest_dist) {
- closest_dist = NR::L2(node->pos - n->pos);
+ if (Geom::L2(node->pos - n->pos) < closest_dist) {
+ closest_dist = Geom::L2(node->pos - n->pos);
closest_unselected = node;
}
}
@@ -3245,9 +3245,9 @@ static void sp_node_adjust_handle(Inkscape::NodePath::Node *node, gint which_adj
if (sp_node_side_is_line(node, other)) {
// other is a line, and we are either smooth or symm
Inkscape::NodePath::Node *othernode = other->other;
- double len = NR::L2(me->pos - node->pos);
+ double len = Geom::L2(me->pos - node->pos);
Geom::Point delta = node->pos - othernode->pos;
- double linelen = NR::L2(delta);
+ double linelen = Geom::L2(delta);
if (linelen < 1e-18)
return;
me->pos = node->pos + (len / linelen)*delta;
@@ -3260,9 +3260,9 @@ static void sp_node_adjust_handle(Inkscape::NodePath::Node *node, gint which_adj
return;
} else {
// smoothify
- double len = NR::L2(me->pos - node->pos);
+ double len = Geom::L2(me->pos - node->pos);
Geom::Point delta = other->pos - node->pos;
- double otherlen = NR::L2(delta);
+ double otherlen = Geom::L2(delta);
if (otherlen < 1e-18) return;
me->pos = node->pos - (len / otherlen) * delta;
}
}
/* We are smooth */
- double plen = NR::L2(node->p.pos - node->pos);
+ double plen = Geom::L2(node->p.pos - node->pos);
if (plen < 1e-18) return;
- double nlen = NR::L2(node->n.pos - node->pos);
+ double nlen = Geom::L2(node->n.pos - node->pos);
if (nlen < 1e-18) return;
node->p.pos = node->pos - (plen / (plen + nlen)) * delta;
node->n.pos = node->pos + (nlen / (plen + nlen)) * delta;
@@ -3500,10 +3500,10 @@ static void node_ungrabbed(SPKnot */*knot*/, guint /*state*/, gpointer data)
static void point_line_closest(Geom::Point *p, double a, Geom::Point *closest)
{
if (a == HUGE_VAL) { // vertical
- *closest = Geom::Point(0, (*p)[NR::Y]);
+ *closest = Geom::Point(0, (*p)[Geom::Y]);
} else {
- (*closest)[NR::X] = ( a * (*p)[NR::Y] + (*p)[NR::X]) / (a*a + 1);
- (*closest)[NR::Y] = a * (*closest)[NR::X];
+ (*closest)[Geom::X] = ( a * (*p)[Geom::Y] + (*p)[Geom::X]) / (a*a + 1);
+ (*closest)[Geom::Y] = a * (*closest)[Geom::X];
}
}
{
Geom::Point c;
point_line_closest(p, a, &c);
- return sqrt(((*p)[NR::X] - c[NR::X])*((*p)[NR::X] - c[NR::X]) + ((*p)[NR::Y] - c[NR::Y])*((*p)[NR::Y] - c[NR::Y]));
+ return sqrt(((*p)[Geom::X] - c[Geom::X])*((*p)[Geom::X] - c[Geom::X]) + ((*p)[Geom::Y] - c[Geom::Y])*((*p)[Geom::Y] - c[Geom::Y]));
}
/**
if (!n->dragging_out) {
// This is the first drag-out event; find out which handle to drag out
- double appr_n = (n->n.other ? NR::L2(n->n.other->pos - n->pos) - NR::L2(n->n.other->pos - (*p)) : -HUGE_VAL);
- double appr_p = (n->p.other ? NR::L2(n->p.other->pos - n->pos) - NR::L2(n->p.other->pos - (*p)) : -HUGE_VAL);
+ double appr_n = (n->n.other ? Geom::L2(n->n.other->pos - n->pos) - Geom::L2(n->n.other->pos - (*p)) : -HUGE_VAL);
+ double appr_p = (n->p.other ? Geom::L2(n->p.other->pos - n->pos) - Geom::L2(n->p.other->pos - (*p)) : -HUGE_VAL);
if (appr_p == -HUGE_VAL && appr_n == -HUGE_VAL) // orphan node?
return FALSE;
opposite = &n->p;
n->n.other->code = NR_CURVETO;
} else { // find out to which handle of the adjacent node we're closer; note that n->n.other == n->p.other
- double appr_other_n = (n->n.other ? NR::L2(n->n.other->n.pos - n->pos) - NR::L2(n->n.other->n.pos - (*p)) : -HUGE_VAL);
- double appr_other_p = (n->n.other ? NR::L2(n->n.other->p.pos - n->pos) - NR::L2(n->n.other->p.pos - (*p)) : -HUGE_VAL);
+ double appr_other_n = (n->n.other ? Geom::L2(n->n.other->n.pos - n->pos) - Geom::L2(n->n.other->n.pos - (*p)) : -HUGE_VAL);
+ double appr_other_p = (n->n.other ? Geom::L2(n->n.other->p.pos - n->pos) - Geom::L2(n->n.other->p.pos - (*p)) : -HUGE_VAL);
if (appr_other_p > appr_other_n) { // closer to other's p handle
n->dragging_out = &n->n;
opposite = &n->p;
// calculate relative distances of handles
// n handle:
- yn = n->n.pos[NR::Y] - n->pos[NR::Y];
- xn = n->n.pos[NR::X] - n->pos[NR::X];
+ yn = n->n.pos[Geom::Y] - n->pos[Geom::Y];
+ xn = n->n.pos[Geom::X] - n->pos[Geom::X];
// if there's no n handle (straight line), see if we can use the direction to the next point on path
if ((n->n.other && n->n.other->code == NR_LINETO) || fabs(yn) + fabs(xn) < 1e-6) {
if (n->n.other) { // if there is the next point
if (L2(n->n.other->p.pos - n->n.other->pos) < 1e-6) // and the next point has no handle either
- yn = n->n.other->origin[NR::Y] - n->origin[NR::Y]; // use origin because otherwise the direction will change as you drag
- xn = n->n.other->origin[NR::X] - n->origin[NR::X];
+ yn = n->n.other->origin[Geom::Y] - n->origin[Geom::Y]; // use origin because otherwise the direction will change as you drag
+ xn = n->n.other->origin[Geom::X] - n->origin[Geom::X];
}
}
if (xn < 0) { xn = -xn; yn = -yn; } // limit the angle to between 0 and pi
if (yn < 0) { xn = -xn; yn = -yn; }
// p handle:
- yp = n->p.pos[NR::Y] - n->pos[NR::Y];
- xp = n->p.pos[NR::X] - n->pos[NR::X];
+ yp = n->p.pos[Geom::Y] - n->pos[Geom::Y];
+ xp = n->p.pos[Geom::X] - n->pos[Geom::X];
// if there's no p handle (straight line), see if we can use the direction to the prev point on path
if (n->code == NR_LINETO || fabs(yp) + fabs(xp) < 1e-6) {
if (n->p.other) {
if (L2(n->p.other->n.pos - n->p.other->pos) < 1e-6)
- yp = n->p.other->origin[NR::Y] - n->origin[NR::Y];
- xp = n->p.other->origin[NR::X] - n->origin[NR::X];
+ yp = n->p.other->origin[Geom::Y] - n->origin[Geom::Y];
+ xp = n->p.other->origin[Geom::X] - n->origin[Geom::X];
}
}
if (xp < 0) { xp = -xp; yp = -yp; } // limit the angle to between 0 and pi
// move the node to the closest point
sp_nodepath_selected_nodes_move(n->subpath->nodepath,
- n->origin[NR::X] + c[NR::X] - n->pos[NR::X],
- n->origin[NR::Y] + c[NR::Y] - n->pos[NR::Y],
+ n->origin[Geom::X] + c[Geom::X] - n->pos[Geom::X],
+ n->origin[Geom::Y] + c[Geom::Y] - n->pos[Geom::Y],
true);
} else { // constraining to hor/vert
- if (fabs((*p)[NR::X] - n->origin[NR::X]) > fabs((*p)[NR::Y] - n->origin[NR::Y])) { // snap to hor
+ if (fabs((*p)[Geom::X] - n->origin[Geom::X]) > fabs((*p)[Geom::Y] - n->origin[Geom::Y])) { // snap to hor
sp_nodepath_selected_nodes_move(n->subpath->nodepath,
- (*p)[NR::X] - n->pos[NR::X],
- n->origin[NR::Y] - n->pos[NR::Y],
+ (*p)[Geom::X] - n->pos[Geom::X],
+ n->origin[Geom::Y] - n->pos[Geom::Y],
true,
- true, Inkscape::Snapper::ConstraintLine(component_vectors[NR::X]));
+ true, Inkscape::Snapper::ConstraintLine(component_vectors[Geom::X]));
} else { // snap to vert
sp_nodepath_selected_nodes_move(n->subpath->nodepath,
- n->origin[NR::X] - n->pos[NR::X],
- (*p)[NR::Y] - n->pos[NR::Y],
+ n->origin[Geom::X] - n->pos[Geom::X],
+ (*p)[Geom::Y] - n->pos[Geom::Y],
true,
- true, Inkscape::Snapper::ConstraintLine(component_vectors[NR::Y]));
+ true, Inkscape::Snapper::ConstraintLine(component_vectors[Geom::Y]));
}
}
} else { // move freely
sp_nodepath_selected_nodes_sculpt(n->subpath->nodepath, n, (*p) - n->origin);
} else {
sp_nodepath_selected_nodes_move(n->subpath->nodepath,
- (*p)[NR::X] - n->pos[NR::X],
- (*p)[NR::Y] - n->pos[NR::Y],
+ (*p)[Geom::X] - n->pos[Geom::X],
+ (*p)[Geom::Y] - n->pos[Geom::Y],
(state & GDK_SHIFT_MASK) == 0);
}
}
@@ -3824,12 +3824,12 @@ static gboolean node_handle_request(SPKnot *knot, Geom::Point *p, guint state, g
if ((n->type != Inkscape::NodePath::NODE_CUSP) && sp_node_side_is_line(n, opposite)) {
/* We are smooth node adjacent with line */
Geom::Point const delta = *p - n->pos;
- NR::Coord const len = NR::L2(delta);
+ Geom::Coord const len = Geom::L2(delta);
Inkscape::NodePath::Node *othernode = opposite->other;
Geom::Point const ndelta = n->pos - othernode->pos;
- NR::Coord const linelen = NR::L2(ndelta);
+ Geom::Coord const linelen = Geom::L2(ndelta);
if (len > NR_EPSILON && linelen > NR_EPSILON) {
- NR::Coord const scal = dot(delta, ndelta) / linelen;
+ Geom::Coord const scal = dot(delta, ndelta) / linelen;
(*p) = n->pos + (scal / linelen) * ndelta;
}
if ((state & GDK_SHIFT_MASK) == 0) {
@@ -3908,7 +3908,7 @@ static void node_handle_moved(SPKnot *knot, Geom::Point *p, guint state, gpointe
} else {
other_to_snap = other->pos - n->pos;
}
- if (NR::L2(other_to_snap) > 1e-3) {
+ if (Geom::L2(other_to_snap) > 1e-3) {
Radial rother_to_snap(other_to_snap);
/* The closest PI/2 angle, starting from the angle of the opposite line segment */
double const a_oppo = rother_to_snap.a + floor((rnew.a - rother_to_snap.a)/(M_PI/2) + 0.5) * (M_PI/2);
@@ -3994,12 +3994,12 @@ static gboolean node_handle_event(SPKnot *knot, GdkEvent *event,Inkscape::NodePa
break;
case GDK_ENTER_NOTIFY:
// we use an experimentally determined threshold that seems to work fine
- if (NR::L2(n->pos - knot->pos) < 0.75)
+ if (Geom::L2(n->pos - knot->pos) < 0.75)
Inkscape::NodePath::Path::active_node = n;
break;
case GDK_LEAVE_NOTIFY:
// we use an experimentally determined threshold that seems to work fine
- if (NR::L2(n->pos - knot->pos) < 0.75)
+ if (Geom::L2(n->pos - knot->pos) < 0.75)
Inkscape::NodePath::Path::active_node = NULL;
break;
default:
@@ -4058,8 +4058,8 @@ static void node_rotate_one (Inkscape::NodePath::Node *n, gdouble angle, int whi
Inkscape::NodePath::NodeSide *me, *other;
bool both = false;
- double xn = n->n.other? n->n.other->pos[NR::X] : n->pos[NR::X];
- double xp = n->p.other? n->p.other->pos[NR::X] : n->pos[NR::X];
+ double xn = n->n.other? n->n.other->pos[Geom::X] : n->pos[Geom::X];
+ double xp = n->p.other? n->p.other->pos[Geom::X] : n->pos[Geom::X];
if (!n->n.other) { // if this is an endnode, select its single handle regardless of "which"
me = &(n->p);
@@ -4125,7 +4125,7 @@ void sp_nodepath_selected_nodes_rotate(Inkscape::NodePath::Path *nodepath, gdoub
// rotate as an object:
Inkscape::NodePath::Node *n0 = (Inkscape::NodePath::Node *) nodepath->selected->data;
- NR::Rect box (n0->pos, n0->pos); // originally includes the first selected node
+ Geom::Rect box (n0->pos, n0->pos); // originally includes the first selected node
for (GList *l = nodepath->selected; l != NULL; l = l->next) {
Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data;
box.expandTo (n->pos); // contain all selected nodes
@@ -4135,7 +4135,7 @@ void sp_nodepath_selected_nodes_rotate(Inkscape::NodePath::Path *nodepath, gdoub
if (screen) {
gdouble const zoom = nodepath->desktop->current_zoom();
gdouble const zmove = angle / zoom;
- gdouble const r = NR::L2(box.max() - box.midpoint());
+ gdouble const r = Geom::L2(box.max() - box.midpoint());
rot = atan2(zmove, r);
} else {
rot = angle;
@@ -4147,10 +4147,10 @@ void sp_nodepath_selected_nodes_rotate(Inkscape::NodePath::Path *nodepath, gdoub
else
rot_center = Inkscape::NodePath::Path::active_node->pos;
- NR::Matrix t =
- NR::Matrix (NR::translate(-rot_center)) *
- NR::Matrix (NR::rotate(rot)) *
- NR::Matrix (NR::translate(rot_center));
+ Geom::Matrix t =
+ Geom::Matrix (Geom::Translate(-rot_center)) *
+ Geom::Matrix (Geom::Rotate(rot)) *
+ Geom::Matrix (Geom::Translate(rot_center));
for (GList *l = nodepath->selected; l != NULL; l = l->next) {
Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data;
@@ -4172,8 +4172,8 @@ static void node_scale_one (Inkscape::NodePath::Node *n, gdouble grow, int which
bool both = false;
Inkscape::NodePath::NodeSide *me, *other;
- double xn = n->n.other? n->n.other->pos[NR::X] : n->pos[NR::X];
- double xp = n->p.other? n->p.other->pos[NR::X] : n->pos[NR::X];
+ double xn = n->n.other? n->n.other->pos[Geom::X] : n->pos[Geom::X];
+ double xp = n->p.other? n->p.other->pos[Geom::X] : n->pos[Geom::X];
if (!n->n.other) { // if this is an endnode, select its single handle regardless of "which"
me = &(n->p);
@@ -4264,7 +4264,7 @@ void sp_nodepath_selected_nodes_scale(Inkscape::NodePath::Path *nodepath, gdoubl
// scale nodes as an "object":
Inkscape::NodePath::Node *n0 = (Inkscape::NodePath::Node *) nodepath->selected->data;
- NR::Rect box (n0->pos, n0->pos); // originally includes the first selected node
+ Geom::Rect box (n0->pos, n0->pos); // originally includes the first selected node
for (GList *l = nodepath->selected; l != NULL; l = l->next) {
Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data;
box.expandTo (n->pos); // contain all selected nodes
@@ -4278,10 +4278,10 @@ void sp_nodepath_selected_nodes_scale(Inkscape::NodePath::Path *nodepath, gdoubl
else
scale_center = Inkscape::NodePath::Path::active_node->pos;
- NR::Matrix t =
- NR::Matrix (NR::translate(-scale_center)) *
- NR::Matrix (NR::scale(scale, scale)) *
- NR::Matrix (NR::translate(scale_center));
+ Geom::Matrix t =
+ Geom::Matrix (Geom::Translate(-scale_center)) *
+ Geom::Matrix (Geom::Scale(scale, scale)) *
+ Geom::Matrix (Geom::Translate(scale_center));
for (GList *l = nodepath->selected; l != NULL; l = l->next) {
Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data;
@@ -4322,10 +4322,10 @@ void sp_nodepath_flip (Inkscape::NodePath::Path *nodepath, Geom::Dim2 axis, boos
if (!center) {
center = box.midpoint();
}
- NR::Matrix t =
- NR::Matrix (NR::translate(- *center)) *
- NR::Matrix ((axis == Geom::X)? NR::scale(-1, 1) : NR::scale(1, -1)) *
- NR::Matrix (NR::translate(*center));
+ Geom::Matrix t =
+ Geom::Matrix (Geom::Translate(- *center)) *
+ Geom::Matrix ((axis == Geom::X)? Geom::Scale(-1, 1) : Geom::Scale(1, -1)) *
+ Geom::Matrix (Geom::Translate(*center));
for (GList *l = nodepath->selected; l != NULL; l = l->next) {
Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) l->data;
@@ -4465,7 +4465,7 @@ sp_nodepath_node_new(Inkscape::NodePath::SubPath *sp, Inkscape::NodePath::Node *
} else {
if (fabs (Inkscape::Util::triangle_area (*pos, *ppos, *npos)) < 1e-2) {
// points are (almost) collinear
- if (NR::L2(*pos - *ppos) < 1e-6 || NR::L2(*pos - *npos) < 1e-6) {
+ if (Geom::L2(*pos - *ppos) < 1e-6 || Geom::L2(*pos - *npos) < 1e-6) {
// endnode, or a node with a retracted handle
n->type = Inkscape::NodePath::NODE_CUSP;
} else {
for (int which = -1; which <= 1; which += 2) {
Inkscape::NodePath::NodeSide *side = sp_node_get_side(node, which);
- if (side->other && NR::L2(side->pos - node->pos) < 1e-6)
+ if (side->other && Geom::L2(side->pos - node->pos) < 1e-6)
retracted ++;
if (!side->other)
endnode = true;
diff --git a/src/nodepath.h b/src/nodepath.h
index 551bf7df146fc0648330fe5e7a2f23fcb783cbd3..907d47be443b391f387ff9535798b182f7fdf758 100644 (file)
--- a/src/nodepath.h
+++ b/src/nodepath.h
#include <glibmm/ustring.h>
#include <gdk/gdkevents.h>
#include <list>
+#include <2geom/forward.h>
+#include <boost/optional.hpp>
+
struct SPCanvasItem;
class SPCurve;
*/
Radial(Geom::Point const &p)
{
- r = NR::L2(p);
+ r = Geom::L2(p);
if (r > 0) {
- a = NR::atan2 (p);
+ a = Geom::atan2 (p);
} else {
a = HUGE_VAL; //undefined
}
void sp_nodepath_select_all_from_subpath(Inkscape::NodePath::Path *nodepath, bool invert);
void sp_nodepath_select_next (Inkscape::NodePath::Path *nodepath);
void sp_nodepath_select_prev (Inkscape::NodePath::Path *nodepath);
-void sp_nodepath_select_rect (Inkscape::NodePath::Path * nodepath, NR::Rect const &b, gboolean incremental);
+void sp_nodepath_select_rect (Inkscape::NodePath::Path * nodepath, Geom::Rect const &b, gboolean incremental);
GList *save_nodepath_selection (Inkscape::NodePath::Path *nodepath);
void restore_nodepath_selection (Inkscape::NodePath::Path *nodepath, GList *r);
gboolean nodepath_repr_d_changed (Inkscape::NodePath::Path * np, const char *newd);
diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp
index cfc1fc01026a792c4a046af4e7c5760229f87111..96313ab37411a98b4b8202889fb3d5b3b113ff5b 100644 (file)
--- a/src/pencil-context.cpp
+++ b/src/pencil-context.cpp
g_assert( pc->npoints > 1 );
double const tol = prefs_get_double_attribute_limited("tools.freehand.pencil", "tolerance", 10.0, 1.0, 100.0);
- double const tolerance_sq = 0.02 * square( NR::expansion(pc->desktop->w2d()) * tol)
+ double const tolerance_sq = 0.02 * square( pc->desktop->w2d().descrim() * tol)
* exp(0.2*tol - 2);
Geom::Point b[4];
diff --git a/src/rubberband.cpp b/src/rubberband.cpp
index 97a260f0fc46a93a7c488c1f7b6c35b39221243c..7c43da9ea28dfa1114576b5679264a4d5acbc533 100644 (file)
--- a/src/rubberband.cpp
+++ b/src/rubberband.cpp
#include "rubberband.h"
#include "display/canvas-bpath.h"
#include "display/curve.h"
-#include "libnr/nr-point.h"
Inkscape::Rubberband *Inkscape::Rubberband::_instance = NULL;
}
-void Inkscape::Rubberband::start(SPDesktop *d, NR::Point const &p)
+void Inkscape::Rubberband::start(SPDesktop *d, Geom::Point const &p)
{
_points.clear();
_touchpath_curve->reset();
sp_canvas_end_forced_full_redraws(_desktop->canvas);
}
-void Inkscape::Rubberband::move(NR::Point const &p)
+void Inkscape::Rubberband::move(Geom::Point const &p)
{
if (!_started)
return;
_desktop->scroll_to_point(p);
_touchpath_curve->lineto(p);
- NR::Point next = _desktop->d2w(p);
+ Geom::Point next = _desktop->d2w(p);
// we want the points to be at most 0.5 screen pixels apart,
// so that we don't lose anything small;
// if they are farther apart, we interpolate more points
- if (_points.size() > 0 && NR::L2(next-_points.back()) > 0.5) {
- NR::Point prev = _points.back();
- int subdiv = 2 * (int) round(NR::L2(next-prev) + 0.5);
+ if (_points.size() > 0 && Geom::L2(next-_points.back()) > 0.5) {
+ Geom::Point prev = _points.back();
+ int subdiv = 2 * (int) round(Geom::L2(next-prev) + 0.5);
for (int i = 1; i <= subdiv; i ++) {
_points.push_back(prev + ((double)i/subdiv) * (next - prev));
}
if (_rect == NULL) {
_rect = static_cast<CtrlRect *>(sp_canvas_item_new(sp_desktop_controls(_desktop), SP_TYPE_CTRLRECT, NULL));
}
- _rect->setRectangle(NR::Rect(_start, _end));
+ _rect->setRectangle(Geom::Rect(_start, _end));
sp_canvas_item_show(_rect);
if (_touchpath)
_mode = mode;
}
-boost::optional<NR::Rect> Inkscape::Rubberband::getRectangle() const
+boost::optional<Geom::Rect> Inkscape::Rubberband::getRectangle() const
{
if (!_started) {
- return boost::optional<NR::Rect>();
+ return boost::optional<Geom::Rect>();
}
- return NR::Rect(_start, _end);
+ return Geom::Rect(_start, _end);
}
Inkscape::Rubberband *Inkscape::Rubberband::get(SPDesktop *desktop)
diff --git a/src/rubberband.h b/src/rubberband.h
index f9adc7b3b5d839f3e9e108b61f1508a5b639c9d9..6da1ddd8d3f59f5c4c26c68eb8c017c6d5d1d518 100644 (file)
--- a/src/rubberband.h
+++ b/src/rubberband.h
*/
#include "forward.h"
-#include "libnr/nr-forward.h"
-#include "libnr/nr-point.h"
#include <boost/optional.hpp>
#include <vector>
+#include <2geom/point.h>
+#include <2geom/rect.h>
/* fixme: do multidocument safe */
{
public:
- void start(SPDesktop *desktop, NR::Point const &p);
- void move(NR::Point const &p);
- boost::optional<NR::Rect> getRectangle() const;
+ void start(SPDesktop *desktop, Geom::Point const &p);
+ void move(Geom::Point const &p);
+ boost::optional<Geom::Rect> getRectangle() const;
void stop();
bool is_started();
inline int getMode() {return _mode;}
- inline std::vector<NR::Point> getPoints() {return _points;}
+ inline std::vector<Geom::Point> getPoints() {return _points;}
void setMode(int mode);
static Rubberband* _instance;
SPDesktop *_desktop;
- NR::Point _start;
- NR::Point _end;
+ Geom::Point _start;
+ Geom::Point _end;
- std::vector<NR::Point> _points;
+ std::vector<Geom::Point> _points;
CtrlRect *_rect;
SPCanvasItem *_touchpath;
diff --git a/src/selcue.cpp b/src/selcue.cpp
index d8d624e9410e65a844302d8cf97804e54dae0e78..418db8e744ff7b8f5e06e55d70633d6fa9123915 100644 (file)
--- a/src/selcue.cpp
+++ b/src/selcue.cpp
for (GSList const *l = _selection->itemList(); l != NULL; l = l->next) {
SPItem *item = (SPItem *) l->data;
- boost::optional<NR::Rect> const b = sp_item_bbox_desktop(item, bbox_type);
+ boost::optional<Geom::Rect> const b = to_2geom(sp_item_bbox_desktop(item, bbox_type));
SPCanvasItem* box = NULL;
diff --git a/src/select-context.cpp b/src/select-context.cpp
index acbeb2c1822aeff525f134099d8100a562b650d6..374bf0810d82d7a76a4334d706f2cd67e1468afb 100644 (file)
--- a/src/select-context.cpp
+++ b/src/select-context.cpp
// this was a rubberband drag
GSList *items = NULL;
if (r->getMode() == RUBBERBAND_MODE_RECT) {
- boost::optional<NR::Rect> const b = r->getRectangle();
+ boost::optional<Geom::Rect> const b = r->getRectangle();
items = sp_document_items_in_box(sp_desktop_document(desktop), desktop->dkey, *b);
} else if (r->getMode() == RUBBERBAND_MODE_TOUCHPATH) {
items = sp_document_items_at_points(sp_desktop_document(desktop), desktop->dkey, r->getPoints());
index 6bc1c54d33237c1293fd81772268e4851e69d659..5e089a87a419af7464383bfe735de814b27e355d 100644 (file)
@@ -153,7 +153,7 @@ GSList *sp_selection_paste_impl (SPDocument *doc, SPObject *parent, GSList **cli
NR::Matrix local (sp_item_i2doc_affine(SP_ITEM(parent)));
if (!local.test_identity()) {
gchar const *t_str = copy->attribute("transform");
- Geom::Matrix item_t (NR::identity());
+ Geom::Matrix item_t (Geom::identity());
if (t_str)
sp_svg_transform_read(t_str, &item_t);
item_t *= local.inverse();
// At this point, current may already have no item, due to its being a clone whose original is already moved away
// So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform
gchar const *t_str = current->attribute("transform");
- Geom::Matrix item_t (NR::identity());
+ Geom::Matrix item_t (Geom::identity());
if (t_str)
sp_svg_transform_read(t_str, &item_t);
item_t *= sp_item_i2doc_affine(SP_ITEM(doc->getObjectByRepr(current->parent())));
}
// FIXME: also transform gradient/pattern fills, by forking? NO, this must be nondestructive
- double ex = NR::expansion(sp_item_i2doc_affine(item));
+ double ex = to_2geom(sp_item_i2doc_affine(item)).descrim();
if (ex != 1.0) {
css = sp_css_attr_scale (css, ex);
}
@@ -1219,32 +1219,34 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix cons
sp_object_read_attr (SP_OBJECT (item), "transform");
// calculate the matrix we need to apply to the clone to cancel its induced transform from its original
- NR::Matrix parent_transform = sp_item_i2root_affine(SP_ITEM(SP_OBJECT_PARENT (item)));
- NR::Matrix t = parent_transform * from_2geom(matrix_to_desktop (matrix_from_desktop (affine, item), item)) * parent_transform.inverse();
- NR::Matrix t_inv =parent_transform * from_2geom(matrix_to_desktop (matrix_from_desktop (affine.inverse(), item), item)) * parent_transform.inverse();
- NR::Matrix result = t_inv * item->transform * t;
+ Geom::Matrix parent_transform = sp_item_i2root_affine(SP_ITEM(SP_OBJECT_PARENT (item)));
+ Geom::Matrix t = parent_transform * matrix_to_desktop (matrix_from_desktop (affine, item), item) * parent_transform.inverse();
+ NR::Matrix t_nr = from_2geom(t);
+ Geom::Matrix t_inv =parent_transform * matrix_to_desktop (matrix_from_desktop (affine.inverse(), item), item) * parent_transform.inverse();
+ Geom::Matrix result = t_inv * item->transform * t;
if ((prefs_parallel || prefs_unmoved) && affine.isTranslation()) {
// we need to cancel out the move compensation, too
// find out the clone move, same as in sp_use_move_compensate
- NR::Matrix parent = sp_use_get_parent_transform (SP_USE(item));
- NR::Matrix clone_move = parent.inverse() * t * parent;
+ Geom::Matrix parent = sp_use_get_parent_transform (SP_USE(item));
+ Geom::Matrix clone_move = parent.inverse() * t * parent;
if (prefs_parallel) {
- NR::Matrix move = result * clone_move * t_inv;
- sp_item_write_transform(item, SP_OBJECT_REPR(item), move, &move);
+ Geom::Matrix move = result * clone_move * t_inv;
+ NR::Matrix move_nr = from_2geom(move);
+ sp_item_write_transform(item, SP_OBJECT_REPR(item), from_2geom(move), &move_nr);
} else if (prefs_unmoved) {
//if (SP_IS_USE(sp_use_get_original(SP_USE(item))))
// clone_move = NR::identity();
- NR::Matrix move = result * clone_move;
- sp_item_write_transform(item, SP_OBJECT_REPR(item), move, &t);
+ Geom::Matrix move = result * clone_move;
+ sp_item_write_transform(item, SP_OBJECT_REPR(item), from_2geom(move), &t_nr);
}
} else {
// just apply the result
- sp_item_write_transform(item, SP_OBJECT_REPR(item), result, &t);
+ sp_item_write_transform(item, SP_OBJECT_REPR(item), result, &t_nr);
}
} else {
*/
void scroll_to_show_item(SPDesktop *desktop, SPItem *item)
{
- NR::Rect dbox = desktop->get_display_area();
- boost::optional<NR::Rect> sbox = sp_item_bbox_desktop(item);
+ Geom::Rect dbox = desktop->get_display_area();
+ boost::optional<Geom::Rect> sbox = to_2geom(sp_item_bbox_desktop(item));
if ( sbox && dbox.contains(*sbox) == false ) {
- NR::Point const s_dt = sbox->midpoint();
- NR::Point const s_w = desktop->d2w(s_dt);
- NR::Point const d_dt = dbox.midpoint();
- NR::Point const d_w = desktop->d2w(d_dt);
- NR::Point const moved_w( d_w - s_w );
+ Geom::Point const s_dt = sbox->midpoint();
+ Geom::Point const s_w = desktop->d2w(s_dt);
+ Geom::Point const d_dt = dbox.midpoint();
+ Geom::Point const d_w = desktop->d2w(d_dt);
+ Geom::Point const moved_w( d_w - s_w );
gint const dx = (gint) moved_w[X];
gint const dy = (gint) moved_w[Y];
desktop->scroll_world(dx, dy);
}
// calculate the transform to be applied to objects to move them to 0,0
- NR::Point move_p = NR::Point(0, sp_document_height(doc)) - *c;
- move_p[NR::Y] = -move_p[NR::Y];
- NR::Matrix move = NR::Matrix (NR::translate (move_p));
+ Geom::Point move_p = Geom::Point(0, sp_document_height(doc)) - *c;
+ move_p[Geom::Y] = -move_p[Geom::Y];
+ Geom::Matrix move = Geom::Matrix (Geom::Translate (move_p));
GSList *items = g_slist_copy((GSList *) selection->itemList());
// bottommost object, after sorting
SPObject *parent = SP_OBJECT_PARENT (items->data);
- NR::Matrix parent_transform (sp_item_i2root_affine(SP_ITEM(parent)));
+ Geom::Matrix parent_transform (sp_item_i2root_affine(SP_ITEM(parent)));
// remember the position of the first item
gint pos = SP_OBJECT_REPR (items->data)->position();
prefs->setInt("options.clonecompensation", "value", SP_CLONE_COMPENSATION_UNMOVED);
gchar const *mark_id = generate_marker(repr_copies, bounds, doc,
- ( NR::Matrix(NR::translate(desktop->dt2doc(NR::Point(r->min()[NR::X],
- r->max()[NR::Y]))))
+ ( Geom::Matrix(Geom::Translate(desktop->dt2doc(
+ Geom::Point(r->min()[Geom::X],
+ r->max()[Geom::Y]))))
* parent_transform.inverse() ),
parent_transform * move);
(void)mark_id;
SPPattern *pattern = pattern_getroot (SP_PATTERN (server));
- NR::Matrix pat_transform = pattern_patternTransform (SP_PATTERN (server));
+ Geom::Matrix pat_transform = to_2geom(pattern_patternTransform (SP_PATTERN (server)));
pat_transform *= item->transform;
for (SPObject *child = sp_object_first_child(SP_OBJECT(pattern)) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
// this is needed to make sure the new item has curve (simply requestDisplayUpdate does not work)
sp_document_ensure_up_to_date (doc);
- NR::Matrix transform( i->transform * pat_transform );
+ Geom::Matrix transform( i->transform * pat_transform );
sp_item_write_transform(i, SP_OBJECT_REPR(i), transform);
new_select = g_slist_prepend(new_select, i);
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to fit canvas to."));
return false;
}
- boost::optional<NR::Rect> const bbox(desktop->selection->bounds());
+ boost::optional<Geom::Rect> const bbox(to_2geom(desktop->selection->bounds()));
if (bbox && !bbox->isEmpty()) {
doc->fitToRect(*bbox);
return true;
sp_document_ensure_up_to_date(doc);
SPItem const *const root = SP_ITEM(doc->root);
- boost::optional<NR::Rect> const bbox(root->getBounds(sp_item_i2r_affine(root)));
+ boost::optional<Geom::Rect> const bbox(to_2geom(root->getBounds(sp_item_i2r_affine(root))));
if (bbox && !bbox->isEmpty()) {
doc->fitToRect(*bbox);
return true;
diff --git a/src/seltrans.cpp b/src/seltrans.cpp
index d5e6afd8acd26f67c172be5c6b01c9bd269b8af7..f5572796d27d44790c8cd4eb9cd8795d1339fc85 100644 (file)
--- a/src/seltrans.cpp
+++ b/src/seltrans.cpp
SPItem *copy_item = (SPItem *) sp_desktop_document(_desktop)->getObjectByRepr(copy_repr);
- NR::Matrix const *new_affine;
+ Geom::Matrix const *new_affine;
if (_show == SHOW_OUTLINE) {
NR::Matrix const i2d(sp_item_i2d_affine(original_item));
NR::Matrix const i2dnew( i2d * _current_relative_affine );
NR::Point pt_geom = _getGeomHandlePos(pt);
NR::scale geom_scale = calcScaleFactors(_point_geom, pt_geom, _origin_for_specpoints);
- _absolute_affine = NR::identity(); //Initialize the scaler
+ _absolute_affine = Geom::identity(); //Initialize the scaler
if (state & GDK_MOD1_MASK) { // scale by an integer multiplier/divider
// We're scaling either the visual or the geometric bbox here (see the comment above)
@@ -1017,7 +1017,7 @@ gboolean Inkscape::SelTrans::stretchRequest(SPSelTransHandle const &handle, NR::
NR::scale geom_scale = calcScaleFactors(_point_geom, pt_geom, _origin_for_specpoints);
geom_scale[perp] = 1;
- _absolute_affine = NR::identity(); //Initialize the scaler
+ _absolute_affine = Geom::identity(); //Initialize the scaler
if (state & GDK_MOD1_MASK) { // stretch by an integer multiplier/divider
if (fabs(default_scale[axis]) > 1) {
@@ -1184,7 +1184,7 @@ gboolean Inkscape::SelTrans::skewRequest(SPSelTransHandle const &handle, NR::Poi
pt[dim_a] = initial_delta[dim_a] * scale[dim_a] + _origin[dim_a];
// Calculate the relative affine
- _relative_affine = NR::identity();
+ _relative_affine = Geom::identity();
_relative_affine[2*dim_a + dim_a] = (pt[dim_a] - _origin[dim_a]) / initial_delta[dim_a];
_relative_affine[2*dim_a + (dim_b)] = (pt[dim_b] - _point[dim_b]) / initial_delta[dim_a];
_relative_affine[2*(dim_b) + (dim_a)] = 0;
diff --git a/src/shape-editor.cpp b/src/shape-editor.cpp
index 6cf1182ee0aedb92e71a76a920cb402cfc76716d..4fe1130bcd48347c66afe8cffcf501f33bfb61c4 100644 (file)
--- a/src/shape-editor.cpp
+++ b/src/shape-editor.cpp
(( !SP_OBJECT_STYLE(item)->stroke.isNone() ?
desktop->current_zoom() *
SP_OBJECT_STYLE (item)->stroke_width.computed * 0.5 *
- NR::expansion(sp_item_i2d_affine(item))
+ to_2geom(sp_item_i2d_affine(item)).descrim()
: 0.0)
- + prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100)) /NR::expansion(sp_item_i2d_affine(item));
- bool close = (NR::L2 (delta) < stroke_tolerance);
+ + prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100)) / to_2geom(sp_item_i2d_affine(item)).descrim();
+ bool close = (Geom::L2 (delta) < stroke_tolerance);
if (remember && close) {
// calculate index for nodepath's representation.
}
}
-void ShapeEditor::select_rect(NR::Rect const &rect, bool add) {
+void ShapeEditor::select_rect(Geom::Rect const &rect, bool add) {
if (this->nodepath) {
sp_nodepath_select_rect(this->nodepath, rect, add);
}
diff --git a/src/shape-editor.h b/src/shape-editor.h
index 9ce64355fe15b64c6e8c7d8e144a0586c1e9ea36..8780586c40b7ac227e94c8955b23bfb57c2f7ce2 100644 (file)
--- a/src/shape-editor.h
+++ b/src/shape-editor.h
void finish_drag ();
- void select_rect (NR::Rect const &rect, bool add);
+ void select_rect (Geom::Rect const &rect, bool add);
bool has_selection ();
void deselect ();
diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp
index 5c3ff8a958725ac7248f346e8f9cd026d19cfb79..ec60251fc4d69a33610eb839a4c268e8ed5e4f84 100644 (file)
--- a/src/sp-flowtext.cpp
+++ b/src/sp-flowtext.cpp
static void sp_flowtext_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
static void sp_flowtext_set(SPObject *object, unsigned key, gchar const *value);
-static void sp_flowtext_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
+static void sp_flowtext_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
static void sp_flowtext_print(SPItem *item, SPPrintContext *ctx);
static gchar *sp_flowtext_description(SPItem *item);
static NRArenaItem *sp_flowtext_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags);
group->rebuildLayout();
NRRect paintbox;
- sp_item_invoke_bbox(group, &paintbox, NR::identity(), TRUE);
+ sp_item_invoke_bbox(group, &paintbox, Geom::identity(), TRUE);
for (SPItemView *v = group->display; v != NULL; v = v->next) {
group->_clearFlow(NR_ARENA_GROUP(v->arenaitem));
nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object));
if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG )) {
SPFlowtext *text = SP_FLOWTEXT(object);
NRRect paintbox;
- sp_item_invoke_bbox(text, &paintbox, NR::identity(), TRUE);
+ sp_item_invoke_bbox(text, &paintbox, Geom::identity(), TRUE);
for (SPItemView* v = text->display; v != NULL; v = v->next) {
text->_clearFlow(NR_ARENA_GROUP(v->arenaitem));
nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object));
@@ -323,7 +323,7 @@ sp_flowtext_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::
}
static void
-sp_flowtext_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const /*flags*/)
+sp_flowtext_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const /*flags*/)
{
SPFlowtext *group = SP_FLOWTEXT(item);
group->layout.getBoundingBox(bbox, transform);
// Add stroke width
SPStyle* style=SP_OBJECT_STYLE (item);
if ( !style->stroke.isNone() ) {
- double const scale = expansion(transform);
+ double const scale = transform.descrim();
if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
double const width = MAX(0.125, style->stroke_width.computed * scale);
if ( fabs(bbox->x1 - bbox->x0) > -0.00001 && fabs(bbox->y1 - bbox->y0) > -0.00001 ) {
SPFlowtext *group = SP_FLOWTEXT(item);
NRRect pbox;
- sp_item_invoke_bbox(item, &pbox, NR::identity(), TRUE);
+ sp_item_invoke_bbox(item, &pbox, Geom::identity(), TRUE);
NRRect bbox;
boost::optional<NR::Rect> bbox_maybe = sp_item_bbox_desktop(item);
if (!bbox_maybe) {
@@ -390,7 +390,7 @@ sp_flowtext_show(SPItem *item, NRArena *arena, unsigned/* key*/, unsigned /*flag
// pass the bbox of the flowtext object as paintbox (used for paintserver fills)
NRRect paintbox;
- sp_item_invoke_bbox(item, &paintbox, NR::identity(), TRUE);
+ sp_item_invoke_bbox(item, &paintbox, Geom::identity(), TRUE);
group->layout.show(flowed, &paintbox);
return flowed;
// set x,y attributes only when we need to
bool set_x = false;
bool set_y = false;
- if (!item->transform.test_identity()) {
+ if (!item->transform.isIdentity()) {
set_x = set_y = true;
} else {
Inkscape::Text::Layout::iterator it_chunk_start = it;
diff --git a/src/sp-image.cpp b/src/sp-image.cpp
index f49812ac78c21870fc945e33dd509815ed8a36dc..a3112bd03f5d0a0c1c44565423816725668e064c 100644 (file)
--- a/src/sp-image.cpp
+++ b/src/sp-image.cpp
static void sp_image_update (SPObject *object, SPCtx *ctx, unsigned int flags);
static Inkscape::XML::Node *sp_image_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
-static void sp_image_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
+static void sp_image_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
static void sp_image_print (SPItem * item, SPPrintContext *ctx);
static gchar * sp_image_description (SPItem * item);
static void sp_image_snappoints(SPItem const *item, SnapPointsIter p);
@@ -1033,7 +1033,7 @@ sp_image_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XM
}
static void
-sp_image_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const /*flags*/)
+sp_image_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const /*flags*/)
{
SPImage const &image = *SP_IMAGE(item);
@@ -1043,10 +1043,10 @@ sp_image_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, uns
double const x1 = x0 + image.width.computed;
double const y1 = y0 + image.height.computed;
- nr_rect_union_pt(bbox, NR::Point(x0, y0) * transform);
- nr_rect_union_pt(bbox, NR::Point(x1, y0) * transform);
- nr_rect_union_pt(bbox, NR::Point(x1, y1) * transform);
- nr_rect_union_pt(bbox, NR::Point(x0, y1) * transform);
+ nr_rect_union_pt(bbox, Geom::Point(x0, y0) * transform);
+ nr_rect_union_pt(bbox, Geom::Point(x1, y0) * transform);
+ nr_rect_union_pt(bbox, Geom::Point(x1, y1) * transform);
+ nr_rect_union_pt(bbox, Geom::Point(x0, y1) * transform);
}
}
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp
index 3d717e669adb5696acb396972176bae1000acb46..123fe73304c110c4ad1e8cab53809ec94d64f5d9 100644 (file)
--- a/src/sp-item-group.cpp
+++ b/src/sp-item-group.cpp
static Inkscape::XML::Node *sp_group_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
static void sp_group_set(SPObject *object, unsigned key, char const *value);
-static void sp_group_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
+static void sp_group_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
static void sp_group_print (SPItem * item, SPPrintContext *ctx);
static gchar * sp_group_description (SPItem * item);
static NR::Matrix sp_group_set_transform(SPItem *item, NR::Matrix const &xform);
@@ -274,7 +274,7 @@ sp_group_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XM
}
static void
-sp_group_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags)
+sp_group_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags)
{
SP_GROUP(item)->group->calculateBBox(bbox, transform, flags);
}
Inkscape::XML::Node *nrepr = SP_OBJECT_REPR (child)->duplicate(prepr->document());
// Merging transform
- NR::Matrix ctrans;
- NR::Matrix const g(gitem->transform);
+ Geom::Matrix ctrans;
+ Geom::Matrix const g(gitem->transform);
if (SP_IS_USE(citem) && sp_use_get_original (SP_USE(citem)) &&
SP_OBJECT_PARENT (sp_use_get_original (SP_USE(citem))) == SP_OBJECT(group)) {
// make sure a clone's effective transform is the same as was under group
}
}
-void CGroup::calculateBBox(NRRect *bbox, NR::Matrix const &transform, unsigned const flags) {
+void CGroup::calculateBBox(NRRect *bbox, Geom::Matrix const &transform, unsigned const flags) {
boost::optional<NR::Rect> dummy_bbox;
@@ -709,7 +709,7 @@ void CGroup::calculateBBox(NRRect *bbox, NR::Matrix const &transform, unsigned c
SPObject *o = SP_OBJECT (l->data);
if (SP_IS_ITEM(o) && !SP_ITEM(o)->isHidden()) {
SPItem *child = SP_ITEM(o);
- NR::Matrix const ct(child->transform * transform);
+ Geom::Matrix const ct(to_2geom(child->transform) * transform);
sp_item_invoke_bbox_full(child, dummy_bbox, ct, flags, FALSE);
}
l = g_slist_remove (l, o);
diff --git a/src/sp-item-group.h b/src/sp-item-group.h
index 46676194c627dfba019e8f326bbbbd59e592ebad..1cf4e9912da248834a2bdb6d68e1536a2f6997fd 100644 (file)
--- a/src/sp-item-group.h
+++ b/src/sp-item-group.h
class CGroup;
-namespace NR{ struct translate; }
-
struct SPGroup : public SPLPEItem {
enum LayerMode { GROUP, LAYER };
virtual void onChildRemoved(Inkscape::XML::Node *child);
virtual void onUpdate(SPCtx *ctx, unsigned int flags);
virtual void onModified(guint flags);
- virtual void calculateBBox(NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
+ virtual void calculateBBox(NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
virtual void onPrint(SPPrintContext *ctx);
virtual void onOrderChanged(Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref);
virtual gchar *getDescription();
diff --git a/src/sp-item.cpp b/src/sp-item.cpp
index cc106e8f71f42fdebc39b9565ce9540178ae19cd..b412353e14c144f97c851cc8d0f78935cd3eda7b 100644 (file)
--- a/src/sp-item.cpp
+++ b/src/sp-item.cpp
{
if (!item->isHidden()) {
if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->print) {
- if (!item->transform.test_identity()
+ if (!item->transform.isIdentity()
|| SP_OBJECT_STYLE(item)->opacity.value != SP_SCALE24_MAX)
{
sp_print_bind(ctx, item->transform, SP_SCALE24_TO_FLOAT(SP_OBJECT_STYLE(item)->opacity.value));
diff --git a/src/sp-item.h b/src/sp-item.h
index e52dbf97453977672984be76e7cc2b20cdb1ca75..76e07e88ed2047152d14d5f3aa5c46433bddaf38 100644 (file)
--- a/src/sp-item.h
+++ b/src/sp-item.h
struct SPItemCtx {
SPCtx ctx;
/** Item to document transformation */
- NR::Matrix i2doc;
+ Geom::Matrix i2doc;
/** Viewport size */
NRRect vp;
/** Item to viewport transformation */
- NR::Matrix i2vp;
+ Geom::Matrix i2vp;
};
/** Abstract base class for all visible shapes. */
double transform_center_x;
double transform_center_y;
- NR::Matrix transform;
+ Geom::Matrix transform;
SPClipPathReference *clip_ref;
SPMaskReference *mask_ref;
SPObjectClass parent_class;
/** BBox union in given coordinate system */
- void (* bbox) (SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
+ void (* bbox) (SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
/** Printing method. Assumes ctm is set to item affine matrix */
/* \todo Think about it, and maybe implement generic export method instead (Lauris) */
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp
index 7783c334d04e87814657f5fe85c6a74afb40a6c1..006e3a140e2796fc7e1f0cddda2bce7a62972388 100644 (file)
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
desktop->setWindowSize(w, h);
}
if (x>0 && y>0) {
- desktop->setWindowPosition(NR::Point(x, y));
+ desktop->setWindowPosition(Geom::Point(x, y));
}
}
gint save_geometry_in_file =
(1==prefs_get_int_attribute("options.savewindowgeometry", "value", 0));
Inkscape::XML::Node *view = SP_OBJECT_REPR(desktop->namedview);
- NR::Rect const r = desktop->get_display_area();
+ Geom::Rect const r = desktop->get_display_area();
// saving window geometry is not undoable
bool saved = sp_document_get_undo_sensitive(sp_desktop_document(desktop));
sp_document_set_undo_sensitive(sp_desktop_document(desktop), false);
sp_repr_set_svg_double(view, "inkscape:zoom", desktop->current_zoom());
- sp_repr_set_svg_double(view, "inkscape:cx", r.midpoint()[NR::X]);
- sp_repr_set_svg_double(view, "inkscape:cy", r.midpoint()[NR::Y]);
+ sp_repr_set_svg_double(view, "inkscape:cx", r.midpoint()[Geom::X]);
+ sp_repr_set_svg_double(view, "inkscape:cy", r.midpoint()[Geom::Y]);
if (save_geometry_in_file) {
gint w, h, x, y;
@@ -1061,7 +1061,7 @@ Inkscape::CanvasGrid * sp_namedview_get_first_enabled_grid(SPNamedView *namedvie
return NULL;
}
-void SPNamedView::translateGuides(NR::translate const &tr) {
+void SPNamedView::translateGuides(Geom::Translate const &tr) {
for (GSList *l = guides; l != NULL; l = l->next) {
SPGuide &guide = *SP_GUIDE(l->data);
Geom::Point point_on_line = guide.point_on_line;
diff --git a/src/sp-namedview.h b/src/sp-namedview.h
index cfc57d1c4cab6688481796e6f86932f6312622b3..3ed02bf59a4fbba75f88f77249ad7b0b08d949e3 100644 (file)
--- a/src/sp-namedview.h
+++ b/src/sp-namedview.h
#include "helper/helper-forward.h"
#include "sp-object-group.h"
-#include "libnr/nr-point.h"
#include "sp-metric.h"
#include "snap.h"
GSList const *getViewList() const;
SPMetric getDefaultMetric() const;
- void translateGuides(NR::translate const &translation);
+ void translateGuides(Geom::Translate const &translation);
void scrollAllDesktops(double dx, double dy, bool is_scrolling);
};
diff --git a/src/sp-root.cpp b/src/sp-root.cpp
index 0ff3b48b6d241408e5ed5f85f1438b4aedc3ac85..80c04c59f30461dec782391359e0b52b1f5d34c9 100644 (file)
--- a/src/sp-root.cpp
+++ b/src/sp-root.cpp
static Inkscape::XML::Node *sp_root_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
static NRArenaItem *sp_root_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags);
-static void sp_root_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
+static void sp_root_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
static void sp_root_print(SPItem *item, SPPrintContext *ctx);
static SPGroupClass *parent_class;
/* root->viewbox.set_identity(); */
root->viewBox_set = FALSE;
- root->c2p.set_identity();
+ root->c2p.setIdentity();
root->defs = NULL;
}
SPItemCtx rctx = *ictx;
/* Calculate child to parent transformation */
- root->c2p.set_identity();
+ root->c2p.setIdentity();
if (object->parent) {
/*
* fixme: height seems natural, as this makes the inner svg element
* fixme: self-contained. The spec is vague here.
*/
- root->c2p = NR::Matrix(NR::translate(root->x.computed,
- root->y.computed));
+ root->c2p = Geom::Matrix(Geom::Translate(root->x.computed,
+ root->y.computed));
}
if (root->viewBox_set) {
}
/* Compose additional transformation from scale and position */
- NR::Point const viewBox_min(root->viewBox.x0,
+ Geom::Point const viewBox_min(root->viewBox.x0,
root->viewBox.y0);
- NR::Point const viewBox_max(root->viewBox.x1,
+ Geom::Point const viewBox_max(root->viewBox.x1,
root->viewBox.y1);
- NR::scale const viewBox_length( viewBox_max - viewBox_min );
- NR::scale const new_length(width, height);
+ Geom::Scale const viewBox_length( viewBox_max - viewBox_min );
+ Geom::Scale const new_length(width, height);
/* Append viewbox transformation */
/* TODO: The below looks suspicious to me (pjrm): I wonder whether the RHS
expression should have c2p at the beginning rather than at the end. Test it. */
- root->c2p = NR::translate(-viewBox_min) * ( new_length / viewBox_length ) * NR::translate(x, y) * root->c2p;
+ root->c2p = Geom::Translate(-viewBox_min) * ( new_length * viewBox_length.inverse() ) * Geom::Translate(x, y) * root->c2p;
}
rctx.i2doc = root->c2p * rctx.i2doc;
@@ -644,12 +644,12 @@ sp_root_show(SPItem *item, NRArena *arena, unsigned int key, unsigned int flags)
* Virtual bbox callback.
*/
static void
-sp_root_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags)
+sp_root_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags)
{
SPRoot const *root = SP_ROOT(item);
if (((SPItemClass *) (parent_class))->bbox) {
- NR::Matrix const product( root->c2p * transform );
+ Geom::Matrix const product( to_2geom(root->c2p) * transform );
((SPItemClass *) (parent_class))->bbox(item, bbox,
product,
flags);
diff --git a/src/sp-root.h b/src/sp-root.h
index c298223f10e2cfcdc968f549257949fc8aaa3c03..655bc3caf1146d918fe61e609462e7dc18001ede 100644 (file)
--- a/src/sp-root.h
+++ b/src/sp-root.h
#define SP_IS_ROOT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_ROOT))
#define SP_IS_ROOT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_ROOT))
-#include <libnr/nr-matrix.h>
#include "version.h"
#include "svg/svg-length.h"
#include "enums.h"
unsigned int aspect_clip : 1;
/** Child to parent additional transform. */
- NR::Matrix c2p;
+ Geom::Matrix c2p;
gchar *onload;
diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp
index e22f8b785024b7ceda861c3d954c0c3f75d1d530..fbb9a60f6f1f42dc68aeabed144b60220faeb634 100644 (file)
--- a/src/sp-shape.cpp
+++ b/src/sp-shape.cpp
static void sp_shape_modified (SPObject *object, unsigned int flags);
static Inkscape::XML::Node *sp_shape_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
-static void sp_shape_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
+static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
void sp_shape_print (SPItem * item, SPPrintContext * ctx);
static NRArenaItem *sp_shape_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags);
static void sp_shape_hide (SPItem *item, unsigned int key);
* Calculates the bounding box for item, storing it into bbox.
* This also includes the bounding boxes of any markers included in the shape.
*/
-static void sp_shape_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags)
+static void sp_shape_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags)
{
SPShape const *shape = SP_SHAPE (item);
@@ -502,7 +502,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &tr
SPStyle* style=SP_OBJECT_STYLE (item);
if (!style->stroke.isNone()) {
- double const scale = expansion(transform);
+ double const scale = transform.descrim();
if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
double const width = MAX(0.125, style->stroke_width.computed * scale);
if ( fabs(cbbox.x1-cbbox.x0) > -0.00001 && fabs(cbbox.y1-cbbox.y0) > -0.00001 ) {
@@ -523,10 +523,10 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &tr
SPMarker* marker = SP_MARKER (shape->marker[SP_MARKER_LOC_START]);
SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (shape->marker[SP_MARKER_LOC_START]));
- NR::Matrix tr(sp_shape_marker_get_transform_at_start(path_it->front()));
+ Geom::Matrix tr(sp_shape_marker_get_transform_at_start(path_it->front()));
if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
- tr = NR::scale(style->stroke_width.computed) * tr;
+ tr = Geom::Scale(style->stroke_width.computed) * tr;
}
// total marker transform
@@ -534,7 +534,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &tr
// get bbox of the marker with that transform
NRRect marker_bbox;
- sp_item_invoke_bbox (marker_item, &marker_bbox, tr, true);
+ sp_item_invoke_bbox (marker_item, &marker_bbox, from_2geom(tr), true);
// union it with the shape bbox
nr_rect_d_union (&cbbox, &cbbox, &marker_bbox);
}
@@ -551,10 +551,10 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &tr
SPMarker* marker = SP_MARKER (shape->marker[SP_MARKER_LOC_MID]);
SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (shape->marker[SP_MARKER_LOC_MID]));
- NR::Matrix tr(sp_shape_marker_get_transform(*curve_it1, *curve_it2));
+ Geom::Matrix tr(sp_shape_marker_get_transform(*curve_it1, *curve_it2));
if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
- tr = NR::scale(style->stroke_width.computed) * tr;
+ tr = Geom::Scale(style->stroke_width.computed) * tr;
}
// total marker transform
@@ -562,7 +562,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &tr
// get bbox of the marker with that transform
NRRect marker_bbox;
- sp_item_invoke_bbox (marker_item, &marker_bbox, tr, true);
+ sp_item_invoke_bbox (marker_item, &marker_bbox, from_2geom(tr), true);
// union it with the shape bbox
nr_rect_d_union (&cbbox, &cbbox, &marker_bbox);
@@ -583,10 +583,10 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &tr
}
Geom::Curve const &lastcurve = (*path_it)[index];
- NR::Matrix tr = sp_shape_marker_get_transform_at_end(lastcurve);
+ Geom::Matrix tr = sp_shape_marker_get_transform_at_end(lastcurve);
if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
- tr = NR::scale(style->stroke_width.computed) * tr;
+ tr = Geom::Scale(style->stroke_width.computed) * tr;
}
// total marker transform
SPMarker* marker = SP_MARKER (shape->marker[SP_MARKER_LOC_START]);
SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (shape->marker[SP_MARKER_LOC_START]));
- NR::Matrix tr(sp_shape_marker_get_transform_at_start(path_it->front()));
+ Geom::Matrix tr(sp_shape_marker_get_transform_at_start(path_it->front()));
if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
- tr = NR::scale(style->stroke_width.computed) * tr;
+ tr = Geom::Scale(style->stroke_width.computed) * tr;
}
tr = marker_item->transform * marker->c2p * tr;
SPMarker* marker = SP_MARKER (shape->marker[SP_MARKER_LOC_MID]);
SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (shape->marker[SP_MARKER_LOC_MID]));
- NR::Matrix tr(sp_shape_marker_get_transform(*curve_it1, *curve_it2));
+ Geom::Matrix tr(sp_shape_marker_get_transform(*curve_it1, *curve_it2));
if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
- tr = NR::scale(style->stroke_width.computed) * tr;
+ tr = Geom::Scale(style->stroke_width.computed) * tr;
}
tr = marker_item->transform * marker->c2p * tr;
}
Geom::Curve const &lastcurve = (*path_it)[index];
- NR::Matrix tr = sp_shape_marker_get_transform_at_end(lastcurve);
+ Geom::Matrix tr = sp_shape_marker_get_transform_at_end(lastcurve);
if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
- tr = NR::scale(style->stroke_width.computed) * tr;
+ tr = Geom::Scale(style->stroke_width.computed) * tr;
}
tr = marker_item->transform * marker->c2p * tr;
diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp
index 064c43442f4929bd2206541f71eac6704b4ae751..06f8bfb493f59de4e2b07c72cf4c1b5f48cae4db 100644 (file)
--- a/src/sp-symbol.cpp
+++ b/src/sp-symbol.cpp
static NRArenaItem *sp_symbol_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flags);
static void sp_symbol_hide (SPItem *item, unsigned int key);
-static void sp_symbol_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
+static void sp_symbol_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
static void sp_symbol_print (SPItem *item, SPPrintContext *ctx);
static SPGroupClass *parent_class;
}
static void
-sp_symbol_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags)
+sp_symbol_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags)
{
SPSymbol const *symbol = SP_SYMBOL(item);
@@ -449,7 +449,7 @@ sp_symbol_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, un
/* Cloned <symbol> is actually renderable */
if (((SPItemClass *) (parent_class))->bbox) {
- Geom::Matrix const a( symbol->c2p * (Geom::Matrix)transform );
+ Geom::Matrix const a( symbol->c2p * transform );
((SPItemClass *) (parent_class))->bbox(item, bbox, a, flags);
}
}
diff --git a/src/sp-text.cpp b/src/sp-text.cpp
index fcfb84968a8b59a0d611919679f8322b3ec04432..754cc24f91e2e19f7d73a7bdb26cdbca8c3fa156 100644 (file)
--- a/src/sp-text.cpp
+++ b/src/sp-text.cpp
static void sp_text_modified (SPObject *object, guint flags);
static Inkscape::XML::Node *sp_text_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
-static void sp_text_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
+static void sp_text_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
static NRArenaItem *sp_text_show (SPItem *item, NRArena *arena, unsigned key, unsigned flags);
static void sp_text_hide (SPItem *item, unsigned key);
static char *sp_text_description (SPItem *item);
@@ -353,14 +353,14 @@ sp_text_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML
}
static void
-sp_text_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const /*flags*/)
+sp_text_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const /*flags*/)
{
SP_TEXT(item)->layout.getBoundingBox(bbox, transform);
// Add stroke width
SPStyle* style=SP_OBJECT_STYLE (item);
if (!style->stroke.isNone()) {
- double const scale = expansion(transform);
+ double const scale = transform.descrim();
if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
double const width = MAX(0.125, style->stroke_width.computed * scale);
if ( fabs(bbox->x1 - bbox->x0) > -0.00001 && fabs(bbox->y1 - bbox->y0) > -0.00001 ) {
diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp
index ad85b4d85d3419103dd947272558ae93ff46c93d..00244c122133d284eebfde8182961fd8fd2c6980 100644 (file)
--- a/src/sp-tref.cpp
+++ b/src/sp-tref.cpp
static void sp_tref_modified(SPObject *object, guint flags);
static Inkscape::XML::Node *sp_tref_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
-static void sp_tref_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
+static void sp_tref_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
static gchar *sp_tref_description(SPItem *item);
static void sp_tref_href_changed(SPObject *old_ref, SPObject *ref, SPTRef *tref);
@@ -320,7 +320,7 @@ sp_tref_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML:
* The code for this function is swiped from the tspan bbox code, since tref should work pretty much the same way
*/
static void
-sp_tref_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const /*flags*/)
+sp_tref_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const /*flags*/)
{
// find out the ancestor text which holds our layout
SPObject *parent_text = SP_OBJECT(item);
@@ -334,7 +334,7 @@ sp_tref_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsi
// Add stroke width
SPStyle* style=SP_OBJECT_STYLE (item);
if (!style->stroke.isNone()) {
- double const scale = expansion(transform);
+ double const scale = transform.descrim();
if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
double const width = MAX(0.125, style->stroke_width.computed * scale);
if ( fabs(bbox->x1 - bbox->x0) > -0.00001 && fabs(bbox->y1 - bbox->y0) > -0.00001 ) {
diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp
index c86c852d7eb14d3316e1b72774dc4595e6f87192..2496fc6e0095f619dc985fb82a0fa935fe3d1137 100644 (file)
--- a/src/sp-tspan.cpp
+++ b/src/sp-tspan.cpp
static void sp_tspan_set(SPObject *object, unsigned key, gchar const *value);
static void sp_tspan_update(SPObject *object, SPCtx *ctx, guint flags);
static void sp_tspan_modified(SPObject *object, unsigned flags);
-static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
+static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
static Inkscape::XML::Node *sp_tspan_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
static char *sp_tspan_description (SPItem *item);
}
}
-static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const /*flags*/)
+static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const /*flags*/)
{
// find out the ancestor text which holds our layout
SPObject *parent_text = SP_OBJECT(item);
@@ -216,7 +216,7 @@ static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &tr
// Add stroke width
SPStyle* style=SP_OBJECT_STYLE (item);
if (!style->stroke.isNone()) {
- double const scale = expansion(transform);
+ double const scale = transform.descrim();
if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
double const width = MAX(0.125, style->stroke_width.computed * scale);
if ( fabs(bbox->x1 - bbox->x0) > -0.00001 && fabs(bbox->y1 - bbox->y0) > -0.00001 ) {
diff --git a/src/sp-use.cpp b/src/sp-use.cpp
index 50b657728fbd3f35d14e5784202c4bae90497699..213f827ef2dfa12b9bdcd32133b7ae697ab50c2c 100644 (file)
--- a/src/sp-use.cpp
+++ b/src/sp-use.cpp
static void sp_use_update(SPObject *object, SPCtx *ctx, guint flags);
static void sp_use_modified(SPObject *object, guint flags);
-static void sp_use_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
+static void sp_use_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags);
static void sp_use_snappoints(SPItem const *item, SnapPointsIter p);
static void sp_use_print(SPItem *item, SPPrintContext *ctx);
static gchar *sp_use_description(SPItem *item);
@@ -269,15 +269,15 @@ sp_use_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::
}
static void
-sp_use_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags)
+sp_use_bbox(SPItem const *item, NRRect *bbox, Geom::Matrix const &transform, unsigned const flags)
{
SPUse const *use = SP_USE(item);
if (use->child && SP_IS_ITEM(use->child)) {
SPItem *child = SP_ITEM(use->child);
- NR::Matrix const ct( child->transform
- * NR::translate(use->x.computed,
- use->y.computed)
+ Geom::Matrix const ct( child->transform
+ * Geom::Translate(use->x.computed,
+ use->y.computed)
* transform );
sp_item_invoke_bbox_full(child, bbox, ct, flags, FALSE);
}
diff --git a/src/splivarot.cpp b/src/splivarot.cpp
index b65e6c239fc55ce97f142c7e8025468ff5b24fa1..f44cba46d60cf7151746ed57e95b099d6a993572 100644 (file)
--- a/src/splivarot.cpp
+++ b/src/splivarot.cpp
@@ -453,7 +453,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb
// to get a correct style attribute for the new path
SPItem* item_source = SP_ITEM(source);
NR::Matrix i2root(sp_item_i2root_affine(item_source));
- sp_item_adjust_stroke(item_source, NR::expansion(i2root));
+ sp_item_adjust_stroke(item_source, i2root.descrim());
sp_item_adjust_pattern(item_source, i2root);
sp_item_adjust_gradient(item_source, i2root);
sp_item_adjust_livepatheffect(item_source, i2root);
@@ -601,13 +601,14 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb
}
static
-void sp_selected_path_outline_add_marker( SPObject *marker_object, Geom::Matrix marker_transform, NR::scale stroke_scale, NR::Matrix transform,
- Inkscape::XML::Node *g_repr, Inkscape::XML::Document *xml_doc, SPDocument * doc )
+void sp_selected_path_outline_add_marker( SPObject *marker_object, Geom::Matrix marker_transform,
+ Geom::Scale stroke_scale, Geom::Matrix transform,
+ Inkscape::XML::Node *g_repr, Inkscape::XML::Document *xml_doc, SPDocument * doc )
{
SPMarker* marker = SP_MARKER (marker_object);
SPItem* marker_item = sp_item_first_item_child (SP_OBJECT (marker_object));
- NR::Matrix tr(marker_transform);
+ Geom::Matrix tr(marker_transform);
if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
tr = stroke_scale * tr;
}
NR::Matrix const transform(item->transform);
- float const scale = NR::expansion(transform);
+ float const scale = transform.descrim();
gchar const *mask = SP_OBJECT_REPR(item)->attribute("mask");
gchar const *clip_path = SP_OBJECT_REPR(item)->attribute("clip-path");
if ( SPObject *marker_obj = shape->marker[SP_MARKER_LOC_START] ) {
Geom::Matrix const m (sp_shape_marker_get_transform_at_start(path_it->front()));
sp_selected_path_outline_add_marker( marker_obj, m,
- NR::scale(i_style->stroke_width.computed), transform,
+ Geom::Scale(i_style->stroke_width.computed), transform,
g_repr, xml_doc, doc );
}
* there should be a midpoint marker between last segment and closing straight line segment
*/
Geom::Matrix const m (sp_shape_marker_get_transform(*curve_it1, *curve_it2));
- sp_selected_path_outline_add_marker( midmarker_obj, m,
- NR::scale(i_style->stroke_width.computed), transform,
- g_repr, xml_doc, doc );
+ sp_selected_path_outline_add_marker(midmarker_obj, m,
+ Geom::Scale(i_style->stroke_width.computed), transform,
+ g_repr, xml_doc, doc);
++curve_it1;
++curve_it2;
Geom::Matrix const m = sp_shape_marker_get_transform_at_end(lastcurve);
sp_selected_path_outline_add_marker( marker_obj, m,
- NR::scale(i_style->stroke_width.computed), transform,
+ Geom::Scale(i_style->stroke_width.computed), transform,
g_repr, xml_doc, doc );
}
}
@@ -1047,7 +1048,7 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat
NR::Matrix const transform(item->transform);
- sp_item_write_transform(item, SP_OBJECT_REPR(item), NR::identity());
+ sp_item_write_transform(item, SP_OBJECT_REPR(item), Geom::identity());
style = g_strdup(SP_OBJECT(item)->repr->attribute("style"));
@@ -1273,7 +1274,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset)
NR::Matrix const transform(item->transform);
- sp_item_write_transform(item, SP_OBJECT_REPR(item), NR::identity());
+ sp_item_write_transform(item, SP_OBJECT_REPR(item), Geom::identity());
gchar *style = g_strdup(SP_OBJECT_REPR(item)->attribute("style"));
this is necessary so that the item is transformed twice back and forth,
allowing all compensations to cancel out regardless of the preferences
*/
- sp_item_write_transform(item, SP_OBJECT_REPR(item), NR::identity());
+ sp_item_write_transform(item, SP_OBJECT_REPR(item), Geom::identity());
gchar *style = g_strdup(SP_OBJECT_REPR(item)->attribute("style"));
gchar *mask = g_strdup(SP_OBJECT_REPR(item)->attribute("mask"));
diff --git a/src/text-context.cpp b/src/text-context.cpp
index 2a804dfbdd2cde68d74e061e399a20ca36676ab9..28384b620631baaba6a629e902f764b1ce92a01a 100644 (file)
--- a/src/text-context.cpp
+++ b/src/text-context.cpp
sp_canvas_item_hide(tc->cursor);
tc->indicator = sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRLRECT, NULL);
- SP_CTRLRECT(tc->indicator)->setRectangle(NR::Rect(NR::Point(0, 0), NR::Point(100, 100)));
+ SP_CTRLRECT(tc->indicator)->setRectangle(Geom::Rect(Geom::Point(0, 0), Geom::Point(100, 100)));
SP_CTRLRECT(tc->indicator)->setColor(0x0000ff7f, false, 0);
sp_canvas_item_hide(tc->indicator);
tc->frame = sp_canvas_item_new(sp_desktop_controls(desktop), SP_TYPE_CTRLRECT, NULL);
- SP_CTRLRECT(tc->frame)->setRectangle(NR::Rect(NR::Point(0, 0), NR::Point(100, 100)));
+ SP_CTRLRECT(tc->frame)->setRectangle(Geom::Rect(Geom::Point(0, 0), Geom::Point(100, 100)));
SP_CTRLRECT(tc->frame)->setColor(0x0000ff7f, false, 0);
sp_canvas_item_hide(tc->frame);
@@ -437,7 +437,7 @@ sp_text_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve
item_ungrouped = desktop->item_at_point(NR::Point(event->button.x, event->button.y), TRUE);
if (SP_IS_TEXT(item_ungrouped) || SP_IS_FLOWTEXT(item_ungrouped)) {
sp_canvas_item_show(tc->indicator);
- boost::optional<NR::Rect> ibbox = sp_item_bbox_desktop(item_ungrouped);
+ boost::optional<Geom::Rect> ibbox = to_2geom(sp_item_bbox_desktop(item_ungrouped));
if (ibbox) {
SP_CTRLRECT(tc->indicator)->setRectangle(*ibbox);
}
@@ -815,8 +815,8 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
int screenlines = 1;
if (tc->text) {
double spacing = sp_te_get_average_linespacing(tc->text);
- NR::Rect const d = desktop->get_display_area();
- screenlines = (int) floor(fabs(d.min()[NR::Y] - d.max()[NR::Y])/spacing) - 1;
+ Geom::Rect const d = desktop->get_display_area();
+ screenlines = (int) floor(fabs(d.min()[Geom::Y] - d.max()[Geom::Y])/spacing) - 1;
if (screenlines <= 0)
screenlines = 1;
}
SPItem *frame = SP_FLOWTEXT(tc->text)->get_frame (NULL); // first frame only
if (frame) {
sp_canvas_item_show(tc->frame);
- boost::optional<NR::Rect> frame_bbox = sp_item_bbox_desktop(frame);
+ boost::optional<Geom::Rect> frame_bbox = to_2geom(sp_item_bbox_desktop(frame));
if (frame_bbox) {
SP_CTRLRECT(tc->frame)->setRectangle(*frame_bbox);
}
diff --git a/src/text-editing.cpp b/src/text-editing.cpp
index 48266cfceca68de38d8208c0d1c2b4b94eb2348c..11b0f0fe491203317bd6a1743e1fcfb08056602a 100644 (file)
--- a/src/text-editing.cpp
+++ b/src/text-editing.cpp
@@ -948,8 +948,8 @@ sp_te_adjust_kerning_screen (SPItem *item, Inkscape::Text::Layout::iterator cons
// divide increment by zoom
// divide increment by matrix expansion
gdouble factor = 1 / desktop->current_zoom();
- NR::Matrix t (sp_item_i2doc_affine(item));
- factor = factor / NR::expansion(t);
+ Geom::Matrix t (sp_item_i2doc_affine(item));
+ factor = factor / t.descrim();
by = factor * by;
unsigned char_index;
@@ -970,8 +970,8 @@ sp_te_adjust_rotation_screen(SPItem *text, Inkscape::Text::Layout::iterator cons
// divide increment by zoom
// divide increment by matrix expansion
gdouble factor = 1 / desktop->current_zoom();
- NR::Matrix t (sp_item_i2doc_affine(text));
- factor = factor / NR::expansion(t);
+ Geom::Matrix t (sp_item_i2doc_affine(text));
+ factor = factor / t.descrim();
Inkscape::Text::Layout const *layout = te_get_layout(text);
if (layout == NULL) return;
SPObject *source_item = 0;
@@ -1055,7 +1055,7 @@ sp_te_adjust_tspan_letterspacing_screen(SPItem *text, Inkscape::Text::Layout::it
gdouble const zoom = desktop->current_zoom();
gdouble const zby = (by
/ (zoom * (nb_let > 1 ? nb_let - 1 : 1))
- / NR::expansion(sp_item_i2doc_affine(SP_ITEM(source_obj))));
+ / to_2geom(sp_item_i2doc_affine(SP_ITEM(source_obj))).descrim());
val += zby;
if (start == end) {
@@ -1127,8 +1127,8 @@ sp_te_adjust_linespacing_screen (SPItem *text, Inkscape::Text::Layout::iterator
gdouble zby = by / (desktop->current_zoom() * (line_count == 0 ? 1 : line_count));
// divide increment by matrix expansion
- NR::Matrix t (sp_item_i2doc_affine (SP_ITEM(text)));
- zby = zby / NR::expansion(t);
+ Geom::Matrix t (sp_item_i2doc_affine (SP_ITEM(text)));
+ zby = zby / t.descrim();
switch (style->line_height.unit) {
case SP_CSS_UNIT_NONE:
diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp
index 9c69811282d67fc31662199de0d7fdb29388426d..56a36aba6e1c7d7cd26b4e0f400361b2492d3541 100644 (file)
--- a/src/tweak-context.cpp
+++ b/src/tweak-context.cpp
@@ -384,9 +384,9 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, NR::Poi
Shape *theShape = new Shape;
Shape *theRes = new Shape;
- NR::Matrix i2doc(sp_item_i2doc_affine(item));
+ Geom::Matrix i2doc(sp_item_i2doc_affine(item));
- orig->ConvertWithBackData((0.08 - (0.07 * fidelity)) / NR::expansion(i2doc)); // default 0.059
+ orig->ConvertWithBackData((0.08 - (0.07 * fidelity)) / i2doc.descrim()); // default 0.059
orig->Fill(theShape, 0);
SPCSSAttr *css = sp_repr_css_attr(SP_OBJECT_REPR(item), "style");
@@ -441,7 +441,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, NR::Poi
res->Reset();
theRes->ConvertToForme(res);
- double th_max = (0.6 - 0.59*sqrt(fidelity)) / NR::expansion(i2doc);
+ double th_max = (0.6 - 0.59*sqrt(fidelity)) / i2doc.descrim();
double threshold = MAX(th_max, th_max*force);
res->ConvertEvenLines(threshold);
res->Simplify(threshold / (selection->desktop()->current_zoom()));
index 423d8e82060d908cd79f8a22aa2377a43e6a6c94..bd6c5032cc34676a3db037baf1aa37329d8c125a 100644 (file)
//Geom::Point gridorigin = _namedview->gridorigin;
/// \todo Why was the origin corrected for the grid origin? (johan)
- Geom::Rect const viewbox = to_2geom(_svg_canvas.spobj()->getViewbox());
+ Geom::Rect const viewbox = _svg_canvas.spobj()->getViewbox();
double lo, up, pos, max;
double const scale = _desktop->current_zoom();
double s = viewbox.min()[Geom::X] / scale; //- gridorigin[Geom::X];
NR::Rect carea( Geom::Point(darea.min()[Geom::X] * scale - 64, darea.max()[Geom::Y] * -scale - 64),
Geom::Point(darea.max()[Geom::X] * scale + 64, darea.min()[Geom::Y] * -scale + 64) );
- NR::Rect const viewbox = _svg_canvas.spobj()->getViewbox();
+ Geom::Rect const viewbox = _svg_canvas.spobj()->getViewbox();
/* Viewbox is always included into scrollable region */
- carea = NR::union_bounds(carea, viewbox);
+ carea = NR::union_bounds(carea, from_2geom(viewbox));
Gtk::Adjustment *adj = _bottom_scrollbar.get_adjustment();
adj->set_value(viewbox.min()[Geom::X]);
return;
}
- Geom::Rect const area = to_2geom(_desktop->get_display_area());
+ Geom::Rect const area = _desktop->get_display_area();
double zoom = _desktop->current_zoom();
if (_sticky_zoom.get_active()) {
/* Calculate zoom per pixel */
double const zpsp = zoom / hypot(area.dimensions()[Geom::X], area.dimensions()[Geom::Y]);
/* Find new visible area */
- Geom::Rect const newarea = to_2geom(_desktop->get_display_area());
+ Geom::Rect const newarea = _desktop->get_display_area();
/* Calculate adjusted zoom */
zoom = zpsp * hypot(newarea.dimensions()[Geom::X], newarea.dimensions()[Geom::Y]);
}
index fbe7c06421ca5b0079f1e58d1c22e751b86a295c..7c1cf72d7db5f3ba9319dd99fe7bb53c10351def 100644 (file)
_upd_f = true;
g_assert(_dt);
double zoom_factor = pow(2, get_value());
- Geom::Rect const d = to_2geom(_dt->get_display_area());
+ Geom::Rect const d = _dt->get_display_area();
_dt->zoom_absolute(d.midpoint()[Geom::X], d.midpoint()[Geom::Y], zoom_factor);
gtk_widget_grab_focus(static_cast<GtkWidget*>((void*)_dt->canvas)); /// \todo this no love song
_upd_f = false;
diff --git a/src/verbs.cpp b/src/verbs.cpp
index be5acbd047b0af49760c5f28f0c07f593b5a05a2..71ec33b3f62e423f13bc34c7675210cb2f4c5185 100644 (file)
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
}
}
- NR::Rect const d = dt->get_display_area();
- dt->zoom_relative( d.midpoint()[NR::X], d.midpoint()[NR::Y], mul*zoom_inc);
+ Geom::Rect const d = dt->get_display_area();
+ dt->zoom_relative( d.midpoint()[Geom::X], d.midpoint()[Geom::Y], mul*zoom_inc);
break;
}
case SP_VERB_ZOOM_OUT:
}
}
- NR::Rect const d = dt->get_display_area();
- dt->zoom_relative( d.midpoint()[NR::X], d.midpoint()[NR::Y], 1 / (mul*zoom_inc) );
+ Geom::Rect const d = dt->get_display_area();
+ dt->zoom_relative( d.midpoint()[Geom::X], d.midpoint()[Geom::Y], 1 / (mul*zoom_inc) );
break;
}
case SP_VERB_ZOOM_1_1:
{
double zcorr = prefs_get_double_attribute ("options.zoomcorrection", "value", 1.0);
- NR::Rect const d = dt->get_display_area();
- dt->zoom_absolute( d.midpoint()[NR::X], d.midpoint()[NR::Y], 1.0 * zcorr );
+ Geom::Rect const d = dt->get_display_area();
+ dt->zoom_absolute( d.midpoint()[Geom::X], d.midpoint()[Geom::Y], 1.0 * zcorr );
break;
}
case SP_VERB_ZOOM_1_2:
{
double zcorr = prefs_get_double_attribute ("options.zoomcorrection", "value", 1.0);
- NR::Rect const d = dt->get_display_area();
- dt->zoom_absolute( d.midpoint()[NR::X], d.midpoint()[NR::Y], 0.5 * zcorr );
+ Geom::Rect const d = dt->get_display_area();
+ dt->zoom_absolute( d.midpoint()[Geom::X], d.midpoint()[Geom::Y], 0.5 * zcorr );
break;
}
case SP_VERB_ZOOM_2_1:
{
double zcorr = prefs_get_double_attribute ("options.zoomcorrection", "value", 1.0);
- NR::Rect const d = dt->get_display_area();
- dt->zoom_absolute( d.midpoint()[NR::X], d.midpoint()[NR::Y], 2.0 * zcorr );
+ Geom::Rect const d = dt->get_display_area();
+ dt->zoom_absolute( d.midpoint()[Geom::X], d.midpoint()[Geom::Y], 2.0 * zcorr );
break;
}
case SP_VERB_ZOOM_PAGE:
index c182fe0174896b38a507ee01ed72f313902a883e..8f7d56c768400f7cc7b9e276571826cce44be20d 100644 (file)
}
if (GTK_WIDGET_REALIZED (widget)) {
- Geom::Rect const area = to_2geom(dtw->desktop->get_display_area());
+ Geom::Rect const area = dtw->desktop->get_display_area();
double zoom = dtw->desktop->current_zoom();
if (GTK_WIDGET_CLASS(dtw_parent_class)->size_allocate) {
/* Calculate zoom per pixel */
double const zpsp = zoom / hypot (area.dimensions()[Geom::X], area.dimensions()[Geom::Y]);
/* Find new visible area */
- Geom::Rect newarea = to_2geom(dtw->desktop->get_display_area());
+ Geom::Rect newarea = dtw->desktop->get_display_area();
/* Calculate adjusted zoom */
zoom = zpsp * hypot(newarea.dimensions()[Geom::X], newarea.dimensions()[Geom::Y]);
dtw->desktop->zoom_absolute(newarea.midpoint()[Geom::X], newarea.midpoint()[Geom::Y], zoom);
SPDesktopWidget *dtw = SP_DESKTOP_WIDGET (data);
SPDesktop *desktop = dtw->desktop;
- Geom::Rect const d = to_2geom(desktop->get_display_area());
+ Geom::Rect const d = desktop->get_display_area();
g_signal_handler_block (spin, dtw->zoom_update);
desktop->zoom_absolute (d.midpoint()[Geom::X], d.midpoint()[Geom::Y], zoom_factor);
g_signal_handler_unblock (spin, dtw->zoom_update);
@@ -1558,7 +1558,7 @@ sp_dtw_zoom_populate_popup (GtkEntry */*entry*/, GtkMenu *menu, gpointer data)
static void
sp_dtw_zoom_menu_handler (SPDesktop *dt, gdouble factor)
{
- Geom::Rect const d = to_2geom(dt->get_display_area());
+ Geom::Rect const d = dt->get_display_area();
dt->zoom_absolute(d.midpoint()[Geom::X], d.midpoint()[Geom::Y], factor);
}
Geom::Point(darea.max()[Geom::X] * scale + 64,
darea.min()[Geom::Y] * -scale + 64));
- NR::Rect viewbox = dtw->canvas->getViewbox();
+ Geom::Rect viewbox = dtw->canvas->getViewbox();
/* Viewbox is always included into scrollable region */
- carea = NR::union_bounds(carea, viewbox);
+ carea = NR::union_bounds(carea, from_2geom(viewbox));
set_adjustment(dtw->hadj, carea.min()[Geom::X], carea.max()[Geom::X],
viewbox.dimensions()[Geom::X],
index 577efe7c15b1aee1631be7382c2611129cf052a5..49a35b5cb797209087cba3534f337673348b67d5 100644 (file)
font_instance *tface = fprev->rfont->daddy;
- double theSize = NR::expansion(fprev->rfont->style.transform);
+ double theSize = fprev->rfont->style.transform.descrim();
gchar const *p;
if (fprev->phrase) {
index c21a327485e9902cb58c079742248070bf757c81..aa0593f857c9a517ac00e4256300d3f5e0cbd960 100644 (file)
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
GSList *items = get_avoided_items(NULL, desktop->currentRoot(), desktop);
for ( GSList const *iter = items ; iter != NULL ; iter = iter->next ) {
SPItem *item = reinterpret_cast<SPItem *>(iter->data);
- NR::Matrix m = NR::identity();
- avoid_item_move(&m, item);
+ Geom::Matrix m = Geom::identity();
+ NR::Matrix m_NR = from_2geom(m);
+ avoid_item_move(&m_NR, item);
}
if (items) {
diff --git a/src/zoom-context.cpp b/src/zoom-context.cpp
index 8c6400189a59816420aa5fb9bb6c4952d286bf1b..1d14d20cd2e039e3dbb4afc06e549106bdf104c1 100644 (file)
--- a/src/zoom-context.cpp
+++ b/src/zoom-context.cpp
@@ -174,7 +174,7 @@ static gint sp_zoom_context_root_handler(SPEventContext *event_context, GdkEvent
NR::Point const button_w(event->button.x, event->button.y);
NR::Point const button_dt(desktop->w2d(button_w));
if ( event->button.button == 1 && !event_context->space_panning) {
- boost::optional<NR::Rect> const b = Inkscape::Rubberband::get(desktop)->getRectangle();
+ boost::optional<Geom::Rect> const b = Inkscape::Rubberband::get(desktop)->getRectangle();
if (b && !within_tolerance) {
desktop->set_display_area(*b, 10);
} else if (!escaped) {