Alias field for tool Cut Arc.
This commit is contained in:
parent
b1f9327393
commit
2574ecda0e
|
@ -544,6 +544,26 @@ void VToolOptionsPropertyBrowser::AddPropertyAlias(Tool *i, const QString &prope
|
|||
AddProperty(itemName, AttrAlias);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template<class Tool>
|
||||
void VToolOptionsPropertyBrowser::AddPropertyAlias1(Tool *i, const QString &propertyName)
|
||||
{
|
||||
auto *itemName = new VPE::VStringProperty(propertyName);
|
||||
itemName->setClearButtonEnable(true);
|
||||
itemName->setValue(qApp->TrVars()->VarToUser(i->GetAliasSuffix1()));
|
||||
AddProperty(itemName, AttrAlias1);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template<class Tool>
|
||||
void VToolOptionsPropertyBrowser::AddPropertyAlias2(Tool *i, const QString &propertyName)
|
||||
{
|
||||
auto *itemName = new VPE::VStringProperty(propertyName);
|
||||
itemName->setClearButtonEnable(true);
|
||||
itemName->setValue(qApp->TrVars()->VarToUser(i->GetAliasSuffix2()));
|
||||
AddProperty(itemName, AttrAlias2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template<class Tool>
|
||||
void VToolOptionsPropertyBrowser::AddPropertyPointName1(Tool *i, const QString &propertyName)
|
||||
|
@ -967,6 +987,46 @@ void VToolOptionsPropertyBrowser::SetAlias(VPE::VProperty *property)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template<class Tool>
|
||||
void VToolOptionsPropertyBrowser::SetAlias1(VPE::VProperty *property)
|
||||
{
|
||||
if (auto *i = qgraphicsitem_cast<Tool *>(currentItem))
|
||||
{
|
||||
QString notes = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toString();
|
||||
if (notes == i->GetAliasSuffix1())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
i->SetAliasSuffix1(notes);
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning()<<"Can't cast item";
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template<class Tool>
|
||||
void VToolOptionsPropertyBrowser::SetAlias2(VPE::VProperty *property)
|
||||
{
|
||||
if (auto *i = qgraphicsitem_cast<Tool *>(currentItem))
|
||||
{
|
||||
QString notes = property->data(VPE::VProperty::DPC_Data, Qt::DisplayRole).toString();
|
||||
if (notes == i->GetAliasSuffix2())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
i->SetAliasSuffix2(notes);
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning()<<"Can't cast item";
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
template<class Tool>
|
||||
void VToolOptionsPropertyBrowser::SetLineType(VPE::VProperty *property)
|
||||
|
@ -1452,6 +1512,12 @@ void VToolOptionsPropertyBrowser::ChangeDataToolCutArc(VPE::VProperty *property)
|
|||
case 61: // AttrNotes
|
||||
SetNotes<VToolCutArc>(property);
|
||||
break;
|
||||
case 63: // AttrAlias1
|
||||
SetAlias1<VToolCutArc>(property);
|
||||
break;
|
||||
case 64: // AttrAlias2
|
||||
SetAlias2<VToolCutArc>(property);
|
||||
break;
|
||||
default:
|
||||
qWarning()<<"Unknown property type. id = "<<id;
|
||||
break;
|
||||
|
@ -2559,6 +2625,8 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCutArc(QGraphicsItem *item)
|
|||
|
||||
AddPropertyObjectName(i, tr("Point label:"));
|
||||
AddPropertyParentPointName(i->CurveName(), tr("Arc:"), AttrArc);
|
||||
AddPropertyAlias1(i, tr("Alias1:"));
|
||||
AddPropertyAlias2(i, tr("Alias2:"));
|
||||
AddPropertyFormula(tr("Length:"), i->GetFormulaLength(), AttrLength);
|
||||
AddPropertyText(tr("Notes:"), i->GetNotes(), AttrNotes);
|
||||
}
|
||||
|
@ -3232,6 +3300,9 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCutArc()
|
|||
idToProperty[AttrArc]->setValue(valueArc);
|
||||
|
||||
idToProperty[AttrNotes]->setValue(i->GetNotes());
|
||||
|
||||
idToProperty[AttrAlias1]->setValue(i->GetAliasSuffix1());
|
||||
idToProperty[AttrAlias2]->setValue(i->GetAliasSuffix2());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -3995,7 +4066,9 @@ QStringList VToolOptionsPropertyBrowser::PropertiesList() const
|
|||
AttrPenStyle, /* 59 */
|
||||
AttrAScale, /* 60 */
|
||||
AttrNotes, /* 61 */
|
||||
AttrAlias /* 62 */
|
||||
AttrAlias, /* 62 */
|
||||
AttrAlias1, /* 63 */
|
||||
AttrAlias2 /* 64 */
|
||||
};
|
||||
return attr;
|
||||
}
|
||||
|
|
|
@ -99,6 +99,12 @@ private:
|
|||
template<class Tool>
|
||||
void SetAlias(VPE::VProperty *property);
|
||||
|
||||
template<class Tool>
|
||||
void SetAlias1(VPE::VProperty *property);
|
||||
|
||||
template<class Tool>
|
||||
void SetAlias2(VPE::VProperty *property);
|
||||
|
||||
template<class Tool>
|
||||
void SetLineType(VPE::VProperty *property);
|
||||
|
||||
|
@ -135,6 +141,12 @@ private:
|
|||
template<class Tool>
|
||||
void AddPropertyAlias(Tool *i, const QString &propertyName);
|
||||
|
||||
template<class Tool>
|
||||
void AddPropertyAlias1(Tool *i, const QString &propertyName);
|
||||
|
||||
template<class Tool>
|
||||
void AddPropertyAlias2(Tool *i, const QString &propertyName);
|
||||
|
||||
template<class Tool>
|
||||
void AddPropertyPointName1(Tool *i, const QString &propertyName);
|
||||
|
||||
|
|
|
@ -2030,7 +2030,7 @@ void VPattern::ParseToolCutSpline(VMainGraphicsScene *scene, QDomElement &domEle
|
|||
|
||||
try
|
||||
{
|
||||
VToolCutSplineInitData initData;
|
||||
VToolCutInitData initData;
|
||||
initData.scene = scene;
|
||||
initData.doc = this;
|
||||
initData.data = data;
|
||||
|
@ -2040,7 +2040,7 @@ void VPattern::ParseToolCutSpline(VMainGraphicsScene *scene, QDomElement &domEle
|
|||
PointsCommonAttributes(domElement, initData);
|
||||
initData.formula = GetParametrString(domElement, AttrLength, QChar('0'));
|
||||
const QString f = initData.formula;//need for saving fixed formula;
|
||||
initData.splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, NULL_ID_STR);
|
||||
initData.baseCurveId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, NULL_ID_STR);
|
||||
|
||||
VToolCutSpline::Create(initData);
|
||||
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
||||
|
@ -2073,7 +2073,7 @@ void VPattern::ParseToolCutSplinePath(VMainGraphicsScene *scene, QDomElement &do
|
|||
|
||||
try
|
||||
{
|
||||
VToolCutSplinePathInitData initData;
|
||||
VToolCutInitData initData;
|
||||
initData.scene = scene;
|
||||
initData.doc = this;
|
||||
initData.data = data;
|
||||
|
@ -2083,7 +2083,7 @@ void VPattern::ParseToolCutSplinePath(VMainGraphicsScene *scene, QDomElement &do
|
|||
PointsCommonAttributes(domElement, initData);
|
||||
initData.formula = GetParametrString(domElement, AttrLength, QChar('0'));
|
||||
const QString f = initData.formula;//need for saving fixed formula;
|
||||
initData.splinePathId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, NULL_ID_STR);
|
||||
initData.baseCurveId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, NULL_ID_STR);
|
||||
|
||||
VToolCutSplinePath::Create(initData);
|
||||
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
||||
|
@ -2116,7 +2116,7 @@ void VPattern::ParseToolCutArc(VMainGraphicsScene *scene, QDomElement &domElemen
|
|||
|
||||
try
|
||||
{
|
||||
VToolCutArcInitData initData;
|
||||
VToolCutInitData initData;
|
||||
initData.scene = scene;
|
||||
initData.doc = this;
|
||||
initData.data = data;
|
||||
|
@ -2126,7 +2126,9 @@ void VPattern::ParseToolCutArc(VMainGraphicsScene *scene, QDomElement &domElemen
|
|||
PointsCommonAttributes(domElement, initData);
|
||||
initData.formula = GetParametrString(domElement, AttrLength, QChar('0'));
|
||||
const QString f = initData.formula;//need for saving fixed formula;
|
||||
initData.arcId = GetParametrUInt(domElement, AttrArc, NULL_ID_STR);
|
||||
initData.baseCurveId = GetParametrUInt(domElement, AttrArc, NULL_ID_STR);
|
||||
initData.aliasSuffix1 = GetParametrEmptyString(domElement, AttrAlias1);
|
||||
initData.aliasSuffix2 = GetParametrEmptyString(domElement, AttrAlias2);
|
||||
|
||||
VToolCutArc::Create(initData);
|
||||
//Rewrite attribute formula. Need for situation when we have wrong formula.
|
||||
|
|
|
@ -135,6 +135,8 @@ const QString AttrFirstToCountour = QStringLiteral("firstToCountour");
|
|||
const QString AttrLastToCountour = QStringLiteral("lastToCountour");
|
||||
const QString AttrNotes = QStringLiteral("notes");
|
||||
const QString AttrAlias = QStringLiteral("alias");
|
||||
const QString AttrAlias1 = QStringLiteral("alias1");
|
||||
const QString AttrAlias2 = QStringLiteral("alias2");
|
||||
|
||||
const QString TypeLineNone = QStringLiteral("none");
|
||||
const QString TypeLineLine = QStringLiteral("hair");
|
||||
|
|
|
@ -153,6 +153,8 @@ extern const QString AttrFirstToCountour;
|
|||
extern const QString AttrLastToCountour;
|
||||
extern const QString AttrNotes;
|
||||
extern const QString AttrAlias;
|
||||
extern const QString AttrAlias1;
|
||||
extern const QString AttrAlias2;
|
||||
|
||||
extern const QString TypeLineNone;
|
||||
extern const QString TypeLineLine;
|
||||
|
|
|
@ -241,6 +241,19 @@ quint32 VContainer::GetPieceForPiecePath(quint32 id) const
|
|||
return NULL_ID;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VContainer::RegisterUniqueName(const QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
SCASSERT(not obj.isNull())
|
||||
|
||||
uniqueNames[d->nspace].insert(obj->name());
|
||||
|
||||
if (not obj->GetAlias().isEmpty())
|
||||
{
|
||||
uniqueNames[d->nspace].insert(obj->GetAlias());
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief AddGObject add new GObject to container
|
||||
|
@ -265,12 +278,7 @@ quint32 VContainer::AddGObject(const QSharedPointer<VGObject> &obj)
|
|||
return NULL_ID;
|
||||
}
|
||||
|
||||
uniqueNames[d->nspace].insert(obj->name());
|
||||
|
||||
if (not obj->GetAlias().isEmpty())
|
||||
{
|
||||
uniqueNames[d->nspace].insert(obj->GetAlias());
|
||||
}
|
||||
RegisterUniqueName(obj);
|
||||
|
||||
const quint32 id = getNextId();
|
||||
obj->setId(id);
|
||||
|
|
|
@ -151,6 +151,8 @@ public:
|
|||
void UpdateId(quint32 newId) const;
|
||||
static void UpdateId(quint32 newId, const QString &nspace);
|
||||
|
||||
void RegisterUniqueName(const QSharedPointer<VGObject> &obj);
|
||||
|
||||
quint32 AddGObject(VGObject *obj);
|
||||
quint32 AddGObject(const QSharedPointer<VGObject> &obj);
|
||||
quint32 AddPiece(const VPiece &detail);
|
||||
|
@ -402,12 +404,7 @@ void VContainer::UpdateGObject(quint32 id, const QSharedPointer<T> &obj)
|
|||
{
|
||||
SCASSERT(not obj.isNull())
|
||||
UpdateObject(id, obj);
|
||||
uniqueNames[d->nspace].insert(obj->name());
|
||||
|
||||
if (not obj->GetAlias().isEmpty())
|
||||
{
|
||||
uniqueNames[d->nspace].insert(obj->GetAlias());
|
||||
}
|
||||
RegisterUniqueName(obj);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -93,6 +93,9 @@ DialogCutArc::DialogCutArc(const VContainer *data, quint32 toolId, QWidget *pare
|
|||
|
||||
connect(ui->comboBoxArc, &QComboBox::currentTextChanged, this, &DialogCutArc::ArcChanged);
|
||||
|
||||
connect(ui->lineEditAlias1, &QLineEdit::textEdited, this, &DialogCutArc::ValidateAlias);
|
||||
connect(ui->lineEditAlias2, &QLineEdit::textEdited, this, &DialogCutArc::ValidateAlias);
|
||||
|
||||
vis = new VisToolCutArc(data);
|
||||
|
||||
ui->tabWidget->setCurrentIndex(0);
|
||||
|
@ -201,6 +204,55 @@ void DialogCutArc::ArcChanged()
|
|||
CurrentCurveLength(getArcId(), const_cast<VContainer *> (data));
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogCutArc::ValidateAlias()
|
||||
{
|
||||
VArc arc1;
|
||||
arc1.SetAliasSuffix(GetAliasSuffix1());
|
||||
if (not GetAliasSuffix1().isEmpty() && not data->IsUnique(arc1.GetAlias()))
|
||||
{
|
||||
flagAlias1 = false;
|
||||
ChangeColor(ui->labelAlias1, errorColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
flagAlias1 = true;
|
||||
ChangeColor(ui->labelAlias1, OkColor(this));
|
||||
}
|
||||
|
||||
VArc arc2;
|
||||
arc2.SetAliasSuffix(GetAliasSuffix2());
|
||||
if (not GetAliasSuffix2().isEmpty() && not data->IsUnique(arc2.GetAlias()))
|
||||
{
|
||||
flagAlias2 = false;
|
||||
ChangeColor(ui->labelAlias2, errorColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
flagAlias2 = true;
|
||||
ChangeColor(ui->labelAlias2, OkColor(this));
|
||||
}
|
||||
|
||||
if (arc1.GetAlias() == arc2.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();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief setArcId set id of arc
|
||||
|
@ -279,3 +331,29 @@ QString DialogCutArc::GetNotes() const
|
|||
{
|
||||
return ui->plainTextEditToolNotes->toPlainText();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogCutArc::SetAliasSuffix1(const QString &alias)
|
||||
{
|
||||
ui->lineEditAlias1->setText(alias);
|
||||
ValidateAlias();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogCutArc::GetAliasSuffix1() const
|
||||
{
|
||||
return ui->lineEditAlias1->text();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogCutArc::SetAliasSuffix2(const QString &alias)
|
||||
{
|
||||
ui->lineEditAlias2->setText(alias);
|
||||
ValidateAlias();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogCutArc::GetAliasSuffix2() const
|
||||
{
|
||||
return ui->lineEditAlias2->text();
|
||||
}
|
||||
|
|
|
@ -54,17 +54,24 @@ public:
|
|||
DialogCutArc(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||
virtual ~DialogCutArc() override;
|
||||
|
||||
QString GetPointName() const;
|
||||
void SetPointName(const QString &value);
|
||||
QString GetPointName() const;
|
||||
void SetPointName(const QString &value);
|
||||
|
||||
QString GetFormula() const;
|
||||
void SetFormula(const QString &value);
|
||||
QString GetFormula() const;
|
||||
void SetFormula(const QString &value);
|
||||
|
||||
quint32 getArcId() const;
|
||||
void setArcId(quint32 value);
|
||||
quint32 getArcId() const;
|
||||
void setArcId(quint32 value);
|
||||
|
||||
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;
|
||||
/**
|
||||
|
@ -84,6 +91,7 @@ protected:
|
|||
virtual bool IsValid() const final;
|
||||
private slots:
|
||||
void ArcChanged();
|
||||
void ValidateAlias();
|
||||
private:
|
||||
Q_DISABLE_COPY(DialogCutArc)
|
||||
/** @brief ui keeps information about user interface */
|
||||
|
@ -94,18 +102,20 @@ private:
|
|||
QString pointName;
|
||||
|
||||
/** @brief formulaBaseHeight base height defined by dialogui */
|
||||
int formulaBaseHeight;
|
||||
int formulaBaseHeight;
|
||||
|
||||
QTimer *timerFormula;
|
||||
|
||||
bool flagFormula;
|
||||
bool flagName;
|
||||
bool flagAlias1{true};
|
||||
bool flagAlias2{true};
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline bool DialogCutArc::IsValid() const
|
||||
{
|
||||
return flagFormula && flagName;
|
||||
return flagFormula && flagName && flagAlias1 && flagAlias2;
|
||||
}
|
||||
|
||||
#endif // DIALOGCUTARC_H
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>334</width>
|
||||
<height>247</height>
|
||||
<width>573</width>
|
||||
<height>295</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="2" column="1">
|
||||
<widget class="QLineEdit" name="lineEditAlias1">
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
|
|
@ -44,14 +44,15 @@
|
|||
#include "../vtoolsinglepoint.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VToolCut::VToolCut(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula,
|
||||
const quint32 &curveCutId, const QString ¬es, QGraphicsItem *parent)
|
||||
: VToolSinglePoint(doc, data, id, notes, parent),
|
||||
formula(formula),
|
||||
curveCutId(curveCutId),
|
||||
detailsMode(qApp->Settings()->IsShowCurveDetails())
|
||||
VToolCut::VToolCut(const VToolCutInitData &initData, QGraphicsItem *parent)
|
||||
: VToolSinglePoint(initData.doc, initData.data, initData.id, initData.notes, parent),
|
||||
formula(initData.formula),
|
||||
baseCurveId(initData.baseCurveId),
|
||||
detailsMode(qApp->Settings()->IsShowCurveDetails()),
|
||||
m_aliasSuffix1(initData.aliasSuffix1),
|
||||
m_aliasSuffix2(initData.aliasSuffix2)
|
||||
{
|
||||
Q_ASSERT_X(curveCutId != 0, Q_FUNC_INFO, "curveCutId == 0"); //-V654 //-V712
|
||||
Q_ASSERT_X(initData.baseCurveId != 0, Q_FUNC_INFO, "curveCutId == 0"); //-V654 //-V712
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -100,10 +101,62 @@ void VToolCut::SetFormulaLength(const VFormula &value)
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolCut::GetAliasSuffix1() const
|
||||
{
|
||||
return m_aliasSuffix1;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCut::SetAliasSuffix1(const QString &alias)
|
||||
{
|
||||
QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(baseCurveId);
|
||||
|
||||
const QString oldAliasSuffix = curve->GetAliasSuffix();
|
||||
curve->SetAliasSuffix(alias);
|
||||
|
||||
if (alias.isEmpty() || VAbstractTool::data.IsUnique(curve->GetAlias()))
|
||||
{
|
||||
m_aliasSuffix1 = alias;
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
curve->SetAliasSuffix(oldAliasSuffix);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolCut::GetAliasSuffix2() const
|
||||
{
|
||||
return m_aliasSuffix2;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCut::SetAliasSuffix2(const QString &alias)
|
||||
{
|
||||
QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(baseCurveId);
|
||||
|
||||
const QString oldAliasSuffix = curve->GetAliasSuffix();
|
||||
curve->SetAliasSuffix(alias);
|
||||
|
||||
if (alias.isEmpty() || VAbstractTool::data.IsUnique(curve->GetAlias()))
|
||||
{
|
||||
m_aliasSuffix2 = alias;
|
||||
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(m_id);
|
||||
SaveOption(obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
curve->SetAliasSuffix(oldAliasSuffix);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolCut::CurveName() const
|
||||
{
|
||||
return VAbstractTool::data.GetGObject(curveCutId)->name();
|
||||
return VAbstractTool::data.GetGObject(baseCurveId)->name();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -121,7 +174,25 @@ void VToolCut::RefreshGeometry()
|
|||
*/
|
||||
void VToolCut::RemoveReferens()
|
||||
{
|
||||
const auto curve = VAbstractTool::data.GetGObject(curveCutId);
|
||||
const auto curve = VAbstractTool::data.GetGObject(baseCurveId);
|
||||
|
||||
doc->DecrementReferens(curve->getIdTool());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCut::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
||||
{
|
||||
VToolSinglePoint::SaveOptions(tag, obj);
|
||||
|
||||
doc->SetAttributeOrRemoveIf(tag, AttrAlias1, m_aliasSuffix1, m_aliasSuffix1.isEmpty());
|
||||
doc->SetAttributeOrRemoveIf(tag, AttrAlias2, m_aliasSuffix2, m_aliasSuffix2.isEmpty());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VToolCut::ReadToolAttributes(const QDomElement &domElement)
|
||||
{
|
||||
VToolSinglePoint::ReadToolAttributes(domElement);
|
||||
|
||||
m_aliasSuffix1 = doc->GetParametrEmptyString(domElement, AttrAlias1);
|
||||
m_aliasSuffix2 = doc->GetParametrEmptyString(domElement, AttrAlias2);
|
||||
}
|
||||
|
|
|
@ -45,18 +45,35 @@
|
|||
|
||||
class VFormula;
|
||||
|
||||
struct VToolCutInitData : VToolSinglePointInitData
|
||||
{
|
||||
VToolCutInitData()
|
||||
: VToolSinglePointInitData()
|
||||
{}
|
||||
|
||||
quint32 baseCurveId{NULL_ID};
|
||||
QString formula{};
|
||||
QString aliasSuffix1{};
|
||||
QString aliasSuffix2{};
|
||||
};
|
||||
|
||||
class VToolCut : public VToolSinglePoint
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VToolCut(VAbstractPattern *doc, VContainer *data, const quint32 &id, const QString &formula,
|
||||
const quint32 &curveCutId, const QString ¬es, QGraphicsItem * parent = nullptr);
|
||||
explicit VToolCut(const VToolCutInitData &initData, QGraphicsItem * parent = nullptr);
|
||||
virtual int type() const override {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::Cut)};
|
||||
|
||||
VFormula GetFormulaLength() const;
|
||||
void SetFormulaLength(const VFormula &value);
|
||||
|
||||
QString GetAliasSuffix1() const;
|
||||
void SetAliasSuffix1(const QString &alias);
|
||||
|
||||
QString GetAliasSuffix2() const;
|
||||
void SetAliasSuffix2(const QString &alias);
|
||||
|
||||
QString CurveName() const;
|
||||
|
||||
public slots:
|
||||
|
@ -67,11 +84,16 @@ protected:
|
|||
/** @brief formula keep formula of length */
|
||||
QString formula;
|
||||
|
||||
quint32 curveCutId;
|
||||
quint32 baseCurveId;
|
||||
bool detailsMode;
|
||||
|
||||
QString m_aliasSuffix1{};
|
||||
QString m_aliasSuffix2{};
|
||||
|
||||
void RefreshGeometry();
|
||||
virtual void RemoveReferens() override;
|
||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) override;
|
||||
virtual void ReadToolAttributes(const QDomElement &domElement) override;
|
||||
|
||||
template <typename T>
|
||||
void ShowToolVisualization(bool show);
|
||||
|
@ -104,7 +126,7 @@ inline void VToolCut::ShowToolVisualization(bool show)
|
|||
delete vis;
|
||||
}
|
||||
|
||||
VDataTool *parent = VAbstractPattern::getTool(VAbstractTool::data.GetGObject(curveCutId)->getIdTool());
|
||||
VDataTool *parent = VAbstractPattern::getTool(VAbstractTool::data.GetGObject(baseCurveId)->getIdTool());
|
||||
if (VAbstractSpline *parentCurve = qobject_cast<VAbstractSpline *>(parent))
|
||||
{
|
||||
detailsMode ? parentCurve->ShowHandles(detailsMode) : parentCurve->ShowHandles(show);
|
||||
|
|
|
@ -62,8 +62,8 @@ const QString VToolCutArc::ToolType = QStringLiteral("cutArc");
|
|||
* @param initData init data.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VToolCutArc::VToolCutArc(const VToolCutArcInitData &initData, QGraphicsItem * parent)
|
||||
:VToolCut(initData.doc, initData.data, initData.id, initData.formula, initData.arcId, initData.notes, parent)
|
||||
VToolCutArc::VToolCutArc(const VToolCutInitData &initData, QGraphicsItem * parent)
|
||||
:VToolCut(initData, parent)
|
||||
{
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
@ -79,9 +79,11 @@ void VToolCutArc::setDialog()
|
|||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetFormula(formula);
|
||||
dialogTool->setArcId(curveCutId);
|
||||
dialogTool->setArcId(baseCurveId);
|
||||
dialogTool->SetPointName(point->name());
|
||||
dialogTool->SetNotes(m_notes);
|
||||
dialogTool->SetAliasSuffix1(m_aliasSuffix1);
|
||||
dialogTool->SetAliasSuffix2(m_aliasSuffix2);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -99,9 +101,9 @@ VToolCutArc* VToolCutArc::Create(const QPointer<DialogTool> &dialog, VMainGraphi
|
|||
const QPointer<DialogCutArc> dialogTool = qobject_cast<DialogCutArc *>(dialog);
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
|
||||
VToolCutArcInitData initData;
|
||||
VToolCutInitData initData;
|
||||
initData.formula = dialogTool->GetFormula();
|
||||
initData.arcId = dialogTool->getArcId();
|
||||
initData.baseCurveId = dialogTool->getArcId();
|
||||
initData.name = dialogTool->GetPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
|
@ -109,6 +111,8 @@ VToolCutArc* VToolCutArc::Create(const QPointer<DialogTool> &dialog, VMainGraphi
|
|||
initData.parse = Document::FullParse;
|
||||
initData.typeCreation = Source::FromGui;
|
||||
initData.notes = dialogTool->GetNotes();
|
||||
initData.aliasSuffix1 = dialogTool->GetAliasSuffix1();
|
||||
initData.aliasSuffix2 = dialogTool->GetAliasSuffix2();
|
||||
|
||||
VToolCutArc* point = Create(initData);
|
||||
if (point != nullptr)
|
||||
|
@ -123,12 +127,12 @@ VToolCutArc* VToolCutArc::Create(const QPointer<DialogTool> &dialog, VMainGraphi
|
|||
* @brief Create help create tool.
|
||||
* @param initData init data.
|
||||
*/
|
||||
VToolCutArc* VToolCutArc::Create(VToolCutArcInitData &initData)
|
||||
VToolCutArc* VToolCutArc::Create(VToolCutInitData &initData)
|
||||
{
|
||||
const QSharedPointer<VArc> arc = initData.data->GeometricObject<VArc>(initData.arcId);
|
||||
const QSharedPointer<VArc> arc = initData.data->GeometricObject<VArc>(initData.baseCurveId);
|
||||
|
||||
//Declare special variable "CurrentLength"
|
||||
VCurveLength *length = new VCurveLength(initData.arcId, initData.arcId, arc.data(),
|
||||
VCurveLength *length = new VCurveLength(initData.baseCurveId, initData.baseCurveId, arc.data(),
|
||||
*initData.data->GetPatternUnit());
|
||||
length->SetName(currentLength);
|
||||
initData.data->AddVariable(length);
|
||||
|
@ -139,6 +143,9 @@ VToolCutArc* VToolCutArc::Create(VToolCutArcInitData &initData)
|
|||
VArc arc2;
|
||||
QPointF point = arc->CutArc(qApp->toPixel(result), arc1, arc2);
|
||||
|
||||
arc1.SetAliasSuffix(initData.aliasSuffix1);
|
||||
arc1.SetAliasSuffix(initData.aliasSuffix2);
|
||||
|
||||
VPointF *p = new VPointF(point, initData.name, initData.mx, initData.my);
|
||||
p->SetShowLabel(initData.showLabel);
|
||||
|
||||
|
@ -147,17 +154,25 @@ VToolCutArc* VToolCutArc::Create(VToolCutArcInitData &initData)
|
|||
if (initData.typeCreation == Source::FromGui)
|
||||
{
|
||||
initData.id = initData.data->AddGObject(p);
|
||||
|
||||
a1->setId(initData.data->getNextId());
|
||||
a2->setId(initData.data->getNextId());
|
||||
initData.data->RegisterUniqueName(a1);
|
||||
initData.data->AddArc(a1, a1->id(), initData.id);
|
||||
|
||||
a2->setId(initData.data->getNextId());
|
||||
initData.data->RegisterUniqueName(a2);
|
||||
initData.data->AddArc(a2, a2->id(), initData.id);
|
||||
}
|
||||
else
|
||||
{
|
||||
initData.data->UpdateGObject(initData.id, p);
|
||||
|
||||
a1->setId(initData.id + 1);
|
||||
a2->setId(initData.id + 2);
|
||||
initData.data->RegisterUniqueName(a1);
|
||||
initData.data->AddArc(a1, a1->id(), initData.id);
|
||||
|
||||
a2->setId(initData.id + 2);
|
||||
initData.data->RegisterUniqueName(a2);
|
||||
initData.data->AddArc(a2, a2->id(), initData.id);
|
||||
|
||||
if (initData.parse != Document::FullParse)
|
||||
|
@ -212,12 +227,16 @@ void VToolCutArc::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepende
|
|||
const QPointer<DialogCutArc> dialogTool = qobject_cast<DialogCutArc *>(m_dialog);
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
|
||||
AddDependence(oldDependencies, curveCutId);
|
||||
AddDependence(oldDependencies, baseCurveId);
|
||||
AddDependence(newDependencies, dialogTool->getArcId());
|
||||
|
||||
doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName());
|
||||
doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
|
||||
doc->SetAttribute(domElement, AttrArc, QString().setNum(dialogTool->getArcId()));
|
||||
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());
|
||||
|
@ -230,7 +249,7 @@ void VToolCutArc::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
|
|||
|
||||
doc->SetAttribute(tag, AttrType, ToolType);
|
||||
doc->SetAttribute(tag, AttrLength, formula);
|
||||
doc->SetAttribute(tag, AttrArc, curveCutId);
|
||||
doc->SetAttribute(tag, AttrArc, baseCurveId);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -239,7 +258,7 @@ void VToolCutArc::ReadToolAttributes(const QDomElement &domElement)
|
|||
VToolCut::ReadToolAttributes(domElement);
|
||||
|
||||
formula = doc->GetParametrString(domElement, AttrLength, QString());
|
||||
curveCutId = doc->GetParametrUInt(domElement, AttrArc, NULL_ID_STR);
|
||||
baseCurveId = doc->GetParametrUInt(domElement, AttrArc, NULL_ID_STR);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -250,10 +269,10 @@ void VToolCutArc::SetVisualization()
|
|||
VisToolCutArc *visual = qobject_cast<VisToolCutArc *>(vis);
|
||||
SCASSERT(visual != nullptr)
|
||||
|
||||
visual->setObject1Id(curveCutId);
|
||||
visual->setObject1Id(baseCurveId);
|
||||
visual->setLength(qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator()));
|
||||
|
||||
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(curveCutId);
|
||||
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(baseCurveId);
|
||||
visual->setLineStyle(LineStyleToPenStyle(curve->GetPenStyle()));
|
||||
|
||||
visual->RefreshGeometry();
|
||||
|
@ -263,7 +282,7 @@ void VToolCutArc::SetVisualization()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolCutArc::MakeToolTip() const
|
||||
{
|
||||
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(curveCutId);
|
||||
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(baseCurveId);
|
||||
|
||||
const QString expression = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator());
|
||||
const qreal length = Visualization::FindValFromUser(expression, VAbstractTool::data.DataVariables());
|
||||
|
@ -296,7 +315,7 @@ QString VToolCutArc::MakeToolTip() const
|
|||
.arg(arc.GetStartAngle())
|
||||
.arg(arcStr + arcNumber + QChar(QChar::Space) + endAngleStr)
|
||||
.arg(arc.GetEndAngle())
|
||||
.arg(arcStr + arcNumber + QChar(QChar::Space) + tr("label"), arc.name());
|
||||
.arg(arcStr + arcNumber + QChar(QChar::Space) + tr("label"), arc.ObjectName());
|
||||
return toolTip;
|
||||
};
|
||||
|
||||
|
|
|
@ -43,18 +43,6 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolCutArcInitData : VToolSinglePointInitData
|
||||
{
|
||||
VToolCutArcInitData()
|
||||
: VToolSinglePointInitData(),
|
||||
formula(),
|
||||
arcId(NULL_ID)
|
||||
{}
|
||||
|
||||
QString formula;
|
||||
quint32 arcId;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolCutArc class tool for cutting arc.
|
||||
*/
|
||||
|
@ -65,7 +53,7 @@ public:
|
|||
virtual void setDialog() override;
|
||||
static VToolCutArc* Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data);
|
||||
static VToolCutArc* Create(VToolCutArcInitData &initData);
|
||||
static VToolCutArc* Create(VToolCutInitData &initData);
|
||||
static const QString ToolType;
|
||||
virtual int type() const override {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Tool::CutArc)};
|
||||
|
@ -82,7 +70,7 @@ protected:
|
|||
private:
|
||||
Q_DISABLE_COPY(VToolCutArc)
|
||||
|
||||
VToolCutArc(const VToolCutArcInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
explicit VToolCutArc(const VToolCutInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLCUTARC_H
|
||||
|
|
|
@ -65,8 +65,8 @@ const QString VToolCutSpline::AttrSpline = QStringLiteral("spline");
|
|||
* @param initData init data.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VToolCutSpline::VToolCutSpline(const VToolCutSplineInitData &initData, QGraphicsItem *parent)
|
||||
:VToolCut(initData.doc, initData.data, initData.id, initData.formula, initData.splineId, initData.notes, parent)
|
||||
VToolCutSpline::VToolCutSpline(const VToolCutInitData &initData, QGraphicsItem *parent)
|
||||
:VToolCut(initData, parent)
|
||||
{
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ void VToolCutSpline::setDialog()
|
|||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetFormula(formula);
|
||||
dialogTool->setSplineId(curveCutId);
|
||||
dialogTool->setSplineId(baseCurveId);
|
||||
dialogTool->SetPointName(point->name());
|
||||
dialogTool->SetNotes(m_notes);
|
||||
}
|
||||
|
@ -102,9 +102,9 @@ VToolCutSpline* VToolCutSpline::Create(const QPointer<DialogTool> &dialog, VMain
|
|||
const QPointer<DialogCutSpline> dialogTool = qobject_cast<DialogCutSpline *>(dialog);
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
|
||||
VToolCutSplineInitData initData;
|
||||
VToolCutInitData initData;
|
||||
initData.formula = dialogTool->GetFormula();
|
||||
initData.splineId = dialogTool->getSplineId();
|
||||
initData.baseCurveId = dialogTool->getSplineId();
|
||||
initData.name = dialogTool->GetPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
|
@ -126,12 +126,12 @@ VToolCutSpline* VToolCutSpline::Create(const QPointer<DialogTool> &dialog, VMain
|
|||
* @brief Create help create tool.
|
||||
* @param initData init data.
|
||||
*/
|
||||
VToolCutSpline* VToolCutSpline::Create(VToolCutSplineInitData &initData)
|
||||
VToolCutSpline* VToolCutSpline::Create(VToolCutInitData &initData)
|
||||
{
|
||||
const auto spl = initData.data->GeometricObject<VAbstractCubicBezier>(initData.splineId);
|
||||
const auto spl = initData.data->GeometricObject<VAbstractCubicBezier>(initData.baseCurveId);
|
||||
|
||||
//Declare special variable "CurrentLength"
|
||||
VCurveLength *length = new VCurveLength(initData.splineId, initData.splineId, spl.data(),
|
||||
VCurveLength *length = new VCurveLength(initData.baseCurveId, initData.baseCurveId, spl.data(),
|
||||
*initData.data->GetPatternUnit());
|
||||
length->SetName(currentLength);
|
||||
initData.data->AddVariable(length);
|
||||
|
@ -211,7 +211,7 @@ void VToolCutSpline::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepe
|
|||
const QPointer<DialogCutSpline> dialogTool = qobject_cast<DialogCutSpline *>(m_dialog);
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
|
||||
AddDependence(oldDependencies, curveCutId);
|
||||
AddDependence(oldDependencies, baseCurveId);
|
||||
AddDependence(newDependencies, dialogTool->getSplineId());
|
||||
|
||||
doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName());
|
||||
|
@ -229,7 +229,7 @@ void VToolCutSpline::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj
|
|||
|
||||
doc->SetAttribute(tag, AttrType, ToolType);
|
||||
doc->SetAttribute(tag, AttrLength, formula);
|
||||
doc->SetAttribute(tag, AttrSpline, curveCutId);
|
||||
doc->SetAttribute(tag, AttrSpline, baseCurveId);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -238,7 +238,7 @@ void VToolCutSpline::ReadToolAttributes(const QDomElement &domElement)
|
|||
VToolCut::ReadToolAttributes(domElement);
|
||||
|
||||
formula = doc->GetParametrString(domElement, AttrLength, QString());
|
||||
curveCutId = doc->GetParametrUInt(domElement, AttrSpline, NULL_ID_STR);
|
||||
baseCurveId = doc->GetParametrUInt(domElement, AttrSpline, NULL_ID_STR);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -249,10 +249,10 @@ void VToolCutSpline::SetVisualization()
|
|||
VisToolCutSpline *visual = qobject_cast<VisToolCutSpline *>(vis);
|
||||
SCASSERT(visual != nullptr)
|
||||
|
||||
visual->setObject1Id(curveCutId);
|
||||
visual->setObject1Id(baseCurveId);
|
||||
visual->setLength(qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator()));
|
||||
|
||||
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(curveCutId);
|
||||
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(baseCurveId);
|
||||
visual->setLineStyle(LineStyleToPenStyle(curve->GetPenStyle()));
|
||||
|
||||
visual->RefreshGeometry();
|
||||
|
@ -262,7 +262,7 @@ void VToolCutSpline::SetVisualization()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolCutSpline::MakeToolTip() const
|
||||
{
|
||||
const auto spl = VAbstractTool::data.GeometricObject<VAbstractCubicBezier>(curveCutId);
|
||||
const auto spl = VAbstractTool::data.GeometricObject<VAbstractCubicBezier>(baseCurveId);
|
||||
|
||||
const QString expression = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator());
|
||||
const qreal length = Visualization::FindValFromUser(expression, VAbstractTool::data.DataVariables());
|
||||
|
|
|
@ -43,18 +43,6 @@
|
|||
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolCutSplineInitData : VToolSinglePointInitData
|
||||
{
|
||||
VToolCutSplineInitData()
|
||||
: VToolSinglePointInitData(),
|
||||
formula(),
|
||||
splineId(NULL_ID)
|
||||
{}
|
||||
|
||||
QString formula;
|
||||
quint32 splineId;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolCutSpline class for tool CutSpline. This tool find point on spline and cut spline on two.
|
||||
*/
|
||||
|
@ -65,7 +53,7 @@ public:
|
|||
virtual void setDialog() override;
|
||||
static VToolCutSpline *Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||
VContainer *data);
|
||||
static VToolCutSpline *Create(VToolCutSplineInitData &initData);
|
||||
static VToolCutSpline *Create(VToolCutInitData &initData);
|
||||
static const QString ToolType;
|
||||
static const QString AttrSpline;
|
||||
virtual int type() const override {return Type;}
|
||||
|
@ -83,7 +71,7 @@ protected:
|
|||
private:
|
||||
Q_DISABLE_COPY(VToolCutSpline)
|
||||
|
||||
VToolCutSpline(const VToolCutSplineInitData &initData, QGraphicsItem * parent = nullptr);
|
||||
VToolCutSpline(const VToolCutInitData &initData, QGraphicsItem * parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLCUTSPLINE_H
|
||||
|
|
|
@ -68,8 +68,8 @@ const QString VToolCutSplinePath::AttrSplinePath = QStringLiteral("splinePath");
|
|||
* @param initData init data.
|
||||
* @param parent parent object.
|
||||
*/
|
||||
VToolCutSplinePath::VToolCutSplinePath(const VToolCutSplinePathInitData &initData, QGraphicsItem *parent)
|
||||
:VToolCut(initData.doc, initData.data, initData.id, initData.formula, initData.splinePathId, initData.notes, parent)
|
||||
VToolCutSplinePath::VToolCutSplinePath(const VToolCutInitData &initData, QGraphicsItem *parent)
|
||||
:VToolCut(initData, parent)
|
||||
{
|
||||
ToolCreation(initData.typeCreation);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ void VToolCutSplinePath::setDialog()
|
|||
SCASSERT(not dialogTool.isNull())
|
||||
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||
dialogTool->SetFormula(formula);
|
||||
dialogTool->setSplinePathId(curveCutId);
|
||||
dialogTool->setSplinePathId(baseCurveId);
|
||||
dialogTool->SetPointName(point->name());
|
||||
dialogTool->SetNotes(m_notes);
|
||||
}
|
||||
|
@ -105,9 +105,9 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const QPointer<DialogTool> &dialo
|
|||
const QPointer<DialogCutSplinePath> dialogTool = qobject_cast<DialogCutSplinePath *>(dialog);
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
|
||||
VToolCutSplinePathInitData initData;
|
||||
VToolCutInitData initData;
|
||||
initData.formula = dialogTool->GetFormula();
|
||||
initData.splinePathId = dialogTool->getSplinePathId();
|
||||
initData.baseCurveId = dialogTool->getSplinePathId();
|
||||
initData.name = dialogTool->GetPointName();
|
||||
initData.scene = scene;
|
||||
initData.doc = doc;
|
||||
|
@ -129,13 +129,13 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const QPointer<DialogTool> &dialo
|
|||
* @brief Create help create tool.
|
||||
* @param initData init data.
|
||||
*/
|
||||
VToolCutSplinePath* VToolCutSplinePath::Create(VToolCutSplinePathInitData &initData)
|
||||
VToolCutSplinePath* VToolCutSplinePath::Create(VToolCutInitData &initData)
|
||||
{
|
||||
const auto splPath = initData.data->GeometricObject<VAbstractCubicBezierPath>(initData.splinePathId);
|
||||
const auto splPath = initData.data->GeometricObject<VAbstractCubicBezierPath>(initData.baseCurveId);
|
||||
SCASSERT(splPath != nullptr)
|
||||
|
||||
//Declare special variable "CurrentLength"
|
||||
VCurveLength *length = new VCurveLength(initData.splinePathId, initData.splinePathId, splPath.data(),
|
||||
VCurveLength *length = new VCurveLength(initData.baseCurveId, initData.baseCurveId, splPath.data(),
|
||||
*initData.data->GetPatternUnit());
|
||||
length->SetName(currentLength);
|
||||
initData.data->AddVariable(length);
|
||||
|
@ -302,7 +302,7 @@ void VToolCutSplinePath::SaveDialog(QDomElement &domElement, QList<quint32> &old
|
|||
const QPointer<DialogCutSplinePath> dialogTool = qobject_cast<DialogCutSplinePath *>(m_dialog);
|
||||
SCASSERT(not dialogTool.isNull())
|
||||
|
||||
AddDependence(oldDependencies, curveCutId);
|
||||
AddDependence(oldDependencies, baseCurveId);
|
||||
AddDependence(newDependencies, dialogTool->getSplinePathId());
|
||||
|
||||
doc->SetAttribute(domElement, AttrName, dialogTool->GetPointName());
|
||||
|
@ -320,7 +320,7 @@ void VToolCutSplinePath::SaveOptions(QDomElement &tag, QSharedPointer<VGObject>
|
|||
|
||||
doc->SetAttribute(tag, AttrType, ToolType);
|
||||
doc->SetAttribute(tag, AttrLength, formula);
|
||||
doc->SetAttribute(tag, AttrSplinePath, curveCutId);
|
||||
doc->SetAttribute(tag, AttrSplinePath, baseCurveId);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -329,7 +329,7 @@ void VToolCutSplinePath::ReadToolAttributes(const QDomElement &domElement)
|
|||
VToolCut::ReadToolAttributes(domElement);
|
||||
|
||||
formula = doc->GetParametrString(domElement, AttrLength, QString());
|
||||
curveCutId = doc->GetParametrUInt(domElement, AttrSplinePath, NULL_ID_STR);
|
||||
baseCurveId = doc->GetParametrUInt(domElement, AttrSplinePath, NULL_ID_STR);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -340,10 +340,10 @@ void VToolCutSplinePath::SetVisualization()
|
|||
VisToolCutSplinePath *visual = qobject_cast<VisToolCutSplinePath *>(vis);
|
||||
SCASSERT(visual != nullptr)
|
||||
|
||||
visual->setObject1Id(curveCutId);
|
||||
visual->setObject1Id(baseCurveId);
|
||||
visual->setLength(qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator()));
|
||||
|
||||
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(curveCutId);
|
||||
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(baseCurveId);
|
||||
visual->setLineStyle(LineStyleToPenStyle(curve->GetPenStyle()));
|
||||
|
||||
visual->RefreshGeometry();
|
||||
|
@ -353,7 +353,7 @@ void VToolCutSplinePath::SetVisualization()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VToolCutSplinePath::MakeToolTip() const
|
||||
{
|
||||
const auto splPath = VAbstractTool::data.GeometricObject<VAbstractCubicBezierPath>(curveCutId);
|
||||
const auto splPath = VAbstractTool::data.GeometricObject<VAbstractCubicBezierPath>(baseCurveId);
|
||||
|
||||
const QString expression = qApp->TrVars()->FormulaToUser(formula, qApp->Settings()->GetOsSeparator());
|
||||
const qreal length = Visualization::FindValFromUser(expression, VAbstractTool::data.DataVariables());
|
||||
|
|
|
@ -44,18 +44,6 @@
|
|||
class VSplinePath;
|
||||
template <class T> class QSharedPointer;
|
||||
|
||||
struct VToolCutSplinePathInitData : VToolSinglePointInitData
|
||||
{
|
||||
VToolCutSplinePathInitData()
|
||||
: VToolSinglePointInitData(),
|
||||
formula(),
|
||||
splinePathId(NULL_ID)
|
||||
{}
|
||||
|
||||
QString formula;
|
||||
quint32 splinePathId;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The VToolCutSplinePath class for tool CutSplinePath. This tool find point on splinePath and cut splinePath on
|
||||
* two.
|
||||
|
@ -67,7 +55,7 @@ public:
|
|||
virtual void setDialog() override;
|
||||
static VToolCutSplinePath *Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene,
|
||||
VAbstractPattern *doc, VContainer *data);
|
||||
static VToolCutSplinePath *Create(VToolCutSplinePathInitData &initData);
|
||||
static VToolCutSplinePath *Create(VToolCutInitData &initData);
|
||||
static const QString ToolType;
|
||||
static const QString AttrSplinePath;
|
||||
virtual int type() const override {return Type;}
|
||||
|
@ -90,7 +78,7 @@ protected:
|
|||
private:
|
||||
Q_DISABLE_COPY(VToolCutSplinePath)
|
||||
|
||||
VToolCutSplinePath(const VToolCutSplinePathInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
VToolCutSplinePath(const VToolCutInitData &initData, QGraphicsItem *parent = nullptr);
|
||||
};
|
||||
|
||||
#endif // VTOOLCUTSPLINEPATH_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user