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 joinSegments();
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 setLiveOutline(bool set);
69 void setLiveObjects(bool set);
70 void updateOutlineColors();
72 sigc::signal<void> signal_coords_changed; /// Emitted whenever the coordinates
73 /// shown in the status bar need updating
74 private:
75 typedef std::pair<ShapeRecord, boost::shared_ptr<PathManipulator> > MapPair;
76 typedef std::map<ShapeRecord, boost::shared_ptr<PathManipulator> > MapType;
78 template <typename R>
79 void invokeForAll(R (PathManipulator::*method)()) {
80 for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
81 ((i->second.get())->*method)();
82 }
83 }
84 template <typename R, typename A>
85 void invokeForAll(R (PathManipulator::*method)(A), A a) {
86 for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
87 ((i->second.get())->*method)(a);
88 }
89 }
90 template <typename R, typename A>
91 void invokeForAll(R (PathManipulator::*method)(A const &), A const &a) {
92 for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
93 ((i->second.get())->*method)(a);
94 }
95 }
96 template <typename R, typename A, typename B>
97 void invokeForAll(R (PathManipulator::*method)(A,B), A a, B b) {
98 for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
99 ((i->second.get())->*method)(a, b);
100 }
101 }
103 void _commit(CommitEvent cps);
104 void _done(gchar const *);
105 void _doneWithCleanup(gchar const *);
106 guint32 _getOutlineColor(ShapeRole role);
108 MapType _mmap;
109 public:
110 PathSharedData const &_path_data;
111 private:
112 sigc::connection &_changed;
113 bool _show_handles;
114 bool _show_outline;
115 bool _show_path_direction;
116 bool _live_outline;
117 bool _live_objects;
119 friend class PathManipulator;
120 };
122 } // namespace UI
123 } // namespace Inkscape
125 #endif
127 /*
128 Local Variables:
129 mode:c++
130 c-file-style:"stroustrup"
131 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
132 indent-tabs-mode:nil
133 fill-column:99
134 End:
135 */
136 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :