summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-11-13 15:11:51 +0000
committerjabiertxof <jabier.arraiza@marker.es>2015-11-13 15:11:51 +0000
commite8ec23b80082d4c1c20675c83f5a6fad18c3392d (patch)
tree391a6b0d836b4d2fff3b56b0a9da3f132efd8cd5 /src
parentFixed a bug on Spray Friendly when SPLPEITEM has clones. POinted by Ivan Louette (diff)
downloadinkscape-e8ec23b80082d4c1c20675c83f5a6fad18c3392d.tar.gz
inkscape-e8ec23b80082d4c1c20675c83f5a6fad18c3392d.zip
Fix bug end node, start calculate size based in number of nodes and lenght
(bzr r14422.3.6)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/lpe-roughen.cpp67
-rw-r--r--src/live_effects/lpe-roughen.h1
2 files changed, 67 insertions, 1 deletions
diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp
index 00f7b8012..6b18cf14e 100644
--- a/src/live_effects/lpe-roughen.cpp
+++ b/src/live_effects/lpe-roughen.cpp
@@ -65,7 +65,7 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject)
true),
fixed_displacement(_("Fixed displacement"), _("Fixed displacement, 1/3 of segment length"),
"fixed_displacement", &wr, this, false),
- spray_tool_friendly(_("Spray Tool friendly"), _("For use with spray tool"),
+ spray_tool_friendly(_("Spray Tool friendly"), _("For use with spray tool in copy mode"),
"spray_tool_friendly", &wr, this, false)
{
registerParameter(&method);
@@ -96,6 +96,59 @@ LPERoughen::LPERoughen(LivePathEffectObject *lpeobject)
LPERoughen::~LPERoughen() {}
+void LPERoughen::doOnApply(SPLPEItem const* lpeitem)
+{
+ SPLPEItem* item = const_cast<SPLPEItem*>(lpeitem);
+ //calculamos el tamaño mas optimo para el roughen en función del número de nodos y la distancia del trazado
+}
+
+static void
+sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write)
+{
+ std::vector<SPItem*> const item_list = sp_item_group_item_list(group);
+
+ for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) {
+ SPObject *subitem = *iter;
+
+ SPGroup *subGroup = dynamic_cast<SPGroup *>(subitem);
+ if (subGroup) {
+ sp_group_perform_patheffect(subGroup, topgroup, write);
+ } else {
+ SPShape *subShape = dynamic_cast<SPShape *>(subitem);
+ if (subShape) {
+ SPCurve * c = NULL;
+
+ SPPath *subPath = dynamic_cast<SPPath *>(subShape);
+ if (subPath) {
+ c = subPath->get_original_curve();
+ } else {
+ c = subShape->getCurve();
+ }
+
+ // only run LPEs when the shape has a curve defined
+ if (c) {
+ c->transform(i2anc_affine(subitem, topgroup));
+ topgroup->performPathEffect(c);
+ c->transform(i2anc_affine(subitem, topgroup).inverse());
+ subShape->setCurve(c, TRUE);
+
+ if (write) {
+ Inkscape::XML::Node *repr = subitem->getRepr();
+ gchar *str = sp_svg_write_path(c->get_pathvector());
+ repr->setAttribute("d", str);
+#ifdef GROUP_VERBOSE
+ g_message("sp_group_perform_patheffect writes 'd' attribute");
+#endif
+ g_free(str);
+ }
+
+ c->unref();
+ }
+ }
+ }
+ }
+}
+
void LPERoughen::doBeforeEffect(SPLPEItem const *lpeitem)
{
if(spray_tool_friendly && seed == 0 && SP_OBJECT(lpeitem)->getId()){
@@ -228,6 +281,18 @@ void LPERoughen::doEffect(SPCurve *curve)
Geom::Point prev(0, 0);
Geom::Point last_move(0, 0);
nCurve->moveto(curve_it1->initialPoint());
+ if (path_it->closed()) {
+ 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();
+ }
+ }
while (curve_it1 != curve_endit) {
Geom::CubicBezier const *cubic = NULL;
cubic = dynamic_cast<Geom::CubicBezier const *>(&*curve_it1);
diff --git a/src/live_effects/lpe-roughen.h b/src/live_effects/lpe-roughen.h
index 6224c09fa..b12bd08af 100644
--- a/src/live_effects/lpe-roughen.h
+++ b/src/live_effects/lpe-roughen.h
@@ -45,6 +45,7 @@ public:
virtual void doEffect(SPCurve *curve);
virtual double sign(double randNumber);
+ virtual void doOnApply(SPLPEItem const* lpeitem);
virtual Geom::Point randomize(double max_lenght, bool is_node = false);
virtual Geom::Point randomize(double lenght, Geom::Point start, Geom::Point end);
virtual void doBeforeEffect(SPLPEItem const * lpeitem);