From c66439ba7a45a8616d9b2156d8e9d42825b8dab6 Mon Sep 17 00:00:00 2001 From: dismine Date: Mon, 21 Oct 2013 17:09:05 +0300 Subject: [PATCH] Tool point of intersection. --HG-- branch : develop --- Valentina.pro | 13 +- cursor.qrc | 1 + cursor/pointofintersect_cursor.png | Bin 0 -> 1403 bytes dialogs/dialogpointofintersection.cpp | 98 ++++++++++ dialogs/dialogpointofintersection.h | 34 ++++ dialogs/dialogpointofintersection.ui | 169 ++++++++++++++++++ icon.qrc | 1 + icon/32x32/point_of_intersection.png | Bin 0 -> 652 bytes mainwindow.cpp | 31 +++- mainwindow.h | 33 ++-- mainwindow.ui | 31 +++- options.h | 3 +- tools/drawTools/drawtools.h | 1 + tools/drawTools/vtoolline.cpp | 1 + tools/drawTools/vtoollineintersect.cpp | 1 + tools/drawTools/vtoolpointofintersection.cpp | 106 +++++++++++ tools/drawTools/vtoolpointofintersection.h | 33 ++++ tools/drawTools/vtoolspline.cpp | 1 + tools/drawTools/vtoolsplinepath.cpp | 1 + tools/drawTools/vtooltriangle.cpp | 2 +- tools/modelingTools/modelingtools.h | 1 + tools/modelingTools/vmodelingline.cpp | 1 + .../modelingTools/vmodelinglineintersect.cpp | 1 + .../vmodelingpointofintersection.cpp | 105 +++++++++++ .../vmodelingpointofintersection.h | 35 ++++ tools/modelingTools/vmodelingspline.cpp | 2 +- tools/modelingTools/vmodelingsplinepath.cpp | 1 + tools/modelingTools/vmodelingtriangle.cpp | 1 - xml/vdomdocument.cpp | 24 +++ 29 files changed, 704 insertions(+), 27 deletions(-) create mode 100644 cursor/pointofintersect_cursor.png create mode 100644 dialogs/dialogpointofintersection.cpp create mode 100644 dialogs/dialogpointofintersection.h create mode 100644 dialogs/dialogpointofintersection.ui create mode 100644 icon/32x32/point_of_intersection.png create mode 100644 tools/drawTools/vtoolpointofintersection.cpp create mode 100644 tools/drawTools/vtoolpointofintersection.h create mode 100644 tools/modelingTools/vmodelingpointofintersection.cpp create mode 100644 tools/modelingTools/vmodelingpointofintersection.h diff --git a/Valentina.pro b/Valentina.pro index 74ac8fbca..f9b662a95 100644 --- a/Valentina.pro +++ b/Valentina.pro @@ -103,7 +103,10 @@ SOURCES += main.cpp\ dialogs/dialogheight.cpp \ tools/drawTools/vtooltriangle.cpp \ tools/modelingTools/vmodelingtriangle.cpp \ - dialogs/dialogtriangle.cpp + dialogs/dialogtriangle.cpp \ + dialogs/dialogpointofintersection.cpp \ + tools/drawTools/vtoolpointofintersection.cpp \ + tools/modelingTools/vmodelingpointofintersection.cpp HEADERS += mainwindow.h \ widgets/vmaingraphicsscene.h \ @@ -200,7 +203,10 @@ HEADERS += mainwindow.h \ dialogs/dialogheight.h \ tools/drawTools/vtooltriangle.h \ tools/modelingTools/vmodelingtriangle.h \ - dialogs/dialogtriangle.h + dialogs/dialogtriangle.h \ + dialogs/dialogpointofintersection.h \ + tools/drawTools/vtoolpointofintersection.h \ + tools/modelingTools/vmodelingpointofintersection.h FORMS += mainwindow.ui \ dialogs/dialogsinglepoint.ui \ @@ -220,7 +226,8 @@ FORMS += mainwindow.ui \ dialogs/dialogdetail.ui \ tablewindow.ui \ dialogs/dialogheight.ui \ - dialogs/dialogtriangle.ui + dialogs/dialogtriangle.ui \ + dialogs/dialogpointofintersection.ui RESOURCES += \ icon.qrc \ diff --git a/cursor.qrc b/cursor.qrc index a0827a0a2..785c3ddd8 100644 --- a/cursor.qrc +++ b/cursor.qrc @@ -14,5 +14,6 @@ cursor/new_detail_cursor.png cursor/height_cursor.png cursor/triangle_cursor.png + cursor/pointofintersect_cursor.png diff --git a/cursor/pointofintersect_cursor.png b/cursor/pointofintersect_cursor.png new file mode 100644 index 0000000000000000000000000000000000000000..c01923887156d8f8f4e996f48696e5ce8d64bb21 GIT binary patch literal 1403 zcmV->1%&#EP)Vl&|00006VoOIv0RI60 z0RN!9r;`8x010qNS#tmY3ljhU3ljkVnw%H_000McNliru-3k>8EDoLDvlRdU06}y` zSad^gZEa<4bO1wAML|?gQaT`KWG!lNWoICEF)lD5D0OpbZf77#N=G0{P(?=|b~Z98 zEFf`pVQgu1c_2L?IWP*aMOc#n00g^9L_t(Y$HkU^Xq0sv$6w#)dG6NTZo1v5%^^C- zB+XN=1|?d9Va??>ow?W_LgCC zwbf=!z3H@_-raN0r$5|t-EMbl1J6G2h41ryzR&mleZN1y9{4|P_wL;jp6l!D)g!$? zOH0du&*ziM%1RNDMUND`qN3s=APW~Rl*IMk-rkJj8UTi205CE#A`J}<;&3=vx^!tn zNlD3pj5DvQs=5e>uIr+d5C_gkbw4k}Ud0T61YuO`VZnL+C zQcB9o%A~!$JvU=MPc+N201y#0O{1WofDIcq+|HQnNDnj-V+Xoal73F0)Z#@?%lim%$YNfrvY{VJ;2Mr1t4d_ z+v@7-l+2S^Cn}+7nrNCPix)4JqM{;cYioNi4fs1rXYQJo&(p<$h+tV3BEsd%ml+-& zCKL)q>^(g_J&B+6BpvbNw0sVTrfHMd8-_8#|4Jz-EiDb!)YSZb`0(Mu6nEYVoCUT| zO0{%8xBZ@+il%8!+7k!_ynwf`urSpzhk)mSeQCjUU5^(Tr4*KBk&}}nB_$AJ3}l-~SY zOdKCrmZ|Hym7A9*1`rRHyu3Wwv}x0|{rmTS7>!2Hnx;8&{rdHYVHnEob`yz2Fims5 z+wJamxm*N;!3iZ`JoUI4yvd2LIssJJ=~<-U(?MNcC_??QOLMlJ{IcWYTf=`n_-gg) z)fWL-vSf)lReb?Yj04;O<|w7mG%aNzQc59Nvm9Zk=hv{)BMHL{J3Y@fH0_B0I=>Ih zx^(H%oxZ-lWq!Z^rxf6C0oCL49N;4n`CLRs0pIwgdVp6%!~(vXAGy2siX(f0Ok|+9 z#iBbye~-Ry0CaVAb=pzy_xsZ^pPy8Y1@Hi4`= zY;;}6FpQMGoyw{!D_FDUMf}e^g*bCI9yA`ieZ`TzZ^)CEUs_r^5Adr0=wM1j6kyE^ zxSW%n->`GXc2!VVV4OP_aOg^R_?9hq&7Pf`+q|vi=h}_0@eiK^7{)V2t-1gJ002ov JPDHLkV1iS`nZ^JB literal 0 HcmV?d00001 diff --git a/dialogs/dialogpointofintersection.cpp b/dialogs/dialogpointofintersection.cpp new file mode 100644 index 000000000..04f239337 --- /dev/null +++ b/dialogs/dialogpointofintersection.cpp @@ -0,0 +1,98 @@ +#include "dialogpointofintersection.h" +#include "ui_dialogpointofintersection.h" + +DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, Draw::Draws mode, QWidget *parent) : + DialogTool(data, mode, parent), ui(new Ui::DialogPointOfIntersection), number(0), pointName(QString()), + firstPointId(0), secondPointId(0){ + ui->setupUi(this); + labelEditNamePoint = ui->labelEditNamePoint; + bOk = ui->buttonBox->button(QDialogButtonBox::Ok); + connect(bOk, &QPushButton::clicked, this, &DialogPointOfIntersection::DialogAccepted); + flagName = false; + CheckState(); + QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); + connect(bCansel, &QPushButton::clicked, this, &DialogPointOfIntersection::DialogRejected); + FillComboBoxPoints(ui->comboBoxFirstPoint); + FillComboBoxPoints(ui->comboBoxSecondPoint); + connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersection::NamePointChanged); +} + +DialogPointOfIntersection::~DialogPointOfIntersection(){ + delete ui; +} + +qint64 DialogPointOfIntersection::getSecondPointId() const{ + return secondPointId; +} + +void DialogPointOfIntersection::setSecondPointId(const qint64 &value, const qint64 &id){ + secondPointId = value; + setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id); +} + +void DialogPointOfIntersection::ChoosedObject(qint64 id, Scene::Scenes type){ + if(idDetail == 0 && mode == Draw::Modeling){ + if(type == Scene::Detail){ + idDetail = id; + return; + } + } + if(mode == Draw::Modeling){ + if(!CheckObject(id)){ + return; + } + } + if(type == Scene::Point){ + VPointF point; + if(mode == Draw::Calculation){ + point = data->GetPoint(id); + } else { + point = data->GetModelingPoint(id); + } + if(number == 0){ + qint32 index = ui->comboBoxFirstPoint->findText(point.name()); + if ( index != -1 ) { // -1 for not found + ui->comboBoxFirstPoint->setCurrentIndex(index); + number++; + emit ToolTip(tr("Select point horizontally")); + return; + } + } + if(number == 1){ + qint32 index = ui->comboBoxSecondPoint->findText(point.name()); + if ( index != -1 ) { // -1 for not found + ui->comboBoxSecondPoint->setCurrentIndex(index); + number = 0; + emit ToolTip(""); + } + if(!isInitialized){ + this->show(); + } + } + } +} + +void DialogPointOfIntersection::DialogAccepted(){ + pointName = ui->lineEditNamePoint->text(); + firstPointId = getCurrentPointId(ui->comboBoxFirstPoint); + secondPointId = getCurrentPointId(ui->comboBoxSecondPoint); + emit DialogClosed(QDialog::Accepted); +} + +qint64 DialogPointOfIntersection::getFirstPointId() const{ + return firstPointId; +} + +void DialogPointOfIntersection::setFirstPointId(const qint64 &value, const qint64 &id){ + firstPointId = value; + setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id); +} + +QString DialogPointOfIntersection::getPointName() const{ + return pointName; +} + +void DialogPointOfIntersection::setPointName(const QString &value){ + pointName = value; + ui->lineEditNamePoint->setText(pointName); +} diff --git a/dialogs/dialogpointofintersection.h b/dialogs/dialogpointofintersection.h new file mode 100644 index 000000000..7ffb57604 --- /dev/null +++ b/dialogs/dialogpointofintersection.h @@ -0,0 +1,34 @@ +#ifndef DIALOGPOINTOFINTERSECTION_H +#define DIALOGPOINTOFINTERSECTION_H + +#include "dialogtool.h" + +namespace Ui { +class DialogPointOfIntersection; +} + +class DialogPointOfIntersection : public DialogTool{ + Q_OBJECT +public: + DialogPointOfIntersection(const VContainer *data, Draw::Draws mode = Draw::Calculation, + QWidget *parent = 0); + ~DialogPointOfIntersection(); + QString getPointName() const; + void setPointName(const QString &value); + qint64 getFirstPointId() const; + void setFirstPointId(const qint64 &value, const qint64 &id); + qint64 getSecondPointId() const; + void setSecondPointId(const qint64 &value, const qint64 &id); +public slots: + virtual void ChoosedObject(qint64 id, Scene::Scenes type); + virtual void DialogAccepted(); +private: + Q_DISABLE_COPY(DialogPointOfIntersection) + Ui::DialogPointOfIntersection *ui; + qint32 number; + QString pointName; + qint64 firstPointId; + qint64 secondPointId; +}; + +#endif // DIALOGPOINTOFINTERSECTION_H diff --git a/dialogs/dialogpointofintersection.ui b/dialogs/dialogpointofintersection.ui new file mode 100644 index 000000000..303aa8cc0 --- /dev/null +++ b/dialogs/dialogpointofintersection.ui @@ -0,0 +1,169 @@ + + + DialogPointOfIntersection + + + + 0 + 0 + 293 + 180 + + + + Dialog + + + + + + + + + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 159 + 158 + 158 + + + + + + + + Name new point + + + + + + + + + + + + + + + 0 + 0 + + + + Point vertically + + + + + + + First point of angle + + + + + + + + + + + + 0 + 0 + + + + Point horizontally + + + + + + + Second point of angle + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + DialogPointOfIntersection + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogPointOfIntersection + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/icon.qrc b/icon.qrc index 520ff398d..66b939f04 100644 --- a/icon.qrc +++ b/icon.qrc @@ -36,5 +36,6 @@ icon/16x16/mirror.png icon/32x32/height.png icon/32x32/triangle.png + icon/32x32/point_of_intersection.png diff --git a/icon/32x32/point_of_intersection.png b/icon/32x32/point_of_intersection.png new file mode 100644 index 0000000000000000000000000000000000000000..7ab757dde6bdb361a22cc30c9a65d9b91dde14c5 GIT binary patch literal 652 zcmV;70(1R|P)8CN@tp;{gBw0vSm} zK~z}7?UuW16j2n$fAczKcTU_WSZGWk#Ks^(P*AYhK)_1SMpT4=LJ(Z6{4?xRN;(B0 zf{h3kDhs|4EmEl1C15lWBe>q#Y{urUj_XW(?cQy2;4(9J&fN3ebHDS=flYH`6ToAj z0(dS1d%#)X6_5hYfMYHJ9JYb8V+9y*JNP{Ya4u)A0-SIKAaDKDB@d3|9Kk!_s7oGP z2HpUlftSE^Kgw_vm;`qBO9yrU*Bx-K&_;j-Ao>%Q_QKXI0e`W;5r7o<0zB#j;wl5{ zKp6=8#epGU*#v~f2oje5W(-~wqMjfaH!e15d!=3>eK4?0I)T) zbI%5A0Zj|$y)CnK+wXk>=6$>cV9!R{Q1Pg@!JNuDf+xVPe{G)<(b{h~a3>uYirfAn za0O`C;4gr&E|lZ_g5WDgbfTz_-_|W1FrtAGok>I&mn3ekiheYrPmO4`=ZctJJRRH_ mPx|5f#UQFVQNm688~X+@g3_69>p|xL0000()), dialogDetail(QSharedPointer()), dialogHeight(QSharedPointer()), dialogTriangle(QSharedPointer()), + dialogPointOfIntersection(QSharedPointer()), dialogHistory(0), doc(0), data(0), comboBoxDraws(0), fileName(QString()), changeInFile(false), mode(Draw::Calculation){ ui->setupUi(this); @@ -94,6 +95,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->toolButtonNewDetail, &QToolButton::clicked, this, &MainWindow::ToolDetail); connect(ui->toolButtonHeight, &QToolButton::clicked, this, &MainWindow::ToolHeight); connect(ui->toolButtonTriangle, &QToolButton::clicked, this, &MainWindow::ToolTriangle); + connect(ui->toolButtonPointOfIntersection, &QToolButton::clicked, this, &MainWindow::ToolPointOfIntersection); data = new VContainer; @@ -485,7 +487,7 @@ void MainWindow::ClosedDialogHeight(int result){ void MainWindow::ToolTriangle(bool checked){ SetToolButton(checked, Tool::Triangle, ":/cursor/triangle_cursor.png", tr("Select first point of axis"), - dialogTriangle, &MainWindow::ClosedDialogTriangle); + dialogTriangle, &MainWindow::ClosedDialogTriangle); } void MainWindow::ClosedDialogTriangle(int result){ @@ -500,6 +502,26 @@ void MainWindow::ClosedDialogTriangle(int result){ ArrowTool(); } +void MainWindow::ToolPointOfIntersection(bool checked){ + SetToolButton(checked, Tool::PointOfIntersection, ":/cursor/pointofintersect_cursor.png", + tr("Select point vertically"), + dialogPointOfIntersection, &MainWindow::ClosedDialogPointOfIntersection); +} + +void MainWindow::ClosedDialogPointOfIntersection(int result){ + if(result == QDialog::Accepted){ + if(mode == Draw::Calculation){ + VToolPointOfIntersection::Create(dialogPointOfIntersection, currentScene, doc, data); + } else { + VModelingPointOfIntersection *point = VModelingPointOfIntersection::Create(dialogPointOfIntersection, + doc, data); + AddToolToDetail(point, point->getId(), Tool::PointOfIntersection, + dialogPointOfIntersection->getIdDetail()); + } + } + ArrowTool(); +} + void MainWindow::About(){ QMessageBox::about(this, tr("About Valentina"), tr("Valentina v.0.1.0")); } @@ -744,6 +766,12 @@ void MainWindow::CanselTool(){ currentScene->setFocus(Qt::OtherFocusReason); currentScene->clearSelection(); break; + case Tool::PointOfIntersection: + dialogPointOfIntersection.clear(); + ui->toolButtonPointOfIntersection->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearSelection(); + break; default: qWarning()<<"Get wrong tool type. Ignore."; break; @@ -986,6 +1014,7 @@ void MainWindow::SetEnableTool(bool enable){ ui->toolButtonNewDetail->setEnabled(enable); ui->toolButtonHeight->setEnabled(enable); ui->toolButtonTriangle->setEnabled(enable); + ui->toolButtonPointOfIntersection->setEnabled(enable); } void MainWindow::MinimumScrollBar(){ diff --git a/mainwindow.h b/mainwindow.h index 2b65763b8..fca2537a4 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -81,6 +81,7 @@ public slots: void ToolDetail(bool checked); void ToolHeight(bool checked); void ToolTriangle(bool checked); + void ToolPointOfIntersection(bool checked); void ClosedDialogEndLine(int result); void ClosedDialogLine(int result); void ClosedDialogAlongLine(int result); @@ -95,6 +96,7 @@ public slots: void ClosedDialogDetail(int result); void ClosedDialogHeight(int result); void ClosedDialogTriangle(int result); + void ClosedDialogPointOfIntersection(int result); void About(); void AboutQt(); void ShowToolTip(const QString &toolTip); @@ -126,27 +128,28 @@ private: VMainGraphicsView *view; bool isInitialized; DialogIncrements *dialogTable; - QSharedPointer dialogEndLine; - QSharedPointer dialogLine; - QSharedPointer dialogAlongLine; - QSharedPointer dialogShoulderPoint; - QSharedPointer dialogNormal; - QSharedPointer dialogBisector; - QSharedPointer dialogLineIntersect; - QSharedPointer dialogSpline; - QSharedPointer dialogArc; - QSharedPointer dialogSplinePath; - QSharedPointer dialogPointOfContact; - QSharedPointer dialogDetail; - QSharedPointer dialogHeight; - QSharedPointer dialogTriangle; + QSharedPointer dialogEndLine; + QSharedPointer dialogLine; + QSharedPointer dialogAlongLine; + QSharedPointer dialogShoulderPoint; + QSharedPointer dialogNormal; + QSharedPointer dialogBisector; + QSharedPointer dialogLineIntersect; + QSharedPointer dialogSpline; + QSharedPointer dialogArc; + QSharedPointer dialogSplinePath; + QSharedPointer dialogPointOfContact; + QSharedPointer dialogDetail; + QSharedPointer dialogHeight; + QSharedPointer dialogTriangle; + QSharedPointer dialogPointOfIntersection; DialogHistory *dialogHistory; VDomDocument *doc; VContainer *data; QComboBox *comboBoxDraws; QString fileName; bool changeInFile; - Draw::Draws mode; + Draw::Draws mode; void ToolBarOption(); void ToolBarDraws(); void CanselTool(); diff --git a/mainwindow.ui b/mainwindow.ui index 920dd684a..2ea6899fd 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -272,6 +272,29 @@ + + + + false + + + ... + + + + :/icon/32x32/point_of_intersection.png:/icon/32x32/point_of_intersection.png + + + + 32 + 32 + + + + true + + + @@ -279,7 +302,7 @@ 0 0 - 100 + 150 58 @@ -355,7 +378,7 @@ 0 0 - 100 + 150 58 @@ -431,7 +454,7 @@ 0 0 - 98 + 150 58 @@ -481,7 +504,7 @@ 0 0 - 98 + 150 58 diff --git a/options.h b/options.h index 71aaa9dfd..5e1a70fab 100644 --- a/options.h +++ b/options.h @@ -57,7 +57,8 @@ enum Tool {ArrowTool, NodeSpline, NodeSplinePath, Height, - Triangle + Triangle, + PointOfIntersection }; Q_DECLARE_FLAGS(Tools, Tool) diff --git a/tools/drawTools/drawtools.h b/tools/drawTools/drawtools.h index 8051d3641..0b07ebc2b 100644 --- a/tools/drawTools/drawtools.h +++ b/tools/drawTools/drawtools.h @@ -36,5 +36,6 @@ #include "vtoolsplinepath.h" #include "vtoolheight.h" #include "vtooltriangle.h" +#include "vtoolpointofintersection.h" #endif // DRAWTOOLS_H diff --git a/tools/drawTools/vtoolline.cpp b/tools/drawTools/vtoolline.cpp index e3fb9e9ac..ced59ed03 100644 --- a/tools/drawTools/vtoolline.cpp +++ b/tools/drawTools/vtoolline.cpp @@ -26,6 +26,7 @@ VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firs Tool::Sources typeCreation, QGraphicsItem *parent):VDrawTool(doc, data, id), QGraphicsLineItem(parent), firstPoint(firstPoint), secondPoint(secondPoint), dialogLine(QSharedPointer()){ + ignoreFullUpdate = true; //Лінія VPointF first = data->GetPoint(firstPoint); VPointF second = data->GetPoint(secondPoint); diff --git a/tools/drawTools/vtoollineintersect.cpp b/tools/drawTools/vtoollineintersect.cpp index 132013d5a..797ce2c26 100644 --- a/tools/drawTools/vtoollineintersect.cpp +++ b/tools/drawTools/vtoollineintersect.cpp @@ -28,6 +28,7 @@ VToolLineIntersect::VToolLineIntersect(VDomDocument *doc, VContainer *data, cons QGraphicsItem *parent): VToolPoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2), p2Line2(p2Line2), dialogLineIntersect(QSharedPointer()){ + ignoreFullUpdate = true; if(typeCreation == Tool::FromGui){ AddToFile(); } diff --git a/tools/drawTools/vtoolpointofintersection.cpp b/tools/drawTools/vtoolpointofintersection.cpp new file mode 100644 index 000000000..10ef3c214 --- /dev/null +++ b/tools/drawTools/vtoolpointofintersection.cpp @@ -0,0 +1,106 @@ +#include "vtoolpointofintersection.h" + +VToolPointOfIntersection::VToolPointOfIntersection(VDomDocument *doc, VContainer *data, const qint64 &id, + const qint64 &firstPointId, const qint64 &secondPointId, + Tool::Sources typeCreation, QGraphicsItem *parent) + :VToolPoint(doc, data, id, parent), firstPointId(firstPointId), secondPointId(secondPointId), + dialogPointOfIntersection(QSharedPointer()) { + ignoreFullUpdate = true; + if(typeCreation == Tool::FromGui){ + AddToFile(); + } +} + +void VToolPointOfIntersection::setDialog(){ + Q_ASSERT(!dialogPointOfIntersection.isNull()); + VPointF p = VAbstractTool::data.GetPoint(id); + dialogPointOfIntersection->setFirstPointId(firstPointId, id); + dialogPointOfIntersection->setSecondPointId(secondPointId, id); + dialogPointOfIntersection->setPointName(p.name()); +} + +void VToolPointOfIntersection::Create(QSharedPointer &dialog, VMainGraphicsScene *scene, + VDomDocument *doc, VContainer *data){ + qint64 firstPointId = dialog->getFirstPointId(); + qint64 secondPointId = dialog->getSecondPointId(); + QString pointName = dialog->getPointName(); + Create(0, pointName, firstPointId, secondPointId, 5, 10, scene, doc, data, Document::FullParse, Tool::FromGui); +} + +void VToolPointOfIntersection::Create(const qint64 _id, const QString &pointName, const qint64 &firstPointId, + const qint64 &secondPointId, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, + const Document::Documents &parse, Tool::Sources typeCreation){ + VPointF firstPoint = data->GetPoint(firstPointId); + VPointF secondPoint = data->GetPoint(secondPointId); + + QPointF point(firstPoint.x(), secondPoint.y()); + qint64 id = _id; + if(typeCreation == Tool::FromGui){ + id = data->AddPoint(VPointF(point.x(), point.y(), pointName, mx, my)); + } else { + data->UpdatePoint(id, VPointF(point.x(), point.y(), pointName, mx, my)); + if(parse != Document::FullParse){ + doc->UpdateToolData(id, data); + } + } + VDrawTool::AddRecord(id, Tool::Triangle, doc); + if(parse == Document::FullParse){ + VToolPointOfIntersection *point = new VToolPointOfIntersection(doc, data, id, firstPointId, + secondPointId, typeCreation); + scene->addItem(point); + connect(point, &VToolPointOfIntersection::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(point, &VToolPointOfIntersection::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfIntersection::SetFactor); + doc->AddTool(id, point); + doc->IncrementReferens(firstPointId); + doc->IncrementReferens(secondPointId); + } +} + +void VToolPointOfIntersection::FullUpdateFromFile(){ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if(domElement.isElement()){ + firstPointId = domElement.attribute("firstPoint", "").toLongLong(); + secondPointId = domElement.attribute("secondPoint", "").toLongLong(); + } + VToolPoint::RefreshPointGeometry(VDrawTool::data.GetPoint(id)); +} + +void VToolPointOfIntersection::FullUpdateFromGui(int result){ + if(result == QDialog::Accepted){ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if(domElement.isElement()){ + domElement.setAttribute("name", dialogPointOfIntersection->getPointName()); + domElement.setAttribute("firstPoint", QString().setNum(dialogPointOfIntersection->getFirstPointId())); + domElement.setAttribute("secondPoint", QString().setNum(dialogPointOfIntersection->getSecondPointId())); + emit FullUpdateTree(); + } + } + dialogPointOfIntersection.clear(); +} + +void VToolPointOfIntersection::RemoveReferens(){ + doc->DecrementReferens(firstPointId); + doc->DecrementReferens(secondPointId); +} + +void VToolPointOfIntersection::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ + ContextMenu(dialogPointOfIntersection, this, event); +} + +void VToolPointOfIntersection::AddToFile(){ + VPointF point = VAbstractTool::data.GetPoint(id); + QDomElement domElement = doc->createElement("point"); + + AddAttribute(domElement, "id", id); + AddAttribute(domElement, "type", "pointOfIntersection"); + AddAttribute(domElement, "name", point.name()); + AddAttribute(domElement, "mx", toMM(point.mx())); + AddAttribute(domElement, "my", toMM(point.my())); + + AddAttribute(domElement, "firstPoint", firstPointId); + AddAttribute(domElement, "secondPoint", secondPointId); + + AddToCalculation(domElement); +} diff --git a/tools/drawTools/vtoolpointofintersection.h b/tools/drawTools/vtoolpointofintersection.h new file mode 100644 index 000000000..206ad322f --- /dev/null +++ b/tools/drawTools/vtoolpointofintersection.h @@ -0,0 +1,33 @@ +#ifndef VTOOLPOINTOFINTERSECTION_H +#define VTOOLPOINTOFINTERSECTION_H + +#include "vtoolpoint.h" +#include "dialogs/dialogpointofintersection.h" + +class VToolPointOfIntersection : public VToolPoint{ + Q_OBJECT +public: + VToolPointOfIntersection(VDomDocument *doc, VContainer *data, const qint64 &id, const qint64 &firstPointId, + const qint64 &secondPointId, Tool::Sources typeCreation, QGraphicsItem * parent = 0); + virtual void setDialog(); + static void Create(QSharedPointer &dialog, VMainGraphicsScene *scene, + VDomDocument *doc, VContainer *data); + static void Create(const qint64 _id, const QString &pointName, const qint64 &firstPointId, + const qint64 &secondPointId, const qreal &mx, const qreal &my, + VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, + const Document::Documents &parse, Tool::Sources typeCreation); +public slots: + virtual void FullUpdateFromFile(); + virtual void FullUpdateFromGui(int result); +protected: + virtual void RemoveReferens(); + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void AddToFile(); +private: + Q_DISABLE_COPY(VToolPointOfIntersection) + qint64 firstPointId; + qint64 secondPointId; + QSharedPointer dialogPointOfIntersection; +}; + +#endif // VTOOLPOINTOFINTERSECTION_H diff --git a/tools/drawTools/vtoolspline.cpp b/tools/drawTools/vtoolspline.cpp index 25efb8ab6..00d3478fb 100644 --- a/tools/drawTools/vtoolspline.cpp +++ b/tools/drawTools/vtoolspline.cpp @@ -28,6 +28,7 @@ VToolSpline::VToolSpline(VDomDocument *doc, VContainer *data, qint64 id, Tool::Sources typeCreation, QGraphicsItem *parent):VDrawTool(doc, data, id), QGraphicsPathItem(parent), dialogSpline(QSharedPointer()), controlPoints(QVector()){ + ignoreFullUpdate = true; VSpline spl = data->GetSpline(id); QPainterPath path; diff --git a/tools/drawTools/vtoolsplinepath.cpp b/tools/drawTools/vtoolsplinepath.cpp index ca9fb7b0d..f13333e62 100644 --- a/tools/drawTools/vtoolsplinepath.cpp +++ b/tools/drawTools/vtoolsplinepath.cpp @@ -27,6 +27,7 @@ VToolSplinePath::VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id, QGraphicsItem *parent):VDrawTool(doc, data, id), QGraphicsPathItem(parent), dialogSplinePath(QSharedPointer()), controlPoints(QVector()){ + ignoreFullUpdate = true; VSplinePath splPath = data->GetSplinePath(id); QPainterPath path; path.addPath(splPath.GetPath()); diff --git a/tools/drawTools/vtooltriangle.cpp b/tools/drawTools/vtooltriangle.cpp index d19f498b7..79fd2c3d2 100644 --- a/tools/drawTools/vtooltriangle.cpp +++ b/tools/drawTools/vtooltriangle.cpp @@ -5,6 +5,7 @@ VToolTriangle::VToolTriangle(VDomDocument *doc, VContainer *data, const qint64 & const qint64 &secondPointId, Tool::Sources typeCreation, QGraphicsItem *parent) :VToolPoint(doc, data, id, parent), axisP1Id(axisP1Id), axisP2Id(axisP2Id), firstPointId(firstPointId), secondPointId(secondPointId), dialogTriangle(QSharedPointer()) { + ignoreFullUpdate = true; if(typeCreation == Tool::FromGui){ AddToFile(); } @@ -29,7 +30,6 @@ void VToolTriangle::Create(QSharedPointer &dialog, VMainGraphics QString pointName = dialog->getPointName(); Create(0, pointName, axisP1Id, axisP2Id, firstPointId, secondPointId, 5, 10, scene, doc, data, Document::FullParse, Tool::FromGui); - } void VToolTriangle::Create(const qint64 _id, const QString &pointName, const qint64 &axisP1Id, diff --git a/tools/modelingTools/modelingtools.h b/tools/modelingTools/modelingtools.h index bd61fee59..2fbf1dfad 100644 --- a/tools/modelingTools/modelingtools.h +++ b/tools/modelingTools/modelingtools.h @@ -36,5 +36,6 @@ #include "vmodelingsplinepath.h" #include "vmodelingheight.h" #include "vmodelingtriangle.h" +#include "vmodelingpointofintersection.h" #endif // MODELINGTOOLS_H diff --git a/tools/modelingTools/vmodelingline.cpp b/tools/modelingTools/vmodelingline.cpp index b9c03f4ca..ea09c70a7 100644 --- a/tools/modelingTools/vmodelingline.cpp +++ b/tools/modelingTools/vmodelingline.cpp @@ -26,6 +26,7 @@ VModelingLine::VModelingLine(VDomDocument *doc, VContainer *data, qint64 id, qin qint64 secondPoint, Tool::Sources typeCreation, QGraphicsItem *parent): VModelingTool(doc, data, id), QGraphicsLineItem(parent), firstPoint(firstPoint), secondPoint(secondPoint), dialogLine(QSharedPointer()){ + ignoreFullUpdate = true; //Лінія VPointF first = data->GetModelingPoint(firstPoint); VPointF second = data->GetModelingPoint(secondPoint); diff --git a/tools/modelingTools/vmodelinglineintersect.cpp b/tools/modelingTools/vmodelinglineintersect.cpp index 51a45e7d0..0ae7c31a3 100644 --- a/tools/modelingTools/vmodelinglineintersect.cpp +++ b/tools/modelingTools/vmodelinglineintersect.cpp @@ -26,6 +26,7 @@ VModelingLineIntersect::VModelingLineIntersect(VDomDocument *doc, VContainer *da const qint64 &p2Line2, Tool::Sources typeCreation, QGraphicsItem *parent): VModelingPoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2), p2Line2(p2Line2), dialogLineIntersect(QSharedPointer()){ + ignoreFullUpdate = true; if(typeCreation == Tool::FromGui){ AddToFile(); } diff --git a/tools/modelingTools/vmodelingpointofintersection.cpp b/tools/modelingTools/vmodelingpointofintersection.cpp new file mode 100644 index 000000000..70d4db79d --- /dev/null +++ b/tools/modelingTools/vmodelingpointofintersection.cpp @@ -0,0 +1,105 @@ +#include "vmodelingpointofintersection.h" + +VModelingPointOfIntersection::VModelingPointOfIntersection(VDomDocument *doc, VContainer *data, const qint64 &id, + const qint64 &firstPointId, const qint64 &secondPointId, + Tool::Sources typeCreation, QGraphicsItem *parent) + :VModelingPoint(doc, data, id, parent), firstPointId(firstPointId), secondPointId(secondPointId), + dialogPointOfIntersection(QSharedPointer()) { + ignoreFullUpdate = true; + if(typeCreation == Tool::FromGui){ + AddToFile(); + } +} + +void VModelingPointOfIntersection::setDialog(){ + Q_ASSERT(!dialogPointOfIntersection.isNull()); + VPointF p = VAbstractTool::data.GetPoint(id); + dialogPointOfIntersection->setFirstPointId(firstPointId, id); + dialogPointOfIntersection->setSecondPointId(secondPointId, id); + dialogPointOfIntersection->setPointName(p.name()); +} + +VModelingPointOfIntersection *VModelingPointOfIntersection::Create(QSharedPointer &dialog, + VDomDocument *doc, VContainer *data){ + qint64 firstPointId = dialog->getFirstPointId(); + qint64 secondPointId = dialog->getSecondPointId(); + QString pointName = dialog->getPointName(); + return Create(0, pointName, firstPointId, secondPointId, 5, 10, doc, data, Document::FullParse, Tool::FromGui); +} + +VModelingPointOfIntersection *VModelingPointOfIntersection::Create(const qint64 _id, const QString &pointName, + const qint64 &firstPointId, + const qint64 &secondPointId, const qreal &mx, + const qreal &my, VDomDocument *doc, + VContainer *data, + const Document::Documents &parse, + Tool::Sources typeCreation){ + VModelingPointOfIntersection *tool = 0; + VPointF firstPoint = data->GetPoint(firstPointId); + VPointF secondPoint = data->GetPoint(secondPointId); + + QPointF point(firstPoint.x(), secondPoint.y()); + qint64 id = _id; + if(typeCreation == Tool::FromGui){ + id = data->AddPoint(VPointF(point.x(), point.y(), pointName, mx, my)); + } else { + data->UpdatePoint(id, VPointF(point.x(), point.y(), pointName, mx, my)); + if(parse != Document::FullParse){ + doc->UpdateToolData(id, data); + } + } + if(parse == Document::FullParse){ + tool = new VModelingPointOfIntersection(doc, data, id, firstPointId, secondPointId, typeCreation); + doc->AddTool(id, tool); + doc->IncrementReferens(firstPointId); + doc->IncrementReferens(secondPointId); + } + return tool; +} + +void VModelingPointOfIntersection::FullUpdateFromFile(){ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if(domElement.isElement()){ + firstPointId = domElement.attribute("firstPoint", "").toLongLong(); + secondPointId = domElement.attribute("secondPoint", "").toLongLong(); + } + VModelingPoint::RefreshPointGeometry(VModelingTool::data.GetPoint(id)); +} + +void VModelingPointOfIntersection::FullUpdateFromGui(int result){ + if(result == QDialog::Accepted){ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if(domElement.isElement()){ + domElement.setAttribute("name", dialogPointOfIntersection->getPointName()); + domElement.setAttribute("firstPoint", QString().setNum(dialogPointOfIntersection->getFirstPointId())); + domElement.setAttribute("secondPoint", QString().setNum(dialogPointOfIntersection->getSecondPointId())); + emit FullUpdateTree(); + } + } + dialogPointOfIntersection.clear(); +} + +void VModelingPointOfIntersection::RemoveReferens(){ + doc->DecrementReferens(firstPointId); + doc->DecrementReferens(secondPointId); +} + +void VModelingPointOfIntersection::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ + ContextMenu(dialogPointOfIntersection, this, event); +} + +void VModelingPointOfIntersection::AddToFile(){ + VPointF point = VAbstractTool::data.GetPoint(id); + QDomElement domElement = doc->createElement("point"); + + AddAttribute(domElement, "id", id); + AddAttribute(domElement, "type", "pointOfIntersection"); + AddAttribute(domElement, "name", point.name()); + AddAttribute(domElement, "mx", toMM(point.mx())); + AddAttribute(domElement, "my", toMM(point.my())); + + AddAttribute(domElement, "firstPoint", firstPointId); + AddAttribute(domElement, "secondPoint", secondPointId); + + AddToModeling(domElement); +} diff --git a/tools/modelingTools/vmodelingpointofintersection.h b/tools/modelingTools/vmodelingpointofintersection.h new file mode 100644 index 000000000..1c4c94397 --- /dev/null +++ b/tools/modelingTools/vmodelingpointofintersection.h @@ -0,0 +1,35 @@ +#ifndef VMODELINGPOINTOFINTERSECTION_H +#define VMODELINGPOINTOFINTERSECTION_H + +#include "vmodelingpoint.h" +#include "dialogs/dialogpointofintersection.h" + +class VModelingPointOfIntersection : public VModelingPoint{ + Q_OBJECT +public: + VModelingPointOfIntersection(VDomDocument *doc, VContainer *data, const qint64 &id, + const qint64 &firstPointId, const qint64 &secondPointId, + Tool::Sources typeCreation, QGraphicsItem * parent = 0); + virtual void setDialog(); + static VModelingPointOfIntersection* Create(QSharedPointer &dialog, VDomDocument *doc, + VContainer *data); + static VModelingPointOfIntersection* Create(const qint64 _id, const QString &pointName, + const qint64 &firstPointId, const qint64 &secondPointId, + const qreal &mx, const qreal &my, VDomDocument *doc, + VContainer *data, const Document::Documents &parse, + Tool::Sources typeCreation); +public slots: + virtual void FullUpdateFromFile(); + virtual void FullUpdateFromGui(int result); +protected: + virtual void RemoveReferens(); + virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); + virtual void AddToFile(); +private: + Q_DISABLE_COPY(VModelingPointOfIntersection) + qint64 firstPointId; + qint64 secondPointId; + QSharedPointer dialogPointOfIntersection; +}; + +#endif // VMODELINGPOINTOFINTERSECTION_H diff --git a/tools/modelingTools/vmodelingspline.cpp b/tools/modelingTools/vmodelingspline.cpp index 17467591b..ccc1a8bb6 100644 --- a/tools/modelingTools/vmodelingspline.cpp +++ b/tools/modelingTools/vmodelingspline.cpp @@ -29,7 +29,7 @@ VModelingSpline::VModelingSpline(VDomDocument *doc, VContainer *data, qint64 id, Tool::Sources typeCreation, QGraphicsItem *parent):VModelingTool(doc, data, id), QGraphicsPathItem(parent), dialogSpline(QSharedPointer()), controlPoints(QVector()){ - + ignoreFullUpdate = true; VSpline spl = data->GetModelingSpline(id); QPainterPath path; path.addPath(spl.GetPath()); diff --git a/tools/modelingTools/vmodelingsplinepath.cpp b/tools/modelingTools/vmodelingsplinepath.cpp index 6756e0d4c..75d4f6c98 100644 --- a/tools/modelingTools/vmodelingsplinepath.cpp +++ b/tools/modelingTools/vmodelingsplinepath.cpp @@ -27,6 +27,7 @@ VModelingSplinePath::VModelingSplinePath(VDomDocument *doc, VContainer *data, qi QGraphicsItem *parent):VModelingTool(doc, data, id), QGraphicsPathItem(parent), dialogSplinePath(QSharedPointer()), controlPoints(QVector()){ + ignoreFullUpdate = true; VSplinePath splPath = data->GetModelingSplinePath(id); QPainterPath path; path.addPath(splPath.GetPath()); diff --git a/tools/modelingTools/vmodelingtriangle.cpp b/tools/modelingTools/vmodelingtriangle.cpp index e2f722a07..feeb7c1c5 100644 --- a/tools/modelingTools/vmodelingtriangle.cpp +++ b/tools/modelingTools/vmodelingtriangle.cpp @@ -32,7 +32,6 @@ VModelingTriangle *VModelingTriangle::Create(QSharedPointer &dia QString pointName = dialog->getPointName(); return Create(0, pointName, axisP1Id, axisP2Id, firstPointId, secondPointId, 5, 10, doc, data, Document::FullParse, Tool::FromGui); - } VModelingTriangle *VModelingTriangle::Create(const qint64 _id, const QString &pointName, diff --git a/xml/vdomdocument.cpp b/xml/vdomdocument.cpp index e4d31e700..7d3cfc2fd 100644 --- a/xml/vdomdocument.cpp +++ b/xml/vdomdocument.cpp @@ -857,6 +857,30 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen throw excep; } } + if(type == "pointOfIntersection"){ + try{ + qint64 id = GetParametrId(domElement); + QString name = GetParametrString(domElement, "name"); + qreal mx = toPixel(GetParametrDouble(domElement, "mx")); + qreal my = toPixel(GetParametrDouble(domElement, "my")); + qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint"); + qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint"); + + if(mode == Draw::Calculation){ + VToolPointOfIntersection::Create(id, name, firstPointId, secondPointId, mx, my, scene, this, data, + parse, Tool::FromFile); + } else { + VModelingPointOfIntersection::Create(id, name, firstPointId, secondPointId, mx, my, this, data, + parse, Tool::FromFile); + } + return; + } + catch(const VExceptionBadId &e){ + VExceptionObjectError excep(tr("Error creating or updating point of intersection"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + } } void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement,