valentina/src/libs/vpatterndb/vpiecepath.h

152 lines
5.7 KiB
C
Raw Normal View History

/************************************************************************
**
** @file
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 22 11, 2016
**
** @brief
** @copyright
** This source code is part of the Valentina project, a pattern making
** program, whose allow create and modeling patterns of clothing.
** Copyright (C) 2016 Valentina project
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
**
** Valentina is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** Valentina is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VPIECEPATH_H
#define VPIECEPATH_H
#include <QtGlobal>
#include <QSharedDataPointer>
#include "../vmisc/def.h"
#include "../vgeometry/vabstractcurve.h"
class VPiecePathData;
class VSAPoint;
class VContainer;
class QPainterPath;
class VPointF;
class VPieceNode;
class VInternalVariable;
2022-10-28 15:16:02 +02:00
class VLayoutPoint;
class VPiecePath
{
public:
VPiecePath();
explicit VPiecePath(PiecePathType type);
VPiecePath(const VPiecePath &path);
~VPiecePath();
2023-05-03 13:07:02 +02:00
auto operator=(const VPiecePath &path) -> VPiecePath &;
#ifdef Q_COMPILER_RVALUE_REFS
2022-08-12 17:50:13 +02:00
VPiecePath(VPiecePath &&path) Q_DECL_NOTHROW;
2023-05-03 13:07:02 +02:00
auto operator=(VPiecePath &&path) Q_DECL_NOTHROW->VPiecePath &;
#endif
void Append(const VPieceNode &node);
void Clear();
2023-05-03 13:07:02 +02:00
auto CountNodes() const -> vsizetype;
2023-05-03 13:07:02 +02:00
auto operator[](vsizetype indx) -> VPieceNode &;
auto at(vsizetype indx) const -> const VPieceNode &;
2023-05-03 13:07:02 +02:00
auto GetNodes() const -> QVector<VPieceNode>;
void SetNodes(const QVector<VPieceNode> &nodes);
2023-05-03 13:07:02 +02:00
auto GetType() const -> PiecePathType;
void SetType(PiecePathType type);
2023-05-03 13:07:02 +02:00
auto GetName() const -> QString;
void SetName(const QString &name);
2023-05-03 13:07:02 +02:00
auto GetPenType() const -> Qt::PenStyle;
void SetPenType(const Qt::PenStyle &type);
2023-05-03 13:07:02 +02:00
auto IsCutPath() const -> bool;
void SetCutPath(bool cut);
2023-05-03 13:07:02 +02:00
auto GetVisibilityTrigger() const -> QString;
void SetVisibilityTrigger(const QString &formula);
2022-11-14 17:02:00 +01:00
void SetFirstToCuttingContour(bool value);
2023-05-03 13:07:02 +02:00
auto IsFirstToCuttingContour() const -> bool;
2022-11-14 17:02:00 +01:00
void SetLastToCuttingContour(bool value);
2023-05-03 13:07:02 +02:00
auto IsLastToCuttingContour() const -> bool;
2023-05-03 13:07:02 +02:00
auto PathPoints(const VContainer *data, const QVector<QPointF> &cuttingPath = QVector<QPointF>()) const
-> QVector<VLayoutPoint>;
auto PathNodePoints(const VContainer *data, bool showExcluded = true) const -> QVector<VPointF>;
auto PathCurvePoints(const VContainer *data) const -> QVector<QVector<QPointF>>;
auto SeamAllowancePoints(const VContainer *data, qreal width, bool reverse) const -> QVector<VSAPoint>;
2023-05-03 13:07:02 +02:00
auto PainterPath(const VContainer *data, const QVector<QPointF> &cuttingPath) const -> QPainterPath;
auto CurvesPainterPath(const VContainer *data) const -> QVector<QPainterPath>;
2023-05-03 13:07:02 +02:00
auto Dependencies() const -> QList<quint32>;
auto MissingNodes(const VPiecePath &path) const -> QVector<quint32>;
2023-05-03 13:07:02 +02:00
auto NodeName(int nodeIndex, const VContainer *data) const -> QString;
2023-05-03 13:07:02 +02:00
auto indexOfNode(quint32 id) const -> int;
void NodeOnEdge(quint32 index, VPieceNode &p1, VPieceNode &p2) const;
2023-05-03 13:07:02 +02:00
auto Contains(quint32 id) const -> bool;
auto OnEdge(quint32 p1, quint32 p2) const -> bool;
auto Edge(quint32 p1, quint32 p2) const -> vsizetype;
2023-05-03 13:07:02 +02:00
auto ListNodePoint() const -> QVector<VPieceNode>;
2023-05-03 13:07:02 +02:00
auto RemoveEdge(quint32 index) const -> VPiecePath;
2023-05-03 13:07:02 +02:00
auto StartSegment(const VContainer *data, int i) const -> VSAPoint;
auto EndSegment(const VContainer *data, int i) const -> VSAPoint;
2023-05-03 13:07:02 +02:00
auto NodePreviousPoint(const VContainer *data, int i) const -> QPointF;
auto NodeNextPoint(const VContainer *data, int i) const -> QPointF;
2023-05-03 13:07:02 +02:00
auto IsVisible(const QHash<QString, QSharedPointer<VInternalVariable>> *vars) const -> bool;
2023-05-03 13:07:02 +02:00
static auto indexOfNode(const QVector<VPieceNode> &nodes, quint32 id) -> int;
2023-05-03 13:07:02 +02:00
static auto FindInLoopNotExcludedUp(vsizetype start, const QVector<VPieceNode> &nodes) -> vsizetype;
static auto FindInLoopNotExcludedDown(vsizetype start, const QVector<VPieceNode> &nodes) -> vsizetype;
2023-05-03 13:07:02 +02:00
static auto StartSegment(const VContainer *data, const QVector<VPieceNode> &nodes, vsizetype i) -> VSAPoint;
static auto EndSegment(const VContainer *data, const QVector<VPieceNode> &nodes, vsizetype i) -> VSAPoint;
2023-05-03 13:07:02 +02:00
static auto PreparePointEkv(const VPieceNode &node, const VContainer *data) -> VSAPoint;
2023-05-03 13:07:02 +02:00
static auto CurveSeamAllowanceSegment(const VContainer *data, const QVector<VPieceNode> &nodes,
const QSharedPointer<VAbstractCurve> &curve, vsizetype i, bool reverse,
qreal width, const QString &piece = QString()) -> QVector<VSAPoint>;
2023-05-03 13:07:02 +02:00
static auto NodeName(const QVector<VPieceNode> &nodes, vsizetype nodeIndex, const VContainer *data) -> QString;
2023-05-03 13:07:02 +02:00
static auto NodesToPoints(const VContainer *data, const QVector<VPieceNode> &nodes,
const QString &piece = QString()) -> QVector<VLayoutPoint>;
private:
QSharedDataPointer<VPiecePathData> d;
};
2022-08-12 17:50:13 +02:00
Q_DECLARE_TYPEINFO(VPiecePath, Q_MOVABLE_TYPE); // NOLINT
Q_DECLARE_METATYPE(VPiecePath)
#endif // VPIECEPATH_H