summaryrefslogtreecommitdiffstats
path: root/src/live_effects/lpe-bendpath.cpp
diff options
context:
space:
mode:
authorBastien Bouclet <bastien.bouclet@gmail.com>2008-04-15 08:07:29 +0000
committerbgk <bgk@users.sourceforge.net>2008-04-15 08:07:29 +0000
commit592838081f391aa2492534a676e30ac363b02713 (patch)
tree00646c5e8d803e482199693a68c224a8ced9162e /src/live_effects/lpe-bendpath.cpp
parentfix include path (diff)
downloadinkscape-592838081f391aa2492534a676e30ac363b02713.tar.gz
inkscape-592838081f391aa2492534a676e30ac363b02713.zip
- Clean up LPE bounding box computing code
- Initial work to make the Perspective Path effect work with groups. Still not working correctly due to a bug in the bounding box code. (bzr r5448)
Diffstat (limited to 'src/live_effects/lpe-bendpath.cpp')
-rw-r--r--src/live_effects/lpe-bendpath.cpp67
1 files changed, 15 insertions, 52 deletions
diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp
index 49569d4b5..c37f34ce7 100644
--- a/src/live_effects/lpe-bendpath.cpp
+++ b/src/live_effects/lpe-bendpath.cpp
@@ -86,21 +86,8 @@ LPEBendPath::doBeforeEffect (SPLPEItem *lpeitem)
{
groupSpecialBehavior = true;
- using namespace Geom;
- Piecewise<D2<SBasis> > pwd2;
- std::vector<Geom::Path> temppath;
-
- recursive_original_bbox(SP_GROUP(lpeitem), pwd2, temppath);
-
- 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]);
+ original_bbox(lpeitem);
}
-
}
Geom::Piecewise<Geom::D2<Geom::SBasis> >
@@ -125,8 +112,8 @@ LPEBendPath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd
boundingbox_X = bounds_exact(x);
boundingbox_Y = bounds_exact(y);
}
- x-= boundingbox_X.min();
- y-= boundingbox_Y.middle();
+ x-= vertical_pattern.get_value() ? boundingbox_Y.min() : boundingbox_X.min();
+ y-= vertical_pattern.get_value() ? boundingbox_X.middle() : boundingbox_Y.middle();
double scaling = uskeleton.cuts.back()/boundingbox_X.extent();
@@ -148,43 +135,19 @@ LPEBendPath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd
void
LPEBendPath::resetDefaults(SPItem * item)
{
- if (SP_IS_PATH(item) || SP_IS_GROUP(item))
- {
- // set the bend path to run horizontally in the middle of the bounding box of the original path
- using namespace Geom;
- Piecewise<D2<SBasis> > pwd2;
- std::vector<Geom::Path> temppath;
-
- if (SP_IS_PATH(item))
- {
- //TODO : this won't work well with LPE stacking
- temppath = SVGD_to_2GeomPath( SP_OBJECT_REPR(item)->attribute("inkscape:original-d"));
- }
- else if (SP_IS_GROUP(item))
- {
- recursive_original_bbox(SP_GROUP(item), pwd2, temppath);
- }
-
- 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]);
-
- Point start(boundingbox_X.min(), (boundingbox_Y.max()+boundingbox_Y.min())/2);
- Point end(boundingbox_X.max(), (boundingbox_Y.max()+boundingbox_Y.min())/2);
-
- if ( Geom::are_near(start,end) ) {
- end += Point(1.,0.);
- }
-
- Geom::Path path;
- path.start( start );
- path.appendNew<Geom::LineSegment>( end );
- bend_path.param_set_and_write_new_value( path.toPwSb() );
+ original_bbox(SP_LPE_ITEM(item));
+
+ Geom::Point start(boundingbox_X.min(), (boundingbox_Y.max()+boundingbox_Y.min())/2);
+ Geom::Point end(boundingbox_X.max(), (boundingbox_Y.max()+boundingbox_Y.min())/2);
+
+ if ( Geom::are_near(start,end) ) {
+ end += Geom::Point(1.,0.);
}
+
+ Geom::Path path;
+ path.start( start );
+ path.appendNew<Geom::LineSegment>( end );
+ bend_path.param_set_and_write_new_value( path.toPwSb() );
}
void