iLand
Public Slots | Signals | Public Member Functions | List of all members
ModelController Class Reference

#include <modelcontroller.h>

Inheritance diagram for ModelController:

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)
 
MainWindowmainWindow ()
 
void connectSignals ()
 
Modelmodel () 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)
 

Constructor & Destructor Documentation

◆ ModelController()

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::~ModelController ( )

Member Function Documentation

◆ addGrid()

void ModelController::addGrid ( const FloatGrid grid,
const QString &  name,
const GridViewType  view_type,
double  min_value,
double  max_value 
)

◆ addLayers()

void ModelController::addLayers ( const LayeredGridBase layers,
const QString &  name 
)

◆ addPaintLayers()

void ModelController::addPaintLayers ( QObject *  handler,
const QStringList  names,
const QVector< GridViewType view_types = QVector<GridViewType>() 
)

◆ availableSpecies()

QList< const Species * > ModelController::availableSpecies ( )

prepare a list of all (active) species

◆ bufferLogs

void ModelController::bufferLogs ( bool  do_buffer)
signal

signal indicating that logs should be buffered (true, model run mode) or that buffering should stop (false) for "interactive" mode

◆ cancel

void ModelController::cancel ( )
slot

cancel execution of the model

◆ canCreate()

bool ModelController::canCreate ( )

return true if the model can be created (settings loaded and model does not exist)

◆ canDestroy()

bool ModelController::canDestroy ( )

model may be destroyed

◆ canRun()

bool ModelController::canRun ( )

model may be run

◆ connectSignals()

void ModelController::connectSignals ( )

◆ continueRun

bool ModelController::continueRun ( )
slot

continues execution if simulation was paused

◆ create

void ModelController::create ( )
slot

create the model

◆ currentYear()

int ModelController::currentYear ( ) const

return current year of the model

◆ destroy

void ModelController::destroy ( )
slot

delete the model

◆ dynamicOutput()

QString ModelController::dynamicOutput ( )

◆ evaluateClick()

QStringList ModelController::evaluateClick ( QObject *  handler,
const QPointF  coord,
const QString &  grid_name 
)

◆ finished

void ModelController::finished ( QString  errorMessage)
signal

model has finished run (errorMessage is empty in case of success)

◆ hasError()

bool ModelController::hasError ( )
inline

returns true if an error occured during the last operation

◆ isBusy()

bool ModelController::isBusy ( )
inline

model is running an operation (startup or simulation)

◆ isFinished()

bool ModelController::isFinished ( )

returns true if there is a valid model state, but the run is finished

◆ isPaused()

bool ModelController::isPaused ( )

returns true if the model is currently paused

◆ isRunning()

bool ModelController::isRunning ( )

model is running

◆ isStartingUp()

bool ModelController::isStartingUp ( )
inline

model is in the creation phase

◆ lastError()

QString ModelController::lastError ( )
inline

error message of the last received error

◆ loadedJavascriptFile()

QString ModelController::loadedJavascriptFile ( ) const
inline

◆ mainWindow()

MainWindow * ModelController::mainWindow ( )
inline

◆ model()

Model * ModelController::model ( ) const
inline

◆ paintMap()

void ModelController::paintMap ( MapGrid map,
double  min_value,
double  max_value 
)

◆ pause

bool ModelController::pause ( )
slot

pause execution, and if paused, continue to run. returns state after change, i.e. true=now in paused mode

◆ preparePaintGrid()

Grid< double > * ModelController::preparePaintGrid ( QObject *  handler,
QString  name,
std::pair< QStringList, QStringList > *  rNamesColors 
)

◆ removeLayers()

void ModelController::removeLayers ( const LayeredGridBase layers)

◆ removePaintLayers()

void ModelController::removePaintLayers ( QObject *  handler)

◆ repaint

void ModelController::repaint ( )
slot

force a repaint of the main drawing window

◆ run

void ModelController::run ( int  years)
slot

run the model

◆ runYear

bool ModelController::runYear ( )
slot

runs a single time step

◆ saveDebugOutputJs

void ModelController::saveDebugOutputJs ( bool  do_clear)
slot

save debug outputs, called from Javascript

◆ saveScreenshot()

void ModelController::saveScreenshot ( QString  file_name)

saves a screenshot of the central view widget to 'file_name'

◆ setDynamicOutputEnabled()

void ModelController::setDynamicOutputEnabled ( bool  enabled)
inline

◆ setFileName

void ModelController::setFileName ( QString  initFileName)
slot

set project file name

◆ setLoadedJavascriptFile()

void ModelController::setLoadedJavascriptFile ( QString  filename)
inline

◆ setMainWindow()

void ModelController::setMainWindow ( MainWindow mw)
inline

◆ setUIShortcuts()

void ModelController::setUIShortcuts ( QVariantMap  shortcuts)

◆ setupDynamicOutput()

void ModelController::setupDynamicOutput ( QString  fieldList)

◆ setViewport()

void ModelController::setViewport ( QPointF  center_point,
double  scale_px_per_m 
)

◆ stateChanged

void ModelController::stateChanged ( )
signal

is emitted when model started/stopped/paused

◆ throwError()

void ModelController::throwError ( const QString  msg)

◆ timeString()

QString ModelController::timeString ( ) const

return a string with elapsed time and estimated remaining time

◆ totalYears()

int ModelController::totalYears ( ) const
inline

returns total number of years to simulate

◆ valueAtHandledGrid()

double ModelController::valueAtHandledGrid ( QObject *  handler,
const QPointF  coord,
const int  layer_id 
)

◆ year

void ModelController::year ( int  year)
signal

signal indicating a year of the simulation has been processed


The documentation for this class was generated from the following files: