Skip to content

Commit

Permalink
Options for keeping the variables browser shown in Modeling perspective.
Browse files Browse the repository at this point in the history
  • Loading branch information
adeas31 committed Oct 18, 2016
1 parent 62ed426 commit e923b7a
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 42 deletions.
41 changes: 16 additions & 25 deletions OMEdit/OMEditGUI/MainWindow.cpp
Expand Up @@ -225,8 +225,6 @@ MainWindow::MainWindow(QSplashScreen *pSplashScreen, bool debug, QWidget *parent
mpVariablesDockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
addDockWidget(Qt::RightDockWidgetArea, mpVariablesDockWidget);
mpVariablesDockWidget->setWidget(mpVariablesWidget);
mShowVariablesWithModel = true;
mPreviousPerspective = -1;
// set the corners for the dock widgets
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
Expand All @@ -238,6 +236,8 @@ MainWindow::MainWindow(QSplashScreen *pSplashScreen, bool debug, QWidget *parent
createActions();
createToolbars();
createMenus();
// enable/disable re-simulation toolbar based on variables browser visibiltiy.
connect(mpVariablesDockWidget, SIGNAL(visibilityChanged(bool)), mpReSimulationToolBar, SLOT(setEnabled(bool)));
// Create simulation dialog when needed
mpSimulationDialog = 0;
// Create TLM co-simulation dialog when needed
Expand Down Expand Up @@ -536,7 +536,6 @@ void MainWindow::openResultFiles(QStringList fileNames)
if (list.size() > 0) {
mpPerspectiveTabbar->setCurrentIndex(2);
mpVariablesWidget->insertVariablesItemsToTree(fileInfo.fileName(), fileInfo.absoluteDir().absolutePath(), list, SimulationOptions());
mpVariablesDockWidget->show();
}
}
}
Expand Down Expand Up @@ -2809,6 +2808,7 @@ void MainWindow::createMenus()
pViewToolbarsMenu->addAction(mpViewToolBar->toggleViewAction());
pViewToolbarsMenu->addAction(mpShapesToolBar->toggleViewAction());
pViewToolbarsMenu->addAction(mpSimulationToolBar->toggleViewAction());
pViewToolbarsMenu->addAction(mpReSimulationToolBar->toggleViewAction());
pViewToolbarsMenu->addAction(mpPlotToolBar->toggleViewAction());
pViewToolbarsMenu->addAction(mpModelSwitcherToolBar->toggleViewAction());
// Add Actions to Windows View Sub Menu
Expand Down Expand Up @@ -2957,17 +2957,15 @@ void MainWindow::switchToWelcomePerspective()
mpUndoAction->setEnabled(false);
mpRedoAction->setEnabled(false);
mpModelSwitcherToolButton->setEnabled(false);
if (mPreviousPerspective == 1) {
mShowVariablesWithModel = mpVariablesDockWidget->isVisible();
if (mpOptionsDialog->getGeneralSettingsPage()->getHideVariablesBrowserCheckBox()->isChecked()) {
mpVariablesDockWidget->hide();
}
mpVariablesDockWidget->hide();
mpStackFramesDockWidget->hide();
mpBreakpointsDockWidget->hide();
mpLocalsDockWidget->hide();
mpTargetOutputDockWidget->hide();
mpGDBLoggerDockWidget->hide();
mpPlotToolBar->setEnabled(false);
mPreviousPerspective = 0;
}

/*!
Expand All @@ -2978,14 +2976,10 @@ void MainWindow::switchToModelingPerspective()
{
mpCentralStackedWidget->setCurrentWidget(mpModelWidgetContainer);
mpModelWidgetContainer->currentModelWidgetChanged(mpModelWidgetContainer->getCurrentMdiSubWindow());
if (mShowVariablesWithModel) {
mpVariablesDockWidget->show();
mpPlotToolBar->setEnabled(true);
}
else {
if (mpOptionsDialog->getGeneralSettingsPage()->getHideVariablesBrowserCheckBox()->isChecked()) {
mpVariablesDockWidget->hide();
mpPlotToolBar->setEnabled(false);
}
mpPlotToolBar->setEnabled(false);
// In case user has tabbed the dock widgets then make LibraryWidget active.
QList<QDockWidget*> tabifiedDockWidgetsList = tabifiedDockWidgets(mpLibraryDockWidget);
if (tabifiedDockWidgetsList.size() > 0) {
Expand All @@ -2996,7 +2990,6 @@ void MainWindow::switchToModelingPerspective()
mpLocalsDockWidget->hide();
mpTargetOutputDockWidget->hide();
mpGDBLoggerDockWidget->hide();
mPreviousPerspective = 1;
}

/*!
Expand Down Expand Up @@ -3024,9 +3017,6 @@ void MainWindow::switchToPlottingPerspective()
if (mpPlotWindowContainer->subWindowList().size() == 0) {
mpPlotWindowContainer->addPlotWindow(true);
}
if (mPreviousPerspective == 1) {
mShowVariablesWithModel = mpVariablesDockWidget->isVisible();
}
mpVariablesDockWidget->show();
mpPlotToolBar->setEnabled(true);
// In case user has tabbed the dock widgets then make VariablesWidget active.
Expand All @@ -3039,7 +3029,6 @@ void MainWindow::switchToPlottingPerspective()
mpLocalsDockWidget->hide();
mpTargetOutputDockWidget->hide();
mpGDBLoggerDockWidget->hide();
mPreviousPerspective = 2;
}

/*!
Expand All @@ -3050,10 +3039,9 @@ void MainWindow::switchToAlgorithmicDebuggingPerspective()
{
mpCentralStackedWidget->setCurrentWidget(mpModelWidgetContainer);
mpModelWidgetContainer->currentModelWidgetChanged(mpModelWidgetContainer->getCurrentMdiSubWindow());
if (mPreviousPerspective == 1) {
mShowVariablesWithModel = mpVariablesDockWidget->isVisible();
if (mpOptionsDialog->getGeneralSettingsPage()->getHideVariablesBrowserCheckBox()->isChecked()) {
mpVariablesDockWidget->hide();
}
mpVariablesDockWidget->hide();
mpPlotToolBar->setEnabled(false);
// In case user has tabbed the dock widgets then make LibraryWidget active.
QList<QDockWidget*> tabifiedDockWidgetsList = tabifiedDockWidgets(mpLibraryDockWidget);
Expand All @@ -3065,7 +3053,6 @@ void MainWindow::switchToAlgorithmicDebuggingPerspective()
mpLocalsDockWidget->show();
mpTargetOutputDockWidget->show();
mpGDBLoggerDockWidget->show();
mPreviousPerspective = 3;
}

/*!
Expand Down Expand Up @@ -3216,14 +3203,18 @@ void MainWindow::createToolbars()
mpModelSwitcherToolButton->setIcon(QIcon(":/Resources/icons/switch.svg"));
connect(mpModelSwitcherToolButton, SIGNAL(clicked()), this, SLOT(openRecentModelWidget()));
mpModelSwitcherToolBar->addWidget(mpModelSwitcherToolButton);
// Re-simulation Toolbar
mpReSimulationToolBar = addToolBar(tr("Re-simulation Toolbar"));
mpReSimulationToolBar->setObjectName("Re-simulation Toolbar");
mpReSimulationToolBar->setAllowedAreas(Qt::TopToolBarArea);
// add actions to Re-simulation Toolbar
mpReSimulationToolBar->addAction(mpReSimulateModelAction);
mpReSimulationToolBar->addAction(mpReSimulateSetupAction);
// Plot Toolbar
mpPlotToolBar = addToolBar(tr("Plot Toolbar"));
mpPlotToolBar->setObjectName("Plot Toolbar");
mpPlotToolBar->setAllowedAreas(Qt::TopToolBarArea);
// add actions to Plot Toolbar
mpPlotToolBar->addAction(mpReSimulateModelAction);
mpPlotToolBar->addAction(mpReSimulateSetupAction);
mpPlotToolBar->addSeparator();
mpPlotToolBar->addAction(mpNewPlotWindowAction);
mpPlotToolBar->addAction(mpNewParametricPlotWindowAction);
mpPlotToolBar->addAction(mpNewAnimationWindowAction);
Expand Down
3 changes: 1 addition & 2 deletions OMEdit/OMEditGUI/MainWindow.h
Expand Up @@ -211,8 +211,6 @@ class MainWindow : public QMainWindow
bool mDebug;
OMCProxy *mpOMCProxy;
bool mExitApplicationStatus;
bool mShowVariablesWithModel;
int mPreviousPerspective;
OptionsDialog *mpOptionsDialog;
MessagesWidget *mpMessagesWidget;
QDockWidget *mpMessagesDockWidget;
Expand Down Expand Up @@ -364,6 +362,7 @@ class MainWindow : public QMainWindow
QToolBar *mpModelSwitcherToolBar;
QToolButton *mpModelSwitcherToolButton;
QMenu *mpModelSwitcherMenu;
QToolBar *mpReSimulationToolBar;
QToolBar *mpPlotToolBar;
QToolBar *mpTLMSimulationToolbar;
QHash<QString, TransformationsWidget*> mTransformationsWidgetHash;
Expand Down
21 changes: 20 additions & 1 deletion OMEdit/OMEditGUI/Options/OptionsDialog.cpp
Expand Up @@ -137,6 +137,10 @@ void OptionsDialog::readGeneralSettings()
if (mpSettings->contains("terminalCommandArgs")) {
mpGeneralSettingsPage->setTerminalCommandArguments(mpSettings->value("terminalCommandArgs").toString());
}
// read hide variables browser
if (mpSettings->contains("hideVariablesBrowser")) {
mpGeneralSettingsPage->getHideVariablesBrowserCheckBox()->setChecked(mpSettings->value("hideVariablesBrowser").toBool());
}
// read library icon size
if (mpSettings->contains("libraryIconSize")) {
mpGeneralSettingsPage->getLibraryIconSizeSpinBox()->setValue(mpSettings->value("libraryIconSize").toInt());
Expand Down Expand Up @@ -453,6 +457,9 @@ void OptionsDialog::readSimulationSettings()
if (mpSettings->contains("simulation/saveClassBeforeSimulation")) {
mpSimulationPage->getSaveClassBeforeSimulationCheckBox()->setChecked(mpSettings->value("simulation/saveClassBeforeSimulation").toBool());
}
if (mpSettings->contains("simulation/switchToPlottingPerspectiveAfterSimulation")) {
mpSimulationPage->getSwitchToPlottingPerspectiveCheckBox()->setChecked(mpSettings->value("simulation/switchToPlottingPerspectiveAfterSimulation").toBool());
}
if (mpSettings->contains("simulation/outputMode")) {
mpSimulationPage->setOutputMode(mpSettings->value("simulation/outputMode").toString());
}
Expand Down Expand Up @@ -716,6 +723,8 @@ void OptionsDialog::saveGeneralSettings()
mpSettings->setValue("terminalCommand", mpGeneralSettingsPage->getTerminalCommand());
// save terminal command arguments
mpSettings->setValue("terminalCommandArgs", mpGeneralSettingsPage->getTerminalCommandArguments());
// save hide variables browser
mpSettings->setValue("hideVariablesBrowser", mpGeneralSettingsPage->getHideVariablesBrowserCheckBox()->isChecked());
// save library icon size
mpSettings->setValue("libraryIconSize", mpGeneralSettingsPage->getLibraryIconSizeSpinBox()->value());
// save show protected classes
Expand Down Expand Up @@ -928,6 +937,7 @@ void OptionsDialog::saveSimulationSettings()
}
// save class before simulation.
mpSettings->setValue("simulation/saveClassBeforeSimulation", mpSimulationPage->getSaveClassBeforeSimulationCheckBox()->isChecked());
mpSettings->setValue("simulation/switchToPlottingPerspectiveAfterSimulation", mpSimulationPage->getSwitchToPlottingPerspectiveCheckBox()->isChecked());
mpSettings->setValue("simulation/outputMode", mpSimulationPage->getOutputMode());
}

Expand Down Expand Up @@ -1379,6 +1389,10 @@ GeneralSettingsPage::GeneralSettingsPage(OptionsDialog *pOptionsDialog)
// terminal command args
mpTerminalCommandArgumentsLabel = new Label(tr("Terminal Command Arguments:"));
mpTerminalCommandArgumentsTextBox = new QLineEdit;
// hide variables browser checkbox
mpHideVariablesBrowserCheckBox = new QCheckBox(tr("Hide Variables Browser"));
mpHideVariablesBrowserCheckBox->setToolTip(tr("Hides the variable browser when switching away from plotting perspective."));
mpHideVariablesBrowserCheckBox->setChecked(true);
// set the layout of general settings group
QGridLayout *generalSettingsLayout = new QGridLayout;
generalSettingsLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
Expand All @@ -1395,6 +1409,7 @@ GeneralSettingsPage::GeneralSettingsPage(OptionsDialog *pOptionsDialog)
generalSettingsLayout->addWidget(mpTerminalCommandBrowseButton, 4, 2);
generalSettingsLayout->addWidget(mpTerminalCommandArgumentsLabel, 5, 0);
generalSettingsLayout->addWidget(mpTerminalCommandArgumentsTextBox, 5, 1, 1, 2);
generalSettingsLayout->addWidget(mpHideVariablesBrowserCheckBox, 6, 0, 1, 3);
mpGeneralSettingsGroupBox->setLayout(generalSettingsLayout);
// Libraries Browser group box
mpLibrariesBrowserGroupBox = new QGroupBox(tr("Libraries Browser"));
Expand Down Expand Up @@ -3013,6 +3028,9 @@ SimulationPage::SimulationPage(OptionsDialog *pOptionsDialog)
mpSaveClassBeforeSimulationCheckBox = new QCheckBox(tr("Save class before simulation"));
mpSaveClassBeforeSimulationCheckBox->setToolTip(tr("Disabling this will effect the debugger functionality."));
mpSaveClassBeforeSimulationCheckBox->setChecked(true);
/* switch to plotting perspective after simulation checkbox */
mpSwitchToPlottingPerspectiveCheckBox = new QCheckBox(tr("Switch to plotting perspective after simulation"));
mpSwitchToPlottingPerspectiveCheckBox->setChecked(true);
// simulation output format
mpOutputGroupBox = new QGroupBox(Helper::output);
mpStructuredRadioButton = new QRadioButton(tr("Structured"));
Expand Down Expand Up @@ -3049,7 +3067,8 @@ SimulationPage::SimulationPage(OptionsDialog *pOptionsDialog)
pSimulationLayout->addWidget(mpIgnoreCommandLineOptionsAnnotationCheckBox, 5, 0, 1, 3);
pSimulationLayout->addWidget(mpIgnoreSimulationFlagsAnnotationCheckBox, 6, 0, 1, 3);
pSimulationLayout->addWidget(mpSaveClassBeforeSimulationCheckBox, 7, 0, 1, 3);
pSimulationLayout->addWidget(mpOutputGroupBox, 8, 0, 1, 3);
pSimulationLayout->addWidget(mpSwitchToPlottingPerspectiveCheckBox, 8, 0, 1, 3);
pSimulationLayout->addWidget(mpOutputGroupBox, 9, 0, 1, 3);
mpSimulationGroupBox->setLayout(pSimulationLayout);
// set the layout
QVBoxLayout *pLayout = new QVBoxLayout;
Expand Down
4 changes: 4 additions & 0 deletions OMEdit/OMEditGUI/Options/OptionsDialog.h
Expand Up @@ -182,6 +182,7 @@ class GeneralSettingsPage : public QWidget
QString getTerminalCommand() {return mpTerminalCommandTextBox->text();}
void setTerminalCommandArguments(QString value) {mpTerminalCommandArgumentsTextBox->setText(value);}
QString getTerminalCommandArguments() {return mpTerminalCommandArgumentsTextBox->text();}
QCheckBox* getHideVariablesBrowserCheckBox() {return mpHideVariablesBrowserCheckBox;}
QSpinBox* getLibraryIconSizeSpinBox() {return mpLibraryIconSizeSpinBox;}
void setShowProtectedClasses(bool value);
bool getShowProtectedClasses();
Expand Down Expand Up @@ -210,6 +211,7 @@ class GeneralSettingsPage : public QWidget
QPushButton *mpTerminalCommandBrowseButton;
Label *mpTerminalCommandArgumentsLabel;
QLineEdit *mpTerminalCommandArgumentsTextBox;
QCheckBox *mpHideVariablesBrowserCheckBox;
QGroupBox *mpLibrariesBrowserGroupBox;
Label *mpLibraryIconSizeLabel;
QSpinBox *mpLibraryIconSizeSpinBox;
Expand Down Expand Up @@ -519,6 +521,7 @@ class SimulationPage : public QWidget
QCheckBox* getIgnoreCommandLineOptionsAnnotationCheckBox() {return mpIgnoreCommandLineOptionsAnnotationCheckBox;}
QCheckBox* getIgnoreSimulationFlagsAnnotationCheckBox() {return mpIgnoreSimulationFlagsAnnotationCheckBox;}
QCheckBox* getSaveClassBeforeSimulationCheckBox() {return mpSaveClassBeforeSimulationCheckBox;}
QCheckBox* getSwitchToPlottingPerspectiveCheckBox() {return mpSwitchToPlottingPerspectiveCheckBox;}
void setOutputMode(QString value);
QString getOutputMode();
private:
Expand All @@ -538,6 +541,7 @@ class SimulationPage : public QWidget
QCheckBox *mpIgnoreCommandLineOptionsAnnotationCheckBox;
QCheckBox *mpIgnoreSimulationFlagsAnnotationCheckBox;
QCheckBox *mpSaveClassBeforeSimulationCheckBox;
QCheckBox *mpSwitchToPlottingPerspectiveCheckBox;
QGroupBox *mpOutputGroupBox;
QRadioButton *mpStructuredRadioButton;
QRadioButton *mpFormattedTextRadioButton;
Expand Down
32 changes: 18 additions & 14 deletions OMEdit/OMEditGUI/Simulation/SimulationDialog.cpp
Expand Up @@ -1256,6 +1256,13 @@ void SimulationDialog::showAlgorithmicDebugger(SimulationOptions simulationOptio
}
}

/*!
* \brief SimulationDialog::simulationProcessFinished
* \param simulationOptions
* \param resultFileLastModifiedDateTime
* Handles what should be done after the simulation process has finished.\n
* Reads the result variables and inserts them into the variables browser.\n
*/
void SimulationDialog::simulationProcessFinished(SimulationOptions simulationOptions, QDateTime resultFileLastModifiedDateTime)
{
QString workingDirectory = simulationOptions.getWorkingDirectory();
Expand All @@ -1270,22 +1277,19 @@ void SimulationDialog::simulationProcessFinished(SimulationOptions simulationOpt
// close the simulation result file.
pOMCProxy->closeSimulationResultFile();
if (list.size() > 0) {
if (mpMainWindow->getVariablesDockWidget()->isVisible()
&& !mpLaunchAnimationCheckBox->isChecked()) {
// stay in current perspective and enable re-simulation
mpMainWindow->getPlotToolBar()->setEnabled(true);
}
else {
// switch to plotting perspective
if (mpMainWindow->getOptionsDialog()->getSimulationPage()->getSwitchToPlottingPerspectiveCheckBox()->isChecked()) {
mpMainWindow->getPerspectiveTabBar()->setCurrentIndex(2);
}
// if simulated with animation then open the animation directly.
if (mpLaunchAnimationCheckBox->isChecked()) {
mpMainWindow->getPlotWindowContainer()->addAnimationWindow();
AnimationWindow *pAnimationWindow = mpMainWindow->getPlotWindowContainer()->getCurrentAnimationWindow();
if (pAnimationWindow) {
pAnimationWindow->openAnimationFile(simulationOptions.getResultFileName());
// if simulated with animation then open the animation directly.
if (mpLaunchAnimationCheckBox->isChecked()) {
mpMainWindow->getPlotWindowContainer()->addAnimationWindow();
AnimationWindow *pAnimationWindow = mpMainWindow->getPlotWindowContainer()->getCurrentAnimationWindow();
if (pAnimationWindow) {
pAnimationWindow->openAnimationFile(simulationOptions.getResultFileName());
}
}
} else {
// stay in current perspective and show variables browser
mpMainWindow->getVariablesDockWidget()->show();
}
pVariablesWidget->insertVariablesItemsToTree(simulationOptions.getResultFileName(), workingDirectory, list, simulationOptions);
}
Expand Down

0 comments on commit e923b7a

Please sign in to comment.