Code

Fix crash in cycle-selection (and restructure internals).
[inkscape.git] / src / connector-context.h
index e8d9a4390d5073b21a5122760ff42c51df86afc6..b03d0fcf0935358b307b9b738983c356ac839b0f 100644 (file)
 #include <sigc++/connection.h>
 #include "event-context.h"
 #include <forward.h>
-#include <display/display-forward.h>
-#include <libnr/nr-point.h>
+#include <2geom/point.h>
 #include "libavoid/connector.h"
-
+#include "connection-points.h"
+#include <glibmm/i18n.h>
 
 #define SP_TYPE_CONNECTOR_CONTEXT (sp_connector_context_get_type())
 #define SP_CONNECTOR_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_CONNECTOR_CONTEXT, SPConnectorContext))
@@ -28,6 +28,8 @@
 #define SP_IS_CONNECTOR_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_CONNECTOR_CONTEXT))
 
 struct SPKnot;
+struct SPCurve;
+
 namespace Inkscape
 {
   class Selection;
@@ -38,32 +40,45 @@ enum {
     SP_CONNECTOR_CONTEXT_DRAGGING,
     SP_CONNECTOR_CONTEXT_CLOSE,
     SP_CONNECTOR_CONTEXT_STOP,
-    SP_CONNECTOR_CONTEXT_REROUTING
+    SP_CONNECTOR_CONTEXT_REROUTING,
+    SP_CONNECTOR_CONTEXT_NEWCONNPOINT
 };
 
+enum {
+    SP_CONNECTOR_CONTEXT_DRAWING_MODE,
+    SP_CONNECTOR_CONTEXT_EDITING_MODE
+};
+
+typedef std::map<SPKnot *, ConnectionPoint>  ConnectionPointMap;
 
 struct SPConnectorContext : public SPEventContext {
     Inkscape::Selection *selection;
-    NR::Point p[5];
+    Geom::Point p[5];
 
     /** \invar npoints in {0, 2}. */
     gint npoints;
-
+    /* The tool mode can be connector drawing or
+       connection points editing.
+    */
     unsigned int mode : 1;
     unsigned int state : 4;
 
+    gchar* knot_tip;
+
     // Red curve
     SPCanvasItem *red_bpath;
     SPCurve *red_curve;
     guint32 red_color;
-    
+
     // Green curve
     SPCurve *green_curve;
-    
+
     // The new connector
     SPItem *newconn;
     Avoid::ConnRef *newConnRef;
-    
+    gdouble curvature;
+    bool isOrthogonal;
+
     // The active shape
     SPItem *active_shape;
     Inkscape::XML::Node *active_shape_repr;
@@ -74,18 +89,23 @@ struct SPConnectorContext : public SPEventContext {
     Inkscape::XML::Node *active_conn_repr;
     sigc::connection sel_changed_connection;
 
-    
+
     // The activehandle
     SPKnot *active_handle;
 
+    // The selected handle, used in editing mode
+    SPKnot *selected_handle;
+
     SPItem *clickeditem;
     SPKnot *clickedhandle;
-    
-    SPKnot *connpthandle;
+
+    ConnectionPointMap connpthandles;
     SPKnot *endpt_handle[2];
     guint  endpt_handler_id[2];
-    gchar *sid;
-    gchar *eid;
+    gchar *shref;
+    gchar *scpid;
+    gchar *ehref;
+    gchar *ecpid;
     SPCanvasItem *c0, *c1, *cl0, *cl1;
 };
 
@@ -93,7 +113,10 @@ struct SPConnectorContextClass : public SPEventContextClass { };
 
 GType sp_connector_context_get_type();
 
+void sp_connector_context_switch_mode(SPEventContext* ec, unsigned int newMode);
 void cc_selection_set_avoid(bool const set_ignore);
+void cc_create_connection_point(SPConnectorContext* cc);
+void cc_remove_connection_point(SPConnectorContext* cc);
 bool cc_item_is_connector(SPItem *item);
 
 
@@ -108,4 +131,4 @@ bool cc_item_is_connector(SPItem *item);
   fill-column:99
   End:
 */
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :