1 #ifndef SEEN_SNAP_CANDIDATE_H
2 #define SEEN_SNAP_CANDIDATE_H
4 /**
5 * \file snap-candidate.h
6 * \brief some utility classes to store various kinds of snap candidates.
7 *
8 * Authors:
9 * Diederik van Lierop <mail@diedenrezi.nl>
10 *
11 * Copyright (C) 2010 Authors
12 *
13 * Released under GNU GPL, read the file 'COPYING' for more information
14 */
16 //#include "snapped-point.h"
17 #include "snap-enums.h"
19 struct SPItem; // forward declaration
21 namespace Inkscape {
23 /// Class to store data for points which are snap candidates, either as a source or as a target
24 class SnapCandidatePoint
25 {
26 public:
27 SnapCandidatePoint(Geom::Point const &point, Inkscape::SnapSourceType const source, long const source_num, Inkscape::SnapTargetType const target, Geom::OptRect const &bbox)
28 : _point(point),
29 _source_type(source),
30 _target_type(target),
31 _source_num(source_num),
32 _target_bbox(bbox)
33 {
34 };
36 SnapCandidatePoint(Geom::Point const &point, Inkscape::SnapSourceType const source, Inkscape::SnapTargetType const target)
37 : _point(point),
38 _source_type(source),
39 _target_type(target)
40 {
41 _source_num = 0;
42 _target_bbox = Geom::OptRect();
43 }
45 SnapCandidatePoint(Geom::Point const &point, Inkscape::SnapSourceType const source, long const source_num = 0)
46 : _point(point),
47 _source_type(source),
48 _target_type(Inkscape::SNAPTARGET_UNDEFINED),
49 _source_num(source_num)
50 {
51 _target_bbox = Geom::OptRect();
52 }
54 inline Geom::Point const & getPoint() const {return _point;}
55 inline Inkscape::SnapSourceType getSourceType() const {return _source_type;}
56 inline Inkscape::SnapTargetType getTargetType() const {return _target_type;}
57 inline long getSourceNum() const {return _source_num;}
58 inline Geom::OptRect const getTargetBBox() const {return _target_bbox;}
60 private:
61 // Coordinates of the point
62 Geom::Point _point;
64 // If this SnapCandidatePoint is a snap source, then _source_type must be defined. If it
65 // is a snap target, then _target_type must be defined. If it's yet unknown whether it will
66 // be a source or target, then both may be defined
67 Inkscape::SnapSourceType _source_type;
68 Inkscape::SnapTargetType _target_type;
70 //Sequence number of the source point within the set of points that is to be snapped. Starting at zero
71 long _source_num;
73 // If this is a target and it belongs to a bounding box, e.g. when the target type is
74 // SNAPTARGET_BBOX_EDGE_MIDPOINT, then _target_bbox stores the relevant bounding box
75 Geom::OptRect _target_bbox;
76 };
78 class SnapCandidateItem
79 {
80 public:
81 SnapCandidateItem(SPItem* item, bool clip_or_mask, Geom::Matrix additional_affine)
82 : item(item), clip_or_mask(clip_or_mask), additional_affine(additional_affine) {}
83 ~SnapCandidateItem() {};
85 SPItem* item; // An item that is to be considered for snapping to
86 bool clip_or_mask; // If true, then item refers to a clipping path or a mask
88 /* To find out the absolute position of a clipping path or mask, we not only need to know
89 * the transformation of the clipping path or mask itself, but also the transformation of
90 * the object to which the clip or mask is being applied; that transformation is stored here
91 */
92 Geom::Matrix additional_affine;
93 }
94 ;
96 class SnapCandidatePath
97 {
99 public:
100 SnapCandidatePath(Geom::PathVector* path, SnapTargetType target, Geom::OptRect bbox, bool edited = false)
101 : path_vector(path), target_type(target), target_bbox(bbox), currently_being_edited(edited) {};
102 ~SnapCandidatePath() {};
104 Geom::PathVector* path_vector;
105 SnapTargetType target_type;
106 Geom::OptRect target_bbox;
107 bool currently_being_edited; // true for the path that's currently being edited in the node tool (if any)
109 };
111 } // end of namespace Inkscape
113 #endif /* !SEEN_SNAP_CANDIDATE_H */