diff --git a/Valentina.pro b/Valentina.pro
index bc52781cc..09a9a93aa 100644
--- a/Valentina.pro
+++ b/Valentina.pro
@@ -40,7 +40,10 @@ SOURCES += main.cpp\
tools/vtoolnormal.cpp \
dialogs/dialognormal.cpp \
tools/vtoolbisector.cpp \
- dialogs/dialogbisector.cpp
+ dialogs/dialogbisector.cpp \
+ tools/vtoollinepoint.cpp \
+ tools/vtoollineintersect.cpp \
+ dialogs/dialoglineintersect.cpp
HEADERS += mainwindow.h \
widgets/vmaingraphicsscene.h \
@@ -71,7 +74,10 @@ HEADERS += mainwindow.h \
tools/vtoolnormal.h \
dialogs/dialognormal.h \
tools/vtoolbisector.h \
- dialogs/dialogbisector.h
+ dialogs/dialogbisector.h \
+ tools/vtoollinepoint.h \
+ tools/vtoollineintersect.h \
+ dialogs/dialoglineintersect.h
FORMS += mainwindow.ui \
dialogs/dialogsinglepoint.ui \
@@ -81,7 +87,8 @@ FORMS += mainwindow.ui \
dialogs/dialogalongline.ui \
dialogs/dialogshoulderpoint.ui \
dialogs/dialognormal.ui \
- dialogs/dialogbisector.ui
+ dialogs/dialogbisector.ui \
+ dialogs/dialoglineintersect.ui
RESOURCES += \
icon.qrc \
diff --git a/cursor.qrc b/cursor.qrc
index 8a10af051..b0c81b9d3 100644
--- a/cursor.qrc
+++ b/cursor.qrc
@@ -7,5 +7,6 @@
cursor/shoulder_cursor.png
cursor/normal_cursor.png
cursor/bisector_cursor.png
+ cursor/intersect_cursor.png
diff --git a/cursor/intersect_cursor.png b/cursor/intersect_cursor.png
new file mode 100644
index 000000000..9cf79f26a
Binary files /dev/null and b/cursor/intersect_cursor.png differ
diff --git a/dialogs/dialoglineintersect.cpp b/dialogs/dialoglineintersect.cpp
new file mode 100644
index 000000000..5f681cb0c
--- /dev/null
+++ b/dialogs/dialoglineintersect.cpp
@@ -0,0 +1,188 @@
+#include "dialoglineintersect.h"
+#include "ui_dialoglineintersect.h"
+
+DialogLineIntersect::DialogLineIntersect(const VContainer *data, QWidget *parent) :
+ DialogTool(data, parent), ui(new Ui::DialogLineIntersect)
+{
+ ui->setupUi(this);
+ number = 0;
+ bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
+ connect(bOk, &QPushButton::clicked, this, &DialogLineIntersect::DialogAccepted);
+ flagName = false;
+ flagPoint = true;
+ QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel);
+ connect(bCansel, &QPushButton::clicked, this, &DialogLineIntersect::DialogRejected);
+ FillComboBoxPoints(ui->comboBoxP1Line1);
+ FillComboBoxPoints(ui->comboBoxP2Line1);
+ FillComboBoxPoints(ui->comboBoxP1Line2);
+ FillComboBoxPoints(ui->comboBoxP2Line2);
+
+ connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogLineIntersect::NamePointChanged);
+}
+
+DialogLineIntersect::~DialogLineIntersect()
+{
+ delete ui;
+}
+
+void DialogLineIntersect::ChoosedPoint(qint64 id, Scene::Type type){
+ if(type == Scene::Point){
+ VPointF point = data->GetPoint(id);
+ if(number == 0){
+ qint32 index = ui->comboBoxP1Line1->findText(point.name());
+ if ( index != -1 ) { // -1 for not found
+ ui->comboBoxP1Line1->setCurrentIndex(index);
+ p1Line1 = id;
+ number++;
+ return;
+ }
+ }
+ if(number == 1){
+ qint32 index = ui->comboBoxP2Line1->findText(point.name());
+ if ( index != -1 ) { // -1 for not found
+ ui->comboBoxP2Line1->setCurrentIndex(index);
+ p2Line1 = id;
+ number++;
+ return;
+ }
+ }
+ if(number == 2){
+ qint32 index = ui->comboBoxP1Line2->findText(point.name());
+ if ( index != -1 ) { // -1 for not found
+ ui->comboBoxP1Line2->setCurrentIndex(index);
+ p1Line2 = id;
+ number++;
+ return;
+ }
+ }
+ if(number == 3){
+ qint32 index = ui->comboBoxP2Line2->findText(point.name());
+ if ( index != -1 ) { // -1 for not found
+ ui->comboBoxP2Line2->setCurrentIndex(index);
+ p2Line2 = id;
+ number = 0;
+ }
+ if(!isInitialized){
+ flagPoint = CheckIntersecion();
+ CheckState();
+ this->show();
+ connect(ui->comboBoxP1Line1,
+ static_cast(&QComboBox::currentIndexChanged), this,
+ &DialogLineIntersect::P1Line1Changed);
+ connect(ui->comboBoxP2Line1,
+ static_cast(&QComboBox::currentIndexChanged), this,
+ &DialogLineIntersect::P2Line1Changed);
+ connect(ui->comboBoxP1Line2,
+ static_cast(&QComboBox::currentIndexChanged), this,
+ &DialogLineIntersect::P1Line2Changed);
+ connect(ui->comboBoxP2Line2,
+ static_cast(&QComboBox::currentIndexChanged), this,
+ &DialogLineIntersect::P2Line2Changed);
+ }
+ }
+ }
+}
+
+void DialogLineIntersect::DialogAccepted(){
+ pointName = ui->lineEditNamePoint->text();
+ qint32 index = ui->comboBoxP1Line1->currentIndex();
+ p1Line1 = qvariant_cast(ui->comboBoxP1Line1->itemData(index));
+ index = ui->comboBoxP2Line1->currentIndex();
+ p2Line1 = qvariant_cast(ui->comboBoxP2Line1->itemData(index));
+ index = ui->comboBoxP1Line2->currentIndex();
+ p1Line2 = qvariant_cast(ui->comboBoxP1Line2->itemData(index));
+ index = ui->comboBoxP2Line2->currentIndex();
+ p2Line2 = qvariant_cast(ui->comboBoxP2Line2->itemData(index));
+ emit DialogClosed(QDialog::Accepted);
+}
+
+void DialogLineIntersect::P1Line1Changed( int index){
+ p1Line1 = qvariant_cast(ui->comboBoxP1Line1->itemData(index));
+ flagPoint = CheckIntersecion();
+ CheckState();
+}
+
+void DialogLineIntersect::P2Line1Changed(int index){
+ p2Line1 = qvariant_cast(ui->comboBoxP2Line1->itemData(index));
+ flagPoint = CheckIntersecion();
+ CheckState();
+}
+
+void DialogLineIntersect::P1Line2Changed(int index){
+ p1Line2 = qvariant_cast(ui->comboBoxP1Line2->itemData(index));
+ flagPoint = CheckIntersecion();
+ CheckState();
+}
+
+void DialogLineIntersect::P2Line2Changed(int index){
+ p2Line2 = qvariant_cast(ui->comboBoxP2Line2->itemData(index));
+ flagPoint = CheckIntersecion();
+ CheckState();
+}
+
+void DialogLineIntersect::CheckState(){
+ Q_CHECK_PTR(bOk);
+ bOk->setEnabled(flagName & flagPoint);
+}
+
+bool DialogLineIntersect::CheckIntersecion(){
+ VPointF p1L1 = data->GetPoint(p1Line1);
+ VPointF p2L1 = data->GetPoint(p2Line1);
+ VPointF p1L2 = data->GetPoint(p1Line2);
+ VPointF p2L2 = data->GetPoint(p2Line2);
+
+ QLineF line1(p1L1, p2L1);
+ QLineF line2(p1L2, p2L2);
+ QPointF fPoint;
+ QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
+ if(intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection){
+ return true;
+ } else {
+ return false;
+ }
+}
+
+qint64 DialogLineIntersect::getP2Line2() const{
+ return p2Line2;
+}
+
+void DialogLineIntersect::setP2Line2(const qint64 &value){
+ p2Line2 = value;
+ ChangeCurrentData(ui->comboBoxP2Line2, value);
+}
+
+qint64 DialogLineIntersect::getP1Line2() const{
+ return p1Line2;
+}
+
+void DialogLineIntersect::setP1Line2(const qint64 &value){
+ p1Line2 = value;
+ ChangeCurrentData(ui->comboBoxP1Line2, value);
+}
+
+qint64 DialogLineIntersect::getP2Line1() const{
+ return p2Line1;
+}
+
+void DialogLineIntersect::setP2Line1(const qint64 &value){
+ p2Line1 = value;
+ ChangeCurrentData(ui->comboBoxP2Line1, value);
+}
+
+qint64 DialogLineIntersect::getP1Line1() const{
+ return p1Line1;
+}
+
+void DialogLineIntersect::setP1Line1(const qint64 &value){
+ p1Line1 = value;
+ ChangeCurrentData(ui->comboBoxP1Line1, value);
+}
+
+QString DialogLineIntersect::getPointName() const{
+ return pointName;
+}
+
+void DialogLineIntersect::setPointName(const QString &value){
+ pointName = value;
+ ui->lineEditNamePoint->setText(pointName);
+}
diff --git a/dialogs/dialoglineintersect.h b/dialogs/dialoglineintersect.h
new file mode 100644
index 000000000..d7354804f
--- /dev/null
+++ b/dialogs/dialoglineintersect.h
@@ -0,0 +1,46 @@
+#ifndef DIALOGLINEINTERSECT_H
+#define DIALOGLINEINTERSECT_H
+
+#include "dialogtool.h"
+
+namespace Ui {
+class DialogLineIntersect;
+}
+
+class DialogLineIntersect : public DialogTool
+{
+ Q_OBJECT
+public:
+ explicit DialogLineIntersect(const VContainer *data, QWidget *parent = 0);
+ ~DialogLineIntersect();
+ qint64 getP1Line1() const;
+ void setP1Line1(const qint64 &value);
+ qint64 getP2Line1() const;
+ void setP2Line1(const qint64 &value);
+ qint64 getP1Line2() const;
+ void setP1Line2(const qint64 &value);
+ qint64 getP2Line2() const;
+ void setP2Line2(const qint64 &value);
+ QString getPointName() const;
+ void setPointName(const QString &value);
+public slots:
+ virtual void ChoosedPoint(qint64 id, Scene::Type type);
+ virtual void DialogAccepted();
+ void P1Line1Changed( int index);
+ void P2Line1Changed( int index);
+ void P1Line2Changed( int index);
+ void P2Line2Changed( int index);
+private:
+ Ui::DialogLineIntersect *ui;
+ qint32 number;
+ QString pointName;
+ qint64 p1Line1;
+ qint64 p2Line1;
+ qint64 p1Line2;
+ qint64 p2Line2;
+ bool flagPoint;
+ virtual void CheckState();
+ bool CheckIntersecion();
+};
+
+#endif // DIALOGLINEINTERSECT_H
diff --git a/dialogs/dialoglineintersect.ui b/dialogs/dialoglineintersect.ui
new file mode 100644
index 000000000..3e4c8c06c
--- /dev/null
+++ b/dialogs/dialoglineintersect.ui
@@ -0,0 +1,158 @@
+
+
+ DialogLineIntersect
+
+
+
+ 0
+ 0
+ 366
+ 196
+
+
+
+ Dialog
+
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Ім'я нової точки
+
+
+
+ -
+
+
+
+
+ -
+
+
+ Перша лінія
+
+
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Перша точка
+
+
+
+ -
+
+
+ -
+
+
+ Друга точка
+
+
+
+ -
+
+
+
+
+ -
+
+
+ Друга лінія
+
+
+
+ -
+
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Перша точка
+
+
+
+ -
+
+
+ -
+
+
+ Друга точка
+
+
+
+ -
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+
+
+
+
+
+ buttonBox
+ accepted()
+ DialogLineIntersect
+ accept()
+
+
+ 248
+ 254
+
+
+ 157
+ 274
+
+
+
+
+ buttonBox
+ rejected()
+ DialogLineIntersect
+ reject()
+
+
+ 316
+ 260
+
+
+ 286
+ 274
+
+
+
+
+
diff --git a/dialogs/dialogtool.h b/dialogs/dialogtool.h
index a8d8acde3..afb2f049e 100644
--- a/dialogs/dialogtool.h
+++ b/dialogs/dialogtool.h
@@ -64,7 +64,7 @@ protected:
void showEvent( QShowEvent *event );
void FillComboBoxPoints(QComboBox *box)const;
void FillComboBoxTypeLine(QComboBox *box) const;
- void CheckState();
+ virtual void CheckState();
QString GetTypeLine(const QComboBox *box)const;
void ShowBase();
void ShowStandartTable();
diff --git a/icon.qrc b/icon.qrc
index 726cb42d5..c0924d234 100644
--- a/icon.qrc
+++ b/icon.qrc
@@ -24,5 +24,6 @@
icon/32x32/shoulder.png
icon/32x32/normal.png
icon/32x32/bisector.png
+ icon/32x32/intersect.png
diff --git a/icon/32x32/intersect.png b/icon/32x32/intersect.png
new file mode 100644
index 000000000..3d70690d9
Binary files /dev/null and b/icon/32x32/intersect.png differ
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 6676eec4a..da9f72d7b 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -17,6 +17,7 @@
#include "tools/vtoolshoulderpoint.h"
#include "tools/vtoolnormal.h"
#include "tools/vtoolbisector.h"
+#include "tools/vtoollineintersect.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), ui(new Ui::MainWindow)
@@ -58,6 +59,8 @@ MainWindow::MainWindow(QWidget *parent) :
&MainWindow::ToolNormal);
connect(ui->toolButtonBisector, &QToolButton::clicked, this,
&MainWindow::ToolBisector);
+ connect(ui->toolButtonLineIntersect, &QToolButton::clicked, this,
+ &MainWindow::ToolLineIntersect);
data = new VContainer;
CreateManTableIGroup ();
@@ -434,6 +437,57 @@ void MainWindow::ClosedDialogBisector(int result){
ArrowTool();
}
+void MainWindow::ToolLineIntersect(bool checked){
+ if(checked){
+ CanselTool();
+ tool = Tools::LineIntersectTool;
+ QPixmap pixmap(":/cursor/intersect_cursor.png");
+ QCursor cur(pixmap, 2, 3);
+ ui->graphicsView->setCursor(cur);
+ helpLabel->setText("Виберіть точки.");
+ dialogLineIntersect = new DialogLineIntersect(data, this);
+ connect(scene, &VMainGraphicsScene::ChoosedObject, dialogLineIntersect,
+ &DialogLineIntersect::ChoosedPoint);
+ connect(dialogLineIntersect, &DialogLineIntersect::DialogClosed, this,
+ &MainWindow::ClosedDialogLineIntersect);
+ } else {
+ ui->toolButtonLineIntersect->setChecked(true);
+ }
+}
+
+void MainWindow::ClosedDialogLineIntersect(int result){
+ if(result == QDialog::Accepted){
+ qint64 p1Line1Id = dialogLineIntersect->getP1Line1();
+ qint64 p2Line1Id = dialogLineIntersect->getP2Line1();
+ qint64 p1Line2Id = dialogLineIntersect->getP1Line2();
+ qint64 p2Line2Id = dialogLineIntersect->getP2Line2();
+ QString pointName = dialogLineIntersect->getPointName();
+
+ VPointF p1Line1 = data->GetPoint(p1Line1Id);
+ VPointF p2Line1 = data->GetPoint(p2Line1Id);
+ VPointF p1Line2 = data->GetPoint(p1Line2Id);
+ VPointF p2Line2 = data->GetPoint(p2Line2Id);
+
+ QLineF line1(p1Line1, p2Line1);
+ QLineF line2(p1Line2, p2Line2);
+ QPointF fPoint;
+ QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
+ if(intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection){
+ qint64 id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, 5, 10));
+ data->AddLine(p1Line1Id, id);
+ data->AddLine(id, p2Line1Id);
+ data->AddLine(p1Line2Id, id);
+ data->AddLine(id, p2Line2Id);
+ VToolLineIntersect *point = new VToolLineIntersect(doc, data, id, p1Line1Id,
+ p2Line1Id, p1Line2Id,
+ p2Line2Id, Tool::FromFile);
+ scene->addItem(point);
+ connect(point, &VToolLineIntersect::ChoosedPoint, scene, &VMainGraphicsScene::ChoosedItem);
+ }
+ }
+ ArrowTool();
+}
+
void MainWindow::showEvent( QShowEvent *event ){
QMainWindow::showEvent( event );
if( event->spontaneous() ){
@@ -578,6 +632,12 @@ void MainWindow::CanselTool(){
scene->setFocus(Qt::OtherFocusReason);
scene->clearSelection();
break;
+ case Tools::LineIntersectTool:
+ delete dialogLineIntersect;
+ ui->toolButtonLineIntersect->setChecked(false);
+ scene->setFocus(Qt::OtherFocusReason);
+ scene->clearSelection();
+ break;
}
}
@@ -839,6 +899,7 @@ void MainWindow::SetEnableTool(bool enable){
ui->toolButtonShoulderPoint->setEnabled(enable);
ui->toolButtonNormal->setEnabled(enable);
ui->toolButtonBisector->setEnabled(enable);
+ ui->toolButtonLineIntersect->setEnabled(enable);
}
MainWindow::~MainWindow(){
diff --git a/mainwindow.h b/mainwindow.h
index 473ddd8b5..b8fe64ed0 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -16,6 +16,7 @@
#include "dialogs/dialogendline.h"
#include "dialogs/dialognormal.h"
#include "dialogs/dialogbisector.h"
+#include "dialogs/dialoglineintersect.h"
#include "tools/vtoolsimplepoint.h"
#include "xml/vdomdocument.h"
#include "container/vcontainer.h"
@@ -34,7 +35,8 @@ namespace Tools{
AlongLineTool,
ShoulderPointTool,
NormalTool,
- BisectorTool
+ BisectorTool,
+ LineIntersectTool
};
}
@@ -75,6 +77,8 @@ public slots:
void ClosedDialogNormal(int result);
void ToolBisector(bool checked);
void ClosedDialogBisector(int result);
+ void ToolLineIntersect(bool checked);
+ void ClosedDialogLineIntersect(int result);
protected:
virtual void keyPressEvent ( QKeyEvent * event );
virtual void showEvent( QShowEvent *event );
@@ -93,6 +97,7 @@ private:
DialogShoulderPoint *dialogShoulderPoint;
DialogNormal *dialogNormal;
DialogBisector *dialogBisector;
+ DialogLineIntersect *dialogLineIntersect;
VDomDocument *doc;
VContainer *data;
QComboBox *comboBoxDraws;
diff --git a/mainwindow.ui b/mainwindow.ui
index 74f0fda7e..046190653 100644
--- a/mainwindow.ui
+++ b/mainwindow.ui
@@ -57,7 +57,7 @@
- 0
+ 1
@@ -230,7 +230,7 @@
0
0
154
- 50
+ 58
@@ -257,8 +257,31 @@
- 24
- 24
+ 32
+ 32
+
+
+
+ true
+
+
+
+ -
+
+
+ false
+
+
+ ...
+
+
+
+ :/icon/32x32/intersect.png:/icon/32x32/intersect.png
+
+
+
+ 32
+ 32
diff --git a/tools/vtoolalongline.cpp b/tools/vtoolalongline.cpp
index f3164d081..77edbda41 100644
--- a/tools/vtoolalongline.cpp
+++ b/tools/vtoolalongline.cpp
@@ -7,68 +7,24 @@
VToolAlongLine::VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, const QString &formula,
const qint64 &firstPointId, const qint64 &secondPointId,
const QString &typeLine, Tool::Enum typeCreation,
- QGraphicsItem *parent):VToolPoint(doc, data, id, parent){
- this->typeLine = typeLine;
- this->formula = formula;
- this->firstPointId = firstPointId;
+ QGraphicsItem *parent):
+ VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, 0, parent){
this->secondPointId = secondPointId;
- //Лінія, якщо потрібно.
- VPointF firstPoint = data->GetPoint(firstPointId);
- VPointF secondPoint = data->GetPoint(secondPointId);
- QLineF line = QLineF(firstPoint.toQPointF(), secondPoint.toQPointF());
- Calculator cal(data);
- QString errorMsg;
- qreal result = cal.eval(formula, &errorMsg);
- if(errorMsg.isEmpty()){
- line.setLength(result*PrintDPI/25.4);
- mainLine = new QGraphicsLineItem(line, this);
- mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
- if(typeLine == "none"){
- mainLine->setVisible(false);
- } else {
- mainLine->setVisible(true);
- }
-
- if(typeCreation == Tool::FromGui){
- AddToFile();
- }
+ if(typeCreation == Tool::FromGui){
+ AddToFile();
}
}
void VToolAlongLine::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();
+ basePointId = domElement.attribute("firstPoint", "").toLongLong();
secondPointId = domElement.attribute("secondPoint", "").toLongLong();
}
- VPointF point = VAbstractTool::data->GetPoint(id);
- RefreshGeometry(name, point.x(), point.y(), mx, my);
- VPointF firstPoint = VAbstractTool::data->GetPoint(firstPointId);
- VPointF secondPoint = VAbstractTool::data->GetPoint(secondPointId);
- mainLine->setLine(QLineF(firstPoint.toQPointF(), secondPoint.toQPointF()));
- if(typeLine == "none"){
- mainLine->setVisible(false);
- } else {
- mainLine->setVisible(true);
- }
-}
-
-void VToolAlongLine::ChangedActivDraw(const QString newName){
- if(nameActivDraw == newName){
- mainLine->setPen(QPen(Qt::black, widthHairLine));
- VToolPoint::ChangedActivDraw(newName);
- } else {
- mainLine->setPen(QPen(Qt::gray, widthHairLine));
- VToolPoint::ChangedActivDraw(newName);
- }
+ RefreshGeometry();
}
void VToolAlongLine::FullUpdateFromGui(int result){
@@ -106,7 +62,7 @@ void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
dialogAlongLine->setTypeLine(typeLine);
dialogAlongLine->setFormula(formula);
- dialogAlongLine->setFirstPointId(firstPointId);
+ dialogAlongLine->setFirstPointId(basePointId);
dialogAlongLine->setSecondPointId(secondPointId);
dialogAlongLine->setPointName(p.name());
@@ -127,7 +83,7 @@ void VToolAlongLine::AddToFile(){
AddAttribute(domElement, "typeLine", typeLine);
AddAttribute(domElement, "length", formula);
- AddAttribute(domElement, "firstPoint", firstPointId);
+ AddAttribute(domElement, "firstPoint", basePointId);
AddAttribute(domElement, "secondPoint", secondPointId);
AddToCalculation(domElement);
diff --git a/tools/vtoolalongline.h b/tools/vtoolalongline.h
index a4ad20571..6cf5e3c80 100644
--- a/tools/vtoolalongline.h
+++ b/tools/vtoolalongline.h
@@ -1,10 +1,10 @@
#ifndef VTOOLALONGLINE_H
#define VTOOLALONGLINE_H
-#include "vtoolpoint.h"
+#include "vtoollinepoint.h"
#include "../dialogs/dialogalongline.h"
-class VToolAlongLine : public VToolPoint
+class VToolAlongLine : public VToolLinePoint
{
Q_OBJECT
public:
@@ -13,17 +13,12 @@ public:
Tool::Enum typeCreation, QGraphicsItem * parent = 0);
public slots:
virtual void FullUpdateFromFile();
- virtual void ChangedActivDraw(const QString newName);
virtual void FullUpdateFromGui(int result);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
private:
- QString typeLine;
- QString formula;
- qint64 firstPointId;
qint64 secondPointId;
- QGraphicsLineItem *mainLine;
QSharedPointer dialogAlongLine;
};
diff --git a/tools/vtoolbisector.cpp b/tools/vtoolbisector.cpp
index 0df45ff8f..085eb16f5 100644
--- a/tools/vtoolbisector.cpp
+++ b/tools/vtoolbisector.cpp
@@ -4,25 +4,10 @@
VToolBisector::VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId,
const qint64 &thirdPointId, Tool::Enum typeCreation, QGraphicsItem *parent):
- VToolPoint(doc, data, id, parent){
- this->typeLine = typeLine;
- this->formula = formula;
+ VToolLinePoint(doc, data, id, typeLine, formula, secondPointId, 0, parent){
this->firstPointId = firstPointId;
- this->secondPointId = secondPointId;
this->thirdPointId = thirdPointId;
- //Лінія, що з'єднує дві точки
- VPointF basePoint = data->GetPoint(secondPointId);
- VPointF point = data->GetPoint(id);
- mainLine = new QGraphicsLineItem(QLineF(basePoint.toQPointF(), point.toQPointF()), this);
- mainLine->setPen(QPen(Qt::black, widthHairLine));
- mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
- if(typeLine == "none"){
- mainLine->setVisible(false);
- } else {
- mainLine->setVisible(true);
- }
-
if(typeCreation == Tool::FromGui){
AddToFile();
}
@@ -42,28 +27,15 @@ QPointF VToolBisector::FindPoint(const QPointF &firstPoint, const QPointF &secon
}
void VToolBisector::FullUpdateFromFile(){
- QString name;
- qreal mx, my;
QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){
- name = domElement.attribute("name", "");
- mx = domElement.attribute("mx", "").toDouble()*PrintDPI/25.4;
- my = domElement.attribute("my", "").toDouble()*PrintDPI/25.4;
typeLine = domElement.attribute("typeLine", "");
formula = domElement.attribute("length", "");
firstPointId = domElement.attribute("firstPoint", "").toLongLong();
- secondPointId = domElement.attribute("secondPoint", "").toLongLong();
+ basePointId = domElement.attribute("secondPoint", "").toLongLong();
thirdPointId = domElement.attribute("thirdPoint", "").toLongLong();
}
- VPointF point = VAbstractTool::data->GetPoint(id);
- RefreshGeometry(name, point.x(), point.y(), mx, my);
- VPointF basePoint = VAbstractTool::data->GetPoint(secondPointId);
- mainLine->setLine(QLineF(basePoint.toQPointF(), point.toQPointF()));
- if(typeLine == "none"){
- mainLine->setVisible(false);
- } else {
- mainLine->setVisible(true);
- }
+ RefreshGeometry();
}
void VToolBisector::FullUpdateFromGui(int result){
@@ -82,16 +54,6 @@ void VToolBisector::FullUpdateFromGui(int result){
dialogBisector.clear();
}
-void VToolBisector::ChangedActivDraw(const QString newName){
- if(nameActivDraw == newName){
- mainLine->setPen(QPen(Qt::black, widthHairLine));
- VToolPoint::ChangedActivDraw(newName);
- } else {
- mainLine->setPen(QPen(Qt::gray, widthHairLine));
- VToolPoint::ChangedActivDraw(newName);
- }
-}
-
void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
if(!ignoreContextMenuEvent){
QMenu menu;
@@ -112,7 +74,7 @@ void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
dialogBisector->setTypeLine(typeLine);
dialogBisector->setFormula(formula);
dialogBisector->setFirstPointId(firstPointId);
- dialogBisector->setSecondPointId(secondPointId);
+ dialogBisector->setSecondPointId(basePointId);
dialogBisector->setThirdPointId(thirdPointId);
dialogBisector->setPointName(p.name());
@@ -134,7 +96,7 @@ void VToolBisector::AddToFile(){
AddAttribute(domElement, "typeLine", typeLine);
AddAttribute(domElement, "length", formula);
AddAttribute(domElement, "firstPoint", firstPointId);
- AddAttribute(domElement, "secondPoint", secondPointId);
+ AddAttribute(domElement, "secondPoint", basePointId);
AddAttribute(domElement, "thirdPoint", thirdPointId);
AddToCalculation(domElement);
diff --git a/tools/vtoolbisector.h b/tools/vtoolbisector.h
index d2488c2fe..268195776 100644
--- a/tools/vtoolbisector.h
+++ b/tools/vtoolbisector.h
@@ -3,31 +3,26 @@
#include
-#include "vtoolpoint.h"
+#include "vtoollinepoint.h"
#include "../dialogs/dialogbisector.h"
-class VToolBisector : public VToolPoint
+class VToolBisector : public VToolLinePoint
{
public:
VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId,
- const qint64 &thirdPointId,Tool::Enum typeCreation, QGraphicsItem * parent = 0);
+ const qint64 &thirdPointId, Tool::Enum typeCreation, QGraphicsItem * parent = 0);
static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint,
const QPointF &thirdPoint, const qreal& length);
public slots:
virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result);
- virtual void ChangedActivDraw(const QString newName);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
private:
- QString typeLine;
- QString formula;
qint64 firstPointId;
- qint64 secondPointId;
qint64 thirdPointId;
- QGraphicsLineItem *mainLine;
QSharedPointer dialogBisector;
};
diff --git a/tools/vtoolendline.cpp b/tools/vtoolendline.cpp
index 44ac63fbe..47d8383ea 100644
--- a/tools/vtoolendline.cpp
+++ b/tools/vtoolendline.cpp
@@ -4,26 +4,10 @@
#include "../widgets/vmaingraphicsscene.h"
-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){
- this->typeLine = typeLine;
- this->formula = formula;
- this->angle = angle;
- this->basePointId = basePointId;
-
- //Лінія, що з'єднує дві точки
- 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);
- } else {
- mainLine->setVisible(true);
- }
+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):
+ VToolLinePoint(doc, data, id, typeLine, formula, basePointId, angle, parent){
if(typeCreation == Tool::FromGui){
AddToFile();
@@ -31,27 +15,14 @@ VToolEndLine::VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id
}
void VToolEndLine::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", "");
basePointId = domElement.attribute("basePoint", "").toLongLong();
angle = domElement.attribute("angle", "").toInt();
}
- VPointF point = VAbstractTool::data->GetPoint(id);
- RefreshGeometry(name, point.x(), point.y(), mx, my);
- VPointF basePoint = VAbstractTool::data->GetPoint(basePointId);
- mainLine->setLine(QLineF(basePoint.toQPointF(), point.toQPointF()));
- if(typeLine == "none"){
- mainLine->setVisible(false);
- } else {
- mainLine->setVisible(true);
- }
+ RefreshGeometry();
}
void VToolEndLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
@@ -96,16 +67,6 @@ void VToolEndLine::FullUpdateFromGui(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 = VAbstractTool::data->GetPoint(id);
QDomElement domElement = doc->createElement("point");
diff --git a/tools/vtoolendline.h b/tools/vtoolendline.h
index fb2f3d7d9..cae123e3e 100644
--- a/tools/vtoolendline.h
+++ b/tools/vtoolendline.h
@@ -3,10 +3,10 @@
#include
-#include "vtoolpoint.h"
+#include "vtoollinepoint.h"
#include "../dialogs/dialogendline.h"
-class VToolEndLine : public VToolPoint
+class VToolEndLine : public VToolLinePoint
{
Q_OBJECT
public:
@@ -17,16 +17,10 @@ public:
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 basePointId;
- QGraphicsLineItem *mainLine;
QSharedPointer dialogEndLine;
};
diff --git a/tools/vtoollineintersect.cpp b/tools/vtoollineintersect.cpp
new file mode 100644
index 000000000..a55872be6
--- /dev/null
+++ b/tools/vtoollineintersect.cpp
@@ -0,0 +1,85 @@
+#include "vtoollineintersect.h"
+#include
+
+VToolLineIntersect::VToolLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id,
+ const qint64 &p1Line1, const qint64 &p2Line1, const qint64 &p1Line2,
+ const qint64 &p2Line2, Tool::Enum typeCreation, QGraphicsItem *parent):
+ VToolPoint(doc, data, id, parent){
+ this->p1Line1 = p1Line1;
+ this->p2Line1 = p2Line1;
+ this->p1Line2 = p1Line2;
+ this->p2Line2 = p2Line2;
+ if(typeCreation == Tool::FromGui){
+ AddToFile();
+ }
+}
+
+void VToolLineIntersect::FullUpdateFromFile(){
+ QDomElement domElement = doc->elementById(QString().setNum(id));
+ if(domElement.isElement()){
+ p1Line1 = domElement.attribute("p1Line1", "").toLongLong();
+ p2Line1 = domElement.attribute("p2Line1", "").toLongLong();
+ p1Line2 = domElement.attribute("p1Line2", "").toLongLong();
+ p2Line2 = domElement.attribute("p2Line2", "").toLongLong();
+ }
+ RefreshGeometry();
+}
+
+void VToolLineIntersect::FullUpdateFromGui(int result){
+ if(result == QDialog::Accepted){
+ QDomElement domElement = doc->elementById(QString().setNum(id));
+ if(domElement.isElement()){
+ domElement.setAttribute("name", dialogLineIntersect->getPointName());
+ domElement.setAttribute("p1Line1", QString().setNum(dialogLineIntersect->getP1Line1()));
+ domElement.setAttribute("p2Line1", QString().setNum(dialogLineIntersect->getP2Line1()));
+ domElement.setAttribute("p1Line2", QString().setNum(dialogLineIntersect->getP1Line2()));
+ domElement.setAttribute("p2Line2", QString().setNum(dialogLineIntersect->getP2Line2()));
+ emit FullUpdateTree();
+ }
+ }
+ dialogLineIntersect.clear();
+}
+
+void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
+ if(!ignoreContextMenuEvent){
+ QMenu menu;
+ QAction *actionOption = menu.addAction("Властивості");
+ QAction *selectedAction = menu.exec(event->screenPos());
+ if(selectedAction == actionOption){
+ dialogLineIntersect = QSharedPointer(new DialogLineIntersect(VAbstractTool::data));
+
+ connect(qobject_cast< VMainGraphicsScene * >(this->scene()), &VMainGraphicsScene::ChoosedObject,
+ dialogLineIntersect.data(), &DialogLineIntersect::ChoosedPoint);
+ connect(dialogLineIntersect.data(), &DialogLineIntersect::DialogClosed, this,
+ &VToolLineIntersect::FullUpdateFromGui);
+
+ VPointF p = VAbstractTool::data->GetPoint(id);
+
+ dialogLineIntersect->setP1Line1(p1Line1);
+ dialogLineIntersect->setP2Line1(p2Line1);
+ dialogLineIntersect->setP1Line2(p1Line2);
+ dialogLineIntersect->setP2Line2(p2Line2);
+ dialogLineIntersect->setPointName(p.name());
+
+ dialogLineIntersect->show();
+ }
+ }
+}
+
+void VToolLineIntersect::AddToFile(){
+ VPointF point = VAbstractTool::data->GetPoint(id);
+ QDomElement domElement = doc->createElement("point");
+
+ AddAttribute(domElement, "id", id);
+ AddAttribute(domElement, "type", "lineIntersect");
+ AddAttribute(domElement, "name", point.name());
+ AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4);
+ AddAttribute(domElement, "my", point.my()/PrintDPI*25.4);
+
+ AddAttribute(domElement, "p1Line1", p1Line1);
+ AddAttribute(domElement, "p2Line1", p2Line1);
+ AddAttribute(domElement, "p1Line2", p1Line2);
+ AddAttribute(domElement, "p2Line2", p2Line2);
+
+ AddToCalculation(domElement);
+}
diff --git a/tools/vtoollineintersect.h b/tools/vtoollineintersect.h
new file mode 100644
index 000000000..44a7c47a7
--- /dev/null
+++ b/tools/vtoollineintersect.h
@@ -0,0 +1,29 @@
+#ifndef VTOOLLINEINTERSECT_H
+#define VTOOLLINEINTERSECT_H
+
+#include "vtoolpoint.h"
+#include "../dialogs/dialoglineintersect.h"
+
+class VToolLineIntersect:public VToolPoint
+{
+public:
+ VToolLineIntersect(VDomDocument *doc, VContainer *data,
+ const qint64 &id, const qint64 &p1Line1,
+ const qint64 &p2Line1, const qint64 &p1Line2,
+ const qint64 &p2Line2, Tool::Enum typeCreation,
+ QGraphicsItem * parent = 0);
+public slots:
+ virtual void FullUpdateFromFile();
+ virtual void FullUpdateFromGui(int result);
+protected:
+ virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
+ virtual void AddToFile();
+private:
+ qint64 p1Line1;
+ qint64 p2Line1;
+ qint64 p1Line2;
+ qint64 p2Line2;
+ QSharedPointer dialogLineIntersect;
+};
+
+#endif // VTOOLLINEINTERSECT_H
diff --git a/tools/vtoollinepoint.cpp b/tools/vtoollinepoint.cpp
index b90d2dd80..336423d15 100644
--- a/tools/vtoollinepoint.cpp
+++ b/tools/vtoollinepoint.cpp
@@ -1,16 +1,17 @@
#include "vtoollinepoint.h"
VToolLinePoint::VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
- const QString &formula, const qint64 &pointId, const qint32 &angle,
+ const QString &formula, const qint64 &basePointId, const qint32 &angle,
QGraphicsItem *parent):VToolPoint(doc, data, id, parent){
this->typeLine = typeLine;
this->formula = formula;
this->angle = angle;
+ this->basePointId = basePointId;
//Лінія, що з'єднує дві точки
- VPointF firstPoint = data->GetPoint(pointId);
- VPointF point = data->GetPoint(id);
- mainLine = new QGraphicsLineItem(QLineF(firstPoint.toQPointF(), point.toQPointF()), this);
+ VPointF point1 = data->GetPoint(basePointId);
+ VPointF point2 = data->GetPoint(id);
+ mainLine = new QGraphicsLineItem(QLineF(point1.toQPointF(), point2.toQPointF()), this);
mainLine->setPen(QPen(Qt::black, widthHairLine));
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
if(typeLine == "none"){
@@ -29,3 +30,15 @@ void VToolLinePoint::ChangedActivDraw(const QString newName){
VToolPoint::ChangedActivDraw(newName);
}
}
+
+void VToolLinePoint::RefreshGeometry(){
+ VToolPoint::RefreshGeometry();
+ VPointF point = VAbstractTool::data->GetPoint(id);
+ VPointF basePoint = VAbstractTool::data->GetPoint(basePointId);
+ mainLine->setLine(QLineF(basePoint.toQPointF(), point.toQPointF()));
+ if(typeLine == "none"){
+ mainLine->setVisible(false);
+ } else {
+ mainLine->setVisible(true);
+ }
+}
diff --git a/tools/vtoollinepoint.h b/tools/vtoollinepoint.h
index adb565de1..be6cad68d 100644
--- a/tools/vtoollinepoint.h
+++ b/tools/vtoollinepoint.h
@@ -8,13 +8,15 @@ class VToolLinePoint : public VToolPoint
public:
VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula,
- const qint64 &pointId, const qint32 &angle, QGraphicsItem * parent = 0);
+ const qint64 &basePointId, const qint32 &angle, QGraphicsItem * parent = 0);
public slots:
virtual void ChangedActivDraw(const QString newName);
+ virtual void RefreshGeometry();
protected:
QString typeLine;
QString formula;
qint32 angle;
+ qint64 basePointId;
QGraphicsLineItem *mainLine;
};
diff --git a/tools/vtoolnormal.cpp b/tools/vtoolnormal.cpp
index 80f96282a..6ef958ca7 100644
--- a/tools/vtoolnormal.cpp
+++ b/tools/vtoolnormal.cpp
@@ -4,25 +4,9 @@
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;
+ VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, angle, parent){
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();
}
@@ -39,28 +23,15 @@ QPointF VToolNormal::FindPoint(const QPointF &firstPoint, const QPointF &secondP
}
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();
+ basePointId = domElement.attribute("firstPoint", "").toLongLong();
secondPointId = domElement.attribute("secondPoint", "").toLongLong();
angle = domElement.attribute("angle", "").toInt();
}
- VPointF point = VAbstractTool::data->GetPoint(id);
- RefreshGeometry(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);
- }
+ RefreshGeometry();
}
void VToolNormal::FullUpdateFromGui(int result){
@@ -79,16 +50,6 @@ void VToolNormal::FullUpdateFromGui(int result){
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;
@@ -108,7 +69,7 @@ void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
dialogNormal->setTypeLine(typeLine);
dialogNormal->setFormula(formula);
dialogNormal->setAngle(angle);
- dialogNormal->setFirstPointId(firstPointId);
+ dialogNormal->setFirstPointId(basePointId);
dialogNormal->setSecondPointId(secondPointId);
dialogNormal->setPointName(p.name());
@@ -130,7 +91,7 @@ void VToolNormal::AddToFile(){
AddAttribute(domElement, "typeLine", typeLine);
AddAttribute(domElement, "length", formula);
AddAttribute(domElement, "angle", angle);
- AddAttribute(domElement, "firstPoint", firstPointId);
+ AddAttribute(domElement, "firstPoint", basePointId);
AddAttribute(domElement, "secondPoint", secondPointId);
AddToCalculation(domElement);
diff --git a/tools/vtoolnormal.h b/tools/vtoolnormal.h
index 8e87e9488..b4da54f52 100644
--- a/tools/vtoolnormal.h
+++ b/tools/vtoolnormal.h
@@ -3,10 +3,10 @@
#include
-#include "vtoolpoint.h"
+#include "vtoollinepoint.h"
#include "../dialogs/dialognormal.h"
-class VToolNormal : public VToolPoint
+class VToolNormal : public VToolLinePoint
{
public:
VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id,
@@ -19,17 +19,11 @@ public:
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;
};
diff --git a/tools/vtoolpoint.cpp b/tools/vtoolpoint.cpp
index 0d4a92117..1a8cf0cb2 100644
--- a/tools/vtoolpoint.cpp
+++ b/tools/vtoolpoint.cpp
@@ -192,15 +192,15 @@ void VToolPoint::mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ){
QGraphicsItem::mouseReleaseEvent(event);
}
-void VToolPoint::RefreshGeometry(const QString &name, const qreal &x, const qreal &y, const qreal &mx,
- const qreal &my){
- QRectF rec = QRectF(x, y, radius*2, radius*2);
- rec.translate(x-rec.center().x(), y-rec.center().y());
+void VToolPoint::RefreshGeometry(){
+ VPointF point = VAbstractTool::data->GetPoint(id);
+ QRectF rec = QRectF(point.x(), point.y(), radius*2, radius*2);
+ rec.translate(point.x()-rec.center().x(), point.y()-rec.center().y());
this->setRect(rec);
rec = this->rect();
- namePoint->setText(name);
- namePoint->setPos(QPointF(rec.center().x()+mx, rec.center().y()+my));
+ namePoint->setText(point.name());
+ namePoint->setPos(QPointF(rec.center().x()+point.mx(), rec.center().y()+point.my()));
RefreshLine();
}
diff --git a/tools/vtoolpoint.h b/tools/vtoolpoint.h
index 3385d57d5..a4ef24ca7 100644
--- a/tools/vtoolpoint.h
+++ b/tools/vtoolpoint.h
@@ -23,8 +23,7 @@ protected:
VGraphicsSimpleTextItem *namePoint;
QGraphicsLineItem *lineName;
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
- void RefreshGeometry(const QString &name, const qreal &x, const qreal &y,
- const qreal &mx, const qreal &my);
+ virtual void RefreshGeometry();
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
private:
diff --git a/tools/vtoolshoulderpoint.cpp b/tools/vtoolshoulderpoint.cpp
index d885d5340..0257a1634 100644
--- a/tools/vtoolshoulderpoint.cpp
+++ b/tools/vtoolshoulderpoint.cpp
@@ -5,24 +5,11 @@
VToolShoulderPoint::VToolShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const qint64 &p1Line,
const qint64 &p2Line, const qint64 &pShoulder, Tool::Enum typeCreation,
- QGraphicsItem * parent):VToolPoint(doc, data, id, parent){
- this->typeLine = typeLine;
- this->formula = formula;
- this->p1Line = p1Line;
+ QGraphicsItem * parent):
+ VToolLinePoint(doc, data, id, typeLine, formula, p1Line, 0, parent){
this->p2Line = p2Line;
this->pShoulder = pShoulder;
- //Лінія, що з'єднує дві точки
- VPointF p1L = data->GetPoint(p1Line);
- VPointF point = data->GetPoint(id);
- mainLine = new QGraphicsLineItem(QLineF(p1L.toQPointF(), point.toQPointF()), this);
- mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
- if(typeLine == "none"){
- mainLine->setVisible(false);
- } else {
- mainLine->setVisible(true);
- }
-
if(typeCreation == Tool::FromGui){
AddToFile();
}
@@ -51,28 +38,15 @@ QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Li
}
void VToolShoulderPoint::FullUpdateFromFile(){
- QString name;
- qreal mx, my;
QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){
- name = domElement.attribute("name", "");
- mx = domElement.attribute("mx", "").toDouble()*PrintDPI/25.4;
- my = domElement.attribute("my", "").toDouble()*PrintDPI/25.4;
typeLine = domElement.attribute("typeLine", "");
formula = domElement.attribute("length", "");
- p1Line = domElement.attribute("p1Line", "").toLongLong();
+ basePointId = domElement.attribute("p1Line", "").toLongLong();
p2Line = domElement.attribute("p2Line", "").toLongLong();
pShoulder = domElement.attribute("pShoulder", "").toLongLong();
}
- VPointF point = VAbstractTool::data->GetPoint(id);
- RefreshGeometry(name, point.x(), point.y(), mx, my);
- VPointF p1L = VAbstractTool::data->GetPoint(p1Line);
- mainLine->setLine(QLineF(p1L.toQPointF(), point.toQPointF()));
- if(typeLine == "none"){
- mainLine->setVisible(false);
- } else {
- mainLine->setVisible(true);
- }
+ RefreshGeometry();
}
void VToolShoulderPoint::FullUpdateFromGui(int result){
@@ -91,16 +65,6 @@ void VToolShoulderPoint::FullUpdateFromGui(int result){
dialogShoulderPoint.clear();
}
-void VToolShoulderPoint::ChangedActivDraw(const QString newName){
- if(nameActivDraw == newName){
- mainLine->setPen(QPen(Qt::black, widthHairLine));
- VToolPoint::ChangedActivDraw(newName);
- } else {
- mainLine->setPen(QPen(Qt::gray, widthHairLine));
- VToolPoint::ChangedActivDraw(newName);
- }
-}
-
void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
if(!ignoreContextMenuEvent){
QMenu menu;
@@ -114,13 +78,14 @@ void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
dialogShoulderPoint.data(), &DialogShoulderPoint::ChoosedPoint);
connect(dialogShoulderPoint.data(), &DialogShoulderPoint::DialogClosed, this,
&VToolShoulderPoint::FullUpdateFromGui);
- connect(doc, &VDomDocument::FullUpdateFromFile, dialogShoulderPoint.data(), &DialogShoulderPoint::UpdateList);
+ connect(doc, &VDomDocument::FullUpdateFromFile, dialogShoulderPoint.data(),
+ &DialogShoulderPoint::UpdateList);
VPointF p = VAbstractTool::data->GetPoint(id);
dialogShoulderPoint->setTypeLine(typeLine);
dialogShoulderPoint->setFormula(formula);
- dialogShoulderPoint->setP1Line(p1Line);
+ dialogShoulderPoint->setP1Line(basePointId);
dialogShoulderPoint->setP2Line(p2Line);
dialogShoulderPoint->setPShoulder(pShoulder);
dialogShoulderPoint->setPointName(p.name());
@@ -142,7 +107,7 @@ void VToolShoulderPoint::AddToFile(){
AddAttribute(domElement, "typeLine", typeLine);
AddAttribute(domElement, "length", formula);
- AddAttribute(domElement, "p1Line", p1Line);
+ AddAttribute(domElement, "p1Line", basePointId);
AddAttribute(domElement, "p2Line", p2Line);
AddAttribute(domElement, "pShoulder", pShoulder);
diff --git a/tools/vtoolshoulderpoint.h b/tools/vtoolshoulderpoint.h
index 6b3ea6174..118a36c62 100644
--- a/tools/vtoolshoulderpoint.h
+++ b/tools/vtoolshoulderpoint.h
@@ -1,10 +1,10 @@
#ifndef VTOOLSHOULDERPOINT_H
#define VTOOLSHOULDERPOINT_H
-#include "vtoolpoint.h"
+#include "vtoollinepoint.h"
#include "../dialogs/dialogshoulderpoint.h"
-class VToolShoulderPoint : public VToolPoint
+class VToolShoulderPoint : public VToolLinePoint
{
public:
VToolShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id,
@@ -16,17 +16,12 @@ public:
public slots:
virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result);
- virtual void ChangedActivDraw(const QString newName);
protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile();
private:
- QString typeLine;
- QString formula;
- qint64 p1Line;
qint64 p2Line;
qint64 pShoulder;
- QGraphicsLineItem *mainLine;
QSharedPointer dialogShoulderPoint;
};
diff --git a/tools/vtoolsimplepoint.cpp b/tools/vtoolsimplepoint.cpp
index d2fc3ab02..4924bde89 100644
--- a/tools/vtoolsimplepoint.cpp
+++ b/tools/vtoolsimplepoint.cpp
@@ -63,15 +63,5 @@ void VToolSimplePoint::contextMenuEvent ( QGraphicsSceneContextMenuEvent * event
}
void VToolSimplePoint::FullUpdateFromFile(){
- QString name;
- qreal x, y, mx, my;
- QDomElement domElement = doc->elementById(QString().setNum(id));
- if(domElement.isElement()){
- name = domElement.attribute("name", "");
- x = domElement.attribute("x", "").toDouble()*PrintDPI/25.4;
- y = domElement.attribute("y", "").toDouble()*PrintDPI/25.4;
- mx = domElement.attribute("mx", "").toDouble()*PrintDPI/25.4;
- my = domElement.attribute("my", "").toDouble()*PrintDPI/25.4;
- }
- RefreshGeometry(name, x, y, mx, my);
+ RefreshGeometry();
}
diff --git a/xml/vdomdocument.cpp b/xml/vdomdocument.cpp
index 55f8cfbf9..fd5bf60c1 100644
--- a/xml/vdomdocument.cpp
+++ b/xml/vdomdocument.cpp
@@ -8,6 +8,7 @@
#include "../tools/vtoolshoulderpoint.h"
#include "../tools/vtoolnormal.h"
#include "../tools/vtoolbisector.h"
+#include "../tools/vtoollineintersect.h"
#include "../options.h"
#include "../container/calculator.h"
@@ -571,6 +572,50 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
}
return;
}
+ if(type == "lineIntersect"){
+ if(!domElement.isNull()){
+ QString name;
+ qreal mx=5, my=10;
+ qint64 id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id;
+ 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;
+
+ p1Line1Id = domElement.attribute("p1Line1", "").toLongLong();
+ p2Line1Id = domElement.attribute("p2Line1", "").toLongLong();
+ p1Line2Id = domElement.attribute("p1Line2", "").toLongLong();
+ p2Line2Id = domElement.attribute("p2Line2", "").toLongLong();
+
+ VPointF p1Line1 = data->GetPoint(p1Line1Id);
+ VPointF p2Line1 = data->GetPoint(p2Line1Id);
+ VPointF p1Line2 = data->GetPoint(p1Line2Id);
+ VPointF p2Line2 = data->GetPoint(p2Line2Id);
+
+ QLineF line1(p1Line1, p2Line1);
+ QLineF line2(p1Line2, p2Line2);
+ QPointF fPoint;
+ QLineF::IntersectType intersect = line1.intersect(line2, &fPoint);
+ if(intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection){
+ data->UpdatePoint(id, VPointF(fPoint.x(), fPoint.y(), name, mx, my));
+ data->AddLine(p1Line1Id, id);
+ data->AddLine(id, p2Line1Id);
+ data->AddLine(p1Line2Id, id);
+ data->AddLine(id, p2Line2Id);
+ if(parse == Document::FullParse){
+ VToolLineIntersect *point = new VToolLineIntersect(this, data, id, p1Line1Id,
+ p2Line1Id, p1Line2Id,
+ p2Line2Id, Tool::FromGui);
+ scene->addItem(point);
+ connect(point, &VToolLineIntersect::ChoosedPoint, scene,
+ &VMainGraphicsScene::ChoosedItem);
+ }
+ }
+ }
+ }
+ return;
+ }
}
void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement,