A piece seam allowance can be controlled by formula.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-01-21 15:24:40 +02:00
parent 25a2717682
commit 0ef10c01b0
29 changed files with 2144 additions and 529 deletions

View File

@ -296,8 +296,9 @@ void VPattern::setCurrentData()
const VDataTool *vTool = tools.value(id);
*data = vTool->getData();
//Delete special variable if exist
//Delete special variables if exist
data->RemoveVariable(currentLength);
data->RemoveVariable(currentSeamAllowance);
qCDebug(vXML, "Data successfully updated.");
}
else
@ -690,7 +691,7 @@ void VPattern::ParseDrawMode(const QDomNode &node, const Document &parse, const
* @param domElement tag in xml tree.
* @param parse parser file mode.
*/
void VPattern::ParseDetailElement(const QDomElement &domElement, const Document &parse)
void VPattern::ParseDetailElement(QDomElement &domElement, const Document &parse)
{
Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null");
try
@ -701,12 +702,13 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document
detail.SetMx(qApp->toPixel(GetParametrDouble(domElement, AttrMx, "0.0")));
detail.SetMy(qApp->toPixel(GetParametrDouble(domElement, AttrMy, "0.0")));
detail.SetSeamAllowance(GetParametrBool(domElement, VToolSeamAllowance::AttrSeamAllowance, falseStr));
detail.SetSAWidth(GetParametrDouble(domElement, VToolSeamAllowance::AttrWidth, "0.0"));
detail.SetForbidFlipping(GetParametrBool(domElement, VToolSeamAllowance::AttrForbidFlipping,
QString().setNum(qApp->ValentinaSettings()->GetForbidWorkpieceFlipping())));
detail.SetInLayout(GetParametrBool(domElement, AttrInLayout, trueStr));
detail.SetUnited(GetParametrBool(domElement, VToolSeamAllowance::AttrUnited, falseStr));
const QString width = GetParametrString(domElement, VToolSeamAllowance::AttrWidth, "0.0");
QString w = width;//need for saving fixed formula;
const uint version = GetParametrUInt(domElement, VToolSeamAllowance::AttrVersion, "1");
const QStringList tags = QStringList() << TagNodes
@ -757,7 +759,14 @@ void VPattern::ParseDetailElement(const QDomElement &domElement, const Document
}
}
}
VToolSeamAllowance::Create(id, detail, sceneDetail, this, data, parse, Source::FromFile);
VToolSeamAllowance::Create(id, detail, w, sceneDetail, this, data, parse, Source::FromFile);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (w != width)
{
SetAttribute(domElement, VToolSeamAllowance::AttrWidth, w);
modified = true;
haveLiteChange();
}
}
catch (const VExceptionBadId &e)
{
@ -877,7 +886,7 @@ void VPattern::ParseDetails(const QDomElement &domElement, const Document &parse
{
if (domNode.isElement())
{
const QDomElement domElement = domNode.toElement();
QDomElement domElement = domNode.toElement();
if (domElement.isNull() == false)
{
if (domElement.tagName() == TagDetail)

View File

@ -118,7 +118,7 @@ private:
void ParseDrawElement(const QDomNode& node, const Document &parse);
void ParseDrawMode(const QDomNode& node, const Document &parse, const Draw &mode);
void ParseDetailElement(const QDomElement &domElement, const Document &parse);
void ParseDetailElement(QDomElement &domElement, const Document &parse);
void ParseDetailNodes(const QDomElement &domElement, VPiece &detail, bool closed) const;
void ParsePieceDataTag(const QDomElement &domElement, VPiece &detail) const;
void ParsePiecePatternInfo(const QDomElement &domElement, VPiece &detail) const;

View File

@ -370,8 +370,8 @@
<xs:attribute name="type" type="xs:string" use="required"/>
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"/>
<xs:attribute name="reverse" type="xs:unsignedInt"/>
<xs:attribute name="before" type="xs:double"/>
<xs:attribute name="after" type="xs:double"/>
<xs:attribute name="before" type="xs:string"/>
<xs:attribute name="after" type="xs:string"/>
<xs:attribute name="angle" type="nodeAngle"/>
</xs:complexType>
</xs:element>
@ -503,8 +503,8 @@
<xs:attribute name="type" type="xs:string" use="required"/>
<xs:attribute name="idObject" type="xs:unsignedInt" use="required"/>
<xs:attribute name="reverse" type="xs:unsignedInt"/>
<xs:attribute name="before" type="xs:double"/>
<xs:attribute name="after" type="xs:double"/>
<xs:attribute name="before" type="xs:string"/>
<xs:attribute name="after" type="xs:string"/>
<xs:attribute name="angle" type="nodeAngle"/>
<xs:attribute name="mx" type="xs:double"/>
<xs:attribute name="my" type="xs:double"/>
@ -547,7 +547,7 @@
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="inLayout" type="xs:boolean"/>
<xs:attribute name="forbidFlipping" type="xs:boolean"/>
<xs:attribute name="width" type="xs:double"/>
<xs:attribute name="width" type="xs:string"/>
<xs:attribute name="seamAllowance" type="xs:boolean"/>
<xs:attribute name="united" type="xs:boolean"/>
<xs:attribute name="closed" type="xs:unsignedInt"/>

View File

@ -634,8 +634,10 @@ VPieceNode VAbstractPattern::ParseSANode(const QDomElement &domElement)
{
const quint32 id = VDomDocument::GetParametrUInt(domElement, AttrIdObject, NULL_ID_STR);
const bool reverse = VDomDocument::GetParametrUInt(domElement, VAbstractPattern::AttrNodeReverse, "0");
const qreal saBefore = VDomDocument::GetParametrDouble(domElement, VAbstractPattern::AttrSABefore, "-1");
const qreal saAfter = VDomDocument::GetParametrDouble(domElement, VAbstractPattern::AttrSAAfter, "-1");
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, "0"));
const QString t = VDomDocument::GetParametrString(domElement, AttrType, VAbstractPattern::NodePoint);
@ -669,8 +671,8 @@ VPieceNode VAbstractPattern::ParseSANode(const QDomElement &domElement)
throw e;
}
VPieceNode node(id, tool, reverse);
node.SetSABefore(saBefore);
node.SetSAAfter(saAfter);
node.SetFormulaSABefore(saBefore);
node.SetFormulaSAAfter(saAfter);
node.SetAngleType(angle);
return node;

View File

@ -199,29 +199,29 @@ QVector<VPieceNode> VNodeDetail::Convert(const VContainer *data, const QVector<V
if (IsSABefore(QLineF(point, previosPoint), QLineF(point, xPoint)))
{
path[i].SetSABefore(LocalWidth(node.getMx()));
path[i].SetFormulaSABefore(QString().setNum(LocalWidth(node.getMx())));
if (IsSAAfter(QLineF(point, nextPoint), QLineF(point, yPoint)))
{
path[i].SetSAAfter(LocalWidth(node.getMy()));
path[i].SetFormulaSAAfter(QString().setNum(LocalWidth(node.getMy())));
}
}
else if (IsSABefore(QLineF(point, previosPoint), QLineF(point, yPoint)))
{
path[i].SetSABefore(LocalWidth(node.getMy()));
path[i].SetFormulaSABefore(QString().setNum(LocalWidth(node.getMy())));
if (IsSAAfter(QLineF(point, nextPoint), QLineF(point, xPoint)))
{
path[i].SetSAAfter(LocalWidth(node.getMx()));
path[i].SetFormulaSAAfter(QString().setNum(LocalWidth(node.getMx())));
}
}
else if (IsSAAfter(QLineF(point, nextPoint), QLineF(point, xPoint)))
{
path[i].SetSAAfter(LocalWidth(node.getMx()));
path[i].SetFormulaSAAfter(QString().setNum(LocalWidth(node.getMx())));
}
else if (IsSAAfter(QLineF(point, nextPoint), QLineF(point, yPoint)))
{
path[i].SetSAAfter(LocalWidth(node.getMy()));
path[i].SetFormulaSAAfter(QString().setNum(LocalWidth(node.getMy())));
}
}
}
@ -230,8 +230,8 @@ QVector<VPieceNode> VNodeDetail::Convert(const VContainer *data, const QVector<V
if (not closed && path.CountNodes() > 1)
{
path[0].SetSABefore(0);
path[path.CountNodes()-1].SetSAAfter(0);
path[0].SetFormulaSABefore("0");
path[path.CountNodes()-1].SetFormulaSAAfter("0");
}
return path.GetNodes();

View File

@ -269,6 +269,20 @@ void VPiece::SetUnited(bool united)
d->m_united = united;
}
//---------------------------------------------------------------------------------------------------------------------
QString VPiece::GetFormulaSAWidth() const
{
return d->m_formulaWidth;
}
//---------------------------------------------------------------------------------------------------------------------
void VPiece::SetFormulaSAWidth(const QString &formula, qreal value)
{
SetSAWidth(value);
const qreal width = GetSAWidth();
width >= 0 ? d->m_formulaWidth = formula : d->m_formulaWidth = QLatin1String("0");
}
//---------------------------------------------------------------------------------------------------------------------
QVector<quint32> VPiece::GetInternalPaths() const
{

View File

@ -79,6 +79,9 @@ public:
bool IsUnited() const;
void SetUnited(bool united);
QString GetFormulaSAWidth() const;
void SetFormulaSAWidth(const QString &formula, qreal value);
QVector<quint32> GetInternalPaths() const;
void SetInternalPaths(const QVector<quint32> &iPaths);
void AppendInternalPath(quint32 path);

View File

@ -56,7 +56,8 @@ public:
m_internalPaths(),
m_ppData(),
m_piPatternInfo(),
m_glGrainline()
m_glGrainline(),
m_formulaWidth("0")
{}
VPieceData(const VPieceData &detail)
@ -70,7 +71,8 @@ public:
m_internalPaths(detail.m_internalPaths),
m_ppData(detail.m_ppData),
m_piPatternInfo(detail.m_piPatternInfo),
m_glGrainline(detail.m_glGrainline)
m_glGrainline(detail.m_glGrainline),
m_formulaWidth(detail.m_formulaWidth)
{}
~VPieceData();
@ -96,6 +98,8 @@ public:
/** @brief m_glGrainline grainline geometry object*/
VGrainlineGeometry m_glGrainline;
QString m_formulaWidth;
private:
VPieceData &operator=(const VPieceData &) Q_DECL_EQ_DELETE;
};

View File

@ -28,8 +28,11 @@
#include "vpiecenode.h"
#include "vpiecenode_p.h"
#include "vcontainer.h"
#include "calculator.h"
#include <QDataStream>
#include <QtNumeric>
//---------------------------------------------------------------------------------------------------------------------
VPieceNode::VPieceNode()
@ -101,15 +104,15 @@ void VPieceNode::SetReverse(bool reverse)
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPieceNode::GetSABefore() const
qreal VPieceNode::GetSABefore(const VContainer *data) const
{
return d->m_saBefore;
return EvalFormula(data, d->m_formulaWidthBefore);
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPieceNode::GetSABefore(Unit unit) const
qreal VPieceNode::GetSABefore(const VContainer *data, Unit unit) const
{
qreal value = d->m_saBefore;
qreal value = EvalFormula(data, d->m_formulaWidthBefore);
if (value >= 0)
{
value = ToPixel(value, unit);
@ -118,24 +121,30 @@ qreal VPieceNode::GetSABefore(Unit unit) const
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceNode::SetSABefore(qreal value)
QString VPieceNode::GetFormulaSABefore() const
{
return d->m_formulaWidthBefore;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceNode::SetFormulaSABefore(const QString &formula)
{
if (d->m_typeTool == Tool::NodePoint)
{
value < 0 ? d->m_saBefore = -1: d->m_saBefore = value;
d->m_formulaWidthBefore = formula;
}
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPieceNode::GetSAAfter() const
qreal VPieceNode::GetSAAfter(const VContainer *data) const
{
return d->m_saAfter;
return EvalFormula(data, d->m_formulaWidthAfter);
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPieceNode::GetSAAfter(Unit unit) const
qreal VPieceNode::GetSAAfter(const VContainer *data, Unit unit) const
{
qreal value = d->m_saAfter;
qreal value = EvalFormula(data, d->m_formulaWidthAfter);
if (value >= 0)
{
value = ToPixel(value, unit);
@ -144,11 +153,17 @@ qreal VPieceNode::GetSAAfter(Unit unit) const
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceNode::SetSAAfter(qreal value)
QString VPieceNode::GetFormulaSAAfter() const
{
return d->m_formulaWidthAfter;
}
//---------------------------------------------------------------------------------------------------------------------
void VPieceNode::SetFormulaSAAfter(const QString &formula)
{
if (d->m_typeTool == Tool::NodePoint)
{
value < 0 ? d->m_saAfter = -1: d->m_saAfter = value;
d->m_formulaWidthAfter = formula;
}
}
@ -167,6 +182,36 @@ void VPieceNode::SetAngleType(PieceNodeAngle type)
}
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPieceNode::EvalFormula(const VContainer *data, QString formula) const
{
if (formula.isEmpty())
{
return -1;
}
else
{
try
{
// Replace line return character with spaces for calc if exist
formula.replace("\n", " ");
QScopedPointer<Calculator> cal(new Calculator());
const qreal result = cal->EvalFormula(data->PlainVariables(), formula);
if (qIsInf(result) || qIsNaN(result))
{
return -1;
}
return result;
}
catch (qmu::QmuParserError &e)
{
Q_UNUSED(e)
return -1;
}
}
}
// Friend functions
//---------------------------------------------------------------------------------------------------------------------
QDataStream& operator<<(QDataStream& out, const VPieceNode& p)

View File

@ -37,6 +37,7 @@
class VPieceNodeData;
class QDataStream;
class VContainer;
class VPieceNode
{
@ -59,18 +60,24 @@ public:
bool GetReverse() const;
void SetReverse(bool reverse);
qreal GetSABefore() const;
qreal GetSABefore(Unit unit) const;
void SetSABefore(qreal value);
qreal GetSABefore(const VContainer *data) const;
qreal GetSABefore(const VContainer *data, Unit unit) const;
qreal GetSAAfter() const;
qreal GetSAAfter(Unit unit) const;
void SetSAAfter(qreal value);
QString GetFormulaSABefore() const;
void SetFormulaSABefore(const QString &formula);
qreal GetSAAfter(const VContainer *data) const;
qreal GetSAAfter(const VContainer *data, Unit unit) const;
QString GetFormulaSAAfter() const;
void SetFormulaSAAfter(const QString &formula);
PieceNodeAngle GetAngleType() const;
void SetAngleType(PieceNodeAngle type);
private:
QSharedDataPointer<VPieceNodeData> d;
qreal EvalFormula(const VContainer *data, QString formula) const;
};
Q_DECLARE_METATYPE(VPieceNode)

View File

@ -45,6 +45,8 @@ public:
m_reverse(false),
m_saBefore(-1),
m_saAfter(-1),
m_formulaWidthBefore("-1"),
m_formulaWidthAfter("-1"),
m_angleType(PieceNodeAngle::ByLength)
{}
@ -54,6 +56,8 @@ public:
m_reverse(reverse),
m_saBefore(-1),
m_saAfter(-1),
m_formulaWidthBefore("-1"),
m_formulaWidthAfter("-1"),
m_angleType(PieceNodeAngle::ByLength)
{
if (m_typeTool == Tool::NodePoint)
@ -69,6 +73,8 @@ public:
m_reverse(node.m_reverse),
m_saBefore(node.m_saBefore),
m_saAfter(node.m_saAfter),
m_formulaWidthBefore(node.m_formulaWidthBefore),
m_formulaWidthAfter(node.m_formulaWidthAfter),
m_angleType(node.m_angleType)
{}
@ -86,6 +92,9 @@ public:
qreal m_saBefore;
qreal m_saAfter;
QString m_formulaWidthBefore;
QString m_formulaWidthAfter;
PieceNodeAngle m_angleType;
private:

View File

@ -656,8 +656,8 @@ VSAPoint VPiecePath::PreparePointEkv(const VPieceNode &node, const VContainer *d
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(node.GetId());
VSAPoint p(point->toQPointF());
p.SetSAAfter(node.GetSAAfter(*data->GetPatternUnit()));
p.SetSABefore(node.GetSABefore(*data->GetPatternUnit()));
p.SetSAAfter(node.GetSAAfter(data, *data->GetPatternUnit()));
p.SetSABefore(node.GetSABefore(data, *data->GetPatternUnit()));
p.SetAngleType(node.GetAngleType());
return p;
@ -762,8 +762,8 @@ VSAPoint VPiecePath::CurvePoint(const VSAPoint &candidate, const VContainer *dat
if (curve->IsPointOnCurve(p))
{
point = VSAPoint(p);
point.SetSAAfter(node.GetSAAfter(*data->GetPatternUnit()));
point.SetSABefore(node.GetSABefore(*data->GetPatternUnit()));
point.SetSAAfter(node.GetSAAfter(data, *data->GetPatternUnit()));
point.SetSABefore(node.GetSABefore(data, *data->GetPatternUnit()));
point.SetAngleType(node.GetAngleType());
}
}

View File

@ -77,7 +77,7 @@ enum {ColumnName = 0, ColumnFullName};
//---------------------------------------------------------------------------------------------------------------------
DialogEditWrongFormula::DialogEditWrongFormula(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogEditWrongFormula), formula(QString()), formulaBaseHeight(0),
checkZero(false), postfix(QString()), restoreCursor(false)
checkZero(false), checkLessThanZero(false), postfix(QString()), restoreCursor(false)
{
ui->setupUi(this);
InitVariables();
@ -156,7 +156,8 @@ void DialogEditWrongFormula::EvalFormula()
{
SCASSERT(plainTextEditFormula != nullptr)
SCASSERT(labelResultCalculation != nullptr)
Eval(plainTextEditFormula->toPlainText(), flagFormula, labelResultCalculation, postfix, checkZero);
Eval(plainTextEditFormula->toPlainText(), flagFormula, labelResultCalculation, postfix, checkZero,
checkLessThanZero);
}
//---------------------------------------------------------------------------------------------------------------------
@ -383,6 +384,12 @@ void DialogEditWrongFormula::setCheckZero(bool value)
checkZero = value;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::setCheckLessThanZero(bool value)
{
}
//---------------------------------------------------------------------------------------------------------------------
void DialogEditWrongFormula::setPostfix(const QString &value)
{

View File

@ -70,6 +70,7 @@ public:
QString GetFormula() const;
void SetFormula(const QString &value);
void setCheckZero(bool value);
void setCheckLessThanZero(bool value);
void setPostfix(const QString &value);
public slots:
virtual void DialogAccepted() Q_DECL_OVERRIDE;
@ -109,6 +110,7 @@ private:
int formulaBaseHeight;
bool checkZero;
bool checkLessThanZero;
QString postfix;
bool restoreCursor;

View File

@ -32,72 +32,34 @@
#include "visualization/path/vistoolpiecepath.h"
#include "../../tools/vabstracttool.h"
#include "../../tools/vtoolseamallowance.h"
#include "../support/dialogeditwrongformula.h"
#include <QMenu>
#include <QTimer>
//---------------------------------------------------------------------------------------------------------------------
DialogPiecePath::DialogPiecePath(const VContainer *data, quint32 toolId, QWidget *parent)
: DialogTool(data, toolId, parent),
ui(new Ui::DialogPiecePath),
m_showMode(false)
ui(new Ui::DialogPiecePath),
m_showMode(false),
m_saWidth(0),
m_timerWidth(nullptr),
m_timerWidthBefore(nullptr),
m_timerWidthAfter(nullptr),
m_formulaBaseWidth(0),
m_formulaBaseWidthBefore(0),
m_formulaBaseWidthAfter(0)
{
ui->setupUi(this);
InitOkCancel(ui);
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
ui->lineEditName->setClearButtonEnabled(true);
#endif
FillComboBoxTypeLine(ui->comboBoxPenType, VAbstractTool::LineStylesPics());
connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogPiecePath::NameChanged);
InitPathTypes();
connect(ui->comboBoxType, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
[this]()
{
ui->comboBoxPenType->setEnabled(GetType() == PiecePathType::InternalPath);
ValidObjects(PathIsValid());
});
InitPathTab();
InitSeamAllowanceTab();
flagName = true;//We have default name of piece.
flagError = PathIsValid();
CheckState();
const QString suffix = QLatin1String(" ") + VDomDocument::UnitsToStr(qApp->patternUnit(), true);
ui->doubleSpinBoxSeams->setSuffix(suffix);
ui->doubleSpinBoxSABefore->setSuffix(suffix);
ui->doubleSpinBoxSAAfter->setSuffix(suffix);
if(qApp->patternUnit() == Unit::Inch)
{
ui->doubleSpinBoxSeams->setDecimals(5);
ui->doubleSpinBoxSABefore->setDecimals(5);
ui->doubleSpinBoxSAAfter->setDecimals(5);
}
InitNodesList();
connect(ui->comboBoxNodes, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogPiecePath::NodeChanged);
connect(ui->pushButtonDefBefore, &QPushButton::clicked, this, &DialogPiecePath::ReturnDefBefore);
connect(ui->pushButtonDefAfter, &QPushButton::clicked, this, &DialogPiecePath::ReturnDefAfter);
connect(ui->doubleSpinBoxSeams, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
[this](){NodeChanged(ui->comboBoxNodes->currentIndex());});
connect(ui->doubleSpinBoxSABefore, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogPiecePath::ChangedSABefore);
connect(ui->doubleSpinBoxSAAfter, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogPiecePath::ChangedSAAfter);
InitNodeAngles(ui->comboBoxAngle);
connect(ui->comboBoxAngle, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogPiecePath::NodeAngleChanged);
ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->listWidget, &QListWidget::customContextMenuRequested, this, &DialogPiecePath::ShowContextMenu);
vis = new VisToolPiecePath(data);
ui->tabWidget->removeTab(1);
@ -314,14 +276,18 @@ void DialogPiecePath::NameChanged()
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::NodeChanged(int index)
{
ui->doubleSpinBoxSABefore->setDisabled(true);
ui->doubleSpinBoxSAAfter->setDisabled(true);
ui->plainTextEditFormulaWidthBefore->setDisabled(true);
ui->toolButtonExprBefore->setDisabled(true);
ui->pushButtonDefBefore->setDisabled(true);
ui->plainTextEditFormulaWidthAfter->setDisabled(true);
ui->toolButtonExprAfter->setDisabled(true);
ui->pushButtonDefAfter->setDisabled(true);
ui->comboBoxAngle->setDisabled(true);
ui->doubleSpinBoxSABefore->blockSignals(true);
ui->doubleSpinBoxSAAfter->blockSignals(true);
ui->plainTextEditFormulaWidthBefore->blockSignals(true);
ui->plainTextEditFormulaWidthAfter->blockSignals(true);
ui->comboBoxAngle->blockSignals(true);
if (index != -1)
@ -337,32 +303,42 @@ void DialogPiecePath::NodeChanged(int index)
{
const VPieceNode &node = path.at(nodeIndex);
ui->doubleSpinBoxSABefore->setEnabled(true);
ui->doubleSpinBoxSAAfter->setEnabled(true);
ui->comboBoxAngle->setEnabled(true);
// Seam alowance before
ui->plainTextEditFormulaWidthBefore->setEnabled(true);
ui->toolButtonExprBefore->setEnabled(true);
qreal w1 = node.GetSABefore();
if (w1 < 0)
{
w1 = ui->doubleSpinBoxSeams->value();
}
else
QString w1Formula = node.GetFormulaSABefore();
if (w1Formula != currentSeamAllowance)
{
ui->pushButtonDefBefore->setEnabled(true);
}
ui->doubleSpinBoxSABefore->setValue(w1);
qreal w2 = node.GetSAAfter();
if (w2 < 0)
if (w1Formula.length() > 80)// increase height if needed.
{
w2 = ui->doubleSpinBoxSeams->value();
this->DeployWidthBeforeFormulaTextEdit();
}
else
{
ui->pushButtonDefAfter->setEnabled(true);
}
ui->doubleSpinBoxSAAfter->setValue(w2);
w1Formula = qApp->TrVars()->FormulaToUser(w1Formula, qApp->Settings()->GetOsSeparator());
ui->plainTextEditFormulaWidthBefore->setPlainText(w1Formula);
MoveCursorToEnd(ui->plainTextEditFormulaWidthBefore);
// Seam alowance after
ui->plainTextEditFormulaWidthAfter->setEnabled(true);
ui->toolButtonExprAfter->setEnabled(true);
QString w2Formula = node.GetFormulaSAAfter();
if (w2Formula != currentSeamAllowance)
{
ui->pushButtonDefBefore->setEnabled(true);
}
if (w2Formula.length() > 80)// increase height if needed.
{
this->DeployWidthAfterFormulaTextEdit();
}
w2Formula = qApp->TrVars()->FormulaToUser(w2Formula, qApp->Settings()->GetOsSeparator());
ui->plainTextEditFormulaWidthAfter->setPlainText(w2Formula);
MoveCursorToEnd(ui->plainTextEditFormulaWidthAfter);
// Angle type
ui->comboBoxAngle->setEnabled(true);
const int index = ui->comboBoxAngle->findData(static_cast<unsigned char>(node.GetAngleType()));
if (index != -1)
{
@ -372,38 +348,238 @@ void DialogPiecePath::NodeChanged(int index)
}
else
{
ui->doubleSpinBoxSABefore->setValue(0);
ui->doubleSpinBoxSAAfter->setValue(0);
ui->plainTextEditFormulaWidthBefore->setPlainText("");
ui->plainTextEditFormulaWidthAfter->setPlainText("");
ui->comboBoxAngle->setCurrentIndex(-1);
}
ui->doubleSpinBoxSABefore->blockSignals(false);
ui->doubleSpinBoxSAAfter->blockSignals(false);
ui->plainTextEditFormulaWidthBefore->blockSignals(false);
ui->plainTextEditFormulaWidthAfter->blockSignals(false);
ui->comboBoxAngle->blockSignals(false);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::ReturnDefBefore()
{
SetCurrentSABefore(-1);
ui->plainTextEditFormulaWidthBefore->setPlainText(currentSeamAllowance);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::ReturnDefAfter()
{
SetCurrentSAAfter(-1);
ui->plainTextEditFormulaWidthAfter->setPlainText(currentSeamAllowance);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::ChangedSABefore(double d)
void DialogPiecePath::EvalWidth()
{
SetCurrentSABefore(d);
labelEditFormula = ui->labelEditWidth;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
const QString formula = ui->plainTextEditFormulaWidth->toPlainText();
m_saWidth = Eval(formula, flagFormula, ui->labelResultWidth, postfix, true, true);
if (m_saWidth >= 0)
{
VContainer *locData = const_cast<VContainer *> (data);
locData->AddVariable(currentSeamAllowance, new VIncrement(locData, currentSeamAllowance, 0, m_saWidth,
QString().setNum(m_saWidth), true,
tr("Current seam aloowance")));
EvalWidthBefore();
EvalWidthAfter();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::ChangedSAAfter(double d)
void DialogPiecePath::EvalWidthBefore()
{
SetCurrentSAAfter(d);
labelEditFormula = ui->labelEditBefore;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
const QString formula = ui->plainTextEditFormulaWidthBefore->toPlainText();
bool flagFormula = false; // fake flag
Eval(formula, flagFormula, ui->labelResultBefore, postfix, true, true);
UpdateNodeSABefore(GetFormulaSAWidthBefore());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::EvalWidthAfter()
{
labelEditFormula = ui->labelEditAfter;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
const QString formula = ui->plainTextEditFormulaWidthAfter->toPlainText();
bool flagFormula = false; // fake flag
Eval(formula, flagFormula, ui->labelResultAfter, postfix, true, true);
UpdateNodeSABefore(GetFormulaSAWidthAfter());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::FXWidth()
{
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit seam allowance width"));
dialog->SetFormula(GetFormulaSAWidth());
dialog->setCheckLessThanZero(true);
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted)
{
SetFormulaSAWidth(dialog->GetFormula());
}
delete dialog;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::FXWidthBefore()
{
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit seam allowance width before"));
dialog->SetFormula(GetFormulaSAWidthBefore());
dialog->setCheckLessThanZero(true);
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted)
{
SetCurrentSABefore(dialog->GetFormula());
}
delete dialog;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::FXWidthAfter()
{
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit seam allowance width after"));
dialog->SetFormula(GetFormulaSAWidthAfter());
dialog->setCheckLessThanZero(true);
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted)
{
SetCurrentSAAfter(dialog->GetFormula());
}
delete dialog;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::WidthChanged()
{
labelEditFormula = ui->labelEditWidth;
labelResultCalculation = ui->labelResultWidth;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
ValFormulaChanged(flagFormula, ui->plainTextEditFormulaWidth, m_timerWidth, postfix);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::WidthBeforeChanged()
{
labelEditFormula = ui->labelEditBefore;
labelResultCalculation = ui->labelResultBefore;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
bool flagFormula = false;
ValFormulaChanged(flagFormula, ui->plainTextEditFormulaWidthBefore, m_timerWidthBefore, postfix);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::WidthAfterChanged()
{
labelEditFormula = ui->labelEditAfter;
labelResultCalculation = ui->labelResultAfter;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
bool flagFormula = false;
ValFormulaChanged(flagFormula, ui->plainTextEditFormulaWidthAfter, m_timerWidthAfter, postfix);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::DeployWidthFormulaTextEdit()
{
DeployFormula(ui->plainTextEditFormulaWidth, ui->pushButtonGrowWidth, m_formulaBaseWidth);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::DeployWidthBeforeFormulaTextEdit()
{
DeployFormula(ui->plainTextEditFormulaWidthBefore, ui->pushButtonGrowWidthBefore, m_formulaBaseWidthBefore);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::DeployWidthAfterFormulaTextEdit()
{
DeployFormula(ui->plainTextEditFormulaWidthAfter, ui->pushButtonGrowWidthAfter, m_formulaBaseWidthAfter);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::InitPathTab()
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
ui->lineEditName->setClearButtonEnabled(true);
#endif
FillComboBoxTypeLine(ui->comboBoxPenType, VAbstractTool::LineStylesPics());
connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogPiecePath::NameChanged);
InitPathTypes();
connect(ui->comboBoxType, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
[this]()
{
ui->comboBoxPenType->setEnabled(GetType() == PiecePathType::InternalPath);
ValidObjects(PathIsValid());
});
ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->listWidget, &QListWidget::customContextMenuRequested, this, &DialogPiecePath::ShowContextMenu);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::InitSeamAllowanceTab()
{
plainTextEditFormula = ui->plainTextEditFormulaWidth;
this->m_formulaBaseWidth = ui->plainTextEditFormulaWidth->height();
this->m_formulaBaseWidthBefore = ui->plainTextEditFormulaWidthBefore->height();
this->m_formulaBaseWidthAfter = ui->plainTextEditFormulaWidthAfter->height();
ui->plainTextEditFormulaWidth->installEventFilter(this);
ui->plainTextEditFormulaWidthBefore->installEventFilter(this);
ui->plainTextEditFormulaWidthAfter->installEventFilter(this);
m_timerWidth = new QTimer(this);
connect(m_timerWidth, &QTimer::timeout, this, &DialogPiecePath::EvalWidth);
m_timerWidthBefore = new QTimer(this);
connect(m_timerWidthBefore, &QTimer::timeout, this, &DialogPiecePath::EvalWidthBefore);
m_timerWidthAfter = new QTimer(this);
connect(m_timerWidthAfter, &QTimer::timeout, this, &DialogPiecePath::EvalWidthAfter);
// Default value for seam allowence is 1 cm. But pattern have different units, so just set 1 in dialog not enough.
m_saWidth = UnitConvertor(1, Unit::Cm, qApp->patternUnit());
ui->plainTextEditFormulaWidth->setPlainText(qApp->LocaleToString(m_saWidth));
InitNodesList();
connect(ui->comboBoxNodes, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogPiecePath::NodeChanged);
connect(ui->pushButtonDefBefore, &QPushButton::clicked, this, &DialogPiecePath::ReturnDefBefore);
connect(ui->pushButtonDefAfter, &QPushButton::clicked, this, &DialogPiecePath::ReturnDefAfter);
InitNodeAngles(ui->comboBoxAngle);
connect(ui->comboBoxAngle, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogPiecePath::NodeAngleChanged);
connect(ui->toolButtonExprWidth, &QPushButton::clicked, this, &DialogPiecePath::FXWidth);
connect(ui->toolButtonExprBefore, &QPushButton::clicked, this, &DialogPiecePath::FXWidthBefore);
connect(ui->toolButtonExprAfter, &QPushButton::clicked, this, &DialogPiecePath::FXWidthAfter);
connect(ui->plainTextEditFormulaWidth, &QPlainTextEdit::textChanged, this, &DialogPiecePath::WidthChanged);
connect(ui->plainTextEditFormulaWidthBefore, &QPlainTextEdit::textChanged, this,
&DialogPiecePath::WidthBeforeChanged);
connect(ui->plainTextEditFormulaWidthAfter, &QPlainTextEdit::textChanged, this,
&DialogPiecePath::WidthAfterChanged);
connect(ui->pushButtonGrowWidth, &QPushButton::clicked, this, &DialogPiecePath::DeployWidthFormulaTextEdit);
connect(ui->pushButtonGrowWidthBefore, &QPushButton::clicked,
this, &DialogPiecePath::DeployWidthBeforeFormulaTextEdit);
connect(ui->pushButtonGrowWidthAfter, &QPushButton::clicked, this,
&DialogPiecePath::DeployWidthAfterFormulaTextEdit);
}
//---------------------------------------------------------------------------------------------------------------------
@ -582,7 +758,21 @@ quint32 DialogPiecePath::GetLastId() const
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::SetCurrentSABefore(qreal value)
void DialogPiecePath::SetCurrentSABefore(const QString &formula)
{
UpdateNodeSABefore(formula);
ListChanged();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::SetCurrentSAAfter(const QString &formula)
{
UpdateNodeSAAfter(formula);
ListChanged();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::UpdateNodeSABefore(const QString &formula)
{
const int index = ui->comboBoxNodes->currentIndex();
if (index != -1)
@ -597,16 +787,14 @@ void DialogPiecePath::SetCurrentSABefore(qreal value)
if (rowItem)
{
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
rowNode.SetSABefore(value);
rowNode.SetFormulaSABefore(formula);
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
ListChanged();
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::SetCurrentSAAfter(qreal value)
void DialogPiecePath::UpdateNodeSAAfter(const QString &formula)
{
const int index = ui->comboBoxNodes->currentIndex();
if (index != -1)
@ -621,14 +809,30 @@ void DialogPiecePath::SetCurrentSAAfter(qreal value)
if (rowItem)
{
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
rowNode.SetSAAfter(value);
rowNode.SetFormulaSAAfter(formula);
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
ListChanged();
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::SetFormulaSAWidth(const QString &formula)
{
const QString width = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator());
// increase height if needed.
if (width.length() > 80)
{
this->DeployWidthFormulaTextEdit();
}
ui->plainTextEditFormulaWidth->setPlainText(width);
VisToolPiecePath *path = qobject_cast<VisToolPiecePath *>(vis);
SCASSERT(path != nullptr)
path->SetPath(CreatePath());
MoveCursorToEnd(ui->plainTextEditFormulaWidth);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 DialogPiecePath::GetPieceId() const
{
@ -667,17 +871,11 @@ void DialogPiecePath::SetPieceId(quint32 id)
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::SetSAWidth(qreal width)
QString DialogPiecePath::GetFormulaSAWidth() const
{
if (width >=0)
{
ui->tabWidget->addTab(ui->tabSeamAllowance, tr("Seam allowance"));
ui->doubleSpinBoxSeams->setValue(width);
}
else
{
ui->tabWidget->removeTab(1);
}
QString width = ui->plainTextEditFormulaWidth->toPlainText();
width.replace("\n", " ");
return qApp->TrVars()->TryFormulaFromUser(width, qApp->Settings()->GetOsSeparator());
}
//---------------------------------------------------------------------------------------------------------------------
@ -758,3 +956,19 @@ void DialogPiecePath::NewItem(const VPieceNode &node)
{
NewNodeItem(ui->listWidget, node);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogPiecePath::GetFormulaSAWidthBefore() const
{
QString width = ui->plainTextEditFormulaWidthBefore->toPlainText();
width.replace("\n", " ");
return qApp->TrVars()->TryFormulaFromUser(width, qApp->Settings()->GetOsSeparator());
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogPiecePath::GetFormulaSAWidthAfter() const
{
QString width = ui->plainTextEditFormulaWidthAfter->toPlainText();
width.replace("\n", " ");
return qApp->TrVars()->TryFormulaFromUser(width, qApp->Settings()->GetOsSeparator());
}

View File

@ -51,7 +51,8 @@ public:
quint32 GetPieceId() const;
void SetPieceId(quint32 id);
void SetSAWidth(qreal width);
QString GetFormulaSAWidth() const;
void SetFormulaSAWidth(const QString &formula);
virtual void SetPiecesList(const QVector<quint32> &list) Q_DECL_OVERRIDE;
@ -72,14 +73,39 @@ private slots:
void NodeChanged(int index);
void ReturnDefBefore();
void ReturnDefAfter();
void ChangedSABefore(double d);
void ChangedSAAfter(double d);
void EvalWidth();
void EvalWidthBefore();
void EvalWidthAfter();
void FXWidth();
void FXWidthBefore();
void FXWidthAfter();
void WidthChanged();
void WidthBeforeChanged();
void WidthAfterChanged();
void DeployWidthFormulaTextEdit();
void DeployWidthBeforeFormulaTextEdit();
void DeployWidthAfterFormulaTextEdit();
private:
Q_DISABLE_COPY(DialogPiecePath)
Ui::DialogPiecePath *ui;
bool m_showMode;
bool m_showMode;
qreal m_saWidth;
QTimer *m_timerWidth;
QTimer *m_timerWidthBefore;
QTimer *m_timerWidthAfter;
int m_formulaBaseWidth;
int m_formulaBaseWidthBefore;
int m_formulaBaseWidthAfter;
void InitPathTab();
void InitSeamAllowanceTab();
void InitPathTypes();
void InitListPieces();
void InitNodesList();
@ -101,8 +127,14 @@ private:
quint32 GetLastId() const;
void SetCurrentSABefore(qreal value);
void SetCurrentSAAfter(qreal value);
void SetCurrentSABefore(const QString &formula);
void SetCurrentSAAfter(const QString &formula);
void UpdateNodeSABefore(const QString &formula);
void UpdateNodeSAAfter(const QString &formula);
QString GetFormulaSAWidthBefore() const;
QString GetFormulaSAWidthAfter() const;
};
#endif // DIALOGPIECEPATH_H

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>480</width>
<height>409</height>
<height>437</height>
</rect>
</property>
<property name="windowTitle">
@ -121,19 +121,53 @@
<attribute name="title">
<string>Seam allowance</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item alignment="Qt::AlignLeft">
<widget class="QLabel" name="labelEditWidth">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
<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>Width:</string>
@ -141,29 +175,7 @@
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxSeams">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="maximum">
<double>900.990000000000009</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -175,6 +187,125 @@
</property>
</spacer>
</item>
<item alignment="Qt::AlignRight">
<widget class="QToolButton" name="toolButtonExprWidth">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Formula wizard</string>
</property>
<property name="text">
<string notr="true">...</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_2">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../vmisc/share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="labelResultWidth">
<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="text">
<string notr="true">_</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormulaWidth">
<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="pushButtonGrowWidth">
<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>
<item>
@ -182,44 +313,108 @@
<property name="title">
<string>Nodes</string>
</property>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="labelNode">
<property name="text">
<string>Node:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxNodes"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelSABefore">
<property name="toolTip">
<string>Seam allowance before node</string>
</property>
<property name="text">
<string>Before:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxSABefore">
<property name="maximum">
<double>900.990000000000009</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
<widget class="QLabel" name="labelNode">
<property name="text">
<string>Node:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxNodes">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item alignment="Qt::AlignLeft">
<widget class="QLabel" name="labelEditBefore">
<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>Before:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<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>
<widget class="QPushButton" name="pushButtonDefBefore">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Return to default width</string>
</property>
@ -228,32 +423,197 @@
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelSAAfter">
<property name="toolTip">
<string>Seam allowance after node</string>
</property>
<property name="text">
<string>After:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxSAAfter">
<property name="maximum">
<double>900.990000000000009</double>
<item alignment="Qt::AlignRight">
<widget class="QToolButton" name="toolButtonExprBefore">
<property name="enabled">
<bool>false</bool>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
<property name="toolTip">
<string>Formula wizard</string>
</property>
<property name="text">
<string notr="true">...</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_6">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../vmisc/share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="labelResultBefore">
<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="text">
<string notr="true">_</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormulaWidthBefore">
<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="pushButtonGrowWidthBefore">
<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>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_16">
<item alignment="Qt::AlignLeft">
<widget class="QLabel" name="labelEditAfter">
<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>After:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<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>
<widget class="QPushButton" name="pushButtonDefAfter">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Return to default width</string>
</property>
@ -262,17 +622,157 @@
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QToolButton" name="toolButtonExprAfter">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Formula wizard</string>
</property>
<property name="text">
<string notr="true">...</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_10">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../vmisc/share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="labelResultAfter">
<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="text">
<string notr="true">_</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelAngle">
<property name="text">
<string>Angle:</string>
</property>
</widget>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormulaWidthAfter">
<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="pushButtonGrowWidthAfter">
<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>
<item row="3" column="1">
<widget class="QComboBox" name="comboBoxAngle"/>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="labelAngle">
<property name="text">
<string>Angle:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxAngle">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>

View File

@ -37,6 +37,7 @@
#include "../support/dialogeditwrongformula.h"
#include <QMenu>
#include <QTimer>
#include <QtNumeric>
//---------------------------------------------------------------------------------------------------------------------
@ -55,7 +56,14 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &
m_oldGeom(),
m_oldGrainline(),
m_iRotBaseHeight(0),
m_iLenBaseHeight(0)
m_iLenBaseHeight(0),
m_formulaBaseWidth(0),
m_formulaBaseWidthBefore(0),
m_formulaBaseWidthAfter(0),
m_timerWidth(nullptr),
m_timerWidthBefore(nullptr),
m_timerWidthAfter(nullptr),
m_saWidth(0)
{
ui->setupUi(this);
@ -84,6 +92,9 @@ DialogSeamAllowance::DialogSeamAllowance(const VContainer *data, const quint32 &
//---------------------------------------------------------------------------------------------------------------------
DialogSeamAllowance::~DialogSeamAllowance()
{
VContainer *locData = const_cast<VContainer *> (data);
locData->RemoveVariable(currentSeamAllowance);
delete ui;
}
@ -141,10 +152,12 @@ void DialogSeamAllowance::SetPiece(const VPiece &piece)
CustomSAChanged(0);
ui->checkBoxForbidFlipping->setChecked(piece.IsForbidFlipping());
ui->doubleSpinBoxSeams->setValue(piece.GetSAWidth());
ui->checkBoxSeams->setChecked(piece.IsSeamAllowance());
ui->lineEditName->setText(piece.GetName());
ui->plainTextEditFormulaWidth->setPlainText(piece.GetFormulaSAWidth());
m_saWidth = piece.GetSAWidth();
m_mx = piece.GetMx();
m_my = piece.GetMy();
@ -283,7 +296,7 @@ void DialogSeamAllowance::SaveData()
void DialogSeamAllowance::CheckState()
{
SCASSERT(bOk != nullptr);
bOk->setEnabled(flagName && flagError);
bOk->setEnabled(flagName && flagError && flagFormula);
// In case dialog hasn't apply button
if ( bApply != nullptr && applyAllowed)
{
@ -506,7 +519,7 @@ void DialogSeamAllowance::ShowCustomSAContextMenu(const QPoint &pos)
dialog->SetPieceId(toolId);
if (record.includeType == PiecePathIncludeType::AsMainPath)
{
dialog->SetSAWidth(ui->doubleSpinBoxSeams->value());
dialog->SetFormulaSAWidth(GetFormulaSAWidth());
}
dialog->EnbleShowMode(true);
m_dialog = dialog;
@ -580,14 +593,18 @@ void DialogSeamAllowance::EnableSeamAllowance(bool enable)
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::NodeChanged(int index)
{
ui->doubleSpinBoxSABefore->setDisabled(true);
ui->doubleSpinBoxSAAfter->setDisabled(true);
ui->plainTextEditFormulaWidthBefore->setDisabled(true);
ui->toolButtonExprBefore->setDisabled(true);
ui->pushButtonDefBefore->setDisabled(true);
ui->plainTextEditFormulaWidthAfter->setDisabled(true);
ui->toolButtonExprAfter->setDisabled(true);
ui->pushButtonDefAfter->setDisabled(true);
ui->comboBoxAngle->setDisabled(true);
ui->doubleSpinBoxSABefore->blockSignals(true);
ui->doubleSpinBoxSAAfter->blockSignals(true);
ui->plainTextEditFormulaWidthBefore->blockSignals(true);
ui->plainTextEditFormulaWidthAfter->blockSignals(true);
ui->comboBoxAngle->blockSignals(true);
if (index != -1)
@ -603,32 +620,42 @@ void DialogSeamAllowance::NodeChanged(int index)
{
const VPieceNode &node = piece.GetPath().at(nodeIndex);
ui->doubleSpinBoxSABefore->setEnabled(true);
ui->doubleSpinBoxSAAfter->setEnabled(true);
ui->comboBoxAngle->setEnabled(true);
// Seam alowance before
ui->plainTextEditFormulaWidthBefore->setEnabled(true);
ui->toolButtonExprBefore->setEnabled(true);
qreal w1 = node.GetSABefore();
if (w1 < 0)
{
w1 = piece.GetSAWidth();
}
else
QString w1Formula = node.GetFormulaSABefore();
if (w1Formula != currentSeamAllowance)
{
ui->pushButtonDefBefore->setEnabled(true);
}
ui->doubleSpinBoxSABefore->setValue(w1);
qreal w2 = node.GetSAAfter();
if (w2 < 0)
if (w1Formula.length() > 80)// increase height if needed.
{
w2 = piece.GetSAWidth();
this->DeployWidthBeforeFormulaTextEdit();
}
else
w1Formula = qApp->TrVars()->FormulaToUser(w1Formula, qApp->Settings()->GetOsSeparator());
ui->plainTextEditFormulaWidthBefore->setPlainText(w1Formula);
MoveCursorToEnd(ui->plainTextEditFormulaWidthBefore);
// Seam alowance after
ui->plainTextEditFormulaWidthAfter->setEnabled(true);
ui->toolButtonExprAfter->setEnabled(true);
QString w2Formula = node.GetFormulaSAAfter();
if (w2Formula != currentSeamAllowance)
{
ui->pushButtonDefAfter->setEnabled(true);
}
ui->doubleSpinBoxSAAfter->setValue(w2);
if (w2Formula.length() > 80)// increase height if needed.
{
this->DeployWidthAfterFormulaTextEdit();
}
w2Formula = qApp->TrVars()->FormulaToUser(w2Formula, qApp->Settings()->GetOsSeparator());
ui->plainTextEditFormulaWidthAfter->setPlainText(w2Formula);
MoveCursorToEnd(ui->plainTextEditFormulaWidthAfter);
// Angle type
ui->comboBoxAngle->setEnabled(true);
const int index = ui->comboBoxAngle->findData(static_cast<unsigned char>(node.GetAngleType()));
if (index != -1)
{
@ -638,13 +665,13 @@ void DialogSeamAllowance::NodeChanged(int index)
}
else
{
ui->doubleSpinBoxSABefore->setValue(0);
ui->doubleSpinBoxSAAfter->setValue(0);
ui->plainTextEditFormulaWidthBefore->setPlainText("");
ui->plainTextEditFormulaWidthAfter->setPlainText("");
ui->comboBoxAngle->setCurrentIndex(-1);
}
ui->doubleSpinBoxSABefore->blockSignals(false);
ui->doubleSpinBoxSAAfter->blockSignals(false);
ui->plainTextEditFormulaWidthBefore->blockSignals(false);
ui->plainTextEditFormulaWidthAfter->blockSignals(false);
ui->comboBoxAngle->blockSignals(false);
}
@ -752,25 +779,13 @@ void DialogSeamAllowance::NodeAngleChanged(int index)
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::ReturnDefBefore()
{
SetCurrentSABefore(-1);
ui->plainTextEditFormulaWidthBefore->setPlainText(currentSeamAllowance);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::ReturnDefAfter()
{
SetCurrentSAAfter(-1);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::ChangedSABefore(double d)
{
SetCurrentSABefore(d);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::ChangedSAAfter(double d)
{
SetCurrentSAAfter(d);
ui->plainTextEditFormulaWidthAfter->setPlainText(currentSeamAllowance);
}
//---------------------------------------------------------------------------------------------------------------------
@ -1061,6 +1076,142 @@ void DialogSeamAllowance::ResetWarning()
ui->tabWidget->setTabIcon(ui->tabWidget->indexOf(ui->tabGrainline), icon);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::EvalWidth()
{
labelEditFormula = ui->labelEditWidth;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
const QString formula = ui->plainTextEditFormulaWidth->toPlainText();
m_saWidth = Eval(formula, flagFormula, ui->labelResultWidth, postfix, true, true);
if (m_saWidth >= 0)
{
VContainer *locData = const_cast<VContainer *> (data);
locData->AddVariable(currentSeamAllowance, new VIncrement(locData, currentSeamAllowance, 0, m_saWidth,
QString().setNum(m_saWidth), true,
tr("Current seam allowance")));
EvalWidthBefore();
EvalWidthAfter();
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::EvalWidthBefore()
{
labelEditFormula = ui->labelEditBefore;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
const QString formula = ui->plainTextEditFormulaWidthBefore->toPlainText();
bool flagFormula = false; // fake flag
Eval(formula, flagFormula, ui->labelResultBefore, postfix, true, true);
UpdateNodeSABefore(GetFormulaSAWidthBefore());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::EvalWidthAfter()
{
labelEditFormula = ui->labelEditAfter;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
const QString formula = ui->plainTextEditFormulaWidthAfter->toPlainText();
bool flagFormula = false; // fake flag
Eval(formula, flagFormula, ui->labelResultAfter, postfix, true, true);
UpdateNodeSAAfter(GetFormulaSAWidthAfter());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::FXWidth()
{
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit seam allowance width"));
dialog->SetFormula(GetFormulaSAWidth());
dialog->setCheckLessThanZero(true);
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted)
{
SetFormulaSAWidth(dialog->GetFormula());
}
delete dialog;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::FXWidthBefore()
{
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit seam allowance width before"));
dialog->SetFormula(GetFormulaSAWidthBefore());
dialog->setCheckLessThanZero(true);
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted)
{
SetCurrentSABefore(dialog->GetFormula());
}
delete dialog;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::FXWidthAfter()
{
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
dialog->setWindowTitle(tr("Edit seam allowance width after"));
dialog->SetFormula(GetFormulaSAWidthAfter());
dialog->setCheckLessThanZero(true);
dialog->setPostfix(VDomDocument::UnitsToStr(qApp->patternUnit(), true));
if (dialog->exec() == QDialog::Accepted)
{
SetCurrentSAAfter(dialog->GetFormula());
}
delete dialog;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::WidthChanged()
{
labelEditFormula = ui->labelEditWidth;
labelResultCalculation = ui->labelResultWidth;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
ValFormulaChanged(flagFormula, ui->plainTextEditFormulaWidth, m_timerWidth, postfix);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::WidthBeforeChanged()
{
labelEditFormula = ui->labelEditBefore;
labelResultCalculation = ui->labelResultBefore;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
bool flagFormula = false;
ValFormulaChanged(flagFormula, ui->plainTextEditFormulaWidthBefore, m_timerWidthBefore, postfix);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::WidthAfterChanged()
{
labelEditFormula = ui->labelEditAfter;
labelResultCalculation = ui->labelResultAfter;
const QString postfix = VDomDocument::UnitsToStr(qApp->patternUnit(), true);
bool flagFormula = false;
ValFormulaChanged(flagFormula, ui->plainTextEditFormulaWidthAfter, m_timerWidthAfter, postfix);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::DeployWidthFormulaTextEdit()
{
DeployFormula(ui->plainTextEditFormulaWidth, ui->pushButtonGrowWidth, m_formulaBaseWidth);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::DeployWidthBeforeFormulaTextEdit()
{
DeployFormula(ui->plainTextEditFormulaWidthBefore, ui->pushButtonGrowWidthBefore, m_formulaBaseWidthBefore);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::DeployWidthAfterFormulaTextEdit()
{
DeployFormula(ui->plainTextEditFormulaWidthAfter, ui->pushButtonGrowWidthAfter, m_formulaBaseWidthAfter);
}
//---------------------------------------------------------------------------------------------------------------------
VPiece DialogSeamAllowance::CreatePiece() const
{
@ -1089,11 +1240,14 @@ VPiece DialogSeamAllowance::CreatePiece() const
piece.SetForbidFlipping(ui->checkBoxForbidFlipping->isChecked());
piece.SetSeamAllowance(ui->checkBoxSeams->isChecked());
piece.SetSAWidth(ui->doubleSpinBoxSeams->value());
piece.SetName(ui->lineEditName->text());
piece.SetMx(m_mx);
piece.SetMy(m_my);
QString width = ui->plainTextEditFormulaWidth->toPlainText();
width.replace("\n", " ");
piece.SetFormulaSAWidth(width, m_saWidth);
piece.GetPatternPieceData().SetLetter(ui->lineEditLetter->text());
for (int i = 0; i < m_conMCP.count(); ++i)
@ -1306,7 +1460,21 @@ quint32 DialogSeamAllowance::GetLastId() const
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetCurrentSABefore(qreal value)
void DialogSeamAllowance::SetCurrentSABefore(const QString &formula)
{
UpdateNodeSABefore(formula);
ListChanged();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetCurrentSAAfter(const QString &formula)
{
UpdateNodeSAAfter(formula);
ListChanged();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::UpdateNodeSABefore(const QString &formula)
{
const int index = ui->comboBoxNodes->currentIndex();
if (index != -1)
@ -1321,16 +1489,14 @@ void DialogSeamAllowance::SetCurrentSABefore(qreal value)
if (rowItem)
{
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
rowNode.SetSABefore(value);
rowNode.SetFormulaSABefore(formula);
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
ListChanged();
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetCurrentSAAfter(qreal value)
void DialogSeamAllowance::UpdateNodeSAAfter(const QString &formula)
{
const int index = ui->comboBoxNodes->currentIndex();
if (index != -1)
@ -1345,10 +1511,8 @@ void DialogSeamAllowance::SetCurrentSAAfter(qreal value)
if (rowItem)
{
VPieceNode rowNode = qvariant_cast<VPieceNode>(rowItem->data(Qt::UserRole));
rowNode.SetSAAfter(value);
rowNode.SetFormulaSAAfter(formula);
rowItem->setData(Qt::UserRole, QVariant::fromValue(rowNode));
ListChanged();
}
}
}
@ -1367,21 +1531,29 @@ void DialogSeamAllowance::InitMainPathTab()
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::InitSeamAllowanceTab()
{
plainTextEditFormula = ui->plainTextEditFormulaWidth;
this->m_formulaBaseWidth = ui->plainTextEditFormulaWidth->height();
this->m_formulaBaseWidthBefore = ui->plainTextEditFormulaWidthBefore->height();
this->m_formulaBaseWidthAfter = ui->plainTextEditFormulaWidthAfter->height();
ui->plainTextEditFormulaWidth->installEventFilter(this);
ui->plainTextEditFormulaWidthBefore->installEventFilter(this);
ui->plainTextEditFormulaWidthAfter->installEventFilter(this);
m_timerWidth = new QTimer(this);
connect(m_timerWidth, &QTimer::timeout, this, &DialogSeamAllowance::EvalWidth);
m_timerWidthBefore = new QTimer(this);
connect(m_timerWidthBefore, &QTimer::timeout, this, &DialogSeamAllowance::EvalWidthBefore);
m_timerWidthAfter = new QTimer(this);
connect(m_timerWidthAfter, &QTimer::timeout, this, &DialogSeamAllowance::EvalWidthAfter);
connect(ui->checkBoxSeams, &QCheckBox::toggled, this, &DialogSeamAllowance::EnableSeamAllowance);
const QString suffix = QLatin1String(" ") + VDomDocument::UnitsToStr(qApp->patternUnit(), true);
ui->doubleSpinBoxSeams->setSuffix(suffix);
ui->doubleSpinBoxSABefore->setSuffix(suffix);
ui->doubleSpinBoxSAAfter->setSuffix(suffix);
if(qApp->patternUnit() == Unit::Inch)
{
ui->doubleSpinBoxSeams->setDecimals(5);
ui->doubleSpinBoxSABefore->setDecimals(5);
ui->doubleSpinBoxSAAfter->setDecimals(5);
}
// Default value for seam allowence is 1 cm. But pattern have different units, so just set 1 in dialog not enough.
ui->doubleSpinBoxSeams->setValue(UnitConvertor(1, Unit::Cm, qApp->patternUnit()));
m_saWidth = UnitConvertor(1, Unit::Cm, qApp->patternUnit());
ui->plainTextEditFormulaWidth->setPlainText(qApp->LocaleToString(m_saWidth));
InitNodesList();
connect(ui->comboBoxNodes, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
@ -1390,14 +1562,6 @@ void DialogSeamAllowance::InitSeamAllowanceTab()
connect(ui->pushButtonDefBefore, &QPushButton::clicked, this, &DialogSeamAllowance::ReturnDefBefore);
connect(ui->pushButtonDefAfter, &QPushButton::clicked, this, &DialogSeamAllowance::ReturnDefAfter);
connect(ui->doubleSpinBoxSeams, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
[this](){NodeChanged(ui->comboBoxNodes->currentIndex());});
connect(ui->doubleSpinBoxSABefore, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogSeamAllowance::ChangedSABefore);
connect(ui->doubleSpinBoxSAAfter, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogSeamAllowance::ChangedSAAfter);
InitNodeAngles(ui->comboBoxAngle);
connect(ui->comboBoxAngle, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogSeamAllowance::NodeAngleChanged);
@ -1412,6 +1576,22 @@ void DialogSeamAllowance::InitSeamAllowanceTab()
&DialogSeamAllowance::CSAEndPointChanged);
connect(ui->comboBoxIncludeType, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogSeamAllowance::CSAIncludeTypeChanged);
connect(ui->toolButtonExprWidth, &QPushButton::clicked, this, &DialogSeamAllowance::FXWidth);
connect(ui->toolButtonExprBefore, &QPushButton::clicked, this, &DialogSeamAllowance::FXWidthBefore);
connect(ui->toolButtonExprAfter, &QPushButton::clicked, this, &DialogSeamAllowance::FXWidthAfter);
connect(ui->plainTextEditFormulaWidth, &QPlainTextEdit::textChanged, this, &DialogSeamAllowance::WidthChanged);
connect(ui->plainTextEditFormulaWidthBefore, &QPlainTextEdit::textChanged, this,
&DialogSeamAllowance::WidthBeforeChanged);
connect(ui->plainTextEditFormulaWidthAfter, &QPlainTextEdit::textChanged, this,
&DialogSeamAllowance::WidthAfterChanged);
connect(ui->pushButtonGrowWidth, &QPushButton::clicked, this, &DialogSeamAllowance::DeployWidthFormulaTextEdit);
connect(ui->pushButtonGrowWidthBefore, &QPushButton::clicked,
this, &DialogSeamAllowance::DeployWidthBeforeFormulaTextEdit);
connect(ui->pushButtonGrowWidthAfter, &QPushButton::clicked, this,
&DialogSeamAllowance::DeployWidthAfterFormulaTextEdit);
}
//---------------------------------------------------------------------------------------------------------------------
@ -1513,6 +1693,49 @@ void DialogSeamAllowance::InitGrainlineTab()
m_iLenBaseHeight = ui->lineEditLenFormula->height();
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogSeamAllowance::GetFormulaSAWidth() const
{
QString width = ui->plainTextEditFormulaWidth->toPlainText();
width.replace("\n", " ");
return qApp->TrVars()->TryFormulaFromUser(width, qApp->Settings()->GetOsSeparator());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::SetFormulaSAWidth(const QString &formula)
{
const QString width = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator());
// increase height if needed.
if (width.length() > 80)
{
this->DeployWidthFormulaTextEdit();
}
ui->plainTextEditFormulaWidth->setPlainText(width);
VisToolPiece *path = qobject_cast<VisToolPiece *>(vis);
SCASSERT(path != nullptr)
const VPiece p = CreatePiece();
path->SetPiece(p);
MoveCursorToEnd(ui->plainTextEditFormulaWidth);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogSeamAllowance::GetFormulaSAWidthBefore() const
{
QString width = ui->plainTextEditFormulaWidthBefore->toPlainText();
width.replace("\n", " ");
return qApp->TrVars()->TryFormulaFromUser(width, qApp->Settings()->GetOsSeparator());
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogSeamAllowance::GetFormulaSAWidthAfter() const
{
QString width = ui->plainTextEditFormulaWidthAfter->toPlainText();
width.replace("\n", " ");
return qApp->TrVars()->TryFormulaFromUser(width, qApp->Settings()->GetOsSeparator());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogSeamAllowance::UpdateCurrentCustomSARecord()
{

View File

@ -53,6 +53,8 @@ public:
VPiece GetPiece() const;
void SetPiece(const VPiece &m_piece);
QString GetFormulaSAWidth() const;
public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type) Q_DECL_OVERRIDE;
virtual void ShowDialog(bool click) Q_DECL_OVERRIDE;
@ -84,8 +86,6 @@ private slots:
void NodeAngleChanged(int index);
void ReturnDefBefore();
void ReturnDefAfter();
void ChangedSABefore(double d);
void ChangedSAAfter(double d);
void CustomSAChanged(int row);
void PathDialogClosed(int result);
@ -98,6 +98,22 @@ private slots:
void DeployLength();
void ResetWarning();
void EvalWidth();
void EvalWidthBefore();
void EvalWidthAfter();
void FXWidth();
void FXWidthBefore();
void FXWidthAfter();
void WidthChanged();
void WidthBeforeChanged();
void WidthAfterChanged();
void DeployWidthFormulaTextEdit();
void DeployWidthBeforeFormulaTextEdit();
void DeployWidthAfterFormulaTextEdit();
private:
Q_DISABLE_COPY(DialogSeamAllowance)
@ -119,6 +135,14 @@ private:
VGrainlineGeometry m_oldGrainline;
int m_iRotBaseHeight;
int m_iLenBaseHeight;
int m_formulaBaseWidth;
int m_formulaBaseWidthBefore;
int m_formulaBaseWidthAfter;
QTimer *m_timerWidth;
QTimer *m_timerWidthBefore;
QTimer *m_timerWidthAfter;
qreal m_saWidth;
VPiece CreatePiece() const;
@ -137,8 +161,11 @@ private:
quint32 GetLastId() const;
void SetCurrentSABefore(qreal value);
void SetCurrentSAAfter(qreal value);
void SetCurrentSABefore(const QString &formula);
void SetCurrentSAAfter(const QString &formula);
void UpdateNodeSABefore(const QString &formula);
void UpdateNodeSAAfter(const QString &formula);
void InitMainPathTab();
void InitSeamAllowanceTab();
@ -148,6 +175,11 @@ private:
void InitInternalPathsTab();
void InitPatternPieceDataTab();
void InitGrainlineTab();
void SetFormulaSAWidth(const QString &formula);
QString GetFormulaSAWidthBefore() const;
QString GetFormulaSAWidthAfter() const;
};
#endif // DIALOGSEAMALLOWANCE_H

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>521</width>
<height>493</height>
<height>611</height>
</rect>
</property>
<property name="windowTitle">
@ -21,7 +21,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>4</number>
<number>1</number>
</property>
<widget class="QWidget" name="tabMainPath">
<attribute name="title">
@ -94,7 +94,7 @@
<attribute name="title">
<string>Seam allowance</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<widget class="QCheckBox" name="checkBoxSeams">
<property name="text">
@ -119,50 +119,62 @@
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="topMargin">
<number>9</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<item alignment="Qt::AlignLeft">
<widget class="QLabel" name="labelEditWidth">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
<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>Width:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxSeams">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<double>900.990000000000009</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@ -176,6 +188,119 @@
</property>
</spacer>
</item>
<item alignment="Qt::AlignRight">
<widget class="QToolButton" name="toolButtonExprWidth">
<property name="toolTip">
<string>Formula wizard</string>
</property>
<property name="text">
<string notr="true">...</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_2">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../vmisc/share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="labelResultWidth">
<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="text">
<string notr="true">_</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormulaWidth">
<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="pushButtonGrowWidth">
<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>
<item>
@ -183,42 +308,115 @@
<property name="title">
<string>Nodes</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="labelNode">
<property name="text">
<string>Node:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxNodes"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelSABefore">
<property name="toolTip">
<string>Seam allowance before node</string>
</property>
<property name="text">
<string>Before:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxSABefore">
<property name="maximum">
<double>900.990000000000009</double>
<widget class="QLabel" name="labelNode">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
<property name="text">
<string>Node:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxNodes">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</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>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item alignment="Qt::AlignLeft">
<widget class="QLabel" name="labelEditBefore">
<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>Before:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<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>
<widget class="QPushButton" name="pushButtonDefBefore">
<property name="toolTip">
@ -229,30 +427,186 @@
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelSAAfter">
<property name="toolTip">
<string>Seam allowance after node</string>
</property>
<property name="text">
<string>After:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QDoubleSpinBox" name="doubleSpinBoxSAAfter">
<property name="maximum">
<double>900.990000000000009</double>
<item alignment="Qt::AlignRight">
<widget class="QToolButton" name="toolButtonExprBefore">
<property name="toolTip">
<string>Formula wizard</string>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
<property name="text">
<string notr="true">...</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_6">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../vmisc/share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="labelResultBefore">
<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="text">
<string notr="true">_</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormulaWidthBefore">
<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="pushButtonGrowWidthBefore">
<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>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_16">
<item alignment="Qt::AlignLeft">
<widget class="QLabel" name="labelEditAfter">
<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>After:</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<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>
<widget class="QPushButton" name="pushButtonDefAfter">
<property name="toolTip">
@ -263,17 +617,154 @@
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QToolButton" name="toolButtonExprAfter">
<property name="toolTip">
<string>Formula wizard</string>
</property>
<property name="text">
<string notr="true">...</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_10">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../vmisc/share/resources/icon.qrc">:/icon/24x24/equal.png</pixmap>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="labelResultAfter">
<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="text">
<string notr="true">_</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QLabel" name="labelAngle">
<property name="text">
<string>Angle:</string>
</property>
</widget>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QPlainTextEdit" name="plainTextEditFormulaWidthAfter">
<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="pushButtonGrowWidthAfter">
<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>
<item row="3" column="1">
<widget class="QComboBox" name="comboBoxAngle"/>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_15">
<item>
<widget class="QLabel" name="labelAngle">
<property name="text">
<string>Angle:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxAngle">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</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>
</layout>
</item>
</layout>
</widget>
@ -293,6 +784,12 @@
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="spacing">
<number>6</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>

View File

@ -582,7 +582,7 @@ void DialogTool::ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer *tim
return;
}
timer->setSingleShot(true);
timer->start(1000);
timer->start(300);
}
//---------------------------------------------------------------------------------------------------------------------
@ -594,13 +594,11 @@ void DialogTool::ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer *tim
* @param postfix unit name
* @param checkZero true - if formula can't be equal zero
*/
qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QString& postfix, bool checkZero)
qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QString& postfix, bool checkZero,
bool checkLessThanZero)
{
qDebug() << "Eval started";
SCASSERT(label != nullptr)
qDebug() << "Label ok";
SCASSERT(labelEditFormula != nullptr)
qDebug() << "lef ok";
qreal result = INT_MIN;//Value can be 0, so use max imposible value
@ -640,6 +638,13 @@ qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QSt
label->setText(tr("Error") + " (" + postfix + ")");
label->setToolTip(tr("Value can't be 0"));
}
else if (checkLessThanZero && result < 0)
{
flag = false;
ChangeColor(labelEditFormula, Qt::red);
label->setText(tr("Error") + " (" + postfix + ")");
label->setToolTip(tr("Value can't be lass than 0"));
}
else
{
label->setText(qApp->LocaleToString(result) + " " +postfix);

View File

@ -231,7 +231,7 @@ protected:
void ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer * timer,
const QString &postfix = QString());
qreal Eval(const QString &text, bool &flag, QLabel *label, const QString &postfix,
bool checkZero = true);
bool checkZero = true, bool checkLessThanZero = false);
void setCurrentPointId(QComboBox *box, const quint32 &value,
FillComboBox rule = FillComboBox::NoChildren,

View File

@ -28,7 +28,6 @@
#include "vdrawtool.h"
#include <qnumeric.h>
#include <QDialog>
#include <QDomNode>
#include <QMessageLogger>
@ -41,10 +40,6 @@
#include "../ifc/ifcdef.h"
#include "../ifc/xml/vdomdocument.h"
#include "../ifc/xml/vabstractpattern.h"
#include "../ifc/exception/vexceptionundo.h"
#include "../vpatterndb/calculator.h"
#include "../../dialogs/support/dialogeditwrongformula.h"
#include "../../dialogs/support/dialogundo.h"
#include "../../undocommands/addtocalc.h"
#include "../../undocommands/savetooloptions.h"
#include "../qmuparser/qmuparsererror.h"
@ -292,96 +287,6 @@ void VDrawTool::DetailsMode(bool mode)
// Do nothing.
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief CheckFormula check formula.
*
* Try calculate formula. If find error show dialog that allow user try fix formula. If user can't throw exception. In
* successes case return result calculation and fixed formula string. If formula ok don't touch formula.
*
* @param toolId [in] tool's id.
* @param formula [in|out] string with formula.
* @param data [in] container with variables. Need for math parser.
* @throw QmuParserError.
* @return result of calculation formula.
*/
qreal VDrawTool::CheckFormula(const quint32 &toolId, QString &formula, VContainer *data)
{
SCASSERT(data != nullptr)
qreal result = 0;
try
{
QScopedPointer<Calculator> cal(new Calculator());
result = cal->EvalFormula(data->PlainVariables(), formula);
if (qIsInf(result) || qIsNaN(result))
{
qDebug() << "Invalid the formula value";
return 0;
}
}
catch (qmu::QmuParserError &e)
{
qDebug() << "\nMath parser error:\n"
<< "--------------------------------------\n"
<< "Message: " << e.GetMsg() << "\n"
<< "Expression: " << e.GetExpr() << "\n"
<< "--------------------------------------";
if (qApp->IsAppInGUIMode())
{
QScopedPointer<DialogUndo> dialogUndo(new DialogUndo(qApp->getMainWindow()));
forever
{
if (dialogUndo->exec() == QDialog::Accepted)
{
const UndoButton resultUndo = dialogUndo->Result();
if (resultUndo == UndoButton::Fix)
{
auto *dialog = new DialogEditWrongFormula(data, toolId, qApp->getMainWindow());
dialog->setWindowTitle(tr("Edit wrong formula"));
dialog->SetFormula(formula);
if (dialog->exec() == QDialog::Accepted)
{
formula = dialog->GetFormula();
/* Need delete dialog here because parser in dialog don't allow use correct separator for
* parsing here. */
delete dialog;
QScopedPointer<Calculator> cal1(new Calculator());
result = cal1->EvalFormula(data->PlainVariables(), formula);
if (qIsInf(result) || qIsNaN(result))
{
qDebug() << "Invalid the formula value";
return 0;
}
break;
}
else
{
delete dialog;
}
}
else
{
throw VExceptionUndo(QString("Undo wrong formula %1").arg(formula));
}
}
else
{
throw;
}
}
}
else
{
throw;
}
}
return result;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief AddToCalculation add tool to calculation tag in pattern file.

View File

@ -75,7 +75,6 @@ public:
/** @brief setDialog set dialog when user want change tool option. */
virtual void setDialog() {}
virtual void DialogLinkDestroy();
static qreal CheckFormula(const quint32 &toolId, QString &formula, VContainer *data);
QString getLineType() const;
virtual void SetTypeLine(const QString &value);

View File

@ -52,11 +52,13 @@
#include <QUndoStack>
#include <QVector>
#include <new>
#include <qnumeric.h>
#include "../vgeometry/vpointf.h"
#include "../vpropertyexplorer/checkablemessagebox.h"
#include "../vwidgets/vmaingraphicsview.h"
#include "../ifc/exception/vexception.h"
#include "../ifc/exception/vexceptionundo.h"
#include "../ifc/xml/vtoolrecord.h"
#include "../undocommands/deltool.h"
#include "../vgeometry/../ifc/ifcdef.h"
@ -71,8 +73,11 @@
#include "../vmisc/logging.h"
#include "../vpatterndb/vcontainer.h"
#include "../vpatterndb/vpiecenode.h"
#include "../vpatterndb/calculator.h"
#include "../vwidgets/vgraphicssimpletextitem.h"
#include "nodeDetails/nodedetails.h"
#include "../dialogs/support/dialogundo.h"
#include "../dialogs/support/dialogeditwrongformula.h"
class QGraphicsEllipseItem;
class QGraphicsLineItem;
@ -152,6 +157,96 @@ VAbstractTool::~VAbstractTool()
}
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief CheckFormula check formula.
*
* Try calculate formula. If find error show dialog that allow user try fix formula. If user can't throw exception. In
* successes case return result calculation and fixed formula string. If formula ok don't touch formula.
*
* @param toolId [in] tool's id.
* @param formula [in|out] string with formula.
* @param data [in] container with variables. Need for math parser.
* @throw QmuParserError.
* @return result of calculation formula.
*/
qreal VAbstractTool::CheckFormula(const quint32 &toolId, QString &formula, VContainer *data)
{
SCASSERT(data != nullptr)
qreal result = 0;
try
{
QScopedPointer<Calculator> cal(new Calculator());
result = cal->EvalFormula(data->PlainVariables(), formula);
if (qIsInf(result) || qIsNaN(result))
{
qDebug() << "Invalid the formula value";
return 0;
}
}
catch (qmu::QmuParserError &e)
{
qDebug() << "\nMath parser error:\n"
<< "--------------------------------------\n"
<< "Message: " << e.GetMsg() << "\n"
<< "Expression: " << e.GetExpr() << "\n"
<< "--------------------------------------";
if (qApp->IsAppInGUIMode())
{
QScopedPointer<DialogUndo> dialogUndo(new DialogUndo(qApp->getMainWindow()));
forever
{
if (dialogUndo->exec() == QDialog::Accepted)
{
const UndoButton resultUndo = dialogUndo->Result();
if (resultUndo == UndoButton::Fix)
{
auto *dialog = new DialogEditWrongFormula(data, toolId, qApp->getMainWindow());
dialog->setWindowTitle(tr("Edit wrong formula"));
dialog->SetFormula(formula);
if (dialog->exec() == QDialog::Accepted)
{
formula = dialog->GetFormula();
/* Need delete dialog here because parser in dialog don't allow use correct separator for
* parsing here. */
delete dialog;
QScopedPointer<Calculator> cal1(new Calculator());
result = cal1->EvalFormula(data->PlainVariables(), formula);
if (qIsInf(result) || qIsNaN(result))
{
qDebug() << "Invalid the formula value";
return 0;
}
break;
}
else
{
delete dialog;
}
}
else
{
throw VExceptionUndo(QString("Undo wrong formula %1").arg(formula));
}
}
else
{
throw;
}
}
}
else
{
throw;
}
}
return result;
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief DeleteTool full delete object form scene and file.
@ -536,16 +631,14 @@ QDomElement VAbstractTool::AddSANode(VAbstractPattern *doc, const QString &tagNa
}
else
{
const qreal w1 = node.GetSABefore();
if (w1 >= 0)
if (node.GetFormulaSABefore() != currentSeamAllowance)
{
doc->SetAttribute(nod, VAbstractPattern::AttrSABefore, w1);
doc->SetAttribute(nod, VAbstractPattern::AttrSABefore, node.GetFormulaSABefore());
}
const qreal w2 = node.GetSAAfter();
if (w2 >= 0)
if (node.GetFormulaSAAfter() != currentSeamAllowance)
{
doc->SetAttribute(nod, VAbstractPattern::AttrSAAfter, w2);
doc->SetAttribute(nod, VAbstractPattern::AttrSAAfter, node.GetFormulaSAAfter());
}
}

View File

@ -73,6 +73,8 @@ public:
static const QString AttrInUse;
static qreal CheckFormula(const quint32 &toolId, QString &formula, VContainer *data);
static const QStringList StylesList();
static Qt::PenStyle LineStyleToPenStyle(const QString &typeLine);
static QString PenStyleToLineStyle(Qt::PenStyle penStyle);

View File

@ -91,10 +91,11 @@ VToolSeamAllowance *VToolSeamAllowance::Create(DialogTool *dialog, VMainGraphics
DialogSeamAllowance *dialogTool = qobject_cast<DialogSeamAllowance*>(dialog);
SCASSERT(dialogTool != nullptr);
VPiece detail = dialogTool->GetPiece();
QString width = detail.GetFormulaSAWidth();
qApp->getUndoStack()->beginMacro("add detail");
detail.GetPath().SetNodes(PrepareNodes(detail.GetPath(), scene, doc, data));
VToolSeamAllowance *piece = Create(0, detail, scene, doc, data, Document::FullParse, Source::FromGui);
VToolSeamAllowance *piece = Create(0, detail, width, scene, doc, data, Document::FullParse, Source::FromGui);
if (piece != nullptr)
{
@ -104,16 +105,24 @@ VToolSeamAllowance *VToolSeamAllowance::Create(DialogTool *dialog, VMainGraphics
}
//---------------------------------------------------------------------------------------------------------------------
VToolSeamAllowance *VToolSeamAllowance::Create(quint32 id, const VPiece &newPiece, VMainGraphicsScene *scene,
VToolSeamAllowance *VToolSeamAllowance::Create(quint32 id, VPiece newPiece, QString &width, VMainGraphicsScene *scene,
VAbstractPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation, const QString &drawName)
{
if (typeCreation == Source::FromGui || typeCreation == Source::FromTool)
{
data->AddVariable(currentSeamAllowance, new VIncrement(data, currentSeamAllowance, 0, newPiece.GetSAWidth(),
width, true, tr("Current seam allowance")));
id = data->AddPiece(newPiece);
}
else
{
const qreal calcWidth = CheckFormula(id, width, data);
newPiece.SetFormulaSAWidth(width, calcWidth);
data->AddVariable(currentSeamAllowance, new VIncrement(data, currentSeamAllowance, 0, calcWidth,
width, true, tr("Current seam allowance")));
data->UpdatePiece(id, newPiece);
if (parse != Document::FullParse)
{
@ -121,19 +130,20 @@ VToolSeamAllowance *VToolSeamAllowance::Create(quint32 id, const VPiece &newPiec
}
}
VAbstractTool::AddRecord(id, Tool::Piece, doc);
VToolSeamAllowance *piece = nullptr;
if (parse == Document::FullParse)
{
VToolSeamAllowance *piece = new VToolSeamAllowance(doc, data, id, typeCreation, scene, drawName);
piece = new VToolSeamAllowance(doc, data, id, typeCreation, scene, drawName);
scene->addItem(piece);
connect(piece, &VToolSeamAllowance::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::EnableDetailItemHover, piece, &VToolSeamAllowance::AllowHover);
connect(scene, &VMainGraphicsScene::EnableDetailItemSelection, piece, &VToolSeamAllowance::AllowSelecting);
connect(scene, &VMainGraphicsScene::HighlightDetail, piece, &VToolSeamAllowance::Highlight);
doc->AddTool(id, piece);
return piece;
}
return nullptr;
//Very important to delete it. Only this tool need this special variable.
data->RemoveVariable(currentLength);
return piece;
}
//---------------------------------------------------------------------------------------------------------------------
@ -163,7 +173,7 @@ void VToolSeamAllowance::AddAttributes(VAbstractPattern *doc, QDomElement &domEl
doc->SetAttribute(domElement, AttrInLayout, piece.IsInLayout());
doc->SetAttribute(domElement, AttrForbidFlipping, piece.IsForbidFlipping());
doc->SetAttribute(domElement, AttrSeamAllowance, piece.IsSeamAllowance());
doc->SetAttribute(domElement, AttrWidth, piece.GetSAWidth());
doc->SetAttribute(domElement, AttrWidth, piece.GetFormulaSAWidth());
doc->SetAttribute(domElement, AttrUnited, piece.IsUnited());
}

View File

@ -51,7 +51,7 @@ public:
static VToolSeamAllowance* Create(DialogTool *m_dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
VContainer *data);
static VToolSeamAllowance* Create(quint32 id, const VPiece &newPiece, VMainGraphicsScene *scene,
static VToolSeamAllowance* Create(quint32 id, VPiece newPiece, QString &width, VMainGraphicsScene *scene,
VAbstractPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation, const QString &m_drawName = QString());

View File

@ -1182,11 +1182,12 @@ void CreateUnitedDetail(quint32 id, const VToolUnionDetailsInitData &initData, q
CreateUnitedInternalPaths(newDetail, d1, d2, id, drawName, initData, dx, dy, pRotate, angle);
newDetail.SetName(QObject::tr("United detail"));
newDetail.SetSAWidth(d1.GetSAWidth());
QString formulaSAWidth = d1.GetFormulaSAWidth();
newDetail.SetFormulaSAWidth(formulaSAWidth, d1.GetSAWidth());
newDetail.SetMx(d1.GetMx());
newDetail.SetMy(d1.GetMy());
VToolSeamAllowance::Create(0, newDetail, initData.scene, initData.doc, initData.data, initData.parse,
Source::FromTool, drawName);
VToolSeamAllowance::Create(0, newDetail, formulaSAWidth, initData.scene, initData.doc, initData.data,
initData.parse, Source::FromTool, drawName);
auto RemoveDetail = [initData](quint32 id)
{