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
21ML_START_NAMESPACE
22
23class ProcessAllPagesHandler;
24
27public:
29 PagedImageProperties(const PagedImage& pagedImage):
30 MedicalImageProperties(pagedImage),
31 _pageExtent(pagedImage.getPageExtent())
32 {
33 // Clear the image properties, since they are not thread-safe!
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
59 void setProgressField(FloatField* field) { _progressField = field; }
60
63 void setStatusField(StringField* field) { _statusField = field; }
64
67 bool hasProgressField() { return !_progressField.isNull(); }
68
71 bool hasStatusField() { return !_statusField.isNull(); }
72
75 void setStatusString(const std::string& status) override;
76
79 void setProgress(float progress) override;
80
83 AsyncTileRequest requestTile(int inputImageIndex, const SubImageBox& box, MLDataType type, const ScaleShiftData& shift = ScaleShiftData(),
85
92 AsyncTileRequest requestTileWithExternalBuffer(int inputImageIndex, const SubImageBox& box, MLDataType type, const ScaleShiftData& shift,
93 ManagedSubImage* externalBuffer, int getTileFlags = ImagingBackgroundTask::ExternalBuffer);
94
98
116
123
130 virtual bool shouldCancelOnInputImageChange(int /*inputIndex*/) const { return true; }
131
133 ImageVector getInputImageExtent(int index = 0) const;
134
137
139 MLDataType getInputImageDataType(int index = 0) const;
140
142 double getInputImageMinVoxelValue(int index = 0) const;
143
145 double getInputImageMaxVoxelValue(int index = 0) const;
146
148
153
155 bool hasValidInputImage(int index = 0) const;
156
158 int getNumInputImages() const { return _numInputImages; }
159
160private:
161
162 Module* _module;
163 DistantObject<FloatField> _progressField;
164 DistantObject<StringField> _statusField;
165
166 int _numInputImages;
167 PagedImageProperties** _inputImageProperties;
168};
169
170ML_END_NAMESPACE
171
172#endif
173
174
#define MLBACKGROUNDTASKS_EXPORT
float progress() const
Status status() const
void clear()
Removes all entries from the container.
An asynchronous tile request. This is copyable!
An asynchronous process all pages request. This is copyable!
ImagingBackgroundTask(void *owner)
ImagePropertyExtensionContainer & getImagePropertyContainer()
Permits access to the container for user image properties.
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
void setProgressField(FloatField *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)
ModuleBackgroundTask(Module *module, FloatField *progressField=nullptr, StringField *statusField=nullptr)
void setProgress(float progress) override
ProcessAllPagesRequest requestProcessAllPages(ProcessAllPagesHandler *handler, const SubImageBox &box=SubImageBox())
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())
void setStatusField(StringField *field)
virtual bool shouldCancelOnInputImageChange(int) const
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)
ImageVector getInputImageExtent(int index=0) const
Returns the extent of the input image at index.
int getNumInputImages() const
Returns the number of input images.
PagedImageProperties extends the MedicalImageProperties with the page extent.
const ImageVector & getPageExtent() const
Returns the page extent.
PagedImageProperties(const PagedImage &pagedImage)
MLint32 MLDataType
Definition mlTypeDefs.h:595
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...
TImageVector< MLint > ImageVector
Defines the standard ImageVector type that is used by the ML for indexing and coordinates.