1 #ifndef __SP_DYNA_DRAW_CONTEXT_H__
2 #define __SP_DYNA_DRAW_CONTEXT_H__
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 *
18 * Released under GNU GPL, read the file 'COPYING' for more information
19 */
21 #include "display/curve.h"
22 #include "event-context.h"
23 #include <display/display-forward.h>
24 #include <libnr/nr-point.h>
26 #define SP_TYPE_DYNA_DRAW_CONTEXT (sp_dyna_draw_context_get_type())
27 #define SP_DYNA_DRAW_CONTEXT(o) (GTK_CHECK_CAST((o), SP_TYPE_DYNA_DRAW_CONTEXT, SPDynaDrawContext))
28 #define SP_DYNA_DRAW_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_CAST((k), SP_TYPE_DYNA_DRAW_CONTEXT, SPDynaDrawContextClass))
29 #define SP_IS_DYNA_DRAW_CONTEXT(o) (GTK_CHECK_TYPE((o), SP_TYPE_DYNA_DRAW_CONTEXT))
30 #define SP_IS_DYNA_DRAW_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_TYPE((k), SP_TYPE_DYNA_DRAW_CONTEXT))
32 class SPDynaDrawContext;
33 class SPDynaDrawContextClass;
35 #define SAMPLING_SIZE 16 /* fixme: ?? */
37 #define DDC_MIN_PRESSURE 0.0
38 #define DDC_MAX_PRESSURE 1.0
39 #define DDC_DEFAULT_PRESSURE 1.0
41 #define DDC_MIN_TILT -1.0
42 #define DDC_MAX_TILT 1.0
43 #define DDC_DEFAULT_TILT 0.0
45 struct SPDynaDrawContext
46 {
47 SPEventContext event_context;
49 SPCurve *accumulated;
50 GSList *segments;
51 /* current shape and curves */
52 SPCanvasItem *currentshape;
53 SPCurve *currentcurve;
54 SPCurve *cal1;
55 SPCurve *cal2;
56 /* temporary work area */
57 NR::Point point1[SAMPLING_SIZE];
58 NR::Point point2[SAMPLING_SIZE];
59 gint npoints;
61 /* repr */
62 Inkscape::XML::Node *repr;
64 /* time_id if use timeout */
65 gint timer_id;
67 /* DynaDraw */
68 NR::Point cur;
69 NR::Point vel;
70 NR::Point acc;
71 NR::Point ang;
72 NR::Point last;
73 NR::Point del;
74 /* extended input data */
75 gdouble pressure;
76 gdouble xtilt;
77 gdouble ytilt;
78 /* attributes */
79 /* fixme: shuld be merge dragging and dynahand ?? */
80 guint dragging : 1; /* mouse state: mouse is dragging */
81 guint dynahand : 1; /* mouse state: mouse is in draw */
82 guint use_timeout : 1;
83 guint use_calligraphic : 1;
84 double mass, drag;
85 double angle;
86 double width;
87 guint usepressure : 1;
88 guint usetilt : 1;
90 double vel_thin;
91 double flatness;
93 Inkscape::MessageContext *_message_context;
95 bool is_drawing;
96 };
98 struct SPDynaDrawContextClass
99 {
100 SPEventContextClass parent_class;
101 };
103 GtkType sp_dyna_draw_context_get_type(void);
105 #endif
107 /*
108 Local Variables:
109 mode:c++
110 c-file-style:"stroustrup"
111 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
112 indent-tabs-mode:nil
113 fill-column:99
114 End:
115 */
116 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :