iLand
firescript.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#ifndef FIRESCRIPT_H
20#define FIRESCRIPT_H
21
22#include <QObject>
23#include <QJSValue>
24class FireModule; // forward
25class FireRUData; // forward
26
27class FireScript : public QObject
28{
29 Q_OBJECT
30 Q_PROPERTY(int id READ id)
31 Q_PROPERTY(int x READ x)
32 Q_PROPERTY(int y READ y)
33 Q_PROPERTY(QJSValue onIgnitionRU READ onIgnitionRU WRITE setOnIgnitionRU)
35 Q_PROPERTY(QJSValue onIgnition READ onIgnition WRITE setOnIgnition)
36
37public:
38 explicit FireScript(QObject *parent = nullptr);
39 void setFireModule(FireModule *module) { mFire = module; }
40 int id() const;
41 double x() const;
42 double y() const;
43 static QString fireRUValueType; // for the exporter
44
45 // event handlers
46 QJSValue onIgnitionRU() const
47 {
48 return mOnIgnitionRU;
49 }
50 bool hasIgnitionRUHandler() { return mOnIgnitionRU.isCallable(); }
51
52 // run the handler
54
55 bool hasCalculateFireSizeHandler() { return mCalcFireSize.isCallable(); }
56 double calculateFireSize(const FireRUData *data, double distribution_value);
57 QJSValue onCalculateFireSize() const
58 {
59 return mCalcFireSize;
60 }
61 QJSValue onIgnition() const {return mExternalIgnitions; }
62 void setOnIgnition(QJSValue handler) { mExternalIgnitions = handler; }
63
64signals:
65
66public slots:
73 double ignite(double x, double y, double firesize=-1, double windspeed=-1, double winddirection=-1);
74 double igniteBurnIn(double x, double y, double length, double max_fire_size, bool simulate=false);
75 bool gridToFile(QString grid_type, QString file_name);
77 QJSValue grid(QString type);
78
79 // setters
81 {
82 mOnIgnitionRU = onIgnitionRU;
83 }
84
86 {
87 mCalcFireSize = onCalculateFireSize;
88 }
89
90
91private:
92 FireModule *mFire;
93
94 // event handler
95 QJSValue mOnIgnitionRU;
96 QJSValue mCalcFireSize;
97 QJSValue mExternalIgnitions;
98};
99
100#endif // FIRESCRIPT_H
FireModule is the main class of the fire sub module.
Definition: firemodule.h:141
FireRUData contains data items for resource units.
Definition: firemodule.h:40
FireScript is the scripting shell for the fire module.
Definition: firescript.h:28
QJSValue onIgnitionRU
Definition: firescript.h:33
static QString fireRUValueType
Definition: firescript.h:43
void setOnCalculateFireSize(QJSValue onCalculateFireSize)
Definition: firescript.h:85
int id
Definition: firescript.h:30
QJSValue onIgnition() const
Definition: firescript.h:61
bool hasCalculateFireSizeHandler()
Definition: firescript.h:55
double calcDyanmicManagementEffect(FireRUData *data)
Definition: firescript.cpp:125
QJSValue onCalculateFireSize
Definition: firescript.h:34
double calculateFireSize(const FireRUData *data, double distribution_value)
Definition: firescript.cpp:135
void setOnIgnition(QJSValue handler)
Definition: firescript.h:62
double igniteBurnIn(double x, double y, double length, double max_fire_size, bool simulate=false)
Definition: firescript.cpp:54
QJSValue grid(QString type)
returns a ScriptGrid with the requested type
Definition: firescript.cpp:101
int x
Definition: firescript.h:31
void setOnIgnitionRU(QJSValue onIgnitionRU)
Definition: firescript.h:80
void setFireModule(FireModule *module)
Definition: firescript.h:39
FireScript(QObject *parent=nullptr)
Definition: firescript.cpp:28
QJSValue onCalculateFireSize() const
Definition: firescript.h:57
double ignite(double x, double y, double firesize=-1, double windspeed=-1, double winddirection=-1)
Ignite a fire event with pre-defined properties, i.e.
Definition: firescript.cpp:34
bool gridToFile(QString grid_type, QString file_name)
create a "ESRI-grid" text file 'grid_type' is one of a fixed list of names, 'file_name' the ouptut fi...
Definition: firescript.cpp:74
QJSValue onIgnition
Definition: firescript.h:35
int y
Definition: firescript.h:32
bool hasIgnitionRUHandler()
Definition: firescript.h:50
QJSValue onIgnitionRU() const
Definition: firescript.h:46