2019-09-01 11:58:54 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vsapoint.h
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 1 9, 2019
|
|
|
|
**
|
|
|
|
** @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) 2019 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2019-09-01 11:58:54 +02: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 VSAPOINT_H
|
|
|
|
#define VSAPOINT_H
|
|
|
|
|
2022-10-08 13:22:52 +02:00
|
|
|
#include <QMetaType>
|
2023-08-12 09:31:10 +02:00
|
|
|
#include <QtGlobal>
|
|
|
|
|
|
|
|
#include "../vgeometry/vgeometrydef.h"
|
|
|
|
#include "../vmisc/def.h"
|
|
|
|
#include "vlayoutpoint.h"
|
2022-10-08 13:22:52 +02:00
|
|
|
|
2019-09-01 11:58:54 +02:00
|
|
|
QT_WARNING_PUSH
|
|
|
|
QT_WARNING_DISABLE_GCC("-Weffc++")
|
|
|
|
QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
|
2022-10-28 15:16:02 +02:00
|
|
|
QT_WARNING_DISABLE_CLANG("-Wnon-virtual-dtor")
|
2019-09-01 11:58:54 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The VSAPoint class seam allowance point
|
|
|
|
*/
|
2022-11-10 14:01:42 +01:00
|
|
|
class VSAPoint final : public VLayoutPoint
|
2019-09-01 11:58:54 +02:00
|
|
|
{
|
|
|
|
public:
|
2022-10-08 13:22:52 +02:00
|
|
|
QT_WARNING_PUSH
|
|
|
|
QT_WARNING_DISABLE_GCC("-Wnoexcept")
|
|
|
|
|
|
|
|
Q_DECL_CONSTEXPR VSAPoint() = default;
|
|
|
|
|
|
|
|
QT_WARNING_POP
|
|
|
|
|
2019-09-01 11:58:54 +02:00
|
|
|
Q_DECL_CONSTEXPR VSAPoint(qreal xpos, qreal ypos);
|
|
|
|
Q_DECL_CONSTEXPR explicit VSAPoint(QPointF p);
|
2022-10-28 15:16:02 +02:00
|
|
|
Q_DECL_CONSTEXPR explicit VSAPoint(const VLayoutPoint &p);
|
2019-09-01 11:58:54 +02:00
|
|
|
|
2022-10-08 13:22:52 +02:00
|
|
|
Q_DECL_CONSTEXPR auto GetSABefore() const -> qreal;
|
|
|
|
Q_DECL_CONSTEXPR auto GetSAAfter() const -> qreal;
|
2023-05-08 16:50:22 +02:00
|
|
|
|
2022-10-08 13:22:52 +02:00
|
|
|
Q_DECL_CONSTEXPR auto GetAngleType() const -> PieceNodeAngle;
|
2023-05-08 16:50:22 +02:00
|
|
|
|
2022-10-08 13:22:52 +02:00
|
|
|
Q_DECL_CONSTEXPR auto IsManualPasskmarkLength() const -> bool;
|
2023-05-06 19:01:15 +02:00
|
|
|
Q_DECL_CONSTEXPR auto IsManualPasskmarkWidth() const -> bool;
|
|
|
|
Q_DECL_CONSTEXPR auto IsManualPasskmarkAngle() const -> bool;
|
|
|
|
|
2022-10-08 13:22:52 +02:00
|
|
|
Q_DECL_CONSTEXPR auto GetPasskmarkLength() const -> qreal;
|
2023-05-06 19:01:15 +02:00
|
|
|
Q_DECL_CONSTEXPR auto GetPasskmarkWidth() const -> qreal;
|
|
|
|
Q_DECL_CONSTEXPR auto GetPasskmarkAngle() const -> qreal;
|
2019-09-01 11:58:54 +02:00
|
|
|
|
2022-10-08 13:22:52 +02:00
|
|
|
Q_DECL_RELAXED_CONSTEXPR auto GetSABefore(qreal width) const -> qreal;
|
|
|
|
Q_DECL_RELAXED_CONSTEXPR auto GetSAAfter(qreal width) const -> qreal;
|
2019-09-01 11:58:54 +02:00
|
|
|
|
2022-10-08 13:22:52 +02:00
|
|
|
Q_DECL_RELAXED_CONSTEXPR void SetSABefore(qreal value);
|
|
|
|
Q_DECL_RELAXED_CONSTEXPR void SetSAAfter(qreal value);
|
2019-09-01 11:58:54 +02:00
|
|
|
|
2022-10-08 13:22:52 +02:00
|
|
|
Q_DECL_RELAXED_CONSTEXPR void SetAngleType(PieceNodeAngle value);
|
2023-05-08 16:50:22 +02:00
|
|
|
|
2019-09-01 11:58:54 +02:00
|
|
|
Q_DECL_RELAXED_CONSTEXPR void SetManualPasskmarkLength(bool value);
|
2023-05-06 19:01:15 +02:00
|
|
|
Q_DECL_RELAXED_CONSTEXPR void SetManualPasskmarkWidth(bool value);
|
|
|
|
Q_DECL_RELAXED_CONSTEXPR void SetManualPasskmarkAngle(bool value);
|
|
|
|
|
2022-10-08 13:22:52 +02:00
|
|
|
Q_DECL_RELAXED_CONSTEXPR void SetPasskmarkLength(qreal value);
|
2023-05-06 19:01:15 +02:00
|
|
|
Q_DECL_RELAXED_CONSTEXPR void SetPasskmarkWidth(qreal value);
|
|
|
|
Q_DECL_RELAXED_CONSTEXPR void SetPasskmarkAngle(qreal value);
|
2019-09-01 11:58:54 +02:00
|
|
|
|
2022-10-08 13:22:52 +02:00
|
|
|
Q_DECL_RELAXED_CONSTEXPR auto MaxLocalSA(qreal width) const -> qreal;
|
|
|
|
Q_DECL_RELAXED_CONSTEXPR auto PassmarkLength(qreal width) const -> qreal;
|
2019-09-01 11:58:54 +02:00
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
Q_DECL_CONSTEXPR auto IsPassmarkClockwiseOpening() const -> bool;
|
|
|
|
Q_DECL_RELAXED_CONSTEXPR void SetPassmarkClockwiseOpening(bool clockwise);
|
|
|
|
|
2022-11-10 14:40:41 +01:00
|
|
|
auto toJson() const -> QJsonObject;
|
2019-09-01 11:58:54 +02:00
|
|
|
|
2022-10-08 13:22:52 +02:00
|
|
|
static constexpr qreal passmarkFactor{0.5};
|
|
|
|
static constexpr qreal maxPassmarkLength{MmToPixel(10.)};
|
2023-08-12 09:31:10 +02:00
|
|
|
static constexpr qreal minSAWidth{accuracyPointOnLine + accuracyPointOnLine * 0.5};
|
2019-09-01 11:58:54 +02:00
|
|
|
|
|
|
|
private:
|
2023-05-06 19:01:15 +02:00
|
|
|
qreal m_before{-1};
|
|
|
|
qreal m_after{-1};
|
2019-09-01 11:58:54 +02:00
|
|
|
PieceNodeAngle m_angle{PieceNodeAngle::ByLength};
|
2023-05-06 19:01:15 +02:00
|
|
|
bool m_manualPassmarkLength{false};
|
|
|
|
bool m_manualPassmarkWidth{false};
|
|
|
|
bool m_manualPassmarkAngle{false};
|
|
|
|
qreal m_passmarkLength{0};
|
|
|
|
qreal m_passmarkWidth{0};
|
|
|
|
qreal m_passmarkAngle{0};
|
|
|
|
bool m_passmarkClockwiseOpening{false};
|
2019-09-01 11:58:54 +02:00
|
|
|
};
|
|
|
|
|
2023-08-12 09:31:10 +02:00
|
|
|
Q_DECLARE_METATYPE(VSAPoint) // NOLINT
|
2022-08-12 17:50:13 +02:00
|
|
|
Q_DECLARE_TYPEINFO(VSAPoint, Q_MOVABLE_TYPE); // NOLINT
|
2019-09-01 11:58:54 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(qreal xpos, qreal ypos)
|
2023-08-12 09:31:10 +02:00
|
|
|
: VLayoutPoint(xpos, ypos)
|
|
|
|
{
|
|
|
|
}
|
2019-09-01 11:58:54 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(QPointF p)
|
2023-08-12 09:31:10 +02:00
|
|
|
: VLayoutPoint(p)
|
|
|
|
{
|
|
|
|
}
|
2022-10-28 15:16:02 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(const VLayoutPoint &p)
|
2023-08-12 09:31:10 +02:00
|
|
|
: VLayoutPoint(p)
|
|
|
|
{
|
|
|
|
}
|
2019-09-01 11:58:54 +02:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2022-10-08 13:22:52 +02:00
|
|
|
Q_DECL_CONSTEXPR inline auto VSAPoint::GetSABefore() const -> qreal
|
2019-09-01 11:58:54 +02:00
|
|
|
{
|
|
|
|
return m_before;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2022-10-08 13:22:52 +02:00
|
|
|
Q_DECL_RELAXED_CONSTEXPR inline auto VSAPoint::GetSABefore(qreal width) const -> qreal
|
|
|
|
{
|
|
|
|
if (m_before < 0)
|
|
|
|
{
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
return qMax(m_before, minSAWidth);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_RELAXED_CONSTEXPR inline void VSAPoint::SetSABefore(qreal value)
|
2019-09-01 11:58:54 +02:00
|
|
|
{
|
|
|
|
value < 0 ? m_before = -1 : m_before = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2022-10-08 13:22:52 +02:00
|
|
|
Q_DECL_CONSTEXPR inline auto VSAPoint::GetSAAfter() const -> qreal
|
2019-09-01 11:58:54 +02:00
|
|
|
{
|
|
|
|
return m_after;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2022-10-08 13:22:52 +02:00
|
|
|
Q_DECL_RELAXED_CONSTEXPR inline auto VSAPoint::GetSAAfter(qreal width) const -> qreal
|
|
|
|
{
|
|
|
|
if (m_after < 0)
|
|
|
|
{
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
return qMax(m_after, minSAWidth);
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_RELAXED_CONSTEXPR inline void VSAPoint::SetSAAfter(qreal value)
|
2019-09-01 11:58:54 +02:00
|
|
|
{
|
|
|
|
value < 0 ? m_after = -1 : m_after = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2022-10-08 13:22:52 +02:00
|
|
|
Q_DECL_CONSTEXPR inline auto VSAPoint::GetAngleType() const -> PieceNodeAngle
|
2019-09-01 11:58:54 +02:00
|
|
|
{
|
|
|
|
return m_angle;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2022-10-08 13:22:52 +02:00
|
|
|
Q_DECL_RELAXED_CONSTEXPR inline void VSAPoint::SetAngleType(PieceNodeAngle value)
|
2019-09-01 11:58:54 +02:00
|
|
|
{
|
|
|
|
m_angle = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2022-10-08 13:22:52 +02:00
|
|
|
Q_DECL_CONSTEXPR inline auto VSAPoint::IsManualPasskmarkLength() const -> bool
|
2019-09-01 11:58:54 +02:00
|
|
|
{
|
|
|
|
return m_manualPassmarkLength;
|
|
|
|
}
|
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_CONSTEXPR inline auto VSAPoint::IsManualPasskmarkWidth() const -> bool
|
|
|
|
{
|
|
|
|
return m_manualPassmarkWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_CONSTEXPR inline auto VSAPoint::IsManualPasskmarkAngle() const -> bool
|
|
|
|
{
|
|
|
|
return m_manualPassmarkAngle;
|
|
|
|
}
|
|
|
|
|
2019-09-01 11:58:54 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_RELAXED_CONSTEXPR inline void VSAPoint::SetManualPasskmarkLength(bool value)
|
|
|
|
{
|
|
|
|
m_manualPassmarkLength = value;
|
|
|
|
}
|
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_RELAXED_CONSTEXPR inline void VSAPoint::SetManualPasskmarkWidth(bool value)
|
|
|
|
{
|
|
|
|
m_manualPassmarkWidth = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_RELAXED_CONSTEXPR inline void VSAPoint::SetManualPasskmarkAngle(bool value)
|
|
|
|
{
|
|
|
|
m_manualPassmarkAngle = value;
|
|
|
|
}
|
|
|
|
|
2019-09-01 11:58:54 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2022-10-08 13:22:52 +02:00
|
|
|
Q_DECL_CONSTEXPR inline auto VSAPoint::GetPasskmarkLength() const -> qreal
|
2019-09-01 11:58:54 +02:00
|
|
|
{
|
|
|
|
return m_passmarkLength;
|
|
|
|
}
|
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_CONSTEXPR inline auto VSAPoint::GetPasskmarkWidth() const -> qreal
|
|
|
|
{
|
|
|
|
return m_passmarkWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_CONSTEXPR inline auto VSAPoint::GetPasskmarkAngle() const -> qreal
|
|
|
|
{
|
|
|
|
return m_passmarkAngle;
|
|
|
|
}
|
|
|
|
|
2019-09-01 11:58:54 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_RELAXED_CONSTEXPR inline void VSAPoint::SetPasskmarkLength(qreal value)
|
|
|
|
{
|
|
|
|
m_passmarkLength = value;
|
|
|
|
}
|
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_RELAXED_CONSTEXPR inline void VSAPoint::SetPasskmarkWidth(qreal value)
|
|
|
|
{
|
|
|
|
m_passmarkWidth = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_RELAXED_CONSTEXPR inline void VSAPoint::SetPasskmarkAngle(qreal value)
|
|
|
|
{
|
|
|
|
m_passmarkAngle = value;
|
|
|
|
}
|
|
|
|
|
2022-10-08 13:22:52 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_RELAXED_CONSTEXPR inline auto VSAPoint::MaxLocalSA(qreal width) const -> qreal
|
|
|
|
{
|
|
|
|
return qMax(GetSAAfter(width), GetSABefore(width));
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_RELAXED_CONSTEXPR inline auto VSAPoint::PassmarkLength(qreal width) const -> qreal
|
|
|
|
{
|
|
|
|
if (not m_manualPassmarkLength)
|
|
|
|
{
|
|
|
|
qreal passmarkLength = MaxLocalSA(width) * passmarkFactor;
|
|
|
|
passmarkLength = qMin(passmarkLength, maxPassmarkLength);
|
|
|
|
return passmarkLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
return m_passmarkLength;
|
|
|
|
}
|
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-10 17:28:38 +02:00
|
|
|
Q_DECL_CONSTEXPR inline auto VSAPoint::IsPassmarkClockwiseOpening() const -> bool
|
2023-05-06 19:01:15 +02:00
|
|
|
{
|
|
|
|
return m_passmarkClockwiseOpening;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
Q_DECL_RELAXED_CONSTEXPR inline void VSAPoint::SetPassmarkClockwiseOpening(bool clockwise)
|
|
|
|
{
|
|
|
|
m_passmarkClockwiseOpening = clockwise;
|
|
|
|
}
|
|
|
|
|
2019-09-01 11:58:54 +02:00
|
|
|
QT_WARNING_POP
|
|
|
|
|
|
|
|
#endif // VSAPOINT_H
|