Code

Fix mask editing behavior on undo and outline display for masks/clips;
[inkscape.git] / src / ui / tool / path-manipulator.h
1 /** @file
2  * Path manipulator - a component that edits a single path on-canvas
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_PATH_MANIPULATOR_H
12 #define SEEN_UI_TOOL_PATH_MANIPULATOR_H
14 #include <string>
15 #include <memory>
16 #include <2geom/pathvector.h>
17 #include <2geom/matrix.h>
18 #include <boost/shared_ptr.hpp>
19 #include <boost/weak_ptr.hpp>
20 #include "display/display-forward.h"
21 #include "forward.h"
22 #include "ui/tool/node.h"
23 #include "ui/tool/manipulator.h"
25 struct SPCanvasItem;
27 namespace Inkscape {
28 namespace UI {
30 class PathManipulator;
31 class ControlPointSelection;
32 class PathManipulatorObserver;
33 class CurveDragPoint;
34 class PathCanvasGroups;
36 struct PathSharedData {
37     NodeSharedData node_data;
38     SPCanvasGroup *outline_group;
39     SPCanvasGroup *dragpoint_group;
40 };
42 /**
43  * Manipulator that edits a single path using nodes with handles.
44  * Currently only cubic bezier and linear segments are supported, but this might change
45  * some time in the future.
46  */
47 class PathManipulator : public PointManipulator {
48 public:
49     typedef SPPath *ItemType;
51     PathManipulator(PathSharedData const &data, SPPath *path,
52         Geom::Matrix const &edit_trans, guint32 outline_color);
53     ~PathManipulator();
54     virtual bool event(GdkEvent *);
56     bool empty();
57     void writeXML();
58     void update(); // update display, but don't commit
59     void clear(); // remove all nodes from manipulator
60     SPPath *item() { return _path; }
62     void selectSubpaths();
63     void selectAll();
64     void selectArea(Geom::Rect const &);
65     void shiftSelection(int dir);
66     void linearGrow(int dir);
67     void spatialGrow(int dir);
68     void invertSelection();
69     void invertSelectionInSubpaths();
71     void insertNodes();
72     void weldNodes(NodeList::iterator const &preserve_pos = NodeList::iterator());
73     void weldSegments();
74     void breakNodes();
75     void deleteNodes(bool keep_shape = true);
76     void deleteSegments();
77     void reverseSubpaths();
78     void setSegmentType(SegmentType);
80     void showOutline(bool show);
81     void showHandles(bool show);
82     void showPathDirection(bool show);
83     void setControlsTransform(Geom::Matrix const &);
85     NodeList::iterator subdivideSegment(NodeList::iterator after, double t);
87     static bool is_item_type(void *item);
88 private:
89     typedef NodeList Subpath;
90     typedef boost::shared_ptr<NodeList> SubpathPtr;
92     void _createControlPointsFromGeometry();
93     void _createGeometryFromControlPoints();
94     std::string _createTypeString();
95     void _updateOutline();
96     //void _setOutline(Geom::PathVector const &);
98     void _attachNodeHandlers(Node *n);
99     void _removeNodeHandlers(Node *n);
101     void _selectionChanged(SelectableControlPoint *p, bool selected);
102     bool _nodeClicked(Node *, GdkEventButton *);
103     void _handleGrabbed();
104     bool _handleClicked(Handle *, GdkEventButton *);
105     void _handleUngrabbed();
106     void _externalChange(unsigned type);
107     void _removeNodesFromSelection();
108     void _commit(Glib::ustring const &annotation);
109     void _updateDragPoint(Geom::Point const &);
110     void _updateOutlineOnZoomChange();
111     double _getStrokeTolerance();
113     SubpathList _subpaths;
114     PathSharedData const &_path_data;
115     SPPath *_path;
116     SPCurve *_spcurve; // in item coordinates
117     SPCanvasItem *_outline;
118     CurveDragPoint *_dragpoint; // an invisible control point hoverng over curve
119     PathManipulatorObserver *_observer;
120     Geom::Matrix _d2i_transform; ///< desktop-to-item transform
121     Geom::Matrix _i2d_transform; ///< item-to-desktop transform, inverse of _d2i_transform
122     Geom::Matrix _edit_transform; ///< additional transform to apply to editing controls
123     unsigned _num_selected; ///< number of selected nodes
124     bool _show_handles;
125     bool _show_outline;
126     bool _show_path_direction;
128     friend class PathManipulatorObserver;
129     friend class CurveDragPoint;
130 };
132 } // namespace UI
133 } // namespace Inkscape
135 #endif
137 /*
138   Local Variables:
139   mode:c++
140   c-file-style:"stroustrup"
141   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
142   indent-tabs-mode:nil
143   fill-column:99
144   End:
145 */
146 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :