Refactoring.
This commit is contained in:
parent
de3179a37c
commit
0aac23ec8e
|
@ -43,13 +43,15 @@
|
|||
#include "../../visualization/line/vistoolbisector.h"
|
||||
#include "../../visualization/visualization.h"
|
||||
#include "../ifc/xml/vabstractpattern.h"
|
||||
#include "../ifc/xml/vdomdocument.h"
|
||||
#include "../support/dialogeditwrongformula.h"
|
||||
#include "../vmisc/vabstractapplication.h"
|
||||
#include "../vmisc/vcommonsettings.h"
|
||||
#include "../vpatterndb/vtranslatevars.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
#include "ui_dialogbisector.h"
|
||||
#include "../vwidgets/vabstractmainwindow.h"
|
||||
#include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
|
@ -60,24 +62,18 @@
|
|||
DialogBisector::DialogBisector(const VContainer *data, quint32 toolId, QWidget *parent)
|
||||
: DialogTool(data, toolId, parent),
|
||||
ui(new Ui::DialogBisector),
|
||||
formula(),
|
||||
pointName(),
|
||||
formulaBaseHeight(0),
|
||||
timerFormula(new QTimer(this)),
|
||||
flagFormula(false),
|
||||
flagError(true),
|
||||
flagName(true)
|
||||
m_timerFormula(new QTimer(this))
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
timerFormula->setSingleShot(true);
|
||||
connect(timerFormula, &QTimer::timeout, this, &DialogBisector::EvalFormula);
|
||||
m_timerFormula->setSingleShot(true);
|
||||
connect(m_timerFormula, &QTimer::timeout, this, &DialogBisector::EvalFormula);
|
||||
|
||||
ui->lineEditNamePoint->setClearButtonEnabled(true);
|
||||
|
||||
ui->lineEditNamePoint->setText(
|
||||
VAbstractValApplication::VApp()->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
|
||||
this->formulaBaseHeight = ui->plainTextEditFormula->height();
|
||||
this->m_formulaBaseHeight = ui->plainTextEditFormula->height();
|
||||
ui->plainTextEditFormula->installEventFilter(this);
|
||||
|
||||
InitOkCancelApply(ui);
|
||||
|
@ -91,12 +87,12 @@ DialogBisector::DialogBisector(const VContainer *data, quint32 toolId, QWidget *
|
|||
connect(ui->toolButtonExprLength, &QPushButton::clicked, this, &DialogBisector::FXLength);
|
||||
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();
|
||||
});
|
||||
connect(ui->plainTextEditFormula, &QPlainTextEdit::textChanged, this, [this]()
|
||||
{
|
||||
timerFormula->start(formulaTimerTimeout);
|
||||
m_timerFormula->start(formulaTimerTimeout);
|
||||
});
|
||||
connect(ui->pushButtonGrowLength, &QPushButton::clicked, this, &DialogBisector::DeployFormulaTextEdit);
|
||||
connect(ui->comboBoxFirstPoint, &QComboBox::currentTextChanged,
|
||||
|
@ -123,12 +119,12 @@ void DialogBisector::PointNameChanged()
|
|||
QColor color;
|
||||
if (set.size() != 3)
|
||||
{
|
||||
flagError = false;
|
||||
m_flagError = false;
|
||||
color = errorColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
flagError = true;
|
||||
m_flagError = true;
|
||||
color = OkColor(this);
|
||||
}
|
||||
ChangeColor(ui->labelFirstPoint, color);
|
||||
|
@ -140,7 +136,7 @@ void DialogBisector::PointNameChanged()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogBisector::FXLength()
|
||||
{
|
||||
DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, this);
|
||||
auto *dialog = new DialogEditWrongFormula(data, toolId, this);
|
||||
dialog->setWindowTitle(tr("Edit length"));
|
||||
dialog->SetFormula(GetFormula());
|
||||
dialog->setPostfix(UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true));
|
||||
|
@ -162,7 +158,7 @@ void DialogBisector::EvalFormula()
|
|||
formulaData.postfix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
formulaData.checkZero = false;
|
||||
|
||||
Eval(formulaData, flagFormula);
|
||||
Eval(formulaData, m_flagFormula);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -174,7 +170,7 @@ void DialogBisector::ShowVisualization()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogBisector::DeployFormulaTextEdit()
|
||||
{
|
||||
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, formulaBaseHeight);
|
||||
DeployFormula(this, ui->plainTextEditFormula, ui->pushButtonGrowLength, m_formulaBaseHeight);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -184,9 +180,9 @@ DialogBisector::~DialogBisector()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogBisector::GetPointName() const
|
||||
auto DialogBisector::GetPointName() const -> QString
|
||||
{
|
||||
return pointName;
|
||||
return m_pointName;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -197,56 +193,41 @@ QString DialogBisector::GetPointName() const
|
|||
*/
|
||||
void DialogBisector::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
|
||||
{
|
||||
if (type == SceneObject::Point)
|
||||
{
|
||||
VisToolBisector *line = qobject_cast<VisToolBisector *>(vis);
|
||||
SCASSERT(line != nullptr)
|
||||
return;
|
||||
}
|
||||
|
||||
switch (number)
|
||||
{
|
||||
case 0:
|
||||
if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point of angle")))
|
||||
if (type == SceneObject::Point)
|
||||
{
|
||||
auto *line = qobject_cast<VisToolBisector *>(vis);
|
||||
SCASSERT(line != nullptr)
|
||||
|
||||
switch (number)
|
||||
{
|
||||
case 0:
|
||||
if (SetObject(id, ui->comboBoxFirstPoint, tr("Select second point of angle")))
|
||||
{
|
||||
number++;
|
||||
line->VisualMode(id);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (getCurrentObjectId(ui->comboBoxFirstPoint) != id)
|
||||
{
|
||||
if (SetObject(id, ui->comboBoxSecondPoint, tr("Select third point of angle")))
|
||||
{
|
||||
number++;
|
||||
line->VisualMode(id);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (getCurrentObjectId(ui->comboBoxFirstPoint) != id)
|
||||
{
|
||||
if (SetObject(id, ui->comboBoxSecondPoint, tr("Select third point of angle")))
|
||||
{
|
||||
number++;
|
||||
line->setObject2Id(id);
|
||||
line->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
QSet<quint32> set;
|
||||
set.insert(getCurrentObjectId(ui->comboBoxFirstPoint));
|
||||
set.insert(getCurrentObjectId(ui->comboBoxSecondPoint));
|
||||
set.insert(id);
|
||||
|
||||
if (set.size() == 3)
|
||||
{
|
||||
if (SetObject(id, ui->comboBoxThirdPoint, QString()))
|
||||
{
|
||||
line->setObject3Id(id);
|
||||
line->RefreshGeometry();
|
||||
prepare = true;
|
||||
this->setModal(true);
|
||||
this->show();
|
||||
}
|
||||
line->setObject2Id(id);
|
||||
line->RefreshGeometry();
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
ChosenThirdPoint(id);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -258,8 +239,8 @@ void DialogBisector::ChosenObject(quint32 id, const SceneObject &type)
|
|||
*/
|
||||
void DialogBisector::SetPointName(const QString &value)
|
||||
{
|
||||
pointName = value;
|
||||
ui->lineEditNamePoint->setText(pointName);
|
||||
m_pointName = value;
|
||||
ui->lineEditNamePoint->setText(m_pointName);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -280,18 +261,18 @@ void DialogBisector::SetTypeLine(const QString &value)
|
|||
*/
|
||||
void DialogBisector::SetFormula(const QString &value)
|
||||
{
|
||||
formula = VAbstractApplication::VApp()->TrVars()
|
||||
m_formula = VAbstractApplication::VApp()->TrVars()
|
||||
->FormulaToUser(value, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
|
||||
// increase height if needed.
|
||||
if (formula.length() > 80)
|
||||
if (m_formula.length() > 80)
|
||||
{
|
||||
this->DeployFormulaTextEdit();
|
||||
}
|
||||
ui->plainTextEditFormula->setPlainText(formula);
|
||||
ui->plainTextEditFormula->setPlainText(m_formula);
|
||||
|
||||
VisToolBisector *line = qobject_cast<VisToolBisector *>(vis);
|
||||
auto *line = qobject_cast<VisToolBisector *>(vis);
|
||||
SCASSERT(line != nullptr)
|
||||
line->setLength(formula);
|
||||
line->setLength(m_formula);
|
||||
|
||||
MoveCursorToEnd(ui->plainTextEditFormula);
|
||||
}
|
||||
|
@ -305,7 +286,7 @@ void DialogBisector::SetFirstPointId(const quint32 &value)
|
|||
{
|
||||
setCurrentPointId(ui->comboBoxFirstPoint, value);
|
||||
|
||||
VisToolBisector *line = qobject_cast<VisToolBisector *>(vis);
|
||||
auto *line = qobject_cast<VisToolBisector *>(vis);
|
||||
SCASSERT(line != nullptr)
|
||||
line->setObject1Id(value);
|
||||
}
|
||||
|
@ -319,7 +300,7 @@ void DialogBisector::SetSecondPointId(const quint32 &value)
|
|||
{
|
||||
setCurrentPointId(ui->comboBoxSecondPoint, value);
|
||||
|
||||
VisToolBisector *line = qobject_cast<VisToolBisector *>(vis);
|
||||
auto *line = qobject_cast<VisToolBisector *>(vis);
|
||||
SCASSERT(line != nullptr)
|
||||
line->setObject2Id(value);
|
||||
}
|
||||
|
@ -333,13 +314,13 @@ void DialogBisector::SetThirdPointId(const quint32 &value)
|
|||
{
|
||||
setCurrentPointId(ui->comboBoxThirdPoint, value);
|
||||
|
||||
VisToolBisector *line = qobject_cast<VisToolBisector *>(vis);
|
||||
auto *line = qobject_cast<VisToolBisector *>(vis);
|
||||
SCASSERT(line != nullptr)
|
||||
line->setObject3Id(value);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogBisector::GetLineColor() const
|
||||
auto DialogBisector::GetLineColor() const -> QString
|
||||
{
|
||||
return GetComboBoxCurrentData(ui->comboBoxLineColor, ColorBlack);
|
||||
}
|
||||
|
@ -357,7 +338,7 @@ void DialogBisector::SetNotes(const QString ¬es)
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString DialogBisector::GetNotes() const
|
||||
auto DialogBisector::GetNotes() const -> QString
|
||||
{
|
||||
return ui->plainTextEditToolNotes->toPlainText();
|
||||
}
|
||||
|
@ -365,16 +346,16 @@ QString DialogBisector::GetNotes() const
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogBisector::SaveData()
|
||||
{
|
||||
pointName = ui->lineEditNamePoint->text();
|
||||
formula = ui->plainTextEditFormula->toPlainText();
|
||||
m_pointName = ui->lineEditNamePoint->text();
|
||||
m_formula = ui->plainTextEditFormula->toPlainText();
|
||||
|
||||
VisToolBisector *line = qobject_cast<VisToolBisector *>(vis);
|
||||
auto *line = qobject_cast<VisToolBisector *>(vis);
|
||||
SCASSERT(line != nullptr)
|
||||
|
||||
line->setObject1Id(GetFirstPointId());
|
||||
line->setObject2Id(GetSecondPointId());
|
||||
line->setObject3Id(GetThirdPointId());
|
||||
line->setLength(formula);
|
||||
line->setLength(m_formula);
|
||||
line->setLineStyle(LineStyleToPenStyle(GetTypeLine()));
|
||||
line->RefreshGeometry();
|
||||
}
|
||||
|
@ -386,12 +367,33 @@ void DialogBisector::closeEvent(QCloseEvent *event)
|
|||
DialogTool::closeEvent(event);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void DialogBisector::ChosenThirdPoint(quint32 id)
|
||||
{
|
||||
QSet<quint32> set;
|
||||
set.insert(getCurrentObjectId(ui->comboBoxFirstPoint));
|
||||
set.insert(getCurrentObjectId(ui->comboBoxSecondPoint));
|
||||
set.insert(id);
|
||||
|
||||
if (set.size() == 3)
|
||||
{
|
||||
if (SetObject(id, ui->comboBoxThirdPoint, QString()))
|
||||
{
|
||||
line->setObject3Id(id);
|
||||
line->RefreshGeometry();
|
||||
prepare = true;
|
||||
this->setModal(true);
|
||||
this->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief GetTypeLine return type of line
|
||||
* @return type
|
||||
*/
|
||||
QString DialogBisector::GetTypeLine() const
|
||||
auto DialogBisector::GetTypeLine() const -> QString
|
||||
{
|
||||
return GetComboBoxCurrentData(ui->comboBoxLineType, TypeLineLine);
|
||||
}
|
||||
|
@ -401,9 +403,9 @@ QString DialogBisector::GetTypeLine() const
|
|||
* @brief GetFormula return string of formula
|
||||
* @return formula
|
||||
*/
|
||||
QString DialogBisector::GetFormula() const
|
||||
auto DialogBisector::GetFormula() const -> QString
|
||||
{
|
||||
return VTranslateVars::TryFormulaFromUser(formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
|
||||
return VTranslateVars::TryFormulaFromUser(m_formula, VAbstractApplication::VApp()->Settings()->GetOsSeparator());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -411,7 +413,7 @@ QString DialogBisector::GetFormula() const
|
|||
* @brief GetFirstPointId return id of first point
|
||||
* @return id
|
||||
*/
|
||||
quint32 DialogBisector::GetFirstPointId() const
|
||||
auto DialogBisector::GetFirstPointId() const -> quint32
|
||||
{
|
||||
return getCurrentObjectId(ui->comboBoxFirstPoint);
|
||||
}
|
||||
|
@ -421,7 +423,7 @@ quint32 DialogBisector::GetFirstPointId() const
|
|||
* @brief GetSecondPointId return id of second point
|
||||
* @return id
|
||||
*/
|
||||
quint32 DialogBisector::GetSecondPointId() const
|
||||
auto DialogBisector::GetSecondPointId() const -> quint32
|
||||
{
|
||||
return getCurrentObjectId(ui->comboBoxSecondPoint);
|
||||
}
|
||||
|
@ -431,7 +433,7 @@ quint32 DialogBisector::GetSecondPointId() const
|
|||
* @brief GetThirdPointId return id of third point
|
||||
* @return id
|
||||
*/
|
||||
quint32 DialogBisector::GetThirdPointId() const
|
||||
auto DialogBisector::GetThirdPointId() const -> quint32
|
||||
{
|
||||
return getCurrentObjectId(ui->comboBoxThirdPoint);
|
||||
}
|
||||
|
|
|
@ -52,49 +52,49 @@ class DialogBisector final : public DialogTool
|
|||
public:
|
||||
|
||||
DialogBisector(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
|
||||
virtual ~DialogBisector() override;
|
||||
~DialogBisector() override;
|
||||
|
||||
QString GetPointName() const;
|
||||
void SetPointName(const QString &value);
|
||||
auto GetPointName() const -> QString;
|
||||
void SetPointName(const QString &value);
|
||||
|
||||
QString GetTypeLine() const;
|
||||
void SetTypeLine(const QString &value);
|
||||
auto GetTypeLine() const -> QString;
|
||||
void SetTypeLine(const QString &value);
|
||||
|
||||
QString GetFormula() const;
|
||||
void SetFormula(const QString &value);
|
||||
auto GetFormula() const -> QString;
|
||||
void SetFormula(const QString &value);
|
||||
|
||||
quint32 GetFirstPointId() const;
|
||||
void SetFirstPointId(const quint32 &value);
|
||||
auto GetFirstPointId() const -> quint32;
|
||||
void SetFirstPointId(const quint32 &value);
|
||||
|
||||
quint32 GetSecondPointId() const;
|
||||
void SetSecondPointId(const quint32 &value);
|
||||
auto GetSecondPointId() const -> quint32;
|
||||
void SetSecondPointId(const quint32 &value);
|
||||
|
||||
quint32 GetThirdPointId() const;
|
||||
void SetThirdPointId(const quint32 &value);
|
||||
auto GetThirdPointId() const -> quint32;
|
||||
void SetThirdPointId(const quint32 &value);
|
||||
|
||||
QString GetLineColor() const;
|
||||
void SetLineColor(const QString &value);
|
||||
auto GetLineColor() const -> QString;
|
||||
void SetLineColor(const QString &value);
|
||||
|
||||
void SetNotes(const QString ¬es);
|
||||
QString GetNotes() const;
|
||||
void SetNotes(const QString ¬es);
|
||||
auto GetNotes() const -> QString;
|
||||
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
|
||||
*/
|
||||
void DeployFormulaTextEdit();
|
||||
void DeployFormulaTextEdit();
|
||||
|
||||
virtual void PointNameChanged() override;
|
||||
void FXLength();
|
||||
void EvalFormula();
|
||||
void PointNameChanged() override;
|
||||
void FXLength();
|
||||
void EvalFormula();
|
||||
protected:
|
||||
virtual void ShowVisualization() override;
|
||||
void ShowVisualization() override;
|
||||
/**
|
||||
* @brief SaveData Put dialog data in local variables
|
||||
*/
|
||||
virtual void SaveData() override;
|
||||
virtual void closeEvent(QCloseEvent *event) override;
|
||||
virtual bool IsValid() const final;
|
||||
void SaveData() override;
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
auto IsValid() const -> bool final;
|
||||
private:
|
||||
Q_DISABLE_COPY_MOVE(DialogBisector) // NOLINT
|
||||
|
||||
|
@ -102,23 +102,27 @@ private:
|
|||
Ui::DialogBisector *ui;
|
||||
|
||||
/** @brief formula formula */
|
||||
QString formula;
|
||||
QString pointName;
|
||||
QString m_formula{};
|
||||
QString m_pointName{};
|
||||
|
||||
/** @brief formulaBaseHeight base height defined by dialogui */
|
||||
int formulaBaseHeight;
|
||||
int m_formulaBaseHeight{0};
|
||||
|
||||
QTimer *timerFormula;
|
||||
QTimer *m_timerFormula;
|
||||
|
||||
bool flagFormula;
|
||||
bool flagError;
|
||||
bool flagName;
|
||||
bool m_flagFormula{false};
|
||||
bool m_flagError{true};
|
||||
bool m_flagName{true};
|
||||
|
||||
bool m_firstRelease{false};
|
||||
|
||||
void ChosenThirdPoint(quint32 id);
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
inline bool DialogBisector::IsValid() const
|
||||
inline auto DialogBisector::IsValid() const -> bool
|
||||
{
|
||||
return flagFormula && flagError && flagName;
|
||||
return m_flagFormula && m_flagError && m_flagName;
|
||||
}
|
||||
|
||||
#endif // DIALOGBISECTOR_H
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include <new>
|
||||
|
||||
#include "../../tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.h"
|
||||
#include "../ifc/ifcdef.h"
|
||||
#include "../vgeometry/vgobject.h"
|
||||
#include "../vgeometry/vpointf.h"
|
||||
#include "../vpatterndb/vcontainer.h"
|
||||
|
@ -44,35 +43,34 @@
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolBisector::VisToolBisector(const VContainer *data, QGraphicsItem *parent)
|
||||
:VisLine(data, parent), object2Id(NULL_ID), object3Id(NULL_ID), point(nullptr), line1P1(nullptr), line1P2(nullptr),
|
||||
line1(nullptr), line2P2(nullptr), line2(nullptr), length(0)
|
||||
:VisLine(data, parent)
|
||||
{
|
||||
line1P1 = InitPoint(supportColor, this);
|
||||
line1P2 = InitPoint(supportColor, this); //-V656
|
||||
line1 = InitItem<VScaledLine>(supportColor, this);
|
||||
m_line1P1 = InitPoint(supportColor, this);
|
||||
m_line1P2 = InitPoint(supportColor, this); //-V656
|
||||
m_line1 = InitItem<VScaledLine>(supportColor, this);
|
||||
|
||||
line2P2 = InitPoint(supportColor, this);
|
||||
line2 = InitItem<VScaledLine>(supportColor, this);
|
||||
m_line2P2 = InitPoint(supportColor, this);
|
||||
m_line2 = InitItem<VScaledLine>(supportColor, this);
|
||||
|
||||
point = InitPoint(mainColor, this);
|
||||
m_point = InitPoint(mainColor, this);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolBisector::setObject2Id(const quint32 &value)
|
||||
{
|
||||
object2Id = value;
|
||||
m_object2Id = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolBisector::setObject3Id(const quint32 &value)
|
||||
{
|
||||
object3Id = value;
|
||||
m_object3Id = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolBisector::setLength(const QString &expression)
|
||||
{
|
||||
length = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
||||
m_length = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -81,39 +79,39 @@ void VisToolBisector::RefreshGeometry()
|
|||
if (object1Id > NULL_ID)
|
||||
{
|
||||
const QSharedPointer<VPointF> first = Visualization::data->GeometricObject<VPointF>(object1Id);
|
||||
DrawPoint(line1P1, static_cast<QPointF>(*first), supportColor);
|
||||
DrawPoint(m_line1P1, static_cast<QPointF>(*first), supportColor);
|
||||
|
||||
if (object2Id <= NULL_ID)
|
||||
if (m_object2Id <= NULL_ID)
|
||||
{
|
||||
DrawLine(line1, QLineF(static_cast<QPointF>(*first), Visualization::scenePos), supportColor);
|
||||
DrawLine(m_line1, QLineF(static_cast<QPointF>(*first), Visualization::scenePos), supportColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QSharedPointer<VPointF> second = Visualization::data->GeometricObject<VPointF>(object2Id);
|
||||
DrawPoint(line1P2, static_cast<QPointF>(*second), supportColor);
|
||||
const QSharedPointer<VPointF> second = Visualization::data->GeometricObject<VPointF>(m_object2Id);
|
||||
DrawPoint(m_line1P2, static_cast<QPointF>(*second), supportColor);
|
||||
|
||||
DrawLine(line1, QLineF(static_cast<QPointF>(*first), static_cast<QPointF>(*second)), supportColor);
|
||||
DrawLine(m_line1, QLineF(static_cast<QPointF>(*first), static_cast<QPointF>(*second)), supportColor);
|
||||
|
||||
if (object3Id <= NULL_ID)
|
||||
if (m_object3Id <= NULL_ID)
|
||||
{
|
||||
DrawLine(line2, QLineF(static_cast<QPointF>(*second), Visualization::scenePos), supportColor);
|
||||
DrawLine(m_line2, QLineF(static_cast<QPointF>(*second), Visualization::scenePos), supportColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QSharedPointer<VPointF> third = Visualization::data->GeometricObject<VPointF>(object3Id);
|
||||
DrawPoint(line2P2, static_cast<QPointF>(*third), supportColor);
|
||||
const QSharedPointer<VPointF> third = Visualization::data->GeometricObject<VPointF>(m_object3Id);
|
||||
DrawPoint(m_line2P2, static_cast<QPointF>(*third), supportColor);
|
||||
|
||||
DrawLine(line2, QLineF(static_cast<QPointF>(*second), static_cast<QPointF>(*third)), supportColor);
|
||||
DrawLine(m_line2, QLineF(static_cast<QPointF>(*second), static_cast<QPointF>(*third)), supportColor);
|
||||
|
||||
if (not qFuzzyIsNull(length))
|
||||
if (not qFuzzyIsNull(m_length))
|
||||
{
|
||||
qreal angle = VToolBisector::BisectorAngle(static_cast<QPointF>(*first),
|
||||
static_cast<QPointF>(*second),
|
||||
static_cast<QPointF>(*third));
|
||||
QLineF mainLine = VGObject::BuildLine(static_cast<QPointF>(*second), length, angle);
|
||||
QLineF mainLine = VGObject::BuildLine(static_cast<QPointF>(*second), m_length, angle);
|
||||
DrawLine(this, mainLine, mainColor, lineStyle);
|
||||
|
||||
DrawPoint(point, mainLine.p2(), mainColor);
|
||||
DrawPoint(m_point, mainLine.p2(), mainColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -44,26 +44,26 @@ class VisToolBisector :public VisLine
|
|||
Q_OBJECT // NOLINT
|
||||
public:
|
||||
explicit VisToolBisector(const VContainer *data, QGraphicsItem *parent = nullptr);
|
||||
virtual ~VisToolBisector() = default;
|
||||
~VisToolBisector() override = default;
|
||||
|
||||
virtual void RefreshGeometry() override;
|
||||
void setObject2Id(const quint32 &value);
|
||||
void setObject3Id(const quint32 &value);
|
||||
void setLength(const QString &expression);
|
||||
virtual int type() const override {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolBisector)};
|
||||
void RefreshGeometry() override;
|
||||
void setObject2Id(const quint32 &value);
|
||||
void setObject3Id(const quint32 &value);
|
||||
void setLength(const QString &expression);
|
||||
auto type() const -> int override {return Type;}
|
||||
enum {Type = UserType + static_cast<int>(Vis::ToolBisector)};
|
||||
private:
|
||||
// cppcheck-suppress unknownMacro
|
||||
Q_DISABLE_COPY_MOVE(VisToolBisector) // NOLINT
|
||||
quint32 object2Id;
|
||||
quint32 object3Id;
|
||||
VScaledEllipse *point;
|
||||
VScaledEllipse *line1P1;
|
||||
VScaledEllipse *line1P2;
|
||||
VScaledLine *line1;
|
||||
VScaledEllipse *line2P2;
|
||||
VScaledLine *line2;
|
||||
qreal length;
|
||||
quint32 m_object2Id{NULL_ID};
|
||||
quint32 m_object3Id{NULL_ID};
|
||||
VScaledEllipse *m_point{nullptr};
|
||||
VScaledEllipse *m_line1P1{nullptr};
|
||||
VScaledEllipse *m_line1P2{nullptr};
|
||||
VScaledLine *m_line1{nullptr};
|
||||
VScaledEllipse *m_line2P2{nullptr};
|
||||
VScaledLine *m_line2{nullptr};
|
||||
qreal m_length{0};
|
||||
};
|
||||
|
||||
#endif // VISTOOLBISECTOR_H
|
||||
|
|
|
@ -45,16 +45,15 @@
|
|||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
VisToolNormal::VisToolNormal(const VContainer *data, QGraphicsItem *parent)
|
||||
: VisLine(data, parent), object2Id(NULL_ID), point(nullptr), lineP1(nullptr), lineP2(nullptr), line(nullptr),
|
||||
length(0), angle(0)
|
||||
: VisLine(data, parent)
|
||||
{
|
||||
this->mainColor = Qt::red;
|
||||
|
||||
lineP1 = InitPoint(supportColor, this);
|
||||
lineP2 = InitPoint(supportColor, this); //-V656
|
||||
line = InitItem<VScaledLine>(supportColor, this);
|
||||
m_lineP1 = InitPoint(supportColor, this);
|
||||
m_lineP2 = InitPoint(supportColor, this); //-V656
|
||||
m_line = InitItem<VScaledLine>(supportColor, this);
|
||||
|
||||
point = InitPoint(mainColor, this);
|
||||
m_point = InitPoint(mainColor, this);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -63,12 +62,12 @@ void VisToolNormal::RefreshGeometry()
|
|||
if (object1Id > NULL_ID)
|
||||
{
|
||||
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 line_mouse(static_cast<QPointF>(*first), Visualization::scenePos);
|
||||
DrawLine(line, line_mouse, supportColor);
|
||||
DrawLine(m_line, line_mouse, supportColor);
|
||||
|
||||
QLineF normal = line_mouse.normalVector();
|
||||
QPointF endRay = Ray(normal.p1(), normal.angle());
|
||||
|
@ -76,20 +75,20 @@ void VisToolNormal::RefreshGeometry()
|
|||
}
|
||||
else
|
||||
{
|
||||
const QSharedPointer<VPointF> second = Visualization::data->GeometricObject<VPointF>(object2Id);
|
||||
DrawPoint(lineP2, static_cast<QPointF>(*second), supportColor);
|
||||
const QSharedPointer<VPointF> second = Visualization::data->GeometricObject<VPointF>(m_object2Id);
|
||||
DrawPoint(m_lineP2, static_cast<QPointF>(*second), supportColor);
|
||||
|
||||
QLineF line_mouse(static_cast<QPointF>(*first), static_cast<QPointF>(*second));
|
||||
DrawLine(line, line_mouse, supportColor);
|
||||
DrawLine(m_line, line_mouse, supportColor);
|
||||
|
||||
if (not qFuzzyIsNull(length))
|
||||
if (not qFuzzyIsNull(m_length))
|
||||
{
|
||||
QPointF fPoint = VToolNormal::FindPoint(static_cast<QPointF>(*first), static_cast<QPointF>(*second),
|
||||
length, angle);
|
||||
m_length, m_angle);
|
||||
QLineF mainLine = QLineF(static_cast<QPointF>(*first), fPoint);
|
||||
DrawLine(this, mainLine, mainColor, lineStyle);
|
||||
|
||||
DrawPoint(point, mainLine.p2(), mainColor);
|
||||
DrawPoint(m_point, mainLine.p2(), mainColor);
|
||||
}
|
||||
else if (mode == Mode::Creation)
|
||||
{
|
||||
|
@ -104,11 +103,11 @@ void VisToolNormal::RefreshGeometry()
|
|||
}
|
||||
|
||||
QPointF fPoint = VToolNormal::FindPoint(static_cast<QPointF>(*first), static_cast<QPointF>(*second),
|
||||
len, angle);
|
||||
len, m_angle);
|
||||
QLineF mainLine = QLineF(static_cast<QPointF>(*first), fPoint);
|
||||
DrawLine(this, mainLine, mainColor, lineStyle);
|
||||
|
||||
DrawPoint(point, mainLine.p2(), mainColor);
|
||||
DrawPoint(m_point, mainLine.p2(), mainColor);
|
||||
|
||||
const QString prefix = UnitsToStr(VAbstractValApplication::VApp()->patternUnits(), true);
|
||||
Visualization::toolTip = tr("Length = %1%2; "
|
||||
|
@ -129,23 +128,23 @@ void VisToolNormal::RefreshGeometry()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolNormal::setObject2Id(const quint32 &value)
|
||||
{
|
||||
object2Id = value;
|
||||
m_object2Id = value;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolNormal::setLength(const QString &expression)
|
||||
{
|
||||
length = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
||||
m_length = FindLengthFromUser(expression, Visualization::data->DataVariables());
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
qreal VisToolNormal::GetAngle() const
|
||||
auto VisToolNormal::GetAngle() const -> qreal
|
||||
{
|
||||
return angle;
|
||||
return m_angle;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VisToolNormal::SetAngle(const qreal &value)
|
||||
{
|
||||
angle = value;
|
||||
m_angle = value;
|
||||
}
|
||||
|
|
|
@ -44,27 +44,27 @@ class VisToolNormal : public VisLine
|
|||
Q_OBJECT // NOLINT
|
||||
public:
|
||||
explicit VisToolNormal(const VContainer *data, QGraphicsItem *parent = nullptr);
|
||||
virtual ~VisToolNormal() = default;
|
||||
~VisToolNormal() override = default;
|
||||
|
||||
virtual void RefreshGeometry() override;
|
||||
void RefreshGeometry() override;
|
||||
|
||||
void setObject2Id(const quint32 &value);
|
||||
void setLength(const QString &expression);
|
||||
qreal GetAngle() const;
|
||||
void SetAngle(const qreal &value);
|
||||
virtual int type() const override {return Type;}
|
||||
enum { Type = UserType + static_cast<int>(Vis::ToolNormal)};
|
||||
void setObject2Id(const quint32 &value);
|
||||
void setLength(const QString &expression);
|
||||
auto GetAngle() const -> qreal;
|
||||
void SetAngle(const qreal &value);
|
||||
auto type() const -> int override {return Type;}
|
||||
enum {Type = UserType + static_cast<int>(Vis::ToolNormal)};
|
||||
|
||||
private:
|
||||
// cppcheck-suppress unknownMacro
|
||||
Q_DISABLE_COPY_MOVE(VisToolNormal) // NOLINT
|
||||
quint32 object2Id;
|
||||
VScaledEllipse *point;
|
||||
VScaledEllipse *lineP1;
|
||||
VScaledEllipse *lineP2;
|
||||
VScaledLine *line;
|
||||
qreal length;
|
||||
qreal angle;
|
||||
quint32 m_object2Id{NULL_ID};
|
||||
VScaledEllipse *m_point{nullptr};
|
||||
VScaledEllipse *m_lineP1{nullptr};
|
||||
VScaledEllipse *m_lineP2{nullptr};
|
||||
VScaledLine *m_line{nullptr};
|
||||
qreal m_length{0};
|
||||
qreal m_angle{0};
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user