Resolved issue #792. New feature. Visibility trigger for internal path.
--HG-- branch : develop
This commit is contained in:
parent
34d1b91225
commit
f52b690827
|
@ -35,6 +35,7 @@
|
|||
- [#779] Add more roll paper size templates.
|
||||
- [#783] Flipping control.
|
||||
- [#790] Generate unique name for each detail.
|
||||
- [#792] New feature. Visibility trigger for internal path.
|
||||
|
||||
# Version 0.5.1
|
||||
- [#683] Tool Seam allowance's dialog is off screen on small resolutions.
|
||||
|
|
|
@ -3644,6 +3644,11 @@ void VPattern::ParsePathElement(VMainGraphicsScene *scene, QDomElement &domEleme
|
|||
initData.path.SetPenType(LineStyleToPenStyle(GetParametrString(domElement, AttrTypeLine, TypeLineLine)));
|
||||
initData.path.SetCutPath(GetParametrBool(domElement, AttrCut, falseStr));
|
||||
|
||||
if (initData.path.GetType() == PiecePathType::InternalPath)
|
||||
{
|
||||
initData.path.SetVisibilityTrigger(GetParametrString(domElement, AttrVisible, "1"));
|
||||
}
|
||||
|
||||
VToolPiecePath::Create(initData);
|
||||
}
|
||||
catch (const VExceptionBadId &e)
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
<file>schema/pattern/v0.7.2.xsd</file>
|
||||
<file>schema/pattern/v0.7.3.xsd</file>
|
||||
<file>schema/pattern/v0.7.4.xsd</file>
|
||||
<file>schema/pattern/v0.7.5.xsd</file>
|
||||
<file>schema/standard_measurements/v0.3.0.xsd</file>
|
||||
<file>schema/standard_measurements/v0.4.0.xsd</file>
|
||||
<file>schema/standard_measurements/v0.4.1.xsd</file>
|
||||
|
|
1047
src/libs/ifc/schema/pattern/v0.7.5.xsd
Normal file
1047
src/libs/ifc/schema/pattern/v0.7.5.xsd
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -58,8 +58,8 @@ class QDomElement;
|
|||
*/
|
||||
|
||||
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0");
|
||||
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.7.4");
|
||||
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.7.4.xsd");
|
||||
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.7.5");
|
||||
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.7.5.xsd");
|
||||
|
||||
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
|
@ -220,7 +220,8 @@ QString VPatternConverter::XSDSchema(int ver) const
|
|||
std::make_pair(0x000701, QStringLiteral("://schema/pattern/v0.7.1.xsd")),
|
||||
std::make_pair(0x000702, QStringLiteral("://schema/pattern/v0.7.2.xsd")),
|
||||
std::make_pair(0x000703, QStringLiteral("://schema/pattern/v0.7.3.xsd")),
|
||||
std::make_pair(0x000704, CurrentSchema)
|
||||
std::make_pair(0x000704, QStringLiteral("://schema/pattern/v0.7.4.xsd")),
|
||||
std::make_pair(0x000705, CurrentSchema)
|
||||
};
|
||||
|
||||
if (schemas.contains(ver))
|
||||
|
@ -419,6 +420,10 @@ void VPatternConverter::ApplyPatches()
|
|||
ValidateXML(XSDSchema(0x000704), m_convertedFileName);
|
||||
V_FALLTHROUGH
|
||||
case (0x000704):
|
||||
ToV0_7_5();
|
||||
ValidateXML(XSDSchema(0x000705), m_convertedFileName);
|
||||
V_FALLTHROUGH
|
||||
case (0x000705):
|
||||
break;
|
||||
default:
|
||||
InvalidVersion(m_ver);
|
||||
|
@ -436,7 +441,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion()
|
|||
bool VPatternConverter::IsReadOnly() const
|
||||
{
|
||||
// Check if attribute readOnly was not changed in file format
|
||||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 7, 4),
|
||||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 7, 5),
|
||||
"Check attribute readOnly.");
|
||||
|
||||
// Possibly in future attribute readOnly will change position etc.
|
||||
|
@ -950,6 +955,16 @@ void VPatternConverter::ToV0_7_4()
|
|||
Save();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPatternConverter::ToV0_7_5()
|
||||
{
|
||||
// TODO. Delete if minimal supported version is 0.7.5
|
||||
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 7, 5),
|
||||
"Time to refactor the code.");
|
||||
SetVersion(QStringLiteral("0.7.5"));
|
||||
Save();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPatternConverter::TagUnitToV0_2_0()
|
||||
{
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
static const QString PatternMaxVerStr;
|
||||
static const QString CurrentSchema;
|
||||
static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0);
|
||||
static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 7, 4);
|
||||
static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 7, 5);
|
||||
|
||||
protected:
|
||||
virtual int MinVer() const Q_DECL_OVERRIDE;
|
||||
|
@ -117,6 +117,7 @@ private:
|
|||
void ToV0_7_2();
|
||||
void ToV0_7_3();
|
||||
void ToV0_7_4();
|
||||
void ToV0_7_5();
|
||||
|
||||
void TagUnitToV0_2_0();
|
||||
void TagIncrementToV0_2_0();
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "vcontainer.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../vlayout/vabstractpiece.h"
|
||||
#include "calculator.h"
|
||||
|
||||
#include <QPainterPath>
|
||||
|
||||
|
@ -249,6 +250,18 @@ void VPiecePath::SetCutPath(bool cut)
|
|||
d->m_cut = cut;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VPiecePath::GetVisibilityTrigger() const
|
||||
{
|
||||
return d->m_visibilityTrigger;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPiecePath::SetVisibilityTrigger(const QString &formula)
|
||||
{
|
||||
d->m_visibilityTrigger = formula;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QVector<QPointF> VPiecePath::PathPoints(const VContainer *data) const
|
||||
{
|
||||
|
@ -780,6 +793,39 @@ QPointF VPiecePath::NodeNextPoint(const VContainer *data, int i) const
|
|||
return point;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
bool VPiecePath::IsVisible(const QHash<QString, QSharedPointer<VInternalVariable>> *vars) const
|
||||
{
|
||||
SCASSERT(vars != nullptr)
|
||||
bool visible = true;
|
||||
try
|
||||
{
|
||||
QString formula = GetVisibilityTrigger();
|
||||
// Replace line return character with spaces for calc if exist
|
||||
formula.replace("\n", " ");
|
||||
qDebug() << "Formula: " << formula;
|
||||
QScopedPointer<Calculator> cal(new Calculator());
|
||||
const qreal result = cal->EvalFormula(vars, formula);
|
||||
qDebug() << "Result: " << result;
|
||||
|
||||
if (qIsInf(result) || qIsNaN(result))
|
||||
{
|
||||
qWarning() << QObject::tr("Visibility trigger contains error and will be ignored");
|
||||
}
|
||||
|
||||
if (qFuzzyIsNull(result))
|
||||
{
|
||||
visible = false;
|
||||
}
|
||||
}
|
||||
catch (qmu::QmuParserError &e)
|
||||
{
|
||||
qDebug() << "Parser error: " << e.GetMsg();
|
||||
qWarning() << QObject::tr("Visibility trigger contains error and will be ignored");
|
||||
}
|
||||
return visible;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
int VPiecePath::indexOfNode(const QVector<VPieceNode> &nodes, quint32 id)
|
||||
{
|
||||
|
|
|
@ -41,6 +41,7 @@ class VContainer;
|
|||
class QPainterPath;
|
||||
class VPointF;
|
||||
class VPieceNode;
|
||||
class VInternalVariable;
|
||||
|
||||
class VPiecePath
|
||||
{
|
||||
|
@ -81,6 +82,9 @@ public:
|
|||
bool IsCutPath() const;
|
||||
void SetCutPath(bool cut);
|
||||
|
||||
QString GetVisibilityTrigger() const;
|
||||
void SetVisibilityTrigger(const QString &formula);
|
||||
|
||||
QVector<QPointF> PathPoints(const VContainer *data) const;
|
||||
QVector<VPointF> PathNodePoints(const VContainer *data, bool showExcluded = true) const;
|
||||
QVector<VSAPoint> SeamAllowancePoints(const VContainer *data, qreal width, bool reverse) const;
|
||||
|
@ -106,6 +110,8 @@ public:
|
|||
QPointF NodePreviousPoint(const VContainer *data, int i) const;
|
||||
QPointF NodeNextPoint(const VContainer *data, int i) const;
|
||||
|
||||
bool IsVisible(const QHash<QString, QSharedPointer<VInternalVariable> > *vars) const;
|
||||
|
||||
static int indexOfNode(const QVector<VPieceNode> &nodes, quint32 id);
|
||||
|
||||
static int FindInLoopNotExcludedUp(int start, const QVector<VPieceNode> &nodes);
|
||||
|
|
|
@ -47,7 +47,8 @@ public:
|
|||
m_type(PiecePathType::Unknown),
|
||||
m_name(),
|
||||
m_penType(Qt::SolidLine),
|
||||
m_cut(false)
|
||||
m_cut(false),
|
||||
m_visibilityTrigger("1")
|
||||
{}
|
||||
|
||||
explicit VPiecePathData(PiecePathType type)
|
||||
|
@ -55,7 +56,8 @@ public:
|
|||
m_type(type),
|
||||
m_name(),
|
||||
m_penType(Qt::SolidLine),
|
||||
m_cut(false)
|
||||
m_cut(false),
|
||||
m_visibilityTrigger("1")
|
||||
{}
|
||||
|
||||
VPiecePathData(const VPiecePathData &path)
|
||||
|
@ -64,7 +66,8 @@ public:
|
|||
m_type(path.m_type),
|
||||
m_name(path.m_name),
|
||||
m_penType(path.m_penType),
|
||||
m_cut(path.m_cut)
|
||||
m_cut(path.m_cut),
|
||||
m_visibilityTrigger(path.m_visibilityTrigger)
|
||||
{}
|
||||
|
||||
~VPiecePathData();
|
||||
|
@ -74,6 +77,7 @@ public:
|
|||
QString m_name;
|
||||
Qt::PenStyle m_penType;
|
||||
bool m_cut;
|
||||
QString m_visibilityTrigger;
|
||||
|
||||
private:
|
||||
VPiecePathData &operator=(const VPiecePathData &) Q_DECL_EQ_DELETE;
|
||||
|
|
|
@ -43,12 +43,17 @@ DialogPiecePath::DialogPiecePath(const VContainer *data, quint32 toolId, QWidget
|
|||
ui(new Ui::DialogPiecePath),
|
||||
m_showMode(false),
|
||||
m_saWidth(0),
|
||||
m_timerWidth(nullptr),
|
||||
m_timerWidthBefore(nullptr),
|
||||
m_timerWidthAfter(nullptr),
|
||||
m_timerWidth(new QTimer(this)),
|
||||
m_timerWidthBefore(new QTimer(this)),
|
||||
m_timerWidthAfter(new QTimer(this)),
|
||||
m_timerVisible(new QTimer(this)),
|
||||
m_formulaBaseWidth(0),
|
||||
m_formulaBaseWidthBefore(0),
|
||||
m_formulaBaseWidthAfter(0)
|
||||
m_formulaBaseWidthAfter(0),
|
||||
m_formulaBaseVisible(0),
|
||||
m_flagFormulaBefore(true),
|
||||
m_flagFormulaAfter(true),
|
||||
m_flagFormulaVisible(true)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
InitOkCancel(ui);
|
||||
|
@ -56,6 +61,9 @@ DialogPiecePath::DialogPiecePath(const VContainer *data, quint32 toolId, QWidget
|
|||
InitPathTab();
|
||||
InitSeamAllowanceTab();
|
||||
InitPassmarksTab();
|
||||
InitControlTab();
|
||||
|
||||
EvalVisible();
|
||||
|
||||
flagName = true;//We have default name of piece.
|
||||
flagError = PathIsValid();
|
||||
|
@ -189,7 +197,37 @@ void DialogPiecePath::ShowDialog(bool click)
|
|||
void DialogPiecePath::CheckState()
|
||||
{
|
||||
SCASSERT(bOk != nullptr);
|
||||
bOk->setEnabled(flagName && flagError);
|
||||
if (GetType() != PiecePathType::InternalPath)
|
||||
{// Works only for internal paths
|
||||
m_flagFormulaVisible = true;
|
||||
}
|
||||
|
||||
bOk->setEnabled(flagName && flagError && flagFormula && m_flagFormulaBefore && m_flagFormulaAfter
|
||||
&& m_flagFormulaVisible);
|
||||
|
||||
const int tabSeamAllowanceIndex = ui->tabWidget->indexOf(ui->tabSeamAllowance);
|
||||
if (flagFormula && m_flagFormulaBefore && m_flagFormulaAfter)
|
||||
{
|
||||
ui->tabWidget->setTabIcon(tabSeamAllowanceIndex, QIcon());
|
||||
}
|
||||
else
|
||||
{
|
||||
const QIcon icon = QIcon::fromTheme("dialog-warning",
|
||||
QIcon(":/icons/win.icon.theme/16x16/status/dialog-warning.png"));
|
||||
ui->tabWidget->setTabIcon(tabSeamAllowanceIndex, icon);
|
||||
}
|
||||
|
||||
const int tabControlIndex = ui->tabWidget->indexOf(ui->tabControl);
|
||||
if (m_flagFormulaVisible)
|
||||
{
|
||||
ui->tabWidget->setTabIcon(tabControlIndex, QIcon());
|
||||
}
|
||||
else
|
||||
{
|
||||
const QIcon icon = QIcon::fromTheme("dialog-warning",
|
||||
QIcon(":/icons/win.icon.theme/16x16/status/dialog-warning.png"));
|
||||
ui->tabWidget->setTabIcon(tabControlIndex, icon);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -213,6 +251,7 @@ void DialogPiecePath::closeEvent(QCloseEvent *event)
|
|||
ui->plainTextEditFormulaWidth->blockSignals(true);
|
||||
ui->plainTextEditFormulaWidthBefore->blockSignals(true);
|
||||
ui->plainTextEditFormulaWidthAfter->blockSignals(true);
|
||||
ui->plainTextEditFormulaVisible->blockSignals(true);
|
||||
DialogTool::closeEvent(event);
|
||||
}
|
||||
|
||||
|
@ -594,8 +633,7 @@ void DialogPiecePath::EvalWidthBefore()
|
|||
labelEditFormula = ui->labelEditBefore;
|
||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||
QString formula = ui->plainTextEditFormulaWidthBefore->toPlainText();
|
||||
bool flagFormula = false; // fake flag
|
||||
Eval(formula, flagFormula, ui->labelResultBefore, postfix, false, true);
|
||||
Eval(formula, m_flagFormulaBefore, ui->labelResultBefore, postfix, false, true);
|
||||
|
||||
formula = GetFormulaSAWidthBefore();
|
||||
if (formula != currentSeamAllowance)
|
||||
|
@ -612,8 +650,7 @@ void DialogPiecePath::EvalWidthAfter()
|
|||
labelEditFormula = ui->labelEditAfter;
|
||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||
QString formula = ui->plainTextEditFormulaWidthAfter->toPlainText();
|
||||
bool flagFormula = false; // fake flag
|
||||
Eval(formula, flagFormula, ui->labelResultAfter, postfix, false, true);
|
||||
Eval(formula, m_flagFormulaAfter, ui->labelResultAfter, postfix, false, true);
|
||||
|
||||
formula = GetFormulaSAWidthAfter();
|
||||
if (formula != currentSeamAllowance)
|
||||
|
@ -624,10 +661,18 @@ void DialogPiecePath::EvalWidthAfter()
|
|||
UpdateNodeSAAfter(formula);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::EvalVisible()
|
||||
{
|
||||
labelEditFormula = ui->labelEditVisible;
|
||||
QString formula = ui->plainTextEditFormulaVisible->toPlainText();
|
||||
Eval(formula, m_flagFormulaVisible, ui->labelResultVisible, "", false, true);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::FXWidth()
|
||||
{
|
||||
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
||||
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
|
||||
dialog->setWindowTitle(tr("Edit seam allowance width"));
|
||||
dialog->SetFormula(GetFormulaSAWidth());
|
||||
dialog->setCheckLessThanZero(true);
|
||||
|
@ -636,13 +681,12 @@ void DialogPiecePath::FXWidth()
|
|||
{
|
||||
SetFormulaSAWidth(dialog->GetFormula());
|
||||
}
|
||||
delete dialog;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::FXWidthBefore()
|
||||
{
|
||||
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
||||
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
|
||||
dialog->setWindowTitle(tr("Edit seam allowance width before"));
|
||||
dialog->SetFormula(GetFormulaSAWidthBefore());
|
||||
dialog->setCheckLessThanZero(true);
|
||||
|
@ -651,13 +695,12 @@ void DialogPiecePath::FXWidthBefore()
|
|||
{
|
||||
SetCurrentSABefore(dialog->GetFormula());
|
||||
}
|
||||
delete dialog;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::FXWidthAfter()
|
||||
{
|
||||
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
||||
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
|
||||
dialog->setWindowTitle(tr("Edit seam allowance width after"));
|
||||
dialog->SetFormula(GetFormulaSAWidthAfter());
|
||||
dialog->setCheckLessThanZero(true);
|
||||
|
@ -666,7 +709,18 @@ void DialogPiecePath::FXWidthAfter()
|
|||
{
|
||||
SetCurrentSAAfter(dialog->GetFormula());
|
||||
}
|
||||
delete dialog;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::FXVisible()
|
||||
{
|
||||
QScopedPointer<DialogEditWrongFormula> dialog(new DialogEditWrongFormula(data, toolId, this));
|
||||
dialog->setWindowTitle(tr("Control visibility"));
|
||||
dialog->SetFormula(GetFormulaVisible());
|
||||
if (dialog->exec() == QDialog::Accepted)
|
||||
{
|
||||
SetFormulaVisible(dialog->GetFormula());
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -684,8 +738,7 @@ void DialogPiecePath::WidthBeforeChanged()
|
|||
labelEditFormula = ui->labelEditBefore;
|
||||
labelResultCalculation = ui->labelResultBefore;
|
||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||
bool flagFormula = false;
|
||||
ValFormulaChanged(flagFormula, ui->plainTextEditFormulaWidthBefore, m_timerWidthBefore, postfix);
|
||||
ValFormulaChanged(m_flagFormulaBefore, ui->plainTextEditFormulaWidthBefore, m_timerWidthBefore, postfix);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -694,8 +747,15 @@ void DialogPiecePath::WidthAfterChanged()
|
|||
labelEditFormula = ui->labelEditAfter;
|
||||
labelResultCalculation = ui->labelResultAfter;
|
||||
const QString postfix = UnitsToStr(qApp->patternUnit(), true);
|
||||
bool flagFormula = false;
|
||||
ValFormulaChanged(flagFormula, ui->plainTextEditFormulaWidthAfter, m_timerWidthAfter, postfix);
|
||||
ValFormulaChanged(m_flagFormulaAfter, ui->plainTextEditFormulaWidthAfter, m_timerWidthAfter, postfix);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::VisibleChanged()
|
||||
{
|
||||
labelEditFormula = ui->labelEditVisible;
|
||||
labelResultCalculation = ui->labelResultVisible;
|
||||
ValFormulaChanged(m_flagFormulaVisible, ui->plainTextEditFormulaVisible, m_timerVisible, "");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -716,6 +776,12 @@ void DialogPiecePath::DeployWidthAfterFormulaTextEdit()
|
|||
DeployFormula(ui->plainTextEditFormulaWidthAfter, ui->pushButtonGrowWidthAfter, m_formulaBaseWidthAfter);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::DeployVisibleFormulaTextEdit()
|
||||
{
|
||||
DeployFormula(ui->plainTextEditFormulaVisible, ui->pushButtonGrowVisible, m_formulaBaseVisible);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::InitPathTab()
|
||||
{
|
||||
|
@ -731,6 +797,7 @@ void DialogPiecePath::InitPathTab()
|
|||
{
|
||||
ui->comboBoxPenType->setEnabled(GetType() == PiecePathType::InternalPath);
|
||||
ui->checkBoxCut->setEnabled(GetType() == PiecePathType::InternalPath);
|
||||
ui->tabControl->setEnabled(GetType() == PiecePathType::InternalPath);
|
||||
ValidObjects(PathIsValid());
|
||||
});
|
||||
|
||||
|
@ -750,13 +817,8 @@ void DialogPiecePath::InitSeamAllowanceTab()
|
|||
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.
|
||||
|
@ -804,6 +866,20 @@ void DialogPiecePath::InitPassmarksTab()
|
|||
this, &DialogPiecePath::PassmarkAngleTypeChanged);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::InitControlTab()
|
||||
{
|
||||
this->m_formulaBaseVisible = ui->plainTextEditFormulaVisible->height();
|
||||
|
||||
ui->plainTextEditFormulaVisible->installEventFilter(this);
|
||||
|
||||
connect(m_timerVisible, &QTimer::timeout, this, &DialogPiecePath::EvalVisible);
|
||||
connect(ui->toolButtonExprVisible, &QPushButton::clicked, this, &DialogPiecePath::FXVisible);
|
||||
connect(ui->plainTextEditFormulaVisible, &QPlainTextEdit::textChanged, this, &DialogPiecePath::VisibleChanged);
|
||||
connect(ui->pushButtonGrowVisible, &QPushButton::clicked, this,
|
||||
&DialogPiecePath::DeployVisibleFormulaTextEdit);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::InitPathTypes()
|
||||
{
|
||||
|
@ -925,6 +1001,15 @@ void DialogPiecePath::SetPiecePath(const VPiecePath &path)
|
|||
SetPenType(path.GetPenType());
|
||||
SetCutPath(path.IsCutPath());
|
||||
|
||||
if (path.GetType() == PiecePathType::InternalPath)
|
||||
{
|
||||
SetFormulaVisible(path.GetVisibilityTrigger());
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->plainTextEditFormulaVisible->setPlainText("1");
|
||||
}
|
||||
|
||||
ValidObjects(PathIsValid());
|
||||
|
||||
ListChanged();
|
||||
|
@ -1141,6 +1226,15 @@ VPiecePath DialogPiecePath::CreatePath() const
|
|||
path.SetPenType(GetType() == PiecePathType::InternalPath ? GetPenType() : Qt::SolidLine);
|
||||
path.SetCutPath(GetType() == PiecePathType::InternalPath ? IsCutPath() : false);
|
||||
|
||||
if (GetType() == PiecePathType::InternalPath)
|
||||
{
|
||||
path.SetVisibilityTrigger(GetFormulaVisible());
|
||||
}
|
||||
else
|
||||
{
|
||||
path.SetVisibilityTrigger("1");
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
|
@ -1222,3 +1316,24 @@ QString DialogPiecePath::GetFormulaSAWidthAfter() const
|
|||
width.replace("\n", " ");
|
||||
return qApp->TrVars()->TryFormulaFromUser(width, qApp->Settings()->GetOsSeparator());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogPiecePath::GetFormulaVisible() const
|
||||
{
|
||||
QString formula = ui->plainTextEditFormulaVisible->toPlainText();
|
||||
formula.replace("\n", " ");
|
||||
return qApp->TrVars()->TryFormulaFromUser(formula, qApp->Settings()->GetOsSeparator());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogPiecePath::SetFormulaVisible(const QString &formula)
|
||||
{
|
||||
const QString f = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator());
|
||||
// increase height if needed.
|
||||
if (f.length() > 80)
|
||||
{
|
||||
this->DeployVisibleFormulaTextEdit();
|
||||
}
|
||||
ui->plainTextEditFormulaVisible->setPlainText(f);
|
||||
MoveCursorToEnd(ui->plainTextEditFormulaVisible);
|
||||
}
|
||||
|
|
|
@ -79,18 +79,22 @@ private slots:
|
|||
void EvalWidth();
|
||||
void EvalWidthBefore();
|
||||
void EvalWidthAfter();
|
||||
void EvalVisible();
|
||||
|
||||
void FXWidth();
|
||||
void FXWidthBefore();
|
||||
void FXWidthAfter();
|
||||
void FXVisible();
|
||||
|
||||
void WidthChanged();
|
||||
void WidthBeforeChanged();
|
||||
void WidthAfterChanged();
|
||||
void VisibleChanged();
|
||||
|
||||
void DeployWidthFormulaTextEdit();
|
||||
void DeployWidthBeforeFormulaTextEdit();
|
||||
void DeployWidthAfterFormulaTextEdit();
|
||||
void DeployVisibleFormulaTextEdit();
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(DialogPiecePath)
|
||||
|
@ -101,14 +105,21 @@ private:
|
|||
QTimer *m_timerWidth;
|
||||
QTimer *m_timerWidthBefore;
|
||||
QTimer *m_timerWidthAfter;
|
||||
QTimer *m_timerVisible;
|
||||
|
||||
int m_formulaBaseWidth;
|
||||
int m_formulaBaseWidthBefore;
|
||||
int m_formulaBaseWidthAfter;
|
||||
int m_formulaBaseVisible;
|
||||
|
||||
bool m_flagFormulaBefore;
|
||||
bool m_flagFormulaAfter;
|
||||
bool m_flagFormulaVisible;
|
||||
|
||||
void InitPathTab();
|
||||
void InitSeamAllowanceTab();
|
||||
void InitPassmarksTab();
|
||||
void InitControlTab();
|
||||
void InitPathTypes();
|
||||
void InitNodesList();
|
||||
void InitPassmarksList();
|
||||
|
@ -141,6 +152,9 @@ private:
|
|||
|
||||
QString GetFormulaSAWidthBefore() const;
|
||||
QString GetFormulaSAWidthAfter() const;
|
||||
|
||||
QString GetFormulaVisible() const;
|
||||
void SetFormulaVisible(const QString &formula);
|
||||
};
|
||||
|
||||
#endif // DIALOGPIECEPATH_H
|
||||
|
|
|
@ -1002,6 +1002,215 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tabControl">
|
||||
<attribute name="title">
|
||||
<string>Control</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_14">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_15">
|
||||
<item alignment="Qt::AlignLeft">
|
||||
<widget class="QLabel" name="labelEditVisible">
|
||||
<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>Visible</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_11">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item alignment="Qt::AlignRight">
|
||||
<widget class="QToolButton" name="toolButtonExprVisible">
|
||||
<property name="enabled">
|
||||
<bool>true</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_5">
|
||||
<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="labelResultVisible">
|
||||
<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_14">
|
||||
<item>
|
||||
<widget class="VPlainTextEdit" name="plainTextEditFormulaVisible">
|
||||
<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>Create a formula that regulates visibility. Values different from "0" make a path visible.</string>
|
||||
</property>
|
||||
<property name="tabChangesFocus">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="plainText">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonGrowVisible">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>18</width>
|
||||
<height>18</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sizeIncrement">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Show full calculation in message box</p></body></html></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>
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
|
|
@ -192,6 +192,7 @@ void VToolPiecePath::AddAttributes(VAbstractPattern *doc, QDomElement &domElemen
|
|||
|
||||
if (path.GetType() == PiecePathType::InternalPath)
|
||||
{
|
||||
doc->SetAttribute(domElement, VAbstractPattern::AttrVisible, path.GetVisibilityTrigger());
|
||||
doc->SetAttribute(domElement, AttrCut, path.IsCutPath());
|
||||
}
|
||||
}
|
||||
|
@ -308,6 +309,8 @@ void VToolPiecePath::RefreshGeometry()
|
|||
QPen pen = this->pen();
|
||||
pen.setStyle(path.GetPenType());
|
||||
this->setPen(pen);
|
||||
|
||||
setVisible(path.IsVisible(this->getData()->DataVariables()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user