From 0263b60e3cff79b9e44a0cd0b11ad7949f533c5a Mon Sep 17 00:00:00 2001 From: dismine Date: Fri, 18 Oct 2013 21:20:54 +0300 Subject: [PATCH] New tool triangle. --HG-- branch : develop --- Valentina.pro | 13 +- cursor.qrc | 1 + cursor/triangle_cursor.png | Bin 0 -> 1480 bytes dialogs/dialogheight.cpp | 1 - dialogs/dialogheight.ui | 3 + dialogs/dialoghistory.cpp | 15 ++ dialogs/dialogtriangle.cpp | 125 ++++++++++++++ dialogs/dialogtriangle.h | 42 +++++ dialogs/dialogtriangle.ui | 196 ++++++++++++++++++++++ icon.qrc | 1 + icon/32x32/triangle.png | Bin 0 -> 3907 bytes mainwindow.cpp | 29 ++++ mainwindow.h | 6 +- mainwindow.ui | 34 +++- options.h | 3 +- tools/drawTools/drawtools.h | 1 + tools/drawTools/vtoolalongline.cpp | 4 +- tools/drawTools/vtoolshoulderpoint.cpp | 28 ++-- tools/drawTools/vtooltriangle.cpp | 150 +++++++++++++++++ tools/drawTools/vtooltriangle.h | 39 +++++ tools/modelingTools/modelingtools.h | 1 + tools/modelingTools/vmodelingtriangle.cpp | 127 ++++++++++++++ tools/modelingTools/vmodelingtriangle.h | 39 +++++ tools/vtooldetail.cpp | 16 ++ xml/vdomdocument.cpp | 26 +++ 25 files changed, 873 insertions(+), 27 deletions(-) create mode 100644 cursor/triangle_cursor.png create mode 100644 dialogs/dialogtriangle.cpp create mode 100644 dialogs/dialogtriangle.h create mode 100644 dialogs/dialogtriangle.ui create mode 100644 icon/32x32/triangle.png create mode 100644 tools/drawTools/vtooltriangle.cpp create mode 100644 tools/drawTools/vtooltriangle.h create mode 100644 tools/modelingTools/vmodelingtriangle.cpp create mode 100644 tools/modelingTools/vmodelingtriangle.h diff --git a/Valentina.pro b/Valentina.pro index c05bf37e1..74ac8fbca 100644 --- a/Valentina.pro +++ b/Valentina.pro @@ -100,7 +100,10 @@ SOURCES += main.cpp\ exception/vexceptionuniqueid.cpp \ tools/drawTools/vtoolheight.cpp \ tools/modelingTools/vmodelingheight.cpp \ - dialogs/dialogheight.cpp + dialogs/dialogheight.cpp \ + tools/drawTools/vtooltriangle.cpp \ + tools/modelingTools/vmodelingtriangle.cpp \ + dialogs/dialogtriangle.cpp HEADERS += mainwindow.h \ widgets/vmaingraphicsscene.h \ @@ -194,7 +197,10 @@ HEADERS += mainwindow.h \ exception/vexceptionuniqueid.h \ tools/drawTools/vtoolheight.h \ tools/modelingTools/vmodelingheight.h \ - dialogs/dialogheight.h + dialogs/dialogheight.h \ + tools/drawTools/vtooltriangle.h \ + tools/modelingTools/vmodelingtriangle.h \ + dialogs/dialogtriangle.h FORMS += mainwindow.ui \ dialogs/dialogsinglepoint.ui \ @@ -213,7 +219,8 @@ FORMS += mainwindow.ui \ dialogs/dialogpointofcontact.ui \ dialogs/dialogdetail.ui \ tablewindow.ui \ - dialogs/dialogheight.ui + dialogs/dialogheight.ui \ + dialogs/dialogtriangle.ui RESOURCES += \ icon.qrc \ diff --git a/cursor.qrc b/cursor.qrc index b38ff9e43..a0827a0a2 100644 --- a/cursor.qrc +++ b/cursor.qrc @@ -13,5 +13,6 @@ cursor/pointcontact_cursor.png cursor/new_detail_cursor.png cursor/height_cursor.png + cursor/triangle_cursor.png diff --git a/cursor/triangle_cursor.png b/cursor/triangle_cursor.png new file mode 100644 index 0000000000000000000000000000000000000000..2fc657ce879efdd8520dad8db447d914bf2fa432 GIT binary patch literal 1480 zcmV;(1vmPMP)Vl&|00006VoOIv0RI60 z0RN!9r;`8x010qNS#tmY3ljhU3ljkVnw%H_000McNliru-3k&A89I~x@jd_m06}y` zSad^gZEa<4bO1wAML|?gQaT`KWG!lNWoICEF)lD5D0OpbZf77#N=G0{P(?=|b~Z98 zEFf`pVQgu1c_2L?IWP*aMOc#n00jt1L_t(Y$HkUyXq9Cc$A993kp^*4|KFZ34mIVtI z_$MvqiFl`)QVPd$5D}W1nuZeRr%s(xlO}trX|3t*?v|>mD$!a~RaM1`6)XN5@N|q5 zX4^KN=K-kW$BzTBc=6%~2E6_?Ry0bL2y3moT~tb;wMIk`kz_Nvdi5$mVBx}rkKZr2 zcB!&Fj!wzoIcFk2P)dyo$L`&`$;`~`?(FOYn6Uhv$Enl<9G(_{3_sCP**?}%!!hZ(>bD)qNAgOP$<;V z+uKWSZtfOfPg=%Dd49N?Z}X>8;P-=gAZARdO*8}|f-wdWp}oDG8#it+G&B@V+-YuZ zPTs%zB~Q46e3j+!NI?-;Dh@7j@VjMux{x@IlXN0co@dUSdB3u<^3VGE`s?%O&j+C6 z2!(o(@3I_b6$K$W0>;BL28}+^!q5u z3&2PO28MY#ZwmDpK7!-GZQD*}bt1!aa&n}+yj+FD;ZYq=Yn|+TB7*C>0A6Wn>G0(* z$k$;$_l77boC~gjfiO#FuI5Z{1Fp}G$?l|MYFQS>7?e^hTC_-=Jb7}$<#hi11$AjJ zdowIvnOy<{{dg{HnYo(pA(m*y#Ns|G=EfK-%St+sNURelPTX^({<$->10A|R%gzUw_}{H){FBx?DkFpJ&km50mj`_VT<#fW&6`K(_7)fQ(0!*L5f4Ej#3UCx zrNcRn^DeNat*z~~ix)30O(QFS8(%sB+`f+&hWj{DG>wd$9Ow^osV~gDo#$S?skMjp zT%wT(BO@c+ywy!l&uzqD5=o~f5YM#j@5%v6db()N%_g^C8UTZRL%axdX_H|&Dk_QB z1+YO!45bA*{N&j9qMF+e1m5%>vqbYlwx8KEg5c^{({MfT3|>+#HTogP#>$ANctmr{ zx!=Lkyn{S(IS`o2>?u<~yD|5ag3Q=!_P8ORvJn$^)a8$RfsbQtSr~joHMo%|I^w1W iNqZFEXpa`xBlI_6Mqud%g5MVa0000setupUi(this); labelEditNamePoint = ui->labelEditNamePoint; - flagFormula = true; bOk = ui->buttonBox->button(QDialogButtonBox::Ok); connect(bOk, &QPushButton::clicked, this, &DialogHeight::DialogAccepted); flagName = false; diff --git a/dialogs/dialogheight.ui b/dialogs/dialogheight.ui index bfb3dab67..9c4900050 100644 --- a/dialogs/dialogheight.ui +++ b/dialogs/dialogheight.ui @@ -13,6 +13,9 @@ Dialog + + + diff --git a/dialogs/dialoghistory.cpp b/dialogs/dialoghistory.cpp index d1b19544a..10df37d63 100644 --- a/dialogs/dialoghistory.cpp +++ b/dialogs/dialoghistory.cpp @@ -264,6 +264,21 @@ QString DialogHistory::Record(const VToolRecord &tool){ data->GetPoint(p2LineId).name()); break; } + case Tool::Triangle:{ + qint64 axisP1Id = 0; + qint64 axisP2Id = 0; + domElement = doc->elementById(QString().setNum(tool.getId())); + if(domElement.isElement()){ + axisP1Id = domElement.attribute("axisP1", "").toLongLong(); + axisP2Id = domElement.attribute("axisP2", "").toLongLong(); + firstPointId = domElement.attribute("firstPoint", "").toLongLong(); + secondPointId = domElement.attribute("secondPoint", "").toLongLong(); + } + record = QString(tr("Triangle: axis %1_%2, points %3 and %4")).arg( + data->GetPoint(axisP1Id).name(),data->GetPoint(axisP2Id).name(), + data->GetPoint(firstPointId).name(), data->GetPoint(secondPointId).name()); + break; + } default: qWarning()<setupUi(this); + labelEditNamePoint = ui->labelEditNamePoint; + bOk = ui->buttonBox->button(QDialogButtonBox::Ok); + connect(bOk, &QPushButton::clicked, this, &DialogTriangle::DialogAccepted); + flagName = false; + CheckState(); + QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); + connect(bCansel, &QPushButton::clicked, this, &DialogTriangle::DialogRejected); + FillComboBoxPoints(ui->comboBoxAxisP1); + FillComboBoxPoints(ui->comboBoxAxisP2); + FillComboBoxPoints(ui->comboBoxFirstPoint); + FillComboBoxPoints(ui->comboBoxSecondPoint); + connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogTriangle::NamePointChanged); +} + +DialogTriangle::~DialogTriangle(){ + delete ui; +} + +void DialogTriangle::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); + } + switch(number){ + case(0): + ChangeCurrentText(ui->comboBoxAxisP1, point.name()); + number++; + emit ToolTip(tr("Select second point of axis")); + break; + case(1): + ChangeCurrentText(ui->comboBoxAxisP2, point.name()); + number++; + emit ToolTip(tr("Select first point")); + break; + case(2): + ChangeCurrentText(ui->comboBoxFirstPoint, point.name()); + number++; + emit ToolTip(tr("Select second point")); + break; + case(3): + ChangeCurrentText(ui->comboBoxSecondPoint, point.name()); + number = 0; + emit ToolTip(tr("")); + if(!isInitialized){ + this->show(); + } + break; + } + } +} + +void DialogTriangle::DialogAccepted(){ + pointName = ui->lineEditNamePoint->text(); + firstPointId = getCurrentPointId(ui->comboBoxFirstPoint); + secondPointId = getCurrentPointId(ui->comboBoxSecondPoint); + axisP1Id = getCurrentPointId(ui->comboBoxAxisP1); + axisP2Id = getCurrentPointId(ui->comboBoxAxisP2); + emit DialogClosed(QDialog::Accepted); +} +QString DialogTriangle::getPointName() const{ + return pointName; +} + +void DialogTriangle::setPointName(const QString &value){ + pointName = value; + ui->lineEditNamePoint->setText(pointName); +} + +qint64 DialogTriangle::getSecondPointId() const{ + return secondPointId; +} + +void DialogTriangle::setSecondPointId(const qint64 &value, const qint64 &id){ + secondPointId = value; + setCurrentPointId(ui->comboBoxSecondPoint, secondPointId, value, id); +} + +qint64 DialogTriangle::getFirstPointId() const{ + return firstPointId; +} + +void DialogTriangle::setFirstPointId(const qint64 &value, const qint64 &id){ + firstPointId = value; + setCurrentPointId(ui->comboBoxFirstPoint, firstPointId, value, id); +} + +qint64 DialogTriangle::getAxisP2Id() const{ + return axisP2Id; +} + +void DialogTriangle::setAxisP2Id(const qint64 &value, const qint64 &id){ + axisP2Id = value; + setCurrentPointId(ui->comboBoxAxisP2, axisP2Id, value, id); +} + +qint64 DialogTriangle::getAxisP1Id() const{ + return axisP1Id; +} + +void DialogTriangle::setAxisP1Id(const qint64 &value, const qint64 &id){ + axisP1Id = value; + setCurrentPointId(ui->comboBoxAxisP1, axisP1Id, value, id); +} + diff --git a/dialogs/dialogtriangle.h b/dialogs/dialogtriangle.h new file mode 100644 index 000000000..74c9bcf3c --- /dev/null +++ b/dialogs/dialogtriangle.h @@ -0,0 +1,42 @@ +#ifndef DIALOGTRIANGLE_H +#define DIALOGTRIANGLE_H + +#include "dialogtool.h" + +namespace Ui { +class DialogTriangle; +} + +class DialogTriangle : public DialogTool +{ + Q_OBJECT + +public: + DialogTriangle(const VContainer *data, Draw::Draws mode = Draw::Calculation, + QWidget *parent = 0); + ~DialogTriangle(); + qint64 getAxisP1Id() const; + void setAxisP1Id(const qint64 &value, const qint64 &id); + qint64 getAxisP2Id() const; + void setAxisP2Id(const qint64 &value, const qint64 &id); + qint64 getFirstPointId() const; + void setFirstPointId(const qint64 &value, const qint64 &id); + qint64 getSecondPointId() const; + void setSecondPointId(const qint64 &value, const qint64 &id); + QString getPointName() const; + void setPointName(const QString &value); +public slots: + virtual void ChoosedObject(qint64 id, Scene::Scenes type); + virtual void DialogAccepted(); +private: + Q_DISABLE_COPY(DialogTriangle) + Ui::DialogTriangle *ui; + qint32 number; + QString pointName; + qint64 axisP1Id; + qint64 axisP2Id; + qint64 firstPointId; + qint64 secondPointId; +}; + +#endif // DIALOGTRIANGLE_H diff --git a/dialogs/dialogtriangle.ui b/dialogs/dialogtriangle.ui new file mode 100644 index 000000000..7e788b2f0 --- /dev/null +++ b/dialogs/dialogtriangle.ui @@ -0,0 +1,196 @@ + + + DialogTriangle + + + + 0 + 0 + 267 + 220 + + + + Dialog + + + + + + + + + + + + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 255 + 0 + 0 + + + + + + + + + 159 + 158 + 158 + + + + + + + + Name new point + + + + + + + + + + + + + + First point of axis + + + + + + + First point of line + + + + + + + + + + + Second point of axis + + + + + + + First point of line + + + + + + + + + + + First point + + + + + + + First point of line + + + + + + + + + + + Second point + + + + + + + First point of line + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + DialogTriangle + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogTriangle + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/icon.qrc b/icon.qrc index e5bf6d0ed..520ff398d 100644 --- a/icon.qrc +++ b/icon.qrc @@ -35,5 +35,6 @@ icon/32x32/layout.png icon/16x16/mirror.png icon/32x32/height.png + icon/32x32/triangle.png diff --git a/icon/32x32/triangle.png b/icon/32x32/triangle.png new file mode 100644 index 0000000000000000000000000000000000000000..c409b3b41367a854e73a52140cd08a6780d7fefc GIT binary patch literal 3907 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 RSnB`)002ovPDHLkV1hvcS0Vra literal 0 HcmV?d00001 diff --git a/mainwindow.cpp b/mainwindow.cpp index 7befade91..37e1be32c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -48,6 +48,7 @@ MainWindow::MainWindow(QWidget *parent) : dialogArc(QSharedPointer()), dialogSplinePath(QSharedPointer()), dialogPointOfContact(QSharedPointer()), dialogDetail(QSharedPointer()), dialogHeight(QSharedPointer()), + dialogTriangle(QSharedPointer()), dialogHistory(0), doc(0), data(0), comboBoxDraws(0), fileName(QString()), changeInFile(false), mode(Draw::Calculation){ ui->setupUi(this); @@ -92,6 +93,7 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->toolButtonPointOfContact, &QToolButton::clicked, this, &MainWindow::ToolPointOfContact); connect(ui->toolButtonNewDetail, &QToolButton::clicked, this, &MainWindow::ToolDetail); connect(ui->toolButtonHeight, &QToolButton::clicked, this, &MainWindow::ToolHeight); + connect(ui->toolButtonTriangle, &QToolButton::clicked, this, &MainWindow::ToolTriangle); data = new VContainer; @@ -481,6 +483,23 @@ void MainWindow::ClosedDialogHeight(int result){ ArrowTool(); } +void MainWindow::ToolTriangle(bool checked){ + SetToolButton(checked, Tool::Triangle, ":/cursor/triangle_cursor.png", tr("Select first point of axis"), + dialogTriangle, &MainWindow::ClosedDialogTriangle); +} + +void MainWindow::ClosedDialogTriangle(int result){ + if(result == QDialog::Accepted){ + if(mode == Draw::Calculation){ + VToolTriangle::Create(dialogTriangle, currentScene, doc, data); + } else { + VModelingTriangle *point = VModelingTriangle::Create(dialogTriangle, doc, data); + AddToolToDetail(point, point->getId(), Tool::Triangle, dialogTriangle->getIdDetail()); + } + } + ArrowTool(); +} + void MainWindow::About(){ QMessageBox::about(this, tr("About Valentina"), tr("Valentina v.0.1.0")); } @@ -640,6 +659,7 @@ void MainWindow::CanselTool(){ helpLabel->setText(""); break; case Tool::SinglePointTool: + Q_UNREACHABLE(); //Nothing to do here because we can't create this tool from main window. break; case Tool::EndLineTool: @@ -715,6 +735,14 @@ void MainWindow::CanselTool(){ case Tool::Height: dialogHeight.clear(); ui->toolButtonHeight->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearSelection(); + break; + case Tool::Triangle: + dialogTriangle.clear(); + ui->toolButtonTriangle->setChecked(false); + currentScene->setFocus(Qt::OtherFocusReason); + currentScene->clearSelection(); break; default: qWarning()<<"Get wrong tool type. Ignore."; @@ -957,6 +985,7 @@ void MainWindow::SetEnableTool(bool enable){ ui->toolButtonPointOfContact->setEnabled(enable); ui->toolButtonNewDetail->setEnabled(enable); ui->toolButtonHeight->setEnabled(enable); + ui->toolButtonTriangle->setEnabled(enable); } void MainWindow::MinimumScrollBar(){ diff --git a/mainwindow.h b/mainwindow.h index 844052539..2b65763b8 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -41,8 +41,7 @@ namespace Ui { class MainWindow; } -class MainWindow : public QMainWindow -{ +class MainWindow : public QMainWindow{ Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); @@ -81,6 +80,7 @@ public slots: void ToolPointOfContact(bool checked); void ToolDetail(bool checked); void ToolHeight(bool checked); + void ToolTriangle(bool checked); void ClosedDialogEndLine(int result); void ClosedDialogLine(int result); void ClosedDialogAlongLine(int result); @@ -94,6 +94,7 @@ public slots: void ClosedDialogPointOfContact(int result); void ClosedDialogDetail(int result); void ClosedDialogHeight(int result); + void ClosedDialogTriangle(int result); void About(); void AboutQt(); void ShowToolTip(const QString &toolTip); @@ -138,6 +139,7 @@ private: QSharedPointer dialogPointOfContact; QSharedPointer dialogDetail; QSharedPointer dialogHeight; + QSharedPointer dialogTriangle; DialogHistory *dialogHistory; VDomDocument *doc; VContainer *data; diff --git a/mainwindow.ui b/mainwindow.ui index 0e9a0df8b..920dd684a 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -246,6 +246,32 @@ + + + + false + + + Tool triangle. + + + ... + + + + :/icon/32x32/triangle.png:/icon/32x32/triangle.png + + + + 32 + 32 + + + + true + + + @@ -253,7 +279,7 @@ 0 0 - 150 + 100 58 @@ -329,7 +355,7 @@ 0 0 - 150 + 100 58 @@ -405,7 +431,7 @@ 0 0 - 150 + 98 58 @@ -455,7 +481,7 @@ 0 0 - 150 + 98 58 diff --git a/options.h b/options.h index 28b99f2d9..71aaa9dfd 100644 --- a/options.h +++ b/options.h @@ -56,7 +56,8 @@ enum Tool {ArrowTool, NodeArc, NodeSpline, NodeSplinePath, - Height + Height, + Triangle }; Q_DECLARE_FLAGS(Tools, Tool) diff --git a/tools/drawTools/drawtools.h b/tools/drawTools/drawtools.h index 58fcbaf08..8051d3641 100644 --- a/tools/drawTools/drawtools.h +++ b/tools/drawTools/drawtools.h @@ -35,5 +35,6 @@ #include "vtoolspline.h" #include "vtoolsplinepath.h" #include "vtoolheight.h" +#include "vtooltriangle.h" #endif // DRAWTOOLS_H diff --git a/tools/drawTools/vtoolalongline.cpp b/tools/drawTools/vtoolalongline.cpp index 8d54e14bc..905a5ea98 100644 --- a/tools/drawTools/vtoolalongline.cpp +++ b/tools/drawTools/vtoolalongline.cpp @@ -79,8 +79,8 @@ void VToolAlongLine::AddToFile(){ AddAttribute(domElement, "id", id); AddAttribute(domElement, "type", "alongLine"); AddAttribute(domElement, "name", point.name()); - AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4); - AddAttribute(domElement, "my", point.my()/PrintDPI*25.4); + AddAttribute(domElement, "mx", toMM(point.mx())); + AddAttribute(domElement, "my", toMM(point.my())); AddAttribute(domElement, "typeLine", typeLine); AddAttribute(domElement, "length", formula); diff --git a/tools/drawTools/vtoolshoulderpoint.cpp b/tools/drawTools/vtoolshoulderpoint.cpp index 4e3307a51..f1ee18525 100644 --- a/tools/drawTools/vtoolshoulderpoint.cpp +++ b/tools/drawTools/vtoolshoulderpoint.cpp @@ -51,22 +51,22 @@ void VToolShoulderPoint::setDialog(){ QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder, const qreal &length){ QLineF line = QLineF(p1Line, p2Line); - qreal dist = line.length(); - if(dist>length){ - qDebug()<<"A3П2="<length){ + qDebug()<<"A3П2="<=length){ return line.p2(); } - qreal step = 0.01; - while(1){ - line.setLength(line.length()+step); - QLineF line2 = QLineF(pShoulder, line.p2()); - if(line2.length()>=length){ - return line.p2(); - } - } + } } void VToolShoulderPoint::Create(QSharedPointer &dialog, VMainGraphicsScene *scene, diff --git a/tools/drawTools/vtooltriangle.cpp b/tools/drawTools/vtooltriangle.cpp new file mode 100644 index 000000000..5b02c23c3 --- /dev/null +++ b/tools/drawTools/vtooltriangle.cpp @@ -0,0 +1,150 @@ +#include "vtooltriangle.h" + +VToolTriangle::VToolTriangle(VDomDocument *doc, VContainer *data, const qint64 &id, + const qint64 &axisP1Id, const qint64 &axisP2Id, const qint64 &firstPointId, + const qint64 &secondPointId, Tool::Sources typeCreation, QGraphicsItem *parent) + :VToolPoint(doc, data, id, parent), axisP1Id(axisP1Id), axisP2Id(axisP2Id), firstPointId(firstPointId), + secondPointId(secondPointId), dialogTriangle(QSharedPointer()) { + if(typeCreation == Tool::FromGui){ + AddToFile(); + } +} + +void VToolTriangle::setDialog(){ + Q_ASSERT(!dialogTriangle.isNull()); + VPointF p = VAbstractTool::data.GetPoint(id); + dialogTriangle->setAxisP1Id(axisP1Id, id); + dialogTriangle->setAxisP2Id(axisP2Id, id); + dialogTriangle->setFirstPointId(firstPointId, id); + dialogTriangle->setSecondPointId(secondPointId, id); + dialogTriangle->setPointName(p.name()); +} + +void VToolTriangle::Create(QSharedPointer &dialog, VMainGraphicsScene *scene, + VDomDocument *doc, VContainer *data){ + qint64 axisP1Id = dialog->getAxisP1Id(); + qint64 axisP2Id = dialog->getAxisP2Id(); + qint64 firstPointId = dialog->getFirstPointId(); + qint64 secondPointId = dialog->getSecondPointId(); + 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, + const qint64 &axisP2Id, 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 axisP1 = data->GetPoint(axisP1Id); + VPointF axisP2 = data->GetPoint(axisP2Id); + VPointF firstPoint = data->GetPoint(firstPointId); + VPointF secondPoint = data->GetPoint(secondPointId); + + QPointF point = FindPoint(axisP1.toQPointF(), axisP2.toQPointF(), firstPoint.toQPointF(), + secondPoint.toQPointF()); + 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){ + VToolTriangle *point = new VToolTriangle(doc, data, id, axisP1Id, axisP2Id, firstPointId, + secondPointId, typeCreation); + scene->addItem(point); + connect(point, &VToolTriangle::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(point, &VToolTriangle::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); + connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolTriangle::SetFactor); + doc->AddTool(id, point); + doc->IncrementReferens(axisP1Id); + doc->IncrementReferens(axisP2Id); + doc->IncrementReferens(firstPointId); + doc->IncrementReferens(secondPointId); + } +} + +QPointF VToolTriangle::FindPoint(const QPointF axisP1, const QPointF axisP2, const QPointF firstPoint, + const QPointF secondPoint){ + qreal c = QLineF(firstPoint, secondPoint).length(); + qreal a = QLineF(axisP2, firstPoint).length(); + qreal b = QLineF(axisP2, secondPoint).length(); + if(c*c == a*a + b*b){ + return axisP2; + } + + QLineF line = QLineF(axisP1, axisP2); + qreal step = 0.01; + while(1){ + line.setLength(line.length()+step); + a = QLineF(line.p2(), firstPoint).length(); + b = QLineF(line.p2(), secondPoint).length(); + if(static_cast(c*c) == static_cast(a*a + b*b)){ + return line.p2(); + } + if(c*c < a*a + b*b){ + return axisP2; + qWarning()<elementById(QString().setNum(id)); + if(domElement.isElement()){ + axisP1Id = domElement.attribute("axisP1", "").toLongLong(); + axisP2Id = domElement.attribute("axisP2", "").toLongLong(); + firstPointId = domElement.attribute("firstPoint", "").toLongLong(); + secondPointId = domElement.attribute("secondPoint", "").toLongLong(); + } + VToolPoint::RefreshPointGeometry(VDrawTool::data.GetPoint(id)); +} + +void VToolTriangle::FullUpdateFromGui(int result){ + if(result == QDialog::Accepted){ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if(domElement.isElement()){ + domElement.setAttribute("name", dialogTriangle->getPointName()); + domElement.setAttribute("axisP1", QString().setNum(dialogTriangle->getAxisP1Id())); + domElement.setAttribute("axisP2", QString().setNum(dialogTriangle->getAxisP2Id())); + domElement.setAttribute("firstPoint", QString().setNum(dialogTriangle->getFirstPointId())); + domElement.setAttribute("secondPoint", QString().setNum(dialogTriangle->getSecondPointId())); + emit FullUpdateTree(); + } + + } + dialogTriangle.clear(); +} + +void VToolTriangle::RemoveReferens(){ + doc->DecrementReferens(axisP1Id); + doc->DecrementReferens(axisP2Id); + doc->DecrementReferens(firstPointId); + doc->DecrementReferens(secondPointId); +} + +void VToolTriangle::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ + ContextMenu(dialogTriangle, this, event); +} + +void VToolTriangle::AddToFile(){ + VPointF point = VAbstractTool::data.GetPoint(id); + QDomElement domElement = doc->createElement("point"); + + AddAttribute(domElement, "id", id); + AddAttribute(domElement, "type", "triangle"); + AddAttribute(domElement, "name", point.name()); + AddAttribute(domElement, "mx", toMM(point.mx())); + AddAttribute(domElement, "my", toMM(point.my())); + + AddAttribute(domElement, "axisP1", axisP1Id); + AddAttribute(domElement, "axisP2", axisP2Id); + AddAttribute(domElement, "firstPoint", firstPointId); + AddAttribute(domElement, "secondPoint", secondPointId); + + AddToCalculation(domElement); +} diff --git a/tools/drawTools/vtooltriangle.h b/tools/drawTools/vtooltriangle.h new file mode 100644 index 000000000..173af52cb --- /dev/null +++ b/tools/drawTools/vtooltriangle.h @@ -0,0 +1,39 @@ +#ifndef VTOOLTRIANGLE_H +#define VTOOLTRIANGLE_H + +#include "vtoolpoint.h" +#include "dialogs/dialogtriangle.h" + +class VToolTriangle : public VToolPoint{ + Q_OBJECT +public: + VToolTriangle(VDomDocument *doc, VContainer *data, const qint64 &id, const qint64 &axisP1Id, + const qint64 &axisP2Id, 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 &axisP1Id, const qint64 &axisP2Id, 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); + static QPointF FindPoint(const QPointF axisP1, const QPointF axisP2, const QPointF firstPoint, + const QPointF secondPoint); +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(VToolTriangle) + qint64 axisP1Id; + qint64 axisP2Id; + qint64 firstPointId; + qint64 secondPointId; + QSharedPointer dialogTriangle; +}; + +#endif // VTOOLTRIANGLE_H diff --git a/tools/modelingTools/modelingtools.h b/tools/modelingTools/modelingtools.h index a40cdf15a..bd61fee59 100644 --- a/tools/modelingTools/modelingtools.h +++ b/tools/modelingTools/modelingtools.h @@ -35,5 +35,6 @@ #include "vmodelingspline.h" #include "vmodelingsplinepath.h" #include "vmodelingheight.h" +#include "vmodelingtriangle.h" #endif // MODELINGTOOLS_H diff --git a/tools/modelingTools/vmodelingtriangle.cpp b/tools/modelingTools/vmodelingtriangle.cpp new file mode 100644 index 000000000..e2f722a07 --- /dev/null +++ b/tools/modelingTools/vmodelingtriangle.cpp @@ -0,0 +1,127 @@ +#include "vmodelingtriangle.h" +#include "../drawTools/vtooltriangle.h" + +VModelingTriangle::VModelingTriangle(VDomDocument *doc, VContainer *data, const qint64 &id, + const qint64 &axisP1Id, const qint64 &axisP2Id, + const qint64 &firstPointId, const qint64 &secondPointId, + Tool::Sources typeCreation, QGraphicsItem *parent) + :VModelingPoint(doc, data, id, parent), axisP1Id(axisP1Id), axisP2Id(axisP2Id), + firstPointId(firstPointId), secondPointId(secondPointId), + dialogTriangle(QSharedPointer()) { + if(typeCreation == Tool::FromGui){ + AddToFile(); + } +} + +void VModelingTriangle::setDialog(){ + Q_ASSERT(!dialogTriangle.isNull()); + VPointF p = VAbstractTool::data.GetPoint(id); + dialogTriangle->setAxisP1Id(axisP1Id, id); + dialogTriangle->setAxisP2Id(axisP2Id, id); + dialogTriangle->setFirstPointId(firstPointId, id); + dialogTriangle->setSecondPointId(secondPointId, id); + dialogTriangle->setPointName(p.name()); +} + +VModelingTriangle *VModelingTriangle::Create(QSharedPointer &dialog, VDomDocument *doc, + VContainer *data){ + qint64 axisP1Id = dialog->getAxisP1Id(); + qint64 axisP2Id = dialog->getAxisP2Id(); + qint64 firstPointId = dialog->getFirstPointId(); + qint64 secondPointId = dialog->getSecondPointId(); + 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, + const qint64 &axisP1Id, const qint64 &axisP2Id, + const qint64 &firstPointId, const qint64 &secondPointId, + const qreal &mx, const qreal &my, VDomDocument *doc, + VContainer *data, const Document::Documents &parse, + Tool::Sources typeCreation){ + VModelingTriangle *tool = 0; + VPointF axisP1 = data->GetPoint(axisP1Id); + VPointF axisP2 = data->GetPoint(axisP2Id); + VPointF firstPoint = data->GetPoint(firstPointId); + VPointF secondPoint = data->GetPoint(secondPointId); + + QPointF point = VToolTriangle::FindPoint(axisP1.toQPointF(), axisP2.toQPointF(), firstPoint.toQPointF(), + secondPoint.toQPointF()); + 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 VModelingTriangle(doc, data, id, axisP1Id, axisP2Id, firstPointId, + secondPointId, typeCreation); + doc->AddTool(id, tool); + doc->IncrementReferens(axisP1Id); + doc->IncrementReferens(axisP2Id); + doc->IncrementReferens(firstPointId); + doc->IncrementReferens(secondPointId); + } + return tool; +} + +void VModelingTriangle::FullUpdateFromFile(){ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if(domElement.isElement()){ + axisP1Id = domElement.attribute("axisP1", "").toLongLong(); + axisP2Id = domElement.attribute("axisP2", "").toLongLong(); + firstPointId = domElement.attribute("firstPoint", "").toLongLong(); + secondPointId = domElement.attribute("secondPoint", "").toLongLong(); + } + VModelingPoint::RefreshPointGeometry(VModelingTool::data.GetPoint(id)); +} + +void VModelingTriangle::FullUpdateFromGui(int result){ + if(result == QDialog::Accepted){ + QDomElement domElement = doc->elementById(QString().setNum(id)); + if(domElement.isElement()){ + domElement.setAttribute("name", dialogTriangle->getPointName()); + domElement.setAttribute("axisP1", QString().setNum(dialogTriangle->getAxisP1Id())); + domElement.setAttribute("axisP2", QString().setNum(dialogTriangle->getAxisP2Id())); + domElement.setAttribute("firstPoint", QString().setNum(dialogTriangle->getFirstPointId())); + domElement.setAttribute("secondPoint", QString().setNum(dialogTriangle->getSecondPointId())); + emit FullUpdateTree(); + } + + } + dialogTriangle.clear(); +} + +void VModelingTriangle::RemoveReferens(){ + doc->DecrementReferens(axisP1Id); + doc->DecrementReferens(axisP2Id); + doc->DecrementReferens(firstPointId); + doc->DecrementReferens(secondPointId); +} + +void VModelingTriangle::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ + ContextMenu(dialogTriangle, this, event); +} + +void VModelingTriangle::AddToFile(){ + VPointF point = VAbstractTool::data.GetPoint(id); + QDomElement domElement = doc->createElement("point"); + + AddAttribute(domElement, "id", id); + AddAttribute(domElement, "type", "triangle"); + AddAttribute(domElement, "name", point.name()); + AddAttribute(domElement, "mx", toMM(point.mx())); + AddAttribute(domElement, "my", toMM(point.my())); + + AddAttribute(domElement, "axisP1", axisP1Id); + AddAttribute(domElement, "axisP2", axisP2Id); + AddAttribute(domElement, "firstPoint", firstPointId); + AddAttribute(domElement, "secondPoint", secondPointId); + + AddToModeling(domElement); +} diff --git a/tools/modelingTools/vmodelingtriangle.h b/tools/modelingTools/vmodelingtriangle.h new file mode 100644 index 000000000..a43b73867 --- /dev/null +++ b/tools/modelingTools/vmodelingtriangle.h @@ -0,0 +1,39 @@ +#ifndef VMODELINGTRIANGLE_H +#define VMODELINGTRIANGLE_H + +#include "vmodelingpoint.h" +#include "../drawTools/vtooltriangle.h" +#include "dialogs/dialogtriangle.h" + +class VModelingTriangle : public VModelingPoint{ + Q_OBJECT +public: + VModelingTriangle(VDomDocument *doc, VContainer *data, const qint64 &id, + const qint64 &axisP1Id, const qint64 &axisP2Id, + const qint64 &firstPointId, const qint64 &secondPointId, + Tool::Sources typeCreation, QGraphicsItem * parent = 0); + virtual void setDialog(); + static VModelingTriangle* Create(QSharedPointer &dialog, VDomDocument *doc, + VContainer *data); + static VModelingTriangle* Create(const qint64 _id, const QString &pointName, const qint64 &axisP1Id, + const qint64 &axisP2Id, 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(VModelingTriangle) + qint64 axisP1Id; + qint64 axisP2Id; + qint64 firstPointId; + qint64 secondPointId; + QSharedPointer dialogTriangle; +}; + +#endif // VMODELINGTRIANGLE_H diff --git a/tools/vtooldetail.cpp b/tools/vtooldetail.cpp index 8f113e39b..93c1c8f3d 100644 --- a/tools/vtooldetail.cpp +++ b/tools/vtooldetail.cpp @@ -150,6 +150,22 @@ VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id, tool->setParentItem(this); break; } + case(Tool::Height):{ + VModelingHeight *tool = qobject_cast(tools->value(detail[i].getId())); + Q_ASSERT(tool != 0); + connect(tool, &VModelingHeight::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(tool, &VModelingHeight::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); + tool->setParentItem(this); + break; + } + case(Tool::Triangle):{ + VModelingTriangle *tool = qobject_cast(tools->value(detail[i].getId())); + Q_ASSERT(tool != 0); + connect(tool, &VModelingTriangle::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(tool, &VModelingTriangle::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); + tool->setParentItem(this); + break; + } default: qWarning()<<"Get wrong tool type. Ignore."; break; diff --git a/xml/vdomdocument.cpp b/xml/vdomdocument.cpp index 52e42e7ff..e4d31e700 100644 --- a/xml/vdomdocument.cpp +++ b/xml/vdomdocument.cpp @@ -831,6 +831,32 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen throw excep; } } + if(type == "triangle"){ + try{ + qint64 id = GetParametrId(domElement); + QString name = GetParametrString(domElement, "name"); + qreal mx = toPixel(GetParametrDouble(domElement, "mx")); + qreal my = toPixel(GetParametrDouble(domElement, "my")); + qint64 axisP1Id = GetParametrLongLong(domElement, "axisP1"); + qint64 axisP2Id = GetParametrLongLong(domElement, "axisP2"); + qint64 firstPointId = GetParametrLongLong(domElement, "firstPoint"); + qint64 secondPointId = GetParametrLongLong(domElement, "secondPoint"); + + if(mode == Draw::Calculation){ + VToolTriangle::Create(id, name, axisP1Id, axisP2Id, firstPointId, secondPointId, mx, my, + scene, this, data, parse, Tool::FromFile); + } else { + VModelingTriangle::Create(id, name, axisP1Id, axisP2Id, firstPointId, secondPointId, mx, my, + this, data, parse, Tool::FromFile); + } + return; + } + catch(const VExceptionBadId &e){ + VExceptionObjectError excep(tr("Error creating or updating triangle"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } + } } void VDomDocument::ParseLineElement(VMainGraphicsScene *scene, const QDomElement &domElement,