1 #define _USE_MATH_DEFINES 11 defaultLineStyle(
SOLID),
16 : QObject(that.parent()),
17 points(that.points), opcode(that.opcode),
18 turtle_angle(that.turtle_angle),
19 defaultLineStyle(that.defaultLineStyle),
20 lineStyles(that.lineStyles)
27 Path::Path(QString svg,
bool forceAbsolute, QObject* parent)
87 return (*
this) +=
Path(svg);
117 angle = -angle*M_PI/180.0;
128 return map(QTransform(mx));
132 return scale(ascale,ascale);
137 tf.
scale(scalex,scaley);
158 QMatrix matrix(-1,0,0, +1,0,0);
163 QMatrix matrix(+1,0,0, -1,0,0);
168 void swap(qreal& a, qreal& b) {
174 void swap(QPointF& a, QPointF& b) {
175 swap (a.rx(),b.rx());
176 swap (a.ry(),b.ry());
184 QPointF* a = &
points.first();
185 QPointF* b = &
points.last();
220 if (
size()==0)
return;
222 Q_ASSERT(style >= 0 && style <=
NONE);
243 QRegExp numexp(
"(\\-?[0-9]*\\.?[0-9]+(e[+\\-]?[0-9]+)?)|[MmLlVvHhZz]");
245 int pos = numexp.indexIn(
str);
248 int len = numexp.matchedLength();
252 if (forceAbsolute) qc = qc.toUpper();
258 case 'z':
Z();
break;
263 double d =
str.midRef(pos,len).toDouble(&ok);
296 pos = numexp.indexIn(
str, pos+len);
312 QRegExp numexp(
"(\\-?[0-9]*\\.?[0-9]+(e[+\\-]?[0-9]+)?)|[mlh]");
314 int pos = numexp.indexIn(
str);
317 int len = numexp.matchedLength();
339 double d =
str.midRef(pos,len).toDouble(&ok);
350 pos = numexp.indexIn(
str, pos+len);
369 for(
int i=0; i <
opcode.size(); i++)
375 next->rx() += prev->rx();
376 next->ry() += prev->ry();
379 next->rx() += prev->rx();
380 next->ry() = prev->ry();
383 next->rx() = prev->rx();
384 next->ry() += prev->ry();
387 next->ry() = prev->ry();
390 next->rx() = prev->rx();
400 double p = pow(10.0f,precision);
401 for(
int i=0; i <
points.size(); ++i)
415 for(
int i=1; i <
points.size(); )
void parseIpe(QString str)
pare an IPE input string
QPolygonF points
the list of vertexes
Path * mirrorx()
mirror the curve about the x-axis
static int distance(int a, int b, int n)
void swap(qreal &a, qreal &b)
static Path svgPath(QString str, bool forceAbsolute=false)
static constructor from SVG input string
global definitions for all algorithms.
void parseSvg(QString str, bool forceAbsolute=false)
parse an SVG input string
static Path ipePath(QString str)
static constructor from IPE input string
void removeDuplicates()
remove all duplicate points
Path * translate(QPointF offset)
translate the curve
Path * left(double angle)
turn the turtle's head to the left
void append(QPointF p, char opcode)
LineStyle defaultLineStyle
default style for grid disaplay
Path * reset(double angle=0.0)
turn the turtle's head to a given angle
Path * map(QTransform tf)
apply a transformation to all vertexes
Path * rotate(double angle)
rotate the curve
Path * ensureClosed()
make sure the curve is closed
Path * undo()
remove the last vertex
void setDefaultLineStyle(int)
change the default style of grid lines
Represents a polygonal curve.
Path * revert()
revert the order of vertexes
Path * mirrory()
mirror the curve about the y-axis
void outerLineStyle(int)
set the style of outermost grid lines
Path * close()
return to the first vertex, creating a closed curve
Path * forward(double distance)
append a new vertex, relative to the current position
Path * scale(double scale)
scale the polygonal curve
Path * Z()
return to the first vertex, creating a closed curve
Q_INVOKABLE Path & operator+=(const Path &that)
append operator
const QPolygonF & toCurve(int precision=0)
convert to a QPolygonF object, ready for processing by the Frechet distance algorithms
Path * polar(double angle, double distance)
append a new vertex, given by polar coordinates
void absolutize()
replace all relative movements by absolute positions
LineStyleVector lineStyles
line styles for grid disaplay
double turtle_angle
turtle_angle current direction of the turtle
Q_INVOKABLE Path(QObject *parent=0)
default constructor
Q_INVOKABLE Path & operator=(const Path &that)
assignment operator
LineStyle
display style of grid lines in free-space diagram
std::string opcode
used during assembly of a path: the next "move" operation
void lineStyle(int)
change the style of grid lines
void setPrecision(int precision)
set the numerical precision for input data (default is unlimited)
Path * m(QPointF p)
append a new vertex, relative to the current position
Path * right(double angle)
turn the turtle's head to the right