Skip to content

Commit

Permalink
- Export to figaro via GUI.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@20625 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed May 15, 2014
1 parent 481057c commit d7aee64
Show file tree
Hide file tree
Showing 11 changed files with 273 additions and 50 deletions.
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/GUI/Containers/ModelWidgetContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3046,6 +3046,7 @@ void ModelWidgetContainer::currentModelWidgetChanged(QMdiSubWindow *pSubWindow)
getMainWindow()->getCheckAllModelsAction()->setEnabled(enabled);
getMainWindow()->getExportFMUAction()->setEnabled(enabled);
getMainWindow()->getExportXMLAction()->setEnabled(enabled);
getMainWindow()->getExportFigaroAction()->setEnabled(enabled);
getMainWindow()->getExportToOMNotebookAction()->setEnabled(enabled);
getMainWindow()->getExportAsImageAction()->setEnabled(enabled);
getMainWindow()->getPrintModelAction()->setEnabled(enabled);
Expand Down
95 changes: 94 additions & 1 deletion OMEdit/OMEditGUI/GUI/Dialogs/OptionsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ OptionsDialog::OptionsDialog(MainWindow *pParent)
mpLineStylePage = new LineStylePage(this);
mpFillStylePage = new FillStylePage(this);
mpCurveStylePage = new CurveStylePage(this);
mpFigaroPage = new FigaroPage(this);
// get the settings
readSettings();
// set up the Options Dialog
Expand All @@ -87,6 +88,7 @@ void OptionsDialog::readSettings()
readLineStyleSettings();
readFillStyleSettings();
readCurveStyleSettings();
readFigaroSettings();
}

//! Reads the General section settings from omedit.ini
Expand Down Expand Up @@ -346,6 +348,20 @@ void OptionsDialog::readCurveStyleSettings()
mpCurveStylePage->setCurveThickness(mSettings.value("curvestyle/thickness").toFloat());
}

//! Reads the Fiagro section settings from omedit.ini
void OptionsDialog::readFigaroSettings()
{
if (mSettings.contains("figaro/libraryfile"))
mpFigaroPage->getFigaroLibraryFileTextBox()->setText(mSettings.value("figaro/libraryfile").toString());
if (mSettings.contains("figaro/mode"))
{
int currentIndex = mpFigaroPage->getFigaroModeComboBox()->findData(mSettings.value("figaro/mode").toString(), Qt::UserRole, Qt::MatchExactly);
if (currentIndex > -1) mpFigaroPage->getFigaroModeComboBox()->setCurrentIndex(currentIndex);
}
if (mSettings.contains("figaro/process"))
mpFigaroPage->getFigaroProcessTextBox()->setText(mSettings.value("figaro/process").toString());
}

//! Saves the General section settings to omedit.ini
void OptionsDialog::saveGeneralSettings()
{
Expand Down Expand Up @@ -555,6 +571,14 @@ void OptionsDialog::saveCurveStyleSettings()
mSettings.setValue("curvestyle/thickness", mpCurveStylePage->getCurveThickness());
}

//! Saves the Figaro section settings to omedit.ini
void OptionsDialog::saveFigaroSettings()
{
mSettings.setValue("figaro/libraryfile", mpFigaroPage->getFigaroLibraryFileTextBox()->text());
mSettings.setValue("figaro/mode", mpFigaroPage->getFigaroModeComboBox()->itemData(mpFigaroPage->getFigaroModeComboBox()->currentIndex()).toString());
mSettings.setValue("figaro/process", mpFigaroPage->getFigaroProcessTextBox()->text());
}

//! Sets up the Options Widget dialog
void OptionsDialog::setUpDialog()
{
Expand Down Expand Up @@ -635,6 +659,10 @@ void OptionsDialog::addListItems()
QListWidgetItem *pCurveStyleItem = new QListWidgetItem(mpOptionsList);
pCurveStyleItem->setIcon(QIcon(":/Resources/icons/omplot.png"));
pCurveStyleItem->setText(Helper::curveStyle);
// Figaro Item
QListWidgetItem *pFigaroItem = new QListWidgetItem(mpOptionsList);
pFigaroItem->setIcon(QIcon(":/Resources/icons/console.png"));
pFigaroItem->setText(Helper::figaro);
}

