OpenFCST: The open-source Fuel Cell Simulation Toolbox
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Private Types | Private Slots | Private Member Functions | Private Attributes | List of all members
FCSTGUI::MainWindow Class Reference

The MainWindow class of the the FCST parameterGUI. More...

#include <main_window.h>

Inheritance diagram for FCSTGUI::MainWindow:
Inheritance graph
[legend]
Collaboration diagram for FCSTGUI::MainWindow:
Collaboration graph
[legend]

Public Member Functions

 MainWindow (const QString &filename="")
 Constructor. More...
 

Protected Member Functions

void closeEvent (QCloseEvent *event)
 Reimplemented from QMainWindow. More...
 

Private Types

enum  States { Start = 0, Main, Ready, Running }
 Enumeration describing states of project creation/simulation execution. More...
 

Private Slots

void openProject ()
 Open a project. More...
 
bool saveAll ()
 Save the parameter file. More...
 
bool save_as ()
 Open a file dialog to save the parameter file. More...
 
void about ()
 Show some information on the parameterGUI. More...
 
void aboutOpenFCST ()
 Show some information on the OpenFCST. More...
 
void tree_was_modified ()
 A slot that should be always called, if parameter values were changed. More...
 
void next_click ()
 A slot for the next button, progresses the GUI's state. More...
 
void printOutput ()
 A slot that should be called to take output from the current process's std and err streams. More...
 
void finishedFCST (int status, QProcess::ExitStatus qStatus)
 A slot that is called when FCST ends, updates GUI state. More...
 
void newProject ()
 A slot attached to a menu action, to start a new project. More...
 
void updateFolderView (const QString &path)
 A slot that is called when fileWatcher reports new files in the workingDir. More...
 
void fileBrowserClicked (QListWidgetItem *item)
 A slot to manage user interaction when a file name is double clicked in the file browser. More...
 
void save_log ()
 A slot to manage user interaction when the menu "Save Log File" action is triggered. More...
 

Private Member Functions

void create_actions ()
 This function creates all actions. More...
 
void create_menus ()
 This function creates all menus. More...
 
bool maybe_save ()
 This function checks, if parameters were changed and show a dialog, if changes should be saved. More...
 
bool save_file (const QString &filename, const QString &newfilename="")
 Save parameters to filename in XML format. More...
 
void load_file (const QString &filename, bool showMsg=true)
 Load parameters from filename in XML format. More...
 
void create_widgets ()
 Function for setting up GUI, used by constructor. More...
 
void create_tab (QString name_)
 Function for creating tab given a file in the local working directory Throws an std::runtime_error if file is not found. More...
 
bool callFCST (QStringList arguments, bool pipeMsg)
 Functions for calling and killing FCST, if pipeMsg is true then FCST output will be displayed on screen. More...
 
void killFCST ()
 
bool setWorkingDir ()
 Function for getting working directory from user. More...
 
void log (const std::string &input)
 Logging function, appends to gui_log.txt. More...
 

Private Attributes

bool callQuit
 
std::map< QString,QTreeWidget * > tree_widget
 This is the trees which we display all parameters. More...
 
std::map< QString, bool > treeStatus
 The status of the individual trees, true if they do not need to be saved. More...
 
QMenu * file_menu
 This menu provides all file actions as open, save, save as and exit More...
 
QMenu * help_menu
 This menu provides some informations about the parameterGUI and about Qt More...
 
QAction * save_log_act
 QAction Start a new project. More...
 
QAction * new_act
 QAction Start a new project. More...
 
QAction * open_act
 QAction open a file. More...
 
QAction * save_act
 QAction save a file. More...
 
QAction * save_as_act
 QAction save as a file. More...
 
QAction * exit_act
 QAction exit the GUI. More...
 
QAction * about_act
 QAction about the parameterGUI. More...
 
QAction * aboutFCST_act
 QAction about the parameterGUI. More...
 
QAction * about_qt_act
 QAction about Qt. More...
 
QStringList current_files
 This value stores the current filename we work on. More...
 
QSettings * gui_settings
 An object for storing user settings. More...
 
QPushButton * nextButton
 Button for driving user events forward. More...
 
QWidget * body
 QWidget elements, essentially panels, to house other elements of interest. More...
 
QWidget * buttonPanel
 
QTextEdit * textOut
 QTextEdit for displaying FCST output to user. More...
 
QLabel * logoLabel
 Elements for displaying FCST logo in bottom left corner. More...
 
QHBoxLayout * hBox
 Dynamic sizers for managing the size and position of visual elements. More...
 
QHBoxLayout * buttonBox
 
QVBoxLayout * vBoxLeft
 
QVBoxLayout * vBoxRight
 
QTabWidget * tabWidget
 
States currentState
 The GUI's current state. More...
 
QListWidget * outputList
 Elements for displaying files output by FCST. More...
 
QFileSystemWatcher * fileWatcher
 
QFont font
 
QLabel * fileLabel
 
QLabel * FCSToutputLabel
 
QProcess * process
 Object for calling FCST. More...
 
QString workingDir
 Strings for important locations. More...
 
QString FCSTBinAddr
 
std::ofstream flog
 ofstream object for logging More...
 
QString paramArg
 OpenFCST binary arguments and file names produced by OpenFCST. More...
 
QString mainFileName
 
QString dataFileName
 
QString optFileName
 

Detailed Description

The MainWindow class of the the FCST parameterGUI.

Modified from the deal.II parameterGUI, which was developed by Martin Steigemann, Wolfgang Bangerth, 2010.

The FCST parameter GUI allows users to start a new "FCST Project" whereby fcst is called to generate default parameter files in a logical sequence (main >> data & opt), allowing the user to manually edit these files, and then eventually run a simulation using FCST and the edited parameter files. Output streams and files are displayed within the user interface, providing the user with a integrated environment in which they can setup and run a simulation from start to finish.

Developer Guide

This application inherits the Qt QMainWindow to provide the functionality of a "main" application, using many of its interfaces.

Visual Elements

The body of the application is composed of several widgets. Each widget is associated with a Box layout element so that it can dynamically expand as the QMainWindow size changes.

Top left: A QTabWidget is used to house several QTreeWidgets which display the loaded parameter files. Bottom Left: A QWidget supports a QLabel (used to display the logo image) and QPushButton Top Right: A read only QTextEdit is used to display fcst output Bottom Right: A QListWidget widget is used to represent a list of files created by fcst

Menus: The menuBar, a member of QMainWindow is populated by two other QMenu's Status Bar: The statusBar is a member of QMainWindow

Maintaining and modifying

Private functions are used to load and set up aspects of the GUI, whilst private slots are used to handle events invoked by the GUI (i.e. a button click). To modify the behaviour of the how the GUI reacts to user interactions please review the slot functions.

The main driving function of the program is the next_click() slot. When the user presses the next button/starts a new project/opens an existing project next_click() will try progress the program state "currentState" along the GUI's enumeration of states "States". The operations associated with each state are as follows:

Start:

Main:

Ready:

Running:

Assumptions of FCST

This program is written with the following assumption of FCST binary's (BIN) interfaces

BIN -p:

BIN -p file_name:

Notes for Qt beginners

Qt online class documentation is very good! If you are wondering about an API just Google any class name.

Most objects in Qt are handled as naked pointers. Object constructors take a pointer to a parent object. The parent will manage their destruction. When the MainWindow is destroyed by the

Note
It is important that all developers learn and understand the Signal/Slots mechanism.
Author
Philip Wardlaw 2014

Member Enumeration Documentation

Enumeration describing states of project creation/simulation execution.

Enumerator
Start 
Main 
Ready 
Running 

Constructor & Destructor Documentation

FCSTGUI::MainWindow::MainWindow ( const QString &  filename = "")

Constructor.

If a filename is given, the MainWindow tries to open and parse the file.

Member Function Documentation

void FCSTGUI::MainWindow::about ( )
privateslot

Show some information on the parameterGUI.

void FCSTGUI::MainWindow::aboutOpenFCST ( )
privateslot

Show some information on the OpenFCST.

bool FCSTGUI::MainWindow::callFCST ( QStringList  arguments,
bool  pipeMsg 
)
private

Functions for calling and killing FCST, if pipeMsg is true then FCST output will be displayed on screen.

void FCSTGUI::MainWindow::closeEvent ( QCloseEvent *  event)
protected

Reimplemented from QMainWindow.

We ask, if changes should be saved.

void FCSTGUI::MainWindow::create_actions ( )
private

This function creates all actions.

void FCSTGUI::MainWindow::create_menus ( )
private

This function creates all menus.

void FCSTGUI::MainWindow::create_tab ( QString  name_)
private

Function for creating tab given a file in the local working directory Throws an std::runtime_error if file is not found.

void FCSTGUI::MainWindow::create_widgets ( )
private

Function for setting up GUI, used by constructor.

void FCSTGUI::MainWindow::fileBrowserClicked ( QListWidgetItem *  item)
privateslot

A slot to manage user interaction when a file name is double clicked in the file browser.

void FCSTGUI::MainWindow::finishedFCST ( int  status,
QProcess::ExitStatus  qStatus 
)
privateslot

A slot that is called when FCST ends, updates GUI state.

void FCSTGUI::MainWindow::killFCST ( )
private
void FCSTGUI::MainWindow::load_file ( const QString &  filename,
bool  showMsg = true 
)
private

Load parameters from filename in XML format.

void FCSTGUI::MainWindow::log ( const std::string &  input)
private

Logging function, appends to gui_log.txt.

bool FCSTGUI::MainWindow::maybe_save ( )
private

This function checks, if parameters were changed and show a dialog, if changes should be saved.

This function should be always called, before open a new parameter file or before closing the GUI

void FCSTGUI::MainWindow::newProject ( )
privateslot

A slot attached to a menu action, to start a new project.

If no files are currently loaded then next_click() is called, otherwise a new instance of FCSTGUI::MainWindow is called by starting a separate process.

void FCSTGUI::MainWindow::next_click ( )
privateslot

A slot for the next button, progresses the GUI's state.

void FCSTGUI::MainWindow::openProject ( )
privateslot

Open a project.

void FCSTGUI::MainWindow::printOutput ( )
privateslot

A slot that should be called to take output from the current process's std and err streams.

bool FCSTGUI::MainWindow::save_as ( )
privateslot

Open a file dialog to save the parameter file.

bool FCSTGUI::MainWindow::save_file ( const QString &  filename,
const QString &  newfilename = "" 
)
private

Save parameters to filename in XML format.

void FCSTGUI::MainWindow::save_log ( )
privateslot

A slot to manage user interaction when the menu "Save Log File" action is triggered.

Saves the OpenFCST simulation log stored in textOut class member.

bool FCSTGUI::MainWindow::saveAll ( )
privateslot

Save the parameter file.

bool FCSTGUI::MainWindow::setWorkingDir ( )
private

Function for getting working directory from user.

void FCSTGUI::MainWindow::tree_was_modified ( )
privateslot

A slot that should be always called, if parameter values were changed.

void FCSTGUI::MainWindow::updateFolderView ( const QString &  path)
privateslot

A slot that is called when fileWatcher reports new files in the workingDir.

Member Data Documentation

QAction* FCSTGUI::MainWindow::about_act
private

QAction about the parameterGUI.

QAction* FCSTGUI::MainWindow::about_qt_act
private

QAction about Qt.

QAction* FCSTGUI::MainWindow::aboutFCST_act
private

QAction about the parameterGUI.

QWidget* FCSTGUI::MainWindow::body
private

QWidget elements, essentially panels, to house other elements of interest.

QHBoxLayout * FCSTGUI::MainWindow::buttonBox
private
QWidget * FCSTGUI::MainWindow::buttonPanel
private
bool FCSTGUI::MainWindow::callQuit
private
QStringList FCSTGUI::MainWindow::current_files
private

This value stores the current filename we work on.

States FCSTGUI::MainWindow::currentState
private

The GUI's current state.

QString FCSTGUI::MainWindow::dataFileName
private
QAction* FCSTGUI::MainWindow::exit_act
private

QAction exit the GUI.

QString FCSTGUI::MainWindow::FCSTBinAddr
private
QLabel * FCSTGUI::MainWindow::FCSToutputLabel
private
QMenu* FCSTGUI::MainWindow::file_menu
private

This menu provides all file actions as open, save, save as and exit

QLabel* FCSTGUI::MainWindow::fileLabel
private
QFileSystemWatcher* FCSTGUI::MainWindow::fileWatcher
private
std::ofstream FCSTGUI::MainWindow::flog
private

ofstream object for logging

QFont FCSTGUI::MainWindow::font
private
QSettings* FCSTGUI::MainWindow::gui_settings
private

An object for storing user settings.

QHBoxLayout* FCSTGUI::MainWindow::hBox
private

Dynamic sizers for managing the size and position of visual elements.

QMenu* FCSTGUI::MainWindow::help_menu
private

This menu provides some informations about the parameterGUI and about Qt

QLabel* FCSTGUI::MainWindow::logoLabel
private

Elements for displaying FCST logo in bottom left corner.

QString FCSTGUI::MainWindow::mainFileName
private
QAction* FCSTGUI::MainWindow::new_act
private

QAction Start a new project.

QPushButton* FCSTGUI::MainWindow::nextButton
private

Button for driving user events forward.

QAction* FCSTGUI::MainWindow::open_act
private

QAction open a file.

QString FCSTGUI::MainWindow::optFileName
private
QListWidget* FCSTGUI::MainWindow::outputList
private

Elements for displaying files output by FCST.

QString FCSTGUI::MainWindow::paramArg
private

OpenFCST binary arguments and file names produced by OpenFCST.

QProcess* FCSTGUI::MainWindow::process
private

Object for calling FCST.

QAction* FCSTGUI::MainWindow::save_act
private

QAction save a file.

QAction* FCSTGUI::MainWindow::save_as_act
private

QAction save as a file.

QAction* FCSTGUI::MainWindow::save_log_act
private

QAction Start a new project.

QTabWidget* FCSTGUI::MainWindow::tabWidget
private
QTextEdit* FCSTGUI::MainWindow::textOut
private

QTextEdit for displaying FCST output to user.

std::map<QString ,QTreeWidget *> FCSTGUI::MainWindow::tree_widget
private

This is the trees which we display all parameters.

std::map<QString , bool> FCSTGUI::MainWindow::treeStatus
private

The status of the individual trees, true if they do not need to be saved.

QVBoxLayout* FCSTGUI::MainWindow::vBoxLeft
private
QVBoxLayout * FCSTGUI::MainWindow::vBoxRight
private
QString FCSTGUI::MainWindow::workingDir
private

Strings for important locations.


The documentation for this class was generated from the following file: