summaryrefslogtreecommitdiffstats
path: root/src/pen-context.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-01-05 10:53:55 +0000
committerJabiertxo Arraiza Cenoz <jtx@jtx.marker.es>2013-01-05 10:53:55 +0000
commit32866e3ed73a2a8c41520e2538687b5701a2d347 (patch)
tree5e864fce52c71e55a5d5b9980f4c939ac9ec3ae9 /src/pen-context.cpp
parentFixing StartAnchor problems in bspline (diff)
downloadinkscape-32866e3ed73a2a8c41520e2538687b5701a2d347.tar.gz
inkscape-32866e3ed73a2a8c41520e2538687b5701a2d347.zip
fix continue
(bzr r11950.1.11)
Diffstat (limited to 'src/pen-context.cpp')
-rw-r--r--src/pen-context.cpp127
1 files changed, 62 insertions, 65 deletions
diff --git a/src/pen-context.cpp b/src/pen-context.cpp
index ea14a5183..92481ec68 100644
--- a/src/pen-context.cpp
+++ b/src/pen-context.cpp
@@ -58,7 +58,6 @@
#include "helper/geom-nodetype.h"
#include "helper/geom-curves.h"
-
// For handling un-continuous paths:
#include "message-stack.h"
#include "inkscape.h"
@@ -1502,6 +1501,14 @@ static void spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, G
//BSpline Set Functions
+//Creates a new curve resetting the original
+static SPCurve * reverse_then_reset(SPCurve *orig)
+{
+ SPCurve *ret = orig->create_reverse();
+ orig->reset();
+ return ret;
+}
+
//Esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro
static void spiro_color(SPPenContext *const pc)
{
@@ -1787,14 +1794,6 @@ static void spiro_doEffect(SPCurve * curve)
g_free (path);
}
-//BSpline Set Functions
-//Creates a new curve resetting the original
-static SPCurve * reverse_then_reset(SPCurve *orig)
-{
- SPCurve *ret = orig->create_reverse();
- orig->reset();
- return ret;
-}
//Unimos todas las curvas en juego y llamamos a la función doEffect.
static void bspline(SPPenContext *const pc, bool Shift)
@@ -1802,62 +1801,61 @@ static void bspline(SPPenContext *const pc, bool Shift)
if(!Shift){
//Modo Bspline formado por nodos CUSP
if (pc->npoints == 5 || !pc->red_curve->is_empty()){
- pc->npoints = 5;
- pc->p[2]= pc->p[3];
+ pc->npoints = 2;
+ pc->p[1]= pc->p[3];
}
}else{
using Geom::X;
using Geom::Y;
- Geom::CubicBezier const * cubic;
- if(pc->green_curve->is_empty() && pc->red_curve->is_empty() && pc->sa && !pc->ea && !pc->sa->curve->is_empty()){
- bool reverse = false;
- if (pc->sa->start) {
- reverse = true;
- pc->sa->curve = reverse_then_reset(pc->sa->curve);
- }
- Geom::Point P0(0,0);
- Geom::Point P1(0,0);
- Geom::Point P2(0,0);
- Geom::Point P3(0,0);
- Geom::Point P4(0,0);
- P0 = pc->sa->curve->last_segment()->initialPoint();
- P1 = P0;
- cubic = dynamic_cast<Geom::CubicBezier const *>( pc->sa->curve->last_segment() );
- if(cubic)
- P1 = (*cubic)[2];
- P3 = pc->sa->curve->last_segment()->finalPoint();
- P2 = P3 + (1./3)*(P0 - P3);
- P2 = Geom::Point(P2[X]+1,P2[Y]+1);
- SPCurve * last = new SPCurve();
- last->moveto(P0);
- last->curveto(P1,P2,P3);
- if( pc->sa->curve->get_segment_count() == 1){
- pc->sa->curve = last;
- }else{
- pc->sa->curve->backspace();
- pc->sa->curve->append_continuous(last, 0.0625);
- }
- if(reverse)
- pc->sa->curve = reverse_then_reset(pc->sa->curve);
- last->reset();
- last->unref();
- }
- //NODO CUSP formado por nodo SMOOTH
- //solo mobemos el manejador del nodo final de cada segmento
- //Es suficiente para mostrar el nodo como CUSP
- //Usamos 5 puntos
+/*
+.* //TODO: No puedo conseguir que el siguoenmte codigo funcione
+.* //Este trata de convertir el nodo de inicio de continuación de curva BSpline a CUSP
+.* //modifiacandpo el segmento al que se trata de anexar la curva
+.* //de manera que le obligue a tener manejador final
+.*
+.* if(pc->anchor_statusbar && pc->sa && !pc->sa->curve->is_empty() && pc->red_curve->is_empty()){
+.* bool reverse = false;
+.* if(pc->sa->start){
+.* pc->sa->curve = reverse_then_reset(pc->sa->curve);
+.* reverse = true;
+.* }
+.* Geom::Point P0(0,0);
+.* Geom::Point P1(0,0);
+.* Geom::Point P2(0,0);
+.* Geom::Point P3(0,0);
+.* Geom::Point P4(0,0);
+.* P0 = pc->sa->curve->last_segment()->initialPoint();
+.* P1 = P0;
+.* P3 = pc->sa->curve->last_segment()->finalPoint();
+.* P2 = P3 + (1./3)*(P0 - P3);
+.* P2 = Geom::Point(P2[X]+1,P2[Y]+1);
+.* SPCurve * last = new SPCurve();
+.* last->moveto(P0);
+.* last->curveto(P1,P2,P3);
+.* if( pc->sa->curve->get_segment_count() == 1){
+.* pc->sa->curve = last;
+.* }else{
+.* pc->sa->curve->backspace();
+.* pc->sa->curve->append_continuous(last, 0.0625);
+.* if(reverse)
+.* pc->sa->curve = reverse_then_reset(pc->sa->curve);
+.* }
+.* delete last;
+.* }
+*/
+ //NODO CUSP formado por nodo SMOOTH
+ //solo mobemos el manejador del nodo final de cada segmento
+ //Es suficiente para mostrar el nodo como CUSP
+ //Usamos 5 puntos
if(!pc->red_curve->is_empty()){
pc->npoints = 5;
pc->p[0] = pc->red_curve->first_segment()->initialPoint();
pc->p[1] = pc->p[0];
- cubic = dynamic_cast<Geom::CubicBezier const *>( pc->red_curve->first_segment() );
- if(cubic)
- pc->p[1] = (*cubic)[1];
pc->p[3] = pc->red_curve->first_segment()->finalPoint();
- pc->p[2] = pc->p[0] + (1./3)*(pc->p[0] - pc->p[3]);
+ pc->p[4] = pc->p[3];
+ pc->p[2] = pc->p[3] + (1./3)*(pc->p[0] - pc->p[3]);
pc->p[2] = Geom::Point(pc->p[2][X]+1,pc->p[2][Y]+1);
- pc->p[4] = pc->p[3] + (1./3)*(pc->p[3] - pc->p[0]);
}
}
bspline_build(pc);
@@ -1956,9 +1954,6 @@ static void bspline_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...
@@ -1987,10 +1982,10 @@ static void bspline_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<Geom::CubicBezier const*>(&*curve_endit);
- if((*cubic)[2] == (*cubic)[3])
- isBSpline = false;
+ if (Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const*>(&*curve_end)){
+ if((*cubic)[2] == (*cubic)[3])
+ isBSpline = false;
+ }
if (path_it->closed() && !isBSpline) {
isBSpline = true;
//Calculamos el nodo de inicio BSpline
@@ -2042,9 +2037,10 @@ static void bspline_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<Geom::CubicBezier const*>(&*curve_it1);
- if((*cubic)[2] == (*cubic)[3])
- isBSpline = true;
+ if (Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const*>(&*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
@@ -2237,11 +2233,12 @@ static void spdc_pen_finish(SPPenContext *const pc, gboolean const closed)
// don't let the path be finished before we have collected the required number of mouse clicks
return;
}
+
//BSpline
if(pc->bspline && pc->green_curve->get_segment_count() < 2 && !pc->sa )
return;
-
//BSpline End
+
pc->num_clicks = 0;
pen_disable_events(pc);