valentina/src/libs/vgeometry/vellipticalarc.h

133 lines
5.3 KiB
C
Raw Normal View History

/************************************************************************
**
** @file vellipticalarc.h
** @author Valentina Zhuravska <zhuravska19(at)gmail.com>
** @date February 1, 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) 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/>.
**
*************************************************************************/
#ifndef VELLIPTICALARC_H
#define VELLIPTICALARC_H
#include <QCoreApplication>
#include <QPointF>
#include <QSharedDataPointer>
#include <QString>
#include <QTypeInfo>
#include <QVector>
#include <QtGlobal>
2022-08-13 18:26:55 +02:00
#include <QtMath>
#include "vabstractarc.h"
#include "vpointf.h"
class VEllipticalArcData;
class VEllipticalArc final : public VAbstractArc
{
2022-05-20 16:08:32 +02:00
Q_DECLARE_TR_FUNCTIONS(VEllipticalArc) // NOLINT
2023-07-13 16:49:20 +02:00
public:
VEllipticalArc();
2022-05-20 16:08:32 +02:00
VEllipticalArc(const VPointF &center, 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 &center, qreal radius1, qreal radius2, qreal f1, qreal f2, qreal rotationAngle);
VEllipticalArc(qreal length, const QString &formulaLength, const VPointF &center, 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 &center, qreal radius1, qreal radius2, qreal f1, qreal rotationAngle);
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;
2022-05-20 16:08:32 +02:00
~VEllipticalArc() override;
2023-07-13 16:49:20 +02:00
auto operator=(const VEllipticalArc &arc) -> VEllipticalArc &;
2024-02-19 10:14:02 +01:00
2023-07-13 16:49:20 +02:00
VEllipticalArc(VEllipticalArc &&arc) noexcept;
auto operator=(VEllipticalArc &&arc) noexcept -> VEllipticalArc &;
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;
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;
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;
2022-05-20 16:08:32 +02:00
auto GetLength() const -> qreal override;
2022-05-20 16:08:32 +02:00
auto GetP1() const -> QPointF;
auto GetP2() const -> QPointF;
2022-05-20 16:08:32 +02:00
auto GetTransform() const -> QTransform;
void SetTransform(const QTransform &matrix, bool combine = false);
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;
2023-11-14 15:37:14 +01:00
auto CutArc(qreal length, VEllipticalArc &arc1, VEllipticalArc &arc2, const QString &pointName) const -> QPointF;
auto CutArc(qreal length, const QString &pointName) const -> QPointF;
2022-05-20 16:08:32 +02:00
static auto OptimizeAngle(qreal angle) -> qreal;
2023-07-13 16:49:20 +02: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
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>;
2023-11-14 15:37:14 +01:00
auto CorrectCutLength(qreal length, qreal fullLength, const QString &pointName) const -> qreal;
};
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
//---------------------------------------------------------------------------------------------------------------------
2022-05-20 16:08:32 +02:00
inline auto VEllipticalArc::OptimizeAngle(qreal angle) -> qreal
{
2023-07-13 16:49:20 +02:00
return angle - 360. * qFloor(angle / 360.);
}
#endif // VELLIPTICALARC_H