Code

Split SPCanvasItem and SPCanvasGroup to individual .h files. Removed forward header.
[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 "forward.h"
16 #include "ui/tool/commit-events.h"
17 #include "ui/tool/manipulator.h"
18 #include "ui/tool/modifier-tracker.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 duplicateNodes();
56     void joinNodes();
57     void breakNodes();
58     void deleteNodes(bool keep_shape = true);
59     void joinSegments();
60     void deleteSegments();
61     void alignNodes(Geom::Dim2 d);
62     void distributeNodes(Geom::Dim2 d);
63     void reverseSubpaths();
64     void move(Geom::Point const &delta);
66     void showOutline(bool show);
67     void showHandles(bool show);
68     void showPathDirection(bool show);
69     void setLiveOutline(bool set);
70     void setLiveObjects(bool set);
71     void updateOutlineColors();
72     
73     sigc::signal<void> signal_coords_changed; /// Emitted whenever the coordinates
74         /// shown in the status bar need updating
75 private:
76     typedef std::pair<ShapeRecord, boost::shared_ptr<PathManipulator> > MapPair;
77     typedef std::map<ShapeRecord, boost::shared_ptr<PathManipulator> > MapType;
79     template <typename R>
80     void invokeForAll(R (PathManipulator::*method)()) {
81         for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
82             ((i->second.get())->*method)();
83         }
84     }
85     template <typename R, typename A>
86     void invokeForAll(R (PathManipulator::*method)(A), A a) {
87         for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
88             ((i->second.get())->*method)(a);
89         }
90     }
91     template <typename R, typename A>
92     void invokeForAll(R (PathManipulator::*method)(A const &), A const &a) {
93         for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
94             ((i->second.get())->*method)(a);
95         }
96     }
97     template <typename R, typename A, typename B>
98     void invokeForAll(R (PathManipulator::*method)(A,B), A a, B b) {
99         for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
100             ((i->second.get())->*method)(a, b);
101         }
102     }
104     void _commit(CommitEvent cps);
105     void _done(gchar const *);
106     void _doneWithCleanup(gchar const *);
107     guint32 _getOutlineColor(ShapeRole role);
109     MapType _mmap;
110 public:
111     PathSharedData const &_path_data;
112 private:
113     sigc::connection &_changed;
114     ModifierTracker _tracker;
115     bool _show_handles;
116     bool _show_outline;
117     bool _show_path_direction;
118     bool _live_outline;
119     bool _live_objects;
121     friend class PathManipulator;
122 };
124 } // namespace UI
125 } // namespace Inkscape
127 #endif
129 /*
130   Local Variables:
131   mode:c++
132   c-file-style:"stroustrup"
133   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
134   indent-tabs-mode:nil
135   fill-column:99
136   End:
137 */
138 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :