Rev 1221 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | |||
1033 | werner | 2 | /******************************************************************************************** |
3 | ** iLand - an individual based forest landscape and disturbance model |
||
4 | ** http://iland.boku.ac.at |
||
5 | ** Copyright (C) 2009- Werner Rammer, Rupert Seidl |
||
6 | ** |
||
7 | ** This program is free software: you can redistribute it and/or modify |
||
8 | ** it under the terms of the GNU General Public License as published by |
||
9 | ** the Free Software Foundation, either version 3 of the License, or |
||
10 | ** (at your option) any later version. |
||
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, see <http://www.gnu.org/licenses/>. |
||
19 | ********************************************************************************************/ |
||
20 | |||
961 | werner | 21 | #ifndef BARKBEETLESCRIPT_H |
22 | #define BARKBEETLESCRIPT_H |
||
23 | |||
24 | #include <QObject> |
||
25 | #include <QJSValue> |
||
26 | |||
27 | class BarkBeetleModule; // forward |
||
28 | |||
29 | class BarkBeetleScript : public QObject |
||
30 | { |
||
31 | Q_OBJECT |
||
962 | werner | 32 | Q_PROPERTY(QJSValue onClick READ onClick WRITE setOnClick) |
1024 | werner | 33 | Q_PROPERTY(bool simulate READ simulate WRITE setSimulate) |
1037 | werner | 34 | Q_PROPERTY(bool enabled READ enabled WRITE setEnabled) |
1024 | werner | 35 | |
961 | werner | 36 | public: |
37 | explicit BarkBeetleScript(QObject *parent = 0); |
||
38 | void setBBModule(BarkBeetleModule *module) { mBeetle = module; } |
||
962 | werner | 39 | QJSValue onClick() const { return mOnClick; } |
40 | void setOnClick(QJSValue handler) { mOnClick = handler; } |
||
1029 | werner | 41 | // properties |
42 | bool simulate(); |
||
43 | void setSimulate(bool do_simulate); |
||
1037 | werner | 44 | bool enabled(); |
45 | void setEnabled(bool do_set_enable); |
||
961 | werner | 46 | signals: |
47 | |||
48 | public slots: |
||
49 | void test(QString value); |
||
50 | |||
51 | void init(QJSValue fun); |
||
52 | void run(QJSValue fun); |
||
53 | double pixelValue(int ix, int iy); |
||
54 | void setPixelValue(int ix, int iy, double val); |
||
1010 | werner | 55 | |
1014 | werner | 56 | /// access the number of bark beetle generation at position ix/iy (indices on the 10m grid) |
1008 | werner | 57 | double generations(int ix, int iy); |
961 | werner | 58 | |
1008 | werner | 59 | // the real thing |
1010 | werner | 60 | void reloadSettings(); ///< reload the BB-Module settings from the XML-File |
1055 | werner | 61 | void newYear(); ///< start a new "year" (not synced with iLand clock) |
1013 | werner | 62 | void runBB(int iteration); ///< run a full cycle of the bark beetle module |
63 | void clear(); ///< reset the barkbeetle module (clear damage and spread data - makes only sense if in simulation mode) |
||
1036 | werner | 64 | bool gridToFile(QString type, QString filename); |
1008 | werner | 65 | |
1081 | werner | 66 | /// get a JS representation of the grid given by 'type' |
67 | QJSValue grid(QString type); |
||
68 | /// number of damaged pixels with a patchsize>'threshold'; save to grid to "fileName" (if not empty) |
||
69 | int damagedArea(int threshold, QString fileName); |
||
1014 | werner | 70 | |
1088 | werner | 71 | /// clear the 'infested' flags on the stand 'stand_id' (on the given 'standmap'). |
72 | /// this does not remove trees! |
||
73 | int clearInfestedPixels(QJSValue standmap, int stand_id, double fraction); |
||
1014 | werner | 74 | |
1157 | werner | 75 | /// initiate damage |
76 | /// sets pixel at (x/y) (grid indices) as infested, return true if pixel was a potential host pixel |
||
77 | bool setInfested(int x, int y); |
||
1081 | werner | 78 | |
961 | werner | 79 | private: |
1024 | werner | 80 | |
962 | werner | 81 | QJSValue mOnClick; |
961 | werner | 82 | BarkBeetleModule *mBeetle; |
83 | |||
84 | }; |
||
85 | |||
86 | #endif // BARKBEETLESCRIPT_H |