13 #ifndef mitkNonBlockingAlgorithm_h
14 #define mitkNonBlockingAlgorithm_h
19 #include <itkObjectFactory.h>
38 #define mitkAlgorithmNewMacro(classname) \
43 classname *rawPtr = new classname(); \
44 Pointer smartPtr = rawPtr; \
45 rawPtr->UnRegister(); \
46 rawPtr->Initialize(); \
51 virtual::itk::LightObject::Pointer \
52 CreateAnother(void) const override \
55 Pointer smartPtr = classname::New(); \
56 ::itk::LightObject::Pointer lightPtr = smartPtr.GetPointer(); \
57 smartPtr->Initialize(this); \
111 template <
typename T>
126 template <
typename T>
131 m_ParameterListMutex.lock();
133 m_ParameterListMutex.unlock();
160 template <
typename TPixel,
unsigned int VImageDimension>
168 SetPointerParameter(parameter, mitkImage);
181 template <
typename TPixel,
unsigned int VImageDimension>
190 SetPointerParameter(parameter, mitkImage);
200 template <
typename T>
215 std::string error(
"There is no parameter \"");
218 throw std::invalid_argument(error);
228 template <
typename T>
248 std::string error(
"There is no parameter \"");
251 throw std::invalid_argument(error);
324 typedef std::map<std::string, unsigned long> MapTypeStringUInt;
326 MapTypeStringUInt m_TriggerPropertyConnections;
328 std::mutex m_ParameterListMutex;
330 int m_UpdateRequests;
331 std::thread m_Thread;
#define MITKALGORITHMSEXT_EXPORT
Base class of all data objects.
Abstract base class for properties.
Abstract data management class that organizes DataNode objects in a directed acyclic graph.
Template class for generating properties for simple value types (int, float, bool,...
virtual T GetValue() const
Get the property value.
Base class for algorithms that can run in a background thread.
void ThreadedUpdateFailed(const itk::EventObject &event)
GUI-thread callback when the threaded update fails.
void GetParameter(const char *parameter, T &value) const
Get a parameter of any normal (value) type.
virtual bool ReadyToRun()
virtual void Reset()
Reset the algorithm to its initial state.
~NonBlockingAlgorithm() override
WeakPointer< DataStorage > m_DataStorage
virtual void ThreadedUpdateSuccessful()
PropertyList::Pointer m_Parameters
void SetItkImageAsMITKImagePointerParameter(const char *parameter, const itk::SmartPointer< itk::Image< TPixel, VImageDimension >> &itkImage)
Set an ITK image as a MITK Image parameter (smart pointer version).
virtual void Initialize(const NonBlockingAlgorithm *other=nullptr)
void DefineTriggerParameter(const char *)
void StartAlgorithm()
Start the algorithm asynchronously in a background thread.
void SetPointerParameter(const char *parameter, BaseData *value)
Set a parameter that holds a BaseData pointer (Image, Surface, etc.).
void TriggerParameterModified(const itk::EventObject &event)
Callback invoked when a trigger parameter is modified.
void GetPointerParameter(const char *parameter, itk::SmartPointer< T > &value) const
Get a parameter that holds a smart pointer.
virtual void ThreadedUpdateFailed()
void StartBlockingAlgorithm()
Start the algorithm and block until it completes.
void StopAlgorithm()
Wait for the running algorithm thread to finish.
DataStorage * GetDataStorage()
Get the DataStorage associated with this algorithm.
virtual bool ThreadedUpdateFunction()
void SetPointerParameter(const char *parameter, const itk::SmartPointer< T > &value)
Set a parameter that holds a smart pointer.
void UnDefineTriggerParameter(const char *)
void SetParameter(const char *parameter, const T &value)
Set a parameter of any normal (value) type.
void SetDataStorage(DataStorage &storage)
Set the DataStorage for this algorithm.
void ThreadedUpdateSuccessful(const itk::EventObject &event)
GUI-thread callback when the threaded update succeeds.
mitkClassMacroItkParent(NonBlockingAlgorithm, itk::Object)
void SetItkImageAsMITKImagePointerParameter(const char *parameter, itk::Image< TPixel, VImageDimension > *itkImage)
Set an ITK image as a MITK Image parameter (raw pointer version).
Property containing a smart pointer to an itk::Object.
itk::Object::Pointer GetSmartPointer() const
Get the stored smart pointer.
A weak pointer that observes an itk::Object without preventing its deletion.
Image::Pointer ImportItkImage(const itk::SmartPointer< ItkOutputImageType > &itkimage, const BaseGeometry *geometry=nullptr, bool update=true)
Import an itk::Image (with a specific type) as an mitk::Image.
Declares commonly used GenericProperty specializations for MITK.
Find image slices visible on a given plane.