Code

whitespace
[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; } }
19 namespace Inkscape { namespace XML { class Node; } }
21 #include "libnr/nr-path-code.h"
22 #include "libnr/nr-point.h"
23 #include <boost/optional.hpp>
24 #include <vector>
26 class KnotHolder;
27 class SPDesktop;
28 class SPNodeContext;
29 class ShapeEditorsCollective;
31 enum SubType{
32     SH_NODEPATH,
33     SH_KNOTHOLDER
34 };
36 class ShapeEditor {
37 public:
39     ShapeEditor(SPDesktop *desktop);
40     ~ShapeEditor();
42     void set_item (SPItem *item, SubType type, bool keep_knotholder = false);
43     void set_item_lpe_path_parameter(SPItem *item, SPObject *lpeobject, const char * key);
44     void unset_item (SubType type, bool keep_knotholder = false);
46     bool has_nodepath (); //((deprecated))
47     void update_knotholder (); //((deprecated))
49     bool has_local_change (SubType type);
50     void decrement_local_change (SubType type);
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 (Geom::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 (Geom::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(SPDesktop *desktop, 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 (Geom::Dim2 axis, boost::optional<Geom::Point> center = boost::optional<Geom::Point>());
115     void distribute (Geom::Dim2 axis);
116     void align (Geom::Dim2 axis);
118     bool nodepath_edits_repr_key(gchar const *name);
120     // this one is only public because it's called from non-C++ repr changed callback
121     void shapeeditor_event_attr_changed(gchar const *name);
123 private:
124     bool has_knotholder ();
125     void reset_item (SubType type, bool keep_knotholder = true);
126     const SPItem *get_item (SubType type);
128     SPDesktop *desktop;
130     Inkscape::NodePath::Path *nodepath;
132     // TODO: std::list<KnotHolder *> knotholders;
133     KnotHolder *knotholder;
135     ShapeEditorsCollective *container;
137     //Inkscape::XML::Node *lidtened_repr;
139     double grab_t;
140     int grab_node; // number of node grabbed by sp_node_context_is_over_stroke
141     bool hit;
142     Geom::Point curvepoint_event; // int coords from event
143     Geom::Point curvepoint_doc; // same, in doc coords
145     Inkscape::XML::Node *listener_attached_for;
146 };
149 /* As the next stage, this will be a collection of multiple ShapeEditors,
150 with the same interface as the single ShapeEditor, passing the actions to all its
151 contained ShapeEditors. Thus it should be easy to switch node context from 
152 using a single ShapeEditor to using a ShapeEditorsCollective. */
154 class ShapeEditorsCollective {
155 public:
157     ShapeEditorsCollective(SPDesktop *desktop);
158     ~ShapeEditorsCollective();
160     void update_statusbar();
162 private:
163     std::vector<ShapeEditor> editors;
165     SPNodeContext *nc; // who holds us
166 };
168 #endif
171 /*
172   Local Variables:
173   mode:c++
174   c-file-style:"stroustrup"
175   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
176   indent-tabs-mode:nil
177   fill-column:99
178   End:
179 */
180 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :