From bf847bac7bd19b90ba4e155f3b8e9371e9fc0694 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 8 Nov 2016 14:04:23 +0200 Subject: [PATCH] Dialog Detail need pointer to scene Details. --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 174 ++++++++++++++++++------------- src/app/valentina/mainwindow.h | 14 ++- 2 files changed, 112 insertions(+), 76 deletions(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index d8f4ac82c..8c6eae650 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -636,7 +636,7 @@ void MainWindow::ClosedDialog(int result) * @param result result working dialog. */ template -void MainWindow::ClosedDialogWithApply(int result) +void MainWindow::ClosedDialogWithApply(int result, VMainGraphicsScene *scene) { SCASSERT(not dialogTool.isNull()); if (result == QDialog::Accepted) @@ -644,7 +644,6 @@ void MainWindow::ClosedDialogWithApply(int result) // Only create tool if not already created with apply if (dialogTool->GetAssociatedTool() == nullptr) { - VMainGraphicsScene *scene = qobject_cast(currentScene); SCASSERT(scene != nullptr); dialogTool->SetAssociatedTool( @@ -682,14 +681,13 @@ void MainWindow::ClosedDialogWithApply(int result) * @brief ApplyDialog handle apply in dialog */ template -void MainWindow::ApplyDialog() +void MainWindow::ApplyDialog(VMainGraphicsScene *scene) { SCASSERT(not dialogTool.isNull()); // Only create tool if not already created with apply if (dialogTool->GetAssociatedTool() == nullptr) { - VMainGraphicsScene *scene = qobject_cast(currentScene); SCASSERT(scene != nullptr); dialogTool->SetAssociatedTool( @@ -703,6 +701,34 @@ void MainWindow::ApplyDialog() } } +//--------------------------------------------------------------------------------------------------------------------- +template +void MainWindow::ClosedDrawDialogWithApply(int result) +{ + ClosedDialogWithApply(result, sceneDraw); +} + +//--------------------------------------------------------------------------------------------------------------------- +template +void MainWindow::ApplyDrawDialog() +{ + ApplyDialog(sceneDraw); +} + +//--------------------------------------------------------------------------------------------------------------------- +template +void MainWindow::ClosedDetailsDialogWithApply(int result) +{ + ClosedDialogWithApply(result, sceneDetails); +} + +//--------------------------------------------------------------------------------------------------------------------- +template +void MainWindow::ApplyDetailsDialog() +{ + ApplyDialog(sceneDetails); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ToolEndLine handler tool endLine. @@ -712,8 +738,8 @@ void MainWindow::ToolEndLine(bool checked) { ToolSelectPointByRelease(); SetToolButtonWithApply(checked, Tool::EndLine, ":/cursor/endline_cursor.png", tr("Select point"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -725,8 +751,8 @@ void MainWindow::ToolLine(bool checked) { ToolSelectPointByRelease(); SetToolButtonWithApply(checked, Tool::Line, ":/cursor/line_cursor.png", tr("Select first point"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -738,8 +764,8 @@ void MainWindow::ToolAlongLine(bool checked) { ToolSelectPointByRelease(); SetToolButtonWithApply(checked, Tool::AlongLine, ":/cursor/alongline_cursor.png", - tr("Select point"), &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + tr("Select point"), &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -748,8 +774,8 @@ void MainWindow::ToolMidpoint(bool checked) ToolSelectPointByRelease(); // Reuse DialogAlongLine and VToolAlongLine but with different cursor SetToolButtonWithApply(checked, Tool::Midpoint, ":/cursor/midpoint_cursor.png", - tr("Select point"), &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + tr("Select point"), &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -762,8 +788,8 @@ void MainWindow::ToolShoulderPoint(bool checked) ToolSelectPointByRelease(); SetToolButtonWithApply(checked, Tool::ShoulderPoint, ":/cursor/shoulder_cursor.png", tr("Select point"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -776,8 +802,8 @@ void MainWindow::ToolNormal(bool checked) ToolSelectPointByRelease(); SetToolButtonWithApply(checked, Tool::Normal, ":/cursor/normal_cursor.png", tr("Select first point of line"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -790,8 +816,8 @@ void MainWindow::ToolBisector(bool checked) ToolSelectPointByRelease(); SetToolButtonWithApply(checked, Tool::Bisector, ":/cursor/bisector_cursor.png", tr("Select first point of angle"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -804,8 +830,8 @@ void MainWindow::ToolLineIntersect(bool checked) ToolSelectPointByRelease(); SetToolButtonWithApply(checked, Tool::LineIntersect, ":/cursor/intersect_cursor.png", tr("Select first point of first line"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -818,8 +844,8 @@ void MainWindow::ToolSpline(bool checked) ToolSelectPointByPress(); SetToolButtonWithApply(checked, Tool::Spline, ":/cursor/spline_cursor.png", tr("Select first point curve"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -828,8 +854,8 @@ void MainWindow::ToolCubicBezier(bool checked) ToolSelectPointByRelease(); SetToolButtonWithApply(checked, Tool::CubicBezier, ":/cursor/cubic_bezier_cursor.png", tr("Select first curve point"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -842,8 +868,8 @@ void MainWindow::ToolCutSpline(bool checked) ToolSelectSpline(); SetToolButtonWithApply(checked, Tool::CutSpline, ":/cursor/spline_cut_point_cursor.png", tr("Select simple curve"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -855,8 +881,8 @@ void MainWindow::ToolArc(bool checked) { ToolSelectPointByRelease(); SetToolButtonWithApply(checked, Tool::Arc, ":/cursor/arc_cursor.png", - tr("Select point of center of arc"), &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + tr("Select point of center of arc"), &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -869,8 +895,8 @@ void MainWindow::ToolSplinePath(bool checked) ToolSelectPointByPress(); SetToolButtonWithApply(checked, Tool::SplinePath, ":/cursor/splinepath_cursor.png", tr("Select point of curve path"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -880,8 +906,8 @@ void MainWindow::ToolCubicBezierPath(bool checked) SetToolButtonWithApply(checked, Tool::CubicBezierPath, ":/cursor/cubic_bezier_path_cursor.png", tr("Select point of cubic bezier path"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -894,8 +920,8 @@ void MainWindow::ToolCutSplinePath(bool checked) ToolSelectSplinePath(); SetToolButtonWithApply(checked, Tool::CutSplinePath, ":/cursor/splinepath_cut_point_cursor.png", tr("Select curve path"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -908,8 +934,8 @@ void MainWindow::ToolPointOfContact(bool checked) ToolSelectPointByRelease(); SetToolButtonWithApply(checked, Tool::PointOfContact, ":/cursor/pointcontact_cursor.png", tr("Select first point of line"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -922,8 +948,8 @@ void MainWindow::ToolDetail(bool checked) ToolSelectAllDrawObjects(); SetToolButtonWithApply(checked, Tool::Piece, "://cursor/new_detail_cursor.png", tr("Select main path objects clockwise."), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDetailsDialogWithApply, + &MainWindow::ApplyDetailsDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -950,8 +976,8 @@ void MainWindow::ToolHeight(bool checked) { ToolSelectPointByRelease(); SetToolButtonWithApply(checked, Tool::Height, ":/cursor/height_cursor.png", tr("Select base point"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -964,8 +990,8 @@ void MainWindow::ToolTriangle(bool checked) ToolSelectPointByRelease(); SetToolButtonWithApply(checked, Tool::Triangle, ":/cursor/triangle_cursor.png", tr("Select first point of axis"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -979,8 +1005,8 @@ void MainWindow::ToolPointOfIntersection(bool checked) SetToolButtonWithApply(checked, Tool::PointOfIntersection, ":/cursor/pointofintersect_cursor.png", tr("Select point for X value (vertical)"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1022,8 +1048,8 @@ void MainWindow::ToolRotation(bool checked) SetToolButtonWithApply(checked, Tool::Rotation, ":/cursor/rotation_cursor.png", tr("Select one or more objects, Enter - confirm selection"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1033,8 +1059,8 @@ void MainWindow::ToolFlippingByLine(bool checked) SetToolButtonWithApply(checked, Tool::FlippingByLine, ":/cursor/flipping_line_cursor.png", tr("Select one or more objects, Enter - confirm selection"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1044,8 +1070,8 @@ void MainWindow::ToolFlippingByAxis(bool checked) SetToolButtonWithApply(checked, Tool::FlippingByAxis, ":/cursor/flipping_axis_cursor.png", tr("Select one or more objects, Enter - confirm selection"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1055,8 +1081,8 @@ void MainWindow::ToolMove(bool checked) SetToolButtonWithApply(checked, Tool::Move, ":/cursor/move_cursor.png", tr("Select one or more objects, Enter - confirm selection"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1087,8 +1113,8 @@ void MainWindow::ToolCutArc(bool checked) { ToolSelectArc(); SetToolButtonWithApply(checked, Tool::CutArc, ":/cursor/arc_cut_cursor.png", - tr("Select arc"), &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + tr("Select arc"), &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1098,8 +1124,8 @@ void MainWindow::ToolLineIntersectAxis(bool checked) SetToolButtonWithApply(checked, Tool::LineIntersectAxis, ":/cursor/line_intersect_axis_cursor.png", tr("Select first point of line"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1109,8 +1135,8 @@ void MainWindow::ToolCurveIntersectAxis(bool checked) SetToolButtonWithApply(checked, Tool::CurveIntersectAxis, ":/cursor/curve_intersect_axis_cursor.png", tr("Select curve"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1121,8 +1147,8 @@ void MainWindow::ToolArcIntersectAxis(bool checked) SetToolButtonWithApply(checked, Tool::ArcIntersectAxis, ":/cursor/arc_intersect_axis_cursor.png", tr("Select arc"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1132,8 +1158,8 @@ void MainWindow::ToolPointOfIntersectionArcs(bool checked) SetToolButtonWithApply(checked, Tool::PointOfIntersectionArcs, "://cursor/point_of_intersection_arcs.png", tr("Select first an arc"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1143,8 +1169,8 @@ void MainWindow::ToolPointOfIntersectionCircles(bool checked) SetToolButtonWithApply(checked, Tool::PointOfIntersectionCircles, "://cursor/point_of_intersection_circles.png", tr("Select first circle center"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1154,8 +1180,8 @@ void MainWindow::ToolPointOfIntersectionCurves(bool checked) SetToolButtonWithApply(checked, Tool::PointOfIntersectionCurves, "://cursor/intersection_curves_cursor.png", tr("Select first curve"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1165,8 +1191,8 @@ void MainWindow::ToolPointFromCircleAndTangent(bool checked) SetToolButtonWithApply(checked, Tool::PointFromCircleAndTangent, "://cursor/point_from_circle_and_tangent_cursor.png", tr("Select point on tangent"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1176,8 +1202,8 @@ void MainWindow::ToolPointFromArcAndTangent(bool checked) SetToolButtonWithApply(checked, Tool::PointFromArcAndTangent, "://cursor/point_from_arc_and_tangent_cursor.png", tr("Select point on tangent"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1187,8 +1213,8 @@ void MainWindow::ToolArcWithLength(bool checked) SetToolButtonWithApply(checked, Tool::ArcWithLength, "://cursor/arc_with_length_cursor.png", tr("Select point of the center of the arc"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- @@ -1198,8 +1224,8 @@ void MainWindow::ToolTrueDarts(bool checked) SetToolButtonWithApply(checked, Tool::TrueDarts, "://cursor/true_darts_cursor.png", tr("Select the first base line point"), - &MainWindow::ClosedDialogWithApply, - &MainWindow::ApplyDialog); + &MainWindow::ClosedDrawDialogWithApply, + &MainWindow::ApplyDrawDialog); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index 8bc530b0c..34851eaf5 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -282,10 +282,20 @@ private: Func closeDialogSlot, Func2 applyDialogSlot); template void ClosedDialog(int result); + template - void ClosedDialogWithApply(int result); + void ClosedDialogWithApply(int result, VMainGraphicsScene *scene); template - void ApplyDialog(); + void ApplyDialog(VMainGraphicsScene *scene); + template + void ClosedDrawDialogWithApply(int result); + template + void ApplyDrawDialog(); + template + void ClosedDetailsDialogWithApply(int result); + template + void ApplyDetailsDialog(); + bool SavePattern(const QString &curFile, QString &error); void AutoSavePattern(); void setCurrentFile(const QString &fileName);