valentina/src/libs/vgeometry/vsplinepath.h

108 lines
3.8 KiB
C
Raw Normal View History

/************************************************************************
**
** @file vsplinepath.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date November 15, 2013
**
** @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) 2013-2015 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/>.
**
*************************************************************************/
2013-08-09 08:49:34 +02:00
#ifndef VSPLINEPATH_H
#define VSPLINEPATH_H
#include <QCoreApplication>
#include <QPainterPath>
#include <QPointF>
#include <QSharedDataPointer>
#include <QString>
#include <QTypeInfo>
#include <QVector>
#include <QtGlobal>
#include "vabstractcubicbezierpath.h"
#include "vgeometrydef.h"
#include "vpointf.h"
#include "vspline.h"
#include "vsplinepoint.h"
2013-08-09 08:49:34 +02:00
class VSplinePathData;
2013-08-09 08:49:34 +02:00
/**
* @brief The VSplinePath class keep information about splinePath.
2013-08-09 08:49:34 +02:00
*/
2023-07-13 16:49:20 +02:00
class VSplinePath final : public VAbstractCubicBezierPath
{
2022-08-12 17:50:13 +02:00
Q_DECLARE_TR_FUNCTIONS(VSplinePath) // NOLINT
2023-07-13 16:49:20 +02:00
2013-08-09 08:49:34 +02:00
public:
explicit VSplinePath(quint32 idObject = 0, Draw mode = Draw::Calculation);
2023-07-13 16:49:20 +02:00
explicit VSplinePath(const QVector<VFSplinePoint> &points, qreal kCurve = 1, quint32 idObject = 0,
Draw mode = Draw::Calculation);
explicit VSplinePath(const QVector<VSplinePoint> &points, quint32 idObject = 0, Draw mode = Draw::Calculation);
VSplinePath(const VSplinePath &splPath);
2023-05-03 13:07:02 +02:00
auto Rotate(const QPointF &originPoint, qreal degrees, const QString &prefix = QString()) const -> VSplinePath;
auto Flip(const QLineF &axis, const QString &prefix = QString()) const -> VSplinePath;
auto Move(qreal length, qreal angle, const QString &prefix = QString()) const -> VSplinePath;
2023-07-13 16:49:20 +02:00
~VSplinePath() override;
2023-05-03 13:07:02 +02:00
auto operator[](vsizetype indx) -> VSplinePoint &;
auto operator=(const VSplinePath &path) -> VSplinePath &;
#ifdef Q_COMPILER_RVALUE_REFS
2023-07-13 16:49:20 +02:00
VSplinePath(VSplinePath &&splPath) noexcept;
auto operator=(VSplinePath &&path) noexcept -> VSplinePath &;
#endif
2023-07-13 16:49:20 +02:00
void append(const VSplinePoint &point);
2023-07-13 16:49:20 +02:00
auto CountSubSpl() const -> vsizetype override;
auto CountPoints() const -> vsizetype override;
void Clear() override;
auto GetSpline(vsizetype index) const -> VSpline override;
2023-07-13 16:49:20 +02:00
auto GetSplinePath() const -> QVector<VSplinePoint> override;
2023-05-03 13:07:02 +02:00
auto GetFSplinePath() const -> QVector<VFSplinePoint>;
2023-07-13 16:49:20 +02:00
auto GetStartAngle() const -> qreal override;
auto GetEndAngle() const -> qreal override;
2023-07-13 16:49:20 +02:00
auto GetC1Length() const -> qreal override;
auto GetC2Length() const -> qreal override;
2023-07-13 16:49:20 +02:00
void UpdatePoint(qint32 indexSpline, const SplinePointPosition &pos, const VSplinePoint &point);
2023-05-03 13:07:02 +02:00
auto GetSplinePoint(qint32 indexSpline, SplinePointPosition pos) const -> VSplinePoint;
2023-05-03 13:07:02 +02:00
auto at(vsizetype indx) const -> const VSplinePoint &;
2023-07-13 16:49:20 +02:00
auto ToJson() const -> QJsonObject override;
protected:
2023-07-13 16:49:20 +02:00
auto FirstPoint() const -> VPointF override;
auto LastPoint() const -> VPointF override;
2023-05-03 13:07:02 +02:00
private:
QSharedDataPointer<VSplinePathData> d;
2013-08-09 08:49:34 +02:00
};
2022-08-12 17:50:13 +02:00
Q_DECLARE_TYPEINFO(VSplinePath, Q_MOVABLE_TYPE); // NOLINT
2013-08-09 08:49:34 +02:00
#endif // VSPLINEPATH_H