summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2011-08-28 21:53:33 +0000
committerKrzysztof Kosinski <tweenk.pl@gmail.com>2011-08-28 21:53:33 +0000
commit7c7326a95acfd6885bf1b29d80679ea84d96c5fb (patch)
treea64cfe0dc6abdea48a15585594cebb6a8368cf90 /src
parentRemove nr-object.h and nr-macros.h (diff)
downloadinkscape-7c7326a95acfd6885bf1b29d80679ea84d96c5fb.tar.gz
inkscape-7c7326a95acfd6885bf1b29d80679ea84d96c5fb.zip
Completely remove libnr
(bzr r10582.1.11)
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/gradient-chemistry.cpp14
-rw-r--r--src/gradient-context.cpp5
-rw-r--r--src/gradient-drag.cpp39
-rw-r--r--src/libnr/CMakeLists.txt15
-rw-r--r--src/libnr/Makefile_insert5
-rw-r--r--src/libnr/makefile.in17
-rw-r--r--src/libnr/nr-point-fns.cpp42
-rw-r--r--src/libnr/nr-point-fns.h21
-rw-r--r--src/livarot/PathOutline.cpp1
-rw-r--r--src/livarot/Shape.cpp1
-rw-r--r--src/livarot/ShapeRaster.cpp1
-rw-r--r--src/livarot/sweep-tree.cpp1
-rw-r--r--src/satisfied-guide-cns.cpp1
15 files changed, 32 insertions, 133 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 038e7bb73..ce289f33c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -550,7 +550,6 @@ add_subdirectory(libcroco)
add_subdirectory(libgdl)
add_subdirectory(libvpsc)
add_subdirectory(livarot)
-add_subdirectory(libnr)
add_subdirectory(libnrtype)
diff --git a/src/Makefile.am b/src/Makefile.am
index 5a50eb36f..2ab4d0030 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -120,7 +120,6 @@ include helper/Makefile_insert
include io/Makefile_insert
include libcroco/Makefile_insert
include libgdl/Makefile_insert
-include libnr/Makefile_insert
include libnrtype/Makefile_insert
include libavoid/Makefile_insert
include livarot/Makefile_insert
diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp
index 5a8b20850..990695068 100644
--- a/src/gradient-chemistry.cpp
+++ b/src/gradient-chemistry.cpp
@@ -16,6 +16,8 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
+#include <2geom/transforms.h>
+#include <2geom/bezier-curve.h>
#include "style.h"
#include "document-private.h"
@@ -30,14 +32,12 @@
#include "sp-text.h"
#include "sp-tspan.h"
-#include <2geom/transforms.h>
#include "xml/repr.h"
#include "svg/svg.h"
#include "svg/svg-color.h"
#include "svg/css-ostringstream.h"
#include "preferences.h"
-#include "libnr/nr-point-fns.h"
#define noSP_GR_VERBOSE
// Terminology:
@@ -838,7 +838,9 @@ void sp_item_gradient_set_coords(SPItem *item, guint point_type, guint point_i,
case POINT_LG_MID:
{
// using X-coordinates only to determine the offset, assuming p has been snapped to the vector from begin to end.
- double offset = get_offset_between_points (p, Geom::Point(lg->x1.computed, lg->y1.computed), Geom::Point(lg->x2.computed, lg->y2.computed));
+ Geom::Point begin(lg->x1.computed, lg->y1.computed);
+ Geom::Point end(lg->x2.computed, lg->y2.computed);
+ double offset = Geom::LineSegment(begin, end).nearestPoint(p);
SPGradient *vector = sp_gradient_get_forked_vector_if_necessary (lg, false);
lg->ensureVector();
lg->vector.stops.at(point_i).offset = offset;
@@ -931,8 +933,8 @@ void sp_item_gradient_set_coords(SPItem *item, guint point_type, guint point_i,
case POINT_RG_MID1:
{
Geom::Point start = Geom::Point (rg->cx.computed, rg->cy.computed);
- Geom::Point end = Geom::Point (rg->cx.computed + rg->r.computed, rg->cy.computed);
- double offset = get_offset_between_points (p, start, end);
+ Geom::Point end = Geom::Point (rg->cx.computed + rg->r.computed, rg->cy.computed);
+ double offset = Geom::LineSegment(start, end).nearestPoint(p);
SPGradient *vector = sp_gradient_get_forked_vector_if_necessary (rg, false);
rg->ensureVector();
rg->vector.stops.at(point_i).offset = offset;
@@ -948,7 +950,7 @@ void sp_item_gradient_set_coords(SPItem *item, guint point_type, guint point_i,
case POINT_RG_MID2:
Geom::Point start = Geom::Point (rg->cx.computed, rg->cy.computed);
Geom::Point end = Geom::Point (rg->cx.computed, rg->cy.computed - rg->r.computed);
- double offset = get_offset_between_points (p, start, end);
+ double offset = Geom::LineSegment(start, end).nearestPoint(p);
SPGradient *vector = sp_gradient_get_forked_vector_if_necessary(rg, false);
rg->ensureVector();
rg->vector.stops.at(point_i).offset = offset;
diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp
index c4bef4683..0cb000003 100644
--- a/src/gradient-context.cpp
+++ b/src/gradient-context.cpp
@@ -46,8 +46,6 @@
#include "sp-namedview.h"
#include "rubberband.h"
-#include "libnr/nr-point-fns.h"
-
using Inkscape::DocumentUndo;
static void sp_gradient_context_class_init(SPGradientContextClass *klass);
@@ -254,7 +252,8 @@ sp_gradient_context_is_over_line (SPGradientContext *rc, SPItem *item, Geom::Poi
SPCtrlLine* line = SP_CTRLLINE(item);
- Geom::Point nearest = snap_vector_midpoint (rc->mousepoint_doc, line->s, line->e, 0);
+ Geom::LineSegment ls(line->s, line->e);
+ Geom::Point nearest = ls.pointAt(ls.nearestPoint(rc->mousepoint_doc));
double dist_screen = Geom::L2 (rc->mousepoint_doc - nearest) * desktop->current_zoom();
double tolerance = (double) SP_EVENT_CONTEXT(rc)->tolerance;
diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp
index 1275bf995..585c55c28 100644
--- a/src/gradient-drag.cpp
+++ b/src/gradient-drag.cpp
@@ -20,6 +20,7 @@
#include <glibmm/i18n.h>
#include <cstring>
#include <string>
+#include <2geom/bezier-curve.h>
#include "desktop-handles.h"
#include "selection.h"
@@ -32,7 +33,6 @@
#include "xml/repr.h"
#include "svg/css-ostringstream.h"
#include "svg/svg.h"
-#include "libnr/nr-point-fns.h"
#include "preferences.h"
#include "sp-item.h"
#include "style.h"
@@ -339,7 +339,7 @@ guint32 GrDrag::getColor()
SPStop *
GrDrag::addStopNearPoint (SPItem *item, Geom::Point mouse_p, double tolerance)
{
- gfloat offset; // type of SPStop.offset = gfloat
+ gfloat offset = 0; // type of SPStop.offset = gfloat
SPGradient *gradient;
bool fill_or_stroke = true;
bool r1_knot = false;
@@ -350,32 +350,34 @@ GrDrag::addStopNearPoint (SPItem *item, Geom::Point mouse_p, double tolerance)
if (SP_IS_LINEARGRADIENT(gradient)) {
Geom::Point begin = sp_item_gradient_get_coords(item, POINT_LG_BEGIN, 0, fill_or_stroke);
Geom::Point end = sp_item_gradient_get_coords(item, POINT_LG_END, 0, fill_or_stroke);
-
- Geom::Point nearest = snap_vector_midpoint (mouse_p, begin, end, 0);
- double dist_screen = Geom::L2 (mouse_p - nearest);
+ Geom::LineSegment ls(begin, end);
+ double offset = ls.nearestPoint(mouse_p);
+ Geom::Point nearest = ls.pointAt(offset);
+ double dist_screen = Geom::distance(mouse_p, nearest);
if ( dist_screen < tolerance ) {
// add the knot
- offset = get_offset_between_points(nearest, begin, end);
addknot = true;
break; // break out of the while loop: add only one knot
}
} else if (SP_IS_RADIALGRADIENT(gradient)) {
Geom::Point begin = sp_item_gradient_get_coords(item, POINT_RG_CENTER, 0, fill_or_stroke);
Geom::Point end = sp_item_gradient_get_coords(item, POINT_RG_R1, 0, fill_or_stroke);
- Geom::Point nearest = snap_vector_midpoint (mouse_p, begin, end, 0);
- double dist_screen = Geom::L2 (mouse_p - nearest);
+ Geom::LineSegment ls(begin, end);
+ double offset = ls.nearestPoint(mouse_p);
+ Geom::Point nearest = ls.pointAt(offset);
+ double dist_screen = Geom::distance(mouse_p, nearest);
if ( dist_screen < tolerance ) {
- offset = get_offset_between_points(nearest, begin, end);
addknot = true;
r1_knot = true;
break; // break out of the while loop: add only one knot
}
end = sp_item_gradient_get_coords(item, POINT_RG_R2, 0, fill_or_stroke);
- nearest = snap_vector_midpoint (mouse_p, begin, end, 0);
- dist_screen = Geom::L2 (mouse_p - nearest);
+ ls = Geom::LineSegment(begin, end);
+ offset = ls.nearestPoint(mouse_p);
+ nearest = ls.pointAt(offset);
+ dist_screen = Geom::distance(mouse_p, nearest);
if ( dist_screen < tolerance ) {
- offset = get_offset_between_points(nearest, begin, end);
addknot = true;
r1_knot = false;
break; // break out of the while loop: add only one knot
@@ -442,7 +444,8 @@ GrDrag::dropColor(SPItem */*item*/, gchar const *c, Geom::Point p)
if (lines) {
for (GSList *l = lines; (l != NULL) && (!over_line); l = l->next) {
line = (SPCtrlLine*) l->data;
- Geom::Point nearest = snap_vector_midpoint (p, line->s, line->e, 0);
+ Geom::LineSegment ls(line->s, line->e);
+ Geom::Point nearest = ls.pointAt(ls.nearestPoint(p));
double dist_screen = Geom::L2 (p - nearest) * desktop->current_zoom();
if (line->item && dist_screen < 5) {
SPStop *stop = addStopNearPoint (line->item, p, 5/desktop->current_zoom());
@@ -847,9 +850,11 @@ gr_knot_moved_midpoint_handler(SPKnot */*knot*/, Geom::Point const &ppointer, gu
gr_midpoint_limits(dragger, server, &begin, &end, &low_lim, &high_lim, &moving);
if (state & GDK_CONTROL_MASK) {
- p = snap_vector_midpoint (p, low_lim, high_lim, snap_fraction);
+ Geom::LineSegment ls(low_lim, high_lim);
+ p = ls.pointAt(round(ls.nearestPoint(p) / snap_fraction) * snap_fraction);
} else {
- p = snap_vector_midpoint (p, low_lim, high_lim, 0);
+ Geom::LineSegment ls(low_lim, high_lim);
+ p = ls.pointAt(ls.nearestPoint(p));
if (!(state & GDK_SHIFT_MASK)) {
Inkscape::Snapper::SnapConstraint cl(low_lim, high_lim - low_lim);
SPDesktop *desktop = dragger->parent->desktop;
@@ -1885,8 +1890,8 @@ GrDrag::selected_move (double x, double y, bool write_repr, bool scale_radial)
GSList *moving = NULL;
gr_midpoint_limits(dragger, server, &begin, &end, &low_lim, &high_lim, &moving);
- Geom::Point p(x, y);
- p = snap_vector_midpoint (dragger->point + p, low_lim, high_lim, 0);
+ Geom::LineSegment ls(low_lim, high_lim);
+ Geom::Point p = ls.pointAt(ls.nearestPoint(dragger->point + p));
Geom::Point displacement = p - dragger->point;
for (GSList const* i = moving; i != NULL; i = i->next) {
diff --git a/src/libnr/CMakeLists.txt b/src/libnr/CMakeLists.txt
deleted file mode 100644
index 0adea96f0..000000000
--- a/src/libnr/CMakeLists.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-
-set(nr_SRC
- nr-object.cpp
- nr-point-fns.cpp
- nr-values.cpp
-
- # -------
- # Headers
- nr-macros.h
- nr-object.h
- nr-point-fns.h
- nr-values.h
-)
-
-add_inkscape_lib(nr_LIB "${nr_SRC}")
diff --git a/src/libnr/Makefile_insert b/src/libnr/Makefile_insert
deleted file mode 100644
index 487f34be1..000000000
--- a/src/libnr/Makefile_insert
+++ /dev/null
@@ -1,5 +0,0 @@
-## Makefile.am fragment sourced by src/Makefile.am.
-
-ink_common_sources += \
- libnr/nr-point-fns.cpp \
- libnr/nr-point-fns.h
diff --git a/src/libnr/makefile.in b/src/libnr/makefile.in
deleted file mode 100644
index 9f8d3919e..000000000
--- a/src/libnr/makefile.in
+++ /dev/null
@@ -1,17 +0,0 @@
-# Convenience stub makefile to call the real Makefile.
-
-@SET_MAKE@
-
-OBJEXT = @OBJEXT@
-
-# Explicit so that it's the default rule.
-all:
- cd .. && $(MAKE) libnr/all
-
-clean %.a %.$(OBJEXT):
- cd .. && $(MAKE) libnr/$@
-
-.PHONY: all clean
-
-.SUFFIXES:
-.SUFFIXES: .a .$(OBJEXT)
diff --git a/src/libnr/nr-point-fns.cpp b/src/libnr/nr-point-fns.cpp
deleted file mode 100644
index e4fb8cf0b..000000000
--- a/src/libnr/nr-point-fns.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-#include "libnr/nr-point-fns.h"
-
-Geom::Point
-snap_vector_midpoint (Geom::Point const &p, Geom::Point const &begin, Geom::Point const &end, double snap)
-{
- double length = Geom::distance(begin, end);
- Geom::Point be = (end - begin) / length;
- double r = Geom::dot(p - begin, be);
-
- if (r < 0.0) return begin;
- if (r > length) return end;
-
- double snapdist = length * snap;
- double r_snapped = (snap==0) ? r : floor(r/(snapdist + 0.5)) * snapdist;
-
- return (begin + r_snapped * be);
-}
-
-// equivalent to Geom::LineSegment(begin, end).nearestPoint(p)
-double
-get_offset_between_points (Geom::Point const &p, Geom::Point const &begin, Geom::Point const &end)
-{
- double length = Geom::distance(begin, end);
- Geom::Point be = (end - begin) / length;
- double r = Geom::dot(p - begin, be);
-
- if (r < 0.0) return 0.0;
- if (r > length) return 1.0;
-
- return (r / length);
-}
-
-/*
- 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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/libnr/nr-point-fns.h b/src/libnr/nr-point-fns.h
deleted file mode 100644
index 036c943f1..000000000
--- a/src/libnr/nr-point-fns.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef __NR_POINT_OPS_H__
-#define __NR_POINT_OPS_H__
-
-#include <2geom/point.h>
-
-Geom::Point snap_vector_midpoint (Geom::Point const &p, Geom::Point const &begin, Geom::Point const &end, double snap);
-
-double get_offset_between_points (Geom::Point const &p, Geom::Point const &begin, Geom::Point const &end);
-
-#endif /* !__NR_POINT_OPS_H__ */
-
-/*
- 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:fileencoding=utf-8:textwidth=99 :
diff --git a/src/livarot/PathOutline.cpp b/src/livarot/PathOutline.cpp
index d4fc7eb30..d170e5d3a 100644
--- a/src/livarot/PathOutline.cpp
+++ b/src/livarot/PathOutline.cpp
@@ -8,7 +8,6 @@
#include "livarot/Path.h"
#include "livarot/path-description.h"
-#include <libnr/nr-point-fns.h>
/*
* the "outliner"
diff --git a/src/livarot/Shape.cpp b/src/livarot/Shape.cpp
index d24e4b99d..805741d3f 100644
--- a/src/livarot/Shape.cpp
+++ b/src/livarot/Shape.cpp
@@ -12,7 +12,6 @@
#include "Shape.h"
#include "livarot/sweep-event-queue.h"
#include "livarot/sweep-tree-list.h"
-#include <libnr/nr-point-fns.h>
/*
* Shape instances handling.
diff --git a/src/livarot/ShapeRaster.cpp b/src/livarot/ShapeRaster.cpp
index 7b00cdc6b..b7b087fba 100644
--- a/src/livarot/ShapeRaster.cpp
+++ b/src/livarot/ShapeRaster.cpp
@@ -12,7 +12,6 @@
#include "AlphaLigne.h"
#include "BitLigne.h"
-#include <libnr/nr-point-fns.h>
#include "livarot/sweep-event-queue.h"
#include "livarot/sweep-tree-list.h"
#include "livarot/sweep-tree.h"
diff --git a/src/livarot/sweep-tree.cpp b/src/livarot/sweep-tree.cpp
index 9ff1143ce..0cfd6bc52 100644
--- a/src/livarot/sweep-tree.cpp
+++ b/src/livarot/sweep-tree.cpp
@@ -1,4 +1,3 @@
-#include "libnr/nr-point-fns.h"
#include "livarot/sweep-event-queue.h"
#include "livarot/sweep-tree-list.h"
#include "livarot/sweep-tree.h"
diff --git a/src/satisfied-guide-cns.cpp b/src/satisfied-guide-cns.cpp
index 6d8c4d048..7aca3b0bd 100644
--- a/src/satisfied-guide-cns.cpp
+++ b/src/satisfied-guide-cns.cpp
@@ -1,5 +1,4 @@
#include <desktop-handles.h>
-#include <libnr/nr-point-fns.h>
#include <sp-guide.h>
#include <sp-guide-constraint.h>
#include <sp-namedview.h>