1 #ifndef COMMON_CONTEXT_H_SEEN
2 #define COMMON_CONTEXT_H_SEEN
4 /*
5 * Common drawing mode
6 *
7 * Authors:
8 * Mitsuru Oka <oka326@parkcity.ne.jp>
9 * Lauris Kaplinski <lauris@kaplinski.com>
10 *
11 * The original dynadraw code:
12 * Paul Haeberli <paul@sgi.com>
13 *
14 * Copyright (C) 1998 The Free Software Foundation
15 * Copyright (C) 1999-2002 authors
16 * Copyright (C) 2001-2002 Ximian, Inc.
17 * Copyright (C) 2008 Jon A. Cruz
18 *
19 * Released under GNU GPL, read the file 'COPYING' for more information
20 */
22 #include "event-context.h"
23 #include "display/curve.h"
24 #include "display/display-forward.h"
26 #define SP_TYPE_COMMON_CONTEXT (sp_common_context_get_type())
27 #define SP_COMMON_CONTEXT(o) (GTK_CHECK_CAST((o), SP_TYPE_COMMON_CONTEXT, SPCommonContext))
28 #define SP_COMMON_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_CAST((k), SP_TYPE_COMMON_CONTEXT, SPCommonContextClass))
29 #define SP_IS_COMMON_CONTEXT(o) (GTK_CHECK_TYPE((o), SP_TYPE_COMMON_CONTEXT))
30 #define SP_IS_COMMON_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_TYPE((k), SP_TYPE_COMMON_CONTEXT))
32 class SPCommonContext;
33 class SPCommonContextClass;
35 #define SAMPLING_SIZE 8 /* fixme: ?? */
38 struct SPCommonContext : public SPEventContext {
39 /** accumulated shape which ultimately goes in svg:path */
40 SPCurve *accumulated;
42 /** canvas items for "comitted" segments */
43 GSList *segments;
45 /** canvas item for red "leading" segment */
46 SPCanvasItem *currentshape;
47 /** shape of red "leading" segment */
48 SPCurve *currentcurve;
50 /** left edge of the stroke; combined to get accumulated */
51 SPCurve *cal1;
53 /** right edge of the stroke; combined to get accumulated */
54 SPCurve *cal2;
56 /** left edge points for this segment */
57 NR::Point point1[SAMPLING_SIZE];
59 /** right edge points for this segment */
60 NR::Point point2[SAMPLING_SIZE];
62 /** number of edge points for this segment */
63 gint npoints;
65 /* repr */
66 Inkscape::XML::Node *repr;
68 /* common */
69 NR::Point cur;
70 NR::Point vel;
71 double vel_max;
72 NR::Point acc;
73 NR::Point ang;
74 NR::Point last;
75 NR::Point del;
77 /* extended input data */
78 gdouble pressure;
79 gdouble xtilt;
80 gdouble ytilt;
82 /* attributes */
83 guint dragging : 1; /* mouse state: mouse is dragging */
84 guint usepressure : 1;
85 guint usetilt : 1;
86 double mass, drag;
87 double angle;
88 double width;
90 double vel_thin;
91 double flatness;
92 double tremor;
93 double cap_rounding;
95 Inkscape::MessageContext *_message_context;
97 bool is_drawing;
99 /** uses absolute width independent of zoom */
100 bool abs_width;
101 };
103 struct SPCommonContextClass : public SPEventContextClass{};
105 GType sp_common_context_get_type(void);
107 #endif // COMMON_CONTEXT_H_SEEN
109 /*
110 Local Variables:
111 mode:c++
112 c-file-style:"stroustrup"
113 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
114 indent-tabs-mode:nil
115 fill-column:99
116 End:
117 */
118 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :