Resolved issue #867. Visibility control for place labels.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2018-07-20 10:30:05 +03:00
parent 20b3f034d4
commit 1ae08d6020
19 changed files with 2105 additions and 637 deletions

View File

@ -52,6 +52,7 @@
- Mouse double click zoom fit best current pattern piece.
- [#862] Force Valentina to immediately terminate if a pattern contains a parsing warning.
- [#865] New feature. Dynamic Way to define Material in piece label.
- [#867] Visibility control for place labels.
# Version 0.5.1 (unreleased)
- [#683] Tool Seam allowance's dialog is off screen on small resolutions.

View File

@ -1827,16 +1827,21 @@ void VPattern::ParsePlaceLabel(QDomElement &domElement, const Document &parse)
initData.angle = GetParametrString(domElement, AttrAngle, "0.0");
const QString angle = initData.angle;//need for saving fixed formula;
initData.visibilityTrigger = GetParametrString(domElement, VAbstractPattern::AttrVisible, "1.0");
const QString visibility = initData.visibilityTrigger;//need for saving fixed formula;
initData.type = static_cast<PlaceLabelType>(GetParametrUInt(domElement, AttrPlaceLabelType, QChar('0')));
VToolPlaceLabel::Create(initData);
//Rewrite attribute formula. Need for situation when we have wrong formula.
if (w != initData.width || h != initData.height || angle != initData.angle)
if (w != initData.width || h != initData.height || angle != initData.angle
|| visibility != initData.visibilityTrigger)
{
SetAttribute(domElement, AttrWidth, initData.width);
SetAttribute(domElement, AttrHeight, initData.height);
SetAttribute(domElement, AttrAngle, initData.angle);
SetAttribute(domElement, VAbstractPattern::AttrVisible, initData.visibilityTrigger);
modified = true;
haveLiteChange();
}

View File

@ -50,6 +50,7 @@
<file>schema/pattern/v0.7.6.xsd</file>
<file>schema/pattern/v0.7.7.xsd</file>
<file>schema/pattern/v0.7.8.xsd</file>
<file>schema/pattern/v0.7.9.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>

File diff suppressed because it is too large Load Diff

View File

@ -59,8 +59,8 @@ class QDomElement;
*/
const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.7.8");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.7.8.xsd");
const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.7.9");
const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.7.9.xsd");
//VPatternConverter::PatternMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VPatternConverter::PatternMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
@ -228,7 +228,8 @@ QString VPatternConverter::XSDSchema(int ver) const
std::make_pair(0x000705, QStringLiteral("://schema/pattern/v0.7.5.xsd")),
std::make_pair(0x000706, QStringLiteral("://schema/pattern/v0.7.6.xsd")),
std::make_pair(0x000707, QStringLiteral("://schema/pattern/v0.7.7.xsd")),
std::make_pair(0x000708, CurrentSchema)
std::make_pair(0x000708, QStringLiteral("://schema/pattern/v0.7.8.xsd")),
std::make_pair(0x000709, CurrentSchema)
};
if (schemas.contains(ver))
@ -443,6 +444,10 @@ void VPatternConverter::ApplyPatches()
ValidateXML(XSDSchema(0x000708), m_convertedFileName);
V_FALLTHROUGH
case (0x000708):
ToV0_7_9();
ValidateXML(XSDSchema(0x000709), m_convertedFileName);
V_FALLTHROUGH
case (0x000709):
break;
default:
InvalidVersion(m_ver);
@ -460,7 +465,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, 8),
Q_STATIC_ASSERT_X(VPatternConverter::PatternMaxVer == CONVERTER_VERSION_CHECK(0, 7, 9),
"Check attribute readOnly.");
// Possibly in future attribute readOnly will change position etc.
@ -1014,6 +1019,15 @@ void VPatternConverter::ToV0_7_8()
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::ToV0_7_9()
{
// TODO. Delete if minimal supported version is 0.7.9
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < CONVERTER_VERSION_CHECK(0, 7, 9),
"Time to refactor the code.");
SetVersion(QStringLiteral("0.7.9"));
Save();
}
//---------------------------------------------------------------------------------------------------------------------
void VPatternConverter::TagUnitToV0_2_0()

View File

