Skip to content

Commit

Permalink
ticket:4402 Show plot window after simulation.
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Apr 28, 2017
1 parent 6fbf5db commit 1b6ac20
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
30 changes: 30 additions & 0 deletions OMEdit/OMEditGUI/Plotting/PlotWindowContainer.cpp
Expand Up @@ -106,6 +106,36 @@ PlotWindow* PlotWindowContainer::getCurrentWindow()
}
}

/*!
* \brief PlotWindowContainer::getTopPlotWindow
* Finds the top PlotWindow and returns it. If there is no PlotWindow then return 0.
* \return
*/
PlotWindow* PlotWindowContainer::getTopPlotWindow()
{
QList<QMdiSubWindow*> subWindowsList = subWindowList(QMdiArea::ActivationHistoryOrder);
for (int i = subWindowsList.size() - 1 ; i >= 0 ; i--) {
if (0 != subWindowsList.at(i)->widget()->objectName().compare(QString("animationWidget"))) {
return qobject_cast<PlotWindow*>(subWindowsList.at(i)->widget());
}
}
return 0;
}

/*!
* \brief PlotWindowContainer::setTopPlotWindowActive
* Finds the top PlotWindow and sets it as active subwindow.
*/
void PlotWindowContainer::setTopPlotWindowActive()
{
QList<QMdiSubWindow*> subWindowsList = subWindowList(QMdiArea::ActivationHistoryOrder);
for (int i = subWindowsList.size() - 1 ; i >= 0 ; i--) {
if (0 != subWindowsList.at(i)->widget()->objectName().compare(QString("animationWidget"))) {
setActiveSubWindow(subWindowsList.at(i));
}
}
}

#if !defined(WITHOUT_OSG)
/*!
* \brief PlotWindowContainer::getCurrentAnimationWindow
Expand Down
2 changes: 2 additions & 0 deletions OMEdit/OMEditGUI/Plotting/PlotWindowContainer.h
Expand Up @@ -51,6 +51,8 @@ class PlotWindowContainer : public QMdiArea
PlotWindowContainer(QWidget *pParent = 0);
QString getUniqueName(QString name = QString("Plot"), int number = 1);
OMPlot::PlotWindow* getCurrentWindow();
OMPlot::PlotWindow* getTopPlotWindow();
void setTopPlotWindowActive();
#if !defined(WITHOUT_OSG)
AnimationWindow* getCurrentAnimationWindow();
#endif
Expand Down
12 changes: 12 additions & 0 deletions OMEdit/OMEditGUI/Simulation/SimulationDialog.cpp
Expand Up @@ -1326,9 +1326,11 @@ void SimulationDialog::simulationProcessFinished(SimulationOptions simulationOpt
pOMCProxy->closeSimulationResultFile();
if (list.size() > 0) {
if (OptionsDialog::instance()->getSimulationPage()->getSwitchToPlottingPerspectiveCheckBox()->isChecked()) {
bool showPlotWindow = true;
#if !defined(WITHOUT_OSG)
// if simulated with animation then open the animation directly.
if (mpLaunchAnimationCheckBox->isChecked()) {
showPlotWindow = false;
if (simulationOptions.getResultFileName().endsWith(".mat")) {
MainWindow::instance()->getPlotWindowContainer()->addAnimationWindow(MainWindow::instance()->getPlotWindowContainer()->subWindowList().isEmpty());
AnimationWindow *pAnimationWindow = MainWindow::instance()->getPlotWindowContainer()->getCurrentAnimationWindow();
Expand All @@ -1340,9 +1342,19 @@ void SimulationDialog::simulationProcessFinished(SimulationOptions simulationOpt
MessagesWidget::instance()->addGUIMessage(MessageItem(MessageItem::Modelica, "", false, 0, 0, 0, 0, msg, Helper::scriptingKind,
Helper::notificationLevel));
}
} else {
showPlotWindow = true;
}
#endif
MainWindow::instance()->getPerspectiveTabBar()->setCurrentIndex(2);
if (showPlotWindow) {
OMPlot::PlotWindow *pPlotWindow = MainWindow::instance()->getPlotWindowContainer()->getTopPlotWindow();
if (pPlotWindow) {
MainWindow::instance()->getPlotWindowContainer()->setTopPlotWindowActive();
} else {
MainWindow::instance()->getPlotWindowContainer()->addPlotWindow(MainWindow::instance()->getPlotWindowContainer()->subWindowList().isEmpty());
}
}
} else {
// stay in current perspective and show variables browser
MainWindow::instance()->getVariablesDockWidget()->show();
Expand Down

0 comments on commit 1b6ac20

Please sign in to comment.