Code

Store cached icons to disk between runs, and invalidate/purge as needed.
[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,
61                   std::vector<SnapCandidatePoint> *unselected_nodes) const;
63 private:
64     //store some lists of candidates, points and paths, so we don't have to rebuild them for each point we want to snap
65     std::vector<SnapCandidateItem> *_candidates;
66     std::vector<SnapCandidatePoint> *_points_to_snap_to;
67     std::vector<SnapCandidatePath > *_paths_to_snap_to;
69     void _findCandidates(SPObject* parent,
70                        std::vector<SPItem const *> const *it,
71                        bool const &first_point,
72                        Geom::Rect const &bbox_to_snap,
73                        bool const _clip_or_mask,
74                        Geom::Matrix const additional_affine) const;
76     void _snapNodes(SnappedConstraints &sc,
77                       Inkscape::SnapCandidatePoint const &p, // in desktop coordinates
78                       std::vector<SnapCandidatePoint> *unselected_nodes,
79                       SnapConstraint const &c = SnapConstraint(),
80                       Geom::Point const &p_proj_on_constraint = Geom::Point()) const;
82     void _snapTranslatingGuide(SnappedConstraints &sc,
83                      Geom::Point const &p,
84                      Geom::Point const &guide_normal) const;
86     void _collectNodes(Inkscape::SnapSourceType const &t,
87                   bool const &first_point) const;
89     void _snapPaths(SnappedConstraints &sc,
90                       Inkscape::SnapCandidatePoint const &p, // in desktop coordinates
91                       std::vector<Inkscape::SnapCandidatePoint> *unselected_nodes, // in desktop coordinates
92                       SPPath const *selected_path) const;
94     void _snapPathsConstrained(SnappedConstraints &sc,
95                  Inkscape::SnapCandidatePoint const &p, // in desktop coordinates
96                  SnapConstraint const &c,
97                  Geom::Point const &p_proj_on_constraint) const;
99     bool isUnselectedNode(Geom::Point const &point, std::vector<Inkscape::SnapCandidatePoint> const *unselected_nodes) const;
101     void _collectPaths(Geom::Point p,
102                       Inkscape::SnapSourceType const source_type,
103                       bool const &first_point) const;
105     void _clear_paths() const;
106     Geom::PathVector* _getBorderPathv() const;
107     Geom::PathVector* _getPathvFromRect(Geom::Rect const rect) const;
108     void _getBorderNodes(std::vector<SnapCandidatePoint> *points) const;
110 }; // end of ObjectSnapper class
112 void getBBoxPoints(Geom::OptRect const bbox, std::vector<SnapCandidatePoint> *points, bool const isTarget, bool const includeCorners, bool const includeLineMidpoints, bool const includeObjectMidpoints);
114 } // end of namespace Inkscape
116 #endif