2016-11-03 16:59:53 +01:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file
|
|
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
|
|
** @date 3 11, 2016
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
2017-10-05 11:20:01 +02:00
|
|
|
** This source code is part of the Valentina project, a pattern making
|
2016-11-03 16:59:53 +01:00
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
** Copyright (C) 2016 Valentina project
|
2020-01-31 07:00:05 +01:00
|
|
|
** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
|
2016-11-03 16:59:53 +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/>.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#include "vpiecenode.h"
|
|
|
|
#include "vpiecenode_p.h"
|
2017-01-21 14:24:40 +01:00
|
|
|
#include "vcontainer.h"
|
|
|
|
#include "calculator.h"
|
2019-04-17 12:02:22 +02:00
|
|
|
#include "vformula.h"
|
2020-10-15 17:05:21 +02:00
|
|
|
#include "../vmisc/vabstractvalapplication.h"
|
2016-11-03 16:59:53 +01:00
|
|
|
|
2017-01-11 14:01:49 +01:00
|
|
|
#include <QDataStream>
|
2017-01-21 14:24:40 +01:00
|
|
|
#include <QtNumeric>
|
2017-01-11 14:01:49 +01:00
|
|
|
|
2016-11-03 16:59:53 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VPieceNode::VPieceNode()
|
|
|
|
: d(new VPieceNodeData)
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VPieceNode::VPieceNode(quint32 id, Tool typeTool, bool reverse)
|
|
|
|
: d(new VPieceNodeData(id, typeTool, reverse))
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VPieceNode::VPieceNode(const VPieceNode &node)
|
|
|
|
: d (node.d)
|
|
|
|
{}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::operator=(const VPieceNode &node) -> VPieceNode &
|
2016-11-03 16:59:53 +01:00
|
|
|
{
|
|
|
|
if ( &node == this )
|
|
|
|
{
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
d = node.d;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2019-12-30 12:00:57 +01:00
|
|
|
#ifdef Q_COMPILER_RVALUE_REFS
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2022-08-12 17:50:13 +02:00
|
|
|
VPieceNode::VPieceNode(VPieceNode &&node) Q_DECL_NOTHROW
|
|
|
|
: d (std::move(node.d))
|
2019-12-30 16:13:18 +01:00
|
|
|
{}
|
2019-12-30 12:00:57 +01:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::operator=(VPieceNode &&node) Q_DECL_NOTHROW->VPieceNode &
|
2019-12-30 12:00:57 +01:00
|
|
|
{
|
|
|
|
std::swap(d, node.d);
|
2019-12-30 16:13:18 +01:00
|
|
|
return *this;
|
2019-12-30 12:00:57 +01:00
|
|
|
}
|
2019-12-30 16:13:18 +01:00
|
|
|
#endif
|
2019-12-30 12:00:57 +01:00
|
|
|
|
2016-11-03 16:59:53 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
VPieceNode::~VPieceNode()
|
|
|
|
{}
|
|
|
|
|
2017-03-28 11:08:33 +02:00
|
|
|
// Friend functions
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto operator<<(QDataStream &out, const VPieceNode &p) -> QDataStream &
|
2017-03-28 11:08:33 +02:00
|
|
|
{
|
2019-07-01 10:02:09 +02:00
|
|
|
out << *p.d;
|
2017-03-28 11:08:33 +02:00
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto operator>>(QDataStream &in, VPieceNode &p) -> QDataStream &
|
2017-03-28 11:08:33 +02:00
|
|
|
{
|
|
|
|
in >> *p.d;
|
|
|
|
return in;
|
|
|
|
}
|
|
|
|
|
2016-11-03 16:59:53 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::GetId() const -> quint32
|
2016-11-03 16:59:53 +01:00
|
|
|
{
|
2016-11-04 15:28:10 +01:00
|
|
|
return d->m_id;
|
2016-11-03 16:59:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPieceNode::SetId(quint32 id)
|
|
|
|
{
|
2016-11-04 15:28:10 +01:00
|
|
|
d->m_id = id;
|
2016-11-03 16:59:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::GetTypeTool() const -> Tool
|
2016-11-03 16:59:53 +01:00
|
|
|
{
|
2016-11-04 15:28:10 +01:00
|
|
|
return d->m_typeTool;
|
2016-11-03 16:59:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPieceNode::SetTypeTool(Tool value)
|
|
|
|
{
|
2016-11-04 15:28:10 +01:00
|
|
|
d->m_typeTool = value;
|
2016-11-03 16:59:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::GetReverse() const -> bool
|
2016-11-03 16:59:53 +01:00
|
|
|
{
|
2016-11-04 15:28:10 +01:00
|
|
|
return d->m_reverse;
|
2016-11-03 16:59:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPieceNode::SetReverse(bool reverse)
|
|
|
|
{
|
2016-11-04 15:28:10 +01:00
|
|
|
if (d->m_typeTool != Tool::NodePoint)
|
2016-11-04 15:25:01 +01:00
|
|
|
{
|
2016-11-04 15:28:10 +01:00
|
|
|
d->m_reverse = reverse;
|
2016-11-04 15:25:01 +01:00
|
|
|
}
|
2016-11-03 16:59:53 +01:00
|
|
|
}
|
2016-11-04 16:34:15 +01:00
|
|
|
|
2016-11-12 11:41:04 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::GetSABefore(const VContainer *data) const -> qreal
|
2016-11-12 11:41:04 +01:00
|
|
|
{
|
2017-03-30 10:09:12 +02:00
|
|
|
if (d->m_formulaWidthBefore == currentSeamAllowance)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-04-17 12:02:22 +02:00
|
|
|
VFormula formula(d->m_formulaWidthBefore, data);
|
2019-04-17 15:08:48 +02:00
|
|
|
formula.setCheckZero(false);
|
2019-04-17 12:02:22 +02:00
|
|
|
formula.Eval();
|
|
|
|
|
|
|
|
if (formula.error())
|
|
|
|
{
|
|
|
|
QString nodeName;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
nodeName = data->GetGObject(d->m_id)->name();
|
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &)
|
|
|
|
{}
|
|
|
|
|
|
|
|
const QString errorMsg = QObject::tr("Cannot calculate seam allowance before for point '%1'. Reason: %2.")
|
|
|
|
.arg(nodeName, formula.Reason());
|
2021-02-06 14:52:21 +01:00
|
|
|
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
|
|
|
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
2019-04-17 12:02:22 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return formula.getDoubleValue();
|
2016-11-12 11:41:04 +01:00
|
|
|
}
|
|
|
|
|
2016-11-17 13:08:23 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::GetSABefore(const VContainer *data, Unit unit) const -> qreal
|
2016-11-17 13:08:23 +01:00
|
|
|
{
|
2017-03-30 10:09:12 +02:00
|
|
|
if (d->m_formulaWidthBefore == currentSeamAllowance)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-04-17 12:02:22 +02:00
|
|
|
VFormula formula(d->m_formulaWidthBefore, data);
|
2019-04-17 15:08:48 +02:00
|
|
|
formula.setCheckZero(false);
|
2019-04-17 12:02:22 +02:00
|
|
|
formula.Eval();
|
|
|
|
|
|
|
|
if (formula.error())
|
|
|
|
{
|
|
|
|
QString nodeName;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
nodeName = data->GetGObject(d->m_id)->name();
|
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &)
|
|
|
|
{}
|
|
|
|
|
|
|
|
const QString errorMsg = QObject::tr("Cannot calculate seam allowance before for point '%1'. Reason: %2.")
|
|
|
|
.arg(nodeName, formula.Reason());
|
2021-02-06 14:52:21 +01:00
|
|
|
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
|
|
|
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
2019-04-17 12:02:22 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
qreal value = formula.getDoubleValue();
|
2016-11-17 13:08:23 +01:00
|
|
|
if (value >= 0)
|
|
|
|
{
|
|
|
|
value = ToPixel(value, unit);
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2016-11-12 11:41:04 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::GetFormulaSABefore() const -> QString
|
2017-01-21 14:24:40 +01:00
|
|
|
{
|
|
|
|
return d->m_formulaWidthBefore;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPieceNode::SetFormulaSABefore(const QString &formula)
|
2016-11-12 11:41:04 +01:00
|
|
|
{
|
|
|
|
if (d->m_typeTool == Tool::NodePoint)
|
|
|
|
{
|
2017-01-21 14:24:40 +01:00
|
|
|
d->m_formulaWidthBefore = formula;
|
2016-11-12 11:41:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::GetSAAfter(const VContainer *data) const -> qreal
|
2016-11-12 11:41:04 +01:00
|
|
|
{
|
2017-03-30 10:09:12 +02:00
|
|
|
if (d->m_formulaWidthAfter == currentSeamAllowance)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-04-17 12:02:22 +02:00
|
|
|
VFormula formula(d->m_formulaWidthAfter, data);
|
2019-04-17 15:08:48 +02:00
|
|
|
formula.setCheckZero(false);
|
2019-04-17 12:02:22 +02:00
|
|
|
formula.Eval();
|
|
|
|
|
|
|
|
if (formula.error())
|
|
|
|
{
|
|
|
|
QString nodeName;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
nodeName = data->GetGObject(d->m_id)->name();
|
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &)
|
|
|
|
{}
|
|
|
|
|
|
|
|
const QString errorMsg = QObject::tr("Cannot calculate seam allowance after for point '%1'. Reason: %2.")
|
|
|
|
.arg(nodeName, formula.Reason());
|
2021-02-06 14:52:21 +01:00
|
|
|
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
|
|
|
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
2019-04-17 12:02:22 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return formula.getDoubleValue();
|
2016-11-12 11:41:04 +01:00
|
|
|
}
|
|
|
|
|
2016-11-17 13:08:23 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::GetSAAfter(const VContainer *data, Unit unit) const -> qreal
|
2016-11-17 13:08:23 +01:00
|
|
|
{
|
2017-03-30 10:09:12 +02:00
|
|
|
if (d->m_formulaWidthAfter == currentSeamAllowance)
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-04-17 12:02:22 +02:00
|
|
|
VFormula formula(d->m_formulaWidthAfter, data);
|
2019-04-17 15:08:48 +02:00
|
|
|
formula.setCheckZero(false);
|
2019-04-17 12:02:22 +02:00
|
|
|
formula.Eval();
|
|
|
|
|
|
|
|
if (formula.error())
|
|
|
|
{
|
|
|
|
QString nodeName;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
nodeName = data->GetGObject(d->m_id)->name();
|
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &)
|
|
|
|
{}
|
|
|
|
|
2023-01-15 16:57:33 +01:00
|
|
|
const QString errorMsg = QObject::tr("Cannot calculate seam allowance after for point '%1'. Reason: %2.")
|
2019-04-17 12:02:22 +02:00
|
|
|
.arg(nodeName, formula.Reason());
|
2021-02-06 14:52:21 +01:00
|
|
|
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
|
|
|
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
2019-04-17 12:02:22 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
qreal value = formula.getDoubleValue();
|
|
|
|
|
2016-11-17 13:08:23 +01:00
|
|
|
if (value >= 0)
|
|
|
|
{
|
|
|
|
value = ToPixel(value, unit);
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2016-11-12 11:41:04 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::GetFormulaSAAfter() const -> QString
|
2017-01-21 14:24:40 +01:00
|
|
|
{
|
|
|
|
return d->m_formulaWidthAfter;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPieceNode::SetFormulaSAAfter(const QString &formula)
|
2016-11-12 11:41:04 +01:00
|
|
|
{
|
|
|
|
if (d->m_typeTool == Tool::NodePoint)
|
|
|
|
{
|
2017-01-21 14:24:40 +01:00
|
|
|
d->m_formulaWidthAfter = formula;
|
2016-11-12 11:41:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-17 12:02:22 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::GetFormulaPassmarkLength() const -> QString
|
2019-04-17 12:02:22 +02:00
|
|
|
{
|
|
|
|
return d->m_formulaPassmarkLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPieceNode::SetFormulaPassmarkLength(const QString &formula)
|
|
|
|
{
|
|
|
|
if (d->m_typeTool == Tool::NodePoint)
|
|
|
|
{
|
|
|
|
d->m_formulaPassmarkLength = formula;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
auto VPieceNode::GetFormulaPassmarkWidth() const -> QString
|
|
|
|
{
|
|
|
|
return d->m_formulaPassmarkWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPieceNode::SetFormulaPassmarkWidth(const QString &formula)
|
|
|
|
{
|
|
|
|
if (d->m_typeTool == Tool::NodePoint)
|
|
|
|
{
|
|
|
|
d->m_formulaPassmarkWidth = formula;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
auto VPieceNode::GetFormulaPassmarkAngle() const -> QString
|
|
|
|
{
|
|
|
|
return d->m_formulaPassmarkAngle;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPieceNode::SetFormulaPassmarkAngle(const QString &formula)
|
|
|
|
{
|
|
|
|
if (d->m_typeTool == Tool::NodePoint)
|
|
|
|
{
|
|
|
|
d->m_formulaPassmarkAngle = formula;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-17 12:02:22 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::GetPassmarkLength(const VContainer *data, Unit unit) const -> qreal
|
2019-04-17 12:02:22 +02:00
|
|
|
{
|
|
|
|
if (d->m_manualPassmarkLength)
|
|
|
|
{
|
|
|
|
VFormula formula(d->m_formulaPassmarkLength, data);
|
2023-05-06 19:01:15 +02:00
|
|
|
formula.setCheckZero(true);
|
|
|
|
formula.setCheckLessThanZero(true);
|
2019-04-17 12:02:22 +02:00
|
|
|
formula.Eval();
|
|
|
|
|
|
|
|
if (formula.error())
|
|
|
|
{
|
|
|
|
QString nodeName;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
nodeName = data->GetGObject(d->m_id)->name();
|
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &)
|
|
|
|
{}
|
|
|
|
|
|
|
|
const QString errorMsg = QObject::tr("Cannot calculate passmark length for point '%1'. Reason: %2.")
|
|
|
|
.arg(nodeName, formula.Reason());
|
2021-02-06 14:52:21 +01:00
|
|
|
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
|
|
|
|
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
2019-04-17 12:02:22 +02:00
|
|
|
return VSAPoint::maxPassmarkLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ToPixel(formula.getDoubleValue(), unit);
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
auto VPieceNode::GetPassmarkWidth(const VContainer *data, Unit unit) const -> qreal
|
|
|
|
{
|
|
|
|
if (d->m_manualPassmarkWidth)
|
|
|
|
{
|
|
|
|
VFormula formula(d->m_formulaPassmarkWidth, data);
|
|
|
|
formula.setCheckZero(true);
|
|
|
|
formula.setCheckLessThanZero(false);
|
|
|
|
formula.Eval();
|
|
|
|
|
|
|
|
if (formula.error())
|
|
|
|
{
|
|
|
|
QString nodeName;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
nodeName = data->GetGObject(d->m_id)->name();
|
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString errorMsg = QObject::tr("Cannot calculate passmark width for point '%1'. Reason: %2.")
|
|
|
|
.arg(nodeName, formula.Reason());
|
|
|
|
VAbstractApplication::VApp()->IsPedantic()
|
|
|
|
? throw VException(errorMsg)
|
|
|
|
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ToPixel(formula.getDoubleValue(), unit);
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
auto VPieceNode::GetPassmarkAngle(const VContainer *data) const -> qreal
|
|
|
|
{
|
|
|
|
if (d->m_manualPassmarkAngle)
|
|
|
|
{
|
|
|
|
VFormula formula(d->m_formulaPassmarkAngle, data);
|
|
|
|
formula.setCheckZero(false);
|
|
|
|
formula.setCheckLessThanZero(false);
|
|
|
|
formula.Eval();
|
|
|
|
|
|
|
|
if (formula.error())
|
|
|
|
{
|
|
|
|
QString nodeName;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
nodeName = data->GetGObject(d->m_id)->name();
|
|
|
|
}
|
|
|
|
catch (const VExceptionBadId &)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString errorMsg = QObject::tr("Cannot calculate passmark angle for point '%1'. Reason: %2.")
|
|
|
|
.arg(nodeName, formula.Reason());
|
|
|
|
VAbstractApplication::VApp()->IsPedantic()
|
|
|
|
? throw VException(errorMsg)
|
|
|
|
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return formula.getDoubleValue();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-11-19 12:44:12 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::GetAngleType() const -> PieceNodeAngle
|
2016-11-19 12:44:12 +01:00
|
|
|
{
|
|
|
|
return d->m_angleType;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPieceNode::SetAngleType(PieceNodeAngle type)
|
|
|
|
{
|
2016-11-19 17:52:47 +01:00
|
|
|
if (d->m_typeTool == Tool::NodePoint)
|
|
|
|
{
|
|
|
|
d->m_angleType = type;
|
|
|
|
}
|
2016-11-19 12:44:12 +01:00
|
|
|
}
|
|
|
|
|
2016-11-04 16:34:15 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::IsPassmark() const -> bool
|
2016-11-04 16:34:15 +01:00
|
|
|
{
|
2017-03-24 12:08:16 +01:00
|
|
|
return d->m_isPassmark;
|
2016-11-04 16:34:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2017-03-24 12:08:16 +01:00
|
|
|
void VPieceNode::SetPassmark(bool passmark)
|
2016-11-04 16:34:15 +01:00
|
|
|
{
|
2017-03-24 12:08:16 +01:00
|
|
|
if (GetTypeTool() == Tool::NodePoint)
|
|
|
|
{
|
|
|
|
d->m_isPassmark = passmark;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-05 12:22:33 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::IsMainPathNode() const -> bool
|
2017-04-05 12:22:33 +02:00
|
|
|
{
|
|
|
|
return d->m_isMainPathNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPieceNode::SetMainPathNode(bool value)
|
|
|
|
{
|
|
|
|
d->m_isMainPathNode = value;
|
|
|
|
}
|
|
|
|
|
2017-03-24 12:08:16 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::GetPassmarkLineType() const -> PassmarkLineType
|
2017-03-24 12:08:16 +01:00
|
|
|
{
|
|
|
|
return d->m_passmarkLineType;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPieceNode::SetPassmarkLineType(PassmarkLineType lineType)
|
|
|
|
{
|
|
|
|
d->m_passmarkLineType = lineType;
|
|
|
|
}
|
2016-11-04 16:34:15 +01:00
|
|
|
|
2017-03-24 12:08:16 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::GetPassmarkAngleType() const -> PassmarkAngleType
|
2017-03-24 12:08:16 +01:00
|
|
|
{
|
|
|
|
return d->m_passmarkAngleType;
|
|
|
|
}
|
2016-11-04 16:34:15 +01:00
|
|
|
|
2017-03-24 12:08:16 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPieceNode::SetPassmarkAngleType(PassmarkAngleType angleType)
|
|
|
|
{
|
|
|
|
d->m_passmarkAngleType = angleType;
|
2016-11-04 16:34:15 +01:00
|
|
|
}
|
2017-03-21 16:18:48 +01:00
|
|
|
|
2017-04-26 10:22:42 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::IsShowSecondPassmark() const -> bool
|
2017-04-26 10:22:42 +02:00
|
|
|
{
|
|
|
|
return d->m_isShowSecondPassmark;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPieceNode::SetShowSecondPassmark(bool value)
|
|
|
|
{
|
|
|
|
d->m_isShowSecondPassmark = value;
|
|
|
|
}
|
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
auto VPieceNode::IsPassmarkClockwiseOpening() const -> bool
|
|
|
|
{
|
|
|
|
return d->m_isPassmarkClockwiseOpening;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPieceNode::SetPassmarkClockwiseOpening(bool value)
|
|
|
|
{
|
|
|
|
d->m_isPassmarkClockwiseOpening = value;
|
|
|
|
}
|
|
|
|
|
2018-03-05 11:05:59 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::IsCheckUniqueness() const -> bool
|
2018-03-05 11:05:59 +01:00
|
|
|
{
|
|
|
|
return d->m_checkUniqueness;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPieceNode::SetCheckUniqueness(bool value)
|
|
|
|
{
|
|
|
|
d->m_checkUniqueness = (d->m_typeTool == Tool::NodePoint ? value : true);
|
|
|
|
}
|
|
|
|
|
2019-04-17 12:02:22 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::IsManualPassmarkLength() const -> bool
|
2019-04-17 12:02:22 +02:00
|
|
|
{
|
|
|
|
return d->m_manualPassmarkLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPieceNode::SetManualPassmarkLength(bool value)
|
|
|
|
{
|
|
|
|
d->m_manualPassmarkLength = value;
|
|
|
|
}
|
|
|
|
|
2023-05-06 19:01:15 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
auto VPieceNode::IsManualPassmarkWidth() const -> bool
|
|
|
|
{
|
|
|
|
return d->m_manualPassmarkWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPieceNode::SetManualPassmarkWidth(bool value)
|
|
|
|
{
|
|
|
|
d->m_manualPassmarkWidth = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
auto VPieceNode::IsManualPassmarkAngle() const -> bool
|
|
|
|
{
|
|
|
|
return d->m_manualPassmarkAngle;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPieceNode::SetManualPassmarkAngle(bool value)
|
|
|
|
{
|
|
|
|
d->m_manualPassmarkAngle = value;
|
|
|
|
}
|
|
|
|
|
2022-10-28 15:16:02 +02:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::IsTurnPoint() const -> bool
|
2022-10-28 15:16:02 +02:00
|
|
|
{
|
|
|
|
return d->m_typeTool == Tool::NodePoint ? d->m_turnPoint : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPieceNode::SetTurnPoint(bool value)
|
|
|
|
{
|
|
|
|
d->m_turnPoint = value;
|
|
|
|
}
|
|
|
|
|
2017-03-21 16:18:48 +01:00
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
2023-05-03 13:07:02 +02:00
|
|
|
auto VPieceNode::IsExcluded() const -> bool
|
2017-03-21 16:18:48 +01:00
|
|
|
{
|
|
|
|
return d->m_excluded;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------
|
|
|
|
void VPieceNode::SetExcluded(bool exclude)
|
|
|
|
{
|
|
|
|
d->m_excluded = exclude;
|
|
|
|
}
|