Rev 1221 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
701 | werner | 1 | /******************************************************************************************** |
2 | ** iLand - an individual based forest landscape and disturbance model |
||
3 | ** http://iland.boku.ac.at |
||
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 | ********************************************************************************************/ |
||
793 | werner | 19 | #include <QJSValue> |
20 | #include <QJSEngine> |
||
21 | |||
701 | werner | 22 | #include "global.h" |
23 | #include "resourceunit.h" |
||
24 | |||
25 | #include "windplugin.h" |
||
26 | #include "windmodule.h" |
||
716 | werner | 27 | #include "windscript.h" |
1054 | werner | 28 | #include "windout.h" |
29 | #include "outputmanager.h" |
||
30 | |||
780 | werner | 31 | #if QT_VERSION < 0x050000 |
701 | werner | 32 | Q_EXPORT_PLUGIN2(iland_wind, WindPlugin) |
780 | werner | 33 | #endif |
701 | werner | 34 | |
35 | WindPlugin::WindPlugin() |
||
36 | { |
||
37 | qDebug() << "Wind plugin created"; |
||
38 | DBGMODE( qDebug("(Wind plugin in debug mode)");); |
||
39 | mWind = 0; |
||
1054 | werner | 40 | mWindOut = 0; |
701 | werner | 41 | } |
42 | |||
43 | WindPlugin::~WindPlugin() |
||
44 | { |
||
45 | if (mWind) |
||
46 | delete mWind; |
||
47 | mWind = 0; |
||
48 | qDebug() << "wind plugin destroyed."; |
||
49 | } |
||
50 | |||
51 | QString WindPlugin::name() |
||
52 | { |
||
53 | return "wind"; |
||
54 | } |
||
55 | |||
56 | QString WindPlugin::version() |
||
57 | { |
||
58 | return "0.1"; |
||
59 | } |
||
60 | |||
61 | QString WindPlugin::description() |
||
62 | { |
||
63 | return "Wind disturbance module for iLand. " \ |
||
1054 | werner | 64 | "Designed and written by Rupert Seidl/Werner Rammer."; |
701 | werner | 65 | } |
66 | |||
67 | void WindPlugin::setup() |
||
68 | { |
||
1054 | werner | 69 | if (!mWind) |
70 | mWind = new WindModule; |
||
71 | |||
701 | werner | 72 | mWind->setup(); |
1054 | werner | 73 | |
74 | mWindOut = new WindOut(); |
||
75 | mWindOut->setWindModule(mWind); |
||
76 | GlobalSettings::instance()->outputManager()->removeOutput(mWindOut->tableName()); |
||
77 | GlobalSettings::instance()->outputManager()->addOutput(mWindOut); |
||
78 | |||
701 | werner | 79 | } |
80 | |||
81 | void WindPlugin::setupResourceUnit(const ResourceUnit *ru) |
||
82 | { |
||
717 | werner | 83 | mWind->setupResourceUnit(ru); |
701 | werner | 84 | } |
85 | |||
793 | werner | 86 | void WindPlugin::setupScripting(QJSEngine *engine) |
701 | werner | 87 | { |
716 | werner | 88 | WindScript *wind_script = new WindScript(); |
89 | wind_script->setModule(mWind); |
||
793 | werner | 90 | QJSValue obj = engine->newQObject(wind_script); |
716 | werner | 91 | engine->globalObject().setProperty("Wind", obj); |
92 | |||
93 | qDebug() << "setup scripting for windmodule called..."; |
||
701 | werner | 94 | } |
95 | |||
96 | void WindPlugin::yearBegin() |
||
97 | { |
||
98 | } |
||
99 | |||
100 | void WindPlugin::run() |
||
101 | { |
||
102 | mWind->run(); |
||
103 | } |
||
104 | |||
105 | |||
106 | |||
107 |