MeVisLabToolboxReference
ml::ModuleBackgroundTask Class Reference

ModuleBackgroundTask extends the ImagingBackgroundTask with a number of useful methods that allow asynchronous access to the images of a Module. More...

#include <mlModuleBackgroundTask.h>

Inheritance diagram for ml::ModuleBackgroundTask:
ml::ImagingBackgroundTask ml::MessagingBackgroundTask ml::BackgroundTask ml::ProcessAllPagesBackgroundTask

List of all members.

Public Member Functions

 ModuleBackgroundTask (Module *module, FloatField *progressField=NULL, StringField *statusField=NULL)
virtual ~ModuleBackgroundTask ()
void setProgressField (FloatField *field)
 set the progress field (call from GUI thread only!)
void setStatusField (StringField *field)
 set the status field (call from GUI thread only!)
bool hasProgressField ()
 get the progress field (call from GUI thread only!)
bool hasStatusField ()
 get the status field (call from GUI thread only!)
virtual void setStatusString (const std::string &status)
 update the status string while processing (from run() method only)
virtual void setProgress (float progress)
 update the progress while processing (from run() method only)
AsyncTileRequest requestTile (int inputImageIndex, const SubImageBox &box, MLDataType type, const ScaleShiftData &shift=ScaleShiftData(), int getTileFlags=ImagingBackgroundTask::UseMemoryManager)
 Asynchronously request the tile (flags specifies an "or" combination of the BackgroundTask::TileRequestFlags enum)
AsyncTileRequest requestTileWithExternalBuffer (int inputImageIndex, const SubImageBox &box, MLDataType type, const ScaleShiftData &shift, ManagedSubImage *externalBuffer, int getTileFlags=ImagingBackgroundTask::ExternalBuffer)
 Asynchronously request the tile (flags specifies an "or" combination of the BackgroundTask::TileRequestFlags enum) Note that the ownership of externalBuffer is passed to the method, so you are not allowed to delete it before you get it back via TileRequest::getTile().
ProcessAllPagesRequest requestProcessAllPages (ProcessAllPagesHandler *handler, const SubImageBox &box=SubImageBox())
 Asynchronously request a processing of pages using the given handler.
ProcessAllPagesRequest requestProcessAllPages (const SubImageBox &box=SubImageBox())
 Asynchronously request a processing of pages, running Module::processAllPages(-1).
virtual bool shouldCancelOnInputImageChange (int) const
 Returns if the task should be canceled when the given input image has changed.
ImageVector getInputImageExtent (int index=0) const
 get the extent of the input image at index
ImageVector getInputImagePageExtent (int index=0) const
 get the page extent of the input image at index
MLDataType getInputImageDataType (int index=0) const
 get the data type of the input image at index
double getInputImageMinVoxelValue (int index=0) const
 get the min voxel value of the input image at index
double getInputImageMaxVoxelValue (int index=0) const
 get the max voxel value of the input image at index
const MedicalImagePropertiesgetInputImageProperties (int index=0) const
 get the image properties of the input image at index
