Add tool ShoulderPoint

This commit is contained in:
dismine 2013-07-29 15:55:40 +03:00
parent 6879b732cb
commit 8942991d29
25 changed files with 951 additions and 87 deletions

View File

@ -34,7 +34,9 @@ SOURCES += main.cpp\
dialogs/dialogline.cpp \ dialogs/dialogline.cpp \
tools/vtoolalongline.cpp \ tools/vtoolalongline.cpp \
dialogs/dialogtool.cpp \ dialogs/dialogtool.cpp \
dialogs/dialogalongline.cpp dialogs/dialogalongline.cpp \
tools/vtoolshoulderpoint.cpp \
dialogs/dialogshoulderpoint.cpp
HEADERS += mainwindow.h \ HEADERS += mainwindow.h \
widgets/vmaingraphicsscene.h \ widgets/vmaingraphicsscene.h \
@ -59,14 +61,17 @@ HEADERS += mainwindow.h \
dialogs/dialogline.h \ dialogs/dialogline.h \
tools/vtoolalongline.h \ tools/vtoolalongline.h \
dialogs/dialogtool.h \ dialogs/dialogtool.h \
dialogs/dialogalongline.h dialogs/dialogalongline.h \
tools/vtoolshoulderpoint.h \
dialogs/dialogshoulderpoint.h
FORMS += mainwindow.ui \ FORMS += mainwindow.ui \
dialogs/dialogsinglepoint.ui \ dialogs/dialogsinglepoint.ui \
dialogs/dialogincrements.ui \ dialogs/dialogincrements.ui \
dialogs/dialogendline.ui \ dialogs/dialogendline.ui \
dialogs/dialogline.ui \ dialogs/dialogline.ui \
dialogs/dialogalongline.ui dialogs/dialogalongline.ui \
dialogs/dialogshoulderpoint.ui
RESOURCES += \ RESOURCES += \
icon.qrc \ icon.qrc \

View File

@ -4,5 +4,6 @@
<file>cursor/endline_cursor.png</file> <file>cursor/endline_cursor.png</file>
<file>cursor/line_cursor.png</file> <file>cursor/line_cursor.png</file>
<file>cursor/alongline_cursor.png</file> <file>cursor/alongline_cursor.png</file>
<file>cursor/shoulder_cursor.png</file>
</qresource> </qresource>
</RCC> </RCC>

