Code

Connector tool: make connectors avoid the convex hull of shapes.
[inkscape.git] / src / snap-preferences.cpp
1 #define __SNAPPREFERENCES_CPP__
3 /**
4  *  \file snap-preferences.cpp
5  *  \brief Storing of snapping preferences
6  *
7  * Authors:
8  *   Diederik van Lierop <mail@diedenrezi.nl>
9  *
10  * Copyright (C) 2008 Authors
11  *
12  * Released under GNU GPL, read the file 'COPYING' for more information
13  */
15 #include "inkscape.h"
16 #include "snap-preferences.h"
18 Inkscape::SnapPreferences::PointType const Inkscape::SnapPreferences::SNAPPOINT_NODE  = 0x1;
19 Inkscape::SnapPreferences::PointType const Inkscape::SnapPreferences::SNAPPOINT_BBOX  = 0x2;
20 Inkscape::SnapPreferences::PointType const Inkscape::SnapPreferences::SNAPPOINT_GUIDE = 0x4;
23 Inkscape::SnapPreferences::SnapPreferences() :
24         _include_item_center(false),
25         _intersectionGG(true),
26         _snap_to_grids(true),
27         _snap_to_guides(true),
28     _snap_enabled_globally(true),
29     _snap_postponed_globally(false),
30     _snap_to_itemnode(true), _snap_to_itempath(true),
31         _snap_to_bboxnode(true), _snap_to_bboxpath(true),
32         _snap_to_page_border(false),
33         _strict_snapping(true)
34 {
35         setSnapFrom(SNAPPOINT_BBOX | SNAPPOINT_NODE | SNAPPOINT_GUIDE, true); //Snap any point. In v0.45 and earlier, this was controlled in the preferences tab
36 }
38 /*
39  *  The snappers have too many parameters to adjust individually. Therefore only
40  *  two snapping modes are presented to the user: snapping bounding box corners (to
41  *  other bounding boxes, grids or guides), and/or snapping nodes (to other nodes,
42  *  paths, grids or guides). To select either of these modes (or both), use the
43  *  methods defined below: setSnapModeBBox() and setSnapModeNode().
44  *
45  * */
48 void Inkscape::SnapPreferences::setSnapModeBBox(bool enabled)
49 {
50         if (enabled) {
51         _snap_from |= Inkscape::SnapPreferences::SNAPPOINT_BBOX;
52     } else {
53         _snap_from &= ~Inkscape::SnapPreferences::SNAPPOINT_BBOX;
54     }
55 }
57 bool Inkscape::SnapPreferences::getSnapModeBBox() const
58 {
59         return (_snap_from & Inkscape::SnapPreferences::SNAPPOINT_BBOX);
60 }
62 void Inkscape::SnapPreferences::setSnapModeNode(bool enabled)
63 {
64         if (enabled) {
65         _snap_from |= Inkscape::SnapPreferences::SNAPPOINT_NODE;
66     } else {
67         _snap_from &= ~Inkscape::SnapPreferences::SNAPPOINT_NODE;
68     }
69 }
71 bool Inkscape::SnapPreferences::getSnapModeNode() const
72 {
73         return (_snap_from & Inkscape::SnapPreferences::SNAPPOINT_NODE);
74 }
76 bool Inkscape::SnapPreferences::getSnapModeBBoxOrNodes() const
77 {
78         return (_snap_from & (Inkscape::SnapPreferences::SNAPPOINT_BBOX | Inkscape::SnapPreferences::SNAPPOINT_NODE) );
79 }
81 bool Inkscape::SnapPreferences::getSnapModeAny() const
82 {
83         return (_snap_from != 0);
84 }
86 void Inkscape::SnapPreferences::setSnapModeGuide(bool enabled)
87 {
88         if (enabled) {
89         _snap_from |= Inkscape::SnapPreferences::SNAPPOINT_GUIDE;
90     } else {
91         _snap_from &= ~Inkscape::SnapPreferences::SNAPPOINT_GUIDE;
92     }
93 }
95 bool Inkscape::SnapPreferences::getSnapModeGuide() const
96 {
97         return (_snap_from & Inkscape::SnapPreferences::SNAPPOINT_GUIDE);
98 }
100 /**
101  *  Turn on/off snapping of specific point types.
102  *  \param t Point type.
103  *  \param s true to snap to this point type, otherwise false;
104  */
105 void Inkscape::SnapPreferences::setSnapFrom(PointType t, bool s)
107     if (s) {
108         _snap_from |= t;
109     } else {
110         _snap_from &= ~t;
111     }
114 /**
115  *  \param t Point type.
116  *  \return true if snapper will snap this type of point, otherwise false.
117  */
118 bool Inkscape::SnapPreferences::getSnapFrom(PointType t) const
120     return (_snap_from & t);
123 /*
124   Local Variables:
125   mode:c++
126   c-file-style:"stroustrup"
127   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
128   indent-tabs-mode:nil
129   fill-column:99
130   End:
131 */
132 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :