Code

Implement selection spatial grow
[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 selectAll();
49     void selectArea(Geom::Rect const &area, bool take);
50     void shiftSelection(int dir);
51     void spatialGrow(NodeList::iterator center, int dir);
52     void invertSelection();
53     void invertSelectionInSubpaths();
54     void deselect();
56     void setNodeType(NodeType t);
57     void setSegmentType(SegmentType t);
59     void insertNodes();
60     void joinNodes();
61     void breakNodes();
62     void deleteNodes(bool keep_shape = true);
63     void joinSegment();
64     void deleteSegments();
65     void alignNodes(Geom::Dim2 d);
66     void distributeNodes(Geom::Dim2 d);
67     void reverseSubpaths();
68     void move(Geom::Point const &delta);
70     void showOutline(bool show);
71     void showHandles(bool show);
72     void showPathDirection(bool show);
73     void updateOutlineColors();
74     
75     sigc::signal<void> signal_coords_changed; /// Emitted whenever the coordinates
76         /// shown in the status bar need updating
77 private:
78     typedef std::pair<ShapeRecord, boost::shared_ptr<PathManipulator> > MapPair;
79     typedef std::map<ShapeRecord, boost::shared_ptr<PathManipulator> > MapType;
81     template <typename R>
82     void invokeForAll(R (PathManipulator::*method)()) {
83         for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
84             ((i->second.get())->*method)();
85         }
86     }
87     template <typename R, typename A>
88     void invokeForAll(R (PathManipulator::*method)(A), A a) {
89         for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
90             ((i->second.get())->*method)(a);
91         }
92     }
93     template <typename R, typename A>
94     void invokeForAll(R (PathManipulator::*method)(A const &), A const &a) {
95         for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
96             ((i->second.get())->*method)(a);
97         }
98     }
99     template <typename R, typename A, typename B>
100     void invokeForAll(R (PathManipulator::*method)(A,B), A a, B b) {
101         for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
102             ((i->second.get())->*method)(a, b);
103         }
104     }
106     void _commit(CommitEvent cps);
107     void _done(gchar const *);
108     void _doneWithCleanup(gchar const *);
109     guint32 _getOutlineColor(ShapeRole role);
111     MapType _mmap;
112 public:
113     PathSharedData const &_path_data;
114 private:
115     sigc::connection &_changed;
116     bool _show_handles;
117     bool _show_outline;
118     bool _show_path_direction;
120     friend class PathManipulator;
121 };
123 } // namespace UI
124 } // namespace Inkscape
126 #endif
128 /*
129   Local Variables:
130   mode:c++
131   c-file-style:"stroustrup"
132   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
133   indent-tabs-mode:nil
134   fill-column:99
135   End:
136 */
137 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :