diff --git a/src/snap-candidate.h b/src/snap-candidate.h
index 13f1d069cc1c6d1c30f04c03bf0149cb15e4c610..772800be56daa25bc77771204081f95b8705522a 100644 (file)
--- a/src/snap-candidate.h
+++ b/src/snap-candidate.h
*/
//#include "snapped-point.h"
+#include "snap-enums.h"
+
struct SPItem; // forward declaration
namespace Inkscape {
-enum SnapTargetType {
- SNAPTARGET_UNDEFINED = 0,
- SNAPTARGET_GRID,
- SNAPTARGET_GRID_INTERSECTION,
- SNAPTARGET_GUIDE,
- SNAPTARGET_GUIDE_INTERSECTION,
- SNAPTARGET_GUIDE_ORIGIN,
- SNAPTARGET_GRID_GUIDE_INTERSECTION,
- SNAPTARGET_NODE_SMOOTH,
- SNAPTARGET_NODE_CUSP,
- SNAPTARGET_LINE_MIDPOINT,
- SNAPTARGET_OBJECT_MIDPOINT,
- SNAPTARGET_ROTATION_CENTER,
- SNAPTARGET_HANDLE,
- SNAPTARGET_PATH,
- SNAPTARGET_PATH_INTERSECTION,
- SNAPTARGET_BBOX_CORNER,
- SNAPTARGET_BBOX_EDGE,
- SNAPTARGET_BBOX_EDGE_MIDPOINT,
- SNAPTARGET_BBOX_MIDPOINT,
- SNAPTARGET_PAGE_BORDER,
- SNAPTARGET_PAGE_CORNER,
- SNAPTARGET_CONVEX_HULL_CORNER,
- SNAPTARGET_ELLIPSE_QUADRANT_POINT,
- SNAPTARGET_CENTER, // of ellipse
- SNAPTARGET_CORNER, // of image or of rectangle
- SNAPTARGET_TEXT_BASELINE,
- SNAPTARGET_CONSTRAINED_ANGLE
-};
-
-enum SnapSourceType {
- SNAPSOURCE_UNDEFINED = 0,
- SNAPSOURCE_BBOX_CORNER,
- SNAPSOURCE_BBOX_MIDPOINT,
- SNAPSOURCE_BBOX_EDGE_MIDPOINT,
- SNAPSOURCE_NODE_SMOOTH,
- SNAPSOURCE_NODE_CUSP,
- SNAPSOURCE_LINE_MIDPOINT,
- SNAPSOURCE_OBJECT_MIDPOINT,
- SNAPSOURCE_ROTATION_CENTER,
- SNAPSOURCE_HANDLE,
- SNAPSOURCE_PATH_INTERSECTION,
- SNAPSOURCE_GUIDE,
- SNAPSOURCE_GUIDE_ORIGIN,
- SNAPSOURCE_CONVEX_HULL_CORNER,
- SNAPSOURCE_ELLIPSE_QUADRANT_POINT,
- SNAPSOURCE_CENTER, // of ellipse
- SNAPSOURCE_CORNER, // of image or of rectangle
- SNAPSOURCE_TEXT_BASELINE
-};
-
/// Class to store data for points which are snap candidates, either as a source or as a target
class SnapCandidatePoint
{
public:
- SnapCandidatePoint(Geom::Point const &point, Inkscape::SnapSourceType const source, long const source_num, Inkscape::SnapTargetType const target, Geom::Rect const &bbox)
- : _point(point), _source_type(source), _target_type(target), _source_num(source_num), _target_bbox(bbox) {};
+ SnapCandidatePoint(Geom::Point const &point, Inkscape::SnapSourceType const source, long const source_num, Inkscape::SnapTargetType const target, Geom::OptRect const &bbox)
+ : _point(point),
+ _source_type(source),
+ _target_type(target),
+ _source_num(source_num),
+ _target_bbox(bbox)
+ {
+ };
SnapCandidatePoint(Geom::Point const &point, Inkscape::SnapSourceType const source, Inkscape::SnapTargetType const target)
- : _point(point), _source_type(source), _target_type(target)
+ : _point(point),
+ _source_type(source),
+ _target_type(target)
{
- _source_num = 0;
- _target_bbox = Geom::Rect();
+ _source_num = -1;
+ _target_bbox = Geom::OptRect();
}
- SnapCandidatePoint(Geom::Point const &point, Inkscape::SnapSourceType const source, long const source_num = 0)
- : _point(point), _source_type(source), _target_type(Inkscape::SNAPTARGET_UNDEFINED), _source_num(source_num) {_target_bbox = Geom::Rect();}
+ SnapCandidatePoint(Geom::Point const &point, Inkscape::SnapSourceType const source)
+ : _point(point),
+ _source_type(source),
+ _target_type(Inkscape::SNAPTARGET_UNDEFINED),
+ _source_num(-1)
+ {
+ _target_bbox = Geom::OptRect();
+ }
inline Geom::Point const & getPoint() const {return _point;}
inline Inkscape::SnapSourceType getSourceType() const {return _source_type;}
+ bool isSingleHandle() const {return (_source_type == SNAPSOURCE_NODE_HANDLE || _source_type == SNAPSOURCE_OTHER_HANDLE) && _source_num == -1;}
inline Inkscape::SnapTargetType getTargetType() const {return _target_type;}
inline long getSourceNum() const {return _source_num;}
- inline Geom::Rect const & getTargetBBox() const {return _target_bbox;}
+ void setSourceNum(long num) {_source_num = num;}
+ inline Geom::OptRect const getTargetBBox() const {return _target_bbox;}
private:
// Coordinates of the point
Inkscape::SnapSourceType _source_type;
Inkscape::SnapTargetType _target_type;
- //Sequence number of the source point within the set of points that is to be snapped. Starting at zero
+ //Sequence number of the source point within the set of points that is to be snapped.
+ // - Starts counting at zero, but only if there might be more points following (e.g. in the selector tool)
+ // - Minus one (-1) if we're sure that we have only a single point
long _source_num;
// If this is a target and it belongs to a bounding box, e.g. when the target type is
// SNAPTARGET_BBOX_EDGE_MIDPOINT, then _target_bbox stores the relevant bounding box
- Geom::Rect _target_bbox;
+ Geom::OptRect _target_bbox;
};
class SnapCandidateItem
{
public:
- SnapCandidatePath(Geom::PathVector* path, SnapTargetType target, bool edited = false)
- : path_vector(path), target_type(target), currently_being_edited(edited) {}
+ SnapCandidatePath(Geom::PathVector* path, SnapTargetType target, Geom::OptRect bbox, bool edited = false)
+ : path_vector(path), target_type(target), target_bbox(bbox), currently_being_edited(edited) {};
~SnapCandidatePath() {};
Geom::PathVector* path_vector;
SnapTargetType target_type;
+ Geom::OptRect target_bbox;
bool currently_being_edited; // true for the path that's currently being edited in the node tool (if any)
};