Code

change doEffect_path to default to calling pwd2 for all continuous subpaths
authorjohanengelen <johanengelen@users.sourceforge.net>
Wed, 9 Apr 2008 20:34:47 +0000 (20:34 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Wed, 9 Apr 2008 20:34:47 +0000 (20:34 +0000)
src/live_effects/effect.cpp
src/live_effects/effect.h
src/live_effects/lpe-bendpath.cpp

index 51a59f1a1d4cc02ea28ed8edfc3ae177ae06b7f1..d8a48535a15c2568647b1de831fc66f99a8ed6b8 100644 (file)
@@ -123,6 +123,7 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj)
 }
 
 Effect::Effect(LivePathEffectObject *lpeobject)
+    : concatenate_before_pwd2(false)
 {
     lpeobj = lpeobject;
     oncanvasedit_it = 0;
@@ -198,16 +199,29 @@ Effect::doEffect_nartbpath (NArtBpath * path_in)
 std::vector<Geom::Path>
 Effect::doEffect_path (std::vector<Geom::Path> & path_in)
 {
-    Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2_in;
-
-    for (unsigned int i=0; i < path_in.size(); i++) {
-        pwd2_in.concat( path_in[i].toPwSb() );
+    std::vector<Geom::Path> path_out;
+
+    if ( !concatenate_before_pwd2 ) {
+        // default behavior
+        for (unsigned int i=0; i < path_in.size(); i++) {
+            Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2_in = path_in[i].toPwSb();
+            Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2_out = doEffect_pwd2(pwd2_in);
+            std::vector<Geom::Path> path = Geom::path_from_piecewise( pwd2_out, LPE_CONVERSION_TOLERANCE);
+            // add the output path vector to the already accumulated vector:
+            for (unsigned int j=0; j < path.size(); j++) {
+                path_out.push_back(path[j]);
+            }
+        }
+    } else {
+      // concatenate the path into possibly discontinuous pwd2
+        Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2_in;
+        for (unsigned int i=0; i < path_in.size(); i++) {
+            pwd2_in.concat( path_in[i].toPwSb() );
+        }
+        Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2_out = doEffect_pwd2(pwd2_in);
+        path_out = Geom::path_from_piecewise( pwd2_out, LPE_CONVERSION_TOLERANCE);
     }
 
-    Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2_out = doEffect_pwd2(pwd2_in);
-
-    std::vector<Geom::Path> path_out = Geom::path_from_piecewise( pwd2_out, LPE_CONVERSION_TOLERANCE);
-
     return path_out;
 }
 
index be3cefecf035816ae22525673aea68720e4ba492..1726613c5f942904650429746b219ecb28563e8f 100644 (file)
@@ -121,11 +121,14 @@ protected:
 
     std::vector<Parameter *> param_vector;
     int oncanvasedit_it;
-
     Inkscape::UI::Widget::Registry wr;
 
     LivePathEffectObject *lpeobj;
 
+    // this boolean defaults to false, it concatenates the input path to one pwd2,
+    // instead of normally 'splitting' the path into continuous pwd2 paths.
+    bool concatenate_before_pwd2;
+
 private:
     Effect(const Effect&);
     Effect& operator=(const Effect&);
index 026c8fb5f593c3b612e4bd433a6ed276d5b6281f..d5bd532479f7b4c4749063d65f559ccd1262d4d4 100644 (file)
@@ -69,6 +69,8 @@ LPEBendPath::LPEBendPath(LivePathEffectObject *lpeobject) :
     prop_scale.param_set_digits(3);
     prop_scale.param_set_increments(0.01, 0.10);
 
+    concatenate_before_pwd2 = true;
+
     groupSpecialBehavior = false;
 }
 
@@ -82,26 +84,25 @@ LPEBendPath::doBeforeEffect (SPLPEItem *lpeitem)
 {
     if(SP_IS_GROUP(lpeitem))
     {
-    groupSpecialBehavior = true;
+        groupSpecialBehavior = true;
 
-            using namespace Geom;
-            Piecewise<D2<SBasis> > pwd2;
-            std::vector<Geom::Path> temppath;  
+        using namespace Geom;
+        Piecewise<D2<SBasis> > pwd2;
+        std::vector<Geom::Path> temppath;  
 
-            recursive_original_bbox(SP_GROUP(lpeitem), pwd2, temppath);
+        recursive_original_bbox(SP_GROUP(lpeitem), pwd2, temppath);
 
-    for (unsigned int i=0; i < temppath.size(); i++) {
-        pwd2.concat( temppath[i].toPwSb() );
+        for (unsigned int i=0; i < temppath.size(); i++) {
+            pwd2.concat( temppath[i].toPwSb() );
         }
 
-    D2<Piecewise<SBasis> > d2pw = make_cuts_independant(pwd2);
-    boundingbox_X = bounds_exact(d2pw[0]);
-    boundingbox_Y = bounds_exact(d2pw[1]);
+        D2<Piecewise<SBasis> > d2pw = make_cuts_independant(pwd2);
+        boundingbox_X = bounds_exact(d2pw[0]);
+        boundingbox_Y = bounds_exact(d2pw[1]);
     }    
 
 }
 
-
 Geom::Piecewise<Geom::D2<Geom::SBasis> >
 LPEBendPath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > & pwd2_in)
 {