summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 278a51c)
raw | patch | inline | side by side (parent: 278a51c)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Fri, 9 May 2008 09:37:08 +0000 (09:37 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Fri, 9 May 2008 09:37:08 +0000 (09:37 +0000) |
- change _bpath to private member of SPCurve, obtain and set with get_bpath and set_bpath.
- added const methods, so protect changes to _bpath in SPCurve
- added const methods, so protect changes to _bpath in SPCurve
46 files changed:
index 07e512e064aa6d85d0a3f9ac7eb08156b1cf298a..3c1669fa6e4e1a3b0a3d9044af67da4148fb6e1c 100644 (file)
#include "sp-namedview.h"
#include "sp-text.h"
#include "sp-flowtext.h"
-
+#include "display/curve.h"
static void sp_connector_context_class_init(SPConnectorContextClass *klass);
static void sp_connector_context_init(SPConnectorContext *conn_context);
{
if (SP_IS_PATH(item)) {
SPCurve *curve = (SP_SHAPE(item))->curve;
- if ( curve && !(curve->closed) ) {
+ if ( curve && !(curve->is_closed()) ) {
// Open paths are connectors.
return false;
}
{
if (SP_IS_PATH(item)) {
if (SP_PATH(item)->connEndPair.isAutoRoutingConn()) {
- g_assert( !(SP_SHAPE(item)->curve->closed) );
+ g_assert( !(SP_SHAPE(item)->curve->is_closed()) );
return true;
}
}
index 49c4c2a814c2e970cc1792caeef0cb8a97aefe2b..e8d9a4390d5073b21a5122760ff42c51df86afc6 100644 (file)
--- a/src/connector-context.h
+++ b/src/connector-context.h
#include <sigc++/sigc++.h>
#include <sigc++/connection.h>
-#include "display/curve.h"
#include "event-context.h"
#include <forward.h>
#include <display/display-forward.h>
index 6c39860b9b5a5ca99d3e667722f36ef7ed674bdc..668c59649b08bdb736a3e1a208bde677ade85d67 100644 (file)
#include "ui/widget/registered-widget.h"
#include "ui/widget/registry.h"
-//#include "ui/widget/tolerance-slider.h"
#include "xml/node-event-vector.h"
index 6aa4136237ecddd8c0957914b0594b079475bc74..a3327308c6e1eb7a58f6c57f509fd42537d0b569 100644 (file)
@@ -142,7 +142,7 @@ sp_canvas_bpath_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned i
Path* thePath=new Path;
thePath->LoadArtBPath(SP_CURVE_BPATH(cbp->curve), affine, true);
thePath->Convert(0.25);
- if ((cbp->fill_rgba & 0xff) && (cbp->curve->end > 2)) {
+ if ((cbp->fill_rgba & 0xff) && (cbp->curve->_end > 2)) {
Shape* theShape=new Shape;
thePath->Fill(theShape,0);
if ( cbp->fill_shp == NULL ) cbp->fill_shp=new Shape;
@@ -165,7 +165,7 @@ sp_canvas_bpath_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned i
}
}
}
- if ((cbp->stroke_rgba & 0xff) && (cbp->curve->end > 1)) {
+ if ((cbp->stroke_rgba & 0xff) && (cbp->curve->_end > 1)) {
JoinType join=join_straight;
// Shape* theShape=new Shape;
ButtType butt=butt_straight;
index 0ff2c65f1fdf953a040284a5ca4ad1cffe7f07fc..a9e317534b90dd12740b80b49aef5681741f8786 100644 (file)
#include "ui/widget/scalar-unit.h"
#include "ui/widget/registered-widget.h"
#include "ui/widget/registry.h"
-//#include "ui/widget/tolerance-slider.h"
#include "xml/node-event-vector.h"
#include "snapper.h"
#include "line-snapper.h"
diff --git a/src/display/curve.cpp b/src/display/curve.cpp
index e97b097443c6f040f4456a919e26842d667a5c32..5b2ac024b8d39379cd7280b48e3652536cfae620 100644 (file)
--- a/src/display/curve.cpp
+++ b/src/display/curve.cpp
* Released under GNU GPL
*/
-#include <display/curve.h>
+#include "display/curve.h"
#include <string.h>
#include <glib/gmem.h>
* \param length Initial number of NArtBpath elements allocated for bpath (including NR_END
* element).
*/
-SPCurve::SPCurve(gint length)
- : refcount(1),
+SPCurve::SPCurve(guint length)
+ : _refcount(1),
_bpath(NULL),
- end(0),
- length(length),
- substart(0),
- hascpt(false),
- posSet(false),
- moving(false),
- closed(false)
+ _end(0),
+ _length(length),
+ _substart(0),
+ _hascpt(false),
+ _posSet(false),
+ _moving(false),
+ _closed(false)
{
if (length <= 0) {
g_error("SPCurve::SPCurve called with invalid length parameter");
SPCurve *curve = new SPCurve();
curve->_bpath = new_bpath;
- curve->length = len;
- curve->end = curve->length - 1;
- gint i = curve->end;
+ curve->_length = len;
+ curve->_end = curve->_length - 1;
+ gint i = curve->_end;
for (; i > 0; i--)
if ((curve->_bpath[i].code == NR_MOVETO) ||
(curve->_bpath[i].code == NR_MOVETO_OPEN))
break;
- curve->substart = i;
- curve->closed = sp_bpath_closed(new_bpath);
+ curve->_substart = i;
+ curve->_closed = sp_bpath_closed(new_bpath);
return curve;
}
/* Methods */
/**
- * Increase refcount of curve.
+ * Frees old path and sets new path
+ * This does not copy the bpath, so the new_bpath should not be deleted by caller
+ */
+void
+SPCurve::set_bpath(NArtBpath * new_bpath)
+{
+ if (new_bpath && new_bpath != _bpath) { // FIXME, add function to SPCurve to change bpath? or a copy function?
+ if (_bpath) {
+ g_free(_bpath); //delete old bpath
+ }
+ _bpath = new_bpath;
+ }
+}
+
+/**
+ * Get pointer to bpath data. Don't keep this reference too long, because the path might change by another function.
+ */
+NArtBpath const *
+SPCurve::get_bpath() const
+{
+ return _bpath;
+};
+NArtBpath *
+SPCurve::get_bpath()
+{
+ return _bpath;
+};
+
+/**
+ * Increase _refcount of curve.
*
* \todo should this be shared with other refcounting code?
*/
{
g_return_val_if_fail(this != NULL, NULL);
- refcount += 1;
+ _refcount += 1;
return this;
}
{
g_return_val_if_fail(this != NULL, NULL);
- refcount -= 1;
+ _refcount -= 1;
- if (refcount < 1) {
+ if (_refcount < 1) {
if (_bpath) {
g_free(_bpath);
_bpath = NULL;
/**
* Add space for more paths in curve.
*/
-static void
-sp_curve_ensure_space(SPCurve *curve, gint space)
+void
+SPCurve::ensure_space(guint space)
{
- g_return_if_fail(curve != NULL);
+ g_return_if_fail(this != NULL);
g_return_if_fail(space > 0);
- if (curve->end + space < curve->length)
+ if (_end + space < _length)
return;
if (space < SP_CURVE_LENSTEP)
space = SP_CURVE_LENSTEP;
- curve->_bpath = g_renew(NArtBpath, curve->_bpath, curve->length + space);
+ _bpath = g_renew(NArtBpath, _bpath, _length + space);
- curve->length += space;
+ _length += space;
}
/**
for (GSList const *l = list; l != NULL; l = l->next) {
SPCurve *c = (SPCurve *) l->data;
- length += c->end;
+ length += c->_end;
}
SPCurve *new_curve = new SPCurve(length + 1);
for (GSList const *l = list; l != NULL; l = l->next) {
SPCurve *c = (SPCurve *) l->data;
- memcpy(bp, c->_bpath, c->end * sizeof(NArtBpath));
- bp += c->end;
+ memcpy(bp, c->_bpath, c->_end * sizeof(NArtBpath));
+ bp += c->_end;
}
bp->code = NR_END;
- new_curve->end = length;
+ new_curve->_end = length;
gint i;
- for (i = new_curve->end; i > 0; i--) {
+ for (i = new_curve->_end; i > 0; i--) {
if ((new_curve->_bpath[i].code == NR_MOVETO) ||
(new_curve->_bpath[i].code == NR_MOVETO_OPEN) )
break;
}
- new_curve->substart = i;
+ new_curve->_substart = i;
return new_curve;
}
gint p = 0;
GSList *l = NULL;
- while (p < end) {
+ while (p < _end) {
gint i = 1;
while ((_bpath[p + i].code == NR_LINETO) ||
(_bpath[p + i].code == NR_CURVETO))
i++;
SPCurve *new_curve = new SPCurve(i + 1);
memcpy(new_curve->_bpath, _bpath + p, i * sizeof(NArtBpath));
- new_curve->end = i;
+ new_curve->_end = i;
new_curve->_bpath[i].code = NR_END;
- new_curve->substart = 0;
- new_curve->closed = (new_curve->_bpath->code == NR_MOVETO);
- new_curve->hascpt = (new_curve->_bpath->code == NR_MOVETO_OPEN);
+ new_curve->_substart = 0;
+ new_curve->_closed = (new_curve->_bpath->code == NR_MOVETO);
+ new_curve->_hascpt = (new_curve->_bpath->code == NR_MOVETO_OPEN);
l = g_slist_prepend(l, new_curve);
p += i;
}
{
g_return_if_fail(curve != NULL);
- for (gint i = 0; i < curve->end; i++) {
+ for (gint i = 0; i < curve->_end; i++) {
NArtBpath *p = curve->_bpath + i;
switch (p->code) {
case NR_MOVETO:
g_return_if_fail(this != NULL);
_bpath->code = NR_END;
- end = 0;
- substart = 0;
- hascpt = false;
- posSet = false;
- moving = false;
- closed = false;
+ _end = 0;
+ _substart = 0;
+ _hascpt = false;
+ _posSet = false;
+ _moving = false;
+ _closed = false;
}
/* Several consecutive movetos are ALLOWED */
SPCurve::moveto(NR::Point const &p)
{
g_return_if_fail(this != NULL);
- g_return_if_fail(!moving);
+ g_return_if_fail(!_moving);
- substart = end;
- hascpt = true;
- posSet = true;
- movePos = p;
+ _substart = _end;
+ _hascpt = true;
+ _posSet = true;
+ _movePos = p;
}
/**
SPCurve::lineto(gdouble x, gdouble y)
{
g_return_if_fail(this != NULL);
- g_return_if_fail(hascpt);
+ g_return_if_fail(_hascpt);
- if (moving) {
+ if (_moving) {
/* fix endpoint */
- g_return_if_fail(!posSet);
- g_return_if_fail(end > 1);
- NArtBpath *bp = _bpath + end - 1;
+ g_return_if_fail(!_posSet);
+ g_return_if_fail(_end > 1);
+ NArtBpath *bp = _bpath + _end - 1;
g_return_if_fail(bp->code == NR_LINETO);
bp->x3 = x;
bp->y3 = y;
- moving = false;
+ _moving = false;
return;
}
- if (posSet) {
+ if (_posSet) {
/* start a new segment */
- sp_curve_ensure_space(this, 2);
- NArtBpath *bp = _bpath + end;
+ ensure_space(2);
+ NArtBpath *bp = _bpath + _end;
bp->code = NR_MOVETO_OPEN;
- bp->setC(3, movePos);
+ bp->setC(3, _movePos);
bp++;
bp->code = NR_LINETO;
bp->x3 = x;
bp->y3 = y;
bp++;
bp->code = NR_END;
- end += 2;
- posSet = false;
- closed = false;
+ _end += 2;
+ _posSet = false;
+ _closed = false;
return;
}
/* add line */
- g_return_if_fail(end > 1);
- sp_curve_ensure_space(this, 1);
- NArtBpath *bp = _bpath + end;
+ g_return_if_fail(_end > 1);
+ ensure_space(1);
+ NArtBpath *bp = _bpath + _end;
bp->code = NR_LINETO;
bp->x3 = x;
bp->y3 = y;
bp++;
bp->code = NR_END;
- end++;
+ _end++;
}
/// Unused
SPCurve::lineto_moving(gdouble x, gdouble y)
{
g_return_if_fail(this != NULL);
- g_return_if_fail(hascpt);
+ g_return_if_fail(_hascpt);
- if (moving) {
+ if (_moving) {
/* change endpoint */
- g_return_if_fail(!posSet);
- g_return_if_fail(end > 1);
- NArtBpath *bp = _bpath + end - 1;
+ g_return_if_fail(!_posSet);
+ g_return_if_fail(_end > 1);
+ NArtBpath *bp = _bpath + _end - 1;
g_return_if_fail(bp->code == NR_LINETO);
bp->x3 = x;
bp->y3 = y;
return;
}
- if (posSet) {
+ if (_posSet) {
/* start a new segment */
- sp_curve_ensure_space(this, 2);
- NArtBpath *bp = _bpath + end;
+ ensure_space(2);
+ NArtBpath *bp = _bpath + _end;
bp->code = NR_MOVETO_OPEN;
- bp->setC(3, movePos);
+ bp->setC(3, _movePos);
bp++;
bp->code = NR_LINETO;
bp->x3 = x;
bp->y3 = y;
bp++;
bp->code = NR_END;
- end += 2;
- posSet = false;
- moving = true;
- closed = false;
+ _end += 2;
+ _posSet = false;
+ _moving = true;
+ _closed = false;
return;
}
/* add line */
- g_return_if_fail(end > 1);
- sp_curve_ensure_space(this, 1);
- NArtBpath *bp = _bpath + end;
+ g_return_if_fail(_end > 1);
+ ensure_space(1);
+ NArtBpath *bp = _bpath + _end;
bp->code = NR_LINETO;
bp->x3 = x;
bp->y3 = y;
bp++;
bp->code = NR_END;
- end++;
- moving = true;
+ _end++;
+ _moving = true;
}
/**
SPCurve::curveto(gdouble x0, gdouble y0, gdouble x1, gdouble y1, gdouble x2, gdouble y2)
{
g_return_if_fail(this != NULL);
- g_return_if_fail(hascpt);
- g_return_if_fail(!moving);
+ g_return_if_fail(_hascpt);
+ g_return_if_fail(!_moving);
- if (posSet) {
+ if (_posSet) {
/* start a new segment */
- sp_curve_ensure_space(this, 2);
- NArtBpath *bp = _bpath + end;
+ ensure_space(2);
+ NArtBpath *bp = _bpath + _end;
bp->code = NR_MOVETO_OPEN;
- bp->setC(3, movePos);
+ bp->setC(3, _movePos);
bp++;
bp->code = NR_CURVETO;
bp->x1 = x0;
@@ -508,17 +537,17 @@ SPCurve::curveto(gdouble x0, gdouble y0, gdouble x1, gdouble y1, gdouble x2, gdo
bp->y3 = y2;
bp++;
bp->code = NR_END;
- end += 2;
- posSet = false;
- closed = false;
+ _end += 2;
+ _posSet = false;
+ _closed = false;
return;
}
/* add curve */
- g_return_if_fail(end > 1);
- sp_curve_ensure_space(this, 1);
- NArtBpath *bp = _bpath + end;
+ g_return_if_fail(_end > 1);
+ ensure_space(1);
+ NArtBpath *bp = _bpath + _end;
bp->code = NR_CURVETO;
bp->x1 = x0;
bp->y1 = y0;
@@ -528,7 +557,7 @@ SPCurve::curveto(gdouble x0, gdouble y0, gdouble x1, gdouble y1, gdouble x2, gdo
bp->y3 = y2;
bp++;
bp->code = NR_END;
- end++;
+ _end++;
}
/**
SPCurve::closepath()
{
g_return_if_fail(this != NULL);
- g_return_if_fail(hascpt);
- g_return_if_fail(!posSet);
- g_return_if_fail(!moving);
- g_return_if_fail(!closed);
+ g_return_if_fail(_hascpt);
+ g_return_if_fail(!_posSet);
+ g_return_if_fail(!_moving);
+ g_return_if_fail(!_closed);
/* We need at least moveto, curveto, end. */
- g_return_if_fail(end - substart > 1);
+ g_return_if_fail(_end - _substart > 1);
{
- NArtBpath *bs = _bpath + substart;
- NArtBpath *be = _bpath + end - 1;
+ NArtBpath *bs = _bpath + _substart;
+ NArtBpath *be = _bpath + _end - 1;
if (bs->c(3) != be->c(3)) {
lineto(bs->c(3));
- bs = _bpath + substart;
+ bs = _bpath + _substart;
}
bs->code = NR_MOVETO;
}
- closed = true;
+ _closed = true;
for (NArtBpath const *bp = _bpath; bp->code != NR_END; bp++) {
/** \todo
* the closed boolean).
*/
if (bp->code == NR_MOVETO_OPEN) {
- closed = false;
+ _closed = false;
break;
}
}
- hascpt = false;
+ _hascpt = false;
}
/** Like SPCurve::closepath() but sets the end point of the current
SPCurve::closepath_current()
{
g_return_if_fail(this != NULL);
- g_return_if_fail(hascpt);
- g_return_if_fail(!posSet);
- g_return_if_fail(!closed);
+ g_return_if_fail(_hascpt);
+ g_return_if_fail(!_posSet);
+ g_return_if_fail(!_closed);
/* We need at least moveto, curveto, end. */
- g_return_if_fail(end - substart > 1);
+ g_return_if_fail(_end - _substart > 1);
{
- NArtBpath *bs = _bpath + substart;
- NArtBpath *be = _bpath + end - 1;
+ NArtBpath *bs = _bpath + _substart;
+ NArtBpath *be = _bpath + _end - 1;
be->x3 = bs->x3;
be->y3 = bs->y3;
bs->code = NR_MOVETO;
}
- closed = true;
+ _closed = true;
for (NArtBpath const *bp = _bpath; bp->code != NR_END; bp++) {
/** \todo
* the closed boolean).
*/
if (bp->code == NR_MOVETO_OPEN) {
- closed = false;
+ _closed = false;
break;
}
}
- hascpt = false;
- moving = false;
+ _hascpt = false;
+ _moving = false;
}
/**
return (_bpath->code == NR_END);
}
+/**
+ * True iff all subpaths are closed.
+ */
+bool
+SPCurve::is_closed() const
+{
+ return _closed;
+}
+
/**
* Return last subpath or NULL.
*/
{
g_return_val_if_fail(this != NULL, NULL);
- if (end == 0) {
+ if (_end == 0) {
return NULL;
}
- return _bpath + end - 1;
+ return _bpath + _end - 1;
}
/**
{
g_return_val_if_fail(this != NULL, NULL);
- if (end == 0) {
+ if (_end == 0) {
return NULL;
}
}
/**
- * Return the second point of first subpath or movePos if curve too short.
+ * Return the second point of first subpath or _movePos if curve too short.
*/
NR::Point
SPCurve::second_point() const
{
g_return_val_if_fail(this != NULL, NR::Point(0, 0));
- if (end < 1) {
- return movePos;
+ if (_end < 1) {
+ return _movePos;
}
NArtBpath *bpath = NULL;
- if (end < 2) {
+ if (_end < 2) {
bpath = _bpath;
} else {
bpath = _bpath + 1;
}
/**
- * Return the second-last point of last subpath or movePos if curve too short.
+ * Return the second-last point of last subpath or _movePos if curve too short.
*/
NR::Point
SPCurve::penultimate_point() const
{
g_return_val_if_fail(this != NULL, NR::Point(0, 0));
- if (end < 2) {
- return movePos;
+ if (_end < 2) {
+ return _movePos;
}
- NArtBpath *const bpath = _bpath + end - 2;
+ NArtBpath *const bpath = _bpath + _end - 2;
g_return_val_if_fail(bpath != NULL, NR::Point(0, 0));
return bpath->c(3);
}
}
/**
- * Returns \a curve but drawn in the opposite direction.
+ * Returns a *new* \a curve but drawn in the opposite direction.
* Should result in the same shape, but
* with all its markers drawn facing the other direction.
**/
SPCurve *
-SPCurve::reverse() const
+SPCurve::create_reverse() const
{
/* We need at least moveto, curveto, end. */
- g_return_val_if_fail(end - substart > 1, NULL);
+ g_return_val_if_fail(_end - _substart > 1, NULL);
- NArtBpath const *be = _bpath + end - 1;
+ NArtBpath const *be = _bpath + _end - 1;
- g_assert(is_moveto(_bpath[substart].code));
+ g_assert(is_moveto(_bpath[_substart].code));
g_assert(is_moveto(_bpath[0].code));
g_assert((be+1)->code == NR_END);
- SPCurve *new_curve = new SPCurve(length);
+ SPCurve *new_curve = new SPCurve(_length);
new_curve->moveto(be->c(3));
for (NArtBpath const *bp = be; ; --bp) {
switch (bp->code) {
case NR_MOVETO:
- g_assert(new_curve->_bpath[new_curve->substart].code == NR_MOVETO_OPEN);
- new_curve->_bpath[new_curve->substart].code = NR_MOVETO;
+ g_assert(new_curve->_bpath[new_curve->_substart].code == NR_MOVETO_OPEN);
+ new_curve->_bpath[new_curve->_substart].code = NR_MOVETO;
/* FALL-THROUGH */
case NR_MOVETO_OPEN:
if (bp == _bpath) {
g_return_if_fail(this != NULL);
g_return_if_fail(curve2 != NULL);
- if (curve2->end < 1)
+ if (curve2->_end < 1)
return;
NArtBpath const *bs = curve2->_bpath;
- bool _closed = this->closed;
+ bool closed = this->_closed;
for (NArtBpath const *bp = bs; bp->code != NR_END; bp++) {
switch (bp->code) {
case NR_MOVETO_OPEN:
- if (use_lineto && hascpt) {
+ if (use_lineto && _hascpt) {
lineto(bp->x3, bp->y3);
use_lineto = FALSE;
} else {
- if (_closed) closepath();
+ if (closed) closepath();
moveto(bp->x3, bp->y3);
}
- _closed = false;
+ closed = false;
break;
case NR_MOVETO:
- if (use_lineto && hascpt) {
+ if (use_lineto && _hascpt) {
lineto(bp->x3, bp->y3);
use_lineto = FALSE;
} else {
- if (_closed) closepath();
+ if (closed) closepath();
moveto(bp->x3, bp->y3);
}
- _closed = true;
+ closed = true;
break;
case NR_LINETO:
}
}
- if (_closed) {
+ if (closed) {
closepath();
}
}
{
g_return_val_if_fail(this != NULL, NULL);
g_return_val_if_fail(c1 != NULL, NULL);
- g_return_val_if_fail(!closed, NULL);
- g_return_val_if_fail(!c1->closed, NULL);
+ g_return_val_if_fail(!_closed, NULL);
+ g_return_val_if_fail(!c1->_closed, NULL);
- if (c1->end < 1) {
+ if (c1->_end < 1) {
return this;
}
* fixme: Strictly we mess in case of multisegment mixed
* open/close curves
*/
- bool _closed = false;
+ bool closed = false;
for (bs = bs + 1; bs->code != NR_END; bs++) {
switch (bs->code) {
case NR_MOVETO_OPEN:
- if (_closed) closepath();
+ if (closed) closepath();
moveto(bs->x3, bs->y3);
- _closed = false;
+ closed = false;
break;
case NR_MOVETO:
- if (_closed) closepath();
+ if (closed) closepath();
moveto(bs->x3, bs->y3);
- _closed = true;
+ closed = true;
break;
case NR_LINETO:
lineto(bs->x3, bs->y3);
{
g_return_if_fail(this != NULL);
- if (end > 0) {
- end -= 1;
- if (end > 0) {
- NArtBpath *bp = _bpath + end - 1;
+ if (_end > 0) {
+ _end -= 1;
+ if (_end > 0) {
+ NArtBpath *bp = _bpath + _end - 1;
if ((bp->code == NR_MOVETO) ||
(bp->code == NR_MOVETO_OPEN) )
{
- hascpt = true;
- posSet = true;
- closed = false;
- movePos = bp->c(3);
- end -= 1;
+ _hascpt = true;
+ _posSet = true;
+ _closed = false;
+ _movePos = bp->c(3);
+ _end -= 1;
}
}
- _bpath[end].code = NR_END;
+ _bpath[_end].code = NR_END;
}
}
/**
* Returns total length of curve, excluding length of closepath segments.
*/
-static double
+double
sp_curve_distance_including_space(SPCurve const *const curve, double seg2len[])
{
g_return_val_if_fail(curve != NULL, 0.);
@@ -1005,7 +1043,7 @@ sp_curve_distance_including_space(SPCurve const *const curve, double seg2len[])
}
NR::Point prev(curve->_bpath->c(3));
- for (gint i = 1; i < curve->end; ++i) {
+ for (gint i = 1; i < curve->_end; ++i) {
NArtBpath &p = curve->_bpath[i];
double seg_len = 0;
switch (p.code) {
@@ -1034,7 +1072,7 @@ sp_curve_distance_including_space(SPCurve const *const curve, double seg2len[])
* Like sp_curve_distance_including_space(), but ensures that the
* result >= 1e-18: uses 1 per segment if necessary.
*/
-static double
+double
sp_curve_nonzero_distance_including_space(SPCurve const *const curve, double seg2len[])
{
double const real_dist(sp_curve_distance_including_space(curve, seg2len));
diff --git a/src/display/curve.h b/src/display/curve.h
index 9cbb115292d2bb6dbef1f8a76b9fcd6464d6a486..28fce31323e030b6c6fe8d2910eb7fd1a161031d 100644 (file)
--- a/src/display/curve.h
+++ b/src/display/curve.h
class SPCurve {
public:
/* Constructors */
- SPCurve(gint length = SP_CURVE_LENSTEP);
+ SPCurve(guint length = SP_CURVE_LENSTEP);
static SPCurve * new_from_bpath(NArtBpath *bpath);
static SPCurve * new_from_foreign_bpath(NArtBpath const *bpath);
static SPCurve * new_from_rect(NR::Maybe<NR::Rect> const &rect);
virtual ~SPCurve();
- gint refcount;
- NArtBpath *_bpath;
-
+ void set_bpath(NArtBpath * new_bpath);
+ NArtBpath const * get_bpath() const;
+ NArtBpath * get_bpath();
+
/// Index in bpath[] of NR_END element.
- gint end;
+ guint _end;
/// Allocated size (i.e., capacity) of bpath[] array. Not to be confused
/// with the SP_CURVE_LENGTH macro, which returns the logical length of
/// the path (i.e., index of NR_END).
- gint length;
+ guint _length;
/// Index in bpath[] of the start (i.e., moveto element) of the last
/// subpath in this path.
- gint substart;
+ guint _substart;
/// Previous moveto position.
/// \note This is used for coalescing moveto's, whereas if we're to
/// midpoint markers. Ref:
/// http://www.w3.org/TR/SVG11/implnote.html#PathElementImplementationNotes
/// (first subitem of the item about zero-length path segments)
- NR::Point movePos;
+ NR::Point _movePos;
/// True iff current point is defined. Initially false for a new curve;
/// becomes true after moveto; becomes false on closepath. Curveto,
/// lineto etc. require hascpt; hascpt remains true after lineto/curveto.
- bool hascpt : 1;
+ bool _hascpt : 1;
/// True iff previous was moveto.
- bool posSet : 1;
+ bool _posSet : 1;
/// True iff bpath end is moving.
- bool moving : 1;
+ bool _moving : 1;
/// True iff all subpaths are closed.
- bool closed : 1;
+ bool _closed : 1;
SPCurve * ref();
SPCurve * unref();
SPCurve * append_continuous(SPCurve const *c1, gdouble tolerance);
bool is_empty() const;
+ bool is_closed() const;
NArtBpath * last_bpath() const;
NArtBpath * first_bpath() const;
NR::Point first_point() const;
NR::Point penultimate_point() const;
void append(SPCurve const *curve2, bool use_lineto);
- SPCurve * reverse() const;
+ SPCurve * create_reverse() const;
void backspace();
static SPCurve * concat(GSList const *list);
+ void ensure_space(guint space);
+
+protected:
+ gint _refcount;
+
+ NArtBpath *_bpath;
+
private:
// Don't implement these:
SPCurve(const SPCurve&);
SPCurve& operator=(const SPCurve&);
+
+ friend double sp_curve_distance_including_space(SPCurve const *const curve, double seg2len[]);
+ friend double sp_curve_nonzero_distance_including_space(SPCurve const *const curve, double seg2len[]);
+ template<class M> friend void tmpl_curve_transform(SPCurve *const curve, M const &m);
};
-#define SP_CURVE_LENGTH(c) (((SPCurve const *)(c))->end)
-#define SP_CURVE_BPATH(c) (((SPCurve const *)(c))->_bpath)
-#define SP_CURVE_SEGMENT(c,i) (((SPCurve const *)(c))->_bpath + (i))
+#define SP_CURVE_LENGTH(c) (((SPCurve const *)(c))->_end)
+#define SP_CURVE_BPATH(c) ((c)->get_bpath())
+#define SP_CURVE_SEGMENT(c,i) ((c)->get_bpath() + (i))
#endif /* !SEEN_DISPLAY_CURVE_H */
index 191aac61fa1d117669484acf61ae8367d0b32e2a..25c4a6e3d3ab341f2ada8253ffeaf80135e9c33a 100644 (file)
typedef struct _SPCanvasItemClass SPCanvasItemClass;
struct SPCanvasGroup;
struct SPCanvasGroupClass;
-struct SPCurve;
+class SPCurve;
namespace Inkscape {
namespace Display {
index 0c01211609cbef81157b6790046140c3f6f18667..ebf5cee6d3646910f2b151742ce26ff3c43e5989 100644 (file)
#include <libnrtype/nrtype-forward.h>
-#include <display/curve.h>
+#include <display/display-forward.h>
#include <forward.h>
#include <sp-paint-server.h>
#include <display/nr-arena-item.h>
index 4df93a9a2d1856a5a7cf1ca8ab8f8f1e8f22660d..aba06068e1d8ef2ccc3de1a94c8ddac98209fa68 100644 (file)
#include <display/canvas-arena.h>
#include <display/nr-arena.h>
#include <display/nr-arena-shape.h>
+#include "display/curve.h"
#include <libnr/n-art-bpath.h>
#include <libnr/nr-path.h>
#include <libnr/nr-pixops.h>
nr_arena_shape_update_fill(NRArenaShape *shape, NRGC *gc, NRRectL *area, bool force_shape)
{
if ((shape->_fill.paint.type() != NRArenaShape::Paint::NONE || force_shape) &&
- ((shape->curve->end > 2) || (SP_CURVE_BPATH(shape->curve)[1].code == NR_CURVETO)) ) {
+ ((shape->curve->_end > 2) || (SP_CURVE_BPATH(shape->curve)[1].code == NR_CURVETO)) ) {
if (TRUE || !shape->fill_shp) {
NR::Matrix cached_to_new = NR::identity();
int isometry = 0;
index b371d2ede57bf331b7de6b3c6cb1ff0ace1d4368..2b56fbf75d90b46334fd495dd3c4c6233070e7d9 100644 (file)
#define NR_ARENA_SHAPE(obj) (NR_CHECK_INSTANCE_CAST ((obj), NR_TYPE_ARENA_SHAPE, NRArenaShape))
#define NR_IS_ARENA_SHAPE(obj) (NR_CHECK_INSTANCE_TYPE ((obj), NR_TYPE_ARENA_SHAPE))
-#include "display/curve.h"
+#include "display/display-forward.h"
#include "display/canvas-bpath.h"
#include "forward.h"
#include "sp-paint-server.h"
diff --git a/src/draw-context.cpp b/src/draw-context.cpp
index b48b34ed03009648a2b2f978c3b98a383582b636..50799b55fe45f2b19c9c1a95e708bf6675976e50 100644 (file)
--- a/src/draw-context.cpp
+++ b/src/draw-context.cpp
#include "svg/svg.h"
#include <glibmm/i18n.h>
#include "libnr/n-art-bpath.h"
+#include "display/curve.h"
#include "desktop.h"
#include "desktop-affine.h"
#include "desktop-handles.h"
for (GSList *l = dc->white_curves; l != NULL; l = l->next) {
SPCurve *c;
c = (SPCurve*)l->data;
- g_return_if_fail( c->end > 1 );
+ g_return_if_fail( c->_end > 1 );
if ( SP_CURVE_BPATH(c)->code == NR_MOVETO_OPEN ) {
NArtBpath *s, *e;
SPDrawAnchor *a;
@@ -378,7 +379,7 @@ void spdc_endpoint_snap_free(SPEventContext const * const ec, NR::Point& p, guin
static SPCurve *
reverse_then_unref(SPCurve *orig)
{
- SPCurve *ret = orig->reverse();
+ SPCurve *ret = orig->create_reverse();
orig->unref();
return ret;
}
if ( dc->sa && dc->ea
&& ( dc->sa->curve == dc->ea->curve )
&& ( ( dc->sa != dc->ea )
- || dc->sa->curve->closed ) )
+ || dc->sa->curve->is_closed() ) )
{
// We hit bot start and end of single curve, closing paths
SP_EVENT_CONTEXT_DESKTOP(dc)->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Closing path."));
- if (dc->sa->start && !(dc->sa->curve->closed) ) {
+ if (dc->sa->start && !(dc->sa->curve->is_closed()) ) {
c = reverse_then_unref(c);
}
dc->sa->curve->append_continuous(c, 0.0625);
diff --git a/src/draw-context.h b/src/draw-context.h
index 59ec5a92fe18ee6b7eb28432d0caf10813851139..5ac1a7d0978fe42a2d89eef2a563d4765f524dec 100644 (file)
--- a/src/draw-context.h
+++ b/src/draw-context.h
*/
#include <sigc++/sigc++.h>
-#include "display/curve.h"
#include "event-context.h"
#include <forward.h>
#include <display/display-forward.h>
index 4de36d0d7f40f3a233c3ef3218438de3f003a51c..cc79dfd2e04d6d3e73ef2539eb6b4e7dce743120 100644 (file)
#include "svg/svg.h"
#include "display/canvas-bpath.h"
#include "display/bezier-utils.h"
-
+#include "display/curve.h"
#include <glib/gmem.h>
#include "macros.h"
#include "document.h"
{
if ( !dc->cal1->is_empty() && !dc->cal2->is_empty() ) {
dc->accumulated->reset(); /* Is this required ?? */
- SPCurve *rev_cal2 = dc->cal2->reverse();
+ SPCurve *rev_cal2 = dc->cal2->create_reverse();
- g_assert(dc->cal1->end > 1);
- g_assert(rev_cal2->end > 1);
+ g_assert(dc->cal1->_end > 1);
+ g_assert(rev_cal2->_end > 1);
g_assert(SP_CURVE_SEGMENT(dc->cal1, 0)->code == NR_MOVETO_OPEN);
g_assert(SP_CURVE_SEGMENT(rev_cal2, 0)->code == NR_MOVETO_OPEN);
g_assert(SP_CURVE_SEGMENT(dc->cal1, 1)->code == NR_CURVETO);
g_assert(SP_CURVE_SEGMENT(rev_cal2, 1)->code == NR_CURVETO);
- g_assert(SP_CURVE_SEGMENT(dc->cal1, dc->cal1->end-1)->code == NR_CURVETO);
- g_assert(SP_CURVE_SEGMENT(rev_cal2, rev_cal2->end-1)->code == NR_CURVETO);
+ g_assert(SP_CURVE_SEGMENT(dc->cal1, dc->cal1->_end-1)->code == NR_CURVETO);
+ g_assert(SP_CURVE_SEGMENT(rev_cal2, rev_cal2->_end-1)->code == NR_CURVETO);
dc->accumulated->append(dc->cal1, FALSE);
- add_cap(dc->accumulated, SP_CURVE_SEGMENT(dc->cal1, dc->cal1->end-1)->c(2), SP_CURVE_SEGMENT(dc->cal1, dc->cal1->end-1)->c(3), SP_CURVE_SEGMENT(rev_cal2, 0)->c(3), SP_CURVE_SEGMENT(rev_cal2, 1)->c(1), dc->cap_rounding);
+ add_cap(dc->accumulated, SP_CURVE_SEGMENT(dc->cal1, dc->cal1->_end-1)->c(2), SP_CURVE_SEGMENT(dc->cal1, dc->cal1->_end-1)->c(3), SP_CURVE_SEGMENT(rev_cal2, 0)->c(3), SP_CURVE_SEGMENT(rev_cal2, 1)->c(1), dc->cap_rounding);
dc->accumulated->append(rev_cal2, TRUE);
- add_cap(dc->accumulated, SP_CURVE_SEGMENT(rev_cal2, rev_cal2->end-1)->c(2), SP_CURVE_SEGMENT(rev_cal2, rev_cal2->end-1)->c(3), SP_CURVE_SEGMENT(dc->cal1, 0)->c(3), SP_CURVE_SEGMENT(dc->cal1, 1)->c(1), dc->cap_rounding);
+ add_cap(dc->accumulated, SP_CURVE_SEGMENT(rev_cal2, rev_cal2->_end-1)->c(2), SP_CURVE_SEGMENT(rev_cal2, rev_cal2->_end-1)->c(3), SP_CURVE_SEGMENT(dc->cal1, 0)->c(3), SP_CURVE_SEGMENT(dc->cal1, 1)->c(1), dc->cap_rounding);
dc->accumulated->closepath();
#endif
/* Current calligraphic */
- if ( dc->cal1->end == 0 || dc->cal2->end == 0 ) {
+ if ( dc->cal1->_end == 0 || dc->cal2->_end == 0 ) {
/* dc->npoints > 0 */
/* g_print("calligraphics(1|2) reset\n"); */
dc->cal1->reset();
index b3561b59a42066ded7306a16331dec5d2821eb15..40e6c6376386fb69fa08db10428a9fefde02cc20 100644 (file)
--- a/src/dyna-draw-context.h
+++ b/src/dyna-draw-context.h
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "display/curve.h"
#include "event-context.h"
#include <display/display-forward.h>
#include <libnr/nr-point.h>
diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp
index 295e75e8704b739e1458ef89fa092b5b02eb90bd..3fe661f99b1b6a414c32e13439218de4811c41a2 100644 (file)
--- a/src/eraser-context.cpp
+++ b/src/eraser-context.cpp
{
if ( !dc->cal1->is_empty() && !dc->cal2->is_empty() ) {
dc->accumulated->reset(); /* Is this required ?? */
- SPCurve *rev_cal2 = dc->cal2->reverse();
+ SPCurve *rev_cal2 = dc->cal2->create_reverse();
- g_assert(dc->cal1->end > 1);
- g_assert(rev_cal2->end > 1);
+ g_assert(dc->cal1->_end > 1);
+ g_assert(rev_cal2->_end > 1);
g_assert(SP_CURVE_SEGMENT(dc->cal1, 0)->code == NR_MOVETO_OPEN);
g_assert(SP_CURVE_SEGMENT(rev_cal2, 0)->code == NR_MOVETO_OPEN);
g_assert(SP_CURVE_SEGMENT(dc->cal1, 1)->code == NR_CURVETO);
g_assert(SP_CURVE_SEGMENT(rev_cal2, 1)->code == NR_CURVETO);
- g_assert(SP_CURVE_SEGMENT(dc->cal1, dc->cal1->end-1)->code == NR_CURVETO);
- g_assert(SP_CURVE_SEGMENT(rev_cal2, rev_cal2->end-1)->code == NR_CURVETO);
+ g_assert(SP_CURVE_SEGMENT(dc->cal1, dc->cal1->_end-1)->code == NR_CURVETO);
+ g_assert(SP_CURVE_SEGMENT(rev_cal2, rev_cal2->_end-1)->code == NR_CURVETO);
dc->accumulated->append(dc->cal1, FALSE);
- add_cap(dc->accumulated, SP_CURVE_SEGMENT(dc->cal1, dc->cal1->end-1)->c(2), SP_CURVE_SEGMENT(dc->cal1, dc->cal1->end-1)->c(3), SP_CURVE_SEGMENT(rev_cal2, 0)->c(3), SP_CURVE_SEGMENT(rev_cal2, 1)->c(1), dc->cap_rounding);
+ add_cap(dc->accumulated, SP_CURVE_SEGMENT(dc->cal1, dc->cal1->_end-1)->c(2), SP_CURVE_SEGMENT(dc->cal1, dc->cal1->_end-1)->c(3), SP_CURVE_SEGMENT(rev_cal2, 0)->c(3), SP_CURVE_SEGMENT(rev_cal2, 1)->c(1), dc->cap_rounding);
dc->accumulated->append(rev_cal2, TRUE);
- add_cap(dc->accumulated, SP_CURVE_SEGMENT(rev_cal2, rev_cal2->end-1)->c(2), SP_CURVE_SEGMENT(rev_cal2, rev_cal2->end-1)->c(3), SP_CURVE_SEGMENT(dc->cal1, 0)->c(3), SP_CURVE_SEGMENT(dc->cal1, 1)->c(1), dc->cap_rounding);
+ add_cap(dc->accumulated, SP_CURVE_SEGMENT(rev_cal2, rev_cal2->_end-1)->c(2), SP_CURVE_SEGMENT(rev_cal2, rev_cal2->_end-1)->c(3), SP_CURVE_SEGMENT(dc->cal1, 0)->c(3), SP_CURVE_SEGMENT(dc->cal1, 1)->c(1), dc->cap_rounding);
dc->accumulated->closepath();
#endif
/* Current eraser */
- if ( dc->cal1->end == 0 || dc->cal2->end == 0 ) {
+ if ( dc->cal1->_end == 0 || dc->cal2->_end == 0 ) {
/* dc->npoints > 0 */
/* g_print("erasers(1|2) reset\n"); */
dc->cal1->reset();
index 0f04c6a1aa0bce1deb9fcd51090babf3b0d1262d..6dd62206c20402ce101af71d7315ff91637ced89 100644 (file)
//Count the NR_CURVETOs/LINETOs
int segmentCount=0;
- NArtBpath *bp = SP_CURVE_BPATH(curve);
+ NArtBpath const *bp = SP_CURVE_BPATH(curve);
for (int curveNr=0 ; curveNr<curveLength ; curveNr++, bp++)
if (bp->code == NR_CURVETO || bp->code == NR_LINETO)
segmentCount++;
index 5fa20c81c41a8591a5c95085e00b0f6002448f6c..f3fac4218611fe70df1cc7956eafdadd063cf38a 100755 (executable)
#include "font-instance.h"
#include "svg/svg-length.h"
#include "extension/internal/cairo-render-context.h"
+#include "display/curve.h"
namespace Inkscape {
namespace Extension {
index 2cd88fd8b0901748889d70c74a455ae28401895e..f699248e4e411d6b9b5140b8100814f684ddf454 100644 (file)
void
Effect::doEffect (SPCurve * curve)
{
- NArtBpath *new_bpath = doEffect_nartbpath(SP_CURVE_BPATH(curve));
+ NArtBpath *new_bpath = doEffect_nartbpath(curve->get_bpath());
- if (new_bpath && new_bpath != SP_CURVE_BPATH(curve)) { // FIXME, add function to SPCurve to change bpath? or a copy function?
- if (curve->_bpath) {
- g_free(curve->_bpath); //delete old bpath
- }
- curve->_bpath = new_bpath;
- }
+ curve->set_bpath(new_bpath);
}
NArtBpath *
-Effect::doEffect_nartbpath (NArtBpath * path_in)
+Effect::doEffect_nartbpath (NArtBpath const * path_in)
{
try {
std::vector<Geom::Path> orig_pathv = BPath_to_2GeomPath(path_in);
index 58010358fc5bf5447a1b4851497eb8264816a67a..7ab4537f9444edcffdae24085d43ca99dc5fa03a 100644 (file)
// called by this base class. (i.e. doEffect(SPCurve * curve) defaults to calling
// doEffect(std::vector<Geom::Path> )
virtual NArtBpath *
- doEffect_nartbpath (NArtBpath * path_in);
+ doEffect_nartbpath (NArtBpath const * path_in) __attribute__ ((deprecated));
virtual std::vector<Geom::Path>
doEffect_path (std::vector<Geom::Path> const & path_in);
virtual Geom::Piecewise<Geom::D2<Geom::SBasis> >
index c37f34ce7a73dd2beb7d03d131fabda110d42d95..6b9fbbb97eaedb8712735680e297f884ffdb487c 100644 (file)
#include "sp-item.h"
#include "sp-path.h"
#include "sp-item-group.h"
-#include "display/curve.h"
-#include <libnr/n-art-bpath.h>
-#include <libnr/nr-matrix-fns.h>
+//#include <libnr/n-art-bpath.h>
#include "libnr/n-art-bpath-2geom.h"
#include "svg/svg.h"
#include "ui/widget/scalar.h"
index 22f20b820cff26f48423aa96d0d7de9dce65fc63..9cf9f2f26fe16311555bf41fa3ff815c7bb7fafb 100644 (file)
*/
#include "live_effects/lpe-curvestitch.h"
-#include "display/curve.h"
-#include <libnr/n-art-bpath.h>
+
#include "sp-item.h"
#include "sp-path.h"
#include "libnr/n-art-bpath-2geom.h"
#include <2geom/d2.h>
#include <2geom/matrix.h>
-
#include "ui/widget/scalar.h"
#include "libnr/nr-values.h"
index 245b6df0f8577e9c2f76f43d259513c2c6a83225..5ac4a98d420775fd672e79b2d4aed087f4d6c324 100644 (file)
*/
#include "live_effects/lpe-knot.h"
-#include "display/curve.h"
-#include <libnr/n-art-bpath.h>
#include <2geom/path.h>
-//#include <2geom/sbasis.h>
-//#include <2geom/sbasis-geometric.h>
-//#include <2geom/bezier-to-sbasis.h>
-//#include <2geom/sbasis-to-bezier.h>
#include <2geom/d2.h>
-//#include <2geom/sbasis-math.h>
-//#include <2geom/piecewise.h>
#include <2geom/crossing.h>
#include <2geom/path-intersection.h>
index 5be5970c1593b15f85144c580939fba4bd967fe5..57bc458a945da28f879206e0b0b566866c170199 100644 (file)
#include "document.h"
#include "live_effects/lpe-perspective_path.h"
-#include "display/curve.h"
-#include <libnr/n-art-bpath.h>
#include "sp-item-group.h"
#include "inkscape.h"
index 571503d8e0df77172950aac550ee69af9a67500b..04d61bd7313cd221d15b8c542777595c727e1848 100644 (file)
*/
#include "live_effects/lpe-skeleton.h"
-#include "display/curve.h"
-#include <libnr/n-art-bpath.h>
// You might need to include other 2geom files. You can add them here:
#include <2geom/path.h>
// spice this up to make the effect actually *do* something!
}
-NArtBpath *
-LPESkeleton::doEffect_nartbpath (NArtBpath * path_in)
-{
- NArtBpath *path_out;
- unsigned ret = 0;
- while ( path_in[ret].code != NR_END ) {
- ++ret;
- }
- unsigned len = ++ret;
- path_out = g_new(NArtBpath, len);
-
- memcpy(path_out, path_in, len * sizeof(NArtBpath)); // spice this up to make the effect actually *do* something!
-
- return path_out;
-}
-
std::vector<Geom::Path>
LPESkeleton::doEffect_path (std::vector<Geom::Path> & path_in)
{
index 290b8a724a7854a22d9eddeefaed27ac3e1fd24c..6522e9ca3c64b83d19398ddfc5522303e11d4028 100644 (file)
// Choose to implement one of the doEffect functions. You can delete or comment out the others.
// virtual void doEffect (SPCurve * curve);
-// virtual NArtBpath * doEffect_nartbpath (NArtBpath * path_in);
// virtual std::vector<Geom::Path> doEffect_path (std::vector<Geom::Path> & path_in);
virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in);
index 4fc6fc35dc1141c8067be4aaf4891fa249200a04..d0320094176bdbc88232461cd09f6dc1765a1f1d 100644 (file)
*/
#include "live_effects/lpe-sketch.h"
-#include "display/curve.h"
-#include <libnr/n-art-bpath.h>
// You might need to include other 2geom files. You can add them here:
#include <2geom/path.h>
index 407e4399293e0620d13cdfecb1154729d105fa51..7382d15e29034f4c07fbd6a0939f3f76a2d6b644 100644 (file)
void
LPESlant::doEffect(SPCurve * curve)
{
- NArtBpath *bpath = curve->_bpath;
+ NArtBpath *bpath = curve->get_bpath();
int i = 0;
while(bpath[i].code != NR_END) {
bpath[i].y1 += (bpath[i].x1-center[Geom::X]) * factor;
index a193b1a0aed28a022e639be8387c79f8b323d4b2..6994b684bff29f0b31e345b395645161badd327c 100644 (file)
bezctx *bc = new_bezctx_ink(curve);
int len = SP_CURVE_LENGTH(csrc);
spiro_cp *path = g_new (spiro_cp, len + 1);
- NArtBpath *bpath = csrc->_bpath;
+ NArtBpath *bpath = csrc->get_bpath();
int ib = 0;
int ip = 0;
bool closed = false;
index 088d576b1aa1c43a059fa94b60fcff013e12fb1f..ee09221ed5668c28c07a1545f630eb200dcb9dd0 100644 (file)
#include <cstdio>
#include "live_effects/lpe-vonkoch.h"
-#include "sp-shape.h"
-#include "sp-item.h"
-#include "sp-path.h"
-#include "display/curve.h"
-#include <libnr/n-art-bpath.h>
-#include <libnr/nr-matrix-fns.h>
-#include "libnr/n-art-bpath-2geom.h"
#include "svg/svg.h"
#include "ui/widget/scalar.h"
#include "nodepath.h"
index 588d3ec0fa6a767f9827216177deb390d1bd15b3..50f7599c0700d26f4a43b79b55f5159618fee4a4 100644 (file)
#include "sp-item.h"
#include "sp-path.h"
#include "sp-item-group.h"
-#include "display/curve.h"
-#include <libnr/n-art-bpath.h>
-#include <libnr/nr-matrix-fns.h>
#include "libnr/n-art-bpath-2geom.h"
#include "svg/svg.h"
#include "ui/widget/scalar.h"
diff --git a/src/live_effects/parameter/path-reference.cpp b/src/live_effects/parameter/path-reference.cpp
index 78f270e64db5d27b5e20fef50025c085392c8904..a76fb1b32edbdfd65764eb0381439fbc5d5ed5c2 100644 (file)
#include "live_effects/parameter/path-reference.h"
-#include <cstring>
-#include <string>
-#include <string.h>
-
-#include "enums.h"
-
-#include "display/curve.h"
-#include "livarot/Path.h"
-#include "prefs-utils.h"
#include "sp-shape.h"
#include "sp-text.h"
-#include "uri.h"
namespace Inkscape {
namespace LivePathEffect {
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index d50ec769e311ced918c45c8730042169eac6b890..d82b82f0d01645be6ce916da6c4cbf7cd4564064 100644 (file)
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
return NULL;
NArtBpath *bpath = curve->first_bpath();
- gint length = curve->end;
+ gint length = curve->_end;
if (length == 0) {
curve->unref();
return NULL; // prevent crash for one-node paths
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index 4e3321567e26fcaf589ea4868758f9789ac3ea81..ffb776dfeb5df57a268de0c4e87ca291dfca1db1 100644 (file)
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
@@ -232,9 +232,23 @@ void Inkscape::ObjectSnapper::_snapTranslatingGuideToNodes(SnappedConstraints &s
}
}
+/**
+ * Returns index of first NR_END bpath in array.
+ */
+static unsigned sp_bpath_length(NArtBpath const bpath[])
+{
+ g_return_val_if_fail(bpath != NULL, FALSE);
+ unsigned ret = 0;
+ while ( bpath[ret].code != NR_END ) {
+ ++ret;
+ }
+ ++ret;
+ return ret;
+}
+
void Inkscape::ObjectSnapper::_collectPaths(Inkscape::Snapper::PointType const &t,
bool const &first_point,
- NArtBpath *border_bpath) const
+ NArtBpath const *border_bpath) const
{
// Now, let's first collect all paths to snap to. If we have a whole bunch of points to snap,
// e.g. when translating an item using the selector tool, then we will only do this for the
@@ -254,8 +268,14 @@ void Inkscape::ObjectSnapper::_collectPaths(Inkscape::Snapper::PointType const &
}
// Consider the page border for snapping
- if (border_bpath != NULL) {
- _bpaths_to_snap_to->push_back(border_bpath);
+ if (border_bpath != NULL) {
+ // make our own copy of the const*
+ NArtBpath *new_bpath;
+ unsigned const len = sp_bpath_length(border_bpath);
+ new_bpath = g_new(NArtBpath, len);
+ memcpy(new_bpath, border_bpath, len * sizeof(NArtBpath));
+
+ _bpaths_to_snap_to->push_back(new_bpath);
}
for (std::vector<SPItem*>::const_iterator i = _candidates->begin(); i != _candidates->end(); i++) {
bool const &first_point,
std::vector<NR::Point> *unselected_nodes,
SPPath const *selected_path,
- NArtBpath *border_bpath) const
+ NArtBpath const *border_bpath) const
{
_collectPaths(t, first_point, border_bpath);
// Now we can finally do the real snapping, using the paths collected above
{
// Consider the page's border for snapping to
- NArtBpath *border_bpath = _snap_to_page_border ? _getBorderBPath() : NULL;
+ NArtBpath const *border_bpath = _snap_to_page_border ? _getBorderBPath() : NULL;
_collectPaths(t, first_point, border_bpath);
}
// Consider the page's border for snapping to
- NArtBpath *border_bpath = _snap_to_page_border ? _getBorderBPath() : NULL;
+ NArtBpath const *border_bpath = _snap_to_page_border ? _getBorderBPath() : NULL;
if (_snap_to_itempath || _snap_to_bboxpath || _snap_to_page_border) {
unsigned n = (unselected_nodes == NULL) ? 0 : unselected_nodes->size();
_paths_to_snap_to->clear();
}
-NArtBpath* Inkscape::ObjectSnapper::_getBorderBPath() const
+NArtBpath const* Inkscape::ObjectSnapper::_getBorderBPath() const
{
- NArtBpath *border_bpath = NULL;
+ NArtBpath const *border_bpath = NULL;
NR::Rect const border_rect = NR::Rect(NR::Point(0,0), NR::Point(sp_document_width(_named_view->document),sp_document_height(_named_view->document)));
SPCurve const *border_curve = SPCurve::new_from_rect(border_rect);
if (border_curve) {
diff --git a/src/object-snapper.h b/src/object-snapper.h
index 94c9e5a1c2df0aac9a89acbb8f86f52ede7dcb9d..95470ed45ce2254f07f564c3f9d9f3d9bba5f012 100644 (file)
--- a/src/object-snapper.h
+++ b/src/object-snapper.h
bool const &first_point,
std::vector<NR::Point> *unselected_nodes,
SPPath const *selected_path,
- NArtBpath *border_bpath) const;
+ NArtBpath const *border_bpath) const;
void _snapPathsConstrained(SnappedConstraints &sc,
Inkscape::Snapper::PointType const &t,
void _collectPaths(Inkscape::Snapper::PointType const &t,
bool const &first_point,
- NArtBpath *border_bpath = NULL) const;
+ NArtBpath const *border_bpath = NULL) const;
void _clear_paths() const;
- NArtBpath* _getBorderBPath() const;
+ NArtBpath const* _getBorderBPath() const;
bool _snap_to_itemnode;
bool _snap_to_itempath;
diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp
index d43d950fb999e3a593b37ac2c539fdf72ae8ad8e..5b57e326efb52a0f6b357aac3e7adbb54d33f286 100644 (file)
--- a/src/path-chemistry.cpp
+++ b/src/path-chemistry.cpp
// Prevent empty paths from being added to the document
// otherwise we end up with zomby markup in the SVG file
- if(curve->end <= 0)
+ if(curve->_end <= 0)
{
curve->unref();
return NULL;
did = true;
SPPath *path = SP_PATH(i->data);
- SPCurve *rcurve = sp_path_get_curve_reference(path)->reverse();
+ SPCurve *rcurve = sp_path_get_curve_reference(path)->create_reverse();
gchar *str = sp_svg_write_path(SP_CURVE_BPATH(rcurve));
if ( sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(path)) ) {
diff --git a/src/pen-context.cpp b/src/pen-context.cpp
index 270b8148db2bab823e9037c6a53106a21c91c125..d286c6f6c00fcfc3cd0b15e2eaef33bc83879066 100644 (file)
--- a/src/pen-context.cpp
+++ b/src/pen-context.cpp
#include "message-context.h"
#include "prefs-utils.h"
#include "sp-path.h"
-
+#include "display/curve.h"
#include "pixmaps/cursor-pen.xpm"
#include "display/canvas-bpath.h"
#include "display/sp-ctrlline.h"
diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp
index 0ba44dc3359ce9849077d54c1c4e6840aa601ebf..ae3a2fa48dcb10980b6136bab98f4b867d2f0eb8 100644 (file)
--- a/src/pencil-context.cpp
+++ b/src/pencil-context.cpp
#include "document.h"
#include "desktop-style.h"
#include "macros.h"
+#include "display/curve.h"
static void sp_pencil_context_class_init(SPPencilContextClass *klass);
static void sp_pencil_context_init(SPPencilContext *pc);
diff --git a/src/sp-lpe-item.h b/src/sp-lpe-item.h
index d05b75cd09378fc5c79cc27582186440c7b8991a..b3e3d85fc5d17a1b5e31cec4b1b9a5473d6daf62 100644 (file)
--- a/src/sp-lpe-item.h
+++ b/src/sp-lpe-item.h
*/
#include "sp-item.h"
-#include "display/curve.h"
+#include "display/display-forward.h"
#define SP_TYPE_LPE_ITEM (sp_lpe_item_get_type())
#define SP_LPE_ITEM(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_LPE_ITEM, SPLPEItem))
diff --git a/src/sp-path.cpp b/src/sp-path.cpp
index b25397a31b99b1fbc2685292ab3f432e9d97c261..86bc83e2b504efb50f2c391efbaaad18da134e06 100644 (file)
--- a/src/sp-path.cpp
+++ b/src/sp-path.cpp
{
SPCurve *curve = SP_SHAPE(path)->curve;
if (!curve) return 0;
- gint r = curve->end;
- gint i = curve->length - 1;
+ gint r = curve->_end;
+ gint i = curve->_length - 1;
if (i > r) i = r; // sometimes after switching from node editor length is wrong, e.g. f6 - draw - f2 - tab - f1, this fixes it
for (; i >= 0; i --)
if (SP_CURVE_BPATH(curve)[i].code == NR_MOVETO)
diff --git a/src/sp-polygon.cpp b/src/sp-polygon.cpp
index 23225d714539579f3e6793fda7c307204a15805d..4d47778cf7817f125898a35bb52b7dc014e6b035 100644 (file)
--- a/src/sp-polygon.cpp
+++ b/src/sp-polygon.cpp
@@ -208,13 +208,13 @@ static void sp_polygon_set(SPObject *object, unsigned int key, const gchar *valu
if (has_error || *cptr != '\0') {
/* TODO: Flag the document as in error, as per
* http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing. */
- } else if (curve->posSet) {
+ } else if (curve->_posSet) {
/* We've done a moveto but no lineto. I'm not sure how we're supposed to represent
* a single-point polygon in SPCurve: sp_curve_closepath at the time of writing
* doesn't seem to like simply moveto followed by closepath. The following works,
* but won't round-trip properly: I believe it will write as two points rather than
* one. */
- curve->lineto(curve->movePos);
+ curve->lineto(curve->_movePos);
} else if (hascpt) {
curve->closepath();
}
diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp
index 99ebdbe23b6a2dfcdd6d545fe31c8a92168078de..fff9de7d3434fa56b2c35f4f722fb5f3b76abaf6 100644 (file)
--- a/src/sp-shape.cpp
+++ b/src/sp-shape.cpp
#include "macros.h"
#include "display/nr-arena-shape.h"
+#include "display/curve.h"
#include "print.h"
#include "document.h"
#include "style.h"
sp_shape_marker_get_transform(SPShape const *shape, NArtBpath const *bp)
{
g_return_val_if_fail(( is_moveto(SP_CURVE_BPATH(shape->curve)[0].code)
- && ( 0 < shape->curve->end )
- && ( SP_CURVE_BPATH(shape->curve)[shape->curve->end].code == NR_END ) ),
+ && ( 0 < shape->curve->_end )
+ && ( SP_CURVE_BPATH(shape->curve)[shape->curve->_end].code == NR_END ) ),
NR::Matrix(NR::translate(bp->c(3))));
double const angle1 = incoming_tangent(bp);
double const angle2 = outgoing_tangent(bp);
diff --git a/src/splivarot.cpp b/src/splivarot.cpp
index a6bd60cd69743f3b68b155e4d99e1523d6b08d9c..aec2b8f6e234dda1e9e51cf50fd5c00af8a2b4db 100644 (file)
--- a/src/splivarot.cpp
+++ b/src/splivarot.cpp
return dest;
}
+/*
+ * This function is buggy: it can either return a new NArtBpath, or an existing one.
+ * It is therefore unclear whether the caller must g_free the path or not!
+*/
NArtBpath *
bpath_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool transformFull)
{
diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp
index d60282d715c004122a05a9b843017c5b65a51aaf..e4b88ffea65ad7bb0634eabe31b9dea99c7f07fe 100644 (file)
--- a/src/tweak-context.cpp
+++ b/src/tweak-context.cpp
#include "sp-flowtext.h"
#include "display/canvas-bpath.h"
#include "display/canvas-arena.h"
+#include "display/curve.h"
#include "livarot/Shape.h"
#include "isnan.h"
#include "prefs-utils.h"
diff --git a/src/tweak-context.h b/src/tweak-context.h
index 6a94a185b5ffc44867876adf9f2edd29eb6859b1..2157ecdaa794f817ca507f11ef5f1a8a4f96cee7 100644 (file)
--- a/src/tweak-context.h
+++ b/src/tweak-context.h
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "display/curve.h"
#include "event-context.h"
#include <display/display-forward.h>
#include <libnr/nr-point.h>
diff --git a/src/verbs.cpp b/src/verbs.cpp
index 1fb179660fe4187188e66c802f8195ae706a0466..8ac2bec8b255b5bb157bd5088231f1980ee62ad9 100644 (file)
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
#include "draw-context.h"
#include "gradient-drag.h"
#include "sp-guide.h"
-
+#include "display/curve.h"
/**
* \brief Return the name without underscores and ellipsis, for use in dialog