Code

Refactoring begining
[inkscape.git] / src / dyna-draw-context.h
1 #ifndef SP_DYNA_DRAW_CONTEXT_H_SEEN
2 #define SP_DYNA_DRAW_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  *
18  * Released under GNU GPL, read the file 'COPYING' for more information
19  */
21 #include "event-context.h"
22 #include <display/display-forward.h>
23 #include <libnr/nr-point.h>
25 #define SP_TYPE_DYNA_DRAW_CONTEXT (sp_dyna_draw_context_get_type())
26 #define SP_DYNA_DRAW_CONTEXT(o) (GTK_CHECK_CAST((o), SP_TYPE_DYNA_DRAW_CONTEXT, SPDynaDrawContext))
27 #define SP_DYNA_DRAW_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_CAST((k), SP_TYPE_DYNA_DRAW_CONTEXT, SPDynaDrawContextClass))
28 #define SP_IS_DYNA_DRAW_CONTEXT(o) (GTK_CHECK_TYPE((o), SP_TYPE_DYNA_DRAW_CONTEXT))
29 #define SP_IS_DYNA_DRAW_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_TYPE((k), SP_TYPE_DYNA_DRAW_CONTEXT))
31 class SPDynaDrawContext;
32 class SPDynaDrawContextClass;
34 #define SAMPLING_SIZE 8        /* fixme: ?? */
36 #define DDC_MIN_PRESSURE      0.0
37 #define DDC_MAX_PRESSURE      1.0
38 #define DDC_DEFAULT_PRESSURE  1.0
40 #define DDC_MIN_TILT         -1.0
41 #define DDC_MAX_TILT          1.0
42 #define DDC_DEFAULT_TILT      0.0
44 struct SPDynaDrawContext
45 {
46     SPEventContext event_context;
48     /** accumulated shape which ultimately goes in svg:path */
49     SPCurve *accumulated;
51     /** canvas items for "comitted" segments */
52     GSList *segments;
54     /** canvas item for red "leading" segment */
55     SPCanvasItem *currentshape;
56     /** shape of red "leading" segment */
57     SPCurve *currentcurve;
59     /** left edge of the stroke; combined to get accumulated */
60     SPCurve *cal1;
61     /** right edge of the stroke; combined to get accumulated */
62     SPCurve *cal2;
64     /** left edge points for this segment */
65     NR::Point point1[SAMPLING_SIZE];
66     /** right edge points for this segment */
67     NR::Point point2[SAMPLING_SIZE];
68     /** number of edge points for this segment */
69     gint npoints;
71     /* repr */
72     Inkscape::XML::Node *repr;
74     /* DynaDraw */
75     NR::Point cur;
76     NR::Point vel;
77     double vel_max;
78     NR::Point acc;
79     NR::Point ang;
80     NR::Point last;
81     NR::Point del;
82     /* extended input data */
83     gdouble pressure;
84     gdouble xtilt;
85     gdouble ytilt;
86     /* attributes */
87     guint dragging : 1;           /* mouse state: mouse is dragging */
88     guint usepressure : 1;
89     guint usetilt : 1;
90     double mass, drag;
91     double angle;
92     double width;
94     double vel_thin;
95     double flatness;
96     double tremor;
97     double cap_rounding;
99     Inkscape::MessageContext *_message_context;
101     bool is_drawing;
103     /** uses absolute width independent of zoom */
104     bool abs_width;
106     /** newly created object remain selected */
107     bool keep_selected;
109     double hatch_spacing;
110     double hatch_spacing_step;
111     SPItem *hatch_item;
112     Path *hatch_livarot_path;
113     std::list<double> hatch_nearest_past;
114     std::list<double> hatch_pointer_past;
115     NR::Point hatch_last_nearest, hatch_last_pointer;
116     NR::Point hatch_vector_accumulated;
117     bool hatch_escaped;
118     SPCanvasItem *hatch_area;
120     bool trace_bg;
121 };
123 struct SPDynaDrawContextClass
125     SPEventContextClass parent_class;
126 };
128 GType sp_dyna_draw_context_get_type(void);
130 #endif // SP_DYNA_DRAW_CONTEXT_H_SEEN
132 /*
133   Local Variables:
134   mode:c++
135   c-file-style:"stroustrup"
136   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
137   indent-tabs-mode:nil
138   fill-column:99
139   End:
140 */
141 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :