Skip to content

Commit

Permalink
Clear the ThreeDViewer when there is no active sub window.
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Feb 7, 2017
1 parent dc42c6b commit 418a7cd
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Animation/AbstractAnimationWindow.h
Expand Up @@ -52,6 +52,7 @@ class AbstractAnimationWindow : public QMainWindow
Q_OBJECT
public:
AbstractAnimationWindow(QWidget *pParent);
ViewerWidget* getViewerWidget() {return mpViewerWidget;}
void openAnimationFile(QString fileName, bool stashCamera=false);
virtual void createActions();
void clearView();
Expand Down
18 changes: 18 additions & 0 deletions OMEdit/OMEditGUI/MainWindow.cpp
Expand Up @@ -46,6 +46,7 @@
#include "Plotting/VariablesWidget.h"
#if !defined(WITHOUT_OSG)
#include "Animation/ThreeDViewer.h"
#include "Animation/ViewerWidget.h"
#endif
#include "Util/Helper.h"
#include "Simulation/SimulationOutputWidget.h"
Expand Down Expand Up @@ -276,6 +277,7 @@ void MainWindow::setUpMainWindow()
mpThreeDViewerDockWidget->setWidget(mpThreeDViewer);
addDockWidget(Qt::RightDockWidgetArea, mpThreeDViewerDockWidget);
mpThreeDViewerDockWidget->hide();
connect(mpThreeDViewerDockWidget, SIGNAL(visibilityChanged(bool)), SLOT(threeDViewerDockWidgetVisibilityChanged(bool)));
#endif
// set the corners for the dock widgets
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
Expand Down Expand Up @@ -2359,6 +2361,22 @@ void MainWindow::documentationDockWidgetVisibilityChanged(bool visible)
}
}

/*!
* \brief MainWindow::threeDViewerDockWidgetVisibilityChanged
* Handles the VisibilityChanged signal of ThreeDViewer Dock Widget.
* \param visible
*/
void MainWindow::threeDViewerDockWidgetVisibilityChanged(bool visible)
{
#if !defined(WITHOUT_OSG)
if (visible) {
mpThreeDViewer->getViewerWidget()->update();
}
#else
Q_UNUSED(visible);
#endif
}

/*!
* \brief MainWindow::autoSave
* Slot activated when mpAutoSaveTimer timeout SIGNAL is raised.\n
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/MainWindow.h
Expand Up @@ -433,6 +433,7 @@ public slots:
private slots:
void perspectiveTabChanged(int tabIndex);
void documentationDockWidgetVisibilityChanged(bool visible);
void threeDViewerDockWidgetVisibilityChanged(bool visible);
void autoSave();
void switchToWelcomePerspectiveSlot();
void switchToModelingPerspectiveSlot();
Expand Down
9 changes: 3 additions & 6 deletions OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.cpp
Expand Up @@ -4711,7 +4711,6 @@ ModelWidgetContainer::ModelWidgetContainer(QWidget *pParent)
pModelSwitcherLayout->setContentsMargins(0, 0, 0, 0);
pModelSwitcherLayout->addWidget(mpRecentModelsList, 0, 0);
mpModelSwitcherDialog->setLayout(pModelSwitcherLayout);
mpLastActiveSubWindow = 0;
// install QApplication event filter to handle the ctrl+tab and ctrl+shift+tab
QApplication::instance()->installEventFilter(this);
connect(this, SIGNAL(subWindowActivated(QMdiSubWindow*)), SLOT(currentModelWidgetChanged(QMdiSubWindow*)));
Expand Down Expand Up @@ -5040,7 +5039,9 @@ void ModelWidgetContainer::updateThreeDViewer(ModelWidget *pModelWidget)
// write dummy csv file and visualization file
if (pModelWidget->writeCoSimulationResultFile(resultFileName) && pModelWidget->writeVisualXMLFile(visualXMLFileName, true)) {
MainWindow::instance()->getThreeDViewer()->stashView();
bool state = MainWindow::instance()->getThreeDViewerDockWidget()->blockSignals(true);
MainWindow::instance()->getThreeDViewerDockWidget()->show();
MainWindow::instance()->getThreeDViewerDockWidget()->blockSignals(state);
MainWindow::instance()->getThreeDViewer()->clearView();
MainWindow::instance()->getThreeDViewer()->openAnimationFile(resultFileName,true);
MainWindow::instance()->getThreeDViewer()->popView();
Expand Down Expand Up @@ -5211,13 +5212,9 @@ void ModelWidgetContainer::updateThreeDViewer(QMdiSubWindow *pSubWindow)
{
#if !defined(WITHOUT_OSG)
if (!pSubWindow) {
MainWindow::instance()->getThreeDViewer()->clearView();
return;
}
/* if the same sub window is activated again then just return */
if (mpLastActiveSubWindow == pSubWindow) {
return;
}
mpLastActiveSubWindow = pSubWindow;
ModelWidget *pModelWidget = qobject_cast<ModelWidget*>(pSubWindow->widget());
updateThreeDViewer(pModelWidget);
#else
Expand Down
1 change: 0 additions & 1 deletion OMEdit/OMEditGUI/Modeling/ModelWidgetContainer.h
Expand Up @@ -469,7 +469,6 @@ class ModelWidgetContainer : public QMdiArea
bool mShowGridLines;
QDialog *mpModelSwitcherDialog;
QListWidget *mpRecentModelsList;
QMdiSubWindow *mpLastActiveSubWindow;
void loadPreviousViewType(ModelWidget *pModelWidget);
public slots:
bool openRecentModelWidget(QListWidgetItem *pListWidgetItem);
Expand Down

0 comments on commit 418a7cd

Please sign in to comment.