snapped-curve.cpp revision 68632bf474bc4b65c03f919fc60a6c7872adb912
/**
* \file src/snapped-curve.cpp
* \brief SnappedCurve class.
*
* Authors:
* Diederik van Lierop <mail@diedenrezi.nl>
*
* Released under GNU GPL, read the file 'COPYING' for more information.
*/
#include "snapped-curve.h"
#include "libnr/nr-values.h"
#include <libnr/nr-convert2geom.h>
// These two are needed for SP_ACTIVE_DESKTOP; this is a dirty hack
#include "desktop.h"
#include "inkscape.h"
Inkscape::SnappedCurve::SnappedCurve(Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, Geom::Coord const &snapped_tolerance, bool const &always_snap, Geom::Curve const *curve)
{
_second_tolerance = 0;
_second_always_snap = false;
_at_intersection = false;
}
{
_tolerance = 0;
_always_snap = false;
_second_tolerance = 0;
_second_always_snap = false;
_at_intersection = false;
}
{
}
Inkscape::SnappedPoint Inkscape::SnappedCurve::intersect(SnappedCurve const &curve, Geom::Point const &p) const
{
// Calculate the intersections of two curves, which are both within snapping range, and
// return only the closest intersection
// The point of intersection should be considered for snapping, but might be outside the snapping range
// PS: We need p (the location of the mouse pointer) for find out which intersection is the
// closest, as there might be multiple intersections of two curves
// There might be multiple intersections: find the closest
}
}
// Now we've found the closests intersection, return it as a SnappedPoint
// The intersection should in fact be returned in desktop coordinates, but for this
// we need a desktop: this is a dirty hack
// TODO: Investigate whether it is possible to use document coordinates everywhere
// in the snapper code. Only the mouse position should be in desktop coordinates, I guess.
// All paths are already in document coords and we are certainly not going to change THAT.
return SnappedPoint(from_2geom(best_p), Inkscape::SNAPTARGET_PATH_INTERSECTION, primaryC->getDistance(), primaryC->getTolerance(), primaryC->getAlwaysSnap(), true,
}
// No intersection
return SnappedPoint(Geom::Point(NR_HUGE, NR_HUGE), SNAPTARGET_UNDEFINED, NR_HUGE, 0, false, false, NR_HUGE, 0, false);
}
// search for the closest snapped line
{
bool success = false;
result = *i;
success = true;
}
}
return success;
}
// search for the closest intersection of two snapped curves, which are both member of the same collection
bool getClosestIntersectionCS(std::list<Inkscape::SnappedCurve> const &list, Geom::Point const &p, Inkscape::SnappedPoint &result)
{
bool success = false;
j++;
if (sp.getAtIntersection()) {
// if it's the first point
// or, if it's closer
// or, if it's just then look at the other distance
// (only relevant for snapped points which are at an intersection
bool const c3 = (sp.getDistance() == result.getDistance()) && (sp.getSecondDistance() < result.getSecondDistance());
// then prefer this point over the previous one
success = true;
}
}
}
}
return success;
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :