Add tool line.
This commit is contained in:
parent
9e78a12d62
commit
7c06d2f689
|
@ -28,7 +28,10 @@ SOURCES += main.cpp\
|
|||
widgets/delegate.cpp \
|
||||
widgets/doubledelegate.cpp \
|
||||
dialogs/dialogendline.cpp \
|
||||
tools/vtoolendline.cpp
|
||||
tools/vtoolendline.cpp \
|
||||
tools/vtoolline.cpp \
|
||||
tools/vabstracttool.cpp \
|
||||
dialogs/dialogline.cpp
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
widgets/vmaingraphicsscene.h \
|
||||
|
@ -47,12 +50,16 @@ HEADERS += mainwindow.h \
|
|||
widgets/delegate.h \
|
||||
widgets/doubledelegate.h \
|
||||
dialogs/dialogendline.h \
|
||||
tools/vtoolendline.h
|
||||
tools/vtoolendline.h \
|
||||
tools/vtoolline.h \
|
||||
tools/vabstracttool.h \
|
||||
dialogs/dialogline.h
|
||||
|
||||
FORMS += mainwindow.ui \
|
||||
dialogs/dialogsinglepoint.ui \
|
||||
dialogs/dialogincrements.ui \
|
||||
dialogs/dialogendline.ui
|
||||
dialogs/dialogendline.ui \
|
||||
dialogs/dialogline.ui
|
||||
|
||||
RESOURCES += \
|
||||
icon.qrc \
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
<qresource prefix="/">
|
||||
<file>cursor/spoint_cursor.png</file>
|
||||
<file>cursor/endline_cursor.png</file>
|
||||
<file>cursor/line_cursor.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
BIN
cursor/line_cursor.png
Normal file
BIN
cursor/line_cursor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
110
dialogs/dialogline.cpp
Normal file
110
dialogs/dialogline.cpp
Normal file
|
@ -0,0 +1,110 @@
|
|||
#include "dialogline.h"
|
||||
#include "ui_dialogline.h"
|
||||
#include <QPushButton>
|
||||
#include <QCloseEvent>
|
||||
|
||||
DialogLine::DialogLine(const VContainer *data, QWidget *parent) :
|
||||
QDialog(parent), ui(new Ui::DialogLine)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->data = data;
|
||||
QPushButton *bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||
connect(bOk, &QPushButton::clicked, this, &DialogLine::DialogAccepted);
|
||||
FillComboBox(ui->comboBoxFirstPoint);
|
||||
FillComboBox(ui->comboBoxSecondPoint);
|
||||
number = 0;
|
||||
}
|
||||
|
||||
DialogLine::~DialogLine(){
|
||||
delete ui;
|
||||
}
|
||||
|
||||
qint64 DialogLine::getSecondPoint() const{
|
||||
return secondPoint;
|
||||
}
|
||||
|
||||
void DialogLine::setSecondPoint(const qint64 &value){
|
||||
secondPoint = value;
|
||||
VPointF point = data->GetPoint(value);
|
||||
qint32 index = ui->comboBoxSecondPoint->findText(point.name());
|
||||
if(index != -1){
|
||||
ui->comboBoxSecondPoint->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
qint64 DialogLine::getFirstPoint() const{
|
||||
return firstPoint;
|
||||
}
|
||||
|
||||
void DialogLine::setFirstPoint(const qint64 &value){
|
||||
firstPoint = value;
|
||||
VPointF point = data->GetPoint(value);
|
||||
qint32 index = ui->comboBoxFirstPoint->findText(point.name());
|
||||
if(index != -1){
|
||||
ui->comboBoxFirstPoint->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
void DialogLine::closeEvent(QCloseEvent *event){
|
||||
DialogClosed(QDialog::Rejected);
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void DialogLine::showEvent(QShowEvent *event){
|
||||
QDialog::showEvent( event );
|
||||
if( event->spontaneous() ){
|
||||
return;
|
||||
}
|
||||
|
||||
if(isInitialized){
|
||||
return;
|
||||
}
|
||||
|
||||
// do your init stuff here
|
||||
|
||||
isInitialized = true;//перший показ вікна вже відбувся
|
||||
}
|
||||
|
||||
|
||||
void DialogLine::DialogAccepted(){
|
||||
qint32 index = ui->comboBoxFirstPoint->currentIndex();
|
||||
firstPoint = qvariant_cast<qint64>(ui->comboBoxFirstPoint->itemData(index));
|
||||
index = ui->comboBoxSecondPoint->currentIndex();
|
||||
secondPoint = qvariant_cast<qint64>(ui->comboBoxSecondPoint->itemData(index));
|
||||
DialogClosed(QDialog::Accepted);
|
||||
}
|
||||
|
||||
void DialogLine::FillComboBox(QComboBox *box){
|
||||
const QMap<qint64, VPointF> *points = data->DataPoints();
|
||||
QMapIterator<qint64, VPointF> i(*points);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
VPointF point = i.value();
|
||||
box->addItem(point.name(), i.key());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DialogLine::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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
44
dialogs/dialogline.h
Normal file
44
dialogs/dialogline.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
#ifndef DIALOGLINE_H
|
||||
#define DIALOGLINE_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "../container/vcontainer.h"
|
||||
#include "../options.h"
|
||||
#include <QComboBox>
|
||||
|
||||
namespace Ui {
|
||||
class DialogLine;
|
||||
}
|
||||
|
||||
class DialogLine : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DialogLine(const VContainer *data, QWidget *parent = 0);
|
||||
~DialogLine();
|
||||
|
||||
qint64 getFirstPoint() const;
|
||||
void setFirstPoint(const qint64 &value);
|
||||
|
||||
qint64 getSecondPoint() const;
|
||||
void setSecondPoint(const qint64 &value);
|
||||
signals:
|
||||
void DialogClosed(int result);
|
||||
public slots:
|
||||
void ChoosedPoint(qint64 id, Scene::Type type);
|
||||
void DialogAccepted();
|
||||
protected:
|
||||
void closeEvent ( QCloseEvent * event );
|
||||
void showEvent( QShowEvent *event );
|
||||
private:
|
||||
Ui::DialogLine *ui;
|
||||
const VContainer *data;
|
||||
qint32 number;
|
||||
qint64 firstPoint;
|
||||
qint64 secondPoint;
|
||||
bool isInitialized;
|
||||
void FillComboBox(QComboBox *box);
|
||||
};
|
||||
|
||||
#endif // DIALOGLINE_H
|
92
dialogs/dialogline.ui
Normal file
92
dialogs/dialogline.ui
Normal file
|
@ -0,0 +1,92 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DialogLine</class>
|
||||
<widget class="QDialog" name="DialogLine">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>217</width>
|
||||
<height>137</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="text">
|
||||
<string>Перша точка</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBoxFirstPoint"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Друга точка</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBoxSecondPoint"/>
|
||||
</item>
|
||||
</layout>
|
||||
</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/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>DialogLine</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>DialogLine</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
|
@ -19,5 +19,6 @@
|
|||
<file>icon/24x24/arrowLeft.png</file>
|
||||
<file>icon/24x24/equal.png</file>
|
||||
<file>icon/32x32/segment.png</file>
|
||||
<file>icon/32x32/line.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
BIN
icon/32x32/line.png
Normal file
BIN
icon/32x32/line.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 525 B |
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include "options.h"
|
||||
#include "tools/vtoolendline.h"
|
||||
#include "tools/vtoolline.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent), ui(new Ui::MainWindow)
|
||||
|
@ -43,6 +44,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
connect(ui->actionTable, &QAction::triggered, this, &MainWindow::ActionTable);
|
||||
connect(ui->toolButtonEndLine, &QToolButton::clicked, this,
|
||||
&MainWindow::ToolEndLine);
|
||||
connect(ui->toolButtonLine, &QToolButton::clicked, this,
|
||||
&MainWindow::ToolLine);
|
||||
|
||||
data = new VContainer;
|
||||
CreateManTableIGroup ();
|
||||
|
@ -201,6 +204,36 @@ void MainWindow::ClosedDialogEndLine(int result){
|
|||
ArrowTool();
|
||||
}
|
||||
|
||||
void MainWindow::ToolLine(bool checked){
|
||||
if(checked){
|
||||
CanselTool();
|
||||
tool = Tools::LineTool;
|
||||
QPixmap pixmap(":/cursor/line_cursor.png");
|
||||
QCursor cur(pixmap, 2, 3);
|
||||
ui->graphicsView->setCursor(cur);
|
||||
helpLabel->setText("Виберіть точки.");
|
||||
dialogLine = new DialogLine(data, this);
|
||||
connect(scene, &VMainGraphicsScene::ChoosedObject, dialogLine, &DialogLine::ChoosedPoint);
|
||||
connect(dialogLine, &DialogLine::DialogClosed, this, &MainWindow::ClosedDialogLine);
|
||||
} else {
|
||||
ui->toolButtonLine->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::ClosedDialogLine(int result){
|
||||
if(result == QDialog::Accepted){
|
||||
qint64 firstPoint = dialogLine->getFirstPoint();
|
||||
qint64 secondPoint = dialogLine->getSecondPoint();
|
||||
|
||||
qint64 id = data->getNextId();
|
||||
VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, Tool::FromGui);
|
||||
scene->addItem(line);
|
||||
connect(line, &VToolLine::ChoosedPoint, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
|
||||
}
|
||||
ArrowTool();
|
||||
}
|
||||
|
||||
void MainWindow::showEvent( QShowEvent *event ){
|
||||
QMainWindow::showEvent( event );
|
||||
if( event->spontaneous() ){
|
||||
|
@ -314,6 +347,11 @@ void MainWindow::CanselTool(){
|
|||
ui->toolButtonEndLine->setChecked(false);
|
||||
scene->clearSelection();
|
||||
break;
|
||||
case Tools::LineTool:
|
||||
delete dialogLine;
|
||||
ui->toolButtonLine->setChecked(false);
|
||||
scene->clearFocus();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -576,6 +614,7 @@ void MainWindow::closeEvent ( QCloseEvent * event ){
|
|||
|
||||
void MainWindow::SetEnableTool(bool enable){
|
||||
ui->toolButtonEndLine->setEnabled(enable);
|
||||
ui->toolButtonLine->setEnabled(enable);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow(){
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "widgets/vmaingraphicsscene.h"
|
||||
#include "dialogs/dialogsinglepoint.h"
|
||||
#include "dialogs/dialogincrements.h"
|
||||
#include "dialogs/dialogline.h"
|
||||
#include "tools/vtoolsimplepoint.h"
|
||||
#include "xml/vdomdocument.h"
|
||||
#include "container/vcontainer.h"
|
||||
|
@ -23,7 +24,8 @@ namespace Tools{
|
|||
{
|
||||
ArrowTool,
|
||||
SinglePointTool,
|
||||
EndLineTool
|
||||
EndLineTool,
|
||||
LineTool
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -55,6 +57,8 @@ public slots:
|
|||
void ClosedActionTable();
|
||||
void ToolEndLine(bool checked);
|
||||
void ClosedDialogEndLine(int result);
|
||||
void ToolLine(bool checked);
|
||||
void ClosedDialogLine(int result);
|
||||
protected:
|
||||
virtual void keyPressEvent ( QKeyEvent * event );
|
||||
virtual void showEvent( QShowEvent *event );
|
||||
|
@ -69,6 +73,7 @@ private:
|
|||
DialogSinglePoint *dialogSinglePoint;
|
||||
DialogIncrements *dialogTable;
|
||||
DialogEndLine *dialogEndLine;
|
||||
DialogLine *dialogLine;
|
||||
VDomDocument *doc;
|
||||
VContainer *data;
|
||||
QComboBox *comboBoxDraws;
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page">
|
||||
<property name="geometry">
|
||||
|
@ -159,7 +159,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>154</width>
|
||||
<height>111</height>
|
||||
<height>50</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -173,33 +173,26 @@
|
|||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="pushButton_4">
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<widget class="QToolButton" name="toolButtonLine">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">buttonGroup_2</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="pushButton_5">
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<string>...</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">buttonGroup_2</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QPushButton" name="pushButton_6">
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
<property name="icon">
|
||||
<iconset resource="icon.qrc">
|
||||
<normaloff>:/icon/32x32/line.png</normaloff>:/icon/32x32/line.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">buttonGroup_2</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
62
tools/vabstracttool.cpp
Normal file
62
tools/vabstracttool.cpp
Normal file
|
@ -0,0 +1,62 @@
|
|||
#include "vabstracttool.h"
|
||||
|
||||
VAbstractTool::VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id){
|
||||
this->doc = doc;
|
||||
this->data = data;
|
||||
this->id = id;
|
||||
nameActivDraw = doc->GetNameActivDraw();
|
||||
ignoreContextMenuEvent = false;//don't ignore context menu events;
|
||||
|
||||
connect(this->doc, &VDomDocument::ChangedActivDraw, this, &VAbstractTool::ChangedActivDraw);
|
||||
connect(this->doc, &VDomDocument::ChangedNameDraw, this, &VAbstractTool::ChangedNameDraw);
|
||||
connect(this, &VAbstractTool::haveLiteChange, this->doc, &VDomDocument::haveLiteChange);
|
||||
connect(this->doc, &VDomDocument::FullUpdateFromFile, this, &VAbstractTool::FullUpdateFromFile);
|
||||
}
|
||||
|
||||
void VAbstractTool::ChangedNameDraw(const QString oldName, const QString newName){
|
||||
if(nameActivDraw == oldName){
|
||||
nameActivDraw = newName;
|
||||
}
|
||||
}
|
||||
|
||||
void VAbstractTool::ChangedActivDraw(const QString newName){
|
||||
if(nameActivDraw == newName){
|
||||
ignoreContextMenuEvent = false;
|
||||
} else {
|
||||
ignoreContextMenuEvent = true;
|
||||
}
|
||||
}
|
||||
|
||||
void VAbstractTool::AddAttribute(QDomElement &domElement, const QString &name, const qint64 &value){
|
||||
QDomAttr domAttr = doc->createAttribute(name);
|
||||
domAttr.setValue(QString().setNum(value));
|
||||
domElement.setAttributeNode(domAttr);
|
||||
}
|
||||
|
||||
void VAbstractTool::AddAttribute(QDomElement &domElement, const QString &name, const qint32 &value){
|
||||
QDomAttr domAttr = doc->createAttribute(name);
|
||||
domAttr.setValue(QString().setNum(value));
|
||||
domElement.setAttributeNode(domAttr);
|
||||
}
|
||||
|
||||
void VAbstractTool::AddAttribute(QDomElement &domElement, const QString &name, const qreal &value){
|
||||
QDomAttr domAttr = doc->createAttribute(name);
|
||||
domAttr.setValue(QString().setNum(value));
|
||||
domElement.setAttributeNode(domAttr);
|
||||
}
|
||||
|
||||
void VAbstractTool::AddAttribute(QDomElement &domElement, const QString &name, const QString &value){
|
||||
QDomAttr domAttr = doc->createAttribute(name);
|
||||
domAttr.setValue(value);
|
||||
domElement.setAttributeNode(domAttr);
|
||||
}
|
||||
|
||||
VAbstractTool::~VAbstractTool(){
|
||||
}
|
||||
|
||||
QString VAbstractTool::GetNameLine(qint64 firstPoint, qint64 secondPoint) const{
|
||||
VPointF first = data->GetPoint(firstPoint);
|
||||
VPointF second = data->GetPoint(secondPoint);
|
||||
QString name = QString("Line_%1_%2").arg(first.name(), second.name());
|
||||
return name;
|
||||
}
|
44
tools/vabstracttool.h
Normal file
44
tools/vabstracttool.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
#ifndef VABSTRACTTOOL_H
|
||||
#define VABSTRACTTOOL_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "../container/vcontainer.h"
|
||||
#include "../xml/vdomdocument.h"
|
||||
|
||||
namespace Tool{
|
||||
enum Enum
|
||||
{
|
||||
FromGui,
|
||||
FromFile
|
||||
};
|
||||
}
|
||||
|
||||
class VAbstractTool:public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VAbstractTool(VDomDocument *doc, VContainer *data, qint64 id);
|
||||
virtual ~VAbstractTool();
|
||||
public slots:
|
||||
virtual void FullUpdateFromFile()=0;
|
||||
void ChangedNameDraw(const QString oldName, const QString newName);
|
||||
virtual void ChangedActivDraw(const QString newName);
|
||||
signals:
|
||||
void haveLiteChange();
|
||||
void ChoosedPoint(qint64 id, Scene::Type type);
|
||||
void FullUpdateTree();
|
||||
protected:
|
||||
VDomDocument *doc;
|
||||
VContainer *data;
|
||||
qint64 id;
|
||||
bool ignoreContextMenuEvent;
|
||||
QString nameActivDraw;
|
||||
virtual void AddToFile()=0;
|
||||
void AddAttribute(QDomElement &domElement, const QString &name, const qint64 &value);
|
||||
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(qint64 firstPoint, qint64 secondPoint) const;
|
||||
};
|
||||
#endif // VABSTRACTTOOL_H
|
|
@ -8,7 +8,6 @@ VToolEndLine::VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id
|
|||
const QString &typeLine, const QString &formula, const qint32 &angle,
|
||||
const qint64 &basePointId, Tool::Enum typeCreation,
|
||||
QGraphicsItem *parent):VToolPoint(doc, data, id, parent){
|
||||
ignoreContextMenuEvent = false;//don't ignore context menu events;
|
||||
connect(this, &VToolEndLine::FullUpdateTree, this->doc, &VDomDocument::FullUpdateTree);
|
||||
this->typeLine = typeLine;
|
||||
this->formula = formula;
|
||||
|
@ -48,14 +47,14 @@ void VToolEndLine::FullUpdateFromFile(){
|
|||
basePointId = domElement.attribute("basePoint", "").toLongLong();
|
||||
angle = domElement.attribute("angle", "").toInt();
|
||||
}
|
||||
VPointF point = data->GetPoint(id);
|
||||
VPointF point = VAbstractTool::data->GetPoint(id);
|
||||
RefreshBaseGeometry(name, point.x(), point.y(), mx, my);
|
||||
VPointF basePoint = data->GetPoint(basePointId);
|
||||
VPointF basePoint = VAbstractTool::data->GetPoint(basePointId);
|
||||
mainLine->setLine(QLineF(basePoint.toQPointF(), point.toQPointF()));
|
||||
|
||||
QString nameLine = GetNameLine(basePointId, id);
|
||||
QLineF line = QLineF(basePoint.toQPointF(), point.toQPointF());
|
||||
data->AddLine(nameLine, line.length());
|
||||
VAbstractTool::data->AddLine(nameLine, line.length());
|
||||
}
|
||||
|
||||
void VToolEndLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||
|
@ -64,14 +63,14 @@ void VToolEndLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
|||
QAction *actionOption = menu.addAction("Властивості");
|
||||
QAction *selectedAction = menu.exec(event->screenPos());
|
||||
if(selectedAction == actionOption){
|
||||
dialogEndLine = QSharedPointer<DialogEndLine>(new DialogEndLine(data));
|
||||
dialogEndLine = QSharedPointer<DialogEndLine>(new DialogEndLine(VAbstractTool::data));
|
||||
|
||||
connect(qobject_cast< VMainGraphicsScene * >(this->scene()), &VMainGraphicsScene::ChoosedObject,
|
||||
dialogEndLine.data(), &DialogEndLine::ChoosedPoint);
|
||||
connect(dialogEndLine.data(), &DialogEndLine::DialogClosed, this, &VToolEndLine::ClosedDialogEndLine);
|
||||
connect(doc, &VDomDocument::FullUpdateFromFile, dialogEndLine.data(), &DialogEndLine::UpdateList);
|
||||
|
||||
VPointF p = data->GetPoint(id);
|
||||
VPointF p = VAbstractTool::data->GetPoint(id);
|
||||
|
||||
dialogEndLine->setTypeLine(typeLine);
|
||||
dialogEndLine->setFormula(formula);
|
||||
|
@ -92,9 +91,9 @@ void VToolEndLine::ClosedDialogEndLine(int result){
|
|||
qint32 angle = dialogEndLine->getAngle();
|
||||
qint64 basePointId = dialogEndLine->getBasePointId();
|
||||
|
||||
VPointF basePoint = data->GetPoint(basePointId);
|
||||
VPointF basePoint = VAbstractTool::data->GetPoint(basePointId);
|
||||
QLineF line = QLineF(basePoint.toQPointF(), QPointF(basePoint.x()+100, basePoint.y()));
|
||||
Calculator cal(data);
|
||||
Calculator cal(VAbstractTool::data);
|
||||
QString errorMsg;
|
||||
qreal result = cal.eval(formula, &errorMsg);
|
||||
if(errorMsg.isEmpty()){
|
||||
|
@ -108,8 +107,18 @@ void VToolEndLine::ClosedDialogEndLine(int result){
|
|||
dialogEndLine.clear();
|
||||
}
|
||||
|
||||
void VToolEndLine::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 VToolEndLine::AddToFile(){
|
||||
VPointF point = data->GetPoint(id);
|
||||
VPointF point = VAbstractTool::data->GetPoint(id);
|
||||
QDomElement domElement = doc->createElement("point");
|
||||
|
||||
AddAttribute(domElement, "id", id);
|
||||
|
|
|
@ -17,6 +17,7 @@ public:
|
|||
public slots:
|
||||
virtual void FullUpdateFromFile();
|
||||
void ClosedDialogEndLine(int result);
|
||||
virtual void ChangedActivDraw(const QString newName);
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void AddToFile();
|
||||
|
|
106
tools/vtoolline.cpp
Normal file
106
tools/vtoolline.cpp
Normal file
|
@ -0,0 +1,106 @@
|
|||
#include "vtoolline.h"
|
||||
#include <QMenu>
|
||||
#include <QDebug>
|
||||
|
||||
VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, qint64 secondPoint,
|
||||
Tool::Enum typeCreation):VAbstractTool(doc, data, id){
|
||||
connect(this, &VToolLine::FullUpdateTree, this->doc, &VDomDocument::FullUpdateTree);
|
||||
this->firstPoint = firstPoint;
|
||||
this->secondPoint = secondPoint;
|
||||
|
||||
//Лінія
|
||||
VPointF first = data->GetPoint(firstPoint);
|
||||
VPointF second = data->GetPoint(secondPoint);
|
||||
this->setLine(QLineF(first.toQPointF(), second.toQPointF()));
|
||||
this->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
|
||||
QString nameLine = GetNameLine(firstPoint, secondPoint);
|
||||
data->AddLine(nameLine, QLineF(first.toQPointF(), second.toQPointF()).length());
|
||||
|
||||
if(typeCreation == Tool::FromGui){
|
||||
AddToFile();
|
||||
}
|
||||
}
|
||||
|
||||
void VToolLine::FullUpdateFromFile(){
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if(domElement.isElement()){
|
||||
firstPoint = domElement.attribute("firstPoint", "").toLongLong();
|
||||
secondPoint = domElement.attribute("secondPoint", "").toLongLong();
|
||||
}
|
||||
VPointF first = VAbstractTool::data->GetPoint(firstPoint);
|
||||
VPointF second = VAbstractTool::data->GetPoint(secondPoint);
|
||||
this->setLine(QLineF(first.toQPointF(), second.toQPointF()));
|
||||
QString nameLine = GetNameLine(firstPoint, secondPoint);
|
||||
VAbstractTool::data->AddLine(nameLine, QLineF(first.toQPointF(), second.toQPointF()).length());
|
||||
}
|
||||
|
||||
void VToolLine::ClosedDialogLine(int result){
|
||||
if(result == QDialog::Accepted){
|
||||
qint64 firstPoint = dialogLine->getFirstPoint();
|
||||
qint64 secondPoint = dialogLine->getSecondPoint();
|
||||
FullUpdateFromGui(firstPoint, secondPoint);
|
||||
}
|
||||
dialogLine.clear();
|
||||
}
|
||||
|
||||
void VToolLine::ChangedActivDraw(const QString newName){
|
||||
if(nameActivDraw == newName){
|
||||
this->setPen(QPen(Qt::black, widthHairLine));
|
||||
VAbstractTool::ChangedActivDraw(newName);
|
||||
} else {
|
||||
this->setPen(QPen(Qt::gray, widthHairLine));
|
||||
VAbstractTool::ChangedActivDraw(newName);
|
||||
}
|
||||
}
|
||||
|
||||
void VToolLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
|
||||
if(!ignoreContextMenuEvent){
|
||||
QMenu menu;
|
||||
QAction *actionOption = menu.addAction("Властивості");
|
||||
QAction *selectedAction = menu.exec(event->screenPos());
|
||||
if(selectedAction == actionOption){
|
||||
dialogLine = QSharedPointer<DialogLine>(new DialogLine(VAbstractTool::data));
|
||||
|
||||
connect(qobject_cast< VMainGraphicsScene * >(this->scene()), &VMainGraphicsScene::ChoosedObject,
|
||||
dialogLine.data(), &DialogLine::ChoosedPoint);
|
||||
connect(dialogLine.data(), &DialogLine::DialogClosed, this, &VToolLine::ClosedDialogLine);
|
||||
|
||||
dialogLine->setFirstPoint(firstPoint);
|
||||
dialogLine->setSecondPoint(secondPoint);
|
||||
|
||||
dialogLine->show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void VToolLine::AddToFile(){
|
||||
QDomElement domElement = doc->createElement("line");
|
||||
|
||||
AddAttribute(domElement, "id", id);
|
||||
|
||||
AddAttribute(domElement, "firstPoint", firstPoint);
|
||||
AddAttribute(domElement, "secondPoint", secondPoint);
|
||||
|
||||
QDomElement calcElement;
|
||||
bool ok = doc->GetActivCalculationElement(calcElement);
|
||||
if(ok){
|
||||
calcElement.appendChild(domElement);
|
||||
} else {
|
||||
qCritical()<<"Не можу знайти тег калькуляції."<< Q_FUNC_INFO;
|
||||
}
|
||||
}
|
||||
|
||||
void VToolLine::FullUpdateFromGui(qint64 firstPoint, qint64 secondPoint){
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if(domElement.isElement()){
|
||||
this->firstPoint = firstPoint;
|
||||
this->secondPoint = secondPoint;
|
||||
|
||||
domElement.setAttribute("firstPoint", QString().setNum(firstPoint));
|
||||
domElement.setAttribute("secondPoint", QString().setNum(secondPoint));
|
||||
emit FullUpdateTree();
|
||||
}
|
||||
}
|
28
tools/vtoolline.h
Normal file
28
tools/vtoolline.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
#ifndef VTOOLLINE_H
|
||||
#define VTOOLLINE_H
|
||||
|
||||
#include "vabstracttool.h"
|
||||
#include "QGraphicsLineItem"
|
||||
#include "../dialogs/dialogline.h"
|
||||
|
||||
class VToolLine: public VAbstractTool, public QGraphicsLineItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, qint64 secondPoint,
|
||||
Tool::Enum typeCreation);
|
||||
public slots:
|
||||
virtual void FullUpdateFromFile();
|
||||
void ClosedDialogLine(int result);
|
||||
virtual void ChangedActivDraw(const QString newName);
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void AddToFile();
|
||||
private:
|
||||
qint64 firstPoint;
|
||||
qint64 secondPoint;
|
||||
QSharedPointer<DialogLine> dialogLine;
|
||||
void FullUpdateFromGui(qint64 firstPoint, qint64 secondPoint);
|
||||
};
|
||||
|
||||
#endif // VTOOLLINE_H
|
|
@ -9,12 +9,8 @@
|
|||
#include "../widgets/vmaingraphicsscene.h"
|
||||
|
||||
VToolPoint::VToolPoint(VDomDocument *doc, VContainer *data, qint64 id,
|
||||
QGraphicsItem *parent):QGraphicsEllipseItem(parent){
|
||||
this->doc = doc;
|
||||
this->data = data;
|
||||
QGraphicsItem *parent):VAbstractTool(doc, data, id), QGraphicsEllipseItem(parent){
|
||||
radius = 1.5*PrintDPI/25.4;
|
||||
this->id = id;
|
||||
nameActivDraw = doc->GetNameActivDraw();
|
||||
//create circle
|
||||
VPointF point = data->GetPoint(id);
|
||||
QRectF rec = QRectF(point.x(), point.y(), radius*2, radius*2);
|
||||
|
@ -36,28 +32,23 @@ VToolPoint::VToolPoint(VDomDocument *doc, VContainer *data, qint64 id,
|
|||
QPointF p1, p2;
|
||||
LineIntersectCircle(rec.center(), radius, QLineF(rec.center(), nameRec.center()), p1, p2);
|
||||
QPointF pRec = LineIntersectRect(nameRec, QLineF(rec.center(), nameRec.center()));
|
||||
line = new QGraphicsLineItem(QLineF(p1, pRec), this);
|
||||
line->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||
lineName = new QGraphicsLineItem(QLineF(p1, pRec), this);
|
||||
lineName->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
|
||||
if(QLineF(p1, pRec).length() <= 4*PrintDPI/25.4){
|
||||
line->setVisible(false);
|
||||
lineName->setVisible(false);
|
||||
} else {
|
||||
line->setVisible(true);
|
||||
lineName->setVisible(true);
|
||||
}
|
||||
|
||||
connect(this->doc, &VDomDocument::ChangedActivDraw, this, &VToolPoint::ChangedActivDraw);
|
||||
connect(this->doc, &VDomDocument::ChangedNameDraw, this, &VToolPoint::ChangedNameDraw);
|
||||
connect(this, &VToolPoint::haveLiteChange, this->doc, &VDomDocument::haveLiteChange);
|
||||
connect(this->doc, &VDomDocument::FullUpdateFromFile, this, &VToolPoint::FullUpdateFromFile);
|
||||
}
|
||||
|
||||
void VToolPoint::NameChangePosition(const QPointF pos){
|
||||
VPointF point = data->GetPoint(id);
|
||||
VPointF point = VAbstractTool::data->GetPoint(id);
|
||||
QRectF rec = this->rect();
|
||||
point.setMx(pos.x() - rec.center().x());
|
||||
point.setMy(pos.y() - rec.center().y());
|
||||
RefreshLine();
|
||||
LiteUpdateFromGui(point.mx(), point.my());
|
||||
data->UpdatePoint(id, point);
|
||||
VAbstractTool::data->UpdatePoint(id, point);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -150,11 +141,11 @@ void VToolPoint::RefreshLine(){
|
|||
QRectF rec = this->rect();
|
||||
LineIntersectCircle(rec.center(), radius, QLineF(rec.center(), nameRec.center()), p1, p2);
|
||||
QPointF pRec = LineIntersectRect(nameRec, QLineF(rec.center(), nameRec.center()));
|
||||
line->setLine(QLineF(p1, pRec));
|
||||
lineName->setLine(QLineF(p1, pRec));
|
||||
if(QLineF(p1, pRec).length() <= 4*PrintDPI/25.4){
|
||||
line->setVisible(false);
|
||||
lineName->setVisible(false);
|
||||
} else {
|
||||
line->setVisible(true);
|
||||
lineName->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,12 +158,6 @@ void VToolPoint::LiteUpdateFromGui(qreal mx, qreal my){
|
|||
}
|
||||
}
|
||||
|
||||
void VToolPoint::ChangedNameDraw(const QString oldName, const QString newName){
|
||||
if(nameActivDraw == oldName){
|
||||
nameActivDraw = newName;
|
||||
}
|
||||
}
|
||||
|
||||
void VToolPoint::ChangedActivDraw(const QString newName){
|
||||
if(nameActivDraw == newName){
|
||||
this->setPen(QPen(Qt::black, widthHairLine));
|
||||
|
@ -181,8 +166,8 @@ void VToolPoint::ChangedActivDraw(const QString newName){
|
|||
namePoint->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||
namePoint->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||
namePoint->setBrush(QBrush(Qt::black));
|
||||
line->setPen(QPen(Qt::black, widthHairLine));
|
||||
ignoreContextMenuEvent = false;
|
||||
lineName->setPen(QPen(Qt::black, widthHairLine));
|
||||
VAbstractTool::ChangedActivDraw(newName);
|
||||
} else {
|
||||
this->setPen(QPen(Qt::gray, widthHairLine));
|
||||
this->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||
|
@ -190,8 +175,8 @@ void VToolPoint::ChangedActivDraw(const QString newName){
|
|||
namePoint->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||
namePoint->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
|
||||
namePoint->setBrush(QBrush(Qt::gray));
|
||||
line->setPen(QPen(Qt::gray, widthHairLine));
|
||||
ignoreContextMenuEvent = true;
|
||||
lineName->setPen(QPen(Qt::gray, widthHairLine));
|
||||
VAbstractTool::ChangedActivDraw(newName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,30 +187,6 @@ void VToolPoint::mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ){
|
|||
QGraphicsItem::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void VToolPoint::AddAttribute(QDomElement &domElement, const QString &name, const qint64 &value){
|
||||
QDomAttr domAttr = doc->createAttribute(name);
|
||||
domAttr.setValue(QString().setNum(value));
|
||||
domElement.setAttributeNode(domAttr);
|
||||
}
|
||||
|
||||
void VToolPoint::AddAttribute(QDomElement &domElement, const QString &name, const qint32 &value){
|
||||
QDomAttr domAttr = doc->createAttribute(name);
|
||||
domAttr.setValue(QString().setNum(value));
|
||||
domElement.setAttributeNode(domAttr);
|
||||
}
|
||||
|
||||
void VToolPoint::AddAttribute(QDomElement &domElement, const QString &name, const qreal &value){
|
||||
QDomAttr domAttr = doc->createAttribute(name);
|
||||
domAttr.setValue(QString().setNum(value));
|
||||
domElement.setAttributeNode(domAttr);
|
||||
}
|
||||
|
||||
void VToolPoint::AddAttribute(QDomElement &domElement, const QString &name, const QString &value){
|
||||
QDomAttr domAttr = doc->createAttribute(name);
|
||||
domAttr.setValue(value);
|
||||
domElement.setAttributeNode(domAttr);
|
||||
}
|
||||
|
||||
void VToolPoint::RefreshBaseGeometry(const QString &name, const qreal &x, const qreal &y, const qreal &mx,
|
||||
const qreal &my){
|
||||
QRectF rec = QRectF(x, y, radius*2, radius*2);
|
||||
|
@ -239,13 +200,6 @@ void VToolPoint::RefreshBaseGeometry(const QString &name, const qreal &x, const
|
|||
RefreshLine();
|
||||
}
|
||||
|
||||
QString VToolPoint::GetNameLine(qint64 firstPoint, qint64 secondPoint) const{
|
||||
VPointF first = data->GetPoint(firstPoint);
|
||||
VPointF second = data->GetPoint(secondPoint);
|
||||
QString name = QString("Line_%1_%2").arg(first.name(), second.name());
|
||||
return name;
|
||||
}
|
||||
|
||||
VToolPoint::~VToolPoint(){
|
||||
|
||||
}
|
||||
|
|
|
@ -5,19 +5,10 @@
|
|||
#include <QGraphicsLineItem>
|
||||
|
||||
#include "../widgets/vgraphicssimpletextitem.h"
|
||||
#include "../container/vcontainer.h"
|
||||
#include "../xml/vdomdocument.h"
|
||||
#include "../options.h"
|
||||
#include "vabstracttool.h"
|
||||
|
||||
namespace Tool{
|
||||
enum Enum
|
||||
{
|
||||
FromGui,
|
||||
FromFile
|
||||
};
|
||||
}
|
||||
|
||||
class VToolPoint: public QObject, public QGraphicsEllipseItem
|
||||
class VToolPoint: public VAbstractTool, public QGraphicsEllipseItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -26,30 +17,14 @@ public:
|
|||
public slots:
|
||||
void NameChangePosition(const QPointF pos);
|
||||
virtual void ChangedActivDraw(const QString newName);
|
||||
virtual void FullUpdateFromFile()=0;
|
||||
void ChangedNameDraw(const QString oldName, const QString newName);
|
||||
signals:
|
||||
void haveLiteChange();
|
||||
void ChoosedPoint(qint64 id, Scene::Type type);
|
||||
void FullUpdateTree();
|
||||
protected:
|
||||
qreal radius;
|
||||
VDomDocument *doc;
|
||||
VContainer *data;
|
||||
VGraphicsSimpleTextItem *namePoint;
|
||||
QGraphicsLineItem *line;
|
||||
qint64 id;
|
||||
QString nameActivDraw;
|
||||
bool ignoreContextMenuEvent;
|
||||
virtual void AddToFile()=0;
|
||||
QGraphicsLineItem *lineName;
|
||||
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
||||
void AddAttribute(QDomElement &domElement, const QString &name, const qint64 &value);
|
||||
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);
|
||||
void RefreshBaseGeometry(const QString &name, const qreal &x, const qreal &y,
|
||||
const qreal &mx, const qreal &my);
|
||||
QString GetNameLine(qint64 firstPoint, qint64 secondPoint) const;
|
||||
|
||||
private:
|
||||
qint32 LineIntersectCircle(QPointF center, qreal radius, QLineF line, QPointF &p1,
|
||||
QPointF &p2) const;
|
||||
|
|
|
@ -21,7 +21,7 @@ VToolSimplePoint::VToolSimplePoint (VDomDocument *doc, VContainer *data, qint64
|
|||
}
|
||||
|
||||
void VToolSimplePoint::AddToFile(){
|
||||
VPointF point = data->GetPoint(id);
|
||||
VPointF point = VAbstractTool::data->GetPoint(id);
|
||||
QDomElement domElement = doc->createElement("point");
|
||||
|
||||
AddAttribute(domElement, "id", id);
|
||||
|
@ -58,7 +58,7 @@ void VToolSimplePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event
|
|||
QAction *selectedAction = menu.exec(event->screenPos());
|
||||
if(selectedAction == actionOption){
|
||||
DialogSinglePoint *dialogSinglePoint = new DialogSinglePoint;
|
||||
VPointF p = data->GetPoint(id);
|
||||
VPointF p = VAbstractTool::data->GetPoint(id);
|
||||
dialogSinglePoint->setData(p.name(), p.toQPointF());
|
||||
qint32 result = dialogSinglePoint->exec();
|
||||
if(result == QDialog::Accepted){
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "../tools/vtoolsimplepoint.h"
|
||||
#include "../tools/vtoolendline.h"
|
||||
#include "../tools/vtoolline.h"
|
||||
#include "../options.h"
|
||||
#include "../container/calculator.h"
|
||||
|
||||
|
@ -336,6 +337,9 @@ void VDomDocument::ParseCalculationElement(VMainGraphicsScene *scene, const QDom
|
|||
if(domElement.tagName() == "point"){
|
||||
ParsePointElement(scene, domElement, parse, domElement.attribute("type", ""));
|
||||
}
|
||||
if(domElement.tagName() == "line"){
|
||||
ParseLineElement(scene, domElement, parse);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -402,6 +406,24 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
|
|||
}
|
||||
}
|
||||
|
||||
void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement,
|
||||
Document::Enum parse){
|
||||
if(!domElement.isNull()){
|
||||
qint64 firstPoint;
|
||||
qint64 secondPoint;
|
||||
if(!domElement.isNull()){
|
||||
firstPoint = domElement.attribute("firstPoint", "").toLongLong();
|
||||
secondPoint = domElement.attribute("secondPoint", "").toLongLong();
|
||||
if(parse == Document::FullParse){
|
||||
qint64 id = data->getNextId();
|
||||
VToolLine *line = new VToolLine(this, data, id, firstPoint, secondPoint, Tool::FromFile);
|
||||
scene->addItem(line);
|
||||
connect(line, &VToolLine::ChoosedPoint, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VDomDocument::FullUpdateTree(){
|
||||
VMainGraphicsScene *scene = new VMainGraphicsScene();
|
||||
QComboBox *comboBoxDraws = new QComboBox();
|
||||
|
|
|
@ -57,6 +57,8 @@ private:
|
|||
Document::Enum parse);
|
||||
void ParsePointElement(VMainGraphicsScene *scene, const QDomElement& domElement,
|
||||
Document::Enum parse, const QString &type);
|
||||
void ParseLineElement(VMainGraphicsScene *scene, const QDomElement& domElement,
|
||||
Document::Enum parse);
|
||||
void ParseIncrementsElement(const QDomNode& node);
|
||||
void AddNewDraw(const QDomElement &node, QComboBox *comboBoxDraws)const;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user