summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2014-03-20 02:27:13 +0000
committerJabiertxof <jtx@jtx.marker.es>2014-03-20 02:27:13 +0000
commit9c0d852d84da8af9cbb07ee2ed0488390225f126 (patch)
tree08f57351249cada5230c0e8057b3836189cbac58 /src/ui
parentupdate to trunk (diff)
downloadinkscape-9c0d852d84da8af9cbb07ee2ed0488390225f126.tar.gz
inkscape-9c0d852d84da8af9cbb07ee2ed0488390225f126.zip
Full refactor of path continuations in bspline-spirolive mode, I think no more suv mac crashes, but need to be full tested again because a lot of things changed.
(bzr r11950.1.308)
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/tools/freehand-base.cpp37
-rw-r--r--src/ui/tools/freehand-base.h4
-rw-r--r--src/ui/tools/pen-tool.cpp5
-rw-r--r--src/ui/tools/pencil-tool.cpp3
4 files changed, 22 insertions, 27 deletions
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp
index 5897ce0ee..cecf0c0ca 100644
--- a/src/ui/tools/freehand-base.cpp
+++ b/src/ui/tools/freehand-base.cpp
@@ -92,7 +92,9 @@ FreehandBase::FreehandBase(gchar const *const *cursor_shape, gint hot_x, gint ho
, white_curves(NULL)
, white_anchors(NULL)
, sa(NULL)
+ , sc(NULL)
, ea(NULL)
+ , ec(NULL)
, waiting_LPE_type(Inkscape::LivePathEffect::INVALID_LPE)
, red_curve_is_valid(false)
, anchor_statusbar(false)
@@ -153,6 +155,12 @@ void FreehandBase::setup() {
this->green_anchor = NULL;
this->green_closed = FALSE;
+ // Create start anchor alternative curve
+ this->sc = new SPCurve();
+
+ // Create end anchor alternative curve
+ this->ec = new SPCurve();
+
this->attach = TRUE;
spdc_attach_selection(this, this->selection);
}
@@ -524,6 +532,10 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed)
dc->sc->append_continuous(c, 0.0625);
c->unref();
dc->sc->closepath_current();
+ if(dc->sa){
+ dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve);
+ dc->white_curves = g_slist_append(dc->white_curves, dc->sc);
+ }
}else{
dc->sa->curve->append_continuous(c, 0.0625);
c->unref();
@@ -536,11 +548,11 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed)
// Step C - test start
if (dc->sa) {
SPCurve *s = dc->sa->curve;
+ dc->white_curves = g_slist_remove(dc->white_curves, s);
if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 ||
prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){
s = dc->sc;
}
- dc->white_curves = g_slist_remove(dc->white_curves, s);
if (dc->sa->start) {
s = reverse_then_unref(s);
}
@@ -549,11 +561,11 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed)
c = s;
} else /* Step D - test end */ if (dc->ea) {
SPCurve *e = dc->ea->curve;
+ dc->white_curves = g_slist_remove(dc->white_curves, e);
if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 ||
prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){
e = dc->ec;
}
- dc->white_curves = g_slist_remove(dc->white_curves, e);
if (!dc->ea->start) {
e = reverse_then_unref(e);
}
@@ -570,20 +582,9 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed)
static void spdc_flush_white(FreehandBase *dc, SPCurve *gc)
{
SPCurve *c;
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
if (dc->white_curves) {
g_assert(dc->white_item);
- if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 ||
- prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){
- if(dc->sa){
- dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve);
- dc->white_curves = g_slist_append(dc->white_curves, dc->sc);
- }
- if(dc->ea){
- dc->white_curves = g_slist_remove(dc->white_curves, dc->ea->curve);
- dc->white_curves = g_slist_append(dc->white_curves, dc->ec);
- }
- }
c = SPCurve::concat(dc->white_curves);
g_slist_free(dc->white_curves);
dc->white_curves = NULL;
@@ -723,14 +724,6 @@ static void spdc_free_colors(FreehandBase *dc)
dc->blue2_curve = dc->blue2_curve->unref();
}
- if (dc->sc) {
- dc->sc = dc->sc->unref();
- }
-
- if (dc->ec) {
- dc->ec = dc->ec->unref();
- }
-
// Green
while (dc->green_bpaths) {
sp_canvas_item_destroy(SP_CANVAS_ITEM(dc->green_bpaths->data));
diff --git a/src/ui/tools/freehand-base.h b/src/ui/tools/freehand-base.h
index 266e22783..c134c5352 100644
--- a/src/ui/tools/freehand-base.h
+++ b/src/ui/tools/freehand-base.h
@@ -74,11 +74,11 @@ public:
// Start anchor
SPDrawAnchor *sa;
- SPCurve * sc;
+ SPCurve *sc;
// End anchor
SPDrawAnchor *ea;
- SPCurve * ec;
+ SPCurve *ec;
/* type of the LPE that is to be applied automatically to a finished path (if any) */
Inkscape::LivePathEffect::EffectType waiting_LPE_type;
diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp
index 1701cf5d9..3ef9b96af 100644
--- a/src/ui/tools/pen-tool.cpp
+++ b/src/ui/tools/pen-tool.cpp
@@ -1516,7 +1516,6 @@ void PenTool::_bspline_spiro_start_anchor_on()
if (this->sa->start) {
tmpCurve = tmpCurve->create_reverse();
}
- this->sc->reset();
this->sc = tmpCurve;
}
@@ -1542,7 +1541,6 @@ void PenTool::_bspline_spiro_start_anchor_off()
if (this->sa->start) {
tmpCurve = tmpCurve->create_reverse();
}
- this->sc->reset();
this->sc = tmpCurve;
}
@@ -1677,7 +1675,6 @@ void PenTool::_bspline_spiro_end_anchor_on()
if (!this->sa->start) {
tmpCurve = tmpCurve->create_reverse();
}
- this->sc->reset();
this->sc = tmpCurve;
}
}
@@ -2176,6 +2173,8 @@ void PenTool::_finish(gboolean const closed) {
// cancelate line without a created segment
this->red_curve->reset();
spdc_concat_colors_and_flush(this, closed);
+ this->sc = NULL;
+ this->ec = NULL;
this->sa = NULL;
this->ea = NULL;
diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp
index 1ccdee637..8fe01a852 100644
--- a/src/ui/tools/pencil-tool.cpp
+++ b/src/ui/tools/pencil-tool.cpp
@@ -203,6 +203,7 @@ gint PencilTool::_handleButtonPress(GdkEventButton const &bevent) {
}
if (anchor) {
p = anchor->dp;
+ this->sc = anchor->curve;
desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Continuing selected path"));
} else {
m.setup(desktop);
@@ -380,6 +381,7 @@ gint PencilTool::_handleButtonRelease(GdkEventButton const &revent) {
/* Finish segment now */
if (anchor) {
p = anchor->dp;
+ this->ec = anchor->curve;
} else {
this->_endpointSnap(p, revent.state);
}
@@ -406,6 +408,7 @@ gint PencilTool::_handleButtonRelease(GdkEventButton const &revent) {
/// \todo fixme: Clean up what follows (Lauris)
if (anchor) {
p = anchor->dp;
+ this->ec = anchor->curve;
} else {
Geom::Point p_end = p;
this->_endpointSnap(p_end, revent.state);