1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/* Authors:
* Johan Engelen
*
* Copyright (C) 2010-2012 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "spiro-converters.h"
#include <2geom/path.h>
#include "display/curve.h"
#include <glib.h>
#define SPIRO_SHOW_INFINITE_COORDINATE_CALLS
#ifdef SPIRO_SHOW_INFINITE_COORDINATE_CALLS
# define SPIRO_G_MESSAGE(x) g_message(x)
#else
# define SPIRO_G_MESSAGE(x)
#endif
namespace Spiro {
void
ConverterSPCurve::moveto(double x, double y, bool is_open)
{
if ( IS_FINITE(x) && IS_FINITE(y) ) {
_curve.moveto(x, y);
if (!is_open) {
_curve.closepath();
}
} else {
SPIRO_G_MESSAGE("Spiro: moveto not finite");
}
}
void
ConverterSPCurve::lineto(double x, double y)
{
if ( IS_FINITE(x) && IS_FINITE(y) ) {
_curve.lineto(x, y);
} else {
SPIRO_G_MESSAGE("Spiro: lineto not finite");
}
}
void
ConverterSPCurve::quadto(double xm, double ym, double x3, double y3)
{
if ( IS_FINITE(xm) && IS_FINITE(ym) && IS_FINITE(x3) && IS_FINITE(y3) ) {
_curve.quadto(xm, ym, x3, y3);
} else {
SPIRO_G_MESSAGE("Spiro: quadto not finite");
}
}
void
ConverterSPCurve::curveto(double x1, double y1, double x2, double y2, double x3, double y3)
{
if ( IS_FINITE(x1) && IS_FINITE(y1) && IS_FINITE(x2) && IS_FINITE(y2) ) {
_curve.curveto(x1, y1, x2, y2, x3, y3);
} else {
SPIRO_G_MESSAGE("Spiro: curveto not finite");
}
}
void
ConverterPath::moveto(double x, double y, bool is_open)
{
if ( IS_FINITE(x) && IS_FINITE(y) ) {
_path.start(Geom::Point(x, y));
_path.close(!is_open);
} else {
SPIRO_G_MESSAGE("spiro moveto not finite");
}
}
void
ConverterPath::lineto(double x, double y)
{
if ( IS_FINITE(x) && IS_FINITE(y) ) {
_path.appendNew<Geom::LineSegment>( Geom::Point(x, y) );
} else {
SPIRO_G_MESSAGE("spiro lineto not finite");
}
}
void
ConverterPath::quadto(double xm, double ym, double x3, double y3)
{
if ( IS_FINITE(xm) && IS_FINITE(ym) && IS_FINITE(x3) && IS_FINITE(y3) ) {
_path.appendNew<Geom::QuadraticBezier>(Geom::Point(xm, ym), Geom::Point(x3, y3));
} else {
SPIRO_G_MESSAGE("spiro quadto not finite");
}
}
void
ConverterPath::curveto(double x1, double y1, double x2, double y2, double x3, double y3)
{
if ( IS_FINITE(x1) && IS_FINITE(y1) && IS_FINITE(x2) && IS_FINITE(y2) ) {
_path.appendNew<Geom::CubicBezier>(Geom::Point(x1, y1), Geom::Point(x2, y2), Geom::Point(x3, y3));
} else {
SPIRO_G_MESSAGE("spiro curveto not finite");
}
}
} // namespace Spiro
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
|