diff --git a/ChangeLog.txt b/ChangeLog.txt
index 1917fdb58..f19a42f0a 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -13,6 +13,7 @@
- [#936] Improve list of predefined paper size formats for layout export. Added format Tabloid.
- Extend Label language to support Czech alphabet.
- [#916] Improve layout generation.
+- [#965] Control passmark length with formula.
# Version 0.6.2 (unreleased)
- [#903] Bug in tool Cut Spline path.
diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc
index fc669a809..94fef1188 100644
--- a/src/libs/ifc/schema.qrc
+++ b/src/libs/ifc/schema.qrc
@@ -54,6 +54,7 @@
schema/pattern/v0.8.0.xsd
schema/pattern/v0.8.1.xsd
schema/pattern/v0.8.2.xsd
+ schema/pattern/v0.8.3.xsd
schema/standard_measurements/v0.3.0.xsd
schema/standard_measurements/v0.4.0.xsd
schema/standard_measurements/v0.4.1.xsd
diff --git a/src/libs/ifc/schema/pattern/v0.8.3.xsd b/src/libs/ifc/schema/pattern/v0.8.3.xsd
new file mode 100644
index 000000000..db10e8c61
--- /dev/null
+++ b/src/libs/ifc/schema/pattern/v0.8.3.xsd
@@ -0,0 +1,1166 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp
index 5c6d07e17..d77378391 100644
--- a/src/libs/ifc/xml/vabstractpattern.cpp
+++ b/src/libs/ifc/xml/vabstractpattern.cpp
@@ -130,6 +130,8 @@ const QString VAbstractPattern::AttrIncludeAs = QStringLiteral("includeA
const QString VAbstractPattern::AttrRotation = QStringLiteral("rotation");
const QString VAbstractPattern::AttrNumber = QStringLiteral("number");
const QString VAbstractPattern::AttrCheckUniqueness = QStringLiteral("checkUniqueness");
+const QString VAbstractPattern::AttrManualPassmarkLength = QStringLiteral("manualPassmarkLength");
+const QString VAbstractPattern::AttrPassmarkLength = QStringLiteral("passmarkLength");
const QString VAbstractPattern::AttrAll = QStringLiteral("all");
@@ -764,6 +766,10 @@ VPieceNode VAbstractPattern::ParseSANode(const QDomElement &domElement)
const bool showSecond = VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrNodeShowSecondPassmark,
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);
Tool tool;
@@ -808,6 +814,8 @@ VPieceNode VAbstractPattern::ParseSANode(const QDomElement &domElement)
node.SetPassmark(passmark);
node.SetPassmarkLineType(passmarkLine);
node.SetPassmarkAngleType(passmarkAngle);
+ node.SetManualPassmarkLength(manualPassmarkLength);
+ node.SetFormulaPassmarkLength(passmarkLength);
return node;
}
diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h
index 59a8769e7..7919ca544 100644
--- a/src/libs/ifc/xml/vabstractpattern.h
+++ b/src/libs/ifc/xml/vabstractpattern.h
@@ -278,6 +278,8 @@ public:
static const QString AttrRotation;
static const QString AttrNumber;
static const QString AttrCheckUniqueness;
+ static const QString AttrManualPassmarkLength;
+ static const QString AttrPassmarkLength;
static const QString AttrAll;
diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp
index 122e77ea7..25e0061a9 100644
--- a/src/libs/ifc/xml/vpatternconverter.cpp
+++ b/src/libs/ifc/xml/vpatternconverter.cpp
@@ -59,8 +59,8 @@ class QDomElement;
*/
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.4");
-const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.2");
-const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.2.xsd");
+const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.8.3");
+const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.8.3.xsd");
//VPatternConverter::PatternMinVer; // <== 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, 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, 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))
@@ -461,6 +462,10 @@ void VPatternConverter::ApplyPatches()
ValidateXML(XSDSchema(FORMAT_VERSION(0, 8, 2)), m_convertedFileName);
Q_FALLTHROUGH();
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;
default:
InvalidVersion(m_ver);
@@ -478,7 +483,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion()
bool VPatternConverter::IsReadOnly() const
{
// 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.");
// Possibly in future attribute readOnly will change position etc.
@@ -1068,6 +1073,16 @@ void VPatternConverter::ToV0_8_2()
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()
{
diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h
index f36708e7d..33eb1d7f8 100644
--- a/src/libs/ifc/xml/vpatternconverter.h
+++ b/src/libs/ifc/xml/vpatternconverter.h
@@ -53,7 +53,7 @@ public:
static const QString PatternMaxVerStr;
static const QString CurrentSchema;
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:
virtual int MinVer() const override;
@@ -125,6 +125,7 @@ private:
void ToV0_8_0();
void ToV0_8_1();
void ToV0_8_2();
+ void ToV0_8_3();
void TagUnitToV0_2_0();
void TagIncrementToV0_2_0();
diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp
index b09e869c8..d5199a352 100644
--- a/src/libs/vlayout/vabstractpiece.cpp
+++ b/src/libs/vlayout/vabstractpiece.cpp
@@ -1571,9 +1571,16 @@ qreal VSAPoint::MaxLocalSA(qreal width) const
//---------------------------------------------------------------------------------------------------------------------
qreal VSAPoint::PassmarkLength(qreal width) const
{
- qreal passmarkLength = MaxLocalSA(width) * passmarkFactor;
- passmarkLength = qMin(passmarkLength, maxPassmarkLength);
- return passmarkLength;
+ if (not m_manualPassmarkLength)
+ {
+ qreal passmarkLength = MaxLocalSA(width) * passmarkFactor;
+ passmarkLength = qMin(passmarkLength, maxPassmarkLength);
+ return passmarkLength;
+ }
+ else
+ {
+ return m_passmarkLength;
+ }
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h
index b5f72af92..a4ae66142 100644
--- a/src/libs/vlayout/vabstractpiece.h
+++ b/src/libs/vlayout/vabstractpiece.h
@@ -57,7 +57,7 @@ class VSAPoint : public QPointF
public:
Q_DECL_CONSTEXPR VSAPoint();
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;
qreal GetSABefore(qreal width) const;
@@ -70,6 +70,12 @@ public:
Q_DECL_CONSTEXPR PieceNodeAngle GetAngleType() const;
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 PassmarkLength(qreal width) const;
@@ -77,9 +83,11 @@ public:
static const qreal maxPassmarkLength;
private:
- qreal m_before;
- qreal m_after;
- PieceNodeAngle m_angle;
+ qreal m_before{-1};
+ qreal m_after{-1};
+ PieceNodeAngle m_angle{PieceNodeAngle::ByLength};
+ bool m_manualPassmarkLength{false};
+ qreal m_passmarkLength{0};
};
Q_DECLARE_METATYPE(VSAPoint)
@@ -87,26 +95,16 @@ Q_DECLARE_TYPEINFO(VSAPoint, Q_MOVABLE_TYPE);
//---------------------------------------------------------------------------------------------------------------------
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)
- : QPointF(xpos, ypos),
- m_before(-1),
- m_after(-1),
- m_angle(PieceNodeAngle::ByLength)
+ : QPointF(xpos, ypos)
{}
//---------------------------------------------------------------------------------------------------------------------
-Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(const QPointF &p)
- : QPointF(p),
- m_before(-1),
- m_after(-1),
- m_angle(PieceNodeAngle::ByLength)
+Q_DECL_CONSTEXPR inline VSAPoint::VSAPoint(QPointF p)
+ : QPointF(p)
{}
//---------------------------------------------------------------------------------------------------------------------
@@ -145,6 +143,30 @@ inline void VSAPoint::SetAngleType(PieceNodeAngle 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
class VAbstractPiece
diff --git a/src/libs/vpatterndb/vformula.cpp b/src/libs/vpatterndb/vformula.cpp
index 3b66c7497..490c7afa1 100644
--- a/src/libs/vpatterndb/vformula.cpp
+++ b/src/libs/vpatterndb/vformula.cpp
@@ -27,6 +27,7 @@
*************************************************************************/
#include "vformula.h"
+#include "vformula_p.h"
#include
#include
@@ -45,26 +46,12 @@
//VFormula
//---------------------------------------------------------------------------------------------------------------------
VFormula::VFormula()
- : formula(QString()),
- value(tr("Error")),
- checkZero(true),
- data(nullptr),
- toolId(NULL_ID),
- postfix(QString()),
- _error(true),
- dValue(0)
+ : d(new VFormulaData)
{}
//---------------------------------------------------------------------------------------------------------------------
VFormula::VFormula(const QString &formula, const VContainer *container)
- : formula(qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator())),
- value(tr("Error")),
- checkZero(true),
- data(container),
- toolId(NULL_ID),
- postfix(QString()),
- _error(true),
- dValue(0)
+ : d(new VFormulaData(formula, container))
{}
//---------------------------------------------------------------------------------------------------------------------
@@ -74,41 +61,26 @@ VFormula &VFormula::operator=(const VFormula &formula)
{
return *this;
}
- this->formula = formula.formula;
- 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;
+ d = formula.d;
return *this;
}
//---------------------------------------------------------------------------------------------------------------------
VFormula::VFormula(const VFormula &formula)
- : formula(formula.formula),
- value(formula.value),
- checkZero(formula.checkZero),
- data(formula.getData()),
- toolId(formula.toolId),
- postfix(formula.postfix),
- _error(formula._error),
- dValue(formula.dValue)
+ : d (formula.d)
+{}
+
+//---------------------------------------------------------------------------------------------------------------------
+VFormula::~VFormula()
{}
//---------------------------------------------------------------------------------------------------------------------
bool VFormula::operator==(const VFormula &formula) const
{
- bool isEqual = false;
- if (this->formula == formula.GetFormula() && this->value == formula.getStringValue() &&
- this->checkZero == formula.getCheckZero() && this->data == formula.getData() &&
- this->toolId == formula.getToolId() && this->postfix == formula.getPostfix() &&
- this->_error == formula.error() && VFuzzyComparePossibleNulls(this->dValue, formula.getDoubleValue()))
- {
- isEqual = true;
- }
- return isEqual;
+ return d->formula == formula.GetFormula() && d->strValue == formula.getStringValue() &&
+ d->checkZero == formula.getCheckZero() && d->checkLessThanZero == formula.getCheckLessThanZero() &&
+ d->data == formula.getData() && d->toolId == formula.getToolId() && d->postfix == formula.getPostfix() &&
+ d->error == formula.error() && VFuzzyComparePossibleNulls(d->dValue, formula.getDoubleValue());
}
//---------------------------------------------------------------------------------------------------------------------
@@ -122,103 +94,120 @@ QString VFormula::GetFormula(FormulaType type) const
{
if (type == FormulaType::ToUser)
{
- return formula;
+ return qApp->TrVars()->TryFormulaToUser(d->formula, qApp->Settings()->GetOsSeparator());
}
else
{
- return qApp->TrVars()->TryFormulaFromUser(formula, qApp->Settings()->GetOsSeparator());
+ return d->formula;
}
}
//---------------------------------------------------------------------------------------------------------------------
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
{
- formula = value;
+ d->formula = value;
}
+
+ ResetState();
}
}
//---------------------------------------------------------------------------------------------------------------------
QString VFormula::getStringValue() const
{
- return value;
+ return d->strValue;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VFormula::getDoubleValue() const
{
- return dValue;
+ return d->dValue;
}
//---------------------------------------------------------------------------------------------------------------------
bool VFormula::getCheckZero() const
{
- return checkZero;
+ return d->checkZero;
}
//---------------------------------------------------------------------------------------------------------------------
void VFormula::setCheckZero(bool value)
{
- if (checkZero != value)
- {
- checkZero = value;
- }
+ d->checkZero = value;
+ ResetState();
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+bool VFormula::getCheckLessThanZero() const
+{
+ return d->checkLessThanZero;
+}
+
+//---------------------------------------------------------------------------------------------------------------------
+void VFormula::setCheckLessThanZero(bool value)
+{
+ d->checkLessThanZero = value;
+ ResetState();
}
//---------------------------------------------------------------------------------------------------------------------
const VContainer *VFormula::getData() const
{
- return data;
+ return d->data;
}
//---------------------------------------------------------------------------------------------------------------------
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
{
- 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
{
- return postfix;
+ return d->postfix;
}
//---------------------------------------------------------------------------------------------------------------------
void VFormula::setPostfix(const QString &value)
{
- if (postfix != value)
- {
- postfix = value;
- }
+ d->postfix = value;
}
//---------------------------------------------------------------------------------------------------------------------
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()
{
- if (data == nullptr)
+ ResetState();
+
+ if (d->data == nullptr)
{
+ d->reason = tr("Data container is empty");
return;
}
- value = tr("Error");
- _error = true;
- dValue = 0;
qreal result = 0;
- if (not formula.isEmpty())
+ if (not d->formula.isEmpty())
{
try
{
QScopedPointer cal(new Calculator());
- const QString expression = qApp->TrVars()->FormulaFromUser(formula, qApp->Settings()->GetOsSeparator());
- result = cal->EvalFormula(data->DataVariables(), expression);
+ result = cal->EvalFormula(d->data->DataVariables(), d->formula);
}
catch (qmu::QmuParserError &e)
{
- qDebug() << "\nMath parser error:\n"
- << "--------------------------------------\n"
- << "Message: " << e.GetMsg() << "\n"
- << "Expression: " << e.GetExpr() << "\n"
- << "--------------------------------------";
+ d->reason = tr("Math parser error: %1").arg(e.GetMsg());
return;
}
- if (not qIsInf(result) && not qIsNaN(result) && not (checkZero && qFuzzyIsNull(result)))
+ d->dValue = result;
+
+ if (qIsInf(result))
{
- dValue = result;
- value = qApp->LocaleToString(result) + QLatin1Char(' ') + postfix;
- _error = false;
+ d->reason = tr("Result is infinite");
+ }
+ 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");
}
diff --git a/src/libs/vpatterndb/vformula.h b/src/libs/vpatterndb/vformula.h
index f14660333..a645d292a 100644
--- a/src/libs/vpatterndb/vformula.h
+++ b/src/libs/vpatterndb/vformula.h
@@ -30,13 +30,16 @@
#define VFORMULA_H
#include
+#include
#include
+#include
#include
#include
enum class FormulaType : char{ToUser, FromUser};
class VContainer;
+class VFormulaData;
class VFormula
{
@@ -46,6 +49,8 @@ public:
VFormula(const QString &formula, const VContainer *container);
VFormula &operator=(const VFormula &formula);
VFormula(const VFormula &formula);
+ ~VFormula();
+
bool operator==(const VFormula &formula) const;
bool operator!=(const VFormula &formula) const;
@@ -58,30 +63,30 @@ public:
bool getCheckZero() const;
void setCheckZero(bool value);
+ bool getCheckLessThanZero() const;
+ void setCheckLessThanZero(bool value);
+
const VContainer *getData() const;
void setData(const VContainer *value);
quint32 getToolId() const;
- void setToolId(const quint32 &value);
+ void setToolId(quint32 value);
QString getPostfix() const;
void setPostfix(const QString &value);
bool error() const;
+ QString Reason() const;
static int FormulaTypeId();
void Eval();
private:
- QString formula;
- QString value;
- bool checkZero;
- const VContainer *data;
- quint32 toolId;
- QString postfix;
- bool _error;
- qreal dValue;
+ QSharedDataPointer d;
+
+ void ResetState();
};
Q_DECLARE_METATYPE(VFormula)
+Q_DECLARE_TYPEINFO(VFormula, Q_MOVABLE_TYPE);
#endif // VFORMULA_H
diff --git a/src/libs/vpatterndb/vformula_p.h b/src/libs/vpatterndb/vformula_p.h
new file mode 100644
index 000000000..5a4c97f79
--- /dev/null
+++ b/src/libs/vpatterndb/vformula_p.h
@@ -0,0 +1,90 @@
+/************************************************************************
+ **
+ ** @file vformula_p.h
+ ** @author Roman Telezhynskyi
+ ** @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
+ ** 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 .
+ **
+ *************************************************************************/
+#ifndef VFORMULA_P_H
+#define VFORMULA_P_H
+
+#include "../vmisc/diagnostic.h"
+#include "../vmisc/typedef.h"
+#include "../vmisc/vmath.h"
+
+#include
+#include
+
+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
diff --git a/src/libs/vpatterndb/vpatterndb.pri b/src/libs/vpatterndb/vpatterndb.pri
index f33c11f22..ea3bc4cf0 100644
--- a/src/libs/vpatterndb/vpatterndb.pri
+++ b/src/libs/vpatterndb/vpatterndb.pri
@@ -74,4 +74,5 @@ HEADERS += \
$$PWD/floatItemData/vpatternlabeldata_p.h \
$$PWD/floatItemData/vpiecelabeldata_p.h \
$$PWD/measurements.h \
- $$PWD/pmsystems.h
+ $$PWD/pmsystems.h \
+ $$PWD/vformula_p.h
diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp
index 309e133da..d339e2dc2 100644
--- a/src/libs/vpatterndb/vpiece.cpp
+++ b/src/libs/vpatterndb/vpiece.cpp
@@ -1365,6 +1365,11 @@ QVector VPiece::CreatePassmark(const QVector &path, int prev
const QVector mainPath = MainPathPoints(data);
+ if (passmarkSAPoint.IsManualPasskmarkLength() && passmarkSAPoint.GetPasskmarkLength() <= 0)
+ {
+ return QVector();
+ }
+
if (not IsSeamAllowanceBuiltIn())
{
// Because rollback cannot be calulated if passmark is not first point in main path we rotate it.
@@ -1434,8 +1439,14 @@ QVector VPiece::SAPassmark(const VPiecePassmarkData &passmarkData, const
if (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,
line, seamAllowance);
}
diff --git a/src/libs/vpatterndb/vpiecenode.cpp b/src/libs/vpatterndb/vpiecenode.cpp
index a8971cf1b..992d0553f 100644
--- a/src/libs/vpatterndb/vpiecenode.cpp
+++ b/src/libs/vpatterndb/vpiecenode.cpp
@@ -30,41 +30,12 @@
#include "vpiecenode_p.h"
#include "vcontainer.h"
#include "calculator.h"
+#include "vformula.h"
+#include "../vmisc/vabstractapplication.h"
#include
#include
-namespace
-{
-//---------------------------------------------------------------------------------------------------------------------
-qreal EvalFormula(const VContainer *data, QString formula)
-{
- if (formula.isEmpty())
- {
- return -1;
- }
- else
- {
- try
- {
- QScopedPointer 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()
: d(new VPieceNodeData)
@@ -157,7 +128,25 @@ qreal VPieceNode::GetSABefore(const VContainer *data) const
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;
}
- 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)
{
value = ToPixel(value, unit);
@@ -199,7 +207,26 @@ qreal VPieceNode::GetSAAfter(const VContainer *data) const
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;
}
- 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)
{
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
{
@@ -323,6 +416,18 @@ void VPieceNode::SetCheckUniqueness(bool value)
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
{
diff --git a/src/libs/vpatterndb/vpiecenode.h b/src/libs/vpatterndb/vpiecenode.h
index edc1a7efa..1cd8b0a5a 100644
--- a/src/libs/vpatterndb/vpiecenode.h
+++ b/src/libs/vpatterndb/vpiecenode.h
@@ -82,6 +82,11 @@ public:
QString GetFormulaSAAfter() const;
void SetFormulaSAAfter(const QString &formula);
+ QString GetFormulaPassmarkLength() const;
+ void SetFormulaPassmarkLength(const QString &formula);
+
+ qreal GetPassmarkLength(const VContainer *data, Unit unit) const;
+
PieceNodeAngle GetAngleType() const;
void SetAngleType(PieceNodeAngle type);
@@ -102,6 +107,9 @@ public:
bool IsCheckUniqueness() const;
void SetCheckUniqueness(bool value);
+
+ bool IsManualPassmarkLength() const;
+ void SetManualPassmarkLength(bool value);
private:
QSharedDataPointer d;
};
diff --git a/src/libs/vpatterndb/vpiecenode_p.h b/src/libs/vpatterndb/vpiecenode_p.h
index 30c655413..86875bfcb 100644
--- a/src/libs/vpatterndb/vpiecenode_p.h
+++ b/src/libs/vpatterndb/vpiecenode_p.h
@@ -89,11 +89,13 @@ public:
m_isMainPathNode(node.m_isMainPathNode),
m_formulaWidthBefore(node.m_formulaWidthBefore),
m_formulaWidthAfter(node.m_formulaWidthAfter),
+ m_formulaPassmarkLength(node.m_formulaPassmarkLength),
m_angleType(node.m_angleType),
m_passmarkLineType(node.m_passmarkLineType),
m_passmarkAngleType(node.m_passmarkAngleType),
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;
@@ -122,6 +124,7 @@ public:
QString m_formulaWidthBefore;
QString m_formulaWidthAfter;
+ QString m_formulaPassmarkLength{};
PieceNodeAngle m_angleType;
@@ -135,6 +138,8 @@ public:
* gradation change a piece shape and the seond point should be remaind.*/
bool m_checkUniqueness;
+ bool m_manualPassmarkLength{false};
+
private:
VPieceNodeData &operator=(const VPieceNodeData &) Q_DECL_EQ_DELETE;
};
diff --git a/src/libs/vpatterndb/vpiecepath.cpp b/src/libs/vpatterndb/vpiecepath.cpp
index 6d32d31eb..6dd320a95 100644
--- a/src/libs/vpatterndb/vpiecepath.cpp
+++ b/src/libs/vpatterndb/vpiecepath.cpp
@@ -1059,6 +1059,8 @@ VSAPoint VPiecePath::PreparePointEkv(const VPieceNode &node, const VContainer *d
p.SetSAAfter(node.GetSAAfter(data, *data->GetPatternUnit()));
p.SetSABefore(node.GetSABefore(data, *data->GetPatternUnit()));
p.SetAngleType(node.GetAngleType());
+ p.SetManualPasskmarkLength(node.IsManualPassmarkLength());
+ p.SetPasskmarkLength(node.GetPassmarkLength(data, *data->GetPatternUnit()));
return p;
}
diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp
index 6728ee350..27e4c28b7 100644
--- a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp
+++ b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp
@@ -63,6 +63,7 @@ DialogPiecePath::DialogPiecePath(const VContainer *data, quint32 toolId, QWidget
m_timerWidthBefore(new QTimer(this)),
m_timerWidthAfter(new QTimer(this)),
m_timerVisible(new QTimer(this)),
+ m_timerPassmarkLength(new QTimer(this)),
m_formulaBaseWidth(0),
m_formulaBaseWidthBefore(0),
m_formulaBaseWidthAfter(0),
@@ -225,6 +226,7 @@ void DialogPiecePath::CheckState()
m_flagFormula = true;
m_flagFormulaBefore = true;
m_flagFormulaAfter = true;
+ m_flagFormulaPassmarkLength = true;
}
else
{
@@ -234,6 +236,7 @@ void DialogPiecePath::CheckState()
m_flagFormula = true;
m_flagFormulaBefore = true;
m_flagFormulaAfter = true;
+ m_flagFormulaPassmarkLength = true;
}
}
@@ -251,6 +254,8 @@ void DialogPiecePath::CheckState()
ui->tabWidget->setTabIcon(tabSeamAllowanceIndex, icon);
}
+ ui->comboBoxNodes->setEnabled(m_flagFormulaBefore && m_flagFormulaAfter);
+
const int tabControlIndex = ui->tabWidget->indexOf(ui->tabControl);
if (m_flagFormulaVisible)
{
@@ -262,6 +267,25 @@ void DialogPiecePath::CheckState()
QIcon(":/icons/win.icon.theme/16x16/status/dialog-warning.png"));
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->plainTextEditFormulaWidthAfter->blockSignals(true);
ui->plainTextEditFormulaVisible->blockSignals(true);
+ ui->plainTextEditPassmarkLength->blockSignals(true);
DialogTool::closeEvent(event);
}
@@ -483,28 +508,19 @@ void DialogPiecePath::NodeChanged(int index)
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::PassmarkChanged(int index)
{
- ui->radioButtonOneLine->setDisabled(true);
- ui->radioButtonTwoLines->setDisabled(true);
- ui->radioButtonThreeLines->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->groupBoxMarkType->setDisabled(true);
+ ui->groupBoxAngleType->setDisabled(true);
+ ui->groupBoxManualLength->setDisabled(true);
ui->checkBoxShowSecondPassmark->setDisabled(true);
ui->checkBoxShowSecondPassmark->blockSignals(true);
+ ui->groupBoxManualLength->blockSignals(true);
ui->groupBoxMarkType->blockSignals(true);
ui->groupBoxAngleType->blockSignals(true);
+ ui->groupBoxManualLength->setChecked(false);
+
if (index != -1)
{
const VPiecePath path = CreatePath();
@@ -513,13 +529,40 @@ void DialogPiecePath::PassmarkChanged(int index)
{
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
- ui->radioButtonOneLine->setEnabled(true);
- ui->radioButtonTwoLines->setEnabled(true);
- ui->radioButtonThreeLines->setEnabled(true);
- ui->radioButtonTMark->setEnabled(true);
- ui->radioButtonVMark->setEnabled(true);
- ui->radioButtonVMark2->setEnabled(true);
+ ui->groupBoxMarkType->setEnabled(true);
switch(node.GetPassmarkLineType())
{
@@ -546,14 +589,7 @@ void DialogPiecePath::PassmarkChanged(int index)
}
// Angle type
- ui->radioButtonStraightforward->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);
+ ui->groupBoxAngleType->setEnabled(true);
switch(node.GetPassmarkAngleType())
{
@@ -593,6 +629,7 @@ void DialogPiecePath::PassmarkChanged(int index)
ui->checkBoxShowSecondPassmark->blockSignals(false);
+ ui->groupBoxManualLength->blockSignals(false);
ui->groupBoxMarkType->blockSignals(false);
ui->groupBoxAngleType->blockSignals(false);
}
@@ -851,6 +888,24 @@ void DialogPiecePath::EvalVisible()
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()
{
@@ -905,6 +960,19 @@ void DialogPiecePath::FXVisible()
}
}
+//---------------------------------------------------------------------------------------------------------------------
+void DialogPiecePath::FXPassmarkLength()
+{
+ QScopedPointer 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()
{
@@ -929,6 +997,12 @@ void DialogPiecePath::DeployVisibleFormulaTextEdit()
DeployFormula(this, ui->plainTextEditFormulaVisible, ui->pushButtonGrowVisible, m_formulaBaseVisible);
}
+//---------------------------------------------------------------------------------------------------------------------
+void DialogPiecePath::DeployPassmarkLength()
+{
+ DeployFormula(this, ui->plainTextEditPassmarkLength, ui->pushButtonGrowPassmarkLength, m_formulaBasePassmarkLength);
+}
+
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::SetMoveControls()
{
@@ -1054,6 +1128,14 @@ void DialogPiecePath::InitSeamAllowanceTab()
//---------------------------------------------------------------------------------------------------------------------
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();
connect(ui->comboBoxPassmarks, QOverload::of(&QComboBox::currentIndexChanged),
this, &DialogPiecePath::PassmarkChanged);
@@ -1064,6 +1146,14 @@ void DialogPiecePath::InitPassmarksTab()
this, &DialogPiecePath::PassmarkAngleTypeChanged);
connect(ui->checkBoxShowSecondPassmark, &QCheckBox::stateChanged, this,
&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(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(rowItem->data(Qt::UserRole));
+ rowNode.SetManualPassmarkLength(ui->groupBoxManualLength->isChecked());
+ rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
+ EvalPassmarkLength();
+ }
+ }
+}
+
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::SetFormulaSAWidth(const QString &formula)
{
@@ -1553,6 +1676,26 @@ void DialogPiecePath::SetFormulaVisible(const QString &formula)
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)
{
diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.h b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.h
index c05ea3ace..86231114d 100644
--- a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.h
+++ b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.h
@@ -83,16 +83,19 @@ private slots:
void EvalWidthBefore();
void EvalWidthAfter();
void EvalVisible();
+ void EvalPassmarkLength();
void FXWidth();
void FXWidthBefore();
void FXWidthAfter();
void FXVisible();
+ void FXPassmarkLength();
void DeployWidthFormulaTextEdit();
void DeployWidthBeforeFormulaTextEdit();
void DeployWidthAfterFormulaTextEdit();
void DeployVisibleFormulaTextEdit();
+ void DeployPassmarkLength();
void SetMoveControls();
@@ -106,15 +109,18 @@ private:
QTimer *m_timerWidthBefore;
QTimer *m_timerWidthAfter;
QTimer *m_timerVisible;
+ QTimer *m_timerPassmarkLength;
int m_formulaBaseWidth;
int m_formulaBaseWidthBefore;
int m_formulaBaseWidthAfter;
int m_formulaBaseVisible;
+ int m_formulaBasePassmarkLength{0};
bool m_flagFormulaBefore;
bool m_flagFormulaAfter;
bool m_flagFormulaVisible;
+ bool m_flagFormulaPassmarkLength{true};
bool m_flagName;
bool m_flagError;
bool m_flagFormula;
@@ -152,6 +158,9 @@ private:
void UpdateNodeSABefore(const QString &formula);
void UpdateNodeSAAfter(const QString &formula);
+ void UpdateNodePassmarkLength(const QString &formula);
+
+ void EnabledManualPassmarkLength();
QString GetFormulaSAWidthBefore() const;
QString GetFormulaSAWidthAfter() const;
@@ -159,6 +168,9 @@ private:
QString GetFormulaVisible() const;
void SetFormulaVisible(const QString &formula);
+ QString GetFormulaPassmarkLength() const;
+ void SetFormulaPassmarkLength(const QString &formula);
+
bool IsShowNotch() const;
void RefreshPathList(const VPiecePath &path);
@@ -168,7 +180,7 @@ private:
inline bool DialogPiecePath::IsValid() const
{
return m_flagName && m_flagError && m_flagFormula && m_flagFormulaBefore && m_flagFormulaAfter
- && m_flagFormulaVisible;
+ && m_flagFormulaVisible && m_flagFormulaPassmarkLength;
}
//---------------------------------------------------------------------------------------------------------------------
diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.ui b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.ui
index 493c381f7..26a579574 100644
--- a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.ui
+++ b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.ui
@@ -6,8 +6,8 @@
0
0
- 436
- 627
+ 394
+ 583
@@ -908,7 +908,7 @@
Passmarks
-
+
-
@@ -927,236 +927,466 @@
-
-
+
true
- Marks
+ Manual length
-
+
+ true
+
+
+ true
+
+
-
-
-
- false
-
-
- One line
-
-
- buttonGroupMarkType
-
-
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+
+
+ 255
+ 0
+ 0
+
+
+
+
+
+
+
+
+ 255
+ 0
+ 0
+
+
+
+
+
+
+
+
+ 159
+ 158
+ 158
+
+
+
+
+
+
+
+ Length:
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ false
+
+
+ Formula wizard
+
+
+ f(x)
+
+
+
+ :/icon/24x24/fx.png:/icon/24x24/fx.png
+
+
+
+ 24
+ 24
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 36
+ 75
+ true
+
+
+
+ =
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 87
+ 0
+
+
+
+ Value
+
+
+
+
+
+ _
+
+
+
+
-
-
-
- false
-
-
- Two lines
-
-
- buttonGroupMarkType
-
-
-
- -
-
-
- false
-
-
- Three lines
-
-
- buttonGroupMarkType
-
-
-
- -
-
-
- false
-
-
- T mark
-
-
- buttonGroupMarkType
-
-
-
- -
-
-
- false
-
-
- Acute angle that looks inside of piece
-
-
- V mark
-
-
- buttonGroupMarkType
-
-
-
- -
-
-
- false
-
-
- Acute angle that looks outside of piece
-
-
- V mark 2
-
-
- buttonGroupMarkType
-
-
+
+
-
+
+
+ true
+
+
+
+ 0
+ 0
+
+
+
+
+ 16777215
+ 28
+
+
+
+ Calculation
+
+
+ true
+
+
+
+ -
+
+
+ true
+
+
+
+ 18
+ 18
+
+
+
+
+ 0
+ 0
+
+
+
+ <html><head/><body><p>Show full calculation in message box</p></body></html>
+
+
+
+
+
+
+ ../../
+
+
+
+ 16
+ 16
+
+
+
+ true
+
+
+
+
-
-
-
- Angle
-
-
-
-
-
-
- false
-
-
- Straightforward
-
-
- buttonGroupAngleType
-
-
-
- -
-
-
- false
-
-
- Bisector
-
-
- buttonGroupAngleType
-
-
-
- -
-
-
- false
-
-
- Select if need designate the corner point as a passmark
-
-
- Intersection
-
-
- buttonGroupAngleType
-
-
-
- -
-
-
- false
-
-
- Select if need designate the corner point as a passmark. Show only left passmark.
-
-
- Intersection (only left)
-
-
- buttonGroupAngleType
-
-
-
- -
-
-
- false
-
-
- Select if need designate the corner point as a passmark. Show only right passmark.
-
-
- Intersection (only right)
-
-
- buttonGroupAngleType
-
-
-
- -
-
-
- false
-
-
- Select if need designate the corner point as a passmark
-
-
- Intersection 2
-
-
- buttonGroupAngleType
-
-
-
- -
-
-
- false
-
-
- Select if need designate the corner point as a passmark. Show only left passmark.
-
-
- Intersection 2 (only left)
-
-
- buttonGroupAngleType
-
-
-
- -
-
-
- false
-
-
- Select if need designate the corner point as a passmark. Show only right passmark.
-
-
- Intersection 2 (only right)
-
-
- buttonGroupAngleType
-
-
-
-
-
+
+ -
+
+
+ true
+
+
+ Marks
+
+
+
-
+
+
+ true
+
+
+ One line
+
+
+ buttonGroupMarkType
+
+
+
+ -
+
+
+ true
+
+
+ Two lines
+
+
+ buttonGroupMarkType
+
+
+
+ -
+
+
+ true
+
+
+ Three lines
+
+
+ buttonGroupMarkType
+
+
+
+ -
+
+
+ true
+
+
+ T mark
+
+
+ buttonGroupMarkType
+
+
+
+ -
+
+
+ true
+
+
+ Acute angle that looks inside of piece
+
+
+ V mark
+
+
+ buttonGroupMarkType
+
+
+
+ -
+
+
+ true
+
+
+ Acute angle that looks outside of piece
+
+
+ V mark 2
+
+
+ buttonGroupMarkType
+
+
+
+
+
+
+ -
+
+
+ true
+
+
+ Angle
+
+
+
-
+
+
+ true
+
+
+ Straightforward
+
+
+ buttonGroupAngleType
+
+
+
+ -
+
+
+ true
+
+
+ Bisector
+
+
+ buttonGroupAngleType
+
+
+
+ -
+
+
+ true
+
+
+ Select if need designate the corner point as a passmark
+
+
+ Intersection
+
+
+ buttonGroupAngleType
+
+
+
+ -
+
+
+ true
+
+
+ Select if need designate the corner point as a passmark. Show only left passmark.
+
+
+ Intersection (only left)
+
+
+ buttonGroupAngleType
+
+
+
+ -
+
+
+ true
+
+
+ Select if need designate the corner point as a passmark. Show only right passmark.
+
+
+ Intersection (only right)
+
+
+ buttonGroupAngleType
+
+
+
+ -
+
+
+ true
+
+
+ Select if need designate the corner point as a passmark
+
+
+ Intersection 2
+
+
+ buttonGroupAngleType
+
+
+
+ -
+
+
+ true
+
+
+ Select if need designate the corner point as a passmark. Show only left passmark.
+
+
+ Intersection 2 (only left)
+
+
+ buttonGroupAngleType
+
+
+
+ -
+
+
+ true
+
+
+ Select if need designate the corner point as a passmark. Show only right passmark.
+
+
+ Intersection 2 (only right)
+
+
+ buttonGroupAngleType
+
+
+
+
+
+
+
-
- false
+ true
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.
@@ -1422,8 +1652,8 @@
accept()
- 248
- 254
+ 257
+ 573
157
@@ -1438,8 +1668,8 @@
reject()
- 316
- 260
+ 325
+ 573
286
diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp
index 7e2cd8af0..a8658bfee 100644
--- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp
+++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp
@@ -135,6 +135,7 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, quint32 toolId,
m_timerWidth(new QTimer(this)),
m_timerWidthBefore(new QTimer(this)),
m_timerWidthAfter(new QTimer(this)),
+ m_timerPassmarkLength(new QTimer(this)),
m_saWidth(0),
m_templateLines(),
m_undoStack(),
@@ -531,6 +532,22 @@ void DialogSeamAllowance::CheckState()
}
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);
uiTabGrainline->lineEditRotFormula->blockSignals(true);
uiTabGrainline->lineEditLenFormula->blockSignals(true);
+ uiTabPassmarks->plainTextEditPassmarkLength->blockSignals(true);
DialogTool::closeEvent(event);
}
@@ -989,28 +1007,19 @@ void DialogSeamAllowance::NodeChanged(int index)
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::PassmarkChanged(int index)
{
- uiTabPassmarks->radioButtonOneLine->setDisabled(true);
- uiTabPassmarks->radioButtonTwoLines->setDisabled(true);
- uiTabPassmarks->radioButtonThreeLines->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->groupBoxMarkType->setDisabled(true);
+ uiTabPassmarks->groupBoxAngleType->setDisabled(true);
+ uiTabPassmarks->groupBoxManualLength->setDisabled(true);
uiTabPassmarks->checkBoxShowSecondPassmark->setDisabled(true);
uiTabPassmarks->checkBoxShowSecondPassmark->blockSignals(true);
+ uiTabPassmarks->groupBoxManualLength->blockSignals(true);
uiTabPassmarks->groupBoxMarkType->blockSignals(true);
uiTabPassmarks->groupBoxAngleType->blockSignals(true);
+ uiTabPassmarks->groupBoxManualLength->setChecked(false);
+
if (index != -1)
{
const VPiece piece = CreatePiece();
@@ -1019,13 +1028,40 @@ void DialogSeamAllowance::PassmarkChanged(int index)
{
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
- uiTabPassmarks->radioButtonOneLine->setEnabled(true);
- uiTabPassmarks->radioButtonTwoLines->setEnabled(true);
- uiTabPassmarks->radioButtonThreeLines->setEnabled(true);
- uiTabPassmarks->radioButtonTMark->setEnabled(true);
- uiTabPassmarks->radioButtonVMark->setEnabled(true);
- uiTabPassmarks->radioButtonVMark2->setEnabled(true);
+ uiTabPassmarks->groupBoxMarkType->setEnabled(true);
switch(node.GetPassmarkLineType())
{
@@ -1052,14 +1088,7 @@ void DialogSeamAllowance::PassmarkChanged(int index)
}
// Angle type
- uiTabPassmarks->radioButtonStraightforward->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);
+ uiTabPassmarks->groupBoxAngleType->setEnabled(true);
switch(node.GetPassmarkAngleType())
{
@@ -1098,7 +1127,7 @@ void DialogSeamAllowance::PassmarkChanged(int index)
}
uiTabPassmarks->checkBoxShowSecondPassmark->blockSignals(false);
-
+ uiTabPassmarks->groupBoxManualLength->blockSignals(false);
uiTabPassmarks->groupBoxMarkType->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(rowItem->data(Qt::UserRole));
+ rowNode.SetManualPassmarkLength(uiTabPassmarks->groupBoxManualLength->isChecked());
+ rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
+ EvalPassmarkLength();
+ }
+ }
+}
+
//---------------------------------------------------------------------------------------------------------------------
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(""));
+ flagFormulaPassmarkLength = true;
+ }
+ }
+}
+
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::FXWidth()
{
@@ -2192,6 +2267,19 @@ void DialogSeamAllowance::FXWidthAfter()
}
}
+//---------------------------------------------------------------------------------------------------------------------
+void DialogSeamAllowance::FXPassmarkLength()
+{
+ QScopedPointer 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()
{
@@ -2212,6 +2300,13 @@ void DialogSeamAllowance::DeployWidthAfterFormulaTextEdit()
m_formulaBaseWidthAfter);
}
+//---------------------------------------------------------------------------------------------------------------------
+void DialogSeamAllowance::DeployPassmarkLength()
+{
+ DeployFormula(this, uiTabPassmarks->plainTextEditPassmarkLength, uiTabPassmarks->pushButtonGrowPassmarkLength,
+ m_formulaBasePassmarkLength);
+}
+
//---------------------------------------------------------------------------------------------------------------------
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(rowItem->data(Qt::UserRole));
+ rowNode.SetFormulaPassmarkLength(formula);
+ rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
+ }
+ }
+}
+
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitFancyTabBar()
{
@@ -3035,6 +3146,15 @@ void DialogSeamAllowance::InitPinsTab()
//---------------------------------------------------------------------------------------------------------------------
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();
connect(uiTabPassmarks->comboBoxPassmarks, QOverload::of(&QComboBox::currentIndexChanged),
this, &DialogSeamAllowance::PassmarkChanged);
@@ -3045,6 +3165,15 @@ void DialogSeamAllowance::InitPassmarksTab()
this, &DialogSeamAllowance::PassmarkAngleTypeChanged);
connect(uiTabPassmarks->checkBoxShowSecondPassmark, &QCheckBox::stateChanged, this,
&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);
}
+//---------------------------------------------------------------------------------------------------------------------
+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()
{
diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h
index d569151e8..b7710df56 100644
--- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h
+++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.h
@@ -134,18 +134,22 @@ private slots:
void EnabledGrainline();
void EnabledDetailLabel();
void EnabledPatternLabel();
+ void EnabledManualPassmarkLength();
void EvalWidth();
void EvalWidthBefore();
void EvalWidthAfter();
+ void EvalPassmarkLength();
void FXWidth();
void FXWidthBefore();
void FXWidthAfter();
+ void FXPassmarkLength();
void DeployWidthFormulaTextEdit();
void DeployWidthBeforeFormulaTextEdit();
void DeployWidthAfterFormulaTextEdit();
+ void DeployPassmarkLength();
void GrainlinePinPointChanged();
void DetailPinPointChanged();
@@ -185,6 +189,7 @@ private:
bool flagPLFormulas;
bool flagFormulaBefore;
bool flagFormulaAfter;
+ bool flagFormulaPassmarkLength{true};
bool flagMainPathIsValid;
bool flagName;
bool flagFormula;
@@ -204,10 +209,12 @@ private:
int m_formulaBaseWidth;
int m_formulaBaseWidthBefore;
int m_formulaBaseWidthAfter;
+ int m_formulaBasePassmarkLength{0};
QTimer *m_timerWidth;
QTimer *m_timerWidthBefore;
QTimer *m_timerWidthAfter;
+ QTimer *m_timerPassmarkLength;
qreal m_saWidth;
QVector m_templateLines;
@@ -236,6 +243,7 @@ private:
void UpdateNodeSABefore(const QString &formula);
void UpdateNodeSAAfter(const QString &formula);
+ void UpdateNodePassmarkLength(const QString &formula);
void InitFancyTabBar();
void InitMainPathTab();
@@ -255,6 +263,7 @@ private:
void InitAllPinComboboxes();
void SetFormulaSAWidth(const QString &formula);
+ void SetFormularPassmarkLength(const QString &formula);
void SetGrainlineAngle(QString angleFormula);
void SetGrainlineLength(QString lengthFormula);
@@ -285,7 +294,7 @@ inline bool DialogSeamAllowance::IsValid() const
{
return flagName && flagMainPathIsValid && flagFormula && flagFormulaBefore && flagFormulaAfter
&& (flagGFormulas || flagGPin) && flagDLAngle && (flagDLFormulas || flagDPin) && flagPLAngle
- && (flagPLFormulas || flagPPin);
+ && (flagPLFormulas || flagPPin) && flagFormulaPassmarkLength;
}
#endif // DIALOGSEAMALLOWANCE_H
diff --git a/src/libs/vtools/dialogs/tools/piece/tabs/tabpassmarks.ui b/src/libs/vtools/dialogs/tools/piece/tabs/tabpassmarks.ui
index eba4bbbc3..c0322f180 100644
--- a/src/libs/vtools/dialogs/tools/piece/tabs/tabpassmarks.ui
+++ b/src/libs/vtools/dialogs/tools/piece/tabs/tabpassmarks.ui
@@ -6,8 +6,8 @@
0
0
- 352
- 594
+ 394
+ 552
@@ -24,11 +24,11 @@
0
0
- 332
- 574
+ 374
+ 532
-
+
-
@@ -47,236 +47,469 @@
-
-
+
true
- Marks
+ Manual length
-
+
+ true
+
+
+ true
+
+
-
-
-
- false
-
-
- One line
-
-
- buttonGroupLineType
-
-
+
+
-
+
+
+ true
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+
+
+ 255
+ 0
+ 0
+
+
+
+
+
+
+
+
+ 255
+ 0
+ 0
+
+
+
+
+
+
+
+
+ 159
+ 158
+ 158
+
+
+
+
+
+
+
+ Length:
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ true
+
+
+ Formula wizard
+
+
+ f(x)
+
+
+
+ :/icon/24x24/fx.png:/icon/24x24/fx.png
+
+
+
+ 24
+ 24
+
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 36
+ 75
+ true
+
+
+
+ =
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 87
+ 0
+
+
+
+ Value
+
+
+
+
+
+ _
+
+
+
+
-
-
-
- false
-
-
- Two lines
-
-
- buttonGroupLineType
-
-
-
- -
-
-
- false
-
-
- Three lines
-
-
- buttonGroupLineType
-
-
-
- -
-
-
- false
-
-
- T mark
-
-
- buttonGroupLineType
-
-
-
- -
-
-
- false
-
-
- Acute angle that looks intside of piece
-
-
- V mark
-
-
- buttonGroupLineType
-
-
-
- -
-
-
- false
-
-
- Acute angle that looks outside of piece
-
-
- V mark 2
-
-
- buttonGroupLineType
-
-
+
+
-
+
+
+ true
+
+
+
+ 0
+ 0
+
+
+
+
+ 16777215
+ 28
+
+
+
+ Calculation
+
+
+ true
+
+
+
+ -
+
+
+ true
+
+
+
+ 18
+ 18
+
+
+
+
+ 0
+ 0
+
+
+
+ <html><head/><body><p>Show full calculation in message box</p></body></html>
+
+
+
+
+
+
+ ../../../../
+
+
+
+ 16
+ 16
+
+
+
+ true
+
+
+
+
-
-
-
- Angle
-
-
-
-
-
-
- false
-
-
- Straightforward
-
-
- buttonGroupAngleType
-
-
-
- -
-
-
- false
-
-
- Bisector
-
-
- buttonGroupAngleType
-
-
-
- -
-
-
- false
-
-
- Select if need designate the corner point as a passmark
-
-
- Intersection
-
-
- buttonGroupAngleType
-
-
-
- -
-
-
- false
-
-
- Select if need designate the corner point as a passmark. Show only left passmark.
-
-
- Intersection (only left)
-
-
- buttonGroupAngleType
-
-
-
- -
-
-
- false
-
-
- Select if need designate the corner point as a passmark. Show only right passmark.
-
-
- Intersection (only right)
-
-
- buttonGroupAngleType
-
-
-
- -
-
-
- false
-
-
- Select if need designate the corner point as a passmark
-
-
- Intersection 2
-
-
- buttonGroupAngleType
-
-
-
- -
-
-
- false
-
-
- Select if need designate the corner point as a passmark. Show only left passmark.
-
-
- Intersection 2 (only left)
-
-
- buttonGroupAngleType
-
-
-
- -
-
-
- false
-
-
- Select if need designate the corner point as a passmark. Show only right passmark.
-
-
- Intersection 2 (only right)
-
-
- buttonGroupAngleType
-
-
-
-
-
+
+ -
+
+
+ true
+
+
+ Marks
+
+
+
-
+
+
+ true
+
+
+ One line
+
+
+ buttonGroupLineType
+
+
+
+ -
+
+
+ true
+
+
+ Two lines
+
+
+ buttonGroupLineType
+
+
+
+ -
+
+
+ true
+
+
+ Three lines
+
+
+ buttonGroupLineType
+
+
+
+ -
+
+
+ true
+
+
+ T mark
+
+
+ buttonGroupLineType
+
+
+
+ -
+
+
+ true
+
+
+ Acute angle that looks intside of piece
+
+
+ V mark
+
+
+ buttonGroupLineType
+
+
+
+ -
+
+
+ true
+
+
+ Acute angle that looks outside of piece
+
+
+ V mark 2
+
+
+ buttonGroupLineType
+
+
+
+
+
+
+ -
+
+
+ true
+
+
+ Angle
+
+
+
-
+
+
+ true
+
+
+ Straightforward
+
+
+ buttonGroupAngleType
+
+
+
+ -
+
+
+ true
+
+
+ Bisector
+
+
+ buttonGroupAngleType
+
+
+
+ -
+
+
+ true
+
+
+ Select if need designate the corner point as a passmark
+
+
+ Intersection
+
+
+ buttonGroupAngleType
+
+
+
+ -
+
+
+ true
+
+
+ Select if need designate the corner point as a passmark. Show only left passmark.
+
+
+ Intersection (only left)
+
+
+ buttonGroupAngleType
+
+
+
+ -
+
+
+ true
+
+
+ Select if need designate the corner point as a passmark. Show only right passmark.
+
+
+ Intersection (only right)
+
+
+ buttonGroupAngleType
+
+
+
+ -
+
+
+ true
+
+
+ Select if need designate the corner point as a passmark
+
+
+ Intersection 2
+
+
+ buttonGroupAngleType
+
+
+
+ -
+
+
+ true
+
+
+ Select if need designate the corner point as a passmark. Show only left passmark.
+
+
+ Intersection 2 (only left)
+
+
+ buttonGroupAngleType
+
+
+
+ -
+
+
+ true
+
+
+ Select if need designate the corner point as a passmark. Show only right passmark.
+
+
+ Intersection 2 (only right)
+
+
+ buttonGroupAngleType
+
+
+
+
+
+
+
-
- false
+ true
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.
@@ -305,7 +538,16 @@
-
+
+
+ VPlainTextEdit
+ QPlainTextEdit
+
+
+
+
+
+
diff --git a/src/libs/vtools/tools/vabstracttool.cpp b/src/libs/vtools/tools/vabstracttool.cpp
index b55b7c948..b8b0a3e0f 100644
--- a/src/libs/vtools/tools/vabstracttool.cpp
+++ b/src/libs/vtools/tools/vabstracttool.cpp
@@ -584,6 +584,11 @@ QDomElement VAbstractTool::AddSANode(VAbstractPattern *doc, const QString &tagNa
doc->SetAttributeOrRemoveIf(nod, VAbstractPattern::AttrNodeShowSecondPassmark, 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;
}