MeVisLab Toolbox Reference
mlModuleBackgroundTask.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2009, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_MODULE_BACKGROUND_TASK_H
14#define ML_MODULE_BACKGROUND_TASK_H
15
16// Local includes
18
20
22
23class ProcessAllPagesHandler;
24
27public:
31 _pageExtent(pagedImage.getPageExtent())
32 {
33 // clear the image properties, since they are not threadsafe!
35 }
36
38 const ImageVector& getPageExtent() const { return _pageExtent; }
39
40protected:
42};
43
44//----------------------------------------------------------------------------------------------------
45
51{
52public:
53 ModuleBackgroundTask(Module* module, FloatField* progressField = nullptr, StringField* statusField= nullptr);
54
56
58 void setProgressField(FloatField* field) { _progressField = field; }
59
61 void setStatusField(StringField* field) { _statusField = field; }
62
64 bool hasProgressField() { return !_progressField.isNull(); }
65
67 bool hasStatusField() { return !_statusField.isNull(); }
68
70 void setStatusString(const std::string& status) override;
71
73 void setProgress(float progress) override;
74
77 int getTileFlags = ImagingBackgroundTask::UseMemoryManager);
78
85 ManagedSubImage* externalBuffer, int getTileFlags = ImagingBackgroundTask::ExternalBuffer);
86
89
107
114
121 virtual bool shouldCancelOnInputImageChange(int /*inputIndex*/) const { return true; }
122
124 ImageVector getInputImageExtent(int index = 0) const;
125
128
130 MLDataType getInputImageDataType(int index = 0) const;
131
133 double getInputImageMinVoxelValue(int index = 0) const;
134
136 double getInputImageMaxVoxelValue(int index = 0) const;
137
139
144
146 bool hasValidInputImage(int index = 0) const;
147
149 int getNumInputImages() const { return _numInputImages; }
150
151private:
152
153 Module* _module;
154 DistantObject<FloatField> _progressField;
155 DistantObject<StringField> _statusField;
156
157 int _numInputImages;
158 PagedImageProperties** _inputImageProperties;
159};
160
162
163#endif
164
165
#define MLBACKGROUNDTASKS_EXPORT
Project global and OS specific declarations.
A DistantObject stores the pointer to an object of type T and forbids direct access to the stored poi...
Field to encapsulate a float value.
Definition mlFields.h:415
void clear()
Removes all entries from the container.
an asynchronous tile request (copyable!)
an asynchronous process all pages request (copyable!)
ManagedSubImage is derived from SubImage and frees its allocated memory automatically when it is dest...
This class encapsulates basic medical image properties:
ImagePropertyExtensionContainer & getImagePropertyContainer()
Permits access to the container for user image properties.
ModuleBackgroundTask extends the ImagingBackgroundTask with a number of useful methods that allow asy...
double getInputImageMinVoxelValue(int index=0) const
get the min voxel value of the input image at index
~ModuleBackgroundTask() override
void setStatusString(const std::string &status) override
update the status string while processing (from run() method only)
void setProgressField(FloatField *field)
set the progress field (call from GUI thread only!)
MLDataType getInputImageDataType(int index=0) const
get the data type of the input image at index
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::TileReque...
ModuleBackgroundTask(Module *module, FloatField *progressField=nullptr, StringField *statusField=nullptr)
void setProgress(float progress) override
update the progress while processing (from run() method only)
ProcessAllPagesRequest requestProcessAllPages(ProcessAllPagesHandler *handler, const SubImageBox &box=SubImageBox())
Asynchronously request a processing of pages using the given handler.
bool hasValidInputImage(int index=0) const
returns if the input image at index is valid (and thus it's properties can be requested)
ImageVector getInputImagePageExtent(int index=0) const
get the page extent of the input image at index
double getInputImageMaxVoxelValue(int index=0) const
get the max voxel value of the input image at index
ProcessAllPagesRequest requestProcessAllPages(const SubImageBox &box=SubImageBox())
Asynchronously request a processing of pages, running Module::processAllPages(-1).
void setStatusField(StringField *field)
set the status field (call from GUI thread only!)
bool hasStatusField()
get the status field (call from GUI thread only!)
virtual bool shouldCancelOnInputImageChange(int) const
Returns if the task should be canceled when the given input image has changed.
const MedicalImageProperties & getInputImageProperties(int index=0) const
get the image properties of the input image at index
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::TileReque...
ImageVector getInputImageExtent(int index=0) const
get the extent of the input image at index
bool hasProgressField()
get the progress field (call from GUI thread only!)
int getNumInputImages() const
get the number of input images
Base class for an image processing module of the ML.
Definition mlModule.h:151
PagedImageProperties extends the MedicalImageProperties with the page extent.
const ImageVector & getPageExtent() const
Get the page extent.
PagedImageProperties(const PagedImage &pagedImage)
Class which represents an image, which manages properties of an image and image data which is located...
Base class for handlers that are used for the Module::processAllPages facility.
Field to encapsulate a string value.
Definition mlFields.h:610
MLint32 MLDataType
MLDataType.
Definition mlTypeDefs.h:596
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
TScaleShiftData< MLdouble > ScaleShiftData
Double version of TScaleShiftData for maximum reasonable precision.
TSubImageBox< MLint > SubImageBox
Define the standard SubImageBox type used in the ML. Its size varies with the size of the MLint type.