Code

Get rid of sp_nodepath_current() and a few instances of SP_ACTIVE_DESKTOP by passing...
[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>
16 #include <libnr/nr-forward.h>
18 namespace Inkscape { namespace NodePath { class Path; } }
20 #include "libnr/nr-path-code.h"
21 #include "libnr/nr-point.h"
22 #include <boost/optional.hpp>
23 #include <vector>
25 class KnotHolder;
26 class SPDesktop;
27 class SPNodeContext;
28 class ShapeEditorsCollective;
30 enum SubType{
31     SH_NODEPATH,
32     SH_KNOTHOLDER
33 };
35 class ShapeEditor {
36 public:
38     ShapeEditor(SPDesktop *desktop);
39     ~ShapeEditor();
41     void set_item (SPItem *item, SubType type, bool keep_knotholder = false);
42     void set_item_lpe_path_parameter(SPItem *item, SPObject *lpeobject, const char * key);
43     void set_knotholder(KnotHolder * knot_holder);
44     void reset_item (SubType type, bool keep_knotholder = true);
45     void unset_item (SubType type, bool keep_knotholder = false);
47     const SPItem *get_item (SubType type);
49     bool has_nodepath ();
50     bool has_knotholder ();
51     void update_knotholder ();
53     bool has_local_change (SubType type);
54     void decrement_local_change (SubType type);
56     GList *save_nodepath_selection ();
57     void restore_nodepath_selection (GList *saved);
59     void nodepath_destroyed ();
61     void update_statusbar ();
63     bool is_over_stroke (NR::Point event_p, bool remember);
65     void add_node_near_point(); // uses the shapeeditor's remembered point, if any
67     void select_segment_near_point(bool toggle); // uses the shapeeditor's remembered point, if any
69     void cancel_hit ();
71     bool hits_curve ();
73     void curve_drag (gdouble eventx, gdouble eventy);
75     void finish_drag ();
77     void select_rect (NR::Rect  const &rect, bool add);
79     bool has_selection ();
80     void deselect ();
82     Inkscape::NodePath::Path *get_nodepath() {return nodepath;} //((deprecated))
83     ShapeEditorsCollective *get_container() {return container;}
85     void add_node();
87     void delete_nodes();
88     void delete_nodes_preserving_shape();
89     void delete_segment();
91     void set_node_type(int type);
93     void break_at_nodes();
94     void join_nodes();
95     void join_segments();
97     void duplicate_nodes();
99     void set_type_of_segments(NRPathcode code);
101     void move_nodes(gdouble dx, gdouble dy);
102     void move_nodes_screen(SPDesktop *desktop, gdouble dx, gdouble dy);
104     void rotate_nodes(gdouble angle, int which, bool screen);
106     void scale_nodes(gdouble const grow, int const which);
107     void scale_nodes_screen(gdouble const grow, int const which);
109     void select_all (bool invert);
110     void select_all_from_subpath (bool invert);
111     void select_next ();
112     void select_prev ();
114     void show_handles (bool show);
115     void show_helperpath (bool show);
117     void flip (NR::Dim2 axis, boost::optional<NR::Point> center = boost::optional<NR::Point>());
119     void distribute (NR::Dim2 axis);
120     void align (NR::Dim2 axis);
122     bool nodepath_edits_repr_key(gchar const *name);
124 private:
125     SPDesktop *desktop;
127     Inkscape::NodePath::Path *nodepath;
128     KnotHolder *knotholder;
130     ShapeEditorsCollective *container;
132     //Inkscape::XML::Node *lidtened_repr;
134     double grab_t;
135     int grab_node; // number of node grabbed by sp_node_context_is_over_stroke
136     bool hit;
137     NR::Point curvepoint_event; // int coords from event
138     NR::Point curvepoint_doc; // same, in doc coords
139 };
142 /* As the next stage, this will be a collection of multiple ShapeEditors,
143 with the same interface as the single ShapeEditor, passing the actions to all its
144 contained ShapeEditors. Thus it should be easy to switch node context from 
145 using a single ShapeEditor to using a ShapeEditorsCollective. */
147 class ShapeEditorsCollective {
148 public:
150     ShapeEditorsCollective(SPDesktop *desktop);
151     ~ShapeEditorsCollective();
153     void update_statusbar();
155 private:
156     std::vector<ShapeEditor> editors;
158     SPNodeContext *nc; // who holds us
159 };
161 #endif
164 /*
165   Local Variables:
166   mode:c++
167   c-file-style:"stroustrup"
168   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
169   indent-tabs-mode:nil
170   fill-column:99
171   End:
172 */
173 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :