Alias field for tool Arc with length.
This commit is contained in:
parent
1246aba24d
commit
7542fc5dc2
|
@ -1359,6 +1359,9 @@ void VToolOptionsPropertyBrowser::ChangeDataToolArcWithLength(VPE::VProperty *pr
|
||||||
case 61: // AttrNotes
|
case 61: // AttrNotes
|
||||||
SetNotes<VToolArcWithLength>(property);
|
SetNotes<VToolArcWithLength>(property);
|
||||||
break;
|
break;
|
||||||
|
case 62: // AttrAlias
|
||||||
|
SetAlias<VToolArcWithLength>(property);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
qWarning()<<"Unknown property type. id = "<<id;
|
qWarning()<<"Unknown property type. id = "<<id;
|
||||||
break;
|
break;
|
||||||
|
@ -2491,6 +2494,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolArcWithLength(QGraphicsItem *it
|
||||||
AddPropertyFormula(tr("Radius:"), i->GetFormulaRadius(), AttrRadius);
|
AddPropertyFormula(tr("Radius:"), i->GetFormulaRadius(), AttrRadius);
|
||||||
AddPropertyFormula(tr("First angle:"), i->GetFormulaF1(), AttrAngle1);
|
AddPropertyFormula(tr("First angle:"), i->GetFormulaF1(), AttrAngle1);
|
||||||
AddPropertyFormula(tr("Length:"), i->GetFormulaLength(), AttrLength);
|
AddPropertyFormula(tr("Length:"), i->GetFormulaLength(), AttrLength);
|
||||||
|
AddPropertyAlias(i, tr("Alias:"));
|
||||||
AddPropertyCurvePenStyle(i, tr("Pen style:"), CurvePenStylesPics());
|
AddPropertyCurvePenStyle(i, tr("Pen style:"), CurvePenStylesPics());
|
||||||
AddPropertyLineColor(i, tr("Color:"), VAbstractTool::ColorsList(), AttrColor);
|
AddPropertyLineColor(i, tr("Color:"), VAbstractTool::ColorsList(), AttrColor);
|
||||||
AddPropertyApproximationScale(tr("Approximation scale:"), i->GetApproximationScale());
|
AddPropertyApproximationScale(tr("Approximation scale:"), i->GetApproximationScale());
|
||||||
|
@ -3088,6 +3092,8 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolArcWithLength()
|
||||||
{
|
{
|
||||||
auto *i = qgraphicsitem_cast<VToolArcWithLength *>(currentItem);
|
auto *i = qgraphicsitem_cast<VToolArcWithLength *>(currentItem);
|
||||||
|
|
||||||
|
idToProperty[AttrName]->setValue(i->name());
|
||||||
|
|
||||||
QVariant valueRadius;
|
QVariant valueRadius;
|
||||||
valueRadius.setValue(i->GetFormulaRadius());
|
valueRadius.setValue(i->GetFormulaRadius());
|
||||||
idToProperty[AttrRadius]->setValue(valueRadius);
|
idToProperty[AttrRadius]->setValue(valueRadius);
|
||||||
|
@ -3119,6 +3125,8 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolArcWithLength()
|
||||||
idToProperty[AttrAScale]->setValue(valueApproximationScale);
|
idToProperty[AttrAScale]->setValue(valueApproximationScale);
|
||||||
|
|
||||||
idToProperty[AttrNotes]->setValue(i->GetNotes());
|
idToProperty[AttrNotes]->setValue(i->GetNotes());
|
||||||
|
|
||||||
|
idToProperty[AttrAlias]->setValue(i->GetAliasSuffix());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -3182,6 +3182,7 @@ void VPattern::ParseToolArcWithLength(VMainGraphicsScene *scene, QDomElement &do
|
||||||
initData.color = GetParametrString(domElement, AttrColor, ColorBlack);
|
initData.color = GetParametrString(domElement, AttrColor, ColorBlack);
|
||||||
initData.penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine);
|
initData.penStyle = GetParametrString(domElement, AttrPenStyle, TypeLineLine);
|
||||||
initData.approximationScale = GetParametrDouble(domElement, AttrAScale, QChar('0'));
|
initData.approximationScale = GetParametrDouble(domElement, AttrAScale, QChar('0'));
|
||||||
|
initData.aliasSuffix = GetParametrEmptyString(domElement, AttrAlias);
|
||||||
|
|
||||||
VToolArcWithLength::Create(initData);
|
VToolArcWithLength::Create(initData);
|
||||||
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
||||||
|
|
|
@ -266,6 +266,12 @@ quint32 VContainer::AddGObject(const QSharedPointer<VGObject> &obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
uniqueNames[d->nspace].insert(obj->name());
|
uniqueNames[d->nspace].insert(obj->name());
|
||||||
|
|
||||||
|
if (not obj->GetAlias().isEmpty())
|
||||||
|
{
|
||||||
|
uniqueNames[d->nspace].insert(obj->GetAlias());
|
||||||
|
}
|
||||||
|
|
||||||
const quint32 id = getNextId();
|
const quint32 id = getNextId();
|
||||||
obj->setId(id);
|
obj->setId(id);
|
||||||
|
|
||||||
|
|
|
@ -403,6 +403,11 @@ void VContainer::UpdateGObject(quint32 id, const QSharedPointer<T> &obj)
|
||||||
SCASSERT(not obj.isNull())
|
SCASSERT(not obj.isNull())
|
||||||
UpdateObject(id, obj);
|
UpdateObject(id, obj);
|
||||||
uniqueNames[d->nspace].insert(obj->name());
|
uniqueNames[d->nspace].insert(obj->name());
|
||||||
|
|
||||||
|
if (not obj->GetAlias().isEmpty())
|
||||||
|
{
|
||||||
|
uniqueNames[d->nspace].insert(obj->GetAlias());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -123,7 +123,7 @@ DialogArc::DialogArc(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
connect(ui->pushButtonGrowLengthF1, &QPushButton::clicked, this, &DialogArc::DeployF1TextEdit);
|
connect(ui->pushButtonGrowLengthF1, &QPushButton::clicked, this, &DialogArc::DeployF1TextEdit);
|
||||||
connect(ui->pushButtonGrowLengthF2, &QPushButton::clicked, this, &DialogArc::DeployF2TextEdit);
|
connect(ui->pushButtonGrowLengthF2, &QPushButton::clicked, this, &DialogArc::DeployF2TextEdit);
|
||||||
|
|
||||||
connect(ui->lineEditAlias, &QLineEdit::textEdited, this, &DialogArc::GetAliasSuffix);
|
connect(ui->lineEditAlias, &QLineEdit::textEdited, this, &DialogArc::ValidateAlias);
|
||||||
|
|
||||||
vis = new VisToolArc(data);
|
vis = new VisToolArc(data);
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include "../vmisc/vcommonsettings.h"
|
#include "../vmisc/vcommonsettings.h"
|
||||||
#include "../../visualization/visualization.h"
|
#include "../../visualization/visualization.h"
|
||||||
#include "ui_dialogarcwithlength.h"
|
#include "ui_dialogarcwithlength.h"
|
||||||
|
#include "../vgeometry/varc.h"
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
DialogArcWithLength::DialogArcWithLength(const VContainer *data, quint32 toolId, QWidget *parent)
|
DialogArcWithLength::DialogArcWithLength(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
|
@ -115,6 +116,8 @@ DialogArcWithLength::DialogArcWithLength(const VContainer *data, quint32 toolId,
|
||||||
connect(ui->pushButtonGrowLengthF1, &QPushButton::clicked, this, &DialogArcWithLength::DeployF1TextEdit);
|
connect(ui->pushButtonGrowLengthF1, &QPushButton::clicked, this, &DialogArcWithLength::DeployF1TextEdit);
|
||||||
connect(ui->pushButtonGrowLengthArcLength, &QPushButton::clicked, this, &DialogArcWithLength::DeployLengthTextEdit);
|
connect(ui->pushButtonGrowLengthArcLength, &QPushButton::clicked, this, &DialogArcWithLength::DeployLengthTextEdit);
|
||||||
|
|
||||||
|
connect(ui->lineEditAlias, &QLineEdit::textEdited, this, &DialogArcWithLength::ValidateAlias);
|
||||||
|
|
||||||
vis = new VisToolArcWithLength(data);
|
vis = new VisToolArcWithLength(data);
|
||||||
|
|
||||||
ui->tabWidget->setCurrentIndex(0);
|
ui->tabWidget->setCurrentIndex(0);
|
||||||
|
@ -263,6 +266,19 @@ QString DialogArcWithLength::GetNotes() const
|
||||||
return ui->plainTextEditToolNotes->toPlainText();
|
return ui->plainTextEditToolNotes->toPlainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogArcWithLength::SetAliasSuffix(const QString &alias)
|
||||||
|
{
|
||||||
|
ui->lineEditAlias->setText(alias);
|
||||||
|
ValidateAlias();
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QString DialogArcWithLength::GetAliasSuffix() const
|
||||||
|
{
|
||||||
|
return ui->lineEditAlias->text();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogArcWithLength::ChosenObject(quint32 id, const SceneObject &type)
|
void DialogArcWithLength::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
{
|
{
|
||||||
|
@ -374,6 +390,25 @@ void DialogArcWithLength::closeEvent(QCloseEvent *event)
|
||||||
DialogTool::closeEvent(event);
|
DialogTool::closeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogArcWithLength::ValidateAlias()
|
||||||
|
{
|
||||||
|
VArc arc;
|
||||||
|
arc.SetAliasSuffix(GetAliasSuffix());
|
||||||
|
if (not GetAliasSuffix().isEmpty() && not data->IsUnique(arc.GetAlias()))
|
||||||
|
{
|
||||||
|
flagAlias = false;
|
||||||
|
ChangeColor(ui->labelAlias, errorColor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
flagAlias = true;
|
||||||
|
ChangeColor(ui->labelAlias, OkColor(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckState();
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogArcWithLength::Radius()
|
void DialogArcWithLength::Radius()
|
||||||
{
|
{
|
||||||
|
|
|
@ -74,6 +74,9 @@ public:
|
||||||
|
|
||||||
void SetNotes(const QString ¬es);
|
void SetNotes(const QString ¬es);
|
||||||
QString GetNotes() const;
|
QString GetNotes() const;
|
||||||
|
|
||||||
|
void SetAliasSuffix(const QString &alias);
|
||||||
|
QString GetAliasSuffix() const;
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
/**
|
/**
|
||||||
|
@ -96,6 +99,9 @@ protected:
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
virtual void closeEvent(QCloseEvent *event) override;
|
||||||
virtual bool IsValid() const final;
|
virtual bool IsValid() const final;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void ValidateAlias();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(DialogArcWithLength)
|
Q_DISABLE_COPY(DialogArcWithLength)
|
||||||
Ui::DialogArcWithLength *ui;
|
Ui::DialogArcWithLength *ui;
|
||||||
|
@ -108,6 +114,8 @@ private:
|
||||||
|
|
||||||
bool flagLength;
|
bool flagLength;
|
||||||
|
|
||||||
|
bool flagAlias{true};
|
||||||
|
|
||||||
/** @brief timerRadius timer of check formula of radius */
|
/** @brief timerRadius timer of check formula of radius */
|
||||||
QTimer *timerRadius;
|
QTimer *timerRadius;
|
||||||
|
|
||||||
|
@ -137,7 +145,7 @@ private:
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
inline bool DialogArcWithLength::IsValid() const
|
inline bool DialogArcWithLength::IsValid() const
|
||||||
{
|
{
|
||||||
return flagRadius && flagF1 && flagLength;
|
return flagRadius && flagF1 && flagLength && flagAlias;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // DIALOGARCWITHLENGTH_H
|
#endif // DIALOGARCWITHLENGTH_H
|
||||||
|
|
|
@ -651,6 +651,20 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="labelAlias">
|
||||||
|
<property name="text">
|
||||||
|
<string>Alias:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QLineEdit" name="lineEditAlias">
|
||||||
|
<property name="clearButtonEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|
|
@ -505,9 +505,19 @@ QString VAbstractSpline::GetAliasSuffix() const
|
||||||
void VAbstractSpline::SetAliasSuffix(const QString &alias)
|
void VAbstractSpline::SetAliasSuffix(const QString &alias)
|
||||||
{
|
{
|
||||||
QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(m_id);
|
QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(m_id);
|
||||||
|
|
||||||
|
const QString oldAliasSuffix = curve->GetAliasSuffix();
|
||||||
curve->SetAliasSuffix(alias);
|
curve->SetAliasSuffix(alias);
|
||||||
QSharedPointer<VGObject> obj = qSharedPointerCast<VGObject>(curve);
|
|
||||||
SaveOption(obj);
|
if (alias.isEmpty() || VAbstractTool::data.IsUnique(curve->GetAlias()))
|
||||||
|
{
|
||||||
|
QSharedPointer<VGObject> obj = qSharedPointerCast<VGObject>(curve);
|
||||||
|
SaveOption(obj);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
curve->SetAliasSuffix(oldAliasSuffix);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -84,6 +84,7 @@ void VToolArcWithLength::setDialog()
|
||||||
dialogTool->SetPenStyle(arc->GetPenStyle());
|
dialogTool->SetPenStyle(arc->GetPenStyle());
|
||||||
dialogTool->SetApproximationScale(arc->GetApproximationScale());
|
dialogTool->SetApproximationScale(arc->GetApproximationScale());
|
||||||
dialogTool->SetNotes(m_notes);
|
dialogTool->SetNotes(m_notes);
|
||||||
|
dialogTool->SetAliasSuffix(arc->GetAliasSuffix());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -108,6 +109,7 @@ VToolArcWithLength *VToolArcWithLength::Create(const QPointer<DialogTool> &dialo
|
||||||
initData.parse = Document::FullParse;
|
initData.parse = Document::FullParse;
|
||||||
initData.typeCreation = Source::FromGui;
|
initData.typeCreation = Source::FromGui;
|
||||||
initData.notes = dialogTool->GetNotes();
|
initData.notes = dialogTool->GetNotes();
|
||||||
|
initData.aliasSuffix = dialogTool->GetAliasSuffix();
|
||||||
|
|
||||||
VToolArcWithLength* point = Create(initData);
|
VToolArcWithLength* point = Create(initData);
|
||||||
if (point != nullptr)
|
if (point != nullptr)
|
||||||
|
@ -131,6 +133,7 @@ VToolArcWithLength *VToolArcWithLength::Create(VToolArcWithLengthInitData &initD
|
||||||
arc->SetColor(initData.color);
|
arc->SetColor(initData.color);
|
||||||
arc->SetPenStyle(initData.penStyle);
|
arc->SetPenStyle(initData.penStyle);
|
||||||
arc->SetApproximationScale(initData.approximationScale);
|
arc->SetApproximationScale(initData.approximationScale);
|
||||||
|
arc->SetAliasSuffix(initData.aliasSuffix);
|
||||||
|
|
||||||
if (initData.typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
|
@ -317,6 +320,8 @@ void VToolArcWithLength::SaveDialog(QDomElement &domElement, QList<quint32> &old
|
||||||
doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor());
|
doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor());
|
||||||
doc->SetAttribute(domElement, AttrPenStyle, dialogTool->GetPenStyle());
|
doc->SetAttribute(domElement, AttrPenStyle, dialogTool->GetPenStyle());
|
||||||
doc->SetAttribute(domElement, AttrAScale, dialogTool->GetApproximationScale());
|
doc->SetAttribute(domElement, AttrAScale, dialogTool->GetApproximationScale());
|
||||||
|
doc->SetAttributeOrRemoveIf(domElement, AttrAlias, dialogTool->GetAliasSuffix(),
|
||||||
|
dialogTool->GetAliasSuffix().isEmpty());
|
||||||
|
|
||||||
const QString notes = dialogTool->GetNotes();
|
const QString notes = dialogTool->GetNotes();
|
||||||
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
|
doc->SetAttributeOrRemoveIf(domElement, AttrNotes, notes, notes.isEmpty());
|
||||||
|
@ -377,6 +382,6 @@ QString VToolArcWithLength::MakeToolTip() const
|
||||||
.arg(arc->GetStartAngle())
|
.arg(arc->GetStartAngle())
|
||||||
.arg(tr("End angle"))
|
.arg(tr("End angle"))
|
||||||
.arg(arc->GetEndAngle())
|
.arg(arc->GetEndAngle())
|
||||||
.arg(tr("Label"), arc->name());
|
.arg(tr("Label"), arc->ObjectName());
|
||||||
return toolTip;
|
return toolTip;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user