Code

036981f6ffc7df624c14e53cbe026b8abcbe8bdc
[inkscape.git] / src / connector-context.h
1 #ifndef SEEN_CONNECTOR_CONTEXT_H
2 #define SEEN_CONNECTOR_CONTEXT_H
4 /*
5  * Connector creation tool
6  *
7  * Authors:
8  *   Michael Wybrow <mjwybrow@users.sourceforge.net>
9  *
10  * Copyright (C) 2005 Michael Wybrow
11  *
12  * Released under GNU GPL, read the file 'COPYING' for more information
13  */
15 #include <sigc++/sigc++.h>
16 #include <sigc++/connection.h>
17 #include "event-context.h"
18 #include <forward.h>
19 #include <display/display-forward.h>
20 #include <2geom/point.h>
21 #include "libavoid/connector.h"
22 #include "connection-points.h"
23 #include <glibmm/i18n.h>
25 #define SP_TYPE_CONNECTOR_CONTEXT (sp_connector_context_get_type())
26 #define SP_CONNECTOR_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_CONNECTOR_CONTEXT, SPConnectorContext))
27 #define SP_CONNECTOR_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_CONNECTOR_CONTEXT, SPConnectorContextClass))
28 #define SP_IS_CONNECTOR_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_CONNECTOR_CONTEXT))
29 #define SP_IS_CONNECTOR_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_CONNECTOR_CONTEXT))
31 struct SPKnot;
32 namespace Inkscape
33 {
34   class Selection;
35 }
37 enum {
38     SP_CONNECTOR_CONTEXT_IDLE,
39     SP_CONNECTOR_CONTEXT_DRAGGING,
40     SP_CONNECTOR_CONTEXT_CLOSE,
41     SP_CONNECTOR_CONTEXT_STOP,
42     SP_CONNECTOR_CONTEXT_REROUTING,
43     SP_CONNECTOR_CONTEXT_NEWCONNPOINT
44 };
46 enum {
47     SP_CONNECTOR_CONTEXT_DRAWING_MODE,
48     SP_CONNECTOR_CONTEXT_EDITING_MODE
49 };
51 typedef std::map<SPKnot *, ConnectionPoint>  ConnectionPointMap;
53 struct SPConnectorContext : public SPEventContext {
54     Inkscape::Selection *selection;
55     Geom::Point p[5];
57     /** \invar npoints in {0, 2}. */
58     gint npoints;
59     /* The tool mode can be connector drawing or
60        connection points editing.
61     */
62     unsigned int mode : 1;
63     unsigned int state : 4;
65     gchar* knot_tip;
67     // Red curve
68     SPCanvasItem *red_bpath;
69     SPCurve *red_curve;
70     guint32 red_color;
72     // Green curve
73     SPCurve *green_curve;
75     // The new connector
76     SPItem *newconn;
77     Avoid::ConnRef *newConnRef;
78     gdouble curvature;
79     bool isOrthogonal;
81     // The active shape
82     SPItem *active_shape;
83     Inkscape::XML::Node *active_shape_repr;
84     Inkscape::XML::Node *active_shape_layer_repr;
86     // Same as above, but for the active connector
87     SPItem *active_conn;
88     Inkscape::XML::Node *active_conn_repr;
89     sigc::connection sel_changed_connection;
92     // The activehandle
93     SPKnot *active_handle;
95     // The selected handle, used in editing mode
96     SPKnot *selected_handle;
98     SPItem *clickeditem;
99     SPKnot *clickedhandle;
101     ConnectionPointMap connpthandles;
102     SPKnot *endpt_handle[2];
103     guint  endpt_handler_id[2];
104     gchar *shref;
105     gchar *scpid;
106     gchar *ehref;
107     gchar *ecpid;
108     SPCanvasItem *c0, *c1, *cl0, *cl1;
109 };
111 struct SPConnectorContextClass : public SPEventContextClass { };
113 GType sp_connector_context_get_type();
115 void sp_connector_context_switch_mode(SPEventContext* ec, unsigned int newMode);
116 void cc_selection_set_avoid(bool const set_ignore);
117 void cc_create_connection_point(SPConnectorContext* cc);
118 void cc_remove_connection_point(SPConnectorContext* cc);
119 bool cc_item_is_connector(SPItem *item);
122 #endif /* !SEEN_CONNECTOR_CONTEXT_H */
124 /*
125   Local Variables:
126   mode:c++
127   c-file-style:"stroustrup"
128   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
129   indent-tabs-mode:nil
130   fill-column:99
131   End:
132 */
133 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :