Krita Source Code Documentation
Loading...
Searching...
No Matches
KisOptimizedBrushOutline.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2022 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef KISOPTIMIZEDBRUSHOUTLINE_H
8#define KISOPTIMIZEDBRUSHOUTLINE_H
9
10#include <QPolygonF>
11#include <QTransform>
12#include <boost/iterator/iterator_facade.hpp>
13#include <optional>
14#include <kritaimage_export.h>
15
16class QPainterPath;
17
26class KRITAIMAGE_EXPORT KisOptimizedBrushOutline
27{
28public:
29 class KRITAIMAGE_EXPORT const_iterator :
30 public boost::iterator_facade <const_iterator,
31 QPolygonF,
32 boost::forward_traversal_tag,
33 QPolygonF>
34 {
35 public:
37 : m_outline(0),
38 m_index(0) {}
39
40 const_iterator(const KisOptimizedBrushOutline *outline, int index)
41 : m_outline(outline),
42 m_index(index) {}
43
44 private:
45 friend class boost::iterator_core_access;
46
47 void increment() {
48 m_index++;
49 }
50
51 bool equal(const_iterator const& other) const {
52 return m_index == other.m_index &&
53 m_outline == other.m_outline;
54 }
55
56 QPolygonF dereference() const;
57
58 private:
61 };
62
63public:
65 KisOptimizedBrushOutline(const QPainterPath &path, const std::optional<QRectF> &bounds = std::nullopt);
66 KisOptimizedBrushOutline(const QVector<QPolygonF> &subpaths, const std::optional<QRectF> &bounds = std::nullopt);
67
68 QRectF boundingRect() const;
69
70 bool isEmpty() const;
71
72 void addRect(const QRectF &rc);
73 void addEllipse(const QPointF &center, qreal rx, qreal ry);
74 void addPath(const QPainterPath &path);
75 void addPath(const KisOptimizedBrushOutline &path);
76
77 void translate(qreal tx, qreal ty);
78 void translate(const QPointF &offset);
79
86 void map(const QTransform &t);
87
91 KisOptimizedBrushOutline mapped(const QTransform &t) const;
92
103 const_iterator begin() const;
104
108 const_iterator end() const;
109
110private:
113 std::optional<QRectF> m_explicitBounds;
114 QTransform m_transform;
115 mutable QRectF m_cachedBoundingRect;
116};
117
118#endif // KISOPTIMIZEDBRUSHOUTLINE_H
const_iterator(const KisOptimizedBrushOutline *outline, int index)
bool equal(const_iterator const &other) const
std::optional< QRectF > m_explicitBounds
QVector< QPolygonF > m_additionalDecorations
#define bounds(x, a, b)