MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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
27{
28public:
32 , _pageExtent(pagedImage.getPageExtent())
33 {
34 // Clear the image properties, since they are not thread-safe!
36 }
37
40 {
41 return _pageExtent;
42 }
43
44protected:
46};
47
48//----------------------------------------------------------------------------------------------------
49
55{
56public:
57 ModuleBackgroundTask(Module* module, FloatField* progressField = nullptr, StringField* statusField = nullptr);
58
60
64 {
65 _progressField = field;
66 }
67
71 {
72 _statusField = field;
73 }
74
78 {
79 return !_progressField.isNull();
80 }
81
85 {
86 return !_statusField.isNull();
87 }
88
91 void setStatusString(const std::string& status) override;
92
95 void setProgress(float progress) override;
96
100 const ScaleShiftData& shift = ScaleShiftData(),
101 int getTileFlags = ImagingBackgroundTask::UseMemoryManager);
102
111 int getTileFlags = ImagingBackgroundTask::ExternalBuffer);
112
117
135 const SubImageBox& box = SubImageBox());
136
143
150 virtual bool shouldCancelOnInputImageChange(int /*inputIndex*/) const
151 {
152 return true;
153 }
154
156 ImageVector getInputImageExtent(int index = 0) const;
157
160
162 MLDataType getInputImageDataType(int index = 0) const;
163
165 double getInputImageMinVoxelValue(int index = 0) const;
166
168 double getInputImageMaxVoxelValue(int index = 0) const;
169
171
176
178 bool hasValidInputImage(int index = 0) const;
179
182 {
183 return _numInputImages;
184 }
185
186private:
187 Module* _module;
188 DistantObject<FloatField> _progressField;
189 DistantObject<StringField> _statusField;
190
191 int _numInputImages;
192 PagedImageProperties** _inputImageProperties;
193};
194
196
197#endif
#define MLBACKGROUNDTASKS_EXPORT
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:449
void clear()
Removes all entries from the container.
An asynchronous tile request. This is copyable!
An asynchronous process all pages request. This is 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 several useful methods that allow asynchr...
double getInputImageMinVoxelValue(int index=0) const
Returns the minimum voxel value of the input image at index.
~ModuleBackgroundTask() override
void setStatusString(const std::string &status) override
Updates the status string while processing.
void setProgressField(FloatField *field)
Sets the progress field.
MLDataType getInputImageDataType(int index=0) const
Returns 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.
ModuleBackgroundTask(Module *module, FloatField *progressField=nullptr, StringField *statusField=nullptr)
void setProgress(float progress) override
Updates the progress while processing.
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 whether the input image at index is valid and thus its properties can be requested.
ImageVector getInputImagePageExtent(int index=0) const
Returns the page extent of the input image at index.
double getInputImageMaxVoxelValue(int index=0) const
Returns the maximum voxel value of the input image at index.
ProcessAllPagesRequest requestProcessAllPages(const SubImageBox &box=SubImageBox())
Asynchronously request a processing of pages and running Module::processAllPages(-1).
void setStatusField(StringField *field)
Sets the status field.
bool hasStatusField()
Returns whether this task has a status field.
virtual bool shouldCancelOnInputImageChange(int) const
Returns whether the task should be canceled when the given input image has changed.
const MedicalImageProperties & getInputImageProperties(int index=0) const
Returns 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.
ImageVector getInputImageExtent(int index=0) const
Returns the extent of the input image at index.
bool hasProgressField()
Returns whether this task has a progress field.
int getNumInputImages() const
Returns the number of input images.
Base class for an image processing module of the ML.
Definition mlModule.h:150
PagedImageProperties extends the MedicalImageProperties with the page extent.
const ImageVector & getPageExtent() const
Returns the page extent.
PagedImageProperties(const PagedImage &pagedImage)
The class PagedImage, representing a fragmented image that manages properties and data of an image lo...
Base class for handlers that are used for the Module::processAllPages facility.
Field to encapsulate a string value.
Definition mlFields.h:634
MLint32 MLDataType
MLDataType.
Definition mlTypeDefs.h:592
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
Defines the standard SubImageBox type used in the ML. Its size varies with the size of the MLint type...