Medical Imaging Interaction Toolkit  2024.12.99-0da743f6
Medical Imaging Interaction Toolkit
QmitkDataGeneratorBase.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef QmitkDataGeneratorBase_h
14 #define QmitkDataGeneratorBase_h
15 
16 #include <mutex>
17 
18 //QT
19 #include <QObject>
20 
21 //MITK
22 #include <mitkDataStorage.h>
23 
25 
27 
42 {
43  Q_OBJECT
44 public:
45  QmitkDataGeneratorBase(const QmitkDataGeneratorBase& other) = delete;
46  QmitkDataGeneratorBase& operator=(const QmitkDataGeneratorBase& other) = delete;
47 
48  virtual ~QmitkDataGeneratorBase();
49 
51 
52  mitk::DataStorage::Pointer GetDataStorage() const;
53 
58  bool GetAutoUpdate() const;
59 
63  bool IsGenerating() const;
64 
69  bool Generate() const;
70 
72  virtual bool IsValidResultAvailable(const mitk::DataNode* imageNode, const mitk::DataNode* roiNode) const = 0;
73 
74 public slots:
76  void SetDataStorage(mitk::DataStorage* storage);
77 
78  void SetAutoUpdate(bool autoUpdate);
79 
80 protected slots:
82  void OnJobError(QString error, const QmitkDataGenerationJobBase* failedJob) const;
84  void OnFinalResultsAvailable(JobResultMapType results, const QmitkDataGenerationJobBase *job) const;
85 
86 signals:
87 
90  void DataGenerationStarted(const mitk::DataNode* imageNode, const mitk::DataNode* roiNode, const QmitkDataGenerationJobBase* job) const;
91 
94  void NewDataAvailable(mitk::DataStorage::SetOfObjects::ConstPointer data) const;
95 
98  void GenerationFinished() const;
99 
102  void JobError(QString error, const QmitkDataGenerationJobBase* failedJob) const;
103 
104 protected:
109  QmitkDataGeneratorBase(mitk::DataStorage::Pointer storage, QObject* parent = nullptr);
110  QmitkDataGeneratorBase(QObject* parent = nullptr);
111 
112  using InputPairVectorType = std::vector<std::pair<mitk::DataNode::ConstPointer, mitk::DataNode::ConstPointer>>;
113 
115  virtual bool ChangedNodeIsRelevant(const mitk::DataNode* changedNode) const = 0;
118  virtual InputPairVectorType GetAllImageROICombinations() const = 0;
122  virtual void IndicateFutureResults(const mitk::DataNode* imageNode, const mitk::DataNode* roiNode) const = 0;
130  virtual std::pair<QmitkDataGenerationJobBase*,mitk::DataNode::Pointer> GetNextMissingGenerationJob(const mitk::DataNode* imageNode, const mitk::DataNode* roiNode) const =0;
133  virtual void RemoveObsoleteDataNodes(const mitk::DataNode* imageNode, const mitk::DataNode* roiNode) const = 0;
135  virtual mitk::DataNode::Pointer PrepareResultForStorage(const std::string& label, mitk::BaseData* result, const QmitkDataGenerationJobBase* job) const = 0;
136 
138  static mitk::DataNode::Pointer CreateWIPDataNode(mitk::BaseData* dataDummy, const std::string& nodeName);
139 
141  InputPairVectorType FilterImageROICombinations(InputPairVectorType&& imageROICombinations) const;
142 
144  std::string GetPairDescription(const InputPairVectorType::value_type& imageAndSeg) const;
145 
147  bool DoGenerate() const;
148 
150  void EnsureRecheckingAndGeneration() const;
151 
153 
154  bool m_AutoUpdate = false;
155 
156  mutable std::mutex m_DataMutex;
157 
159  mutable itk::TimeStamp m_GenerationTime;
160 
161 private:
164  mutable bool m_InGenerate = false;
166  mutable bool m_RestartGeneration = false;
168  mutable bool m_WIP = false;
170  mutable bool m_AddingToStorage = false;
171 
173  void NodeAddedOrModified(const mitk::DataNode* node);
174 
175  unsigned long m_DataStorageDeletedTag;
176 };
177 
178 #endif
QmitkDataGeneratorBase::InputPairVectorType
std::vector< std::pair< mitk::DataNode::ConstPointer, mitk::DataNode::ConstPointer > > InputPairVectorType
Definition: QmitkDataGeneratorBase.h:112
QmitkDataGeneratorBase::m_Storage
mitk::WeakPointer< mitk::DataStorage > m_Storage
Definition: QmitkDataGeneratorBase.h:152
mitkDataStorage.h
MitkImageStatisticsUIExports.h
QmitkDataGenerationJobBase.h
itk::SmartPointer< Self >
QmitkDataGeneratorBase::m_GenerationTime
itk::TimeStamp m_GenerationTime
Definition: QmitkDataGeneratorBase.h:159
QmitkDataGeneratorBase::JobResultMapType
QmitkDataGenerationJobBase::ResultMapType JobResultMapType
Definition: QmitkDataGeneratorBase.h:50
MITKIMAGESTATISTICSUI_EXPORT
#define MITKIMAGESTATISTICSUI_EXPORT
Definition: MitkImageStatisticsUIExports.h:15
mitk::BaseData
Base of all data objects.
Definition: mitkBaseData.h:42
mitk::DataStorage
Data management class that handles 'was created by' relations.
Definition: mitkDataStorage.h:43
QmitkDataGeneratorBase::m_DataMutex
std::mutex m_DataMutex
Definition: QmitkDataGeneratorBase.h:156
mitk::WeakPointer< mitk::DataStorage >
mitk::DataNode
Class for nodes of the DataTree.
Definition: mitkDataNode.h:63
QmitkDataGenerationJobBase
QmitkDataGenerationJobBase Base class for generation jobs used by QmitkDataGenerationBase and derived...
Definition: QmitkDataGenerationJobBase.h:32
QmitkDataGeneratorBase
QmitkDataGeneratorBase BaseClass that implements the organization of (statistic) data generation for ...
Definition: QmitkDataGeneratorBase.h:41
QmitkDataGenerationJobBase::ResultMapType
std::map< std::string, mitk::BaseData::Pointer > ResultMapType
Definition: QmitkDataGenerationJobBase.h:39