From 452aec26f124e101aec20b72e3dcd99b95220306 Mon Sep 17 00:00:00 2001 From: dismine Date: Wed, 18 Dec 2013 20:55:27 +0200 Subject: [PATCH] New tool CutSpline (Modeling mode). --HG-- branch : feature --- src/container/vcontainer.cpp | 15 +++ src/container/vcontainer.h | 1 + src/dialogs/dialogalongline.cpp | 9 +- src/dialogs/dialogarc.cpp | 6 +- src/dialogs/dialogbisector.cpp | 12 +- src/dialogs/dialogcutspline.cpp | 6 +- src/dialogs/dialogcutsplinepath.cpp | 6 +- src/dialogs/dialogdetail.cpp | 1 + src/dialogs/dialogendline.cpp | 6 +- src/dialogs/dialogheight.cpp | 12 +- src/dialogs/dialogline.cpp | 9 +- src/dialogs/dialoglineintersect.cpp | 15 ++- src/dialogs/dialognormal.cpp | 9 +- src/dialogs/dialogpointofcontact.cpp | 12 +- src/dialogs/dialogpointofintersection.cpp | 9 +- src/dialogs/dialogshoulderpoint.cpp | 12 +- src/dialogs/dialogsplinepath.cpp | 6 +- src/dialogs/dialogtriangle.cpp | 15 ++- src/mainwindow.cpp | 1 + src/options.h | 4 +- src/tools/drawTools/vtoolcutspline.cpp | 4 +- .../modelingTools/vmodelingcutspline.cpp | 125 +++++++++++++++++- src/tools/modelingTools/vmodelingcutspline.h | 22 ++- src/tools/vtooldetail.cpp | 12 ++ src/widgets/vsimplespline.cpp | 29 +++- src/widgets/vsimplespline.h | 2 +- src/xml/vdomdocument.cpp | 7 + 27 files changed, 319 insertions(+), 48 deletions(-) diff --git a/src/container/vcontainer.cpp b/src/container/vcontainer.cpp index 108909dc7..5a5a59eed 100644 --- a/src/container/vcontainer.cpp +++ b/src/container/vcontainer.cpp @@ -553,6 +553,21 @@ void VContainer::PrepareDetails(QVector &list) const } } +qint64 VContainer::PointConvertToModeling(qint64 id) +{ + QHashIterator pModeling(pointsModeling); + while (pModeling.hasNext()) + { + pModeling.next(); + VPointF p = pModeling.value(); + if(p.getIdObject() == id) + { + return pModeling.key(); + } + } + return 0; +} + template void VContainer::UpdateObject(QHash &obj, const qint64 &id, const val& point) { diff --git a/src/container/vcontainer.h b/src/container/vcontainer.h index 91044d5cf..e6bf775ac 100644 --- a/src/container/vcontainer.h +++ b/src/container/vcontainer.h @@ -573,6 +573,7 @@ public: * @param list list of details */ void PrepareDetails(QVector & list) const; + qint64 PointConvertToModeling(qint64 id); private: /** * @brief _id current id. New object will have value +1. For full class equal 0. diff --git a/src/dialogs/dialogalongline.cpp b/src/dialogs/dialogalongline.cpp index 7cd5aecb2..46551b3e5 100644 --- a/src/dialogs/dialogalongline.cpp +++ b/src/dialogs/dialogalongline.cpp @@ -57,8 +57,11 @@ DialogAlongLine::DialogAlongLine(const VContainer *data, Draw::Draws mode, QWidg connect(bCansel, &QPushButton::clicked, this, &DialogAlongLine::DialogRejected); FillComboBoxTypeLine(ui->comboBoxLineType); ui->comboBoxLineType->setCurrentIndex(1); - FillComboBoxPoints(ui->comboBoxFirstPoint); - FillComboBoxPoints(ui->comboBoxSecondPoint); + if(mode == Draw::Calculation) + { + FillComboBoxPoints(ui->comboBoxFirstPoint); + FillComboBoxPoints(ui->comboBoxSecondPoint); + } connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogAlongLine::PutHere); connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogAlongLine::PutVal); @@ -88,6 +91,8 @@ void DialogAlongLine::ChoosedObject(qint64 id, const Scene::Scenes &type) if (type == Scene::Detail) { idDetail = id; + FillComboBoxPoints(ui->comboBoxFirstPoint); + FillComboBoxPoints(ui->comboBoxSecondPoint); return; } } diff --git a/src/dialogs/dialogarc.cpp b/src/dialogs/dialogarc.cpp index 0e5db954c..9425f17f9 100644 --- a/src/dialogs/dialogarc.cpp +++ b/src/dialogs/dialogarc.cpp @@ -52,7 +52,10 @@ DialogArc::DialogArc(const VContainer *data, Draw::Draws mode, QWidget *parent) QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); connect(bCansel, &QPushButton::clicked, this, &DialogArc::DialogRejected); - FillComboBoxPoints(ui->comboBoxBasePoint); + if(mode == Draw::Calculation) + { + FillComboBoxPoints(ui->comboBoxBasePoint); + } CheckState(); @@ -124,6 +127,7 @@ void DialogArc::ChoosedObject(qint64 id, const Scene::Scenes &type) if (type == Scene::Detail) { idDetail = id; + FillComboBoxPoints(ui->comboBoxBasePoint); return; } } diff --git a/src/dialogs/dialogbisector.cpp b/src/dialogs/dialogbisector.cpp index 9837832bb..8bc425a1f 100644 --- a/src/dialogs/dialogbisector.cpp +++ b/src/dialogs/dialogbisector.cpp @@ -55,9 +55,12 @@ DialogBisector::DialogBisector(const VContainer *data, Draw::Draws mode, QWidget CheckState(); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); connect(bCansel, &QPushButton::clicked, this, &DialogBisector::DialogRejected); - FillComboBoxPoints(ui->comboBoxFirstPoint); - FillComboBoxPoints(ui->comboBoxSecondPoint); - FillComboBoxPoints(ui->comboBoxThirdPoint); + if(mode == Draw::Calculation) + { + FillComboBoxPoints(ui->comboBoxFirstPoint); + FillComboBoxPoints(ui->comboBoxSecondPoint); + FillComboBoxPoints(ui->comboBoxThirdPoint); + } FillComboBoxTypeLine(ui->comboBoxLineType); connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogBisector::PutHere); @@ -88,6 +91,9 @@ void DialogBisector::ChoosedObject(qint64 id, const Scene::Scenes &type) if (type == Scene::Detail) { idDetail = id; + FillComboBoxPoints(ui->comboBoxFirstPoint); + FillComboBoxPoints(ui->comboBoxSecondPoint); + FillComboBoxPoints(ui->comboBoxThirdPoint); return; } } diff --git a/src/dialogs/dialogcutspline.cpp b/src/dialogs/dialogcutspline.cpp index 72a858f82..c077b28e2 100644 --- a/src/dialogs/dialogcutspline.cpp +++ b/src/dialogs/dialogcutspline.cpp @@ -53,7 +53,10 @@ DialogCutSpline::DialogCutSpline(const VContainer *data, Draw::Draws mode, QWidg CheckState(); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); connect(bCansel, &QPushButton::clicked, this, &DialogCutSpline::DialogRejected); - FillComboBoxSplines(ui->comboBoxSpline); + if(mode == Draw::Calculation) + { + FillComboBoxSplines(ui->comboBoxSpline); + } connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutSpline::PutHere); connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutSpline::PutVal); @@ -100,6 +103,7 @@ void DialogCutSpline::ChoosedObject(qint64 id, const Scene::Scenes &type) if (type == Scene::Detail) { idDetail = id; + FillComboBoxSplines(ui->comboBoxSpline); return; } } diff --git a/src/dialogs/dialogcutsplinepath.cpp b/src/dialogs/dialogcutsplinepath.cpp index 3e25a60fa..a25395495 100644 --- a/src/dialogs/dialogcutsplinepath.cpp +++ b/src/dialogs/dialogcutsplinepath.cpp @@ -53,7 +53,10 @@ DialogCutSplinePath::DialogCutSplinePath(const VContainer *data, Draw::Draws mod CheckState(); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); connect(bCansel, &QPushButton::clicked, this, &DialogCutSplinePath::DialogRejected); - FillComboBoxSplines(ui->comboBoxSplinePath); + if(mode == Draw::Calculation) + { + FillComboBoxSplines(ui->comboBoxSplinePath); + } connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogCutSplinePath::PutHere); connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogCutSplinePath::PutVal); @@ -100,6 +103,7 @@ void DialogCutSplinePath::ChoosedObject(qint64 id, const Scene::Scenes &type) if (type == Scene::Detail) { idDetail = id; + FillComboBoxSplines(ui->comboBoxSplinePath); return; } } diff --git a/src/dialogs/dialogdetail.cpp b/src/dialogs/dialogdetail.cpp index 6b1b7ab9b..711f9a9be 100644 --- a/src/dialogs/dialogdetail.cpp +++ b/src/dialogs/dialogdetail.cpp @@ -67,6 +67,7 @@ void DialogDetail::ChoosedObject(qint64 id, const Scene::Scenes &type) { if (CheckObject(id) == false) { + qDebug()<<"false"; return; } } diff --git a/src/dialogs/dialogendline.cpp b/src/dialogs/dialogendline.cpp index 012e3987d..a3de025b3 100644 --- a/src/dialogs/dialogendline.cpp +++ b/src/dialogs/dialogendline.cpp @@ -56,7 +56,10 @@ DialogEndLine::DialogEndLine(const VContainer *data, Draw::Draws mode, QWidget * CheckState(); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); connect(bCansel, &QPushButton::clicked, this, &DialogEndLine::DialogRejected); - FillComboBoxPoints(ui->comboBoxBasePoint); + if(mode == Draw::Calculation) + { + FillComboBoxPoints(ui->comboBoxBasePoint); + } FillComboBoxTypeLine(ui->comboBoxLineType); connect(ui->toolButtonArrowDown, &QPushButton::clicked, this, @@ -98,6 +101,7 @@ void DialogEndLine::ChoosedObject(qint64 id, const Scene::Scenes &type) if (type == Scene::Detail) { idDetail = id; + FillComboBoxPoints(ui->comboBoxBasePoint); return; } } diff --git a/src/dialogs/dialogheight.cpp b/src/dialogs/dialogheight.cpp index 9c8f32b18..6ddd95c2e 100644 --- a/src/dialogs/dialogheight.cpp +++ b/src/dialogs/dialogheight.cpp @@ -43,9 +43,12 @@ DialogHeight::DialogHeight(const VContainer *data, Draw::Draws mode, QWidget *pa CheckState(); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); connect(bCansel, &QPushButton::clicked, this, &DialogHeight::DialogRejected); - FillComboBoxPoints(ui->comboBoxBasePoint); - FillComboBoxPoints(ui->comboBoxP1Line); - FillComboBoxPoints(ui->comboBoxP2Line); + if(mode == Draw::Calculation) + { + FillComboBoxPoints(ui->comboBoxBasePoint); + FillComboBoxPoints(ui->comboBoxP1Line); + FillComboBoxPoints(ui->comboBoxP2Line); + } FillComboBoxTypeLine(ui->comboBoxLineType); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogHeight::NamePointChanged); } @@ -92,6 +95,9 @@ void DialogHeight::ChoosedObject(qint64 id, const Scene::Scenes &type) if (type == Scene::Detail) { idDetail = id; + FillComboBoxPoints(ui->comboBoxBasePoint); + FillComboBoxPoints(ui->comboBoxP1Line); + FillComboBoxPoints(ui->comboBoxP2Line); return; } } diff --git a/src/dialogs/dialogline.cpp b/src/dialogs/dialogline.cpp index bfb438486..7a083e85b 100644 --- a/src/dialogs/dialogline.cpp +++ b/src/dialogs/dialogline.cpp @@ -39,8 +39,11 @@ DialogLine::DialogLine(const VContainer *data, Draw::Draws mode, QWidget *parent connect(bOk, &QPushButton::clicked, this, &DialogLine::DialogAccepted); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); connect(bCansel, &QPushButton::clicked, this, &DialogLine::DialogRejected); - FillComboBoxPoints(ui->comboBoxFirstPoint); - FillComboBoxPoints(ui->comboBoxSecondPoint); + if(mode == Draw::Calculation) + { + FillComboBoxPoints(ui->comboBoxFirstPoint); + FillComboBoxPoints(ui->comboBoxSecondPoint); + } number = 0; } @@ -88,6 +91,8 @@ void DialogLine::ChoosedObject(qint64 id, const Scene::Scenes &type) if (type == Scene::Detail) { idDetail = id; + FillComboBoxPoints(ui->comboBoxFirstPoint); + FillComboBoxPoints(ui->comboBoxSecondPoint); return; } } diff --git a/src/dialogs/dialoglineintersect.cpp b/src/dialogs/dialoglineintersect.cpp index 216a19fec..0045f3c1f 100644 --- a/src/dialogs/dialoglineintersect.cpp +++ b/src/dialogs/dialoglineintersect.cpp @@ -43,10 +43,13 @@ DialogLineIntersect::DialogLineIntersect(const VContainer *data, Draw::Draws mod flagName = false; 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); + if(mode == Draw::Calculation) + { + FillComboBoxPoints(ui->comboBoxP1Line1); + FillComboBoxPoints(ui->comboBoxP2Line1); + FillComboBoxPoints(ui->comboBoxP1Line2); + FillComboBoxPoints(ui->comboBoxP2Line2); + } connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogLineIntersect::NamePointChanged); } @@ -63,6 +66,10 @@ void DialogLineIntersect::ChoosedObject(qint64 id, const Scene::Scenes &type) if (type == Scene::Detail) { idDetail = id; + FillComboBoxPoints(ui->comboBoxP1Line1); + FillComboBoxPoints(ui->comboBoxP2Line1); + FillComboBoxPoints(ui->comboBoxP1Line2); + FillComboBoxPoints(ui->comboBoxP2Line2); return; } } diff --git a/src/dialogs/dialognormal.cpp b/src/dialogs/dialognormal.cpp index e9359fbbc..d735eff74 100644 --- a/src/dialogs/dialognormal.cpp +++ b/src/dialogs/dialognormal.cpp @@ -56,8 +56,11 @@ DialogNormal::DialogNormal(const VContainer *data, Draw::Draws mode, QWidget *pa CheckState(); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); connect(bCansel, &QPushButton::clicked, this, &DialogNormal::DialogRejected); - FillComboBoxPoints(ui->comboBoxFirstPoint); - FillComboBoxPoints(ui->comboBoxSecondPoint); + if(mode == Draw::Calculation) + { + FillComboBoxPoints(ui->comboBoxFirstPoint); + FillComboBoxPoints(ui->comboBoxSecondPoint); + } FillComboBoxTypeLine(ui->comboBoxLineType); connect(ui->toolButtonArrowDown, &QPushButton::clicked, this, @@ -104,6 +107,8 @@ void DialogNormal::ChoosedObject(qint64 id, const Scene::Scenes &type) if (type == Scene::Detail) { idDetail = id; + FillComboBoxPoints(ui->comboBoxFirstPoint); + FillComboBoxPoints(ui->comboBoxSecondPoint); return; } } diff --git a/src/dialogs/dialogpointofcontact.cpp b/src/dialogs/dialogpointofcontact.cpp index 092f8b748..2fe17f7d1 100644 --- a/src/dialogs/dialogpointofcontact.cpp +++ b/src/dialogs/dialogpointofcontact.cpp @@ -54,9 +54,12 @@ DialogPointOfContact::DialogPointOfContact(const VContainer *data, Draw::Draws m CheckState(); QPushButton *bCansel = ui.buttonBox->button(QDialogButtonBox::Cancel); connect(bCansel, &QPushButton::clicked, this, &DialogPointOfContact::DialogRejected); - FillComboBoxPoints(ui.comboBoxCenter); - FillComboBoxPoints(ui.comboBoxFirstPoint); - FillComboBoxPoints(ui.comboBoxSecondPoint); + if(mode == Draw::Calculation) + { + FillComboBoxPoints(ui.comboBoxCenter); + FillComboBoxPoints(ui.comboBoxFirstPoint); + FillComboBoxPoints(ui.comboBoxSecondPoint); + } connect(ui.toolButtonPutHere, &QPushButton::clicked, this, &DialogPointOfContact::PutHere); connect(ui.listWidget, &QListWidget::itemDoubleClicked, this, &DialogPointOfContact::PutVal); @@ -81,6 +84,9 @@ void DialogPointOfContact::ChoosedObject(qint64 id, const Scene::Scenes &type) if (type == Scene::Detail) { idDetail = id; + FillComboBoxPoints(ui.comboBoxCenter); + FillComboBoxPoints(ui.comboBoxFirstPoint); + FillComboBoxPoints(ui.comboBoxSecondPoint); return; } } diff --git a/src/dialogs/dialogpointofintersection.cpp b/src/dialogs/dialogpointofintersection.cpp index c355cf4b0..6860ab1eb 100644 --- a/src/dialogs/dialogpointofintersection.cpp +++ b/src/dialogs/dialogpointofintersection.cpp @@ -43,8 +43,11 @@ DialogPointOfIntersection::DialogPointOfIntersection(const VContainer *data, Dra CheckState(); QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); connect(bCansel, &QPushButton::clicked, this, &DialogPointOfIntersection::DialogRejected); - FillComboBoxPoints(ui->comboBoxFirstPoint); - FillComboBoxPoints(ui->comboBoxSecondPoint); + if(mode == Draw::Calculation) + { + FillComboBoxPoints(ui->comboBoxFirstPoint); + FillComboBoxPoints(ui->comboBoxSecondPoint); + } connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersection::NamePointChanged); } @@ -66,6 +69,8 @@ void DialogPointOfIntersection::ChoosedObject(qint64 id, const Scene::Scenes &ty if (type == Scene::Detail) { idDetail = id; + FillComboBoxPoints(ui->comboBoxFirstPoint); + FillComboBoxPoints(ui->comboBoxSecondPoint); return; } } diff --git a/src/dialogs/dialogshoulderpoint.cpp b/src/dialogs/dialogshoulderpoint.cpp index 6a6ab18c7..fe30645d0 100644 --- a/src/dialogs/dialogshoulderpoint.cpp +++ b/src/dialogs/dialogshoulderpoint.cpp @@ -57,9 +57,12 @@ DialogShoulderPoint::DialogShoulderPoint(const VContainer *data, Draw::Draws mod QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); connect(bCansel, &QPushButton::clicked, this, &DialogShoulderPoint::DialogRejected); FillComboBoxTypeLine(ui->comboBoxLineType); - FillComboBoxPoints(ui->comboBoxP1Line); - FillComboBoxPoints(ui->comboBoxP2Line); - FillComboBoxPoints(ui->comboBoxPShoulder); + if(mode == Draw::Calculation) + { + FillComboBoxPoints(ui->comboBoxP1Line); + FillComboBoxPoints(ui->comboBoxP2Line); + FillComboBoxPoints(ui->comboBoxPShoulder); + } connect(ui->toolButtonPutHere, &QPushButton::clicked, this, &DialogShoulderPoint::PutHere); connect(ui->listWidget, &QListWidget::itemDoubleClicked, this, &DialogShoulderPoint::PutVal); @@ -89,6 +92,9 @@ void DialogShoulderPoint::ChoosedObject(qint64 id, const Scene::Scenes &type) if (type == Scene::Detail) { idDetail = id; + FillComboBoxPoints(ui->comboBoxP1Line); + FillComboBoxPoints(ui->comboBoxP2Line); + FillComboBoxPoints(ui->comboBoxPShoulder); return; } } diff --git a/src/dialogs/dialogsplinepath.cpp b/src/dialogs/dialogsplinepath.cpp index 17117e9ee..9240bf738 100644 --- a/src/dialogs/dialogsplinepath.cpp +++ b/src/dialogs/dialogsplinepath.cpp @@ -41,7 +41,10 @@ DialogSplinePath::DialogSplinePath(const VContainer *data, Draw::Draws mode, QWi QPushButton *bCansel = ui->buttonBox->button(QDialogButtonBox::Cancel); connect(bCansel, &QPushButton::clicked, this, &DialogSplinePath::DialogRejected); - FillComboBoxPoints(ui->comboBoxPoint); + if(mode == Draw::Calculation) + { + FillComboBoxPoints(ui->comboBoxPoint); + } path = VSplinePath(data->DataPoints()); @@ -83,6 +86,7 @@ void DialogSplinePath::ChoosedObject(qint64 id, const Scene::Scenes &type) if (type == Scene::Detail) { idDetail = id; + FillComboBoxPoints(ui->comboBoxPoint); return; } } diff --git a/src/dialogs/dialogtriangle.cpp b/src/dialogs/dialogtriangle.cpp index 5c405aa2a..ef097efa6 100644 --- a/src/dialogs/dialogtriangle.cpp +++ b/src/dialogs/dialogtriangle.cpp @@ -43,10 +43,13 @@ DialogTriangle::DialogTriangle(const VContainer *data, Draw::Draws mode, QWidget 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); + if(mode == Draw::Calculation) + { + FillComboBoxPoints(ui->comboBoxAxisP1); + FillComboBoxPoints(ui->comboBoxAxisP2); + FillComboBoxPoints(ui->comboBoxFirstPoint); + FillComboBoxPoints(ui->comboBoxSecondPoint); + } connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogTriangle::NamePointChanged); } @@ -62,6 +65,10 @@ void DialogTriangle::ChoosedObject(qint64 id, const Scene::Scenes &type) if (type == Scene::Detail) { idDetail = id; + FillComboBoxPoints(ui->comboBoxAxisP1); + FillComboBoxPoints(ui->comboBoxAxisP2); + FillComboBoxPoints(ui->comboBoxFirstPoint); + FillComboBoxPoints(ui->comboBoxSecondPoint); return; } } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 828c8261e..07f9519c4 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -271,6 +271,7 @@ template void MainWindow::AddToolToDetail(T *tool, const qint64 &id, Tool::Tools typeTool, const qint64 &idDetail) { QHash* tools = doc->getTools(); + Q_ASSERT(tools != 0); VToolDetail *det = qobject_cast(tools->value(idDetail)); Q_ASSERT(det != 0); det->AddTool(tool, id, typeTool); diff --git a/src/options.h b/src/options.h index 52881be48..e0808cbf3 100644 --- a/src/options.h +++ b/src/options.h @@ -77,7 +77,9 @@ namespace Tool NodeSplinePath, Height, Triangle, - PointOfIntersection + PointOfIntersection, + SimpleSpline, + SimpleSplinePath }; Q_DECLARE_FLAGS(Tools, Tool) diff --git a/src/tools/drawTools/vtoolcutspline.cpp b/src/tools/drawTools/vtoolcutspline.cpp index cb18aae95..a1c71c1d7 100644 --- a/src/tools/drawTools/vtoolcutspline.cpp +++ b/src/tools/drawTools/vtoolcutspline.cpp @@ -42,13 +42,13 @@ VToolCutSpline::VToolCutSpline(VDomDocument *doc, VContainer *data, const qint64 Q_ASSERT_X(spl1id > 0, Q_FUNC_INFO, "spl1id <= 0"); Q_ASSERT_X(spl2id > 0, Q_FUNC_INFO, "spl2id <= 0"); - firstSpline = new VSimpleSpline(spl1id, &factor, ¤tColor); + firstSpline = new VSimpleSpline(spl1id, ¤tColor, &factor); Q_ASSERT(firstSpline != 0); RefreshSpline(firstSpline, spl1id, SimpleSpline::ForthPoint); firstSpline->setParentItem(this); connect(firstSpline, &VSimpleSpline::Choosed, this, &VToolCutSpline::SplineChoosed); - secondSpline = new VSimpleSpline(spl2id, &factor, ¤tColor); + secondSpline = new VSimpleSpline(spl2id, ¤tColor, &factor); Q_ASSERT(secondSpline != 0); RefreshSpline(secondSpline, spl2id, SimpleSpline::FirstPoint); secondSpline->setParentItem(this); diff --git a/src/tools/modelingTools/vmodelingcutspline.cpp b/src/tools/modelingTools/vmodelingcutspline.cpp index 1fd66f2e8..b6c0dbc36 100644 --- a/src/tools/modelingTools/vmodelingcutspline.cpp +++ b/src/tools/modelingTools/vmodelingcutspline.cpp @@ -27,17 +27,32 @@ *************************************************************************/ #include "vmodelingcutspline.h" +#include "../../container/calculator.h" const QString VModelingCutSpline::ToolType = QStringLiteral("cutSpline"); const QString VModelingCutSpline::AttrSpline = QStringLiteral("spline"); VModelingCutSpline::VModelingCutSpline(VDomDocument *doc, VContainer *data, const qint64 &id, - const QString &formula, const qint64 &splineId, - const Tool::Sources &typeCreation, QGraphicsItem *parent) + const QString &formula, const qint64 &splineId, const qint64 &spl1id, + const qint64 &spl2id, const Tool::Sources &typeCreation, QGraphicsItem *parent) :VModelingPoint(doc, data, id, parent), formula(formula), splineId(splineId), - dialogCutSpline(QSharedPointer()) + dialogCutSpline(QSharedPointer()), firstSpline(), secondSpline(), spl1id(spl1id), spl2id(spl2id) { Q_ASSERT_X(splineId > 0, Q_FUNC_INFO, "splineId <= 0"); + Q_ASSERT_X(spl1id > 0, Q_FUNC_INFO, "spl1id <= 0"); + Q_ASSERT_X(spl2id > 0, Q_FUNC_INFO, "spl2id <= 0"); + + firstSpline = new VSimpleSpline(spl1id, ¤tColor); + Q_ASSERT(firstSpline != 0); + RefreshSpline(firstSpline, spl1id, SimpleSpline::ForthPoint); + firstSpline->setParentItem(this); + connect(firstSpline, &VSimpleSpline::Choosed, this, &VModelingCutSpline::SplineChoosed); + + secondSpline = new VSimpleSpline(spl2id, ¤tColor); + Q_ASSERT(secondSpline != 0); + RefreshSpline(secondSpline, spl2id, SimpleSpline::FirstPoint); + secondSpline->setParentItem(this); + connect(secondSpline, &VSimpleSpline::Choosed, this, &VModelingCutSpline::SplineChoosed); if (typeCreation == Tool::FromGui) { AddToFile(); @@ -47,10 +62,10 @@ VModelingCutSpline::VModelingCutSpline(VDomDocument *doc, VContainer *data, cons void VModelingCutSpline::setDialog() { Q_ASSERT(dialogCutSpline.isNull() == false); - VSpline spl = VAbstractTool::data.GetSplineModeling(id); + VPointF point = VAbstractTool::data.GetPointModeling(id); dialogCutSpline->setFormula(formula); dialogCutSpline->setSplineId(splineId, id); - dialogCutSpline->setPointName(spl.name()); + dialogCutSpline->setPointName(point.name()); } VModelingCutSpline *VModelingCutSpline::Create(QSharedPointer &dialog, @@ -67,7 +82,81 @@ VModelingCutSpline *VModelingCutSpline::Create(const qint64 _id, const QString & VDomDocument *doc, VContainer *data, const Document::Documents &parse, const Tool::Sources &typeCreation) { + VModelingCutSpline *cutPoint = 0; + VSpline spl = data->GetSplineModeling(splineId); + Calculator cal(data); + QString errorMsg; + qreal result = cal.eval(formula, &errorMsg); + if (errorMsg.isEmpty()) + { + QPointF spl1p2, spl1p3, spl2p2, spl2p3; + QPointF point = spl.CutSpline(toPixel(result), spl1p2, spl1p3, spl2p2, spl2p3); + qint64 splP1id, splP4id; + Draw::Draws typeObject = spl.getMode(); + if (typeObject == Draw::Calculation) + { + splP1id = data->PointConvertToModeling(spl.GetP1()); + splP4id = data->PointConvertToModeling(spl.GetP4()); + if (parse == Document::FullParse) + { + doc->IncrementReferens(splP1id); + doc->IncrementReferens(splP4id); + } + } + else + { + splP1id = spl.GetP1(); + splP4id = spl.GetP4(); + } + + qint64 id = _id; + qint64 spl1id = 0; + qint64 spl2id = 0; + if (typeCreation == Tool::FromGui) + { + id = data->AddPointModeling(VPointF(point.x(), point.y(), pointName, mx, my)); + + VSpline spline1 = VSpline(data->DataPointsModeling(), splP1id, spl1p2, spl1p3, id, spl.GetKcurve()); + spl1id = data->AddSplineModeling(spline1); + data->AddLengthSpline(spline1.name(), toMM(spline1.GetLength())); + + VSpline spline2 = VSpline(data->DataPointsModeling(), id, spl2p2, spl2p3, splP4id, spl.GetKcurve()); + spl2id = data->AddSplineModeling(spline2); + data->AddLengthSpline(spline2.name(), toMM(spline2.GetLength())); + } + else + { + data->UpdatePointModeling(id, VPointF(point.x(), point.y(), pointName, mx, my)); + + spl1id = id + 1; + spl2id = id + 2; + + VSpline spline1 = VSpline(data->DataPointsModeling(), splP1id, spl1p2, spl1p3, id, spl.GetKcurve()); + data->UpdateSplineModeling(spl1id, spline1); + data->AddLengthSpline(spline1.name(), toMM(spline1.GetLength())); + + VSpline spline2 = VSpline(data->DataPointsModeling(), id, spl2p2, spl2p3, splP4id, spl.GetKcurve()); + data->UpdateSplineModeling(spl2id, spline2); + data->AddLengthSpline(spline2.name(), toMM(spline2.GetLength())); + + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + //VDrawTool::AddRecord(id, Tool::CutSplineTool, doc); + if (parse == Document::FullParse) + { + cutPoint = new VModelingCutSpline(doc, data, id, formula, splineId, spl1id, spl2id, typeCreation); + + doc->AddTool(id, cutPoint); + doc->AddTool(spl1id, cutPoint); + doc->AddTool(spl2id, cutPoint); + doc->IncrementReferens(splineId); + } + } + return cutPoint; } void VModelingCutSpline::FullUpdateFromFile() @@ -97,6 +186,11 @@ void VModelingCutSpline::FullUpdateFromGui(int result) dialogCutSpline.clear(); } +void VModelingCutSpline::SplineChoosed(qint64 id) +{ + emit ChoosedTool(id, Scene::Spline); +} + void VModelingCutSpline::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) { ContextMenu(dialogCutSpline, this, event); @@ -108,6 +202,7 @@ void VModelingCutSpline::AddToFile() QDomElement domElement = doc->createElement(TagName); AddAttribute(domElement, AttrId, id); + AddAttribute(domElement, AttrType, ToolType); AddAttribute(domElement, AttrName, point.name()); AddAttribute(domElement, AttrMx, toMM(point.mx())); AddAttribute(domElement, AttrMy, toMM(point.my())); @@ -120,5 +215,25 @@ void VModelingCutSpline::AddToFile() void VModelingCutSpline::RefreshGeometry() { + RefreshSpline(firstSpline, spl1id, SimpleSpline::ForthPoint); + RefreshSpline(secondSpline, spl2id, SimpleSpline::FirstPoint); VModelingPoint::RefreshPointGeometry(VModelingTool::data.GetPointModeling(id)); } + + +void VModelingCutSpline::RefreshSpline(VSimpleSpline *spline, qint64 splid, SimpleSpline::Translation tr) +{ + VSpline spl = VModelingTool::data.GetSplineModeling(splid); + QPainterPath path; + path.addPath(spl.GetPath()); + path.setFillRule( Qt::WindingFill ); + if(tr == SimpleSpline::FirstPoint) + { + path.translate(-spl.GetPointP1().toQPointF().x(), -spl.GetPointP1().toQPointF().y()); + } + else + { + path.translate(-spl.GetPointP4().toQPointF().x(), -spl.GetPointP4().toQPointF().y()); + } + spline->setPath(path); +} diff --git a/src/tools/modelingTools/vmodelingcutspline.h b/src/tools/modelingTools/vmodelingcutspline.h index 6c9a12471..60d9e4c1a 100644 --- a/src/tools/modelingTools/vmodelingcutspline.h +++ b/src/tools/modelingTools/vmodelingcutspline.h @@ -31,13 +31,15 @@ #include "vmodelingpoint.h" #include "../../dialogs/dialogcutspline.h" +#include "../../widgets/vsimplespline.h" class VModelingCutSpline: public VModelingPoint { Q_OBJECT public: - VModelingCutSpline(VDomDocument *doc, VContainer *data, const qint64 &id,const QString &formula, - const qint64 &splineId, const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); + VModelingCutSpline(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &formula, + const qint64 &splineId, const qint64 &spl1id, const qint64 &spl2id, + const Tool::Sources &typeCreation, QGraphicsItem * parent = 0); /** * @brief setDialog */ @@ -83,6 +85,11 @@ public slots: * @param result */ virtual void FullUpdateFromGui(int result); + /** + * @brief SplineChoosed + * @param id + */ + void SplineChoosed(qint64 id); protected: /** * @brief contextMenuEvent @@ -107,6 +114,17 @@ private: * @brief DialogCutSpline pointer to the tool's dialog */ QSharedPointer dialogCutSpline; + /** + * @brief firstSpline + */ + VSimpleSpline *firstSpline; + /** + * @brief secondSpline + */ + VSimpleSpline *secondSpline; + const qint64 spl1id; + const qint64 spl2id; + void RefreshSpline(VSimpleSpline *spline, qint64 splid, SimpleSpline::Translation tr); }; #endif // VMODELINGCUTSPLINE_H diff --git a/src/tools/vtooldetail.cpp b/src/tools/vtooldetail.cpp index aeffdcee5..84fe56fa1 100644 --- a/src/tools/vtooldetail.cpp +++ b/src/tools/vtooldetail.cpp @@ -105,6 +105,15 @@ VToolDetail::VToolDetail(VDomDocument *doc, VContainer *data, const qint64 &id, case (Tool::PointOfIntersection): InitTool(scene, detail[i]); break; + case (Tool::CutSplineTool): + InitTool(scene, detail[i]); + break; + case (Tool::SimpleSpline): + //No need init this tool. See CutSplineTool. + break; + case (Tool::SimpleSplinePath): + //No need init this tool. See CutSplineTool. + break; default: qWarning()<<"Get wrong tool type. Ignore."; break; @@ -455,6 +464,9 @@ void VToolDetail::AddNode(QDomElement &domElement, VNodeDetail &node) case (Tool::PointOfIntersection): AddAttribute(nod, AttrType, QStringLiteral("PointOfIntersection")); break; + case (Tool::CutSplineTool): + AddAttribute(nod, AttrType, QStringLiteral("CutSplineTool")); + break; default: qWarning()<<"May be wrong tool type!!! Ignoring."<setPen(QPen(*currentColor, widthMainLine/ *factor)); + if(factor == 0) + { + this->setPen(QPen(*currentColor, widthMainLine)); + } + else + { + this->setPen(QPen(*currentColor, widthMainLine/ *factor)); + } } void VSimpleSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); - this->setPen(QPen(*currentColor, widthHairLine/ *factor)); + if(factor == 0) + { + this->setPen(QPen(*currentColor, widthHairLine)); + } + else + { + this->setPen(QPen(*currentColor, widthHairLine/ *factor)); + } } diff --git a/src/widgets/vsimplespline.h b/src/widgets/vsimplespline.h index 5802948fc..c534118bc 100644 --- a/src/widgets/vsimplespline.h +++ b/src/widgets/vsimplespline.h @@ -55,7 +55,7 @@ public: * @param currentColor * @param parent */ - VSimpleSpline(qint64 id, qreal *factor, Qt::GlobalColor *currentColor, QObject *parent = 0); + VSimpleSpline(qint64 id, Qt::GlobalColor *currentColor, qreal *factor = 0, QObject *parent = 0); signals: /** * @brief Choosed diff --git a/src/xml/vdomdocument.cpp b/src/xml/vdomdocument.cpp index edb498d28..072981a92 100644 --- a/src/xml/vdomdocument.cpp +++ b/src/xml/vdomdocument.cpp @@ -671,6 +671,13 @@ void VDomDocument::ParseDetailElement(VMainGraphicsScene *sceneDetail, const QDo { tool = Tool::PointOfIntersection; } + else if (t == "CutSplineTool") + { + tool = Tool::CutSplineTool; + nodeType = NodeDetail::Modeling; + detail.append(VNodeDetail(id + 1, Tool::SimpleSpline, Draw::Modeling, nodeType, mx, my)); + detail.append(VNodeDetail(id + 2, Tool::SimpleSplinePath, Draw::Modeling, nodeType, mx, my)); + } detail.append(VNodeDetail(id, tool, Draw::Modeling, nodeType, mx, my)); } }