diff options
Diffstat (limited to 'src/snapped-point.h')
| -rw-r--r-- | src/snapped-point.h | 52 |
1 files changed, 33 insertions, 19 deletions
diff --git a/src/snapped-point.h b/src/snapped-point.h index b50207429..dbd672bdf 100644 --- a/src/snapped-point.h +++ b/src/snapped-point.h @@ -35,7 +35,7 @@ enum SnapTargetType { SNAPTARGET_BBOX_EDGE, SNAPTARGET_GRADIENT }; - + /// Class describing the result of an attempt to snap. class SnappedPoint { @@ -56,49 +56,64 @@ public: bool getSecondAlwaysSnap() const {return _second_always_snap;} Geom::Coord getPointerDistance() const {return _pointer_distance;} void setPointerDistance(Geom::Coord const d) {_pointer_distance = d;} - + /* This is the preferred method to find out which point we have snapped * to, because it only returns a point if snapping has actually occured * (by overwriting p) - */ + */ void getPoint(Geom::Point &p) const; - + /* This method however always returns a point, even if no snapping * has occured; A check should be implemented in the calling code * to check for snapping. Use this method only when really needed, e.g. * when the calling code is trying to snap multiple points and must * determine itself which point is most appropriate - */ + */ Geom::Point getPoint() const {return _point;} - + bool getAtIntersection() const {return _at_intersection;} - bool getFullyConstrained() const {return _fully_constrained;} + bool getFullyConstrained() const {return _fully_constrained;} bool getSnapped() const {return _distance < NR_HUGE;} Geom::Point getTransformation() const {return _transformation;} void setTransformation(Geom::Point const t) {_transformation = t;} void setTarget(SnapTargetType const target) {_target = target;} SnapTargetType getTarget() {return _target;} - + bool isOtherSnapBetter(SnappedPoint const &other_one, bool weighted) const; - + + /*void dump() const { + std::cout << "_point = " << _point << std::endl; + std::cout << "_target = " << _target << std::endl; + std::cout << "_at_intersection = " << _at_intersection << std::endl; + std::cout << "_fully_constrained = " << _fully_constrained << std::endl; + std::cout << "_distance = " << _distance << std::endl; + std::cout << "_tolerance = " << _tolerance << std::endl; + std::cout << "_always_snap = " << _always_snap << std::endl; + std::cout << "_second_distance = " << _second_distance << std::endl; + std::cout << "_second_tolerance = " << _second_tolerance << std::endl; + std::cout << "_second_always_snap = " << _second_always_snap << std::endl; + std::cout << "_transformation = " << _transformation << std::endl; + std::cout << "_pointer_distance = " << _pointer_distance << std::endl; + }*/ + protected: Geom::Point _point; // Location of the snapped point SnapTargetType _target; // Describes to what we've snapped to bool _at_intersection; // If true, the snapped point is at an intersection - bool _fully_constrained; // When snapping for example to a node, then the snap will be "fully constrained". + bool _fully_constrained; // When snapping for example to a node, then the snap will be "fully constrained". // When snapping to a line however, the snap is only partly constrained (i.e. only in one dimension) - + /* Distance from original point to snapped point. If the snapped point is at an intersection of e.g. two lines, then this is the distance to the closest - line */ - Geom::Coord _distance; - /* The snapping tolerance in screen pixels (depends on zoom)*/ + line */ + Geom::Coord _distance; + /* The snapping tolerance in screen pixels (depends on zoom)*/ Geom::Coord _tolerance; /* If true then "Always snap" is on */ bool _always_snap; - + /* If the snapped point is at an intersection of e.g. two lines, then this is - the distance to the fartest line */ + the distance to the fartest line */ Geom::Coord _second_distance; /* The snapping tolerance in screen pixels (depends on zoom)*/ Geom::Coord _second_tolerance; @@ -108,13 +123,12 @@ protected: Geom::Point _transformation; /* Distance from the un-transformed point to the mouse pointer, measured at the point in time when dragging started */ Geom::Coord _pointer_distance; -}; +}; -} +}// end of namespace Inkscape bool getClosestSP(std::list<Inkscape::SnappedPoint> &list, Inkscape::SnappedPoint &result); - #endif /* !SEEN_SNAPPEDPOINT_H */ /* |
