summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjtx <javier.arraiza@marker.es>2013-02-14 17:44:03 +0000
committerjtx <javier.arraiza@marker.es>2013-02-14 17:44:03 +0000
commite18ec9f6b20ec15306e07adfad1587a6ae9b7f59 (patch)
tree66c5c58dc4c43c712745cd50cfeb986539ca321c /src
parentFirst Steps, BSpline Live Path Ok, working Pen Context (diff)
parentAll done except cusp continuous and close bspline (diff)
downloadinkscape-e18ec9f6b20ec15306e07adfad1587a6ae9b7f59.tar.gz
inkscape-e18ec9f6b20ec15306e07adfad1587a6ae9b7f59.zip
Fix cusp continuous? path close broken
(bzr r11950.3.1)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/lpe-bspline.cpp2
-rw-r--r--src/pen-context.cpp120
-rw-r--r--src/ui/tool/path-manipulator.cpp23
3 files changed, 112 insertions, 33 deletions
diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp
index 408f0f8a6..0ce18dcea 100644
--- a/src/live_effects/lpe-bspline.cpp
+++ b/src/live_effects/lpe-bspline.cpp
@@ -98,7 +98,7 @@ LPEBSpline::doEffect(SPCurve * curve)
cubicIn = dynamic_cast<Geom::CubicBezier const*>(&*curve_it1);
cubicOut = dynamic_cast<Geom::CubicBezier const*>(&*curve_it2);
cubicEnd = dynamic_cast<Geom::CubicBezier const*>(&*curve_end);
- if (path_it->closed() && cubicIn && cubicEnd && (*cubicIn)[1] != (*cubicEnd)[2]){
+ if (path_it->closed() && cubicEnd && (*cubicEnd)[3] != (*cubicEnd)[2]){
//Calculamos el nodo de inicio BSpline
SBasisIn = in->first_segment()->toSBasis();
SBasisEnd = end->first_segment()->toSBasis();
diff --git a/src/pen-context.cpp b/src/pen-context.cpp
index 3c8e46a54..9577ecbf9 100644
--- a/src/pen-context.cpp
+++ b/src/pen-context.cpp
@@ -583,7 +583,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
//BSpline
//Esto evita arrastrar los manejadores ya que el punto se crea
//al soltar el botón del ratón.
- if((pc->spiro || pc->bspline) && pc->state != SP_PEN_CONTEXT_CLOSE ) pc->state = SP_PEN_CONTEXT_POINT;
+ if((pc->spiro || pc->bspline) && pc->state != SP_PEN_CONTEXT_CLOSE) pc->state = SP_PEN_CONTEXT_POINT;
//BSpline End
ret = TRUE;
break;
@@ -984,8 +984,20 @@ static void pen_redraw_all (SPPenContext *const pc)
// handles
//BSpline
- if (pc->p[0] != pc->p[1] && !pc->spiro && !pc->bspline) {
+ SPCurve * WPower = new SPCurve();
+ Geom::D2< Geom::SBasis > SBasisWPower;
+ float WP = 0;
+ if (pc->p[0] != pc->p[1] && !pc->spiro /*&& !pc->bspline*/) {
//BSpline End
+ if(pc->bspline){
+ WPower->moveto(pc->red_curve->first_segment()->initialPoint());
+ WPower->lineto(pc->red_curve->first_segment()->finalPoint());
+ SBasisWPower = WPower->first_segment()->toSBasis();
+
+ WPower->reset();
+ pc->p[1] = SBasisWPower.valueAt(WP);
+ }
+
SP_CTRL(pc->c1)->moveto(pc->p[1]);
pc->cl1->setCoords(pc->p[0], pc->p[1]);
sp_canvas_item_show(pc->c1);
@@ -994,16 +1006,23 @@ static void pen_redraw_all (SPPenContext *const pc)
sp_canvas_item_hide(pc->c1);
sp_canvas_item_hide(pc->cl1);
}
-
+ Geom::Point p2;
Geom::Curve const * last_seg = pc->green_curve->last_segment();
if (last_seg) {
Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const *>( last_seg );
//BSpline
if ( cubic &&
- (*cubic)[2] != pc->p[0]&& !pc->spiro && !pc->bspline )
+ (*cubic)[2] != pc->p[0]&& !pc->spiro /*&& !pc->bspline*/ )
{
//BSpline End
- Geom::Point p2 = (*cubic)[2];
+ if(pc->bspline){
+ WPower->moveto(last_seg->finalPoint());
+ WPower->lineto(last_seg->initialPoint());
+ SBasisWPower = WPower->first_segment()->toSBasis();
+ p2 = SBasisWPower.valueAt(WP);
+ }else{
+ p2 = (*cubic)[2];
+ }
SP_CTRL(pc->c0)->moveto(p2);
pc->cl0->setCoords(p2, pc->p[0]);
sp_canvas_item_show(pc->c0);
@@ -1766,16 +1785,10 @@ static void spiro_doEffect(SPCurve * curve)
//Unimos todas las curvas en juego y llamamos a la función doEffect.
static void bspline(SPPenContext *const pc, bool Shift)
{
+ using Geom::X;
+ using Geom::Y;
+ Geom::CubicBezier const *cubic;
if(!Shift){
-
- using Geom::X;
- using Geom::Y;
- Geom::CubicBezier const *cubic;
- //Continuamos la curva en modo CUSP
- //Guardamos el valor de inicio en cusp para que no se redibuje como SYMM
- if(pc->anchor_statusbar && pc->red_curve->is_empty()){
- saShift = true;
- }
//NODO CUSP formado por nodo SMOOTH
//solo mobemos el manejador del nodo final de cada segmento
//Es suficiente para mostrar el nodo como CUSP
@@ -1784,34 +1797,81 @@ static void bspline(SPPenContext *const pc, bool Shift)
pc->npoints = 5;
pc->p[0] = pc->red_curve->first_segment()->initialPoint();
pc->p[3] = pc->red_curve->first_segment()->finalPoint();
- if(pc->green_curve->is_empty())
- pc->p[1] = pc->p[0] + (1./3)*(pc->p[0] - pc->p[3]);
- else
+ if(pc->green_curve->is_empty()){
+ pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]);
+ pc->p[1] = Geom::Point(pc->p[1][X]+1,pc->p[1][Y]+1);
+ }else{
cubic = dynamic_cast<Geom::CubicBezier const*>(&*pc->green_curve->last_segment());
- if(cubic && ((*cubic)[2] == (*cubic)[3]))
+ if(!cubic || ((*cubic)[2] == (*cubic)[3]))
pc->p[1] = pc->p[0];
- else
- pc->p[1] = pc->p[0] + (1./3)*(pc->p[0] - pc->p[3]);
+ else{
+ SPCurve * WPower = new SPCurve();
+ Geom::D2< Geom::SBasis > SBasisWPower;
+ WPower->moveto(pc->green_curve->last_segment()->finalPoint());
+ WPower->lineto(pc->green_curve->last_segment()->initialPoint());
+ float WP = Geom::nearest_point((*cubic)[2],*WPower->first_segment());
+ WPower->reset();
+ WPower->moveto(pc->red_curve->last_segment()->initialPoint());
+ WPower->lineto(pc->red_curve->last_segment()->finalPoint());
+ SBasisWPower = WPower->first_segment()->toSBasis();
+ WPower->reset();
+ pc->p[1] = SBasisWPower.valueAt(WP);
+ pc->p[1] = Geom::Point(pc->p[1][X]+1,pc->p[1][Y]+1);
+ }
+ }
pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]);
+ pc->p[2] = Geom::Point(pc->p[2][X]+1,pc->p[2][Y]+1);
}
+ if(pc->green_curve->is_empty() && saShift)
+ pc->p[1] = pc->p[0];
+ if(pc->anchor_statusbar && pc->red_curve->is_empty())
+ saShift = false;
}else{
+ //Continuamos la curva en modo CUSP
+ //Guardamos el valor de inicio en cusp para que no se redibuje como SYMM
if(pc->anchor_statusbar && pc->red_curve->is_empty()){
- saShift = false;
+ saShift = true;
+ SPCurve *previousCurve = new SPCurve();
+ if(pc->sa && !pc->sa->curve->is_empty()){
+ previousCurve = pc->sa->curve->copy();
+ if (pc->sa->start) {
+ previousCurve = previousCurve->create_reverse();
+ }
+ cubic = dynamic_cast<Geom::CubicBezier const*>(&*previousCurve->last_segment());
+ if(cubic){
+ SPCurve *lastSeg = new SPCurve();
+ lastSeg->moveto((*cubic)[0]);
+ lastSeg->curveto((*cubic)[1],(*cubic)[3],(*cubic)[3]);
+ previousCurve->backspace();
+ previousCurve->append_continuous(lastSeg, 0.0625);
+ pc->sa = previousCurve;
+ }
+ }
}
+
if(!pc->green_curve->is_empty()){
//Damos valor original a la variable por si se necesita de nuevo
saShift = false;
}
- if (pc->npoints == 5 || !pc->red_curve->is_empty()){
- pc->npoints = 2;
- pc->p[1]= pc->p[3];
- }
- if(pc->green_curve->is_empty() && saShift){
+ if (!pc->red_curve->is_empty()){
pc->npoints = 5;
- pc->p[3] = pc->p[1];
- pc->p[2] = pc->p[3];
- pc->p[1] = pc->p[0] + (1./3)*(pc->p[0] - pc->p[3]);
+ pc->p[0] = pc->red_curve->first_segment()->initialPoint();
+ pc->p[3] = pc->red_curve->first_segment()->finalPoint();
+ if(pc->green_curve->is_empty()){
+ pc->p[1] = pc->p[0];
+ }else{
+ cubic = dynamic_cast<Geom::CubicBezier const*>(&*pc->green_curve->last_segment());
+ if(!cubic || ((*cubic)[2] == (*cubic)[3])){
+ pc->p[1] = pc->p[0];
+ pc->p[2] = pc->p[3];
+ }else{
+ pc->p[1] = pc->p[0] + (1./3)*(pc->p[3] - pc->p[0]);
+ pc->p[1] = Geom::Point(pc->p[1][X]+1,pc->p[1][Y]+1);
+ pc->p[2] = pc->p[3];
+ }
+
+ }
}
}
bspline_build(pc);
@@ -1944,7 +2004,7 @@ static void bspline_doEffect(SPCurve * curve)
cubicIn = dynamic_cast<Geom::CubicBezier const*>(&*curve_it1);
cubicOut = dynamic_cast<Geom::CubicBezier const*>(&*curve_it2);
cubicEnd = dynamic_cast<Geom::CubicBezier const*>(&*curve_end);
- if (path_it->closed() && cubicIn && cubicEnd && (*cubicIn)[1] != (*cubicEnd)[2]){
+ if (path_it->closed()){
//Calculamos el nodo de inicio BSpline
SBasisIn = in->first_segment()->toSBasis();
SBasisEnd = end->first_segment()->toSBasis();
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp
index 35eb23f42..f1b2e12be 100644
--- a/src/ui/tool/path-manipulator.cpp
+++ b/src/ui/tool/path-manipulator.cpp
@@ -9,7 +9,9 @@
* Copyright (C) 2009 Authors
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-
+//BSpline
+#include "live_effects/lpe-bspline.h"
+//BSpline end
#include "live_effects/lpe-powerstroke.h"
#include <string>
#include <sstream>
@@ -1257,9 +1259,26 @@ void PathManipulator::_updateOutline()
sp_canvas_item_hide(_outline);
return;
}
-
Geom::PathVector pv = _spcurve->get_pathvector();
pv *= (_edit_transform * _i2d_transform);
+ //BSpline
+ if (SP_IS_LPE_ITEM(_path) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(_path))) {
+ PathEffectList effect_list = sp_lpe_item_get_effect_list(SP_LPE_ITEM(_path));
+ LivePathEffect::LPEBSpline *lpe_bsp = dynamic_cast<LivePathEffect::LPEBSpline*>( effect_list.front()->lpeobject->get_lpe());
+ if (lpe_bsp) {
+ Geom::PathVector pv2;
+ for (Geom::PathVector::iterator i = pv.begin(); i != pv.end(); ++i) {
+ Geom::Path &path = *i;
+ for (Geom::Path::const_iterator j = path.begin(); j != path.end_default(); ++j) {
+ Geom::Path pv2j(j->pointAt(0));
+ pv2j.appendNew<Geom::LineSegment>(j->pointAt(1));
+ pv2.push_back(pv2j);
+ }
+ }
+ pv = pv2;
+ }
+ }
+ //BSpline End
// This SPCurve thing has to be killed with extreme prejudice
SPCurve *_hc = new SPCurve();
if (_show_path_direction) {