iLand
|
#include <modelcontroller.h>
Public Slots | |
void | setFileName (QString initFileName) |
set project file name More... | |
void | create () |
create the model More... | |
void | destroy () |
delete the model More... | |
void | run (int years) |
run the model More... | |
bool | runYear () |
runs a single time step More... | |
bool | pause () |
pause execution, and if paused, continue to run. returns state after change, i.e. true=now in paused mode More... | |
bool | continueRun () |
continues execution if simulation was paused More... | |
void | cancel () |
cancel execution of the model More... | |
void | repaint () |
force a repaint of the main drawing window More... | |
void | saveDebugOutputJs (bool do_clear) |
save debug outputs, called from Javascript More... | |
Signals | |
void | finished (QString errorMessage) |
model has finished run (errorMessage is empty in case of success) More... | |
void | year (int year) |
signal indicating a year of the simulation has been processed More... | |
void | bufferLogs (bool do_buffer) |
signal indicating that logs should be buffered (true, model run mode) or that buffering should stop (false) for "interactive" mode More... | |
void | stateChanged () |
is emitted when model started/stopped/paused More... | |
Public Member Functions | |
ModelController () | |
ModelController is a helper class used to control the flow of operations during a model run. More... | |
~ModelController () | |
void | setMainWindow (MainWindow *mw) |
MainWindow * | mainWindow () |
void | connectSignals () |
Model * | model () const |
bool | canCreate () |
return true if the model can be created (settings loaded and model does not exist) More... | |
bool | canDestroy () |
model may be destroyed More... | |
bool | canRun () |
model may be run More... | |
bool | isRunning () |
model is running More... | |
bool | isStartingUp () |
model is in the creation phase More... | |
bool | isFinished () |
returns true if there is a valid model state, but the run is finished More... | |
bool | isPaused () |
returns true if the model is currently paused More... | |
bool | isBusy () |
model is running an operation (startup or simulation) More... | |
bool | hasError () |
returns true if an error occured during the last operation More... | |
QString | lastError () |
error message of the last received error More... | |
int | currentYear () const |
return current year of the model More... | |
int | totalYears () const |
returns total number of years to simulate More... | |
QString | timeString () const |
return a string with elapsed time and estimated remaining time More... | |
void | throwError (const QString msg) |
void | setDynamicOutputEnabled (bool enabled) |
void | setupDynamicOutput (QString fieldList) |
QString | dynamicOutput () |
QList< const Species * > | availableSpecies () |
prepare a list of all (active) species More... | |
void | setLoadedJavascriptFile (QString filename) |
QString | loadedJavascriptFile () const |
void | saveScreenshot (QString file_name) |
saves a screenshot of the central view widget to 'file_name' More... | |
void | addGrid (const FloatGrid *grid, const QString &name, const GridViewType view_type, double min_value, double max_value) |
void | paintMap (MapGrid *map, double min_value, double max_value) |
void | addLayers (const LayeredGridBase *layers, const QString &name) |
void | removeLayers (const LayeredGridBase *layers) |
void | addPaintLayers (QObject *handler, const QStringList names, const QVector< GridViewType > view_types=QVector< GridViewType >()) |
void | removePaintLayers (QObject *handler) |
Grid< double > * | preparePaintGrid (QObject *handler, QString name, std::pair< QStringList, QStringList > *rNamesColors) |
QStringList | evaluateClick (QObject *handler, const QPointF coord, const QString &grid_name) |
double | valueAtHandledGrid (QObject *handler, const QPointF coord, const int layer_id) |
void | setViewport (QPointF center_point, double scale_px_per_m) |
void | setUIShortcuts (QVariantMap shortcuts) |
ModelController::ModelController | ( | ) |
ModelController is a helper class used to control the flow of operations during a model run.
The ModelController encapsulates the Model class and is the main control unit. It is used by the iLand GUI as well as the command line version (ilandc).
ModelController::~ModelController | ( | ) |
void ModelController::addGrid | ( | const FloatGrid * | grid, |
const QString & | name, | ||
const GridViewType | view_type, | ||
double | min_value, | ||
double | max_value | ||
) |
void ModelController::addLayers | ( | const LayeredGridBase * | layers, |
const QString & | name | ||
) |
void ModelController::addPaintLayers | ( | QObject * | handler, |
const QStringList | names, | ||
const QVector< GridViewType > | view_types = QVector<GridViewType>() |
||
) |
QList< const Species * > ModelController::availableSpecies | ( | ) |
prepare a list of all (active) species
|
signal |
signal indicating that logs should be buffered (true, model run mode) or that buffering should stop (false) for "interactive" mode
|
slot |
cancel execution of the model
bool ModelController::canCreate | ( | ) |
return true if the model can be created (settings loaded and model does not exist)
bool ModelController::canDestroy | ( | ) |
model may be destroyed
bool ModelController::canRun | ( | ) |
model may be run
void ModelController::connectSignals | ( | ) |
|
slot |
continues execution if simulation was paused
|
slot |
create the model
int ModelController::currentYear | ( | ) | const |
return current year of the model
|
slot |
delete the model
QString ModelController::dynamicOutput | ( | ) |
QStringList ModelController::evaluateClick | ( | QObject * | handler, |
const QPointF | coord, | ||
const QString & | grid_name | ||
) |
|
signal |
model has finished run (errorMessage is empty in case of success)
|
inline |
returns true if an error occured during the last operation
|
inline |
model is running an operation (startup or simulation)
bool ModelController::isFinished | ( | ) |
returns true if there is a valid model state, but the run is finished
bool ModelController::isPaused | ( | ) |
returns true if the model is currently paused
bool ModelController::isRunning | ( | ) |
model is running
|
inline |
model is in the creation phase
|
inline |
error message of the last received error
|
inline |
|
inline |
|
inline |
void ModelController::paintMap | ( | MapGrid * | map, |
double | min_value, | ||
double | max_value | ||
) |
|
slot |
pause execution, and if paused, continue to run. returns state after change, i.e. true=now in paused mode
Grid< double > * ModelController::preparePaintGrid | ( | QObject * | handler, |
QString | name, | ||
std::pair< QStringList, QStringList > * | rNamesColors | ||
) |
void ModelController::removeLayers | ( | const LayeredGridBase * | layers | ) |
void ModelController::removePaintLayers | ( | QObject * | handler | ) |
|
slot |
force a repaint of the main drawing window
|
slot |
run the model
|
slot |
runs a single time step
|
slot |
save debug outputs, called from Javascript
void ModelController::saveScreenshot | ( | QString | file_name | ) |
saves a screenshot of the central view widget to 'file_name'
|
inline |
|
slot |
set project file name
|
inline |
|
inline |
void ModelController::setUIShortcuts | ( | QVariantMap | shortcuts | ) |
void ModelController::setupDynamicOutput | ( | QString | fieldList | ) |
void ModelController::setViewport | ( | QPointF | center_point, |
double | scale_px_per_m | ||
) |
|
signal |
is emitted when model started/stopped/paused
void ModelController::throwError | ( | const QString | msg | ) |
QString ModelController::timeString | ( | ) | const |
return a string with elapsed time and estimated remaining time
|
inline |
returns total number of years to simulate
double ModelController::valueAtHandledGrid | ( | QObject * | handler, |
const QPointF | coord, | ||
const int | layer_id | ||
) |
|
signal |
signal indicating a year of the simulation has been processed