Add tool Normal
This commit is contained in:
parent
8942991d29
commit
af95762c09
|
@ -36,7 +36,9 @@ SOURCES += main.cpp\
|
|||
dialogs/dialogtool.cpp \
|
||||
dialogs/dialogalongline.cpp \
|
||||
tools/vtoolshoulderpoint.cpp \
|
||||
dialogs/dialogshoulderpoint.cpp
|
||||
dialogs/dialogshoulderpoint.cpp \
|
||||
tools/vtoolnormal.cpp \
|
||||
dialogs/dialognormal.cpp
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
widgets/vmaingraphicsscene.h \
|
||||
|
@ -63,7 +65,9 @@ HEADERS += mainwindow.h \
|
|||
dialogs/dialogtool.h \
|
||||
dialogs/dialogalongline.h \
|
||||
tools/vtoolshoulderpoint.h \
|
||||
dialogs/dialogshoulderpoint.h
|
||||
dialogs/dialogshoulderpoint.h \
|
||||
tools/vtoolnormal.h \
|
||||
dialogs/dialognormal.h
|
||||
|
||||
FORMS += mainwindow.ui \
|
||||
dialogs/dialogsinglepoint.ui \
|
||||
|
@ -71,7 +75,8 @@ FORMS += mainwindow.ui \
|
|||
dialogs/dialogendline.ui \
|
||||
dialogs/dialogline.ui \
|
||||
dialogs/dialogalongline.ui \
|
||||
dialogs/dialogshoulderpoint.ui
|
||||
dialogs/dialogshoulderpoint.ui \
|
||||
dialogs/dialognormal.ui
|
||||
|
||||
RESOURCES += \
|
||||
icon.qrc \
|
||||
|
|
|
@ -176,6 +176,7 @@ qreal Calculator::find_var(QString s){
|
|||
bool ok = false;
|
||||
qreal value = data->FindVar(s, &ok);
|
||||
if(!ok){
|
||||
qDebug()<<s;
|
||||
serror(4); /* не переменная */
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -175,6 +175,19 @@ const QMap<QString, qreal> *VContainer::DataLengthLines() const{
|
|||
return &lengthLines;
|
||||
}
|
||||
|
||||
void VContainer::AddLine(const qint64 &firstPointId, const qint64 &secondPointId){
|
||||
QString nameLine = GetNameLine(firstPointId, secondPointId);
|
||||
VPointF firstPoint = GetPoint(firstPointId);
|
||||
VPointF secondPoint = GetPoint(secondPointId);
|
||||
AddLine(nameLine, QLineF(firstPoint.toQPointF(), secondPoint.toQPointF()).length());
|
||||
}
|
||||
|
||||
QString VContainer::GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint) const{
|
||||
VPointF first = GetPoint(firstPoint);
|
||||
VPointF second = GetPoint(secondPoint);
|
||||
return QString("Line_%1_%2").arg(first.name(), second.name());
|
||||
}
|
||||
|
||||
void VContainer::AddLine(const QString &name, const qreal &value){
|
||||
Q_ASSERT(!name.isEmpty());
|
||||
lengthLines[name] = value/PrintDPI*25.4;
|
||||
|
|
|
@ -21,6 +21,8 @@ public:
|
|||
void AddStandartTableCell(const QString& name, const VStandartTableCell& cell);
|
||||
void AddIncrementTableRow(const QString& name, const VIncrementTableRow &cell);
|
||||
void AddLine(const QString &name, const qreal &value);
|
||||
void AddLine(const qint64 &firstPointId, const qint64 &secondPointId);
|
||||
QString GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint) const;
|
||||
void UpdatePoint(qint64 id, const VPointF& point);
|
||||
void UpdateStandartTableCell(const QString& name, const VStandartTableCell& cell);
|
||||
void UpdateIncrementTableRow(const QString& name, const VIncrementTableRow& cell);
|
||||
|
@ -41,8 +43,7 @@ public:
|
|||
const QMap<QString, qint32> *DataBase() const;
|
||||
const QMap<QString, VStandartTableCell> *DataStandartTable() const;
|
||||
const QMap<QString, VIncrementTableRow> *DataIncrementTable() const;
|
||||
const QMap<QString, qreal> * DataLengthLines() const;
|
||||
|
||||
const QMap<QString, qreal> * DataLengthLines() const;
|
||||
private:
|
||||
qint64 _id;
|
||||
QMap<QString, qint32> base;
|
||||
|
|
|
@ -5,5 +5,6 @@
|
|||
<file>cursor/line_cursor.png</file>
|
||||
<file>cursor/alongline_cursor.png</file>
|
||||
<file>cursor/shoulder_cursor.png</file>
|
||||
<file>cursor/normal_cursor.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
BIN
cursor/normal_cursor.png
Normal file
BIN
cursor/normal_cursor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
153
dialogs/dialognormal.cpp
Normal file
153
dialogs/dialognormal.cpp
Normal file
|
@ -0,0 +1,153 @@
|
|||
#include "dialognormal.h"
|
||||
#include "ui_dialognormal.h"
|
||||
#include <QMenu>
|
||||
|
||||
DialogNormal::DialogNormal(const VContainer *data, QWidget *parent) :
|
||||
DialogTool(data, parent), ui(new Ui::DialogNormal)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
number = 0;
|
||||
spinBoxAngle = ui->spinBoxAngle;
|
||||
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, &DialogNormal::DialogAccepted);
|
||||
flagName = false;
|
||||
CheckState();
|
||||
QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
|
||||
connect(bCansel, &QPushButton::clicked, this, &DialogNormal::DialogRejected);
|
||||
FillComboBoxPoints(ui->comboBoxFirstPoint);
|
||||
FillComboBoxPoints(ui->comboBoxSecondPoint);
|
||||
FillComboBoxTypeLine(ui->comboBoxLineType);
|
||||
|
||||
connect(ui->toolButtonArrowDown, &QPushButton::clicked, this,
|
||||
&DialogNormal::ArrowDown);
|
||||
connect(ui->toolButtonArrowUp, &QPushButton::clicked, this,
|
||||
&DialogNormal::ArrowUp);
|
||||
connect(ui->toolButtonArrowLeft, &QPushButton::clicked, this,
|
||||
&DialogNormal::ArrowLeft);
|
||||
connect(ui->toolButtonArrowRight, &QPushButton::clicked, this,
|
||||
&DialogNormal::ArrowRight);
|
||||
connect(ui->toolButtonArrowLeftUp, &QPushButton::clicked, this,
|
||||
&DialogNormal::ArrowLeftUp);
|
||||
connect(ui->toolButtonArrowLeftDown, &QPushButton::clicked, this,
|
||||
&DialogNormal::ArrowLeftDown);
|
||||
connect(ui->toolButtonArrowRightUp, &QPushButton::clicked, this,
|
||||
&DialogNormal::ArrowRightUp);
|
||||
connect(ui->toolButtonArrowRightDown, &QPushButton::clicked, this,
|
||||
&DialogNormal::ArrowRightDown);
|
||||
connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogNormal::PutHere);
|
||||
connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogNormal::PutVal);
|
||||
connect(ui->listWidget, &QListWidget::currentRowChanged, this, &DialogNormal::ValChenged);
|
||||
|
||||
ShowBase();
|
||||
connect(ui->radioButtonSizeGrowth, &QRadioButton::clicked, this, &DialogNormal::SizeGrowth);
|
||||
connect(ui->radioButtonStandartTable, &QRadioButton::clicked, this, &DialogNormal::StandartTable);
|
||||
connect(ui->radioButtonIncrements, &QRadioButton::clicked, this, &DialogNormal::Increments);
|
||||
connect(ui->radioButtonLengthLine, &QRadioButton::clicked, this, &DialogNormal::LengthLines);
|
||||
connect(ui->toolButtonEqual, &QPushButton::clicked, this, &DialogNormal::EvalFormula);
|
||||
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogNormal::NamePointChanged);
|
||||
connect(ui->lineEditFormula, &QLineEdit::textChanged, this, &DialogNormal::FormulaChanged);
|
||||
}
|
||||
|
||||
DialogNormal::~DialogNormal()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void DialogNormal::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 = 0;
|
||||
}
|
||||
if(!isInitialized){
|
||||
this->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DialogNormal::DialogAccepted(){
|
||||
pointName = ui->lineEditNamePoint->text();
|
||||
typeLine = GetTypeLine(ui->comboBoxLineType);
|
||||
formula = ui->lineEditFormula->text();
|
||||
angle = ui->spinBoxAngle->value();
|
||||
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));
|
||||
emit DialogClosed(QDialog::Accepted);
|
||||
}
|
||||
|
||||
qint64 DialogNormal::getSecondPointId() const{
|
||||
return secondPointId;
|
||||
}
|
||||
|
||||
void DialogNormal::setSecondPointId(const qint64 &value){
|
||||
secondPointId = value;
|
||||
ChangeCurrentData(ui->comboBoxSecondPoint, value);
|
||||
}
|
||||
|
||||
qint64 DialogNormal::getFirstPointId() const{
|
||||
return firstPointId;
|
||||
}
|
||||
|
||||
void DialogNormal::setFirstPointId(const qint64 &value){
|
||||
firstPointId = value;
|
||||
ChangeCurrentData(ui->comboBoxFirstPoint, value);
|
||||
}
|
||||
|
||||
qint32 DialogNormal::getAngle() const{
|
||||
return angle;
|
||||
}
|
||||
|
||||
void DialogNormal::setAngle(const qint32 &value){
|
||||
angle = value;
|
||||
ui->spinBoxAngle->setValue(angle);
|
||||
}
|
||||
|
||||
QString DialogNormal::getFormula() const{
|
||||
return formula;
|
||||
}
|
||||
|
||||
void DialogNormal::setFormula(const QString &value){
|
||||
formula = value;
|
||||
ui->lineEditFormula->setText(formula);
|
||||
}
|
||||
|
||||
QString DialogNormal::getTypeLine() const{
|
||||
return typeLine;
|
||||
}
|
||||
|
||||
void DialogNormal::setTypeLine(const QString &value){
|
||||
typeLine = value;
|
||||
SetupTypeLine(ui->comboBoxLineType, value);
|
||||
}
|
||||
|
||||
QString DialogNormal::getPointName() const{
|
||||
return pointName;
|
||||
}
|
||||
|
||||
void DialogNormal::setPointName(const QString &value){
|
||||
pointName = value;
|
||||
ui->lineEditNamePoint->setText(pointName);
|
||||
}
|
49
dialogs/dialognormal.h
Normal file
49
dialogs/dialognormal.h
Normal file
|
@ -0,0 +1,49 @@
|
|||
#ifndef DIALOGNORMAL_H
|
||||
#define DIALOGNORMAL_H
|
||||
|
||||
#include "dialogtool.h"
|
||||
#include <QPushButton>
|
||||
#include <QListWidgetItem>
|
||||
#include <QTimer>
|
||||
|
||||
#include "../options.h"
|
||||
#include "../container/vcontainer.h"
|
||||
#include "../container/calculator.h"
|
||||
|
||||
namespace Ui {
|
||||
class DialogNormal;
|
||||
}
|
||||
|
||||
class DialogNormal : public DialogTool
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DialogNormal(const VContainer *data, QWidget *parent = 0);
|
||||
~DialogNormal();
|
||||
QString getPointName() const;
|
||||
void setPointName(const QString &value);
|
||||
QString getTypeLine() const;
|
||||
void setTypeLine(const QString &value);
|
||||
QString getFormula() const;
|
||||
void setFormula(const QString &value);
|
||||
qint32 getAngle() const;
|
||||
void setAngle(const qint32 &value);
|
||||
qint64 getFirstPointId() const;
|
||||
void setFirstPointId(const qint64 &value);
|
||||
qint64 getSecondPointId() const;
|
||||
void setSecondPointId(const qint64 &value);
|
||||
public slots:
|
||||
virtual void ChoosedPoint(qint64 id, Scene::Type type);
|
||||
virtual void DialogAccepted();
|
||||
private:
|
||||
Ui::DialogNormal *ui;
|
||||
qint32 number;
|
||||
QString pointName;
|
||||
QString typeLine;
|
||||
QString formula;
|
||||
qint32 angle;
|
||||
qint64 firstPointId;
|
||||
qint64 secondPointId;
|
||||
};
|
||||
|
||||
#endif // DIALOGNORMAL_H
|
510
dialogs/dialognormal.ui
Normal file
510
dialogs/dialognormal.ui
Normal file
|
@ -0,0 +1,510 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DialogNormal</class>
|
||||
<widget class="QDialog" name="DialogNormal">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>488</width>
|
||||
<height>594</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_8">
|
||||
<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="comboBoxSecondPoint"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Додатковий кут градуси</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinimumSize</enum>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>29</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="toolButtonArrowRightUp">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icon.qrc">
|
||||
<normaloff>:/icon/24x24/arrowRightUp.png</normaloff>:/icon/24x24/arrowRightUp.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QToolButton" name="toolButtonArrowLeftUp">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icon.qrc">
|
||||
<normaloff>:/icon/24x24/arrowLeftUp.png</normaloff>:/icon/24x24/arrowLeftUp.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QToolButton" name="toolButtonArrowLeft">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icon.qrc">
|
||||
<normaloff>:/icon/24x24/arrowLeft.png</normaloff>:/icon/24x24/arrowLeft.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QToolButton" name="toolButtonArrowRight">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icon.qrc">
|
||||
<normaloff>:/icon/24x24/arrowRight.png</normaloff>:/icon/24x24/arrowRight.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QToolButton" name="toolButtonArrowUp">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icon.qrc">
|
||||
<normaloff>:/icon/24x24/arrowUp.png</normaloff>:/icon/24x24/arrowUp.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QToolButton" name="toolButtonArrowDown">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icon.qrc">
|
||||
<normaloff>:/icon/24x24/arrowDown.png</normaloff>:/icon/24x24/arrowDown.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QToolButton" name="toolButtonArrowLeftDown">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icon.qrc">
|
||||
<normaloff>:/icon/24x24/arrowLeftDown.png</normaloff>:/icon/24x24/arrowLeftDown.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QToolButton" name="toolButtonArrowRightDown">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icon.qrc">
|
||||
<normaloff>:/icon/24x24/arrowRightDown.png</normaloff>:/icon/24x24/arrowRightDown.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spinBoxAngle">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>52</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>360</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</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>DialogNormal</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>DialogNormal</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
|
@ -22,5 +22,6 @@
|
|||
<file>icon/32x32/line.png</file>
|
||||
<file>icon/32x32/along_line.png</file>
|
||||
<file>icon/32x32/shoulder.png</file>
|
||||
<file>icon/32x32/normal.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
BIN
icon/32x32/normal.png
Normal file
BIN
icon/32x32/normal.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 754 B |
|
@ -15,6 +15,7 @@
|
|||
#include "tools/vtoolline.h"
|
||||
#include "tools/vtoolalongline.h"
|
||||
#include "tools/vtoolshoulderpoint.h"
|
||||
#include "tools/vtoolnormal.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent), ui(new Ui::MainWindow)
|
||||
|
@ -52,6 +53,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
&MainWindow::ToolAlongLine);
|
||||
connect(ui->toolButtonShoulderPoint, &QToolButton::clicked, this,
|
||||
&MainWindow::ToolShoulderPoint);
|
||||
connect(ui->toolButtonNormal, &QToolButton::clicked, this,
|
||||
&MainWindow::ToolNormal);
|
||||
|
||||
data = new VContainer;
|
||||
CreateManTableIGroup ();
|
||||
|
@ -198,6 +201,7 @@ void MainWindow::ClosedDialogEndLine(int result){
|
|||
line.setLength(result*PrintDPI/25.4);
|
||||
line.setAngle(angle);
|
||||
qint64 id = data->AddPoint(VPointF(line.p2().x(), line.p2().y(), pointName, 5, 10));
|
||||
data->AddLine(basePointId, id);
|
||||
VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, formula, angle, basePointId,
|
||||
Tool::FromGui);
|
||||
scene->addItem(point);
|
||||
|
@ -229,6 +233,7 @@ void MainWindow::ClosedDialogLine(int result){
|
|||
qint64 firstPoint = dialogLine->getFirstPoint();
|
||||
qint64 secondPoint = dialogLine->getSecondPoint();
|
||||
|
||||
data->AddLine(firstPoint, secondPoint);
|
||||
qint64 id = data->getNextId();
|
||||
VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, Tool::FromGui);
|
||||
scene->addItem(line);
|
||||
|
@ -271,6 +276,8 @@ void MainWindow::ClosedDialogAlongLine(int result){
|
|||
if(errorMsg.isEmpty()){
|
||||
line.setLength(result*PrintDPI/25.4);
|
||||
qint64 id = data->AddPoint(VPointF(line.p2().x(), line.p2().y(), pointName, 5, 10));
|
||||
data->AddLine(firstPointId, id);
|
||||
data->AddLine(id, secondPointId);
|
||||
VToolAlongLine *point = new VToolAlongLine(doc, data, id, formula, firstPointId, secondPointId,
|
||||
typeLine, Tool::FromGui);
|
||||
scene->addItem(point);
|
||||
|
@ -318,6 +325,8 @@ void MainWindow::ClosedDialogShoulderPoint(int result){
|
|||
QPointF fPoint = VToolShoulderPoint::FindPoint(firstPoint, secondPoint, shoulderPoint,
|
||||
result*PrintDPI/25.4);
|
||||
qint64 id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, 5, 10));
|
||||
data->AddLine(p1Line, id);
|
||||
data->AddLine(p2Line, id);
|
||||
VToolShoulderPoint *point = new VToolShoulderPoint(doc, data, id, typeLine, formula, p1Line,
|
||||
p2Line, pShoulder, Tool::FromGui);
|
||||
scene->addItem(point);
|
||||
|
@ -327,6 +336,53 @@ void MainWindow::ClosedDialogShoulderPoint(int result){
|
|||
ArrowTool();
|
||||
}
|
||||
|
||||
void MainWindow::ToolNormal(bool checked){
|
||||
if(checked){
|
||||
CanselTool();
|
||||
tool = Tools::NormalTool;
|
||||
QPixmap pixmap(":/cursor/normal_cursor.png");
|
||||
QCursor cur(pixmap, 2, 3);
|
||||
ui->graphicsView->setCursor(cur);
|
||||
helpLabel->setText("Виберіть точки.");
|
||||
dialogNormal = new DialogNormal(data, this);
|
||||
connect(scene, &VMainGraphicsScene::ChoosedObject, dialogNormal,
|
||||
&DialogNormal::ChoosedPoint);
|
||||
connect(dialogNormal, &DialogNormal::DialogClosed, this,
|
||||
&MainWindow::ClosedDialogNormal);
|
||||
} else {
|
||||
ui->toolButtonNormal->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::ClosedDialogNormal(int result){
|
||||
if(result == QDialog::Accepted){
|
||||
QString formula = dialogNormal->getFormula();
|
||||
qint64 firstPointId = dialogNormal->getFirstPointId();
|
||||
qint64 secondPointId = dialogNormal->getSecondPointId();
|
||||
QString typeLine = dialogNormal->getTypeLine();
|
||||
QString pointName = dialogNormal->getPointName();
|
||||
qint32 angle = dialogNormal->getAngle();
|
||||
|
||||
VPointF firstPoint = data->GetPoint(firstPointId);
|
||||
VPointF secondPoint = data->GetPoint(secondPointId);
|
||||
|
||||
Calculator cal(data);
|
||||
QString errorMsg;
|
||||
qreal result = cal.eval(formula, &errorMsg);
|
||||
if(errorMsg.isEmpty()){
|
||||
QPointF fPoint = VToolNormal::FindPoint(firstPoint, secondPoint, result*PrintDPI/25.4,
|
||||
angle);
|
||||
qint64 id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, 5, 10));
|
||||
data->AddLine(firstPointId, id);
|
||||
VToolNormal *point = new VToolNormal(doc, data, id, typeLine, formula, angle, firstPointId,
|
||||
secondPointId, Tool::FromGui);
|
||||
scene->addItem(point);
|
||||
connect(point, &VToolNormal::ChoosedPoint, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
}
|
||||
}
|
||||
ArrowTool();
|
||||
}
|
||||
|
||||
void MainWindow::showEvent( QShowEvent *event ){
|
||||
QMainWindow::showEvent( event );
|
||||
if( event->spontaneous() ){
|
||||
|
@ -459,6 +515,12 @@ void MainWindow::CanselTool(){
|
|||
scene->setFocus(Qt::OtherFocusReason);
|
||||
scene->clearSelection();
|
||||
break;
|
||||
case Tools::NormalTool:
|
||||
delete dialogNormal;
|
||||
ui->toolButtonNormal->setChecked(false);
|
||||
scene->setFocus(Qt::OtherFocusReason);
|
||||
scene->clearSelection();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -718,6 +780,7 @@ void MainWindow::SetEnableTool(bool enable){
|
|||
ui->toolButtonLine->setEnabled(enable);
|
||||
ui->toolButtonAlongLine->setEnabled(enable);
|
||||
ui->toolButtonShoulderPoint->setEnabled(enable);
|
||||
ui->toolButtonNormal->setEnabled(enable);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow(){
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "dialogs/dialogalongline.h"
|
||||
#include "dialogs/dialogshoulderpoint.h"
|
||||
#include "dialogs/dialogendline.h"
|
||||
#include "dialogs/dialognormal.h"
|
||||
#include "tools/vtoolsimplepoint.h"
|
||||
#include "xml/vdomdocument.h"
|
||||
#include "container/vcontainer.h"
|
||||
|
@ -30,7 +31,8 @@ namespace Tools{
|
|||
EndLineTool,
|
||||
LineTool,
|
||||
AlongLineTool,
|
||||
ShoulderPointTool
|
||||
ShoulderPointTool,
|
||||
NormalTool
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -67,6 +69,8 @@ public slots:
|
|||
void ClosedDialogAlongLine(int result);
|
||||
void ToolShoulderPoint(bool checked);
|
||||
void ClosedDialogShoulderPoint(int result);
|
||||
void ToolNormal(bool checked);
|
||||
void ClosedDialogNormal(int result);
|
||||
protected:
|
||||
virtual void keyPressEvent ( QKeyEvent * event );
|
||||
virtual void showEvent( QShowEvent *event );
|
||||
|
@ -83,6 +87,7 @@ private:
|
|||
DialogLine *dialogLine;
|
||||
DialogAlongLine *dialogAlongLine;
|
||||
DialogShoulderPoint *dialogShoulderPoint;
|
||||
DialogNormal *dialogNormal;
|
||||
VDomDocument *doc;
|
||||
VContainer *data;
|
||||
QComboBox *comboBoxDraws;
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>156</width>
|
||||
<height>81</height>
|
||||
<height>104</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -78,29 +78,6 @@
|
|||
<string>Точка</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="3">
|
||||
<widget class="QToolButton" name="toolButtonShoulderPoint">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</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>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QToolButton" name="toolButtonEndLine">
|
||||
<property name="enabled">
|
||||
|
@ -115,8 +92,8 @@
|
|||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
|
@ -138,8 +115,8 @@
|
|||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
|
@ -167,8 +144,8 @@
|
|||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
|
@ -177,10 +154,49 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QToolButton" name="toolButton_4">
|
||||
<widget class="QToolButton" name="toolButtonNormal">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icon.qrc">
|
||||
<normaloff>:/icon/32x32/normal.png</normaloff>:/icon/32x32/normal.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QToolButton" name="toolButtonShoulderPoint">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</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>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -56,19 +56,6 @@ void VAbstractTool::AddAttribute(QDomElement &domElement, const QString &name, c
|
|||
VAbstractTool::~VAbstractTool(){
|
||||
}
|
||||
|
||||
QString VAbstractTool::GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint) const{
|
||||
VPointF first = data->GetPoint(firstPoint);
|
||||
VPointF second = data->GetPoint(secondPoint);
|
||||
return QString("Line_%1_%2").arg(first.name(), second.name());
|
||||
}
|
||||
|
||||
void VAbstractTool::AddLine(const qint64 &firstPointId, const qint64 &secondPointId) const{
|
||||
QString nameLine = GetNameLine(firstPointId, secondPointId);
|
||||
VPointF firstPoint = data->GetPoint(firstPointId);
|
||||
VPointF secondPoint = data->GetPoint(secondPointId);
|
||||
data->AddLine(nameLine, QLineF(firstPoint.toQPointF(), secondPoint.toQPointF()).length());
|
||||
}
|
||||
|
||||
void VAbstractTool::AddToCalculation(const QDomElement &domElement){
|
||||
QDomElement calcElement;
|
||||
bool ok = doc->GetActivCalculationElement(calcElement);
|
||||
|
|
|
@ -40,8 +40,6 @@ protected:
|
|||
void AddAttribute(QDomElement &domElement, const QString &name, const qint32 &value);
|
||||
void AddAttribute(QDomElement &domElement, const QString &name, const qreal &value);
|
||||
void AddAttribute(QDomElement &domElement, const QString &name, const QString &value);
|
||||
QString GetNameLine(const qint64 &firstPoint, const qint64 &secondPoint) const;
|
||||
void AddLine(const qint64 &firstPointId, const qint64 &secondPointId) const;
|
||||
void AddToCalculation(const QDomElement &domElement);
|
||||
};
|
||||
#endif // VABSTRACTTOOL_H
|
||||
|
|
|
@ -30,9 +30,6 @@ VToolAlongLine::VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, c
|
|||
mainLine->setVisible(true);
|
||||
}
|
||||
|
||||
AddLine(firstPointId, id);
|
||||
AddLine(id, secondPointId);
|
||||
|
||||
if(typeCreation == Tool::FromGui){
|
||||
AddToFile();
|
||||
}
|
||||
|
@ -57,9 +54,11 @@ void VToolAlongLine::FullUpdateFromFile(){
|
|||
VPointF firstPoint = VAbstractTool::data->GetPoint(firstPointId);
|
||||
VPointF secondPoint = VAbstractTool::data->GetPoint(secondPointId);
|
||||
mainLine->setLine(QLineF(firstPoint.toQPointF(), secondPoint.toQPointF()));
|
||||
|
||||
AddLine(firstPointId, id);
|
||||
AddLine(id, secondPointId);
|
||||
if(typeLine == "none"){
|
||||
mainLine->setVisible(false);
|
||||
} else {
|
||||
mainLine->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
void VToolAlongLine::FullUpdateFromGui(int result){
|
||||
|
|
|
@ -17,6 +17,7 @@ VToolEndLine::VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id
|
|||
VPointF basePoint = data->GetPoint(basePointId);
|
||||
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);
|
||||
|
@ -24,8 +25,6 @@ VToolEndLine::VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id
|
|||
mainLine->setVisible(true);
|
||||
}
|
||||
|
||||
AddLine(basePointId, id);
|
||||
|
||||
if(typeCreation == Tool::FromGui){
|
||||
AddToFile();
|
||||
}
|
||||
|
@ -48,8 +47,11 @@ void VToolEndLine::FullUpdateFromFile(){
|
|||
RefreshBaseGeometry(name, point.x(), point.y(), mx, my);
|
||||
VPointF basePoint = VAbstractTool::data->GetPoint(basePointId);
|
||||
mainLine->setLine(QLineF(basePoint.toQPointF(), point.toQPointF()));
|
||||
|
||||
AddLine(basePointId, id);
|
||||
if(typeLine == "none"){
|
||||
mainLine->setVisible(false);
|
||||
} else {
|
||||
mainLine->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
void VToolEndLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||
|
|
|
@ -16,8 +16,6 @@ VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firs
|
|||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
this->setAcceptHoverEvents(true);
|
||||
|
||||
AddLine(firstPoint, secondPoint);
|
||||
|
||||
if(typeCreation == Tool::FromGui){
|
||||
AddToFile();
|
||||
}
|
||||
|
@ -32,7 +30,6 @@ void VToolLine::FullUpdateFromFile(){
|
|||
VPointF first = VAbstractTool::data->GetPoint(firstPoint);
|
||||
VPointF second = VAbstractTool::data->GetPoint(secondPoint);
|
||||
this->setLine(QLineF(first.toQPointF(), second.toQPointF()));
|
||||
AddLine(firstPoint, secondPoint);
|
||||
}
|
||||
|
||||
void VToolLine::FullUpdateFromGui(int result){
|
||||
|
|
137
tools/vtoolnormal.cpp
Normal file
137
tools/vtoolnormal.cpp
Normal file
|
@ -0,0 +1,137 @@
|
|||
#include "vtoolnormal.h"
|
||||
#include <QMenu>
|
||||
|
||||
VToolNormal::VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
|
||||
const QString &formula, const qint32 &angle, const qint64 &firstPointId,
|
||||
const qint64 &secondPointId, Tool::Enum typeCreation, QGraphicsItem *parent):
|
||||
VToolPoint(doc, data, id, parent){
|
||||
this->typeLine = typeLine;
|
||||
this->formula = formula;
|
||||
this->angle = angle;
|
||||
this->firstPointId = firstPointId;
|
||||
this->secondPointId = secondPointId;
|
||||
|
||||
//Лінія, що з'єднує дві точки
|
||||
VPointF firstPoint = data->GetPoint(firstPointId);
|
||||
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);
|
||||
}
|
||||
|
||||
if(typeCreation == Tool::FromGui){
|
||||
AddToFile();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QPointF VToolNormal::FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const qreal &length,
|
||||
const qint32 &angle){
|
||||
QLineF line(firstPoint, secondPoint);
|
||||
QLineF normal = line.normalVector();
|
||||
normal.setAngle(normal.angle()+angle);
|
||||
normal.setLength(length);
|
||||
return normal.p2();
|
||||
}
|
||||
|
||||
void VToolNormal::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();
|
||||
angle = domElement.attribute("angle", "").toInt();
|
||||
}
|
||||
VPointF point = VAbstractTool::data->GetPoint(id);
|
||||
RefreshBaseGeometry(name, point.x(), point.y(), mx, my);
|
||||
VPointF firstPoint = VAbstractTool::data->GetPoint(firstPointId);
|
||||
mainLine->setLine(QLineF(firstPoint.toQPointF(), point.toQPointF()));
|
||||
if(typeLine == "none"){
|
||||
mainLine->setVisible(false);
|
||||
} else {
|
||||
mainLine->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
void VToolNormal::FullUpdateFromGui(int result){
|
||||
if(result == QDialog::Accepted){
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if(domElement.isElement()){
|
||||
domElement.setAttribute("name", dialogNormal->getPointName());
|
||||
domElement.setAttribute("typeLine", dialogNormal->getTypeLine());
|
||||
domElement.setAttribute("length", dialogNormal->getFormula());
|
||||
domElement.setAttribute("angle", QString().setNum(dialogNormal->getAngle()));
|
||||
domElement.setAttribute("firstPoint", QString().setNum(dialogNormal->getFirstPointId()));
|
||||
domElement.setAttribute("secondPoint", QString().setNum(dialogNormal->getSecondPointId()));
|
||||
emit FullUpdateTree();
|
||||
}
|
||||
}
|
||||
dialogNormal.clear();
|
||||
}
|
||||
|
||||
void VToolNormal::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 VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||
if(!ignoreContextMenuEvent){
|
||||
QMenu menu;
|
||||
QAction *actionOption = menu.addAction("Властивості");
|
||||
QAction *selectedAction = menu.exec(event->screenPos());
|
||||
if(selectedAction == actionOption){
|
||||
dialogNormal = QSharedPointer<DialogNormal>(new DialogNormal(VAbstractTool::data));
|
||||
|
||||
connect(qobject_cast< VMainGraphicsScene * >(this->scene()), &VMainGraphicsScene::ChoosedObject,
|
||||
dialogNormal.data(), &DialogNormal::ChoosedPoint);
|
||||
connect(dialogNormal.data(), &DialogNormal::DialogClosed, this,
|
||||
&VToolNormal::FullUpdateFromGui);
|
||||
connect(doc, &VDomDocument::FullUpdateFromFile, dialogNormal.data(), &DialogNormal::UpdateList);
|
||||
|
||||
VPointF p = VAbstractTool::data->GetPoint(id);
|
||||
|
||||
dialogNormal->setTypeLine(typeLine);
|
||||
dialogNormal->setFormula(formula);
|
||||
dialogNormal->setAngle(angle);
|
||||
dialogNormal->setFirstPointId(firstPointId);
|
||||
dialogNormal->setSecondPointId(secondPointId);
|
||||
dialogNormal->setPointName(p.name());
|
||||
|
||||
dialogNormal->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VToolNormal::AddToFile(){
|
||||
VPointF point = VAbstractTool::data->GetPoint(id);
|
||||
QDomElement domElement = doc->createElement("point");
|
||||
|
||||
AddAttribute(domElement, "id", id);
|
||||
AddAttribute(domElement, "type", "normal");
|
||||
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, "angle", angle);
|
||||
AddAttribute(domElement, "firstPoint", firstPointId);
|
||||
AddAttribute(domElement, "secondPoint", firstPointId);
|
||||
|
||||
AddToCalculation(domElement);
|
||||
}
|
36
tools/vtoolnormal.h
Normal file
36
tools/vtoolnormal.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#ifndef VTOOLNORMAL_H
|
||||
#define VTOOLNORMAL_H
|
||||
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include "vtoolpoint.h"
|
||||
#include "../dialogs/dialognormal.h"
|
||||
|
||||
class VToolNormal : public VToolPoint
|
||||
{
|
||||
public:
|
||||
VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||
const QString &typeLine, const QString &formula,
|
||||
const qint32 &angle, const qint64 &firstPointId,
|
||||
const qint64 &secondPointId, Tool::Enum typeCreation,
|
||||
QGraphicsItem * parent = 0);
|
||||
static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint,
|
||||
const qreal &length, const qint32 &angle = 0);
|
||||
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;
|
||||
qint32 angle;
|
||||
qint64 firstPointId;
|
||||
qint64 secondPointId;
|
||||
QGraphicsLineItem *mainLine;
|
||||
QSharedPointer<DialogNormal> dialogNormal;
|
||||
};
|
||||
|
||||
#endif // VTOOLNORMAL_H
|
|
@ -23,9 +23,6 @@ VToolShoulderPoint::VToolShoulderPoint(VDomDocument *doc, VContainer *data, cons
|
|||
mainLine->setVisible(true);
|
||||
}
|
||||
|
||||
AddLine(p1Line, id);
|
||||
AddLine(p2Line, id);
|
||||
|
||||
if(typeCreation == Tool::FromGui){
|
||||
AddToFile();
|
||||
}
|
||||
|
@ -76,9 +73,6 @@ void VToolShoulderPoint::FullUpdateFromFile(){
|
|||
} else {
|
||||
mainLine->setVisible(true);
|
||||
}
|
||||
|
||||
AddLine(p1Line, id);
|
||||
AddLine(p2Line, id);
|
||||
}
|
||||
|
||||
void VToolShoulderPoint::FullUpdateFromGui(int result){
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "../tools/vtoolline.h"
|
||||
#include "../tools/vtoolalongline.h"
|
||||
#include "../tools/vtoolshoulderpoint.h"
|
||||
#include "../tools/vtoolnormal.h"
|
||||
#include "../options.h"
|
||||
#include "../container/calculator.h"
|
||||
|
||||
|
@ -397,6 +398,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
|
|||
line.setLength(result*PrintDPI/25.4);
|
||||
line.setAngle(angle);
|
||||
data->UpdatePoint(id, VPointF(line.p2().x(), line.p2().y(), name, mx, my));
|
||||
data->AddLine(basePointId, id);
|
||||
if(parse == Document::FullParse){
|
||||
VToolEndLine *point = new VToolEndLine(this, data, id, typeLine, formula, angle,
|
||||
basePointId, Tool::FromFile);
|
||||
|
@ -433,6 +435,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
|
|||
if(errorMsg.isEmpty()){
|
||||
line.setLength(result*PrintDPI/25.4);
|
||||
data->UpdatePoint(id, VPointF(line.p2().x(), line.p2().y(), name, mx, my));
|
||||
data->AddLine(firstPointId, id);
|
||||
data->AddLine(id, secondPointId);
|
||||
if(parse == Document::FullParse){
|
||||
VToolAlongLine *point = new VToolAlongLine(this, data, id, formula, firstPointId,
|
||||
secondPointId, typeLine, Tool::FromGui);
|
||||
|
@ -472,6 +476,8 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
|
|||
QPointF fPoint = VToolShoulderPoint::FindPoint(firstPoint, secondPoint, shoulderPoint,
|
||||
result*PrintDPI/25.4);
|
||||
data->UpdatePoint(id,VPointF(fPoint.x(), fPoint.y(), name, mx, my));
|
||||
data->AddLine(p1Line, id);
|
||||
data->AddLine(p2Line, id);
|
||||
if(parse == Document::FullParse){
|
||||
VToolShoulderPoint *point = new VToolShoulderPoint(this, data, id, typeLine, formula,
|
||||
p1Line, p2Line, pShoulder,
|
||||
|
@ -485,6 +491,44 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
|
|||
}
|
||||
return;
|
||||
}
|
||||
if(type == "normal"){
|
||||
if(!domElement.isNull()){
|
||||
QString name, typeLine, formula;
|
||||
qreal mx=5, my=10, angle;
|
||||
qint64 id, firstPointId, secondPointId;
|
||||
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();
|
||||
angle = domElement.attribute("angle", "").toInt();
|
||||
|
||||
VPointF firstPoint = data->GetPoint(firstPointId);
|
||||
VPointF secondPoint = data->GetPoint(secondPointId);
|
||||
Calculator cal(data);
|
||||
QString errorMsg;
|
||||
qreal result = cal.eval(formula, &errorMsg);
|
||||
if(errorMsg.isEmpty()){
|
||||
QPointF fPoint = VToolNormal::FindPoint(firstPoint, secondPoint, result*PrintDPI/25.4,
|
||||
angle);
|
||||
data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), name, mx, my));
|
||||
data->AddLine(firstPointId, id);
|
||||
if(parse == Document::FullParse){
|
||||
VToolNormal *point = new VToolNormal(this, data, id, typeLine, formula, angle,
|
||||
firstPointId, secondPointId, Tool::FromFile);
|
||||
scene->addItem(point);
|
||||
connect(point, &VToolNormal::ChoosedPoint, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
||||
|
@ -495,6 +539,7 @@ void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement
|
|||
if(!domElement.isNull()){
|
||||
firstPoint = domElement.attribute("firstPoint", "").toLongLong();
|
||||
secondPoint = domElement.attribute("secondPoint", "").toLongLong();
|
||||
data->AddLine(firstPoint, secondPoint);
|
||||
if(parse == Document::FullParse){
|
||||
qint64 id = data->getNextId();
|
||||
VToolLine *line = new VToolLine(this, data, id, firstPoint, secondPoint, Tool::FromFile);
|
||||
|
|
Loading…
Reference in New Issue
Block a user