Refactoring DialogSpline.
--HG-- branch : feature
This commit is contained in:
parent
1925f6476c
commit
f264206aab
|
@ -1861,8 +1861,12 @@ void VPattern::ParseToolSpline(VMainGraphicsScene *scene, const QDomElement &dom
|
||||||
const qreal kCurve = GetParametrDouble(domElement, AttrKCurve, "1.0");
|
const qreal kCurve = GetParametrDouble(domElement, AttrKCurve, "1.0");
|
||||||
const QString color = GetParametrString(domElement, AttrColor, ColorBlack);
|
const QString color = GetParametrString(domElement, AttrColor, ColorBlack);
|
||||||
|
|
||||||
VToolSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, color, scene, this, data,
|
const auto p1 = data->GeometricObject<VPointF>(point1);
|
||||||
parse, Source::FromFile);
|
const auto p4 = data->GeometricObject<VPointF>(point4);
|
||||||
|
|
||||||
|
VSpline spline(*p1, *p4, angle1, angle2, kAsm1, kAsm2, kCurve);
|
||||||
|
|
||||||
|
VToolSpline::Create(id, spline, color, scene, this, data, parse, Source::FromFile);
|
||||||
}
|
}
|
||||||
catch (const VExceptionBadId &e)
|
catch (const VExceptionBadId &e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
* @param parent parent widget
|
* @param parent parent widget
|
||||||
*/
|
*/
|
||||||
DialogSpline::DialogSpline(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
DialogSpline::DialogSpline(const VContainer *data, const quint32 &toolId, QWidget *parent)
|
||||||
:DialogTool(data, toolId, parent), ui(new Ui::DialogSpline), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1)
|
:DialogTool(data, toolId, parent), ui(new Ui::DialogSpline), spl()
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
|
@ -74,16 +74,6 @@ DialogSpline::~DialogSpline()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief GetP1 return id first point of spline
|
|
||||||
* @return id
|
|
||||||
*/
|
|
||||||
quint32 DialogSpline::GetP1() const
|
|
||||||
{
|
|
||||||
return getCurrentObjectId(ui->comboBoxP1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
|
* @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong.
|
||||||
|
@ -133,17 +123,19 @@ void DialogSpline::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSpline::SaveData()
|
void DialogSpline::SaveData()
|
||||||
{
|
{
|
||||||
angle1 = ui->spinBoxAngle1->value();
|
const qreal angle1 = ui->spinBoxAngle1->value();
|
||||||
angle2 = ui->spinBoxAngle2->value();
|
const qreal angle2 = ui->spinBoxAngle2->value();
|
||||||
kAsm1 = ui->doubleSpinBoxKasm1->value();
|
const qreal kAsm1 = ui->doubleSpinBoxKasm1->value();
|
||||||
kAsm2 = ui->doubleSpinBoxKasm2->value();
|
const qreal kAsm2 = ui->doubleSpinBoxKasm2->value();
|
||||||
kCurve = ui->doubleSpinBoxKcurve->value();
|
const qreal kCurve = ui->doubleSpinBoxKcurve->value();
|
||||||
|
|
||||||
|
spl = VSpline(*GetP1(), *GetP4(), angle1, angle2, kAsm1, kAsm2, kCurve);
|
||||||
|
|
||||||
auto path = qobject_cast<VisToolSpline *>(vis);
|
auto path = qobject_cast<VisToolSpline *>(vis);
|
||||||
SCASSERT(path != nullptr);
|
SCASSERT(path != nullptr);
|
||||||
|
|
||||||
path->setObject1Id(GetP1());
|
path->setObject1Id(GetP1()->id());
|
||||||
path->setObject4Id(GetP4());
|
path->setObject4Id(GetP4()->id());
|
||||||
path->SetAngle1(angle1);
|
path->SetAngle1(angle1);
|
||||||
path->SetAngle2(angle2);
|
path->SetAngle2(angle2);
|
||||||
path->SetKAsm1(kAsm1);
|
path->SetKAsm1(kAsm1);
|
||||||
|
@ -153,6 +145,18 @@ void DialogSpline::SaveData()
|
||||||
path->RefreshGeometry();
|
path->RefreshGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
const QSharedPointer<VPointF> DialogSpline::GetP1() const
|
||||||
|
{
|
||||||
|
return data->GeometricObject<VPointF>(getCurrentObjectId(ui->comboBoxP1));
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
const QSharedPointer<VPointF> DialogSpline::GetP4() const
|
||||||
|
{
|
||||||
|
return data->GeometricObject<VPointF>(getCurrentObjectId(ui->comboBoxP4));
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogSpline::PointNameChanged()
|
void DialogSpline::PointNameChanged()
|
||||||
{
|
{
|
||||||
|
@ -181,22 +185,16 @@ void DialogSpline::ShowDialog(bool click)
|
||||||
{
|
{
|
||||||
if (prepare && click)
|
if (prepare && click)
|
||||||
{
|
{
|
||||||
const auto p1 = data->GeometricObject<VPointF>(getCurrentObjectId(ui->comboBoxP1));
|
|
||||||
const auto p4 = data->GeometricObject<VPointF>(getCurrentObjectId(ui->comboBoxP4));
|
|
||||||
|
|
||||||
auto *path = qobject_cast<VisToolSpline *>(vis);
|
auto *path = qobject_cast<VisToolSpline *>(vis);
|
||||||
SCASSERT(path != nullptr);
|
SCASSERT(path != nullptr);
|
||||||
|
|
||||||
const QPointF p2 = path->GetP2();
|
VSpline spl(*GetP1(), path->GetP2(), path->GetP3(), *GetP4(), 1);
|
||||||
const QPointF p3 = path->GetP3();
|
|
||||||
|
|
||||||
VSpline spline(*p1, p2, p3, *p4, kCurve);
|
ui->spinBoxAngle1->setValue(static_cast<qint32>(spl.GetStartAngle()));
|
||||||
|
ui->spinBoxAngle2->setValue(static_cast<qint32>(spl.GetEndAngle()));
|
||||||
|
|
||||||
ui->spinBoxAngle1->setValue(static_cast<qint32>(spline.GetStartAngle()));
|
ui->doubleSpinBoxKasm1->setValue(spl.GetKasm1());
|
||||||
ui->spinBoxAngle2->setValue(static_cast<qint32>(spline.GetEndAngle()));
|
ui->doubleSpinBoxKasm2->setValue(spl.GetKasm2());
|
||||||
|
|
||||||
ui->doubleSpinBoxKasm1->setValue(spline.GetKasm1());
|
|
||||||
ui->doubleSpinBoxKasm2->setValue(spline.GetKasm2());
|
|
||||||
|
|
||||||
DialogAccepted();
|
DialogAccepted();
|
||||||
}
|
}
|
||||||
|
@ -209,18 +207,34 @@ void DialogSpline::ShowVisualization()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
VSpline DialogSpline::GetSpline() const
|
||||||
* @brief SetKCurve set coefficient curve
|
|
||||||
* @param value value. Can be >= 0.
|
|
||||||
*/
|
|
||||||
void DialogSpline::SetKCurve(const qreal &value)
|
|
||||||
{
|
{
|
||||||
kCurve = value;
|
return spl;
|
||||||
ui->doubleSpinBoxKcurve->setValue(value);
|
}
|
||||||
|
|
||||||
VisToolSpline *path = qobject_cast<VisToolSpline *>(vis);
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void DialogSpline::SetSpline(const VSpline &spline)
|
||||||
|
{
|
||||||
|
spl = spline;
|
||||||
|
|
||||||
|
setCurrentPointId(ui->comboBoxP1, spl.GetP1().id());
|
||||||
|
setCurrentPointId(ui->comboBoxP4, spl.GetP4().id());
|
||||||
|
ui->spinBoxAngle1->setValue(static_cast<qint32>(spl.GetStartAngle()));
|
||||||
|
ui->spinBoxAngle2->setValue(static_cast<qint32>(spl.GetEndAngle()));
|
||||||
|
ui->doubleSpinBoxKasm1->setValue(spl.GetKasm1());
|
||||||
|
ui->doubleSpinBoxKasm2->setValue(spl.GetKasm2());
|
||||||
|
ui->doubleSpinBoxKcurve->setValue(spl.GetKcurve());
|
||||||
|
|
||||||
|
auto path = qobject_cast<VisToolSpline *>(vis);
|
||||||
SCASSERT(path != nullptr);
|
SCASSERT(path != nullptr);
|
||||||
path->SetKCurve(kCurve);
|
|
||||||
|
path->setObject1Id(spl.GetP1().id());
|
||||||
|
path->setObject4Id(spl.GetP4().id());
|
||||||
|
path->SetAngle1(spl.GetStartAngle());
|
||||||
|
path->SetAngle2(spl.GetEndAngle());
|
||||||
|
path->SetKAsm1(spl.GetKasm1());
|
||||||
|
path->SetKAsm2(spl.GetKasm2());
|
||||||
|
path->SetKCurve(spl.GetKcurve());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -234,151 +248,3 @@ void DialogSpline::SetColor(const QString &value)
|
||||||
{
|
{
|
||||||
ChangeCurrentData(ui->comboBoxColor, value);
|
ChangeCurrentData(ui->comboBoxColor, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief SetKAsm2 set second coefficient asymmetry
|
|
||||||
* @param value value. Can be >= 0.
|
|
||||||
*/
|
|
||||||
void DialogSpline::SetKAsm2(const qreal &value)
|
|
||||||
{
|
|
||||||
kAsm2 = value;
|
|
||||||
ui->doubleSpinBoxKasm2->setValue(value);
|
|
||||||
|
|
||||||
VisToolSpline *path = qobject_cast<VisToolSpline *>(vis);
|
|
||||||
SCASSERT(path != nullptr);
|
|
||||||
path->SetKAsm2(kAsm2);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief SetKAsm1 set first coefficient asymmetry
|
|
||||||
* @param value value. Can be >= 0.
|
|
||||||
*/
|
|
||||||
void DialogSpline::SetKAsm1(const qreal &value)
|
|
||||||
{
|
|
||||||
kAsm1 = value;
|
|
||||||
ui->doubleSpinBoxKasm1->setValue(value);
|
|
||||||
|
|
||||||
VisToolSpline *path = qobject_cast<VisToolSpline *>(vis);
|
|
||||||
SCASSERT(path != nullptr);
|
|
||||||
path->SetKAsm1(kAsm1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief SetAngle2 set second angle of spline
|
|
||||||
* @param value angle in degree
|
|
||||||
*/
|
|
||||||
void DialogSpline::SetAngle2(const qreal &value)
|
|
||||||
{
|
|
||||||
angle2 = value;
|
|
||||||
ui->spinBoxAngle2->setValue(static_cast<qint32>(value));
|
|
||||||
|
|
||||||
VisToolSpline *path = qobject_cast<VisToolSpline *>(vis);
|
|
||||||
SCASSERT(path != nullptr);
|
|
||||||
path->SetAngle2(angle2);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief SetAngle1 set first angle of spline
|
|
||||||
* @param value angle in degree
|
|
||||||
*/
|
|
||||||
void DialogSpline::SetAngle1(const qreal &value)
|
|
||||||
{
|
|
||||||
angle1 = value;
|
|
||||||
ui->spinBoxAngle1->setValue(static_cast<qint32>(value));
|
|
||||||
|
|
||||||
VisToolSpline *path = qobject_cast<VisToolSpline *>(vis);
|
|
||||||
SCASSERT(path != nullptr);
|
|
||||||
path->SetAngle1(angle1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief SetP4 set id fourth point of spline
|
|
||||||
* @param value id
|
|
||||||
*/
|
|
||||||
void DialogSpline::SetP4(const quint32 &value)
|
|
||||||
{
|
|
||||||
setCurrentPointId(ui->comboBoxP4, value);
|
|
||||||
|
|
||||||
VisToolSpline *path = qobject_cast<VisToolSpline *>(vis);
|
|
||||||
SCASSERT(path != nullptr);
|
|
||||||
path->setObject4Id(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief SetP1 set id first point of spline
|
|
||||||
* @param value id
|
|
||||||
*/
|
|
||||||
void DialogSpline::SetP1(const quint32 &value)
|
|
||||||
{
|
|
||||||
setCurrentPointId(ui->comboBoxP1, value);
|
|
||||||
|
|
||||||
VisToolSpline *path = qobject_cast<VisToolSpline *>(vis);
|
|
||||||
SCASSERT(path != nullptr);
|
|
||||||
path->setObject1Id(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief GetP4 return id fourth point of spline
|
|
||||||
* @return id
|
|
||||||
*/
|
|
||||||
quint32 DialogSpline::GetP4() const
|
|
||||||
{
|
|
||||||
return getCurrentObjectId(ui->comboBoxP4);
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief GetAngle1 return first angle of spline
|
|
||||||
* @return angle in degree
|
|
||||||
*/
|
|
||||||
qreal DialogSpline::GetAngle1() const
|
|
||||||
{
|
|
||||||
return angle1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief GetAngle2 return second angle of spline
|
|
||||||
* @return angle in degree
|
|
||||||
*/
|
|
||||||
qreal DialogSpline::GetAngle2() const
|
|
||||||
{
|
|
||||||
return angle2;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief GetKAsm1 return first coefficient asymmetry
|
|
||||||
* @return value. Can be >= 0.
|
|
||||||
*/
|
|
||||||
qreal DialogSpline::GetKAsm1() const
|
|
||||||
{
|
|
||||||
return kAsm1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief GetKAsm2 return second coefficient asymmetry
|
|
||||||
* @return value. Can be >= 0.
|
|
||||||
*/
|
|
||||||
qreal DialogSpline::GetKAsm2() const
|
|
||||||
{
|
|
||||||
return kAsm2;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* @brief GetKCurve return coefficient curve
|
|
||||||
* @return value. Can be >= 0.
|
|
||||||
*/
|
|
||||||
qreal DialogSpline::GetKCurve() const
|
|
||||||
{
|
|
||||||
return kCurve;
|
|
||||||
}
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#define DIALOGSPLINE_H
|
#define DIALOGSPLINE_H
|
||||||
|
|
||||||
#include "dialogtool.h"
|
#include "dialogtool.h"
|
||||||
|
#include "../vgeometry/vspline.h"
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
{
|
{
|
||||||
|
@ -46,26 +47,8 @@ public:
|
||||||
DialogSpline(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
DialogSpline(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogSpline() Q_DECL_OVERRIDE;
|
virtual ~DialogSpline() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
quint32 GetP1() const;
|
VSpline GetSpline() const;
|
||||||
void SetP1(const quint32 &value);
|
void SetSpline(const VSpline &spline);
|
||||||
|
|
||||||
quint32 GetP4() const;
|
|
||||||
void SetP4(const quint32 &value);
|
|
||||||
|
|
||||||
qreal GetAngle1() const;
|
|
||||||
void SetAngle1(const qreal &value);
|
|
||||||
|
|
||||||
qreal GetAngle2() const;
|
|
||||||
void SetAngle2(const qreal &value);
|
|
||||||
|
|
||||||
qreal GetKAsm1() const;
|
|
||||||
void SetKAsm1(const qreal &value);
|
|
||||||
|
|
||||||
qreal GetKAsm2() const;
|
|
||||||
void SetKAsm2(const qreal &value);
|
|
||||||
|
|
||||||
qreal GetKCurve() const;
|
|
||||||
void SetKCurve(const qreal &value);
|
|
||||||
|
|
||||||
QString GetColor() const;
|
QString GetColor() const;
|
||||||
void SetColor(const QString &value);
|
void SetColor(const QString &value);
|
||||||
|
@ -85,20 +68,11 @@ private:
|
||||||
/** @brief ui keeps information about user interface */
|
/** @brief ui keeps information about user interface */
|
||||||
Ui::DialogSpline *ui;
|
Ui::DialogSpline *ui;
|
||||||
|
|
||||||
/** @brief angle1 first angle of spline in degree */
|
/** @brief spl spline */
|
||||||
qreal angle1;
|
VSpline spl;
|
||||||
|
|
||||||
/** @brief angle2 second angle of spline in degree */
|
const QSharedPointer<VPointF> GetP1() const;
|
||||||
qreal angle2;
|
const QSharedPointer<VPointF> GetP4() const;
|
||||||
|
|
||||||
/** @brief kAsm1 first coefficient asymmetry */
|
|
||||||
qreal kAsm1;
|
|
||||||
|
|
||||||
/** @brief kAsm2 second coefficient asymmetry */
|
|
||||||
qreal kAsm2;
|
|
||||||
|
|
||||||
/** @brief kCurve coefficient curve */
|
|
||||||
qreal kCurve;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIALOGSPLINE_H
|
#endif // DIALOGSPLINE_H
|
||||||
|
|
|
@ -104,14 +104,8 @@ void VToolSpline::setDialog()
|
||||||
SCASSERT(dialog != nullptr);
|
SCASSERT(dialog != nullptr);
|
||||||
DialogSpline *dialogTool = qobject_cast<DialogSpline*>(dialog);
|
DialogSpline *dialogTool = qobject_cast<DialogSpline*>(dialog);
|
||||||
SCASSERT(dialogTool != nullptr);
|
SCASSERT(dialogTool != nullptr);
|
||||||
const QSharedPointer<VSpline> spl = VAbstractTool::data.GeometricObject<VSpline>(id);
|
const auto spl = VAbstractTool::data.GeometricObject<VSpline>(id);
|
||||||
dialogTool->SetP1(spl->GetP1().id());
|
dialogTool->SetSpline(*spl);
|
||||||
dialogTool->SetP4(spl->GetP4().id());
|
|
||||||
dialogTool->SetAngle1(spl->GetStartAngle());
|
|
||||||
dialogTool->SetAngle2(spl->GetEndAngle());
|
|
||||||
dialogTool->SetKAsm1(spl->GetKasm1());
|
|
||||||
dialogTool->SetKAsm2(spl->GetKasm2());
|
|
||||||
dialogTool->SetKCurve(spl->GetKcurve());
|
|
||||||
dialogTool->SetColor(lineColor);
|
dialogTool->SetColor(lineColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,18 +121,12 @@ void VToolSpline::setDialog()
|
||||||
VToolSpline* VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
|
VToolSpline* VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data)
|
||||||
{
|
{
|
||||||
SCASSERT(dialog != nullptr);
|
SCASSERT(dialog != nullptr);
|
||||||
DialogSpline *dialogTool = qobject_cast<DialogSpline*>(dialog);
|
auto dialogTool = qobject_cast<DialogSpline*>(dialog);
|
||||||
SCASSERT(dialogTool != nullptr);
|
SCASSERT(dialogTool != nullptr);
|
||||||
const quint32 p1 = dialogTool->GetP1();
|
|
||||||
const quint32 p4 = dialogTool->GetP4();
|
auto spl = Create(0, dialogTool->GetSpline(), dialogTool->GetColor(), scene, doc, data, Document::FullParse,
|
||||||
const qreal kAsm1 = dialogTool->GetKAsm1();
|
Source::FromGui);
|
||||||
const qreal kAsm2 = dialogTool->GetKAsm2();
|
|
||||||
const qreal angle1 = dialogTool->GetAngle1();
|
|
||||||
const qreal angle2 = dialogTool->GetAngle2();
|
|
||||||
const qreal kCurve = dialogTool->GetKCurve();
|
|
||||||
const QString color = dialogTool->GetColor();
|
|
||||||
VToolSpline *spl = Create(0, p1, p4, kAsm1, kAsm2, angle1, angle2, kCurve, color, scene, doc, data,
|
|
||||||
Document::FullParse, Source::FromGui);
|
|
||||||
if (spl != nullptr)
|
if (spl != nullptr)
|
||||||
{
|
{
|
||||||
spl->dialog=dialogTool;
|
spl->dialog=dialogTool;
|
||||||
|
@ -150,13 +138,8 @@ VToolSpline* VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene,
|
||||||
/**
|
/**
|
||||||
* @brief Create help create tool.
|
* @brief Create help create tool.
|
||||||
* @param _id tool id, 0 if tool doesn't exist yet.
|
* @param _id tool id, 0 if tool doesn't exist yet.
|
||||||
* @param p1 id first spline point.
|
* @param spl spline.
|
||||||
* @param p4 id last spline point.
|
* @param color spline color.
|
||||||
* @param kAsm1 coefficient of length first control line.
|
|
||||||
* @param kAsm2 coefficient of length second control line.
|
|
||||||
* @param angle1 angle from first point to first control point.
|
|
||||||
* @param angle2 angle from second point to second control point.
|
|
||||||
* @param kCurve coefficient of curvature spline.
|
|
||||||
* @param scene pointer to scene.
|
* @param scene pointer to scene.
|
||||||
* @param doc dom document container.
|
* @param doc dom document container.
|
||||||
* @param data container with variables.
|
* @param data container with variables.
|
||||||
|
@ -164,15 +147,11 @@ VToolSpline* VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene,
|
||||||
* @param typeCreation way we create this tool.
|
* @param typeCreation way we create this tool.
|
||||||
* @return the created tool
|
* @return the created tool
|
||||||
*/
|
*/
|
||||||
VToolSpline* VToolSpline::Create(const quint32 _id, const quint32 &p1, const quint32 &p4, const qreal &kAsm1,
|
VToolSpline* VToolSpline::Create(const quint32 _id, const VSpline &spl, const QString &color, VMainGraphicsScene *scene,
|
||||||
const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve,
|
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||||
const QString &color, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
const Source &typeCreation)
|
||||||
VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation)
|
|
||||||
{
|
{
|
||||||
VPointF point1 = *data->GeometricObject<VPointF>(p1);
|
auto spline = new VSpline(spl);
|
||||||
VPointF point4 = *data->GeometricObject<VPointF>(p4);
|
|
||||||
VSpline *spline = new VSpline(point1, point4, angle1, angle2, kAsm1, kAsm2, kCurve);
|
|
||||||
quint32 id = _id;
|
quint32 id = _id;
|
||||||
if (typeCreation == Source::FromGui)
|
if (typeCreation == Source::FromGui)
|
||||||
{
|
{
|
||||||
|
@ -191,17 +170,17 @@ VToolSpline* VToolSpline::Create(const quint32 _id, const quint32 &p1, const qui
|
||||||
VDrawTool::AddRecord(id, Tool::Spline, doc);
|
VDrawTool::AddRecord(id, Tool::Spline, doc);
|
||||||
if (parse == Document::FullParse)
|
if (parse == Document::FullParse)
|
||||||
{
|
{
|
||||||
VToolSpline *spl = new VToolSpline(doc, data, id, color, typeCreation);
|
auto _spl = new VToolSpline(doc, data, id, color, typeCreation);
|
||||||
scene->addItem(spl);
|
scene->addItem(_spl);
|
||||||
connect(spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
connect(_spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSpline::SetFactor);
|
connect(scene, &VMainGraphicsScene::NewFactor, _spl, &VToolSpline::SetFactor);
|
||||||
connect(scene, &VMainGraphicsScene::DisableItem, spl, &VToolSpline::Disable);
|
connect(scene, &VMainGraphicsScene::DisableItem, _spl, &VToolSpline::Disable);
|
||||||
connect(scene, &VMainGraphicsScene::EnableToolMove, spl, &VToolSpline::EnableToolMove);
|
connect(scene, &VMainGraphicsScene::EnableToolMove, _spl, &VToolSpline::EnableToolMove);
|
||||||
connect(scene, &VMainGraphicsScene::CurveDetailsMode, spl, &VToolSpline::DetailsMode);
|
connect(scene, &VMainGraphicsScene::CurveDetailsMode, _spl, &VToolSpline::DetailsMode);
|
||||||
doc->AddTool(id, spl);
|
doc->AddTool(id, _spl);
|
||||||
doc->IncrementReferens(point1.getIdTool());
|
doc->IncrementReferens(spline->GetP1().id());
|
||||||
doc->IncrementReferens(point4.getIdTool());
|
doc->IncrementReferens(spline->GetP4().id());
|
||||||
return spl;
|
return _spl;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -297,13 +276,10 @@ void VToolSpline::RemoveReferens()
|
||||||
void VToolSpline::SaveDialog(QDomElement &domElement)
|
void VToolSpline::SaveDialog(QDomElement &domElement)
|
||||||
{
|
{
|
||||||
SCASSERT(dialog != nullptr);
|
SCASSERT(dialog != nullptr);
|
||||||
DialogSpline *dialogTool = qobject_cast<DialogSpline*>(dialog);
|
auto dialogTool = qobject_cast<DialogSpline*>(dialog);
|
||||||
SCASSERT(dialogTool != nullptr);
|
SCASSERT(dialogTool != nullptr);
|
||||||
|
|
||||||
VPointF point1 = *VAbstractTool::data.GeometricObject<VPointF>(dialogTool->GetP1());
|
const VSpline spl = dialogTool->GetSpline();
|
||||||
VPointF point4 = *VAbstractTool::data.GeometricObject<VPointF>(dialogTool->GetP4());
|
|
||||||
VSpline spl = VSpline (point1, point4, dialogTool->GetAngle1(), dialogTool->GetAngle2(),
|
|
||||||
dialogTool->GetKAsm1(), dialogTool->GetKAsm2(), dialogTool->GetKCurve());
|
|
||||||
|
|
||||||
controlPoints[0]->blockSignals(true);
|
controlPoints[0]->blockSignals(true);
|
||||||
controlPoints[1]->blockSignals(true);
|
controlPoints[1]->blockSignals(true);
|
||||||
|
@ -314,8 +290,6 @@ void VToolSpline::SaveDialog(QDomElement &domElement)
|
||||||
controlPoints[0]->blockSignals(false);
|
controlPoints[0]->blockSignals(false);
|
||||||
controlPoints[1]->blockSignals(false);
|
controlPoints[1]->blockSignals(false);
|
||||||
|
|
||||||
spl = VSpline (point1, controlPoints[0]->pos(), controlPoints[1]->pos(), point4, dialogTool->GetKCurve());
|
|
||||||
|
|
||||||
doc->SetAttribute(domElement, AttrPoint1, spl.GetP1().id());
|
doc->SetAttribute(domElement, AttrPoint1, spl.GetP1().id());
|
||||||
doc->SetAttribute(domElement, AttrPoint4, spl.GetP4().id());
|
doc->SetAttribute(domElement, AttrPoint4, spl.GetP4().id());
|
||||||
doc->SetAttribute(domElement, AttrAngle1, spl.GetStartAngle());
|
doc->SetAttribute(domElement, AttrAngle1, spl.GetStartAngle());
|
||||||
|
|
|
@ -45,11 +45,9 @@ public:
|
||||||
virtual ~VToolSpline() Q_DECL_OVERRIDE;
|
virtual ~VToolSpline() Q_DECL_OVERRIDE;
|
||||||
virtual void setDialog() Q_DECL_OVERRIDE;
|
virtual void setDialog() Q_DECL_OVERRIDE;
|
||||||
static VToolSpline *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data);
|
static VToolSpline *Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data);
|
||||||
static VToolSpline *Create(const quint32 _id, const quint32 &p1, const quint32 &p4, const qreal &kAsm1,
|
static VToolSpline *Create(const quint32 _id, const VSpline &spl, const QString &color, VMainGraphicsScene *scene,
|
||||||
const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve,
|
VAbstractPattern *doc, VContainer *data, const Document &parse,
|
||||||
const QString &color, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
const Source &typeCreation);
|
||||||
VContainer *data,
|
|
||||||
const Document &parse, const Source &typeCreation);
|
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
virtual int type() const Q_DECL_OVERRIDE {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Tool::Spline)};
|
enum { Type = UserType + static_cast<int>(Tool::Spline)};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user