Code

First GSoC node tool commit to Bazaar
[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/manipulator.h"
18 #include "ui/tool/node-types.h"
19 #include "ui/tool/commit-events.h"
21 struct SPCanvasGroup;
23 namespace Inkscape {
24 namespace UI {
26 class PathManipulator;
27 class MultiPathManipulator;
28 struct PathSharedData;
30 /**
31  * Manipulator that manages multiple path manipulators active at the same time.
32  * It functions like a boost::ptr_set - manipulators added via insert() are retained.
33  */
34 class MultiPathManipulator : public PointManipulator {
35 public:
36     MultiPathManipulator(PathSharedData const &data, sigc::connection &chg);
37     virtual ~MultiPathManipulator();
38     virtual bool event(GdkEvent *event);
40     bool empty() { return _mmap.empty(); }
41     unsigned size() { return _mmap.empty(); }
42     // TODO fix this garbage!
43     void setItems(std::map<SPPath*, std::pair<Geom::Matrix, guint32> > const &items);
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 linearGrow(int dir);
52     void spatialGrow(int dir);
53     void invertSelection();
54     void invertSelectionInSubpaths();
55     void deselect();
57     void setNodeType(NodeType t);
58     void setSegmentType(SegmentType t);
60     void insertNodes();
61     void joinNodes();
62     void breakNodes();
63     void deleteNodes(bool keep_shape = true);
64     void joinSegment();
65     void deleteSegments();
66     void alignNodes(Geom::Dim2 d);
67     void distributeNodes(Geom::Dim2 d);
68     void reverseSubpaths();
69     void move(Geom::Point const &delta);
71     void showOutline(bool show);
72     void showHandles(bool show);
73     void showPathDirection(bool show);
74     void setOutlineTransform(SPPath *item, Geom::Matrix const &t);
75     
76     sigc::signal<void> signal_coords_changed;
77 private:
78     typedef std::pair<SPPath*, boost::shared_ptr<PathManipulator> > MapPair;
79     typedef std::map<SPPath*, 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     void _storeClipMaskItems(SPObject *obj, std::set<SPPath*> &, bool);
111     MapType _mmap;
112     PathSharedData const &_path_data;
113     sigc::connection &_changed;
114     bool _show_handles;
115     bool _show_outline;
116     bool _show_path_direction;
117 };
119 } // namespace UI
120 } // namespace Inkscape
122 #endif
124 /*
125   Local Variables:
126   mode:c++
127   c-file-style:"stroustrup"
128   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
129   indent-tabs-mode:nil
130   fill-column:99
131   End:
132 */
133 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :