Add tool Bisector
This commit is contained in:
parent
af95762c09
commit
f25d3e7f7f
|
@ -38,7 +38,9 @@ SOURCES += main.cpp\
|
||||||
tools/vtoolshoulderpoint.cpp \
|
tools/vtoolshoulderpoint.cpp \
|
||||||
dialogs/dialogshoulderpoint.cpp \
|
dialogs/dialogshoulderpoint.cpp \
|
||||||
tools/vtoolnormal.cpp \
|
tools/vtoolnormal.cpp \
|
||||||
dialogs/dialognormal.cpp
|
dialogs/dialognormal.cpp \
|
||||||
|
tools/vtoolbisector.cpp \
|
||||||
|
dialogs/dialogbisector.cpp
|
||||||
|
|
||||||
HEADERS += mainwindow.h \
|
HEADERS += mainwindow.h \
|
||||||
widgets/vmaingraphicsscene.h \
|
widgets/vmaingraphicsscene.h \
|
||||||
|
@ -67,7 +69,9 @@ HEADERS += mainwindow.h \
|
||||||
tools/vtoolshoulderpoint.h \
|
tools/vtoolshoulderpoint.h \
|
||||||
dialogs/dialogshoulderpoint.h \
|
dialogs/dialogshoulderpoint.h \
|
||||||
tools/vtoolnormal.h \
|
tools/vtoolnormal.h \
|
||||||
dialogs/dialognormal.h
|
dialogs/dialognormal.h \
|
||||||
|
tools/vtoolbisector.h \
|
||||||
|
dialogs/dialogbisector.h
|
||||||
|
|
||||||
FORMS += mainwindow.ui \
|
FORMS += mainwindow.ui \
|
||||||
dialogs/dialogsinglepoint.ui \
|
dialogs/dialogsinglepoint.ui \
|
||||||
|
@ -76,7 +80,8 @@ FORMS += mainwindow.ui \
|
||||||
dialogs/dialogline.ui \
|
dialogs/dialogline.ui \
|
||||||
dialogs/dialogalongline.ui \
|
dialogs/dialogalongline.ui \
|
||||||
dialogs/dialogshoulderpoint.ui \
|
dialogs/dialogshoulderpoint.ui \
|
||||||
dialogs/dialognormal.ui
|
dialogs/dialognormal.ui \
|
||||||
|
dialogs/dialogbisector.ui
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
icon.qrc \
|
icon.qrc \
|
||||||
|
|
|
@ -6,5 +6,6 @@
|
||||||
<file>cursor/alongline_cursor.png</file>
|
<file>cursor/alongline_cursor.png</file>
|
||||||
<file>cursor/shoulder_cursor.png</file>
|
<file>cursor/shoulder_cursor.png</file>
|
||||||
<file>cursor/normal_cursor.png</file>
|
<file>cursor/normal_cursor.png</file>
|
||||||
|
<file>cursor/bisector_cursor.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
BIN
cursor/bisector_cursor.png
Normal file
BIN
cursor/bisector_cursor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
144
dialogs/dialogbisector.cpp
Normal file
144
dialogs/dialogbisector.cpp
Normal file
|
@ -0,0 +1,144 @@
|
||||||
|
#include "dialogbisector.h"
|
||||||
|
#include "ui_dialogbisector.h"
|
||||||
|
|
||||||
|
DialogBisector::DialogBisector(const VContainer *data, QWidget *parent) :
|
||||||
|
DialogTool(data, parent), ui(new Ui::DialogBisector)
|
||||||
|
{
|
||||||
|
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, &DialogBisector::DialogAccepted);
|
||||||
|
flagName = false;
|
||||||
|
CheckState();
|
||||||
|
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
|
||||||
|
connect(bCansel, &QPushButton::clicked, this, &DialogBisector::DialogRejected);
|
||||||
|
FillComboBoxPoints(ui->comboBoxFirstPoint);
|
||||||
|
FillComboBoxPoints(ui->comboBoxSecondPoint);
|
||||||
|
FillComboBoxPoints(ui->comboBoxThirdPoint);
|
||||||
|
FillComboBoxTypeLine(ui->comboBoxLineType);
|
||||||
|
|
||||||
|
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogBisector::PutHere);
|
||||||
|
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogBisector::PutVal);
|
||||||
|
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogBisector::ValChenged);
|
||||||
|
|
||||||
|
ShowBase();
|
||||||
|
connect(ui->radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogBisector::SizeGrowth);
|
||||||
|
connect(ui->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogBisector::StandartTable);
|
||||||
|
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogBisector::Increments);
|
||||||
|
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogBisector::LengthLines);
|
||||||
|
connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogBisector::EvalFormula);
|
||||||
|
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogBisector::NamePointChanged);
|
||||||
|
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogBisector::FormulaChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
DialogBisector::~DialogBisector(){
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogBisector::ChoosedPoint(qint64 id, Scene::Type type){
|
||||||
|
if(type == Scene::Point){
|
||||||
|
VPointF point = data->GetPoint(id);
|
||||||
|
if(number == 0){
|
||||||
|
qint32 index = ui->comboBoxFirstPoint->findText(point.name());
|
||||||
|
if ( index != -1 ) { // -1 for not found
|
||||||
|
ui->comboBoxFirstPoint->setCurrentIndex(index);
|
||||||
|
number++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(number == 1){
|
||||||
|
qint32 index = ui->comboBoxSecondPoint->findText(point.name());
|
||||||
|
if ( index != -1 ) { // -1 for not found
|
||||||
|
ui->comboBoxSecondPoint->setCurrentIndex(index);
|
||||||
|
number++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(number == 2){
|
||||||
|
qint32 index = ui->comboBoxThirdPoint->findText(point.name());
|
||||||
|
if ( index != -1 ) { // -1 for not found
|
||||||
|
ui->comboBoxThirdPoint->setCurrentIndex(index);
|
||||||
|
number = 0;
|
||||||
|
}
|
||||||
|
if(!isInitialized){
|
||||||
|
this->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DialogBisector::getPointName() const{
|
||||||
|
return pointName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogBisector::setPointName(const QString &value){
|
||||||
|
pointName = value;
|
||||||
|
ui->lineEditNamePoint->setText(pointName);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DialogBisector::getTypeLine() const{
|
||||||
|
return typeLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogBisector::setTypeLine(const QString &value){
|
||||||
|
typeLine = value;
|
||||||
|
SetupTypeLine(ui->comboBoxLineType, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DialogBisector::getFormula() const{
|
||||||
|
return formula;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogBisector::setFormula(const QString &value){
|
||||||
|
formula = value;
|
||||||
|
ui->lineEditFormula->setText(formula);
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 DialogBisector::getFirstPointId() const{
|
||||||
|
return firstPointId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogBisector::setFirstPointId(const qint64 &value){
|
||||||
|
firstPointId = value;
|
||||||
|
ChangeCurrentData(ui->comboBoxFirstPoint, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 DialogBisector::getSecondPointId() const{
|
||||||
|
return secondPointId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogBisector::setSecondPointId(const qint64 &value){
|
||||||
|
secondPointId = value;
|
||||||
|
ChangeCurrentData(ui->comboBoxSecondPoint, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 DialogBisector::getThirdPointId() const{
|
||||||
|
return thirdPointId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogBisector::setThirdPointId(const qint64 &value){
|
||||||
|
thirdPointId = value;
|
||||||
|
ChangeCurrentData(ui->comboBoxThirdPoint, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogBisector::DialogAccepted(){
|
||||||
|
pointName = ui->lineEditNamePoint->text();
|
||||||
|
typeLine = GetTypeLine(ui->comboBoxLineType);
|
||||||
|
formula = ui->lineEditFormula->text();
|
||||||
|
qint32 index = ui->comboBoxFirstPoint->currentIndex();
|
||||||
|
firstPointId = qvariant_cast<qint64>(ui->comboBoxFirstPoint->itemData(index));
|
||||||
|
index = ui->comboBoxSecondPoint->currentIndex();
|
||||||
|
secondPointId = qvariant_cast<qint64>(ui->comboBoxSecondPoint->itemData(index));
|
||||||
|
index = ui->comboBoxThirdPoint->currentIndex();
|
||||||
|
thirdPointId = qvariant_cast<qint64>(ui->comboBoxThirdPoint->itemData(index));
|
||||||
|
emit DialogClosed(QDialog::Accepted);
|
||||||
|
}
|
50
dialogs/dialogbisector.h
Normal file
50
dialogs/dialogbisector.h
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
#ifndef DIALOGBISECTOR_H
|
||||||
|
#define DIALOGBISECTOR_H
|
||||||
|
|
||||||
|
#include "dialogtool.h"
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QListWidgetItem>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include "../options.h"
|
||||||
|
#include "../container/vcontainer.h"
|
||||||
|
#include "../container/calculator.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class DialogBisector;
|
||||||
|
}
|
||||||
|
|
||||||
|
class DialogBisector : public DialogTool
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DialogBisector(const VContainer *data, QWidget *parent = 0);
|
||||||
|
~DialogBisector();
|
||||||
|
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 getFirstPointId() const;
|
||||||
|
void setFirstPointId(const qint64 &value);
|
||||||
|
qint64 getSecondPointId() const;
|
||||||
|
void setSecondPointId(const qint64 &value);
|
||||||
|
qint64 getThirdPointId() const;
|
||||||
|
void setThirdPointId(const qint64 &value);
|
||||||
|
public slots:
|
||||||
|
virtual void ChoosedPoint(qint64 id, Scene::Type type);
|
||||||
|
virtual void DialogAccepted();
|
||||||
|
private:
|
||||||
|
Ui::DialogBisector *ui;
|
||||||
|
qint32 number;
|
||||||
|
QString pointName;
|
||||||
|
QString typeLine;
|
||||||
|
QString formula;
|
||||||
|
qint64 firstPointId;
|
||||||
|
qint64 secondPointId;
|
||||||
|
qint64 thirdPointId;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DIALOGBISECTOR_H
|
323
dialogs/dialogbisector.ui
Normal file
323
dialogs/dialogbisector.ui
Normal file
|
@ -0,0 +1,323 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>DialogBisector</class>
|
||||||
|
<widget class="QDialog" name="DialogBisector">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>480</width>
|
||||||
|
<height>485</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<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_2">
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<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_3">
|
||||||
|
<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="comboBoxFirstPoint"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
|
<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="comboBoxSecondPoint"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<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="comboBoxThirdPoint"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_7">
|
||||||
|
<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>DialogBisector</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>DialogBisector</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>
|
1
icon.qrc
1
icon.qrc
|
@ -23,5 +23,6 @@
|
||||||
<file>icon/32x32/along_line.png</file>
|
<file>icon/32x32/along_line.png</file>
|
||||||
<file>icon/32x32/shoulder.png</file>
|
<file>icon/32x32/shoulder.png</file>
|
||||||
<file>icon/32x32/normal.png</file>
|
<file>icon/32x32/normal.png</file>
|
||||||
|
<file>icon/32x32/bisector.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
BIN
icon/32x32/bisector.png
Normal file
BIN
icon/32x32/bisector.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
|
@ -16,6 +16,7 @@
|
||||||
#include "tools/vtoolalongline.h"
|
#include "tools/vtoolalongline.h"
|
||||||
#include "tools/vtoolshoulderpoint.h"
|
#include "tools/vtoolshoulderpoint.h"
|
||||||
#include "tools/vtoolnormal.h"
|
#include "tools/vtoolnormal.h"
|
||||||
|
#include "tools/vtoolbisector.h"
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent), ui(new Ui::MainWindow)
|
QMainWindow(parent), ui(new Ui::MainWindow)
|
||||||
|
@ -55,6 +56,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
&MainWindow::ToolShoulderPoint);
|
&MainWindow::ToolShoulderPoint);
|
||||||
connect(ui->toolButtonNormal, &QToolButton::clicked, this,
|
connect(ui->toolButtonNormal, &QToolButton::clicked, this,
|
||||||
&MainWindow::ToolNormal);
|
&MainWindow::ToolNormal);
|
||||||
|
connect(ui->toolButtonBisector, &QToolButton::clicked, this,
|
||||||
|
&MainWindow::ToolBisector);
|
||||||
|
|
||||||
data = new VContainer;
|
data = new VContainer;
|
||||||
CreateManTableIGroup ();
|
CreateManTableIGroup ();
|
||||||
|
@ -383,6 +386,54 @@ void MainWindow::ClosedDialogNormal(int result){
|
||||||
ArrowTool();
|
ArrowTool();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::ToolBisector(bool checked){
|
||||||
|
if(checked){
|
||||||
|
CanselTool();
|
||||||
|
tool = Tools::BisectorTool;
|
||||||
|
QPixmap pixmap(":/cursor/bisector_cursor.png");
|
||||||
|
QCursor cur(pixmap, 2, 3);
|
||||||
|
ui->graphicsView->setCursor(cur);
|
||||||
|
helpLabel->setText("Виберіть точки.");
|
||||||
|
dialogBisector = new DialogBisector(data, this);
|
||||||
|
connect(scene, &VMainGraphicsScene::ChoosedObject, dialogBisector,
|
||||||
|
&DialogBisector::ChoosedPoint);
|
||||||
|
connect(dialogBisector, &DialogBisector::DialogClosed, this,
|
||||||
|
&MainWindow::ClosedDialogBisector);
|
||||||
|
} else {
|
||||||
|
ui->toolButtonBisector->setChecked(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::ClosedDialogBisector(int result){
|
||||||
|
if(result == QDialog::Accepted){
|
||||||
|
QString formula = dialogBisector->getFormula();
|
||||||
|
qint64 firstPointId = dialogBisector->getFirstPointId();
|
||||||
|
qint64 secondPointId = dialogBisector->getSecondPointId();
|
||||||
|
qint64 thirdPointId = dialogBisector->getThirdPointId();
|
||||||
|
QString typeLine = dialogBisector->getTypeLine();
|
||||||
|
QString pointName = dialogBisector->getPointName();
|
||||||
|
|
||||||
|
VPointF firstPoint = data->GetPoint(firstPointId);
|
||||||
|
VPointF secondPoint = data->GetPoint(secondPointId);
|
||||||
|
VPointF thirdPoint = data->GetPoint(thirdPointId);
|
||||||
|
|
||||||
|
Calculator cal(data);
|
||||||
|
QString errorMsg;
|
||||||
|
qreal result = cal.eval(formula, &errorMsg);
|
||||||
|
if(errorMsg.isEmpty()){
|
||||||
|
QPointF fPoint = VToolBisector::FindPoint(firstPoint, secondPoint, thirdPoint,
|
||||||
|
result*PrintDPI/25.4);
|
||||||
|
qint64 id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, 5, 10));
|
||||||
|
data->AddLine(secondPointId, id);
|
||||||
|
VToolBisector *point = new VToolBisector(doc, data, id, typeLine, formula, firstPointId,
|
||||||
|
secondPointId, thirdPointId, Tool::FromGui);
|
||||||
|
scene->addItem(point);
|
||||||
|
connect(point, &VToolBisector::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() ){
|
||||||
|
@ -521,6 +572,12 @@ void MainWindow::CanselTool(){
|
||||||
scene->setFocus(Qt::OtherFocusReason);
|
scene->setFocus(Qt::OtherFocusReason);
|
||||||
scene->clearSelection();
|
scene->clearSelection();
|
||||||
break;
|
break;
|
||||||
|
case Tools::BisectorTool:
|
||||||
|
delete dialogBisector;
|
||||||
|
ui->toolButtonBisector->setChecked(false);
|
||||||
|
scene->setFocus(Qt::OtherFocusReason);
|
||||||
|
scene->clearSelection();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -781,6 +838,7 @@ void MainWindow::SetEnableTool(bool enable){
|
||||||
ui->toolButtonAlongLine->setEnabled(enable);
|
ui->toolButtonAlongLine->setEnabled(enable);
|
||||||
ui->toolButtonShoulderPoint->setEnabled(enable);
|
ui->toolButtonShoulderPoint->setEnabled(enable);
|
||||||
ui->toolButtonNormal->setEnabled(enable);
|
ui->toolButtonNormal->setEnabled(enable);
|
||||||
|
ui->toolButtonBisector->setEnabled(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow(){
|
MainWindow::~MainWindow(){
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "dialogs/dialogshoulderpoint.h"
|
#include "dialogs/dialogshoulderpoint.h"
|
||||||
#include "dialogs/dialogendline.h"
|
#include "dialogs/dialogendline.h"
|
||||||
#include "dialogs/dialognormal.h"
|
#include "dialogs/dialognormal.h"
|
||||||
|
#include "dialogs/dialogbisector.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"
|
||||||
|
@ -32,7 +33,8 @@ namespace Tools{
|
||||||
LineTool,
|
LineTool,
|
||||||
AlongLineTool,
|
AlongLineTool,
|
||||||
ShoulderPointTool,
|
ShoulderPointTool,
|
||||||
NormalTool
|
NormalTool,
|
||||||
|
BisectorTool
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +73,8 @@ public slots:
|
||||||
void ClosedDialogShoulderPoint(int result);
|
void ClosedDialogShoulderPoint(int result);
|
||||||
void ToolNormal(bool checked);
|
void ToolNormal(bool checked);
|
||||||
void ClosedDialogNormal(int result);
|
void ClosedDialogNormal(int result);
|
||||||
|
void ToolBisector(bool checked);
|
||||||
|
void ClosedDialogBisector(int result);
|
||||||
protected:
|
protected:
|
||||||
virtual void keyPressEvent ( QKeyEvent * event );
|
virtual void keyPressEvent ( QKeyEvent * event );
|
||||||
virtual void showEvent( QShowEvent *event );
|
virtual void showEvent( QShowEvent *event );
|
||||||
|
@ -88,6 +92,7 @@ private:
|
||||||
DialogAlongLine *dialogAlongLine;
|
DialogAlongLine *dialogAlongLine;
|
||||||
DialogShoulderPoint *dialogShoulderPoint;
|
DialogShoulderPoint *dialogShoulderPoint;
|
||||||
DialogNormal *dialogNormal;
|
DialogNormal *dialogNormal;
|
||||||
|
DialogBisector *dialogBisector;
|
||||||
VDomDocument *doc;
|
VDomDocument *doc;
|
||||||
VContainer *data;
|
VContainer *data;
|
||||||
QComboBox *comboBoxDraws;
|
QComboBox *comboBoxDraws;
|
||||||
|
|
|
@ -64,7 +64,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>156</width>
|
<width>154</width>
|
||||||
<height>104</height>
|
<height>104</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -199,6 +199,29 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QToolButton" name="toolButtonBisector">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="icon.qrc">
|
||||||
|
<normaloff>:/icon/32x32/bisector.png</normaloff>:/icon/32x32/bisector.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>32</width>
|
||||||
|
<height>32</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="page_2">
|
<widget class="QWidget" name="page_2">
|
||||||
|
|
|
@ -50,7 +50,7 @@ void VToolAlongLine::FullUpdateFromFile(){
|
||||||
secondPointId = domElement.attribute("secondPoint", "").toLongLong();
|
secondPointId = domElement.attribute("secondPoint", "").toLongLong();
|
||||||
}
|
}
|
||||||
VPointF point = VAbstractTool::data->GetPoint(id);
|
VPointF point = VAbstractTool::data->GetPoint(id);
|
||||||
RefreshBaseGeometry(name, point.x(), point.y(), mx, my);
|
RefreshGeometry(name, point.x(), point.y(), mx, my);
|
||||||
VPointF firstPoint = VAbstractTool::data->GetPoint(firstPointId);
|
VPointF firstPoint = VAbstractTool::data->GetPoint(firstPointId);
|
||||||
VPointF secondPoint = VAbstractTool::data->GetPoint(secondPointId);
|
VPointF secondPoint = VAbstractTool::data->GetPoint(secondPointId);
|
||||||
mainLine->setLine(QLineF(firstPoint.toQPointF(), secondPoint.toQPointF()));
|
mainLine->setLine(QLineF(firstPoint.toQPointF(), secondPoint.toQPointF()));
|
||||||
|
@ -61,6 +61,16 @@ void VToolAlongLine::FullUpdateFromFile(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VToolAlongLine::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 VToolAlongLine::FullUpdateFromGui(int result){
|
void VToolAlongLine::FullUpdateFromGui(int result){
|
||||||
if(result == QDialog::Accepted){
|
if(result == QDialog::Accepted){
|
||||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
@ -77,16 +87,6 @@ void VToolAlongLine::FullUpdateFromGui(int result){
|
||||||
dialogAlongLine.clear();
|
dialogAlongLine.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolAlongLine::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 VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||||
if(!ignoreContextMenuEvent){
|
if(!ignoreContextMenuEvent){
|
||||||
QMenu menu;
|
QMenu menu;
|
||||||
|
|
141
tools/vtoolbisector.cpp
Normal file
141
tools/vtoolbisector.cpp
Normal file
|
@ -0,0 +1,141 @@
|
||||||
|
#include "vtoolbisector.h"
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
|
VToolBisector::VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
|
||||||
|
const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId,
|
||||||
|
const qint64 &thirdPointId, Tool::Enum typeCreation, QGraphicsItem *parent):
|
||||||
|
VToolPoint(doc, data, id, parent){
|
||||||
|
this->typeLine = typeLine;
|
||||||
|
this->formula = formula;
|
||||||
|
this->firstPointId = firstPointId;
|
||||||
|
this->secondPointId = secondPointId;
|
||||||
|
this->thirdPointId = thirdPointId;
|
||||||
|
|
||||||
|
//Лінія, що з'єднує дві точки
|
||||||
|
VPointF basePoint = data->GetPoint(secondPointId);
|
||||||
|
VPointF point = data->GetPoint(id);
|
||||||
|
mainLine = new QGraphicsLineItem(QLineF(basePoint.toQPointF(), point.toQPointF()), this);
|
||||||
|
mainLine->setPen(QPen(Qt::black, widthHairLine));
|
||||||
|
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||||
|
if(typeLine == "none"){
|
||||||
|
mainLine->setVisible(false);
|
||||||
|
} else {
|
||||||
|
mainLine->setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(typeCreation == Tool::FromGui){
|
||||||
|
AddToFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QPointF VToolBisector::FindPoint(const QPointF &firstPoint, const QPointF &secondPoint,
|
||||||
|
const QPointF &thirdPoint, const qreal &length){
|
||||||
|
QLineF line1(secondPoint, firstPoint);
|
||||||
|
QLineF line2(secondPoint, thirdPoint);
|
||||||
|
qreal angle = line1.angleTo(line2);
|
||||||
|
if(angle>180){
|
||||||
|
angle = 360 - angle;
|
||||||
|
}
|
||||||
|
line1.setAngle(line1.angle()-angle/2);
|
||||||
|
line1.setLength(length);
|
||||||
|
return line1.p2();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolBisector::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", "");
|
||||||
|
firstPointId = domElement.attribute("firstPoint", "").toLongLong();
|
||||||
|
secondPointId = domElement.attribute("secondPoint", "").toLongLong();
|
||||||
|
thirdPointId = domElement.attribute("thirdPoint", "").toLongLong();
|
||||||
|
}
|
||||||
|
VPointF point = VAbstractTool::data->GetPoint(id);
|
||||||
|
RefreshGeometry(name, point.x(), point.y(), mx, my);
|
||||||
|
VPointF basePoint = VAbstractTool::data->GetPoint(secondPointId);
|
||||||
|
mainLine->setLine(QLineF(basePoint.toQPointF(), point.toQPointF()));
|
||||||
|
if(typeLine == "none"){
|
||||||
|
mainLine->setVisible(false);
|
||||||
|
} else {
|
||||||
|
mainLine->setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolBisector::FullUpdateFromGui(int result){
|
||||||
|
if(result == QDialog::Accepted){
|
||||||
|
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||||
|
if(domElement.isElement()){
|
||||||
|
domElement.setAttribute("name", dialogBisector->getPointName());
|
||||||
|
domElement.setAttribute("typeLine", dialogBisector->getTypeLine());
|
||||||
|
domElement.setAttribute("length", dialogBisector->getFormula());
|
||||||
|
domElement.setAttribute("firstPoint", QString().setNum(dialogBisector->getFirstPointId()));
|
||||||
|
domElement.setAttribute("secondPoint", QString().setNum(dialogBisector->getSecondPointId()));
|
||||||
|
domElement.setAttribute("thirdPoint", QString().setNum(dialogBisector->getThirdPointId()));
|
||||||
|
emit FullUpdateTree();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dialogBisector.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolBisector::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 VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||||
|
if(!ignoreContextMenuEvent){
|
||||||
|
QMenu menu;
|
||||||
|
QAction *actionOption = menu.addAction("Властивості");
|
||||||
|
QAction *selectedAction = menu.exec(event->screenPos());
|
||||||
|
if(selectedAction == actionOption){
|
||||||
|
dialogBisector = QSharedPointer<DialogBisector>(new DialogBisector(VAbstractTool::data));
|
||||||
|
|
||||||
|
connect(qobject_cast< VMainGraphicsScene * >(this->scene()), &VMainGraphicsScene::ChoosedObject,
|
||||||
|
dialogBisector.data(), &DialogBisector::ChoosedPoint);
|
||||||
|
connect(dialogBisector.data(), &DialogBisector::DialogClosed, this,
|
||||||
|
&VToolBisector::FullUpdateFromGui);
|
||||||
|
connect(doc, &VDomDocument::FullUpdateFromFile, dialogBisector.data(),
|
||||||
|
&DialogBisector::UpdateList);
|
||||||
|
|
||||||
|
VPointF p = VAbstractTool::data->GetPoint(id);
|
||||||
|
|
||||||
|
dialogBisector->setTypeLine(typeLine);
|
||||||
|
dialogBisector->setFormula(formula);
|
||||||
|
dialogBisector->setFirstPointId(firstPointId);
|
||||||
|
dialogBisector->setSecondPointId(secondPointId);
|
||||||
|
dialogBisector->setThirdPointId(thirdPointId);
|
||||||
|
dialogBisector->setPointName(p.name());
|
||||||
|
|
||||||
|
dialogBisector->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolBisector::AddToFile(){
|
||||||
|
VPointF point = VAbstractTool::data->GetPoint(id);
|
||||||
|
QDomElement domElement = doc->createElement("point");
|
||||||
|
|
||||||
|
AddAttribute(domElement, "id", id);
|
||||||
|
AddAttribute(domElement, "type", "bisector");
|
||||||
|
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, "firstPoint", firstPointId);
|
||||||
|
AddAttribute(domElement, "secondPoint", secondPointId);
|
||||||
|
AddAttribute(domElement, "thirdPoint", thirdPointId);
|
||||||
|
|
||||||
|
AddToCalculation(domElement);
|
||||||
|
}
|
34
tools/vtoolbisector.h
Normal file
34
tools/vtoolbisector.h
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#ifndef VTOOLBISECTOR_H
|
||||||
|
#define VTOOLBISECTOR_H
|
||||||
|
|
||||||
|
#include <QSharedPointer>
|
||||||
|
|
||||||
|
#include "vtoolpoint.h"
|
||||||
|
#include "../dialogs/dialogbisector.h"
|
||||||
|
|
||||||
|
class VToolBisector : public VToolPoint
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
|
||||||
|
const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId,
|
||||||
|
const qint64 &thirdPointId,Tool::Enum typeCreation, QGraphicsItem * parent = 0);
|
||||||
|
static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint,
|
||||||
|
const QPointF &thirdPoint, 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 firstPointId;
|
||||||
|
qint64 secondPointId;
|
||||||
|
qint64 thirdPointId;
|
||||||
|
QGraphicsLineItem *mainLine;
|
||||||
|
QSharedPointer<DialogBisector> dialogBisector;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VTOOLBISECTOR_H
|
|
@ -44,7 +44,7 @@ void VToolEndLine::FullUpdateFromFile(){
|
||||||
angle = domElement.attribute("angle", "").toInt();
|
angle = domElement.attribute("angle", "").toInt();
|
||||||
}
|
}
|
||||||
VPointF point = VAbstractTool::data->GetPoint(id);
|
VPointF point = VAbstractTool::data->GetPoint(id);
|
||||||
RefreshBaseGeometry(name, point.x(), point.y(), mx, my);
|
RefreshGeometry(name, point.x(), point.y(), mx, my);
|
||||||
VPointF basePoint = VAbstractTool::data->GetPoint(basePointId);
|
VPointF basePoint = VAbstractTool::data->GetPoint(basePointId);
|
||||||
mainLine->setLine(QLineF(basePoint.toQPointF(), point.toQPointF()));
|
mainLine->setLine(QLineF(basePoint.toQPointF(), point.toQPointF()));
|
||||||
if(typeLine == "none"){
|
if(typeLine == "none"){
|
||||||
|
|
31
tools/vtoollinepoint.cpp
Normal file
31
tools/vtoollinepoint.cpp
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#include "vtoollinepoint.h"
|
||||||
|
|
||||||
|
VToolLinePoint::VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
|
||||||
|
const QString &formula, const qint64 &pointId, const qint32 &angle,
|
||||||
|
QGraphicsItem *parent):VToolPoint(doc, data, id, parent){
|
||||||
|
this->typeLine = typeLine;
|
||||||
|
this->formula = formula;
|
||||||
|
this->angle = angle;
|
||||||
|
|
||||||
|
//Лінія, що з'єднує дві точки
|
||||||
|
VPointF firstPoint = data->GetPoint(pointId);
|
||||||
|
VPointF point = data->GetPoint(id);
|
||||||
|
mainLine = new QGraphicsLineItem(QLineF(firstPoint.toQPointF(), point.toQPointF()), this);
|
||||||
|
mainLine->setPen(QPen(Qt::black, widthHairLine));
|
||||||
|
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||||
|
if(typeLine == "none"){
|
||||||
|
mainLine->setVisible(false);
|
||||||
|
} else {
|
||||||
|
mainLine->setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VToolLinePoint::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);
|
||||||
|
}
|
||||||
|
}
|
21
tools/vtoollinepoint.h
Normal file
21
tools/vtoollinepoint.h
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#ifndef VTOOLLINEPOINT_H
|
||||||
|
#define VTOOLLINEPOINT_H
|
||||||
|
|
||||||
|
#include "vtoolpoint.h"
|
||||||
|
|
||||||
|
class VToolLinePoint : public VToolPoint
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||||
|
const QString &typeLine, const QString &formula,
|
||||||
|
const qint64 &pointId, const qint32 &angle, QGraphicsItem * parent = 0);
|
||||||
|
public slots:
|
||||||
|
virtual void ChangedActivDraw(const QString newName);
|
||||||
|
protected:
|
||||||
|
QString typeLine;
|
||||||
|
QString formula;
|
||||||
|
qint32 angle;
|
||||||
|
QGraphicsLineItem *mainLine;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VTOOLLINEPOINT_H
|
|
@ -53,7 +53,7 @@ void VToolNormal::FullUpdateFromFile(){
|
||||||
angle = domElement.attribute("angle", "").toInt();
|
angle = domElement.attribute("angle", "").toInt();
|
||||||
}
|
}
|
||||||
VPointF point = VAbstractTool::data->GetPoint(id);
|
VPointF point = VAbstractTool::data->GetPoint(id);
|
||||||
RefreshBaseGeometry(name, point.x(), point.y(), mx, my);
|
RefreshGeometry(name, point.x(), point.y(), mx, my);
|
||||||
VPointF firstPoint = VAbstractTool::data->GetPoint(firstPointId);
|
VPointF firstPoint = VAbstractTool::data->GetPoint(firstPointId);
|
||||||
mainLine->setLine(QLineF(firstPoint.toQPointF(), point.toQPointF()));
|
mainLine->setLine(QLineF(firstPoint.toQPointF(), point.toQPointF()));
|
||||||
if(typeLine == "none"){
|
if(typeLine == "none"){
|
||||||
|
@ -131,7 +131,7 @@ void VToolNormal::AddToFile(){
|
||||||
AddAttribute(domElement, "length", formula);
|
AddAttribute(domElement, "length", formula);
|
||||||
AddAttribute(domElement, "angle", angle);
|
AddAttribute(domElement, "angle", angle);
|
||||||
AddAttribute(domElement, "firstPoint", firstPointId);
|
AddAttribute(domElement, "firstPoint", firstPointId);
|
||||||
AddAttribute(domElement, "secondPoint", firstPointId);
|
AddAttribute(domElement, "secondPoint", secondPointId);
|
||||||
|
|
||||||
AddToCalculation(domElement);
|
AddToCalculation(domElement);
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,7 +192,7 @@ void VToolPoint::mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ){
|
||||||
QGraphicsItem::mouseReleaseEvent(event);
|
QGraphicsItem::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VToolPoint::RefreshBaseGeometry(const QString &name, const qreal &x, const qreal &y, const qreal &mx,
|
void VToolPoint::RefreshGeometry(const QString &name, const qreal &x, const qreal &y, const qreal &mx,
|
||||||
const qreal &my){
|
const qreal &my){
|
||||||
QRectF rec = QRectF(x, y, radius*2, radius*2);
|
QRectF rec = QRectF(x, y, radius*2, radius*2);
|
||||||
rec.translate(x-rec.center().x(), y-rec.center().y());
|
rec.translate(x-rec.center().x(), y-rec.center().y());
|
||||||
|
|
|
@ -23,7 +23,7 @@ protected:
|
||||||
VGraphicsSimpleTextItem *namePoint;
|
VGraphicsSimpleTextItem *namePoint;
|
||||||
QGraphicsLineItem *lineName;
|
QGraphicsLineItem *lineName;
|
||||||
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
||||||
void RefreshBaseGeometry(const QString &name, const qreal &x, const qreal &y,
|
void RefreshGeometry(const QString &name, const qreal &x, const qreal &y,
|
||||||
const qreal &mx, const qreal &my);
|
const qreal &mx, const qreal &my);
|
||||||
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
|
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
|
||||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
||||||
|
|
|
@ -65,7 +65,7 @@ void VToolShoulderPoint::FullUpdateFromFile(){
|
||||||
pShoulder = domElement.attribute("pShoulder", "").toLongLong();
|
pShoulder = domElement.attribute("pShoulder", "").toLongLong();
|
||||||
}
|
}
|
||||||
VPointF point = VAbstractTool::data->GetPoint(id);
|
VPointF point = VAbstractTool::data->GetPoint(id);
|
||||||
RefreshBaseGeometry(name, point.x(), point.y(), mx, my);
|
RefreshGeometry(name, point.x(), point.y(), mx, my);
|
||||||
VPointF p1L = VAbstractTool::data->GetPoint(p1Line);
|
VPointF p1L = VAbstractTool::data->GetPoint(p1Line);
|
||||||
mainLine->setLine(QLineF(p1L.toQPointF(), point.toQPointF()));
|
mainLine->setLine(QLineF(p1L.toQPointF(), point.toQPointF()));
|
||||||
if(typeLine == "none"){
|
if(typeLine == "none"){
|
||||||
|
|
|
@ -73,5 +73,5 @@ void VToolSimplePoint::FullUpdateFromFile(){
|
||||||
mx = domElement.attribute("mx", "").toDouble()*PrintDPI/25.4;
|
mx = domElement.attribute("mx", "").toDouble()*PrintDPI/25.4;
|
||||||
my = domElement.attribute("my", "").toDouble()*PrintDPI/25.4;
|
my = domElement.attribute("my", "").toDouble()*PrintDPI/25.4;
|
||||||
}
|
}
|
||||||
RefreshBaseGeometry(name, x, y, mx, my);
|
RefreshGeometry(name, x, y, mx, my);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "../tools/vtoolalongline.h"
|
#include "../tools/vtoolalongline.h"
|
||||||
#include "../tools/vtoolshoulderpoint.h"
|
#include "../tools/vtoolshoulderpoint.h"
|
||||||
#include "../tools/vtoolnormal.h"
|
#include "../tools/vtoolnormal.h"
|
||||||
|
#include "../tools/vtoolbisector.h"
|
||||||
#include "../options.h"
|
#include "../options.h"
|
||||||
#include "../container/calculator.h"
|
#include "../container/calculator.h"
|
||||||
|
|
||||||
|
@ -529,6 +530,47 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(type == "bisector"){
|
||||||
|
if(!domElement.isNull()){
|
||||||
|
QString name, typeLine, formula;
|
||||||
|
qreal mx=5, my=10;
|
||||||
|
qint64 id, firstPointId, secondPointId, thirdPointId;
|
||||||
|
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", "");
|
||||||
|
firstPointId = domElement.attribute("firstPoint", "").toLongLong();
|
||||||
|
secondPointId = domElement.attribute("secondPoint", "").toLongLong();
|
||||||
|
thirdPointId = domElement.attribute("thirdPoint", "").toLongLong();
|
||||||
|
|
||||||
|
VPointF firstPoint = data->GetPoint(firstPointId);
|
||||||
|
VPointF secondPoint = data->GetPoint(secondPointId);
|
||||||
|
VPointF thirdPoint = data->GetPoint(thirdPointId);
|
||||||
|
|
||||||
|
Calculator cal(data);
|
||||||
|
QString errorMsg;
|
||||||
|
qreal result = cal.eval(formula, &errorMsg);
|
||||||
|
if(errorMsg.isEmpty()){
|
||||||
|
QPointF fPoint = VToolBisector::FindPoint(firstPoint, secondPoint, thirdPoint,
|
||||||
|
result*PrintDPI/25.4);
|
||||||
|
data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), name, mx, my));
|
||||||
|
data->AddLine(firstPointId, id);
|
||||||
|
if(parse == Document::FullParse){
|
||||||
|
VToolBisector *point = new VToolBisector(this, data, id, typeLine, formula,
|
||||||
|
firstPointId, secondPointId, thirdPointId,
|
||||||
|
Tool::FromFile);
|
||||||
|
scene->addItem(point);
|
||||||
|
connect(point, &VToolBisector::ChoosedPoint, scene, &VMainGraphicsScene::ChoosedItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user