BIN
cursor/shoulder_cursor.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -85,10 +85,7 @@ qint64 DialogAlongLine::getSecondPointId() const{
void DialogAlongLine::setSecondPointId(const qint64 &value){ void DialogAlongLine::setSecondPointId(const qint64 &value){
secondPointId = value; secondPointId = value;
qint32 index = ui->comboBoxSecondPoint->findData(secondPointId); ChangeCurrentData(ui->comboBoxSecondPoint, value);
if(index != -1){
ui->comboBoxSecondPoint->setCurrentIndex(index);
}
} }
qint64 DialogAlongLine::getFirstPointId() const{ qint64 DialogAlongLine::getFirstPointId() const{
@ -97,10 +94,7 @@ qint64 DialogAlongLine::getFirstPointId() const{
void DialogAlongLine::setFirstPointId(const qint64 &value){ void DialogAlongLine::setFirstPointId(const qint64 &value){
firstPointId = value; firstPointId = value;
qint32 index = ui->comboBoxFirstPoint->findData(firstPointId); ChangeCurrentData(ui->comboBoxFirstPoint, value);
if(index != -1){
ui->comboBoxFirstPoint->setCurrentIndex(index);
}
} }
QString DialogAlongLine::getFormula() const{ QString DialogAlongLine::getFormula() const{
@ -118,18 +112,7 @@ QString DialogAlongLine::getTypeLine() const{
void DialogAlongLine::setTypeLine(const QString &value){ void DialogAlongLine::setTypeLine(const QString &value){
typeLine = value; typeLine = value;
if(typeLine == "hair"){ SetupTypeLine(ui->comboBoxLineType, value);
qint32 index = ui->comboBoxLineType->findText("Лінія");
if(index != -1){
ui->comboBoxLineType->setCurrentIndex(index);
}
}
if(typeLine == "none"){
qint32 index = ui->comboBoxLineType->findText("Без лінії");
if(index != -1){
ui->comboBoxLineType->setCurrentIndex(index);
}
}
} }
QString DialogAlongLine::getPointName() const{ QString DialogAlongLine::getPointName() const{

View File

@ -62,10 +62,7 @@ DialogEndLine::DialogEndLine(const VContainer *data, QWidget *parent) :
void DialogEndLine::ChoosedPoint(qint64 id, Scene::Type type){ void DialogEndLine::ChoosedPoint(qint64 id, Scene::Type type){
if(type == Scene::Point){ if(type == Scene::Point){
VPointF point = data->GetPoint(id); VPointF point = data->GetPoint(id);
qint32 index = ui->comboBoxBasePoint->findText(point.name()); ChangeCurrentText(ui->comboBoxBasePoint, point.name());
if ( index != -1 ) { // -1 for not found
ui->comboBoxBasePoint->setCurrentIndex(index);
}
this->show(); this->show();
} }
} }
@ -85,18 +82,7 @@ QString DialogEndLine::getTypeLine() const{
void DialogEndLine::setTypeLine(const QString &value){ void DialogEndLine::setTypeLine(const QString &value){
typeLine = value; typeLine = value;
if(typeLine == "hair"){ SetupTypeLine(ui->comboBoxLineType, value);
qint32 index = ui->comboBoxLineType->findText("Лінія");
if(index != -1){
ui->comboBoxLineType->setCurrentIndex(index);
}
}
if(typeLine == "none"){
qint32 index = ui->comboBoxLineType->findText("Без лінії");
if(index != -1){
ui->comboBoxLineType->setCurrentIndex(index);
}
}
} }
QString DialogEndLine::getFormula() const{ QString DialogEndLine::getFormula() const{
@ -117,18 +103,13 @@ void DialogEndLine::setAngle(const qint32 &value){
ui->spinBoxAngle->setValue(angle); ui->spinBoxAngle->setValue(angle);
} }
qint64 DialogEndLine::getBasePointId() const qint64 DialogEndLine::getBasePointId() const{
{
return basePointId; return basePointId;
} }
void DialogEndLine::setBasePointId(const qint64 &value) void DialogEndLine::setBasePointId(const qint64 &value){
{
basePointId = value; basePointId = value;
qint32 index = ui->comboBoxBasePoint->findData(basePointId); ChangeCurrentData(ui->comboBoxBasePoint, value);
if(index != -1){
ui->comboBoxBasePoint->setCurrentIndex(index);
}
} }
void DialogEndLine::DialogAccepted(){ void DialogEndLine::DialogAccepted(){

View File

@ -28,7 +28,7 @@ signals:
void haveLiteChange(); void haveLiteChange();
private: private:
Ui::DialogIncrements *ui; Ui::DialogIncrements *ui;
VContainer *data; VContainer *data; // need because we must change data
VDomDocument *doc; VDomDocument *doc;
void InitialStandartTable(); void InitialStandartTable();
void InitialIncrementTable(); void InitialIncrementTable();

View File

@ -0,0 +1,146 @@
#include "dialogshoulderpoint.h"
#include "ui_dialogshoulderpoint.h"
DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, QWidget *parent) :
DialogTool(data, parent), ui(new Ui::DialogShoulderPoint)
{
ui->setupUi(this);
number = 0;
listWidget = ui->listWidget;
labelResultCalculation = ui->labelResultCalculation;
labelDescription = ui->labelDescription;
radioButtonSizeGrowth = ui->radioButtonSizeGrowth;
radioButtonStandartTable = ui->radioButtonStandartTable;
radioButtonIncrements = ui->radioButtonIncrements;
radioButtonLengthLine = ui->radioButtonLengthLine;
lineEditFormula = ui->lineEditFormula;
flagFormula = false;
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
connect(bOk, &QPushButton::clicked, this, &DialogShoulderPoint::DialogAccepted);
flagName = false;
CheckState();
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
connect(bCansel, &QPushButton::clicked, this, &DialogShoulderPoint::DialogRejected);
FillComboBoxTypeLine(ui->comboBoxLineType);
FillComboBoxPoints(ui->comboBoxP1Line);
FillComboBoxPoints(ui->comboBoxP2Line);
FillComboBoxPoints(ui->comboBoxPShoulder);
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogShoulderPoint::PutHere);
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogShoulderPoint::PutVal);
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogShoulderPoint::ValChenged);
ShowBase();
connect(ui->radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogShoulderPoint::SizeGrowth);
connect(ui->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogShoulderPoint::StandartTable);
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogShoulderPoint::Increments);
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogShoulderPoint::LengthLines);
connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogShoulderPoint::EvalFormula);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogShoulderPoint::NamePointChanged);
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogShoulderPoint::FormulaChanged);
}
DialogShoulderPoint::~DialogShoulderPoint()
{
delete ui;
}
void DialogShoulderPoint::ChoosedPoint(qint64 id, Scene::Type type){
if(type == Scene::Point){
VPointF point = data->GetPoint(id);
if(number == 0){
qint32 index = ui->comboBoxP1Line->findText(point.name());
if ( index != -1 ) { // -1 for not found
ui->comboBoxP1Line->setCurrentIndex(index);
number++;
return;
}
}
if(number == 1){
qint32 index = ui->comboBoxP2Line->findText(point.name());
if ( index != -1 ) { // -1 for not found
ui->comboBoxP2Line->setCurrentIndex(index);
number++;
return;
}
}
if(number == 2){
qint32 index = ui->comboBoxPShoulder->findText(point.name());
if ( index != -1 ) { // -1 for not found
ui->comboBoxPShoulder->setCurrentIndex(index);
number = 0;
}
if(!isInitialized){
this->show();
}
}
}
}
void DialogShoulderPoint::DialogAccepted(){
pointName = ui->lineEditNamePoint->text();
typeLine = GetTypeLine(ui->comboBoxLineType);
formula = ui->lineEditFormula->text();
qint32 index = ui->comboBoxP1Line->currentIndex();
p1Line = qvariant_cast<qint64>(ui->comboBoxP1Line->itemData(index));
index = ui->comboBoxP2Line->currentIndex();
p2Line = qvariant_cast<qint64>(ui->comboBoxP2Line->itemData(index));
index = ui->comboBoxPShoulder->currentIndex();
pShoulder = qvariant_cast<qint64>(ui->comboBoxPShoulder->itemData(index));
emit DialogClosed(QDialog::Accepted);
}
qint64 DialogShoulderPoint::getPShoulder() const{
return pShoulder;
}
void DialogShoulderPoint::setPShoulder(const qint64 &value){
pShoulder = value;
ChangeCurrentData(ui->comboBoxPShoulder, value);
}
qint64 DialogShoulderPoint::getP2Line() const{
return p2Line;
}
void DialogShoulderPoint::setP2Line(const qint64 &value){
p2Line = value;
ChangeCurrentData(ui->comboBoxP2Line, value);
}
qint64 DialogShoulderPoint::getP1Line() const{
return p1Line;
}
void DialogShoulderPoint::setP1Line(const qint64 &value)
{
p1Line = value;
ChangeCurrentData(ui->comboBoxP1Line, value);
}
QString DialogShoulderPoint::getFormula() const{
return formula;
}
void DialogShoulderPoint::setFormula(const QString &value){
formula = value;
ui->lineEditFormula->setText(formula);
}
QString DialogShoulderPoint::getTypeLine() const{
return typeLine;
}
void DialogShoulderPoint::setTypeLine(const QString &value){
typeLine = value;
SetupTypeLine(ui->comboBoxLineType, value);
}
QString DialogShoulderPoint::getPointName() const{
return pointName;
}
void DialogShoulderPoint::setPointName(const QString &value){
pointName = value;
ui->lineEditNamePoint->setText(pointName);
}

View File

@ -0,0 +1,45 @@
#ifndef DIALOGSHOULDERPOINT_H
#define DIALOGSHOULDERPOINT_H
#include "dialogtool.h"
#include "../options.h"
#include "../container/vcontainer.h"
#include "../container/calculator.h"
namespace Ui {
class DialogShoulderPoint;
}
class DialogShoulderPoint : public DialogTool
{
Q_OBJECT
public:
explicit DialogShoulderPoint(const VContainer *data, QWidget *parent = 0);
~DialogShoulderPoint();
QString getPointName() const;
void setPointName(const QString &value);
QString getTypeLine() const;
void setTypeLine(const QString &value);
QString getFormula() const;
void setFormula(const QString &value);
qint64 getP1Line() const;
void setP1Line(const qint64 &value);
qint64 getP2Line() const;
void setP2Line(const qint64 &value);
qint64 getPShoulder() const;
void setPShoulder(const qint64 &value);
public slots:
virtual void ChoosedPoint(qint64 id, Scene::Type type);
virtual void DialogAccepted();
private:
Ui::DialogShoulderPoint *ui;
qint32 number;
QString pointName;
QString typeLine;
QString formula;
qint64 p1Line;
qint64 p2Line;
qint64 pShoulder;
};
#endif // DIALOGSHOULDERPOINT_H

View File

@ -0,0 +1,368 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DialogShoulderPoint</class>
<widget class="QDialog" name="DialogShoulderPoint">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>473</width>
<height>485</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Відстань</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditFormula">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButtonEqual">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../icon.qrc">
<normaloff>:/icon/24x24/equal.png</normaloff>:/icon/24x24/equal.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="labelResultCalculation">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>87</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>_</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Ім'я нової точки</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditNamePoint"/>
</item>
<item>
<widget class="QToolButton" name="toolButtonPutHere">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../icon.qrc">
<normaloff>:/icon/24x24/putHere.png</normaloff>:/icon/24x24/putHere.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Перша точка</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxP1Line">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>145</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Друга точка</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxP2Line">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>143</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Точка плеча</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxPShoulder">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>145</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QLabel" name="label_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Тип лінії</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxLineType"/>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Вхідні данні</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonSizeGrowth">
<property name="text">
<string>Розмір і зріст</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonStandartTable">
<property name="text">
<string>Стандартна таблиця</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonIncrements">
<property name="text">
<string>Прибавки</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthLine">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Довжини ліній</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthArc">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Довжини дуг</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButtonLengthSpline">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Довжини сплайні</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="listWidget"/>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="labelDescription">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../icon.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>DialogShoulderPoint</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>DialogShoulderPoint</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -135,6 +135,35 @@ void DialogTool::ShowLengthLines(){
listWidget->setCurrentRow (0); listWidget->setCurrentRow (0);
} }
void DialogTool::SetupTypeLine(QComboBox *box, const QString &value){
if(value == "hair"){
qint32 index = box->findText("Лінія");
if(index != -1){
box->setCurrentIndex(index);
}
}
if(value == "none"){
qint32 index = box->findText("Без лінії");
if(index != -1){
box->setCurrentIndex(index);
}
}
}
void DialogTool::ChangeCurrentText(QComboBox *box, const QString &value){
qint32 index = box->findText(value);
if(index != -1){
box->setCurrentIndex(index);
}
}
void DialogTool::ChangeCurrentData(QComboBox *box, const qint64 &value){
qint32 index = box->findData(value);
if(index != -1){
box->setCurrentIndex(index);
}
}
void DialogTool::CheckState(){ void DialogTool::CheckState(){
Q_CHECK_PTR(bOk); Q_CHECK_PTR(bOk);
bOk->setEnabled(flagFormula & flagName); bOk->setEnabled(flagFormula & flagName);
@ -302,6 +331,11 @@ void DialogTool::ValChenged(int row){
.arg(itable.getDescription()); .arg(itable.getDescription());
labelDescription->setText(desc); labelDescription->setText(desc);
} }
if(radioButtonLengthLine->isChecked()){
QString desc = QString("%1(%2) - %3").arg(item->text()).arg(data->GetLine(item->text()))
.arg("Довжина лінії");
labelDescription->setText(desc);
}
} }
void DialogTool::UpdateList(){ void DialogTool::UpdateList(){

View File

@ -70,6 +70,9 @@ protected:
void ShowStandartTable(); void ShowStandartTable();
void ShowIncrementTable(); void ShowIncrementTable();
void ShowLengthLines(); void ShowLengthLines();
void SetupTypeLine(QComboBox *box, const QString &value);
void ChangeCurrentText(QComboBox *box, const QString &value);
void ChangeCurrentData(QComboBox *box, const qint64 &value);
}; };
#endif // DIALOGTOOL_H #endif // DIALOGTOOL_H

View File

@ -21,5 +21,6 @@
<file>icon/32x32/segment.png</file> <file>icon/32x32/segment.png</file>
<file>icon/32x32/line.png</file> <file>icon/32x32/line.png</file>
<file>icon/32x32/along_line.png</file> <file>icon/32x32/along_line.png</file>
<file>icon/32x32/shoulder.png</file>
</qresource> </qresource>
</RCC> </RCC>

BIN
icon/32x32/shoulder.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 683 B

View File

@ -14,6 +14,7 @@
#include "tools/vtoolendline.h" #include "tools/vtoolendline.h"
#include "tools/vtoolline.h" #include "tools/vtoolline.h"
#include "tools/vtoolalongline.h" #include "tools/vtoolalongline.h"
#include "tools/vtoolshoulderpoint.h"
MainWindow::MainWindow(QWidget *parent) : MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), ui(new Ui::MainWindow) QMainWindow(parent), ui(new Ui::MainWindow)
@ -49,6 +50,8 @@ MainWindow::MainWindow(QWidget *parent) :
&MainWindow::ToolLine); &MainWindow::ToolLine);
connect(ui->toolButtonAlongLine, &QToolButton::clicked, this, connect(ui->toolButtonAlongLine, &QToolButton::clicked, this,
&MainWindow::ToolAlongLine); &MainWindow::ToolAlongLine);
connect(ui->toolButtonShoulderPoint, &QToolButton::clicked, this,
&MainWindow::ToolShoulderPoint);
data = new VContainer; data = new VContainer;
CreateManTableIGroup (); CreateManTableIGroup ();
@ -277,6 +280,53 @@ void MainWindow::ClosedDialogAlongLine(int result){
ArrowTool(); ArrowTool();
} }
void MainWindow::ToolShoulderPoint(bool checked){
if(checked){
CanselTool();
tool = Tools::ShoulderPointTool;
QPixmap pixmap(":/cursor/shoulder_cursor.png");
QCursor cur(pixmap, 2, 3);
ui->graphicsView->setCursor(cur);
helpLabel->setText("Виберіть точки.");
dialogShoulderPoint = new DialogShoulderPoint(data, this);
connect(scene, &VMainGraphicsScene::ChoosedObject, dialogShoulderPoint,
&DialogShoulderPoint::ChoosedPoint);
connect(dialogShoulderPoint, &DialogShoulderPoint::DialogClosed, this,
&MainWindow::ClosedDialogShoulderPoint);
} else {
ui->toolButtonShoulderPoint->setChecked(true);
}
}
void MainWindow::ClosedDialogShoulderPoint(int result){
if(result == QDialog::Accepted){
QString formula = dialogShoulderPoint->getFormula();
qint64 p1Line = dialogShoulderPoint->getP1Line();
qint64 p2Line = dialogShoulderPoint->getP2Line();
qint64 pShoulder = dialogShoulderPoint->getPShoulder();
QString typeLine = dialogShoulderPoint->getTypeLine();
QString pointName = dialogShoulderPoint->getPointName();
VPointF firstPoint = data->GetPoint(p1Line);
VPointF secondPoint = data->GetPoint(p2Line);
VPointF shoulderPoint = data->GetPoint(pShoulder);
Calculator cal(data);
QString errorMsg;
qreal result = cal.eval(formula, &errorMsg);
if(errorMsg.isEmpty()){
QPointF fPoint = VToolShoulderPoint::FindPoint(firstPoint, secondPoint, shoulderPoint,
result*PrintDPI/25.4);
qint64 id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, 5, 10));
VToolShoulderPoint *point = new VToolShoulderPoint(doc, data, id, typeLine, formula, p1Line,
p2Line, pShoulder, Tool::FromGui);
scene->addItem(point);
connect(point, &VToolShoulderPoint::ChoosedPoint, scene, &VMainGraphicsScene::ChoosedItem);
}
}
ArrowTool();
}
void MainWindow::showEvent( QShowEvent *event ){ void MainWindow::showEvent( QShowEvent *event ){
QMainWindow::showEvent( event ); QMainWindow::showEvent( event );
if( event->spontaneous() ){ if( event->spontaneous() ){
@ -388,17 +438,26 @@ void MainWindow::CanselTool(){
case Tools::EndLineTool: case Tools::EndLineTool:
delete dialogEndLine; delete dialogEndLine;
ui->toolButtonEndLine->setChecked(false); ui->toolButtonEndLine->setChecked(false);
scene->setFocus(Qt::OtherFocusReason);
scene->clearSelection(); scene->clearSelection();
break; break;
case Tools::LineTool: case Tools::LineTool:
delete dialogLine; delete dialogLine;
ui->toolButtonLine->setChecked(false); ui->toolButtonLine->setChecked(false);
scene->setFocus(Qt::OtherFocusReason);
scene->clearFocus(); scene->clearFocus();
break; break;
case Tools::AlongLineTool: case Tools::AlongLineTool:
delete dialogAlongLine; delete dialogAlongLine;
ui->toolButtonAlongLine->setChecked(false); ui->toolButtonAlongLine->setChecked(false);
scene->clearFocus(); scene->setFocus(Qt::OtherFocusReason);
scene->clearSelection();
break;
case Tools::ShoulderPointTool:
delete dialogShoulderPoint;
ui->toolButtonShoulderPoint->setChecked(false);
scene->setFocus(Qt::OtherFocusReason);
scene->clearSelection();
break; break;
} }
} }
@ -658,6 +717,7 @@ void MainWindow::SetEnableTool(bool enable){
ui->toolButtonEndLine->setEnabled(enable); ui->toolButtonEndLine->setEnabled(enable);
ui->toolButtonLine->setEnabled(enable); ui->toolButtonLine->setEnabled(enable);
ui->toolButtonAlongLine->setEnabled(enable); ui->toolButtonAlongLine->setEnabled(enable);
ui->toolButtonShoulderPoint->setEnabled(enable);
} }
MainWindow::~MainWindow(){ MainWindow::~MainWindow(){

View File

@ -12,10 +12,11 @@
#include "dialogs/dialogincrements.h" #include "dialogs/dialogincrements.h"
#include "dialogs/dialogline.h" #include "dialogs/dialogline.h"
#include "dialogs/dialogalongline.h" #include "dialogs/dialogalongline.h"
#include "dialogs/dialogshoulderpoint.h"
#include "dialogs/dialogendline.h"
#include "tools/vtoolsimplepoint.h" #include "tools/vtoolsimplepoint.h"
#include "xml/vdomdocument.h" #include "xml/vdomdocument.h"
#include "container/vcontainer.h" #include "container/vcontainer.h"
#include "dialogs/dialogendline.h"
namespace Ui { namespace Ui {
class MainWindow; class MainWindow;
@ -28,7 +29,8 @@ namespace Tools{
SinglePointTool, SinglePointTool,
EndLineTool, EndLineTool,
LineTool, LineTool,
AlongLineTool AlongLineTool,
ShoulderPointTool
}; };
} }
@ -63,6 +65,8 @@ public slots:
void ClosedDialogLine(int result); void ClosedDialogLine(int result);
void ToolAlongLine(bool checked); void ToolAlongLine(bool checked);
void ClosedDialogAlongLine(int result); void ClosedDialogAlongLine(int result);
void ToolShoulderPoint(bool checked);
void ClosedDialogShoulderPoint(int result);
protected: protected:
virtual void keyPressEvent ( QKeyEvent * event ); virtual void keyPressEvent ( QKeyEvent * event );
virtual void showEvent( QShowEvent *event ); virtual void showEvent( QShowEvent *event );
@ -78,6 +82,7 @@ private:
DialogEndLine *dialogEndLine; DialogEndLine *dialogEndLine;
DialogLine *dialogLine; DialogLine *dialogLine;
DialogAlongLine *dialogAlongLine; DialogAlongLine *dialogAlongLine;
DialogShoulderPoint *dialogShoulderPoint;
VDomDocument *doc; VDomDocument *doc;
VContainer *data; VContainer *data;
QComboBox *comboBoxDraws; QComboBox *comboBoxDraws;

View File

@ -64,7 +64,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>154</width> <width>156</width>
<height>81</height> <height>81</height>
</rect> </rect>
</property> </property>
@ -79,10 +79,26 @@
</attribute> </attribute>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="3"> <item row="0" column="3">
<widget class="QToolButton" name="toolButton_5"> <widget class="QToolButton" name="toolButtonShoulderPoint">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>...</string> <string>...</string>
</property> </property>
<property name="icon">
<iconset resource="icon.qrc">
<normaloff>:/icon/32x32/shoulder.png</normaloff>:/icon/32x32/shoulder.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
@ -218,7 +234,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>117</width> <width>154</width>
<height>45</height> <height>45</height>
</rect> </rect>
</property> </property>
@ -246,7 +262,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>117</width> <width>154</width>
<height>45</height> <height>45</height>
</rect> </rect>
</property> </property>

View File

@ -1,4 +1,5 @@
#include "vabstracttool.h" #include "vabstracttool.h"
#include <QDebug>
VAbstractTool::VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id){ VAbstractTool::VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id){
this->doc = doc; this->doc = doc;
@ -11,6 +12,7 @@ VAbstractTool::VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id){
connect(this->doc, &VDomDocument::ChangedNameDraw, this, &VAbstractTool::ChangedNameDraw); connect(this->doc, &VDomDocument::ChangedNameDraw, this, &VAbstractTool::ChangedNameDraw);
connect(this, &VAbstractTool::haveLiteChange, this->doc, &VDomDocument::haveLiteChange); connect(this, &VAbstractTool::haveLiteChange, this->doc, &VDomDocument::haveLiteChange);
connect(this->doc, &VDomDocument::FullUpdateFromFile, this, &VAbstractTool::FullUpdateFromFile); connect(this->doc, &VDomDocument::FullUpdateFromFile, this, &VAbstractTool::FullUpdateFromFile);
connect(this, &VAbstractTool::FullUpdateTree, this->doc, &VDomDocument::FullUpdateTree);
} }
void VAbstractTool::ChangedNameDraw(const QString oldName, const QString newName){ void VAbstractTool::ChangedNameDraw(const QString oldName, const QString newName){
@ -66,3 +68,13 @@ void VAbstractTool::AddLine(const qint64 &firstPointId, const qint64 &secondPoin
VPointF secondPoint = data->GetPoint(secondPointId); VPointF secondPoint = data->GetPoint(secondPointId);
data->AddLine(nameLine, QLineF(firstPoint.toQPointF(), secondPoint.toQPointF()).length()); data->AddLine(nameLine, QLineF(firstPoint.toQPointF(), secondPoint.toQPointF()).length());
} }
void VAbstractTool::AddToCalculation(const QDomElement &domElement){
QDomElement calcElement;
bool ok = doc->GetActivCalculationElement(calcElement);
if(ok){
calcElement.appendChild(domElement);
} else {
qCritical()<<"Не можу знайти тег калькуляції."<< Q_FUNC_INFO;
}
}

View File

@ -42,5 +42,6 @@ protected:
void AddAttribute(QDomElement &domElement, const QString &name, const QString &value); void AddAttribute(QDomElement &domElement, const QString &name, const QString &value);
QString GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint) const; QString GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint) const;
void AddLine(const qint64 &firstPointId, const qint64 &secondPointId) const; void AddLine(const qint64 &firstPointId, const qint64 &secondPointId) const;
void AddToCalculation(const QDomElement &domElement);
}; };
#endif // VABSTRACTTOOL_H #endif // VABSTRACTTOOL_H

