summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f307a86)
raw | patch | inline | side by side (parent: f307a86)
author | cilix42 <cilix42@users.sourceforge.net> | |
Thu, 18 Sep 2008 17:41:03 +0000 (17:41 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Thu, 18 Sep 2008 17:41:03 +0000 (17:41 +0000) |
21 files changed:
diff --git a/src/common-context.cpp b/src/common-context.cpp
index d20b43b1234e602bd1ea820996702016336253a8..eab50b478500f9b376bb42a5ecf98d32c76ca74b 100644 (file)
--- a/src/common-context.cpp
+++ b/src/common-context.cpp
ctx->repr = 0;
/* Common values */
- ctx->cur = NR::Point(0,0);
- ctx->last = NR::Point(0,0);
- ctx->vel = NR::Point(0,0);
+ ctx->cur = Geom::Point(0,0);
+ ctx->last = Geom::Point(0,0);
+ ctx->vel = Geom::Point(0,0);
ctx->vel_max = 0;
- ctx->acc = NR::Point(0,0);
- ctx->ang = NR::Point(0,0);
- ctx->del = NR::Point(0,0);
+ ctx->acc = Geom::Point(0,0);
+ ctx->ang = Geom::Point(0,0);
+ ctx->del = Geom::Point(0,0);
/* attributes */
ctx->dragging = FALSE;
diff --git a/src/common-context.h b/src/common-context.h
index 22fa796ee62df09d7a83603300aa393d292827bc..870649caa5924b7d9a06561d6d32fe287c6e1ab0 100644 (file)
--- a/src/common-context.h
+++ b/src/common-context.h
#include "event-context.h"
#include "display/curve.h"
#include "display/display-forward.h"
-#include <libnr/nr-point.h>
+#include <2geom/point.h>
#define SP_TYPE_COMMON_CONTEXT (sp_common_context_get_type())
#define SP_COMMON_CONTEXT(o) (GTK_CHECK_CAST((o), SP_TYPE_COMMON_CONTEXT, SPCommonContext))
SPCurve *cal2;
/** left edge points for this segment */
- NR::Point point1[SAMPLING_SIZE];
+ Geom::Point point1[SAMPLING_SIZE];
/** right edge points for this segment */
- NR::Point point2[SAMPLING_SIZE];
+ Geom::Point point2[SAMPLING_SIZE];
/** number of edge points for this segment */
gint npoints;
Inkscape::XML::Node *repr;
/* common */
- NR::Point cur;
- NR::Point vel;
+ Geom::Point cur;
+ Geom::Point vel;
double vel_max;
- NR::Point acc;
- NR::Point ang;
- NR::Point last;
- NR::Point del;
+ Geom::Point acc;
+ Geom::Point ang;
+ Geom::Point last;
+ Geom::Point del;
/* extended input data */
gdouble pressure;
index 434e7169e8df1a2e1fb579eb5070eb9fee909bb5..5d09e66a7516df13229779200cabb84386d6dbcd 100644 (file)
#include "2geom/isnan.h"
-typedef NR::Point BezierCurve[];
+typedef Geom::Point BezierCurve[];
/* Forward declarations */
-static void generate_bezier(NR::Point b[], NR::Point const d[], gdouble const u[], unsigned len,
- NR::Point const &tHat1, NR::Point const &tHat2, double tolerance_sq);
-static void estimate_lengths(NR::Point bezier[],
- NR::Point const data[], gdouble const u[], unsigned len,
- NR::Point const &tHat1, NR::Point const &tHat2);
-static void estimate_bi(NR::Point b[4], unsigned ei,
- NR::Point const data[], double const u[], unsigned len);
-static void reparameterize(NR::Point const d[], unsigned len, double u[], BezierCurve const bezCurve);
-static gdouble NewtonRaphsonRootFind(BezierCurve const Q, NR::Point const &P, gdouble u);
-static NR::Point sp_darray_center_tangent(NR::Point const d[], unsigned center, unsigned length);
-static NR::Point sp_darray_right_tangent(NR::Point const d[], unsigned const len);
-static unsigned copy_without_nans_or_adjacent_duplicates(NR::Point const src[], unsigned src_len, NR::Point dest[]);
-static void chord_length_parameterize(NR::Point const d[], gdouble u[], unsigned len);
-static double compute_max_error_ratio(NR::Point const d[], double const u[], unsigned len,
+static void generate_bezier(Geom::Point b[], Geom::Point const d[], gdouble const u[], unsigned len,
+ Geom::Point const &tHat1, Geom::Point const &tHat2, double tolerance_sq);
+static void estimate_lengths(Geom::Point bezier[],
+ Geom::Point const data[], gdouble const u[], unsigned len,
+ Geom::Point const &tHat1, Geom::Point const &tHat2);
+static void estimate_bi(Geom::Point b[4], unsigned ei,
+ Geom::Point const data[], double const u[], unsigned len);
+static void reparameterize(Geom::Point const d[], unsigned len, double u[], BezierCurve const bezCurve);
+static gdouble NewtonRaphsonRootFind(BezierCurve const Q, Geom::Point const &P, gdouble u);
+static Geom::Point sp_darray_center_tangent(Geom::Point const d[], unsigned center, unsigned length);
+static Geom::Point sp_darray_right_tangent(Geom::Point const d[], unsigned const len);
+static unsigned copy_without_nans_or_adjacent_duplicates(Geom::Point const src[], unsigned src_len, Geom::Point dest[]);
+static void chord_length_parameterize(Geom::Point const d[], gdouble u[], unsigned len);
+static double compute_max_error_ratio(Geom::Point const d[], double const u[], unsigned len,
BezierCurve const bezCurve, double tolerance,
unsigned *splitPoint);
-static double compute_hook(NR::Point const &a, NR::Point const &b, double const u, BezierCurve const bezCurve,
+static double compute_hook(Geom::Point const &a, Geom::Point const &b, double const u, BezierCurve const bezCurve,
double const tolerance);
-static NR::Point const unconstrained_tangent(0, 0);
+static Geom::Point const unconstrained_tangent(0, 0);
/*
* \return Number of segments generated, or -1 on error.
*/
gint
-sp_bezier_fit_cubic(NR::Point *bezier, NR::Point const *data, gint len, gdouble error)
+sp_bezier_fit_cubic(Geom::Point *bezier, Geom::Point const *data, gint len, gdouble error)
{
return sp_bezier_fit_cubic_r(bezier, data, len, error, 1);
}
@@ -112,14 +112,14 @@ sp_bezier_fit_cubic(NR::Point *bezier, NR::Point const *data, gint len, gdouble
* \return Number of segments generated, or -1 on error.
*/
gint
-sp_bezier_fit_cubic_r(NR::Point bezier[], NR::Point const data[], gint const len, gdouble const error, unsigned const max_beziers)
+sp_bezier_fit_cubic_r(Geom::Point bezier[], Geom::Point const data[], gint const len, gdouble const error, unsigned const max_beziers)
{
g_return_val_if_fail(bezier != NULL, -1);
g_return_val_if_fail(data != NULL, -1);
g_return_val_if_fail(len > 0, -1);
g_return_val_if_fail(max_beziers < (1ul << (31 - 2 - 1 - 3)), -1);
- NR::Point *uniqued_data = g_new(NR::Point, len);
+ Geom::Point *uniqued_data = g_new(Geom::Point, len);
unsigned uniqued_len = copy_without_nans_or_adjacent_duplicates(data, len, uniqued_data);
if ( uniqued_len < 2 ) {
@@ -141,7 +141,7 @@ sp_bezier_fit_cubic_r(NR::Point bezier[], NR::Point const data[], gint const len
* \return length of dest
*/
static unsigned
-copy_without_nans_or_adjacent_duplicates(NR::Point const src[], unsigned src_len, NR::Point dest[])
+copy_without_nans_or_adjacent_duplicates(Geom::Point const src[], unsigned src_len, Geom::Point dest[])
{
unsigned si = 0;
for (;;) {
@@ -150,7 +150,7 @@ copy_without_nans_or_adjacent_duplicates(NR::Point const src[], unsigned src_len
}
if (!IS_NAN(src[si][NR::X]) &&
!IS_NAN(src[si][NR::Y])) {
- dest[0] = NR::Point(src[si]);
+ dest[0] = Geom::Point(src[si]);
++si;
break;
}
@@ -158,7 +158,7 @@ copy_without_nans_or_adjacent_duplicates(NR::Point const src[], unsigned src_len
}
unsigned di = 0;
for (; si < src_len; ++si) {
- NR::Point const src_pt = NR::Point(src[si]);
+ Geom::Point const src_pt = Geom::Point(src[si]);
if ( src_pt != dest[di]
&& !IS_NAN(src_pt[NR::X])
&& !IS_NAN(src_pt[NR::Y])) {
@@ -179,9 +179,9 @@ copy_without_nans_or_adjacent_duplicates(NR::Point const src[], unsigned src_len
* \param Result array, must be large enough for n. segments * 4 elements.
*/
gint
-sp_bezier_fit_cubic_full(NR::Point bezier[], int split_points[],
- NR::Point const data[], gint const len,
- NR::Point const &tHat1, NR::Point const &tHat2,
+sp_bezier_fit_cubic_full(Geom::Point bezier[], int split_points[],
+ Geom::Point const data[], gint const len,
+ Geom::Point const &tHat1, Geom::Point const &tHat2,
double const error, unsigned const max_beziers)
{
int const maxIterations = 4; /* Max times to try iterating */
*/
unsigned const rec_max_beziers1 = max_beziers - 1;
- NR::Point recTHat2, recTHat1;
+ Geom::Point recTHat2, recTHat1;
if (is_corner) {
g_return_val_if_fail(0 < splitPoint && splitPoint < unsigned(len - 1), -1);
recTHat1 = recTHat2 = unconstrained_tangent;
* when \a tHat1 or \a tHat2 is zero.
*/
static void
-generate_bezier(NR::Point bezier[],
- NR::Point const data[], gdouble const u[], unsigned const len,
- NR::Point const &tHat1, NR::Point const &tHat2,
+generate_bezier(Geom::Point bezier[],
+ Geom::Point const data[], gdouble const u[], unsigned const len,
+ Geom::Point const &tHat1, Geom::Point const &tHat2,
double const tolerance_sq)
{
bool const est1 = is_zero(tHat1);
bool const est2 = is_zero(tHat2);
- NR::Point est_tHat1( est1
+ Geom::Point est_tHat1( est1
? sp_darray_left_tangent(data, len, tolerance_sq)
: tHat1 );
- NR::Point est_tHat2( est2
+ Geom::Point est_tHat2( est2
? sp_darray_right_tangent(data, len, tolerance_sq)
: tHat2 );
estimate_lengths(bezier, data, u, len, est_tHat1, est_tHat2);
static void
-estimate_lengths(NR::Point bezier[],
- NR::Point const data[], gdouble const uPrime[], unsigned const len,
- NR::Point const &tHat1, NR::Point const &tHat2)
+estimate_lengths(Geom::Point bezier[],
+ Geom::Point const data[], gdouble const uPrime[], unsigned const len,
+ Geom::Point const &tHat1, Geom::Point const &tHat2)
{
double C[2][2]; /* Matrix C. */
double X[2]; /* Matrix X. */
double const b3 = B3(uPrime[i]);
/* rhs for eqn */
- NR::Point const a1 = b1 * tHat1;
- NR::Point const a2 = b2 * tHat2;
+ Geom::Point const a1 = b1 * tHat1;
+ Geom::Point const a2 = b2 * tHat2;
C[0][0] += dot(a1, a1);
C[0][1] += dot(a1, a2);
/* Additional offset to the data point from the predicted point if we were to set bezier[1]
to bezier[0] and bezier[2] to bezier[3]. */
- NR::Point const shortfall
+ Geom::Point const shortfall
= ( data[i]
- ( ( b0 + b1 ) * bezier[0] )
- ( ( b2 + b3 ) * bezier[3] ) );
return;
}
-static double lensq(NR::Point const p) {
+static double lensq(Geom::Point const p) {
return dot(p, p);
}
static void
-estimate_bi(NR::Point bezier[4], unsigned const ei,
- NR::Point const data[], double const u[], unsigned const len)
+estimate_bi(Geom::Point bezier[4], unsigned const ei,
+ Geom::Point const data[], double const u[], unsigned const len)
{
g_return_if_fail(1 <= ei && ei <= 2);
unsigned const oi = 3 - ei;
* Also the size of the array that is allocated for return.
*/
static void
-reparameterize(NR::Point const d[],
+reparameterize(Geom::Point const d[],
unsigned const len,
double u[],
BezierCurve const bezCurve)
* \return Improved u
*/
static gdouble
-NewtonRaphsonRootFind(BezierCurve const Q, NR::Point const &P, gdouble const u)
+NewtonRaphsonRootFind(BezierCurve const Q, Geom::Point const &P, gdouble const u)
{
g_assert( 0.0 <= u );
g_assert( u <= 1.0 );
/* Generate control vertices for Q'. */
- NR::Point Q1[3];
+ Geom::Point Q1[3];
for (unsigned i = 0; i < 3; i++) {
Q1[i] = 3.0 * ( Q[i+1] - Q[i] );
}
/* Generate control vertices for Q''. */
- NR::Point Q2[2];
+ Geom::Point Q2[2];
for (unsigned i = 0; i < 2; i++) {
Q2[i] = 2.0 * ( Q1[i+1] - Q1[i] );
}
/* Compute Q(u), Q'(u) and Q''(u). */
- NR::Point const Q_u = bezier_pt(3, Q, u);
- NR::Point const Q1_u = bezier_pt(2, Q1, u);
- NR::Point const Q2_u = bezier_pt(1, Q2, u);
+ Geom::Point const Q_u = bezier_pt(3, Q, u);
+ Geom::Point const Q1_u = bezier_pt(2, Q1, u);
+ Geom::Point const Q2_u = bezier_pt(1, Q2, u);
/* Compute f(u)/f'(u), where f is the derivative wrt u of distsq(u) = 0.5 * the square of the
distance from P to Q(u). Here we're using Newton-Raphson to find a stationary point in the
distsq(u), hopefully corresponding to a local minimum in distsq (and hence a local minimum
distance from P to Q(u)). */
- NR::Point const diff = Q_u - P;
+ Geom::Point const diff = Q_u - P;
double numerator = dot(diff, Q1_u);
double denominator = dot(Q1_u, Q1_u) + dot(diff, Q2_u);
* is i * BezierII(i-1, V'), where for all j, V'[j] =
* V[j + 1] - V[j].
*/
-NR::Point
-bezier_pt(unsigned const degree, NR::Point const V[], gdouble const t)
+Geom::Point
+bezier_pt(unsigned const degree, Geom::Point const V[], gdouble const t)
{
/** Pascal's triangle. */
static int const pascal[4][4] = {{1},
tpow[i + 1] = tpow[i] * t;
}
- NR::Point ret = spow[degree] * V[0];
+ Geom::Point ret = spow[degree] * V[0];
for (unsigned i = 1; i <= degree; ++i) {
ret += pascal[degree][i] * spow[degree - i] * tpow[i] * V[i];
}
* the way one might expect, i.e., wrt increasing index into d.
* \pre (2 \<= len) and (d[0] != d[1]).
**/
-NR::Point
-sp_darray_left_tangent(NR::Point const d[], unsigned const len)
+Geom::Point
+sp_darray_left_tangent(Geom::Point const d[], unsigned const len)
{
g_assert( len >= 2 );
g_assert( d[0] != d[1] );
* \pre d[len - 1] != d[len - 2].
* \pre all[p in d] in_svg_plane(p).
*/
-static NR::Point
-sp_darray_right_tangent(NR::Point const d[], unsigned const len)
+static Geom::Point
+sp_darray_right_tangent(Geom::Point const d[], unsigned const len)
{
g_assert( 2 <= len );
unsigned const last = len - 1;
* \pre all[p in d] in_svg_plane(p).
* \post is_unit_vector(ret).
**/
-NR::Point
-sp_darray_left_tangent(NR::Point const d[], unsigned const len, double const tolerance_sq)
+Geom::Point
+sp_darray_left_tangent(Geom::Point const d[], unsigned const len, double const tolerance_sq)
{
g_assert( 2 <= len );
g_assert( 0 <= tolerance_sq );
for (unsigned i = 1;;) {
- NR::Point const pi(d[i]);
- NR::Point const t(pi - d[0]);
+ Geom::Point const pi(d[i]);
+ Geom::Point const t(pi - d[0]);
double const distsq = dot(t, t);
if ( tolerance_sq < distsq ) {
return unit_vector(t);
@@ -763,15 +763,15 @@ sp_darray_left_tangent(NR::Point const d[], unsigned const len, double const tol
* \pre d[len - 1] != d[len - 2].
* \pre all[p in d] in_svg_plane(p).
*/
-NR::Point
-sp_darray_right_tangent(NR::Point const d[], unsigned const len, double const tolerance_sq)
+Geom::Point
+sp_darray_right_tangent(Geom::Point const d[], unsigned const len, double const tolerance_sq)
{
g_assert( 2 <= len );
g_assert( 0 <= tolerance_sq );
unsigned const last = len - 1;
for (unsigned i = last - 1;; i--) {
- NR::Point const pi(d[i]);
- NR::Point const t(pi - d[last]);
+ Geom::Point const pi(d[i]);
+ Geom::Point const t(pi - d[last]);
double const distsq = dot(t, t);
if ( tolerance_sq < distsq ) {
return unit_vector(t);
@@ -794,18 +794,18 @@ sp_darray_right_tangent(NR::Point const d[], unsigned const len, double const to
* \pre (0 \< center \< len - 1) and d is uniqued (at least in
* the immediate vicinity of \a center).
*/
-static NR::Point
-sp_darray_center_tangent(NR::Point const d[],
+static Geom::Point
+sp_darray_center_tangent(Geom::Point const d[],
unsigned const center,
unsigned const len)
{
g_assert( center != 0 );
g_assert( center < len - 1 );
- NR::Point ret;
+ Geom::Point ret;
if ( d[center + 1] == d[center - 1] ) {
/* Rotate 90 degrees in an arbitrary direction. */
- NR::Point const diff = d[center] - d[center - 1];
+ Geom::Point const diff = d[center] - d[center - 1];
ret = NR::rot90(diff);
} else {
ret = d[center - 1] - d[center + 1];
* \pre Parameter array u must have space for \a len items.
*/
static void
-chord_length_parameterize(NR::Point const d[], gdouble u[], unsigned const len)
+chord_length_parameterize(Geom::Point const d[], gdouble u[], unsigned const len)
{
g_return_if_fail( 2 <= len );
* \&\& (*splitPoint != 0 || ret \< 0.0))).
*/
static gdouble
-compute_max_error_ratio(NR::Point const d[], double const u[], unsigned const len,
+compute_max_error_ratio(Geom::Point const d[], double const u[], unsigned const len,
BezierCurve const bezCurve, double const tolerance,
unsigned *const splitPoint)
{
@@ -901,9 +901,9 @@ compute_max_error_ratio(NR::Point const d[], double const u[], unsigned const le
double maxDistsq = 0.0; /* Maximum error */
double max_hook_ratio = 0.0;
unsigned snap_end = 0;
- NR::Point prev = bezCurve[0];
+ Geom::Point prev = bezCurve[0];
for (unsigned i = 1; i <= last; i++) {
- NR::Point const curr = bezier_pt(3, bezCurve, u[i]);
+ Geom::Point const curr = bezier_pt(3, bezCurve, u[i]);
double const distsq = lensq( curr - d[i] );
if ( distsq > maxDistsq ) {
maxDistsq = distsq;
@@ -954,11 +954,11 @@ compute_max_error_ratio(NR::Point const d[], double const u[], unsigned const le
* distance.)
*/
static double
-compute_hook(NR::Point const &a, NR::Point const &b, double const u, BezierCurve const bezCurve,
+compute_hook(Geom::Point const &a, Geom::Point const &b, double const u, BezierCurve const bezCurve,
double const tolerance)
{
- NR::Point const P = bezier_pt(3, bezCurve, u);
- NR::Point const diff = .5 * (a + b) - P;
+ Geom::Point const P = bezier_pt(3, bezCurve, u);
+ Geom::Point const diff = .5 * (a + b) - P;
double const dist = NR::L2(diff);
if (dist < tolerance) {
return 0;
index 1d6c8678f0de12a7e1847302942ceb3cca7d0497..fc5fa61a4b6149723837478a4cd669bab2f2d1b2 100644 (file)
* Released under GNU GPL
*/
-#include <libnr/nr-forward.h>
+#include <2geom/forward.h>
#include <glib/gtypes.h>
/* Bezier approximation utils */
-NR::Point bezier_pt(unsigned degree, NR::Point const V[], gdouble t);
+Geom::Point bezier_pt(unsigned degree, Geom::Point const V[], gdouble t);
-gint sp_bezier_fit_cubic(NR::Point bezier[], NR::Point const data[], gint len, gdouble error);
+gint sp_bezier_fit_cubic(Geom::Point bezier[], Geom::Point const data[], gint len, gdouble error);
-gint sp_bezier_fit_cubic_r(NR::Point bezier[], NR::Point const data[], gint len, gdouble error,
+gint sp_bezier_fit_cubic_r(Geom::Point bezier[], Geom::Point const data[], gint len, gdouble error,
unsigned max_beziers);
-gint sp_bezier_fit_cubic_full(NR::Point bezier[], int split_points[], NR::Point const data[], gint len,
- NR::Point const &tHat1, NR::Point const &tHat2,
+gint sp_bezier_fit_cubic_full(Geom::Point bezier[], int split_points[], Geom::Point const data[], gint len,
+ Geom::Point const &tHat1, Geom::Point const &tHat2,
gdouble error, unsigned max_beziers);
-NR::Point sp_darray_left_tangent(NR::Point const d[], unsigned const len);
-NR::Point sp_darray_left_tangent(NR::Point const d[], unsigned const len, double const tolerance_sq);
-NR::Point sp_darray_right_tangent(NR::Point const d[], unsigned const length, double const tolerance_sq);
+Geom::Point sp_darray_left_tangent(Geom::Point const d[], unsigned const len);
+Geom::Point sp_darray_left_tangent(Geom::Point const d[], unsigned const len, double const tolerance_sq);
+Geom::Point sp_darray_right_tangent(Geom::Point const d[], unsigned const length, double const tolerance_sq);
#endif /* __SP_BEZIER_UTILS_H__ */
diff --git a/src/draw-context.cpp b/src/draw-context.cpp
index 266c6a961e1cb76ab3dd16d36bfa371cf820e7f6..d21ee5ffec156f834542e223b7f408c18a02a95f 100644 (file)
--- a/src/draw-context.cpp
+++ b/src/draw-context.cpp
* \param state keyboard state to check if ctrl was pressed
*/
-void spdc_endpoint_snap_rotation(SPEventContext const *const ec, NR::Point &p, NR::Point const &o,
+void spdc_endpoint_snap_rotation(SPEventContext const *const ec, Geom::Point &p, Geom::Point const &o,
guint state)
{
unsigned const snaps = abs(prefs_get_int_attribute("options.rotationsnapsperpi", "value", 12));
/* 0 means no snapping. */
/* mirrored by fabs, so this corresponds to 15 degrees */
- NR::Point best; /* best solution */
+ Geom::Point best; /* best solution */
double bn = NR_HUGE; /* best normal */
double bdot = 0;
- NR::Point v = NR::Point(0, 1);
+ Geom::Point v = Geom::Point(0, 1);
double const r00 = cos(M_PI / snaps), r01 = sin(M_PI / snaps);
double const r10 = -r01, r11 = r00;
- NR::Point delta = p - o;
+ Geom::Point delta = p - o;
for (unsigned i = 0; i < snaps; i++) {
- double const ndot = fabs(dot(v,NR::rot90(delta)));
- NR::Point t(r00*v[NR::X] + r01*v[NR::Y],
+ double const ndot = fabs(dot(v,Geom::rot90(delta)));
+ Geom::Point t(r00*v[NR::X] + r01*v[NR::Y],
r10*v[NR::X] + r11*v[NR::Y]);
if (ndot < bn) {
/* I think it is better numerically to use the normal, rather than the dot product
@@ -513,7 +513,7 @@ void spdc_endpoint_snap_rotation(SPEventContext const *const ec, NR::Point &p, N
}
-void spdc_endpoint_snap_free(SPEventContext const * const ec, NR::Point& p, guint const /*state*/)
+void spdc_endpoint_snap_free(SPEventContext const * const ec, Geom::Point& p, guint const /*state*/)
{
SnapManager &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager;
m.setup(SP_EVENT_CONTEXT_DESKTOP(ec));
* Returns FIRST active anchor (the activated one).
*/
SPDrawAnchor *
-spdc_test_inside(SPDrawContext *dc, NR::Point p)
+spdc_test_inside(SPDrawContext *dc, Geom::Point p)
{
SPDrawAnchor *active = NULL;
}
/* Create a single dot represented by a circle */
-void spdc_create_single_dot(SPEventContext *ec, NR::Point const &pt, char const *tool, guint event_state) {
+void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char const *tool, guint event_state) {
g_return_if_fail(!strcmp(tool, "tools.freehand.pen") || !strcmp(tool, "tools.freehand.pencil"));
SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(ec);
/* put the circle where the mouse click occurred and set the diameter to the
current stroke width, multiplied by the amount specified in the preferences */
- NR::Matrix const i2d (sp_item_i2d_affine (item));
- NR::Point pp = pt * i2d;
+ Geom::Matrix const i2d (sp_item_i2d_affine (item));
+ Geom::Point pp = pt * i2d;
double rad = 0.5 * prefs_get_double_attribute(tool, "dot-size", 3.0);
if (event_state & GDK_MOD1_MASK) {
/* TODO: We vary the dot size between 0.5*rad and 1.5*rad, where rad is the dot size
diff --git a/src/draw-context.h b/src/draw-context.h
index 42b270b823d2f1151b832cf88da81e25b94f52ce..30ebaa61d3a024f6eeab2398747eb9baf9312385 100644 (file)
--- a/src/draw-context.h
+++ b/src/draw-context.h
struct SPDrawContextClass : public SPEventContextClass{};
GType sp_draw_context_get_type(void);
-SPDrawAnchor *spdc_test_inside(SPDrawContext *dc, NR::Point p);
+SPDrawAnchor *spdc_test_inside(SPDrawContext *dc, Geom::Point p);
void spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed);
-void spdc_endpoint_snap_rotation(SPEventContext const *const ec, NR::Point &p, NR::Point const &o, guint state);
-void spdc_endpoint_snap_free(SPEventContext const *ec, NR::Point &p, guint state);
+void spdc_endpoint_snap_rotation(SPEventContext const *const ec, Geom::Point &p, Geom::Point const &o, guint state);
+void spdc_endpoint_snap_free(SPEventContext const *ec, Geom::Point &p, guint state);
void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item);
-void spdc_create_single_dot(SPEventContext *ec, NR::Point const &pt, char const *tool, guint event_state);
+void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char const *tool, guint event_state);
#endif
index e29865ff6c79029021891b101c3ba1361680ba3f..0cffd4bc55801faa5dbe2a6886c87d9148c8b793 100644 (file)
@@ -89,14 +89,14 @@ static gint sp_dyna_draw_context_root_handler(SPEventContext *ec, GdkEvent *even
static void clear_current(SPDynaDrawContext *dc);
static void set_to_accumulated(SPDynaDrawContext *dc, bool unionize);
-static void add_cap(SPCurve *curve, NR::Point const &from, NR::Point const &to, double rounding);
+static void add_cap(SPCurve *curve, Geom::Point const &from, Geom::Point const &to, double rounding);
static bool accumulate_calligraphic(SPDynaDrawContext *dc);
static void fit_and_split(SPDynaDrawContext *ddc, gboolean release);
-static void sp_dyna_draw_reset(SPDynaDrawContext *ddc, NR::Point p);
-static NR::Point sp_dyna_draw_get_npoint(SPDynaDrawContext const *ddc, NR::Point v);
-static NR::Point sp_dyna_draw_get_vpoint(SPDynaDrawContext const *ddc, NR::Point n);
+static void sp_dyna_draw_reset(SPDynaDrawContext *ddc, Geom::Point p);
+static Geom::Point sp_dyna_draw_get_npoint(SPDynaDrawContext const *ddc, Geom::Point v);
+static Geom::Point sp_dyna_draw_get_vpoint(SPDynaDrawContext const *ddc, Geom::Point n);
static void draw_temporary_box(SPDynaDrawContext *dc);
ddc->hatch_spacing_step = 0;
new (&ddc->hatch_pointer_past) std::list<double>();
new (&ddc->hatch_nearest_past) std::list<double>();
- ddc->hatch_last_nearest = NR::Point(0,0);
- ddc->hatch_last_pointer = NR::Point(0,0);
- ddc->hatch_vector_accumulated = NR::Point(0,0);
+ ddc->hatch_last_nearest = Geom::Point(0,0);
+ ddc->hatch_last_pointer = Geom::Point(0,0);
+ ddc->hatch_vector_accumulated = Geom::Point(0,0);
ddc->hatch_escaped = false;
ddc->hatch_area = NULL;
ddc->hatch_item = NULL;
}
/* Get normalized point */
-static NR::Point
-sp_dyna_draw_get_npoint(SPDynaDrawContext const *dc, NR::Point v)
+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 NR::Point(( v[NR::X] - drect.min()[NR::X] ) / max, ( v[NR::Y] - drect.min()[NR::Y] ) / max);
+ return Geom::Point(( v[NR::X] - drect.min()[NR::X] ) / max, ( v[NR::Y] - drect.min()[NR::Y] ) / max);
}
/* Get view point */
-static NR::Point
-sp_dyna_draw_get_vpoint(SPDynaDrawContext const *dc, NR::Point n)
+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 NR::Point(n[NR::X] * max + drect.min()[NR::X], n[NR::Y] * max + drect.min()[NR::Y]);
+ return Geom::Point(n[NR::X] * max + drect.min()[NR::X], n[NR::Y] * max + drect.min()[NR::Y]);
}
static void
-sp_dyna_draw_reset(SPDynaDrawContext *dc, NR::Point p)
+sp_dyna_draw_reset(SPDynaDrawContext *dc, Geom::Point p)
{
dc->last = dc->cur = sp_dyna_draw_get_npoint(dc, p);
- dc->vel = NR::Point(0,0);
+ dc->vel = Geom::Point(0,0);
dc->vel_max = 0;
- dc->acc = NR::Point(0,0);
- dc->ang = NR::Point(0,0);
- dc->del = NR::Point(0,0);
+ dc->acc = Geom::Point(0,0);
+ dc->ang = Geom::Point(0,0);
+ dc->del = Geom::Point(0,0);
}
static void
static gboolean
-sp_dyna_draw_apply(SPDynaDrawContext *dc, NR::Point p)
+sp_dyna_draw_apply(SPDynaDrawContext *dc, Geom::Point p)
{
- NR::Point n = sp_dyna_draw_get_npoint(dc, p);
+ Geom::Point n = sp_dyna_draw_get_npoint(dc, p);
/* Calculate mass and drag */
double const mass = flerp(1.0, 160.0, dc->mass);
double const drag = flerp(0.0, 0.5, dc->drag * dc->drag);
/* Calculate force and acceleration */
- NR::Point force = n - dc->cur;
+ Geom::Point force = n - dc->cur;
// If force is below the absolute threshold DYNA_EPSILON,
// or we haven't yet reached DYNA_VEL_START (i.e. at the beginning of stroke)
gdouble length = std::sqrt(dc->xtilt*dc->xtilt + dc->ytilt*dc->ytilt);;
if (length > 0) {
- NR::Point ang1 = NR::Point(dc->ytilt/length, dc->xtilt/length);
+ Geom::Point ang1 = Geom::Point(dc->ytilt/length, dc->xtilt/length);
a1 = atan2(ang1);
}
else
else {
// 1b. fixed dc->angle (absolutely flat nib):
double const radians = ( (dc->angle - 90) / 180.0 ) * M_PI;
- NR::Point ang1 = NR::Point(-sin(radians), cos(radians));
+ Geom::Point ang1 = Geom::Point(-sin(radians), cos(radians));
a1 = atan2(ang1);
}
if ( mag_vel < DYNA_EPSILON ) {
return FALSE;
}
- NR::Point ang2 = NR::rot90(dc->vel) / mag_vel;
+ Geom::Point ang2 = NR::rot90(dc->vel) / mag_vel;
// 3. Average them using flatness parameter:
// calculate angles
// Try to detect a sudden flip when the new angle differs too much from the previous for the
// current velocity; in that case discard this move
- double angle_delta = NR::L2(NR::Point (cos (new_ang), sin (new_ang)) - dc->ang);
+ double angle_delta = NR::L2(Geom::Point (cos (new_ang), sin (new_ang)) - dc->ang);
if ( angle_delta / NR::L2(dc->vel) > 4000 ) {
return FALSE;
}
// convert to point
- dc->ang = NR::Point (cos (new_ang), sin (new_ang));
+ dc->ang = Geom::Point (cos (new_ang), sin (new_ang));
// g_print ("force %g acc %g vel_max %g vel %g a1 %g a2 %g new_ang %g\n", NR::L2(force), NR::L2(dc->acc), dc->vel_max, NR::L2(dc->vel), a1, a2, new_ang);
// get the real brush point, not the same as pointer (affected by hatch tracking and/or mass
// drag)
- NR::Point brush = sp_dyna_draw_get_vpoint(dc, dc->cur);
- NR::Point brush_w = SP_EVENT_CONTEXT(dc)->desktop->d2w(brush);
+ Geom::Point brush = sp_dyna_draw_get_vpoint(dc, dc->cur);
+ Geom::Point brush_w = SP_EVENT_CONTEXT(dc)->desktop->d2w(brush);
double trace_thick = 1;
if (dc->trace_bg) {
dezoomify_factor /= SP_EVENT_CONTEXT(dc)->desktop->current_zoom();
}
- NR::Point del_left = dezoomify_factor * (width + tremble_left) * dc->ang;
- NR::Point del_right = dezoomify_factor * (width + tremble_right) * dc->ang;
+ Geom::Point del_left = dezoomify_factor * (width + tremble_left) * dc->ang;
+ Geom::Point del_right = dezoomify_factor * (width + tremble_right) * dc->ang;
dc->point1[dc->npoints] = brush + del_left;
dc->point2[dc->npoints] = brush - del_right;
return TRUE;
}
- NR::Point const button_w(event->button.x,
+ Geom::Point const button_w(event->button.x,
event->button.y);
- NR::Point const button_dt(desktop->w2d(button_w));
+ Geom::Point const button_dt(desktop->w2d(button_w));
sp_dyna_draw_reset(dc, button_dt);
sp_dyna_draw_extinput(dc, event);
sp_dyna_draw_apply(dc, button_dt);
break;
case GDK_MOTION_NOTIFY:
{
- NR::Point const motion_w(event->motion.x,
+ Geom::Point const motion_w(event->motion.x,
event->motion.y);
- NR::Point motion_dt(desktop->w2d(motion_w));
+ Geom::Point motion_dt(desktop->w2d(motion_w));
sp_dyna_draw_extinput(dc, event);
dc->_message_context->clear();
// for hatching:
double hatch_dist = 0;
- NR::Point hatch_unit_vector(0,0);
- NR::Point nearest(0,0);
- NR::Point pointer(0,0);
- NR::Matrix motion_to_curve(NR::identity());
+ Geom::Point hatch_unit_vector(0,0);
+ Geom::Point nearest(0,0);
+ Geom::Point pointer(0,0);
+ Geom::Matrix motion_to_curve(Geom::identity());
if (event->motion.state & GDK_CONTROL_MASK) { // hatching - sense the item
}
// This is the track pointer that we will use instead of the real one
- NR::Point new_pointer = nearest + target * hatch_unit_vector;
+ Geom::Point new_pointer = nearest + target * hatch_unit_vector;
// some limited feedback: allow persistent pulling to slightly change
// the spacing
if (event->motion.state & GDK_CONTROL_MASK) {
if (dc->hatch_spacing == 0 && hatch_dist != 0) {
// Haven't set spacing yet: gray, center free, update radius live
- NR::Point c = desktop->w2d(motion_w);
+ Geom::Point c = desktop->w2d(motion_w);
NR::Matrix const sm (NR::scale(hatch_dist, hatch_dist) * NR::translate(c));
sp_canvas_item_affine_absolute(dc->hatch_area, sm);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(dc->hatch_area), 0x7f7f7fff, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_item_show(dc->hatch_area);
} else if (dc->dragging && !dc->hatch_escaped) {
// Tracking: green, center snapped, fixed radius
- NR::Point c = motion_dt;
+ Geom::Point c = motion_dt;
NR::Matrix const sm (NR::scale(dc->hatch_spacing, dc->hatch_spacing) * NR::translate(c));
sp_canvas_item_affine_absolute(dc->hatch_area, sm);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(dc->hatch_area), 0x00FF00ff, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_item_show(dc->hatch_area);
} else if (dc->dragging && dc->hatch_escaped) {
// Tracking escaped: red, center free, fixed radius
- NR::Point c = desktop->w2d(motion_w);
+ Geom::Point c = desktop->w2d(motion_w);
NR::Matrix const sm (NR::scale(dc->hatch_spacing, dc->hatch_spacing) * NR::translate(c));
sp_canvas_item_affine_absolute(dc->hatch_area, sm);
sp_canvas_item_show(dc->hatch_area);
} else {
// Not drawing but spacing set: gray, center snapped, fixed radius
- NR::Point c = (nearest + dc->hatch_spacing * hatch_unit_vector) * motion_to_curve.inverse();
+ Geom::Point c = (nearest + dc->hatch_spacing * hatch_unit_vector) * motion_to_curve.inverse();
if (!IS_NAN(c[NR::X]) && !IS_NAN(c[NR::Y])) {
NR::Matrix const sm (NR::scale(dc->hatch_spacing, dc->hatch_spacing) * NR::translate(c));
sp_canvas_item_affine_absolute(dc->hatch_area, sm);
case GDK_BUTTON_RELEASE:
{
- NR::Point const motion_w(event->button.x, event->button.y);
- NR::Point const motion_dt(desktop->w2d(motion_w));
+ Geom::Point const motion_w(event->button.x, event->button.y);
+ Geom::Point const motion_dt(desktop->w2d(motion_w));
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time);
sp_canvas_end_forced_full_redraws(desktop->canvas);
if (!dc->hatch_pointer_past.empty()) dc->hatch_pointer_past.clear();
if (!dc->hatch_nearest_past.empty()) dc->hatch_nearest_past.clear();
- dc->hatch_last_nearest = NR::Point(0,0);
- dc->hatch_last_pointer = NR::Point(0,0);
- dc->hatch_vector_accumulated = NR::Point(0,0);
+ dc->hatch_last_nearest = Geom::Point(0,0);
+ dc->hatch_last_pointer = Geom::Point(0,0);
+ dc->hatch_vector_accumulated = Geom::Point(0,0);
dc->hatch_escaped = false;
dc->hatch_item = NULL;
dc->hatch_livarot_path = NULL;
static void
add_cap(SPCurve *curve,
- NR::Point const &from,
- NR::Point const &to,
+ Geom::Point const &from,
+ Geom::Point const &to,
double rounding)
{
if (NR::L2( to - from ) > DYNA_EPSILON) {
- NR::Point vel = rounding * NR::rot90( to - from ) / sqrt(2.0);
+ Geom::Point vel = rounding * NR::rot90( to - from ) / sqrt(2.0);
double mag = NR::L2(vel);
- NR::Point v = mag * NR::rot90( to - from ) / NR::L2( to - from );
+ Geom::Point v = mag * NR::rot90( to - from ) / NR::L2( to - from );
curve->curveto(from + v, to + v, to);
}
}
dc->cal2->moveto(dc->point2[0]);
}
- NR::Point b1[BEZIER_MAX_LENGTH];
+ Geom::Point b1[BEZIER_MAX_LENGTH];
gint const nb1 = sp_bezier_fit_cubic_r(b1, dc->point1, dc->npoints,
tolerance_sq, BEZIER_MAX_BEZIERS);
g_assert( nb1 * BEZIER_SIZE <= gint(G_N_ELEMENTS(b1)) );
- NR::Point b2[BEZIER_MAX_LENGTH];
+ Geom::Point b2[BEZIER_MAX_LENGTH];
gint const nb2 = sp_bezier_fit_cubic_r(b2, dc->point2, dc->npoints,
tolerance_sq, BEZIER_MAX_BEZIERS);
g_assert( nb2 * BEZIER_SIZE <= gint(G_N_ELEMENTS(b2)) );
if (! release) {
dc->currentcurve->reset();
dc->currentcurve->moveto(b1[0]);
- for (NR::Point *bp1 = b1; bp1 < b1 + BEZIER_SIZE * nb1; bp1 += BEZIER_SIZE) {
+ for (Geom::Point *bp1 = b1; bp1 < b1 + BEZIER_SIZE * nb1; bp1 += BEZIER_SIZE) {
dc->currentcurve->curveto(bp1[1], bp1[2], bp1[3]);
}
dc->currentcurve->lineto(b2[BEZIER_SIZE*(nb2-1) + 3]);
- for (NR::Point *bp2 = b2 + BEZIER_SIZE * ( nb2 - 1 ); bp2 >= b2; bp2 -= BEZIER_SIZE) {
+ for (Geom::Point *bp2 = b2 + BEZIER_SIZE * ( nb2 - 1 ); bp2 >= b2; bp2 -= BEZIER_SIZE) {
dc->currentcurve->curveto(bp2[2], bp2[1], bp2[0]);
}
// FIXME: dc->segments is always NULL at this point??
}
/* Current calligraphic */
- for (NR::Point *bp1 = b1; bp1 < b1 + BEZIER_SIZE * nb1; bp1 += BEZIER_SIZE) {
+ for (Geom::Point *bp1 = b1; bp1 < b1 + BEZIER_SIZE * nb1; bp1 += BEZIER_SIZE) {
dc->cal1->curveto(bp1[1], bp1[2], bp1[3]);
}
- for (NR::Point *bp2 = b2; bp2 < b2 + BEZIER_SIZE * nb2; bp2 += BEZIER_SIZE) {
+ for (Geom::Point *bp2 = b2; bp2 < b2 + BEZIER_SIZE * nb2; bp2 += BEZIER_SIZE) {
dc->cal2->curveto(bp2[1], bp2[2], bp2[3]);
}
} else {
index 09bc73e29d8fce0d18046417993aa5abd07dcde4..ddab2b53cf4128c062d0123889e1ecbe60a42bba 100644 (file)
--- a/src/dyna-draw-context.h
+++ b/src/dyna-draw-context.h
Path *hatch_livarot_path;
std::list<double> hatch_nearest_past;
std::list<double> hatch_pointer_past;
- NR::Point hatch_last_nearest, hatch_last_pointer;
- NR::Point hatch_vector_accumulated;
+ Geom::Point hatch_last_nearest, hatch_last_pointer;
+ Geom::Point hatch_vector_accumulated;
bool hatch_escaped;
SPCanvasItem *hatch_area;
diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp
index ccbb877905e91a6e140555c69990cc534b91e246..86d5e66dc831aa60d1c11ea76580c9f9ece65a02 100644 (file)
--- a/src/eraser-context.cpp
+++ b/src/eraser-context.cpp
@@ -89,14 +89,14 @@ static gint sp_eraser_context_root_handler(SPEventContext *ec, GdkEvent *event);
static void clear_current(SPEraserContext *dc);
static void set_to_accumulated(SPEraserContext *dc);
-static void add_cap(SPCurve *curve, NR::Point const &pre, NR::Point const &from, NR::Point const &to, NR::Point const &post, double rounding);
+static void add_cap(SPCurve *curve, Geom::Point const &pre, Geom::Point const &from, Geom::Point const &to, Geom::Point const &post, double rounding);
static void accumulate_eraser(SPEraserContext *dc);
static void fit_and_split(SPEraserContext *erc, gboolean release);
-static void sp_eraser_reset(SPEraserContext *erc, NR::Point p);
-static NR::Point sp_eraser_get_npoint(SPEraserContext const *erc, NR::Point v);
-static NR::Point sp_eraser_get_vpoint(SPEraserContext const *erc, NR::Point n);
+static void sp_eraser_reset(SPEraserContext *erc, Geom::Point p);
+static Geom::Point sp_eraser_get_npoint(SPEraserContext const *erc, Geom::Point v);
+static Geom::Point sp_eraser_get_vpoint(SPEraserContext const *erc, Geom::Point n);
static void draw_temporary_box(SPEraserContext *dc);
}
/* Get normalized point */
-static NR::Point
-sp_eraser_get_npoint(SPEraserContext const *dc, NR::Point v)
+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 NR::Point(( v[NR::X] - drect.min()[NR::X] ) / max, ( v[NR::Y] - drect.min()[NR::Y] ) / max);
+ return Geom::Point(( v[NR::X] - drect.min()[NR::X] ) / max, ( v[NR::Y] - drect.min()[NR::Y] ) / max);
}
/* Get view point */
-static NR::Point
-sp_eraser_get_vpoint(SPEraserContext const *dc, NR::Point n)
+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 NR::Point(n[NR::X] * max + drect.min()[NR::X], n[NR::Y] * max + drect.min()[NR::Y]);
+ return Geom::Point(n[NR::X] * max + drect.min()[NR::X], n[NR::Y] * max + drect.min()[NR::Y]);
}
static void
-sp_eraser_reset(SPEraserContext *dc, NR::Point p)
+sp_eraser_reset(SPEraserContext *dc, Geom::Point p)
{
dc->last = dc->cur = sp_eraser_get_npoint(dc, p);
- dc->vel = NR::Point(0,0);
+ dc->vel = Geom::Point(0,0);
dc->vel_max = 0;
- dc->acc = NR::Point(0,0);
- dc->ang = NR::Point(0,0);
- dc->del = NR::Point(0,0);
+ dc->acc = Geom::Point(0,0);
+ dc->ang = Geom::Point(0,0);
+ dc->del = Geom::Point(0,0);
}
static void
static gboolean
-sp_eraser_apply(SPEraserContext *dc, NR::Point p)
+sp_eraser_apply(SPEraserContext *dc, Geom::Point p)
{
- NR::Point n = sp_eraser_get_npoint(dc, p);
+ Geom::Point n = sp_eraser_get_npoint(dc, p);
/* Calculate mass and drag */
double const mass = flerp(1.0, 160.0, dc->mass);
double const drag = flerp(0.0, 0.5, dc->drag * dc->drag);
/* Calculate force and acceleration */
- NR::Point force = n - dc->cur;
+ Geom::Point force = n - dc->cur;
// If force is below the absolute threshold ERASER_EPSILON,
// or we haven't yet reached ERASER_VEL_START (i.e. at the beginning of stroke)
gdouble length = std::sqrt(dc->xtilt*dc->xtilt + dc->ytilt*dc->ytilt);;
if (length > 0) {
- NR::Point ang1 = NR::Point(dc->ytilt/length, dc->xtilt/length);
+ Geom::Point ang1 = Geom::Point(dc->ytilt/length, dc->xtilt/length);
a1 = atan2(ang1);
}
else
else {
// 1b. fixed dc->angle (absolutely flat nib):
double const radians = ( (dc->angle - 90) / 180.0 ) * M_PI;
- NR::Point ang1 = NR::Point(-sin(radians), cos(radians));
+ Geom::Point ang1 = Geom::Point(-sin(radians), cos(radians));
a1 = atan2(ang1);
}
if ( mag_vel < ERASER_EPSILON ) {
return FALSE;
}
- NR::Point ang2 = NR::rot90(dc->vel) / mag_vel;
+ Geom::Point ang2 = NR::rot90(dc->vel) / mag_vel;
// 3. Average them using flatness parameter:
// calculate angles
// Try to detect a sudden flip when the new angle differs too much from the previous for the
// current velocity; in that case discard this move
- double angle_delta = NR::L2(NR::Point (cos (new_ang), sin (new_ang)) - dc->ang);
+ double angle_delta = NR::L2(Geom::Point (cos (new_ang), sin (new_ang)) - dc->ang);
if ( angle_delta / NR::L2(dc->vel) > 4000 ) {
return FALSE;
}
// convert to point
- dc->ang = NR::Point (cos (new_ang), sin (new_ang));
+ dc->ang = Geom::Point (cos (new_ang), sin (new_ang));
// g_print ("force %g acc %g vel_max %g vel %g a1 %g a2 %g new_ang %g\n", NR::L2(force), NR::L2(dc->acc), dc->vel_max, NR::L2(dc->vel), a1, a2, new_ang);
// get the real brush point, not the same as pointer (affected by hatch tracking and/or mass
// drag)
- NR::Point brush = sp_eraser_get_vpoint(dc, dc->cur);
- NR::Point brush_w = SP_EVENT_CONTEXT(dc)->desktop->d2w(brush);
+ Geom::Point brush = sp_eraser_get_vpoint(dc, dc->cur);
+ Geom::Point brush_w = SP_EVENT_CONTEXT(dc)->desktop->d2w(brush);
double trace_thick = 1;
dezoomify_factor /= SP_EVENT_CONTEXT(dc)->desktop->current_zoom();
}
- NR::Point del_left = dezoomify_factor * (width + tremble_left) * dc->ang;
- NR::Point del_right = dezoomify_factor * (width + tremble_right) * dc->ang;
+ Geom::Point del_left = dezoomify_factor * (width + tremble_left) * dc->ang;
+ Geom::Point del_right = dezoomify_factor * (width + tremble_right) * dc->ang;
dc->point1[dc->npoints] = brush + del_left;
dc->point2[dc->npoints] = brush - del_right;
return TRUE;
}
- NR::Point const button_w(event->button.x,
+ Geom::Point const button_w(event->button.x,
event->button.y);
- NR::Point const button_dt(desktop->w2d(button_w));
+ Geom::Point const button_dt(desktop->w2d(button_w));
sp_eraser_reset(dc, button_dt);
sp_eraser_extinput(dc, event);
sp_eraser_apply(dc, button_dt);
break;
case GDK_MOTION_NOTIFY:
{
- NR::Point const motion_w(event->motion.x,
+ Geom::Point const motion_w(event->motion.x,
event->motion.y);
- NR::Point motion_dt(desktop->w2d(motion_w));
+ Geom::Point motion_dt(desktop->w2d(motion_w));
sp_eraser_extinput(dc, event);
dc->_message_context->clear();
case GDK_BUTTON_RELEASE:
{
- NR::Point const motion_w(event->button.x, event->button.y);
- NR::Point const motion_dt(desktop->w2d(motion_w));
+ Geom::Point const motion_w(event->button.x, event->button.y);
+ Geom::Point const motion_dt(desktop->w2d(motion_w));
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time);
sp_canvas_end_forced_full_redraws(desktop->canvas);
static void
add_cap(SPCurve *curve,
- NR::Point const &pre, NR::Point const &from,
- NR::Point const &to, NR::Point const &post,
+ Geom::Point const &pre, Geom::Point const &from,
+ Geom::Point const &to, Geom::Point const &post,
double rounding)
{
- NR::Point vel = rounding * NR::rot90( to - from ) / sqrt(2.0);
+ Geom::Point vel = rounding * NR::rot90( to - from ) / sqrt(2.0);
double mag = NR::L2(vel);
- NR::Point v_in = from - pre;
+ Geom::Point v_in = from - pre;
double mag_in = NR::L2(v_in);
if ( mag_in > ERASER_EPSILON ) {
v_in = mag * v_in / mag_in;
} else {
- v_in = NR::Point(0, 0);
+ v_in = Geom::Point(0, 0);
}
- NR::Point v_out = to - post;
+ Geom::Point v_out = to - post;
double mag_out = NR::L2(v_out);
if ( mag_out > ERASER_EPSILON ) {
v_out = mag * v_out / mag_out;
} else {
- v_out = NR::Point(0, 0);
+ v_out = Geom::Point(0, 0);
}
if ( NR::L2(v_in) > ERASER_EPSILON || NR::L2(v_out) > ERASER_EPSILON ) {
dc->cal2->moveto(dc->point2[0]);
}
- NR::Point b1[BEZIER_MAX_LENGTH];
+ Geom::Point b1[BEZIER_MAX_LENGTH];
gint const nb1 = sp_bezier_fit_cubic_r(b1, dc->point1, dc->npoints,
tolerance_sq, BEZIER_MAX_BEZIERS);
g_assert( nb1 * BEZIER_SIZE <= gint(G_N_ELEMENTS(b1)) );
- NR::Point b2[BEZIER_MAX_LENGTH];
+ Geom::Point b2[BEZIER_MAX_LENGTH];
gint const nb2 = sp_bezier_fit_cubic_r(b2, dc->point2, dc->npoints,
tolerance_sq, BEZIER_MAX_BEZIERS);
g_assert( nb2 * BEZIER_SIZE <= gint(G_N_ELEMENTS(b2)) );
if (! release) {
dc->currentcurve->reset();
dc->currentcurve->moveto(b1[0]);
- for (NR::Point *bp1 = b1; bp1 < b1 + BEZIER_SIZE * nb1; bp1 += BEZIER_SIZE) {
+ for (Geom::Point *bp1 = b1; bp1 < b1 + BEZIER_SIZE * nb1; bp1 += BEZIER_SIZE) {
dc->currentcurve->curveto(bp1[1],
bp1[2], bp1[3]);
}
dc->currentcurve->lineto(b2[BEZIER_SIZE*(nb2-1) + 3]);
- for (NR::Point *bp2 = b2 + BEZIER_SIZE * ( nb2 - 1 ); bp2 >= b2; bp2 -= BEZIER_SIZE) {
+ for (Geom::Point *bp2 = b2 + BEZIER_SIZE * ( nb2 - 1 ); bp2 >= b2; bp2 -= BEZIER_SIZE) {
dc->currentcurve->curveto(bp2[2], bp2[1], bp2[0]);
}
// FIXME: dc->segments is always NULL at this point??
}
/* Current eraser */
- for (NR::Point *bp1 = b1; bp1 < b1 + BEZIER_SIZE * nb1; bp1 += BEZIER_SIZE) {
+ for (Geom::Point *bp1 = b1; bp1 < b1 + BEZIER_SIZE * nb1; bp1 += BEZIER_SIZE) {
dc->cal1->curveto(bp1[1], bp1[2], bp1[3]);
}
- for (NR::Point *bp2 = b2; bp2 < b2 + BEZIER_SIZE * nb2; bp2 += BEZIER_SIZE) {
+ for (Geom::Point *bp2 = b2; bp2 < b2 + BEZIER_SIZE * nb2; bp2 += BEZIER_SIZE) {
dc->cal2->curveto(bp2[1], bp2[2], bp2[3]);
}
} else {
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index 8e54bf89cf127064d3f21393899a2d6292a5a2d5..7a6276dde05d20d930b35269c7c7063ea7093b30 100644 (file)
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
static void node_clicked(SPKnot *knot, guint state, gpointer data);
static void node_grabbed(SPKnot *knot, guint state, gpointer data);
static void node_ungrabbed(SPKnot *knot, guint state, gpointer data);
-static gboolean node_request(SPKnot *knot, NR::Point *p, guint state, gpointer data);
+static gboolean node_request(SPKnot *knot, Geom::Point *p, guint state, gpointer data);
/* Handle event callbacks */
static void node_handle_clicked(SPKnot *knot, guint state, gpointer data);
static void node_handle_grabbed(SPKnot *knot, guint state, gpointer data);
static void node_handle_ungrabbed(SPKnot *knot, guint state, gpointer data);
-static gboolean node_handle_request(SPKnot *knot, NR::Point *p, guint state, gpointer data);
-static void node_handle_moved(SPKnot *knot, NR::Point *p, guint state, gpointer data);
+static gboolean node_handle_request(SPKnot *knot, Geom::Point *p, guint state, gpointer data);
+static void node_handle_moved(SPKnot *knot, Geom::Point *p, guint state, gpointer data);
static gboolean node_handle_event(SPKnot *knot, GdkEvent *event, Inkscape::NodePath::Node *n);
/* Constructors and destructors */
static void sp_nodepath_subpath_close(Inkscape::NodePath::SubPath *sp);
static void sp_nodepath_subpath_open(Inkscape::NodePath::SubPath *sp,Inkscape::NodePath::Node *n);
static Inkscape::NodePath::Node * sp_nodepath_node_new(Inkscape::NodePath::SubPath *sp,Inkscape::NodePath::Node *next,Inkscape::NodePath::NodeType type, NRPathcode code,
- NR::Point *ppos, NR::Point *pos, NR::Point *npos);
+ Geom::Point *ppos, Geom::Point *pos, Geom::Point *npos);
static void sp_nodepath_node_destroy(Inkscape::NodePath::Node *node);
/* Helpers */
@@ -533,7 +533,7 @@ static void subpaths_from_pathvector(Inkscape::NodePath::Path *np, Geom::PathVec
Inkscape::NodePath::SubPath *sp = sp_nodepath_subpath_new(np);
- NR::Point ppos = pit->initialPoint() * (Geom::Matrix)np->i2d;
+ Geom::Point ppos = pit->initialPoint() * (Geom::Matrix)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)*/
@@ -542,7 +542,7 @@ static void subpaths_from_pathvector(Inkscape::NodePath::Path *np, Geom::PathVec
dynamic_cast<Geom::HLineSegment const*>(&*cit) ||
dynamic_cast<Geom::VLineSegment const*>(&*cit) )
{
- NR::Point pos = cit->initialPoint() * (Geom::Matrix)np->i2d;
+ Geom::Point pos = cit->initialPoint() * (Geom::Matrix)np->i2d;
sp_nodepath_node_new(sp, NULL, t[i++], pcode, &ppos, &pos, &pos);
ppos = cit->finalPoint() * (Geom::Matrix)np->i2d;
@@ -550,8 +550,8 @@ static void subpaths_from_pathvector(Inkscape::NodePath::Path *np, Geom::PathVec
}
else if(Geom::CubicBezier const *cubic_bezier = dynamic_cast<Geom::CubicBezier const*>(&*cit)) {
std::vector<Geom::Point> points = cubic_bezier->points();
- NR::Point pos = points[0] * (Geom::Matrix)np->i2d;
- NR::Point npos = points[1] * (Geom::Matrix)np->i2d;
+ Geom::Point pos = points[0] * (Geom::Matrix)np->i2d;
+ Geom::Point npos = points[1] * (Geom::Matrix)np->i2d;
sp_nodepath_node_new(sp, NULL, t[i++], pcode, &ppos, &pos, &npos);
ppos = points[2] * (Geom::Matrix)np->i2d;
@@ -566,7 +566,7 @@ static void subpaths_from_pathvector(Inkscape::NodePath::Path *np, Geom::PathVec
Geom::Curve const &closing_seg = pit->back_closed();
// Don't use !closing_seg.isDegenerate() as it is too precise, and does not account for floating point rounding probs (LP bug #257289)
if ( ! are_near(closing_seg.initialPoint(), closing_seg.finalPoint()) ) {
- NR::Point pos = closing_seg.finalPoint() * (Geom::Matrix)np->i2d;
+ Geom::Point pos = closing_seg.finalPoint() * (Geom::Matrix)np->i2d;
sp_nodepath_node_new(sp, NULL, t[i++], NR_LINETO, &pos, &pos, &pos);
}
for (GList *spl = np->subpaths; spl != NULL; spl = spl->next) {
Inkscape::NodePath::SubPath *sp = (Inkscape::NodePath::SubPath *) spl->data;
- curve->moveto(sp->first->pos * np->d2i);
+ curve->moveto(sp->first->pos * np->d2i);
Inkscape::NodePath::Node *n = sp->first->n.other;
while (n) {
- NR::Point const end_pt = n->pos * np->d2i;
+ Geom::Point const end_pt = n->pos * np->d2i;
switch (n->code) {
case NR_LINETO:
curve->lineto(end_pt);
@@ -1045,7 +1045,7 @@ static void sp_nodepath_set_line_type(Inkscape::NodePath::Node *end, NRPathcode
}
}
} else {
- NR::Point delta = end->pos - start->pos;
+ Geom::Point delta = end->pos - start->pos;
start->n.pos = start->pos + delta / 3;
end->p.pos = end->pos - delta / 3;
sp_node_adjust_handle(start, 1);
@@ -1206,13 +1206,13 @@ void sp_nodepath_convert_node_type(Inkscape::NodePath::Node *node, Inkscape::Nod
node->code = NR_CURVETO;
node->n.other->code = NR_CURVETO;
- NR::Point leg_prev = node->pos - node->p.other->pos;
- NR::Point leg_next = node->pos - node->n.other->pos;
+ Geom::Point leg_prev = node->pos - node->p.other->pos;
+ Geom::Point leg_next = node->pos - node->n.other->pos;
double norm_leg_prev = L2(leg_prev);
double norm_leg_next = L2(leg_next);
- NR::Point delta;
+ Geom::Point delta;
if (norm_leg_next > 0.0) {
delta = (norm_leg_prev / norm_leg_next) * leg_next - leg_prev;
(&delta)->normalize();
@@ -1259,9 +1259,9 @@ void sp_nodepath_convert_node_type(Inkscape::NodePath::Node *node, Inkscape::Nod
/**
* Move node to point, and adjust its and neighbouring handles.
*/
-void sp_node_moveto(Inkscape::NodePath::Node *node, NR::Point p)
+void sp_node_moveto(Inkscape::NodePath::Node *node, Geom::Point p)
{
- NR::Point delta = p - node->pos;
+ Geom::Point delta = p - node->pos;
node->pos = p;
node->p.pos += delta;
@@ -1304,8 +1304,8 @@ static void sp_nodepath_selected_nodes_move(Inkscape::NodePath::Path *nodepath,
Inkscape::Snapper::ConstraintLine const &constraint = Geom::Point())
{
NR::Coord best = NR_HUGE;
- NR::Point delta(dx, dy);
- NR::Point best_pt = delta;
+ Geom::Point delta(dx, dy);
+ Geom::Point best_pt = delta;
Inkscape::SnappedPoint best_abs;
if (snap) {
}
double
-bezier_length (NR::Point a, NR::Point ah, NR::Point bh, NR::Point b)
+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);
}
void
-sp_nodepath_move_node_and_handles (Inkscape::NodePath::Node *n, NR::Point delta, NR::Point delta_n, NR::Point delta_p)
+sp_nodepath_move_node_and_handles (Inkscape::NodePath::Node *n, Geom::Point delta, Geom::Point delta_n, Geom::Point delta_p)
{
n->pos = n->origin + delta;
n->n.pos = n->n.origin + delta_n;
@@ -1418,7 +1418,7 @@ sp_nodepath_move_node_and_handles (Inkscape::NodePath::Node *n, NR::Point delta,
* on how far they are from the dragged node n.
*/
static void
-sp_nodepath_selected_nodes_sculpt(Inkscape::NodePath::Path *nodepath, Inkscape::NodePath::Node *n, NR::Point delta)
+sp_nodepath_selected_nodes_sculpt(Inkscape::NodePath::Path *nodepath, Inkscape::NodePath::Node *n, Geom::Point delta)
{
g_assert (n);
g_assert (nodepath);
/**
* Align selected nodes on the specified axis.
*/
-void sp_nodepath_selected_align(Inkscape::NodePath::Path *nodepath, NR::Dim2 axis)
+void sp_nodepath_selected_align(Inkscape::NodePath::Path *nodepath, Geom::Dim2 axis)
{
if ( !nodepath || !nodepath->selected ) { // no nodepath, or no nodes selected
return;
@@ -1832,7 +1832,7 @@ void sp_nodepath_selected_align(Inkscape::NodePath::Path *nodepath, NR::Dim2 axi
return;
}
Inkscape::NodePath::Node *pNode = reinterpret_cast<Inkscape::NodePath::Node *>(nodepath->selected->data);
- NR::Point dest(pNode->pos);
+ Geom::Point dest(pNode->pos);
for (GList *l = nodepath->selected; l != NULL; l = l->next) {
pNode = reinterpret_cast<Inkscape::NodePath::Node *>(l->data);
if (pNode) {
Inkscape::NodePath::Node *_node;
NR::Coord _coord;
/// \todo use vectorof pointers instead of calling copy ctor
- NodeSort(Inkscape::NodePath::Node *node, NR::Dim2 axis) :
+ NodeSort(Inkscape::NodePath::Node *node, Geom::Dim2 axis) :
_node(node), _coord(node->pos[axis])
{}
/**
* Distribute selected nodes on the specified axis.
*/
-void sp_nodepath_selected_distribute(Inkscape::NodePath::Path *nodepath, NR::Dim2 axis)
+void sp_nodepath_selected_distribute(Inkscape::NodePath::Path *nodepath, Geom::Dim2 axis)
{
if ( !nodepath || !nodepath->selected ) { // no nodepath, or no nodes selected
return;
@@ -1897,7 +1897,7 @@ void sp_nodepath_selected_distribute(Inkscape::NodePath::Path *nodepath, NR::Dim
it < sorted.end();
it ++ )
{
- NR::Point dest((*it)._node->pos);
+ Geom::Point dest((*it)._node->pos);
dest[axis] = pos;
sp_node_moveto((*it)._node, dest);
pos += step;
* Select segment nearest to point
*/
void
-sp_nodepath_select_segment_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p, bool toggle)
+sp_nodepath_select_segment_near_point(Inkscape::NodePath::Path *nodepath, Geom::Point p, bool toggle)
{
if (!nodepath) {
return;
@@ -2001,7 +2001,7 @@ sp_nodepath_select_segment_near_point(Inkscape::NodePath::Path *nodepath, NR::Po
* Add a node nearest to point
*/
void
-sp_nodepath_add_node_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p)
+sp_nodepath_add_node_near_point(Inkscape::NodePath::Path *nodepath, Geom::Point p)
{
if (!nodepath) {
return;
@@ -2055,7 +2055,7 @@ sp_nodepath_add_node_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p)
* cf. app/vectors/gimpbezierstroke.c, gimp_bezier_stroke_point_move_relative()
*/
void
-sp_nodepath_curve_drag(Inkscape::NodePath::Path *nodepath, int node, double t, NR::Point delta)
+sp_nodepath_curve_drag(Inkscape::NodePath::Path *nodepath, int node, double t, Geom::Point delta)
{
Inkscape::NodePath::Node *e = sp_nodepath_get_node_by_index(nodepath, node);
@@ -2082,8 +2082,8 @@ sp_nodepath_curve_drag(Inkscape::NodePath::Path *nodepath, int node, double t, N
sp_nodepath_set_line_type(e, NR_CURVETO);
}
- NR::Point offsetcoord0 = ((1-feel_good)/(3*t*(1-t)*(1-t))) * delta;
- NR::Point offsetcoord1 = (feel_good/(3*t*t*(1-t))) * delta;
+ Geom::Point offsetcoord0 = ((1-feel_good)/(3*t*(1-t)*(1-t))) * delta;
+ Geom::Point offsetcoord1 = (feel_good/(3*t*t*(1-t))) * delta;
e->p.other->n.pos += offsetcoord0;
e->p.pos += offsetcoord1;
@@ -2165,7 +2165,7 @@ static void do_node_selected_join(Inkscape::NodePath::Path *nodepath, Inkscape::
/* a and b are endpoints */
// if one of the two nodes is mouseovered, fix its position
- NR::Point c;
+ Geom::Point c;
if (a->knot && SP_KNOT_IS_MOUSEOVER(a->knot)) {
c = a->pos;
} else if (b->knot && SP_KNOT_IS_MOUSEOVER(b->knot)) {
@@ -2188,7 +2188,7 @@ static void do_node_selected_join(Inkscape::NodePath::Path *nodepath, Inkscape::
/* a and b are separate subpaths */
Inkscape::NodePath::SubPath *sa = a->subpath;
Inkscape::NodePath::SubPath *sb = b->subpath;
- NR::Point p;
+ Geom::Point p;
Inkscape::NodePath::Node *n;
NRPathcode code;
if (a == sa->first) {
@@ -2279,7 +2279,7 @@ static void do_node_selected_join_segment(Inkscape::NodePath::Path *nodepath, In
Inkscape::NodePath::SubPath *sb = b->subpath;
Inkscape::NodePath::Node *n;
- NR::Point p;
+ Geom::Point p;
NRPathcode code;
if (a == sa->first) {
code = (NRPathcode) sa->first->n.other->code;
//calculate points for each segment
int rate = 5;
float period = 1.0 / rate;
- std::vector<NR::Point> data;
+ std::vector<Geom::Point> data;
if (!just_delete) {
data.push_back(sample_cursor->pos);
for (Inkscape::NodePath::Node *curr=sample_cursor; curr; curr=curr->n.other) {
}
//sample points on the contiguous selected segment
- NR::Point *bez;
- bez = new NR::Point [4];
+ Geom::Point *bez;
+ bez = new Geom::Point [4];
bez[0] = curr->pos;
bez[1] = curr->n.pos;
bez[2] = curr->n.other->p.pos;
bez[3] = curr->n.other->pos;
for (int i=1; i<rate; i++) {
gdouble t = i * period;
- NR::Point p = bezier_pt(3, bez, t);
+ Geom::Point p = bezier_pt(3, bez, t);
data.push_back(p);
}
data.push_back(curr->n.other->pos);
if (!just_delete) {
//calculate the best fitting single segment and adjust the endpoints
- NR::Point *adata;
- adata = new NR::Point [data.size()];
+ Geom::Point *adata;
+ adata = new Geom::Point [data.size()];
copy(data.begin(), data.end(), adata);
- NR::Point *bez;
- bez = new NR::Point [4];
+ Geom::Point *bez;
+ bez = new Geom::Point [4];
//would decreasing error create a better fitting approximation?
gdouble error = 1.0;
gint ret;
@@ -3246,7 +3246,7 @@ static void sp_node_adjust_handle(Inkscape::NodePath::Node *node, gint which_adj
// 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);
- NR::Point delta = node->pos - othernode->pos;
+ Geom::Point delta = node->pos - othernode->pos;
double linelen = NR::L2(delta);
if (linelen < 1e-18)
return;
@@ -3261,7 +3261,7 @@ static void sp_node_adjust_handle(Inkscape::NodePath::Node *node, gint which_adj
} else {
// smoothify
double len = NR::L2(me->pos - node->pos);
- NR::Point delta = other->pos - node->pos;
+ Geom::Point delta = other->pos - node->pos;
double otherlen = NR::L2(delta);
if (otherlen < 1e-18) return;
me->pos = node->pos - (len / otherlen) * delta;
}
/* both are curves */
- NR::Point const delta( node->n.pos - node->p.pos );
+ Geom::Point const delta( node->n.pos - node->p.pos );
if (node->type == Inkscape::NodePath::NODE_SYMM) {
node->p.pos = node->pos - delta / 2;
@@ -3497,10 +3497,10 @@ static void node_ungrabbed(SPKnot */*knot*/, guint /*state*/, gpointer data)
* \param closest Pointer to the point struct where the result is stored.
* \todo FIXME: use dot product perhaps?
*/
-static void point_line_closest(NR::Point *p, double a, NR::Point *closest)
+static void point_line_closest(Geom::Point *p, double a, Geom::Point *closest)
{
if (a == HUGE_VAL) { // vertical
- *closest = NR::Point(0, (*p)[NR::Y]);
+ *closest = Geom::Point(0, (*p)[NR::Y]);
} else {
(*closest)[NR::X] = ( a * (*p)[NR::Y] + (*p)[NR::X]) / (a*a + 1);
(*closest)[NR::Y] = a * (*closest)[NR::X];
* \param p A point.
* \param a Angle of the line; it is assumed to go through coordinate origin.
*/
-static double point_line_distance(NR::Point *p, double a)
+static double point_line_distance(Geom::Point *p, double a)
{
- NR::Point c;
+ 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]));
}
* \todo fixme: This goes to "moved" event? (lauris)
*/
static gboolean
-node_request(SPKnot */*knot*/, NR::Point *p, guint state, gpointer data)
+node_request(SPKnot */*knot*/, Geom::Point *p, guint state, gpointer data)
{
double yn, xn, yp, xp;
double an, ap, na, pa;
double d_an, d_ap, d_na, d_pa;
gboolean collinear = FALSE;
- NR::Point c;
- NR::Point pr;
+ Geom::Point c;
+ Geom::Point pr;
Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) data;
( ((state & GDK_SHIFT_MASK) && ((n->n.other && n->n.pos == n->pos) || (n->p.other && n->p.pos == n->pos)))
|| n->dragging_out ) )
{
- NR::Point mouse = (*p);
+ Geom::Point mouse = (*p);
if (!n->dragging_out) {
// This is the first drag-out event; find out which handle to drag out
// if there's another handle, make sure the one we drag out starts parallel to it
if (opposite->pos != n->pos) {
- mouse = n->pos - NR::L2(mouse - n->pos) * NR::unit_vector(opposite->pos - n->pos);
+ mouse = n->pos - Geom::L2(mouse - n->pos) * Geom::unit_vector(opposite->pos - n->pos);
}
// knots might not be created yet!
/**
* Node handle "request" signal callback.
*/
-static gboolean node_handle_request(SPKnot *knot, NR::Point *p, guint state, gpointer data)
+static gboolean node_handle_request(SPKnot *knot, Geom::Point *p, guint state, gpointer data)
{
Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) data;
@@ -3823,10 +3823,10 @@ static gboolean node_handle_request(SPKnot *knot, NR::Point *p, guint state, gpo
if (othernode) {
if ((n->type != Inkscape::NodePath::NODE_CUSP) && sp_node_side_is_line(n, opposite)) {
/* We are smooth node adjacent with line */
- NR::Point const delta = *p - n->pos;
+ Geom::Point const delta = *p - n->pos;
NR::Coord const len = NR::L2(delta);
Inkscape::NodePath::Node *othernode = opposite->other;
- NR::Point const ndelta = n->pos - othernode->pos;
+ Geom::Point const ndelta = n->pos - othernode->pos;
NR::Coord const linelen = NR::L2(ndelta);
if (len > NR_EPSILON && linelen > NR_EPSILON) {
NR::Coord const scal = dot(delta, ndelta) / linelen;
@@ -3858,7 +3858,7 @@ static gboolean node_handle_request(SPKnot *knot, NR::Point *p, guint state, gpo
/**
* Node handle moved callback.
*/
-static void node_handle_moved(SPKnot *knot, NR::Point *p, guint state, gpointer data)
+static void node_handle_moved(SPKnot *knot, Geom::Point *p, guint state, gpointer data)
{
Inkscape::NodePath::Node *n = (Inkscape::NodePath::Node *) data;
@@ -3902,7 +3902,7 @@ static void node_handle_moved(SPKnot *knot, NR::Point *p, guint state, gpointer
// 3. Snap to the angle of the opposite line, if any
Inkscape::NodePath::Node *othernode = other->other;
if (othernode) {
- NR::Point other_to_snap(0,0);
+ Geom::Point other_to_snap(0,0);
if (sp_node_side_is_line(n, other)) {
other_to_snap = othernode->pos - n->pos;
} else {
@@ -3932,14 +3932,14 @@ static void node_handle_moved(SPKnot *knot, NR::Point *p, guint state, gpointer
&& rme.a != HUGE_VAL && rnew.a != HUGE_VAL && (fabs(rme.a - rnew.a) > 0.001 || n->type ==Inkscape::NodePath::NODE_SYMM)) {
// rotate the other handle correspondingly, if both old and new angles exist and are not the same
rother.a += rnew.a - rme.a;
- other->pos = NR::Point(rother) + n->pos;
+ other->pos = Geom::Point(rother) + n->pos;
if (other->knot) {
sp_ctrlline_set_coords(SP_CTRLLINE(other->line), n->pos, other->pos);
sp_knot_moveto(other->knot, other->pos);
}
}
- me->pos = NR::Point(rnew) + n->pos;
+ me->pos = Geom::Point(rnew) + n->pos;
sp_ctrlline_set_coords(SP_CTRLLINE(me->line), n->pos, me->pos);
// move knot, but without emitting the signal:
@@ -4100,10 +4100,10 @@ static void node_rotate_one (Inkscape::NodePath::Node *n, gdouble angle, int whi
node_rotate_one_internal (*n, angle, rme, rother, both);
}
- me->pos = n->pos + NR::Point(rme);
+ me->pos = n->pos + Geom::Point(rme);
if (both || n->type == Inkscape::NodePath::NODE_SMOOTH || n->type == Inkscape::NodePath::NODE_SYMM) {
- other->pos = n->pos + NR::Point(rother);
+ other->pos = n->pos + Geom::Point(rother);
}
// this function is only called from sp_nodepath_selected_nodes_rotate that will update display at the end,
@@ -4141,7 +4141,7 @@ void sp_nodepath_selected_nodes_rotate(Inkscape::NodePath::Path *nodepath, gdoub
rot = angle;
}
- NR::Point rot_center;
+ Geom::Point rot_center;
if (Inkscape::NodePath::Path::active_node == NULL)
rot_center = box.midpoint();
else
@@ -4238,10 +4238,10 @@ static void node_scale_one (Inkscape::NodePath::Node *n, gdouble grow, int which
}
}
- me->pos = n->pos + NR::Point(rme);
+ me->pos = n->pos + Geom::Point(rme);
if (both || n->type == Inkscape::NodePath::NODE_SYMM) {
- other->pos = n->pos + NR::Point(rother);
+ other->pos = n->pos + Geom::Point(rother);
}
// this function is only called from sp_nodepath_selected_nodes_scale that will update display at the end,
@@ -4272,7 +4272,7 @@ void sp_nodepath_selected_nodes_scale(Inkscape::NodePath::Path *nodepath, gdoubl
double scale = (box.maxExtent() + grow)/box.maxExtent();
- NR::Point scale_center;
+ Geom::Point scale_center;
if (Inkscape::NodePath::Path::active_node == NULL)
scale_center = box.midpoint();
else
@@ -4304,7 +4304,7 @@ void sp_nodepath_selected_nodes_scale_screen(Inkscape::NodePath::Path *nodepath,
/**
* Flip selected nodes horizontally/vertically.
*/
-void sp_nodepath_flip (Inkscape::NodePath::Path *nodepath, NR::Dim2 axis, boost::optional<NR::Point> center)
+void sp_nodepath_flip (Inkscape::NodePath::Path *nodepath, Geom::Dim2 axis, boost::optional<Geom::Point> center)
{
if (!nodepath || !nodepath->selected) return;
@@ -4324,7 +4324,7 @@ void sp_nodepath_flip (Inkscape::NodePath::Path *nodepath, NR::Dim2 axis, boost:
}
NR::Matrix t =
NR::Matrix (NR::translate(- *center)) *
- NR::Matrix ((axis == NR::X)? NR::scale(-1, 1) : NR::scale(1, -1)) *
+ NR::Matrix ((axis == Geom::X)? NR::scale(-1, 1) : NR::scale(1, -1)) *
NR::Matrix (NR::translate(*center));
for (GList *l = nodepath->selected; l != NULL; l = l->next) {
@@ -4446,7 +4446,7 @@ static void sp_nodepath_subpath_open(Inkscape::NodePath::SubPath *sp,Inkscape::N
* \param npos Handle position in previous direction
*/
Inkscape::NodePath::Node *
-sp_nodepath_node_new(Inkscape::NodePath::SubPath *sp, Inkscape::NodePath::Node *next, Inkscape::NodePath::NodeType type, NRPathcode code, NR::Point *ppos, NR::Point *pos, NR::Point *npos)
+sp_nodepath_node_new(Inkscape::NodePath::SubPath *sp, Inkscape::NodePath::Node *next, Inkscape::NodePath::NodeType type, NRPathcode code, Geom::Point *ppos, Geom::Point *pos, Geom::Point *npos)
{
g_assert(sp);
g_assert(sp->nodepath);
diff --git a/src/nodepath.h b/src/nodepath.h
index 39eb10b4f9220c5d382d326161d6f22c011a08ac..551bf7df146fc0648330fe5e7a2f23fcb783cbd3 100644 (file)
--- a/src/nodepath.h
+++ b/src/nodepath.h
/** Amplitude */
double a;
Radial() {}
- // Radial(NR::Point const &p); // Convert a point to radial coordinates
+ // Radial(Geom::Point const &p); // Convert a point to radial coordinates
Radial(Radial &p) : r(p.r),a(p.a) {}
- // operator NR::Point() const;
+ // operator Geom::Point() const;
/**
- * Construct Radial from NR::Point.
+ * Construct Radial from Geom::Point.
*/
-Radial(NR::Point const &p)
+Radial(Geom::Point const &p)
{
r = NR::L2(p);
if (r > 0) {
}
/**
- * Cast Radial to cartesian NR::Point.
+ * Cast Radial to cartesian Geom::Point.
*/
-operator NR::Point() const
+operator Geom::Point() const
{
if (a == HUGE_VAL) {
- return NR::Point(0,0);
+ return Geom::Point(0,0);
} else {
- return r*NR::Point(cos(a), sin(a));
+ return r*Geom::Point(cos(a), sin(a));
}
}
/** Pointer to the next node, */
Node * other;
/** Position */
- NR::Point pos;
+ Geom::Point pos;
/** Origin (while dragging) in radial notation */
Radial origin_radial;
/** Origin (while dragging) in x/y notation */
- NR::Point origin;
+ Geom::Point origin;
/** Knots are Inkscape's way of providing draggable points. This
* Knot is the point on the curve representing the control point in a
* bezier curve.*/
/** Boolean. Am I currently selected or not? */
guint selected : 1;
/** */
- NR::Point pos;
+ Geom::Point pos;
/** */
- NR::Point origin;
+ Geom::Point origin;
/** Knots are Inkscape's way of providing draggable points. This
* Knot is the point on the curve representing the endpoint.*/
SPKnot * knot;
GList * selected;
/** Transforms (userspace <---> virtual space? someone please describe )
njh: I'd be guessing that these are item <-> desktop transforms.*/
- NR::Matrix i2d, d2i;
+ Geom::Matrix i2d, d2i;
/** The DOM node which describes this NodePath */
Inkscape::XML::Node *repr;
gchar *repr_key;
void selection(std::list<Node *> &l);
guint numSelected() {return (selected? g_list_length(selected) : 0);}
- NR::Point& singleSelectedCoords() {return (((Node *) selected->data)->pos);}
+ Geom::Point& singleSelectedCoords() {return (((Node *) selected->data)->pos);}
/// draw a "sketch" of the path by using these variables
SPCanvasItem *helper_path;
@@ -291,11 +291,11 @@ gboolean nodepath_repr_typestr_changed (Inkscape::NodePath::Path * np, const cha
gboolean node_key (GdkEvent * event);
void sp_nodepath_update_repr(Inkscape::NodePath::Path *np, const gchar *annotation);
void sp_nodepath_update_statusbar (Inkscape::NodePath::Path *nodepath);
-void sp_nodepath_selected_align(Inkscape::NodePath::Path *nodepath, NR::Dim2 axis);
-void sp_nodepath_selected_distribute(Inkscape::NodePath::Path *nodepath, NR::Dim2 axis);
-void sp_nodepath_select_segment_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p, bool toggle);
-void sp_nodepath_add_node_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p);
-void sp_nodepath_curve_drag(Inkscape::NodePath::Path *nodepath, int node, double t, NR::Point delta);
+void sp_nodepath_selected_align(Inkscape::NodePath::Path *nodepath, Geom::Dim2 axis);
+void sp_nodepath_selected_distribute(Inkscape::NodePath::Path *nodepath, Geom::Dim2 axis);
+void sp_nodepath_select_segment_near_point(Inkscape::NodePath::Path *nodepath, Geom::Point p, bool toggle);
+void sp_nodepath_add_node_near_point(Inkscape::NodePath::Path *nodepath, Geom::Point p);
+void sp_nodepath_curve_drag(Inkscape::NodePath::Path *nodepath, int node, double t, Geom::Point delta);
Inkscape::NodePath::Node * sp_nodepath_get_node_by_index(Inkscape::NodePath::Path *np, int index);
/* possibly private functions */
@@ -328,6 +328,6 @@ void sp_nodepath_selected_nodes_rotate (Inkscape::NodePath::Path * nodepath, gdo
void sp_nodepath_selected_nodes_scale (Inkscape::NodePath::Path * nodepath, gdouble grow, int which);
void sp_nodepath_selected_nodes_scale_screen (Inkscape::NodePath::Path * nodepath, gdouble grow, int which);
-void sp_nodepath_flip (Inkscape::NodePath::Path *nodepath, NR::Dim2 axis, boost::optional<NR::Point> center);
+void sp_nodepath_flip (Inkscape::NodePath::Path *nodepath, Geom::Dim2 axis, boost::optional<Geom::Point> center);
#endif
diff --git a/src/pen-context.cpp b/src/pen-context.cpp
index 12253632d450ccc10276d249de82fd5b7b7b795d..9d11df0591a9ccdee9cf6dd3f4dc6eea8a08ab3f 100644 (file)
--- a/src/pen-context.cpp
+++ b/src/pen-context.cpp
@@ -53,10 +53,10 @@ static void sp_pen_context_set(SPEventContext *ec, gchar const *key, gchar const
static gint sp_pen_context_root_handler(SPEventContext *ec, GdkEvent *event);
static gint sp_pen_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event);
-static void spdc_pen_set_initial_point(SPPenContext *pc, NR::Point const p);
-static void spdc_pen_set_subsequent_point(SPPenContext *const pc, NR::Point const p, bool statusbar, guint status = 0);
-static void spdc_pen_set_ctrl(SPPenContext *pc, NR::Point const p, guint state);
-static void spdc_pen_finish_segment(SPPenContext *pc, NR::Point p, guint state);
+static void spdc_pen_set_initial_point(SPPenContext *pc, Geom::Point const p);
+static void spdc_pen_set_subsequent_point(SPPenContext *const pc, Geom::Point const p, bool statusbar, guint status = 0);
+static void spdc_pen_set_ctrl(SPPenContext *pc, Geom::Point const p, guint state);
+static void spdc_pen_finish_segment(SPPenContext *pc, Geom::Point p, guint state);
static void spdc_pen_finish(SPPenContext *pc, gboolean closed);
static void pen_disable_events(SPPenContext *const pc);
static void pen_enable_events(SPPenContext *const pc);
-static NR::Point pen_drag_origin_w(0, 0);
+static Geom::Point pen_drag_origin_w(0, 0);
static bool pen_within_tolerance = false;
static SPDrawContextClass *pen_parent_class;
-static int pen_next_paraxial_direction(const SPPenContext *const pc, NR::Point const &pt, NR::Point const &origin, guint state);
-static void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, NR::Point &pt, guint const state);
-static NR::Point pen_get_intermediate_horiz_vert(const SPPenContext *const pc, NR::Point const &pt, guint const state);
+static int pen_next_paraxial_direction(const SPPenContext *const pc, Geom::Point const &pt, Geom::Point const &origin, guint state);
+static void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, Geom::Point &pt, guint const state);
+static Geom::Point pen_get_intermediate_horiz_vert(const SPPenContext *const pc, Geom::Point const &pt, guint const state);
static int pen_last_paraxial_dir = 0; // last used direction in horizontal/vertical mode; 0 = horizontal, 1 = vertical
* Snaps new node relative to the previous node.
*/
static void
-spdc_endpoint_snap(SPPenContext const *const pc, NR::Point &p, guint const state)
+spdc_endpoint_snap(SPPenContext const *const pc, Geom::Point &p, guint const state)
{
if ((state & GDK_CONTROL_MASK)) { //CTRL enables angular snapping
if (pc->npoints > 0) {
@@ -315,7 +315,7 @@ spdc_endpoint_snap(SPPenContext const *const pc, NR::Point &p, guint const state
* Snaps new node's handle relative to the new node.
*/
static void
-spdc_endpoint_snap_handle(SPPenContext const *const pc, NR::Point &p, guint const state)
+spdc_endpoint_snap_handle(SPPenContext const *const pc, Geom::Point &p, guint const state)
{
g_return_if_fail(( pc->npoints == 2 ||
pc->npoints == 5 ));
@@ -413,8 +413,8 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
SPDrawContext * const dc = SP_DRAW_CONTEXT(pc);
SPDesktop * const desktop = SP_EVENT_CONTEXT_DESKTOP(dc);
- NR::Point const event_w(bevent.x, bevent.y);
- NR::Point const event_dt(desktop->w2d(event_w));
+ Geom::Point const event_w(bevent.x, bevent.y);
+ Geom::Point const event_dt(desktop->w2d(event_w));
SPEventContext *event_context = SP_EVENT_CONTEXT(pc);
gint ret = FALSE;
@@ -475,7 +475,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
/* Set start anchor */
pc->sa = anchor;
- NR::Point p;
+ Geom::Point p;
if (anchor && !sp_pen_context_has_waiting_LPE(pc)) {
/* Adjust point to anchor if needed; if we have a waiting LPE, we need
a fresh path to be created so don't continue an existing one */
@@ -509,7 +509,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
/* Set end anchor */
pc->ea = anchor;
- NR::Point p;
+ Geom::Point p;
if (anchor) {
p = anchor->dp;
// we hit an anchor, will finish the curve (either with or without closing)
return FALSE;
}
- NR::Point const event_w(mevent.x,
+ Geom::Point const event_w(mevent.x,
mevent.y);
if (pen_within_tolerance) {
gint const tolerance = prefs_get_int_attribute_limited("options.dragtolerance",
pen_within_tolerance = false;
/* Find desktop coordinates */
- NR::Point p = dt->w2d(event_w);
+ Geom::Point p = dt->w2d(event_w);
/* Test, whether we hit any anchor */
SPDrawAnchor *anchor = spdc_test_inside(pc, event_w);
@@ -715,10 +715,10 @@ pen_handle_button_release(SPPenContext *const pc, GdkEventButton const &revent)
SPDrawContext *dc = SP_DRAW_CONTEXT (pc);
- NR::Point const event_w(revent.x,
+ Geom::Point const event_w(revent.x,
revent.y);
/* Find desktop coordinates */
- NR::Point p = pc->desktop->w2d(event_w);
+ Geom::Point p = pc->desktop->w2d(event_w);
/* Test whether we hit any anchor. */
SPDrawAnchor *anchor = spdc_test_inside(pc, event_w);
if ( cubic &&
(*cubic)[2] != to_2geom(pc->p[0]) )
{
- NR::Point p2 = (*cubic)[2];
+ Geom::Point p2 = (*cubic)[2];
SP_CTRL(pc->c0)->moveto(p2);
sp_ctrlline_set_coords(SP_CTRLLINE(pc->cl0), p2, pc->p[0]);
sp_canvas_item_show (pc->c0);
} else {
// start anchor too
if (pc->green_anchor) {
- pc->green_anchor->dp += NR::Point(x, y);
+ pc->green_anchor->dp += Geom::Point(x, y);
}
}
// red
- pc->p[0] += NR::Point(x, y);
- pc->p[1] += NR::Point(x, y);
+ pc->p[0] += Geom::Point(x, y);
+ pc->p[1] += Geom::Point(x, y);
pen_redraw_all(pc);
}
Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const *>( pc->green_curve->last_segment() );
if ( cubic ) {
- pc->p[1] = pc->p[0] + (NR::Point)( (*cubic)[3] - (*cubic)[2] );
+ pc->p[1] = pc->p[0] + (Geom::Point)( (*cubic)[3] - (*cubic)[2] );
} else {
pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]);
}
} else {
pc->p[1] = pc->p[0];
}
- NR::Point const pt(( pc->npoints < 4
- ? (NR::Point)(crv->finalPoint())
+ Geom::Point const pt(( pc->npoints < 4
+ ? (Geom::Point)(crv->finalPoint())
: pc->p[3] ));
pc->npoints = 2;
pc->green_curve->backspace();
static void
-spdc_pen_set_initial_point(SPPenContext *const pc, NR::Point const p)
+spdc_pen_set_initial_point(SPPenContext *const pc, Geom::Point const p)
{
g_assert( pc->npoints == 0 );
* two parameters ("angle %3.2f°, distance %s").
*/
static void
-spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, NR::Point const p, int pc_point_to_compare, gchar const *message)
+spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, Geom::Point const p, int pc_point_to_compare, gchar const *message)
{
g_assert(pc != NULL);
g_assert((pc_point_to_compare == 0) || (pc_point_to_compare == 3)); // exclude control handles
g_assert(message != NULL);
SPDesktop *desktop = SP_EVENT_CONTEXT(pc)->desktop;
- NR::Point rel = p - pc->p[pc_point_to_compare];
+ Geom::Point rel = p - pc->p[pc_point_to_compare];
GString *dist = SP_PX_TO_METRIC_STRING(NR::L2(rel), desktop->namedview->getDefaultMetric());
double angle = atan2(rel[NR::Y], rel[NR::X]) * 180 / M_PI;
if (prefs_get_int_attribute("options.compassangledisplay", "value", 0) != 0)
@@ -1218,7 +1218,7 @@ spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, NR::Point con
}
static void
-spdc_pen_set_subsequent_point(SPPenContext *const pc, NR::Point const p, bool statusbar, guint status)
+spdc_pen_set_subsequent_point(SPPenContext *const pc, Geom::Point const p, bool statusbar, guint status)
{
g_assert( pc->npoints != 0 );
/* todo: Check callers to see whether 2 <= npoints is guaranteed. */
@@ -1232,7 +1232,7 @@ spdc_pen_set_subsequent_point(SPPenContext *const pc, NR::Point const p, bool st
pc->red_curve->moveto(pc->p[0]);
if (pc->polylines_paraxial && !statusbar) {
// we are drawing horizontal/vertical lines and hit an anchor; draw an L-shaped path
- NR::Point intermed = p;
+ Geom::Point intermed = p;
pen_set_to_nearest_horiz_vert(pc, intermed, status);
pc->red_curve->lineto(intermed);
pc->red_curve->lineto(p);
@@ -1260,7 +1260,7 @@ spdc_pen_set_subsequent_point(SPPenContext *const pc, NR::Point const p, bool st
}
static void
-spdc_pen_set_ctrl(SPPenContext *const pc, NR::Point const p, guint const state)
+spdc_pen_set_ctrl(SPPenContext *const pc, Geom::Point const p, guint const state)
{
sp_canvas_item_show(pc->c1);
sp_canvas_item_show(pc->cl1);
@@ -1280,7 +1280,7 @@ spdc_pen_set_ctrl(SPPenContext *const pc, NR::Point const p, guint const state)
bool is_symm = false;
if ( ( ( pc->mode == SP_PEN_CONTEXT_MODE_CLICK ) && ( state & GDK_CONTROL_MASK ) ) ||
( ( pc->mode == SP_PEN_CONTEXT_MODE_DRAG ) && !( state & GDK_SHIFT_MASK ) ) ) {
- NR::Point delta = p - pc->p[3];
+ Geom::Point delta = p - pc->p[3];
pc->p[2] = pc->p[3] - delta;
is_symm = true;
pc->red_curve->reset();
@@ -1303,7 +1303,7 @@ spdc_pen_set_ctrl(SPPenContext *const pc, NR::Point const p, guint const state)
}
static void
-spdc_pen_finish_segment(SPPenContext *const pc, NR::Point const p, guint const state)
+spdc_pen_finish_segment(SPPenContext *const pc, Geom::Point const p, guint const state)
{
if (pc->polylines_paraxial) {
pen_last_paraxial_dir = pen_next_paraxial_direction(pc, p, pc->p[0], state);
}
static int pen_next_paraxial_direction(const SPPenContext *const pc,
- NR::Point const &pt, NR::Point const &origin, guint state) {
+ Geom::Point const &pt, Geom::Point const &origin, guint state) {
/*
* after the first mouse click we determine whether the mouse pointer is closest to a
* horizontal or vertical segment; for all subsequent mouse clicks, we use the direction
}
}
-void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, NR::Point &pt, guint const state)
+void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, Geom::Point &pt, guint const state)
{
- NR::Point const &origin = pc->p[0];
+ Geom::Point const &origin = pc->p[0];
int next_dir = pen_next_paraxial_direction(pc, pt, origin, state);
@@ -1435,14 +1435,14 @@ void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, NR::Point &pt,
}
}
-NR::Point pen_get_intermediate_horiz_vert(const SPPenContext *const pc, NR::Point const &pt)
+Geom::Point pen_get_intermediate_horiz_vert(const SPPenContext *const pc, Geom::Point const &pt)
{
- NR::Point const &origin = pc->p[0];
+ Geom::Point const &origin = pc->p[0];
if (pen_last_paraxial_dir == 0) {
- return NR::Point (origin[NR::X], pt[NR::Y]);
+ return Geom::Point (origin[NR::X], pt[NR::Y]);
} else {
- return NR::Point (pt[NR::X], origin[NR::Y]);
+ return Geom::Point (pt[NR::X], origin[NR::Y]);
}
}
diff --git a/src/pen-context.h b/src/pen-context.h
index 1c84ee2da80fc2f51af399c636acfbe37a9df777..c214da30ddd7b6d69479cd0b686733c3f6df7b41 100644 (file)
--- a/src/pen-context.h
+++ b/src/pen-context.h
* SPPenContext: a context for pen tool events.
*/
struct SPPenContext : public SPDrawContext {
- NR::Point p[5];
+ Geom::Point p[5];
/** \invar npoints in {0, 2, 5}. */
// npoints somehow determines the type of the node (what does it mean, exactly? the number of Bezier handles?)
diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp
index b6231f7cb16c9be9ef3a77eee2978dc20c3efb06..cfc1fc01026a792c4a046af4e7c5760229f87111 100644 (file)
--- a/src/pencil-context.cpp
+++ b/src/pencil-context.cpp
@@ -53,15 +53,15 @@ static gint pencil_handle_motion_notify(SPPencilContext *const pc, GdkEventMotio
static gint pencil_handle_button_release(SPPencilContext *const pc, GdkEventButton const &revent);
static gint pencil_handle_key_press(SPPencilContext *const pc, guint const keyval, guint const state);
-static void spdc_set_startpoint(SPPencilContext *pc, NR::Point const p);
-static void spdc_set_endpoint(SPPencilContext *pc, NR::Point const p);
+static void spdc_set_startpoint(SPPencilContext *pc, Geom::Point const p);
+static void spdc_set_endpoint(SPPencilContext *pc, Geom::Point const p);
static void spdc_finish_endpoint(SPPencilContext *pc);
-static void spdc_add_freehand_point(SPPencilContext *pc, NR::Point p, guint state);
+static void spdc_add_freehand_point(SPPencilContext *pc, Geom::Point p, guint state);
static void fit_and_split(SPPencilContext *pc);
static SPDrawContextClass *pencil_parent_class;
-static NR::Point pencil_drag_origin_w(0, 0);
+static Geom::Point pencil_drag_origin_w(0, 0);
static bool pencil_within_tolerance = false;
/**
pc->npoints = 0;
pc->state = SP_PENCIL_CONTEXT_IDLE;
- pc->req_tangent = NR::Point(0, 0);
+ pc->req_tangent = Geom::Point(0, 0);
}
/**
/** Snaps new node relative to the previous node. */
static void
-spdc_endpoint_snap(SPPencilContext const *pc, NR::Point &p, guint const state)
+spdc_endpoint_snap(SPPencilContext const *pc, Geom::Point &p, guint const state)
{
if ((state & GDK_CONTROL_MASK)) { //CTRL enables constrained snapping
spdc_endpoint_snap_rotation(pc, p, pc->p[0], state);
@@ -222,7 +222,7 @@ pencil_handle_button_press(SPPencilContext *const pc, GdkEventButton const &beve
return TRUE;
}
- NR::Point const button_w(bevent.x, bevent.y);
+ Geom::Point const button_w(bevent.x, bevent.y);
/* Find desktop coordinates */
Geom::Point p = pc->desktop->w2d(button_w);
@@ -230,7 +230,7 @@ pencil_handle_button_press(SPPencilContext *const pc, GdkEventButton const &beve
/* Test whether we hit any anchor. */
SPDrawAnchor *anchor = spdc_test_inside(pc, button_w);
- pencil_drag_origin_w = NR::Point(bevent.x,bevent.y);
+ pencil_drag_origin_w = Geom::Point(bevent.x,bevent.y);
pencil_within_tolerance = true;
switch (pc->state) {
@@ -303,15 +303,15 @@ pencil_handle_motion_notify(SPPencilContext *const pc, GdkEventMotion const &mev
}
/* Find desktop coordinates */
- Geom::Point p = to_2geom(dt->w2d(NR::Point(mevent.x, mevent.y)));
+ Geom::Point p = to_2geom(dt->w2d(Geom::Point(mevent.x, mevent.y)));
/* Test whether we hit any anchor. */
- SPDrawAnchor *anchor = spdc_test_inside(pc, NR::Point(mevent.x, mevent.y));
+ SPDrawAnchor *anchor = spdc_test_inside(pc, Geom::Point(mevent.x, mevent.y));
if (pencil_within_tolerance) {
gint const tolerance = prefs_get_int_attribute_limited("options.dragtolerance",
"value", 0, 0, 100);
- if ( NR::LInfty( NR::Point(mevent.x,mevent.y) - pencil_drag_origin_w ) < tolerance ) {
+ if ( NR::LInfty( Geom::Point(mevent.x,mevent.y) - pencil_drag_origin_w ) < tolerance ) {
return FALSE; // Do not drag if we're within tolerance from origin.
}
}
@@ -327,7 +327,7 @@ pencil_handle_motion_notify(SPPencilContext *const pc, GdkEventMotion const &mev
if (anchor) {
p = to_2geom(anchor->dp);
} else {
- NR::Point ptnr = from_2geom(p);
+ Geom::Point ptnr = from_2geom(p);
spdc_endpoint_snap(pc, ptnr, mevent.state);
p = to_2geom(ptnr);
}
@@ -394,10 +394,10 @@ pencil_handle_button_release(SPPencilContext *const pc, GdkEventButton const &re
pc->is_drawing = false;
/* Find desktop coordinates */
- NR::Point p = dt->w2d(NR::Point(revent.x, revent.y));
+ Geom::Point p = dt->w2d(Geom::Point(revent.x, revent.y));
/* Test whether we hit any anchor. */
- SPDrawAnchor *anchor = spdc_test_inside(pc, NR::Point(revent.x,
+ SPDrawAnchor *anchor = spdc_test_inside(pc, Geom::Point(revent.x,
revent.y));
switch (pc->state) {
@@ -538,7 +538,7 @@ pencil_handle_key_press(SPPencilContext *const pc, guint const keyval, guint con
* Reset points and set new starting point.
*/
static void
-spdc_set_startpoint(SPPencilContext *const pc, NR::Point const p)
+spdc_set_startpoint(SPPencilContext *const pc, Geom::Point const p)
{
pc->npoints = 0;
pc->red_curve_is_valid = false;
* We change RED curve.
*/
static void
-spdc_set_endpoint(SPPencilContext *const pc, NR::Point const p)
+spdc_set_endpoint(SPPencilContext *const pc, Geom::Point const p)
{
if (pc->npoints == 0) {
return;
}
static void
-spdc_add_freehand_point(SPPencilContext *pc, NR::Point p, guint /*state*/)
+spdc_add_freehand_point(SPPencilContext *pc, Geom::Point p, guint /*state*/)
{
g_assert( pc->npoints > 0 );
g_return_if_fail(unsigned(pc->npoints) < G_N_ELEMENTS(pc->p));
double const tolerance_sq = 0.02 * square( NR::expansion(pc->desktop->w2d()) * tol)
* exp(0.2*tol - 2);
- NR::Point b[4];
+ Geom::Point b[4];
g_assert(is_zero(pc->req_tangent)
|| is_unit_vector(pc->req_tangent));
- NR::Point const tHatEnd(0, 0);
+ Geom::Point const tHatEnd(0, 0);
int const n_segs = sp_bezier_fit_cubic_full(b, NULL, pc->p, pc->npoints,
pc->req_tangent, tHatEnd, tolerance_sq, 1);
if ( n_segs > 0
g_assert( last_seg ); // Relevance: validity of (*last_seg)[2]
pc->p[0] = last_seg->finalPoint();
pc->npoints = 1;
- NR::Point const req_vec( pc->p[0] - (*last_seg)[2] );
- pc->req_tangent = ( ( NR::is_zero(req_vec) || !in_svg_plane(req_vec) )
- ? NR::Point(0, 0)
- : NR::unit_vector(req_vec) );
+ Geom::Point const req_vec( pc->p[0] - (*last_seg)[2] );
+ pc->req_tangent = ( ( Geom::is_zero(req_vec) || !in_svg_plane(req_vec) )
+ ? Geom::Point(0, 0)
+ : Geom::unit_vector(req_vec) );
}
pc->green_curve->append_continuous(pc->red_curve, 0.0625);
diff --git a/src/pencil-context.h b/src/pencil-context.h
index 60519c2691b637f96389153663aee7d3bc7420d8..87e9b2470483bd8b4fdd15d74433abce32d2856c 100644 (file)
--- a/src/pencil-context.h
+++ b/src/pencil-context.h
* SPPencilContext: a context for pencil tool events
*/
struct SPPencilContext : public SPDrawContext {
- NR::Point p[16];
+ Geom::Point p[16];
gint npoints;
PencilState state;
- NR::Point req_tangent;
+ Geom::Point req_tangent;
bool is_drawing;
};
diff --git a/src/shape-editor.cpp b/src/shape-editor.cpp
index d59e7f0bc372ba1f813529c0fbe8c8b4f05160d0..6cf1182ee0aedb92e71a76a920cb402cfc76716d 100644 (file)
--- a/src/shape-editor.cpp
+++ b/src/shape-editor.cpp
sp_nodepath_update_statusbar(this->nodepath);
}
-bool ShapeEditor::is_over_stroke (NR::Point event_p, bool remember) {
+bool ShapeEditor::is_over_stroke (Geom::Point event_p, bool remember) {
if (!this->nodepath)
return false; // no stroke in knotholder
return false;
}
- NR::Point nearest = pathv[pvpos->path_nr].pointAt(pvpos->t);
- NR::Point delta = nearest - this->curvepoint_doc;
+ Geom::Point nearest = pathv[pvpos->path_nr].pointAt(pvpos->t);
+ Geom::Point delta = nearest - this->curvepoint_doc;
delta = desktop->d2w(delta);
segment_index += 1;
}
- this->curvepoint_event[NR::X] = (gint) event_p [NR::X];
- this->curvepoint_event[NR::Y] = (gint) event_p [NR::Y];
+ this->curvepoint_event[Geom::X] = (gint) event_p [Geom::X];
+ this->curvepoint_event[Geom::Y] = (gint) event_p [Geom::Y];
this->hit = true;
this->grab_t = t;
this->grab_node = segment_index;
// The coordinates hasn't changed since the last motion event, abort
- if (this->curvepoint_event[NR::X] == x &&
- this->curvepoint_event[NR::Y] == y)
+ if (this->curvepoint_event[Geom::X] == x &&
+ this->curvepoint_event[Geom::Y] == y)
return;
- NR::Point const delta_w(eventx - this->curvepoint_event[NR::X],
- eventy - this->curvepoint_event[NR::Y]);
- NR::Point const delta_dt(this->desktop->w2d(delta_w));
+ Geom::Point const delta_w(eventx - this->curvepoint_event[Geom::X],
+ eventy - this->curvepoint_event[Geom::Y]);
+ Geom::Point const delta_dt(this->desktop->w2d(delta_w));
sp_nodepath_curve_drag (this->nodepath, this->grab_node, this->grab_t, delta_dt);
- this->curvepoint_event[NR::X] = x;
- this->curvepoint_event[NR::Y] = y;
+ this->curvepoint_event[Geom::X] = x;
+ this->curvepoint_event[Geom::Y] = y;
}
if (this->knotholder) {
sp_nodepath_show_helperpath (this->nodepath, show);
}
-void ShapeEditor::flip (NR::Dim2 axis, boost::optional<NR::Point> center) {
+void ShapeEditor::flip (Geom::Dim2 axis, boost::optional<Geom::Point> center) {
if (this->nodepath)
sp_nodepath_flip (this->nodepath, axis, center);
}
-void ShapeEditor::distribute (NR::Dim2 axis) {
+void ShapeEditor::distribute (Geom::Dim2 axis) {
if (this->nodepath)
sp_nodepath_selected_distribute (this->nodepath, axis);
}
-void ShapeEditor::align (NR::Dim2 axis) {
+void ShapeEditor::align (Geom::Dim2 axis) {
if (this->nodepath)
sp_nodepath_selected_align (this->nodepath, axis);
}
diff --git a/src/shape-editor.h b/src/shape-editor.h
index 4e78869570839aea6979a8967b092f9b05c51c37..9ce64355fe15b64c6e8c7d8e144a0586c1e9ea36 100644 (file)
--- a/src/shape-editor.h
+++ b/src/shape-editor.h
void update_statusbar ();
- bool is_over_stroke (NR::Point event_p, bool remember);
+ bool is_over_stroke (Geom::Point event_p, bool remember);
void add_node_near_point(); // uses the shapeeditor's remembered point, if any
void show_handles (bool show);
void show_helperpath (bool show);
- void flip (NR::Dim2 axis, boost::optional<NR::Point> center = boost::optional<NR::Point>());
+ void flip (Geom::Dim2 axis, boost::optional<Geom::Point> center = boost::optional<Geom::Point>());
- void distribute (NR::Dim2 axis);
- void align (NR::Dim2 axis);
+ void distribute (Geom::Dim2 axis);
+ void align (Geom::Dim2 axis);
bool nodepath_edits_repr_key(gchar const *name);
double grab_t;
int grab_node; // number of node grabbed by sp_node_context_is_over_stroke
bool hit;
- NR::Point curvepoint_event; // int coords from event
- NR::Point curvepoint_doc; // same, in doc coords
+ Geom::Point curvepoint_event; // int coords from event
+ Geom::Point curvepoint_doc; // same, in doc coords
Inkscape::XML::Node *listener_attached_for;
};
diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp
index 3a37a8da278805f91880d93e5d48805f007fdf41..7b741a940cb80d9230ce3e6789ad54361895754b 100644 (file)
--- a/src/sp-spiral.cpp
+++ b/src/sp-spiral.cpp
static void sp_spiral_set_shape (SPShape *shape);
static void sp_spiral_update_patheffect (SPLPEItem *lpeitem, bool write);
-static NR::Point sp_spiral_get_tangent (SPSpiral const *spiral, gdouble t);
+static Geom::Point sp_spiral_get_tangent (SPSpiral const *spiral, gdouble t);
static SPShapeClass *parent_class;
sp_spiral_fit_and_draw (SPSpiral const *spiral,
SPCurve *c,
double dstep,
- NR::Point darray[],
- NR::Point const &hat1,
- NR::Point &hat2,
+ Geom::Point darray[],
+ Geom::Point const &hat1,
+ Geom::Point &hat2,
double *t)
{
#define BEZIER_SIZE 4
g_assert (dstep > 0);
g_assert (is_unit_vector (hat1));
- NR::Point bezier[BEZIER_LENGTH];
+ Geom::Point bezier[BEZIER_LENGTH];
double d;
int depth, i;
static void
sp_spiral_set_shape (SPShape *shape)
{
- NR::Point darray[SAMPLE_SIZE + 1];
+ Geom::Point darray[SAMPLE_SIZE + 1];
double t;
SPSpiral *spiral = SP_SPIRAL(shape);
double const tstep = SAMPLE_STEP / spiral->revo;
double const dstep = tstep / (SAMPLE_SIZE - 1);
- NR::Point hat1 = sp_spiral_get_tangent (spiral, spiral->t0);
- NR::Point hat2;
+ Geom::Point hat1 = sp_spiral_get_tangent (spiral, spiral->t0);
+ Geom::Point hat2;
for (t = spiral->t0; t < (1.0 - tstep);) {
sp_spiral_fit_and_draw (spiral, c, dstep, darray, hat1, hat2, &t);
* than 1.0, though some callers go slightly beyond 1.0 for curve-fitting
* purposes.)
*/
-NR::Point sp_spiral_get_xy (SPSpiral const *spiral, gdouble t)
+Geom::Point sp_spiral_get_xy (SPSpiral const *spiral, gdouble t)
{
g_assert (spiral != NULL);
g_assert (SP_IS_SPIRAL(spiral));
double const rad = spiral->rad * pow(t, (double) spiral->exp);
double const arg = 2.0 * M_PI * spiral->revo * t + spiral->arg;
- return NR::Point(rad * cos (arg) + spiral->cx,
- rad * sin (arg) + spiral->cy);
+ return Geom::Point(rad * cos (arg) + spiral->cx,
+ rad * sin (arg) + spiral->cy);
}
* \pre p != NULL.
* \post is_unit_vector(*p).
*/
-static NR::Point
+static Geom::Point
sp_spiral_get_tangent (SPSpiral const *spiral, gdouble t)
{
- NR::Point ret(1.0, 0.0);
+ Geom::Point ret(1.0, 0.0);
g_return_val_if_fail (( ( spiral != NULL )
&& SP_IS_SPIRAL(spiral) ),
ret);
double const c = cos (arg);
if (spiral->exp == 0.0) {
- ret = NR::Point(-s, c);
+ ret = Geom::Point(-s, c);
} else if (t_scaled == 0.0) {
- ret = NR::Point(c, s);
+ ret = Geom::Point(c, s);
} else {
- NR::Point unrotated(spiral->exp, t_scaled);
+ Geom::Point unrotated(spiral->exp, t_scaled);
double const s_len = L2 (unrotated);
g_assert (s_len != 0);
/** \todo
/* ret = spiral->exp * (c, s) + t_scaled * (-s, c);
alternatively ret = (spiral->exp, t_scaled) * (( c, s),
(-s, c)).*/
- ret = NR::Point(dot(unrotated, NR::Point(c, -s)),
- dot(unrotated, NR::Point(s, c)));
+ ret = Geom::Point(dot(unrotated, Geom::Point(c, -s)),
+ dot(unrotated, Geom::Point(s, c)));
/* ret should already be approximately normalized: the
matrix ((c, -s), (s, c)) is orthogonal (it just
rotates by arg), and unrotated has been normalized,
diff --git a/src/sp-spiral.h b/src/sp-spiral.h
index 62c916e824e22347a25e98f11ca8977eefb4e6a9..7b31b19d8bad4951d567636ea64a354470189d95 100644 (file)
--- a/src/sp-spiral.h
+++ b/src/sp-spiral.h
gdouble arg,
gdouble t0);
-NR::Point sp_spiral_get_xy (SPSpiral const *spiral,
+Geom::Point sp_spiral_get_xy (SPSpiral const *spiral,
gdouble t);
void sp_spiral_get_polar (SPSpiral const *spiral,
index 4d029fe42d028e8c9e4f8b7105b46c3585c45544..ae7f0a64bf48e377b8657e162d0484235ed2d2cd 100644 (file)
if (!SP_IS_NODE_CONTEXT (event_context)) return ;
if (_distribute)
- SP_NODE_CONTEXT (event_context)->shape_editor->distribute((NR::Dim2)_orientation);
+ SP_NODE_CONTEXT (event_context)->shape_editor->distribute((Geom::Dim2)_orientation);
else
- SP_NODE_CONTEXT (event_context)->shape_editor->align((NR::Dim2)_orientation);
+ SP_NODE_CONTEXT (event_context)->shape_editor->align((Geom::Dim2)_orientation);
}
};
diff --git a/src/verbs.cpp b/src/verbs.cpp
index 6b8d0a1fada0b6a1565550ffde5ad1616a9860cf..f33019f24ebe9233dd8b86c9685c85a1a2db81f0 100644 (file)
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
if (active_node) {
// ... flip the selected nodes about that node
- SP_NODE_CONTEXT(ec)->shape_editor->flip(NR::X, active_node->pos);
+ SP_NODE_CONTEXT(ec)->shape_editor->flip(Geom::X, active_node->pos);
} else {
// ... or else about the center of their bounding box.
- SP_NODE_CONTEXT(ec)->shape_editor->flip(NR::X);
+ SP_NODE_CONTEXT(ec)->shape_editor->flip(Geom::X);
}
// When working with the selector tool, flip the selection about its rotation center
if (tools_isactive(dt, TOOLS_NODES)) {
Inkscape::NodePath::Node *active_node = Inkscape::NodePath::Path::active_node;
if (active_node) {
- SP_NODE_CONTEXT(ec)->shape_editor->flip(NR::Y, active_node->pos);
+ SP_NODE_CONTEXT(ec)->shape_editor->flip(Geom::Y, active_node->pos);
} else {
- SP_NODE_CONTEXT(ec)->shape_editor->flip(NR::Y);
+ SP_NODE_CONTEXT(ec)->shape_editor->flip(Geom::Y);
}
} else {
sp_selection_scale_relative(sel, center, NR::scale(1.0, -1.0));