Code

* Implement node snapping.
[inkscape.git] / src / ui / tool / multi-path-manipulator.h
1 /** @file
2  * Multi path manipulator - a tool component that edits multiple paths at once
3  */
4 /* Authors:
5  *   Krzysztof KosiƄski <tweenk.pl@gmail.com>
6  *
7  * Copyright (C) 2009 Authors
8  * Released under GNU GPL, read the file 'COPYING' for more information
9  */
11 #ifndef SEEN_UI_TOOL_MULTI_PATH_MANIPULATOR_H
12 #define SEEN_UI_TOOL_MULTI_PATH_MANIPULATOR_H
14 #include <sigc++/connection.h>
15 #include "display/display-forward.h"
16 #include "forward.h"
17 #include "ui/tool/commit-events.h"
18 #include "ui/tool/manipulator.h"
19 #include "ui/tool/node.h"
20 #include "ui/tool/node-types.h"
21 #include "ui/tool/shape-record.h"
23 struct SPCanvasGroup;
25 namespace Inkscape {
26 namespace UI {
28 class PathManipulator;
29 class MultiPathManipulator;
30 struct PathSharedData;
32 /**
33  * Manipulator that manages multiple path manipulators active at the same time.
34  */
35 class MultiPathManipulator : public PointManipulator {
36 public:
37     MultiPathManipulator(PathSharedData &data, sigc::connection &chg);
38     virtual ~MultiPathManipulator();
39     virtual bool event(GdkEvent *event);
41     bool empty() { return _mmap.empty(); }
42     unsigned size() { return _mmap.empty(); }
43     void setItems(std::set<ShapeRecord> const &);
44     void clear() { _mmap.clear(); }
45     void cleanup();
47     void selectSubpaths();
48     void shiftSelection(int dir);
49     void invertSelectionInSubpaths();
51     void setNodeType(NodeType t);
52     void setSegmentType(SegmentType t);
54     void insertNodes();
55     void joinNodes();
56     void breakNodes();
57     void deleteNodes(bool keep_shape = true);
58     void joinSegment();
59     void deleteSegments();
60     void alignNodes(Geom::Dim2 d);
61     void distributeNodes(Geom::Dim2 d);
62     void reverseSubpaths();
63     void move(Geom::Point const &delta);
65     void showOutline(bool show);
66     void showHandles(bool show);
67     void showPathDirection(bool show);
68     void updateOutlineColors();
69     
70     sigc::signal<void> signal_coords_changed; /// Emitted whenever the coordinates
71         /// shown in the status bar need updating
72 private:
73     typedef std::pair<ShapeRecord, boost::shared_ptr<PathManipulator> > MapPair;
74     typedef std::map<ShapeRecord, boost::shared_ptr<PathManipulator> > MapType;
76     template <typename R>
77     void invokeForAll(R (PathManipulator::*method)()) {
78         for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
79             ((i->second.get())->*method)();
80         }
81     }
82     template <typename R, typename A>
83     void invokeForAll(R (PathManipulator::*method)(A), A a) {
84         for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
85             ((i->second.get())->*method)(a);
86         }
87     }
88     template <typename R, typename A>
89     void invokeForAll(R (PathManipulator::*method)(A const &), A const &a) {
90         for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
91             ((i->second.get())->*method)(a);
92         }
93     }
94     template <typename R, typename A, typename B>
95     void invokeForAll(R (PathManipulator::*method)(A,B), A a, B b) {
96         for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
97             ((i->second.get())->*method)(a, b);
98         }
99     }
101     void _commit(CommitEvent cps);
102     void _done(gchar const *);
103     void _doneWithCleanup(gchar const *);
104     guint32 _getOutlineColor(ShapeRole role);
106     MapType _mmap;
107 public:
108     PathSharedData const &_path_data;
109 private:
110     sigc::connection &_changed;
111     bool _show_handles;
112     bool _show_outline;
113     bool _show_path_direction;
115     friend class PathManipulator;
116 };
118 } // namespace UI
119 } // namespace Inkscape
121 #endif
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 :