iLand
barkbeetlescript.h
Go to the documentation of this file.
1/********************************************************************************************
2** iLand - an individual based forest landscape and disturbance model
3** http://iland-model.org
4** Copyright (C) 2009- Werner Rammer, Rupert Seidl
5**
6** This program is free software: you can redistribute it and/or modify
7** it under the terms of the GNU General Public License as published by
8** the Free Software Foundation, either version 3 of the License, or
9** (at your option) any later version.
10**
11** This program is distributed in the hope that it will be useful,
12** but WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14** GNU General Public License for more details.
15**
16** You should have received a copy of the GNU General Public License
17** along with this program. If not, see <http://www.gnu.org/licenses/>.
18********************************************************************************************/
19
20#ifndef BARKBEETLESCRIPT_H
21#define BARKBEETLESCRIPT_H
22
23#include <QObject>
24#include <QJSValue>
25
26#include "scriptglobal.h"
27
28class BarkBeetleModule; // forward
29
30class BarkBeetleScript : public QObject
31{
32 Q_OBJECT
33 Q_PROPERTY(QJSValue onClick READ onClick WRITE setOnClick)
34 Q_PROPERTY(bool simulate READ simulate WRITE setSimulate)
35 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
36
37public:
38 explicit BarkBeetleScript(QObject *parent = 0);
39 void setBBModule(BarkBeetleModule *module) { mBeetle = module; }
40 QJSValue onClick() const { return mOnClick; }
41 void setOnClick(QJSValue handler) { mOnClick = handler; }
42 // properties
43 bool simulate();
44 void setSimulate(bool do_simulate);
45 bool enabled();
46 void setEnabled(bool do_set_enable);
47signals:
48
49public slots:
50 void test(QString value);
51
52 void init(QJSValue fun);
53 void run(QJSValue fun);
54 double pixelValue(int ix, int iy);
55 void setPixelValue(int ix, int iy, double val);
56
58 double generations(int ix, int iy);
59
60 // the real thing
61 void reloadSettings();
62 void newYear();
63 void runBB(int iteration);
64 void clear();
65 bool gridToFile(QString type, QString filename);
66
68 QJSValue grid(QString type);
70 int damagedArea(int threshold, QString fileName);
71
74 int clearInfestedPixels(QJSValue standmap, int stand_id, double fraction);
75
78 bool setInfested(int x, int y);
80 int setInfestedFromMap(MapGridWrapper *grid, int key, double probability, int agerange);
81
82private:
83
84 QJSValue mOnClick;
85 BarkBeetleModule *mBeetle;
86
87};
88
89#endif // BARKBEETLESCRIPT_H
The BarkBeetleModule class is the main class of the bark beetle module.
Definition: barkbeetlemodule.h:135
BarkBeetleScript is the scripting shell for the bark beetle module.
Definition: barkbeetlescript.h:31
bool gridToFile(QString type, QString filename)
Definition: barkbeetlescript.cpp:128
double pixelValue(int ix, int iy)
Definition: barkbeetlescript.cpp:76
void reloadSettings()
reload the BB-Module settings from the XML-File
Definition: barkbeetlescript.cpp:102
void setEnabled(bool do_set_enable)
Definition: barkbeetlescript.cpp:274
void clear()
reset the barkbeetle module (clear damage and spread data - makes only sense if in simulation mode)
Definition: barkbeetlescript.cpp:120
void run(QJSValue fun)
Definition: barkbeetlescript.cpp:61
bool setInfested(int x, int y)
initiate damage sets pixel at (x/y) (grid indices) as infested, return true if pixel was a potential ...
Definition: barkbeetlescript.cpp:205
void test(QString value)
Definition: barkbeetlescript.cpp:40
int setInfestedFromMap(MapGridWrapper *grid, int key, double probability, int agerange)
set all pixels on stand 'key' on the map 'grid' (with probability 'probability') as infested
Definition: barkbeetlescript.cpp:219
BarkBeetleScript(QObject *parent=0)
Definition: barkbeetlescript.cpp:35
void setPixelValue(int ix, int iy, double val)
Definition: barkbeetlescript.cpp:85
void init(QJSValue fun)
Definition: barkbeetlescript.cpp:45
QJSValue onClick
Definition: barkbeetlescript.h:33
void runBB(int iteration)
run a full cycle of the bark beetle module
Definition: barkbeetlescript.cpp:113
bool enabled
Definition: barkbeetlescript.h:35
int damagedArea(int threshold, QString fileName)
number of damaged pixels with a patchsize>'threshold'; save to grid to "fileName" (if not empty)
Definition: barkbeetlescript.cpp:162
void setOnClick(QJSValue handler)
Definition: barkbeetlescript.h:41
bool simulate
Definition: barkbeetlescript.h:34
QJSValue grid(QString type)
get a JS representation of the grid given by 'type'
Definition: barkbeetlescript.cpp:150
void setSimulate(bool do_simulate)
Definition: barkbeetlescript.cpp:264
int clearInfestedPixels(QJSValue standmap, int stand_id, double fraction)
clear the 'infested' flags on the stand 'stand_id' (on the given 'standmap').
Definition: barkbeetlescript.cpp:180
QJSValue onClick() const
Definition: barkbeetlescript.h:40
double generations(int ix, int iy)
access the number of bark beetle generation at position ix/iy (indices on the 10m grid)
Definition: barkbeetlescript.cpp:92
void setBBModule(BarkBeetleModule *module)
Definition: barkbeetlescript.h:39
void newYear()
start a new "year" (not synced with iLand clock)
Definition: barkbeetlescript.cpp:107
Definition: scriptglobal.h:31