Standard passmarks length for all pieces. Closes #124

This commit is contained in:
Roman Telezhynskyi 2021-05-10 16:39:17 +03:00
parent 6bfc5065bd
commit 6abddfd240
23 changed files with 281 additions and 102 deletions

View File

@ -12,6 +12,7 @@
- Fix regression. Incorrect data caching. - Fix regression. Incorrect data caching.
- Improve tool tooltip. Show segment names and aliases. - Improve tool tooltip. Show segment names and aliases.
- Alias support for tools Point of intersection curve and axis and Point of intersection curves. - Alias support for tools Point of intersection curve and axis and Point of intersection curves.
- [smart-pattern/valentina#124] Standard passmarks length for all pieces.
# Version 0.7.46 Mar 31, 2021 # Version 0.7.46 Mar 31, 2021
- Fix incorrect calculation of value for multisize measurements in Valentina. - Fix incorrect calculation of value for multisize measurements in Valentina.

View File

@ -35,6 +35,7 @@
#include <QDate> #include <QDate>
#include <QMessageBox> #include <QMessageBox>
#include <QRadioButton> #include <QRadioButton>
#include <QCompleter>
#include "../xml/vpattern.h" #include "../xml/vpattern.h"
#include "../vpatterndb/vcontainer.h" #include "../vpatterndb/vcontainer.h"
@ -42,22 +43,14 @@
#include "../vtools/dialogs/support/dialogeditlabel.h" #include "../vtools/dialogs/support/dialogeditlabel.h"
#include "dialogknownmaterials.h" #include "dialogknownmaterials.h"
#include "../vmisc/vsettings.h" #include "../vmisc/vsettings.h"
#include "../qmuparser/qmudef.h"
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent) DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent)
: QDialog(parent), : QDialog(parent),
ui(new Ui::DialogPatternProperties), ui(new Ui::DialogPatternProperties),
doc(doc), doc(doc),
pattern(pattern), pattern(pattern)
data(QMap<QCheckBox *, int>()),
descriptionChanged(false),
gradationChanged(false),
defaultChanged(false),
securityChanged(false),
deleteAction(nullptr),
changeImageAction(nullptr),
saveImageAction(nullptr),
showImageAction(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -137,8 +130,27 @@ DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pat
ui->checkBoxPatternReadOnly->setDisabled(true); 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::MatchStartsWith);
m_completer->setCaseSensitivity(Qt::CaseSensitive);
ui->lineEditPassmarkLength->setCompleter(m_completer);
connect(ui->lineEditPassmarkLength, &QLineEdit::textEdited, this, [this]()
{
ValidatePassmarkLength();
DescEdited();
});
ui->lineEditPassmarkLength->installEventFilter(this);
m_oldPassmarkLength = doc->GetPassmarkLengthVariable();
ui->lineEditPassmarkLength->setText(m_oldPassmarkLength);
ValidatePassmarkLength();
//Initialization change value. Set to default value after initialization //Initialization change value. Set to default value after initialization
gradationChanged = false;
defaultChanged = false; defaultChanged = false;
securityChanged = false; securityChanged = false;
} }
@ -149,6 +161,27 @@ DialogPatternProperties::~DialogPatternProperties()
delete ui; delete ui;
} }
//---------------------------------------------------------------------------------------------------------------------
auto DialogPatternProperties::eventFilter(QObject *object, QEvent *event) -> bool
{
if (ui->lineEditPassmarkLength == qobject_cast<QLineEdit *>(object))
{
if (event->type() == QEvent::KeyPress)
{
auto *keyEvent = static_cast<QKeyEvent *>(event);
if ((keyEvent->key() == Qt::Key_Space) && ((keyEvent->modifiers() & Qt::ControlModifier) != 0U))
{
m_completer->complete();
return true;
}
}
return false;
}
return QDialog::eventFilter(object, event);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::Apply() void DialogPatternProperties::Apply()
{ {
@ -188,8 +221,16 @@ void DialogPatternProperties::SaveDescription()
doc->SetNotes(ui->plainTextEditTechNotes->document()->toPlainText()); doc->SetNotes(ui->plainTextEditTechNotes->document()->toPlainText());
doc->SetDescription(ui->plainTextEditDescription->document()->toPlainText()); doc->SetDescription(ui->plainTextEditDescription->document()->toPlainText());
doc->SetLabelPrefix(qvariant_cast<QString>(ui->comboBoxLabelLanguage->currentData())); doc->SetLabelPrefix(qvariant_cast<QString>(ui->comboBoxLabelLanguage->currentData()));
doc->SetPassmarkLengthVariable(ui->lineEditPassmarkLength->text());
if (m_oldPassmarkLength != ui->lineEditPassmarkLength->text())
{
emit UpddatePieces();
m_oldPassmarkLength = ui->lineEditPassmarkLength->text();
}
descriptionChanged = false; descriptionChanged = false;
emit doc->patternChanged(false);
} }
} }
@ -219,6 +260,27 @@ QImage DialogPatternProperties::GetImage()
return image; return image;
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::ValidatePassmarkLength() const
{
const QString text = ui->lineEditPassmarkLength->text();
QPalette palette = ui->lineEditPassmarkLength->palette();
const QPalette::ColorRole foregroundRole = ui->lineEditPassmarkLength->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->lineEditPassmarkLength->setPalette(palette);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPatternProperties::InitImage() void DialogPatternProperties::InitImage()
{ {

View File

@ -38,6 +38,7 @@
class VPattern; class VPattern;
class VContainer; class VContainer;
class QCheckBox; class QCheckBox;
class QCompleter;
namespace Ui namespace Ui
{ {
@ -50,6 +51,10 @@ class DialogPatternProperties : public QDialog
public: public:
explicit DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent = nullptr); explicit DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent = nullptr);
virtual ~DialogPatternProperties() override; virtual ~DialogPatternProperties() override;
signals:
void UpddatePieces();
protected:
virtual bool eventFilter(QObject *object, QEvent *event) override;
private slots: private slots:
void Apply(); void Apply();
void Ok(); void Ok();
@ -61,21 +66,25 @@ private:
Ui::DialogPatternProperties *ui; Ui::DialogPatternProperties *ui;
VPattern *doc; VPattern *doc;
VContainer *pattern; VContainer *pattern;
QMap<QCheckBox *, int> data; QMap<QCheckBox *, int> data{};
bool descriptionChanged; bool descriptionChanged{false};
bool gradationChanged; bool defaultChanged{false};
bool defaultChanged; bool securityChanged{false};
bool securityChanged; QAction *deleteAction{nullptr};
QAction *deleteAction; QAction *changeImageAction{nullptr};
QAction *changeImageAction; QAction *saveImageAction{nullptr};
QAction *saveImageAction; QAction *showImageAction{nullptr};
QAction *showImageAction; QCompleter *m_completer{nullptr};
QStringList m_variables{};
QString m_oldPassmarkLength{};
void SaveDescription(); void SaveDescription();
void SaveReadOnlyState(); void SaveReadOnlyState();
void InitImage(); void InitImage();
QImage GetImage(); QImage GetImage();
void ValidatePassmarkLength() const;
}; };
#endif // DIALOGPATTERNPROPERTIES_H #endif // DIALOGPATTERNPROPERTIES_H

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>571</width> <width>493</width>
<height>491</height> <height>582</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -81,8 +81,11 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QFormLayout" name="formLayout">
<item> <property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_12"> <widget class="QLabel" name="label_12">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred"> <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
@ -95,7 +98,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="0" column="1">
<widget class="QComboBox" name="comboBoxLabelLanguage"> <widget class="QComboBox" name="comboBoxLabelLanguage">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -105,18 +108,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="1" column="0">
<spacer name="horizontalSpacer_2"> <widget class="QLabel" name="label">
<property name="orientation"> <property name="text">
<enum>Qt::Horizontal</enum> <string>Passmark length:</string>
</property> </property>
<property name="sizeHint" stdset="0"> </widget>
<size> </item>
<width>40</width> <item row="1" column="1">
<height>20</height> <widget class="QLineEdit" name="lineEditPassmarkLength">
</size> <property name="clearButtonEnabled">
<bool>true</bool>
</property> </property>
</spacer> </widget>
</item> </item>
</layout> </layout>
</item> </item>

View File

@ -4923,6 +4923,8 @@ void MainWindow::CreateActions()
connect(ui->actionPattern_properties, &QAction::triggered, this, [this]() connect(ui->actionPattern_properties, &QAction::triggered, this, [this]()
{ {
DialogPatternProperties proper(doc, pattern, this); DialogPatternProperties proper(doc, pattern, this);
connect(&proper, &DialogPatternProperties::UpddatePieces, sceneDetails,
&VMainGraphicsScene::UpdatePiecePassmarks);
proper.exec(); proper.exec();
}); });

View File

@ -3700,21 +3700,21 @@ void VPattern::RefreshPieceGeometry()
VMainGraphicsView::NewSceneRect(sceneDetail, VAbstractValApplication::VApp()->getSceneView()); VMainGraphicsView::NewSceneRect(sceneDetail, VAbstractValApplication::VApp()->getSceneView());
}); });
if (VApplication::VApp()->IsGUIMode() && m_parsing) if (VApplication::IsGUIMode() && m_parsing)
{ {
return; return;
} }
for(auto pieceId : qAsConst(updatePieces)) for(auto pieceId : qAsConst(updatePieces))
{ {
if (VApplication::VApp()->IsGUIMode() && m_parsing) if (VApplication::IsGUIMode() && m_parsing)
{ {
return; return;
} }
try try
{ {
if (VToolSeamAllowance *piece = qobject_cast<VToolSeamAllowance *>(VAbstractPattern::getTool(pieceId))) if (auto *piece = qobject_cast<VToolSeamAllowance *>(VAbstractPattern::getTool(pieceId)))
{ {
piece->RefreshGeometry(); piece->RefreshGeometry();
} }
@ -3726,7 +3726,7 @@ void VPattern::RefreshPieceGeometry()
QApplication::processEvents(); QApplication::processEvents();
if (VApplication::VApp()->IsGUIMode() && m_parsing) if (VApplication::IsGUIMode() && m_parsing)
{ {
return; return;
} }

View File

@ -119,12 +119,11 @@ signals:
public slots: public slots:
virtual void LiteParseTree(const Document &parse) override; virtual void LiteParseTree(const Document &parse) override;
void RefreshPieceGeometry();
protected: protected:
virtual void customEvent(QEvent * event) override; virtual void customEvent(QEvent * event) override;
private slots:
void RefreshPieceGeometry();
private: private:
Q_DISABLE_COPY(VPattern) Q_DISABLE_COPY(VPattern)

View File

@ -762,6 +762,7 @@
</xs:sequence> </xs:sequence>
<xs:attribute name="readOnly" type="xs:boolean"/> <xs:attribute name="readOnly" type="xs:boolean"/>
<xs:attribute name="labelPrefix" type="labelPrefixType"/> <xs:attribute name="labelPrefix" type="labelPrefixType"/>
<xs:attribute name="passmarkLength" type="xs:string"/>
</xs:complexType> </xs:complexType>
<xs:unique name="incrementName"> <xs:unique name="incrementName">
<xs:selector xpath=".//increment"/> <xs:selector xpath=".//increment"/>

View File

@ -1200,6 +1200,31 @@ bool VAbstractPattern::GetPatternWasChanged() const
return patternLabelWasChanged; return patternLabelWasChanged;
} }
//---------------------------------------------------------------------------------------------------------------------
QString VAbstractPattern::GetPassmarkLengthVariable() const
{
const QDomElement pattern = documentElement();
if (pattern.isNull())
{
return {};
}
return GetParametrEmptyString(pattern, AttrPassmarkLength);
}
//---------------------------------------------------------------------------------------------------------------------
void VAbstractPattern::SetPassmarkLengthVariable(const QString &name)
{
QDomElement pattern = documentElement();
if (not pattern.isNull())
{
SetAttribute(pattern, AttrPassmarkLength, name);
modified = true;
}
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString VAbstractPattern::GetImage() const QString VAbstractPattern::GetImage() const
{ {

View File

@ -192,6 +192,9 @@ public:
void SetPatternWasChanged(bool changed); void SetPatternWasChanged(bool changed);
bool GetPatternWasChanged() const; bool GetPatternWasChanged() const;
QString GetPassmarkLengthVariable() const;
void SetPassmarkLengthVariable(const QString &name);
QString GetImage() const; QString GetImage() const;
QString GetImageExtension() const; QString GetImageExtension() const;
void SetImage(const QString &text, const QString &extension); void SetImage(const QString &text, const QString &extension);

View File

@ -1646,11 +1646,9 @@ qreal VSAPoint::PassmarkLength(qreal width) const
passmarkLength = qMin(passmarkLength, maxPassmarkLength); passmarkLength = qMin(passmarkLength, maxPassmarkLength);
return passmarkLength; return passmarkLength;
} }
else
{
return m_passmarkLength; return m_passmarkLength;
} }
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QJsonObject VSAPoint::toJson() const QJsonObject VSAPoint::toJson() const

View File

@ -537,6 +537,43 @@ QVector<QLineF> CreatePassmarkLines(PassmarkLineType lineType, PassmarkAngleType
return passmarksLines; return passmarksLines;
} }
//---------------------------------------------------------------------------------------------------------------------
auto PassmarkLength(const VPiecePassmarkData &passmarkData, qreal width, bool &ok) -> qreal
{
qreal length = 0;
if (not passmarkData.passmarkSAPoint.IsManualPasskmarkLength())
{
if (passmarkData.globalPassmarkLength > accuracyPointOnLine)
{
ok = true;
return passmarkData.globalPassmarkLength;
}
length = qMin(width * VSAPoint::passmarkFactor, VSAPoint::maxPassmarkLength);
if (length <= accuracyPointOnLine)
{
const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is less "
"than minimal allowed.")
.arg(passmarkData.nodeName, passmarkData.pieceName);
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
ok = false;
return length;
}
ok = true;
return length;
}
length = passmarkData.passmarkSAPoint.GetPasskmarkLength();
ok = true;
return length;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QLineF> PassmarkBisectorBaseLine(PassmarkStatus seamPassmarkType, const VPiecePassmarkData &passmarkData, QVector<QLineF> PassmarkBisectorBaseLine(PassmarkStatus seamPassmarkType, const VPiecePassmarkData &passmarkData,
const QPointF &seamPassmarkSAPoint, const QVector<QPointF> &seamAllowance) const QPointF &seamPassmarkSAPoint, const QVector<QPointF> &seamAllowance)
@ -572,14 +609,11 @@ QVector<QLineF> PassmarkBisectorBaseLine(PassmarkStatus seamPassmarkType, const
return QVector<QLineF>(); return QVector<QLineF>();
} }
const qreal length = passmarkData.passmarkSAPoint.PassmarkLength(passmarkData.saWidth); bool ok = false;
if (not passmarkData.passmarkSAPoint.IsManualPasskmarkLength() && length <= accuracyPointOnLine) const qreal length = PassmarkLength(passmarkData, passmarkData.passmarkSAPoint.MaxLocalSA(passmarkData.saWidth),
ok);
if (not ok)
{ {
const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is less "
"than minimal allowed.")
.arg(passmarkData.nodeName, passmarkData.pieceName);
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
return QVector<QLineF>(); return QVector<QLineF>();
} }
@ -624,6 +658,7 @@ QJsonObject VPiecePassmarkData::toJson() const
{"isShowSecondPassmark", isShowSecondPassmark}, {"isShowSecondPassmark", isShowSecondPassmark},
{"passmarkIndex", passmarkIndex}, {"passmarkIndex", passmarkIndex},
{"id", static_cast<qint64>(id)}, {"id", static_cast<qint64>(id)},
{"globalPassmarkLength", static_cast<qreal>(globalPassmarkLength)},
}; };
return dataObject; return dataObject;
@ -781,15 +816,11 @@ QVector<QLineF> VPassmark::BuiltInSAPassmarkBaseLine(const VPiece &piece) const
qreal length = 0; qreal length = 0;
if (not piece.IsSeamAllowanceBuiltIn()) if (not piece.IsSeamAllowanceBuiltIn())
{ {
length = m_data.passmarkSAPoint.PassmarkLength(m_data.saWidth); bool ok = false;
if (not m_data.passmarkSAPoint.IsManualPasskmarkLength() && length <= accuracyPointOnLine) length = PassmarkLength(m_data, m_data.passmarkSAPoint.MaxLocalSA(m_data.saWidth), ok);
if (not ok)
{ {
const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is less " return {};
"than minimal allowed.")
.arg(m_data.nodeName, m_data.pieceName);
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
return QVector<QLineF>();
} }
} }
else else
@ -888,35 +919,24 @@ QVector<QLineF> VPassmark::SAPassmarkBaseLine(const QVector<QPointF> &seamAllowa
if (intersections.last() != m_data.passmarkSAPoint) if (intersections.last() != m_data.passmarkSAPoint)
{ {
line = QLineF(intersections.last(), m_data.passmarkSAPoint); line = QLineF(intersections.last(), m_data.passmarkSAPoint);
if (not m_data.passmarkSAPoint.IsManualPasskmarkLength())
bool ok = false;
const qreal length = PassmarkLength(m_data, width, ok);
if (not ok)
{ {
const qreal length = qMin(width * VSAPoint::passmarkFactor, VSAPoint::maxPassmarkLength);
if (length <= accuracyPointOnLine)
{
const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is "
"less than minimal allowed.")
.arg(m_data.nodeName, m_data.pieceName);
VAbstractApplication::VApp()->IsPedantic() ? throw VException(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
return QLineF(); return QLineF();
} }
line.setLength(length); line.setLength(length);
}
else
{
line.setLength(m_data.passmarkSAPoint.GetPasskmarkLength());
}
return line; return line;
} }
else
{
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Notch " const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Notch "
"collapse.") "collapse.")
.arg(m_data.nodeName, m_data.pieceName); .arg(m_data.nodeName, m_data.pieceName);
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) : VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
} }
}
else else
{ {
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Cannot find " const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Cannot find "
@ -931,21 +951,17 @@ QVector<QLineF> VPassmark::SAPassmarkBaseLine(const QVector<QPointF> &seamAllowa
if (m_data.passmarkAngleType == PassmarkAngleType::Straightforward) if (m_data.passmarkAngleType == PassmarkAngleType::Straightforward)
{ {
const qreal length = m_data.passmarkSAPoint.PassmarkLength(m_data.saWidth); bool ok = false;
if (not m_data.passmarkSAPoint.IsManualPasskmarkLength() && length <= accuracyPointOnLine) const qreal length = PassmarkLength(m_data, m_data.passmarkSAPoint.MaxLocalSA(m_data.saWidth), ok);
if (not ok)
{ {
const QString errorMsg = QObject::tr("Found null notch for point '%1' in piece '%2'. Length is less " return {};
"than minimal allowed.")
.arg(m_data.nodeName, m_data.pieceName);
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) :
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
} }
else
{
QLineF line = QLineF(seamPassmarkSAPoint, m_data.passmarkSAPoint); QLineF line = QLineF(seamPassmarkSAPoint, m_data.passmarkSAPoint);
line.setLength(length); line.setLength(length);
return QVector<QLineF>({line}); return {line};
}
} }
else if (m_data.passmarkAngleType == PassmarkAngleType::Bisector) else if (m_data.passmarkAngleType == PassmarkAngleType::Bisector)
{ {

View File

@ -61,6 +61,7 @@ struct VPiecePassmarkData
bool isShowSecondPassmark{true}; bool isShowSecondPassmark{true};
int passmarkIndex{-1}; int passmarkIndex{-1};
vidtype id{NULL_ID}; vidtype id{NULL_ID};
qreal globalPassmarkLength{0};
QJsonObject toJson() const; QJsonObject toJson() const;
}; };
@ -102,7 +103,6 @@ private:
bool m_null{true}; bool m_null{true};
QVector<QLineF> MakeSAPassmark(const QVector<QPointF> &seamAllowance, PassmarkSide side) const; QVector<QLineF> MakeSAPassmark(const QVector<QPointF> &seamAllowance, PassmarkSide side) const;
}; };
#endif // VPASSMARK_H #endif // VPASSMARK_H

View File

@ -7,7 +7,7 @@
# File with common stuff for whole project # File with common stuff for whole project
include(../../../common.pri) include(../../../common.pri)
QT += core widgets printsupport QT += core widgets printsupport xmlpatterns concurrent
# Name of the library # Name of the library
TARGET = vpatterndb TARGET = vpatterndb

View File

@ -38,6 +38,7 @@
#include "../vmisc/compatibility.h" #include "../vmisc/compatibility.h"
#include "../ifc/exception/vexceptioninvalidnotch.h" #include "../ifc/exception/vexceptioninvalidnotch.h"
#include "../vlayout/testpath.h" #include "../vlayout/testpath.h"
#include "../ifc/xml/vabstractpattern.h"
#include <QSharedPointer> #include <QSharedPointer>
#include <QDebug> #include <QDebug>
@ -1106,6 +1107,7 @@ VPassmark VPiece::CreatePassmark(const QVector<VPieceNode> &path, int previousIn
passmarkData.isShowSecondPassmark = path.at(passmarkIndex).IsShowSecondPassmark(); passmarkData.isShowSecondPassmark = path.at(passmarkIndex).IsShowSecondPassmark();
passmarkData.passmarkIndex = passmarkIndex; passmarkData.passmarkIndex = passmarkIndex;
passmarkData.id = path.at(passmarkIndex).GetId(); passmarkData.id = path.at(passmarkIndex).GetId();
passmarkData.globalPassmarkLength = ToPixel(GlobalPassmarkLength(data), *data->GetPatternUnit());
return VPassmark(passmarkData); return VPassmark(passmarkData);
} }
@ -1170,6 +1172,39 @@ QJsonObject VPiece::DBToJson(const VContainer *data) const
return dbObject; return dbObject;
} }
//---------------------------------------------------------------------------------------------------------------------
auto VPiece::GlobalPassmarkLength(const VContainer *data) const -> qreal
{
qreal length = 0;
QString passmarkLengthVariable = VAbstractValApplication::VApp()->getCurrentDocument()->GetPassmarkLengthVariable();
if (passmarkLengthVariable.isEmpty())
{
return 0;
}
try
{
QSharedPointer<VInternalVariable> var = data->GetVariable<VInternalVariable>(passmarkLengthVariable);
length = *var->GetValue();
if (length <= accuracyPointOnLine)
{
const QString errorMsg = QObject::tr("Invalid global value for a passmark length. Piece '%1'. Length is "
"less than minimal allowed.")
.arg(GetName());
VAbstractApplication::VApp()->IsPedantic()
? throw VException(errorMsg)
: qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
}
}
catch (const VExceptionBadId &)
{
length = 0;
}
return length;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VPiece::DumpPiece(const VPiece &piece, const VContainer *data) void VPiece::DumpPiece(const VPiece &piece, const VContainer *data)
{ {

View File

@ -158,6 +158,8 @@ private:
QJsonObject MainPathToJson() const; QJsonObject MainPathToJson() const;
QJsonObject DBToJson(const VContainer *data) const; QJsonObject DBToJson(const VContainer *data) const;
qreal GlobalPassmarkLength(const VContainer *data) const;
}; };
Q_DECLARE_TYPEINFO(VPiece, Q_MOVABLE_TYPE); Q_DECLARE_TYPEINFO(VPiece, Q_MOVABLE_TYPE);

View File

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

View File

@ -710,6 +710,13 @@ void VToolSeamAllowance::UpdatePatternInfo()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::UpdatePassmarks()
{
const VPiece detail = VAbstractTool::data.GetPiece(m_id);
m_passmarks->setPath(detail.PassmarksPath(getData()));
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief VToolDetail::UpdateGrainline updates the grain line item * @brief VToolDetail::UpdateGrainline updates the grain line item
@ -1293,6 +1300,7 @@ VToolSeamAllowance::VToolSeamAllowance(const VToolSeamAllowanceInitData &initDat
connect(this, &VToolSeamAllowance::ChoosedTool, m_sceneDetails, &VMainGraphicsScene::ChoosedItem); connect(this, &VToolSeamAllowance::ChoosedTool, m_sceneDetails, &VMainGraphicsScene::ChoosedItem);
connect(m_sceneDetails, &VMainGraphicsScene::EnableToolMove, this, &VToolSeamAllowance::EnableToolMove); connect(m_sceneDetails, &VMainGraphicsScene::EnableToolMove, this, &VToolSeamAllowance::EnableToolMove);
connect(m_sceneDetails, &VMainGraphicsScene::ItemSelection, this, &VToolSeamAllowance::ToolSelectionType); connect(m_sceneDetails, &VMainGraphicsScene::ItemSelection, this, &VToolSeamAllowance::ToolSelectionType);
connect(m_sceneDetails, &VMainGraphicsScene::UpdatePassmarks, this, &VToolSeamAllowance::UpdatePassmarks);
ConnectOutsideSignals(); ConnectOutsideSignals();
} }

View File

@ -133,6 +133,7 @@ public slots:
void Highlight(quint32 id); void Highlight(quint32 id);
void UpdateDetailLabel(); void UpdateDetailLabel();
void UpdatePatternInfo(); void UpdatePatternInfo();
void UpdatePassmarks();
void ShowOptions(); void ShowOptions();
void DeleteFromMenu(); void DeleteFromMenu();
protected slots: protected slots:

View File

@ -319,6 +319,12 @@ void VMainGraphicsScene::HighlightItem(quint32 id)
emit HighlightDetail(id); emit HighlightDetail(id);
} }
//---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::UpdatePiecePassmarks()
{
emit UpdatePassmarks();
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VMainGraphicsScene::ToggleLabelSelection(bool enabled) void VMainGraphicsScene::ToggleLabelSelection(bool enabled)
{ {

View File

@ -74,6 +74,7 @@ public slots:
void EnableDetailsMode(bool mode); void EnableDetailsMode(bool mode);
void ItemsSelection(const SelectionType &type); void ItemsSelection(const SelectionType &type);
void HighlightItem(quint32 id); void HighlightItem(quint32 id);
void UpdatePiecePassmarks();
void ToggleLabelSelection(bool enabled); void ToggleLabelSelection(bool enabled);
void TogglePointSelection(bool enabled); void TogglePointSelection(bool enabled);
@ -123,6 +124,7 @@ signals:
void CurveDetailsMode(bool mode); void CurveDetailsMode(bool mode);
void ItemSelection(const SelectionType &type); void ItemSelection(const SelectionType &type);
void HighlightDetail(quint32 id); void HighlightDetail(quint32 id);
void UpdatePassmarks();
void EnableLabelItemSelection(bool enable); void EnableLabelItemSelection(bool enable);
void EnablePointItemSelection(bool enable); void EnablePointItemSelection(bool enable);

View File

@ -4,7 +4,7 @@
# #
#------------------------------------------------- #-------------------------------------------------
QT += testlib widgets printsupport concurrent xml QT += testlib widgets printsupport concurrent xml xmlpatterns
QT -= gui QT -= gui

View File

@ -4,7 +4,7 @@
# #
#------------------------------------------------- #-------------------------------------------------
QT += testlib widgets xml printsupport QT += testlib widgets xml printsupport concurrent xmlpatterns
QT -= gui QT -= gui