summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-11-14 17:32:14 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-11-14 17:32:14 +0000
commit151126ef45cb00bab461181388a433e751a27bc3 (patch)
treeb30b996c838fd8c346366040e4705215ae1d42f0 /src
parentFix a compile problem (diff)
downloadinkscape-151126ef45cb00bab461181388a433e751a27bc3.tar.gz
inkscape-151126ef45cb00bab461181388a433e751a27bc3.zip
adding default width
(bzr r14422.3.8)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/lpe-roughen.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp
index 2be3bae31..87046ef4a 100644
--- a/src/live_effects/lpe-roughen.cpp
+++ b/src/live_effects/lpe-roughen.cpp
@@ -20,6 +20,7 @@
#include "live_effects/parameter/parameter.h"
#include <boost/functional/hash.hpp>
#include "helper/geom.h"
+#include "sp-item-group.h"
#include <glibmm/i18n.h>
#include <cmath>
@@ -42,6 +43,35 @@ static const Util::EnumData<HandlesMethod> HandlesMethodData[HM_END] = {
static const Util::EnumDataConverter<HandlesMethod>
HMConverter(HandlesMethodData, HM_END);
+static void
+sp_get_better_default_size(SPItem *item, double &value)
+{
+ if (SP_IS_GROUP(item)) {
+ std::vector<SPItem*> const item_list = sp_item_group_item_list(SP_GROUP(item));
+ for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) {
+ SPItem *subitem = *iter;
+ value += sp_get_better_default_size(subitem, value);
+ }
+ if(item_list.size() > 0){
+ value /= item_list.size();
+ }
+ } else {
+ SPShape *shape = dynamic_cast<SPShape *>(item);
+ if (shape) {
+ SPCurve * c = NULL;
+ SPPath *path = dynamic_cast<SPPath *>(shape);
+ if (path) {
+ c = path->get_original_curve();
+ } else {
+ c = shape->getCurve();
+ }
+ if (c) {
+ value = Geom::length(paths_to_pw(c->get_pathvector()))/(c->get_segment_count () * 3);
+ }
+ }
+ }
+}
+
LPERoughen::LPERoughen(LivePathEffectObject *lpeobject)
: Effect(lpeobject),
// initialise your parameters here:
@@ -98,11 +128,13 @@ LPERoughen::~LPERoughen() {}
void LPERoughen::doOnApply(SPLPEItem const* lpeitem)
{
- //calculamos el tamaño mas optimo para el roughen en función del número de nodos y la distancia del trazado
+ SPLPEItem * splpeitem = const_cast<SPLPEItem *>(lpeitem);
+ double initial = 0;
+ sp_get_better_default_size(SP_ITEM(splpeitem), initial);
+ displace_x.param_set_value(initial, displace_x.defseed);
+ displace_y.param_set_value(initial, displace_y.defseed);
}
-
-
void LPERoughen::doBeforeEffect(SPLPEItem const *lpeitem)
{
if(spray_tool_friendly && seed == 0 && SP_OBJECT(lpeitem)->getId()){