2016-02-10 05:59:29 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vellipticalarc.h
|
|
|
|
** @author Valentina Zhuravska <zhuravska19(at)gmail.com>
|
|
|
|
** @date February 1, 2016
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2016-02-10 05:59:29 +01:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2013-2015 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2016-02-10 05:59:29 +01:00
|
|
|
**
|
|
|
|
** 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 VELLIPTICALARC_H
|
|
|
|
#define VELLIPTICALARC_H
|
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QCoreApplication>
|
|
|
|
#include <QPointF>
|
|
|
|
#include <QSharedDataPointer>
|
|
|
|
#include <QString>
|
|
|
|
#include <QTypeInfo>
|
|
|
|
#include <QVector>
|
|
|
|
#include <QtGlobal>
|
2022-08-13 18:26:55 +02:00
|
|
|
#include <QtMath>
|
2016-08-08 13:44:49 +02:00
|
|
|
|
2016-04-10 16:40:55 +02:00
|
|
|
#include "vabstractarc.h"
|
2016-02-10 05:59:29 +01:00
|
|
|
#include "vpointf.h"
|
|
|
|
|
|
|
|
class VEllipticalArcData;
|
|
|
|
|
2021-09-25 10:43:05 +02:00
|
|
|
class VEllipticalArc final : public VAbstractArc
|
2016-02-10 05:59:29 +01:00
|
|
|
{
|
2022-05-20 16:08:32 +02:00
|
|
|
Q_DECLARE_TR_FUNCTIONS(VEllipticalArc) // NOLINT
|
2023-07-13 16:49:20 +02:00
|
|
|
|
2016-02-10 05:59:29 +01:00
|
|
|
public:
|
|
|
|
VEllipticalArc();
|
2022-05-20 16:08:32 +02:00
|
|
|
VEllipticalArc(const VPointF ¢er, qreal radius1, qreal radius2, const QString &formulaRadius1,
|
|
|
|
const QString &formulaRadius2, qreal f1, const QString &formulaF1, qreal f2,
|
|
|
|
const QString &formulaF2, qreal rotationAngle, const QString &formulaRotationAngle,
|
|
|
|
quint32 idObject = 0, Draw mode = Draw::Calculation);
|
|
|
|
VEllipticalArc(const VPointF ¢er, qreal radius1, qreal radius2, qreal f1, qreal f2, qreal rotationAngle);
|
|
|
|
VEllipticalArc(qreal length, const QString &formulaLength, const VPointF ¢er, qreal radius1, qreal radius2,
|
|
|
|
const QString &formulaRadius1, const QString &formulaRadius2, qreal f1, const QString &formulaF1,
|
|
|
|
qreal rotationAngle, const QString &formulaRotationAngle, quint32 idObject = 0,
|
|
|
|
Draw mode = Draw::Calculation);
|
|
|
|
VEllipticalArc(qreal length, const VPointF ¢er, qreal radius1, qreal radius2, qreal f1, qreal rotationAngle);
|
2016-02-10 05:59:29 +01:00
|
|
|
VEllipticalArc(const VEllipticalArc &arc);
|
|
|
|
|
2022-05-20 16:08:32 +02:00
|
|
|
auto Rotate(QPointF originPoint, qreal degrees, const QString &prefix = QString()) const -> VEllipticalArc;
|
|
|
|
auto Flip(const QLineF &axis, const QString &prefix = QString()) const -> VEllipticalArc;
|
|
|
|
auto Move(qreal length, qreal angle, const QString &prefix = QString()) const -> VEllipticalArc;
|
2016-02-10 05:59:29 +01:00
|
|
|
|
2022-05-20 16:08:32 +02:00
|
|
|
~VEllipticalArc() override;
|
2016-02-10 05:59:29 +01:00
|
|
|
|
2023-07-13 16:49:20 +02:00
|
|
|
auto operator=(const VEllipticalArc &arc) -> VEllipticalArc &;
|
2017-04-19 12:27:17 +02:00
|
|
|
#ifdef Q_COMPILER_RVALUE_REFS
|
2023-07-13 16:49:20 +02:00
|
|
|
VEllipticalArc(VEllipticalArc &&arc) noexcept;
|
|
|
|
auto operator=(VEllipticalArc &&arc) noexcept -> VEllipticalArc &;
|
2017-04-19 12:27:17 +02:00
|
|
|
#endif
|
|
|
|
|
2022-05-20 16:08:32 +02:00
|
|
|
auto GetFormulaRotationAngle() const -> QString;
|
|
|
|
void SetFormulaRotationAngle(const QString &formula, qreal value);
|
|
|
|
void SetRotationAngle(qreal value);
|
|
|
|
auto GetRotationAngle() const -> qreal;
|
2016-02-10 05:59:29 +01:00
|
|
|
|
2022-05-20 16:08:32 +02:00
|
|
|
auto GetFormulaRadius1() const -> QString;
|
|
|
|
void SetFormulaRadius1(const QString &formula, qreal value);
|
|
|
|
void SetRadius1(qreal value);
|
|
|
|
auto GetRadius1() const -> qreal;
|
2016-02-10 05:59:29 +01:00
|
|
|
|
2022-05-20 16:08:32 +02:00
|
|
|
auto GetFormulaRadius2() const -> QString;
|
|
|
|
void SetFormulaRadius2(const QString &formula, qreal value);
|
|
|
|
void SetRadius2(qreal value);
|
|
|
|
auto GetRadius2() const -> qreal;
|
2016-02-12 19:19:46 +01:00
|
|
|
|
2022-05-20 16:08:32 +02:00
|
|
|
auto GetLength() const -> qreal override;
|
2016-02-12 21:02:54 +01:00
|
|
|
|
2022-05-20 16:08:32 +02:00
|
|
|
auto GetP1() const -> QPointF;
|
|
|
|
auto GetP2() const -> QPointF;
|
2016-02-10 05:59:29 +01:00
|
|
|
|
2022-05-20 16:08:32 +02:00
|
|
|
auto GetTransform() const -> QTransform;
|
|
|
|
void SetTransform(const QTransform &matrix, bool combine = false);
|
2018-01-05 18:41:09 +01:00
|
|
|
|
2022-05-20 16:08:32 +02:00
|
|
|
auto GetCenter() const -> VPointF;
|
|
|
|
auto GetPoints() const -> QVector<QPointF> override;
|
|
|
|
auto GetStartAngle() const -> qreal override;
|
|
|
|
auto GetEndAngle() const -> qreal override;
|
2016-02-10 05:59:29 +01:00
|
|
|
|
2023-07-13 16:49:20 +02:00
|
|
|
auto CutArc(const qreal &length, VEllipticalArc &arc1, VEllipticalArc &arc2, const QString &pointName) const
|
|
|
|
-> QPointF;
|
|
|
|
auto CutArc(const qreal &length, const QString &pointName) const -> QPointF;
|
2018-01-05 18:41:09 +01:00
|
|
|
|
2022-05-20 16:08:32 +02:00
|
|
|
static auto OptimizeAngle(qreal angle) -> qreal;
|
2023-07-13 16:49:20 +02:00
|
|
|
|
2016-02-27 15:53:17 +01:00
|
|
|
protected:
|
2022-05-20 16:08:32 +02:00
|
|
|
void CreateName() override;
|
|
|
|
void CreateAlias() override;
|
|
|
|
void FindF2(qreal length) override;
|
2023-07-13 16:49:20 +02:00
|
|
|
|
2016-02-10 05:59:29 +01:00
|
|
|
private:
|
|
|
|
QSharedDataPointer<VEllipticalArcData> d;
|
|
|
|
|
2022-05-20 16:08:32 +02:00
|
|
|
auto MaxLength() const -> qreal;
|
|
|
|
auto GetP(qreal angle) const -> QPointF;
|
2022-08-27 15:46:25 +02:00
|
|
|
auto ArcPoints(QVector<QPointF> points) const -> QVector<QPointF>;
|
2016-02-10 05:59:29 +01:00
|
|
|
};
|
|
|
|
|
2023-07-13 16:49:20 +02:00
|
|
|
Q_DECLARE_METATYPE(VEllipticalArc) // NOLINT
|
2022-05-20 16:08:32 +02:00
|
|
|
Q_DECLARE_TYPEINFO(VEllipticalArc, Q_MOVABLE_TYPE); // NOLINT
|
2016-02-10 05:59:29 +01:00
|
|
|
|
2018-01-05 18:41:09 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2022-05-20 16:08:32 +02:00
|
|
|
inline auto VEllipticalArc::OptimizeAngle(qreal angle) -> qreal
|
2018-01-05 18:41:09 +01:00
|
|
|
{
|
2023-07-13 16:49:20 +02:00
|
|
|
return angle - 360. * qFloor(angle / 360.);
|
2018-01-05 18:41:09 +01:00
|
|
|
}
|
|
|
|
|
2016-02-10 05:59:29 +01:00
|
|
|
#endif // VELLIPTICALARC_H
|