From 354ca935d29ee84f14b531088e4e4eb702db5aad Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 23 Apr 2015 18:06:17 +0300 Subject: [PATCH] Resolved issue #275. Add 'Show Curve Details' icon on top menu bar to show/hide control points and curve direction. --HG-- branch : develop --- src/app/mainwindow.cpp | 11 +++++++++++ src/app/mainwindow.h | 1 + src/app/mainwindow.ui | 18 ++++++++++++++++++ src/app/tools/drawTools/vabstractspline.cpp | 19 +++++++++++++++++-- src/app/tools/drawTools/vabstractspline.h | 2 ++ src/app/tools/drawTools/vtoolcut.cpp | 8 +++++++- src/app/tools/drawTools/vtoolcut.h | 3 +++ src/app/tools/drawTools/vtoolcutspline.cpp | 10 +++++++++- .../tools/drawTools/vtoolcutsplinepath.cpp | 10 +++++++++- src/app/tools/drawTools/vtoolspline.cpp | 13 +++++++++++-- src/app/tools/drawTools/vtoolsplinepath.cpp | 15 ++++++++++++--- src/app/widgets/vmaingraphicsscene.cpp | 6 ++++++ src/app/widgets/vmaingraphicsscene.h | 2 ++ 13 files changed, 108 insertions(+), 10 deletions(-) diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 1eb01848e..00b40e53b 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -1479,6 +1479,7 @@ void MainWindow::Clear() ui->actionTable->setEnabled(false); ui->actionEdit_pattern_code->setEnabled(false); ui->actionLast_tool->setEnabled(false); + ui->actionShowCurveDetails->setEnabled(false); SetEnableTool(false); qApp->setPatternUnit(Unit::Cm); qApp->setPatternType(MeasurementsType::Individual); @@ -1669,6 +1670,7 @@ void MainWindow::SetEnabledGUI(bool enabled) ui->actionTable->setEnabled(enabled); ui->actionZoomFitBest->setEnabled(enabled); ui->actionZoomOriginal->setEnabled(enabled); + ui->actionShowCurveDetails->setEnabled(enabled); if (enabled) { @@ -1839,6 +1841,7 @@ void MainWindow::SetEnableWidgets(bool enable) ui->actionZoomOut->setEnabled(enable); ui->actionZoomFitBest->setEnabled(enable); ui->actionZoomOriginal->setEnabled(enable); + ui->actionShowCurveDetails->setEnabled(enable); //Now we want allow user call context menu ui->view->setEnabled(enable); } @@ -1896,6 +1899,13 @@ void MainWindow::ActionHistory(bool checked) } } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ActionDetailsMode(bool checked) +{ + ui->view->itemClicked(nullptr); + sceneDraw->EnableDetailsMode(checked); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ActionLayout begin creation layout. @@ -2383,6 +2393,7 @@ void MainWindow::CreateActions() ui->actionPattern_properties->setEnabled(false); connect(ui->actionEdit_pattern_code, &QAction::triggered, this, &MainWindow::EditPatternCode); connect(ui->actionCloseWindow, &QAction::triggered, this, &MainWindow::ResetWindow); + connect(ui->actionShowCurveDetails, &QAction::triggered, this, &MainWindow::ActionDetailsMode); ui->actionEdit_pattern_code->setEnabled(false); //Actions for recent files loaded by a main window application. diff --git a/src/app/mainwindow.h b/src/app/mainwindow.h index 689bb4783..838878cc2 100644 --- a/src/app/mainwindow.h +++ b/src/app/mainwindow.h @@ -67,6 +67,7 @@ public slots: void ActionLayout(bool checked); void ActionTable(bool checked); void ActionHistory(bool checked); + void ActionDetailsMode(bool checked); void tableClosed(); void ClosedActionTable(); diff --git a/src/app/mainwindow.ui b/src/app/mainwindow.ui index 99932725a..254d53da8 100644 --- a/src/app/mainwindow.ui +++ b/src/app/mainwindow.ui @@ -803,6 +803,7 @@ + @@ -1356,6 +1357,23 @@ L + + + true + + + false + + + Show Curve Details + + + Show/hide control points and curve direction + + + F2 + + diff --git a/src/app/tools/drawTools/vabstractspline.cpp b/src/app/tools/drawTools/vabstractspline.cpp index affe230c5..8b10d0b6f 100644 --- a/src/app/tools/drawTools/vabstractspline.cpp +++ b/src/app/tools/drawTools/vabstractspline.cpp @@ -34,7 +34,7 @@ const QString VAbstractSpline::TagName = QStringLiteral("spline"); //--------------------------------------------------------------------------------------------------------------------- VAbstractSpline::VAbstractSpline(VPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent) :VDrawTool(doc, data, id), QGraphicsPathItem(parent), controlPoints(QVector()), - sceneType(SceneObject::Unknown), isHovered(false) + sceneType(SceneObject::Unknown), isHovered(false), detailsMode(false) { ignoreFullUpdate = true; } @@ -82,6 +82,14 @@ void VAbstractSpline::Disable(bool disable) emit setEnabledPoint(enabled); } +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractSpline::DetailsMode(bool mode) +{ + detailsMode = mode; + RefreshGeometry(); + ShowHandles(detailsMode); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ChangedActivDraw disable or enable context menu after change active pattern peace. @@ -140,7 +148,14 @@ void VAbstractSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor)); - this->setPath(ToolPath()); + if (detailsMode) + { + this->setPath(ToolPath(PathDirection::Show)); + } + else + { + this->setPath(ToolPath()); + } isHovered = false; QGraphicsPathItem::hoverLeaveEvent(event); } diff --git a/src/app/tools/drawTools/vabstractspline.h b/src/app/tools/drawTools/vabstractspline.h index 2df8ab3cc..d89d179f1 100644 --- a/src/app/tools/drawTools/vabstractspline.h +++ b/src/app/tools/drawTools/vabstractspline.h @@ -52,6 +52,7 @@ public: public slots: virtual void FullUpdateFromFile (); void Disable(bool disable); + void DetailsMode(bool mode); signals: /** * @brief RefreshLine refresh control line. @@ -74,6 +75,7 @@ protected: QVector controlPoints; SceneObject sceneType; bool isHovered; + bool detailsMode; /** * @brief RefreshGeometry refresh item on scene. */ diff --git a/src/app/tools/drawTools/vtoolcut.cpp b/src/app/tools/drawTools/vtoolcut.cpp index f97ce2b37..d24265028 100644 --- a/src/app/tools/drawTools/vtoolcut.cpp +++ b/src/app/tools/drawTools/vtoolcut.cpp @@ -35,7 +35,7 @@ VToolCut::VToolCut(VPattern *doc, VContainer *data, const quint32 &id, const QSt const quint32 &curveCutId, const quint32 &curve1id, const quint32 &curve2id, const QString &color, QGraphicsItem *parent) :VToolPoint(doc, data, id, parent), formula(formula), firstCurve(nullptr), secondCurve(nullptr), - curveCutId(curveCutId), curve1id(curve1id), curve2id(curve2id) + curveCutId(curveCutId), curve1id(curve1id), curve2id(curve2id), detailsMode(false) { Q_ASSERT_X(curveCutId > 0, Q_FUNC_INFO, "curveCutId <= 0"); Q_ASSERT_X(curve1id > 0, Q_FUNC_INFO, "curve1id <= 0"); @@ -85,6 +85,12 @@ void VToolCut::Disable(bool disable) secondCurve->ChangedActivDraw(enabled); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolCut::DetailsMode(bool mode) +{ + detailsMode = mode; +} + //--------------------------------------------------------------------------------------------------------------------- // cppcheck-suppress unusedFunction quint32 VToolCut::getCurveCutId() const diff --git a/src/app/tools/drawTools/vtoolcut.h b/src/app/tools/drawTools/vtoolcut.h index 836650f98..79d48cd76 100644 --- a/src/app/tools/drawTools/vtoolcut.h +++ b/src/app/tools/drawTools/vtoolcut.h @@ -54,6 +54,7 @@ public slots: virtual void CurveChoosed(quint32 id)=0; void HoverPath(quint32 id, SimpleCurvePoint curvePosition, PathDirection direction); void Disable(bool disable); + void DetailsMode(bool mode); protected: /** @brief formula keep formula of length */ QString formula; @@ -68,6 +69,8 @@ protected: quint32 curve1id; quint32 curve2id; + bool detailsMode; + virtual void RefreshCurve(VSimpleCurve *curve, quint32 curveId, SimpleCurvePoint curvePosition, PathDirection direction = PathDirection::Hide)=0; void RefreshGeometry(); diff --git a/src/app/tools/drawTools/vtoolcutspline.cpp b/src/app/tools/drawTools/vtoolcutspline.cpp index d99c97c16..985a377f0 100644 --- a/src/app/tools/drawTools/vtoolcutspline.cpp +++ b/src/app/tools/drawTools/vtoolcutspline.cpp @@ -184,6 +184,7 @@ VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointNa connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCutSpline::SetFactor); connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCutSpline::Disable); connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCutSpline::EnableToolMove); + connect(scene, &VMainGraphicsScene::CurveDetailsMode, point, &VToolCutSpline::DetailsMode); doc->AddTool(id, point); doc->AddTool(spl1id, point); doc->AddTool(spl2id, point); @@ -226,7 +227,14 @@ void VToolCutSpline::ShowVisualization(bool show) } if (VAbstractSpline *parentCurve = qobject_cast(doc->getTool(curveCutId))) { - parentCurve->ShowHandles(show); + if (detailsMode) + { + parentCurve->ShowHandles(detailsMode); + } + else + { + parentCurve->ShowHandles(show); + } } } diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.cpp b/src/app/tools/drawTools/vtoolcutsplinepath.cpp index ffb77fa41..7cf9b7e43 100644 --- a/src/app/tools/drawTools/vtoolcutsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolcutsplinepath.cpp @@ -229,6 +229,7 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCutSplinePath::SetFactor); connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCutSplinePath::Disable); connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCutSplinePath::EnableToolMove); + connect(scene, &VMainGraphicsScene::CurveDetailsMode, point, &VToolCutSplinePath::DetailsMode); doc->AddTool(id, point); doc->AddTool(splPath1id, point); doc->AddTool(splPath2id, point); @@ -271,7 +272,14 @@ void VToolCutSplinePath::ShowVisualization(bool show) } if (VAbstractSpline *parentCurve = qobject_cast(doc->getTool(curveCutId))) { - parentCurve->ShowHandles(show); + if (detailsMode) + { + parentCurve->ShowHandles(detailsMode); + } + else + { + parentCurve->ShowHandles(show); + } } } diff --git a/src/app/tools/drawTools/vtoolspline.cpp b/src/app/tools/drawTools/vtoolspline.cpp index 7e92f75d8..4246da5b1 100644 --- a/src/app/tools/drawTools/vtoolspline.cpp +++ b/src/app/tools/drawTools/vtoolspline.cpp @@ -201,6 +201,7 @@ VToolSpline* VToolSpline::Create(const quint32 _id, const quint32 &p1, const qui connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSpline::SetFactor); connect(scene, &VMainGraphicsScene::DisableItem, spl, &VToolSpline::Disable); connect(scene, &VMainGraphicsScene::EnableToolMove, spl, &VToolSpline::EnableToolMove); + connect(scene, &VMainGraphicsScene::CurveDetailsMode, spl, &VToolSpline::DetailsMode); doc->AddTool(id, spl); doc->IncrementReferens(p1); doc->IncrementReferens(p4); @@ -261,7 +262,15 @@ void VToolSpline::ShowVisualization(bool show) delete vis; vis = nullptr; } - ShowHandles(show); + + if (detailsMode) + { + ShowHandles(detailsMode); + } + else + { + ShowHandles(show); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -484,7 +493,7 @@ void VToolSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) void VToolSpline::RefreshGeometry() { this->setPen(QPen(CorrectColor(lineColor), qApp->toPixel(qApp->widthHairLine())/factor)); - if (isHovered) + if (isHovered || detailsMode) { this->setPath(ToolPath(PathDirection::Show)); } diff --git a/src/app/tools/drawTools/vtoolsplinepath.cpp b/src/app/tools/drawTools/vtoolsplinepath.cpp index 57fdd0146..6a3b0f158 100644 --- a/src/app/tools/drawTools/vtoolsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolsplinepath.cpp @@ -85,7 +85,7 @@ VToolSplinePath::VToolSplinePath(VPattern *doc, VContainer *data, quint32 id, co controlPoints.append(controlPoint); } - ShowHandlers(false); + ShowHandles(false); if (typeCreation == Source::FromGui) { @@ -178,6 +178,7 @@ VToolSplinePath* VToolSplinePath::Create(const quint32 _id, VSplinePath *path, c connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSplinePath::SetFactor); connect(scene, &VMainGraphicsScene::DisableItem, spl, &VToolSplinePath::Disable); connect(scene, &VMainGraphicsScene::EnableToolMove, spl, &VToolSplinePath::EnableToolMove); + connect(scene, &VMainGraphicsScene::CurveDetailsMode, spl, &VToolSplinePath::DetailsMode); doc->AddTool(id, spl); return spl; } @@ -333,7 +334,15 @@ void VToolSplinePath::ShowVisualization(bool show) delete vis; vis = nullptr; } - ShowHandlers(show); + + if (detailsMode) + { + ShowHandles(detailsMode); + } + else + { + ShowHandles(show); + } } //--------------------------------------------------------------------------------------------------------------------- @@ -552,7 +561,7 @@ void VToolSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) */ void VToolSplinePath::RefreshGeometry() { - if (isHovered) + if (isHovered || detailsMode) { this->setPath(ToolPath(PathDirection::Show)); } diff --git a/src/app/widgets/vmaingraphicsscene.cpp b/src/app/widgets/vmaingraphicsscene.cpp index c93a2392d..464805c76 100644 --- a/src/app/widgets/vmaingraphicsscene.cpp +++ b/src/app/widgets/vmaingraphicsscene.cpp @@ -132,3 +132,9 @@ void VMainGraphicsScene::EnableItemMove(bool move) { emit EnableToolMove(move); } + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::EnableDetailsMode(bool mode) +{ + emit CurveDetailsMode(mode); +} diff --git a/src/app/widgets/vmaingraphicsscene.h b/src/app/widgets/vmaingraphicsscene.h index cde39f846..3d9295384 100644 --- a/src/app/widgets/vmaingraphicsscene.h +++ b/src/app/widgets/vmaingraphicsscene.h @@ -53,6 +53,7 @@ public slots: void ChoosedItem(quint32 id, const SceneObject &type); void SetFactor(qreal factor); void EnableItemMove(bool move); + void EnableDetailsMode(bool mode); protected: virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); @@ -80,6 +81,7 @@ signals: void NewFactor(qreal factor); void DisableItem(bool disable); void EnableToolMove(bool move); + void CurveDetailsMode(bool mode); private: /** @brief horScrollBar value horizontal scroll bar. */ qint32 horScrollBar;