From 351f01e0e3ab99a0f71468d5bf1b1e8f25538704 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 31 Mar 2016 17:01:41 +0300 Subject: [PATCH] Disable hover and selection when work with a tool. --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 255 +++++++++++++++++- src/app/valentina/mainwindow.h | 28 ++ src/app/valentina/xml/vpattern.cpp | 18 +- .../drawTools/toolcurve/vabstractspline.cpp | 30 ++- .../drawTools/toolcurve/vabstractspline.h | 54 +++- .../tools/drawTools/toolcurve/vtoolarc.cpp | 5 +- .../toolcurve/vtoolarcwithlength.cpp | 5 +- .../drawTools/toolcurve/vtoolcubicbezier.cpp | 5 +- .../toolcurve/vtoolcubicbezierpath.cpp | 5 +- .../tools/drawTools/toolcurve/vtoolspline.cpp | 7 +- .../drawTools/toolcurve/vtoolsplinepath.cpp | 7 +- .../tooldoublepoint/vtooldoublepoint.cpp | 28 ++ .../tooldoublepoint/vtooldoublepoint.h | 4 + .../tooldoublepoint/vtooltruedarts.cpp | 5 +- .../toolsinglepoint/toolcut/vtoolcut.h | 2 +- .../toolsinglepoint/toolcut/vtoolcutarc.cpp | 5 +- .../toolcut/vtoolcutspline.cpp | 6 +- .../toolcut/vtoolcutsplinepath.cpp | 6 +- .../toollinepoint/vtoolalongline.cpp | 5 +- .../toollinepoint/vtoolbisector.cpp | 5 +- .../toollinepoint/vtoolcurveintersectaxis.cpp | 5 +- .../toollinepoint/vtoolendline.cpp | 5 +- .../toollinepoint/vtoolheight.cpp | 5 +- .../toollinepoint/vtoollineintersectaxis.cpp | 5 +- .../toollinepoint/vtoolnormal.cpp | 5 +- .../toollinepoint/vtoolshoulderpoint.cpp | 5 +- .../toolsinglepoint/vtoolbasepoint.cpp | 32 +++ .../toolsinglepoint/vtoolbasepoint.h | 3 + .../toolsinglepoint/vtoollineintersect.cpp | 5 +- .../vtoolpointfromarcandtangent.cpp | 5 +- .../vtoolpointfromcircleandtangent.cpp | 5 +- .../toolsinglepoint/vtoolpointofcontact.cpp | 5 +- .../vtoolpointofintersection.cpp | 5 +- .../vtoolpointofintersectionarcs.cpp | 5 +- .../vtoolpointofintersectioncircles.cpp | 5 +- .../vtoolpointofintersectioncurves.cpp | 5 +- .../toolsinglepoint/vtoolsinglepoint.cpp | 38 ++- .../toolsinglepoint/vtoolsinglepoint.h | 7 +- .../toolsinglepoint/vtooltriangle.cpp | 5 +- .../drawTools/toolpoint/vabstractpoint.h | 17 ++ src/libs/vtools/tools/drawTools/vdrawtool.cpp | 7 + src/libs/vtools/tools/drawTools/vdrawtool.h | 18 ++ src/libs/vtools/tools/drawTools/vtoolline.cpp | 13 + src/libs/vtools/tools/drawTools/vtoolline.h | 2 + .../vtools/tools/nodeDetails/vnodearc.cpp | 14 + src/libs/vtools/tools/nodeDetails/vnodearc.h | 2 + .../vtools/tools/nodeDetails/vnodepoint.cpp | 38 ++- .../vtools/tools/nodeDetails/vnodepoint.h | 5 + .../vtools/tools/nodeDetails/vnodespline.cpp | 14 + .../vtools/tools/nodeDetails/vnodespline.h | 2 + .../tools/nodeDetails/vnodesplinepath.cpp | 14 + .../tools/nodeDetails/vnodesplinepath.h | 2 + src/libs/vtools/tools/vabstracttool.h | 2 + src/libs/vtools/tools/vtooldetail.cpp | 20 +- src/libs/vtools/tools/vtooldetail.h | 2 + src/libs/vtools/tools/vtooluniondetails.h | 2 + src/libs/vwidgets/vgraphicssimpletextitem.cpp | 15 +- src/libs/vwidgets/vmaingraphicsscene.cpp | 102 +++++++ src/libs/vwidgets/vmaingraphicsscene.h | 38 +++ src/libs/vwidgets/vmaingraphicsview.cpp | 15 +- src/libs/vwidgets/vmaingraphicsview.h | 2 + src/libs/vwidgets/vsimplepoint.cpp | 22 +- src/libs/vwidgets/vsimplepoint.h | 5 +- 63 files changed, 845 insertions(+), 168 deletions(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 2c6febaaa..7eac35337 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -242,18 +242,11 @@ void MainWindow::AddPP(const QString &PPName) ui->view->itemClicked(nullptr);//hide options previous tool const QString label = doc->GenerateLabel(LabelType::NewPatternPiece); const QPointF startPosition = StartPositionNewPP(); - const quint32 id = pattern->AddGObject(new VPointF(startPosition.x(), startPosition.y(), label, 5, 10)); - VToolBasePoint *spoint = new VToolBasePoint(doc, pattern, id, Source::FromGui, PPName); - sceneDraw->addItem(spoint); + VPointF *point = new VPointF(startPosition.x(), startPosition.y(), label, 5, 10); + auto spoint = VToolBasePoint::Create(0, PPName, point, sceneDraw, doc, pattern, Document::FullParse, + Source::FromGui); ui->view->itemClicked(spoint); - connect(spoint, &VToolSinglePoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem); - connect(sceneDraw, &VMainGraphicsScene::DisableItem, spoint, &VToolBasePoint::Disable); - connect(sceneDraw, &VMainGraphicsScene::NewFactor, spoint, &VToolBasePoint::SetFactor); - connect(sceneDraw, &VMainGraphicsScene::EnableToolMove, spoint, &VToolBasePoint::EnableToolMove); - - doc->AddTool(id, spoint); - VDrawTool::AddRecord(id, Tool::BasePoint, doc); SetEnableTool(true); SetEnableWidgets(true); @@ -308,9 +301,33 @@ void MainWindow::InitScenes() currentScene = sceneDraw; qApp->setCurrentScene(currentScene); connect(this, &MainWindow::EnableItemMove, sceneDraw, &VMainGraphicsScene::EnableItemMove); + + connect(this, &MainWindow::EnableLabelSelection, sceneDraw, &VMainGraphicsScene::ToggleLabelSelection); + connect(this, &MainWindow::EnablePointSelection, sceneDraw, &VMainGraphicsScene::TogglePointSelection); + connect(this, &MainWindow::EnableArcSelection, sceneDraw, &VMainGraphicsScene::ToggleArcSelection); + connect(this, &MainWindow::EnableSplineSelection, sceneDraw, &VMainGraphicsScene::ToggleSplineSelection); + connect(this, &MainWindow::EnableSplinePathSelection, sceneDraw, &VMainGraphicsScene::ToggleSplinePathSelection); + + connect(this, &MainWindow::EnableLabelHover, sceneDraw, &VMainGraphicsScene::ToggleLabelHover); + connect(this, &MainWindow::EnablePointHover, sceneDraw, &VMainGraphicsScene::TogglePointHover); + connect(this, &MainWindow::EnableLineHover, sceneDraw, &VMainGraphicsScene::ToggleLineHover); + connect(this, &MainWindow::EnableArcHover, sceneDraw, &VMainGraphicsScene::ToggleArcHover); + connect(this, &MainWindow::EnableSplineHover, sceneDraw, &VMainGraphicsScene::ToggleSplineHover); + connect(this, &MainWindow::EnableSplinePathHover, sceneDraw, &VMainGraphicsScene::ToggleSplinePathHover); + connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove); + sceneDetails = new VMainGraphicsScene(); connect(this, &MainWindow::EnableItemMove, sceneDetails, &VMainGraphicsScene::EnableItemMove); + + connect(this, &MainWindow::EnableNodeLabelSelection, sceneDetails, &VMainGraphicsScene::ToggleNodeLabelSelection); + connect(this, &MainWindow::EnableNodePointSelection, sceneDetails, &VMainGraphicsScene::ToggleNodePointSelection); + connect(this, &MainWindow::EnableDetailSelection, sceneDetails, &VMainGraphicsScene::ToggleDetailSelection); + + connect(this, &MainWindow::EnableNodeLabelHover, sceneDetails, &VMainGraphicsScene::ToggleNodeLabelHover); + connect(this, &MainWindow::EnableNodePointHover, sceneDetails, &VMainGraphicsScene::ToggleNodePointHover); + connect(this, &MainWindow::EnableDetailHover, sceneDetails, &VMainGraphicsScene::ToggleDetailHover); + connect(sceneDetails, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove); ui->view->setScene(currentScene); @@ -689,6 +706,7 @@ void MainWindow::ApplyDialog() */ void MainWindow::ToolEndLine(bool checked) { + ToolSelectPoint(); SetToolButtonWithApply(checked, Tool::EndLine, ":/cursor/endline_cursor.png", tr("Select point"), &MainWindow::ClosedDialogWithApply, &MainWindow::ApplyDialog); @@ -701,6 +719,7 @@ void MainWindow::ToolEndLine(bool checked) */ void MainWindow::ToolLine(bool checked) { + ToolSelectPoint(); SetToolButtonWithApply(checked, Tool::Line, ":/cursor/line_cursor.png", tr("Select first point"), &MainWindow::ClosedDialogWithApply, &MainWindow::ApplyDialog); @@ -713,6 +732,7 @@ void MainWindow::ToolLine(bool checked) */ void MainWindow::ToolAlongLine(bool checked) { + ToolSelectPoint(); SetToolButtonWithApply(checked, Tool::AlongLine, ":/cursor/alongline_cursor.png", tr("Select point"), &MainWindow::ClosedDialogWithApply, &MainWindow::ApplyDialog); @@ -725,6 +745,7 @@ void MainWindow::ToolAlongLine(bool checked) */ void MainWindow::ToolShoulderPoint(bool checked) { + ToolSelectPoint(); SetToolButtonWithApply(checked, Tool::ShoulderPoint, ":/cursor/shoulder_cursor.png", tr("Select point"), &MainWindow::ClosedDialogWithApply, @@ -738,6 +759,7 @@ void MainWindow::ToolShoulderPoint(bool checked) */ void MainWindow::ToolNormal(bool checked) { + ToolSelectPoint(); SetToolButtonWithApply(checked, Tool::Normal, ":/cursor/normal_cursor.png", tr("Select first point of line"), &MainWindow::ClosedDialogWithApply, @@ -751,6 +773,7 @@ void MainWindow::ToolNormal(bool checked) */ void MainWindow::ToolBisector(bool checked) { + ToolSelectPoint(); SetToolButtonWithApply(checked, Tool::Bisector, ":/cursor/bisector_cursor.png", tr("Select first point of angle"), &MainWindow::ClosedDialogWithApply, @@ -764,6 +787,7 @@ void MainWindow::ToolBisector(bool checked) */ void MainWindow::ToolLineIntersect(bool checked) { + ToolSelectPoint(); SetToolButtonWithApply(checked, Tool::LineIntersect, ":/cursor/intersect_cursor.png", tr("Select first point of first line"), &MainWindow::ClosedDialogWithApply, @@ -777,6 +801,7 @@ void MainWindow::ToolLineIntersect(bool checked) */ void MainWindow::ToolSpline(bool checked) { + ToolSelectPoint(); SetToolButtonWithApply(checked, Tool::Spline, ":/cursor/spline_cursor.png", tr("Select first point curve"), &MainWindow::ClosedDialogWithApply, @@ -786,6 +811,7 @@ void MainWindow::ToolSpline(bool checked) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolCubicBezier(bool checked) { + ToolSelectPoint(); SetToolButtonWithApply(checked, Tool::CubicBezier, ":/cursor/cubic_bezier_cursor.png", tr("Select first curve point"), &MainWindow::ClosedDialogWithApply, @@ -799,6 +825,7 @@ void MainWindow::ToolCubicBezier(bool checked) */ void MainWindow::ToolCutSpline(bool checked) { + ToolSelectSpline(); SetToolButtonWithApply(checked, Tool::CutSpline, ":/cursor/spline_cut_point_cursor.png", tr("Select simple curve"), &MainWindow::ClosedDialogWithApply, @@ -812,6 +839,7 @@ void MainWindow::ToolCutSpline(bool checked) */ void MainWindow::ToolArc(bool checked) { + ToolSelectPoint(); SetToolButtonWithApply(checked, Tool::Arc, ":/cursor/arc_cursor.png", tr("Select point of center of arc"), &MainWindow::ClosedDialogWithApply, &MainWindow::ApplyDialog); @@ -824,6 +852,7 @@ void MainWindow::ToolArc(bool checked) */ void MainWindow::ToolSplinePath(bool checked) { + ToolSelectPoint(); SetToolButtonWithApply(checked, Tool::SplinePath, ":/cursor/splinepath_cursor.png", tr("Select point of curve path"), &MainWindow::ClosedDialogWithApply, @@ -833,6 +862,7 @@ void MainWindow::ToolSplinePath(bool checked) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolCubicBezierPath(bool checked) { + ToolSelectPoint(); SetToolButtonWithApply(checked, Tool::CubicBezierPath, ":/cursor/cubic_bezier_path_cursor.png", tr("Select point of cubic bezier path"), @@ -847,6 +877,7 @@ void MainWindow::ToolCubicBezierPath(bool checked) */ void MainWindow::ToolCutSplinePath(bool checked) { + ToolSelectSplinePath(); SetToolButtonWithApply(checked, Tool::CutSplinePath, ":/cursor/splinepath_cut_point_cursor.png", tr("Select curve path"), &MainWindow::ClosedDialogWithApply, @@ -860,6 +891,7 @@ void MainWindow::ToolCutSplinePath(bool checked) */ void MainWindow::ToolPointOfContact(bool checked) { + ToolSelectPoint(); SetToolButtonWithApply(checked, Tool::PointOfContact, ":/cursor/pointcontact_cursor.png", tr("Select first point of line"), &MainWindow::ClosedDialogWithApply, @@ -873,6 +905,7 @@ void MainWindow::ToolPointOfContact(bool checked) */ void MainWindow::ToolDetail(bool checked) { + ToolSelectAllObjects(); SetToolButton(checked, Tool::Detail, "://cursor/new_detail_cursor.png", tr("Select points, arcs, curves clockwise."), &MainWindow::ClosedDialogDetail); } @@ -899,6 +932,7 @@ void MainWindow::ClosedDialogDetail(int result) */ void MainWindow::ToolHeight(bool checked) { + ToolSelectPoint(); SetToolButtonWithApply(checked, Tool::Height, ":/cursor/height_cursor.png", tr("Select base point"), &MainWindow::ClosedDialogWithApply, &MainWindow::ApplyDialog); @@ -911,6 +945,7 @@ void MainWindow::ToolHeight(bool checked) */ void MainWindow::ToolTriangle(bool checked) { + ToolSelectPoint(); SetToolButtonWithApply(checked, Tool::Triangle, ":/cursor/triangle_cursor.png", tr("Select first point of axis"), &MainWindow::ClosedDialogWithApply, @@ -924,6 +959,7 @@ void MainWindow::ToolTriangle(bool checked) */ void MainWindow::ToolPointOfIntersection(bool checked) { + ToolSelectPoint(); SetToolButtonWithApply(checked, Tool::PointOfIntersection, ":/cursor/pointofintersect_cursor.png", tr("Select point for X value (vertical)"), @@ -938,6 +974,7 @@ void MainWindow::ToolPointOfIntersection(bool checked) */ void MainWindow::ToolUnionDetails(bool checked) { + ToolSelectDetail(); SetToolButton(checked, Tool::UnionDetails, ":/cursor/union_cursor.png", tr("Select detail"), &MainWindow::ClosedDialogUnionDetails); } @@ -960,6 +997,7 @@ void MainWindow::ClosedDialogUnionDetails(int result) */ void MainWindow::ToolCutArc(bool checked) { + ToolSelectArc(); SetToolButtonWithApply(checked, Tool::CutArc, ":/cursor/arc_cut_cursor.png", tr("Select arc"), &MainWindow::ClosedDialogWithApply, &MainWindow::ApplyDialog); @@ -968,6 +1006,7 @@ void MainWindow::ToolCutArc(bool checked) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolLineIntersectAxis(bool checked) { + ToolSelectPoint(); SetToolButtonWithApply(checked, Tool::LineIntersectAxis, ":/cursor/line_intersect_axis_cursor.png", tr("Select first point of line"), @@ -978,6 +1017,7 @@ void MainWindow::ToolLineIntersectAxis(bool checked) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolCurveIntersectAxis(bool checked) { + ToolSelectAllObjects(); SetToolButtonWithApply(checked, Tool::CurveIntersectAxis, ":/cursor/curve_intersect_axis_cursor.png", tr("Select curve"), @@ -988,6 +1028,7 @@ void MainWindow::ToolCurveIntersectAxis(bool checked) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolArcIntersectAxis(bool checked) { + ToolSelectAllObjects(); // Reuse ToolCurveIntersectAxis but with different cursor and tool tip SetToolButtonWithApply(checked, Tool::CurveIntersectAxis, ":/cursor/arc_intersect_axis_cursor.png", @@ -999,6 +1040,7 @@ void MainWindow::ToolArcIntersectAxis(bool checked) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolPointOfIntersectionArcs(bool checked) { + ToolSelectArc(); SetToolButtonWithApply(checked, Tool::PointOfIntersectionArcs, "://cursor/point_of_intersection_arcs.png", tr("Select first an arc"), @@ -1009,6 +1051,7 @@ void MainWindow::ToolPointOfIntersectionArcs(bool checked) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolPointOfIntersectionCircles(bool checked) { + ToolSelectPoint(); SetToolButtonWithApply(checked, Tool::PointOfIntersectionCircles, "://cursor/point_of_intersection_circles.png", tr("Select first circle center "), @@ -1019,6 +1062,7 @@ void MainWindow::ToolPointOfIntersectionCircles(bool checked) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolPointOfIntersectionCurves(bool checked) { + ToolSelectCurve(); SetToolButtonWithApply(checked, Tool::PointOfIntersectionCurves, "://cursor/intersection_curves_cursor.png", tr("Select first curve"), @@ -1029,6 +1073,7 @@ void MainWindow::ToolPointOfIntersectionCurves(bool checked) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolPointFromCircleAndTangent(bool checked) { + ToolSelectPoint(); SetToolButtonWithApply(checked, Tool::PointFromCircleAndTangent, "://cursor/point_from_circle_and_tangent_cursor.png", tr("Select point on tangent "), @@ -1039,6 +1084,7 @@ void MainWindow::ToolPointFromCircleAndTangent(bool checked) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolPointFromArcAndTangent(bool checked) { + ToolSelectPointArc(); SetToolButtonWithApply(checked, Tool::PointFromArcAndTangent, "://cursor/point_from_arc_and_tangent_cursor.png", tr("Select point on tangent "), @@ -1049,6 +1095,7 @@ void MainWindow::ToolPointFromArcAndTangent(bool checked) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolArcWithLength(bool checked) { + ToolSelectPoint(); SetToolButtonWithApply(checked, Tool::ArcWithLength, "://cursor/arc_with_length_cursor.png", tr("Select point of the center of the arc"), @@ -1059,6 +1106,7 @@ void MainWindow::ToolArcWithLength(bool checked) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolTrueDarts(bool checked) { + ToolSelectPoint(); SetToolButtonWithApply(checked, Tool::TrueDarts, "://cursor/true_darts_cursor.png", tr("Select the first base line point"), @@ -1841,6 +1889,30 @@ void MainWindow::ArrowTool() ui->actionStopTool->setEnabled(false); currentTool = Tool::Arrow; emit EnableItemMove(true); + + // Only true for rubber band selection + emit EnableLabelSelection(true); + emit EnablePointSelection(false); + emit EnableArcSelection(false); + emit EnableSplineSelection(false); + emit EnableSplinePathSelection(false); + emit EnableNodeLabelSelection(true); + emit EnableNodePointSelection(true); + emit EnableDetailSelection(true);// Disable when done visualization details + + // Hovering + emit EnableLabelHover(true); + emit EnablePointHover(true); + emit EnableLineHover(true); + emit EnableArcHover(true); + emit EnableSplineHover(true); + emit EnableSplinePathHover(true); + emit EnableNodeLabelHover(true); + emit EnableNodePointHover(true); + emit EnableDetailHover(true); + + ui->view->AllowRubberBand(true); + QCursor cur(Qt::ArrowCursor); ui->view->setCursor(cur); helpLabel->setText(""); @@ -4406,3 +4478,166 @@ bool MainWindow::IgnoreLocking(int error, const QString &path) } return true; } + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ToolSelectPoint() const +{ + // Only true for rubber band selection + emit EnableLabelSelection(false); + emit EnablePointSelection(false); + emit EnableArcSelection(false); + emit EnableSplineSelection(false); + emit EnableSplinePathSelection(false); + + // Hovering + emit EnableLabelHover(true); + emit EnablePointHover(true); + emit EnableLineHover(false); + emit EnableArcHover(false); + emit EnableSplineHover(false); + emit EnableSplinePathHover(false); + + ui->view->AllowRubberBand(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ToolSelectSpline() const +{ + // Only true for rubber band selection + emit EnableLabelSelection(false); + emit EnablePointSelection(false); + emit EnableArcSelection(false); + emit EnableSplineSelection(false); + emit EnableSplinePathSelection(false); + + // Hovering + emit EnableLabelHover(false); + emit EnablePointHover(false); + emit EnableLineHover(false); + emit EnableArcHover(false); + emit EnableSplineHover(true); + emit EnableSplinePathHover(false); + + ui->view->AllowRubberBand(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ToolSelectSplinePath() const +{ + // Only true for rubber band selection + emit EnableLabelSelection(false); + emit EnablePointSelection(false); + emit EnableArcSelection(false); + emit EnableSplineSelection(false); + emit EnableSplinePathSelection(false); + + // Hovering + emit EnableLabelHover(false); + emit EnablePointHover(false); + emit EnableLineHover(false); + emit EnableArcHover(false); + emit EnableSplineHover(false); + emit EnableSplinePathHover(true); + + ui->view->AllowRubberBand(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ToolSelectArc() const +{ + // Only true for rubber band selection + emit EnableLabelSelection(false); + emit EnablePointSelection(false); + emit EnableArcSelection(false); + emit EnableSplineSelection(false); + emit EnableSplinePathSelection(false); + + // Hovering + emit EnableLabelHover(false); + emit EnablePointHover(false); + emit EnableLineHover(false); + emit EnableArcHover(true); + emit EnableSplineHover(false); + emit EnableSplinePathHover(false); + + ui->view->AllowRubberBand(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ToolSelectPointArc() const +{ + // Only true for rubber band selection + emit EnableLabelSelection(false); + emit EnablePointSelection(false); + emit EnableArcSelection(false); + emit EnableSplineSelection(false); + emit EnableSplinePathSelection(false); + + // Hovering + emit EnableLabelHover(true); + emit EnablePointHover(true); + emit EnableLineHover(false); + emit EnableArcHover(true); + emit EnableSplineHover(false); + emit EnableSplinePathHover(false); + + ui->view->AllowRubberBand(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ToolSelectCurve() const +{ + // Only true for rubber band selection + emit EnableLabelSelection(false); + emit EnablePointSelection(false); + emit EnableArcSelection(false); + emit EnableSplineSelection(false); + emit EnableSplinePathSelection(false); + + // Hovering + emit EnableLabelHover(false); + emit EnablePointHover(false); + emit EnableLineHover(false); + emit EnableArcHover(true); + emit EnableSplineHover(true); + emit EnableSplinePathHover(true); + + ui->view->AllowRubberBand(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ToolSelectAllObjects() const +{ + // Only true for rubber band selection + emit EnableLabelSelection(false); + emit EnablePointSelection(false); + emit EnableArcSelection(false); + emit EnableSplineSelection(false); + emit EnableSplinePathSelection(false); + + // Hovering + emit EnableLabelHover(true); + emit EnablePointHover(true); + emit EnableLineHover(false); + emit EnableArcHover(true); + emit EnableSplineHover(true); + emit EnableSplinePathHover(true); + + ui->view->AllowRubberBand(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ToolSelectDetail() const +{ + // Only true for rubber band selection + emit EnableNodeLabelSelection(false); + emit EnableNodePointSelection(false); + emit EnableDetailSelection(true);// Disable when done visualization details + + // Hovering + emit EnableNodeLabelHover(true); + emit EnableNodePointHover(true); + emit EnableDetailHover(true); + + ui->view->AllowRubberBand(false); +} diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index 92829ac41..e78d7d3b7 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -157,6 +157,25 @@ public slots: signals: void RefreshHistory(); void EnableItemMove(bool move); + + void EnableLabelSelection(bool enable) const; + void EnablePointSelection(bool enable) const; + void EnableArcSelection(bool enable) const; + void EnableSplineSelection(bool enable) const; + void EnableSplinePathSelection(bool enable) const; + void EnableNodeLabelSelection(bool enable) const; + void EnableNodePointSelection(bool enable) const; + void EnableDetailSelection(bool enable) const; + + void EnableLabelHover(bool enable) const; + void EnablePointHover(bool enable) const; + void EnableLineHover(bool enable) const; + void EnableArcHover(bool enable) const; + void EnableSplineHover(bool enable) const; + void EnableSplinePathHover(bool enable) const; + void EnableNodeLabelHover(bool enable) const; + void EnableNodePointHover(bool enable) const; + void EnableDetailHover(bool enable) const; protected: virtual void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE; virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE; @@ -331,6 +350,15 @@ private: void UpdateWindowTitle(); bool IgnoreLocking(int error, const QString &path); + + void ToolSelectPoint() const; + void ToolSelectSpline() const; + void ToolSelectSplinePath() const; + void ToolSelectArc() const; + void ToolSelectPointArc() const; + void ToolSelectCurve() const; + void ToolSelectAllObjects() const; + void ToolSelectDetail() const; }; #endif // MAINWINDOW_H diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 47d0c0130..3b691a784 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -940,22 +940,8 @@ void VPattern::ParseToolBasePoint(VMainGraphicsScene *scene, const QDomElement & const qreal x = qApp->toPixel(GetParametrDouble(domElement, AttrX, "10.0")); const qreal y = qApp->toPixel(GetParametrDouble(domElement, AttrY, "10.0")); - data->UpdateGObject(id, new VPointF(x, y, name, mx, my)); - VDrawTool::AddRecord(id, Tool::BasePoint, this); - if (parse != Document::FullParse) - { - UpdateToolData(id, data); - } - if (parse == Document::FullParse) - { - spoint = new VToolBasePoint(this, data, id, Source::FromFile, nameActivPP); - scene->addItem(spoint); - connect(spoint, &VToolBasePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, spoint, &VToolBasePoint::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, spoint, &VToolBasePoint::Disable); - connect(scene, &VMainGraphicsScene::EnableToolMove, spoint, &VToolBasePoint::EnableToolMove); - tools[id] = spoint; - } + VPointF *point = new VPointF(x, y, name, mx, my); + VToolBasePoint::Create(id, nameActivPP, point, scene, this, data, parse, Source::FromFile); } catch (const VExceptionBadId &e) { diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp index 3cd08c5c7..87d5d7bab 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp @@ -38,7 +38,9 @@ const QString VAbstractSpline::TagName = QStringLiteral("spline"); VAbstractSpline::VAbstractSpline(VAbstractPattern *doc, VContainer *data, quint32 id, QGraphicsItem *parent) :VDrawTool(doc, data, id), QGraphicsPathItem(parent), controlPoints(QVector()), sceneType(SceneObject::Unknown), isHovered(false), detailsMode(false) -{} +{ + setAcceptHoverEvents(true); +} //--------------------------------------------------------------------------------------------------------------------- VAbstractSpline::~VAbstractSpline() @@ -92,6 +94,18 @@ void VAbstractSpline::DetailsMode(bool mode) ShowHandles(detailsMode); } +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractSpline::AllowHover(bool enabled) +{ + setAcceptHoverEvents(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractSpline::AllowSelecting(bool enabled) +{ + setFlag(QGraphicsItem::ItemIsSelectable, enabled); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ShowTool highlight tool. @@ -205,18 +219,26 @@ void VAbstractSpline::keyReleaseEvent(QKeyEvent *event) QGraphicsItem::keyReleaseEvent ( event ); } +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractSpline::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + // Special for not selectable item first need to call standard mousePressEvent then accept event + QGraphicsPathItem::mousePressEvent(event); + event->accept();// Special for not selectable item first need to call standard mousePressEvent then accept event +} + //--------------------------------------------------------------------------------------------------------------------- /** - * @brief mousePressEvent handle mouse press events. + * @brief mouseReleaseEvent handle mouse release events. * @param event mouse release event. */ -void VAbstractSpline::mousePressEvent(QGraphicsSceneMouseEvent *event) +void VAbstractSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton) { emit ChoosedTool(id, sceneType); } - QGraphicsPathItem::mousePressEvent(event); + QGraphicsPathItem::mouseReleaseEvent(event); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h index 821c56899..5a7d2a10b 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h @@ -58,7 +58,10 @@ public: public slots: virtual void FullUpdateFromFile () Q_DECL_OVERRIDE; virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE; - void DetailsMode(bool mode); + virtual void DetailsMode(bool mode) Q_DECL_OVERRIDE; + virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE; + virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE; + virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE; signals: /** * @brief setEnabledPoint disable control points. @@ -78,12 +81,12 @@ protected: */ virtual void RefreshGeometry ()=0; virtual void ShowTool(quint32 id, bool enable) Q_DECL_OVERRIDE; - virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE; virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE; virtual void keyReleaseEvent(QKeyEvent * event) Q_DECL_OVERRIDE; - virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; + virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE; + virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; QPainterPath ToolPath(PathDirection direction = PathDirection::Hide) const; virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE; virtual void SaveOptions(QDomElement &tag, QSharedPointer &obj) Q_DECL_OVERRIDE; @@ -93,6 +96,15 @@ protected: template void ShowToolVisualization(bool show); + template + static void InitSplineToolConnections(VMainGraphicsScene *scene, T *tool); + + template + static void InitSplinePathToolConnections(VMainGraphicsScene *scene, T *tool); + + template + static void InitArcToolConnections(VMainGraphicsScene *scene, T *tool); + private: Q_DISABLE_COPY(VAbstractSpline) }; @@ -137,4 +149,40 @@ inline void VAbstractSpline::ShowToolVisualization(bool show) } } +//--------------------------------------------------------------------------------------------------------------------- +template +void VAbstractSpline::InitSplineToolConnections(VMainGraphicsScene *scene, T *tool) +{ + SCASSERT(scene != nullptr); + SCASSERT(tool != nullptr); + + InitDrawToolConnections(scene, tool); + QObject::connect(scene, &VMainGraphicsScene::EnableSplineItemHover, tool, &T::AllowHover); + QObject::connect(scene, &VMainGraphicsScene::EnableSplineItemSelection, tool, &T::AllowSelecting); +} + +//--------------------------------------------------------------------------------------------------------------------- +template +void VAbstractSpline::InitSplinePathToolConnections(VMainGraphicsScene *scene, T *tool) +{ + SCASSERT(scene != nullptr); + SCASSERT(tool != nullptr); + + InitDrawToolConnections(scene, tool); + QObject::connect(scene, &VMainGraphicsScene::EnableSplinePathItemHover, tool, &T::AllowHover); + QObject::connect(scene, &VMainGraphicsScene::EnableSplinePathItemSelection, tool, &T::AllowSelecting); +} + +//--------------------------------------------------------------------------------------------------------------------- +template +void VAbstractSpline::InitArcToolConnections(VMainGraphicsScene *scene, T *tool) +{ + SCASSERT(scene != nullptr); + SCASSERT(tool != nullptr); + + InitDrawToolConnections(scene, tool); + QObject::connect(scene, &VMainGraphicsScene::EnableArcItemHover, tool, &T::AllowHover); + QObject::connect(scene, &VMainGraphicsScene::EnableArcItemSelection, tool, &T::AllowSelecting); +} + #endif // VABSTRACTSPLINE_H diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp index df7114e16..599424926 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarc.cpp @@ -58,7 +58,6 @@ VToolArc::VToolArc(VAbstractPattern *doc, VContainer *data, quint32 id, const QS this->setPath(ToolPath()); this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); - this->setAcceptHoverEvents(true); ToolCreation(typeCreation); } @@ -154,9 +153,7 @@ VToolArc* VToolArc::Create(const quint32 _id, const quint32 ¢er, QString &ra { VToolArc *toolArc = new VToolArc(doc, data, id, color, typeCreation); scene->addItem(toolArc); - connect(toolArc, &VToolArc::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, toolArc, &VToolArc::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, toolArc, &VToolArc::Disable); + InitArcToolConnections(scene, toolArc); doc->AddTool(id, toolArc); doc->IncrementReferens(c.getIdTool()); return toolArc; diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp index 3fb84429e..cbfc76864 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolarcwithlength.cpp @@ -49,7 +49,6 @@ VToolArcWithLength::VToolArcWithLength(VAbstractPattern *doc, VContainer *data, this->setPath(ToolPath()); this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); - this->setAcceptHoverEvents(true); ToolCreation(typeCreation); } @@ -123,9 +122,7 @@ VToolArcWithLength *VToolArcWithLength::Create(const quint32 _id, const quint32 { VToolArcWithLength *toolArc = new VToolArcWithLength(doc, data, id, color, typeCreation); scene->addItem(toolArc); - connect(toolArc, &VToolArcWithLength::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, toolArc, &VToolArcWithLength::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, toolArc, &VToolArcWithLength::Disable); + InitArcToolConnections(scene, toolArc); doc->AddTool(id, toolArc); doc->IncrementReferens(c.getIdTool()); return toolArc; diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp index e3899059d..a00a11c43 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezier.cpp @@ -43,7 +43,6 @@ VToolCubicBezier::VToolCubicBezier(VAbstractPattern *doc, VContainer *data, quin lineColor = color; this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); - this->setAcceptHoverEvents(true); this->setPath(ToolPath()); ToolCreation(typeCreation); @@ -108,9 +107,7 @@ VToolCubicBezier *VToolCubicBezier::Create(const quint32 _id, VCubicBezier *spli { auto _spl = new VToolCubicBezier(doc, data, id, color, typeCreation); scene->addItem(_spl); - connect(_spl, &VToolCubicBezier::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, _spl, &VToolCubicBezier::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, _spl, &VToolCubicBezier::Disable); + InitSplineToolConnections(scene, _spl); doc->AddTool(id, _spl); doc->IncrementReferens(spline->GetP1().getIdTool()); doc->IncrementReferens(spline->GetP1().getIdTool()); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp index 92b21142a..3c7e3a24a 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolcubicbezierpath.cpp @@ -42,7 +42,6 @@ VToolCubicBezierPath::VToolCubicBezierPath(VAbstractPattern *doc, VContainer *da this->setPath(ToolPath()); this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); - this->setAcceptHoverEvents(true); ToolCreation(typeCreation); } @@ -109,9 +108,7 @@ VToolCubicBezierPath *VToolCubicBezierPath::Create(const quint32 _id, VCubicBezi { VToolCubicBezierPath *spl = new VToolCubicBezierPath(doc, data, id, color, typeCreation); scene->addItem(spl); - connect(spl, &VToolCubicBezierPath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolCubicBezierPath::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, spl, &VToolCubicBezierPath::Disable); + InitSplinePathToolConnections(scene, spl); doc->AddTool(id, spl); return spl; } diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp index 0d5d5d098..0b73033bb 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolspline.cpp @@ -62,7 +62,6 @@ VToolSpline::VToolSpline(VAbstractPattern *doc, VContainer *data, quint32 id, co this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); this->setFlag(QGraphicsItem::ItemIsMovable, true); - this->setAcceptHoverEvents(true); this->setPath(ToolPath()); const auto spl = VAbstractTool::data.GeometricObject(id); @@ -179,11 +178,7 @@ VToolSpline* VToolSpline::Create(const quint32 _id, VSpline *spline, const QStri { auto _spl = new VToolSpline(doc, data, id, color, typeCreation); scene->addItem(_spl); - connect(_spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - 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); + InitSplineToolConnections(scene, _spl); doc->AddTool(id, _spl); doc->IncrementReferens(spline->GetP1().getIdTool()); doc->IncrementReferens(spline->GetP4().getIdTool()); diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp index a5f7a5307..c6075650e 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vtoolsplinepath.cpp @@ -63,7 +63,6 @@ VToolSplinePath::VToolSplinePath(VAbstractPattern *doc, VContainer *data, quint3 this->setPath(ToolPath()); this->setPen(QPen(Qt::black, qApp->toPixel(WidthHairLine(*VAbstractTool::data.GetPatternUnit()))/factor)); this->setFlag(QGraphicsItem::ItemIsMovable, true); - this->setAcceptHoverEvents(true); const QSharedPointer splPath = data->GeometricObject(id); for (qint32 i = 1; i<=splPath->CountSubSpl(); ++i) @@ -183,11 +182,7 @@ VToolSplinePath* VToolSplinePath::Create(const quint32 _id, VSplinePath *path, c { VToolSplinePath *spl = new VToolSplinePath(doc, data, id, color, typeCreation); scene->addItem(spl); - connect(spl, &VToolSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - 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); + InitSplinePathToolConnections(scene, spl); doc->AddTool(id, spl); return spl; } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp index 70c0c93f3..ee4ec7407 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp @@ -187,6 +187,34 @@ void VToolDoublePoint::DoChangePosition(quint32 id, qreal mx, qreal my) } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolDoublePoint::AllowHover(bool enabled) +{ + firstPoint->setAcceptHoverEvents(enabled); + secondPoint->setAcceptHoverEvents(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolDoublePoint::AllowSelecting(bool enabled) +{ + firstPoint->setFlag(QGraphicsItem::ItemIsSelectable, enabled); + secondPoint->setFlag(QGraphicsItem::ItemIsSelectable, enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolDoublePoint::AllowLabelHover(bool enabled) +{ + firstPoint->AllowLabelHover(enabled); + secondPoint->AllowLabelHover(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolDoublePoint::AllowLabelSelecting(bool enabled) +{ + firstPoint->AllowLabelSelecting(enabled); + secondPoint->AllowLabelSelecting(enabled); +} + //--------------------------------------------------------------------------------------------------------------------- void VToolDoublePoint::UpdateNamePosition(quint32 id) { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h index 88bced16f..a825d50e4 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h @@ -69,6 +69,10 @@ public slots: void Point2Choosed(); virtual void FullUpdateFromFile() Q_DECL_OVERRIDE; virtual void DoChangePosition(quint32 id, qreal mx, qreal my) Q_DECL_OVERRIDE; + virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE; + virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE; + void AllowLabelHover(bool enabled); + void AllowLabelSelecting(bool enabled); protected: VSimplePoint *firstPoint; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp index 9f17876fa..822a7bd8f 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp @@ -172,10 +172,7 @@ VToolTrueDarts *VToolTrueDarts::Create(quint32 _id, VToolTrueDarts *points = new VToolTrueDarts(doc, data, id, p1id, p2id, baseLineP1Id, baseLineP2Id, dartP1Id, dartP2Id, dartP3Id, typeCreation); scene->addItem(points); - connect(points, &VToolDoublePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, points, &VToolTrueDarts::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, points, &VToolTrueDarts::Disable); - connect(scene, &VMainGraphicsScene::EnableToolMove, points, &VToolTrueDarts::EnableToolMove); + InitToolConnections(scene, points); doc->AddTool(id, points); doc->IncrementReferens(baseLineP1->getIdTool()); doc->IncrementReferens(baseLineP2->getIdTool()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.h index b221d232d..6ba9fe2a1 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcut.h @@ -52,7 +52,7 @@ public: public slots: virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE; - void DetailsMode(bool mode); + virtual void DetailsMode(bool mode) Q_DECL_OVERRIDE; virtual void FullUpdateFromFile() Q_DECL_OVERRIDE; protected: /** @brief formula keep formula of length */ diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp index 57bb058ee..f1699afb8 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.cpp @@ -163,10 +163,7 @@ VToolCutArc* VToolCutArc::Create(const quint32 _id, const QString &pointName, QS { VToolCutArc *point = new VToolCutArc(doc, data, id, formula, arcId, arc1id, arc2id, color, typeCreation); scene->addItem(point); - connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCutArc::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCutArc::Disable); - connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCutArc::EnableToolMove); + InitToolConnections(scene, point); doc->AddTool(id, point); doc->AddTool(arc1id, point); doc->AddTool(arc2id, point); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp index f28f9eb47..896076bff 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.cpp @@ -170,11 +170,7 @@ VToolCutSpline* VToolCutSpline::Create(const quint32 _id, const QString &pointNa VToolCutSpline *point = new VToolCutSpline(doc, data, id, formula, splineId, spl1id, spl2id, color, typeCreation); scene->addItem(point); - connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - 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); + InitToolConnections(scene, point); doc->AddTool(id, point); doc->AddTool(spl1id, point); doc->AddTool(spl2id, point); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp index bc9b1ac86..6cbe40add 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.cpp @@ -180,11 +180,7 @@ VToolCutSplinePath* VToolCutSplinePath::Create(const quint32 _id, const QString VToolCutSplinePath *point = new VToolCutSplinePath(doc, data, id, formula, splinePathId, splPath1id, splPath2id, color, typeCreation); scene->addItem(point); - connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - 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); + InitToolConnections(scene, point); doc->AddTool(id, point); doc->AddTool(splPath1id, point); doc->AddTool(splPath2id, point); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp index a98c91ce3..3ae03a962 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolalongline.cpp @@ -275,10 +275,7 @@ VToolAlongLine* VToolAlongLine::Create(const quint32 _id, const QString &pointNa VToolAlongLine *point = new VToolAlongLine(doc, data, id, formula, firstPointId, secondPointId, typeLine, lineColor, typeCreation); scene->addItem(point); - connect(point, &VToolAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolAlongLine::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolAlongLine::Disable); - connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolAlongLine::EnableToolMove); + InitToolConnections(scene, point); doc->AddTool(id, point); doc->IncrementReferens(firstPoint->getIdTool()); doc->IncrementReferens(secondPoint->getIdTool()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp index 28dc1dfc8..c58d3aba0 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolbisector.cpp @@ -200,10 +200,7 @@ VToolBisector* VToolBisector::Create(const quint32 _id, QString &formula, const VToolBisector *point = new VToolBisector(doc, data, id, typeLine, lineColor, formula, firstPointId, secondPointId, thirdPointId, typeCreation); scene->addItem(point); - connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolBisector::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolBisector::Disable); - connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolBisector::EnableToolMove); + InitToolConnections(scene, point); doc->AddTool(id, point); doc->IncrementReferens(firstPoint->getIdTool()); doc->IncrementReferens(secondPoint->getIdTool()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp index ce812b298..d4aa0972b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp @@ -129,10 +129,7 @@ VToolCurveIntersectAxis *VToolCurveIntersectAxis::Create(const quint32 _id, cons VToolCurveIntersectAxis *point = new VToolCurveIntersectAxis(doc, data, id, typeLine, lineColor, formulaAngle, basePointId, curveId, typeCreation); scene->addItem(point); - connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolCurveIntersectAxis::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolCurveIntersectAxis::Disable); - connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolCurveIntersectAxis::EnableToolMove); + InitToolConnections(scene, point); doc->AddTool(id, point); doc->IncrementReferens(basePoint->getIdTool()); doc->IncrementReferens(curve->getIdTool()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp index 478ae02ea..5c37a3bfd 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolendline.cpp @@ -165,10 +165,7 @@ VToolEndLine* VToolEndLine::Create(const quint32 _id, const QString &pointName, VToolEndLine *point = new VToolEndLine(doc, data, id, typeLine, lineColor, formulaLength, formulaAngle, basePointId, typeCreation); scene->addItem(point); - connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolEndLine::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolEndLine::Disable); - connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolEndLine::EnableToolMove); + InitToolConnections(scene, point); doc->AddTool(id, point); doc->IncrementReferens(basePoint->getIdTool()); return point; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp index 19646a1b2..2056dedfc 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolheight.cpp @@ -157,10 +157,7 @@ VToolHeight* VToolHeight::Create(const quint32 _id, const QString &pointName, co VToolHeight *point = new VToolHeight(doc, data, id, typeLine, lineColor, basePointId, p1LineId, p2LineId, typeCreation); scene->addItem(point); - connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolHeight::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolHeight::Disable); - connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolHeight::EnableToolMove); + InitToolConnections(scene, point); doc->AddTool(id, point); doc->IncrementReferens(basePoint->getIdTool()); doc->IncrementReferens(p1Line->getIdTool()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp index 8a93e6404..dd8409b0b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp @@ -140,10 +140,7 @@ VToolLineIntersectAxis *VToolLineIntersectAxis::Create(const quint32 _id, const basePointId, firstPointId, secondPointId, typeCreation); scene->addItem(point); - connect(point, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolLineIntersectAxis::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolLineIntersectAxis::Disable); - connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolLineIntersectAxis::EnableToolMove); + InitToolConnections(scene, point); doc->AddTool(id, point); doc->IncrementReferens(basePoint->getIdTool()); doc->IncrementReferens(firstPoint->getIdTool()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp index 9f1ee7e2f..f73de34fb 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolnormal.cpp @@ -160,10 +160,7 @@ VToolNormal* VToolNormal::Create(const quint32 _id, QString &formula, const quin VToolNormal *point = new VToolNormal(doc, data, id, typeLine, lineColor, formula, angle, firstPointId, secondPointId, typeCreation); scene->addItem(point); - connect(point, &VToolNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolNormal::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolNormal::Disable); - connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolNormal::EnableToolMove); + InitToolConnections(scene, point); doc->AddTool(id, point); doc->IncrementReferens(firstPoint->getIdTool()); doc->IncrementReferens(secondPoint->getIdTool()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp index ea5696638..c0890dff4 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolshoulderpoint.cpp @@ -204,10 +204,7 @@ VToolShoulderPoint* VToolShoulderPoint::Create(const quint32 _id, QString &formu p1Line, p2Line, pShoulder, typeCreation); scene->addItem(point); - connect(point, &VToolShoulderPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolShoulderPoint::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolShoulderPoint::Disable); - connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolShoulderPoint::EnableToolMove); + InitToolConnections(scene, point); doc->AddTool(id, point); doc->IncrementReferens(firstPoint->getIdTool()); doc->IncrementReferens(secondPoint->getIdTool()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp index 7d4fb427b..34ee3980c 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.cpp @@ -79,6 +79,38 @@ void VToolBasePoint::setDialog() dialogTool->SetData(p->name(), p->toQPointF()); } +//--------------------------------------------------------------------------------------------------------------------- +VToolBasePoint *VToolBasePoint::Create(quint32 _id, const QString &nameActivPP, VPointF *point, + VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation) +{ + SCASSERT(point != nullptr); + + quint32 id = _id; + if (typeCreation == Source::FromGui) + { + id = data->AddGObject(point); + } + else + { + data->UpdateGObject(id, point); + if (parse != Document::FullParse) + { + doc->UpdateToolData(id, data); + } + } + VDrawTool::AddRecord(id, Tool::BasePoint, doc); + if (parse == Document::FullParse) + { + VToolBasePoint *spoint = new VToolBasePoint(doc, data, id, typeCreation, nameActivPP); + scene->addItem(spoint); + InitToolConnections(scene, spoint); + doc->AddTool(id, spoint); + return spoint; + } + return nullptr; +} + //--------------------------------------------------------------------------------------------------------------------- void VToolBasePoint::ShowVisualization(bool show) { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h index 5c1707934..e817dc982 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolbasepoint.h @@ -43,6 +43,9 @@ public: const QString &namePP, QGraphicsItem * parent = nullptr ); virtual ~VToolBasePoint() Q_DECL_OVERRIDE; virtual void setDialog() Q_DECL_OVERRIDE; + static VToolBasePoint *Create(quint32 _id, const QString &nameActivPP, VPointF *point, + VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, + const Document &parse, const Source &typeCreation); static const QString ToolType; virtual int type() const Q_DECL_OVERRIDE {return Type;} enum { Type = UserType + static_cast(Tool::BasePoint)}; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp index cee5b97af..4eab669b6 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp @@ -164,10 +164,7 @@ VToolLineIntersect* VToolLineIntersect::Create(const quint32 _id, const quint32 VToolLineIntersect *point = new VToolLineIntersect(doc, data, id, p1Line1Id, p2Line1Id, p1Line2Id, p2Line2Id, typeCreation); scene->addItem(point); - connect(point, &VToolLineIntersect::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolLineIntersect::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolLineIntersect::Disable); - connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolLineIntersect::EnableToolMove); + InitToolConnections(scene, point); doc->AddTool(id, point); doc->IncrementReferens(p1Line1->getIdTool()); doc->IncrementReferens(p2Line1->getIdTool()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp index 6ed292e99..cb118ad07 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromarcandtangent.cpp @@ -108,10 +108,7 @@ VToolPointFromArcAndTangent *VToolPointFromArcAndTangent::Create(const quint32 _ VToolPointFromArcAndTangent *point = new VToolPointFromArcAndTangent(doc, data, id, arcId, tangentPointId, crossPoint, typeCreation); scene->addItem(point); - connect(point, &VToolPointFromArcAndTangent::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointFromArcAndTangent::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointFromArcAndTangent::Disable); - connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointFromArcAndTangent::EnableToolMove); + InitToolConnections(scene, point); doc->AddTool(id, point); doc->IncrementReferens(arc.getIdTool()); doc->IncrementReferens(tPoint.getIdTool()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp index 0cca3b160..bcb21eb6b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointfromcircleandtangent.cpp @@ -118,10 +118,7 @@ VToolPointFromCircleAndTangent *VToolPointFromCircleAndTangent::Create(const qui circleRadius, tangentPointId, crossPoint, typeCreation); scene->addItem(point); - connect(point, &VToolPointFromCircleAndTangent::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointFromCircleAndTangent::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointFromCircleAndTangent::Disable); - connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointFromCircleAndTangent::EnableToolMove); + InitToolConnections(scene, point); doc->AddTool(id, point); doc->IncrementReferens(cPoint.getIdTool()); doc->IncrementReferens(tPoint.getIdTool()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp index bb2607ff0..6d9fd88c8 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofcontact.cpp @@ -220,10 +220,7 @@ VToolPointOfContact* VToolPointOfContact::Create(const quint32 _id, QString &rad VToolPointOfContact *point = new VToolPointOfContact(doc, data, id, radius, center, firstPointId, secondPointId, typeCreation); scene->addItem(point); - connect(point, &VToolPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfContact::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointOfContact::Disable); - connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointOfContact::EnableToolMove); + InitToolConnections(scene, point); doc->AddTool(id, point); doc->IncrementReferens(centerP->getIdTool()); doc->IncrementReferens(firstP->getIdTool()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp index bd97a73f0..46af9a1bd 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersection.cpp @@ -141,10 +141,7 @@ VToolPointOfIntersection *VToolPointOfIntersection::Create(const quint32 _id, co VToolPointOfIntersection *point = new VToolPointOfIntersection(doc, data, id, firstPointId, secondPointId, typeCreation); scene->addItem(point); - connect(point, &VToolPointOfIntersection::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfIntersection::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointOfIntersection::Disable); - connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointOfIntersection::EnableToolMove); + InitToolConnections(scene, point); doc->AddTool(id, point); doc->IncrementReferens(firstPoint->getIdTool()); doc->IncrementReferens(secondPoint->getIdTool()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp index 3520a0ab2..a67f9f450 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectionarcs.cpp @@ -109,10 +109,7 @@ VToolPointOfIntersectionArcs *VToolPointOfIntersectionArcs::Create(const quint32 VToolPointOfIntersectionArcs *point = new VToolPointOfIntersectionArcs(doc, data, id, firstArcId, secondArcId, pType, typeCreation); scene->addItem(point); - connect(point, &VToolPointOfIntersectionArcs::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfIntersectionArcs::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointOfIntersectionArcs::Disable); - connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointOfIntersectionArcs::EnableToolMove); + InitToolConnections(scene, point); doc->AddTool(id, point); doc->IncrementReferens(firstArc->getIdTool()); doc->IncrementReferens(secondArc->getIdTool()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp index d0b1518e6..6bcdde298 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncircles.cpp @@ -130,10 +130,7 @@ VToolPointOfIntersectionCircles *VToolPointOfIntersectionCircles::Create(const q secondCircleRadius, crossPoint, typeCreation); scene->addItem(point); - connect(point, &VToolPointOfIntersectionCircles::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfIntersectionCircles::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointOfIntersectionCircles::Disable); - connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointOfIntersectionCircles::EnableToolMove); + InitToolConnections(scene, point); doc->AddTool(id, point); doc->IncrementReferens(c1Point.getIdTool()); doc->IncrementReferens(c2Point.getIdTool()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp index 3f92442f4..b0d0da647 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolpointofintersectioncurves.cpp @@ -116,10 +116,7 @@ VToolPointOfIntersectionCurves *VToolPointOfIntersectionCurves::Create(const qui auto point = new VToolPointOfIntersectionCurves(doc, data, id, firstCurveId, secondCurveId, vCrossPoint, hCrossPoint, typeCreation); scene->addItem(point); - connect(point, &VToolPointOfIntersectionCurves::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfIntersectionCurves::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolPointOfIntersectionCurves::Disable); - connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolPointOfIntersectionCurves::EnableToolMove); + InitToolConnections(scene, point); doc->AddTool(id, point); doc->IncrementReferens(curve1->getIdTool()); doc->IncrementReferens(curve2->getIdTool()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp index 14ae5228b..59cda043d 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp @@ -131,6 +131,14 @@ void VToolSinglePoint::UpdateNamePosition(quint32 id) qApp->getUndoStack()->push(moveLabel); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSinglePoint::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + // Special for not selectable item first need to call standard mousePressEvent then accept event + QGraphicsEllipseItem::mousePressEvent(event); + event->accept();// Special for not selectable item first need to call standard mousePressEvent then accept event +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief SetFactor set current scale factor of scene. @@ -175,16 +183,16 @@ void VToolSinglePoint::FullUpdateFromFile() //--------------------------------------------------------------------------------------------------------------------- /** - * @brief mousePressEvent handle mouse press events. + * @brief mouseReleaseEvent handle mouse release events. * @param event mouse release event. */ -void VToolSinglePoint::mousePressEvent(QGraphicsSceneMouseEvent *event) +void VToolSinglePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton) { PointChoosed(); } - QGraphicsEllipseItem::mousePressEvent(event); + QGraphicsEllipseItem::mouseReleaseEvent(event); } //--------------------------------------------------------------------------------------------------------------------- @@ -333,3 +341,27 @@ void VToolSinglePoint::DoChangePosition(quint32 id, qreal mx, qreal my) namePoint->blockSignals(false); RefreshLine(id); } + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSinglePoint::AllowHover(bool enabled) +{ + setAcceptHoverEvents(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSinglePoint::AllowSelecting(bool enabled) +{ + setFlag(QGraphicsItem::ItemIsSelectable, enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSinglePoint::AllowLabelHover(bool enabled) +{ + namePoint->setAcceptHoverEvents(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolSinglePoint::AllowLabelSelecting(bool enabled) +{ + namePoint->setFlag(QGraphicsItem::ItemIsSelectable, enabled); +} diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h index 927126917..f6837c9c1 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h @@ -63,6 +63,10 @@ public slots: void PointChoosed(); virtual void FullUpdateFromFile() Q_DECL_OVERRIDE; virtual void DoChangePosition(quint32 id, qreal mx, qreal my) Q_DECL_OVERRIDE; + virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE; + virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE; + void AllowLabelHover(bool enabled); + void AllowLabelSelecting(bool enabled); protected: /** @brief radius radius circle. */ qreal radius; @@ -74,7 +78,8 @@ protected: QGraphicsLineItem *lineName; virtual void UpdateNamePosition(quint32 id) Q_DECL_OVERRIDE; - virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; + virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE; + virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; virtual void RefreshPointGeometry(const VPointF &point); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp index d118082f9..22e745653 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp @@ -151,10 +151,7 @@ VToolTriangle* VToolTriangle::Create(const quint32 _id, const QString &pointName VToolTriangle *point = new VToolTriangle(doc, data, id, axisP1Id, axisP2Id, firstPointId, secondPointId, typeCreation); scene->addItem(point); - connect(point, &VToolTriangle::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolTriangle::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, point, &VToolTriangle::Disable); - connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VToolTriangle::EnableToolMove); + InitToolConnections(scene, point); doc->AddTool(id, point); doc->IncrementReferens(axisP1->getIdTool()); doc->IncrementReferens(axisP2->getIdTool()); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/vabstractpoint.h b/src/libs/vtools/tools/drawTools/toolpoint/vabstractpoint.h index 3348743e3..c6ae7623e 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/vabstractpoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/vabstractpoint.h @@ -63,6 +63,9 @@ protected: template void SetToolEnabled(T *item, bool enabled); + template + static void InitToolConnections(VMainGraphicsScene *scene, T *tool); + private: Q_DISABLE_COPY(VAbstractPoint) }; @@ -118,4 +121,18 @@ void VAbstractPoint::ChangePosition(T *item, quint32 id, const QPointF &pos) UpdateNamePosition(id); } +//--------------------------------------------------------------------------------------------------------------------- +template +void VAbstractPoint::InitToolConnections(VMainGraphicsScene *scene, T *tool) +{ + SCASSERT(scene != nullptr); + SCASSERT(tool != nullptr); + + InitDrawToolConnections(scene, tool); + QObject::connect(scene, &VMainGraphicsScene::EnablePointItemHover, tool, &T::AllowHover); + QObject::connect(scene, &VMainGraphicsScene::EnablePointItemSelection, tool, &T::AllowSelecting); + QObject::connect(scene, &VMainGraphicsScene::EnableLabelItemHover, tool, &T::AllowLabelHover); + QObject::connect(scene, &VMainGraphicsScene::EnableLabelItemSelection, tool, &T::AllowLabelSelecting); +} + #endif // VABSTRACTPOINT_H diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.cpp b/src/libs/vtools/tools/drawTools/vdrawtool.cpp index 20f635459..96dec91e1 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.cpp +++ b/src/libs/vtools/tools/drawTools/vdrawtool.cpp @@ -265,6 +265,13 @@ void VDrawTool::EnableToolMove(bool move) // Do nothing. } +//--------------------------------------------------------------------------------------------------------------------- +void VDrawTool::DetailsMode(bool mode) +{ + Q_UNUSED(mode) + // Do nothing. +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief CheckFormula check formula. diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.h b/src/libs/vtools/tools/drawTools/vdrawtool.h index e9fba51a9..6c691b050 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.h +++ b/src/libs/vtools/tools/drawTools/vdrawtool.h @@ -70,6 +70,7 @@ public slots: virtual void SetFactor(qreal factor); virtual void EnableToolMove(bool move); virtual void Disable(bool disable, const QString &namePP)=0; + virtual void DetailsMode(bool mode); protected: enum class RemoveOption : bool {Disable = false, Enable = true}; @@ -115,6 +116,9 @@ protected: template QString ObjectName(quint32 id) const; + + template + static void InitDrawToolConnections(VMainGraphicsScene *scene, T *tool); private: Q_DISABLE_COPY(VDrawTool) }; @@ -226,4 +230,18 @@ QString VDrawTool::ObjectName(quint32 id) const } } +//--------------------------------------------------------------------------------------------------------------------- +template +void VDrawTool::InitDrawToolConnections(VMainGraphicsScene *scene, T *tool) +{ + SCASSERT(scene != nullptr); + SCASSERT(tool != nullptr); + + QObject::connect(tool, &T::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + QObject::connect(scene, &VMainGraphicsScene::NewFactor, tool, &T::SetFactor); + QObject::connect(scene, &VMainGraphicsScene::DisableItem, tool, &T::Disable); + QObject::connect(scene, &VMainGraphicsScene::EnableToolMove, tool, &T::EnableToolMove); + QObject::connect(scene, &VMainGraphicsScene::CurveDetailsMode, tool, &T::DetailsMode); +} + #endif // VDRAWTOOL_H diff --git a/src/libs/vtools/tools/drawTools/vtoolline.cpp b/src/libs/vtools/tools/drawTools/vtoolline.cpp index c10c88305..07225e1d4 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.cpp +++ b/src/libs/vtools/tools/drawTools/vtoolline.cpp @@ -152,6 +152,7 @@ VToolLine * VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, con connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(scene, &VMainGraphicsScene::NewFactor, line, &VToolLine::SetFactor); connect(scene, &VMainGraphicsScene::DisableItem, line, &VToolLine::Disable); + connect(scene, &VMainGraphicsScene::EnableLineItemHover, line, &VToolLine::AllowHover); doc->AddTool(id, line); const QSharedPointer first = data->GeometricObject(firstPoint); @@ -226,6 +227,18 @@ void VToolLine::Disable(bool disable, const QString &namePP) LineStyleToPenStyle(typeLine))); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolLine::AllowHover(bool enabled) +{ + setAcceptHoverEvents(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolLine::AllowSelecting(bool enabled) +{ + setFlag(QGraphicsItem::ItemIsSelectable, enabled); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief contextMenuEvent handle context menu events. diff --git a/src/libs/vtools/tools/drawTools/vtoolline.h b/src/libs/vtools/tools/drawTools/vtoolline.h index 474d0f83b..db03b01a8 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.h +++ b/src/libs/vtools/tools/drawTools/vtoolline.h @@ -69,6 +69,8 @@ public slots: virtual void ShowTool(quint32 id, bool enable) Q_DECL_OVERRIDE; virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE; virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE; + virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE; + virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE; protected: virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) Q_DECL_OVERRIDE; virtual void AddToFile() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/nodeDetails/vnodearc.cpp b/src/libs/vtools/tools/nodeDetails/vnodearc.cpp index b9863c4ea..d252c5a24 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodearc.cpp +++ b/src/libs/vtools/tools/nodeDetails/vnodearc.cpp @@ -99,6 +99,20 @@ QString VNodeArc::getTagName() const return VNodeArc::TagName; } +//--------------------------------------------------------------------------------------------------------------------- +void VNodeArc::AllowHover(bool enabled) +{ + Q_UNUSED(enabled) + // do nothing +} + +//--------------------------------------------------------------------------------------------------------------------- +void VNodeArc::AllowSelecting(bool enabled) +{ + Q_UNUSED(enabled) + // do nothing +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief AddToFile add tag with informations about tool into file. diff --git a/src/libs/vtools/tools/nodeDetails/vnodearc.h b/src/libs/vtools/tools/nodeDetails/vnodearc.h index cb416aaea..55d064e3f 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodearc.h +++ b/src/libs/vtools/tools/nodeDetails/vnodearc.h @@ -49,6 +49,8 @@ public: virtual QString getTagName() const Q_DECL_OVERRIDE; public slots: virtual void FullUpdateFromFile() Q_DECL_OVERRIDE {} + virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE; + virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE; protected: virtual void AddToFile() Q_DECL_OVERRIDE; virtual void RefreshDataInFile() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp b/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp index 3b4cb520a..ba8215936 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp +++ b/src/libs/vtools/tools/nodeDetails/vnodepoint.cpp @@ -91,6 +91,10 @@ void VNodePoint::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsSc VNodePoint *point = new VNodePoint(doc, data, id, idPoint, typeCreation, idTool, doc); connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VNodePoint::EnableToolMove); + connect(scene, &VMainGraphicsScene::EnablePointItemHover, point, &VNodePoint::AllowHover); + connect(scene, &VMainGraphicsScene::EnablePointItemSelection, point, &VNodePoint::AllowSelecting); + connect(scene, &VMainGraphicsScene::EnableLabelItemHover, point, &VNodePoint::AllowLabelHover); + connect(scene, &VMainGraphicsScene::EnableLabelItemSelection, point, &VNodePoint::AllowLabelSelecting); doc->AddTool(id, point); if (idTool != NULL_ID) { @@ -227,6 +231,14 @@ void VNodePoint::RefreshDataInFile() } } +//--------------------------------------------------------------------------------------------------------------------- +void VNodePoint::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + // Special for not selectable item first need to call standard mousePressEvent then accept event + QGraphicsEllipseItem::mousePressEvent(event); + event->accept();// Special for not selectable item first need to call standard mousePressEvent then accept event +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief mouseReleaseEvent handle mouse release events. @@ -238,7 +250,7 @@ void VNodePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { emit ChoosedTool(id, SceneObject::Point); } - QGraphicsItem::mouseReleaseEvent(event); + QGraphicsEllipseItem::mouseReleaseEvent(event); } //--------------------------------------------------------------------------------------------------------------------- @@ -345,3 +357,27 @@ void VNodePoint::EnableToolMove(bool move) { namePoint->setFlag(QGraphicsItem::ItemIsMovable, move); } + +//--------------------------------------------------------------------------------------------------------------------- +void VNodePoint::AllowHover(bool enabled) +{ + setAcceptHoverEvents(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VNodePoint::AllowSelecting(bool enabled) +{ + setFlag(QGraphicsItem::ItemIsSelectable, enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VNodePoint::AllowLabelHover(bool enabled) +{ + namePoint->setAcceptHoverEvents(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VNodePoint::AllowLabelSelecting(bool enabled) +{ + namePoint->setFlag(QGraphicsItem::ItemIsSelectable, enabled); +} diff --git a/src/libs/vtools/tools/nodeDetails/vnodepoint.h b/src/libs/vtools/tools/nodeDetails/vnodepoint.h index 87a280b44..246b249f2 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodepoint.h +++ b/src/libs/vtools/tools/nodeDetails/vnodepoint.h @@ -64,6 +64,10 @@ public slots: void NameChangePosition(const QPointF &pos); void PointChoosed(); void EnableToolMove(bool move); + virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE; + virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE; + void AllowLabelHover(bool enabled); + void AllowLabelSelecting(bool enabled); protected: /** @brief radius radius circle. */ qreal radius; @@ -76,6 +80,7 @@ protected: virtual void AddToFile() Q_DECL_OVERRIDE; virtual void RefreshDataInFile() Q_DECL_OVERRIDE; + virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE; virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/nodeDetails/vnodespline.cpp b/src/libs/vtools/tools/nodeDetails/vnodespline.cpp index 65110fc3a..393c63cfd 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodespline.cpp +++ b/src/libs/vtools/tools/nodeDetails/vnodespline.cpp @@ -102,6 +102,20 @@ QString VNodeSpline::getTagName() const return VNodeSpline::TagName; } +//--------------------------------------------------------------------------------------------------------------------- +void VNodeSpline::AllowHover(bool enabled) +{ + Q_UNUSED(enabled) + // do nothing +} + +//--------------------------------------------------------------------------------------------------------------------- +void VNodeSpline::AllowSelecting(bool enabled) +{ + Q_UNUSED(enabled) + // do nothing +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief AddToFile add tag with informations about tool into file. diff --git a/src/libs/vtools/tools/nodeDetails/vnodespline.h b/src/libs/vtools/tools/nodeDetails/vnodespline.h index 0bfdd123d..2339cffec 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodespline.h +++ b/src/libs/vtools/tools/nodeDetails/vnodespline.h @@ -50,6 +50,8 @@ public: virtual QString getTagName() const Q_DECL_OVERRIDE; public slots: virtual void FullUpdateFromFile () Q_DECL_OVERRIDE {} + virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE; + virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE; protected: virtual void AddToFile () Q_DECL_OVERRIDE; virtual void RefreshDataInFile() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/nodeDetails/vnodesplinepath.cpp b/src/libs/vtools/tools/nodeDetails/vnodesplinepath.cpp index 7bde3bcd3..32ffdda54 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodesplinepath.cpp +++ b/src/libs/vtools/tools/nodeDetails/vnodesplinepath.cpp @@ -100,6 +100,20 @@ QString VNodeSplinePath::getTagName() const return VNodeSplinePath::TagName; } +//--------------------------------------------------------------------------------------------------------------------- +void VNodeSplinePath::AllowHover(bool enabled) +{ + Q_UNUSED(enabled) + // do nothing +} + +//--------------------------------------------------------------------------------------------------------------------- +void VNodeSplinePath::AllowSelecting(bool enabled) +{ + Q_UNUSED(enabled) + // do nothing +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief AddToFile add tag with informations about tool into file. diff --git a/src/libs/vtools/tools/nodeDetails/vnodesplinepath.h b/src/libs/vtools/tools/nodeDetails/vnodesplinepath.h index 3fefc0fb9..35e188f48 100644 --- a/src/libs/vtools/tools/nodeDetails/vnodesplinepath.h +++ b/src/libs/vtools/tools/nodeDetails/vnodesplinepath.h @@ -49,6 +49,8 @@ public: virtual QString getTagName() const Q_DECL_OVERRIDE; public slots: virtual void FullUpdateFromFile() Q_DECL_OVERRIDE {} + virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE; + virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE; protected: virtual void AddToFile() Q_DECL_OVERRIDE; virtual void RefreshDataInFile() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/vabstracttool.h b/src/libs/vtools/tools/vabstracttool.h index 19be562c6..fac9e89fa 100644 --- a/src/libs/vtools/tools/vabstracttool.h +++ b/src/libs/vtools/tools/vabstracttool.h @@ -77,6 +77,8 @@ public slots: * @brief FullUpdateFromFile update tool data form file. */ virtual void FullUpdateFromFile()=0; + virtual void AllowHover(bool enabled)=0; + virtual void AllowSelecting(bool enabled)=0; signals: /** * @brief toolhaveChange emit if tool create change that need save. diff --git a/src/libs/vtools/tools/vtooldetail.cpp b/src/libs/vtools/tools/vtooldetail.cpp index cb3a37709..d876c9fef 100644 --- a/src/libs/vtools/tools/vtooldetail.cpp +++ b/src/libs/vtools/tools/vtooldetail.cpp @@ -253,6 +253,8 @@ void VToolDetail::Create(const quint32 &_id, const VDetail &newDetail, VMainGrap VToolDetail *detail = new VToolDetail(doc, data, id, typeCreation, scene, drawName); scene->addItem(detail); connect(detail, &VToolDetail::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + connect(scene, &VMainGraphicsScene::EnableDetailItemHover, detail, &VToolDetail::AllowHover); + connect(scene, &VMainGraphicsScene::EnableDetailItemSelection, detail, &VToolDetail::AllowSelecting); doc->AddTool(id, detail); } } @@ -458,6 +460,8 @@ void VToolDetail::keyReleaseEvent(QKeyEvent *event) //--------------------------------------------------------------------------------------------------------------------- void VToolDetail::mousePressEvent(QGraphicsSceneMouseEvent *event) { + // Special for not selectable item first need to call standard mousePressEvent then accept event + VNoBrushScalePathItem::mousePressEvent(event); if (flags() & QGraphicsItem::ItemIsMovable) { if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) @@ -471,7 +475,7 @@ void VToolDetail::mousePressEvent(QGraphicsSceneMouseEvent *event) emit ChoosedTool(id, SceneObject::Detail); } - VNoBrushScalePathItem::mousePressEvent(event); + event->accept();// Special for not selectable item first need to call standard mousePressEvent then accept event } //--------------------------------------------------------------------------------------------------------------------- @@ -689,5 +693,17 @@ void VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node) //--------------------------------------------------------------------------------------------------------------------- void VToolDetail::EnableToolMove(bool move) { - this->setFlag(QGraphicsItem::ItemIsMovable, move); + setFlag(QGraphicsItem::ItemIsMovable, move); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolDetail::AllowHover(bool enabled) +{ + setAcceptHoverEvents(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolDetail::AllowSelecting(bool enabled) +{ + setFlag(QGraphicsItem::ItemIsSelectable, enabled); } diff --git a/src/libs/vtools/tools/vtooldetail.h b/src/libs/vtools/tools/vtooldetail.h index 8190fb97e..322b5fee9 100644 --- a/src/libs/vtools/tools/vtooldetail.h +++ b/src/libs/vtools/tools/vtooldetail.h @@ -90,6 +90,8 @@ public slots: virtual void FullUpdateFromFile () Q_DECL_OVERRIDE; virtual void FullUpdateFromGuiOk(int result); void EnableToolMove(bool move); + virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE; + virtual void AllowSelecting(bool enabled) Q_DECL_OVERRIDE; protected: virtual void AddToFile () Q_DECL_OVERRIDE; virtual void RefreshDataInFile() Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/vtooluniondetails.h b/src/libs/vtools/tools/vtooluniondetails.h index 5a4d20edd..058d4ee79 100644 --- a/src/libs/vtools/tools/vtooluniondetails.h +++ b/src/libs/vtools/tools/vtooluniondetails.h @@ -89,6 +89,8 @@ public slots: * @brief FullUpdateFromFile update tool data form file. */ virtual void FullUpdateFromFile () Q_DECL_OVERRIDE {} + virtual void AllowHover(bool) Q_DECL_OVERRIDE {} + virtual void AllowSelecting(bool) Q_DECL_OVERRIDE {} protected: virtual void AddToFile() Q_DECL_OVERRIDE; virtual void RefreshDataInFile() Q_DECL_OVERRIDE; diff --git a/src/libs/vwidgets/vgraphicssimpletextitem.cpp b/src/libs/vwidgets/vgraphicssimpletextitem.cpp index 16ef6bc6e..2067ffc3c 100644 --- a/src/libs/vwidgets/vgraphicssimpletextitem.cpp +++ b/src/libs/vwidgets/vgraphicssimpletextitem.cpp @@ -158,10 +158,9 @@ void VGraphicsSimpleTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { if (flags() & QGraphicsItem::ItemIsMovable) { - this->setBrush(Qt::green); - SetOverrideCursor(cursorArrowOpenHand, 1, 1); } + this->setBrush(Qt::green); QGraphicsSimpleTextItem::hoverEnterEvent(event); } @@ -175,11 +174,10 @@ void VGraphicsSimpleTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_UNUSED(event); if (flags() & QGraphicsItem::ItemIsMovable) { - this->setBrush(Qt::black); - //Disable cursor-arrow-openhand RestoreOverrideCursor(cursorArrowOpenHand); } + this->setBrush(Qt::black); QGraphicsSimpleTextItem::hoverLeaveEvent(event); } @@ -196,6 +194,8 @@ void VGraphicsSimpleTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *e //--------------------------------------------------------------------------------------------------------------------- void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event) { + // Special for not selectable item first need to call standard mousePressEvent then accept event + QGraphicsSimpleTextItem::mousePressEvent(event); if (flags() & QGraphicsItem::ItemIsMovable) { if (event->button() == Qt::LeftButton && event->type() != QEvent::GraphicsSceneMouseDoubleClick) @@ -203,10 +203,7 @@ void VGraphicsSimpleTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event) SetOverrideCursor(cursorArrowCloseHand, 1, 1); } } - - emit PointChoosed(); - - QGraphicsSimpleTextItem::mousePressEvent(event); + event->accept(); // This help for not selectable items still receive mouseReleaseEvent events } //--------------------------------------------------------------------------------------------------------------------- @@ -221,6 +218,8 @@ void VGraphicsSimpleTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) } } + emit PointChoosed(); + QGraphicsSimpleTextItem::mouseReleaseEvent(event); } diff --git a/src/libs/vwidgets/vmaingraphicsscene.cpp b/src/libs/vwidgets/vmaingraphicsscene.cpp index 30e93f5ad..976a41fc4 100644 --- a/src/libs/vwidgets/vmaingraphicsscene.cpp +++ b/src/libs/vwidgets/vmaingraphicsscene.cpp @@ -280,3 +280,105 @@ void VMainGraphicsScene::EnableDetailsMode(bool mode) { emit CurveDetailsMode(mode); } + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::ToggleLabelSelection(bool enabled) +{ + emit EnableLabelItemSelection(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::TogglePointSelection(bool enabled) +{ + emit EnablePointItemSelection(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::ToggleArcSelection(bool enabled) +{ + emit EnableArcItemSelection(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::ToggleSplineSelection(bool enabled) +{ + emit EnableSplineItemSelection(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::ToggleSplinePathSelection(bool enabled) +{ + emit EnableSplinePathItemSelection(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::ToggleNodeLabelSelection(bool enabled) +{ + emit EnableNodeLabelItemSelection(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::ToggleNodePointSelection(bool enabled) +{ + emit EnableNodePointItemSelection(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::ToggleDetailSelection(bool enabled) +{ + emit EnableDetailItemSelection(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::ToggleLabelHover(bool enabled) +{ + emit EnableLabelItemHover(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::TogglePointHover(bool enabled) +{ + emit EnablePointItemHover(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::ToggleLineHover(bool enabled) +{ + emit EnableLineItemHover(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::ToggleArcHover(bool enabled) +{ + emit EnableArcItemHover(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::ToggleSplineHover(bool enabled) +{ + emit EnableSplineItemHover(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::ToggleSplinePathHover(bool enabled) +{ + emit EnableSplinePathItemHover(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::ToggleNodeLabelHover(bool enabled) +{ + emit EnableNodeLabelItemHover(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::ToggleNodePointHover(bool enabled) +{ + emit EnableNodePointItemHover(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::ToggleDetailHover(bool enabled) +{ + emit EnableDetailItemHover(enabled); +} diff --git a/src/libs/vwidgets/vmaingraphicsscene.h b/src/libs/vwidgets/vmaingraphicsscene.h index 20526b9d2..84fced90b 100644 --- a/src/libs/vwidgets/vmaingraphicsscene.h +++ b/src/libs/vwidgets/vmaingraphicsscene.h @@ -58,6 +58,25 @@ public slots: void SetFactor(qreal factor); void EnableItemMove(bool move); void EnableDetailsMode(bool mode); + + void ToggleLabelSelection(bool enabled); + void TogglePointSelection(bool enabled); + void ToggleArcSelection(bool enabled); + void ToggleSplineSelection(bool enabled); + void ToggleSplinePathSelection(bool enabled); + void ToggleNodeLabelSelection(bool enabled); + void ToggleNodePointSelection(bool enabled); + void ToggleDetailSelection(bool enabled); + + void ToggleLabelHover(bool enabled); + void TogglePointHover(bool enabled); + void ToggleLineHover(bool enabled); + void ToggleArcHover(bool enabled); + void ToggleSplineHover(bool enabled); + void ToggleSplinePathHover(bool enabled); + void ToggleNodeLabelHover(bool enabled); + void ToggleNodePointHover(bool enabled); + void ToggleDetailHover(bool enabled); protected: virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE; virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE; @@ -86,6 +105,25 @@ signals: void DisableItem(bool disable, const QString &namePP); void EnableToolMove(bool move); void CurveDetailsMode(bool mode); + + void EnableLabelItemSelection(bool enable); + void EnablePointItemSelection(bool enable); + void EnableArcItemSelection(bool enable); + void EnableSplineItemSelection(bool enable); + void EnableSplinePathItemSelection(bool enable); + void EnableNodeLabelItemSelection(bool enabled); + void EnableNodePointItemSelection(bool enabled); + void EnableDetailItemSelection(bool enabled); + + void EnableLabelItemHover(bool enable); + void EnablePointItemHover(bool enable); + void EnableArcItemHover(bool enable); + void EnableSplineItemHover(bool enable); + void EnableSplinePathItemHover(bool enable); + void EnableNodeLabelItemHover(bool enabled); + void EnableNodePointItemHover(bool enabled); + void EnableDetailItemHover(bool enabled); + void EnableLineItemHover(bool enabled); private: /** @brief horScrollBar value horizontal scroll bar. */ qint32 horScrollBar; diff --git a/src/libs/vwidgets/vmaingraphicsview.cpp b/src/libs/vwidgets/vmaingraphicsview.cpp index 10a61f9fa..be0898116 100644 --- a/src/libs/vwidgets/vmaingraphicsview.cpp +++ b/src/libs/vwidgets/vmaingraphicsview.cpp @@ -321,7 +321,7 @@ bool GraphicsViewZoom::StartHorizontalScrollings(QWheelEvent *wheel_event) * @param parent parent object. */ VMainGraphicsView::VMainGraphicsView(QWidget *parent) - :QGraphicsView(parent), zoom(nullptr), showToolOptions(true) + :QGraphicsView(parent), zoom(nullptr), showToolOptions(true), isAllowRubberBand(true) { zoom = new GraphicsViewZoom(this); this->setResizeAnchor(QGraphicsView::AnchorUnderMouse); @@ -386,7 +386,10 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress) { case Qt::LeftButton: { - QGraphicsView::setDragMode(QGraphicsView::RubberBandDrag); + if (isAllowRubberBand) + { + QGraphicsView::setDragMode(QGraphicsView::RubberBandDrag); + } if (showToolOptions) { QList list = items(mousePress->pos()); @@ -436,7 +439,7 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress) */ void VMainGraphicsView::mouseReleaseEvent(QMouseEvent *event) { - QGraphicsView::mouseReleaseEvent ( event ); + QGraphicsView::mouseReleaseEvent ( event ); // First because need to hide a rubber band QGraphicsView::setDragMode( QGraphicsView::NoDrag ); if (event->button() == Qt::LeftButton) { @@ -450,6 +453,12 @@ void VMainGraphicsView::setShowToolOptions(bool value) showToolOptions = value; } +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsView::AllowRubberBand(bool value) +{ + isAllowRubberBand = value; +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief NewSceneRect calculate scene rect what contains all items and doesn't less that size of scene view. diff --git a/src/libs/vwidgets/vmaingraphicsview.h b/src/libs/vwidgets/vmaingraphicsview.h index ea2677432..3ce6f5603 100644 --- a/src/libs/vwidgets/vmaingraphicsview.h +++ b/src/libs/vwidgets/vmaingraphicsview.h @@ -109,6 +109,7 @@ public: explicit VMainGraphicsView(QWidget *parent = nullptr); void setShowToolOptions(bool value); + void AllowRubberBand(bool value); static void NewSceneRect(QGraphicsScene *sc, QGraphicsView *view); static QRectF SceneVisibleArea(QGraphicsView *view); @@ -138,6 +139,7 @@ private: Q_DISABLE_COPY(VMainGraphicsView) GraphicsViewZoom* zoom; bool showToolOptions; + bool isAllowRubberBand; }; #endif // VMAINGRAPHICSVIEW_H diff --git a/src/libs/vwidgets/vsimplepoint.cpp b/src/libs/vwidgets/vsimplepoint.cpp index 1db213ff9..db420b856 100644 --- a/src/libs/vwidgets/vsimplepoint.cpp +++ b/src/libs/vwidgets/vsimplepoint.cpp @@ -146,6 +146,18 @@ void VSimplePoint::EnableToolMove(bool move) namePoint->setFlag(QGraphicsItem::ItemIsMovable, move); } +//--------------------------------------------------------------------------------------------------------------------- +void VSimplePoint::AllowLabelHover(bool enabled) +{ + namePoint->setAcceptHoverEvents(enabled); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VSimplePoint::AllowLabelSelecting(bool enabled) +{ + namePoint->setFlag(QGraphicsItem::ItemIsSelectable, enabled); +} + //--------------------------------------------------------------------------------------------------------------------- void VSimplePoint::DeleteFromLabel() { @@ -172,12 +184,20 @@ void VSimplePoint::ContextMenu(QGraphicsSceneContextMenuEvent *event) //--------------------------------------------------------------------------------------------------------------------- void VSimplePoint::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + // Special for not selectable item first need to call standard mousePressEvent then accept event + QGraphicsEllipseItem::mousePressEvent(event); + event->accept();// Special for not selectable item first need to call standard mousePressEvent then accept event +} + +//--------------------------------------------------------------------------------------------------------------------- +void VSimplePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton) { emit Choosed(id); } - QGraphicsEllipseItem::mousePressEvent(event); + QGraphicsEllipseItem::mouseReleaseEvent(event); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vwidgets/vsimplepoint.h b/src/libs/vwidgets/vsimplepoint.h index ffb45f869..53f79df81 100644 --- a/src/libs/vwidgets/vsimplepoint.h +++ b/src/libs/vwidgets/vsimplepoint.h @@ -55,6 +55,8 @@ public: void RefreshGeometry(const VPointF &point); void SetEnabled(bool enabled); void EnableToolMove(bool move); + void AllowLabelHover(bool enabled); + void AllowLabelSelecting(bool enabled); QColor GetCurrentColor() const; void SetCurrentColor(const QColor &value); @@ -75,7 +77,8 @@ public slots: void ContextMenu(QGraphicsSceneContextMenuEvent * event); protected: - virtual void mousePressEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; + virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; + virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE;