Resolved issue #965. Control passmark length with formula.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-04-17 13:02:22 +03:00
parent b500650cf1
commit 52dfb912ee
25 changed files with 2903 additions and 655 deletions

View File

@ -13,6 +13,7 @@
- [#936] Improve list of predefined paper size formats for layout export. Added format Tabloid. - [#936] Improve list of predefined paper size formats for layout export. Added format Tabloid.
- Extend Label language to support Czech alphabet. - Extend Label language to support Czech alphabet.
- [#916] Improve layout generation. - [#916] Improve layout generation.
- [#965] Control passmark length with formula.
# Version 0.6.2 (unreleased) # Version 0.6.2 (unreleased)
- [#903] Bug in tool Cut Spline path. - [#903] Bug in tool Cut Spline path.

View File

@ -54,6 +54,7 @@
<file>schema/pattern/v0.8.0.xsd</file> <file>schema/pattern/v0.8.0.xsd</file>
<file>schema/pattern/v0.8.1.xsd</file> <file>schema/pattern/v0.8.1.xsd</file>
<file>schema/pattern/v0.8.2.xsd</file> <file>schema/pattern/v0.8.2.xsd</file>
<file>schema/pattern/v0.8.3.xsd</file>
<file>schema/standard_measurements/v0.3.0.xsd</file> <file>schema/standard_measurements/v0.3.0.xsd</file>
<file>schema/standard_measurements/v0.4.0.xsd</file> <file>schema/standard_measurements/v0.4.0.xsd</file>
<file>schema/standard_measurements/v0.4.1.xsd</file> <file>schema/standard_measurements/v0.4.1.xsd</file>

File diff suppressed because it is too large Load Diff

View File

@ -130,6 +130,8 @@ const QString VAbstractPattern::AttrIncludeAs = QStringLiteral("includeA
const QString VAbstractPattern::AttrRotation = QStringLiteral("rotation"); const QString VAbstractPattern::AttrRotation = QStringLiteral("rotation");
const QString VAbstractPattern::AttrNumber = QStringLiteral("number"); const QString VAbstractPattern::AttrNumber = QStringLiteral("number");
const QString VAbstractPattern::AttrCheckUniqueness = QStringLiteral("checkUniqueness"); const QString VAbstractPattern::AttrCheckUniqueness = QStringLiteral("checkUniqueness");
const QString VAbstractPattern::AttrManualPassmarkLength = QStringLiteral("manualPassmarkLength");
const QString VAbstractPattern::AttrPassmarkLength = QStringLiteral("passmarkLength");
const QString VAbstractPattern::AttrAll = QStringLiteral("all"); const QString VAbstractPattern::AttrAll = QStringLiteral("all");
@ -764,6 +766,10 @@ VPieceNode VAbstractPattern::ParseSANode(const QDomElement &domElement)
const bool showSecond = VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrNodeShowSecondPassmark, const bool showSecond = VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrNodeShowSecondPassmark,
trueStr); trueStr);
const bool manualPassmarkLength =
VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrManualPassmarkLength, falseStr);
const QString passmarkLength =
VDomDocument::GetParametrEmptyString(domElement, VAbstractPattern::AttrPassmarkLength);
const QString t = VDomDocument::GetParametrString(domElement, AttrType, VAbstractPattern::NodePoint); const QString t = VDomDocument::GetParametrString(domElement, AttrType, VAbstractPattern::NodePoint);
Tool tool; Tool tool;
@ -808,6 +814,8 @@ VPieceNode VAbstractPattern::ParseSANode(const QDomElement &domElement)
node.SetPassmark(passmark); node.SetPassmark(passmark);
node.SetPassmarkLineType(passmarkLine); node.SetPassmarkLineType(passmarkLine);
node.SetPassmarkAngleType(passmarkAngle); node.SetPassmarkAngleType(passmarkAngle);
node.SetManualPassmarkLength(manualPassmarkLength);
node.SetFormulaPassmarkLength(passmarkLength);
return node; return node;
} }

View File

@ -278,6 +278,8 @@ public:
static const QString AttrRotation; static const QString AttrRotation;
static const QString AttrNumber; static const QString AttrNumber;
static const QString AttrCheckUniqueness; static const QString AttrCheckUniqueness;
static const QString AttrManualPassmarkLength;
static const QString AttrPassmarkLength;
static const QString AttrAll; static const QString AttrAll;

View File

