Refactoring.
This commit is contained in:
parent
3d186c2a37
commit
48b7c387a8
|
@ -265,7 +265,7 @@ void DialogAlongLine::SetCurrentLength()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogAlongLine::ChosenSecondPoint(quint32 id, const QString toolTip)
|
void DialogAlongLine::ChosenSecondPoint(quint32 id, const QString &toolTip)
|
||||||
{
|
{
|
||||||
if (SetObject(id, ui->comboBoxSecondPoint, QString()))
|
if (SetObject(id, ui->comboBoxSecondPoint, QString()))
|
||||||
{
|
{
|
||||||
|
|
|
@ -120,7 +120,7 @@ private:
|
||||||
|
|
||||||
void SetCurrentLength();
|
void SetCurrentLength();
|
||||||
|
|
||||||
void ChosenSecondPoint(quint32 id, const QString toolTip);
|
void ChosenSecondPoint(quint32 id, const QString &toolTip);
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -46,7 +46,6 @@
|
||||||
#include "../ifc/xml/vabstractpattern.h"
|
#include "../ifc/xml/vabstractpattern.h"
|
||||||
#include "../vgeometry/vgobject.h"
|
#include "../vgeometry/vgobject.h"
|
||||||
#include "../vgeometry/vpointf.h"
|
#include "../vgeometry/vpointf.h"
|
||||||
#include "../vmisc/vabstractapplication.h"
|
|
||||||
#include "../vpatterndb/vcontainer.h"
|
#include "../vpatterndb/vcontainer.h"
|
||||||
#include "dialogtool.h"
|
#include "dialogtool.h"
|
||||||
#include "ui_dialogheight.h"
|
#include "ui_dialogheight.h"
|
||||||
|
@ -59,10 +58,7 @@
|
||||||
*/
|
*/
|
||||||
DialogHeight::DialogHeight(const VContainer *data, quint32 toolId, QWidget *parent)
|
DialogHeight::DialogHeight(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogHeight),
|
ui(new Ui::DialogHeight)
|
||||||
pointName(),
|
|
||||||
flagError(true),
|
|
||||||
flagName(true)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -80,7 +76,7 @@ DialogHeight::DialogHeight(const VContainer *data, quint32 toolId, QWidget *pare
|
||||||
|
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||||
{
|
{
|
||||||
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, m_pointName, this->data, m_flagName);
|
||||||
CheckState();
|
CheckState();
|
||||||
});
|
});
|
||||||
connect(ui->comboBoxBasePoint, &QComboBox::currentTextChanged,
|
connect(ui->comboBoxBasePoint, &QComboBox::currentTextChanged,
|
||||||
|
@ -103,9 +99,9 @@ DialogHeight::~DialogHeight()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DialogHeight::GetPointName() const
|
auto DialogHeight::GetPointName() const -> QString
|
||||||
{
|
{
|
||||||
return pointName;
|
return m_pointName;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -115,8 +111,8 @@ QString DialogHeight::GetPointName() const
|
||||||
*/
|
*/
|
||||||
void DialogHeight::SetPointName(const QString &value)
|
void DialogHeight::SetPointName(const QString &value)
|
||||||
{
|
{
|
||||||
pointName = value;
|
m_pointName = value;
|
||||||
ui->lineEditNamePoint->setText(pointName);
|
ui->lineEditNamePoint->setText(m_pointName);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -139,7 +135,7 @@ void DialogHeight::SetBasePointId(const quint32 &value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxBasePoint, value);
|
setCurrentPointId(ui->comboBoxBasePoint, value);
|
||||||
|
|
||||||
VisToolHeight *line = qobject_cast<VisToolHeight *>(vis);
|
auto *line = qobject_cast<VisToolHeight *>(vis);
|
||||||
SCASSERT(line != nullptr)
|
SCASSERT(line != nullptr)
|
||||||
line->setObject1Id(value);
|
line->setObject1Id(value);
|
||||||
}
|
}
|
||||||
|
@ -153,7 +149,7 @@ void DialogHeight::SetP1LineId(const quint32 &value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxP1Line, value);
|
setCurrentPointId(ui->comboBoxP1Line, value);
|
||||||
|
|
||||||
VisToolHeight *line = qobject_cast<VisToolHeight *>(vis);
|
auto *line = qobject_cast<VisToolHeight *>(vis);
|
||||||
SCASSERT(line != nullptr)
|
SCASSERT(line != nullptr)
|
||||||
line->setLineP1Id(value);
|
line->setLineP1Id(value);
|
||||||
}
|
}
|
||||||
|
@ -167,13 +163,13 @@ void DialogHeight::SetP2LineId(const quint32 &value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxP2Line, value);
|
setCurrentPointId(ui->comboBoxP2Line, value);
|
||||||
|
|
||||||
VisToolHeight *line = qobject_cast<VisToolHeight *>(vis);
|
auto *line = qobject_cast<VisToolHeight *>(vis);
|
||||||
SCASSERT(line != nullptr)
|
SCASSERT(line != nullptr)
|
||||||
line->setLineP2Id(value);
|
line->setLineP2Id(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DialogHeight::GetLineColor() const
|
auto DialogHeight::GetLineColor() const -> QString
|
||||||
{
|
{
|
||||||
return GetComboBoxCurrentData(ui->comboBoxLineColor, ColorBlack);
|
return GetComboBoxCurrentData(ui->comboBoxLineColor, ColorBlack);
|
||||||
}
|
}
|
||||||
|
@ -192,11 +188,14 @@ void DialogHeight::SetLineColor(const QString &value)
|
||||||
*/
|
*/
|
||||||
void DialogHeight::ChosenObject(quint32 id, const SceneObject &type)
|
void DialogHeight::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
{
|
{
|
||||||
if (prepare == false)// After first choose we ignore all objects
|
if (prepare)// After first choose we ignore all objects
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (type == SceneObject::Point)
|
if (type == SceneObject::Point)
|
||||||
{
|
{
|
||||||
VisToolHeight *line = qobject_cast<VisToolHeight *>(vis);
|
auto *line = qobject_cast<VisToolHeight *>(vis);
|
||||||
SCASSERT(line != nullptr)
|
SCASSERT(line != nullptr)
|
||||||
|
|
||||||
switch (number)
|
switch (number)
|
||||||
|
@ -243,14 +242,13 @@ void DialogHeight::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogHeight::SaveData()
|
void DialogHeight::SaveData()
|
||||||
{
|
{
|
||||||
pointName = ui->lineEditNamePoint->text();
|
m_pointName = ui->lineEditNamePoint->text();
|
||||||
|
|
||||||
VisToolHeight *line = qobject_cast<VisToolHeight *>(vis);
|
auto *line = qobject_cast<VisToolHeight *>(vis);
|
||||||
SCASSERT(line != nullptr)
|
SCASSERT(line != nullptr)
|
||||||
|
|
||||||
line->setObject1Id(GetBasePointId());
|
line->setObject1Id(GetBasePointId());
|
||||||
|
@ -282,18 +280,18 @@ void DialogHeight::PointNameChanged()
|
||||||
|
|
||||||
if (set.size() != 3 || VGObject::ClosestPoint(QLineF(p1Line, p2Line), basePoint) == QPointF())
|
if (set.size() != 3 || VGObject::ClosestPoint(QLineF(p1Line, p2Line), basePoint) == QPointF())
|
||||||
{
|
{
|
||||||
flagError = false;
|
m_flagError = false;
|
||||||
color = errorColor;
|
color = errorColor;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
m_flagError = true;
|
||||||
color = OkColor(this);
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const VExceptionBadId &)
|
catch (const VExceptionBadId &)
|
||||||
{
|
{
|
||||||
flagError = false;
|
m_flagError = false;
|
||||||
color = errorColor;
|
color = errorColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,7 +312,7 @@ void DialogHeight::ShowVisualization()
|
||||||
* @brief GetTypeLine return type of line
|
* @brief GetTypeLine return type of line
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
QString DialogHeight::GetTypeLine() const
|
auto DialogHeight::GetTypeLine() const -> QString
|
||||||
{
|
{
|
||||||
return GetComboBoxCurrentData(ui->comboBoxLineType, TypeLineLine);
|
return GetComboBoxCurrentData(ui->comboBoxLineType, TypeLineLine);
|
||||||
}
|
}
|
||||||
|
@ -324,7 +322,7 @@ QString DialogHeight::GetTypeLine() const
|
||||||
* @brief GetBasePointId return id base point of height
|
* @brief GetBasePointId return id base point of height
|
||||||
* @return id
|
* @return id
|
||||||
*/
|
*/
|
||||||
quint32 DialogHeight::GetBasePointId() const
|
auto DialogHeight::GetBasePointId() const -> quint32
|
||||||
{
|
{
|
||||||
return getCurrentObjectId(ui->comboBoxBasePoint);
|
return getCurrentObjectId(ui->comboBoxBasePoint);
|
||||||
}
|
}
|
||||||
|
@ -334,7 +332,7 @@ quint32 DialogHeight::GetBasePointId() const
|
||||||
* @brief GetP1LineId return id first point of line
|
* @brief GetP1LineId return id first point of line
|
||||||
* @return id id
|
* @return id id
|
||||||
*/
|
*/
|
||||||
quint32 DialogHeight::GetP1LineId() const
|
auto DialogHeight::GetP1LineId() const -> quint32
|
||||||
{
|
{
|
||||||
return getCurrentObjectId(ui->comboBoxP1Line);
|
return getCurrentObjectId(ui->comboBoxP1Line);
|
||||||
}
|
}
|
||||||
|
@ -344,7 +342,7 @@ quint32 DialogHeight::GetP1LineId() const
|
||||||
* @brief GetP2LineId return id second point of line
|
* @brief GetP2LineId return id second point of line
|
||||||
* @return id
|
* @return id
|
||||||
*/
|
*/
|
||||||
quint32 DialogHeight::GetP2LineId() const
|
auto DialogHeight::GetP2LineId() const -> quint32
|
||||||
{
|
{
|
||||||
return getCurrentObjectId(ui->comboBoxP2Line);
|
return getCurrentObjectId(ui->comboBoxP2Line);
|
||||||
}
|
}
|
||||||
|
@ -356,7 +354,7 @@ void DialogHeight::SetNotes(const QString ¬es)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DialogHeight::GetNotes() const
|
auto DialogHeight::GetNotes() const -> QString
|
||||||
{
|
{
|
||||||
return ui->plainTextEditToolNotes->toPlainText();
|
return ui->plainTextEditToolNotes->toPlainText();
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,54 +51,54 @@ class DialogHeight final : public DialogTool
|
||||||
Q_OBJECT // NOLINT
|
Q_OBJECT // NOLINT
|
||||||
public:
|
public:
|
||||||
DialogHeight(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
DialogHeight(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogHeight() override;
|
~DialogHeight() override;
|
||||||
|
|
||||||
QString GetPointName() const;
|
auto GetPointName() const -> QString;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
|
|
||||||
QString GetTypeLine() const;
|
auto GetTypeLine() const -> QString;
|
||||||
void SetTypeLine(const QString &value);
|
void SetTypeLine(const QString &value);
|
||||||
|
|
||||||
quint32 GetBasePointId() const;
|
auto GetBasePointId() const -> quint32;
|
||||||
void SetBasePointId(const quint32 &value);
|
void SetBasePointId(const quint32 &value);
|
||||||
|
|
||||||
quint32 GetP1LineId() const;
|
auto GetP1LineId() const -> quint32;
|
||||||
void SetP1LineId(const quint32 &value);
|
void SetP1LineId(const quint32 &value);
|
||||||
|
|
||||||
quint32 GetP2LineId() const;
|
auto GetP2LineId() const -> quint32;
|
||||||
void SetP2LineId(const quint32 &value);
|
void SetP2LineId(const quint32 &value);
|
||||||
|
|
||||||
QString GetLineColor() const;
|
auto GetLineColor() const -> QString;
|
||||||
void SetLineColor(const QString &value);
|
void SetLineColor(const QString &value);
|
||||||
|
|
||||||
void SetNotes(const QString ¬es);
|
void SetNotes(const QString ¬es);
|
||||||
QString GetNotes() const;
|
auto GetNotes() const -> QString;
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
virtual void PointNameChanged() override;
|
void PointNameChanged() override;
|
||||||
protected:
|
protected:
|
||||||
virtual void ShowVisualization() override;
|
void ShowVisualization() override;
|
||||||
/**
|
/**
|
||||||
* @brief SaveData Put dialog data in local variables
|
* @brief SaveData Put dialog data in local variables
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
void SaveData() override;
|
||||||
virtual bool IsValid() const final;
|
auto IsValid() const -> bool final;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY_MOVE(DialogHeight) // NOLINT
|
Q_DISABLE_COPY_MOVE(DialogHeight) // NOLINT
|
||||||
|
|
||||||
/** @brief ui keeps information about user interface */
|
/** @brief ui keeps information about user interface */
|
||||||
Ui::DialogHeight *ui;
|
Ui::DialogHeight *ui;
|
||||||
|
|
||||||
QString pointName;
|
QString m_pointName{};
|
||||||
|
|
||||||
bool flagError;
|
bool m_flagError{true};
|
||||||
bool flagName;
|
bool m_flagName{true};
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
inline bool DialogHeight::IsValid() const
|
inline auto DialogHeight::IsValid() const -> bool
|
||||||
{
|
{
|
||||||
return flagError && flagName;
|
return m_flagError && m_flagName;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // DIALOGHEIGHT_H
|
#endif // DIALOGHEIGHT_H
|
||||||
|
|
|
@ -60,25 +60,18 @@
|
||||||
DialogNormal::DialogNormal(const VContainer *data, quint32 toolId, QWidget *parent)
|
DialogNormal::DialogNormal(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||||
: DialogTool(data, toolId, parent),
|
: DialogTool(data, toolId, parent),
|
||||||
ui(new Ui::DialogNormal),
|
ui(new Ui::DialogNormal),
|
||||||
formula(),
|
m_timerFormula(new QTimer(this))
|
||||||
angle(0),
|
|
||||||
formulaBaseHeight(0),
|
|
||||||
pointName(),
|
|
||||||
timerFormula(new QTimer(this)),
|
|
||||||
flagFormula(false),
|
|
||||||
flagName(true),
|
|
||||||
flagError(true)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
timerFormula->setSingleShot(true);
|
m_timerFormula->setSingleShot(true);
|
||||||
connect(timerFormula, &QTimer::timeout, this, &DialogNormal::EvalFormula);
|
connect(m_timerFormula, &QTimer::timeout, this, &DialogNormal::EvalFormula);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||||
|
|
||||||
ui->lineEditNamePoint->setText(
|
ui->lineEditNamePoint->setText(
|
||||||
VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||||
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
this->m_formulaBaseHeight = ui->plainTextEditFormula->height();
|
||||||
ui->plainTextEditFormula->installEventFilter(this);
|
ui->plainTextEditFormula->installEventFilter(this);
|
||||||
|
|
||||||
InitOkCancelApply(ui);
|
InitOkCancelApply(ui);
|
||||||
|
@ -101,12 +94,12 @@ DialogNormal::DialogNormal(const VContainer *data, quint32 toolId, QWidget *pare
|
||||||
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogNormal::FXLength);
|
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogNormal::FXLength);
|
||||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, [this]()
|
||||||
{
|
{
|
||||||
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, pointName, this->data, flagName);
|
CheckPointLabel(this, ui->lineEditNamePoint, ui->labelEditNamePoint, m_pointName, this->data, m_flagName);
|
||||||
CheckState();
|
CheckState();
|
||||||
});
|
});
|
||||||
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
|
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
|
||||||
{
|
{
|
||||||
timerFormula->start(formulaTimerTimeout);
|
m_timerFormula->start(formulaTimerTimeout);
|
||||||
});
|
});
|
||||||
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogNormal::DeployFormulaTextEdit);
|
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogNormal::DeployFormulaTextEdit);
|
||||||
connect(ui->comboBoxFirstPoint, &QComboBox::currentTextChanged,
|
connect(ui->comboBoxFirstPoint, &QComboBox::currentTextChanged,
|
||||||
|
@ -126,12 +119,12 @@ void DialogNormal::PointNameChanged()
|
||||||
QColor color;
|
QColor color;
|
||||||
if (getCurrentObjectId(ui->comboBoxFirstPoint) == getCurrentObjectId(ui->comboBoxSecondPoint))
|
if (getCurrentObjectId(ui->comboBoxFirstPoint) == getCurrentObjectId(ui->comboBoxSecondPoint))
|
||||||
{
|
{
|
||||||
flagError = false;
|
m_flagError = false;
|
||||||
color = errorColor;
|
color = errorColor;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
flagError = true;
|
m_flagError = true;
|
||||||
color = OkColor(this);
|
color = OkColor(this);
|
||||||
}
|
}
|
||||||
ChangeColor(ui->labelFirstPoint, color);
|
ChangeColor(ui->labelFirstPoint, color);
|
||||||
|
@ -142,7 +135,7 @@ void DialogNormal::PointNameChanged()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogNormal::FXLength()
|
void DialogNormal::FXLength()
|
||||||
{
|
{
|
||||||
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
auto *dialog = new DialogEditWrongFormula(data, toolId, this);
|
||||||
dialog->setWindowTitle(tr("Edit length"));
|
dialog->setWindowTitle(tr("Edit length"));
|
||||||
dialog->SetFormula(GetFormula());
|
dialog->SetFormula(GetFormula());
|
||||||
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
|
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
|
||||||
|
@ -163,7 +156,7 @@ void DialogNormal::EvalFormula()
|
||||||
formulaData.labelResult = ui->labelResultCalculation;
|
formulaData.labelResult = ui->labelResultCalculation;
|
||||||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||||
|
|
||||||
Eval(formulaData, flagFormula);
|
Eval(formulaData, m_flagFormula);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -175,7 +168,7 @@ void DialogNormal::ShowVisualization()
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogNormal::DeployFormulaTextEdit()
|
void DialogNormal::DeployFormulaTextEdit()
|
||||||
{
|
{
|
||||||
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, m_formulaBaseHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -185,9 +178,9 @@ DialogNormal::~DialogNormal()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DialogNormal::GetPointName() const
|
auto DialogNormal::GetPointName() const -> QString
|
||||||
{
|
{
|
||||||
return pointName;
|
return m_pointName;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -198,11 +191,14 @@ QString DialogNormal::GetPointName() const
|
||||||
*/
|
*/
|
||||||
void DialogNormal::ChosenObject(quint32 id, const SceneObject &type)
|
void DialogNormal::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
{
|
{
|
||||||
if (prepare == false)// After first choose we ignore all objects
|
if (prepare)// After first choose we ignore all objects
|
||||||
{
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (type == SceneObject::Point)
|
if (type == SceneObject::Point)
|
||||||
{
|
{
|
||||||
VisToolNormal *line = qobject_cast<VisToolNormal *>(vis);
|
auto *line = qobject_cast<VisToolNormal *>(vis);
|
||||||
SCASSERT(line != nullptr)
|
SCASSERT(line != nullptr)
|
||||||
|
|
||||||
switch (number)
|
switch (number)
|
||||||
|
@ -232,22 +228,21 @@ void DialogNormal::ChosenObject(quint32 id, const SceneObject &type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void DialogNormal::SaveData()
|
void DialogNormal::SaveData()
|
||||||
{
|
{
|
||||||
pointName = ui->lineEditNamePoint->text();
|
m_pointName = ui->lineEditNamePoint->text();
|
||||||
formula = ui->plainTextEditFormula->toPlainText();
|
m_formula = ui->plainTextEditFormula->toPlainText();
|
||||||
angle = ui->doubleSpinBoxAngle->value();
|
m_angle = ui->doubleSpinBoxAngle->value();
|
||||||
|
|
||||||
VisToolNormal *line = qobject_cast<VisToolNormal *>(vis);
|
auto *line = qobject_cast<VisToolNormal *>(vis);
|
||||||
SCASSERT(line != nullptr)
|
SCASSERT(line != nullptr)
|
||||||
|
|
||||||
line->setObject1Id(GetFirstPointId());
|
line->setObject1Id(GetFirstPointId());
|
||||||
line->setObject2Id(GetSecondPointId());
|
line->setObject2Id(GetSecondPointId());
|
||||||
line->setLength(formula);
|
line->setLength(m_formula);
|
||||||
line->SetAngle(angle);
|
line->SetAngle(m_angle);
|
||||||
line->setLineStyle(LineStyleToPenStyle(GetTypeLine()));
|
line->setLineStyle(LineStyleToPenStyle(GetTypeLine()));
|
||||||
line->RefreshGeometry();
|
line->RefreshGeometry();
|
||||||
}
|
}
|
||||||
|
@ -268,13 +263,13 @@ void DialogNormal::SetSecondPointId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxSecondPoint, value);
|
setCurrentPointId(ui->comboBoxSecondPoint, value);
|
||||||
|
|
||||||
VisToolNormal *line = qobject_cast<VisToolNormal *>(vis);
|
auto *line = qobject_cast<VisToolNormal *>(vis);
|
||||||
SCASSERT(line != nullptr)
|
SCASSERT(line != nullptr)
|
||||||
line->setObject2Id(value);
|
line->setObject2Id(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DialogNormal::GetLineColor() const
|
auto DialogNormal::GetLineColor() const -> QString
|
||||||
{
|
{
|
||||||
return GetComboBoxCurrentData(ui->comboBoxLineColor, ColorBlack);
|
return GetComboBoxCurrentData(ui->comboBoxLineColor, ColorBlack);
|
||||||
}
|
}
|
||||||
|
@ -294,7 +289,7 @@ void DialogNormal::SetFirstPointId(quint32 value)
|
||||||
{
|
{
|
||||||
setCurrentPointId(ui->comboBoxFirstPoint, value);
|
setCurrentPointId(ui->comboBoxFirstPoint, value);
|
||||||
|
|
||||||
VisToolNormal *line = qobject_cast<VisToolNormal *>(vis);
|
auto *line = qobject_cast<VisToolNormal *>(vis);
|
||||||
SCASSERT(line != nullptr)
|
SCASSERT(line != nullptr)
|
||||||
line->setObject1Id(value);
|
line->setObject1Id(value);
|
||||||
}
|
}
|
||||||
|
@ -306,12 +301,12 @@ void DialogNormal::SetFirstPointId(quint32 value)
|
||||||
*/
|
*/
|
||||||
void DialogNormal::SetAngle(qreal value)
|
void DialogNormal::SetAngle(qreal value)
|
||||||
{
|
{
|
||||||
angle = value;
|
m_angle = value;
|
||||||
ui->doubleSpinBoxAngle->setValue(angle);
|
ui->doubleSpinBoxAngle->setValue(m_angle);
|
||||||
|
|
||||||
VisToolNormal *line = qobject_cast<VisToolNormal *>(vis);
|
auto *line = qobject_cast<VisToolNormal *>(vis);
|
||||||
SCASSERT(line != nullptr)
|
SCASSERT(line != nullptr)
|
||||||
line->SetAngle(angle);
|
line->SetAngle(m_angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -321,18 +316,18 @@ void DialogNormal::SetAngle(qreal value)
|
||||||
*/
|
*/
|
||||||
void DialogNormal::SetFormula(const QString &value)
|
void DialogNormal::SetFormula(const QString &value)
|
||||||
{
|
{
|
||||||
formula = VAbstractApplication::VApp()->TrVars()
|
m_formula = VAbstractApplication::VApp()->TrVars()
|
||||||
->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
|
->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
|
||||||
// increase height if needed.
|
// increase height if needed.
|
||||||
if (formula.length() > 80)
|
if (m_formula.length() > 80)
|
||||||
{
|
{
|
||||||
this->DeployFormulaTextEdit();
|
this->DeployFormulaTextEdit();
|
||||||
}
|
}
|
||||||
ui->plainTextEditFormula->setPlainText(formula);
|
ui->plainTextEditFormula->setPlainText(m_formula);
|
||||||
|
|
||||||
VisToolNormal *line = qobject_cast<VisToolNormal *>(vis);
|
auto *line = qobject_cast<VisToolNormal *>(vis);
|
||||||
SCASSERT(line != nullptr)
|
SCASSERT(line != nullptr)
|
||||||
line->setLength(formula);
|
line->setLength(m_formula);
|
||||||
|
|
||||||
MoveCursorToEnd(ui->plainTextEditFormula);
|
MoveCursorToEnd(ui->plainTextEditFormula);
|
||||||
}
|
}
|
||||||
|
@ -355,8 +350,8 @@ void DialogNormal::SetTypeLine(const QString &value)
|
||||||
*/
|
*/
|
||||||
void DialogNormal::SetPointName(const QString &value)
|
void DialogNormal::SetPointName(const QString &value)
|
||||||
{
|
{
|
||||||
pointName = value;
|
m_pointName = value;
|
||||||
ui->lineEditNamePoint->setText(pointName);
|
ui->lineEditNamePoint->setText(m_pointName);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -364,7 +359,7 @@ void DialogNormal::SetPointName(const QString &value)
|
||||||
* @brief GetTypeLine return type of line
|
* @brief GetTypeLine return type of line
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
QString DialogNormal::GetTypeLine() const
|
auto DialogNormal::GetTypeLine() const -> QString
|
||||||
{
|
{
|
||||||
return GetComboBoxCurrentData(ui->comboBoxLineType, TypeLineLine);
|
return GetComboBoxCurrentData(ui->comboBoxLineType, TypeLineLine);
|
||||||
}
|
}
|
||||||
|
@ -374,9 +369,9 @@ QString DialogNormal::GetTypeLine() const
|
||||||
* @brief GetFormula return string of formula
|
* @brief GetFormula return string of formula
|
||||||
* @return formula
|
* @return formula
|
||||||
*/
|
*/
|
||||||
QString DialogNormal::GetFormula() const
|
auto DialogNormal::GetFormula() const -> QString
|
||||||
{
|
{
|
||||||
return VTranslateVars::TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
|
return VTranslateVars::TryFormulaFromUser(m_formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -384,9 +379,9 @@ QString DialogNormal::GetFormula() const
|
||||||
* @brief GetAngle return aditional angle of normal
|
* @brief GetAngle return aditional angle of normal
|
||||||
* @return angle in degree
|
* @return angle in degree
|
||||||
*/
|
*/
|
||||||
qreal DialogNormal::GetAngle() const
|
auto DialogNormal::GetAngle() const -> qreal
|
||||||
{
|
{
|
||||||
return angle;
|
return m_angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -394,7 +389,7 @@ qreal DialogNormal::GetAngle() const
|
||||||
* @brief GetFirstPointId return id of first point
|
* @brief GetFirstPointId return id of first point
|
||||||
* @return id
|
* @return id
|
||||||
*/
|
*/
|
||||||
quint32 DialogNormal::GetFirstPointId() const
|
auto DialogNormal::GetFirstPointId() const -> quint32
|
||||||
{
|
{
|
||||||
return getCurrentObjectId(ui->comboBoxFirstPoint);
|
return getCurrentObjectId(ui->comboBoxFirstPoint);
|
||||||
}
|
}
|
||||||
|
@ -404,7 +399,7 @@ quint32 DialogNormal::GetFirstPointId() const
|
||||||
* @brief GetSecondPointId return id of second point
|
* @brief GetSecondPointId return id of second point
|
||||||
* @return id
|
* @return id
|
||||||
*/
|
*/
|
||||||
quint32 DialogNormal::GetSecondPointId() const
|
auto DialogNormal::GetSecondPointId() const -> quint32
|
||||||
{
|
{
|
||||||
return getCurrentObjectId(ui->comboBoxSecondPoint);
|
return getCurrentObjectId(ui->comboBoxSecondPoint);
|
||||||
}
|
}
|
||||||
|
@ -416,7 +411,7 @@ void DialogNormal::SetNotes(const QString ¬es)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString DialogNormal::GetNotes() const
|
auto DialogNormal::GetNotes() const -> QString
|
||||||
{
|
{
|
||||||
return ui->plainTextEditToolNotes->toPlainText();
|
return ui->plainTextEditToolNotes->toPlainText();
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,48 +51,48 @@ class DialogNormal : public DialogTool
|
||||||
Q_OBJECT // NOLINT
|
Q_OBJECT // NOLINT
|
||||||
public:
|
public:
|
||||||
DialogNormal(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
DialogNormal(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||||
virtual ~DialogNormal() override;
|
~DialogNormal() override;
|
||||||
|
|
||||||
QString GetPointName() const;
|
auto GetPointName() const -> QString;
|
||||||
void SetPointName(const QString &value);
|
void SetPointName(const QString &value);
|
||||||
|
|
||||||
QString GetTypeLine() const;
|
auto GetTypeLine() const -> QString;
|
||||||
void SetTypeLine(const QString &value);
|
void SetTypeLine(const QString &value);
|
||||||
|
|
||||||
QString GetFormula() const;
|
auto GetFormula() const -> QString;
|
||||||
void SetFormula(const QString &value);
|
void SetFormula(const QString &value);
|
||||||
|
|
||||||
qreal GetAngle() const;
|
auto GetAngle() const -> qreal;
|
||||||
void SetAngle(qreal value);
|
void SetAngle(qreal value);
|
||||||
|
|
||||||
quint32 GetFirstPointId() const;
|
auto GetFirstPointId() const -> quint32;
|
||||||
void SetFirstPointId(quint32 value);
|
void SetFirstPointId(quint32 value);
|
||||||
|
|
||||||
quint32 GetSecondPointId() const;
|
auto GetSecondPointId() const -> quint32;
|
||||||
void SetSecondPointId(quint32 value);
|
void SetSecondPointId(quint32 value);
|
||||||
|
|
||||||
QString GetLineColor() const;
|
auto GetLineColor() const -> QString;
|
||||||
void SetLineColor(const QString &value);
|
void SetLineColor(const QString &value);
|
||||||
|
|
||||||
void SetNotes(const QString ¬es);
|
void SetNotes(const QString ¬es);
|
||||||
QString GetNotes() const;
|
auto GetNotes() const -> QString;
|
||||||
public slots:
|
public slots:
|
||||||
virtual void ChosenObject(quint32 id, const SceneObject &type) override;
|
void ChosenObject(quint32 id, const SceneObject &type) override;
|
||||||
/**
|
/**
|
||||||
* @brief DeployFormulaTextEdit grow or shrink formula input
|
* @brief DeployFormulaTextEdit grow or shrink formula input
|
||||||
*/
|
*/
|
||||||
void DeployFormulaTextEdit();
|
void DeployFormulaTextEdit();
|
||||||
virtual void PointNameChanged() override;
|
void PointNameChanged() override;
|
||||||
void FXLength();
|
void FXLength();
|
||||||
void EvalFormula();
|
void EvalFormula();
|
||||||
protected:
|
protected:
|
||||||
virtual void ShowVisualization() override;
|
void ShowVisualization() override;
|
||||||
/**
|
/**
|
||||||
* @brief SaveData Put dialog data in local variables
|
* @brief SaveData Put dialog data in local variables
|
||||||
*/
|
*/
|
||||||
virtual void SaveData() override;
|
void SaveData() override;
|
||||||
virtual void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
virtual bool IsValid() const final;
|
auto IsValid() const -> bool final;
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY_MOVE(DialogNormal) // NOLINT
|
Q_DISABLE_COPY_MOVE(DialogNormal) // NOLINT
|
||||||
|
|
||||||
|
@ -100,27 +100,29 @@ private:
|
||||||
Ui::DialogNormal *ui;
|
Ui::DialogNormal *ui;
|
||||||
|
|
||||||
/** @brief formula formula */
|
/** @brief formula formula */
|
||||||
QString formula;
|
QString m_formula{};
|
||||||
|
|
||||||
/** @brief angle aditional angle of normal */
|
/** @brief angle aditional angle of normal */
|
||||||
qreal angle;
|
qreal m_angle{0};
|
||||||
|
|
||||||
/** @brief formulaBaseHeight base height defined by dialogui */
|
/** @brief formulaBaseHeight base height defined by dialogui */
|
||||||
int formulaBaseHeight;
|
int m_formulaBaseHeight{0};
|
||||||
|
|
||||||
QString pointName;
|
QString m_pointName{};
|
||||||
|
|
||||||
QTimer *timerFormula;
|
QTimer *m_timerFormula;
|
||||||
|
|
||||||
bool flagFormula;
|
bool m_flagFormula{false};
|
||||||
bool flagName;
|
bool m_flagName{true};
|
||||||
bool flagError;
|
bool m_flagError{true};
|
||||||
|
|
||||||
|
bool m_firstRelease{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
inline bool DialogNormal::IsValid() const
|
inline auto DialogNormal::IsValid() const -> bool
|
||||||
{
|
{
|
||||||
return flagFormula && flagName && flagError;
|
return m_flagFormula && m_flagName && m_flagError;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // DIALOGNORMAL_H
|
#endif // DIALOGNORMAL_H
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
|
|
||||||
template <class T> class QSharedPointer;
|
template <class T> class QSharedPointer;
|
||||||
|
|
||||||
const QString VToolAlongLine::ToolType = QStringLiteral("alongLine");
|
const QString VToolAlongLine::ToolType = QStringLiteral("alongLine"); // NOLINT(cert-err58-cpp)
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -67,7 +67,7 @@ const QString VToolAlongLine::ToolType = QStringLiteral("alongLine");
|
||||||
VToolAlongLine::VToolAlongLine(const VToolAlongLineInitData &initData, QGraphicsItem *parent)
|
VToolAlongLine::VToolAlongLine(const VToolAlongLineInitData &initData, QGraphicsItem *parent)
|
||||||
:VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, initData.formula,
|
:VToolLinePoint(initData.doc, initData.data, initData.id, initData.typeLine, initData.lineColor, initData.formula,
|
||||||
initData.firstPointId, 0, initData.notes, parent),
|
initData.firstPointId, 0, initData.notes, parent),
|
||||||
secondPointId(initData.secondPointId)
|
m_secondPointId(initData.secondPointId)
|
||||||
{
|
{
|
||||||
ToolCreation(initData.typeCreation);
|
ToolCreation(initData.typeCreation);
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ VToolAlongLine::VToolAlongLine(const VToolAlongLineInitData &initData, QGraphics
|
||||||
*/
|
*/
|
||||||
void VToolAlongLine::RemoveReferens()
|
void VToolAlongLine::RemoveReferens()
|
||||||
{
|
{
|
||||||
const auto secondPoint = VAbstractTool::data.GetGObject(secondPointId);
|
const auto secondPoint = VAbstractTool::data.GetGObject(m_secondPointId);
|
||||||
doc->DecrementReferens(secondPoint->getIdTool());
|
doc->DecrementReferens(secondPoint->getIdTool());
|
||||||
VToolLinePoint::RemoveReferens();
|
VToolLinePoint::RemoveReferens();
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ void VToolAlongLine::SaveDialog(QDomElement &domElement, QList<quint32> &oldDepe
|
||||||
SCASSERT(not dialogTool.isNull())
|
SCASSERT(not dialogTool.isNull())
|
||||||
|
|
||||||
AddDependence(oldDependencies, basePointId);
|
AddDependence(oldDependencies, basePointId);
|
||||||
AddDependence(oldDependencies, secondPointId);
|
AddDependence(oldDependencies, m_secondPointId);
|
||||||
AddDependence(newDependencies, dialogTool->GetFirstPointId());
|
AddDependence(newDependencies, dialogTool->GetFirstPointId());
|
||||||
AddDependence(newDependencies, dialogTool->GetSecondPointId());
|
AddDependence(newDependencies, dialogTool->GetSecondPointId());
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ void VToolAlongLine::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj
|
||||||
doc->SetAttribute(tag, AttrType, ToolType);
|
doc->SetAttribute(tag, AttrType, ToolType);
|
||||||
doc->SetAttribute(tag, AttrLength, formulaLength);
|
doc->SetAttribute(tag, AttrLength, formulaLength);
|
||||||
doc->SetAttribute(tag, AttrFirstPoint, basePointId);
|
doc->SetAttribute(tag, AttrFirstPoint, basePointId);
|
||||||
doc->SetAttribute(tag, AttrSecondPoint, secondPointId);
|
doc->SetAttribute(tag, AttrSecondPoint, m_secondPointId);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -127,11 +127,11 @@ void VToolAlongLine::ReadToolAttributes(const QDomElement &domElement)
|
||||||
{
|
{
|
||||||
VToolLinePoint::ReadToolAttributes(domElement);
|
VToolLinePoint::ReadToolAttributes(domElement);
|
||||||
|
|
||||||
m_lineType = doc->GetParametrString(domElement, AttrTypeLine, TypeLineLine);
|
m_lineType = VDomDocument::GetParametrString(domElement, AttrTypeLine, TypeLineLine);
|
||||||
lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack);
|
lineColor = VDomDocument::GetParametrString(domElement, AttrLineColor, ColorBlack);
|
||||||
formulaLength = doc->GetParametrString(domElement, AttrLength, QString());
|
formulaLength = VDomDocument::GetParametrString(domElement, AttrLength, QString());
|
||||||
basePointId = doc->GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
|
basePointId = VDomDocument::GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR);
|
||||||
secondPointId = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
|
m_secondPointId = VDomDocument::GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -139,10 +139,10 @@ void VToolAlongLine::SetVisualization()
|
||||||
{
|
{
|
||||||
if (not vis.isNull())
|
if (not vis.isNull())
|
||||||
{
|
{
|
||||||
VisToolAlongLine *visual = qobject_cast<VisToolAlongLine *>(vis);
|
auto *visual = qobject_cast<VisToolAlongLine *>(vis);
|
||||||
SCASSERT(visual != nullptr)
|
SCASSERT(visual != nullptr)
|
||||||
visual->setObject1Id(basePointId);
|
visual->setObject1Id(basePointId);
|
||||||
visual->setObject2Id(secondPointId);
|
visual->setObject2Id(m_secondPointId);
|
||||||
visual->setLength(VAbstractApplication::VApp()->TrVars()
|
visual->setLength(VAbstractApplication::VApp()->TrVars()
|
||||||
->FormulaToUser(formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator()));
|
->FormulaToUser(formulaLength, VAbstractApplication::VApp()->Settings()->GetOsSeparator()));
|
||||||
visual->setLineStyle(LineStyleToPenStyle(m_lineType));
|
visual->setLineStyle(LineStyleToPenStyle(m_lineType));
|
||||||
|
@ -151,10 +151,10 @@ void VToolAlongLine::SetVisualization()
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString VToolAlongLine::MakeToolTip() const
|
auto VToolAlongLine::MakeToolTip() const -> QString
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> basePoint = VAbstractTool::data.GeometricObject<VPointF>(basePointId);
|
const QSharedPointer<VPointF> basePoint = VAbstractTool::data.GeometricObject<VPointF>(basePointId);
|
||||||
const QSharedPointer<VPointF> secondPoint = VAbstractTool::data.GeometricObject<VPointF>(secondPointId);
|
const QSharedPointer<VPointF> secondPoint = VAbstractTool::data.GeometricObject<VPointF>(m_secondPointId);
|
||||||
const QSharedPointer<VPointF> current = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
const QSharedPointer<VPointF> current = VAbstractTool::data.GeometricObject<VPointF>(m_id);
|
||||||
|
|
||||||
const QLineF curLine(static_cast<QPointF>(*basePoint), static_cast<QPointF>(*current));
|
const QLineF curLine(static_cast<QPointF>(*basePoint), static_cast<QPointF>(*current));
|
||||||
|
@ -212,7 +212,7 @@ void VToolAlongLine::setDialog()
|
||||||
dialogTool->SetLineColor(lineColor);
|
dialogTool->SetLineColor(lineColor);
|
||||||
dialogTool->SetFormula(formulaLength);
|
dialogTool->SetFormula(formulaLength);
|
||||||
dialogTool->SetFirstPointId(basePointId);
|
dialogTool->SetFirstPointId(basePointId);
|
||||||
dialogTool->SetSecondPointId(secondPointId);
|
dialogTool->SetSecondPointId(m_secondPointId);
|
||||||
dialogTool->SetPointName(p->name());
|
dialogTool->SetPointName(p->name());
|
||||||
dialogTool->SetNotes(m_notes);
|
dialogTool->SetNotes(m_notes);
|
||||||
}
|
}
|
||||||
|
@ -225,8 +225,8 @@ void VToolAlongLine::setDialog()
|
||||||
* @param doc dom document container.
|
* @param doc dom document container.
|
||||||
* @param data container with variables.
|
* @param data container with variables.
|
||||||
*/
|
*/
|
||||||
VToolAlongLine* VToolAlongLine::Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene,
|
auto VToolAlongLine::Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene, VAbstractPattern *doc,
|
||||||
VAbstractPattern *doc, VContainer *data)
|
VContainer *data) -> VToolAlongLine*
|
||||||
{
|
{
|
||||||
SCASSERT(not dialog.isNull())
|
SCASSERT(not dialog.isNull())
|
||||||
const QPointer<DialogAlongLine> dialogTool = qobject_cast<DialogAlongLine *>(dialog);
|
const QPointer<DialogAlongLine> dialogTool = qobject_cast<DialogAlongLine *>(dialog);
|
||||||
|
@ -259,14 +259,14 @@ VToolAlongLine* VToolAlongLine::Create(const QPointer<DialogTool> &dialog, VMain
|
||||||
* @brief Create help create tool.
|
* @brief Create help create tool.
|
||||||
* @param initData init data.
|
* @param initData init data.
|
||||||
*/
|
*/
|
||||||
VToolAlongLine* VToolAlongLine::Create(VToolAlongLineInitData &initData)
|
auto VToolAlongLine::Create(VToolAlongLineInitData &initData) -> VToolAlongLine*
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> firstPoint = initData.data->GeometricObject<VPointF>(initData.firstPointId);
|
const QSharedPointer<VPointF> firstPoint = initData.data->GeometricObject<VPointF>(initData.firstPointId);
|
||||||
const QSharedPointer<VPointF> secondPoint = initData.data->GeometricObject<VPointF>(initData.secondPointId);
|
const QSharedPointer<VPointF> secondPoint = initData.data->GeometricObject<VPointF>(initData.secondPointId);
|
||||||
QLineF line = QLineF(static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*secondPoint));
|
QLineF line = QLineF(static_cast<QPointF>(*firstPoint), static_cast<QPointF>(*secondPoint));
|
||||||
|
|
||||||
//Declare special variable "CurrentLength"
|
//Declare special variable "CurrentLength"
|
||||||
VLengthLine *length = new VLengthLine(firstPoint.data(), initData.firstPointId, secondPoint.data(),
|
auto *length = new VLengthLine(firstPoint.data(), initData.firstPointId, secondPoint.data(),
|
||||||
initData.secondPointId, *initData.data->GetPatternUnit());
|
initData.secondPointId, *initData.data->GetPatternUnit());
|
||||||
length->SetName(currentLength);
|
length->SetName(currentLength);
|
||||||
initData.data->AddVariable(length);
|
initData.data->AddVariable(length);
|
||||||
|
@ -274,7 +274,7 @@ VToolAlongLine* VToolAlongLine::Create(VToolAlongLineInitData &initData)
|
||||||
line.setLength(VAbstractValApplication::VApp()->toPixel(
|
line.setLength(VAbstractValApplication::VApp()->toPixel(
|
||||||
CheckFormula(initData.id, initData.formula, initData.data)));
|
CheckFormula(initData.id, initData.formula, initData.data)));
|
||||||
|
|
||||||
VPointF *p = new VPointF(line.p2(), initData.name, initData.mx, initData.my);
|
auto *p = new VPointF(line.p2(), initData.name, initData.mx, initData.my);
|
||||||
p->SetShowLabel(initData.showLabel);
|
p->SetShowLabel(initData.showLabel);
|
||||||
|
|
||||||
if (initData.typeCreation == Source::FromGui)
|
if (initData.typeCreation == Source::FromGui)
|
||||||
|
@ -311,7 +311,7 @@ VToolAlongLine* VToolAlongLine::Create(VToolAlongLineInitData &initData)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString VToolAlongLine::SecondPointName() const
|
auto VToolAlongLine::SecondPointName() const -> QString
|
||||||
{
|
{
|
||||||
return VAbstractTool::data.GetGObject(secondPointId)->name();
|
return VAbstractTool::data.GetGObject(m_secondPointId)->name();
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,16 +45,11 @@ template <class T> class QSharedPointer;
|
||||||
|
|
||||||
struct VToolAlongLineInitData : VToolLinePointInitData
|
struct VToolAlongLineInitData : VToolLinePointInitData
|
||||||
{
|
{
|
||||||
VToolAlongLineInitData()
|
VToolAlongLineInitData() = default;
|
||||||
: VToolLinePointInitData(),
|
|
||||||
formula("100.0"),
|
|
||||||
firstPointId(NULL_ID),
|
|
||||||
secondPointId(NULL_ID)
|
|
||||||
{}
|
|
||||||
|
|
||||||
QString formula;
|
QString formula{QStringLiteral("100.0")}; // NOLINT(misc-non-private-member-variables-in-classes)
|
||||||
quint32 firstPointId;
|
quint32 firstPointId{NULL_ID}; // NOLINT(misc-non-private-member-variables-in-classes)
|
||||||
quint32 secondPointId;
|
quint32 secondPointId{NULL_ID}; // NOLINT(misc-non-private-member-variables-in-classes)
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,34 +59,35 @@ class VToolAlongLine : public VToolLinePoint
|
||||||
{
|
{
|
||||||
Q_OBJECT // NOLINT
|
Q_OBJECT // NOLINT
|
||||||
public:
|
public:
|
||||||
virtual void setDialog() override;
|
~VToolAlongLine() override = default;
|
||||||
static VToolAlongLine* Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene,
|
|
||||||
VAbstractPattern *doc, VContainer *data);
|
void setDialog() override;
|
||||||
static VToolAlongLine* Create(VToolAlongLineInitData &initData);
|
static auto Create(const QPointer<DialogTool> &dialog, VMainGraphicsScene *scene,
|
||||||
|
VAbstractPattern *doc, VContainer *data) -> VToolAlongLine*;
|
||||||
|
static auto Create(VToolAlongLineInitData &initData) -> VToolAlongLine*;
|
||||||
static const QString ToolType;
|
static const QString ToolType;
|
||||||
virtual int type() const override {return Type;}
|
auto type() const -> int override {return Type;}
|
||||||
enum { Type = UserType + static_cast<int>(Tool::AlongLine)};
|
enum { Type = UserType + static_cast<int>(Tool::AlongLine)};
|
||||||
|
|
||||||
QString SecondPointName() const;
|
auto SecondPointName() const -> QString;
|
||||||
|
|
||||||
virtual void ShowVisualization(bool show) override;
|
void ShowVisualization(bool show) override;
|
||||||
protected slots:
|
protected slots:
|
||||||
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) override;
|
void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) override;
|
||||||
protected:
|
protected:
|
||||||
virtual void RemoveReferens() override;
|
void RemoveReferens() override;
|
||||||
virtual void SaveDialog(QDomElement &domElement, QList<quint32> &oldDependencies,
|
void SaveDialog(QDomElement &domElement, QList<quint32> &oldDependencies, QList<quint32> &newDependencies) override;
|
||||||
QList<quint32> &newDependencies) override;
|
void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) override;
|
||||||
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) override;
|
void ReadToolAttributes(const QDomElement &domElement) override;
|
||||||
virtual void ReadToolAttributes(const QDomElement &domElement) override;
|
void SetVisualization() override;
|
||||||
virtual void SetVisualization() override;
|
auto MakeToolTip() const -> QString override;
|
||||||
virtual QString MakeToolTip() const override;
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY_MOVE(VToolAlongLine) // NOLINT
|
Q_DISABLE_COPY_MOVE(VToolAlongLine) // NOLINT
|
||||||
|
|
||||||
/** @brief secondPointId id second point of line. */
|
/** @brief secondPointId id second point of line. */
|
||||||
quint32 secondPointId;
|
quint32 m_secondPointId;
|
||||||
|
|
||||||
VToolAlongLine(const VToolAlongLineInitData &initData, QGraphicsItem *parent = nullptr);
|
explicit VToolAlongLine(const VToolAlongLineInitData &initData, QGraphicsItem *parent = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VTOOLALONGLINE_H
|
#endif // VTOOLALONGLINE_H
|
||||||
|
|
|
@ -45,34 +45,27 @@
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VisToolAlongLine::VisToolAlongLine(const VContainer *data, QGraphicsItem *parent)
|
VisToolAlongLine::VisToolAlongLine(const VContainer *data, QGraphicsItem *parent)
|
||||||
: VisLine(data, parent),
|
: VisLine(data, parent)
|
||||||
object2Id(NULL_ID),
|
|
||||||
point(nullptr),
|
|
||||||
lineP1(nullptr),
|
|
||||||
lineP2(nullptr),
|
|
||||||
line(nullptr),
|
|
||||||
length(0),
|
|
||||||
m_midPointMode(false)
|
|
||||||
{
|
{
|
||||||
this->mainColor = Qt::red;
|
this->mainColor = Qt::red;
|
||||||
this->setZValue(2);// Show on top real tool
|
this->setZValue(2);// Show on top real tool
|
||||||
|
|
||||||
lineP1 = InitPoint(supportColor, this);
|
m_lineP1 = InitPoint(supportColor, this);
|
||||||
lineP2 = InitPoint(supportColor, this); //-V656
|
m_lineP2 = InitPoint(supportColor, this); //-V656
|
||||||
line = InitItem<VScaledLine>(supportColor, this);
|
m_line = InitItem<VScaledLine>(supportColor, this);
|
||||||
point = InitPoint(mainColor, this);
|
m_point = InitPoint(mainColor, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolAlongLine::setObject2Id(const quint32 &value)
|
void VisToolAlongLine::setObject2Id(const quint32 &value)
|
||||||
{
|
{
|
||||||
object2Id = value;
|
m_object2Id = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VisToolAlongLine::setLength(const QString &expression)
|
void VisToolAlongLine::setLength(const QString &expression)
|
||||||
{
|
{
|
||||||
length = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
m_length = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -87,33 +80,33 @@ void VisToolAlongLine::RefreshGeometry()
|
||||||
if (object1Id > NULL_ID)
|
if (object1Id > NULL_ID)
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> first = Visualization::data->GeometricObject<VPointF>(object1Id);
|
const QSharedPointer<VPointF> first = Visualization::data->GeometricObject<VPointF>(object1Id);
|
||||||
DrawPoint(lineP1, static_cast<QPointF>(*first), supportColor);
|
DrawPoint(m_lineP1, static_cast<QPointF>(*first), supportColor);
|
||||||
|
|
||||||
if (object2Id <= NULL_ID)
|
if (m_object2Id <= NULL_ID)
|
||||||
{
|
{
|
||||||
QLineF cursorLine (static_cast<QPointF>(*first), Visualization::scenePos);
|
QLineF cursorLine (static_cast<QPointF>(*first), Visualization::scenePos);
|
||||||
DrawLine(line, cursorLine, supportColor);
|
DrawLine(m_line, cursorLine, supportColor);
|
||||||
|
|
||||||
if (m_midPointMode)
|
if (m_midPointMode)
|
||||||
{
|
{
|
||||||
cursorLine.setLength(cursorLine.length()/2.0);
|
cursorLine.setLength(cursorLine.length()/2.0);
|
||||||
DrawPoint(point, cursorLine.p2(), mainColor);
|
DrawPoint(m_point, cursorLine.p2(), mainColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const QSharedPointer<VPointF> second = Visualization::data->GeometricObject<VPointF>(object2Id);
|
const QSharedPointer<VPointF> second = Visualization::data->GeometricObject<VPointF>(m_object2Id);
|
||||||
DrawPoint(lineP2, static_cast<QPointF>(*second), supportColor);
|
DrawPoint(m_lineP2, static_cast<QPointF>(*second), supportColor);
|
||||||
|
|
||||||
QLineF baseLine(static_cast<QPointF>(*first), static_cast<QPointF>(*second));
|
QLineF baseLine(static_cast<QPointF>(*first), static_cast<QPointF>(*second));
|
||||||
DrawLine(line, baseLine, supportColor);
|
DrawLine(m_line, baseLine, supportColor);
|
||||||
|
|
||||||
if (not qFuzzyIsNull(length))
|
if (not qFuzzyIsNull(m_length))
|
||||||
{
|
{
|
||||||
QLineF mainLine = VGObject::BuildLine(static_cast<QPointF>(*first), length, line->line().angle());
|
QLineF mainLine = VGObject::BuildLine(static_cast<QPointF>(*first), m_length, m_line->line().angle());
|
||||||
DrawLine(this, mainLine, mainColor, lineStyle);
|
DrawLine(this, mainLine, mainColor, lineStyle);
|
||||||
|
|
||||||
DrawPoint(point, mainLine.p2(), mainColor);
|
DrawPoint(m_point, mainLine.p2(), mainColor);
|
||||||
}
|
}
|
||||||
else if (mode == Mode::Creation)
|
else if (mode == Mode::Creation)
|
||||||
{
|
{
|
||||||
|
@ -126,10 +119,10 @@ void VisToolAlongLine::RefreshGeometry()
|
||||||
len *= -1;
|
len *= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
QLineF mainLine = VGObject::BuildLine(static_cast<QPointF>(*first), len, line->line().angle());
|
QLineF mainLine = VGObject::BuildLine(static_cast<QPointF>(*first), len, m_line->line().angle());
|
||||||
DrawLine(this, mainLine, mainColor, lineStyle);
|
DrawLine(this, mainLine, mainColor, lineStyle);
|
||||||
|
|
||||||
DrawPoint(point, mainLine.p2(), mainColor);
|
DrawPoint(m_point, mainLine.p2(), mainColor);
|
||||||
|
|
||||||
const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||||
Visualization::toolTip = tr("Length = %1%2; "
|
Visualization::toolTip = tr("Length = %1%2; "
|
||||||
|
|
|
@ -44,24 +44,25 @@ class VisToolAlongLine final :public VisLine
|
||||||
Q_OBJECT // NOLINT
|
Q_OBJECT // NOLINT
|
||||||
public:
|
public:
|
||||||
explicit VisToolAlongLine(const VContainer *data, QGraphicsItem *parent = nullptr);
|
explicit VisToolAlongLine(const VContainer *data, QGraphicsItem *parent = nullptr);
|
||||||
virtual ~VisToolAlongLine() = default;
|
~VisToolAlongLine() override = default;
|
||||||
|
|
||||||
virtual void RefreshGeometry() override;
|
void RefreshGeometry() override;
|
||||||
void setObject2Id(const quint32 &value);
|
void setObject2Id(const quint32 &value);
|
||||||
void setLength(const QString &expression);
|
void setLength(const QString &expression);
|
||||||
void setMidPointMode(bool midPointMode);
|
void setMidPointMode(bool midPointMode);
|
||||||
virtual int type() const override {return Type;}
|
|
||||||
|
auto type() const -> int override {return Type;}
|
||||||
enum {Type = UserType + static_cast<int>(Vis::ToolAlongLine)};
|
enum {Type = UserType + static_cast<int>(Vis::ToolAlongLine)};
|
||||||
private:
|
private:
|
||||||
// cppcheck-suppress unknownMacro
|
// cppcheck-suppress unknownMacro
|
||||||
Q_DISABLE_COPY_MOVE(VisToolAlongLine) // NOLINT
|
Q_DISABLE_COPY_MOVE(VisToolAlongLine) // NOLINT
|
||||||
quint32 object2Id;
|
quint32 m_object2Id{NULL_ID};
|
||||||
VScaledEllipse *point;
|
VScaledEllipse *m_point{nullptr};
|
||||||
VScaledEllipse *lineP1;
|
VScaledEllipse *m_lineP1{nullptr};
|
||||||
VScaledEllipse *lineP2;
|
VScaledEllipse *m_lineP2{nullptr};
|
||||||
VScaledLine *line;
|
VScaledLine *m_line{nullptr};
|
||||||
qreal length;
|
qreal m_length{0};
|
||||||
bool m_midPointMode;
|
bool m_midPointMode{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VISTOOLALONGLINE_H
|
#endif // VISTOOLALONGLINE_H
|
||||||
|
|
Loading…
Reference in New Issue
Block a user