Rev 646 | Rev 649 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 646 | Rev 647 | ||
---|---|---|---|
1 | Redirecting to URL 'https://iland.boku.ac.at/svn/iland/tags/release_1.0/src/core/modelcontroller.h': |
1 | Redirecting to URL 'https://iland.boku.ac.at/svn/iland/tags/release_1.0/src/core/modelcontroller.h': |
2 | #ifndef MODELCONTROLLER_H
|
2 | #ifndef MODELCONTROLLER_H
|
3 | #define MODELCONTROLLER_H
|
3 | #define MODELCONTROLLER_H
|
4 | #include <QObject>
|
4 | #include <QObject>
|
5 | #include <QHash>
|
5 | #include <QHash>
|
6 | #include "grid.h"
|
6 | #include "grid.h"
|
7 | #include "layeredgrid.h"
|
7 | #include "layeredgrid.h"
|
8 | class Model; |
8 | class Model; |
9 | class MainWindow; |
9 | class MainWindow; |
10 | class MapGrid; |
10 | class MapGrid; |
11 | 11 | ||
12 | class ModelController: public QObject |
12 | class ModelController: public QObject |
13 | {
|
13 | {
|
14 | Q_OBJECT |
14 | Q_OBJECT |
15 | public: |
15 | public: |
16 | ModelController(); |
16 | ModelController(); |
17 | ~ModelController(); |
17 | ~ModelController(); |
18 | void setMainWindow(MainWindow *mw) { mViewerWindow = mw; } |
18 | void setMainWindow(MainWindow *mw) { mViewerWindow = mw; } |
19 | void connectSignals(); // connect signal/slots to the main window if available |
19 | void connectSignals(); // connect signal/slots to the main window if available |
20 | Model *model() const { return mModel; } |
20 | Model *model() const { return mModel; } |
21 | // bool checkers...
|
21 | // bool checkers...
|
22 | bool canCreate(); ///< return true if the model can be created (settings loaded and model does not exist) |
22 | bool canCreate(); ///< return true if the model can be created (settings loaded and model does not exist) |
23 | bool canDestroy(); ///< model may be destroyed |
23 | bool canDestroy(); ///< model may be destroyed |
24 | bool canRun(); ///< model may be run |
24 | bool canRun(); ///< model may be run |
25 | bool isRunning(); ///< model is running |
25 | bool isRunning(); ///< model is running |
26 | bool isFinished(); ///< returns true if there is a valid model state, but the run is finished |
26 | bool isFinished(); ///< returns true if there is a valid model state, but the run is finished |
27 | // simulation length
|
27 | // simulation length
|
28 | int currentYear() const; ///< return current year of the model |
28 | int currentYear() const; ///< return current year of the model |
29 | int totalYears() const { return mYearsToRun; } ///< returns total number of years to simulate |
29 | int totalYears() const { return mYearsToRun; } ///< returns total number of years to simulate |
30 | // error handling
|
30 | // error handling
|
31 | void throwError(const QString msg); |
31 | void throwError(const QString msg); |
32 | // dynamic outputs (variable fields)
|
32 | // dynamic outputs (variable fields)
|
33 | void setupDynamicOutput(QString fieldList); |
33 | void setupDynamicOutput(QString fieldList); |
34 | QString dynamicOutput(); |
34 | QString dynamicOutput(); |
35 | // some informational services
|
35 | // some informational services
|
36 | QHash<QString, QString> availableSpecies(); |
36 | QHash<QString, QString> availableSpecies(); |
37 | 37 | ||
38 | void saveScreenshot(QString file_name); ///< saves a screenshot of the central view widget to 'file_name' |
38 | void saveScreenshot(QString file_name); ///< saves a screenshot of the central view widget to 'file_name' |
39 | void paintGrid(const FloatGrid *grid, const QString &name, const GridViewType view_type, double min_value, double max_value); |
39 | void paintGrid(const FloatGrid *grid, const QString &name, const GridViewType view_type, double min_value, double max_value); |
40 | void paintMap(MapGrid *map, double min_value, double max_value); |
40 | void paintMap(MapGrid *map, double min_value, double max_value); |
41 | 41 | ||
42 | void addLayers(const LayeredGridBase *layers); |
- | |
- | 42 | void addLayers(const LayeredGridBase *layers, const QString &name); |
|
43 | void setViewport(QPointF center_point, double scale_px_per_m); |
43 | void setViewport(QPointF center_point, double scale_px_per_m); |
44 | signals:
|
44 | signals:
|
45 | void finished(QString errorMessage); |
45 | void finished(QString errorMessage); |
46 | void year(int year); |
46 | void year(int year); |
47 | void bufferLogs(bool do_buffer); |
47 | void bufferLogs(bool do_buffer); |
48 | public slots: |
48 | public slots: |
49 | void setFileName(QString initFileName); ///< set project file name |
49 | void setFileName(QString initFileName); ///< set project file name |
50 | void create(); ///< create the model |
50 | void create(); ///< create the model |
51 | void destroy(); ///< delete the model |
51 | void destroy(); ///< delete the model |
52 | void run(int years); ///< run the model |
52 | void run(int years); ///< run the model |
53 | bool runYear(); ///< runs a single time step |
53 | bool runYear(); ///< runs a single time step |
54 | bool pause(); ///< pause execution, and if paused, continue to run. returns state *after* change, i.e. true=now in paused mode |
54 | bool pause(); ///< pause execution, and if paused, continue to run. returns state *after* change, i.e. true=now in paused mode |
55 | void cancel(); ///< cancel execution of the model |
55 | void cancel(); ///< cancel execution of the model |
56 | private slots: |
56 | private slots: |
57 | void runloop(); |
57 | void runloop(); |
58 | private: |
58 | private: |
59 | void fetchDynamicOutput(); |
59 | void fetchDynamicOutput(); |
60 | MainWindow *mViewerWindow; |
60 | MainWindow *mViewerWindow; |
61 | Model *mModel; |
61 | Model *mModel; |
62 | bool mPaused; |
62 | bool mPaused; |
63 | bool mRunning; |
63 | bool mRunning; |
64 | bool mFinished; |
64 | bool mFinished; |
65 | bool mCanceled; |
65 | bool mCanceled; |
66 | int mYearsToRun; |
66 | int mYearsToRun; |
67 | QString mInitFile;
|
67 | QString mInitFile;
|
68 | QStringList mDynFieldList;
|
68 | QStringList mDynFieldList;
|
69 | QStringList mDynData;
|
69 | QStringList mDynData;
|
70 | 70 | ||
71 | }; |
71 | }; |
72 | 72 | ||
73 | #endif // MODELCONTROLLER_H
|
73 | #endif // MODELCONTROLLER_H
|
74 | 74 |