Skip to content

Commit

Permalink
Add option for simplified save total model in OMEdit (#10923)
Browse files Browse the repository at this point in the history
  • Loading branch information
perost committed Jul 3, 2023
1 parent b9c7adf commit f1c1d2c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
14 changes: 10 additions & 4 deletions OMEdit/OMEditLIB/Modeling/ModelicaClassDialog.cpp
Expand Up @@ -1267,6 +1267,8 @@ SaveTotalFileDialog::SaveTotalFileDialog(LibraryTreeItem *pLibraryTreeItem, QWid
mpObfuscateOutputCheckBox = new QCheckBox(tr("Obfuscate output"));
mpStripAnnotationsCheckBox = new QCheckBox(tr("Strip annotations"));
mpStripCommentsCheckBox = new QCheckBox(tr("Strip comments"));
mpUseSimplifiedHeuristic = new QCheckBox(tr("Use simplified heuristic"));
mpUseSimplifiedHeuristic->setToolTip(tr("Use a simplified identifier-based heuristic that results in larger models but can succeed when the normal method fails."));
// buttons
mpOkButton = new QPushButton(Helper::ok);
mpOkButton->setAutoDefault(true);
Expand All @@ -1281,7 +1283,8 @@ SaveTotalFileDialog::SaveTotalFileDialog(LibraryTreeItem *pLibraryTreeItem, QWid
pMainGridLayout->addWidget(mpObfuscateOutputCheckBox, 0, 0);
pMainGridLayout->addWidget(mpStripAnnotationsCheckBox, 1, 0);
pMainGridLayout->addWidget(mpStripCommentsCheckBox, 2, 0);
pMainGridLayout->addWidget(mpButtonBox, 3, 0, 1, 1, Qt::AlignRight);
pMainGridLayout->addWidget(mpUseSimplifiedHeuristic, 3, 0);
pMainGridLayout->addWidget(mpButtonBox, 4, 0, 1, 1, Qt::AlignRight);
setLayout(pMainGridLayout);
}

Expand All @@ -1298,9 +1301,12 @@ void SaveTotalFileDialog::saveTotalModel()
if (fileName.isEmpty()) { // if user press ESC
reject();
} else {
// save the model through OMC
MainWindow::instance()->getOMCProxy()->saveTotalModel(fileName, mpLibraryTreeItem->getNameStructure(), mpStripAnnotationsCheckBox->isChecked(),
mpStripCommentsCheckBox->isChecked(), mpObfuscateOutputCheckBox->isChecked());
// save the model through OMC
MainWindow::instance()->getOMCProxy()->saveTotalModel(fileName, mpLibraryTreeItem->getNameStructure(),
mpStripAnnotationsCheckBox->isChecked(),
mpStripCommentsCheckBox->isChecked(),
mpObfuscateOutputCheckBox->isChecked(),
mpUseSimplifiedHeuristic->isChecked());
accept();
}
}
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditLIB/Modeling/ModelicaClassDialog.h
Expand Up @@ -216,6 +216,7 @@ class SaveTotalFileDialog : public QDialog
QCheckBox *mpObfuscateOutputCheckBox;
QCheckBox *mpStripAnnotationsCheckBox;
QCheckBox *mpStripCommentsCheckBox;
QCheckBox *mpUseSimplifiedHeuristic;
QPushButton *mpOkButton;
QPushButton *mpCancelButton;
QDialogButtonBox *mpButtonBox;
Expand Down
12 changes: 10 additions & 2 deletions OMEdit/OMEditLIB/OMC/OMCProxy.cpp
Expand Up @@ -1860,11 +1860,19 @@ bool OMCProxy::saveModifiedModel(QString modelText)
* \param stripAnnotations
* \param stripComments
* \param obfuscate
* \param simplified
* \return true on success.
*/
bool OMCProxy::saveTotalModel(QString fileName, QString className, bool stripAnnotations, bool stripComments, bool obfuscate)
bool OMCProxy::saveTotalModel(QString fileName, QString className, bool stripAnnotations, bool stripComments, bool obfuscate, bool simplified)
{
bool result = mpOMCInterface->saveTotalModel(fileName, className, stripAnnotations, stripComments, obfuscate);
bool result;

if (simplified) {
result = mpOMCInterface->saveTotalModelDebug(fileName, className, stripAnnotations, stripComments, obfuscate);
} else {
result = mpOMCInterface->saveTotalModel(fileName, className, stripAnnotations, stripComments, obfuscate);
}

printMessagesStringInternal();
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditLIB/OMC/OMCProxy.h
Expand Up @@ -176,7 +176,7 @@ class OMCProxy : public QObject
bool setSourceFile(QString className, QString path);
bool save(QString className);
bool saveModifiedModel(QString modelText);
bool saveTotalModel(QString fileName, QString className, bool stripAnnotations, bool stripComments, bool obfuscate);
bool saveTotalModel(QString fileName, QString className, bool stripAnnotations, bool stripComments, bool obfuscate, bool simplified);
QString list(QString className);
QString listFile(QString className, bool nestedClasses = true);
QString diffModelicaFileListings(const QString &before, const QString &after);
Expand Down

0 comments on commit f1c1d2c

Please sign in to comment.