Skip to content

Commit 1b6ac20

Browse files
committed
ticket:4402 Show plot window after simulation.
1 parent 6fbf5db commit 1b6ac20

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

OMEdit/OMEditGUI/Plotting/PlotWindowContainer.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,36 @@ PlotWindow* PlotWindowContainer::getCurrentWindow()
106106
}
107107
}
108108

109+
/*!
110+
* \brief PlotWindowContainer::getTopPlotWindow
111+
* Finds the top PlotWindow and returns it. If there is no PlotWindow then return 0.
112+
* \return
113+
*/
114+
PlotWindow* PlotWindowContainer::getTopPlotWindow()
115+
{
116+
QList<QMdiSubWindow*> subWindowsList = subWindowList(QMdiArea::ActivationHistoryOrder);
117+
for (int i = subWindowsList.size() - 1 ; i >= 0 ; i--) {
118+
if (0 != subWindowsList.at(i)->widget()->objectName().compare(QString("animationWidget"))) {
119+
return qobject_cast<PlotWindow*>(subWindowsList.at(i)->widget());
120+
}
121+
}
122+
return 0;
123+
}
124+
125+
/*!
126+
* \brief PlotWindowContainer::setTopPlotWindowActive
127+
* Finds the top PlotWindow and sets it as active subwindow.
128+
*/
129+
void PlotWindowContainer::setTopPlotWindowActive()
130+
{
131+
QList<QMdiSubWindow*> subWindowsList = subWindowList(QMdiArea::ActivationHistoryOrder);
132+
for (int i = subWindowsList.size() - 1 ; i >= 0 ; i--) {
133+
if (0 != subWindowsList.at(i)->widget()->objectName().compare(QString("animationWidget"))) {
134+
setActiveSubWindow(subWindowsList.at(i));
135+
}
136+
}
137+
}
138+
109139
#if !defined(WITHOUT_OSG)
110140
/*!
111141
* \brief PlotWindowContainer::getCurrentAnimationWindow

OMEdit/OMEditGUI/Plotting/PlotWindowContainer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class PlotWindowContainer : public QMdiArea
5151
PlotWindowContainer(QWidget *pParent = 0);
5252
QString getUniqueName(QString name = QString("Plot"), int number = 1);
5353
OMPlot::PlotWindow* getCurrentWindow();
54+
OMPlot::PlotWindow* getTopPlotWindow();
55+
void setTopPlotWindowActive();
5456
#if !defined(WITHOUT_OSG)
5557
AnimationWindow* getCurrentAnimationWindow();
5658
#endif

OMEdit/OMEditGUI/Simulation/SimulationDialog.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,9 +1326,11 @@ void SimulationDialog::simulationProcessFinished(SimulationOptions simulationOpt
13261326
pOMCProxy->closeSimulationResultFile();
13271327
if (list.size() > 0) {
13281328
if (OptionsDialog::instance()->getSimulationPage()->getSwitchToPlottingPerspectiveCheckBox()->isChecked()) {
1329+
bool showPlotWindow = true;
13291330
#if !defined(WITHOUT_OSG)
13301331
// if simulated with animation then open the animation directly.
13311332
if (mpLaunchAnimationCheckBox->isChecked()) {
1333+
showPlotWindow = false;
13321334
if (simulationOptions.getResultFileName().endsWith(".mat")) {
13331335
MainWindow::instance()->getPlotWindowContainer()->addAnimationWindow(MainWindow::instance()->getPlotWindowContainer()->subWindowList().isEmpty());
13341336
AnimationWindow *pAnimationWindow = MainWindow::instance()->getPlotWindowContainer()->getCurrentAnimationWindow();
@@ -1340,9 +1342,19 @@ void SimulationDialog::simulationProcessFinished(SimulationOptions simulationOpt
13401342
MessagesWidget::instance()->addGUIMessage(MessageItem(MessageItem::Modelica, "", false, 0, 0, 0, 0, msg, Helper::scriptingKind,
13411343
Helper::notificationLevel));
13421344
}
1345+
} else {
1346+
showPlotWindow = true;
13431347
}
13441348
#endif
13451349
MainWindow::instance()->getPerspectiveTabBar()->setCurrentIndex(2);
1350+
if (showPlotWindow) {
1351+
OMPlot::PlotWindow *pPlotWindow = MainWindow::instance()->getPlotWindowContainer()->getTopPlotWindow();
1352+
if (pPlotWindow) {
1353+
MainWindow::instance()->getPlotWindowContainer()->setTopPlotWindowActive();
1354+
} else {
1355+
MainWindow::instance()->getPlotWindowContainer()->addPlotWindow(MainWindow::instance()->getPlotWindowContainer()->subWindowList().isEmpty());
1356+
}
1357+
}
13461358
} else {
13471359
// stay in current perspective and show variables browser
13481360
MainWindow::instance()->getVariablesDockWidget()->show();

0 commit comments

Comments
 (0)