From c76718e9d0edee860fb636add523f8e9cf8daf5f Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 12 May 2015 18:15:10 +0300 Subject: [PATCH] Tool layout settings. --HG-- branch : feature --- src/app/core/vapplication.cpp | 4 +- src/app/core/vapplication.h | 7 +- src/app/dialogs/tools/dialogalongline.cpp | 3 +- src/app/dialogs/tools/dialogarc.cpp | 3 +- src/app/dialogs/tools/dialogbisector.cpp | 3 +- .../tools/dialogcurveintersectaxis.cpp | 5 +- src/app/dialogs/tools/dialogcutarc.cpp | 3 +- src/app/dialogs/tools/dialogcutspline.cpp | 3 +- src/app/dialogs/tools/dialogcutsplinepath.cpp | 3 +- src/app/dialogs/tools/dialogendline.cpp | 5 +- src/app/dialogs/tools/dialogheight.cpp | 3 +- src/app/dialogs/tools/dialogline.cpp | 3 +- src/app/dialogs/tools/dialoglineintersect.cpp | 3 +- .../dialogs/tools/dialoglineintersectaxis.cpp | 5 +- src/app/dialogs/tools/dialognormal.cpp | 3 +- .../dialogs/tools/dialogpointofcontact.cpp | 3 +- .../tools/dialogpointofintersection.cpp | 3 +- src/app/dialogs/tools/dialogshoulderpoint.cpp | 3 +- src/app/dialogs/tools/dialogspline.cpp | 3 +- src/app/dialogs/tools/dialogsplinepath.cpp | 3 +- src/app/dialogs/tools/dialogtriangle.cpp | 3 +- src/app/mainwindow.cpp | 75 +++++++-- src/app/mainwindow.h | 3 + src/app/mainwindow.ui | 11 +- src/app/mainwindowsnogui.cpp | 142 +++++++++++++++++- src/app/mainwindowsnogui.h | 21 ++- src/app/tools/drawTools/vtoolalongline.cpp | 3 +- src/app/tools/drawTools/vtoolarc.cpp | 3 +- src/app/tools/drawTools/vtoolbisector.cpp | 3 +- .../drawTools/vtoolcurveintersectaxis.cpp | 3 +- src/app/tools/drawTools/vtoolcutarc.cpp | 3 +- src/app/tools/drawTools/vtoolcutspline.cpp | 3 +- .../tools/drawTools/vtoolcutsplinepath.cpp | 3 +- src/app/tools/drawTools/vtoolendline.cpp | 3 +- src/app/tools/drawTools/vtoolheight.cpp | 3 +- src/app/tools/drawTools/vtoolline.cpp | 3 +- .../tools/drawTools/vtoollineintersect.cpp | 3 +- .../drawTools/vtoollineintersectaxis.cpp | 3 +- src/app/tools/drawTools/vtoolnormal.cpp | 3 +- .../tools/drawTools/vtoolpointofcontact.cpp | 3 +- .../drawTools/vtoolpointofintersection.cpp | 3 +- .../tools/drawTools/vtoolshoulderpoint.cpp | 3 +- src/app/tools/drawTools/vtoolspline.cpp | 3 +- src/app/tools/drawTools/vtoolsplinepath.cpp | 3 +- src/app/tools/drawTools/vtooltriangle.cpp | 3 +- src/app/visualization/visualization.cpp | 2 +- src/app/visualization/visualization.h | 2 +- 47 files changed, 319 insertions(+), 68 deletions(-) diff --git a/src/app/core/vapplication.cpp b/src/app/core/vapplication.cpp index daaf8c478..61076608c 100644 --- a/src/app/core/vapplication.cpp +++ b/src/app/core/vapplication.cpp @@ -2068,14 +2068,14 @@ VSettings *VApplication::getSettings() } //--------------------------------------------------------------------------------------------------------------------- -VMainGraphicsScene *VApplication::getCurrentScene() const +QGraphicsScene *VApplication::getCurrentScene() const { SCASSERT(currentScene != nullptr); return currentScene; } //--------------------------------------------------------------------------------------------------------------------- -void VApplication::setCurrentScene(VMainGraphicsScene *value) +void VApplication::setCurrentScene(QGraphicsScene *value) { currentScene = value; } diff --git a/src/app/core/vapplication.h b/src/app/core/vapplication.h index da5df856d..38c714903 100644 --- a/src/app/core/vapplication.h +++ b/src/app/core/vapplication.h @@ -38,7 +38,6 @@ class VApplication;// used in define class QUndoStack; class VMainGraphicsView; -class VMainGraphicsScene; class VPattern; class QFile; #if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) @@ -110,8 +109,8 @@ public: void OpenSettings(); VSettings *getSettings(); - VMainGraphicsScene *getCurrentScene() const; - void setCurrentScene(VMainGraphicsScene *value); + QGraphicsScene *getCurrentScene() const; + void setCurrentScene(QGraphicsScene *value); void setCurrentDocument(VPattern *doc); VPattern *getCurrentDocument()const; @@ -151,7 +150,7 @@ private: QMap stDescriptions; QUndoStack *undoStack; VMainGraphicsView *sceneView; - VMainGraphicsScene *currentScene; + QGraphicsScene *currentScene; QTimer *autoSaveTimer; /** * @brief mainWindow pointer to main window. Usefull if need create modal dialog. Without pointer to main window diff --git a/src/app/dialogs/tools/dialogalongline.cpp b/src/app/dialogs/tools/dialogalongline.cpp index 9d3cd576d..f33b72ab8 100644 --- a/src/app/dialogs/tools/dialogalongline.cpp +++ b/src/app/dialogs/tools/dialogalongline.cpp @@ -117,7 +117,8 @@ void DialogAlongLine::ShowVisualization() { if (prepare == false) { - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolAlongLine::SetFactor); scene->addItem(line); line->RefreshGeometry(); diff --git a/src/app/dialogs/tools/dialogarc.cpp b/src/app/dialogs/tools/dialogarc.cpp index 4edc42a66..3105693df 100644 --- a/src/app/dialogs/tools/dialogarc.cpp +++ b/src/app/dialogs/tools/dialogarc.cpp @@ -225,7 +225,8 @@ void DialogArc::ShowVisualization() { if (prepare == false) { - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor); scene->addItem(path); path->RefreshGeometry(); diff --git a/src/app/dialogs/tools/dialogbisector.cpp b/src/app/dialogs/tools/dialogbisector.cpp index 4d3136c2c..c43a27d1a 100644 --- a/src/app/dialogs/tools/dialogbisector.cpp +++ b/src/app/dialogs/tools/dialogbisector.cpp @@ -126,7 +126,8 @@ void DialogBisector::ShowVisualization() { if (prepare == false) { - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolBisector::SetFactor); scene->addItem(line); line->RefreshGeometry(); diff --git a/src/app/dialogs/tools/dialogcurveintersectaxis.cpp b/src/app/dialogs/tools/dialogcurveintersectaxis.cpp index d240d3d23..3476be2d2 100644 --- a/src/app/dialogs/tools/dialogcurveintersectaxis.cpp +++ b/src/app/dialogs/tools/dialogcurveintersectaxis.cpp @@ -166,7 +166,7 @@ void DialogCurveIntersectAxis::ShowDialog(bool click) if (click) { /*We will ignore click if poinet is in point circle*/ - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); SCASSERT(scene != nullptr); const QSharedPointer point = data->GeometricObject(GetBasePointId()); QLineF line = QLineF(point->toQPointF(), scene->getScenePos()); @@ -258,7 +258,8 @@ void DialogCurveIntersectAxis::ShowVisualization() if (prepare == false) { //TODO move to parent class! - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolCurveIntersectAxis::SetFactor); scene->addItem(line); line->RefreshGeometry(); diff --git a/src/app/dialogs/tools/dialogcutarc.cpp b/src/app/dialogs/tools/dialogcutarc.cpp index 437831a70..7268423e9 100644 --- a/src/app/dialogs/tools/dialogcutarc.cpp +++ b/src/app/dialogs/tools/dialogcutarc.cpp @@ -92,7 +92,8 @@ void DialogCutArc::ShowVisualization() { if (prepare == false) { - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor); scene->addItem(path); path->RefreshGeometry(); diff --git a/src/app/dialogs/tools/dialogcutspline.cpp b/src/app/dialogs/tools/dialogcutspline.cpp index 62e72c46d..8eefa1e0d 100644 --- a/src/app/dialogs/tools/dialogcutspline.cpp +++ b/src/app/dialogs/tools/dialogcutspline.cpp @@ -196,7 +196,8 @@ void DialogCutSpline::ShowVisualization() { if (prepare == false) { - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor); scene->addItem(path); path->RefreshGeometry(); diff --git a/src/app/dialogs/tools/dialogcutsplinepath.cpp b/src/app/dialogs/tools/dialogcutsplinepath.cpp index 46affdf82..f2f06812d 100644 --- a/src/app/dialogs/tools/dialogcutsplinepath.cpp +++ b/src/app/dialogs/tools/dialogcutsplinepath.cpp @@ -196,7 +196,8 @@ void DialogCutSplinePath::ShowVisualization() { if (prepare == false) { - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor); scene->addItem(path); path->RefreshGeometry(); diff --git a/src/app/dialogs/tools/dialogendline.cpp b/src/app/dialogs/tools/dialogendline.cpp index 43553a0b0..27b9891e0 100644 --- a/src/app/dialogs/tools/dialogendline.cpp +++ b/src/app/dialogs/tools/dialogendline.cpp @@ -261,7 +261,7 @@ void DialogEndLine::ShowDialog(bool click) if (click) { /*We will ignore click if poinet is in point circle*/ - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); SCASSERT(scene != nullptr); const QSharedPointer point = data->GeometricObject(GetBasePointId()); QLineF line = QLineF(point->toQPointF(), scene->getScenePos()); @@ -287,7 +287,8 @@ void DialogEndLine::ShowVisualization() if (prepare == false) { //TODO move to parent class! - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolEndLine::SetFactor); scene->addItem(line); line->RefreshGeometry(); diff --git a/src/app/dialogs/tools/dialogheight.cpp b/src/app/dialogs/tools/dialogheight.cpp index 971e86f5f..9440e517a 100644 --- a/src/app/dialogs/tools/dialogheight.cpp +++ b/src/app/dialogs/tools/dialogheight.cpp @@ -254,7 +254,8 @@ void DialogHeight::ShowVisualization() { if (prepare == false) { - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor); scene->addItem(line); line->RefreshGeometry(); diff --git a/src/app/dialogs/tools/dialogline.cpp b/src/app/dialogs/tools/dialogline.cpp index 3f358cb83..218deabb2 100644 --- a/src/app/dialogs/tools/dialogline.cpp +++ b/src/app/dialogs/tools/dialogline.cpp @@ -145,7 +145,8 @@ void DialogLine::ShowVisualization() { if (prepare == false) { - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolLine::SetFactor); scene->addItem(line); line->RefreshGeometry(); diff --git a/src/app/dialogs/tools/dialoglineintersect.cpp b/src/app/dialogs/tools/dialoglineintersect.cpp index 48ab1b952..084373e2c 100644 --- a/src/app/dialogs/tools/dialoglineintersect.cpp +++ b/src/app/dialogs/tools/dialoglineintersect.cpp @@ -229,7 +229,8 @@ void DialogLineIntersect::ShowVisualization() { if (prepare == false) { - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor); scene->addItem(line); line->RefreshGeometry(); diff --git a/src/app/dialogs/tools/dialoglineintersectaxis.cpp b/src/app/dialogs/tools/dialoglineintersectaxis.cpp index f54198ae5..d9aac1dd7 100644 --- a/src/app/dialogs/tools/dialoglineintersectaxis.cpp +++ b/src/app/dialogs/tools/dialoglineintersectaxis.cpp @@ -187,7 +187,7 @@ void DialogLineIntersectAxis::ShowDialog(bool click) if (click) { /*We will ignore click if poinet is in point circle*/ - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); SCASSERT(scene != nullptr); const QSharedPointer point = data->GeometricObject(GetBasePointId()); QLineF line = QLineF(point->toQPointF(), scene->getScenePos()); @@ -322,7 +322,8 @@ void DialogLineIntersectAxis::ShowVisualization() if (prepare == false) { //TODO move to parent class! - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, line, &VisToolLineIntersectAxis::SetFactor); scene->addItem(line); line->RefreshGeometry(); diff --git a/src/app/dialogs/tools/dialognormal.cpp b/src/app/dialogs/tools/dialognormal.cpp index 960bac439..fe54d4703 100644 --- a/src/app/dialogs/tools/dialognormal.cpp +++ b/src/app/dialogs/tools/dialognormal.cpp @@ -116,7 +116,8 @@ void DialogNormal::ShowVisualization() { if (prepare == false) { - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor); scene->addItem(line); line->RefreshGeometry(); diff --git a/src/app/dialogs/tools/dialogpointofcontact.cpp b/src/app/dialogs/tools/dialogpointofcontact.cpp index 5f5e3f336..694ab9cdc 100644 --- a/src/app/dialogs/tools/dialogpointofcontact.cpp +++ b/src/app/dialogs/tools/dialogpointofcontact.cpp @@ -133,7 +133,8 @@ void DialogPointOfContact::ShowVisualization() { if (prepare == false) { - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor); scene->addItem(line); line->RefreshGeometry(); diff --git a/src/app/dialogs/tools/dialogpointofintersection.cpp b/src/app/dialogs/tools/dialogpointofintersection.cpp index 3c03d60e5..b122108a7 100644 --- a/src/app/dialogs/tools/dialogpointofintersection.cpp +++ b/src/app/dialogs/tools/dialogpointofintersection.cpp @@ -161,7 +161,8 @@ void DialogPointOfIntersection::ShowVisualization() { if (prepare == false) { - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor); line->RefreshGeometry(); } diff --git a/src/app/dialogs/tools/dialogshoulderpoint.cpp b/src/app/dialogs/tools/dialogshoulderpoint.cpp index 16619b558..33194dbce 100644 --- a/src/app/dialogs/tools/dialogshoulderpoint.cpp +++ b/src/app/dialogs/tools/dialogshoulderpoint.cpp @@ -126,7 +126,8 @@ void DialogShoulderPoint::ShowVisualization() { if (prepare == false) { - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor); scene->addItem(line); line->RefreshGeometry(); diff --git a/src/app/dialogs/tools/dialogspline.cpp b/src/app/dialogs/tools/dialogspline.cpp index e6cdcc807..297cd135d 100644 --- a/src/app/dialogs/tools/dialogspline.cpp +++ b/src/app/dialogs/tools/dialogspline.cpp @@ -185,7 +185,8 @@ void DialogSpline::ShowVisualization() { if (prepare == false) { - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, path, &Visualization::SetFactor); scene->addItem(path); path->RefreshGeometry(); diff --git a/src/app/dialogs/tools/dialogsplinepath.cpp b/src/app/dialogs/tools/dialogsplinepath.cpp index d9b3dc968..d36870d10 100644 --- a/src/app/dialogs/tools/dialogsplinepath.cpp +++ b/src/app/dialogs/tools/dialogsplinepath.cpp @@ -267,7 +267,8 @@ void DialogSplinePath::ShowVisualization() { if (prepare == false) { - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, visPath, &Visualization::SetFactor); scene->addItem(visPath); visPath->setMode(Mode::Show); diff --git a/src/app/dialogs/tools/dialogtriangle.cpp b/src/app/dialogs/tools/dialogtriangle.cpp index d35d9e68e..e765be0c7 100644 --- a/src/app/dialogs/tools/dialogtriangle.cpp +++ b/src/app/dialogs/tools/dialogtriangle.cpp @@ -200,7 +200,8 @@ void DialogTriangle::ShowVisualization() { if (prepare == false) { - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, line, &VisLine::SetFactor); scene->addItem(line); line->RefreshGeometry(); diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index 462bc3f8d..df748737e 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -264,7 +264,11 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons helpLabel->setText(toolTip); ui->view->setShowToolOptions(false); dialogTool = new Dialog(pattern, 0, this); - connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChosenObject); + + VMainGraphicsScene *scene = qobject_cast(currentScene); + SCASSERT(scene != nullptr); + + connect(scene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChosenObject); connect(dialogTool, &DialogTool::DialogClosed, this, closeDialogSlot); connect(dialogTool, &DialogTool::ToolTip, this, &MainWindow::ShowToolTip); ui->view->itemClicked(nullptr); @@ -273,7 +277,6 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons { if (QToolButton *tButton = qobject_cast< QToolButton * >(this->sender())) { - SCASSERT(tButton != nullptr); tButton->setChecked(true); } } @@ -304,7 +307,11 @@ void MainWindow::SetToolButtonWithApply(bool checked, Tool t, const QString &cur ui->view->setShowToolOptions(false); helpLabel->setText(toolTip); dialogTool = new Dialog(pattern, 0, this); - connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChosenObject); + + VMainGraphicsScene *scene = qobject_cast(currentScene); + SCASSERT(scene != nullptr); + + connect(scene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChosenObject); connect(dialogTool, &DialogTool::DialogClosed, this, closeDialogSlot); connect(dialogTool, &DialogTool::DialogApplied, this, applyDialogSlot); connect(dialogTool, &DialogTool::ToolTip, this, &MainWindow::ShowToolTip); @@ -315,7 +322,6 @@ void MainWindow::SetToolButtonWithApply(bool checked, Tool t, const QString &cur { if (QToolButton *tButton = qobject_cast< QToolButton * >(this->sender())) { - SCASSERT(tButton != nullptr); tButton->setChecked(true); } } @@ -331,7 +337,10 @@ void MainWindow::ClosedDialog(int result) SCASSERT(dialogTool != nullptr); if (result == QDialog::Accepted) { - QGraphicsItem *tool = dynamic_cast(DrawTool::Create(dialogTool, currentScene, doc, pattern)); + VMainGraphicsScene *scene = qobject_cast(currentScene); + SCASSERT(scene != nullptr); + + QGraphicsItem *tool = dynamic_cast(DrawTool::Create(dialogTool, scene, doc, pattern)); ui->view->itemClicked(tool); } ArrowTool(); @@ -351,8 +360,11 @@ 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( - dynamic_cast (DrawTool::Create(dialogTool, currentScene, doc, pattern))); + dynamic_cast (DrawTool::Create(dialogTool, scene, doc, pattern))); } else { // Or update associated tool with data @@ -382,8 +394,11 @@ void MainWindow::ApplyDialog() // Only create tool if not already created with apply if (dialogTool->GetAssociatedTool() == nullptr) { + VMainGraphicsScene *scene = qobject_cast(currentScene); + SCASSERT(scene != nullptr); + dialogTool->SetAssociatedTool( - static_cast (DrawTool::Create(dialogTool, currentScene, doc, pattern))); + static_cast (DrawTool::Create(dialogTool, scene, doc, pattern))); } else { // Or update associated tool with data @@ -792,6 +807,33 @@ void MainWindow::customEvent(QEvent *event) } } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ClearLayout() +{ + qDeleteAll (scenes); + scenes.clear(); + shadows.clear(); + papers.clear(); + ui->listWidget->clear(); + //EnableActions(false); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::PrepareSceneList() +{ + for (int i=1; i<=scenes.size(); ++i) + { + QListWidgetItem *item = new QListWidgetItem(ScenePreview(i-1), QString::number(i)); + ui->listWidget->addItem(item); + } + + if (not scenes.isEmpty()) + { + ui->listWidget->setCurrentRow(0); + //EnableActions(true); + } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ToolBarOption enable option toolbar. @@ -944,6 +986,7 @@ void MainWindow::InitToolButtons() connect(ui->toolButtonLineIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolLineIntersectAxis); connect(ui->toolButtonCurveIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolCurveIntersectAxis); connect(ui->toolButtonArcIntersectAxis, &QToolButton::clicked, this, &MainWindow::ToolCurveIntersectAxis); + connect(ui->toolButtonLayoutSettings, &QToolButton::clicked, this, &MainWindow::ToolLayoutSettings); } //--------------------------------------------------------------------------------------------------------------------- @@ -1120,13 +1163,16 @@ void MainWindow::SaveCurrentScene() { if (mode == Draw::Calculation || mode == Draw::Modeling) { + VMainGraphicsScene *scene = qobject_cast(currentScene); + SCASSERT(scene != nullptr); + /*Save transform*/ - currentScene->setTransform(ui->view->transform()); + scene->setTransform(ui->view->transform()); /*Save scroll bars value for previous scene.*/ QScrollBar *horScrollBar = ui->view->horizontalScrollBar(); - currentScene->setHorScrollBar(horScrollBar->value()); + scene->setHorScrollBar(horScrollBar->value()); QScrollBar *verScrollBar = ui->view->verticalScrollBar(); - currentScene->setVerScrollBar(verScrollBar->value()); + scene->setVerScrollBar(verScrollBar->value()); } } @@ -1136,13 +1182,16 @@ void MainWindow::SaveCurrentScene() */ void MainWindow::RestoreCurrentScene() { + VMainGraphicsScene *scene = qobject_cast(currentScene); + SCASSERT(scene != nullptr); + /*Set transform for current scene*/ - ui->view->setTransform(currentScene->transform()); + ui->view->setTransform(scene->transform()); /*Set value for current scene scroll bar.*/ QScrollBar *horScrollBar = ui->view->horizontalScrollBar(); - horScrollBar->setValue(currentScene->getHorScrollBar()); + horScrollBar->setValue(scene->getHorScrollBar()); QScrollBar *verScrollBar = ui->view->verticalScrollBar(); - verScrollBar->setValue(currentScene->getVerScrollBar()); + verScrollBar->setValue(scene->getVerScrollBar()); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/mainwindow.h b/src/app/mainwindow.h index 1e7a1202e..94a1a7a79 100644 --- a/src/app/mainwindow.h +++ b/src/app/mainwindow.h @@ -146,6 +146,9 @@ protected: virtual void showEvent(QShowEvent *event); virtual void closeEvent(QCloseEvent *event); virtual void customEvent(QEvent * event); + + virtual void ClearLayout(); + virtual void PrepareSceneList(); private: Q_DISABLE_COPY(MainWindow) /** @brief ui keeps information about user interface */ diff --git a/src/app/mainwindow.ui b/src/app/mainwindow.ui index 77573adb3..e2b8f5ade 100644 --- a/src/app/mainwindow.ui +++ b/src/app/mainwindow.ui @@ -24,6 +24,9 @@ + + true + 2 @@ -40,7 +43,7 @@ - 5 + 4 @@ -685,6 +688,9 @@ + + false + Seam allowance tool @@ -741,6 +747,9 @@ + + false + Settings diff --git a/src/app/mainwindowsnogui.cpp b/src/app/mainwindowsnogui.cpp index 5e2d37c22..fb00a38b4 100644 --- a/src/app/mainwindowsnogui.cpp +++ b/src/app/mainwindowsnogui.cpp @@ -29,13 +29,20 @@ #include "mainwindowsnogui.h" #include "../core/vapplication.h" #include "../container/vcontainer.h" +#include "../dialogs/app/dialoglayoutsettings.h" +#include "../../libs/vlayout/vlayoutgenerator.h" +#include "../dialogs/app/dialoglayoutprogress.h" +#include "../dialogs/app/dialogsavelayout.h" +#include "../../libs/vlayout/vposter.h" #include +#include //--------------------------------------------------------------------------------------------------------------------- MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent) : QMainWindow(parent), listDetails(QVector()), currentScene(nullptr), tempSceneLayout(nullptr), - pattern(new VContainer()) + pattern(new VContainer()), papers(QList()), shadows(QList()), + scenes(QList()), details(QList >()) { InitTempLayoutScene(); } @@ -47,6 +54,60 @@ MainWindowsNoGUI::~MainWindowsNoGUI() delete pattern; } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindowsNoGUI::ToolLayoutSettings(bool checked) +{ + if (checked) + { + VLayoutGenerator lGenerator(this); + lGenerator.SetDetails(listDetails); + + DialogLayoutSettings layout(&lGenerator, this); + if (layout.exec() == QDialog::Rejected) + { + return; + } + + DialogLayoutProgress progress(listDetails.count(), this); + + connect(&lGenerator, &VLayoutGenerator::Start, &progress, &DialogLayoutProgress::Start); + connect(&lGenerator, &VLayoutGenerator::Arranged, &progress, &DialogLayoutProgress::Arranged); + connect(&lGenerator, &VLayoutGenerator::Error, &progress, &DialogLayoutProgress::Error); + connect(&lGenerator, &VLayoutGenerator::Finished, &progress, &DialogLayoutProgress::Finished); + connect(&progress, &DialogLayoutProgress::Abort, &lGenerator, &VLayoutGenerator::Abort); + + lGenerator.Generate(); + + switch (lGenerator.State()) + { + case LayoutErrors::NoError: + ClearLayout(); + papers = lGenerator.GetPapersItems();// Blank sheets + details = lGenerator.GetAllDetails();// All details + CreateShadows(); + CreateScenes(); + PrepareSceneList(); + break; + case LayoutErrors::ProcessStoped: + break; + case LayoutErrors::PrepareLayoutError: + case LayoutErrors::PaperSizeError: + case LayoutErrors::EmptyPaperError: + ClearLayout(); + break; + default: + break; + } + } + else + { + if (QToolButton *tButton = qobject_cast< QToolButton * >(this->sender())) + { + tButton->setChecked(true); + } + } +} + //--------------------------------------------------------------------------------------------------------------------- void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash *details) { @@ -76,6 +137,83 @@ void MainWindowsNoGUI::PrepareDetailsForLayout(const QHash *de //--------------------------------------------------------------------------------------------------------------------- void MainWindowsNoGUI::InitTempLayoutScene() { - tempSceneLayout = new VMainGraphicsScene(); + tempSceneLayout = new QGraphicsScene(); tempSceneLayout->setBackgroundBrush( QBrush(QColor(Qt::gray), Qt::SolidPattern) ); } + +//--------------------------------------------------------------------------------------------------------------------- +QIcon MainWindowsNoGUI::ScenePreview(int i) const +{ + QImage image; + QGraphicsRectItem *paper = qgraphicsitem_cast(papers.at(i)); + if (paper) + { + const QRectF r = paper->rect(); + // Create the image with the exact size of the shrunk scene + image = QImage(QSize(static_cast(r.width()), static_cast(r.height())), QImage::Format_RGB32); + + if (not image.isNull()) + { + image.fill(Qt::white); + QPainter painter(&image); + painter.setFont( QFont( "Arial", 8, QFont::Normal ) ); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setPen(QPen(Qt::black, qApp->toPixel(qApp->widthMainLine()), Qt::SolidLine, Qt::RoundCap, + Qt::RoundJoin)); + painter.setBrush ( QBrush ( Qt::NoBrush ) ); + scenes.at(i)->render(&painter); + painter.end(); + } + else + { + qWarning()<<"Cannot create image. Size too big"; + } + } + else + { + image = QImage(QSize(101, 146), QImage::Format_RGB32); + image.fill(Qt::white); + } + return QIcon(QBitmap::fromImage(image)); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindowsNoGUI::CreateShadows() +{ + for (int i=0; i< papers.size(); ++i) + { + qreal x1=0, y1=0, x2=0, y2=0; + QGraphicsRectItem *item = qgraphicsitem_cast(papers.at(i)); + if (item) + { + item->rect().getCoords(&x1, &y1, &x2, &y2); + QGraphicsRectItem *shadowPaper = new QGraphicsRectItem(QRectF(x1+4, y1+4, x2+4, y2+4)); + shadowPaper->setBrush(QBrush(Qt::black)); + shadows.append(shadowPaper); + } + else + { + shadows.append(nullptr); + } + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindowsNoGUI::CreateScenes() +{ + for (int i=0; isetBackgroundBrush(QBrush(QColor(Qt::gray), Qt::SolidPattern)); + scene->addItem(shadows.at(i)); + scene->addItem(papers.at(i)); + + QList paperDetails = details.at(i); + for (int i=0; i < paperDetails.size(); ++i) + { + scene->addItem(paperDetails.at(i)); + } + + scenes.append(scene); + } +} diff --git a/src/app/mainwindowsnogui.h b/src/app/mainwindowsnogui.h index 4edbb8f93..4a426f86e 100644 --- a/src/app/mainwindowsnogui.h +++ b/src/app/mainwindowsnogui.h @@ -33,7 +33,8 @@ #include "../geometry/vdetail.h" #include "../libs/vlayout/vlayoutdetail.h" -#include "../widgets/vmaingraphicsscene.h" + +class QGraphicsScene; class MainWindowsNoGUI : public QMainWindow { @@ -42,24 +43,38 @@ public: MainWindowsNoGUI(QWidget *parent = nullptr); virtual ~MainWindowsNoGUI(); +public slots: + void ToolLayoutSettings(bool checked); + protected: QVector listDetails; /** @brief currentScene pointer to current scene. */ - VMainGraphicsScene *currentScene; + QGraphicsScene *currentScene; - VMainGraphicsScene *tempSceneLayout; + QGraphicsScene *tempSceneLayout; /** @brief pattern container with data (points, arcs, splines, spline paths, variables) */ VContainer *pattern; + QList papers; + QList shadows; + QList scenes; + QList > details; + void PrepareDetailsForLayout(const QHash *details); void InitTempLayoutScene(); + virtual void ClearLayout()=0; + virtual void PrepareSceneList()=0; + QIcon ScenePreview(int i) const; private: Q_DISABLE_COPY(MainWindowsNoGUI) + void CreateShadows(); + void CreateScenes(); + }; #endif // MAINWINDOWSNOGUI_H diff --git a/src/app/tools/drawTools/vtoolalongline.cpp b/src/app/tools/drawTools/vtoolalongline.cpp index 616567143..2fb5c2587 100644 --- a/src/app/tools/drawTools/vtoolalongline.cpp +++ b/src/app/tools/drawTools/vtoolalongline.cpp @@ -189,7 +189,8 @@ void VToolAlongLine::ShowVisualization(bool show) if (vis == nullptr) { VisToolAlongLine *visual = new VisToolAlongLine(getData()); - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); scene->addItem(visual); diff --git a/src/app/tools/drawTools/vtoolarc.cpp b/src/app/tools/drawTools/vtoolarc.cpp index 9fe94e448..57ab391d3 100644 --- a/src/app/tools/drawTools/vtoolarc.cpp +++ b/src/app/tools/drawTools/vtoolarc.cpp @@ -293,7 +293,8 @@ void VToolArc::ShowVisualization(bool show) if (vis == nullptr) { VisToolArc * visual = new VisToolArc(getData()); - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); scene->addItem(visual); diff --git a/src/app/tools/drawTools/vtoolbisector.cpp b/src/app/tools/drawTools/vtoolbisector.cpp index 025adcf0a..4361b76a7 100644 --- a/src/app/tools/drawTools/vtoolbisector.cpp +++ b/src/app/tools/drawTools/vtoolbisector.cpp @@ -347,7 +347,8 @@ void VToolBisector::ShowVisualization(bool show) if (vis == nullptr) { VisToolBisector * visual = new VisToolBisector(getData()); - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); scene->addItem(visual); diff --git a/src/app/tools/drawTools/vtoolcurveintersectaxis.cpp b/src/app/tools/drawTools/vtoolcurveintersectaxis.cpp index eb81c8a01..7bcd8ea8d 100644 --- a/src/app/tools/drawTools/vtoolcurveintersectaxis.cpp +++ b/src/app/tools/drawTools/vtoolcurveintersectaxis.cpp @@ -227,7 +227,8 @@ void VToolCurveIntersectAxis::ShowVisualization(bool show) if (vis == nullptr) { VisToolCurveIntersectAxis * visual = new VisToolCurveIntersectAxis(getData()); - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); scene->addItem(visual); diff --git a/src/app/tools/drawTools/vtoolcutarc.cpp b/src/app/tools/drawTools/vtoolcutarc.cpp index c2eacbccb..6f2876c63 100644 --- a/src/app/tools/drawTools/vtoolcutarc.cpp +++ b/src/app/tools/drawTools/vtoolcutarc.cpp @@ -192,7 +192,8 @@ void VToolCutArc::ShowVisualization(bool show) if (vis == nullptr) { VisToolCutArc * visual = new VisToolCutArc(getData()); - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); scene->addItem(visual); diff --git a/src/app/tools/drawTools/vtoolcutspline.cpp b/src/app/tools/drawTools/vtoolcutspline.cpp index 6690f2737..e4f2690c5 100644 --- a/src/app/tools/drawTools/vtoolcutspline.cpp +++ b/src/app/tools/drawTools/vtoolcutspline.cpp @@ -202,7 +202,8 @@ void VToolCutSpline::ShowVisualization(bool show) if (vis == nullptr) { VisToolCutSpline * visual = new VisToolCutSpline(getData()); - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); scene->addItem(visual); diff --git a/src/app/tools/drawTools/vtoolcutsplinepath.cpp b/src/app/tools/drawTools/vtoolcutsplinepath.cpp index f160d41ef..211022387 100644 --- a/src/app/tools/drawTools/vtoolcutsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolcutsplinepath.cpp @@ -246,7 +246,8 @@ void VToolCutSplinePath::ShowVisualization(bool show) if (vis == nullptr) { VisToolCutSplinePath *visual = new VisToolCutSplinePath(getData()); - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); scene->addItem(visual); diff --git a/src/app/tools/drawTools/vtoolendline.cpp b/src/app/tools/drawTools/vtoolendline.cpp index bc23fc022..d69a26404 100644 --- a/src/app/tools/drawTools/vtoolendline.cpp +++ b/src/app/tools/drawTools/vtoolendline.cpp @@ -287,7 +287,8 @@ void VToolEndLine::ShowVisualization(bool show) if (vis == nullptr) { VisToolEndLine * visual = new VisToolEndLine(getData()); - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); scene->addItem(visual); diff --git a/src/app/tools/drawTools/vtoolheight.cpp b/src/app/tools/drawTools/vtoolheight.cpp index fc021dc66..84acc0609 100644 --- a/src/app/tools/drawTools/vtoolheight.cpp +++ b/src/app/tools/drawTools/vtoolheight.cpp @@ -291,7 +291,8 @@ void VToolHeight::ShowVisualization(bool show) if (vis == nullptr) { VisToolHeight * visual = new VisToolHeight(getData()); - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); scene->addItem(visual); diff --git a/src/app/tools/drawTools/vtoolline.cpp b/src/app/tools/drawTools/vtoolline.cpp index d440acef4..20fa07a60 100644 --- a/src/app/tools/drawTools/vtoolline.cpp +++ b/src/app/tools/drawTools/vtoolline.cpp @@ -428,7 +428,8 @@ void VToolLine::ShowVisualization(bool show) if (vis == nullptr) { VisToolLine * visual = new VisToolLine(getData()); - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); scene->addItem(visual); diff --git a/src/app/tools/drawTools/vtoollineintersect.cpp b/src/app/tools/drawTools/vtoollineintersect.cpp index 050a7d044..10ce3e675 100644 --- a/src/app/tools/drawTools/vtoollineintersect.cpp +++ b/src/app/tools/drawTools/vtoollineintersect.cpp @@ -309,7 +309,8 @@ void VToolLineIntersect::ShowVisualization(bool show) if (vis == nullptr) { VisToolLineIntersect * visual = new VisToolLineIntersect(getData()); - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); scene->addItem(visual); diff --git a/src/app/tools/drawTools/vtoollineintersectaxis.cpp b/src/app/tools/drawTools/vtoollineintersectaxis.cpp index eadae8e6d..a6ead89bc 100644 --- a/src/app/tools/drawTools/vtoollineintersectaxis.cpp +++ b/src/app/tools/drawTools/vtoollineintersectaxis.cpp @@ -239,7 +239,8 @@ void VToolLineIntersectAxis::ShowVisualization(bool show) if (vis == nullptr) { VisToolLineIntersectAxis * visual = new VisToolLineIntersectAxis(getData()); - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); scene->addItem(visual); diff --git a/src/app/tools/drawTools/vtoolnormal.cpp b/src/app/tools/drawTools/vtoolnormal.cpp index d5aef5670..9b6f4e4e8 100644 --- a/src/app/tools/drawTools/vtoolnormal.cpp +++ b/src/app/tools/drawTools/vtoolnormal.cpp @@ -324,7 +324,8 @@ void VToolNormal::ShowVisualization(bool show) if (vis == nullptr) { VisToolNormal * visual = new VisToolNormal(getData()); - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); scene->addItem(visual); diff --git a/src/app/tools/drawTools/vtoolpointofcontact.cpp b/src/app/tools/drawTools/vtoolpointofcontact.cpp index 360d8a4b0..14bf954fc 100644 --- a/src/app/tools/drawTools/vtoolpointofcontact.cpp +++ b/src/app/tools/drawTools/vtoolpointofcontact.cpp @@ -355,7 +355,8 @@ void VToolPointOfContact::ShowVisualization(bool show) if (vis == nullptr) { VisToolPointOfContact * visual = new VisToolPointOfContact(getData()); - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); scene->addItem(visual); diff --git a/src/app/tools/drawTools/vtoolpointofintersection.cpp b/src/app/tools/drawTools/vtoolpointofintersection.cpp index 7908fa150..7ea98a311 100644 --- a/src/app/tools/drawTools/vtoolpointofintersection.cpp +++ b/src/app/tools/drawTools/vtoolpointofintersection.cpp @@ -260,7 +260,8 @@ void VToolPointOfIntersection::ShowVisualization(bool show) if (vis == nullptr) { VisToolPointOfIntersection * visual = new VisToolPointOfIntersection(getData()); - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); scene->addItem(visual); diff --git a/src/app/tools/drawTools/vtoolshoulderpoint.cpp b/src/app/tools/drawTools/vtoolshoulderpoint.cpp index fbfa389bf..4537df002 100644 --- a/src/app/tools/drawTools/vtoolshoulderpoint.cpp +++ b/src/app/tools/drawTools/vtoolshoulderpoint.cpp @@ -353,7 +353,8 @@ void VToolShoulderPoint::ShowVisualization(bool show) if (vis == nullptr) { VisToolShoulderPoint * visual = new VisToolShoulderPoint(getData()); - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); scene->addItem(visual); diff --git a/src/app/tools/drawTools/vtoolspline.cpp b/src/app/tools/drawTools/vtoolspline.cpp index 897ecfc6a..cd04d94e5 100644 --- a/src/app/tools/drawTools/vtoolspline.cpp +++ b/src/app/tools/drawTools/vtoolspline.cpp @@ -237,7 +237,8 @@ void VToolSpline::ShowVisualization(bool show) if (vis == nullptr) { VisToolSpline *visual = new VisToolSpline(getData(), this); - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); const QSharedPointer spl = VAbstractTool::data.GeometricObject(id); diff --git a/src/app/tools/drawTools/vtoolsplinepath.cpp b/src/app/tools/drawTools/vtoolsplinepath.cpp index 414becdaa..9fd9947dd 100644 --- a/src/app/tools/drawTools/vtoolsplinepath.cpp +++ b/src/app/tools/drawTools/vtoolsplinepath.cpp @@ -318,7 +318,8 @@ void VToolSplinePath::ShowVisualization(bool show) if (vis == nullptr) { VisToolSplinePath *visual = new VisToolSplinePath(getData(), this); - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); QSharedPointer splPath = VAbstractTool::data.GeometricObject(id); diff --git a/src/app/tools/drawTools/vtooltriangle.cpp b/src/app/tools/drawTools/vtooltriangle.cpp index b3071bbba..965d629c7 100644 --- a/src/app/tools/drawTools/vtooltriangle.cpp +++ b/src/app/tools/drawTools/vtooltriangle.cpp @@ -325,7 +325,8 @@ void VToolTriangle::ShowVisualization(bool show) if (vis == nullptr) { VisToolTriangle * visual = new VisToolTriangle(getData()); - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); + SCASSERT(scene != nullptr) connect(scene, &VMainGraphicsScene::NewFactor, visual, &Visualization::SetFactor); scene->addItem(visual); diff --git a/src/app/visualization/visualization.cpp b/src/app/visualization/visualization.cpp index 66dc9a856..f14f3a9c7 100644 --- a/src/app/visualization/visualization.cpp +++ b/src/app/visualization/visualization.cpp @@ -67,7 +67,7 @@ void Visualization::setScenePos(const QPointF &value) //--------------------------------------------------------------------------------------------------------------------- void Visualization::VisualMode(const quint32 &pointId) { - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); SCASSERT(scene != nullptr); this->point1Id = pointId; diff --git a/src/app/visualization/visualization.h b/src/app/visualization/visualization.h index 860db38d9..c72d21ad2 100644 --- a/src/app/visualization/visualization.h +++ b/src/app/visualization/visualization.h @@ -87,7 +87,7 @@ protected: void AddItem(Item *item) { SCASSERT(item != nullptr); - VMainGraphicsScene *scene = qApp->getCurrentScene(); + VMainGraphicsScene *scene = qobject_cast(qApp->getCurrentScene()); SCASSERT(scene != nullptr); scene->addItem(item);