Code

63d7fba15215bffbbf26ac60d7e2f4ff91ff08b4
[inkscape.git] / src / snap-preferences.h
1 #ifndef SNAPPREFERENCES_H_
2 #define SNAPPREFERENCES_H_
4 /**
5  *  \file snap-preferences.cpp
6  *  \brief Storing of snapping preferences
7  *
8  * Authors:
9  *   Diederik van Lierop <mail@diedenrezi.nl>
10  *
11  * Copyright (C) 2008 Authors
12  *
13  * Released under GNU GPL, read the file 'COPYING' for more information
14  */
16 #include "helper/units.h"
18 namespace Inkscape
19 {
21 class SnapPreferences
22 {
23 public:
24         SnapPreferences();
26         /// Point types to snap.
27     typedef int PointType;
28     static const PointType SNAPPOINT_NODE;
29     static const PointType SNAPPOINT_BBOX;
30     static const PointType SNAPPOINT_GUIDE;
32     void setSnapModeBBox(bool enabled);
33     void setSnapModeNode(bool enabled);
34     void setSnapModeGuide(bool enabled);
35     bool getSnapModeBBox() const;
36     bool getSnapModeNode() const;
37     bool getSnapModeBBoxOrNodes() const;
38     bool getSnapModeAny() const;
39     bool getSnapModeGuide() const;
41     void setSnapIntersectionGG(bool enabled) {_intersectionGG = enabled;}
42     void setSnapIntersectionCS(bool enabled) {_intersectionCS = enabled;}
43     void setSnapSmoothNodes(bool enabled) {_smoothNodes = enabled;}
44     void setSnapLineMidpoints(bool enabled) {_line_midpoints = enabled;}
45     void setSnapObjectMidpoints(bool enabled) {_object_midpoints = enabled;}
46     void setSnapBBoxEdgeMidpoints(bool enabled) {_bbox_edge_midpoints = enabled;}
47         void setSnapBBoxMidpoints(bool enabled) {_bbox_midpoints = enabled;}
48     bool getSnapIntersectionGG() const {return _intersectionGG;}
49     bool getSnapIntersectionCS() const {return _intersectionCS;}
50     bool getSnapSmoothNodes() const {return _smoothNodes;}
51     bool getSnapLineMidpoints() const {return _line_midpoints;}
52     bool getSnapObjectMidpoints() const {return _object_midpoints;}
53     bool getSnapBBoxEdgeMidpoints() const {return _bbox_edge_midpoints;}
54         bool getSnapBBoxMidpoints() const {return _bbox_midpoints;}
56         void setSnapToGrids(bool enabled) {_snap_to_grids = enabled;}
57     bool getSnapToGrids() const {return _snap_to_grids;}
59     void setSnapToGuides(bool enabled) {_snap_to_guides = enabled;}
60         bool getSnapToGuides() const {return _snap_to_guides;}
62     void setIncludeItemCenter(bool enabled) {_include_item_center = enabled;}
63     bool getIncludeItemCenter() const {return _include_item_center;}
65     void setSnapEnabledGlobally(bool enabled) {_snap_enabled_globally = enabled;}
66     bool getSnapEnabledGlobally() const {return _snap_enabled_globally;}
68     void setSnapPostponedGlobally(bool postponed) {_snap_postponed_globally = postponed;}
69     bool getSnapPostponedGlobally() const {return _snap_postponed_globally;}
71     void setSnapFrom(PointType t, bool s);
72     bool getSnapFrom(PointType t) const;
74     // These will only be used for the object snapper
75     void setSnapToItemNode(bool s) {_snap_to_itemnode = s;}
76         bool getSnapToItemNode() const {return _snap_to_itemnode;}
77         void setSnapToItemPath(bool s) {_snap_to_itempath = s;}
78         bool getSnapToItemPath() const {return _snap_to_itempath;}
79         void setSnapToBBoxNode(bool s) {_snap_to_bboxnode = s;}
80         bool getSnapToBBoxNode() const {return _snap_to_bboxnode;}
81         void setSnapToBBoxPath(bool s) {_snap_to_bboxpath = s;}
82         bool getSnapToBBoxPath() const {return _snap_to_bboxpath;}
83         void setSnapToPageBorder(bool s) {_snap_to_page_border = s;}
84         bool getSnapToPageBorder() const {return _snap_to_page_border;}
85         bool getStrictSnapping() const {return _strict_snapping;}
87         gdouble getGridTolerance() const {return _grid_tolerance;}
88         gdouble getGuideTolerance() const {return _guide_tolerance;}
89         gdouble getObjectTolerance() const {return _object_tolerance;}
91         void setGridTolerance(gdouble val) {_grid_tolerance = val;}
92         void setGuideTolerance(gdouble val) {_guide_tolerance = val;}
93         void setObjectTolerance(gdouble val) {_object_tolerance = val;}
96 private:
97     bool _include_item_center; //If true, snapping nodes will also snap the item's center
98     bool _intersectionGG; //Consider snapping to intersections of grid and guides
99     bool _intersectionCS; //Consider snapping to intersections of curves
100     bool _smoothNodes;
101     bool _line_midpoints;
102     bool _object_midpoints; // the midpoint of shapes (e.g. a circle, rect, polygon) or of any other shape (at [h/2, w/2])
103     bool _bbox_edge_midpoints;
104         bool _bbox_midpoints;
105         bool _snap_to_grids;
106         bool _snap_to_guides;
107     bool _snap_enabled_globally; // Toggles ALL snapping
108     bool _snap_postponed_globally; // Hold all snapping temporarily when the mouse is moving fast
109     PointType _snap_from; ///< bitmap of point types that we will snap from
111     // These will only be used for the object snapper
112     bool _snap_to_itemnode;
113         bool _snap_to_itempath;
114         bool _snap_to_bboxnode;
115         bool _snap_to_bboxpath;
116         bool _snap_to_page_border;
117         //If enabled, then bbox corners will only snap to bboxes,
118         //and nodes will only snap to nodes and paths. We will not
119         //snap bbox corners to nodes, or nodes to bboxes.
120         //(snapping to grids and guides is not affected by this)
121         bool _strict_snapping;
123         gdouble _grid_tolerance;
124         gdouble _guide_tolerance;
125         gdouble _object_tolerance;
126 };
129 #endif /*SNAPPREFERENCES_H_*/
131 /*
132   Local Variables:
133   mode:c++
134   c-file-style:"stroustrup"
135   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
136   indent-tabs-mode:nil
137   fill-column:99
138   End:
139 */
140 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :