Code

Fixed a few warnings and hardcoded PANGO_GLYPH_* constants
[inkscape.git] / src / display / curve.h
1 #ifndef SEEN_DISPLAY_CURVE_H
2 #define SEEN_DISPLAY_CURVE_H
4 /** \file
5  * Wrapper around an array of NArtBpath objects.
6  *
7  * Author:
8  *   Lauris Kaplinski <lauris@kaplinski.com>
9  *
10  * Copyright (C) 2000 Lauris Kaplinski
11  * Copyright (C) 2000-2001 Ximian, Inc.
12  * Copyright (C) 2002 Lauris Kaplinski
13  *
14  * Released under GNU GPL
15  */
17 #include <glib/gtypes.h>
18 #include <glib/gslist.h>
20 #include "libnr/nr-forward.h"
21 #include "libnr/nr-point.h"
23 /// Wrapper around NArtBpath.
24 struct SPCurve {
25     gint refcount;
26     NArtBpath *_bpath;
27     
28     /// Index in bpath[] of NR_END element.
29     gint end;
31     /// Allocated size (i.e., capacity) of bpath[] array.  Not to be confused 
32     /// with the SP_CURVE_LENGTH macro, which returns the logical length of 
33     /// the path (i.e., index of NR_END).
34     gint length;
36     /// Index in bpath[] of the start (i.e., moveto element) of the last 
37     /// subpath in this path.
38     gint substart;
40     /// Previous moveto position.
41     /// \note This is used for coalescing moveto's, whereas if we're to 
42     /// conform to the SVG spec then we mustn't coalesce movetos if we have 
43     /// midpoint markers.  Ref:
44     /// http://www.w3.org/TR/SVG11/implnote.html#PathElementImplementationNotes
45     /// (first subitem of the item about zero-length path segments)
46     NR::Point movePos;
48     /// True iff current point is defined.  Initially false for a new curve; 
49     /// becomes true after moveto; becomes false on closepath.  Curveto, 
50     /// lineto etc. require hascpt; hascpt remains true after lineto/curveto.
51     bool hascpt : 1;
52     
53     /// True iff previous was moveto.
54     bool posSet : 1;
56     /// True iff bpath end is moving.
57     bool moving : 1;
58     
59     /// True iff all subpaths are closed.
60     bool closed : 1;
61 };
63 #define SP_CURVE_LENGTH(c) (((SPCurve const *)(c))->end)
64 #define SP_CURVE_BPATH(c) (((SPCurve const *)(c))->_bpath)
65 #define SP_CURVE_SEGMENT(c,i) (((SPCurve const *)(c))->_bpath + (i))
67 /* Constructors */
69 SPCurve *sp_curve_new();
70 SPCurve *sp_curve_new_sized(gint length);
71 SPCurve *sp_curve_new_from_bpath(NArtBpath *bpath);
72 SPCurve *sp_curve_new_from_foreign_bpath(NArtBpath const bpath[]);
74 SPCurve *sp_curve_ref(SPCurve *curve);
75 SPCurve *sp_curve_unref(SPCurve *curve);
77 SPCurve *sp_curve_copy(SPCurve *curve);
78 SPCurve *sp_curve_concat(GSList const *list);
79 GSList *sp_curve_split(SPCurve const *curve);
80 void sp_curve_transform(SPCurve *curve, NR::Matrix const &);
81 void sp_curve_transform(SPCurve *curve, NR::translate const &);
82 void sp_curve_stretch_endpoints(SPCurve *curve, NR::Point const &, NR::Point const &);
83 void sp_curve_move_endpoints(SPCurve *curve, NR::Point const &,
84         NR::Point const &);
86 /* Methods */
88 void sp_curve_reset(SPCurve *curve);
90 void sp_curve_moveto(SPCurve *curve, NR::Point const &p);
91 void sp_curve_moveto(SPCurve *curve, gdouble x, gdouble y);
92 void sp_curve_lineto(SPCurve *curve, NR::Point const &p);
93 void sp_curve_lineto(SPCurve *curve, gdouble x, gdouble y);
94 void sp_curve_lineto_moving(SPCurve *curve, gdouble x, gdouble y);
95 void sp_curve_curveto(SPCurve *curve, NR::Point const &p0, NR::Point const &p1, NR::Point const &p2);
96 void sp_curve_curveto(SPCurve *curve, gdouble x0, gdouble y0, gdouble x1, gdouble y1, gdouble x2, gdouble y2);
97 void sp_curve_closepath(SPCurve *curve);
98 void sp_curve_closepath_current(SPCurve *curve);
100 SPCurve *sp_curve_append_continuous(SPCurve *c0, SPCurve const *c1, gdouble tolerance);
102 #define sp_curve_is_empty sp_curve_empty
103 bool sp_curve_empty(SPCurve *curve);
104 NArtBpath *sp_curve_last_bpath(SPCurve const *curve);
105 NArtBpath *sp_curve_first_bpath(SPCurve const *curve);
106 NR::Point sp_curve_first_point(SPCurve const *curve);
107 NR::Point sp_curve_last_point(SPCurve const *curve);
108 NR::Point sp_curve_second_point(SPCurve const *curve);
109 NR::Point sp_curve_penultimate_point(SPCurve const *curve);
111 void sp_curve_append(SPCurve *curve, SPCurve const *curve2, bool use_lineto);
112 SPCurve *sp_curve_reverse(SPCurve const *curve);
113 void sp_curve_backspace(SPCurve *curve);
116 #endif /* !SEEN_DISPLAY_CURVE_H */
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 :