summaryrefslogtreecommitdiffstats
path: root/src/live_effects
diff options
context:
space:
mode:
Diffstat (limited to 'src/live_effects')
-rw-r--r--src/live_effects/lpe-bspline.cpp44
-rw-r--r--src/live_effects/lpe-bspline.h31
-rw-r--r--src/live_effects/lpe-recursiveskeleton.cpp3
3 files changed, 50 insertions, 28 deletions
diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp
index 9e83bbb41..785c545b5 100644
--- a/src/live_effects/lpe-bspline.cpp
+++ b/src/live_effects/lpe-bspline.cpp
@@ -39,11 +39,12 @@
using Inkscape::DocumentUndo;
+
namespace Inkscape {
namespace LivePathEffect {
LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject) :
- Effect(lpeobject),scal,noCusp
+ Effect(lpeobject)
{
}
@@ -238,26 +239,25 @@ Gtk::Widget *
LPEBSpline::newWidget()
{
Gtk::VBox * vbox = dynamic_cast<Gtk::VBox*>(Effect::newWidget());
- vbox->set_border_width(5);
Glib::ustring title = Glib::ustring(_("Ignore cusp nodes"));
Glib::ustring tip = Glib::ustring(_("Ignore cusp nodes"));
- Gtk::Widget *noCuspWidget = new LPEBSpline::newCheckButton(title,tip);
- vbox->pack_start(*noCuspWidget,true,true,(guint)2);
+ this->setNoCuspWidget(this->newCheckButton(title));
title = Glib::ustring(_("Unify weights:"));
tip = Glib::ustring(_("Percent of the with for all poinrs"));
- Gtk::Widget *scalWidget = new LPEBSpline::newScalar(title,tip);
- vbox->pack_start(*scalWidget, true, true,2);
+ 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);
return dynamic_cast<Gtk::VBox *> (vbox);
}
Gtk::Widget *
LPEBSpline::newScalar(Glib::ustring title, Glib::ustring tip)
{
- scal = Gtk::manage( new Inkscape::UI::Widget::Scalar(title, tip));
- scal->setValue(33.);
- scal->setDigits(2);
+ 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->setRange(0, 100.);
+ scal->setValue(33.);
scal->setProgrammatically = false;
scal->addSlider();
scal->signal_value_changed().connect(sigc::mem_fun (*this,&LPEBSpline::updateAllHandles));
@@ -265,17 +265,20 @@ LPEBSpline::newScalar(Glib::ustring title, Glib::ustring tip)
}
Gtk::Widget *
-LPEBSpline::newCheckButton(Glib::ustring title, Glib::ustring tip)
+LPEBSpline::newCheckButton(Glib::ustring title)
{
- noCusp = Gtk::manage( new Gtk::CheckButton(title,tip));
+ Gtk::CheckButton * noCusp = Gtk::manage( new Gtk::CheckButton(title,true));
+ noCusp->set_alignment(1.0,0.0);
return dynamic_cast<Gtk::Widget *>(noCusp);
}
void
LPEBSpline::updateAllHandles()
{
- double value = scal->setValue(33.);
- bool noCusp = false;
+ Inkscape::UI::Widget::Scalar * scal = dynamic_cast<Inkscape::UI::Widget::Scalar *>(this->getScalWidget());
+ double value = scal->getValue()/100;
+ Gtk::CheckButton * noCusp = dynamic_cast<Gtk::CheckButton *>(this->getNoCuspWidget());
+ bool noCuspValue = noCusp->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();
@@ -288,7 +291,7 @@ LPEBSpline::updateAllHandles()
SPItem *item = (SPItem *) items->data;
SPPath *path = SP_PATH(item);
SPCurve *curve = path->get_curve_for_edit();
- LPEBSpline::doBSplineFromWidget(curve,value,noCusp);
+ LPEBSpline::doBSplineFromWidget(curve,value,noCuspValue);
gchar *str = sp_svg_write_path(curve->get_pathvector());
path->getRepr()->setAttribute("inkscape:original-d", str);
g_free(str);
@@ -310,6 +313,8 @@ 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) {
@@ -363,16 +368,20 @@ 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();
@@ -391,16 +400,20 @@ 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();
@@ -409,6 +422,7 @@ 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 eace58837..a0f1554d0 100644
--- a/src/live_effects/lpe-bspline.h
+++ b/src/live_effects/lpe-bspline.h
@@ -8,9 +8,7 @@
*/
#include "live_effects/effect.h"
-#include "live_effects/parameter/parameter.h"
-#include "ui/widget/scalar.h"
-#include <gtkmm/checkbutton.h>
+
namespace Inkscape {
namespace LivePathEffect {
@@ -18,6 +16,13 @@ namespace LivePathEffect {
class LPEBSpline : public Effect {
+
+private:
+ double scalWidget;
+ bool noCuspWidget;
+ LPEBSpline(const LPEBSpline&);
+ LPEBSpline& operator=(const LPEBSpline&);
+
public:
LPEBSpline(LivePathEffectObject *lpeobject);
virtual ~LPEBSpline();
@@ -30,20 +35,22 @@ public:
virtual void updateAllHandles();
- virtual void newScalar(Glib::ustring title, Glib::ustring tip);
+ virtual Gtk::Widget* 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 Gtk::Widget * newWidget();
-
+ 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();
-private:
- Inkscape::UI::Widget::Scalar* scal;
- Gtk::CheckButton* 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 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<Geom::D2<Geom::SBasis> > 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;