MeVisLabToolboxReference
MeVis/Foundation/Sources/MLBackgroundTasks/mlModuleBackgroundTask.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00009 //----------------------------------------------------------------------------------
00010 
00011 
00012 #ifndef __mlModuleBackgroundTask_H
00013 #define __mlModuleBackgroundTask_H
00014 
00015 
00016 // Local includes
00017 #include "MLBackgroundTasksSystem.h"
00018 
00019 #include "mlImagingBackgroundTask.h"
00020 
00021 ML_START_NAMESPACE
00022 
00023 class ProcessAllPagesHandler;
00024 
00026 class MLBACKGROUNDTASKS_EXPORT PagedImageProperties : public MedicalImageProperties {
00027 public:
00028   PagedImageProperties() {};
00029   PagedImageProperties(const PagedImage& pagedImage):
00030       MedicalImageProperties(pagedImage),
00031       _pageExtent(pagedImage.getPageExtent())
00032   {
00033     // clear the image properties, since they are not threadsafe!
00034     getImagePropertyContainer().clear();
00035   }
00036 
00038   const ImageVector& getPageExtent() const { return _pageExtent; }
00039 
00040 protected:
00041   ImageVector _pageExtent;
00042 };
00043 
00044 //----------------------------------------------------------------------------------------------------
00045 
00050 class MLBACKGROUNDTASKS_EXPORT ModuleBackgroundTask : public ImagingBackgroundTask
00051 {
00052 public:
00053   ModuleBackgroundTask(Module* module, FloatField* progressField = NULL, StringField* statusField= NULL);
00054 
00055   virtual ~ModuleBackgroundTask();
00056 
00058   void setProgressField(FloatField* field) { _progressField = field; }
00059 
00061   void setStatusField(StringField* field) { _statusField = field; }
00062 
00064   bool hasProgressField() { return !_progressField.isNull(); }
00065 
00067   bool hasStatusField() { return !_statusField.isNull(); }
00068 
00070   virtual void setStatusString(const std::string& status);
00071 
00073   virtual void setProgress(float progress);
00074 
00076   AsyncTileRequest  requestTile(int inputImageIndex, const SubImageBox& box, MLDataType type, const ScaleShiftData& shift = ScaleShiftData(),
00077                            int getTileFlags = ImagingBackgroundTask::UseMemoryManager);
00078 
00084   AsyncTileRequest  requestTileWithExternalBuffer(int inputImageIndex, const SubImageBox& box, MLDataType type, const ScaleShiftData& shift,
00085     ManagedSubImage* externalBuffer, int getTileFlags = ImagingBackgroundTask::ExternalBuffer);
00086 
00089 
00106   ProcessAllPagesRequest requestProcessAllPages(ProcessAllPagesHandler* handler, const SubImageBox& box = SubImageBox());
00107 
00113   ProcessAllPagesRequest requestProcessAllPages(const SubImageBox& box = SubImageBox());
00114 
00121   virtual bool shouldCancelOnInputImageChange(int /*inputIndex*/) const { return true; }
00122 
00124   ImageVector getInputImageExtent(int index = 0) const;
00125 
00127   ImageVector getInputImagePageExtent(int index = 0) const;
00128 
00130   MLDataType getInputImageDataType(int index = 0) const;
00131 
00133   double getInputImageMinVoxelValue(int index = 0) const;
00134 
00136   double getInputImageMaxVoxelValue(int index = 0) const;
00137 
00139 
00143   const MedicalImageProperties& getInputImageProperties(int index = 0) const;
00144 
00146   bool  hasValidInputImage(int index = 0) const;
00147 
00149   int   getNumInputImages() const { return _numInputImages; }
00150 
00151 private:
00152 
00153   Module*      _module;
00154   DistantObject<FloatField>  _progressField;
00155   DistantObject<StringField> _statusField;
00156 
00157   int _numInputImages;
00158   PagedImageProperties** _inputImageProperties;
00159 };
00160 
00161 ML_END_NAMESPACE
00162 
00163 #endif
00164 
00165