//! Creates pages for the Options Widget. The pages are created as stacked widget and are mapped with mpOptionsList.
Expand All @@ -650,6 +678,7 @@ void OptionsDialog::createPages()
mpPagesWidget->addWidget(mpLineStylePage);
mpPagesWidget->addWidget(mpFillStylePage);
mpPagesWidget->addWidget(mpCurveStylePage);
mpPagesWidget->addWidget(mpFigaroPage);
}

MainWindow* OptionsDialog::getMainWindow()
Expand Down Expand Up @@ -702,6 +731,11 @@ CurveStylePage* OptionsDialog::getCurveStylePage()
return mpCurveStylePage;
}

FigaroPage* OptionsDialog::getFigaroPage()
{
return mpFigaroPage;
}

//! Change the page in Options Widget when the mpOptionsList currentItemChanged Signal is raised.
void OptionsDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
{
Expand Down Expand Up @@ -735,6 +769,7 @@ void OptionsDialog::saveSettings()
saveLineStyleSettings();
saveFillStyleSettings();
saveCurveStyleSettings();
saveFigaroSettings();
mSettings.sync();
accept();
}
Expand Down Expand Up @@ -2403,6 +2438,7 @@ LineStylePage::LineStylePage(OptionsDialog *pParent)
// Line Color
mpLineColorLabel = new Label(Helper::color);
mpLinePickColorButton = new QPushButton(Helper::pickColor);
mpLinePickColorButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
mpLinePickColorButton->setAutoDefault(false);
connect(mpLinePickColorButton, SIGNAL(clicked()), SLOT(linePickColor()));
setLineColor(Qt::black);
Expand Down Expand Up @@ -2576,6 +2612,7 @@ FillStylePage::FillStylePage(OptionsDialog *pParent)
// Fill Color
mpFillColorLabel = new Label(Helper::color);
mpFillPickColorButton = new QPushButton(Helper::pickColor);
mpFillPickColorButton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
mpFillPickColorButton->setAutoDefault(false);
connect(mpFillPickColorButton, SIGNAL(clicked()), SLOT(fillPickColor()));
setFillColor(Qt::black);
Expand Down Expand Up @@ -2638,7 +2675,6 @@ void FillStylePage::fillPickColor()
setFillPickColorButtonIcon();
}


//! @class CurveStylePage
//! @brief Creates an interface for curve style settings.

Expand All @@ -2652,6 +2688,7 @@ CurveStylePage::CurveStylePage(OptionsDialog *pParent)
// Curve Pattern
mpCurvePatternLabel = new Label(Helper::pattern);
mpCurvePatternComboBox = new QComboBox;
mpCurvePatternComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
mpCurvePatternComboBox->addItem("SolidLine", 1);
mpCurvePatternComboBox->addItem("DashLine", 2);
mpCurvePatternComboBox->addItem("DotLine", 3);
Expand Down Expand Up @@ -2708,3 +2745,59 @@ qreal CurveStylePage::getCurveThickness()
{
return mpCurveThicknessSpinBox->value();
}

//! @class FigaroPage
//! @brief Creates an interface for Figaro settings.

//! Constructor
//! @param pParent is the pointer to OptionsDialog
FigaroPage::FigaroPage(OptionsDialog *pParent)
: QWidget(pParent)
{
mpOptionsDialog = pParent;
mpFigaroGroupBox = new QGroupBox(Helper::figaro);
// Figaro library file
mpFigaroLibraryFileLabel = new Label(tr("Figaro Library File:"));
mpFigaroLibraryFileTextBox = new QLineEdit;
mpBrowseFigaroLibraryFileButton = new QPushButton(Helper::browse);
connect(mpBrowseFigaroLibraryFileButton, SIGNAL(clicked()), SLOT(browseFigaroLibraryFile()));
// Figaro model
mpFigaroModeLabel = new Label(tr("Figaro Mode:"));
mpFigaroModeComboBox = new QComboBox;
mpFigaroModeComboBox->addItem(tr("figaro0"), "figaro0");
mpFigaroModeComboBox->addItem(tr("fault-tree"), "fault-tree");
// figaro process
mpFigaroProcessLabel = new Label(tr("Figaro Process:"));
mpFigaroProcessTextBox = new QLineEdit;
mpBrowseFigaroProcessButton = new QPushButton(Helper::browse);
connect(mpBrowseFigaroProcessButton, SIGNAL(clicked()), SLOT(browseFigaroProcessFile()));
// set the layout
QGridLayout *pFigaroLayout = new QGridLayout;
pFigaroLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft);
pFigaroLayout->addWidget(mpFigaroLibraryFileLabel, 0, 0);
pFigaroLayout->addWidget(mpFigaroLibraryFileTextBox, 0, 1);
pFigaroLayout->addWidget(mpBrowseFigaroLibraryFileButton, 0, 2);
pFigaroLayout->addWidget(mpFigaroModeLabel, 1, 0);
pFigaroLayout->addWidget(mpFigaroModeComboBox, 1, 1, 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);
pMainLayout->setContentsMargins(0, 0, 0, 0);
pMainLayout->addWidget(mpFigaroGroupBox);
setLayout(pMainLayout);
}

void FigaroPage::browseFigaroLibraryFile()
{
mpFigaroLibraryFileTextBox->setText(StringHandler::getOpenFileName(this, QString(Helper::applicationName).append(" - ").append(Helper::chooseFile),
NULL, "", NULL));
}

void FigaroPage::browseFigaroProcessFile()
{
mpFigaroProcessTextBox->setText(StringHandler::getOpenFileName(this, QString(Helper::applicationName).append(" - ").append(Helper::chooseFile),
NULL, "", NULL));
}
29 changes: 29 additions & 0 deletions OMEdit/OMEditGUI/GUI/Dialogs/OptionsDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class NotificationsPage;
class LineStylePage;
class FillStylePage;
class CurveStylePage;
class FigaroPage;

class OptionsDialog : public QDialog
{
Expand All @@ -71,6 +72,7 @@ class OptionsDialog : public QDialog
void readLineStyleSettings();
void readFillStyleSettings();
void readCurveStyleSettings();
void readFigaroSettings();
void saveGeneralSettings();
void saveLibrariesSettings();
void saveModelicaTextSettings();
Expand All @@ -80,6 +82,7 @@ class OptionsDialog : public QDialog
void saveLineStyleSettings();
void saveFillStyleSettings();
void saveCurveStyleSettings();
void saveFigaroSettings();
void setUpDialog();
void addListItems();
void createPages();
Expand All @@ -93,6 +96,7 @@ class OptionsDialog : public QDialog
LineStylePage* getLineStylePage();
FillStylePage* getFillStylePage();
CurveStylePage* getCurveStylePage();
FigaroPage* getFigaroPage();
signals:
void modelicaTextSettingsChanged();
void updateLineWrapping();
Expand All @@ -112,6 +116,7 @@ public slots:
LineStylePage *mpLineStylePage;
FillStylePage *mpFillStylePage;
CurveStylePage *mpCurveStylePage;
FigaroPage *mpFigaroPage;
QSettings mSettings;
QListWidget *mpOptionsList;
QStackedWidget *mpPagesWidget;
Expand Down Expand Up @@ -538,4 +543,28 @@ class CurveStylePage : public QWidget
DoubleSpinBox *mpCurveThicknessSpinBox;
};

class FigaroPage : public QWidget
{
Q_OBJECT
public:
FigaroPage(OptionsDialog *pParent);
QLineEdit* getFigaroLibraryFileTextBox() {return mpFigaroLibraryFileTextBox;}
QComboBox* getFigaroModeComboBox() {return mpFigaroModeComboBox;}
QLineEdit* getFigaroProcessTextBox() {return mpFigaroProcessTextBox;}
private:
OptionsDialog *mpOptionsDialog;
QGroupBox *mpFigaroGroupBox;
Label *mpFigaroLibraryFileLabel;
QLineEdit *mpFigaroLibraryFileTextBox;
QPushButton *mpBrowseFigaroLibraryFileButton;
Label *mpFigaroModeLabel;
QComboBox *mpFigaroModeComboBox;
Label *mpFigaroProcessLabel;
QLineEdit *mpFigaroProcessTextBox;
QPushButton *mpBrowseFigaroProcessButton;
private slots:
void browseFigaroLibraryFile();
void browseFigaroProcessFile();
};

#endif // OPTIONSDIALOG_H

0 comments on commit d7aee64

Please sign in to comment.