summaryrefslogtreecommitdiffstats
path: root/src/ui/tools/spray-tool.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-10-22 06:25:32 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-10-22 06:25:32 +0000
commit913cb932fefc97f72cc834beb4129f833ccdd25a (patch)
tree7e551f7f4e1c5f84f61c445691fbc92f6df536cb /src/ui/tools/spray-tool.cpp
parentworking 2 ways (diff)
downloadinkscape-913cb932fefc97f72cc834beb4129f833ccdd25a.tar.gz
inkscape-913cb932fefc97f72cc834beb4129f833ccdd25a.zip
improving spray tool
(bzr r14422.2.1)
Diffstat (limited to 'src/ui/tools/spray-tool.cpp')
-rw-r--r--src/ui/tools/spray-tool.cpp32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp
index 240d002ae..c6448f818 100644
--- a/src/ui/tools/spray-tool.cpp
+++ b/src/ui/tools/spray-tool.cpp
@@ -57,6 +57,9 @@
#include "livarot/Shape.h"
#include <2geom/circle.h>
#include <2geom/transforms.h>
+#include <2geom/path-intersection.h>
+#include <2geom/pathvector.h>
+#include <2geom/crossing.h>
#include "preferences.h"
#include "style.h"
#include "box3d.h"
@@ -380,7 +383,10 @@ static bool sp_spray_recursive(SPDesktop *desktop,
Inkscape::XML::Node *old_repr = item->getRepr();
Inkscape::XML::Node *parent = old_repr->parent();
Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc);
- copy->setAttribute("inkscape:spray-origin", item->getId());
+ std::stringstream original_id;
+ original_id << "#" << item->getId();
+ gchar const * spray_origin = original_id.str().c_str());
+ copy->setAttribute("inkscape:spray-origin", spray_origin);
parent->appendChild(copy);
SPObject *new_obj = doc->getObjectByRepr(copy);
@@ -394,44 +400,46 @@ static bool sp_spray_recursive(SPDesktop *desktop,
Geom::Point move = (Geom::Point(cos(tilt)*cos(dp)*dr/(1-ratio)+sin(tilt)*sin(dp)*dr/(1+ratio), -sin(tilt)*cos(dp)*dr/(1-ratio)+cos(tilt)*sin(dp)*dr/(1+ratio)))+(p-a->midpoint());
sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y]));
did = true;
- Geom::OptRect bbox = item_copied->desktopGeometricBounds();
+ Geom::OptRect bbox = item_copied->documentVisualBounds();
std::vector<SPItem*> items = desktop->getDocument()->getItemsInBox(desktop->dkey, *bbox);
for (std::vector<SPItem*>::const_iterator i=items.begin(); i!=items.end(); i++) {
SPItem *item_down = *i;
std::cout << item_down->getAttribute("inkscape:spray-origin") << "asdgfasdasas\n";
- if(item_down->getAttribute("inkscape:spray-origin") &&( strcmp(item_down->getAttribute("inkscape:spray-origin"),item->getId()) == 0 || strcmp(item_down->getId(),item->getId()) == 0)){
+ if(item_down->getAttribute("inkscape:spray-origin") &&( strcmp(item_down->getAttribute("inkscape:spray-origin"),spray_origin) == 0 || strcmp(item_down->getId(),item->getId()) == 0)){
if(!SP_IS_GROUP(item)){
SPShape *down_item_shape = dynamic_cast<SPShape *>(item_down);
if (down_item_shape) {
- Geom::PathVector c;
+ Geom::PathVector pathv;
SPPath *down_item_path = dynamic_cast<SPPath *>(down_item_shape);
if (down_item_path) {
- c = down_item_path->get_curve()->get_pathvector();
+ pathv = down_item_path->get_curve()->get_pathvector();
} else {
- c = down_item_shape->getCurve()->get_pathvector();
+ pathv = down_item_shape->getCurve()->get_pathvector();
}
- if (c) {
+ if (!pathv.empty()) {
SPShape *copied_item_shape = dynamic_cast<SPShape *>(item_copied);
if (copied_item_shape) {
- Geom::PathVector d;
+ Geom::PathVector pathv_other;
SPPath *copied_item_path = dynamic_cast<SPPath *>(copied_item_shape);
if (copied_item_path) {
- d = copied_item_path->get_curve()->get_pathvector();
+ pathv_other = copied_item_path->get_curve()->get_pathvector();
} else {
- d = copied_item_shape->getCurve()->get_pathvector();
+ pathv_other = copied_item_shape->getCurve()->get_pathvector();
}
- if (d) {
- Geom::CrossingSet cs = Geom::crossings(c,d);
+ if (!pathv_other.empty()) {
+ Geom::CrossingSet cs = Geom::crossings(pathv, pathv_other);
if(cs[0].size() == 0){
continue;
}
}
+ }
}
}
}
item_copied->deleteObject();
std::cout << item_down->getAttribute("inkscape:spray-origin") << "hasssss\n";
did = false;
+ break;
}
}
}