1 #ifndef __SHAPE_EDITOR_H__
2 #define __SHAPE_EDITOR_H__
4 /*
5 * Inkscape::ShapeEditor
6 *
7 * This is a container class which contains either knotholder (for shapes) or nodepath (for
8 * paths). It is attached to a single item so only one of these is active at a time.
9 *
10 * Authors:
11 * bulia byak <buliabyak@users.sf.net>
12 *
13 */
15 #include <forward.h>
17 namespace Inkscape {
18 namespace NodePath {
19 class Path;
20 }
21 }
23 #include "libnr/nr-path-code.h"
24 #include "libnr/nr-point.h"
25 #include "libnr/nr-maybe.h"
27 class SPKnotHolder;
28 class SPDesktop;
29 class SPNodeContext;
30 class ShapeEditorsCollective;
32 class ShapeEditor {
33 public:
35 ShapeEditor(SPDesktop *desktop);
36 ~ShapeEditor();
38 void set_item (SPItem *item);
39 void unset_item ();
41 SPItem *get_item ();
43 bool has_nodepath ();
44 bool has_knotholder ();
46 bool has_local_change ();
47 void decrement_local_change ();
49 GList *save_nodepath_selection ();
50 void restore_nodepath_selection (GList *saved);
52 void nodepath_destroyed ();
54 void update_statusbar ();
56 bool is_over_stroke (NR::Point event_p, bool remember);
58 void add_node_near_point(); // uses the shapeeditor's remembered point, if any
60 void select_segment_near_point(bool toggle); // uses the shapeeditor's remembered point, if any
62 void cancel_hit ();
64 bool hits_curve ();
66 void curve_drag (gdouble eventx, gdouble eventy);
68 void finish_drag ();
70 void select_rect (NR::Rect const &rect, bool add);
72 bool has_selection ();
73 void deselect ();
75 Inkscape::NodePath::Path *get_nodepath() {return nodepath;} //((deprecated))
76 ShapeEditorsCollective *get_container() {return container;}
78 void add_node();
80 void delete_nodes();
81 void delete_nodes_preserving_shape();
82 void delete_segment();
84 void set_node_type(int type);
86 void break_at_nodes();
87 void join_nodes();
88 void join_segments();
90 void duplicate_nodes();
92 void set_type_of_segments(NRPathcode code);
94 void move_nodes(gdouble dx, gdouble dy);
95 void move_nodes_screen(gdouble dx, gdouble dy);
97 void rotate_nodes(gdouble angle, int which, bool screen);
99 void scale_nodes(gdouble const grow, int const which);
100 void scale_nodes_screen(gdouble const grow, int const which);
102 void select_all (bool invert);
103 void select_all_from_subpath (bool invert);
104 void select_next ();
105 void select_prev ();
107 void show_handles (bool show);
109 void flip (NR::Dim2 axis, NR::Maybe<NR::Point> center = NR::Nothing());
111 void distribute (NR::Dim2 axis);
112 void align (NR::Dim2 axis);
114 private:
115 SPDesktop *desktop;
117 Inkscape::NodePath::Path *nodepath;
118 SPKnotHolder *knotholder;
120 ShapeEditorsCollective *container;
122 //Inkscape::XML::Node *lidtened_repr;
124 double grab_t;
125 int grab_node; // number of node grabbed by sp_node_context_is_over_stroke
126 bool hit;
127 NR::Point curvepoint_event; // int coords from event
128 NR::Point curvepoint_doc; // same, in doc coords
129 };
132 /* As the next stage, this will be a collection of multiple ShapeEditors,
133 with the same interface as the single ShapeEditor, passing the actions to all its
134 contained ShapeEditors. Thus it should be easy to switch node context from
135 using a single ShapeEditor to using a ShapeEditorsCollective. */
137 class ShapeEditorsCollective {
138 public:
140 ShapeEditorsCollective(SPDesktop *desktop);
141 ~ShapeEditorsCollective();
143 void update_statusbar();
145 private:
146 std::vector<ShapeEditor> editors;
148 SPNodeContext *nc; // who holds us
149 };
151 #endif
154 /*
155 Local Variables:
156 mode:c++
157 c-file-style:"stroustrup"
158 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
159 indent-tabs-mode:nil
160 fill-column:99
161 End:
162 */
163 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :