From afcec343e905389d2645115d60f14dfd45f5f2d0 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 14 Dec 2012 01:01:57 +0100 Subject: bzr history lost by a killed merge (bzr r11950.1.1) --- src/live_effects/CMakeLists.txt | 2 ++ src/live_effects/Makefile_insert | 2 ++ src/live_effects/effect-enum.h | 3 +++ src/live_effects/effect.cpp | 13 ++++++++++++- 4 files changed, 19 insertions(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt index a5f50a69d..7aeb911b0 100644 --- a/src/live_effects/CMakeLists.txt +++ b/src/live_effects/CMakeLists.txt @@ -34,6 +34,7 @@ set(live_effects_SRC lpe-spiro.cpp lpe-tangent_to_curve.cpp lpe-test-doEffect-stack.cpp + lpe-bspline.cpp lpe-text_label.cpp lpe-vonkoch.cpp lpegroupbbox.cpp @@ -94,6 +95,7 @@ set(live_effects_SRC lpe-spiro.h lpe-tangent_to_curve.h lpe-test-doEffect-stack.h + lpe-bspline.h lpe-text_label.h lpe-vonkoch.h lpegroupbbox.h diff --git a/src/live_effects/Makefile_insert b/src/live_effects/Makefile_insert index 9c3c171f2..248030e8c 100644 --- a/src/live_effects/Makefile_insert +++ b/src/live_effects/Makefile_insert @@ -38,6 +38,8 @@ ink_common_sources += \ live_effects/lpe-interpolate.h \ live_effects/lpe-test-doEffect-stack.cpp \ live_effects/lpe-test-doEffect-stack.h \ + live_effects/lpe-bspline.cpp \ + live_effects/lpe-bspline.h \ live_effects/lpe-lattice.cpp \ live_effects/lpe-lattice.h \ live_effects/lpe-envelope.cpp \ diff --git a/src/live_effects/effect-enum.h b/src/live_effects/effect-enum.h index 43af33b53..cf97dd87f 100644 --- a/src/live_effects/effect-enum.h +++ b/src/live_effects/effect-enum.h @@ -45,6 +45,9 @@ enum EffectType { PATH_LENGTH, LINE_SEGMENT, DOEFFECTSTACK_TEST, + //BSpline + BSPLINE, + //BSpline End DYNASTROKE, RECURSIVE_SKELETON, EXTRUDE, diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 3b57de25c..e9ec2076f 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -10,7 +10,7 @@ #include "live_effects/effect.h" #ifdef HAVE_CONFIG_H -# include "config.h" +#include "config.h" #endif // include effects: @@ -22,6 +22,9 @@ #include "live_effects/lpe-rough-hatches.h" #include "live_effects/lpe-dynastroke.h" #include "live_effects/lpe-test-doEffect-stack.h" +//BSpline +#include "live_effects/lpe-bspline.h" +//BSpline End #include "live_effects/lpe-gears.h" #include "live_effects/lpe-curvestitch.h" #include "live_effects/lpe-circle_with_radius.h" @@ -123,6 +126,9 @@ const Util::EnumData LPETypeData[] = { /* 0.49 */ {POWERSTROKE, N_("Power stroke"), "powerstroke"}, {CLONE_ORIGINAL, N_("Clone original path"), "clone_original"}, + //BSpline + {BSPLINE, N_("BSpline"), "bspline"}, + //BSpline End }; const Util::EnumDataConverter LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData)); @@ -231,6 +237,11 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj) case DOEFFECTSTACK_TEST: neweffect = static_cast ( new LPEdoEffectStackTest(lpeobj) ); break; + //BSpline + case BSPLINE: + neweffect = static_cast ( new LPEBSpline(lpeobj) ); + break; + //BSpline End case DYNASTROKE: neweffect = static_cast ( new LPEDynastroke(lpeobj) ); break; -- cgit v1.2.3 From d395af6ee332142c63355d008d49b1f4b3487dfe Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 24 Dec 2012 08:05:24 +0100 Subject: Going to merge (bzr r11950.1.5) --- src/live_effects/lpe-bspline.cpp | 226 +++++++++++++++++++++++++++++++++++++++ src/live_effects/lpe-bspline.h | 35 ++++++ 2 files changed, 261 insertions(+) create mode 100644 src/live_effects/lpe-bspline.cpp create mode 100644 src/live_effects/lpe-bspline.h (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp new file mode 100644 index 000000000..e125cc4e0 --- /dev/null +++ b/src/live_effects/lpe-bspline.cpp @@ -0,0 +1,226 @@ +#define INKSCAPE_LPE_BSPLINE_C + +/* + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "live_effects/lpe-bspline.h" + +#include "display/curve.h" +#include +#include <2geom/pathvector.h> +#include <2geom/affine.h> +#include <2geom/bezier-curve.h> +#include "helper/geom-curves.h" + +// For handling un-continuous paths: +#include "message-stack.h" +#include "inkscape.h" +#include "desktop.h" + +namespace Inkscape { +namespace LivePathEffect { + +LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) : + Effect(lpeobject) +{ +} + +LPEBSpline::~LPEBSpline() +{ +} +//Crea una nueva curva reseteando la original +SPCurve * +LPEBSpline::reverse_then_reset(SPCurve * orig){ + SPCurve *ret = orig->create_reverse(); + orig->reset(); + return ret; +} + +void +LPEBSpline::doEffect(SPCurve * curve) +{ + using Geom::X; + using Geom::Y; + + // Make copy of old path as it is changed during processing + Geom::PathVector const original_pathv = curve->get_pathvector(); + curve->reset(); + //Sbasis + Geom::D2< Geom::SBasis > SBasisIn; + Geom::D2< Geom::SBasis > SBasisOut; + Geom::D2< Geom::SBasis > SBasisEnd; + Geom::D2< Geom::SBasis > SBasisHelper; + //curves + SPCurve * in = new SPCurve(); + SPCurve * out = new SPCurve(); + SPCurve * end = new SPCurve(); + //Curvas temporales + SPCurve *lineHelper = new SPCurve(); + SPCurve *curveHelper = new SPCurve(); + SPCurve *nCurve = new SPCurve(); + //Puntos a usar. Ponemos todos los posibles para hacer más inteligible el código + Geom::Point startNode(0,0); + Geom::Point previousNode(0,0); + Geom::Point node(0,0); + //Geom::Point previousPointAt3(0,0); + Geom::Point pointAt0(0,0); + Geom::Point pointAt1(0,0); + Geom::Point pointAt2(0,0); + Geom::Point pointAt3(0,0); + //Geom::Point nextPointAt0(0,0); + Geom::Point nextPointAt1(0,0); + Geom::Point nextPointAt2(0,0); + Geom::Point nextPointAt3(0,0); + + //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo + for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { + //Si está vacío... + if (path_it->empty()) + continue; + //Itreadores + Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve + Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve + Geom::Path::const_iterator curve_end = path_it->end(); // end curve + Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop + //Las lineas rectas forman nodos BSpline + //Las curvas forman nodos CUSP + bool isBSpline = true; + //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán + //los puntos clave para los manejadores. + //Esto hace que la curva BSpline no pierda su condición aunque se trasladen + //dichos manejadores + in->moveto(curve_it1->initialPoint()); + in->lineto(curve_it1->finalPoint()); + out->moveto(curve_it2->initialPoint()); + out->lineto(curve_it2->finalPoint()); + //este no cambia. + end->moveto(curve_end->initialPoint()); + end->lineto(curve_end->finalPoint()); + //Si la curva está cerrada calculamos el punto donde + //deveria estar el nodo BSpline de cierre/inicio de la curva + //en posible caso de que se cierre con una linea recta creando un nodo BSPline + if (path_it->closed() && is_straight_curve(*curve_end)) { + //Calculamos el nodo de inicio BSpline + SBasisIn = in->first_segment()->toSBasis(); + SBasisEnd = end->first_segment()->toSBasis(); + lineHelper->moveto(SBasisIn.valueAt(0.3334)); + lineHelper->lineto(SBasisEnd.valueAt(0.6664)); + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + //Guardamos el principio de la curva + startNode = SBasisHelper.valueAt(0.5); + //Definimos el punto de inicio original de la curva resultante + node = startNode; + }else{ + //Guardamos el principio de la curva + startNode = in->first_segment()->initialPoint(); + //Definimos el punto de inicio original de la curva resultante + node = startNode; + } + //Recorremos todos los segmentos menos el último + while ( curve_it2 != curve_endit ) + { + //Damos valor a el objeto SBasis para el path de entrada y el de salida + SBasisIn = in->first_segment()->toSBasis(); + SBasisOut = out->first_segment()->toSBasis(); + //previousPointAt3 = pointAt3; + //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida + pointAt0 = SBasisIn.valueAt(0); + pointAt1 = SBasisIn.valueAt(0.3334); + pointAt2 = SBasisIn.valueAt(0.6667); + pointAt3 = SBasisIn.valueAt(1); + //Y hacemos lo propio con el path de salida + //nextPointAt0 = curveOut.valueAt(0); + nextPointAt1 = SBasisOut.valueAt(0.3334); + nextPointAt2 = SBasisOut.valueAt(0.6667);; + nextPointAt3 = SBasisOut.valueAt(1); + //La curva BSpline se forma calculando el centro del segmanto de unión + //de el punto situado en las 2/3 partes de el segmento de entrada + //con el punto situado en la posición 1/3 del segmento de salida + //Estos dos puntos ademas estan posicionados en el lugas correspondiente de + //los manejadores de la curva + lineHelper->moveto(pointAt2); + lineHelper->lineto(nextPointAt1); + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de principio de curva + previousNode = node; + //Y este hará de final de curva + node = SBasisHelper.valueAt(0.5); + //Vemos si el nodo es BSpline o CUSP + //Averiguamos si el path de entrada es recto o tiene manejadores + isBSpline = is_straight_curve(*curve_it1); + //Si no es recto, tenemos que generar la curva con nodo final CUSP + if(!isBSpline ){ + //Definimos como nodo el final del segmento de entrada + node = pointAt3; + } + curveHelper->moveto(previousNode); + curveHelper->curveto(pointAt1, pointAt2, node); + //añadimos la curva generada a la curva pricipal + nCurve->append_continuous(curveHelper, 0.0625); + curveHelper->reset(); + //aumentamos los valores para el siguiente paso en el bucle + ++curve_it1; + ++curve_it2; + in->reset(); + in->moveto(curve_it1->initialPoint()); + in->lineto(curve_it1->finalPoint()); + out->reset(); + if(curve_it1 != curve_end){ + out->moveto(curve_it2->initialPoint()); + out->lineto(curve_it2->finalPoint()); + } + } + //Aberiguamos la ultima parte de la curva correspondiente al último segmento + curveHelper->moveto(node); + //Si está cerrada la curva, la cerramos sobre el valor guardado previamente + //Si no finalizamos en el punto final + if (path_it->closed()) { + curveHelper->curveto(nextPointAt1, nextPointAt2, startNode); + }else{ + curveHelper->curveto(nextPointAt1, nextPointAt2, nextPointAt3); + } + //añadimos este último segmento + nCurve->append_continuous(curveHelper, 0.0625); + //y cerramos la curva + if (path_it->closed()) { + nCurve->closepath_current(); + } + curve->append(nCurve,false); + nCurve->reset(); + //Limpiamos + in->reset(); + out->reset(); + end->reset(); + lineHelper->reset(); + curveHelper->reset(); + } + delete in; + delete out; + delete end; + delete lineHelper; + delete curveHelper; + //Todo: remove? + //delete SBasisIn; + //delete SBasisOut; + //delete SBasisEnd; + //delete SBasisHelper; +} + + + +}; //namespace LivePathEffect +}; /* namespace Inkscape */ + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h new file mode 100644 index 000000000..23ac495df --- /dev/null +++ b/src/live_effects/lpe-bspline.h @@ -0,0 +1,35 @@ +#ifndef INKSCAPE_LPE_BSPLINE_H +#define INKSCAPE_LPE_BSPLINE_H + +/* + * Inkscape::LPEBSpline + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "live_effects/effect.h" + + +namespace Inkscape { +namespace LivePathEffect { + +class LPEBSpline : public Effect { +public: + LPEBSpline(LivePathEffectObject *lpeobject); + virtual ~LPEBSpline(); + + virtual LPEPathFlashType pathFlashType() { return SUPPRESS_FLASH; } + + virtual SPCurve *reverse_then_reset(SPCurve * orig); + + virtual void doEffect(SPCurve * curve); + +private: + LPEBSpline(const LPEBSpline&); + LPEBSpline& operator=(const LPEBSpline&); +}; + +}; //namespace LivePathEffect +}; //namespace Inkscape + +#endif -- cgit v1.2.3 From eac303cf672b1c09a0378ca8b34aafcfdf4ee08d Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 4 Jan 2013 22:30:00 +0100 Subject: Fixing StartAnchor problems in bspline (bzr r11950.1.10) --- src/live_effects/lpe-bspline.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index e125cc4e0..24e7a5027 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -13,6 +13,7 @@ #include <2geom/bezier-curve.h> #include "helper/geom-curves.h" + // For handling un-continuous paths: #include "message-stack.h" #include "inkscape.h" @@ -72,6 +73,8 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); + Geom::CubicBezier const * cubic; + Geom::PathVector newpathv; //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { @@ -79,6 +82,7 @@ LPEBSpline::doEffect(SPCurve * curve) if (path_it->empty()) continue; //Itreadores + Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve Geom::Path::const_iterator curve_end = path_it->end(); // end curve @@ -100,7 +104,12 @@ LPEBSpline::doEffect(SPCurve * curve) //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - if (path_it->closed() && is_straight_curve(*curve_end)) { + + cubic = dynamic_cast(&*curve_endit); + if((*cubic)[2] == (*cubic)[3]) + isBSpline = false; + if (path_it->closed() && !isBSpline) { + isBSpline = true; //Calculamos el nodo de inicio BSpline SBasisIn = in->first_segment()->toSBasis(); SBasisEnd = end->first_segment()->toSBasis(); @@ -149,9 +158,11 @@ LPEBSpline::doEffect(SPCurve * curve) //Y este hará de final de curva node = SBasisHelper.valueAt(0.5); //Vemos si el nodo es BSpline o CUSP - //Averiguamos si el path de entrada es recto o tiene manejadores - isBSpline = is_straight_curve(*curve_it1); - //Si no es recto, tenemos que generar la curva con nodo final CUSP + //Averiguamos si el punto de union tiene manejadores + cubic = dynamic_cast(&*curve_it1); + if((*cubic)[2] == (*cubic)[3]) + isBSpline = true; + //Si no tiene manejador, tenemos que generar la curva con nodo final CUSP if(!isBSpline ){ //Definimos como nodo el final del segmento de entrada node = pointAt3; -- cgit v1.2.3 From 32866e3ed73a2a8c41520e2538687b5701a2d347 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 5 Jan 2013 11:53:55 +0100 Subject: fix continue (bzr r11950.1.11) --- src/live_effects/lpe-bspline.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 24e7a5027..c8263282e 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -1,5 +1,5 @@ +#define INKSCAPE_HELPER_GEOM_CURVES_H #define INKSCAPE_LPE_BSPLINE_C - /* * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -73,9 +73,6 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); - Geom::CubicBezier const * cubic; - Geom::PathVector newpathv; - //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { //Si está vacío... @@ -104,10 +101,10 @@ LPEBSpline::doEffect(SPCurve * curve) //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - - cubic = dynamic_cast(&*curve_endit); - if((*cubic)[2] == (*cubic)[3]) - isBSpline = false; + if (Geom::CubicBezier const *cubic = dynamic_cast(&*curve_end)){ + if((*cubic)[2] == (*cubic)[3]) + isBSpline = false; + } if (path_it->closed() && !isBSpline) { isBSpline = true; //Calculamos el nodo de inicio BSpline @@ -159,9 +156,10 @@ LPEBSpline::doEffect(SPCurve * curve) node = SBasisHelper.valueAt(0.5); //Vemos si el nodo es BSpline o CUSP //Averiguamos si el punto de union tiene manejadores - cubic = dynamic_cast(&*curve_it1); - if((*cubic)[2] == (*cubic)[3]) - isBSpline = true; + if (Geom::CubicBezier const *cubic = dynamic_cast(&*curve_it1)){ + if((*cubic)[2] == (*cubic)[3]) + isBSpline = true; + } //Si no tiene manejador, tenemos que generar la curva con nodo final CUSP if(!isBSpline ){ //Definimos como nodo el final del segmento de entrada @@ -221,7 +219,6 @@ LPEBSpline::doEffect(SPCurve * curve) } - }; //namespace LivePathEffect }; /* namespace Inkscape */ -- cgit v1.2.3 From 74b658f45b5044ab5903ccc255c1ae0f8a750fce Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 6 Jan 2013 19:20:10 +0100 Subject: fix continue (bzr r11950.1.12) --- src/live_effects/lpe-bspline.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index c8263282e..a57cc9a88 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -1,4 +1,3 @@ -#define INKSCAPE_HELPER_GEOM_CURVES_H #define INKSCAPE_LPE_BSPLINE_C /* * Released under GNU GPL, read the file 'COPYING' for more information @@ -73,6 +72,7 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); + Geom::CubicBezier const *cubic; //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { //Si está vacío... @@ -101,17 +101,15 @@ LPEBSpline::doEffect(SPCurve * curve) //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - if (Geom::CubicBezier const *cubic = dynamic_cast(&*curve_end)){ - if((*cubic)[2] == (*cubic)[3]) - isBSpline = false; - } - if (path_it->closed() && !isBSpline) { - isBSpline = true; + cubic = dynamic_cast(&*curve_end); + if(cubic && (*cubic)[2] != (*cubic)[3]) + isBSpline = false; + if (path_it->closed() && isBSpline) { //Calculamos el nodo de inicio BSpline SBasisIn = in->first_segment()->toSBasis(); SBasisEnd = end->first_segment()->toSBasis(); lineHelper->moveto(SBasisIn.valueAt(0.3334)); - lineHelper->lineto(SBasisEnd.valueAt(0.6664)); + lineHelper->lineto(SBasisEnd.valueAt(0.6667)); SBasisHelper = lineHelper->first_segment()->toSBasis(); lineHelper->reset(); //Guardamos el principio de la curva @@ -119,6 +117,7 @@ LPEBSpline::doEffect(SPCurve * curve) //Definimos el punto de inicio original de la curva resultante node = startNode; }else{ + isBSpline = true; //Guardamos el principio de la curva startNode = in->first_segment()->initialPoint(); //Definimos el punto de inicio original de la curva resultante @@ -156,13 +155,16 @@ LPEBSpline::doEffect(SPCurve * curve) node = SBasisHelper.valueAt(0.5); //Vemos si el nodo es BSpline o CUSP //Averiguamos si el punto de union tiene manejadores - if (Geom::CubicBezier const *cubic = dynamic_cast(&*curve_it1)){ - if((*cubic)[2] == (*cubic)[3]) - isBSpline = true; - } + cubic = dynamic_cast(&*curve_it1); + if(cubic && (*cubic)[2] != (*cubic)[3]) + isBSpline = false; + cubic = dynamic_cast(&*curve_it2); + if(cubic && (*cubic)[0] != (*cubic)[1]) + isBSpline = false; //Si no tiene manejador, tenemos que generar la curva con nodo final CUSP if(!isBSpline ){ //Definimos como nodo el final del segmento de entrada + isBSpline = true; node = pointAt3; } curveHelper->moveto(previousNode); @@ -190,6 +192,7 @@ LPEBSpline::doEffect(SPCurve * curve) curveHelper->curveto(nextPointAt1, nextPointAt2, startNode); }else{ curveHelper->curveto(nextPointAt1, nextPointAt2, nextPointAt3); + isBSpline = true; } //añadimos este último segmento nCurve->append_continuous(curveHelper, 0.0625); -- cgit v1.2.3 From eeb9410c8748a03536119dd01615cda3ca215cb1 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 8 Jan 2013 01:57:47 +0100 Subject: Fix BSplines whit 1 segment (bzr r11950.1.16) --- src/live_effects/lpe-bspline.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index a57cc9a88..a1f51de0b 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -43,6 +43,8 @@ LPEBSpline::doEffect(SPCurve * curve) using Geom::X; using Geom::Y; + if(curve->get_segment_count() < 2) + return; // Make copy of old path as it is changed during processing Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); -- cgit v1.2.3 From 91942b752107bb44bbc64af31d5912a8b04c815a Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 13 Feb 2013 00:07:12 +0100 Subject: First attempt for Adjustable Wheight (bzr r11950.1.28) --- src/live_effects/lpe-bspline.cpp | 82 ++++++++++++++-------------------------- src/live_effects/lpe-bspline.h | 2 - 2 files changed, 28 insertions(+), 56 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index a1f51de0b..8a01beabd 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -53,14 +53,14 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::D2< Geom::SBasis > SBasisOut; Geom::D2< Geom::SBasis > SBasisEnd; Geom::D2< Geom::SBasis > SBasisHelper; - //curves - SPCurve * in = new SPCurve(); - SPCurve * out = new SPCurve(); - SPCurve * end = new SPCurve(); //Curvas temporales SPCurve *lineHelper = new SPCurve(); SPCurve *curveHelper = new SPCurve(); SPCurve *nCurve = new SPCurve(); + //curves + SPCurve * in = new SPCurve(); + SPCurve * out = new SPCurve(); + SPCurve * end = new SPCurve(); //Puntos a usar. Ponemos todos los posibles para hacer más inteligible el código Geom::Point startNode(0,0); Geom::Point previousNode(0,0); @@ -74,7 +74,9 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); - Geom::CubicBezier const *cubic; + Geom::CubicBezier const *cubicIn; + Geom::CubicBezier const *cubicOut; + Geom::CubicBezier const *cubicEnd; //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { //Si está vacío... @@ -86,9 +88,6 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve Geom::Path::const_iterator curve_end = path_it->end(); // end curve Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop - //Las lineas rectas forman nodos BSpline - //Las curvas forman nodos CUSP - bool isBSpline = true; //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán //los puntos clave para los manejadores. //Esto hace que la curva BSpline no pierda su condición aunque se trasladen @@ -100,31 +99,22 @@ LPEBSpline::doEffect(SPCurve * curve) //este no cambia. end->moveto(curve_end->initialPoint()); end->lineto(curve_end->finalPoint()); + //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - cubic = dynamic_cast(&*curve_end); - if(cubic && (*cubic)[2] != (*cubic)[3]) - isBSpline = false; - if (path_it->closed() && isBSpline) { - //Calculamos el nodo de inicio BSpline - SBasisIn = in->first_segment()->toSBasis(); - SBasisEnd = end->first_segment()->toSBasis(); - lineHelper->moveto(SBasisIn.valueAt(0.3334)); - lineHelper->lineto(SBasisEnd.valueAt(0.6667)); - SBasisHelper = lineHelper->first_segment()->toSBasis(); - lineHelper->reset(); - //Guardamos el principio de la curva - startNode = SBasisHelper.valueAt(0.5); - //Definimos el punto de inicio original de la curva resultante - node = startNode; - }else{ - isBSpline = true; - //Guardamos el principio de la curva - startNode = in->first_segment()->initialPoint(); - //Definimos el punto de inicio original de la curva resultante - node = startNode; - } + cubicIn = dynamic_cast(&*curve_it1); + cubicOut = dynamic_cast(&*curve_it2); + cubicEnd = dynamic_cast(&*curve_end); + //Calculamos el nodo de inicio BSpline + lineHelper->moveto(SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment()))); + lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*cubicEnd)[2],*end->first_segment()))); + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + //Guardamos el principio de la curva + startNode = SBasisHelper.valueAt(0.5); + //Definimos el punto de inicio original de la curva resultante + node = startNode; //Recorremos todos los segmentos menos el último while ( curve_it2 != curve_endit ) { @@ -134,14 +124,15 @@ LPEBSpline::doEffect(SPCurve * curve) //previousPointAt3 = pointAt3; //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida pointAt0 = SBasisIn.valueAt(0); - pointAt1 = SBasisIn.valueAt(0.3334); - pointAt2 = SBasisIn.valueAt(0.6667); + pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment())); + pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[2],*in->first_segment())); pointAt3 = SBasisIn.valueAt(1); //Y hacemos lo propio con el path de salida //nextPointAt0 = curveOut.valueAt(0); - nextPointAt1 = SBasisOut.valueAt(0.3334); - nextPointAt2 = SBasisOut.valueAt(0.6667);; + nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[1],*in->first_segment())); + nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[1],*out->first_segment())); nextPointAt3 = SBasisOut.valueAt(1); + //La curva BSpline se forma calculando el centro del segmanto de unión //de el punto situado en las 2/3 partes de el segmento de entrada //con el punto situado en la posición 1/3 del segmento de salida @@ -155,20 +146,6 @@ LPEBSpline::doEffect(SPCurve * curve) previousNode = node; //Y este hará de final de curva node = SBasisHelper.valueAt(0.5); - //Vemos si el nodo es BSpline o CUSP - //Averiguamos si el punto de union tiene manejadores - cubic = dynamic_cast(&*curve_it1); - if(cubic && (*cubic)[2] != (*cubic)[3]) - isBSpline = false; - cubic = dynamic_cast(&*curve_it2); - if(cubic && (*cubic)[0] != (*cubic)[1]) - isBSpline = false; - //Si no tiene manejador, tenemos que generar la curva con nodo final CUSP - if(!isBSpline ){ - //Definimos como nodo el final del segmento de entrada - isBSpline = true; - node = pointAt3; - } curveHelper->moveto(previousNode); curveHelper->curveto(pointAt1, pointAt2, node); //añadimos la curva generada a la curva pricipal @@ -177,6 +154,7 @@ LPEBSpline::doEffect(SPCurve * curve) //aumentamos los valores para el siguiente paso en el bucle ++curve_it1; ++curve_it2; + //Damos valor a el objeto para el path de entrada y el de salida in->reset(); in->moveto(curve_it1->initialPoint()); in->lineto(curve_it1->finalPoint()); @@ -185,6 +163,8 @@ LPEBSpline::doEffect(SPCurve * curve) out->moveto(curve_it2->initialPoint()); out->lineto(curve_it2->finalPoint()); } + cubicIn = dynamic_cast(&*curve_it1); + cubicOut = dynamic_cast(&*curve_it2); } //Aberiguamos la ultima parte de la curva correspondiente al último segmento curveHelper->moveto(node); @@ -194,7 +174,6 @@ LPEBSpline::doEffect(SPCurve * curve) curveHelper->curveto(nextPointAt1, nextPointAt2, startNode); }else{ curveHelper->curveto(nextPointAt1, nextPointAt2, nextPointAt3); - isBSpline = true; } //añadimos este último segmento nCurve->append_continuous(curveHelper, 0.0625); @@ -217,13 +196,8 @@ LPEBSpline::doEffect(SPCurve * curve) delete lineHelper; delete curveHelper; //Todo: remove? - //delete SBasisIn; - //delete SBasisOut; - //delete SBasisEnd; //delete SBasisHelper; } - - }; //namespace LivePathEffect }; /* namespace Inkscape */ diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 23ac495df..898f638ed 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -18,8 +18,6 @@ public: LPEBSpline(LivePathEffectObject *lpeobject); virtual ~LPEBSpline(); - virtual LPEPathFlashType pathFlashType() { return SUPPRESS_FLASH; } - virtual SPCurve *reverse_then_reset(SPCurve * orig); virtual void doEffect(SPCurve * curve); -- cgit v1.2.3 From 23e56d5e362d55bb22edaf1070cbac0b604aee36 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 13 Feb 2013 03:55:29 +0100 Subject: First Steps, BSpline Live Path Ok, working Pen Context (bzr r11950.1.29) --- src/live_effects/lpe-bspline.cpp | 88 ++++++++++++++++++++++++---------------- src/live_effects/lpe-bspline.h | 2 +- 2 files changed, 54 insertions(+), 36 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 8a01beabd..408f0f8a6 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -12,7 +12,6 @@ #include <2geom/bezier-curve.h> #include "helper/geom-curves.h" - // For handling un-continuous paths: #include "message-stack.h" #include "inkscape.h" @@ -29,13 +28,6 @@ LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) : LPEBSpline::~LPEBSpline() { } -//Crea una nueva curva reseteando la original -SPCurve * -LPEBSpline::reverse_then_reset(SPCurve * orig){ - SPCurve *ret = orig->create_reverse(); - orig->reset(); - return ret; -} void LPEBSpline::doEffect(SPCurve * curve) @@ -106,46 +98,70 @@ LPEBSpline::doEffect(SPCurve * curve) cubicIn = dynamic_cast(&*curve_it1); cubicOut = dynamic_cast(&*curve_it2); cubicEnd = dynamic_cast(&*curve_end); - //Calculamos el nodo de inicio BSpline - lineHelper->moveto(SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment()))); - lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*cubicEnd)[2],*end->first_segment()))); - SBasisHelper = lineHelper->first_segment()->toSBasis(); - lineHelper->reset(); - //Guardamos el principio de la curva - startNode = SBasisHelper.valueAt(0.5); - //Definimos el punto de inicio original de la curva resultante - node = startNode; + if (path_it->closed() && cubicIn && cubicEnd && (*cubicIn)[1] != (*cubicEnd)[2]){ + //Calculamos el nodo de inicio BSpline + SBasisIn = in->first_segment()->toSBasis(); + SBasisEnd = end->first_segment()->toSBasis(); + lineHelper->moveto(SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment()))); + lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*cubicEnd)[2],*end->first_segment()))); + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + //Guardamos el principio de la curva + startNode = SBasisHelper.valueAt(0.5); + //Definimos el punto de inicio original de la curva resultante + node = startNode; + }else{ + startNode = in->first_segment()->initialPoint(); + node = startNode; + } //Recorremos todos los segmentos menos el último while ( curve_it2 != curve_endit ) { - //Damos valor a el objeto SBasis para el path de entrada y el de salida SBasisIn = in->first_segment()->toSBasis(); SBasisOut = out->first_segment()->toSBasis(); //previousPointAt3 = pointAt3; //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida - pointAt0 = SBasisIn.valueAt(0); - pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment())); - pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[2],*in->first_segment())); - pointAt3 = SBasisIn.valueAt(1); + if(cubicIn){ + pointAt0 = SBasisIn.valueAt(0); + pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment())); + pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[2],*in->first_segment())); + pointAt3 = SBasisIn.valueAt(1); + }else{ + pointAt0 = SBasisIn.valueAt(0); + pointAt1 = SBasisIn.valueAt(0); + pointAt2 = SBasisIn.valueAt(1); + pointAt3 = SBasisIn.valueAt(1); + } //Y hacemos lo propio con el path de salida //nextPointAt0 = curveOut.valueAt(0); - nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[1],*in->first_segment())); - nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[1],*out->first_segment())); - nextPointAt3 = SBasisOut.valueAt(1); - + if(cubicOut){ + nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[1],*out->first_segment())); + nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[2],*out->first_segment())); + nextPointAt3 = SBasisOut.valueAt(1); + }else{ + nextPointAt1 = SBasisOut.valueAt(0); + nextPointAt2 = SBasisOut.valueAt(1); + nextPointAt3 = SBasisOut.valueAt(1); + } //La curva BSpline se forma calculando el centro del segmanto de unión //de el punto situado en las 2/3 partes de el segmento de entrada //con el punto situado en la posición 1/3 del segmento de salida //Estos dos puntos ademas estan posicionados en el lugas correspondiente de //los manejadores de la curva - lineHelper->moveto(pointAt2); - lineHelper->lineto(nextPointAt1); - SBasisHelper = lineHelper->first_segment()->toSBasis(); - lineHelper->reset(); - //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de principio de curva - previousNode = node; - //Y este hará de final de curva - node = SBasisHelper.valueAt(0.5); + if(nextPointAt1 != pointAt2){ + lineHelper->moveto(pointAt2); + lineHelper->lineto(nextPointAt1); + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de principio de curva + previousNode = node; + //Y este hará de final de curva + node = SBasisHelper.valueAt(0.5); + }else{ + previousNode = node; + //Y este hará de final de curva + node = nextPointAt1; + } curveHelper->moveto(previousNode); curveHelper->curveto(pointAt1, pointAt2, node); //añadimos la curva generada a la curva pricipal @@ -162,9 +178,10 @@ LPEBSpline::doEffect(SPCurve * curve) if(curve_it1 != curve_end){ out->moveto(curve_it2->initialPoint()); out->lineto(curve_it2->finalPoint()); + cubicOut = dynamic_cast(&*curve_it2); } cubicIn = dynamic_cast(&*curve_it1); - cubicOut = dynamic_cast(&*curve_it2); + } //Aberiguamos la ultima parte de la curva correspondiente al último segmento curveHelper->moveto(node); @@ -198,6 +215,7 @@ LPEBSpline::doEffect(SPCurve * curve) //Todo: remove? //delete SBasisHelper; } + }; //namespace LivePathEffect }; /* namespace Inkscape */ diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 898f638ed..d983a7654 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -18,7 +18,7 @@ public: LPEBSpline(LivePathEffectObject *lpeobject); virtual ~LPEBSpline(); - virtual SPCurve *reverse_then_reset(SPCurve * orig); + virtual LPEPathFlashType pathFlashType() const { return SUPPRESS_FLASH; } virtual void doEffect(SPCurve * curve); -- cgit v1.2.3 From 28b44133e0d9df8054e17ed9724ea645220e1530 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 14 Feb 2013 06:01:26 +0100 Subject: All done except cusp continuous and close bspline (bzr r11950.1.32) --- src/live_effects/lpe-bspline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/live_effects') 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(&*curve_it1); cubicOut = dynamic_cast(&*curve_it2); cubicEnd = dynamic_cast(&*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(); -- cgit v1.2.3 From 4a0858ff965d54fc08f721fbbc2503f9ab3d9d3c Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 18 Feb 2013 11:23:51 +0100 Subject: refactor (bzr r11950.1.35) --- src/live_effects/lpe-bspline.cpp | 46 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 0ce18dcea..858a09159 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -45,14 +45,14 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::D2< Geom::SBasis > SBasisOut; Geom::D2< Geom::SBasis > SBasisEnd; Geom::D2< Geom::SBasis > SBasisHelper; - //Curvas temporales - SPCurve *lineHelper = new SPCurve(); - SPCurve *curveHelper = new SPCurve(); - SPCurve *nCurve = new SPCurve(); //curves SPCurve * in = new SPCurve(); SPCurve * out = new SPCurve(); SPCurve * end = new SPCurve(); + //Curvas temporales + SPCurve *lineHelper = new SPCurve(); + SPCurve *curveHelper = new SPCurve(); + SPCurve *nCurve = new SPCurve(); //Puntos a usar. Ponemos todos los posibles para hacer más inteligible el código Geom::Point startNode(0,0); Geom::Point previousNode(0,0); @@ -66,9 +66,7 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); - Geom::CubicBezier const *cubicIn; - Geom::CubicBezier const *cubicOut; - Geom::CubicBezier const *cubicEnd; + Geom::BezierCurve const *bezier; //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { //Si está vacío... @@ -80,6 +78,7 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve Geom::Path::const_iterator curve_end = path_it->end(); // end curve Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop + //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán //los puntos clave para los manejadores. //Esto hace que la curva BSpline no pierda su condición aunque se trasladen @@ -91,19 +90,18 @@ LPEBSpline::doEffect(SPCurve * curve) //este no cambia. end->moveto(curve_end->initialPoint()); end->lineto(curve_end->finalPoint()); - //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - cubicIn = dynamic_cast(&*curve_it1); - cubicOut = dynamic_cast(&*curve_it2); - cubicEnd = dynamic_cast(&*curve_end); - if (path_it->closed() && cubicEnd && (*cubicEnd)[3] != (*cubicEnd)[2]){ + bezier = dynamic_cast(&*curve_end); + if (path_it->closed() && bezier && (*bezier)[2] != (*bezier)[3]) { //Calculamos el nodo de inicio BSpline SBasisIn = in->first_segment()->toSBasis(); SBasisEnd = end->first_segment()->toSBasis(); - lineHelper->moveto(SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment()))); - lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*cubicEnd)[2],*end->first_segment()))); + bezier = dynamic_cast(&*curve_it1); + lineHelper->moveto(SBasisIn.valueAt(Geom::nearest_point((*bezier)[1],*in->first_segment()))); + bezier = dynamic_cast(&*curve_end); + lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*bezier)[2],*end->first_segment()))); SBasisHelper = lineHelper->first_segment()->toSBasis(); lineHelper->reset(); //Guardamos el principio de la curva @@ -111,9 +109,12 @@ LPEBSpline::doEffect(SPCurve * curve) //Definimos el punto de inicio original de la curva resultante node = startNode; }else{ + //Guardamos el principio de la curva startNode = in->first_segment()->initialPoint(); + //Definimos el punto de inicio original de la curva resultante node = startNode; } + //Recorremos todos los segmentos menos el último while ( curve_it2 != curve_endit ) { @@ -121,10 +122,11 @@ LPEBSpline::doEffect(SPCurve * curve) SBasisOut = out->first_segment()->toSBasis(); //previousPointAt3 = pointAt3; //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida - if(cubicIn){ + bezier = dynamic_cast(&*curve_it1); + if(bezier){ pointAt0 = SBasisIn.valueAt(0); - pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[1],*in->first_segment())); - pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubicIn)[2],*in->first_segment())); + pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*bezier)[1],*in->first_segment())); + pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*bezier)[2],*in->first_segment())); pointAt3 = SBasisIn.valueAt(1); }else{ pointAt0 = SBasisIn.valueAt(0); @@ -134,9 +136,10 @@ LPEBSpline::doEffect(SPCurve * curve) } //Y hacemos lo propio con el path de salida //nextPointAt0 = curveOut.valueAt(0); - if(cubicOut){ - nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[1],*out->first_segment())); - nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubicOut)[2],*out->first_segment())); + bezier = dynamic_cast(&*curve_it2); + if(bezier){ + nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*bezier)[1],*out->first_segment())); + nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*bezier)[2],*out->first_segment())); nextPointAt3 = SBasisOut.valueAt(1); }else{ nextPointAt1 = SBasisOut.valueAt(0); @@ -178,10 +181,7 @@ LPEBSpline::doEffect(SPCurve * curve) if(curve_it1 != curve_end){ out->moveto(curve_it2->initialPoint()); out->lineto(curve_it2->finalPoint()); - cubicOut = dynamic_cast(&*curve_it2); } - cubicIn = dynamic_cast(&*curve_it1); - } //Aberiguamos la ultima parte de la curva correspondiente al último segmento curveHelper->moveto(node); -- cgit v1.2.3 From dfe131791aef37e26fd0358c32222dacf813864c Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 19 Feb 2013 12:08:14 +0100 Subject: Mayor refactor (bzr r11950.1.36) --- src/live_effects/lpe-bspline.cpp | 80 +++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 46 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 858a09159..8147ae014 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -41,9 +41,6 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); //Sbasis - Geom::D2< Geom::SBasis > SBasisIn; - Geom::D2< Geom::SBasis > SBasisOut; - Geom::D2< Geom::SBasis > SBasisEnd; Geom::D2< Geom::SBasis > SBasisHelper; //curves SPCurve * in = new SPCurve(); @@ -66,7 +63,9 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); - Geom::BezierCurve const *bezier; + Geom::CubicBezier const *cubicIn; + Geom::CubicBezier const *cubicOut; + Geom::CubicBezier const *cubicEnd; //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { //Si está vacío... @@ -93,15 +92,12 @@ LPEBSpline::doEffect(SPCurve * curve) //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - bezier = dynamic_cast(&*curve_end); - if (path_it->closed() && bezier && (*bezier)[2] != (*bezier)[3]) { + cubicEnd = dynamic_cast(&*curve_end); + cubicIn = dynamic_cast(&*curve_it1); + if (path_it->closed() && cubicEnd && cubicIn) { //Calculamos el nodo de inicio BSpline - SBasisIn = in->first_segment()->toSBasis(); - SBasisEnd = end->first_segment()->toSBasis(); - bezier = dynamic_cast(&*curve_it1); - lineHelper->moveto(SBasisIn.valueAt(Geom::nearest_point((*bezier)[1],*in->first_segment()))); - bezier = dynamic_cast(&*curve_end); - lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*bezier)[2],*end->first_segment()))); + lineHelper->moveto((*cubicIn)[1]); + lineHelper->lineto((*cubicEnd)[2]); SBasisHelper = lineHelper->first_segment()->toSBasis(); lineHelper->reset(); //Guardamos el principio de la curva @@ -118,53 +114,45 @@ LPEBSpline::doEffect(SPCurve * curve) //Recorremos todos los segmentos menos el último while ( curve_it2 != curve_endit ) { - SBasisIn = in->first_segment()->toSBasis(); - SBasisOut = out->first_segment()->toSBasis(); //previousPointAt3 = pointAt3; //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida - bezier = dynamic_cast(&*curve_it1); - if(bezier){ - pointAt0 = SBasisIn.valueAt(0); - pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*bezier)[1],*in->first_segment())); - pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*bezier)[2],*in->first_segment())); - pointAt3 = SBasisIn.valueAt(1); + cubicIn = dynamic_cast(&*curve_it1); + if(cubicIn){ + pointAt0 = (*cubicIn)[0]; + pointAt1 = (*cubicIn)[1]; + pointAt2 = (*cubicIn)[2]; + pointAt3 = (*cubicIn)[3]; }else{ - pointAt0 = SBasisIn.valueAt(0); - pointAt1 = SBasisIn.valueAt(0); - pointAt2 = SBasisIn.valueAt(1); - pointAt3 = SBasisIn.valueAt(1); + pointAt0 = in->first_segment()->initialPoint(); + pointAt1 = in->first_segment()->initialPoint(); + pointAt2 = in->first_segment()->finalPoint(); + pointAt3 = in->first_segment()->finalPoint(); } //Y hacemos lo propio con el path de salida //nextPointAt0 = curveOut.valueAt(0); - bezier = dynamic_cast(&*curve_it2); - if(bezier){ - nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*bezier)[1],*out->first_segment())); - nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*bezier)[2],*out->first_segment())); - nextPointAt3 = SBasisOut.valueAt(1); + cubicOut = dynamic_cast(&*curve_it2); + if(cubicOut){ + nextPointAt1 = (*cubicOut)[1]; + nextPointAt2 = (*cubicOut)[2]; + nextPointAt3 = (*cubicOut)[3]; }else{ - nextPointAt1 = SBasisOut.valueAt(0); - nextPointAt2 = SBasisOut.valueAt(1); - nextPointAt3 = SBasisOut.valueAt(1); + nextPointAt1 = in->first_segment()->initialPoint(); + nextPointAt2 = in->first_segment()->finalPoint(); + nextPointAt3 = in->first_segment()->finalPoint(); } //La curva BSpline se forma calculando el centro del segmanto de unión //de el punto situado en las 2/3 partes de el segmento de entrada //con el punto situado en la posición 1/3 del segmento de salida //Estos dos puntos ademas estan posicionados en el lugas correspondiente de //los manejadores de la curva - if(nextPointAt1 != pointAt2){ - lineHelper->moveto(pointAt2); - lineHelper->lineto(nextPointAt1); - SBasisHelper = lineHelper->first_segment()->toSBasis(); - lineHelper->reset(); - //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de principio de curva - previousNode = node; - //Y este hará de final de curva - node = SBasisHelper.valueAt(0.5); - }else{ - previousNode = node; - //Y este hará de final de curva - node = nextPointAt1; - } + lineHelper->moveto(pointAt2); + lineHelper->lineto(nextPointAt1); + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de principio de curva + previousNode = node; + //Y este hará de final de curva + node = SBasisHelper.valueAt(0.5); curveHelper->moveto(previousNode); curveHelper->curveto(pointAt1, pointAt2, node); //añadimos la curva generada a la curva pricipal -- cgit v1.2.3 From 9af17a6572db964acebd2b7eeea29c8b722c8221 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 23 Feb 2013 23:34:58 +0100 Subject: Saved for next refactor (bzr r11950.1.37) --- src/live_effects/lpe-bspline.cpp | 77 +++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 29 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 8147ae014..8dc840556 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -32,15 +32,15 @@ LPEBSpline::~LPEBSpline() void LPEBSpline::doEffect(SPCurve * curve) { - using Geom::X; - using Geom::Y; - if(curve->get_segment_count() < 2) return; // Make copy of old path as it is changed during processing Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); //Sbasis + Geom::D2< Geom::SBasis > SBasisIn; + Geom::D2< Geom::SBasis > SBasisOut; + Geom::D2< Geom::SBasis > SBasisEnd; Geom::D2< Geom::SBasis > SBasisHelper; //curves SPCurve * in = new SPCurve(); @@ -63,9 +63,9 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); - Geom::CubicBezier const *cubicIn; - Geom::CubicBezier const *cubicOut; - Geom::CubicBezier const *cubicEnd; + + Geom::Point endPointAt2(0,0); + Geom::CubicBezier const *cubic; //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { //Si está vacío... @@ -75,7 +75,7 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve - Geom::Path::const_iterator curve_end = path_it->end(); // end curve + Geom::Path::const_iterator curve_end = path_it->end_open(); // end curve Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán @@ -92,12 +92,31 @@ LPEBSpline::doEffect(SPCurve * curve) //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - cubicEnd = dynamic_cast(&*curve_end); - cubicIn = dynamic_cast(&*curve_it1); - if (path_it->closed() && cubicEnd && cubicIn) { - //Calculamos el nodo de inicio BSpline - lineHelper->moveto((*cubicIn)[1]); - lineHelper->lineto((*cubicEnd)[2]); + + if (path_it->closed()) { + // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. + const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + // closingline.isDegenerate() did not work, because it only checks for *exact* zero length, which goes wrong for relative coordinates and rounding errors... + // the closing line segment has zero-length. So stop before that one! + curve_endit = path_it->end_open(); + } + SBasisIn = in->first_segment()->toSBasis(); + SBasisEnd = end->first_segment()->toSBasis(); + cubic = dynamic_cast(&*curve_it1); + if(cubic){ + pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[1],*in->first_segment())); + }else{ + pointAt1 = in->first_segment()->initialPoint(); + } + cubic = dynamic_cast(&*curve_end); + if(cubic){ + endPointAt2 = SBasisEnd.valueAt(Geom::nearest_point((*cubic)[2],*end->first_segment())); + }else{ + endPointAt2 = end->first_segment()->finalPoint(); + } + lineHelper->moveto(pointAt1); + lineHelper->lineto(endPointAt2); SBasisHelper = lineHelper->first_segment()->toSBasis(); lineHelper->reset(); //Guardamos el principio de la curva @@ -110,18 +129,18 @@ LPEBSpline::doEffect(SPCurve * curve) //Definimos el punto de inicio original de la curva resultante node = startNode; } - //Recorremos todos los segmentos menos el último while ( curve_it2 != curve_endit ) { //previousPointAt3 = pointAt3; //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida - cubicIn = dynamic_cast(&*curve_it1); - if(cubicIn){ - pointAt0 = (*cubicIn)[0]; - pointAt1 = (*cubicIn)[1]; - pointAt2 = (*cubicIn)[2]; - pointAt3 = (*cubicIn)[3]; + cubic = dynamic_cast(&*curve_it1); + if(cubic){ + SBasisIn = in->first_segment()->toSBasis(); + pointAt0 = (*cubic)[0]; + pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[1],*in->first_segment())); + pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[2],*in->first_segment())); + pointAt3 = (*cubic)[3]; }else{ pointAt0 = in->first_segment()->initialPoint(); pointAt1 = in->first_segment()->initialPoint(); @@ -130,15 +149,16 @@ LPEBSpline::doEffect(SPCurve * curve) } //Y hacemos lo propio con el path de salida //nextPointAt0 = curveOut.valueAt(0); - cubicOut = dynamic_cast(&*curve_it2); - if(cubicOut){ - nextPointAt1 = (*cubicOut)[1]; - nextPointAt2 = (*cubicOut)[2]; - nextPointAt3 = (*cubicOut)[3]; + cubic = dynamic_cast(&*curve_it2); + if(cubic){ + SBasisOut = out->first_segment()->toSBasis(); + nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[1],*out->first_segment())); + nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[2],*out->first_segment()));; + nextPointAt3 = (*cubic)[3]; }else{ - nextPointAt1 = in->first_segment()->initialPoint(); - nextPointAt2 = in->first_segment()->finalPoint(); - nextPointAt3 = in->first_segment()->finalPoint(); + nextPointAt1 = out->first_segment()->initialPoint(); + nextPointAt2 = out->first_segment()->finalPoint(); + nextPointAt3 = out->first_segment()->finalPoint(); } //La curva BSpline se forma calculando el centro del segmanto de unión //de el punto situado en las 2/3 partes de el segmento de entrada @@ -203,7 +223,6 @@ LPEBSpline::doEffect(SPCurve * curve) //Todo: remove? //delete SBasisHelper; } - }; //namespace LivePathEffect }; /* namespace Inkscape */ -- cgit v1.2.3 From ecc57932f1e7d157950ada2901f6ea6f3acc8aad Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 28 Feb 2013 04:43:21 +0100 Subject: Fixed closed pc->ea (bzr r11950.1.40) --- src/live_effects/lpe-bspline.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 8dc840556..36caf73c5 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -34,6 +34,8 @@ LPEBSpline::doEffect(SPCurve * curve) { if(curve->get_segment_count() < 2) return; + using Geom::X; + using Geom::Y; // Make copy of old path as it is changed during processing Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); @@ -94,13 +96,6 @@ LPEBSpline::doEffect(SPCurve * curve) //en posible caso de que se cierre con una linea recta creando un nodo BSPline if (path_it->closed()) { - // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. - const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. - if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - // closingline.isDegenerate() did not work, because it only checks for *exact* zero length, which goes wrong for relative coordinates and rounding errors... - // the closing line segment has zero-length. So stop before that one! - curve_endit = path_it->end_open(); - } SBasisIn = in->first_segment()->toSBasis(); SBasisEnd = end->first_segment()->toSBasis(); cubic = dynamic_cast(&*curve_it1); @@ -223,6 +218,7 @@ LPEBSpline::doEffect(SPCurve * curve) //Todo: remove? //delete SBasisHelper; } + }; //namespace LivePathEffect }; /* namespace Inkscape */ -- cgit v1.2.3 From 9c35b88816e60d7fe413a76b48d1764e45157612 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 1 Mar 2013 02:36:23 +0100 Subject: BSpline refactor (bzr r11950.1.41) --- src/live_effects/lpe-bspline.cpp | 118 +++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 66 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 36caf73c5..d046ad683 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -33,41 +33,11 @@ void LPEBSpline::doEffect(SPCurve * curve) { if(curve->get_segment_count() < 2) - return; - using Geom::X; - using Geom::Y; + return; // Make copy of old path as it is changed during processing Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); - //Sbasis - Geom::D2< Geom::SBasis > SBasisIn; - Geom::D2< Geom::SBasis > SBasisOut; - Geom::D2< Geom::SBasis > SBasisEnd; - Geom::D2< Geom::SBasis > SBasisHelper; - //curves - SPCurve * in = new SPCurve(); - SPCurve * out = new SPCurve(); - SPCurve * end = new SPCurve(); - //Curvas temporales - SPCurve *lineHelper = new SPCurve(); - SPCurve *curveHelper = new SPCurve(); - SPCurve *nCurve = new SPCurve(); - //Puntos a usar. Ponemos todos los posibles para hacer más inteligible el código - Geom::Point startNode(0,0); - Geom::Point previousNode(0,0); - Geom::Point node(0,0); - //Geom::Point previousPointAt3(0,0); - Geom::Point pointAt0(0,0); - Geom::Point pointAt1(0,0); - Geom::Point pointAt2(0,0); - Geom::Point pointAt3(0,0); - //Geom::Point nextPointAt0(0,0); - Geom::Point nextPointAt1(0,0); - Geom::Point nextPointAt2(0,0); - Geom::Point nextPointAt3(0,0); - - Geom::Point endPointAt2(0,0); - Geom::CubicBezier const *cubic; + //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { //Si está vacío... @@ -77,43 +47,60 @@ LPEBSpline::doEffect(SPCurve * curve) Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve - Geom::Path::const_iterator curve_end = path_it->end_open(); // end curve Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop - //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán //los puntos clave para los manejadores. //Esto hace que la curva BSpline no pierda su condición aunque se trasladen //dichos manejadores + SPCurve * in = new SPCurve(); in->moveto(curve_it1->initialPoint()); in->lineto(curve_it1->finalPoint()); + SPCurve * out = new SPCurve(); out->moveto(curve_it2->initialPoint()); out->lineto(curve_it2->finalPoint()); - //este no cambia. - end->moveto(curve_end->initialPoint()); - end->lineto(curve_end->finalPoint()); + SPCurve *nCurve = new SPCurve(); + Geom::Point startNode(0,0); + Geom::Point previousNode(0,0); + Geom::Point node(0,0); + Geom::Point pointAt1(0,0); + Geom::Point pointAt2(0,0); + Geom::Point nextPointAt1(0,0); + Geom::Point nextPointAt2(0,0); + Geom::Point nextPointAt3(0,0); + Geom::CubicBezier const *cubic = NULL; //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline if (path_it->closed()) { - SBasisIn = in->first_segment()->toSBasis(); - SBasisEnd = end->first_segment()->toSBasis(); + //Calculamos el nodo de inicio BSpline + const Geom::Curve &closingline = path_it->back_closed(); + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + curve_endit = path_it->end_open(); + } + SPCurve * end = new SPCurve(); + end->moveto(curve_endit->initialPoint()); + end->lineto(curve_endit->finalPoint()); + Geom::D2< Geom::SBasis > SBasisIn = in->first_segment()->toSBasis(); + Geom::D2< Geom::SBasis > SBasisEnd = end->first_segment()->toSBasis(); + end->reset(); + delete end; + SPCurve *lineHelper = new SPCurve(); cubic = dynamic_cast(&*curve_it1); if(cubic){ - pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[1],*in->first_segment())); + lineHelper->moveto(SBasisIn.valueAt(Geom::nearest_point((*cubic)[1],*in->first_segment()))); }else{ - pointAt1 = in->first_segment()->initialPoint(); + lineHelper->moveto(in->first_segment()->initialPoint()); } - cubic = dynamic_cast(&*curve_end); + cubic = dynamic_cast(&*curve_endit); if(cubic){ - endPointAt2 = SBasisEnd.valueAt(Geom::nearest_point((*cubic)[2],*end->first_segment())); + lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*cubic)[2],*end->first_segment()))); }else{ - endPointAt2 = end->first_segment()->finalPoint(); + lineHelper->lineto(end->first_segment()->finalPoint()); } - lineHelper->moveto(pointAt1); - lineHelper->lineto(endPointAt2); - SBasisHelper = lineHelper->first_segment()->toSBasis(); + Geom::D2< Geom::SBasis > SBasisHelper = lineHelper->first_segment()->toSBasis(); lineHelper->reset(); + delete lineHelper; //Guardamos el principio de la curva startNode = SBasisHelper.valueAt(0.5); //Definimos el punto de inicio original de la curva resultante @@ -131,22 +118,18 @@ LPEBSpline::doEffect(SPCurve * curve) //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida cubic = dynamic_cast(&*curve_it1); if(cubic){ - SBasisIn = in->first_segment()->toSBasis(); - pointAt0 = (*cubic)[0]; + Geom::D2< Geom::SBasis > SBasisIn = in->first_segment()->toSBasis(); pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[1],*in->first_segment())); pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[2],*in->first_segment())); - pointAt3 = (*cubic)[3]; }else{ - pointAt0 = in->first_segment()->initialPoint(); pointAt1 = in->first_segment()->initialPoint(); pointAt2 = in->first_segment()->finalPoint(); - pointAt3 = in->first_segment()->finalPoint(); } //Y hacemos lo propio con el path de salida //nextPointAt0 = curveOut.valueAt(0); cubic = dynamic_cast(&*curve_it2); if(cubic){ - SBasisOut = out->first_segment()->toSBasis(); + Geom::D2< Geom::SBasis > SBasisOut = out->first_segment()->toSBasis(); nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[1],*out->first_segment())); nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[2],*out->first_segment()));; nextPointAt3 = (*cubic)[3]; @@ -160,33 +143,41 @@ LPEBSpline::doEffect(SPCurve * curve) //con el punto situado en la posición 1/3 del segmento de salida //Estos dos puntos ademas estan posicionados en el lugas correspondiente de //los manejadores de la curva + SPCurve *lineHelper = new SPCurve(); lineHelper->moveto(pointAt2); lineHelper->lineto(nextPointAt1); - SBasisHelper = lineHelper->first_segment()->toSBasis(); + Geom::D2< Geom::SBasis > SBasisHelper = lineHelper->first_segment()->toSBasis(); lineHelper->reset(); + delete lineHelper; //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de principio de curva previousNode = node; //Y este hará de final de curva node = SBasisHelper.valueAt(0.5); + SPCurve *curveHelper = new SPCurve(); curveHelper->moveto(previousNode); curveHelper->curveto(pointAt1, pointAt2, node); //añadimos la curva generada a la curva pricipal nCurve->append_continuous(curveHelper, 0.0625); curveHelper->reset(); + delete curveHelper; //aumentamos los valores para el siguiente paso en el bucle ++curve_it1; ++curve_it2; - //Damos valor a el objeto para el path de entrada y el de salida in->reset(); + delete in; + SPCurve * in = new SPCurve(); in->moveto(curve_it1->initialPoint()); in->lineto(curve_it1->finalPoint()); out->reset(); - if(curve_it1 != curve_end){ + delete out; + if(curve_it1 != curve_endit){ + SPCurve * out = new SPCurve(); out->moveto(curve_it2->initialPoint()); out->lineto(curve_it2->finalPoint()); } } //Aberiguamos la ultima parte de la curva correspondiente al último segmento + SPCurve *curveHelper = new SPCurve(); curveHelper->moveto(node); //Si está cerrada la curva, la cerramos sobre el valor guardado previamente //Si no finalizamos en el punto final @@ -197,26 +188,21 @@ LPEBSpline::doEffect(SPCurve * curve) } //añadimos este último segmento nCurve->append_continuous(curveHelper, 0.0625); + curveHelper->reset(); + delete curveHelper; //y cerramos la curva if (path_it->closed()) { nCurve->closepath_current(); } curve->append(nCurve,false); nCurve->reset(); + delete nCurve; //Limpiamos in->reset(); out->reset(); - end->reset(); - lineHelper->reset(); - curveHelper->reset(); + delete in; + delete out; } - delete in; - delete out; - delete end; - delete lineHelper; - delete curveHelper; - //Todo: remove? - //delete SBasisHelper; } }; //namespace LivePathEffect -- cgit v1.2.3 From b2981a3b8f54bccfa45c76f57b38c9c93808d2fc Mon Sep 17 00:00:00 2001 From: root Date: Tue, 12 Mar 2013 00:48:05 +0100 Subject: ~sub fix, double click to reset default handles and control to 10% step (bzr r11950.1.51) --- src/live_effects/lpe-bspline.cpp | 135 ++++++++++++++++++++++++++++++++++++++- src/live_effects/lpe-bspline.h | 5 +- 2 files changed, 137 insertions(+), 3 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index d91f7297e..fcca38e4c 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -11,7 +11,7 @@ #include <2geom/affine.h> #include <2geom/bezier-curve.h> #include "helper/geom-curves.h" - +#include // For handling un-continuous paths: #include "message-stack.h" #include "inkscape.h" @@ -21,8 +21,11 @@ namespace Inkscape { namespace LivePathEffect { LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) : - Effect(lpeobject) + Effect(lpeobject),unify_weights(_("Unify weights:"), + _("Percent of the with for all poinrs"), "unify_weights", &wr, this, 33.) { + registerParameter( dynamic_cast(&unify_weights) ); + unify_weights.param_set_range(0, 100.); } LPEBSpline::~LPEBSpline() @@ -205,6 +208,134 @@ LPEBSpline::doEffect(SPCurve * curve) } } +std::vector +LPEBSpline::doEffect_path (std::vector const &path_in) +{ + Geom::PathVector const original_pathv = path_in; + SPCurve *curve = new SPCurve(); + //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo + for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { + //Si está vacío... + if (path_it->empty()) + continue; + //Itreadores + + Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve + Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve + Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop + //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán + //los puntos clave para los manejadores. + //Esto hace que la curva BSpline no pierda su condición aunque se trasladen + //dichos manejadores + SPCurve *nCurve = new SPCurve(); + Geom::Point previousNode(0,0); + Geom::Point node(0,0); + Geom::Point pointAt0(0,0); + Geom::Point pointAt1(0,0); + Geom::Point pointAt2(0,0); + Geom::Point pointAt3(0,0); + double pos1 = 0; + double pos2 = 0; + Geom::Point nextPointAt1(0,0); + Geom::Point nextPointAt2(0,0); + Geom::Point nextPointAt3(0,0); + Geom::D2< Geom::SBasis > SBasisIn; + Geom::D2< Geom::SBasis > SBasisOut; + Geom::D2< Geom::SBasis > SBasisHelper; + Geom::CubicBezier const *cubic = NULL; + if (path_it->closed()) { + // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. + const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + // closingline.isDegenerate() did not work, because it only checks for *exact* zero length, which goes wrong for relative coordinates and rounding errors... + // the closing line segment has zero-length. So stop before that one! + curve_endit = path_it->end_open(); + } + } + //Si la curva está cerrada calculamos el punto donde + //deveria estar el nodo BSpline de cierre/inicio de la curva + //en posible caso de que se cierre con una linea recta creando un nodo BSPline + + //Recorremos todos los segmentos menos el último + while ( curve_it2 != curve_endit ) + { + //previousPointAt3 = pointAt3; + //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida + SPCurve * in = new SPCurve(); + in->moveto(curve_it1->initialPoint()); + in->lineto(curve_it1->finalPoint()); + cubic = dynamic_cast(&*curve_it1); + if(cubic){ + SBasisIn = in->first_segment()->toSBasis(); + pointAt0 = in->first_segment()->initialPoint(); + pos1 = unify_weights/100; + pos2 = 1-unify_weights/100; + pointAt1 = SBasisIn.valueAt(pos1); + pointAt2 = SBasisIn.valueAt(pos2); + pointAt3 = in->first_segment()->finalPoint(); + }else{ + pointAt0 = in->first_segment()->initialPoint(); + pointAt1 = in->first_segment()->initialPoint(); + pointAt2 = in->first_segment()->finalPoint(); + pointAt3 = in->first_segment()->finalPoint(); + } + in->reset(); + delete in; + //Y hacemos lo propio con el path de salida + //nextPointAt0 = curveOut.valueAt(0); + SPCurve * out = new SPCurve(); + out->moveto(curve_it2->initialPoint()); + out->lineto(curve_it2->finalPoint()); + cubic = dynamic_cast(&*curve_it2); + if(cubic){ + SBasisOut = out->first_segment()->toSBasis(); + pos1 = unify_weights/100; + pos2 = 1-unify_weights/100; + nextPointAt1 = SBasisOut.valueAt(pos1); + nextPointAt2 = SBasisOut.valueAt(pos2); + nextPointAt3 = (*cubic)[3]; + }else{ + nextPointAt1 = out->first_segment()->initialPoint(); + nextPointAt2 = out->first_segment()->finalPoint(); + nextPointAt3 = out->first_segment()->finalPoint(); + } + out->reset(); + delete out; + //Y este hará de final de curva + SPCurve *curveHelper = new SPCurve(); + curveHelper->moveto(pointAt0); + curveHelper->curveto(pointAt1, pointAt2, pointAt3); + //añadimos la curva generada a la curva pricipal + nCurve->append_continuous(curveHelper, 0.0625); + curveHelper->reset(); + delete curveHelper; + //aumentamos los valores para el siguiente paso en el bucle + ++curve_it1; + ++curve_it2; + } + //Aberiguamos la ultima parte de la curva correspondiente al último segmento + SPCurve *curveHelper = new SPCurve(); + curveHelper->moveto(node); + //Si está cerrada la curva, la cerramos sobre el valor guardado previamente + //Si no finalizamos en el punto final + Geom::Point startNode(0,0); + startNode = path_it->begin()->initialPoint(); + curveHelper->curveto(nextPointAt1, nextPointAt2, nextPointAt3); + nCurve->append_continuous(curveHelper, 0.0625); + nCurve->move_endpoints(startNode,nextPointAt3); + curveHelper->reset(); + delete curveHelper; + //y cerramos la curva + if (path_it->closed()) { + nCurve->closepath_current(); + } + curve->append(nCurve,false); + nCurve->reset(); + delete nCurve; + } + return curve->get_pathvector(); +} + }; //namespace LivePathEffect }; /* namespace Inkscape */ diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index d983a7654..27c79f040 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -8,7 +8,7 @@ */ #include "live_effects/effect.h" - +#include "live_effects/parameter/parameter.h" namespace Inkscape { namespace LivePathEffect { @@ -18,11 +18,14 @@ public: LPEBSpline(LivePathEffectObject *lpeobject); virtual ~LPEBSpline(); + virtual std::vector doEffect_path (std::vector const & input_path); + virtual LPEPathFlashType pathFlashType() const { return SUPPRESS_FLASH; } virtual void doEffect(SPCurve * curve); private: + ScalarParam unify_weights; LPEBSpline(const LPEBSpline&); LPEBSpline& operator=(const LPEBSpline&); }; -- cgit v1.2.3 From d0bebd018087b363bfde91bce46744dfd004549c Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 14 Mar 2013 22:28:34 +0100 Subject: Updating original path (bzr r11950.1.53) --- src/live_effects/lpe-bspline.cpp | 208 +++++++++++-------------------- src/live_effects/lpe-bspline.h | 6 + src/live_effects/parameter/parameter.cpp | 7 +- 3 files changed, 85 insertions(+), 136 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index fcca38e4c..f5dff3abe 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -34,6 +34,11 @@ LPEBSpline::~LPEBSpline() void LPEBSpline::doEffect(SPCurve * curve) +{ +LPEBSpline::doEffect(curve,NULL) +} +void +LPEBSpline::doEffect(SPCurve * curve,int value) { if(curve->get_segment_count() < 2) return; @@ -91,11 +96,21 @@ LPEBSpline::doEffect(SPCurve * curve) cubic = dynamic_cast(&*curve_it1); if(cubic){ SBasisIn = in->first_segment()->toSBasis(); - pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[1],*in->first_segment())); - pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[2],*in->first_segment())); + if(value){ + pointAt1 = SBasisIn.valueAt(value); + pointAt2 = SBasisIn.valueAt(1-value); + }else{ + pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[1],*in->first_segment())); + pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[2],*in->first_segment())); + } }else{ - pointAt1 = in->first_segment()->initialPoint(); - pointAt2 = in->first_segment()->finalPoint(); + if(value){ + pointAt1 = SBasisIn.valueAt(value); + pointAt2 = SBasisIn.valueAt(1-value); + }else{ + pointAt1 = in->first_segment()->initialPoint(); + pointAt2 = in->first_segment()->finalPoint(); + } } in->reset(); delete in; @@ -107,12 +122,22 @@ LPEBSpline::doEffect(SPCurve * curve) cubic = dynamic_cast(&*curve_it2); if(cubic){ SBasisOut = out->first_segment()->toSBasis(); - nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[1],*out->first_segment())); - nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[2],*out->first_segment()));; + if(value){ + nextPointAt1 = SBasisIn.valueAt(value); + nextPointAt2 = SBasisIn.valueAt(1-value); + }else{ + nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[1],*out->first_segment())); + nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[2],*out->first_segment()));; + ] nextPointAt3 = (*cubic)[3]; }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - nextPointAt2 = out->first_segment()->finalPoint(); + if(value){ + nextPointAt1 = SBasisIn.valueAt(value); + nextPointAt2 = SBasisIn.valueAt(1-value); + }else{ + nextPointAt1 = out->first_segment()->initialPoint(); + nextPointAt2 = out->first_segment()->finalPoint(); + } nextPointAt3 = out->first_segment()->finalPoint(); } out->reset(); @@ -133,8 +158,13 @@ LPEBSpline::doEffect(SPCurve * curve) //Y este hará de final de curva node = SBasisHelper.valueAt(0.5); SPCurve *curveHelper = new SPCurve(); - curveHelper->moveto(previousNode); - curveHelper->curveto(pointAt1, pointAt2, node); + if(value){ + curveHelper->moveto(*in->first_segment()->initialPoint()); + curveHelper->curveto(pointAt1, pointAt2, *in->first_segment()->finalPoint()); + }else{ + curveHelper->moveto(previousNode); + curveHelper->curveto(pointAt1, pointAt2, node); + } //añadimos la curva generada a la curva pricipal nCurve->append_continuous(curveHelper, 0.0625); curveHelper->reset(); @@ -181,7 +211,10 @@ LPEBSpline::doEffect(SPCurve * curve) lineHelper->reset(); delete lineHelper; //Guardamos el principio de la curva - startNode = SBasisHelper.valueAt(0.5); + if(value) + startNode = path_it->begin()->initialPoint(); + else + startNode = SBasisHelper.valueAt(0.5); curveHelper->curveto(nextPointAt1, nextPointAt2, startNode); nCurve->append_continuous(curveHelper, 0.0625); nCurve->move_endpoints(startNode,startNode); @@ -208,132 +241,37 @@ LPEBSpline::doEffect(SPCurve * curve) } } -std::vector -LPEBSpline::doEffect_path (std::vector const &path_in) +void +LPEBSpline::updateAllHandles(int value) { - Geom::PathVector const original_pathv = path_in; - SPCurve *curve = new SPCurve(); - //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo - for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { - //Si está vacío... - if (path_it->empty()) - continue; - //Itreadores - - Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve - Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve - Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop - //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán - //los puntos clave para los manejadores. - //Esto hace que la curva BSpline no pierda su condición aunque se trasladen - //dichos manejadores - SPCurve *nCurve = new SPCurve(); - Geom::Point previousNode(0,0); - Geom::Point node(0,0); - Geom::Point pointAt0(0,0); - Geom::Point pointAt1(0,0); - Geom::Point pointAt2(0,0); - Geom::Point pointAt3(0,0); - double pos1 = 0; - double pos2 = 0; - Geom::Point nextPointAt1(0,0); - Geom::Point nextPointAt2(0,0); - Geom::Point nextPointAt3(0,0); - Geom::D2< Geom::SBasis > SBasisIn; - Geom::D2< Geom::SBasis > SBasisOut; - Geom::D2< Geom::SBasis > SBasisHelper; - Geom::CubicBezier const *cubic = NULL; - if (path_it->closed()) { - // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. - const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. - if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - // closingline.isDegenerate() did not work, because it only checks for *exact* zero length, which goes wrong for relative coordinates and rounding errors... - // the closing line segment has zero-length. So stop before that one! - curve_endit = path_it->end_open(); - } - } - //Si la curva está cerrada calculamos el punto donde - //deveria estar el nodo BSpline de cierre/inicio de la curva - //en posible caso de que se cierre con una linea recta creando un nodo BSPline - - //Recorremos todos los segmentos menos el último - while ( curve_it2 != curve_endit ) - { - //previousPointAt3 = pointAt3; - //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida - SPCurve * in = new SPCurve(); - in->moveto(curve_it1->initialPoint()); - in->lineto(curve_it1->finalPoint()); - cubic = dynamic_cast(&*curve_it1); - if(cubic){ - SBasisIn = in->first_segment()->toSBasis(); - pointAt0 = in->first_segment()->initialPoint(); - pos1 = unify_weights/100; - pos2 = 1-unify_weights/100; - pointAt1 = SBasisIn.valueAt(pos1); - pointAt2 = SBasisIn.valueAt(pos2); - pointAt3 = in->first_segment()->finalPoint(); - }else{ - pointAt0 = in->first_segment()->initialPoint(); - pointAt1 = in->first_segment()->initialPoint(); - pointAt2 = in->first_segment()->finalPoint(); - pointAt3 = in->first_segment()->finalPoint(); - } - in->reset(); - delete in; - //Y hacemos lo propio con el path de salida - //nextPointAt0 = curveOut.valueAt(0); - SPCurve * out = new SPCurve(); - out->moveto(curve_it2->initialPoint()); - out->lineto(curve_it2->finalPoint()); - cubic = dynamic_cast(&*curve_it2); - if(cubic){ - SBasisOut = out->first_segment()->toSBasis(); - pos1 = unify_weights/100; - pos2 = 1-unify_weights/100; - nextPointAt1 = SBasisOut.valueAt(pos1); - nextPointAt2 = SBasisOut.valueAt(pos2); - nextPointAt3 = (*cubic)[3]; - }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - nextPointAt2 = out->first_segment()->finalPoint(); - nextPointAt3 = out->first_segment()->finalPoint(); - } - out->reset(); - delete out; - //Y este hará de final de curva - SPCurve *curveHelper = new SPCurve(); - curveHelper->moveto(pointAt0); - curveHelper->curveto(pointAt1, pointAt2, pointAt3); - //añadimos la curva generada a la curva pricipal - nCurve->append_continuous(curveHelper, 0.0625); - curveHelper->reset(); - delete curveHelper; - //aumentamos los valores para el siguiente paso en el bucle - ++curve_it1; - ++curve_it2; - } - //Aberiguamos la ultima parte de la curva correspondiente al último segmento - SPCurve *curveHelper = new SPCurve(); - curveHelper->moveto(node); - //Si está cerrada la curva, la cerramos sobre el valor guardado previamente - //Si no finalizamos en el punto final - Geom::Point startNode(0,0); - startNode = path_it->begin()->initialPoint(); - curveHelper->curveto(nextPointAt1, nextPointAt2, nextPointAt3); - nCurve->append_continuous(curveHelper, 0.0625); - nCurve->move_endpoints(startNode,nextPointAt3); - curveHelper->reset(); - delete curveHelper; - //y cerramos la curva - if (path_it->closed()) { - nCurve->closepath_current(); - } - curve->append(nCurve,false); - nCurve->reset(); - delete nCurve; + SPDesktop *desktop = inkscape_active_desktop(); // TODO: Is there a better method to find the item's desktop? + Inkscape::Selection *selection = sp_desktop_selection(desktop); + for (GSList *items = (GSList *) selection->itemList(); + items != NULL; + items = items->next) { + if (SP_IS_LPE_ITEM(items->data) && sp_lpe_item_has_path_effect(items->data)){ + PathEffectList effect_list = sp_lpe_item_get_effect_list(SP_LPE_ITEM(_path)); + lpe_bsp = dynamic_cast( effect_list.front()->lpeobject->get_lpe()); + if(lpe_bsp) + LPEBSpline::updateHandles((SPItem *) items->data,value); + } +} +void +LPEBSpline::updateHandles(SPItem * item,int value){ + + Inkscape::XML::Node *newitem = item->getRepr(); + Inkscape::XML::Node *path = sp_repr_lookup_child(newitem,"svg:path", -1); //unlimited search depth + if ( path != NULL ){ + gchar const *svgd = path->attribute("d"); } - return curve->get_pathvector(); + + SPCurve *original = new SPCurve(); + original = (SPPath *)item->original_curve(); + LPEBSpline::doEffect(original,value); + gchar *str = sp_svg_write_path( original->get_pathvector() ); + g_assert( str != NULL ); + path->setAttribute ("inkscaspe:original-d", str); + item->updateRepr(); } }; //namespace LivePathEffect diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 27c79f040..501b1fdaf 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -23,6 +23,12 @@ public: virtual LPEPathFlashType pathFlashType() const { return SUPPRESS_FLASH; } virtual void doEffect(SPCurve * curve); + + virtual void doEffect(SPCurve * curve, int value); + + virtual void updateAllHandles(int value); + + virtual void updateHandles(SPItem * item , int value); private: ScalarParam unify_weights; diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 8615721b0..30414842d 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -128,7 +128,12 @@ ScalarParam::param_newWidget() { Inkscape::UI::Widget::RegisteredScalar *rsu = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar( param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) ); - + //BSpline + lpe_bsp = dynamic_cast(param_effect->get_lpe()); + if(lpe_bsp){ + lpe_bsp->updateAllHandles(value/100); + } + //BSpline End rsu->setValue(value); rsu->setDigits(digits); rsu->setIncrements(inc_step, inc_page); -- cgit v1.2.3 From 732618cd7d6159ee47cc0dd8b86cf07790e3e724 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 17 Mar 2013 13:29:02 +0100 Subject: Working with widjets (bzr r11950.1.56) --- src/live_effects/lpe-bspline.cpp | 48 +++++++++++------------------- src/live_effects/lpe-bspline.h | 32 ++++++++------------ src/live_effects/lpe-recursiveskeleton.cpp | 3 +- 3 files changed, 31 insertions(+), 52 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 785c545b5..b1e40655d 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -39,13 +39,18 @@ using Inkscape::DocumentUndo; - namespace Inkscape { namespace LivePathEffect { LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) : Effect(lpeobject) { + Glib::ustring title = Glib::ustring(_("Ignore cusp nodes")); + Glib::ustring tip = Glib::ustring(_("Ignore cusp nodes")); + LPEBSpline::Gtk::Widget *noCusp = new LPEBSpline::newCheckButton(title,tip); + title = Glib::ustring(_("Unify weights:")); + tip = Glib::ustring(_("Percent of the with for all poinrs")); + LPEBSpline::Gtk::Widget *scal = new LPEBSpline::newScalar(title,tip); } LPEBSpline::~LPEBSpline() @@ -239,25 +244,20 @@ Gtk::Widget * LPEBSpline::newWidget() { Gtk::VBox * vbox = dynamic_cast(Effect::newWidget()); - Glib::ustring title = Glib::ustring(_("Ignore cusp nodes")); - Glib::ustring tip = Glib::ustring(_("Ignore cusp nodes")); - this->setNoCuspWidget(this->newCheckButton(title)); - title = Glib::ustring(_("Unify weights:")); - tip = Glib::ustring(_("Percent of the with for all poinrs")); - this->setScalWidget(this->newScalar(title,tip)); vbox->set_border_width(5); - vbox->pack_start(*this->getNoCuspWidget(), true, true,2); - vbox->pack_start(*this->getScalWidget(),true,true,(guint)2); + vbox->pack_start(&noCusp,true,true,(guint)2); + vbox->pack_start(&scal, true, true,2); return dynamic_cast (vbox); } Gtk::Widget * LPEBSpline::newScalar(Glib::ustring title, Glib::ustring tip) { - Inkscape::UI::Widget::Scalar * scal = Gtk::manage( new Inkscape::UI::Widget::Scalar(title, tip, 2)); - scal->setRange(0.01, 100.); - scal->setIncrements(1., 5.); + scal = Gtk::manage( new Inkscape::UI::Widget::Scalar(title, tip)); scal->setValue(33.); + scal->setDigits(2); + scal->setIncrements(1., 5.); + scal->setRange(0, 100.); scal->setProgrammatically = false; scal->addSlider(); scal->signal_value_changed().connect(sigc::mem_fun (*this,&LPEBSpline::updateAllHandles)); @@ -265,20 +265,17 @@ LPEBSpline::newScalar(Glib::ustring title, Glib::ustring tip) } Gtk::Widget * -LPEBSpline::newCheckButton(Glib::ustring title) +LPEBSpline::newCheckButton(Glib::ustring title, Glib::ustring tip) { - Gtk::CheckButton * noCusp = Gtk::manage( new Gtk::CheckButton(title,true)); - noCusp->set_alignment(1.0,0.0); + noCusp = Gtk::manage( new Gtk::CheckButton(title,tip)); return dynamic_cast(noCusp); } void LPEBSpline::updateAllHandles() { - Inkscape::UI::Widget::Scalar * scal = dynamic_cast(this->getScalWidget()); - double value = scal->getValue()/100; - Gtk::CheckButton * noCusp = dynamic_cast(this->getNoCuspWidget()); - bool noCuspValue = noCusp->get_active(); + double value = scal->setValue(33.); + bool noCusp = false; SPDesktop *desktop = inkscape_active_desktop(); // TODO: Is there a better method to find the item's desktop? Inkscape::Selection *selection = sp_desktop_selection(desktop); for (GSList *items = (GSList *) selection->itemList(); @@ -291,7 +288,7 @@ LPEBSpline::updateAllHandles() SPItem *item = (SPItem *) items->data; SPPath *path = SP_PATH(item); SPCurve *curve = path->get_curve_for_edit(); - LPEBSpline::doBSplineFromWidget(curve,value,noCuspValue); + LPEBSpline::doBSplineFromWidget(curve,value,noCusp); gchar *str = sp_svg_write_path(curve->get_pathvector()); path->getRepr()->setAttribute("inkscape:original-d", str); g_free(str); @@ -313,8 +310,6 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double value , bool noCusp) // Make copy of old path as it is changed during processing Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); - using Geom::X; - using Geom::Y; //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { @@ -368,20 +363,16 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double value , bool noCusp) if(cubic){ if(!noCusp || (*cubic)[1] != in->first_segment()->initialPoint()) pointAt1 = SBasisIn.valueAt(value); - pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); else pointAt1 = in->first_segment()->initialPoint(); if(!noCusp || (*cubic)[2] != in->first_segment()->finalPoint()) pointAt2 = SBasisIn.valueAt(1-value); - pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); else pointAt2 = in->first_segment()->finalPoint(); }else{ if(!noCusp){ pointAt1 = SBasisIn.valueAt(value); - pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); pointAt2 = SBasisIn.valueAt(1-value); - pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); }else{ pointAt1 = in->first_segment()->initialPoint(); pointAt2 = in->first_segment()->finalPoint(); @@ -400,20 +391,16 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double value , bool noCusp) if(cubic){ if(!noCusp || (*cubic)[1] != out->first_segment()->initialPoint()) nextPointAt1 = SBasisOut.valueAt(value); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); else nextPointAt1 = out->first_segment()->initialPoint(); if(!noCusp || (*cubic)[2] != out->first_segment()->finalPoint()) nextPointAt2 = SBasisOut.valueAt(1-value); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); else nextPointAt2 = out->first_segment()->finalPoint(); }else{ if(!noCusp){ nextPointAt1 = SBasisOut.valueAt(value); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); nextPointAt2 = SBasisOut.valueAt(1-value); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); }else{ nextPointAt1 = out->first_segment()->initialPoint(); nextPointAt2 = out->first_segment()->finalPoint(); @@ -422,7 +409,6 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double value , bool noCusp) nextPointAt3 = out->first_segment()->finalPoint(); out->reset(); delete out; - //La curva BSpline se forma calculando el centro del segmanto de unión //de el punto situado en las 2/3 partes de el segmento de entrada //con el punto situado en la posición 1/3 del segmento de salida diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index a0f1554d0..dbe0789f2 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -8,7 +8,9 @@ */ #include "live_effects/effect.h" - +#include "live_effects/parameter/parameter.h" +#include "ui/widget/scalar.h" +#include namespace Inkscape { namespace LivePathEffect { @@ -16,13 +18,6 @@ namespace LivePathEffect { class LPEBSpline : public Effect { - -private: - double scalWidget; - bool noCuspWidget; - LPEBSpline(const LPEBSpline&); - LPEBSpline& operator=(const LPEBSpline&); - public: LPEBSpline(LivePathEffectObject *lpeobject); virtual ~LPEBSpline(); @@ -35,22 +30,21 @@ public: virtual void updateAllHandles(); - virtual Gtk::Widget* newScalar(Glib::ustring title, Glib::ustring tip); + virtual void newScalar(Glib::ustring title, Glib::ustring tip); + + virtual void newCheckButton(Glib::ustring title, Glib::ustring tip); - virtual Gtk::Widget* newCheckButton(Glib::ustring title); virtual void doBSplineFromWidget(SPCurve * curve, double value, bool noCusp); - virtual double getScal(){return scal;}; - - virtual double setScal(double setScal){scal = setScal;}; - - virtual bool getNoCusp(){return noCusp;}; - - virtual bool setNoCusp(bool setNoCusp){noCusp = setNoCusp;}; - - virtual Gtk::Widget* newWidget(); + virtual Gtk::Widget * newWidget(); + +private: + Gtk::Widget * scal; + Gtk::Widget * noCusp; + LPEBSpline(const LPEBSpline&); + LPEBSpline& operator=(const LPEBSpline&); }; }; //namespace LivePathEffect diff --git a/src/live_effects/lpe-recursiveskeleton.cpp b/src/live_effects/lpe-recursiveskeleton.cpp index ac571d963..452139344 100644 --- a/src/live_effects/lpe-recursiveskeleton.cpp +++ b/src/live_effects/lpe-recursiveskeleton.cpp @@ -91,8 +91,7 @@ LPERecursiveSkeleton::doEffect_pwd2 (Geom::Piecewise > co double scaling = (uskeleton.domain().extent() - toffset)/pattBndsX->extent(); // TODO investigate why pattWidth is not being used: - // - Doesn't appear to have been used anywhere in bzr history (Alex V: 2013-03-16) - // double pattWidth = pattBndsX->extent() * scaling; + double pattWidth = pattBndsX->extent() * scaling; if (scaling != 1.0) { x*=scaling; -- cgit v1.2.3 From a5fc5840c370d58f395b7b256a11fd11ef3a9a54 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 18 Mar 2013 02:53:59 +0100 Subject: working whith widgets (bzr r11950.1.57) --- src/live_effects/lpe-bspline.cpp | 94 +++++++++++++++++++++++++++++----------- src/live_effects/lpe-bspline.h | 47 +++++++++++++++----- 2 files changed, 104 insertions(+), 37 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index b1e40655d..5d50eae87 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -31,7 +31,6 @@ #include "helper/geom-curves.h" #include "ui/widget/scalar.h" - // For handling un-continuous paths: #include "message-stack.h" #include "inkscape.h" @@ -42,15 +41,20 @@ using Inkscape::DocumentUndo; namespace Inkscape { namespace LivePathEffect { + LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) : Effect(lpeobject) { - Glib::ustring title = Glib::ustring(_("Ignore cusp nodes")); - Glib::ustring tip = Glib::ustring(_("Ignore cusp nodes")); - LPEBSpline::Gtk::Widget *noCusp = new LPEBSpline::newCheckButton(title,tip); - title = Glib::ustring(_("Unify weights:")); - tip = Glib::ustring(_("Percent of the with for all poinrs")); - LPEBSpline::Gtk::Widget *scal = new LPEBSpline::newScalar(title,tip); + Glib::ustring title = Glib::ustring(_("Unify weights:")); + Glib::ustring tip = Glib::ustring(_("Percent of the with for all poinrs")); + registerScal(title,tip); + title = Glib::ustring(_("Ignore cusp nodes")); + registerNoCusp(title); + title = Glib::ustring(_("Reset")); + registerReset(title); + title = Glib::ustring(_("CTRL handle steps:")); + tip = Glib::ustring(_("CTRL handle steps")); + registerStepsHandles(title,tip); } LPEBSpline::~LPEBSpline() @@ -243,39 +247,79 @@ LPEBSpline::doEffect(SPCurve * curve) Gtk::Widget * LPEBSpline::newWidget() { - Gtk::VBox * vbox = dynamic_cast(Effect::newWidget()); + Gtk::VBox * vbox = Gtk::manage( dynamic_cast(LPEBSpline::newWidget())); vbox->set_border_width(5); - vbox->pack_start(&noCusp,true,true,(guint)2); - vbox->pack_start(&scal, true, true,2); + vbox->pack_start(*noCusp,true,true,2); + vbox->pack_start(*scal, true, true,2); + vbox->pack_start(*reset, true, true,2); + vbox->pack_start(*stepsHandles, true, true,2); return dynamic_cast (vbox); } Gtk::Widget * -LPEBSpline::newScalar(Glib::ustring title, Glib::ustring tip) +LPEBSpline::newScal(Glib::ustring title, Glib::ustring tip) +{ + Inkscape::UI::Widget::Scalar *scalIn = Gtk::manage( new Inkscape::UI::Widget::Scalar(title, tip)); + scalIn->setRange(0, 100.); + scalIn->setDigits(2); + scalIn->setIncrements(1., 5.); + scalIn->setValue(33.33); + scalIn->setProgrammatically = false; + scalIn->addSlider(); + scalIn->signal_value_changed().connect(sigc::mem_fun (*this,&LPEBSpline::updateAllHandles)); + return dynamic_cast(scalIn); +} + +Gtk::Widget * +LPEBSpline::newNoCusp(Glib::ustring title) +{ + Gtk::CheckButton * noCuspIn = Gtk::manage( new Gtk::CheckButton(title,true)); + noCuspIn->set_alignment(0.0, 0.5); + return dynamic_cast(noCuspIn); +} + +Gtk::Widget * +LPEBSpline::newReset(Glib::ustring title) { - scal = Gtk::manage( new Inkscape::UI::Widget::Scalar(title, tip)); - scal->setValue(33.); - scal->setDigits(2); - scal->setIncrements(1., 5.); - scal->setRange(0, 100.); - scal->setProgrammatically = false; - scal->addSlider(); - scal->signal_value_changed().connect(sigc::mem_fun (*this,&LPEBSpline::updateAllHandles)); - return dynamic_cast(scal); + Gtk::Button * resetIn = Gtk::manage(new Gtk::Button(title)); + resetIn->signal_clicked().connect(sigc::mem_fun (*this,&LPEBSpline::resetHandles)); + resetIn->set_alignment(0.0, 0.5); + return dynamic_cast(resetIn); } Gtk::Widget * -LPEBSpline::newCheckButton(Glib::ustring title, Glib::ustring tip) +LPEBSpline::newStepsHandles(Glib::ustring title, Glib::ustring tip) { - noCusp = Gtk::manage( new Gtk::CheckButton(title,tip)); - return dynamic_cast(noCusp); + Inkscape::UI::Widget::Scalar *stepsIn = Gtk::manage( new Inkscape::UI::Widget::Scalar(title, tip)); + stepsIn->setRange(1, 10); + stepsIn->setDigits(0); + stepsIn->setIncrements(1.,1.); + stepsIn->setValue(2); + stepsIn->setProgrammatically = false; + stepsIn->signal_value_changed().connect(sigc::mem_fun (*this,&LPEBSpline::updateSteps)); + return dynamic_cast(stepsIn); +} + +void +LPEBSpline::resetHandles(){ + Inkscape::UI::Widget::Scalar * scalIn = dynamic_cast(scal); + scalIn->setValue(33.33); + updateAllHandles(); +} + +void +LPEBSpline::updateSteps(){ + Inkscape::UI::Widget::Scalar * stepsIn = dynamic_cast(stepsHandles); + updateStepsValue(stepsIn->getValue()); } void LPEBSpline::updateAllHandles() { - double value = scal->setValue(33.); - bool noCusp = false; + Inkscape::UI::Widget::Scalar * scalIn = dynamic_cast(scal); + double value = scalIn->getValue()/100; + Gtk::CheckButton * noCuspIn = dynamic_cast(noCusp); + bool noCusp = noCuspIn->get_active(); SPDesktop *desktop = inkscape_active_desktop(); // TODO: Is there a better method to find the item's desktop? Inkscape::Selection *selection = sp_desktop_selection(desktop); for (GSList *items = (GSList *) selection->itemList(); diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index dbe0789f2..3915a476c 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -8,16 +8,12 @@ */ #include "live_effects/effect.h" -#include "live_effects/parameter/parameter.h" -#include "ui/widget/scalar.h" -#include namespace Inkscape { namespace LivePathEffect { - - class LPEBSpline : public Effect { + public: LPEBSpline(LivePathEffectObject *lpeobject); virtual ~LPEBSpline(); @@ -28,23 +24,50 @@ public: virtual void doEffect(SPCurve * curve); - virtual void updateAllHandles(); + virtual void doBSplineFromWidget(SPCurve * curve, double value, bool noCusp); - virtual void newScalar(Glib::ustring title, Glib::ustring tip); + virtual Gtk::Widget * newWidget(); - virtual void newCheckButton(Glib::ustring title, Glib::ustring tip); + int steps; +protected: - virtual void doBSplineFromWidget(SPCurve * curve, double value, bool noCusp); + Gtk::Widget* scal; - virtual Gtk::Widget * newWidget(); + Gtk::Widget* noCusp; + + Gtk::Widget* reset; + + Gtk::Widget* stepsHandles; + + virtual void registerScal(Glib::ustring title, Glib::ustring tip){scal = LPEBSpline::newScal(title,tip);}; + + virtual void registerNoCusp(Glib::ustring title){noCusp = LPEBSpline::newNoCusp(title);}; + + virtual void registerReset(Glib::ustring title){reset = LPEBSpline::newReset(title);}; + + virtual void registerStepsHandles(Glib::ustring title, Glib::ustring tip){stepsHandles = LPEBSpline::newStepsHandles(title,tip);}; + + virtual Gtk::Widget* newScal(Glib::ustring title, Glib::ustring tip); + + virtual Gtk::Widget* newNoCusp(Glib::ustring title); + + virtual Gtk::Widget* newReset(Glib::ustring title); + + virtual Gtk::Widget* newStepsHandles(Glib::ustring title, Glib::ustring tip); + + virtual void updateAllHandles(); + + virtual void resetHandles(); + + virtual void updateSteps(); + virtual void updateStepsValue(int stepsValue){steps=stepsValue;}; private: - Gtk::Widget * scal; - Gtk::Widget * noCusp; LPEBSpline(const LPEBSpline&); LPEBSpline& operator=(const LPEBSpline&); + }; }; //namespace LivePathEffect -- cgit v1.2.3 From 4e41340374ba833e748ffbbc610a28c7c3559557 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 19 Mar 2013 04:35:35 +0100 Subject: Working width widgets (bzr r11950.1.58) --- src/live_effects/lpe-bspline.cpp | 236 +++++++++++++++++++-------------------- src/live_effects/lpe-bspline.h | 49 ++------ 2 files changed, 124 insertions(+), 161 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 5d50eae87..e6461e94c 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -13,23 +13,20 @@ #include "style.h" #include "document.h" #include "document-undo.h" -#include "selection.h" -#include "desktop.h" -#include "verbs.h" #include "desktop-handles.h" -#include -#include -#include -#include +#include "verbs.h" #include "live_effects/lpe-bspline.h" -#include "live_effects/lpeobject.h" -#include "live_effects/lpeobject-reference.h" +#include +#include #include "sp-lpe-item.h" +#include "live_effects/lpeobject.h" +#include "live_effects/parameter/parameter.h" #include "display/sp-canvas.h" #include #include <2geom/bezier-curve.h> #include "helper/geom-curves.h" #include "ui/widget/scalar.h" +#include "selection.h" // For handling un-continuous paths: #include "message-stack.h" @@ -38,23 +35,29 @@ using Inkscape::DocumentUndo; + namespace Inkscape { namespace LivePathEffect { + LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) : - Effect(lpeobject) + Effect(lpeobject), + // initialise your parameters here: + //testpointA(_("Test Point A"), _("Test A"), "ptA", &wr, this, Geom::Point(100,100)), + ignoreCusp(_("Ignore cusp nodes:"), _("Change ignoring cusp nodes"), "ignoreCusp", &wr, this, true), + weight(_("Change weight:"), _("Change weight of the effect"), "weight", &wr, this, 33.33), + steps(_("Steps whith CTRL:"), _("Change number of steps whith CTRL pressed"), "steps", &wr, this, 2) { - Glib::ustring title = Glib::ustring(_("Unify weights:")); - Glib::ustring tip = Glib::ustring(_("Percent of the with for all poinrs")); - registerScal(title,tip); - title = Glib::ustring(_("Ignore cusp nodes")); - registerNoCusp(title); - title = Glib::ustring(_("Reset")); - registerReset(title); - title = Glib::ustring(_("CTRL handle steps:")); - tip = Glib::ustring(_("CTRL handle steps")); - registerStepsHandles(title,tip); + registerParameter( dynamic_cast(&ignoreCusp) ); + registerParameter( dynamic_cast(&weight) ); + registerParameter( dynamic_cast(&steps) ); + weight.param_set_range(0.00, 100); + weight.param_set_increments(1., 1.); + weight.param_set_digits(2); + steps.param_set_range(1, 10); + steps.param_set_increments(1, 1); + steps.param_set_digits(0); } LPEBSpline::~LPEBSpline() @@ -247,108 +250,81 @@ LPEBSpline::doEffect(SPCurve * curve) Gtk::Widget * LPEBSpline::newWidget() { - Gtk::VBox * vbox = Gtk::manage( dynamic_cast(LPEBSpline::newWidget())); + // use manage here, because after deletion of Effect object, others might still be pointing to this widget. + Gtk::VBox * vbox = Gtk::manage( new Gtk::VBox(Effect::newWidget()) ); + vbox->set_border_width(5); - vbox->pack_start(*noCusp,true,true,2); - vbox->pack_start(*scal, true, true,2); - vbox->pack_start(*reset, true, true,2); - vbox->pack_start(*stepsHandles, true, true,2); - return dynamic_cast (vbox); -} -Gtk::Widget * -LPEBSpline::newScal(Glib::ustring title, Glib::ustring tip) -{ - Inkscape::UI::Widget::Scalar *scalIn = Gtk::manage( new Inkscape::UI::Widget::Scalar(title, tip)); - scalIn->setRange(0, 100.); - scalIn->setDigits(2); - scalIn->setIncrements(1., 5.); - scalIn->setValue(33.33); - scalIn->setProgrammatically = false; - scalIn->addSlider(); - scalIn->signal_value_changed().connect(sigc::mem_fun (*this,&LPEBSpline::updateAllHandles)); - return dynamic_cast(scalIn); -} + Gtk::Button* defaultWeight = Gtk::manage(new Gtk::Button(Glib::ustring(_("Default weight")))); + defaultWeight->set_alignment(0.0, 0.5); + Gtk::Widget* defaultWeightWidget = dynamic_cast(defaultWeight); + defaultWeight->signal_clicked().connect(sigc::mem_fun (*this,&LPEBSpline::toDefaultWeight)); + vbox->pack_start(*defaultWeightWidget, true, true,2); -Gtk::Widget * -LPEBSpline::newNoCusp(Glib::ustring title) -{ - Gtk::CheckButton * noCuspIn = Gtk::manage( new Gtk::CheckButton(title,true)); - noCuspIn->set_alignment(0.0, 0.5); - return dynamic_cast(noCuspIn); -} - -Gtk::Widget * -LPEBSpline::newReset(Glib::ustring title) -{ - Gtk::Button * resetIn = Gtk::manage(new Gtk::Button(title)); - resetIn->signal_clicked().connect(sigc::mem_fun (*this,&LPEBSpline::resetHandles)); - resetIn->set_alignment(0.0, 0.5); - return dynamic_cast(resetIn); -} + std::vector::iterator it = param_vector.begin(); + while (it != param_vector.end()) { + if ((*it)->widget_is_visible) { + Parameter * param = *it; + Gtk::Widget * widg = param->param_newWidget(); + if(param->param_key == "weight"){ + Inkscape::UI::Widget::Scalar * widgRegistered = dynamic_cast(widg); + widgRegistered->signal_value_changed().connect(sigc::mem_fun (*this,&LPEBSpline::toWeight)); + } + Glib::ustring * tip = param->param_getTooltip(); + if (widg) { + vbox->pack_start(*widg, true, true, 2); + if (tip) { + widg->set_tooltip_text(*tip); + } else { + widg->set_tooltip_text(""); + widg->set_has_tooltip(false); + } + } + } -Gtk::Widget * -LPEBSpline::newStepsHandles(Glib::ustring title, Glib::ustring tip) -{ - Inkscape::UI::Widget::Scalar *stepsIn = Gtk::manage( new Inkscape::UI::Widget::Scalar(title, tip)); - stepsIn->setRange(1, 10); - stepsIn->setDigits(0); - stepsIn->setIncrements(1.,1.); - stepsIn->setValue(2); - stepsIn->setProgrammatically = false; - stepsIn->signal_value_changed().connect(sigc::mem_fun (*this,&LPEBSpline::updateSteps)); - return dynamic_cast(stepsIn); + ++it; + } + return dynamic_cast(vbox); } -void -LPEBSpline::resetHandles(){ - Inkscape::UI::Widget::Scalar * scalIn = dynamic_cast(scal); - scalIn->setValue(33.33); - updateAllHandles(); +void +LPEBSpline::toDefaultWeight(){ +double weightValue = 0.3333; +changeWeight(weightValue); +weight.param_set_value(33.33); +gtk_widget_draw(GTK_WIDGET(LPEBSpline::newWidget()), NULL); } -void -LPEBSpline::updateSteps(){ - Inkscape::UI::Widget::Scalar * stepsIn = dynamic_cast(stepsHandles); - updateStepsValue(stepsIn->getValue()); +void +LPEBSpline::toWeight(){ +double weightValue = weight/100; +changeWeight(weightValue); } void -LPEBSpline::updateAllHandles() +LPEBSpline::changeWeight(double weightValue) { - Inkscape::UI::Widget::Scalar * scalIn = dynamic_cast(scal); - double value = scalIn->getValue()/100; - Gtk::CheckButton * noCuspIn = dynamic_cast(noCusp); - bool noCusp = noCuspIn->get_active(); - SPDesktop *desktop = inkscape_active_desktop(); // TODO: Is there a better method to find the item's desktop? + SPDesktop *desktop = inkscape_active_desktop(); Inkscape::Selection *selection = sp_desktop_selection(desktop); - for (GSList *items = (GSList *) selection->itemList(); - items != NULL; - items = items->next) { - if (SP_IS_LPE_ITEM((SPLPEItem *)items->data) && sp_lpe_item_has_path_effect((SPLPEItem *)items->data)){ - LivePathEffect::LPEBSpline *lpe_bsp = NULL; - lpe_bsp = dynamic_cast(sp_lpe_item_has_path_effect_of_type(SP_LPE_ITEM((SPLPEItem *)items->data),Inkscape::LivePathEffect::BSPLINE)->getLPEObj()->get_lpe()); - if(lpe_bsp){ - SPItem *item = (SPItem *) items->data; - SPPath *path = SP_PATH(item); - SPCurve *curve = path->get_curve_for_edit(); - LPEBSpline::doBSplineFromWidget(curve,value,noCusp); - gchar *str = sp_svg_write_path(curve->get_pathvector()); - path->getRepr()->setAttribute("inkscape:original-d", str); - g_free(str); - curve->unref(); - SPDesktop *desktop = inkscape_active_desktop(); - desktop->clearWaitingCursor(); - DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_LPE, - _("Modified the weight of the BSpline")); - } - } - } + GSList *items = (GSList *) selection->itemList(); + SPItem *item = (SPItem *)g_slist_nth(items,0)->data; + SPPath *path = SP_PATH(item); + SPCurve *curve = path->get_curve_for_edit(); + LPEBSpline::doBSplineFromWidget(curve,weightValue,ignoreCusp); + gchar *str = sp_svg_write_path(curve->get_pathvector()); + path->getRepr()->setAttribute("inkscape:original-d", str); + g_free(str); + curve->unref(); + desktop->clearWaitingCursor(); + DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_LPE, + _("Modified the weight of the BSpline")); } void -LPEBSpline::doBSplineFromWidget(SPCurve * curve, double value , bool noCusp) +LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue , bool ignoreCusp) { + using Geom::X; + using Geom::Y; if(curve->get_segment_count() < 2) return; // Make copy of old path as it is changed during processing @@ -404,19 +380,25 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double value , bool noCusp) cubic = dynamic_cast(&*curve_it1); pointAt0 = in->first_segment()->initialPoint(); SBasisIn = in->first_segment()->toSBasis(); - if(cubic){ - if(!noCusp || (*cubic)[1] != in->first_segment()->initialPoint()) - pointAt1 = SBasisIn.valueAt(value); - else + if(cubic){ + if(!ignoreCusp || !Geom::are_near((*cubic)[1],in->first_segment()->initialPoint())){ + pointAt1 = SBasisIn.valueAt(weightValue); + pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + }else{ pointAt1 = in->first_segment()->initialPoint(); - if(!noCusp || (*cubic)[2] != in->first_segment()->finalPoint()) - pointAt2 = SBasisIn.valueAt(1-value); - else + } + if(!ignoreCusp || !Geom::are_near((*cubic)[2],in->first_segment()->finalPoint())){ + pointAt2 = SBasisIn.valueAt(1-weightValue); + pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); + }else{ pointAt2 = in->first_segment()->finalPoint(); + } }else{ - if(!noCusp){ - pointAt1 = SBasisIn.valueAt(value); - pointAt2 = SBasisIn.valueAt(1-value); + if(!ignoreCusp){ + pointAt1 = SBasisIn.valueAt(weightValue); + pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + pointAt2 = SBasisIn.valueAt(1-weightValue); + pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); }else{ pointAt1 = in->first_segment()->initialPoint(); pointAt2 = in->first_segment()->finalPoint(); @@ -433,18 +415,24 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double value , bool noCusp) SBasisOut = out->first_segment()->toSBasis(); cubic = dynamic_cast(&*curve_it2); if(cubic){ - if(!noCusp || (*cubic)[1] != out->first_segment()->initialPoint()) - nextPointAt1 = SBasisOut.valueAt(value); - else + if(!ignoreCusp || !Geom::are_near((*cubic)[1],out->first_segment()->initialPoint())){ + nextPointAt1 = SBasisOut.valueAt(weightValue); + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + }else{ nextPointAt1 = out->first_segment()->initialPoint(); - if(!noCusp || (*cubic)[2] != out->first_segment()->finalPoint()) - nextPointAt2 = SBasisOut.valueAt(1-value); - else + } + if(!ignoreCusp || !Geom::are_near((*cubic)[2],out->first_segment()->finalPoint())){ + nextPointAt2 = SBasisOut.valueAt(1-weightValue); + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); + }else{ nextPointAt2 = out->first_segment()->finalPoint(); + } }else{ - if(!noCusp){ - nextPointAt1 = SBasisOut.valueAt(value); - nextPointAt2 = SBasisOut.valueAt(1-value); + if(!ignoreCusp){ + nextPointAt1 = SBasisOut.valueAt(weightValue); + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + nextPointAt2 = SBasisOut.valueAt(1-weightValue); + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); }else{ nextPointAt1 = out->first_segment()->initialPoint(); nextPointAt2 = out->first_segment()->finalPoint(); diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 3915a476c..10d157ac1 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -8,12 +8,20 @@ */ #include "live_effects/effect.h" +#include "live_effects/parameter/bool.h" namespace Inkscape { namespace LivePathEffect { class LPEBSpline : public Effect { +private: + BoolParam ignoreCusp; + ScalarParam weight; + + LPEBSpline(const LPEBSpline&); + LPEBSpline& operator=(const LPEBSpline&); + public: LPEBSpline(LivePathEffectObject *lpeobject); virtual ~LPEBSpline(); @@ -28,49 +36,16 @@ public: virtual Gtk::Widget * newWidget(); - int steps; - -protected: - - Gtk::Widget* scal; - - Gtk::Widget* noCusp; - - Gtk::Widget* reset; - - Gtk::Widget* stepsHandles; - - virtual void registerScal(Glib::ustring title, Glib::ustring tip){scal = LPEBSpline::newScal(title,tip);}; + virtual void changeWeight(double weightValue); - virtual void registerNoCusp(Glib::ustring title){noCusp = LPEBSpline::newNoCusp(title);}; + virtual void toDefaultWeight(); - virtual void registerReset(Glib::ustring title){reset = LPEBSpline::newReset(title);}; + virtual void toWeight(); - virtual void registerStepsHandles(Glib::ustring title, Glib::ustring tip){stepsHandles = LPEBSpline::newStepsHandles(title,tip);}; + ScalarParam steps; - virtual Gtk::Widget* newScal(Glib::ustring title, Glib::ustring tip); - - virtual Gtk::Widget* newNoCusp(Glib::ustring title); - - virtual Gtk::Widget* newReset(Glib::ustring title); - - virtual Gtk::Widget* newStepsHandles(Glib::ustring title, Glib::ustring tip); - - virtual void updateAllHandles(); - - virtual void resetHandles(); - - virtual void updateSteps(); - - virtual void updateStepsValue(int stepsValue){steps=stepsValue;}; - -private: - LPEBSpline(const LPEBSpline&); - LPEBSpline& operator=(const LPEBSpline&); - }; }; //namespace LivePathEffect }; //namespace Inkscape - #endif -- cgit v1.2.3 From fc95705f9d5761fe111a445c51afc505d08738a7 Mon Sep 17 00:00:00 2001 From: jtx Date: Tue, 19 Mar 2013 17:56:26 +0100 Subject: Fixing regression (bzr r11950.1.61) --- src/live_effects/lpe-recursiveskeleton.cpp | 3 ++- src/live_effects/parameter/parameter.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-recursiveskeleton.cpp b/src/live_effects/lpe-recursiveskeleton.cpp index 452139344..ac571d963 100644 --- a/src/live_effects/lpe-recursiveskeleton.cpp +++ b/src/live_effects/lpe-recursiveskeleton.cpp @@ -91,7 +91,8 @@ LPERecursiveSkeleton::doEffect_pwd2 (Geom::Piecewise > co double scaling = (uskeleton.domain().extent() - toffset)/pattBndsX->extent(); // TODO investigate why pattWidth is not being used: - double pattWidth = pattBndsX->extent() * scaling; + // - Doesn't appear to have been used anywhere in bzr history (Alex V: 2013-03-16) + // double pattWidth = pattBndsX->extent() * scaling; if (scaling != 1.0) { x*=scaling; diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp index 7e155cb92..8615721b0 100644 --- a/src/live_effects/parameter/parameter.cpp +++ b/src/live_effects/parameter/parameter.cpp @@ -5,7 +5,7 @@ */ #include -#include "live_effects/lpe-bspline.h" + #include "live_effects/parameter/parameter.h" #include "live_effects/effect.h" #include "svg/svg.h" @@ -128,6 +128,7 @@ ScalarParam::param_newWidget() { Inkscape::UI::Widget::RegisteredScalar *rsu = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar( param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) ); + rsu->setValue(value); rsu->setDigits(digits); rsu->setIncrements(inc_step, inc_page); -- cgit v1.2.3 From b887e821e03cae71b2116d58e64efb62eb9be0be Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 20 Mar 2013 01:47:49 +0100 Subject: For testing, widget added, regression fixed (bzr r11950.1.62) --- src/live_effects/lpe-bspline.cpp | 35 ++++++++++++++++++++++++----------- src/live_effects/lpe-bspline.h | 18 +++++++++--------- 2 files changed, 33 insertions(+), 20 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index e6461e94c..d3c64bb67 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -11,6 +11,7 @@ #include #include "sp-path.h" #include "style.h" +#include "document-private.h" #include "document.h" #include "document-undo.h" #include "desktop-handles.h" @@ -45,9 +46,9 @@ LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) : Effect(lpeobject), // initialise your parameters here: //testpointA(_("Test Point A"), _("Test A"), "ptA", &wr, this, Geom::Point(100,100)), + steps(_("Steps whith CTRL:"), _("Change number of steps whith CTRL pressed"), "steps", &wr, this, 2), ignoreCusp(_("Ignore cusp nodes:"), _("Change ignoring cusp nodes"), "ignoreCusp", &wr, this, true), - weight(_("Change weight:"), _("Change weight of the effect"), "weight", &wr, this, 33.33), - steps(_("Steps whith CTRL:"), _("Change number of steps whith CTRL pressed"), "steps", &wr, this, 2) + weight(_("Change weight:"), _("Change weight of the effect"), "weight", &wr, this, 33.33) { registerParameter( dynamic_cast(&ignoreCusp) ); registerParameter( dynamic_cast(&weight) ); @@ -64,11 +65,24 @@ LPEBSpline::~LPEBSpline() { } -void -LPEBSpline::doOnApply(SPLPEItem const* lpeitem) +void +LPEBSpline::createAndApply(const char* name, SPDocument *doc, SPItem *item) { - if (!SP_IS_SHAPE(lpeitem)) { + if (!SP_IS_SHAPE(item)) { g_warning("LPE BSpline can only be applied to shapes (not groups)."); + }else{ + // Path effect definition + Inkscape::XML::Document *xml_doc = doc->getReprDoc(); + Inkscape::XML::Node *repr = xml_doc->createElement("inkscape:path-effect"); + repr->setAttribute("effect", name); + + doc->getDefs()->getRepr()->addChild(repr, NULL); // adds to and assigns the 'id' attribute + const gchar * repr_id = repr->attribute("id"); + Inkscape::GC::release(repr); + + gchar *href = g_strdup_printf("#%s", repr_id); + sp_lpe_item_add_path_effect(SP_LPE_ITEM(item), href, true); + g_free(href); } } @@ -289,16 +303,15 @@ LPEBSpline::newWidget() void LPEBSpline::toDefaultWeight(){ -double weightValue = 0.3333; -changeWeight(weightValue); -weight.param_set_value(33.33); -gtk_widget_draw(GTK_WIDGET(LPEBSpline::newWidget()), NULL); + double weightValue = 0.3334; + weight.param_set_value(33.33); + changeWeight(weightValue); } void LPEBSpline::toWeight(){ -double weightValue = weight/100; -changeWeight(weightValue); + double weightValue = weight/100; + changeWeight(weightValue); } void diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 10d157ac1..44c3f451c 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -15,20 +15,13 @@ namespace LivePathEffect { class LPEBSpline : public Effect { -private: - BoolParam ignoreCusp; - ScalarParam weight; - - LPEBSpline(const LPEBSpline&); - LPEBSpline& operator=(const LPEBSpline&); - public: LPEBSpline(LivePathEffectObject *lpeobject); virtual ~LPEBSpline(); - virtual LPEPathFlashType pathFlashType() const { return SUPPRESS_FLASH; } + virtual void createAndApply(const char* name, SPDocument *doc, SPItem *item); - virtual void doOnApply(SPLPEItem const* lpeitem); + virtual LPEPathFlashType pathFlashType() const { return SUPPRESS_FLASH; } virtual void doEffect(SPCurve * curve); @@ -44,6 +37,13 @@ public: ScalarParam steps; +private: + BoolParam ignoreCusp; + ScalarParam weight; + + LPEBSpline(const LPEBSpline&); + LPEBSpline& operator=(const LPEBSpline&); + }; }; //namespace LivePathEffect -- cgit v1.2.3 From d142ebe8740c40922c1a6aa423ca4e0e7d2335d6 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 22 Mar 2013 01:50:18 +0100 Subject: Fixed end extremium node delete fault, ready for testing (bzr r11950.1.66) --- src/live_effects/lpe-bspline.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 44c3f451c..20012f894 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -38,6 +38,7 @@ public: ScalarParam steps; private: + BoolParam ignoreCusp; ScalarParam weight; -- cgit v1.2.3 From 37d99686ec9b0a49c1ef07483967571da674e65e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 23 Mar 2013 20:09:28 +0100 Subject: Fix weight 0 by widget now give a full cusp node (bzr r11950.1.70) --- src/live_effects/lpe-bspline.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 0a13c17b2..ee771a54e 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -399,20 +399,20 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue , bool ignor pointAt0 = in->first_segment()->initialPoint(); SBasisIn = in->first_segment()->toSBasis(); if(cubic){ - if(!ignoreCusp || !Geom::are_near((*cubic)[1],in->first_segment()->initialPoint())){ + if((!ignoreCusp || !Geom::are_near((*cubic)[1],in->first_segment()->initialPoint())) && weightValue !=0){ pointAt1 = SBasisIn.valueAt(weightValue); pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); }else{ pointAt1 = in->first_segment()->initialPoint(); } - if(!ignoreCusp || !Geom::are_near((*cubic)[2],in->first_segment()->finalPoint())){ + if((!ignoreCusp || !Geom::are_near((*cubic)[2],in->first_segment()->finalPoint())) && weightValue !=0){ pointAt2 = SBasisIn.valueAt(1-weightValue); pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); }else{ pointAt2 = in->first_segment()->finalPoint(); } }else{ - if(!ignoreCusp){ + if(!ignoreCusp && weightValue !=0){ pointAt1 = SBasisIn.valueAt(weightValue); pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); pointAt2 = SBasisIn.valueAt(1-weightValue); @@ -433,20 +433,20 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue , bool ignor SBasisOut = out->first_segment()->toSBasis(); cubic = dynamic_cast(&*curve_it2); if(cubic){ - if(!ignoreCusp || !Geom::are_near((*cubic)[1],out->first_segment()->initialPoint())){ + if((!ignoreCusp || !Geom::are_near((*cubic)[1],out->first_segment()->initialPoint()))&& weightValue !=0){ nextPointAt1 = SBasisOut.valueAt(weightValue); nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); }else{ nextPointAt1 = out->first_segment()->initialPoint(); } - if(!ignoreCusp || !Geom::are_near((*cubic)[2],out->first_segment()->finalPoint())){ + if((!ignoreCusp || !Geom::are_near((*cubic)[2],out->first_segment()->finalPoint()))&& weightValue !=0){ nextPointAt2 = SBasisOut.valueAt(1-weightValue); nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); }else{ nextPointAt2 = out->first_segment()->finalPoint(); } }else{ - if(!ignoreCusp){ + if(!ignoreCusp && weightValue !=0){ nextPointAt1 = SBasisOut.valueAt(weightValue); nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); nextPointAt2 = SBasisOut.valueAt(1-weightValue); -- cgit v1.2.3 From a7ced41f3fa6933d0da0151ef42e82e0862581fb Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 1 Apr 2013 01:09:52 +0200 Subject: Fix scale and rotate some nodes (bzr r11950.1.78) --- src/live_effects/lpe-bspline.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index ee771a54e..37d6a86a5 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -29,6 +29,7 @@ #include "ui/widget/scalar.h" #include "selection.h" #include "gtkmm/checkbutton.h" +#include "ui/tool/node.h" // For handling un-continuous paths: #include "message-stack.h" #include "inkscape.h" @@ -337,15 +338,34 @@ LPEBSpline::changeWeight(double weightValue) DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_LPE, _("Modified the weight of the BSpline")); } - +//bool +//LPEBspline::selectedPoint(Geom::Point p){ +// for (SubpathList::iterator i = NodeIterator.begin(); i != NodeIterator.end(); ++i) { +// if (i->selected() && i.ptr()->getPosition() == p) { +// return true; +// } +// } +// return false; +//} +//bool +//LPEBspline::hasNodesSelected(){ +// for (SubpathList::iterator i = NodeIterator.begin(); i != NodeIterator.end(); ++i) { +// if (i->selected() && i.ptr()->getPosition() == p) { +// return true; +// } +// } +// return false; +//} void LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue , bool ignoreCusp) { using Geom::X; using Geom::Y; + //bool hasNodesSelected = LPEBspline::hasNodesSelected(); if(curve->get_segment_count() < 2) return; // Make copy of old path as it is changed during processing + Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); -- cgit v1.2.3 From 0b6a723f67700368d3585fc9b8009a3db30b5473 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 4 Apr 2013 19:34:41 +0200 Subject: Changing width only to selected nodes (bzr r11950.1.81) --- src/live_effects/lpe-bspline.cpp | 282 ++++++++++++++++++++++++++++----------- src/live_effects/lpe-bspline.h | 9 +- 2 files changed, 214 insertions(+), 77 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 37d6a86a5..389c11a23 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -3,12 +3,25 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ - -#include "xml/repr.h" -#include "svg/svg.h" -#include "display/curve.h" +#include +#include +#include #include #include +#include "display/curve.h" +#include <2geom/bezier-curve.h> +#include "helper/geom-curves.h" +#include "live_effects/lpe-bspline.h" +#include "live_effects/lpeobject.h" +#include "live_effects/parameter/parameter.h" +#include "ui/widget/scalar.h" +#include "ui/tool/node.h" +#include "ui/tool/node-tool.h" +#include "ui/tool/control-point-selection.h" +#include "ui/tool/selectable-control-point.h" +#include "selection.h" +#include "xml/repr.h" +#include "svg/svg.h" #include "sp-path.h" #include "style.h" #include "document-private.h" @@ -16,20 +29,10 @@ #include "document-undo.h" #include "desktop-handles.h" #include "verbs.h" -#include "live_effects/lpe-bspline.h" -#include -#include #include "sp-lpe-item.h" -#include "live_effects/lpeobject.h" -#include "live_effects/parameter/parameter.h" #include "display/sp-canvas.h" #include -#include <2geom/bezier-curve.h> -#include "helper/geom-curves.h" -#include "ui/widget/scalar.h" -#include "selection.h" -#include "gtkmm/checkbutton.h" -#include "ui/tool/node.h" +#include // For handling un-continuous paths: #include "message-stack.h" #include "inkscape.h" @@ -49,9 +52,11 @@ LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) : //testpointA(_("Test Point A"), _("Test A"), "ptA", &wr, this, Geom::Point(100,100)), steps(_("Steps whith CTRL:"), _("Change number of steps whith CTRL pressed"), "steps", &wr, this, 2), ignoreCusp(_("Ignore cusp nodes:"), _("Change ignoring cusp nodes"), "ignoreCusp", &wr, this, true), + onlySelected(_("Change only selected nodes:"), _("Change only selected nodes"), "onlySelected", &wr, this, false), weight(_("Change weight:"), _("Change weight of the effect"), "weight", &wr, this, 0.3334) { registerParameter( dynamic_cast(&ignoreCusp) ); + registerParameter( dynamic_cast(&onlySelected) ); registerParameter( dynamic_cast(&weight) ); registerParameter( dynamic_cast(&steps) ); weight.param_set_range(0.0000, 1); @@ -279,6 +284,10 @@ LPEBSpline::newWidget() widgRegistered->signal_value_changed().connect(sigc::mem_fun (*this,&LPEBSpline::toWeight)); widg = dynamic_cast(widgRegistered); } + if(param->param_key == "onlySelected"){ + Gtk::CheckButton * widgRegistered = Gtk::manage(dynamic_cast(widg)); + widg = dynamic_cast(widgRegistered); + } if(param->param_key == "ignoreCusp"){ Gtk::CheckButton * widgRegistered = Gtk::manage(dynamic_cast(widg)); widg = dynamic_cast(widgRegistered); @@ -307,7 +316,7 @@ LPEBSpline::newWidget() void LPEBSpline::toDefaultWeight(){ - Gtk::Widget * widg = dynamic_cast(param_vector[2]->param_newWidget()); + Gtk::Widget * widg = dynamic_cast(param_vector[3]->param_newWidget()); Inkscape::UI::Widget::Scalar * widgRegistered = Gtk::manage(dynamic_cast(widg)); widgRegistered->setValue(0.3334); widgRegistered->update(); @@ -329,7 +338,7 @@ LPEBSpline::changeWeight(double weightValue) SPItem *item = (SPItem *)g_slist_nth(items,0)->data; SPPath *path = SP_PATH(item); SPCurve *curve = path->get_curve_for_edit(); - LPEBSpline::doBSplineFromWidget(curve,weightValue,ignoreCusp); + LPEBSpline::doBSplineFromWidget(curve,weightValue); gchar *str = sp_svg_write_path(curve->get_pathvector()); path->getRepr()->setAttribute("inkscape:original-d", str); g_free(str); @@ -338,34 +347,42 @@ LPEBSpline::changeWeight(double weightValue) DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_LPE, _("Modified the weight of the BSpline")); } -//bool -//LPEBspline::selectedPoint(Geom::Point p){ -// for (SubpathList::iterator i = NodeIterator.begin(); i != NodeIterator.end(); ++i) { -// if (i->selected() && i.ptr()->getPosition() == p) { -// return true; -// } -// } -// return false; -//} -//bool -//LPEBspline::hasNodesSelected(){ -// for (SubpathList::iterator i = NodeIterator.begin(); i != NodeIterator.end(); ++i) { -// if (i->selected() && i.ptr()->getPosition() == p) { -// return true; -// } -// } -// return false; -//} + +bool +LPEBSpline::nodeIsSelected(Geom::Point nodePoint, int index){ + volatile int index2 = index; + volatile Geom::Point aa = nodePoint; + volatile std::vector x2 = points; + if(points.size() > 0){ + volatile double dist = Geom::distance(points[index], nodePoint); + if(dist == 0 ){ + return true; + } + } + return false; +} + void -LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue , bool ignoreCusp) +LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) { using Geom::X; using Geom::Y; + SPDesktop *desktop = inkscape_active_desktop(); + if(INK_IS_NODE_TOOL(desktop->event_context)){ + InkNodeTool *nt = INK_NODE_TOOL(desktop->event_context); + Inkscape::UI::ControlPointSelection::Set &selection = nt->_selected_nodes->allPoints(); + points.clear(); + for (Inkscape::UI::ControlPointSelection::Set::iterator i = selection.begin(); i != selection.end(); ++i){ + if ((*i)->selected()) { + Inkscape::UI::Node *n = static_cast(*i); + points.push_back(n->position()); + } + } + } //bool hasNodesSelected = LPEBspline::hasNodesSelected(); if(curve->get_segment_count() < 2) return; // Make copy of old path as it is changed during processing - Geom::PathVector const original_pathv = curve->get_pathvector(); curve->reset(); @@ -388,12 +405,14 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue , bool ignor Geom::Point pointAt1(0,0); Geom::Point pointAt2(0,0); Geom::Point pointAt3(0,0); + Geom::Point nextPointAt0(0,0); Geom::Point nextPointAt1(0,0); Geom::Point nextPointAt2(0,0); Geom::Point nextPointAt3(0,0); Geom::D2< Geom::SBasis > SBasisIn; Geom::D2< Geom::SBasis > SBasisOut; Geom::CubicBezier const *cubic = NULL; + int i = 0; if (path_it->closed()) { // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. @@ -417,32 +436,88 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue , bool ignor in->lineto(curve_it1->finalPoint()); cubic = dynamic_cast(&*curve_it1); pointAt0 = in->first_segment()->initialPoint(); + pointAt3 = in->first_segment()->finalPoint(); SBasisIn = in->first_segment()->toSBasis(); - if(cubic){ - if((!ignoreCusp || !Geom::are_near((*cubic)[1],in->first_segment()->initialPoint())) && weightValue !=0){ - pointAt1 = SBasisIn.valueAt(weightValue); - pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + if(!onlySelected){ + if(cubic){ + if((!ignoreCusp || !Geom::are_near((*cubic)[1],in->first_segment()->initialPoint())) && weightValue !=0){ + pointAt1 = SBasisIn.valueAt(weightValue); + pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + }else{ + pointAt1 = in->first_segment()->initialPoint(); + } + if((!ignoreCusp || !Geom::are_near((*cubic)[2],in->first_segment()->finalPoint())) && weightValue !=0){ + pointAt2 = SBasisIn.valueAt(1-weightValue); + pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); }else{ - pointAt1 = in->first_segment()->initialPoint(); - } - if((!ignoreCusp || !Geom::are_near((*cubic)[2],in->first_segment()->finalPoint())) && weightValue !=0){ - pointAt2 = SBasisIn.valueAt(1-weightValue); - pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); - }else{ - pointAt2 = in->first_segment()->finalPoint(); + pointAt2 = in->first_segment()->finalPoint(); + } + }else{ + if(!ignoreCusp && weightValue !=0){ + pointAt1 = SBasisIn.valueAt(weightValue); + pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + pointAt2 = SBasisIn.valueAt(1-weightValue); + pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); + }else{ + pointAt1 = in->first_segment()->initialPoint(); + pointAt2 = in->first_segment()->finalPoint(); + } } }else{ - if(!ignoreCusp && weightValue !=0){ - pointAt1 = SBasisIn.valueAt(weightValue); - pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); - pointAt2 = SBasisIn.valueAt(1-weightValue); - pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); + if(cubic){ + if((!ignoreCusp || !Geom::are_near((*cubic)[1],in->first_segment()->initialPoint())) && weightValue !=0){ + if(nodeIsSelected(pointAt0,i)){ + pointAt1 = SBasisIn.valueAt(weightValue); + pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + }else{ + pointAt1 = (*cubic)[1]; + } + }else{ + if(nodeIsSelected(pointAt0,i)){ + pointAt1 = in->first_segment()->initialPoint(); + }else{ + pointAt1 = (*cubic)[1]; + } + } + i++; + if((!ignoreCusp || !Geom::are_near((*cubic)[2],in->first_segment()->finalPoint())) && weightValue !=0){ + if(nodeIsSelected(pointAt3,i)){ + pointAt2 = SBasisIn.valueAt(1-weightValue); + pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); + }else{ + pointAt2 = (*cubic)[2]; + i--; + } + }else{ + if(nodeIsSelected(pointAt3,i)){ + pointAt2 = in->first_segment()->finalPoint(); + }else{ + pointAt2 = (*cubic)[2]; + i--; + } + } }else{ - pointAt1 = in->first_segment()->initialPoint(); - pointAt2 = in->first_segment()->finalPoint(); + if(!ignoreCusp && weightValue !=0){ + if(nodeIsSelected(pointAt0,i)){ + pointAt1 = SBasisIn.valueAt(weightValue); + pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + }else{ + pointAt1 = in->first_segment()->initialPoint(); + } + i++; + if(nodeIsSelected(pointAt3,i)){ + pointAt2 = SBasisIn.valueAt(weightValue); + pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); + }else{ + pointAt2 = in->first_segment()->finalPoint(); + i--; + } + }else{ + pointAt1 = in->first_segment()->initialPoint(); + pointAt2 = in->first_segment()->finalPoint(); + } } } - pointAt3 = in->first_segment()->finalPoint(); in->reset(); delete in; //Y hacemos lo propio con el path de salida @@ -451,32 +526,89 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue , bool ignor out->moveto(curve_it2->initialPoint()); out->lineto(curve_it2->finalPoint()); SBasisOut = out->first_segment()->toSBasis(); + nextPointAt0 = out->first_segment()->initialPoint(); + nextPointAt3 = out->first_segment()->finalPoint(); cubic = dynamic_cast(&*curve_it2); - if(cubic){ - if((!ignoreCusp || !Geom::are_near((*cubic)[1],out->first_segment()->initialPoint()))&& weightValue !=0){ - nextPointAt1 = SBasisOut.valueAt(weightValue); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + if(!onlySelected){ + if(cubic){ + if((!ignoreCusp || !Geom::are_near((*cubic)[1],out->first_segment()->initialPoint()))&& weightValue !=0){ + nextPointAt1 = SBasisOut.valueAt(weightValue); + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + }else{ + nextPointAt1 = out->first_segment()->initialPoint(); + } + if((!ignoreCusp || !Geom::are_near((*cubic)[2],out->first_segment()->finalPoint()))&& weightValue !=0){ + nextPointAt2 = SBasisOut.valueAt(1-weightValue); + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); + }else{ + nextPointAt2 = out->first_segment()->finalPoint(); + } }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - } - if((!ignoreCusp || !Geom::are_near((*cubic)[2],out->first_segment()->finalPoint()))&& weightValue !=0){ - nextPointAt2 = SBasisOut.valueAt(1-weightValue); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); - }else{ - nextPointAt2 = out->first_segment()->finalPoint(); + if(!ignoreCusp && weightValue !=0){ + nextPointAt1 = SBasisOut.valueAt(weightValue); + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + nextPointAt2 = SBasisOut.valueAt(1-weightValue); + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); + }else{ + nextPointAt1 = out->first_segment()->initialPoint(); + nextPointAt2 = out->first_segment()->finalPoint(); + } } }else{ - if(!ignoreCusp && weightValue !=0){ - nextPointAt1 = SBasisOut.valueAt(weightValue); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); - nextPointAt2 = SBasisOut.valueAt(1-weightValue); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); + if(cubic){ + if((!ignoreCusp || !Geom::are_near((*cubic)[1],out->first_segment()->initialPoint())) && weightValue !=0){ + if(nodeIsSelected(nextPointAt0,i)){ + nextPointAt1 = SBasisOut.valueAt(weightValue); + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + }else{ + nextPointAt1 = (*cubic)[1]; + } + }else{ + if(nodeIsSelected(nextPointAt0,i)){ + nextPointAt1 = out->first_segment()->initialPoint(); + }else{ + nextPointAt1 = (*cubic)[1]; + } + } + i++; + if((!ignoreCusp || !Geom::are_near((*cubic)[2],out->first_segment()->finalPoint())) && weightValue !=0){ + if(nodeIsSelected(nextPointAt3,i)){ + nextPointAt2 = SBasisOut.valueAt(1-weightValue); + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); + }else{ + nextPointAt2 = (*cubic)[2]; + i--; + } + }else{ + if(nodeIsSelected(nextPointAt3,i)){ + nextPointAt2 = out->first_segment()->finalPoint(); + }else{ + nextPointAt2 = (*cubic)[2]; + i--; + } + } }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - nextPointAt2 = out->first_segment()->finalPoint(); + if(!ignoreCusp && weightValue !=0){ + if(nodeIsSelected(nextPointAt0,i)){ + nextPointAt1 = SBasisOut.valueAt(weightValue); + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + }else{ + nextPointAt1 = out->first_segment()->initialPoint(); + } + i++; + if(nodeIsSelected(nextPointAt3,i)){ + nextPointAt2 = SBasisOut.valueAt(weightValue); + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); + }else{ + nextPointAt2 = out->first_segment()->finalPoint(); + i--; + } + }else{ + nextPointAt1 = out->first_segment()->initialPoint(); + nextPointAt2 = out->first_segment()->finalPoint(); + } } } - nextPointAt3 = out->first_segment()->finalPoint(); out->reset(); delete out; //La curva BSpline se forma calculando el centro del segmanto de unión diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 20012f894..2361c10d0 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -9,6 +9,8 @@ #include "live_effects/effect.h" #include "live_effects/parameter/bool.h" +#include + namespace Inkscape { namespace LivePathEffect { @@ -25,7 +27,9 @@ public: virtual void doEffect(SPCurve * curve); - virtual void doBSplineFromWidget(SPCurve * curve, double value, bool noCusp); + virtual void doBSplineFromWidget(SPCurve * curve, double value); + + virtual bool nodeIsSelected(Geom::Point nodePoint, int index); virtual Gtk::Widget * newWidget(); @@ -38,8 +42,9 @@ public: ScalarParam steps; private: - + std::vector points; BoolParam ignoreCusp; + BoolParam onlySelected; ScalarParam weight; LPEBSpline(const LPEBSpline&); -- cgit v1.2.3 From 30858428c74d1fa0f119f40b99fa5e51836d8599 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 8 Apr 2013 00:50:31 +0200 Subject: Change width only for selected nodes by widget (bzr r11950.1.83) --- src/live_effects/lpe-bspline.cpp | 46 ++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 389c11a23..e93fd62d2 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -10,6 +10,7 @@ #include #include "display/curve.h" #include <2geom/bezier-curve.h> +#include <2geom/point.h> #include "helper/geom-curves.h" #include "live_effects/lpe-bspline.h" #include "live_effects/lpeobject.h" @@ -341,6 +342,10 @@ LPEBSpline::changeWeight(double weightValue) LPEBSpline::doBSplineFromWidget(curve,weightValue); gchar *str = sp_svg_write_path(curve->get_pathvector()); path->getRepr()->setAttribute("inkscape:original-d", str); + if(INK_IS_NODE_TOOL(desktop->event_context)){ + InkNodeTool *nt = INK_NODE_TOOL(desktop->event_context); + nt->desktop->updateNow(); + } g_free(str); curve->unref(); desktop->clearWaitingCursor(); @@ -350,12 +355,8 @@ LPEBSpline::changeWeight(double weightValue) bool LPEBSpline::nodeIsSelected(Geom::Point nodePoint, int index){ - volatile int index2 = index; - volatile Geom::Point aa = nodePoint; - volatile std::vector x2 = points; if(points.size() > 0){ - volatile double dist = Geom::distance(points[index], nodePoint); - if(dist == 0 ){ + if(Geom::are_near(points[index], nodePoint)){ return true; } } @@ -373,9 +374,12 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) Inkscape::UI::ControlPointSelection::Set &selection = nt->_selected_nodes->allPoints(); points.clear(); for (Inkscape::UI::ControlPointSelection::Set::iterator i = selection.begin(); i != selection.end(); ++i){ - if ((*i)->selected()) { - Inkscape::UI::Node *n = static_cast(*i); - points.push_back(n->position()); + if(onlySelected){ + if ((*i)->selected()) { + Inkscape::UI::Node *n = static_cast(*i); + n->bsplineWeight = weightValue; + points.insert(points.begin(),desktop->doc2dt(n->position())); + } } } } @@ -469,31 +473,30 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) if(nodeIsSelected(pointAt0,i)){ pointAt1 = SBasisIn.valueAt(weightValue); pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + i++; }else{ pointAt1 = (*cubic)[1]; } }else{ if(nodeIsSelected(pointAt0,i)){ pointAt1 = in->first_segment()->initialPoint(); + i++; }else{ pointAt1 = (*cubic)[1]; } } - i++; if((!ignoreCusp || !Geom::are_near((*cubic)[2],in->first_segment()->finalPoint())) && weightValue !=0){ if(nodeIsSelected(pointAt3,i)){ pointAt2 = SBasisIn.valueAt(1-weightValue); pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); }else{ pointAt2 = (*cubic)[2]; - i--; } }else{ if(nodeIsSelected(pointAt3,i)){ pointAt2 = in->first_segment()->finalPoint(); }else{ pointAt2 = (*cubic)[2]; - i--; } } }else{ @@ -501,20 +504,22 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) if(nodeIsSelected(pointAt0,i)){ pointAt1 = SBasisIn.valueAt(weightValue); pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + i++; }else{ pointAt1 = in->first_segment()->initialPoint(); } - i++; if(nodeIsSelected(pointAt3,i)){ pointAt2 = SBasisIn.valueAt(weightValue); pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); }else{ pointAt2 = in->first_segment()->finalPoint(); - i--; } }else{ pointAt1 = in->first_segment()->initialPoint(); pointAt2 = in->first_segment()->finalPoint(); + if(nodeIsSelected(pointAt0,i)){ + i++; + } } } } @@ -560,51 +565,50 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) if(nodeIsSelected(nextPointAt0,i)){ nextPointAt1 = SBasisOut.valueAt(weightValue); nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + if (path_it->closed()) i++; }else{ nextPointAt1 = (*cubic)[1]; } }else{ if(nodeIsSelected(nextPointAt0,i)){ - nextPointAt1 = out->first_segment()->initialPoint(); + nextPointAt1 = out->first_segment()->initialPoint(); + if (path_it->closed()) i++; }else{ nextPointAt1 = (*cubic)[1]; } } - i++; if((!ignoreCusp || !Geom::are_near((*cubic)[2],out->first_segment()->finalPoint())) && weightValue !=0){ if(nodeIsSelected(nextPointAt3,i)){ nextPointAt2 = SBasisOut.valueAt(1-weightValue); nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); }else{ nextPointAt2 = (*cubic)[2]; - i--; - } + } }else{ if(nodeIsSelected(nextPointAt3,i)){ nextPointAt2 = out->first_segment()->finalPoint(); }else{ nextPointAt2 = (*cubic)[2]; - i--; - } + } } }else{ if(!ignoreCusp && weightValue !=0){ if(nodeIsSelected(nextPointAt0,i)){ nextPointAt1 = SBasisOut.valueAt(weightValue); nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + if (path_it->closed()) i++; }else{ nextPointAt1 = out->first_segment()->initialPoint(); } - i++; if(nodeIsSelected(nextPointAt3,i)){ nextPointAt2 = SBasisOut.valueAt(weightValue); nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); }else{ nextPointAt2 = out->first_segment()->finalPoint(); - i--; } }else{ nextPointAt1 = out->first_segment()->initialPoint(); + if (path_it->closed()&&nodeIsSelected(nextPointAt0,i)) i++; nextPointAt2 = out->first_segment()->finalPoint(); } } -- cgit v1.2.3 From d2e58f51d29c5da3f82d29883c0a07ce9573f8ca Mon Sep 17 00:00:00 2001 From: root Date: Wed, 10 Apr 2013 06:08:17 +0200 Subject: fixing error moving selected nodes (bzr r11950.1.86) --- src/live_effects/lpe-bspline.cpp | 102 +++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 52 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index e93fd62d2..657b2ded3 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -374,13 +374,10 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) Inkscape::UI::ControlPointSelection::Set &selection = nt->_selected_nodes->allPoints(); points.clear(); for (Inkscape::UI::ControlPointSelection::Set::iterator i = selection.begin(); i != selection.end(); ++i){ - if(onlySelected){ if ((*i)->selected()) { Inkscape::UI::Node *n = static_cast(*i); - n->bsplineWeight = weightValue; points.insert(points.begin(),desktop->doc2dt(n->position())); } - } } } //bool hasNodesSelected = LPEBspline::hasNodesSelected(); @@ -416,7 +413,7 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) Geom::D2< Geom::SBasis > SBasisIn; Geom::D2< Geom::SBasis > SBasisOut; Geom::CubicBezier const *cubic = NULL; - int i = 0; + int j = 0; if (path_it->closed()) { // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. @@ -470,30 +467,30 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) }else{ if(cubic){ if((!ignoreCusp || !Geom::are_near((*cubic)[1],in->first_segment()->initialPoint())) && weightValue !=0){ - if(nodeIsSelected(pointAt0,i)){ + if(nodeIsSelected(pointAt0,j)){ pointAt1 = SBasisIn.valueAt(weightValue); pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); - i++; + j++; }else{ pointAt1 = (*cubic)[1]; } }else{ - if(nodeIsSelected(pointAt0,i)){ + if(nodeIsSelected(pointAt0,j)){ pointAt1 = in->first_segment()->initialPoint(); - i++; + j++; }else{ pointAt1 = (*cubic)[1]; } } if((!ignoreCusp || !Geom::are_near((*cubic)[2],in->first_segment()->finalPoint())) && weightValue !=0){ - if(nodeIsSelected(pointAt3,i)){ + if(nodeIsSelected(pointAt3,j)){ pointAt2 = SBasisIn.valueAt(1-weightValue); pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); }else{ pointAt2 = (*cubic)[2]; } }else{ - if(nodeIsSelected(pointAt3,i)){ + if(nodeIsSelected(pointAt3,j)){ pointAt2 = in->first_segment()->finalPoint(); }else{ pointAt2 = (*cubic)[2]; @@ -501,14 +498,14 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) } }else{ if(!ignoreCusp && weightValue !=0){ - if(nodeIsSelected(pointAt0,i)){ + if(nodeIsSelected(pointAt0,j)){ pointAt1 = SBasisIn.valueAt(weightValue); pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); - i++; + j++; }else{ pointAt1 = in->first_segment()->initialPoint(); } - if(nodeIsSelected(pointAt3,i)){ + if(nodeIsSelected(pointAt3,j)){ pointAt2 = SBasisIn.valueAt(weightValue); pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); }else{ @@ -517,24 +514,42 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) }else{ pointAt1 = in->first_segment()->initialPoint(); pointAt2 = in->first_segment()->finalPoint(); - if(nodeIsSelected(pointAt0,i)){ - i++; + if(nodeIsSelected(pointAt0,j)){ + j++; } } } } in->reset(); delete in; - //Y hacemos lo propio con el path de salida - //nextPointAt0 = curveOut.valueAt(0); - SPCurve * out = new SPCurve(); - out->moveto(curve_it2->initialPoint()); - out->lineto(curve_it2->finalPoint()); - SBasisOut = out->first_segment()->toSBasis(); - nextPointAt0 = out->first_segment()->initialPoint(); - nextPointAt3 = out->first_segment()->finalPoint(); - cubic = dynamic_cast(&*curve_it2); - if(!onlySelected){ + + //La curva BSpline se forma calculando el centro del segmanto de unión + //de el punto situado en las 2/3 partes de el segmento de entrada + //con el punto situado en la posición 1/3 del segmento de salida + //Estos dos puntos ademas estan posicionados en el lugas correspondiente de + //los manejadores de la curva + SPCurve *curveHelper = new SPCurve(); + curveHelper->moveto(pointAt0); + curveHelper->curveto(pointAt1, pointAt2, pointAt3); + //añadimos la curva generada a la curva pricipal + nCurve->append_continuous(curveHelper, 0.0625); + curveHelper->reset(); + delete curveHelper; + //aumentamos los valores para el siguiente paso en el bucle + ++curve_it1; + ++curve_it2; + } + //Aberiguamos la ultima parte de la curva correspondiente al último segmento + //Y hacemos lo propio con el path de salida + //nextPointAt0 = curveOut.valueAt(0); + SPCurve * out = new SPCurve(); + out->moveto(curve_it1->initialPoint()); + out->lineto(curve_it1->finalPoint()); + SBasisOut = out->first_segment()->toSBasis(); + nextPointAt0 = out->first_segment()->initialPoint(); + nextPointAt3 = out->first_segment()->finalPoint(); + cubic = dynamic_cast(&*curve_it1); + if(!onlySelected){ if(cubic){ if((!ignoreCusp || !Geom::are_near((*cubic)[1],out->first_segment()->initialPoint()))&& weightValue !=0){ nextPointAt1 = SBasisOut.valueAt(weightValue); @@ -562,30 +577,30 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) }else{ if(cubic){ if((!ignoreCusp || !Geom::are_near((*cubic)[1],out->first_segment()->initialPoint())) && weightValue !=0){ - if(nodeIsSelected(nextPointAt0,i)){ + if(nodeIsSelected(nextPointAt0,j)){ nextPointAt1 = SBasisOut.valueAt(weightValue); nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); - if (path_it->closed()) i++; + j++; }else{ nextPointAt1 = (*cubic)[1]; } }else{ - if(nodeIsSelected(nextPointAt0,i)){ + if(nodeIsSelected(nextPointAt0,j)){ nextPointAt1 = out->first_segment()->initialPoint(); - if (path_it->closed()) i++; + j++; }else{ nextPointAt1 = (*cubic)[1]; } } if((!ignoreCusp || !Geom::are_near((*cubic)[2],out->first_segment()->finalPoint())) && weightValue !=0){ - if(nodeIsSelected(nextPointAt3,i)){ + if(nodeIsSelected(nextPointAt3,j)){ nextPointAt2 = SBasisOut.valueAt(1-weightValue); nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); }else{ nextPointAt2 = (*cubic)[2]; } }else{ - if(nodeIsSelected(nextPointAt3,i)){ + if(nodeIsSelected(nextPointAt3,j)){ nextPointAt2 = out->first_segment()->finalPoint(); }else{ nextPointAt2 = (*cubic)[2]; @@ -593,14 +608,14 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) } }else{ if(!ignoreCusp && weightValue !=0){ - if(nodeIsSelected(nextPointAt0,i)){ + if(nodeIsSelected(nextPointAt0,j)){ nextPointAt1 = SBasisOut.valueAt(weightValue); nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); - if (path_it->closed()) i++; + j++; }else{ nextPointAt1 = out->first_segment()->initialPoint(); } - if(nodeIsSelected(nextPointAt3,i)){ + if(nodeIsSelected(nextPointAt3,j)){ nextPointAt2 = SBasisOut.valueAt(weightValue); nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); }else{ @@ -608,30 +623,13 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) } }else{ nextPointAt1 = out->first_segment()->initialPoint(); - if (path_it->closed()&&nodeIsSelected(nextPointAt0,i)) i++; + if(nodeIsSelected(nextPointAt0,j)) j++; nextPointAt2 = out->first_segment()->finalPoint(); } } } out->reset(); delete out; - //La curva BSpline se forma calculando el centro del segmanto de unión - //de el punto situado en las 2/3 partes de el segmento de entrada - //con el punto situado en la posición 1/3 del segmento de salida - //Estos dos puntos ademas estan posicionados en el lugas correspondiente de - //los manejadores de la curva - SPCurve *curveHelper = new SPCurve(); - curveHelper->moveto(pointAt0); - curveHelper->curveto(pointAt1, pointAt2, pointAt3); - //añadimos la curva generada a la curva pricipal - nCurve->append_continuous(curveHelper, 0.0625); - curveHelper->reset(); - delete curveHelper; - //aumentamos los valores para el siguiente paso en el bucle - ++curve_it1; - ++curve_it2; - } - //Aberiguamos la ultima parte de la curva correspondiente al último segmento SPCurve *curveHelper = new SPCurve(); curveHelper->moveto(pointAt3); if (path_it->closed()) { -- cgit v1.2.3 From 1290320ca882992345418ce8572af053f1659628 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 10 Apr 2013 21:45:15 +0200 Subject: Fixed bug moving selected nodes (bzr r11950.1.88) --- src/live_effects/lpe-bspline.cpp | 168 ++++++++++++++------------------------- src/live_effects/lpe-bspline.h | 2 +- 2 files changed, 61 insertions(+), 109 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index e7adab071..37bf24021 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -140,7 +140,7 @@ LPEBSpline::doEffect(SPCurve * curve) //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - + nCurve->moveto(curve_it1->initialPoint()); //Recorremos todos los segmentos menos el último while ( curve_it2 != curve_endit ) { @@ -193,20 +193,11 @@ LPEBSpline::doEffect(SPCurve * curve) previousNode = node; //Y este hará de final de curva node = SBasisHelper.valueAt(0.5); - SPCurve *curveHelper = new SPCurve(); - curveHelper->moveto(previousNode); - curveHelper->curveto(pointAt1, pointAt2, node); - //añadimos la curva generada a la curva pricipal - nCurve->append_continuous(curveHelper, 0.0625); - curveHelper->reset(); - delete curveHelper; + nCurve->curveto(pointAt1, pointAt2, node); //aumentamos los valores para el siguiente paso en el bucle ++curve_it1; ++curve_it2; } - //Aberiguamos la ultima parte de la curva correspondiente al último segmento - SPCurve *curveHelper = new SPCurve(); - curveHelper->moveto(node); //Si está cerrada la curva, la cerramos sobre el valor guardado previamente //Si no finalizamos en el punto final Geom::Point startNode(0,0); @@ -242,8 +233,7 @@ LPEBSpline::doEffect(SPCurve * curve) lineHelper->reset(); delete lineHelper; startNode = SBasisHelper.valueAt(0.5); - curveHelper->curveto(nextPointAt1, nextPointAt2, startNode); - nCurve->append_continuous(curveHelper, 0.0625); + nCurve->curveto(nextPointAt1, nextPointAt2, startNode); nCurve->move_endpoints(startNode,startNode); }else{ SPCurve * start = new SPCurve(); @@ -252,12 +242,9 @@ LPEBSpline::doEffect(SPCurve * curve) startNode = start->first_segment()->initialPoint(); start->reset(); delete start; - curveHelper->curveto(nextPointAt1, nextPointAt2, nextPointAt3); - nCurve->append_continuous(curveHelper, 0.0625); + nCurve->curveto(nextPointAt1, nextPointAt2, nextPointAt3); nCurve->move_endpoints(startNode,nextPointAt3); } - curveHelper->reset(); - delete curveHelper; //y cerramos la curva if (path_it->closed()) { nCurve->closepath_current(); @@ -354,10 +341,15 @@ LPEBSpline::changeWeight(double weightValue) } bool -LPEBSpline::nodeIsSelected(Geom::Point nodePoint, int index){ +LPEBSpline::nodeIsSelected(Geom::Point nodePoint){ if(points.size() > 0){ - if(Geom::are_near(points[index], nodePoint)){ - return true; + for(std::vector::iterator i = points.begin(); i != points.end();){ + Geom::Point p = static_cast(*i); + if(Geom::are_near(p, nodePoint)){ + return true; + points.erase(i); + } + i++; } } return false; @@ -415,7 +407,6 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) Geom::D2< Geom::SBasis > SBasisIn; Geom::D2< Geom::SBasis > SBasisOut; Geom::CubicBezier const *cubic = NULL; - int j = 0; if (path_it->closed()) { // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. @@ -428,7 +419,7 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) //Si la curva está cerrada calculamos el punto donde //deveria estar el nodo BSpline de cierre/inicio de la curva //en posible caso de que se cierre con una linea recta creando un nodo BSPline - + nCurve->moveto(curve_it1->initialPoint()); //Recorremos todos los segmentos menos el último while ( curve_it2 != curve_endit ) { @@ -443,7 +434,7 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) SBasisIn = in->first_segment()->toSBasis(); if(!onlySelected){ if(cubic){ - if((!ignoreCusp || !Geom::are_near((*cubic)[1],in->first_segment()->initialPoint())) && weightValue !=0){ + if(!ignoreCusp || (!Geom::are_near((*cubic)[1],in->first_segment()->initialPoint()) && weightValue !=0)){ pointAt1 = SBasisIn.valueAt(weightValue); pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); }else{ @@ -468,46 +459,35 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) } }else{ if(cubic){ - if((!ignoreCusp || !Geom::are_near((*cubic)[1],in->first_segment()->initialPoint())) && weightValue !=0){ - if(nodeIsSelected(pointAt0,j)){ + if(!ignoreCusp || (!Geom::are_near((*cubic)[1],in->first_segment()->initialPoint())&& weightValue !=0)){ + if(nodeIsSelected(pointAt0)){ pointAt1 = SBasisIn.valueAt(weightValue); pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); - j++; }else{ pointAt1 = (*cubic)[1]; } }else{ - if(nodeIsSelected(pointAt0,j)){ pointAt1 = in->first_segment()->initialPoint(); - j++; - }else{ - pointAt1 = (*cubic)[1]; - } } - if((!ignoreCusp || !Geom::are_near((*cubic)[2],in->first_segment()->finalPoint())) && weightValue !=0){ - if(nodeIsSelected(pointAt3,j)){ + if(!ignoreCusp || (!Geom::are_near((*cubic)[2],in->first_segment()->finalPoint()) && weightValue !=0)){ + if(nodeIsSelected(pointAt3)){ pointAt2 = SBasisIn.valueAt(1-weightValue); pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); }else{ pointAt2 = (*cubic)[2]; } }else{ - if(nodeIsSelected(pointAt3,j)){ pointAt2 = in->first_segment()->finalPoint(); - }else{ - pointAt2 = (*cubic)[2]; - } } }else{ if(!ignoreCusp && weightValue !=0){ - if(nodeIsSelected(pointAt0,j)){ + if(nodeIsSelected(pointAt0)){ pointAt1 = SBasisIn.valueAt(weightValue); pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); - j++; }else{ pointAt1 = in->first_segment()->initialPoint(); } - if(nodeIsSelected(pointAt3,j)){ + if(nodeIsSelected(pointAt3)){ pointAt2 = SBasisIn.valueAt(weightValue); pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); }else{ @@ -516,34 +496,21 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) }else{ pointAt1 = in->first_segment()->initialPoint(); pointAt2 = in->first_segment()->finalPoint(); - if(nodeIsSelected(pointAt0,j)){ - j++; - } } } } in->reset(); delete in; - //La curva BSpline se forma calculando el centro del segmanto de unión //de el punto situado en las 2/3 partes de el segmento de entrada //con el punto situado en la posición 1/3 del segmento de salida //Estos dos puntos ademas estan posicionados en el lugas correspondiente de //los manejadores de la curva - SPCurve *curveHelper = new SPCurve(); - curveHelper->moveto(pointAt0); - curveHelper->curveto(pointAt1, pointAt2, pointAt3); - //añadimos la curva generada a la curva pricipal - nCurve->append_continuous(curveHelper, 0.0625); - curveHelper->reset(); - delete curveHelper; + nCurve->curveto(pointAt1, pointAt2, pointAt3); //aumentamos los valores para el siguiente paso en el bucle ++curve_it1; ++curve_it2; } - //Aberiguamos la ultima parte de la curva correspondiente al último segmento - //Y hacemos lo propio con el path de salida - //nextPointAt0 = curveOut.valueAt(0); SPCurve * out = new SPCurve(); out->moveto(curve_it1->initialPoint()); out->lineto(curve_it1->finalPoint()); @@ -576,75 +543,60 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) nextPointAt2 = out->first_segment()->finalPoint(); } } - }else{ - if(cubic){ - if((!ignoreCusp || !Geom::are_near((*cubic)[1],out->first_segment()->initialPoint())) && weightValue !=0){ - if(nodeIsSelected(nextPointAt0,j)){ - nextPointAt1 = SBasisOut.valueAt(weightValue); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); - j++; - }else{ - nextPointAt1 = (*cubic)[1]; - } + }else{ + if(cubic){ + if(!ignoreCusp || (!Geom::are_near((*cubic)[1],out->first_segment()->initialPoint()) && weightValue !=0)){ + if(nodeIsSelected(nextPointAt0)){ + nextPointAt1 = SBasisOut.valueAt(weightValue); + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); }else{ - if(nodeIsSelected(nextPointAt0,j)){ - nextPointAt1 = out->first_segment()->initialPoint(); - j++; - }else{ - nextPointAt1 = (*cubic)[1]; - } + nextPointAt1 = (*cubic)[1]; } - if((!ignoreCusp || !Geom::are_near((*cubic)[2],out->first_segment()->finalPoint())) && weightValue !=0){ - if(nodeIsSelected(nextPointAt3,j)){ - nextPointAt2 = SBasisOut.valueAt(1-weightValue); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); - }else{ - nextPointAt2 = (*cubic)[2]; - } + }else{ + nextPointAt1 = out->first_segment()->initialPoint(); + } + if(!ignoreCusp || (!Geom::are_near((*cubic)[2],out->first_segment()->finalPoint()) && weightValue !=0)){ + if(nodeIsSelected(nextPointAt3)){ + nextPointAt2 = SBasisOut.valueAt(1-weightValue); + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); }else{ - if(nodeIsSelected(nextPointAt3,j)){ - nextPointAt2 = out->first_segment()->finalPoint(); - }else{ - nextPointAt2 = (*cubic)[2]; - } - } + nextPointAt2 = (*cubic)[2]; + } }else{ - if(!ignoreCusp && weightValue !=0){ - if(nodeIsSelected(nextPointAt0,j)){ - nextPointAt1 = SBasisOut.valueAt(weightValue); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); - j++; - }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - } - if(nodeIsSelected(nextPointAt3,j)){ - nextPointAt2 = SBasisOut.valueAt(weightValue); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); - }else{ - nextPointAt2 = out->first_segment()->finalPoint(); - } + nextPointAt2 = out->first_segment()->finalPoint(); + } + }else{ + if(!ignoreCusp && weightValue !=0){ + if(nodeIsSelected(nextPointAt0)){ + nextPointAt1 = SBasisOut.valueAt(weightValue); + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); }else{ nextPointAt1 = out->first_segment()->initialPoint(); - if(nodeIsSelected(nextPointAt0,j)) j++; + } + if(nodeIsSelected(nextPointAt3)){ + nextPointAt2 = SBasisOut.valueAt(weightValue); + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); + }else{ nextPointAt2 = out->first_segment()->finalPoint(); } + }else{ + nextPointAt1 = out->first_segment()->initialPoint(); + nextPointAt2 = out->first_segment()->finalPoint(); } } - out->reset(); - delete out; - SPCurve *curveHelper = new SPCurve(); - curveHelper->moveto(pointAt3); + } + out->reset(); + delete out; + //Aberiguamos la ultima parte de la curva correspondiente al último segmento + //Y hacemos lo propio con el path de salida + //nextPointAt0 = curveOut.valueAt(0); if (path_it->closed()) { - curveHelper->curveto(nextPointAt1, nextPointAt2, path_it->begin()->initialPoint()); - nCurve->append_continuous(curveHelper, 0.0625); + nCurve->curveto(nextPointAt1, nextPointAt2, path_it->begin()->initialPoint()); nCurve->move_endpoints(path_it->begin()->initialPoint(),path_it->begin()->initialPoint()); }else{ - curveHelper->curveto(nextPointAt1, nextPointAt2, nextPointAt3); - nCurve->append_continuous(curveHelper, 0.0625); + nCurve->curveto(nextPointAt1, nextPointAt2, nextPointAt3); nCurve->move_endpoints(path_it->begin()->initialPoint(),nextPointAt3); } - curveHelper->reset(); - delete curveHelper; //y cerramos la curva if (path_it->closed()) { nCurve->closepath_current(); diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 2361c10d0..103f09338 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -29,7 +29,7 @@ public: virtual void doBSplineFromWidget(SPCurve * curve, double value); - virtual bool nodeIsSelected(Geom::Point nodePoint, int index); + virtual bool nodeIsSelected(Geom::Point nodePoint); virtual Gtk::Widget * newWidget(); -- cgit v1.2.3 From 458ca2842297a5eae7e4f6fc394b227d61881c8d Mon Sep 17 00:00:00 2001 From: root Date: Wed, 17 Apr 2013 23:03:51 +0200 Subject: Update color lines overlay, with halo of 1 px matched by Gez. Fix some crash snapping. Added new button widget to make cusp node (bzr r11950.1.96) --- src/live_effects/lpe-bspline.cpp | 95 +++++++++++++++++++++++++--------------- src/live_effects/lpe-bspline.h | 2 + 2 files changed, 62 insertions(+), 35 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 37bf24021..cc1b86e72 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -170,7 +170,7 @@ LPEBSpline::doEffect(SPCurve * curve) SBasisOut = out->first_segment()->toSBasis(); nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[1],*out->first_segment())); nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[2],*out->first_segment()));; - nextPointAt3 = (*cubic)[3]; + nextPointAt3 = out->first_segment()->finalPoint(); }else{ nextPointAt1 = out->first_segment()->initialPoint(); nextPointAt2 = out->first_segment()->finalPoint(); @@ -299,19 +299,24 @@ LPEBSpline::newWidget() defaultWeight->signal_clicked().connect(sigc::mem_fun (*this,&LPEBSpline::toDefaultWeight)); Gtk::Widget* defaultWeightWidget = dynamic_cast(defaultWeight); vbox->pack_start(*defaultWeightWidget, true, true,2); + Gtk::Button* makeCusp = Gtk::manage(new Gtk::Button(Glib::ustring(_("Make cusp")))); + makeCusp->set_alignment(0.0, 0.5); + makeCusp->signal_clicked().connect(sigc::mem_fun (*this,&LPEBSpline::toMakeCusp)); + Gtk::Widget* makeCuspWidget = dynamic_cast(makeCusp); + vbox->pack_start(*makeCuspWidget, true, true,2); return dynamic_cast(vbox); } void LPEBSpline::toDefaultWeight(){ - Gtk::Widget * widg = dynamic_cast(param_vector[3]->param_newWidget()); - Inkscape::UI::Widget::Scalar * widgRegistered = Gtk::manage(dynamic_cast(widg)); - widgRegistered->setValue(0.3334); - widgRegistered->update(); - weight.param_set_value(0.3334); changeWeight(0.3334); } +void +LPEBSpline::toMakeCusp(){ + changeWeight(0.0000); +} + void LPEBSpline::toWeight(){ changeWeight(weight); @@ -434,24 +439,32 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) SBasisIn = in->first_segment()->toSBasis(); if(!onlySelected){ if(cubic){ - if(!ignoreCusp || (!Geom::are_near((*cubic)[1],in->first_segment()->initialPoint()) && weightValue !=0)){ + if(!ignoreCusp || !Geom::are_near((*cubic)[1],pointAt0)){ pointAt1 = SBasisIn.valueAt(weightValue); - pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + if(weightValue !=0.0000){ + pointAt1 = Geom::Point(pointAt1[X] + 0.0001,pointAt1[Y] + 0.0001); + } }else{ pointAt1 = in->first_segment()->initialPoint(); } - if((!ignoreCusp || !Geom::are_near((*cubic)[2],in->first_segment()->finalPoint())) && weightValue !=0){ + if(!ignoreCusp || !Geom::are_near((*cubic)[2],pointAt3)){ pointAt2 = SBasisIn.valueAt(1-weightValue); - pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); - }else{ + if(weightValue !=0.0000){ + pointAt2 = Geom::Point(pointAt2[X] + 0.0001,pointAt2[Y] + 0.0001); + } + }else{ pointAt2 = in->first_segment()->finalPoint(); } }else{ - if(!ignoreCusp && weightValue !=0){ + if(!ignoreCusp && weightValue !=0.0000){ pointAt1 = SBasisIn.valueAt(weightValue); - pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + if(weightValue !=0.0000){ + pointAt1 = Geom::Point(pointAt1[X] + 0.0001,pointAt1[Y] + 0.0001); + } pointAt2 = SBasisIn.valueAt(1-weightValue); - pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); + if(weightValue !=0.0000){ + pointAt2 = Geom::Point(pointAt2[X] + 0.0001,pointAt2[Y] + 0.0001); + } }else{ pointAt1 = in->first_segment()->initialPoint(); pointAt2 = in->first_segment()->finalPoint(); @@ -459,20 +472,24 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) } }else{ if(cubic){ - if(!ignoreCusp || (!Geom::are_near((*cubic)[1],in->first_segment()->initialPoint())&& weightValue !=0)){ + if(!ignoreCusp || !Geom::are_near((*cubic)[1],pointAt0)){ if(nodeIsSelected(pointAt0)){ pointAt1 = SBasisIn.valueAt(weightValue); - pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + if(weightValue !=0.0000){ + pointAt1 = Geom::Point(pointAt1[X] + 0.0001,pointAt1[Y] + 0.0001); + } }else{ pointAt1 = (*cubic)[1]; } }else{ pointAt1 = in->first_segment()->initialPoint(); } - if(!ignoreCusp || (!Geom::are_near((*cubic)[2],in->first_segment()->finalPoint()) && weightValue !=0)){ + if(!ignoreCusp || !Geom::are_near((*cubic)[2],pointAt3)){ if(nodeIsSelected(pointAt3)){ pointAt2 = SBasisIn.valueAt(1-weightValue); - pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); + if(weightValue !=0.0000){ + pointAt2 = Geom::Point(pointAt2[X] + 0.0001,pointAt2[Y] + 0.0001); + } }else{ pointAt2 = (*cubic)[2]; } @@ -480,16 +497,16 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) pointAt2 = in->first_segment()->finalPoint(); } }else{ - if(!ignoreCusp && weightValue !=0){ + if(!ignoreCusp && weightValue !=0.000){ if(nodeIsSelected(pointAt0)){ pointAt1 = SBasisIn.valueAt(weightValue); - pointAt1 = Geom::Point(pointAt1[X] + 0.0625,pointAt1[Y] + 0.0625); + pointAt1 = Geom::Point(pointAt1[X] + 0.0001,pointAt1[Y] + 0.0001); }else{ pointAt1 = in->first_segment()->initialPoint(); } if(nodeIsSelected(pointAt3)){ pointAt2 = SBasisIn.valueAt(weightValue); - pointAt2 = Geom::Point(pointAt2[X] + 0.0625,pointAt2[Y] + 0.0625); + pointAt2 = Geom::Point(pointAt2[X] + 0.0001,pointAt2[Y] + 0.0001); }else{ pointAt2 = in->first_segment()->finalPoint(); } @@ -520,24 +537,28 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) cubic = dynamic_cast(&*curve_it1); if(!onlySelected){ if(cubic){ - if((!ignoreCusp || !Geom::are_near((*cubic)[1],out->first_segment()->initialPoint()))&& weightValue !=0){ + if(!ignoreCusp || !Geom::are_near((*cubic)[1],nextPointAt0)){ nextPointAt1 = SBasisOut.valueAt(weightValue); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + if(weightValue !=0.0000){ + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0001,nextPointAt1[Y] + 0.0001); + } }else{ nextPointAt1 = out->first_segment()->initialPoint(); } - if((!ignoreCusp || !Geom::are_near((*cubic)[2],out->first_segment()->finalPoint()))&& weightValue !=0){ + if(!ignoreCusp || !Geom::are_near((*cubic)[2],nextPointAt3)){ nextPointAt2 = SBasisOut.valueAt(1-weightValue); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); + if(weightValue !=0.0000){ + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0001,nextPointAt2[Y] + 0.0001); + } }else{ nextPointAt2 = out->first_segment()->finalPoint(); } }else{ - if(!ignoreCusp && weightValue !=0){ + if(!ignoreCusp && weightValue !=0.0000){ nextPointAt1 = SBasisOut.valueAt(weightValue); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0001,nextPointAt1[Y] + 0.0001); nextPointAt2 = SBasisOut.valueAt(1-weightValue); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0001,nextPointAt2[Y] + 0.0001); }else{ nextPointAt1 = out->first_segment()->initialPoint(); nextPointAt2 = out->first_segment()->finalPoint(); @@ -545,20 +566,24 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) } }else{ if(cubic){ - if(!ignoreCusp || (!Geom::are_near((*cubic)[1],out->first_segment()->initialPoint()) && weightValue !=0)){ + if(!ignoreCusp || !Geom::are_near((*cubic)[1],nextPointAt0)){ if(nodeIsSelected(nextPointAt0)){ nextPointAt1 = SBasisOut.valueAt(weightValue); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + if(weightValue !=0.0000){ + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0001,nextPointAt1[Y] + 0.0001); + } }else{ nextPointAt1 = (*cubic)[1]; } }else{ nextPointAt1 = out->first_segment()->initialPoint(); } - if(!ignoreCusp || (!Geom::are_near((*cubic)[2],out->first_segment()->finalPoint()) && weightValue !=0)){ + if(!ignoreCusp || !Geom::are_near((*cubic)[2],nextPointAt3)){ if(nodeIsSelected(nextPointAt3)){ nextPointAt2 = SBasisOut.valueAt(1-weightValue); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); + if(weightValue !=0.0000){ + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0001,nextPointAt2[Y] + 0.0001); + } }else{ nextPointAt2 = (*cubic)[2]; } @@ -566,16 +591,16 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) nextPointAt2 = out->first_segment()->finalPoint(); } }else{ - if(!ignoreCusp && weightValue !=0){ + if(!ignoreCusp && weightValue !=0.0000){ if(nodeIsSelected(nextPointAt0)){ nextPointAt1 = SBasisOut.valueAt(weightValue); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0625,nextPointAt1[Y] + 0.0625); + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0001,nextPointAt1[Y] + 0.0001); }else{ nextPointAt1 = out->first_segment()->initialPoint(); } if(nodeIsSelected(nextPointAt3)){ nextPointAt2 = SBasisOut.valueAt(weightValue); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0625,nextPointAt2[Y] + 0.0625); + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0001,nextPointAt2[Y] + 0.0001); }else{ nextPointAt2 = out->first_segment()->finalPoint(); } diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 103f09338..510f9c989 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -37,6 +37,8 @@ public: virtual void toDefaultWeight(); + virtual void toMakeCusp(); + virtual void toWeight(); ScalarParam steps; -- cgit v1.2.3 From 9291d4e3a3ad22bef4669b74568ee6d43ba74547 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 18 May 2013 10:38:35 +0200 Subject: Fix error with envelope lpe (bzr r11950.1.117) --- src/live_effects/effect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 8bf8bab6c..b84403495 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -8,7 +8,7 @@ //#define LPE_ENABLE_TEST_EFFECTS #ifdef HAVE_CONFIG_H -#include "config.h" +# include "config.h" #endif // include effects: -- cgit v1.2.3 From 0bd0fa66b7825f0d4e0c9051aa527ba91e415683 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 19 Aug 2013 01:10:42 +0200 Subject: Reverted po files to master branch, now the diff of launchpad is more usable (bzr r11950.1.136) --- src/live_effects/lpe-bspline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index cc1b86e72..c2749e393 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -2,7 +2,7 @@ /* * Released under GNU GPL, read the file 'COPYING' for more information */ - + #include #include #include -- cgit v1.2.3 From 9737c8d04d0ad85bf6a61d36edf7d717419b30f2 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 27 Sep 2013 01:39:44 +0200 Subject: update to trunk (bzr r11950.1.152) --- src/live_effects/lpe-bendpath.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h index 16b8c6137..d3564bac4 100644 --- a/src/live_effects/lpe-bendpath.h +++ b/src/live_effects/lpe-bendpath.h @@ -39,9 +39,9 @@ public: virtual void resetDefaults(SPItem const* item); + PathParam bend_path; private: - PathParam bend_path; ScalarParam prop_scale; BoolParam scale_y_rel; BoolParam vertical_pattern; -- cgit v1.2.3 From f3a885546d1bd971c5bd4a6bbdbaedb59557007d Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 27 Sep 2013 01:42:10 +0200 Subject: error bend lpe (bzr r11950.1.153) --- src/live_effects/lpe-bendpath.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h index d3564bac4..38b1a1446 100644 --- a/src/live_effects/lpe-bendpath.h +++ b/src/live_effects/lpe-bendpath.h @@ -39,9 +39,8 @@ public: virtual void resetDefaults(SPItem const* item); - PathParam bend_path; - private: + PathParam bend_path; ScalarParam prop_scale; BoolParam scale_y_rel; BoolParam vertical_pattern; -- cgit v1.2.3 From cdf6320ab752de234f986031bfdd7dcb8e705e69 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 8 Nov 2013 10:13:22 +0100 Subject: Fixing bugs on update to trunk (bzr r11950.1.194) --- src/live_effects/lpe-bspline.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 84f3fbb33..ef03d8ef0 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -335,7 +335,7 @@ LPEBSpline::changeWeight(double weightValue) gchar *str = sp_svg_write_path(curve->get_pathvector()); path->getRepr()->setAttribute("inkscape:original-d", str); if(INK_IS_NODE_TOOL(desktop->event_context)){ - InkNodeTool *nt = INK_NODE_TOOL(desktop->event_context); + Inkscape::UI::Tools::NodeTool *nt = INK_NODE_TOOL(desktop->event_context); nt->desktop->updateNow(); } g_free(str); @@ -367,7 +367,7 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) using Geom::Y; SPDesktop *desktop = inkscape_active_desktop(); if(INK_IS_NODE_TOOL(desktop->event_context)){ - InkNodeTool *nt = INK_NODE_TOOL(desktop->event_context); + Inkscape::UI::Tools::NodeTool *nt = INK_NODE_TOOL(desktop->event_context); Inkscape::UI::ControlPointSelection::Set &selection = nt->_selected_nodes->allPoints(); points.clear(); std::vector::iterator pbegin; -- cgit v1.2.3 From 3ed9b4ff7ebbae3ba6446d911001688bcbbdc847 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 10 Nov 2013 12:17:23 +0100 Subject: Update to trunk (bzr r11950.1.196) --- src/live_effects/lpe-bspline.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index ef03d8ef0..c19eda8f0 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -17,7 +17,7 @@ #include "live_effects/parameter/parameter.h" #include "ui/widget/scalar.h" #include "ui/tool/node.h" -#include "ui/tool/node-tool.h" +#include "ui/tools/node-tool.h" #include "ui/tool/control-point-selection.h" #include "ui/tool/selectable-control-point.h" #include "selection.h" -- cgit v1.2.3 From 4c6918c72721a35e0347e9e087396238e72eb62e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 30 Dec 2013 20:41:32 +0100 Subject: Refactorizing (bzr r11950.1.212) --- src/live_effects/effect-enum.h | 2 -- src/live_effects/effect.cpp | 6 ------ src/live_effects/lpe-bendpath.h | 1 - 3 files changed, 9 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/effect-enum.h b/src/live_effects/effect-enum.h index cf97dd87f..342a2c849 100644 --- a/src/live_effects/effect-enum.h +++ b/src/live_effects/effect-enum.h @@ -45,9 +45,7 @@ enum EffectType { PATH_LENGTH, LINE_SEGMENT, DOEFFECTSTACK_TEST, - //BSpline BSPLINE, - //BSpline End DYNASTROKE, RECURSIVE_SKELETON, EXTRUDE, diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 3289c239e..29da403e8 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -21,9 +21,7 @@ #include "live_effects/lpe-rough-hatches.h" #include "live_effects/lpe-dynastroke.h" #include "live_effects/lpe-test-doEffect-stack.h" -//BSpline #include "live_effects/lpe-bspline.h" -//BSpline End #include "live_effects/lpe-gears.h" #include "live_effects/lpe-curvestitch.h" #include "live_effects/lpe-circle_with_radius.h" @@ -125,9 +123,7 @@ const Util::EnumData LPETypeData[] = { /* 0.49 */ {POWERSTROKE, N_("Power stroke"), "powerstroke"}, {CLONE_ORIGINAL, N_("Clone original path"), "clone_original"}, - //BSpline {BSPLINE, N_("BSpline"), "bspline"}, - //BSpline End }; const Util::EnumDataConverter LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData)); @@ -236,11 +232,9 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj) case DOEFFECTSTACK_TEST: neweffect = static_cast ( new LPEdoEffectStackTest(lpeobj) ); break; - //BSpline case BSPLINE: neweffect = static_cast ( new LPEBSpline(lpeobj) ); break; - //BSpline End case DYNASTROKE: neweffect = static_cast ( new LPEDynastroke(lpeobj) ); break; diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h index 38b1a1446..554f20413 100644 --- a/src/live_effects/lpe-bendpath.h +++ b/src/live_effects/lpe-bendpath.h @@ -38,7 +38,6 @@ public: virtual Geom::Piecewise > doEffect_pwd2 (Geom::Piecewise > const & pwd2_in); virtual void resetDefaults(SPItem const* item); - private: PathParam bend_path; ScalarParam prop_scale; -- cgit v1.2.3 From df2cf6584407ae3744aac917039681fb3a04a678 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 30 Dec 2013 23:32:51 +0100 Subject: refactor, fixing some diff diferences (bzr r11950.1.219) --- src/live_effects/lpe-bendpath.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h index 554f20413..16b8c6137 100644 --- a/src/live_effects/lpe-bendpath.h +++ b/src/live_effects/lpe-bendpath.h @@ -38,6 +38,8 @@ public: virtual Geom::Piecewise > doEffect_pwd2 (Geom::Piecewise > const & pwd2_in); virtual void resetDefaults(SPItem const* item); + + private: PathParam bend_path; ScalarParam prop_scale; -- cgit v1.2.3 From f7943d80067732ec4a0565077b26b32562a150d3 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 27 Mar 2014 01:31:58 +0100 Subject: Adding cout << output to check bug in Geom::are_near (bzr r11950.1.314) --- src/live_effects/lpe-bspline.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index c19eda8f0..df98f0897 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -39,6 +39,7 @@ #include "inkscape.h" #include "desktop.h" +#include using Inkscape::DocumentUndo; @@ -347,14 +348,24 @@ LPEBSpline::changeWeight(double weightValue) bool LPEBSpline::nodeIsSelected(Geom::Point nodePoint){ + using Geom::X; + using Geom::Y; + std::cout << "\n"; + std::cout << ":: Executed -> nodeIsSelected(Geom::Point nodePoint) ::\n"; + std::cout << "Want to check the argument -nodePoint- is in points vector \n"; + std::cout << "nodePoint::X=" << nodePoint[X] << ";Y=" << nodePoint[Y] << "\n"; + std::cout << "Checking points std::vector\n"; if(points.size() > 0){ - for(std::vector::iterator i = points.begin(); i != points.end();){ - Geom::Point p = static_cast(*i); + for(std::vector::iterator i = points.begin(); i != points.end(); ++i){ + Geom::Point p = *i; + std::cout << "p::X=" << p[X] << ";Y=" << p[Y] << "\n"; + std::cout << "Are near? "; if(Geom::are_near(p, nodePoint)){ + std::cout << "YES\n"; return true; - points.erase(i); + }else{ + std::cout << "NO\n"; } - i++; } } return false; @@ -367,17 +378,21 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) using Geom::Y; SPDesktop *desktop = inkscape_active_desktop(); if(INK_IS_NODE_TOOL(desktop->event_context)){ + std::cout << ":: Start -> doBSplineFromWidget(SPCurve * curve, double weightValue) ::\n"; + std::cout << "Inserting nodes selected into std::vector 'points'\n"; Inkscape::UI::Tools::NodeTool *nt = INK_NODE_TOOL(desktop->event_context); Inkscape::UI::ControlPointSelection::Set &selection = nt->_selected_nodes->allPoints(); points.clear(); std::vector::iterator pbegin; for (Inkscape::UI::ControlPointSelection::Set::iterator i = selection.begin(); i != selection.end(); ++i){ if ((*i)->selected()) { - Inkscape::UI::Node *n = static_cast(*i); + Inkscape::UI::Node *n = dynamic_cast(*i); pbegin = points.begin(); points.insert(pbegin,desktop->doc2dt(n->position())); + std::cout << "inserting point::X=" << desktop->doc2dt(n->position())[X] << ";Y=" << desktop->doc2dt(n->position())[Y] << "\n"; } } + std::cout << "End inserting selected nodes into vector\n"; } //bool hasNodesSelected = LPEBspline::hasNodesSelected(); if(curve->get_segment_count() < 2) @@ -629,6 +644,7 @@ LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) curve->append(nCurve,false); nCurve->reset(); delete nCurve; + std::cout << ":: End ::\n"; } } -- cgit v1.2.3 From 9d5889926c9752867b244e9247843dd012cefdda Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 30 Mar 2014 23:53:17 +0200 Subject: clang-format bspline lpe files (bzr r11950.1.316) --- src/live_effects/lpe-bspline.cpp | 1182 ++++++++++++++++++++------------------ src/live_effects/lpe-bspline.h | 39 +- 2 files changed, 636 insertions(+), 585 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index df98f0897..09e71d833 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -2,7 +2,7 @@ /* * Released under GNU GPL, read the file 'COPYING' for more information */ - + #include #include #include @@ -46,606 +46,658 @@ using Inkscape::DocumentUndo; namespace Inkscape { namespace LivePathEffect { - - -LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) : - Effect(lpeobject), - // initialise your parameters here: - //testpointA(_("Test Point A"), _("Test A"), "ptA", &wr, this, Geom::Point(100,100)), - steps(_("Steps whith CTRL:"), _("Change number of steps whith CTRL pressed"), "steps", &wr, this, 2), - ignoreCusp(_("Ignore cusp nodes:"), _("Change ignoring cusp nodes"), "ignoreCusp", &wr, this, true), - onlySelected(_("Change only selected nodes:"), _("Change only selected nodes"), "onlySelected", &wr, this, false), - weight(_("Change weight:"), _("Change weight of the effect"), "weight", &wr, this, 0.3334) -{ - registerParameter( dynamic_cast(&ignoreCusp) ); - registerParameter( dynamic_cast(&onlySelected) ); - registerParameter( dynamic_cast(&weight) ); - registerParameter( dynamic_cast(&steps) ); - weight.param_set_range(0.0000, 1); - weight.param_set_increments(0.1, 0.1); - weight.param_set_digits(4); - steps.param_set_range(1, 10); - steps.param_set_increments(1, 1); - steps.param_set_digits(0); +LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) + : Effect(lpeobject), + // initialise your parameters here: + //testpointA(_("Test Point A"), _("Test A"), "ptA", &wr, this, + //Geom::Point(100,100)), + steps(_("Steps whith CTRL:"), + _("Change number of steps whith CTRL pressed"), "steps", &wr, this, + 2), + ignoreCusp(_("Ignore cusp nodes:"), _("Change ignoring cusp nodes"), + "ignoreCusp", &wr, this, true), + onlySelected(_("Change only selected nodes:"), + _("Change only selected nodes"), "onlySelected", &wr, this, + false), + weight(_("Change weight:"), _("Change weight of the effect"), "weight", + &wr, this, 0.3334) { + registerParameter(dynamic_cast(&ignoreCusp)); + registerParameter(dynamic_cast(&onlySelected)); + registerParameter(dynamic_cast(&weight)); + registerParameter(dynamic_cast(&steps)); + weight.param_set_range(0.0000, 1); + weight.param_set_increments(0.1, 0.1); + weight.param_set_digits(4); + steps.param_set_range(1, 10); + steps.param_set_increments(1, 1); + steps.param_set_digits(0); } -LPEBSpline::~LPEBSpline() -{ -} +LPEBSpline::~LPEBSpline() {} -void -LPEBSpline::createAndApply(const char* name, SPDocument *doc, SPItem *item) -{ - if (!SP_IS_SHAPE(item)) { - g_warning("LPE BSpline can only be applied to shapes (not groups)."); - }else{ - // Path effect definition - Inkscape::XML::Document *xml_doc = doc->getReprDoc(); - Inkscape::XML::Node *repr = xml_doc->createElement("inkscape:path-effect"); - repr->setAttribute("effect", name); +void LPEBSpline::createAndApply(const char *name, SPDocument *doc, + SPItem *item) { + if (!SP_IS_SHAPE(item)) { + g_warning("LPE BSpline can only be applied to shapes (not groups)."); + } else { + // Path effect definition + Inkscape::XML::Document *xml_doc = doc->getReprDoc(); + Inkscape::XML::Node *repr = xml_doc->createElement("inkscape:path-effect"); + repr->setAttribute("effect", name); - doc->getDefs()->getRepr()->addChild(repr, NULL); // adds to and assigns the 'id' attribute - const gchar * repr_id = repr->attribute("id"); - Inkscape::GC::release(repr); + doc->getDefs()->getRepr() + ->addChild(repr, NULL); // adds to and assigns the 'id' attribute + const gchar *repr_id = repr->attribute("id"); + Inkscape::GC::release(repr); - gchar *href = g_strdup_printf("#%s", repr_id); - SP_LPE_ITEM(item)->addPathEffect( href, true); - g_free(href); - } + gchar *href = g_strdup_printf("#%s", repr_id); + SP_LPE_ITEM(item)->addPathEffect(href, true); + g_free(href); + } } -void -LPEBSpline::doEffect(SPCurve * curve) -{ - if(curve->get_segment_count() < 2) - return; - // Make copy of old path as it is changed during processing - Geom::PathVector const original_pathv = curve->get_pathvector(); - curve->reset(); +void LPEBSpline::doEffect(SPCurve *curve) { + if (curve->get_segment_count() < 2) + return; + // Make copy of old path as it is changed during processing + Geom::PathVector const original_pathv = curve->get_pathvector(); + curve->reset(); - //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo - for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { - //Si está vacío... - if (path_it->empty()) - continue; - //Itreadores - - Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve - Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve - Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop - //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán - //los puntos clave para los manejadores. - //Esto hace que la curva BSpline no pierda su condición aunque se trasladen - //dichos manejadores - SPCurve *nCurve = new SPCurve(); - Geom::Point previousNode(0,0); - Geom::Point node(0,0); - Geom::Point pointAt1(0,0); - Geom::Point pointAt2(0,0); - Geom::Point nextPointAt1(0,0); - Geom::Point nextPointAt2(0,0); - Geom::Point nextPointAt3(0,0); - Geom::D2< Geom::SBasis > SBasisIn; - Geom::D2< Geom::SBasis > SBasisOut; - Geom::D2< Geom::SBasis > SBasisHelper; - Geom::CubicBezier const *cubic = NULL; - if (path_it->closed()) { - // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. - const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. - if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - // closingline.isDegenerate() did not work, because it only checks for *exact* zero length, which goes wrong for relative coordinates and rounding errors... - // the closing line segment has zero-length. So stop before that one! - curve_endit = path_it->end_open(); - } - } - //Si la curva está cerrada calculamos el punto donde - //deveria estar el nodo BSpline de cierre/inicio de la curva - //en posible caso de que se cierre con una linea recta creando un nodo BSPline - nCurve->moveto(curve_it1->initialPoint()); - //Recorremos todos los segmentos menos el último - while ( curve_it2 != curve_endit ) - { - //previousPointAt3 = pointAt3; - //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida - SPCurve * in = new SPCurve(); - in->moveto(curve_it1->initialPoint()); - in->lineto(curve_it1->finalPoint()); - cubic = dynamic_cast(&*curve_it1); - if(cubic){ - SBasisIn = in->first_segment()->toSBasis(); - pointAt1 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[1],*in->first_segment())); - pointAt2 = SBasisIn.valueAt(Geom::nearest_point((*cubic)[2],*in->first_segment())); - }else{ - pointAt1 = in->first_segment()->initialPoint(); - pointAt2 = in->first_segment()->finalPoint(); - } - in->reset(); - delete in; - //Y hacemos lo propio con el path de salida - //nextPointAt0 = curveOut.valueAt(0); - SPCurve * out = new SPCurve(); - out->moveto(curve_it2->initialPoint()); - out->lineto(curve_it2->finalPoint()); - cubic = dynamic_cast(&*curve_it2); - if(cubic){ - SBasisOut = out->first_segment()->toSBasis(); - nextPointAt1 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[1],*out->first_segment())); - nextPointAt2 = SBasisOut.valueAt(Geom::nearest_point((*cubic)[2],*out->first_segment()));; - nextPointAt3 = out->first_segment()->finalPoint(); - }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - nextPointAt2 = out->first_segment()->finalPoint(); - nextPointAt3 = out->first_segment()->finalPoint(); - } - out->reset(); - delete out; - //La curva BSpline se forma calculando el centro del segmanto de unión - //de el punto situado en las 2/3 partes de el segmento de entrada - //con el punto situado en la posición 1/3 del segmento de salida - //Estos dos puntos ademas estan posicionados en el lugas correspondiente de - //los manejadores de la curva - SPCurve *lineHelper = new SPCurve(); - lineHelper->moveto(pointAt2); - lineHelper->lineto(nextPointAt1); - SBasisHelper = lineHelper->first_segment()->toSBasis(); - lineHelper->reset(); - delete lineHelper; - //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de principio de curva - previousNode = node; - //Y este hará de final de curva - node = SBasisHelper.valueAt(0.5); - nCurve->curveto(pointAt1, pointAt2, node); - //aumentamos los valores para el siguiente paso en el bucle - ++curve_it1; - ++curve_it2; - } - //Si está cerrada la curva, la cerramos sobre el valor guardado previamente - //Si no finalizamos en el punto final - Geom::Point startNode(0,0); - if (path_it->closed()) { - SPCurve * start = new SPCurve(); - start->moveto(path_it->begin()->initialPoint()); - start->lineto(path_it->begin()->finalPoint()); - Geom::D2< Geom::SBasis > SBasisStart = start->first_segment()->toSBasis(); - SPCurve *lineHelper = new SPCurve(); - cubic = dynamic_cast(&*path_it->begin()); - if(cubic){ - lineHelper->moveto(SBasisStart.valueAt(Geom::nearest_point((*cubic)[1],*start->first_segment()))); - }else{ - lineHelper->moveto(start->first_segment()->initialPoint()); - } - start->reset(); - delete start; + //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el + //penúltimo + for (Geom::PathVector::const_iterator path_it = original_pathv.begin(); + path_it != original_pathv.end(); ++path_it) { + //Si está vacío... + if (path_it->empty()) + continue; + //Itreadores - SPCurve * end = new SPCurve(); - end->moveto(curve_it1->initialPoint()); - end->lineto(curve_it1->finalPoint()); - Geom::D2< Geom::SBasis > SBasisEnd = end->first_segment()->toSBasis(); - //Geom::BezierCurve const *bezier = dynamic_cast(&*curve_endit); - cubic = dynamic_cast(&*curve_it1); - if(cubic){ - lineHelper->lineto(SBasisEnd.valueAt(Geom::nearest_point((*cubic)[2],*end->first_segment()))); - }else{ - lineHelper->lineto(end->first_segment()->finalPoint()); - } - end->reset(); - delete end; - SBasisHelper = lineHelper->first_segment()->toSBasis(); - lineHelper->reset(); - delete lineHelper; - startNode = SBasisHelper.valueAt(0.5); - nCurve->curveto(nextPointAt1, nextPointAt2, startNode); - nCurve->move_endpoints(startNode,startNode); - }else{ - SPCurve * start = new SPCurve(); - start->moveto(path_it->begin()->initialPoint()); - start->lineto(path_it->begin()->finalPoint()); - startNode = start->first_segment()->initialPoint(); - start->reset(); - delete start; - nCurve->curveto(nextPointAt1, nextPointAt2, nextPointAt3); - nCurve->move_endpoints(startNode,nextPointAt3); - } - //y cerramos la curva - if (path_it->closed()) { - nCurve->closepath_current(); - } - curve->append(nCurve,false); - nCurve->reset(); - delete nCurve; + Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve + Geom::Path::const_iterator curve_it2 = + ++(path_it->begin()); // outgoing curve + Geom::Path::const_iterator curve_endit = + path_it->end_default(); // this determines when the loop has to stop + //Creamos las lineas rectas que unen todos los puntos del trazado y donde se + //calcularán + //los puntos clave para los manejadores. + //Esto hace que la curva BSpline no pierda su condición aunque se trasladen + //dichos manejadores + SPCurve *nCurve = new SPCurve(); + Geom::Point previousNode(0, 0); + Geom::Point node(0, 0); + Geom::Point pointAt1(0, 0); + Geom::Point pointAt2(0, 0); + Geom::Point nextPointAt1(0, 0); + Geom::Point nextPointAt2(0, 0); + Geom::Point nextPointAt3(0, 0); + Geom::D2 SBasisIn; + Geom::D2 SBasisOut; + Geom::D2 SBasisHelper; + Geom::CubicBezier const *cubic = NULL; + if (path_it->closed()) { + // if the path is closed, maybe we have to stop a bit earlier because the + // closing line segment has zerolength. + const Geom::Curve &closingline = + path_it->back_closed(); // the closing line segment is always of type + // Geom::LineSegment. + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + // closingline.isDegenerate() did not work, because it only checks for + // *exact* zero length, which goes wrong for relative coordinates and + // rounding errors... + // the closing line segment has zero-length. So stop before that one! + curve_endit = path_it->end_open(); + } + } + //Si la curva está cerrada calculamos el punto donde + //deveria estar el nodo BSpline de cierre/inicio de la curva + //en posible caso de que se cierre con una linea recta creando un nodo + //BSPline + nCurve->moveto(curve_it1->initialPoint()); + //Recorremos todos los segmentos menos el último + while (curve_it2 != curve_endit) { + //previousPointAt3 = pointAt3; + //Calculamos los puntos que dividirían en tres segmentos iguales el path + //recto de entrada y de salida + SPCurve *in = new SPCurve(); + in->moveto(curve_it1->initialPoint()); + in->lineto(curve_it1->finalPoint()); + cubic = dynamic_cast(&*curve_it1); + if (cubic) { + SBasisIn = in->first_segment()->toSBasis(); + pointAt1 = SBasisIn.valueAt( + Geom::nearest_point((*cubic)[1], *in->first_segment())); + pointAt2 = SBasisIn.valueAt( + Geom::nearest_point((*cubic)[2], *in->first_segment())); + } else { + pointAt1 = in->first_segment()->initialPoint(); + pointAt2 = in->first_segment()->finalPoint(); + } + in->reset(); + delete in; + //Y hacemos lo propio con el path de salida + //nextPointAt0 = curveOut.valueAt(0); + SPCurve *out = new SPCurve(); + out->moveto(curve_it2->initialPoint()); + out->lineto(curve_it2->finalPoint()); + cubic = dynamic_cast(&*curve_it2); + if (cubic) { + SBasisOut = out->first_segment()->toSBasis(); + nextPointAt1 = SBasisOut.valueAt( + Geom::nearest_point((*cubic)[1], *out->first_segment())); + nextPointAt2 = SBasisOut.valueAt( + Geom::nearest_point((*cubic)[2], *out->first_segment())); + ; + nextPointAt3 = out->first_segment()->finalPoint(); + } else { + nextPointAt1 = out->first_segment()->initialPoint(); + nextPointAt2 = out->first_segment()->finalPoint(); + nextPointAt3 = out->first_segment()->finalPoint(); + } + out->reset(); + delete out; + //La curva BSpline se forma calculando el centro del segmanto de unión + //de el punto situado en las 2/3 partes de el segmento de entrada + //con el punto situado en la posición 1/3 del segmento de salida + //Estos dos puntos ademas estan posicionados en el lugas correspondiente + //de + //los manejadores de la curva + SPCurve *lineHelper = new SPCurve(); + lineHelper->moveto(pointAt2); + lineHelper->lineto(nextPointAt1); + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + delete lineHelper; + //almacenamos el punto del anterior bucle -o el de cierre- que nos hara de + //principio de curva + previousNode = node; + //Y este hará de final de curva + node = SBasisHelper.valueAt(0.5); + nCurve->curveto(pointAt1, pointAt2, node); + //aumentamos los valores para el siguiente paso en el bucle + ++curve_it1; + ++curve_it2; + } + //Si está cerrada la curva, la cerramos sobre el valor guardado + //previamente + //Si no finalizamos en el punto final + Geom::Point startNode(0, 0); + if (path_it->closed()) { + SPCurve *start = new SPCurve(); + start->moveto(path_it->begin()->initialPoint()); + start->lineto(path_it->begin()->finalPoint()); + Geom::D2 SBasisStart = start->first_segment()->toSBasis(); + SPCurve *lineHelper = new SPCurve(); + cubic = dynamic_cast(&*path_it->begin()); + if (cubic) { + lineHelper->moveto(SBasisStart.valueAt( + Geom::nearest_point((*cubic)[1], *start->first_segment()))); + } else { + lineHelper->moveto(start->first_segment()->initialPoint()); + } + start->reset(); + delete start; + + SPCurve *end = new SPCurve(); + end->moveto(curve_it1->initialPoint()); + end->lineto(curve_it1->finalPoint()); + Geom::D2 SBasisEnd = end->first_segment()->toSBasis(); + //Geom::BezierCurve const *bezier = dynamic_cast(&*curve_endit); + cubic = dynamic_cast(&*curve_it1); + if (cubic) { + lineHelper->lineto(SBasisEnd.valueAt( + Geom::nearest_point((*cubic)[2], *end->first_segment()))); + } else { + lineHelper->lineto(end->first_segment()->finalPoint()); + } + end->reset(); + delete end; + SBasisHelper = lineHelper->first_segment()->toSBasis(); + lineHelper->reset(); + delete lineHelper; + startNode = SBasisHelper.valueAt(0.5); + nCurve->curveto(nextPointAt1, nextPointAt2, startNode); + nCurve->move_endpoints(startNode, startNode); + } else { + SPCurve *start = new SPCurve(); + start->moveto(path_it->begin()->initialPoint()); + start->lineto(path_it->begin()->finalPoint()); + startNode = start->first_segment()->initialPoint(); + start->reset(); + delete start; + nCurve->curveto(nextPointAt1, nextPointAt2, nextPointAt3); + nCurve->move_endpoints(startNode, nextPointAt3); } + //y cerramos la curva + if (path_it->closed()) { + nCurve->closepath_current(); + } + curve->append(nCurve, false); + nCurve->reset(); + delete nCurve; + } } -Gtk::Widget * -LPEBSpline::newWidget() -{ - // use manage here, because after deletion of Effect object, others might still be pointing to this widget. - Gtk::VBox * vbox = Gtk::manage( new Gtk::VBox(Effect::newWidget()) ); +Gtk::Widget *LPEBSpline::newWidget() { + // use manage here, because after deletion of Effect object, others might + // still be pointing to this widget. + Gtk::VBox *vbox = Gtk::manage(new Gtk::VBox(Effect::newWidget())); - vbox->set_border_width(5); - std::vector::iterator it = param_vector.begin(); - while (it != param_vector.end()) { - if ((*it)->widget_is_visible) { - Parameter * param = *it; - Gtk::Widget * widg = dynamic_cast(param->param_newWidget()); - if(param->param_key == "weight"||param->param_key == "steps"){ - Inkscape::UI::Widget::Scalar * widgRegistered = Gtk::manage(dynamic_cast(widg)); - widgRegistered->signal_value_changed().connect(sigc::mem_fun (*this,&LPEBSpline::toWeight)); - widg = dynamic_cast(widgRegistered); - } - if(param->param_key == "onlySelected"){ - Gtk::CheckButton * widgRegistered = Gtk::manage(dynamic_cast(widg)); - widg = dynamic_cast(widgRegistered); - } - if(param->param_key == "ignoreCusp"){ - Gtk::CheckButton * widgRegistered = Gtk::manage(dynamic_cast(widg)); - widg = dynamic_cast(widgRegistered); - } - Glib::ustring * tip = param->param_getTooltip(); - if (widg) { - vbox->pack_start(*widg, true, true, 2); - if (tip) { - widg->set_tooltip_text(*tip); - } else { - widg->set_tooltip_text(""); - widg->set_has_tooltip(false); - } - } + vbox->set_border_width(5); + std::vector::iterator it = param_vector.begin(); + while (it != param_vector.end()) { + if ((*it)->widget_is_visible) { + Parameter *param = *it; + Gtk::Widget *widg = dynamic_cast(param->param_newWidget()); + if (param->param_key == "weight" || param->param_key == "steps") { + Inkscape::UI::Widget::Scalar *widgRegistered = + Gtk::manage(dynamic_cast(widg)); + widgRegistered->signal_value_changed() + .connect(sigc::mem_fun(*this, &LPEBSpline::toWeight)); + widg = dynamic_cast(widgRegistered); + } + if (param->param_key == "onlySelected") { + Gtk::CheckButton *widgRegistered = + Gtk::manage(dynamic_cast(widg)); + widg = dynamic_cast(widgRegistered); + } + if (param->param_key == "ignoreCusp") { + Gtk::CheckButton *widgRegistered = + Gtk::manage(dynamic_cast(widg)); + widg = dynamic_cast(widgRegistered); + } + Glib::ustring *tip = param->param_getTooltip(); + if (widg) { + vbox->pack_start(*widg, true, true, 2); + if (tip) { + widg->set_tooltip_text(*tip); + } else { + widg->set_tooltip_text(""); + widg->set_has_tooltip(false); } - - ++it; + } } - Gtk::Button* defaultWeight = Gtk::manage(new Gtk::Button(Glib::ustring(_("Default weight 0.3334")))); - defaultWeight->set_alignment(0.0, 0.5); - defaultWeight->signal_clicked().connect(sigc::mem_fun (*this,&LPEBSpline::toDefaultWeight)); - Gtk::Widget* defaultWeightWidget = dynamic_cast(defaultWeight); - vbox->pack_start(*defaultWeightWidget, true, true,2); - Gtk::Button* makeCusp = Gtk::manage(new Gtk::Button(Glib::ustring(_("Make cusp")))); - makeCusp->set_alignment(0.0, 0.5); - makeCusp->signal_clicked().connect(sigc::mem_fun (*this,&LPEBSpline::toMakeCusp)); - Gtk::Widget* makeCuspWidget = dynamic_cast(makeCusp); - vbox->pack_start(*makeCuspWidget, true, true,2); - return dynamic_cast(vbox); -} -void -LPEBSpline::toDefaultWeight(){ - changeWeight(0.3334); + ++it; + } + Gtk::Button *defaultWeight = + Gtk::manage(new Gtk::Button(Glib::ustring(_("Default weight 0.3334")))); + defaultWeight->set_alignment(0.0, 0.5); + defaultWeight->signal_clicked() + .connect(sigc::mem_fun(*this, &LPEBSpline::toDefaultWeight)); + Gtk::Widget *defaultWeightWidget = dynamic_cast(defaultWeight); + vbox->pack_start(*defaultWeightWidget, true, true, 2); + Gtk::Button *makeCusp = + Gtk::manage(new Gtk::Button(Glib::ustring(_("Make cusp")))); + makeCusp->set_alignment(0.0, 0.5); + makeCusp->signal_clicked() + .connect(sigc::mem_fun(*this, &LPEBSpline::toMakeCusp)); + Gtk::Widget *makeCuspWidget = dynamic_cast(makeCusp); + vbox->pack_start(*makeCuspWidget, true, true, 2); + return dynamic_cast(vbox); } -void -LPEBSpline::toMakeCusp(){ - changeWeight(0.0000); -} +void LPEBSpline::toDefaultWeight() { changeWeight(0.3334); } -void -LPEBSpline::toWeight(){ - changeWeight(weight); -} +void LPEBSpline::toMakeCusp() { changeWeight(0.0000); } -void -LPEBSpline::changeWeight(double weightValue) -{ - SPDesktop *desktop = inkscape_active_desktop(); - Inkscape::Selection *selection = sp_desktop_selection(desktop); - GSList *items = (GSList *) selection->itemList(); - SPItem *item = (SPItem *)g_slist_nth(items,0)->data; - SPPath *path = SP_PATH(item); - SPCurve *curve = path->get_curve_for_edit(); - LPEBSpline::doBSplineFromWidget(curve,weightValue); - gchar *str = sp_svg_write_path(curve->get_pathvector()); - path->getRepr()->setAttribute("inkscape:original-d", str); - if(INK_IS_NODE_TOOL(desktop->event_context)){ - Inkscape::UI::Tools::NodeTool *nt = INK_NODE_TOOL(desktop->event_context); - nt->desktop->updateNow(); - } - g_free(str); - curve->unref(); - desktop->clearWaitingCursor(); - DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_LPE, - _("Modified the weight of the BSpline")); +void LPEBSpline::toWeight() { changeWeight(weight); } + +void LPEBSpline::changeWeight(double weightValue) { + SPDesktop *desktop = inkscape_active_desktop(); + Inkscape::Selection *selection = sp_desktop_selection(desktop); + GSList *items = (GSList *)selection->itemList(); + SPItem *item = (SPItem *)g_slist_nth(items, 0)->data; + SPPath *path = SP_PATH(item); + SPCurve *curve = path->get_curve_for_edit(); + LPEBSpline::doBSplineFromWidget(curve, weightValue); + gchar *str = sp_svg_write_path(curve->get_pathvector()); + path->getRepr()->setAttribute("inkscape:original-d", str); + if (INK_IS_NODE_TOOL(desktop->event_context)) { + Inkscape::UI::Tools::NodeTool *nt = INK_NODE_TOOL(desktop->event_context); + nt->desktop->updateNow(); + } + g_free(str); + curve->unref(); + desktop->clearWaitingCursor(); + DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_LPE, + _("Modified the weight of the BSpline")); } -bool -LPEBSpline::nodeIsSelected(Geom::Point nodePoint){ - using Geom::X; - using Geom::Y; - std::cout << "\n"; - std::cout << ":: Executed -> nodeIsSelected(Geom::Point nodePoint) ::\n"; - std::cout << "Want to check the argument -nodePoint- is in points vector \n"; - std::cout << "nodePoint::X=" << nodePoint[X] << ";Y=" << nodePoint[Y] << "\n"; - std::cout << "Checking points std::vector\n"; - if(points.size() > 0){ - for(std::vector::iterator i = points.begin(); i != points.end(); ++i){ - Geom::Point p = *i; - std::cout << "p::X=" << p[X] << ";Y=" << p[Y] << "\n"; - std::cout << "Are near? "; - if(Geom::are_near(p, nodePoint)){ - std::cout << "YES\n"; - return true; - }else{ - std::cout << "NO\n"; - } - } +bool LPEBSpline::nodeIsSelected(Geom::Point nodePoint) { + using Geom::X; + using Geom::Y; + std::cout << "\n"; + std::cout << ":: Executed -> nodeIsSelected(Geom::Point nodePoint) ::\n"; + std::cout << "Want to check the argument -nodePoint- is in points vector \n"; + std::cout << "nodePoint::X=" << nodePoint[X] << ";Y=" << nodePoint[Y] << "\n"; + std::cout << "Checking points std::vector\n"; + if (points.size() > 0) { + for (std::vector::iterator i = points.begin(); + i != points.end(); ++i) { + Geom::Point p = *i; + std::cout << "p::X=" << p[X] << ";Y=" << p[Y] << "\n"; + std::cout << "Are near? "; + if (Geom::are_near(p, nodePoint)) { + std::cout << "YES\n"; + return true; + } else { + std::cout << "NO\n"; + } } - return false; + } + return false; } -void -LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue) -{ - using Geom::X; - using Geom::Y; - SPDesktop *desktop = inkscape_active_desktop(); - if(INK_IS_NODE_TOOL(desktop->event_context)){ - std::cout << ":: Start -> doBSplineFromWidget(SPCurve * curve, double weightValue) ::\n"; - std::cout << "Inserting nodes selected into std::vector 'points'\n"; - Inkscape::UI::Tools::NodeTool *nt = INK_NODE_TOOL(desktop->event_context); - Inkscape::UI::ControlPointSelection::Set &selection = nt->_selected_nodes->allPoints(); - points.clear(); - std::vector::iterator pbegin; - for (Inkscape::UI::ControlPointSelection::Set::iterator i = selection.begin(); i != selection.end(); ++i){ - if ((*i)->selected()) { - Inkscape::UI::Node *n = dynamic_cast(*i); - pbegin = points.begin(); - points.insert(pbegin,desktop->doc2dt(n->position())); - std::cout << "inserting point::X=" << desktop->doc2dt(n->position())[X] << ";Y=" << desktop->doc2dt(n->position())[Y] << "\n"; - } - } - std::cout << "End inserting selected nodes into vector\n"; +void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weightValue) { + using Geom::X; + using Geom::Y; + SPDesktop *desktop = inkscape_active_desktop(); + if (INK_IS_NODE_TOOL(desktop->event_context)) { + std::cout << ":: Start -> doBSplineFromWidget(SPCurve * curve, double " + "weightValue) ::\n"; + std::cout << "Inserting nodes selected into std::vector 'points'\n"; + Inkscape::UI::Tools::NodeTool *nt = INK_NODE_TOOL(desktop->event_context); + Inkscape::UI::ControlPointSelection::Set &selection = + nt->_selected_nodes->allPoints(); + points.clear(); + std::vector::iterator pbegin; + for (Inkscape::UI::ControlPointSelection::Set::iterator i = + selection.begin(); + i != selection.end(); ++i) { + if ((*i)->selected()) { + Inkscape::UI::Node *n = dynamic_cast(*i); + pbegin = points.begin(); + points.insert(pbegin, desktop->doc2dt(n->position())); + std::cout << "inserting point::X=" << desktop->doc2dt(n->position())[X] + << ";Y=" << desktop->doc2dt(n->position())[Y] << "\n"; + } } - //bool hasNodesSelected = LPEBspline::hasNodesSelected(); - if(curve->get_segment_count() < 2) - return; - // Make copy of old path as it is changed during processing - Geom::PathVector const original_pathv = curve->get_pathvector(); - curve->reset(); + std::cout << "End inserting selected nodes into vector\n"; + } + //bool hasNodesSelected = LPEBspline::hasNodesSelected(); + if (curve->get_segment_count() < 2) + return; + // Make copy of old path as it is changed during processing + Geom::PathVector const original_pathv = curve->get_pathvector(); + curve->reset(); + + //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el + //penúltimo + for (Geom::PathVector::const_iterator path_it = original_pathv.begin(); + path_it != original_pathv.end(); ++path_it) { + //Si está vacío... + if (path_it->empty()) + continue; + //Itreadores - //Recorremos todos los paths a los que queremos aplicar el efecto, hasta el penúltimo - for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { - //Si está vacío... - if (path_it->empty()) - continue; - //Itreadores - - Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve - Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve - Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop - //Creamos las lineas rectas que unen todos los puntos del trazado y donde se calcularán - //los puntos clave para los manejadores. - //Esto hace que la curva BSpline no pierda su condición aunque se trasladen - //dichos manejadores - SPCurve *nCurve = new SPCurve(); - Geom::Point pointAt0(0,0); - Geom::Point pointAt1(0,0); - Geom::Point pointAt2(0,0); - Geom::Point pointAt3(0,0); - Geom::Point nextPointAt0(0,0); - Geom::Point nextPointAt1(0,0); - Geom::Point nextPointAt2(0,0); - Geom::Point nextPointAt3(0,0); - Geom::D2< Geom::SBasis > SBasisIn; - Geom::D2< Geom::SBasis > SBasisOut; - Geom::CubicBezier const *cubic = NULL; - if (path_it->closed()) { - // if the path is closed, maybe we have to stop a bit earlier because the closing line segment has zerolength. - const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment. - if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - // closingline.isDegenerate() did not work, because it only checks for *exact* zero length, which goes wrong for relative coordinates and rounding errors... - // the closing line segment has zero-length. So stop before that one! - curve_endit = path_it->end_open(); + Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve + Geom::Path::const_iterator curve_it2 = + ++(path_it->begin()); // outgoing curve + Geom::Path::const_iterator curve_endit = + path_it->end_default(); // this determines when the loop has to stop + //Creamos las lineas rectas que unen todos los puntos del trazado y donde se + //calcularán + //los puntos clave para los manejadores. + //Esto hace que la curva BSpline no pierda su condición aunque se trasladen + //dichos manejadores + SPCurve *nCurve = new SPCurve(); + Geom::Point pointAt0(0, 0); + Geom::Point pointAt1(0, 0); + Geom::Point pointAt2(0, 0); + Geom::Point pointAt3(0, 0); + Geom::Point nextPointAt0(0, 0); + Geom::Point nextPointAt1(0, 0); + Geom::Point nextPointAt2(0, 0); + Geom::Point nextPointAt3(0, 0); + Geom::D2 SBasisIn; + Geom::D2 SBasisOut; + Geom::CubicBezier const *cubic = NULL; + if (path_it->closed()) { + // if the path is closed, maybe we have to stop a bit earlier because the + // closing line segment has zerolength. + const Geom::Curve &closingline = + path_it->back_closed(); // the closing line segment is always of type + // Geom::LineSegment. + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + // closingline.isDegenerate() did not work, because it only checks for + // *exact* zero length, which goes wrong for relative coordinates and + // rounding errors... + // the closing line segment has zero-length. So stop before that one! + curve_endit = path_it->end_open(); + } + } + //Si la curva está cerrada calculamos el punto donde + //deveria estar el nodo BSpline de cierre/inicio de la curva + //en posible caso de que se cierre con una linea recta creando un nodo + //BSPline + nCurve->moveto(curve_it1->initialPoint()); + //Recorremos todos los segmentos menos el último + while (curve_it2 != curve_endit) { + //previousPointAt3 = pointAt3; + //Calculamos los puntos que dividirían en tres segmentos iguales el path + //recto de entrada y de salida + SPCurve *in = new SPCurve(); + in->moveto(curve_it1->initialPoint()); + in->lineto(curve_it1->finalPoint()); + cubic = dynamic_cast(&*curve_it1); + pointAt0 = in->first_segment()->initialPoint(); + pointAt3 = in->first_segment()->finalPoint(); + SBasisIn = in->first_segment()->toSBasis(); + if (!onlySelected) { + if (cubic) { + if (!ignoreCusp || !Geom::are_near((*cubic)[1], pointAt0)) { + pointAt1 = SBasisIn.valueAt(weightValue); + if (weightValue != 0.0000) { + pointAt1 = + Geom::Point(pointAt1[X] + 0.0001, pointAt1[Y] + 0.0001); + } + } else { + pointAt1 = in->first_segment()->initialPoint(); + } + if (!ignoreCusp || !Geom::are_near((*cubic)[2], pointAt3)) { + pointAt2 = SBasisIn.valueAt(1 - weightValue); + if (weightValue != 0.0000) { + pointAt2 = + Geom::Point(pointAt2[X] + 0.0001, pointAt2[Y] + 0.0001); + } + } else { + pointAt2 = in->first_segment()->finalPoint(); + } + } else { + if (!ignoreCusp && weightValue != 0.0000) { + pointAt1 = SBasisIn.valueAt(weightValue); + if (weightValue != 0.0000) { + pointAt1 = + Geom::Point(pointAt1[X] + 0.0001, pointAt1[Y] + 0.0001); + } + pointAt2 = SBasisIn.valueAt(1 - weightValue); + if (weightValue != 0.0000) { + pointAt2 = + Geom::Point(pointAt2[X] + 0.0001, pointAt2[Y] + 0.0001); } + } else { + pointAt1 = in->first_segment()->initialPoint(); + pointAt2 = in->first_segment()->finalPoint(); + } } - //Si la curva está cerrada calculamos el punto donde - //deveria estar el nodo BSpline de cierre/inicio de la curva - //en posible caso de que se cierre con una linea recta creando un nodo BSPline - nCurve->moveto(curve_it1->initialPoint()); - //Recorremos todos los segmentos menos el último - while ( curve_it2 != curve_endit ) - { - //previousPointAt3 = pointAt3; - //Calculamos los puntos que dividirían en tres segmentos iguales el path recto de entrada y de salida - SPCurve * in = new SPCurve(); - in->moveto(curve_it1->initialPoint()); - in->lineto(curve_it1->finalPoint()); - cubic = dynamic_cast(&*curve_it1); - pointAt0 = in->first_segment()->initialPoint(); - pointAt3 = in->first_segment()->finalPoint(); - SBasisIn = in->first_segment()->toSBasis(); - if(!onlySelected){ - if(cubic){ - if(!ignoreCusp || !Geom::are_near((*cubic)[1],pointAt0)){ - pointAt1 = SBasisIn.valueAt(weightValue); - if(weightValue !=0.0000){ - pointAt1 = Geom::Point(pointAt1[X] + 0.0001,pointAt1[Y] + 0.0001); - } - }else{ - pointAt1 = in->first_segment()->initialPoint(); - } - if(!ignoreCusp || !Geom::are_near((*cubic)[2],pointAt3)){ - pointAt2 = SBasisIn.valueAt(1-weightValue); - if(weightValue !=0.0000){ - pointAt2 = Geom::Point(pointAt2[X] + 0.0001,pointAt2[Y] + 0.0001); - } - }else{ - pointAt2 = in->first_segment()->finalPoint(); - } - }else{ - if(!ignoreCusp && weightValue !=0.0000){ - pointAt1 = SBasisIn.valueAt(weightValue); - if(weightValue !=0.0000){ - pointAt1 = Geom::Point(pointAt1[X] + 0.0001,pointAt1[Y] + 0.0001); - } - pointAt2 = SBasisIn.valueAt(1-weightValue); - if(weightValue !=0.0000){ - pointAt2 = Geom::Point(pointAt2[X] + 0.0001,pointAt2[Y] + 0.0001); - } - }else{ - pointAt1 = in->first_segment()->initialPoint(); - pointAt2 = in->first_segment()->finalPoint(); - } - } - }else{ - if(cubic){ - if(!ignoreCusp || !Geom::are_near((*cubic)[1],pointAt0)){ - if(nodeIsSelected(pointAt0)){ - pointAt1 = SBasisIn.valueAt(weightValue); - if(weightValue !=0.0000){ - pointAt1 = Geom::Point(pointAt1[X] + 0.0001,pointAt1[Y] + 0.0001); - } - }else{ - pointAt1 = (*cubic)[1]; - } - }else{ - pointAt1 = in->first_segment()->initialPoint(); - } - if(!ignoreCusp || !Geom::are_near((*cubic)[2],pointAt3)){ - if(nodeIsSelected(pointAt3)){ - pointAt2 = SBasisIn.valueAt(1-weightValue); - if(weightValue !=0.0000){ - pointAt2 = Geom::Point(pointAt2[X] + 0.0001,pointAt2[Y] + 0.0001); - } - }else{ - pointAt2 = (*cubic)[2]; - } - }else{ - pointAt2 = in->first_segment()->finalPoint(); - } - }else{ - if(!ignoreCusp && weightValue !=0.000){ - if(nodeIsSelected(pointAt0)){ - pointAt1 = SBasisIn.valueAt(weightValue); - pointAt1 = Geom::Point(pointAt1[X] + 0.0001,pointAt1[Y] + 0.0001); - }else{ - pointAt1 = in->first_segment()->initialPoint(); - } - if(nodeIsSelected(pointAt3)){ - pointAt2 = SBasisIn.valueAt(weightValue); - pointAt2 = Geom::Point(pointAt2[X] + 0.0001,pointAt2[Y] + 0.0001); - }else{ - pointAt2 = in->first_segment()->finalPoint(); - } - }else{ - pointAt1 = in->first_segment()->initialPoint(); - pointAt2 = in->first_segment()->finalPoint(); - } - } + } else { + if (cubic) { + if (!ignoreCusp || !Geom::are_near((*cubic)[1], pointAt0)) { + if (nodeIsSelected(pointAt0)) { + pointAt1 = SBasisIn.valueAt(weightValue); + if (weightValue != 0.0000) { + pointAt1 = + Geom::Point(pointAt1[X] + 0.0001, pointAt1[Y] + 0.0001); + } + } else { + pointAt1 = (*cubic)[1]; } - in->reset(); - delete in; - //La curva BSpline se forma calculando el centro del segmanto de unión - //de el punto situado en las 2/3 partes de el segmento de entrada - //con el punto situado en la posición 1/3 del segmento de salida - //Estos dos puntos ademas estan posicionados en el lugas correspondiente de - //los manejadores de la curva - nCurve->curveto(pointAt1, pointAt2, pointAt3); - //aumentamos los valores para el siguiente paso en el bucle - ++curve_it1; - ++curve_it2; + } else { + pointAt1 = in->first_segment()->initialPoint(); + } + if (!ignoreCusp || !Geom::are_near((*cubic)[2], pointAt3)) { + if (nodeIsSelected(pointAt3)) { + pointAt2 = SBasisIn.valueAt(1 - weightValue); + if (weightValue != 0.0000) { + pointAt2 = + Geom::Point(pointAt2[X] + 0.0001, pointAt2[Y] + 0.0001); + } + } else { + pointAt2 = (*cubic)[2]; + } + } else { + pointAt2 = in->first_segment()->finalPoint(); + } + } else { + if (!ignoreCusp && weightValue != 0.000) { + if (nodeIsSelected(pointAt0)) { + pointAt1 = SBasisIn.valueAt(weightValue); + pointAt1 = + Geom::Point(pointAt1[X] + 0.0001, pointAt1[Y] + 0.0001); + } else { + pointAt1 = in->first_segment()->initialPoint(); + } + if (nodeIsSelected(pointAt3)) { + pointAt2 = SBasisIn.valueAt(weightValue); + pointAt2 = + Geom::Point(pointAt2[X] + 0.0001, pointAt2[Y] + 0.0001); + } else { + pointAt2 = in->first_segment()->finalPoint(); + } + } else { + pointAt1 = in->first_segment()->initialPoint(); + pointAt2 = in->first_segment()->finalPoint(); + } } - SPCurve * out = new SPCurve(); - out->moveto(curve_it1->initialPoint()); - out->lineto(curve_it1->finalPoint()); - SBasisOut = out->first_segment()->toSBasis(); - nextPointAt0 = out->first_segment()->initialPoint(); - nextPointAt3 = out->first_segment()->finalPoint(); - cubic = dynamic_cast(&*curve_it1); - if(!onlySelected){ - if(cubic){ - if(!ignoreCusp || !Geom::are_near((*cubic)[1],nextPointAt0)){ - nextPointAt1 = SBasisOut.valueAt(weightValue); - if(weightValue !=0.0000){ - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0001,nextPointAt1[Y] + 0.0001); - } - }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - } - if(!ignoreCusp || !Geom::are_near((*cubic)[2],nextPointAt3)){ - nextPointAt2 = SBasisOut.valueAt(1-weightValue); - if(weightValue !=0.0000){ - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0001,nextPointAt2[Y] + 0.0001); - } - }else{ - nextPointAt2 = out->first_segment()->finalPoint(); - } - }else{ - if(!ignoreCusp && weightValue !=0.0000){ - nextPointAt1 = SBasisOut.valueAt(weightValue); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0001,nextPointAt1[Y] + 0.0001); - nextPointAt2 = SBasisOut.valueAt(1-weightValue); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0001,nextPointAt2[Y] + 0.0001); - }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - nextPointAt2 = out->first_segment()->finalPoint(); - } - } - }else{ - if(cubic){ - if(!ignoreCusp || !Geom::are_near((*cubic)[1],nextPointAt0)){ - if(nodeIsSelected(nextPointAt0)){ - nextPointAt1 = SBasisOut.valueAt(weightValue); - if(weightValue !=0.0000){ - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0001,nextPointAt1[Y] + 0.0001); - } - }else{ - nextPointAt1 = (*cubic)[1]; - } - }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - } - if(!ignoreCusp || !Geom::are_near((*cubic)[2],nextPointAt3)){ - if(nodeIsSelected(nextPointAt3)){ - nextPointAt2 = SBasisOut.valueAt(1-weightValue); - if(weightValue !=0.0000){ - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0001,nextPointAt2[Y] + 0.0001); - } - }else{ - nextPointAt2 = (*cubic)[2]; - } - }else{ - nextPointAt2 = out->first_segment()->finalPoint(); - } - }else{ - if(!ignoreCusp && weightValue !=0.0000){ - if(nodeIsSelected(nextPointAt0)){ - nextPointAt1 = SBasisOut.valueAt(weightValue); - nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0001,nextPointAt1[Y] + 0.0001); - }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - } - if(nodeIsSelected(nextPointAt3)){ - nextPointAt2 = SBasisOut.valueAt(weightValue); - nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0001,nextPointAt2[Y] + 0.0001); - }else{ - nextPointAt2 = out->first_segment()->finalPoint(); - } - }else{ - nextPointAt1 = out->first_segment()->initialPoint(); - nextPointAt2 = out->first_segment()->finalPoint(); - } + } + in->reset(); + delete in; + //La curva BSpline se forma calculando el centro del segmanto de unión + //de el punto situado en las 2/3 partes de el segmento de entrada + //con el punto situado en la posición 1/3 del segmento de salida + //Estos dos puntos ademas estan posicionados en el lugas correspondiente + //de + //los manejadores de la curva + nCurve->curveto(pointAt1, pointAt2, pointAt3); + //aumentamos los valores para el siguiente paso en el bucle + ++curve_it1; + ++curve_it2; + } + SPCurve *out = new SPCurve(); + out->moveto(curve_it1->initialPoint()); + out->lineto(curve_it1->finalPoint()); + SBasisOut = out->first_segment()->toSBasis(); + nextPointAt0 = out->first_segment()->initialPoint(); + nextPointAt3 = out->first_segment()->finalPoint(); + cubic = dynamic_cast(&*curve_it1); + if (!onlySelected) { + if (cubic) { + if (!ignoreCusp || !Geom::are_near((*cubic)[1], nextPointAt0)) { + nextPointAt1 = SBasisOut.valueAt(weightValue); + if (weightValue != 0.0000) { + nextPointAt1 = + Geom::Point(nextPointAt1[X] + 0.0001, nextPointAt1[Y] + 0.0001); + } + } else { + nextPointAt1 = out->first_segment()->initialPoint(); + } + if (!ignoreCusp || !Geom::are_near((*cubic)[2], nextPointAt3)) { + nextPointAt2 = SBasisOut.valueAt(1 - weightValue); + if (weightValue != 0.0000) { + nextPointAt2 = + Geom::Point(nextPointAt2[X] + 0.0001, nextPointAt2[Y] + 0.0001); + } + } else { + nextPointAt2 = out->first_segment()->finalPoint(); + } + } else { + if (!ignoreCusp && weightValue != 0.0000) { + nextPointAt1 = SBasisOut.valueAt(weightValue); + nextPointAt1 = + Geom::Point(nextPointAt1[X] + 0.0001, nextPointAt1[Y] + 0.0001); + nextPointAt2 = SBasisOut.valueAt(1 - weightValue); + nextPointAt2 = + Geom::Point(nextPointAt2[X] + 0.0001, nextPointAt2[Y] + 0.0001); + } else { + nextPointAt1 = out->first_segment()->initialPoint(); + nextPointAt2 = out->first_segment()->finalPoint(); + } + } + } else { + if (cubic) { + if (!ignoreCusp || !Geom::are_near((*cubic)[1], nextPointAt0)) { + if (nodeIsSelected(nextPointAt0)) { + nextPointAt1 = SBasisOut.valueAt(weightValue); + if (weightValue != 0.0000) { + nextPointAt1 = Geom::Point(nextPointAt1[X] + 0.0001, + nextPointAt1[Y] + 0.0001); } + } else { + nextPointAt1 = (*cubic)[1]; + } + } else { + nextPointAt1 = out->first_segment()->initialPoint(); } - out->reset(); - delete out; - //Aberiguamos la ultima parte de la curva correspondiente al último segmento - //Y hacemos lo propio con el path de salida - //nextPointAt0 = curveOut.valueAt(0); - if (path_it->closed()) { - nCurve->curveto(nextPointAt1, nextPointAt2, path_it->begin()->initialPoint()); - nCurve->move_endpoints(path_it->begin()->initialPoint(),path_it->begin()->initialPoint()); - }else{ - nCurve->curveto(nextPointAt1, nextPointAt2, nextPointAt3); - nCurve->move_endpoints(path_it->begin()->initialPoint(),nextPointAt3); + if (!ignoreCusp || !Geom::are_near((*cubic)[2], nextPointAt3)) { + if (nodeIsSelected(nextPointAt3)) { + nextPointAt2 = SBasisOut.valueAt(1 - weightValue); + if (weightValue != 0.0000) { + nextPointAt2 = Geom::Point(nextPointAt2[X] + 0.0001, + nextPointAt2[Y] + 0.0001); + } + } else { + nextPointAt2 = (*cubic)[2]; + } + } else { + nextPointAt2 = out->first_segment()->finalPoint(); } - //y cerramos la curva - if (path_it->closed()) { - nCurve->closepath_current(); + } else { + if (!ignoreCusp && weightValue != 0.0000) { + if (nodeIsSelected(nextPointAt0)) { + nextPointAt1 = SBasisOut.valueAt(weightValue); + nextPointAt1 = + Geom::Point(nextPointAt1[X] + 0.0001, nextPointAt1[Y] + 0.0001); + } else { + nextPointAt1 = out->first_segment()->initialPoint(); + } + if (nodeIsSelected(nextPointAt3)) { + nextPointAt2 = SBasisOut.valueAt(weightValue); + nextPointAt2 = + Geom::Point(nextPointAt2[X] + 0.0001, nextPointAt2[Y] + 0.0001); + } else { + nextPointAt2 = out->first_segment()->finalPoint(); + } + } else { + nextPointAt1 = out->first_segment()->initialPoint(); + nextPointAt2 = out->first_segment()->finalPoint(); } - curve->append(nCurve,false); - nCurve->reset(); - delete nCurve; - std::cout << ":: End ::\n"; + } + } + out->reset(); + delete out; + //Aberiguamos la ultima parte de la curva correspondiente al último + //segmento + //Y hacemos lo propio con el path de salida + //nextPointAt0 = curveOut.valueAt(0); + if (path_it->closed()) { + nCurve->curveto(nextPointAt1, nextPointAt2, + path_it->begin()->initialPoint()); + nCurve->move_endpoints(path_it->begin()->initialPoint(), + path_it->begin()->initialPoint()); + } else { + nCurve->curveto(nextPointAt1, nextPointAt2, nextPointAt3); + nCurve->move_endpoints(path_it->begin()->initialPoint(), nextPointAt3); + } + //y cerramos la curva + if (path_it->closed()) { + nCurve->closepath_current(); } + curve->append(nCurve, false); + nCurve->reset(); + delete nCurve; + std::cout << ":: End ::\n"; + } } }; //namespace LivePathEffect diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 510f9c989..167810c49 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -11,46 +11,45 @@ #include "live_effects/parameter/bool.h" #include - namespace Inkscape { namespace LivePathEffect { class LPEBSpline : public Effect { public: - LPEBSpline(LivePathEffectObject *lpeobject); - virtual ~LPEBSpline(); + LPEBSpline(LivePathEffectObject *lpeobject); + virtual ~LPEBSpline(); - virtual void createAndApply(const char* name, SPDocument *doc, SPItem *item); + virtual void createAndApply(const char *name, SPDocument *doc, SPItem *item); - virtual LPEPathFlashType pathFlashType() const { return SUPPRESS_FLASH; } + virtual LPEPathFlashType pathFlashType() const { return SUPPRESS_FLASH; } - virtual void doEffect(SPCurve * curve); + virtual void doEffect(SPCurve *curve); - virtual void doBSplineFromWidget(SPCurve * curve, double value); + virtual void doBSplineFromWidget(SPCurve *curve, double value); - virtual bool nodeIsSelected(Geom::Point nodePoint); + virtual bool nodeIsSelected(Geom::Point nodePoint); - virtual Gtk::Widget * newWidget(); + virtual Gtk::Widget *newWidget(); - virtual void changeWeight(double weightValue); + virtual void changeWeight(double weightValue); - virtual void toDefaultWeight(); + virtual void toDefaultWeight(); - virtual void toMakeCusp(); + virtual void toMakeCusp(); - virtual void toWeight(); + virtual void toWeight(); - ScalarParam steps; + ScalarParam steps; private: - std::vector points; - BoolParam ignoreCusp; - BoolParam onlySelected; - ScalarParam weight; + std::vector points; + BoolParam ignoreCusp; + BoolParam onlySelected; + ScalarParam weight; - LPEBSpline(const LPEBSpline&); - LPEBSpline& operator=(const LPEBSpline&); + LPEBSpline(const LPEBSpline &); + LPEBSpline &operator=(const LPEBSpline &); }; -- cgit v1.2.3 From 10fcc833d8d5d02bc8b77b87c812fd9e723193a0 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 31 Mar 2014 14:10:57 +0200 Subject: Fixed bug in LPE Bspline widget, on apply selected nodes, because a rounding problem. Thanks very much to Johan Engelen for point me to the correct direction. maybe is better round it previously to the are_near function, not sure (bzr r11950.1.318) --- src/live_effects/lpe-bspline.cpp | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 09e71d833..8254a13b6 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -39,8 +39,6 @@ #include "inkscape.h" #include "desktop.h" -#include - using Inkscape::DocumentUndo; namespace Inkscape { @@ -367,22 +365,14 @@ void LPEBSpline::changeWeight(double weightValue) { bool LPEBSpline::nodeIsSelected(Geom::Point nodePoint) { using Geom::X; using Geom::Y; - std::cout << "\n"; - std::cout << ":: Executed -> nodeIsSelected(Geom::Point nodePoint) ::\n"; - std::cout << "Want to check the argument -nodePoint- is in points vector \n"; - std::cout << "nodePoint::X=" << nodePoint[X] << ";Y=" << nodePoint[Y] << "\n"; - std::cout << "Checking points std::vector\n"; + if (points.size() > 0) { for (std::vector::iterator i = points.begin(); i != points.end(); ++i) { Geom::Point p = *i; - std::cout << "p::X=" << p[X] << ";Y=" << p[Y] << "\n"; - std::cout << "Are near? "; - if (Geom::are_near(p, nodePoint)) { - std::cout << "YES\n"; + if (Geom::are_near(p, nodePoint, 0.0001)) { return true; } else { - std::cout << "NO\n"; } } } @@ -394,9 +384,6 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weightValue) { using Geom::Y; SPDesktop *desktop = inkscape_active_desktop(); if (INK_IS_NODE_TOOL(desktop->event_context)) { - std::cout << ":: Start -> doBSplineFromWidget(SPCurve * curve, double " - "weightValue) ::\n"; - std::cout << "Inserting nodes selected into std::vector 'points'\n"; Inkscape::UI::Tools::NodeTool *nt = INK_NODE_TOOL(desktop->event_context); Inkscape::UI::ControlPointSelection::Set &selection = nt->_selected_nodes->allPoints(); @@ -409,11 +396,8 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weightValue) { Inkscape::UI::Node *n = dynamic_cast(*i); pbegin = points.begin(); points.insert(pbegin, desktop->doc2dt(n->position())); - std::cout << "inserting point::X=" << desktop->doc2dt(n->position())[X] - << ";Y=" << desktop->doc2dt(n->position())[Y] << "\n"; } } - std::cout << "End inserting selected nodes into vector\n"; } //bool hasNodesSelected = LPEBspline::hasNodesSelected(); if (curve->get_segment_count() < 2) @@ -696,7 +680,6 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weightValue) { curve->append(nCurve, false); nCurve->reset(); delete nCurve; - std::cout << ":: End ::\n"; } } -- cgit v1.2.3 From 0f91c5cd6a3a8a07185e107da881ff4da71f7081 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 22 Apr 2014 19:03:36 +0200 Subject: align two buttons in LPE widget (bzr r11950.1.334) --- src/live_effects/lpe-bspline.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 8254a13b6..00ebcd9ba 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -318,20 +318,18 @@ Gtk::Widget *LPEBSpline::newWidget() { ++it; } + Gtk::HBox * buttons = Gtk::manage(new Gtk::HBox(true,0)); Gtk::Button *defaultWeight = Gtk::manage(new Gtk::Button(Glib::ustring(_("Default weight 0.3334")))); - defaultWeight->set_alignment(0.0, 0.5); defaultWeight->signal_clicked() .connect(sigc::mem_fun(*this, &LPEBSpline::toDefaultWeight)); - Gtk::Widget *defaultWeightWidget = dynamic_cast(defaultWeight); - vbox->pack_start(*defaultWeightWidget, true, true, 2); + buttons->pack_start(*defaultWeight, true, true, 2); Gtk::Button *makeCusp = Gtk::manage(new Gtk::Button(Glib::ustring(_("Make cusp")))); - makeCusp->set_alignment(0.0, 0.5); makeCusp->signal_clicked() .connect(sigc::mem_fun(*this, &LPEBSpline::toMakeCusp)); - Gtk::Widget *makeCuspWidget = dynamic_cast(makeCusp); - vbox->pack_start(*makeCuspWidget, true, true, 2); + buttons->pack_start(*makeCusp, true, true, 2); + vbox->pack_start(*buttons, true, true, 2); return dynamic_cast(vbox); } -- cgit v1.2.3 From bb9297f7e0a297c85b5d40eab49677293effc88f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 22 Apr 2014 21:44:02 +0200 Subject: Redesign of the BSpline LPE widgets (bzr r11950.1.335) --- src/live_effects/lpe-bspline.cpp | 57 ++++++++++++++++++++++++++++------------ src/live_effects/lpe-bspline.h | 4 +-- 2 files changed, 42 insertions(+), 19 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 00ebcd9ba..edf19d1e5 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -2,7 +2,8 @@ /* * Released under GNU GPL, read the file 'COPYING' for more information */ - +#include +#include #include #include #include @@ -59,10 +60,10 @@ LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) false), weight(_("Change weight:"), _("Change weight of the effect"), "weight", &wr, this, 0.3334) { - registerParameter(dynamic_cast(&ignoreCusp)); - registerParameter(dynamic_cast(&onlySelected)); registerParameter(dynamic_cast(&weight)); registerParameter(dynamic_cast(&steps)); + registerParameter(dynamic_cast(&ignoreCusp)); + registerParameter(dynamic_cast(&onlySelected)); weight.param_set_range(0.0000, 1); weight.param_set_increments(0.1, 0.1); weight.param_set_digits(4); @@ -287,12 +288,32 @@ Gtk::Widget *LPEBSpline::newWidget() { if ((*it)->widget_is_visible) { Parameter *param = *it; Gtk::Widget *widg = dynamic_cast(param->param_newWidget()); + if (param->param_key == "weight"){ + Gtk::HBox * buttons = Gtk::manage(new Gtk::HBox(true,0)); + Gtk::Button *defaultWeight = + Gtk::manage(new Gtk::Button(Glib::ustring(_("Default weight")))); + defaultWeight->signal_clicked() + .connect(sigc::bind(sigc::mem_fun(*this, &LPEBSpline::toDefaultWeight), widg)); + buttons->pack_start(*defaultWeight, true, true, 2); + Gtk::Button *makeCusp = + Gtk::manage(new Gtk::Button(Glib::ustring(_("Make cusp")))); + makeCusp->signal_clicked() + .connect(sigc::bind(sigc::mem_fun(*this, &LPEBSpline::toMakeCusp), widg)); + buttons->pack_start(*makeCusp, true, true, 2); + vbox->pack_start(*buttons, true, true, 2); + } if (param->param_key == "weight" || param->param_key == "steps") { Inkscape::UI::Widget::Scalar *widgRegistered = Gtk::manage(dynamic_cast(widg)); widgRegistered->signal_value_changed() .connect(sigc::mem_fun(*this, &LPEBSpline::toWeight)); widg = dynamic_cast(widgRegistered); + if (widg){ + Gtk::HBox * scalarParameter = dynamic_cast(widg); + std::vector< Gtk::Widget* > childList = scalarParameter->get_children(); + Gtk::Entry* entryWidg = dynamic_cast(childList[1]); + entryWidg->set_width_chars(6); + } } if (param->param_key == "onlySelected") { Gtk::CheckButton *widgRegistered = @@ -318,24 +339,26 @@ Gtk::Widget *LPEBSpline::newWidget() { ++it; } - Gtk::HBox * buttons = Gtk::manage(new Gtk::HBox(true,0)); - Gtk::Button *defaultWeight = - Gtk::manage(new Gtk::Button(Glib::ustring(_("Default weight 0.3334")))); - defaultWeight->signal_clicked() - .connect(sigc::mem_fun(*this, &LPEBSpline::toDefaultWeight)); - buttons->pack_start(*defaultWeight, true, true, 2); - Gtk::Button *makeCusp = - Gtk::manage(new Gtk::Button(Glib::ustring(_("Make cusp")))); - makeCusp->signal_clicked() - .connect(sigc::mem_fun(*this, &LPEBSpline::toMakeCusp)); - buttons->pack_start(*makeCusp, true, true, 2); - vbox->pack_start(*buttons, true, true, 2); return dynamic_cast(vbox); } -void LPEBSpline::toDefaultWeight() { changeWeight(0.3334); } +void LPEBSpline::toDefaultWeight(Gtk::Widget *widgWeight) { + weight.param_set_value(0.3334); + changeWeight(0.3334); + Gtk::HBox * scalarParameter = dynamic_cast(widgWeight); + std::vector< Gtk::Widget* > childList = scalarParameter->get_children(); + Gtk::Entry* entryWidg = dynamic_cast(childList[1]); + entryWidg->set_text("0.3334"); +} -void LPEBSpline::toMakeCusp() { changeWeight(0.0000); } +void LPEBSpline::toMakeCusp(Gtk::Widget *widgWeight) { + weight.param_set_value(0.0000); + changeWeight(0.0000); + Gtk::HBox * scalarParameter = dynamic_cast(widgWeight); + std::vector< Gtk::Widget* > childList = scalarParameter->get_children(); + Gtk::Entry* entryWidg = dynamic_cast(childList[1]); + entryWidg->set_text("0.0000"); +} void LPEBSpline::toWeight() { changeWeight(weight); } diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h index 167810c49..aff4ce812 100644 --- a/src/live_effects/lpe-bspline.h +++ b/src/live_effects/lpe-bspline.h @@ -34,9 +34,9 @@ public: virtual void changeWeight(double weightValue); - virtual void toDefaultWeight(); + virtual void toDefaultWeight(Gtk::Widget *widgWeight); - virtual void toMakeCusp(); + virtual void toMakeCusp(Gtk::Widget *widgWeight); virtual void toWeight(); -- cgit v1.2.3 From 5a8b00f027b9eb3d4abb290d2ddf26d36d71cf80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20dos=20Santos=20Oliveira?= Date: Mon, 5 May 2014 04:13:35 -0300 Subject: Enabling path manipulator to comunicate if paths are bspline when accessing const objects. This change was required to correctly show on the GUI whether or not a node was a bspline. (bzr r11950.8.1) --- src/live_effects/effect.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/live_effects') diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index 1da9b4cc9..940770616 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -101,6 +101,7 @@ public: Inkscape::XML::Node * getRepr(); SPDocument * getSPDoc(); LivePathEffectObject * getLPEObj() {return lpeobj;}; + LivePathEffectObject const * getLPEObj() const {return lpeobj;}; Parameter * getParameter(const char * key); void readallParameters(Inkscape::XML::Node const* repr); -- cgit v1.2.3