Skip to content

Commit

Permalink
FMUSettingsDialog is a QDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
vwaurich authored and adeas31 committed Jan 10, 2017
1 parent 66eb20b commit 398fc36
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 24 deletions.
6 changes: 3 additions & 3 deletions OMEdit/OMEditGUI/Animation/AbstractAnimationWindow.cpp
Expand Up @@ -79,8 +79,7 @@ AbstractAnimationWindow::AbstractAnimationWindow(QWidget *pParent)
mpSpeedComboBox(nullptr),
mpPerspectiveDropDownBox(nullptr),
mpRotateCameraLeftAction(nullptr),
mpRotateCameraRightAction(nullptr),
mpFMUSettingsDialog(nullptr)
mpRotateCameraRightAction(nullptr)
{
// to distinguish this widget as a subwindow among the plotwindows
this->setObjectName(QString("animationWidget"));
Expand Down Expand Up @@ -221,7 +220,8 @@ QWidget* AbstractAnimationWindow::setupViewWidget()
*/
void AbstractAnimationWindow::openFMUSettingsDialog(VisualizerFMU* fmuVisualizer)
{
mpFMUSettingsDialog = new FMUSettingsDialog(this, fmuVisualizer);
FMUSettingsDialog *pFMUSettingsDialog = new FMUSettingsDialog(this, fmuVisualizer);
pFMUSettingsDialog->exec();
}

/*!
Expand Down
1 change: 0 additions & 1 deletion OMEdit/OMEditGUI/Animation/AbstractAnimationWindow.h
Expand Up @@ -86,7 +86,6 @@ class AbstractAnimationWindow : public QMainWindow, public osgViewer::CompositeV
QComboBox *mpPerspectiveDropDownBox;
QAction *mpRotateCameraLeftAction;
QAction *mpRotateCameraRightAction;
FMUSettingsDialog *mpFMUSettingsDialog;

void resetCamera();
void cameraPositionIsometric();
Expand Down
28 changes: 9 additions & 19 deletions OMEdit/OMEditGUI/Animation/FMUSettingsDialog.cpp
Expand Up @@ -47,25 +47,26 @@ FMUSettingsDialog::FMUSettingsDialog(QWidget *pParent, VisualizerFMU* fmuVisuali
renderFreq(0.1),
solver(Solver::EULER_FORWARD)
{
setAttribute(Qt::WA_DeleteOnClose);
//create dialog
mpSettingsDialog = new QDialog;
mpSettingsDialog->setWindowTitle("FMU-Simulation Settings");
mpSettingsDialog->setWindowIcon(QIcon(":/Resources/icons/animation.svg"));
this->setWindowTitle("FMU-Simulation Settings");
this->setWindowIcon(QIcon(":/Resources/icons/animation.svg"));

//the layouts
QVBoxLayout *mainLayout = new QVBoxLayout;
QGridLayout *settingsLayOut = new QGridLayout;
//the widgets
mpButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
QLabel *solverLabel = new QLabel(tr("Solver"));
mpSolverComboBox = new QComboBox(mpSettingsDialog);
mpSolverComboBox = new QComboBox();
mpSolverComboBox->addItem(QString("Explicit Euler"));
QLabel *stepsizeLabel = new QLabel(tr("Step Size [s]"));
mpStepsizeLineEdit = new QLineEdit(QString::number(stepSize));
QLabel *handleEventsLabel = new QLabel(tr("Process Events in FMU"));
mpHandleEventsCheck = new QCheckBox();
mpHandleEventsCheck->setCheckState(Qt::Checked);
//assemble
mpSettingsDialog->setLayout(mainLayout);
this->setLayout(mainLayout);
mainLayout->addLayout(settingsLayOut);
settingsLayOut->addWidget(solverLabel,0,0);
settingsLayOut->addWidget(mpSolverComboBox,0,1);
Expand All @@ -74,25 +75,14 @@ FMUSettingsDialog::FMUSettingsDialog(QWidget *pParent, VisualizerFMU* fmuVisuali
settingsLayOut->addWidget(handleEventsLabel,2,0);
settingsLayOut->addWidget(mpHandleEventsCheck,2,1);
mainLayout->addWidget(mpButtonBox);

//connections
QObject::connect(mpButtonBox, SIGNAL(accepted()), this,SLOT(saveSimSettings()));
QObject::connect(mpButtonBox, SIGNAL(rejected()), mpSettingsDialog,SLOT(close()));

mpSettingsDialog->exec();
QObject::connect(mpButtonBox, SIGNAL(rejected()), this,SLOT(reject()));
}

FMUSettingsDialog::~FMUSettingsDialog()
{
if (mpSettingsDialog)
delete mpSettingsDialog;
if (mpStepsizeLineEdit)
delete mpStepsizeLineEdit;
if (mpHandleEventsCheck)
delete mpHandleEventsCheck;
if (mpSolverComboBox)
delete mpSolverComboBox;
if (mpButtonBox)
delete mpButtonBox;
}

/*!
Expand All @@ -119,5 +109,5 @@ void FMUSettingsDialog::saveSimSettings()
}
//store in FMU simulator
fmu->setSimulationSettings(stepSize, solver, handleEvents);
mpSettingsDialog->close();
accept();
}
1 change: 0 additions & 1 deletion OMEdit/OMEditGUI/Animation/FMUSettingsDialog.h
Expand Up @@ -60,7 +60,6 @@ class FMUSettingsDialog : public QDialog
double renderFreq;
Solver solver;
bool handleEvents;
QDialog* mpSettingsDialog;
QLineEdit* mpStepsizeLineEdit;
QCheckBox* mpHandleEventsCheck;
QComboBox* mpSolverComboBox;
Expand Down

0 comments on commit 398fc36

Please sign in to comment.