Refactoring dialogs.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-05-21 22:24:31 +03:00
parent 9284ec82f8
commit cda5b76a7a
43 changed files with 463 additions and 380 deletions

View File

@ -43,7 +43,7 @@
*/
DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogAlongLine),
formula(QString()), formulaBaseHeight(0), line(nullptr)
formula(QString()), formulaBaseHeight(0)
{
ui->setupUi(this);
InitFormulaUI(ui);
@ -71,7 +71,7 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId,
connect(ui->comboBoxSecondPoint, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogAlongLine::PointChanged);
line = new VisToolAlongLine(data);
vis = new VisToolAlongLine(data);
}
//---------------------------------------------------------------------------------------------------------------------
@ -115,14 +115,7 @@ void DialogAlongLine::FXLength()
//---------------------------------------------------------------------------------------------------------------------
void DialogAlongLine::ShowVisualization()
{
if (prepare == false)
{
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr)
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolAlongLine::SetFactor);
scene->addItem(line);
line->RefreshGeometry();
}
AddVisualization<VisToolAlongLine>();
}
//---------------------------------------------------------------------------------------------------------------------
@ -134,10 +127,7 @@ void DialogAlongLine::DeployFormulaTextEdit()
//---------------------------------------------------------------------------------------------------------------------
DialogAlongLine::~DialogAlongLine()
{
if (qApp->getCurrentScene()->items().contains(line))
{ // In some cases scene delete object yourself. If not make check program will crash.
delete line;
}
DeleteVisualization<VisToolAlongLine>();
delete ui;
}
@ -153,6 +143,9 @@ void DialogAlongLine::ChosenObject(quint32 id, const SceneObject &type)
{
if (type == SceneObject::Point)
{
VisToolAlongLine *line = qobject_cast<VisToolAlongLine *>(vis);
SCASSERT(line != nullptr);
const QString toolTip = tr("Select second point of line");
switch (number)
{
@ -195,6 +188,9 @@ void DialogAlongLine::SaveData()
formula = ui->plainTextEditFormula->toPlainText();
formula.replace("\n", " ");
VisToolAlongLine *line = qobject_cast<VisToolAlongLine *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(GetFirstPointId());
line->setPoint2Id(GetSecondPointId());
line->setLength(formula);
@ -217,6 +213,9 @@ void DialogAlongLine::closeEvent(QCloseEvent *event)
void DialogAlongLine::SetSecondPointId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxSecondPoint, value);
VisToolAlongLine *line = qobject_cast<VisToolAlongLine *>(vis);
SCASSERT(line != nullptr);
line->setPoint2Id(value);
}
@ -228,6 +227,9 @@ void DialogAlongLine::SetSecondPointId(const quint32 &value)
void DialogAlongLine::SetFirstPointId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxFirstPoint, value);
VisToolAlongLine *line = qobject_cast<VisToolAlongLine *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(value);
}
@ -245,7 +247,11 @@ void DialogAlongLine::SetFormula(const QString &value)
this->DeployFormulaTextEdit();
}
ui->plainTextEditFormula->setPlainText(formula);
VisToolAlongLine *line = qobject_cast<VisToolAlongLine *>(vis);
SCASSERT(line != nullptr);
line->setLength(formula);
MoveCursorToEnd(ui->plainTextEditFormula);
}
@ -257,7 +263,7 @@ void DialogAlongLine::SetFormula(const QString &value)
void DialogAlongLine::SetTypeLine(const QString &value)
{
ChangeCurrentData(ui->comboBoxLineType, value);
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
vis->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -31,8 +31,6 @@
#include "dialogtool.h"
class VisToolAlongLine;
namespace Ui
{
class DialogAlongLine;
@ -46,7 +44,7 @@ class DialogAlongLine : public DialogTool
Q_OBJECT
public:
DialogAlongLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogAlongLine();
virtual ~DialogAlongLine();
void SetPointName(const QString &value);
@ -95,7 +93,6 @@ private:
/** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight;
VisToolAlongLine *line;
};
#endif // DIALOGALONGLINE_H

View File

@ -47,8 +47,7 @@
DialogArc::DialogArc(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false),
timerRadius(nullptr), timerF1(nullptr), timerF2(nullptr), radius(QString()), f1(QString()), f2(QString()),
formulaBaseHeight(0), formulaBaseHeightF1(0), formulaBaseHeightF2(0), path(nullptr), angleF1(INT_MIN),
angleF2(INT_MIN)
formulaBaseHeight(0), formulaBaseHeightF1(0), formulaBaseHeightF2(0), angleF1(INT_MIN), angleF2(INT_MIN)
{
ui->setupUi(this);
@ -89,7 +88,7 @@ DialogArc::DialogArc(const VContainer *data, const quint32 &toolId, QWidget *par
connect(ui->pushButtonGrowLengthF1, &QPushButton::clicked, this, &DialogArc::DeployF1TextEdit);
connect(ui->pushButtonGrowLengthF2, &QPushButton::clicked, this, &DialogArc::DeployF2TextEdit);
path = new VisToolArc(data);
vis = new VisToolArc(data);
}
//---------------------------------------------------------------------------------------------------------------------
@ -113,10 +112,7 @@ void DialogArc::DeployF2TextEdit()
//---------------------------------------------------------------------------------------------------------------------
DialogArc::~DialogArc()
{
if (qApp->getCurrentScene()->items().contains(path))
{ // In some cases scene delete object yourself. If not make check program will crash.
delete path;
}
DeleteVisualization<VisToolArc>();
delete ui;
}
@ -128,7 +124,7 @@ DialogArc::~DialogArc()
void DialogArc::SetCenter(const quint32 &value)
{
ChangeCurrentData(ui->comboBoxBasePoint, value);
path->setPoint1Id(value);
vis->setPoint1Id(value);
}
//---------------------------------------------------------------------------------------------------------------------
@ -145,7 +141,11 @@ void DialogArc::SetF2(const QString &value)
this->DeployF2TextEdit();
}
ui->plainTextEditF2->setPlainText(f2);
VisToolArc *path = qobject_cast<VisToolArc *>(vis);
SCASSERT(path != nullptr);
path->setF2(f2);
MoveCursorToEnd(ui->plainTextEditF2);
}
@ -175,7 +175,11 @@ void DialogArc::SetF1(const QString &value)
this->DeployF1TextEdit();
}
ui->plainTextEditF1->setPlainText(f1);
VisToolArc *path = qobject_cast<VisToolArc *>(vis);
SCASSERT(path != nullptr);
path->setF1(f1);
MoveCursorToEnd(ui->plainTextEditF1);
}
@ -193,7 +197,11 @@ void DialogArc::SetRadius(const QString &value)
this->DeployFormulaTextEdit();
}
ui->plainTextEditFormula->setPlainText(radius);
VisToolArc *path = qobject_cast<VisToolArc *>(vis);
SCASSERT(path != nullptr);
path->setRadius(radius);
MoveCursorToEnd(ui->plainTextEditFormula);
}
@ -211,7 +219,7 @@ void DialogArc::ChosenObject(quint32 id, const SceneObject &type)
{
if (SetObject(id, ui->comboBoxBasePoint, ""))
{
path->VisualMode(id);
vis->VisualMode(id);
prepare = true;
this->setModal(true);
this->show();
@ -223,14 +231,7 @@ void DialogArc::ChosenObject(quint32 id, const SceneObject &type)
//---------------------------------------------------------------------------------------------------------------------
void DialogArc::ShowVisualization()
{
if (prepare == false)
{
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr)
connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor);
scene->addItem(path);
path->RefreshGeometry();
}
AddVisualization<VisToolArc>();
}
//---------------------------------------------------------------------------------------------------------------------
@ -243,6 +244,9 @@ void DialogArc::SaveData()
f2 = ui->plainTextEditF2->toPlainText();
f2.replace("\n", " ");
VisToolArc *path = qobject_cast<VisToolArc *>(vis);
SCASSERT(path != nullptr);
path->setPoint1Id(GetCenter());
path->setRadius(radius);
path->setF1(f1);

View File

@ -36,8 +36,6 @@ namespace Ui
class DialogArc;
}
class VisToolArc;
/**
* @brief The DialogArc class dialog for ToolArc. Help create arc and edit option.
*/
@ -46,7 +44,7 @@ class DialogArc : public DialogTool
Q_OBJECT
public:
DialogArc(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogArc();
virtual ~DialogArc();
quint32 GetCenter() const;
void SetCenter(const quint32 &value);
@ -123,8 +121,6 @@ private:
int formulaBaseHeightF1;
int formulaBaseHeightF2;
VisToolArc *path;
qreal angleF1;
qreal angleF2;

View File

@ -43,8 +43,7 @@
* @param parent parent widget
*/
DialogBisector::DialogBisector(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogBisector), formula(QString()), formulaBaseHeight(0),
line(nullptr)
:DialogTool(data, toolId, parent), ui(new Ui::DialogBisector), formula(QString()), formulaBaseHeight(0)
{
ui->setupUi(this);
InitFormulaUI(ui);
@ -74,7 +73,7 @@ DialogBisector::DialogBisector(const VContainer *data, const quint32 &toolId, QW
connect(ui->comboBoxThirdPoint, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogBisector::PointNameChanged);
line = new VisToolBisector(data);
vis = new VisToolBisector(data);
}
//---------------------------------------------------------------------------------------------------------------------
@ -124,14 +123,7 @@ void DialogBisector::FXLength()
//---------------------------------------------------------------------------------------------------------------------
void DialogBisector::ShowVisualization()
{
if (prepare == false)
{
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr)
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolBisector::SetFactor);
scene->addItem(line);
line->RefreshGeometry();
}
AddVisualization<VisToolBisector>();
}
//---------------------------------------------------------------------------------------------------------------------
@ -143,10 +135,7 @@ void DialogBisector::DeployFormulaTextEdit()
//---------------------------------------------------------------------------------------------------------------------
DialogBisector::~DialogBisector()
{
if (qApp->getCurrentScene()->items().contains(line))
{ // In some cases scene delete object yourself. If not make check program will crash.
delete line;
}
DeleteVisualization<VisToolBisector>();
delete ui;
}
@ -162,6 +151,9 @@ void DialogBisector::ChosenObject(quint32 id, const SceneObject &type)
{
if (type == SceneObject::Point)
{
VisToolBisector *line = qobject_cast<VisToolBisector *>(vis);
SCASSERT(line != nullptr);
switch (number)
{
case 0:
@ -228,7 +220,7 @@ void DialogBisector::SetPointName(const QString &value)
void DialogBisector::SetTypeLine(const QString &value)
{
ChangeCurrentData(ui->comboBoxLineType, value);
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
vis->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
}
//---------------------------------------------------------------------------------------------------------------------
@ -245,7 +237,11 @@ void DialogBisector::SetFormula(const QString &value)
this->DeployFormulaTextEdit();
}
ui->plainTextEditFormula->setPlainText(formula);
VisToolBisector *line = qobject_cast<VisToolBisector *>(vis);
SCASSERT(line != nullptr);
line->setLength(formula);
MoveCursorToEnd(ui->plainTextEditFormula);
}
@ -257,6 +253,9 @@ void DialogBisector::SetFormula(const QString &value)
void DialogBisector::SetFirstPointId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxFirstPoint, value);
VisToolBisector *line = qobject_cast<VisToolBisector *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(value);
}
@ -268,6 +267,9 @@ void DialogBisector::SetFirstPointId(const quint32 &value)
void DialogBisector::SetSecondPointId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxSecondPoint, value);
VisToolBisector *line = qobject_cast<VisToolBisector *>(vis);
SCASSERT(line != nullptr);
line->setPoint2Id(value);
}
@ -279,6 +281,9 @@ void DialogBisector::SetSecondPointId(const quint32 &value)
void DialogBisector::SetThirdPointId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxThirdPoint, value);
VisToolBisector *line = qobject_cast<VisToolBisector *>(vis);
SCASSERT(line != nullptr);
line->setPoint3Id(value);
}
@ -302,6 +307,9 @@ void DialogBisector::SaveData()
formula = ui->plainTextEditFormula->toPlainText();
formula.replace("\n", " ");
VisToolBisector *line = qobject_cast<VisToolBisector *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(GetFirstPointId());
line->setPoint2Id(GetSecondPointId());
line->setPoint3Id(GetThirdPointId());

View File

@ -36,8 +36,6 @@ namespace Ui
class DialogBisector;
}
class VisToolBisector;
/**
* @brief The DialogBisector class dialog for ToolBisector. Help create point and edit option.
*/
@ -47,7 +45,7 @@ class DialogBisector : public DialogTool
public:
DialogBisector(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogBisector();
virtual ~DialogBisector();
void SetPointName(const QString &value);
@ -98,8 +96,6 @@ private:
/** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight;
VisToolBisector *line;
};
#endif // DIALOGBISECTOR_H

View File

@ -40,8 +40,8 @@
//---------------------------------------------------------------------------------------------------------------------
DialogCurveIntersectAxis::DialogCurveIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogCurveIntersectAxis),
formulaAngle(QString()), formulaBaseHeightAngle(0), line(nullptr)
:DialogTool(data, toolId, parent), ui(new Ui::DialogCurveIntersectAxis), formulaAngle(QString()),
formulaBaseHeightAngle(0)
{
ui->setupUi(this);
@ -66,16 +66,13 @@ DialogCurveIntersectAxis::DialogCurveIntersectAxis(const VContainer *data, const
connect(ui->pushButtonGrowLengthAngle, &QPushButton::clicked, this, &DialogCurveIntersectAxis::DeployAngleTextEdit);
connect(timerFormula, &QTimer::timeout, this, &DialogCurveIntersectAxis::EvalAngle);
line = new VisToolCurveIntersectAxis(data);
vis = new VisToolCurveIntersectAxis(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogCurveIntersectAxis::~DialogCurveIntersectAxis()
{
if (qApp->getCurrentScene()->items().contains(line))
{ // In some cases scene delete object yourself. If not make check program will crash.
delete line;
}
DeleteVisualization<VisToolCurveIntersectAxis>();
delete ui;
}
@ -96,7 +93,7 @@ QString DialogCurveIntersectAxis::GetTypeLine() const
void DialogCurveIntersectAxis::SetTypeLine(const QString &value)
{
ChangeCurrentData(ui->comboBoxLineType, value);
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
vis->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
}
//---------------------------------------------------------------------------------------------------------------------
@ -116,7 +113,11 @@ void DialogCurveIntersectAxis::SetAngle(const QString &value)
this->DeployAngleTextEdit();
}
ui->plainTextEditFormula->setPlainText(formulaAngle);
VisToolCurveIntersectAxis *line = qobject_cast<VisToolCurveIntersectAxis *>(vis);
SCASSERT(line != nullptr);
line->SetAngle(formulaAngle);
MoveCursorToEnd(ui->plainTextEditFormula);
}
@ -130,6 +131,9 @@ quint32 DialogCurveIntersectAxis::GetBasePointId() const
void DialogCurveIntersectAxis::SetBasePointId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxAxisPoint, value);
VisToolCurveIntersectAxis *line = qobject_cast<VisToolCurveIntersectAxis *>(vis);
SCASSERT(line != nullptr);
line->setAxisPointId(value);
}
@ -143,6 +147,9 @@ quint32 DialogCurveIntersectAxis::getCurveId() const
void DialogCurveIntersectAxis::setCurveId(const quint32 &value)
{
setCurrentCurveId(ui->comboBoxCurve, value);
VisToolCurveIntersectAxis *line = qobject_cast<VisToolCurveIntersectAxis *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(value);
}
@ -179,6 +186,10 @@ void DialogCurveIntersectAxis::ShowDialog(bool click)
}
}
this->setModal(true);
VisToolCurveIntersectAxis *line = qobject_cast<VisToolCurveIntersectAxis *>(vis);
SCASSERT(line != nullptr);
this->SetAngle(line->Angle());//Show in dialog angle what user choose
emit ToolTip("");
timerFormula->start();
@ -191,6 +202,9 @@ void DialogCurveIntersectAxis::ChosenObject(quint32 id, const SceneObject &type)
{
if (prepare == false)// After first choose we ignore all objects
{
VisToolCurveIntersectAxis *line = qobject_cast<VisToolCurveIntersectAxis *>(vis);
SCASSERT(line != nullptr);
switch (number)
{
case (0):
@ -255,15 +269,7 @@ void DialogCurveIntersectAxis::FXAngle()
//---------------------------------------------------------------------------------------------------------------------
void DialogCurveIntersectAxis::ShowVisualization()
{
if (prepare == false)
{
//TODO move to parent class!
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr)
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolCurveIntersectAxis::SetFactor);
scene->addItem(line);
line->RefreshGeometry();
}
AddVisualization<VisToolCurveIntersectAxis>();
}
//---------------------------------------------------------------------------------------------------------------------
@ -274,6 +280,9 @@ void DialogCurveIntersectAxis::SaveData()
formulaAngle = ui->plainTextEditFormula->toPlainText();
formulaAngle.replace("\n", " ");
VisToolCurveIntersectAxis *line = qobject_cast<VisToolCurveIntersectAxis *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(getCurveId());
line->setAxisPointId(GetBasePointId());
line->SetAngle(formulaAngle);

View File

@ -36,15 +36,13 @@ namespace Ui
class DialogCurveIntersectAxis;
}
class VisToolCurveIntersectAxis;
class DialogCurveIntersectAxis : public DialogTool
{
Q_OBJECT
public:
DialogCurveIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogCurveIntersectAxis();
virtual ~DialogCurveIntersectAxis();
void SetPointName(const QString &value);
@ -83,8 +81,6 @@ private:
QString formulaAngle;
int formulaBaseHeightAngle;
VisToolCurveIntersectAxis *line;
};
#endif // DIALOGCURVEINTERSECTAXIS_H

View File

@ -43,8 +43,7 @@
* @param parent parent widget
*/
DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidget *parent)
: DialogTool(data, toolId, parent), ui(new Ui::DialogCutArc), formula(QString()), formulaBaseHeight(0),
path(nullptr)
: DialogTool(data, toolId, parent), ui(new Ui::DialogCutArc), formula(QString()), formulaBaseHeight(0)
{
ui->setupUi(this);
InitFormulaUI(ui);
@ -65,7 +64,7 @@ DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidge
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutArc::FormulaTextChanged);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutArc::DeployFormulaTextEdit);
path = new VisToolCutArc(data);
vis = new VisToolCutArc(data);
}
//---------------------------------------------------------------------------------------------------------------------
@ -90,14 +89,7 @@ void DialogCutArc::FXLength()
//---------------------------------------------------------------------------------------------------------------------
void DialogCutArc::ShowVisualization()
{
if (prepare == false)
{
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr)
connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor);
scene->addItem(path);
path->RefreshGeometry();
}
AddVisualization<VisToolCutArc>();
}
//---------------------------------------------------------------------------------------------------------------------
@ -109,10 +101,7 @@ void DialogCutArc::DeployFormulaTextEdit()
//---------------------------------------------------------------------------------------------------------------------
DialogCutArc::~DialogCutArc()
{
if (qApp->getCurrentScene()->items().contains(path))
{ // In some cases scene delete object yourself. If not make check program will crash.
delete path;
}
DeleteVisualization<VisToolCutArc>();
delete ui;
}
@ -130,7 +119,7 @@ void DialogCutArc::ChosenObject(quint32 id, const SceneObject &type)
{
if (SetObject(id, ui->comboBoxArc, ""))
{
path->VisualMode(id);
vis->VisualMode(id);
prepare = true;
this->setModal(true);
this->show();
@ -146,6 +135,9 @@ void DialogCutArc::SaveData()
formula = ui->plainTextEditFormula->toPlainText();
formula.replace("\n", " ");
VisToolCutArc *path = qobject_cast<VisToolCutArc *>(vis);
SCASSERT(path != nullptr);
path->setPoint1Id(getArcId());
path->setLength(formula);
path->RefreshGeometry();
@ -166,6 +158,9 @@ void DialogCutArc::closeEvent(QCloseEvent *event)
void DialogCutArc::setArcId(const quint32 &value)
{
setCurrentArcId(ui->comboBoxArc, value, ComboBoxCutArc::CutArc);
VisToolCutArc *path = qobject_cast<VisToolCutArc *>(vis);
SCASSERT(path != nullptr);
path->setPoint1Id(value);
}
@ -195,7 +190,11 @@ void DialogCutArc::SetFormula(const QString &value)
this->DeployFormulaTextEdit();
}
ui->plainTextEditFormula->setPlainText(formula);
VisToolCutArc *path = qobject_cast<VisToolCutArc *>(vis);
SCASSERT(path != nullptr);
path->setLength(formula);
MoveCursorToEnd(ui->plainTextEditFormula);
}

