X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fnodepath.h;h=8f17ecb14b966a76596abfb54120f7912cf53dd1;hb=1cb64c3a763a8a064cfff29309c9ad16f96a0aa5;hp=a0f33d4b10105a350df486c6f2168050e4bff7db;hpb=21813d102eee54ff9d70082f4a03c7a662c90f9d;p=inkscape.git diff --git a/src/nodepath.h b/src/nodepath.h index a0f33d4b1..8f17ecb14 100644 --- a/src/nodepath.h +++ b/src/nodepath.h @@ -17,12 +17,15 @@ //#include "desktop-handles.h" #include "libnr/nr-path-code.h" #include "livarot/Path.h" +#include #include +class SPObject; class SPDesktop; class SPPath; class SPKnot; +class LivePathEffectObject; namespace Inkscape { namespace XML { @@ -73,8 +76,7 @@ operator NR::Point() const }; -/** defined in node-context.h */ -class SPNodeContext; +class ShapeEditor; namespace Inkscape { namespace NodePath { @@ -97,45 +99,6 @@ class NodeSide; class Node; -/** - * This is a collection of subpaths which contain nodes - * - * In the following data model. Nodepaths are made up of subpaths which - * are comprised of nodes. - * - * Nodes are linked thus: - * \verbatim - n other - node -----> nodeside ------> node \endverbatim - */ -class Path { - public: -/** Pointer to the current desktop, for reporting purposes */ - SPDesktop * desktop; -/** The parent path of this nodepath */ - SPPath * path; -/** The context which created this nodepath. Important if this nodepath is deleted */ - SPNodeContext * nodeContext; -/** The subpaths which comprise this NodePath */ - GList * subpaths; -/** A list of nodes which are currently selected */ - GList * selected; -/** Transforms (userspace <---> virtual space? someone please describe ) - njh: I'd be guessing that these are item <-> desktop transforms.*/ - NR::Matrix i2d, d2i; -/** The DOM node which describes this NodePath */ - Inkscape::XML::Node *repr; - //STL compliant method to get the selected nodes - void selection(std::list &l); - - /// livarot library is used for "point on path" and "nearest position on path", so we need to maintain its path representation as well - ::Path *livarot_path; - - /// true if we changed repr, to tell this change from an external one such as from undo, simplify, or another desktop - unsigned int local_change; -}; - - /** * This is the lowest list item, a simple list of nodes. */ @@ -185,14 +148,16 @@ class NodeSide{ Node * other; /** Position */ NR::Point pos; +/** Origin (while dragging) in radial notation */ + Radial origin_radial; +/** Origin (while dragging) in x/y notation */ + NR::Point origin; /** Knots are Inkscape's way of providing draggable points. This * Knot is the point on the curve representing the control point in a * bezier curve.*/ SPKnot * knot; /** What kind of rendering? */ SPCanvasItem * line; -/** */ - Radial origin; }; /** @@ -223,14 +188,87 @@ class Node { /** The pointer to the nodeside which we are dragging out with Shift */ NodeSide *dragging_out; + + /** Boolean. Am I being dragged? */ + guint is_dragging : 1; +}; + +/** + * This is a collection of subpaths which contain nodes + * + * In the following data model. Nodepaths are made up of subpaths which + * are comprised of nodes. + * + * Nodes are linked thus: + * \verbatim + n other + node -----> nodeside ------> node \endverbatim + */ +class Path { + public: +/** Pointer to the current desktop, for reporting purposes */ + SPDesktop * desktop; +/** The parent path of this nodepath */ + SPObject * object; +/** The parent livepatheffect of this nodepath, if applicable */ + SPItem * item; +/** The context which created this nodepath. Important if this nodepath is deleted */ + ShapeEditor *shape_editor; +/** The subpaths which comprise this NodePath */ + GList * subpaths; +/** A list of nodes which are currently selected */ + GList * selected; +/** Transforms (userspace <---> virtual space? someone please describe ) + njh: I'd be guessing that these are item <-> desktop transforms.*/ + NR::Matrix i2d, d2i; +/** The DOM node which describes this NodePath */ + Inkscape::XML::Node *repr; + gchar *repr_key; + gchar *repr_nodetypes_key; + //STL compliant method to get the selected nodes + void selection(std::list &l); + + guint numSelected() {return (selected? g_list_length(selected) : 0);} + NR::Point& singleSelectedCoords() {return (((Node *) selected->data)->pos);} + + /// livarot library is used for "point on path" and "nearest position on path", so we need to maintain its path representation as well + ::Path *livarot_path; + + /// draw a "sketch" of the path by using these variables + SPCanvasItem *helper_path; + SPCurve *curve; + bool show_helperpath; + guint32 helperpath_rgba; + gdouble helperpath_width; + + /// true if we changed repr, to tell this change from an external one such as from undo, simplify, or another desktop + unsigned int local_change; + + /// true if we're showing selected nodes' handles + bool show_handles; + + /// true if the path cannot contain curves, just straight lines + bool straight_path; + + /// active_node points to the node that is currently mouseovered (= NULL if + /// there isn't any); we also consider the node mouseovered if it is covered + /// by one of its handles and the latter is mouseovered + static Node *active_node; }; } // namespace NodePath } // namespace Inkscape +enum { + SCULPT_PROFILE_LINEAR, + SCULPT_PROFILE_BELL, + SCULPT_PROFILE_ELLIPTIC +}; + // Do function documentation in nodepath.cpp -Inkscape::NodePath::Path * sp_nodepath_new (SPDesktop * desktop, SPItem * item); +Inkscape::NodePath::Path * sp_nodepath_new (SPDesktop * desktop, SPObject *object, bool show_handles, const char * repr_key = NULL, SPItem *item = NULL); void sp_nodepath_destroy (Inkscape::NodePath::Path * nodepath); +void sp_nodepath_ensure_livarot_path(Inkscape::NodePath::Path *np); void sp_nodepath_deselect (Inkscape::NodePath::Path *nodepath); void sp_nodepath_select_all (Inkscape::NodePath::Path *nodepath, bool invert); void sp_nodepath_select_all_from_subpath(Inkscape::NodePath::Path *nodepath, bool invert); @@ -242,33 +280,39 @@ void restore_nodepath_selection (Inkscape::NodePath::Path *nodepath, GList *r); gboolean nodepath_repr_d_changed (Inkscape::NodePath::Path * np, const char *newd); gboolean nodepath_repr_typestr_changed (Inkscape::NodePath::Path * np, const char *newtypestr); gboolean node_key (GdkEvent * event); -void sp_nodepath_update_repr(Inkscape::NodePath::Path *np); +void sp_nodepath_update_repr(Inkscape::NodePath::Path *np, const gchar *annotation); void sp_nodepath_update_statusbar (Inkscape::NodePath::Path *nodepath); void sp_nodepath_selected_align(Inkscape::NodePath::Path *nodepath, NR::Dim2 axis); void sp_nodepath_selected_distribute(Inkscape::NodePath::Path *nodepath, NR::Dim2 axis); void sp_nodepath_select_segment_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p, bool toggle); void sp_nodepath_add_node_near_point(Inkscape::NodePath::Path *nodepath, NR::Point p); -void sp_nodepath_curve_drag(Inkscape::NodePath::Node * e, double t, NR::Point delta); +void sp_nodepath_curve_drag(int node, double t, NR::Point delta); Inkscape::NodePath::Node * sp_nodepath_get_node_by_index(int index); /* possibly private functions */ -void sp_node_selected_add_node (void); -void sp_node_selected_break (void); -void sp_node_selected_duplicate (void); -void sp_node_selected_join (void); -void sp_node_selected_join_segment (void); -void sp_node_selected_delete (void); -void sp_node_selected_delete_segment (void); -void sp_node_selected_set_type (Inkscape::NodePath::NodeType type); -void sp_node_selected_set_line_type (NRPathcode code); -void sp_node_selected_move (gdouble dx, gdouble dy); -void sp_node_selected_move_screen (gdouble dx, gdouble dy); +void sp_node_selected_add_node (Inkscape::NodePath::Path *nodepath); +void sp_node_selected_break (Inkscape::NodePath::Path *nodepath); +void sp_node_selected_duplicate (Inkscape::NodePath::Path *nodepath); +void sp_node_selected_join (Inkscape::NodePath::Path *nodepath); +void sp_node_selected_join_segment (Inkscape::NodePath::Path *nodepath); +void sp_node_delete_preserve (GList *nodes_to_delete); +void sp_node_selected_delete (Inkscape::NodePath::Path *nodepath); +void sp_node_selected_delete_segment (Inkscape::NodePath::Path *nodepath); +void sp_node_selected_set_type (Inkscape::NodePath::Path *nodepath, Inkscape::NodePath::NodeType type); +void sp_node_selected_set_line_type (Inkscape::NodePath::Path *nodepath, NRPathcode code); +void sp_node_selected_move (Inkscape::NodePath::Path *nodepath, gdouble dx, gdouble dy); +void sp_node_selected_move_screen (Inkscape::NodePath::Path *nodepath, gdouble dx, gdouble dy); +void sp_node_selected_move_absolute (Inkscape::NodePath::Path *nodepath, NR::Coord val, NR::Dim2 axis); +NR::Rect sp_node_selected_bbox (Inkscape::NodePath::Path *nodepath); +NR::Maybe sp_node_selected_common_coord (Inkscape::NodePath::Path *nodepath, NR::Dim2 axis); + +void sp_nodepath_show_handles(Inkscape::NodePath::Path *nodepath, bool show); void sp_nodepath_selected_nodes_rotate (Inkscape::NodePath::Path * nodepath, gdouble angle, int which, bool screen); void sp_nodepath_selected_nodes_scale (Inkscape::NodePath::Path * nodepath, gdouble grow, int which); void sp_nodepath_selected_nodes_scale_screen (Inkscape::NodePath::Path * nodepath, gdouble grow, int which); -void sp_nodepath_flip (Inkscape::NodePath::Path *nodepath, NR::Dim2 axis); +void sp_nodepath_flip (Inkscape::NodePath::Path *nodepath, NR::Dim2 axis, NR::Maybe center); #endif