MainWindow.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2006-2008 by Antonello Lobianco                         *
00003  *   http://regmas.org                                                     *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 3 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #ifndef MAINWINDOW_H
00021 #define MAINWINDOW_H
00022 
00023 #include <iostream>
00024 #include <string>
00025 #include <sstream>
00026 
00027 #include <QMainWindow>
00028 #include <QTextEdit>
00029 #include <QLabel>
00030 
00031 #include "ui_MainWindow.h"
00032 
00033 // regmas headers..
00034 #include "ThreadManager.h"
00035 #include "ScenarioSelectionWidget.h"
00036 
00037 using namespace std;
00038 
00039 //class ScenarioSelectionWidget;
00040 
00042 
00048 class MainWindow : public QMainWindow, public Ui::MainWindow {
00049     Q_OBJECT
00050 
00051 public:
00052                         MainWindow(); 
00053 
00054     void                setCurrentLogFileName(const QString &fileName);
00055     void                setCurrentModelFileName(const QString &fileName);
00056     bool                saveLogFile(const QString &logFileName);
00057     QString             strippedName(const QString &fullFileName);
00058     
00059     QString             getModelFileName(){return curModelFileName;};
00060     void                setModelFileName(const QString curModelFileName_h){curModelFileName=curModelFileName_h;};
00061 
00062 public slots:
00063     void                setUnsavedStatus(bool unsavedStatus_h){unsavedStatus = unsavedStatus_h;};
00064     void                setOutputDirName(string outputDirName_h){outputDirName = outputDirName_h.c_str();};
00065     void                addLayer(QString layerName_h, QString layerLabel_h);
00066     void                switchToLayer(QString layerName_h);
00067     void                updatePixel(QString layerName_h, int x_h, int y_h, QColor color_h);
00068     void                updateImage(QString layerName_h, const QImage &image_h);
00069     void                switchToLayerFromLayerSelector(int layerIndex_h);
00071     void                treeViewerItemChangeValue(string itemID, string newValue);
00072     void                treeViewerItemRemove(string itemID);
00073     void                treeViewerAddItem(string text, string itemID, string parentID); 
00074     void                processLogArea(const QString& message_h);
00075     void                resetGUIForNewSimulation(); 
00076 
00077     //void                sendQueryToMainThread(int px_ID);
00078     void                receiveScenarioOptions(const QVector<QString> &scenarios_h);
00079 
00080 
00081 signals:
00082     void                currentModelFilenameChanged (QString);
00083     void                selectedScenarioName(const QString &scenarioName_h);
00084 
00085 protected:
00086     void                closeEvent(QCloseEvent *event); 
00087 
00088 private slots:
00089     void                open();
00090     bool                save();
00091     bool                saveAs();
00092     void                startModelMainThread();
00093     void                stopModelMainThread();
00094     void                pauseOrResumeModelMainThread();
00095     void                openRecentFile(); //already in the ui file ????
00096     void                hideDebugMsgs(bool hide);
00097     void                about();
00098     void                showDocumentation();
00099 
00100 private:
00101 
00102     ThreadManager                modelMainThread;
00103     QLabel*                          yearSBLabel; 
00104     QLabel*                          mainSBLabel; 
00105     bool                           unsavedStatus;
00106     QString                        outputDirName;
00107     QString                       curLogFileName;
00108     QString                     curModelFileName;
00109     QString                     curBaseDirectory;
00110     QStringList                      recentFiles;
00111     enum { MaxRecentFiles = 5 };
00112     QAction *  recentFileActions[MaxRecentFiles];
00113     QAction *                    separatorAction;
00114     bool                         debugMsgsEnable; 
00115     ScenarioSelectionWidget      *scenarioWidget;
00127     map <string, QTreeWidgetItem*>       svIndex; 
00128 
00129     void                       createStatusBar();
00130     bool                          okToContinue();
00131     void                          readSettings();
00132     void                         writeSettings();
00133     void               updateRecentFileActions();
00134 };
00135 
00136 #endif