summaryrefslogtreecommitdiffstats
path: root/src/live_effects
diff options
context:
space:
mode:
Diffstat (limited to 'src/live_effects')
-rw-r--r--src/live_effects/effect.cpp16
-rw-r--r--src/live_effects/effect.h2
-rw-r--r--src/live_effects/lpe-bspline.cpp47
-rw-r--r--src/live_effects/lpe-bspline.h2
-rw-r--r--src/live_effects/lpe-copy_rotate.cpp3
-rw-r--r--src/live_effects/lpe-fillet-chamfer.cpp2
-rw-r--r--src/live_effects/lpe-knot.cpp2
-rw-r--r--src/live_effects/lpe-lattice.cpp15
-rw-r--r--src/live_effects/lpe-lattice2.cpp359
-rw-r--r--src/live_effects/lpe-lattice2.h65
-rw-r--r--src/live_effects/lpe-offset.cpp4
-rw-r--r--src/live_effects/lpe-parallel.cpp5
-rw-r--r--src/live_effects/lpe-perspective-envelope.cpp27
-rw-r--r--src/live_effects/lpe-perspective-envelope.h10
-rw-r--r--src/live_effects/lpe-simplify.cpp139
-rw-r--r--src/live_effects/lpe-simplify.h6
-rw-r--r--src/live_effects/lpe-sketch.cpp2
-rw-r--r--src/live_effects/lpe-test-doEffect-stack.cpp1
-rw-r--r--src/live_effects/lpeobject.cpp10
-rw-r--r--src/live_effects/parameter/Makefile_insert2
-rw-r--r--src/live_effects/parameter/filletchamferpointarray.cpp2
-rw-r--r--src/live_effects/parameter/filletchamferpointarray.h4
-rw-r--r--src/live_effects/parameter/point.cpp100
-rw-r--r--src/live_effects/parameter/point.h13
-rw-r--r--src/live_effects/parameter/pointreseteable.cpp210
-rw-r--r--src/live_effects/parameter/pointreseteable.h74
26 files changed, 505 insertions, 617 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index 48fc788fa..572d4c35c 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -368,6 +368,10 @@ Effect::Effect(LivePathEffectObject *lpeobject)
show_orig_path(false),
lpeobj(lpeobject),
concatenate_before_pwd2(false),
+ sp_lpe_item(NULL),
+ defaultUnit("px"),
+ current_zoom(1),
+ sp_curve(NULL),
provides_own_flash_paths(true), // is automatically set to false if providesOwnFlashPaths() is not overridden
is_ready(false) // is automatically set to false if providesOwnFlashPaths() is not overridden
{
@@ -455,7 +459,7 @@ void Effect::doOnRemove (SPLPEItem const* /*lpeitem*/)
void Effect::doOnApply_impl(SPLPEItem const* lpeitem)
{
sp_lpe_item = const_cast<SPLPEItem *>(lpeitem);
- defaultUnit = &sp_lpe_item->document->getDisplayUnit()->abbr;
+ defaultUnit = sp_lpe_item->document->getDisplayUnit()->abbr;
/*sp_curve = SP_SHAPE(sp_lpe_item)->getCurve();
pathvector_before_effect = sp_curve->get_pathvector();*/
doOnApply(lpeitem);
@@ -464,11 +468,13 @@ void Effect::doOnApply_impl(SPLPEItem const* lpeitem)
void Effect::doBeforeEffect_impl(SPLPEItem const* lpeitem)
{
sp_lpe_item = const_cast<SPLPEItem *>(lpeitem);
- defaultUnit = &sp_lpe_item->document->getDisplayUnit()->abbr;
+ defaultUnit = sp_lpe_item->document->getDisplayUnit()->abbr;
//printf("(SPLPEITEM*) %p\n", sp_lpe_item);
- sp_curve = SP_SHAPE(sp_lpe_item)->getCurve();
- pathvector_before_effect = sp_curve->get_pathvector();
-
+ SPShape * shape = dynamic_cast<SPShape *>(sp_lpe_item);
+ if(shape){
+ sp_curve = shape->getCurve();
+ pathvector_before_effect = sp_curve->get_pathvector();
+ }
doBeforeEffect(lpeitem);
}
diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h
index 7da76b267..ac1f0b8dc 100644
--- a/src/live_effects/effect.h
+++ b/src/live_effects/effect.h
@@ -159,7 +159,7 @@ protected:
bool concatenate_before_pwd2;
SPLPEItem * sp_lpe_item; // these get stored in doBeforeEffect_impl, and derived classes may do as they please with them.
- Glib::ustring const * defaultUnit; // these get stored in doBeforeEffect_impl, and derived classes may do as they please with them.
+ Glib::ustring defaultUnit; // these get stored in doBeforeEffect_impl, and derived classes may do as they please with them.
double current_zoom;
std::vector<Geom::Point> selectedNodesPoints;
SPCurve * sp_curve;
diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp
index 2bed90139..b924d8a23 100644
--- a/src/live_effects/lpe-bspline.cpp
+++ b/src/live_effects/lpe-bspline.cpp
@@ -54,20 +54,17 @@ const double defaultEndPower = 0.6667;
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 with CTRL:"), _("Change number of steps with CTRL pressed"), "steps", &wr, this, 2),
+ helper_size(_("Helper size:"), _("Helper size"), "helper_size", &wr, this, 0),
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),
- showHelper(_("Show helper paths"), _("Show helper paths"), "showHelper", &wr, this, false),
weight(_("Change weight:"), _("Change weight of the effect"), "weight", &wr, this, defaultStartPower)
{
- registerParameter(dynamic_cast<Parameter *>(&weight));
- registerParameter(dynamic_cast<Parameter *>(&steps));
- registerParameter(dynamic_cast<Parameter *>(&ignoreCusp));
- registerParameter(dynamic_cast<Parameter *>(&onlySelected));
- registerParameter(dynamic_cast<Parameter *>(&showHelper));
+ registerParameter(&weight);
+ registerParameter(&steps);
+ registerParameter(&helper_size);
+ registerParameter(&ignoreCusp);
+ registerParameter(&onlySelected);
weight.param_set_range(noPower, 1);
weight.param_set_increments(0.1, 0.1);
@@ -76,6 +73,10 @@ LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject)
steps.param_set_range(1, 10);
steps.param_set_increments(1, 1);
steps.param_set_digits(0);
+
+ helper_size.param_set_range(0.0, 999.0);
+ helper_size.param_set_increments(5, 5);
+ helper_size.param_set_digits(2);
}
LPEBSpline::~LPEBSpline() {}
@@ -106,9 +107,7 @@ void LPEBSpline::doEffect(SPCurve *curve)
// Make copy of old path as it is changed during processing
Geom::PathVector const original_pathv = curve->get_pathvector();
curve->reset();
- double radiusHelperNodes = 6.0;
- radiusHelperNodes /= current_zoom;
- radiusHelperNodes = Inkscape::Util::Quantity::convert(radiusHelperNodes, "px", *defaultUnit);
+
for (Geom::PathVector::const_iterator path_it = original_pathv.begin();
path_it != original_pathv.end(); ++path_it) {
if (path_it->empty())
@@ -236,8 +235,8 @@ void LPEBSpline::doEffect(SPCurve *curve)
}
nCurve->curveto(pointAt1, pointAt2, node);
}
- if(!are_near(node,curve_it1->finalPoint()) && showHelper){
- drawHandle(node, radiusHelperNodes);
+ if(!are_near(node,curve_it1->finalPoint()) && helper_size > 0.0){
+ drawHandle(node, helper_size);
}
++curve_it1;
++curve_it2;
@@ -250,21 +249,21 @@ void LPEBSpline::doEffect(SPCurve *curve)
nCurve->reset();
delete nCurve;
}
- if(showHelper){
+ if(helper_size > 0.0){
Geom::PathVector const pathv = curve->get_pathvector();
hp.push_back(pathv[0]);
}
}
void
-LPEBSpline::drawHandle(Geom::Point p, double radiusHelperNodes)
+LPEBSpline::drawHandle(Geom::Point p, double helper_size)
{
char const * svgd = "M 1,0.5 A 0.5,0.5 0 0 1 0.5,1 0.5,0.5 0 0 1 0,0.5 0.5,0.5 0 0 1 0.5,0 0.5,0.5 0 0 1 1,0.5 Z";
Geom::PathVector pathv = sp_svg_read_pathv(svgd);
Geom::Affine aff = Geom::Affine();
- aff *= Geom::Scale(radiusHelperNodes);
+ aff *= Geom::Scale(helper_size);
pathv *= aff;
- pathv += p - Geom::Point(0.5*radiusHelperNodes, 0.5*radiusHelperNodes);
+ pathv += p - Geom::Point(0.5*helper_size, 0.5*helper_size);
hp.push_back(pathv[0]);
}
@@ -356,11 +355,13 @@ void LPEBSpline::toWeight()
void LPEBSpline::changeWeight(double weightValue)
{
- SPPath *path = SP_PATH(sp_lpe_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);
+ SPPath *path = dynamic_cast<SPPath *>(sp_lpe_item);
+ if(path){
+ 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);
+ }
}
void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weightValue)
diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h
index a17c0c4ac..642562b24 100644
--- a/src/live_effects/lpe-bspline.h
+++ b/src/live_effects/lpe-bspline.h
@@ -38,9 +38,9 @@ public:
ScalarParam steps;
private:
+ ScalarParam helper_size;
BoolParam ignoreCusp;
BoolParam onlySelected;
- BoolParam showHelper;
ScalarParam weight;
Geom::PathVector hp;
diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp
index 0fa2ebedc..fd9b853d5 100644
--- a/src/live_effects/lpe-copy_rotate.cpp
+++ b/src/live_effects/lpe-copy_rotate.cpp
@@ -69,7 +69,7 @@ LPECopyRotate::LPECopyRotate(LivePathEffectObject *lpeobject) :
registerParameter(&rotation_angle);
registerParameter(&num_copies);
registerParameter(&origin);
-
+
num_copies.param_make_integer(true);
num_copies.param_set_range(0, 1000);
}
@@ -88,6 +88,7 @@ LPECopyRotate::doOnApply(SPLPEItem const* lpeitem)
A = Point(boundingbox_X.min(), boundingbox_Y.middle());
B = Point(boundingbox_X.middle(), boundingbox_Y.middle());
origin.param_setValue(A);
+ origin.param_update_default(A);
dist_angle_handle = L2(B - A);
dir = unit_vector(B - A);
}
diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp
index d2bdf2d8d..c8458b8cb 100644
--- a/src/live_effects/lpe-fillet-chamfer.cpp
+++ b/src/live_effects/lpe-fillet-chamfer.cpp
@@ -223,7 +223,7 @@ void LPEFilletChamfer::updateFillet()
{
double power = 0;
if (!flexible) {
- power = Inkscape::Util::Quantity::convert(radius, unit.get_abbreviation(), *defaultUnit) * -1;
+ power = Inkscape::Util::Quantity::convert(radius, unit.get_abbreviation(), defaultUnit) * -1;
} else {
power = radius;
}
diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp
index 3876aa24b..820221abf 100644
--- a/src/live_effects/lpe-knot.cpp
+++ b/src/live_effects/lpe-knot.cpp
@@ -404,7 +404,7 @@ LPEKnot::doEffect_path (std::vector<Geom::Path> const &path_in)
for (unsigned comp=0; comp<path_in.size(); comp++){
//find the relevant path component in gpaths (required to allow groups!)
- //Q: do we always recieve the group members in the same order? can we rest on that?
+ //Q: do we always receive the group members in the same order? can we rest on that?
unsigned i0 = 0;
for (i0=0; i0<gpaths.size(); i0++){
if (path_in[comp]==gpaths[i0]) break;
diff --git a/src/live_effects/lpe-lattice.cpp b/src/live_effects/lpe-lattice.cpp
index a241a8a2e..c05bae7e1 100644
--- a/src/live_effects/lpe-lattice.cpp
+++ b/src/live_effects/lpe-lattice.cpp
@@ -236,6 +236,21 @@ LPELattice::resetDefaults(SPItem const* item)
grid_point15[Geom::X] = 2.0/3*boundingbox_X.max()+1.0/3*boundingbox_X.min();
grid_point15[Geom::Y] = 2.0/3*boundingbox_Y.max()+1.0/3*boundingbox_Y.min();
+ grid_point1.param_update_default(grid_point1);
+ grid_point2.param_update_default(grid_point2);
+ grid_point3.param_update_default(grid_point3);
+ grid_point4.param_update_default(grid_point4);
+ grid_point5.param_update_default(grid_point5);
+ grid_point6.param_update_default(grid_point6);
+ grid_point7.param_update_default(grid_point7);
+ grid_point8.param_update_default(grid_point8);
+ grid_point9.param_update_default(grid_point9);
+ grid_point10.param_update_default(grid_point10);
+ grid_point11.param_update_default(grid_point11);
+ grid_point12.param_update_default(grid_point12);
+ grid_point13.param_update_default(grid_point13);
+ grid_point14.param_update_default(grid_point14);
+ grid_point15.param_update_default(grid_point15);
}
/**
diff --git a/src/live_effects/lpe-lattice2.cpp b/src/live_effects/lpe-lattice2.cpp
index e1cd91340..08bbbd504 100644
--- a/src/live_effects/lpe-lattice2.cpp
+++ b/src/live_effects/lpe-lattice2.cpp
@@ -23,18 +23,17 @@
#include "sp-path.h"
#include "display/curve.h"
#include "svg/svg.h"
-
+#include "helper/geom.h"
+#include <2geom/path.h>
#include <2geom/sbasis.h>
#include <2geom/sbasis-2d.h>
+#include "helper/geom-curves.h"
#include <2geom/sbasis-geometric.h>
#include <2geom/bezier-to-sbasis.h>
#include <2geom/sbasis-to-bezier.h>
#include <2geom/d2.h>
#include <2geom/piecewise.h>
#include <2geom/transforms.h>
-#include "ui/tools-switch.h"
-
-#include "desktop.h" // TODO: should be factored out (see below)
using namespace Geom;
@@ -43,61 +42,63 @@ namespace LivePathEffect {
LPELattice2::LPELattice2(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
- // initialise your parameters here:
- grid_point0(_("Control handle 0:"), _("Control handle 0 - Ctrl+Alt+Click to reset"), "gridpoint0", &wr, this),
- grid_point1(_("Control handle 1:"), _("Control handle 1 - Ctrl+Alt+Click to reset"), "gridpoint1", &wr, this),
- grid_point2(_("Control handle 2:"), _("Control handle 2 - Ctrl+Alt+Click to reset"), "gridpoint2", &wr, this),
- grid_point3(_("Control handle 3:"), _("Control handle 3 - Ctrl+Alt+Click to reset"), "gridpoint3", &wr, this),
- grid_point4(_("Control handle 4:"), _("Control handle 4 - Ctrl+Alt+Click to reset"), "gridpoint4", &wr, this),
- grid_point5(_("Control handle 5:"), _("Control handle 5 - Ctrl+Alt+Click to reset"), "gridpoint5", &wr, this),
- grid_point6(_("Control handle 6:"), _("Control handle 6 - Ctrl+Alt+Click to reset"), "gridpoint6", &wr, this),
- grid_point7(_("Control handle 7:"), _("Control handle 7 - Ctrl+Alt+Click to reset"), "gridpoint7", &wr, this),
- grid_point8x9(_("Control handle 8x9:"), _("Control handle 8x9 - Ctrl+Alt+Click to reset"), "gridpoint8x9", &wr, this),
- grid_point10x11(_("Control handle 10x11:"), _("Control handle 10x11 - Ctrl+Alt+Click to reset"), "gridpoint10x11", &wr, this),
- grid_point12(_("Control handle 12:"), _("Control handle 12 - Ctrl+Alt+Click to reset"), "gridpoint12", &wr, this),
- grid_point13(_("Control handle 13:"), _("Control handle 13 - Ctrl+Alt+Click to reset"), "gridpoint13", &wr, this),
- grid_point14(_("Control handle 14:"), _("Control handle 14 - Ctrl+Alt+Click to reset"), "gridpoint14", &wr, this),
- grid_point15(_("Control handle 15:"), _("Control handle 15 - Ctrl+Alt+Click to reset"), "gridpoint15", &wr, this),
- grid_point16(_("Control handle 16:"), _("Control handle 16 - Ctrl+Alt+Click to reset"), "gridpoint16", &wr, this),
- grid_point17(_("Control handle 17:"), _("Control handle 17 - Ctrl+Alt+Click to reset"), "gridpoint17", &wr, this),
- grid_point18(_("Control handle 18:"), _("Control handle 18 - Ctrl+Alt+Click to reset"), "gridpoint18", &wr, this),
- grid_point19(_("Control handle 19:"), _("Control handle 19 - Ctrl+Alt+Click to reset"), "gridpoint19", &wr, this),
- grid_point20x21(_("Control handle 20x21:"), _("Control handle 20x21 - Ctrl+Alt+Click to reset"), "gridpoint20x21", &wr, this),
- grid_point22x23(_("Control handle 22x23:"), _("Control handle 22x23 - Ctrl+Alt+Click to reset"), "gridpoint22x23", &wr, this),
- grid_point24x26(_("Control handle 24x26:"), _("Control handle 24x26 - Ctrl+Alt+Click to reset"), "gridpoint24x26", &wr, this),
- grid_point25x27(_("Control handle 25x27:"), _("Control handle 25x27 - Ctrl+Alt+Click to reset"), "gridpoint25x27", &wr, this),
- grid_point28x30(_("Control handle 28x30:"), _("Control handle 28x30 - Ctrl+Alt+Click to reset"), "gridpoint28x30", &wr, this),
- grid_point29x31(_("Control handle 29x31:"), _("Control handle 29x31 - Ctrl+Alt+Click to reset"), "gridpoint29x31", &wr, this),
- grid_point32x33x34x35(_("Control handle 32x33x34x35:"), _("Control handle 32x33x34x35 - Ctrl+Alt+Click to reset"), "gridpoint32x33x34x35", &wr, this)
-
-
+ horizontalMirror(_("Mirror movements in horizontal"), _("Mirror movements in horizontal"), "horizontalMirror", &wr, this, false),
+ verticalMirror(_("Mirror movements in vertical"), _("Mirror movements in vertical"), "verticalMirror", &wr, this, false),
+ grid_point0(_("Control 0:"), _("Control 0 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint0", &wr, this),
+ grid_point1(_("Control 1:"), _("Control 1 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint1", &wr, this),
+ grid_point2(_("Control 2:"), _("Control 2 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint2", &wr, this),
+ grid_point3(_("Control 3:"), _("Control 3 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint3", &wr, this),
+ grid_point4(_("Control 4:"), _("Control 4 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint4", &wr, this),
+ grid_point5(_("Control 5:"), _("Control 5 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint5", &wr, this),
+ grid_point6(_("Control 6:"), _("Control 6 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint6", &wr, this),
+ grid_point7(_("Control 7:"), _("Control 7 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint7", &wr, this),
+ grid_point8x9(_("Control 8x9:"), _("Control 8x9 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint8x9", &wr, this),
+ grid_point10x11(_("Control 10x11:"), _("Control 10x11 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint10x11", &wr, this),
+ grid_point12(_("Control 12:"), _("Control 12 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint12", &wr, this),
+ grid_point13(_("Control 13:"), _("Control 13 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint13", &wr, this),
+ grid_point14(_("Control 14:"), _("Control 14 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint14", &wr, this),
+ grid_point15(_("Control 15:"), _("Control 15 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint15", &wr, this),
+ grid_point16(_("Control 16:"), _("Control 16 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint16", &wr, this),
+ grid_point17(_("Control 17:"), _("Control 17 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint17", &wr, this),
+ grid_point18(_("Control 18:"), _("Control 18 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint18", &wr, this),
+ grid_point19(_("Control 19:"), _("Control 19 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint19", &wr, this),
+ grid_point20x21(_("Control 20x21:"), _("Control 20x21 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint20x21", &wr, this),
+ grid_point22x23(_("Control 22x23:"), _("Control 22x23 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint22x23", &wr, this),
+ grid_point24x26(_("Control 24x26:"), _("Control 24x26 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint24x26", &wr, this),
+ grid_point25x27(_("Control 25x27:"), _("Control 25x27 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint25x27", &wr, this),
+ grid_point28x30(_("Control 28x30:"), _("Control 28x30 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint28x30", &wr, this),
+ grid_point29x31(_("Control 29x31:"), _("Control 29x31 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint29x31", &wr, this),
+ grid_point32x33x34x35(_("Control 32x33x34x35:"), _("Control 32x33x34x35 - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "gridpoint32x33x34x35", &wr, this),
+ expanded(false)
{
// register all your parameters here, so Inkscape knows which parameters this effect has:
- registerParameter( dynamic_cast<Parameter *>(&grid_point0) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point1) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point2) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point3) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point4) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point5) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point6) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point7) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point8x9) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point10x11) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point12) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point13) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point14) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point15) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point16) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point17) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point18) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point19) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point20x21) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point22x23) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point24x26) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point25x27) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point28x30) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point29x31) );
- registerParameter( dynamic_cast<Parameter *>(&grid_point32x33x34x35) );
+ registerParameter(&horizontalMirror);
+ registerParameter(&verticalMirror);
+ registerParameter(&grid_point0);
+ registerParameter(&grid_point1);
+ registerParameter(&grid_point2);
+ registerParameter(&grid_point3);
+ registerParameter(&grid_point4);
+ registerParameter(&grid_point5);
+ registerParameter(&grid_point6);
+ registerParameter(&grid_point7);
+ registerParameter(&grid_point8x9);
+ registerParameter(&grid_point10x11);
+ registerParameter(&grid_point12);
+ registerParameter(&grid_point13);
+ registerParameter(&grid_point14);
+ registerParameter(&grid_point15);
+ registerParameter(&grid_point16);
+ registerParameter(&grid_point17);
+ registerParameter(&grid_point18);
+ registerParameter(&grid_point19);
+ registerParameter(&grid_point20x21);
+ registerParameter(&grid_point22x23);
+ registerParameter(&grid_point24x26);
+ registerParameter(&grid_point25x27);
+ registerParameter(&grid_point28x30);
+ registerParameter(&grid_point29x31);
+ registerParameter(&grid_point32x33x34x35);
}
LPELattice2::~LPELattice2()
@@ -107,6 +108,10 @@ LPELattice2::~LPELattice2()
Geom::Piecewise<Geom::D2<Geom::SBasis> >
LPELattice2::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in)
{
+ PathVector pathv = path_from_piecewise(pwd2_in,0.001);
+ //this is because strange problems whith sb2 and LineSegment
+ PathVector cubic = pathv_to_cubicbezier(pathv);
+ Geom::Piecewise<Geom::D2<Geom::SBasis> > const &pwd2_in_linear_and_cubic = paths_to_pw(cubic);
D2<SBasis2d> sb2;
//Initialisation of the sb2
@@ -118,44 +123,45 @@ LPELattice2::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd
}
//Grouping the point params in a convenient vector
- std::vector<Geom::Point *> handles(36);
+
+ std::vector<Geom::Point > handles(36);
- handles[0] = &grid_point0;
- handles[1] = &grid_point1;
- handles[2] = &grid_point2;
- handles[3] = &grid_point3;
- handles[4] = &grid_point4;
- handles[5] = &grid_point5;
- handles[6] = &grid_point6;
- handles[7] = &grid_point7;
- handles[8] = &grid_point8x9;
- handles[9] = &grid_point8x9;
- handles[10] = &grid_point10x11;
- handles[11] = &grid_point10x11;
- handles[12] = &grid_point12;
- handles[13] = &grid_point13;
- handles[14] = &grid_point14;
- handles[15] = &grid_point15;
- handles[16] = &grid_point16;
- handles[17] = &grid_point17;
- handles[18] = &grid_point18;
- handles[19] = &grid_point19;
- handles[20] = &grid_point20x21;
- handles[21] = &grid_point20x21;
- handles[22] = &grid_point22x23;
- handles[23] = &grid_point22x23;
- handles[24] = &grid_point24x26;
- handles[25] = &grid_point25x27;
- handles[26] = &grid_point24x26;
- handles[27] = &grid_point25x27;
- handles[28] = &grid_point28x30;
- handles[29] = &grid_point29x31;
- handles[30] = &grid_point28x30;
- handles[31] = &grid_point29x31;
- handles[32] = &grid_point32x33x34x35;
- handles[33] = &grid_point32x33x34x35;
- handles[34] = &grid_point32x33x34x35;
- handles[35] = &grid_point32x33x34x35;
+ handles[0] = grid_point0;
+ handles[1] = grid_point1;
+ handles[2] = grid_point2;
+ handles[3] = grid_point3;
+ handles[4] = grid_point4;
+ handles[5] = grid_point5;
+ handles[6] = grid_point6;
+ handles[7] = grid_point7;
+ handles[8] = grid_point8x9;
+ handles[9] = grid_point8x9;
+ handles[10] = grid_point10x11;
+ handles[11] = grid_point10x11;
+ handles[12] = grid_point12;
+ handles[13] = grid_point13;
+ handles[14] = grid_point14;
+ handles[15] = grid_point15;
+ handles[16] = grid_point16;
+ handles[17] = grid_point17;
+ handles[18] = grid_point18;
+ handles[19] = grid_point19;
+ handles[20] = grid_point20x21;
+ handles[21] = grid_point20x21;
+ handles[22] = grid_point22x23;
+ handles[23] = grid_point22x23;
+ handles[24] = grid_point24x26;
+ handles[25] = grid_point25x27;
+ handles[26] = grid_point24x26;
+ handles[27] = grid_point25x27;
+ handles[28] = grid_point28x30;
+ handles[29] = grid_point29x31;
+ handles[30] = grid_point28x30;
+ handles[31] = grid_point29x31;
+ handles[32] = grid_point32x33x34x35;
+ handles[33] = grid_point32x33x34x35;
+ handles[34] = grid_point32x33x34x35;
+ handles[35] = grid_point32x33x34x35;
Geom::Point origin = Geom::Point(boundingbox_X.min(),boundingbox_Y.min());
@@ -185,7 +191,7 @@ LPELattice2::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd
// i = Upperleft corner of the considerated rectangle
// corner = actual corner of the rectangle
// origin = Upperleft point
- double dl = dot((*handles[corner+4*i] - (base + origin)), dir)/dot(dir,dir);
+ double dl = dot((handles[corner+4*i] - (base + origin)), dir)/dot(dir,dir);
sb2[dim][i][corner] = dl/( dim ? height : width )*pow(4.0,ui+vi);
}
}
@@ -195,8 +201,8 @@ LPELattice2::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd
Piecewise<D2<SBasis> > output;
output.push_cut(0.);
- for(unsigned i = 0; i < pwd2_in.size(); i++) {
- D2<SBasis> B = pwd2_in[i];
+ for(unsigned i = 0; i < pwd2_in_linear_and_cubic.size(); i++) {
+ D2<SBasis> B = pwd2_in_linear_and_cubic[i];
B[Geom::X] -= origin[Geom::X];
B[Geom::X]*= 1/width;
B[Geom::Y] -= origin[Geom::Y];
@@ -211,6 +217,7 @@ LPELattice2::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd
return output;
}
+
Gtk::Widget *
LPELattice2::newWidget()
{
@@ -218,12 +225,17 @@ LPELattice2::newWidget()
Gtk::VBox * vbox = Gtk::manage( new Gtk::VBox(Effect::newWidget()) );
vbox->set_border_width(5);
- Gtk::Button* resetButton = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset grid"))));
- resetButton->set_alignment(0.0, 0.5);
+ vbox->set_homogeneous(false);
+ vbox->set_spacing(6);
+ Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false,0));
+ Gtk::VBox * vboxExpander = Gtk::manage( new Gtk::VBox(Effect::newWidget()) );
+ vboxExpander->set_border_width(0);
+ vboxExpander->set_spacing(2);
+ Gtk::Button * resetButton = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset grid"))));
resetButton->signal_clicked().connect(sigc::mem_fun (*this,&LPELattice2::resetGrid));
- Gtk::Widget* resetButtonWidget = dynamic_cast<Gtk::Widget *>(resetButton);
- resetButtonWidget->set_tooltip_text("Reset grid");
- vbox->pack_start(*resetButtonWidget, true, true,2);
+ resetButton->set_size_request(140,30);
+ vbox->pack_start(*hbox, true,true,2);
+ hbox->pack_start(*resetButton, false, false,2);
std::vector<Parameter *>::iterator it = param_vector.begin();
while (it != param_vector.end()) {
if ((*it)->widget_is_visible) {
@@ -234,7 +246,11 @@ LPELattice2::newWidget()
}
Glib::ustring * tip = param->param_getTooltip();
if (widg) {
- vbox->pack_start(*widg, true, true, 2);
+ if (param->param_key == "horizontalMirror" || param->param_key == "verticalMirror") {
+ vbox->pack_start(*widg, true, true, 2);
+ } else {
+ vboxExpander->pack_start(*widg, true, true, 2);
+ }
if (tip) {
widg->set_tooltip_text(*tip);
} else {
@@ -246,14 +262,96 @@ LPELattice2::newWidget()
++it;
}
+
+ expander = Gtk::manage(new Gtk::Expander(Glib::ustring(_("Show Points"))));
+ expander->add(*vboxExpander);
+ expander->set_expanded(expanded);
+ vbox->pack_start(*expander, true, true, 2);
+ expander->property_expanded().signal_changed().connect(sigc::mem_fun(*this, &LPELattice2::on_expander_changed) );
return dynamic_cast<Gtk::Widget *>(vbox);
}
void
+LPELattice2::on_expander_changed()
+{
+ expanded = expander->get_expanded();
+ if(expander->get_expanded()){
+ expander->set_label (Glib::ustring(_("Hide Points")));
+ } else {
+ expander->set_label (Glib::ustring(_("Show Points")));
+ }
+}
+void
+LPELattice2::vertical(PointParam &paramA, PointParam &paramB, Geom::Line vert){
+ Geom::Point A = paramA;
+ Geom::Point B = paramB;
+ double Y = (A[Geom::Y] + B[Geom::Y])/2;
+ A[Geom::Y] = Y;
+ B[Geom::Y] = Y;
+ Geom::Point nearest = vert.pointAt(vert.nearestPoint(A));
+ double distA = Geom::distance(A,nearest);
+ double distB = Geom::distance(B,nearest);
+ double distanceMed = (distA + distB)/2;
+ if(A[Geom::X] > B[Geom::X]){
+ distanceMed *= -1;
+ }
+ A[Geom::X] = nearest[Geom::X] - distanceMed;
+ B[Geom::X] = nearest[Geom::X] + distanceMed;
+ paramA.param_setValue(A, true);
+ paramB.param_setValue(B, true);
+}
+
+void
+LPELattice2::horizontal(PointParam &paramA, PointParam &paramB, Geom::Line horiz){
+ Geom::Point A = paramA;
+ Geom::Point B = paramB;
+ double X = (A[Geom::X] + B[Geom::X])/2;
+ A[Geom::X] = X;
+ B[Geom::X] = X;
+ Geom::Point nearest = horiz.pointAt(horiz.nearestPoint(A));
+ double distA = Geom::distance(A,nearest);
+ double distB = Geom::distance(B,nearest);
+ double distanceMed = (distA + distB)/2;
+ if(A[Geom::Y] > B[Geom::Y]){
+ distanceMed *= -1;
+ }
+ A[Geom::Y] = nearest[Geom::Y] - distanceMed;
+ B[Geom::Y] = nearest[Geom::Y] + distanceMed;
+ paramA.param_setValue(A, true);
+ paramB.param_setValue(B, true);
+}
+
+void
LPELattice2::doBeforeEffect (SPLPEItem const* lpeitem)
{
original_bbox(lpeitem);
setDefaults();
+ Geom::Line vert(grid_point8x9.param_get_default(),grid_point10x11.param_get_default());
+ Geom::Line horiz(grid_point24x26.param_get_default(),grid_point25x27.param_get_default());
+ if(verticalMirror){
+ vertical(grid_point0, grid_point1,vert);
+ vertical(grid_point2, grid_point3,vert);
+ vertical(grid_point4, grid_point5,vert);
+ vertical(grid_point6, grid_point7,vert);
+ vertical(grid_point12, grid_point13,vert);
+ vertical(grid_point14, grid_point15,vert);
+ vertical(grid_point16, grid_point17,vert);
+ vertical(grid_point18, grid_point19,vert);
+ vertical(grid_point24x26, grid_point25x27,vert);
+ vertical(grid_point28x30, grid_point29x31,vert);
+ }
+ if(horizontalMirror){
+ horizontal(grid_point0, grid_point2,horiz);
+ horizontal(grid_point1, grid_point3,horiz);
+ horizontal(grid_point4, grid_point6,horiz);
+ horizontal(grid_point5, grid_point7,horiz);
+ horizontal(grid_point8x9, grid_point10x11,horiz);
+ horizontal(grid_point12, grid_point14,horiz);
+ horizontal(grid_point13, grid_point15,horiz);
+ horizontal(grid_point16, grid_point18,horiz);
+ horizontal(grid_point17, grid_point19,horiz);
+ horizontal(grid_point20x21, grid_point22x23,horiz);
+ }
SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
item->apply_to_clippath(item);
item->apply_to_mask(item);
@@ -367,36 +465,31 @@ LPELattice2::setDefaults()
void
LPELattice2::resetGrid()
{
- grid_point0.param_set_and_write_default();
- grid_point1.param_set_and_write_default();
- grid_point2.param_set_and_write_default();
- grid_point3.param_set_and_write_default();
- grid_point4.param_set_and_write_default();
- grid_point5.param_set_and_write_default();
- grid_point6.param_set_and_write_default();
- grid_point7.param_set_and_write_default();
- grid_point8x9.param_set_and_write_default();
- grid_point10x11.param_set_and_write_default();
- grid_point12.param_set_and_write_default();
- grid_point13.param_set_and_write_default();
- grid_point14.param_set_and_write_default();
- grid_point15.param_set_and_write_default();
- grid_point16.param_set_and_write_default();
- grid_point17.param_set_and_write_default();
- grid_point18.param_set_and_write_default();
- grid_point19.param_set_and_write_default();
- grid_point20x21.param_set_and_write_default();
- grid_point22x23.param_set_and_write_default();
- grid_point24x26.param_set_and_write_default();
- grid_point25x27.param_set_and_write_default();
- grid_point28x30.param_set_and_write_default();
- grid_point29x31.param_set_and_write_default();
- grid_point32x33x34x35.param_set_and_write_default();
- //todo:this hack is only to reposition the knots on reser grid button
- //Better update path effect in LPEITEM
- SPDesktop * desktop = SP_ACTIVE_DESKTOP;
- tools_switch(desktop, TOOLS_SELECT);
- tools_switch(desktop, TOOLS_NODES);
+ grid_point0.param_set_default();
+ grid_point1.param_set_default();
+ grid_point2.param_set_default();
+ grid_point3.param_set_default();
+ grid_point4.param_set_default();
+ grid_point5.param_set_default();
+ grid_point6.param_set_default();
+ grid_point7.param_set_default();
+ grid_point8x9.param_set_default();
+ grid_point10x11.param_set_default();
+ grid_point12.param_set_default();
+ grid_point13.param_set_default();
+ grid_point14.param_set_default();
+ grid_point15.param_set_default();
+ grid_point16.param_set_default();
+ grid_point17.param_set_default();
+ grid_point18.param_set_default();
+ grid_point19.param_set_default();
+ grid_point20x21.param_set_default();
+ grid_point22x23.param_set_default();
+ grid_point24x26.param_set_default();
+ grid_point25x27.param_set_default();
+ grid_point28x30.param_set_default();
+ grid_point29x31.param_set_default();
+ grid_point32x33x34x35.param_set_default();
}
void
diff --git a/src/live_effects/lpe-lattice2.h b/src/live_effects/lpe-lattice2.h
index 461f835c6..086bdab7e 100644
--- a/src/live_effects/lpe-lattice2.h
+++ b/src/live_effects/lpe-lattice2.h
@@ -18,10 +18,10 @@
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-
+#include <gtkmm.h>
#include "live_effects/parameter/enum.h"
#include "live_effects/effect.h"
-#include "live_effects/parameter/pointreseteable.h"
+#include "live_effects/parameter/point.h"
#include "live_effects/lpegroupbbox.h"
namespace Inkscape {
@@ -43,8 +43,14 @@ public:
virtual void calculateCurve(Geom::Point a,Geom::Point b, SPCurve *c, bool horizontal, bool move);
+ virtual void vertical(PointParam &paramA,PointParam &paramB, Geom::Line vert);
+
+ virtual void horizontal(PointParam &paramA,PointParam &paramB,Geom::Line horiz);
+
virtual void setDefaults();
+ virtual void on_expander_changed();
+
virtual void resetGrid();
//virtual void original_bbox(SPLPEItem const* lpeitem, bool absolute = false);
@@ -56,31 +62,36 @@ protected:
void addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec);
private:
- PointReseteableParam grid_point0;
- PointReseteableParam grid_point1;
- PointReseteableParam grid_point2;
- PointReseteableParam grid_point3;
- PointReseteableParam grid_point4;
- PointReseteableParam grid_point5;
- PointReseteableParam grid_point6;
- PointReseteableParam grid_point7;
- PointReseteableParam grid_point8x9;
- PointReseteableParam grid_point10x11;
- PointReseteableParam grid_point12;
- PointReseteableParam grid_point13;
- PointReseteableParam grid_point14;
- PointReseteableParam grid_point15;
- PointReseteableParam grid_point16;
- PointReseteableParam grid_point17;
- PointReseteableParam grid_point18;
- PointReseteableParam grid_point19;
- PointReseteableParam grid_point20x21;
- PointReseteableParam grid_point22x23;
- PointReseteableParam grid_point24x26;
- PointReseteableParam grid_point25x27;
- PointReseteableParam grid_point28x30;
- PointReseteableParam grid_point29x31;
- PointReseteableParam grid_point32x33x34x35;
+ BoolParam horizontalMirror;
+ BoolParam verticalMirror;
+ PointParam grid_point0;
+ PointParam grid_point1;
+ PointParam grid_point2;
+ PointParam grid_point3;
+ PointParam grid_point4;
+ PointParam grid_point5;
+ PointParam grid_point6;
+ PointParam grid_point7;
+ PointParam grid_point8x9;
+ PointParam grid_point10x11;
+ PointParam grid_point12;
+ PointParam grid_point13;
+ PointParam grid_point14;
+ PointParam grid_point15;
+ PointParam grid_point16;
+ PointParam grid_point17;
+ PointParam grid_point18;
+ PointParam grid_point19;
+ PointParam grid_point20x21;
+ PointParam grid_point22x23;
+ PointParam grid_point24x26;
+ PointParam grid_point25x27;
+ PointParam grid_point28x30;
+ PointParam grid_point29x31;
+ PointParam grid_point32x33x34x35;
+
+ bool expanded;
+ Gtk::Expander * expander;
LPELattice2(const LPELattice2&);
LPELattice2& operator=(const LPELattice2&);
diff --git a/src/live_effects/lpe-offset.cpp b/src/live_effects/lpe-offset.cpp
index dc91775b7..ba7179476 100644
--- a/src/live_effects/lpe-offset.cpp
+++ b/src/live_effects/lpe-offset.cpp
@@ -42,7 +42,9 @@ LPEOffset::~LPEOffset()
void
LPEOffset::doOnApply(SPLPEItem const* lpeitem)
{
- offset_pt.param_set_and_write_new_value(*(SP_SHAPE(lpeitem)->_curve->first_point()));
+ Geom::Point offset = *(SP_SHAPE(lpeitem)->_curve->first_point());
+ offset_pt.param_update_default(offset);
+ offset_pt.param_setValue(offset,true);
}
static void append_half_circle(Geom::Piecewise<Geom::D2<Geom::SBasis> > &pwd2,
diff --git a/src/live_effects/lpe-parallel.cpp b/src/live_effects/lpe-parallel.cpp
index bb37fd42c..aa7405607 100644
--- a/src/live_effects/lpe-parallel.cpp
+++ b/src/live_effects/lpe-parallel.cpp
@@ -72,8 +72,9 @@ LPEParallel::doOnApply (SPLPEItem const* lpeitem)
A = *(curve->first_point());
B = *(curve->last_point());
dir = unit_vector(B - A);
-
- offset_pt.param_set_and_write_new_value((A + B)/2 + dir.ccw() * 100);
+ Geom::Point offset = (A + B)/2 + dir.ccw() * 100;
+ offset_pt.param_update_default(offset);
+ offset_pt.param_setValue(offset, true);
}
Geom::Piecewise<Geom::D2<Geom::SBasis> >
diff --git a/src/live_effects/lpe-perspective-envelope.cpp b/src/live_effects/lpe-perspective-envelope.cpp
index b5ef26e2f..d60a13c23 100644
--- a/src/live_effects/lpe-perspective-envelope.cpp
+++ b/src/live_effects/lpe-perspective-envelope.cpp
@@ -19,9 +19,7 @@
#include "helper/geom.h"
#include "display/curve.h"
#include "svg/svg.h"
-#include "ui/tools-switch.h"
#include <gsl/gsl_linalg.h>
-#include "desktop.h"
using namespace Geom;
@@ -44,10 +42,10 @@ LPEPerspectiveEnvelope::LPEPerspectiveEnvelope(LivePathEffectObject *lpeobject)
Effect(lpeobject),
// initialise your parameters here:
deform_type(_("Type"), _("Select the type of deformation"), "deform_type", DeformationTypeConverter, &wr, this, DEFORMATION_PERSPECTIVE),
- Up_Left_Point(_("Top Left"), _("Top Left - Ctrl+Alt+Click to reset"), "Up_Left_Point", &wr, this),
- Up_Right_Point(_("Top Right"), _("Top Right - Ctrl+Alt+Click to reset"), "Up_Right_Point", &wr, this),
- Down_Left_Point(_("Down Left"), _("Down Left - Ctrl+Alt+Click to reset"), "Down_Left_Point", &wr, this),
- Down_Right_Point(_("Down Right"), _("Down Right - Ctrl+Alt+Click to reset"), "Down_Right_Point", &wr, this)
+ Up_Left_Point(_("Top Left"), _("Top Left - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "Up_Left_Point", &wr, this),
+ Up_Right_Point(_("Top Right"), _("Top Right - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "Up_Right_Point", &wr, this),
+ Down_Left_Point(_("Down Left"), _("Down Left - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "Down_Left_Point", &wr, this),
+ Down_Right_Point(_("Down Right"), _("Down Right - <b>Ctrl+Alt+Click</b>: reset, <b>Ctrl</b>: move along axes"), "Down_Right_Point", &wr, this)
{
// register all your parameters here, so Inkscape knows which parameters this effect has:
registerParameter( dynamic_cast<Parameter *>(&deform_type));
@@ -298,7 +296,7 @@ LPEPerspectiveEnvelope::newWidget()
Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false,0));
Gtk::Button* resetButton = Gtk::manage(new Gtk::Button(Gtk::Stock::CLEAR));
resetButton->signal_clicked().connect(sigc::mem_fun (*this,&LPEPerspectiveEnvelope::resetGrid));
- resetButton->set_size_request(140,45);
+ resetButton->set_size_request(140,30);
vbox->pack_start(*hbox, true,true,2);
hbox->pack_start(*resetButton, false, false,2);
return dynamic_cast<Gtk::Widget *>(vbox);
@@ -331,15 +329,10 @@ LPEPerspectiveEnvelope::setDefaults()
void
LPEPerspectiveEnvelope::resetGrid()
{
- Up_Left_Point.param_set_and_write_default();
- Up_Right_Point.param_set_and_write_default();
- Down_Right_Point.param_set_and_write_default();
- Down_Left_Point.param_set_and_write_default();
- //todo:this hack is only to reposition the knots on reser grid button
- //Better update path effect in LPEITEM
- SPDesktop * desktop = SP_ACTIVE_DESKTOP;
- tools_switch(desktop, TOOLS_SELECT);
- tools_switch(desktop, TOOLS_NODES);
+ Up_Left_Point.param_set_default();
+ Up_Right_Point.param_set_default();
+ Down_Right_Point.param_set_default();
+ Down_Left_Point.param_set_default();
}
void
@@ -347,8 +340,8 @@ LPEPerspectiveEnvelope::resetDefaults(SPItem const* item)
{
Effect::resetDefaults(item);
original_bbox(SP_LPE_ITEM(item));
- setDefaults();
resetGrid();
+ setDefaults();
}
void
diff --git a/src/live_effects/lpe-perspective-envelope.h b/src/live_effects/lpe-perspective-envelope.h
index 2f253882e..d3ff76445 100644
--- a/src/live_effects/lpe-perspective-envelope.h
+++ b/src/live_effects/lpe-perspective-envelope.h
@@ -19,7 +19,7 @@
#include "live_effects/parameter/enum.h"
#include "live_effects/effect.h"
-#include "live_effects/parameter/pointreseteable.h"
+#include "live_effects/parameter/point.h"
#include "live_effects/lpegroupbbox.h"
namespace Inkscape {
@@ -55,10 +55,10 @@ protected:
private:
EnumParam<unsigned> deform_type;
- PointReseteableParam Up_Left_Point;
- PointReseteableParam Up_Right_Point;
- PointReseteableParam Down_Left_Point;
- PointReseteableParam Down_Right_Point;
+ PointParam Up_Left_Point;
+ PointParam Up_Right_Point;
+ PointParam Down_Left_Point;
+ PointParam Down_Right_Point;
LPEPerspectiveEnvelope(const LPEPerspectiveEnvelope&);
LPEPerspectiveEnvelope& operator=(const LPEPerspectiveEnvelope&);
diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp
index 2b2efb1a9..1fe18dd5e 100644
--- a/src/live_effects/lpe-simplify.cpp
+++ b/src/live_effects/lpe-simplify.cpp
@@ -20,6 +20,7 @@
#include <2geom/generic-rect.h>
#include <2geom/interval.h>
#include "ui/icon-names.h"
+#include "util/units.h"
namespace Inkscape {
namespace LivePathEffect {
@@ -28,32 +29,37 @@ LPESimplify::LPESimplify(LivePathEffectObject *lpeobject)
: Effect(lpeobject),
steps(_("Steps:"),_("Change number of simplify steps "), "steps", &wr, this,1),
threshold(_("Roughly threshold:"), _("Roughly threshold:"), "threshold", &wr, this, 0.003),
- helper_size(_("Helper size:"), _("Helper size"), "helper_size", &wr, this, 2.),
- nodes(_("Helper nodes"), _("Show helper nodes"), "nodes", &wr, this, false,
- "", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")),
- handles(_("Helper handles"), _("Show helper handles"), "handles", &wr, this, false,
- "", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")),
+ smooth_angles(_("Smooth angles:"), _("Max degree difference on handles to preform a smooth"), "smooth_angles", &wr, this, 20.),
+ helper_size(_("Helper size:"), _("Helper size"), "helper_size", &wr, this, 5),
simplifyindividualpaths(_("Paths separately"), _("Simplifying paths (separately)"), "simplifyindividualpaths", &wr, this, false,
"", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")),
simplifyJustCoalesce(_("Just coalesce"), _("Simplify just coalesce"), "simplifyJustCoalesce", &wr, this, false,
"", INKSCAPE_ICON("on"), INKSCAPE_ICON("off"))
{
- registerParameter(dynamic_cast<Parameter *>(&steps));
- registerParameter(dynamic_cast<Parameter *>(&threshold));
- registerParameter(dynamic_cast<Parameter *>(&helper_size));
- registerParameter(dynamic_cast<Parameter *>(&nodes));
- registerParameter(dynamic_cast<Parameter *>(&handles));
- registerParameter(dynamic_cast<Parameter *>(&simplifyindividualpaths));
- registerParameter(dynamic_cast<Parameter *>(&simplifyJustCoalesce));
+ registerParameter(&steps);
+ registerParameter(&threshold);
+ registerParameter(&smooth_angles);
+ registerParameter(&helper_size);
+ registerParameter(&simplifyindividualpaths);
+ registerParameter(&simplifyJustCoalesce);
+
threshold.param_set_range(0.0001, Geom::infinity());
threshold.param_set_increments(0.0001, 0.0001);
threshold.param_set_digits(6);
+
steps.param_set_range(0, 100);
steps.param_set_increments(1, 1);
steps.param_set_digits(0);
- helper_size.param_set_range(0.1, 100);
- helper_size.param_set_increments(1, 1);
- helper_size.param_set_digits(1);
+
+ smooth_angles.param_set_range(0.0, 365.0);
+ smooth_angles.param_set_increments(10, 10);
+ smooth_angles.param_set_digits(2);
+
+ helper_size.param_set_range(0.0, 999.0);
+ helper_size.param_set_increments(5, 5);
+ helper_size.param_set_digits(2);
+
+ radiusHelperNodes = 6.0;
}
LPESimplify::~LPESimplify() {}
@@ -66,9 +72,9 @@ LPESimplify::doBeforeEffect (SPLPEItem const* lpeitem)
}
bbox = SP_ITEM(lpeitem)->visualBounds();
SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
+ radiusHelperNodes = helper_size;
item->apply_to_clippath(item);
item->apply_to_mask(item);
-
}
Gtk::Widget *
@@ -81,7 +87,6 @@ LPESimplify::newWidget()
vbox->set_spacing(2);
std::vector<Parameter *>::iterator it = param_vector.begin();
Gtk::HBox * buttons = Gtk::manage(new Gtk::HBox(true,0));
- Gtk::HBox * buttonsTwo = Gtk::manage(new Gtk::HBox(true,0));
while (it != param_vector.end()) {
if ((*it)->widget_is_visible) {
Parameter * param = *it;
@@ -91,19 +96,6 @@ LPESimplify::newWidget()
{
Glib::ustring * tip = param->param_getTooltip();
if (widg) {
- buttonsTwo->pack_start(*widg, true, true, 2);
- if (tip) {
- widg->set_tooltip_text(*tip);
- } else {
- widg->set_tooltip_text("");
- widg->set_has_tooltip(false);
- }
- }
- } else if (param->param_key == "nodes" ||
- param->param_key == "handles")
- {
- Glib::ustring * tip = param->param_getTooltip();
- if (widg) {
buttons->pack_start(*widg, true, true, 2);
if (tip) {
widg->set_tooltip_text(*tip);
@@ -112,7 +104,7 @@ LPESimplify::newWidget()
widg->set_has_tooltip(false);
}
}
- }else{
+ } else{
Glib::ustring * tip = param->param_getTooltip();
if (widg) {
Gtk::HBox * scalarParameter = dynamic_cast<Gtk::HBox *>(widg);
@@ -133,7 +125,6 @@ LPESimplify::newWidget()
++it;
}
vbox->pack_start(*buttons,true, true, 2);
- vbox->pack_start(*buttonsTwo,true, true, 2);
return dynamic_cast<Gtk::Widget *>(vbox);
}
@@ -154,9 +145,9 @@ LPESimplify::doEffect(SPCurve *curve) {
pathliv->Simplify(threshold * size);
}
}
- Geom::PathVector outres = Geom::parse_svg_path(pathliv->svg_dump_path());
- generateHelperPath(outres);
- curve->set_pathvector(outres);
+ Geom::PathVector result = Geom::parse_svg_path(pathliv->svg_dump_path());
+ generateHelperPathAndSmooth(result);
+ curve->set_pathvector(result);
SPDesktop* desktop = SP_ACTIVE_DESKTOP;
if(desktop && INK_IS_NODE_TOOL(desktop->event_context)){
Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(desktop->event_context);
@@ -165,16 +156,12 @@ LPESimplify::doEffect(SPCurve *curve) {
}
void
-LPESimplify::generateHelperPath(Geom::PathVector result)
+LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result)
{
- if(!handles && !nodes){
- return;
- }
-
if(steps < 1){
return;
}
-
+ Geom::PathVector tmpPath;
Geom::CubicBezier const *cubic = NULL;
for (Geom::PathVector::iterator path_it = result.begin(); path_it != result.end(); ++path_it) {
//Si está vacío...
@@ -183,11 +170,9 @@ LPESimplify::generateHelperPath(Geom::PathVector result)
}
//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
-
+ 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
+ SPCurve *nCurve = new SPCurve();
if (path_it->closed()) {
// if the path is closed, maybe we have to stop a bit earlier because the
// closing line segment has zerolength.
@@ -202,13 +187,50 @@ LPESimplify::generateHelperPath(Geom::PathVector result)
curve_endit = path_it->end_open();
}
}
- if(nodes){
+ if(helper_size > 0){
drawNode(curve_it1->initialPoint());
}
+ nCurve->moveto(curve_it1->initialPoint());
+ Geom::Point start = Geom::Point(0,0);
while (curve_it1 != curve_endit) {
cubic = dynamic_cast<Geom::CubicBezier const *>(&*curve_it1);
+ Geom::Point pointAt1 = curve_it1->initialPoint();
+ Geom::Point pointAt2 = curve_it1->finalPoint();
+ Geom::Point pointAt3 = curve_it1->finalPoint();
+ Geom::Point pointAt4 = curve_it1->finalPoint();
+ if (cubic) {
+ pointAt1 = (*cubic)[1];
+ pointAt2 = (*cubic)[2];
+ }
+ if(start == Geom::Point(0,0)){
+ start = pointAt1;
+ }
+
+ if(path_it->closed() && curve_it2 == curve_endit){
+ pointAt4 = start;
+ }
+ if(curve_it2 != curve_endit){
+ cubic = dynamic_cast<Geom::CubicBezier const *>(&*curve_it2);
+ if (cubic) {
+ pointAt4 = (*cubic)[1];
+ }
+ }
+ Geom::Ray ray1(pointAt2, pointAt3);
+ Geom::Ray ray2(pointAt3, pointAt4);
+ double angle1 = Geom::rad_to_deg(ray1.angle());
+ double angle2 = Geom::rad_to_deg(ray2.angle());
+ if((smooth_angles >= angle2 - angle1) && !are_near(pointAt4,pointAt3) && !are_near(pointAt2,pointAt3)){
+ double dist = Geom::distance(pointAt2,pointAt3);
+ Geom::Angle angleFixed = ray2.angle();
+ angleFixed -= Geom::Angle::from_degrees(180.0);
+ pointAt2 = Geom::Point::polar(angleFixed,dist) + pointAt3;
+ }
+ nCurve->curveto(pointAt1, pointAt2, curve_it1->finalPoint());
+ cubic = dynamic_cast<Geom::CubicBezier const *>(nCurve->last_segment());
if (cubic) {
- if(handles) {
+ pointAt1 = (*cubic)[1];
+ pointAt2 = (*cubic)[2];
+ if(helper_size > 0) {
if(!are_near((*cubic)[0],(*cubic)[1])){
drawHandle((*cubic)[1]);
drawHandleLine((*cubic)[0],(*cubic)[1]);
@@ -219,21 +241,26 @@ LPESimplify::generateHelperPath(Geom::PathVector result)
}
}
}
- if(nodes) {
+ if(helper_size > 0) {
drawNode(curve_it1->finalPoint());
}
++curve_it1;
- if(curve_it2 != curve_endit){
- ++curve_it2;
- }
+ ++curve_it2;
+ }
+ if (path_it->closed()) {
+ nCurve->closepath_current();
}
+ tmpPath.push_back(nCurve->get_pathvector()[0]);
+ nCurve->reset();
+ delete nCurve;
}
+ result = tmpPath;
}
void
LPESimplify::drawNode(Geom::Point p)
{
- double r = helper_size/0.67;
+ double r = radiusHelperNodes;
char const * svgd;
svgd = "M 0.55,0.5 A 0.05,0.05 0 0 1 0.5,0.55 0.05,0.05 0 0 1 0.45,0.5 0.05,0.05 0 0 1 0.5,0.45 0.05,0.05 0 0 1 0.55,0.5 Z M 0,0 1,0 1,1 0,1 Z";
Geom::PathVector pathv = sp_svg_read_pathv(svgd);
@@ -246,7 +273,7 @@ LPESimplify::drawNode(Geom::Point p)
void
LPESimplify::drawHandle(Geom::Point p)
{
- double r = helper_size/0.67;
+ double r = radiusHelperNodes;
char const * svgd;
svgd = "M 0.7,0.35 A 0.35,0.35 0 0 1 0.35,0.7 0.35,0.35 0 0 1 0,0.35 0.35,0.35 0 0 1 0.35,0 0.35,0.35 0 0 1 0.7,0.35 Z";
Geom::PathVector pathv = sp_svg_read_pathv(svgd);
@@ -261,8 +288,8 @@ LPESimplify::drawHandleLine(Geom::Point p,Geom::Point p2)
{
Geom::Path path;
path.start( p );
- double diameter = helper_size/0.67;
- if(helper_size > 0.0 && Geom::distance(p,p2) > (diameter * 0.35)){
+ double diameter = radiusHelperNodes;
+ if(helper_size > 0 && Geom::distance(p,p2) > (diameter * 0.35)){
Geom::Ray ray2(p, p2);
p2 = p2 - Geom::Point::polar(ray2.angle(),(diameter * 0.35));
}
diff --git a/src/live_effects/lpe-simplify.h b/src/live_effects/lpe-simplify.h
index 6acf2f2d4..c18c3ecdf 100644
--- a/src/live_effects/lpe-simplify.h
+++ b/src/live_effects/lpe-simplify.h
@@ -24,7 +24,7 @@ public:
virtual void doBeforeEffect (SPLPEItem const* lpeitem);
- virtual void generateHelperPath(Geom::PathVector result);
+ virtual void generateHelperPathAndSmooth(Geom::PathVector &result);
virtual Gtk::Widget * newWidget();
@@ -40,12 +40,12 @@ protected:
private:
ScalarParam steps;
ScalarParam threshold;
+ ScalarParam smooth_angles;
ScalarParam helper_size;
- ToggleButtonParam nodes;
- ToggleButtonParam handles;
ToggleButtonParam simplifyindividualpaths;
ToggleButtonParam simplifyJustCoalesce;
+ double radiusHelperNodes;
Geom::PathVector hp;
Geom::OptRect bbox;
diff --git a/src/live_effects/lpe-sketch.cpp b/src/live_effects/lpe-sketch.cpp
index 8ad0e616f..551dbe16a 100644
--- a/src/live_effects/lpe-sketch.cpp
+++ b/src/live_effects/lpe-sketch.cpp
@@ -240,7 +240,7 @@ LPESketch::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_
for (unsigned i = 0; i<nbiter_approxstrokes; i++){
//Basic steps:
- //- Choose a rdm seg [s0,s1], find coresponding [t0,t1],
+ //- Choose a rdm seg [s0,s1], find corresponding [t0,t1],
//- Pick a rdm perturbation delta(s), collect 'piece(t)+delta(s(t))' over [t0,t1] into output.
// pick a point where to start the stroke (s0 = dist from start).
diff --git a/src/live_effects/lpe-test-doEffect-stack.cpp b/src/live_effects/lpe-test-doEffect-stack.cpp
index 03e3e7997..c6787aae1 100644
--- a/src/live_effects/lpe-test-doEffect-stack.cpp
+++ b/src/live_effects/lpe-test-doEffect-stack.cpp
@@ -28,6 +28,7 @@ LPEdoEffectStackTest::LPEdoEffectStackTest(LivePathEffectObject *lpeobject) :
registerParameter( dynamic_cast<Parameter *>(&path) );
point.set_oncanvas_looks(SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR, 0x00ff0000);
+ point.param_setValue(point,true);
}
LPEdoEffectStackTest::~LPEdoEffectStackTest()
diff --git a/src/live_effects/lpeobject.cpp b/src/live_effects/lpeobject.cpp
index d92c94d01..8e5ae568f 100644
--- a/src/live_effects/lpeobject.cpp
+++ b/src/live_effects/lpeobject.cpp
@@ -20,16 +20,6 @@
//#define LIVEPATHEFFECT_VERBOSE
-#include "sp-factory.h"
-
-namespace {
- SPObject* createLivepatheffect() {
- return new LivePathEffectObject();
- }
-
- bool livepatheffectRegistered = SPFactory::instance().registerObject("inkscape:path-effect", createLivepatheffect);
-}
-
static void livepatheffect_on_repr_attr_changed (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive, void * data);
static Inkscape::XML::NodeEventVector const livepatheffect_repr_events = {
diff --git a/src/live_effects/parameter/Makefile_insert b/src/live_effects/parameter/Makefile_insert
index f990f41c7..bd1c5b600 100644
--- a/src/live_effects/parameter/Makefile_insert
+++ b/src/live_effects/parameter/Makefile_insert
@@ -11,8 +11,6 @@ ink_common_sources += \
live_effects/parameter/random.h \
live_effects/parameter/point.cpp \
live_effects/parameter/point.h \
- live_effects/parameter/pointreseteable.cpp \
- live_effects/parameter/pointreseteable.h \
live_effects/parameter/enum.h \
live_effects/parameter/path-reference.cpp \
live_effects/parameter/path-reference.h \
diff --git a/src/live_effects/parameter/filletchamferpointarray.cpp b/src/live_effects/parameter/filletchamferpointarray.cpp
index 2ebe11b4b..e9d375b93 100644
--- a/src/live_effects/parameter/filletchamferpointarray.cpp
+++ b/src/live_effects/parameter/filletchamferpointarray.cpp
@@ -354,7 +354,7 @@ void FilletChamferPointArrayParam::set_pwd2(
last_pwd2_normal = pwd2_normal_in;
}
-void FilletChamferPointArrayParam::set_document_unit(Glib::ustring const * value_document_unit)
+void FilletChamferPointArrayParam::set_document_unit(Glib::ustring value_document_unit)
{
documentUnit = value_document_unit;
}
diff --git a/src/live_effects/parameter/filletchamferpointarray.h b/src/live_effects/parameter/filletchamferpointarray.h
index 6e5cce353..7849d5afb 100644
--- a/src/live_effects/parameter/filletchamferpointarray.h
+++ b/src/live_effects/parameter/filletchamferpointarray.h
@@ -53,7 +53,7 @@ public:
virtual void set_helper_size(int hs);
virtual void set_use_distance(bool use_knot_distance);
virtual void set_chamfer_steps(int value_chamfer_steps);
- virtual void set_document_unit(Glib::ustring const * value_document_unit);
+ virtual void set_document_unit(Glib::ustring value_document_unit);
virtual void set_unit(const gchar *abbr);
virtual void addCanvasIndicators(SPLPEItem const *lpeitem,
std::vector<Geom::PathVector> &hp_vec);
@@ -90,7 +90,7 @@ private:
int chamfer_steps;
bool use_distance;
const gchar *unit;
- Glib::ustring const * documentUnit;
+ Glib::ustring documentUnit;
Geom::PathVector hp;
Geom::Piecewise<Geom::D2<Geom::SBasis> > last_pwd2;
diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp
index 302818e55..4c4d2cd9c 100644
--- a/src/live_effects/parameter/point.cpp
+++ b/src/live_effects/parameter/point.cpp
@@ -26,7 +26,9 @@ namespace LivePathEffect {
PointParam::PointParam( const Glib::ustring& label, const Glib::ustring& tip,
const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
Effect* effect, const gchar *htip, Geom::Point default_value)
- : Geom::Point(default_value), Parameter(label, tip, key, wr, effect), defvalue(default_value)
+ : Parameter(label, tip, key, wr, effect),
+ defvalue(default_value),
+ knoth(NULL)
{
knot_shape = SP_KNOT_SHAPE_DIAMOND;
knot_mode = SP_KNOT_MODE_XOR;
@@ -43,7 +45,34 @@ PointParam::~PointParam()
void
PointParam::param_set_default()
{
- param_setValue(defvalue);
+ param_setValue(defvalue,true);
+}
+
+Geom::Point
+PointParam::param_get_default() const{
+ return defvalue;
+}
+
+void
+PointParam::param_update_default(Geom::Point newpoint)
+{
+ defvalue = newpoint;
+}
+
+void
+PointParam::param_setValue(Geom::Point newpoint, bool write)
+{
+ *dynamic_cast<Geom::Point *>( this ) = newpoint;
+ if(write){
+ Inkscape::SVGOStringStream os;
+ os << newpoint;
+ gchar * str = g_strdup(os.str().c_str());
+ param_write_to_repr(str);
+ g_free(str);
+ }
+ if(knoth){
+ knoth->update_knots();
+ }
}
bool
@@ -70,6 +99,12 @@ PointParam::param_getSVGValue() const
return str;
}
+void
+PointParam::param_transform_multiply(Geom::Affine const& postmul, bool /*set*/)
+{
+ param_setValue( (*this) * postmul, true);
+}
+
Gtk::Widget *
PointParam::param_newWidget()
{
@@ -96,29 +131,6 @@ PointParam::param_newWidget()
}
void
-PointParam::param_setValue(Geom::Point newpoint)
-{
- *dynamic_cast<Geom::Point *>( this ) = newpoint;
-}
-
-void
-PointParam::param_set_and_write_new_value (Geom::Point newpoint)
-{
- Inkscape::SVGOStringStream os;
- os << newpoint;
- gchar * str = g_strdup(os.str().c_str());
- param_write_to_repr(str);
- g_free(str);
-}
-
-void
-PointParam::param_transform_multiply(Geom::Affine const& postmul, bool /*set*/)
-{
- param_set_and_write_new_value( (*this) * postmul );
-}
-
-
-void
PointParam::set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color)
{
knot_shape = shape;
@@ -129,7 +141,7 @@ PointParam::set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint
class PointParamKnotHolderEntity : public KnotHolderEntity {
public:
PointParamKnotHolderEntity(PointParam *p) { this->pparam = p; }
- virtual ~PointParamKnotHolderEntity() {}
+ virtual ~PointParamKnotHolderEntity() { this->pparam->knoth = NULL;}
virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
virtual Geom::Point knot_get() const;
@@ -140,11 +152,25 @@ private:
};
void
-PointParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state)
+PointParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &origin, guint state)
{
- Geom::Point const s = snap_knot_position(p, state);
- pparam->param_setValue(s);
- sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
+ Geom::Point s = snap_knot_position(p, state);
+ if (state & GDK_CONTROL_MASK) {
+ Geom::Point A(origin[Geom::X],p[Geom::Y]);
+ Geom::Point B(p[Geom::X],origin[Geom::Y]);
+ double distanceA = Geom::distance(A,p);
+ double distanceB = Geom::distance(B,p);
+ if(distanceA > distanceB){
+ s = B;
+ } else {
+ s = A;
+ }
+ }
+ pparam->param_setValue(s, true);
+ SPLPEItem * splpeitem = dynamic_cast<SPLPEItem *>(item);
+ if(splpeitem){
+ sp_lpe_item_update_patheffect(splpeitem, false, false);
+ }
}
Geom::Point
@@ -154,19 +180,27 @@ PointParamKnotHolderEntity::knot_get() const
}
void
-PointParamKnotHolderEntity::knot_click(guint /*state*/)
+PointParamKnotHolderEntity::knot_click(guint state)
{
- g_print ("This is the handle associated to parameter '%s'\n", pparam->param_key.c_str());
+ if (state & GDK_CONTROL_MASK) {
+ if (state & GDK_MOD1_MASK) {
+ this->pparam->param_set_default();
+ SPLPEItem * splpeitem = dynamic_cast<SPLPEItem *>(item);
+ if(splpeitem){
+ sp_lpe_item_update_patheffect(splpeitem, false, false);
+ }
+ }
+ }
}
void
PointParam::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item)
{
+ knoth = knotholder;
PointParamKnotHolderEntity *e = new PointParamKnotHolderEntity(this);
// TODO: can we ditch handleTip() etc. because we have access to handle_tip etc. itself???
e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, handleTip(), knot_shape, knot_mode, knot_color);
knotholder->add(e);
-
}
} /* namespace LivePathEffect */
diff --git a/src/live_effects/parameter/point.h b/src/live_effects/parameter/point.h
index 319835bb3..471fbc993 100644
--- a/src/live_effects/parameter/point.h
+++ b/src/live_effects/parameter/point.h
@@ -20,6 +20,7 @@ namespace Inkscape {
namespace LivePathEffect {
+class PointParamKnotHolderEntity;
class PointParam : public Geom::Point, public Parameter {
public:
@@ -37,12 +38,10 @@ public:
bool param_readSVGValue(const gchar * strvalue);
gchar * param_getSVGValue() const;
inline const gchar *handleTip() const { return handle_tip ? handle_tip : param_tooltip.c_str(); }
-
- void param_setValue(Geom::Point newpoint);
+ void param_setValue(Geom::Point newpoint, bool write = false);
void param_set_default();
-
- void param_set_and_write_new_value(Geom::Point newpoint);
-
+ Geom::Point param_get_default() const;
+ void param_update_default(Geom::Point newpoint);
virtual void param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/);
void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color);
@@ -50,12 +49,12 @@ public:
virtual bool providesKnotHolderEntities() const { return true; }
virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
+ friend class PointParamKnotHolderEntity;
private:
PointParam(const PointParam&);
PointParam& operator=(const PointParam&);
-
Geom::Point defvalue;
-
+ KnotHolder *knoth;
SPKnotShapeType knot_shape;
SPKnotModeType knot_mode;
guint32 knot_color;
diff --git a/src/live_effects/parameter/pointreseteable.cpp b/src/live_effects/parameter/pointreseteable.cpp
deleted file mode 100644
index c0f8858b8..000000000
--- a/src/live_effects/parameter/pointreseteable.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include "ui/widget/registered-widget.h"
-#include "live_effects/parameter/pointreseteable.h"
-#include "live_effects/effect.h"
-#include "svg/svg.h"
-#include "svg/stringstream.h"
-#include "ui/widget/point.h"
-#include "widgets/icon.h"
-#include "inkscape.h"
-#include "verbs.h"
-#include "knotholder.h"
-#include <glibmm/i18n.h>
-#include "ui/tools-switch.h"
-#include "ui/tools/node-tool.h"
-
-// needed for on-canvas editting:
-#include "desktop.h"
-
-namespace Inkscape {
-
-namespace LivePathEffect {
-
-PointReseteableParam::PointReseteableParam( const Glib::ustring& label, const Glib::ustring& tip,
- const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
- Effect* effect, const gchar *htip, Geom::Point default_value)
- : Geom::Point(default_value), Parameter(label, tip, key, wr, effect), defvalue(default_value)
-{
- knot_shape = SP_KNOT_SHAPE_DIAMOND;
- knot_mode = SP_KNOT_MODE_XOR;
- knot_color = 0xffffff00;
- handle_tip = g_strdup(htip);
-}
-
-PointReseteableParam::~PointReseteableParam()
-{
- if (handle_tip)
- g_free(handle_tip);
-}
-
-void
-PointReseteableParam::param_set_default()
-{
- param_setValue(defvalue);
-}
-
-void
-PointReseteableParam::param_set_and_write_default()
-{
- param_set_and_write_new_value(defvalue);
-}
-
-void
-PointReseteableParam::param_update_default(Geom::Point newpoint)
-{
- this->defvalue = newpoint;
-}
-
-bool
-PointReseteableParam::param_readSVGValue(const gchar * strvalue)
-{
- gchar ** strarray = g_strsplit(strvalue, ",", 2);
- double newx, newy;
- unsigned int success = sp_svg_number_read_d(strarray[0], &newx);
- success += sp_svg_number_read_d(strarray[1], &newy);
- g_strfreev (strarray);
- if (success == 2) {
- param_setValue( Geom::Point(newx, newy) );
- return true;
- }
- return false;
-}
-
-gchar *
-PointReseteableParam::param_getSVGValue() const
-{
- Inkscape::SVGOStringStream os;
- os << *dynamic_cast<Geom::Point const *>( this );
- gchar * str = g_strdup(os.str().c_str());
- return str;
-}
-
-Gtk::Widget *
-PointReseteableParam::param_newWidget()
-{
- Inkscape::UI::Widget::RegisteredTransformedPoint * pointwdg = Gtk::manage(
- new Inkscape::UI::Widget::RegisteredTransformedPoint( param_label,
- param_tooltip,
- param_key,
- *param_wr,
- param_effect->getRepr(),
- param_effect->getSPDoc() ) );
- // TODO: fix to get correct desktop (don't use SP_ACTIVE_DESKTOP)
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- Geom::Affine transf = desktop->doc2dt();
- pointwdg->setTransform(transf);
- pointwdg->setValue( *this );
- pointwdg->clearProgrammatically();
- pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change point parameter"));
-
- Gtk::HBox * hbox = Gtk::manage( new Gtk::HBox() );
- static_cast<Gtk::HBox*>(hbox)->pack_start(*pointwdg, true, true);
- static_cast<Gtk::HBox*>(hbox)->show_all_children();
-
- return dynamic_cast<Gtk::Widget *> (hbox);
-}
-
-void
-PointReseteableParam::param_setValue(Geom::Point newpoint)
-{
- *dynamic_cast<Geom::Point *>( this ) = newpoint;
- if(SP_ACTIVE_DESKTOP){
- SPDesktop* desktop = SP_ACTIVE_DESKTOP;
- if (tools_isactive( desktop, TOOLS_NODES)) {
- Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>( desktop->event_context);
- nt->update_helperpath();
- }
- }
-}
-
-void
-PointReseteableParam::param_set_and_write_new_value (Geom::Point newpoint)
-{
- Inkscape::SVGOStringStream os;
- os << newpoint;
- gchar * str = g_strdup(os.str().c_str());
- param_write_to_repr(str);
- g_free(str);
-}
-
-void
-PointReseteableParam::param_transform_multiply(Geom::Affine const& postmul, bool /*set*/)
-{
- param_set_and_write_new_value( (*this) * postmul );
-}
-
-
-void
-PointReseteableParam::set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color)
-{
- knot_shape = shape;
- knot_mode = mode;
- knot_color = color;
-}
-
-class PointReseteableParamKnotHolderEntity : public KnotHolderEntity {
-public:
- PointReseteableParamKnotHolderEntity(PointReseteableParam *p) { this->pparam = p; }
- virtual ~PointReseteableParamKnotHolderEntity() {}
-
- virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
- virtual Geom::Point knot_get() const;
- virtual void knot_click(guint state);
-
-private:
- PointReseteableParam *pparam;
-};
-
-void
-PointReseteableParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state)
-{
- Geom::Point const s = snap_knot_position(p, state);
- pparam->param_setValue(s);
- sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
-}
-
-Geom::Point
-PointReseteableParamKnotHolderEntity::knot_get() const
-{
- return *pparam;
-}
-
-void
-PointReseteableParamKnotHolderEntity::knot_click(guint state)
-{
- if (state & GDK_CONTROL_MASK) {
- if (state & GDK_MOD1_MASK) {
- this->pparam->param_set_default();
- sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
- }
- }
-}
-
-void
-PointReseteableParam::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item)
-{
- PointReseteableParamKnotHolderEntity *e = new PointReseteableParamKnotHolderEntity(this);
- // TODO: can we ditch handleTip() etc. because we have access to handle_tip etc. itself???
- e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, handleTip(), knot_shape, knot_mode, knot_color);
- knotholder->add(e);
-}
-
-} /* 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/parameter/pointreseteable.h b/src/live_effects/parameter/pointreseteable.h
deleted file mode 100644
index 5ae1fdf02..000000000
--- a/src/live_effects/parameter/pointreseteable.h
+++ /dev/null
@@ -1,74 +0,0 @@
-#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_POINT_RESETEABLE_H
-#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_POINT_RESETEABLE_H
-
-/*
- * Inkscape::LivePathEffectParameters
- *
-* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include <glib.h>
-#include <2geom/point.h>
-
-#include "live_effects/parameter/parameter.h"
-
-#include "knot-holder-entity.h"
-
-namespace Inkscape {
-
-namespace LivePathEffect {
-
-class PointReseteableParamKnotHolderEntity;
-
-class PointReseteableParam : public Geom::Point, public Parameter {
-public:
- PointReseteableParam( const Glib::ustring& label,
- const Glib::ustring& tip,
- const Glib::ustring& key,
- Inkscape::UI::Widget::Registry* wr,
- Effect* effect,
- const gchar *handle_tip = NULL,
- Geom::Point default_value = Geom::Point(0,0) ); // tip for automatically associated on-canvas handle
- virtual ~PointReseteableParam();
-
- virtual Gtk::Widget * param_newWidget();
-
- bool param_readSVGValue(const gchar * strvalue);
- gchar * param_getSVGValue() const;
- inline const gchar *handleTip() const { return handle_tip ? handle_tip : param_tooltip.c_str(); }
-
- void param_setValue(Geom::Point newpoint);
- void param_set_default();
- void param_set_and_write_default();
- void param_update_default(Geom::Point newpoint);
-
- void param_set_and_write_new_value(Geom::Point newpoint);
-
- virtual void param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/);
-
- void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color);
-
- virtual bool providesKnotHolderEntities() const { return true; }
- virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
-
- friend class PointReseteableParamKnotHolderEntity;
-private:
- PointReseteableParam(const PointReseteableParam&);
- PointReseteableParam& operator=(const PointReseteableParam&);
-
- Geom::Point defvalue;
-
- SPKnotShapeType knot_shape;
- SPKnotModeType knot_mode;
- guint32 knot_color;
- gchar *handle_tip;
-};
-
-
-} //namespace LivePathEffect
-
-} //namespace Inkscape
-
-#endif