Code

ddb74c1bc13d0f65422c2d25ff82e73b9d2048e7
[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/modifier-tracker.h"
20 #include "ui/tool/node.h"
21 #include "ui/tool/node-types.h"
22 #include "ui/tool/shape-record.h"
24 struct SPCanvasGroup;
26 namespace Inkscape {
27 namespace UI {
29 class PathManipulator;
30 class MultiPathManipulator;
31 struct PathSharedData;
33 /**
34  * Manipulator that manages multiple path manipulators active at the same time.
35  */
36 class MultiPathManipulator : public PointManipulator {
37 public:
38     MultiPathManipulator(PathSharedData &data, sigc::connection &chg);
39     virtual ~MultiPathManipulator();
40     virtual bool event(GdkEvent *event);
42     bool empty() { return _mmap.empty(); }
43     unsigned size() { return _mmap.empty(); }
44     void setItems(std::set<ShapeRecord> const &);
45     void clear() { _mmap.clear(); }
46     void cleanup();
48     void selectSubpaths();
49     void shiftSelection(int dir);
50     void invertSelectionInSubpaths();
52     void setNodeType(NodeType t);
53     void setSegmentType(SegmentType t);
55     void insertNodes();
56     void duplicateNodes();
57     void joinNodes();
58     void breakNodes();
59     void deleteNodes(bool keep_shape = true);
60     void joinSegments();
61     void deleteSegments();
62     void alignNodes(Geom::Dim2 d);
63     void distributeNodes(Geom::Dim2 d);
64     void reverseSubpaths();
65     void move(Geom::Point const &delta);
67     void showOutline(bool show);
68     void showHandles(bool show);
69     void showPathDirection(bool show);
70     void setLiveOutline(bool set);
71     void setLiveObjects(bool set);
72     void updateOutlineColors();
73     
74     sigc::signal<void> signal_coords_changed; /// Emitted whenever the coordinates
75         /// shown in the status bar need updating
76 private:
77     typedef std::pair<ShapeRecord, boost::shared_ptr<PathManipulator> > MapPair;
78     typedef std::map<ShapeRecord, boost::shared_ptr<PathManipulator> > MapType;
80     template <typename R>
81     void invokeForAll(R (PathManipulator::*method)()) {
82         for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
83             ((i->second.get())->*method)();
84         }
85     }
86     template <typename R, typename A>
87     void invokeForAll(R (PathManipulator::*method)(A), A a) {
88         for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
89             ((i->second.get())->*method)(a);
90         }
91     }
92     template <typename R, typename A>
93     void invokeForAll(R (PathManipulator::*method)(A const &), A const &a) {
94         for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
95             ((i->second.get())->*method)(a);
96         }
97     }
98     template <typename R, typename A, typename B>
99     void invokeForAll(R (PathManipulator::*method)(A,B), A a, B b) {
100         for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
101             ((i->second.get())->*method)(a, b);
102         }
103     }
105     void _commit(CommitEvent cps);
106     void _done(gchar const *);
107     void _doneWithCleanup(gchar const *);
108     guint32 _getOutlineColor(ShapeRole role);
110     MapType _mmap;
111 public:
112     PathSharedData const &_path_data;
113 private:
114     sigc::connection &_changed;
115     ModifierTracker _tracker;
116     bool _show_handles;
117     bool _show_outline;
118     bool _show_path_direction;
119     bool _live_outline;
120     bool _live_objects;
122     friend class PathManipulator;
123 };
125 } // namespace UI
126 } // namespace Inkscape
128 #endif
130 /*
131   Local Variables:
132   mode:c++
133   c-file-style:"stroustrup"
134   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
135   indent-tabs-mode:nil
136   fill-column:99
137   End:
138 */
139 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :