Fréchet View  1.6.0
A Tool for Exploring Fréchet Distance Algorithms
Path Class Reference

Detailed Description

Represents a polygonal curve.

Used when constructing curves from input data. Has methods for assembling and modifying the curve point by point.

This class appears in the JavaScript interface, so many methods are exposed as Qt slots. All methods marked as Q_INVOKABLE can be referred to from JavaScript. All methods return 'this' as result, allowing for a fluent API.

See also
https://bitbucket.org/hrimfaxi/c-development/wiki/ScriptFiles.md

Note that this class has to live in the global namespace, rather than in the frechet::input namespace.

Author
Peter Schäfer

Definition at line 30 of file path.h.

#include <path.h>

Inherits QObject.

Public Slots

int size () const
 
PathappendPath (Path *that)
 appends a copy of another Path More...
 
PathappendString (QString svg)
 appends a copy of an SVG path More...
 
PathM (QPointF p)
 append a new vertex at an absolute position More...
 
PathM (double x, double y)
 append a new vertex at an absolute position More...
 
PathH (double h)
 horizontal move to an absolute position More...
 
PathV (double v)
 vertical move to an absolute position More...
 
Pathclose ()
 return to the first vertex, creating a closed curve More...
 
PathZ ()
 return to the first vertex, creating a closed curve More...
 
Pathundo ()
 remove the last vertex More...
 
PathensureClosed ()
 make sure the curve is closed More...
 
Pathm (QPointF p)
 append a new vertex, relative to the current position More...
 
Pathm (double x, double y)
 append a new vertex, relative to the current position More...
 
Pathh (double h)
 horizontal move, relative to the current position More...
 
Pathv (double v)
 vertical move, relative to the current position More...
 
Pathpolar (double angle, double distance)
 append a new vertex, given by polar coordinates More...
 
Pathmap (QTransform tf)
 apply a transformation to all vertexes More...
 
Pathmap (QMatrix mx)
 apply a transformation to all vertexes More...
 
Pathscale (double scale)
 scale the polygonal curve More...
 
Pathscale (double scalex, double scaley)
 scale the polygonal curve More...
 
Pathrotate (double angle)
 rotate the curve More...
 
Pathtranslate (QPointF offset)
 translate the curve More...
 
Pathtranslate (double dx, double dy)
 translate the curve More...
 
Pathmirrorx ()
 mirror the curve about the x-axis More...
 
Pathmirrory ()
 mirror the curve about the y-axis More...
 
Pathrevert ()
 revert the order of vertexes More...
 
Pathleft (double angle)
 turn the turtle's head to the left More...
 
Pathright (double angle)
 turn the turtle's head to the right More...
 
Pathreset (double angle=0.0)
 turn the turtle's head to a given angle More...
 
Pathforward (double distance)
 append a new vertex, relative to the current position More...
 
void lineStyle (int)
 change the style of grid lines More...
 
void setDefaultLineStyle (int)
 change the default style of grid lines More...
 
void outerLineStyle (int)
 set the style of outermost grid lines More...
 

Public Member Functions

Q_INVOKABLE Path (QObject *parent=0)
 default constructor More...
 
Q_INVOKABLE Path (const Path &that)
 copy constructor More...
 
Q_INVOKABLE Path (const Path *that)
 copy constructor More...
 
Q_INVOKABLE Path (QString svg, bool forceAbsolute=false, QObject *parent=0)
 constructor from SVG input string More...
 
const QPolygonF & toCurve (int precision=0)
 convert to a QPolygonF object, ready for processing by the Frechet distance algorithms More...
 
Q_INVOKABLE Pathoperator= (const Path &that)
 assignment operator More...
 
Q_INVOKABLE Pathoperator+= (const Path &that)
 append operator More...
 
Q_INVOKABLE Pathoperator+= (QString svg)
 append operator with SVG input string More...
 
void parseSvg (QString str, bool forceAbsolute=false)
 parse an SVG input string More...
 
void parseIpe (QString str)
 pare an IPE input string More...
 
LineStyle getDefaultLineStyle () const
 
const LineStyleVectorgetLineStyles () const
 

Static Public Member Functions

static Path svgPath (QString str, bool forceAbsolute=false)
 static constructor from SVG input string More...
 
