Code

isolate the nodepath-or-knotholder unit into the new ShapeEditor class which handles...
[inkscape.git] / src / shape-editor.h
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 typedef enum NodeType;
21 }
22 }
24 #include "libnr/nr-path-code.h"
25 #include "libnr/nr-point.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();
83     void set_node_type(Inkscape::NodePath::NodeType type);
85     void break_at_nodes();
86     void join_nodes();
88     void duplicate_nodes();
90     void set_type_of_segments(NRPathcode code);
92     void move_nodes(gdouble dx, gdouble dy);
93     void move_nodes_screen(gdouble dx, gdouble dy);
95     void rotate_nodes(gdouble angle, int which, bool screen);
97     void scale_nodes(gdouble const grow, int const which);
98     void scale_nodes_screen(gdouble const grow, int const which);
100     void select_all (bool invert);
101     void select_all_from_subpath (bool invert);
102     void select_next ();
103     void select_prev ();
105     void flip (NR::Dim2 axis);
107     void distribute (NR::Dim2 axis);
108     void align (NR::Dim2 axis);
110 private:
111     SPDesktop *desktop;
113     Inkscape::NodePath::Path *nodepath;
114     SPKnotHolder *knotholder;
116     ShapeEditorsCollective *container;
118     //Inkscape::XML::Node *lidtened_repr;
120     double grab_t;
121     int grab_node; // number of node grabbed by sp_node_context_is_over_stroke
122     bool hit;
123     NR::Point curvepoint_event; // int coords from event
124     NR::Point curvepoint_doc; // same, in doc coords
125 };
128 /* As the next stage, this will be a collection of multiple ShapeEditors,
129 with the same interface as the single ShapeEditor, passing the actions to all its
130 contained ShapeEditors. Thus it should be easy to switch node context from 
131 using a single ShapeEditor to using a ShapeEditorsCollective. */
133 class ShapeEditorsCollective {
134 public:
136     ShapeEditorsCollective(SPDesktop *desktop);
137     ~ShapeEditorsCollective();
139     void update_statusbar();
141 private:
142     std::vector<ShapeEditor> editors;
144     SPNodeContext *nc; // who holds us
145 };
147 #endif
150 /*
151   Local Variables:
152   mode:c++
153   c-file-style:"stroustrup"
154   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
155   indent-tabs-mode:nil
156   fill-column:99
157   End:
158 */
159 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :