New notch type - Check Notch. Control a notch width and angle with formulas.

This commit is contained in:
Roman Telezhynskyi 2023-05-06 20:01:15 +03:00
parent 66e01d9994
commit 598682e57b
39 changed files with 4522 additions and 1872 deletions

View File

@ -25,6 +25,8 @@
- [smart-pattern/valentina#163] Show/hide grainline when export.
- Improve calculating notches.
- Simplify number of versions for DXF AAMA/ASTM.
- New notch type - Check Notch.
- Control a notch width and angle with formulas.
# Valentina 0.7.52 September 12, 2022
- Fix crash when default locale is ru.

View File

@ -691,6 +691,7 @@ auto VPLayoutFileReader::ReadNotch() -> VLayoutPassmark
passmark.isBuiltIn = ReadAttributeBool(attribs, ML::AttrBuiltIn, falseStr);
passmark.baseLine = StringToLine(ReadAttributeEmptyString(attribs, ML::AttrBaseLine));
passmark.lines = StringToLines(ReadAttributeEmptyString(attribs, ML::AttrPath));
passmark.isClockwiseOpening = ReadAttributeBool(attribs, ML::AttrClockwiseOpening, falseStr);
QString defaultType = QString::number(static_cast<int>(PassmarkLineType::OneLine));
passmark.type = static_cast<PassmarkLineType>(ReadAttributeUInt(attribs, ML::AttrType, defaultType));

View File

@ -334,6 +334,8 @@ void VPLayoutFileWriter::WritePiece(const VPPiecePtr &piece)
SetAttribute(ML::AttrType, static_cast<int>(passmark.type));
SetAttribute(ML::AttrBaseLine, LineToString(passmark.baseLine));
SetAttribute(ML::AttrPath, LinesToString(passmark.lines));
SetAttributeOrRemoveIf<bool>(ML::AttrClockwiseOpening, passmark.isClockwiseOpening,
[](bool clockwise) noexcept { return not clockwise; });
writeEndElement();
}
writeEndElement();

View File

@ -113,6 +113,7 @@ const QString AttrX = QStringLiteral("x"); // NOLINT(cert-err
const QString AttrY = QStringLiteral("y"); // NOLINT(cert-err58-cpp)
const QString AttrTurnPoint = QStringLiteral("turnPoint"); // NOLINT(cert-err58-cpp)
const QString AttrCurvePoint = QStringLiteral("curvePoint"); // NOLINT(cert-err58-cpp)
const QString AttrClockwiseOpening = QStringLiteral("clockwiseOpening"); // NOLINT(cert-err58-cpp)
const QString oneWayUpStr = QStringLiteral("oneWayUp"); // NOLINT(cert-err58-cpp)
const QString oneWayDownStr = QStringLiteral("oneWayDown"); // NOLINT(cert-err58-cpp)

View File

@ -118,6 +118,7 @@ extern const QString AttrX;
extern const QString AttrY;
extern const QString AttrTurnPoint;
extern const QString AttrCurvePoint;
extern const QString AttrClockwiseOpening;
extern const QString oneWayUpStr;
extern const QString oneWayDownStr;

View File

@ -138,20 +138,22 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
ui->checkBoxPatternReadOnly->setDisabled(true);
}
//----------------------- Passmark length
m_variables = pattern->DataMeasurements().keys() + pattern->DataIncrements().keys();
m_completer = new QCompleter(m_variables, this);
m_completer->setCompletionMode(QCompleter::PopupCompletion);
m_completer->setModelSorting(QCompleter::UnsortedModel);
m_completer->setFilterMode(Qt::MatchContains);
m_completer->setCaseSensitivity(Qt::CaseSensitive);
connect(m_completer, QOverload<const QString &>::of(&QCompleter::activated), this, [this]()
//----------------------- Passmark length
m_completerLength = new QCompleter(m_variables, this);
m_completerLength->setCompletionMode(QCompleter::PopupCompletion);
m_completerLength->setModelSorting(QCompleter::UnsortedModel);
m_completerLength->setFilterMode(Qt::MatchContains);
m_completerLength->setCaseSensitivity(Qt::CaseSensitive);
connect(m_completerLength, QOverload<const QString &>::of(&QCompleter::activated), this,
[this]()
{
ValidatePassmarkLength();
DescEdited();
});
ui->lineEditPassmarkLength->setCompleter(m_completer);
ui->lineEditPassmarkLength->setCompleter(m_completerLength);
connect(ui->lineEditPassmarkLength, &QLineEdit::textEdited, this, [this]()
{
ValidatePassmarkLength();
@ -163,6 +165,32 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
ui->lineEditPassmarkLength->setText(m_oldPassmarkLength);
ValidatePassmarkLength();
//----------------------- Passmark width
m_completerWidth = new QCompleter(m_variables, this);
m_completerWidth->setCompletionMode(QCompleter::PopupCompletion);
m_completerWidth->setModelSorting(QCompleter::UnsortedModel);
m_completerWidth->setFilterMode(Qt::MatchContains);
m_completerWidth->setCaseSensitivity(Qt::CaseSensitive);
connect(m_completerWidth, QOverload<const QString &>::of(&QCompleter::activated), this,
[this]()
{
ValidatePassmarkWidth();
DescEdited();
});
ui->lineEditPassmarkWidth->setCompleter(m_completerWidth);
connect(ui->lineEditPassmarkWidth, &QLineEdit::textEdited, this,
[this]()
{
ValidatePassmarkWidth();
DescEdited();
});
ui->lineEditPassmarkWidth->installEventFilter(this);
m_oldPassmarkWidth = doc->GetPassmarkWidthVariable();
ui->lineEditPassmarkWidth->setText(m_oldPassmarkWidth);
ValidatePassmarkWidth();
//Initialization change value. Set to default value after initialization
m_defaultChanged = false;
m_securityChanged = false;
@ -189,7 +217,22 @@ auto DialogPatternProperties::eventFilter(QObject *object, QEvent *event) -> boo
auto *keyEvent = static_cast<QKeyEvent *>(event); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
if ((keyEvent->key() == Qt::Key_Space) && ((keyEvent->modifiers() & Qt::ControlModifier) != 0U))
{
m_completer->complete();
m_completerLength->complete();
return true;
}
}
return false;// clazy:exclude=base-class-event
}
if (ui->lineEditPassmarkWidth == qobject_cast<QLineEdit *>(object))
{
if (event->type() == QEvent::KeyPress)
{
auto *keyEvent = static_cast<QKeyEvent *>(event); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast)
if ((keyEvent->key() == Qt::Key_Space) && ((keyEvent->modifiers() & Qt::ControlModifier) != 0U))
{
m_completerWidth->complete();
return true;
}
}
@ -240,14 +283,27 @@ void DialogPatternProperties::SaveDescription()
m_doc->SetDescription(ui->plainTextEditDescription->document()->toPlainText());
m_doc->SetLabelPrefix(qvariant_cast<QString>(ui->comboBoxLabelLanguage->currentData()));
m_doc->SetPassmarkLengthVariable(ui->lineEditPassmarkLength->text());
m_doc->SetPassmarkWidthVariable(ui->lineEditPassmarkWidth->text());
m_doc->SetDefaultPieceLabelPath(ui->lineEditPieceLabelPath->text());
if (m_oldPassmarkLength != ui->lineEditPassmarkLength->text())
const bool lengthChanged = m_oldPassmarkLength != ui->lineEditPassmarkLength->text();
const bool widthChanged = m_oldPassmarkWidth != ui->lineEditPassmarkWidth->text();
if (lengthChanged || widthChanged)
{
emit UpddatePieces();
if (lengthChanged)
{
m_oldPassmarkLength = ui->lineEditPassmarkLength->text();
}
if (widthChanged)
{
m_oldPassmarkWidth = ui->lineEditPassmarkWidth->text();
}
}
m_descriptionChanged = false;
emit m_doc->patternChanged(false);
}
@ -285,6 +341,26 @@ void DialogPatternProperties::ValidatePassmarkLength() const
ui->lineEditPassmarkLength->setPalette(palette);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::ValidatePassmarkWidth() const
{
const QString text = ui->lineEditPassmarkWidth->text();
QPalette palette = ui->lineEditPassmarkWidth->palette();
const QPalette::ColorRole foregroundRole = ui->lineEditPassmarkWidth->foregroundRole();
QRegularExpression rx(NameRegExp());
if (not text.isEmpty())
{
palette.setColor(foregroundRole, rx.match(text).hasMatch() && m_variables.contains(text) ? Qt::black : Qt::red);
}
else
{
palette.setColor(foregroundRole, Qt::black);
}
ui->lineEditPassmarkWidth->setPalette(palette);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::InitImage()
{

View File

@ -79,9 +79,11 @@ private:
QAction *m_changeImageAction{nullptr};
QAction *m_saveImageAction{nullptr};
QAction *m_showImageAction{nullptr};
QCompleter *m_completer{nullptr};
QCompleter *m_completerLength{nullptr};
QCompleter *m_completerWidth{nullptr};
QStringList m_variables{};
QString m_oldPassmarkLength{};
QString m_oldPassmarkWidth{};
QPointer<QTemporaryFile> m_tmpImage{};
void SaveDescription();
@ -90,6 +92,7 @@ private:
void InitImage();
void ValidatePassmarkLength() const;
void ValidatePassmarkWidth() const;
};
#endif // DIALOGPATTERNPROPERTIES_H

View File

@ -122,6 +122,20 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Passmark width:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEditPassmarkWidth">
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>

View File

@ -115,6 +115,7 @@
<xs:attribute type="NotchType" name="type" use="optional"/>
<xs:attribute type="LinePath" name="baseLine" use="optional"/>
<xs:attribute type="LinesPath" name="path" use="optional"/>
<xs:attribute type="xs:boolean" name="clockwiseOpening" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
@ -309,6 +310,7 @@
<xs:attribute type="NotchType" name="type" use="optional"/>
<xs:attribute type="LinePath" name="baseLine" use="optional"/>
<xs:attribute type="LinesPath" name="path" use="optional"/>
<xs:attribute type="xs:boolean" name="clockwiseOpening" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
@ -474,22 +476,24 @@
</xs:simpleType>
<xs:simpleType name="NotchType">
<xs:restriction base="xs:unsignedInt">
<xs:enumeration value="0"/>
<!--OneLine-->
<xs:enumeration value="1"/>
<xs:enumeration value="0"/>
<!--TwoLines-->
<xs:enumeration value="2"/>
<xs:enumeration value="1"/>
<!--ThreeLines-->
<xs:enumeration value="3"/>
<xs:enumeration value="2"/>
<!--TMark-->
<xs:enumeration value="4"/>
<xs:enumeration value="3"/>
<!--VMark-->
<xs:enumeration value="5"/>
<xs:enumeration value="4"/>
<!--VMark2-->
<xs:enumeration value="6"/>
<xs:enumeration value="5"/>
<!--UMark-->
<xs:enumeration value="7"/>
<xs:enumeration value="6"/>
<!--BoxMark-->
<xs:enumeration value="7"/>
<!--CheckMark-->
<xs:enumeration value="8"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="CurvePenStyle">

View File

@ -409,6 +409,7 @@
<xs:attribute name="passmarkLine" type="passmarkLineType"/>
<xs:attribute name="passmarkAngle" type="passmarkAngleType"/>
<xs:attribute name="showSecondPassmark" type="xs:boolean"/>
<xs:attribute name="passmarkClockwiseOpening" type="xs:boolean"/>
<xs:attribute name="allowCollapse" type="xs:boolean"/>
<xs:attribute name="checkWidth" type="xs:string"/>
<xs:attribute name="checkHeight" type="xs:string"/>
@ -416,6 +417,10 @@
<xs:attribute name="checkHeightReference" type="checkReference"/>
<xs:attribute name="manualPassmarkLength" type="xs:boolean"/>
<xs:attribute name="passmarkLength" type="xs:string"/>
<xs:attribute name="manualPassmarkWidth" type="xs:boolean"/>
<xs:attribute name="passmarkWidth" type="xs:string"/>
<xs:attribute name="manualPassmarkAngle" type="xs:boolean"/>
<xs:attribute name="passmarkAngleFormula" type="xs:string"/>
<xs:attribute name="singlePassmarkCuttingStop" type="cuttingStop"/>
<xs:attribute name="leftPassmarkCuttingStop" type="cuttingStop"/>
<xs:attribute name="rightPassmarkCuttingStop" type="cuttingStop"/>
@ -473,9 +478,14 @@
<xs:attribute name="passmarkLine" type="passmarkLineType"/>
<xs:attribute name="passmarkAngle" type="passmarkAngleType"/>
<xs:attribute name="showSecondPassmark" type="xs:boolean"/>
<xs:attribute name="passmarkClockwiseOpening" type="xs:boolean"/>
<xs:attribute name="allowCollapse" type="xs:boolean"/>
<xs:attribute name="manualPassmarkLength" type="xs:boolean"/>
<xs:attribute name="passmarkLength" type="xs:string"/>
<xs:attribute name="manualPassmarkWidth" type="xs:boolean"/>
<xs:attribute name="passmarkWidth" type="xs:string"/>
<xs:attribute name="manualPassmarkAngle" type="xs:boolean"/>
<xs:attribute name="passmarkAngleFormula" type="xs:string"/>
<xs:attribute name="singlePassmarkCuttingStop" type="cuttingStop"/>
<xs:attribute name="leftPassmarkCuttingStop" type="cuttingStop"/>
<xs:attribute name="rightPassmarkCuttingStop" type="cuttingStop"/>
@ -673,6 +683,7 @@
<xs:attribute name="passmarkLine" type="passmarkLineType"/>
<xs:attribute name="passmarkAngle" type="passmarkAngleType"/>
<xs:attribute name="showSecondPassmark" type="xs:boolean"/>
<xs:attribute name="passmarkClockwiseOpening" type="xs:boolean"/>
<xs:attribute name="allowCollapse" type="xs:boolean"/>
<xs:attribute name="checkWidth" type="xs:string"/>
<xs:attribute name="checkHeight" type="xs:string"/>
@ -681,6 +692,10 @@
<xs:attribute name="checkStop" type="cuttingStop"/>
<xs:attribute name="manualPassmarkLength" type="xs:boolean"/>
<xs:attribute name="passmarkLength" type="xs:string"/>
<xs:attribute name="manualPassmarkWidth" type="xs:boolean"/>
<xs:attribute name="passmarkWidth" type="xs:string"/>
<xs:attribute name="manualPassmarkAngle" type="xs:boolean"/>
<xs:attribute name="passmarkAngleFormula" type="xs:string"/>
<xs:attribute name="singlePassmarkCuttingStop" type="cuttingStop"/>
<xs:attribute name="leftPassmarkCuttingStop" type="cuttingStop"/>
<xs:attribute name="rightPassmarkCuttingStop" type="cuttingStop"/>
@ -1023,6 +1038,7 @@
<xs:enumeration value="vMark2"/>
<xs:enumeration value="uMark"/>
<xs:enumeration value="boxMark"/>
<xs:enumeration value="checkMark"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="passmarkAngleType">

View File

@ -127,6 +127,7 @@ const QString VAbstractPattern::AttrNodePassmark = QStringLiteral("passmark
const QString VAbstractPattern::AttrNodePassmarkLine = QStringLiteral("passmarkLine");
const QString VAbstractPattern::AttrNodePassmarkAngle = QStringLiteral("passmarkAngle");
const QString VAbstractPattern::AttrNodeShowSecondPassmark = QStringLiteral("showSecondPassmark");
const QString VAbstractPattern::AttrNodePassmarkOpening = QStringLiteral("passmarkClockwiseOpening");
const QString VAbstractPattern::AttrNodeTurnPoint = QStringLiteral("turnPoint");
const QString VAbstractPattern::AttrSABefore = QStringLiteral("before");
const QString VAbstractPattern::AttrSAAfter = QStringLiteral("after");
@ -139,6 +140,10 @@ 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::AttrManualPassmarkWidth = QStringLiteral("manualPassmarkWidth");
const QString VAbstractPattern::AttrPassmarkWidth = QStringLiteral("passmarkWidth");
const QString VAbstractPattern::AttrManualPassmarkAngle = QStringLiteral("manualPassmarkAngle");
const QString VAbstractPattern::AttrPassmarkAngle = QStringLiteral("passmarkAngleFormula");
const QString VAbstractPattern::AttrOpacity = QStringLiteral("opacity");
const QString VAbstractPattern::AttrTags = QStringLiteral("tags");
const QString VAbstractPattern::AttrTransform = QStringLiteral("transform");
@ -786,28 +791,37 @@ auto VAbstractPattern::ParseSANode(const QDomElement &domElement) -> VPieceNode
const bool reverse = VDomDocument::GetParametrUInt(domElement, VAbstractPattern::AttrNodeReverse, QChar('0'));
const bool excluded = VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrNodeExcluded, falseStr);
const bool uniqeness = VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrCheckUniqueness, trueStr);
const QString saBefore = VDomDocument::GetParametrString(domElement, VAbstractPattern::AttrSABefore,
currentSeamAllowance);
const QString saAfter = VDomDocument::GetParametrString(domElement, VAbstractPattern::AttrSAAfter,
currentSeamAllowance);
const PieceNodeAngle angle = static_cast<PieceNodeAngle>(VDomDocument::GetParametrUInt(domElement, AttrAngle,
QChar('0')));
const QString saBefore =
VDomDocument::GetParametrString(domElement, VAbstractPattern::AttrSABefore, currentSeamAllowance);
const QString saAfter =
VDomDocument::GetParametrString(domElement, VAbstractPattern::AttrSAAfter, currentSeamAllowance);
const PieceNodeAngle angle =
static_cast<PieceNodeAngle>(VDomDocument::GetParametrUInt(domElement, AttrAngle, QChar('0')));
const bool passmark = VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrNodePassmark, falseStr);
const PassmarkLineType passmarkLine = StringToPassmarkLineType(VDomDocument::GetParametrString(domElement,
VAbstractPattern::AttrNodePassmarkLine,
strOne));
const PassmarkAngleType passmarkAngle = StringToPassmarkAngleType(VDomDocument::GetParametrString(domElement,
VAbstractPattern::AttrNodePassmarkAngle,
strStraightforward));
const PassmarkLineType passmarkLine = StringToPassmarkLineType(
VDomDocument::GetParametrString(domElement, VAbstractPattern::AttrNodePassmarkLine, strOne));
const PassmarkAngleType passmarkAngleType = StringToPassmarkAngleType(
VDomDocument::GetParametrString(domElement, VAbstractPattern::AttrNodePassmarkAngle, strStraightforward));
const bool showSecond =
VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrNodeShowSecondPassmark, trueStr);
const bool passmarkOpening =
VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrNodePassmarkOpening, falseStr);
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 bool manualPassmarkWidth =
VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrManualPassmarkWidth, falseStr);
const QString passmarkWidth = VDomDocument::GetParametrEmptyString(domElement, VAbstractPattern::AttrPassmarkWidth);
const bool manualPassmarkAngle =
VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrManualPassmarkAngle, falseStr);
const QString passmarkAngle = VDomDocument::GetParametrEmptyString(domElement, VAbstractPattern::AttrPassmarkAngle);
const bool turnPoint =
VDomDocument::GetParametrBool(domElement, VAbstractPattern::AttrNodeTurnPoint, trueStr);
@ -850,11 +864,16 @@ auto VAbstractPattern::ParseSANode(const QDomElement &domElement) -> VPieceNode
node.SetExcluded(excluded);
node.SetCheckUniqueness(uniqeness);
node.SetShowSecondPassmark(showSecond);
node.SetPassmarkClockwiseOpening(passmarkOpening);
node.SetPassmark(passmark);
node.SetPassmarkLineType(passmarkLine);
node.SetPassmarkAngleType(passmarkAngle);
node.SetPassmarkAngleType(passmarkAngleType);
node.SetManualPassmarkLength(manualPassmarkLength);
node.SetFormulaPassmarkLength(passmarkLength);
node.SetManualPassmarkWidth(manualPassmarkWidth);
node.SetFormulaPassmarkWidth(passmarkWidth);
node.SetManualPassmarkAngle(manualPassmarkAngle);
node.SetFormulaPassmarkAngle(passmarkAngle);
node.SetTurnPoint(turnPoint);
return node;
@ -1319,6 +1338,31 @@ void VAbstractPattern::SetPassmarkLengthVariable(const QString &name)
}
}
//---------------------------------------------------------------------------------------------------------------------
auto VAbstractPattern::GetPassmarkWidthVariable() const -> QString
{
const QDomElement pattern = documentElement();
if (pattern.isNull())
{
return {};
}
return GetParametrEmptyString(pattern, AttrPassmarkWidth);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetPassmarkWidthVariable(const QString &name)
{
QDomElement pattern = documentElement();
if (not pattern.isNull())
{
SetAttribute(pattern, AttrPassmarkWidth, name);
modified = true;
}
}
//---------------------------------------------------------------------------------------------------------------------
auto VAbstractPattern::GetImage() const -> VPatternImage
{

View File

@ -205,6 +205,9 @@ public:
auto GetPassmarkLengthVariable() const -> QString;
void SetPassmarkLengthVariable(const QString &name);
auto GetPassmarkWidthVariable() const -> QString;
void SetPassmarkWidthVariable(const QString &name);
auto GetImage() const -> VPatternImage;
auto SetImage(const VPatternImage &image) -> bool;
void DeleteImage();
@ -327,6 +330,7 @@ public:
static const QString AttrNodePassmarkLine;
static const QString AttrNodePassmarkAngle;
static const QString AttrNodeShowSecondPassmark;
static const QString AttrNodePassmarkOpening;
static const QString AttrNodeTurnPoint;
static const QString AttrSABefore;
static const QString AttrSAAfter;
@ -339,6 +343,10 @@ public:
static const QString AttrCheckUniqueness;
static const QString AttrManualPassmarkLength;
static const QString AttrPassmarkLength;
static const QString AttrManualPassmarkWidth;
static const QString AttrPassmarkWidth;
static const QString AttrManualPassmarkAngle;
static const QString AttrPassmarkAngle;
static const QString AttrOpacity;
static const QString AttrTags;
static const QString AttrTransform;

View File

@ -89,7 +89,7 @@
// Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer26, (UTF8STRING("26"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer80, (UTF8STRING("80"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer81, (UTF8STRING("81"))) // NOLINT
// Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer82, (UTF8STRING("82"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer82, (UTF8STRING("82"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer83, (UTF8STRING("83"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer84, (UTF8STRING("84"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const UTF8STRING, layer85, (UTF8STRING("85"))) // NOLINT
@ -1175,10 +1175,10 @@ void VDxfEngine::ExportASTMNotch(const QSharedPointer<dx_ifaceBlock> &detailBloc
// Slit notch
notch->layer = *layer4;
break;
case PassmarkLineType::VMark:
case PassmarkLineType::VMark2:
case PassmarkLineType::ExternalVMark:
case PassmarkLineType::InternalVMark:
{ // V-Notch
QLineF boundaryLine(ConstFirst(passmark.lines).p2(), ConstLast(passmark.lines).p2());
QLineF boundaryLine(ConstFirst(passmark.lines).p1(), ConstLast(passmark.lines).p2());
notch->thickness = FromPixel(boundaryLine.length(), m_varInsunits); // width
notch->layer = *layer4;
break;
@ -1207,6 +1207,22 @@ void VDxfEngine::ExportASTMNotch(const QSharedPointer<dx_ifaceBlock> &detailBloc
notch->layer = *layer83;
break;
}
case PassmarkLineType::CheckMark:
{ // Check Notch
const QLineF &line1 = ConstFirst(passmark.lines);
const QLineF &line2 = ConstLast(passmark.lines);
qreal width = QLineF(line1.p1(), line2.p2()).length();
if (not passmark.isClockwiseOpening)
{ // a counter clockwise opening
width *= -1;
}
notch->thickness = FromPixel(width, m_varInsunits); // width
notch->layer = *layer82;
break;
}
case PassmarkLineType::LAST_ONE_DO_NOT_USE:
Q_UNREACHABLE();
break;

View File

@ -36,7 +36,7 @@
#include <QCoreApplication>
const quint32 VLayoutPassmark::streamHeader = 0x943E2759; // CRC-32Q string "VLayoutPassmark"
const quint16 VLayoutPassmark::classVersion = 1;
const quint16 VLayoutPassmark::classVersion = 2;
// Friend functions
//---------------------------------------------------------------------------------------------------------------------
@ -44,14 +44,7 @@ auto operator<<(QDataStream &dataStream, const VLayoutPassmark &data) -> QDataSt
{
dataStream << VLayoutPassmark::streamHeader << VLayoutPassmark::classVersion;
// Added in classVersion = 1
dataStream << data.lines;
dataStream << data.type;
dataStream << data.baseLine;
dataStream << data.isBuiltIn;
// Added in classVersion = 2
dataStream << data.lines << data.type << data.baseLine << data.isBuiltIn << data.isClockwiseOpening;
return dataStream;
}
@ -81,15 +74,12 @@ auto operator>>(QDataStream &dataStream, VLayoutPassmark &data) -> QDataStream &
throw VException(message);
}
dataStream >> data.lines;
dataStream >> data.type;
dataStream >> data.baseLine;
dataStream >> data.isBuiltIn;
dataStream >> data.lines >> data.type >> data.baseLine >> data.isBuiltIn;
// if (actualClassVersion >= 2)
// {
// }
if (actualClassVersion >= 2)
{
dataStream >> data.isClockwiseOpening;
}
return dataStream;
}

View File

@ -70,6 +70,7 @@ struct VLayoutPassmark
PassmarkLineType type{PassmarkLineType::OneLine};
QLineF baseLine{};
bool isBuiltIn{false};
bool isClockwiseOpening{false};
friend auto operator<<(QDataStream& dataStream, const VLayoutPassmark& data) -> QDataStream&;
friend auto operator>>(QDataStream& dataStream, VLayoutPassmark& data) -> QDataStream&;

View File

@ -1556,6 +1556,28 @@ auto VSAPoint::toJson() const -> QJsonObject
pointObject[QLatin1String("angle")] = static_cast<int>(m_angle);
}
if (m_manualPassmarkLength)
{
pointObject[QLatin1String("manualPassmarkLength")] = m_manualPassmarkLength;
pointObject[QLatin1String("passmarkLength")] = m_passmarkLength;
}
if (m_manualPassmarkWidth)
{
pointObject[QLatin1String("manualPassmarkWidth")] = m_manualPassmarkWidth;
pointObject[QLatin1String("passmarkWidth")] = m_passmarkWidth;
}
else
{
pointObject[QLatin1String("passmarkClockwiseOpening")] = m_passmarkClockwiseOpening;
}
if (m_manualPassmarkAngle)
{
pointObject[QLatin1String("manualPassmarkAngle")] = m_manualPassmarkAngle;
pointObject[QLatin1String("passmarkAngle")] = m_passmarkAngle;
}
return pointObject;
}

View File

@ -293,6 +293,7 @@ auto PrepareSAPassmark(const VPiece &piece, const VContainer *pattern, const VPa
layoutPassmark.lines = lines;
layoutPassmark.type = pData.passmarkLineType;
layoutPassmark.isBuiltIn = false;
layoutPassmark.isClockwiseOpening = pData.passmarkSAPoint.IsPassmarkClockwiseOpening();
ok = true;
return layoutPassmark;
@ -354,6 +355,7 @@ auto PreapreBuiltInSAPassmark(const VPiece &piece, const VContainer *pattern, co
layoutPassmark.baseLine = ConstFirst (baseLines);
layoutPassmark.type = pData.passmarkLineType;
layoutPassmark.isBuiltIn = true;
layoutPassmark.isClockwiseOpening = pData.passmarkSAPoint.IsPassmarkClockwiseOpening();
ok = true;
return layoutPassmark;

View File

@ -66,7 +66,12 @@ public:
Q_DECL_CONSTEXPR auto GetAngleType() const -> PieceNodeAngle;
Q_DECL_CONSTEXPR auto IsManualPasskmarkLength() const -> bool;
Q_DECL_CONSTEXPR auto IsManualPasskmarkWidth() const -> bool;
Q_DECL_CONSTEXPR auto IsManualPasskmarkAngle() const -> bool;
Q_DECL_CONSTEXPR auto GetPasskmarkLength() const -> qreal;
Q_DECL_CONSTEXPR auto GetPasskmarkWidth() const -> qreal;
Q_DECL_CONSTEXPR auto GetPasskmarkAngle() const -> qreal;
Q_DECL_RELAXED_CONSTEXPR auto GetSABefore(qreal width) const -> qreal;
Q_DECL_RELAXED_CONSTEXPR auto GetSAAfter(qreal width) const -> qreal;
@ -77,11 +82,19 @@ public:
Q_DECL_RELAXED_CONSTEXPR void SetAngleType(PieceNodeAngle value);
Q_DECL_RELAXED_CONSTEXPR void SetManualPasskmarkLength(bool value);
Q_DECL_RELAXED_CONSTEXPR void SetManualPasskmarkWidth(bool value);
Q_DECL_RELAXED_CONSTEXPR void SetManualPasskmarkAngle(bool value);
Q_DECL_RELAXED_CONSTEXPR void SetPasskmarkLength(qreal value);
Q_DECL_RELAXED_CONSTEXPR void SetPasskmarkWidth(qreal value);
Q_DECL_RELAXED_CONSTEXPR void SetPasskmarkAngle(qreal value);
Q_DECL_RELAXED_CONSTEXPR auto MaxLocalSA(qreal width) const -> qreal;
Q_DECL_RELAXED_CONSTEXPR auto PassmarkLength(qreal width) const -> qreal;
Q_DECL_CONSTEXPR auto IsPassmarkClockwiseOpening() const -> bool;
Q_DECL_RELAXED_CONSTEXPR void SetPassmarkClockwiseOpening(bool clockwise);
auto toJson() const -> QJsonObject;
static constexpr qreal passmarkFactor{0.5};
@ -93,7 +106,12 @@ private:
qreal m_after{-1};
PieceNodeAngle m_angle{PieceNodeAngle::ByLength};
bool m_manualPassmarkLength{false};
bool m_manualPassmarkWidth{false};
bool m_manualPassmarkAngle{false};
qreal m_passmarkLength{0};
qreal m_passmarkWidth{0};
qreal m_passmarkAngle{0};
bool m_passmarkClockwiseOpening{false};
};
Q_DECLARE_METATYPE(VSAPoint) // NOLINT
@ -176,24 +194,72 @@ Q_DECL_CONSTEXPR inline auto VSAPoint::IsManualPasskmarkLength() const -> bool
return m_manualPassmarkLength;
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline auto VSAPoint::IsManualPasskmarkWidth() const -> bool
{
return m_manualPassmarkWidth;
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline auto VSAPoint::IsManualPasskmarkAngle() const -> bool
{
return m_manualPassmarkAngle;
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_RELAXED_CONSTEXPR inline void VSAPoint::SetManualPasskmarkLength(bool value)
{
m_manualPassmarkLength = value;
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_RELAXED_CONSTEXPR inline void VSAPoint::SetManualPasskmarkWidth(bool value)
{
m_manualPassmarkWidth = value;
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_RELAXED_CONSTEXPR inline void VSAPoint::SetManualPasskmarkAngle(bool value)
{
m_manualPassmarkAngle = value;
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline auto VSAPoint::GetPasskmarkLength() const -> qreal
{
return m_passmarkLength;
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline auto VSAPoint::GetPasskmarkWidth() const -> qreal
{
return m_passmarkWidth;
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_CONSTEXPR inline auto VSAPoint::GetPasskmarkAngle() const -> qreal
{
return m_passmarkAngle;
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_RELAXED_CONSTEXPR inline void VSAPoint::SetPasskmarkLength(qreal value)
{
m_passmarkLength = value;
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_RELAXED_CONSTEXPR inline void VSAPoint::SetPasskmarkWidth(qreal value)
{
m_passmarkWidth = value;
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_RELAXED_CONSTEXPR inline void VSAPoint::SetPasskmarkAngle(qreal value)
{
m_passmarkAngle = value;
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_RELAXED_CONSTEXPR inline auto VSAPoint::MaxLocalSA(qreal width) const -> qreal
{
@ -213,6 +279,18 @@ Q_DECL_RELAXED_CONSTEXPR inline auto VSAPoint::PassmarkLength(qreal width) const
return m_passmarkLength;
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_RELAXED_CONSTEXPR inline bool VSAPoint::IsPassmarkClockwiseOpening() const
{
return m_passmarkClockwiseOpening;
}
//---------------------------------------------------------------------------------------------------------------------
Q_DECL_RELAXED_CONSTEXPR inline void VSAPoint::SetPassmarkClockwiseOpening(bool clockwise)
{
m_passmarkClockwiseOpening = clockwise;
}
QT_WARNING_POP
#endif // VSAPOINT_H

View File

@ -328,6 +328,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(const QString, strVMark, (QLatin1String("vMark"))) //
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strVMark2, (QLatin1String("vMark2"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strUMark, (QLatin1String("uMark"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strBoxMark, (QLatin1String("boxMark"))) // NOLINT
Q_GLOBAL_STATIC_WITH_ARGS(const QString, strCheckMark, (QLatin1String("checkMark"))) // NOLINT
//---------------------------------------------------------------------------------------------------------------------
auto PassmarkLineTypeToString(PassmarkLineType type) -> QString
@ -342,14 +343,16 @@ auto PassmarkLineTypeToString(PassmarkLineType type) -> QString
return strThree;
case PassmarkLineType::TMark:
return *strTMark;
case PassmarkLineType::VMark:
case PassmarkLineType::ExternalVMark:
return *strVMark;
case PassmarkLineType::VMark2:
case PassmarkLineType::InternalVMark:
return *strVMark2;
case PassmarkLineType::UMark:
return *strUMark;
case PassmarkLineType::BoxMark:
return *strBoxMark;
case PassmarkLineType::CheckMark:
return *strCheckMark;
default:
break;
}
@ -361,7 +364,7 @@ auto PassmarkLineTypeToString(PassmarkLineType type) -> QString
auto StringToPassmarkLineType(const QString &value) -> PassmarkLineType
{
const QStringList values{strOne, strTwo, strThree, *strTMark, *strVMark,
*strVMark2, *strUMark, *strBoxMark};
*strVMark2, *strUMark, *strBoxMark, *strCheckMark};
switch(values.indexOf(value))
{
@ -374,13 +377,15 @@ auto StringToPassmarkLineType(const QString &value) -> PassmarkLineType
case 3: // strTMark
return PassmarkLineType::TMark;
case 4: // strVMark
return PassmarkLineType::VMark;
return PassmarkLineType::ExternalVMark;
case 5: // strVMark2
return PassmarkLineType::VMark2;
return PassmarkLineType::InternalVMark;
case 6: // strUMark
return PassmarkLineType::UMark;
case 7: // strBoxMark
return PassmarkLineType::BoxMark;
case 8: // strCheckMark
return PassmarkLineType::CheckMark;
default:
break;
}

View File

@ -111,10 +111,11 @@ enum class PassmarkLineType : quint8
TwoLines = 1,
ThreeLines = 2,
TMark = 3,
VMark = 4,
VMark2 = 5,
ExternalVMark = 4,
InternalVMark = 5,
UMark = 6,
BoxMark = 7,
CheckMark = 8,
LAST_ONE_DO_NOT_USE
};

File diff suppressed because it is too large Load Diff

View File

@ -63,6 +63,7 @@ struct VPiecePassmarkData
vsizetype passmarkIndex{-1}; // NOLINT(misc-non-private-member-variables-in-classes)
vidtype id{NULL_ID}; // NOLINT(misc-non-private-member-variables-in-classes)
qreal globalPassmarkLength{0}; // NOLINT(misc-non-private-member-variables-in-classes)
qreal globalPassmarkWidth{0}; // NOLINT(misc-non-private-member-variables-in-classes)
auto toJson() const -> QJsonObject;
};
@ -104,6 +105,17 @@ public:
private:
VPiecePassmarkData m_data{};
bool m_null{true};
auto PassmarkIntersection(const QVector<QPointF> &path, QLineF line, qreal width) const -> QLineF;
auto PassmarkStraightforwardBaseLine(const QPointF &seamPassmarkSAPoint) const -> QVector<QLineF>;
auto PassmarkBisectorBaseLine(PassmarkStatus seamPassmarkType, const QPointF &seamPassmarkSAPoint,
const QVector<QPointF> &seamAllowance) const -> QVector<QLineF>;
auto PassmarkIntersectionBaseLine(const QVector<QPointF> &path, PassmarkSide side) const -> QVector<QLineF>;
auto PassmarkIntersection2BaseLine(const QVector<QPointF> &path, PassmarkSide side) const -> QVector<QLineF>;
auto CreatePassmarkLines(const QVector<QLineF> &lines, const QVector<QPointF> &seamAllowance,
PassmarkSide side) const -> QVector<QLineF>;
};
#endif // VPASSMARK_H

View File

@ -1116,6 +1116,7 @@ auto VPiece::CreatePassmark(const QVector<VPieceNode> &path, vsizetype previousI
passmarkData.passmarkIndex = passmarkIndex;
passmarkData.id = path.at(passmarkIndex).GetId();
passmarkData.globalPassmarkLength = ToPixel(GlobalPassmarkLength(data), *data->GetPatternUnit());
passmarkData.globalPassmarkWidth = ToPixel(GlobalPassmarkWidth(data), *data->GetPatternUnit());
// cppcheck-suppress unknownMacro
QT_WARNING_POP
@ -1202,6 +1203,40 @@ auto VPiece::GlobalPassmarkLength(const VContainer *data) const -> qreal
return length;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPiece::GlobalPassmarkWidth(const VContainer *data) const
{
QString passmarkWidthVariable = VAbstractValApplication::VApp()->getCurrentDocument()->GetPassmarkWidthVariable();
if (passmarkWidthVariable.isEmpty())
{
return 0;
}
qreal width = 0;
try
{
QSharedPointer<VInternalVariable> var = data->GetVariable<VInternalVariable>(passmarkWidthVariable);
width = *var->GetValue();
if (VAbstractValApplication::VApp()->toPixel(width) <= accuracyPointOnLine)
{
const QString errorMsg = QObject::tr("Invalid global value for a passmark width. Piece '%1'. Width is "
"less than minimal allowed.")
.arg(GetName());
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
}
}
catch (const VExceptionBadId &)
{
width = 0;
}
return width;
}
//---------------------------------------------------------------------------------------------------------------------
#if !defined(V_NO_ASSERT)
// Use for writing tests

View File

@ -173,6 +173,7 @@ private:
auto DBToJson(const VContainer *data) const -> QJsonObject;
auto GlobalPassmarkLength(const VContainer *data) const -> qreal;
auto GlobalPassmarkWidth(const VContainer *data) const -> qreal;
void TestInternalPathCuttingPathIntersection(const VContainer *data) const;
void TestInternalPathsIntersections(const VContainer *data) const;

View File

@ -317,14 +317,44 @@ void VPieceNode::SetFormulaPassmarkLength(const QString &formula)
}
}
//---------------------------------------------------------------------------------------------------------------------
auto VPieceNode::GetFormulaPassmarkWidth() const -> QString
{
return d->m_formulaPassmarkWidth;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceNode::SetFormulaPassmarkWidth(const QString &formula)
{
if (d->m_typeTool == Tool::NodePoint)
{
d->m_formulaPassmarkWidth = formula;
}
}
//---------------------------------------------------------------------------------------------------------------------
auto VPieceNode::GetFormulaPassmarkAngle() const -> QString
{
return d->m_formulaPassmarkAngle;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceNode::SetFormulaPassmarkAngle(const QString &formula)
{
if (d->m_typeTool == Tool::NodePoint)
{
d->m_formulaPassmarkAngle = formula;
}
}
//---------------------------------------------------------------------------------------------------------------------
auto VPieceNode::GetPassmarkLength(const VContainer *data, Unit unit) const -> qreal
{
if (d->m_manualPassmarkLength)
{
VFormula formula(d->m_formulaPassmarkLength, data);
formula.setCheckZero(false);
formula.setCheckLessThanZero(false);
formula.setCheckZero(true);
formula.setCheckLessThanZero(true);
formula.Eval();
if (formula.error())
@ -349,6 +379,74 @@ auto VPieceNode::GetPassmarkLength(const VContainer *data, Unit unit) const -> q
return -1;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPieceNode::GetPassmarkWidth(const VContainer *data, Unit unit) const -> qreal
{
if (d->m_manualPassmarkWidth)
{
VFormula formula(d->m_formulaPassmarkWidth, data);
formula.setCheckZero(true);
formula.setCheckLessThanZero(false);
formula.Eval();
if (formula.error())
{
QString nodeName;
try
{
nodeName = data->GetGObject(d->m_id)->name();
}
catch (const VExceptionBadId &)
{
}
const QString errorMsg = QObject::tr("Cannot calculate passmark width for point '%1'. Reason: %2.")
.arg(nodeName, formula.Reason());
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
return 0;
}
return ToPixel(formula.getDoubleValue(), unit);
}
return -1;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPieceNode::GetPassmarkAngle(const VContainer *data) const -> qreal
{
if (d->m_manualPassmarkAngle)
{
VFormula formula(d->m_formulaPassmarkAngle, data);
formula.setCheckZero(false);
formula.setCheckLessThanZero(false);
formula.Eval();
if (formula.error())
{
QString nodeName;
try
{
nodeName = data->GetGObject(d->m_id)->name();
}
catch (const VExceptionBadId &)
{
}
const QString errorMsg = QObject::tr("Cannot calculate passmark angle for point '%1'. Reason: %2.")
.arg(nodeName, formula.Reason());
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
return 0;
}
return formula.getDoubleValue();
}
return 0;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPieceNode::GetAngleType() const -> PieceNodeAngle
{
@ -427,6 +525,18 @@ void VPieceNode::SetShowSecondPassmark(bool value)
d->m_isShowSecondPassmark = value;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPieceNode::IsPassmarkClockwiseOpening() const -> bool
{
return d->m_isPassmarkClockwiseOpening;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceNode::SetPassmarkClockwiseOpening(bool value)
{
d->m_isPassmarkClockwiseOpening = value;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPieceNode::IsCheckUniqueness() const -> bool
{
@ -451,6 +561,30 @@ void VPieceNode::SetManualPassmarkLength(bool value)
d->m_manualPassmarkLength = value;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPieceNode::IsManualPassmarkWidth() const -> bool
{
return d->m_manualPassmarkWidth;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceNode::SetManualPassmarkWidth(bool value)
{
d->m_manualPassmarkWidth = value;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPieceNode::IsManualPassmarkAngle() const -> bool
{
return d->m_manualPassmarkAngle;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceNode::SetManualPassmarkAngle(bool value)
{
d->m_manualPassmarkAngle = value;
}
//---------------------------------------------------------------------------------------------------------------------
auto VPieceNode::IsTurnPoint() const -> bool
{

View File

@ -83,7 +83,15 @@ public:
auto GetFormulaPassmarkLength() const -> QString;
void SetFormulaPassmarkLength(const QString &formula);
auto GetFormulaPassmarkWidth() const -> QString;
void SetFormulaPassmarkWidth(const QString &formula);
auto GetFormulaPassmarkAngle() const -> QString;
void SetFormulaPassmarkAngle(const QString &formula);
auto GetPassmarkLength(const VContainer *data, Unit unit) const -> qreal;
auto GetPassmarkWidth(const VContainer *data, Unit unit) const -> qreal;
auto GetPassmarkAngle(const VContainer *data) const -> qreal;
auto GetAngleType() const -> PieceNodeAngle;
void SetAngleType(PieceNodeAngle type);
@ -103,12 +111,21 @@ public:
auto IsShowSecondPassmark() const -> bool;
void SetShowSecondPassmark(bool value);
auto IsPassmarkClockwiseOpening() const -> bool;
void SetPassmarkClockwiseOpening(bool value);
auto IsCheckUniqueness() const -> bool;
void SetCheckUniqueness(bool value);
auto IsManualPassmarkLength() const -> bool;
void SetManualPassmarkLength(bool value);
auto IsManualPassmarkWidth() const -> bool;
void SetManualPassmarkWidth(bool value);
auto IsManualPassmarkAngle() const -> bool;
void SetManualPassmarkAngle(bool value);
auto IsTurnPoint() const -> bool;
void SetTurnPoint(bool value);
private:

View File

@ -92,6 +92,8 @@ public:
QString m_formulaWidthBefore{currentSeamAllowance}; // NOLINT(misc-non-private-member-variables-in-classes)
QString m_formulaWidthAfter{currentSeamAllowance}; // NOLINT(misc-non-private-member-variables-in-classes)
QString m_formulaPassmarkLength{}; // NOLINT(misc-non-private-member-variables-in-classes)
QString m_formulaPassmarkWidth{}; // NOLINT(misc-non-private-member-variables-in-classes)
QString m_formulaPassmarkAngle{}; // NOLINT(misc-non-private-member-variables-in-classes)
PieceNodeAngle m_angleType{PieceNodeAngle::ByLength}; // NOLINT(misc-non-private-member-variables-in-classes)
@ -101,6 +103,7 @@ public:
PassmarkAngleType::Straightforward};
bool m_isShowSecondPassmark{true}; // NOLINT(misc-non-private-member-variables-in-classes)
bool m_isPassmarkClockwiseOpening{false}; // NOLINT(misc-non-private-member-variables-in-classes)
/** @brief m_checkUniqueness need in cases where different points have the same coordinates, become one point.
* By default the check enabled. Disable it only if in a path cannot be used just one point. For example if
@ -108,6 +111,8 @@ public:
bool m_checkUniqueness{true}; // NOLINT(misc-non-private-member-variables-in-classes)
bool m_manualPassmarkLength{false}; // NOLINT(misc-non-private-member-variables-in-classes)
bool m_manualPassmarkWidth{false}; // NOLINT(misc-non-private-member-variables-in-classes)
bool m_manualPassmarkAngle{false}; // NOLINT(misc-non-private-member-variables-in-classes)
bool m_turnPoint{true}; // NOLINT(misc-non-private-member-variables-in-classes)
@ -115,7 +120,7 @@ private:
Q_DISABLE_ASSIGN_MOVE(VPieceNodeData) // NOLINT
static constexpr quint32 streamHeader = 0x2198CBC8; // CRC-32Q string "VPieceNodeData"
static constexpr quint16 classVersion = 2;
static constexpr quint16 classVersion = 3;
};
// See https://stackoverflow.com/a/46719572/3045403
@ -133,7 +138,8 @@ inline auto operator<<(QDataStream &out, const VPieceNodeData &p) -> QDataStream
out << p.m_id << p.m_typeTool << p.m_reverse << p.m_excluded << p.m_isPassmark << p.m_formulaWidthBefore
<< p.m_formulaWidthAfter << p.m_formulaPassmarkLength << p.m_angleType << p.m_passmarkLineType
<< p.m_passmarkAngleType << p.m_isShowSecondPassmark << p.m_checkUniqueness << p.m_manualPassmarkLength
<< p.m_turnPoint;
<< p.m_turnPoint << p.m_formulaPassmarkWidth << p.m_formulaPassmarkAngle << p.m_manualPassmarkWidth
<< p.m_manualPassmarkAngle << p.m_isPassmarkClockwiseOpening;
return out;
}
@ -184,6 +190,12 @@ inline auto operator>>(QDataStream &in, VPieceNodeData &p) -> QDataStream &
in >> p.m_turnPoint;
}
if (actualClassVersion >= 3)
{
in >> p.m_formulaPassmarkWidth >> p.m_formulaPassmarkAngle >> p.m_manualPassmarkWidth >>
p.m_manualPassmarkAngle >> p.m_isPassmarkClockwiseOpening;
}
return in;
}

View File

@ -212,11 +212,9 @@ auto IntersectionWithCuttingContour(const QVector<QPointF> &cuttingPath, const Q
*connection = first;
return true;
}
else
{
return VAbstractCurve::CurveIntersectAxis(first, FindTipDirection(points), cuttingPath, connection);
}
}
//---------------------------------------------------------------------------------------------------------------------
template <class T>
@ -1143,6 +1141,11 @@ auto VPiecePath::PreparePointEkv(const VPieceNode &node, const VContainer *data)
p.SetAngleType(node.GetAngleType());
p.SetManualPasskmarkLength(node.IsManualPassmarkLength());
p.SetPasskmarkLength(node.GetPassmarkLength(data, *data->GetPatternUnit()));
p.SetManualPasskmarkWidth(node.IsManualPassmarkWidth());
p.SetPasskmarkWidth(node.GetPassmarkWidth(data, *data->GetPatternUnit()));
p.SetManualPasskmarkAngle(node.IsManualPassmarkAngle());
p.SetPasskmarkAngle(node.GetPassmarkAngle(data));
p.SetPassmarkClockwiseOpening(node.IsPassmarkClockwiseOpening());
return p;
}

View File

@ -207,6 +207,11 @@ void AbstractTest::PassmarkDataFromJson(const QString &json, VPiecePassmarkData
AbstractTest::ReadDoubleValue(passmarkData, QStringLiteral("globalPassmarkLength"), globalPassmarkLength,
QString::number(NULL_ID));
data.globalPassmarkLength = globalPassmarkLength;
qreal globalPassmarkWidth;
AbstractTest::ReadDoubleValue(passmarkData, QStringLiteral("globalPassmarkWidth"), globalPassmarkWidth,
QString::number(NULL_ID));
data.globalPassmarkWidth = globalPassmarkWidth;
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -310,6 +310,50 @@ inline auto AbstractTest::PointFromJson(const QJsonObject &pointObject, VSAPoint
AbstractTest::ReadDoubleValue(pointObject, QStringLiteral("angle"), angleType,
QString::number(static_cast<int>(PieceNodeAngle::ByLength)));
point.SetAngleType(angleType);
bool manualPassmarkLength = false;
AbstractTest::ReadBooleanValue(pointObject, QLatin1String("manualPassmarkLength"), manualPassmarkLength,
QStringLiteral("0"));
point.SetManualPasskmarkLength(manualPassmarkLength);
if (manualPassmarkLength)
{
qreal passmarkLength = 0;
AbstractTest::ReadDoubleValue(pointObject, QStringLiteral("passmarkLength"), passmarkLength,
QStringLiteral("0"));
point.SetPasskmarkLength(passmarkLength);
}
bool manualPassmarkWidth = false;
AbstractTest::ReadBooleanValue(pointObject, QLatin1String("manualPassmarkWidth"), manualPassmarkWidth,
QStringLiteral("0"));
point.SetManualPasskmarkWidth(manualPassmarkWidth);
if (manualPassmarkWidth)
{
qreal passmarkWidth = 0;
AbstractTest::ReadDoubleValue(pointObject, QStringLiteral("passmarkWidth"), passmarkWidth, QStringLiteral("0"));
point.SetPasskmarkWidth(passmarkWidth);
}
else
{
bool passmarkClockwiseOpening = false;
AbstractTest::ReadBooleanValue(pointObject, QLatin1String("passmarkClockwiseOpening"), passmarkClockwiseOpening,
QStringLiteral("0"));
point.SetPassmarkClockwiseOpening(passmarkClockwiseOpening);
}
bool manualPassmarkAngle = false;
AbstractTest::ReadBooleanValue(pointObject, QLatin1String("manualPassmarkAngle"), manualPassmarkAngle,
QStringLiteral("0"));
point.SetManualPasskmarkAngle(manualPassmarkAngle);
if (manualPassmarkAngle)
{
qreal passmarkAngle = 0;
AbstractTest::ReadDoubleValue(pointObject, QStringLiteral("passmarkAngle"), passmarkAngle, QStringLiteral("0"));
point.SetPasskmarkAngle(passmarkAngle);
}
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -180,7 +180,7 @@ auto RowNode(QListWidget *listWidget, int i) -> VPieceNode
if (i < 0 || i >= listWidget->count())
{
return VPieceNode();
return {};
}
const QListWidgetItem *rowItem = listWidget->item(i);
@ -651,10 +651,10 @@ auto GetNodeName(const VContainer *data, const VPieceNode &node, bool showPassma
case PassmarkLineType::TMark:
name += QStringLiteral("");
break;
case PassmarkLineType::VMark:
case PassmarkLineType::ExternalVMark:
name += QStringLiteral("");
break;
case PassmarkLineType::VMark2:
case PassmarkLineType::InternalVMark:
name += QStringLiteral("");
break;
case PassmarkLineType::UMark:
@ -663,6 +663,9 @@ auto GetNodeName(const VContainer *data, const VPieceNode &node, bool showPassma
case PassmarkLineType::BoxMark:
name += QStringLiteral("");
break;
case PassmarkLineType::CheckMark:
name += QStringLiteral("");
break;
default:
break;
}

View File

@ -34,10 +34,17 @@
#include "../../../tools/vtoolseamallowance.h"
#include "../../support/dialogeditwrongformula.h"
#include "../vmisc/vmodifierkey.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vmisc/backport/qoverload.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
#include "../vmisc/backport/qscopeguard.h"
#else
#include <QScopeGuard>
#endif
#include <QMenu>
#include <QTimer>
@ -64,7 +71,9 @@ 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_timerPassmarkLength(new QTimer(this)),
m_timerPassmarkWidth(new QTimer(this)),
m_timerPassmarkAngle(new QTimer(this))
{
ui->setupUi(this);
InitOkCancel(ui);
@ -265,7 +274,7 @@ void DialogPiecePath::CheckState()
}
const int tabPassmarksIndex = ui->tabWidget->indexOf(ui->tabPassmarks);
if (m_flagFormulaPassmarkLength)
if (m_flagFormulaPassmarkLength && m_flagFormulaPassmarkWidth && m_flagFormulaPassmarkAngle)
{
ui->tabWidget->setTabIcon(tabPassmarksIndex, QIcon());
}
@ -276,7 +285,8 @@ void DialogPiecePath::CheckState()
ui->tabWidget->setTabIcon(tabPassmarksIndex, icon);
}
ui->comboBoxPassmarks->setEnabled(m_flagFormulaPassmarkLength);
ui->comboBoxPassmarks->setEnabled(m_flagFormulaPassmarkLength && m_flagFormulaPassmarkWidth &&
m_flagFormulaPassmarkAngle);
}
//---------------------------------------------------------------------------------------------------------------------
@ -516,135 +526,73 @@ void DialogPiecePath::PassmarkChanged(int index)
ui->groupBoxMarkType->setDisabled(true);
ui->groupBoxAngleType->setDisabled(true);
ui->groupBoxManualLength->setDisabled(true);
ui->groupBoxManualWidth->setDisabled(true);
ui->groupBoxManualAngle->setDisabled(true);
ui->labelEditPassmarkLength->setDisabled(true);
ui->labelEditPassmarkWidth->setDisabled(true);
ui->labelEditPassmarkAngle->setDisabled(true);
ui->checkBoxClockwiseOpening->setDisabled(true);
ui->checkBoxShowSecondPassmark->setDisabled(true);
ui->checkBoxClockwiseOpening->blockSignals(true);
ui->checkBoxShowSecondPassmark->blockSignals(true);
ui->groupBoxManualLength->blockSignals(true);
ui->groupBoxManualWidth->blockSignals(true);
ui->groupBoxManualAngle->blockSignals(true);
ui->groupBoxMarkType->blockSignals(true);
ui->groupBoxAngleType->blockSignals(true);
ui->groupBoxManualLength->setChecked(false);
ui->checkBoxClockwiseOpening->setChecked(false);
if (index != -1)
ui->groupBoxManualLength->setChecked(false);
ui->groupBoxManualWidth->setChecked(false);
ui->groupBoxManualAngle->setChecked(false);
auto EnableSignals = qScopeGuard(
[this]
{
ui->checkBoxClockwiseOpening->blockSignals(false);
ui->checkBoxShowSecondPassmark->blockSignals(false);
ui->groupBoxManualLength->blockSignals(false);
ui->groupBoxManualWidth->blockSignals(false);
ui->groupBoxManualAngle->blockSignals(false);
ui->groupBoxMarkType->blockSignals(false);
ui->groupBoxAngleType->blockSignals(false);
});
if (index == -1)
{
return;
}
const VPiecePath path = CreatePath();
const int nodeIndex = path.indexOfNode(ui->comboBoxPassmarks->currentData().toUInt());
if (nodeIndex != -1)
if (nodeIndex == -1)
{
return;
}
const VPieceNode &node = path.at(nodeIndex);
// Passmark length
ui->groupBoxManualLength->setEnabled(true);
InitPassmarkLengthFormula(node);
InitPassmarkWidthFormula(node);
InitPassmarkAngleFormula(node);
InitPassmarkShapeType(node);
InitPassmarkAngleType(node);
if (node.IsManualPassmarkLength())
if (node.GetPassmarkLineType() == PassmarkLineType::CheckMark)
{
ui->groupBoxManualLength->setChecked(true);
QString passmarkLength = node.GetFormulaPassmarkLength();
passmarkLength = VAbstractApplication::VApp()->TrVars()
->FormulaToUser(passmarkLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
if (passmarkLength.length() > 80)// increase height if needed.
{
this->DeployPassmarkLength();
}
if (passmarkLength.isEmpty())
{
qreal length = UnitConvertor(1, Unit::Cm, VAbstractValApplication::VApp()->patternUnits());
ui->plainTextEditPassmarkLength->setPlainText(VAbstractApplication::VApp()->LocaleToString(length));
}
else
{
ui->plainTextEditPassmarkLength->setPlainText(passmarkLength);
}
}
else
{
qreal length = UnitConvertor(1, Unit::Cm, VAbstractValApplication::VApp()->patternUnits());
ui->plainTextEditPassmarkLength->setPlainText(VAbstractApplication::VApp()->LocaleToString(length));
}
MoveCursorToEnd(ui->plainTextEditPassmarkLength);
// Line type
ui->groupBoxMarkType->setEnabled(true);
switch(node.GetPassmarkLineType())
{
case PassmarkLineType::OneLine:
ui->radioButtonOneLine->setChecked(true);
break;
case PassmarkLineType::TwoLines:
ui->radioButtonTwoLines->setChecked(true);
break;
case PassmarkLineType::ThreeLines:
ui->radioButtonThreeLines->setChecked(true);
break;
case PassmarkLineType::TMark:
ui->radioButtonTMark->setChecked(true);
break;
case PassmarkLineType::VMark:
ui->radioButtonVMark->setChecked(true);
break;
case PassmarkLineType::VMark2:
ui->radioButtonVMark2->setChecked(true);
break;
case PassmarkLineType::UMark:
ui->radioButtonUMark->setChecked(true);
break;
case PassmarkLineType::BoxMark:
ui->radioButtonBoxMark->setChecked(true);
break;
default:
break;
}
// Angle type
ui->groupBoxAngleType->setEnabled(true);
switch(node.GetPassmarkAngleType())
{
case PassmarkAngleType::Straightforward:
ui->radioButtonStraightforward->setChecked(true);
break;
case PassmarkAngleType::Bisector:
ui->radioButtonBisector->setChecked(true);
break;
case PassmarkAngleType::Intersection:
ui->radioButtonIntersection->setChecked(true);
break;
case PassmarkAngleType::IntersectionOnlyLeft:
ui->radioButtonIntersectionOnlyLeft->setChecked(true);
break;
case PassmarkAngleType::IntersectionOnlyRight:
ui->radioButtonIntersectionOnlyRight->setChecked(true);
break;
case PassmarkAngleType::Intersection2:
ui->radioButtonIntersection2->setChecked(true);
break;
case PassmarkAngleType::Intersection2OnlyLeft:
ui->radioButtonIntersection2OnlyLeft->setChecked(true);
break;
case PassmarkAngleType::Intersection2OnlyRight:
ui->radioButtonIntersection2OnlyRight->setChecked(true);
break;
default:
break;
ui->checkBoxClockwiseOpening->setEnabled(true);
ui->checkBoxClockwiseOpening->setChecked(node.IsPassmarkClockwiseOpening());
}
// Show the second option
ui->checkBoxShowSecondPassmark->setEnabled(true);
ui->checkBoxShowSecondPassmark->setChecked(node.IsShowSecondPassmark());
}
}
ui->checkBoxShowSecondPassmark->blockSignals(false);
ui->groupBoxManualLength->blockSignals(false);
ui->groupBoxMarkType->blockSignals(false);
ui->groupBoxAngleType->blockSignals(false);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::ReturnDefBefore()
@ -700,11 +648,11 @@ void DialogPiecePath::PassmarkLineTypeChanged(int id)
}
else if (id == ui->buttonGroupMarkType->id(ui->radioButtonVMark))
{
lineType = PassmarkLineType::VMark;
lineType = PassmarkLineType::ExternalVMark;
}
else if (id == ui->buttonGroupMarkType->id(ui->radioButtonVMark2))
{
lineType = PassmarkLineType::VMark2;
lineType = PassmarkLineType::InternalVMark;
}
else if (id == ui->buttonGroupMarkType->id(ui->radioButtonUMark))
{
@ -714,6 +662,10 @@ void DialogPiecePath::PassmarkLineTypeChanged(int id)
{
lineType = PassmarkLineType::BoxMark;
}
else if (id == ui->buttonGroupMarkType->id(ui->radioButtonCheckMark))
{
lineType = PassmarkLineType::CheckMark;
}
rowNode.SetPassmarkLineType(lineType);
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
@ -796,6 +748,24 @@ void DialogPiecePath::PassmarkShowSecondChanged(int state)
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::PassmarkClockwiseOrientationChanged(int state)
{
const int i = ui->comboBoxPassmarks->currentIndex();
if (i != -1)
{
QListWidgetItem *rowItem = GetItemById(ui->comboBoxPassmarks->currentData().toUInt());
if (rowItem)
{
auto rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
rowNode.SetPassmarkClockwiseOpening(state);
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
ListChanged();
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::EvalWidth()
{
@ -912,6 +882,10 @@ void DialogPiecePath::EvalVisible()
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::EvalPassmarkLength()
{
if (ui->groupBoxManualLength->isChecked())
{
if (ui->comboBoxPassmarks->count() > 0)
{
FormulaData formulaData;
formulaData.formula = ui->plainTextEditPassmarkLength->toPlainText();
@ -919,13 +893,84 @@ void DialogPiecePath::EvalPassmarkLength()
formulaData.labelEditFormula = ui->labelEditPassmarkLength;
formulaData.labelResult = ui->labelResultPassmarkLength;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = false;
formulaData.checkLessThanZero = false;
formulaData.checkZero = true;
formulaData.checkLessThanZero = true;
Eval(formulaData, m_flagFormulaPassmarkLength);
UpdateNodePassmarkLength(VTranslateVars::TryFormulaFromUser(
ui->plainTextEditPassmarkLength->toPlainText(), VAbstractApplication::VApp()->Settings()->GetOsSeparator()));
UpdateNodePassmarkLength(
VTranslateVars::TryFormulaFromUser(ui->plainTextEditPassmarkLength->toPlainText(),
VAbstractApplication::VApp()->Settings()->GetOsSeparator()));
}
else
{
ChangeColor(ui->labelEditPassmarkLength, OkColor(this));
ui->labelResultPassmarkLength->setText(tr("<Empty>"));
m_flagFormulaPassmarkLength = true;
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::EvalPassmarkWidth()
{
if (ui->groupBoxManualWidth->isChecked())
{
if (ui->comboBoxPassmarks->count() > 0)
{
FormulaData formulaData;
formulaData.formula = ui->plainTextEditPassmarkWidth->toPlainText();
formulaData.variables = data->DataVariables();
formulaData.labelEditFormula = ui->labelEditPassmarkWidth;
formulaData.labelResult = ui->labelResultPassmarkWidth;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = true;
formulaData.checkLessThanZero = false;
Eval(formulaData, m_flagFormulaPassmarkWidth);
UpdateNodePassmarkWidth(
VTranslateVars::TryFormulaFromUser(ui->plainTextEditPassmarkWidth->toPlainText(),
VAbstractApplication::VApp()->Settings()->GetOsSeparator()));
}
else
{
ChangeColor(ui->labelEditPassmarkWidth, OkColor(this));
ui->labelResultPassmarkWidth->setText(tr("<Empty>"));
m_flagFormulaPassmarkWidth = true;
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::EvalPassmarkAngle()
{
if (ui->groupBoxManualWidth->isChecked())
{
if (ui->comboBoxPassmarks->count() > 0)
{
FormulaData formulaData;
formulaData.formula = ui->plainTextEditPassmarkAngle->toPlainText();
formulaData.variables = data->DataVariables();
formulaData.labelEditFormula = ui->labelEditPassmarkAngle;
formulaData.labelResult = ui->labelResultPassmarkAngle;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = false;
formulaData.checkLessThanZero = false;
Eval(formulaData, m_flagFormulaPassmarkAngle);
UpdateNodePassmarkAngle(
VTranslateVars::TryFormulaFromUser(ui->plainTextEditPassmarkAngle->toPlainText(),
VAbstractApplication::VApp()->Settings()->GetOsSeparator()));
}
else
{
ChangeColor(ui->labelEditPassmarkAngle, OkColor(this));
ui->labelResultPassmarkAngle->setText(tr("<Empty>"));
m_flagFormulaPassmarkAngle = true;
}
}
}
//---------------------------------------------------------------------------------------------------------------------
@ -995,6 +1040,32 @@ void DialogPiecePath::FXPassmarkLength()
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::FXPassmarkWidth()
{
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
dialog->setWindowTitle(tr("Edit passmark width"));
dialog->SetFormula(GetFormulaPassmarkWidth());
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
if (dialog->exec() == QDialog::Accepted)
{
SetFormulaPassmarkWidth(dialog->GetFormula());
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::FXPassmarkAngle()
{
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
dialog->setWindowTitle(tr("Edit passmark angle"));
dialog->SetFormula(GetFormulaPassmarkAngle());
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
if (dialog->exec() == QDialog::Accepted)
{
SetFormulaPassmarkAngle(dialog->GetFormula());
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::DeployWidthFormulaTextEdit()
{
@ -1025,6 +1096,18 @@ void DialogPiecePath::DeployPassmarkLength()
DeployFormula(this, ui->plainTextEditPassmarkLength, ui->pushButtonGrowPassmarkLength, m_formulaBasePassmarkLength);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::DeployPassmarkWidth()
{
DeployFormula(this, ui->plainTextEditPassmarkWidth, ui->pushButtonGrowPassmarkWidth, m_formulaBasePassmarkWidth);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::DeployPassmarkAngle()
{
DeployFormula(this, ui->plainTextEditPassmarkAngle, ui->pushButtonGrowPassmarkAngle, m_formulaBasePassmarkAngle);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::SetMoveControls()
{
@ -1171,14 +1254,43 @@ void DialogPiecePath::InitSeamAllowanceTab()
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::InitPassmarksTab()
{
// Length formula
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);
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);
// Width formula
this->m_formulaBasePassmarkWidth = ui->plainTextEditPassmarkWidth->height();
ui->plainTextEditPassmarkWidth->installEventFilter(this);
m_timerPassmarkWidth->setSingleShot(true);
connect(m_timerPassmarkWidth, &QTimer::timeout, this, &DialogPiecePath::EvalPassmarkWidth);
connect(ui->groupBoxManualWidth, &QGroupBox::toggled, this, &DialogPiecePath::EnabledManualPassmarkWidth);
connect(ui->toolButtonExprWidth, &QPushButton::clicked, this, &DialogPiecePath::FXPassmarkWidth);
connect(ui->plainTextEditPassmarkWidth, &QPlainTextEdit::textChanged, this,
[this]() { m_timerPassmarkWidth->start(formulaTimerTimeout); });
connect(ui->pushButtonGrowPassmarkWidth, &QPushButton::clicked, this, &DialogPiecePath::DeployPassmarkWidth);
// Angle formula
this->m_formulaBasePassmarkAngle = ui->plainTextEditPassmarkAngle->height();
ui->plainTextEditPassmarkAngle->installEventFilter(this);
m_timerPassmarkAngle->setSingleShot(true);
connect(m_timerPassmarkAngle, &QTimer::timeout, this, &DialogPiecePath::EvalPassmarkAngle);
connect(ui->groupBoxManualAngle, &QGroupBox::toggled, this, &DialogPiecePath::EnabledManualPassmarkAngle);
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogPiecePath::FXPassmarkAngle);
connect(ui->plainTextEditPassmarkAngle, &QPlainTextEdit::textChanged, this,
[this]() { m_timerPassmarkAngle->start(formulaTimerTimeout); });
connect(ui->pushButtonGrowPassmarkAngle, &QPushButton::clicked, this, &DialogPiecePath::DeployPassmarkAngle);
// notch list
InitPassmarksList();
connect(ui->comboBoxPassmarks, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &DialogPiecePath::PassmarkChanged);
@ -1195,14 +1307,8 @@ void DialogPiecePath::InitPassmarksTab()
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);
connect(ui->checkBoxClockwiseOpening, &QCheckBox::stateChanged, this,
&DialogPiecePath::PassmarkClockwiseOrientationChanged);
}
//---------------------------------------------------------------------------------------------------------------------
@ -1501,6 +1607,38 @@ void DialogPiecePath::UpdateNodePassmarkLength(const QString &formula)
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::UpdateNodePassmarkWidth(const QString &formula)
{
const int index = ui->comboBoxPassmarks->currentIndex();
if (index != -1)
{
QListWidgetItem *rowItem = GetItemById(ui->comboBoxPassmarks->currentData().toUInt());
if (rowItem)
{
auto rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
rowNode.SetFormulaPassmarkWidth(formula);
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::UpdateNodePassmarkAngle(const QString &formula)
{
const int index = ui->comboBoxPassmarks->currentIndex();
if (index != -1)
{
QListWidgetItem *rowItem = GetItemById(ui->comboBoxPassmarks->currentData().toUInt());
if (rowItem)
{
auto rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
rowNode.SetFormulaPassmarkAngle(formula);
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::EnabledManualPassmarkLength()
{
@ -1513,11 +1651,66 @@ void DialogPiecePath::EnabledManualPassmarkLength()
auto rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
rowNode.SetManualPassmarkLength(ui->groupBoxManualLength->isChecked());
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
ui->toolButtonExprLength->setEnabled(ui->groupBoxManualLength->isChecked());
ui->plainTextEditPassmarkLength->setEnabled(ui->groupBoxManualLength->isChecked());
ui->pushButtonGrowPassmarkLength->setEnabled(ui->groupBoxManualLength->isChecked());
ui->labelEditPassmarkLength->setEnabled(ui->groupBoxManualLength->isChecked());
ui->label_8->setEnabled(ui->groupBoxManualLength->isChecked());
EvalPassmarkLength();
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::EnabledManualPassmarkWidth()
{
const int index = ui->comboBoxPassmarks->currentIndex();
if (index != -1)
{
QListWidgetItem *rowItem = GetItemById(ui->comboBoxPassmarks->currentData().toUInt());
if (rowItem)
{
auto rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
rowNode.SetManualPassmarkWidth(ui->groupBoxManualWidth->isChecked());
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
ui->toolButtonExprWidth->setEnabled(ui->groupBoxManualWidth->isChecked());
ui->plainTextEditPassmarkWidth->setEnabled(ui->groupBoxManualWidth->isChecked());
ui->pushButtonGrowPassmarkWidth->setEnabled(ui->groupBoxManualWidth->isChecked());
ui->labelEditPassmarkWidth->setEnabled(ui->groupBoxManualWidth->isChecked());
ui->label_4->setEnabled(ui->groupBoxManualWidth->isChecked());
EvalPassmarkWidth();
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::EnabledManualPassmarkAngle()
{
const int index = ui->comboBoxPassmarks->currentIndex();
if (index != -1)
{
QListWidgetItem *rowItem = GetItemById(ui->comboBoxPassmarks->currentData().toUInt());
if (rowItem)
{
auto rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
rowNode.SetManualPassmarkAngle(ui->groupBoxManualAngle->isChecked());
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
ui->toolButtonExprAngle->setEnabled(ui->groupBoxManualAngle->isChecked());
ui->plainTextEditPassmarkAngle->setEnabled(ui->groupBoxManualAngle->isChecked());
ui->pushButtonGrowPassmarkAngle->setEnabled(ui->groupBoxManualAngle->isChecked());
ui->labelEditPassmarkAngle->setEnabled(ui->groupBoxManualAngle->isChecked());
ui->label_7->setEnabled(ui->groupBoxManualAngle->isChecked());
EvalPassmarkAngle();
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::SetFormulaSAWidth(const QString &formula)
{
@ -1754,6 +1947,48 @@ void DialogPiecePath::SetFormulaPassmarkLength(const QString &formula)
MoveCursorToEnd(ui->plainTextEditPassmarkLength);
}
//---------------------------------------------------------------------------------------------------------------------
auto DialogPiecePath::GetFormulaPassmarkWidth() const -> QString
{
QString formula = ui->plainTextEditPassmarkWidth->toPlainText();
return VTranslateVars::TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::SetFormulaPassmarkWidth(const QString &formula)
{
const QString f = VAbstractApplication::VApp()->TrVars()->FormulaToUser(
formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
// increase height if needed.
if (f.length() > 80)
{
this->DeployPassmarkWidth();
}
ui->plainTextEditPassmarkWidth->setPlainText(f);
MoveCursorToEnd(ui->plainTextEditPassmarkWidth);
}
//---------------------------------------------------------------------------------------------------------------------
auto DialogPiecePath::GetFormulaPassmarkAngle() const -> QString
{
QString formula = ui->plainTextEditPassmarkWidth->toPlainText();
return VTranslateVars::TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::SetFormulaPassmarkAngle(const QString &formula)
{
const QString f = VAbstractApplication::VApp()->TrVars()->FormulaToUser(
formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
// increase height if needed.
if (f.length() > 80)
{
this->DeployPassmarkAngle();
}
ui->plainTextEditPassmarkAngle->setPlainText(f);
MoveCursorToEnd(ui->plainTextEditPassmarkAngle);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::RefreshPathList(const VPiecePath &path)
{
@ -1765,3 +2000,218 @@ void DialogPiecePath::RefreshPathList(const VPiecePath &path)
}
ui->listWidget->blockSignals(false);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::InitPassmarkLengthFormula(const VPieceNode &node)
{
// notch depth
ui->groupBoxManualLength->setEnabled(true);
if (node.IsManualPassmarkLength())
{
ui->groupBoxManualLength->setChecked(true);
ui->toolButtonExprLength->setEnabled(ui->groupBoxManualLength->isChecked());
ui->plainTextEditPassmarkLength->setEnabled(ui->groupBoxManualLength->isChecked());
ui->pushButtonGrowPassmarkLength->setEnabled(ui->groupBoxManualLength->isChecked());
ui->labelEditPassmarkLength->setEnabled(ui->groupBoxManualLength->isChecked());
ui->label_8->setEnabled(ui->groupBoxManualLength->isChecked());
QString passmarkLength = node.GetFormulaPassmarkLength();
passmarkLength = VAbstractApplication::VApp()->TrVars()->FormulaToUser(
passmarkLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
if (passmarkLength.length() > 80) // increase height if needed.
{
this->DeployPassmarkLength();
}
if (passmarkLength.isEmpty())
{
qreal length = UnitConvertor(1, Unit::Cm, VAbstractValApplication::VApp()->patternUnits());
ui->plainTextEditPassmarkLength->setPlainText(VAbstractApplication::VApp()->LocaleToString(length));
}
else
{
ui->plainTextEditPassmarkLength->setPlainText(passmarkLength);
}
}
else
{
qreal length = UnitConvertor(1, Unit::Cm, VAbstractValApplication::VApp()->patternUnits());
ui->plainTextEditPassmarkLength->setPlainText(VAbstractApplication::VApp()->LocaleToString(length));
}
MoveCursorToEnd(ui->plainTextEditPassmarkLength);
ChangeColor(ui->labelEditPassmarkLength, OkColor(this));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::InitPassmarkWidthFormula(const VPieceNode &node)
{
// notch width
if (node.GetPassmarkLineType() != PassmarkLineType::OneLine)
{
ui->groupBoxManualWidth->setEnabled(true);
if (node.IsManualPassmarkWidth())
{
ui->groupBoxManualWidth->setChecked(true);
ui->toolButtonExprWidth->setEnabled(ui->groupBoxManualWidth->isChecked());
ui->plainTextEditPassmarkWidth->setEnabled(ui->groupBoxManualWidth->isChecked());
ui->pushButtonGrowPassmarkWidth->setEnabled(ui->groupBoxManualWidth->isChecked());
ui->labelEditPassmarkWidth->setEnabled(ui->groupBoxManualWidth->isChecked());
ui->label_4->setEnabled(ui->groupBoxManualWidth->isChecked());
QString passmarkWidth = node.GetFormulaPassmarkWidth();
passmarkWidth = VAbstractApplication::VApp()->TrVars()->FormulaToUser(
passmarkWidth, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
if (passmarkWidth.length() > 80) // increase height if needed.
{
this->DeployPassmarkWidth();
}
if (passmarkWidth.isEmpty())
{
qreal width = UnitConvertor(0.85, Unit::Cm, VAbstractValApplication::VApp()->patternUnits());
ui->plainTextEditPassmarkWidth->setPlainText(VAbstractApplication::VApp()->LocaleToString(width));
}
else
{
ui->plainTextEditPassmarkWidth->setPlainText(passmarkWidth);
}
}
else
{
qreal width = UnitConvertor(0.85, Unit::Cm, VAbstractValApplication::VApp()->patternUnits());
ui->plainTextEditPassmarkWidth->setPlainText(VAbstractApplication::VApp()->LocaleToString(width));
}
MoveCursorToEnd(ui->plainTextEditPassmarkWidth);
}
else
{
qreal width = UnitConvertor(0.85, Unit::Cm, VAbstractValApplication::VApp()->patternUnits());
ui->plainTextEditPassmarkWidth->setPlainText(VAbstractApplication::VApp()->LocaleToString(width));
}
ChangeColor(ui->labelEditPassmarkWidth, OkColor(this));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::InitPassmarkAngleFormula(const VPieceNode &node)
{
// notch angle
if (node.GetPassmarkAngleType() == PassmarkAngleType::Straightforward)
{
ui->groupBoxManualAngle->setEnabled(true);
if (node.IsManualPassmarkAngle())
{
ui->groupBoxManualAngle->setChecked(true);
ui->toolButtonExprAngle->setEnabled(ui->groupBoxManualAngle->isChecked());
ui->plainTextEditPassmarkAngle->setEnabled(ui->groupBoxManualAngle->isChecked());
ui->pushButtonGrowPassmarkAngle->setEnabled(ui->groupBoxManualAngle->isChecked());
ui->labelEditPassmarkAngle->setEnabled(ui->groupBoxManualAngle->isChecked());
ui->label_7->setEnabled(ui->groupBoxManualAngle->isChecked());
QString passmarkAngle = node.GetFormulaPassmarkLength();
passmarkAngle = VAbstractApplication::VApp()->TrVars()->FormulaToUser(
passmarkAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
if (passmarkAngle.length() > 80) // increase height if needed.
{
this->DeployPassmarkAngle();
}
ui->plainTextEditPassmarkAngle->setPlainText(passmarkAngle.isEmpty() ? QString::number(0) : passmarkAngle);
}
else
{
ui->plainTextEditPassmarkAngle->setPlainText(QString::number(0));
}
MoveCursorToEnd(ui->plainTextEditPassmarkAngle);
}
else
{
ui->plainTextEditPassmarkAngle->setPlainText(QString::number(0));
}
ChangeColor(ui->labelEditPassmarkAngle, OkColor(this));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::InitPassmarkShapeType(const VPieceNode &node)
{
// Line type
ui->groupBoxMarkType->setEnabled(true);
switch (node.GetPassmarkLineType())
{
case PassmarkLineType::OneLine:
ui->radioButtonOneLine->setChecked(true);
break;
case PassmarkLineType::TwoLines:
ui->radioButtonTwoLines->setChecked(true);
break;
case PassmarkLineType::ThreeLines:
ui->radioButtonThreeLines->setChecked(true);
break;
case PassmarkLineType::TMark:
ui->radioButtonTMark->setChecked(true);
break;
case PassmarkLineType::ExternalVMark:
ui->radioButtonVMark->setChecked(true);
break;
case PassmarkLineType::InternalVMark:
ui->radioButtonVMark2->setChecked(true);
break;
case PassmarkLineType::UMark:
ui->radioButtonUMark->setChecked(true);
break;
case PassmarkLineType::BoxMark:
ui->radioButtonBoxMark->setChecked(true);
break;
case PassmarkLineType::CheckMark:
ui->radioButtonCheckMark->setChecked(true);
break;
default:
break;
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::InitPassmarkAngleType(const VPieceNode &node)
{
// Angle type
ui->groupBoxAngleType->setEnabled(true);
switch (node.GetPassmarkAngleType())
{
case PassmarkAngleType::Straightforward:
ui->radioButtonStraightforward->setChecked(true);
break;
case PassmarkAngleType::Bisector:
ui->radioButtonBisector->setChecked(true);
break;
case PassmarkAngleType::Intersection:
ui->radioButtonIntersection->setChecked(true);
break;
case PassmarkAngleType::IntersectionOnlyLeft:
ui->radioButtonIntersectionOnlyLeft->setChecked(true);
break;
case PassmarkAngleType::IntersectionOnlyRight:
ui->radioButtonIntersectionOnlyRight->setChecked(true);
break;
case PassmarkAngleType::Intersection2:
ui->radioButtonIntersection2->setChecked(true);
break;
case PassmarkAngleType::Intersection2OnlyLeft:
ui->radioButtonIntersection2OnlyLeft->setChecked(true);
break;
case PassmarkAngleType::Intersection2OnlyRight:
ui->radioButtonIntersection2OnlyRight->setChecked(true);
break;
default:
break;
}
}

View File

@ -78,24 +78,31 @@ private slots:
void PassmarkLineTypeChanged(int id);
void PassmarkAngleTypeChanged(int id);
void PassmarkShowSecondChanged(int state);
void PassmarkClockwiseOrientationChanged(int state);
void EvalWidth();
void EvalWidthBefore();
void EvalWidthAfter();
void EvalVisible();
void EvalPassmarkLength();
void EvalPassmarkWidth();
void EvalPassmarkAngle();
void FXWidth();
void FXWidthBefore();
void FXWidthAfter();
void FXVisible();
void FXPassmarkLength();
void FXPassmarkWidth();
void FXPassmarkAngle();
void DeployWidthFormulaTextEdit();
void DeployWidthBeforeFormulaTextEdit();
void DeployWidthAfterFormulaTextEdit();
void DeployVisibleFormulaTextEdit();
void DeployPassmarkLength();
void DeployPassmarkWidth();
void DeployPassmarkAngle();
void SetMoveControls();
@ -110,17 +117,23 @@ private:
QTimer *m_timerWidthAfter;
QTimer *m_timerVisible;
QTimer *m_timerPassmarkLength;
QTimer *m_timerPassmarkWidth;
QTimer *m_timerPassmarkAngle;
int m_formulaBaseWidth{0};
int m_formulaBaseWidthBefore{0};
int m_formulaBaseWidthAfter{0};
int m_formulaBaseVisible{0};
int m_formulaBasePassmarkLength{0};
int m_formulaBasePassmarkWidth{0};
int m_formulaBasePassmarkAngle{0};
bool m_flagFormulaBefore{true};
bool m_flagFormulaAfter{true};
bool m_flagFormulaVisible{true};
bool m_flagFormulaPassmarkLength{true};
bool m_flagFormulaPassmarkWidth{true};
bool m_flagFormulaPassmarkAngle{true};
bool m_flagName{true}; // We have default name of piece.
bool m_flagError{false};
bool m_flagFormula{false};
@ -159,8 +172,12 @@ private:
void UpdateNodeSABefore(const QString &formula);
void UpdateNodeSAAfter(const QString &formula);
void UpdateNodePassmarkLength(const QString &formula);
void UpdateNodePassmarkWidth(const QString &formula);
void UpdateNodePassmarkAngle(const QString &formula);
void EnabledManualPassmarkLength();
void EnabledManualPassmarkWidth();
void EnabledManualPassmarkAngle();
auto GetFormulaSAWidthBefore() const -> QString;
auto GetFormulaSAWidthAfter() const -> QString;
@ -171,9 +188,21 @@ private:
auto GetFormulaPassmarkLength() const -> QString;
void SetFormulaPassmarkLength(const QString &formula);
auto GetFormulaPassmarkWidth() const -> QString;
void SetFormulaPassmarkWidth(const QString &formula);
auto GetFormulaPassmarkAngle() const -> QString;
void SetFormulaPassmarkAngle(const QString &formula);
auto IsShowNotch() const -> bool;
void RefreshPathList(const VPiecePath &path);
void InitPassmarkLengthFormula(const VPieceNode &node);
void InitPassmarkWidthFormula(const VPieceNode &node);
void InitPassmarkAngleFormula(const VPieceNode &node);
void InitPassmarkShapeType(const VPieceNode &node);
void InitPassmarkAngleType(const VPieceNode &node);
};
//---------------------------------------------------------------------------------------------------------------------

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>394</width>
<height>583</height>
<width>420</width>
<height>647</height>
</rect>
</property>
<property name="windowTitle">
@ -908,7 +908,7 @@
<attribute name="title">
<string>Passmarks</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_8">
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
@ -927,227 +927,15 @@
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBoxManualLength">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Manual length</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
<widget class="QTabWidget" name="tabWidget_2">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabType">
<attribute name="title">
<string>Type</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item alignment="Qt::AlignLeft">
<widget class="QLabel" name="labelEditPassmarkLength">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</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_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>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">=</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>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="VPlainTextEdit" name="plainTextEditPassmarkLength">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>Calculation</string>
</property>
<property name="tabChangesFocus">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonGrowPassmarkLength">
<property name="enabled">
<bool>true</bool>
</property>
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<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 name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff>../</normaloff>../</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@ -1263,6 +1051,16 @@
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonCheckMark">
<property name="text">
<string>Check mark</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroupMarkType</string>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
@ -1402,6 +1200,702 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBoxClockwiseOpening">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Clockwise opening</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabManualShape">
<attribute name="title">
<string>Manual shape</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<widget class="QGroupBox" name="groupBoxManualLength">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Length</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_19">
<item alignment="Qt::AlignLeft">
<widget class="QLabel" name="labelEditPassmarkLength">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</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 comment="notch depth">Length:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_10">
<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_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>36</pointsize>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">=</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>
<layout class="QHBoxLayout" name="horizontalLayout_20">
<item>
<widget class="VPlainTextEdit" name="plainTextEditPassmarkLength">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>Calculation</string>
</property>
<property name="tabChangesFocus">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonGrowPassmarkLength">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<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 name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff>../</normaloff>../</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxManualWidth">
<property name="enabled">
<bool>false</bool>
</property>
<property name="title">
<string>Width</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item alignment="Qt::AlignLeft">
<widget class="QLabel" name="labelEditPassmarkWidth">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</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 comment="notch width">Width:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_9">
<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="toolButtonExprWidth_2">
<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_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>36</pointsize>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">=</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="labelResultPassmarkWidth">
<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>
<layout class="QHBoxLayout" name="horizontalLayout_18">
<item>
<widget class="VPlainTextEdit" name="plainTextEditPassmarkWidth">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>Calculation</string>
</property>
<property name="tabChangesFocus">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonGrowPassmarkWidth">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<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 name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff>../</normaloff>../</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBoxManualAngle">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Angle</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item alignment="Qt::AlignLeft">
<widget class="QLabel" name="labelEditPassmarkAngle">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</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 comment="notch angle">Angle:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<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="toolButtonExprAngle">
<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_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>36</pointsize>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">=</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="labelResultPassmarkAngle">
<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>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="VPlainTextEdit" name="plainTextEditPassmarkAngle">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>28</height>
</size>
</property>
<property name="toolTip">
<string>Calculation</string>
</property>
<property name="tabChangesFocus">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonGrowPassmarkAngle">
<property name="enabled">
<bool>false</bool>
</property>
<property name="maximumSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<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 name="text">
<string notr="true"/>
</property>
<property name="icon">
<iconset theme="go-down">
<normaloff>../</normaloff>../</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBoxShowSecondPassmark">
<property name="enabled">

View File

@ -58,10 +58,17 @@
#include "ui_tabpaths.h"
#include "ui_tabpins.h"
#include "ui_tabplacelabels.h"
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#include "../vmisc/backport/qoverload.h"
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
#include "../vmisc/backport/qscopeguard.h"
#else
#include <QScopeGuard>
#endif
#include <QMenu>
#include <QMessageBox>
#include <QTimer>
@ -145,6 +152,8 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, quint32 toolId,
m_timerWidthBefore(new QTimer(this)),
m_timerWidthAfter(new QTimer(this)),
m_timerPassmarkLength(new QTimer(this)),
m_timerPassmarkWidth(new QTimer(this)),
m_timerPassmarkAngle(new QTimer(this)),
m_placeholdersMenu(new QMenu(this))
{
ui->setupUi(this);
@ -581,17 +590,29 @@ void DialogSeamAllowance::CheckState()
uiTabPaths->comboBoxNodes->setEnabled(flagFormulaBefore && flagFormulaAfter);
flagFormulaPassmarkLength = uiTabPassmarks->comboBoxPassmarks->count() == 0;
if (flagFormulaPassmarkLength)
if (uiTabPassmarks->comboBoxPassmarks->count() == 0)
{
flagFormulaPassmarkLength = true;
flagFormulaPassmarkWidth = true;
flagFormulaPassmarkAngle = true;
}
if (flagFormulaPassmarkLength && flagFormulaPassmarkWidth && flagFormulaPassmarkAngle)
{
m_ftb->SetTabText(TabOrder::Passmarks, tr("Passmarks"));
uiTabPassmarks->tabWidget->setTabIcon(uiTabPassmarks->tabWidget->indexOf(uiTabPassmarks->tabManualShape),
QIcon());
}
else
{
m_ftb->SetTabText(TabOrder::Passmarks, tr("Passmarks") + '*');
const QIcon icon = QIcon::fromTheme(QStringLiteral("dialog-warning"),
QIcon(":/icons/win.icon.theme/16x16/status/dialog-warning.png"));
uiTabPassmarks->tabWidget->setTabIcon(uiTabPassmarks->tabWidget->indexOf(uiTabPassmarks->tabManualShape), icon);
}
uiTabPassmarks->comboBoxPassmarks->setEnabled(flagFormulaPassmarkLength);
uiTabPassmarks->comboBoxPassmarks->setEnabled(flagFormulaPassmarkLength && flagFormulaPassmarkWidth &&
flagFormulaPassmarkAngle);
}
//---------------------------------------------------------------------------------------------------------------------
@ -1123,136 +1144,73 @@ void DialogSeamAllowance::PassmarkChanged(int index)
uiTabPassmarks->groupBoxMarkType->setDisabled(true);
uiTabPassmarks->groupBoxAngleType->setDisabled(true);
uiTabPassmarks->groupBoxManualLength->setDisabled(true);
uiTabPassmarks->groupBoxManualWidth->setDisabled(true);
uiTabPassmarks->groupBoxManualAngle->setDisabled(true);
uiTabPassmarks->labelEditPassmarkLength->setDisabled(true);
uiTabPassmarks->labelEditPassmarkWidth->setDisabled(true);
uiTabPassmarks->labelEditPassmarkAngle->setDisabled(true);
uiTabPassmarks->checkBoxClockwiseOpening->setDisabled(true);
uiTabPassmarks->checkBoxShowSecondPassmark->setDisabled(true);
uiTabPassmarks->checkBoxClockwiseOpening->blockSignals(true);
uiTabPassmarks->checkBoxShowSecondPassmark->blockSignals(true);
uiTabPassmarks->groupBoxManualLength->blockSignals(true);
uiTabPassmarks->groupBoxManualWidth->blockSignals(true);
uiTabPassmarks->groupBoxManualAngle->blockSignals(true);
uiTabPassmarks->groupBoxMarkType->blockSignals(true);
uiTabPassmarks->groupBoxAngleType->blockSignals(true);
uiTabPassmarks->groupBoxManualLength->setChecked(false);
uiTabPassmarks->checkBoxClockwiseOpening->setChecked(false);
if (index != -1)
uiTabPassmarks->groupBoxManualLength->setChecked(false);
uiTabPassmarks->groupBoxManualWidth->setChecked(false);
uiTabPassmarks->groupBoxManualAngle->setChecked(false);
auto EnableSignals = qScopeGuard(
[this]
{
uiTabPassmarks->checkBoxClockwiseOpening->blockSignals(false);
uiTabPassmarks->checkBoxShowSecondPassmark->blockSignals(false);
uiTabPassmarks->groupBoxManualLength->blockSignals(false);
uiTabPassmarks->groupBoxManualWidth->blockSignals(false);
uiTabPassmarks->groupBoxManualAngle->blockSignals(false);
uiTabPassmarks->groupBoxMarkType->blockSignals(false);
uiTabPassmarks->groupBoxAngleType->blockSignals(false);
});
if (index == -1)
{
return;
}
const VPiece piece = CreatePiece();
const int nodeIndex = piece.GetPath().indexOfNode(uiTabPassmarks->comboBoxPassmarks->currentData().toUInt());
if (nodeIndex != -1)
if (nodeIndex == -1)
{
return;
}
const VPieceNode &node = piece.GetPath().at(nodeIndex);
// Passmark length
uiTabPassmarks->groupBoxManualLength->setEnabled(true);
InitPassmarkLengthFormula(node);
InitPassmarkWidthFormula(node);
InitPassmarkAngleFormula(node);
InitPassmarkShapeType(node);
InitPassmarkAngleType(node);
if (node.IsManualPassmarkLength())
if (node.GetPassmarkLineType() == PassmarkLineType::CheckMark)
{
uiTabPassmarks->groupBoxManualLength->setChecked(true);
QString passmarkLength = node.GetFormulaPassmarkLength();
passmarkLength = VAbstractApplication::VApp()->TrVars()
->FormulaToUser(passmarkLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
if (passmarkLength.length() > 80)// increase height if needed.
{
this->DeployPassmarkLength();
}
if (passmarkLength.isEmpty())
{
qreal length = UnitConvertor(1, Unit::Cm, VAbstractValApplication::VApp()->patternUnits());
uiTabPassmarks->plainTextEditPassmarkLength->setPlainText(
VAbstractApplication::VApp()->LocaleToString(length));
}
else
{
uiTabPassmarks->plainTextEditPassmarkLength->setPlainText(passmarkLength);
}
}
else
{
qreal length = UnitConvertor(1, Unit::Cm, VAbstractValApplication::VApp()->patternUnits());
uiTabPassmarks->plainTextEditPassmarkLength->setPlainText(
VAbstractApplication::VApp()->LocaleToString(length));
}
MoveCursorToEnd(uiTabPassmarks->plainTextEditPassmarkLength);
// Line type
uiTabPassmarks->groupBoxMarkType->setEnabled(true);
switch(node.GetPassmarkLineType())
{
case PassmarkLineType::OneLine:
uiTabPassmarks->radioButtonOneLine->setChecked(true);
break;
case PassmarkLineType::TwoLines:
uiTabPassmarks->radioButtonTwoLines->setChecked(true);
break;
case PassmarkLineType::ThreeLines:
uiTabPassmarks->radioButtonThreeLines->setChecked(true);
break;
case PassmarkLineType::TMark:
uiTabPassmarks->radioButtonTMark->setChecked(true);
break;
case PassmarkLineType::VMark:
uiTabPassmarks->radioButtonVMark->setChecked(true);
break;
case PassmarkLineType::VMark2:
uiTabPassmarks->radioButtonVMark2->setChecked(true);
break;
case PassmarkLineType::UMark:
uiTabPassmarks->radioButtonUMark->setChecked(true);
break;
case PassmarkLineType::BoxMark:
uiTabPassmarks->radioButtonBoxMark->setChecked(true);
break;
default:
break;
}
// Angle type
uiTabPassmarks->groupBoxAngleType->setEnabled(true);
switch(node.GetPassmarkAngleType())
{
case PassmarkAngleType::Straightforward:
uiTabPassmarks->radioButtonStraightforward->setChecked(true);
break;
case PassmarkAngleType::Bisector:
uiTabPassmarks->radioButtonBisector->setChecked(true);
break;
case PassmarkAngleType::Intersection:
uiTabPassmarks->radioButtonIntersection->setChecked(true);
break;
case PassmarkAngleType::IntersectionOnlyLeft:
uiTabPassmarks->radioButtonIntersectionOnlyLeft->setChecked(true);
break;
case PassmarkAngleType::IntersectionOnlyRight:
uiTabPassmarks->radioButtonIntersectionOnlyRight->setChecked(true);
break;
case PassmarkAngleType::Intersection2:
uiTabPassmarks->radioButtonIntersection2->setChecked(true);
break;
case PassmarkAngleType::Intersection2OnlyLeft:
uiTabPassmarks->radioButtonIntersection2OnlyLeft->setChecked(true);
break;
case PassmarkAngleType::Intersection2OnlyRight:
uiTabPassmarks->radioButtonIntersection2OnlyRight->setChecked(true);
break;
default:
break;
uiTabPassmarks->checkBoxClockwiseOpening->setEnabled(true);
uiTabPassmarks->checkBoxClockwiseOpening->setChecked(node.IsPassmarkClockwiseOpening());
}
// Show the second option
uiTabPassmarks->checkBoxShowSecondPassmark->setEnabled(true);
uiTabPassmarks->checkBoxShowSecondPassmark->setChecked(node.IsShowSecondPassmark());
}
}
uiTabPassmarks->checkBoxShowSecondPassmark->blockSignals(false);
uiTabPassmarks->groupBoxManualLength->blockSignals(false);
uiTabPassmarks->groupBoxMarkType->blockSignals(false);
uiTabPassmarks->groupBoxAngleType->blockSignals(false);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::CSAStartPointChanged(int index)
@ -1598,11 +1556,11 @@ void DialogSeamAllowance::PassmarkLineTypeChanged(int id)
}
else if (id == uiTabPassmarks->buttonGroupLineType->id(uiTabPassmarks->radioButtonVMark))
{
lineType = PassmarkLineType::VMark;
lineType = PassmarkLineType::ExternalVMark;
}
else if (id == uiTabPassmarks->buttonGroupLineType->id(uiTabPassmarks->radioButtonVMark2))
{
lineType = PassmarkLineType::VMark2;
lineType = PassmarkLineType::InternalVMark;
}
else if (id == uiTabPassmarks->buttonGroupLineType->id(uiTabPassmarks->radioButtonUMark))
{
@ -1612,6 +1570,10 @@ void DialogSeamAllowance::PassmarkLineTypeChanged(int id)
{
lineType = PassmarkLineType::BoxMark;
}
else if (id == uiTabPassmarks->buttonGroupLineType->id(uiTabPassmarks->radioButtonCheckMark))
{
lineType = PassmarkLineType::CheckMark;
}
rowNode.SetPassmarkLineType(lineType);
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
@ -1693,6 +1655,24 @@ void DialogSeamAllowance::PassmarkShowSecondChanged(int state)
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::PassmarkClockwiseOrientationChanged(int state)
{
const int i = uiTabPassmarks->comboBoxPassmarks->currentIndex();
if (i != -1)
{
QListWidgetItem *rowItem = GetItemById(uiTabPassmarks->comboBoxPassmarks->currentData().toUInt());
if (rowItem)
{
auto rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
rowNode.SetPassmarkClockwiseOpening(state);
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
ListChanged();
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::UpdateGrainlineValues()
{
@ -1997,11 +1977,66 @@ void DialogSeamAllowance::EnabledManualPassmarkLength()
auto rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
rowNode.SetManualPassmarkLength(uiTabPassmarks->groupBoxManualLength->isChecked());
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
uiTabPassmarks->toolButtonExprLength->setEnabled(uiTabPassmarks->groupBoxManualLength->isChecked());
uiTabPassmarks->plainTextEditPassmarkLength->setEnabled(uiTabPassmarks->groupBoxManualLength->isChecked());
uiTabPassmarks->pushButtonGrowPassmarkLength->setEnabled(uiTabPassmarks->groupBoxManualLength->isChecked());
uiTabPassmarks->labelEditPassmarkLength->setEnabled(uiTabPassmarks->groupBoxManualLength->isChecked());
uiTabPassmarks->label_3->setEnabled(uiTabPassmarks->groupBoxManualLength->isChecked());
EvalPassmarkLength();
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::EnabledManualPassmarkWidth()
{
const int index = uiTabPassmarks->comboBoxPassmarks->currentIndex();
if (index != -1)
{
QListWidgetItem *rowItem = GetItemById(uiTabPassmarks->comboBoxPassmarks->currentData().toUInt());
if (rowItem)
{
auto rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
rowNode.SetManualPassmarkWidth(uiTabPassmarks->groupBoxManualWidth->isChecked());
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
uiTabPassmarks->toolButtonExprWidth->setEnabled(uiTabPassmarks->groupBoxManualWidth->isChecked());
uiTabPassmarks->plainTextEditPassmarkWidth->setEnabled(uiTabPassmarks->groupBoxManualWidth->isChecked());
uiTabPassmarks->pushButtonGrowPassmarkWidth->setEnabled(uiTabPassmarks->groupBoxManualWidth->isChecked());
uiTabPassmarks->labelEditPassmarkWidth->setEnabled(uiTabPassmarks->groupBoxManualWidth->isChecked());
uiTabPassmarks->label_4->setEnabled(uiTabPassmarks->groupBoxManualWidth->isChecked());
EvalPassmarkWidth();
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::EnabledManualPassmarkAngle()
{
const int index = uiTabPassmarks->comboBoxPassmarks->currentIndex();
if (index != -1)
{
QListWidgetItem *rowItem = GetItemById(uiTabPassmarks->comboBoxPassmarks->currentData().toUInt());
if (rowItem)
{
auto rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
rowNode.SetManualPassmarkAngle(uiTabPassmarks->groupBoxManualAngle->isChecked());
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
uiTabPassmarks->toolButtonExprAngle->setEnabled(uiTabPassmarks->groupBoxManualAngle->isChecked());
uiTabPassmarks->plainTextEditPassmarkAngle->setEnabled(uiTabPassmarks->groupBoxManualAngle->isChecked());
uiTabPassmarks->pushButtonGrowPassmarkAngle->setEnabled(uiTabPassmarks->groupBoxManualAngle->isChecked());
uiTabPassmarks->labelEditPassmarkAngle->setEnabled(uiTabPassmarks->groupBoxManualAngle->isChecked());
uiTabPassmarks->label_5->setEnabled(uiTabPassmarks->groupBoxManualAngle->isChecked());
EvalPassmarkAngle();
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::EditGrainlineFormula()
{
@ -2362,6 +2397,64 @@ void DialogSeamAllowance::EvalPassmarkLength()
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::EvalPassmarkWidth()
{
if (uiTabPassmarks->groupBoxManualWidth->isChecked())
{
if (uiTabPassmarks->comboBoxPassmarks->count() > 0)
{
FormulaData formulaData;
formulaData.formula = uiTabPassmarks->plainTextEditPassmarkWidth->toPlainText();
formulaData.variables = data->DataVariables();
formulaData.labelEditFormula = uiTabPassmarks->labelEditPassmarkWidth;
formulaData.labelResult = uiTabPassmarks->labelResultPassmarkWidth;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = true;
formulaData.checkLessThanZero = false;
Eval(formulaData, flagFormulaPassmarkWidth);
UpdateNodePassmarkWidth(GetFormulaFromUser(uiTabPassmarks->plainTextEditPassmarkWidth));
}
else
{
ChangeColor(uiTabPassmarks->labelEditPassmarkWidth, OkColor(this));
uiTabPassmarks->labelResultPassmarkWidth->setText(tr("<Empty>"));
flagFormulaPassmarkWidth = true;
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::EvalPassmarkAngle()
{
if (uiTabPassmarks->groupBoxManualAngle->isChecked())
{
if (uiTabPassmarks->comboBoxPassmarks->count() > 0)
{
FormulaData formulaData;
formulaData.formula = uiTabPassmarks->plainTextEditPassmarkAngle->toPlainText();
formulaData.variables = data->DataVariables();
formulaData.labelEditFormula = uiTabPassmarks->labelEditPassmarkAngle;
formulaData.labelResult = uiTabPassmarks->labelResultPassmarkAngle;
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
formulaData.checkZero = false;
formulaData.checkLessThanZero = false;
Eval(formulaData, flagFormulaPassmarkAngle);
UpdateNodePassmarkAngle(GetFormulaFromUser(uiTabPassmarks->plainTextEditPassmarkAngle));
}
else
{
ChangeColor(uiTabPassmarks->labelEditPassmarkAngle, OkColor(this));
uiTabPassmarks->labelResultPassmarkAngle->setText(tr("<Empty>"));
flagFormulaPassmarkAngle = true;
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::FXWidth()
{
@ -2413,7 +2506,33 @@ void DialogSeamAllowance::FXPassmarkLength()
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
if (dialog->exec() == QDialog::Accepted)
{
SetFormularPassmarkLength(dialog->GetFormula());
SetFormulaPassmarkLength(dialog->GetFormula());
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::FXPassmarkWidth()
{
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
dialog->setWindowTitle(tr("Edit passmark width"));
dialog->SetFormula(GetFormulaFromUser(uiTabPassmarks->plainTextEditPassmarkWidth));
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
if (dialog->exec() == QDialog::Accepted)
{
SetFormulaPassmarkWidth(dialog->GetFormula());
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::FXPassmarkAngle()
{
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
dialog->setWindowTitle(tr("Edit passmark angle"));
dialog->SetFormula(GetFormulaFromUser(uiTabPassmarks->plainTextEditPassmarkAngle));
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
if (dialog->exec() == QDialog::Accepted)
{
SetFormulaPassmarkAngle(dialog->GetFormula());
}
}
@ -2444,6 +2563,20 @@ void DialogSeamAllowance::DeployPassmarkLength()
m_formulaBasePassmarkLength);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::DeployPassmarkWidth()
{
DeployFormula(this, uiTabPassmarks->plainTextEditPassmarkWidth, uiTabPassmarks->pushButtonGrowPassmarkWidth,
m_formulaBasePassmarkWidth);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::DeployPassmarkAngle()
{
DeployFormula(this, uiTabPassmarks->plainTextEditPassmarkAngle, uiTabPassmarks->pushButtonGrowPassmarkAngle,
m_formulaBasePassmarkAngle);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::GrainlinePinPointChanged()
{
@ -2910,6 +3043,38 @@ void DialogSeamAllowance::UpdateNodePassmarkLength(const QString &formula)
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::UpdateNodePassmarkWidth(const QString &formula)
{
const int index = uiTabPassmarks->comboBoxPassmarks->currentIndex();
if (index != -1)
{
QListWidgetItem *rowItem = GetItemById(uiTabPassmarks->comboBoxPassmarks->currentData().toUInt());
if (rowItem)
{
auto rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
rowNode.SetFormulaPassmarkWidth(formula);
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::UpdateNodePassmarkAngle(const QString &formula)
{
const int index = uiTabPassmarks->comboBoxPassmarks->currentIndex();
if (index != -1)
{
QListWidgetItem *rowItem = GetItemById(uiTabPassmarks->comboBoxPassmarks->currentData().toUInt());
if (rowItem)
{
auto rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
rowNode.SetFormulaPassmarkAngle(formula);
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitFancyTabBar()
{
@ -3412,6 +3577,34 @@ void DialogSeamAllowance::InitPassmarksTab()
connect(uiTabPassmarks->pushButtonGrowPassmarkLength, &QPushButton::clicked, this,
&DialogSeamAllowance::DeployPassmarkLength);
// Width formula
this->m_formulaBasePassmarkWidth = uiTabPassmarks->plainTextEditPassmarkWidth->height();
uiTabPassmarks->plainTextEditPassmarkWidth->installEventFilter(this);
m_timerPassmarkWidth->setSingleShot(true);
connect(m_timerPassmarkWidth, &QTimer::timeout, this, &DialogSeamAllowance::EvalPassmarkWidth);
connect(uiTabPassmarks->groupBoxManualWidth, &QGroupBox::toggled, this,
&DialogSeamAllowance::EnabledManualPassmarkWidth);
connect(uiTabPassmarks->toolButtonExprWidth, &QPushButton::clicked, this, &DialogSeamAllowance::FXPassmarkWidth);
connect(uiTabPassmarks->plainTextEditPassmarkWidth, &QPlainTextEdit::textChanged, this,
[this]() { m_timerPassmarkWidth->start(formulaTimerTimeout); });
connect(uiTabPassmarks->pushButtonGrowPassmarkWidth, &QPushButton::clicked, this,
&DialogSeamAllowance::DeployPassmarkWidth);
// Angle formula
this->m_formulaBasePassmarkAngle = uiTabPassmarks->plainTextEditPassmarkAngle->height();
uiTabPassmarks->plainTextEditPassmarkAngle->installEventFilter(this);
m_timerPassmarkAngle->setSingleShot(true);
connect(m_timerPassmarkAngle, &QTimer::timeout, this, &DialogSeamAllowance::EvalPassmarkAngle);
connect(uiTabPassmarks->groupBoxManualAngle, &QGroupBox::toggled, this,
&DialogSeamAllowance::EnabledManualPassmarkAngle);
connect(uiTabPassmarks->toolButtonExprAngle, &QPushButton::clicked, this, &DialogSeamAllowance::FXPassmarkAngle);
connect(uiTabPassmarks->plainTextEditPassmarkAngle, &QPlainTextEdit::textChanged, this,
[this]() { m_timerPassmarkAngle->start(formulaTimerTimeout); });
connect(uiTabPassmarks->pushButtonGrowPassmarkAngle, &QPushButton::clicked, this,
&DialogSeamAllowance::DeployPassmarkAngle);
// notch list
InitPassmarksList();
connect(uiTabPassmarks->comboBoxPassmarks, QOverload<int>::of(&QComboBox::currentIndexChanged),
@ -3430,6 +3623,8 @@ void DialogSeamAllowance::InitPassmarksTab()
#endif
connect(uiTabPassmarks->checkBoxShowSecondPassmark, &QCheckBox::stateChanged, this,
&DialogSeamAllowance::PassmarkShowSecondChanged);
connect(uiTabPassmarks->checkBoxClockwiseOpening, &QCheckBox::stateChanged, this,
&DialogSeamAllowance::PassmarkClockwiseOrientationChanged);
}
//---------------------------------------------------------------------------------------------------------------------
@ -3502,7 +3697,7 @@ void DialogSeamAllowance::SetFormulaSAWidth(const QString &formula)
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetFormularPassmarkLength(const QString &formula)
void DialogSeamAllowance::SetFormulaPassmarkLength(const QString &formula)
{
const QString width = VAbstractApplication::VApp()->TrVars()
->FormulaToUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
@ -3516,6 +3711,36 @@ void DialogSeamAllowance::SetFormularPassmarkLength(const QString &formula)
MoveCursorToEnd(uiTabPassmarks->plainTextEditPassmarkLength);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetFormulaPassmarkWidth(const QString &formula)
{
const QString width = VAbstractApplication::VApp()->TrVars()->FormulaToUser(
formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
// increase height if needed.
if (width.length() > 80)
{
this->DeployPassmarkWidth();
}
uiTabPassmarks->plainTextEditPassmarkWidth->setPlainText(width);
MoveCursorToEnd(uiTabPassmarks->plainTextEditPassmarkWidth);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetFormulaPassmarkAngle(const QString &formula)
{
const QString width = VAbstractApplication::VApp()->TrVars()->FormulaToUser(
formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
// increase height if needed.
if (width.length() > 80)
{
this->DeployPassmarkAngle();
}
uiTabPassmarks->plainTextEditPassmarkAngle->setPlainText(width);
MoveCursorToEnd(uiTabPassmarks->plainTextEditPassmarkAngle);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::UpdateCurrentCustomSARecord()
{
@ -3961,6 +4186,225 @@ void DialogSeamAllowance::InitGradationPlaceholders()
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitPassmarkLengthFormula(const VPieceNode &node)
{
// notch depth
uiTabPassmarks->groupBoxManualLength->setEnabled(true);
if (node.IsManualPassmarkLength())
{
uiTabPassmarks->groupBoxManualLength->setChecked(true);
uiTabPassmarks->toolButtonExprLength->setEnabled(uiTabPassmarks->groupBoxManualLength->isChecked());
uiTabPassmarks->plainTextEditPassmarkLength->setEnabled(uiTabPassmarks->groupBoxManualLength->isChecked());
uiTabPassmarks->pushButtonGrowPassmarkLength->setEnabled(uiTabPassmarks->groupBoxManualLength->isChecked());
uiTabPassmarks->labelEditPassmarkLength->setEnabled(uiTabPassmarks->groupBoxManualLength->isChecked());
uiTabPassmarks->label_3->setEnabled(uiTabPassmarks->groupBoxManualLength->isChecked());
QString passmarkLength = node.GetFormulaPassmarkLength();
passmarkLength = VAbstractApplication::VApp()->TrVars()->FormulaToUser(
passmarkLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
if (passmarkLength.length() > 80) // increase height if needed.
{
this->DeployPassmarkLength();
}
if (passmarkLength.isEmpty())
{
qreal length = UnitConvertor(1, Unit::Cm, VAbstractValApplication::VApp()->patternUnits());
uiTabPassmarks->plainTextEditPassmarkLength->setPlainText(
VAbstractApplication::VApp()->LocaleToString(length));
}
else
{
uiTabPassmarks->plainTextEditPassmarkLength->setPlainText(passmarkLength);
}
}
else
{
qreal length = UnitConvertor(1, Unit::Cm, VAbstractValApplication::VApp()->patternUnits());
uiTabPassmarks->plainTextEditPassmarkLength->setPlainText(VAbstractApplication::VApp()->LocaleToString(length));
}
MoveCursorToEnd(uiTabPassmarks->plainTextEditPassmarkLength);
ChangeColor(uiTabPassmarks->labelEditPassmarkLength, OkColor(this));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitPassmarkWidthFormula(const VPieceNode &node)
{
// notch width
if (node.GetPassmarkLineType() != PassmarkLineType::OneLine)
{
uiTabPassmarks->groupBoxManualWidth->setEnabled(true);
if (node.IsManualPassmarkWidth())
{
uiTabPassmarks->groupBoxManualWidth->setChecked(true);
uiTabPassmarks->toolButtonExprWidth->setEnabled(uiTabPassmarks->groupBoxManualWidth->isChecked());
uiTabPassmarks->plainTextEditPassmarkWidth->setEnabled(uiTabPassmarks->groupBoxManualWidth->isChecked());
uiTabPassmarks->pushButtonGrowPassmarkWidth->setEnabled(uiTabPassmarks->groupBoxManualWidth->isChecked());
uiTabPassmarks->labelEditPassmarkWidth->setEnabled(uiTabPassmarks->groupBoxManualWidth->isChecked());
uiTabPassmarks->label_4->setEnabled(uiTabPassmarks->groupBoxManualWidth->isChecked());
QString passmarkWidth = node.GetFormulaPassmarkWidth();
passmarkWidth = VAbstractApplication::VApp()->TrVars()->FormulaToUser(
passmarkWidth, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
if (passmarkWidth.length() > 80) // increase height if needed.
{
this->DeployPassmarkWidth();
}
if (passmarkWidth.isEmpty())
{
qreal width = UnitConvertor(0.85, Unit::Cm, VAbstractValApplication::VApp()->patternUnits());
uiTabPassmarks->plainTextEditPassmarkWidth->setPlainText(
VAbstractApplication::VApp()->LocaleToString(width));
}
else
{
uiTabPassmarks->plainTextEditPassmarkWidth->setPlainText(passmarkWidth);
}
}
else
{
qreal length = UnitConvertor(0.85, Unit::Cm, VAbstractValApplication::VApp()->patternUnits());
uiTabPassmarks->plainTextEditPassmarkWidth->setPlainText(
VAbstractApplication::VApp()->LocaleToString(length));
}
MoveCursorToEnd(uiTabPassmarks->plainTextEditPassmarkWidth);
}
else
{
qreal length = UnitConvertor(0.85, Unit::Cm, VAbstractValApplication::VApp()->patternUnits());
uiTabPassmarks->plainTextEditPassmarkWidth->setPlainText(VAbstractApplication::VApp()->LocaleToString(length));
}
ChangeColor(uiTabPassmarks->labelEditPassmarkWidth, OkColor(this));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitPassmarkAngleFormula(const VPieceNode &node)
{
// notch angle
if (node.GetPassmarkAngleType() == PassmarkAngleType::Straightforward)
{
uiTabPassmarks->groupBoxManualAngle->setEnabled(true);
if (node.IsManualPassmarkAngle())
{
uiTabPassmarks->groupBoxManualAngle->setChecked(true);
uiTabPassmarks->toolButtonExprAngle->setEnabled(uiTabPassmarks->groupBoxManualAngle->isChecked());
uiTabPassmarks->plainTextEditPassmarkAngle->setEnabled(uiTabPassmarks->groupBoxManualAngle->isChecked());
uiTabPassmarks->pushButtonGrowPassmarkAngle->setEnabled(uiTabPassmarks->groupBoxManualAngle->isChecked());
uiTabPassmarks->labelEditPassmarkAngle->setEnabled(uiTabPassmarks->groupBoxManualAngle->isChecked());
uiTabPassmarks->label_5->setEnabled(uiTabPassmarks->groupBoxManualAngle->isChecked());
QString passmarkAngle = node.GetFormulaPassmarkAngle();
passmarkAngle = VAbstractApplication::VApp()->TrVars()->FormulaToUser(
passmarkAngle, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
if (passmarkAngle.length() > 80) // increase height if needed.
{
this->DeployPassmarkAngle();
}
uiTabPassmarks->plainTextEditPassmarkAngle->setPlainText(passmarkAngle.isEmpty() ? QString::number(0)
: passmarkAngle);
}
else
{
uiTabPassmarks->plainTextEditPassmarkAngle->setPlainText(QString::number(0));
}
MoveCursorToEnd(uiTabPassmarks->plainTextEditPassmarkAngle);
}
else
{
uiTabPassmarks->plainTextEditPassmarkAngle->setPlainText(QString::number(0));
}
ChangeColor(uiTabPassmarks->labelEditPassmarkAngle, OkColor(this));
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitPassmarkShapeType(const VPieceNode &node)
{
// Line type
uiTabPassmarks->groupBoxMarkType->setEnabled(true);
switch (node.GetPassmarkLineType())
{
case PassmarkLineType::OneLine:
uiTabPassmarks->radioButtonOneLine->setChecked(true);
break;
case PassmarkLineType::TwoLines:
uiTabPassmarks->radioButtonTwoLines->setChecked(true);
break;
case PassmarkLineType::ThreeLines:
uiTabPassmarks->radioButtonThreeLines->setChecked(true);
break;
case PassmarkLineType::TMark:
uiTabPassmarks->radioButtonTMark->setChecked(true);
break;
case PassmarkLineType::ExternalVMark:
uiTabPassmarks->radioButtonVMark->setChecked(true);
break;
case PassmarkLineType::InternalVMark:
uiTabPassmarks->radioButtonVMark2->setChecked(true);
break;
case PassmarkLineType::UMark:
uiTabPassmarks->radioButtonUMark->setChecked(true);
break;
case PassmarkLineType::BoxMark:
uiTabPassmarks->radioButtonBoxMark->setChecked(true);
break;
case PassmarkLineType::CheckMark:
uiTabPassmarks->radioButtonCheckMark->setChecked(true);
break;
default:
break;
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitPassmarkAngleType(const VPieceNode &node)
{
// Angle type
uiTabPassmarks->groupBoxAngleType->setEnabled(true);
switch (node.GetPassmarkAngleType())
{
case PassmarkAngleType::Straightforward:
uiTabPassmarks->radioButtonStraightforward->setChecked(true);
break;
case PassmarkAngleType::Bisector:
uiTabPassmarks->radioButtonBisector->setChecked(true);
break;
case PassmarkAngleType::Intersection:
uiTabPassmarks->radioButtonIntersection->setChecked(true);
break;
case PassmarkAngleType::IntersectionOnlyLeft:
uiTabPassmarks->radioButtonIntersectionOnlyLeft->setChecked(true);
break;
case PassmarkAngleType::IntersectionOnlyRight:
uiTabPassmarks->radioButtonIntersectionOnlyRight->setChecked(true);
break;
case PassmarkAngleType::Intersection2:
uiTabPassmarks->radioButtonIntersection2->setChecked(true);
break;
case PassmarkAngleType::Intersection2OnlyLeft:
uiTabPassmarks->radioButtonIntersection2OnlyLeft->setChecked(true);
break;
case PassmarkAngleType::Intersection2OnlyRight:
uiTabPassmarks->radioButtonIntersection2OnlyRight->setChecked(true);
break;
default:
break;
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetMoveControls()
{

View File

@ -107,6 +107,7 @@ private slots:
void PassmarkLineTypeChanged(int id);
void PassmarkAngleTypeChanged(int id);
void PassmarkShowSecondChanged(int state);
void PassmarkClockwiseOrientationChanged(int state);
void UpdateGrainlineValues();
void UpdateDetailLabelValues();
@ -134,21 +135,29 @@ private slots:
void EnabledDetailLabel();
void EnabledPatternLabel();
void EnabledManualPassmarkLength();
void EnabledManualPassmarkWidth();
void EnabledManualPassmarkAngle();
void EvalWidth();
void EvalWidthBefore();
void EvalWidthAfter();
void EvalPassmarkLength();
void EvalPassmarkWidth();
void EvalPassmarkAngle();
void FXWidth();
void FXWidthBefore();
void FXWidthAfter();
void FXPassmarkLength();
void FXPassmarkWidth();
void FXPassmarkAngle();
void DeployWidthFormulaTextEdit();
void DeployWidthBeforeFormulaTextEdit();
void DeployWidthAfterFormulaTextEdit();
void DeployPassmarkLength();
void DeployPassmarkWidth();
void DeployPassmarkAngle();
void GrainlinePinPointChanged();
void DetailPinPointChanged();
@ -195,6 +204,8 @@ private:
bool flagFormulaBefore{true};
bool flagFormulaAfter{true};
bool flagFormulaPassmarkLength{true};
bool flagFormulaPassmarkWidth{true};
bool flagFormulaPassmarkAngle{true};
bool flagMainPathIsValid{true};
bool flagName{true}; // We have default name of piece.
bool flagUUID{true};
@ -224,11 +235,15 @@ private:
int m_formulaBaseWidthBefore{0};
int m_formulaBaseWidthAfter{0};
int m_formulaBasePassmarkLength{0};
int m_formulaBasePassmarkWidth{0};
int m_formulaBasePassmarkAngle{0};
QTimer *m_timerWidth{nullptr};
QTimer *m_timerWidthBefore{nullptr};
QTimer *m_timerWidthAfter{nullptr};
QTimer *m_timerPassmarkLength{nullptr};
QTimer *m_timerPassmarkWidth{nullptr};
QTimer *m_timerPassmarkAngle{nullptr};
qreal m_saWidth{0};
QVector<VLabelTemplateLine> m_templateLines{};
@ -266,6 +281,8 @@ private:
void UpdateNodeSABefore(const QString &formula);
void UpdateNodeSAAfter(const QString &formula);
void UpdateNodePassmarkLength(const QString &formula);
void UpdateNodePassmarkWidth(const QString &formula);
void UpdateNodePassmarkAngle(const QString &formula);
void InitFancyTabBar();
void InitMainPathTab();
@ -286,7 +303,9 @@ private:
void InitAllPinComboboxes();
void SetFormulaSAWidth(const QString &formula);
void SetFormularPassmarkLength(const QString &formula);
void SetFormulaPassmarkLength(const QString &formula);
void SetFormulaPassmarkWidth(const QString &formula);
void SetFormulaPassmarkAngle(const QString &formula);
void SetGrainlineAngle(QString angleFormula);
void SetGrainlineLength(QString lengthFormula);
@ -317,6 +336,12 @@ private:
void InitGradationPlaceholdersMenu();
void InitGradationPlaceholders();
void InitPassmarkLengthFormula(const VPieceNode &node);
void InitPassmarkWidthFormula(const VPieceNode &node);
void InitPassmarkAngleFormula(const VPieceNode &node);
void InitPassmarkShapeType(const VPieceNode &node);
void InitPassmarkAngleType(const VPieceNode &node);
};
//---------------------------------------------------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@ -92,6 +92,7 @@ enum class ContextMenuOption : int
VMark2,
UMark,
BoxMark,
CheckMark,
Option,
InLayout,
ForbidFlipping,
@ -505,7 +506,7 @@ void VNodePoint::InitPassmarkLineTypeMenu(QMenu *menu, vidtype pieceId, QHash<in
return action;
};
Q_STATIC_ASSERT_X(static_cast<int>(PassmarkLineType::LAST_ONE_DO_NOT_USE) == 8, "Not all types were handled.");
Q_STATIC_ASSERT_X(static_cast<int>(PassmarkLineType::LAST_ONE_DO_NOT_USE) == 9, "Not all types were handled.");
contextMenu.insert(static_cast<int>(ContextMenuOption::OneLine),
InitPassmarkLineTypeAction(tr("One line"), PassmarkLineType::OneLine));
contextMenu.insert(static_cast<int>(ContextMenuOption::TwoLines),
@ -515,14 +516,15 @@ void VNodePoint::InitPassmarkLineTypeMenu(QMenu *menu, vidtype pieceId, QHash<in
contextMenu.insert(static_cast<int>(ContextMenuOption::TMark),
InitPassmarkLineTypeAction(tr("T mark"), PassmarkLineType::TMark));
contextMenu.insert(static_cast<int>(ContextMenuOption::VMark),
InitPassmarkLineTypeAction(tr("External V mark"), PassmarkLineType::VMark));
InitPassmarkLineTypeAction(tr("External V mark"), PassmarkLineType::ExternalVMark));
contextMenu.insert(static_cast<int>(ContextMenuOption::VMark2),
InitPassmarkLineTypeAction(tr("Internal V mark"), PassmarkLineType::VMark2));
InitPassmarkLineTypeAction(tr("Internal V mark"), PassmarkLineType::InternalVMark));
contextMenu.insert(static_cast<int>(ContextMenuOption::UMark),
InitPassmarkLineTypeAction(tr("U mark"), PassmarkLineType::UMark));
contextMenu.insert(static_cast<int>(ContextMenuOption::BoxMark),
InitPassmarkLineTypeAction(tr("Box mark"), PassmarkLineType::BoxMark));
contextMenu.insert(static_cast<int>(ContextMenuOption::CheckMark),
InitPassmarkLineTypeAction(tr("Check mark"), PassmarkLineType::CheckMark));
}
//---------------------------------------------------------------------------------------------------------------------
@ -582,7 +584,7 @@ void VNodePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
ContextMenuOption selectedOption = static_cast<ContextMenuOption>(
contextMenu.key(selectedAction, static_cast<int>(ContextMenuOption::NoSelection)));
Q_STATIC_ASSERT_X(static_cast<int>(ContextMenuOption::LAST_ONE_DO_NOT_USE) == 33,
Q_STATIC_ASSERT_X(static_cast<int>(ContextMenuOption::LAST_ONE_DO_NOT_USE) == 34,
"Not all options were handled.");
QT_WARNING_PUSH
@ -688,10 +690,10 @@ void VNodePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
SelectPassmarkLine(PassmarkLineType::TMark);
break;
case ContextMenuOption::VMark:
SelectPassmarkLine(PassmarkLineType::VMark);
SelectPassmarkLine(PassmarkLineType::ExternalVMark);
break;
case ContextMenuOption::VMark2:
SelectPassmarkLine(PassmarkLineType::VMark2);
SelectPassmarkLine(PassmarkLineType::InternalVMark);
break;
case ContextMenuOption::UMark:
SelectPassmarkLine(PassmarkLineType::UMark);
@ -699,6 +701,9 @@ void VNodePoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
case ContextMenuOption::BoxMark:
SelectPassmarkLine(PassmarkLineType::BoxMark);
break;
case ContextMenuOption::CheckMark:
SelectPassmarkLine(PassmarkLineType::CheckMark);
break;
};
QT_WARNING_POP
}

View File

@ -550,23 +550,66 @@ auto VAbstractTool::AddSANode(VAbstractPattern *doc, const QString &tagName, con
if (type == Tool::NodePoint)
{
doc->SetAttribute(nod, VAbstractPattern::AttrNodePassmark, node.IsPassmark());
doc->SetAttribute(nod, VAbstractPattern::AttrNodePassmarkLine,
PassmarkLineTypeToString(node.GetPassmarkLineType()));
doc->SetAttribute(nod, VAbstractPattern::AttrNodePassmarkAngle,
PassmarkAngleTypeToString(node.GetPassmarkAngleType()));
if (not node.IsPassmark()
&& node.GetPassmarkLineType() == PassmarkLineType::OneLine
&& node.GetPassmarkAngleType() == PassmarkAngleType::Straightforward)
{ // For backward compatebility.
nod.removeAttribute(VAbstractPattern::AttrNodePassmark);
nod.removeAttribute(VAbstractPattern::AttrNodePassmarkLine);
nod.removeAttribute(VAbstractPattern::AttrNodePassmarkAngle);
}
doc->SetAttributeOrRemoveIf<bool>(nod, VAbstractPattern::AttrNodePassmark, node.IsPassmark(),
[node](bool passmark) noexcept
{
return not passmark &&
node.GetPassmarkLineType() == PassmarkLineType::OneLine &&
node.GetPassmarkAngleType() == PassmarkAngleType::Straightforward;
});
doc->SetAttributeOrRemoveIf<QString>(
nod, VAbstractPattern::AttrNodePassmarkLine, PassmarkLineTypeToString(node.GetPassmarkLineType()),
[node](const QString &) noexcept
{
return not node.IsPassmark() && node.GetPassmarkLineType() == PassmarkLineType::OneLine &&
node.GetPassmarkAngleType() == PassmarkAngleType::Straightforward;
});
doc->SetAttributeOrRemoveIf<QString>(
nod, VAbstractPattern::AttrNodePassmarkAngle, PassmarkAngleTypeToString(node.GetPassmarkAngleType()),
[node](const QString &) noexcept
{
return not node.IsPassmark() && node.GetPassmarkLineType() == PassmarkLineType::OneLine &&
node.GetPassmarkAngleType() == PassmarkAngleType::Straightforward;
});
doc->SetAttributeOrRemoveIf<bool>(nod, VAbstractPattern::AttrNodeTurnPoint, node.IsTurnPoint(),
[](bool value) noexcept { return value; });
doc->SetAttributeOrRemoveIf<bool>(nod, VAbstractPattern::AttrNodeShowSecondPassmark,
node.IsShowSecondPassmark(), [](bool show) noexcept { return show; });
doc->SetAttributeOrRemoveIf<bool>(nod, VAbstractPattern::AttrNodePassmarkOpening,
node.IsPassmarkClockwiseOpening(),
[](bool opening) noexcept { return not opening; });
doc->SetAttributeOrRemoveIf<bool>(nod, VAbstractPattern::AttrManualPassmarkLength,
node.IsManualPassmarkLength(),
[](bool manualPassmarkLength) noexcept { return not manualPassmarkLength; });
doc->SetAttributeOrRemoveIf<QString>(nod, VAbstractPattern::AttrPassmarkLength, node.GetFormulaPassmarkLength(),
[node](const QString &) noexcept
{ return not node.IsManualPassmarkLength(); });
doc->SetAttributeOrRemoveIf<bool>(nod, VAbstractPattern::AttrManualPassmarkWidth, node.IsManualPassmarkWidth(),
[node](bool manualPassmarkWidth) noexcept {
return not manualPassmarkWidth ||
node.GetPassmarkLineType() == PassmarkLineType::OneLine;
});
doc->SetAttributeOrRemoveIf<QString>(nod, VAbstractPattern::AttrPassmarkWidth, node.GetFormulaPassmarkWidth(),
[node](const QString &) noexcept {
return not node.IsManualPassmarkWidth() ||
node.GetPassmarkLineType() == PassmarkLineType::OneLine;
});
doc->SetAttributeOrRemoveIf<bool>(nod, VAbstractPattern::AttrManualPassmarkAngle, node.IsManualPassmarkAngle(),
[node](bool manualPassmarkAngle) noexcept {
return not manualPassmarkAngle ||
node.GetPassmarkAngleType() == PassmarkAngleType::Straightforward;
});
doc->SetAttributeOrRemoveIf<QString>(nod, VAbstractPattern::AttrPassmarkAngle, node.GetFormulaPassmarkAngle(),
[node](const QString &) noexcept {
return not node.IsManualPassmarkAngle() ||
node.GetPassmarkAngleType() ==
PassmarkAngleType::Straightforward;
});
}
else
{ // Wrong configuration.
@ -575,14 +618,6 @@ auto VAbstractTool::AddSANode(VAbstractPattern *doc, const QString &tagName, con
nod.removeAttribute(VAbstractPattern::AttrNodePassmarkAngle);
}
doc->SetAttributeOrRemoveIf<bool>(nod, VAbstractPattern::AttrNodeShowSecondPassmark, node.IsShowSecondPassmark(),
[](bool show) noexcept {return show;});
doc->SetAttributeOrRemoveIf<bool>(nod, VAbstractPattern::AttrManualPassmarkLength, node.IsManualPassmarkLength(),
[](bool manualPassmarkLength) noexcept {return not manualPassmarkLength;});
doc->SetAttributeOrRemoveIf<QString>(nod, VAbstractPattern::AttrPassmarkLength, node.GetFormulaPassmarkLength(),
[node](const QString &) noexcept {return not node.IsManualPassmarkLength();});
return nod;
}