|
Medical Imaging Interaction Toolkit
2026.06.00
Medical Imaging Interaction Toolkit
|
Base class that orchestrates asynchronous data generation for image/ROI pairs. More...
#include <QmitkDataGeneratorBase.h>


Public Types | |
| using | JobResultMapType = QmitkDataGenerationJobBase::ResultMapType |
| Alias for the result map type produced by generation jobs. More... | |
Public Slots | |
| void | SetDataStorage (mitk::DataStorage *storage) |
| Sets the data storage for monitoring, storing WIP placeholders, and final results. More... | |
| void | SetAutoUpdate (bool autoUpdate) |
| Enables or disables automatic update on data changes. More... | |
Signals | |
| void | DataGenerationStarted (const mitk::DataNode *imageNode, const mitk::DataNode *roiNode, const QmitkDataGenerationJobBase *job) const |
| Emitted when a data generation job is started for outdated or missing data. More... | |
| void | NewDataAvailable (mitk::DataStorage::SetOfObjects::ConstPointer data) const |
| Emitted when new final result data has been produced and added to the data storage. More... | |
| void | GenerationFinished () const |
| Emitted when all generation jobs have finished and all results are up to date. More... | |
| void | JobError (QString error, const QmitkDataGenerationJobBase *failedJob) const |
| Emitted when a generation job encounters an error. More... | |
Public Member Functions | |
| QmitkDataGeneratorBase (const QmitkDataGeneratorBase &other)=delete | |
| QmitkDataGeneratorBase & | operator= (const QmitkDataGeneratorBase &other)=delete |
| virtual | ~QmitkDataGeneratorBase () |
| mitk::DataStorage::Pointer | GetDataStorage () const |
| Returns the data storage used by this generator. More... | |
| bool | GetAutoUpdate () const |
| Returns whether automatic updates are enabled. More... | |
| bool | IsGenerating () const |
| Returns whether data generation jobs are currently running or pending. More... | |
| bool | Generate () const |
| Checks data validity and triggers generation of missing or outdated data. More... | |
| virtual bool | IsValidResultAvailable (const mitk::DataNode *imageNode, const mitk::DataNode *roiNode) const =0 |
| Checks whether a valid final result exists for the given image and ROI. More... | |
Protected Types | |
| using | InputPairVectorType = std::vector< std::pair< mitk::DataNode::ConstPointer, mitk::DataNode::ConstPointer > > |
| Vector of image/ROI node pairs used as input for generation. More... | |
Protected Slots | |
| void | OnJobError (QString error, const QmitkDataGenerationJobBase *failedJob) const |
| Handles error signals from generation jobs and re-emits JobError. More... | |
| void | OnFinalResultsAvailable (JobResultMapType results, const QmitkDataGenerationJobBase *job) const |
| Handles completed job results, adds them to the data storage, and emits NewDataAvailable. More... | |
Protected Member Functions | |
| QmitkDataGeneratorBase (mitk::DataStorage::Pointer storage, QObject *parent=nullptr) | |
| Constructs a generator with the given data storage. More... | |
| QmitkDataGeneratorBase (QObject *parent=nullptr) | |
| Constructs a generator without an initial data storage. More... | |
| virtual bool | ChangedNodeIsRelevant (const mitk::DataNode *changedNode) const =0 |
| Determines whether a changed data node is relevant and should trigger a regeneration. More... | |
| virtual InputPairVectorType | GetAllImageROICombinations () const =0 |
| Returns all image/ROI pairs for which data generation is needed. More... | |
| virtual void | IndicateFutureResults (const mitk::DataNode *imageNode, const mitk::DataNode *roiNode) const =0 |
| Adds placeholder nodes and WIP dummy data to the data storage for missing or outdated results. More... | |
| virtual std::pair< QmitkDataGenerationJobBase *, mitk::DataNode::Pointer > | GetNextMissingGenerationJob (const mitk::DataNode *imageNode, const mitk::DataNode *roiNode) const =0 |
| Returns the next generation job and its associated placeholder node. More... | |
| virtual void | RemoveObsoleteDataNodes (const mitk::DataNode *imageNode, const mitk::DataNode *roiNode) const =0 |
| Removes obsolete result nodes for the given image/ROI pair from the data storage. More... | |
| virtual mitk::DataNode::Pointer | PrepareResultForStorage (const std::string &label, mitk::BaseData *result, const QmitkDataGenerationJobBase *job) const =0 |
| Wraps a generation result in a data node suitable for storage. More... | |
| InputPairVectorType | FilterImageROICombinations (InputPairVectorType &&imageROICombinations) const |
| Filters image/ROI pairs to only include those whose nodes exist in the data storage. More... | |
| std::string | GetPairDescription (const InputPairVectorType::value_type &imageAndSeg) const |
| Returns a human-readable description of an image/ROI pair for debug logging. More... | |
| bool | DoGenerate () const |
| Core generation loop that checks validity and launches jobs for all image/ROI pairs. More... | |
| void | EnsureRecheckingAndGeneration () const |
| Ensures generation is (re)started, either immediately or by flagging a restart if already running. More... | |
Static Protected Member Functions | |
| static mitk::DataNode::Pointer | CreateWIPDataNode (mitk::BaseData *dataDummy, const std::string &nodeName) |
| Creates a WIP placeholder data node for future results. More... | |
Protected Attributes | |
| mitk::WeakPointer< mitk::DataStorage > | m_Storage |
| bool | m_AutoUpdate |
| std::mutex | m_DataMutex |
| itk::TimeStamp | m_GenerationTime |
Base class that orchestrates asynchronous data generation for image/ROI pairs.
This class manages the lifecycle of background data generation jobs for pairs of images and ROIs. It ensures that for each image/ROI combination (defined by derived classes), a result instance (e.g., mitk::ImageStatisticsContainer) is calculated when needed (missing or outdated) and stored in the associated data storage. Derived classes define how to produce image/ROI pairs, how to detect existing results, what constitutes the next generation step, and how to clean up obsolete data. The base class observes the data storage for changes and orchestrates the checking and generation workflow.
The data storage serves two roles: (1) it stores and retrieves final results, and (2) it tracks the generation state via work-in-progress (WIP) placeholder nodes for pending or in-progress jobs.
Definition at line 45 of file QmitkDataGeneratorBase.h.
|
protected |
Vector of image/ROI node pairs used as input for generation.
Definition at line 171 of file QmitkDataGeneratorBase.h.
Alias for the result map type produced by generation jobs.
Definition at line 55 of file QmitkDataGeneratorBase.h.
|
delete |
|
virtual |
|
protected |
Constructs a generator with the given data storage.
| [in] | storage | The data storage where all produced data should be stored. |
| [in] | parent | Optional parent QObject for Qt ownership. |
|
protected |
Constructs a generator without an initial data storage.
| [in] | parent | Optional parent QObject for Qt ownership. |
|
protectedpure virtual |
Determines whether a changed data node is relevant and should trigger a regeneration.
| [in] | changedNode | The node that was changed in the data storage. |
Implemented in QmitkImageAndRoiDataGeneratorBase, and QmitkImageStatisticsDataGenerator.
|
staticprotected |
Creates a WIP placeholder data node for future results.
The created node is marked as a hidden helper object with a "pending" generation status. Can be used by IndicateFutureResults() implementations.
| [in] | dataDummy | The dummy data object to attach to the node. Must not be nullptr. |
| [in] | nodeName | The name to assign to the node. |
| mitk::Exception | if dataDummy is nullptr. |
|
signal |
Emitted when a data generation job is started for outdated or missing data.
| [in] | imageNode | The image data node being processed. |
| [in] | roiNode | The ROI data node being processed (may be nullptr). |
| [in] | job | Pointer to the started generation job. |
|
protected |
Core generation loop that checks validity and launches jobs for all image/ROI pairs.
|
protected |
Ensures generation is (re)started, either immediately or by flagging a restart if already running.
|
protected |
Filters image/ROI pairs to only include those whose nodes exist in the data storage.
| [in] | imageROICombinations | The pairs to filter (moved into the method). |
| bool QmitkDataGeneratorBase::Generate | ( | ) | const |
Checks data validity and triggers generation of missing or outdated data.
The generation is performed asynchronously using a thread pool. To detect when all jobs have completed, connect to the GenerationFinished signal.
|
signal |
Emitted when all generation jobs have finished and all results are up to date.
|
protectedpure virtual |
Returns all image/ROI pairs for which data generation is needed.
The ROI element of a pair may be nullptr if no ROI is required.
Implemented in QmitkImageAndRoiDataGeneratorBase.
| bool QmitkDataGeneratorBase::GetAutoUpdate | ( | ) | const |
Returns whether automatic updates are enabled.
When enabled, the generator automatically triggers regeneration when:
| mitk::DataStorage::Pointer QmitkDataGeneratorBase::GetDataStorage | ( | ) | const |
Returns the data storage used by this generator.
|
protectedpure virtual |
Returns the next generation job and its associated placeholder node.
| [in] | imageNode | The image data node. |
| [in] | roiNode | The ROI data node (may be nullptr). |
Implemented in QmitkImageStatisticsDataGenerator.
|
protected |
Returns a human-readable description of an image/ROI pair for debug logging.
| [in] | imageAndSeg | The image/ROI pair to describe. |
|
protectedpure virtual |
Adds placeholder nodes and WIP dummy data to the data storage for missing or outdated results.
The placeholder nodes will be replaced by real results once generation completes. Derived classes define the detection strategy and dummy data format.
| [in] | imageNode | The image data node. |
| [in] | roiNode | The ROI data node (may be nullptr). |
Implemented in QmitkImageStatisticsDataGenerator.
| bool QmitkDataGeneratorBase::IsGenerating | ( | ) | const |
Returns whether data generation jobs are currently running or pending.
Set to true when DataGenerationStarted is emitted and becomes false when GenerationFinished is emitted.
|
pure virtual |
Checks whether a valid final result exists for the given image and ROI.
| [in] | imageNode | The image data node to check. |
| [in] | roiNode | The ROI data node to check (may be nullptr if no ROI is used). |
Implemented in QmitkImageStatisticsDataGenerator.
|
signal |
Emitted when a generation job encounters an error.
| [in] | error | The error description. |
| [in] | failedJob | Pointer to the job that failed. |
|
signal |
Emitted when new final result data has been produced and added to the data storage.
| [in] | data | The set of newly added result data nodes. |
|
protectedslot |
Handles completed job results, adds them to the data storage, and emits NewDataAvailable.
| [in] | results | The result map from the completed job. |
| [in] | job | Pointer to the job that produced the results. |
|
protectedslot |
Handles error signals from generation jobs and re-emits JobError.
| [in] | error | The error message. |
| [in] | failedJob | Pointer to the job that failed. |
|
delete |
|
protectedpure virtual |
Wraps a generation result in a data node suitable for storage.
| [in] | label | The result label from the job's result map. |
| [in] | result | The generated data to store. |
| [in] | job | The job that produced the result. |
Implemented in QmitkImageStatisticsDataGenerator.
|
protectedpure virtual |
Removes obsolete result nodes for the given image/ROI pair from the data storage.
Obsolete nodes are interim result nodes that have been superseded by newer results.
| [in] | imageNode | The image data node. |
| [in] | roiNode | The ROI data node (may be nullptr). |
Implemented in QmitkImageStatisticsDataGenerator.
|
slot |
Enables or disables automatic update on data changes.
| [in] | autoUpdate | True to enable; false to disable. |
|
slot |
Sets the data storage for monitoring, storing WIP placeholders, and final results.
| [in] | storage | Pointer to the data storage to use. May be nullptr to disconnect. |
|
protected |
Definition at line 268 of file QmitkDataGeneratorBase.h.
|
mutableprotected |
Definition at line 270 of file QmitkDataGeneratorBase.h.
|
mutableprotected |
Time stamp for the last successful run through with the current image roi pairs.
Definition at line 273 of file QmitkDataGeneratorBase.h.
|
protected |
Definition at line 266 of file QmitkDataGeneratorBase.h.