summaryrefslogtreecommitdiffstats
path: root/src/live_effects
diff options
context:
space:
mode:
authorBastien Bouclet <bastien.bouclet@gmail.com>2008-05-17 10:47:58 +0000
committerbgk <bgk@users.sourceforge.net>2008-05-17 10:47:58 +0000
commit757daf2667d1ec00a67477597795cb8a3497fce1 (patch)
tree9f18a9740be39aea72a42d03f69c98700dbe8e0c /src/live_effects
parentWarning cleanup (diff)
downloadinkscape-757daf2667d1ec00a67477597795cb8a3497fce1.tar.gz
inkscape-757daf2667d1ec00a67477597795cb8a3497fce1.zip
Fix LPE for groups bounding box calculation by using the SPItem->getBounds method.
Some preliminary work for LPE stacking. (bzr r5683)
Diffstat (limited to '')
-rw-r--r--src/live_effects/lpegroupbbox.cpp80
-rw-r--r--src/live_effects/lpegroupbbox.h24
2 files changed, 22 insertions, 82 deletions
diff --git a/src/live_effects/lpegroupbbox.cpp b/src/live_effects/lpegroupbbox.cpp
index 50f7599c0..f797d0358 100644
--- a/src/live_effects/lpegroupbbox.cpp
+++ b/src/live_effects/lpegroupbbox.cpp
@@ -7,80 +7,34 @@
*/
#include "live_effects/lpegroupbbox.h"
-#include "sp-shape.h"
+
#include "sp-item.h"
-#include "sp-path.h"
-#include "sp-item-group.h"
+#include "libnr/nr-matrix-fns.h"
#include "libnr/n-art-bpath-2geom.h"
-#include "svg/svg.h"
-#include "ui/widget/scalar.h"
-
-#include <2geom/sbasis.h>
-#include <2geom/sbasis-geometric.h>
-#include <2geom/bezier-to-sbasis.h>
-#include <2geom/sbasis-to-bezier.h>
-#include <2geom/d2.h>
-#include <2geom/piecewise.h>
-
-#include <algorithm>
-
-using std::vector;
namespace Inkscape {
namespace LivePathEffect {
void
-GroupBBoxEffect::recursive_original_bbox(SPGroup *group, Geom::Piecewise<Geom::D2<Geom::SBasis> > & pwd2, std::vector<Geom::Path> & temppath)
+GroupBBoxEffect::original_bbox(SPLPEItem *lpeitem, bool absolute)
{
- std::vector<Geom::Path> tempsubpath;
- GSList const *item_list = sp_item_group_item_list(group);
-
- for ( GSList const *iter = item_list; iter; iter = iter->next )
- {
- SPObject *subitem = static_cast<SPObject *>(iter->data);
- if (SP_IS_PATH(subitem))
- {
- //if there is not an original-d, just take the d
- if(SP_OBJECT_REPR(subitem)->attribute("inkscape:original-d") != NULL)
- tempsubpath = SVGD_to_2GeomPath(SP_OBJECT_REPR(subitem)->attribute("inkscape:original-d"));
- else
- tempsubpath = SVGD_to_2GeomPath(SP_OBJECT_REPR(subitem)->attribute("d"));
-
- temppath.insert(temppath.end(), tempsubpath.begin(), tempsubpath.end());
- }
- else if (SP_IS_GROUP(subitem))
- {
- recursive_original_bbox(SP_GROUP(subitem), pwd2, temppath);
- }
+ // Get item bounding box
+ SPItem* item = SP_ITEM(lpeitem);
+
+ NR::Matrix transform;
+ if (absolute) {
+ transform = sp_item_i2doc_affine(item);
}
-}
-
-void
-GroupBBoxEffect::original_bbox(SPLPEItem *lpeitem)
-{
-
- using namespace Geom;
- Piecewise<D2<SBasis> > pwd2;
- std::vector<Geom::Path> temppath;
-
-
- if (SP_IS_PATH(lpeitem))
- {
- //TODO : this won't work well with LPE stacking
- temppath = SVGD_to_2GeomPath( SP_OBJECT_REPR(lpeitem)->attribute("inkscape:original-d"));
- }
- else if (SP_IS_GROUP(lpeitem))
- {
- recursive_original_bbox(SP_GROUP(lpeitem), pwd2, temppath);
- }
-
- for (unsigned int i=0; i < temppath.size(); i++) {
- pwd2.concat( temppath[i].toPwSb() );
+ else {
+ transform = NR::identity();
}
+
+ NR::Maybe<NR::Rect> itemBBox = item->getBounds(transform, SPItem::GEOMETRIC_BBOX);
- D2<Piecewise<SBasis> > d2pw = make_cuts_independant(pwd2);
- boundingbox_X = bounds_exact(d2pw[0]);
- boundingbox_Y = bounds_exact(d2pw[1]);
+ // NR to Geom glue
+ Geom::Rect geomBBox = Geom::Rect(itemBBox->min().to_2geom(), itemBBox->max().to_2geom());
+ boundingbox_X = geomBBox[Geom::X];
+ boundingbox_Y = geomBBox[Geom::Y];
}
} // namespace LivePathEffect
diff --git a/src/live_effects/lpegroupbbox.h b/src/live_effects/lpegroupbbox.h
index bf1fa0902..57577d20f 100644
--- a/src/live_effects/lpegroupbbox.h
+++ b/src/live_effects/lpegroupbbox.h
@@ -8,35 +8,21 @@
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "live_effects/effect.h"
-#include "live_effects/parameter/path.h"
-#include "live_effects/parameter/enum.h"
-#include "live_effects/parameter/bool.h"
+#include "sp-lpe-item.h"
-#include <2geom/sbasis.h>
-#include <2geom/sbasis-geometric.h>
-#include <2geom/bezier-to-sbasis.h>
-#include <2geom/sbasis-to-bezier.h>
-#include <2geom/d2.h>
-#include <2geom/piecewise.h>
+#include <2geom/interval.h>
namespace Inkscape {
namespace LivePathEffect {
class GroupBBoxEffect {
protected:
-//if we need information concerning the group Bounding box and coordinates of each subshapes.
+ // Bounding box of the item the path effect is applied on
Geom::Interval boundingbox_X;
Geom::Interval boundingbox_Y;
-//This set boundingbox_X and boundingbox_Y
- void original_bbox(SPLPEItem *lpeitem);
-
-//Here is a recursive function to calculate the bbox of a group
- void recursive_original_bbox(SPGroup *group, Geom::Piecewise<Geom::D2<Geom::SBasis> > & pwd2, std::vector<Geom::Path> & temppath);
-
-
-
+ //This sets boundingbox_X and boundingbox_Y
+ void original_bbox(SPLPEItem *lpeitem, bool absolute = false);
};
}; //namespace LivePathEffect