Refactoring.

--HG--
branch : develop
This commit is contained in:
dismine 2014-08-12 20:21:50 +03:00
parent 30aa0402fe
commit 4bba3df4af
14 changed files with 35 additions and 64 deletions

View File

@ -42,8 +42,7 @@
*/ */
DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogAlongLine), number(0), pointName(QString()), :DialogTool(data, toolId, parent), ui(new Ui::DialogAlongLine), number(0), pointName(QString()),
typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0), formulaBaseHeight(0), line(nullptr), typeLine(QString()), formula(QString()), firstPointId(0), secondPointId(0), formulaBaseHeight(0), line(nullptr)
prepare(false)
{ {
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
@ -142,12 +141,7 @@ void DialogAlongLine::ChosenObject(quint32 id, const SceneObject &type)
if (ChoosedPoint(id, ui->comboBoxFirstPoint, tr("Select second point of line"))) if (ChoosedPoint(id, ui->comboBoxFirstPoint, tr("Select second point of line")))
{ {
number++; number++;
VMainGraphicsScene *scene = qApp->getCurrentScene(); line->VisualMode(id);
SCASSERT(scene != nullptr);
line->VisualMode(id, scene->getScenePos());
scene->addItem(line);
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolAlongLine::SetFactor);
connect(scene, &VMainGraphicsScene::mouseMove, line, &VisToolAlongLine::MousePos);
return; return;
} }
} }

View File

@ -106,8 +106,6 @@ private:
/** @brief formulaBaseHeight base height defined by dialogui */ /** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight; int formulaBaseHeight;
VisToolAlongLine *line; VisToolAlongLine *line;
/** @brief prepare show if we prepare show dialog after finish working with visual part of tool*/
bool prepare;
/** /**
* @brief SaveData Put dialog data in local variables * @brief SaveData Put dialog data in local variables

View File

@ -155,12 +155,7 @@ void DialogBisector::ChosenObject(quint32 id, const SceneObject &type)
{ // -1 for not found { // -1 for not found
ui->comboBoxFirstPoint->setCurrentIndex(index); ui->comboBoxFirstPoint->setCurrentIndex(index);
number++; number++;
VMainGraphicsScene *scene = qApp->getCurrentScene(); line->VisualMode(id);
SCASSERT(scene != nullptr);
line->VisualMode(id, scene->getScenePos());
scene->addItem(line);
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolBisector::SetFactor);
connect(scene, &VMainGraphicsScene::mouseMove, line, &VisToolBisector::MousePos);
emit ToolTip(tr("Select second point of angle")); emit ToolTip(tr("Select second point of angle"));
return; return;
} }

View File

@ -44,7 +44,7 @@
DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogEndLine), pointName(QString()), typeLine(QString()), :DialogTool(data, toolId, parent), ui(new Ui::DialogEndLine), pointName(QString()), typeLine(QString()),
formulaLength(QString()), formulaAngle(QString()), basePointId(0), formulaBaseHeight(0), formulaLength(QString()), formulaAngle(QString()), basePointId(0), formulaBaseHeight(0),
formulaBaseHeightAngle(0), line(nullptr), prepare(false) formulaBaseHeightAngle(0), line(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
@ -144,12 +144,7 @@ void DialogEndLine::ChosenObject(quint32 id, const SceneObject &type)
basePointId = id; basePointId = id;
ChangeCurrentText(ui->comboBoxBasePoint, point->name()); ChangeCurrentText(ui->comboBoxBasePoint, point->name());
VMainGraphicsScene *scene = qApp->getCurrentScene(); line->VisualMode(id);
SCASSERT(scene != nullptr);
scene->addItem(line);
line->VisualMode(id, scene->getScenePos());
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolEndLine::SetFactor);
connect(scene, &VMainGraphicsScene::mouseMove, line, &VisToolEndLine::MousePos);
connect(line, &VisToolEndLine::ToolTip, this, &DialogTool::ShowVisToolTip); connect(line, &VisToolEndLine::ToolTip, this, &DialogTool::ShowVisToolTip);
emit ToolTip(""); emit ToolTip("");

View File

@ -111,9 +111,6 @@ private:
VisToolEndLine *line; VisToolEndLine *line;
/** @brief prepare show if we prepare show dialog after finish working with visual part of tool*/
bool prepare;
/** /**
* @brief SaveData Put dialog data in local variables * @brief SaveData Put dialog data in local variables
*/ */

View File

@ -152,10 +152,13 @@ void DialogLine::UpdateList()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLine::ShowVisualization() void DialogLine::ShowVisualization()
{ {
if (prepare == false)
{
VMainGraphicsScene *scene = qApp->getCurrentScene(); VMainGraphicsScene *scene = qApp->getCurrentScene();
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolLine::SetFactor); connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolLine::SetFactor);
scene->addItem(line); scene->addItem(line);
line->RefreshGeometry(); line->RefreshGeometry();
}
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -189,13 +192,7 @@ void DialogLine::ChosenObject(quint32 id, const SceneObject &type)
qint32 index = ui->comboBoxFirstPoint->findText(point->name()); qint32 index = ui->comboBoxFirstPoint->findText(point->name());
if ( index != -1 ) if ( index != -1 )
{ // -1 for not found { // -1 for not found
line->VisualMode(id);
VMainGraphicsScene *scene = qApp->getCurrentScene();
line->VisualMode(id, scene->getScenePos());
scene->addItem(line);
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolLine::SetFactor);
connect(scene, &VMainGraphicsScene::mouseMove, line, &VisToolLine::MousePos);
ui->comboBoxFirstPoint->setCurrentIndex(index); ui->comboBoxFirstPoint->setCurrentIndex(index);
number++; number++;
emit ToolTip(tr("Select second point")); emit ToolTip(tr("Select second point"));
@ -211,6 +208,7 @@ void DialogLine::ChosenObject(quint32 id, const SceneObject &type)
if (flagError) if (flagError)
{ {
number = 0; number = 0;
prepare = true;
emit ToolTip(""); emit ToolTip("");
DialogAccepted(); DialogAccepted();
} }

View File

@ -40,8 +40,7 @@
*/ */
DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()), typeLine(QString()), :DialogTool(data, toolId, parent), ui(new Ui::DialogNormal), number(0), pointName(QString()), typeLine(QString()),
formula(QString()), angle(0), firstPointId(0), secondPointId(0), formulaBaseHeight(0), line(nullptr), formula(QString()), angle(0), firstPointId(0), secondPointId(0), formulaBaseHeight(0), line(nullptr)
prepare(false)
{ {
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
@ -141,12 +140,7 @@ void DialogNormal::ChosenObject(quint32 id, const SceneObject &type)
if (ChoosedPoint(id, ui->comboBoxFirstPoint, tr("Select second point of line"))) if (ChoosedPoint(id, ui->comboBoxFirstPoint, tr("Select second point of line")))
{ {
number++; number++;
VMainGraphicsScene *scene = qApp->getCurrentScene(); line->VisualMode(id);
SCASSERT(scene != nullptr);
line->VisualMode(id, scene->getScenePos());
scene->addItem(line);
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolNormal::SetFactor);
connect(scene, &VMainGraphicsScene::mouseMove, line, &VisToolNormal::MousePos);
return; return;
} }
} }

View File

@ -115,9 +115,6 @@ private:
VisToolNormal *line; VisToolNormal *line;
/** @brief prepare show if we prepare show dialog after finish working with visual part of tool*/
bool prepare;
/** /**
* @brief SaveData Put dialog data in local variables * @brief SaveData Put dialog data in local variables
*/ */

View File

@ -43,8 +43,7 @@
*/ */
DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogShoulderPoint), number(0), pointName(QString()), :DialogTool(data, toolId, parent), ui(new Ui::DialogShoulderPoint), number(0), pointName(QString()),
typeLine(QString()), formula(QString()), p1Line(0), p2Line(0), pShoulder(0), formulaBaseHeight(0), line (nullptr), typeLine(QString()), formula(QString()), p1Line(0), p2Line(0), pShoulder(0), formulaBaseHeight(0), line (nullptr)
prepare(false)
{ {
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
@ -155,12 +154,7 @@ void DialogShoulderPoint::ChosenObject(quint32 id, const SceneObject &type)
{ // -1 for not found { // -1 for not found
ui->comboBoxPShoulder->setCurrentIndex(index); ui->comboBoxPShoulder->setCurrentIndex(index);
number++; number++;
VMainGraphicsScene *scene = qApp->getCurrentScene(); line->VisualMode(id);
SCASSERT(scene != nullptr);
line->VisualMode(id, scene->getScenePos());
scene->addItem(line);
connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolShoulderPoint::SetFactor);
connect(scene, &VMainGraphicsScene::mouseMove, line, &VisToolShoulderPoint::MousePos);
emit ToolTip(tr("Select first point of line")); emit ToolTip(tr("Select first point of line"));
return; return;
} }

View File

@ -113,7 +113,6 @@ private:
/** @brief formulaBaseHeight base height defined by dialogui */ /** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight; int formulaBaseHeight;
VisToolShoulderPoint *line; VisToolShoulderPoint *line;
bool prepare;
/** /**
* @brief SaveData Put dialog data in local variables * @brief SaveData Put dialog data in local variables

View File

@ -48,7 +48,7 @@
#include <QPushButton> #include <QPushButton>
#include <QDoubleSpinBox> #include <QDoubleSpinBox>
#define DIALOGARC_MAX_FORMULA_HEIGHT 64 #define DIALOG_MAX_FORMULA_HEIGHT 64
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
@ -63,7 +63,7 @@ DialogTool::DialogTool(const VContainer *data, const quint32 &toolId, QWidget *p
labelEditFormula(nullptr), radioButtonSizeGrowth(nullptr), radioButtonStandardTable(nullptr), labelEditFormula(nullptr), radioButtonSizeGrowth(nullptr), radioButtonStandardTable(nullptr),
radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr), radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr),
radioButtonLengthCurve(nullptr), radioButtonAngleLine(nullptr), lineStyles(VAbstractTool::Styles()), radioButtonLengthCurve(nullptr), radioButtonAngleLine(nullptr), lineStyles(VAbstractTool::Styles()),
okColor(QColor(76, 76, 76)), errorColor(Qt::red), associatedTool(nullptr), toolId(toolId) okColor(QColor(76, 76, 76)), errorColor(Qt::red), associatedTool(nullptr), toolId(toolId), prepare(false)
{ {
SCASSERT(data != nullptr); SCASSERT(data != nullptr);
timerFormula = new QTimer(this); timerFormula = new QTimer(this);
@ -592,9 +592,9 @@ void DialogTool::DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowL
{ {
SCASSERT(formula != nullptr); SCASSERT(formula != nullptr);
SCASSERT(buttonGrowLength != nullptr) SCASSERT(buttonGrowLength != nullptr)
if (formula->height() < DIALOGARC_MAX_FORMULA_HEIGHT) if (formula->height() < DIALOG_MAX_FORMULA_HEIGHT)
{ {
formula->setFixedHeight(DIALOGARC_MAX_FORMULA_HEIGHT); formula->setFixedHeight(DIALOG_MAX_FORMULA_HEIGHT);
//Set icon from theme (internal for Windows system) //Set icon from theme (internal for Windows system)
buttonGrowLength->setIcon(QIcon::fromTheme("go-next", buttonGrowLength->setIcon(QIcon::fromTheme("go-next",
QIcon(":/icons/win.icon.theme/16x16/actions/go-next.png"))); QIcon(":/icons/win.icon.theme/16x16/actions/go-next.png")));

View File

@ -197,6 +197,9 @@ protected:
VAbstractTool *associatedTool; VAbstractTool *associatedTool;
quint32 toolId; quint32 toolId;
/** @brief prepare show if we prepare. Show dialog after finish working with visual part of tool*/
bool prepare;
virtual void closeEvent ( QCloseEvent * event ); virtual void closeEvent ( QCloseEvent * event );
virtual void showEvent( QShowEvent *event ); virtual void showEvent( QShowEvent *event );
void FillComboBoxPoints(QComboBox *box)const; void FillComboBoxPoints(QComboBox *box)const;

View File

@ -270,11 +270,18 @@ void VisLine::setScenePos(const QPointF &value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VisLine::VisualMode(const quint32 &pointId, const QPointF &scenePos) void VisLine::VisualMode(const quint32 &pointId)
{ {
VMainGraphicsScene *scene = qApp->getCurrentScene();
SCASSERT(scene != nullptr);
this->point1Id = pointId; this->point1Id = pointId;
this->scenePos = scenePos; this->scenePos = scene->getScenePos();
RefreshGeometry(); RefreshGeometry();
scene->addItem(this);
connect(scene, &VMainGraphicsScene::NewFactor, this, &VisLine::SetFactor);
connect(scene, &VMainGraphicsScene::mouseMove, this, &VisLine::MousePos);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -46,7 +46,7 @@ public:
void setLineStyle(const Qt::PenStyle &value); void setLineStyle(const Qt::PenStyle &value);
virtual void RefreshGeometry()=0; virtual void RefreshGeometry()=0;
void setScenePos(const QPointF &value); void setScenePos(const QPointF &value);
void VisualMode(const quint32 &pointId, const QPointF &scenePos); void VisualMode(const quint32 &pointId);
void setMainColor(const QColor &value); void setMainColor(const QColor &value);
signals: signals:
void ToolTip(const QString &toolTip); void ToolTip(const QString &toolTip);