Code

NR::Maybe => boost::optional
[inkscape.git] / src / nodepath.h
index 29d34addd774cbbf02ccc193873701615a35f118..b330ff96415b9ca8a75f8b2f9e7e324e77ed24df 100644 (file)
 //#include "sp-path.h"
 //#include "desktop-handles.h"
 #include "libnr/nr-path-code.h"
-#include "livarot/Path.h"
 #include <glibmm/ustring.h>
-
+#include <gdk/gdkevents.h>
 #include <list>
 
+struct SPCanvasItem;
+class SPCurve;
+struct SPItem;
+class SPObject;
 class SPDesktop;
 class SPPath;
 class SPKnot;
+class LivePathEffectObject;
 
 namespace Inkscape {
-namespace XML {
-class Node;
-}
+  namespace XML {
+    class Node;
+  }
+
+  namespace LivePathEffect {
+    class Effect;
+  }
 }
 
+typedef std::map<Inkscape::LivePathEffect::Effect *, std::vector<SPCanvasItem *> > HelperPathList;
 
 /**
  * Radial objects are represented by an angle and a distance from
@@ -80,77 +89,24 @@ namespace Inkscape {
 namespace NodePath {
 
 /**
- * This is a node on a subpath
+ * The entire nodepath, containing multiple subpaths
  */
 class Path;
 
 /**
- * This is a subdivision of a NodePath
+ * A subpath is a continuous chain of linked nodes
  */
 class SubPath;
 
-class NodeSide;
-
 /**
- * This is a node (point) along a subpath
+ * One side of a node, i.e. prev or next
  */
-class Node;
+class NodeSide;
 
 /**
- *  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
+ * A node on a subpath
  */
-class Path {
- public:
-/**  Pointer to the current desktop, for reporting purposes */
-       SPDesktop * desktop;
-/**  The parent path of this nodepath */
-       SPObject * object;
-/**  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<Node *> &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;
-    
-    /// draw a "sketch" of the path by using these variables
-    SPCanvasItem *helper_path;
-    SPCurve *curve;
-    bool show_helperpath;
-
-      /// 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;
-};
+class Node;
 
 
 /**
@@ -247,6 +203,69 @@ class Node {
   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<Node *> &l);
+
+       guint numSelected() {return (selected? g_list_length(selected) : 0);}
+       NR::Point& singleSelectedCoords() {return (((Node *) selected->data)->pos);}
+
+    /// draw a "sketch" of the path by using these variables
+    SPCanvasItem *helper_path;
+    SPCurve *curve;
+    bool show_helperpath;
+    guint32 helperpath_rgba;
+    gdouble helperpath_width;
+
+    // the helperpaths provided by all LPEs (and their paramaters) of the current item
+    HelperPathList* helper_path_vec;
+
+      /// 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
 
@@ -257,9 +276,8 @@ enum {
 };
 
 // Do function documentation in nodepath.cpp
-Inkscape::NodePath::Path * sp_nodepath_new (SPDesktop * desktop, SPObject *object, bool show_handles, const char * repr_key = NULL);
+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);
@@ -293,14 +311,23 @@ void sp_node_selected_set_type (Inkscape::NodePath::Path *nodepath, Inkscape::No
 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, Geom::Coord val, Geom::Dim2 axis);
+Geom::Rect sp_node_selected_bbox (Inkscape::NodePath::Path *nodepath);
+boost::optional<Geom::Coord> sp_node_selected_common_coord (Inkscape::NodePath::Path *nodepath, Geom::Dim2 axis);
 
 void sp_nodepath_show_handles(Inkscape::NodePath::Path *nodepath, bool show);
+//SPCanvasItem *sp_nodepath_generate_helperpath(SPDesktop *desktop, SPCurve *curve, const SPItem *item, guint32 color);
+//SPCanvasItem *sp_nodepath_generate_helperpath(SPDesktop *desktop, SPPath *path);
+SPCanvasItem *sp_nodepath_helperpath_from_path(SPDesktop *desktop, SPPath *path);
+void sp_nodepath_show_helperpath(Inkscape::NodePath::Path *nodepath, bool show);
+void sp_nodepath_update_helperpaths(Inkscape::NodePath::Path *np);
+void sp_nodepath_make_straight_path(Inkscape::NodePath::Path *np);
 
 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, NR::Maybe<NR::Point> center);
+void sp_nodepath_flip (Inkscape::NodePath::Path *nodepath, NR::Dim2 axis, boost::optional<NR::Point> center);
 
 #endif