3bb8ab5f7528a67bb2651e72967e4c14b5372e58
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 8 /* 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 /** accumulated shape which ultimately goes in svg:path */
50 SPCurve *accumulated;
52 /** canvas items for "comitted" segments */
53 GSList *segments;
55 /** canvas item for red "leading" segment */
56 SPCanvasItem *currentshape;
57 /** shape of red "leading" segment */
58 SPCurve *currentcurve;
60 /** left edge of the stroke; combined to get accumulated */
61 SPCurve *cal1;
62 /** right edge of the stroke; combined to get accumulated */
63 SPCurve *cal2;
65 /** left edge points for this segment */
66 NR::Point point1[SAMPLING_SIZE];
67 /** right edge points for this segment */
68 NR::Point point2[SAMPLING_SIZE];
69 /** number of edge points for this segment */
70 gint npoints;
72 /* repr */
73 Inkscape::XML::Node *repr;
75 /* DynaDraw */
76 NR::Point cur;
77 NR::Point vel;
78 double vel_max;
79 NR::Point acc;
80 NR::Point ang;
81 NR::Point last;
82 NR::Point del;
83 /* extended input data */
84 gdouble pressure;
85 gdouble xtilt;
86 gdouble ytilt;
87 /* attributes */
88 guint dragging : 1; /* mouse state: mouse is dragging */
89 guint usepressure : 1;
90 guint usetilt : 1;
91 double mass, drag;
92 double angle;
93 double width;
95 double vel_thin;
96 double flatness;
97 double tremor;
98 double cap_rounding;
100 Inkscape::MessageContext *_message_context;
102 bool is_drawing;
104 /** uses absolute width independent of zoom */
105 bool abs_width;
107 /** newly created object remain selected */
108 bool keep_selected;
110 double hatch_spacing;
111 double hatch_spacing_step;
112 SPItem *hatch_item;
113 Path *hatch_livarot_path;
114 std::list<double> hatch_nearest_past;
115 std::list<double> hatch_pointer_past;
116 NR::Point hatch_last_nearest, hatch_last_pointer;
117 NR::Point hatch_vector_accumulated;
118 bool hatch_escaped;
119 SPCanvasItem *hatch_area;
121 bool trace_bg;
123 bool is_dilating;
124 SPCanvasItem *dilate_area;
125 };
127 struct SPDynaDrawContextClass
128 {
129 SPEventContextClass parent_class;
130 };
132 GtkType sp_dyna_draw_context_get_type(void);
134 #endif
136 /*
137 Local Variables:
138 mode:c++
139 c-file-style:"stroustrup"
140 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
141 indent-tabs-mode:nil
142 fill-column:99
143 End:
144 */
145 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :