Skip to content

Commit

Permalink
Added documentation about FMI options (#8156)
Browse files Browse the repository at this point in the history
Fixes #8102
Generate a complete tooltip for combobox options and an item based tooltip as well
  • Loading branch information
adeas31 committed Nov 17, 2021
1 parent 6e11c98 commit 2ca59e4
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 117 deletions.
3 changes: 2 additions & 1 deletion OMEdit/OMEditLIB/MainWindow.cpp
Expand Up @@ -952,7 +952,8 @@ void MainWindow::exportModelFMU(LibraryTreeItem *pLibraryTreeItem)
if (OptionsDialog::instance()->getFMIPage()->getGenerateDebugSymbolsCheckBox()->isChecked()) {
mpOMCProxy->setCommandLineOptions(QString("-d=gendebugsymbols"));
}
QString fmuFileName = mpOMCProxy->buildModelFMU(pLibraryTreeItem->getNameStructure(), version, type, FMUName, platforms);
bool includeResources = OptionsDialog::instance()->getFMIPage()->getIncludeResourcesCheckBox()->isChecked();
QString fmuFileName = mpOMCProxy->buildModelFMU(pLibraryTreeItem->getNameStructure(), version, type, FMUName, platforms, includeResources);
if (!fmuFileName.isEmpty()) { // FMU was generated
if (!newFmuName.isEmpty()) { // FMU should be moved
QDir newNameAsDir(newFmuName);
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditLIB/OMC/OMCProxy.cpp
Expand Up @@ -2508,6 +2508,7 @@ OMCInterface::getSimulationOptions_res OMCProxy::getSimulationOptions(QString cl
* \param type - the fmu type
* \param fileNamePrefix
* \param platforms
* \param includeResources
* \return
*/
QString OMCProxy::buildModelFMU(QString className, QString version, QString type, QString fileNamePrefix, QList<QString> platforms, bool includeResources)
Expand Down
2 changes: 1 addition & 1 deletion OMEdit/OMEditLIB/OMC/OMCProxy.h
Expand Up @@ -213,7 +213,7 @@ class OMCProxy : public QObject
QString checkAllModelsRecursive(QString className);
bool isExperiment(QString className);
OMCInterface::getSimulationOptions_res getSimulationOptions(QString className, double defaultTolerance = 1e-6);
QString buildModelFMU(QString className, QString version, QString type, QString fileNamePrefix, QList<QString> platforms, bool includeResources = true);
QString buildModelFMU(QString className, QString version, QString type, QString fileNamePrefix, QList<QString> platforms, bool includeResources);
QString translateModelXML(QString className);
QString importFMU(QString fmuName, QString outputDirectory, int logLevel, bool debugLogging, bool generateInputConnectors, bool generateOutputConnectors);
QString importFMUModelDescription(QString fmuModelDescriptionName, QString outputDirectory, int logLevel, bool debugLogging, bool generateInputConnectors, bool generateOutputConnectors);
Expand Down
53 changes: 27 additions & 26 deletions OMEdit/OMEditLIB/Options/OptionsDialog.cpp
Expand Up @@ -931,6 +931,10 @@ void OptionsDialog::readFMISettings()
mpFMIPage->getModelDescriptionFiltersComboBox()->setCurrentIndex(currentIndex);
}
}
// read include resources
if (mpSettings->contains("FMIExport/IncludeResources")) {
mpFMIPage->getIncludeResourcesCheckBox()->setChecked(mpSettings->value("FMIExport/IncludeResources").toBool());
}
// read include source code
if (mpSettings->contains("FMIExport/IncludeSourceCode")) {
mpFMIPage->getIncludeSourceCodeCheckBox()->setChecked(mpSettings->value("FMIExport/IncludeSourceCode").toBool());
Expand Down Expand Up @@ -1566,6 +1570,7 @@ void OptionsDialog::saveFMISettings()
mpSettings->setValue("FMIExport/Platforms", platforms);
mpSettings->setValue("FMIExport/solver", mpFMIPage->getSolverForCoSimulationComboBox()->itemData(mpFMIPage->getSolverForCoSimulationComboBox()->currentIndex()).toString());
mpSettings->setValue("FMIExport/ModelDescriptionFilter", mpFMIPage->getModelDescriptionFiltersComboBox()->currentText());
mpSettings->setValue("FMIExport/IncludeResources", mpFMIPage->getIncludeResourcesCheckBox()->isChecked());
mpSettings->setValue("FMIExport/IncludeSourceCode", mpFMIPage->getIncludeSourceCodeCheckBox()->isChecked());
mpSettings->setValue("FMIExport/GenerateDebugSymbols", mpFMIPage->getGenerateDebugSymbolsCheckBox()->isChecked());
mpSettings->setValue("FMIImport/DeleteFMUDirectoyAndModel", mpFMIPage->getDeleteFMUDirectoryAndModelCheckBox()->isChecked());
Expand Down Expand Up @@ -1991,16 +1996,15 @@ GeneralSettingsPage::GeneralSettingsPage(OptionsDialog *pOptionsDialog)
// activate access annotation
mpActivateAccessAnnotationsLabel = new Label(tr("Activate Access Annotations *"));
mpActivateAccessAnnotationsComboBox = new QComboBox;
QStringList activateAccessAnnotationsDescriptions;
activateAccessAnnotationsDescriptions << tr("Activates the access annotations even for the non-encrypted libraries.")
<< tr("Activates the access annotations even if the .mol contains a non-encrypted library.")
<< tr("Deactivates access annotations except for encrypted libraries.");
mpActivateAccessAnnotationsComboBox->addItem(tr("Always"), GeneralSettingsPage::Always);
mpActivateAccessAnnotationsComboBox->addItem(tr("When loading .mol file(s)"), GeneralSettingsPage::Loading);
mpActivateAccessAnnotationsComboBox->addItem(tr("Never"), GeneralSettingsPage::Never);
mpActivateAccessAnnotationsComboBox->setCurrentIndex(1);
mpActivateAccessAnnotationsComboBox->setToolTip(tr("<html><head/><body>"
"<p>Options for handling of access annotations:</p>"
"<ul><li><i>Always:</i> Activates the access annotations even for the non-encrypted libraries.</li>"
"<li><i>When loading .mol file(s):</i> Activates the access annotations even if the .mol contains a non-encrypted library.</li>"
"<li><i>Never:</i> Deactivates access annotations except for encrypted libraries.</li></ul>"
"</body></html>"));
Utilities::setToolTip(mpActivateAccessAnnotationsComboBox, tr("Options for handling of access annotations"), activateAccessAnnotationsDescriptions);
// create backup file
mpCreateBackupFileCheckbox = new QCheckBox(tr("Create a model.bak-mo backup file when deleting a model."));
mpCreateBackupFileCheckbox->setChecked(true);
Expand Down Expand Up @@ -2620,16 +2624,15 @@ TextEditorPage::TextEditorPage(OptionsDialog *pOptionsDialog)
// Byte Order Mark BOM
mpBOMLabel = new Label(tr("Byte Order Mark (BOM):"));
mpBOMComboBox = new QComboBox;
mpBOMComboBox->setToolTip(tr("<html><head/><body>"
"<p>Note that BOMs are uncommon and treated incorrectly by some editors, so it usually makes little sense to add any.</p>"
"<ul><li><i>Always Add:</i> always add a BOM when saving a file.</li>"
"<li><i>Keep If Already Present:</i> save the file with a BOM if it already had one when it was loaded.</li>"
"<li><i>Always Delete:</i> never write a BOM, possibly deleting a pre-existing one.</li></ul>"
"</body></html>"));
QStringList bomDescriptions;
bomDescriptions << tr("Always add a BOM when saving a file.")
<< tr("Save the file with a BOM if it already had one when it was loaded.")
<< tr("Never write a BOM, possibly deleting a pre-existing one.");
mpBOMComboBox->addItem(tr("Always Add"), Utilities::AlwaysAddBom);
mpBOMComboBox->addItem(tr("Keep If Already Present"), Utilities::KeepBom);
mpBOMComboBox->addItem(tr("Always Delete"), Utilities::AlwaysDeleteBom);
mpBOMComboBox->setCurrentIndex(1);
Utilities::setToolTip(mpBOMComboBox, tr("Note that BOMs are uncommon and treated incorrectly by some editors, so it usually makes little sense to add any"), bomDescriptions);
// set format groupbox layout
QGridLayout *pFormatGroupBoxLayout = new QGridLayout;
pFormatGroupBoxLayout->addWidget(mpLineEndingLabel, 0, 0);
Expand Down Expand Up @@ -3842,13 +3845,8 @@ SimulationPage::SimulationPage(OptionsDialog *pOptionsDialog)
OMCInterface::getConfigFlagValidOptions_res simCodeTarget = MainWindow::instance()->getOMCProxy()->getConfigFlagValidOptions("simCodeTarget");
mpTargetLanguageComboBox = new QComboBox;
mpTargetLanguageComboBox->addItems(simCodeTarget.validOptions);
mpTargetLanguageComboBox->setToolTip(simCodeTarget.mainDescription);
int i = 0;
foreach (QString description, simCodeTarget.descriptions) {
mpTargetLanguageComboBox->setItemData(i, description, Qt::ToolTipRole);
i++;
}
mpTargetLanguageComboBox->setCurrentIndex(mpTargetLanguageComboBox->findText("C"));
Utilities::setToolTip(mpTargetLanguageComboBox, simCodeTarget.mainDescription, simCodeTarget.descriptions);
// Target Build
mpTargetBuildLabel = new Label(tr("Target Build:"));
mpTargetBuildComboBox = new QComboBox;
Expand Down Expand Up @@ -4969,10 +4967,15 @@ FMIPage::FMIPage(OptionsDialog *pOptionsDialog)
Label *pPlatformNoteLabel = new Label(tr("Note: The list of platforms is created by searching for programs in the PATH matching pattern \"*-*-*-*cc\"."));
mpLinkingComboBox = new QComboBox;
mpLinkingComboBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
QStringList linkingDescriptions;
linkingDescriptions << "Do not generate code for any platform i.e., a source only FMU."
<< "Generate the FMU with dynamically linked runtime for current platform."
<< "Generate the FMU with statically linked runtime for current platform.";
mpLinkingComboBox->addItem(tr("None"), "none");
mpLinkingComboBox->addItem(tr("Dynamic"), "dynamic");
mpLinkingComboBox->addItem(tr("Static"), "static");
mpLinkingComboBox->setCurrentIndex(2);
Utilities::setToolTip(mpLinkingComboBox, "Platforms", linkingDescriptions);
// set the type groupbox layout
QVBoxLayout *pPlatformsLayout = new QVBoxLayout;
pPlatformsLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
Expand All @@ -4993,14 +4996,11 @@ FMIPage::FMIPage(OptionsDialog *pOptionsDialog)
OMCInterface::getConfigFlagValidOptions_res fmiFilters = MainWindow::instance()->getOMCProxy()->getConfigFlagValidOptions("fmiFilter");
mpModelDescriptionFiltersComboBox = new QComboBox;
mpModelDescriptionFiltersComboBox->addItems(fmiFilters.validOptions);
mpModelDescriptionFiltersComboBox->setToolTip(fmiFilters.mainDescription);
int i = 0;
foreach (QString description, fmiFilters.descriptions) {
mpModelDescriptionFiltersComboBox->setItemData(i, description, Qt::ToolTipRole);
i++;
}
mpModelDescriptionFiltersComboBox->setCurrentIndex(mpModelDescriptionFiltersComboBox->findText("internal"));
Utilities::setToolTip(mpModelDescriptionFiltersComboBox, fmiFilters.mainDescription, fmiFilters.descriptions);
connect(mpModelDescriptionFiltersComboBox, SIGNAL(currentIndexChanged(QString)), SLOT(enableIncludeSourcesCheckBox(QString)));
// include resources checkbox
mpIncludeResourcesCheckBox = new QCheckBox(tr("Include Modelica based resources via loadResource"));
// include source code checkbox
mpIncludeSourceCodeCheckBox = new QCheckBox(tr("Include Source Code (model description filter \"blackBox\" will override this, because black box FMUs do never contain their source code.)"));
mpIncludeSourceCodeCheckBox->setChecked(true);
Expand All @@ -5022,8 +5022,9 @@ FMIPage::FMIPage(OptionsDialog *pOptionsDialog)
pExportLayout->addWidget(mpSolverForCoSimulationComboBox, 5, 1, 1, 2);
pExportLayout->addWidget(new Label(tr("Model Description Filters:")), 6, 0);
pExportLayout->addWidget(mpModelDescriptionFiltersComboBox, 6, 1, 1, 2);
pExportLayout->addWidget(mpIncludeSourceCodeCheckBox, 7, 0, 1, 3);
pExportLayout->addWidget(mpGenerateDebugSymbolsCheckBox, 8, 0, 1, 3);
pExportLayout->addWidget(mpIncludeResourcesCheckBox, 7, 0, 1, 3);
pExportLayout->addWidget(mpIncludeSourceCodeCheckBox, 8, 0, 1, 3);
pExportLayout->addWidget(mpGenerateDebugSymbolsCheckBox, 9, 0, 1, 3);
mpExportGroupBox->setLayout(pExportLayout);
// import groupbox
mpImportGroupBox = new QGroupBox(tr("Import"));
Expand Down
2 changes: 2 additions & 0 deletions OMEdit/OMEditLIB/Options/OptionsDialog.h
Expand Up @@ -941,6 +941,7 @@ class FMIPage : public QWidget
QComboBox* getLinkingComboBox() {return mpLinkingComboBox;}
QComboBox *getModelDescriptionFiltersComboBox() const {return mpModelDescriptionFiltersComboBox;}
QComboBox *getSolverForCoSimulationComboBox() const {return mpSolverForCoSimulationComboBox;}
QCheckBox *getIncludeResourcesCheckBox() const {return mpIncludeResourcesCheckBox;}
QCheckBox *getIncludeSourceCodeCheckBox() const {return mpIncludeSourceCodeCheckBox;}
QCheckBox *getGenerateDebugSymbolsCheckBox() const {return mpGenerateDebugSymbolsCheckBox;}
QCheckBox* getDeleteFMUDirectoryAndModelCheckBox() {return mpDeleteFMUDirectoryAndModelCheckBox;}
Expand All @@ -967,6 +968,7 @@ class FMIPage : public QWidget
QComboBox *mpLinkingComboBox;
QComboBox *mpSolverForCoSimulationComboBox;
QComboBox *mpModelDescriptionFiltersComboBox;
QCheckBox *mpIncludeResourcesCheckBox;
QCheckBox *mpIncludeSourceCodeCheckBox;
QCheckBox *mpGenerateDebugSymbolsCheckBox;
QGroupBox *mpImportGroupBox;
Expand Down
53 changes: 8 additions & 45 deletions OMEdit/OMEditLIB/Simulation/SimulationDialog.cpp
Expand Up @@ -208,10 +208,7 @@ void SimulationDialog::setUpForm()
MainWindow::instance()->getOMCProxy()->getSolverMethods(&solverMethods, &solverMethodsDesc);
mpMethodComboBox = new QComboBox;
mpMethodComboBox->addItems(solverMethods);
for (int i = 0 ; i < solverMethodsDesc.size() ; i++) {
mpMethodComboBox->setItemData(i, solverMethodsDesc.at(i), Qt::ToolTipRole);
}
connect(mpMethodComboBox, SIGNAL(currentIndexChanged(int)), SLOT(updateMethodToolTip(int)));
Utilities::setToolTip(mpMethodComboBox, "Integration Methods", solverMethodsDesc);
connect(mpMethodComboBox, SIGNAL(currentIndexChanged(QString)), SLOT(enableDasslIdaOptions(QString)));
mpMehtodHelpButton = new QToolButton;
mpMehtodHelpButton->setIcon(QIcon(":/Resources/icons/link-external.svg"));
Expand All @@ -226,13 +223,10 @@ void SimulationDialog::setUpForm()
QStringList jacobianMethods, jacobianMethodsDesc;
MainWindow::instance()->getOMCProxy()->getJacobianMethods(&jacobianMethods, &jacobianMethodsDesc);
mpJacobianComboBox = new QComboBox;
mpJacobianComboBox->addItem("");
mpJacobianComboBox->setItemData(0, "", Qt::ToolTipRole);
jacobianMethods.prepend("");
jacobianMethodsDesc.prepend("");
mpJacobianComboBox->addItems(jacobianMethods);
for (int i = 0 ; i < jacobianMethodsDesc.size() ; i++) {
mpJacobianComboBox->setItemData(i + 1, jacobianMethodsDesc.at(i), Qt::ToolTipRole);
}
connect(mpJacobianComboBox, SIGNAL(currentIndexChanged(int)), SLOT(updateJacobianToolTip(int)));
Utilities::setToolTip(mpJacobianComboBox, "Jacobians", jacobianMethodsDesc);
// dassl/ida options
mpDasslIdaOptionsGroupBox = new QGroupBox(tr("DASSL/IDA Options"));
// no root finding
Expand Down Expand Up @@ -380,9 +374,7 @@ void SimulationDialog::setUpForm()
initializationMethodsDesc.prepend("");
mpInitializationMethodComboBox = new QComboBox;
mpInitializationMethodComboBox->addItems(initializationMethods);
for (int i = 0 ; i < initializationMethodsDesc.size() ; i++) {
mpInitializationMethodComboBox->setItemData(i, initializationMethodsDesc.at(i), Qt::ToolTipRole);
}
Utilities::setToolTip(mpInitializationMethodComboBox, "Initialization Methods", initializationMethodsDesc);
// Equation System Initialization File
mpEquationSystemInitializationFileLabel = new Label(tr("Equation System Initialization File (Optional):"));
mpEquationSystemInitializationFileLabel->setToolTip(tr("Specifies an external file for the initialization of the model."));
Expand All @@ -407,9 +399,7 @@ void SimulationDialog::setUpForm()
linearSolverMethodsDesc.prepend("");
mpLinearSolverComboBox = new QComboBox;
mpLinearSolverComboBox->addItems(linearSolverMethods);
for (int i = 0 ; i < linearSolverMethodsDesc.size() ; i++) {
mpLinearSolverComboBox->setItemData(i, linearSolverMethodsDesc.at(i), Qt::ToolTipRole);
}
Utilities::setToolTip(mpLinearSolverComboBox, "Linear Solvers", linearSolverMethodsDesc);
// Non Linear Solvers
mpNonLinearSolverLabel = new Label(tr("Non Linear Solver (Optional):"));
// get the non-linear solvers
Expand All @@ -419,9 +409,7 @@ void SimulationDialog::setUpForm()
nonLinearSolverMethodsDesc.prepend("");
mpNonLinearSolverComboBox = new QComboBox;
mpNonLinearSolverComboBox->addItems(nonLinearSolverMethods);
for (int i = 0 ; i < nonLinearSolverMethodsDesc.size() ; i++) {
mpNonLinearSolverComboBox->setItemData(i, nonLinearSolverMethodsDesc.at(i), Qt::ToolTipRole);
}
Utilities::setToolTip(mpNonLinearSolverComboBox, "Non Linear Solvers", nonLinearSolverMethodsDesc);
// time where the linearization of the model should be performed
mpLinearizationTimeLabel = new Label(tr("Linearization Time (Optional):"));
mpLinearizationTimeTextBox = new QLineEdit;
Expand All @@ -435,12 +423,7 @@ void SimulationDialog::setUpForm()
OMCInterface::getConfigFlagValidOptions_res profiling = MainWindow::instance()->getOMCProxy()->getConfigFlagValidOptions("profiling");
mpProfilingComboBox->addItems(profiling.validOptions);
mpProfilingComboBox->setCurrentIndex(0);
mpProfilingComboBox->setToolTip(profiling.mainDescription);
int i = 0;
foreach (QString description, profiling.descriptions) {
mpProfilingComboBox->setItemData(i, description, Qt::ToolTipRole);
i++;
}
Utilities::setToolTip(mpProfilingComboBox, profiling.mainDescription, profiling.descriptions);
// cpu-time checkbox
mpCPUTimeCheckBox = new QCheckBox(tr("CPU Time"));
// enable all warnings
Expand Down Expand Up @@ -2156,16 +2139,6 @@ void SimulationDialog::intervalRadioToggled(bool toggle)
}
}

/*!
* \brief SimulationDialog::updateMethodToolTip
* Updates the Method combobox tooltip.
* \param index
*/
void SimulationDialog::updateMethodToolTip(int index)
{
mpMethodComboBox->setToolTip(mpMethodComboBox->itemData(index, Qt::ToolTipRole).toString());
}

/*!
* \brief SimulationDialog::enableDasslOptions
* Slot activated when mpMethodComboBox currentIndexChanged signal is raised.\n
Expand Down Expand Up @@ -2197,16 +2170,6 @@ void SimulationDialog::showIntegrationHelp()
}
}

/*!
* \brief SimulationDialog::updateJacobianToolTip
* Updates the Jacobian combobox tooltip.
* \param index
*/
void SimulationDialog::updateJacobianToolTip(int index)
{
mpJacobianComboBox->setToolTip(mpJacobianComboBox->itemData(index, Qt::ToolTipRole).toString());
}

/*!
* \brief SimulationDialog::buildOnly
* Slot activated when mpBuildOnlyCheckBox checkbox is checked.\n
Expand Down
2 changes: 0 additions & 2 deletions OMEdit/OMEditLIB/Simulation/SimulationDialog.h
Expand Up @@ -225,10 +225,8 @@ class SimulationDialog : public QDialog
public slots:
void numberOfIntervalsRadioToggled(bool toggle);
void intervalRadioToggled(bool toggle);
void updateMethodToolTip(int index);
void enableDasslIdaOptions(QString method);
void showIntegrationHelp();
void updateJacobianToolTip(int index);
void buildOnly(bool checked);
void interactiveSimulation(bool checked);
void browseModelSetupFile();
Expand Down

0 comments on commit 2ca59e4

Please sign in to comment.