FFSM++ 1.1.0
French Forest Sector Model ++
Loading...
Searching...
No Matches
MainWindow.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2015 by Laboratoire d'Economie Forestière *
3 * http://ffsm-project.org *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 3 of the License, or *
8 * (at your option) any later version, given the compliance with the *
9 * exceptions listed in the file COPYING that is distribued together *
10 * with this file. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21 ***************************************************************************/
22#ifndef MAINWINDOW_H
23#define MAINWINDOW_H
24
25#include <iostream>
26#include <string>
27#include <sstream>
28
29#include <QMainWindow>
30#include <QTextEdit>
31#include <QLabel>
32
33#include "ui_MainWindow.h"
34
35// regmas headers..
36#include "ThreadManager.h"
38
39using namespace std;
40
41//class ScenarioSelectionWidget;
42
43/// Main GUI interface
44
45/**
46MainWindow derive from both the generic Qt QMainWindow and from Ui::MainWindow (the latter being the autmatically generated C++ code from QtDesigner).
47<br>It implements code and functionality that can not be done in the QtDesigner.
48*/
49
50class MainWindow : public QMainWindow, public Ui::MainWindow {
51 Q_OBJECT
52
53public:
54 MainWindow(); ///< Constructor
55
56 void setCurrentLogFileName(const QString &fileName);
57 void setCurrentModelFileName(const QString &fileName);
58 bool saveLogFile(const QString &logFileName);
59 QString strippedName(const QString &fullFileName);
60
62 void setModelFileName(const QString curModelFileName_h){curModelFileName=curModelFileName_h;};
63
64public slots:
65 void setUnsavedStatus(bool unsavedStatus_h){unsavedStatus = unsavedStatus_h;};
66 void setOutputDirName(string outputDirName_h){outputDirName = outputDirName_h.c_str();};
67 void addLayer(QString layerName_h, QString layerLabel_h);
68 void switchToLayer(QString layerName_h);
69 void updatePixel(QString layerName_h, int x_h, int y_h, QColor color_h);
70 void updateImage(QString layerName_h, const QImage &image_h);
71 void switchToLayerFromLayerSelector(int layerIndex_h);
72 /// Change value to an existing item in the Status Viewer
73 void treeViewerItemChangeValue(string itemID, string newValue);
74 void treeViewerItemRemove(string itemID);
75 void treeViewerAddItem(string text, string itemID, string parentID); ///< e.g. manager_farmer_manager agents or agent_12345_ownedHa
76 void processLogArea(const QString& message_h);
77 void resetGUIForNewSimulation(); ///< Reset the graphical elements for a new simulation
78 ///// Send the request of getting the pixel info to the main thread
79 //void sendQueryToMainThread(int px_ID);
80 void receiveScenarioOptions(const QVector<QString> &scenarios_h);
81
82
83signals:
85 void selectedScenarioName(const QString &scenarioName_h);
86 void resized();
87
88protected:
89 void closeEvent(QCloseEvent *event); ///< Manage the event of closing the application
90 void resizeEvent(QResizeEvent *event); ///< Manage the event of resizing the application
91
92private slots:
93 void open();
94 bool save();
95 bool saveAs();
99 void openRecentFile(); //already in the ui file ????
100 void hideDebugMsgs(bool hide);
101 void about();
102 void showDocumentation();
103 void openResults();
104
105private:
106
108 QLabel* yearSBLabel; ///< Status bar current year label
109 QLabel* mainSBLabel; ///< Status bar main label
115 QStringList recentFiles;
116 enum { MaxRecentFiles = 5 };
119 bool debugMsgsEnable; ///< Allow debug messages to be show in the logArea
121 /**
122 Ids are based on the name of the item:
123 - general
124 - general_{name}
125 - managers
126 - manager_{managerID}
127 - manager_{managerID}_{name}
128 - agents
129 - agent_{agentUniqueID}
130 - agent_{agentUniqueID}_{name}
131 */
132 map <string, QTreeWidgetItem*> svIndex; ///< Map containing the ID and the pointers to the status viewer
133
134 void createStatusBar();
135 bool okToContinue();
136 void readSettings();
137 void writeSettings();
139};
140
141#endif
Main GUI interface.
Definition MainWindow.h:50
void stopModelMainThread()
void createStatusBar()
bool unsavedStatus
Definition MainWindow.h:110
void setCurrentLogFileName(const QString &fileName)
QString getModelFileName()
Definition MainWindow.h:61
ScenarioSelectionWidget * scenarioWidget
Definition MainWindow.h:120
QString outputDirName
Definition MainWindow.h:111
ThreadManager modelMainThread
Definition MainWindow.h:107
void resized()
void treeViewerItemChangeValue(string itemID, string newValue)
Change value to an existing item in the Status Viewer.
bool okToContinue()
void resetGUIForNewSimulation()
Reset the graphical elements for a new simulation // Send the request of getting the pixel info to th...
void treeViewerAddItem(string text, string itemID, string parentID)
e.g. manager_farmer_manager agents or agent_12345_ownedHa
void treeViewerItemRemove(string itemID)
void pauseOrResumeModelMainThread()
void readSettings()
QLabel * yearSBLabel
Status bar current year label.
Definition MainWindow.h:108
void openRecentFile()
void closeEvent(QCloseEvent *event)
Manage the event of closing the application.
QString strippedName(const QString &fullFileName)
void setOutputDirName(string outputDirName_h)
Definition MainWindow.h:66
void resizeEvent(QResizeEvent *event)
Manage the event of resizing the application.
void receiveScenarioOptions(const QVector< QString > &scenarios_h)
void updateRecentFileActions()
void currentModelFilenameChanged(QString)
void setUnsavedStatus(bool unsavedStatus_h)
Definition MainWindow.h:65
void setModelFileName(const QString curModelFileName_h)
Definition MainWindow.h:62
void writeSettings()
bool debugMsgsEnable
Allow debug messages to be show in the logArea.
Definition MainWindow.h:119
void openResults()
bool saveAs()
void selectedScenarioName(const QString &scenarioName_h)
map< string, QTreeWidgetItem * > svIndex
Map containing the ID and the pointers to the status viewer.
Definition MainWindow.h:132
QAction * separatorAction
Definition MainWindow.h:118
QStringList recentFiles
Definition MainWindow.h:115
void updateImage(QString layerName_h, const QImage &image_h)
QString curLogFileName
Definition MainWindow.h:112
void setCurrentModelFileName(const QString &fileName)
void addLayer(QString layerName_h, QString layerLabel_h)
void processLogArea(const QString &message_h)
void switchToLayer(QString layerName_h)
void updatePixel(QString layerName_h, int x_h, int y_h, QColor color_h)
QString curModelFileName
Definition MainWindow.h:113
void showDocumentation()
QAction * recentFileActions[MaxRecentFiles]
Definition MainWindow.h:117
void startModelMainThread()
void hideDebugMsgs(bool hide)
MainWindow()
Constructor
QString curBaseDirectory
Definition MainWindow.h:114
QLabel * mainSBLabel
Status bar main label.
Definition MainWindow.h:109
bool saveLogFile(const QString &logFileName)
void switchToLayerFromLayerSelector(int layerIndex_h)
Thread manager. Responsable to manage the main thread and "speak" with the GUI.