Standard passmarks length for all pieces. Closes #124
This commit is contained in:
parent
6bfc5065bd
commit
6abddfd240
|
@ -12,6 +12,7 @@
|
|||
- Fix regression. Incorrect data caching.
|
||||
- Improve tool tooltip. Show segment names and aliases.
|
||||
- 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
|
||||
- Fix incorrect calculation of value for multisize measurements in Valentina.
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <QDate>
|
||||
#include <QMessageBox>
|
||||
#include <QRadioButton>
|
||||
#include <QCompleter>
|
||||
|
||||
#include "../xml/vpattern.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
|
@ -42,22 +43,14 @@
|
|||
#include "../vtools/dialogs/support/dialogeditlabel.h"
|
||||
#include "dialogknownmaterials.h"
|
||||
#include "../vmisc/vsettings.h"
|
||||
#include "../qmuparser/qmudef.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
DialogPatternProperties::DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent)
|
||||
: QDialog(parent),
|
||||
ui(new Ui::DialogPatternProperties),
|
||||
doc(doc),
|
||||
pattern(pattern),
|
||||
data(QMap<QCheckBox *, int>()),
|
||||
descriptionChanged(false),
|
||||
gradationChanged(false),
|
||||
defaultChanged(false),
|
||||
securityChanged(false),
|
||||
deleteAction(nullptr),
|
||||
changeImageAction(nullptr),
|
||||
saveImageAction(nullptr),
|
||||
showImageAction(nullptr)
|
||||
pattern(pattern)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
|
@ -137,8 +130,27 @@ 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::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
|
||||
gradationChanged = false;
|
||||
defaultChanged = false;
|
||||
securityChanged = false;
|
||||
}
|
||||
|
@ -149,6 +161,27 @@ DialogPatternProperties::~DialogPatternProperties()
|
|||
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()
|
||||
{
|
||||
|
@ -188,8 +221,16 @@ void DialogPatternProperties::SaveDescription()
|
|||
doc->SetNotes(ui->plainTextEditTechNotes->document()->toPlainText());
|
||||
doc->SetDescription(ui->plainTextEditDescription->document()->toPlainText());
|
||||
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;
|
||||
emit doc->patternChanged(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,6 +260,27 @@ QImage DialogPatternProperties::GetImage()
|
|||
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()
|
||||
{
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
class VPattern;
|
||||
class VContainer;
|
||||
class QCheckBox;
|
||||
class QCompleter;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
|
@ -50,6 +51,10 @@ class DialogPatternProperties : public QDialog
|
|||
public:
|
||||
explicit DialogPatternProperties(VPattern *doc, VContainer *pattern, QWidget *parent = nullptr);
|
||||
virtual ~DialogPatternProperties() override;
|
||||
signals:
|
||||
void UpddatePieces();
|
||||
protected:
|
||||
virtual bool eventFilter(QObject *object, QEvent *event) override;
|
||||
private slots:
|
||||
void Apply();
|
||||
void Ok();
|
||||
|
@ -61,21 +66,25 @@ private:
|
|||
Ui::DialogPatternProperties *ui;
|
||||
VPattern *doc;
|
||||
VContainer *pattern;
|
||||
QMap<QCheckBox *, int> data;
|
||||
bool descriptionChanged;
|
||||
bool gradationChanged;
|
||||
bool defaultChanged;
|
||||
bool securityChanged;
|
||||
QAction *deleteAction;
|
||||
QAction *changeImageAction;
|
||||
QAction *saveImageAction;
|
||||
QAction *showImageAction;
|
||||
QMap<QCheckBox *, int> data{};
|
||||
bool descriptionChanged{false};
|
||||
bool defaultChanged{false};
|
||||
bool securityChanged{false};
|
||||
QAction *deleteAction{nullptr};
|
||||
QAction *changeImageAction{nullptr};
|
||||
QAction *saveImageAction{nullptr};
|
||||
QAction *showImageAction{nullptr};
|
||||
QCompleter *m_completer{nullptr};
|
||||
QStringList m_variables{};
|
||||
QString m_oldPassmarkLength{};
|
||||
|
||||
void SaveDescription();
|
||||
void SaveReadOnlyState();
|
||||
|
||||
void InitImage();
|
||||
QImage GetImage();
|
||||
|
||||
void ValidatePassmarkLength() const;
|
||||
};
|
||||
|
||||
#endif // DIALOGPATTERNPROPERTIES_H
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>571</width>
|
||||
<height>491</height>
|
||||
<width>493</width>
|
||||
<height>582</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -81,8 +81,11 @@
|
|||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_12">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
|
@ -95,7 +98,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="comboBoxLabelLanguage">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
|
@ -105,18 +108,19 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Passmark length:</string>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="lineEditPassmarkLength">
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</spacer>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
|
|
@ -4923,6 +4923,8 @@ void MainWindow::CreateActions()
|
|||
connect(ui->actionPattern_properties, &QAction::triggered, this, [this]()
|
||||
{
|
||||
DialogPatternProperties proper(doc, pattern, this);
|
||||
connect(&proper, &DialogPatternProperties::UpddatePieces, sceneDetails,
|
||||
&VMainGraphicsScene::UpdatePiecePassmarks);
|
||||
proper.exec();
|
||||
});
|
||||
|
||||
|
|
|
@ -3700,21 +3700,21 @@ void VPattern::RefreshPieceGeometry()
|
|||
VMainGraphicsView::NewSceneRect(sceneDetail, VAbstractValApplication::VApp()->getSceneView());
|
||||
});
|
||||
|
||||
if (VApplication::VApp()->IsGUIMode() && m_parsing)
|
||||
if (VApplication::IsGUIMode() && m_parsing)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(auto pieceId : qAsConst(updatePieces))
|
||||
{
|
||||
if (VApplication::VApp()->IsGUIMode() && m_parsing)
|
||||
if (VApplication::IsGUIMode() && m_parsing)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (VToolSeamAllowance *piece = qobject_cast<VToolSeamAllowance *>(VAbstractPattern::getTool(pieceId)))
|
||||
if (auto *piece = qobject_cast<VToolSeamAllowance *>(VAbstractPattern::getTool(pieceId)))
|
||||
{
|
||||
piece->RefreshGeometry();
|
||||
}
|
||||
|
@ -3726,7 +3726,7 @@ void VPattern::RefreshPieceGeometry()
|
|||
|
||||
QApplication::processEvents();
|
||||
|
||||
if (VApplication::VApp()->IsGUIMode() && m_parsing)
|
||||
if (VApplication::IsGUIMode() && m_parsing)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -119,12 +119,11 @@ signals:
|
|||
public slots:
|
||||
virtual void LiteParseTree(const Document &parse) override;
|
||||
|
||||
void RefreshPieceGeometry();
|
||||
|
||||
protected:
|
||||
virtual void customEvent(QEvent * event) override;
|
||||
|
||||
private slots:
|
||||
void RefreshPieceGeometry();
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VPattern)
|
||||
|
||||
|
|
|
@ -762,6 +762,7 @@
|
|||
</xs:sequence>
|
||||
<xs:attribute name="readOnly" type="xs:boolean"/>
|
||||
<xs:attribute name="labelPrefix" type="labelPrefixType"/>
|
||||
<xs:attribute name="passmarkLength" type="xs:string"/>
|
||||
</xs:complexType>
|
||||
<xs:unique name="incrementName">
|
||||
<xs:selector xpath=".//increment"/>
|
||||
|
|
|
@ -1200,6 +1200,31 @@ bool VAbstractPattern::GetPatternWasChanged() const
|
|||
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
|
||||
{
|
||||
|
|
|
@ -192,6 +192,9 @@ public:
|
|||
void SetPatternWasChanged(bool changed);
|
||||
bool GetPatternWasChanged() const;
|
||||
|
||||
QString GetPassmarkLengthVariable() const;
|
||||
void SetPassmarkLengthVariable(const QString &name);
|
||||
|
||||
QString GetImage() const;
|
||||
QString GetImageExtension() const;
|
||||
void SetImage(const QString &text, const QString &extension);
|
||||
|
|
|
@ -1646,10 +1646,8 @@ qreal VSAPoint::PassmarkLength(qreal width) const
|
|||
passmarkLength = qMin(passmarkLength, maxPassmarkLength);
|
||||
return passmarkLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_passmarkLength;
|
||||
}
|
||||
|
||||
return m_passmarkLength;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -537,6 +537,43 @@ QVector<QLineF> CreatePassmarkLines(PassmarkLineType lineType, PassmarkAngleType
|
|||
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,
|
||||
const QPointF &seamPassmarkSAPoint, const QVector<QPointF> &seamAllowance)
|
||||
|
@ -572,14 +609,11 @@ QVector<QLineF> PassmarkBisectorBaseLine(PassmarkStatus seamPassmarkType, const
|
|||
return QVector<QLineF>();
|
||||
}
|
||||
|
||||
const qreal length = passmarkData.passmarkSAPoint.PassmarkLength(passmarkData.saWidth);
|
||||
if (not passmarkData.passmarkSAPoint.IsManualPasskmarkLength() && length <= accuracyPointOnLine)
|
||||
bool ok = false;
|
||||
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>();
|
||||
}
|
||||
|
||||
|
@ -624,6 +658,7 @@ QJsonObject VPiecePassmarkData::toJson() const
|
|||
{"isShowSecondPassmark", isShowSecondPassmark},
|
||||
{"passmarkIndex", passmarkIndex},
|
||||
{"id", static_cast<qint64>(id)},
|
||||
{"globalPassmarkLength", static_cast<qreal>(globalPassmarkLength)},
|
||||
};
|
||||
|
||||
return dataObject;
|
||||
|
@ -781,15 +816,11 @@ QVector<QLineF> VPassmark::BuiltInSAPassmarkBaseLine(const VPiece &piece) const
|
|||
qreal length = 0;
|
||||
if (not piece.IsSeamAllowanceBuiltIn())
|
||||
{
|
||||
length = m_data.passmarkSAPoint.PassmarkLength(m_data.saWidth);
|
||||
if (not m_data.passmarkSAPoint.IsManualPasskmarkLength() && length <= accuracyPointOnLine)
|
||||
bool ok = false;
|
||||
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 "
|
||||
"than minimal allowed.")
|
||||
.arg(m_data.nodeName, m_data.pieceName);
|
||||
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) :
|
||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||
return QVector<QLineF>();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -888,34 +919,23 @@ QVector<QLineF> VPassmark::SAPassmarkBaseLine(const QVector<QPointF> &seamAllowa
|
|||
if (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();
|
||||
}
|
||||
line.setLength(length);
|
||||
}
|
||||
else
|
||||
{
|
||||
line.setLength(m_data.passmarkSAPoint.GetPasskmarkLength());
|
||||
return QLineF();
|
||||
}
|
||||
line.setLength(length);
|
||||
|
||||
return line;
|
||||
}
|
||||
else
|
||||
{
|
||||
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Notch "
|
||||
"collapse.")
|
||||
.arg(m_data.nodeName, m_data.pieceName);
|
||||
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) :
|
||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||
}
|
||||
|
||||
const QString errorMsg = QObject::tr("Cannot calculate a notch for point '%1' in piece '%2'. Notch "
|
||||
"collapse.")
|
||||
.arg(m_data.nodeName, m_data.pieceName);
|
||||
VAbstractApplication::VApp()->IsPedantic() ? throw VExceptionInvalidNotch(errorMsg) :
|
||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -931,21 +951,17 @@ QVector<QLineF> VPassmark::SAPassmarkBaseLine(const QVector<QPointF> &seamAllowa
|
|||
|
||||
if (m_data.passmarkAngleType == PassmarkAngleType::Straightforward)
|
||||
{
|
||||
const qreal length = m_data.passmarkSAPoint.PassmarkLength(m_data.saWidth);
|
||||
if (not m_data.passmarkSAPoint.IsManualPasskmarkLength() && length <= accuracyPointOnLine)
|
||||
bool ok = false;
|
||||
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 "
|
||||
"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);
|
||||
line.setLength(length);
|
||||
return QVector<QLineF>({line});
|
||||
return {};
|
||||
}
|
||||
|
||||
QLineF line = QLineF(seamPassmarkSAPoint, m_data.passmarkSAPoint);
|
||||
line.setLength(length);
|
||||
return {line};
|
||||
}
|
||||
else if (m_data.passmarkAngleType == PassmarkAngleType::Bisector)
|
||||
{
|
||||
|
|
|
@ -61,6 +61,7 @@ struct VPiecePassmarkData
|
|||
bool isShowSecondPassmark{true};
|
||||
int passmarkIndex{-1};
|
||||
vidtype id{NULL_ID};
|
||||
qreal globalPassmarkLength{0};
|
||||
|
||||
QJsonObject toJson() const;
|
||||
};
|
||||
|
@ -102,7 +103,6 @@ private:
|
|||
bool m_null{true};
|
||||
|
||||
QVector<QLineF> MakeSAPassmark(const QVector<QPointF> &seamAllowance, PassmarkSide side) const;
|
||||
|
||||
};
|
||||
|
||||
#endif // VPASSMARK_H
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# File with common stuff for whole project
|
||||
include(../../../common.pri)
|
||||
|
||||
QT += core widgets printsupport
|
||||
QT += core widgets printsupport xmlpatterns concurrent
|
||||
|
||||
# Name of the library
|
||||
TARGET = vpatterndb
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "../vmisc/compatibility.h"
|
||||
#include "../ifc/exception/vexceptioninvalidnotch.h"
|
||||
#include "../vlayout/testpath.h"
|
||||
#include "../ifc/xml/vabstractpattern.h"
|
||||
|
||||
#include <QSharedPointer>
|
||||
#include <QDebug>
|
||||
|
@ -1106,6 +1107,7 @@ VPassmark VPiece::CreatePassmark(const QVector<VPieceNode> &path, int previousIn
|
|||
passmarkData.isShowSecondPassmark = path.at(passmarkIndex).IsShowSecondPassmark();
|
||||
passmarkData.passmarkIndex = passmarkIndex;
|
||||
passmarkData.id = path.at(passmarkIndex).GetId();
|
||||
passmarkData.globalPassmarkLength = ToPixel(GlobalPassmarkLength(data), *data->GetPatternUnit());
|
||||
|
||||
return VPassmark(passmarkData);
|
||||
}
|
||||
|
@ -1170,6 +1172,39 @@ QJsonObject VPiece::DBToJson(const VContainer *data) const
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -158,6 +158,8 @@ private:
|
|||
|
||||
QJsonObject MainPathToJson() const;
|
||||
QJsonObject DBToJson(const VContainer *data) const;
|
||||
|
||||
qreal GlobalPassmarkLength(const VContainer *data) const;
|
||||
};
|
||||
|
||||
Q_DECLARE_TYPEINFO(VPiece, Q_MOVABLE_TYPE);
|
||||
|
|
|
@ -266,6 +266,11 @@ void AbstractTest::PassmarkDataFromJson(const QString &json, VPiecePassmarkData
|
|||
vidtype id;
|
||||
AbstractTest::ReadDoubleValue(passmarkData, QStringLiteral("id"), id, QString::number(NULL_ID));
|
||||
data.id = id;
|
||||
|
||||
qreal globalPassmarkLength;
|
||||
AbstractTest::ReadDoubleValue(passmarkData, QStringLiteral("globalPassmarkLength"), globalPassmarkLength,
|
||||
QString::number(NULL_ID));
|
||||
data.globalPassmarkLength = globalPassmarkLength;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -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
|
||||
|
@ -1293,6 +1300,7 @@ VToolSeamAllowance::VToolSeamAllowance(const VToolSeamAllowanceInitData &initDat
|
|||
connect(this, &VToolSeamAllowance::ChoosedTool, m_sceneDetails, &VMainGraphicsScene::ChoosedItem);
|
||||
connect(m_sceneDetails, &VMainGraphicsScene::EnableToolMove, this, &VToolSeamAllowance::EnableToolMove);
|
||||
connect(m_sceneDetails, &VMainGraphicsScene::ItemSelection, this, &VToolSeamAllowance::ToolSelectionType);
|
||||
connect(m_sceneDetails, &VMainGraphicsScene::UpdatePassmarks, this, &VToolSeamAllowance::UpdatePassmarks);
|
||||
|
||||
ConnectOutsideSignals();
|
||||
}
|
||||
|
|
|
@ -133,6 +133,7 @@ public slots:
|
|||
void Highlight(quint32 id);
|
||||
void UpdateDetailLabel();
|
||||
void UpdatePatternInfo();
|
||||
void UpdatePassmarks();
|
||||
void ShowOptions();
|
||||
void DeleteFromMenu();
|
||||
protected slots:
|
||||
|
|
|
@ -319,6 +319,12 @@ void VMainGraphicsScene::HighlightItem(quint32 id)
|
|||
emit HighlightDetail(id);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VMainGraphicsScene::UpdatePiecePassmarks()
|
||||
{
|
||||
emit UpdatePassmarks();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VMainGraphicsScene::ToggleLabelSelection(bool enabled)
|
||||
{
|
||||
|
|
|
@ -74,6 +74,7 @@ public slots:
|
|||
void EnableDetailsMode(bool mode);
|
||||
void ItemsSelection(const SelectionType &type);
|
||||
void HighlightItem(quint32 id);
|
||||
void UpdatePiecePassmarks();
|
||||
|
||||
void ToggleLabelSelection(bool enabled);
|
||||
void TogglePointSelection(bool enabled);
|
||||
|
@ -123,6 +124,7 @@ signals:
|
|||
void CurveDetailsMode(bool mode);
|
||||
void ItemSelection(const SelectionType &type);
|
||||
void HighlightDetail(quint32 id);
|
||||
void UpdatePassmarks();
|
||||
|
||||
void EnableLabelItemSelection(bool enable);
|
||||
void EnablePointItemSelection(bool enable);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += testlib widgets printsupport concurrent xml
|
||||
QT += testlib widgets printsupport concurrent xml xmlpatterns
|
||||
|
||||
QT -= gui
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += testlib widgets xml printsupport
|
||||
QT += testlib widgets xml printsupport concurrent xmlpatterns
|
||||
|
||||
QT -= gui
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user