Skip to content

Commit efbdcda

Browse files
authored
Save the experiment annotation without simulating the model (#8549)
Fixes #8538
1 parent 8d0b1ce commit efbdcda

File tree

3 files changed

+110
-107
lines changed

3 files changed

+110
-107
lines changed

OMEdit/OMEditLIB/Simulation/SimulationDialog.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,7 @@ SimulationOptions SimulationDialog::createSimulationOptions()
14611461
* Creates the SimulationOutputWidget.
14621462
* \param simulationOptions
14631463
*/
1464-
void SimulationDialog::createAndShowSimulationOutputWidget(SimulationOptions simulationOptions)
1464+
void SimulationDialog::createAndShowSimulationOutputWidget(const SimulationOptions &simulationOptions)
14651465
{
14661466
/* If resimulation and show algorithmic debugger is checked then show algorithmic debugger.
14671467
* Otherwise run the normal resimulation.
@@ -1526,8 +1526,7 @@ void SimulationDialog::saveExperimentAnnotation()
15261526
// if we have ModelWidget for class then put the change on undo stack.
15271527
if (mpLibraryTreeItem->getModelWidget()) {
15281528
UpdateClassAnnotationCommand *pUpdateClassExperimentAnnotationCommand;
1529-
pUpdateClassExperimentAnnotationCommand = new UpdateClassAnnotationCommand(mpLibraryTreeItem, oldExperimentAnnotation,
1530-
newExperimentAnnotation);
1529+
pUpdateClassExperimentAnnotationCommand = new UpdateClassAnnotationCommand(mpLibraryTreeItem, oldExperimentAnnotation, newExperimentAnnotation);
15311530
mpLibraryTreeItem->getModelWidget()->getUndoStack()->push(pUpdateClassExperimentAnnotationCommand);
15321531
mpLibraryTreeItem->getModelWidget()->updateModelText();
15331532
} else {
@@ -1721,9 +1720,13 @@ void SimulationDialog::saveTranslationFlagsAnnotation()
17211720
}
17221721
}
17231722

1724-
void SimulationDialog::performSimulation()
1723+
/*!
1724+
* \brief SimulationDialog::performSimulation
1725+
* Translates the model and starts the simulation.
1726+
* \param simulationOptions
1727+
*/
1728+
void SimulationDialog::performSimulation(const SimulationOptions &simulationOptions)
17251729
{
1726-
SimulationOptions simulationOptions;
17271730
QString simulationParameters;
17281731
/* build the simulation parameters */
17291732
simulationParameters.append("startTime=").append(mpStartTimeTextBox->text());
@@ -1758,11 +1761,6 @@ void SimulationDialog::performSimulation()
17581761
if (!mpCflagsTextBox->text().isEmpty()) {
17591762
simulationParameters.append(", cflags=").append("\"").append(mpCflagsTextBox->text()).append("\"");
17601763
}
1761-
simulationOptions = createSimulationOptions();
1762-
// If we are not doing a re-simulation then save the new SimulationOptions in the class.
1763-
if (!mIsReSimulate) {
1764-
mpLibraryTreeItem->mSimulationOptions = simulationOptions;
1765-
}
17661764
// change the cursor to Qt::WaitCursor
17671765
QApplication::setOverrideCursor(Qt::WaitCursor);
17681766
// show the progress bar
@@ -2223,9 +2221,14 @@ void SimulationDialog::showSimulationFlagsHelp()
22232221
void SimulationDialog::simulate()
22242222
{
22252223
if (validate()) {
2224+
SimulationOptions simulationOptions = createSimulationOptions();
2225+
// If we are not doing a re-simulation then save the new SimulationOptions in the class.
2226+
if (!mIsReSimulate) {
2227+
mpLibraryTreeItem->mSimulationOptions = simulationOptions;
2228+
}
22262229
// interactive simulation
22272230
if (mpInteractiveSimulationGroupBox->isChecked() || mIsReSimulate) {
2228-
performSimulation();
2231+
performSimulation(simulationOptions);
22292232
} else {
22302233
// if no option is selected then show error message to user
22312234
if (!(mpSaveExperimentAnnotationCheckBox->isChecked() ||
@@ -2254,7 +2257,7 @@ void SimulationDialog::simulate()
22542257
mpLibraryTreeItem->getModelWidget()->endMacro();
22552258
}
22562259
if (mpSimulateCheckBox->isChecked()) {
2257-
performSimulation();
2260+
performSimulation(simulationOptions);
22582261
}
22592262
}
22602263
if (isVisible()) {

OMEdit/OMEditLIB/Simulation/SimulationDialog.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,12 @@ class SimulationDialog : public QDialog
194194
void applySimulationOptions(SimulationOptions simulationOptions);
195195
bool translateModel(QString simulationParameters);
196196
SimulationOptions createSimulationOptions();
197-
void createAndShowSimulationOutputWidget(SimulationOptions simulationOptions);
197+
void createAndShowSimulationOutputWidget(const SimulationOptions &simulationOptions);
198198
void showSimulationOutputWidget(SimulationOutputWidget *pSimulationOutputWidget);
199199
void saveExperimentAnnotation();
200200
void saveSimulationFlagsAnnotation();
201201
void saveTranslationFlagsAnnotation();
202-
void performSimulation();
202+
void performSimulation(const SimulationOptions &simulationOptions);
203203
void saveDialogGeometry();
204204
void killSimulationProcess(int port);
205205
void removeVariablesFromTree(QString className);

0 commit comments

Comments
 (0)