Merge with feature. Fixed issue #74. Fold Line in pattern piece.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-02-08 13:01:18 +02:00
commit 17fa00ba75
157 changed files with 3822 additions and 2759 deletions

View File

@ -40,10 +40,10 @@ class VContainer;
* Note. If created to many parser for different purpes in the same time parser can work wrong. * Note. If created to many parser for different purpes in the same time parser can work wrong.
* Example: * Example:
* DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data); * DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data);
* dialog->setFormula(formula); * dialog->SetFormula(formula);
* if (dialog->exec() == QDialog::Accepted) * 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. * //Need delete dialog here because parser in dialog don't allow use correct separator for parsing here.
* //Don't know why. * //Don't know why.
* delete dialog; * delete dialog;

View File

@ -56,7 +56,7 @@ VFormula &VFormula::operator=(const VFormula &formula)
{ {
return *this; return *this;
} }
this->formula = formula.getFormula(); this->formula = formula.GetFormula();
this->value = formula.getStringValue(); this->value = formula.getStringValue();
this->checkZero = formula.getCheckZero(); this->checkZero = formula.getCheckZero();
this->data = formula.getData(); this->data = formula.getData();
@ -69,7 +69,7 @@ VFormula &VFormula::operator=(const VFormula &formula)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VFormula::VFormula(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()), data(formula.getData()), toolId(formula.getToolId()), postfix(formula.getPostfix()), _error(formula.error()),
dValue(formula.getDoubleValue()) dValue(formula.getDoubleValue())
{} {}
@ -78,7 +78,7 @@ VFormula::VFormula(const VFormula &formula)
bool VFormula::operator==(const VFormula &formula) const bool VFormula::operator==(const VFormula &formula) const
{ {
bool isEqual = false; 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->checkZero == formula.getCheckZero() && this->data == formula.getData() &&
this->toolId == formula.getToolId() && this->postfix == formula.getPostfix() && this->toolId == formula.getToolId() && this->postfix == formula.getPostfix() &&
this->_error == formula.error() && qFuzzyCompare(this->dValue, formula.getDoubleValue())) 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) 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) if (formula != value)
{ {

View File

@ -46,8 +46,8 @@ public:
bool operator==(const VFormula &formula) const; bool operator==(const VFormula &formula) const;
bool operator!=(const VFormula &formula) const; bool operator!=(const VFormula &formula) const;
QString getFormula(FormulaType type = FormulaType::ToUser) const; QString GetFormula(FormulaType type = FormulaType::ToUser) const;
void setFormula(const QString &value, FormulaType type = FormulaType::ToUser); void SetFormula(const QString &value, FormulaType type = FormulaType::ToUser);
QString getStringValue() const; QString getStringValue() const;
qreal getDoubleValue() const; qreal getDoubleValue() const;

View File

@ -74,7 +74,7 @@ void DialogHistory::DialogAccepted()
{ {
QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0);
quint32 id = qvariant_cast<quint32>(item->data(Qt::UserRole)); quint32 id = qvariant_cast<quint32>(item->data(Qt::UserRole));
emit ShowHistoryTool(id, Qt::green, false); emit ShowHistoryTool(id, false);
emit DialogClosed(QDialog::Accepted); emit DialogClosed(QDialog::Accepted);
} }
@ -103,12 +103,12 @@ void DialogHistory::cellClicked(int row, int column)
{ {
QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0); QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0);
quint32 id = qvariant_cast<quint32>(item->data(Qt::UserRole)); quint32 id = qvariant_cast<quint32>(item->data(Qt::UserRole));
emit ShowHistoryTool(id, Qt::green, false); emit ShowHistoryTool(id, false);
cursorToolRecordRow = row; cursorToolRecordRow = row;
item = ui->tableWidget->item(cursorToolRecordRow, 0); item = ui->tableWidget->item(cursorToolRecordRow, 0);
id = qvariant_cast<quint32>(item->data(Qt::UserRole)); id = qvariant_cast<quint32>(item->data(Qt::UserRole));
emit ShowHistoryTool(id, Qt::green, true); emit ShowHistoryTool(id, true);
} }
} }
@ -434,7 +434,7 @@ void DialogHistory::ShowPoint()
cursorToolRecordRow = 0; cursorToolRecordRow = 0;
item = ui->tableWidget->item(0, 0); item = ui->tableWidget->item(0, 0);
quint32 id = qvariant_cast<quint32>(item->data(Qt::UserRole)); quint32 id = qvariant_cast<quint32>(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); QTableWidgetItem *item = ui->tableWidget->item(cursorToolRecordRow, 0);
quint32 id = qvariant_cast<quint32>(item->data(Qt::UserRole)); quint32 id = qvariant_cast<quint32>(item->data(Qt::UserRole));
emit ShowHistoryTool(id, Qt::green, false); emit ShowHistoryTool(id, false);
DialogTool::closeEvent(event); DialogTool::closeEvent(event);
} }

View File

@ -63,10 +63,9 @@ signals:
/** /**
* @brief ShowHistoryTool signal change color of selected in records tool * @brief ShowHistoryTool signal change color of selected in records tool
* @param id id of tool * @param id id of tool
* @param color new color of tool
* @param enable true enable selection, false disable selection * @param enable true enable selection, false disable selection
*/ */
void ShowHistoryTool(quint32 id, Qt::GlobalColor color, bool enable); void ShowHistoryTool(quint32 id, bool enable);
protected: protected:
virtual void closeEvent ( QCloseEvent * event ); virtual void closeEvent ( QCloseEvent * event );
private: private:

View File

@ -41,9 +41,8 @@
* @param parent parent widget * @param parent parent widget
*/ */
DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogAlongLine), number(0), :DialogTool(data, toolId, parent), ui(new Ui::DialogAlongLine),
typeLine(QString()), formula(QString()), firstPointId(NULL_ID), secondPointId(NULL_ID), formulaBaseHeight(0), formula(QString()), formulaBaseHeight(0), line(nullptr)
line(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
@ -61,7 +60,7 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, const quint32 &toolId,
FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint); FillComboBoxPoints(ui->comboBoxSecondPoint);
FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics()); FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics());
ui->comboBoxLineType->setCurrentIndex(0); FillComboBoxLineColors(ui->comboBoxLineColor);
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogAlongLine::PutHere); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogAlongLine::PutHere);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogAlongLine::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogAlongLine::NamePointChanged);
@ -180,16 +179,14 @@ void DialogAlongLine::ChosenObject(quint32 id, const SceneObject &type)
void DialogAlongLine::SaveData() void DialogAlongLine::SaveData()
{ {
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType);
formula = ui->plainTextEditFormula->toPlainText(); formula = ui->plainTextEditFormula->toPlainText();
formula.replace("\n", " "); formula.replace("\n", " ");
firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint);
secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint);
line->setPoint1Id(firstPointId); line->setPoint1Id(GetFirstPointId());
line->setPoint2Id(secondPointId); line->setPoint2Id(GetSecondPointId());
line->setLength(formula); line->setLength(formula);
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine()));
line->RefreshGeometry(); 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 * @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); line->setPoint2Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setFirstPointId set id first point of line * @brief SetFirstPointId set id first point of line
* @param value id * @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); line->setPoint1Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setFormula set string of formula * @brief SetFormula set string of formula
* @param value formula * @param value formula
*/ */
void DialogAlongLine::setFormula(const QString &value) void DialogAlongLine::SetFormula(const QString &value)
{ {
formula = qApp->FormulaToUser(value); formula = qApp->FormulaToUser(value);
// increase height if needed. // 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 * @param value type
*/ */
void DialogAlongLine::setTypeLine(const QString &value) void DialogAlongLine::SetTypeLine(const QString &value)
{ {
typeLine = value; ChangeCurrentData(ui->comboBoxLineType, value);
SetupTypeLine(ui->comboBoxLineType, value); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); }
//---------------------------------------------------------------------------------------------------------------------
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 * @param value name
*/ */
void DialogAlongLine::setPointName(const QString &value) void DialogAlongLine::SetPointName(const QString &value)
{ {
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); 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);
}

View File

@ -47,20 +47,23 @@ class DialogAlongLine : public DialogTool
public: public:
DialogAlongLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); DialogAlongLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogAlongLine(); ~DialogAlongLine();
QString getPointName() const;
void setPointName(const QString &value);
QString getTypeLine() const; void SetPointName(const QString &value);
void setTypeLine(const QString &value);
QString getFormula() const; QString GetTypeLine() const;
void setFormula(const QString &value); void SetTypeLine(const QString &value);
quint32 getFirstPointId() const; QString GetLineColor() const;
void setFirstPointId(const quint32 &value); void SetLineColor(const QString &value);
quint32 getSecondPointId() const; QString GetFormula() const;
void setSecondPointId(const quint32 &value); void SetFormula(const QString &value);
quint32 GetFirstPointId() const;
void SetFirstPointId(const quint32 &value);
quint32 GetSecondPointId() const;
void SetSecondPointId(const quint32 &value);
public slots: public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void ChosenObject(quint32 id, const SceneObject &type);
/** /**
@ -85,74 +88,12 @@ private:
/** @brief ui keeps information about user interface */ /** @brief ui keeps information about user interface */
Ui::DialogAlongLine *ui; Ui::DialogAlongLine *ui;
/** @brief number number of handled objects */
qint32 number;
/** @brief typeLine type of line */
QString typeLine;
/** @brief formula formula */ /** @brief formula formula */
QString 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 */ /** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight; int formulaBaseHeight;
VisToolAlongLine *line; 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 #endif // DIALOGALONGLINE_H

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>428</width> <width>428</width>
<height>499</height> <height>532</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -223,6 +223,9 @@
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="labelEditNamePoint"> <widget class="QLabel" name="labelEditNamePoint">
<property name="text"> <property name="text">
@ -230,9 +233,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditNamePoint"/>
</item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="labelFirstPoint"> <widget class="QLabel" name="labelFirstPoint">
<property name="text"> <property name="text">
@ -299,6 +299,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Line color</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="comboBoxLineColor"/>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditNamePoint"/>
</item>
</layout> </layout>
</item> </item>
<item> <item>

View File

@ -45,9 +45,9 @@
*/ */
DialogArc::DialogArc(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogArc::DialogArc(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogArc), flagRadius(false), flagF1(false), flagF2(false), :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()), timerRadius(nullptr), timerF1(nullptr), timerF2(nullptr), radius(QString()), f1(QString()), f2(QString()),
f1(QString()), f2(QString()), formulaBaseHeight(0), formulaBaseHeightF1(0), formulaBaseHeightF2(0), path(nullptr), formulaBaseHeight(0), formulaBaseHeightF1(0), formulaBaseHeightF2(0), path(nullptr), angleF1(INT_MIN),
angleF1(INT_MIN), angleF2(INT_MIN) angleF2(INT_MIN)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -74,6 +74,7 @@ DialogArc::DialogArc(const VContainer *data, const quint32 &toolId, QWidget *par
InitOkCancelApply(ui); InitOkCancelApply(ui);
FillComboBoxPoints(ui->comboBoxBasePoint); FillComboBoxPoints(ui->comboBoxBasePoint);
FillComboBoxLineColors(ui->comboBoxColor);
CheckState(); CheckState();
@ -131,9 +132,8 @@ DialogArc::~DialogArc()
*/ */
void DialogArc::SetCenter(const quint32 &value) void DialogArc::SetCenter(const quint32 &value)
{ {
center = value; ChangeCurrentData(ui->comboBoxBasePoint, value);
ChangeCurrentData(ui->comboBoxBasePoint, center); path->setPoint1Id(value);
path->setPoint1Id(center);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -154,6 +154,18 @@ void DialogArc::SetF2(const QString &value)
MoveCursorToEnd(ui->plainTextEditF2); 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 * @brief SetF1 set formula first angle of arc
@ -234,9 +246,8 @@ void DialogArc::SaveData()
f1.replace("\n", " "); f1.replace("\n", " ");
f2 = ui->plainTextEditF2->toPlainText(); f2 = ui->plainTextEditF2->toPlainText();
f2.replace("\n", " "); f2.replace("\n", " ");
center = getCurrentObjectId(ui->comboBoxBasePoint);
path->setPoint1Id(center); path->setPoint1Id(GetCenter());
path->setRadius(radius); path->setRadius(radius);
path->setF1(f1); path->setF1(f1);
path->setF2(f2); path->setF2(f2);
@ -436,3 +447,43 @@ void DialogArc::CheckAngles()
DialogArc::CheckState(); 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;
}

View File

@ -59,6 +59,9 @@ public:
QString GetF2() const; QString GetF2() const;
void SetF2(const QString &value); void SetF2(const QString &value);
QString GetColor() const;
void SetColor(const QString &value);
public slots: public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void ChosenObject(quint32 id, const SceneObject &type);
/** /**
@ -108,9 +111,6 @@ private:
/** @brief timerF2 timer of check formula of second angle */ /** @brief timerF2 timer of check formula of second angle */
QTimer *timerF2; QTimer *timerF2;
/** @brief center id of center point */
quint32 center;
/** @brief radius formula of radius */ /** @brief radius formula of radius */
QString radius; QString radius;
@ -136,44 +136,4 @@ private:
void CheckAngles(); 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 #endif // DIALOGARC_H

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>423</width> <width>425</width>
<height>544</height> <height>577</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -584,11 +584,13 @@
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_5"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -598,17 +600,25 @@
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="0" column="1">
<widget class="QComboBox" name="comboBoxBasePoint"> <widget class="QComboBox" name="comboBoxBasePoint">
<property name="toolTip"> <property name="toolTip">
<string>Select point of center of arc</string> <string>Select point of center of arc</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxColor"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<widget class="QLabel" name="label_8"> <widget class="QLabel" name="label_8">
<property name="text"> <property name="text">
@ -782,7 +792,6 @@
<tabstop>pushButtonGrowLengthF1</tabstop> <tabstop>pushButtonGrowLengthF1</tabstop>
<tabstop>toolButtonPutHereF2</tabstop> <tabstop>toolButtonPutHereF2</tabstop>
<tabstop>toolButtonEqualF2</tabstop> <tabstop>toolButtonEqualF2</tabstop>
<tabstop>comboBoxBasePoint</tabstop>
<tabstop>radioButtonSizeGrowth</tabstop> <tabstop>radioButtonSizeGrowth</tabstop>
<tabstop>radioButtonStandardTable</tabstop> <tabstop>radioButtonStandardTable</tabstop>
<tabstop>radioButtonIncrements</tabstop> <tabstop>radioButtonIncrements</tabstop>

View File

@ -42,8 +42,7 @@
* @param parent parent widget * @param parent parent widget
*/ */
DialogBisector::DialogBisector(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogBisector::DialogBisector(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogBisector), number(0), typeLine(QString()), :DialogTool(data, toolId, parent), ui(new Ui::DialogBisector), formula(QString()), formulaBaseHeight(0),
formula(QString()), firstPointId(NULL_ID), secondPointId(NULL_ID), thirdPointId(NULL_ID), formulaBaseHeight(0),
line(nullptr) line(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -62,6 +61,7 @@ DialogBisector::DialogBisector(const VContainer *data, const quint32 &toolId, QW
FillComboBoxPoints(ui->comboBoxSecondPoint); FillComboBoxPoints(ui->comboBoxSecondPoint);
FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics()); FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics());
FillComboBoxPoints(ui->comboBoxThirdPoint); FillComboBoxPoints(ui->comboBoxThirdPoint);
FillComboBoxLineColors(ui->comboBoxLineColor);
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogBisector::PutHere); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogBisector::PutHere);
connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogBisector::PutVal); 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 * @param value name
*/ */
void DialogBisector::setPointName(const QString &value) void DialogBisector::SetPointName(const QString &value)
{ {
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); 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 * @param value type
*/ */
void DialogBisector::setTypeLine(const QString &value) void DialogBisector::SetTypeLine(const QString &value)
{ {
typeLine = value; ChangeCurrentData(ui->comboBoxLineType, value);
SetupTypeLine(ui->comboBoxLineType, value); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setFormula set string of formula * @brief SetFormula set string of formula
* @param value formula * @param value formula
*/ */
void DialogBisector::setFormula(const QString &value) void DialogBisector::SetFormula(const QString &value)
{ {
formula = qApp->FormulaToUser(value); formula = qApp->FormulaToUser(value);
// increase height if needed. // 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 * @param value id
*/ */
void DialogBisector::setFirstPointId(const quint32 &value) void DialogBisector::SetFirstPointId(const quint32 &value)
{ {
setPointId(ui->comboBoxFirstPoint, firstPointId, value); setCurrentPointId(ui->comboBoxFirstPoint, value);
line->setPoint1Id(firstPointId); line->setPoint1Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setSecondPointId set id of second point * @brief SetSecondPointId set id of second point
* @param value id * @param value id
*/ */
void DialogBisector::setSecondPointId(const quint32 &value) void DialogBisector::SetSecondPointId(const quint32 &value)
{ {
setPointId(ui->comboBoxSecondPoint, secondPointId, value); setCurrentPointId(ui->comboBoxSecondPoint, value);
line->setPoint2Id(secondPointId); line->setPoint2Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setThirdPointId set id of third point * @brief SetThirdPointId set id of third point
* @param value id * @param value id
*/ */
void DialogBisector::setThirdPointId(const quint32 &value) void DialogBisector::SetThirdPointId(const quint32 &value)
{ {
setPointId(ui->comboBoxThirdPoint, thirdPointId, value); setCurrentPointId(ui->comboBoxThirdPoint, value);
line->setPoint3Id(thirdPointId); line->setPoint3Id(value);
}
//---------------------------------------------------------------------------------------------------------------------
QString DialogBisector::GetLineColor() const
{
return GetComboBoxCurrentData(ui->comboBoxLineColor);
}
//---------------------------------------------------------------------------------------------------------------------
void DialogBisector::SetLineColor(const QString &value)
{
ChangeCurrentData(ui->comboBoxLineColor, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogBisector::SaveData() void DialogBisector::SaveData()
{ {
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType);
formula = ui->plainTextEditFormula->toPlainText(); formula = ui->plainTextEditFormula->toPlainText();
formula.replace("\n", " "); formula.replace("\n", " ");
firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint);
secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint);
thirdPointId = getCurrentObjectId(ui->comboBoxThirdPoint);
line->setPoint1Id(firstPointId); line->setPoint1Id(GetFirstPointId());
line->setPoint2Id(secondPointId); line->setPoint2Id(GetSecondPointId());
line->setPoint3Id(thirdPointId); line->setPoint3Id(GetThirdPointId());
line->setLength(formula); line->setLength(formula);
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine()));
line->RefreshGeometry(); line->RefreshGeometry();
} }
@ -297,3 +305,53 @@ void DialogBisector::closeEvent(QCloseEvent *event)
ui->plainTextEditFormula->blockSignals(true); ui->plainTextEditFormula->blockSignals(true);
DialogTool::closeEvent(event); 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);
}

View File

@ -49,23 +49,25 @@ public:
DialogBisector(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); DialogBisector(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogBisector(); ~DialogBisector();
QString getPointName() const; void SetPointName(const QString &value);
void setPointName(const QString &value);
QString getTypeLine() const; QString GetTypeLine() const;
void setTypeLine(const QString &value); void SetTypeLine(const QString &value);
QString getFormula() const; QString GetFormula() const;
void setFormula(const QString &value); void SetFormula(const QString &value);
quint32 getFirstPointId() const; quint32 GetFirstPointId() const;
void setFirstPointId(const quint32 &value); void SetFirstPointId(const quint32 &value);
quint32 getSecondPointId() const; quint32 GetSecondPointId() const;
void setSecondPointId(const quint32 &value); void SetSecondPointId(const quint32 &value);
quint32 getThirdPointId() const; quint32 GetThirdPointId() const;
void setThirdPointId(const quint32 &value); void SetThirdPointId(const quint32 &value);
QString GetLineColor() const;
void SetLineColor(const QString &value);
public slots: public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void ChosenObject(quint32 id, const SceneObject &type);
/** /**
@ -90,88 +92,13 @@ private:
/** @brief ui keeps information about user interface */ /** @brief ui keeps information about user interface */
Ui::DialogBisector *ui; Ui::DialogBisector *ui;
/** @brief number number of handled objects */
qint32 number;
/** @brief typeLine type of line */
QString typeLine;
/** @brief formula formula */ /** @brief formula formula */
QString 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 */ /** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight; int formulaBaseHeight;
VisToolBisector *line; 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 #endif // DIALOGBISECTOR_H

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>428</width> <width>428</width>
<height>532</height> <height>565</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -325,6 +325,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Line color</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="comboBoxLineColor"/>
</item>
</layout> </layout>
</item> </item>
<item> <item>

View File

@ -38,8 +38,8 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogCurveIntersectAxis::DialogCurveIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogCurveIntersectAxis::DialogCurveIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogCurveIntersectAxis), number(0), typeLine(QString()), :DialogTool(data, toolId, parent), ui(new Ui::DialogCurveIntersectAxis),
formulaAngle(QString()), basePointId(NULL_ID), curveId(NULL_ID), formulaBaseHeightAngle(0), line(nullptr) formulaAngle(QString()), formulaBaseHeightAngle(0), line(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -57,6 +57,7 @@ DialogCurveIntersectAxis::DialogCurveIntersectAxis(const VContainer *data, const
FillComboBoxPoints(ui->comboBoxAxisPoint); FillComboBoxPoints(ui->comboBoxAxisPoint);
FillComboBoxCurves(ui->comboBoxCurve); FillComboBoxCurves(ui->comboBoxCurve);
FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics()); FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics());
FillComboBoxLineColors(ui->comboBoxLineColor);
connect(ui->toolButtonPutHereAngle, &QPushButton::clicked, this, &DialogCurveIntersectAxis::PutAngle); connect(ui->toolButtonPutHereAngle, &QPushButton::clicked, this, &DialogCurveIntersectAxis::PutAngle);
connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogCurveIntersectAxis::PutVal); connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogCurveIntersectAxis::PutVal);
@ -80,40 +81,33 @@ DialogCurveIntersectAxis::~DialogCurveIntersectAxis()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogCurveIntersectAxis::getPointName() const void DialogCurveIntersectAxis::SetPointName(const QString &value)
{
return pointName;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogCurveIntersectAxis::setPointName(const QString &value)
{ {
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); 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; ChangeCurrentData(ui->comboBoxLineType, value);
SetupTypeLine(ui->comboBoxLineType, value); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogCurveIntersectAxis::getAngle() const QString DialogCurveIntersectAxis::GetAngle() const
{ {
return qApp->FormulaFromUser(formulaAngle); return qApp->FormulaFromUser(formulaAngle);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCurveIntersectAxis::setAngle(const QString &value) void DialogCurveIntersectAxis::SetAngle(const QString &value)
{ {
formulaAngle = qApp->FormulaToUser(value); formulaAngle = qApp->FormulaToUser(value);
// increase height if needed. TODO : see if I can get the max number of caracters in one line // 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(); this->DeployAngleTextEdit();
} }
ui->plainTextEditFormula->setPlainText(formulaAngle); ui->plainTextEditFormula->setPlainText(formulaAngle);
line->setAngle(formulaAngle); line->SetAngle(formulaAngle);
MoveCursorToEnd(ui->plainTextEditFormula); 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); line->setAxisPointId(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
quint32 DialogCurveIntersectAxis::getCurveId() const quint32 DialogCurveIntersectAxis::getCurveId() const
{ {
return curveId; return getCurrentObjectId(ui->comboBoxCurve);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogCurveIntersectAxis::setCurveId(const quint32 &value) void DialogCurveIntersectAxis::setCurveId(const quint32 &value)
{ {
setCurrentCurveId(ui->comboBoxCurve, curveId, value); setCurrentCurveId(ui->comboBoxCurve, value);
line->setPoint1Id(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) void DialogCurveIntersectAxis::ShowDialog(bool click)
{ {
@ -163,7 +169,7 @@ void DialogCurveIntersectAxis::ShowDialog(bool click)
/*We will ignore click if poinet is in point circle*/ /*We will ignore click if poinet is in point circle*/
VMainGraphicsScene *scene = qApp->getCurrentScene(); VMainGraphicsScene *scene = qApp->getCurrentScene();
SCASSERT(scene != nullptr); SCASSERT(scene != nullptr);
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(basePointId); const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetBasePointId());
QLineF line = QLineF(point->toQPointF(), scene->getScenePos()); QLineF line = QLineF(point->toQPointF(), scene->getScenePos());
//Radius of point circle, but little bigger. Need handle with hover sizes. //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->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(""); emit ToolTip("");
timerFormula->start(); timerFormula->start();
this->show(); this->show();
@ -204,7 +210,6 @@ void DialogCurveIntersectAxis::ChosenObject(quint32 id, const SceneObject &type)
{ {
if (SetObject(id, ui->comboBoxAxisPoint, "")) if (SetObject(id, ui->comboBoxAxisPoint, ""))
{ {
basePointId = id;
line->setAxisPointId(id); line->setAxisPointId(id);
line->RefreshGeometry(); line->RefreshGeometry();
prepare = true; prepare = true;
@ -258,18 +263,14 @@ void DialogCurveIntersectAxis::ShowVisualization()
void DialogCurveIntersectAxis::SaveData() void DialogCurveIntersectAxis::SaveData()
{ {
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType);
formulaAngle = ui->plainTextEditFormula->toPlainText(); formulaAngle = ui->plainTextEditFormula->toPlainText();
formulaAngle.replace("\n", " "); formulaAngle.replace("\n", " ");
basePointId = getCurrentObjectId(ui->comboBoxAxisPoint); line->setPoint1Id(getCurveId());
curveId = getCurrentObjectId(ui->comboBoxCurve); line->setAxisPointId(GetBasePointId());
line->SetAngle(formulaAngle);
line->setPoint1Id(curveId); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine()));
line->setAxisPointId(basePointId);
line->setAngle(formulaAngle);
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
line->RefreshGeometry(); line->RefreshGeometry();
} }

View File

@ -45,21 +45,23 @@ public:
DialogCurveIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); DialogCurveIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogCurveIntersectAxis(); ~DialogCurveIntersectAxis();
QString getPointName() const; void SetPointName(const QString &value);
void setPointName(const QString &value);
QString getTypeLine() const; QString GetTypeLine() const;
void setTypeLine(const QString &value); void SetTypeLine(const QString &value);
QString getAngle() const; QString GetAngle() const;
void setAngle(const QString &value); void SetAngle(const QString &value);
quint32 getBasePointId() const; quint32 GetBasePointId() const;
void setBasePointId(const quint32 &value); void SetBasePointId(const quint32 &value);
quint32 getCurveId() const; quint32 getCurveId() const;
void setCurveId(const quint32 &value); void setCurveId(const quint32 &value);
QString GetLineColor() const;
void SetLineColor(const QString &value);
virtual void ShowDialog(bool click); virtual void ShowDialog(bool click);
public slots: public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void ChosenObject(quint32 id, const SceneObject &type);
@ -78,15 +80,7 @@ private:
Q_DISABLE_COPY(DialogCurveIntersectAxis) Q_DISABLE_COPY(DialogCurveIntersectAxis)
Ui::DialogCurveIntersectAxis *ui; Ui::DialogCurveIntersectAxis *ui;
/** @brief number number of handled objects */
qint32 number;
/** @brief typeLine type of line */
QString typeLine;
QString formulaAngle; QString formulaAngle;
quint32 basePointId;
quint32 curveId;
int formulaBaseHeightAngle; int formulaBaseHeightAngle;
VisToolCurveIntersectAxis *line; VisToolCurveIntersectAxis *line;

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>419</width> <width>419</width>
<height>499</height> <height>532</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -308,6 +308,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Line color</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="comboBoxLineColor"/>
</item>
</layout> </layout>
</item> </item>
<item> <item>

View File

@ -42,8 +42,8 @@
* @param parent parent widget * @param parent parent widget
*/ */
DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidget *parent)
: DialogTool(data, toolId, parent), ui(new Ui::DialogCutArc), formula(QString()), : DialogTool(data, toolId, parent), ui(new Ui::DialogCutArc), formula(QString()), formulaBaseHeight(0),
arcId(NULL_ID), formulaBaseHeight(0), path(nullptr) path(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
@ -58,6 +58,7 @@ DialogCutArc::DialogCutArc(const VContainer *data, const quint32 &toolId, QWidge
CheckState(); CheckState();
FillComboBoxArcs(ui->comboBoxArc); FillComboBoxArcs(ui->comboBoxArc);
FillComboBoxLineColors(ui->comboBoxColor);
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutArc::PutHere); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutArc::PutHere);
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutArc::PutVal); connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutArc::PutVal);
@ -133,9 +134,8 @@ void DialogCutArc::SaveData()
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
formula = ui->plainTextEditFormula->toPlainText(); formula = ui->plainTextEditFormula->toPlainText();
formula.replace("\n", " "); formula.replace("\n", " ");
arcId = getCurrentObjectId(ui->comboBoxArc);
path->setPoint1Id(arcId); path->setPoint1Id(getArcId());
path->setLength(formula); path->setLength(formula);
path->RefreshGeometry(); path->RefreshGeometry();
} }
@ -154,16 +154,28 @@ void DialogCutArc::closeEvent(QCloseEvent *event)
*/ */
void DialogCutArc::setArcId(const quint32 &value) void DialogCutArc::setArcId(const quint32 &value)
{ {
setCurrentArcId(ui->comboBoxArc, arcId, value, ComboBoxCutArc::CutArc); setCurrentArcId(ui->comboBoxArc, value, ComboBoxCutArc::CutArc);
path->setPoint1Id(arcId); 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 * @param value string with formula
*/ */
void DialogCutArc::setFormula(const QString &value) void DialogCutArc::SetFormula(const QString &value)
{ {
formula = qApp->FormulaToUser(value); formula = qApp->FormulaToUser(value);
// increase height if needed. // 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 * @param value name
*/ */
void DialogCutArc::setPointName(const QString &value) void DialogCutArc::SetPointName(const QString &value)
{ {
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); 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 * @return formula
*/ */
QString DialogCutArc::getFormula() const QString DialogCutArc::GetFormula() const
{ {
return qApp->FormulaFromUser(formula); return qApp->FormulaFromUser(formula);
} }
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief getArcId return id of arc
* @return id
*/
quint32 DialogCutArc::getArcId() const
{
return getCurrentObjectId(ui->comboBoxArc);
}

View File

@ -49,14 +49,16 @@ public:
DialogCutArc(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); DialogCutArc(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogCutArc(); ~DialogCutArc();
QString getPointName() const; void SetPointName(const QString &value);
void setPointName(const QString &value);
QString getFormula() const; QString GetFormula() const;
void setFormula(const QString &value); void SetFormula(const QString &value);
quint32 getArcId() const; quint32 getArcId() const;
void setArcId(const quint32 &value); void setArcId(const quint32 &value);
QString GetColor() const;
void SetColor(const QString &value);
public slots: public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void ChosenObject(quint32 id, const SceneObject &type);
/** /**
@ -82,33 +84,10 @@ private:
/** @brief formula string with formula */ /** @brief formula string with formula */
QString formula; QString formula;
/** @brief arcId keep id of arc */
quint32 arcId;
/** @brief formulaBaseHeight base height defined by dialogui */ /** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight; int formulaBaseHeight;
VisToolCutArc *path; 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 #endif // DIALOGCUTARC_H

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>412</width> <width>412</width>
<height>433</height> <height>466</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -250,6 +250,16 @@
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLineEdit" name="lineEditNamePoint"/> <widget class="QLineEdit" name="lineEditNamePoint"/>
</item> </item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxColor"/>
</item>
</layout> </layout>
</item> </item>
<item> <item>

View File

@ -41,8 +41,8 @@
* @param parent parent widget * @param parent parent widget
*/ */
DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSpline), formula(QString()), :DialogTool(data, toolId, parent), ui(new Ui::DialogCutSpline), formula(QString()), formulaBaseHeight(0),
splineId(NULL_ID), formulaBaseHeight(0), path(nullptr) path(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
@ -57,6 +57,7 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, const quint32 &toolId,
CheckState(); CheckState();
FillComboBoxSplines(ui->comboBoxSpline); FillComboBoxSplines(ui->comboBoxSpline);
FillComboBoxLineColors(ui->comboBoxColor);
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutSpline::PutHere); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutSpline::PutHere);
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutSpline::PutVal); 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 * @param value name
*/ */
void DialogCutSpline::setPointName(const QString &value) void DialogCutSpline::SetPointName(const QString &value)
{ {
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); 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 * @param value formula
*/ */
void DialogCutSpline::setFormula(const QString &value) void DialogCutSpline::SetFormula(const QString &value)
{ {
formula = qApp->FormulaToUser(value); formula = qApp->FormulaToUser(value);
// increase height if needed. TODO : see if I can get the max number of caracters in one line // 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) void DialogCutSpline::setSplineId(const quint32 &value)
{ {
setCurrentSplineId(ui->comboBoxSpline, splineId, value, ComboBoxCutSpline::CutSpline); setCurrentSplineId(ui->comboBoxSpline, value, ComboBoxCutSpline::CutSpline);
path->setPoint1Id(splineId); 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(); pointName = ui->lineEditNamePoint->text();
formula = ui->plainTextEditFormula->toPlainText(); formula = ui->plainTextEditFormula->toPlainText();
formula.replace("\n", " "); formula.replace("\n", " ");
splineId = getCurrentObjectId(ui->comboBoxSpline);
path->setPoint1Id(splineId); path->setPoint1Id(getSplineId());
path->setLength(formula); path->setLength(formula);
path->RefreshGeometry(); path->RefreshGeometry();
} }
@ -179,3 +191,23 @@ void DialogCutSpline::ShowVisualization()
path->RefreshGeometry(); 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);
}

View File

@ -48,14 +48,16 @@ public:
DialogCutSpline(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); DialogCutSpline(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogCutSpline(); ~DialogCutSpline();
QString getPointName() const; void SetPointName(const QString &value);
void setPointName(const QString &value);
QString getFormula() const; QString GetFormula() const;
void setFormula(const QString &value); void SetFormula(const QString &value);
quint32 getSplineId() const; quint32 getSplineId() const;
void setSplineId(const quint32 &value); void setSplineId(const quint32 &value);
QString GetColor() const;
void SetColor(const QString &value);
public slots: public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void ChosenObject(quint32 id, const SceneObject &type);
/** /**
@ -78,43 +80,10 @@ private:
/** @brief formula string with formula */ /** @brief formula string with formula */
QString formula; QString formula;
/** @brief splineId keep id of spline */
quint32 splineId;
/** @brief formulaBaseHeight base height defined by dialogui */ /** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight; int formulaBaseHeight;
VisToolCutSpline *path; 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 #endif // DIALOGCUTSPLINE_H

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>412</width> <width>412</width>
<height>433</height> <height>466</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -217,7 +217,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -237,7 +237,7 @@
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="labelEditNamePoint"> <widget class="QLabel" name="labelEditNamePoint">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -250,6 +250,16 @@
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLineEdit" name="lineEditNamePoint"/> <widget class="QLineEdit" name="lineEditNamePoint"/>
</item> </item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxColor"/>
</item>
</layout> </layout>
</item> </item>
<item> <item>

View File

@ -41,8 +41,8 @@
* @param parent parent widget * @param parent parent widget
*/ */
DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogCutSplinePath), formula(QString()), :DialogTool(data, toolId, parent), ui(new Ui::DialogCutSplinePath), formula(QString()), formulaBaseHeight(0),
splinePathId(NULL_ID), formulaBaseHeight(0), path(nullptr) path(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
@ -57,6 +57,7 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, const quint32 &
CheckState(); CheckState();
FillComboBoxSplinesPath(ui->comboBoxSplinePath); FillComboBoxSplinesPath(ui->comboBoxSplinePath);
FillComboBoxLineColors(ui->comboBoxColor);
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutSplinePath::PutHere); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutSplinePath::PutHere);
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutSplinePath::PutVal); 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 * @param value name
*/ */
void DialogCutSplinePath::setPointName(const QString &value) void DialogCutSplinePath::SetPointName(const QString &value)
{ {
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); 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 * @param value formula
*/ */
void DialogCutSplinePath::setFormula(const QString &value) void DialogCutSplinePath::SetFormula(const QString &value)
{ {
formula = qApp->FormulaToUser(value); formula = qApp->FormulaToUser(value);
// increase height if needed. TODO : see if I can get the max number of caracters in one line // 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) void DialogCutSplinePath::setSplinePathId(const quint32 &value)
{ {
setCurrentSplinePathId(ui->comboBoxSplinePath, splinePathId, value, ComboBoxCutSpline::CutSpline); setCurrentSplinePathId(ui->comboBoxSplinePath, value, ComboBoxCutSpline::CutSpline);
path->setPoint1Id(splinePathId); 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(); pointName = ui->lineEditNamePoint->text();
formula = ui->plainTextEditFormula->toPlainText(); formula = ui->plainTextEditFormula->toPlainText();
formula.replace("\n", " "); formula.replace("\n", " ");
splinePathId = getCurrentObjectId(ui->comboBoxSplinePath);
path->setPoint1Id(splinePathId); path->setPoint1Id(getSplinePathId());
path->setLength(formula); path->setLength(formula);
path->RefreshGeometry(); path->RefreshGeometry();
} }
@ -179,3 +191,23 @@ void DialogCutSplinePath::ShowVisualization()
path->RefreshGeometry(); 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);
}

View File

@ -48,14 +48,16 @@ public:
DialogCutSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); DialogCutSplinePath(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogCutSplinePath(); ~DialogCutSplinePath();
QString getPointName() const; void SetPointName(const QString &value);
void setPointName(const QString &value);
QString getFormula() const; QString GetFormula() const;
void setFormula(const QString &value); void SetFormula(const QString &value);
quint32 getSplinePathId() const; quint32 getSplinePathId() const;
void setSplinePathId(const quint32 &value); void setSplinePathId(const quint32 &value);
QString GetColor() const;
void SetColor(const QString &value);
public slots: public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void ChosenObject(quint32 id, const SceneObject &type);
/** /**
@ -78,43 +80,10 @@ private:
/** @brief formula string with formula */ /** @brief formula string with formula */
QString formula; QString formula;
/** @brief splinePathId keep id of splinePath */
quint32 splinePathId;
/** @brief formulaBaseHeight base height defined by dialogui */ /** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight; int formulaBaseHeight;
VisToolCutSplinePath *path; 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 #endif // DIALOGCUTSPLINEPATH_H

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>412</width> <width>412</width>
<height>433</height> <height>466</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -217,7 +217,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -237,7 +237,7 @@
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="labelEditNamePoint"> <widget class="QLabel" name="labelEditNamePoint">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -250,6 +250,22 @@
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLineEdit" name="lineEditNamePoint"/> <widget class="QLineEdit" name="lineEditNamePoint"/>
</item> </item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxColor"/>
</item>
</layout> </layout>
</item> </item>
<item> <item>

View File

@ -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); formula = qApp->FormulaToUser(value);
// increase height if needed. TODO : see if I can get the max number of caracters in one line // 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); return qApp->FormulaFromUser(formula);
} }

View File

@ -51,8 +51,8 @@ public:
explicit DialogEditWrongFormula(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); explicit DialogEditWrongFormula(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogEditWrongFormula(); ~DialogEditWrongFormula();
QString getFormula() const; QString GetFormula() const;
void setFormula(const QString &value); void SetFormula(const QString &value);
void setCheckZero(bool value); void setCheckZero(bool value);
void setPostfix(const QString &value); void setPostfix(const QString &value);
public slots: public slots:

View File

@ -43,9 +43,8 @@
* @param parent parent widget * @param parent parent widget
*/ */
DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogEndLine), typeLine(QString()), :DialogTool(data, toolId, parent), ui(new Ui::DialogEndLine),
formulaLength(QString()), formulaAngle(QString()), basePointId(NULL_ID), formulaBaseHeight(0), formulaLength(QString()), formulaAngle(QString()), formulaBaseHeight(0), formulaBaseHeightAngle(0), line(nullptr)
formulaBaseHeightAngle(0), line(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
@ -64,6 +63,7 @@ DialogEndLine::DialogEndLine(const VContainer *data, const quint32 &toolId, QWid
FillComboBoxPoints(ui->comboBoxBasePoint); FillComboBoxPoints(ui->comboBoxBasePoint);
FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics()); FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics());
FillComboBoxLineColors(ui->comboBoxLineColor);
connect(ui->toolButtonPutHereLength, &QPushButton::clicked, this, &DialogEndLine::PutHere); connect(ui->toolButtonPutHereLength, &QPushButton::clicked, this, &DialogEndLine::PutHere);
connect(ui->toolButtonPutHereAngle, &QPushButton::clicked, this, &DialogEndLine::PutAngle); 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, "")) if (SetObject(id, ui->comboBoxBasePoint, ""))
{ {
basePointId = id;
line->VisualMode(id); line->VisualMode(id);
connect(line, &VisToolEndLine::ToolTip, this, &DialogTool::ShowVisToolTip); connect(line, &VisToolEndLine::ToolTip, this, &DialogTool::ShowVisToolTip);
prepare = true; 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 * @param value name
*/ */
void DialogEndLine::setPointName(const QString &value) void DialogEndLine::SetPointName(const QString &value)
{ {
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); 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 * @param value type
*/ */
void DialogEndLine::setTypeLine(const QString &value) void DialogEndLine::SetTypeLine(const QString &value)
{ {
typeLine = value; ChangeCurrentData(ui->comboBoxLineType, value);
SetupTypeLine(ui->comboBoxLineType, value); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setFormula set string of formula * @brief SetFormula set string of formula
* @param value formula * @param value formula
*/ */
void DialogEndLine::setFormula(const QString &value) void DialogEndLine::SetFormula(const QString &value)
{ {
formulaLength = qApp->FormulaToUser(value); formulaLength = qApp->FormulaToUser(value);
// increase height if needed. TODO : see if I can get the max number of caracters in one line // 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 * @param value angle in degree
*/ */
void DialogEndLine::setAngle(const QString &value) void DialogEndLine::SetAngle(const QString &value)
{ {
formulaAngle = qApp->FormulaToUser(value); formulaAngle = qApp->FormulaToUser(value);
// increase height if needed. TODO : see if I can get the max number of caracters in one line // 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(); this->DeployAngleTextEdit();
} }
ui->plainTextEditAngle->setPlainText(formulaAngle); ui->plainTextEditAngle->setPlainText(formulaAngle);
line->setAngle(formulaAngle); line->SetAngle(formulaAngle);
MoveCursorToEnd(ui->plainTextEditAngle); MoveCursorToEnd(ui->plainTextEditAngle);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setBasePointId set id base point of line * @brief SetBasePointId set id base point of line
* @param value id * @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); 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 * @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*/ /*We will ignore click if poinet is in point circle*/
VMainGraphicsScene *scene = qApp->getCurrentScene(); VMainGraphicsScene *scene = qApp->getCurrentScene();
SCASSERT(scene != nullptr); SCASSERT(scene != nullptr);
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(basePointId); const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetBasePointId());
QLineF line = QLineF(point->toQPointF(), scene->getScenePos()); QLineF line = QLineF(point->toQPointF(), scene->getScenePos());
//Radius of point circle, but little bigger. Need handle with hover sizes. //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->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(""); emit ToolTip("");
timerFormula->start(); timerFormula->start();
this->show(); this->show();
@ -274,7 +284,6 @@ void DialogEndLine::ShowVisualization()
void DialogEndLine::SaveData() void DialogEndLine::SaveData()
{ {
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType);
formulaLength = ui->plainTextEditFormula->toPlainText(); formulaLength = ui->plainTextEditFormula->toPlainText();
formulaLength.replace("\n", " "); formulaLength.replace("\n", " ");
@ -282,12 +291,10 @@ void DialogEndLine::SaveData()
formulaAngle = ui->plainTextEditAngle->toPlainText(); formulaAngle = ui->plainTextEditAngle->toPlainText();
formulaAngle.replace("\n", " "); formulaAngle.replace("\n", " ");
basePointId = getCurrentObjectId(ui->comboBoxBasePoint); line->setPoint1Id(GetBasePointId());
line->setPoint1Id(basePointId);
line->setLength(formulaLength); line->setLength(formulaLength);
line->setAngle(formulaAngle); line->SetAngle(formulaAngle);
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine()));
line->RefreshGeometry(); line->RefreshGeometry();
} }
@ -308,3 +315,43 @@ DialogEndLine::~DialogEndLine()
} }
delete ui; 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);
}

View File

@ -48,20 +48,23 @@ public:
DialogEndLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); DialogEndLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogEndLine(); ~DialogEndLine();
QString getPointName() const; void SetPointName(const QString &value);
void setPointName(const QString &value);
QString getTypeLine() const; QString GetTypeLine() const;
void setTypeLine(const QString &value); void SetTypeLine(const QString &value);
QString getFormula() const; QString GetFormula() const;
void setFormula(const QString &value); void SetFormula(const QString &value);
QString getAngle() const; QString GetAngle() const;
void setAngle(const QString &value); 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); virtual void ShowDialog(bool click);
public slots: public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void ChosenObject(quint32 id, const SceneObject &type);
@ -90,75 +93,17 @@ private:
/** @brief ui keeps information about user interface */ /** @brief ui keeps information about user interface */
Ui::DialogEndLine *ui; Ui::DialogEndLine *ui;
/** @brief typeLine type of line */
QString typeLine;
/** @brief formula formula */ /** @brief formula formula */
QString formulaLength; QString formulaLength;
/** @brief angle angle of line */ /** @brief angle angle of line */
QString formulaAngle; QString formulaAngle;
/** @brief basePointId id base point of line */
quint32 basePointId;
/** @brief formulaBaseHeight base height defined by dialogui */ /** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight; int formulaBaseHeight;
int formulaBaseHeightAngle; int formulaBaseHeightAngle;
VisToolEndLine *line; 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 #endif // DIALOGENDLINE_H

View File

@ -409,6 +409,9 @@
<layout class="QVBoxLayout" name="verticalLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item> <item>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="sizePolicy"> <property name="sizePolicy">
@ -477,6 +480,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Line color</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="comboBoxLineColor"/>
</item>
</layout> </layout>
</item> </item>
<item> <item>

View File

@ -42,8 +42,7 @@
* @param parent parent widget * @param parent parent widget
*/ */
DialogHeight::DialogHeight(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogHeight::DialogHeight(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogHeight), number(0), :DialogTool(data, toolId, parent), ui(new Ui::DialogHeight), line(nullptr)
typeLine(QString()), basePointId(NULL_ID), p1LineId(NULL_ID), p2LineId(NULL_ID), line(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); 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->comboBoxP1Line);
FillComboBoxPoints(ui->comboBoxP2Line); FillComboBoxPoints(ui->comboBoxP2Line);
FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics()); FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics());
FillComboBoxLineColors(ui->comboBoxLineColor);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogHeight::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogHeight::NamePointChanged);
connect(ui->comboBoxBasePoint, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged), connect(ui->comboBoxBasePoint, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogHeight::PointNameChanged); this, &DialogHeight::PointNameChanged);
@ -78,10 +79,10 @@ DialogHeight::~DialogHeight()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setPointName set name of point * @brief SetPointName set name of point
* @param value name * @param value name
*/ */
void DialogHeight::setPointName(const QString &value) void DialogHeight::SetPointName(const QString &value)
{ {
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); 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 * @param value type
*/ */
void DialogHeight::setTypeLine(const QString &value) void DialogHeight::SetTypeLine(const QString &value)
{ {
typeLine = value; ChangeCurrentData(ui->comboBoxLineType, value);
SetupTypeLine(ui->comboBoxLineType, value); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setBasePointId set id base point of height * @brief SetBasePointId set id base point of height
* @param value id * @param value id
*/ */
void DialogHeight::setBasePointId(const quint32 &value) void DialogHeight::SetBasePointId(const quint32 &value)
{ {
setPointId(ui->comboBoxBasePoint, basePointId, value); setCurrentPointId(ui->comboBoxBasePoint, value);
line->setPoint1Id(basePointId); line->setPoint1Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setP1LineId set id first point of line * @brief SetP1LineId set id first point of line
* @param value id * @param value id
*/ */
void DialogHeight::setP1LineId(const quint32 &value) void DialogHeight::SetP1LineId(const quint32 &value)
{ {
setPointId(ui->comboBoxP1Line, p1LineId, value); setCurrentPointId(ui->comboBoxP1Line, value);
line->setLineP1Id(p1LineId); line->setLineP1Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setP2LineId set id second point of line * @brief SetP2LineId set id second point of line
* @param value id * @param value id
*/ */
void DialogHeight::setP2LineId(const quint32 &value) void DialogHeight::SetP2LineId(const quint32 &value)
{ {
setPointId(ui->comboBoxP2Line, p2LineId, value); setCurrentPointId(ui->comboBoxP2Line, value);
line->setLineP2Id(p2LineId); 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() void DialogHeight::SaveData()
{ {
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType);
basePointId = getCurrentObjectId(ui->comboBoxBasePoint);
p1LineId = getCurrentObjectId(ui->comboBoxP1Line);
p2LineId = getCurrentObjectId(ui->comboBoxP2Line);
line->setPoint1Id(basePointId); line->setPoint1Id(GetBasePointId());
line->setLineP1Id(p1LineId); line->setLineP1Id(GetP1LineId());
line->setLineP2Id(p2LineId); line->setLineP2Id(GetP2LineId());
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine()));
line->RefreshGeometry(); line->RefreshGeometry();
} }
@ -261,3 +269,43 @@ void DialogHeight::ShowVisualization()
line->RefreshGeometry(); 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);
}

View File

@ -48,20 +48,22 @@ public:
DialogHeight(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); DialogHeight(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogHeight(); ~DialogHeight();
QString getPointName() const; void SetPointName(const QString &value);
void setPointName(const QString &value);
QString getTypeLine() const; QString GetTypeLine() const;
void setTypeLine(const QString &value); void SetTypeLine(const QString &value);
quint32 getBasePointId() const; quint32 GetBasePointId() const;
void setBasePointId(const quint32 &value); void SetBasePointId(const quint32 &value);
quint32 getP1LineId() const; quint32 GetP1LineId() const;
void setP1LineId(const quint32 &value); void SetP1LineId(const quint32 &value);
quint32 getP2LineId() const; quint32 GetP2LineId() const;
void setP2LineId(const quint32 &value); void SetP2LineId(const quint32 &value);
QString GetLineColor() const;
void SetLineColor(const QString &value);
public slots: public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void ChosenObject(quint32 id, const SceneObject &type);
virtual void PointNameChanged(); virtual void PointNameChanged();
@ -78,71 +80,7 @@ private:
/** @brief ui keeps information about user interface */ /** @brief ui keeps information about user interface */
Ui::DialogHeight *ui; 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; 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 #endif // DIALOGHEIGHT_H

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>285</width> <width>285</width>
<height>212</height> <height>245</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -134,6 +134,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Line color</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="comboBoxLineColor"/>
</item>
</layout> </layout>
</item> </item>
<item> <item>

View File

@ -43,14 +43,14 @@
* @param parent parent widget * @param parent parent widget
*/ */
DialogLine::DialogLine(const VContainer *data, const quint32 &toolId, QWidget *parent) 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), :DialogTool(data, toolId, parent), ui(new Ui::DialogLine), line(nullptr)
typeLine(QString()), line(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
InitOkCancelApply(ui); InitOkCancelApply(ui);
FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint); FillComboBoxPoints(ui->comboBoxSecondPoint);
FillComboBoxLineColors(ui->comboBoxLineColor);
QMap<QString, QIcon> stylesPics = VAbstractTool::LineStylesPics(); QMap<QString, QIcon> stylesPics = VAbstractTool::LineStylesPics();
stylesPics.remove(VAbstractTool::TypeLineNone);// Prevent hiding line 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 * @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); line->setPoint2Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setTypeLine set type of line * @brief SetTypeLine set type of line
* @param value type * @param value type
*/ */
void DialogLine::setTypeLine(const QString &value) void DialogLine::SetTypeLine(const QString &value)
{ {
typeLine = value; ChangeCurrentData(ui->comboBoxLineType, value);
SetupTypeLine(ui->comboBoxLineType, value); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); }
//---------------------------------------------------------------------------------------------------------------------
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 * @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); line->setPoint1Id(value);
} }
@ -153,15 +164,9 @@ void DialogLine::ShowVisualization()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLine::SaveData() void DialogLine::SaveData()
{ {
qint32 index = ui->comboBoxFirstPoint->currentIndex(); line->setPoint1Id(GetFirstPoint());
firstPoint = qvariant_cast<quint32>(ui->comboBoxFirstPoint->itemData(index)); line->setPoint2Id(GetSecondPoint());
index = ui->comboBoxSecondPoint->currentIndex(); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine()));
secondPoint = qvariant_cast<quint32>(ui->comboBoxSecondPoint->itemData(index));
typeLine = GetTypeLine(ui->comboBoxLineType);
line->setPoint1Id(firstPoint);
line->setPoint2Id(secondPoint);
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
line->RefreshGeometry(); 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<quint32>(ui->comboBoxFirstPoint->currentData());
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetSecondPoint return id second point
* @return id
*/
quint32 DialogLine::GetSecondPoint() const
{
return qvariant_cast<quint32>(ui->comboBoxSecondPoint->currentData());
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief GetTypeLine return type of line
* @return type
*/
QString DialogLine::GetTypeLine() const
{
return GetComboBoxCurrentData(ui->comboBoxLineType);
}

View File

@ -48,14 +48,17 @@ public:
DialogLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); DialogLine(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogLine(); ~DialogLine();
quint32 getFirstPoint() const; quint32 GetFirstPoint() const;
void setFirstPoint(const quint32 &value); void SetFirstPoint(const quint32 &value);
quint32 getSecondPoint() const; quint32 GetSecondPoint() const;
void setSecondPoint(const quint32 &value); void SetSecondPoint(const quint32 &value);
QString getTypeLine() const; QString GetTypeLine() const;
void setTypeLine(const QString &value); void SetTypeLine(const QString &value);
QString GetLineColor() const;
void SetLineColor(const QString &value);
public slots: public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void ChosenObject(quint32 id, const SceneObject &type);
virtual void PointNameChanged(); virtual void PointNameChanged();
@ -72,49 +75,8 @@ private:
/** @brief ui keeps information about user interface */ /** @brief ui keeps information about user interface */
Ui::DialogLine *ui; 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; 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 #endif // DIALOGLINE_H

View File

@ -10,19 +10,19 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>286</width> <width>286</width>
<height>151</height> <height>179</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>286</width> <width>286</width>
<height>151</height> <height>179</height>
</size> </size>
</property> </property>
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>286</width> <width>286</width>
<height>151</height> <height>179</height>
</size> </size>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -143,6 +143,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Line color</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="comboBoxLineColor"/>
</item>
</layout> </layout>
</item> </item>
<item> <item>

View File

@ -42,8 +42,7 @@
* @param parent parent widget * @param parent parent widget
*/ */
DialogLineIntersect::DialogLineIntersect(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogLineIntersect::DialogLineIntersect(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersect), number(0), :DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersect), flagPoint(true), line(nullptr)
p1Line1(NULL_ID), p2Line1(NULL_ID), p1Line2(NULL_ID), p2Line2(NULL_ID), flagPoint(true), line(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
number = 0; 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"))) if (SetObject(id, ui->comboBoxP1Line1, tr("Select second point of first line")))
{ {
number++; number++;
p1Line1 = id;
line->VisualMode(id); line->VisualMode(id);
} }
break; 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"))) if (SetObject(id, ui->comboBoxP2Line1, tr("Select first point of second line")))
{ {
number++; number++;
p2Line1 = id;
line->setLine1P2Id(id); line->setLine1P2Id(id);
line->RefreshGeometry(); 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"))) if (SetObject(id, ui->comboBoxP1Line2, tr("Select second point of second line")))
{ {
number++; number++;
p1Line2 = id;
line->setLine2P1Id(id); line->setLine2P1Id(id);
line->RefreshGeometry(); line->RefreshGeometry();
} }
@ -134,7 +130,6 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type)
{ {
if (SetObject(id, ui->comboBoxP2Line2, "")) if (SetObject(id, ui->comboBoxP2Line2, ""))
{ {
p2Line2 = id;
line->setLine2P2Id(id); line->setLine2P2Id(id);
line->RefreshGeometry(); line->RefreshGeometry();
prepare = true; prepare = true;
@ -144,16 +139,16 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type)
this->show(); this->show();
connect(ui->comboBoxP1Line1, connect(ui->comboBoxP1Line1,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogLineIntersect::P1Line1Changed); &DialogLineIntersect::PointChanged);
connect(ui->comboBoxP2Line1, connect(ui->comboBoxP2Line1,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogLineIntersect::P2Line1Changed); &DialogLineIntersect::PointChanged);
connect(ui->comboBoxP1Line2, connect(ui->comboBoxP1Line2,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogLineIntersect::P1Line2Changed); &DialogLineIntersect::PointChanged);
connect(ui->comboBoxP2Line2, connect(ui->comboBoxP2Line2,
static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&DialogLineIntersect::P2Line2Changed); &DialogLineIntersect::PointChanged);
} }
} }
} }
@ -169,15 +164,11 @@ void DialogLineIntersect::ChosenObject(quint32 id, const SceneObject &type)
void DialogLineIntersect::SaveData() void DialogLineIntersect::SaveData()
{ {
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
p1Line1 = getCurrentObjectId(ui->comboBoxP1Line1);
p2Line1 = getCurrentObjectId(ui->comboBoxP2Line1);
p1Line2 = getCurrentObjectId(ui->comboBoxP1Line2);
p2Line2 = getCurrentObjectId(ui->comboBoxP2Line2);
line->setPoint1Id(p1Line1); line->setPoint1Id(GetP1Line1());
line->setLine1P2Id(p2Line1); line->setLine1P2Id(GetP2Line1());
line->setLine2P1Id(p1Line2); line->setLine2P1Id(GetP1Line2());
line->setLine2P2Id(p2Line2); line->setLine2P2Id(GetP2Line2());
line->RefreshGeometry(); line->RefreshGeometry();
} }
@ -186,55 +177,10 @@ void DialogLineIntersect::SaveData()
* @brief P1Line1Changed changed first point of first line * @brief P1Line1Changed changed first point of first line
* @param index index in list * @param index index in list
*/ */
void DialogLineIntersect::P1Line1Changed( int index) void DialogLineIntersect::PointChanged()
{ {
p1Line1 = qvariant_cast<quint32>(ui->comboBoxP1Line1->itemData(index));
flagPoint = CheckIntersecion(); flagPoint = CheckIntersecion();
CheckState(); 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<quint32>(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<quint32>(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<quint32>(ui->comboBoxP2Line2->itemData(index));
flagPoint = CheckIntersecion();
CheckState();
line->setLine2P2Id(p2Line2);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -317,10 +263,10 @@ void DialogLineIntersect::CheckState()
*/ */
bool DialogLineIntersect::CheckIntersecion() bool DialogLineIntersect::CheckIntersecion()
{ {
const QSharedPointer<VPointF> p1L1 = data->GeometricObject<VPointF>(p1Line1); const QSharedPointer<VPointF> p1L1 = data->GeometricObject<VPointF>(GetP1Line1());
const QSharedPointer<VPointF> p2L1 = data->GeometricObject<VPointF>(p2Line1); const QSharedPointer<VPointF> p2L1 = data->GeometricObject<VPointF>(GetP2Line1());
const QSharedPointer<VPointF> p1L2 = data->GeometricObject<VPointF>(p1Line2); const QSharedPointer<VPointF> p1L2 = data->GeometricObject<VPointF>(GetP1Line2());
const QSharedPointer<VPointF> p2L2 = data->GeometricObject<VPointF>(p2Line2); const QSharedPointer<VPointF> p2L2 = data->GeometricObject<VPointF>(GetP2Line2());
QLineF line1(p1L1->toQPointF(), p2L1->toQPointF()); QLineF line1(p1L1->toQPointF(), p2L1->toQPointF());
QLineF line2(p1L2->toQPointF(), p2L2->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 * @param value id
*/ */
void DialogLineIntersect::setP2Line2(const quint32 &value) void DialogLineIntersect::SetP2Line2(const quint32 &value)
{ {
setPointId(ui->comboBoxP2Line2, p2Line2, value); setCurrentPointId(ui->comboBoxP2Line2, value);
line->setLine2P2Id(p2Line2); line->setLine2P2Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setP1Line2 set id first point of second line * @brief SetP1Line2 set id first point of second line
* @param value id * @param value id
*/ */
void DialogLineIntersect::setP1Line2(const quint32 &value) void DialogLineIntersect::SetP1Line2(const quint32 &value)
{ {
setPointId(ui->comboBoxP1Line2, p1Line2, value); setCurrentPointId(ui->comboBoxP1Line2, value);
line->setLine2P1Id(p1Line2); line->setLine2P1Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setP2Line1 set id second point of first line * @brief SetP2Line1 set id second point of first line
* @param value id * @param value id
*/ */
void DialogLineIntersect::setP2Line1(const quint32 &value) void DialogLineIntersect::SetP2Line1(const quint32 &value)
{ {
setPointId(ui->comboBoxP2Line1, p2Line1, value); setCurrentPointId(ui->comboBoxP2Line1, value);
line->setLine1P2Id(p2Line1); line->setLine1P2Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setP1Line1 set id first point of first line * @brief SetP1Line1 set id first point of first line
* @param value id * @param value id
*/ */
void DialogLineIntersect::setP1Line1(const quint32 &value) void DialogLineIntersect::SetP1Line1(const quint32 &value)
{ {
setPointId(ui->comboBoxP1Line1, p1Line1, value); setCurrentPointId(ui->comboBoxP1Line1, value);
line->setPoint1Id(p1Line1); line->setPoint1Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setPointName set name of point * @brief SetPointName set name of point
* @param value name of point * @param value name of point
*/ */
void DialogLineIntersect::setPointName(const QString &value) void DialogLineIntersect::SetPointName(const QString &value)
{ {
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); 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);
}

View File

@ -48,26 +48,22 @@ public:
DialogLineIntersect(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); DialogLineIntersect(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogLineIntersect(); ~DialogLineIntersect();
quint32 getP1Line1() const; quint32 GetP1Line1() const;
void setP1Line1(const quint32 &value); void SetP1Line1(const quint32 &value);
quint32 getP2Line1() const; quint32 GetP2Line1() const;
void setP2Line1(const quint32 &value); void SetP2Line1(const quint32 &value);
quint32 getP1Line2() const; quint32 GetP1Line2() const;
void setP1Line2(const quint32 &value); void SetP1Line2(const quint32 &value);
quint32 getP2Line2() const; quint32 GetP2Line2() const;
void setP2Line2(const quint32 &value); void SetP2Line2(const quint32 &value);
QString getPointName() const; void SetPointName(const QString &value);
void setPointName(const QString &value);
public slots: public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void ChosenObject(quint32 id, const SceneObject &type);
void P1Line1Changed( int index); void PointChanged();
void P2Line1Changed( int index);
void P1Line2Changed( int index);
void P2Line2Changed( int index);
virtual void PointNameChanged(); virtual void PointNameChanged();
virtual void UpdateList(); virtual void UpdateList();
protected: protected:
@ -82,21 +78,6 @@ private:
/** @brief ui keeps information about user interface */ /** @brief ui keeps information about user interface */
Ui::DialogLineIntersect *ui; 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 */ /** @brief flagPoint keep state of point */
bool flagPoint; bool flagPoint;
@ -106,54 +87,4 @@ private:
bool CheckIntersecion(); 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 #endif // DIALOGLINEINTERSECT_H

View File

@ -38,8 +38,7 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
DialogLineIntersectAxis::DialogLineIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogLineIntersectAxis::DialogLineIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersectAxis), number(0), typeLine(QString()), :DialogTool(data, toolId, parent), ui(new Ui::DialogLineIntersectAxis), formulaAngle(QString()),
formulaAngle(QString()), basePointId(NULL_ID), firstPointId(NULL_ID), secondPointId(NULL_ID),
formulaBaseHeightAngle(0), line(nullptr) formulaBaseHeightAngle(0), line(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
@ -58,6 +57,7 @@ DialogLineIntersectAxis::DialogLineIntersectAxis(const VContainer *data, const q
FillComboBoxPoints(ui->comboBoxFirstLinePoint); FillComboBoxPoints(ui->comboBoxFirstLinePoint);
FillComboBoxPoints(ui->comboBoxSecondLinePoint); FillComboBoxPoints(ui->comboBoxSecondLinePoint);
FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics()); FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics());
FillComboBoxLineColors(ui->comboBoxLineColor);
connect(ui->toolButtonPutHereAngle, &QPushButton::clicked, this, &DialogLineIntersectAxis::PutAngle); connect(ui->toolButtonPutHereAngle, &QPushButton::clicked, this, &DialogLineIntersectAxis::PutAngle);
connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogLineIntersectAxis::PutVal); connect(listWidget, &QListWidget::itemDoubleClicked, this, &DialogLineIntersectAxis::PutVal);
@ -89,40 +89,33 @@ DialogLineIntersectAxis::~DialogLineIntersectAxis()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogLineIntersectAxis::getPointName() const void DialogLineIntersectAxis::SetPointName(const QString &value)
{
return pointName;
}
//---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::setPointName(const QString &value)
{ {
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); 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; ChangeCurrentData(ui->comboBoxLineType, value);
SetupTypeLine(ui->comboBoxLineType, value); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QString DialogLineIntersectAxis::getAngle() const QString DialogLineIntersectAxis::GetAngle() const
{ {
return qApp->FormulaFromUser(formulaAngle); return qApp->FormulaFromUser(formulaAngle);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogLineIntersectAxis::setAngle(const QString &value) void DialogLineIntersectAxis::SetAngle(const QString &value)
{ {
formulaAngle = qApp->FormulaToUser(value); formulaAngle = qApp->FormulaToUser(value);
// increase height if needed. TODO : see if I can get the max number of caracters in one line // 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(); this->DeployAngleTextEdit();
} }
ui->plainTextEditFormula->setPlainText(formulaAngle); ui->plainTextEditFormula->setPlainText(formulaAngle);
line->setAngle(formulaAngle); line->SetAngle(formulaAngle);
MoveCursorToEnd(ui->plainTextEditFormula); 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); 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); 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); 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) void DialogLineIntersectAxis::ShowDialog(bool click)
{ {
@ -185,7 +190,7 @@ void DialogLineIntersectAxis::ShowDialog(bool click)
/*We will ignore click if poinet is in point circle*/ /*We will ignore click if poinet is in point circle*/
VMainGraphicsScene *scene = qApp->getCurrentScene(); VMainGraphicsScene *scene = qApp->getCurrentScene();
SCASSERT(scene != nullptr); SCASSERT(scene != nullptr);
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(basePointId); const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(GetBasePointId());
QLineF line = QLineF(point->toQPointF(), scene->getScenePos()); QLineF line = QLineF(point->toQPointF(), scene->getScenePos());
//Radius of point circle, but little bigger. Need handle with hover sizes. //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->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(""); emit ToolTip("");
timerFormula->start(); timerFormula->start();
this->show(); this->show();
@ -242,7 +247,6 @@ void DialogLineIntersectAxis::ChosenObject(quint32 id, const SceneObject &type)
{ {
if (SetObject(id, ui->comboBoxAxisPoint, "")) if (SetObject(id, ui->comboBoxAxisPoint, ""))
{ {
basePointId = id;
line->setAxisPointId(id); line->setAxisPointId(id);
line->RefreshGeometry(); line->RefreshGeometry();
prepare = true; prepare = true;
@ -323,20 +327,15 @@ void DialogLineIntersectAxis::ShowVisualization()
void DialogLineIntersectAxis::SaveData() void DialogLineIntersectAxis::SaveData()
{ {
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType);
formulaAngle = ui->plainTextEditFormula->toPlainText(); formulaAngle = ui->plainTextEditFormula->toPlainText();
formulaAngle.replace("\n", " "); formulaAngle.replace("\n", " ");
basePointId = getCurrentObjectId(ui->comboBoxAxisPoint); line->setPoint1Id(GetFirstPointId());
firstPointId = getCurrentObjectId(ui->comboBoxFirstLinePoint); line->setPoint2Id(GetSecondPointId());
secondPointId = getCurrentObjectId(ui->comboBoxSecondLinePoint); line->setAxisPointId(GetBasePointId());
line->SetAngle(formulaAngle);
line->setPoint1Id(firstPointId); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine()));
line->setPoint2Id(secondPointId);
line->setAxisPointId(basePointId);
line->setAngle(formulaAngle);
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
line->RefreshGeometry(); line->RefreshGeometry();
} }

View File

@ -45,23 +45,25 @@ public:
DialogLineIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); DialogLineIntersectAxis(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogLineIntersectAxis(); ~DialogLineIntersectAxis();
QString getPointName() const; void SetPointName(const QString &value);
void setPointName(const QString &value);
QString getTypeLine() const; QString GetTypeLine() const;
void setTypeLine(const QString &value); void SetTypeLine(const QString &value);
QString getAngle() const; QString GetAngle() const;
void setAngle(const QString &value); void SetAngle(const QString &value);
quint32 getBasePointId() const; quint32 GetBasePointId() const;
void setBasePointId(const quint32 &value); void SetBasePointId(const quint32 &value);
quint32 getFirstPointId() const; quint32 GetFirstPointId() const;
void setFirstPointId(const quint32 &value); void SetFirstPointId(const quint32 &value);
quint32 getSecondPointId() const; quint32 GetSecondPointId() const;
void setSecondPointId(const quint32 &value); void SetSecondPointId(const quint32 &value);
QString GetLineColor() const;
void SetLineColor(const QString &value);
virtual void ShowDialog(bool click); virtual void ShowDialog(bool click);
public slots: public slots:
@ -82,16 +84,7 @@ private:
Q_DISABLE_COPY(DialogLineIntersectAxis) Q_DISABLE_COPY(DialogLineIntersectAxis)
Ui::DialogLineIntersectAxis *ui; Ui::DialogLineIntersectAxis *ui;
/** @brief number number of handled objects */
qint32 number;
/** @brief typeLine type of line */
QString typeLine;
QString formulaAngle; QString formulaAngle;
quint32 basePointId;
quint32 firstPointId;
quint32 secondPointId;
int formulaBaseHeightAngle; int formulaBaseHeightAngle;
VisToolLineIntersectAxis *line; VisToolLineIntersectAxis *line;

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>457</width> <width>457</width>
<height>532</height> <height>565</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -325,6 +325,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Line color</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="comboBoxLineColor"/>
</item>
</layout> </layout>
</item> </item>
<item> <item>

View File

@ -39,8 +39,8 @@
* @param parent parent widget * @param parent parent widget
*/ */
DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogNormal), number(0), typeLine(QString()), :DialogTool(data, toolId, parent), ui(new Ui::DialogNormal), formula(QString()), angle(0), formulaBaseHeight(0),
formula(QString()), angle(0), firstPointId(NULL_ID), secondPointId(NULL_ID), formulaBaseHeight(0), line(nullptr) line(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
@ -57,6 +57,7 @@ DialogNormal::DialogNormal(const VContainer *data, const quint32 &toolId, QWidge
FillComboBoxPoints(ui->comboBoxFirstPoint); FillComboBoxPoints(ui->comboBoxFirstPoint);
FillComboBoxPoints(ui->comboBoxSecondPoint); FillComboBoxPoints(ui->comboBoxSecondPoint);
FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics()); FillComboBoxTypeLine(ui->comboBoxLineType, VAbstractTool::LineStylesPics());
FillComboBoxLineColors(ui->comboBoxLineColor);
InitArrow(ui); InitArrow(ui);
@ -172,18 +173,15 @@ void DialogNormal::ChosenObject(quint32 id, const SceneObject &type)
void DialogNormal::SaveData() void DialogNormal::SaveData()
{ {
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType);
formula = ui->plainTextEditFormula->toPlainText(); formula = ui->plainTextEditFormula->toPlainText();
formula.replace("\n", " "); formula.replace("\n", " ");
angle = ui->doubleSpinBoxAngle->value(); angle = ui->doubleSpinBoxAngle->value();
firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint);
secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint);
line->setPoint1Id(firstPointId); line->setPoint1Id(GetFirstPointId());
line->setPoint2Id(secondPointId); line->setPoint2Id(GetSecondPointId());
line->setLength(formula); line->setLength(formula);
line->setAngle(angle); line->SetAngle(angle);
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine()));
line->RefreshGeometry(); 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 * @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); 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 * @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); line->setPoint1Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setAngle set aditional angle of normal * @brief SetAngle set aditional angle of normal
* @param value angle in degree * @param value angle in degree
*/ */
void DialogNormal::setAngle(const qreal &value) void DialogNormal::SetAngle(const qreal &value)
{ {
angle = value; angle = value;
ui->doubleSpinBoxAngle->setValue(angle); 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 * @param value formula
*/ */
void DialogNormal::setFormula(const QString &value) void DialogNormal::SetFormula(const QString &value)
{ {
formula = qApp->FormulaToUser(value); formula = qApp->FormulaToUser(value);
// increase height if needed. // 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 * @param value type
*/ */
void DialogNormal::setTypeLine(const QString &value) void DialogNormal::SetTypeLine(const QString &value)
{ {
typeLine = value; ChangeCurrentData(ui->comboBoxLineType, value);
SetupTypeLine(ui->comboBoxLineType, value); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setPointName set name of point * @brief SetPointName set name of point
* @param value name * @param value name
*/ */
void DialogNormal::setPointName(const QString &value) void DialogNormal::SetPointName(const QString &value)
{ {
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); 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);
}

View File

@ -48,23 +48,25 @@ public:
DialogNormal(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); DialogNormal(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogNormal(); ~DialogNormal();
QString getPointName() const; void SetPointName(const QString &value);
void setPointName(const QString &value);
QString getTypeLine() const; QString GetTypeLine() const;
void setTypeLine(const QString &value); void SetTypeLine(const QString &value);
QString getFormula() const; QString GetFormula() const;
void setFormula(const QString &value); void SetFormula(const QString &value);
qreal getAngle() const; qreal GetAngle() const;
void setAngle(const qreal &value); void SetAngle(const qreal &value);
quint32 getFirstPointId() const; quint32 GetFirstPointId() const;
void setFirstPointId(const quint32 &value); void SetFirstPointId(const quint32 &value);
quint32 getSecondPointId() const; quint32 GetSecondPointId() const;
void setSecondPointId(const quint32 &value); void SetSecondPointId(const quint32 &value);
QString GetLineColor() const;
void SetLineColor(const QString &value);
public slots: public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void ChosenObject(quint32 id, const SceneObject &type);
/** /**
@ -89,88 +91,16 @@ private:
/** @brief ui keeps information about user interface */ /** @brief ui keeps information about user interface */
Ui::DialogNormal *ui; Ui::DialogNormal *ui;
/** @brief number number of handled objects */
qint32 number;
/** @brief typeLine type of line */
QString typeLine;
/** @brief formula formula */ /** @brief formula formula */
QString formula; QString formula;
/** @brief angle aditional angle of normal */ /** @brief angle aditional angle of normal */
qreal angle; 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 */ /** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight; int formulaBaseHeight;
VisToolNormal *line; 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 #endif // DIALOGNORMAL_H

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>517</width> <width>517</width>
<height>645</height> <height>678</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -481,15 +481,17 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="label_7">
<property name="text"> <property name="text">
<string>Type of line</string> <string>Type of line</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="0" column="1">
<widget class="QComboBox" name="comboBoxLineType"> <widget class="QComboBox" name="comboBoxLineType">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
@ -514,10 +516,18 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxLineColor"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Line color</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">
@ -697,7 +707,6 @@
<tabstop>toolButtonArrowLeftDown</tabstop> <tabstop>toolButtonArrowLeftDown</tabstop>
<tabstop>toolButtonArrowLeft</tabstop> <tabstop>toolButtonArrowLeft</tabstop>
<tabstop>toolButtonArrowLeftUp</tabstop> <tabstop>toolButtonArrowLeftUp</tabstop>
<tabstop>comboBoxLineType</tabstop>
<tabstop>radioButtonSizeGrowth</tabstop> <tabstop>radioButtonSizeGrowth</tabstop>
<tabstop>radioButtonStandardTable</tabstop> <tabstop>radioButtonStandardTable</tabstop>
<tabstop>radioButtonIncrements</tabstop> <tabstop>radioButtonIncrements</tabstop>

View File

@ -41,8 +41,8 @@
* @param parent parent widget * @param parent parent widget
*/ */
DialogPointOfContact::DialogPointOfContact(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogPointOfContact::DialogPointOfContact(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfContact), number(0), :DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfContact),
radius(QString()), center(NULL_ID), firstPoint(NULL_ID), secondPoint(NULL_ID), formulaBaseHeight(0), line(nullptr) radius(QString()), formulaBaseHeight(0), line(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
@ -217,13 +217,10 @@ void DialogPointOfContact::SaveData()
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
radius = ui->plainTextEditFormula->toPlainText(); radius = ui->plainTextEditFormula->toPlainText();
radius.replace("\n", " "); radius.replace("\n", " ");
center = getCurrentObjectId(ui->comboBoxCenter);
firstPoint = getCurrentObjectId(ui->comboBoxFirstPoint);
secondPoint = getCurrentObjectId(ui->comboBoxSecondPoint);
line->setPoint1Id(firstPoint); line->setPoint1Id(GetFirstPoint());
line->setLineP2Id(secondPoint); line->setLineP2Id(GetSecondPoint());
line->setRadiusId(center); line->setRadiusId(getCenter());
line->setRadius(radius); line->setRadius(radius);
line->RefreshGeometry(); 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 * @param value id
*/ */
void DialogPointOfContact::setSecondPoint(const quint32 &value) void DialogPointOfContact::SetSecondPoint(const quint32 &value)
{ {
setPointId(ui->comboBoxSecondPoint, secondPoint, value); setCurrentPointId(ui->comboBoxSecondPoint, value);
line->setLineP2Id(secondPoint); line->setLineP2Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setFirstPoint set id first point * @brief SetFirstPoint set id first point
* @param value id * @param value id
*/ */
void DialogPointOfContact::setFirstPoint(const quint32 &value) void DialogPointOfContact::SetFirstPoint(const quint32 &value)
{ {
setPointId(ui->comboBoxFirstPoint, firstPoint, value); setCurrentPointId(ui->comboBoxFirstPoint, value);
line->setPoint1Id(firstPoint); line->setPoint1Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -264,8 +261,8 @@ void DialogPointOfContact::setFirstPoint(const quint32 &value)
*/ */
void DialogPointOfContact::setCenter(const quint32 &value) void DialogPointOfContact::setCenter(const quint32 &value)
{ {
setPointId(ui->comboBoxCenter, center, value); setCurrentPointId(ui->comboBoxCenter, value);
line->setRadiusId(center); 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 * @param value name
*/ */
void DialogPointOfContact::setPointName(const QString &value) void DialogPointOfContact::SetPointName(const QString &value)
{ {
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); 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);
}

View File

@ -49,8 +49,7 @@ public:
DialogPointOfContact(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); DialogPointOfContact(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
virtual ~DialogPointOfContact(); virtual ~DialogPointOfContact();
QString getPointName() const; void SetPointName(const QString &value);
void setPointName(const QString &value);
QString getRadius() const; QString getRadius() const;
void setRadius(const QString &value); void setRadius(const QString &value);
@ -58,11 +57,11 @@ public:
quint32 getCenter() const; quint32 getCenter() const;
void setCenter(const quint32 &value); void setCenter(const quint32 &value);
quint32 getFirstPoint() const; quint32 GetFirstPoint() const;
void setFirstPoint(const quint32 &value); void SetFirstPoint(const quint32 &value);
quint32 getSecondPoint() const; quint32 GetSecondPoint() const;
void setSecondPoint(const quint32 &value); void SetSecondPoint(const quint32 &value);
public slots: public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void ChosenObject(quint32 id, const SceneObject &type);
/** /**
@ -87,75 +86,13 @@ private:
/** @brief ui keeps information about user interface */ /** @brief ui keeps information about user interface */
Ui::DialogPointOfContact *ui; Ui::DialogPointOfContact *ui;
/** @brief number number of handled objects */
qint32 number;
/** @brief radius radius of arc */ /** @brief radius radius of arc */
QString radius; 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 */ /** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight; int formulaBaseHeight;
VisToolPointOfContact *line; 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 #endif // DIALOGPOINTOFCONTACT_H

View File

@ -42,8 +42,7 @@
* @param parent parent widget * @param parent parent widget
*/ */
DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersection), number(0), :DialogTool(data, toolId, parent), ui(new Ui::DialogPointOfIntersection), line(nullptr)
firstPointId(NULL_ID), secondPointId(NULL_ID), line(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); 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 * @param value id
*/ */
void DialogPointOfIntersection::setSecondPointId(const quint32 &value) void DialogPointOfIntersection::SetSecondPointId(const quint32 &value)
{ {
setPointId(ui->comboBoxSecondPoint, secondPointId, value); setCurrentPointId(ui->comboBoxSecondPoint, value);
line->setPoint2Id(secondPointId); line->setPoint2Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -132,11 +131,9 @@ void DialogPointOfIntersection::ChosenObject(quint32 id, const SceneObject &type
void DialogPointOfIntersection::SaveData() void DialogPointOfIntersection::SaveData()
{ {
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint);
secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint);
line->setPoint1Id(firstPointId); line->setPoint1Id(GetFirstPointId());
line->setPoint2Id(secondPointId); line->setPoint2Id(GetSecondPointId());
line->RefreshGeometry(); 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 * @param value id
*/ */
void DialogPointOfIntersection::setFirstPointId(const quint32 &value) void DialogPointOfIntersection::SetFirstPointId(const quint32 &value)
{ {
setPointId(ui->comboBoxFirstPoint, firstPointId, value); setCurrentPointId(ui->comboBoxFirstPoint, value);
line->setPoint1Id(firstPointId); line->setPoint1Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setPointName set name of point * @brief SetPointName set name of point
* @param value name * @param value name
*/ */
void DialogPointOfIntersection::setPointName(const QString &value) void DialogPointOfIntersection::SetPointName(const QString &value)
{ {
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); 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);
}

View File

@ -48,14 +48,13 @@ public:
DialogPointOfIntersection(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); DialogPointOfIntersection(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogPointOfIntersection(); ~DialogPointOfIntersection();
QString getPointName() const; void SetPointName(const QString &value);
void setPointName(const QString &value);
quint32 getFirstPointId() const; quint32 GetFirstPointId() const;
void setFirstPointId(const quint32 &value); void SetFirstPointId(const quint32 &value);
quint32 getSecondPointId() const; quint32 GetSecondPointId() const;
void setSecondPointId(const quint32 &value); void SetSecondPointId(const quint32 &value);
public slots: public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void ChosenObject(quint32 id, const SceneObject &type);
virtual void PointNameChanged(); virtual void PointNameChanged();
@ -72,45 +71,7 @@ private:
/** @brief ui keeps information about user interface */ /** @brief ui keeps information about user interface */
Ui::DialogPointOfIntersection *ui; 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; 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 #endif // DIALOGPOINTOFINTERSECTION_H

View File

@ -42,9 +42,8 @@
* @param parent parent widget * @param parent parent widget
*/ */
DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogShoulderPoint), number(0), :DialogTool(data, toolId, parent), ui(new Ui::DialogShoulderPoint), formula(QString()),
typeLine(QString()), formula(QString()), p1Line(NULL_ID), p2Line(NULL_ID), pShoulder(NULL_ID), formulaBaseHeight(0), formulaBaseHeight(0), line (nullptr)
line (nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
InitVariables(ui); InitVariables(ui);
@ -62,6 +61,7 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, const quint32 &
FillComboBoxPoints(ui->comboBoxP1Line); FillComboBoxPoints(ui->comboBoxP1Line);
FillComboBoxPoints(ui->comboBoxP2Line); FillComboBoxPoints(ui->comboBoxP2Line);
FillComboBoxPoints(ui->comboBoxP3); FillComboBoxPoints(ui->comboBoxP3);
FillComboBoxLineColors(ui->comboBoxLineColor);
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogShoulderPoint::PutHere); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogShoulderPoint::PutHere);
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogShoulderPoint::PutVal); connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogShoulderPoint::PutVal);
@ -201,18 +201,14 @@ void DialogShoulderPoint::ChosenObject(quint32 id, const SceneObject &type)
void DialogShoulderPoint::SaveData() void DialogShoulderPoint::SaveData()
{ {
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType);
formula = ui->plainTextEditFormula->toPlainText(); formula = ui->plainTextEditFormula->toPlainText();
formula.replace("\n", " "); formula.replace("\n", " ");
p1Line = getCurrentObjectId(ui->comboBoxP1Line);
p2Line = getCurrentObjectId(ui->comboBoxP2Line);
pShoulder = getCurrentObjectId(ui->comboBoxP3);
line->setPoint1Id(pShoulder); line->setPoint1Id(GetP3());
line->setLineP1Id(p1Line); line->setLineP1Id(GetP1Line());
line->setLineP2Id(p2Line); line->setLineP2Id(GetP2Line());
line->setLength(formula); line->setLength(formula);
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(GetTypeLine()));
line->RefreshGeometry(); line->RefreshGeometry();
} }
@ -228,40 +224,52 @@ void DialogShoulderPoint::closeEvent(QCloseEvent *event)
* @brief setPShoulder set id shoulder point * @brief setPShoulder set id shoulder point
* @param value id * @param value id
*/ */
void DialogShoulderPoint::setP3(const quint32 &value) void DialogShoulderPoint::SetP3(const quint32 &value)
{ {
setPointId(ui->comboBoxP3, pShoulder, value); setCurrentPointId(ui->comboBoxP3, value);
line->setPoint1Id(pShoulder); 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 * @param value id
*/ */
void DialogShoulderPoint::setP2Line(const quint32 &value) void DialogShoulderPoint::SetP2Line(const quint32 &value)
{ {
setPointId(ui->comboBoxP2Line, p2Line, value); setCurrentPointId(ui->comboBoxP2Line, value);
line->setLineP2Id(p2Line); line->setLineP2Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setP1Line set id first point of line * @brief SetP1Line set id first point of line
* @param value id * @param value id
*/ */
void DialogShoulderPoint::setP1Line(const quint32 &value) void DialogShoulderPoint::SetP1Line(const quint32 &value)
{ {
setPointId(ui->comboBoxP1Line, p1Line, value); setCurrentPointId(ui->comboBoxP1Line, value);
line->setLineP1Id(p1Line); line->setLineP1Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setFormula set string of formula * @brief SetFormula set string of formula
* @param value formula * @param value formula
*/ */
void DialogShoulderPoint::setFormula(const QString &value) void DialogShoulderPoint::SetFormula(const QString &value)
{ {
formula = qApp->FormulaToUser(value); formula = qApp->FormulaToUser(value);
// increase height if needed. // 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 * @param value type
*/ */
void DialogShoulderPoint::setTypeLine(const QString &value) void DialogShoulderPoint::SetTypeLine(const QString &value)
{ {
typeLine = value; ChangeCurrentData(ui->comboBoxLineType, value);
SetupTypeLine(ui->comboBoxLineType, value); line->setLineStyle(VAbstractTool::LineStyleToPenStyle(value));
line->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setPointName set name of point * @brief SetPointName set name of point
* @param value name * @param value name
*/ */
void DialogShoulderPoint::setPointName(const QString &value) void DialogShoulderPoint::SetPointName(const QString &value)
{ {
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); 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);
}

View File

@ -48,23 +48,25 @@ public:
DialogShoulderPoint(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); DialogShoulderPoint(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogShoulderPoint(); ~DialogShoulderPoint();
QString getPointName() const; void SetPointName(const QString &value);
void setPointName(const QString &value);
QString getTypeLine() const; QString GetTypeLine() const;
void setTypeLine(const QString &value); void SetTypeLine(const QString &value);
QString getFormula() const; QString GetFormula() const;
void setFormula(const QString &value); void SetFormula(const QString &value);
quint32 getP1Line() const; quint32 GetP1Line() const;
void setP1Line(const quint32 &value); void SetP1Line(const quint32 &value);
quint32 getP2Line() const; quint32 GetP2Line() const;
void setP2Line(const quint32 &value); void SetP2Line(const quint32 &value);
quint32 getP3() const; quint32 GetP3() const;
void setP3(const quint32 &value); void SetP3(const quint32 &value);
QString GetLineColor() const;
void SetLineColor(const QString &value);
public slots: public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void ChosenObject(quint32 id, const SceneObject &type);
/** /**
@ -89,87 +91,12 @@ private:
/** @brief ui keeps information about user interface */ /** @brief ui keeps information about user interface */
Ui::DialogShoulderPoint *ui; Ui::DialogShoulderPoint *ui;
/** @brief number number of handled objects */
qint32 number;
/** @brief typeLine type of line */
QString typeLine;
/** @brief formula formula */ /** @brief formula formula */
QString 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 */ /** @brief formulaBaseHeight base height defined by dialogui */
int formulaBaseHeight; int formulaBaseHeight;
VisToolShoulderPoint *line; 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 #endif // DIALOGSHOULDERPOINT_H

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>488</width> <width>488</width>
<height>532</height> <height>565</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -364,6 +364,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Line color</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QComboBox" name="comboBoxLineColor"/>
</item>
</layout> </layout>
</item> </item>
<item> <item>

View File

@ -92,7 +92,7 @@ void DialogSinglePoint::UpdateList()
* @param name name of point * @param name name of point
* @param point data for 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; pointName = name;
this->point = point; this->point = point;
@ -107,3 +107,13 @@ DialogSinglePoint::~DialogSinglePoint()
{ {
delete ui; delete ui;
} }
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief getPoint return point
* @return point
*/
QPointF DialogSinglePoint::GetPoint() const
{
return point;
}

View File

@ -45,9 +45,10 @@ class DialogSinglePoint : public DialogTool
public: public:
DialogSinglePoint(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); DialogSinglePoint(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogSinglePoint(); ~DialogSinglePoint();
void setData(const QString &name, const QPointF &point);
QString getName()const; void SetData(const QString &name, const QPointF &point);
QPointF getPoint()const; QPointF GetPoint()const;
public slots: public slots:
void mousePress(const QPointF &scenePos); void mousePress(const QPointF &scenePos);
virtual void UpdateList(); virtual void UpdateList();
@ -66,24 +67,4 @@ private:
QPointF point; 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 #endif // DIALOGSINGLEPOINT_H

View File

@ -41,14 +41,16 @@
* @param parent parent widget * @param parent parent widget
*/ */
DialogSpline::DialogSpline(const VContainer *data, const quint32 &toolId, QWidget *parent) 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), :DialogTool(data, toolId, parent), ui(new Ui::DialogSpline), angle1(0), angle2(0), kAsm1(1), kAsm2(1),
angle2(0), kAsm1(1), kAsm2(1), kCurve(1), path(nullptr) kCurve(1), path(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
InitOkCancelApply(ui); InitOkCancelApply(ui);
FillComboBoxPoints(ui->comboBoxP1); FillComboBoxPoints(ui->comboBoxP1);
FillComboBoxPoints(ui->comboBoxP4); FillComboBoxPoints(ui->comboBoxP4);
FillComboBoxLineColors(ui->comboBoxColor);
connect(ui->comboBoxP1, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged), connect(ui->comboBoxP1, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogSpline::PointNameChanged); this, &DialogSpline::PointNameChanged);
connect(ui->comboBoxP4, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged), connect(ui->comboBoxP4, static_cast<void (QComboBox::*)(const QString &)>(&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 * @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() void DialogSpline::SaveData()
{ {
p1 = getCurrentObjectId(ui->comboBoxP1);
p4 = getCurrentObjectId(ui->comboBoxP4);
angle1 = ui->spinBoxAngle1->value(); angle1 = ui->spinBoxAngle1->value();
angle2 = ui->spinBoxAngle2->value(); angle2 = ui->spinBoxAngle2->value();
kAsm1 = ui->doubleSpinBoxKasm1->value(); kAsm1 = ui->doubleSpinBoxKasm1->value();
kAsm2 = ui->doubleSpinBoxKasm2->value(); kAsm2 = ui->doubleSpinBoxKasm2->value();
kCurve = ui->doubleSpinBoxKcurve->value(); kCurve = ui->doubleSpinBoxKcurve->value();
path->setPoint1Id(p1); path->setPoint1Id(GetP1());
path->setPoint4Id(p4); path->setPoint4Id(GetP4());
path->setAngle1(angle1); path->SetAngle1(angle1);
path->setAngle2(angle2); path->SetAngle2(angle2);
path->setKAsm1(kAsm1); path->SetKAsm1(kAsm1);
path->setKAsm2(kAsm2); path->SetKAsm2(kAsm2);
path->setKCurve(kCurve); path->SetKCurve(kCurve);
path->RefreshGeometry(); 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. * @param value value. Can be >= 0.
*/ */
void DialogSpline::setKCurve(const qreal &value) void DialogSpline::SetKCurve(const qreal &value)
{ {
kCurve = value; kCurve = value;
ui->doubleSpinBoxKcurve->setValue(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. * @param value value. Can be >= 0.
*/ */
void DialogSpline::setKAsm2(const qreal &value) void DialogSpline::SetKAsm2(const qreal &value)
{ {
kAsm2 = value; kAsm2 = value;
ui->doubleSpinBoxKasm2->setValue(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. * @param value value. Can be >= 0.
*/ */
void DialogSpline::setKAsm1(const qreal &value) void DialogSpline::SetKAsm1(const qreal &value)
{ {
kAsm1 = value; kAsm1 = value;
ui->doubleSpinBoxKasm1->setValue(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 * @param value angle in degree
*/ */
void DialogSpline::setAngle2(const qreal &value) void DialogSpline::SetAngle2(const qreal &value)
{ {
angle2 = value; angle2 = value;
ui->spinBoxAngle2->setValue(static_cast<qint32>(value)); ui->spinBoxAngle2->setValue(static_cast<qint32>(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 * @param value angle in degree
*/ */
void DialogSpline::setAngle1(const qreal &value) void DialogSpline::SetAngle1(const qreal &value)
{ {
angle1 = value; angle1 = value;
ui->spinBoxAngle1->setValue(static_cast<qint32>(value)); ui->spinBoxAngle1->setValue(static_cast<qint32>(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 * @param value id
*/ */
void DialogSpline::setP4(const quint32 &value) void DialogSpline::SetP4(const quint32 &value)
{ {
setPointId(ui->comboBoxP4, p4, value); setCurrentPointId(ui->comboBoxP4, value);
path->setPoint4Id(p4); path->setPoint4Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setP1 set id first point of spline * @brief SetP1 set id first point of spline
* @param value id * @param value id
*/ */
void DialogSpline::setP1(const quint32 &value) void DialogSpline::SetP1(const quint32 &value)
{ {
setPointId(ui->comboBoxP1, p1, value); setCurrentPointId(ui->comboBoxP1, value);
path->setPoint1Id(p1); path->setPoint1Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief getP4 return id fourth point of spline * @brief GetP4 return id fourth point of spline
* @return id * @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;
} }

View File

@ -48,26 +48,29 @@ public:
DialogSpline(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); DialogSpline(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogSpline(); ~DialogSpline();
quint32 getP1() const; quint32 GetP1() const;
void setP1(const quint32 &value); void SetP1(const quint32 &value);
quint32 getP4() const; quint32 GetP4() const;
void setP4(const quint32 &value); void SetP4(const quint32 &value);
qreal getAngle1() const; qreal GetAngle1() const;
void setAngle1(const qreal &value); void SetAngle1(const qreal &value);
qreal getAngle2() const; qreal GetAngle2() const;
void setAngle2(const qreal &value); void SetAngle2(const qreal &value);
qreal getKAsm1() const; qreal GetKAsm1() const;
void setKAsm1(const qreal &value); void SetKAsm1(const qreal &value);
qreal getKAsm2() const; qreal GetKAsm2() const;
void setKAsm2(const qreal &value); void SetKAsm2(const qreal &value);
qreal getKCurve() const; qreal GetKCurve() const;
void setKCurve(const qreal &value); void SetKCurve(const qreal &value);
QString GetColor() const;
void SetColor(const QString &value);
public slots: public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void ChosenObject(quint32 id, const SceneObject &type);
virtual void PointNameChanged(); virtual void PointNameChanged();
@ -84,15 +87,6 @@ private:
/** @brief ui keeps information about user interface */ /** @brief ui keeps information about user interface */
Ui::DialogSpline *ui; 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 */ /** @brief angle1 first angle of spline in degree */
qreal angle1; qreal angle1;
@ -111,54 +105,4 @@ private:
VisToolSpline *path; 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 #endif // DIALOGSPLINE_H

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>524</width> <width>540</width>
<height>254</height> <height>233</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -152,8 +152,11 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_8"> <layout class="QFormLayout" name="formLayout">
<item> <property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
@ -172,7 +175,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxKcurve"> <widget class="QDoubleSpinBox" name="doubleSpinBoxKcurve">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -194,6 +197,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxColor"/>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@ -215,7 +228,6 @@
<tabstop>comboBoxP4</tabstop> <tabstop>comboBoxP4</tabstop>
<tabstop>doubleSpinBoxKasm2</tabstop> <tabstop>doubleSpinBoxKasm2</tabstop>
<tabstop>spinBoxAngle2</tabstop> <tabstop>spinBoxAngle2</tabstop>
<tabstop>doubleSpinBoxKcurve</tabstop>
<tabstop>buttonBox</tabstop> <tabstop>buttonBox</tabstop>
</tabstops> </tabstops>
<resources> <resources>

View File

@ -46,6 +46,7 @@ DialogSplinePath::DialogSplinePath(const VContainer *data, const quint32 &toolId
bOk->setEnabled(false); bOk->setEnabled(false);
FillComboBoxPoints(ui->comboBoxPoint); FillComboBoxPoints(ui->comboBoxPoint);
FillComboBoxLineColors(ui->comboBoxColor);
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogSplinePath::PointChanged); connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogSplinePath::PointChanged);
connect(ui->comboBoxPoint, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), connect(ui->comboBoxPoint, static_cast<void (QComboBox::*)(int)>(&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()); 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->listWidget->setFocus(Qt::OtherFocusReason);
ui->doubleSpinBoxKcurve->setValue(path.getKCurve()); ui->doubleSpinBoxKcurve->setValue(path.GetKCurve());
visPath->setPath(path); visPath->setPath(path);
ui->listWidget->blockSignals(false); 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. * @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); QListWidgetItem *item = ui->listWidget->item(i);
path.append( qvariant_cast<VSplinePoint>(item->data(Qt::UserRole))); path.append( qvariant_cast<VSplinePoint>(item->data(Qt::UserRole)));
} }
path.setKCurve(ui->doubleSpinBoxKcurve->value()); path.SetKCurve(ui->doubleSpinBoxKcurve->value());
} }

View File

@ -51,6 +51,9 @@ public:
VSplinePath GetPath() const; VSplinePath GetPath() const;
void SetPath(const VSplinePath &value); void SetPath(const VSplinePath &value);
QString GetColor() const;
void SetColor(const QString &value);
public slots: public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void ChosenObject(quint32 id, const SceneObject &type);
void PointChanged(int row); void PointChanged(int row);

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>524</width> <width>528</width>
<height>321</height> <height>322</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -141,8 +141,11 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_8"> <layout class="QFormLayout" name="formLayout">
<item> <property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="label_4">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
@ -161,7 +164,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBoxKcurve"> <widget class="QDoubleSpinBox" name="doubleSpinBoxKcurve">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
@ -183,6 +186,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Color</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxColor"/>
</item>
</layout> </layout>
</item> </item>
<item> <item>
@ -204,7 +217,6 @@
<tabstop>doubleSpinBoxKasm2</tabstop> <tabstop>doubleSpinBoxKasm2</tabstop>
<tabstop>doubleSpinBoxAngle2</tabstop> <tabstop>doubleSpinBoxAngle2</tabstop>
<tabstop>listWidget</tabstop> <tabstop>listWidget</tabstop>
<tabstop>doubleSpinBoxKcurve</tabstop>
<tabstop>buttonBox</tabstop> <tabstop>buttonBox</tabstop>
</tabstops> </tabstops>
<resources> <resources>

View File

@ -67,7 +67,7 @@ DialogTool::DialogTool(const VContainer *data, const quint32 &toolId, QWidget *p
radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr), radioButtonIncrements(nullptr), radioButtonLengthLine(nullptr), radioButtonLengthArc(nullptr),
radioButtonLengthCurve(nullptr), radioButtonAngleLine(nullptr), checkBoxHideEmpty(nullptr), radioButtonLengthCurve(nullptr), radioButtonAngleLine(nullptr), checkBoxHideEmpty(nullptr),
okColor(QColor(76, 76, 76)), errorColor(Qt::red), associatedTool(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); SCASSERT(data != nullptr);
timerFormula = new QTimer(this); timerFormula = new QTimer(this);
@ -302,12 +302,23 @@ void DialogTool::FillComboBoxTypeLine(QComboBox *box, const QMap<QString, QIcon>
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** void DialogTool::FillComboBoxLineColors(QComboBox *box) const
* @brief getTypeLine return type of line {
* @param box combobox SCASSERT(box != nullptr);
* @return type
*/ const QMap<QString, QString> map = VAbstractTool::ColorsList();
QString DialogTool::GetTypeLine(const QComboBox *box) const QMap<QString, QString>::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) SCASSERT(box != nullptr)
QString value = box->currentData().toString(); QString value = box->currentData().toString();
@ -318,29 +329,13 @@ QString DialogTool::GetTypeLine(const QComboBox *box) const
return value; 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 * @brief ChangeCurrentData select item in combobox by id
* @param box combobox * @param box combobox
* @param value id of item * @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) SCASSERT(box != nullptr)
const qint32 index = box->findData(value); 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); SCASSERT(box != nullptr);
box->blockSignals(true);
FillComboBoxPoints(box); FillComboBoxPoints(box);
pointId = value;
ChangeCurrentData(box, value); ChangeCurrentData(box, value);
box->blockSignals(false);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setCurrentSplineId set current spline id in combobox * @brief setCurrentSplineId set current spline id in combobox
* @param box combobox * @param box combobox
* @param splineId save current spline id
* @param value spline id * @param value spline id
* @param cut if set to ComboMode::CutSpline don't show id+1 and id+2 * @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, void DialogTool::setCurrentSplineId(QComboBox *box, const quint32 &value, ComboBoxCutSpline cut) const
ComboBoxCutSpline cut) const
{ {
SCASSERT(box != nullptr); SCASSERT(box != nullptr);
FillComboBoxSplines(box, cut); FillComboBoxSplines(box, cut);
splineId = value;
ChangeCurrentData(box, value); ChangeCurrentData(box, value);
} }
@ -571,15 +567,13 @@ void DialogTool::setCurrentSplineId(QComboBox *box, quint32 &splineId, const qui
/** /**
* @brief setCurrentArcId * @brief setCurrentArcId
* @param box combobox * @param box combobox
* @param arcId save current arc id
* @param value arc id * @param value arc id
* @param cut if set to ComboMode::CutArc don't show id+1 and id+2 * @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); SCASSERT(box != nullptr);
FillComboBoxArcs(box, cut); FillComboBoxArcs(box, cut);
arcId = value;
ChangeCurrentData(box, 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 * @brief setCurrentSplinePathId set current splinePath id in combobox
* @param box combobox * @param box combobox
* @param splinePathId save current splinePath id
* @param value splinePath id * @param value splinePath id
* @param cut if set to ComboMode::CutSpline don't show id+1 and id+2 * @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, void DialogTool::setCurrentSplinePathId(QComboBox *box, const quint32 &value, ComboBoxCutSpline cut) const
ComboBoxCutSpline cut) const
{ {
SCASSERT(box != nullptr); SCASSERT(box != nullptr);
FillComboBoxSplinesPath(box, cut); FillComboBoxSplinesPath(box, cut);
splinePathId = value;
ChangeCurrentData(box, 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); SCASSERT(box != nullptr);
FillComboBoxCurves(box); FillComboBoxCurves(box);
curveId = value;
ChangeCurrentData(box, value); ChangeCurrentData(box, value);
} }
@ -760,15 +750,6 @@ void DialogTool::ChangeColor(QWidget *widget, const QColor &color)
widget->setPalette(palette); 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. * @brief DialogAccepted save data and emit signal about closed dialog.
@ -1147,6 +1128,12 @@ void DialogTool::SetToolId(const quint32 &value)
toolId = value; toolId = value;
} }
//---------------------------------------------------------------------------------------------------------------------
QString DialogTool::getPointName() const
{
return pointName;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief ShowVariable show variables in list * @brief ShowVariable show variables in list

View File

@ -69,6 +69,8 @@ public:
quint32 GetToolId() const; quint32 GetToolId() const;
void SetToolId(const quint32 &value); void SetToolId(const quint32 &value);
QString getPointName() const;
signals: signals:
/** /**
* @brief DialogClosed signal dialog closed * @brief DialogClosed signal dialog closed
@ -207,8 +209,12 @@ protected:
/** @brief pointName name of point */ /** @brief pointName name of point */
QString pointName; QString pointName;
/** @brief number number of handled objects */
qint32 number;
virtual void closeEvent ( QCloseEvent * event ); virtual void closeEvent ( QCloseEvent * event );
virtual void showEvent( QShowEvent *event ); virtual void showEvent( QShowEvent *event );
void FillComboBoxPoints(QComboBox *box)const; void FillComboBoxPoints(QComboBox *box)const;
void FillComboBoxArcs(QComboBox *box, ComboBoxCutArc cut = ComboBoxCutArc::NoCutArc)const; void FillComboBoxArcs(QComboBox *box, ComboBoxCutArc cut = ComboBoxCutArc::NoCutArc)const;
void FillComboBoxSplines(QComboBox *box, ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline)const; void FillComboBoxSplines(QComboBox *box, ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline)const;
@ -216,26 +222,27 @@ protected:
ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline)const; ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline)const;
void FillComboBoxCurves(QComboBox *box)const; void FillComboBoxCurves(QComboBox *box)const;
void FillComboBoxTypeLine(QComboBox *box, const QMap<QString, QIcon> &stylesPics) const; void FillComboBoxTypeLine(QComboBox *box, const QMap<QString, QIcon> &stylesPics) const;
void FillComboBoxLineColors(QComboBox *box)const;
virtual void CheckState(); virtual void CheckState();
QString GetTypeLine(const QComboBox *box)const; QString GetComboBoxCurrentData(const QComboBox *box)const;
template <class key, class val> template <class key, class val>
void ShowVariable(const QMap<key, val> var); void ShowVariable(const QMap<key, val> var);
void SetupTypeLine(QComboBox *box, const QString &value); void ChangeCurrentData(QComboBox *box, const QVariant &value) const;
void ChangeCurrentData(QComboBox *box, const quint32 &value) const;
void PutValHere(QLineEdit *lineEdit, QListWidget *listWidget); void PutValHere(QLineEdit *lineEdit, QListWidget *listWidget);
void PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidget); void PutValHere(QPlainTextEdit *plainTextEdit, QListWidget *listWidget);
void ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer * timer); void ValFormulaChanged(bool &flag, QLineEdit *edit, QTimer * timer);
void ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer * timer); void ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer * timer);
qreal Eval(const QString &text, bool &flag, QLabel *label, const QString &postfix, qreal Eval(const QString &text, bool &flag, QLabel *label, const QString &postfix,
bool checkZero = true); bool checkZero = true);
void setCurrentPointId(QComboBox *box, quint32 &pointId, const quint32 &value) const; void setCurrentPointId(QComboBox *box, const quint32 &value) const;
void setCurrentSplineId(QComboBox *box, quint32 &splineId, const quint32 &value, void setCurrentSplineId(QComboBox *box, const quint32 &value,
ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline) const; 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; 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; 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; quint32 getCurrentObjectId(QComboBox *box) const;
bool SetObject(const quint32 &id, QComboBox *box, const QString &toolTip); bool SetObject(const quint32 &id, QComboBox *box, const QString &toolTip);
void DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight); void DeployFormula(QPlainTextEdit *formula, QPushButton *buttonGrowLength, int formulaBaseHeight);
@ -328,7 +335,6 @@ protected:
} }
void ChangeColor(QWidget *widget, const QColor &color); void ChangeColor(QWidget *widget, const QColor &color);
void setPointId(QComboBox *box, quint32 &pointId, const quint32 &value);
virtual void ShowVisualization(){} virtual void ShowVisualization(){}
/** /**
* @brief SaveData Put dialog data in local variables * @brief SaveData Put dialog data in local variables

View File

@ -41,8 +41,7 @@
* @param parent parent widget * @param parent parent widget
*/ */
DialogTriangle::DialogTriangle(const VContainer *data, const quint32 &toolId, QWidget *parent) DialogTriangle::DialogTriangle(const VContainer *data, const quint32 &toolId, QWidget *parent)
:DialogTool(data, toolId, parent), ui(new Ui::DialogTriangle), number(0), axisP1Id(NULL_ID), :DialogTool(data, toolId, parent), ui(new Ui::DialogTriangle), line (nullptr)
axisP2Id(NULL_ID), firstPointId(NULL_ID), secondPointId(NULL_ID), line (nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel)); ui->lineEditNamePoint->setText(qApp->getCurrentDocument()->GenerateLabel(LabelType::NewLabel));
@ -161,15 +160,11 @@ void DialogTriangle::ChosenObject(quint32 id, const SceneObject &type)
void DialogTriangle::SaveData() void DialogTriangle::SaveData()
{ {
pointName = ui->lineEditNamePoint->text(); pointName = ui->lineEditNamePoint->text();
firstPointId = getCurrentObjectId(ui->comboBoxFirstPoint);
secondPointId = getCurrentObjectId(ui->comboBoxSecondPoint);
axisP1Id = getCurrentObjectId(ui->comboBoxAxisP1);
axisP2Id = getCurrentObjectId(ui->comboBoxAxisP2);
line->setPoint1Id(axisP1Id); line->setPoint1Id(GetAxisP1Id());
line->setPoint2Id(axisP2Id); line->setPoint2Id(GetAxisP2Id());
line->setHypotenuseP1Id(firstPointId); line->setHypotenuseP1Id(GetFirstPointId());
line->setHypotenuseP2Id(secondPointId); line->setHypotenuseP2Id(GetSecondPointId());
line->RefreshGeometry(); line->RefreshGeometry();
} }
@ -223,10 +218,10 @@ void DialogTriangle::ShowVisualization()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setPointName set name of point * @brief SetPointName set name of point
* @param value name * @param value name
*/ */
void DialogTriangle::setPointName(const QString &value) void DialogTriangle::SetPointName(const QString &value)
{ {
pointName = value; pointName = value;
ui->lineEditNamePoint->setText(pointName); 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 * @param value id
*/ */
void DialogTriangle::setSecondPointId(const quint32 &value) void DialogTriangle::SetSecondPointId(const quint32 &value)
{ {
setPointId(ui->comboBoxSecondPoint, secondPointId, value); setCurrentPointId(ui->comboBoxSecondPoint, value);
line->setHypotenuseP2Id(secondPointId); line->setHypotenuseP2Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setFirstPointId set id of first point * @brief SetFirstPointId set id of first point
* @param value id * @param value id
*/ */
void DialogTriangle::setFirstPointId(const quint32 &value) void DialogTriangle::SetFirstPointId(const quint32 &value)
{ {
setPointId(ui->comboBoxFirstPoint, firstPointId, value); setCurrentPointId(ui->comboBoxFirstPoint, value);
line->setHypotenuseP1Id(firstPointId); line->setHypotenuseP1Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setAxisP2Id set id second point of axis * @brief SetAxisP2Id set id second point of axis
* @param value id * @param value id
*/ */
void DialogTriangle::setAxisP2Id(const quint32 &value) void DialogTriangle::SetAxisP2Id(const quint32 &value)
{ {
setPointId(ui->comboBoxAxisP2, axisP2Id, value); setCurrentPointId(ui->comboBoxAxisP2, value);
line->setPoint2Id(axisP2Id); line->setPoint2Id(value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setAxisP1Id set id first point of axis * @brief SetAxisP1Id set id first point of axis
* @param value id * @param value id
*/ */
void DialogTriangle::setAxisP1Id(const quint32 &value) void DialogTriangle::SetAxisP1Id(const quint32 &value)
{ {
setPointId(ui->comboBoxAxisP1, axisP1Id, value); setCurrentPointId(ui->comboBoxAxisP1, value);
line->setPoint1Id(axisP1Id); 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);
} }

View File

@ -48,20 +48,19 @@ public:
DialogTriangle(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); DialogTriangle(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr);
~DialogTriangle(); ~DialogTriangle();
quint32 getAxisP1Id() const; quint32 GetAxisP1Id() const;
void setAxisP1Id(const quint32 &value); void SetAxisP1Id(const quint32 &value);
quint32 getAxisP2Id() const; quint32 GetAxisP2Id() const;
void setAxisP2Id(const quint32 &value); void SetAxisP2Id(const quint32 &value);
quint32 getFirstPointId() const; quint32 GetFirstPointId() const;
void setFirstPointId(const quint32 &value); void SetFirstPointId(const quint32 &value);
quint32 getSecondPointId() const; quint32 GetSecondPointId() const;
void setSecondPointId(const quint32 &value); void SetSecondPointId(const quint32 &value);
QString getPointName() const; void SetPointName(const QString &value);
void setPointName(const QString &value);
public slots: public slots:
virtual void ChosenObject(quint32 id, const SceneObject &type); virtual void ChosenObject(quint32 id, const SceneObject &type);
virtual void PointNameChanged(); virtual void PointNameChanged();
@ -78,72 +77,7 @@ private:
/** @brief ui keeps information about user interface */ /** @brief ui keeps information about user interface */
Ui::DialogTriangle *ui; 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; 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 #endif // DIALOGTRIANGLE_H

View File

@ -255,7 +255,7 @@ QString VArc::GetFormulaF1() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VArc::SetFormulaF1(const VFormula &value) void VArc::SetFormulaF1(const VFormula &value)
{ {
d->formulaF1 = value.getFormula(FormulaType::FromUser); d->formulaF1 = value.GetFormula(FormulaType::FromUser);
d->f1 = value.getDoubleValue(); d->f1 = value.getDoubleValue();
} }
@ -282,7 +282,7 @@ QString VArc::GetFormulaF2() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VArc::SetFormulaF2(const VFormula &value) void VArc::SetFormulaF2(const VFormula &value)
{ {
d->formulaF2 = value.getFormula(FormulaType::FromUser); d->formulaF2 = value.GetFormula(FormulaType::FromUser);
d->f2 = value.getDoubleValue(); d->f2 = value.getDoubleValue();
} }
@ -309,7 +309,7 @@ QString VArc::GetFormulaRadius() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VArc::SetFormulaRadius(const VFormula &value) void VArc::SetFormulaRadius(const VFormula &value)
{ {
d->formulaRadius = value.getFormula(FormulaType::FromUser); d->formulaRadius = value.GetFormula(FormulaType::FromUser);
d->radius = value.getDoubleValue(); d->radius = value.getDoubleValue();
} }

View File

@ -255,13 +255,13 @@ void VSplinePath::Clear()
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VSplinePath::getKCurve() const qreal VSplinePath::GetKCurve() const
{ {
return d->kCurve; return d->kCurve;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VSplinePath::setKCurve(const qreal &value) void VSplinePath::SetKCurve(const qreal &value)
{ {
if (value > 0) if (value > 0)
{ {

View File

@ -118,15 +118,15 @@ public:
*/ */
void Clear(); void Clear();
/** /**
* @brief getKCurve return coefficient of curvature spline path. * @brief GetKCurve return coefficient of curvature spline path.
* @return coefficient of curvature spline. * @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. * @param value coefficient of curvature spline path.
*/ */
void setKCurve(const qreal &value); void SetKCurve(const qreal &value);
/** /**
* @brief GetPoint pointer to list spline point. * @brief GetPoint pointer to list spline point.
* @return list. * @return list.
@ -160,8 +160,8 @@ public:
* *
* VSplinePoint splP1 = splPath->at(p1); * VSplinePoint splP1 = splPath->at(p1);
* VSplinePoint splP2 = splPath->at(p2); * VSplinePoint splP2 = splPath->at(p2);
* VSpline spl1 = VSpline(splP1.P(), spl1p2, spl1p3, *p, splPath->getKCurve()); * VSpline spl1 = VSpline(splP1.P(), spl1p2, spl1p3, *p, splPath->GetKCurve());
* VSpline spl2 = VSpline(*p, spl2p2, spl2p3, splP2.P(), splPath->getKCurve()); * VSpline spl2 = VSpline(*p, spl2p2, spl2p3, splP2.P(), splPath->GetKCurve());
* @param length length first spline path. * @param length length first spline path.
* @param p1 index first spline point in list. * @param p1 index first spline point in list.
* @param p2 index second spline point in list. * @param p2 index second spline point in list.

View File

@ -68,13 +68,18 @@ QString VAbstractSpline::getTagName() const
*/ */
void VAbstractSpline::FullUpdateFromFile() void VAbstractSpline::FullUpdateFromFile()
{ {
ReadAttributes();
RefreshGeometry(); RefreshGeometry();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::Disable(bool disable) 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) void VAbstractSpline::ChangedActivDraw(const QString &newName)
{ {
VDrawTool::ChangedActivDraw(newName); Disable(!(nameActivDraw == newName));
const bool selectable = (nameActivDraw == newName);
this->setEnabled(selectable);
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
emit setEnabledPoint(selectable);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief ShowTool highlight tool. * @brief ShowTool highlight tool.
* @param id object id in container * @param id object id in container
* @param color highlight color.
* @param enable enable or disable highlight. * @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) void VAbstractSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
Q_UNUSED(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)); this->setPath(ToolPath(PathDirection::Show));
isHovered = true; isHovered = true;
QGraphicsPathItem::hoverEnterEvent(event); QGraphicsPathItem::hoverEnterEvent(event);
@ -138,7 +139,7 @@ void VAbstractSpline::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void VAbstractSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) void VAbstractSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{ {
Q_UNUSED(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()); this->setPath(ToolPath());
isHovered = false; isHovered = false;
QGraphicsPathItem::hoverLeaveEvent(event); QGraphicsPathItem::hoverLeaveEvent(event);
@ -211,6 +212,12 @@ QPainterPath VAbstractSpline::ToolPath(PathDirection direction) const
return path; return path;
} }
//---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::ReadToolAttributes(const QDomElement &domElement)
{
lineColor = doc->GetParametrString(domElement, AttrColor, ColorBlack);
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VAbstractSpline::ShowFoot(bool show) void VAbstractSpline::ShowFoot(bool show)
{ {
@ -219,3 +226,17 @@ void VAbstractSpline::ShowFoot(bool show)
controlPoints.at(i)->setVisible(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));
}
}

View File

@ -45,6 +45,9 @@ public:
enum { Type = UserType + static_cast<int>(Tool::AbstractSpline)}; enum { Type = UserType + static_cast<int>(Tool::AbstractSpline)};
virtual QString getTagName() const; virtual QString getTagName() const;
void ShowFoot(bool show); void ShowFoot(bool show);
void setEnabled(bool enabled);
public slots: public slots:
virtual void FullUpdateFromFile (); virtual void FullUpdateFromFile ();
void Disable(bool disable); void Disable(bool disable);
@ -75,7 +78,7 @@ protected:
*/ */
virtual void RefreshGeometry ()=0; virtual void RefreshGeometry ()=0;
virtual void ChangedActivDraw ( const QString &newName ); 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 SetFactor(qreal factor);
virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
@ -83,6 +86,7 @@ protected:
virtual void keyReleaseEvent(QKeyEvent * event); virtual void keyReleaseEvent(QKeyEvent * event);
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ); virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
QPainterPath ToolPath(PathDirection direction = PathDirection::Hide) const; QPainterPath ToolPath(PathDirection direction = PathDirection::Hide) const;
virtual void ReadToolAttributes(const QDomElement &domElement);
private: private:
Q_DISABLE_COPY(VAbstractSpline) Q_DISABLE_COPY(VAbstractSpline)
}; };

View File

@ -46,8 +46,8 @@ qreal VDrawTool::factor = 1;
* @param id object id in container. * @param id object id in container.
*/ */
VDrawTool::VDrawTool(VPattern *doc, VContainer *data, quint32 id, QObject *parent) VDrawTool::VDrawTool(VPattern *doc, VContainer *data, quint32 id, QObject *parent)
:VAbstractTool(doc, data, id, parent), ignoreFullUpdate(false), :VAbstractTool(doc, data, id, parent), ignoreFullUpdate(false), nameActivDraw(doc->GetNameActivPP()),
nameActivDraw(doc->GetNameActivPP()), dialog(nullptr) dialog(nullptr), typeLine(TypeLineLine), lineColor(ColorBlack), enabled(true)
{ {
connect(this->doc, &VPattern::ChangedActivPP, this, &VDrawTool::ChangedActivDraw); connect(this->doc, &VPattern::ChangedActivPP, this, &VDrawTool::ChangedActivDraw);
connect(this->doc, &VPattern::ChangedNameDraw, this, &VDrawTool::ChangedNameDraw); connect(this->doc, &VPattern::ChangedNameDraw, this, &VDrawTool::ChangedNameDraw);
@ -64,33 +64,14 @@ VDrawTool::~VDrawTool()
/** /**
* @brief ShowTool highlight tool. * @brief ShowTool highlight tool.
* @param id object id in container. * @param id object id in container.
* @param color highlight color.
* @param enable enable or disable highlight. * @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(id);
Q_UNUSED(color);
Q_UNUSED(enable); 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. * @brief ChangedNameDraw save new name active pattern peace.
@ -175,7 +156,34 @@ void VDrawTool::RefreshDataInFile()
} }
else 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()); DialogEditWrongFormula *dialog = new DialogEditWrongFormula(data, toolId, qApp->getMainWindow());
dialog->setWindowTitle(tr("Edit wrong formula")); dialog->setWindowTitle(tr("Edit wrong formula"));
dialog->setFormula(formula); dialog->SetFormula(formula);
if (dialog->exec() == QDialog::Accepted) 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 /* Need delete dialog here because parser in dialog don't allow use correct separator for parsing
* here. */ * here. */
delete dialog; delete dialog;
@ -285,3 +293,34 @@ void VDrawTool::AddToCalculation(const QDomElement &domElement)
connect(addToCal, &AddToCalc::NeedFullParsing, doc, &VPattern::NeedFullParsing); connect(addToCal, &AddToCalc::NeedFullParsing, doc, &VPattern::NeedFullParsing);
qApp->getUndoStack()->push(addToCal); qApp->getUndoStack()->push(addToCal);
} }
//---------------------------------------------------------------------------------------------------------------------
QString VDrawTool::getLineType() const
{
return typeLine;
}
//---------------------------------------------------------------------------------------------------------------------
void VDrawTool::SetTypeLine(const QString &value)
{
typeLine = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}
//---------------------------------------------------------------------------------------------------------------------
QString VDrawTool::GetLineColor() const
{
return lineColor;
}
//---------------------------------------------------------------------------------------------------------------------
void VDrawTool::SetLineColor(const QString &value)
{
lineColor = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj);
}

View File

@ -55,9 +55,16 @@ public:
virtual void setDialog() {} virtual void setDialog() {}
virtual void DialogLinkDestroy(); virtual void DialogLinkDestroy();
static qreal CheckFormula(const quint32 &toolId, QString &formula, VContainer *data); 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: public slots:
virtual void ShowTool(quint32 id, Qt::GlobalColor color, bool enable); virtual void ShowTool(quint32 id, bool enable);
virtual void ChangedActivDraw(const QString &newName); virtual void ChangedActivDraw(const QString &newName) = 0;
void ChangedNameDraw(const QString &oldName, const QString &newName); void ChangedNameDraw(const QString &oldName, const QString &newName);
virtual void FullUpdateFromGuiOk(int result); virtual void FullUpdateFromGuiOk(int result);
virtual void FullUpdateFromGuiApply(); virtual void FullUpdateFromGuiApply();
@ -73,6 +80,14 @@ protected:
/** @brief dialog dialog options.*/ /** @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); void AddToCalculation(const QDomElement &domElement);
/** @brief SaveDialog save options into file after change in dialog. */ /** @brief SaveDialog save options into file after change in dialog. */
@ -80,6 +95,10 @@ protected:
void SaveDialogChange(); void SaveDialogChange();
virtual void AddToFile(); virtual void AddToFile();
virtual void RefreshDataInFile(); virtual void RefreshDataInFile();
QColor CorrectColor(const QColor &color) const;
void ReadAttributes();
virtual void ReadToolAttributes(const QDomElement &domElement)=0;
template <typename Dialog, typename Tool> template <typename Dialog, typename Tool>
/** /**
@ -142,38 +161,15 @@ protected:
* @brief ShowItem highlight tool. * @brief ShowItem highlight tool.
* @param item tool. * @param item tool.
* @param id object id in container. * @param id object id in container.
* @param color highlight color.
* @param enable enable or disable highlight. * @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); SCASSERT(item != nullptr);
if (id == item->id) if (id == item->id)
{ {
if (enable == false) ShowVisualization(enable);
{
currentColor = baseColor;
} }
else
{
currentColor = color;
}
item->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor));
}
}
template <typename Item>
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: private:
Q_DISABLE_COPY(VDrawTool) Q_DISABLE_COPY(VDrawTool)

View File

@ -50,9 +50,9 @@ const QString VToolAlongLine::ToolType = QStringLiteral("alongLine");
*/ */
VToolAlongLine::VToolAlongLine(VPattern *doc, VContainer *data, quint32 id, const QString &formula, VToolAlongLine::VToolAlongLine(VPattern *doc, VContainer *data, quint32 id, const QString &formula,
const quint32 &firstPointId, const quint32 &secondPointId, const quint32 &firstPointId, const quint32 &secondPointId,
const QString &typeLine, const Source &typeCreation, const QString &typeLine, const QString &lineColor, const Source &typeCreation,
QGraphicsItem *parent) 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) if (typeCreation == Source::FromGui)
@ -71,14 +71,7 @@ VToolAlongLine::VToolAlongLine(VPattern *doc, VContainer *data, quint32 id, cons
*/ */
void VToolAlongLine::FullUpdateFromFile() void VToolAlongLine::FullUpdateFromFile()
{ {
QDomElement domElement = doc->elementById(QString().setNum(id)); ReadAttributes();
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
formulaLength = domElement.attribute(AttrLength, "");
basePointId = domElement.attribute(AttrFirstPoint, "").toUInt();
secondPointId = domElement.attribute(AttrSecondPoint, "").toUInt();
}
RefreshGeometry(); RefreshGeometry();
if (vis != nullptr) if (vis != nullptr)
@ -144,10 +137,11 @@ void VToolAlongLine::SaveDialog(QDomElement &domElement)
DialogAlongLine *dialogTool = qobject_cast<DialogAlongLine*>(dialog); DialogAlongLine *dialogTool = qobject_cast<DialogAlongLine*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine());
doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor());
doc->SetAttribute(domElement, AttrFirstPoint, dialogTool->getFirstPointId()); doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
doc->SetAttribute(domElement, AttrSecondPoint, dialogTool->getSecondPointId()); doc->SetAttribute(domElement, AttrFirstPoint, dialogTool->GetFirstPointId());
doc->SetAttribute(domElement, AttrSecondPoint, dialogTool->GetSecondPointId());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -163,19 +157,30 @@ void VToolAlongLine::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrTypeLine, typeLine); doc->SetAttribute(tag, AttrTypeLine, typeLine);
doc->SetAttribute(tag, AttrLineColor, lineColor);
doc->SetAttribute(tag, AttrLength, formulaLength); doc->SetAttribute(tag, AttrLength, formulaLength);
doc->SetAttribute(tag, AttrFirstPoint, basePointId); doc->SetAttribute(tag, AttrFirstPoint, basePointId);
doc->SetAttribute(tag, AttrSecondPoint, secondPointId); doc->SetAttribute(tag, AttrSecondPoint, 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; return secondPointId;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolAlongLine::setSecondPointId(const quint32 &value) void VToolAlongLine::SetSecondPointId(const quint32 &value)
{ {
if (value != NULL_ID) if (value != NULL_ID)
{ {
@ -231,11 +236,12 @@ void VToolAlongLine::setDialog()
DialogAlongLine *dialogTool = qobject_cast<DialogAlongLine*>(dialog); DialogAlongLine *dialogTool = qobject_cast<DialogAlongLine*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id); const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
dialogTool->setTypeLine(typeLine); dialogTool->SetTypeLine(typeLine);
dialogTool->setFormula(formulaLength); dialogTool->SetLineColor(lineColor);
dialogTool->setFirstPointId(basePointId); dialogTool->SetFormula(formulaLength);
dialogTool->setSecondPointId(secondPointId); dialogTool->SetFirstPointId(basePointId);
dialogTool->setPointName(p->name()); dialogTool->SetSecondPointId(secondPointId);
dialogTool->SetPointName(p->name());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -251,13 +257,14 @@ VToolAlongLine* VToolAlongLine::Create(DialogTool *dialog, VMainGraphicsScene *s
SCASSERT(dialog != nullptr); SCASSERT(dialog != nullptr);
DialogAlongLine *dialogTool = qobject_cast<DialogAlongLine*>(dialog); DialogAlongLine *dialogTool = qobject_cast<DialogAlongLine*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
QString formula = dialogTool->getFormula(); QString formula = dialogTool->GetFormula();
const quint32 firstPointId = dialogTool->getFirstPointId(); const quint32 firstPointId = dialogTool->GetFirstPointId();
const quint32 secondPointId = dialogTool->getSecondPointId(); const quint32 secondPointId = dialogTool->GetSecondPointId();
const QString typeLine = dialogTool->getTypeLine(); const QString typeLine = dialogTool->GetTypeLine();
const QString lineColor = dialogTool->GetLineColor();
const QString pointName = dialogTool->getPointName(); const QString pointName = dialogTool->getPointName();
VToolAlongLine *point=nullptr; VToolAlongLine *point=nullptr;
point = Create(0, pointName, typeLine, formula, firstPointId, secondPointId, 5, 10, scene, doc, data, point = Create(0, pointName, typeLine, lineColor, formula, firstPointId, secondPointId, 5, 10, scene, doc, data,
Document::FullParse, Source::FromGui); Document::FullParse, Source::FromGui);
if (point != nullptr) if (point != nullptr)
{ {
@ -284,9 +291,10 @@ VToolAlongLine* VToolAlongLine::Create(DialogTool *dialog, VMainGraphicsScene *s
* @param typeCreation way we create this tool. * @param typeCreation way we create this tool.
*/ */
VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine, VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine,
QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, const QString &lineColor, QString &formula, const quint32 &firstPointId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, const quint32 &secondPointId, const qreal &mx, const qreal &my,
VContainer *data, const Document &parse, const Source &typeCreation) VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation)
{ {
const QSharedPointer<VPointF> firstPoint = data->GeometricObject<VPointF>(firstPointId); const QSharedPointer<VPointF> firstPoint = data->GeometricObject<VPointF>(firstPointId);
const QSharedPointer<VPointF> secondPoint = data->GeometricObject<VPointF>(secondPointId); const QSharedPointer<VPointF> secondPoint = data->GeometricObject<VPointF>(secondPointId);
@ -314,8 +322,8 @@ VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointNa
VDrawTool::AddRecord(id, Tool::AlongLine, doc); VDrawTool::AddRecord(id, Tool::AlongLine, doc);
if (parse == Document::FullParse) if (parse == Document::FullParse)
{ {
VToolAlongLine *point = new VToolAlongLine(doc, data, id, formula, firstPointId, VToolAlongLine *point = new VToolAlongLine(doc, data, id, formula, firstPointId, secondPointId, typeLine,
secondPointId, typeLine, typeCreation); lineColor, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolAlongLine::SetFactor); connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolAlongLine::SetFactor);

View File

@ -40,20 +40,21 @@ class VToolAlongLine : public VToolLinePoint
public: public:
VToolAlongLine(VPattern *doc, VContainer *data, quint32 id, const QString &formula, const quint32 &firstPointId, VToolAlongLine(VPattern *doc, VContainer *data, quint32 id, const QString &formula, const quint32 &firstPointId,
const quint32 &secondPointId, const QString &typeLine, const Source &typeCreation, const quint32 &secondPointId, const QString &typeLine, const QString &lineColor,
QGraphicsItem * parent = nullptr); const Source &typeCreation, QGraphicsItem * parent = nullptr);
virtual void setDialog(); virtual void setDialog();
static VToolAlongLine* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolAlongLine* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolAlongLine* Create(const quint32 _id, const QString &pointName, const QString &typeLine, static VToolAlongLine* Create(const quint32 _id, const QString &pointName, const QString &typeLine,
QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, const QString &lineColor, QString &formula, const quint32 &firstPointId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, const quint32 &secondPointId, const qreal &mx, const qreal &my,
VContainer *data, const Document &parse, const Source &typeCreation); VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation);
static const QString ToolType; static const QString ToolType;
virtual int type() const {return Type;} virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::AlongLine)}; enum { Type = UserType + static_cast<int>(Tool::AlongLine)};
quint32 getSecondPointId() const; quint32 GetSecondPointId() const;
void setSecondPointId(const quint32 &value); void SetSecondPointId(const quint32 &value);
virtual void ShowVisualization(bool show); virtual void ShowVisualization(bool show);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
@ -64,6 +65,7 @@ protected:
virtual void RemoveReferens(); virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private: private:
/** @brief secondPointId id second point of line. */ /** @brief secondPointId id second point of line. */
quint32 secondPointId; quint32 secondPointId;

View File

@ -47,10 +47,12 @@ const QString VToolArc::ToolType = QStringLiteral("simple");
* @param typeCreation way we create this tool. * @param typeCreation way we create this tool.
* @param parent parent object * @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) :VAbstractSpline(doc, data, id, parent)
{ {
sceneType = SceneObject::Arc; sceneType = SceneObject::Arc;
lineColor = color;
this->setPath(ToolPath()); this->setPath(ToolPath());
this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor)); this->setPen(QPen(Qt::black, qApp->toPixel(qApp->widthHairLine())/factor));
@ -82,6 +84,7 @@ void VToolArc::setDialog()
dialogTool->SetF1(arc->GetFormulaF1()); dialogTool->SetF1(arc->GetFormulaF1());
dialogTool->SetF2(arc->GetFormulaF2()); dialogTool->SetF2(arc->GetFormulaF2());
dialogTool->SetRadius(arc->GetFormulaRadius()); dialogTool->SetRadius(arc->GetFormulaRadius());
dialogTool->SetColor(lineColor);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -101,8 +104,9 @@ VToolArc* VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPatte
QString radius = dialogTool->GetRadius(); QString radius = dialogTool->GetRadius();
QString f1 = dialogTool->GetF1(); QString f1 = dialogTool->GetF1();
QString f2 = dialogTool->GetF2(); QString f2 = dialogTool->GetF2();
const QString color = dialogTool->GetColor();
VToolArc* point = nullptr; 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) if (point != nullptr)
{ {
point->dialog=dialogTool; point->dialog=dialogTool;
@ -125,8 +129,8 @@ VToolArc* VToolArc::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPatte
* @param typeCreation way we create this tool. * @param typeCreation way we create this tool.
*/ */
VToolArc* VToolArc::Create(const quint32 _id, const quint32 &center, QString &radius, QString &f1, QString &f2, VToolArc* VToolArc::Create(const quint32 _id, const quint32 &center, QString &radius, QString &f1, QString &f2,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const QString &color, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Source &typeCreation) const Document &parse, const Source &typeCreation)
{ {
qreal calcRadius = 0, calcF1 = 0, calcF2 = 0; qreal calcRadius = 0, calcF1 = 0, calcF2 = 0;
@ -155,7 +159,7 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 &center, QString &ra
VDrawTool::AddRecord(id, Tool::Arc, doc); VDrawTool::AddRecord(id, Tool::Arc, doc);
if (parse == Document::FullParse) if (parse == Document::FullParse)
{ {
VToolArc *toolArc = new VToolArc(doc, data, id, typeCreation); VToolArc *toolArc = new VToolArc(doc, data, id, color, typeCreation);
scene->addItem(toolArc); scene->addItem(toolArc);
connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, toolArc, &VToolArc::SetFactor); 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<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id); QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
SCASSERT(arc.isNull() == false); 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) if (value.error() == false)
{ {
@ -225,7 +229,7 @@ void VToolArc::setFormulaRadius(const VFormula &value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VFormula VToolArc::getFormulaF1() const VFormula VToolArc::GetFormulaF1() const
{ {
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id); QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
SCASSERT(arc.isNull() == false); 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) if (value.error() == false)
{ {
@ -254,7 +258,7 @@ void VToolArc::setFormulaF1(const VFormula &value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VFormula VToolArc::getFormulaF2() const VFormula VToolArc::GetFormulaF2() const
{ {
QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id); QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(id);
SCASSERT(arc.isNull() == false); 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) if (value.error() == false)
{ {
@ -351,6 +355,7 @@ void VToolArc::SaveDialog(QDomElement &domElement)
doc->SetAttribute(domElement, AttrRadius, dialogTool->GetRadius()); doc->SetAttribute(domElement, AttrRadius, dialogTool->GetRadius());
doc->SetAttribute(domElement, AttrAngle1, dialogTool->GetF1()); doc->SetAttribute(domElement, AttrAngle1, dialogTool->GetF1());
doc->SetAttribute(domElement, AttrAngle2, dialogTool->GetF2()); doc->SetAttribute(domElement, AttrAngle2, dialogTool->GetF2());
doc->SetAttribute(domElement, AttrColor, dialogTool->GetColor());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -365,6 +370,7 @@ void VToolArc::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
doc->SetAttribute(tag, AttrRadius, arc->GetFormulaRadius()); doc->SetAttribute(tag, AttrRadius, arc->GetFormulaRadius());
doc->SetAttribute(tag, AttrAngle1, arc->GetFormulaF1()); doc->SetAttribute(tag, AttrAngle1, arc->GetFormulaF1());
doc->SetAttribute(tag, AttrAngle2, arc->GetFormulaF2()); doc->SetAttribute(tag, AttrAngle2, arc->GetFormulaF2());
doc->SetAttribute(tag, AttrColor, lineColor);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -373,7 +379,7 @@ void VToolArc::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
*/ */
void VToolArc::RefreshGeometry() 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()); this->setPath(ToolPath());
if (vis != nullptr) if (vis != nullptr)

View File

@ -40,12 +40,13 @@ class VToolArc :public VAbstractSpline
{ {
Q_OBJECT Q_OBJECT
public: 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(); virtual void setDialog();
static VToolArc* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolArc* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolArc* Create(const quint32 _id, const quint32 &center, QString &radius, QString &f1, QString &f2, static VToolArc* Create(const quint32 _id, const quint32 &center, QString &radius, QString &f1, QString &f2,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse, const QString &color, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Source &typeCreation); const Document &parse, const Source &typeCreation);
static const QString TagName; static const QString TagName;
static const QString ToolType; static const QString ToolType;
virtual int type() const {return Type;} virtual int type() const {return Type;}
@ -55,14 +56,14 @@ public:
quint32 getCenter() const; quint32 getCenter() const;
void setCenter(const quint32 &value); void setCenter(const quint32 &value);
VFormula getFormulaRadius() const; VFormula GetFormulaRadius() const;
void setFormulaRadius(const VFormula &value); void SetFormulaRadius(const VFormula &value);
VFormula getFormulaF1() const; VFormula GetFormulaF1() const;
void setFormulaF1(const VFormula &value); void SetFormulaF1(const VFormula &value);
VFormula getFormulaF2() const; VFormula GetFormulaF2() const;
void setFormulaF2(const VFormula &value); void SetFormulaF2(const VFormula &value);
virtual void ShowVisualization(bool show); virtual void ShowVisualization(bool show);
protected: protected:

View File

@ -49,9 +49,10 @@ const QString VToolBisector::ToolType = QStringLiteral("bisector");
* @param parent parent object. * @param parent parent object.
*/ */
VToolBisector::VToolBisector(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, VToolBisector::VToolBisector(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const QString &formula, const quint32 &firstPointId, const quint32 &secondPointId, const QString &lineColor, const QString &formula, const quint32 &firstPointId,
const quint32 &thirdPointId, const Source &typeCreation, QGraphicsItem *parent) const quint32 &secondPointId, const quint32 &thirdPointId, const Source &typeCreation,
:VToolLinePoint(doc, data, id, typeLine, formula, secondPointId, 0, parent), firstPointId(NULL_ID), QGraphicsItem *parent)
:VToolLinePoint(doc, data, id, typeLine, lineColor, formula, secondPointId, 0, parent), firstPointId(NULL_ID),
thirdPointId(NULL_ID) thirdPointId(NULL_ID)
{ {
this->firstPointId = firstPointId; this->firstPointId = firstPointId;
@ -112,12 +113,13 @@ void VToolBisector::setDialog()
DialogBisector *dialogTool = qobject_cast<DialogBisector*>(dialog); DialogBisector *dialogTool = qobject_cast<DialogBisector*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id); const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
dialogTool->setTypeLine(typeLine); dialogTool->SetTypeLine(typeLine);
dialogTool->setFormula(formulaLength); dialogTool->SetLineColor(lineColor);
dialogTool->setFirstPointId(firstPointId); dialogTool->SetFormula(formulaLength);
dialogTool->setSecondPointId(basePointId); dialogTool->SetFirstPointId(firstPointId);
dialogTool->setThirdPointId(thirdPointId); dialogTool->SetSecondPointId(basePointId);
dialogTool->setPointName(p->name()); dialogTool->SetThirdPointId(thirdPointId);
dialogTool->SetPointName(p->name());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -134,15 +136,16 @@ VToolBisector* VToolBisector::Create(DialogTool *dialog, VMainGraphicsScene *sce
SCASSERT(dialog != nullptr); SCASSERT(dialog != nullptr);
DialogBisector *dialogTool = qobject_cast<DialogBisector*>(dialog); DialogBisector *dialogTool = qobject_cast<DialogBisector*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
QString formula = dialogTool->getFormula(); QString formula = dialogTool->GetFormula();
const quint32 firstPointId = dialogTool->getFirstPointId(); const quint32 firstPointId = dialogTool->GetFirstPointId();
const quint32 secondPointId = dialogTool->getSecondPointId(); const quint32 secondPointId = dialogTool->GetSecondPointId();
const quint32 thirdPointId = dialogTool->getThirdPointId(); const quint32 thirdPointId = dialogTool->GetThirdPointId();
const QString typeLine = dialogTool->getTypeLine(); const QString typeLine = dialogTool->GetTypeLine();
const QString lineColor = dialogTool->GetLineColor();
const QString pointName = dialogTool->getPointName(); const QString pointName = dialogTool->getPointName();
VToolBisector *point = nullptr; VToolBisector *point = nullptr;
point=Create(0, formula, firstPointId, secondPointId, thirdPointId, typeLine, pointName, 5, 10, scene, doc, data, point=Create(0, formula, firstPointId, secondPointId, thirdPointId, typeLine, lineColor, pointName, 5, 10, scene,
Document::FullParse, Source::FromGui); doc, data, Document::FullParse, Source::FromGui);
if (point != nullptr) if (point != nullptr)
{ {
point->dialog=dialogTool; point->dialog=dialogTool;
@ -170,8 +173,8 @@ VToolBisector* VToolBisector::Create(DialogTool *dialog, VMainGraphicsScene *sce
*/ */
VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const quint32 &firstPointId, VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine, const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine,
const QString &pointName, const qreal &mx, const qreal &my, const QString &lineColor, const QString &pointName, const qreal &mx,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation) const Document &parse, const Source &typeCreation)
{ {
const QSharedPointer<VPointF> firstPoint = data->GeometricObject<VPointF>(firstPointId); const QSharedPointer<VPointF> firstPoint = data->GeometricObject<VPointF>(firstPointId);
@ -200,12 +203,12 @@ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const
VDrawTool::AddRecord(id, Tool::Bisector, doc); VDrawTool::AddRecord(id, Tool::Bisector, doc);
if (parse == Document::FullParse) if (parse == Document::FullParse)
{ {
VToolBisector *point = new VToolBisector(doc, data, id, typeLine, formula, firstPointId, secondPointId, VToolBisector *point = new VToolBisector(doc, data, id, typeLine, lineColor, formula, firstPointId,
thirdPointId, typeCreation); secondPointId, thirdPointId, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolBisector::SetFactor); 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->AddTool(id, point);
doc->IncrementReferens(firstPointId); doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId); doc->IncrementReferens(secondPointId);
@ -221,15 +224,7 @@ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const
*/ */
void VToolBisector::FullUpdateFromFile() void VToolBisector::FullUpdateFromFile()
{ {
QDomElement domElement = doc->elementById(QString().setNum(id)); ReadAttributes();
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();
}
RefreshGeometry(); RefreshGeometry();
if (vis != nullptr) if (vis != nullptr)
@ -296,11 +291,12 @@ void VToolBisector::SaveDialog(QDomElement &domElement)
DialogBisector *dialogTool = qobject_cast<DialogBisector*>(dialog); DialogBisector *dialogTool = qobject_cast<DialogBisector*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine());
doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor());
doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId())); doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPointId()));
doc->SetAttribute(domElement, AttrThirdPoint, QString().setNum(dialogTool->getThirdPointId())); 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<VGObject> &obj)
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrTypeLine, typeLine); doc->SetAttribute(tag, AttrTypeLine, typeLine);
doc->SetAttribute(tag, AttrLineColor, lineColor);
doc->SetAttribute(tag, AttrLength, formulaLength); doc->SetAttribute(tag, AttrLength, formulaLength);
doc->SetAttribute(tag, AttrFirstPoint, firstPointId); doc->SetAttribute(tag, AttrFirstPoint, firstPointId);
doc->SetAttribute(tag, AttrSecondPoint, basePointId); doc->SetAttribute(tag, AttrSecondPoint, basePointId);
@ -323,13 +320,24 @@ void VToolBisector::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &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; return thirdPointId;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolBisector::setThirdPointId(const quint32 &value) void VToolBisector::SetThirdPointId(const quint32 &value)
{ {
if (value != NULL_ID) if (value != NULL_ID)
{ {
@ -377,13 +385,13 @@ void VToolBisector::ShowVisualization(bool show)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
quint32 VToolBisector::getFirstPointId() const quint32 VToolBisector::GetFirstPointId() const
{ {
return firstPointId; return firstPointId;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolBisector::setFirstPointId(const quint32 &value) void VToolBisector::SetFirstPointId(const quint32 &value)
{ {
if (value != NULL_ID) if (value != NULL_ID)
{ {

View File

@ -39,9 +39,9 @@ class VToolBisector : public VToolLinePoint
Q_OBJECT Q_OBJECT
public: public:
VToolBisector(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &formula, VToolBisector(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &lineColor,
const quint32 &firstPointId, const quint32 &secondPointId, const quint32 &thirdPointId, const QString &formula, const quint32 &firstPointId, const quint32 &secondPointId,
const Source &typeCreation, QGraphicsItem * parent = nullptr); const quint32 &thirdPointId, const Source &typeCreation, QGraphicsItem * parent = nullptr);
static qreal BisectorAngle(const QPointF &firstPoint, const QPointF &secondPoint, const QPointF &thirdPoint); static qreal BisectorAngle(const QPointF &firstPoint, const QPointF &secondPoint, const QPointF &thirdPoint);
static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const QPointF &thirdPoint, static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const QPointF &thirdPoint,
const qreal& length); const qreal& length);
@ -49,18 +49,18 @@ public:
static VToolBisector* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolBisector* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolBisector* Create(const quint32 _id, QString &formula, const quint32 &firstPointId, static VToolBisector* Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine, const quint32 &secondPointId, const quint32 &thirdPointId, const QString &typeLine,
const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, const QString &lineColor, const QString &pointName, const qreal &mx, const qreal &my,
VPattern *doc, VContainer *data, const Document &parse, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation); const Source &typeCreation);
static const QString ToolType; static const QString ToolType;
virtual int type() const {return Type;} virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::Bisector)}; enum { Type = UserType + static_cast<int>(Tool::Bisector)};
quint32 getFirstPointId() const; quint32 GetFirstPointId() const;
void setFirstPointId(const quint32 &value); void SetFirstPointId(const quint32 &value);
quint32 getThirdPointId() const; quint32 GetThirdPointId() const;
void setThirdPointId(const quint32 &value); void SetThirdPointId(const quint32 &value);
virtual void ShowVisualization(bool show); virtual void ShowVisualization(bool show);
public slots: public slots:
@ -72,6 +72,7 @@ protected:
virtual void RemoveReferens(); virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private: private:
/** @brief firstPointId id first point of angle. */ /** @brief firstPointId id first point of angle. */
quint32 firstPointId; quint32 firstPointId;

View File

@ -38,10 +38,11 @@ const QString VToolCurveIntersectAxis::ToolType = QStringLiteral("curveIntersect
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VToolCurveIntersectAxis::VToolCurveIntersectAxis(VPattern *doc, VContainer *data, const quint32 &id, VToolCurveIntersectAxis::VToolCurveIntersectAxis(VPattern *doc, VContainer *data, const quint32 &id,
const QString &typeLine, const QString &formulaAngle, const QString &typeLine, const QString &lineColor,
const quint32 &basePointId, const quint32 &curveId, const QString &formulaAngle, const quint32 &basePointId,
const Source &typeCreation, QGraphicsItem *parent) const quint32 &curveId, const Source &typeCreation,
:VToolLinePoint(doc, data, id, typeLine, QString(), basePointId, 0, parent), formulaAngle(formulaAngle), QGraphicsItem *parent)
:VToolLinePoint(doc, data, id, typeLine, lineColor, QString(), basePointId, 0, parent), formulaAngle(formulaAngle),
curveId(curveId) curveId(curveId)
{ {
if (typeCreation == Source::FromGui) if (typeCreation == Source::FromGui)
@ -66,11 +67,12 @@ void VToolCurveIntersectAxis::setDialog()
DialogCurveIntersectAxis *dialogTool = qobject_cast<DialogCurveIntersectAxis*>(dialog); DialogCurveIntersectAxis *dialogTool = qobject_cast<DialogCurveIntersectAxis*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id); const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
dialogTool->setTypeLine(typeLine); dialogTool->SetTypeLine(typeLine);
dialogTool->setAngle(formulaAngle); dialogTool->SetLineColor(lineColor);
dialogTool->setBasePointId(basePointId); dialogTool->SetAngle(formulaAngle);
dialogTool->SetBasePointId(basePointId);
dialogTool->setCurveId(curveId); 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<DialogCurveIntersectAxis*>(dialog); DialogCurveIntersectAxis *dialogTool = qobject_cast<DialogCurveIntersectAxis*>(dialog);
SCASSERT(dialogTool); SCASSERT(dialogTool);
const QString pointName = dialogTool->getPointName(); const QString pointName = dialogTool->getPointName();
const QString typeLine = dialogTool->getTypeLine(); const QString typeLine = dialogTool->GetTypeLine();
QString formulaAngle = dialogTool->getAngle(); const QString lineColor = dialogTool->GetLineColor();
const quint32 basePointId = dialogTool->getBasePointId(); QString formulaAngle = dialogTool->GetAngle();
const quint32 basePointId = dialogTool->GetBasePointId();
const quint32 curveId = dialogTool->getCurveId(); const quint32 curveId = dialogTool->getCurveId();
VToolCurveIntersectAxis *point = nullptr; 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); Document::FullParse, Source::FromGui);
if (point != nullptr) if (point != nullptr)
{ {
@ -98,9 +101,9 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(DialogTool *dialog, VMa
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(const quint32 _id, const QString &pointName, VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(const quint32 _id, const QString &pointName,
const QString &typeLine, QString &formulaAngle, const QString &typeLine, const QString &lineColor,
const quint32 &basePointId, const quint32 &curveId, QString &formulaAngle, const quint32 &basePointId,
const qreal &mx, const qreal &my, const quint32 &curveId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation) const Document &parse, const Source &typeCreation)
{ {
@ -127,12 +130,12 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(const quint32 _id, cons
VDrawTool::AddRecord(id, Tool::CurveIntersectAxis, doc); VDrawTool::AddRecord(id, Tool::CurveIntersectAxis, doc);
if (parse == Document::FullParse) if (parse == Document::FullParse)
{ {
VToolCurveIntersectAxis *point = new VToolCurveIntersectAxis(doc, data, id, typeLine, formulaAngle, basePointId, VToolCurveIntersectAxis *point = new VToolCurveIntersectAxis(doc, data, id, typeLine, lineColor, formulaAngle,
curveId, typeCreation); basePointId, curveId, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor); connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCurveIntersectAxis::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCurveIntersectAxis::Disable);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(basePointId); doc->IncrementReferens(basePointId);
doc->IncrementReferens(curveId); 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()); VFormula fAngle(formulaAngle, getData());
fAngle.setCheckZero(false); 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) if (value.error() == false)
{ {
formulaAngle = value.getFormula(FormulaType::FromUser); formulaAngle = value.GetFormula(FormulaType::FromUser);
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id); QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj); SaveOption(obj);
@ -226,7 +229,7 @@ void VToolCurveIntersectAxis::ShowVisualization(bool show)
visual->setPoint1Id(curveId); visual->setPoint1Id(curveId);
visual->setAxisPointId(basePointId); visual->setAxisPointId(basePointId);
visual->setAngle(qApp->FormulaToUser(formulaAngle)); visual->SetAngle(qApp->FormulaToUser(formulaAngle));
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry(); visual->RefreshGeometry();
vis = visual; vis = visual;
@ -250,14 +253,7 @@ void VToolCurveIntersectAxis::ShowVisualization(bool show)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolCurveIntersectAxis::FullUpdateFromFile() void VToolCurveIntersectAxis::FullUpdateFromFile()
{ {
QDomElement domElement = doc->elementById(QString().setNum(id)); ReadAttributes();
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
basePointId = domElement.attribute(AttrBasePoint, "").toUInt();
curveId = domElement.attribute(AttrCurve, "").toUInt();
formulaAngle = domElement.attribute(AttrAngle, "");
}
RefreshGeometry(); RefreshGeometry();
if (vis != nullptr) if (vis != nullptr)
@ -265,7 +261,7 @@ void VToolCurveIntersectAxis::FullUpdateFromFile()
VisToolCurveIntersectAxis *visual = qobject_cast<VisToolCurveIntersectAxis *>(vis); VisToolCurveIntersectAxis *visual = qobject_cast<VisToolCurveIntersectAxis *>(vis);
visual->setPoint1Id(curveId); visual->setPoint1Id(curveId);
visual->setAxisPointId(basePointId); visual->setAxisPointId(basePointId);
visual->setAngle(qApp->FormulaToUser(formulaAngle)); visual->SetAngle(qApp->FormulaToUser(formulaAngle));
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry(); visual->RefreshGeometry();
} }
@ -290,9 +286,10 @@ void VToolCurveIntersectAxis::SaveDialog(QDomElement &domElement)
DialogCurveIntersectAxis *dialogTool = qobject_cast<DialogCurveIntersectAxis*>(dialog); DialogCurveIntersectAxis *dialogTool = qobject_cast<DialogCurveIntersectAxis*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine());
doc->SetAttribute(domElement, AttrAngle, dialogTool->getAngle()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor());
doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->getBasePointId())); doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle());
doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->GetBasePointId()));
doc->SetAttribute(domElement, AttrCurve, QString().setNum(dialogTool->getCurveId())); doc->SetAttribute(domElement, AttrCurve, QString().setNum(dialogTool->getCurveId()));
} }
@ -309,7 +306,18 @@ void VToolCurveIntersectAxis::SaveOptions(QDomElement &tag, QSharedPointer<VGObj
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrTypeLine, typeLine); doc->SetAttribute(tag, AttrTypeLine, typeLine);
doc->SetAttribute(tag, AttrLineColor, lineColor);
doc->SetAttribute(tag, AttrAngle, formulaAngle); doc->SetAttribute(tag, AttrAngle, formulaAngle);
doc->SetAttribute(tag, AttrBasePoint, basePointId); doc->SetAttribute(tag, AttrBasePoint, basePointId);
doc->SetAttribute(tag, AttrCurve, curveId); 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, "");
}

View File

@ -36,17 +36,18 @@ class VToolCurveIntersectAxis : public VToolLinePoint
Q_OBJECT Q_OBJECT
public: public:
VToolCurveIntersectAxis(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, VToolCurveIntersectAxis(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const QString &formulaAngle, const quint32 &basePointId, const quint32 &curveId, const QString &lineColor, const QString &formulaAngle, const quint32 &basePointId,
const Source &typeCreation, QGraphicsItem * parent = nullptr); const quint32 &curveId, const Source &typeCreation, QGraphicsItem * parent = nullptr);
virtual ~VToolCurveIntersectAxis(); virtual ~VToolCurveIntersectAxis();
virtual void setDialog(); virtual void setDialog();
static VToolCurveIntersectAxis *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, static VToolCurveIntersectAxis *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data); VContainer *data);
static VToolCurveIntersectAxis *Create(const quint32 _id, const QString &pointName, const QString &typeLine, static VToolCurveIntersectAxis *Create(const quint32 _id, const QString &pointName, const QString &typeLine,
QString &formulaAngle, const quint32 &basePointId, const quint32 &curveId, const QString &lineColor, QString &formulaAngle, const quint32 &basePointId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, const quint32 &curveId, const qreal &mx, const qreal &my,
VContainer *data, const Document &parse, const Source &typeCreation); VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation);
static QPointF FindPoint(const QPointF &point, qreal angle, const QSharedPointer<VAbstractCurve> &curve); static QPointF FindPoint(const QPointF &point, qreal angle, const QSharedPointer<VAbstractCurve> &curve);
@ -54,8 +55,8 @@ public:
virtual int type() const {return Type;} virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::CurveIntersectAxis)}; enum { Type = UserType + static_cast<int>(Tool::CurveIntersectAxis)};
VFormula getFormulaAngle() const; VFormula GetFormulaAngle() const;
void setFormulaAngle(const VFormula &value); void SetFormulaAngle(const VFormula &value);
quint32 getCurveId() const; quint32 getCurveId() const;
void setCurveId(const quint32 &value); void setCurveId(const quint32 &value);
@ -68,6 +69,7 @@ protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private: private:
Q_DISABLE_COPY(VToolCurveIntersectAxis) Q_DISABLE_COPY(VToolCurveIntersectAxis)
QString formulaAngle; QString formulaAngle;

View File

@ -32,7 +32,7 @@
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VToolCut::VToolCut(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, 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) QGraphicsItem *parent)
:VToolPoint(doc, data, id, parent), formula(formula), firstCurve(nullptr), secondCurve(nullptr), :VToolPoint(doc, data, id, parent), formula(formula), firstCurve(nullptr), secondCurve(nullptr),
curveCutId(curveCutId), curve1id(curve1id), curve2id(curve2id) 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(curve1id > 0, Q_FUNC_INFO, "curve1id <= 0");
Q_ASSERT_X(curve2id > 0, Q_FUNC_INFO, "curve2id <= 0"); Q_ASSERT_X(curve2id > 0, Q_FUNC_INFO, "curve2id <= 0");
firstCurve = new VSimpleCurve(curve1id, &currentColor, SimpleCurvePoint::ForthPoint, &factor); lineColor = color;
firstCurve = new VSimpleCurve(curve1id, QColor(lineColor), SimpleCurvePoint::ForthPoint, &factor);
firstCurve->setParentItem(this); firstCurve->setParentItem(this);
connect(firstCurve, &VSimpleCurve::Choosed, this, &VToolCut::CurveChoosed); connect(firstCurve, &VSimpleCurve::Choosed, this, &VToolCut::CurveChoosed);
connect(firstCurve, &VSimpleCurve::HoverPath, this, &VToolCut::HoverPath); connect(firstCurve, &VSimpleCurve::HoverPath, this, &VToolCut::HoverPath);
secondCurve = new VSimpleCurve(curve2id, &currentColor, SimpleCurvePoint::FirstPoint, &factor); secondCurve = new VSimpleCurve(curve2id, QColor(lineColor), SimpleCurvePoint::FirstPoint, &factor);
secondCurve->setParentItem(this); secondCurve->setParentItem(this);
connect(secondCurve, &VSimpleCurve::Choosed, this, &VToolCut::CurveChoosed); connect(secondCurve, &VSimpleCurve::Choosed, this, &VToolCut::CurveChoosed);
connect(secondCurve, &VSimpleCurve::HoverPath, this, &VToolCut::HoverPath); 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) void VToolCut::ChangedActivDraw(const QString &newName)
{ {
VToolPoint::ChangedActivDraw(newName); Disable(!(nameActivDraw == newName));
const bool flag = (nameActivDraw == newName);
this->setEnabled(flag);
firstCurve->ChangedActivDraw(flag);
secondCurve->ChangedActivDraw(flag);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -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 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()); VFormula val(formula, getData());
val.setCheckZero(true); 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) if (value.error() == false)
{ {
formula = value.getFormula(FormulaType::FromUser); formula = value.GetFormula(FormulaType::FromUser);
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id); QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj); SaveOption(obj);
@ -146,5 +152,4 @@ void VToolCut::FullUpdateCurveFromFile(const QString &attrCurve)
formula = domElement.attribute(AttrLength, ""); formula = domElement.attribute(AttrLength, "");
curveCutId = domElement.attribute(attrCurve, "").toUInt(); curveCutId = domElement.attribute(attrCurve, "").toUInt();
} }
RefreshGeometry();
} }

View File

@ -39,12 +39,12 @@ class VToolCut : public VToolPoint
Q_OBJECT Q_OBJECT
public: public:
VToolCut(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, const quint32 &curveCutId, 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;} virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::Cut)}; enum { Type = UserType + static_cast<int>(Tool::Cut)};
VFormula getFormula() const; VFormula GetFormula() const;
void setFormula(const VFormula &value); void SetFormula(const VFormula &value);
quint32 getCurveCutId() const; quint32 getCurveCutId() const;
void setCurveCutId(const quint32 &value); void setCurveCutId(const quint32 &value);
@ -53,6 +53,7 @@ public slots:
virtual void ChangedActivDraw(const QString &newName); virtual void ChangedActivDraw(const QString &newName);
virtual void CurveChoosed(quint32 id)=0; virtual void CurveChoosed(quint32 id)=0;
void HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirection direction); void HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirection direction);
void Disable(bool disable);
protected: protected:
/** @brief formula keep formula of length */ /** @brief formula keep formula of length */
QString formula; QString formula;

View File

@ -50,9 +50,9 @@ const QString VToolCutArc::AttrArc = QStringLiteral("arc");
* @param parent parent object. * @param parent parent object.
*/ */
VToolCutArc::VToolCutArc(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, 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) 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(firstCurve, curve1id, SimpleCurvePoint::ForthPoint);
RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint); RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint);
@ -77,9 +77,10 @@ void VToolCutArc::setDialog()
DialogCutArc *dialogTool = qobject_cast<DialogCutArc*>(dialog); DialogCutArc *dialogTool = qobject_cast<DialogCutArc*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id); const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
dialogTool->setFormula(formula); dialogTool->SetFormula(formula);
dialogTool->setArcId(curveCutId); 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<DialogCutArc*>(dialog); DialogCutArc *dialogTool = qobject_cast<DialogCutArc*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
const QString pointName = dialogTool->getPointName(); const QString pointName = dialogTool->getPointName();
QString formula = dialogTool->getFormula(); QString formula = dialogTool->GetFormula();
const quint32 arcId = dialogTool->getArcId(); const quint32 arcId = dialogTool->getArcId();
const QString color = dialogTool->GetColor();
VToolCutArc* point = nullptr; 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) if (point != nullptr)
{ {
point->dialog=dialogTool; point->dialog=dialogTool;
@ -123,8 +125,8 @@ VToolCutArc* VToolCutArc::Create(DialogTool *dialog, VMainGraphicsScene *scene,
* @param typeCreation way we create this tool. * @param typeCreation way we create this tool.
*/ */
VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId, VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, const qreal &mx, const qreal &my, const QString &color, VMainGraphicsScene *scene,
VContainer *data, const Document &parse, const Source &typeCreation) VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation)
{ {
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(arcId); const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(arcId);
@ -167,11 +169,11 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS
VDrawTool::AddRecord(id, Tool::CutArc, doc); VDrawTool::AddRecord(id, Tool::CutArc, doc);
if (parse == Document::FullParse) 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); scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCutArc::SetFactor); 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(id, point);
doc->AddTool(arc1id, point); doc->AddTool(arc1id, point);
doc->AddTool(arc2id, point); doc->AddTool(arc2id, point);
@ -220,7 +222,8 @@ void VToolCutArc::ShowVisualization(bool show)
*/ */
void VToolCutArc::FullUpdateFromFile() void VToolCutArc::FullUpdateFromFile()
{ {
FullUpdateCurveFromFile(AttrArc); ReadAttributes();
RefreshGeometry();
if (vis != nullptr) if (vis != nullptr)
{ {
@ -271,8 +274,9 @@ void VToolCutArc::SaveDialog(QDomElement &domElement)
DialogCutArc *dialogTool = qobject_cast<DialogCutArc*>(dialog); DialogCutArc *dialogTool = qobject_cast<DialogCutArc*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); 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, 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()); path.translate(-arc->GetP2().x(), -arc->GetP2().y());
} }
curve->SetCurrentColor(QColor(lineColor));
curve->setPath(path); curve->setPath(path);
} }
@ -310,7 +315,16 @@ void VToolCutArc::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
doc->SetAttribute(tag, AttrName, point->name()); doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrColor, lineColor);
doc->SetAttribute(tag, AttrLength, formula); doc->SetAttribute(tag, AttrLength, formula);
doc->SetAttribute(tag, AttrArc, curveCutId); 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);
}

View File

@ -39,13 +39,13 @@ class VToolCutArc : public VToolCut
Q_OBJECT Q_OBJECT
public: public:
VToolCutArc(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, const quint32 &arcId, 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); QGraphicsItem * parent = nullptr);
virtual void setDialog(); virtual void setDialog();
static VToolCutArc* Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); 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, static VToolCutArc* Create(const quint32 _id, const QString &pointName, QString &formula, const quint32 &arcId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, const qreal &mx, const qreal &my, const QString &color, VMainGraphicsScene *scene,
VContainer *data, const Document &parse, const Source &typeCreation); VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation);
static const QString ToolType; static const QString ToolType;
static const QString AttrArc; static const QString AttrArc;
virtual int type() const {return Type;} virtual int type() const {return Type;}
@ -61,6 +61,7 @@ protected:
virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition, virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition,
PathDirection direction = PathDirection::Hide); PathDirection direction = PathDirection::Hide);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private: private:
Q_DISABLE_COPY(VToolCutArc) Q_DISABLE_COPY(VToolCutArc)
}; };

View File

@ -50,8 +50,8 @@ const QString VToolCutSpline::AttrSpline = QStringLiteral("spline");
*/ */
VToolCutSpline::VToolCutSpline(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, VToolCutSpline::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 Source &typeCreation, QGraphicsItem *parent) const QString &color, const Source &typeCreation, QGraphicsItem *parent)
:VToolCut(doc, data, id, formula, splineId, spl1id, spl2id, parent) :VToolCut(doc, data, id, formula, splineId, spl1id, spl2id, color, parent)
{ {
RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint); RefreshCurve(firstCurve, curve1id, SimpleCurvePoint::ForthPoint);
RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint); RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint);
@ -76,9 +76,10 @@ void VToolCutSpline::setDialog()
DialogCutSpline *dialogTool = qobject_cast<DialogCutSpline*>(dialog); DialogCutSpline *dialogTool = qobject_cast<DialogCutSpline*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id); const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
dialogTool->setFormula(formula); dialogTool->SetFormula(formula);
dialogTool->setSplineId(curveCutId); 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<DialogCutSpline*>(dialog); DialogCutSpline *dialogTool = qobject_cast<DialogCutSpline*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
const QString pointName = dialogTool->getPointName(); const QString pointName = dialogTool->getPointName();
QString formula = dialogTool->getFormula(); QString formula = dialogTool->GetFormula();
const quint32 splineId = dialogTool->getSplineId(); const quint32 splineId = dialogTool->getSplineId();
const QString color = dialogTool->GetColor();
VToolCutSpline* point = nullptr; 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) if (point != nullptr)
{ {
point->dialog=dialogTool; point->dialog=dialogTool;
@ -123,7 +126,7 @@ VToolCutSpline* VToolCutSpline::Create(DialogTool *dialog, VMainGraphicsScene *s
* @param typeCreation way we create this tool. * @param typeCreation way we create this tool.
*/ */
VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointName, QString &formula, 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, VMainGraphicsScene *scene, VPattern *doc, VContainer *data,
const Document &parse, const Source &typeCreation) 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); VDrawTool::AddRecord(id, Tool::CutSpline, doc);
if (parse == Document::FullParse) 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); scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCutSpline::SetFactor); 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(id, point);
doc->AddTool(spl1id, point); doc->AddTool(spl1id, point);
doc->AddTool(spl2id, point); doc->AddTool(spl2id, point);
@ -231,7 +235,8 @@ void VToolCutSpline::ShowVisualization(bool show)
*/ */
void VToolCutSpline::FullUpdateFromFile() void VToolCutSpline::FullUpdateFromFile()
{ {
FullUpdateCurveFromFile(AttrSpline); ReadAttributes();
RefreshGeometry();
if (vis != nullptr) if (vis != nullptr)
{ {
@ -282,8 +287,9 @@ void VToolCutSpline::SaveDialog(QDomElement &domElement)
DialogCutSpline *dialogTool = qobject_cast<DialogCutSpline*>(dialog); DialogCutSpline *dialogTool = qobject_cast<DialogCutSpline*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); 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, 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()); path.translate(-spl->GetP4().toQPointF().x(), -spl->GetP4().toQPointF().y());
} }
curve->SetCurrentColor(QColor(lineColor));
curve->setPath(path); curve->setPath(path);
} }
@ -321,7 +328,16 @@ void VToolCutSpline::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj
doc->SetAttribute(tag, AttrName, point->name()); doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrColor, lineColor);
doc->SetAttribute(tag, AttrLength, formula); doc->SetAttribute(tag, AttrLength, formula);
doc->SetAttribute(tag, AttrSpline, curveCutId); 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);
}

View File

@ -40,13 +40,14 @@ class VToolCutSpline : public VToolCut
public: public:
VToolCutSpline(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, 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); const Source &typeCreation, QGraphicsItem * parent = nullptr);
virtual void setDialog(); virtual void setDialog();
static VToolCutSpline *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolCutSpline *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolCutSpline *Create(const quint32 _id, const QString &pointName, QString &formula, static VToolCutSpline *Create(const quint32 _id, const QString &pointName, QString &formula,
const quint32 &splineId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, const quint32 &splineId, const qreal &mx, const qreal &my, const QString &color,
VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation); VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation);
static const QString ToolType; static const QString ToolType;
static const QString AttrSpline; static const QString AttrSpline;
virtual int type() const {return Type;} virtual int type() const {return Type;}
@ -62,6 +63,7 @@ protected:
virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition, virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition,
PathDirection direction = PathDirection::Hide); PathDirection direction = PathDirection::Hide);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private: private:
Q_DISABLE_COPY(VToolCutSpline) Q_DISABLE_COPY(VToolCutSpline)
}; };

View File

@ -53,9 +53,9 @@ const QString VToolCutSplinePath::AttrSplinePath = QStringLiteral("splinePath");
*/ */
VToolCutSplinePath::VToolCutSplinePath(VPattern *doc, VContainer *data, const quint32 &id, VToolCutSplinePath::VToolCutSplinePath(VPattern *doc, VContainer *data, const quint32 &id,
const QString &formula, const quint32 &splinePathId, 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) 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(firstCurve, curve1id, SimpleCurvePoint::ForthPoint);
RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint); RefreshCurve(secondCurve, curve2id, SimpleCurvePoint::FirstPoint);
@ -80,9 +80,10 @@ void VToolCutSplinePath::setDialog()
DialogCutSplinePath *dialogTool = qobject_cast<DialogCutSplinePath*>(dialog); DialogCutSplinePath *dialogTool = qobject_cast<DialogCutSplinePath*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id); const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(id);
dialogTool->setFormula(formula); dialogTool->SetFormula(formula);
dialogTool->setSplinePathId(curveCutId); 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<DialogCutSplinePath*>(dialog); DialogCutSplinePath *dialogTool = qobject_cast<DialogCutSplinePath*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
const QString pointName = dialogTool->getPointName(); const QString pointName = dialogTool->getPointName();
QString formula = dialogTool->getFormula(); QString formula = dialogTool->GetFormula();
const quint32 splinePathId = dialogTool->getSplinePathId(); const quint32 splinePathId = dialogTool->getSplinePathId();
const QString color = dialogTool->GetColor();
VToolCutSplinePath* point = nullptr; 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) if (point != nullptr)
{ {
point->dialog=dialogTool; point->dialog=dialogTool;
@ -128,8 +131,8 @@ VToolCutSplinePath* VToolCutSplinePath::Create(DialogTool *dialog, VMainGraphics
*/ */
VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QString &formula, VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString &pointName, QString &formula,
const quint32 &splinePathId, const qreal &mx, const qreal &my, const quint32 &splinePathId, const qreal &mx, const qreal &my,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const QString &color, VMainGraphicsScene *scene, VPattern *doc,
const Document &parse, const Source &typeCreation) VContainer *data, const Document &parse, const Source &typeCreation)
{ {
const QSharedPointer<VSplinePath> splPath = data->GeometricObject<VSplinePath>(splinePathId); const QSharedPointer<VSplinePath> splPath = data->GeometricObject<VSplinePath>(splinePathId);
SCASSERT(splPath != nullptr); SCASSERT(splPath != nullptr);
@ -156,8 +159,8 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString
VSplinePoint splP1 = splPath->at(p1); VSplinePoint splP1 = splPath->at(p1);
VSplinePoint splP2 = splPath->at(p2); VSplinePoint splP2 = splPath->at(p2);
const VSpline spl1 = VSpline(splP1.P(), spl1p2, spl1p3, *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()); const VSpline spl2 = VSpline(*p, spl2p2, spl2p3, splP2.P(), splPath->GetKCurve());
VSplinePath *splPath1 = new VSplinePath(); VSplinePath *splPath1 = new VSplinePath();
VSplinePath *splPath2 = new VSplinePath(); VSplinePath *splPath2 = new VSplinePath();
@ -191,8 +194,8 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString
splPath2->append(splPath->at(i)); splPath2->append(splPath->at(i));
} }
} }
splPath1->setKCurve(splPath->getKCurve()); splPath1->SetKCurve(splPath->GetKCurve());
splPath2->setKCurve(splPath->getKCurve()); splPath2->SetKCurve(splPath->GetKCurve());
splPath1->setMaxCountPoints(splPath->CountPoint()); splPath1->setMaxCountPoints(splPath->CountPoint());
splPath2->setMaxCountPoints(splPath->CountPoint()); splPath2->setMaxCountPoints(splPath->CountPoint());
@ -223,11 +226,11 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString
if (parse == Document::FullParse) if (parse == Document::FullParse)
{ {
VToolCutSplinePath *point = new VToolCutSplinePath(doc, data, id, formula, splinePathId, splPath1id, VToolCutSplinePath *point = new VToolCutSplinePath(doc, data, id, formula, splinePathId, splPath1id,
splPath2id, typeCreation); splPath2id, color, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor); connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCutSplinePath::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCutSplinePath::Disable);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->AddTool(splPath1id, point); doc->AddTool(splPath1id, point);
doc->AddTool(splPath2id, point); doc->AddTool(splPath2id, point);
@ -280,7 +283,8 @@ void VToolCutSplinePath::ShowVisualization(bool show)
*/ */
void VToolCutSplinePath::FullUpdateFromFile() void VToolCutSplinePath::FullUpdateFromFile()
{ {
FullUpdateCurveFromFile(AttrSplinePath); ReadAttributes();
RefreshGeometry();
if (vis != nullptr) if (vis != nullptr)
{ {
@ -331,8 +335,9 @@ void VToolCutSplinePath::SaveDialog(QDomElement &domElement)
DialogCutSplinePath *dialogTool = qobject_cast<DialogCutSplinePath*>(dialog); DialogCutSplinePath *dialogTool = qobject_cast<DialogCutSplinePath*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); 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, 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()); VSpline spl = splPath->GetSpline(splPath->Count());
path.translate(-spl.GetP4().toQPointF().x(), -spl.GetP4().toQPointF().y()); path.translate(-spl.GetP4().toQPointF().x(), -spl.GetP4().toQPointF().y());
} }
curve->SetCurrentColor(QColor(lineColor));
curve->setPath(path); curve->setPath(path);
} }
@ -372,7 +378,16 @@ void VToolCutSplinePath::SaveOptions(QDomElement &tag, QSharedPointer<VGObject>
doc->SetAttribute(tag, AttrName, point->name()); doc->SetAttribute(tag, AttrName, point->name());
doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx())); doc->SetAttribute(tag, AttrMx, qApp->fromPixel(point->mx()));
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrColor, lineColor);
doc->SetAttribute(tag, AttrLength, formula); doc->SetAttribute(tag, AttrLength, formula);
doc->SetAttribute(tag, AttrSplinePath, curveCutId); 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);
}

View File

@ -42,12 +42,12 @@ public:
VToolCutSplinePath(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula, VToolCutSplinePath(VPattern *doc, VContainer *data, const quint32 &id, const QString &formula,
const quint32 &splinePathId, const quint32 &splPath1id, const quint32 &splPath2id, 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(); virtual void setDialog();
static VToolCutSplinePath *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolCutSplinePath *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolCutSplinePath *Create(const quint32 _id, const QString &pointName, QString &formula, static VToolCutSplinePath *Create(const quint32 _id, const QString &pointName, QString &formula,
const quint32 &splinePathId, const qreal &mx, const qreal &my, 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); const Document &parse, const Source &typeCreation);
static const QString ToolType; static const QString ToolType;
static const QString AttrSplinePath; static const QString AttrSplinePath;
@ -64,6 +64,7 @@ protected:
virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition, virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition,
PathDirection direction = PathDirection::Hide); PathDirection direction = PathDirection::Hide);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private: private:
Q_DISABLE_COPY(VToolCutSplinePath) Q_DISABLE_COPY(VToolCutSplinePath)
}; };

View File

@ -50,9 +50,10 @@ const QString VToolEndLine::ToolType = QStringLiteral("endLine");
* @param parent parent object. * @param parent parent object.
*/ */
VToolEndLine::VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, VToolEndLine::VToolEndLine(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const QString &formulaLength, const QString &formulaAngle, const quint32 &basePointId, const QString &lineColor, const QString &formulaLength, const QString &formulaAngle,
const Source &typeCreation, QGraphicsItem *parent) const quint32 &basePointId, const Source &typeCreation, QGraphicsItem *parent)
:VToolLinePoint(doc, data, id, typeLine, formulaLength, basePointId, 0, parent), formulaAngle(formulaAngle) :VToolLinePoint(doc, data, id, typeLine, lineColor, formulaLength, basePointId, 0, parent),
formulaAngle(formulaAngle)
{ {
if (typeCreation == Source::FromGui) if (typeCreation == Source::FromGui)
{ {
@ -79,11 +80,12 @@ void VToolEndLine::setDialog()
DialogEndLine *dialogTool = qobject_cast<DialogEndLine*>(dialog); DialogEndLine *dialogTool = qobject_cast<DialogEndLine*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id); const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
dialogTool->setTypeLine(typeLine); dialogTool->SetTypeLine(typeLine);
dialogTool->setFormula(formulaLength); dialogTool->SetLineColor(lineColor);
dialogTool->setAngle(formulaAngle); dialogTool->SetFormula(formulaLength);
dialogTool->setBasePointId(basePointId); dialogTool->SetAngle(formulaAngle);
dialogTool->setPointName(p->name()); dialogTool->SetBasePointId(basePointId);
dialogTool->SetPointName(p->name());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -101,13 +103,14 @@ VToolEndLine* VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene
DialogEndLine *dialogTool = qobject_cast<DialogEndLine*>(dialog); DialogEndLine *dialogTool = qobject_cast<DialogEndLine*>(dialog);
SCASSERT(dialogTool); SCASSERT(dialogTool);
const QString pointName = dialogTool->getPointName(); const QString pointName = dialogTool->getPointName();
const QString typeLine = dialogTool->getTypeLine(); const QString typeLine = dialogTool->GetTypeLine();
QString formulaLength = dialogTool->getFormula(); const QString lineColor = dialogTool->GetLineColor();
QString formulaAngle = dialogTool->getAngle(); QString formulaLength = dialogTool->GetFormula();
const quint32 basePointId = dialogTool->getBasePointId(); QString formulaAngle = dialogTool->GetAngle();
const quint32 basePointId = dialogTool->GetBasePointId();
VToolEndLine *point = nullptr; 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); Document::FullParse, Source::FromGui);
if (point != nullptr) 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 _id tool id, 0 if tool doesn't exist yet.
* @param pointName point name. * @param pointName point name.
* @param typeLine line type. * @param typeLine line type.
* @param lineColor line color.
* @param formulaLength string with formula length of line. * @param formulaLength string with formula length of line.
* @param formulaAngle formula angle of line. * @param formulaAngle formula angle of line.
* @param basePointId id first point of line. * @param basePointId id first point of line.
@ -135,9 +139,10 @@ VToolEndLine* VToolEndLine::Create(DialogTool *dialog, VMainGraphicsScene *scene
* @return the created tool * @return the created tool
*/ */
VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine, VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, const QString &typeLine,
QString &formulaLength, QString &formulaAngle, const quint32 &basePointId, const QString &lineColor, QString &formulaLength, QString &formulaAngle,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, const quint32 &basePointId, const qreal &mx, const qreal &my,
VContainer *data, const Document &parse, const Source &typeCreation) VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation)
{ {
const QSharedPointer<VPointF> basePoint = data->GeometricObject<VPointF>(basePointId); const QSharedPointer<VPointF> basePoint = data->GeometricObject<VPointF>(basePointId);
QLineF line = QLineF(basePoint->toQPointF(), QPointF(basePoint->x()+100, basePoint->y())); 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); VDrawTool::AddRecord(id, Tool::EndLine, doc);
if (parse == Document::FullParse) if (parse == Document::FullParse)
{ {
VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, formulaLength, formulaAngle, basePointId, VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, lineColor, formulaLength, formulaAngle,
typeCreation); basePointId, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor); connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolEndLine::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolEndLine::Disable);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(basePointId); doc->IncrementReferens(basePointId);
return point; return point;
@ -181,14 +186,7 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName,
*/ */
void VToolEndLine::FullUpdateFromFile() void VToolEndLine::FullUpdateFromFile()
{ {
QDomElement domElement = doc->elementById(QString().setNum(id)); ReadAttributes();
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
formulaLength = domElement.attribute(AttrLength, "");
basePointId = domElement.attribute(AttrBasePoint, "").toUInt();
formulaAngle = domElement.attribute(AttrAngle, "");
}
RefreshGeometry(); RefreshGeometry();
if (vis != nullptr) if (vis != nullptr)
@ -196,7 +194,7 @@ void VToolEndLine::FullUpdateFromFile()
VisToolEndLine *visual = qobject_cast<VisToolEndLine *>(vis); VisToolEndLine *visual = qobject_cast<VisToolEndLine *>(vis);
visual->setPoint1Id(basePointId); visual->setPoint1Id(basePointId);
visual->setLength(qApp->FormulaToUser(formulaLength)); visual->setLength(qApp->FormulaToUser(formulaLength));
visual->setAngle(qApp->FormulaToUser(formulaAngle)); visual->SetAngle(qApp->FormulaToUser(formulaAngle));
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry(); visual->RefreshGeometry();
} }
@ -232,10 +230,11 @@ void VToolEndLine::SaveDialog(QDomElement &domElement)
DialogEndLine *dialogTool = qobject_cast<DialogEndLine*>(dialog); DialogEndLine *dialogTool = qobject_cast<DialogEndLine*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine());
doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor());
doc->SetAttribute(domElement, AttrAngle, dialogTool->getAngle()); doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->getBasePointId())); doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle());
doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->GetBasePointId()));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -251,13 +250,24 @@ void VToolEndLine::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrTypeLine, typeLine); doc->SetAttribute(tag, AttrTypeLine, typeLine);
doc->SetAttribute(tag, AttrLineColor, lineColor);
doc->SetAttribute(tag, AttrLength, formulaLength); doc->SetAttribute(tag, AttrLength, formulaLength);
doc->SetAttribute(tag, AttrAngle, formulaAngle); doc->SetAttribute(tag, AttrAngle, formulaAngle);
doc->SetAttribute(tag, AttrBasePoint, basePointId); 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()); VFormula fAngle(formulaAngle, getData());
fAngle.setCheckZero(false); 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) if (value.error() == false)
{ {
formulaAngle = value.getFormula(FormulaType::FromUser); formulaAngle = value.GetFormula(FormulaType::FromUser);
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id); QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj); SaveOption(obj);
@ -292,7 +302,7 @@ void VToolEndLine::ShowVisualization(bool show)
visual->setPoint1Id(basePointId); visual->setPoint1Id(basePointId);
visual->setLength(qApp->FormulaToUser(formulaLength)); visual->setLength(qApp->FormulaToUser(formulaLength));
visual->setAngle(qApp->FormulaToUser(formulaAngle)); visual->SetAngle(qApp->FormulaToUser(formulaAngle));
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry(); visual->RefreshGeometry();
vis = visual; vis = visual;

View File

@ -39,22 +39,23 @@ class VToolEndLine : public VToolLinePoint
Q_OBJECT Q_OBJECT
public: 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 QString &formulaLength, const QString &formulaAngle, const quint32 &basePointId,
const Source &typeCreation, QGraphicsItem * parent = nullptr); const Source &typeCreation, QGraphicsItem * parent = nullptr);
virtual ~VToolEndLine(); virtual ~VToolEndLine();
virtual void setDialog(); virtual void setDialog();
static VToolEndLine *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolEndLine *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolEndLine *Create(const quint32 _id, const QString &pointName, const QString &typeLine, static VToolEndLine *Create(const quint32 _id, const QString &pointName, const QString &typeLine,
QString &formulaLength, QString &formulaAngle, const quint32 &basePointId, const QString &lineColor, QString &formulaLength, QString &formulaAngle,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, const quint32 &basePointId, const qreal &mx, const qreal &my,
VContainer *data, const Document &parse, const Source &typeCreation); VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation);
static const QString ToolType; static const QString ToolType;
virtual int type() const {return Type;} virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::EndLine)}; enum { Type = UserType + static_cast<int>(Tool::EndLine)};
VFormula getFormulaAngle() const; VFormula GetFormulaAngle() const;
void setFormulaAngle(const VFormula &value); void SetFormulaAngle(const VFormula &value);
virtual void ShowVisualization(bool show); virtual void ShowVisualization(bool show);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
@ -63,6 +64,7 @@ protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private: private:
QString formulaAngle; QString formulaAngle;
}; };

View File

@ -47,9 +47,10 @@ const QString VToolHeight::ToolType = QStringLiteral("height");
* @param parent parent object. * @param parent parent object.
*/ */
VToolHeight::VToolHeight(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, VToolHeight::VToolHeight(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const quint32 &basePointId, const quint32 &p1LineId, const quint32 &p2LineId, const QString &lineColor, const quint32 &basePointId, const quint32 &p1LineId,
const Source &typeCreation, QGraphicsItem * parent) const quint32 &p2LineId, const Source &typeCreation, QGraphicsItem * parent)
:VToolLinePoint(doc, data, id, typeLine, QString(), basePointId, 0, parent), p1LineId(p1LineId), p2LineId(p2LineId) :VToolLinePoint(doc, data, id, typeLine, lineColor, QString(), basePointId, 0, parent), p1LineId(p1LineId),
p2LineId(p2LineId)
{ {
ignoreFullUpdate = true; ignoreFullUpdate = true;
if (typeCreation == Source::FromGui) if (typeCreation == Source::FromGui)
@ -72,11 +73,12 @@ void VToolHeight::setDialog()
DialogHeight *dialogTool = qobject_cast<DialogHeight*>(dialog); DialogHeight *dialogTool = qobject_cast<DialogHeight*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id); const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
dialogTool->setTypeLine(typeLine); dialogTool->SetTypeLine(typeLine);
dialogTool->setBasePointId(basePointId); dialogTool->SetLineColor(lineColor);
dialogTool->setP1LineId(p1LineId); dialogTool->SetBasePointId(basePointId);
dialogTool->setP2LineId(p2LineId); dialogTool->SetP1LineId(p1LineId);
dialogTool->setPointName(p->name()); dialogTool->SetP2LineId(p2LineId);
dialogTool->SetPointName(p->name());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -95,13 +97,14 @@ VToolHeight* VToolHeight::Create(DialogTool *dialog, VMainGraphicsScene *scene,
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
disconnect(doc, &VPattern::FullUpdateFromFile, dialogTool, &DialogHeight::UpdateList); disconnect(doc, &VPattern::FullUpdateFromFile, dialogTool, &DialogHeight::UpdateList);
const QString pointName = dialogTool->getPointName(); const QString pointName = dialogTool->getPointName();
const QString typeLine = dialogTool->getTypeLine(); const QString typeLine = dialogTool->GetTypeLine();
const quint32 basePointId = dialogTool->getBasePointId(); const QString lineColor = dialogTool->GetLineColor();
const quint32 p1LineId = dialogTool->getP1LineId(); const quint32 basePointId = dialogTool->GetBasePointId();
const quint32 p2LineId = dialogTool->getP2LineId(); const quint32 p1LineId = dialogTool->GetP1LineId();
const quint32 p2LineId = dialogTool->GetP2LineId();
VToolHeight *point = nullptr; 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); Document::FullParse, Source::FromGui);
if (point != nullptr) if (point != nullptr)
{ {
@ -129,9 +132,9 @@ VToolHeight* VToolHeight::Create(DialogTool *dialog, VMainGraphicsScene *scene,
* @return the created tool * @return the created tool
*/ */
VToolHeight* VToolHeight::Create(const quint32 _id, const QString &pointName, const QString &typeLine, VToolHeight* VToolHeight::Create(const quint32 _id, const QString &pointName, const QString &typeLine,
const quint32 &basePointId, const quint32 &p1LineId, const quint32 &p2LineId, const QString &lineColor, const quint32 &basePointId, const quint32 &p1LineId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, const quint32 &p2LineId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VContainer *data, const Document &parse, const Source &typeCreation) VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation)
{ {
const QSharedPointer<VPointF> basePoint = data->GeometricObject<VPointF>(basePointId); const QSharedPointer<VPointF> basePoint = data->GeometricObject<VPointF>(basePointId);
const QSharedPointer<VPointF> p1Line = data->GeometricObject<VPointF>(p1LineId); const QSharedPointer<VPointF> p1Line = data->GeometricObject<VPointF>(p1LineId);
@ -160,12 +163,12 @@ VToolHeight* VToolHeight::Create(const quint32 _id, const QString &pointName, co
VDrawTool::AddRecord(id, Tool::Height, doc); VDrawTool::AddRecord(id, Tool::Height, doc);
if (parse == Document::FullParse) 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); typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor); connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolHeight::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolHeight::Disable);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(basePointId); doc->IncrementReferens(basePointId);
doc->IncrementReferens(p1LineId); doc->IncrementReferens(p1LineId);
@ -193,14 +196,7 @@ QPointF VToolHeight::FindPoint(const QLineF &line, const QPointF &point)
*/ */
void VToolHeight::FullUpdateFromFile() void VToolHeight::FullUpdateFromFile()
{ {
QDomElement domElement = doc->elementById(QString().setNum(id)); ReadAttributes();
if (domElement.isElement())
{
typeLine = domElement.attribute(AttrTypeLine, "");
basePointId = domElement.attribute(AttrBasePoint, "").toUInt();
p1LineId = domElement.attribute(AttrP1Line, "").toUInt();
p2LineId = domElement.attribute(AttrP2Line, "").toUInt();
}
RefreshGeometry(); RefreshGeometry();
if (vis != nullptr) if (vis != nullptr)
@ -244,10 +240,11 @@ void VToolHeight::SaveDialog(QDomElement &domElement)
DialogHeight *dialogTool = qobject_cast<DialogHeight*>(dialog); DialogHeight *dialogTool = qobject_cast<DialogHeight*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine());
doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->getBasePointId())); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor());
doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->getP1LineId())); doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->GetBasePointId()));
doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->getP2LineId())); 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<VGObject> &obj)
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrTypeLine, typeLine); doc->SetAttribute(tag, AttrTypeLine, typeLine);
doc->SetAttribute(tag, AttrLineColor, lineColor);
doc->SetAttribute(tag, AttrBasePoint, basePointId); doc->SetAttribute(tag, AttrBasePoint, basePointId);
doc->SetAttribute(tag, AttrP1Line, p1LineId); doc->SetAttribute(tag, AttrP1Line, p1LineId);
doc->SetAttribute(tag, AttrP2Line, p2LineId); 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; return p2LineId;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolHeight::setP2LineId(const quint32 &value) void VToolHeight::SetP2LineId(const quint32 &value)
{ {
if (value != NULL_ID) if (value != NULL_ID)
{ {
@ -322,13 +330,13 @@ void VToolHeight::ShowVisualization(bool show)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
quint32 VToolHeight::getP1LineId() const quint32 VToolHeight::GetP1LineId() const
{ {
return p1LineId; return p1LineId;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolHeight::setP1LineId(const quint32 &value) void VToolHeight::SetP1LineId(const quint32 &value)
{ {
if (value != NULL_ID) if (value != NULL_ID)
{ {

View File

@ -39,25 +39,25 @@ class VToolHeight: public VToolLinePoint
Q_OBJECT Q_OBJECT
public: public:
VToolHeight(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const quint32 &basePointId, VToolHeight(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, const QString &lineColor,
const quint32 &p1LineId, const quint32 &p2LineId, const Source &typeCreation, const quint32 &basePointId, const quint32 &p1LineId, const quint32 &p2LineId,
QGraphicsItem * parent = nullptr); const Source &typeCreation, QGraphicsItem * parent = nullptr);
virtual void setDialog(); virtual void setDialog();
static VToolHeight *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolHeight *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolHeight *Create(const quint32 _id, const QString &pointName, const QString &typeLine, static VToolHeight *Create(const quint32 _id, const QString &pointName, const QString &typeLine,
const quint32 &basePointId, const quint32 &p1LineId, const quint32 &p2LineId, const QString &lineColor, const quint32 &basePointId, const quint32 &p1LineId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, const quint32 &p2LineId, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VContainer *data, const Document &parse, const Source &typeCreation); VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation);
static QPointF FindPoint(const QLineF &line, const QPointF &point); static QPointF FindPoint(const QLineF &line, const QPointF &point);
static const QString ToolType; static const QString ToolType;
virtual int type() const {return Type;} virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::Height)}; enum { Type = UserType + static_cast<int>(Tool::Height)};
quint32 getP1LineId() const; quint32 GetP1LineId() const;
void setP1LineId(const quint32 &value); void SetP1LineId(const quint32 &value);
quint32 getP2LineId() const; quint32 GetP2LineId() const;
void setP2LineId(const quint32 &value); void SetP2LineId(const quint32 &value);
virtual void ShowVisualization(bool show); virtual void ShowVisualization(bool show);
public slots: public slots:
@ -67,6 +67,7 @@ protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private: private:
/** @brief p1LineId id first point of line. */ /** @brief p1LineId id first point of line. */
quint32 p1LineId; quint32 p1LineId;

View File

@ -48,10 +48,12 @@ const QString VToolLine::TagName = QStringLiteral("line");
* @param parent parent object. * @param parent parent object.
*/ */
VToolLine::VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstPoint, quint32 secondPoint, 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) :VDrawTool(doc, data, id), QGraphicsLineItem(parent), firstPoint(firstPoint), secondPoint(secondPoint)
{ {
this->typeLine = typeLine; this->typeLine = typeLine;
this->lineColor = lineColor;
ignoreFullUpdate = true; ignoreFullUpdate = true;
//Line //Line
const QSharedPointer<VPointF> first = data->GeometricObject<VPointF>(firstPoint); const QSharedPointer<VPointF> first = data->GeometricObject<VPointF>(firstPoint);
@ -82,9 +84,10 @@ void VToolLine::setDialog()
SCASSERT(dialog != nullptr); SCASSERT(dialog != nullptr);
DialogLine *dialogTool = qobject_cast<DialogLine*>(dialog); DialogLine *dialogTool = qobject_cast<DialogLine*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
dialogTool->setFirstPoint(firstPoint); dialogTool->SetFirstPoint(firstPoint);
dialogTool->setSecondPoint(secondPoint); dialogTool->SetSecondPoint(secondPoint);
dialogTool->setTypeLine(typeLine); dialogTool->SetTypeLine(typeLine);
dialogTool->SetLineColor(lineColor);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -100,12 +103,14 @@ VToolLine *VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPat
SCASSERT(dialog != nullptr); SCASSERT(dialog != nullptr);
DialogLine *dialogTool = qobject_cast<DialogLine*>(dialog); DialogLine *dialogTool = qobject_cast<DialogLine*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
const quint32 firstPoint = dialogTool->getFirstPoint(); const quint32 firstPoint = dialogTool->GetFirstPoint();
const quint32 secondPoint = dialogTool->getSecondPoint(); const quint32 secondPoint = dialogTool->GetSecondPoint();
const QString typeLine = dialogTool->getTypeLine(); const QString typeLine = dialogTool->GetTypeLine();
const QString lineColor = dialogTool->GetLineColor();
VToolLine *line = nullptr; 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) if (line != nullptr)
{ {
line->dialog=dialogTool; line->dialog=dialogTool;
@ -127,8 +132,8 @@ VToolLine *VToolLine::Create(DialogTool *dialog, VMainGraphicsScene *scene, VPat
* @param typeCreation way we create this tool. * @param typeCreation way we create this tool.
*/ */
VToolLine * VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, const quint32 &secondPoint, VToolLine * VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, const quint32 &secondPoint,
const QString &typeLine, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const QString &typeLine, const QString &lineColor, VMainGraphicsScene *scene,
const Document &parse, const Source &typeCreation) VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation)
{ {
SCASSERT(scene != nullptr); SCASSERT(scene != nullptr);
SCASSERT(doc != nullptr); SCASSERT(doc != nullptr);
@ -151,7 +156,7 @@ VToolLine * VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, con
VDrawTool::AddRecord(id, Tool::Line, doc); VDrawTool::AddRecord(id, Tool::Line, doc);
if (parse == Document::FullParse) 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); scene->addItem(line);
connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, line, &VToolLine::SetFactor); connect(scene, &VMainGraphicsScene::NewFactor, line, &VToolLine::SetFactor);
@ -189,6 +194,7 @@ QString VToolLine::getTagName() const
*/ */
void VToolLine::FullUpdateFromFile() void VToolLine::FullUpdateFromFile()
{ {
ReadAttributes();
RefreshGeometry(); RefreshGeometry();
if (vis != nullptr) if (vis != nullptr)
@ -205,12 +211,11 @@ void VToolLine::FullUpdateFromFile()
/** /**
* @brief ShowTool highlight tool. * @brief ShowTool highlight tool.
* @param id object id in container * @param id object id in container
* @param color highlight color.
* @param enable enable or disable highlight. * @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) 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) void VToolLine::ChangedActivDraw(const QString &newName)
{ {
VDrawTool::ChangedActivDraw(newName); Disable(!(nameActivDraw == newName));
this->setEnabled(nameActivDraw == newName);
this->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine)));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -290,7 +295,8 @@ void VToolLine::RefreshDataInFile()
void VToolLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void VToolLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{ {
Q_UNUSED(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) void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{ {
Q_UNUSED(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); SCASSERT(dialog != nullptr);
DialogLine *dialogTool = qobject_cast<DialogLine*>(dialog); DialogLine *dialogTool = qobject_cast<DialogLine*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPoint())); doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->GetFirstPoint()));
doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPoint())); doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->GetSecondPoint()));
doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine());
doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -380,22 +391,32 @@ void VToolLine::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj)
doc->SetAttribute(tag, AttrFirstPoint, firstPoint); doc->SetAttribute(tag, AttrFirstPoint, firstPoint);
doc->SetAttribute(tag, AttrSecondPoint, secondPoint); doc->SetAttribute(tag, AttrSecondPoint, secondPoint);
doc->SetAttribute(tag, AttrTypeLine, typeLine); 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; return secondPoint;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolLine::setSecondPoint(const quint32 &value) void VToolLine::SetSecondPoint(const quint32 &value)
{ {
if (value != NULL_ID) if (value != NULL_ID)
{ {
secondPoint = value; secondPoint = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id); QSharedPointer<VGObject> obj;//We don't have object for line in data container. Just will send empty object.
SaveOption(obj); SaveOption(obj);
} }
} }
@ -431,11 +452,12 @@ void VToolLine::ShowVisualization(bool show)
{ {
delete vis; delete vis;
vis = nullptr; vis = nullptr;
hoverLeaveEvent(nullptr);
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolLine::setTypeLine(const QString &value) void VToolLine::SetTypeLine(const QString &value)
{ {
typeLine = 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<VGObject> obj;//We don't have object for line in data container. Just will send empty object.
SaveOption(obj);
}
//---------------------------------------------------------------------------------------------------------------------
quint32 VToolLine::GetFirstPoint() const
{ {
return firstPoint; return firstPoint;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolLine::setFirstPoint(const quint32 &value) void VToolLine::SetFirstPoint(const quint32 &value)
{ {
if (value != NULL_ID) if (value != NULL_ID)
{ {
firstPoint = value; firstPoint = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id); QSharedPointer<VGObject> obj;//We don't have object for line in data container. Just will send empty object.
SaveOption(obj); SaveOption(obj);
} }
} }
@ -467,15 +498,8 @@ void VToolLine::setFirstPoint(const quint32 &value)
*/ */
void VToolLine::RefreshGeometry() 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<VPointF> first = VAbstractTool::data.GeometricObject<VPointF>(firstPoint); const QSharedPointer<VPointF> first = VAbstractTool::data.GeometricObject<VPointF>(firstPoint);
const QSharedPointer<VPointF> second = VAbstractTool::data.GeometricObject<VPointF>(secondPoint); const QSharedPointer<VPointF> second = VAbstractTool::data.GeometricObject<VPointF>(secondPoint);
this->setLine(QLineF(first->toQPointF(), second->toQPointF())); 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)));
} }

View File

@ -40,29 +40,32 @@ class VToolLine: public VDrawTool, public QGraphicsLineItem
Q_OBJECT Q_OBJECT
public: public:
VToolLine(VPattern *doc, VContainer *data, quint32 id, quint32 firstPoint, quint32 secondPoint, 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(); virtual void setDialog();
static VToolLine *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data); static VToolLine *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, VContainer *data);
static VToolLine *Create(const quint32 &_id, const quint32 &firstPoint, const quint32 &secondPoint, static VToolLine *Create(const quint32 &_id, const quint32 &firstPoint, const quint32 &secondPoint,
const QString &typeLine, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const QString &typeLine, const QString &lineColor, VMainGraphicsScene *scene,
const Document &parse, const Source &typeCreation); VPattern *doc, VContainer *data, const Document &parse, const Source &typeCreation);
static const QString TagName; static const QString TagName;
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0); virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0);
virtual int type() const {return Type;} virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::Line)}; enum { Type = UserType + static_cast<int>(Tool::Line)};
virtual QString getTagName() const; virtual QString getTagName() const;
quint32 getFirstPoint() const; quint32 GetFirstPoint() const;
void setFirstPoint(const quint32 &value); void SetFirstPoint(const quint32 &value);
quint32 getSecondPoint() const; quint32 GetSecondPoint() const;
void setSecondPoint(const quint32 &value); void SetSecondPoint(const quint32 &value);
virtual void ShowVisualization(bool show); 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: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void ChangedActivDraw(const QString &newName); 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 SetFactor(qreal factor);
void Disable(bool disable); void Disable(bool disable);
protected: protected:
@ -76,6 +79,7 @@ protected:
virtual void keyReleaseEvent(QKeyEvent * event); virtual void keyReleaseEvent(QKeyEvent * event);
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private: private:
/** @brief firstPoint id first line point. */ /** @brief firstPoint id first line point. */
quint32 firstPoint; quint32 firstPoint;

View File

@ -74,11 +74,11 @@ void VToolLineIntersect::setDialog()
DialogLineIntersect *dialogTool = qobject_cast<DialogLineIntersect*>(dialog); DialogLineIntersect *dialogTool = qobject_cast<DialogLineIntersect*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id); const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
dialogTool->setP1Line1(p1Line1); dialogTool->SetP1Line1(p1Line1);
dialogTool->setP2Line1(p2Line1); dialogTool->SetP2Line1(p2Line1);
dialogTool->setP1Line2(p1Line2); dialogTool->SetP1Line2(p1Line2);
dialogTool->setP2Line2(p2Line2); dialogTool->SetP2Line2(p2Line2);
dialogTool->setPointName(p->name()); dialogTool->SetPointName(p->name());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -96,10 +96,10 @@ VToolLineIntersect* VToolLineIntersect::Create(DialogTool *dialog, VMainGraphics
SCASSERT(dialog != nullptr); SCASSERT(dialog != nullptr);
DialogLineIntersect *dialogTool = qobject_cast<DialogLineIntersect*>(dialog); DialogLineIntersect *dialogTool = qobject_cast<DialogLineIntersect*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
const quint32 p1Line1Id = dialogTool->getP1Line1(); const quint32 p1Line1Id = dialogTool->GetP1Line1();
const quint32 p2Line1Id = dialogTool->getP2Line1(); const quint32 p2Line1Id = dialogTool->GetP2Line1();
const quint32 p1Line2Id = dialogTool->getP1Line2(); const quint32 p1Line2Id = dialogTool->GetP1Line2();
const quint32 p2Line2Id = dialogTool->getP2Line2(); const quint32 p2Line2Id = dialogTool->GetP2Line2();
const QString pointName = dialogTool->getPointName(); const QString pointName = dialogTool->getPointName();
VToolLineIntersect* point = nullptr; VToolLineIntersect* point = nullptr;
point = Create(0, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, pointName, 5, 10, scene, doc, data, 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); scene->addItem(point);
connect(point, &VToolLineIntersect::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolLineIntersect::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolLineIntersect::SetFactor); 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->AddTool(id, point);
doc->IncrementReferens(p1Line1Id); doc->IncrementReferens(p1Line1Id);
doc->IncrementReferens(p2Line1Id); doc->IncrementReferens(p2Line1Id);
@ -193,14 +193,7 @@ VToolLineIntersect* VToolLineIntersect::Create(const quint32 _id, const quint32
*/ */
void VToolLineIntersect::FullUpdateFromFile() void VToolLineIntersect::FullUpdateFromFile()
{ {
QDomElement domElement = doc->elementById(QString().setNum(id)); ReadAttributes();
if (domElement.isElement())
{
p1Line1 = domElement.attribute(AttrP1Line1, "").toUInt();
p2Line1 = domElement.attribute(AttrP2Line1, "").toUInt();
p1Line2 = domElement.attribute(AttrP1Line2, "").toUInt();
p2Line2 = domElement.attribute(AttrP2Line2, "").toUInt();
}
RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id)); RefreshPointGeometry(*VAbstractTool::data.GeometricObject<VPointF>(id));
if (vis != nullptr) if (vis != nullptr)
@ -267,10 +260,10 @@ void VToolLineIntersect::SaveDialog(QDomElement &domElement)
DialogLineIntersect *dialogTool = qobject_cast<DialogLineIntersect*>(dialog); DialogLineIntersect *dialogTool = qobject_cast<DialogLineIntersect*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
doc->SetAttribute(domElement, AttrP1Line1, QString().setNum(dialogTool->getP1Line1())); doc->SetAttribute(domElement, AttrP1Line1, QString().setNum(dialogTool->GetP1Line1()));
doc->SetAttribute(domElement, AttrP2Line1, QString().setNum(dialogTool->getP2Line1())); doc->SetAttribute(domElement, AttrP2Line1, QString().setNum(dialogTool->GetP2Line1()));
doc->SetAttribute(domElement, AttrP1Line2, QString().setNum(dialogTool->getP1Line2())); doc->SetAttribute(domElement, AttrP1Line2, QString().setNum(dialogTool->GetP1Line2()));
doc->SetAttribute(domElement, AttrP2Line2, QString().setNum(dialogTool->getP2Line2())); doc->SetAttribute(domElement, AttrP2Line2, QString().setNum(dialogTool->GetP2Line2()));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -292,13 +285,22 @@ void VToolLineIntersect::SaveOptions(QDomElement &tag, QSharedPointer<VGObject>
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
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; return p2Line2;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersect::setP2Line2(const quint32 &value) void VToolLineIntersect::SetP2Line2(const quint32 &value)
{ {
if (value != NULL_ID) if (value != NULL_ID)
{ {
@ -345,13 +347,13 @@ void VToolLineIntersect::ShowVisualization(bool show)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
quint32 VToolLineIntersect::getP1Line2() const quint32 VToolLineIntersect::GetP1Line2() const
{ {
return p1Line2; return p1Line2;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersect::setP1Line2(const quint32 &value) void VToolLineIntersect::SetP1Line2(const quint32 &value)
{ {
if (value != NULL_ID) if (value != NULL_ID)
{ {
@ -363,13 +365,13 @@ void VToolLineIntersect::setP1Line2(const quint32 &value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
quint32 VToolLineIntersect::getP2Line1() const quint32 VToolLineIntersect::GetP2Line1() const
{ {
return p2Line1; return p2Line1;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersect::setP2Line1(const quint32 &value) void VToolLineIntersect::SetP2Line1(const quint32 &value)
{ {
if (value != NULL_ID) if (value != NULL_ID)
{ {
@ -381,13 +383,13 @@ void VToolLineIntersect::setP2Line1(const quint32 &value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
quint32 VToolLineIntersect::getP1Line1() const quint32 VToolLineIntersect::GetP1Line1() const
{ {
return p1Line1; return p1Line1;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersect::setP1Line1(const quint32 &value) void VToolLineIntersect::SetP1Line1(const quint32 &value)
{ {
if (value != NULL_ID) if (value != NULL_ID)
{ {

View File

@ -51,17 +51,17 @@ public:
virtual int type() const {return Type;} virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::LineIntersect)}; enum { Type = UserType + static_cast<int>(Tool::LineIntersect)};
quint32 getP1Line1() const; quint32 GetP1Line1() const;
void setP1Line1(const quint32 &value); void SetP1Line1(const quint32 &value);
quint32 getP2Line1() const; quint32 GetP2Line1() const;
void setP2Line1(const quint32 &value); void SetP2Line1(const quint32 &value);
quint32 getP1Line2() const; quint32 GetP1Line2() const;
void setP1Line2(const quint32 &value); void SetP1Line2(const quint32 &value);
quint32 getP2Line2() const; quint32 GetP2Line2() const;
void setP2Line2(const quint32 &value); void SetP2Line2(const quint32 &value);
virtual void ShowVisualization(bool show); virtual void ShowVisualization(bool show);
public slots: public slots:
@ -73,6 +73,7 @@ protected:
virtual void RemoveReferens(); virtual void RemoveReferens();
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private: private:
/** @brief p1Line1 id first point first line. */ /** @brief p1Line1 id first point first line. */
quint32 p1Line1; quint32 p1Line1;

View File

@ -38,11 +38,11 @@ const QString VToolLineIntersectAxis::ToolType = QStringLiteral("lineIntersectAx
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VToolLineIntersectAxis::VToolLineIntersectAxis(VPattern *doc, VContainer *data, const quint32 &id, VToolLineIntersectAxis::VToolLineIntersectAxis(VPattern *doc, VContainer *data, const quint32 &id,
const QString &typeLine, const QString &formulaAngle, const QString &typeLine, const QString &lineColor,
const quint32 &basePointId, const quint32 &firstPointId, const QString &formulaAngle, const quint32 &basePointId,
const quint32 &secondPointId, const Source &typeCreation, const quint32 &firstPointId, const quint32 &secondPointId,
QGraphicsItem *parent) const Source &typeCreation, QGraphicsItem *parent)
:VToolLinePoint(doc, data, id, typeLine, QString(), basePointId, 0, parent), formulaAngle(formulaAngle), :VToolLinePoint(doc, data, id, typeLine, lineColor, QString(), basePointId, 0, parent), formulaAngle(formulaAngle),
firstPointId(firstPointId), secondPointId(secondPointId) firstPointId(firstPointId), secondPointId(secondPointId)
{ {
if (typeCreation == Source::FromGui) if (typeCreation == Source::FromGui)
@ -67,12 +67,13 @@ void VToolLineIntersectAxis::setDialog()
DialogLineIntersectAxis *dialogTool = qobject_cast<DialogLineIntersectAxis*>(dialog); DialogLineIntersectAxis *dialogTool = qobject_cast<DialogLineIntersectAxis*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id); const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
dialogTool->setTypeLine(typeLine); dialogTool->SetTypeLine(typeLine);
dialogTool->setAngle(formulaAngle); dialogTool->SetLineColor(lineColor);
dialogTool->setBasePointId(basePointId); dialogTool->SetAngle(formulaAngle);
dialogTool->setFirstPointId(firstPointId); dialogTool->SetBasePointId(basePointId);
dialogTool->setSecondPointId(secondPointId); dialogTool->SetFirstPointId(firstPointId);
dialogTool->setPointName(p->name()); dialogTool->SetSecondPointId(secondPointId);
dialogTool->SetPointName(p->name());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -83,15 +84,16 @@ VToolLineIntersectAxis *VToolLineIntersectAxis::Create(DialogTool *dialog, VMain
DialogLineIntersectAxis *dialogTool = qobject_cast<DialogLineIntersectAxis*>(dialog); DialogLineIntersectAxis *dialogTool = qobject_cast<DialogLineIntersectAxis*>(dialog);
SCASSERT(dialogTool); SCASSERT(dialogTool);
const QString pointName = dialogTool->getPointName(); const QString pointName = dialogTool->getPointName();
const QString typeLine = dialogTool->getTypeLine(); const QString typeLine = dialogTool->GetTypeLine();
QString formulaAngle = dialogTool->getAngle(); const QString lineColor = dialogTool->GetLineColor();
const quint32 basePointId = dialogTool->getBasePointId(); QString formulaAngle = dialogTool->GetAngle();
const quint32 firstPointId = dialogTool->getFirstPointId(); const quint32 basePointId = dialogTool->GetBasePointId();
const quint32 secondPointId = dialogTool->getSecondPointId(); const quint32 firstPointId = dialogTool->GetFirstPointId();
const quint32 secondPointId = dialogTool->GetSecondPointId();
VToolLineIntersectAxis *point = nullptr; VToolLineIntersectAxis *point = nullptr;
point=Create(0, pointName, typeLine, formulaAngle, basePointId, firstPointId, secondPointId, 5, 10, scene, doc, point=Create(0, pointName, typeLine, lineColor, formulaAngle, basePointId, firstPointId, secondPointId, 5, 10,
data, Document::FullParse, Source::FromGui); scene, doc, data, Document::FullParse, Source::FromGui);
if (point != nullptr) if (point != nullptr)
{ {
point->dialog=dialogTool; point->dialog=dialogTool;
@ -101,11 +103,12 @@ VToolLineIntersectAxis *VToolLineIntersectAxis::Create(DialogTool *dialog, VMain
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VToolLineIntersectAxis *VToolLineIntersectAxis::Create(const quint32 _id, const QString &pointName, VToolLineIntersectAxis *VToolLineIntersectAxis::Create(const quint32 _id, const QString &pointName,
const QString &typeLine, QString &formulaAngle, const QString &typeLine, const QString &lineColor,
const quint32 &basePointId, const quint32 &firstPointId, QString &formulaAngle, const quint32 &basePointId,
const quint32 &secondPointId, const qreal &mx, const qreal &my, const quint32 &firstPointId, const quint32 &secondPointId,
VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
const Document &parse, const Source &typeCreation) VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation)
{ {
const QSharedPointer<VPointF> basePoint = data->GeometricObject<VPointF>(basePointId); const QSharedPointer<VPointF> basePoint = data->GeometricObject<VPointF>(basePointId);
QLineF axis = QLineF(basePoint->toQPointF(), QPointF(basePoint->x()+100, basePoint->y())); 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); VDrawTool::AddRecord(id, Tool::LineIntersectAxis, doc);
if (parse == Document::FullParse) 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, basePointId, firstPointId, secondPointId,
typeCreation); typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor); connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolLineIntersectAxis::SetFactor);
connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPoint::Disable); connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolLineIntersectAxis::Disable);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(basePointId); doc->IncrementReferens(basePointId);
doc->IncrementReferens(firstPointId); 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()); VFormula fAngle(formulaAngle, getData());
fAngle.setCheckZero(false); 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) if (value.error() == false)
{ {
formulaAngle = value.getFormula(FormulaType::FromUser); formulaAngle = value.GetFormula(FormulaType::FromUser);
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id); QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj); SaveOption(obj);
@ -192,13 +195,13 @@ void VToolLineIntersectAxis::setFormulaAngle(const VFormula &value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
quint32 VToolLineIntersectAxis::getFirstPointId() const quint32 VToolLineIntersectAxis::GetFirstPointId() const
{ {
return firstPointId; return firstPointId;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersectAxis::setFirstPointId(const quint32 &value) void VToolLineIntersectAxis::SetFirstPointId(const quint32 &value)
{ {
if (value != NULL_ID) if (value != NULL_ID)
{ {
@ -210,13 +213,13 @@ void VToolLineIntersectAxis::setFirstPointId(const quint32 &value)
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
quint32 VToolLineIntersectAxis::getSecondPointId() const quint32 VToolLineIntersectAxis::GetSecondPointId() const
{ {
return secondPointId; return secondPointId;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersectAxis::setSecondPointId(const quint32 &value) void VToolLineIntersectAxis::SetSecondPointId(const quint32 &value)
{ {
if (value != NULL_ID) if (value != NULL_ID)
{ {
@ -242,7 +245,7 @@ void VToolLineIntersectAxis::ShowVisualization(bool show)
visual->setPoint1Id(firstPointId); visual->setPoint1Id(firstPointId);
visual->setPoint2Id(secondPointId); visual->setPoint2Id(secondPointId);
visual->setAxisPointId(basePointId); visual->setAxisPointId(basePointId);
visual->setAngle(qApp->FormulaToUser(formulaAngle)); visual->SetAngle(qApp->FormulaToUser(formulaAngle));
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry(); visual->RefreshGeometry();
vis = visual; vis = visual;
@ -266,15 +269,7 @@ void VToolLineIntersectAxis::ShowVisualization(bool show)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolLineIntersectAxis::FullUpdateFromFile() void VToolLineIntersectAxis::FullUpdateFromFile()
{ {
QDomElement domElement = doc->elementById(QString().setNum(id)); ReadAttributes();
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, "");
}
RefreshGeometry(); RefreshGeometry();
if (vis != nullptr) if (vis != nullptr)
@ -283,7 +278,7 @@ void VToolLineIntersectAxis::FullUpdateFromFile()
visual->setPoint1Id(firstPointId); visual->setPoint1Id(firstPointId);
visual->setPoint2Id(secondPointId); visual->setPoint2Id(secondPointId);
visual->setAxisPointId(basePointId); visual->setAxisPointId(basePointId);
visual->setAngle(qApp->FormulaToUser(formulaAngle)); visual->SetAngle(qApp->FormulaToUser(formulaAngle));
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry(); visual->RefreshGeometry();
} }
@ -308,11 +303,12 @@ void VToolLineIntersectAxis::SaveDialog(QDomElement &domElement)
DialogLineIntersectAxis *dialogTool = qobject_cast<DialogLineIntersectAxis*>(dialog); DialogLineIntersectAxis *dialogTool = qobject_cast<DialogLineIntersectAxis*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine());
doc->SetAttribute(domElement, AttrAngle, dialogTool->getAngle()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor());
doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->getBasePointId())); doc->SetAttribute(domElement, AttrAngle, dialogTool->GetAngle());
doc->SetAttribute(domElement, AttrP1Line, QString().setNum(dialogTool->getFirstPointId())); doc->SetAttribute(domElement, AttrBasePoint, QString().setNum(dialogTool->GetBasePointId()));
doc->SetAttribute(domElement, AttrP2Line, QString().setNum(dialogTool->getSecondPointId())); 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, QSharedPointer<VGObje
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrTypeLine, typeLine); doc->SetAttribute(tag, AttrTypeLine, typeLine);
doc->SetAttribute(tag, AttrLineColor, lineColor);
doc->SetAttribute(tag, AttrAngle, formulaAngle); doc->SetAttribute(tag, AttrAngle, formulaAngle);
doc->SetAttribute(tag, AttrBasePoint, basePointId); doc->SetAttribute(tag, AttrBasePoint, basePointId);
doc->SetAttribute(tag, AttrP1Line, firstPointId); doc->SetAttribute(tag, AttrP1Line, firstPointId);
doc->SetAttribute(tag, AttrP2Line, secondPointId); 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, "");
}

View File

@ -36,15 +36,16 @@ class VToolLineIntersectAxis : public VToolLinePoint
Q_OBJECT Q_OBJECT
public: public:
VToolLineIntersectAxis(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, VToolLineIntersectAxis(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const QString &formulaAngle, const quint32 &basePointId, const quint32 &firstPointId, const QString &lineColor, const QString &formulaAngle, const quint32 &basePointId,
const quint32 &secondPointId, const Source &typeCreation, QGraphicsItem * parent = nullptr); const quint32 &firstPointId, const quint32 &secondPointId, const Source &typeCreation,
QGraphicsItem * parent = nullptr);
virtual ~VToolLineIntersectAxis(); virtual ~VToolLineIntersectAxis();
virtual void setDialog(); virtual void setDialog();
static VToolLineIntersectAxis *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc, static VToolLineIntersectAxis *Create(DialogTool *dialog, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data); VContainer *data);
static VToolLineIntersectAxis *Create(const quint32 _id, const QString &pointName, const QString &typeLine, 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 quint32 &firstPointId, const quint32 &secondPointId,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VPattern *doc,
VContainer *data, const Document &parse, const Source &typeCreation); VContainer *data, const Document &parse, const Source &typeCreation);
@ -55,14 +56,14 @@ public:
virtual int type() const {return Type;} virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::LineIntersectAxis)}; enum { Type = UserType + static_cast<int>(Tool::LineIntersectAxis)};
VFormula getFormulaAngle() const; VFormula GetFormulaAngle() const;
void setFormulaAngle(const VFormula &value); void SetFormulaAngle(const VFormula &value);
quint32 getFirstPointId() const; quint32 GetFirstPointId() const;
void setFirstPointId(const quint32 &value); void SetFirstPointId(const quint32 &value);
quint32 getSecondPointId() const; quint32 GetSecondPointId() const;
void setSecondPointId(const quint32 &value); void SetSecondPointId(const quint32 &value);
virtual void ShowVisualization(bool show); virtual void ShowVisualization(bool show);
public slots: public slots:
@ -72,6 +73,7 @@ protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void SaveDialog(QDomElement &domElement); virtual void SaveDialog(QDomElement &domElement);
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj); virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj);
virtual void ReadToolAttributes(const QDomElement &domElement);
private: private:
Q_DISABLE_COPY(VToolLineIntersectAxis) Q_DISABLE_COPY(VToolLineIntersectAxis)
QString formulaAngle; QString formulaAngle;

View File

@ -36,18 +36,20 @@
* @param data container with variables. * @param data container with variables.
* @param id object id in container. * @param id object id in container.
* @param typeLine line type. * @param typeLine line type.
* @param lineColor line color.
* @param formula string with length formula. * @param formula string with length formula.
* @param basePointId id base line point. * @param basePointId id base line point.
* @param angle line angle. * @param angle line angle.
* @param parent parent object. * @param parent parent object.
*/ */
VToolLinePoint::VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &id, VToolLinePoint::VToolLinePoint(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const QString &typeLine, const QString &formula, const quint32 &basePointId, const QString &lineColor, const QString &formula, const quint32 &basePointId,
const qreal &angle, QGraphicsItem *parent) 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) mainLine(nullptr)
{ {
this->typeLine = typeLine; this->typeLine = typeLine;
this->lineColor = lineColor;
Q_ASSERT_X(basePointId > 0, Q_FUNC_INFO, "basePointId <= 0"); Q_ASSERT_X(basePointId > 0, Q_FUNC_INFO, "basePointId <= 0");
QPointF point1 = data->GeometricObject<VPointF>(basePointId)->toQPointF(); QPointF point1 = data->GeometricObject<VPointF>(basePointId)->toQPointF();
QPointF point2 = data->GeometricObject<VPointF>(id)->toQPointF(); QPointF point2 = data->GeometricObject<VPointF>(id)->toQPointF();
@ -69,9 +71,7 @@ VToolLinePoint::~VToolLinePoint()
*/ */
void VToolLinePoint::ChangedActivDraw(const QString &newName) void VToolLinePoint::ChangedActivDraw(const QString &newName)
{ {
VToolPoint::ChangedActivDraw(newName); Disable(!(nameActivDraw == newName));
this->setEnabled(nameActivDraw == newName);
mainLine->setPen(QPen(currentColor, qApp->toPixel(qApp->widthHairLine())/factor, LineStyleToPenStyle(typeLine)));
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -80,7 +80,8 @@ void VToolLinePoint::ChangedActivDraw(const QString &newName)
*/ */
void VToolLinePoint::RefreshGeometry() 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<VPointF>(id)); VToolPoint::RefreshPointGeometry(*VDrawTool::data.GeometricObject<VPointF>(id));
QPointF point = VDrawTool::data.GeometricObject<VPointF>(id)->toQPointF(); QPointF point = VDrawTool::data.GeometricObject<VPointF>(id)->toQPointF();
QPointF basePoint = VDrawTool::data.GeometricObject<VPointF>(basePointId)->toQPointF(); QPointF basePoint = VDrawTool::data.GeometricObject<VPointF>(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; return angle;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolLinePoint::setAngle(const qreal &value) void VToolLinePoint::SetAngle(const qreal &value)
{ {
angle = value; angle = value;
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id); QSharedPointer<VGObject> 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; return basePointId;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolLinePoint::setBasePointId(const quint32 &value) void VToolLinePoint::SetBasePointId(const quint32 &value)
{ {
if (value != NULL_ID) 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()); VFormula fLength(formulaLength, this->getData());
fLength.setCheckZero(true); 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) if (value.error() == false)
{ {
formulaLength = value.getFormula(FormulaType::FromUser); formulaLength = value.GetFormula(FormulaType::FromUser);
QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id); QSharedPointer<VGObject> obj = VAbstractTool::data.GetGObject(id);
SaveOption(obj); SaveOption(obj);

View File

@ -39,23 +39,24 @@ class VToolLinePoint : public VToolPoint
{ {
Q_OBJECT Q_OBJECT
public: 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); const quint32 &basePointId, const qreal &angle, QGraphicsItem * parent = nullptr);
virtual ~VToolLinePoint(); virtual ~VToolLinePoint();
virtual int type() const {return Type;} virtual int type() const {return Type;}
enum { Type = UserType + static_cast<int>(Tool::LinePoint)}; enum { Type = UserType + static_cast<int>(Tool::LinePoint)};
VFormula getFormulaLength() const; VFormula GetFormulaLength() const;
void setFormulaLength(const VFormula &value); void SetFormulaLength(const VFormula &value);
quint32 getBasePointId() const; quint32 GetBasePointId() const;
void setBasePointId(const quint32 &value); void SetBasePointId(const quint32 &value);
qreal getAngle() const; qreal GetAngle() const;
void setAngle(const qreal &value); void SetAngle(const qreal &value);
public slots: public slots:
virtual void ChangedActivDraw(const QString &newName); virtual void ChangedActivDraw(const QString &newName);
virtual void SetFactor(qreal factor); virtual void SetFactor(qreal factor);
void Disable(bool disable);
protected: protected:
/** @brief formula string with length formula. */ /** @brief formula string with length formula. */
QString formulaLength; QString formulaLength;

View File

@ -49,9 +49,10 @@ const QString VToolNormal::ToolType = QStringLiteral("normal");
* @param parent parent object. * @param parent parent object.
*/ */
VToolNormal::VToolNormal(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine, VToolNormal::VToolNormal(VPattern *doc, VContainer *data, const quint32 &id, const QString &typeLine,
const QString &formula, const qreal &angle, const quint32 &firstPointId, const QString &lineColor, const QString &formula, const qreal &angle,
const quint32 &secondPointId, const Source &typeCreation, QGraphicsItem *parent) const quint32 &firstPointId, const quint32 &secondPointId, const Source &typeCreation,
:VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, angle, parent), QGraphicsItem *parent)
:VToolLinePoint(doc, data, id, typeLine, lineColor, formula, firstPointId, angle, parent),
secondPointId(secondPointId) secondPointId(secondPointId)
{ {
@ -75,12 +76,12 @@ void VToolNormal::setDialog()
DialogNormal *dialogTool = qobject_cast<DialogNormal*>(dialog); DialogNormal *dialogTool = qobject_cast<DialogNormal*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id); const QSharedPointer<VPointF> p = VAbstractTool::data.GeometricObject<VPointF>(id);
dialogTool->setTypeLine(typeLine); dialogTool->SetTypeLine(typeLine);
dialogTool->setFormula(formulaLength); dialogTool->SetFormula(formulaLength);
dialogTool->setAngle(angle); dialogTool->SetAngle(angle);
dialogTool->setFirstPointId(basePointId); dialogTool->SetFirstPointId(basePointId);
dialogTool->setSecondPointId(secondPointId); dialogTool->SetSecondPointId(secondPointId);
dialogTool->setPointName(p->name()); dialogTool->SetPointName(p->name());
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -96,15 +97,16 @@ VToolNormal* VToolNormal::Create(DialogTool *dialog, VMainGraphicsScene *scene,
SCASSERT(dialog != nullptr); SCASSERT(dialog != nullptr);
DialogNormal *dialogTool = qobject_cast<DialogNormal*>(dialog); DialogNormal *dialogTool = qobject_cast<DialogNormal*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
QString formula = dialogTool->getFormula(); QString formula = dialogTool->GetFormula();
const quint32 firstPointId = dialogTool->getFirstPointId(); const quint32 firstPointId = dialogTool->GetFirstPointId();
const quint32 secondPointId = dialogTool->getSecondPointId(); const quint32 secondPointId = dialogTool->GetSecondPointId();
const QString typeLine = dialogTool->getTypeLine(); const QString typeLine = dialogTool->GetTypeLine();
const QString lineColor = dialogTool->GetLineColor();
const QString pointName = dialogTool->getPointName(); const QString pointName = dialogTool->getPointName();
const qreal angle = dialogTool->getAngle(); const qreal angle = dialogTool->GetAngle();
VToolNormal *point = nullptr; VToolNormal *point = nullptr;
point=Create(0, formula, firstPointId, secondPointId, typeLine, pointName, angle, 5, 10, scene, doc, data, point=Create(0, formula, firstPointId, secondPointId, typeLine, lineColor, pointName, angle, 5, 10, scene, doc,
Document::FullParse, Source::FromGui); data, Document::FullParse, Source::FromGui);
if (point != nullptr) if (point != nullptr)
{ {
point->dialog=dialogTool; point->dialog=dialogTool;
@ -131,9 +133,9 @@ VToolNormal* VToolNormal::Create(DialogTool *dialog, VMainGraphicsScene *scene,
* @param typeCreation way we create this tool. * @param typeCreation way we create this tool.
*/ */
VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quint32 &firstPointId, VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quint32 &firstPointId,
const quint32 &secondPointId, const QString &typeLine, const QString &pointName, const quint32 &secondPointId, const QString &typeLine, const QString &lineColor,
const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, const QString &pointName, const qreal angle, const qreal &mx, const qreal &my,
VPattern *doc, VContainer *data, const Document &parse, VMainGraphicsScene *scene, VPattern *doc, VContainer *data, const Document &parse,
const Source &typeCreation) const Source &typeCreation)
{ {
const QSharedPointer<VPointF> firstPoint = data->GeometricObject<VPointF>(firstPointId); const QSharedPointer<VPointF> firstPoint = data->GeometricObject<VPointF>(firstPointId);
@ -161,12 +163,12 @@ VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quin
VDrawTool::AddRecord(id, Tool::Normal, doc); VDrawTool::AddRecord(id, Tool::Normal, doc);
if (parse == Document::FullParse) if (parse == Document::FullParse)
{ {
VToolNormal *point = new VToolNormal(doc, data, id, typeLine, formula, angle, VToolNormal *point = new VToolNormal(doc, data, id, typeLine, lineColor, formula, angle, firstPointId,
firstPointId, secondPointId, typeCreation); secondPointId, typeCreation);
scene->addItem(point); scene->addItem(point);
connect(point, &VToolNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolNormal::SetFactor); 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->AddTool(id, point);
doc->IncrementReferens(firstPointId); doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId); doc->IncrementReferens(secondPointId);
@ -200,15 +202,7 @@ QPointF VToolNormal::FindPoint(const QPointF &firstPoint, const QPointF &secondP
*/ */
void VToolNormal::FullUpdateFromFile() void VToolNormal::FullUpdateFromFile()
{ {
QDomElement domElement = doc->elementById(QString().setNum(id)); ReadAttributes();
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();
}
RefreshGeometry(); RefreshGeometry();
if (vis != nullptr) if (vis != nullptr)
@ -217,7 +211,7 @@ void VToolNormal::FullUpdateFromFile()
visual->setPoint1Id(basePointId); visual->setPoint1Id(basePointId);
visual->setPoint2Id(secondPointId); visual->setPoint2Id(secondPointId);
visual->setLength(qApp->FormulaToUser(formulaLength)); visual->setLength(qApp->FormulaToUser(formulaLength));
visual->setAngle(angle); visual->SetAngle(angle);
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry(); visual->RefreshGeometry();
} }
@ -274,11 +268,12 @@ void VToolNormal::SaveDialog(QDomElement &domElement)
DialogNormal *dialogTool = qobject_cast<DialogNormal*>(dialog); DialogNormal *dialogTool = qobject_cast<DialogNormal*>(dialog);
SCASSERT(dialogTool != nullptr); SCASSERT(dialogTool != nullptr);
doc->SetAttribute(domElement, AttrName, dialogTool->getPointName()); doc->SetAttribute(domElement, AttrName, dialogTool->getPointName());
doc->SetAttribute(domElement, AttrTypeLine, dialogTool->getTypeLine()); doc->SetAttribute(domElement, AttrTypeLine, dialogTool->GetTypeLine());
doc->SetAttribute(domElement, AttrLength, dialogTool->getFormula()); doc->SetAttribute(domElement, AttrLineColor, dialogTool->GetLineColor());
doc->SetAttribute(domElement, AttrAngle, QString().setNum(dialogTool->getAngle())); doc->SetAttribute(domElement, AttrLength, dialogTool->GetFormula());
doc->SetAttribute(domElement, AttrFirstPoint, QString().setNum(dialogTool->getFirstPointId())); doc->SetAttribute(domElement, AttrAngle, QString().setNum(dialogTool->GetAngle()));
doc->SetAttribute(domElement, AttrSecondPoint, QString().setNum(dialogTool->getSecondPointId())); 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<VGObject> &obj)
doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my())); doc->SetAttribute(tag, AttrMy, qApp->fromPixel(point->my()));
doc->SetAttribute(tag, AttrTypeLine, typeLine); doc->SetAttribute(tag, AttrTypeLine, typeLine);
doc->SetAttribute(tag, AttrLineColor, lineColor);
doc->SetAttribute(tag, AttrLength, formulaLength); doc->SetAttribute(tag, AttrLength, formulaLength);
doc->SetAttribute(tag, AttrAngle, angle); doc->SetAttribute(tag, AttrAngle, angle);
doc->SetAttribute(tag, AttrFirstPoint, basePointId); doc->SetAttribute(tag, AttrFirstPoint, basePointId);
@ -301,13 +297,24 @@ void VToolNormal::SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &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; return secondPointId;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void VToolNormal::setSecondPointId(const quint32 &value) void VToolNormal::SetSecondPointId(const quint32 &value)
{ {
if (value != NULL_ID) if (value != NULL_ID)
{ {
@ -333,7 +340,7 @@ void VToolNormal::ShowVisualization(bool show)
visual->setPoint1Id(basePointId); visual->setPoint1Id(basePointId);
visual->setPoint2Id(secondPointId); visual->setPoint2Id(secondPointId);
visual->setLength(qApp->FormulaToUser(formulaLength)); visual->setLength(qApp->FormulaToUser(formulaLength));
visual->setAngle(angle); visual->SetAngle(angle);
visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine)); visual->setLineStyle(VAbstractTool::LineStyleToPenStyle(typeLine));
visual->RefreshGeometry(); visual->RefreshGeometry();
vis = visual; vis = visual;

Some files were not shown because too many files have changed in this diff Show More