static Path ipePath (QString str)
 static constructor from IPE input string More...
 

Private Member Functions

void append (QPointF p, char opcode)
 
void absolutize ()
 replace all relative movements by absolute positions More...
 
void setPrecision (int precision)
 set the numerical precision for input data (default is unlimited) More...
 
void removeDuplicates ()
 remove all duplicate points More...
 

Private Attributes

QPolygonF points
 the list of vertexes More...
 
std::string opcode
 used during assembly of a path: the next "move" operation More...
 
double turtle_angle
 turtle_angle current direction of the turtle More...
 
LineStyle defaultLineStyle
 default style for grid disaplay More...
 
LineStyleVector lineStyles
 line styles for grid disaplay More...
 

Constructor & Destructor Documentation

◆ Path() [1/4]

Path::Path ( QObject *  parent = 0)

default constructor

Parameters
parentowning QObject, optional

Definition at line 7 of file path.cpp.

◆ Path() [2/4]

Path::Path ( const Path that)

copy constructor

Parameters
thatobject to copy from

Definition at line 15 of file path.cpp.

◆ Path() [3/4]

Path::Path ( const Path that)

copy constructor

Parameters
thatobject to copy from

Definition at line 23 of file path.cpp.

◆ Path() [4/4]

Path::Path ( QString  svg,
bool  forceAbsolute = false,
QObject *  parent = 0 
)

constructor from SVG input string

Parameters
svgan svg-encoded polygonal path
forceAbsoluteassume all commands are absolute movements (no relative movements)
parentowning QObject, optional
See also
SVG specification https://www.w3.org/TR/SVG/paths.html

Definition at line 27 of file path.cpp.

Member Function Documentation

◆ absolutize()

void Path::absolutize ( )
private

replace all relative movements by absolute positions

Definition at line 364 of file path.cpp.

◆ append()

void Path::append ( QPointF  p,
char  opcode 
)
private

append a point to the curve

Parameters
pnew point
opcodepath operation (move etc.)

Definition at line 354 of file path.cpp.

◆ appendPath

Path* Path::appendPath ( Path that)
inlineslot

appends a copy of another Path

Parameters
thatobject to copy from
Returns
this object, after appending a copy of the input

Definition at line 147 of file path.h.

◆ appendString

Path* Path::appendString ( QString  svg)
inlineslot

appends a copy of an SVG path

Parameters
svg
See also
SVG specification https://www.w3.org/TR/SVG/paths.html
Returns
this object, after appending a copy of the input

Definition at line 154 of file path.h.

◆ close

Path * Path::close ( )
slot

return to the first vertex, creating a closed curve

Returns
this object, after appending one more vertex

Definition at line 90 of file path.cpp.

◆ ensureClosed

Path * Path::ensureClosed ( )
slot

make sure the curve is closed

Returns
this object, appending one more vertex, if necessary

Definition at line 108 of file path.cpp.

◆ forward

Path * Path::forward ( double  distance)
slot

append a new vertex, relative to the current position

Parameters
distancedistance to move
Returns
this object, after appending a new vertex

Definition at line 207 of file path.cpp.

◆ getDefaultLineStyle()

LineStyle Path::getDefaultLineStyle ( ) const
inline
Returns
current default grid line style

Definition at line 361 of file path.h.

◆ getLineStyles()

const LineStyleVector& Path::getLineStyles ( ) const
inline
Returns
line styles for drawing the grid

Definition at line 363 of file path.h.

◆ H

Path* Path::H ( double  h)
inlineslot

horizontal move to an absolute position

Parameters
hx-coordinate of next vertex
Returns
this object, after appending one more vertex

Definition at line 178 of file path.h.

◆ h

Path* Path::h ( double  h)
inlineslot

horizontal move, relative to the current position

Parameters
hhorizontal offset
Returns
this object, after appending one more vertex

Definition at line 228 of file path.h.

◆ ipePath()

Path Path::ipePath ( QString  str)
static

static constructor from IPE input string

Parameters
stran IPE-encoded polygonal curve
Returns
a Path object, constructed from IPE input

Definition at line 40 of file path.cpp.

◆ left

Path * Path::left ( double  angle)
slot

turn the turtle's head to the left

Parameters
anglein degrees
Returns
this object

Definition at line 192 of file path.cpp.

◆ lineStyle

void Path::lineStyle ( int  style)
slot

change the style of grid lines

See also
LineStyle

Definition at line 218 of file path.cpp.

◆ M [1/2]

Path* Path::M ( QPointF  p)
inlineslot

append a new vertex at an absolute position

Parameters
pnext vertex
Returns
this object, after appending one more vertex

Definition at line 165 of file path.h.

◆ M [2/2]

Path* Path::M ( double  x,
double  y 
)
inlineslot

append a new vertex at an absolute position

Parameters
xx-coordinate of next vertex
yy-coordinate of next vertex
Returns
this object, after appending one more vertex

Definition at line 172 of file path.h.

◆ m [1/2]

Path* Path::m ( QPointF  p)
inlineslot

append a new vertex, relative to the current position

Parameters
poffset to next vertex
Returns
this object, after appending one more vertex

Definition at line 215 of file path.h.

◆ m [2/2]

Path* Path::m ( double  x,
double  y 
)
inlineslot

append a new vertex, relative to the current position

Parameters
xx-offset to next vertex
yy-offset to next vertex
Returns
this object, after appending one more vertex

Definition at line 222 of file path.h.

◆ map [1/2]

Path * Path::map ( QTransform  tf)
slot

apply a transformation to all vertexes

Parameters
tfan affine transformation
Returns
this object, after applying the transformation

Definition at line 121 of file path.cpp.

◆ map [2/2]

Path * Path::map ( QMatrix  mx)
slot

apply a transformation to all vertexes

Parameters
mxan affine transformation
Returns
this object, after applying the transformation

Definition at line 127 of file path.cpp.

◆ mirrorx

Path * Path::mirrorx ( )
slot

mirror the curve about the x-axis

Returns
this object, after applying the mirror transformation

Definition at line 157 of file path.cpp.

◆ mirrory

Path * Path::mirrory ( )
slot

mirror the curve about the y-axis

Returns
this object, after applying the mirror transformation

Definition at line 162 of file path.cpp.

◆ operator+=() [1/2]

Path & Path::operator+= ( const Path that)

append operator

Parameters
thatobject to copy from
Returns
this object, after appending a copy of the input

Definition at line 66 of file path.cpp.

◆ operator+=() [2/2]

Path & Path::operator+= ( QString  svg)

append operator with SVG input string

Parameters
svgan svg-encoded polygonal path
See also
SVG specification https://www.w3.org/TR/SVG/paths.html
Returns
this object, after appending a copy of the input

Definition at line 85 of file path.cpp.

◆ operator=()

Path & Path::operator= ( const Path that)

assignment operator

Parameters
thatobject to copy from
Returns
this object, containing a copy of the input

Definition at line 57 of file path.cpp.

◆ outerLineStyle

void Path::outerLineStyle ( int  style)
slot

set the style of outermost grid lines

See also
LineStyle

Definition at line 229 of file path.cpp.

◆ parseIpe()

void Path::parseIpe ( QString  str)

pare an IPE input string

Definition at line 300 of file path.cpp.

◆ parseSvg()

void Path::parseSvg ( QString  str,
bool  forceAbsolute = false 
)

parse an SVG input string

Definition at line 236 of file path.cpp.

◆ polar

Path * Path::polar ( double  angle,
double  distance 
)
slot

append a new vertex, given by polar coordinates

Parameters
angledirection of movement
distancedistance from current position
Returns
this object, after appending one more vertex

Definition at line 116 of file path.cpp.

◆ removeDuplicates()

void Path::removeDuplicates ( )
private

remove all duplicate points

Duplicates are not forbidden per se, but they are meaningless w.r.t. the Fréchet distance. Besides, duplicates create confusion in many polygon algorithms, so better remove them on input.

Definition at line 413 of file path.cpp.

◆ reset

Path * Path::reset ( double  angle = 0.0)
slot

turn the turtle's head to a given angle

Parameters
anglenew direction
Returns
this object

Definition at line 202 of file path.cpp.

◆ revert

Path * Path::revert ( )
slot

revert the order of vertexes

Returns
this object, after reverting the order of vertexes

Definition at line 179 of file path.cpp.

◆ right

Path * Path::right ( double  angle)
slot

turn the turtle's head to the right

Parameters
anglein degrees
Returns
this object

Definition at line 197 of file path.cpp.

◆ rotate

Path * Path::rotate ( double  angle)
slot

rotate the curve

Parameters
anglerotation angle (in degrees)
Returns
this object, after applying the rotation

Definition at line 141 of file path.cpp.

◆ scale [1/2]

Path * Path::scale ( double  scale)
slot

scale the polygonal curve

Parameters
scalescaling factor
Returns
this object, after applying the scaling

Definition at line 131 of file path.cpp.

◆ scale [2/2]

Path * Path::scale ( double  scalex,
double  scaley 
)
slot

scale the polygonal curve

Parameters
scalexhorizontal scaling factor
scaleyvertital scaling factor
Returns
this object, after applying the scaling

Definition at line 135 of file path.cpp.

◆ setDefaultLineStyle

void Path::setDefaultLineStyle ( int  style)
slot

change the default style of grid lines

See also
LineStyle

Definition at line 211 of file path.cpp.

◆ setPrecision()

void Path::setPrecision ( int  precision)
private

set the numerical precision for input data (default is unlimited)

Definition at line 398 of file path.cpp.

◆ size

int Path::size ( ) const
inlineslot
Returns
number of vertexes in the polygonal curve

Definition at line 136 of file path.h.

◆ svgPath()

Path Path::svgPath ( QString  str,
bool  forceAbsolute = false 
)
static

static constructor from SVG input string

Parameters
stran svg-encoded polygonal path
forceAbsoluteassume all commands are absolute movements (no relative movements)
See also
SVG specification https://www.w3.org/TR/SVG/paths.html
Returns
a Path object, constructed from SVG input

Definition at line 33 of file path.cpp.

◆ toCurve()

const QPolygonF & Path::toCurve ( int  precision = 0)

convert to a QPolygonF object, ready for processing by the Frechet distance algorithms

Parameters
precisionlimit numerical precision (optional, default is most precise)
Returns
a polygonal curve with absolute vertex data

Definition at line 47 of file path.cpp.

◆ translate [1/2]

Path * Path::translate ( QPointF  offset)
slot

translate the curve

Parameters
offsettranslation offset
Returns
this object, after applying the translation

Definition at line 147 of file path.cpp.

◆ translate [2/2]

Path * Path::translate ( double  dx,
double  dy 
)
slot

translate the curve

Parameters
dxhorizontal translation offset
dyvertical translation offset
Returns
this object, after applying the translation

Definition at line 151 of file path.cpp.

◆ undo

Path * Path::undo ( )
slot

remove the last vertex

Returns
this object, after remove one vertex

Definition at line 100 of file path.cpp.

◆ V

Path* Path::V ( double  v)
inlineslot

vertical move to an absolute position

Parameters
vy-coordinate of next vertex
Returns
this object, after appending one more vertex

Definition at line 184 of file path.h.

◆ v

Path* Path::v ( double  v)
inlineslot

vertical move, relative to the current position

Parameters
vvertical offset
Returns
this object, after appending one more vertex

Definition at line 234 of file path.h.

◆ Z

Path * Path::Z ( )
slot

return to the first vertex, creating a closed curve

Returns
this object, after appending one more vertex

Definition at line 96 of file path.cpp.

Member Data Documentation

◆ defaultLineStyle

LineStyle Path::defaultLineStyle
private

default style for grid disaplay

See also
setDefaultLineStyle

Definition at line 42 of file path.h.

◆ lineStyles

LineStyleVector Path::lineStyles
private

line styles for grid disaplay

See also
lineStyle

Definition at line 45 of file path.h.

◆ opcode

std::string Path::opcode
private

used during assembly of a path: the next "move" operation

Definition at line 36 of file path.h.

◆ points

QPolygonF Path::points
private

the list of vertexes

Definition at line 34 of file path.h.

◆ turtle_angle

double Path::turtle_angle
private

turtle_angle current direction of the turtle

Definition at line 38 of file path.h.


The documentation for this class was generated from the following files: