summaryrefslogtreecommitdiffstats
path: root/src/object-snapper.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2016-03-14 16:37:50 +0000
committerJabiertxof <jtx@jtx.marker.es>2016-03-14 16:37:50 +0000
commitb8d22beef5345210ad27cdc2685083aeae6f8f3b (patch)
treed69b8bfd19d3627a8425a1b265c2abf229b05354 /src/object-snapper.cpp
parentfixes for update to trunk (diff)
parent"Relative to" option for node alignment. (diff)
downloadinkscape-b8d22beef5345210ad27cdc2685083aeae6f8f3b.tar.gz
inkscape-b8d22beef5345210ad27cdc2685083aeae6f8f3b.zip
update to trunk
(bzr r13708.1.39)
Diffstat (limited to 'src/object-snapper.cpp')
-rw-r--r--src/object-snapper.cpp46
1 files changed, 7 insertions, 39 deletions
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index 634d56aa6..3e559ee7a 100644
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
@@ -239,7 +239,7 @@ void Inkscape::ObjectSnapper::_collectNodes(SnapSourceType const &t,
bool old_pref2 = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_ROTATION_CENTER);
if (old_pref2) {
std::vector<SPItem*> rotationSource=_snapmanager->getRotationCenterSource();
- for ( std::vector<SPItem*>::const_iterator itemlist = rotationSource.begin(); itemlist != rotationSource.end(); itemlist++) {
+ for ( std::vector<SPItem*>::const_iterator itemlist = rotationSource.begin(); itemlist != rotationSource.end(); ++itemlist) {
if ((*i).item == *itemlist) {
// don't snap to this item's rotation center
_snapmanager->snapprefs.setTargetSnappable(SNAPTARGET_ROTATION_CENTER, false);
@@ -637,54 +637,22 @@ void Inkscape::ObjectSnapper::_snapPathsConstrained(IntermSnapResults &isr,
constraint_line.appendNew<Geom::LineSegment>(p_max_on_cl);
constraint_path.push_back(constraint_line);
}
- // Length of constraint_path will always be one
bool strict_snapping = _snapmanager->snapprefs.getStrictSnapping();
// Find all intersections of the constrained path with the snap target candidates
- std::vector<Geom::Point> intersections;
for (std::vector<SnapCandidatePath >::const_iterator k = _paths_to_snap_to->begin(); k != _paths_to_snap_to->end(); ++k) {
if (k->path_vector && _allowSourceToSnapToTarget(p.getSourceType(), (*k).target_type, strict_snapping)) {
// Do the intersection math
- Geom::CrossingSet cs = Geom::crossings(constraint_path, *(k->path_vector));
- // Store the results as intersection points
- unsigned int index = 0;
- for (Geom::CrossingSet::const_iterator i = cs.begin(); i != cs.end(); ++i) {
- if (index >= constraint_path.size()) {
- break;
- }
- // Reconstruct and store the points of intersection
- for (Geom::Crossings::const_iterator m = (*i).begin(); m != (*i).end(); ++m) {
- intersections.push_back(constraint_path[index].pointAt((*m).ta));
- }
- index++;
- }
-
- //Geom::crossings will not consider the closing segment apparently, so we'll handle that separately here
- //TODO: This should have been fixed in rev. #9859, which makes this workaround obsolete
- for(Geom::PathVector::iterator it_pv = k->path_vector->begin(); it_pv != k->path_vector->end(); ++it_pv) {
- if (it_pv->closed()) {
- // Get the closing linesegment and convert it to a path
- Geom::Path cls;
- cls.close(false);
- cls.append(it_pv->back_closed());
- // Intersect that closing path with the constrained path
- Geom::Crossings cs = Geom::crossings(constraint_path.front(), cls);
- // Reconstruct and store the points of intersection
- index = 0; // assuming the constraint path vector has only one path
- for (Geom::Crossings::const_iterator m = cs.begin(); m != cs.end(); ++m) {
- intersections.push_back(constraint_path[index].pointAt((*m).ta));
- }
- }
- }
+ std::vector<Geom::PVIntersection> inters = constraint_path.intersect(*(k->path_vector));
- // Convert the collected points of intersection to snapped points
- for (std::vector<Geom::Point>::iterator p_inters = intersections.begin(); p_inters != intersections.end(); ++p_inters) {
+ // Convert the collected intersections to snapped points
+ for (std::vector<Geom::PVIntersection>::const_iterator i = inters.begin(); i != inters.end(); ++i) {
// Convert to desktop coordinates
- (*p_inters) = dt->doc2dt(*p_inters);
+ Geom::Point p_inters = dt->doc2dt(i->point());
// Construct a snapped point
- Geom::Coord dist = Geom::L2(p.getPoint() - *p_inters);
- SnappedPoint s = SnappedPoint(*p_inters, p.getSourceType(), p.getSourceNum(), k->target_type, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), true, false, k->target_bbox);
+ Geom::Coord dist = Geom::L2(p.getPoint() - p_inters);
+ SnappedPoint s = SnappedPoint(p_inters, p.getSourceType(), p.getSourceNum(), k->target_type, dist, getSnapperTolerance(), getSnapperAlwaysSnap(), true, false, k->target_bbox);
// Store the snapped point
if (dist <= tolerance) { // If the intersection is within snapping range, then we might snap to it
isr.points.push_back(s);