Code

Corects delete/delete[] issue. Fixes bug #613723.
[inkscape.git] / src / object-snapper.h
1 #ifndef SEEN_OBJECT_SNAPPER_H
2 #define SEEN_OBJECT_SNAPPER_H
4 /**
5  *  \file object-snapper.h
6  *  \brief Snapping things to objects.
7  *
8  * Authors:
9  *   Carl Hetherington <inkscape@carlh.net>
10  *   Diederik van Lierop <mail@diedenrezi.nl>
11  *
12  * Copyright (C) 2005 - 2008 Authors
13  *
14  * Released under GNU GPL, read the file 'COPYING' for more information
15  */
17 #include "snapper.h"
18 #include "sp-path.h"
19 #include "splivarot.h"
20 #include "snap-candidate.h"
22 struct SPNamedView;
23 struct SPItem;
24 struct SPObject;
26 namespace Inkscape
27 {
29 class ObjectSnapper : public Snapper
30 {
32 public:
33     ObjectSnapper(SnapManager *sm, Geom::Coord const d);
34     ~ObjectSnapper();
36     void guideFreeSnap(SnappedConstraints &sc,
37                    Geom::Point const &p,
38                    Geom::Point const &guide_normal) const;
40     void guideConstrainedSnap(SnappedConstraints &sc,
41                        Geom::Point const &p,
42                        Geom::Point const &guide_normal,
43                        SnapConstraint const &c) const;
45     bool ThisSnapperMightSnap() const;
47     Geom::Coord getSnapperTolerance() const; //returns the tolerance of the snapper in screen pixels (i.e. independent of zoom)
48     bool getSnapperAlwaysSnap() const; //if true, then the snapper will always snap, regardless of its tolerance
50     void freeSnap(SnappedConstraints &sc,
51                   Inkscape::SnapCandidatePoint const &p,
52                   Geom::OptRect const &bbox_to_snap,
53                   std::vector<SPItem const *> const *it,
54                   std::vector<SnapCandidatePoint> *unselected_nodes) const;
56     void constrainedSnap(SnappedConstraints &sc,
57                   Inkscape::SnapCandidatePoint const &p,
58                   Geom::OptRect const &bbox_to_snap,
59                   SnapConstraint const &c,
60                   std::vector<SPItem const *> const *it) const;
62 private:
63     //store some lists of candidates, points and paths, so we don't have to rebuild them for each point we want to snap
64     std::vector<SnapCandidateItem> *_candidates;
65     std::vector<SnapCandidatePoint> *_points_to_snap_to;
66     std::vector<SnapCandidatePath > *_paths_to_snap_to;
68     void _findCandidates(SPObject* parent,
69                        std::vector<SPItem const *> const *it,
70                        bool const &first_point,
71                        Geom::Rect const &bbox_to_snap,
72                        bool const _clip_or_mask,
73                        Geom::Matrix const additional_affine) const;
75     void _snapNodes(SnappedConstraints &sc,
76                       Inkscape::SnapCandidatePoint const &p,
77                       std::vector<SnapCandidatePoint> *unselected_nodes) const; // in desktop coordinates
79     void _snapTranslatingGuide(SnappedConstraints &sc,
80                      Geom::Point const &p,
81                      Geom::Point const &guide_normal) const;
83     void _collectNodes(Inkscape::SnapSourceType const &t,
84                   bool const &first_point) const;
86     void _snapPaths(SnappedConstraints &sc,
87                       Inkscape::SnapCandidatePoint const &p, // in desktop coordinates
88                       std::vector<Inkscape::SnapCandidatePoint> *unselected_nodes, // in desktop coordinates
89                       SPPath const *selected_path) const;
91     void _snapPathsConstrained(SnappedConstraints &sc,
92                  Inkscape::SnapCandidatePoint const &p, // in desktop coordinates
93                  SnapConstraint const &c) const;
95     bool isUnselectedNode(Geom::Point const &point, std::vector<Inkscape::SnapCandidatePoint> const *unselected_nodes) const;
97     void _collectPaths(Inkscape::SnapCandidatePoint const &p,
98                   bool const &first_point) const;
100     void _clear_paths() const;
101     Geom::PathVector* _getBorderPathv() const;
102     Geom::PathVector* _getPathvFromRect(Geom::Rect const rect) const;
103     void _getBorderNodes(std::vector<SnapCandidatePoint> *points) const;
105 }; // end of ObjectSnapper class
107 void getBBoxPoints(Geom::OptRect const bbox, std::vector<SnapCandidatePoint> *points, bool const isTarget, bool const includeCorners, bool const includeLineMidpoints, bool const includeObjectMidpoints);
109 } // end of namespace Inkscape
111 #endif