Krita Source Code Documentation
Loading...
Searching...
No Matches
SvgMeshArray.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2020 Sharaf Zaman <sharafzaz121@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6#ifndef SVGMESHARRAY_H
7#define SVGMESHARRAY_H
8
9#include <QVector>
10
11#include "SvgMeshPatch.h"
12
14 int row;
15 int col;
17
19 : row(-1)
20 , col(-1)
22 {
23 }
24
26 : row(row)
27 , col(col)
28 , segmentType(type)
29 {
30 }
31
32 bool isValid() const {
33 return row >= 0 && col >= 0;
34 }
35};
36
37class KRITAFLAKE_EXPORT SvgMeshArray
38{
39public:
41
42 SvgMeshArray(const SvgMeshArray& other);
43
45
47 void createDefaultMesh(const int nrows, const int ncols, const QColor color, const QSizeF size);
48
49 void newRow();
50
51 bool addPatch(QList<QPair<QString, QColor>> stops, const QPointF initialPoint);
52
54 SvgMeshStop getStop(const SvgMeshPatch::Type edge, const int row, const int col) const;
55
56 SvgMeshStop getStop(const SvgMeshPosition &pos) const;
57
59 std::array<QPointF, 4> getPath(const SvgMeshPatch::Type edge, const int row, const int col) const;
60
61 // overload
62 SvgMeshPath getPath(const SvgMeshPosition &pos) const;
63
64 SvgMeshPatch* getPatch(const int row, const int col) const;
65
66 int numRows() const;
67 int numColumns() const;
68
69 void setTransform(const QTransform& matrix);
70
71 QRectF boundingRect() const;
72
74 QVector<SvgMeshPosition> getConnectedPaths(const SvgMeshPosition &position) const;
75
76 void modifyHandle(const SvgMeshPosition &position, const std::array<QPointF, 4> &newPath);
77 void modifyCorner(const SvgMeshPosition &position, const QPointF &newPos);
78
79 void modifyColor(const SvgMeshPosition &position, const QColor &color);
80
81private:
84 QVector<SvgMeshPosition> getSharedPaths(const SvgMeshPosition &position) const;
85
86 // get color of a stop
87 QColor getColor(SvgMeshPatch::Type edge, int row, int col) const;
88
89private:
92};
93
94#endif // SVGMESHARRAY_H
std::array< QPointF, 4 > SvgMeshPath
QVector< QVector< SvgMeshPatch * > > m_array
where each vector is a meshrow
Type
Position of stop in the patch.
SvgMeshPosition(int row, int col, SvgMeshPatch::Type type)
SvgMeshPatch::Type segmentType
bool isValid() const