17
18
#include <glib/gtypes.h>
18
19
#include <glib/gslist.h>
20
#include "libnr/nr-forward.h"
21
#include "libnr/nr-point.h"
22
#include "libnr/nr-rect.h"
24
/// Wrapper around NArtBpath.
29
/// Index in bpath[] of NR_END element.
32
/// Allocated size (i.e., capacity) of bpath[] array. Not to be confused
33
/// with the SP_CURVE_LENGTH macro, which returns the logical length of
34
/// the path (i.e., index of NR_END).
37
/// Index in bpath[] of the start (i.e., moveto element) of the last
38
/// subpath in this path.
41
/// Previous moveto position.
42
/// \note This is used for coalescing moveto's, whereas if we're to
43
/// conform to the SVG spec then we mustn't coalesce movetos if we have
44
/// midpoint markers. Ref:
45
/// http://www.w3.org/TR/SVG11/implnote.html#PathElementImplementationNotes
46
/// (first subitem of the item about zero-length path segments)
49
/// True iff current point is defined. Initially false for a new curve;
50
/// becomes true after moveto; becomes false on closepath. Curveto,
51
/// lineto etc. require hascpt; hascpt remains true after lineto/curveto.
54
/// True iff previous was moveto.
57
/// True iff bpath end is moving.
60
/// True iff all subpaths are closed.
21
#include <2geom/forward.h>
23
#include <boost/optional.hpp>
29
explicit SPCurve(Geom::PathVector const& pathv);
30
static SPCurve * new_from_rect(Geom::Rect const &rect);
34
void set_pathvector(Geom::PathVector const & new_pathv);
35
Geom::PathVector const & get_pathvector() const;
40
SPCurve * copy() const;
42
guint get_segment_count() const;
43
guint nodes_in_path() const;
45
bool is_empty() const;
46
bool is_closed() const;
47
Geom::Curve const * last_segment() const;
48
Geom::Path const * last_path() const;
49
Geom::Curve const * first_segment() const;
50
Geom::Path const * first_path() const;
51
boost::optional<Geom::Point> first_point() const;
52
boost::optional<Geom::Point> last_point() const;
53
boost::optional<Geom::Point> second_point() const;
54
boost::optional<Geom::Point> penultimate_point() const;
58
void moveto(Geom::Point const &p);
59
void moveto(gdouble x, gdouble y);
60
void lineto(Geom::Point const &p);
61
void lineto(gdouble x, gdouble y);
62
void quadto(Geom::Point const &p1, Geom::Point const &p2);
63
void quadto(gdouble x1, gdouble y1, gdouble x2, gdouble y2);
64
void curveto(Geom::Point const &p0, Geom::Point const &p1, Geom::Point const &p2);
65
void curveto(gdouble x0, gdouble y0, gdouble x1, gdouble y1, gdouble x2, gdouble y2);
67
void closepath_current();
70
void transform(Geom::Matrix const &m);
71
void stretch_endpoints(Geom::Point const &, Geom::Point const &);
72
void move_endpoints(Geom::Point const &, Geom::Point const &);
73
void last_point_additive_move(Geom::Point const & p);
75
void append(SPCurve const *curve2, bool use_lineto);
76
SPCurve * append_continuous(SPCurve const *c1, gdouble tolerance);
77
SPCurve * create_reverse() const;
79
GSList * split() const;
80
static SPCurve * concat(GSList const *list);
85
Geom::PathVector _pathv;
88
// Don't implement these:
89
SPCurve(const SPCurve&);
90
SPCurve& operator=(const SPCurve&);
64
#define SP_CURVE_LENGTH(c) (((SPCurve const *)(c))->end)
65
#define SP_CURVE_BPATH(c) (((SPCurve const *)(c))->_bpath)
66
#define SP_CURVE_SEGMENT(c,i) (((SPCurve const *)(c))->_bpath + (i))
70
SPCurve *sp_curve_new();
71
SPCurve *sp_curve_new_sized(gint length);
72
SPCurve *sp_curve_new_from_bpath(NArtBpath *bpath);
73
SPCurve *sp_curve_new_from_foreign_bpath(NArtBpath const bpath[]);
74
SPCurve *sp_curve_new_from_rect(NR::Maybe<NR::Rect> const &rect);
76
SPCurve *sp_curve_ref(SPCurve *curve);
77
SPCurve *sp_curve_unref(SPCurve *curve);
79
SPCurve *sp_curve_copy(SPCurve *curve);
80
SPCurve *sp_curve_concat(GSList const *list);
81
GSList *sp_curve_split(SPCurve const *curve);
82
void sp_curve_transform(SPCurve *curve, NR::Matrix const &);
83
void sp_curve_transform(SPCurve *curve, NR::translate const &);
84
void sp_curve_stretch_endpoints(SPCurve *curve, NR::Point const &, NR::Point const &);
85
void sp_curve_move_endpoints(SPCurve *curve, NR::Point const &,
90
void sp_curve_reset(SPCurve *curve);
92
void sp_curve_moveto(SPCurve *curve, NR::Point const &p);
93
void sp_curve_moveto(SPCurve *curve, gdouble x, gdouble y);
94
void sp_curve_lineto(SPCurve *curve, NR::Point const &p);
95
void sp_curve_lineto(SPCurve *curve, gdouble x, gdouble y);
96
void sp_curve_lineto_moving(SPCurve *curve, gdouble x, gdouble y);
97
void sp_curve_curveto(SPCurve *curve, NR::Point const &p0, NR::Point const &p1, NR::Point const &p2);
98
void sp_curve_curveto(SPCurve *curve, gdouble x0, gdouble y0, gdouble x1, gdouble y1, gdouble x2, gdouble y2);
99
void sp_curve_closepath(SPCurve *curve);
100
void sp_curve_closepath_current(SPCurve *curve);
102
SPCurve *sp_curve_append_continuous(SPCurve *c0, SPCurve const *c1, gdouble tolerance);
104
#define sp_curve_is_empty sp_curve_empty
105
bool sp_curve_empty(SPCurve *curve);
106
NArtBpath *sp_curve_last_bpath(SPCurve const *curve);
107
NArtBpath *sp_curve_first_bpath(SPCurve const *curve);
108
NR::Point sp_curve_first_point(SPCurve const *curve);
109
NR::Point sp_curve_last_point(SPCurve const *curve);
110
NR::Point sp_curve_second_point(SPCurve const *curve);
111
NR::Point sp_curve_penultimate_point(SPCurve const *curve);
113
void sp_curve_append(SPCurve *curve, SPCurve const *curve2, bool use_lineto);
114
SPCurve *sp_curve_reverse(SPCurve const *curve);
115
void sp_curve_backspace(SPCurve *curve);
118
93
#endif /* !SEEN_DISPLAY_CURVE_H */