@ -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, 8);
static Q_DECL_CONSTEXPR const int PatternMaxVer = CONVERTER_VERSION_CHECK(0, 7, 9);
protected:
virtual int MinVer() const override;
@ -121,6 +121,7 @@ private:
void ToV0_7_6();
void ToV0_7_7();
void ToV0_7_8();
void ToV0_7_9();
void TagUnitToV0_2_0();
void TagIncrementToV0_2_0();

View File

@ -125,6 +125,41 @@ void VPlaceLabelItem::SetAngle(qreal value, const QString &formula)
d->angle = formula;
}
//---------------------------------------------------------------------------------------------------------------------
QString VPlaceLabelItem::GetVisibilityTrigger() const
{
return d->visibilityTrigger;
}
//---------------------------------------------------------------------------------------------------------------------
QString &VPlaceLabelItem::GetVisibilityTrigger()
{
return d->visibilityTrigger;
}
//---------------------------------------------------------------------------------------------------------------------
bool VPlaceLabelItem::IsVisible() const
{
bool visible = true;
if (qIsInf(d->isVisible) || qIsNaN(d->isVisible))
{
qWarning() << QObject::tr("Visibility trigger contains error and will be ignored");
}
else if (qFuzzyIsNull(d->isVisible))
{
visible = false;
}
return visible;
}
//---------------------------------------------------------------------------------------------------------------------
void VPlaceLabelItem::SetVisibilityTrigger(qreal visible, const QString &formula)
{
d->visibilityTrigger = formula;
d->isVisible = visible;
}
//---------------------------------------------------------------------------------------------------------------------
qreal VPlaceLabelItem::GetCorrectionAngle() const
{

View File

@ -68,6 +68,11 @@ public:
qreal GetAngle() const;
void SetAngle(qreal value, const QString &formula);
QString GetVisibilityTrigger() const;
QString& GetVisibilityTrigger();
bool IsVisible() const;
void SetVisibilityTrigger(qreal visible, const QString &formula);
qreal GetCorrectionAngle() const;
void SetCorrectionAngle(qreal value);

View File

@ -44,12 +44,14 @@ public:
: width(),
height(),
angle('0'),
visibilityTrigger('1'),
type(PlaceLabelType::Button),
centerPoint(0),
wValue(0),
hValue(0),
aValue(0),
correctionAngle(0)
correctionAngle(0),
isVisible(1)
{}
VPlaceLabelItemData(const VPlaceLabelItemData &item)
@ -57,12 +59,14 @@ public:
width(item.width),
height(item.height),
angle(item.angle),
visibilityTrigger(item.visibilityTrigger),
type(item.type),
centerPoint(item.centerPoint),
wValue(item.wValue),
hValue(item.hValue),
aValue(item.aValue),
correctionAngle(item.correctionAngle)
correctionAngle(item.correctionAngle),
isVisible(item.isVisible)
{}
virtual ~VPlaceLabelItemData();
@ -70,6 +74,7 @@ public:
QString width;
QString height;
QString angle;
QString visibilityTrigger;
PlaceLabelType type;
quint32 centerPoint;
@ -77,6 +82,7 @@ public:
qreal hValue;
qreal aValue;
qreal correctionAngle;
qreal isVisible;
private:
VPlaceLabelItemData &operator=(const VPlaceLabelItemData &) Q_DECL_EQ_DELETE;

View File

@ -352,12 +352,15 @@ QVector<VLayoutPlaceLabel> ConvertPlaceLabels(const VPiece &piece, const VContai
for(auto placeLabel : placeLabels)
{
const auto label = pattern->GeometricObject<VPlaceLabelItem>(placeLabel);
if (label->IsVisible())
{
VLayoutPlaceLabel layoutLabel;
layoutLabel.shape = label->LabelShape();
layoutLabel.center = label->toQPointF();
layoutLabel.type = label->GetLabelType();
labels.append(layoutLabel);
}
}
return labels;
}
}

View File

@ -452,8 +452,11 @@ QVector<PlaceLabelImg> VPiece::PlaceLabelPoints(const VContainer *data) const
try
{
const auto label = data->GeometricObject<VPlaceLabelItem>(placeLabel);
if (label->IsVisible())
{
points.append(label->LabelShape());
}
}
catch (const VExceptionBadId &e)
{
qWarning() << e.ErrorMessage();

View File

@ -45,50 +45,27 @@ DialogPlaceLabel::DialogPlaceLabel(const VContainer *data, quint32 toolId, QWidg
m_flagWidth(false),
m_flagHeight(false),
m_flagAngle(false),
m_flagFormulaVisible(false),
m_formulaBaseHeightWidth(0),
m_formulaBaseHeightHeight(0),
m_formulaBaseHeightAngle(0),
m_formulaBaseVisible(0),
timerAngle(new QTimer(this)),
timerWidth(new QTimer(this)),
timerHeight(new QTimer(this))
timerHeight(new QTimer(this)),
m_timerVisible(new QTimer(this))
{
ui->setupUi(this);
InitOkCancel(ui);
FillComboBoxPoints(ui->comboBoxPoint);
FillPlaceLabelTypes();
InitPlaceLabelTab();
InitControlTab();
m_formulaBaseHeightWidth = ui->plainTextEditFormulaWidth->height();
m_formulaBaseHeightHeight = ui->plainTextEditFormulaHeight->height();
m_formulaBaseHeightAngle = ui->plainTextEditFormulaAngle->height();
ui->plainTextEditFormulaWidth->installEventFilter(this);
ui->plainTextEditFormulaHeight->installEventFilter(this);
ui->plainTextEditFormulaAngle->installEventFilter(this);
ui->plainTextEditFormulaWidth->setPlainText(QString::number(UnitConvertor(1, Unit::Cm, qApp->patternUnit())));
ui->plainTextEditFormulaHeight->setPlainText(QString::number(UnitConvertor(1, Unit::Cm, qApp->patternUnit())));
EvalVisible();
flagError = false;
CheckState();
connect(ui->toolButtonExprWidth, &QPushButton::clicked, this, &DialogPlaceLabel::FXWidth);
connect(ui->toolButtonExprHeight, &QPushButton::clicked, this, &DialogPlaceLabel::FXHeight);
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogPlaceLabel::FXAngle);
connect(ui->plainTextEditFormulaWidth, &QPlainTextEdit::textChanged, this, &DialogPlaceLabel::FormulaWidthChanged);
connect(ui->plainTextEditFormulaHeight, &QPlainTextEdit::textChanged, this,
&DialogPlaceLabel::FormulaHeightChanged);
connect(ui->plainTextEditFormulaAngle, &QPlainTextEdit::textChanged, this, &DialogPlaceLabel::FormulaAngleChanged);
connect(ui->pushButtonGrowWidth, &QPushButton::clicked, this, &DialogPlaceLabel::DeployFormulaWidthEdit);
connect(ui->pushButtonGrowHeight, &QPushButton::clicked, this, &DialogPlaceLabel::DeployFormulaHeightEdit);
connect(ui->pushButtonGrowAngle, &QPushButton::clicked, this, &DialogPlaceLabel::DeployFormulaAngleEdit);
connect(timerWidth, &QTimer::timeout, this, &DialogPlaceLabel::EvalWidth);
connect(timerHeight, &QTimer::timeout, this, &DialogPlaceLabel::EvalHeight);
connect(timerAngle, &QTimer::timeout, this, &DialogPlaceLabel::EvalAngle);
connect(ui->comboBoxPiece, QOverload<int>::of(&QComboBox::currentIndexChanged), this, [this]()
{
CheckPieces();
@ -287,7 +264,7 @@ void DialogPlaceLabel::ChosenObject(quint32 id, const SceneObject &type)
void DialogPlaceLabel::CheckState()
{
SCASSERT(bOk != nullptr);
bOk->setEnabled(m_flagPoint && flagError && m_flagWidth && m_flagHeight && m_flagAngle);
bOk->setEnabled(m_flagPoint && flagError && m_flagWidth && m_flagHeight && m_flagAngle && m_flagFormulaVisible);
}
//---------------------------------------------------------------------------------------------------------------------
@ -305,6 +282,7 @@ void DialogPlaceLabel::closeEvent(QCloseEvent *event)
ui->plainTextEditFormulaWidth->blockSignals(true);
ui->plainTextEditFormulaHeight->blockSignals(true);
ui->plainTextEditFormulaAngle->blockSignals(true);
ui->plainTextEditFormulaVisible->blockSignals(true);
DialogTool::closeEvent(event);
}
@ -326,6 +304,12 @@ void DialogPlaceLabel::DeployFormulaAngleEdit()
DeployFormula(ui->plainTextEditFormulaAngle, ui->pushButtonGrowAngle, m_formulaBaseHeightAngle);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPlaceLabel::DeployVisibleFormulaTextEdit()
{
DeployFormula(ui->plainTextEditFormulaVisible, ui->pushButtonGrowVisible, m_formulaBaseVisible);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPlaceLabel::FormulaWidthChanged()
{
@ -352,6 +336,14 @@ void DialogPlaceLabel::FormulaAngleChanged()
ValFormulaChanged(m_flagAngle, ui->plainTextEditFormulaAngle, timerAngle, degreeSymbol);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPlaceLabel::VisibleChanged()
{
labelEditFormula = ui->labelEditVisible;
labelResultCalculation = ui->labelResultVisible;
ValFormulaChanged(m_flagFormulaVisible, ui->plainTextEditFormulaVisible, m_timerVisible, QString());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPlaceLabel::EvalWidth()
{
@ -378,6 +370,14 @@ void DialogPlaceLabel::EvalAngle()
false);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPlaceLabel::EvalVisible()
{
labelEditFormula = ui->labelEditVisible;
QString formula = ui->plainTextEditFormulaVisible->toPlainText();
Eval(formula, m_flagFormulaVisible, ui->labelResultVisible, QString(), false, true);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPlaceLabel::FXWidth()
{
@ -417,6 +417,67 @@ void DialogPlaceLabel::FXAngle()
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPlaceLabel::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());
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPlaceLabel::InitPlaceLabelTab()
{
FillComboBoxPoints(ui->comboBoxPoint);
FillPlaceLabelTypes();
m_formulaBaseHeightWidth = ui->plainTextEditFormulaWidth->height();
m_formulaBaseHeightHeight = ui->plainTextEditFormulaHeight->height();
m_formulaBaseHeightAngle = ui->plainTextEditFormulaAngle->height();
ui->plainTextEditFormulaWidth->installEventFilter(this);
ui->plainTextEditFormulaHeight->installEventFilter(this);
ui->plainTextEditFormulaAngle->installEventFilter(this);
ui->plainTextEditFormulaWidth->setPlainText(QString::number(UnitConvertor(1, Unit::Cm, qApp->patternUnit())));
ui->plainTextEditFormulaHeight->setPlainText(QString::number(UnitConvertor(1, Unit::Cm, qApp->patternUnit())));
connect(ui->toolButtonExprWidth, &QPushButton::clicked, this, &DialogPlaceLabel::FXWidth);
connect(ui->toolButtonExprHeight, &QPushButton::clicked, this, &DialogPlaceLabel::FXHeight);
connect(ui->toolButtonExprAngle, &QPushButton::clicked, this, &DialogPlaceLabel::FXAngle);
connect(ui->plainTextEditFormulaWidth, &QPlainTextEdit::textChanged, this, &DialogPlaceLabel::FormulaWidthChanged);
connect(ui->plainTextEditFormulaHeight, &QPlainTextEdit::textChanged, this,
&DialogPlaceLabel::FormulaHeightChanged);
connect(ui->plainTextEditFormulaAngle, &QPlainTextEdit::textChanged, this, &DialogPlaceLabel::FormulaAngleChanged);
connect(ui->pushButtonGrowWidth, &QPushButton::clicked, this, &DialogPlaceLabel::DeployFormulaWidthEdit);
connect(ui->pushButtonGrowHeight, &QPushButton::clicked, this, &DialogPlaceLabel::DeployFormulaHeightEdit);
connect(ui->pushButtonGrowAngle, &QPushButton::clicked, this, &DialogPlaceLabel::DeployFormulaAngleEdit);
connect(timerWidth, &QTimer::timeout, this, &DialogPlaceLabel::EvalWidth);
connect(timerHeight, &QTimer::timeout, this, &DialogPlaceLabel::EvalHeight);
connect(timerAngle, &QTimer::timeout, this, &DialogPlaceLabel::EvalAngle);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPlaceLabel::InitControlTab()
{
this->m_formulaBaseVisible = ui->plainTextEditFormulaVisible->height();
ui->plainTextEditFormulaVisible->installEventFilter(this);
connect(m_timerVisible, &QTimer::timeout, this, &DialogPlaceLabel::EvalVisible);
connect(ui->toolButtonExprVisible, &QPushButton::clicked, this, &DialogPlaceLabel::FXVisible);
connect(ui->plainTextEditFormulaVisible, &QPlainTextEdit::textChanged, this, &DialogPlaceLabel::VisibleChanged);
connect(ui->pushButtonGrowVisible, &QPushButton::clicked, this,
&DialogPlaceLabel::DeployVisibleFormulaTextEdit);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPlaceLabel::FillPlaceLabelTypes()
{
@ -469,3 +530,23 @@ void DialogPlaceLabel::CheckPoint()
ChangeColor(ui->labelPoint, color);
CheckState();
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogPlaceLabel::GetFormulaVisible() const
{
QString formula = ui->plainTextEditFormulaVisible->toPlainText();
return qApp->TrVars()->TryFormulaFromUser(formula, qApp->Settings()->GetOsSeparator());
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPlaceLabel::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

@ -65,6 +65,9 @@ public:
quint32 GetPieceId() const;
void SetPieceId(quint32 id);
QString GetFormulaVisible() const;
void SetFormulaVisible(const QString &formula);
virtual void SetPiecesList(const QVector<quint32> &list) override;
public slots:
@ -79,18 +82,22 @@ private slots:
void DeployFormulaWidthEdit();
void DeployFormulaHeightEdit();
void DeployFormulaAngleEdit();
void DeployVisibleFormulaTextEdit();
void FormulaWidthChanged();
void FormulaHeightChanged();
void FormulaAngleChanged();
void VisibleChanged();
void EvalWidth();
void EvalHeight();
void EvalAngle();
void EvalVisible();
void FXWidth();
void FXHeight();
void FXAngle();
void FXVisible();
private:
Q_DISABLE_COPY(DialogPlaceLabel)
@ -100,15 +107,21 @@ private:
bool m_flagWidth;
bool m_flagHeight;
bool m_flagAngle;
bool m_flagFormulaVisible;
/** @brief formulaBaseHeight base height defined by dialogui */
int m_formulaBaseHeightWidth;
int m_formulaBaseHeightHeight;
int m_formulaBaseHeightAngle;
int m_formulaBaseVisible;
QTimer *timerAngle;
QTimer *timerWidth;
QTimer *timerHeight;
QTimer *m_timerVisible;
void InitPlaceLabelTab();
void InitControlTab();
void FillPlaceLabelTypes();

View File

@ -6,14 +6,28 @@
<rect>
<x>0</x>
<y>0</y>
<width>338</width>
<height>363</height>
<width>396</width>
<height>414</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
<string>Place label</string>
</property>
<property name="windowIcon">
<iconset resource="../../../../vmisc/share/resources/icon.qrc">
<normaloff>:/icon/64x64/icon64x64.png</normaloff>:/icon/64x64/icon64x64.png</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabPlaceLabel">
<attribute name="title">
<string>Place label</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item alignment="Qt::AlignLeft">
@ -603,6 +617,219 @@
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabControl">
<attribute name="title">
<string>Control</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<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_8">
<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>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">

View File

@ -843,6 +843,7 @@ void DialogSeamAllowance::ShowPlaceLabelsContextMenu(const QPoint &pos)
dialog->SetWidth(currentLabel.GetWidthFormula());
dialog->SetHeight(currentLabel.GetHeightFormula());
dialog->SetAngle(currentLabel.GetAngleFormula());
dialog->SetFormulaVisible(currentLabel.GetVisibilityTrigger());
dialog->SetPieceId(toolId);
dialog->EnbleShowMode(true);
m_dialog = dialog;
@ -1295,7 +1296,8 @@ void DialogSeamAllowance::PlaceLabelDialogClosed(int result)
const qreal w = qAbs(Visualization::FindLengthFromUser(dialogTool->GetWidth(), vars, false));
const qreal h = qAbs(Visualization::FindLengthFromUser(dialogTool->GetHeight(), vars, false));
const qreal a = Visualization::FindValFromUser(dialogTool->GetAngle(), vars, false);
qDebug() << w << h << a;
const qreal v = Visualization::FindValFromUser(dialogTool->GetFormulaVisible(), vars, false);
qDebug() << w << h << a << v;
VPlaceLabelItem newLabel = VPlaceLabelItem();
newLabel.setName(currentLabel.name());
@ -1306,6 +1308,7 @@ void DialogSeamAllowance::PlaceLabelDialogClosed(int result)
newLabel.SetWidth(w, dialogTool->GetWidth());
newLabel.SetHeight(h, dialogTool->GetHeight());
newLabel.SetAngle(a, dialogTool->GetAngle());
newLabel.SetVisibilityTrigger(v, dialogTool->GetFormulaVisible());
newLabel.SetLabelType(dialogTool->GetLabelType());
newLabel.SetCenterPoint(currentLabel.GetCenterPoint());
newLabel.SetCorrectionAngle(currentLabel.GetCorrectionAngle());

View File

@ -46,6 +46,7 @@ VToolPlaceLabel *VToolPlaceLabel::Create(QSharedPointer<DialogTool> dialog, VAbs
initData.width = dialogTool->GetWidth();
initData.height = dialogTool->GetHeight();
initData.angle = dialogTool->GetAngle();
initData.visibilityTrigger = dialogTool->GetFormulaVisible();
initData.type = dialogTool->GetLabelType();
initData.centerPoint = dialogTool->GetCenterPoint();
initData.idObject = dialogTool->GetPieceId();
@ -63,11 +64,13 @@ VToolPlaceLabel *VToolPlaceLabel::Create(VToolPlaceLabelInitData &initData)
const qreal w = qAbs(qApp->toPixel(CheckFormula(initData.id, initData.width, initData.data)));
const qreal h = qAbs(qApp->toPixel(CheckFormula(initData.id, initData.height, initData.data)));
const qreal a = CheckFormula(initData.id, initData.angle, initData.data);
const qreal v = CheckFormula(initData.id, initData.visibilityTrigger, initData.data);
QSharedPointer<VPlaceLabelItem> node(new VPlaceLabelItem());
node->SetWidth(w, initData.width);
node->SetHeight(h, initData.height);
node->SetAngle(a, initData.angle);
node->SetVisibilityTrigger(v, initData.visibilityTrigger);
node->SetLabelType(initData.type);
node->SetCenterPoint(initData.centerPoint);
@ -159,6 +162,7 @@ void VToolPlaceLabel::AddAttributes(VAbstractPattern *doc, QDomElement &domEleme
doc->SetAttribute(domElement, AttrWidth, label.GetWidthFormula());
doc->SetAttribute(domElement, AttrHeight, label.GetHeightFormula());
doc->SetAttribute(domElement, AttrAngle, label.GetAngleFormula());
doc->SetAttribute(domElement, VAbstractPattern::AttrVisible, label.GetVisibilityTrigger());
doc->SetAttribute(domElement, AttrPlaceLabelType, static_cast<int>(label.GetLabelType()));
}

View File

@ -43,7 +43,8 @@ struct VToolPlaceLabelInitData : VAbstractNodeInitData
height('0'),
angle('0'),
type(PlaceLabelType::Button),
centerPoint(NULL_ID)
centerPoint(NULL_ID),
visibilityTrigger('1')
{}
QString width;
@ -51,6 +52,7 @@ struct VToolPlaceLabelInitData : VAbstractNodeInitData
QString angle;
PlaceLabelType type;
quint32 centerPoint;
QString visibilityTrigger;
};
class VToolPlaceLabel : public VAbstractNode

View File

@ -2093,6 +2093,7 @@ QVector<quint32> VToolSeamAllowance::DuplicatePlaceLabels(const QVector<quint32>
initNodeData.width = label->GetWidthFormula();
initNodeData.height = label->GetHeightFormula();
initNodeData.angle = label->GetAngleFormula();
initNodeData.visibilityTrigger = label->GetVisibilityTrigger();
initNodeData.type = label->GetLabelType();
initNodeData.centerPoint = label->GetCenterPoint();
initNodeData.id = initNodeData.data->AddGObject(new VPlaceLabelItem(*label));

View File

@ -490,6 +490,7 @@ quint32 AddPlaceLabel(quint32 id, const VToolUnionDetailsInitData &initData, QVe
initNodeData.width = label->GetWidthFormula();
initNodeData.height = label->GetHeightFormula();
initNodeData.angle = label->GetAngleFormula();
initNodeData.visibilityTrigger = label->GetVisibilityTrigger();
initNodeData.type = label->GetLabelType();
QScopedPointer<VPlaceLabelItem> label1(new VPlaceLabelItem(*label));