48 void load(QString file_name);
50 void paint(
double min_value,
double max_value);
57 void createStand(
int stand_id, QString paint_function,
bool wrap_around);
64 double copyPolygonFromRect(QJSValue source,
int id_in,
int id,
double destx,
double desty,
double x1,
double y1,
double x2,
double y2);
88 Q_PROPERTY(
bool qt5 READ
qt5)
97 bool qt5()
const {
return true; }
107 static void loadScript(
const QString &fileName);
124 static QJSValue
valueFromJs(
const QJSValue &js_value,
const QString &key,
const QString default_value=QLatin1Literal(
""),
const QString &errorMessage=QLatin1Literal(
""));
130 void set(QString key, QString value);
131 void print(QString message);
132 void alert(QString message);
133 void include(QString filename);
136 QString
path(QString filename);
143 int addTrees(
const int resourceIndex, QString content);
151 int addSaplings(
int standId,
double x,
double y,
double width,
double height, QString species,
double treeheight,
int age);
153 void removeSaplings(
int standId,
double x,
double y,
double width,
double height);
161 void setViewport(
double x,
double y,
double scale_px_per_m);
164 bool gridToFile(QString grid_type, QString file_name);
167 QJSValue
grid(QString type);
179 void wait(
int milliseconds);
185 bool saveStandCarbon(
int stand_id, QList<int> ru_ids,
bool rid_mode=
true);
195 void throwError(
const QString &errormessage);
Definition: scriptglobal.h:31
double copyPolygonFromRect(QJSValue source, int id_in, int id, double destx, double desty, double x1, double y1, double x2, double y2)
copy a bit of the source-map 'source' to this map.
Definition: scriptglobal.cpp:378
QString name
Definition: scriptglobal.h:34
int valid
Definition: scriptglobal.h:33
~MapGridWrapper()
Definition: scriptglobal.cpp:267
void load(QString file_name)
Definition: scriptglobal.cpp:274
void createMapIndex()
call after creating stands with copyPolygonFromRect
Definition: scriptglobal.cpp:439
bool isValid() const
returns true if map is successfully loaded
Definition: scriptglobal.cpp:282
double area(int id)
retrieve the area (m2) of the polygon denoted by 'id'
Definition: scriptglobal.cpp:452
MapGridWrapper(QObject *parent=nullptr)
Definition: scriptglobal.cpp:258
MapGrid * map() const
acccess for C++ classes
Definition: scriptglobal.h:39
void paint(double min_value, double max_value)
Definition: scriptglobal.cpp:292
void clear()
clears the map (set all values to 0)
Definition: scriptglobal.cpp:303
static void addToScriptEngine(QJSEngine &engine)
Definition: scriptglobal.cpp:247
void createStand(int stand_id, QString paint_function, bool wrap_around)
paint a shape on the stand grid with id stand_id paint_function is a valid expression (paramters: x,...
Definition: scriptglobal.cpp:331
void clearProjectArea()
clear the project area (set to 0), but copy mask with pixels from "outside of project area" (i....
Definition: scriptglobal.cpp:314
void saveAsImage(QString file)
Definition: scriptglobal.cpp:287
Main object of the iLand model composited of various sub models / sub components.
Definition: model.h:90
This is a global interface providing useful functionality for javascripts.
Definition: scriptglobal.h:80
bool loadStandCarbon()
Definition: scriptglobal.cpp:871
void setViewOptions(QJSValue opts)
set current view options
Definition: scriptglobal.cpp:1010
bool qt5() const
is this the qt5-model? (changes in script object creation)
Definition: scriptglobal.h:97
QString currentDir
Definition: scriptglobal.h:85
static QString formattedErrorMessage(const QJSValue &error_value, const QString &sourcecode)
Definition: scriptglobal.cpp:979
void setUIshortcuts(QJSValue shortcuts)
set a list of JS shortcuts in the UI
Definition: scriptglobal.cpp:889
void set(QString key, QString value)
set the value of a setting
Definition: scriptglobal.cpp:104
static void setupGlobalScripting()
Definition: scriptglobal.cpp:1134
void test_tree_mortality(double thresh, int years, double p_death)
Definition: scriptglobal.cpp:898
QVariant setting(QString key)
get a value from the global xml-settings (returns undefined if not present)
Definition: scriptglobal.cpp:95
QString loadTextFile(QString fileName)
load content from a text file in a String (
Definition: scriptglobal.cpp:186
bool screenshot(QString file_name)
make a screenshot from the central viewing widget
Definition: scriptglobal.cpp:543
bool saveModelSnapshot(QString file_name)
saves a snapshot of the current model state (trees, soil, etc.) to a dedicated SQLite database.
Definition: scriptglobal.cpp:806
bool qt5
Definition: scriptglobal.h:88
void repaint()
force a repainting of the GUI visualization (if available)
Definition: scriptglobal.cpp:550
int addSaplingsOnMap(MapGridWrapper *map, const int mapID, QString species, int px_per_hectare, double height, int age)
Definition: scriptglobal.cpp:755
static void loadScript(const QString &fileName)
Definition: scriptglobal.cpp:917
int addTrees(const int resourceIndex, QString content)
add tree distribution
Definition: scriptglobal.cpp:226
bool loadModelSnapshot(QString file_name)
loads a snapshot of the current model state (trees, soil, etc.) from a dedicated SQLite database.
Definition: scriptglobal.cpp:820
QString defaultDirectory(QString dir)
get default directory of category 'dir'
Definition: scriptglobal.cpp:154
void removeSaplings(int standId, double x, double y, double width, double height)
remove all saplings from a metric rectangle. See also addSaplings().
Definition: scriptglobal.cpp:787
ScriptGlobal(QObject *parent=nullptr)
Definition: scriptglobal.cpp:82
bool loadStandSnapshot(int stand_id, QString file_name)
Definition: scriptglobal.cpp:846
QJSValue resourceUnitGrid(QString expression)
return a grid (level of resource units) with the result of an expression evaluated in the context of ...
Definition: scriptglobal.cpp:679
void setViewport(double x, double y, double scale_px_per_m)
set the viewport of the main project area view
Definition: scriptglobal.cpp:556
QJSValue speciesShareGrid(QString species)
return a grid with the basal area of the given species (resource unit resolution)
Definition: scriptglobal.cpp:659
void include(QString filename)
"include" the given script file and evaluate. The path is relative to the "script" path
Definition: scriptglobal.cpp:137
double worldY
Definition: scriptglobal.h:87
bool fileExists(QString fileName)
return true if the given file exists.
Definition: scriptglobal.cpp:194
void saveTextFile(QString fileName, QString content)
save string (content) to a text file.
Definition: scriptglobal.cpp:190
void print(QString message)
print the contents of the message to the log
Definition: scriptglobal.cpp:116
bool saveStandCarbon(int stand_id, QList< int > ru_ids, bool rid_mode=true)
Definition: scriptglobal.cpp:860
bool saveStandSnapshot(int stand_id, QString file_name)
Definition: scriptglobal.cpp:832
int year
Definition: scriptglobal.h:83
void reloadABE()
Definition: scriptglobal.cpp:883
void setCurrentDir(QString newDir)
set current working dir
Definition: scriptglobal.h:102
int addSingleTrees(const int resourceIndex, QString content)
add single trees
Definition: scriptglobal.cpp:215
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: scriptglobal.cpp:568
static QObject * scriptOutput
public "pipe" for script output (is redirected to GUI if available)
Definition: scriptglobal.h:110
QString currentDir() const
current execution directory (default is the Script execution directory)
Definition: scriptglobal.h:101
QJSValue viewOptions()
retrieve current viewing options (JS - object)
void debugOutputFilter(QList< int > ru_indices)
enable debug outputs for a list of resource units (output for other RUs are suppressed)
Definition: scriptglobal.cpp:519
double worldY()
extent of the world (without buffer) in meters (y-direction)
int resourceUnitCount
Definition: scriptglobal.h:84
QJSValue grid(QString type)
return Javascript grid for given type
Definition: scriptglobal.cpp:589
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.
Definition: scriptglobal.cpp:768
static QJSValue valueFromJs(const QJSValue &js_value, const QString &key, const QString default_value=QLatin1Literal(""), const QString &errorMessage=QLatin1Literal(""))
Definition: scriptglobal.cpp:1102
static QString executeJSFunction(QString function)
Definition: scriptglobal.cpp:959
bool stopOutput(QString table_name)
stops output 'table_name'. return true if successful
Definition: scriptglobal.cpp:489
double worldX()
extent of the world (without buffer) in meters (x-direction)
bool saveDebugOutputs(bool do_clear)
save debug outputs to file; if do_clear=true then debug data is cleared from memorey
Definition: scriptglobal.cpp:536
double worldX
Definition: scriptglobal.h:86
int addTreesOnMap(const int standID, QString content)
add trees (distribution mode) for stand 'standID'
Definition: scriptglobal.cpp:235
void wait(int milliseconds)
wait for 'milliseconds' or (if ms=-1 until a key is pressed)
Definition: scriptglobal.cpp:745
static QString JStoString(QJSValue value)
Definition: scriptglobal.cpp:1123
void alert(QString message)
shows a message box to the user (if in GUI mode)
Definition: scriptglobal.cpp:130
QString path(QString filename)
get a path relative to the project main folder
Definition: scriptglobal.cpp:160
static QString executeScript(QString cmd)
Definition: scriptglobal.cpp:941
QJSValue resourceUnit(int index)
access to single resource unit (returns a reference)
Definition: scriptglobal.cpp:701
QJSValue viewOptions
Definition: scriptglobal.h:90
bool startOutput(QString table_name)
starts output 'table_name'. return true if successful
Definition: scriptglobal.cpp:459
bool seedMapToFile(QString species, QString file_name)
save the "seedmap" (i.e. a grid showing the seed distribution) as ESRI rastser file
Definition: scriptglobal.cpp:715
void systemCmd(QString command)
execute system command (e.g., copy files)
Definition: scriptglobal.cpp:199
int msec
Definition: scriptglobal.h:89
The ScriptObjectFactory can instantiate objects of other C++ (QObject-based) types.
Definition: scriptglobal.h:207
QJSValue newSpatialAnalysis()
creates a new SpatialAnalysis object and returns it
Definition: scriptglobal.cpp:1238
QJSValue newMap()
create new instance of Map and return it
Definition: scriptglobal.cpp:1215
ScriptObjectFactory(QObject *parent=nullptr)
Definition: scriptglobal.cpp:1186
int stats()
return the number of created objects
Definition: scriptglobal.h:218
QJSValue newCSVFile(QString filename)
create a new instance of CSVFile and return it
Definition: scriptglobal.cpp:1192
QJSValue newDBHDistribution()
create new instance of DBHDistribution and return it
Definition: scriptglobal.cpp:1224
QJSValue newClimateConverter()
create new instance of ClimateConverter and return it
Definition: scriptglobal.cpp:1205
QJSValue newGrid()
creates a new grid object and return it
Definition: scriptglobal.cpp:1232
Definition: scriptresourceunit.h:8