Skip to content

Commit

Permalink
- Updated the Figaro interface.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@24743 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Feb 24, 2015
1 parent db68426 commit 511d028
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 49 deletions.
27 changes: 5 additions & 22 deletions OMEdit/OMEditGUI/MainWindow.cpp
Expand Up @@ -871,30 +871,13 @@ void MainWindow::exportModelXML(LibraryTreeNode *pLibraryTreeNode)
void MainWindow::exportModelFigaro(LibraryTreeNode *pLibraryTreeNode)
{
/* if Modelica text is changed manually by user then validate it before saving. */
if (pLibraryTreeNode->getModelWidget())
{
if (!pLibraryTreeNode->getModelWidget()->getModelicaTextEditor()->validateModelicaText())
if (pLibraryTreeNode->getModelWidget()) {
if (!pLibraryTreeNode->getModelWidget()->getModelicaTextEditor()->validateModelicaText()) {
return;
}
}
// set the status message.
mpStatusBar->showMessage(tr("Exporting model as Figaro"));
// show the progress bar
mpProgressBar->setRange(0, 0);
showProgressBar();
FigaroPage *pFigaroPage = mpOptionsDialog->getFigaroPage();
QString library = pFigaroPage->getFigaroDatabaseFileTextBox()->text();
QString mode = pFigaroPage->getFigaroModeComboBox()->itemData(pFigaroPage->getFigaroModeComboBox()->currentIndex()).toString();
QString options = pFigaroPage->getFigaroOptionsTextBox()->text();
QString processor = pFigaroPage->getFigaroProcessTextBox()->text();
if (mpOMCProxy->exportToFigaro(pLibraryTreeNode->getNameStructure(), library, mode, options, processor))
{
mpMessagesWidget->addGUIMessage(new MessageItem("", false, 0, 0, 0, 0, GUIMessages::getMessage(GUIMessages::FIGARO_GENERATED),
Helper::scriptingKind, Helper::notificationLevel, 0));
}
// hide progress bar
hideProgressBar();
// clear the status bar message
mpStatusBar->clearMessage();
ExportFigaroDialog *pExportFigaroDialog = new ExportFigaroDialog(this, pLibraryTreeNode);
pExportFigaroDialog->exec();
}

void MainWindow::exportModelToOMNotebook(LibraryTreeNode *pLibraryTreeNode)
Expand Down
67 changes: 66 additions & 1 deletion OMEdit/OMEditGUI/Modeling/ModelicaClassDialog.cpp
Expand Up @@ -1162,7 +1162,7 @@ void GraphicsViewProperties::saveGraphicsViewProperties()
*/

/*!
\param pMainWindow - pointer to GraphicsView
\param pMainWindow - pointer to MainWindow
*/
SaveChangesDialog::SaveChangesDialog(MainWindow *pMainWindow)
: QDialog(pMainWindow, Qt::WindowTitleHint)
Expand Down Expand Up @@ -1268,3 +1268,68 @@ int SaveChangesDialog::exec()
return 1;
return QDialog::exec();
}

/*!
\class ExportFigaroDialog
\brief Creates a dialog for Figaro export.
*/

/*!
\param pMainWindow - pointer to MainWindow
*/
ExportFigaroDialog::ExportFigaroDialog(MainWindow *pMainWindow, LibraryTreeNode *pLibraryTreeNode)
: QDialog(pMainWindow, Qt::WindowTitleHint)
{
setAttribute(Qt::WA_DeleteOnClose);
setWindowTitle(QString(Helper::applicationName).append(" - ").append(Helper::exportFigaro));
mpMainWindow = pMainWindow;
mpLibraryTreeNode = pLibraryTreeNode;
// figaro mode
mpFigaroModeLabel = new Label(tr("Figaro Mode:"));
mpFigaroModeComboBox = new QComboBox;
mpFigaroModeComboBox->addItem("figaro0", "figaro0");
mpFigaroModeComboBox->addItem("fault-tree", "fault-tree");
// create the export button
mpExportFigaroButton = new QPushButton(Helper::exportFigaro);
mpExportFigaroButton->setAutoDefault(true);
connect(mpExportFigaroButton, SIGNAL(clicked()), SLOT(exportModelFigaro()));
// create the cancel button
mpCancelButton = new QPushButton(Helper::cancel);
mpCancelButton->setAutoDefault(false);
connect(mpCancelButton, SIGNAL(clicked()), SLOT(reject()));
// create buttons box
mpButtonBox = new QDialogButtonBox(Qt::Horizontal);
mpButtonBox->addButton(mpExportFigaroButton, QDialogButtonBox::ActionRole);
mpButtonBox->addButton(mpCancelButton, QDialogButtonBox::ActionRole);
// layout
QGridLayout *pMainGridLayout = new QGridLayout;
pMainGridLayout->setAlignment(Qt::AlignTop);
pMainGridLayout->addWidget(mpFigaroModeLabel, 0, 0);
pMainGridLayout->addWidget(mpFigaroModeComboBox, 0, 1);
pMainGridLayout->addWidget(mpButtonBox, 1, 0, 2, Qt::AlignRight);
setLayout(pMainGridLayout);
}

void ExportFigaroDialog::exportModelFigaro()
{
// set the status message.
mpMainWindow->getStatusBar()->showMessage(tr("Exporting model as Figaro"));
// show the progress bar
mpMainWindow->getProgressBar()->setRange(0, 0);
mpMainWindow->showProgressBar();
FigaroPage *pFigaroPage = mpMainWindow->getOptionsDialog()->getFigaroPage();
QString library = pFigaroPage->getFigaroDatabaseFileTextBox()->text();
QString mode = mpFigaroModeComboBox->currentText();
QString options = pFigaroPage->getFigaroOptionsTextBox()->text();
QString processor = pFigaroPage->getFigaroProcessTextBox()->text();
if (mpMainWindow->getOMCProxy()->exportToFigaro(mpLibraryTreeNode->getNameStructure(), library, mode, options, processor)) {
mpMainWindow->getMessagesWidget()->addGUIMessage(new MessageItem("", false, 0, 0, 0, 0,
GUIMessages::getMessage(GUIMessages::FIGARO_GENERATED),
Helper::scriptingKind, Helper::notificationLevel, 0));
}
// hide progress bar
mpMainWindow->hideProgressBar();
// clear the status bar message
mpMainWindow->getStatusBar()->clearMessage();
accept();
}
17 changes: 17 additions & 0 deletions OMEdit/OMEditGUI/Modeling/ModelicaClassDialog.h
Expand Up @@ -250,4 +250,21 @@ public slots:
int exec();
};

class ExportFigaroDialog : public QDialog
{
Q_OBJECT
public:
ExportFigaroDialog(MainWindow *pMainWindow, LibraryTreeNode *pLibraryTreeNode);
private:
MainWindow *mpMainWindow;
LibraryTreeNode *mpLibraryTreeNode;
Label *mpFigaroModeLabel;
QComboBox *mpFigaroModeComboBox;
QPushButton *mpExportFigaroButton;
QPushButton *mpCancelButton;
QDialogButtonBox *mpButtonBox;
public slots:
void exportModelFigaro();
};

#endif // MODELICACLASSDIALOG_H
32 changes: 9 additions & 23 deletions OMEdit/OMEditGUI/Options/OptionsDialog.cpp
Expand Up @@ -414,12 +414,6 @@ void OptionsDialog::readFigaroSettings()
if (mpSettings->contains("figaro/databasefile")) {
mpFigaroPage->getFigaroDatabaseFileTextBox()->setText(mpSettings->value("figaro/databasefile").toString());
}
if (mpSettings->contains("figaro/mode")) {
int currentIndex = mpFigaroPage->getFigaroModeComboBox()->findData(mpSettings->value("figaro/mode").toString(), Qt::UserRole, Qt::MatchExactly);
if (currentIndex > -1) {
mpFigaroPage->getFigaroModeComboBox()->setCurrentIndex(currentIndex);
}
}
if (mpSettings->contains("figaro/options")) {
mpFigaroPage->getFigaroOptionsTextBox()->setText(mpSettings->value("figaro/options").toString());
}
Expand Down Expand Up @@ -699,7 +693,6 @@ void OptionsDialog::saveCurveStyleSettings()
void OptionsDialog::saveFigaroSettings()
{
mpSettings->setValue("figaro/databasefile", mpFigaroPage->getFigaroDatabaseFileTextBox()->text());
mpSettings->setValue("figaro/mode", mpFigaroPage->getFigaroModeComboBox()->itemData(mpFigaroPage->getFigaroModeComboBox()->currentIndex()).toString());
mpSettings->setValue("figaro/options", mpFigaroPage->getFigaroOptionsTextBox()->text());
mpSettings->setValue("figaro/process", mpFigaroPage->getFigaroProcessTextBox()->text());
}
Expand Down Expand Up @@ -773,7 +766,7 @@ void OptionsDialog::setUpDialog()
horizontalLayout->addWidget(mpOptionsList);
QScrollArea *pPagesWidgetScrollArea = new QScrollArea;
pPagesWidgetScrollArea->setWidget(mpPagesWidget);
horizontalLayout->addWidget(pPagesWidgetScrollArea, 1);
horizontalLayout->addWidget(pPagesWidgetScrollArea);
// Create a layout
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addLayout(horizontalLayout, 0, 0, 1, 2);
Expand Down Expand Up @@ -3153,11 +3146,6 @@ FigaroPage::FigaroPage(OptionsDialog *pOptionsDialog)
mpBrowseFigaroDatabaseFileButton = new QPushButton(Helper::browse);
mpBrowseFigaroDatabaseFileButton->setAutoDefault(false);
connect(mpBrowseFigaroDatabaseFileButton, SIGNAL(clicked()), SLOT(browseFigaroLibraryFile()));
// Figaro model
mpFigaroModeLabel = new Label(tr("Figaro Mode:"));
mpFigaroModeComboBox = new QComboBox;
mpFigaroModeComboBox->addItem("figaro0", "figaro0");
mpFigaroModeComboBox->addItem("fault-tree", "fault-tree");
// Figaro options file
mpFigaroOptionsFileLabel = new Label(tr("Figaro Options File:"));
mpFigaroOptionsFileTextBox = new QLineEdit;
Expand All @@ -3166,7 +3154,7 @@ FigaroPage::FigaroPage(OptionsDialog *pOptionsDialog)
connect(mpBrowseFigaroOptionsFileButton, SIGNAL(clicked()), SLOT(browseFigaroOptionsFile()));
// figaro process
mpFigaroProcessLabel = new Label(tr("Figaro Process:"));
mpFigaroProcessTextBox = new QLineEdit(QString(Helper::OpenModelicaHome).append("/share/VisualFigaro/jEdit4.5_VisualFigaro/VisualFigaro/figp.exe"));
mpFigaroProcessTextBox = new QLineEdit(QString(Helper::OpenModelicaHome).append("/share/jEdit4.5_VisualFigaro/VisualFigaro/figp.exe"));
mpBrowseFigaroProcessButton = new QPushButton(Helper::browse);
mpBrowseFigaroProcessButton->setAutoDefault(false);
connect(mpBrowseFigaroProcessButton, SIGNAL(clicked()), SLOT(browseFigaroProcessFile()));
Expand All @@ -3176,14 +3164,12 @@ FigaroPage::FigaroPage(OptionsDialog *pOptionsDialog)
pFigaroLayout->addWidget(mpFigaroDatabaseFileLabel, 0, 0);
pFigaroLayout->addWidget(mpFigaroDatabaseFileTextBox, 0, 1);
pFigaroLayout->addWidget(mpBrowseFigaroDatabaseFileButton, 0, 2);
pFigaroLayout->addWidget(mpFigaroModeLabel, 1, 0);
pFigaroLayout->addWidget(mpFigaroModeComboBox, 1, 1, 1, 2);
pFigaroLayout->addWidget(mpFigaroOptionsFileLabel, 2, 0);
pFigaroLayout->addWidget(mpFigaroOptionsFileTextBox, 2, 1);
pFigaroLayout->addWidget(mpBrowseFigaroOptionsFileButton, 2, 2);
pFigaroLayout->addWidget(mpFigaroProcessLabel, 3, 0);
pFigaroLayout->addWidget(mpFigaroProcessTextBox, 3, 1);
pFigaroLayout->addWidget(mpBrowseFigaroProcessButton, 3, 2);
pFigaroLayout->addWidget(mpFigaroOptionsFileLabel, 1, 0);
pFigaroLayout->addWidget(mpFigaroOptionsFileTextBox, 1, 1);
pFigaroLayout->addWidget(mpBrowseFigaroOptionsFileButton, 1, 2);
pFigaroLayout->addWidget(mpFigaroProcessLabel, 2, 0);
pFigaroLayout->addWidget(mpFigaroProcessTextBox, 2, 1);
pFigaroLayout->addWidget(mpBrowseFigaroProcessButton, 2, 2);
mpFigaroGroupBox->setLayout(pFigaroLayout);
QVBoxLayout *pMainLayout = new QVBoxLayout;
pMainLayout->setAlignment(Qt::AlignTop);
Expand All @@ -3195,7 +3181,7 @@ FigaroPage::FigaroPage(OptionsDialog *pOptionsDialog)
void FigaroPage::browseFigaroLibraryFile()
{
mpFigaroDatabaseFileTextBox->setText(StringHandler::getOpenFileName(this, QString(Helper::applicationName).append(" - ").append(Helper::chooseFile),
NULL, Helper::xmlFileTypes, NULL));
NULL, Helper::figaroFileTypes, NULL));
}

void FigaroPage::browseFigaroOptionsFile()
Expand Down
3 changes: 0 additions & 3 deletions OMEdit/OMEditGUI/Options/OptionsDialog.h
Expand Up @@ -628,7 +628,6 @@ class FigaroPage : public QWidget
public:
FigaroPage(OptionsDialog *pOptionsDialog);
QLineEdit* getFigaroDatabaseFileTextBox() {return mpFigaroDatabaseFileTextBox;}
QComboBox* getFigaroModeComboBox() {return mpFigaroModeComboBox;}
QLineEdit* getFigaroOptionsTextBox() {return mpFigaroOptionsFileTextBox;}
QLineEdit* getFigaroProcessTextBox() {return mpFigaroProcessTextBox;}
private:
Expand All @@ -637,8 +636,6 @@ class FigaroPage : public QWidget
Label *mpFigaroDatabaseFileLabel;
QLineEdit *mpFigaroDatabaseFileTextBox;
QPushButton *mpBrowseFigaroDatabaseFileButton;
Label *mpFigaroModeLabel;
QComboBox *mpFigaroModeComboBox;
Label *mpFigaroOptionsFileLabel;
QLineEdit *mpFigaroOptionsFileTextBox;
QPushButton *mpBrowseFigaroOptionsFileButton;
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Util/Helper.cpp
Expand Up @@ -65,6 +65,7 @@ QString Helper::exeFileTypes = "EXE Files (*.exe)";
QString Helper::exeFileTypes = "Executable files (*)";
#endif
QString Helper::txtFileTypes = "TXT Files (*.txt)";
QString Helper::figaroFileTypes = "Figaro Files (*.fi)";
int Helper::treeIndentation = 13;
QSize Helper::iconSize = QSize(20, 20);
QSize Helper::buttonIconSize = QSize(16, 16);
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Util/Helper.h
Expand Up @@ -72,6 +72,7 @@ class Helper : public QObject
static QString omResultFileTypes;
static QString exeFileTypes;
static QString txtFileTypes;
static QString figaroFileTypes;
static int treeIndentation;
static QSize iconSize;
static QSize buttonIconSize;
Expand Down

0 comments on commit 511d028

Please sign in to comment.