1 #ifndef SP_ERASER_CONTEXT_H_SEEN
2 #define SP_ERASER_CONTEXT_H_SEEN
4 /*
5 * Handwriting-like 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 "display/curve.h"
23 #include "event-context.h"
24 #include <display/display-forward.h>
25 #include <libnr/nr-point.h>
27 #define SP_TYPE_ERASER_CONTEXT (sp_eraser_context_get_type())
28 #define SP_ERASER_CONTEXT(o) (GTK_CHECK_CAST((o), SP_TYPE_ERASER_CONTEXT, SPEraserContext))
29 #define SP_ERASER_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_CAST((k), SP_TYPE_ERASER_CONTEXT, SPEraserContextClass))
30 #define SP_IS_ERASER_CONTEXT(o) (GTK_CHECK_TYPE((o), SP_TYPE_ERASER_CONTEXT))
31 #define SP_IS_ERASER_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_TYPE((k), SP_TYPE_ERASER_CONTEXT))
33 class SPEraserContext;
34 class SPEraserContextClass;
36 #define SAMPLING_SIZE 8 /* fixme: ?? */
38 #define ERC_MIN_PRESSURE 0.0
39 #define ERC_MAX_PRESSURE 1.0
40 #define ERC_DEFAULT_PRESSURE 1.0
42 #define ERC_MIN_TILT -1.0
43 #define ERC_MAX_TILT 1.0
44 #define ERC_DEFAULT_TILT 0.0
46 struct SPEraserContext
47 {
48 SPEventContext event_context;
50 /** accumulated shape which ultimately goes in svg:path */
51 SPCurve *accumulated;
53 /** canvas items for "comitted" segments */
54 GSList *segments;
56 /** canvas item for red "leading" segment */
57 SPCanvasItem *currentshape;
58 /** shape of red "leading" segment */
59 SPCurve *currentcurve;
61 /** left edge of the stroke; combined to get accumulated */
62 SPCurve *cal1;
63 /** right edge of the stroke; combined to get accumulated */
64 SPCurve *cal2;
66 /** left edge points for this segment */
67 NR::Point point1[SAMPLING_SIZE];
68 /** right edge points for this segment */
69 NR::Point point2[SAMPLING_SIZE];
70 /** number of edge points for this segment */
71 gint npoints;
73 /* repr */
74 Inkscape::XML::Node *repr;
76 /* Eraser */
77 NR::Point cur;
78 NR::Point vel;
79 double vel_max;
80 NR::Point acc;
81 NR::Point ang;
82 NR::Point last;
83 NR::Point del;
84 /* extended input data */
85 gdouble pressure;
86 gdouble xtilt;
87 gdouble ytilt;
88 /* attributes */
89 guint dragging : 1; /* mouse state: mouse is dragging */
90 guint usepressure : 1;
91 guint usetilt : 1;
92 double mass, drag;
93 double angle;
94 double width;
96 double vel_thin;
97 double flatness;
98 double tremor;
99 double cap_rounding;
101 Inkscape::MessageContext *_message_context;
103 bool is_drawing;
105 /** uses absolute width independent of zoom */
106 bool abs_width;
107 };
109 struct SPEraserContextClass
110 {
111 SPEventContextClass parent_class;
112 };
114 GtkType sp_eraser_context_get_type(void);
116 #endif // SP_ERASER_CONTEXT_H_SEEN
118 /*
119 Local Variables:
120 mode:c++
121 c-file-style:"stroustrup"
122 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
123 indent-tabs-mode:nil
124 fill-column:99
125 End:
126 */
127 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :