17 for (
const auto& row: other.
m_array) {
19 for (
const auto& patch: row) {
28 for (
auto& patch: row) {
36 m_array << QVector<SvgMeshPatch*>();
45 qreal patchWidth = size.width() / ncols;
46 qreal patchHeight = size.height() / nrows;
49 patchWidth /= size.width();
50 patchHeight /= size.height();
52 QRectF start(0, 0, patchWidth, patchHeight);
54 QColor colors[2] = {Qt::white, color};
56 for (
int irow = 0; irow < nrows; ++irow) {
59 for (
int icol = 0; icol < ncols; ++icol) {
62 int index = (irow + icol) % 2;
68 index = (index + 1) % 2;
73 index = (index + 1) % 2;
74 patch->
addStopLinear({start.bottomRight(), start.bottomLeft()},
78 index = (index + 1) % 2;
87 start.setWidth(patchWidth);
92 start.setSize({patchWidth, patchHeight});
99 if (stops.size() > 4 || stops.size() < 2)
107 int icol =
m_array.last().size() - 1;
109 if (irow == 0 && icol == 0) {
112 }
else if (irow == 0) {
121 std::reverse(points.begin(), points.end());
160 std::reverse(points.begin(), points.end());
170 && row >= 0 && col >= 0);
199 && row >= 0 && col >= 0);
201 return m_array[row][col]->getSegment(edge);
212 && row >= 0 && col >= 0);
232 for (
auto& patch: row) {
233 patch->setTransform(matrix);
242 QPointF topLeft =
m_array[0][0]->boundingRect().topLeft();
243 QPointF bottomRight =
m_array.last().last()->boundingRect().bottomRight();
247 for (
int i = 0; i <
numRows(); ++i) {
249 QPointF left =
m_array[i][j]->boundingRect().topLeft();
250 if (left.x() < topLeft.x()) {
251 topLeft.rx() = left.x();
253 if ( left.y() < topLeft.y()) {
254 topLeft.ry() = left.y();
257 QPointF right =
m_array[i][j]->boundingRect().bottomRight();
258 if (bottomRight.x() < right.x()) {
259 bottomRight.rx() = right.x();
261 if (bottomRight.y() < right.y()) {
262 bottomRight.ry() = right.y();
268 return QRectF(topLeft, bottomRight);
275 int row = position.
row;
276 int col = position.
col;
308 const std::array<QPointF, 4> &newPath)
310 std::array<QPointF, 4> reversed = newPath;
311 std::reverse(reversed.begin(), reversed.end());
325 const QPointF &newPos)
331 for (
const auto &path: paths) {
332 m_array[path.row][path.col]->modifyCorner(path.segmentType, delta);
340 for (
const auto &path: paths) {
341 m_array[path.row][path.col]->setStopColor(path.segmentType, color);
349 int row = position.
row;
350 int col = position.
col;
std::array< QPointF, 4 > SvgMeshPath
QVector< QVector< SvgMeshPatch * > > m_array
where each vector is a meshrow
QVector< SvgMeshPosition > getConnectedPaths(const SvgMeshPosition &position) const
Return the paths connected to the corner. Can be thought of as edges connected to a vertex.
QColor getColor(SvgMeshPatch::Type edge, int row, int col) const
void modifyCorner(const SvgMeshPosition &position, const QPointF &newPos)
void createDefaultMesh(const int nrows, const int ncols, const QColor color, const QSizeF size)
creates a default mesh in OBB coordinates (because it's easier and more logical in this case)
QRectF boundingRect() const
void modifyColor(const SvgMeshPosition &position, const QColor &color)
void setTransform(const QTransform &matrix)
bool addPatch(QList< QPair< QString, QColor > > stops, const QPointF initialPoint)
void modifyHandle(const SvgMeshPosition &position, const std::array< QPointF, 4 > &newPath)
std::array< QPointF, 4 > getPath(const SvgMeshPatch::Type edge, const int row, const int col) const
Get the Path Points for a segment of the meshpatch.
SvgMeshPatch * getPatch(const int row, const int col) const
SvgMeshStop getStop(const SvgMeshPatch::Type edge, const int row, const int col) const
Get the point of a node in mesharray.
QVector< SvgMeshPosition > getSharedPaths(const SvgMeshPosition &position) const
Type
Position of stop in the patch.
void addStop(const QString &pathStr, QColor color, Type edge, bool pathIncomplete=false, QPointF lastPoint=QPointF())
void addStopLinear(const std::array< QPointF, 2 > &pathPoints, QColor color, Type edge)
Adds linear path to the shape.
SvgMeshStop getStop(Type type) const
returns the starting point of the stop
SvgMeshPatch::Type segmentType