Medical Imaging Interaction Toolkit  2022.04.99-2e1e005b
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 
158 private:
161  mutable bool m_InGenerate = false;
163  mutable bool m_RestartGeneration = false;
165  mutable bool m_WIP = false;
167  mutable bool m_AddingToStorage = false;
168 
170  void NodeAddedOrModified(const mitk::DataNode* node);
171 
172  unsigned long m_DataStorageDeletedTag;
173 };
174 
175 #endif
mitk::WeakPointer< mitk::DataStorage > m_Storage
Data management class that handles &#39;was created by&#39; relations.
Base of all data objects.
Definition: mitkBaseData.h:42
#define MITKIMAGESTATISTICSUI_EXPORT
std::vector< std::pair< mitk::DataNode::ConstPointer, mitk::DataNode::ConstPointer > > InputPairVectorType
QmitkDataGeneratorBase BaseClass that implements the organisation of (statistic) data generation for ...
std::map< std::string, mitk::BaseData::Pointer > ResultMapType
QmitkDataGenerationJobBase::ResultMapType JobResultMapType
Class for nodes of the DataTree.
Definition: mitkDataNode.h:63
QmitkDataGenerationJobBase Base class for generation jobs used by QmitkDataGenerationBase and derived...