View File

@ -8,7 +8,6 @@ VToolAlongLine::VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, c
const qint64 &firstPointId, const qint64 &secondPointId, const qint64 &firstPointId, const qint64 &secondPointId,
const QString &typeLine, Tool::Enum typeCreation, const QString &typeLine, Tool::Enum typeCreation,
QGraphicsItem *parent):VToolPoint(doc, data, id, parent){ QGraphicsItem *parent):VToolPoint(doc, data, id, parent){
connect(this, &VToolAlongLine::FullUpdateTree, this->doc, &VDomDocument::FullUpdateTree);
this->typeLine = typeLine; this->typeLine = typeLine;
this->formula = formula; this->formula = formula;
this->firstPointId = firstPointId; this->firstPointId = firstPointId;
@ -132,11 +131,5 @@ void VToolAlongLine::AddToFile(){
AddAttribute(domElement, "firstPoint", firstPointId); AddAttribute(domElement, "firstPoint", firstPointId);
AddAttribute(domElement, "secondPoint", secondPointId); AddAttribute(domElement, "secondPoint", secondPointId);
QDomElement calcElement; AddToCalculation(domElement);
bool ok = doc->GetActivCalculationElement(calcElement);
if(ok){
calcElement.appendChild(domElement);
} else {
qCritical()<<"Не можу знайти тег калькуляції."<< Q_FUNC_INFO;
}
} }

View File

@ -8,7 +8,6 @@ VToolEndLine::VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id
const QString &typeLine, const QString &formula, const qint32 &angle, const QString &typeLine, const QString &formula, const qint32 &angle,
const qint64 &basePointId, Tool::Enum typeCreation, const qint64 &basePointId, Tool::Enum typeCreation,
QGraphicsItem *parent):VToolPoint(doc, data, id, parent){ QGraphicsItem *parent):VToolPoint(doc, data, id, parent){
connect(this, &VToolEndLine::FullUpdateTree, this->doc, &VDomDocument::FullUpdateTree);
this->typeLine = typeLine; this->typeLine = typeLine;
this->formula = formula; this->formula = formula;
this->angle = angle; this->angle = angle;
@ -120,11 +119,5 @@ void VToolEndLine::AddToFile(){
AddAttribute(domElement, "angle", angle); AddAttribute(domElement, "angle", angle);
AddAttribute(domElement, "basePoint", basePointId); AddAttribute(domElement, "basePoint", basePointId);
QDomElement calcElement; AddToCalculation(domElement);
bool ok = doc->GetActivCalculationElement(calcElement);
if(ok){
calcElement.appendChild(domElement);
} else {
qCritical()<<"Не можу знайти тег калькуляції."<< Q_FUNC_INFO;
}
} }

