diff --git a/src/app/container/calculator.h b/src/app/container/calculator.h index c00cb2360..cb2089c9f 100644 --- a/src/app/container/calculator.h +++ b/src/app/container/calculator.h @@ -40,10 +40,10 @@ class VContainer; * Note. If created to many parser for different purpes in the same time parser can work wrong. * Example: * DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data); - * dialog->setFormula(formula); + * dialog->SetFormula(formula); * if (dialog->exec() == QDialog::Accepted) * { - * formula = dialog->getFormula(); + * formula = dialog->GetFormula(); * //Need delete dialog here because parser in dialog don't allow use correct separator for parsing here. * //Don't know why. * delete dialog; diff --git a/src/app/container/vformula.cpp b/src/app/container/vformula.cpp index ed3659a20..fa345e4a5 100644 --- a/src/app/container/vformula.cpp +++ b/src/app/container/vformula.cpp @@ -56,7 +56,7 @@ VFormula &VFormula::operator=(const VFormula &formula) { return *this; } - this->formula = formula.getFormula(); + this->formula = formula.GetFormula(); this->value = formula.getStringValue(); this->checkZero = formula.getCheckZero(); this->data = formula.getData(); @@ -69,7 +69,7 @@ VFormula &VFormula::operator=(const VFormula &formula) //--------------------------------------------------------------------------------------------------------------------- VFormula::VFormula(const VFormula &formula) - :formula(formula.getFormula()), value(formula.getStringValue()), checkZero(formula.getCheckZero()), + :formula(formula.GetFormula()), value(formula.getStringValue()), checkZero(formula.getCheckZero()), data(formula.getData()), toolId(formula.getToolId()), postfix(formula.getPostfix()), _error(formula.error()), dValue(formula.getDoubleValue()) {} @@ -78,7 +78,7 @@ VFormula::VFormula(const VFormula &formula) bool VFormula::operator==(const VFormula &formula) const { bool isEqual = false; - if (this->formula == formula.getFormula() && this->value == formula.getStringValue() && + if (this->formula == formula.GetFormula() && this->value == formula.getStringValue() && this->checkZero == formula.getCheckZero() && this->data == formula.getData() && this->toolId == formula.getToolId() && this->postfix == formula.getPostfix() && this->_error == formula.error() && qFuzzyCompare(this->dValue, formula.getDoubleValue())) @@ -94,7 +94,7 @@ bool VFormula::operator!=(const VFormula &formula) const } //--------------------------------------------------------------------------------------------------------------------- -QString VFormula::getFormula(FormulaType type) const +QString VFormula::GetFormula(FormulaType type) const { if (type == FormulaType::ToUser) { @@ -107,7 +107,7 @@ QString VFormula::getFormula(FormulaType type) const } //--------------------------------------------------------------------------------------------------------------------- -void VFormula::setFormula(const QString &value, FormulaType type) +void VFormula::SetFormula(const QString &value, FormulaType type) { if (formula != value) { diff --git a/src/app/container/vformula.h b/src/app/container/vformula.h index 222845442..7599dcdac 100644 --- a/src/app/container/vformula.h +++ b/src/app/container/vformula.h @@ -46,8 +46,8 @@ public: bool operator==(const VFormula &formula) const; bool operator!=(const VFormula &formula) const; - QString getFormula(FormulaType type = FormulaType::ToUser) const; - void setFormula(const QString &value, FormulaType type = FormulaType::ToUser); + QString GetFormula(FormulaType type = FormulaType::ToUser) const; + void SetFormula(const QString &value, FormulaType type = FormulaType::ToUser); QString getStringValue() const; qreal getDoubleValue() const; diff --git a/src/app/dialogs/app/dialoghistory.cpp b/src/app/dialogs/app/dialoghistory.cpp index 78b7c6d96..6e70e1b97 100644 --- a/src/app/dialogs/app/dialoghistory.cpp +++ b/src/app/dialogs/app/dialoghistory.cpp @@ -74,7 +74,7 @@ void DialogHistory::DialogAccepted() { QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); quint32 id = qvariant_cast(item->data(Qt::UserRole)); - emit ShowHistoryTool(id, Qt::green, false); + emit ShowHistoryTool(id, false); emit DialogClosed(QDialog::Accepted); } @@ -103,12 +103,12 @@ void DialogHistory::cellClicked(int row, int column) { QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); quint32 id = qvariant_cast(item->data(Qt::UserRole)); - emit ShowHistoryTool(id, Qt::green, false); + emit ShowHistoryTool(id, false); cursorToolRecordRow = row; item = ui->tableWidget->item(cursorToolRecordRow, 0); id = qvariant_cast(item->data(Qt::UserRole)); - emit ShowHistoryTool(id, Qt::green, true); + emit ShowHistoryTool(id, true); } } @@ -434,7 +434,7 @@ void DialogHistory::ShowPoint() cursorToolRecordRow = 0; item = ui->tableWidget->item(0, 0); quint32 id = qvariant_cast(item->data(Qt::UserRole)); - emit ShowHistoryTool(id, Qt::green, true); + emit ShowHistoryTool(id, true); } } @@ -466,6 +466,6 @@ void DialogHistory::closeEvent(QCloseEvent *event) { QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); quint32 id = qvariant_cast(item->data(Qt::UserRole)); - emit ShowHistoryTool(id, Qt::green, false); + emit ShowHistoryTool(id, false); DialogTool::closeEvent(event); } diff --git a/src/app/dialogs/app/dialoghistory.h b/src/app/dialogs/app/dialoghistory.h index 20b18e6b6..c6d085bf2 100644 --- a/src/app/dialogs/app/dialoghistory.h +++ b/src/app/dialogs/app/dialoghistory.h @@ -63,10 +63,9 @@ signals: /** * @brief ShowHistoryTool signal change color of selected in records tool * @param id id of tool - * @param color new color of tool * @param enable true enable selection, false disable selection */ - void ShowHistoryTool(quint32 id, Qt::GlobalColor color, bool enable); + void ShowHistoryTool(quint32 id, bool enable); protected: virtual void closeEvent ( QCloseEvent * event ); private: diff --git a/src/app/dialogs/tools/dialogalongline.cpp b/src/app/dialogs/tools/dialogalongline.cpp index dbf57e8b6..46463ff6e 100644 --- a/src/app/dialogs/tools/dialogalongline.cpp +++ b/src/app/dialogs/tools/dialogalongline.cpp @@ -41,9 +41,8 @@ * @param parent parent widget */ DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogAlongLine), number(0), - typeLine(QString()), formula(QString()), firstPointId(NULL_ID), secondPointId(NULL_ID), formulaBaseHeight(0), - line(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogAlongLine), + formula(QString()), formulaBaseHeight(0), line(nullptr) { ui->setupUi(this); InitVariables(ui); @@ -61,7 +60,7 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId, FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxSecondPoint); FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics()); - ui->comboBoxLineType->setCurrentIndex(0); + FillComboBoxLineColors(ui->comboBoxLineColor); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogAlongLine::PutHere); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogAlongLine::NamePointChanged); @@ -180,16 +179,14 @@ void DialogAlongLine::ChosenObject(quint32 id, const SceneObject &type) void DialogAlongLine::SaveData() { pointName = ui->lineEditNamePoint->text(); - typeLine = GetTypeLine(ui->comboBoxLineType); + formula = ui->plainTextEditFormula->toPlainText(); formula.replace("\n", " "); - firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint); - secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint); - line->setPoint1Id(firstPointId); - line->setPoint2Id(secondPointId); + line->setPoint1Id(GetFirstPointId()); + line->setPoint2Id(GetSecondPointId()); line->setLength(formula); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); + line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine())); line->RefreshGeometry(); } @@ -202,32 +199,32 @@ void DialogAlongLine::closeEvent(QCloseEvent *event) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setSecondPointId set id second point of line + * @brief SetSecondPointId set id second point of line * @param value id */ -void DialogAlongLine::setSecondPointId(const quint32 &value) +void DialogAlongLine::SetSecondPointId(const quint32 &value) { - setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value); + setCurrentPointId(ui->comboBoxSecondPoint, value); line->setPoint2Id(value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setFirstPointId set id first point of line + * @brief SetFirstPointId set id first point of line * @param value id */ -void DialogAlongLine::setFirstPointId(const quint32 &value) +void DialogAlongLine::SetFirstPointId(const quint32 &value) { - setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value); + setCurrentPointId(ui->comboBoxFirstPoint, value); line->setPoint1Id(value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setFormula set string of formula + * @brief SetFormula set string of formula * @param value formula */ -void DialogAlongLine::setFormula(const QString &value) +void DialogAlongLine::SetFormula(const QString &value) { formula = qApp->FormulaToUser(value); // increase height if needed. @@ -242,23 +239,74 @@ void DialogAlongLine::setFormula(const QString &value) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setTypeLine set type of line + * @brief SetTypeLine set type of line * @param value type */ -void DialogAlongLine::setTypeLine(const QString &value) +void DialogAlongLine::SetTypeLine(const QString &value) { - typeLine = value; - SetupTypeLine(ui->comboBoxLineType, value); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); + ChangeCurrentData(ui->comboBoxLineType, value); + line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogAlongLine::GetLineColor() const +{ + return GetComboBoxCurrentData(ui->comboBoxLineColor); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogAlongLine::SetLineColor(const QString &value) +{ + ChangeCurrentData(ui->comboBoxLineColor, value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setPointName set name of point + * @brief SetPointName set name of point * @param value name */ -void DialogAlongLine::setPointName(const QString &value) +void DialogAlongLine::SetPointName(const QString &value) { pointName = value; ui->lineEditNamePoint->setText(pointName); } + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetTypeLine return type of line + * @return type + */ +QString DialogAlongLine::GetTypeLine() const +{ + return GetComboBoxCurrentData(ui->comboBoxLineType); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetFormula return string of formula + * @return formula + */ +QString DialogAlongLine::GetFormula() const +{ + return qApp->FormulaFromUser(formula); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetFirstPointId return id first point of line + * @return id + */ +quint32 DialogAlongLine::GetFirstPointId() const +{ + return getCurrentObjectId(ui->comboBoxFirstPoint); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetSecondPointId return id second point of line + * @return id + */ +quint32 DialogAlongLine::GetSecondPointId() const +{ + return getCurrentObjectId(ui->comboBoxSecondPoint); +} diff --git a/src/app/dialogs/tools/dialogalongline.h b/src/app/dialogs/tools/dialogalongline.h index 01dd498a5..057f7763b 100644 --- a/src/app/dialogs/tools/dialogalongline.h +++ b/src/app/dialogs/tools/dialogalongline.h @@ -47,20 +47,23 @@ class DialogAlongLine : public DialogTool public: DialogAlongLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); ~DialogAlongLine(); - QString getPointName() const; - void setPointName(const QString &value); - QString getTypeLine() const; - void setTypeLine(const QString &value); + void SetPointName(const QString &value); - QString getFormula() const; - void setFormula(const QString &value); + QString GetTypeLine() const; + void SetTypeLine(const QString &value); - quint32 getFirstPointId() const; - void setFirstPointId(const quint32 &value); + QString GetLineColor() const; + void SetLineColor(const QString &value); - quint32 getSecondPointId() const; - void setSecondPointId(const quint32 &value); + QString GetFormula() const; + void SetFormula(const QString &value); + + quint32 GetFirstPointId() const; + void SetFirstPointId(const quint32 &value); + + quint32 GetSecondPointId() const; + void SetSecondPointId(const quint32 &value); public slots: virtual void ChosenObject(quint32 id, const SceneObject &type); /** @@ -85,74 +88,12 @@ private: /** @brief ui keeps information about user interface */ Ui::DialogAlongLine *ui; - /** @brief number number of handled objects */ - qint32 number; - - /** @brief typeLine type of line */ - QString typeLine; - /** @brief formula formula */ QString formula; - /** @brief firstPointId id first point of line */ - quint32 firstPointId; - - /** @brief secondPointId id second point of line */ - quint32 secondPointId; - /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; VisToolAlongLine *line; }; -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getPointName return name of point - * @return name - */ -inline QString DialogAlongLine::getPointName() const -{ - return pointName; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getTypeLine return type of line - * @return type - */ -inline QString DialogAlongLine::getTypeLine() const -{ - return typeLine; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getFormula return string of formula - * @return formula - */ -inline QString DialogAlongLine::getFormula() const -{ - return qApp->FormulaFromUser(formula); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getFirstPointId return id first point of line - * @return id - */ -inline quint32 DialogAlongLine::getFirstPointId() const -{ - return firstPointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getSecondPointId return id second point of line - * @return id - */ -inline quint32 DialogAlongLine::getSecondPointId() const -{ - return secondPointId; -} - #endif // DIALOGALONGLINE_H diff --git a/src/app/dialogs/tools/dialogalongline.ui b/src/app/dialogs/tools/dialogalongline.ui index a2e13e7e6..3dec6c83a 100644 --- a/src/app/dialogs/tools/dialogalongline.ui +++ b/src/app/dialogs/tools/dialogalongline.ui @@ -7,7 +7,7 @@ 0 0 428 - 499 + 532 @@ -223,6 +223,9 @@ + + QFormLayout::AllNonFixedFieldsGrow + @@ -230,9 +233,6 @@ - - - @@ -299,6 +299,19 @@ + + + + Line color + + + + + + + + + diff --git a/src/app/dialogs/tools/dialogarc.cpp b/src/app/dialogs/tools/dialogarc.cpp index 045f0c2be..92a78cf4d 100644 --- a/src/app/dialogs/tools/dialogarc.cpp +++ b/src/app/dialogs/tools/dialogarc.cpp @@ -45,9 +45,9 @@ */ DialogArc::DialogArc(const VContainer *data, const quint32 &toolId, QWidget *parent) :DialogTool(data, toolId, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false), - timerRadius(nullptr), timerF1(nullptr), timerF2(nullptr), center(NULL_ID), radius(QString()), - f1(QString()), f2(QString()), formulaBaseHeight(0), formulaBaseHeightF1(0), formulaBaseHeightF2(0), path(nullptr), - angleF1(INT_MIN), angleF2(INT_MIN) + timerRadius(nullptr), timerF1(nullptr), timerF2(nullptr), radius(QString()), f1(QString()), f2(QString()), + formulaBaseHeight(0), formulaBaseHeightF1(0), formulaBaseHeightF2(0), path(nullptr), angleF1(INT_MIN), + angleF2(INT_MIN) { ui->setupUi(this); @@ -74,6 +74,7 @@ DialogArc::DialogArc(const VContainer *data, const quint32 &toolId, QWidget *par InitOkCancelApply(ui); FillComboBoxPoints(ui->comboBoxBasePoint); + FillComboBoxLineColors(ui->comboBoxColor); CheckState(); @@ -131,9 +132,8 @@ DialogArc::~DialogArc() */ void DialogArc::SetCenter(const quint32 &value) { - center = value; - ChangeCurrentData(ui->comboBoxBasePoint, center); - path->setPoint1Id(center); + ChangeCurrentData(ui->comboBoxBasePoint, value); + path->setPoint1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -154,6 +154,18 @@ void DialogArc::SetF2(const QString &value) MoveCursorToEnd(ui->plainTextEditF2); } +//--------------------------------------------------------------------------------------------------------------------- +QString DialogArc::GetColor() const +{ + return GetComboBoxCurrentData(ui->comboBoxColor); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogArc::SetColor(const QString &value) +{ + ChangeCurrentData(ui->comboBoxColor, value); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief SetF1 set formula first angle of arc @@ -234,9 +246,8 @@ void DialogArc::SaveData() f1.replace("\n", " "); f2 = ui->plainTextEditF2->toPlainText(); f2.replace("\n", " "); - center = getCurrentObjectId(ui->comboBoxBasePoint); - path->setPoint1Id(center); + path->setPoint1Id(GetCenter()); path->setRadius(radius); path->setF1(f1); path->setF2(f2); @@ -436,3 +447,43 @@ void DialogArc::CheckAngles() DialogArc::CheckState(); } + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetCenter return id of center point + * @return id id + */ +quint32 DialogArc::GetCenter() const +{ + return getCurrentObjectId(ui->comboBoxBasePoint); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetRadius return formula of radius + * @return formula + */ +QString DialogArc::GetRadius() const +{ + return radius; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetF1 return formula first angle of arc + * @return formula + */ +QString DialogArc::GetF1() const +{ + return f1; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetF2 return formula second angle of arc + * @return formula + */ +QString DialogArc::GetF2() const +{ + return f2; +} diff --git a/src/app/dialogs/tools/dialogarc.h b/src/app/dialogs/tools/dialogarc.h index 189e86abe..40de32e27 100644 --- a/src/app/dialogs/tools/dialogarc.h +++ b/src/app/dialogs/tools/dialogarc.h @@ -59,6 +59,9 @@ public: QString GetF2() const; void SetF2(const QString &value); + + QString GetColor() const; + void SetColor(const QString &value); public slots: virtual void ChosenObject(quint32 id, const SceneObject &type); /** @@ -108,9 +111,6 @@ private: /** @brief timerF2 timer of check formula of second angle */ QTimer *timerF2; - /** @brief center id of center point */ - quint32 center; - /** @brief radius formula of radius */ QString radius; @@ -136,44 +136,4 @@ private: void CheckAngles(); }; -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief GetCenter return id of center point - * @return id id - */ -inline quint32 DialogArc::GetCenter() const -{ - return center; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief GetRadius return formula of radius - * @return formula - */ -inline QString DialogArc::GetRadius() const -{ - return radius; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief GetF1 return formula first angle of arc - * @return formula - */ -inline QString DialogArc::GetF1() const -{ - return f1; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief GetF2 return formula second angle of arc - * @return formula - */ -inline QString DialogArc::GetF2() const -{ - return f2; -} - #endif // DIALOGARC_H diff --git a/src/app/dialogs/tools/dialogarc.ui b/src/app/dialogs/tools/dialogarc.ui index 4bf89a0cc..84ccc7856 100644 --- a/src/app/dialogs/tools/dialogarc.ui +++ b/src/app/dialogs/tools/dialogarc.ui @@ -6,8 +6,8 @@ 0 0 - 423 - 544 + 425 + 577 @@ -583,32 +583,42 @@ - - - - - - - 0 - 0 - - - - Center point - - - - - - - Select point of center of arc - - - - - + + + + + + + 0 + 0 + + + + Center point + + + + + + + Select point of center of arc + + + + + + + + + + Color + + + + + @@ -782,7 +792,6 @@ pushButtonGrowLengthF1 toolButtonPutHereF2 toolButtonEqualF2 - comboBoxBasePoint radioButtonSizeGrowth radioButtonStandardTable radioButtonIncrements diff --git a/src/app/dialogs/tools/dialogbisector.cpp b/src/app/dialogs/tools/dialogbisector.cpp index 90c4449ed..98e68ab91 100644 --- a/src/app/dialogs/tools/dialogbisector.cpp +++ b/src/app/dialogs/tools/dialogbisector.cpp @@ -42,8 +42,7 @@ * @param parent parent widget */ DialogBisector::DialogBisector(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogBisector), number(0), typeLine(QString()), - formula(QString()), firstPointId(NULL_ID), secondPointId(NULL_ID), thirdPointId(NULL_ID), formulaBaseHeight(0), + :DialogTool(data, toolId, parent), ui(new Ui::DialogBisector), formula(QString()), formulaBaseHeight(0), line(nullptr) { ui->setupUi(this); @@ -62,6 +61,7 @@ DialogBisector::DialogBisector(const VContainer *data, const quint32 &toolId, QW FillComboBoxPoints(ui->comboBoxSecondPoint); FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics()); FillComboBoxPoints(ui->comboBoxThirdPoint); + FillComboBoxLineColors(ui->comboBoxLineColor); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogBisector::PutHere); connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogBisector::PutVal); @@ -200,10 +200,10 @@ void DialogBisector::ChosenObject(quint32 id, const SceneObject &type) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setPointName set name of point + * @brief SetPointName set name of point * @param value name */ -void DialogBisector::setPointName(const QString &value) +void DialogBisector::SetPointName(const QString &value) { pointName = value; ui->lineEditNamePoint->setText(pointName); @@ -211,22 +211,21 @@ void DialogBisector::setPointName(const QString &value) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setTypeLine set type of line + * @brief SetTypeLine set type of line * @param value type */ -void DialogBisector::setTypeLine(const QString &value) +void DialogBisector::SetTypeLine(const QString &value) { - typeLine = value; - SetupTypeLine(ui->comboBoxLineType, value); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); + ChangeCurrentData(ui->comboBoxLineType, value); + line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setFormula set string of formula + * @brief SetFormula set string of formula * @param value formula */ -void DialogBisector::setFormula(const QString &value) +void DialogBisector::SetFormula(const QString &value) { formula = qApp->FormulaToUser(value); // increase height if needed. @@ -241,53 +240,62 @@ void DialogBisector::setFormula(const QString &value) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setFirstPointId set id of first point + * @brief SetFirstPointId set id of first point * @param value id */ -void DialogBisector::setFirstPointId(const quint32 &value) +void DialogBisector::SetFirstPointId(const quint32 &value) { - setPointId(ui->comboBoxFirstPoint, firstPointId, value); - line->setPoint1Id(firstPointId); + setCurrentPointId(ui->comboBoxFirstPoint, value); + line->setPoint1Id(value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setSecondPointId set id of second point + * @brief SetSecondPointId set id of second point * @param value id */ -void DialogBisector::setSecondPointId(const quint32 &value) +void DialogBisector::SetSecondPointId(const quint32 &value) { - setPointId(ui->comboBoxSecondPoint, secondPointId, value); - line->setPoint2Id(secondPointId); + setCurrentPointId(ui->comboBoxSecondPoint, value); + line->setPoint2Id(value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setThirdPointId set id of third point + * @brief SetThirdPointId set id of third point * @param value id */ -void DialogBisector::setThirdPointId(const quint32 &value) +void DialogBisector::SetThirdPointId(const quint32 &value) { - setPointId(ui->comboBoxThirdPoint, thirdPointId, value); - line->setPoint3Id(thirdPointId); + setCurrentPointId(ui->comboBoxThirdPoint, value); + line->setPoint3Id(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogBisector::GetLineColor() const +{ + return GetComboBoxCurrentData(ui->comboBoxLineColor); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogBisector::SetLineColor(const QString &value) +{ + ChangeCurrentData(ui->comboBoxLineColor, value); } //--------------------------------------------------------------------------------------------------------------------- void DialogBisector::SaveData() { pointName = ui->lineEditNamePoint->text(); - typeLine = GetTypeLine(ui->comboBoxLineType); + formula = ui->plainTextEditFormula->toPlainText(); formula.replace("\n", " "); - firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint); - secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint); - thirdPointId = getCurrentObjectId(ui->comboBoxThirdPoint); - line->setPoint1Id(firstPointId); - line->setPoint2Id(secondPointId); - line->setPoint3Id(thirdPointId); + line->setPoint1Id(GetFirstPointId()); + line->setPoint2Id(GetSecondPointId()); + line->setPoint3Id(GetThirdPointId()); line->setLength(formula); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); + line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine())); line->RefreshGeometry(); } @@ -297,3 +305,53 @@ void DialogBisector::closeEvent(QCloseEvent *event) ui->plainTextEditFormula->blockSignals(true); DialogTool::closeEvent(event); } + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetTypeLine return type of line + * @return type + */ +QString DialogBisector::GetTypeLine() const +{ + return GetComboBoxCurrentData(ui->comboBoxLineType); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetFormula return string of formula + * @return formula + */ +QString DialogBisector::GetFormula() const +{ + return qApp->FormulaFromUser(formula); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetFirstPointId return id of first point + * @return id + */ +quint32 DialogBisector::GetFirstPointId() const +{ + return getCurrentObjectId(ui->comboBoxFirstPoint); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetSecondPointId return id of second point + * @return id + */ +quint32 DialogBisector::GetSecondPointId() const +{ + return getCurrentObjectId(ui->comboBoxSecondPoint); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetThirdPointId return id of third point + * @return id + */ +quint32 DialogBisector::GetThirdPointId() const +{ + return getCurrentObjectId(ui->comboBoxThirdPoint); +} diff --git a/src/app/dialogs/tools/dialogbisector.h b/src/app/dialogs/tools/dialogbisector.h index 2cc69c2ca..4cadc9bb9 100644 --- a/src/app/dialogs/tools/dialogbisector.h +++ b/src/app/dialogs/tools/dialogbisector.h @@ -49,23 +49,25 @@ public: DialogBisector(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); ~DialogBisector(); - QString getPointName() const; - void setPointName(const QString &value); + void SetPointName(const QString &value); - QString getTypeLine() const; - void setTypeLine(const QString &value); + QString GetTypeLine() const; + void SetTypeLine(const QString &value); - QString getFormula() const; - void setFormula(const QString &value); + QString GetFormula() const; + void SetFormula(const QString &value); - quint32 getFirstPointId() const; - void setFirstPointId(const quint32 &value); + quint32 GetFirstPointId() const; + void SetFirstPointId(const quint32 &value); - quint32 getSecondPointId() const; - void setSecondPointId(const quint32 &value); + quint32 GetSecondPointId() const; + void SetSecondPointId(const quint32 &value); - quint32 getThirdPointId() const; - void setThirdPointId(const quint32 &value); + quint32 GetThirdPointId() const; + void SetThirdPointId(const quint32 &value); + + QString GetLineColor() const; + void SetLineColor(const QString &value); public slots: virtual void ChosenObject(quint32 id, const SceneObject &type); /** @@ -90,88 +92,13 @@ private: /** @brief ui keeps information about user interface */ Ui::DialogBisector *ui; - /** @brief number number of handled objects */ - qint32 number; - - /** @brief typeLine type of line */ - QString typeLine; - /** @brief formula formula */ QString formula; - /** @brief firstPointId id of first point */ - quint32 firstPointId; - - /** @brief secondPointId id of second point */ - quint32 secondPointId; - - /** @brief thirdPointId id of third point */ - quint32 thirdPointId; - /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; VisToolBisector *line; }; -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getPointName return name of point - * @return name - */ -inline QString DialogBisector::getPointName() const -{ - return pointName; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getTypeLine return type of line - * @return type - */ -inline QString DialogBisector::getTypeLine() const -{ - return typeLine; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getFormula return string of formula - * @return formula - */ -inline QString DialogBisector::getFormula() const -{ - return qApp->FormulaFromUser(formula); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getFirstPointId return id of first point - * @return id - */ -inline quint32 DialogBisector::getFirstPointId() const -{ - return firstPointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getSecondPointId return id of second point - * @return id - */ -inline quint32 DialogBisector::getSecondPointId() const -{ - return secondPointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getThirdPointId return id of third point - * @return id - */ -inline quint32 DialogBisector::getThirdPointId() const -{ - return thirdPointId; -} - #endif // DIALOGBISECTOR_H diff --git a/src/app/dialogs/tools/dialogbisector.ui b/src/app/dialogs/tools/dialogbisector.ui index c4ad6001a..40d359b8b 100644 --- a/src/app/dialogs/tools/dialogbisector.ui +++ b/src/app/dialogs/tools/dialogbisector.ui @@ -7,7 +7,7 @@ 0 0 428 - 532 + 565 @@ -325,6 +325,16 @@ + + + + Line color + + + + + + diff --git a/src/app/dialogs/tools/dialogcurveintersectaxis.cpp b/src/app/dialogs/tools/dialogcurveintersectaxis.cpp index 43eefe4a4..839fb5dc5 100644 --- a/src/app/dialogs/tools/dialogcurveintersectaxis.cpp +++ b/src/app/dialogs/tools/dialogcurveintersectaxis.cpp @@ -38,8 +38,8 @@ //--------------------------------------------------------------------------------------------------------------------- DialogCurveIntersectAxis::DialogCurveIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogCurveIntersectAxis), number(0), typeLine(QString()), - formulaAngle(QString()), basePointId(NULL_ID), curveId(NULL_ID), formulaBaseHeightAngle(0), line(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogCurveIntersectAxis), + formulaAngle(QString()), formulaBaseHeightAngle(0), line(nullptr) { ui->setupUi(this); @@ -57,6 +57,7 @@ DialogCurveIntersectAxis::DialogCurveIntersectAxis(const VContainer *data, const FillComboBoxPoints(ui->comboBoxAxisPoint); FillComboBoxCurves(ui->comboBoxCurve); FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics()); + FillComboBoxLineColors(ui->comboBoxLineColor); connect(ui->toolButtonPutHereAngle, &QPushButton::clicked, this, &DialogCurveIntersectAxis::PutAngle); connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogCurveIntersectAxis::PutVal); @@ -80,40 +81,33 @@ DialogCurveIntersectAxis::~DialogCurveIntersectAxis() } //--------------------------------------------------------------------------------------------------------------------- -QString DialogCurveIntersectAxis::getPointName() const -{ - return pointName; -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogCurveIntersectAxis::setPointName(const QString &value) +void DialogCurveIntersectAxis::SetPointName(const QString &value) { pointName = value; ui->lineEditNamePoint->setText(pointName); } //--------------------------------------------------------------------------------------------------------------------- -QString DialogCurveIntersectAxis::getTypeLine() const +QString DialogCurveIntersectAxis::GetTypeLine() const { - return typeLine; + return GetComboBoxCurrentData(ui->comboBoxLineType); } //--------------------------------------------------------------------------------------------------------------------- -void DialogCurveIntersectAxis::setTypeLine(const QString &value) +void DialogCurveIntersectAxis::SetTypeLine(const QString &value) { - typeLine = value; - SetupTypeLine(ui->comboBoxLineType, value); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); + ChangeCurrentData(ui->comboBoxLineType, value); + line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- -QString DialogCurveIntersectAxis::getAngle() const +QString DialogCurveIntersectAxis::GetAngle() const { return qApp->FormulaFromUser(formulaAngle); } //--------------------------------------------------------------------------------------------------------------------- -void DialogCurveIntersectAxis::setAngle(const QString &value) +void DialogCurveIntersectAxis::SetAngle(const QString &value) { formulaAngle = qApp->FormulaToUser(value); // increase height if needed. TODO : see if I can get the max number of caracters in one line @@ -123,36 +117,48 @@ void DialogCurveIntersectAxis::setAngle(const QString &value) this->DeployAngleTextEdit(); } ui->plainTextEditFormula->setPlainText(formulaAngle); - line->setAngle(formulaAngle); + line->SetAngle(formulaAngle); MoveCursorToEnd(ui->plainTextEditFormula); } //--------------------------------------------------------------------------------------------------------------------- -quint32 DialogCurveIntersectAxis::getBasePointId() const +quint32 DialogCurveIntersectAxis::GetBasePointId() const { - return basePointId; + return getCurrentObjectId(ui->comboBoxAxisPoint); } //--------------------------------------------------------------------------------------------------------------------- -void DialogCurveIntersectAxis::setBasePointId(const quint32 &value) +void DialogCurveIntersectAxis::SetBasePointId(const quint32 &value) { - setCurrentPointId(ui->comboBoxAxisPoint, basePointId, value); + setCurrentPointId(ui->comboBoxAxisPoint, value); line->setAxisPointId(value); } //--------------------------------------------------------------------------------------------------------------------- quint32 DialogCurveIntersectAxis::getCurveId() const { - return curveId; + return getCurrentObjectId(ui->comboBoxCurve); } //--------------------------------------------------------------------------------------------------------------------- void DialogCurveIntersectAxis::setCurveId(const quint32 &value) { - setCurrentCurveId(ui->comboBoxCurve, curveId, value); + setCurrentCurveId(ui->comboBoxCurve, value); line->setPoint1Id(value); } +//--------------------------------------------------------------------------------------------------------------------- +QString DialogCurveIntersectAxis::GetLineColor() const +{ + return GetComboBoxCurrentData(ui->comboBoxLineColor); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCurveIntersectAxis::SetLineColor(const QString &value) +{ + ChangeCurrentData(ui->comboBoxLineColor, value); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogCurveIntersectAxis::ShowDialog(bool click) { @@ -163,7 +169,7 @@ void DialogCurveIntersectAxis::ShowDialog(bool click) /*We will ignore click if poinet is in point circle*/ VMainGraphicsScene *scene = qApp->getCurrentScene(); SCASSERT(scene != nullptr); - const QSharedPointer point = data->GeometricObject(basePointId); + const QSharedPointer point = data->GeometricObject(GetBasePointId()); QLineF line = QLineF(point->toQPointF(), scene->getScenePos()); //Radius of point circle, but little bigger. Need handle with hover sizes. @@ -174,7 +180,7 @@ void DialogCurveIntersectAxis::ShowDialog(bool click) } } this->setModal(true); - this->setAngle(line->Angle());//Show in dialog angle what user choose + this->SetAngle(line->Angle());//Show in dialog angle what user choose emit ToolTip(""); timerFormula->start(); this->show(); @@ -204,7 +210,6 @@ void DialogCurveIntersectAxis::ChosenObject(quint32 id, const SceneObject &type) { if (SetObject(id, ui->comboBoxAxisPoint, "")) { - basePointId = id; line->setAxisPointId(id); line->RefreshGeometry(); prepare = true; @@ -258,18 +263,14 @@ void DialogCurveIntersectAxis::ShowVisualization() void DialogCurveIntersectAxis::SaveData() { pointName = ui->lineEditNamePoint->text(); - typeLine = GetTypeLine(ui->comboBoxLineType); formulaAngle = ui->plainTextEditFormula->toPlainText(); formulaAngle.replace("\n", " "); - basePointId = getCurrentObjectId(ui->comboBoxAxisPoint); - curveId = getCurrentObjectId(ui->comboBoxCurve); - - line->setPoint1Id(curveId); - line->setAxisPointId(basePointId); - line->setAngle(formulaAngle); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); + line->setPoint1Id(getCurveId()); + line->setAxisPointId(GetBasePointId()); + line->SetAngle(formulaAngle); + line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine())); line->RefreshGeometry(); } diff --git a/src/app/dialogs/tools/dialogcurveintersectaxis.h b/src/app/dialogs/tools/dialogcurveintersectaxis.h index 9ab667062..33d5262eb 100644 --- a/src/app/dialogs/tools/dialogcurveintersectaxis.h +++ b/src/app/dialogs/tools/dialogcurveintersectaxis.h @@ -45,21 +45,23 @@ public: DialogCurveIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); ~DialogCurveIntersectAxis(); - QString getPointName() const; - void setPointName(const QString &value); + void SetPointName(const QString &value); - QString getTypeLine() const; - void setTypeLine(const QString &value); + QString GetTypeLine() const; + void SetTypeLine(const QString &value); - QString getAngle() const; - void setAngle(const QString &value); + QString GetAngle() const; + void SetAngle(const QString &value); - quint32 getBasePointId() const; - void setBasePointId(const quint32 &value); + quint32 GetBasePointId() const; + void SetBasePointId(const quint32 &value); quint32 getCurveId() const; void setCurveId(const quint32 &value); + QString GetLineColor() const; + void SetLineColor(const QString &value); + virtual void ShowDialog(bool click); public slots: virtual void ChosenObject(quint32 id, const SceneObject &type); @@ -78,15 +80,7 @@ private: Q_DISABLE_COPY(DialogCurveIntersectAxis) Ui::DialogCurveIntersectAxis *ui; - /** @brief number number of handled objects */ - qint32 number; - - /** @brief typeLine type of line */ - QString typeLine; - QString formulaAngle; - quint32 basePointId; - quint32 curveId; int formulaBaseHeightAngle; VisToolCurveIntersectAxis *line; diff --git a/src/app/dialogs/tools/dialogcurveintersectaxis.ui b/src/app/dialogs/tools/dialogcurveintersectaxis.ui index e48091695..c947ba329 100644 --- a/src/app/dialogs/tools/dialogcurveintersectaxis.ui +++ b/src/app/dialogs/tools/dialogcurveintersectaxis.ui @@ -7,7 +7,7 @@ 0 0 419 - 499 + 532 @@ -308,6 +308,16 @@ + + + + Line color + + + + + + diff --git a/src/app/dialogs/tools/dialogcutarc.cpp b/src/app/dialogs/tools/dialogcutarc.cpp index 247e02dd2..6650a4751 100644 --- a/src/app/dialogs/tools/dialogcutarc.cpp +++ b/src/app/dialogs/tools/dialogcutarc.cpp @@ -42,8 +42,8 @@ * @param parent parent widget */ DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidget *parent) - : DialogTool(data, toolId, parent), ui(new Ui::DialogCutArc), formula(QString()), - arcId(NULL_ID), formulaBaseHeight(0), path(nullptr) + : DialogTool(data, toolId, parent), ui(new Ui::DialogCutArc), formula(QString()), formulaBaseHeight(0), + path(nullptr) { ui->setupUi(this); InitVariables(ui); @@ -58,6 +58,7 @@ DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidge CheckState(); FillComboBoxArcs(ui->comboBoxArc); + FillComboBoxLineColors(ui->comboBoxColor); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutArc::PutHere); connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutArc::PutVal); @@ -133,9 +134,8 @@ void DialogCutArc::SaveData() pointName = ui->lineEditNamePoint->text(); formula = ui->plainTextEditFormula->toPlainText(); formula.replace("\n", " "); - arcId = getCurrentObjectId(ui->comboBoxArc); - path->setPoint1Id(arcId); + path->setPoint1Id(getArcId()); path->setLength(formula); path->RefreshGeometry(); } @@ -154,16 +154,28 @@ void DialogCutArc::closeEvent(QCloseEvent *event) */ void DialogCutArc::setArcId(const quint32 &value) { - setCurrentArcId(ui->comboBoxArc, arcId, value, ComboBoxCutArc::CutArc); - path->setPoint1Id(arcId); + setCurrentArcId(ui->comboBoxArc, value, ComboBoxCutArc::CutArc); + path->setPoint1Id(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogCutArc::GetColor() const +{ + return GetComboBoxCurrentData(ui->comboBoxColor); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutArc::SetColor(const QString &value) +{ + ChangeCurrentData(ui->comboBoxColor, value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setFormula set string with formula length + * @brief SetFormula set string with formula length * @param value string with formula */ -void DialogCutArc::setFormula(const QString &value) +void DialogCutArc::SetFormula(const QString &value) { formula = qApp->FormulaToUser(value); // increase height if needed. @@ -178,10 +190,10 @@ void DialogCutArc::setFormula(const QString &value) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setPointName set name point on arc + * @brief SetPointName set name point on arc * @param value name */ -void DialogCutArc::setPointName(const QString &value) +void DialogCutArc::SetPointName(const QString &value) { pointName = value; ui->lineEditNamePoint->setText(pointName); @@ -189,10 +201,20 @@ void DialogCutArc::setPointName(const QString &value) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief getFormula return string with formula length + * @brief GetFormula return string with formula length * @return formula */ -QString DialogCutArc::getFormula() const +QString DialogCutArc::GetFormula() const { return qApp->FormulaFromUser(formula); } + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getArcId return id of arc + * @return id + */ +quint32 DialogCutArc::getArcId() const +{ + return getCurrentObjectId(ui->comboBoxArc); +} diff --git a/src/app/dialogs/tools/dialogcutarc.h b/src/app/dialogs/tools/dialogcutarc.h index d2cf2f288..f9ba4aa07 100644 --- a/src/app/dialogs/tools/dialogcutarc.h +++ b/src/app/dialogs/tools/dialogcutarc.h @@ -49,14 +49,16 @@ public: DialogCutArc(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); ~DialogCutArc(); - QString getPointName() const; - void setPointName(const QString &value); + void SetPointName(const QString &value); - QString getFormula() const; - void setFormula(const QString &value); + QString GetFormula() const; + void SetFormula(const QString &value); quint32 getArcId() const; void setArcId(const quint32 &value); + + QString GetColor() const; + void SetColor(const QString &value); public slots: virtual void ChosenObject(quint32 id, const SceneObject &type); /** @@ -82,33 +84,10 @@ private: /** @brief formula string with formula */ QString formula; - /** @brief arcId keep id of arc */ - quint32 arcId; - /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; VisToolCutArc *path; }; -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getPointName return name point on arc - * @return name - */ -inline QString DialogCutArc::getPointName() const -{ - return pointName; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getArcId return id of arc - * @return id - */ -inline quint32 DialogCutArc::getArcId() const -{ - return arcId; -} - #endif // DIALOGCUTARC_H diff --git a/src/app/dialogs/tools/dialogcutarc.ui b/src/app/dialogs/tools/dialogcutarc.ui index feb4d2d1e..3ee9722f0 100644 --- a/src/app/dialogs/tools/dialogcutarc.ui +++ b/src/app/dialogs/tools/dialogcutarc.ui @@ -7,7 +7,7 @@ 0 0 412 - 433 + 466 @@ -250,6 +250,16 @@ + + + + Color + + + + + + diff --git a/src/app/dialogs/tools/dialogcutspline.cpp b/src/app/dialogs/tools/dialogcutspline.cpp index 7ed289dcc..13a55e935 100644 --- a/src/app/dialogs/tools/dialogcutspline.cpp +++ b/src/app/dialogs/tools/dialogcutspline.cpp @@ -41,8 +41,8 @@ * @param parent parent widget */ DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogCutSpline), formula(QString()), - splineId(NULL_ID), formulaBaseHeight(0), path(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogCutSpline), formula(QString()), formulaBaseHeight(0), + path(nullptr) { ui->setupUi(this); InitVariables(ui); @@ -57,6 +57,7 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId, CheckState(); FillComboBoxSplines(ui->comboBoxSpline); + FillComboBoxLineColors(ui->comboBoxColor); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutSpline::PutHere); connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutSpline::PutVal); @@ -80,10 +81,10 @@ DialogCutSpline::~DialogCutSpline() //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setPointName set name of point + * @brief SetPointName set name of point * @param value name */ -void DialogCutSpline::setPointName(const QString &value) +void DialogCutSpline::SetPointName(const QString &value) { pointName = value; ui->lineEditNamePoint->setText(pointName); @@ -91,10 +92,10 @@ void DialogCutSpline::setPointName(const QString &value) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setFormula set string of formula + * @brief SetFormula set string of formula * @param value formula */ -void DialogCutSpline::setFormula(const QString &value) +void DialogCutSpline::SetFormula(const QString &value) { formula = qApp->FormulaToUser(value); // increase height if needed. TODO : see if I can get the max number of caracters in one line @@ -115,8 +116,20 @@ void DialogCutSpline::setFormula(const QString &value) */ void DialogCutSpline::setSplineId(const quint32 &value) { - setCurrentSplineId(ui->comboBoxSpline, splineId, value, ComboBoxCutSpline::CutSpline); - path->setPoint1Id(splineId); + setCurrentSplineId(ui->comboBoxSpline, value, ComboBoxCutSpline::CutSpline); + path->setPoint1Id(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogCutSpline::GetColor() const +{ + return GetComboBoxCurrentData(ui->comboBoxColor); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutSpline::SetColor(const QString &value) +{ + ChangeCurrentData(ui->comboBoxColor, value); } //--------------------------------------------------------------------------------------------------------------------- @@ -148,9 +161,8 @@ void DialogCutSpline::SaveData() pointName = ui->lineEditNamePoint->text(); formula = ui->plainTextEditFormula->toPlainText(); formula.replace("\n", " "); - splineId = getCurrentObjectId(ui->comboBoxSpline); - path->setPoint1Id(splineId); + path->setPoint1Id(getSplineId()); path->setLength(formula); path->RefreshGeometry(); } @@ -179,3 +191,23 @@ void DialogCutSpline::ShowVisualization() path->RefreshGeometry(); } } + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetFormula return string of formula + * @return formula + */ +QString DialogCutSpline::GetFormula() const +{ + return qApp->FormulaFromUser(formula); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getSplineId return id base point of line + * @return id + */ +quint32 DialogCutSpline::getSplineId() const +{ + return getCurrentObjectId(ui->comboBoxSpline); +} diff --git a/src/app/dialogs/tools/dialogcutspline.h b/src/app/dialogs/tools/dialogcutspline.h index 163d703c0..12665a998 100644 --- a/src/app/dialogs/tools/dialogcutspline.h +++ b/src/app/dialogs/tools/dialogcutspline.h @@ -48,14 +48,16 @@ public: DialogCutSpline(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); ~DialogCutSpline(); - QString getPointName() const; - void setPointName(const QString &value); + void SetPointName(const QString &value); - QString getFormula() const; - void setFormula(const QString &value); + QString GetFormula() const; + void SetFormula(const QString &value); quint32 getSplineId() const; void setSplineId(const quint32 &value); + + QString GetColor() const; + void SetColor(const QString &value); public slots: virtual void ChosenObject(quint32 id, const SceneObject &type); /** @@ -78,43 +80,10 @@ private: /** @brief formula string with formula */ QString formula; - /** @brief splineId keep id of spline */ - quint32 splineId; - /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; VisToolCutSpline *path; }; -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getPointName return name of point - * @return name - */ -inline QString DialogCutSpline::getPointName() const -{ - return pointName; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getFormula return string of formula - * @return formula - */ -inline QString DialogCutSpline::getFormula() const -{ - return qApp->FormulaFromUser(formula); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getSplineId return id base point of line - * @return id - */ -inline quint32 DialogCutSpline::getSplineId() const -{ - return splineId; -} - #endif // DIALOGCUTSPLINE_H diff --git a/src/app/dialogs/tools/dialogcutspline.ui b/src/app/dialogs/tools/dialogcutspline.ui index 3107db846..c7df135dc 100644 --- a/src/app/dialogs/tools/dialogcutspline.ui +++ b/src/app/dialogs/tools/dialogcutspline.ui @@ -7,7 +7,7 @@ 0 0 412 - 433 + 466 @@ -217,7 +217,7 @@ - + 0 0 @@ -237,7 +237,7 @@ - + 0 0 @@ -250,6 +250,16 @@ + + + + Color + + + + + + diff --git a/src/app/dialogs/tools/dialogcutsplinepath.cpp b/src/app/dialogs/tools/dialogcutsplinepath.cpp index 6367feae9..507d53a3e 100644 --- a/src/app/dialogs/tools/dialogcutsplinepath.cpp +++ b/src/app/dialogs/tools/dialogcutsplinepath.cpp @@ -41,8 +41,8 @@ * @param parent parent widget */ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogCutSplinePath), formula(QString()), - splinePathId(NULL_ID), formulaBaseHeight(0), path(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogCutSplinePath), formula(QString()), formulaBaseHeight(0), + path(nullptr) { ui->setupUi(this); InitVariables(ui); @@ -57,6 +57,7 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 & CheckState(); FillComboBoxSplinesPath(ui->comboBoxSplinePath); + FillComboBoxLineColors(ui->comboBoxColor); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutSplinePath::PutHere); connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutSplinePath::PutVal); @@ -80,10 +81,10 @@ DialogCutSplinePath::~DialogCutSplinePath() //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setPointName set name of point + * @brief SetPointName set name of point * @param value name */ -void DialogCutSplinePath::setPointName(const QString &value) +void DialogCutSplinePath::SetPointName(const QString &value) { pointName = value; ui->lineEditNamePoint->setText(pointName); @@ -91,10 +92,10 @@ void DialogCutSplinePath::setPointName(const QString &value) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setFormula set string of formula + * @brief SetFormula set string of formula * @param value formula */ -void DialogCutSplinePath::setFormula(const QString &value) +void DialogCutSplinePath::SetFormula(const QString &value) { formula = qApp->FormulaToUser(value); // increase height if needed. TODO : see if I can get the max number of caracters in one line @@ -115,8 +116,20 @@ void DialogCutSplinePath::setFormula(const QString &value) */ void DialogCutSplinePath::setSplinePathId(const quint32 &value) { - setCurrentSplinePathId(ui->comboBoxSplinePath, splinePathId, value, ComboBoxCutSpline::CutSpline); - path->setPoint1Id(splinePathId); + setCurrentSplinePathId(ui->comboBoxSplinePath, value, ComboBoxCutSpline::CutSpline); + path->setPoint1Id(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogCutSplinePath::GetColor() const +{ + return GetComboBoxCurrentData(ui->comboBoxColor); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogCutSplinePath::SetColor(const QString &value) +{ + ChangeCurrentData(ui->comboBoxColor, value); } //--------------------------------------------------------------------------------------------------------------------- @@ -148,9 +161,8 @@ void DialogCutSplinePath::SaveData() pointName = ui->lineEditNamePoint->text(); formula = ui->plainTextEditFormula->toPlainText(); formula.replace("\n", " "); - splinePathId = getCurrentObjectId(ui->comboBoxSplinePath); - path->setPoint1Id(splinePathId); + path->setPoint1Id(getSplinePathId()); path->setLength(formula); path->RefreshGeometry(); } @@ -179,3 +191,23 @@ void DialogCutSplinePath::ShowVisualization() path->RefreshGeometry(); } } + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetFormula return string of formula + * @return formula + */ +QString DialogCutSplinePath::GetFormula() const +{ + return qApp->FormulaFromUser(formula); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getSplineId return id base point of line + * @return id + */ +quint32 DialogCutSplinePath::getSplinePathId() const +{ + return getCurrentObjectId(ui->comboBoxSplinePath); +} diff --git a/src/app/dialogs/tools/dialogcutsplinepath.h b/src/app/dialogs/tools/dialogcutsplinepath.h index 063cd316b..340c91fbb 100644 --- a/src/app/dialogs/tools/dialogcutsplinepath.h +++ b/src/app/dialogs/tools/dialogcutsplinepath.h @@ -48,14 +48,16 @@ public: DialogCutSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); ~DialogCutSplinePath(); - QString getPointName() const; - void setPointName(const QString &value); + void SetPointName(const QString &value); - QString getFormula() const; - void setFormula(const QString &value); + QString GetFormula() const; + void SetFormula(const QString &value); quint32 getSplinePathId() const; void setSplinePathId(const quint32 &value); + + QString GetColor() const; + void SetColor(const QString &value); public slots: virtual void ChosenObject(quint32 id, const SceneObject &type); /** @@ -78,43 +80,10 @@ private: /** @brief formula string with formula */ QString formula; - /** @brief splinePathId keep id of splinePath */ - quint32 splinePathId; - /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; VisToolCutSplinePath *path; }; -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getPointName return name of point - * @return name - */ -inline QString DialogCutSplinePath::getPointName() const -{ - return pointName; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getFormula return string of formula - * @return formula - */ -inline QString DialogCutSplinePath::getFormula() const -{ - return qApp->FormulaFromUser(formula); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getSplineId return id base point of line - * @return id - */ -inline quint32 DialogCutSplinePath::getSplinePathId() const -{ - return splinePathId; -} - #endif // DIALOGCUTSPLINEPATH_H diff --git a/src/app/dialogs/tools/dialogcutsplinepath.ui b/src/app/dialogs/tools/dialogcutsplinepath.ui index f5d497074..2312d2eed 100644 --- a/src/app/dialogs/tools/dialogcutsplinepath.ui +++ b/src/app/dialogs/tools/dialogcutsplinepath.ui @@ -7,7 +7,7 @@ 0 0 412 - 433 + 466 @@ -217,7 +217,7 @@ - + 0 0 @@ -237,7 +237,7 @@ - + 0 0 @@ -250,6 +250,22 @@ + + + + + 0 + 0 + + + + Color + + + + + + diff --git a/src/app/dialogs/tools/dialogeditwrongformula.cpp b/src/app/dialogs/tools/dialogeditwrongformula.cpp index 3987b12a7..804a78ff6 100644 --- a/src/app/dialogs/tools/dialogeditwrongformula.cpp +++ b/src/app/dialogs/tools/dialogeditwrongformula.cpp @@ -121,7 +121,7 @@ void DialogEditWrongFormula::closeEvent(QCloseEvent *event) } //--------------------------------------------------------------------------------------------------------------------- -void DialogEditWrongFormula::setFormula(const QString &value) +void DialogEditWrongFormula::SetFormula(const QString &value) { formula = qApp->FormulaToUser(value); // increase height if needed. TODO : see if I can get the max number of caracters in one line @@ -147,7 +147,7 @@ void DialogEditWrongFormula::setPostfix(const QString &value) } //--------------------------------------------------------------------------------------------------------------------- -QString DialogEditWrongFormula::getFormula() const +QString DialogEditWrongFormula::GetFormula() const { return qApp->FormulaFromUser(formula); } diff --git a/src/app/dialogs/tools/dialogeditwrongformula.h b/src/app/dialogs/tools/dialogeditwrongformula.h index a2d389baf..e163d7c21 100644 --- a/src/app/dialogs/tools/dialogeditwrongformula.h +++ b/src/app/dialogs/tools/dialogeditwrongformula.h @@ -51,8 +51,8 @@ public: explicit DialogEditWrongFormula(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); ~DialogEditWrongFormula(); - QString getFormula() const; - void setFormula(const QString &value); + QString GetFormula() const; + void SetFormula(const QString &value); void setCheckZero(bool value); void setPostfix(const QString &value); public slots: diff --git a/src/app/dialogs/tools/dialogendline.cpp b/src/app/dialogs/tools/dialogendline.cpp index e450a5659..3ecb0651d 100644 --- a/src/app/dialogs/tools/dialogendline.cpp +++ b/src/app/dialogs/tools/dialogendline.cpp @@ -43,9 +43,8 @@ * @param parent parent widget */ DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogEndLine), typeLine(QString()), - formulaLength(QString()), formulaAngle(QString()), basePointId(NULL_ID), formulaBaseHeight(0), - formulaBaseHeightAngle(0), line(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogEndLine), + formulaLength(QString()), formulaAngle(QString()), formulaBaseHeight(0), formulaBaseHeightAngle(0), line(nullptr) { ui->setupUi(this); InitVariables(ui); @@ -64,6 +63,7 @@ DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWid FillComboBoxPoints(ui->comboBoxBasePoint); FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics()); + FillComboBoxLineColors(ui->comboBoxLineColor); connect(ui->toolButtonPutHereLength, &QPushButton::clicked, this, &DialogEndLine::PutHere); connect(ui->toolButtonPutHereAngle, &QPushButton::clicked, this, &DialogEndLine::PutAngle); @@ -144,7 +144,6 @@ void DialogEndLine::ChosenObject(quint32 id, const SceneObject &type) { if (SetObject(id, ui->comboBoxBasePoint, "")) { - basePointId = id; line->VisualMode(id); connect(line, &VisToolEndLine::ToolTip, this, &DialogTool::ShowVisToolTip); prepare = true; @@ -155,10 +154,10 @@ void DialogEndLine::ChosenObject(quint32 id, const SceneObject &type) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setPointName set name of point + * @brief SetPointName set name of point * @param value name */ -void DialogEndLine::setPointName(const QString &value) +void DialogEndLine::SetPointName(const QString &value) { pointName = value; ui->lineEditNamePoint->setText(pointName); @@ -166,22 +165,21 @@ void DialogEndLine::setPointName(const QString &value) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setTypeLine set type of line + * @brief SetTypeLine set type of line * @param value type */ -void DialogEndLine::setTypeLine(const QString &value) +void DialogEndLine::SetTypeLine(const QString &value) { - typeLine = value; - SetupTypeLine(ui->comboBoxLineType, value); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); + ChangeCurrentData(ui->comboBoxLineType, value); + line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setFormula set string of formula + * @brief SetFormula set string of formula * @param value formula */ -void DialogEndLine::setFormula(const QString &value) +void DialogEndLine::SetFormula(const QString &value) { formulaLength = qApp->FormulaToUser(value); // increase height if needed. TODO : see if I can get the max number of caracters in one line @@ -197,10 +195,10 @@ void DialogEndLine::setFormula(const QString &value) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setAngle set angle of line + * @brief SetAngle set angle of line * @param value angle in degree */ -void DialogEndLine::setAngle(const QString &value) +void DialogEndLine::SetAngle(const QString &value) { formulaAngle = qApp->FormulaToUser(value); // increase height if needed. TODO : see if I can get the max number of caracters in one line @@ -210,21 +208,33 @@ void DialogEndLine::setAngle(const QString &value) this->DeployAngleTextEdit(); } ui->plainTextEditAngle->setPlainText(formulaAngle); - line->setAngle(formulaAngle); + line->SetAngle(formulaAngle); MoveCursorToEnd(ui->plainTextEditAngle); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setBasePointId set id base point of line + * @brief SetBasePointId set id base point of line * @param value id */ -void DialogEndLine::setBasePointId(const quint32 &value) +void DialogEndLine::SetBasePointId(const quint32 &value) { - setCurrentPointId(ui->comboBoxBasePoint, basePointId, value); + setCurrentPointId(ui->comboBoxBasePoint, value); line->setPoint1Id(value); } +//--------------------------------------------------------------------------------------------------------------------- +QString DialogEndLine::GetLineColor() const +{ + return GetComboBoxCurrentData(ui->comboBoxLineColor); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogEndLine::SetLineColor(const QString &value) +{ + ChangeCurrentData(ui->comboBoxLineColor, value); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief DialogEndLine::ShowDialog show dialog after finish working with visual part @@ -239,7 +249,7 @@ void DialogEndLine::ShowDialog(bool click) /*We will ignore click if poinet is in point circle*/ VMainGraphicsScene *scene = qApp->getCurrentScene(); SCASSERT(scene != nullptr); - const QSharedPointer point = data->GeometricObject(basePointId); + const QSharedPointer point = data->GeometricObject(GetBasePointId()); QLineF line = QLineF(point->toQPointF(), scene->getScenePos()); //Radius of point circle, but little bigger. Need handle with hover sizes. @@ -250,7 +260,7 @@ void DialogEndLine::ShowDialog(bool click) } } this->setModal(true); - this->setAngle(line->Angle());//Show in dialog angle what user choose + this->SetAngle(line->Angle());//Show in dialog angle what user choose emit ToolTip(""); timerFormula->start(); this->show(); @@ -274,7 +284,6 @@ void DialogEndLine::ShowVisualization() void DialogEndLine::SaveData() { pointName = ui->lineEditNamePoint->text(); - typeLine = GetTypeLine(ui->comboBoxLineType); formulaLength = ui->plainTextEditFormula->toPlainText(); formulaLength.replace("\n", " "); @@ -282,12 +291,10 @@ void DialogEndLine::SaveData() formulaAngle = ui->plainTextEditAngle->toPlainText(); formulaAngle.replace("\n", " "); - basePointId = getCurrentObjectId(ui->comboBoxBasePoint); - - line->setPoint1Id(basePointId); + line->setPoint1Id(GetBasePointId()); line->setLength(formulaLength); - line->setAngle(formulaAngle); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); + line->SetAngle(formulaAngle); + line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine())); line->RefreshGeometry(); } @@ -308,3 +315,43 @@ DialogEndLine::~DialogEndLine() } delete ui; } + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetTypeLine return type of line + * @return type + */ +QString DialogEndLine::GetTypeLine() const +{ + return GetComboBoxCurrentData(ui->comboBoxLineType); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetFormula return string of formula + * @return formula + */ +QString DialogEndLine::GetFormula() const +{ + return qApp->FormulaFromUser(formulaLength); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetAngle return formula angle of line + * @return angle formula + */ +QString DialogEndLine::GetAngle() const +{ + return qApp->FormulaFromUser(formulaAngle); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetBasePointId return id base point of line + * @return id + */ +quint32 DialogEndLine::GetBasePointId() const +{ + return getCurrentObjectId(ui->comboBoxBasePoint); +} diff --git a/src/app/dialogs/tools/dialogendline.h b/src/app/dialogs/tools/dialogendline.h index 0747f4b65..d31101a12 100644 --- a/src/app/dialogs/tools/dialogendline.h +++ b/src/app/dialogs/tools/dialogendline.h @@ -48,20 +48,23 @@ public: DialogEndLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); ~DialogEndLine(); - QString getPointName() const; - void setPointName(const QString &value); + void SetPointName(const QString &value); - QString getTypeLine() const; - void setTypeLine(const QString &value); + QString GetTypeLine() const; + void SetTypeLine(const QString &value); - QString getFormula() const; - void setFormula(const QString &value); + QString GetFormula() const; + void SetFormula(const QString &value); - QString getAngle() const; - void setAngle(const QString &value); + QString GetAngle() const; + void SetAngle(const QString &value); + + quint32 GetBasePointId() const; + void SetBasePointId(const quint32 &value); + + QString GetLineColor() const; + void SetLineColor(const QString &value); - quint32 getBasePointId() const; - void setBasePointId(const quint32 &value); virtual void ShowDialog(bool click); public slots: virtual void ChosenObject(quint32 id, const SceneObject &type); @@ -90,75 +93,17 @@ private: /** @brief ui keeps information about user interface */ Ui::DialogEndLine *ui; - /** @brief typeLine type of line */ - QString typeLine; - /** @brief formula formula */ QString formulaLength; /** @brief angle angle of line */ QString formulaAngle; - /** @brief basePointId id base point of line */ - quint32 basePointId; - /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; int formulaBaseHeightAngle; VisToolEndLine *line; - - }; -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getPointName return name of point - * @return name - */ -inline QString DialogEndLine::getPointName() const -{ - return pointName; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getTypeLine return type of line - * @return type - */ -inline QString DialogEndLine::getTypeLine() const -{ - return typeLine; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getFormula return string of formula - * @return formula - */ -inline QString DialogEndLine::getFormula() const -{ - return qApp->FormulaFromUser(formulaLength); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getAngle return formula angle of line - * @return angle formula - */ -inline QString DialogEndLine::getAngle() const -{ - return qApp->FormulaFromUser(formulaAngle); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getBasePointId return id base point of line - * @return id - */ -inline quint32 DialogEndLine::getBasePointId() const -{ - return basePointId; -} - #endif // DIALOGENDLINE_H diff --git a/src/app/dialogs/tools/dialogendline.ui b/src/app/dialogs/tools/dialogendline.ui index a5e8259f5..93dbd3f8f 100644 --- a/src/app/dialogs/tools/dialogendline.ui +++ b/src/app/dialogs/tools/dialogendline.ui @@ -409,6 +409,9 @@ + + QFormLayout::AllNonFixedFieldsGrow + @@ -477,6 +480,16 @@ + + + + Line color + + + + + + diff --git a/src/app/dialogs/tools/dialogheight.cpp b/src/app/dialogs/tools/dialogheight.cpp index b4f80756a..59ada77f2 100644 --- a/src/app/dialogs/tools/dialogheight.cpp +++ b/src/app/dialogs/tools/dialogheight.cpp @@ -42,8 +42,7 @@ * @param parent parent widget */ DialogHeight::DialogHeight(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogHeight), number(0), - typeLine(QString()), basePointId(NULL_ID), p1LineId(NULL_ID), p2LineId(NULL_ID), line(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogHeight), line(nullptr) { ui->setupUi(this); ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); @@ -55,6 +54,8 @@ DialogHeight::DialogHeight(const VContainer *data, const quint32 &toolId, QWidge FillComboBoxPoints(ui->comboBoxP1Line); FillComboBoxPoints(ui->comboBoxP2Line); FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics()); + FillComboBoxLineColors(ui->comboBoxLineColor); + connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogHeight::NamePointChanged); connect(ui->comboBoxBasePoint, static_cast(&QComboBox::currentIndexChanged), this, &DialogHeight::PointNameChanged); @@ -78,10 +79,10 @@ DialogHeight::~DialogHeight() //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setPointName set name of point + * @brief SetPointName set name of point * @param value name */ -void DialogHeight::setPointName(const QString &value) +void DialogHeight::SetPointName(const QString &value) { pointName = value; ui->lineEditNamePoint->setText(pointName); @@ -89,47 +90,58 @@ void DialogHeight::setPointName(const QString &value) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setTypeLine set type of line + * @brief SetTypeLine set type of line * @param value type */ -void DialogHeight::setTypeLine(const QString &value) +void DialogHeight::SetTypeLine(const QString &value) { - typeLine = value; - SetupTypeLine(ui->comboBoxLineType, value); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); + ChangeCurrentData(ui->comboBoxLineType, value); + line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setBasePointId set id base point of height + * @brief SetBasePointId set id base point of height * @param value id */ -void DialogHeight::setBasePointId(const quint32 &value) +void DialogHeight::SetBasePointId(const quint32 &value) { - setPointId(ui->comboBoxBasePoint, basePointId, value); - line->setPoint1Id(basePointId); + setCurrentPointId(ui->comboBoxBasePoint, value); + line->setPoint1Id(value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setP1LineId set id first point of line + * @brief SetP1LineId set id first point of line * @param value id */ -void DialogHeight::setP1LineId(const quint32 &value) +void DialogHeight::SetP1LineId(const quint32 &value) { - setPointId(ui->comboBoxP1Line, p1LineId, value); - line->setLineP1Id(p1LineId); + setCurrentPointId(ui->comboBoxP1Line, value); + line->setLineP1Id(value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setP2LineId set id second point of line + * @brief SetP2LineId set id second point of line * @param value id */ -void DialogHeight::setP2LineId(const quint32 &value) +void DialogHeight::SetP2LineId(const quint32 &value) { - setPointId(ui->comboBoxP2Line, p2LineId, value); - line->setLineP2Id(p2LineId); + setCurrentPointId(ui->comboBoxP2Line, value); + line->setLineP2Id(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogHeight::GetLineColor() const +{ + return GetComboBoxCurrentData(ui->comboBoxLineColor); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogHeight::SetLineColor(const QString &value) +{ + ChangeCurrentData(ui->comboBoxLineColor, value); } //--------------------------------------------------------------------------------------------------------------------- @@ -195,15 +207,11 @@ void DialogHeight::ChosenObject(quint32 id, const SceneObject &type) void DialogHeight::SaveData() { pointName = ui->lineEditNamePoint->text(); - typeLine = GetTypeLine(ui->comboBoxLineType); - basePointId = getCurrentObjectId(ui->comboBoxBasePoint); - p1LineId = getCurrentObjectId(ui->comboBoxP1Line); - p2LineId = getCurrentObjectId(ui->comboBoxP2Line); - line->setPoint1Id(basePointId); - line->setLineP1Id(p1LineId); - line->setLineP2Id(p2LineId); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); + line->setPoint1Id(GetBasePointId()); + line->setLineP1Id(GetP1LineId()); + line->setLineP2Id(GetP2LineId()); + line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine())); line->RefreshGeometry(); } @@ -261,3 +269,43 @@ void DialogHeight::ShowVisualization() line->RefreshGeometry(); } } + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetTypeLine return type of line + * @return type + */ +QString DialogHeight::GetTypeLine() const +{ + return GetComboBoxCurrentData(ui->comboBoxLineType); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetBasePointId return id base point of height + * @return id + */ +quint32 DialogHeight::GetBasePointId() const +{ + return getCurrentObjectId(ui->comboBoxBasePoint); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetP1LineId return id first point of line + * @return id id + */ +quint32 DialogHeight::GetP1LineId() const +{ + return getCurrentObjectId(ui->comboBoxP1Line); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetP2LineId return id second point of line + * @return id + */ +quint32 DialogHeight::GetP2LineId() const +{ + return getCurrentObjectId(ui->comboBoxP2Line); +} diff --git a/src/app/dialogs/tools/dialogheight.h b/src/app/dialogs/tools/dialogheight.h index 8c384b145..18859f56a 100644 --- a/src/app/dialogs/tools/dialogheight.h +++ b/src/app/dialogs/tools/dialogheight.h @@ -48,20 +48,22 @@ public: DialogHeight(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); ~DialogHeight(); - QString getPointName() const; - void setPointName(const QString &value); + void SetPointName(const QString &value); - QString getTypeLine() const; - void setTypeLine(const QString &value); + QString GetTypeLine() const; + void SetTypeLine(const QString &value); - quint32 getBasePointId() const; - void setBasePointId(const quint32 &value); + quint32 GetBasePointId() const; + void SetBasePointId(const quint32 &value); - quint32 getP1LineId() const; - void setP1LineId(const quint32 &value); + quint32 GetP1LineId() const; + void SetP1LineId(const quint32 &value); - quint32 getP2LineId() const; - void setP2LineId(const quint32 &value); + quint32 GetP2LineId() const; + void SetP2LineId(const quint32 &value); + + QString GetLineColor() const; + void SetLineColor(const QString &value); public slots: virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void PointNameChanged(); @@ -78,71 +80,7 @@ private: /** @brief ui keeps information about user interface */ Ui::DialogHeight *ui; - /** @brief number number of handled objects */ - qint32 number; - - /** @brief typeLine type of line */ - QString typeLine; - - /** @brief basePointId id base point of height */ - quint32 basePointId; - - /** @brief p1LineId id first point of line */ - quint32 p1LineId; - - /** @brief p2LineId id second point of line */ - quint32 p2LineId; VisToolHeight *line; }; -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getPointName return name of point - * @return name - */ -inline QString DialogHeight::getPointName() const -{ - return pointName; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getTypeLine return type of line - * @return type - */ -inline QString DialogHeight::getTypeLine() const -{ - return typeLine; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getBasePointId return id base point of height - * @return id - */ -inline quint32 DialogHeight::getBasePointId() const -{ - return basePointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getP1LineId return id first point of line - * @return id id - */ -inline quint32 DialogHeight::getP1LineId() const -{ - return p1LineId; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getP2LineId return id second point of line - * @return id - */ -inline quint32 DialogHeight::getP2LineId() const -{ - return p2LineId; -} - #endif // DIALOGHEIGHT_H diff --git a/src/app/dialogs/tools/dialogheight.ui b/src/app/dialogs/tools/dialogheight.ui index 39e855ae5..45541665a 100644 --- a/src/app/dialogs/tools/dialogheight.ui +++ b/src/app/dialogs/tools/dialogheight.ui @@ -7,7 +7,7 @@ 0 0 285 - 212 + 245 @@ -134,6 +134,16 @@ + + + + Line color + + + + + + diff --git a/src/app/dialogs/tools/dialogline.cpp b/src/app/dialogs/tools/dialogline.cpp index 1e62d1290..b545f8c9d 100644 --- a/src/app/dialogs/tools/dialogline.cpp +++ b/src/app/dialogs/tools/dialogline.cpp @@ -43,14 +43,14 @@ * @param parent parent widget */ DialogLine::DialogLine(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogLine), number(0), firstPoint(NULL_ID), secondPoint(NULL_ID), - typeLine(QString()), line(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogLine), line(nullptr) { ui->setupUi(this); InitOkCancelApply(ui); FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxSecondPoint); + FillComboBoxLineColors(ui->comboBoxLineColor); QMap stylesPics = VAbstractTool::LineStylesPics(); stylesPics.remove(VAbstractTool::TypeLineNone);// Prevent hiding line @@ -78,35 +78,46 @@ DialogLine::~DialogLine() //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setSecondPoint set id second point + * @brief SetSecondPoint set id second point * @param value id */ -void DialogLine::setSecondPoint(const quint32 &value) +void DialogLine::SetSecondPoint(const quint32 &value) { - setPointId(ui->comboBoxSecondPoint, secondPoint, value); + setCurrentPointId(ui->comboBoxSecondPoint, value); line->setPoint2Id(value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setTypeLine set type of line + * @brief SetTypeLine set type of line * @param value type */ -void DialogLine::setTypeLine(const QString &value) +void DialogLine::SetTypeLine(const QString &value) { - typeLine = value; - SetupTypeLine(ui->comboBoxLineType, value); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); + ChangeCurrentData(ui->comboBoxLineType, value); + line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogLine::GetLineColor() const +{ + return GetComboBoxCurrentData(ui->comboBoxLineColor); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLine::SetLineColor(const QString &value) +{ + ChangeCurrentData(ui->comboBoxLineColor, value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setFirstPoint set id first point + * @brief SetFirstPoint set id first point * @param value id */ -void DialogLine::setFirstPoint(const quint32 &value) +void DialogLine::SetFirstPoint(const quint32 &value) { - setPointId(ui->comboBoxFirstPoint, firstPoint, value); + setCurrentPointId(ui->comboBoxFirstPoint, value); line->setPoint1Id(value); } @@ -153,15 +164,9 @@ void DialogLine::ShowVisualization() //--------------------------------------------------------------------------------------------------------------------- void DialogLine::SaveData() { - qint32 index = ui->comboBoxFirstPoint->currentIndex(); - firstPoint = qvariant_cast(ui->comboBoxFirstPoint->itemData(index)); - index = ui->comboBoxSecondPoint->currentIndex(); - secondPoint = qvariant_cast(ui->comboBoxSecondPoint->itemData(index)); - typeLine = GetTypeLine(ui->comboBoxLineType); - - line->setPoint1Id(firstPoint); - line->setPoint2Id(secondPoint); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); + line->setPoint1Id(GetFirstPoint()); + line->setPoint2Id(GetSecondPoint()); + line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine())); line->RefreshGeometry(); } @@ -203,3 +208,33 @@ void DialogLine::ChosenObject(quint32 id, const SceneObject &type) } } } + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetFirstPoint return id first point + * @return id + */ +quint32 DialogLine::GetFirstPoint() const +{ + return qvariant_cast(ui->comboBoxFirstPoint->currentData()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetSecondPoint return id second point + * @return id + */ +quint32 DialogLine::GetSecondPoint() const +{ + return qvariant_cast(ui->comboBoxSecondPoint->currentData()); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetTypeLine return type of line + * @return type + */ +QString DialogLine::GetTypeLine() const +{ + return GetComboBoxCurrentData(ui->comboBoxLineType); +} diff --git a/src/app/dialogs/tools/dialogline.h b/src/app/dialogs/tools/dialogline.h index c08d061b0..8c7ff5d8f 100644 --- a/src/app/dialogs/tools/dialogline.h +++ b/src/app/dialogs/tools/dialogline.h @@ -48,14 +48,17 @@ public: DialogLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); ~DialogLine(); - quint32 getFirstPoint() const; - void setFirstPoint(const quint32 &value); + quint32 GetFirstPoint() const; + void SetFirstPoint(const quint32 &value); - quint32 getSecondPoint() const; - void setSecondPoint(const quint32 &value); + quint32 GetSecondPoint() const; + void SetSecondPoint(const quint32 &value); - QString getTypeLine() const; - void setTypeLine(const QString &value); + QString GetTypeLine() const; + void SetTypeLine(const QString &value); + + QString GetLineColor() const; + void SetLineColor(const QString &value); public slots: virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void PointNameChanged(); @@ -72,49 +75,8 @@ private: /** @brief ui keeps information about user interface */ Ui::DialogLine *ui; - /** @brief number number of handled objects */ - qint32 number; - - /** @brief firstPoint id first point */ - quint32 firstPoint; - - /** @brief secondPoint id second point */ - quint32 secondPoint; - - /** @brief typeLine type of line */ - QString typeLine; VisToolLine *line; }; -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getFirstPoint return id first point - * @return id - */ -inline quint32 DialogLine::getFirstPoint() const -{ - return firstPoint; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getSecondPoint return id second point - * @return id - */ -inline quint32 DialogLine::getSecondPoint() const -{ - return secondPoint; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getTypeLine return type of line - * @return type - */ -inline QString DialogLine::getTypeLine() const -{ - return typeLine; -} - #endif // DIALOGLINE_H diff --git a/src/app/dialogs/tools/dialogline.ui b/src/app/dialogs/tools/dialogline.ui index 50dc4afe7..e57621c42 100644 --- a/src/app/dialogs/tools/dialogline.ui +++ b/src/app/dialogs/tools/dialogline.ui @@ -10,19 +10,19 @@ 0 0 286 - 151 + 179 286 - 151 + 179 286 - 151 + 179 @@ -143,6 +143,16 @@ + + + + Line color + + + + + + diff --git a/src/app/dialogs/tools/dialoglineintersect.cpp b/src/app/dialogs/tools/dialoglineintersect.cpp index ae45b1589..83e38e663 100644 --- a/src/app/dialogs/tools/dialoglineintersect.cpp +++ b/src/app/dialogs/tools/dialoglineintersect.cpp @@ -42,8 +42,7 @@ * @param parent parent widget */ DialogLineIntersect::DialogLineIntersect(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersect), number(0), - p1Line1(NULL_ID), p2Line1(NULL_ID), p1Line2(NULL_ID), p2Line2(NULL_ID), flagPoint(true), line(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersect), flagPoint(true), line(nullptr) { ui->setupUi(this); number = 0; @@ -97,7 +96,6 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxP1Line1, tr("Select second point of first line"))) { number++; - p1Line1 = id; line->VisualMode(id); } break; @@ -107,7 +105,6 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxP2Line1, tr("Select first point of second line"))) { number++; - p2Line1 = id; line->setLine1P2Id(id); line->RefreshGeometry(); } @@ -117,7 +114,6 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type) if (SetObject(id, ui->comboBoxP1Line2, tr("Select second point of second line"))) { number++; - p1Line2 = id; line->setLine2P1Id(id); line->RefreshGeometry(); } @@ -134,7 +130,6 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type) { if (SetObject(id, ui->comboBoxP2Line2, "")) { - p2Line2 = id; line->setLine2P2Id(id); line->RefreshGeometry(); prepare = true; @@ -144,16 +139,16 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type) this->show(); connect(ui->comboBoxP1Line1, static_cast(&QComboBox::currentIndexChanged), this, - &DialogLineIntersect::P1Line1Changed); + &DialogLineIntersect::PointChanged); connect(ui->comboBoxP2Line1, static_cast(&QComboBox::currentIndexChanged), this, - &DialogLineIntersect::P2Line1Changed); + &DialogLineIntersect::PointChanged); connect(ui->comboBoxP1Line2, static_cast(&QComboBox::currentIndexChanged), this, - &DialogLineIntersect::P1Line2Changed); + &DialogLineIntersect::PointChanged); connect(ui->comboBoxP2Line2, static_cast(&QComboBox::currentIndexChanged), this, - &DialogLineIntersect::P2Line2Changed); + &DialogLineIntersect::PointChanged); } } } @@ -169,15 +164,11 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type) void DialogLineIntersect::SaveData() { pointName = ui->lineEditNamePoint->text(); - p1Line1 = getCurrentObjectId(ui->comboBoxP1Line1); - p2Line1 = getCurrentObjectId(ui->comboBoxP2Line1); - p1Line2 = getCurrentObjectId(ui->comboBoxP1Line2); - p2Line2 = getCurrentObjectId(ui->comboBoxP2Line2); - line->setPoint1Id(p1Line1); - line->setLine1P2Id(p2Line1); - line->setLine2P1Id(p1Line2); - line->setLine2P2Id(p2Line2); + line->setPoint1Id(GetP1Line1()); + line->setLine1P2Id(GetP2Line1()); + line->setLine2P1Id(GetP1Line2()); + line->setLine2P2Id(GetP2Line2()); line->RefreshGeometry(); } @@ -186,55 +177,10 @@ void DialogLineIntersect::SaveData() * @brief P1Line1Changed changed first point of first line * @param index index in list */ -void DialogLineIntersect::P1Line1Changed( int index) +void DialogLineIntersect::PointChanged() { - p1Line1 = qvariant_cast(ui->comboBoxP1Line1->itemData(index)); flagPoint = CheckIntersecion(); CheckState(); - - line->setPoint1Id(p1Line1); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief P2Line1Changed changed second point of first line - * @param index index in list - */ -void DialogLineIntersect::P2Line1Changed(int index) -{ - p2Line1 = qvariant_cast(ui->comboBoxP2Line1->itemData(index)); - flagPoint = CheckIntersecion(); - CheckState(); - - line->setLine1P2Id(p2Line1); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief P1Line2Changed changed first point of second line - * @param index index in list - */ -void DialogLineIntersect::P1Line2Changed(int index) -{ - p1Line2 = qvariant_cast(ui->comboBoxP1Line2->itemData(index)); - flagPoint = CheckIntersecion(); - CheckState(); - - line->setLine2P1Id(p1Line2); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief P2Line2Changed changed second point of second line - * @param index index in list - */ -void DialogLineIntersect::P2Line2Changed(int index) -{ - p2Line2 = qvariant_cast(ui->comboBoxP2Line2->itemData(index)); - flagPoint = CheckIntersecion(); - CheckState(); - - line->setLine2P2Id(p2Line2); } //--------------------------------------------------------------------------------------------------------------------- @@ -317,10 +263,10 @@ void DialogLineIntersect::CheckState() */ bool DialogLineIntersect::CheckIntersecion() { - const QSharedPointer p1L1 = data->GeometricObject(p1Line1); - const QSharedPointer p2L1 = data->GeometricObject(p2Line1); - const QSharedPointer p1L2 = data->GeometricObject(p1Line2); - const QSharedPointer p2L2 = data->GeometricObject(p2Line2); + const QSharedPointer p1L1 = data->GeometricObject(GetP1Line1()); + const QSharedPointer p2L1 = data->GeometricObject(GetP2Line1()); + const QSharedPointer p1L2 = data->GeometricObject(GetP1Line2()); + const QSharedPointer p2L2 = data->GeometricObject(GetP2Line2()); QLineF line1(p1L1->toQPointF(), p2L1->toQPointF()); QLineF line2(p1L2->toQPointF(), p2L2->toQPointF()); @@ -338,55 +284,95 @@ bool DialogLineIntersect::CheckIntersecion() //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setP2Line2 set id second point of second line + * @brief SetP2Line2 set id second point of second line * @param value id */ -void DialogLineIntersect::setP2Line2(const quint32 &value) +void DialogLineIntersect::SetP2Line2(const quint32 &value) { - setPointId(ui->comboBoxP2Line2, p2Line2, value); - line->setLine2P2Id(p2Line2); + setCurrentPointId(ui->comboBoxP2Line2, value); + line->setLine2P2Id(value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setP1Line2 set id first point of second line + * @brief SetP1Line2 set id first point of second line * @param value id */ -void DialogLineIntersect::setP1Line2(const quint32 &value) +void DialogLineIntersect::SetP1Line2(const quint32 &value) { - setPointId(ui->comboBoxP1Line2, p1Line2, value); - line->setLine2P1Id(p1Line2); + setCurrentPointId(ui->comboBoxP1Line2, value); + line->setLine2P1Id(value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setP2Line1 set id second point of first line + * @brief SetP2Line1 set id second point of first line * @param value id */ -void DialogLineIntersect::setP2Line1(const quint32 &value) +void DialogLineIntersect::SetP2Line1(const quint32 &value) { - setPointId(ui->comboBoxP2Line1, p2Line1, value); - line->setLine1P2Id(p2Line1); + setCurrentPointId(ui->comboBoxP2Line1, value); + line->setLine1P2Id(value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setP1Line1 set id first point of first line + * @brief SetP1Line1 set id first point of first line * @param value id */ -void DialogLineIntersect::setP1Line1(const quint32 &value) +void DialogLineIntersect::SetP1Line1(const quint32 &value) { - setPointId(ui->comboBoxP1Line1, p1Line1, value); - line->setPoint1Id(p1Line1); + setCurrentPointId(ui->comboBoxP1Line1, value); + line->setPoint1Id(value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setPointName set name of point + * @brief SetPointName set name of point * @param value name of point */ -void DialogLineIntersect::setPointName(const QString &value) +void DialogLineIntersect::SetPointName(const QString &value) { pointName = value; ui->lineEditNamePoint->setText(pointName); } + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetP1Line1 return id first point of first line + * @return id + */ +quint32 DialogLineIntersect::GetP1Line1() const +{ + return getCurrentObjectId(ui->comboBoxP1Line1); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetP2Line1 return id second point of first line + * @return id + */ +quint32 DialogLineIntersect::GetP2Line1() const +{ + return getCurrentObjectId(ui->comboBoxP2Line1); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetP1Line2 return id first point of second line + * @return id + */ +quint32 DialogLineIntersect::GetP1Line2() const +{ + return getCurrentObjectId(ui->comboBoxP1Line2); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetP2Line2 return id second point of second line + * @return id + */ +quint32 DialogLineIntersect::GetP2Line2() const +{ + return getCurrentObjectId(ui->comboBoxP2Line2); +} diff --git a/src/app/dialogs/tools/dialoglineintersect.h b/src/app/dialogs/tools/dialoglineintersect.h index 93f686f73..5f7a374f1 100644 --- a/src/app/dialogs/tools/dialoglineintersect.h +++ b/src/app/dialogs/tools/dialoglineintersect.h @@ -48,26 +48,22 @@ public: DialogLineIntersect(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); ~DialogLineIntersect(); - quint32 getP1Line1() const; - void setP1Line1(const quint32 &value); + quint32 GetP1Line1() const; + void SetP1Line1(const quint32 &value); - quint32 getP2Line1() const; - void setP2Line1(const quint32 &value); + quint32 GetP2Line1() const; + void SetP2Line1(const quint32 &value); - quint32 getP1Line2() const; - void setP1Line2(const quint32 &value); + quint32 GetP1Line2() const; + void SetP1Line2(const quint32 &value); - quint32 getP2Line2() const; - void setP2Line2(const quint32 &value); + quint32 GetP2Line2() const; + void SetP2Line2(const quint32 &value); - QString getPointName() const; - void setPointName(const QString &value); + void SetPointName(const QString &value); public slots: virtual void ChosenObject(quint32 id, const SceneObject &type); - void P1Line1Changed( int index); - void P2Line1Changed( int index); - void P1Line2Changed( int index); - void P2Line2Changed( int index); + void PointChanged(); virtual void PointNameChanged(); virtual void UpdateList(); protected: @@ -82,21 +78,6 @@ private: /** @brief ui keeps information about user interface */ Ui::DialogLineIntersect *ui; - /** @brief number number of handled objects */ - qint32 number; - - /** @brief p1Line1 id first point of first line */ - quint32 p1Line1; - - /** @brief p2Line1 id second point of first line */ - quint32 p2Line1; - - /** @brief p1Line2 id first point of second line */ - quint32 p1Line2; - - /** @brief p2Line2 id second point of second line */ - quint32 p2Line2; - /** @brief flagPoint keep state of point */ bool flagPoint; @@ -106,54 +87,4 @@ private: bool CheckIntersecion(); }; -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getP1Line1 return id first point of first line - * @return id - */ -inline quint32 DialogLineIntersect::getP1Line1() const -{ - return p1Line1; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getP2Line1 return id second point of first line - * @return id - */ -inline quint32 DialogLineIntersect::getP2Line1() const -{ - return p2Line1; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getP1Line2 return id first point of second line - * @return id - */ -inline quint32 DialogLineIntersect::getP1Line2() const -{ - return p1Line2; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getP2Line2 return id second point of second line - * @return id - */ -inline quint32 DialogLineIntersect::getP2Line2() const -{ - return p2Line2; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getPointName return name of point - * @return name of point - */ -inline QString DialogLineIntersect::getPointName() const -{ - return pointName; -} - #endif // DIALOGLINEINTERSECT_H diff --git a/src/app/dialogs/tools/dialoglineintersectaxis.cpp b/src/app/dialogs/tools/dialoglineintersectaxis.cpp index a7b77c1b1..39e12c91b 100644 --- a/src/app/dialogs/tools/dialoglineintersectaxis.cpp +++ b/src/app/dialogs/tools/dialoglineintersectaxis.cpp @@ -38,8 +38,7 @@ //--------------------------------------------------------------------------------------------------------------------- DialogLineIntersectAxis::DialogLineIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersectAxis), number(0), typeLine(QString()), - formulaAngle(QString()), basePointId(NULL_ID), firstPointId(NULL_ID), secondPointId(NULL_ID), + :DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersectAxis), formulaAngle(QString()), formulaBaseHeightAngle(0), line(nullptr) { ui->setupUi(this); @@ -58,6 +57,7 @@ DialogLineIntersectAxis::DialogLineIntersectAxis(const VContainer *data, const q FillComboBoxPoints(ui->comboBoxFirstLinePoint); FillComboBoxPoints(ui->comboBoxSecondLinePoint); FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics()); + FillComboBoxLineColors(ui->comboBoxLineColor); connect(ui->toolButtonPutHereAngle, &QPushButton::clicked, this, &DialogLineIntersectAxis::PutAngle); connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogLineIntersectAxis::PutVal); @@ -89,40 +89,33 @@ DialogLineIntersectAxis::~DialogLineIntersectAxis() } //--------------------------------------------------------------------------------------------------------------------- -QString DialogLineIntersectAxis::getPointName() const -{ - return pointName; -} - -//--------------------------------------------------------------------------------------------------------------------- -void DialogLineIntersectAxis::setPointName(const QString &value) +void DialogLineIntersectAxis::SetPointName(const QString &value) { pointName = value; ui->lineEditNamePoint->setText(pointName); } //--------------------------------------------------------------------------------------------------------------------- -QString DialogLineIntersectAxis::getTypeLine() const +QString DialogLineIntersectAxis::GetTypeLine() const { - return typeLine; + return GetComboBoxCurrentData(ui->comboBoxLineType); } //--------------------------------------------------------------------------------------------------------------------- -void DialogLineIntersectAxis::setTypeLine(const QString &value) +void DialogLineIntersectAxis::SetTypeLine(const QString &value) { - typeLine = value; - SetupTypeLine(ui->comboBoxLineType, value); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); + ChangeCurrentData(ui->comboBoxLineType, value); + line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- -QString DialogLineIntersectAxis::getAngle() const +QString DialogLineIntersectAxis::GetAngle() const { return qApp->FormulaFromUser(formulaAngle); } //--------------------------------------------------------------------------------------------------------------------- -void DialogLineIntersectAxis::setAngle(const QString &value) +void DialogLineIntersectAxis::SetAngle(const QString &value) { formulaAngle = qApp->FormulaToUser(value); // increase height if needed. TODO : see if I can get the max number of caracters in one line @@ -132,49 +125,61 @@ void DialogLineIntersectAxis::setAngle(const QString &value) this->DeployAngleTextEdit(); } ui->plainTextEditFormula->setPlainText(formulaAngle); - line->setAngle(formulaAngle); + line->SetAngle(formulaAngle); MoveCursorToEnd(ui->plainTextEditFormula); } //--------------------------------------------------------------------------------------------------------------------- -quint32 DialogLineIntersectAxis::getBasePointId() const +quint32 DialogLineIntersectAxis::GetBasePointId() const { - return basePointId; + return getCurrentObjectId(ui->comboBoxAxisPoint); } //--------------------------------------------------------------------------------------------------------------------- -void DialogLineIntersectAxis::setBasePointId(const quint32 &value) +void DialogLineIntersectAxis::SetBasePointId(const quint32 &value) { - setCurrentPointId(ui->comboBoxAxisPoint, basePointId, value); + setCurrentPointId(ui->comboBoxAxisPoint, value); line->setAxisPointId(value); } //--------------------------------------------------------------------------------------------------------------------- -quint32 DialogLineIntersectAxis::getFirstPointId() const +quint32 DialogLineIntersectAxis::GetFirstPointId() const { - return firstPointId; + return getCurrentObjectId(ui->comboBoxFirstLinePoint); } //--------------------------------------------------------------------------------------------------------------------- -void DialogLineIntersectAxis::setFirstPointId(const quint32 &value) +void DialogLineIntersectAxis::SetFirstPointId(const quint32 &value) { - setCurrentPointId(ui->comboBoxFirstLinePoint, firstPointId, value); + setCurrentPointId(ui->comboBoxFirstLinePoint, value); line->setPoint1Id(value); } //--------------------------------------------------------------------------------------------------------------------- -quint32 DialogLineIntersectAxis::getSecondPointId() const +quint32 DialogLineIntersectAxis::GetSecondPointId() const { - return secondPointId; + return getCurrentObjectId(ui->comboBoxSecondLinePoint); } //--------------------------------------------------------------------------------------------------------------------- -void DialogLineIntersectAxis::setSecondPointId(const quint32 &value) +void DialogLineIntersectAxis::SetSecondPointId(const quint32 &value) { - setCurrentPointId(ui->comboBoxSecondLinePoint, secondPointId, value); + setCurrentPointId(ui->comboBoxSecondLinePoint, value); line->setPoint2Id(value); } +//--------------------------------------------------------------------------------------------------------------------- +QString DialogLineIntersectAxis::GetLineColor() const +{ + return GetComboBoxCurrentData(ui->comboBoxLineColor); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogLineIntersectAxis::SetLineColor(const QString &value) +{ + ChangeCurrentData(ui->comboBoxLineColor, value); +} + //--------------------------------------------------------------------------------------------------------------------- void DialogLineIntersectAxis::ShowDialog(bool click) { @@ -185,7 +190,7 @@ void DialogLineIntersectAxis::ShowDialog(bool click) /*We will ignore click if poinet is in point circle*/ VMainGraphicsScene *scene = qApp->getCurrentScene(); SCASSERT(scene != nullptr); - const QSharedPointer point = data->GeometricObject(basePointId); + const QSharedPointer point = data->GeometricObject(GetBasePointId()); QLineF line = QLineF(point->toQPointF(), scene->getScenePos()); //Radius of point circle, but little bigger. Need handle with hover sizes. @@ -196,7 +201,7 @@ void DialogLineIntersectAxis::ShowDialog(bool click) } } this->setModal(true); - this->setAngle(line->Angle());//Show in dialog angle what user choose + this->SetAngle(line->Angle());//Show in dialog angle what user choose emit ToolTip(""); timerFormula->start(); this->show(); @@ -242,7 +247,6 @@ void DialogLineIntersectAxis::ChosenObject(quint32 id, const SceneObject &type) { if (SetObject(id, ui->comboBoxAxisPoint, "")) { - basePointId = id; line->setAxisPointId(id); line->RefreshGeometry(); prepare = true; @@ -323,20 +327,15 @@ void DialogLineIntersectAxis::ShowVisualization() void DialogLineIntersectAxis::SaveData() { pointName = ui->lineEditNamePoint->text(); - typeLine = GetTypeLine(ui->comboBoxLineType); formulaAngle = ui->plainTextEditFormula->toPlainText(); formulaAngle.replace("\n", " "); - basePointId = getCurrentObjectId(ui->comboBoxAxisPoint); - firstPointId = getCurrentObjectId(ui->comboBoxFirstLinePoint); - secondPointId = getCurrentObjectId(ui->comboBoxSecondLinePoint); - - line->setPoint1Id(firstPointId); - line->setPoint2Id(secondPointId); - line->setAxisPointId(basePointId); - line->setAngle(formulaAngle); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); + line->setPoint1Id(GetFirstPointId()); + line->setPoint2Id(GetSecondPointId()); + line->setAxisPointId(GetBasePointId()); + line->SetAngle(formulaAngle); + line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine())); line->RefreshGeometry(); } diff --git a/src/app/dialogs/tools/dialoglineintersectaxis.h b/src/app/dialogs/tools/dialoglineintersectaxis.h index 73115d278..130510eb5 100644 --- a/src/app/dialogs/tools/dialoglineintersectaxis.h +++ b/src/app/dialogs/tools/dialoglineintersectaxis.h @@ -45,23 +45,25 @@ public: DialogLineIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); ~DialogLineIntersectAxis(); - QString getPointName() const; - void setPointName(const QString &value); + void SetPointName(const QString &value); - QString getTypeLine() const; - void setTypeLine(const QString &value); + QString GetTypeLine() const; + void SetTypeLine(const QString &value); - QString getAngle() const; - void setAngle(const QString &value); + QString GetAngle() const; + void SetAngle(const QString &value); - quint32 getBasePointId() const; - void setBasePointId(const quint32 &value); + quint32 GetBasePointId() const; + void SetBasePointId(const quint32 &value); - quint32 getFirstPointId() const; - void setFirstPointId(const quint32 &value); + quint32 GetFirstPointId() const; + void SetFirstPointId(const quint32 &value); - quint32 getSecondPointId() const; - void setSecondPointId(const quint32 &value); + quint32 GetSecondPointId() const; + void SetSecondPointId(const quint32 &value); + + QString GetLineColor() const; + void SetLineColor(const QString &value); virtual void ShowDialog(bool click); public slots: @@ -82,16 +84,7 @@ private: Q_DISABLE_COPY(DialogLineIntersectAxis) Ui::DialogLineIntersectAxis *ui; - /** @brief number number of handled objects */ - qint32 number; - - /** @brief typeLine type of line */ - QString typeLine; - QString formulaAngle; - quint32 basePointId; - quint32 firstPointId; - quint32 secondPointId; int formulaBaseHeightAngle; VisToolLineIntersectAxis *line; diff --git a/src/app/dialogs/tools/dialoglineintersectaxis.ui b/src/app/dialogs/tools/dialoglineintersectaxis.ui index de2030551..93bb92747 100644 --- a/src/app/dialogs/tools/dialoglineintersectaxis.ui +++ b/src/app/dialogs/tools/dialoglineintersectaxis.ui @@ -7,7 +7,7 @@ 0 0 457 - 532 + 565 @@ -325,6 +325,16 @@ + + + + Line color + + + + + + diff --git a/src/app/dialogs/tools/dialognormal.cpp b/src/app/dialogs/tools/dialognormal.cpp index 1461259cd..0d6ae44a6 100644 --- a/src/app/dialogs/tools/dialognormal.cpp +++ b/src/app/dialogs/tools/dialognormal.cpp @@ -39,8 +39,8 @@ * @param parent parent widget */ DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogNormal), number(0), typeLine(QString()), - formula(QString()), angle(0), firstPointId(NULL_ID), secondPointId(NULL_ID), formulaBaseHeight(0), line(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogNormal), formula(QString()), angle(0), formulaBaseHeight(0), + line(nullptr) { ui->setupUi(this); InitVariables(ui); @@ -57,6 +57,7 @@ DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidge FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxSecondPoint); FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics()); + FillComboBoxLineColors(ui->comboBoxLineColor); InitArrow(ui); @@ -172,18 +173,15 @@ void DialogNormal::ChosenObject(quint32 id, const SceneObject &type) void DialogNormal::SaveData() { pointName = ui->lineEditNamePoint->text(); - typeLine = GetTypeLine(ui->comboBoxLineType); formula = ui->plainTextEditFormula->toPlainText(); formula.replace("\n", " "); angle = ui->doubleSpinBoxAngle->value(); - firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint); - secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint); - line->setPoint1Id(firstPointId); - line->setPoint2Id(secondPointId); + line->setPoint1Id(GetFirstPointId()); + line->setPoint2Id(GetSecondPointId()); line->setLength(formula); - line->setAngle(angle); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); + line->SetAngle(angle); + line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine())); line->RefreshGeometry(); } @@ -196,44 +194,56 @@ void DialogNormal::closeEvent(QCloseEvent *event) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setSecondPointId set id of second point + * @brief SetSecondPointId set id of second point * @param value id */ -void DialogNormal::setSecondPointId(const quint32 &value) +void DialogNormal::SetSecondPointId(const quint32 &value) { - setPointId(ui->comboBoxSecondPoint, secondPointId, value); + setCurrentPointId(ui->comboBoxSecondPoint, value); line->setPoint2Id(value); } +//--------------------------------------------------------------------------------------------------------------------- +QString DialogNormal::GetLineColor() const +{ + return GetComboBoxCurrentData(ui->comboBoxLineColor); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogNormal::SetLineColor(const QString &value) +{ + ChangeCurrentData(ui->comboBoxLineColor, value); +} + //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setFirstPointId set id of first point + * @brief SetFirstPointId set id of first point * @param value id */ -void DialogNormal::setFirstPointId(const quint32 &value) +void DialogNormal::SetFirstPointId(const quint32 &value) { - setPointId(ui->comboBoxFirstPoint, firstPointId, value); + setCurrentPointId(ui->comboBoxFirstPoint, value); line->setPoint1Id(value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setAngle set aditional angle of normal + * @brief SetAngle set aditional angle of normal * @param value angle in degree */ -void DialogNormal::setAngle(const qreal &value) +void DialogNormal::SetAngle(const qreal &value) { angle = value; ui->doubleSpinBoxAngle->setValue(angle); - line->setAngle(angle); + line->SetAngle(angle); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setFormula set string of formula + * @brief SetFormula set string of formula * @param value formula */ -void DialogNormal::setFormula(const QString &value) +void DialogNormal::SetFormula(const QString &value) { formula = qApp->FormulaToUser(value); // increase height if needed. @@ -248,23 +258,72 @@ void DialogNormal::setFormula(const QString &value) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setTypeLine set type of line + * @brief SetTypeLine set type of line * @param value type */ -void DialogNormal::setTypeLine(const QString &value) +void DialogNormal::SetTypeLine(const QString &value) { - typeLine = value; - SetupTypeLine(ui->comboBoxLineType, value); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); + ChangeCurrentData(ui->comboBoxLineType, value); + line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setPointName set name of point + * @brief SetPointName set name of point * @param value name */ -void DialogNormal::setPointName(const QString &value) +void DialogNormal::SetPointName(const QString &value) { pointName = value; ui->lineEditNamePoint->setText(pointName); } + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetTypeLine return type of line + * @return type + */ +QString DialogNormal::GetTypeLine() const +{ + return GetComboBoxCurrentData(ui->comboBoxLineType); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetFormula return string of formula + * @return formula + */ +QString DialogNormal::GetFormula() const +{ + return qApp->FormulaFromUser(formula); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetAngle return aditional angle of normal + * @return angle in degree + */ +qreal DialogNormal::GetAngle() const +{ + return angle; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetFirstPointId return id of first point + * @return id + */ +quint32 DialogNormal::GetFirstPointId() const +{ + return getCurrentObjectId(ui->comboBoxFirstPoint); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetSecondPointId return id of second point + * @return id + */ +quint32 DialogNormal::GetSecondPointId() const +{ + return getCurrentObjectId(ui->comboBoxSecondPoint); +} diff --git a/src/app/dialogs/tools/dialognormal.h b/src/app/dialogs/tools/dialognormal.h index 0b346d473..8fce4a01a 100644 --- a/src/app/dialogs/tools/dialognormal.h +++ b/src/app/dialogs/tools/dialognormal.h @@ -48,23 +48,25 @@ public: DialogNormal(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); ~DialogNormal(); - QString getPointName() const; - void setPointName(const QString &value); + void SetPointName(const QString &value); - QString getTypeLine() const; - void setTypeLine(const QString &value); + QString GetTypeLine() const; + void SetTypeLine(const QString &value); - QString getFormula() const; - void setFormula(const QString &value); + QString GetFormula() const; + void SetFormula(const QString &value); - qreal getAngle() const; - void setAngle(const qreal &value); + qreal GetAngle() const; + void SetAngle(const qreal &value); - quint32 getFirstPointId() const; - void setFirstPointId(const quint32 &value); + quint32 GetFirstPointId() const; + void SetFirstPointId(const quint32 &value); - quint32 getSecondPointId() const; - void setSecondPointId(const quint32 &value); + quint32 GetSecondPointId() const; + void SetSecondPointId(const quint32 &value); + + QString GetLineColor() const; + void SetLineColor(const QString &value); public slots: virtual void ChosenObject(quint32 id, const SceneObject &type); /** @@ -89,88 +91,16 @@ private: /** @brief ui keeps information about user interface */ Ui::DialogNormal *ui; - /** @brief number number of handled objects */ - qint32 number; - - /** @brief typeLine type of line */ - QString typeLine; - /** @brief formula formula */ QString formula; /** @brief angle aditional angle of normal */ qreal angle; - /** @brief firstPointId id first point of line */ - quint32 firstPointId; - - /** @brief secondPointId id second point of line */ - quint32 secondPointId; - /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; VisToolNormal *line; }; -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getPointName return name of point - * @return name - */ -inline QString DialogNormal::getPointName() const -{ - return pointName; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getTypeLine return type of line - * @return type - */ -inline QString DialogNormal::getTypeLine() const -{ - return typeLine; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getFormula return string of formula - * @return formula - */ -inline QString DialogNormal::getFormula() const -{ - return qApp->FormulaFromUser(formula); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getAngle return aditional angle of normal - * @return angle in degree - */ -inline qreal DialogNormal::getAngle() const -{ - return angle; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getFirstPointId return id of first point - * @return id - */ -inline quint32 DialogNormal::getFirstPointId() const -{ - return firstPointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getSecondPointId return id of second point - * @return id - */ -inline quint32 DialogNormal::getSecondPointId() const -{ - return secondPointId; -} - #endif // DIALOGNORMAL_H diff --git a/src/app/dialogs/tools/dialognormal.ui b/src/app/dialogs/tools/dialognormal.ui index 6cbff13b9..b5fb9541a 100644 --- a/src/app/dialogs/tools/dialognormal.ui +++ b/src/app/dialogs/tools/dialognormal.ui @@ -7,7 +7,7 @@ 0 0 517 - 645 + 678 @@ -480,44 +480,54 @@ - - - - - - Type of line - - - - - - - - 80 - 0 - - - - - 110 - 16777215 - - - - Show line from first point to this point - - - - 80 - 14 - - - - - - + + + + + + Type of line + + + + + + + + 80 + 0 + + + + + 110 + 16777215 + + + + Show line from first point to this point + + + + 80 + 14 + + + + + + + + + + + Line color + + + + + @@ -697,7 +707,6 @@ toolButtonArrowLeftDown toolButtonArrowLeft toolButtonArrowLeftUp - comboBoxLineType radioButtonSizeGrowth radioButtonStandardTable radioButtonIncrements diff --git a/src/app/dialogs/tools/dialogpointofcontact.cpp b/src/app/dialogs/tools/dialogpointofcontact.cpp index 27e6e3ae3..d01773ffb 100644 --- a/src/app/dialogs/tools/dialogpointofcontact.cpp +++ b/src/app/dialogs/tools/dialogpointofcontact.cpp @@ -41,8 +41,8 @@ * @param parent parent widget */ DialogPointOfContact::DialogPointOfContact(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfContact), number(0), - radius(QString()), center(NULL_ID), firstPoint(NULL_ID), secondPoint(NULL_ID), formulaBaseHeight(0), line(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfContact), + radius(QString()), formulaBaseHeight(0), line(nullptr) { ui->setupUi(this); InitVariables(ui); @@ -217,13 +217,10 @@ void DialogPointOfContact::SaveData() pointName = ui->lineEditNamePoint->text(); radius = ui->plainTextEditFormula->toPlainText(); radius.replace("\n", " "); - center = getCurrentObjectId(ui->comboBoxCenter); - firstPoint = getCurrentObjectId(ui->comboBoxFirstPoint); - secondPoint = getCurrentObjectId(ui->comboBoxSecondPoint); - line->setPoint1Id(firstPoint); - line->setLineP2Id(secondPoint); - line->setRadiusId(center); + line->setPoint1Id(GetFirstPoint()); + line->setLineP2Id(GetSecondPoint()); + line->setRadiusId(getCenter()); line->setRadius(radius); line->RefreshGeometry(); } @@ -237,24 +234,24 @@ void DialogPointOfContact::closeEvent(QCloseEvent *event) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setSecondPoint set id second point + * @brief SetSecondPoint set id second point * @param value id */ -void DialogPointOfContact::setSecondPoint(const quint32 &value) +void DialogPointOfContact::SetSecondPoint(const quint32 &value) { - setPointId(ui->comboBoxSecondPoint, secondPoint, value); - line->setLineP2Id(secondPoint); + setCurrentPointId(ui->comboBoxSecondPoint, value); + line->setLineP2Id(value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setFirstPoint set id first point + * @brief SetFirstPoint set id first point * @param value id */ -void DialogPointOfContact::setFirstPoint(const quint32 &value) +void DialogPointOfContact::SetFirstPoint(const quint32 &value) { - setPointId(ui->comboBoxFirstPoint, firstPoint, value); - line->setPoint1Id(firstPoint); + setCurrentPointId(ui->comboBoxFirstPoint, value); + line->setPoint1Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -264,8 +261,8 @@ void DialogPointOfContact::setFirstPoint(const quint32 &value) */ void DialogPointOfContact::setCenter(const quint32 &value) { - setPointId(ui->comboBoxCenter, center, value); - line->setRadiusId(center); + setCurrentPointId(ui->comboBoxCenter, value); + line->setRadiusId(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -288,11 +285,51 @@ void DialogPointOfContact::setRadius(const QString &value) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setPointName set name of point + * @brief SetPointName set name of point * @param value name */ -void DialogPointOfContact::setPointName(const QString &value) +void DialogPointOfContact::SetPointName(const QString &value) { pointName = value; ui->lineEditNamePoint->setText(pointName); } + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getRadius return formula radius of arc + * @return formula + */ +QString DialogPointOfContact::getRadius() const +{ + return radius; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetCenter return id of center point + * @return id + */ +quint32 DialogPointOfContact::getCenter() const +{ + return getCurrentObjectId(ui->comboBoxCenter); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetFirstPoint return id first point + * @return id + */ +quint32 DialogPointOfContact::GetFirstPoint() const +{ + return getCurrentObjectId(ui->comboBoxFirstPoint);; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetSecondPoint return id second point + * @return id + */ +quint32 DialogPointOfContact::GetSecondPoint() const +{ + return getCurrentObjectId(ui->comboBoxSecondPoint); +} diff --git a/src/app/dialogs/tools/dialogpointofcontact.h b/src/app/dialogs/tools/dialogpointofcontact.h index 2b7126f3e..549487a2e 100644 --- a/src/app/dialogs/tools/dialogpointofcontact.h +++ b/src/app/dialogs/tools/dialogpointofcontact.h @@ -49,8 +49,7 @@ public: DialogPointOfContact(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); virtual ~DialogPointOfContact(); - QString getPointName() const; - void setPointName(const QString &value); + void SetPointName(const QString &value); QString getRadius() const; void setRadius(const QString &value); @@ -58,11 +57,11 @@ public: quint32 getCenter() const; void setCenter(const quint32 &value); - quint32 getFirstPoint() const; - void setFirstPoint(const quint32 &value); + quint32 GetFirstPoint() const; + void SetFirstPoint(const quint32 &value); - quint32 getSecondPoint() const; - void setSecondPoint(const quint32 &value); + quint32 GetSecondPoint() const; + void SetSecondPoint(const quint32 &value); public slots: virtual void ChosenObject(quint32 id, const SceneObject &type); /** @@ -87,75 +86,13 @@ private: /** @brief ui keeps information about user interface */ Ui::DialogPointOfContact *ui; - /** @brief number number of handled objects */ - qint32 number; - /** @brief radius radius of arc */ QString radius; - /** @brief center id center point of arc */ - quint32 center; - - /** @brief firstPoint id first point of line */ - quint32 firstPoint; - - /** @brief secondPoint id second point of line */ - quint32 secondPoint; - /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; VisToolPointOfContact *line; }; -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getPointName return name of point - * @return name - */ -inline QString DialogPointOfContact::getPointName() const -{ - return pointName; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getRadius return formula radius of arc - * @return formula - */ -inline QString DialogPointOfContact::getRadius() const -{ - return radius; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief GetCenter return id of center point - * @return id - */ -inline quint32 DialogPointOfContact::getCenter() const -{ - return center; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getFirstPoint return id first point - * @return id - */ -inline quint32 DialogPointOfContact::getFirstPoint() const -{ - return firstPoint; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getSecondPoint return id second point - * @return id - */ -inline quint32 DialogPointOfContact::getSecondPoint() const -{ - return secondPoint; -} - #endif // DIALOGPOINTOFCONTACT_H diff --git a/src/app/dialogs/tools/dialogpointofintersection.cpp b/src/app/dialogs/tools/dialogpointofintersection.cpp index 5f565ddeb..882afa5dd 100644 --- a/src/app/dialogs/tools/dialogpointofintersection.cpp +++ b/src/app/dialogs/tools/dialogpointofintersection.cpp @@ -42,8 +42,7 @@ * @param parent parent widget */ DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersection), number(0), - firstPointId(NULL_ID), secondPointId(NULL_ID), line(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersection), line(nullptr) { ui->setupUi(this); ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); @@ -77,13 +76,13 @@ DialogPointOfIntersection::~DialogPointOfIntersection() //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setSecondPointId set id of second point + * @brief SetSecondPointId set id of second point * @param value id */ -void DialogPointOfIntersection::setSecondPointId(const quint32 &value) +void DialogPointOfIntersection::SetSecondPointId(const quint32 &value) { - setPointId(ui->comboBoxSecondPoint, secondPointId, value); - line->setPoint2Id(secondPointId); + setCurrentPointId(ui->comboBoxSecondPoint, value); + line->setPoint2Id(value); } //--------------------------------------------------------------------------------------------------------------------- @@ -132,11 +131,9 @@ void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type void DialogPointOfIntersection::SaveData() { pointName = ui->lineEditNamePoint->text(); - firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint); - secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint); - line->setPoint1Id(firstPointId); - line->setPoint2Id(secondPointId); + line->setPoint1Id(GetFirstPointId()); + line->setPoint2Id(GetSecondPointId()); line->RefreshGeometry(); } @@ -181,22 +178,42 @@ void DialogPointOfIntersection::ShowVisualization() //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setFirstPointId set id of first point + * @brief SetFirstPointId set id of first point * @param value id */ -void DialogPointOfIntersection::setFirstPointId(const quint32 &value) +void DialogPointOfIntersection::SetFirstPointId(const quint32 &value) { - setPointId(ui->comboBoxFirstPoint, firstPointId, value); - line->setPoint1Id(firstPointId); + setCurrentPointId(ui->comboBoxFirstPoint, value); + line->setPoint1Id(value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setPointName set name of point + * @brief SetPointName set name of point * @param value name */ -void DialogPointOfIntersection::setPointName(const QString &value) +void DialogPointOfIntersection::SetPointName(const QString &value) { pointName = value; ui->lineEditNamePoint->setText(pointName); } + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetFirstPointId return id of first point + * @return id + */ +quint32 DialogPointOfIntersection::GetFirstPointId() const +{ + return getCurrentObjectId(ui->comboBoxFirstPoint); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetSecondPointId return id of second point + * @return id + */ +quint32 DialogPointOfIntersection::GetSecondPointId() const +{ + return getCurrentObjectId(ui->comboBoxSecondPoint); +} diff --git a/src/app/dialogs/tools/dialogpointofintersection.h b/src/app/dialogs/tools/dialogpointofintersection.h index 00fb7648b..811375a8d 100644 --- a/src/app/dialogs/tools/dialogpointofintersection.h +++ b/src/app/dialogs/tools/dialogpointofintersection.h @@ -48,14 +48,13 @@ public: DialogPointOfIntersection(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); ~DialogPointOfIntersection(); - QString getPointName() const; - void setPointName(const QString &value); + void SetPointName(const QString &value); - quint32 getFirstPointId() const; - void setFirstPointId(const quint32 &value); + quint32 GetFirstPointId() const; + void SetFirstPointId(const quint32 &value); - quint32 getSecondPointId() const; - void setSecondPointId(const quint32 &value); + quint32 GetSecondPointId() const; + void SetSecondPointId(const quint32 &value); public slots: virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void PointNameChanged(); @@ -72,45 +71,7 @@ private: /** @brief ui keeps information about user interface */ Ui::DialogPointOfIntersection *ui; - /** @brief number number of handled objects */ - qint32 number; - - /** @brief firstPointId id first point of line */ - quint32 firstPointId; - - /** @brief secondPointId id second point of line */ - quint32 secondPointId; VisToolPointOfIntersection *line; }; -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getPointName return name of point - * @return name - */ -inline QString DialogPointOfIntersection::getPointName() const -{ - return pointName; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getFirstPointId return id of first point - * @return id - */ -inline quint32 DialogPointOfIntersection::getFirstPointId() const -{ - return firstPointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getSecondPointId return id of second point - * @return id - */ -inline quint32 DialogPointOfIntersection::getSecondPointId() const -{ - return secondPointId; -} - #endif // DIALOGPOINTOFINTERSECTION_H diff --git a/src/app/dialogs/tools/dialogshoulderpoint.cpp b/src/app/dialogs/tools/dialogshoulderpoint.cpp index 1ef046f91..ad92e20c8 100644 --- a/src/app/dialogs/tools/dialogshoulderpoint.cpp +++ b/src/app/dialogs/tools/dialogshoulderpoint.cpp @@ -42,9 +42,8 @@ * @param parent parent widget */ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogShoulderPoint), number(0), - typeLine(QString()), formula(QString()), p1Line(NULL_ID), p2Line(NULL_ID), pShoulder(NULL_ID), formulaBaseHeight(0), - line (nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogShoulderPoint), formula(QString()), + formulaBaseHeight(0), line (nullptr) { ui->setupUi(this); InitVariables(ui); @@ -62,6 +61,7 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 & FillComboBoxPoints(ui->comboBoxP1Line); FillComboBoxPoints(ui->comboBoxP2Line); FillComboBoxPoints(ui->comboBoxP3); + FillComboBoxLineColors(ui->comboBoxLineColor); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogShoulderPoint::PutHere); connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogShoulderPoint::PutVal); @@ -201,18 +201,14 @@ void DialogShoulderPoint::ChosenObject(quint32 id, const SceneObject &type) void DialogShoulderPoint::SaveData() { pointName = ui->lineEditNamePoint->text(); - typeLine = GetTypeLine(ui->comboBoxLineType); formula = ui->plainTextEditFormula->toPlainText(); formula.replace("\n", " "); - p1Line = getCurrentObjectId(ui->comboBoxP1Line); - p2Line = getCurrentObjectId(ui->comboBoxP2Line); - pShoulder = getCurrentObjectId(ui->comboBoxP3); - line->setPoint1Id(pShoulder); - line->setLineP1Id(p1Line); - line->setLineP2Id(p2Line); + line->setPoint1Id(GetP3()); + line->setLineP1Id(GetP1Line()); + line->setLineP2Id(GetP2Line()); line->setLength(formula); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); + line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine())); line->RefreshGeometry(); } @@ -228,40 +224,52 @@ void DialogShoulderPoint::closeEvent(QCloseEvent *event) * @brief setPShoulder set id shoulder point * @param value id */ -void DialogShoulderPoint::setP3(const quint32 &value) +void DialogShoulderPoint::SetP3(const quint32 &value) { - setPointId(ui->comboBoxP3, pShoulder, value); - line->setPoint1Id(pShoulder); + setCurrentPointId(ui->comboBoxP3, value); + line->setPoint1Id(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogShoulderPoint::GetLineColor() const +{ + return GetComboBoxCurrentData(ui->comboBoxLineColor); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogShoulderPoint::SetLineColor(const QString &value) +{ + ChangeCurrentData(ui->comboBoxLineColor, value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setP2Line set id second point of line + * @brief SetP2Line set id second point of line * @param value id */ -void DialogShoulderPoint::setP2Line(const quint32 &value) +void DialogShoulderPoint::SetP2Line(const quint32 &value) { - setPointId(ui->comboBoxP2Line, p2Line, value); - line->setLineP2Id(p2Line); + setCurrentPointId(ui->comboBoxP2Line, value); + line->setLineP2Id(value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setP1Line set id first point of line + * @brief SetP1Line set id first point of line * @param value id */ -void DialogShoulderPoint::setP1Line(const quint32 &value) +void DialogShoulderPoint::SetP1Line(const quint32 &value) { - setPointId(ui->comboBoxP1Line, p1Line, value); - line->setLineP1Id(p1Line); + setCurrentPointId(ui->comboBoxP1Line, value); + line->setLineP1Id(value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setFormula set string of formula + * @brief SetFormula set string of formula * @param value formula */ -void DialogShoulderPoint::setFormula(const QString &value) +void DialogShoulderPoint::SetFormula(const QString &value) { formula = qApp->FormulaToUser(value); // increase height if needed. @@ -276,23 +284,72 @@ void DialogShoulderPoint::setFormula(const QString &value) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setTypeLine set type of line + * @brief SetTypeLine set type of line * @param value type */ -void DialogShoulderPoint::setTypeLine(const QString &value) +void DialogShoulderPoint::SetTypeLine(const QString &value) { - typeLine = value; - SetupTypeLine(ui->comboBoxLineType, value); - line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); + ChangeCurrentData(ui->comboBoxLineType, value); + line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value)); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setPointName set name of point + * @brief SetPointName set name of point * @param value name */ -void DialogShoulderPoint::setPointName(const QString &value) +void DialogShoulderPoint::SetPointName(const QString &value) { pointName = value; ui->lineEditNamePoint->setText(pointName); } + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetTypeLine return type of line + * @return type + */ +QString DialogShoulderPoint::GetTypeLine() const +{ + return GetComboBoxCurrentData(ui->comboBoxLineType); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetFormula return string of formula + * @return formula + */ +QString DialogShoulderPoint::GetFormula() const +{ + return qApp->FormulaFromUser(formula); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetP1Line return id first point of line + * @return id + */ +quint32 DialogShoulderPoint::GetP1Line() const +{ + return getCurrentObjectId(ui->comboBoxP1Line); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetP2Line return id second point of line + * @return id + */ +quint32 DialogShoulderPoint::GetP2Line() const +{ + return getCurrentObjectId(ui->comboBoxP2Line); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getPShoulder return id shoulder point + * @return id + */ +quint32 DialogShoulderPoint::GetP3() const +{ + return getCurrentObjectId(ui->comboBoxP3); +} diff --git a/src/app/dialogs/tools/dialogshoulderpoint.h b/src/app/dialogs/tools/dialogshoulderpoint.h index 47c1d489c..4f5670654 100644 --- a/src/app/dialogs/tools/dialogshoulderpoint.h +++ b/src/app/dialogs/tools/dialogshoulderpoint.h @@ -48,23 +48,25 @@ public: DialogShoulderPoint(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); ~DialogShoulderPoint(); - QString getPointName() const; - void setPointName(const QString &value); + void SetPointName(const QString &value); - QString getTypeLine() const; - void setTypeLine(const QString &value); + QString GetTypeLine() const; + void SetTypeLine(const QString &value); - QString getFormula() const; - void setFormula(const QString &value); + QString GetFormula() const; + void SetFormula(const QString &value); - quint32 getP1Line() const; - void setP1Line(const quint32 &value); + quint32 GetP1Line() const; + void SetP1Line(const quint32 &value); - quint32 getP2Line() const; - void setP2Line(const quint32 &value); + quint32 GetP2Line() const; + void SetP2Line(const quint32 &value); - quint32 getP3() const; - void setP3(const quint32 &value); + quint32 GetP3() const; + void SetP3(const quint32 &value); + + QString GetLineColor() const; + void SetLineColor(const QString &value); public slots: virtual void ChosenObject(quint32 id, const SceneObject &type); /** @@ -89,87 +91,12 @@ private: /** @brief ui keeps information about user interface */ Ui::DialogShoulderPoint *ui; - /** @brief number number of handled objects */ - qint32 number; - - /** @brief typeLine type of line */ - QString typeLine; - /** @brief formula formula */ QString formula; - /** @brief p1Line id first point of line */ - quint32 p1Line; - - /** @brief p2Line id second point of line */ - quint32 p2Line; - - /** @brief pShoulder id shoulder point */ - quint32 pShoulder; - /** @brief formulaBaseHeight base height defined by dialogui */ int formulaBaseHeight; VisToolShoulderPoint *line; }; -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getPointName return name of point - * @return name - */ -inline QString DialogShoulderPoint::getPointName() const -{ - return pointName; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getTypeLine return type of line - * @return type - */ -inline QString DialogShoulderPoint::getTypeLine() const -{ - return typeLine; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getFormula return string of formula - * @return formula - */ -inline QString DialogShoulderPoint::getFormula() const -{ - return qApp->FormulaFromUser(formula); -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getP1Line return id first point of line - * @return id - */ -inline quint32 DialogShoulderPoint::getP1Line() const -{ - return p1Line; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getP2Line return id second point of line - * @return id - */ -inline quint32 DialogShoulderPoint::getP2Line() const -{ - return p2Line; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getPShoulder return id shoulder point - * @return id - */ -inline quint32 DialogShoulderPoint::getP3() const -{ - return pShoulder; -} - #endif // DIALOGSHOULDERPOINT_H diff --git a/src/app/dialogs/tools/dialogshoulderpoint.ui b/src/app/dialogs/tools/dialogshoulderpoint.ui index 8c306b556..c63a6d001 100644 --- a/src/app/dialogs/tools/dialogshoulderpoint.ui +++ b/src/app/dialogs/tools/dialogshoulderpoint.ui @@ -7,7 +7,7 @@ 0 0 488 - 532 + 565 @@ -364,6 +364,16 @@ + + + + Line color + + + + + + diff --git a/src/app/dialogs/tools/dialogsinglepoint.cpp b/src/app/dialogs/tools/dialogsinglepoint.cpp index 3c95d069c..f218776a4 100644 --- a/src/app/dialogs/tools/dialogsinglepoint.cpp +++ b/src/app/dialogs/tools/dialogsinglepoint.cpp @@ -92,7 +92,7 @@ void DialogSinglePoint::UpdateList() * @param name name of point * @param point data for point */ -void DialogSinglePoint::setData(const QString &name, const QPointF &point) +void DialogSinglePoint::SetData(const QString &name, const QPointF &point) { pointName = name; this->point = point; @@ -107,3 +107,13 @@ DialogSinglePoint::~DialogSinglePoint() { delete ui; } + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief getPoint return point + * @return point + */ +QPointF DialogSinglePoint::GetPoint() const +{ + return point; +} diff --git a/src/app/dialogs/tools/dialogsinglepoint.h b/src/app/dialogs/tools/dialogsinglepoint.h index 86e489ab9..0b6ef3d0b 100644 --- a/src/app/dialogs/tools/dialogsinglepoint.h +++ b/src/app/dialogs/tools/dialogsinglepoint.h @@ -45,9 +45,10 @@ class DialogSinglePoint : public DialogTool public: DialogSinglePoint(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); ~DialogSinglePoint(); - void setData(const QString &name, const QPointF &point); - QString getName()const; - QPointF getPoint()const; + + void SetData(const QString &name, const QPointF &point); + QPointF GetPoint()const; + public slots: void mousePress(const QPointF &scenePos); virtual void UpdateList(); @@ -66,24 +67,4 @@ private: QPointF point; }; -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getName return name - * @return name - */ -inline QString DialogSinglePoint::getName() const -{ - return pointName; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getPoint return point - * @return point - */ -inline QPointF DialogSinglePoint::getPoint() const -{ - return point; -} - #endif // DIALOGSINGLEPOINT_H diff --git a/src/app/dialogs/tools/dialogspline.cpp b/src/app/dialogs/tools/dialogspline.cpp index d60ae5b9c..496c461dd 100644 --- a/src/app/dialogs/tools/dialogspline.cpp +++ b/src/app/dialogs/tools/dialogspline.cpp @@ -41,14 +41,16 @@ * @param parent parent widget */ DialogSpline::DialogSpline(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogSpline), number(0), p1(NULL_ID), p4(NULL_ID), angle1(0), - angle2(0), kAsm1(1), kAsm2(1), kCurve(1), path(nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogSpline), angle1(0), angle2(0), kAsm1(1), kAsm2(1), + kCurve(1), path(nullptr) { ui->setupUi(this); InitOkCancelApply(ui); FillComboBoxPoints(ui->comboBoxP1); FillComboBoxPoints(ui->comboBoxP4); + FillComboBoxLineColors(ui->comboBoxColor); + connect(ui->comboBoxP1, static_cast(&QComboBox::currentIndexChanged), this, &DialogSpline::PointNameChanged); connect(ui->comboBoxP4, static_cast(&QComboBox::currentIndexChanged), @@ -69,12 +71,12 @@ DialogSpline::~DialogSpline() //--------------------------------------------------------------------------------------------------------------------- /** - * @brief getP1 return id first point of spline + * @brief GetP1 return id first point of spline * @return id */ -quint32 DialogSpline::getP1() const +quint32 DialogSpline::GetP1() const { - return p1; + return getCurrentObjectId(ui->comboBoxP1); } //--------------------------------------------------------------------------------------------------------------------- @@ -139,21 +141,19 @@ void DialogSpline::ChosenObject(quint32 id, const SceneObject &type) //--------------------------------------------------------------------------------------------------------------------- void DialogSpline::SaveData() { - p1 = getCurrentObjectId(ui->comboBoxP1); - p4 = getCurrentObjectId(ui->comboBoxP4); angle1 = ui->spinBoxAngle1->value(); angle2 = ui->spinBoxAngle2->value(); kAsm1 = ui->doubleSpinBoxKasm1->value(); kAsm2 = ui->doubleSpinBoxKasm2->value(); kCurve = ui->doubleSpinBoxKcurve->value(); - path->setPoint1Id(p1); - path->setPoint4Id(p4); - path->setAngle1(angle1); - path->setAngle2(angle2); - path->setKAsm1(kAsm1); - path->setKAsm2(kAsm2); - path->setKCurve(kCurve); + path->setPoint1Id(GetP1()); + path->setPoint4Id(GetP4()); + path->SetAngle1(angle1); + path->SetAngle2(angle2); + path->SetKAsm1(kAsm1); + path->SetKAsm2(kAsm2); + path->SetKCurve(kCurve); path->RefreshGeometry(); } @@ -203,92 +203,154 @@ void DialogSpline::ShowVisualization() //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setKCurve set coefficient curve + * @brief SetKCurve set coefficient curve * @param value value. Can be >= 0. */ -void DialogSpline::setKCurve(const qreal &value) +void DialogSpline::SetKCurve(const qreal &value) { kCurve = value; ui->doubleSpinBoxKcurve->setValue(value); - path->setKCurve(kCurve); + path->SetKCurve(kCurve); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogSpline::GetColor() const +{ + return GetComboBoxCurrentData(ui->comboBoxColor); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSpline::SetColor(const QString &value) +{ + ChangeCurrentData(ui->comboBoxColor, value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setKAsm2 set second coefficient asymmetry + * @brief SetKAsm2 set second coefficient asymmetry * @param value value. Can be >= 0. */ -void DialogSpline::setKAsm2(const qreal &value) +void DialogSpline::SetKAsm2(const qreal &value) { kAsm2 = value; ui->doubleSpinBoxKasm2->setValue(value); - path->setKAsm2(kAsm2); + path->SetKAsm2(kAsm2); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setKAsm1 set first coefficient asymmetry + * @brief SetKAsm1 set first coefficient asymmetry * @param value value. Can be >= 0. */ -void DialogSpline::setKAsm1(const qreal &value) +void DialogSpline::SetKAsm1(const qreal &value) { kAsm1 = value; ui->doubleSpinBoxKasm1->setValue(value); - path->setKAsm1(kAsm1); + path->SetKAsm1(kAsm1); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setAngle2 set second angle of spline + * @brief SetAngle2 set second angle of spline * @param value angle in degree */ -void DialogSpline::setAngle2(const qreal &value) +void DialogSpline::SetAngle2(const qreal &value) { angle2 = value; ui->spinBoxAngle2->setValue(static_cast(value)); - path->setAngle2(angle2); + path->SetAngle2(angle2); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setAngle1 set first angle of spline + * @brief SetAngle1 set first angle of spline * @param value angle in degree */ -void DialogSpline::setAngle1(const qreal &value) +void DialogSpline::SetAngle1(const qreal &value) { angle1 = value; ui->spinBoxAngle1->setValue(static_cast(value)); - path->setAngle1(angle1); + path->SetAngle1(angle1); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setP4 set id fourth point of spline + * @brief SetP4 set id fourth point of spline * @param value id */ -void DialogSpline::setP4(const quint32 &value) +void DialogSpline::SetP4(const quint32 &value) { - setPointId(ui->comboBoxP4, p4, value); - path->setPoint4Id(p4); + setCurrentPointId(ui->comboBoxP4, value); + path->setPoint4Id(value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setP1 set id first point of spline + * @brief SetP1 set id first point of spline * @param value id */ -void DialogSpline::setP1(const quint32 &value) +void DialogSpline::SetP1(const quint32 &value) { - setPointId(ui->comboBoxP1, p1, value); - path->setPoint1Id(p1); + setCurrentPointId(ui->comboBoxP1, value); + path->setPoint1Id(value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief getP4 return id fourth point of spline + * @brief GetP4 return id fourth point of spline * @return id */ -quint32 DialogSpline::getP4() const +quint32 DialogSpline::GetP4() const { - return p4; + return getCurrentObjectId(ui->comboBoxP4); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetAngle1 return first angle of spline + * @return angle in degree + */ +qreal DialogSpline::GetAngle1() const +{ + return angle1; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetAngle2 return second angle of spline + * @return angle in degree + */ +qreal DialogSpline::GetAngle2() const +{ + return angle2; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetKAsm1 return first coefficient asymmetry + * @return value. Can be >= 0. + */ +qreal DialogSpline::GetKAsm1() const +{ + return kAsm1; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetKAsm2 return second coefficient asymmetry + * @return value. Can be >= 0. + */ +qreal DialogSpline::GetKAsm2() const +{ + return kAsm2; +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetKCurve return coefficient curve + * @return value. Can be >= 0. + */ +qreal DialogSpline::GetKCurve() const +{ + return kCurve; } diff --git a/src/app/dialogs/tools/dialogspline.h b/src/app/dialogs/tools/dialogspline.h index 20d97f396..b2634c5f7 100644 --- a/src/app/dialogs/tools/dialogspline.h +++ b/src/app/dialogs/tools/dialogspline.h @@ -48,26 +48,29 @@ public: DialogSpline(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); ~DialogSpline(); - quint32 getP1() const; - void setP1(const quint32 &value); + quint32 GetP1() const; + void SetP1(const quint32 &value); - quint32 getP4() const; - void setP4(const quint32 &value); + quint32 GetP4() const; + void SetP4(const quint32 &value); - qreal getAngle1() const; - void setAngle1(const qreal &value); + qreal GetAngle1() const; + void SetAngle1(const qreal &value); - qreal getAngle2() const; - void setAngle2(const qreal &value); + qreal GetAngle2() const; + void SetAngle2(const qreal &value); - qreal getKAsm1() const; - void setKAsm1(const qreal &value); + qreal GetKAsm1() const; + void SetKAsm1(const qreal &value); - qreal getKAsm2() const; - void setKAsm2(const qreal &value); + qreal GetKAsm2() const; + void SetKAsm2(const qreal &value); - qreal getKCurve() const; - void setKCurve(const qreal &value); + qreal GetKCurve() const; + void SetKCurve(const qreal &value); + + QString GetColor() const; + void SetColor(const QString &value); public slots: virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void PointNameChanged(); @@ -84,15 +87,6 @@ private: /** @brief ui keeps information about user interface */ Ui::DialogSpline *ui; - /** @brief number number of handled objects */ - qint32 number; - - /** @brief p1 id first point of spline */ - quint32 p1; - - /** @brief p4 id fourth point of spline */ - quint32 p4; - /** @brief angle1 first angle of spline in degree */ qreal angle1; @@ -111,54 +105,4 @@ private: VisToolSpline *path; }; -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getAngle1 return first angle of spline - * @return angle in degree - */ -inline qreal DialogSpline::getAngle1() const -{ - return angle1; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getAngle2 return second angle of spline - * @return angle in degree - */ -inline qreal DialogSpline::getAngle2() const -{ - return angle2; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getKAsm1 return first coefficient asymmetry - * @return value. Can be >= 0. - */ -inline qreal DialogSpline::getKAsm1() const -{ - return kAsm1; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getKAsm2 return second coefficient asymmetry - * @return value. Can be >= 0. - */ -inline qreal DialogSpline::getKAsm2() const -{ - return kAsm2; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getKCurve return coefficient curve - * @return value. Can be >= 0. - */ -inline qreal DialogSpline::getKCurve() const -{ - return kCurve; -} - #endif // DIALOGSPLINE_H diff --git a/src/app/dialogs/tools/dialogspline.ui b/src/app/dialogs/tools/dialogspline.ui index 580268256..10238a584 100644 --- a/src/app/dialogs/tools/dialogspline.ui +++ b/src/app/dialogs/tools/dialogspline.ui @@ -6,8 +6,8 @@ 0 0 - 524 - 254 + 540 + 233 @@ -152,8 +152,11 @@ - - + + + QFormLayout::AllNonFixedFieldsGrow + + @@ -172,7 +175,7 @@ - + @@ -194,6 +197,16 @@ + + + + Color + + + + + + @@ -215,7 +228,6 @@ comboBoxP4 doubleSpinBoxKasm2 spinBoxAngle2 - doubleSpinBoxKcurve buttonBox diff --git a/src/app/dialogs/tools/dialogsplinepath.cpp b/src/app/dialogs/tools/dialogsplinepath.cpp index e68650792..fe059a403 100644 --- a/src/app/dialogs/tools/dialogsplinepath.cpp +++ b/src/app/dialogs/tools/dialogsplinepath.cpp @@ -46,6 +46,7 @@ DialogSplinePath::DialogSplinePath(const VContainer *data, const quint32 &toolId bOk->setEnabled(false); FillComboBoxPoints(ui->comboBoxPoint); + FillComboBoxLineColors(ui->comboBoxColor); connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogSplinePath::PointChanged); connect(ui->comboBoxPoint, static_cast(&QComboBox::currentIndexChanged), @@ -87,12 +88,24 @@ void DialogSplinePath::SetPath(const VSplinePath &value) NewItem(path.at(i).P().id(), path.at(i).KAsm1(), path.at(i).Angle1(), path.at(i).KAsm2(), path.at(i).Angle2()); } ui->listWidget->setFocus(Qt::OtherFocusReason); - ui->doubleSpinBoxKcurve->setValue(path.getKCurve()); + ui->doubleSpinBoxKcurve->setValue(path.GetKCurve()); visPath->setPath(path); ui->listWidget->blockSignals(false); } +//--------------------------------------------------------------------------------------------------------------------- +QString DialogSplinePath::GetColor() const +{ + return GetComboBoxCurrentData(ui->comboBoxColor); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogSplinePath::SetColor(const QString &value) +{ + ChangeCurrentData(ui->comboBoxColor, value); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ChoosedObject gets id and type of selected object. Save right data and ignore wrong. @@ -362,5 +375,5 @@ void DialogSplinePath::SavePath() QListWidgetItem *item = ui->listWidget->item(i); path.append( qvariant_cast(item->data(Qt::UserRole))); } - path.setKCurve(ui->doubleSpinBoxKcurve->value()); + path.SetKCurve(ui->doubleSpinBoxKcurve->value()); } diff --git a/src/app/dialogs/tools/dialogsplinepath.h b/src/app/dialogs/tools/dialogsplinepath.h index 4316ddefd..d16cb0fd5 100644 --- a/src/app/dialogs/tools/dialogsplinepath.h +++ b/src/app/dialogs/tools/dialogsplinepath.h @@ -51,6 +51,9 @@ public: VSplinePath GetPath() const; void SetPath(const VSplinePath &value); + + QString GetColor() const; + void SetColor(const QString &value); public slots: virtual void ChosenObject(quint32 id, const SceneObject &type); void PointChanged(int row); diff --git a/src/app/dialogs/tools/dialogsplinepath.ui b/src/app/dialogs/tools/dialogsplinepath.ui index 44c1b3459..7c00882f6 100644 --- a/src/app/dialogs/tools/dialogsplinepath.ui +++ b/src/app/dialogs/tools/dialogsplinepath.ui @@ -6,8 +6,8 @@ 0 0 - 524 - 321 + 528 + 322 @@ -141,8 +141,11 @@ - - + + + QFormLayout::AllNonFixedFieldsGrow + + @@ -161,7 +164,7 @@ - + @@ -183,6 +186,16 @@ + + + + Color + + + + + + @@ -204,7 +217,6 @@ doubleSpinBoxKasm2 doubleSpinBoxAngle2 listWidget - doubleSpinBoxKcurve buttonBox diff --git a/src/app/dialogs/tools/dialogtool.cpp b/src/app/dialogs/tools/dialogtool.cpp index d02213a1b..4d664f2b8 100644 --- a/src/app/dialogs/tools/dialogtool.cpp +++ b/src/app/dialogs/tools/dialogtool.cpp @@ -67,7 +67,7 @@ DialogTool::DialogTool(const VContainer *data, const quint32 &toolId, QWidget *p radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr), radioButtonLengthCurve(nullptr), radioButtonAngleLine(nullptr), checkBoxHideEmpty(nullptr), okColor(QColor(76, 76, 76)), errorColor(Qt::red), associatedTool(nullptr), - toolId(toolId), prepare(false), pointName(QString()) + toolId(toolId), prepare(false), pointName(QString()), number(0) { SCASSERT(data != nullptr); timerFormula = new QTimer(this); @@ -302,12 +302,23 @@ void DialogTool::FillComboBoxTypeLine(QComboBox *box, const QMap } //--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getTypeLine return type of line - * @param box combobox - * @return type - */ -QString DialogTool::GetTypeLine(const QComboBox *box) const +void DialogTool::FillComboBoxLineColors(QComboBox *box) const +{ + SCASSERT(box != nullptr); + + const QMap map = VAbstractTool::ColorsList(); + QMap::const_iterator i = map.constBegin(); + while (i != map.constEnd()) + { + QPixmap pix(16, 16); + pix.fill(QColor(i.key())); + box->addItem(QIcon(pix), i.value(), QVariant(i.key())); + ++i; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogTool::GetComboBoxCurrentData(const QComboBox *box) const { SCASSERT(box != nullptr) QString value = box->currentData().toString(); @@ -318,29 +329,13 @@ QString DialogTool::GetTypeLine(const QComboBox *box) const return value; } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief SetupTypeLine setupe type of line - * @param box combobox - * @param value string from pattern file - */ -void DialogTool::SetupTypeLine(QComboBox *box, const QString &value) -{ - SCASSERT(box != nullptr) - const qint32 index = box->findData(value); - if (index != -1) - { - box->setCurrentIndex(index); - } -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief ChangeCurrentData select item in combobox by id * @param box combobox * @param value id of item */ -void DialogTool::ChangeCurrentData(QComboBox *box, const quint32 &value) const +void DialogTool::ChangeCurrentData(QComboBox *box, const QVariant &value) const { SCASSERT(box != nullptr) const qint32 index = box->findData(value); @@ -542,28 +537,29 @@ qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QSt } //--------------------------------------------------------------------------------------------------------------------- -void DialogTool::setCurrentPointId(QComboBox *box, quint32 &pointId, const quint32 &value) const +void DialogTool::setCurrentPointId(QComboBox *box, const quint32 &value) const { SCASSERT(box != nullptr); + + box->blockSignals(true); + FillComboBoxPoints(box); - pointId = value; ChangeCurrentData(box, value); + + box->blockSignals(false); } //--------------------------------------------------------------------------------------------------------------------- /** * @brief setCurrentSplineId set current spline id in combobox * @param box combobox - * @param splineId save current spline id * @param value spline id * @param cut if set to ComboMode::CutSpline don't show id+1 and id+2 */ -void DialogTool::setCurrentSplineId(QComboBox *box, quint32 &splineId, const quint32 &value, - ComboBoxCutSpline cut) const +void DialogTool::setCurrentSplineId(QComboBox *box, const quint32 &value, ComboBoxCutSpline cut) const { SCASSERT(box != nullptr); FillComboBoxSplines(box, cut); - splineId = value; ChangeCurrentData(box, value); } @@ -571,15 +567,13 @@ void DialogTool::setCurrentSplineId(QComboBox *box, quint32 &splineId, const qui /** * @brief setCurrentArcId * @param box combobox - * @param arcId save current arc id * @param value arc id * @param cut if set to ComboMode::CutArc don't show id+1 and id+2 */ -void DialogTool::setCurrentArcId(QComboBox *box, quint32 &arcId, const quint32 &value, ComboBoxCutArc cut) const +void DialogTool::setCurrentArcId(QComboBox *box, const quint32 &value, ComboBoxCutArc cut) const { SCASSERT(box != nullptr); FillComboBoxArcs(box, cut); - arcId = value; ChangeCurrentData(box, value); } @@ -587,25 +581,21 @@ void DialogTool::setCurrentArcId(QComboBox *box, quint32 &arcId, const quint32 & /** * @brief setCurrentSplinePathId set current splinePath id in combobox * @param box combobox - * @param splinePathId save current splinePath id * @param value splinePath id * @param cut if set to ComboMode::CutSpline don't show id+1 and id+2 */ -void DialogTool::setCurrentSplinePathId(QComboBox *box, quint32 &splinePathId, const quint32 &value, - ComboBoxCutSpline cut) const +void DialogTool::setCurrentSplinePathId(QComboBox *box, const quint32 &value, ComboBoxCutSpline cut) const { SCASSERT(box != nullptr); FillComboBoxSplinesPath(box, cut); - splinePathId = value; ChangeCurrentData(box, value); } //--------------------------------------------------------------------------------------------------------------------- -void DialogTool::setCurrentCurveId(QComboBox *box, quint32 &curveId, const quint32 &value) const +void DialogTool::setCurrentCurveId(QComboBox *box, const quint32 &value) const { SCASSERT(box != nullptr); FillComboBoxCurves(box); - curveId = value; ChangeCurrentData(box, value); } @@ -760,15 +750,6 @@ void DialogTool::ChangeColor(QWidget *widget, const QColor &color) widget->setPalette(palette); } -//--------------------------------------------------------------------------------------------------------------------- -void DialogTool::setPointId(QComboBox *box, quint32 &pointId, const quint32 &value) -{ - SCASSERT(box != nullptr); - box->blockSignals(true); - setCurrentPointId(box, pointId, value); - box->blockSignals(false); -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief DialogAccepted save data and emit signal about closed dialog. @@ -1147,6 +1128,12 @@ void DialogTool::SetToolId(const quint32 &value) toolId = value; } +//--------------------------------------------------------------------------------------------------------------------- +QString DialogTool::getPointName() const +{ + return pointName; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ShowVariable show variables in list diff --git a/src/app/dialogs/tools/dialogtool.h b/src/app/dialogs/tools/dialogtool.h index 7366a862e..8cd7cece1 100644 --- a/src/app/dialogs/tools/dialogtool.h +++ b/src/app/dialogs/tools/dialogtool.h @@ -69,6 +69,8 @@ public: quint32 GetToolId() const; void SetToolId(const quint32 &value); + + QString getPointName() const; signals: /** * @brief DialogClosed signal dialog closed @@ -207,8 +209,12 @@ protected: /** @brief pointName name of point */ QString pointName; + /** @brief number number of handled objects */ + qint32 number; + virtual void closeEvent ( QCloseEvent * event ); virtual void showEvent( QShowEvent *event ); + void FillComboBoxPoints(QComboBox *box)const; void FillComboBoxArcs(QComboBox *box, ComboBoxCutArc cut = ComboBoxCutArc::NoCutArc)const; void FillComboBoxSplines(QComboBox *box, ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline)const; @@ -216,26 +222,27 @@ protected: ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline)const; void FillComboBoxCurves(QComboBox *box)const; void FillComboBoxTypeLine(QComboBox *box, const QMap &stylesPics) const; + void FillComboBoxLineColors(QComboBox *box)const; + virtual void CheckState(); - QString GetTypeLine(const QComboBox *box)const; + QString GetComboBoxCurrentData(const QComboBox *box)const; template void ShowVariable(const QMap var); - void SetupTypeLine(QComboBox *box, const QString &value); - void ChangeCurrentData(QComboBox *box, const quint32 &value) const; + void ChangeCurrentData(QComboBox *box, const QVariant &value) const; void PutValHere(QLineEdit *lineEdit, QListWidget *listWidget); void PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidget); void ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer * timer); void ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer * timer); qreal Eval(const QString &text, bool &flag, QLabel *label, const QString &postfix, bool checkZero = true); - void setCurrentPointId(QComboBox *box, quint32 &pointId, const quint32 &value) const; - void setCurrentSplineId(QComboBox *box, quint32 &splineId, const quint32 &value, + void setCurrentPointId(QComboBox *box, const quint32 &value) const; + void setCurrentSplineId(QComboBox *box, const quint32 &value, ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline) const; - void setCurrentArcId(QComboBox *box, quint32 &arcId, const quint32 &value, + void setCurrentArcId(QComboBox *box, const quint32 &value, ComboBoxCutArc cut = ComboBoxCutArc::NoCutArc) const; - void setCurrentSplinePathId(QComboBox *box, quint32 &splinePathId, const quint32 &value, + void setCurrentSplinePathId(QComboBox *box, const quint32 &value, ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline) const; - void setCurrentCurveId(QComboBox *box, quint32 &curveId, const quint32 &value) const; + void setCurrentCurveId(QComboBox *box, const quint32 &value) const; quint32 getCurrentObjectId(QComboBox *box) const; bool SetObject(const quint32 &id, QComboBox *box, const QString &toolTip); void DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight); @@ -328,7 +335,6 @@ protected: } void ChangeColor(QWidget *widget, const QColor &color); - void setPointId(QComboBox *box, quint32 &pointId, const quint32 &value); virtual void ShowVisualization(){} /** * @brief SaveData Put dialog data in local variables diff --git a/src/app/dialogs/tools/dialogtriangle.cpp b/src/app/dialogs/tools/dialogtriangle.cpp index a0a21e7a3..ce88a6b80 100644 --- a/src/app/dialogs/tools/dialogtriangle.cpp +++ b/src/app/dialogs/tools/dialogtriangle.cpp @@ -41,8 +41,7 @@ * @param parent parent widget */ DialogTriangle::DialogTriangle(const VContainer *data, const quint32 &toolId, QWidget *parent) - :DialogTool(data, toolId, parent), ui(new Ui::DialogTriangle), number(0), axisP1Id(NULL_ID), - axisP2Id(NULL_ID), firstPointId(NULL_ID), secondPointId(NULL_ID), line (nullptr) + :DialogTool(data, toolId, parent), ui(new Ui::DialogTriangle), line (nullptr) { ui->setupUi(this); ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); @@ -161,15 +160,11 @@ void DialogTriangle::ChosenObject(quint32 id, const SceneObject &type) void DialogTriangle::SaveData() { pointName = ui->lineEditNamePoint->text(); - firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint); - secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint); - axisP1Id = getCurrentObjectId(ui->comboBoxAxisP1); - axisP2Id = getCurrentObjectId(ui->comboBoxAxisP2); - line->setPoint1Id(axisP1Id); - line->setPoint2Id(axisP2Id); - line->setHypotenuseP1Id(firstPointId); - line->setHypotenuseP2Id(secondPointId); + line->setPoint1Id(GetAxisP1Id()); + line->setPoint2Id(GetAxisP2Id()); + line->setHypotenuseP1Id(GetFirstPointId()); + line->setHypotenuseP2Id(GetSecondPointId()); line->RefreshGeometry(); } @@ -223,10 +218,10 @@ void DialogTriangle::ShowVisualization() //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setPointName set name of point + * @brief SetPointName set name of point * @param value name */ -void DialogTriangle::setPointName(const QString &value) +void DialogTriangle::SetPointName(const QString &value) { pointName = value; ui->lineEditNamePoint->setText(pointName); @@ -234,44 +229,84 @@ void DialogTriangle::setPointName(const QString &value) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setSecondPointId set id of second point + * @brief SetSecondPointId set id of second point * @param value id */ -void DialogTriangle::setSecondPointId(const quint32 &value) +void DialogTriangle::SetSecondPointId(const quint32 &value) { - setPointId(ui->comboBoxSecondPoint, secondPointId, value); - line->setHypotenuseP2Id(secondPointId); + setCurrentPointId(ui->comboBoxSecondPoint, value); + line->setHypotenuseP2Id(value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setFirstPointId set id of first point + * @brief SetFirstPointId set id of first point * @param value id */ -void DialogTriangle::setFirstPointId(const quint32 &value) +void DialogTriangle::SetFirstPointId(const quint32 &value) { - setPointId(ui->comboBoxFirstPoint, firstPointId, value); - line->setHypotenuseP1Id(firstPointId); + setCurrentPointId(ui->comboBoxFirstPoint, value); + line->setHypotenuseP1Id(value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setAxisP2Id set id second point of axis + * @brief SetAxisP2Id set id second point of axis * @param value id */ -void DialogTriangle::setAxisP2Id(const quint32 &value) +void DialogTriangle::SetAxisP2Id(const quint32 &value) { - setPointId(ui->comboBoxAxisP2, axisP2Id, value); - line->setPoint2Id(axisP2Id); + setCurrentPointId(ui->comboBoxAxisP2, value); + line->setPoint2Id(value); } //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setAxisP1Id set id first point of axis + * @brief SetAxisP1Id set id first point of axis * @param value id */ -void DialogTriangle::setAxisP1Id(const quint32 &value) +void DialogTriangle::SetAxisP1Id(const quint32 &value) { - setPointId(ui->comboBoxAxisP1, axisP1Id, value); - line->setPoint1Id(axisP1Id); + setCurrentPointId(ui->comboBoxAxisP1, value); + line->setPoint1Id(value); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetAxisP1Id return id first point of axis + * @return id + */ +quint32 DialogTriangle::GetAxisP1Id() const +{ + return getCurrentObjectId(ui->comboBoxAxisP1); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetAxisP2Id return id second point of axis + * @return id + */ +quint32 DialogTriangle::GetAxisP2Id() const +{ + return getCurrentObjectId(ui->comboBoxAxisP2); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetFirstPointId return id of first point + * @return id + */ +quint32 DialogTriangle::GetFirstPointId() const +{ + return getCurrentObjectId(ui->comboBoxFirstPoint); +} + +//--------------------------------------------------------------------------------------------------------------------- +/** + * @brief GetSecondPointId return id of second point + * @return id + */ +quint32 DialogTriangle::GetSecondPointId() const +{ + return getCurrentObjectId(ui->comboBoxSecondPoint); } diff --git a/src/app/dialogs/tools/dialogtriangle.h b/src/app/dialogs/tools/dialogtriangle.h index 9ca29765c..e4d3d3236 100644 --- a/src/app/dialogs/tools/dialogtriangle.h +++ b/src/app/dialogs/tools/dialogtriangle.h @@ -48,20 +48,19 @@ public: DialogTriangle(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); ~DialogTriangle(); - quint32 getAxisP1Id() const; - void setAxisP1Id(const quint32 &value); + quint32 GetAxisP1Id() const; + void SetAxisP1Id(const quint32 &value); - quint32 getAxisP2Id() const; - void setAxisP2Id(const quint32 &value); + quint32 GetAxisP2Id() const; + void SetAxisP2Id(const quint32 &value); - quint32 getFirstPointId() const; - void setFirstPointId(const quint32 &value); + quint32 GetFirstPointId() const; + void SetFirstPointId(const quint32 &value); - quint32 getSecondPointId() const; - void setSecondPointId(const quint32 &value); + quint32 GetSecondPointId() const; + void SetSecondPointId(const quint32 &value); - QString getPointName() const; - void setPointName(const QString &value); + void SetPointName(const QString &value); public slots: virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void PointNameChanged(); @@ -78,72 +77,7 @@ private: /** @brief ui keeps information about user interface */ Ui::DialogTriangle *ui; - /** @brief number number of handled objects */ - qint32 number; - - /** @brief axisP1Id id first point of axis */ - quint32 axisP1Id; - - /** @brief axisP2Id id second point of axis */ - quint32 axisP2Id; - - /** @brief firstPointId id first point of line */ - quint32 firstPointId; - - /** @brief secondPointId id second point of line */ - quint32 secondPointId; - VisToolTriangle *line; }; -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getAxisP1Id return id first point of axis - * @return id - */ -inline quint32 DialogTriangle::getAxisP1Id() const -{ - return axisP1Id; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getAxisP2Id return id second point of axis - * @return id - */ -inline quint32 DialogTriangle::getAxisP2Id() const -{ - return axisP2Id; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getFirstPointId return id of first point - * @return id - */ -inline quint32 DialogTriangle::getFirstPointId() const -{ - return firstPointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getSecondPointId return id of second point - * @return id - */ -inline quint32 DialogTriangle::getSecondPointId() const -{ - return secondPointId; -} - -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief getPointName return name of point - * @return name - */ -inline QString DialogTriangle::getPointName() const -{ - return pointName; -} - #endif // DIALOGTRIANGLE_H diff --git a/src/app/geometry/varc.cpp b/src/app/geometry/varc.cpp index 2f9c434b8..c407012a3 100644 --- a/src/app/geometry/varc.cpp +++ b/src/app/geometry/varc.cpp @@ -255,7 +255,7 @@ QString VArc::GetFormulaF1() const //--------------------------------------------------------------------------------------------------------------------- void VArc::SetFormulaF1(const VFormula &value) { - d->formulaF1 = value.getFormula(FormulaType::FromUser); + d->formulaF1 = value.GetFormula(FormulaType::FromUser); d->f1 = value.getDoubleValue(); } @@ -282,7 +282,7 @@ QString VArc::GetFormulaF2() const //--------------------------------------------------------------------------------------------------------------------- void VArc::SetFormulaF2(const VFormula &value) { - d->formulaF2 = value.getFormula(FormulaType::FromUser); + d->formulaF2 = value.GetFormula(FormulaType::FromUser); d->f2 = value.getDoubleValue(); } @@ -309,7 +309,7 @@ QString VArc::GetFormulaRadius() const //--------------------------------------------------------------------------------------------------------------------- void VArc::SetFormulaRadius(const VFormula &value) { - d->formulaRadius = value.getFormula(FormulaType::FromUser); + d->formulaRadius = value.GetFormula(FormulaType::FromUser); d->radius = value.getDoubleValue(); } diff --git a/src/app/geometry/vsplinepath.cpp b/src/app/geometry/vsplinepath.cpp index 832b313d2..068c910cb 100644 --- a/src/app/geometry/vsplinepath.cpp +++ b/src/app/geometry/vsplinepath.cpp @@ -255,13 +255,13 @@ void VSplinePath::Clear() } //--------------------------------------------------------------------------------------------------------------------- -qreal VSplinePath::getKCurve() const +qreal VSplinePath::GetKCurve() const { return d->kCurve; } //--------------------------------------------------------------------------------------------------------------------- -void VSplinePath::setKCurve(const qreal &value) +void VSplinePath::SetKCurve(const qreal &value) { if (value > 0) { diff --git a/src/app/geometry/vsplinepath.h b/src/app/geometry/vsplinepath.h index e562be232..b3de10941 100644 --- a/src/app/geometry/vsplinepath.h +++ b/src/app/geometry/vsplinepath.h @@ -118,15 +118,15 @@ public: */ void Clear(); /** - * @brief getKCurve return coefficient of curvature spline path. + * @brief GetKCurve return coefficient of curvature spline path. * @return coefficient of curvature spline. */ - qreal getKCurve() const; + qreal GetKCurve() const; /** - * @brief setKCurve set coefficient of curvature spline path. + * @brief SetKCurve set coefficient of curvature spline path. * @param value coefficient of curvature spline path. */ - void setKCurve(const qreal &value); + void SetKCurve(const qreal &value); /** * @brief GetPoint pointer to list spline point. * @return list. @@ -160,8 +160,8 @@ public: * * VSplinePoint splP1 = splPath->at(p1); * VSplinePoint splP2 = splPath->at(p2); - * VSpline spl1 = VSpline(splP1.P(), spl1p2, spl1p3, *p, splPath->getKCurve()); - * VSpline spl2 = VSpline(*p, spl2p2, spl2p3, splP2.P(), splPath->getKCurve()); + * VSpline spl1 = VSpline(splP1.P(), spl1p2, spl1p3, *p, splPath->GetKCurve()); + * VSpline spl2 = VSpline(*p, spl2p2, spl2p3, splP2.P(), splPath->GetKCurve()); * @param length length first spline path. * @param p1 index first spline point in list. * @param p2 index second spline point in list. diff --git a/src/app/tools/drawTools/vabstractspline.cpp b/src/app/tools/drawTools/vabstractspline.cpp index aa6efbe7e..f0d04dcab 100644 --- a/src/app/tools/drawTools/vabstractspline.cpp +++ b/src/app/tools/drawTools/vabstractspline.cpp @@ -68,13 +68,18 @@ QString VAbstractSpline::getTagName() const */ void VAbstractSpline::FullUpdateFromFile() { + ReadAttributes(); RefreshGeometry(); } //--------------------------------------------------------------------------------------------------------------------- void VAbstractSpline::Disable(bool disable) { - DisableItem(this, disable); + enabled = !disable; + this->setEnabled(enabled); + this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthMainLine())/factor, Qt::SolidLine, + Qt::RoundCap)); + emit setEnabledPoint(enabled); } //--------------------------------------------------------------------------------------------------------------------- @@ -84,23 +89,18 @@ void VAbstractSpline::Disable(bool disable) */ void VAbstractSpline::ChangedActivDraw(const QString &newName) { - VDrawTool::ChangedActivDraw(newName); - const bool selectable = (nameActivDraw == newName); - this->setEnabled(selectable); - this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); - emit setEnabledPoint(selectable); + Disable(!(nameActivDraw == newName)); } //--------------------------------------------------------------------------------------------------------------------- /** * @brief ShowTool highlight tool. * @param id object id in container - * @param color highlight color. * @param enable enable or disable highlight. */ -void VAbstractSpline::ShowTool(quint32 id, Qt::GlobalColor color, bool enable) +void VAbstractSpline::ShowTool(quint32 id, bool enable) { - ShowItem(this, id, color, enable); + ShowItem(this, id, enable); } //--------------------------------------------------------------------------------------------------------------------- @@ -123,7 +123,8 @@ void VAbstractSpline::SetFactor(qreal factor) void VAbstractSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/factor, Qt::SolidLine, Qt::RoundCap)); + this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthMainLine())/factor, Qt::SolidLine, + Qt::RoundCap)); this->setPath(ToolPath(PathDirection::Show)); isHovered = true; QGraphicsPathItem::hoverEnterEvent(event); @@ -138,7 +139,7 @@ void VAbstractSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void VAbstractSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); + this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor)); this->setPath(ToolPath()); isHovered = false; QGraphicsPathItem::hoverLeaveEvent(event); @@ -211,6 +212,12 @@ QPainterPath VAbstractSpline::ToolPath(PathDirection direction) const return path; } +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractSpline::ReadToolAttributes(const QDomElement &domElement) +{ + lineColor = doc->GetParametrString(domElement, AttrColor, ColorBlack); +} + //--------------------------------------------------------------------------------------------------------------------- void VAbstractSpline::ShowFoot(bool show) { @@ -219,3 +226,17 @@ void VAbstractSpline::ShowFoot(bool show) controlPoints.at(i)->setVisible(show); } } + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractSpline::setEnabled(bool enabled) +{ + QGraphicsPathItem::setEnabled(enabled); + if (enabled) + { + setPen(QPen(QColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor)); + } + else + { + setPen(QPen(Qt::gray, qApp->toPixel(qApp->widthHairLine())/factor)); + } +} diff --git a/src/app/tools/drawTools/vabstractspline.h b/src/app/tools/drawTools/vabstractspline.h index 2c39f033f..f9b314b73 100644 --- a/src/app/tools/drawTools/vabstractspline.h +++ b/src/app/tools/drawTools/vabstractspline.h @@ -45,6 +45,9 @@ public: enum { Type = UserType + static_cast(Tool::AbstractSpline)}; virtual QString getTagName() const; void ShowFoot(bool show); + + void setEnabled(bool enabled); + public slots: virtual void FullUpdateFromFile (); void Disable(bool disable); @@ -75,7 +78,7 @@ protected: */ virtual void RefreshGeometry ()=0; virtual void ChangedActivDraw ( const QString &newName ); - virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); + virtual void ShowTool(quint32 id, bool enable); virtual void SetFactor(qreal factor); virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); @@ -83,6 +86,7 @@ protected: virtual void keyReleaseEvent(QKeyEvent * event); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); QPainterPath ToolPath(PathDirection direction = PathDirection::Hide) const; + virtual void ReadToolAttributes(const QDomElement &domElement); private: Q_DISABLE_COPY(VAbstractSpline) }; diff --git a/src/app/tools/drawTools/vdrawtool.cpp b/src/app/tools/drawTools/vdrawtool.cpp index 0902db7ba..597399843 100644 --- a/src/app/tools/drawTools/vdrawtool.cpp +++ b/src/app/tools/drawTools/vdrawtool.cpp @@ -46,8 +46,8 @@ qreal VDrawTool::factor = 1; * @param id object id in container. */ VDrawTool::VDrawTool(VPattern *doc, VContainer *data, quint32 id, QObject *parent) - :VAbstractTool(doc, data, id, parent), ignoreFullUpdate(false), - nameActivDraw(doc->GetNameActivPP()), dialog(nullptr) + :VAbstractTool(doc, data, id, parent), ignoreFullUpdate(false), nameActivDraw(doc->GetNameActivPP()), + dialog(nullptr), typeLine(TypeLineLine), lineColor(ColorBlack), enabled(true) { connect(this->doc, &VPattern::ChangedActivPP, this, &VDrawTool::ChangedActivDraw); connect(this->doc, &VPattern::ChangedNameDraw, this, &VDrawTool::ChangedNameDraw); @@ -64,33 +64,14 @@ VDrawTool::~VDrawTool() /** * @brief ShowTool highlight tool. * @param id object id in container. - * @param color highlight color. * @param enable enable or disable highlight. */ -void VDrawTool::ShowTool(quint32 id, Qt::GlobalColor color, bool enable) +void VDrawTool::ShowTool(quint32 id, bool enable) { Q_UNUSED(id); - Q_UNUSED(color); Q_UNUSED(enable); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. - * @param newName new name active pattern peace. name new active pattern peace. - */ -void VDrawTool::ChangedActivDraw(const QString &newName) -{ - if (nameActivDraw == newName) - { - currentColor = baseColor; - } - else - { - currentColor = Qt::gray; - } -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief ChangedNameDraw save new name active pattern peace. @@ -175,7 +156,34 @@ void VDrawTool::RefreshDataInFile() } else { - qDebug()<<"Can't find tool with id ="<< id << Q_FUNC_INFO; + qCDebug(vTool)<<"Can't find tool with id ="<< id << Q_FUNC_INFO; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +QColor VDrawTool::CorrectColor(const QColor &color) const +{ + if (enabled) + { + return color; + } + else + { + return Qt::gray; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDrawTool::ReadAttributes() +{ + const QDomElement domElement = doc->elementById(QString().setNum(id)); + if (domElement.isElement()) + { + ReadToolAttributes(domElement); + } + else + { + qCDebug(vTool)<<"Can't find tool with id ="<< id << Q_FUNC_INFO; } } @@ -241,10 +249,10 @@ qreal VDrawTool::CheckFormula(const quint32 &toolId, QString &formula, VContaine { DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, qApp->getMainWindow()); dialog->setWindowTitle(tr("Edit wrong formula")); - dialog->setFormula(formula); + dialog->SetFormula(formula); if (dialog->exec() == QDialog::Accepted) { - formula = dialog->getFormula(); + formula = dialog->GetFormula(); /* Need delete dialog here because parser in dialog don't allow use correct separator for parsing * here. */ delete dialog; @@ -285,3 +293,34 @@ void VDrawTool::AddToCalculation(const QDomElement &domElement) connect(addToCal, &AddToCalc::NeedFullParsing, doc, &VPattern::NeedFullParsing); qApp->getUndoStack()->push(addToCal); } + +//--------------------------------------------------------------------------------------------------------------------- +QString VDrawTool::getLineType() const +{ + return typeLine; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VDrawTool::SetTypeLine(const QString &value) +{ + typeLine = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString VDrawTool::GetLineColor() const +{ + return lineColor; +} + + +//--------------------------------------------------------------------------------------------------------------------- +void VDrawTool::SetLineColor(const QString &value) +{ + lineColor = value; + + QSharedPointer obj = VAbstractTool::data.GetGObject(id); + SaveOption(obj); +} diff --git a/src/app/tools/drawTools/vdrawtool.h b/src/app/tools/drawTools/vdrawtool.h index 14044c766..021387e20 100644 --- a/src/app/tools/drawTools/vdrawtool.h +++ b/src/app/tools/drawTools/vdrawtool.h @@ -55,9 +55,16 @@ public: virtual void setDialog() {} virtual void DialogLinkDestroy(); static qreal CheckFormula(const quint32 &toolId, QString &formula, VContainer *data); + + QString getLineType() const; + virtual void SetTypeLine(const QString &value); + + QString GetLineColor() const; + virtual void SetLineColor(const QString &value); + public slots: - virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); - virtual void ChangedActivDraw(const QString &newName); + virtual void ShowTool(quint32 id, bool enable); + virtual void ChangedActivDraw(const QString &newName) = 0; void ChangedNameDraw(const QString &oldName, const QString &newName); virtual void FullUpdateFromGuiOk(int result); virtual void FullUpdateFromGuiApply(); @@ -71,7 +78,15 @@ protected: QString nameActivDraw; /** @brief dialog dialog options.*/ - DialogTool *dialog; + DialogTool *dialog; + + /** @brief typeLine line type. */ + QString typeLine; + + /** @brief lineColor color line or curve, but not a point. */ + QString lineColor; + + bool enabled; void AddToCalculation(const QDomElement &domElement); @@ -80,6 +95,10 @@ protected: void SaveDialogChange(); virtual void AddToFile(); virtual void RefreshDataInFile(); + QColor CorrectColor(const QColor &color) const; + + void ReadAttributes(); + virtual void ReadToolAttributes(const QDomElement &domElement)=0; template /** @@ -142,39 +161,16 @@ protected: * @brief ShowItem highlight tool. * @param item tool. * @param id object id in container. - * @param color highlight color. * @param enable enable or disable highlight. */ - void ShowItem(Item *item, quint32 id, Qt::GlobalColor color, bool enable) + void ShowItem(Item *item, quint32 id, bool enable) { SCASSERT(item != nullptr); if (id == item->id) { - if (enable == false) - { - currentColor = baseColor; - } - else - { - currentColor = color; - } - item->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); + ShowVisualization(enable); } } - template - void DisableItem(Item *item, bool disable) - { - SCASSERT(item != nullptr); - if (disable) - { - currentColor = Qt::gray; - } - else - { - currentColor = baseColor; - } - item->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); - } private: Q_DISABLE_COPY(VDrawTool) }; diff --git a/src/app/tools/drawTools/vtoolalongline.cpp b/src/app/tools/drawTools/vtoolalongline.cpp index 442e8d69a..61020f9ea 100644 --- a/src/app/tools/drawTools/vtoolalongline.cpp +++ b/src/app/tools/drawTools/vtoolalongline.cpp @@ -50,9 +50,9 @@ const QString VToolAlongLine::ToolType = QStringLiteral("alongLine"); */ VToolAlongLine::VToolAlongLine(VPattern *doc, VContainer *data, quint32 id, const QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, - const QString &typeLine, const Source &typeCreation, + const QString &typeLine, const QString &lineColor, const Source &typeCreation, QGraphicsItem *parent) - :VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, 0, parent), secondPointId(secondPointId) + :VToolLinePoint(doc, data, id, typeLine, lineColor, formula, firstPointId, 0, parent), secondPointId(secondPointId) { if (typeCreation == Source::FromGui) @@ -71,14 +71,7 @@ VToolAlongLine::VToolAlongLine(VPattern *doc, VContainer *data, quint32 id, cons */ void VToolAlongLine::FullUpdateFromFile() { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - typeLine = domElement.attribute(AttrTypeLine, ""); - formulaLength = domElement.attribute(AttrLength, ""); - basePointId = domElement.attribute(AttrFirstPoint, "").toUInt(); - secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt(); - } + ReadAttributes(); RefreshGeometry(); if (vis != nullptr) @@ -144,10 +137,11 @@ void VToolAlongLine::SaveDialog(QDomElement &domElement) DialogAlongLine *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); - doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); - doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); - doc->SetAttribute(domElement, AttrFirstPoint, dialogTool->getFirstPointId()); - doc->SetAttribute(domElement, AttrSecondPoint, dialogTool->getSecondPointId()); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); + doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); + doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); + doc->SetAttribute(domElement, AttrFirstPoint, dialogTool->GetFirstPointId()); + doc->SetAttribute(domElement, AttrSecondPoint, dialogTool->GetSecondPointId()); } //--------------------------------------------------------------------------------------------------------------------- @@ -163,19 +157,30 @@ void VToolAlongLine::SaveOptions(QDomElement &tag, QSharedPointer &obj doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrTypeLine, typeLine); + doc->SetAttribute(tag, AttrLineColor, lineColor); doc->SetAttribute(tag, AttrLength, formulaLength); doc->SetAttribute(tag, AttrFirstPoint, basePointId); doc->SetAttribute(tag, AttrSecondPoint, secondPointId); } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolAlongLine::getSecondPointId() const +void VToolAlongLine::ReadToolAttributes(const QDomElement &domElement) +{ + typeLine = doc->GetParametrString(domElement, AttrTypeLine, TypeLineLine); + lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack); + formulaLength = doc->GetParametrString(domElement, AttrLength, ""); + basePointId = doc->GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR); + secondPointId = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolAlongLine::GetSecondPointId() const { return secondPointId; } //--------------------------------------------------------------------------------------------------------------------- -void VToolAlongLine::setSecondPointId(const quint32 &value) +void VToolAlongLine::SetSecondPointId(const quint32 &value) { if (value != NULL_ID) { @@ -231,11 +236,12 @@ void VToolAlongLine::setDialog() DialogAlongLine *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); const QSharedPointer p = VAbstractTool::data.GeometricObject(id); - dialogTool->setTypeLine(typeLine); - dialogTool->setFormula(formulaLength); - dialogTool->setFirstPointId(basePointId); - dialogTool->setSecondPointId(secondPointId); - dialogTool->setPointName(p->name()); + dialogTool->SetTypeLine(typeLine); + dialogTool->SetLineColor(lineColor); + dialogTool->SetFormula(formulaLength); + dialogTool->SetFirstPointId(basePointId); + dialogTool->SetSecondPointId(secondPointId); + dialogTool->SetPointName(p->name()); } //--------------------------------------------------------------------------------------------------------------------- @@ -251,14 +257,15 @@ VToolAlongLine* VToolAlongLine::Create(DialogTool *dialog, VMainGraphicsScene *s SCASSERT(dialog != nullptr); DialogAlongLine *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - QString formula = dialogTool->getFormula(); - const quint32 firstPointId = dialogTool->getFirstPointId(); - const quint32 secondPointId = dialogTool->getSecondPointId(); - const QString typeLine = dialogTool->getTypeLine(); + QString formula = dialogTool->GetFormula(); + const quint32 firstPointId = dialogTool->GetFirstPointId(); + const quint32 secondPointId = dialogTool->GetSecondPointId(); + const QString typeLine = dialogTool->GetTypeLine(); + const QString lineColor = dialogTool->GetLineColor(); const QString pointName = dialogTool->getPointName(); VToolAlongLine *point=nullptr; - point = Create(0, pointName, typeLine, formula, firstPointId, secondPointId, 5, 10, scene, doc, data, - Document::FullParse, Source::FromGui); + point = Create(0, pointName, typeLine, lineColor, formula, firstPointId, secondPointId, 5, 10, scene, doc, data, + Document::FullParse, Source::FromGui); if (point != nullptr) { point->dialog=dialogTool; @@ -284,9 +291,10 @@ VToolAlongLine* VToolAlongLine::Create(DialogTool *dialog, VMainGraphicsScene *s * @param typeCreation way we create this tool. */ VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine, - QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document &parse, const Source &typeCreation) + const QString &lineColor, QString &formula, const quint32 &firstPointId, + const quint32 &secondPointId, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation) { const QSharedPointer firstPoint = data->GeometricObject(firstPointId); const QSharedPointer secondPoint = data->GeometricObject(secondPointId); @@ -314,8 +322,8 @@ VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointNa VDrawTool::AddRecord(id, Tool::AlongLine, doc); if (parse == Document::FullParse) { - VToolAlongLine *point = new VToolAlongLine(doc, data, id, formula, firstPointId, - secondPointId, typeLine, typeCreation); + VToolAlongLine *point = new VToolAlongLine(doc, data, id, formula, firstPointId, secondPointId, typeLine, + lineColor, typeCreation); scene->addItem(point); connect(point, &VToolAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolAlongLine::SetFactor); diff --git a/src/app/tools/drawTools/vtoolalongline.h b/src/app/tools/drawTools/vtoolalongline.h index 09b44ef31..f3b860cd1 100644 --- a/src/app/tools/drawTools/vtoolalongline.h +++ b/src/app/tools/drawTools/vtoolalongline.h @@ -40,20 +40,21 @@ class VToolAlongLine : public VToolLinePoint public: VToolAlongLine(VPattern *doc, VContainer *data, quint32 id, const QString &formula, const quint32 &firstPointId, - const quint32 &secondPointId, const QString &typeLine, const Source &typeCreation, - QGraphicsItem * parent = nullptr); + const quint32 &secondPointId, const QString &typeLine, const QString &lineColor, + const Source &typeCreation, QGraphicsItem * parent = nullptr); virtual void setDialog(); static VToolAlongLine* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolAlongLine* Create(const quint32 _id, const QString &pointName, const QString &typeLine, - QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document &parse, const Source &typeCreation); + const QString &lineColor, QString &formula, const quint32 &firstPointId, + const quint32 &secondPointId, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation); static const QString ToolType; virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::AlongLine)}; - quint32 getSecondPointId() const; - void setSecondPointId(const quint32 &value); + quint32 GetSecondPointId() const; + void SetSecondPointId(const quint32 &value); virtual void ShowVisualization(bool show); public slots: virtual void FullUpdateFromFile(); @@ -64,6 +65,7 @@ protected: virtual void RemoveReferens(); virtual void SaveDialog(QDomElement &domElement); virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); + virtual void ReadToolAttributes(const QDomElement &domElement); private: /** @brief secondPointId id second point of line. */ quint32 secondPointId; diff --git a/src/app/tools/drawTools/vtoolarc.cpp b/src/app/tools/drawTools/vtoolarc.cpp index 5e245d2e3..332006ebc 100644 --- a/src/app/tools/drawTools/vtoolarc.cpp +++ b/src/app/tools/drawTools/vtoolarc.cpp @@ -47,10 +47,12 @@ const QString VToolArc::ToolType = QStringLiteral("simple"); * @param typeCreation way we create this tool. * @param parent parent object */ -VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, QGraphicsItem *parent) +VToolArc::VToolArc(VPattern *doc, VContainer *data, quint32 id, const QString &color, const Source &typeCreation, + QGraphicsItem *parent) :VAbstractSpline(doc, data, id, parent) { sceneType = SceneObject::Arc; + lineColor = color; this->setPath(ToolPath()); this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor)); @@ -82,6 +84,7 @@ void VToolArc::setDialog() dialogTool->SetF1(arc->GetFormulaF1()); dialogTool->SetF2(arc->GetFormulaF2()); dialogTool->SetRadius(arc->GetFormulaRadius()); + dialogTool->SetColor(lineColor); } //--------------------------------------------------------------------------------------------------------------------- @@ -101,8 +104,9 @@ VToolArc* VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPatte QString radius = dialogTool->GetRadius(); QString f1 = dialogTool->GetF1(); QString f2 = dialogTool->GetF2(); + const QString color = dialogTool->GetColor(); VToolArc* point = nullptr; - point=Create(0, center, radius, f1, f2, scene, doc, data, Document::FullParse, Source::FromGui); + point=Create(0, center, radius, f1, f2, color, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { point->dialog=dialogTool; @@ -125,8 +129,8 @@ VToolArc* VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPatte * @param typeCreation way we create this tool. */ VToolArc* VToolArc::Create(const quint32 _id, const quint32 ¢er, QString &radius, QString &f1, QString &f2, - VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, - const Source &typeCreation) + const QString &color, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation) { qreal calcRadius = 0, calcF1 = 0, calcF2 = 0; @@ -155,7 +159,7 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 ¢er, QString &ra VDrawTool::AddRecord(id, Tool::Arc, doc); if (parse == Document::FullParse) { - VToolArc *toolArc = new VToolArc(doc, data, id, typeCreation); + VToolArc *toolArc = new VToolArc(doc, data, id, color, typeCreation); scene->addItem(toolArc); connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(scene, &VMainGraphicsScene::NewFactor, toolArc, &VToolArc::SetFactor); @@ -197,7 +201,7 @@ void VToolArc::setCenter(const quint32 &value) } //--------------------------------------------------------------------------------------------------------------------- -VFormula VToolArc::getFormulaRadius() const +VFormula VToolArc::GetFormulaRadius() const { QSharedPointer arc = VAbstractTool::data.GeometricObject(id); SCASSERT(arc.isNull() == false); @@ -210,7 +214,7 @@ VFormula VToolArc::getFormulaRadius() const } //--------------------------------------------------------------------------------------------------------------------- -void VToolArc::setFormulaRadius(const VFormula &value) +void VToolArc::SetFormulaRadius(const VFormula &value) { if (value.error() == false) { @@ -225,7 +229,7 @@ void VToolArc::setFormulaRadius(const VFormula &value) } //--------------------------------------------------------------------------------------------------------------------- -VFormula VToolArc::getFormulaF1() const +VFormula VToolArc::GetFormulaF1() const { QSharedPointer arc = VAbstractTool::data.GeometricObject(id); SCASSERT(arc.isNull() == false); @@ -238,7 +242,7 @@ VFormula VToolArc::getFormulaF1() const } //--------------------------------------------------------------------------------------------------------------------- -void VToolArc::setFormulaF1(const VFormula &value) +void VToolArc::SetFormulaF1(const VFormula &value) { if (value.error() == false) { @@ -254,7 +258,7 @@ void VToolArc::setFormulaF1(const VFormula &value) } //--------------------------------------------------------------------------------------------------------------------- -VFormula VToolArc::getFormulaF2() const +VFormula VToolArc::GetFormulaF2() const { QSharedPointer arc = VAbstractTool::data.GeometricObject(id); SCASSERT(arc.isNull() == false); @@ -267,7 +271,7 @@ VFormula VToolArc::getFormulaF2() const } //--------------------------------------------------------------------------------------------------------------------- -void VToolArc::setFormulaF2(const VFormula &value) +void VToolArc::SetFormulaF2(const VFormula &value) { if (value.error() == false) { @@ -351,6 +355,7 @@ void VToolArc::SaveDialog(QDomElement &domElement) doc->SetAttribute(domElement, AttrRadius, dialogTool->GetRadius()); doc->SetAttribute(domElement, AttrAngle1, dialogTool->GetF1()); doc->SetAttribute(domElement, AttrAngle2, dialogTool->GetF2()); + doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor()); } //--------------------------------------------------------------------------------------------------------------------- @@ -365,6 +370,7 @@ void VToolArc::SaveOptions(QDomElement &tag, QSharedPointer &obj) doc->SetAttribute(tag, AttrRadius, arc->GetFormulaRadius()); doc->SetAttribute(tag, AttrAngle1, arc->GetFormulaF1()); doc->SetAttribute(tag, AttrAngle2, arc->GetFormulaF2()); + doc->SetAttribute(tag, AttrColor, lineColor); } //--------------------------------------------------------------------------------------------------------------------- @@ -373,7 +379,7 @@ void VToolArc::SaveOptions(QDomElement &tag, QSharedPointer &obj) */ void VToolArc::RefreshGeometry() { - this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); + this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor)); this->setPath(ToolPath()); if (vis != nullptr) diff --git a/src/app/tools/drawTools/vtoolarc.h b/src/app/tools/drawTools/vtoolarc.h index b8264694b..fa4e291b4 100644 --- a/src/app/tools/drawTools/vtoolarc.h +++ b/src/app/tools/drawTools/vtoolarc.h @@ -40,12 +40,13 @@ class VToolArc :public VAbstractSpline { Q_OBJECT public: - VToolArc(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, QGraphicsItem * parent = nullptr); + VToolArc(VPattern *doc, VContainer *data, quint32 id, const QString &color, const Source &typeCreation, + QGraphicsItem * parent = nullptr); virtual void setDialog(); static VToolArc* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolArc* Create(const quint32 _id, const quint32 ¢er, QString &radius, QString &f1, QString &f2, - VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, - const Source &typeCreation); + const QString &color, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation); static const QString TagName; static const QString ToolType; virtual int type() const {return Type;} @@ -55,14 +56,14 @@ public: quint32 getCenter() const; void setCenter(const quint32 &value); - VFormula getFormulaRadius() const; - void setFormulaRadius(const VFormula &value); + VFormula GetFormulaRadius() const; + void SetFormulaRadius(const VFormula &value); - VFormula getFormulaF1() const; - void setFormulaF1(const VFormula &value); + VFormula GetFormulaF1() const; + void SetFormulaF1(const VFormula &value); - VFormula getFormulaF2() const; - void setFormulaF2(const VFormula &value); + VFormula GetFormulaF2() const; + void SetFormulaF2(const VFormula &value); virtual void ShowVisualization(bool show); protected: diff --git a/src/app/tools/drawTools/vtoolbisector.cpp b/src/app/tools/drawTools/vtoolbisector.cpp index 96b42eadc..e3bb1b9ee 100644 --- a/src/app/tools/drawTools/vtoolbisector.cpp +++ b/src/app/tools/drawTools/vtoolbisector.cpp @@ -49,9 +49,10 @@ const QString VToolBisector::ToolType = QStringLiteral("bisector"); * @param parent parent object. */ VToolBisector::VToolBisector(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, - const QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, - const quint32 &thirdPointId, const Source &typeCreation, QGraphicsItem *parent) - :VToolLinePoint(doc, data, id, typeLine, formula, secondPointId, 0, parent), firstPointId(NULL_ID), + const QString &lineColor, const QString &formula, const quint32 &firstPointId, + const quint32 &secondPointId, const quint32 &thirdPointId, const Source &typeCreation, + QGraphicsItem *parent) + :VToolLinePoint(doc, data, id, typeLine, lineColor, formula, secondPointId, 0, parent), firstPointId(NULL_ID), thirdPointId(NULL_ID) { this->firstPointId = firstPointId; @@ -112,12 +113,13 @@ void VToolBisector::setDialog() DialogBisector *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); const QSharedPointer p = VAbstractTool::data.GeometricObject(id); - dialogTool->setTypeLine(typeLine); - dialogTool->setFormula(formulaLength); - dialogTool->setFirstPointId(firstPointId); - dialogTool->setSecondPointId(basePointId); - dialogTool->setThirdPointId(thirdPointId); - dialogTool->setPointName(p->name()); + dialogTool->SetTypeLine(typeLine); + dialogTool->SetLineColor(lineColor); + dialogTool->SetFormula(formulaLength); + dialogTool->SetFirstPointId(firstPointId); + dialogTool->SetSecondPointId(basePointId); + dialogTool->SetThirdPointId(thirdPointId); + dialogTool->SetPointName(p->name()); } //--------------------------------------------------------------------------------------------------------------------- @@ -134,15 +136,16 @@ VToolBisector* VToolBisector::Create(DialogTool *dialog, VMainGraphicsScene *sce SCASSERT(dialog != nullptr); DialogBisector *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - QString formula = dialogTool->getFormula(); - const quint32 firstPointId = dialogTool->getFirstPointId(); - const quint32 secondPointId = dialogTool->getSecondPointId(); - const quint32 thirdPointId = dialogTool->getThirdPointId(); - const QString typeLine = dialogTool->getTypeLine(); + QString formula = dialogTool->GetFormula(); + const quint32 firstPointId = dialogTool->GetFirstPointId(); + const quint32 secondPointId = dialogTool->GetSecondPointId(); + const quint32 thirdPointId = dialogTool->GetThirdPointId(); + const QString typeLine = dialogTool->GetTypeLine(); + const QString lineColor = dialogTool->GetLineColor(); const QString pointName = dialogTool->getPointName(); VToolBisector *point = nullptr; - point=Create(0, formula, firstPointId, secondPointId, thirdPointId, typeLine, pointName, 5, 10, scene, doc, data, - Document::FullParse, Source::FromGui); + point=Create(0, formula, firstPointId, secondPointId, thirdPointId, typeLine, lineColor, pointName, 5, 10, scene, + doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { point->dialog=dialogTool; @@ -169,10 +172,10 @@ VToolBisector* VToolBisector::Create(DialogTool *dialog, VMainGraphicsScene *sce * @param typeCreation way we create this tool. */ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const quint32 &firstPointId, - const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine, - const QString &pointName, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document &parse, const Source &typeCreation) + const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine, + const QString &lineColor, const QString &pointName, const qreal &mx, + const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation) { const QSharedPointer firstPoint = data->GeometricObject(firstPointId); const QSharedPointer secondPoint = data->GeometricObject(secondPointId); @@ -200,12 +203,12 @@ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const VDrawTool::AddRecord(id, Tool::Bisector, doc); if (parse == Document::FullParse) { - VToolBisector *point = new VToolBisector(doc, data, id, typeLine, formula, firstPointId, secondPointId, - thirdPointId, typeCreation); + VToolBisector *point = new VToolBisector(doc, data, id, typeLine, lineColor, formula, firstPointId, + secondPointId, thirdPointId, typeCreation); scene->addItem(point); connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolBisector::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolBisector::Disable); doc->AddTool(id, point); doc->IncrementReferens(firstPointId); doc->IncrementReferens(secondPointId); @@ -221,15 +224,7 @@ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const */ void VToolBisector::FullUpdateFromFile() { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - typeLine = domElement.attribute(AttrTypeLine, ""); - formulaLength = domElement.attribute(AttrLength, ""); - firstPointId = domElement.attribute(AttrFirstPoint, "").toUInt(); - basePointId = domElement.attribute(AttrSecondPoint, "").toUInt(); - thirdPointId = domElement.attribute(AttrThirdPoint, "").toUInt(); - } + ReadAttributes(); RefreshGeometry(); if (vis != nullptr) @@ -296,11 +291,12 @@ void VToolBisector::SaveDialog(QDomElement &domElement) DialogBisector *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); - doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); - doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); - doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId())); - doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); - doc->SetAttribute(domElement, AttrThirdPoint, QString().setNum(dialogTool->getThirdPointId())); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); + doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); + doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); + doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPointId())); + doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPointId())); + doc->SetAttribute(domElement, AttrThirdPoint, QString().setNum(dialogTool->GetThirdPointId())); } //--------------------------------------------------------------------------------------------------------------------- @@ -316,6 +312,7 @@ void VToolBisector::SaveOptions(QDomElement &tag, QSharedPointer &obj) doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrTypeLine, typeLine); + doc->SetAttribute(tag, AttrLineColor, lineColor); doc->SetAttribute(tag, AttrLength, formulaLength); doc->SetAttribute(tag, AttrFirstPoint, firstPointId); doc->SetAttribute(tag, AttrSecondPoint, basePointId); @@ -323,13 +320,24 @@ void VToolBisector::SaveOptions(QDomElement &tag, QSharedPointer &obj) } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolBisector::getThirdPointId() const +void VToolBisector::ReadToolAttributes(const QDomElement &domElement) +{ + typeLine = doc->GetParametrString(domElement, AttrTypeLine, TypeLineLine); + lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack); + formulaLength = doc->GetParametrString(domElement, AttrLength, ""); + firstPointId = doc->GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR); + basePointId = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR); + thirdPointId = doc->GetParametrUInt(domElement, AttrThirdPoint, NULL_ID_STR); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolBisector::GetThirdPointId() const { return thirdPointId; } //--------------------------------------------------------------------------------------------------------------------- -void VToolBisector::setThirdPointId(const quint32 &value) +void VToolBisector::SetThirdPointId(const quint32 &value) { if (value != NULL_ID) { @@ -377,13 +385,13 @@ void VToolBisector::ShowVisualization(bool show) } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolBisector::getFirstPointId() const +quint32 VToolBisector::GetFirstPointId() const { return firstPointId; } //--------------------------------------------------------------------------------------------------------------------- -void VToolBisector::setFirstPointId(const quint32 &value) +void VToolBisector::SetFirstPointId(const quint32 &value) { if (value != NULL_ID) { diff --git a/src/app/tools/drawTools/vtoolbisector.h b/src/app/tools/drawTools/vtoolbisector.h index 42ac58091..5d8ea8316 100644 --- a/src/app/tools/drawTools/vtoolbisector.h +++ b/src/app/tools/drawTools/vtoolbisector.h @@ -39,9 +39,9 @@ class VToolBisector : public VToolLinePoint Q_OBJECT public: - VToolBisector(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula, - const quint32 &firstPointId, const quint32 &secondPointId, const quint32 &thirdPointId, - const Source &typeCreation, QGraphicsItem * parent = nullptr); + VToolBisector(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &lineColor, + const QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, + const quint32 &thirdPointId, const Source &typeCreation, QGraphicsItem * parent = nullptr); static qreal BisectorAngle(const QPointF &firstPoint, const QPointF &secondPoint, const QPointF &thirdPoint); static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const QPointF &thirdPoint, const qreal& length); @@ -49,18 +49,18 @@ public: static VToolBisector* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolBisector* Create(const quint32 _id, QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine, - const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, - VPattern *doc, VContainer *data, const Document &parse, + const QString &lineColor, const QString &pointName, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); static const QString ToolType; virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::Bisector)}; - quint32 getFirstPointId() const; - void setFirstPointId(const quint32 &value); + quint32 GetFirstPointId() const; + void SetFirstPointId(const quint32 &value); - quint32 getThirdPointId() const; - void setThirdPointId(const quint32 &value); + quint32 GetThirdPointId() const; + void SetThirdPointId(const quint32 &value); virtual void ShowVisualization(bool show); public slots: @@ -72,6 +72,7 @@ protected: virtual void RemoveReferens(); virtual void SaveDialog(QDomElement &domElement); virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); + virtual void ReadToolAttributes(const QDomElement &domElement); private: /** @brief firstPointId id first point of angle. */ quint32 firstPointId; diff --git a/src/app/tools/drawTools/vtoolcurveintersectaxis.cpp b/src/app/tools/drawTools/vtoolcurveintersectaxis.cpp index 3aa46c33f..e5f23ae9d 100644 --- a/src/app/tools/drawTools/vtoolcurveintersectaxis.cpp +++ b/src/app/tools/drawTools/vtoolcurveintersectaxis.cpp @@ -38,10 +38,11 @@ const QString VToolCurveIntersectAxis::ToolType = QStringLiteral("curveIntersect //--------------------------------------------------------------------------------------------------------------------- VToolCurveIntersectAxis::VToolCurveIntersectAxis(VPattern *doc, VContainer *data, const quint32 &id, - const QString &typeLine, const QString &formulaAngle, - const quint32 &basePointId, const quint32 &curveId, - const Source &typeCreation, QGraphicsItem *parent) - :VToolLinePoint(doc, data, id, typeLine, QString(), basePointId, 0, parent), formulaAngle(formulaAngle), + const QString &typeLine, const QString &lineColor, + const QString &formulaAngle, const quint32 &basePointId, + const quint32 &curveId, const Source &typeCreation, + QGraphicsItem *parent) + :VToolLinePoint(doc, data, id, typeLine, lineColor, QString(), basePointId, 0, parent), formulaAngle(formulaAngle), curveId(curveId) { if (typeCreation == Source::FromGui) @@ -66,11 +67,12 @@ void VToolCurveIntersectAxis::setDialog() DialogCurveIntersectAxis *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); const QSharedPointer p = VAbstractTool::data.GeometricObject(id); - dialogTool->setTypeLine(typeLine); - dialogTool->setAngle(formulaAngle); - dialogTool->setBasePointId(basePointId); + dialogTool->SetTypeLine(typeLine); + dialogTool->SetLineColor(lineColor); + dialogTool->SetAngle(formulaAngle); + dialogTool->SetBasePointId(basePointId); dialogTool->setCurveId(curveId); - dialogTool->setPointName(p->name()); + dialogTool->SetPointName(p->name()); } //--------------------------------------------------------------------------------------------------------------------- @@ -81,13 +83,14 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(DialogTool *dialog, VMa DialogCurveIntersectAxis *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool); const QString pointName = dialogTool->getPointName(); - const QString typeLine = dialogTool->getTypeLine(); - QString formulaAngle = dialogTool->getAngle(); - const quint32 basePointId = dialogTool->getBasePointId(); + const QString typeLine = dialogTool->GetTypeLine(); + const QString lineColor = dialogTool->GetLineColor(); + QString formulaAngle = dialogTool->GetAngle(); + const quint32 basePointId = dialogTool->GetBasePointId(); const quint32 curveId = dialogTool->getCurveId(); VToolCurveIntersectAxis *point = nullptr; - point=Create(0, pointName, typeLine, formulaAngle, basePointId, curveId, 5, 10, scene, doc, data, + point=Create(0, pointName, typeLine, lineColor, formulaAngle, basePointId, curveId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { @@ -98,9 +101,9 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(DialogTool *dialog, VMa //--------------------------------------------------------------------------------------------------------------------- VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(const quint32 _id, const QString &pointName, - const QString &typeLine, QString &formulaAngle, - const quint32 &basePointId, const quint32 &curveId, - const qreal &mx, const qreal &my, + const QString &typeLine, const QString &lineColor, + QString &formulaAngle, const quint32 &basePointId, + const quint32 &curveId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { @@ -127,12 +130,12 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(const quint32 _id, cons VDrawTool::AddRecord(id, Tool::CurveIntersectAxis, doc); if (parse == Document::FullParse) { - VToolCurveIntersectAxis *point = new VToolCurveIntersectAxis(doc, data, id, typeLine, formulaAngle, basePointId, - curveId, typeCreation); + VToolCurveIntersectAxis *point = new VToolCurveIntersectAxis(doc, data, id, typeLine, lineColor, formulaAngle, + basePointId, curveId, typeCreation); scene->addItem(point); connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCurveIntersectAxis::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCurveIntersectAxis::Disable); doc->AddTool(id, point); doc->IncrementReferens(basePointId); doc->IncrementReferens(curveId); @@ -173,7 +176,7 @@ QPointF VToolCurveIntersectAxis::FindPoint(const QPointF &point, qreal angle, } //--------------------------------------------------------------------------------------------------------------------- -VFormula VToolCurveIntersectAxis::getFormulaAngle() const +VFormula VToolCurveIntersectAxis::GetFormulaAngle() const { VFormula fAngle(formulaAngle, getData()); fAngle.setCheckZero(false); @@ -183,11 +186,11 @@ VFormula VToolCurveIntersectAxis::getFormulaAngle() const } //--------------------------------------------------------------------------------------------------------------------- -void VToolCurveIntersectAxis::setFormulaAngle(const VFormula &value) +void VToolCurveIntersectAxis::SetFormulaAngle(const VFormula &value) { if (value.error() == false) { - formulaAngle = value.getFormula(FormulaType::FromUser); + formulaAngle = value.GetFormula(FormulaType::FromUser); QSharedPointer obj = VAbstractTool::data.GetGObject(id); SaveOption(obj); @@ -226,7 +229,7 @@ void VToolCurveIntersectAxis::ShowVisualization(bool show) visual->setPoint1Id(curveId); visual->setAxisPointId(basePointId); - visual->setAngle(qApp->FormulaToUser(formulaAngle)); + visual->SetAngle(qApp->FormulaToUser(formulaAngle)); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); visual->RefreshGeometry(); vis = visual; @@ -250,14 +253,7 @@ void VToolCurveIntersectAxis::ShowVisualization(bool show) //--------------------------------------------------------------------------------------------------------------------- void VToolCurveIntersectAxis::FullUpdateFromFile() { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - typeLine = domElement.attribute(AttrTypeLine, ""); - basePointId = domElement.attribute(AttrBasePoint, "").toUInt(); - curveId = domElement.attribute(AttrCurve, "").toUInt(); - formulaAngle = domElement.attribute(AttrAngle, ""); - } + ReadAttributes(); RefreshGeometry(); if (vis != nullptr) @@ -265,7 +261,7 @@ void VToolCurveIntersectAxis::FullUpdateFromFile() VisToolCurveIntersectAxis *visual = qobject_cast(vis); visual->setPoint1Id(curveId); visual->setAxisPointId(basePointId); - visual->setAngle(qApp->FormulaToUser(formulaAngle)); + visual->SetAngle(qApp->FormulaToUser(formulaAngle)); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); visual->RefreshGeometry(); } @@ -290,9 +286,10 @@ void VToolCurveIntersectAxis::SaveDialog(QDomElement &domElement) DialogCurveIntersectAxis *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); - doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); - doc->SetAttribute(domElement, AttrAngle, dialogTool->getAngle()); - doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->getBasePointId())); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); + doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); + doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle()); + doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->GetBasePointId())); doc->SetAttribute(domElement, AttrCurve, QString().setNum(dialogTool->getCurveId())); } @@ -309,7 +306,18 @@ void VToolCurveIntersectAxis::SaveOptions(QDomElement &tag, QSharedPointerSetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrTypeLine, typeLine); + doc->SetAttribute(tag, AttrLineColor, lineColor); doc->SetAttribute(tag, AttrAngle, formulaAngle); doc->SetAttribute(tag, AttrBasePoint, basePointId); doc->SetAttribute(tag, AttrCurve, curveId); } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCurveIntersectAxis::ReadToolAttributes(const QDomElement &domElement) +{ + typeLine = doc->GetParametrString(domElement, AttrTypeLine, TypeLineLine); + lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack); + basePointId = doc->GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR); + curveId = doc->GetParametrUInt(domElement, AttrCurve, NULL_ID_STR); + formulaAngle = doc->GetParametrString(domElement, AttrAngle, ""); +} diff --git a/src/app/tools/drawTools/vtoolcurveintersectaxis.h b/src/app/tools/drawTools/vtoolcurveintersectaxis.h index fedd78c8b..5dbb7d475 100644 --- a/src/app/tools/drawTools/vtoolcurveintersectaxis.h +++ b/src/app/tools/drawTools/vtoolcurveintersectaxis.h @@ -36,17 +36,18 @@ class VToolCurveIntersectAxis : public VToolLinePoint Q_OBJECT public: VToolCurveIntersectAxis(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, - const QString &formulaAngle, const quint32 &basePointId, const quint32 &curveId, - const Source &typeCreation, QGraphicsItem * parent = nullptr); + const QString &lineColor, const QString &formulaAngle, const quint32 &basePointId, + const quint32 &curveId, const Source &typeCreation, QGraphicsItem * parent = nullptr); virtual ~VToolCurveIntersectAxis(); virtual void setDialog(); static VToolCurveIntersectAxis *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolCurveIntersectAxis *Create(const quint32 _id, const QString &pointName, const QString &typeLine, - QString &formulaAngle, const quint32 &basePointId, const quint32 &curveId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document &parse, const Source &typeCreation); + const QString &lineColor, QString &formulaAngle, const quint32 &basePointId, + const quint32 &curveId, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation); static QPointF FindPoint(const QPointF &point, qreal angle, const QSharedPointer &curve); @@ -54,8 +55,8 @@ public: virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::CurveIntersectAxis)}; - VFormula getFormulaAngle() const; - void setFormulaAngle(const VFormula &value); + VFormula GetFormulaAngle() const; + void SetFormulaAngle(const VFormula &value); quint32 getCurveId() const; void setCurveId(const quint32 &value); @@ -68,6 +69,7 @@ protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void SaveDialog(QDomElement &domElement); virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); + virtual void ReadToolAttributes(const QDomElement &domElement); private: Q_DISABLE_COPY(VToolCurveIntersectAxis) QString formulaAngle; diff --git a/src/app/tools/drawTools/vtoolcut.cpp b/src/app/tools/drawTools/vtoolcut.cpp index ff2365dcd..192fc1e69 100644 --- a/src/app/tools/drawTools/vtoolcut.cpp +++ b/src/app/tools/drawTools/vtoolcut.cpp @@ -32,7 +32,7 @@ //--------------------------------------------------------------------------------------------------------------------- VToolCut::VToolCut(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, - const quint32 &curveCutId, const quint32 &curve1id, const quint32 &curve2id, + const quint32 &curveCutId, const quint32 &curve1id, const quint32 &curve2id, const QString &color, QGraphicsItem *parent) :VToolPoint(doc, data, id, parent), formula(formula), firstCurve(nullptr), secondCurve(nullptr), curveCutId(curveCutId), curve1id(curve1id), curve2id(curve2id) @@ -41,12 +41,14 @@ VToolCut::VToolCut(VPattern *doc, VContainer *data, const quint32 &id, const QSt Q_ASSERT_X(curve1id > 0, Q_FUNC_INFO, "curve1id <= 0"); Q_ASSERT_X(curve2id > 0, Q_FUNC_INFO, "curve2id <= 0"); - firstCurve = new VSimpleCurve(curve1id, ¤tColor, SimpleCurvePoint::ForthPoint, &factor); + lineColor = color; + + firstCurve = new VSimpleCurve(curve1id, QColor(lineColor), SimpleCurvePoint::ForthPoint, &factor); firstCurve->setParentItem(this); connect(firstCurve, &VSimpleCurve::Choosed, this, &VToolCut::CurveChoosed); connect(firstCurve, &VSimpleCurve::HoverPath, this, &VToolCut::HoverPath); - secondCurve = new VSimpleCurve(curve2id, ¤tColor, SimpleCurvePoint::FirstPoint, &factor); + secondCurve = new VSimpleCurve(curve2id, QColor(lineColor), SimpleCurvePoint::FirstPoint, &factor); secondCurve->setParentItem(this); connect(secondCurve, &VSimpleCurve::Choosed, this, &VToolCut::CurveChoosed); connect(secondCurve, &VSimpleCurve::HoverPath, this, &VToolCut::HoverPath); @@ -59,11 +61,7 @@ VToolCut::VToolCut(VPattern *doc, VContainer *data, const quint32 &id, const QSt */ void VToolCut::ChangedActivDraw(const QString &newName) { - VToolPoint::ChangedActivDraw(newName); - const bool flag = (nameActivDraw == newName); - this->setEnabled(flag); - firstCurve->ChangedActivDraw(flag); - secondCurve->ChangedActivDraw(flag); + Disable(!(nameActivDraw == newName)); } //--------------------------------------------------------------------------------------------------------------------- @@ -76,6 +74,14 @@ void VToolCut::HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirecti } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolCut::Disable(bool disable) +{ + VToolPoint::Disable(disable); + firstCurve->ChangedActivDraw(enabled); + secondCurve->ChangedActivDraw(enabled); +} + //--------------------------------------------------------------------------------------------------------------------- quint32 VToolCut::getCurveCutId() const { @@ -94,7 +100,7 @@ void VToolCut::setCurveCutId(const quint32 &value) } //--------------------------------------------------------------------------------------------------------------------- -VFormula VToolCut::getFormula() const +VFormula VToolCut::GetFormula() const { VFormula val(formula, getData()); val.setCheckZero(true); @@ -104,11 +110,11 @@ VFormula VToolCut::getFormula() const } //--------------------------------------------------------------------------------------------------------------------- -void VToolCut::setFormula(const VFormula &value) +void VToolCut::SetFormula(const VFormula &value) { if (value.error() == false) { - formula = value.getFormula(FormulaType::FromUser); + formula = value.GetFormula(FormulaType::FromUser); QSharedPointer obj = VAbstractTool::data.GetGObject(id); SaveOption(obj); @@ -146,5 +152,4 @@ void VToolCut::FullUpdateCurveFromFile(const QString &attrCurve) formula = domElement.attribute(AttrLength, ""); curveCutId = domElement.attribute(attrCurve, "").toUInt(); } - RefreshGeometry(); } diff --git a/src/app/tools/drawTools/vtoolcut.h b/src/app/tools/drawTools/vtoolcut.h index f99e82847..a815b3017 100644 --- a/src/app/tools/drawTools/vtoolcut.h +++ b/src/app/tools/drawTools/vtoolcut.h @@ -39,12 +39,12 @@ class VToolCut : public VToolPoint Q_OBJECT public: VToolCut(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, const quint32 &curveCutId, - const quint32 &curve1id, const quint32 &curve2id, QGraphicsItem * parent = nullptr); + const quint32 &curve1id, const quint32 &curve2id, const QString &color, QGraphicsItem * parent = nullptr); virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::Cut)}; - VFormula getFormula() const; - void setFormula(const VFormula &value); + VFormula GetFormula() const; + void SetFormula(const VFormula &value); quint32 getCurveCutId() const; void setCurveCutId(const quint32 &value); @@ -53,6 +53,7 @@ public slots: virtual void ChangedActivDraw(const QString &newName); virtual void CurveChoosed(quint32 id)=0; void HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirection direction); + void Disable(bool disable); protected: /** @brief formula keep formula of length */ QString formula; diff --git a/src/app/tools/drawTools/vtoolcutarc.cpp b/src/app/tools/drawTools/vtoolcutarc.cpp index 1bdb9d222..a2b00da2f 100644 --- a/src/app/tools/drawTools/vtoolcutarc.cpp +++ b/src/app/tools/drawTools/vtoolcutarc.cpp @@ -50,9 +50,9 @@ const QString VToolCutArc::AttrArc = QStringLiteral("arc"); * @param parent parent object. */ VToolCutArc::VToolCutArc(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, - const quint32 &arcId, const quint32 &arc1id, const quint32 &arc2id, + const quint32 &arcId, const quint32 &arc1id, const quint32 &arc2id, const QString &color, const Source &typeCreation, QGraphicsItem * parent) - :VToolCut(doc, data, id, formula, arcId, arc1id, arc2id, parent) + :VToolCut(doc, data, id, formula, arcId, arc1id, arc2id, color, parent) { RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint); RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint); @@ -77,9 +77,10 @@ void VToolCutArc::setDialog() DialogCutArc *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - dialogTool->setFormula(formula); + dialogTool->SetFormula(formula); dialogTool->setArcId(curveCutId); - dialogTool->setPointName(point->name()); + dialogTool->SetPointName(point->name()); + dialogTool->SetColor(lineColor); } //--------------------------------------------------------------------------------------------------------------------- @@ -96,10 +97,11 @@ VToolCutArc* VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, DialogCutArc *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); const QString pointName = dialogTool->getPointName(); - QString formula = dialogTool->getFormula(); + QString formula = dialogTool->GetFormula(); const quint32 arcId = dialogTool->getArcId(); + const QString color = dialogTool->GetColor(); VToolCutArc* point = nullptr; - point=Create(0, pointName, formula, arcId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); + point=Create(0, pointName, formula, arcId, 5, 10, color, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { point->dialog=dialogTool; @@ -123,8 +125,8 @@ VToolCutArc* VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, * @param typeCreation way we create this tool. */ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document &parse, const Source &typeCreation) + const qreal &mx, const qreal &my, const QString &color, VMainGraphicsScene *scene, + VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { const QSharedPointer arc = data->GeometricObject(arcId); @@ -167,11 +169,11 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS VDrawTool::AddRecord(id, Tool::CutArc, doc); if (parse == Document::FullParse) { - VToolCutArc *point = new VToolCutArc(doc, data, id, formula, arcId, arc1id, arc2id, typeCreation); + VToolCutArc *point = new VToolCutArc(doc, data, id, formula, arcId, arc1id, arc2id, color, typeCreation); scene->addItem(point); connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCutArc::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCutArc::Disable); doc->AddTool(id, point); doc->AddTool(arc1id, point); doc->AddTool(arc2id, point); @@ -220,7 +222,8 @@ void VToolCutArc::ShowVisualization(bool show) */ void VToolCutArc::FullUpdateFromFile() { - FullUpdateCurveFromFile(AttrArc); + ReadAttributes(); + RefreshGeometry(); if (vis != nullptr) { @@ -271,8 +274,9 @@ void VToolCutArc::SaveDialog(QDomElement &domElement) DialogCutArc *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); - doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); + doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); doc->SetAttribute(domElement, AttrArc, QString().setNum(dialogTool->getArcId())); + doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor()); } //--------------------------------------------------------------------------------------------------------------------- @@ -296,6 +300,7 @@ void VToolCutArc::RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurve { path.translate(-arc->GetP2().x(), -arc->GetP2().y()); } + curve->SetCurrentColor(QColor(lineColor)); curve->setPath(path); } @@ -310,7 +315,16 @@ void VToolCutArc::SaveOptions(QDomElement &tag, QSharedPointer &obj) doc->SetAttribute(tag, AttrName, point->name()); doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + doc->SetAttribute(tag, AttrColor, lineColor); doc->SetAttribute(tag, AttrLength, formula); doc->SetAttribute(tag, AttrArc, curveCutId); } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCutArc::ReadToolAttributes(const QDomElement &domElement) +{ + formula = doc->GetParametrString(domElement, AttrLength, ""); + curveCutId = doc->GetParametrUInt(domElement, AttrArc, NULL_ID_STR); + lineColor = doc->GetParametrString(domElement, AttrColor, ColorBlack); +} diff --git a/src/app/tools/drawTools/vtoolcutarc.h b/src/app/tools/drawTools/vtoolcutarc.h index 2e852cdca..5a731a43d 100644 --- a/src/app/tools/drawTools/vtoolcutarc.h +++ b/src/app/tools/drawTools/vtoolcutarc.h @@ -39,13 +39,13 @@ class VToolCutArc : public VToolCut Q_OBJECT public: VToolCutArc(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, const quint32 &arcId, - const quint32 &arc1id, const quint32 &arc2id, const Source &typeCreation, + const quint32 &arc1id, const quint32 &arc2id, const QString &color, const Source &typeCreation, QGraphicsItem * parent = nullptr); virtual void setDialog(); static VToolCutArc* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolCutArc* Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document &parse, const Source &typeCreation); + const qreal &mx, const qreal &my, const QString &color, VMainGraphicsScene *scene, + VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); static const QString ToolType; static const QString AttrArc; virtual int type() const {return Type;} @@ -61,6 +61,7 @@ protected: virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition, PathDirection direction = PathDirection::Hide); virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); + virtual void ReadToolAttributes(const QDomElement &domElement); private: Q_DISABLE_COPY(VToolCutArc) }; diff --git a/src/app/tools/drawTools/vtoolcutspline.cpp b/src/app/tools/drawTools/vtoolcutspline.cpp index eed9eba7a..24fe69975 100644 --- a/src/app/tools/drawTools/vtoolcutspline.cpp +++ b/src/app/tools/drawTools/vtoolcutspline.cpp @@ -50,8 +50,8 @@ const QString VToolCutSpline::AttrSpline = QStringLiteral("spline"); */ VToolCutSpline::VToolCutSpline(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, const quint32 &splineId, const quint32 &spl1id, const quint32 &spl2id, - const Source &typeCreation, QGraphicsItem *parent) - :VToolCut(doc, data, id, formula, splineId, spl1id, spl2id, parent) + const QString &color, const Source &typeCreation, QGraphicsItem *parent) + :VToolCut(doc, data, id, formula, splineId, spl1id, spl2id, color, parent) { RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint); RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint); @@ -76,9 +76,10 @@ void VToolCutSpline::setDialog() DialogCutSpline *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - dialogTool->setFormula(formula); + dialogTool->SetFormula(formula); dialogTool->setSplineId(curveCutId); - dialogTool->setPointName(point->name()); + dialogTool->SetPointName(point->name()); + dialogTool->SetColor(lineColor); } //--------------------------------------------------------------------------------------------------------------------- @@ -96,10 +97,12 @@ VToolCutSpline* VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *s DialogCutSpline *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); const QString pointName = dialogTool->getPointName(); - QString formula = dialogTool->getFormula(); + QString formula = dialogTool->GetFormula(); const quint32 splineId = dialogTool->getSplineId(); + const QString color = dialogTool->GetColor(); VToolCutSpline* point = nullptr; - point = Create(0, pointName, formula, splineId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); + point = Create(0, pointName, formula, splineId, 5, 10, color, scene, doc, data, Document::FullParse, + Source::FromGui); if (point != nullptr) { point->dialog=dialogTool; @@ -123,7 +126,7 @@ VToolCutSpline* VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *s * @param typeCreation way we create this tool. */ VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString &formula, - const quint32 &splineId, const qreal &mx, const qreal &my, + const quint32 &splineId, const qreal &mx, const qreal &my, const QString &color, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { @@ -174,11 +177,12 @@ VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointNa VDrawTool::AddRecord(id, Tool::CutSpline, doc); if (parse == Document::FullParse) { - VToolCutSpline *point = new VToolCutSpline(doc, data, id, formula, splineId, spl1id, spl2id, typeCreation); + VToolCutSpline *point = new VToolCutSpline(doc, data, id, formula, splineId, spl1id, spl2id, color, + typeCreation); scene->addItem(point); connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCutSpline::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCutSpline::Disable); doc->AddTool(id, point); doc->AddTool(spl1id, point); doc->AddTool(spl2id, point); @@ -231,7 +235,8 @@ void VToolCutSpline::ShowVisualization(bool show) */ void VToolCutSpline::FullUpdateFromFile() { - FullUpdateCurveFromFile(AttrSpline); + ReadAttributes(); + RefreshGeometry(); if (vis != nullptr) { @@ -282,8 +287,9 @@ void VToolCutSpline::SaveDialog(QDomElement &domElement) DialogCutSpline *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); - doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); + doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); doc->SetAttribute(domElement, AttrSpline, QString().setNum(dialogTool->getSplineId())); + doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor()); } //--------------------------------------------------------------------------------------------------------------------- @@ -307,6 +313,7 @@ void VToolCutSpline::RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCu { path.translate(-spl->GetP4().toQPointF().x(), -spl->GetP4().toQPointF().y()); } + curve->SetCurrentColor(QColor(lineColor)); curve->setPath(path); } @@ -321,7 +328,16 @@ void VToolCutSpline::SaveOptions(QDomElement &tag, QSharedPointer &obj doc->SetAttribute(tag, AttrName, point->name()); doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + doc->SetAttribute(tag, AttrColor, lineColor); doc->SetAttribute(tag, AttrLength, formula); doc->SetAttribute(tag, AttrSpline, curveCutId); } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCutSpline::ReadToolAttributes(const QDomElement &domElement) +{ + formula = doc->GetParametrString(domElement, AttrLength, ""); + curveCutId = doc->GetParametrUInt(domElement, AttrSpline, NULL_ID_STR); + lineColor = doc->GetParametrString(domElement, AttrColor, ColorBlack); +} diff --git a/src/app/tools/drawTools/vtoolcutspline.h b/src/app/tools/drawTools/vtoolcutspline.h index d1b184edc..94799aa4c 100644 --- a/src/app/tools/drawTools/vtoolcutspline.h +++ b/src/app/tools/drawTools/vtoolcutspline.h @@ -40,13 +40,14 @@ class VToolCutSpline : public VToolCut public: VToolCutSpline(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, - const quint32 &splineId, const quint32 &spl1id, const quint32 &spl2id, + const quint32 &splineId, const quint32 &spl1id, const quint32 &spl2id, const QString &color, const Source &typeCreation, QGraphicsItem * parent = nullptr); virtual void setDialog(); static VToolCutSpline *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolCutSpline *Create(const quint32 _id, const QString &pointName, QString &formula, - const quint32 &splineId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, - VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); + const quint32 &splineId, const qreal &mx, const qreal &my, const QString &color, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation); static const QString ToolType; static const QString AttrSpline; virtual int type() const {return Type;} @@ -62,6 +63,7 @@ protected: virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition, PathDirection direction = PathDirection::Hide); virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); + virtual void ReadToolAttributes(const QDomElement &domElement); private: Q_DISABLE_COPY(VToolCutSpline) }; diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.cpp b/src/app/tools/drawTools/vtoolcutsplinepath.cpp index 92678b185..f93ae346b 100644 --- a/src/app/tools/drawTools/vtoolcutsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolcutsplinepath.cpp @@ -53,9 +53,9 @@ const QString VToolCutSplinePath::AttrSplinePath = QStringLiteral("splinePath"); */ VToolCutSplinePath::VToolCutSplinePath(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, const quint32 &splinePathId, - const quint32 &splPath1id, const quint32 &splPath2id, + const quint32 &splPath1id, const quint32 &splPath2id, const QString &color, const Source &typeCreation, QGraphicsItem *parent) - :VToolCut(doc, data, id, formula, splinePathId, splPath1id, splPath2id, parent) + :VToolCut(doc, data, id, formula, splinePathId, splPath1id, splPath2id, color, parent) { RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint); RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint); @@ -80,9 +80,10 @@ void VToolCutSplinePath::setDialog() DialogCutSplinePath *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); const QSharedPointer point = VAbstractTool::data.GeometricObject(id); - dialogTool->setFormula(formula); + dialogTool->SetFormula(formula); dialogTool->setSplinePathId(curveCutId); - dialogTool->setPointName(point->name()); + dialogTool->SetPointName(point->name()); + dialogTool->SetColor(lineColor); } //--------------------------------------------------------------------------------------------------------------------- @@ -100,10 +101,12 @@ VToolCutSplinePath* VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphics DialogCutSplinePath *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); const QString pointName = dialogTool->getPointName(); - QString formula = dialogTool->getFormula(); + QString formula = dialogTool->GetFormula(); const quint32 splinePathId = dialogTool->getSplinePathId(); + const QString color = dialogTool->GetColor(); VToolCutSplinePath* point = nullptr; - point = Create(0, pointName, formula, splinePathId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); + point = Create(0, pointName, formula, splinePathId, 5, 10, color, scene, doc, data, Document::FullParse, + Source::FromGui); if (point != nullptr) { point->dialog=dialogTool; @@ -128,8 +131,8 @@ VToolCutSplinePath* VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphics */ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splinePathId, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document &parse, const Source &typeCreation) + const QString &color, VMainGraphicsScene *scene, VPattern *doc, + VContainer *data, const Document &parse, const Source &typeCreation) { const QSharedPointer splPath = data->GeometricObject(splinePathId); SCASSERT(splPath != nullptr); @@ -156,8 +159,8 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString VSplinePoint splP1 = splPath->at(p1); VSplinePoint splP2 = splPath->at(p2); - const VSpline spl1 = VSpline(splP1.P(), spl1p2, spl1p3, *p, splPath->getKCurve()); - const VSpline spl2 = VSpline(*p, spl2p2, spl2p3, splP2.P(), splPath->getKCurve()); + const VSpline spl1 = VSpline(splP1.P(), spl1p2, spl1p3, *p, splPath->GetKCurve()); + const VSpline spl2 = VSpline(*p, spl2p2, spl2p3, splP2.P(), splPath->GetKCurve()); VSplinePath *splPath1 = new VSplinePath(); VSplinePath *splPath2 = new VSplinePath(); @@ -191,8 +194,8 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString splPath2->append(splPath->at(i)); } } - splPath1->setKCurve(splPath->getKCurve()); - splPath2->setKCurve(splPath->getKCurve()); + splPath1->SetKCurve(splPath->GetKCurve()); + splPath2->SetKCurve(splPath->GetKCurve()); splPath1->setMaxCountPoints(splPath->CountPoint()); splPath2->setMaxCountPoints(splPath->CountPoint()); @@ -223,11 +226,11 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString if (parse == Document::FullParse) { VToolCutSplinePath *point = new VToolCutSplinePath(doc, data, id, formula, splinePathId, splPath1id, - splPath2id, typeCreation); + splPath2id, color, typeCreation); scene->addItem(point); connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCutSplinePath::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCutSplinePath::Disable); doc->AddTool(id, point); doc->AddTool(splPath1id, point); doc->AddTool(splPath2id, point); @@ -280,7 +283,8 @@ void VToolCutSplinePath::ShowVisualization(bool show) */ void VToolCutSplinePath::FullUpdateFromFile() { - FullUpdateCurveFromFile(AttrSplinePath); + ReadAttributes(); + RefreshGeometry(); if (vis != nullptr) { @@ -331,8 +335,9 @@ void VToolCutSplinePath::SaveDialog(QDomElement &domElement) DialogCutSplinePath *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); - doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); + doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); doc->SetAttribute(domElement, AttrSplinePath, QString().setNum(dialogTool->getSplinePathId())); + doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor()); } //--------------------------------------------------------------------------------------------------------------------- @@ -358,6 +363,7 @@ void VToolCutSplinePath::RefreshCurve(VSimpleCurve *curve, quint32 curveId, Simp VSpline spl = splPath->GetSpline(splPath->Count()); path.translate(-spl.GetP4().toQPointF().x(), -spl.GetP4().toQPointF().y()); } + curve->SetCurrentColor(QColor(lineColor)); curve->setPath(path); } @@ -372,7 +378,16 @@ void VToolCutSplinePath::SaveOptions(QDomElement &tag, QSharedPointer doc->SetAttribute(tag, AttrName, point->name()); doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); + doc->SetAttribute(tag, AttrColor, lineColor); doc->SetAttribute(tag, AttrLength, formula); doc->SetAttribute(tag, AttrSplinePath, curveCutId); } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolCutSplinePath::ReadToolAttributes(const QDomElement &domElement) +{ + formula = doc->GetParametrString(domElement, AttrLength, ""); + curveCutId = doc->GetParametrUInt(domElement, AttrSplinePath, NULL_ID_STR); + lineColor = doc->GetParametrString(domElement, AttrColor, ColorBlack); +} diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.h b/src/app/tools/drawTools/vtoolcutsplinepath.h index 6f5db493c..1de640cfe 100644 --- a/src/app/tools/drawTools/vtoolcutsplinepath.h +++ b/src/app/tools/drawTools/vtoolcutsplinepath.h @@ -42,12 +42,12 @@ public: VToolCutSplinePath(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, const quint32 &splinePathId, const quint32 &splPath1id, const quint32 &splPath2id, - const Source &typeCreation, QGraphicsItem * parent = nullptr); + const QString &color, const Source &typeCreation, QGraphicsItem * parent = nullptr); virtual void setDialog(); static VToolCutSplinePath *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolCutSplinePath *Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &splinePathId, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const QString &color, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); static const QString ToolType; static const QString AttrSplinePath; @@ -64,6 +64,7 @@ protected: virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition, PathDirection direction = PathDirection::Hide); virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); + virtual void ReadToolAttributes(const QDomElement &domElement); private: Q_DISABLE_COPY(VToolCutSplinePath) }; diff --git a/src/app/tools/drawTools/vtoolendline.cpp b/src/app/tools/drawTools/vtoolendline.cpp index 3bc0fc2f8..0956ef24f 100644 --- a/src/app/tools/drawTools/vtoolendline.cpp +++ b/src/app/tools/drawTools/vtoolendline.cpp @@ -50,9 +50,10 @@ const QString VToolEndLine::ToolType = QStringLiteral("endLine"); * @param parent parent object. */ VToolEndLine::VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, - const QString &formulaLength, const QString &formulaAngle, const quint32 &basePointId, - const Source &typeCreation, QGraphicsItem *parent) - :VToolLinePoint(doc, data, id, typeLine, formulaLength, basePointId, 0, parent), formulaAngle(formulaAngle) + const QString &lineColor, const QString &formulaLength, const QString &formulaAngle, + const quint32 &basePointId, const Source &typeCreation, QGraphicsItem *parent) + :VToolLinePoint(doc, data, id, typeLine, lineColor, formulaLength, basePointId, 0, parent), + formulaAngle(formulaAngle) { if (typeCreation == Source::FromGui) { @@ -79,11 +80,12 @@ void VToolEndLine::setDialog() DialogEndLine *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); const QSharedPointer p = VAbstractTool::data.GeometricObject(id); - dialogTool->setTypeLine(typeLine); - dialogTool->setFormula(formulaLength); - dialogTool->setAngle(formulaAngle); - dialogTool->setBasePointId(basePointId); - dialogTool->setPointName(p->name()); + dialogTool->SetTypeLine(typeLine); + dialogTool->SetLineColor(lineColor); + dialogTool->SetFormula(formulaLength); + dialogTool->SetAngle(formulaAngle); + dialogTool->SetBasePointId(basePointId); + dialogTool->SetPointName(p->name()); } //--------------------------------------------------------------------------------------------------------------------- @@ -101,13 +103,14 @@ VToolEndLine* VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene DialogEndLine *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool); const QString pointName = dialogTool->getPointName(); - const QString typeLine = dialogTool->getTypeLine(); - QString formulaLength = dialogTool->getFormula(); - QString formulaAngle = dialogTool->getAngle(); - const quint32 basePointId = dialogTool->getBasePointId(); + const QString typeLine = dialogTool->GetTypeLine(); + const QString lineColor = dialogTool->GetLineColor(); + QString formulaLength = dialogTool->GetFormula(); + QString formulaAngle = dialogTool->GetAngle(); + const quint32 basePointId = dialogTool->GetBasePointId(); VToolEndLine *point = nullptr; - point=Create(0, pointName, typeLine, formulaLength, formulaAngle, basePointId, 5, 10, scene, doc, data, + point=Create(0, pointName, typeLine, lineColor, formulaLength, formulaAngle, basePointId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { @@ -122,6 +125,7 @@ VToolEndLine* VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene * @param _id tool id, 0 if tool doesn't exist yet. * @param pointName point name. * @param typeLine line type. + * @param lineColor line color. * @param formulaLength string with formula length of line. * @param formulaAngle formula angle of line. * @param basePointId id first point of line. @@ -135,9 +139,10 @@ VToolEndLine* VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene * @return the created tool */ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine, - QString &formulaLength, QString &formulaAngle, const quint32 &basePointId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document &parse, const Source &typeCreation) + const QString &lineColor, QString &formulaLength, QString &formulaAngle, + const quint32 &basePointId, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation) { const QSharedPointer basePoint = data->GeometricObject(basePointId); QLineF line = QLineF(basePoint->toQPointF(), QPointF(basePoint->x()+100, basePoint->y())); @@ -162,12 +167,12 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, VDrawTool::AddRecord(id, Tool::EndLine, doc); if (parse == Document::FullParse) { - VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, formulaLength, formulaAngle, basePointId, - typeCreation); + VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, lineColor, formulaLength, formulaAngle, + basePointId, typeCreation); scene->addItem(point); connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolEndLine::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolEndLine::Disable); doc->AddTool(id, point); doc->IncrementReferens(basePointId); return point; @@ -181,14 +186,7 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, */ void VToolEndLine::FullUpdateFromFile() { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - typeLine = domElement.attribute(AttrTypeLine, ""); - formulaLength = domElement.attribute(AttrLength, ""); - basePointId = domElement.attribute(AttrBasePoint, "").toUInt(); - formulaAngle = domElement.attribute(AttrAngle, ""); - } + ReadAttributes(); RefreshGeometry(); if (vis != nullptr) @@ -196,7 +194,7 @@ void VToolEndLine::FullUpdateFromFile() VisToolEndLine *visual = qobject_cast(vis); visual->setPoint1Id(basePointId); visual->setLength(qApp->FormulaToUser(formulaLength)); - visual->setAngle(qApp->FormulaToUser(formulaAngle)); + visual->SetAngle(qApp->FormulaToUser(formulaAngle)); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); visual->RefreshGeometry(); } @@ -232,10 +230,11 @@ void VToolEndLine::SaveDialog(QDomElement &domElement) DialogEndLine *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); - doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); - doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); - doc->SetAttribute(domElement, AttrAngle, dialogTool->getAngle()); - doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->getBasePointId())); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); + doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); + doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); + doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle()); + doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->GetBasePointId())); } //--------------------------------------------------------------------------------------------------------------------- @@ -251,13 +250,24 @@ void VToolEndLine::SaveOptions(QDomElement &tag, QSharedPointer &obj) doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrTypeLine, typeLine); + doc->SetAttribute(tag, AttrLineColor, lineColor); doc->SetAttribute(tag, AttrLength, formulaLength); doc->SetAttribute(tag, AttrAngle, formulaAngle); doc->SetAttribute(tag, AttrBasePoint, basePointId); } //--------------------------------------------------------------------------------------------------------------------- -VFormula VToolEndLine::getFormulaAngle() const +void VToolEndLine::ReadToolAttributes(const QDomElement &domElement) +{ + typeLine = doc->GetParametrString(domElement, AttrTypeLine, TypeLineLine); + lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack); + formulaLength = doc->GetParametrString(domElement, AttrLength, ""); + basePointId = doc->GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR); + formulaAngle = doc->GetParametrString(domElement, AttrAngle, ""); +} + +//--------------------------------------------------------------------------------------------------------------------- +VFormula VToolEndLine::GetFormulaAngle() const { VFormula fAngle(formulaAngle, getData()); fAngle.setCheckZero(false); @@ -267,11 +277,11 @@ VFormula VToolEndLine::getFormulaAngle() const } //--------------------------------------------------------------------------------------------------------------------- -void VToolEndLine::setFormulaAngle(const VFormula &value) +void VToolEndLine::SetFormulaAngle(const VFormula &value) { if (value.error() == false) { - formulaAngle = value.getFormula(FormulaType::FromUser); + formulaAngle = value.GetFormula(FormulaType::FromUser); QSharedPointer obj = VAbstractTool::data.GetGObject(id); SaveOption(obj); @@ -292,7 +302,7 @@ void VToolEndLine::ShowVisualization(bool show) visual->setPoint1Id(basePointId); visual->setLength(qApp->FormulaToUser(formulaLength)); - visual->setAngle(qApp->FormulaToUser(formulaAngle)); + visual->SetAngle(qApp->FormulaToUser(formulaAngle)); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); visual->RefreshGeometry(); vis = visual; diff --git a/src/app/tools/drawTools/vtoolendline.h b/src/app/tools/drawTools/vtoolendline.h index b60014931..a2e7327d7 100644 --- a/src/app/tools/drawTools/vtoolendline.h +++ b/src/app/tools/drawTools/vtoolendline.h @@ -39,22 +39,23 @@ class VToolEndLine : public VToolLinePoint Q_OBJECT public: - VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, + VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &lineColor, const QString &formulaLength, const QString &formulaAngle, const quint32 &basePointId, const Source &typeCreation, QGraphicsItem * parent = nullptr); virtual ~VToolEndLine(); virtual void setDialog(); static VToolEndLine *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolEndLine *Create(const quint32 _id, const QString &pointName, const QString &typeLine, - QString &formulaLength, QString &formulaAngle, const quint32 &basePointId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document &parse, const Source &typeCreation); + const QString &lineColor, QString &formulaLength, QString &formulaAngle, + const quint32 &basePointId, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation); static const QString ToolType; virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::EndLine)}; - VFormula getFormulaAngle() const; - void setFormulaAngle(const VFormula &value); + VFormula GetFormulaAngle() const; + void SetFormulaAngle(const VFormula &value); virtual void ShowVisualization(bool show); public slots: virtual void FullUpdateFromFile(); @@ -63,6 +64,7 @@ protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void SaveDialog(QDomElement &domElement); virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); + virtual void ReadToolAttributes(const QDomElement &domElement); private: QString formulaAngle; }; diff --git a/src/app/tools/drawTools/vtoolheight.cpp b/src/app/tools/drawTools/vtoolheight.cpp index fd878a4ee..ae69149b5 100644 --- a/src/app/tools/drawTools/vtoolheight.cpp +++ b/src/app/tools/drawTools/vtoolheight.cpp @@ -47,9 +47,10 @@ const QString VToolHeight::ToolType = QStringLiteral("height"); * @param parent parent object. */ VToolHeight::VToolHeight(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, - const quint32 &basePointId, const quint32 &p1LineId, const quint32 &p2LineId, - const Source &typeCreation, QGraphicsItem * parent) - :VToolLinePoint(doc, data, id, typeLine, QString(), basePointId, 0, parent), p1LineId(p1LineId), p2LineId(p2LineId) + const QString &lineColor, const quint32 &basePointId, const quint32 &p1LineId, + const quint32 &p2LineId, const Source &typeCreation, QGraphicsItem * parent) + :VToolLinePoint(doc, data, id, typeLine, lineColor, QString(), basePointId, 0, parent), p1LineId(p1LineId), + p2LineId(p2LineId) { ignoreFullUpdate = true; if (typeCreation == Source::FromGui) @@ -72,11 +73,12 @@ void VToolHeight::setDialog() DialogHeight *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); const QSharedPointer p = VAbstractTool::data.GeometricObject(id); - dialogTool->setTypeLine(typeLine); - dialogTool->setBasePointId(basePointId); - dialogTool->setP1LineId(p1LineId); - dialogTool->setP2LineId(p2LineId); - dialogTool->setPointName(p->name()); + dialogTool->SetTypeLine(typeLine); + dialogTool->SetLineColor(lineColor); + dialogTool->SetBasePointId(basePointId); + dialogTool->SetP1LineId(p1LineId); + dialogTool->SetP2LineId(p2LineId); + dialogTool->SetPointName(p->name()); } //--------------------------------------------------------------------------------------------------------------------- @@ -95,13 +97,14 @@ VToolHeight* VToolHeight::Create(DialogTool *dialog, VMainGraphicsScene *scene, SCASSERT(dialogTool != nullptr); disconnect(doc, &VPattern::FullUpdateFromFile, dialogTool, &DialogHeight::UpdateList); const QString pointName = dialogTool->getPointName(); - const QString typeLine = dialogTool->getTypeLine(); - const quint32 basePointId = dialogTool->getBasePointId(); - const quint32 p1LineId = dialogTool->getP1LineId(); - const quint32 p2LineId = dialogTool->getP2LineId(); + const QString typeLine = dialogTool->GetTypeLine(); + const QString lineColor = dialogTool->GetLineColor(); + const quint32 basePointId = dialogTool->GetBasePointId(); + const quint32 p1LineId = dialogTool->GetP1LineId(); + const quint32 p2LineId = dialogTool->GetP2LineId(); VToolHeight *point = nullptr; - point = Create(0, pointName, typeLine, basePointId, p1LineId, p2LineId, 5, 10, scene, doc, data, + point = Create(0, pointName, typeLine, lineColor, basePointId, p1LineId, p2LineId, 5, 10, scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { @@ -129,9 +132,9 @@ VToolHeight* VToolHeight::Create(DialogTool *dialog, VMainGraphicsScene *scene, * @return the created tool */ VToolHeight* VToolHeight::Create(const quint32 _id, const QString &pointName, const QString &typeLine, - const quint32 &basePointId, const quint32 &p1LineId, const quint32 &p2LineId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document &parse, const Source &typeCreation) + const QString &lineColor, const quint32 &basePointId, const quint32 &p1LineId, + const quint32 &p2LineId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, + VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { const QSharedPointer basePoint = data->GeometricObject(basePointId); const QSharedPointer p1Line = data->GeometricObject(p1LineId); @@ -160,12 +163,12 @@ VToolHeight* VToolHeight::Create(const quint32 _id, const QString &pointName, co VDrawTool::AddRecord(id, Tool::Height, doc); if (parse == Document::FullParse) { - VToolHeight *point = new VToolHeight(doc, data, id, typeLine, basePointId, p1LineId, p2LineId, + VToolHeight *point = new VToolHeight(doc, data, id, typeLine, lineColor, basePointId, p1LineId, p2LineId, typeCreation); scene->addItem(point); connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolHeight::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolHeight::Disable); doc->AddTool(id, point); doc->IncrementReferens(basePointId); doc->IncrementReferens(p1LineId); @@ -193,14 +196,7 @@ QPointF VToolHeight::FindPoint(const QLineF &line, const QPointF &point) */ void VToolHeight::FullUpdateFromFile() { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - typeLine = domElement.attribute(AttrTypeLine, ""); - basePointId = domElement.attribute(AttrBasePoint, "").toUInt(); - p1LineId = domElement.attribute(AttrP1Line, "").toUInt(); - p2LineId = domElement.attribute(AttrP2Line, "").toUInt(); - } + ReadAttributes(); RefreshGeometry(); if (vis != nullptr) @@ -244,10 +240,11 @@ void VToolHeight::SaveDialog(QDomElement &domElement) DialogHeight *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); - doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); - doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->getBasePointId())); - doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->getP1LineId())); - doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->getP2LineId())); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); + doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); + doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->GetBasePointId())); + doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->GetP1LineId())); + doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->GetP2LineId())); } //--------------------------------------------------------------------------------------------------------------------- @@ -263,19 +260,30 @@ void VToolHeight::SaveOptions(QDomElement &tag, QSharedPointer &obj) doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrTypeLine, typeLine); + doc->SetAttribute(tag, AttrLineColor, lineColor); doc->SetAttribute(tag, AttrBasePoint, basePointId); doc->SetAttribute(tag, AttrP1Line, p1LineId); doc->SetAttribute(tag, AttrP2Line, p2LineId); } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolHeight::getP2LineId() const +void VToolHeight::ReadToolAttributes(const QDomElement &domElement) +{ + typeLine = doc->GetParametrString(domElement, AttrTypeLine, TypeLineLine); + lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack); + basePointId = doc->GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR); + p1LineId = doc->GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR); + p2LineId = doc->GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolHeight::GetP2LineId() const { return p2LineId; } //--------------------------------------------------------------------------------------------------------------------- -void VToolHeight::setP2LineId(const quint32 &value) +void VToolHeight::SetP2LineId(const quint32 &value) { if (value != NULL_ID) { @@ -322,13 +330,13 @@ void VToolHeight::ShowVisualization(bool show) } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolHeight::getP1LineId() const +quint32 VToolHeight::GetP1LineId() const { return p1LineId; } //--------------------------------------------------------------------------------------------------------------------- -void VToolHeight::setP1LineId(const quint32 &value) +void VToolHeight::SetP1LineId(const quint32 &value) { if (value != NULL_ID) { diff --git a/src/app/tools/drawTools/vtoolheight.h b/src/app/tools/drawTools/vtoolheight.h index 79dcfe08f..02e77cf0a 100644 --- a/src/app/tools/drawTools/vtoolheight.h +++ b/src/app/tools/drawTools/vtoolheight.h @@ -39,25 +39,25 @@ class VToolHeight: public VToolLinePoint Q_OBJECT public: - VToolHeight(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const quint32 &basePointId, - const quint32 &p1LineId, const quint32 &p2LineId, const Source &typeCreation, - QGraphicsItem * parent = nullptr); + VToolHeight(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &lineColor, + const quint32 &basePointId, const quint32 &p1LineId, const quint32 &p2LineId, + const Source &typeCreation, QGraphicsItem * parent = nullptr); virtual void setDialog(); static VToolHeight *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolHeight *Create(const quint32 _id, const QString &pointName, const QString &typeLine, - const quint32 &basePointId, const quint32 &p1LineId, const quint32 &p2LineId, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document &parse, const Source &typeCreation); + const QString &lineColor, const quint32 &basePointId, const quint32 &p1LineId, + const quint32 &p2LineId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, + VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); static QPointF FindPoint(const QLineF &line, const QPointF &point); static const QString ToolType; virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::Height)}; - quint32 getP1LineId() const; - void setP1LineId(const quint32 &value); + quint32 GetP1LineId() const; + void SetP1LineId(const quint32 &value); - quint32 getP2LineId() const; - void setP2LineId(const quint32 &value); + quint32 GetP2LineId() const; + void SetP2LineId(const quint32 &value); virtual void ShowVisualization(bool show); public slots: @@ -67,6 +67,7 @@ protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void SaveDialog(QDomElement &domElement); virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); + virtual void ReadToolAttributes(const QDomElement &domElement); private: /** @brief p1LineId id first point of line. */ quint32 p1LineId; diff --git a/src/app/tools/drawTools/vtoolline.cpp b/src/app/tools/drawTools/vtoolline.cpp index a38daf2d5..1f879afb9 100644 --- a/src/app/tools/drawTools/vtoolline.cpp +++ b/src/app/tools/drawTools/vtoolline.cpp @@ -48,10 +48,12 @@ const QString VToolLine::TagName = QStringLiteral("line"); * @param parent parent object. */ VToolLine::VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstPoint, quint32 secondPoint, - const QString &typeLine, const Source &typeCreation, QGraphicsItem *parent) + const QString &typeLine, const QString &lineColor, const Source &typeCreation, + QGraphicsItem *parent) :VDrawTool(doc, data, id), QGraphicsLineItem(parent), firstPoint(firstPoint), secondPoint(secondPoint) { this->typeLine = typeLine; + this->lineColor = lineColor; ignoreFullUpdate = true; //Line const QSharedPointer first = data->GeometricObject(firstPoint); @@ -82,9 +84,10 @@ void VToolLine::setDialog() SCASSERT(dialog != nullptr); DialogLine *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - dialogTool->setFirstPoint(firstPoint); - dialogTool->setSecondPoint(secondPoint); - dialogTool->setTypeLine(typeLine); + dialogTool->SetFirstPoint(firstPoint); + dialogTool->SetSecondPoint(secondPoint); + dialogTool->SetTypeLine(typeLine); + dialogTool->SetLineColor(lineColor); } //--------------------------------------------------------------------------------------------------------------------- @@ -100,12 +103,14 @@ VToolLine *VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPat SCASSERT(dialog != nullptr); DialogLine *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - const quint32 firstPoint = dialogTool->getFirstPoint(); - const quint32 secondPoint = dialogTool->getSecondPoint(); - const QString typeLine = dialogTool->getTypeLine(); + const quint32 firstPoint = dialogTool->GetFirstPoint(); + const quint32 secondPoint = dialogTool->GetSecondPoint(); + const QString typeLine = dialogTool->GetTypeLine(); + const QString lineColor = dialogTool->GetLineColor(); VToolLine *line = nullptr; - line = Create(0, firstPoint, secondPoint, typeLine, scene, doc, data, Document::FullParse, Source::FromGui); + line = Create(0, firstPoint, secondPoint, typeLine, lineColor, scene, doc, data, Document::FullParse, + Source::FromGui); if (line != nullptr) { line->dialog=dialogTool; @@ -127,8 +132,8 @@ VToolLine *VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPat * @param typeCreation way we create this tool. */ VToolLine * VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, const quint32 &secondPoint, - const QString &typeLine, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document &parse, const Source &typeCreation) + const QString &typeLine, const QString &lineColor, VMainGraphicsScene *scene, + VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { SCASSERT(scene != nullptr); SCASSERT(doc != nullptr); @@ -151,7 +156,7 @@ VToolLine * VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, con VDrawTool::AddRecord(id, Tool::Line, doc); if (parse == Document::FullParse) { - VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeLine, typeCreation); + VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeLine, lineColor, typeCreation); scene->addItem(line); connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(scene, &VMainGraphicsScene::NewFactor, line, &VToolLine::SetFactor); @@ -189,6 +194,7 @@ QString VToolLine::getTagName() const */ void VToolLine::FullUpdateFromFile() { + ReadAttributes(); RefreshGeometry(); if (vis != nullptr) @@ -205,12 +211,11 @@ void VToolLine::FullUpdateFromFile() /** * @brief ShowTool highlight tool. * @param id object id in container - * @param color highlight color. * @param enable enable or disable highlight. */ -void VToolLine::ShowTool(quint32 id, Qt::GlobalColor color, bool enable) +void VToolLine::ShowTool(quint32 id, bool enable) { - ShowItem(this, id, color, enable); + ShowItem(this, id, enable); } //--------------------------------------------------------------------------------------------------------------------- @@ -227,7 +232,9 @@ void VToolLine::SetFactor(qreal factor) //--------------------------------------------------------------------------------------------------------------------- void VToolLine::Disable(bool disable) { - DisableItem(this, disable); + enabled = !disable; + this->setEnabled(enabled); + this->setPen(QPen(QColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine))); } //--------------------------------------------------------------------------------------------------------------------- @@ -237,9 +244,7 @@ void VToolLine::Disable(bool disable) */ void VToolLine::ChangedActivDraw(const QString &newName) { - VDrawTool::ChangedActivDraw(newName); - this->setEnabled(nameActivDraw == newName); - this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine))); + Disable(!(nameActivDraw == newName)); } //--------------------------------------------------------------------------------------------------------------------- @@ -290,7 +295,8 @@ void VToolLine::RefreshDataInFile() void VToolLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/factor, LineStyleToPenStyle(typeLine))); + this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthMainLine())/factor, + LineStyleToPenStyle(typeLine))); } //--------------------------------------------------------------------------------------------------------------------- @@ -301,7 +307,11 @@ void VToolLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine))); + if (vis == nullptr) + { + this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor, + LineStyleToPenStyle(typeLine))); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -366,9 +376,10 @@ void VToolLine::SaveDialog(QDomElement &domElement) SCASSERT(dialog != nullptr); DialogLine *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPoint())); - doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPoint())); - doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); + doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPoint())); + doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPoint())); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); + doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); } //--------------------------------------------------------------------------------------------------------------------- @@ -380,22 +391,32 @@ void VToolLine::SaveOptions(QDomElement &tag, QSharedPointer &obj) doc->SetAttribute(tag, AttrFirstPoint, firstPoint); doc->SetAttribute(tag, AttrSecondPoint, secondPoint); doc->SetAttribute(tag, AttrTypeLine, typeLine); + doc->SetAttribute(tag, AttrLineColor, lineColor); } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolLine::getSecondPoint() const +void VToolLine::ReadToolAttributes(const QDomElement &domElement) +{ + firstPoint = doc->GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR); + secondPoint = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR); + typeLine = doc->GetParametrString(domElement, AttrTypeLine, TypeLineLine); + lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolLine::GetSecondPoint() const { return secondPoint; } //--------------------------------------------------------------------------------------------------------------------- -void VToolLine::setSecondPoint(const quint32 &value) +void VToolLine::SetSecondPoint(const quint32 &value) { if (value != NULL_ID) { secondPoint = value; - QSharedPointer obj = VAbstractTool::data.GetGObject(id); + QSharedPointer obj;//We don't have object for line in data container. Just will send empty object. SaveOption(obj); } } @@ -431,11 +452,12 @@ void VToolLine::ShowVisualization(bool show) { delete vis; vis = nullptr; + hoverLeaveEvent(nullptr); } } //--------------------------------------------------------------------------------------------------------------------- -void VToolLine::setTypeLine(const QString &value) +void VToolLine::SetTypeLine(const QString &value) { typeLine = value; @@ -444,19 +466,28 @@ void VToolLine::setTypeLine(const QString &value) } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolLine::getFirstPoint() const +void VToolLine::SetLineColor(const QString &value) +{ + lineColor = value; + + QSharedPointer obj;//We don't have object for line in data container. Just will send empty object. + SaveOption(obj); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolLine::GetFirstPoint() const { return firstPoint; } //--------------------------------------------------------------------------------------------------------------------- -void VToolLine::setFirstPoint(const quint32 &value) +void VToolLine::SetFirstPoint(const quint32 &value) { if (value != NULL_ID) { firstPoint = value; - QSharedPointer obj = VAbstractTool::data.GetGObject(id); + QSharedPointer obj;//We don't have object for line in data container. Just will send empty object. SaveOption(obj); } } @@ -467,15 +498,8 @@ void VToolLine::setFirstPoint(const quint32 &value) */ void VToolLine::RefreshGeometry() { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - firstPoint = doc->GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, NULL_ID_STR); - secondPoint = doc->GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, NULL_ID_STR); - typeLine = doc->GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine); - } const QSharedPointer first = VAbstractTool::data.GeometricObject(firstPoint); const QSharedPointer second = VAbstractTool::data.GeometricObject(secondPoint); this->setLine(QLineF(first->toQPointF(), second->toQPointF())); - this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine))); + this->setPen(QPen(CorrectColor(lineColor), pen().widthF(), LineStyleToPenStyle(typeLine))); } diff --git a/src/app/tools/drawTools/vtoolline.h b/src/app/tools/drawTools/vtoolline.h index 1d852957a..17be7b9b4 100644 --- a/src/app/tools/drawTools/vtoolline.h +++ b/src/app/tools/drawTools/vtoolline.h @@ -40,29 +40,32 @@ class VToolLine: public VDrawTool, public QGraphicsLineItem Q_OBJECT public: VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstPoint, quint32 secondPoint, - const QString &typeLine, const Source &typeCreation, QGraphicsItem * parent = nullptr); + const QString &typeLine, const QString &lineColor, const Source &typeCreation, + QGraphicsItem * parent = nullptr); virtual void setDialog(); static VToolLine *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolLine *Create(const quint32 &_id, const quint32 &firstPoint, const quint32 &secondPoint, - const QString &typeLine, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document &parse, const Source &typeCreation); + const QString &typeLine, const QString &lineColor, VMainGraphicsScene *scene, + VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); static const QString TagName; virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0); virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::Line)}; virtual QString getTagName() const; - quint32 getFirstPoint() const; - void setFirstPoint(const quint32 &value); + quint32 GetFirstPoint() const; + void SetFirstPoint(const quint32 &value); - quint32 getSecondPoint() const; - void setSecondPoint(const quint32 &value); + quint32 GetSecondPoint() const; + void SetSecondPoint(const quint32 &value); virtual void ShowVisualization(bool show); - virtual void setTypeLine(const QString &value); + + virtual void SetTypeLine(const QString &value); + virtual void SetLineColor(const QString &value); public slots: virtual void FullUpdateFromFile(); virtual void ChangedActivDraw(const QString &newName); - virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); + virtual void ShowTool(quint32 id, bool enable); virtual void SetFactor(qreal factor); void Disable(bool disable); protected: @@ -76,6 +79,7 @@ protected: virtual void keyReleaseEvent(QKeyEvent * event); virtual void SaveDialog(QDomElement &domElement); virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); + virtual void ReadToolAttributes(const QDomElement &domElement); private: /** @brief firstPoint id first line point. */ quint32 firstPoint; diff --git a/src/app/tools/drawTools/vtoollineintersect.cpp b/src/app/tools/drawTools/vtoollineintersect.cpp index 973836f6a..beb7805da 100644 --- a/src/app/tools/drawTools/vtoollineintersect.cpp +++ b/src/app/tools/drawTools/vtoollineintersect.cpp @@ -74,11 +74,11 @@ void VToolLineIntersect::setDialog() DialogLineIntersect *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); const QSharedPointer p = VAbstractTool::data.GeometricObject(id); - dialogTool->setP1Line1(p1Line1); - dialogTool->setP2Line1(p2Line1); - dialogTool->setP1Line2(p1Line2); - dialogTool->setP2Line2(p2Line2); - dialogTool->setPointName(p->name()); + dialogTool->SetP1Line1(p1Line1); + dialogTool->SetP2Line1(p2Line1); + dialogTool->SetP1Line2(p1Line2); + dialogTool->SetP2Line2(p2Line2); + dialogTool->SetPointName(p->name()); } //--------------------------------------------------------------------------------------------------------------------- @@ -96,10 +96,10 @@ VToolLineIntersect* VToolLineIntersect::Create(DialogTool *dialog, VMainGraphics SCASSERT(dialog != nullptr); DialogLineIntersect *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - const quint32 p1Line1Id = dialogTool->getP1Line1(); - const quint32 p2Line1Id = dialogTool->getP2Line1(); - const quint32 p1Line2Id = dialogTool->getP1Line2(); - const quint32 p2Line2Id = dialogTool->getP2Line2(); + const quint32 p1Line1Id = dialogTool->GetP1Line1(); + const quint32 p2Line1Id = dialogTool->GetP2Line1(); + const quint32 p1Line2Id = dialogTool->GetP1Line2(); + const quint32 p2Line2Id = dialogTool->GetP2Line2(); const QString pointName = dialogTool->getPointName(); VToolLineIntersect* point = nullptr; point = Create(0, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, pointName, 5, 10, scene, doc, data, @@ -175,7 +175,7 @@ VToolLineIntersect* VToolLineIntersect::Create(const quint32 _id, const quint32 scene->addItem(point); connect(point, &VToolLineIntersect::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolLineIntersect::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolLineIntersect::Disable); doc->AddTool(id, point); doc->IncrementReferens(p1Line1Id); doc->IncrementReferens(p2Line1Id); @@ -193,14 +193,7 @@ VToolLineIntersect* VToolLineIntersect::Create(const quint32 _id, const quint32 */ void VToolLineIntersect::FullUpdateFromFile() { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - p1Line1 = domElement.attribute(AttrP1Line1, "").toUInt(); - p2Line1 = domElement.attribute(AttrP2Line1, "").toUInt(); - p1Line2 = domElement.attribute(AttrP1Line2, "").toUInt(); - p2Line2 = domElement.attribute(AttrP2Line2, "").toUInt(); - } + ReadAttributes(); RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); if (vis != nullptr) @@ -267,10 +260,10 @@ void VToolLineIntersect::SaveDialog(QDomElement &domElement) DialogLineIntersect *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); - doc->SetAttribute(domElement, AttrP1Line1, QString().setNum(dialogTool->getP1Line1())); - doc->SetAttribute(domElement, AttrP2Line1, QString().setNum(dialogTool->getP2Line1())); - doc->SetAttribute(domElement, AttrP1Line2, QString().setNum(dialogTool->getP1Line2())); - doc->SetAttribute(domElement, AttrP2Line2, QString().setNum(dialogTool->getP2Line2())); + doc->SetAttribute(domElement, AttrP1Line1, QString().setNum(dialogTool->GetP1Line1())); + doc->SetAttribute(domElement, AttrP2Line1, QString().setNum(dialogTool->GetP2Line1())); + doc->SetAttribute(domElement, AttrP1Line2, QString().setNum(dialogTool->GetP1Line2())); + doc->SetAttribute(domElement, AttrP2Line2, QString().setNum(dialogTool->GetP2Line2())); } //--------------------------------------------------------------------------------------------------------------------- @@ -292,13 +285,22 @@ void VToolLineIntersect::SaveOptions(QDomElement &tag, QSharedPointer } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolLineIntersect::getP2Line2() const +void VToolLineIntersect::ReadToolAttributes(const QDomElement &domElement) +{ + p1Line1 = doc->GetParametrUInt(domElement, AttrP1Line1, NULL_ID_STR); + p2Line1 = doc->GetParametrUInt(domElement, AttrP2Line1, NULL_ID_STR); + p1Line2 = doc->GetParametrUInt(domElement, AttrP1Line2, NULL_ID_STR); + p2Line2 = doc->GetParametrUInt(domElement, AttrP2Line2, NULL_ID_STR); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolLineIntersect::GetP2Line2() const { return p2Line2; } //--------------------------------------------------------------------------------------------------------------------- -void VToolLineIntersect::setP2Line2(const quint32 &value) +void VToolLineIntersect::SetP2Line2(const quint32 &value) { if (value != NULL_ID) { @@ -345,13 +347,13 @@ void VToolLineIntersect::ShowVisualization(bool show) } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolLineIntersect::getP1Line2() const +quint32 VToolLineIntersect::GetP1Line2() const { return p1Line2; } //--------------------------------------------------------------------------------------------------------------------- -void VToolLineIntersect::setP1Line2(const quint32 &value) +void VToolLineIntersect::SetP1Line2(const quint32 &value) { if (value != NULL_ID) { @@ -363,13 +365,13 @@ void VToolLineIntersect::setP1Line2(const quint32 &value) } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolLineIntersect::getP2Line1() const +quint32 VToolLineIntersect::GetP2Line1() const { return p2Line1; } //--------------------------------------------------------------------------------------------------------------------- -void VToolLineIntersect::setP2Line1(const quint32 &value) +void VToolLineIntersect::SetP2Line1(const quint32 &value) { if (value != NULL_ID) { @@ -381,13 +383,13 @@ void VToolLineIntersect::setP2Line1(const quint32 &value) } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolLineIntersect::getP1Line1() const +quint32 VToolLineIntersect::GetP1Line1() const { return p1Line1; } //--------------------------------------------------------------------------------------------------------------------- -void VToolLineIntersect::setP1Line1(const quint32 &value) +void VToolLineIntersect::SetP1Line1(const quint32 &value) { if (value != NULL_ID) { diff --git a/src/app/tools/drawTools/vtoollineintersect.h b/src/app/tools/drawTools/vtoollineintersect.h index dd28d16b9..414edcf15 100644 --- a/src/app/tools/drawTools/vtoollineintersect.h +++ b/src/app/tools/drawTools/vtoollineintersect.h @@ -51,17 +51,17 @@ public: virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::LineIntersect)}; - quint32 getP1Line1() const; - void setP1Line1(const quint32 &value); + quint32 GetP1Line1() const; + void SetP1Line1(const quint32 &value); - quint32 getP2Line1() const; - void setP2Line1(const quint32 &value); + quint32 GetP2Line1() const; + void SetP2Line1(const quint32 &value); - quint32 getP1Line2() const; - void setP1Line2(const quint32 &value); + quint32 GetP1Line2() const; + void SetP1Line2(const quint32 &value); - quint32 getP2Line2() const; - void setP2Line2(const quint32 &value); + quint32 GetP2Line2() const; + void SetP2Line2(const quint32 &value); virtual void ShowVisualization(bool show); public slots: @@ -73,6 +73,7 @@ protected: virtual void RemoveReferens(); virtual void SaveDialog(QDomElement &domElement); virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); + virtual void ReadToolAttributes(const QDomElement &domElement); private: /** @brief p1Line1 id first point first line. */ quint32 p1Line1; diff --git a/src/app/tools/drawTools/vtoollineintersectaxis.cpp b/src/app/tools/drawTools/vtoollineintersectaxis.cpp index 53f88fb5a..0dcfb7605 100644 --- a/src/app/tools/drawTools/vtoollineintersectaxis.cpp +++ b/src/app/tools/drawTools/vtoollineintersectaxis.cpp @@ -38,11 +38,11 @@ const QString VToolLineIntersectAxis::ToolType = QStringLiteral("lineIntersectAx //--------------------------------------------------------------------------------------------------------------------- VToolLineIntersectAxis::VToolLineIntersectAxis(VPattern *doc, VContainer *data, const quint32 &id, - const QString &typeLine, const QString &formulaAngle, - const quint32 &basePointId, const quint32 &firstPointId, - const quint32 &secondPointId, const Source &typeCreation, - QGraphicsItem *parent) - :VToolLinePoint(doc, data, id, typeLine, QString(), basePointId, 0, parent), formulaAngle(formulaAngle), + const QString &typeLine, const QString &lineColor, + const QString &formulaAngle, const quint32 &basePointId, + const quint32 &firstPointId, const quint32 &secondPointId, + const Source &typeCreation, QGraphicsItem *parent) + :VToolLinePoint(doc, data, id, typeLine, lineColor, QString(), basePointId, 0, parent), formulaAngle(formulaAngle), firstPointId(firstPointId), secondPointId(secondPointId) { if (typeCreation == Source::FromGui) @@ -67,12 +67,13 @@ void VToolLineIntersectAxis::setDialog() DialogLineIntersectAxis *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); const QSharedPointer p = VAbstractTool::data.GeometricObject(id); - dialogTool->setTypeLine(typeLine); - dialogTool->setAngle(formulaAngle); - dialogTool->setBasePointId(basePointId); - dialogTool->setFirstPointId(firstPointId); - dialogTool->setSecondPointId(secondPointId); - dialogTool->setPointName(p->name()); + dialogTool->SetTypeLine(typeLine); + dialogTool->SetLineColor(lineColor); + dialogTool->SetAngle(formulaAngle); + dialogTool->SetBasePointId(basePointId); + dialogTool->SetFirstPointId(firstPointId); + dialogTool->SetSecondPointId(secondPointId); + dialogTool->SetPointName(p->name()); } //--------------------------------------------------------------------------------------------------------------------- @@ -83,15 +84,16 @@ VToolLineIntersectAxis *VToolLineIntersectAxis::Create(DialogTool *dialog, VMain DialogLineIntersectAxis *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool); const QString pointName = dialogTool->getPointName(); - const QString typeLine = dialogTool->getTypeLine(); - QString formulaAngle = dialogTool->getAngle(); - const quint32 basePointId = dialogTool->getBasePointId(); - const quint32 firstPointId = dialogTool->getFirstPointId(); - const quint32 secondPointId = dialogTool->getSecondPointId(); + const QString typeLine = dialogTool->GetTypeLine(); + const QString lineColor = dialogTool->GetLineColor(); + QString formulaAngle = dialogTool->GetAngle(); + const quint32 basePointId = dialogTool->GetBasePointId(); + const quint32 firstPointId = dialogTool->GetFirstPointId(); + const quint32 secondPointId = dialogTool->GetSecondPointId(); VToolLineIntersectAxis *point = nullptr; - point=Create(0, pointName, typeLine, formulaAngle, basePointId, firstPointId, secondPointId, 5, 10, scene, doc, - data, Document::FullParse, Source::FromGui); + point=Create(0, pointName, typeLine, lineColor, formulaAngle, basePointId, firstPointId, secondPointId, 5, 10, + scene, doc, data, Document::FullParse, Source::FromGui); if (point != nullptr) { point->dialog=dialogTool; @@ -101,11 +103,12 @@ VToolLineIntersectAxis *VToolLineIntersectAxis::Create(DialogTool *dialog, VMain //--------------------------------------------------------------------------------------------------------------------- VToolLineIntersectAxis *VToolLineIntersectAxis::Create(const quint32 _id, const QString &pointName, - const QString &typeLine, QString &formulaAngle, - const quint32 &basePointId, const quint32 &firstPointId, - const quint32 &secondPointId, const qreal &mx, const qreal &my, - VMainGraphicsScene *scene, VPattern *doc, VContainer *data, - const Document &parse, const Source &typeCreation) + const QString &typeLine, const QString &lineColor, + QString &formulaAngle, const quint32 &basePointId, + const quint32 &firstPointId, const quint32 &secondPointId, + const qreal &mx, const qreal &my, VMainGraphicsScene *scene, + VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation) { const QSharedPointer basePoint = data->GeometricObject(basePointId); QLineF axis = QLineF(basePoint->toQPointF(), QPointF(basePoint->x()+100, basePoint->y())); @@ -138,13 +141,13 @@ VToolLineIntersectAxis *VToolLineIntersectAxis::Create(const quint32 _id, const VDrawTool::AddRecord(id, Tool::LineIntersectAxis, doc); if (parse == Document::FullParse) { - VToolLineIntersectAxis *point = new VToolLineIntersectAxis(doc, data, id, typeLine, formulaAngle, + VToolLineIntersectAxis *point = new VToolLineIntersectAxis(doc, data, id, typeLine, lineColor, formulaAngle, basePointId, firstPointId, secondPointId, typeCreation); scene->addItem(point); connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolLineIntersectAxis::SetFactor); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolLineIntersectAxis::Disable); doc->AddTool(id, point); doc->IncrementReferens(basePointId); doc->IncrementReferens(firstPointId); @@ -170,7 +173,7 @@ QPointF VToolLineIntersectAxis::FindPoint(const QLineF &axis, const QLineF &line } //--------------------------------------------------------------------------------------------------------------------- -VFormula VToolLineIntersectAxis::getFormulaAngle() const +VFormula VToolLineIntersectAxis::GetFormulaAngle() const { VFormula fAngle(formulaAngle, getData()); fAngle.setCheckZero(false); @@ -180,11 +183,11 @@ VFormula VToolLineIntersectAxis::getFormulaAngle() const } //--------------------------------------------------------------------------------------------------------------------- -void VToolLineIntersectAxis::setFormulaAngle(const VFormula &value) +void VToolLineIntersectAxis::SetFormulaAngle(const VFormula &value) { if (value.error() == false) { - formulaAngle = value.getFormula(FormulaType::FromUser); + formulaAngle = value.GetFormula(FormulaType::FromUser); QSharedPointer obj = VAbstractTool::data.GetGObject(id); SaveOption(obj); @@ -192,13 +195,13 @@ void VToolLineIntersectAxis::setFormulaAngle(const VFormula &value) } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolLineIntersectAxis::getFirstPointId() const +quint32 VToolLineIntersectAxis::GetFirstPointId() const { return firstPointId; } //--------------------------------------------------------------------------------------------------------------------- -void VToolLineIntersectAxis::setFirstPointId(const quint32 &value) +void VToolLineIntersectAxis::SetFirstPointId(const quint32 &value) { if (value != NULL_ID) { @@ -210,13 +213,13 @@ void VToolLineIntersectAxis::setFirstPointId(const quint32 &value) } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolLineIntersectAxis::getSecondPointId() const +quint32 VToolLineIntersectAxis::GetSecondPointId() const { return secondPointId; } //--------------------------------------------------------------------------------------------------------------------- -void VToolLineIntersectAxis::setSecondPointId(const quint32 &value) +void VToolLineIntersectAxis::SetSecondPointId(const quint32 &value) { if (value != NULL_ID) { @@ -242,7 +245,7 @@ void VToolLineIntersectAxis::ShowVisualization(bool show) visual->setPoint1Id(firstPointId); visual->setPoint2Id(secondPointId); visual->setAxisPointId(basePointId); - visual->setAngle(qApp->FormulaToUser(formulaAngle)); + visual->SetAngle(qApp->FormulaToUser(formulaAngle)); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); visual->RefreshGeometry(); vis = visual; @@ -266,15 +269,7 @@ void VToolLineIntersectAxis::ShowVisualization(bool show) //--------------------------------------------------------------------------------------------------------------------- void VToolLineIntersectAxis::FullUpdateFromFile() { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - typeLine = domElement.attribute(AttrTypeLine, ""); - basePointId = domElement.attribute(AttrBasePoint, "").toUInt(); - firstPointId = domElement.attribute(AttrP1Line, "").toUInt(); - secondPointId = domElement.attribute(AttrP2Line, "").toUInt(); - formulaAngle = domElement.attribute(AttrAngle, ""); - } + ReadAttributes(); RefreshGeometry(); if (vis != nullptr) @@ -283,7 +278,7 @@ void VToolLineIntersectAxis::FullUpdateFromFile() visual->setPoint1Id(firstPointId); visual->setPoint2Id(secondPointId); visual->setAxisPointId(basePointId); - visual->setAngle(qApp->FormulaToUser(formulaAngle)); + visual->SetAngle(qApp->FormulaToUser(formulaAngle)); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); visual->RefreshGeometry(); } @@ -308,11 +303,12 @@ void VToolLineIntersectAxis::SaveDialog(QDomElement &domElement) DialogLineIntersectAxis *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); - doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); - doc->SetAttribute(domElement, AttrAngle, dialogTool->getAngle()); - doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->getBasePointId())); - doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->getFirstPointId())); - doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->getSecondPointId())); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); + doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); + doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle()); + doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->GetBasePointId())); + doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->GetFirstPointId())); + doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->GetSecondPointId())); } //--------------------------------------------------------------------------------------------------------------------- @@ -328,8 +324,20 @@ void VToolLineIntersectAxis::SaveOptions(QDomElement &tag, QSharedPointerSetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrTypeLine, typeLine); + doc->SetAttribute(tag, AttrLineColor, lineColor); doc->SetAttribute(tag, AttrAngle, formulaAngle); doc->SetAttribute(tag, AttrBasePoint, basePointId); doc->SetAttribute(tag, AttrP1Line, firstPointId); doc->SetAttribute(tag, AttrP2Line, secondPointId); } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLineIntersectAxis::ReadToolAttributes(const QDomElement &domElement) +{ + typeLine = doc->GetParametrString(domElement, AttrTypeLine, TypeLineLine); + lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack); + basePointId = doc->GetParametrUInt(domElement, AttrBasePoint, NULL_ID_STR); + firstPointId = doc->GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR); + secondPointId = doc->GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR); + formulaAngle = doc->GetParametrString(domElement, AttrAngle, ""); +} diff --git a/src/app/tools/drawTools/vtoollineintersectaxis.h b/src/app/tools/drawTools/vtoollineintersectaxis.h index b7ddb00d7..6a8d0da17 100644 --- a/src/app/tools/drawTools/vtoollineintersectaxis.h +++ b/src/app/tools/drawTools/vtoollineintersectaxis.h @@ -36,15 +36,16 @@ class VToolLineIntersectAxis : public VToolLinePoint Q_OBJECT public: VToolLineIntersectAxis(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, - const QString &formulaAngle, const quint32 &basePointId, const quint32 &firstPointId, - const quint32 &secondPointId, const Source &typeCreation, QGraphicsItem * parent = nullptr); + const QString &lineColor, const QString &formulaAngle, const quint32 &basePointId, + const quint32 &firstPointId, const quint32 &secondPointId, const Source &typeCreation, + QGraphicsItem * parent = nullptr); virtual ~VToolLineIntersectAxis(); virtual void setDialog(); static VToolLineIntersectAxis *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolLineIntersectAxis *Create(const quint32 _id, const QString &pointName, const QString &typeLine, - QString &formulaAngle, const quint32 &basePointId, + const QString &lineColor, QString &formulaAngle, const quint32 &basePointId, const quint32 &firstPointId, const quint32 &secondPointId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); @@ -55,14 +56,14 @@ public: virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::LineIntersectAxis)}; - VFormula getFormulaAngle() const; - void setFormulaAngle(const VFormula &value); + VFormula GetFormulaAngle() const; + void SetFormulaAngle(const VFormula &value); - quint32 getFirstPointId() const; - void setFirstPointId(const quint32 &value); + quint32 GetFirstPointId() const; + void SetFirstPointId(const quint32 &value); - quint32 getSecondPointId() const; - void setSecondPointId(const quint32 &value); + quint32 GetSecondPointId() const; + void SetSecondPointId(const quint32 &value); virtual void ShowVisualization(bool show); public slots: @@ -72,6 +73,7 @@ protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void SaveDialog(QDomElement &domElement); virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); + virtual void ReadToolAttributes(const QDomElement &domElement); private: Q_DISABLE_COPY(VToolLineIntersectAxis) QString formulaAngle; diff --git a/src/app/tools/drawTools/vtoollinepoint.cpp b/src/app/tools/drawTools/vtoollinepoint.cpp index 1213c85ca..0de9db82b 100644 --- a/src/app/tools/drawTools/vtoollinepoint.cpp +++ b/src/app/tools/drawTools/vtoollinepoint.cpp @@ -36,18 +36,20 @@ * @param data container with variables. * @param id object id in container. * @param typeLine line type. + * @param lineColor line color. * @param formula string with length formula. * @param basePointId id base line point. * @param angle line angle. * @param parent parent object. */ -VToolLinePoint::VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &id, - const QString &typeLine, const QString &formula, const quint32 &basePointId, +VToolLinePoint::VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, + const QString &lineColor, const QString &formula, const quint32 &basePointId, const qreal &angle, QGraphicsItem *parent) - :VToolPoint(doc, data, id, parent), formulaLength(formula), angle(angle), basePointId(basePointId), + :VToolPoint(doc, data, id, parent), formulaLength(formula), angle(angle), basePointId(basePointId), mainLine(nullptr) { this->typeLine = typeLine; + this->lineColor = lineColor; Q_ASSERT_X(basePointId > 0, Q_FUNC_INFO, "basePointId <= 0"); QPointF point1 = data->GeometricObject(basePointId)->toQPointF(); QPointF point2 = data->GeometricObject(id)->toQPointF(); @@ -69,9 +71,7 @@ VToolLinePoint::~VToolLinePoint() */ void VToolLinePoint::ChangedActivDraw(const QString &newName) { - VToolPoint::ChangedActivDraw(newName); - this->setEnabled(nameActivDraw == newName); - mainLine->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine))); + Disable(!(nameActivDraw == newName)); } //--------------------------------------------------------------------------------------------------------------------- @@ -80,7 +80,8 @@ void VToolLinePoint::ChangedActivDraw(const QString &newName) */ void VToolLinePoint::RefreshGeometry() { - mainLine->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine))); + mainLine->setPen(QPen(CorrectColor(QColor(lineColor)), qApp->toPixel(qApp->widthHairLine())/factor, + LineStyleToPenStyle(typeLine))); VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); QPointF point = VDrawTool::data.GeometricObject(id)->toQPointF(); QPointF basePoint = VDrawTool::data.GeometricObject(basePointId)->toQPointF(); @@ -108,13 +109,22 @@ void VToolLinePoint::SetFactor(qreal factor) } //--------------------------------------------------------------------------------------------------------------------- -qreal VToolLinePoint::getAngle() const +void VToolLinePoint::Disable(bool disable) +{ + VToolPoint::Disable(disable); + mainLine->setPen(QPen(QColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor, + LineStyleToPenStyle(typeLine))); + mainLine->setEnabled(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +qreal VToolLinePoint::GetAngle() const { return angle; } //--------------------------------------------------------------------------------------------------------------------- -void VToolLinePoint::setAngle(const qreal &value) +void VToolLinePoint::SetAngle(const qreal &value) { angle = value; QSharedPointer obj = VAbstractTool::data.GetGObject(id); @@ -122,13 +132,13 @@ void VToolLinePoint::setAngle(const qreal &value) } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolLinePoint::getBasePointId() const +quint32 VToolLinePoint::GetBasePointId() const { return basePointId; } //--------------------------------------------------------------------------------------------------------------------- -void VToolLinePoint::setBasePointId(const quint32 &value) +void VToolLinePoint::SetBasePointId(const quint32 &value) { if (value != NULL_ID) { @@ -140,7 +150,7 @@ void VToolLinePoint::setBasePointId(const quint32 &value) } //--------------------------------------------------------------------------------------------------------------------- -VFormula VToolLinePoint::getFormulaLength() const +VFormula VToolLinePoint::GetFormulaLength() const { VFormula fLength(formulaLength, this->getData()); fLength.setCheckZero(true); @@ -151,11 +161,11 @@ VFormula VToolLinePoint::getFormulaLength() const } //--------------------------------------------------------------------------------------------------------------------- -void VToolLinePoint::setFormulaLength(const VFormula &value) +void VToolLinePoint::SetFormulaLength(const VFormula &value) { if (value.error() == false) { - formulaLength = value.getFormula(FormulaType::FromUser); + formulaLength = value.GetFormula(FormulaType::FromUser); QSharedPointer obj = VAbstractTool::data.GetGObject(id); SaveOption(obj); diff --git a/src/app/tools/drawTools/vtoollinepoint.h b/src/app/tools/drawTools/vtoollinepoint.h index 3c29e248e..eded33065 100644 --- a/src/app/tools/drawTools/vtoollinepoint.h +++ b/src/app/tools/drawTools/vtoollinepoint.h @@ -39,23 +39,24 @@ class VToolLinePoint : public VToolPoint { Q_OBJECT public: - VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula, + VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &lineColor, const QString &formula, const quint32 &basePointId, const qreal &angle, QGraphicsItem * parent = nullptr); virtual ~VToolLinePoint(); virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::LinePoint)}; - VFormula getFormulaLength() const; - void setFormulaLength(const VFormula &value); + VFormula GetFormulaLength() const; + void SetFormulaLength(const VFormula &value); - quint32 getBasePointId() const; - void setBasePointId(const quint32 &value); + quint32 GetBasePointId() const; + void SetBasePointId(const quint32 &value); - qreal getAngle() const; - void setAngle(const qreal &value); + qreal GetAngle() const; + void SetAngle(const qreal &value); public slots: virtual void ChangedActivDraw(const QString &newName); virtual void SetFactor(qreal factor); + void Disable(bool disable); protected: /** @brief formula string with length formula. */ QString formulaLength; diff --git a/src/app/tools/drawTools/vtoolnormal.cpp b/src/app/tools/drawTools/vtoolnormal.cpp index c4d9f9268..2a083aaa4 100644 --- a/src/app/tools/drawTools/vtoolnormal.cpp +++ b/src/app/tools/drawTools/vtoolnormal.cpp @@ -49,9 +49,10 @@ const QString VToolNormal::ToolType = QStringLiteral("normal"); * @param parent parent object. */ VToolNormal::VToolNormal(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, - const QString &formula, const qreal &angle, const quint32 &firstPointId, - const quint32 &secondPointId, const Source &typeCreation, QGraphicsItem *parent) - :VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, angle, parent), + const QString &lineColor, const QString &formula, const qreal &angle, + const quint32 &firstPointId, const quint32 &secondPointId, const Source &typeCreation, + QGraphicsItem *parent) + :VToolLinePoint(doc, data, id, typeLine, lineColor, formula, firstPointId, angle, parent), secondPointId(secondPointId) { @@ -75,12 +76,12 @@ void VToolNormal::setDialog() DialogNormal *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); const QSharedPointer p = VAbstractTool::data.GeometricObject(id); - dialogTool->setTypeLine(typeLine); - dialogTool->setFormula(formulaLength); - dialogTool->setAngle(angle); - dialogTool->setFirstPointId(basePointId); - dialogTool->setSecondPointId(secondPointId); - dialogTool->setPointName(p->name()); + dialogTool->SetTypeLine(typeLine); + dialogTool->SetFormula(formulaLength); + dialogTool->SetAngle(angle); + dialogTool->SetFirstPointId(basePointId); + dialogTool->SetSecondPointId(secondPointId); + dialogTool->SetPointName(p->name()); } //--------------------------------------------------------------------------------------------------------------------- @@ -96,15 +97,16 @@ VToolNormal* VToolNormal::Create(DialogTool *dialog, VMainGraphicsScene *scene, SCASSERT(dialog != nullptr); DialogNormal *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - QString formula = dialogTool->getFormula(); - const quint32 firstPointId = dialogTool->getFirstPointId(); - const quint32 secondPointId = dialogTool->getSecondPointId(); - const QString typeLine = dialogTool->getTypeLine(); + QString formula = dialogTool->GetFormula(); + const quint32 firstPointId = dialogTool->GetFirstPointId(); + const quint32 secondPointId = dialogTool->GetSecondPointId(); + const QString typeLine = dialogTool->GetTypeLine(); + const QString lineColor = dialogTool->GetLineColor(); const QString pointName = dialogTool->getPointName(); - const qreal angle = dialogTool->getAngle(); + const qreal angle = dialogTool->GetAngle(); VToolNormal *point = nullptr; - point=Create(0, formula, firstPointId, secondPointId, typeLine, pointName, angle, 5, 10, scene, doc, data, - Document::FullParse, Source::FromGui); + point=Create(0, formula, firstPointId, secondPointId, typeLine, lineColor, pointName, angle, 5, 10, scene, doc, + data, Document::FullParse, Source::FromGui); if (point != nullptr) { point->dialog=dialogTool; @@ -131,10 +133,10 @@ VToolNormal* VToolNormal::Create(DialogTool *dialog, VMainGraphicsScene *scene, * @param typeCreation way we create this tool. */ VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quint32 &firstPointId, - const quint32 &secondPointId, const QString &typeLine, const QString &pointName, - const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, - VPattern *doc, VContainer *data, const Document &parse, - const Source &typeCreation) + const quint32 &secondPointId, const QString &typeLine, const QString &lineColor, + const QString &pointName, const qreal angle, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation) { const QSharedPointer firstPoint = data->GeometricObject(firstPointId); const QSharedPointer secondPoint = data->GeometricObject(secondPointId); @@ -161,12 +163,12 @@ VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quin VDrawTool::AddRecord(id, Tool::Normal, doc); if (parse == Document::FullParse) { - VToolNormal *point = new VToolNormal(doc, data, id, typeLine, formula, angle, - firstPointId, secondPointId, typeCreation); + VToolNormal *point = new VToolNormal(doc, data, id, typeLine, lineColor, formula, angle, firstPointId, + secondPointId, typeCreation); scene->addItem(point); connect(point, &VToolNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolNormal::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolNormal::Disable); doc->AddTool(id, point); doc->IncrementReferens(firstPointId); doc->IncrementReferens(secondPointId); @@ -200,15 +202,7 @@ QPointF VToolNormal::FindPoint(const QPointF &firstPoint, const QPointF &secondP */ void VToolNormal::FullUpdateFromFile() { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - typeLine = domElement.attribute(AttrTypeLine, ""); - formulaLength = domElement.attribute(AttrLength, ""); - basePointId = domElement.attribute(AttrFirstPoint, "").toUInt(); - secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt(); - angle = domElement.attribute(AttrAngle, "").toDouble(); - } + ReadAttributes(); RefreshGeometry(); if (vis != nullptr) @@ -217,7 +211,7 @@ void VToolNormal::FullUpdateFromFile() visual->setPoint1Id(basePointId); visual->setPoint2Id(secondPointId); visual->setLength(qApp->FormulaToUser(formulaLength)); - visual->setAngle(angle); + visual->SetAngle(angle); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); visual->RefreshGeometry(); } @@ -274,11 +268,12 @@ void VToolNormal::SaveDialog(QDomElement &domElement) DialogNormal *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); - doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); - doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); - doc->SetAttribute(domElement, AttrAngle, QString().setNum(dialogTool->getAngle())); - doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId())); - doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); + doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); + doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); + doc->SetAttribute(domElement, AttrAngle, QString().setNum(dialogTool->GetAngle())); + doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPointId())); + doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPointId())); } //--------------------------------------------------------------------------------------------------------------------- @@ -294,6 +289,7 @@ void VToolNormal::SaveOptions(QDomElement &tag, QSharedPointer &obj) doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrTypeLine, typeLine); + doc->SetAttribute(tag, AttrLineColor, lineColor); doc->SetAttribute(tag, AttrLength, formulaLength); doc->SetAttribute(tag, AttrAngle, angle); doc->SetAttribute(tag, AttrFirstPoint, basePointId); @@ -301,13 +297,24 @@ void VToolNormal::SaveOptions(QDomElement &tag, QSharedPointer &obj) } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolNormal::getSecondPointId() const +void VToolNormal::ReadToolAttributes(const QDomElement &domElement) +{ + typeLine = doc->GetParametrString(domElement, AttrTypeLine, TypeLineLine); + lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack); + formulaLength = doc->GetParametrString(domElement, AttrLength, ""); + basePointId = doc->GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR); + secondPointId = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR); + angle = doc->GetParametrDouble(domElement, AttrAngle, "0"); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolNormal::GetSecondPointId() const { return secondPointId; } //--------------------------------------------------------------------------------------------------------------------- -void VToolNormal::setSecondPointId(const quint32 &value) +void VToolNormal::SetSecondPointId(const quint32 &value) { if (value != NULL_ID) { @@ -333,7 +340,7 @@ void VToolNormal::ShowVisualization(bool show) visual->setPoint1Id(basePointId); visual->setPoint2Id(secondPointId); visual->setLength(qApp->FormulaToUser(formulaLength)); - visual->setAngle(angle); + visual->SetAngle(angle); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); visual->RefreshGeometry(); vis = visual; diff --git a/src/app/tools/drawTools/vtoolnormal.h b/src/app/tools/drawTools/vtoolnormal.h index 3c85cb439..6595e895e 100644 --- a/src/app/tools/drawTools/vtoolnormal.h +++ b/src/app/tools/drawTools/vtoolnormal.h @@ -38,23 +38,24 @@ class VToolNormal : public VToolLinePoint { Q_OBJECT public: - VToolNormal(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula, - const qreal &angle, const quint32 &firstPointId, const quint32 &secondPointId, + VToolNormal(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &lineColor, + const QString &formula, const qreal &angle, const quint32 &firstPointId, const quint32 &secondPointId, const Source &typeCreation, QGraphicsItem * parent = nullptr); virtual void setDialog(); static VToolNormal* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolNormal* Create(const quint32 _id, QString &formula, const quint32 &firstPointId, - const quint32 &secondPointId, const QString &typeLine, const QString &pointName, - const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, - VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); + const quint32 &secondPointId, const QString &typeLine, const QString &lineColor, + const QString &pointName, const qreal angle, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation); static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const qreal &length, const qreal &angle = 0); static const QString ToolType; virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::Normal)}; - quint32 getSecondPointId() const; - void setSecondPointId(const quint32 &value); + quint32 GetSecondPointId() const; + void SetSecondPointId(const quint32 &value); virtual void ShowVisualization(bool show); public slots: @@ -66,6 +67,7 @@ protected: virtual void RemoveReferens(); virtual void SaveDialog(QDomElement &domElement); virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); + virtual void ReadToolAttributes(const QDomElement &domElement); private: /** @brief secondPointId id second line point. */ quint32 secondPointId; diff --git a/src/app/tools/drawTools/vtoolpoint.cpp b/src/app/tools/drawTools/vtoolpoint.cpp index 53025c402..d082ddd20 100644 --- a/src/app/tools/drawTools/vtoolpoint.cpp +++ b/src/app/tools/drawTools/vtoolpoint.cpp @@ -50,9 +50,7 @@ VToolPoint::VToolPoint(VPattern *doc, VContainer *data, quint32 id, QGraphicsIte namePoint = new VGraphicsSimpleTextItem(this); connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, &VToolPoint::ShowContextMenu); connect(namePoint, &VGraphicsSimpleTextItem::DeleteTool, this, &VToolPoint::DeleteFromLabel); - namePoint->setBrush(Qt::black); lineName = new QGraphicsLineItem(this); - lineName->setPen(QPen(Qt::black)); connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VToolPoint::NameChangePosition); this->setBrush(QBrush(Qt::NoBrush)); this->setFlag(QGraphicsItem::ItemIsSelectable, true); @@ -134,23 +132,18 @@ void VToolPoint::UpdateNamePosition(qreal mx, qreal my) */ void VToolPoint::ChangedActivDraw(const QString &newName) { - VDrawTool::ChangedActivDraw(newName); - this->setEnabled(nameActivDraw == newName); - namePoint->setBrush(QBrush(currentColor)); - lineName->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); - this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); + Disable(!(nameActivDraw == newName)); } //--------------------------------------------------------------------------------------------------------------------- /** * @brief ShowTool highlight tool. * @param id object id in container. - * @param color highlight color. * @param enable enable or disable highlight. */ -void VToolPoint::ShowTool(quint32 id, Qt::GlobalColor color, bool enable) +void VToolPoint::ShowTool(quint32 id, bool enable) { - ShowItem(this, id, color, enable); + ShowItem(this, id, enable); } //--------------------------------------------------------------------------------------------------------------------- @@ -177,7 +170,9 @@ void VToolPoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event) //--------------------------------------------------------------------------------------------------------------------- void VToolPoint::Disable(bool disable) { - DisableItem(this, disable); + enabled = !disable; + this->setEnabled(enabled); + namePoint->setEnabled(enabled); } //--------------------------------------------------------------------------------------------------------------------- @@ -208,7 +203,7 @@ void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void VToolPoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthMainLine())/factor)); + this->setPen(QPen(CorrectColor(baseColor), qApp->toPixel(qApp->widthMainLine())/factor)); QGraphicsEllipseItem::hoverEnterEvent(event); } @@ -220,7 +215,7 @@ void VToolPoint::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); + this->setPen(QPen(CorrectColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor)); } //--------------------------------------------------------------------------------------------------------------------- @@ -231,7 +226,7 @@ void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) void VToolPoint::RefreshPointGeometry(const VPointF &point) { this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); - this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); + this->setPen(QPen(CorrectColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor)); QRectF rec = QRectF(0, 0, radius*2, radius*2); rec.translate(-rec.center().x(), -rec.center().y()); this->setRect(rec); @@ -263,14 +258,7 @@ void VToolPoint::RefreshLine() VGObject::LineIntersectCircle(QPointF(), radius, QLineF(QPointF(), nameRec.center() - scenePos()), p1, p2); QPointF pRec = VGObject::LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center())); lineName->setLine(QLineF(p1, pRec - scenePos())); - if (currentColor == Qt::gray) - { - lineName->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); - } - else - { - lineName->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor)); - } + lineName->setPen(QPen(CorrectColor(Qt::black), qApp->toPixel(qApp->widthHairLine())/factor)); if (QLineF(p1, pRec - scenePos()).length() <= qApp->toPixel(4, Unit::Mm)) { @@ -329,3 +317,17 @@ void VToolPoint::keyReleaseEvent(QKeyEvent *event) } QGraphicsEllipseItem::keyReleaseEvent ( event ); } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolPoint::setEnabled(bool enabled) +{ + QGraphicsEllipseItem::setEnabled(enabled); + if (enabled) + { + setPen(QPen(QColor(baseColor), qApp->toPixel(qApp->widthHairLine())/factor)); + } + else + { + setPen(QPen(Qt::gray, qApp->toPixel(qApp->widthHairLine())/factor)); + } +} diff --git a/src/app/tools/drawTools/vtoolpoint.h b/src/app/tools/drawTools/vtoolpoint.h index 218753e31..e0c0c52d5 100644 --- a/src/app/tools/drawTools/vtoolpoint.h +++ b/src/app/tools/drawTools/vtoolpoint.h @@ -49,10 +49,12 @@ public: void setName(const QString &name); virtual QString getTagName() const; static const QString TagName; + + void setEnabled(bool enabled); public slots: void NameChangePosition(const QPointF &pos); virtual void ChangedActivDraw(const QString &newName); - virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); + virtual void ShowTool(quint32 id, bool enable); virtual void SetFactor(qreal factor); virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); void Disable(bool disable); diff --git a/src/app/tools/drawTools/vtoolpointofcontact.cpp b/src/app/tools/drawTools/vtoolpointofcontact.cpp index 96e4eabe7..37042dcf6 100644 --- a/src/app/tools/drawTools/vtoolpointofcontact.cpp +++ b/src/app/tools/drawTools/vtoolpointofcontact.cpp @@ -78,9 +78,9 @@ void VToolPointOfContact::setDialog() const QSharedPointer p = VAbstractTool::data.GeometricObject(id); dialogTool->setRadius(arcRadius); dialogTool->setCenter(center); - dialogTool->setFirstPoint(firstPointId); - dialogTool->setSecondPoint(secondPointId); - dialogTool->setPointName(p->name()); + dialogTool->SetFirstPoint(firstPointId); + dialogTool->SetSecondPoint(secondPointId); + dialogTool->SetPointName(p->name()); } //--------------------------------------------------------------------------------------------------------------------- @@ -138,8 +138,8 @@ VToolPointOfContact* VToolPointOfContact::Create(DialogTool *dialog, VMainGraphi SCASSERT(dialogTool != nullptr); QString radius = dialogTool->getRadius(); const quint32 center = dialogTool->getCenter(); - const quint32 firstPointId = dialogTool->getFirstPoint(); - const quint32 secondPointId = dialogTool->getSecondPoint(); + const quint32 firstPointId = dialogTool->GetFirstPoint(); + const quint32 secondPointId = dialogTool->GetSecondPoint(); const QString pointName = dialogTool->getPointName(); VToolPointOfContact *point = nullptr; point=Create(0, radius, center, firstPointId, secondPointId, pointName, 5, 10, scene, doc, data, @@ -209,7 +209,7 @@ VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &rad scene->addItem(point); connect(point, &VToolPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfContact::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointOfContact::Disable); doc->AddTool(id, point); doc->IncrementReferens(center); doc->IncrementReferens(firstPointId); @@ -225,14 +225,7 @@ VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &rad */ void VToolPointOfContact::FullUpdateFromFile() { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - arcRadius = domElement.attribute(AttrRadius, ""); - center = domElement.attribute(AttrCenter, "").toUInt(); - firstPointId = domElement.attribute(AttrFirstPoint, "").toUInt(); - secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt(); - } + ReadAttributes(); RefreshPointGeometry(*VAbstractTool::data.GeometricObject(id)); if (vis != nullptr) @@ -300,8 +293,8 @@ void VToolPointOfContact::SaveDialog(QDomElement &domElement) doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrRadius, dialogTool->getRadius()); doc->SetAttribute(domElement, AttrCenter, QString().setNum(dialogTool->getCenter())); - doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPoint())); - doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPoint())); + doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPoint())); + doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPoint())); } //--------------------------------------------------------------------------------------------------------------------- @@ -323,13 +316,22 @@ void VToolPointOfContact::SaveOptions(QDomElement &tag, QSharedPointer } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolPointOfContact::getSecondPointId() const +void VToolPointOfContact::ReadToolAttributes(const QDomElement &domElement) +{ + arcRadius = doc->GetParametrString(domElement, AttrRadius, ""); + center = doc->GetParametrUInt(domElement, AttrCenter, NULL_ID_STR); + firstPointId = doc->GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR); + secondPointId = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolPointOfContact::GetSecondPointId() const { return secondPointId; } //--------------------------------------------------------------------------------------------------------------------- -void VToolPointOfContact::setSecondPointId(const quint32 &value) +void VToolPointOfContact::SetSecondPointId(const quint32 &value) { secondPointId = value; } @@ -370,13 +372,13 @@ void VToolPointOfContact::ShowVisualization(bool show) } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolPointOfContact::getFirstPointId() const +quint32 VToolPointOfContact::GetFirstPointId() const { return firstPointId; } //--------------------------------------------------------------------------------------------------------------------- -void VToolPointOfContact::setFirstPointId(const quint32 &value) +void VToolPointOfContact::SetFirstPointId(const quint32 &value) { firstPointId = value; } @@ -415,7 +417,7 @@ void VToolPointOfContact::setArcRadius(const VFormula &value) { if (value.error() == false) { - arcRadius = value.getFormula(FormulaType::FromUser); + arcRadius = value.GetFormula(FormulaType::FromUser); QSharedPointer obj = VAbstractTool::data.GetGObject(id); SaveOption(obj); diff --git a/src/app/tools/drawTools/vtoolpointofcontact.h b/src/app/tools/drawTools/vtoolpointofcontact.h index 1cbc84815..5f4e13053 100644 --- a/src/app/tools/drawTools/vtoolpointofcontact.h +++ b/src/app/tools/drawTools/vtoolpointofcontact.h @@ -62,11 +62,11 @@ public: quint32 getCenter() const; void setCenter(const quint32 &value); - quint32 getFirstPointId() const; - void setFirstPointId(const quint32 &value); + quint32 GetFirstPointId() const; + void SetFirstPointId(const quint32 &value); - quint32 getSecondPointId() const; - void setSecondPointId(const quint32 &value); + quint32 GetSecondPointId() const; + void SetSecondPointId(const quint32 &value); virtual void ShowVisualization(bool show); public slots: @@ -78,6 +78,7 @@ protected: virtual void RemoveReferens(); virtual void SaveDialog(QDomElement &domElement); virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); + virtual void ReadToolAttributes(const QDomElement &domElement); private: /** @brief radius string with formula radius arc. */ QString arcRadius; diff --git a/src/app/tools/drawTools/vtoolpointofintersection.cpp b/src/app/tools/drawTools/vtoolpointofintersection.cpp index 52ef71132..e67ee2110 100644 --- a/src/app/tools/drawTools/vtoolpointofintersection.cpp +++ b/src/app/tools/drawTools/vtoolpointofintersection.cpp @@ -70,9 +70,9 @@ void VToolPointOfIntersection::setDialog() DialogPointOfIntersection *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); const QSharedPointer p = VAbstractTool::data.GeometricObject(id); - dialogTool->setFirstPointId(firstPointId); - dialogTool->setSecondPointId(secondPointId); - dialogTool->setPointName(p->name()); + dialogTool->SetFirstPointId(firstPointId); + dialogTool->SetSecondPointId(secondPointId); + dialogTool->SetPointName(p->name()); } //--------------------------------------------------------------------------------------------------------------------- @@ -90,8 +90,8 @@ VToolPointOfIntersection *VToolPointOfIntersection::Create(DialogTool *dialog, V SCASSERT(dialog != nullptr); DialogPointOfIntersection *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - const quint32 firstPointId = dialogTool->getFirstPointId(); - const quint32 secondPointId = dialogTool->getSecondPointId(); + const quint32 firstPointId = dialogTool->GetFirstPointId(); + const quint32 secondPointId = dialogTool->GetSecondPointId(); const QString pointName = dialogTool->getPointName(); VToolPointOfIntersection *point = nullptr; point = Create(0, pointName, firstPointId, secondPointId, 5, 10, scene, doc, data, Document::FullParse, @@ -150,7 +150,7 @@ VToolPointOfIntersection *VToolPointOfIntersection::Create(const quint32 _id, co scene->addItem(point); connect(point, &VToolPointOfIntersection::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfIntersection::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointOfIntersection::Disable); doc->AddTool(id, point); doc->IncrementReferens(firstPointId); doc->IncrementReferens(secondPointId); @@ -165,12 +165,7 @@ VToolPointOfIntersection *VToolPointOfIntersection::Create(const quint32 _id, co */ void VToolPointOfIntersection::FullUpdateFromFile() { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - firstPointId = domElement.attribute(AttrFirstPoint, "").toUInt(); - secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt(); - } + ReadAttributes(); VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); if (vis != nullptr) @@ -222,8 +217,8 @@ void VToolPointOfIntersection::SaveDialog(QDomElement &domElement) DialogPointOfIntersection *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); - doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId())); - doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); + doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPointId())); + doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPointId())); } //--------------------------------------------------------------------------------------------------------------------- @@ -243,13 +238,20 @@ void VToolPointOfIntersection::SaveOptions(QDomElement &tag, QSharedPointerGetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR); + secondPointId = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolPointOfIntersection::GetSecondPointId() const { return secondPointId; } //--------------------------------------------------------------------------------------------------------------------- -void VToolPointOfIntersection::setSecondPointId(const quint32 &value) +void VToolPointOfIntersection::SetSecondPointId(const quint32 &value) { if (value != NULL_ID) { @@ -294,13 +296,13 @@ void VToolPointOfIntersection::ShowVisualization(bool show) } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolPointOfIntersection::getFirstPointId() const +quint32 VToolPointOfIntersection::GetFirstPointId() const { return firstPointId; } //--------------------------------------------------------------------------------------------------------------------- -void VToolPointOfIntersection::setFirstPointId(const quint32 &value) +void VToolPointOfIntersection::SetFirstPointId(const quint32 &value) { if (value != NULL_ID) { diff --git a/src/app/tools/drawTools/vtoolpointofintersection.h b/src/app/tools/drawTools/vtoolpointofintersection.h index 80e2980de..876c475bf 100644 --- a/src/app/tools/drawTools/vtoolpointofintersection.h +++ b/src/app/tools/drawTools/vtoolpointofintersection.h @@ -52,11 +52,11 @@ public: virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::PointOfIntersection) }; - quint32 getFirstPointId() const; - void setFirstPointId(const quint32 &value); + quint32 GetFirstPointId() const; + void SetFirstPointId(const quint32 &value); - quint32 getSecondPointId() const; - void setSecondPointId(const quint32 &value); + quint32 GetSecondPointId() const; + void SetSecondPointId(const quint32 &value); virtual void ShowVisualization(bool show); public slots: @@ -67,6 +67,7 @@ protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void SaveDialog(QDomElement &domElement); virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); + virtual void ReadToolAttributes(const QDomElement &domElement); private: Q_DISABLE_COPY(VToolPointOfIntersection) /** @brief firstPointId id first line point. */ diff --git a/src/app/tools/drawTools/vtoolshoulderpoint.cpp b/src/app/tools/drawTools/vtoolshoulderpoint.cpp index 312aa5d9d..540f474ea 100644 --- a/src/app/tools/drawTools/vtoolshoulderpoint.cpp +++ b/src/app/tools/drawTools/vtoolshoulderpoint.cpp @@ -49,10 +49,11 @@ const QString VToolShoulderPoint::ToolType = QStringLiteral("shoulder"); * @param parent parent object. */ VToolShoulderPoint::VToolShoulderPoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, - const QString &formula, const quint32 &p1Line, const quint32 &p2Line, - const quint32 &pShoulder, const Source &typeCreation, + const QString &lineColor, const QString &formula, const quint32 &p1Line, + const quint32 &p2Line, const quint32 &pShoulder, const Source &typeCreation, QGraphicsItem * parent) - :VToolLinePoint(doc, data, id, typeLine, formula, p1Line, 0, parent), p2Line(p2Line), pShoulder(pShoulder) + :VToolLinePoint(doc, data, id, typeLine, lineColor, formula, p1Line, 0, parent), p2Line(p2Line), + pShoulder(pShoulder) { if (typeCreation == Source::FromGui) { @@ -74,12 +75,13 @@ void VToolShoulderPoint::setDialog() DialogShoulderPoint *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); const QSharedPointer p = VAbstractTool::data.GeometricObject(id); - dialogTool->setTypeLine(typeLine); - dialogTool->setFormula(formulaLength); - dialogTool->setP1Line(basePointId); - dialogTool->setP2Line(p2Line); - dialogTool->setP3(pShoulder); - dialogTool->setPointName(p->name()); + dialogTool->SetTypeLine(typeLine); + dialogTool->SetLineColor(lineColor); + dialogTool->SetFormula(formulaLength); + dialogTool->SetP1Line(basePointId); + dialogTool->SetP2Line(p2Line); + dialogTool->SetP3(pShoulder); + dialogTool->SetPointName(p->name()); } //--------------------------------------------------------------------------------------------------------------------- @@ -134,15 +136,16 @@ VToolShoulderPoint* VToolShoulderPoint::Create(DialogTool *dialog, VMainGraphics SCASSERT(dialog != nullptr); DialogShoulderPoint *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool); - QString formula = dialogTool->getFormula(); - const quint32 p1Line = dialogTool->getP1Line(); - const quint32 p2Line = dialogTool->getP2Line(); - const quint32 pShoulder = dialogTool->getP3(); - const QString typeLine = dialogTool->getTypeLine(); + QString formula = dialogTool->GetFormula(); + const quint32 p1Line = dialogTool->GetP1Line(); + const quint32 p2Line = dialogTool->GetP2Line(); + const quint32 pShoulder = dialogTool->GetP3(); + const QString typeLine = dialogTool->GetTypeLine(); + const QString lineColor = dialogTool->GetLineColor(); const QString pointName = dialogTool->getPointName(); VToolShoulderPoint * point = nullptr; - point=Create(0, formula, p1Line, p2Line, pShoulder, typeLine, pointName, 5, 10, scene, doc, data, - Document::FullParse, Source::FromGui); + point=Create(0, formula, p1Line, p2Line, pShoulder, typeLine, lineColor, pointName, 5, 10, scene, doc, data, + Document::FullParse, Source::FromGui); if (point != nullptr) { point->dialog=dialogTool; @@ -170,7 +173,7 @@ VToolShoulderPoint* VToolShoulderPoint::Create(DialogTool *dialog, VMainGraphics * @return the created tool */ VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formula, const quint32 &p1Line, - const quint32 &p2Line, const quint32 &pShoulder, const QString &typeLine, + const quint32 &p2Line, const quint32 &pShoulder, const QString &typeLine, const QString &lineColor, const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) @@ -203,13 +206,13 @@ VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formu VDrawTool::AddRecord(id, Tool::ShoulderPoint, doc); if (parse == Document::FullParse) { - VToolShoulderPoint *point = new VToolShoulderPoint(doc, data, id, typeLine, formula, + VToolShoulderPoint *point = new VToolShoulderPoint(doc, data, id, typeLine, lineColor, formula, p1Line, p2Line, pShoulder, typeCreation); scene->addItem(point); connect(point, &VToolShoulderPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolShoulderPoint::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolShoulderPoint::Disable); doc->AddTool(id, point); doc->IncrementReferens(p1Line); doc->IncrementReferens(p2Line); @@ -225,15 +228,7 @@ VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formu */ void VToolShoulderPoint::FullUpdateFromFile() { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - typeLine = domElement.attribute(AttrTypeLine, ""); - formulaLength = domElement.attribute(AttrLength, ""); - basePointId = domElement.attribute(AttrP1Line, "").toUInt(); - p2Line = domElement.attribute(AttrP2Line, "").toUInt(); - pShoulder = domElement.attribute(AttrPShoulder, "").toUInt(); - } + ReadAttributes(); RefreshGeometry(); if (vis != nullptr) @@ -300,11 +295,12 @@ void VToolShoulderPoint::SaveDialog(QDomElement &domElement) DialogShoulderPoint *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); - doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); - doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); - doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->getP1Line())); - doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->getP2Line())); - doc->SetAttribute(domElement, AttrPShoulder, QString().setNum(dialogTool->getP3())); + doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine()); + doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor()); + doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula()); + doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->GetP1Line())); + doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->GetP2Line())); + doc->SetAttribute(domElement, AttrPShoulder, QString().setNum(dialogTool->GetP3())); } //--------------------------------------------------------------------------------------------------------------------- @@ -320,12 +316,24 @@ void VToolShoulderPoint::SaveOptions(QDomElement &tag, QSharedPointer doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrTypeLine, typeLine); + doc->SetAttribute(tag, AttrLineColor, lineColor); doc->SetAttribute(tag, AttrLength, formulaLength); doc->SetAttribute(tag, AttrP1Line, basePointId); doc->SetAttribute(tag, AttrP2Line, p2Line); doc->SetAttribute(tag, AttrPShoulder, pShoulder); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolShoulderPoint::ReadToolAttributes(const QDomElement &domElement) +{ + typeLine = doc->GetParametrString(domElement, AttrTypeLine, TypeLineLine); + lineColor = doc->GetParametrString(domElement, AttrLineColor, ColorBlack); + formulaLength = doc->GetParametrString(domElement, AttrLength, ""); + basePointId = doc->GetParametrUInt(domElement, AttrP1Line, NULL_ID_STR); + p2Line = doc->GetParametrUInt(domElement, AttrP2Line, NULL_ID_STR); + pShoulder = doc->GetParametrUInt(domElement, AttrPShoulder, NULL_ID_STR); +} + //--------------------------------------------------------------------------------------------------------------------- quint32 VToolShoulderPoint::getPShoulder() const { @@ -381,13 +389,13 @@ void VToolShoulderPoint::ShowVisualization(bool show) } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolShoulderPoint::getP2Line() const +quint32 VToolShoulderPoint::GetP2Line() const { return p2Line; } //--------------------------------------------------------------------------------------------------------------------- -void VToolShoulderPoint::setP2Line(const quint32 &value) +void VToolShoulderPoint::SetP2Line(const quint32 &value) { if (value != NULL_ID) { diff --git a/src/app/tools/drawTools/vtoolshoulderpoint.h b/src/app/tools/drawTools/vtoolshoulderpoint.h index ef8c08df6..1af8391b4 100644 --- a/src/app/tools/drawTools/vtoolshoulderpoint.h +++ b/src/app/tools/drawTools/vtoolshoulderpoint.h @@ -40,22 +40,23 @@ class VToolShoulderPoint : public VToolLinePoint Q_OBJECT public: VToolShoulderPoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, - const QString &formula, const quint32 &p1Line, const quint32 &p2Line, const quint32 &pShoulder, - const Source &typeCreation, QGraphicsItem * parent = nullptr); + const QString &lineColor, const QString &formula, const quint32 &p1Line, const quint32 &p2Line, + const quint32 &pShoulder, const Source &typeCreation, QGraphicsItem * parent = nullptr); virtual void setDialog(); static QPointF FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder, const qreal &length); static VToolShoulderPoint* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolShoulderPoint* Create(const quint32 _id, QString &formula, const quint32 &p1Line, const quint32 &p2Line, - const quint32 &pShoulder, const QString &typeLine, const QString &pointName, - const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document &parse, const Source &typeCreation); + const quint32 &pShoulder, const QString &typeLine, const QString &lineColor, + const QString &pointName, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation); static const QString ToolType; virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::ShoulderPoint) }; - quint32 getP2Line() const; - void setP2Line(const quint32 &value); + quint32 GetP2Line() const; + void SetP2Line(const quint32 &value); quint32 getPShoulder() const; void setPShoulder(const quint32 &value); @@ -70,6 +71,7 @@ protected: virtual void RemoveReferens(); virtual void SaveDialog(QDomElement &domElement); virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); + virtual void ReadToolAttributes(const QDomElement &domElement); private: /** @brief p2Line id second line point. */ quint32 p2Line; diff --git a/src/app/tools/drawTools/vtoolsinglepoint.cpp b/src/app/tools/drawTools/vtoolsinglepoint.cpp index a90ed60da..003d7b3a5 100644 --- a/src/app/tools/drawTools/vtoolsinglepoint.cpp +++ b/src/app/tools/drawTools/vtoolsinglepoint.cpp @@ -52,13 +52,12 @@ VToolSinglePoint::VToolSinglePoint (VPattern *doc, VContainer *data, quint32 id, :VToolPoint(doc, data, id, parent), namePP(namePP), mPath(mPath) { baseColor = Qt::red; - currentColor = baseColor; - this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); + this->setPen(QPen(baseColor, qApp->toPixel(qApp->widthHairLine())/factor)); ignoreFullUpdate = true; this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); this->setFlag(QGraphicsItem::ItemIsFocusable, false); - setColorLabel(Qt::black); + SetColorLabel(Qt::black); if (typeCreation == Source::FromGui) { AddToFile(); @@ -79,7 +78,7 @@ void VToolSinglePoint::setDialog() DialogSinglePoint *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); const QSharedPointer p = VAbstractTool::data.GeometricObject(id); - dialogTool->setData(p->name(), p->toQPointF()); + dialogTool->SetData(p->name(), p->toQPointF()); } //--------------------------------------------------------------------------------------------------------------------- @@ -194,8 +193,8 @@ void VToolSinglePoint::SaveDialog(QDomElement &domElement) SCASSERT(dialog != nullptr); DialogSinglePoint *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - QPointF p = dialogTool->getPoint(); - QString name = dialogTool->getName(); + QPointF p = dialogTool->GetPoint(); + QString name = dialogTool->getPointName(); doc->SetAttribute(domElement, AttrName, name); doc->SetAttribute(domElement, AttrX, QString().setNum(qApp->fromPixel(p.x()))); doc->SetAttribute(domElement, AttrY, QString().setNum(qApp->fromPixel(p.y()))); @@ -241,10 +240,10 @@ void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) //--------------------------------------------------------------------------------------------------------------------- /** - * @brief setColorLabel change color for label and label line. + * @brief SetColorLabel change color for label and label line. * @param color new color. */ -void VToolSinglePoint::setColorLabel(const Qt::GlobalColor &color) +void VToolSinglePoint::SetColorLabel(const Qt::GlobalColor &color) { namePoint->setBrush(color); lineName->setPen(QPen(color, qApp->toPixel(qApp->widthHairLine())/factor)); @@ -265,6 +264,13 @@ void VToolSinglePoint::SaveOptions(QDomElement &tag, QSharedPointer &o doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSinglePoint::ReadToolAttributes(const QDomElement &domElement) +{ + Q_UNUSED(domElement); + // This tool doesn't need read attributes from file. +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief contextMenuEvent handle context menu events. @@ -299,26 +305,6 @@ void VToolSinglePoint::FullUpdateFromFile() RefreshPointGeometry(point); } -//--------------------------------------------------------------------------------------------------------------------- -/** - * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. - * @param newName new name active pattern peace. - */ -void VToolSinglePoint::ChangedActivDraw(const QString &newName) -{ - VToolPoint::ChangedActivDraw(newName); - if (nameActivDraw == newName) - { - this->setEnabled(true); - setColorLabel(Qt::black); - } - else - { - this->setEnabled(false); - setColorLabel(Qt::gray); - } -} - //--------------------------------------------------------------------------------------------------------------------- /** * @brief SetFactor set current scale factor of scene. diff --git a/src/app/tools/drawTools/vtoolsinglepoint.h b/src/app/tools/drawTools/vtoolsinglepoint.h index 2e9aa14f1..833365a9b 100644 --- a/src/app/tools/drawTools/vtoolsinglepoint.h +++ b/src/app/tools/drawTools/vtoolsinglepoint.h @@ -48,7 +48,6 @@ public: virtual void ShowVisualization(bool show); public slots: virtual void FullUpdateFromFile(); - virtual void ChangedActivDraw(const QString &newName); virtual void SetFactor(qreal factor); virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); signals: @@ -68,10 +67,11 @@ protected: virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); + virtual void ReadToolAttributes(const QDomElement &domElement); private: QString namePP; QString mPath; - void setColorLabel(const Qt::GlobalColor & color); + void SetColorLabel(const Qt::GlobalColor & color); }; diff --git a/src/app/tools/drawTools/vtoolspline.cpp b/src/app/tools/drawTools/vtoolspline.cpp index 96eddc313..ce50c27a0 100644 --- a/src/app/tools/drawTools/vtoolspline.cpp +++ b/src/app/tools/drawTools/vtoolspline.cpp @@ -43,11 +43,12 @@ const QString VToolSpline::ToolType = QStringLiteral("simple"); * @param typeCreation way we create this tool. * @param parent parent object. */ -VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, +VToolSpline::VToolSpline(VPattern *doc, VContainer *data, quint32 id, const QString color, const Source &typeCreation, QGraphicsItem *parent) :VAbstractSpline(doc, data, id, parent) { sceneType = SceneObject::Spline; + lineColor = color; this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor)); this->setFlag(QGraphicsItem::ItemIsSelectable, true); @@ -98,13 +99,14 @@ void VToolSpline::setDialog() DialogSpline *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); const QSharedPointer spl = VAbstractTool::data.GeometricObject(id); - dialogTool->setP1(spl->GetP1().id()); - dialogTool->setP4(spl->GetP4().id()); - dialogTool->setAngle1(spl->GetAngle1()); - dialogTool->setAngle2(spl->GetAngle2()); - dialogTool->setKAsm1(spl->GetKasm1()); - dialogTool->setKAsm2(spl->GetKasm2()); - dialogTool->setKCurve(spl->GetKcurve()); + dialogTool->SetP1(spl->GetP1().id()); + dialogTool->SetP4(spl->GetP4().id()); + dialogTool->SetAngle1(spl->GetAngle1()); + dialogTool->SetAngle2(spl->GetAngle2()); + dialogTool->SetKAsm1(spl->GetKasm1()); + dialogTool->SetKAsm2(spl->GetKasm2()); + dialogTool->SetKCurve(spl->GetKcurve()); + dialogTool->SetColor(lineColor); } //--------------------------------------------------------------------------------------------------------------------- @@ -121,15 +123,16 @@ VToolSpline* VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, SCASSERT(dialog != nullptr); DialogSpline *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - const quint32 p1 = dialogTool->getP1(); - const quint32 p4 = dialogTool->getP4(); - const qreal kAsm1 = dialogTool->getKAsm1(); - const qreal kAsm2 = dialogTool->getKAsm2(); - const qreal angle1 = dialogTool->getAngle1(); - const qreal angle2 = dialogTool->getAngle2(); - const qreal kCurve = dialogTool->getKCurve(); + const quint32 p1 = dialogTool->GetP1(); + const quint32 p4 = dialogTool->GetP4(); + const qreal kAsm1 = dialogTool->GetKAsm1(); + const qreal kAsm2 = dialogTool->GetKAsm2(); + const qreal angle1 = dialogTool->GetAngle1(); + const qreal angle2 = dialogTool->GetAngle2(); + const qreal kCurve = dialogTool->GetKCurve(); + const QString color = dialogTool->GetColor(); VToolSpline *spl = nullptr; - spl = Create(0, p1, p4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, doc, data, Document::FullParse, + spl = Create(0, p1, p4, kAsm1, kAsm2, angle1, angle2, kCurve, color, scene, doc, data, Document::FullParse, Source::FromGui); if (spl != nullptr) { @@ -158,7 +161,7 @@ VToolSpline* VToolSpline::Create(DialogTool *dialog, VMainGraphicsScene *scene, */ VToolSpline* VToolSpline::Create(const quint32 _id, const quint32 &p1, const quint32 &p4, const qreal &kAsm1, const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve, - VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const QString &color, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation) { VPointF point1 = *data->GeometricObject(p1); @@ -182,7 +185,7 @@ VToolSpline* VToolSpline::Create(const quint32 _id, const quint32 &p1, const qui VDrawTool::AddRecord(id, Tool::Spline, doc); if (parse == Document::FullParse) { - VToolSpline *spl = new VToolSpline(doc, data, id, typeCreation); + VToolSpline *spl = new VToolSpline(doc, data, id, color, typeCreation); scene->addItem(spl); connect(spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSpline::SetFactor); @@ -225,11 +228,11 @@ void VToolSpline::ShowVisualization(bool show) const QSharedPointer spl = VAbstractTool::data.GeometricObject(id); visual->setPoint1Id(spl->GetP1().id()); visual->setPoint4Id(spl->GetP4().id()); - visual->setAngle1(spl->GetAngle1()); - visual->setAngle2(spl->GetAngle2()); - visual->setKAsm1(spl->GetKasm1()); - visual->setKAsm2(spl->GetKasm2()); - visual->setKCurve(spl->GetKcurve()); + visual->SetAngle1(spl->GetAngle1()); + visual->SetAngle2(spl->GetAngle2()); + visual->SetKAsm1(spl->GetKasm1()); + visual->SetKAsm2(spl->GetKasm2()); + visual->SetKCurve(spl->GetKcurve()); visual->RefreshGeometry(); vis = visual; } @@ -308,10 +311,10 @@ void VToolSpline::SaveDialog(QDomElement &domElement) DialogSpline *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - VPointF point1 = *VAbstractTool::data.GeometricObject(dialogTool->getP1()); - VPointF point4 = *VAbstractTool::data.GeometricObject(dialogTool->getP4()); - VSpline spl = VSpline (point1, point4, dialogTool->getAngle1(), dialogTool->getAngle2(), - dialogTool->getKAsm1(), dialogTool->getKAsm2(), dialogTool->getKCurve()); + VPointF point1 = *VAbstractTool::data.GeometricObject(dialogTool->GetP1()); + VPointF point4 = *VAbstractTool::data.GeometricObject(dialogTool->GetP4()); + VSpline spl = VSpline (point1, point4, dialogTool->GetAngle1(), dialogTool->GetAngle2(), + dialogTool->GetKAsm1(), dialogTool->GetKAsm2(), dialogTool->GetKCurve()); controlPoints[0]->blockSignals(true); controlPoints[1]->blockSignals(true); @@ -322,7 +325,7 @@ void VToolSpline::SaveDialog(QDomElement &domElement) controlPoints[0]->blockSignals(false); controlPoints[1]->blockSignals(false); - spl = VSpline (point1, controlPoints[0]->pos(), controlPoints[1]->pos(), point4, dialogTool->getKCurve()); + spl = VSpline (point1, controlPoints[0]->pos(), controlPoints[1]->pos(), point4, dialogTool->GetKCurve()); doc->SetAttribute(domElement, AttrPoint1, spl.GetP1().id()); doc->SetAttribute(domElement, AttrPoint4, spl.GetP4().id()); @@ -331,6 +334,7 @@ void VToolSpline::SaveDialog(QDomElement &domElement) doc->SetAttribute(domElement, AttrKAsm1, spl.GetKasm1()); doc->SetAttribute(domElement, AttrKAsm2, spl.GetKasm2()); doc->SetAttribute(domElement, AttrKCurve, spl.GetKcurve()); + doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor()); } //--------------------------------------------------------------------------------------------------------------------- @@ -348,6 +352,7 @@ void VToolSpline::SaveOptions(QDomElement &tag, QSharedPointer &obj) doc->SetAttribute(tag, AttrKAsm1, spl->GetKasm1()); doc->SetAttribute(tag, AttrKAsm2, spl->GetKasm2()); doc->SetAttribute(tag, AttrKCurve, spl->GetKcurve()); + doc->SetAttribute(tag, AttrColor, lineColor); } //--------------------------------------------------------------------------------------------------------------------- @@ -356,7 +361,7 @@ void VToolSpline::SaveOptions(QDomElement &tag, QSharedPointer &obj) */ void VToolSpline::RefreshGeometry() { - //this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor)); + this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor)); if (isHovered) { this->setPath(ToolPath(PathDirection::Show)); @@ -388,11 +393,11 @@ void VToolSpline::RefreshGeometry() VisToolSpline *visual = qobject_cast(vis); visual->setPoint1Id(spl->GetP1().id()); visual->setPoint4Id(spl->GetP4().id()); - visual->setAngle1(spl->GetAngle1()); - visual->setAngle2(spl->GetAngle2()); - visual->setKAsm1(spl->GetKasm1()); - visual->setKAsm2(spl->GetKasm2()); - visual->setKCurve(spl->GetKcurve()); + visual->SetAngle1(spl->GetAngle1()); + visual->SetAngle2(spl->GetAngle2()); + visual->SetKAsm1(spl->GetKasm1()); + visual->SetKAsm2(spl->GetKasm2()); + visual->SetKCurve(spl->GetKcurve()); visual->RefreshGeometry(); } } diff --git a/src/app/tools/drawTools/vtoolspline.h b/src/app/tools/drawTools/vtoolspline.h index 214b14687..b10345fd6 100644 --- a/src/app/tools/drawTools/vtoolspline.h +++ b/src/app/tools/drawTools/vtoolspline.h @@ -38,14 +38,14 @@ class VToolSpline:public VAbstractSpline { Q_OBJECT public: - VToolSpline (VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, + VToolSpline (VPattern *doc, VContainer *data, quint32 id, const QString color, const Source &typeCreation, QGraphicsItem * parent = nullptr ); virtual ~VToolSpline(); virtual void setDialog(); static VToolSpline *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolSpline *Create(const quint32 _id, const quint32 &p1, const quint32 &p4, const qreal &kAsm1, const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve, - VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const QString &color, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); static const QString ToolType; virtual int type() const {return Type;} diff --git a/src/app/tools/drawTools/vtoolsplinepath.cpp b/src/app/tools/drawTools/vtoolsplinepath.cpp index c77576e96..7c82241a8 100644 --- a/src/app/tools/drawTools/vtoolsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolsplinepath.cpp @@ -42,8 +42,8 @@ const QString VToolSplinePath::ToolType = QStringLiteral("path"); * @param typeCreation way we create this tool. * @param parent parent object. */ -VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, - QGraphicsItem *parent) +VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, const QString &color, + const Source &typeCreation, QGraphicsItem *parent) :VAbstractSpline(doc, data, id, parent) { sceneType = SceneObject::SplinePath; @@ -98,6 +98,7 @@ void VToolSplinePath::setDialog() SCASSERT(dialogTool != nullptr); const QSharedPointer splPath = VAbstractTool::data.GeometricObject(id); dialogTool->SetPath(*splPath); + dialogTool->SetColor(lineColor); } //--------------------------------------------------------------------------------------------------------------------- @@ -114,12 +115,13 @@ VToolSplinePath* VToolSplinePath::Create(DialogTool *dialog, VMainGraphicsScene DialogSplinePath *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); VSplinePath *path = new VSplinePath(dialogTool->GetPath()); + const QString color = dialogTool->GetColor(); for (qint32 i = 0; i < path->CountPoint(); ++i) { doc->IncrementReferens((*path)[i].P().id()); } VToolSplinePath* spl = nullptr; - spl = Create(0, path, scene, doc, data, Document::FullParse, Source::FromGui); + spl = Create(0, path, color, scene, doc, data, Document::FullParse, Source::FromGui); if (spl != nullptr) { spl->dialog=dialogTool; @@ -138,8 +140,9 @@ VToolSplinePath* VToolSplinePath::Create(DialogTool *dialog, VMainGraphicsScene * @param parse parser file mode. * @param typeCreation way we create this tool. */ -VToolSplinePath* VToolSplinePath::Create(const quint32 _id, VSplinePath *path, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document &parse, const Source &typeCreation) +VToolSplinePath* VToolSplinePath::Create(const quint32 _id, VSplinePath *path, const QString &color, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation) { quint32 id = _id; if (typeCreation == Source::FromGui) @@ -159,7 +162,7 @@ VToolSplinePath* VToolSplinePath::Create(const quint32 _id, VSplinePath *path, V VDrawTool::AddRecord(id, Tool::SplinePath, doc); if (parse == Document::FullParse) { - VToolSplinePath *spl = new VToolSplinePath(doc, data, id, typeCreation); + VToolSplinePath *spl = new VToolSplinePath(doc, data, id, color, typeCreation); scene->addItem(spl); connect(spl, &VToolSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSplinePath::SetFactor); @@ -237,7 +240,7 @@ void VToolSplinePath::RefreshSplinePath(VSplinePath &splPath) controlPoints[j-1]->blockSignals(false); spl = VSpline (spl.GetP1(), controlPoints[j-2]->pos(), controlPoints[j-1]->pos(), spl.GetP4(), - splPath.getKCurve()); + splPath.GetKCurve()); UpdateControlPoints(spl, splPath, i); } } @@ -340,7 +343,7 @@ void VToolSplinePath::RefreshDataInFile() } VSplinePath splPath = *VAbstractTool::data.GeometricObject(id); RefreshSplinePath(splPath); - doc->SetAttribute(domElement, AttrKCurve, QString().setNum(splPath.getKCurve())); + doc->SetAttribute(domElement, AttrKCurve, QString().setNum(splPath.GetKCurve())); UpdatePathPoint(doc, domElement, splPath); } @@ -388,7 +391,8 @@ void VToolSplinePath::SaveDialog(QDomElement &domElement) VSplinePath splPath = dialogTool->GetPath(); RefreshSplinePath(splPath); - doc->SetAttribute(domElement, AttrKCurve, QString().setNum(splPath.getKCurve())); + doc->SetAttribute(domElement, AttrKCurve, QString().setNum(splPath.GetKCurve())); + doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor()); UpdatePathPoint(doc, domElement, splPath); } @@ -400,7 +404,8 @@ void VToolSplinePath::SaveOptions(QDomElement &tag, QSharedPointer &ob doc->SetAttribute(tag, VDomDocument::AttrId, id); doc->SetAttribute(tag, AttrType, ToolType); - doc->SetAttribute(tag, AttrKCurve, splPath->getKCurve()); + doc->SetAttribute(tag, AttrKCurve, splPath->GetKCurve()); + doc->SetAttribute(tag, AttrColor, lineColor); doc->RemoveAllChild(tag); for (qint32 i = 0; i < splPath->CountPoint(); ++i) @@ -423,7 +428,7 @@ void VToolSplinePath::RefreshGeometry() { this->setPath(ToolPath()); } - + this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor)); const QSharedPointer splPath = VAbstractTool::data.GeometricObject(id); for (qint32 i = 1; i<=splPath->Count(); ++i) { diff --git a/src/app/tools/drawTools/vtoolsplinepath.h b/src/app/tools/drawTools/vtoolsplinepath.h index 75ffbf8ef..9b3dfd3c9 100644 --- a/src/app/tools/drawTools/vtoolsplinepath.h +++ b/src/app/tools/drawTools/vtoolsplinepath.h @@ -38,12 +38,13 @@ class VToolSplinePath:public VAbstractSpline { Q_OBJECT public: - VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, const Source &typeCreation, + VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, const QString &color, const Source &typeCreation, QGraphicsItem * parent = nullptr); virtual void setDialog(); static VToolSplinePath *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); - static VToolSplinePath *Create(const quint32 _id, VSplinePath *path, VMainGraphicsScene *scene, VPattern *doc, - VContainer *data, const Document &parse, const Source &typeCreation); + static VToolSplinePath *Create(const quint32 _id, VSplinePath *path, const QString &color, + VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, + const Source &typeCreation); static const QString ToolType; static void UpdatePathPoint(VPattern *doc, QDomNode& node, const VSplinePath &path); virtual int type() const {return Type;} diff --git a/src/app/tools/drawTools/vtooltriangle.cpp b/src/app/tools/drawTools/vtooltriangle.cpp index 6afce72ce..6c674121f 100644 --- a/src/app/tools/drawTools/vtooltriangle.cpp +++ b/src/app/tools/drawTools/vtooltriangle.cpp @@ -74,11 +74,11 @@ void VToolTriangle::setDialog() DialogTriangle *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); const QSharedPointer p = VAbstractTool::data.GeometricObject(id); - dialogTool->setAxisP1Id(axisP1Id); - dialogTool->setAxisP2Id(axisP2Id); - dialogTool->setFirstPointId(firstPointId); - dialogTool->setSecondPointId(secondPointId); - dialogTool->setPointName(p->name()); + dialogTool->SetAxisP1Id(axisP1Id); + dialogTool->SetAxisP2Id(axisP2Id); + dialogTool->SetFirstPointId(firstPointId); + dialogTool->SetSecondPointId(secondPointId); + dialogTool->SetPointName(p->name()); } //--------------------------------------------------------------------------------------------------------------------- @@ -95,10 +95,10 @@ VToolTriangle* VToolTriangle::Create(DialogTool *dialog, VMainGraphicsScene *sce SCASSERT(dialog != nullptr); DialogTriangle *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); - const quint32 axisP1Id = dialogTool->getAxisP1Id(); - const quint32 axisP2Id = dialogTool->getAxisP2Id(); - const quint32 firstPointId = dialogTool->getFirstPointId(); - const quint32 secondPointId = dialogTool->getSecondPointId(); + const quint32 axisP1Id = dialogTool->GetAxisP1Id(); + const quint32 axisP2Id = dialogTool->GetAxisP2Id(); + const quint32 firstPointId = dialogTool->GetFirstPointId(); + const quint32 secondPointId = dialogTool->GetSecondPointId(); const QString pointName = dialogTool->getPointName(); VToolTriangle* point = nullptr; point = Create(0, pointName, axisP1Id, axisP2Id, firstPointId, secondPointId, 5, 10, scene, doc, data, @@ -161,7 +161,7 @@ VToolTriangle* VToolTriangle::Create(const quint32 _id, const QString &pointName scene->addItem(point); connect(point, &VToolTriangle::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolTriangle::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); + connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolTriangle::Disable); doc->AddTool(id, point); doc->IncrementReferens(axisP1Id); doc->IncrementReferens(axisP2Id); @@ -220,14 +220,7 @@ QPointF VToolTriangle::FindPoint(const QPointF &axisP1, const QPointF &axisP2, c */ void VToolTriangle::FullUpdateFromFile() { - QDomElement domElement = doc->elementById(QString().setNum(id)); - if (domElement.isElement()) - { - axisP1Id = domElement.attribute(AttrAxisP1, "").toUInt(); - axisP2Id = domElement.attribute(AttrAxisP2, "").toUInt(); - firstPointId = domElement.attribute(AttrFirstPoint, "").toUInt(); - secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt(); - } + ReadAttributes(); VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject(id)); if (vis != nullptr) @@ -283,10 +276,10 @@ void VToolTriangle::SaveDialog(QDomElement &domElement) DialogTriangle *dialogTool = qobject_cast(dialog); SCASSERT(dialogTool != nullptr); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); - doc->SetAttribute(domElement, AttrAxisP1, QString().setNum(dialogTool->getAxisP1Id())); - doc->SetAttribute(domElement, AttrAxisP2, QString().setNum(dialogTool->getAxisP2Id())); - doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId())); - doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); + doc->SetAttribute(domElement, AttrAxisP1, QString().setNum(dialogTool->GetAxisP1Id())); + doc->SetAttribute(domElement, AttrAxisP2, QString().setNum(dialogTool->GetAxisP2Id())); + doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPointId())); + doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPointId())); } //--------------------------------------------------------------------------------------------------------------------- @@ -308,13 +301,22 @@ void VToolTriangle::SaveOptions(QDomElement &tag, QSharedPointer &obj) } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolTriangle::getSecondPointId() const +void VToolTriangle::ReadToolAttributes(const QDomElement &domElement) +{ + axisP1Id = doc->GetParametrUInt(domElement, AttrAxisP1, NULL_ID_STR); + axisP2Id = doc->GetParametrUInt(domElement, AttrAxisP2, NULL_ID_STR); + firstPointId = doc->GetParametrUInt(domElement, AttrFirstPoint, NULL_ID_STR); + secondPointId = doc->GetParametrUInt(domElement, AttrSecondPoint, NULL_ID_STR); +} + +//--------------------------------------------------------------------------------------------------------------------- +quint32 VToolTriangle::GetSecondPointId() const { return secondPointId; } //--------------------------------------------------------------------------------------------------------------------- -void VToolTriangle::setSecondPointId(const quint32 &value) +void VToolTriangle::SetSecondPointId(const quint32 &value) { if (value != NULL_ID) { @@ -361,13 +363,13 @@ void VToolTriangle::ShowVisualization(bool show) } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolTriangle::getFirstPointId() const +quint32 VToolTriangle::GetFirstPointId() const { return firstPointId; } //--------------------------------------------------------------------------------------------------------------------- -void VToolTriangle::setFirstPointId(const quint32 &value) +void VToolTriangle::SetFirstPointId(const quint32 &value) { if (value != NULL_ID) { @@ -379,13 +381,13 @@ void VToolTriangle::setFirstPointId(const quint32 &value) } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolTriangle::getAxisP2Id() const +quint32 VToolTriangle::GetAxisP2Id() const { return axisP2Id; } //--------------------------------------------------------------------------------------------------------------------- -void VToolTriangle::setAxisP2Id(const quint32 &value) +void VToolTriangle::SetAxisP2Id(const quint32 &value) { if (value != NULL_ID) { @@ -397,13 +399,13 @@ void VToolTriangle::setAxisP2Id(const quint32 &value) } //--------------------------------------------------------------------------------------------------------------------- -quint32 VToolTriangle::getAxisP1Id() const +quint32 VToolTriangle::GetAxisP1Id() const { return axisP1Id; } //--------------------------------------------------------------------------------------------------------------------- -void VToolTriangle::setAxisP1Id(const quint32 &value) +void VToolTriangle::SetAxisP1Id(const quint32 &value) { if (value != NULL_ID) { diff --git a/src/app/tools/drawTools/vtooltriangle.h b/src/app/tools/drawTools/vtooltriangle.h index 5ae0743dc..4e5696727 100644 --- a/src/app/tools/drawTools/vtooltriangle.h +++ b/src/app/tools/drawTools/vtooltriangle.h @@ -54,17 +54,17 @@ public: virtual int type() const {return Type;} enum { Type = UserType + static_cast(Tool::Triangle)}; - quint32 getAxisP1Id() const; - void setAxisP1Id(const quint32 &value); + quint32 GetAxisP1Id() const; + void SetAxisP1Id(const quint32 &value); - quint32 getAxisP2Id() const; - void setAxisP2Id(const quint32 &value); + quint32 GetAxisP2Id() const; + void SetAxisP2Id(const quint32 &value); - quint32 getFirstPointId() const; - void setFirstPointId(const quint32 &value); + quint32 GetFirstPointId() const; + void SetFirstPointId(const quint32 &value); - quint32 getSecondPointId() const; - void setSecondPointId(const quint32 &value); + quint32 GetSecondPointId() const; + void SetSecondPointId(const quint32 &value); virtual void ShowVisualization(bool show); public slots: @@ -75,6 +75,7 @@ protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void SaveDialog(QDomElement &domElement); virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj); + virtual void ReadToolAttributes(const QDomElement &domElement); private: Q_DISABLE_COPY(VToolTriangle) /** @brief axisP1Id id first axis point. */ diff --git a/src/app/tools/nodeDetails/vabstractnode.cpp b/src/app/tools/nodeDetails/vabstractnode.cpp index 13ea1b71b..c4c1df277 100644 --- a/src/app/tools/nodeDetails/vabstractnode.cpp +++ b/src/app/tools/nodeDetails/vabstractnode.cpp @@ -47,7 +47,7 @@ const QString VAbstractNode::AttrIdTool = QStringLiteral("idTool"); */ VAbstractNode::VAbstractNode(VPattern *doc, VContainer *data, const quint32 &id, const quint32 &idNode, const quint32 &idTool, QObject *parent) - : VAbstractTool(doc, data, id, parent), idNode(idNode), idTool(idTool) + : VAbstractTool(doc, data, id, parent), idNode(idNode), idTool(idTool), currentColor(Qt::black) { _referens = 0; } diff --git a/src/app/tools/nodeDetails/vabstractnode.h b/src/app/tools/nodeDetails/vabstractnode.h index 61f505ccc..95a668378 100644 --- a/src/app/tools/nodeDetails/vabstractnode.h +++ b/src/app/tools/nodeDetails/vabstractnode.h @@ -53,6 +53,9 @@ protected: /** @brief idTool id tool. */ quint32 idTool; + /** @brief currentColor current tool color. */ + QColor currentColor; + void AddToModeling(const QDomElement &domElement); virtual void decrementReferens(); virtual void RemoveReferens(); diff --git a/src/app/tools/vabstracttool.cpp b/src/app/tools/vabstracttool.cpp index 92fc3de7e..194c5b5c7 100644 --- a/src/app/tools/vabstracttool.cpp +++ b/src/app/tools/vabstracttool.cpp @@ -70,6 +70,8 @@ const QString VAbstractTool::AttrPSpline = QStringLiteral("pSpline"); const QString VAbstractTool::AttrAxisP1 = QStringLiteral("axisP1"); const QString VAbstractTool::AttrAxisP2 = QStringLiteral("axisP2"); const QString VAbstractTool::AttrCurve = QStringLiteral("curve"); +const QString VAbstractTool::AttrLineColor = QStringLiteral("lineColor"); +const QString VAbstractTool::AttrColor = QStringLiteral("color"); const QString VAbstractTool::TypeLineNone = QStringLiteral("none"); const QString VAbstractTool::TypeLineLine = QStringLiteral("hair"); @@ -78,6 +80,14 @@ const QString VAbstractTool::TypeLineDotLine = QStringLiteral("dotLine"); const QString VAbstractTool::TypeLineDashDotLine = QStringLiteral("dashDotLine"); const QString VAbstractTool::TypeLineDashDotDotLine = QStringLiteral("dashDotDotLine"); +const QString VAbstractTool::ColorBlack = QStringLiteral("black"); +const QString VAbstractTool::ColorGreen = QStringLiteral("green"); +const QString VAbstractTool::ColorBlue = QStringLiteral("blue"); +const QString VAbstractTool::ColorDarkRed = QStringLiteral("darkRed"); +const QString VAbstractTool::ColorDarkGreen = QStringLiteral("darkGreen"); +const QString VAbstractTool::ColorDarkBlue = QStringLiteral("darkBlue"); +const QString VAbstractTool::ColorYellow = QStringLiteral("yellow"); + //--------------------------------------------------------------------------------------------------------------------- /** * @brief VAbstractTool container. @@ -87,8 +97,7 @@ const QString VAbstractTool::TypeLineDashDotDotLine = QStringLiteral("dashDotDot * @param parent parent object. */ VAbstractTool::VAbstractTool(VPattern *doc, VContainer *data, quint32 id, QObject *parent) - :VDataTool(data, parent), doc(doc), id(id), baseColor(Qt::black), currentColor(Qt::black), typeLine(TypeLineLine), - vis(nullptr) + :VDataTool(data, parent), doc(doc), id(id), baseColor(Qt::black), vis(nullptr) { SCASSERT(doc != nullptr); connect(this, &VAbstractTool::toolhaveChange, this->doc, &VPattern::haveLiteChange); @@ -215,18 +224,53 @@ QMap VAbstractTool::LineStylesPics() } //--------------------------------------------------------------------------------------------------------------------- -QString VAbstractTool::getLineType() const +const QStringList VAbstractTool::Colors() { - return typeLine; + const QStringList colors = QStringList() << ColorBlack << ColorGreen << ColorBlue << ColorDarkRed << ColorDarkGreen + << ColorDarkBlue << ColorYellow; + return colors; } //--------------------------------------------------------------------------------------------------------------------- -void VAbstractTool::setTypeLine(const QString &value) +QMap VAbstractTool::ColorsList() { - typeLine = value; + QMap map; - QSharedPointer obj = VAbstractTool::data.GetGObject(id); - SaveOption(obj); + const QStringList colorNames = Colors(); + for (int i = 0; i < colorNames.size(); ++i) + { + QString name; + switch (i) + { + case 0: // ColorBlack + name = tr("black"); + break; + case 1: // ColorGreen + name = tr("green"); + break; + case 2: // ColorBlue + name = tr("blue"); + break; + case 3: // ColorDarkRed + name = tr("dark red"); + break; + case 4: // ColorDarkGreen + name = tr("dark green"); + break; + case 5: // ColorDarkBlue + name = tr("dark blue"); + break; + case 6: // ColorYellow + name = tr("yellow"); + break; + default: + name = tr("black"); + break; + } + + map.insert(colorNames.at(i), name); + } + return map; } //--------------------------------------------------------------------------------------------------------------------- @@ -290,8 +334,8 @@ void VAbstractTool::SaveOption(QSharedPointer &obj) */ const QStringList VAbstractTool::StylesList() { - QStringList styles = QStringList() << TypeLineNone << TypeLineLine << TypeLineDashLine << TypeLineDotLine << - TypeLineDashDotLine << TypeLineDashDotDotLine; + const QStringList styles = QStringList() << TypeLineNone << TypeLineLine << TypeLineDashLine << TypeLineDotLine + << TypeLineDashDotLine << TypeLineDashDotDotLine; return styles; } diff --git a/src/app/tools/vabstracttool.h b/src/app/tools/vabstracttool.h index 3667f9377..0212b5692 100644 --- a/src/app/tools/vabstracttool.h +++ b/src/app/tools/vabstracttool.h @@ -86,6 +86,9 @@ public: static const QString AttrAxisP1; static const QString AttrAxisP2; static const QString AttrCurve; + static const QString AttrLineColor; + static const QString AttrColor; + static const QString TypeLineNone; static const QString TypeLineLine; static const QString TypeLineDashLine; @@ -93,16 +96,25 @@ public: static const QString TypeLineDashDotLine; static const QString TypeLineDashDotDotLine; + static const QString ColorBlack; + static const QString ColorGreen; + static const QString ColorBlue; + static const QString ColorDarkRed; + static const QString ColorDarkGreen; + static const QString ColorDarkBlue; + static const QString ColorYellow; + static const QStringList StylesList(); static Qt::PenStyle LineStyleToPenStyle(const QString &typeLine); static QMap LineStylesPics(); + static const QStringList Colors(); + static QMap ColorsList(); + static void AddRecord(const quint32 id, const Tool &toolType, VPattern *doc); const VContainer *getData() const; - QString getLineType() const; - virtual void setTypeLine(const QString &value); QMap PointsList() const; virtual QString getTagName() const =0; virtual void ShowVisualization(bool show) =0; @@ -136,12 +148,6 @@ protected: /** @brief baseColor base color for tool. */ Qt::GlobalColor baseColor; - /** @brief currentColor current tool color. */ - Qt::GlobalColor currentColor; - - /** @brief typeLine line type. */ - QString typeLine; - Visualization *vis; /** diff --git a/src/app/tools/vtooluniondetails.cpp b/src/app/tools/vtooluniondetails.cpp index d59f93e40..32350ad1d 100644 --- a/src/app/tools/vtooluniondetails.cpp +++ b/src/app/tools/vtooluniondetails.cpp @@ -206,7 +206,7 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VPattern *doc, VContainer { VSpline spline(splinePath->at(i-1).P(), splinePath->at(i).P(), splinePath->at(i-1).Angle2(), splinePath->at(i).Angle1(), splinePath->at(i-1).KAsm2(), - splinePath->at(i).KAsm1(), splinePath->getKCurve()); + splinePath->at(i).KAsm1(), splinePath->GetKCurve()); VPointF *p1 = new VPointF(spline.GetP1()); BiasRotatePoint(p1, dx, dy, data->GeometricObject(pRotate)->toQPointF(), @@ -366,7 +366,7 @@ void VToolUnionDetails::UpdatePoints(const quint32 &idDetail, VContainer *data, { VSpline spline(splinePath->at(i-1).P(), splinePath->at(i).P(), splinePath->at(i-1).Angle2(), splinePath->at(i).Angle1(), splinePath->at(i-1).KAsm2(), - splinePath->at(i).KAsm1(), splinePath->getKCurve()); + splinePath->at(i).KAsm1(), splinePath->GetKCurve()); VPointF *p1 = new VPointF(spline.GetP1()); BiasRotatePoint(p1, dx, dy, data->GeometricObject(pRotate)->toQPointF(), diff --git a/src/app/undocommands/movesplinepath.cpp b/src/app/undocommands/movesplinepath.cpp index 1e756ad8a..86f72b5a3 100644 --- a/src/app/undocommands/movesplinepath.cpp +++ b/src/app/undocommands/movesplinepath.cpp @@ -89,7 +89,7 @@ void MoveSplinePath::Do(const VSplinePath &splPath) QDomElement domElement = doc->elementById(QString().setNum(nodeId)); if (domElement.isElement()) { - doc->SetAttribute(domElement, VToolSplinePath::AttrKCurve, QString().setNum(splPath.getKCurve())); + doc->SetAttribute(domElement, VToolSplinePath::AttrKCurve, QString().setNum(splPath.GetKCurve())); VToolSplinePath::UpdatePathPoint(doc, domElement, splPath); emit NeedLiteParsing(Document::LiteParse); diff --git a/src/app/visualization/vgraphicssimpletextitem.cpp b/src/app/visualization/vgraphicssimpletextitem.cpp index 49921e86b..85f07a71d 100644 --- a/src/app/visualization/vgraphicssimpletextitem.cpp +++ b/src/app/visualization/vgraphicssimpletextitem.cpp @@ -83,6 +83,21 @@ void VGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphic QGraphicsSimpleTextItem::paint(painter, &myOption, widget); } +//--------------------------------------------------------------------------------------------------------------------- +void VGraphicsSimpleTextItem::setEnabled(bool enabled) +{ + QGraphicsSimpleTextItem::setEnabled(enabled); + const QPalette palet = this->scene()->palette(); + if (enabled) + { + setBrush(palet.brush(QPalette::Active, QPalette::Text)); + } + else + { + setBrush(palet.brush(QPalette::Disabled, QPalette::Text)); + } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief itemChange handle item change. diff --git a/src/app/visualization/vgraphicssimpletextitem.h b/src/app/visualization/vgraphicssimpletextitem.h index daf3c9297..3868e33f6 100644 --- a/src/app/visualization/vgraphicssimpletextitem.h +++ b/src/app/visualization/vgraphicssimpletextitem.h @@ -47,6 +47,8 @@ public: virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); virtual int type() const {return Type;} enum { Type = UserType + static_cast(Vis::GraphicsSimpleTextItem)}; + + void setEnabled(bool enabled); signals: /** * @brief NameChangePosition emit when label change position. diff --git a/src/app/visualization/vistoolcurveintersectaxis.cpp b/src/app/visualization/vistoolcurveintersectaxis.cpp index d3cabc903..9ceb59a18 100644 --- a/src/app/visualization/vistoolcurveintersectaxis.cpp +++ b/src/app/visualization/vistoolcurveintersectaxis.cpp @@ -92,7 +92,7 @@ QString VisToolCurveIntersectAxis::Angle() const } //--------------------------------------------------------------------------------------------------------------------- -void VisToolCurveIntersectAxis::setAngle(const QString &expression) +void VisToolCurveIntersectAxis::SetAngle(const QString &expression) { angle = FindVal(expression); } diff --git a/src/app/visualization/vistoolcurveintersectaxis.h b/src/app/visualization/vistoolcurveintersectaxis.h index d6481bf48..1398a01ce 100644 --- a/src/app/visualization/vistoolcurveintersectaxis.h +++ b/src/app/visualization/vistoolcurveintersectaxis.h @@ -43,7 +43,7 @@ public: virtual void RefreshGeometry(); QString Angle() const; - void setAngle(const QString &expression); + void SetAngle(const QString &expression); void setAxisPointId(const quint32 &value); virtual int type() const {return Type;} diff --git a/src/app/visualization/vistoolcutsplinepath.cpp b/src/app/visualization/vistoolcutsplinepath.cpp index fcea7e2ee..f79105cc8 100644 --- a/src/app/visualization/vistoolcutsplinepath.cpp +++ b/src/app/visualization/vistoolcutsplinepath.cpp @@ -67,8 +67,8 @@ void VisToolCutSplinePath::RefreshGeometry() VSplinePoint splP1 = splPath->at(p1); VSplinePoint splP2 = splPath->at(p2); - const VSpline spl1 = VSpline(splP1.P(), spl1p2, spl1p3, p, splPath->getKCurve()); - const VSpline spl2 = VSpline(p, spl2p2, spl2p3, splP2.P(), splPath->getKCurve()); + const VSpline spl1 = VSpline(splP1.P(), spl1p2, spl1p3, p, splPath->GetKCurve()); + const VSpline spl2 = VSpline(p, spl2p2, spl2p3, splP2.P(), splPath->GetKCurve()); VSplinePath spPath1 = VSplinePath(); VSplinePath spPath2 = VSplinePath(); @@ -104,8 +104,8 @@ void VisToolCutSplinePath::RefreshGeometry() } } - spPath1.setKCurve(splPath->getKCurve()); - spPath2.setKCurve(splPath->getKCurve()); + spPath1.SetKCurve(splPath->GetKCurve()); + spPath2.SetKCurve(splPath->GetKCurve()); DrawPoint(point, cutPoint, mainColor); diff --git a/src/app/visualization/vistoolendline.cpp b/src/app/visualization/vistoolendline.cpp index 0bd977362..a3483c829 100644 --- a/src/app/visualization/vistoolendline.cpp +++ b/src/app/visualization/vistoolendline.cpp @@ -72,7 +72,7 @@ QString VisToolEndLine::Angle() const } //--------------------------------------------------------------------------------------------------------------------- -void VisToolEndLine::setAngle(const QString &expression) +void VisToolEndLine::SetAngle(const QString &expression) { angle = FindVal(expression); } diff --git a/src/app/visualization/vistoolendline.h b/src/app/visualization/vistoolendline.h index 7b44f697f..cc3dd3f14 100644 --- a/src/app/visualization/vistoolendline.h +++ b/src/app/visualization/vistoolendline.h @@ -42,7 +42,7 @@ public: virtual void RefreshGeometry(); QString Angle() const; - void setAngle(const QString &expression); + void SetAngle(const QString &expression); void setLength(const QString &expression); virtual int type() const {return Type;} enum { Type = UserType + static_cast(Vis::ToolEndLine)}; diff --git a/src/app/visualization/vistoollineintersectaxis.cpp b/src/app/visualization/vistoollineintersectaxis.cpp index 371d46cad..bf757847f 100644 --- a/src/app/visualization/vistoollineintersectaxis.cpp +++ b/src/app/visualization/vistoollineintersectaxis.cpp @@ -108,7 +108,7 @@ QString VisToolLineIntersectAxis::Angle() const } //--------------------------------------------------------------------------------------------------------------------- -void VisToolLineIntersectAxis::setAngle(const QString &expression) +void VisToolLineIntersectAxis::SetAngle(const QString &expression) { angle = FindVal(expression); } diff --git a/src/app/visualization/vistoollineintersectaxis.h b/src/app/visualization/vistoollineintersectaxis.h index f9f0f370e..419873f80 100644 --- a/src/app/visualization/vistoollineintersectaxis.h +++ b/src/app/visualization/vistoollineintersectaxis.h @@ -43,7 +43,7 @@ public: virtual void RefreshGeometry(); QString Angle() const; - void setAngle(const QString &expression); + void SetAngle(const QString &expression); void setPoint2Id(const quint32 &value); void setAxisPointId(const quint32 &value); diff --git a/src/app/visualization/vistoolnormal.cpp b/src/app/visualization/vistoolnormal.cpp index e9b5402c5..858415366 100644 --- a/src/app/visualization/vistoolnormal.cpp +++ b/src/app/visualization/vistoolnormal.cpp @@ -104,13 +104,13 @@ void VisToolNormal::setLength(const QString &expression) } //--------------------------------------------------------------------------------------------------------------------- -qreal VisToolNormal::getAngle() const +qreal VisToolNormal::GetAngle() const { return angle; } //--------------------------------------------------------------------------------------------------------------------- -void VisToolNormal::setAngle(const qreal &value) +void VisToolNormal::SetAngle(const qreal &value) { angle = value; } diff --git a/src/app/visualization/vistoolnormal.h b/src/app/visualization/vistoolnormal.h index 1593d03f5..c73a0cace 100644 --- a/src/app/visualization/vistoolnormal.h +++ b/src/app/visualization/vistoolnormal.h @@ -42,8 +42,8 @@ public: void setPoint2Id(const quint32 &value); void setLength(const QString &expression); - qreal getAngle() const; - void setAngle(const qreal &value); + qreal GetAngle() const; + void SetAngle(const qreal &value); virtual int type() const {return Type;} enum { Type = UserType + static_cast(Vis::ToolNormal)}; private: diff --git a/src/app/visualization/vistoolspline.cpp b/src/app/visualization/vistoolspline.cpp index 92562e751..5c014feeb 100644 --- a/src/app/visualization/vistoolspline.cpp +++ b/src/app/visualization/vistoolspline.cpp @@ -84,31 +84,31 @@ void VisToolSpline::setPoint4Id(const quint32 &value) } //--------------------------------------------------------------------------------------------------------------------- -void VisToolSpline::setAngle1(const qreal &value) +void VisToolSpline::SetAngle1(const qreal &value) { angle1 = value; } //--------------------------------------------------------------------------------------------------------------------- -void VisToolSpline::setAngle2(const qreal &value) +void VisToolSpline::SetAngle2(const qreal &value) { angle2 = value; } //--------------------------------------------------------------------------------------------------------------------- -void VisToolSpline::setKAsm1(const qreal &value) +void VisToolSpline::SetKAsm1(const qreal &value) { kAsm1 = value; } //--------------------------------------------------------------------------------------------------------------------- -void VisToolSpline::setKAsm2(const qreal &value) +void VisToolSpline::SetKAsm2(const qreal &value) { kAsm2 = value; } //--------------------------------------------------------------------------------------------------------------------- -void VisToolSpline::setKCurve(const qreal &value) +void VisToolSpline::SetKCurve(const qreal &value) { kCurve = value; } diff --git a/src/app/visualization/vistoolspline.h b/src/app/visualization/vistoolspline.h index 56c12d021..df24af01b 100644 --- a/src/app/visualization/vistoolspline.h +++ b/src/app/visualization/vistoolspline.h @@ -41,11 +41,11 @@ public: virtual void RefreshGeometry(); void setPoint4Id(const quint32 &value); - void setAngle1(const qreal &value); - void setAngle2(const qreal &value); - void setKAsm1(const qreal &value); - void setKAsm2(const qreal &value); - void setKCurve(const qreal &value); + void SetAngle1(const qreal &value); + void SetAngle2(const qreal &value); + void SetKAsm1(const qreal &value); + void SetKAsm2(const qreal &value); + void SetKCurve(const qreal &value); virtual int type() const {return Type;} enum { Type = UserType + static_cast(Vis::ToolSpline)}; diff --git a/src/app/visualization/vsimplecurve.cpp b/src/app/visualization/vsimplecurve.cpp index 92ba03fba..33031f3eb 100644 --- a/src/app/visualization/vsimplecurve.cpp +++ b/src/app/visualization/vsimplecurve.cpp @@ -40,18 +40,18 @@ * @param currentColor current color. * @param parent parent object. */ -VSimpleCurve::VSimpleCurve(quint32 id, Qt::GlobalColor *currentColor, SimpleCurvePoint pointPosition, qreal *factor, +VSimpleCurve::VSimpleCurve(quint32 id, QColor currentColor, SimpleCurvePoint pointPosition, qreal *factor, QObject *parent) :QObject(parent), QGraphicsPathItem(), id (id), factor(factor), currentColor(currentColor), - curvePosition(pointPosition) + curvePosition(pointPosition), enabled(true) { if (factor == nullptr) { - setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine()))); + setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine()))); } else { - setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/ *factor)); + setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/ *factor)); } setFlag(QGraphicsItem::ItemIsSelectable, true); setAcceptHoverEvents(true); @@ -60,9 +60,9 @@ VSimpleCurve::VSimpleCurve(quint32 id, Qt::GlobalColor *currentColor, SimpleCurv //--------------------------------------------------------------------------------------------------------------------- void VSimpleCurve::ChangedActivDraw(const bool &flag) { - setFlag(QGraphicsItem::ItemIsSelectable, flag); - setAcceptHoverEvents(flag); - setPen(QPen(*currentColor, qApp->toPixel(qApp->widthHairLine())/ *factor)); + enabled = flag; + setEnabled(enabled); + setPen(QPen(CorrectColor(currentColor), qApp->toPixel(qApp->widthHairLine())/ *factor)); } //--------------------------------------------------------------------------------------------------------------------- @@ -102,11 +102,11 @@ void VSimpleCurve::hoverMoveEvent(QGraphicsSceneHoverEvent *event) Q_UNUSED(event); if (factor == nullptr) { - this->setPen(QPen(*currentColor, qApp->toPixel(qApp->widthMainLine()))); + this->setPen(QPen(CorrectColor(currentColor), qApp->toPixel(qApp->widthMainLine()))); } else { - this->setPen(QPen(*currentColor, qApp->toPixel(qApp->widthMainLine())/ *factor)); + this->setPen(QPen(CorrectColor(currentColor), qApp->toPixel(qApp->widthMainLine())/ *factor)); } emit HoverPath(id, curvePosition, PathDirection::Show); } @@ -121,12 +121,38 @@ void VSimpleCurve::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_UNUSED(event); if (factor == nullptr) { - this->setPen(QPen(*currentColor, qApp->toPixel(qApp->widthHairLine()))); + this->setPen(QPen(CorrectColor(currentColor), qApp->toPixel(qApp->widthHairLine()))); } else { - this->setPen(QPen(*currentColor, qApp->toPixel(qApp->widthHairLine())/ *factor)); + this->setPen(QPen(CorrectColor(currentColor), qApp->toPixel(qApp->widthHairLine())/ *factor)); } emit HoverPath(id, curvePosition, PathDirection::Hide); } + +//--------------------------------------------------------------------------------------------------------------------- +QColor VSimpleCurve::GetCurrentColor() const +{ + return currentColor; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VSimpleCurve::SetCurrentColor(const QColor &value) +{ + currentColor = value; + setPen(QPen(CorrectColor(currentColor), pen().widthF())); +} + +//--------------------------------------------------------------------------------------------------------------------- +QColor VSimpleCurve::CorrectColor(const QColor &color) const +{ + if (enabled) + { + return color; + } + else + { + return Qt::gray; + } +} diff --git a/src/app/visualization/vsimplecurve.h b/src/app/visualization/vsimplecurve.h index d33afb269..a013727c2 100644 --- a/src/app/visualization/vsimplecurve.h +++ b/src/app/visualization/vsimplecurve.h @@ -41,13 +41,17 @@ class VSimpleCurve : public QObject, public QGraphicsPathItem { Q_OBJECT public: - VSimpleCurve(quint32 id, Qt::GlobalColor *currentColor, SimpleCurvePoint curvePosition, + VSimpleCurve(quint32 id, QColor currentColor, SimpleCurvePoint curvePosition, qreal *factor = nullptr, QObject *parent = 0); void ChangedActivDraw(const bool &flag); virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0); virtual int type() const {return Type;} enum { Type = UserType + static_cast(Vis::SimpleSplinePath)}; + + QColor GetCurrentColor() const; + void SetCurrentColor(const QColor &value); + signals: /** * @brief Choosed send id when clicked. @@ -68,9 +72,13 @@ private: qreal *factor; /** @brief currentColor current color. */ - Qt::GlobalColor *currentColor; + QColor currentColor; SimpleCurvePoint curvePosition; + + bool enabled; + + QColor CorrectColor(const QColor &color) const; }; #endif // VSIMPLECURVE_H diff --git a/src/app/widgets/vformulaproperty.cpp b/src/app/widgets/vformulaproperty.cpp index 444a9fca6..09fbd2057 100644 --- a/src/app/widgets/vformulaproperty.cpp +++ b/src/app/widgets/vformulaproperty.cpp @@ -95,7 +95,7 @@ QWidget* VFormulaProperty::createEditor(QWidget* parent, const QStyleOptionViewI VFormula formula = VProperty::d_ptr->VariantValue.value(); VFormulaPropertyEditor* tmpEditor = new VFormulaPropertyEditor(parent); - tmpEditor->setFormula(formula); + tmpEditor->SetFormula(formula); VProperty::d_ptr->editor = tmpEditor; return VProperty::d_ptr->editor; } @@ -108,7 +108,7 @@ bool VFormulaProperty::setEditorData(QWidget* editor) if (tmpWidget) { VFormula formula = VProperty::d_ptr->VariantValue.value(); - tmpWidget->setFormula(formula); + tmpWidget->SetFormula(formula); } else return false; @@ -124,7 +124,7 @@ QVariant VFormulaProperty::getEditorData(const QWidget *editor) const if (tmpWidget) { QVariant value; - value.setValue(tmpWidget->getFormula()); + value.setValue(tmpWidget->GetFormula()); return value; } @@ -163,26 +163,26 @@ VProperty *VFormulaProperty::clone(bool include_children, VProperty *container) void VFormulaProperty::setValue(const QVariant &value) { VFormula tmpFormula = value.value(); - setFormula(tmpFormula); + SetFormula(tmpFormula); } //--------------------------------------------------------------------------------------------------------------------- QVariant VFormulaProperty::getValue() const { - VFormula tmpFormula = getFormula(); + VFormula tmpFormula = GetFormula(); QVariant value; value.setValue(tmpFormula); return value; } //--------------------------------------------------------------------------------------------------------------------- -VFormula VFormulaProperty::getFormula() const +VFormula VFormulaProperty::GetFormula() const { return VProperty::d_ptr->VariantValue.value(); } //--------------------------------------------------------------------------------------------------------------------- -void VFormulaProperty::setFormula(const VFormula &formula) +void VFormulaProperty::SetFormula(const VFormula &formula) { if (d_ptr->Children.count() < 2) { @@ -197,7 +197,7 @@ void VFormulaProperty::setFormula(const VFormula &formula) QVariant tmpValue(formula.getStringValue()); tmpValue.convert(QVariant::String); - QVariant tmpFormula(formula.getFormula()); + QVariant tmpFormula(formula.GetFormula()); tmpFormula.convert(QVariant::String); VProperty::d_ptr->Children.at(0)->setValue(tmpValue); @@ -213,8 +213,8 @@ void VFormulaProperty::ValueChildChanged(const QVariant &value, int typeForParen { if (typeForParent == static_cast(ChildType::Formula)) { - VFormula newFormula = getFormula(); - newFormula.setFormula(value.toString()); - setFormula(newFormula); + VFormula newFormula = GetFormula(); + newFormula.SetFormula(value.toString()); + SetFormula(newFormula); } } diff --git a/src/app/widgets/vformulaproperty.h b/src/app/widgets/vformulaproperty.h index 90c177aed..bcbc2f407 100644 --- a/src/app/widgets/vformulaproperty.h +++ b/src/app/widgets/vformulaproperty.h @@ -76,10 +76,10 @@ public: virtual QVariant getValue() const; //! Returns the formula - virtual VFormula getFormula() const; + virtual VFormula GetFormula() const; //! Sets the formula - virtual void setFormula(const VFormula &formula); + virtual void SetFormula(const VFormula &formula); public slots: virtual void ValueChildChanged(const QVariant &value, int typeForParent); diff --git a/src/app/widgets/vformulapropertyeditor.cpp b/src/app/widgets/vformulapropertyeditor.cpp index 7030ae7fa..cc583ccfb 100644 --- a/src/app/widgets/vformulapropertyeditor.cpp +++ b/src/app/widgets/vformulapropertyeditor.cpp @@ -73,7 +73,7 @@ VFormulaPropertyEditor::VFormulaPropertyEditor(QWidget *parent) } //--------------------------------------------------------------------------------------------------------------------- -void VFormulaPropertyEditor::setFormula(const VFormula& formula) +void VFormulaPropertyEditor::SetFormula(const VFormula& formula) { if (this->formula != formula) { @@ -89,11 +89,11 @@ void VFormulaPropertyEditor::onToolButtonClicked() qApp->getMainWindow()); tmpWidget->setCheckZero(formula.getCheckZero()); tmpWidget->setPostfix(formula.getPostfix()); - tmpWidget->setFormula(formula.getFormula(FormulaType::FromUser)); + tmpWidget->SetFormula(formula.GetFormula(FormulaType::FromUser)); if (tmpWidget->exec() == QDialog::Accepted) { - formula.setFormula(tmpWidget->getFormula(), FormulaType::ToUser); + formula.SetFormula(tmpWidget->GetFormula(), FormulaType::ToUser); TextLabel->setText(formula.getStringValue()); delete tmpWidget; emit dataChangedByUser(formula, this); @@ -122,7 +122,7 @@ VFormulaPropertyEditor::~VFormulaPropertyEditor() } //--------------------------------------------------------------------------------------------------------------------- -VFormula VFormulaPropertyEditor::getFormula() const +VFormula VFormulaPropertyEditor::GetFormula() const { return formula; } diff --git a/src/app/widgets/vformulapropertyeditor.h b/src/app/widgets/vformulapropertyeditor.h index e7a1ab291..52de778aa 100644 --- a/src/app/widgets/vformulapropertyeditor.h +++ b/src/app/widgets/vformulapropertyeditor.h @@ -49,20 +49,20 @@ public: virtual ~VFormulaPropertyEditor(); //! Returns the formula currently set - VFormula getFormula() const; + VFormula GetFormula() const; //! Needed for proper event handling bool eventFilter(QObject *obj, QEvent *ev); signals: //! This is emitted, when the user changes the color - void dataChangedByUser(const VFormula &getFormula, VFormulaPropertyEditor* editor); + void dataChangedByUser(const VFormula &GetFormula, VFormulaPropertyEditor* editor); void dataChanged(); public slots: //! Sets the color of the widget - void setFormula(const VFormula &formula); + void SetFormula(const VFormula &formula); private slots: void onToolButtonClicked(); diff --git a/src/app/widgets/vtooloptionspropertybrowser.cpp b/src/app/widgets/vtooloptionspropertybrowser.cpp index 8ad42eb67..d565d45e5 100644 --- a/src/app/widgets/vtooloptionspropertybrowser.cpp +++ b/src/app/widgets/vtooloptionspropertybrowser.cpp @@ -367,7 +367,7 @@ void VToolOptionsPropertyBrowser::AddPropertyFormula(const QString &propertyName const QString &attrName) { VFormulaProperty* itemLength = new VFormulaProperty(propertyName); - itemLength->setFormula(formula); + itemLength->SetFormula(formula); AddProperty(itemLength, attrName); } @@ -396,6 +396,22 @@ void VToolOptionsPropertyBrowser::AddPropertyLineType(Tool *i, const QString &pr AddProperty(lineTypeProperty, VAbstractTool::AttrTypeLine); } +//--------------------------------------------------------------------------------------------------------------------- +template +void VToolOptionsPropertyBrowser::AddPropertyLineColor(Tool *i, const QString &propertyName, + const QMap &colors, const QString &id) +{ + VLineColorProperty *lineColorProperty = new VLineColorProperty(propertyName); + lineColorProperty->setColors(colors); + const qint32 index = VLineColorProperty::IndexOfColor(colors, i->GetLineColor()); + if (index == -1) + { + qWarning()<<"Can't find line style" << i->GetLineColor()<<"in list"; + } + lineColorProperty->setValue(index); + AddProperty(lineColorProperty, id); +} + //--------------------------------------------------------------------------------------------------------------------- template void VToolOptionsPropertyBrowser::SetPointName(const QString &name) @@ -469,13 +485,16 @@ void VToolOptionsPropertyBrowser::ChangeDataToolEndLine(VProperty *property) SetPointName(value.toString()); break; case 3: // VAbstractTool::AttrTypeLine - i->setTypeLine(value.toString()); + i->SetTypeLine(value.toString()); + break; + case 26: // VAbstractTool::AttrTypeLineColor + i->SetLineColor(value.toString()); break; case 4: // VAbstractTool::AttrLength - i->setFormulaLength(value.value()); + i->SetFormulaLength(value.value()); break; case 5: // VAbstractTool::AttrAngle - i->setFormulaAngle(value.value()); + i->SetFormulaAngle(value.value()); break; default: qWarning()<<"Unknown property type. id = "<(value.toString()); break; case 3: // VAbstractTool::AttrTypeLine - i->setTypeLine(value.toString()); + i->SetTypeLine(value.toString()); + break; + case 26: // VAbstractTool::AttrTypeLineColor + i->SetLineColor(value.toString()); break; case 4: // VAbstractTool::AttrLength - i->setFormulaLength(value.value()); + i->SetFormulaLength(value.value()); break; default: qWarning()<<"Unknown property type. id = "<setFormulaRadius(value.value()); + i->SetFormulaRadius(value.value()); break; case 9: // VAbstractTool::AttrAngle1 - i->setFormulaF1(value.value()); + i->SetFormulaF1(value.value()); break; case 10: // VAbstractTool::AttrAngle2 - i->setFormulaF2(value.value()); + i->SetFormulaF2(value.value()); + break; + case 27: // VAbstractTool::AttrTypeColor + i->SetLineColor(value.toString()); break; default: qWarning()<<"Unknown property type. id = "<(value.toString()); break; case 4: // VAbstractTool::AttrLength - i->setFormulaLength(value.value()); + i->SetFormulaLength(value.value()); break; case 3: // VAbstractTool::AttrTypeLine - i->setTypeLine(value.toString()); + i->SetTypeLine(value.toString()); + break; + case 26: // VAbstractTool::AttrTypeLineColor + i->SetLineColor(value.toString()); break; default: qWarning()<<"Unknown property type. id = "<(value.toString()); break; case 4: // VAbstractTool::AttrLength - i->setFormula(value.value()); + i->SetFormula(value.value()); + break; + case 27: // VAbstractTool::AttrTypeColor + i->SetLineColor(value.toString()); break; default: qWarning()<<"Unknown property type. id = "<(value.toString()); break; case 4: // VAbstractTool::AttrLength - i->setFormula(value.value()); + i->SetFormula(value.value()); + break; + case 27: // VAbstractTool::AttrTypeColor + i->SetLineColor(value.toString()); break; default: qWarning()<<"Unknown property type. id = "<(value.toString()); break; case 4: // VAbstractTool::AttrLength - i->setFormula(value.value()); + i->SetFormula(value.value()); + break; + case 27: // VAbstractTool::AttrTypeColor + i->SetLineColor(value.toString()); break; default: qWarning()<<"Unknown property type. id = "<(value.toString()); break; case 3: // VAbstractTool::AttrTypeLine - i->setTypeLine(value.toString()); + i->SetTypeLine(value.toString()); + break; + case 26: // VAbstractTool::AttrTypeLineColor + i->SetLineColor(value.toString()); break; default: qWarning()<<"Unknown property type. id = "<setTypeLine(value.toString()); + i->SetTypeLine(value.toString()); + break; + case 26: // VAbstractTool::AttrTypeLineColor + i->SetLineColor(value.toString()); break; default: qWarning()<<"Unknown property type. id = "<setFormulaLength(value.value()); + i->SetFormulaLength(value.value()); break; case 0: // VAbstractTool::AttrName SetPointName(value.toString()); break; case 5: // VAbstractTool::AttrAngle - i->setAngle(value.toDouble()); + i->SetAngle(value.toDouble()); break; case 3: // VAbstractTool::AttrTypeLine - i->setTypeLine(value.toString()); + i->SetTypeLine(value.toString()); + break; + case 26: // VAbstractTool::AttrTypeLineColor + i->SetLineColor(value.toString()); break; default: qWarning()<<"Unknown property type. id = "<setFormulaLength(value.value()); + i->SetFormulaLength(value.value()); break; case 0: // VAbstractTool::AttrName SetPointName(value.toString()); break; case 3: // VAbstractTool::AttrTypeLine - i->setTypeLine(value.toString()); + i->SetTypeLine(value.toString()); + break; + case 26: // VAbstractTool::AttrTypeLineColor + i->SetLineColor(value.toString()); break; default: qWarning()<<"Unknown property type. id = "<setSpline(spl); break; } + case 27: // VAbstractTool::AttrTypeColor + i->SetLineColor(value.toString()); + break; default: qWarning()<<"Unknown property type. id = "<getSplinePath(); - splPath.setKCurve(value.toDouble()); + splPath.SetKCurve(value.toDouble()); i->setSplinePath(splPath); break; } + case 27: // VAbstractTool::AttrTypeColor + i->SetLineColor(value.toString()); + break; default: qWarning()<<"Unknown property type. id = "<(value.toString()); break; case 3: // VAbstractTool::AttrTypeLine - i->setTypeLine(value.toString()); + i->SetTypeLine(value.toString()); + break; + case 26: // VAbstractTool::AttrTypeLineColor + i->SetLineColor(value.toString()); break; case 5: // VAbstractTool::AttrAngle - i->setFormulaAngle(value.value()); + i->SetFormulaAngle(value.value()); break; default: qWarning()<<"Unknown property type. id = "<(value.toString()); break; case 3: // VAbstractTool::AttrTypeLine - i->setTypeLine(value.toString()); + i->SetTypeLine(value.toString()); + break; + case 26: // VAbstractTool::AttrTypeLineColor + i->SetLineColor(value.toString()); break; case 5: // VAbstractTool::AttrAngle - i->setFormulaAngle(value.value()); + i->SetFormulaAngle(value.value()); break; default: qWarning()<<"Unknown property type. id = "<getFormulaLength(), VAbstractTool::AttrLength); - AddPropertyFormula(tr("Angle"), i->getFormulaAngle(), VAbstractTool::AttrAngle); + AddPropertyLineColor(i, tr("Line color"), VAbstractTool::ColorsList(), VAbstractTool::AttrLineColor); + AddPropertyFormula(tr("Length"), i->GetFormulaLength(), VAbstractTool::AttrLength); + AddPropertyFormula(tr("Angle"), i->GetFormulaAngle(), VAbstractTool::AttrAngle); } //--------------------------------------------------------------------------------------------------------------------- @@ -959,7 +1021,8 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolAlongLine(QGraphicsItem *item) AddPropertyPointName(i, tr("Point label")); AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics()); - AddPropertyFormula(tr("Length"), i->getFormulaLength(), VAbstractTool::AttrLength); + AddPropertyLineColor(i, tr("Line color"), VAbstractTool::ColorsList(), VAbstractTool::AttrLineColor); + AddPropertyFormula(tr("Length"), i->GetFormulaLength(), VAbstractTool::AttrLength); } //--------------------------------------------------------------------------------------------------------------------- @@ -969,9 +1032,10 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolArc(QGraphicsItem *item) i->ShowVisualization(true); formView->setTitle(tr("Arc")); - AddPropertyFormula(tr("Radius"), i->getFormulaRadius(), VAbstractTool::AttrRadius); - AddPropertyFormula(tr("First angle"), i->getFormulaF1(), VAbstractTool::AttrAngle1); - AddPropertyFormula(tr("Second angle"), i->getFormulaF2(), VAbstractTool::AttrAngle2); + AddPropertyFormula(tr("Radius"), i->GetFormulaRadius(), VAbstractTool::AttrRadius); + AddPropertyFormula(tr("First angle"), i->GetFormulaF1(), VAbstractTool::AttrAngle1); + AddPropertyFormula(tr("Second angle"), i->GetFormulaF2(), VAbstractTool::AttrAngle2); + AddPropertyLineColor(i, tr("Color"), VAbstractTool::ColorsList(), VAbstractTool::AttrColor); } //--------------------------------------------------------------------------------------------------------------------- @@ -983,7 +1047,8 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolBisector(QGraphicsItem *item) AddPropertyPointName(i, tr("Point label")); AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics()); - AddPropertyFormula(tr("Length"), i->getFormulaLength(), VAbstractTool::AttrLength); + AddPropertyLineColor(i, tr("Line color"), VAbstractTool::ColorsList(), VAbstractTool::AttrLineColor); + AddPropertyFormula(tr("Length"), i->GetFormulaLength(), VAbstractTool::AttrLength); } //--------------------------------------------------------------------------------------------------------------------- @@ -994,7 +1059,8 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCutArc(QGraphicsItem *item) formView->setTitle(tr("Cut arc tool")); AddPropertyPointName(i, tr("Point label")); - AddPropertyFormula(tr("Length"), i->getFormula(), VAbstractTool::AttrLength); + AddPropertyFormula(tr("Length"), i->GetFormula(), VAbstractTool::AttrLength); + AddPropertyLineColor(i, tr("Color"), VAbstractTool::ColorsList(), VAbstractTool::AttrColor); } //--------------------------------------------------------------------------------------------------------------------- @@ -1005,7 +1071,8 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCutSpline(QGraphicsItem *item) formView->setTitle(tr("Tool for segmenting a curve")); AddPropertyPointName(i, tr("Point label")); - AddPropertyFormula(tr("Length"), i->getFormula(), VAbstractTool::AttrLength); + AddPropertyFormula(tr("Length"), i->GetFormula(), VAbstractTool::AttrLength); + AddPropertyLineColor(i, tr("Color"), VAbstractTool::ColorsList(), VAbstractTool::AttrColor); } //--------------------------------------------------------------------------------------------------------------------- @@ -1016,7 +1083,8 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCutSplinePath(QGraphicsItem *it formView->setTitle(tr("Tool segment a pathed curve")); AddPropertyPointName(i, tr("Point label")); - AddPropertyFormula(tr("Length"), i->getFormula(), VAbstractTool::AttrLength); + AddPropertyFormula(tr("Length"), i->GetFormula(), VAbstractTool::AttrLength); + AddPropertyLineColor(i, tr("Color"), VAbstractTool::ColorsList(), VAbstractTool::AttrColor); } //--------------------------------------------------------------------------------------------------------------------- @@ -1028,6 +1096,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolHeight(QGraphicsItem *item) AddPropertyPointName(i, tr("Point label")); AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics()); + AddPropertyLineColor(i, tr("Line color"), VAbstractTool::ColorsList(), VAbstractTool::AttrLineColor); } //--------------------------------------------------------------------------------------------------------------------- @@ -1040,6 +1109,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolLine(QGraphicsItem *item) QMap styles = VAbstractTool::LineStylesPics(); styles.remove(VAbstractTool::TypeLineNone); AddPropertyLineType(i, tr("Line type"), styles); + AddPropertyLineColor(i, tr("Line color"), VAbstractTool::ColorsList(), VAbstractTool::AttrLineColor); } //--------------------------------------------------------------------------------------------------------------------- @@ -1059,12 +1129,13 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolNormal(QGraphicsItem *item) i->ShowVisualization(true); formView->setTitle(tr("Point along perpendicular")); - AddPropertyFormula(tr("Length"), i->getFormulaLength(), VAbstractTool::AttrLength); + AddPropertyFormula(tr("Length"), i->GetFormulaLength(), VAbstractTool::AttrLength); AddPropertyPointName(i, tr("Point label")); AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics()); + AddPropertyLineColor(i, tr("Line color"), VAbstractTool::ColorsList(), VAbstractTool::AttrLineColor); VDoubleProperty* itemAngle = new VDoubleProperty(tr("Additional angle degrees")); - itemAngle->setValue(i->getAngle()); + itemAngle->setValue(i->GetAngle()); itemAngle->setSetting("Min", -360); itemAngle->setSetting("Max", 360); itemAngle->setSetting("Precision", 3); @@ -1101,7 +1172,8 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolShoulderPoint(QGraphicsItem *it AddPropertyPointName(i, tr("Point label")); AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics()); - AddPropertyFormula(tr("Length"), i->getFormulaLength(), VAbstractTool::AttrLength); + AddPropertyLineColor(i, tr("Line color"), VAbstractTool::ColorsList(), VAbstractTool::AttrLineColor); + AddPropertyFormula(tr("Length"), i->GetFormulaLength(), VAbstractTool::AttrLength); } //--------------------------------------------------------------------------------------------------------------------- @@ -1119,6 +1191,7 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolSpline(QGraphicsItem *item) itemFactor->setSetting("Precision", 3); itemFactor->setValue(spl.GetKcurve()); AddProperty(itemFactor, VAbstractTool::AttrKCurve); + AddPropertyLineColor(i, tr("Color"), VAbstractTool::ColorsList(), VAbstractTool::AttrColor); } //--------------------------------------------------------------------------------------------------------------------- @@ -1134,8 +1207,9 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolSplinePath(QGraphicsItem *item) itemFactor->setSetting("Max", 1000); itemFactor->setSetting("Step", 0.01); itemFactor->setSetting("Precision", 3); - itemFactor->setValue(splPath.getKCurve()); + itemFactor->setValue(splPath.GetKCurve()); AddProperty(itemFactor, VAbstractTool::AttrKCurve); + AddPropertyLineColor(i, tr("Color"), VAbstractTool::ColorsList(), VAbstractTool::AttrColor); } //--------------------------------------------------------------------------------------------------------------------- @@ -1157,7 +1231,8 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolLineIntersectAxis(QGraphicsItem AddPropertyPointName(i, tr("Point label")); AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics()); - AddPropertyFormula(tr("Angle"), i->getFormulaAngle(), VAbstractTool::AttrAngle); + AddPropertyLineColor(i, tr("Line color"), VAbstractTool::ColorsList(), VAbstractTool::AttrLineColor); + AddPropertyFormula(tr("Angle"), i->GetFormulaAngle(), VAbstractTool::AttrAngle); } //--------------------------------------------------------------------------------------------------------------------- @@ -1169,7 +1244,8 @@ void VToolOptionsPropertyBrowser::ShowOptionsToolCurveIntersectAxis(QGraphicsIte AddPropertyPointName(i, tr("Point label")); AddPropertyLineType(i, tr("Line type"), VAbstractTool::LineStylesPics()); - AddPropertyFormula(tr("Angle"), i->getFormulaAngle(), VAbstractTool::AttrAngle); + AddPropertyLineColor(i, tr("Line color"), VAbstractTool::ColorsList(), VAbstractTool::AttrLineColor); + AddPropertyFormula(tr("Angle"), i->GetFormulaAngle(), VAbstractTool::AttrAngle); } //--------------------------------------------------------------------------------------------------------------------- @@ -1186,15 +1262,22 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolEndLine() VToolEndLine *i = qgraphicsitem_cast(currentItem); idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + { const qint32 index = VLineTypeProperty::IndexOfStyle(VAbstractTool::LineStylesPics(), i->getLineType()); idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); + } + + { + const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + idToProperty[VAbstractTool::AttrLineColor]->setValue(index); + } QVariant valueFormula; - valueFormula.setValue(i->getFormulaLength()); + valueFormula.setValue(i->GetFormulaLength()); idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); QVariant valueAngle; - valueAngle.setValue(i->getFormulaAngle()); + valueAngle.setValue(i->GetFormulaAngle()); idToProperty[VAbstractTool::AttrAngle]->setValue(valueAngle); } @@ -1204,11 +1287,18 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolAlongLine() VToolAlongLine *i = qgraphicsitem_cast(currentItem); idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + { const qint32 index = VLineTypeProperty::IndexOfStyle(VAbstractTool::LineStylesPics(), i->getLineType()); idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); + } + + { + const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + idToProperty[VAbstractTool::AttrLineColor]->setValue(index); + } QVariant valueFormula; - valueFormula.setValue(i->getFormulaLength()); + valueFormula.setValue(i->GetFormulaLength()); idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); } @@ -1219,16 +1309,19 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolArc() QVariant valueRadius; - valueRadius.setValue(i->getFormulaRadius()); + valueRadius.setValue(i->GetFormulaRadius()); idToProperty[VAbstractTool::AttrRadius]->setValue(valueRadius); QVariant valueFirstAngle; - valueFirstAngle.setValue(i->getFormulaF1()); + valueFirstAngle.setValue(i->GetFormulaF1()); idToProperty[VAbstractTool::AttrAngle1]->setValue(valueFirstAngle); QVariant valueSecondAngle; - valueSecondAngle.setValue(i->getFormulaF2()); + valueSecondAngle.setValue(i->GetFormulaF2()); idToProperty[VAbstractTool::AttrAngle2]->setValue(valueSecondAngle); + + const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + idToProperty[VAbstractTool::AttrColor]->setValue(index); } //--------------------------------------------------------------------------------------------------------------------- @@ -1239,11 +1332,18 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolBisector() idToProperty[VAbstractTool::AttrName]->setValue(i->name()); QVariant valueFormula; - valueFormula.setValue(i->getFormulaLength()); + valueFormula.setValue(i->GetFormulaLength()); idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); + { const qint32 index = VLineTypeProperty::IndexOfStyle(VAbstractTool::LineStylesPics(), i->getLineType()); idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); + } + + { + const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + idToProperty[VAbstractTool::AttrLineColor]->setValue(index); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -1254,8 +1354,11 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCutArc() idToProperty[VAbstractTool::AttrName]->setValue(i->name()); QVariant valueFormula; - valueFormula.setValue(i->getFormula()); + valueFormula.setValue(i->GetFormula()); idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); + + const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + idToProperty[VAbstractTool::AttrColor]->setValue(index); } //--------------------------------------------------------------------------------------------------------------------- @@ -1266,8 +1369,11 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCutSpline() idToProperty[VAbstractTool::AttrName]->setValue(i->name()); QVariant valueFormula; - valueFormula.setValue(i->getFormula()); + valueFormula.setValue(i->GetFormula()); idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); + + const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + idToProperty[VAbstractTool::AttrColor]->setValue(index); } //--------------------------------------------------------------------------------------------------------------------- @@ -1278,8 +1384,11 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCutSplinePath() idToProperty[VAbstractTool::AttrName]->setValue(i->name()); QVariant valueFormula; - valueFormula.setValue(i->getFormula()); + valueFormula.setValue(i->GetFormula()); idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); + + const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + idToProperty[VAbstractTool::AttrColor]->setValue(index); } //--------------------------------------------------------------------------------------------------------------------- @@ -1289,8 +1398,15 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolHeight() idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + { const qint32 index = VLineTypeProperty::IndexOfStyle(VAbstractTool::LineStylesPics(), i->getLineType()); idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); + } + + { + const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + idToProperty[VAbstractTool::AttrLineColor]->setValue(index); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -1298,8 +1414,15 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolLine() { VToolLine *i = qgraphicsitem_cast(currentItem); + { const qint32 index = VLineTypeProperty::IndexOfStyle(VAbstractTool::LineStylesPics(), i->getLineType()); idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); + } + + { + const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + idToProperty[VAbstractTool::AttrLineColor]->setValue(index); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -1316,15 +1439,22 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolNormal() VToolNormal *i = qgraphicsitem_cast(currentItem); QVariant valueFormula; - valueFormula.setValue(i->getFormulaLength()); + valueFormula.setValue(i->GetFormulaLength()); idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); idToProperty[VAbstractTool::AttrName]->setValue(i->name()); - idToProperty[VAbstractTool::AttrAngle]->setValue( i->getAngle()); + idToProperty[VAbstractTool::AttrAngle]->setValue( i->GetAngle()); + { const qint32 index = VLineTypeProperty::IndexOfStyle(VAbstractTool::LineStylesPics(), i->getLineType()); idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); + } + + { + const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + idToProperty[VAbstractTool::AttrLineColor]->setValue(index); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -1353,13 +1483,20 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolShoulderPoint() VToolShoulderPoint *i = qgraphicsitem_cast(currentItem); QVariant valueFormula; - valueFormula.setValue(i->getFormulaLength()); + valueFormula.setValue(i->GetFormulaLength()); idToProperty[VAbstractTool::AttrLength]->setValue(valueFormula); idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + { const qint32 index = VLineTypeProperty::IndexOfStyle(VAbstractTool::LineStylesPics(), i->getLineType()); idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); + } + + { + const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + idToProperty[VAbstractTool::AttrLineColor]->setValue(index); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -1369,6 +1506,9 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSpline() VSpline spl = i->getSpline(); idToProperty[VAbstractTool::AttrKCurve]->setValue(spl.GetKcurve()); + + const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + idToProperty[VAbstractTool::AttrColor]->setValue(index); } //--------------------------------------------------------------------------------------------------------------------- @@ -1377,7 +1517,10 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolSplinePath() VToolSplinePath *i = qgraphicsitem_cast(currentItem); VSplinePath splPath = i->getSplinePath(); - idToProperty[VAbstractTool::AttrKCurve]->setValue(splPath.getKCurve()); + idToProperty[VAbstractTool::AttrKCurve]->setValue(splPath.GetKCurve()); + + const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + idToProperty[VAbstractTool::AttrColor]->setValue(index); } //--------------------------------------------------------------------------------------------------------------------- @@ -1394,11 +1537,18 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolLineIntersectAxis() VToolLineIntersectAxis *i = qgraphicsitem_cast(currentItem); idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + { const qint32 index = VLineTypeProperty::IndexOfStyle(VAbstractTool::LineStylesPics(), i->getLineType()); idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); + } + + { + const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + idToProperty[VAbstractTool::AttrLineColor]->setValue(index); + } QVariant valueAngle; - valueAngle.setValue(i->getFormulaAngle()); + valueAngle.setValue(i->GetFormulaAngle()); idToProperty[VAbstractTool::AttrAngle]->setValue(valueAngle); } @@ -1408,11 +1558,18 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolCurveIntersectAxis() VToolCurveIntersectAxis *i = qgraphicsitem_cast(currentItem); idToProperty[VAbstractTool::AttrName]->setValue(i->name()); + { const qint32 index = VLineTypeProperty::IndexOfStyle(VAbstractTool::LineStylesPics(), i->getLineType()); idToProperty[VAbstractTool::AttrTypeLine]->setValue(index); + } + + { + const qint32 index = VLineColorProperty::IndexOfColor(VAbstractTool::ColorsList(), i->GetLineColor()); + idToProperty[VAbstractTool::AttrLineColor]->setValue(index); + } QVariant valueAngle; - valueAngle.setValue(i->getFormulaAngle()); + valueAngle.setValue(i->GetFormulaAngle()); idToProperty[VAbstractTool::AttrAngle]->setValue(valueAngle); } @@ -1444,6 +1601,8 @@ QStringList VToolOptionsPropertyBrowser::PropertiesList() const << VAbstractTool::AttrPShoulder /* 22 */ << VAbstractTool::AttrAxisP1 /* 23 */ << VAbstractTool::AttrAxisP2 /* 24 */ - << VAbstractTool::AttrKCurve; /* 25 */ + << VAbstractTool::AttrKCurve /* 25 */ + << VAbstractTool::AttrLineColor /* 26 */ + << VAbstractTool::AttrColor; /* 27 */ return attr; } diff --git a/src/app/widgets/vtooloptionspropertybrowser.h b/src/app/widgets/vtooloptionspropertybrowser.h index b2b918e99..50a4d9ed8 100644 --- a/src/app/widgets/vtooloptionspropertybrowser.h +++ b/src/app/widgets/vtooloptionspropertybrowser.h @@ -73,6 +73,10 @@ private: template void AddPropertyLineType(Tool *i, const QString &propertyName, const QMap &styles); + template + void AddPropertyLineColor(Tool *i, const QString &propertyName, const QMap &colors, + const QString &id); + void AddPropertyFormula(const QString &propertyName, const VFormula &formula, const QString &attrName); QStringList PropertiesList() const; diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp index 02b401175..5b5d3b4f9 100644 --- a/src/app/xml/vpattern.cpp +++ b/src/app/xml/vpattern.cpp @@ -857,12 +857,11 @@ void VPattern::haveLiteChange() /** * @brief ShowHistoryTool hightlight tool. * @param id tool id. - * @param color hightlight color. * @param enable enable or diasable hightlight. */ -void VPattern::ShowHistoryTool(quint32 id, Qt::GlobalColor color, bool enable) +void VPattern::ShowHistoryTool(quint32 id, bool enable) { - emit ShowTool(id, color, enable); + emit ShowTool(id, enable); } //--------------------------------------------------------------------------------------------------------------------- @@ -1088,10 +1087,11 @@ void VPattern::ParseDetails(const QDomElement &domElement, const Document &parse //--------------------------------------------------------------------------------------------------------------------- void VPattern::PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx, qreal &my, - QString &typeLine) + QString &typeLine, QString &lineColor) { PointsCommonAttributes(domElement, id, name, mx, my); typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine); + lineColor = GetParametrString(domElement, VAbstractTool::AttrLineColor, VAbstractTool::ColorBlack); } //--------------------------------------------------------------------------------------------------------------------- @@ -1129,6 +1129,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem qreal mx = 0; qreal my = 0; QString typeLine; + QString lineColor; QStringList points = QStringList() << VToolSinglePoint::ToolType << VToolEndLine::ToolType << VToolAlongLine::ToolType << VToolShoulderPoint::ToolType @@ -1161,7 +1162,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem scene->addItem(spoint); connect(spoint, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(scene, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, spoint, &VToolPoint::Disable); + connect(scene, &VMainGraphicsScene::DisableItem, spoint, &VToolSinglePoint::Disable); tools[id] = spoint; } } @@ -1178,7 +1179,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem case 1: //VToolEndLine::ToolType try { - PointsCommonAttributes(domElement, id, name, mx, my, typeLine); + PointsCommonAttributes(domElement, id, name, mx, my, typeLine, lineColor); const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); QString f = formula;//need for saving fixed formula; @@ -1188,8 +1189,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const QString angle = GetParametrString(domElement, VAbstractTool::AttrAngle, "0.0"); QString angleFix = angle; - VToolEndLine::Create(id, name, typeLine, f, angleFix, basePointId, mx, my, scene, this, data, parse, - Source::FromFile); + VToolEndLine::Create(id, name, typeLine, lineColor, f, angleFix, basePointId, mx, my, scene, this, data, + parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula || angleFix != angle) { @@ -1214,14 +1215,14 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem case 2: //VToolAlongLine::ToolType try { - PointsCommonAttributes(domElement, id, name, mx, my, typeLine); + PointsCommonAttributes(domElement, id, name, mx, my, typeLine, lineColor); const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); QString f = formula;//need for saving fixed formula; const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, NULL_ID_STR); const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, NULL_ID_STR); - VToolAlongLine::Create(id, name, typeLine, f, firstPointId, secondPointId, mx, my, scene, this, - data, parse, Source::FromFile); + VToolAlongLine::Create(id, name, typeLine, lineColor, f, firstPointId, secondPointId, mx, my, scene, + this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) { @@ -1245,15 +1246,15 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem case 3: //VToolShoulderPoint::ToolType try { - PointsCommonAttributes(domElement, id, name, mx, my, typeLine); + PointsCommonAttributes(domElement, id, name, mx, my, typeLine, lineColor); const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); QString f = formula;//need for saving fixed formula; const quint32 p1Line = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, NULL_ID_STR); const quint32 p2Line = GetParametrUInt(domElement, VAbstractTool::AttrP2Line, NULL_ID_STR); const quint32 pShoulder = GetParametrUInt(domElement, VAbstractTool::AttrPShoulder, NULL_ID_STR); - VToolShoulderPoint::Create(id, f, p1Line, p2Line, pShoulder, typeLine, name, mx, my, scene, this, - data, parse, Source::FromFile); + VToolShoulderPoint::Create(id, f, p1Line, p2Line, pShoulder, typeLine, lineColor, name, mx, my, scene, + this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) { @@ -1277,14 +1278,14 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem case 4: //VToolNormal::ToolType try { - PointsCommonAttributes(domElement, id, name, mx, my, typeLine); + PointsCommonAttributes(domElement, id, name, mx, my, typeLine, lineColor); const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); QString f = formula;//need for saving fixed formula; const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, NULL_ID_STR); const quint32 secondPointId = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, NULL_ID_STR); const qreal angle = GetParametrDouble(domElement, VAbstractTool::AttrAngle, "0.0"); - VToolNormal::Create(id, f, firstPointId, secondPointId, typeLine, name, angle, mx, my, scene, + VToolNormal::Create(id, f, firstPointId, secondPointId, typeLine, lineColor, name, angle, mx, my, scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) @@ -1309,7 +1310,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem case 5: //VToolBisector::ToolType try { - PointsCommonAttributes(domElement, id, name, mx, my, typeLine); + PointsCommonAttributes(domElement, id, name, mx, my, typeLine, lineColor); const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "100.0"); QString f = formula;//need for saving fixed formula; const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrFirstPoint, NULL_ID_STR); @@ -1317,7 +1318,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const quint32 thirdPointId = GetParametrUInt(domElement, VAbstractTool::AttrThirdPoint, NULL_ID_STR); VToolBisector::Create(id, f, firstPointId, secondPointId, thirdPointId, - typeLine, name, mx, my, scene, this, data, parse, Source::FromFile); + typeLine, lineColor, name, mx, my, scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) { @@ -1410,12 +1411,12 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem case 9: //VToolHeight::ToolType try { - PointsCommonAttributes(domElement, id, name, mx, my, typeLine); + PointsCommonAttributes(domElement, id, name, mx, my, typeLine, lineColor); const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, NULL_ID_STR); const quint32 p1LineId = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, NULL_ID_STR); const quint32 p2LineId = GetParametrUInt(domElement, VAbstractTool::AttrP2Line, NULL_ID_STR); - VToolHeight::Create(id, name, typeLine, basePointId, p1LineId, p2LineId, + VToolHeight::Create(id, name, typeLine, lineColor, basePointId, p1LineId, p2LineId, mx, my, scene, this, data, parse, Source::FromFile); } catch (const VExceptionBadId &e) @@ -1468,8 +1469,11 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0"); QString f = formula;//need for saving fixed formula; const quint32 splineId = GetParametrUInt(domElement, VToolCutSpline::AttrSpline, NULL_ID_STR); + const QString color = GetParametrString(domElement, VAbstractTool::AttrColor, + VAbstractTool::ColorBlack); - VToolCutSpline::Create(id, name, f, splineId, mx, my, scene, this, data, parse, Source::FromFile); + VToolCutSpline::Create(id, name, f, splineId, mx, my, color, scene, this, data, parse, + Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) { @@ -1498,8 +1502,10 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem QString f = formula;//need for saving fixed formula; const quint32 splinePathId = GetParametrUInt(domElement, VToolCutSplinePath::AttrSplinePath, NULL_ID_STR); + const QString color = GetParametrString(domElement, VAbstractTool::AttrColor, + VAbstractTool::ColorBlack); - VToolCutSplinePath::Create(id, name, f, splinePathId, mx, my, scene, this, data, parse, + VToolCutSplinePath::Create(id, name, f, splinePathId, mx, my, color, scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) @@ -1528,8 +1534,10 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const QString formula = GetParametrString(domElement, VAbstractTool::AttrLength, "0"); QString f = formula;//need for saving fixed formula; const quint32 arcId = GetParametrUInt(domElement, VToolCutArc::AttrArc, NULL_ID_STR); + const QString color = GetParametrString(domElement, VAbstractTool::AttrColor, + VAbstractTool::ColorBlack); - VToolCutArc::Create(id, name, f, arcId, mx, my, scene, this, data, parse, Source::FromFile); + VToolCutArc::Create(id, name, f, arcId, mx, my, color, scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (f != formula) { @@ -1553,7 +1561,7 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem case 15: //VToolLineIntersectAxis::ToolType try { - PointsCommonAttributes(domElement, id, name, mx, my, typeLine); + PointsCommonAttributes(domElement, id, name, mx, my, typeLine, lineColor); const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, NULL_ID_STR); const quint32 firstPointId = GetParametrUInt(domElement, VAbstractTool::AttrP1Line, NULL_ID_STR); @@ -1562,8 +1570,8 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem const QString angle = GetParametrString(domElement, VAbstractTool::AttrAngle, "0.0"); QString angleFix = angle; - VToolLineIntersectAxis::Create(id, name, typeLine, angleFix, basePointId, firstPointId, secondPointId, - mx, my, scene, this, data, parse, Source::FromFile); + VToolLineIntersectAxis::Create(id, name, typeLine, lineColor, angleFix, basePointId, firstPointId, + secondPointId, mx, my, scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (angleFix != angle) { @@ -1589,15 +1597,15 @@ void VPattern::ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElem case 16: //VToolCurveIntersectAxis::ToolType try { - PointsCommonAttributes(domElement, id, name, mx, my, typeLine); + PointsCommonAttributes(domElement, id, name, mx, my, typeLine, lineColor); const quint32 basePointId = GetParametrUInt(domElement, VAbstractTool::AttrBasePoint, NULL_ID_STR); const quint32 curveId = GetParametrUInt(domElement, VAbstractTool::AttrCurve, NULL_ID_STR); const QString angle = GetParametrString(domElement, VAbstractTool::AttrAngle, "0.0"); QString angleFix = angle; - VToolCurveIntersectAxis::Create(id, name, typeLine, angleFix, basePointId, curveId, mx, my, scene, this, - data, parse, Source::FromFile); + VToolCurveIntersectAxis::Create(id, name, typeLine, lineColor, angleFix, basePointId, curveId, mx, my, + scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (angleFix != angle) { @@ -1646,8 +1654,10 @@ void VPattern::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &do const quint32 secondPoint = GetParametrUInt(domElement, VAbstractTool::AttrSecondPoint, NULL_ID_STR); const QString typeLine = GetParametrString(domElement, VAbstractTool::AttrTypeLine, VAbstractTool::TypeLineLine); + const QString lineColor = GetParametrString(domElement, VAbstractTool::AttrLineColor, + VAbstractTool::ColorBlack); - VToolLine::Create(id, firstPoint, secondPoint, typeLine, scene, this, data, parse, Source::FromFile); + VToolLine::Create(id, firstPoint, secondPoint, typeLine, lineColor, scene, this, data, parse, Source::FromFile); } catch (const VExceptionBadId &e) { @@ -1855,9 +1865,11 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement & const qreal kAsm1 = GetParametrDouble(domElement, VAbstractTool::AttrKAsm1, "1.0"); const qreal kAsm2 = GetParametrDouble(domElement, VAbstractTool::AttrKAsm2, "1.0"); const qreal kCurve = GetParametrDouble(domElement, VAbstractTool::AttrKCurve, "1.0"); + const QString color = GetParametrString(domElement, VAbstractTool::AttrColor, + VAbstractTool::ColorBlack); - VToolSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, scene, this, data, parse, - Source::FromFile); + VToolSpline::Create(id, point1, point4, kAsm1, kAsm2, angle1, angle2, kCurve, color, scene, this, data, + parse, Source::FromFile); } catch (const VExceptionBadId &e) { @@ -1872,6 +1884,8 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement & { ToolsCommonAttributes(domElement, id); const qreal kCurve = GetParametrDouble(domElement, VAbstractTool::AttrKCurve, "1.0"); + const QString color = GetParametrString(domElement, VAbstractTool::AttrColor, + VAbstractTool::ColorBlack); VSplinePath *path = new VSplinePath(kCurve); const QDomNodeList nodeList = domElement.childNodes(); @@ -1902,7 +1916,7 @@ void VPattern::ParseSplineElement(VMainGraphicsScene *scene, const QDomElement & } } - VToolSplinePath::Create(id, path, scene, this, data, parse, Source::FromFile); + VToolSplinePath::Create(id, path, color, scene, this, data, parse, Source::FromFile); } catch (const VExceptionBadId &e) { @@ -1984,8 +1998,10 @@ void VPattern::ParseArcElement(VMainGraphicsScene *scene, QDomElement &domElemen QString f1Fix = f1;//need for saving fixed formula; const QString f2 = GetParametrString(domElement, VAbstractTool::AttrAngle2, "270"); QString f2Fix = f2;//need for saving fixed formula; + const QString color = GetParametrString(domElement, VAbstractTool::AttrColor, + VAbstractTool::ColorBlack); - VToolArc::Create(id, center, r, f1Fix, f2Fix, scene, this, data, parse, Source::FromFile); + VToolArc::Create(id, center, r, f1Fix, f2Fix, color, scene, this, data, parse, Source::FromFile); //Rewrite attribute formula. Need for situation when we have wrong formula. if (r != radius || f1Fix != f1 || f2Fix != f2) { diff --git a/src/app/xml/vpattern.h b/src/app/xml/vpattern.h index 439d5c0be..ea4db3e0b 100644 --- a/src/app/xml/vpattern.h +++ b/src/app/xml/vpattern.h @@ -197,10 +197,9 @@ signals: /** * @brief ShowTool highlight tool. * @param id tool id. - * @param color highlight color. * @param enable enable or disable highlight. */ - void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); + void ShowTool(quint32 id, bool enable); /** * @brief ChangedCursor change cursor position. * @param id tool id. @@ -214,7 +213,7 @@ signals: public slots: void LiteParseTree(const Document &parse); void haveLiteChange(); - void ShowHistoryTool(quint32 id, Qt::GlobalColor color, bool enable); + void ShowHistoryTool(quint32 id, bool enable); void NeedFullParsing(); void ClearScene(); protected: @@ -267,7 +266,7 @@ private: void UpdateMeasurements(); void ToolsCommonAttributes(const QDomElement &domElement, quint32 &id); void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx, - qreal &my, QString &typeLine); + qreal &my, QString &typeLine, QString &lineColor); void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, QString &name, qreal &mx, qreal &my); void PointsCommonAttributes(const QDomElement &domElement, quint32 &id, qreal &mx, qreal &my); diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index 2037ec8b5..f8b8fe11e 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -5,5 +5,6 @@ schema/pattern/v0.1.0.xsd schema/pattern/v0.1.1.xsd schema/pattern/v0.1.2.xsd + schema/pattern/v0.1.3.xsd diff --git a/src/libs/ifc/schema/pattern/v0.1.3.xsd b/src/libs/ifc/schema/pattern/v0.1.3.xsd new file mode 100644 index 000000000..18cf62b78 --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.1.3.xsd @@ -0,0 +1,307 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index af47c64ed..df94c32cc 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -40,8 +40,8 @@ */ const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0"); -const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.1.2"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.1.2.xsd"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.1.3"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.1.3.xsd"); //--------------------------------------------------------------------------------------------------------------------- VPatternConverter::VPatternConverter(const QString &fileName) @@ -91,6 +91,8 @@ QString VPatternConverter::XSDSchema(int ver) const case (0x000101): return QStringLiteral("://schema/pattern/v0.1.1.xsd"); case (0x000102): + return QStringLiteral("://schema/pattern/v0.1.2.xsd"); + case (0x000103): return CurrentSchema; default: { @@ -119,9 +121,16 @@ void VPatternConverter::ApplyPatches() ToV0_1_2(); const QString schema = XSDSchema(0x000102); ValidateXML(schema, fileName); - break; + // continue conversion } case (0x000102): + { + ToV0_1_3(); + const QString schema = XSDSchema(0x000103); + ValidateXML(schema, fileName); + // continue conversion + } + case (0x000103): break; default: break; @@ -159,3 +168,10 @@ void VPatternConverter::ToV0_1_2() SetVersion(QStringLiteral("0.1.2")); Save(); } + +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_1_3() +{ + SetVersion(QStringLiteral("0.1.3")); + Save(); +} diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index 5d8b4c651..b8afb8c3c 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -57,6 +57,7 @@ private: void ToV0_1_1(); void ToV0_1_2(); + void ToV0_1_3(); }; #endif // VPATTERNCONVERTER_H diff --git a/src/libs/vpropertyexplorer/plugins/vcolorproperty.cpp b/src/libs/vpropertyexplorer/plugins/vcolorproperty.cpp index f47b41856..38a1791a9 100644 --- a/src/libs/vpropertyexplorer/plugins/vcolorproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vcolorproperty.cpp @@ -36,7 +36,7 @@ QVariant VColorProperty::data (int column, int role) const { if (column == DPC_Data && (Qt::DisplayRole == role)) { - return VColorPropertyEditor::getColorString(d_ptr->VariantValue.value()); + return VColorPropertyEditor::GetColorString(d_ptr->VariantValue.value()); } else if (Qt::EditRole == role) { @@ -44,7 +44,7 @@ QVariant VColorProperty::data (int column, int role) const } else if (column == DPC_Data && (Qt::DecorationRole == role)) { - return VColorPropertyEditor::getColorPixmap(d_ptr->VariantValue.value()); + return VColorPropertyEditor::GetColorPixmap(d_ptr->VariantValue.value()); } else return VProperty::data(column, role); @@ -58,7 +58,7 @@ QWidget* VColorProperty::createEditor(QWidget* parent, const QStyleOptionViewIte Q_UNUSED(delegate); VColorPropertyEditor* tmpWidget = new VColorPropertyEditor(parent); - tmpWidget->setColor(d_ptr->VariantValue.value()); + tmpWidget->SetColor(d_ptr->VariantValue.value()); return tmpWidget; } @@ -68,7 +68,7 @@ bool VColorProperty::setEditorData(QWidget* editor) VColorPropertyEditor* tmpWidget = qobject_cast(editor); if (tmpWidget) { - tmpWidget->setColor(d_ptr->VariantValue.value()); + tmpWidget->SetColor(d_ptr->VariantValue.value()); } else return false; @@ -82,7 +82,7 @@ QVariant VColorProperty::getEditorData(const QWidget *editor) const const VColorPropertyEditor* tmpWidget = qobject_cast(editor); if (tmpWidget) { - return tmpWidget->getColor(); + return tmpWidget->GetColor(); } return QVariant(); diff --git a/src/libs/vpropertyexplorer/plugins/vcolorpropertyeditor.cpp b/src/libs/vpropertyexplorer/plugins/vcolorpropertyeditor.cpp index ab55c2378..8dface9a7 100644 --- a/src/libs/vpropertyexplorer/plugins/vcolorpropertyeditor.cpp +++ b/src/libs/vpropertyexplorer/plugins/vcolorpropertyeditor.cpp @@ -47,11 +47,11 @@ VColorPropertyEditor::VColorPropertyEditor(QWidget *parent) // Create the text label TextLabel = new QLabel(this); - TextLabel->setText(getColorString(Color)); + TextLabel->setText(GetColorString(Color)); // Create the label for the pixmap ColorLabel = new QLabel(this); - ColorLabel->setPixmap(getColorPixmap(Color)); + ColorLabel->setPixmap(GetColorPixmap(Color)); // Spacer (this is needed for proper display of the label and button) Spacer = new QSpacerItem(1, 0, QSizePolicy::Expanding, QSizePolicy::Ignored); @@ -68,17 +68,17 @@ VColorPropertyEditor::VColorPropertyEditor(QWidget *parent) //ColorLabel->hide(); // for now, we just use the standard display and only add the button } -void VColorPropertyEditor::setColor(const QColor& color_) +void VColorPropertyEditor::SetColor(const QColor& color_) { if (Color != color_) { Color = color_; - ColorLabel->setPixmap(getColorPixmap(Color)); - TextLabel->setText(getColorString(Color)); + ColorLabel->setPixmap(GetColorPixmap(Color)); + TextLabel->setText(GetColorString(Color)); } } -QPixmap VColorPropertyEditor::getColorPixmap(const QColor& color, unsigned int size) +QPixmap VColorPropertyEditor::GetColorPixmap(const QColor& color, unsigned int size) { QImage tmpImgage(static_cast(size), static_cast(size), QImage::Format_ARGB32_Premultiplied); tmpImgage.fill(static_cast(color.rgb())); @@ -86,7 +86,7 @@ QPixmap VColorPropertyEditor::getColorPixmap(const QColor& color, unsigned int s // todo: support alpha channel } -QString VColorPropertyEditor::getColorString(const QColor& color) +QString VColorPropertyEditor::GetColorString(const QColor& color) { return QString("[%1, %2, %3] (%4)").arg(color.red()).arg(color.green()).arg(color.blue()).arg(color.alpha()); } @@ -98,7 +98,7 @@ void VColorPropertyEditor::onToolButtonClicked() QRgb newRgba = QColorDialog::getRgba(oldRgba, &ok, this); if (ok && newRgba != oldRgba) { - setColor(QColor::fromRgba(newRgba)); + SetColor(QColor::fromRgba(newRgba)); emit dataChangedByUser(Color, this); UserChangeEvent *event = new UserChangeEvent(); QCoreApplication::postEvent ( this, event ); @@ -123,7 +123,7 @@ VColorPropertyEditor::~VColorPropertyEditor() // } -QColor VColorPropertyEditor::getColor() const +QColor VColorPropertyEditor::GetColor() const { return Color; } diff --git a/src/libs/vpropertyexplorer/plugins/vcolorpropertyeditor.h b/src/libs/vpropertyexplorer/plugins/vcolorpropertyeditor.h index ac6dba31a..2de237f34 100644 --- a/src/libs/vpropertyexplorer/plugins/vcolorpropertyeditor.h +++ b/src/libs/vpropertyexplorer/plugins/vcolorpropertyeditor.h @@ -45,31 +45,31 @@ public: //! Returns the color currently set - QColor getColor() const; + QColor GetColor() const; //! A little helper function generating an image to represent a color //! \param color The color to fill the image with //! \size The size of the generated pixmap //! \return Returns a QPixmap - static QPixmap getColorPixmap(const QColor& color, unsigned int size = 16); + static QPixmap GetColorPixmap(const QColor& color, unsigned int size = 16); //! A helper function to convert a color into a string. //! \param color The color to fill the image with //! \return The color as string, usually in the format [RRR, GGG, BBB] (AAA) - static QString getColorString(const QColor& color); + static QString GetColorString(const QColor& color); //! Needed for proper event handling bool eventFilter(QObject *obj, QEvent *ev); signals: //! This is emitted, when the user changes the color - void dataChangedByUser(const QColor &getColor, VColorPropertyEditor* editor); + void dataChangedByUser(const QColor &GetColor, VColorPropertyEditor* editor); void dataChanged(); public slots: //! Sets the color of the widget - void setColor(const QColor &color_); + void SetColor(const QColor &color_); private slots: void onToolButtonClicked(); diff --git a/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.cpp b/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.cpp new file mode 100644 index 000000000..f4fce1de4 --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.cpp @@ -0,0 +1,170 @@ +/************************************************************************ + ** + ** @file vlinecolorproperty.cpp + ** @author Roman Telezhynskyi + ** @date 7 2, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "vlinecolorproperty.h" +#include "../vproperty_p.h" + +#include +#include + +using namespace VPE; + +VLineColorProperty::VLineColorProperty(const QString &name) + : VProperty(name, QVariant::Int), colors(), indexList() +{ + VProperty::d_ptr->VariantValue = 0; + VProperty::d_ptr->VariantValue.convert(QVariant::Int); +} + +QVariant VLineColorProperty::data(int column, int role) const +{ + if (colors.empty()) + { + return QVariant(); + } + + int tmpIndex = VProperty::d_ptr->VariantValue.toInt(); + + if (tmpIndex < 0 || tmpIndex >= indexList.count()) + { + tmpIndex = 0; + } + + if (column == DPC_Data && Qt::DisplayRole == role) + { + return indexList.at(tmpIndex); + } + else if (column == DPC_Data && Qt::EditRole == role) + { + return tmpIndex; + } + else + { + return VProperty::data(column, role); + } +} + +QWidget *VLineColorProperty::createEditor(QWidget *parent, const QStyleOptionViewItem &options, + const QAbstractItemDelegate *delegate) +{ + Q_UNUSED(options); + Q_UNUSED(delegate); + QComboBox* tmpEditor = new QComboBox(parent); + tmpEditor->clear(); + + QMap::const_iterator i = colors.constBegin(); + while (i != colors.constEnd()) + { + QPixmap pix(16, 16); + pix.fill(QColor(i.key())); + tmpEditor->addItem(QIcon(pix), i.value(), QVariant(i.key())); + ++i; + } + + tmpEditor->setCurrentIndex(VProperty::d_ptr->VariantValue.toInt()); + connect(tmpEditor, static_cast(&QComboBox::currentIndexChanged), this, + &VLineColorProperty::currentIndexChanged); + + VProperty::d_ptr->editor = tmpEditor; + return VProperty::d_ptr->editor; +} + +QVariant VLineColorProperty::getEditorData(const QWidget *editor) const +{ + const QComboBox* tmpEditor = qobject_cast(editor); + if (tmpEditor) + { + return tmpEditor->currentIndex(); + } + + return QVariant(0); +} + +void VLineColorProperty::setColors(const QMap &colors) +{ + this->colors = colors; + indexList.clear(); + QMap::const_iterator i = colors.constBegin(); + while (i != colors.constEnd()) + { + indexList.append(i.key()); + ++i; + } +} + +QMap VLineColorProperty::getColors() const +{ + return colors; +} + +void VLineColorProperty::setValue(const QVariant &value) +{ + int tmpIndex = value.toInt(); + + if (tmpIndex < 0 || tmpIndex >= indexList.count()) + { + tmpIndex = 0; + } + + VProperty::d_ptr->VariantValue = tmpIndex; + VProperty::d_ptr->VariantValue.convert(QVariant::Int); + + if (VProperty::d_ptr->editor != nullptr) + { + setEditorData(VProperty::d_ptr->editor); + } +} + +QString VLineColorProperty::type() const +{ + return QStringLiteral("lineColor"); +} + +VProperty *VLineColorProperty::clone(bool include_children, VProperty *container) const +{ + return VProperty::clone(include_children, container ? container : new VLineColorProperty(getName())); +} + +int VLineColorProperty::IndexOfColor(const QMap &colors, const QString &color) +{ + QVector indexList; + QMap::const_iterator i = colors.constBegin(); + while (i != colors.constEnd()) + { + indexList.append(i.key()); + ++i; + } + return indexList.indexOf(color); +} + +void VLineColorProperty::currentIndexChanged(int index) +{ + Q_UNUSED(index) + UserChangeEvent *event = new UserChangeEvent(); + QCoreApplication::postEvent ( VProperty::d_ptr->editor, event ); +} diff --git a/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.h b/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.h new file mode 100644 index 000000000..416b2a1d3 --- /dev/null +++ b/src/libs/vpropertyexplorer/plugins/vlinecolorproperty.h @@ -0,0 +1,100 @@ +/************************************************************************ + ** + ** @file vlinecolorproperty.h + ** @author Roman Telezhynskyi + ** @date 7 2, 2015 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2015 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef VLINECOLORPROPERTY_H +#define VLINECOLORPROPERTY_H + +#include "../vproperty.h" + +#include +#include + +namespace VPE +{ + +class VPROPERTYEXPLORERSHARED_EXPORT VLineColorProperty : public VProperty +{ + Q_OBJECT +public: + //! Constructor + VLineColorProperty(const QString& name); + + //! Destructor + ~VLineColorProperty() {} + + //! Get the data how it should be displayed + virtual QVariant data (int column = DPC_Name, int role = Qt::DisplayRole) const; + + //! Returns an editor widget, or NULL if it doesn't supply one + //! \param parent The widget to which the editor will be added as a child + //! \options Render options + //! \delegate A pointer to the QAbstractItemDelegate requesting the editor. This can be used to connect signals and + //! slots. + virtual QWidget *createEditor(QWidget* parent, const QStyleOptionViewItem& options, + const QAbstractItemDelegate* delegate); + + //! Gets the data from the widget + virtual QVariant getEditorData(const QWidget* editor) const; + + //! Sets the colors + virtual void setColors(const QMap &colors); + + //! Get the settings. This function has to be implemented in a subclass in order to have an effect + virtual QMap getColors() const; + + //! Sets the value of the property + virtual void setValue(const QVariant& value); + + //! Returns a string containing the type of the property + virtual QString type() const; + + //! Clones this property + //! \param include_children Indicates whether to also clone the children + //! \param container If a property is being passed here, no new VProperty is being created but instead it is tried + //! to fill all the data into container. This can also be used when subclassing this function. + //! \return Returns the newly created property (or container, if it was not NULL) + virtual VProperty* clone(bool include_children = true, VProperty* container = nullptr) const; + + static int IndexOfColor(const QMap &colors, const QString &color); + +public slots: + void currentIndexChanged(int index); + +protected: + //! The list of possible options to choose from + QMap colors; + QVector indexList; + // No use of d-pointer in this case, because it is unlikely this will change. If it does, we can still add other + //members by reimplementing the VPropertyPrivate class without touching this header file. +private: + Q_DISABLE_COPY(VLineColorProperty) +}; + +} + +#endif // VLINECOLORPROPERTY_H diff --git a/src/libs/vpropertyexplorer/vproperties.h b/src/libs/vpropertyexplorer/vproperties.h index 0c8467d4d..a86299421 100644 --- a/src/libs/vpropertyexplorer/vproperties.h +++ b/src/libs/vpropertyexplorer/vproperties.h @@ -35,5 +35,6 @@ #include "plugins/vshortcutproperty.h" #include "plugins/vstringproperty.h" #include "plugins/vwidgetproperty.h" +#include "plugins/vlinecolorproperty.h" #endif // VPROPERTIES_H diff --git a/src/libs/vpropertyexplorer/vpropertyexplorer.pri b/src/libs/vpropertyexplorer/vpropertyexplorer.pri index 871cff6d3..6f11c2705 100644 --- a/src/libs/vpropertyexplorer/vpropertyexplorer.pri +++ b/src/libs/vpropertyexplorer/vpropertyexplorer.pri @@ -28,7 +28,8 @@ SOURCES += \ $$PWD/plugins/vpointfproperty.cpp \ $$PWD/plugins/vobjectproperty.cpp \ $$PWD/stable.cpp \ - $$PWD/plugins/vlinetypeproperty.cpp + $$PWD/plugins/vlinetypeproperty.cpp \ + $$PWD/plugins/vlinecolorproperty.cpp HEADERS +=\ $$PWD/vpropertyexplorer_global.h \ @@ -69,4 +70,5 @@ HEADERS +=\ $$PWD/plugins/vobjectproperty.h \ $$PWD/vproperties.h \ $$PWD/stable.h \ - $$PWD/plugins/vlinetypeproperty.h + $$PWD/plugins/vlinetypeproperty.h \ + $$PWD/plugins/vlinecolorproperty.h