Alias field for tool Cut Spline Path.
This commit is contained in:
parent
abff41813a
commit
3e682b180c
|
@ -1576,6 +1576,12 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCutSplinePath(VPE::VProperty *pr
|
|||
case 61: // AttrNotes
|
||||
SetNotes<VToolCutSplinePath>(property);
|
||||
break;
|
||||
case 63: // AttrAlias1
|
||||
SetAlias1<VToolCutSplinePath>(property);
|
||||
break;
|
||||
case 64: // AttrAlias2
|
||||
SetAlias2<VToolCutSplinePath>(property);
|
||||
break;
|
||||
default:
|
||||
qWarning()<<"Unknown property type. id = "<<id;
|
||||
break;
|
||||
|
@ -2661,6 +2667,8 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCutSplinePath(QGraphicsItem *it
|
|||
|
||||
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);
|
||||
}
|
||||
|
@ -3350,6 +3358,9 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCutSplinePath()
|
|||
idToProperty[AttrCurve]->setValue(valueCurve);
|
||||
|
||||
idToProperty[AttrNotes]->setValue(i->GetNotes());
|
||||
|
||||
idToProperty[AttrAlias1]->setValue(i->GetAliasSuffix1());
|
||||
idToProperty[AttrAlias2]->setValue(i->GetAliasSuffix2());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -2086,6 +2086,8 @@ void VPattern::ParseToolCutSplinePath(VMainGraphicsScene *scene, QDomElement &do
|
|||
initData.formula = GetParametrString(domElement, AttrLength, QChar('0'));
|
||||
const QString f = initData.formula;//need for saving fixed formula;
|
||||
initData.baseCurveId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, NULL_ID_STR);
|
||||
initData.aliasSuffix1 = GetParametrEmptyString(domElement, AttrAlias1);
|
||||
initData.aliasSuffix2 = GetParametrEmptyString(domElement, AttrAlias2);
|
||||
|
||||
VToolCutSplinePath::Create(initData);
|
||||
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
||||
|
|
|
@ -160,6 +160,8 @@
|
|||
<xs:attribute name="showLabel1" type="xs:boolean"/>
|
||||
<xs:attribute name="showLabel2" type="xs:boolean"/>
|
||||
<xs:attribute name="notes" type="xs:string"/>
|
||||
<xs:attribute name="alias1" type="xs:string"/>
|
||||
<xs:attribute name="alias2" type="xs:string"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="line" minOccurs="0" maxOccurs="unbounded">
|
||||
|
|
|
@ -241,6 +241,14 @@ quint32 VContainer::GetPieceForPiecePath(quint32 id) const
|
|||
return NULL_ID;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VContainer::RegisterUniqueName(VGObject *obj)
|
||||
{
|
||||
SCASSERT(obj != nullptr)
|
||||
QSharedPointer<VGObject> pointer(obj);
|
||||
RegisterUniqueName(pointer);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VContainer::RegisterUniqueName(const QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
|
|
|
@ -151,6 +151,7 @@ public:
|
|||
void UpdateId(quint32 newId) const;
|
||||
static void UpdateId(quint32 newId, const QString &nspace);
|
||||
|
||||
void RegisterUniqueName(VGObject *obj);
|
||||
void RegisterUniqueName(const QSharedPointer<VGObject> &obj);
|
||||
|
||||
quint32 AddGObject(VGObject *obj);
|
||||
|
|
|
@ -92,6 +92,9 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, quint32 toolId,
|
|||
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSplinePath::DeployFormulaTextEdit);
|
||||
connect(ui->comboBoxSplinePath, &QComboBox::currentTextChanged, this, &DialogCutSplinePath::SplinePathChanged);
|
||||
|
||||
connect(ui->lineEditAlias1, &QLineEdit::textEdited, this, &DialogCutSplinePath::ValidateAlias);
|
||||
connect(ui->lineEditAlias2, &QLineEdit::textEdited, this, &DialogCutSplinePath::ValidateAlias);
|
||||
|
||||
vis = new VisToolCutSplinePath(data);
|
||||
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
|
@ -208,6 +211,55 @@ void DialogCutSplinePath::SplinePathChanged()
|
|||
CurrentCurveLength(getSplinePathId(), const_cast<VContainer *> (data));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogCutSplinePath::ValidateAlias()
|
||||
{
|
||||
VSplinePath path1;
|
||||
path1.SetAliasSuffix(GetAliasSuffix1());
|
||||
if (not GetAliasSuffix1().isEmpty() && not data->IsUnique(path1.GetAlias()))
|
||||
{
|
||||
flagAlias1 = false;
|
||||
ChangeColor(ui->labelAlias1, errorColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
flagAlias1 = true;
|
||||
ChangeColor(ui->labelAlias1, OkColor(this));
|
||||
}
|
||||
|
||||
VSplinePath path2;
|
||||
path2.SetAliasSuffix(GetAliasSuffix2());
|
||||
if (not GetAliasSuffix2().isEmpty() && not data->IsUnique(path2.GetAlias()))
|
||||
{
|
||||
flagAlias2 = false;
|
||||
ChangeColor(ui->labelAlias2, errorColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
flagAlias2 = true;
|
||||
ChangeColor(ui->labelAlias2, OkColor(this));
|
||||
}
|
||||
|
||||
if (path1.GetAlias() == path2.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 DialogCutSplinePath::DeployFormulaTextEdit()
|
||||
{
|
||||
|
@ -279,3 +331,29 @@ QString DialogCutSplinePath::GetNotes() const
|
|||
{
|
||||
return ui->plainTextEditToolNotes->toPlainText();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogCutSplinePath::SetAliasSuffix1(const QString &alias)
|
||||
{
|
||||
ui->lineEditAlias1->setText(alias);
|
||||
ValidateAlias();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogCutSplinePath::GetAliasSuffix1() const
|
||||
{
|
||||
return ui->lineEditAlias1->text();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogCutSplinePath::SetAliasSuffix2(const QString &alias)
|
||||
{
|
||||
ui->lineEditAlias2->setText(alias);
|
||||
ValidateAlias();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogCutSplinePath::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 SplinePathChanged();
|
||||
void ValidateAlias();
|
||||
private:
|
||||
Q_DISABLE_COPY(DialogCutSplinePath)
|
||||
|
||||
|
@ -99,12 +106,14 @@ private:
|
|||
|
||||
bool flagFormula;
|
||||
bool flagName;
|
||||
bool flagAlias1{true};
|
||||
bool flagAlias2{true};
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline bool DialogCutSplinePath::IsValid() const
|
||||
{
|
||||
return flagFormula;
|
||||
return flagFormula && flagAlias1 && flagAlias2;
|
||||
}
|
||||
|
||||
#endif // DIALOGCUTSPLINEPATH_H
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>326</width>
|
||||
<height>245</height>
|
||||
<width>483</width>
|
||||
<height>373</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -255,6 +255,34 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="labelAlias1">
|
||||
<property name="text">
|
||||
<string>Alias1:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="labelAlias2">
|
||||
<property name="text">
|
||||
<string>Alias2:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lineEditAlias1">
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="lineEditAlias2">
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
|
|
@ -88,6 +88,8 @@ void VToolCutSplinePath::setDialog()
|
|||
dialogTool->setSplinePathId(baseCurveId);
|
||||
dialogTool->SetPointName(point->name());
|
||||
dialogTool->SetNotes(m_notes);
|
||||
dialogTool->SetAliasSuffix1(m_aliasSuffix1);
|
||||
dialogTool->SetAliasSuffix2(m_aliasSuffix2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -115,6 +117,8 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const QPointer<DialogTool> &dialo
|
|||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
initData.notes = dialogTool->GetNotes();
|
||||
initData.aliasSuffix1 = dialogTool->GetAliasSuffix1();
|
||||
initData.aliasSuffix2 = dialogTool->GetAliasSuffix2();
|
||||
|
||||
VToolCutSplinePath* point = Create(initData);
|
||||
if (point != nullptr)
|
||||
|
@ -154,12 +158,18 @@ VToolCutSplinePath* VToolCutSplinePath::Create(VToolCutInitData &initData)
|
|||
p->setMy(initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
splPath1->SetAliasSuffix(initData.aliasSuffix1);
|
||||
splPath2->SetAliasSuffix(initData.aliasSuffix2);
|
||||
|
||||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
|
||||
initData.data->AddSpline(QSharedPointer<VAbstractBezier>(splPath1), NULL_ID, initData.id);
|
||||
initData.data->AddSpline(QSharedPointer<VAbstractBezier>(splPath2), NULL_ID, initData.id);
|
||||
|
||||
initData.data->RegisterUniqueName(splPath1);
|
||||
initData.data->RegisterUniqueName(splPath2);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -168,6 +178,9 @@ VToolCutSplinePath* VToolCutSplinePath::Create(VToolCutInitData &initData)
|
|||
initData.data->AddSpline(QSharedPointer<VAbstractBezier>(splPath1), NULL_ID, initData.id);
|
||||
initData.data->AddSpline(QSharedPointer<VAbstractBezier>(splPath2), NULL_ID, initData.id);
|
||||
|
||||
initData.data->RegisterUniqueName(splPath1);
|
||||
initData.data->RegisterUniqueName(splPath2);
|
||||
|
||||
if (initData.parse != Document::FullParse)
|
||||
{
|
||||
initData.doc->UpdateToolData(initData.id, initData.data);
|
||||
|
@ -308,6 +321,10 @@ void VToolCutSplinePath::SaveDialog(QDomElement &domElement, QList<quint32> &old
|
|||
doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName());
|
||||
doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
|
||||
doc->SetAttribute(domElement, AttrSplinePath, QString().setNum(dialogTool->getSplinePathId()));
|
||||
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());
|
||||
|
@ -376,8 +393,8 @@ QString VToolCutSplinePath::MakeToolTip() const
|
|||
.arg(qApp->fromPixel(splPath1->GetLength()))
|
||||
.arg(UnitsToStr(qApp->patternUnits(), true), curveStr + QLatin1String("2 ") + lengthStr)
|
||||
.arg(qApp->fromPixel(splPath2->GetLength()))
|
||||
.arg(curveStr + QLatin1String(" 1") + tr("label"), splPath1->name(),
|
||||
curveStr + QLatin1String(" 2") + tr("label"), splPath2->name());
|
||||
.arg(curveStr + QLatin1String(" 1") + tr("label"), splPath1->ObjectName(),
|
||||
curveStr + QLatin1String(" 2") + tr("label"), splPath2->ObjectName());
|
||||
|
||||
delete splPath1;
|
||||
delete splPath2;
|
||||
|
|
Loading…
Reference in New Issue
Block a user