View File

@ -36,8 +36,6 @@ namespace Ui
class DialogCutArc;
}
class VisToolCutArc;
/**
* @brief The DialogCutArc class dialog for ToolCutArc.
*/
@ -47,7 +45,7 @@ class DialogCutArc : public DialogTool
public:
DialogCutArc(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogCutArc();
virtual ~DialogCutArc();
void SetPointName(const QString &value);
@ -87,8 +85,6 @@ private:
/** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight;
VisToolCutArc *path;
};
#endif // DIALOGCUTARC_H

View File

@ -42,8 +42,7 @@
* @param parent parent widget
*/
DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSpline), formula(QString()), formulaBaseHeight(0),
path(nullptr)
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSpline), formula(QString()), formulaBaseHeight(0)
{
ui->setupUi(this);
InitFormulaUI(ui);
@ -64,16 +63,13 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId,
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutSpline::FormulaChanged);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSpline::DeployFormulaTextEdit);
path = new VisToolCutSpline(data);
vis = new VisToolCutSpline(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogCutSpline::~DialogCutSpline()
{
if (qApp->getCurrentScene()->items().contains(path))
{ // In some cases scene delete object yourself. If not make check program will crash.
delete path;
}
DeleteVisualization<VisToolCutSpline>();
delete ui;
}
@ -103,7 +99,11 @@ void DialogCutSpline::SetFormula(const QString &value)
this->DeployFormulaTextEdit();
}
ui->plainTextEditFormula->setPlainText(formula);
VisToolCutSpline *path = qobject_cast<VisToolCutSpline *>(vis);
SCASSERT(path != nullptr);
path->setLength(formula);
MoveCursorToEnd(ui->plainTextEditFormula);
}
@ -115,6 +115,9 @@ void DialogCutSpline::SetFormula(const QString &value)
void DialogCutSpline::setSplineId(const quint32 &value)
{
setCurrentSplineId(ui->comboBoxSpline, value, ComboBoxCutSpline::CutSpline);
VisToolCutSpline *path = qobject_cast<VisToolCutSpline *>(vis);
SCASSERT(path != nullptr);
path->setPoint1Id(value);
}
@ -144,7 +147,7 @@ void DialogCutSpline::ChosenObject(quint32 id, const SceneObject &type)
{
if (SetObject(id, ui->comboBoxSpline, ""))
{
path->VisualMode(id);
vis->VisualMode(id);
prepare = true;
this->setModal(true);
this->show();
@ -160,6 +163,9 @@ void DialogCutSpline::SaveData()
formula = ui->plainTextEditFormula->toPlainText();
formula.replace("\n", " ");
VisToolCutSpline *path = qobject_cast<VisToolCutSpline *>(vis);
SCASSERT(path != nullptr);
path->setPoint1Id(getSplineId());
path->setLength(formula);
path->RefreshGeometry();
@ -194,14 +200,7 @@ void DialogCutSpline::FXLength()
//---------------------------------------------------------------------------------------------------------------------
void DialogCutSpline::ShowVisualization()
{
if (prepare == false)
{
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr)
connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor);
scene->addItem(path);
path->RefreshGeometry();
}
AddVisualization<VisToolCutSpline>();
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -36,8 +36,6 @@ namespace Ui
class DialogCutSpline;
}
class VisToolCutSpline;
/**
* @brief The DialogCutSpline class dialog for ToolCutSpline.
*/
@ -46,7 +44,7 @@ class DialogCutSpline : public DialogTool
Q_OBJECT
public:
DialogCutSpline(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogCutSpline();
virtual ~DialogCutSpline();
void SetPointName(const QString &value);
@ -83,8 +81,6 @@ private:
/** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight;
VisToolCutSpline *path;
};
#endif // DIALOGCUTSPLINE_H

View File

@ -42,8 +42,7 @@
* @param parent parent widget
*/
DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSplinePath), formula(QString()), formulaBaseHeight(0),
path(nullptr)
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSplinePath), formula(QString()), formulaBaseHeight(0)
{
ui->setupUi(this);
InitFormulaUI(ui);
@ -64,16 +63,13 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 &
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, &DialogCutSplinePath::FormulaChanged);
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogCutSplinePath::DeployFormulaTextEdit);
path = new VisToolCutSplinePath(data);
vis = new VisToolCutSplinePath(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogCutSplinePath::~DialogCutSplinePath()
{
if (qApp->getCurrentScene()->items().contains(path))
{ // In some cases scene delete object yourself. If not make check program will crash.
delete path;
}
DeleteVisualization<VisToolCutSplinePath>();
delete ui;
}
@ -103,7 +99,11 @@ void DialogCutSplinePath::SetFormula(const QString &value)
this->DeployFormulaTextEdit();
}
ui->plainTextEditFormula->setPlainText(formula);
VisToolCutSplinePath *path = qobject_cast<VisToolCutSplinePath *>(vis);
SCASSERT(path != nullptr);
path->setLength(formula);
MoveCursorToEnd(ui->plainTextEditFormula);
}
@ -115,6 +115,9 @@ void DialogCutSplinePath::SetFormula(const QString &value)
void DialogCutSplinePath::setSplinePathId(const quint32 &value)
{
setCurrentSplinePathId(ui->comboBoxSplinePath, value, ComboBoxCutSpline::CutSpline);
VisToolCutSplinePath *path = qobject_cast<VisToolCutSplinePath *>(vis);
SCASSERT(path != nullptr);
path->setPoint1Id(value);
}
@ -144,7 +147,7 @@ void DialogCutSplinePath::ChosenObject(quint32 id, const SceneObject &type)
{
if (SetObject(id, ui->comboBoxSplinePath, ""))
{
path->VisualMode(id);
vis->VisualMode(id);
prepare = true;
this->setModal(true);
this->show();
@ -160,6 +163,9 @@ void DialogCutSplinePath::SaveData()
formula = ui->plainTextEditFormula->toPlainText();
formula.replace("\n", " ");
VisToolCutSplinePath *path = qobject_cast<VisToolCutSplinePath *>(vis);
SCASSERT(path != nullptr);
path->setPoint1Id(getSplinePathId());
path->setLength(formula);
path->RefreshGeometry();
@ -194,14 +200,7 @@ void DialogCutSplinePath::FXLength()
//---------------------------------------------------------------------------------------------------------------------
void DialogCutSplinePath::ShowVisualization()
{
if (prepare == false)
{
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr)
connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor);
scene->addItem(path);
path->RefreshGeometry();
}
AddVisualization<VisToolCutSplinePath>();
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -36,8 +36,6 @@ namespace Ui
class DialogCutSplinePath;
}
class VisToolCutSplinePath;
/**
* @brief The DialogCutSplinePath class dialog for ToolCutSplinePath.
*/
@ -46,7 +44,7 @@ class DialogCutSplinePath : public DialogTool
Q_OBJECT
public:
DialogCutSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogCutSplinePath();
virtual ~DialogCutSplinePath();
void SetPointName(const QString &value);
@ -83,8 +81,6 @@ private:
/** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight;
VisToolCutSplinePath *path;
};
#endif // DIALOGCUTSPLINEPATH_H

View File

@ -49,7 +49,7 @@ class DialogEditWrongFormula : public DialogTool
Q_OBJECT
public:
explicit DialogEditWrongFormula(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogEditWrongFormula();
virtual ~DialogEditWrongFormula();
QString GetFormula() const;
void SetFormula(const QString &value);

View File

@ -45,7 +45,7 @@
*/
DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogEndLine),
formulaLength(QString()), formulaAngle(QString()), formulaBaseHeight(0), formulaBaseHeightAngle(0), line(nullptr)
formulaLength(QString()), formulaAngle(QString()), formulaBaseHeight(0), formulaBaseHeightAngle(0)
{
ui->setupUi(this);
InitFormulaUI(ui);
@ -78,7 +78,7 @@ DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWid
connect(timerFormula, &QTimer::timeout, this, &DialogEndLine::EvalAngle);
line = new VisToolEndLine(data);
vis = new VisToolEndLine(data);
}
//---------------------------------------------------------------------------------------------------------------------
@ -158,8 +158,8 @@ void DialogEndLine::ChosenObject(quint32 id, const SceneObject &type)
{
if (SetObject(id, ui->comboBoxBasePoint, ""))
{
line->VisualMode(id);
connect(line, &VisToolEndLine::ToolTip, this, &DialogTool::ShowVisToolTip);
vis->VisualMode(id);
connect(vis, &Visualization::ToolTip, this, &DialogTool::ShowVisToolTip);
prepare = true;
}
}
@ -185,7 +185,7 @@ void DialogEndLine::SetPointName(const QString &value)
void DialogEndLine::SetTypeLine(const QString &value)
{
ChangeCurrentData(ui->comboBoxLineType, value);
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
vis->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
}
//---------------------------------------------------------------------------------------------------------------------
@ -203,7 +203,11 @@ void DialogEndLine::SetFormula(const QString &value)
this->DeployFormulaTextEdit();
}
ui->plainTextEditFormula->setPlainText(formulaLength);
VisToolEndLine *line = qobject_cast<VisToolEndLine *>(vis);
SCASSERT(line != nullptr);
line->setLength(formulaLength);
MoveCursorToEnd(ui->plainTextEditFormula);
}
@ -222,7 +226,11 @@ void DialogEndLine::SetAngle(const QString &value)
this->DeployAngleTextEdit();
}
ui->plainTextEditAngle->setPlainText(formulaAngle);
VisToolEndLine *line = qobject_cast<VisToolEndLine *>(vis);
SCASSERT(line != nullptr);
line->SetAngle(formulaAngle);
MoveCursorToEnd(ui->plainTextEditAngle);
}
@ -234,6 +242,9 @@ void DialogEndLine::SetAngle(const QString &value)
void DialogEndLine::SetBasePointId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxBasePoint, value);
VisToolEndLine *line = qobject_cast<VisToolEndLine *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(value);
}
@ -274,6 +285,10 @@ void DialogEndLine::ShowDialog(bool click)
}
}
this->setModal(true);
VisToolEndLine *line = qobject_cast<VisToolEndLine *>(vis);
SCASSERT(line != nullptr);
this->SetAngle(line->Angle());//Show in dialog angle what user choose
emit ToolTip("");
timerFormula->start();
@ -284,15 +299,7 @@ void DialogEndLine::ShowDialog(bool click)
//---------------------------------------------------------------------------------------------------------------------
void DialogEndLine::ShowVisualization()
{
if (prepare == false)
{
//TODO move to parent class!
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr)
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolEndLine::SetFactor);
scene->addItem(line);
line->RefreshGeometry();
}
AddVisualization<VisToolEndLine>();
}
//---------------------------------------------------------------------------------------------------------------------
@ -306,6 +313,9 @@ void DialogEndLine::SaveData()
formulaAngle = ui->plainTextEditAngle->toPlainText();
formulaAngle.replace("\n", " ");
VisToolEndLine *line = qobject_cast<VisToolEndLine *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(GetBasePointId());
line->setLength(formulaLength);
line->SetAngle(formulaAngle);
@ -324,10 +334,7 @@ void DialogEndLine::closeEvent(QCloseEvent *event)
//---------------------------------------------------------------------------------------------------------------------
DialogEndLine::~DialogEndLine()
{
if (qApp->getCurrentScene()->items().contains(line))
{ // In some cases scene delete object yourself. If not make check program will crash.
delete line;
}
DeleteVisualization<VisToolEndLine>();
delete ui;
}

View File

@ -36,8 +36,6 @@ namespace Ui
class DialogEndLine;
}
class VisToolEndLine;
/**
* @brief The DialogEndLine class dialog for ToolEndLine. Help create point and edit option.
*/
@ -46,7 +44,7 @@ class DialogEndLine : public DialogTool
Q_OBJECT
public:
DialogEndLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogEndLine();
virtual ~DialogEndLine();
void SetPointName(const QString &value);
@ -105,8 +103,6 @@ private:
/** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight;
int formulaBaseHeightAngle;
VisToolEndLine *line;
};
#endif // DIALOGENDLINE_H

View File

@ -42,7 +42,7 @@
* @param parent parent widget
*/
DialogHeight::DialogHeight(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogHeight), line(nullptr)
:DialogTool(data, toolId, parent), ui(new Ui::DialogHeight)
{
ui->setupUi(this);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
@ -64,16 +64,13 @@ DialogHeight::DialogHeight(const VContainer *data, const quint32 &toolId, QWidge
connect(ui->comboBoxP2Line, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogHeight::PointNameChanged);
line = new VisToolHeight(data);
vis = new VisToolHeight(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogHeight::~DialogHeight()
{
if (qApp->getCurrentScene()->items().contains(line))
{ // In some cases scene delete object yourself. If not make check program will crash.
delete line;
}
DeleteVisualization<VisToolHeight>();
delete ui;
}
@ -96,7 +93,7 @@ void DialogHeight::SetPointName(const QString &value)
void DialogHeight::SetTypeLine(const QString &value)
{
ChangeCurrentData(ui->comboBoxLineType, value);
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
vis->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
}
//---------------------------------------------------------------------------------------------------------------------
@ -107,6 +104,9 @@ void DialogHeight::SetTypeLine(const QString &value)
void DialogHeight::SetBasePointId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxBasePoint, value);
VisToolHeight *line = qobject_cast<VisToolHeight *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(value);
}
@ -118,6 +118,9 @@ void DialogHeight::SetBasePointId(const quint32 &value)
void DialogHeight::SetP1LineId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxP1Line, value);
VisToolHeight *line = qobject_cast<VisToolHeight *>(vis);
SCASSERT(line != nullptr);
line->setLineP1Id(value);
}
@ -129,6 +132,9 @@ void DialogHeight::SetP1LineId(const quint32 &value)
void DialogHeight::SetP2LineId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxP2Line, value);
VisToolHeight *line = qobject_cast<VisToolHeight *>(vis);
SCASSERT(line != nullptr);
line->setLineP2Id(value);
}
@ -156,6 +162,9 @@ void DialogHeight::ChosenObject(quint32 id, const SceneObject &type)
{
if (type == SceneObject::Point)
{
VisToolHeight *line = qobject_cast<VisToolHeight *>(vis);
SCASSERT(line != nullptr);
switch (number)
{
case (0):
@ -208,6 +217,9 @@ void DialogHeight::SaveData()
{
pointName = ui->lineEditNamePoint->text();
VisToolHeight *line = qobject_cast<VisToolHeight *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(GetBasePointId());
line->setLineP1Id(GetP1LineId());
line->setLineP2Id(GetP2LineId());
@ -252,14 +264,7 @@ void DialogHeight::PointNameChanged()
//---------------------------------------------------------------------------------------------------------------------
void DialogHeight::ShowVisualization()
{
if (prepare == false)
{
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr)
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor);
scene->addItem(line);
line->RefreshGeometry();
}
AddVisualization<VisLine>();
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -36,8 +36,6 @@ namespace Ui
class DialogHeight;
}
class VisToolHeight;
/**
* @brief The DialogHeight class dialog for ToolHeight. Help create point and edit option.
*/
@ -46,7 +44,7 @@ class DialogHeight : public DialogTool
Q_OBJECT
public:
DialogHeight(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogHeight();
virtual ~DialogHeight();
void SetPointName(const QString &value);
@ -78,8 +76,6 @@ private:
/** @brief ui keeps information about user interface */
Ui::DialogHeight *ui;
VisToolHeight *line;
};
#endif // DIALOGHEIGHT_H

View File

@ -43,7 +43,7 @@
* @param parent parent widget
*/
DialogLine::DialogLine(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogLine), line(nullptr)
:DialogTool(data, toolId, parent), ui(new Ui::DialogLine)
{
ui->setupUi(this);
InitOkCancelApply(ui);
@ -63,16 +63,13 @@ DialogLine::DialogLine(const VContainer *data, const quint32 &toolId, QWidget *p
connect(ui->comboBoxSecondPoint, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogLine::PointNameChanged);
line = new VisToolLine(data);
vis = new VisToolLine(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogLine::~DialogLine()
{
if (qApp->getCurrentScene()->items().contains(line))
{ // In some cases scene delete object yourself. If not make check program will crash.
delete line;
}
DeleteVisualization<VisToolLine>();
delete ui;
}
@ -84,6 +81,9 @@ DialogLine::~DialogLine()
void DialogLine::SetSecondPoint(const quint32 &value)
{
setCurrentPointId(ui->comboBoxSecondPoint, value);
VisToolLine *line = qobject_cast<VisToolLine *>(vis);
SCASSERT(line != nullptr);
line->setPoint2Id(value);
}
@ -95,7 +95,7 @@ void DialogLine::SetSecondPoint(const quint32 &value)
void DialogLine::SetTypeLine(const QString &value)
{
ChangeCurrentData(ui->comboBoxLineType, value);
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
vis->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
}
//---------------------------------------------------------------------------------------------------------------------
@ -118,6 +118,9 @@ void DialogLine::SetLineColor(const QString &value)
void DialogLine::SetFirstPoint(const quint32 &value)
{
setCurrentPointId(ui->comboBoxFirstPoint, value);
VisToolLine *line = qobject_cast<VisToolLine *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(value);
}
@ -143,19 +146,15 @@ void DialogLine::PointNameChanged()
//---------------------------------------------------------------------------------------------------------------------
void DialogLine::ShowVisualization()
{
if (prepare == false)
{
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr)
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolLine::SetFactor);
scene->addItem(line);
line->RefreshGeometry();
}
AddVisualization<VisToolLine>();
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLine::SaveData()
{
VisToolLine *line = qobject_cast<VisToolLine *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(GetFirstPoint());
line->setPoint2Id(GetSecondPoint());
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine()));
@ -180,7 +179,7 @@ void DialogLine::ChosenObject(quint32 id, const SceneObject &type)
if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point")))
{
number++;
line->VisualMode(id);
vis->VisualMode(id);
}
break;
case 1:

View File

@ -36,8 +36,6 @@ namespace Ui
class DialogLine;
}
class VisToolLine;
/**
* @brief The DialogLine class dialog for ToolLine. Help create line and edit option.
*/
@ -46,7 +44,7 @@ class DialogLine : public DialogTool
Q_OBJECT
public:
DialogLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogLine();
virtual ~DialogLine();
quint32 GetFirstPoint() const;
void SetFirstPoint(const quint32 &value);
@ -73,9 +71,6 @@ private:
/** @brief ui keeps information about user interface */
Ui::DialogLine *ui;
VisToolLine *line;
};
#endif // DIALOGLINE_H

View File

@ -42,7 +42,7 @@
* @param parent parent widget
*/
DialogLineIntersect::DialogLineIntersect(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersect), flagPoint(true), line(nullptr)
:DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersect), flagPoint(true)
{
ui->setupUi(this);
number = 0;
@ -65,16 +65,13 @@ DialogLineIntersect::DialogLineIntersect(const VContainer *data, const quint32 &
connect(ui->comboBoxP2Line2, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogLineIntersect::PointNameChanged);
line = new VisToolLineIntersect(data);
vis = new VisToolLineIntersect(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogLineIntersect::~DialogLineIntersect()
{
if (qApp->getCurrentScene()->items().contains(line))
{ // In some cases scene delete object yourself. If not make check program will crash.
delete line;
}
DeleteVisualization<VisToolLineIntersect>();
delete ui;
}
@ -90,6 +87,9 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type)
{
if (type == SceneObject::Point)
{
VisToolLineIntersect *line = qobject_cast<VisToolLineIntersect *>(vis);
SCASSERT(line != nullptr);
switch (number)
{
case 0:
@ -165,6 +165,9 @@ void DialogLineIntersect::SaveData()
{
pointName = ui->lineEditNamePoint->text();
VisToolLineIntersect *line = qobject_cast<VisToolLineIntersect *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(GetP1Line1());
line->setLine1P2Id(GetP2Line1());
line->setLine2P1Id(GetP1Line2());
@ -227,14 +230,7 @@ void DialogLineIntersect::PointNameChanged()
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersect::ShowVisualization()
{
if (prepare == false)
{
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr)
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor);
scene->addItem(line);
line->RefreshGeometry();
}
AddVisualization<VisToolLineIntersect>();
}
//---------------------------------------------------------------------------------------------------------------------
@ -281,6 +277,9 @@ bool DialogLineIntersect::CheckIntersecion()
void DialogLineIntersect::SetP2Line2(const quint32 &value)
{
setCurrentPointId(ui->comboBoxP2Line2, value);
VisToolLineIntersect *line = qobject_cast<VisToolLineIntersect *>(vis);
SCASSERT(line != nullptr);
line->setLine2P2Id(value);
}
@ -292,6 +291,9 @@ void DialogLineIntersect::SetP2Line2(const quint32 &value)
void DialogLineIntersect::SetP1Line2(const quint32 &value)
{
setCurrentPointId(ui->comboBoxP1Line2, value);
VisToolLineIntersect *line = qobject_cast<VisToolLineIntersect *>(vis);
SCASSERT(line != nullptr);
line->setLine2P1Id(value);
}
@ -303,6 +305,9 @@ void DialogLineIntersect::SetP1Line2(const quint32 &value)
void DialogLineIntersect::SetP2Line1(const quint32 &value)
{
setCurrentPointId(ui->comboBoxP2Line1, value);
VisToolLineIntersect *line = qobject_cast<VisToolLineIntersect *>(vis);
SCASSERT(line != nullptr);
line->setLine1P2Id(value);
}
@ -314,6 +319,9 @@ void DialogLineIntersect::SetP2Line1(const quint32 &value)
void DialogLineIntersect::SetP1Line1(const quint32 &value)
{
setCurrentPointId(ui->comboBoxP1Line1, value);
VisToolLineIntersect *line = qobject_cast<VisToolLineIntersect *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(value);
}

View File

@ -36,8 +36,6 @@ namespace Ui
class DialogLineIntersect;
}
class VisToolLineIntersect;
/**
* @brief The DialogLineIntersect class dialog for ToolLineIntersect. Help create point and edit option.
*/
@ -46,7 +44,7 @@ class DialogLineIntersect : public DialogTool
Q_OBJECT
public:
DialogLineIntersect(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogLineIntersect();
virtual ~DialogLineIntersect();
quint32 GetP1Line1() const;
void SetP1Line1(const quint32 &value);
@ -80,8 +78,6 @@ private:
/** @brief flagPoint keep state of point */
bool flagPoint;
VisToolLineIntersect *line;
virtual void CheckState();
bool CheckIntersecion();
};

View File

@ -41,7 +41,7 @@
//---------------------------------------------------------------------------------------------------------------------
DialogLineIntersectAxis::DialogLineIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersectAxis), formulaAngle(QString()),
formulaBaseHeightAngle(0), line(nullptr)
formulaBaseHeightAngle(0)
{
ui->setupUi(this);
InitFormulaUI(ui);
@ -74,16 +74,13 @@ DialogLineIntersectAxis::DialogLineIntersectAxis(const VContainer *data, const q
connect(ui->comboBoxAxisPoint, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogLineIntersectAxis::PointNameChanged);
line = new VisToolLineIntersectAxis(data);
vis = new VisToolLineIntersectAxis(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogLineIntersectAxis::~DialogLineIntersectAxis()
{
if (qApp->getCurrentScene()->items().contains(line))
{ // In some cases scene delete object yourself. If not make check program will crash.
delete line;
}
DeleteVisualization<VisToolLineIntersectAxis>();
delete ui;
}
@ -104,7 +101,7 @@ QString DialogLineIntersectAxis::GetTypeLine() const
void DialogLineIntersectAxis::SetTypeLine(const QString &value)
{
ChangeCurrentData(ui->comboBoxLineType, value);
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
vis->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
}
//---------------------------------------------------------------------------------------------------------------------
@ -124,7 +121,11 @@ void DialogLineIntersectAxis::SetAngle(const QString &value)
this->DeployAngleTextEdit();
}
ui->plainTextEditFormula->setPlainText(formulaAngle);
VisToolLineIntersectAxis *line = qobject_cast<VisToolLineIntersectAxis *>(vis);
SCASSERT(line != nullptr);
line->SetAngle(formulaAngle);
MoveCursorToEnd(ui->plainTextEditFormula);
}
@ -138,6 +139,9 @@ quint32 DialogLineIntersectAxis::GetBasePointId() const
void DialogLineIntersectAxis::SetBasePointId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxAxisPoint, value);
VisToolLineIntersectAxis *line = qobject_cast<VisToolLineIntersectAxis *>(vis);
SCASSERT(line != nullptr);
line->setAxisPointId(value);
}
@ -151,6 +155,9 @@ quint32 DialogLineIntersectAxis::GetFirstPointId() const
void DialogLineIntersectAxis::SetFirstPointId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxFirstLinePoint, value);
VisToolLineIntersectAxis *line = qobject_cast<VisToolLineIntersectAxis *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(value);
}
@ -164,6 +171,9 @@ quint32 DialogLineIntersectAxis::GetSecondPointId() const
void DialogLineIntersectAxis::SetSecondPointId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxSecondLinePoint, value);
VisToolLineIntersectAxis *line = qobject_cast<VisToolLineIntersectAxis *>(vis);
SCASSERT(line != nullptr);
line->setPoint2Id(value);
}
@ -200,6 +210,10 @@ void DialogLineIntersectAxis::ShowDialog(bool click)
}
}
this->setModal(true);
VisToolLineIntersectAxis *line = qobject_cast<VisToolLineIntersectAxis *>(vis);
SCASSERT(line != nullptr);
this->SetAngle(line->Angle());//Show in dialog angle what user choose
emit ToolTip("");
timerFormula->start();
@ -214,6 +228,9 @@ void DialogLineIntersectAxis::ChosenObject(quint32 id, const SceneObject &type)
{
if (type == SceneObject::Point)
{
VisToolLineIntersectAxis *line = qobject_cast<VisToolLineIntersectAxis *>(vis);
SCASSERT(line != nullptr);
switch (number)
{
case (0):
@ -319,15 +336,7 @@ void DialogLineIntersectAxis::FXAngle()
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::ShowVisualization()
{
if (prepare == false)
{
//TODO move to parent class!
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr)
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolLineIntersectAxis::SetFactor);
scene->addItem(line);
line->RefreshGeometry();
}
AddVisualization<VisToolLineIntersectAxis>();
}
//---------------------------------------------------------------------------------------------------------------------
@ -338,6 +347,9 @@ void DialogLineIntersectAxis::SaveData()
formulaAngle = ui->plainTextEditFormula->toPlainText();
formulaAngle.replace("\n", " ");
VisToolLineIntersectAxis *line = qobject_cast<VisToolLineIntersectAxis *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(GetFirstPointId());
line->setPoint2Id(GetSecondPointId());
line->setAxisPointId(GetBasePointId());

View File

@ -36,15 +36,13 @@ namespace Ui
class DialogLineIntersectAxis;
}
class VisToolLineIntersectAxis;
class DialogLineIntersectAxis : public DialogTool
{
Q_OBJECT
public:
DialogLineIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogLineIntersectAxis();
virtual ~DialogLineIntersectAxis();
void SetPointName(const QString &value);
@ -87,8 +85,6 @@ private:
QString formulaAngle;
int formulaBaseHeightAngle;
VisToolLineIntersectAxis *line;
};
#endif // DIALOGLINEINTERSECTAXIS_H

View File

@ -40,8 +40,7 @@
* @param parent parent widget
*/
DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogNormal), formula(QString()), angle(0), formulaBaseHeight(0),
line(nullptr)
:DialogTool(data, toolId, parent), ui(new Ui::DialogNormal), formula(QString()), angle(0), formulaBaseHeight(0)
{
ui->setupUi(this);
InitFormulaUI(ui);
@ -70,7 +69,7 @@ DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidge
connect(ui->comboBoxSecondPoint, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogNormal::PointNameChanged);
line = new VisToolNormal(data);
vis = new VisToolNormal(data);
}
//---------------------------------------------------------------------------------------------------------------------
@ -114,14 +113,7 @@ void DialogNormal::FXLength()
//---------------------------------------------------------------------------------------------------------------------
void DialogNormal::ShowVisualization()
{
if (prepare == false)
{
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr)
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor);
scene->addItem(line);
line->RefreshGeometry();
}
AddVisualization<VisToolNormal>();
}
//---------------------------------------------------------------------------------------------------------------------
@ -133,10 +125,7 @@ void DialogNormal::DeployFormulaTextEdit()
//---------------------------------------------------------------------------------------------------------------------
DialogNormal::~DialogNormal()
{
if (qApp->getCurrentScene()->items().contains(line))
{ // In some cases scene delete object yourself. If not make check program will crash.
delete line;
}
DeleteVisualization<VisToolNormal>();
delete ui;
}
@ -152,6 +141,9 @@ void DialogNormal::ChosenObject(quint32 id, const SceneObject &type)
{
if (type == SceneObject::Point)
{
VisToolNormal *line = qobject_cast<VisToolNormal *>(vis);
SCASSERT(line != nullptr);
switch (number)
{
case 0:
@ -189,6 +181,9 @@ void DialogNormal::SaveData()
formula.replace("\n", " ");
angle = ui->doubleSpinBoxAngle->value();
VisToolNormal *line = qobject_cast<VisToolNormal *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(GetFirstPointId());
line->setPoint2Id(GetSecondPointId());
line->setLength(formula);
@ -212,6 +207,9 @@ void DialogNormal::closeEvent(QCloseEvent *event)
void DialogNormal::SetSecondPointId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxSecondPoint, value);
VisToolNormal *line = qobject_cast<VisToolNormal *>(vis);
SCASSERT(line != nullptr);
line->setPoint2Id(value);
}
@ -235,6 +233,9 @@ void DialogNormal::SetLineColor(const QString &value)
void DialogNormal::SetFirstPointId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxFirstPoint, value);
VisToolNormal *line = qobject_cast<VisToolNormal *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(value);
}
@ -247,6 +248,9 @@ void DialogNormal::SetAngle(const qreal &value)
{
angle = value;
ui->doubleSpinBoxAngle->setValue(angle);
VisToolNormal *line = qobject_cast<VisToolNormal *>(vis);
SCASSERT(line != nullptr);
line->SetAngle(angle);
}
@ -264,7 +268,11 @@ void DialogNormal::SetFormula(const QString &value)
this->DeployFormulaTextEdit();
}
ui->plainTextEditFormula->setPlainText(formula);
VisToolNormal *line = qobject_cast<VisToolNormal *>(vis);
SCASSERT(line != nullptr);
line->setLength(formula);
MoveCursorToEnd(ui->plainTextEditFormula);
}
@ -276,7 +284,7 @@ void DialogNormal::SetFormula(const QString &value)
void DialogNormal::SetTypeLine(const QString &value)
{
ChangeCurrentData(ui->comboBoxLineType, value);
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
vis->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -36,8 +36,6 @@ namespace Ui
class DialogNormal;
}
class VisToolNormal;
/**
* @brief The DialogNormal class dialog for ToolNormal. Help create point and edit option.
*/
@ -46,7 +44,7 @@ class DialogNormal : public DialogTool
Q_OBJECT
public:
DialogNormal(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogNormal();
virtual ~DialogNormal();
void SetPointName(const QString &value);
@ -100,8 +98,6 @@ private:
/** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight;
VisToolNormal *line;
};
#endif // DIALOGNORMAL_H

View File

@ -42,8 +42,7 @@
* @param parent parent widget
*/
DialogPointOfContact::DialogPointOfContact(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfContact),
radius(QString()), formulaBaseHeight(0), line(nullptr)
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfContact), radius(QString()), formulaBaseHeight(0)
{
ui->setupUi(this);
InitFormulaUI(ui);
@ -71,16 +70,13 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, const quint32
connect(ui->comboBoxCenter, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogPointOfContact::PointNameChanged);
line = new VisToolPointOfContact(data);
vis = new VisToolPointOfContact(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogPointOfContact::~DialogPointOfContact()
{
if (qApp->getCurrentScene()->items().contains(line))
{ // In some cases scene delete object yourself. If not make check program will crash.
delete line;
}
DeleteVisualization<VisToolPointOfContact>();
delete ui;
}
@ -131,14 +127,7 @@ void DialogPointOfContact::FXRadius()
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfContact::ShowVisualization()
{
if (prepare == false)
{
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr)
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor);
scene->addItem(line);
line->RefreshGeometry();
}
AddVisualization<VisToolPointOfContact>();
}
//---------------------------------------------------------------------------------------------------------------------
@ -159,6 +148,9 @@ void DialogPointOfContact::ChosenObject(quint32 id, const SceneObject &type)
{
if (type == SceneObject::Point)
{
VisToolPointOfContact *line = qobject_cast<VisToolPointOfContact *>(vis);
SCASSERT(line != nullptr);
switch (number)
{
case 0:
@ -213,6 +205,9 @@ void DialogPointOfContact::SaveData()
radius = ui->plainTextEditFormula->toPlainText();
radius.replace("\n", " ");
VisToolPointOfContact *line = qobject_cast<VisToolPointOfContact *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(GetFirstPoint());
line->setLineP2Id(GetSecondPoint());
line->setRadiusId(getCenter());
@ -235,6 +230,9 @@ void DialogPointOfContact::closeEvent(QCloseEvent *event)
void DialogPointOfContact::SetSecondPoint(const quint32 &value)
{
setCurrentPointId(ui->comboBoxSecondPoint, value);
VisToolPointOfContact *line = qobject_cast<VisToolPointOfContact *>(vis);
SCASSERT(line != nullptr);
line->setLineP2Id(value);
}
@ -246,6 +244,9 @@ void DialogPointOfContact::SetSecondPoint(const quint32 &value)
void DialogPointOfContact::SetFirstPoint(const quint32 &value)
{
setCurrentPointId(ui->comboBoxFirstPoint, value);
VisToolPointOfContact *line = qobject_cast<VisToolPointOfContact *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(value);
}
@ -257,6 +258,9 @@ void DialogPointOfContact::SetFirstPoint(const quint32 &value)
void DialogPointOfContact::setCenter(const quint32 &value)
{
setCurrentPointId(ui->comboBoxCenter, value);
VisToolPointOfContact *line = qobject_cast<VisToolPointOfContact *>(vis);
SCASSERT(line != nullptr);
line->setRadiusId(value);
}
@ -274,7 +278,11 @@ void DialogPointOfContact::setRadius(const QString &value)
this->DeployFormulaTextEdit();
}
ui->plainTextEditFormula->setPlainText(radius);
VisToolPointOfContact *line = qobject_cast<VisToolPointOfContact *>(vis);
SCASSERT(line != nullptr);
line->setRadius(radius);
MoveCursorToEnd(ui->plainTextEditFormula);
}

View File

@ -37,8 +37,6 @@ namespace Ui
class DialogPointOfContact;
}
class VisToolPointOfContact;
/**
* @brief The DialogPointOfContact class dialog for ToolPointOfContact. Help create point and edit option.
*/
@ -92,8 +90,6 @@ private:
/** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight;
VisToolPointOfContact *line;
};
#endif // DIALOGPOINTOFCONTACT_H

View File

@ -42,7 +42,7 @@
* @param parent parent widget
*/
DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersection), line(nullptr)
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersection)
{
ui->setupUi(this);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
@ -60,17 +60,14 @@ DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, con
connect(ui->comboBoxSecondPoint, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogPointOfIntersection::PointNameChanged);
line = new VisToolPointOfIntersection(data);
line->VisualMode(NULL_ID);
vis = new VisToolPointOfIntersection(data);
vis->VisualMode(NULL_ID);
}
//---------------------------------------------------------------------------------------------------------------------
DialogPointOfIntersection::~DialogPointOfIntersection()
{
if (qApp->getCurrentScene()->items().contains(line))
{ // In some cases scene delete object yourself. If not make check program will crash.
delete line;
}
DeleteVisualization<VisToolPointOfIntersection>();
delete ui;
}
@ -82,6 +79,9 @@ DialogPointOfIntersection::~DialogPointOfIntersection()
void DialogPointOfIntersection::SetSecondPointId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxSecondPoint, value);
VisToolPointOfIntersection *line = qobject_cast<VisToolPointOfIntersection *>(vis);
SCASSERT(line != nullptr);
line->setPoint2Id(value);
}
@ -97,6 +97,9 @@ void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type
{
if (type == SceneObject::Point)
{
VisToolPointOfIntersection *line = qobject_cast<VisToolPointOfIntersection *>(vis);
SCASSERT(line != nullptr);
switch (number)
{
case 0:
@ -132,6 +135,9 @@ void DialogPointOfIntersection::SaveData()
{
pointName = ui->lineEditNamePoint->text();
VisToolPointOfIntersection *line = qobject_cast<VisToolPointOfIntersection *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(GetFirstPointId());
line->setPoint2Id(GetSecondPointId());
line->RefreshGeometry();
@ -162,9 +168,13 @@ void DialogPointOfIntersection::ShowVisualization()
if (prepare == false)
{
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr)
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor);
line->RefreshGeometry();
SCASSERT(scene != nullptr);
VisToolPointOfIntersection *toolVis = qobject_cast<VisToolPointOfIntersection *>(vis);
SCASSERT(toolVis != nullptr);
connect(scene, &VMainGraphicsScene::NewFactor, toolVis, &Visualization::SetFactor);
toolVis->RefreshGeometry();
}
}
@ -176,6 +186,9 @@ void DialogPointOfIntersection::ShowVisualization()
void DialogPointOfIntersection::SetFirstPointId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxFirstPoint, value);
VisToolPointOfIntersection *line = qobject_cast<VisToolPointOfIntersection *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(value);
}

View File

@ -36,8 +36,6 @@ namespace Ui
class DialogPointOfIntersection;
}
class VisToolPointOfIntersection;
/**
* @brief The DialogPointOfIntersection class dialog for ToolPointOfIntersection. Help create point and edit option.
*/
@ -46,7 +44,7 @@ class DialogPointOfIntersection : public DialogTool
Q_OBJECT
public:
DialogPointOfIntersection(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogPointOfIntersection();
virtual ~DialogPointOfIntersection();
void SetPointName(const QString &value);
@ -69,8 +67,6 @@ private:
/** @brief ui keeps information about user interface */
Ui::DialogPointOfIntersection *ui;
VisToolPointOfIntersection *line;
};
#endif // DIALOGPOINTOFINTERSECTION_H

View File

@ -44,7 +44,7 @@
*/
DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogShoulderPoint), formula(QString()),
formulaBaseHeight(0), line (nullptr)
formulaBaseHeight(0)
{
ui->setupUi(this);
InitFormulaUI(ui);
@ -74,7 +74,7 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 &
connect(ui->comboBoxP3, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogShoulderPoint::PointNameChanged);
line = new VisToolShoulderPoint(data);
vis = new VisToolShoulderPoint(data);
}
//---------------------------------------------------------------------------------------------------------------------
@ -124,14 +124,7 @@ void DialogShoulderPoint::FXLength()
//---------------------------------------------------------------------------------------------------------------------
void DialogShoulderPoint::ShowVisualization()
{
if (prepare == false)
{
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr)
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor);
scene->addItem(line);
line->RefreshGeometry();
}
AddVisualization<VisToolShoulderPoint>();
}
//---------------------------------------------------------------------------------------------------------------------
@ -143,10 +136,7 @@ void DialogShoulderPoint::DeployFormulaTextEdit()
//---------------------------------------------------------------------------------------------------------------------
DialogShoulderPoint::~DialogShoulderPoint()
{
if (qApp->getCurrentScene()->items().contains(line))
{ // In some cases scene delete object yourself. If not make check program will crash.
delete line;
}
DeleteVisualization<VisToolShoulderPoint>();
delete ui;
}
@ -162,6 +152,9 @@ void DialogShoulderPoint::ChosenObject(quint32 id, const SceneObject &type)
{
if (type == SceneObject::Point)
{
VisToolShoulderPoint *line = qobject_cast<VisToolShoulderPoint *>(vis);
SCASSERT(line != nullptr);
switch (number)
{
case 0:
@ -216,6 +209,9 @@ void DialogShoulderPoint::SaveData()
formula = ui->plainTextEditFormula->toPlainText();
formula.replace("\n", " ");
VisToolShoulderPoint *line = qobject_cast<VisToolShoulderPoint *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(GetP3());
line->setLineP1Id(GetP1Line());
line->setLineP2Id(GetP2Line());
@ -239,6 +235,9 @@ void DialogShoulderPoint::closeEvent(QCloseEvent *event)
void DialogShoulderPoint::SetP3(const quint32 &value)
{
setCurrentPointId(ui->comboBoxP3, value);
VisToolShoulderPoint *line = qobject_cast<VisToolShoulderPoint *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(value);
}
@ -262,6 +261,9 @@ void DialogShoulderPoint::SetLineColor(const QString &value)
void DialogShoulderPoint::SetP2Line(const quint32 &value)
{
setCurrentPointId(ui->comboBoxP2Line, value);
VisToolShoulderPoint *line = qobject_cast<VisToolShoulderPoint *>(vis);
SCASSERT(line != nullptr);
line->setLineP2Id(value);
}
@ -273,6 +275,9 @@ void DialogShoulderPoint::SetP2Line(const quint32 &value)
void DialogShoulderPoint::SetP1Line(const quint32 &value)
{
setCurrentPointId(ui->comboBoxP1Line, value);
VisToolShoulderPoint *line = qobject_cast<VisToolShoulderPoint *>(vis);
SCASSERT(line != nullptr);
line->setLineP1Id(value);
}
@ -290,6 +295,9 @@ void DialogShoulderPoint::SetFormula(const QString &value)
this->DeployFormulaTextEdit();
}
ui->plainTextEditFormula->setPlainText(formula);
VisToolShoulderPoint *line = qobject_cast<VisToolShoulderPoint *>(vis);
SCASSERT(line != nullptr);
line->setLength(formula);
MoveCursorToEnd(ui->plainTextEditFormula);
}
@ -302,7 +310,7 @@ void DialogShoulderPoint::SetFormula(const QString &value)
void DialogShoulderPoint::SetTypeLine(const QString &value)
{
ChangeCurrentData(ui->comboBoxLineType, value);
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
vis->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
}
//---------------------------------------------------------------------------------------------------------------------

View File

@ -36,8 +36,6 @@ namespace Ui
class DialogShoulderPoint;
}
class VisToolShoulderPoint;
/**
* @brief The DialogShoulderPoint class dialog for ToolShoulderPoint. Help create point and edit option.
*/
@ -46,7 +44,7 @@ class DialogShoulderPoint : public DialogTool
Q_OBJECT
public:
DialogShoulderPoint(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogShoulderPoint();
virtual ~DialogShoulderPoint();
void SetPointName(const QString &value);
@ -97,7 +95,6 @@ private:
/** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight;
VisToolShoulderPoint *line;
};
#endif // DIALOGSHOULDERPOINT_H

View File

@ -44,7 +44,7 @@ class DialogSinglePoint : public DialogTool
Q_OBJECT
public:
DialogSinglePoint(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogSinglePoint();
virtual ~DialogSinglePoint();
void SetData(const QString &name, const QPointF &point);
QPointF GetPoint()const;

View File

@ -42,7 +42,7 @@
*/
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), path(nullptr)
kCurve(1)
{
ui->setupUi(this);
InitOkCancelApply(ui);
@ -56,16 +56,13 @@ DialogSpline::DialogSpline(const VContainer *data, const quint32 &toolId, QWidge
connect(ui->comboBoxP4, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogSpline::PointNameChanged);
path = new VisToolSpline(data);
vis = new VisToolSpline(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogSpline::~DialogSpline()
{
if (qApp->getCurrentScene()->items().contains(path))
{ // In some cases scene delete object yourself. If not make check program will crash.
delete path;
}
DeleteVisualization<VisToolSpline>();
delete ui;
}
@ -91,6 +88,9 @@ void DialogSpline::ChosenObject(quint32 id, const SceneObject &type)
{
if (type == SceneObject::Point)
{
VisToolSpline *path = qobject_cast<VisToolSpline *>(vis);
SCASSERT(path != nullptr);
switch (number)
{
case 0:
@ -147,6 +147,9 @@ void DialogSpline::SaveData()
kAsm2 = ui->doubleSpinBoxKasm2->value();
kCurve = ui->doubleSpinBoxKcurve->value();
VisToolSpline *path = qobject_cast<VisToolSpline *>(vis);
SCASSERT(path != nullptr);
path->setPoint1Id(GetP1());
path->setPoint4Id(GetP4());
path->SetAngle1(angle1);
@ -183,14 +186,7 @@ void DialogSpline::PointNameChanged()
//---------------------------------------------------------------------------------------------------------------------
void DialogSpline::ShowVisualization()
{
if (prepare == false)
{
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr)
connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor);
scene->addItem(path);
path->RefreshGeometry();
}
AddVisualization<VisToolSpline>();
}
//---------------------------------------------------------------------------------------------------------------------
@ -202,6 +198,9 @@ void DialogSpline::SetKCurve(const qreal &value)
{
kCurve = value;
ui->doubleSpinBoxKcurve->setValue(value);
VisToolSpline *path = qobject_cast<VisToolSpline *>(vis);
SCASSERT(path != nullptr);
path->SetKCurve(kCurve);
}
@ -226,6 +225,9 @@ void DialogSpline::SetKAsm2(const qreal &value)
{
kAsm2 = value;
ui->doubleSpinBoxKasm2->setValue(value);
VisToolSpline *path = qobject_cast<VisToolSpline *>(vis);
SCASSERT(path != nullptr);
path->SetKAsm2(kAsm2);
}
@ -238,6 +240,9 @@ void DialogSpline::SetKAsm1(const qreal &value)
{
kAsm1 = value;
ui->doubleSpinBoxKasm1->setValue(value);
VisToolSpline *path = qobject_cast<VisToolSpline *>(vis);
SCASSERT(path != nullptr);
path->SetKAsm1(kAsm1);
}
@ -250,6 +255,9 @@ 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);
}
@ -262,6 +270,9 @@ 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);
}
@ -273,6 +284,9 @@ void DialogSpline::SetAngle1(const qreal &value)
void DialogSpline::SetP4(const quint32 &value)
{
setCurrentPointId(ui->comboBoxP4, value);
VisToolSpline *path = qobject_cast<VisToolSpline *>(vis);
SCASSERT(path != nullptr);
path->setPoint4Id(value);
}
@ -284,6 +298,9 @@ void DialogSpline::SetP4(const quint32 &value)
void DialogSpline::SetP1(const quint32 &value)
{
setCurrentPointId(ui->comboBoxP1, value);
VisToolSpline *path = qobject_cast<VisToolSpline *>(vis);
SCASSERT(path != nullptr);
path->setPoint1Id(value);
}

View File

@ -36,8 +36,6 @@ namespace Ui
class DialogSpline;
}
class VisToolSpline;
/**
* @brief The DialogSpline class dialog for ToolSpline. Help create spline and edit option.
*/
@ -46,7 +44,7 @@ class DialogSpline : public DialogTool
Q_OBJECT
public:
DialogSpline(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogSpline();
virtual ~DialogSpline();
quint32 GetP1() const;
void SetP1(const quint32 &value);
@ -100,8 +98,6 @@ private:
/** @brief kCurve coefficient curve */
qreal kCurve;
VisToolSpline *path;
};
#endif // DIALOGSPLINE_H

View File

@ -39,7 +39,7 @@
* @param parent parent widget
*/
DialogSplinePath::DialogSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogSplinePath), path(VSplinePath()), visPath(nullptr)
:DialogTool(data, toolId, parent), ui(new Ui::DialogSplinePath), path(VSplinePath())
{
ui->setupUi(this);
InitOkCancelApply(ui);
@ -60,16 +60,13 @@ DialogSplinePath::DialogSplinePath(const VContainer *data, const quint32 &toolId
connect(ui->doubleSpinBoxKasm2, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
this, &DialogSplinePath::KAsm2Changed);
visPath = new VisToolSplinePath(data);
vis = new VisToolSplinePath(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogSplinePath::~DialogSplinePath()
{
if (qApp->getCurrentScene()->items().contains(visPath))
{ // In some cases scene delete object yourself. If not make check program will crash.
delete visPath;
}
DeleteVisualization<VisToolSplinePath>();
delete ui;
}
@ -90,6 +87,8 @@ void DialogSplinePath::SetPath(const VSplinePath &value)
ui->listWidget->setFocus(Qt::OtherFocusReason);
ui->doubleSpinBoxKcurve->setValue(path.GetKCurve());
VisToolSplinePath *visPath = qobject_cast<VisToolSplinePath *>(vis);
SCASSERT(visPath != nullptr);
visPath->setPath(path);
ui->listWidget->blockSignals(false);
}
@ -125,7 +124,11 @@ void DialogSplinePath::ChosenObject(quint32 id, const SceneObject &type)
emit ToolTip(tr("Select point of curve path"));
SavePath();
VisToolSplinePath *visPath = qobject_cast<VisToolSplinePath *>(vis);
SCASSERT(visPath != nullptr);
visPath->setPath(path);
if (path.CountPoint() == 1)
{
visPath->VisualMode(NULL_ID);
@ -144,6 +147,8 @@ void DialogSplinePath::SaveData()
{
SavePath();
VisToolSplinePath *visPath = qobject_cast<VisToolSplinePath *>(vis);
SCASSERT(visPath != nullptr);
visPath->setPath(path);
visPath->RefreshGeometry();
}
@ -268,7 +273,11 @@ void DialogSplinePath::ShowVisualization()
if (prepare == false)
{
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr)
SCASSERT(scene != nullptr);
VisToolSplinePath *visPath = qobject_cast<VisToolSplinePath *>(vis);
SCASSERT(visPath != nullptr);
connect(scene, &VMainGraphicsScene::NewFactor, visPath, &Visualization::SetFactor);
scene->addItem(visPath);
visPath->setMode(Mode::Show);

View File

@ -37,8 +37,6 @@ namespace Ui
class DialogSplinePath;
}
class VisToolSplinePath;
/**
* @brief The DialogSplinePath class dialog for ToolSplinePath. Help create spline path and edit option.
*/
@ -47,7 +45,7 @@ class DialogSplinePath : public DialogTool
Q_OBJECT
public:
DialogSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogSplinePath();
virtual ~DialogSplinePath();
VSplinePath GetPath() const;
void SetPath(const VSplinePath &value);
@ -79,8 +77,6 @@ private:
/** @brief path spline path */
VSplinePath path;
VisToolSplinePath *visPath;
void NewItem(quint32 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2);
void DataPoint(quint32 id, qreal kAsm1, qreal angle1, qreal kAsm2, qreal angle2);
void EnableFields();

View File

@ -62,7 +62,7 @@ DialogTool::DialogTool(const VContainer *data, const quint32 &toolId, QWidget *p
timerFormula(nullptr), bOk(nullptr), bApply(nullptr), spinBoxAngle(nullptr), plainTextEditFormula(nullptr),
labelResultCalculation(nullptr), labelEditNamePoint(nullptr), labelEditFormula(nullptr),
okColor(QColor(76, 76, 76)), errorColor(Qt::red), associatedTool(nullptr),
toolId(toolId), prepare(false), pointName(QString()), number(0)
toolId(toolId), prepare(false), pointName(QString()), number(0), vis(nullptr)
{
SCASSERT(data != nullptr);
timerFormula = new QTimer(this);

View File

@ -31,6 +31,8 @@
#include "../../core/vapplication.h"
#include "../../utils/logging.h"
#include "../../widgets/vmaingraphicsscene.h"
#include "../../visualization/visualization.h"
#include <QDialog>
#include <QDialogButtonBox>
@ -177,6 +179,8 @@ protected:
/** @brief number number of handled objects */
qint32 number;
Visualization *vis;
virtual void closeEvent ( QCloseEvent * event );
virtual void showEvent( QShowEvent *event );
@ -261,6 +265,34 @@ protected:
plainTextEditFormula = ui->plainTextEditFormula;
labelEditFormula = ui->labelEditFormula;
}
template <typename T>
void AddVisualization()
{
if (prepare == false)
{
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr);
T *toolVis = qobject_cast<T *>(vis);
SCASSERT(toolVis != nullptr);
connect(scene, &VMainGraphicsScene::NewFactor, toolVis, &Visualization::SetFactor);
scene->addItem(toolVis);
toolVis->RefreshGeometry();
}
}
template <typename T>
void DeleteVisualization()
{
T *toolVis = qobject_cast<T *>(vis);
SCASSERT(toolVis != nullptr);
if (qApp->getCurrentScene()->items().contains(toolVis))
{ // In some cases scene delete object yourself. If not make check program will crash.
delete vis;
}
}
void ChangeColor(QWidget *widget, const QColor &color);
virtual void ShowVisualization(){}

View File

@ -41,7 +41,7 @@
* @param parent parent widget
*/
DialogTriangle::DialogTriangle(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogTriangle), line (nullptr)
:DialogTool(data, toolId, parent), ui(new Ui::DialogTriangle)
{
ui->setupUi(this);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
@ -65,16 +65,13 @@ DialogTriangle::DialogTriangle(const VContainer *data, const quint32 &toolId, QW
connect(ui->comboBoxAxisP2, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogTriangle::PointNameChanged);
line = new VisToolTriangle(data);
vis = new VisToolTriangle(data);
}
//---------------------------------------------------------------------------------------------------------------------
DialogTriangle::~DialogTriangle()
{
if (qApp->getCurrentScene()->items().contains(line))
{ // In some cases scene delete object yourself. If not make check program will crash.
delete line;
}
DeleteVisualization<VisToolTriangle>();
delete ui;
}
@ -90,6 +87,9 @@ void DialogTriangle::ChosenObject(quint32 id, const SceneObject &type)
{
if (type == SceneObject::Point)
{
VisToolTriangle *line = qobject_cast<VisToolTriangle *>(vis);
SCASSERT(line != nullptr);
switch (number)
{
case (0):
@ -161,6 +161,9 @@ void DialogTriangle::SaveData()
{
pointName = ui->lineEditNamePoint->text();
VisToolTriangle *line = qobject_cast<VisToolTriangle *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(GetAxisP1Id());
line->setPoint2Id(GetAxisP2Id());
line->setHypotenuseP1Id(GetFirstPointId());
@ -198,14 +201,7 @@ void DialogTriangle::PointNameChanged()
//---------------------------------------------------------------------------------------------------------------------
void DialogTriangle::ShowVisualization()
{
if (prepare == false)
{
VMainGraphicsScene *scene = qobject_cast<VMainGraphicsScene *>(qApp->getCurrentScene());
SCASSERT(scene != nullptr)
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor);
scene->addItem(line);
line->RefreshGeometry();
}
AddVisualization<VisToolTriangle>();
}
//---------------------------------------------------------------------------------------------------------------------
@ -227,6 +223,9 @@ void DialogTriangle::SetPointName(const QString &value)
void DialogTriangle::SetSecondPointId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxSecondPoint, value);
VisToolTriangle *line = qobject_cast<VisToolTriangle *>(vis);
SCASSERT(line != nullptr);
line->setHypotenuseP2Id(value);
}
@ -238,6 +237,9 @@ void DialogTriangle::SetSecondPointId(const quint32 &value)
void DialogTriangle::SetFirstPointId(const quint32 &value)
{
setCurrentPointId(ui->comboBoxFirstPoint, value);
VisToolTriangle *line = qobject_cast<VisToolTriangle *>(vis);
SCASSERT(line != nullptr);
line->setHypotenuseP1Id(value);
}
@ -249,6 +251,9 @@ void DialogTriangle::SetFirstPointId(const quint32 &value)
void DialogTriangle::SetAxisP2Id(const quint32 &value)
{
setCurrentPointId(ui->comboBoxAxisP2, value);
VisToolTriangle *line = qobject_cast<VisToolTriangle *>(vis);
SCASSERT(line != nullptr);
line->setPoint2Id(value);
}
@ -260,6 +265,9 @@ void DialogTriangle::SetAxisP2Id(const quint32 &value)
void DialogTriangle::SetAxisP1Id(const quint32 &value)
{
setCurrentPointId(ui->comboBoxAxisP1, value);
VisToolTriangle *line = qobject_cast<VisToolTriangle *>(vis);
SCASSERT(line != nullptr);
line->setPoint1Id(value);
}

View File

@ -36,8 +36,6 @@ namespace Ui
class DialogTriangle;
}
class VisToolTriangle;
/**
* @brief The DialogTriangle class dialog for ToolTriangle. Help create point and edit option.
*/
@ -46,7 +44,7 @@ class DialogTriangle : public DialogTool
Q_OBJECT
public:
DialogTriangle(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogTriangle();
virtual ~DialogTriangle();
quint32 GetAxisP1Id() const;
void SetAxisP1Id(const quint32 &value);
@ -75,8 +73,6 @@ private:
/** @brief ui keeps information about user interface */
Ui::DialogTriangle *ui;
VisToolTriangle *line;
};
#endif // DIALOGTRIANGLE_H

View File

@ -44,7 +44,7 @@ class DialogUnionDetails : public DialogTool
Q_OBJECT
public:
DialogUnionDetails(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogUnionDetails();
virtual ~DialogUnionDetails();
quint32 getD1() const;
quint32 getD2() const;