~centralelyon2010/inkscape/imagelinks2

« back to all changes in this revision

Viewing changes to src/object-snapper.h

  • Committer: Diederik van Lierop
  • Date: 2009-12-24 20:10:43 UTC
  • Revision ID: diederik_van_lierop_mail_at-sign_diedenrezi_dot_nl-20091224201043-txzqbq2uvs8334ei
refactoring the snapping code (laying the groundwork for my next commit which reduces snap jitter)

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
{
47
47
 
48
48
public:
49
 
        ObjectSnapper(SnapManager *sm, Geom::Coord const d);
 
49
    ObjectSnapper(SnapManager *sm, Geom::Coord const d);
50
50
    ~ObjectSnapper();
51
51
 
52
 
        enum DimensionToSnap {
53
 
                GUIDE_TRANSL_SNAP_X, // For snapping a vertical guide (normal in the X-direction) to objects,
54
 
                GUIDE_TRANSL_SNAP_Y, // For snapping a horizontal guide (normal in the Y-direction) to objects
55
 
                ANGLED_GUIDE_TRANSL_SNAP, // For snapping an angled guide, while translating it accross the desktop
56
 
                TRANSL_SNAP_XY}; // All other cases; for snapping to objects, other than guides
57
 
 
58
 
        void guideFreeSnap(SnappedConstraints &sc,
59
 
                                   Geom::Point const &p,
60
 
                                   Geom::Point const &guide_normal) const;
61
 
 
62
 
        void guideConstrainedSnap(SnappedConstraints &sc,
63
 
                                           Geom::Point const &p,
64
 
                                           Geom::Point const &guide_normal,
65
 
                                           ConstraintLine const &c) const;
66
 
 
67
 
        bool ThisSnapperMightSnap() const;
68
 
        bool GuidesMightSnap() const;
69
 
 
70
 
        Geom::Coord getSnapperTolerance() const; //returns the tolerance of the snapper in screen pixels (i.e. independent of zoom)
71
 
        bool getSnapperAlwaysSnap() const; //if true, then the snapper will always snap, regardless of its tolerance
72
 
 
73
 
        void freeSnap(SnappedConstraints &sc,
74
 
                                  Inkscape::SnapPreferences::PointType const &t,
75
 
                                  Geom::Point const &p,
76
 
                                  SnapSourceType const &source_type,
77
 
                                  bool const &first_point,
78
 
                                  Geom::OptRect const &bbox_to_snap,
79
 
                                  std::vector<SPItem const *> const *it,
80
 
                                  std::vector<std::pair<Geom::Point, int> > *unselected_nodes) const;
81
 
 
82
 
        void constrainedSnap(SnappedConstraints &sc,
83
 
                                  Inkscape::SnapPreferences::PointType const &t,
84
 
                                  Geom::Point const &p,
85
 
                                  SnapSourceType const &source_type,
86
 
                                  bool const &first_point,
87
 
                                  Geom::OptRect const &bbox_to_snap,
88
 
                                  ConstraintLine const &c,
89
 
                                  std::vector<SPItem const *> const *it) const;
 
52
    enum DimensionToSnap {
 
53
        GUIDE_TRANSL_SNAP_X, // For snapping a vertical guide (normal in the X-direction) to objects,
 
54
        GUIDE_TRANSL_SNAP_Y, // For snapping a horizontal guide (normal in the Y-direction) to objects
 
55
        ANGLED_GUIDE_TRANSL_SNAP, // For snapping an angled guide, while translating it accross the desktop
 
56
        TRANSL_SNAP_XY}; // All other cases; for snapping to objects, other than guides
 
57
 
 
58
    void guideFreeSnap(SnappedConstraints &sc,
 
59
                   Geom::Point const &p,
 
60
                   Geom::Point const &guide_normal) const;
 
61
 
 
62
    void guideConstrainedSnap(SnappedConstraints &sc,
 
63
                       Geom::Point const &p,
 
64
                       Geom::Point const &guide_normal,
 
65
                       ConstraintLine const &c) const;
 
66
 
 
67
    bool ThisSnapperMightSnap() const;
 
68
    bool GuidesMightSnap() const;
 
69
 
 
70
    Geom::Coord getSnapperTolerance() const; //returns the tolerance of the snapper in screen pixels (i.e. independent of zoom)
 
71
    bool getSnapperAlwaysSnap() const; //if true, then the snapper will always snap, regardless of its tolerance
 
72
 
 
73
    void freeSnap(SnappedConstraints &sc,
 
74
                  Inkscape::SnapPreferences::PointType const &t,
 
75
                  Geom::Point const &p,
 
76
                  SnapSourceType const &source_type,
 
77
                  long source_num,
 
78
                  Geom::OptRect const &bbox_to_snap,
 
79
                  std::vector<SPItem const *> const *it,
 
80
                  std::vector<std::pair<Geom::Point, int> > *unselected_nodes) const;
 
81
 
 
82
    void constrainedSnap(SnappedConstraints &sc,
 
83
                  Inkscape::SnapPreferences::PointType const &t,
 
84
                  Geom::Point const &p,
 
85
                  SnapSourceType const &source_type,
 
86
                  long source_num,
 
87
                  Geom::OptRect const &bbox_to_snap,
 
88
                  ConstraintLine const &c,
 
89
                  std::vector<SPItem const *> const *it) const;
90
90
 
91
91
private:
92
92
    //store some lists of candidates, points and paths, so we don't have to rebuild them for each point we want to snap
106
106
                      Inkscape::SnapPreferences::PointType const &t,
107
107
                      Geom::Point const &p, // in desktop coordinates
108
108
                      SnapSourceType const &source_type,
109
 
                      bool const &first_point,
 
109
                      long source_num,
110
110
                      std::vector<std::pair<Geom::Point, int> > *unselected_nodes) const; // in desktop coordinates
111
111
 
112
112
    void _snapTranslatingGuideToNodes(SnappedConstraints &sc,
119
119
 
120
120
    void _snapPaths(SnappedConstraints &sc,
121
121
                      Inkscape::SnapPreferences::PointType const &t,
122
 
                      Geom::Point const &p,     // in desktop coordinates
 
122
                      Geom::Point const &p,    // in desktop coordinates
123
123
                      SnapSourceType const &source_type,
124
 
                      bool const &first_point,
 
124
                      long source_num,
125
125
                      std::vector<std::pair<Geom::Point, int> > *unselected_nodes, // in desktop coordinates
126
126
                      SPPath const *selected_path) const;
127
127
 
129
129
                 Inkscape::SnapPreferences::PointType const &t,
130
130
                 Geom::Point const &p, // in desktop coordinates
131
131
                 SnapSourceType const source_type,
132
 
                                 bool const &first_point,
 
132
                 long source_num,
133
133
                 ConstraintLine const &c) const;
134
134
 
135
135
    bool isUnselectedNode(Geom::Point const &point, std::vector<std::pair<Geom::Point, int> > const *unselected_nodes) const;