Code

Implement selection linear grow
[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 XML { class Node; }
30 namespace UI {
32 class PathManipulator;
33 class ControlPointSelection;
34 class PathManipulatorObserver;
35 class CurveDragPoint;
36 class PathCanvasGroups;
37 class MultiPathManipulator;
38 class Node;
40 struct PathSharedData {
41     NodeSharedData node_data;
42     SPCanvasGroup *outline_group;
43     SPCanvasGroup *dragpoint_group;
44 };
46 /**
47  * Manipulator that edits a single path using nodes with handles.
48  * Currently only cubic bezier and linear segments are supported, but this might change
49  * some time in the future.
50  */
51 class PathManipulator : public PointManipulator {
52 public:
53     typedef SPPath *ItemType;
55     PathManipulator(MultiPathManipulator &mpm, SPPath *path, Geom::Matrix const &edit_trans,
56         guint32 outline_color, Glib::ustring lpe_key);
57     ~PathManipulator();
58     virtual bool event(GdkEvent *);
60     bool empty();
61     void writeXML();
62     void update(); // update display, but don't commit
63     void clear(); // remove all nodes from manipulator
64     SPPath *item() { return _path; }
66     void selectSubpaths();
67     void selectAll();
68     void selectArea(Geom::Rect const &);
69     void shiftSelection(int dir);
70     void invertSelection();
71     void invertSelectionInSubpaths();
73     void insertNodes();
74     void weldNodes(NodeList::iterator preserve_pos = NodeList::iterator());
75     void weldSegments();
76     void breakNodes();
77     void deleteNodes(bool keep_shape = true);
78     void deleteSegments();
79     void reverseSubpaths();
80     void setSegmentType(SegmentType);
82     void showOutline(bool show);
83     void showHandles(bool show);
84     void showPathDirection(bool show);
85     void setControlsTransform(Geom::Matrix const &);
86     void hideDragPoint();
88     NodeList::iterator subdivideSegment(NodeList::iterator after, double t);
89     NodeList::iterator extremeNode(NodeList::iterator origin, bool search_selected,
90         bool search_unselected, bool closest);
92     static bool is_item_type(void *item);
93 private:
94     typedef NodeList Subpath;
95     typedef boost::shared_ptr<NodeList> SubpathPtr;
97     void _createControlPointsFromGeometry();
98     void _createGeometryFromControlPoints();
99     std::string _createTypeString();
100     void _updateOutline();
101     //void _setOutline(Geom::PathVector const &);
102     void _getGeometry();
103     void _setGeometry();
104     Glib::ustring _nodetypesKey();
105     Inkscape::XML::Node *_getXMLNode();
107     void _attachNodeHandlers(Node *n);
108     void _removeNodeHandlers(Node *n);
110     void _selectionChanged(SelectableControlPoint *p, bool selected);
111     bool _nodeClicked(Node *, GdkEventButton *);
112     void _handleGrabbed();
113     bool _handleClicked(Handle *, GdkEventButton *);
114     void _handleUngrabbed();
115     void _externalChange(unsigned type);
116     void _removeNodesFromSelection();
117     void _commit(Glib::ustring const &annotation);
118     void _updateDragPoint(Geom::Point const &);
119     void _updateOutlineOnZoomChange();
120     double _getStrokeTolerance();
122     SubpathList _subpaths;
123     MultiPathManipulator &_multi_path_manipulator;
124     SPPath *_path;
125     SPCurve *_spcurve; // in item coordinates
126     SPCanvasItem *_outline;
127     CurveDragPoint *_dragpoint; // an invisible control point hoverng over curve
128     PathManipulatorObserver *_observer;
129     Geom::Matrix _d2i_transform; ///< desktop-to-item transform
130     Geom::Matrix _i2d_transform; ///< item-to-desktop transform, inverse of _d2i_transform
131     Geom::Matrix _edit_transform; ///< additional transform to apply to editing controls
132     unsigned _num_selected; ///< number of selected nodes
133     bool _show_handles;
134     bool _show_outline;
135     bool _show_path_direction;
136     Glib::ustring _lpe_key;
138     friend class PathManipulatorObserver;
139     friend class CurveDragPoint;
140     friend class Node;
141 };
143 } // namespace UI
144 } // namespace Inkscape
146 #endif
148 /*
149   Local Variables:
150   mode:c++
151   c-file-style:"stroustrup"
152   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
153   indent-tabs-mode:nil
154   fill-column:99
155   End:
156 */
157 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :