summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6b76ef6)
raw | patch | inline | side by side (parent: 6b76ef6)
author | cilix42 <cilix42@users.sourceforge.net> | |
Thu, 18 Sep 2008 21:10:10 +0000 (21:10 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Thu, 18 Sep 2008 21:10:10 +0000 (21:10 +0000) |
diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp
index f839b69461aede4fc32fa575cc58d704afc8eba4..726341dedef6a6b312e9692e6e315fdfdf7eff62 100644 (file)
--- a/src/desktop-events.cpp
+++ b/src/desktop-events.cpp
Inkscape::XML::Node *repr = SP_OBJECT_REPR(desktop->namedview);
gdk_window_get_pointer(GTK_WIDGET(dtw->canvas)->window, &wx, &wy, NULL);
- NR::Point const event_win(wx, wy);
+ Geom::Point const event_win(wx, wy);
gint width, height;
gdk_window_get_geometry(GTK_WIDGET(dtw->canvas)->window, NULL /*x*/, NULL /*y*/, &width, &height, NULL/*depth*/);
case GDK_BUTTON_PRESS:
if (event->button.button == 1) {
dragging = true;
- NR::Point const event_w(sp_canvas_window_to_world(dtw->canvas, event_win));
- NR::Point const event_dt(desktop->w2d(event_w));
+ Geom::Point const event_w(sp_canvas_window_to_world(dtw->canvas, event_win));
+ Geom::Point const event_dt(desktop->w2d(event_w));
// explicitly show guidelines; if I draw a guide, I want them on
sp_repr_set_boolean(repr, "showguides", TRUE);
@@ -139,7 +139,7 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge
break;
case GDK_MOTION_NOTIFY:
if (dragging) {
- NR::Point const event_w(sp_canvas_window_to_world(dtw->canvas, event_win));
+ Geom::Point const event_w(sp_canvas_window_to_world(dtw->canvas, event_win));
Geom::Point event_dt(desktop->w2d(event_w));
SnapManager &m = desktop->namedview->snap_manager;
@@ -154,7 +154,7 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge
case GDK_BUTTON_RELEASE:
if (dragging && event->button.button == 1) {
gdk_pointer_ungrab(event->button.time);
- NR::Point const event_w(sp_canvas_window_to_world(dtw->canvas, event_win));
+ Geom::Point const event_w(sp_canvas_window_to_world(dtw->canvas, event_win));
Geom::Point event_dt(desktop->w2d(event_w));
SnapManager &m = desktop->namedview->snap_manager;
case GDK_BUTTON_RELEASE:
if (dragging && event->button.button == 1) {
if (moved) {
- NR::Point const event_w(event->button.x,
- event->button.y);
+ Geom::Point const event_w(event->button.x,
+ event->button.y);
Geom::Point event_dt(desktop->w2d(event_w));
SnapManager &m = desktop->namedview->snap_manager;
diff --git a/src/dialogs/export.cpp b/src/dialogs/export.cpp
index 382e956efbd6bdb9934f1195c6e100ddbe19e6a1..5e23f0656f2613eb2562796a2cd34376bd3b3f9d 100644 (file)
--- a/src/dialogs/export.cpp
+++ b/src/dialogs/export.cpp
if ( SP_ACTIVE_DESKTOP ) {
SPDocument *doc;
doc = sp_desktop_document (SP_ACTIVE_DESKTOP);
- boost::optional<NR::Rect> bbox = sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc)));
+ boost::optional<Geom::Rect> bbox = to_2geom(sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc))));
if (bbox) {
- sp_export_set_area (base, bbox->min()[NR::X],
- bbox->min()[NR::Y],
- bbox->max()[NR::X],
- bbox->max()[NR::Y]);
+ sp_export_set_area (base, bbox->min()[Geom::X],
+ bbox->min()[Geom::Y],
+ bbox->max()[Geom::X],
+ bbox->max()[Geom::Y]);
}
}
break;
if ( SP_ACTIVE_DESKTOP )
{
SPDocument *doc;
- boost::optional<NR::Rect> bbox;
+ boost::optional<Geom::Rect> bbox;
doc = sp_desktop_document (SP_ACTIVE_DESKTOP);
/* Notice how the switch is used to 'fall through' here to get
case SELECTION_SELECTION:
if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false)
{
- bbox = (sp_desktop_selection (SP_ACTIVE_DESKTOP))->bounds();
+ bbox = to_2geom((sp_desktop_selection (SP_ACTIVE_DESKTOP))->bounds());
/* Only if there is a selection that we can set
do we break, otherwise we fall through to the
drawing */
/** \todo
* This returns wrong values if the document has a viewBox.
*/
- bbox = sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc)));
+ bbox = to_2geom(sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc))));
/* If the drawing is valid, then we'll use it and break
otherwise we drop through to the page settings */
if (bbox) {
break;
}
case SELECTION_PAGE:
- bbox = NR::Rect(NR::Point(0.0, 0.0),
- NR::Point(sp_document_width(doc), sp_document_height(doc))
- );
+ bbox = Geom::Rect(Geom::Point(0.0, 0.0),
+ Geom::Point(sp_document_width(doc), sp_document_height(doc)));
// std::cout << "Using selection: PAGE" << std::endl;
key = SELECTION_PAGE;
prefs->setString("dialogs.export.exportarea", "value", selection_names[key]);
if ( key != SELECTION_CUSTOM && bbox ) {
- sp_export_set_area (base, bbox->min()[NR::X],
- bbox->min()[NR::Y],
- bbox->max()[NR::X],
- bbox->max()[NR::Y]);
+ sp_export_set_area (base, bbox->min()[Geom::X],
+ bbox->min()[Geom::Y],
+ bbox->max()[Geom::X],
+ bbox->max()[Geom::Y]);
}
} // end of if ( SP_ACTIVE_DESKTOP )
// TODO: Move this to nr-rect-fns.h.
static bool
-sp_export_bbox_equal(NR::Rect const &one, NR::Rect const &two)
+sp_export_bbox_equal(Geom::Rect const &one, Geom::Rect const &two)
{
double const epsilon = pow(10.0, -EXPORT_COORD_PRECISION);
return (
- (fabs(one.min()[NR::X] - two.min()[NR::X]) < epsilon) &&
- (fabs(one.min()[NR::Y] - two.min()[NR::Y]) < epsilon) &&
- (fabs(one.max()[NR::X] - two.max()[NR::X]) < epsilon) &&
- (fabs(one.max()[NR::Y] - two.max()[NR::Y]) < epsilon)
+ (fabs(one.min()[Geom::X] - two.min()[Geom::X]) < epsilon) &&
+ (fabs(one.min()[Geom::Y] - two.min()[Geom::Y]) < epsilon) &&
+ (fabs(one.max()[Geom::X] - two.max()[Geom::X]) < epsilon) &&
+ (fabs(one.max()[Geom::Y] - two.max()[Geom::Y]) < epsilon)
);
}
selection_type this_test[SELECTION_NUMBER_OF + 1];
selection_type key = SELECTION_NUMBER_OF;
- NR::Point x(sp_export_value_get_px (base, "x0"),
- sp_export_value_get_px (base, "y0"));
- NR::Point y(sp_export_value_get_px (base, "x1"),
- sp_export_value_get_px (base, "y1"));
- NR::Rect current_bbox(x, y);
+ Geom::Point x(sp_export_value_get_px (base, "x0"),
+ sp_export_value_get_px (base, "y0"));
+ Geom::Point y(sp_export_value_get_px (base, "x1"),
+ sp_export_value_get_px (base, "y1"));
+ Geom::Rect current_bbox(x, y);
//std::cout << "Current " << current_bbox;
this_test[0] = (selection_type)(GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(base), "selection-type")));
switch (this_test[i]) {
case SELECTION_SELECTION:
if ((sp_desktop_selection(SP_ACTIVE_DESKTOP))->isEmpty() == false) {
- boost::optional<NR::Rect> bbox = (sp_desktop_selection (SP_ACTIVE_DESKTOP))->bounds();
+ boost::optional<Geom::Rect> bbox = to_2geom((sp_desktop_selection (SP_ACTIVE_DESKTOP))->bounds());
//std::cout << "Selection " << bbox;
if ( bbox && sp_export_bbox_equal(*bbox,current_bbox)) {
case SELECTION_DRAWING: {
SPDocument *doc = sp_desktop_document (SP_ACTIVE_DESKTOP);
- boost::optional<NR::Rect> bbox = sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc)));
+ boost::optional<Geom::Rect> bbox = to_2geom(sp_item_bbox_desktop (SP_ITEM (SP_DOCUMENT_ROOT (doc))));
// std::cout << "Drawing " << bbox2;
if ( bbox && sp_export_bbox_equal(*bbox,current_bbox) ) {
doc = sp_desktop_document (SP_ACTIVE_DESKTOP);
- NR::Point x(0.0, 0.0);
- NR::Point y(sp_document_width(doc),
- sp_document_height(doc));
- NR::Rect bbox(x, y);
+ Geom::Point x(0.0, 0.0);
+ Geom::Point y(sp_document_width(doc),
+ sp_document_height(doc));
+ Geom::Rect bbox(x, y);
// std::cout << "Page " << bbox;
if (sp_export_bbox_equal(bbox,current_bbox)) {
index 63732df0bcca4618105cca08b084663d9eb4dd30..e1287f0516ee2f3378225357274043002aa86472 100644 (file)
#include <glibmm/i18n.h>
#include <gtkmm/stock.h>
-#include "libnr/nr-matrix-ops.h"
#include "verbs.h"
#include "prefs-utils.h"
#include "inkscape.h"
int
sp_compare_x_position(SPItem *first, SPItem *second)
{
- using NR::X;
- using NR::Y;
+ using Geom::X;
+ using Geom::Y;
- boost::optional<NR::Rect> a = first->getBounds(sp_item_i2doc_affine(first));
- boost::optional<NR::Rect> b = second->getBounds(sp_item_i2doc_affine(second));
+ boost::optional<Geom::Rect> a = to_2geom(first->getBounds(sp_item_i2doc_affine(first)));
+ boost::optional<Geom::Rect> b = to_2geom(second->getBounds(sp_item_i2doc_affine(second)));
if ( !a || !b ) {
// FIXME?
int
sp_compare_y_position(SPItem *first, SPItem *second)
{
- boost::optional<NR::Rect> a = first->getBounds(sp_item_i2doc_affine(first));
- boost::optional<NR::Rect> b = second->getBounds(sp_item_i2doc_affine(second));
+ boost::optional<Geom::Rect> a = to_2geom(first->getBounds(sp_item_i2doc_affine(first)));
+ boost::optional<Geom::Rect> b = to_2geom(second->getBounds(sp_item_i2doc_affine(second)));
if ( !a || !b ) {
// FIXME?
return 0;
}
- if (a->min()[NR::Y] > b->min()[NR::Y]) {
+ if (a->min()[Geom::Y] > b->min()[Geom::Y]) {
return 1;
}
- if (a->min()[NR::Y] < b->min()[NR::Y]) {
+ if (a->min()[Geom::Y] < b->min()[Geom::Y]) {
return -1;
}
cnt=0;
for (; items != NULL; items = items->next) {
SPItem *item = SP_ITEM(items->data);
- boost::optional<NR::Rect> b = item->getBounds(sp_item_i2doc_affine(item));
+ boost::optional<Geom::Rect> b = to_2geom(item->getBounds(sp_item_i2doc_affine(item)));
if (!b) {
continue;
}
- width = b->dimensions()[NR::X];
- height = b->dimensions()[NR::Y];
+ width = b->dimensions()[Geom::X];
+ height = b->dimensions()[Geom::Y];
- cx = b->midpoint()[NR::X];
- cy = b->midpoint()[NR::Y];
+ cx = b->midpoint()[Geom::X];
+ cy = b->midpoint()[Geom::Y];
- if (b->min()[NR::X] < grid_left) {
- grid_left = b->min()[NR::X];
+ if (b->min()[Geom::X] < grid_left) {
+ grid_left = b->min()[Geom::X];
}
- if (b->min()[NR::Y] < grid_top) {
- grid_top = b->min()[NR::Y];
+ if (b->min()[Geom::Y] < grid_top) {
+ grid_top = b->min()[Geom::Y];
}
if (width > col_width) {
col_width = width;
const GSList *sizes = sorted;
for (; sizes != NULL; sizes = sizes->next) {
SPItem *item = SP_ITEM(sizes->data);
- boost::optional<NR::Rect> b = item->getBounds(sp_item_i2doc_affine(item));
+ boost::optional<Geom::Rect> b = to_2geom(item->getBounds(sp_item_i2doc_affine(item)));
if (b) {
- width = b->dimensions()[NR::X];
- height = b->dimensions()[NR::Y];
+ width = b->dimensions()[Geom::X];
+ height = b->dimensions()[Geom::Y];
if (width > col_widths[(cnt % NoOfCols)]) {
col_widths[(cnt % NoOfCols)] = width;
}
}
- boost::optional<NR::Rect> sel_bbox = selection->bounds();
+ boost::optional<Geom::Rect> sel_bbox = to_2geom(selection->bounds());
// Fit to bbox, calculate padding between rows accordingly.
if ( sel_bbox && !SpaceManualRadioButton.get_active() ){
#ifdef DEBUG_GRID_ARRANGE
-g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_height,total_col_width, b.extent(NR::X), b.extent(NR::Y));
+g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_height,total_col_width, b.extent(Geom::X), b.extent(Geom::Y));
#endif
- paddingx = (sel_bbox->extent(NR::X) - total_col_width) / (NoOfCols -1);
- paddingy = (sel_bbox->extent(NR::Y) - total_row_height) / (NoOfRows -1);
+ paddingx = (sel_bbox->width() - total_col_width) / (NoOfCols -1);
+ paddingy = (sel_bbox->height() - total_row_height) / (NoOfRows -1);
}
/*
for (; current_row != NULL; current_row = current_row->next) {
SPItem *item=SP_ITEM(current_row->data);
Inkscape::XML::Node *repr = SP_OBJECT_REPR(item);
- boost::optional<NR::Rect> b = item->getBounds(sp_item_i2doc_affine(item));
- NR::Point min;
+ boost::optional<Geom::Rect> b = to_2geom(item->getBounds(sp_item_i2doc_affine(item)));
+ Geom::Point min;
if (b) {
- width = b->dimensions()[NR::X];
- height = b->dimensions()[NR::Y];
+ width = b->dimensions()[Geom::X];
+ height = b->dimensions()[Geom::Y];
min = b->min();
} else {
width = height = 0;
- min = NR::Point(0, 0);
+ min = Geom::Point(0, 0);
}
row = cnt / NoOfCols;
new_y = grid_top + (((row_heights[row] - height)/2)*VertAlign) + row_ys[row];
// signs are inverted between x and y due to y inversion
- NR::Point move = NR::Point(new_x - min[NR::X], min[NR::Y] - new_y);
+ Geom::Point move = Geom::Point(new_x - min[Geom::X], min[Geom::Y] - new_y);
Geom::Matrix const affine = Geom::Matrix(Geom::Translate(move));
sp_item_set_i2d_affine(item, sp_item_i2d_affine(item) * affine);
sp_item_write_transform(item, repr, item->transform, NULL);
index 77c18aa64c91cf751b5ac439c1f87bb50d8acfae..9e4fce1e7770f7c66a264855fade9d639e4a939c 100644 (file)
--- a/src/dialogs/unclump.cpp
+++ b/src/dialogs/unclump.cpp
// cache the centers, widths, and heights of items
//FIXME: make a class with these cashes as members instead of globals
-std::map<const gchar *, NR::Point> c_cache;
-std::map<const gchar *, NR::Point> wh_cache;
+std::map<const gchar *, Geom::Point> c_cache;
+std::map<const gchar *, Geom::Point> wh_cache;
/**
Center of bbox of item
*/
-NR::Point
+Geom::Point
unclump_center (SPItem *item)
{
- std::map<const gchar *, NR::Point>::iterator i = c_cache.find(SP_OBJECT_ID(item));
+ std::map<const gchar *, Geom::Point>::iterator i = c_cache.find(SP_OBJECT_ID(item));
if ( i != c_cache.end() ) {
return i->second;
}
- boost::optional<NR::Rect> r = item->getBounds(sp_item_i2d_affine(item));
+ boost::optional<Geom::Rect> r = to_2geom(item->getBounds(sp_item_i2d_affine(item)));
if (r) {
- NR::Point const c = r->midpoint();
+ Geom::Point const c = r->midpoint();
c_cache[SP_OBJECT_ID(item)] = c;
return c;
} else {
// FIXME
- return NR::Point(0, 0);
+ return Geom::Point(0, 0);
}
}
-NR::Point
+Geom::Point
unclump_wh (SPItem *item)
{
- NR::Point wh;
- std::map<const gchar *, NR::Point>::iterator i = wh_cache.find(SP_OBJECT_ID(item));
+ Geom::Point wh;
+ std::map<const gchar *, Geom::Point>::iterator i = wh_cache.find(SP_OBJECT_ID(item));
if ( i != wh_cache.end() ) {
wh = i->second;
} else {
- boost::optional<NR::Rect> r = item->getBounds(sp_item_i2d_affine(item));
+ boost::optional<Geom::Rect> r = to_2geom(item->getBounds(sp_item_i2d_affine(item)));
if (r) {
wh = r->dimensions();
wh_cache[SP_OBJECT_ID(item)] = wh;
} else {
- wh = NR::Point(0, 0);
+ wh = Geom::Point(0, 0);
}
}
@@ -74,30 +74,30 @@ May be negative if the edge of item1 is between the center and the edge of item2
double
unclump_dist (SPItem *item1, SPItem *item2)
{
- NR::Point c1 = unclump_center (item1);
- NR::Point c2 = unclump_center (item2);
+ Geom::Point c1 = unclump_center (item1);
+ Geom::Point c2 = unclump_center (item2);
- NR::Point wh1 = unclump_wh (item1);
- NR::Point wh2 = unclump_wh (item2);
+ Geom::Point wh1 = unclump_wh (item1);
+ Geom::Point wh2 = unclump_wh (item2);
// angle from each item's center to the other's, unsqueezed by its w/h, normalized to 0..pi/2
- double a1 = atan2 ((c2 - c1)[NR::Y], (c2 - c1)[NR::X] * wh1[NR::Y]/wh1[NR::X]);
+ double a1 = atan2 ((c2 - c1)[Geom::Y], (c2 - c1)[Geom::X] * wh1[Geom::Y]/wh1[Geom::X]);
a1 = fabs (a1);
if (a1 > M_PI/2) a1 = M_PI - a1;
- double a2 = atan2 ((c1 - c2)[NR::Y], (c1 - c2)[NR::X] * wh2[NR::Y]/wh2[NR::X]);
+ double a2 = atan2 ((c1 - c2)[Geom::Y], (c1 - c2)[Geom::X] * wh2[Geom::Y]/wh2[Geom::X]);
a2 = fabs (a2);
if (a2 > M_PI/2) a2 = M_PI - a2;
// get the radius of each item for the given angle
- double r1 = 0.5 * (wh1[NR::X] + (wh1[NR::Y] - wh1[NR::X]) * (a1/(M_PI/2)));
- double r2 = 0.5 * (wh2[NR::X] + (wh2[NR::Y] - wh2[NR::X]) * (a2/(M_PI/2)));
+ double r1 = 0.5 * (wh1[Geom::X] + (wh1[Geom::Y] - wh1[Geom::X]) * (a1/(M_PI/2)));
+ double r2 = 0.5 * (wh2[Geom::X] + (wh2[Geom::Y] - wh2[Geom::X]) * (a2/(M_PI/2)));
// dist between centers minus angle-adjusted radii
- double dist_r = (NR::L2 (c2 - c1) - r1 - r2);
+ double dist_r = (Geom::L2 (c2 - c1) - r1 - r2);
- double stretch1 = wh1[NR::Y]/wh1[NR::X];
- double stretch2 = wh2[NR::Y]/wh2[NR::X];
+ double stretch1 = wh1[Geom::Y]/wh1[Geom::X];
+ double stretch2 = wh2[Geom::Y]/wh2[Geom::X];
if ((stretch1 > 1.5 || stretch1 < 0.66) && (stretch2 > 1.5 || stretch2 < 0.66)) {
dists.push_back (dist_r);
// If both objects are not circle-like, find dists between four corners
- std::vector<NR::Point> c1_points(2);
+ std::vector<Geom::Point> c1_points(2);
{
double y_closest;
- if (c2[NR::Y] > c1[NR::Y] + wh1[NR::Y]/2) {
- y_closest = c1[NR::Y] + wh1[NR::Y]/2;
- } else if (c2[NR::Y] < c1[NR::Y] - wh1[NR::Y]/2) {
- y_closest = c1[NR::Y] - wh1[NR::Y]/2;
+ if (c2[Geom::Y] > c1[Geom::Y] + wh1[Geom::Y]/2) {
+ y_closest = c1[Geom::Y] + wh1[Geom::Y]/2;
+ } else if (c2[Geom::Y] < c1[Geom::Y] - wh1[Geom::Y]/2) {
+ y_closest = c1[Geom::Y] - wh1[Geom::Y]/2;
} else {
- y_closest = c2[NR::Y];
+ y_closest = c2[Geom::Y];
}
- c1_points[0] = NR::Point (c1[NR::X], y_closest);
+ c1_points[0] = Geom::Point (c1[Geom::X], y_closest);
double x_closest;
- if (c2[NR::X] > c1[NR::X] + wh1[NR::X]/2) {
- x_closest = c1[NR::X] + wh1[NR::X]/2;
- } else if (c2[NR::X] < c1[NR::X] - wh1[NR::X]/2) {
- x_closest = c1[NR::X] - wh1[NR::X]/2;
+ if (c2[Geom::X] > c1[Geom::X] + wh1[Geom::X]/2) {
+ x_closest = c1[Geom::X] + wh1[Geom::X]/2;
+ } else if (c2[Geom::X] < c1[Geom::X] - wh1[Geom::X]/2) {
+ x_closest = c1[Geom::X] - wh1[Geom::X]/2;
} else {
- x_closest = c2[NR::X];
+ x_closest = c2[Geom::X];
}
- c1_points[1] = NR::Point (x_closest, c1[NR::Y]);
+ c1_points[1] = Geom::Point (x_closest, c1[Geom::Y]);
}
- std::vector<NR::Point> c2_points(2);
+ std::vector<Geom::Point> c2_points(2);
{
double y_closest;
- if (c1[NR::Y] > c2[NR::Y] + wh2[NR::Y]/2) {
- y_closest = c2[NR::Y] + wh2[NR::Y]/2;
- } else if (c1[NR::Y] < c2[NR::Y] - wh2[NR::Y]/2) {
- y_closest = c2[NR::Y] - wh2[NR::Y]/2;
+ if (c1[Geom::Y] > c2[Geom::Y] + wh2[Geom::Y]/2) {
+ y_closest = c2[Geom::Y] + wh2[Geom::Y]/2;
+ } else if (c1[Geom::Y] < c2[Geom::Y] - wh2[Geom::Y]/2) {
+ y_closest = c2[Geom::Y] - wh2[Geom::Y]/2;
} else {
- y_closest = c1[NR::Y];
+ y_closest = c1[Geom::Y];
}
- c2_points[0] = NR::Point (c2[NR::X], y_closest);
+ c2_points[0] = Geom::Point (c2[Geom::X], y_closest);
double x_closest;
- if (c1[NR::X] > c2[NR::X] + wh2[NR::X]/2) {
- x_closest = c2[NR::X] + wh2[NR::X]/2;
- } else if (c1[NR::X] < c2[NR::X] - wh2[NR::X]/2) {
- x_closest = c2[NR::X] - wh2[NR::X]/2;
+ if (c1[Geom::X] > c2[Geom::X] + wh2[Geom::X]/2) {
+ x_closest = c2[Geom::X] + wh2[Geom::X]/2;
+ } else if (c1[Geom::X] < c2[Geom::X] - wh2[Geom::X]/2) {
+ x_closest = c2[Geom::X] - wh2[Geom::X]/2;
} else {
- x_closest = c1[NR::X];
+ x_closest = c1[Geom::X];
}
- c2_points[1] = NR::Point (x_closest, c2[NR::Y]);
+ c2_points[1] = Geom::Point (x_closest, c2[Geom::Y]);
}
for (int i = 0; i < 2; i ++) {
for (int j = 0; j < 2; j ++) {
- dists.push_back (NR::L2 (c1_points[i] - c2_points[j]));
+ dists.push_back (Geom::L2 (c1_points[i] - c2_points[j]));
}
}
GSList *
unclump_remove_behind (SPItem *item, SPItem *closest, GSList *rest)
{
- NR::Point it = unclump_center (item);
- NR::Point p1 = unclump_center (closest);
+ Geom::Point it = unclump_center (item);
+ Geom::Point p1 = unclump_center (closest);
// perpendicular through closest to the direction to item:
- NR::Point perp = NR::rot90(it - p1);
- NR::Point p2 = p1 + perp;
+ Geom::Point perp = Geom::rot90(it - p1);
+ Geom::Point p2 = p1 + perp;
// get the standard Ax + By + C = 0 form for p1-p2:
- double A = p1[NR::Y] - p2[NR::Y];
- double B = p2[NR::X] - p1[NR::X];
- double C = p2[NR::Y] * p1[NR::X] - p1[NR::Y] * p2[NR::X];
+ double A = p1[Geom::Y] - p2[Geom::Y];
+ double B = p2[Geom::X] - p1[Geom::X];
+ double C = p2[Geom::Y] * p1[Geom::X] - p1[Geom::Y] * p2[Geom::X];
// substitute the item into it:
- double val_item = A * it[NR::X] + B * it[NR::Y] + C;
+ double val_item = A * it[Geom::X] + B * it[Geom::Y] + C;
GSList *out = NULL;
if (other == item)
continue;
- NR::Point o = unclump_center (other);
- double val_other = A * o[NR::X] + B * o[NR::Y] + C;
+ Geom::Point o = unclump_center (other);
+ double val_other = A * o[Geom::X] + B * o[Geom::Y] + C;
if (val_item * val_other <= 1e-6) {
// different signs, which means item and other are on the different sides of p1-p2 line; skip
void
unclump_push (SPItem *from, SPItem *what, double dist)
{
- NR::Point it = unclump_center (what);
- NR::Point p = unclump_center (from);
- NR::Point by = dist * NR::unit_vector (- (p - it));
+ Geom::Point it = unclump_center (what);
+ Geom::Point p = unclump_center (from);
+ Geom::Point by = dist * Geom::unit_vector (- (p - it));
Geom::Matrix move = Geom::Translate (by);
- std::map<const gchar *, NR::Point>::iterator i = c_cache.find(SP_OBJECT_ID(what));
+ std::map<const gchar *, Geom::Point>::iterator i = c_cache.find(SP_OBJECT_ID(what));
if ( i != c_cache.end() ) {
i->second *= move;
}
- //g_print ("push %s at %g,%g from %g,%g by %g,%g, dist %g\n", SP_OBJECT_ID(what), it[NR::X],it[NR::Y], p[NR::X],p[NR::Y], by[NR::X],by[NR::Y], dist);
+ //g_print ("push %s at %g,%g from %g,%g by %g,%g, dist %g\n", SP_OBJECT_ID(what), it[Geom::X],it[Geom::Y], p[Geom::X],p[Geom::Y], by[Geom::X],by[Geom::Y], dist);
sp_item_set_i2d_affine(what, sp_item_i2d_affine(what) * move);
sp_item_write_transform(what, SP_OBJECT_REPR(what), what->transform, NULL);
void
unclump_pull (SPItem *to, SPItem *what, double dist)
{
- NR::Point it = unclump_center (what);
- NR::Point p = unclump_center (to);
- NR::Point by = dist * NR::unit_vector (p - it);
+ Geom::Point it = unclump_center (what);
+ Geom::Point p = unclump_center (to);
+ Geom::Point by = dist * Geom::unit_vector (p - it);
Geom::Matrix move = Geom::Translate (by);
- std::map<const gchar *, NR::Point>::iterator i = c_cache.find(SP_OBJECT_ID(what));
+ std::map<const gchar *, Geom::Point>::iterator i = c_cache.find(SP_OBJECT_ID(what));
if ( i != c_cache.end() ) {
i->second *= move;
}
- //g_print ("pull %s at %g,%g to %g,%g by %g,%g, dist %g\n", SP_OBJECT_ID(what), it[NR::X],it[NR::Y], p[NR::X],p[NR::Y], by[NR::X],by[NR::Y], dist);
+ //g_print ("pull %s at %g,%g to %g,%g by %g,%g, dist %g\n", SP_OBJECT_ID(what), it[Geom::X],it[Geom::Y], p[Geom::X],p[Geom::Y], by[Geom::X],by[Geom::Y], dist);
sp_item_set_i2d_affine(what, sp_item_i2d_affine(what) * move);
sp_item_write_transform(what, SP_OBJECT_REPR(what), what->transform, NULL);
diff --git a/src/document.cpp b/src/document.cpp
index 57ac0f1f15ffde8c4ebb5e37bcf61d90dcae7830..c3ebdcdb212372921d0a279eedf45d1ec1ecd1b1 100644 (file)
--- a/src/document.cpp
+++ b/src/document.cpp
#include <cstring>
#include "application/application.h"
#include "application/editor.h"
-#include "libnr/nr-matrix-fns.h"
#include "xml/repr.h"
#include "helper/units.h"
#include "inkscape-private.h"
#include "unit-constants.h"
#include "prefs-utils.h"
#include "libavoid/router.h"
-#include "libnr/nr-rect.h"
#include "sp-item-group.h"
#include "profile-manager.h"
#include "persp3d.h"
}
/**
- * Given an NR::Rect that may, for example, correspond to the bbox of an object,
+ * Given a Geom::Rect that may, for example, correspond to the bbox of an object,
* this function fits the canvas to that rect by resizing the canvas
* and translating the document root into position.
*/
sp_document_setup_viewport (SPDocument *doc, SPItemCtx *ctx)
{
ctx->ctx.flags = 0;
- ctx->i2doc = NR::identity();
+ ctx->i2doc = Geom::identity();
/* Set up viewport in case svg has it defined as percentages */
if (SP_ROOT(doc->root)->viewBox_set) { // if set, take from viewBox
ctx->vp.x0 = SP_ROOT(doc->root)->viewBox.x0;
ctx->vp.x1 = 210 * PX_PER_MM;
ctx->vp.y1 = 297 * PX_PER_MM;
}
- ctx->i2vp = NR::identity();
+ ctx->i2vp = Geom::identity();
}
/**