diff options
| author | Ted Gould <ted@gould.cx> | 2008-10-27 18:03:09 +0000 |
|---|---|---|
| committer | Ted Gould <ted@canonical.com> | 2008-10-27 18:03:09 +0000 |
| commit | 7dbe11bc23efa5f51a9b84e7d0f6dd16e63e0902 (patch) | |
| tree | 7d3a2b95b84a03a19cb132cdf88bea0ab6dc4773 /src/live_effects | |
| parent | Merging from trunk (diff) | |
| download | inkscape-7dbe11bc23efa5f51a9b84e7d0f6dd16e63e0902.tar.gz inkscape-7dbe11bc23efa5f51a9b84e7d0f6dd16e63e0902.zip | |
From trunk
(bzr r6885)
Diffstat (limited to 'src/live_effects')
| -rw-r--r-- | src/live_effects/effect.cpp | 2 | ||||
| -rw-r--r-- | src/live_effects/effect.h | 5 | ||||
| -rw-r--r-- | src/live_effects/lpe-bendpath.cpp | 7 | ||||
| -rw-r--r-- | src/live_effects/lpe-bendpath.h | 1 | ||||
| -rw-r--r-- | src/live_effects/lpe-curvestitch.cpp | 5 | ||||
| -rwxr-xr-x | src/live_effects/lpe-envelope.cpp | 7 | ||||
| -rwxr-xr-x | src/live_effects/lpe-envelope.h | 2 | ||||
| -rw-r--r-- | src/live_effects/lpe-knot.cpp | 18 | ||||
| -rw-r--r-- | src/live_effects/lpe-patternalongpath.cpp | 7 | ||||
| -rw-r--r-- | src/live_effects/lpe-patternalongpath.h | 2 | ||||
| -rw-r--r-- | src/live_effects/lpe-sketch.cpp | 23 | ||||
| -rw-r--r-- | src/live_effects/lpe-sketch.h | 5 | ||||
| -rw-r--r-- | src/live_effects/lpe-vonkoch.cpp | 8 | ||||
| -rw-r--r-- | src/live_effects/lpe-vonkoch.h | 2 | ||||
| -rw-r--r-- | src/live_effects/lpegroupbbox.cpp | 21 | ||||
| -rw-r--r-- | src/live_effects/lpeobject-reference.cpp | 2 |
16 files changed, 52 insertions, 65 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index ef886a749..a04100cd3 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -491,7 +491,7 @@ Effect::getHelperPaths(SPLPEItem *lpeitem) std::vector<Geom::PathVector> hp_vec; if (!SP_IS_SHAPE(lpeitem)) { - g_print ("How to handle helperpaths for non-shapes?\n"); + g_print ("How to handle helperpaths for non-shapes?\n"); // non-shapes are for example SPGroups. return hp_vec; } diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index 609778b46..8dd1354e2 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -129,12 +129,13 @@ public: virtual void setup_nodepath(Inkscape::NodePath::Path *np); + /// /todo: is this method really necessary? it causes UI inconsistensies... (johan) virtual void transform_multiply(Geom::Matrix const& postmul, bool set); - // TODO: providesKnotholder() is currently used as an indicator of whether a nodepath is + // /TODO: providesKnotholder() is currently used as an indicator of whether a nodepath is // created for an item or not. When we allow both at the same time, this needs rethinking! bool providesKnotholder(); - // TODO: in view of providesOwnFlashPaths() below, this is somewhat redundant + // /TODO: in view of providesOwnFlashPaths() below, this is somewhat redundant // (but spiro lpe still needs it!) virtual LPEPathFlashType pathFlashType() { return DEFAULT; } void addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp index c5cde7025..c3be57981 100644 --- a/src/live_effects/lpe-bendpath.cpp +++ b/src/live_effects/lpe-bendpath.cpp @@ -139,13 +139,6 @@ LPEBendPath::resetDefaults(SPItem * item) bend_path.set_new_value( path.toPwSb(), true ); } -void -LPEBendPath::transform_multiply(Geom::Matrix const& postmul, bool set) -{ - // TODO: implement correct transformation instead of this default behavior - Effect::transform_multiply(postmul, set); -} - } // namespace LivePathEffect } /* namespace Inkscape */ diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h index 20871bc0f..98421df88 100644 --- a/src/live_effects/lpe-bendpath.h +++ b/src/live_effects/lpe-bendpath.h @@ -39,7 +39,6 @@ public: virtual void resetDefaults(SPItem * item); - virtual void transform_multiply(Geom::Matrix const& postmul, bool set); private: PathParam bend_path; diff --git a/src/live_effects/lpe-curvestitch.cpp b/src/live_effects/lpe-curvestitch.cpp index 34c17a025..4404620be 100644 --- a/src/live_effects/lpe-curvestitch.cpp +++ b/src/live_effects/lpe-curvestitch.cpp @@ -179,6 +179,11 @@ LPECurveStitch::resetDefaults(SPItem * item) } } + +/** /todo check whether this special case is necessary. It seems to "bug" editing behavior: + * scaling an object with transforms preserved behaves differently from scaling with + * transforms optimized (difference caused by this special method). + */ void LPECurveStitch::transform_multiply(Geom::Matrix const& postmul, bool set) { diff --git a/src/live_effects/lpe-envelope.cpp b/src/live_effects/lpe-envelope.cpp index fad912df7..553390585 100755 --- a/src/live_effects/lpe-envelope.cpp +++ b/src/live_effects/lpe-envelope.cpp @@ -248,13 +248,6 @@ LPEEnvelope::resetDefaults(SPItem * item) bend_path4.set_new_value( path4.toPwSb(), true ); } -void -LPEEnvelope::transform_multiply(Geom::Matrix const& postmul, bool set) -{ - // TODO: implement correct transformation instead of this default behavior - Effect::transform_multiply(postmul, set); -} - } // namespace LivePathEffect } /* namespace Inkscape */ diff --git a/src/live_effects/lpe-envelope.h b/src/live_effects/lpe-envelope.h index 282169674..fe1d9561d 100755 --- a/src/live_effects/lpe-envelope.h +++ b/src/live_effects/lpe-envelope.h @@ -37,8 +37,6 @@ public: virtual void resetDefaults(SPItem * item); - virtual void transform_multiply(Geom::Matrix const& postmul, bool set); - private: PathParam bend_path1; PathParam bend_path2; diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 4504f4467..0ff1beccf 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -28,6 +28,8 @@ #include <2geom/path-intersection.h> #include <2geom/elliptical-arc.h> +#include <exception> + namespace Inkscape { namespace LivePathEffect { @@ -171,12 +173,12 @@ namespace LPEKnotNS { CrossingPoints::CrossingPoints(Geom::CrossingSet const &input, std::vector<Geom::Path> const &path) : std::vector<CrossingPoint>() { using namespace Geom; - g_print("JF>\nCrossing set content:\n"); +// g_print("JF>\nCrossing set content:\n"); for( unsigned i=0; i<input.size(); i++){ Crossings i_crossings = input[i]; for( unsigned n=0; n<i_crossings.size(); n++ ){ Crossing c = i_crossings[n]; - g_print("JF> (%u,%u) at times (%f,%f) ----->",c.a,c.b,c.ta,c.tb); +// g_print("JF> (%u,%u) at times (%f,%f) ----->",c.a,c.b,c.ta,c.tb); unsigned j = c.getOther(i); if (i<j || (i==j && c.ta<c.tb) ){ CrossingPoint cp; @@ -195,10 +197,10 @@ CrossingPoints::CrossingPoints(Geom::CrossingSet const &input, std::vector<Geom: cp.nj = std::find(input[j].begin(),input[j].end(),c_bar)-input[j].begin(); cp.sign = 1; push_back(cp); - g_print("i=%u, ni=%u, j=%u, nj=%u\n",cp.i,cp.ni,cp.j,cp.nj); +// g_print("i=%u, ni=%u, j=%u, nj=%u\n",cp.i,cp.ni,cp.j,cp.nj); } else{ - g_print("\n"); +// g_print("\n"); bool found = false; for( unsigned ii=0; ii<input.size(); ii++){ Crossings ii_crossings = input[ii]; @@ -207,7 +209,9 @@ CrossingPoints::CrossingPoints(Geom::CrossingSet const &input, std::vector<Geom: if (cc.b==c.a && cc.a==c.b && cc.ta==c.tb && cc.tb==c.ta) found = true; } } - assert( found ); + if (!found) { + throw std::exception(); + } } } } @@ -384,14 +388,14 @@ LPEKnot::doEffect_path (std::vector<Geom::Path> const &input_path) for(unsigned i=0;i<crossingTable.size();i++){ for(unsigned j=0;j<crossingTable[i].size();j++){ - g_print("JF>avant: %u,%u,%f,%f\n",crossingTable[i][j].a, crossingTable[i][j].b, crossingTable[i][j].ta, crossingTable[i][j].tb); +// g_print("JF>avant: %u,%u,%f,%f\n",crossingTable[i][j].a, crossingTable[i][j].b, crossingTable[i][j].ta, crossingTable[i][j].tb); } } crossingTable = crossingSet_remove_double(crossingTable); for(unsigned i=0;i<crossingTable.size();i++){ for(unsigned j=0;j<crossingTable[i].size();j++){ - g_print("JF>apres: %u,%u,%f,%f\n",crossingTable[i][j].a, crossingTable[i][j].b, crossingTable[i][j].ta, crossingTable[i][j].tb); +// g_print("JF>apres: %u,%u,%f,%f\n",crossingTable[i][j].a, crossingTable[i][j].b, crossingTable[i][j].ta, crossingTable[i][j].tb); } } diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp index 2240a0c3d..0e5011e51 100644 --- a/src/live_effects/lpe-patternalongpath.cpp +++ b/src/live_effects/lpe-patternalongpath.cpp @@ -195,13 +195,6 @@ LPEPatternAlongPath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > con return output; } -void -LPEPatternAlongPath::transform_multiply(Geom::Matrix const& postmul, bool set) -{ - // TODO: implement correct transformation instead of this default behavior - Effect::transform_multiply(postmul, set); -} - LPEFreehandShape::LPEFreehandShape(LivePathEffectObject *lpeobject) : LPEPatternAlongPath(lpeobject) { } diff --git a/src/live_effects/lpe-patternalongpath.h b/src/live_effects/lpe-patternalongpath.h index 10b9e8bc2..5adc049fb 100644 --- a/src/live_effects/lpe-patternalongpath.h +++ b/src/live_effects/lpe-patternalongpath.h @@ -32,8 +32,6 @@ public: virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in); - virtual void transform_multiply(Geom::Matrix const& postmul, bool set); - PathParam pattern; private: EnumParam<PAPCopyType> copytype; diff --git a/src/live_effects/lpe-sketch.cpp b/src/live_effects/lpe-sketch.cpp index a95d89398..38957a658 100644 --- a/src/live_effects/lpe-sketch.cpp +++ b/src/live_effects/lpe-sketch.cpp @@ -180,17 +180,6 @@ LPESketch::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_ Piecewise<D2<SBasis> > output; - - //init random parameters. - parallel_offset.resetRandomizer(); - strokelength_rdm.resetRandomizer(); - strokeoverlap_rdm.resetRandomizer(); - ends_tolerance.resetRandomizer(); - tremble_size.resetRandomizer(); - tgtlength_rdm.resetRandomizer(); - - - // some variables for futur use (for construction lines; compute arclength only once...) // notations will be : t = path time, s = distance from start along the path. Piecewise<SBasis> pathlength; @@ -304,6 +293,18 @@ LPESketch::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_ return output; } +void +LPESketch::doBeforeEffect (SPLPEItem *lpeitem) +{ + //init random parameters. + parallel_offset.resetRandomizer(); + strokelength_rdm.resetRandomizer(); + strokeoverlap_rdm.resetRandomizer(); + ends_tolerance.resetRandomizer(); + tremble_size.resetRandomizer(); + tgtlength_rdm.resetRandomizer(); +} + /* ######################## */ } //namespace LivePathEffect (setq default-directory "c:/Documents And Settings/jf/Mes Documents/InkscapeSVN") diff --git a/src/live_effects/lpe-sketch.h b/src/live_effects/lpe-sketch.h index f4881ac55..bca4e2447 100644 --- a/src/live_effects/lpe-sketch.h +++ b/src/live_effects/lpe-sketch.h @@ -27,11 +27,10 @@ public: LPESketch(LivePathEffectObject *lpeobject); virtual ~LPESketch(); -// Choose to implement one of the doEffect functions. You can delete or comment out the others. -// virtual void doEffect (SPCurve * curve); -// virtual std::vector<Geom::Path> doEffect_path (std::vector<Geom::Path> & path_in); virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in); + virtual void doBeforeEffect (SPLPEItem *lpeitem); + private: // add the parameters for your effect here: //PointParam testpointA; diff --git a/src/live_effects/lpe-vonkoch.cpp b/src/live_effects/lpe-vonkoch.cpp index 72d96f5a2..0f105ad60 100644 --- a/src/live_effects/lpe-vonkoch.cpp +++ b/src/live_effects/lpe-vonkoch.cpp @@ -305,14 +305,6 @@ LPEVonKoch::resetDefaults(SPItem * item) //generator.set_new_value(paths, true); } -void -LPEVonKoch::transform_multiply(Geom::Matrix const& postmul, bool set) -{ - // TODO: implement correct transformation instead of this default behavior - Effect::transform_multiply(postmul, set); -} - - } // namespace LivePathEffect } /* namespace Inkscape */ diff --git a/src/live_effects/lpe-vonkoch.h b/src/live_effects/lpe-vonkoch.h index 16964f527..7862cdbb5 100644 --- a/src/live_effects/lpe-vonkoch.h +++ b/src/live_effects/lpe-vonkoch.h @@ -55,8 +55,6 @@ public: virtual void doBeforeEffect(SPLPEItem * item); - virtual void transform_multiply(Geom::Matrix const& postmul, bool set); - //Usefull?? // protected: //virtual void addCanvasIndicators(SPLPEItem *lpeitem, std::vector<Geom::PathVector> &hp_vec); diff --git a/src/live_effects/lpegroupbbox.cpp b/src/live_effects/lpegroupbbox.cpp index 79e6857f0..3b1ece2ad 100644 --- a/src/live_effects/lpegroupbbox.cpp +++ b/src/live_effects/lpegroupbbox.cpp @@ -13,6 +13,16 @@ namespace Inkscape { namespace LivePathEffect { +/** + * \brief Updates the \c boundingbox_X and \c boundingbox_Y values from the geometric bounding box of \c lpeitem. + * + * \pre lpeitem must have an existing geometric boundingbox (usually this is guaranteed when: \code SP_SHAPE(lpeitem)->curve != NULL \endcode ) + It's not possible to run LPEs on items without their original-d having a bbox. + * \param lpeitem This is not allowed to be NULL. + * \param absolute Determines whether the bbox should be calculated of the untransformed lpeitem (\c absolute = \c false) + * or of the transformed lpeitem (\c absolute = \c true) using sp_item_i2doc_affine. + * \post Updated values of boundingbox_X and boundingbox_Y. These intervals are set to empty intervals when the precondition is not met. + */ void GroupBBoxEffect::original_bbox(SPLPEItem *lpeitem, bool absolute) { @@ -27,9 +37,14 @@ GroupBBoxEffect::original_bbox(SPLPEItem *lpeitem, bool absolute) transform = Geom::identity(); } - Geom::Rect itemBBox = *item->getBounds(transform, SPItem::GEOMETRIC_BBOX); // fixme: fix for when getBounds returns invalid Rect - boundingbox_X = itemBBox[Geom::X]; - boundingbox_Y = itemBBox[Geom::Y]; + boost::optional<Geom::Rect> bbox = item->getBounds(transform, SPItem::GEOMETRIC_BBOX); + if (bbox) { + boundingbox_X = (*bbox)[Geom::X]; + boundingbox_Y = (*bbox)[Geom::Y]; + } else { + boundingbox_X = Geom::Interval(); + boundingbox_Y = Geom::Interval(); + } } } // namespace LivePathEffect diff --git a/src/live_effects/lpeobject-reference.cpp b/src/live_effects/lpeobject-reference.cpp index f522ae56e..9163d1c91 100644 --- a/src/live_effects/lpeobject-reference.cpp +++ b/src/live_effects/lpeobject-reference.cpp @@ -11,8 +11,6 @@ #include "enums.h" #include "live_effects/lpeobject-reference.h" #include "live_effects/lpeobject.h" - -#include "prefs-utils.h" #include "uri.h" namespace Inkscape { |