bool hasValidInputImage (int index=0) const
 returns if the input image at index is valid (and thus it's properties can be requested)
int getNumInputImages () const
 get the number of input images

Detailed Description

ModuleBackgroundTask extends the ImagingBackgroundTask with a number of useful methods that allow asynchronous access to the images of a Module.

It allows passing a progressField and statusField so that setStatusString() and setProgress() will update the fields as well.

Definition at line 50 of file mlModuleBackgroundTask.h.


Constructor & Destructor Documentation

ml::ModuleBackgroundTask::ModuleBackgroundTask ( Module module,
FloatField progressField = NULL,
StringField statusField = NULL 
)
virtual ml::ModuleBackgroundTask::~ModuleBackgroundTask ( ) [virtual]

Member Function Documentation

MLDataType ml::ModuleBackgroundTask::getInputImageDataType ( int  index = 0) const

get the data type of the input image at index

ImageVector ml::ModuleBackgroundTask::getInputImageExtent ( int  index = 0) const

get the extent of the input image at index

double ml::ModuleBackgroundTask::getInputImageMaxVoxelValue ( int  index = 0) const

get the max voxel value of the input image at index

double ml::ModuleBackgroundTask::getInputImageMinVoxelValue ( int  index = 0) const

get the min voxel value of the input image at index

ImageVector ml::ModuleBackgroundTask::getInputImagePageExtent ( int  index = 0) const

get the page extent of the input image at index

const MedicalImageProperties& ml::ModuleBackgroundTask::getInputImageProperties ( int  index = 0) const

get the image properties of the input image at index

Most members are available directly via getInputImage*, but for e.g. the voxel size or the world matrix, access to the MedicalImageProperties is useful.

int ml::ModuleBackgroundTask::getNumInputImages ( ) const [inline]

get the number of input images

Definition at line 149 of file mlModuleBackgroundTask.h.

bool ml::ModuleBackgroundTask::hasProgressField ( ) [inline]

get the progress field (call from GUI thread only!)

Definition at line 64 of file mlModuleBackgroundTask.h.

bool ml::ModuleBackgroundTask::hasStatusField ( ) [inline]

get the status field (call from GUI thread only!)

Definition at line 67 of file mlModuleBackgroundTask.h.

bool ml::ModuleBackgroundTask::hasValidInputImage ( int  index = 0) const

returns if the input image at index is valid (and thus it's properties can be requested)

ProcessAllPagesRequest ml::ModuleBackgroundTask::requestProcessAllPages ( ProcessAllPagesHandler handler,
const SubImageBox box = SubImageBox() 
)

Asynchronously request a processing of pages using the given handler.

NOTE: The ownership of the handler is passed to the method, so it MAY NOT be accessed or deleted until ProcessAllPagesRequest::waitUntilFinished() returns true.

A common use of this method is the following:

   MyProcessAllPagesHandler* handler = new MyProcessAllPagesHandler;

   // setup the handler
   //handler->setSomeParameters();

   bool result = requestProcessAllPages(handler).waitUntilFinished();
   if (result) {
     // get result values of handler
     // handler->getSomeResult();

     // only delete handler if we received result==true
     delete handler;
   }
ProcessAllPagesRequest ml::ModuleBackgroundTask::requestProcessAllPages ( const SubImageBox box = SubImageBox())

Asynchronously request a processing of pages, running Module::processAllPages(-1).

NOTE: It is preferable to use the version above using a ProcessAllPagesHandler, since this avoids side effects with the Module! We strongly encourage you to use a ProcessAllPagesHandler instead, since it will be much clearer what happens and it will not interfere with a processAllPages(-1) call that the Module might issue while the background task is running.

AsyncTileRequest ml::ModuleBackgroundTask::requestTile ( int  inputImageIndex,
const SubImageBox box,
MLDataType  type,
const ScaleShiftData shift = ScaleShiftData(),
int  getTileFlags = ImagingBackgroundTask::UseMemoryManager 
)

Asynchronously request the tile (flags specifies an "or" combination of the BackgroundTask::TileRequestFlags enum)

AsyncTileRequest ml::ModuleBackgroundTask::requestTileWithExternalBuffer ( int  inputImageIndex,
const SubImageBox box,
MLDataType  type,
const ScaleShiftData shift,
ManagedSubImage externalBuffer,
int  getTileFlags = ImagingBackgroundTask::ExternalBuffer 
)

Asynchronously request the tile (flags specifies an "or" combination of the BackgroundTask::TileRequestFlags enum) Note that the ownership of externalBuffer is passed to the method, so you are not allowed to delete it before you get it back via TileRequest::getTile().

If getTile() returns NULL, the externalBuffer is already deleted internally. To support own destruction of the memory, you may derive from ManagedSubImage and reimplement the destructor.

virtual void ml::ModuleBackgroundTask::setProgress ( float  progress) [virtual]

update the progress while processing (from run() method only)

Reimplemented from ml::BackgroundTask.

void ml::ModuleBackgroundTask::setProgressField ( FloatField field) [inline]

set the progress field (call from GUI thread only!)

Definition at line 58 of file mlModuleBackgroundTask.h.

void ml::ModuleBackgroundTask::setStatusField ( StringField field) [inline]

set the status field (call from GUI thread only!)

Definition at line 61 of file mlModuleBackgroundTask.h.

virtual void ml::ModuleBackgroundTask::setStatusString ( const std::string &  status) [virtual]

update the status string while processing (from run() method only)

Reimplemented from ml::BackgroundTask.

virtual bool ml::ModuleBackgroundTask::shouldCancelOnInputImageChange ( int  ) const [inline, virtual]

Returns if the task should be canceled when the given input image has changed.

The default implementation returns true, so that any input image change will cancel the task (NOTE: this flag needs to be used from handleNotification(), this is typically be done in BackgroundTaskBaseModule). If your reimplement this method, make sure that it can safely be called from the GUI thread.

Definition at line 121 of file mlModuleBackgroundTask.h.


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