33 #include <Pt/Gfx/Api.h>
34 #include <Pt/Gfx/FillRule.h>
35 #include <Pt/Gfx/Point.h>
36 #include <Pt/Gfx/Rect.h>
37 #include <Pt/Gfx/Polygon.h>
38 #include <Pt/Gfx/Transform.h>
39 #include <Pt/SmartPtr.h>
172 double degBegin,
double degEnd);
206 double degBegin,
double degEnd);
211 double degBegin,
double degEnd);
216 double degBegin,
double degEnd);
260 PathEntry(Type type, std::size_t n)
271 std::size_t size()
const
296 void setPosition(
const PointF& pos)
301 void setEntry(
const PathEntry* entry,
const PointF* points)
312 return _entry->type();
319 return _entry->size();
338 void flatten(Polygon& points,
double tolerance = 0.25)
const;
341 const PathEntry* _entry;
352 using iterator_category = std::forward_iterator_tag;
354 using difference_type = std::ptrdiff_t;
372 , _element(_entry, _points)
394 if( _entry->size() > 0)
396 const PointF& pos = _points[ _entry->size() - 1 ];
397 _element.setPosition(pos);
400 _points += _entry->size();
403 _element.setEntry(_entry, _points);
420 return _entry == other._entry;
427 return _entry != other._entry;
434 return _entry < other._entry;
438 const PathEntry* _entry;
454 const PointF& currentPosition()
const
459 void setCurrentPosition(
const PointF& p)
464 Path::Iterator begin()
const
466 return Path::Iterator( _entries.data(), _points.data() );
469 Path::Iterator end()
const
471 return Path::Iterator(_entries.data() + _entries.size(), _points.data() + _points.size());
474 std::size_t size()
const
476 return _entries.size();
481 return _entries.empty();
489 _position = PointF();
492 void append(
const PathData& path);
494 void moveTo(
const PointF& pos);
496 void lineTo(
const PointF& pos);
498 void quadTo(
const PointF& cp,
const PointF& to);
500 void cubicTo(
const PointF& cp1,
const PointF& cp2,
const PointF& to);
504 void transform(
const Transform& tform);
507 std::vector<PathEntry> _entries;
508 std::vector<PointF> _points;
Core module.
Definition: pt-gfx-images.dox:14
const PointF & currentPosition() const
Returns the current drawing position.
Read-only view of a path element.
Definition: Path.h:285
void addPolygon(const PointF *points, std::size_t count)
Adds a polygon as a new closed subpath.
void arcTo(const PointF &topLeft, const SizeF &size, double degBegin, double degEnd)
Adds an arc segment to the current subpath.
~Path()
Destroys the path.
PathIterator operator++(int)
Advances to the next path element and returns the previous iterator.
Definition: Path.h:409
Path(const Path &other)
Copies another path.
void addRoundedRect(const RectF &rect, double radius)
Adds a rounded rectangle as a new subpath.
ElementType
Identifies the command stored in a path element.
Definition: Path.h:66
PathIterator & operator++()
Advances to the next path element.
Definition: Path.h:392
const Path::Element & operator*() const
Returns the current path element.
Definition: Path.h:378
RectF boundingRect() const
Returns the bounding rectangle of the path.
std::size_t size() const
Returns the number of path elements.
void addChord(const PointF &topLeft, const SizeF &size, double degBegin, double degEnd)
Adds a chord as a new subpath.
Path & operator=(const Path &other)
Replaces the path contents.
Path::ElementType type() const
Returns the element type.
Definition: Path.h:310
Iterator begin() const
Returns an iterator to the first element.
void close()
Closes the current subpath.
bool contains(const PointF &point, FillRule rule=FillRule::NonZero) const
Returns true if the point lies inside the filled area of the path.
Size with floating-point width and height.
Definition: Size.h:45
Point with floating-point X and Y coordinates.
Definition: Point.h:45
void addPolyline(const PointF *points, std::size_t count)
Adds a polyline as a new subpath.
FillRule
Determines how overlapping subpaths of a filled shape are painted.
Definition: FillRule.h:45
bool operator<(const PathIterator &other) const
Returns true if this iterator precedes the other iterator.
Definition: Path.h:432
Iterator getPolygon(Iterator it, Polygon &polygon, float tolerance=0.25f) const
Flattens one subpath into polygon starting at it.
void moveTo(const PointF &p)
Starts a new subpath at the given point.
const PointF & point(std::size_t n) const
Returns one point of the element.
Definition: Path.h:331
const Path::Element * operator->() const
Returns a pointer to the current path element.
Definition: Path.h:385
void flatten(Polygon &points, double tolerance=0.25) const
Flattens the element into polygon points.
Vector path for drawing outlines and filled shapes.
Definition: Path.h:61
Forward iterator over path elements.
Definition: Path.h:350
bool intersects(const RectF &rect, FillRule rule=FillRule::NonZero) const
Returns true if the filled area of the path overlaps rect.
Iterator end() const
Returns an iterator past the last element.
PathIterator(const PathEntry *entry, const PointF *points)
Constructs an iterator for the given storage pointers.
Definition: Path.h:369
bool operator!=(const PathIterator &other) const
Returns true if both iterators refer to different elements.
Definition: Path.h:425
void addRect(const RectF &rect)
Adds a rectangle as a new subpath.
void addPie(const PointF &topLeft, const SizeF &size, double degBegin, double degEnd)
Adds a pie segment as a new subpath.
bool operator==(const PathIterator &other) const
Returns true if both iterators refer to the same element.
Definition: Path.h:418
std::size_t size() const
Returns the number of points stored in the element.
Definition: Path.h:317
Path()
Constructs an empty path.
void addArc(const PointF &topLeft, const SizeF &size, double degBegin, double degEnd)
Adds an arc as a new subpath.
bool contains(const RectF &rect, FillRule rule=FillRule::NonZero) const
Returns true if the rectangle lies entirely inside the filled area.
void quadTo(const PointF &cp, const PointF &to)
Adds a quadratic Bezier segment.
void clear()
Removes all path elements.
void addRoundedRect(const RectF &rect, double rx, double ry)
Adds a rounded rectangle with elliptical corners as a new subpath.
Rect with floating-point coordinates.
Definition: Rect.h:45
void addEllipse(const PointF &topLeft, const SizeF &size)
Adds an ellipse as a new subpath.
Path toTransformed(const Transform &transform) const
Returns a copy of the path with the transform applied.
void transform(const Transform &transform)
Applies a transform to all path coordinates.
bool isEmpty() const
Returns true if the path has no elements.
void addPath(const Path &p)
Appends all elements of p to this path.
void cubicTo(const PointF &cp1, const PointF &cp2, const PointF &to)
Adds a cubic Bezier segment.
const PointF & position() const
Returns the current path position before the element.
Definition: Path.h:324
void lineTo(const PointF &p)
Adds a straight line to the given point.
PathIterator()
Constructs an end iterator.
Definition: Path.h:360