View File

@ -5,7 +5,6 @@
VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, qint64 secondPoint, VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, qint64 secondPoint,
Tool::Enum typeCreation, QGraphicsItem *parent):VAbstractTool(doc, data, id), Tool::Enum typeCreation, QGraphicsItem *parent):VAbstractTool(doc, data, id),
QGraphicsLineItem(parent){ QGraphicsLineItem(parent){
connect(this, &VToolLine::FullUpdateTree, this->doc, &VDomDocument::FullUpdateTree);
this->firstPoint = firstPoint; this->firstPoint = firstPoint;
this->secondPoint = secondPoint; this->secondPoint = secondPoint;
@ -87,13 +86,7 @@ void VToolLine::AddToFile(){
AddAttribute(domElement, "firstPoint", firstPoint); AddAttribute(domElement, "firstPoint", firstPoint);
AddAttribute(domElement, "secondPoint", secondPoint); AddAttribute(domElement, "secondPoint", secondPoint);
QDomElement calcElement; AddToCalculation(domElement);
bool ok = doc->GetActivCalculationElement(calcElement);
if(ok){
calcElement.appendChild(domElement);
} else {
qCritical()<<"Не можу знайти тег калькуляції."<< Q_FUNC_INFO;
}
} }
void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event){ void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event){

View File

@ -0,0 +1,156 @@
#include "vtoolshoulderpoint.h"
#include <QDebug>
#include <QMenu>
VToolShoulderPoint::VToolShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const qint64 &p1Line,
const qint64 &p2Line, const qint64 &pShoulder, Tool::Enum typeCreation,
QGraphicsItem * parent):VToolPoint(doc, data, id, parent){
this->typeLine = typeLine;
this->formula = formula;
this->p1Line = p1Line;
this->p2Line = p2Line;
this->pShoulder = pShoulder;
//Лінія, що з'єднує дві точки
VPointF p1L = data->GetPoint(p1Line);
VPointF point = data->GetPoint(id);
mainLine = new QGraphicsLineItem(QLineF(p1L.toQPointF(), point.toQPointF()), this);
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
if(typeLine == "none"){
mainLine->setVisible(false);
} else {
mainLine->setVisible(true);
}
AddLine(p1Line, id);
AddLine(p2Line, id);
if(typeCreation == Tool::FromGui){
AddToFile();
}
}
QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder,
const qreal &length){
QLineF line = QLineF(p1Line, p2Line);
qreal dist = line.length();
if(dist>length){
qDebug()<<"A3П2="<<length/PrintDPI*25.4<<"А30П ="<<dist/PrintDPI*25.4;
throw"Не можу знайти точку плеча. Довжина А3П2 < А3П.";
}
if(dist==length){
return line.p2();
}
qreal step = 0.01;
while(1){
line.setLength(line.length()+step);
QLineF line2 = QLineF(pShoulder, line.p2());
if(line2.length()>=length){
return line.p2();
}
}
}
void VToolShoulderPoint::FullUpdateFromFile(){
QString name;
qreal mx, my;
QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){
name = domElement.attribute("name", "");
mx = domElement.attribute("mx", "").toDouble()*PrintDPI/25.4;
my = domElement.attribute("my", "").toDouble()*PrintDPI/25.4;
typeLine = domElement.attribute("typeLine", "");
formula = domElement.attribute("length", "");
p1Line = domElement.attribute("p1Line", "").toLongLong();
p2Line = domElement.attribute("p2Line", "").toLongLong();
pShoulder = domElement.attribute("pShoulder", "").toLongLong();
}
VPointF point = VAbstractTool::data->GetPoint(id);
RefreshBaseGeometry(name, point.x(), point.y(), mx, my);
VPointF p1L = VAbstractTool::data->GetPoint(p1Line);
mainLine->setLine(QLineF(p1L.toQPointF(), point.toQPointF()));
if(typeLine == "none"){
mainLine->setVisible(false);
} else {
mainLine->setVisible(true);
}
AddLine(p1Line, id);
AddLine(p2Line, id);
}
void VToolShoulderPoint::FullUpdateFromGui(int result){
if(result == QDialog::Accepted){
QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){
domElement.setAttribute("name", dialogShoulderPoint->getPointName());
domElement.setAttribute("typeLine", dialogShoulderPoint->getTypeLine());
domElement.setAttribute("length", dialogShoulderPoint->getFormula());
domElement.setAttribute("p1Line", QString().setNum(dialogShoulderPoint->getP1Line()));
domElement.setAttribute("p2Line", QString().setNum(dialogShoulderPoint->getP2Line()));
domElement.setAttribute("pShoulder", QString().setNum(dialogShoulderPoint->getPShoulder()));
emit FullUpdateTree();
}
}
dialogShoulderPoint.clear();
}
void VToolShoulderPoint::ChangedActivDraw(const QString newName){
if(nameActivDraw == newName){
mainLine->setPen(QPen(Qt::black, widthHairLine));
VToolPoint::ChangedActivDraw(newName);
} else {
mainLine->setPen(QPen(Qt::gray, widthHairLine));
VToolPoint::ChangedActivDraw(newName);
}
}
void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
if(!ignoreContextMenuEvent){
QMenu menu;
QAction *actionOption = menu.addAction("Властивості");
QAction *selectedAction = menu.exec(event->screenPos());
if(selectedAction == actionOption){
dialogShoulderPoint =
QSharedPointer<DialogShoulderPoint>(new DialogShoulderPoint(VAbstractTool::data));
connect(qobject_cast< VMainGraphicsScene * >(this->scene()), &VMainGraphicsScene::ChoosedObject,
dialogShoulderPoint.data(), &DialogShoulderPoint::ChoosedPoint);
connect(dialogShoulderPoint.data(), &DialogShoulderPoint::DialogClosed, this,
&VToolShoulderPoint::FullUpdateFromGui);
connect(doc, &VDomDocument::FullUpdateFromFile, dialogShoulderPoint.data(), &DialogShoulderPoint::UpdateList);
VPointF p = VAbstractTool::data->GetPoint(id);
dialogShoulderPoint->setTypeLine(typeLine);
dialogShoulderPoint->setFormula(formula);
dialogShoulderPoint->setP1Line(p1Line);
dialogShoulderPoint->setP2Line(p2Line);
dialogShoulderPoint->setPShoulder(pShoulder);
dialogShoulderPoint->setPointName(p.name());
dialogShoulderPoint->show();
}
}
}
void VToolShoulderPoint::AddToFile(){
VPointF point = VAbstractTool::data->GetPoint(id);
QDomElement domElement = doc->createElement("point");
AddAttribute(domElement, "id", id);
AddAttribute(domElement, "type", "shoulder");
AddAttribute(domElement, "name", point.name());
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4);
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4);
AddAttribute(domElement, "typeLine", typeLine);
AddAttribute(domElement, "length", formula);
AddAttribute(domElement, "p1Line", p1Line);
AddAttribute(domElement, "p2Line", p2Line);
AddAttribute(domElement, "pShoulder", pShoulder);
AddToCalculation(domElement);
}

View File

@ -0,0 +1,33 @@
#ifndef VTOOLSHOULDERPOINT_H
#define VTOOLSHOULDERPOINT_H
#include "vtoolpoint.h"
#include "../dialogs/dialogshoulderpoint.h"
class VToolShoulderPoint : public VToolPoint
{
public:
VToolShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const qint64 &p1Line,
const qint64 &p2Line, const qint64 &pShoulder, Tool::Enum typeCreation,
QGraphicsItem * parent = 0);
static QPointF FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder,
const qreal &length);
public slots:
virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result);
virtual void ChangedActivDraw(const QString newName);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
private:
QString typeLine;
QString formula;
qint64 p1Line;
qint64 p2Line;
qint64 pShoulder;
QGraphicsLineItem *mainLine;
QSharedPointer<DialogShoulderPoint> dialogShoulderPoint;
};
#endif // VTOOLSHOULDERPOINT_H

View File

@ -12,7 +12,6 @@
VToolSimplePoint::VToolSimplePoint (VDomDocument *doc, VContainer *data, qint64 id, Tool::Enum typeCreation, VToolSimplePoint::VToolSimplePoint (VDomDocument *doc, VContainer *data, qint64 id, Tool::Enum typeCreation,
QGraphicsItem * parent ):VToolPoint(doc, data, id, parent){ QGraphicsItem * parent ):VToolPoint(doc, data, id, parent){
connect(this, &VToolSimplePoint::FullUpdateTree, this->doc, &VDomDocument::FullUpdateTree);
if(typeCreation == Tool::FromGui){ if(typeCreation == Tool::FromGui){
AddToFile(); AddToFile();
} }
@ -30,13 +29,7 @@ void VToolSimplePoint::AddToFile(){
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4); AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4);
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4); AddAttribute(domElement, "my", point.my()/PrintDPI*25.4);
QDomElement calcElement; AddToCalculation(domElement);
bool ok = doc->GetActivCalculationElement(calcElement);
if(ok){
calcElement.appendChild(domElement);
} else {
qCritical("Не можу знайти тег калькуляції. VToolSimplePoint::AddSimplePoint");
}
} }
void VToolSimplePoint::FullUpdateFromGui(int result){ void VToolSimplePoint::FullUpdateFromGui(int result){

View File

@ -5,6 +5,7 @@
#include "../tools/vtoolendline.h" #include "../tools/vtoolendline.h"
#include "../tools/vtoolline.h" #include "../tools/vtoolline.h"
#include "../tools/vtoolalongline.h" #include "../tools/vtoolalongline.h"
#include "../tools/vtoolshoulderpoint.h"
#include "../options.h" #include "../options.h"
#include "../container/calculator.h" #include "../container/calculator.h"
@ -443,6 +444,47 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
} }
return; return;
} }
if(type == "shoulder"){
if(!domElement.isNull()){
QString name, typeLine, formula;
qreal mx=5, my=10;
qint64 id, p1Line, p2Line, pShoulder;
if(!domElement.isNull()){
id = domElement.attribute("id", "").toLongLong();
name = domElement.attribute("name", "");
mx = domElement.attribute("mx","").toDouble()*PrintDPI/25.4;
my = domElement.attribute("my","").toDouble()*PrintDPI/25.4;
typeLine = domElement.attribute("typeLine", "");
formula = domElement.attribute("length", "");
p1Line = domElement.attribute("p1Line", "").toLongLong();
p2Line = domElement.attribute("p2Line", "").toLongLong();
pShoulder = domElement.attribute("pShoulder", "").toLongLong();
VPointF firstPoint = data->GetPoint(p1Line);
VPointF secondPoint = data->GetPoint(p2Line);
VPointF shoulderPoint = data->GetPoint(pShoulder);
Calculator cal(data);
QString errorMsg;
qreal result = cal.eval(formula, &errorMsg);
if(errorMsg.isEmpty()){
QPointF fPoint = VToolShoulderPoint::FindPoint(firstPoint, secondPoint, shoulderPoint,
result*PrintDPI/25.4);
data->UpdatePoint(id,VPointF(fPoint.x(), fPoint.y(), name, mx, my));
if(parse == Document::FullParse){
VToolShoulderPoint *point = new VToolShoulderPoint(this, data, id, typeLine, formula,
p1Line, p2Line, pShoulder,
Tool::FromGui);
scene->addItem(point);
connect(point, &VToolShoulderPoint::ChoosedPoint, scene,
&VMainGraphicsScene::ChoosedItem);
}
}
}
}
return;
}
} }
void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement, void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement,