Alias field for tool Cut Spline.
This commit is contained in:
parent
2574ecda0e
commit
abff41813a
|
@ -1544,6 +1544,12 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCutSpline(VPE::VProperty *proper
|
|||
case 61: // AttrNotes
|
||||
SetNotes<VToolCutSpline>(property);
|
||||
break;
|
||||
case 63: // AttrAlias1
|
||||
SetAlias1<VToolCutSpline>(property);
|
||||
break;
|
||||
case 64: // AttrAlias2
|
||||
SetAlias2<VToolCutSpline>(property);
|
||||
break;
|
||||
default:
|
||||
qWarning()<<"Unknown property type. id = "<<id;
|
||||
break;
|
||||
|
@ -2640,6 +2646,8 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCutSpline(QGraphicsItem *item)
|
|||
|
||||
AddPropertyObjectName(i, tr("Point label:"));
|
||||
AddPropertyParentPointName(i->CurveName(), tr("Curve:"), AttrCurve);
|
||||
AddPropertyAlias1(i, tr("Alias1:"));
|
||||
AddPropertyAlias2(i, tr("Alias2:"));
|
||||
AddPropertyFormula(tr("Length:"), i->GetFormulaLength(), AttrLength);
|
||||
AddPropertyText(tr("Notes:"), i->GetNotes(), AttrNotes);
|
||||
}
|
||||
|
@ -3321,6 +3329,9 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCutSpline()
|
|||
idToProperty[AttrCurve]->setValue(valueCurve);
|
||||
|
||||
idToProperty[AttrNotes]->setValue(i->GetNotes());
|
||||
|
||||
idToProperty[AttrAlias1]->setValue(i->GetAliasSuffix1());
|
||||
idToProperty[AttrAlias2]->setValue(i->GetAliasSuffix2());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -2041,6 +2041,8 @@ void VPattern::ParseToolCutSpline(VMainGraphicsScene *scene, QDomElement &domEle
|
|||
initData.formula = GetParametrString(domElement, AttrLength, QChar('0'));
|
||||
const QString f = initData.formula;//need for saving fixed formula;
|
||||
initData.baseCurveId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, NULL_ID_STR);
|
||||
initData.aliasSuffix1 = GetParametrEmptyString(domElement, AttrAlias1);
|
||||
initData.aliasSuffix2 = GetParametrEmptyString(domElement, AttrAlias2);
|
||||
|
||||
VToolCutSpline::Create(initData);
|
||||
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
||||
|
|
|
@ -92,6 +92,9 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, quint32 toolId, QWidget
|
|||
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSpline::DeployFormulaTextEdit);
|
||||
connect(ui->comboBoxSpline, &QComboBox::currentTextChanged, this, &DialogCutSpline::SplineChanged);
|
||||
|
||||
connect(ui->lineEditAlias1, &QLineEdit::textEdited, this, &DialogCutSpline::ValidateAlias);
|
||||
connect(ui->lineEditAlias2, &QLineEdit::textEdited, this, &DialogCutSpline::ValidateAlias);
|
||||
|
||||
vis = new VisToolCutSpline(data);
|
||||
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
|
@ -208,6 +211,55 @@ void DialogCutSpline::SplineChanged()
|
|||
CurrentCurveLength(getSplineId(), const_cast<VContainer *> (data));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogCutSpline::ValidateAlias()
|
||||
{
|
||||
VSpline spl1;
|
||||
spl1.SetAliasSuffix(GetAliasSuffix1());
|
||||
if (not GetAliasSuffix1().isEmpty() && not data->IsUnique(spl1.GetAlias()))
|
||||
{
|
||||
flagAlias1 = false;
|
||||
ChangeColor(ui->labelAlias1, errorColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
flagAlias1 = true;
|
||||
ChangeColor(ui->labelAlias1, OkColor(this));
|
||||
}
|
||||
|
||||
VSpline spl2;
|
||||
spl2.SetAliasSuffix(GetAliasSuffix2());
|
||||
if (not GetAliasSuffix2().isEmpty() && not data->IsUnique(spl2.GetAlias()))
|
||||
{
|
||||
flagAlias2 = false;
|
||||
ChangeColor(ui->labelAlias2, errorColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
flagAlias2 = true;
|
||||
ChangeColor(ui->labelAlias2, OkColor(this));
|
||||
}
|
||||
|
||||
if (spl1.GetAlias() == spl2.GetAlias())
|
||||
{
|
||||
flagAlias1 = false;
|
||||
ChangeColor(ui->labelAlias1, errorColor);
|
||||
|
||||
flagAlias2 = false;
|
||||
ChangeColor(ui->labelAlias2, errorColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
flagAlias1 = true;
|
||||
ChangeColor(ui->labelAlias1, OkColor(this));
|
||||
|
||||
flagAlias2 = true;
|
||||
ChangeColor(ui->labelAlias2, OkColor(this));
|
||||
}
|
||||
|
||||
CheckState();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogCutSpline::DeployFormulaTextEdit()
|
||||
{
|
||||
|
@ -279,3 +331,29 @@ QString DialogCutSpline::GetNotes() const
|
|||
{
|
||||
return ui->plainTextEditToolNotes->toPlainText();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogCutSpline::SetAliasSuffix1(const QString &alias)
|
||||
{
|
||||
ui->lineEditAlias1->setText(alias);
|
||||
ValidateAlias();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogCutSpline::GetAliasSuffix1() const
|
||||
{
|
||||
return ui->lineEditAlias1->text();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogCutSpline::SetAliasSuffix2(const QString &alias)
|
||||
{
|
||||
ui->lineEditAlias2->setText(alias);
|
||||
ValidateAlias();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogCutSpline::GetAliasSuffix2() const
|
||||
{
|
||||
return ui->lineEditAlias2->text();
|
||||
}
|
||||
|
|
|
@ -64,6 +64,12 @@ public:
|
|||
|
||||
void SetNotes(const QString ¬es);
|
||||
QString GetNotes() const;
|
||||
|
||||
void SetAliasSuffix1(const QString &alias);
|
||||
QString GetAliasSuffix1() const;
|
||||
|
||||
void SetAliasSuffix2(const QString &alias);
|
||||
QString GetAliasSuffix2() const;
|
||||
public slots:
|
||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||
/**
|
||||
|
@ -82,6 +88,7 @@ protected:
|
|||
virtual bool IsValid() const final;
|
||||
private slots:
|
||||
void SplineChanged();
|
||||
void ValidateAlias();
|
||||
private:
|
||||
Q_DISABLE_COPY(DialogCutSpline)
|
||||
|
||||
|
@ -100,12 +107,14 @@ private:
|
|||
|
||||
bool flagFormula;
|
||||
bool flagName;
|
||||
bool flagAlias1{true};
|
||||
bool flagAlias2{true};
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline bool DialogCutSpline::IsValid() const
|
||||
{
|
||||
return flagFormula && flagName;
|
||||
return flagFormula && flagName && flagAlias1 && flagAlias2;
|
||||
}
|
||||
|
||||
#endif // DIALOGCUTSPLINE_H
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>324</width>
|
||||
<height>240</height>
|
||||
<width>527</width>
|
||||
<height>379</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -255,6 +255,26 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelAlias1">
|
||||
<property name="text">
|
||||
<string>Alias1:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lineEditAlias1"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="labelAlias2">
|
||||
<property name="text">
|
||||
<string>Alias2:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="lineEditAlias2"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
|
|
@ -85,6 +85,8 @@ void VToolCutSpline::setDialog()
|
|||
dialogTool->setSplineId(baseCurveId);
|
||||
dialogTool->SetPointName(point->name());
|
||||
dialogTool->SetNotes(m_notes);
|
||||
dialogTool->SetAliasSuffix1(m_aliasSuffix1);
|
||||
dialogTool->SetAliasSuffix2(m_aliasSuffix2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -112,6 +114,8 @@ VToolCutSpline* VToolCutSpline::Create(const QPointer<DialogTool> &dialog, VMain
|
|||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
initData.notes = dialogTool->GetNotes();
|
||||
initData.aliasSuffix1 = dialogTool->GetAliasSuffix1();
|
||||
initData.aliasSuffix2 = dialogTool->GetAliasSuffix2();
|
||||
|
||||
VToolCutSpline* point = Create(initData);
|
||||
if (point != nullptr)
|
||||
|
@ -147,11 +151,17 @@ VToolCutSpline* VToolCutSpline::Create(VToolCutInitData &initData)
|
|||
auto spline1 = QSharedPointer<VAbstractBezier>(new VSpline(spl->GetP1(), spl1p2, spl1p3, *p));
|
||||
auto spline2 = QSharedPointer<VAbstractBezier>(new VSpline(*p, spl2p2, spl2p3, spl->GetP4()));
|
||||
|
||||
spline1->SetAliasSuffix(initData.aliasSuffix1);
|
||||
spline2->SetAliasSuffix(initData.aliasSuffix2);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
initData.data->AddSpline(spline1, NULL_ID, initData.id);
|
||||
initData.data->AddSpline(spline2, NULL_ID, initData.id);
|
||||
|
||||
initData.data->RegisterUniqueName(spline1);
|
||||
initData.data->RegisterUniqueName(spline2);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -159,6 +169,9 @@ VToolCutSpline* VToolCutSpline::Create(VToolCutInitData &initData)
|
|||
initData.data->AddSpline(spline1, NULL_ID, initData.id);
|
||||
initData.data->AddSpline(spline2, NULL_ID, initData.id);
|
||||
|
||||
initData.data->RegisterUniqueName(spline1);
|
||||
initData.data->RegisterUniqueName(spline2);
|
||||
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
|
@ -217,6 +230,10 @@ void VToolCutSpline::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepe
|
|||
doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName());
|
||||
doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
|
||||
doc->SetAttribute(domElement, AttrSpline, QString().setNum(dialogTool->getSplineId()));
|
||||
doc->SetAttributeOrRemoveIf(domElement, AttrAlias1, dialogTool->GetAliasSuffix1(),
|
||||
dialogTool->GetAliasSuffix1().isEmpty());
|
||||
doc->SetAttributeOrRemoveIf(domElement, AttrAlias2, dialogTool->GetAliasSuffix2(),
|
||||
dialogTool->GetAliasSuffix2().isEmpty());
|
||||
|
||||
const QString notes = dialogTool->GetNotes();
|
||||
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
|
||||
|
@ -286,8 +303,8 @@ QString VToolCutSpline::MakeToolTip() const
|
|||
.arg(qApp->fromPixel(spline1.GetLength()))
|
||||
.arg(UnitsToStr(qApp->patternUnits(), true), curveStr + QLatin1String("2 ") + lengthStr)
|
||||
.arg(qApp->fromPixel(spline2.GetLength()))
|
||||
.arg(curveStr + QLatin1String(" 1") + tr("label"), spline1.name(),
|
||||
curveStr + QLatin1String(" 2") + tr("label"), spline2.name());
|
||||
.arg(curveStr + QLatin1String(" 1") + tr("label"), spline1.ObjectName(),
|
||||
curveStr + QLatin1String(" 2") + tr("label"), spline2.ObjectName());
|
||||
|
||||
return toolTip;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ class VToolCutSpline : public VToolCut
|
|||
Q_OBJECT
|
||||
public:
|
||||
virtual void setDialog() override;
|
||||
static VToolCutSpline *Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
static VToolCutSpline *Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data);
|
||||
static VToolCutSpline *Create(VToolCutInitData &initData);
|
||||
static const QString ToolType;
|
||||
|
@ -71,7 +71,7 @@ protected:
|
|||
private:
|
||||
Q_DISABLE_COPY(VToolCutSpline)
|
||||
|
||||
VToolCutSpline(const VToolCutInitData &initData, QGraphicsItem * parent = nullptr);
|
||||
explicit VToolCutSpline(const VToolCutInitData &initData, QGraphicsItem * parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLCUTSPLINE_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user