Skip to content

Commit 7c94730

Browse files
committed
Keep Variables Browser if shown in Modeling Perspective
This enables edit/simulate/re-simulate cycles directly in the modeling perspective -- useful for steady-state models and maybe also in the future if the model diagram will be animated.
1 parent 52f9e6f commit 7c94730

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

OMEdit/OMEditGUI/MainWindow.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ MainWindow::MainWindow(QSplashScreen *pSplashScreen, bool debug, QWidget *parent
225225
mpVariablesDockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
226226
addDockWidget(Qt::RightDockWidgetArea, mpVariablesDockWidget);
227227
mpVariablesDockWidget->setWidget(mpVariablesWidget);
228+
mShowVariablesWithModel = false;
229+
mPreviousPerspective = -1;
228230
// set the corners for the dock widgets
229231
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
230232
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
@@ -2955,13 +2957,17 @@ void MainWindow::switchToWelcomePerspective()
29552957
mpUndoAction->setEnabled(false);
29562958
mpRedoAction->setEnabled(false);
29572959
mpModelSwitcherToolButton->setEnabled(false);
2960+
if (mPreviousPerspective == 1) {
2961+
mShowVariablesWithModel = mpVariablesDockWidget->isVisible();
2962+
}
29582963
mpVariablesDockWidget->hide();
29592964
mpStackFramesDockWidget->hide();
29602965
mpBreakpointsDockWidget->hide();
29612966
mpLocalsDockWidget->hide();
29622967
mpTargetOutputDockWidget->hide();
29632968
mpGDBLoggerDockWidget->hide();
29642969
mpPlotToolBar->setEnabled(false);
2970+
mPreviousPerspective = 0;
29652971
}
29662972

29672973
/*!
@@ -2972,19 +2978,25 @@ void MainWindow::switchToModelingPerspective()
29722978
{
29732979
mpCentralStackedWidget->setCurrentWidget(mpModelWidgetContainer);
29742980
mpModelWidgetContainer->currentModelWidgetChanged(mpModelWidgetContainer->getCurrentMdiSubWindow());
2975-
mpVariablesDockWidget->hide();
2976-
mpPlotToolBar->setEnabled(false);
2981+
if (mShowVariablesWithModel) {
2982+
mpVariablesDockWidget->show();
2983+
mpPlotToolBar->setEnabled(true);
2984+
}
2985+
else {
2986+
mpVariablesDockWidget->hide();
2987+
mpPlotToolBar->setEnabled(false);
2988+
}
29772989
// In case user has tabbed the dock widgets then make LibraryWidget active.
29782990
QList<QDockWidget*> tabifiedDockWidgetsList = tabifiedDockWidgets(mpLibraryDockWidget);
29792991
if (tabifiedDockWidgetsList.size() > 0) {
29802992
tabifyDockWidget(tabifiedDockWidgetsList.at(0), mpLibraryDockWidget);
29812993
}
2982-
mpVariablesDockWidget->hide();
29832994
mpStackFramesDockWidget->hide();
29842995
mpBreakpointsDockWidget->hide();
29852996
mpLocalsDockWidget->hide();
29862997
mpTargetOutputDockWidget->hide();
29872998
mpGDBLoggerDockWidget->hide();
2999+
mPreviousPerspective = 1;
29883000
}
29893001

29903002
/*!
@@ -3012,19 +3024,22 @@ void MainWindow::switchToPlottingPerspective()
30123024
if (mpPlotWindowContainer->subWindowList().size() == 0) {
30133025
mpPlotWindowContainer->addPlotWindow(true);
30143026
}
3027+
if (mPreviousPerspective == 1) {
3028+
mShowVariablesWithModel = mpVariablesDockWidget->isVisible();
3029+
}
30153030
mpVariablesDockWidget->show();
30163031
mpPlotToolBar->setEnabled(true);
30173032
// In case user has tabbed the dock widgets then make VariablesWidget active.
30183033
QList<QDockWidget*> tabifiedDockWidgetsList = tabifiedDockWidgets(mpVariablesDockWidget);
30193034
if (tabifiedDockWidgetsList.size() > 0) {
30203035
tabifyDockWidget(tabifiedDockWidgetsList.at(0), mpVariablesDockWidget);
30213036
}
3022-
mpVariablesDockWidget->show();
30233037
mpStackFramesDockWidget->hide();
30243038
mpBreakpointsDockWidget->hide();
30253039
mpLocalsDockWidget->hide();
30263040
mpTargetOutputDockWidget->hide();
30273041
mpGDBLoggerDockWidget->hide();
3042+
mPreviousPerspective = 2;
30283043
}
30293044

30303045
/*!
@@ -3035,6 +3050,9 @@ void MainWindow::switchToAlgorithmicDebuggingPerspective()
30353050
{
30363051
mpCentralStackedWidget->setCurrentWidget(mpModelWidgetContainer);
30373052
mpModelWidgetContainer->currentModelWidgetChanged(mpModelWidgetContainer->getCurrentMdiSubWindow());
3053+
if (mPreviousPerspective == 1) {
3054+
mShowVariablesWithModel = mpVariablesDockWidget->isVisible();
3055+
}
30383056
mpVariablesDockWidget->hide();
30393057
mpPlotToolBar->setEnabled(false);
30403058
// In case user has tabbed the dock widgets then make LibraryWidget active.
@@ -3047,6 +3065,7 @@ void MainWindow::switchToAlgorithmicDebuggingPerspective()
30473065
mpLocalsDockWidget->show();
30483066
mpTargetOutputDockWidget->show();
30493067
mpGDBLoggerDockWidget->show();
3068+
mPreviousPerspective = 3;
30503069
}
30513070

30523071
/*!

OMEdit/OMEditGUI/MainWindow.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ class MainWindow : public QMainWindow
134134
Label* getPointerXPositionLabel() {return mpPointerXPositionLabel;}
135135
Label* getPointerYPositionLabel() {return mpPointerYPositionLabel;}
136136
QTabBar* getPerspectiveTabBar() {return mpPerspectiveTabbar;}
137+
QToolBar* getPlotToolBar() {return mpPlotToolBar;}
137138
QTimer* getAutoSaveTimer() {return mpAutoSaveTimer;}
138139
QAction* getSaveAction() {return mpSaveAction;}
139140
QAction* getSaveAsAction() {return mpSaveAsAction;}
@@ -210,6 +211,8 @@ class MainWindow : public QMainWindow
210211
bool mDebug;
211212
OMCProxy *mpOMCProxy;
212213
bool mExitApplicationStatus;
214+
bool mShowVariablesWithModel;
215+
int mPreviousPerspective;
213216
OptionsDialog *mpOptionsDialog;
214217
MessagesWidget *mpMessagesWidget;
215218
QDockWidget *mpMessagesDockWidget;

OMEdit/OMEditGUI/Simulation/SimulationDialog.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1270,7 +1270,15 @@ void SimulationDialog::simulationProcessFinished(SimulationOptions simulationOpt
12701270
// close the simulation result file.
12711271
pOMCProxy->closeSimulationResultFile();
12721272
if (list.size() > 0) {
1273-
mpMainWindow->getPerspectiveTabBar()->setCurrentIndex(2);
1273+
if (mpMainWindow->getVariablesDockWidget()->isVisible()
1274+
&& !mpLaunchAnimationCheckBox->isChecked()) {
1275+
// stay in current perspective and enable re-simulation
1276+
mpMainWindow->getPlotToolBar()->setEnabled(true);
1277+
}
1278+
else {
1279+
// switch to plotting perspective
1280+
mpMainWindow->getPerspectiveTabBar()->setCurrentIndex(2);
1281+
}
12741282
// if simulated with animation then open the animation directly.
12751283
if (mpLaunchAnimationCheckBox->isChecked()) {
12761284
mpMainWindow->getPlotWindowContainer()->addAnimationWindow();

0 commit comments

Comments
 (0)