@ -59,8 +59,8 @@ class QDomElement;
*/ */
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4"); const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.2"); const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.3");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.2.xsd"); const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.3.xsd");
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
@ -232,7 +232,8 @@ QString VPatternConverter::XSDSchema(int ver) const
std::make_pair(FORMAT_VERSION(0, 7, 13), QStringLiteral("://schema/pattern/v0.7.13.xsd")), std::make_pair(FORMAT_VERSION(0, 7, 13), QStringLiteral("://schema/pattern/v0.7.13.xsd")),
std::make_pair(FORMAT_VERSION(0, 8, 0), QStringLiteral("://schema/pattern/v0.8.0.xsd")), std::make_pair(FORMAT_VERSION(0, 8, 0), QStringLiteral("://schema/pattern/v0.8.0.xsd")),
std::make_pair(FORMAT_VERSION(0, 8, 1), QStringLiteral("://schema/pattern/v0.8.1.xsd")), std::make_pair(FORMAT_VERSION(0, 8, 1), QStringLiteral("://schema/pattern/v0.8.1.xsd")),
std::make_pair(FORMAT_VERSION(0, 8, 2), CurrentSchema) std::make_pair(FORMAT_VERSION(0, 8, 2), QStringLiteral("://schema/pattern/v0.8.2.xsd")),
std::make_pair(FORMAT_VERSION(0, 8, 3), CurrentSchema)
}; };
if (schemas.contains(ver)) if (schemas.contains(ver))
@ -461,6 +462,10 @@ void VPatternConverter::ApplyPatches()
ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 2)), m_convertedFileName); ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 2)), m_convertedFileName);
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 8, 2)): case (FORMAT_VERSION(0, 8, 2)):
ToV0_8_3();
ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 3)), m_convertedFileName);
Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 8, 3)):
break; break;
default: default:
InvalidVersion(m_ver); InvalidVersion(m_ver);
@ -478,7 +483,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion()
bool VPatternConverter::IsReadOnly() const bool VPatternConverter::IsReadOnly() const
{ {
// Check if attribute readOnly was not changed in file format // Check if attribute readOnly was not changed in file format
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 8, 2), Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == FORMAT_VERSION(0, 8, 3),
"Check attribute readOnly."); "Check attribute readOnly.");
// Possibly in future attribute readOnly will change position etc. // Possibly in future attribute readOnly will change position etc.
@ -1068,6 +1073,16 @@ void VPatternConverter::ToV0_8_2()
Save(); Save();
} }
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::ToV0_8_3()
{
// TODO. Delete if minimal supported version is 0.8.3
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FORMAT_VERSION(0, 8, 3),
"Time to refactor the code.");
SetVersion(QStringLiteral("0.8.3"));
Save();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnitToV0_2_0() void VPatternConverter::TagUnitToV0_2_0()
{ {

View File

@ -53,7 +53,7 @@ public:
static const QString PatternMaxVerStr; static const QString PatternMaxVerStr;
static const QString CurrentSchema; static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const int PatternMinVer = FORMAT_VERSION(0, 1, 4); static Q_DECL_CONSTEXPR const int PatternMinVer = FORMAT_VERSION(0, 1, 4);
static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 2); static Q_DECL_CONSTEXPR const int PatternMaxVer = FORMAT_VERSION(0, 8, 3);
protected: protected:
virtual int MinVer() const override; virtual int MinVer() const override;
@ -125,6 +125,7 @@ private:
void ToV0_8_0(); void ToV0_8_0();
void ToV0_8_1(); void ToV0_8_1();
void ToV0_8_2(); void ToV0_8_2();
void ToV0_8_3();
void TagUnitToV0_2_0(); void TagUnitToV0_2_0();
void TagIncrementToV0_2_0(); void TagIncrementToV0_2_0();

View File

@ -1571,9 +1571,16 @@ qreal VSAPoint::MaxLocalSA(qreal width) const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VSAPoint::PassmarkLength(qreal width) const qreal VSAPoint::PassmarkLength(qreal width) const
{ {
qreal passmarkLength = MaxLocalSA(width) * passmarkFactor; if (not m_manualPassmarkLength)
passmarkLength = qMin(passmarkLength, maxPassmarkLength); {
return passmarkLength; qreal passmarkLength = MaxLocalSA(width) * passmarkFactor;
passmarkLength = qMin(passmarkLength, maxPassmarkLength);
return passmarkLength;
}
else
{
return m_passmarkLength;
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -57,7 +57,7 @@ class VSAPoint : public QPointF
public: public:
Q_DECL_CONSTEXPR VSAPoint(); Q_DECL_CONSTEXPR VSAPoint();
Q_DECL_CONSTEXPR VSAPoint(qreal xpos, qreal ypos); Q_DECL_CONSTEXPR VSAPoint(qreal xpos, qreal ypos);
Q_DECL_CONSTEXPR explicit VSAPoint(const QPointF &p); Q_DECL_CONSTEXPR explicit VSAPoint(QPointF p);
Q_DECL_CONSTEXPR qreal GetSABefore() const; Q_DECL_CONSTEXPR qreal GetSABefore() const;
qreal GetSABefore(qreal width) const; qreal GetSABefore(qreal width) const;
@ -70,6 +70,12 @@ public:
Q_DECL_CONSTEXPR PieceNodeAngle GetAngleType() const; Q_DECL_CONSTEXPR PieceNodeAngle GetAngleType() const;
void SetAngleType(PieceNodeAngle value); void SetAngleType(PieceNodeAngle value);
Q_DECL_CONSTEXPR bool IsManualPasskmarkLength() const;
Q_DECL_CONSTEXPR void SetManualPasskmarkLength(bool value);
Q_DECL_CONSTEXPR qreal GetPasskmarkLength() const;
Q_DECL_CONSTEXPR void SetPasskmarkLength(qreal value);
qreal MaxLocalSA(qreal width) const; qreal MaxLocalSA(qreal width) const;
qreal PassmarkLength(qreal width) const; qreal PassmarkLength(qreal width) const;
@ -77,9 +83,11 @@ public:
static const qreal maxPassmarkLength; static const qreal maxPassmarkLength;
private: private:
qreal m_before; qreal m_before{-1};
qreal m_after; qreal m_after{-1};
PieceNodeAngle m_angle; PieceNodeAngle m_angle{PieceNodeAngle::ByLength};
bool m_manualPassmarkLength{false};
qreal m_passmarkLength{0};
}; };
Q_DECLARE_METATYPE(VSAPoint) Q_DECLARE_METATYPE(VSAPoint)
@ -87,26 +95,16 @@ Q_DECLARE_TYPEINFO(VSAPoint, Q_MOVABLE_TYPE);
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint() Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint()
: QPointF(),
m_before(-1),
m_after(-1),
m_angle(PieceNodeAngle::ByLength)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(qreal xpos, qreal ypos) Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(qreal xpos, qreal ypos)
: QPointF(xpos, ypos), : QPointF(xpos, ypos)
m_before(-1),
m_after(-1),
m_angle(PieceNodeAngle::ByLength)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(const QPointF &p) Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(QPointF p)
: QPointF(p), : QPointF(p)
m_before(-1),
m_after(-1),
m_angle(PieceNodeAngle::ByLength)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -145,6 +143,30 @@ inline void VSAPoint::SetAngleType(PieceNodeAngle value)
m_angle = value; m_angle = value;
} }
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline bool VSAPoint::IsManualPasskmarkLength() const
{
return m_manualPassmarkLength;
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline void VSAPoint::SetManualPasskmarkLength(bool value)
{
m_manualPassmarkLength = value;
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline qreal VSAPoint::GetPasskmarkLength() const
{
return m_passmarkLength;
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline void VSAPoint::SetPasskmarkLength(qreal value)
{
m_passmarkLength = value;
}
QT_WARNING_POP QT_WARNING_POP
class VAbstractPiece class VAbstractPiece

View File

@ -27,6 +27,7 @@
*************************************************************************/ *************************************************************************/
#include "vformula.h" #include "vformula.h"
#include "vformula_p.h"
#include <qnumeric.h> #include <qnumeric.h>
#include <QMessageLogger> #include <QMessageLogger>
@ -45,26 +46,12 @@
//VFormula //VFormula
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VFormula::VFormula() VFormula::VFormula()
: formula(QString()), : d(new VFormulaData)
value(tr("Error")),
checkZero(true),
data(nullptr),
toolId(NULL_ID),
postfix(QString()),
_error(true),
dValue(0)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VFormula::VFormula(const QString &formula, const VContainer *container) VFormula::VFormula(const QString &formula, const VContainer *container)
: formula(qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator())), : d(new VFormulaData(formula, container))
value(tr("Error")),
checkZero(true),
data(container),
toolId(NULL_ID),
postfix(QString()),
_error(true),
dValue(0)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -74,41 +61,26 @@ VFormula &VFormula::operator=(const VFormula &formula)
{ {
return *this; return *this;
} }
this->formula = formula.formula; d = formula.d;
this->value = formula.value;
this->checkZero = formula.checkZero;
this->data = formula.data;
this->toolId = formula.toolId;
this->postfix = formula.postfix;
this->_error = formula._error;
this->dValue = formula.dValue;
return *this; return *this;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VFormula::VFormula(const VFormula &formula) VFormula::VFormula(const VFormula &formula)
: formula(formula.formula), : d (formula.d)
value(formula.value), {}
checkZero(formula.checkZero),
data(formula.getData()), //---------------------------------------------------------------------------------------------------------------------
toolId(formula.toolId), VFormula::~VFormula()
postfix(formula.postfix),
_error(formula._error),
dValue(formula.dValue)
{} {}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VFormula::operator==(const VFormula &formula) const bool VFormula::operator==(const VFormula &formula) const
{ {
bool isEqual = false; return d->formula == formula.GetFormula() && d->strValue == formula.getStringValue() &&
if (this->formula == formula.GetFormula() && this->value == formula.getStringValue() && d->checkZero == formula.getCheckZero() && d->checkLessThanZero == formula.getCheckLessThanZero() &&
this->checkZero == formula.getCheckZero() && this->data == formula.getData() && d->data == formula.getData() && d->toolId == formula.getToolId() && d->postfix == formula.getPostfix() &&
this->toolId == formula.getToolId() && this->postfix == formula.getPostfix() && d->error == formula.error() && VFuzzyComparePossibleNulls(d->dValue, formula.getDoubleValue());
this->_error == formula.error() && VFuzzyComparePossibleNulls(this->dValue, formula.getDoubleValue()))
{
isEqual = true;
}
return isEqual;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -122,103 +94,120 @@ QString VFormula::GetFormula(FormulaType type) const
{ {
if (type == FormulaType::ToUser) if (type == FormulaType::ToUser)
{ {
return formula; return qApp->TrVars()->TryFormulaToUser(d->formula, qApp->Settings()->GetOsSeparator());
} }
else else
{ {
return qApp->TrVars()->TryFormulaFromUser(formula, qApp->Settings()->GetOsSeparator()); return d->formula;
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VFormula::SetFormula(const QString &value, FormulaType type) void VFormula::SetFormula(const QString &value, FormulaType type)
{ {
if (formula != value) if (d->formula != value)
{ {
if (type == FormulaType::ToUser) if (type == FormulaType::FromUser)
{ {
formula = qApp->TrVars()->FormulaToUser(value, qApp->Settings()->GetOsSeparator()); d->formula = qApp->TrVars()->FormulaFromUser(value, qApp->Settings()->GetOsSeparator());
} }
else else
{ {
formula = value; d->formula = value;
} }
ResetState();
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VFormula::getStringValue() const QString VFormula::getStringValue() const
{ {
return value; return d->strValue;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VFormula::getDoubleValue() const qreal VFormula::getDoubleValue() const
{ {
return dValue; return d->dValue;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VFormula::getCheckZero() const bool VFormula::getCheckZero() const
{ {
return checkZero; return d->checkZero;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VFormula::setCheckZero(bool value) void VFormula::setCheckZero(bool value)
{ {
if (checkZero != value) d->checkZero = value;
{ ResetState();
checkZero = value; }
}
//---------------------------------------------------------------------------------------------------------------------
bool VFormula::getCheckLessThanZero() const
{
return d->checkLessThanZero;
}
//---------------------------------------------------------------------------------------------------------------------
void VFormula::setCheckLessThanZero(bool value)
{
d->checkLessThanZero = value;
ResetState();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
const VContainer *VFormula::getData() const const VContainer *VFormula::getData() const
{ {
return data; return d->data;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VFormula::setData(const VContainer *value) void VFormula::setData(const VContainer *value)
{ {
if (data != value && value != nullptr) if (d->data != value && value != nullptr)
{ {
data = value; d->data = value;
ResetState();
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
quint32 VFormula::getToolId() const quint32 VFormula::getToolId() const
{ {
return toolId; return d->toolId;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VFormula::setToolId(const quint32 &value) void VFormula::setToolId(quint32 value)
{ {
toolId = value; d->toolId = value;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VFormula::getPostfix() const QString VFormula::getPostfix() const
{ {
return postfix; return d->postfix;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VFormula::setPostfix(const QString &value) void VFormula::setPostfix(const QString &value)
{ {
if (postfix != value) d->postfix = value;
{
postfix = value;
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VFormula::error() const bool VFormula::error() const
{ {
return _error; return d->error;
}
//---------------------------------------------------------------------------------------------------------------------
QString VFormula::Reason() const
{
return d->reason;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -230,39 +219,64 @@ int VFormula::FormulaTypeId()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VFormula::Eval() void VFormula::Eval()
{ {
if (data == nullptr) ResetState();
if (d->data == nullptr)
{ {
d->reason = tr("Data container is empty");
return; return;
} }
value = tr("Error");
_error = true;
dValue = 0;
qreal result = 0; qreal result = 0;
if (not formula.isEmpty()) if (not d->formula.isEmpty())
{ {
try try
{ {
QScopedPointer<Calculator> cal(new Calculator()); QScopedPointer<Calculator> cal(new Calculator());
const QString expression = qApp->TrVars()->FormulaFromUser(formula, qApp->Settings()->GetOsSeparator()); result = cal->EvalFormula(d->data->DataVariables(), d->formula);
result = cal->EvalFormula(data->DataVariables(), expression);
} }
catch (qmu::QmuParserError &e) catch (qmu::QmuParserError &e)
{ {
qDebug() << "\nMath parser error:\n" d->reason = tr("Math parser error: %1").arg(e.GetMsg());
<< "--------------------------------------\n"
<< "Message: " << e.GetMsg() << "\n"
<< "Expression: " << e.GetExpr() << "\n"
<< "--------------------------------------";
return; return;
} }
if (not qIsInf(result) && not qIsNaN(result) && not (checkZero && qFuzzyIsNull(result))) d->dValue = result;
if (qIsInf(result))
{ {
dValue = result; d->reason = tr("Result is infinite");
value = qApp->LocaleToString(result) + QLatin1Char(' ') + postfix; }
_error = false; else if (qIsNaN(result))
{
d->reason = tr("Result is NaN");
}
else if (d->checkZero && qFuzzyIsNull(result))
{
d->reason = tr("Result is zero");
}
else if (d->checkLessThanZero && result < 0)
{
d->reason = tr("Result less than zero");
}
else
{
d->strValue = qApp->LocaleToString(result) + QLatin1Char(' ') + d->postfix;
d->error = false;
} }
} }
else
{
d->reason = tr("Formula is empty");
}
}
//---------------------------------------------------------------------------------------------------------------------
void VFormula::ResetState()
{
d->strValue = tr("Error");
d->error = true;
d->dValue = NAN;
d->reason = tr("Not evaluated");
} }

View File

@ -30,13 +30,16 @@
#define VFORMULA_H #define VFORMULA_H
#include <QCoreApplication> #include <QCoreApplication>
#include <QSharedDataPointer>
#include <QMetaType> #include <QMetaType>
#include <QTypeInfo>
#include <QString> #include <QString>
#include <QtGlobal> #include <QtGlobal>
enum class FormulaType : char{ToUser, FromUser}; enum class FormulaType : char{ToUser, FromUser};
class VContainer; class VContainer;
class VFormulaData;
class VFormula class VFormula
{ {
@ -46,6 +49,8 @@ public:
VFormula(const QString &formula, const VContainer *container); VFormula(const QString &formula, const VContainer *container);
VFormula &operator=(const VFormula &formula); VFormula &operator=(const VFormula &formula);
VFormula(const VFormula &formula); VFormula(const VFormula &formula);
~VFormula();
bool operator==(const VFormula &formula) const; bool operator==(const VFormula &formula) const;
bool operator!=(const VFormula &formula) const; bool operator!=(const VFormula &formula) const;
@ -58,30 +63,30 @@ public:
bool getCheckZero() const; bool getCheckZero() const;
void setCheckZero(bool value); void setCheckZero(bool value);
bool getCheckLessThanZero() const;
void setCheckLessThanZero(bool value);
const VContainer *getData() const; const VContainer *getData() const;
void setData(const VContainer *value); void setData(const VContainer *value);
quint32 getToolId() const; quint32 getToolId() const;
void setToolId(const quint32 &value); void setToolId(quint32 value);
QString getPostfix() const; QString getPostfix() const;
void setPostfix(const QString &value); void setPostfix(const QString &value);
bool error() const; bool error() const;
QString Reason() const;
static int FormulaTypeId(); static int FormulaTypeId();
void Eval(); void Eval();
private: private:
QString formula; QSharedDataPointer<VFormulaData> d;
QString value;
bool checkZero; void ResetState();
const VContainer *data;
quint32 toolId;
QString postfix;
bool _error;
qreal dValue;
}; };
Q_DECLARE_METATYPE(VFormula) Q_DECLARE_METATYPE(VFormula)
Q_DECLARE_TYPEINFO(VFormula, Q_MOVABLE_TYPE);
#endif // VFORMULA_H #endif // VFORMULA_H

View File

@ -0,0 +1,90 @@
/************************************************************************
**
** @file vformula_p.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @date 17 4, 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
** <https://bitbucket.org/dismine/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 VFORMULA_P_H
#define VFORMULA_P_H
#include "../vmisc/diagnostic.h"
#include "../vmisc/typedef.h"
#include "../vmisc/vmath.h"
#include <QSharedData>
#include <QCoreApplication>
class VContainer;
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Weffc++")
QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor")
class VFormulaData : public QSharedData
{
Q_DECLARE_TR_FUNCTIONS(VFormulaData)
public:
VFormulaData()
{}
VFormulaData(const QString &formula, const VContainer *container)
: formula(formula),
data(container),
reason(tr("Not evaluated"))
{}
VFormulaData (const VFormulaData& formula)
: QSharedData(formula),
formula(formula.formula),
strValue(formula.strValue),
checkZero(formula.checkZero),
checkLessThanZero(formula.checkLessThanZero),
data(formula.data),
toolId(formula.toolId),
postfix(formula.postfix),
error(formula.error),
dValue(formula.dValue),
reason(formula.reason)
{}
~VFormulaData() {}
QString formula{};
QString strValue{tr("Error")};
bool checkZero{true};
bool checkLessThanZero{false};
const VContainer *data{nullptr};
quint32 toolId{NULL_ID};
QString postfix{};
bool error{true};
qreal dValue{NAN};
QString reason{tr("Formula is empty")};
private:
VFormulaData &operator=(const VFormulaData &) Q_DECL_EQ_DELETE;
};
QT_WARNING_POP
#endif // VFORMULA_P_H

View File

@ -74,4 +74,5 @@ HEADERS += \
$$PWD/floatItemData/vpatternlabeldata_p.h \ $$PWD/floatItemData/vpatternlabeldata_p.h \
$$PWD/floatItemData/vpiecelabeldata_p.h \ $$PWD/floatItemData/vpiecelabeldata_p.h \
$$PWD/measurements.h \ $$PWD/measurements.h \
$$PWD/pmsystems.h $$PWD/pmsystems.h \
$$PWD/vformula_p.h

View File

@ -1365,6 +1365,11 @@ QVector<QLineF> VPiece::CreatePassmark(const QVector<VPieceNode> &path, int prev
const QVector<QPointF> mainPath = MainPathPoints(data); const QVector<QPointF> mainPath = MainPathPoints(data);
if (passmarkSAPoint.IsManualPasskmarkLength() && passmarkSAPoint.GetPasskmarkLength() <= 0)
{
return QVector<QLineF>();
}
if (not IsSeamAllowanceBuiltIn()) if (not IsSeamAllowanceBuiltIn())
{ {
// Because rollback cannot be calulated if passmark is not first point in main path we rotate it. // Because rollback cannot be calulated if passmark is not first point in main path we rotate it.
@ -1434,8 +1439,14 @@ QVector<QLineF> VPiece::SAPassmark(const VPiecePassmarkData &passmarkData, const
if (intersections.last() != passmarkData.passmarkSAPoint) if (intersections.last() != passmarkData.passmarkSAPoint)
{ {
line = QLineF(intersections.last(), passmarkData.passmarkSAPoint); line = QLineF(intersections.last(), passmarkData.passmarkSAPoint);
line.setLength(qMin(width * VSAPoint::passmarkFactor, VSAPoint::maxPassmarkLength)); if (not passmarkData.passmarkSAPoint.IsManualPasskmarkLength())
{
line.setLength(qMin(width * VSAPoint::passmarkFactor, VSAPoint::maxPassmarkLength));
}
else
{
line.setLength(passmarkData.passmarkSAPoint.GetPasskmarkLength());
}
passmarksLines += CreatePassmarkLines(passmarkData.passmarkLineType, passmarkData.passmarkAngleType, passmarksLines += CreatePassmarkLines(passmarkData.passmarkLineType, passmarkData.passmarkAngleType,
line, seamAllowance); line, seamAllowance);
} }

View File

@ -30,41 +30,12 @@
#include "vpiecenode_p.h" #include "vpiecenode_p.h"
#include "vcontainer.h" #include "vcontainer.h"
#include "calculator.h" #include "calculator.h"
#include "vformula.h"
#include "../vmisc/vabstractapplication.h"
#include <QDataStream> #include <QDataStream>
#include <QtNumeric> #include <QtNumeric>
namespace
{
//---------------------------------------------------------------------------------------------------------------------
qreal EvalFormula(const VContainer *data, QString formula)
{
if (formula.isEmpty())
{
return -1;
}
else
{
try
{
QScopedPointer<Calculator> cal(new Calculator());
const qreal result = cal->EvalFormula(data->DataVariables(), formula);
if (qIsInf(result) || qIsNaN(result))
{
return -1;
}
return result;
}
catch (qmu::QmuParserError &e)
{
Q_UNUSED(e)
return -1;
}
}
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VPieceNode::VPieceNode() VPieceNode::VPieceNode()
: d(new VPieceNodeData) : d(new VPieceNodeData)
@ -157,7 +128,25 @@ qreal VPieceNode::GetSABefore(const VContainer *data) const
return -1; return -1;
} }
return EvalFormula(data, d->m_formulaWidthBefore); VFormula formula(d->m_formulaWidthBefore, data);
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());
qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg;
return -1;
}
return formula.getDoubleValue();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -168,7 +157,26 @@ qreal VPieceNode::GetSABefore(const VContainer *data, Unit unit) const
return -1; return -1;
} }
qreal value = EvalFormula(data, d->m_formulaWidthBefore); VFormula formula(d->m_formulaWidthBefore, data);
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());
qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg;
return -1;
}
qreal value = formula.getDoubleValue();
if (value >= 0) if (value >= 0)
{ {
value = ToPixel(value, unit); value = ToPixel(value, unit);
@ -199,7 +207,26 @@ qreal VPieceNode::GetSAAfter(const VContainer *data) const
return -1; return -1;
} }
return EvalFormula(data, d->m_formulaWidthAfter); VFormula formula(d->m_formulaWidthAfter, data);
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());
qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg;
return -1;
}
return formula.getDoubleValue();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -210,7 +237,27 @@ qreal VPieceNode::GetSAAfter(const VContainer *data, Unit unit) const
return -1; return -1;
} }
qreal value = EvalFormula(data, d->m_formulaWidthAfter); VFormula formula(d->m_formulaWidthAfter, data);
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: ")
.arg(nodeName, formula.Reason());
qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg;
return -1;
}
qreal value = formula.getDoubleValue();
if (value >= 0) if (value >= 0)
{ {
value = ToPixel(value, unit); value = ToPixel(value, unit);
@ -233,6 +280,52 @@ void VPieceNode::SetFormulaSAAfter(const QString &formula)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
QString VPieceNode::GetFormulaPassmarkLength() const
{
return d->m_formulaPassmarkLength;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceNode::SetFormulaPassmarkLength(const QString &formula)
{
if (d->m_typeTool == Tool::NodePoint)
{
d->m_formulaPassmarkLength = formula;
}
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPieceNode::GetPassmarkLength(const VContainer *data, Unit unit) const
{
if (d->m_manualPassmarkLength)
{
VFormula formula(d->m_formulaPassmarkLength, 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 length for point '%1'. Reason: %2.")
.arg(nodeName, formula.Reason());
qApp->IsPedantic() ? throw VException(errorMsg) : qWarning() << errorMsg;
return VSAPoint::maxPassmarkLength;
}
return ToPixel(formula.getDoubleValue(), unit);
}
return -1;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
PieceNodeAngle VPieceNode::GetAngleType() const PieceNodeAngle VPieceNode::GetAngleType() const
{ {
@ -323,6 +416,18 @@ void VPieceNode::SetCheckUniqueness(bool value)
d->m_checkUniqueness = (d->m_typeTool == Tool::NodePoint ? value : true); d->m_checkUniqueness = (d->m_typeTool == Tool::NodePoint ? value : true);
} }
//---------------------------------------------------------------------------------------------------------------------
bool VPieceNode::IsManualPassmarkLength() const
{
return d->m_manualPassmarkLength;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceNode::SetManualPassmarkLength(bool value)
{
d->m_manualPassmarkLength = value;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
bool VPieceNode::IsExcluded() const bool VPieceNode::IsExcluded() const
{ {

View File

@ -82,6 +82,11 @@ public:
QString GetFormulaSAAfter() const; QString GetFormulaSAAfter() const;
void SetFormulaSAAfter(const QString &formula); void SetFormulaSAAfter(const QString &formula);
QString GetFormulaPassmarkLength() const;
void SetFormulaPassmarkLength(const QString &formula);
qreal GetPassmarkLength(const VContainer *data, Unit unit) const;
PieceNodeAngle GetAngleType() const; PieceNodeAngle GetAngleType() const;
void SetAngleType(PieceNodeAngle type); void SetAngleType(PieceNodeAngle type);
@ -102,6 +107,9 @@ public:
bool IsCheckUniqueness() const; bool IsCheckUniqueness() const;
void SetCheckUniqueness(bool value); void SetCheckUniqueness(bool value);
bool IsManualPassmarkLength() const;
void SetManualPassmarkLength(bool value);
private: private:
QSharedDataPointer<VPieceNodeData> d; QSharedDataPointer<VPieceNodeData> d;
}; };

View File

@ -89,11 +89,13 @@ public:
m_isMainPathNode(node.m_isMainPathNode), m_isMainPathNode(node.m_isMainPathNode),
m_formulaWidthBefore(node.m_formulaWidthBefore), m_formulaWidthBefore(node.m_formulaWidthBefore),
m_formulaWidthAfter(node.m_formulaWidthAfter), m_formulaWidthAfter(node.m_formulaWidthAfter),
m_formulaPassmarkLength(node.m_formulaPassmarkLength),
m_angleType(node.m_angleType), m_angleType(node.m_angleType),
m_passmarkLineType(node.m_passmarkLineType), m_passmarkLineType(node.m_passmarkLineType),
m_passmarkAngleType(node.m_passmarkAngleType), m_passmarkAngleType(node.m_passmarkAngleType),
m_isShowSecondPassmark(node.m_isShowSecondPassmark), m_isShowSecondPassmark(node.m_isShowSecondPassmark),
m_checkUniqueness(node.m_checkUniqueness) m_checkUniqueness(node.m_checkUniqueness),
m_manualPassmarkLength(node.m_manualPassmarkLength)
{} {}
~VPieceNodeData() Q_DECL_EQ_DEFAULT; ~VPieceNodeData() Q_DECL_EQ_DEFAULT;
@ -122,6 +124,7 @@ public:
QString m_formulaWidthBefore; QString m_formulaWidthBefore;
QString m_formulaWidthAfter; QString m_formulaWidthAfter;
QString m_formulaPassmarkLength{};
PieceNodeAngle m_angleType; PieceNodeAngle m_angleType;
@ -135,6 +138,8 @@ public:
* gradation change a piece shape and the seond point should be remaind.*/ * gradation change a piece shape and the seond point should be remaind.*/
bool m_checkUniqueness; bool m_checkUniqueness;
bool m_manualPassmarkLength{false};
private: private:
VPieceNodeData &operator=(const VPieceNodeData &) Q_DECL_EQ_DELETE; VPieceNodeData &operator=(const VPieceNodeData &) Q_DECL_EQ_DELETE;
}; };

View File

@ -1059,6 +1059,8 @@ VSAPoint VPiecePath::PreparePointEkv(const VPieceNode &node, const VContainer *d
p.SetSAAfter(node.GetSAAfter(data, *data->GetPatternUnit())); p.SetSAAfter(node.GetSAAfter(data, *data->GetPatternUnit()));
p.SetSABefore(node.GetSABefore(data, *data->GetPatternUnit())); p.SetSABefore(node.GetSABefore(data, *data->GetPatternUnit()));
p.SetAngleType(node.GetAngleType()); p.SetAngleType(node.GetAngleType());
p.SetManualPasskmarkLength(node.IsManualPassmarkLength());
p.SetPasskmarkLength(node.GetPassmarkLength(data, *data->GetPatternUnit()));
return p; return p;
} }

View File

@ -63,6 +63,7 @@ DialogPiecePath::DialogPiecePath(const VContainer *data, quint32 toolId, QWidget
m_timerWidthBefore(new QTimer(this)), m_timerWidthBefore(new QTimer(this)),
m_timerWidthAfter(new QTimer(this)), m_timerWidthAfter(new QTimer(this)),
m_timerVisible(new QTimer(this)), m_timerVisible(new QTimer(this)),
m_timerPassmarkLength(new QTimer(this)),
m_formulaBaseWidth(0), m_formulaBaseWidth(0),
m_formulaBaseWidthBefore(0), m_formulaBaseWidthBefore(0),
m_formulaBaseWidthAfter(0), m_formulaBaseWidthAfter(0),
@ -225,6 +226,7 @@ void DialogPiecePath::CheckState()
m_flagFormula = true; m_flagFormula = true;
m_flagFormulaBefore = true; m_flagFormulaBefore = true;
m_flagFormulaAfter = true; m_flagFormulaAfter = true;
m_flagFormulaPassmarkLength = true;
} }
else else
{ {
@ -234,6 +236,7 @@ void DialogPiecePath::CheckState()
m_flagFormula = true; m_flagFormula = true;
m_flagFormulaBefore = true; m_flagFormulaBefore = true;
m_flagFormulaAfter = true; m_flagFormulaAfter = true;
m_flagFormulaPassmarkLength = true;
} }
} }
@ -251,6 +254,8 @@ void DialogPiecePath::CheckState()
ui->tabWidget->setTabIcon(tabSeamAllowanceIndex, icon); ui->tabWidget->setTabIcon(tabSeamAllowanceIndex, icon);
} }
ui->comboBoxNodes->setEnabled(m_flagFormulaBefore && m_flagFormulaAfter);
const int tabControlIndex = ui->tabWidget->indexOf(ui->tabControl); const int tabControlIndex = ui->tabWidget->indexOf(ui->tabControl);
if (m_flagFormulaVisible) if (m_flagFormulaVisible)
{ {
@ -262,6 +267,25 @@ void DialogPiecePath::CheckState()
QIcon(":/icons/win.icon.theme/16x16/status/dialog-warning.png")); QIcon(":/icons/win.icon.theme/16x16/status/dialog-warning.png"));
ui->tabWidget->setTabIcon(tabControlIndex, icon); ui->tabWidget->setTabIcon(tabControlIndex, icon);
} }
if (ui->comboBoxPassmarks->count() == 0)
{
m_flagFormulaPassmarkLength = true;
}
const int tabPassmarksIndex = ui->tabWidget->indexOf(ui->tabPassmarks);
if (m_flagFormulaPassmarkLength)
{
ui->tabWidget->setTabIcon(tabPassmarksIndex, QIcon());
}
else
{
const QIcon icon = QIcon::fromTheme("dialog-warning",
QIcon(":/icons/win.icon.theme/16x16/status/dialog-warning.png"));
ui->tabWidget->setTabIcon(tabPassmarksIndex, icon);
}
ui->comboBoxPassmarks->setEnabled(m_flagFormulaPassmarkLength);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -286,6 +310,7 @@ void DialogPiecePath::closeEvent(QCloseEvent *event)
ui->plainTextEditFormulaWidthBefore->blockSignals(true); ui->plainTextEditFormulaWidthBefore->blockSignals(true);
ui->plainTextEditFormulaWidthAfter->blockSignals(true); ui->plainTextEditFormulaWidthAfter->blockSignals(true);
ui->plainTextEditFormulaVisible->blockSignals(true); ui->plainTextEditFormulaVisible->blockSignals(true);
ui->plainTextEditPassmarkLength->blockSignals(true);
DialogTool::closeEvent(event); DialogTool::closeEvent(event);
} }
@ -483,28 +508,19 @@ void DialogPiecePath::NodeChanged(int index)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::PassmarkChanged(int index) void DialogPiecePath::PassmarkChanged(int index)
{ {
ui->radioButtonOneLine->setDisabled(true); ui->groupBoxMarkType->setDisabled(true);
ui->radioButtonTwoLines->setDisabled(true); ui->groupBoxAngleType->setDisabled(true);
ui->radioButtonThreeLines->setDisabled(true); ui->groupBoxManualLength->setDisabled(true);
ui->radioButtonTMark->setDisabled(true);
ui->radioButtonVMark->setDisabled(true);
ui->radioButtonVMark2->setDisabled(true);
ui->radioButtonStraightforward->setDisabled(true);
ui->radioButtonBisector->setDisabled(true);
ui->radioButtonIntersection->setDisabled(true);
ui->radioButtonIntersectionOnlyLeft->setDisabled(true);
ui->radioButtonIntersectionOnlyRight->setDisabled(true);
ui->radioButtonIntersection2->setDisabled(true);
ui->radioButtonIntersection2OnlyLeft->setDisabled(true);
ui->radioButtonIntersection2OnlyRight->setDisabled(true);
ui->checkBoxShowSecondPassmark->setDisabled(true); ui->checkBoxShowSecondPassmark->setDisabled(true);
ui->checkBoxShowSecondPassmark->blockSignals(true); ui->checkBoxShowSecondPassmark->blockSignals(true);
ui->groupBoxManualLength->blockSignals(true);
ui->groupBoxMarkType->blockSignals(true); ui->groupBoxMarkType->blockSignals(true);
ui->groupBoxAngleType->blockSignals(true); ui->groupBoxAngleType->blockSignals(true);
ui->groupBoxManualLength->setChecked(false);
if (index != -1) if (index != -1)
{ {
const VPiecePath path = CreatePath(); const VPiecePath path = CreatePath();
@ -513,13 +529,40 @@ void DialogPiecePath::PassmarkChanged(int index)
{ {
const VPieceNode &node = path.at(nodeIndex); const VPieceNode &node = path.at(nodeIndex);
// Passmark length
ui->groupBoxManualLength->setEnabled(true);
if (node.IsManualPassmarkLength())
{
ui->groupBoxManualLength->setChecked(true);
QString passmarkLength = node.GetFormulaPassmarkLength();
passmarkLength = qApp->TrVars()->FormulaToUser(passmarkLength, qApp->Settings()->GetOsSeparator());
if (passmarkLength.length() > 80)// increase height if needed.
{
this->DeployPassmarkLength();
}
if (passmarkLength.isEmpty())
{
qreal length = UnitConvertor(1, Unit::Cm, qApp->patternUnit());
ui->plainTextEditPassmarkLength->setPlainText(qApp->LocaleToString(length));
}
else
{
ui->plainTextEditPassmarkLength->setPlainText(passmarkLength);
}
}
else
{
qreal length = UnitConvertor(1, Unit::Cm, qApp->patternUnit());
ui->plainTextEditPassmarkLength->setPlainText(qApp->LocaleToString(length));
}
MoveCursorToEnd(ui->plainTextEditPassmarkLength);
// Line type // Line type
ui->radioButtonOneLine->setEnabled(true); ui->groupBoxMarkType->setEnabled(true);
ui->radioButtonTwoLines->setEnabled(true);
ui->radioButtonThreeLines->setEnabled(true);
ui->radioButtonTMark->setEnabled(true);
ui->radioButtonVMark->setEnabled(true);
ui->radioButtonVMark2->setEnabled(true);
switch(node.GetPassmarkLineType()) switch(node.GetPassmarkLineType())
{ {
@ -546,14 +589,7 @@ void DialogPiecePath::PassmarkChanged(int index)
} }
// Angle type // Angle type
ui->radioButtonStraightforward->setEnabled(true); ui->groupBoxAngleType->setEnabled(true);
ui->radioButtonBisector->setEnabled(true);
ui->radioButtonIntersection->setEnabled(true);
ui->radioButtonIntersectionOnlyLeft->setEnabled(true);
ui->radioButtonIntersectionOnlyRight->setEnabled(true);
ui->radioButtonIntersection2->setEnabled(true);
ui->radioButtonIntersection2OnlyLeft->setEnabled(true);
ui->radioButtonIntersection2OnlyRight->setEnabled(true);
switch(node.GetPassmarkAngleType()) switch(node.GetPassmarkAngleType())
{ {
@ -593,6 +629,7 @@ void DialogPiecePath::PassmarkChanged(int index)
ui->checkBoxShowSecondPassmark->blockSignals(false); ui->checkBoxShowSecondPassmark->blockSignals(false);
ui->groupBoxManualLength->blockSignals(false);
ui->groupBoxMarkType->blockSignals(false); ui->groupBoxMarkType->blockSignals(false);
ui->groupBoxAngleType->blockSignals(false); ui->groupBoxAngleType->blockSignals(false);
} }
@ -851,6 +888,24 @@ void DialogPiecePath::EvalVisible()
Eval(formulaData, m_flagFormulaVisible); Eval(formulaData, m_flagFormulaVisible);
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::EvalPassmarkLength()
{
FormulaData formulaData;
formulaData.formula = ui->plainTextEditPassmarkLength->toPlainText();
formulaData.variables = data->DataVariables();
formulaData.labelEditFormula = ui->labelEditPassmarkLength;
formulaData.labelResult = ui->labelResultPassmarkLength;
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
formulaData.checkZero = false;
formulaData.checkLessThanZero = false;
Eval(formulaData, m_flagFormulaPassmarkLength);
UpdateNodePassmarkLength(qApp->TrVars()->TryFormulaFromUser(ui->plainTextEditPassmarkLength->toPlainText(),
qApp->Settings()->GetOsSeparator()));
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::FXWidth() void DialogPiecePath::FXWidth()
{ {
@ -905,6 +960,19 @@ void DialogPiecePath::FXVisible()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::FXPassmarkLength()
{
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
dialog->setWindowTitle(tr("Edit passmark length"));
dialog->SetFormula(GetFormulaPassmarkLength());
dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted)
{
SetFormulaPassmarkLength(dialog->GetFormula());
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::DeployWidthFormulaTextEdit() void DialogPiecePath::DeployWidthFormulaTextEdit()
{ {
@ -929,6 +997,12 @@ void DialogPiecePath::DeployVisibleFormulaTextEdit()
DeployFormula(this, ui->plainTextEditFormulaVisible, ui->pushButtonGrowVisible, m_formulaBaseVisible); DeployFormula(this, ui->plainTextEditFormulaVisible, ui->pushButtonGrowVisible, m_formulaBaseVisible);
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::DeployPassmarkLength()
{
DeployFormula(this, ui->plainTextEditPassmarkLength, ui->pushButtonGrowPassmarkLength, m_formulaBasePassmarkLength);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::SetMoveControls() void DialogPiecePath::SetMoveControls()
{ {
@ -1054,6 +1128,14 @@ void DialogPiecePath::InitSeamAllowanceTab()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::InitPassmarksTab() void DialogPiecePath::InitPassmarksTab()
{ {
this->m_formulaBasePassmarkLength = ui->plainTextEditPassmarkLength->height();
ui->plainTextEditPassmarkLength->installEventFilter(this);
m_timerPassmarkLength->setSingleShot(true);
connect(m_timerPassmarkLength, &QTimer::timeout, this, &DialogPiecePath::EvalPassmarkLength);
connect(ui->groupBoxManualLength, &QGroupBox::toggled, this, &DialogPiecePath::EnabledManualPassmarkLength);
InitPassmarksList(); InitPassmarksList();
connect(ui->comboBoxPassmarks, QOverload<int>::of(&QComboBox::currentIndexChanged), connect(ui->comboBoxPassmarks, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &DialogPiecePath::PassmarkChanged); this, &DialogPiecePath::PassmarkChanged);
@ -1064,6 +1146,14 @@ void DialogPiecePath::InitPassmarksTab()
this, &DialogPiecePath::PassmarkAngleTypeChanged); this, &DialogPiecePath::PassmarkAngleTypeChanged);
connect(ui->checkBoxShowSecondPassmark, &QCheckBox::stateChanged, this, connect(ui->checkBoxShowSecondPassmark, &QCheckBox::stateChanged, this,
&DialogPiecePath::PassmarkShowSecondChanged); &DialogPiecePath::PassmarkShowSecondChanged);
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogPiecePath::FXPassmarkLength);
connect(ui->plainTextEditPassmarkLength, &QPlainTextEdit::textChanged, this, [this]()
{
m_timerPassmarkLength->start(formulaTimerTimeout);
});
connect(ui->pushButtonGrowPassmarkLength, &QPushButton::clicked, this, &DialogPiecePath::DeployPassmarkLength);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -1348,6 +1438,39 @@ void DialogPiecePath::UpdateNodeSAAfter(const QString &formula)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::UpdateNodePassmarkLength(const QString &formula)
{
const int index = ui->comboBoxPassmarks->currentIndex();
if (index != -1)
{
QListWidgetItem *rowItem = GetItemById(ui->comboBoxPassmarks->currentData().toUInt());
if (rowItem)
{
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
rowNode.SetFormulaPassmarkLength(formula);
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::EnabledManualPassmarkLength()
{
const int index = ui->comboBoxPassmarks->currentIndex();
if (index != -1)
{
QListWidgetItem *rowItem = GetItemById(ui->comboBoxPassmarks->currentData().toUInt());
if (rowItem)
{
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
rowNode.SetManualPassmarkLength(ui->groupBoxManualLength->isChecked());
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
EvalPassmarkLength();
}
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::SetFormulaSAWidth(const QString &formula) void DialogPiecePath::SetFormulaSAWidth(const QString &formula)
{ {
@ -1553,6 +1676,26 @@ void DialogPiecePath::SetFormulaVisible(const QString &formula)
MoveCursorToEnd(ui->plainTextEditFormulaVisible); MoveCursorToEnd(ui->plainTextEditFormulaVisible);
} }
//---------------------------------------------------------------------------------------------------------------------
QString DialogPiecePath::GetFormulaPassmarkLength() const
{
QString formula = ui->plainTextEditPassmarkLength->toPlainText();
return qApp->TrVars()->TryFormulaFromUser(formula, qApp->Settings()->GetOsSeparator());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::SetFormulaPassmarkLength(const QString &formula)
{
const QString f = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator());
// increase height if needed.
if (f.length() > 80)
{
this->DeployPassmarkLength();
}
ui->plainTextEditPassmarkLength->setPlainText(f);
MoveCursorToEnd(ui->plainTextEditPassmarkLength);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::RefreshPathList(const VPiecePath &path) void DialogPiecePath::RefreshPathList(const VPiecePath &path)
{ {

View File

@ -83,16 +83,19 @@ private slots:
void EvalWidthBefore(); void EvalWidthBefore();
void EvalWidthAfter(); void EvalWidthAfter();
void EvalVisible(); void EvalVisible();
void EvalPassmarkLength();
void FXWidth(); void FXWidth();
void FXWidthBefore(); void FXWidthBefore();
void FXWidthAfter(); void FXWidthAfter();
void FXVisible(); void FXVisible();
void FXPassmarkLength();
void DeployWidthFormulaTextEdit(); void DeployWidthFormulaTextEdit();
void DeployWidthBeforeFormulaTextEdit(); void DeployWidthBeforeFormulaTextEdit();
void DeployWidthAfterFormulaTextEdit(); void DeployWidthAfterFormulaTextEdit();
void DeployVisibleFormulaTextEdit(); void DeployVisibleFormulaTextEdit();
void DeployPassmarkLength();
void SetMoveControls(); void SetMoveControls();
@ -106,15 +109,18 @@ private:
QTimer *m_timerWidthBefore; QTimer *m_timerWidthBefore;
QTimer *m_timerWidthAfter; QTimer *m_timerWidthAfter;
QTimer *m_timerVisible; QTimer *m_timerVisible;
QTimer *m_timerPassmarkLength;
int m_formulaBaseWidth; int m_formulaBaseWidth;
int m_formulaBaseWidthBefore; int m_formulaBaseWidthBefore;
int m_formulaBaseWidthAfter; int m_formulaBaseWidthAfter;
int m_formulaBaseVisible; int m_formulaBaseVisible;
int m_formulaBasePassmarkLength{0};
bool m_flagFormulaBefore; bool m_flagFormulaBefore;
bool m_flagFormulaAfter; bool m_flagFormulaAfter;
bool m_flagFormulaVisible; bool m_flagFormulaVisible;
bool m_flagFormulaPassmarkLength{true};
bool m_flagName; bool m_flagName;
bool m_flagError; bool m_flagError;
bool m_flagFormula; bool m_flagFormula;
@ -152,6 +158,9 @@ private:
void UpdateNodeSABefore(const QString &formula); void UpdateNodeSABefore(const QString &formula);
void UpdateNodeSAAfter(const QString &formula); void UpdateNodeSAAfter(const QString &formula);
void UpdateNodePassmarkLength(const QString &formula);
void EnabledManualPassmarkLength();
QString GetFormulaSAWidthBefore() const; QString GetFormulaSAWidthBefore() const;
QString GetFormulaSAWidthAfter() const; QString GetFormulaSAWidthAfter() const;
@ -159,6 +168,9 @@ private:
QString GetFormulaVisible() const; QString GetFormulaVisible() const;
void SetFormulaVisible(const QString &formula); void SetFormulaVisible(const QString &formula);
QString GetFormulaPassmarkLength() const;
void SetFormulaPassmarkLength(const QString &formula);
bool IsShowNotch() const; bool IsShowNotch() const;
void RefreshPathList(const VPiecePath &path); void RefreshPathList(const VPiecePath &path);
@ -168,7 +180,7 @@ private:
inline bool DialogPiecePath::IsValid() const inline bool DialogPiecePath::IsValid() const
{ {
return m_flagName && m_flagError && m_flagFormula && m_flagFormulaBefore && m_flagFormulaAfter return m_flagName && m_flagError && m_flagFormula && m_flagFormulaBefore && m_flagFormulaAfter
&& m_flagFormulaVisible; && m_flagFormulaVisible && m_flagFormulaPassmarkLength;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>436</width> <width>394</width>
<height>627</height> <height>583</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -908,7 +908,7 @@
<attribute name="title"> <attribute name="title">
<string>Passmarks</string> <string>Passmarks</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_8">
<item> <item>
<layout class="QFormLayout" name="formLayout_2"> <layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy"> <property name="fieldGrowthPolicy">
@ -927,236 +927,466 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBoxMarkType"> <widget class="QGroupBox" name="groupBoxManualLength">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="title"> <property name="title">
<string>Marks</string> <string>Manual length</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_6"> <property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item> <item>
<widget class="QRadioButton" name="radioButtonOneLine"> <layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="enabled"> <item alignment="Qt::AlignLeft">
<bool>false</bool> <widget class="QLabel" name="labelEditPassmarkLength">
</property> <property name="sizePolicy">
<property name="text"> <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<string>One line</string> <horstretch>0</horstretch>
</property> <verstretch>0</verstretch>
<attribute name="buttonGroup"> </sizepolicy>
<string notr="true">buttonGroupMarkType</string> </property>
</attribute> <property name="palette">
</widget> <palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Length:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignRight">
<widget class="QToolButton" name="toolButtonExprLength">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Formula wizard</string>
</property>
<property name="text">
<string notr="true">f(x)</string>
</property>
<property name="icon">
<iconset resource="../../../../vmisc/share/resources/icon.qrc">
<normaloff>:/icon/24x24/fx.png</normaloff>:/icon/24x24/fx.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>36</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>=</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="labelResultPassmarkLength">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>87</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Value</string>
</property>
<property name="whatsThis">
<string notr="true"/>
</property>
<property name="text">
<string notr="true">_</string>
</property>
</widget>
</item>
</layout>
</item> </item>
<item> <item>
<widget class="QRadioButton" name="radioButtonTwoLines"> <layout class="QHBoxLayout" name="horizontalLayout_10">
<property name="enabled"> <item>
<bool>false</bool> <widget class="VPlainTextEdit" name="plainTextEditPassmarkLength">
</property> <property name="enabled">
<property name="text"> <bool>true</bool>
<string>Two lines</string> </property>
</property> <property name="sizePolicy">
<attribute name="buttonGroup"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<string notr="true">buttonGroupMarkType</string> <horstretch>0</horstretch>
</attribute> <verstretch>0</verstretch>
</widget> </sizepolicy>
</item> </property>
<item> <property name="maximumSize">
<widget class="QRadioButton" name="radioButtonThreeLines"> <size>
<property name="enabled"> <width>16777215</width>
<bool>false</bool> <height>28</height>
</property> </size>
<property name="text"> </property>
<string>Three lines</string> <property name="toolTip">
</property> <string>Calculation</string>
<attribute name="buttonGroup"> </property>
<string notr="true">buttonGroupMarkType</string> <property name="tabChangesFocus">
</attribute> <bool>true</bool>
</widget> </property>
</item> </widget>
<item> </item>
<widget class="QRadioButton" name="radioButtonTMark"> <item>
<property name="enabled"> <widget class="QPushButton" name="pushButtonGrowPassmarkLength">
<bool>false</bool> <property name="enabled">
</property> <bool>true</bool>
<property name="text"> </property>
<string>T mark</string> <property name="maximumSize">
</property> <size>
<attribute name="buttonGroup"> <width>18</width>
<string notr="true">buttonGroupMarkType</string> <height>18</height>
</attribute> </size>
</widget> </property>
</item> <property name="sizeIncrement">
<item> <size>
<widget class="QRadioButton" name="radioButtonVMark"> <width>0</width>
<property name="enabled"> <height>0</height>
<bool>false</bool> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Acute angle that looks inside of piece</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Show full calculation in message box&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>V mark</string> <string notr="true"/>
</property> </property>
<attribute name="buttonGroup"> <property name="icon">
<string notr="true">buttonGroupMarkType</string> <iconset theme="go-down">
</attribute> <normaloff>../</normaloff>../</iconset>
</widget> </property>
</item> <property name="iconSize">
<item> <size>
<widget class="QRadioButton" name="radioButtonVMark2"> <width>16</width>
<property name="enabled"> <height>16</height>
<bool>false</bool> </size>
</property> </property>
<property name="toolTip"> <property name="flat">
<string>Acute angle that looks outside of piece</string> <bool>true</bool>
</property> </property>
<property name="text"> </widget>
<string>V mark 2</string> </item>
</property> </layout>
<attribute name="buttonGroup">
<string notr="true">buttonGroupMarkType</string>
</attribute>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBoxAngleType"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="title"> <item>
<string>Angle</string> <widget class="QGroupBox" name="groupBoxMarkType">
</property> <property name="enabled">
<layout class="QVBoxLayout" name="verticalLayout_5"> <bool>true</bool>
<item> </property>
<widget class="QRadioButton" name="radioButtonStraightforward"> <property name="title">
<property name="enabled"> <string>Marks</string>
<bool>false</bool> </property>
</property> <layout class="QVBoxLayout" name="verticalLayout_6">
<property name="text"> <item>
<string>Straightforward</string> <widget class="QRadioButton" name="radioButtonOneLine">
</property> <property name="enabled">
<attribute name="buttonGroup"> <bool>true</bool>
<string notr="true">buttonGroupAngleType</string> </property>
</attribute> <property name="text">
</widget> <string>One line</string>
</item> </property>
<item> <attribute name="buttonGroup">
<widget class="QRadioButton" name="radioButtonBisector"> <string notr="true">buttonGroupMarkType</string>
<property name="enabled"> </attribute>
<bool>false</bool> </widget>
</property> </item>
<property name="text"> <item>
<string>Bisector</string> <widget class="QRadioButton" name="radioButtonTwoLines">
</property> <property name="enabled">
<attribute name="buttonGroup"> <bool>true</bool>
<string notr="true">buttonGroupAngleType</string> </property>
</attribute> <property name="text">
</widget> <string>Two lines</string>
</item> </property>
<item> <attribute name="buttonGroup">
<widget class="QRadioButton" name="radioButtonIntersection"> <string notr="true">buttonGroupMarkType</string>
<property name="enabled"> </attribute>
<bool>false</bool> </widget>
</property> </item>
<property name="toolTip"> <item>
<string>Select if need designate the corner point as a passmark</string> <widget class="QRadioButton" name="radioButtonThreeLines">
</property> <property name="enabled">
<property name="text"> <bool>true</bool>
<string>Intersection</string> </property>
</property> <property name="text">
<attribute name="buttonGroup"> <string>Three lines</string>
<string notr="true">buttonGroupAngleType</string> </property>
</attribute> <attribute name="buttonGroup">
</widget> <string notr="true">buttonGroupMarkType</string>
</item> </attribute>
<item> </widget>
<widget class="QRadioButton" name="radioButtonIntersectionOnlyLeft"> </item>
<property name="enabled"> <item>
<bool>false</bool> <widget class="QRadioButton" name="radioButtonTMark">
</property> <property name="enabled">
<property name="toolTip"> <bool>true</bool>
<string>Select if need designate the corner point as a passmark. Show only left passmark.</string> </property>
</property> <property name="text">
<property name="text"> <string>T mark</string>
<string>Intersection (only left)</string> </property>
</property> <attribute name="buttonGroup">
<attribute name="buttonGroup"> <string notr="true">buttonGroupMarkType</string>
<string notr="true">buttonGroupAngleType</string> </attribute>
</attribute> </widget>
</widget> </item>
</item> <item>
<item> <widget class="QRadioButton" name="radioButtonVMark">
<widget class="QRadioButton" name="radioButtonIntersectionOnlyRight"> <property name="enabled">
<property name="enabled"> <bool>true</bool>
<bool>false</bool> </property>
</property> <property name="toolTip">
<property name="toolTip"> <string>Acute angle that looks inside of piece</string>
<string>Select if need designate the corner point as a passmark. Show only right passmark.</string> </property>
</property> <property name="text">
<property name="text"> <string>V mark</string>
<string>Intersection (only right)</string> </property>
</property> <attribute name="buttonGroup">
<attribute name="buttonGroup"> <string notr="true">buttonGroupMarkType</string>
<string notr="true">buttonGroupAngleType</string> </attribute>
</attribute> </widget>
</widget> </item>
</item> <item>
<item> <widget class="QRadioButton" name="radioButtonVMark2">
<widget class="QRadioButton" name="radioButtonIntersection2"> <property name="enabled">
<property name="enabled"> <bool>true</bool>
<bool>false</bool> </property>
</property> <property name="toolTip">
<property name="toolTip"> <string>Acute angle that looks outside of piece</string>
<string>Select if need designate the corner point as a passmark</string> </property>
</property> <property name="text">
<property name="text"> <string>V mark 2</string>
<string>Intersection 2</string> </property>
</property> <attribute name="buttonGroup">
<attribute name="buttonGroup"> <string notr="true">buttonGroupMarkType</string>
<string notr="true">buttonGroupAngleType</string> </attribute>
</attribute> </widget>
</widget> </item>
</item> </layout>
<item> </widget>
<widget class="QRadioButton" name="radioButtonIntersection2OnlyLeft"> </item>
<property name="enabled"> <item>
<bool>false</bool> <widget class="QGroupBox" name="groupBoxAngleType">
</property> <property name="enabled">
<property name="toolTip"> <bool>true</bool>
<string>Select if need designate the corner point as a passmark. Show only left passmark.</string> </property>
</property> <property name="title">
<property name="text"> <string>Angle</string>
<string>Intersection 2 (only left)</string> </property>
</property> <layout class="QVBoxLayout" name="verticalLayout_5">
<attribute name="buttonGroup"> <item>
<string notr="true">buttonGroupAngleType</string> <widget class="QRadioButton" name="radioButtonStraightforward">
</attribute> <property name="enabled">
</widget> <bool>true</bool>
</item> </property>
<item> <property name="text">
<widget class="QRadioButton" name="radioButtonIntersection2OnlyRight"> <string>Straightforward</string>
<property name="enabled"> </property>
<bool>false</bool> <attribute name="buttonGroup">
</property> <string notr="true">buttonGroupAngleType</string>
<property name="toolTip"> </attribute>
<string>Select if need designate the corner point as a passmark. Show only right passmark.</string> </widget>
</property> </item>
<property name="text"> <item>
<string>Intersection 2 (only right)</string> <widget class="QRadioButton" name="radioButtonBisector">
</property> <property name="enabled">
<attribute name="buttonGroup"> <bool>true</bool>
<string notr="true">buttonGroupAngleType</string> </property>
</attribute> <property name="text">
</widget> <string>Bisector</string>
</item> </property>
</layout> <attribute name="buttonGroup">
</widget> <string notr="true">buttonGroupAngleType</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonIntersection">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Select if need designate the corner point as a passmark</string>
</property>
<property name="text">
<string>Intersection</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroupAngleType</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonIntersectionOnlyLeft">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Select if need designate the corner point as a passmark. Show only left passmark.</string>
</property>
<property name="text">
<string>Intersection (only left)</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroupAngleType</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonIntersectionOnlyRight">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Select if need designate the corner point as a passmark. Show only right passmark.</string>
</property>
<property name="text">
<string>Intersection (only right)</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroupAngleType</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonIntersection2">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Select if need designate the corner point as a passmark</string>
</property>
<property name="text">
<string>Intersection 2</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroupAngleType</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonIntersection2OnlyLeft">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Select if need designate the corner point as a passmark. Show only left passmark.</string>
</property>
<property name="text">
<string>Intersection 2 (only left)</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroupAngleType</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonIntersection2OnlyRight">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Select if need designate the corner point as a passmark. Show only right passmark.</string>
</property>
<property name="text">
<string>Intersection 2 (only right)</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroupAngleType</string>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkBoxShowSecondPassmark"> <widget class="QCheckBox" name="checkBoxShowSecondPassmark">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>This option has effect only if the second passmark on seam line enabled in global preferences. The option helps disable the second passmark for this passmark only.</string> <string>This option has effect only if the second passmark on seam line enabled in global preferences. The option helps disable the second passmark for this passmark only.</string>
@ -1422,8 +1652,8 @@
<slot>accept()</slot> <slot>accept()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>248</x> <x>257</x>
<y>254</y> <y>573</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>157</x> <x>157</x>
@ -1438,8 +1668,8 @@
<slot>reject()</slot> <slot>reject()</slot>
<hints> <hints>
<hint type="sourcelabel"> <hint type="sourcelabel">
<x>316</x> <x>325</x>
<y>260</y> <y>573</y>
</hint> </hint>
<hint type="destinationlabel"> <hint type="destinationlabel">
<x>286</x> <x>286</x>

View File

@ -135,6 +135,7 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, quint32 toolId,
m_timerWidth(new QTimer(this)), m_timerWidth(new QTimer(this)),
m_timerWidthBefore(new QTimer(this)), m_timerWidthBefore(new QTimer(this)),
m_timerWidthAfter(new QTimer(this)), m_timerWidthAfter(new QTimer(this)),
m_timerPassmarkLength(new QTimer(this)),
m_saWidth(0), m_saWidth(0),
m_templateLines(), m_templateLines(),
m_undoStack(), m_undoStack(),
@ -531,6 +532,22 @@ void DialogSeamAllowance::CheckState()
} }
uiTabPaths->comboBoxNodes->setEnabled(flagFormulaBefore && flagFormulaAfter); uiTabPaths->comboBoxNodes->setEnabled(flagFormulaBefore && flagFormulaAfter);
if (uiTabPassmarks->comboBoxPassmarks->count() == 0)
{
flagFormulaPassmarkLength = true;
}
if (flagFormulaPassmarkLength)
{
m_ftb->SetTabText(TabOrder::Passmarks, tr("Passmarks"));
}
else
{
m_ftb->SetTabText(TabOrder::Passmarks, tr("Passmarks") + '*');
}
uiTabPassmarks->comboBoxPassmarks->setEnabled(flagFormulaPassmarkLength);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -541,6 +558,7 @@ void DialogSeamAllowance::closeEvent(QCloseEvent *event)
uiTabPaths->plainTextEditFormulaWidthAfter->blockSignals(true); uiTabPaths->plainTextEditFormulaWidthAfter->blockSignals(true);
uiTabGrainline->lineEditRotFormula->blockSignals(true); uiTabGrainline->lineEditRotFormula->blockSignals(true);
uiTabGrainline->lineEditLenFormula->blockSignals(true); uiTabGrainline->lineEditLenFormula->blockSignals(true);
uiTabPassmarks->plainTextEditPassmarkLength->blockSignals(true);
DialogTool::closeEvent(event); DialogTool::closeEvent(event);
} }
@ -989,28 +1007,19 @@ void DialogSeamAllowance::NodeChanged(int index)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::PassmarkChanged(int index) void DialogSeamAllowance::PassmarkChanged(int index)
{ {
uiTabPassmarks->radioButtonOneLine->setDisabled(true); uiTabPassmarks->groupBoxMarkType->setDisabled(true);
uiTabPassmarks->radioButtonTwoLines->setDisabled(true); uiTabPassmarks->groupBoxAngleType->setDisabled(true);
uiTabPassmarks->radioButtonThreeLines->setDisabled(true); uiTabPassmarks->groupBoxManualLength->setDisabled(true);
uiTabPassmarks->radioButtonTMark->setDisabled(true);
uiTabPassmarks->radioButtonVMark->setDisabled(true);
uiTabPassmarks->radioButtonVMark2->setDisabled(true);
uiTabPassmarks->radioButtonStraightforward->setDisabled(true);
uiTabPassmarks->radioButtonBisector->setDisabled(true);
uiTabPassmarks->radioButtonIntersection->setDisabled(true);
uiTabPassmarks->radioButtonIntersectionOnlyLeft->setDisabled(true);
uiTabPassmarks->radioButtonIntersectionOnlyRight->setDisabled(true);
uiTabPassmarks->radioButtonIntersection2->setDisabled(true);
uiTabPassmarks->radioButtonIntersection2OnlyLeft->setDisabled(true);
uiTabPassmarks->radioButtonIntersection2OnlyRight->setDisabled(true);
uiTabPassmarks->checkBoxShowSecondPassmark->setDisabled(true); uiTabPassmarks->checkBoxShowSecondPassmark->setDisabled(true);
uiTabPassmarks->checkBoxShowSecondPassmark->blockSignals(true); uiTabPassmarks->checkBoxShowSecondPassmark->blockSignals(true);
uiTabPassmarks->groupBoxManualLength->blockSignals(true);
uiTabPassmarks->groupBoxMarkType->blockSignals(true); uiTabPassmarks->groupBoxMarkType->blockSignals(true);
uiTabPassmarks->groupBoxAngleType->blockSignals(true); uiTabPassmarks->groupBoxAngleType->blockSignals(true);
uiTabPassmarks->groupBoxManualLength->setChecked(false);
if (index != -1) if (index != -1)
{ {
const VPiece piece = CreatePiece(); const VPiece piece = CreatePiece();
@ -1019,13 +1028,40 @@ void DialogSeamAllowance::PassmarkChanged(int index)
{ {
const VPieceNode &node = piece.GetPath().at(nodeIndex); const VPieceNode &node = piece.GetPath().at(nodeIndex);
// Passmark length
uiTabPassmarks->groupBoxManualLength->setEnabled(true);
if (node.IsManualPassmarkLength())
{
uiTabPassmarks->groupBoxManualLength->setChecked(true);
QString passmarkLength = node.GetFormulaPassmarkLength();
passmarkLength = qApp->TrVars()->FormulaToUser(passmarkLength, qApp->Settings()->GetOsSeparator());
if (passmarkLength.length() > 80)// increase height if needed.
{
this->DeployPassmarkLength();
}
if (passmarkLength.isEmpty())
{
qreal length = UnitConvertor(1, Unit::Cm, qApp->patternUnit());
uiTabPassmarks->plainTextEditPassmarkLength->setPlainText(qApp->LocaleToString(length));
}
else
{
uiTabPassmarks->plainTextEditPassmarkLength->setPlainText(passmarkLength);
}
}
else
{
qreal length = UnitConvertor(1, Unit::Cm, qApp->patternUnit());
uiTabPassmarks->plainTextEditPassmarkLength->setPlainText(qApp->LocaleToString(length));
}
MoveCursorToEnd(uiTabPassmarks->plainTextEditPassmarkLength);
// Line type // Line type
uiTabPassmarks->radioButtonOneLine->setEnabled(true); uiTabPassmarks->groupBoxMarkType->setEnabled(true);
uiTabPassmarks->radioButtonTwoLines->setEnabled(true);
uiTabPassmarks->radioButtonThreeLines->setEnabled(true);
uiTabPassmarks->radioButtonTMark->setEnabled(true);
uiTabPassmarks->radioButtonVMark->setEnabled(true);
uiTabPassmarks->radioButtonVMark2->setEnabled(true);
switch(node.GetPassmarkLineType()) switch(node.GetPassmarkLineType())
{ {
@ -1052,14 +1088,7 @@ void DialogSeamAllowance::PassmarkChanged(int index)
} }
// Angle type // Angle type
uiTabPassmarks->radioButtonStraightforward->setEnabled(true); uiTabPassmarks->groupBoxAngleType->setEnabled(true);
uiTabPassmarks->radioButtonBisector->setEnabled(true);
uiTabPassmarks->radioButtonIntersection->setEnabled(true);
uiTabPassmarks->radioButtonIntersectionOnlyLeft->setEnabled(true);
uiTabPassmarks->radioButtonIntersectionOnlyRight->setEnabled(true);
uiTabPassmarks->radioButtonIntersection2->setEnabled(true);
uiTabPassmarks->radioButtonIntersection2OnlyLeft->setEnabled(true);
uiTabPassmarks->radioButtonIntersection2OnlyRight->setEnabled(true);
switch(node.GetPassmarkAngleType()) switch(node.GetPassmarkAngleType())
{ {
@ -1098,7 +1127,7 @@ void DialogSeamAllowance::PassmarkChanged(int index)
} }
uiTabPassmarks->checkBoxShowSecondPassmark->blockSignals(false); uiTabPassmarks->checkBoxShowSecondPassmark->blockSignals(false);
uiTabPassmarks->groupBoxManualLength->blockSignals(false);
uiTabPassmarks->groupBoxMarkType->blockSignals(false); uiTabPassmarks->groupBoxMarkType->blockSignals(false);
uiTabPassmarks->groupBoxAngleType->blockSignals(false); uiTabPassmarks->groupBoxAngleType->blockSignals(false);
} }
@ -1822,6 +1851,23 @@ void DialogSeamAllowance::EnabledPatternLabel()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::EnabledManualPassmarkLength()
{
const int index = uiTabPassmarks->comboBoxPassmarks->currentIndex();
if (index != -1)
{
QListWidgetItem *rowItem = GetItemById(uiTabPassmarks->comboBoxPassmarks->currentData().toUInt());
if (rowItem)
{
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
rowNode.SetManualPassmarkLength(uiTabPassmarks->groupBoxManualLength->isChecked());
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
EvalPassmarkLength();
}
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::EditGrainlineFormula() void DialogSeamAllowance::EditGrainlineFormula()
{ {
@ -2150,6 +2196,35 @@ void DialogSeamAllowance::EvalWidthAfter()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::EvalPassmarkLength()
{
if (uiTabPassmarks->groupBoxManualLength->isChecked())
{
if (uiTabPassmarks->comboBoxPassmarks->count() > 0)
{
FormulaData formulaData;
formulaData.formula = uiTabPassmarks->plainTextEditPassmarkLength->toPlainText();
formulaData.variables = data->DataVariables();
formulaData.labelEditFormula = uiTabPassmarks->labelEditPassmarkLength;
formulaData.labelResult = uiTabPassmarks->labelResultPassmarkLength;
formulaData.postfix = UnitsToStr(qApp->patternUnit(), true);
formulaData.checkZero = false;
formulaData.checkLessThanZero = false;
Eval(formulaData, flagFormulaPassmarkLength);
UpdateNodePassmarkLength(GetFormulaFromUser(uiTabPassmarks->plainTextEditPassmarkLength));
}
else
{
ChangeColor(uiTabPassmarks->labelEditPassmarkLength, OkColor(this));
uiTabPassmarks->labelResultPassmarkLength->setText(tr("<Empty>"));
flagFormulaPassmarkLength = true;
}
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::FXWidth() void DialogSeamAllowance::FXWidth()
{ {
@ -2192,6 +2267,19 @@ void DialogSeamAllowance::FXWidthAfter()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::FXPassmarkLength()
{
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
dialog->setWindowTitle(tr("Edit passmark length"));
dialog->SetFormula(GetFormulaFromUser(uiTabPassmarks->plainTextEditPassmarkLength));
dialog->setPostfix(UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted)
{
SetFormularPassmarkLength(dialog->GetFormula());
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::DeployWidthFormulaTextEdit() void DialogSeamAllowance::DeployWidthFormulaTextEdit()
{ {
@ -2212,6 +2300,13 @@ void DialogSeamAllowance::DeployWidthAfterFormulaTextEdit()
m_formulaBaseWidthAfter); m_formulaBaseWidthAfter);
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::DeployPassmarkLength()
{
DeployFormula(this, uiTabPassmarks->plainTextEditPassmarkLength, uiTabPassmarks->pushButtonGrowPassmarkLength,
m_formulaBasePassmarkLength);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::GrainlinePinPointChanged() void DialogSeamAllowance::GrainlinePinPointChanged()
{ {
@ -2654,6 +2749,22 @@ void DialogSeamAllowance::UpdateNodeSAAfter(const QString &formula)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::UpdateNodePassmarkLength(const QString &formula)
{
const int index = uiTabPassmarks->comboBoxPassmarks->currentIndex();
if (index != -1)
{
QListWidgetItem *rowItem = GetItemById(uiTabPassmarks->comboBoxPassmarks->currentData().toUInt());
if (rowItem)
{
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
rowNode.SetFormulaPassmarkLength(formula);
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
}
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitFancyTabBar() void DialogSeamAllowance::InitFancyTabBar()
{ {
@ -3035,6 +3146,15 @@ void DialogSeamAllowance::InitPinsTab()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitPassmarksTab() void DialogSeamAllowance::InitPassmarksTab()
{ {
this->m_formulaBasePassmarkLength = uiTabPassmarks->plainTextEditPassmarkLength->height();
uiTabPassmarks->plainTextEditPassmarkLength->installEventFilter(this);
m_timerPassmarkLength->setSingleShot(true);
connect(m_timerPassmarkLength, &QTimer::timeout, this, &DialogSeamAllowance::EvalPassmarkLength);
connect(uiTabPassmarks->groupBoxManualLength, &QGroupBox::toggled, this,
&DialogSeamAllowance::EnabledManualPassmarkLength);
InitPassmarksList(); InitPassmarksList();
connect(uiTabPassmarks->comboBoxPassmarks, QOverload<int>::of(&QComboBox::currentIndexChanged), connect(uiTabPassmarks->comboBoxPassmarks, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &DialogSeamAllowance::PassmarkChanged); this, &DialogSeamAllowance::PassmarkChanged);
@ -3045,6 +3165,15 @@ void DialogSeamAllowance::InitPassmarksTab()
this, &DialogSeamAllowance::PassmarkAngleTypeChanged); this, &DialogSeamAllowance::PassmarkAngleTypeChanged);
connect(uiTabPassmarks->checkBoxShowSecondPassmark, &QCheckBox::stateChanged, this, connect(uiTabPassmarks->checkBoxShowSecondPassmark, &QCheckBox::stateChanged, this,
&DialogSeamAllowance::PassmarkShowSecondChanged); &DialogSeamAllowance::PassmarkShowSecondChanged);
connect(uiTabPassmarks->toolButtonExprLength, &QPushButton::clicked, this, &DialogSeamAllowance::FXPassmarkLength);
connect(uiTabPassmarks->plainTextEditPassmarkLength, &QPlainTextEdit::textChanged, this, [this]()
{
m_timerPassmarkLength->start(formulaTimerTimeout);
});
connect(uiTabPassmarks->pushButtonGrowPassmarkLength, &QPushButton::clicked, this,
&DialogSeamAllowance::DeployPassmarkLength);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -3115,6 +3244,20 @@ void DialogSeamAllowance::SetFormulaSAWidth(const QString &formula)
MoveCursorToEnd(uiTabPaths->plainTextEditFormulaWidth); MoveCursorToEnd(uiTabPaths->plainTextEditFormulaWidth);
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetFormularPassmarkLength(const QString &formula)
{
const QString width = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator());
// increase height if needed.
if (width.length() > 80)
{
this->DeployPassmarkLength();
}
uiTabPassmarks->plainTextEditPassmarkLength->setPlainText(width);
MoveCursorToEnd(uiTabPassmarks->plainTextEditPassmarkLength);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::UpdateCurrentCustomSARecord() void DialogSeamAllowance::UpdateCurrentCustomSARecord()
{ {

View File

@ -134,18 +134,22 @@ private slots:
void EnabledGrainline(); void EnabledGrainline();
void EnabledDetailLabel(); void EnabledDetailLabel();
void EnabledPatternLabel(); void EnabledPatternLabel();
void EnabledManualPassmarkLength();
void EvalWidth(); void EvalWidth();
void EvalWidthBefore(); void EvalWidthBefore();
void EvalWidthAfter(); void EvalWidthAfter();
void EvalPassmarkLength();
void FXWidth(); void FXWidth();
void FXWidthBefore(); void FXWidthBefore();
void FXWidthAfter(); void FXWidthAfter();
void FXPassmarkLength();
void DeployWidthFormulaTextEdit(); void DeployWidthFormulaTextEdit();
void DeployWidthBeforeFormulaTextEdit(); void DeployWidthBeforeFormulaTextEdit();
void DeployWidthAfterFormulaTextEdit(); void DeployWidthAfterFormulaTextEdit();
void DeployPassmarkLength();
void GrainlinePinPointChanged(); void GrainlinePinPointChanged();
void DetailPinPointChanged(); void DetailPinPointChanged();
@ -185,6 +189,7 @@ private:
bool flagPLFormulas; bool flagPLFormulas;
bool flagFormulaBefore; bool flagFormulaBefore;
bool flagFormulaAfter; bool flagFormulaAfter;
bool flagFormulaPassmarkLength{true};
bool flagMainPathIsValid; bool flagMainPathIsValid;
bool flagName; bool flagName;
bool flagFormula; bool flagFormula;
@ -204,10 +209,12 @@ private:
int m_formulaBaseWidth; int m_formulaBaseWidth;
int m_formulaBaseWidthBefore; int m_formulaBaseWidthBefore;
int m_formulaBaseWidthAfter; int m_formulaBaseWidthAfter;
int m_formulaBasePassmarkLength{0};
QTimer *m_timerWidth; QTimer *m_timerWidth;
QTimer *m_timerWidthBefore; QTimer *m_timerWidthBefore;
QTimer *m_timerWidthAfter; QTimer *m_timerWidthAfter;
QTimer *m_timerPassmarkLength;
qreal m_saWidth; qreal m_saWidth;
QVector<VLabelTemplateLine> m_templateLines; QVector<VLabelTemplateLine> m_templateLines;
@ -236,6 +243,7 @@ private:
void UpdateNodeSABefore(const QString &formula); void UpdateNodeSABefore(const QString &formula);
void UpdateNodeSAAfter(const QString &formula); void UpdateNodeSAAfter(const QString &formula);
void UpdateNodePassmarkLength(const QString &formula);
void InitFancyTabBar(); void InitFancyTabBar();
void InitMainPathTab(); void InitMainPathTab();
@ -255,6 +263,7 @@ private:
void InitAllPinComboboxes(); void InitAllPinComboboxes();
void SetFormulaSAWidth(const QString &formula); void SetFormulaSAWidth(const QString &formula);
void SetFormularPassmarkLength(const QString &formula);
void SetGrainlineAngle(QString angleFormula); void SetGrainlineAngle(QString angleFormula);
void SetGrainlineLength(QString lengthFormula); void SetGrainlineLength(QString lengthFormula);
@ -285,7 +294,7 @@ inline bool DialogSeamAllowance::IsValid() const
{ {
return flagName && flagMainPathIsValid && flagFormula && flagFormulaBefore && flagFormulaAfter return flagName && flagMainPathIsValid && flagFormula && flagFormulaBefore && flagFormulaAfter
&& (flagGFormulas || flagGPin) && flagDLAngle && (flagDLFormulas || flagDPin) && flagPLAngle && (flagGFormulas || flagGPin) && flagDLAngle && (flagDLFormulas || flagDPin) && flagPLAngle
&& (flagPLFormulas || flagPPin); && (flagPLFormulas || flagPPin) && flagFormulaPassmarkLength;
} }
#endif // DIALOGSEAMALLOWANCE_H #endif // DIALOGSEAMALLOWANCE_H

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>352</width> <width>394</width>
<height>594</height> <height>552</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -24,11 +24,11 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>332</width> <width>374</width>
<height>574</height> <height>532</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_5">
<item> <item>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy"> <property name="fieldGrowthPolicy">
@ -47,236 +47,469 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBoxMarkType"> <widget class="QGroupBox" name="groupBoxManualLength">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="title"> <property name="title">
<string>Marks</string> <string>Manual length</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<widget class="QRadioButton" name="radioButtonOneLine"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="enabled"> <item alignment="Qt::AlignLeft">
<bool>false</bool> <widget class="QLabel" name="labelEditPassmarkLength">
</property> <property name="enabled">
<property name="text"> <bool>true</bool>
<string>One line</string> </property>
</property> <property name="sizePolicy">
<attribute name="buttonGroup"> <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<string notr="true">buttonGroupLineType</string> <horstretch>0</horstretch>
</attribute> <verstretch>0</verstretch>
</widget> </sizepolicy>
</property>
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>159</red>
<green>158</green>
<blue>158</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>Length:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignRight">
<widget class="QToolButton" name="toolButtonExprLength">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Formula wizard</string>
</property>
<property name="text">
<string notr="true">f(x)</string>
</property>
<property name="icon">
<iconset resource="../../../../../vmisc/share/resources/icon.qrc">
<normaloff>:/icon/24x24/fx.png</normaloff>:/icon/24x24/fx.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>36</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>=</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="labelResultPassmarkLength">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>87</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>Value</string>
</property>
<property name="whatsThis">
<string notr="true"/>
</property>
<property name="text">
<string notr="true">_</string>
</property>
</widget>
</item>
</layout>
</item> </item>
<item> <item>
<widget class="QRadioButton" name="radioButtonTwoLines"> <layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="enabled"> <item>
<bool>false</bool> <widget class="VPlainTextEdit" name="plainTextEditPassmarkLength">
</property> <property name="enabled">
<property name="text"> <bool>true</bool>
<string>Two lines</string> </property>
</property> <property name="sizePolicy">
<attribute name="buttonGroup"> <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<string notr="true">buttonGroupLineType</string> <horstretch>0</horstretch>
</attribute> <verstretch>0</verstretch>
</widget> </sizepolicy>
</item> </property>
<item> <property name="maximumSize">
<widget class="QRadioButton" name="radioButtonThreeLines"> <size>
<property name="enabled"> <width>16777215</width>
<bool>false</bool> <height>28</height>
</property> </size>
<property name="text"> </property>
<string>Three lines</string> <property name="toolTip">
</property> <string>Calculation</string>
<attribute name="buttonGroup"> </property>
<string notr="true">buttonGroupLineType</string> <property name="tabChangesFocus">
</attribute> <bool>true</bool>
</widget> </property>
</item> </widget>
<item> </item>
<widget class="QRadioButton" name="radioButtonTMark"> <item>
<property name="enabled"> <widget class="QPushButton" name="pushButtonGrowPassmarkLength">
<bool>false</bool> <property name="enabled">
</property> <bool>true</bool>
<property name="text"> </property>
<string>T mark</string> <property name="maximumSize">
</property> <size>
<attribute name="buttonGroup"> <width>18</width>
<string notr="true">buttonGroupLineType</string> <height>18</height>
</attribute> </size>
</widget> </property>
</item> <property name="sizeIncrement">
<item> <size>
<widget class="QRadioButton" name="radioButtonVMark"> <width>0</width>
<property name="enabled"> <height>0</height>
<bool>false</bool> </size>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>Acute angle that looks intside of piece</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Show full calculation in message box&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>V mark</string> <string notr="true"/>
</property> </property>
<attribute name="buttonGroup"> <property name="icon">
<string notr="true">buttonGroupLineType</string> <iconset theme="go-down">
</attribute> <normaloff>../../</normaloff>../../</iconset>
</widget> </property>
</item> <property name="iconSize">
<item> <size>
<widget class="QRadioButton" name="radioButtonVMark2"> <width>16</width>
<property name="enabled"> <height>16</height>
<bool>false</bool> </size>
</property> </property>
<property name="toolTip"> <property name="flat">
<string>Acute angle that looks outside of piece</string> <bool>true</bool>
</property> </property>
<property name="text"> </widget>
<string>V mark 2</string> </item>
</property> </layout>
<attribute name="buttonGroup">
<string notr="true">buttonGroupLineType</string>
</attribute>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBoxAngleType"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="title"> <item>
<string>Angle</string> <widget class="QGroupBox" name="groupBoxMarkType">
</property> <property name="enabled">
<layout class="QVBoxLayout" name="verticalLayout_2"> <bool>true</bool>
<item> </property>
<widget class="QRadioButton" name="radioButtonStraightforward"> <property name="title">
<property name="enabled"> <string>Marks</string>
<bool>false</bool> </property>
</property> <layout class="QVBoxLayout" name="verticalLayout">
<property name="text"> <item>
<string>Straightforward</string> <widget class="QRadioButton" name="radioButtonOneLine">
</property> <property name="enabled">
<attribute name="buttonGroup"> <bool>true</bool>
<string notr="true">buttonGroupAngleType</string> </property>
</attribute> <property name="text">
</widget> <string>One line</string>
</item> </property>
<item> <attribute name="buttonGroup">
<widget class="QRadioButton" name="radioButtonBisector"> <string notr="true">buttonGroupLineType</string>
<property name="enabled"> </attribute>
<bool>false</bool> </widget>
</property> </item>
<property name="text"> <item>
<string>Bisector</string> <widget class="QRadioButton" name="radioButtonTwoLines">
</property> <property name="enabled">
<attribute name="buttonGroup"> <bool>true</bool>
<string notr="true">buttonGroupAngleType</string> </property>
</attribute> <property name="text">
</widget> <string>Two lines</string>
</item> </property>
<item> <attribute name="buttonGroup">
<widget class="QRadioButton" name="radioButtonIntersection"> <string notr="true">buttonGroupLineType</string>
<property name="enabled"> </attribute>
<bool>false</bool> </widget>
</property> </item>
<property name="toolTip"> <item>
<string>Select if need designate the corner point as a passmark</string> <widget class="QRadioButton" name="radioButtonThreeLines">
</property> <property name="enabled">
<property name="text"> <bool>true</bool>
<string>Intersection</string> </property>
</property> <property name="text">
<attribute name="buttonGroup"> <string>Three lines</string>
<string notr="true">buttonGroupAngleType</string> </property>
</attribute> <attribute name="buttonGroup">
</widget> <string notr="true">buttonGroupLineType</string>
</item> </attribute>
<item> </widget>
<widget class="QRadioButton" name="radioButtonIntersectionOnlyLeft"> </item>
<property name="enabled"> <item>
<bool>false</bool> <widget class="QRadioButton" name="radioButtonTMark">
</property> <property name="enabled">
<property name="toolTip"> <bool>true</bool>
<string>Select if need designate the corner point as a passmark. Show only left passmark.</string> </property>
</property> <property name="text">
<property name="text"> <string>T mark</string>
<string>Intersection (only left)</string> </property>
</property> <attribute name="buttonGroup">
<attribute name="buttonGroup"> <string notr="true">buttonGroupLineType</string>
<string notr="true">buttonGroupAngleType</string> </attribute>
</attribute> </widget>
</widget> </item>
</item> <item>
<item> <widget class="QRadioButton" name="radioButtonVMark">
<widget class="QRadioButton" name="radioButtonIntersectionOnlyRight"> <property name="enabled">
<property name="enabled"> <bool>true</bool>
<bool>false</bool> </property>
</property> <property name="toolTip">
<property name="toolTip"> <string>Acute angle that looks intside of piece</string>
<string>Select if need designate the corner point as a passmark. Show only right passmark.</string> </property>
</property> <property name="text">
<property name="text"> <string>V mark</string>
<string>Intersection (only right)</string> </property>
</property> <attribute name="buttonGroup">
<attribute name="buttonGroup"> <string notr="true">buttonGroupLineType</string>
<string notr="true">buttonGroupAngleType</string> </attribute>
</attribute> </widget>
</widget> </item>
</item> <item>
<item> <widget class="QRadioButton" name="radioButtonVMark2">
<widget class="QRadioButton" name="radioButtonIntersection2"> <property name="enabled">
<property name="enabled"> <bool>true</bool>
<bool>false</bool> </property>
</property> <property name="toolTip">
<property name="toolTip"> <string>Acute angle that looks outside of piece</string>
<string>Select if need designate the corner point as a passmark</string> </property>
</property> <property name="text">
<property name="text"> <string>V mark 2</string>
<string>Intersection 2</string> </property>
</property> <attribute name="buttonGroup">
<attribute name="buttonGroup"> <string notr="true">buttonGroupLineType</string>
<string notr="true">buttonGroupAngleType</string> </attribute>
</attribute> </widget>
</widget> </item>
</item> </layout>
<item> </widget>
<widget class="QRadioButton" name="radioButtonIntersection2OnlyLeft"> </item>
<property name="enabled"> <item>
<bool>false</bool> <widget class="QGroupBox" name="groupBoxAngleType">
</property> <property name="enabled">
<property name="toolTip"> <bool>true</bool>
<string>Select if need designate the corner point as a passmark. Show only left passmark.</string> </property>
</property> <property name="title">
<property name="text"> <string>Angle</string>
<string>Intersection 2 (only left)</string> </property>
</property> <layout class="QVBoxLayout" name="verticalLayout_2">
<attribute name="buttonGroup"> <item>
<string notr="true">buttonGroupAngleType</string> <widget class="QRadioButton" name="radioButtonStraightforward">
</attribute> <property name="enabled">
</widget> <bool>true</bool>
</item> </property>
<item> <property name="text">
<widget class="QRadioButton" name="radioButtonIntersection2OnlyRight"> <string>Straightforward</string>
<property name="enabled"> </property>
<bool>false</bool> <attribute name="buttonGroup">
</property> <string notr="true">buttonGroupAngleType</string>
<property name="toolTip"> </attribute>
<string>Select if need designate the corner point as a passmark. Show only right passmark.</string> </widget>
</property> </item>
<property name="text"> <item>
<string>Intersection 2 (only right)</string> <widget class="QRadioButton" name="radioButtonBisector">
</property> <property name="enabled">
<attribute name="buttonGroup"> <bool>true</bool>
<string notr="true">buttonGroupAngleType</string> </property>
</attribute> <property name="text">
</widget> <string>Bisector</string>
</item> </property>
</layout> <attribute name="buttonGroup">
</widget> <string notr="true">buttonGroupAngleType</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonIntersection">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Select if need designate the corner point as a passmark</string>
</property>
<property name="text">
<string>Intersection</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroupAngleType</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonIntersectionOnlyLeft">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Select if need designate the corner point as a passmark. Show only left passmark.</string>
</property>
<property name="text">
<string>Intersection (only left)</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroupAngleType</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonIntersectionOnlyRight">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Select if need designate the corner point as a passmark. Show only right passmark.</string>
</property>
<property name="text">
<string>Intersection (only right)</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroupAngleType</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonIntersection2">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Select if need designate the corner point as a passmark</string>
</property>
<property name="text">
<string>Intersection 2</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroupAngleType</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonIntersection2OnlyLeft">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Select if need designate the corner point as a passmark. Show only left passmark.</string>
</property>
<property name="text">
<string>Intersection 2 (only left)</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroupAngleType</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonIntersection2OnlyRight">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Select if need designate the corner point as a passmark. Show only right passmark.</string>
</property>
<property name="text">
<string>Intersection 2 (only right)</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroupAngleType</string>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkBoxShowSecondPassmark"> <widget class="QCheckBox" name="checkBoxShowSecondPassmark">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</bool>
</property> </property>
<property name="toolTip"> <property name="toolTip">
<string>This option has effect only if the second passmark on seam line enabled in global preferences. The option helps disable the second passmark for this passmark only.</string> <string>This option has effect only if the second passmark on seam line enabled in global preferences. The option helps disable the second passmark for this passmark only.</string>
@ -305,7 +538,16 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<resources/> <customwidgets>
<customwidget>
<class>VPlainTextEdit</class>
<extends>QPlainTextEdit</extends>
<header location="global">vplaintextedit.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../../../../vmisc/share/resources/icon.qrc"/>
</resources>
<connections/> <connections/>
<buttongroups> <buttongroups>
<buttongroup name="buttonGroupLineType"/> <buttongroup name="buttonGroupLineType"/>

View File

@ -584,6 +584,11 @@ QDomElement VAbstractTool::AddSANode(VAbstractPattern *doc, const QString &tagNa
doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrNodeShowSecondPassmark, node.IsShowSecondPassmark(), doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrNodeShowSecondPassmark, node.IsShowSecondPassmark(),
node.IsShowSecondPassmark()); node.IsShowSecondPassmark());
doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrManualPassmarkLength, node.IsManualPassmarkLength(),
not node.IsManualPassmarkLength());
doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrPassmarkLength, node.GetFormulaPassmarkLength(),
not node.IsManualPassmarkLength());
return nod; return nod;
} }