Resolved issue #792. New feature. Visibility trigger for internal path.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-01-03 19:31:50 +02:00
parent 34d1b91225
commit f52b690827
13 changed files with 1499 additions and 32 deletions

View File

@ -35,6 +35,7 @@
- [#779] Add more roll paper size templates. - [#779] Add more roll paper size templates.
- [#783] Flipping control. - [#783] Flipping control.
- [#790] Generate unique name for each detail. - [#790] Generate unique name for each detail.
- [#792] New feature. Visibility trigger for internal path.
# Version 0.5.1 # Version 0.5.1
- [#683] Tool Seam allowance's dialog is off screen on small resolutions. - [#683] Tool Seam allowance's dialog is off screen on small resolutions.

View File

@ -3644,6 +3644,11 @@ void VPattern::ParsePathElement(VMainGraphicsScene *scene, QDomElement &domEleme
initData.path.SetPenType(LineStyleToPenStyle(GetParametrString(domElement, AttrTypeLine, TypeLineLine))); initData.path.SetPenType(LineStyleToPenStyle(GetParametrString(domElement, AttrTypeLine, TypeLineLine)));
initData.path.SetCutPath(GetParametrBool(domElement, AttrCut, falseStr)); initData.path.SetCutPath(GetParametrBool(domElement, AttrCut, falseStr));
if (initData.path.GetType() == PiecePathType::InternalPath)
{
initData.path.SetVisibilityTrigger(GetParametrString(domElement, AttrVisible, "1"));
}
VToolPiecePath::Create(initData); VToolPiecePath::Create(initData);
} }
catch (const VExceptionBadId &e) catch (const VExceptionBadId &e)

View File

@ -46,6 +46,7 @@
<file>schema/pattern/v0.7.2.xsd</file> <file>schema/pattern/v0.7.2.xsd</file>
<file>schema/pattern/v0.7.3.xsd</file> <file>schema/pattern/v0.7.3.xsd</file>
<file>schema/pattern/v0.7.4.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.3.0.xsd</file>
<file>schema/standard_measurements/v0.4.0.xsd</file> <file>schema/standard_measurements/v0.4.0.xsd</file>
<file>schema/standard_measurements/v0.4.1.xsd</file> <file>schema/standard_measurements/v0.4.1.xsd</file>

File diff suppressed because it is too large Load Diff

View File

@ -58,8 +58,8 @@ class QDomElement;
*/ */
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0"); const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.7.4"); const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.7.5");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.7.4.xsd"); const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.7.5.xsd");
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VPatternConverter::PatternMaxVer; // <== 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(0x000701, QStringLiteral("://schema/pattern/v0.7.1.xsd")),
std::make_pair(0x000702, QStringLiteral("://schema/pattern/v0.7.2.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(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)) if (schemas.contains(ver))
@ -419,6 +420,10 @@ void VPatternConverter::ApplyPatches()
ValidateXML(XSDSchema(0x000704), m_convertedFileName); ValidateXML(XSDSchema(0x000704), m_convertedFileName);
V_FALLTHROUGH V_FALLTHROUGH
case (0x000704): case (0x000704):
ToV0_7_5();
ValidateXML(XSDSchema(0x000705), m_convertedFileName);
V_FALLTHROUGH
case (0x000705):
break; break;
default: default:
InvalidVersion(m_ver); InvalidVersion(m_ver);
@ -436,7 +441,7 @@ void VPatternConverter::DowngradeToCurrentMaxVersion()
bool VPatternConverter::IsReadOnly() const bool VPatternConverter::IsReadOnly() const
{ {
// Check if attribute readOnly was not changed in file format // 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."); "Check attribute readOnly.");
// Possibly in future attribute readOnly will change position etc. // Possibly in future attribute readOnly will change position etc.
@ -950,6 +955,16 @@ void VPatternConverter::ToV0_7_4()
Save(); 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() void VPatternConverter::TagUnitToV0_2_0()
{ {

View File

@ -53,7 +53,7 @@ public:
static const QString PatternMaxVerStr; static const QString PatternMaxVerStr;
static const QString CurrentSchema; static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const int PatternMinVer = CONVERTER_VERSION_CHECK(0, 1, 0); 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: protected:
virtual int MinVer() const Q_DECL_OVERRIDE; virtual int MinVer() const Q_DECL_OVERRIDE;
@ -117,6 +117,7 @@ private:
void ToV0_7_2(); void ToV0_7_2();
void ToV0_7_3(); void ToV0_7_3();
void ToV0_7_4(); void ToV0_7_4();
void ToV0_7_5();
void TagUnitToV0_2_0(); void TagUnitToV0_2_0();
void TagIncrementToV0_2_0(); void TagIncrementToV0_2_0();

View File

@ -31,6 +31,7 @@
#include "vcontainer.h" #include "vcontainer.h"
#include "../vgeometry/vpointf.h" #include "../vgeometry/vpointf.h"
#include "../vlayout/vabstractpiece.h" #include "../vlayout/vabstractpiece.h"
#include "calculator.h"
#include <QPainterPath> #include <QPainterPath>
@ -249,6 +250,18 @@ void VPiecePath::SetCutPath(bool cut)
d->m_cut = 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 QVector<QPointF> VPiecePath::PathPoints(const VContainer *data) const
{ {
@ -780,6 +793,39 @@ QPointF VPiecePath::NodeNextPoint(const VContainer *data, int i) const
return point; 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) int VPiecePath::indexOfNode(const QVector<VPieceNode> &nodes, quint32 id)
{ {

View File

@ -41,6 +41,7 @@ class VContainer;
class QPainterPath; class QPainterPath;
class VPointF; class VPointF;
class VPieceNode; class VPieceNode;
class VInternalVariable;
class VPiecePath class VPiecePath
{ {
@ -81,6 +82,9 @@ public:
bool IsCutPath() const; bool IsCutPath() const;
void SetCutPath(bool cut); void SetCutPath(bool cut);
QString GetVisibilityTrigger() const;
void SetVisibilityTrigger(const QString &formula);
QVector<QPointF> PathPoints(const VContainer *data) const; QVector<QPointF> PathPoints(const VContainer *data) const;
QVector<VPointF> PathNodePoints(const VContainer *data, bool showExcluded = true) const; QVector<VPointF> PathNodePoints(const VContainer *data, bool showExcluded = true) const;
QVector<VSAPoint> SeamAllowancePoints(const VContainer *data, qreal width, bool reverse) 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 NodePreviousPoint(const VContainer *data, int i) const;
QPointF NodeNextPoint(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 indexOfNode(const QVector<VPieceNode> &nodes, quint32 id);
static int FindInLoopNotExcludedUp(int start, const QVector<VPieceNode> &nodes); static int FindInLoopNotExcludedUp(int start, const QVector<VPieceNode> &nodes);

View File

@ -47,7 +47,8 @@ public:
m_type(PiecePathType::Unknown), m_type(PiecePathType::Unknown),
m_name(), m_name(),
m_penType(Qt::SolidLine), m_penType(Qt::SolidLine),
m_cut(false) m_cut(false),
m_visibilityTrigger("1")
{} {}
explicit VPiecePathData(PiecePathType type) explicit VPiecePathData(PiecePathType type)
@ -55,7 +56,8 @@ public:
m_type(type), m_type(type),
m_name(), m_name(),
m_penType(Qt::SolidLine), m_penType(Qt::SolidLine),
m_cut(false) m_cut(false),
m_visibilityTrigger("1")
{} {}
VPiecePathData(const VPiecePathData &path) VPiecePathData(const VPiecePathData &path)
@ -64,7 +66,8 @@ public:
m_type(path.m_type), m_type(path.m_type),
m_name(path.m_name), m_name(path.m_name),
m_penType(path.m_penType), m_penType(path.m_penType),
m_cut(path.m_cut) m_cut(path.m_cut),
m_visibilityTrigger(path.m_visibilityTrigger)
{} {}
~VPiecePathData(); ~VPiecePathData();
@ -74,6 +77,7 @@ public:
QString m_name; QString m_name;
Qt::PenStyle m_penType; Qt::PenStyle m_penType;
bool m_cut; bool m_cut;
QString m_visibilityTrigger;
private: private:
VPiecePathData &operator=(const VPiecePathData &) Q_DECL_EQ_DELETE; VPiecePathData &operator=(const VPiecePathData &) Q_DECL_EQ_DELETE;

View File

@ -43,12 +43,17 @@ DialogPiecePath::DialogPiecePath(const VContainer *data, quint32 toolId, QWidget
ui(new Ui::DialogPiecePath), ui(new Ui::DialogPiecePath),
m_showMode(false), m_showMode(false),
m_saWidth(0), m_saWidth(0),
m_timerWidth(nullptr), m_timerWidth(new QTimer(this)),
m_timerWidthBefore(nullptr), m_timerWidthBefore(new QTimer(this)),
m_timerWidthAfter(nullptr), m_timerWidthAfter(new QTimer(this)),
m_timerVisible(new QTimer(this)),
m_formulaBaseWidth(0), m_formulaBaseWidth(0),
m_formulaBaseWidthBefore(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); ui->setupUi(this);
InitOkCancel(ui); InitOkCancel(ui);
@ -56,6 +61,9 @@ DialogPiecePath::DialogPiecePath(const VContainer *data, quint32 toolId, QWidget
InitPathTab(); InitPathTab();
InitSeamAllowanceTab(); InitSeamAllowanceTab();
InitPassmarksTab(); InitPassmarksTab();
InitControlTab();
EvalVisible();
flagName = true;//We have default name of piece. flagName = true;//We have default name of piece.
flagError = PathIsValid(); flagError = PathIsValid();
@ -189,7 +197,37 @@ void DialogPiecePath::ShowDialog(bool click)
void DialogPiecePath::CheckState() void DialogPiecePath::CheckState()
{ {
SCASSERT(bOk != nullptr); 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->plainTextEditFormulaWidth->blockSignals(true);
ui->plainTextEditFormulaWidthBefore->blockSignals(true); ui->plainTextEditFormulaWidthBefore->blockSignals(true);
ui->plainTextEditFormulaWidthAfter->blockSignals(true); ui->plainTextEditFormulaWidthAfter->blockSignals(true);
ui->plainTextEditFormulaVisible->blockSignals(true);
DialogTool::closeEvent(event); DialogTool::closeEvent(event);
} }
@ -594,8 +633,7 @@ void DialogPiecePath::EvalWidthBefore()
labelEditFormula = ui->labelEditBefore; labelEditFormula = ui->labelEditBefore;
const QString postfix = UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
QString formula = ui->plainTextEditFormulaWidthBefore->toPlainText(); QString formula = ui->plainTextEditFormulaWidthBefore->toPlainText();
bool flagFormula = false; // fake flag Eval(formula, m_flagFormulaBefore, ui->labelResultBefore, postfix, false, true);
Eval(formula, flagFormula, ui->labelResultBefore, postfix, false, true);
formula = GetFormulaSAWidthBefore(); formula = GetFormulaSAWidthBefore();
if (formula != currentSeamAllowance) if (formula != currentSeamAllowance)
@ -612,8 +650,7 @@ void DialogPiecePath::EvalWidthAfter()
labelEditFormula = ui->labelEditAfter; labelEditFormula = ui->labelEditAfter;
const QString postfix = UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
QString formula = ui->plainTextEditFormulaWidthAfter->toPlainText(); QString formula = ui->plainTextEditFormulaWidthAfter->toPlainText();
bool flagFormula = false; // fake flag Eval(formula, m_flagFormulaAfter, ui->labelResultAfter, postfix, false, true);
Eval(formula, flagFormula, ui->labelResultAfter, postfix, false, true);
formula = GetFormulaSAWidthAfter(); formula = GetFormulaSAWidthAfter();
if (formula != currentSeamAllowance) if (formula != currentSeamAllowance)
@ -624,10 +661,18 @@ void DialogPiecePath::EvalWidthAfter()
UpdateNodeSAAfter(formula); UpdateNodeSAAfter(formula);
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::EvalVisible()
{
labelEditFormula = ui->labelEditVisible;
QString formula = ui->plainTextEditFormulaVisible->toPlainText();
Eval(formula, m_flagFormulaVisible, ui->labelResultVisible, "", false, true);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::FXWidth() 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->setWindowTitle(tr("Edit seam allowance width"));
dialog->SetFormula(GetFormulaSAWidth()); dialog->SetFormula(GetFormulaSAWidth());
dialog->setCheckLessThanZero(true); dialog->setCheckLessThanZero(true);
@ -636,13 +681,12 @@ void DialogPiecePath::FXWidth()
{ {
SetFormulaSAWidth(dialog->GetFormula()); SetFormulaSAWidth(dialog->GetFormula());
} }
delete dialog;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::FXWidthBefore() 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->setWindowTitle(tr("Edit seam allowance width before"));
dialog->SetFormula(GetFormulaSAWidthBefore()); dialog->SetFormula(GetFormulaSAWidthBefore());
dialog->setCheckLessThanZero(true); dialog->setCheckLessThanZero(true);
@ -651,13 +695,12 @@ void DialogPiecePath::FXWidthBefore()
{ {
SetCurrentSABefore(dialog->GetFormula()); SetCurrentSABefore(dialog->GetFormula());
} }
delete dialog;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::FXWidthAfter() 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->setWindowTitle(tr("Edit seam allowance width after"));
dialog->SetFormula(GetFormulaSAWidthAfter()); dialog->SetFormula(GetFormulaSAWidthAfter());
dialog->setCheckLessThanZero(true); dialog->setCheckLessThanZero(true);
@ -666,7 +709,18 @@ void DialogPiecePath::FXWidthAfter()
{ {
SetCurrentSAAfter(dialog->GetFormula()); 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; labelEditFormula = ui->labelEditBefore;
labelResultCalculation = ui->labelResultBefore; labelResultCalculation = ui->labelResultBefore;
const QString postfix = UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
bool flagFormula = false; ValFormulaChanged(m_flagFormulaBefore, ui->plainTextEditFormulaWidthBefore, m_timerWidthBefore, postfix);
ValFormulaChanged(flagFormula, ui->plainTextEditFormulaWidthBefore, m_timerWidthBefore, postfix);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -694,8 +747,15 @@ void DialogPiecePath::WidthAfterChanged()
labelEditFormula = ui->labelEditAfter; labelEditFormula = ui->labelEditAfter;
labelResultCalculation = ui->labelResultAfter; labelResultCalculation = ui->labelResultAfter;
const QString postfix = UnitsToStr(qApp->patternUnit(), true); const QString postfix = UnitsToStr(qApp->patternUnit(), true);
bool flagFormula = false; ValFormulaChanged(m_flagFormulaAfter, ui->plainTextEditFormulaWidthAfter, m_timerWidthAfter, postfix);
ValFormulaChanged(flagFormula, 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); DeployFormula(ui->plainTextEditFormulaWidthAfter, ui->pushButtonGrowWidthAfter, m_formulaBaseWidthAfter);
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::DeployVisibleFormulaTextEdit()
{
DeployFormula(ui->plainTextEditFormulaVisible, ui->pushButtonGrowVisible, m_formulaBaseVisible);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPiecePath::InitPathTab() void DialogPiecePath::InitPathTab()
{ {
@ -731,6 +797,7 @@ void DialogPiecePath::InitPathTab()
{ {
ui->comboBoxPenType->setEnabled(GetType() == PiecePathType::InternalPath); ui->comboBoxPenType->setEnabled(GetType() == PiecePathType::InternalPath);
ui->checkBoxCut->setEnabled(GetType() == PiecePathType::InternalPath); ui->checkBoxCut->setEnabled(GetType() == PiecePathType::InternalPath);
ui->tabControl->setEnabled(GetType() == PiecePathType::InternalPath);
ValidObjects(PathIsValid()); ValidObjects(PathIsValid());
}); });
@ -750,13 +817,8 @@ void DialogPiecePath::InitSeamAllowanceTab()
ui->plainTextEditFormulaWidthBefore->installEventFilter(this); ui->plainTextEditFormulaWidthBefore->installEventFilter(this);
ui->plainTextEditFormulaWidthAfter->installEventFilter(this); ui->plainTextEditFormulaWidthAfter->installEventFilter(this);
m_timerWidth = new QTimer(this);
connect(m_timerWidth, &QTimer::timeout, this, &DialogPiecePath::EvalWidth); connect(m_timerWidth, &QTimer::timeout, this, &DialogPiecePath::EvalWidth);
m_timerWidthBefore = new QTimer(this);
connect(m_timerWidthBefore, &QTimer::timeout, this, &DialogPiecePath::EvalWidthBefore); connect(m_timerWidthBefore, &QTimer::timeout, this, &DialogPiecePath::EvalWidthBefore);
m_timerWidthAfter = new QTimer(this);
connect(m_timerWidthAfter, &QTimer::timeout, this, &DialogPiecePath::EvalWidthAfter); 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. // 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); 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() void DialogPiecePath::InitPathTypes()
{ {
@ -925,6 +1001,15 @@ void DialogPiecePath::SetPiecePath(const VPiecePath &path)
SetPenType(path.GetPenType()); SetPenType(path.GetPenType());
SetCutPath(path.IsCutPath()); SetCutPath(path.IsCutPath());
if (path.GetType() == PiecePathType::InternalPath)
{
SetFormulaVisible(path.GetVisibilityTrigger());
}
else
{
ui->plainTextEditFormulaVisible->setPlainText("1");
}
ValidObjects(PathIsValid()); ValidObjects(PathIsValid());
ListChanged(); ListChanged();
@ -1141,6 +1226,15 @@ VPiecePath DialogPiecePath::CreatePath() const
path.SetPenType(GetType() == PiecePathType::InternalPath ? GetPenType() : Qt::SolidLine); path.SetPenType(GetType() == PiecePathType::InternalPath ? GetPenType() : Qt::SolidLine);
path.SetCutPath(GetType() == PiecePathType::InternalPath ? IsCutPath() : false); path.SetCutPath(GetType() == PiecePathType::InternalPath ? IsCutPath() : false);
if (GetType() == PiecePathType::InternalPath)
{
path.SetVisibilityTrigger(GetFormulaVisible());
}
else
{
path.SetVisibilityTrigger("1");
}
return path; return path;
} }
@ -1222,3 +1316,24 @@ QString DialogPiecePath::GetFormulaSAWidthAfter() const
width.replace("\n", " "); width.replace("\n", " ");
return qApp->TrVars()->TryFormulaFromUser(width, qApp->Settings()->GetOsSeparator()); 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);
}

View File

@ -79,18 +79,22 @@ private slots:
void EvalWidth(); void EvalWidth();
void EvalWidthBefore(); void EvalWidthBefore();
void EvalWidthAfter(); void EvalWidthAfter();
void EvalVisible();
void FXWidth(); void FXWidth();
void FXWidthBefore(); void FXWidthBefore();
void FXWidthAfter(); void FXWidthAfter();
void FXVisible();
void WidthChanged(); void WidthChanged();
void WidthBeforeChanged(); void WidthBeforeChanged();
void WidthAfterChanged(); void WidthAfterChanged();
void VisibleChanged();
void DeployWidthFormulaTextEdit(); void DeployWidthFormulaTextEdit();
void DeployWidthBeforeFormulaTextEdit(); void DeployWidthBeforeFormulaTextEdit();
void DeployWidthAfterFormulaTextEdit(); void DeployWidthAfterFormulaTextEdit();
void DeployVisibleFormulaTextEdit();
private: private:
Q_DISABLE_COPY(DialogPiecePath) Q_DISABLE_COPY(DialogPiecePath)
@ -101,14 +105,21 @@ private:
QTimer *m_timerWidth; QTimer *m_timerWidth;
QTimer *m_timerWidthBefore; QTimer *m_timerWidthBefore;
QTimer *m_timerWidthAfter; QTimer *m_timerWidthAfter;
QTimer *m_timerVisible;
int m_formulaBaseWidth; int m_formulaBaseWidth;
int m_formulaBaseWidthBefore; int m_formulaBaseWidthBefore;
int m_formulaBaseWidthAfter; int m_formulaBaseWidthAfter;
int m_formulaBaseVisible;
bool m_flagFormulaBefore;
bool m_flagFormulaAfter;
bool m_flagFormulaVisible;
void InitPathTab(); void InitPathTab();
void InitSeamAllowanceTab(); void InitSeamAllowanceTab();
void InitPassmarksTab(); void InitPassmarksTab();
void InitControlTab();
void InitPathTypes(); void InitPathTypes();
void InitNodesList(); void InitNodesList();
void InitPassmarksList(); void InitPassmarksList();
@ -141,6 +152,9 @@ private:
QString GetFormulaSAWidthBefore() const; QString GetFormulaSAWidthBefore() const;
QString GetFormulaSAWidthAfter() const; QString GetFormulaSAWidthAfter() const;
QString GetFormulaVisible() const;
void SetFormulaVisible(const QString &formula);
}; };
#endif // DIALOGPIECEPATH_H #endif // DIALOGPIECEPATH_H

View File

@ -1002,6 +1002,215 @@
</item> </item>
</layout> </layout>
</widget> </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 &quot;0&quot; 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>&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>
<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> </widget>
</item> </item>
<item> <item>

View File

@ -192,6 +192,7 @@ void VToolPiecePath::AddAttributes(VAbstractPattern *doc, QDomElement &domElemen
if (path.GetType() == PiecePathType::InternalPath) if (path.GetType() == PiecePathType::InternalPath)
{ {
doc->SetAttribute(domElement, VAbstractPattern::AttrVisible, path.GetVisibilityTrigger());
doc->SetAttribute(domElement, AttrCut, path.IsCutPath()); doc->SetAttribute(domElement, AttrCut, path.IsCutPath());
} }
} }
@ -308,6 +309,8 @@ void VToolPiecePath::RefreshGeometry()
QPen pen = this->pen(); QPen pen = this->pen();
pen.setStyle(path.GetPenType()); pen.setStyle(path.GetPenType());
this->setPen(pen); this->setPen(pen);
setVisible(path.IsVisible(this->getData()->DataVariables()));
} }
} }