Code

- try to use more forward declarations for less dependencies on display/curve.h
[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 }
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 set_item_lpe_path_parameter(SPItem *item, SPObject *lpeobject, const char * key);
40     void set_knotholder(SPKnotHolder * knot_holder);
41     void reset_item ();
42     void unset_item ();
44     SPItem *get_item ();
46     bool has_nodepath ();
47     bool has_knotholder ();
49     bool has_local_change ();
50     void decrement_local_change ();
52     GList *save_nodepath_selection ();
53     void restore_nodepath_selection (GList *saved);
55     void nodepath_destroyed ();
57     void update_statusbar ();
59     bool is_over_stroke (NR::Point event_p, bool remember);
61     void add_node_near_point(); // uses the shapeeditor's remembered point, if any
63     void select_segment_near_point(bool toggle); // uses the shapeeditor's remembered point, if any
65     void cancel_hit ();
67     bool hits_curve ();
69     void curve_drag (gdouble eventx, gdouble eventy);
71     void finish_drag ();
73     void select_rect (NR::Rect  const &rect, bool add);
75     bool has_selection ();
76     void deselect ();
78     Inkscape::NodePath::Path *get_nodepath() {return nodepath;} //((deprecated))
79     ShapeEditorsCollective *get_container() {return container;}
81     void add_node();
83     void delete_nodes();
84     void delete_nodes_preserving_shape();
85     void delete_segment();
87     void set_node_type(int type);
89     void break_at_nodes();
90     void join_nodes();
91     void join_segments();
93     void duplicate_nodes();
95     void set_type_of_segments(NRPathcode code);
97     void move_nodes(gdouble dx, gdouble dy);
98     void move_nodes_screen(gdouble dx, gdouble dy);
100     void rotate_nodes(gdouble angle, int which, bool screen);
102     void scale_nodes(gdouble const grow, int const which);
103     void scale_nodes_screen(gdouble const grow, int const which);
105     void select_all (bool invert);
106     void select_all_from_subpath (bool invert);
107     void select_next ();
108     void select_prev ();
110     void show_handles (bool show);
111     void show_helperpath (bool show);
113     void flip (NR::Dim2 axis, NR::Maybe<NR::Point> center = NR::Nothing());
115     void distribute (NR::Dim2 axis);
116     void align (NR::Dim2 axis);
118     bool nodepath_edits_repr_key(gchar const *name);
120 private:
121     SPDesktop *desktop;
123     Inkscape::NodePath::Path *nodepath;
124     SPKnotHolder *knotholder;
126     ShapeEditorsCollective *container;
128     //Inkscape::XML::Node *lidtened_repr;
130     double grab_t;
131     int grab_node; // number of node grabbed by sp_node_context_is_over_stroke
132     bool hit;
133     NR::Point curvepoint_event; // int coords from event
134     NR::Point curvepoint_doc; // same, in doc coords
135 };
138 /* As the next stage, this will be a collection of multiple ShapeEditors,
139 with the same interface as the single ShapeEditor, passing the actions to all its
140 contained ShapeEditors. Thus it should be easy to switch node context from 
141 using a single ShapeEditor to using a ShapeEditorsCollective. */
143 class ShapeEditorsCollective {
144 public:
146     ShapeEditorsCollective(SPDesktop *desktop);
147     ~ShapeEditorsCollective();
149     void update_statusbar();
151 private:
152     std::vector<ShapeEditor> editors;
154     SPNodeContext *nc; // who holds us
155 };
157 #endif
160 /*
161   Local Variables:
162   mode:c++
163   c-file-style:"stroustrup"
164   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
165   indent-tabs-mode:nil
166   fill-column:99
167   End:
168 */
169 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :