|
iLand
|
This is a global interface providing useful functionality for javascripts. More...
#include <scriptglobal.h>
Public Slots | |
| QVariant | setting (QString key) |
| get a value from the global xml-settings (returns undefined if not present) More... | |
| void | set (QString key, QString value) |
| set the value of a setting More... | |
| void | print (QString message) |
| print the contents of the message to the log More... | |
| void | alert (QString message) |
| shows a message box to the user (if in GUI mode) More... | |
| void | include (QString filename) |
| "include" the given script file and evaluate. The path is relative to the "script" path More... | |
| QString | defaultDirectory (QString dir) |
| get default directory of category 'dir' More... | |
| QString | path (QString filename) |
| get a path relative to the project main folder More... | |
| QString | loadTextFile (QString fileName) |
| load content from a text file in a String ( More... | |
| void | saveTextFile (QString fileName, QString content) |
save string (content) to a text file. More... | |
| bool | fileExists (QString fileName) |
| return true if the given file exists. More... | |
| void | systemCmd (QString command) |
| execute system command (e.g., copy files) More... | |
| int | addSingleTrees (const int resourceIndex, QString content) |
| add single trees More... | |
| int | addTrees (const int resourceIndex, QString content) |
| add tree distribution More... | |
| int | addTreesOnMap (const int standID, QString content) |
| add trees (distribution mode) for stand 'standID' More... | |
| int | addSaplingsOnMap (MapGridWrapper *map, const int mapID, QString species, int px_per_hectare, double height, int age) |
| int | addSaplings (int standId, double x, double y, double width, double height, QString species, double treeheight, int age) |
add sapling on a metric rectangle given with width and height at x/y. More... | |
| void | removeSaplings (int standId, double x, double y, double width, double height) |
remove all saplings from a metric rectangle. See also addSaplings(). More... | |
| bool | startOutput (QString table_name) |
| starts output 'table_name'. return true if successful More... | |
| bool | stopOutput (QString table_name) |
| stops output 'table_name'. return true if successful More... | |
| void | debugOutputFilter (QList< int > ru_indices) |
| enable debug outputs for a list of resource units (output for other RUs are suppressed) More... | |
| bool | saveDebugOutputs (bool do_clear) |
| save debug outputs to file; if do_clear=true then debug data is cleared from memorey More... | |
| void | setViewport (double x, double y, double scale_px_per_m) |
| set the viewport of the main project area view More... | |
| bool | screenshot (QString file_name) |
| make a screenshot from the central viewing widget More... | |
| void | repaint () |
| force a repainting of the GUI visualization (if available) More... | |
| 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 file location More... | |
| QJSValue | grid (QString type) |
| return Javascript grid for given type More... | |
| QJSValue | speciesShareGrid (QString species) |
| return a grid with the basal area of the given species (resource unit resolution) More... | |
| QJSValue | resourceUnitGrid (QString expression) |
| return a grid (level of resource units) with the result of an expression evaluated in the context of the resource unit. More... | |
| QJSValue | resourceUnit (int index) |
| access to single resource unit (returns a reference) More... | |
| bool | seedMapToFile (QString species, QString file_name) |
| save the "seedmap" (i.e. a grid showing the seed distribution) as ESRI rastser file More... | |
| void | wait (int milliseconds) |
| wait for 'milliseconds' or (if ms=-1 until a key is pressed) More... | |
| bool | saveModelSnapshot (QString file_name) |
| saves a snapshot of the current model state (trees, soil, etc.) to a dedicated SQLite database. More... | |
| bool | loadModelSnapshot (QString file_name) |
| loads a snapshot of the current model state (trees, soil, etc.) from a dedicated SQLite database. More... | |
| bool | saveStandSnapshot (int stand_id, QString file_name) |
| bool | loadStandSnapshot (int stand_id, QString file_name) |
| bool | saveStandCarbon (int stand_id, QList< int > ru_ids, bool rid_mode=true) |
| bool | loadStandCarbon () |
| void | reloadABE () |
| void | setUIshortcuts (QJSValue shortcuts) |
| set a list of JS shortcuts in the UI More... | |
| void | test_tree_mortality (double thresh, int years, double p_death) |
Public Member Functions | |
| ScriptGlobal (QObject *parent=nullptr) | |
| bool | qt5 () const |
| is this the qt5-model? (changes in script object creation) More... | |
| int | msec () const |
| the milliseconds since the start of the day More... | |
| int | year () const |
| current year in the model More... | |
| int | resourceUnitCount () const |
| get number of resource uinit More... | |
| QString | currentDir () const |
| current execution directory (default is the Script execution directory) More... | |
| void | setCurrentDir (QString newDir) |
| set current working dir More... | |
| double | worldX () |
| extent of the world (without buffer) in meters (x-direction) More... | |
| double | worldY () |
| extent of the world (without buffer) in meters (y-direction) More... | |
| QJSValue | viewOptions () |
| retrieve current viewing options (JS - object) More... | |
| void | setViewOptions (QJSValue opts) |
| set current view options More... | |
Static Public Member Functions | |
| static void | setupGlobalScripting () |
| static void | loadScript (const QString &fileName) |
| static QString | executeScript (QString cmd) |
| static QString | executeJSFunction (QString function) |
| static QString | formattedErrorMessage (const QJSValue &error_value, const QString &sourcecode) |
| static QJSValue | valueFromJs (const QJSValue &js_value, const QString &key, const QString default_value=QLatin1Literal(""), const QString &errorMessage=QLatin1Literal("")) |
| static QString | JStoString (QJSValue value) |
Static Public Attributes | |
| static QObject * | scriptOutput = nullptr |
| public "pipe" for script output (is redirected to GUI if available) More... | |
Properties | |
| int | year |
| int | resourceUnitCount |
| QString | currentDir |
| double | worldX |
| double | worldY |
| bool | qt5 |
| int | msec |
| QJSValue | viewOptions |
This is a global interface providing useful functionality for javascripts.
Within javascript-code an instance of this class can be accessed as "Globals" in the global scope (no instantiation necessary).
| ScriptGlobal::ScriptGlobal | ( | QObject * | parent = nullptr | ) |
|
slot |
add sapling on a metric rectangle given with width and height at x/y.
if a standId is provided (-1 or 0: no stand), x/y is relative to the lower left edge of the stand rectangle. If no stand is provided, x/y are absolute (relative to the project area). returns the number of successfully added sapling cells
|
slot |
|
slot |
add single trees
add trees on given resource unit
| content | init file in a string (containing headers) |
|
slot |
add tree distribution
|
slot |
add trees (distribution mode) for stand 'standID'
|
slot |
shows a message box to the user (if in GUI mode)
|
inline |
current execution directory (default is the Script execution directory)
|
slot |
enable debug outputs for a list of resource units (output for other RUs are suppressed)
|
slot |
get default directory of category 'dir'
|
static |
|
static |
|
slot |
return true if the given file exists.
|
static |
|
slot |
return Javascript grid for given type
|
slot |
create a "ESRI-grid" text file 'grid_type' is one of a fixed list of names, 'file_name' the ouptut file location
write grid to a file...
|
slot |
"include" the given script file and evaluate. The path is relative to the "script" path
|
static |
|
slot |
loads a snapshot of the current model state (trees, soil, etc.) from a dedicated SQLite database.
|
static |
|
slot |
|
slot |
|
slot |
load content from a text file in a String (
| int ScriptGlobal::msec | ( | ) | const |
the milliseconds since the start of the day
|
slot |
get a path relative to the project main folder
|
slot |
print the contents of the message to the log
|
inline |
is this the qt5-model? (changes in script object creation)
|
slot |
|
slot |
remove all saplings from a metric rectangle. See also addSaplings().
|
slot |
force a repainting of the GUI visualization (if available)
|
slot |
access to single resource unit (returns a reference)
| int ScriptGlobal::resourceUnitCount | ( | ) | const |
get number of resource uinit
|
slot |
return a grid (level of resource units) with the result of an expression evaluated in the context of the resource unit.
|
slot |
save debug outputs to file; if do_clear=true then debug data is cleared from memorey
|
slot |
saves a snapshot of the current model state (trees, soil, etc.) to a dedicated SQLite database.
|
slot |
|
slot |
|
slot |
save string (content) to a text file.
|
slot |
make a screenshot from the central viewing widget
|
slot |
save the "seedmap" (i.e. a grid showing the seed distribution) as ESRI rastser file
|
slot |
set the value of a setting
|
inline |
set current working dir
|
slot |
get a value from the global xml-settings (returns undefined if not present)
|
slot |
set a list of JS shortcuts in the UI
|
static |
| void ScriptGlobal::setViewOptions | ( | QJSValue | opts | ) |
set current view options
|
slot |
set the viewport of the main project area view
|
slot |
return a grid with the basal area of the given species (resource unit resolution)
|
slot |
starts output 'table_name'. return true if successful
|
slot |
stops output 'table_name'. return true if successful
|
slot |
execute system command (e.g., copy files)
|
slot |
|
static |
| QJSValue ScriptGlobal::viewOptions | ( | ) |
retrieve current viewing options (JS - object)
|
slot |
wait for 'milliseconds' or (if ms=-1 until a key is pressed)
| double ScriptGlobal::worldX | ( | ) |
extent of the world (without buffer) in meters (x-direction)
| double ScriptGlobal::worldY | ( | ) |
extent of the world (without buffer) in meters (y-direction)
| int ScriptGlobal::year | ( | ) | const |
current year in the model
|
static |
public "pipe" for script output (is redirected to GUI if available)
|
readwrite |
|
read |
|
read |
|
read |
|
readwrite |
|
read |
|
read |
|
read |