Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkRenderWindowDataStorageListModel Class Reference

List model that displays the layer stack for a specific render window with drag-and-drop support. More...

#include <QmitkRenderWindowDataStorageListModel.h>

Inheritance diagram for QmitkRenderWindowDataStorageListModel:
Collaboration diagram for QmitkRenderWindowDataStorageListModel:

Public Member Functions

 QmitkRenderWindowDataStorageListModel (QObject *parent=nullptr)
 Construct the list model. More...
 
void DataStorageChanged () override
 Called when the data storage has been changed. More...
 
void NodePredicateChanged () override
 Called when the node predicate has been changed. Refreshes the model data. More...
 
void NodeAdded (const mitk::DataNode *node) override
 Called when a data node has been added to the data storage. More...
 
void NodeChanged (const mitk::DataNode *node) override
 Called when a data node has been changed. More...
 
void NodeRemoved (const mitk::DataNode *node) override
 Called when a data node has been removed from the data storage. Refreshes the model. More...
 
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const override
 Create a model index for the given row and column. More...
 
QModelIndex parent (const QModelIndex &child) const override
 Return the parent index (always invalid, since this is a flat list model). More...
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 Return the number of rows (layers) in the model. More...
 
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 Return the number of columns (always 1). More...
 
QVariant data (const QModelIndex &index, int role) const override
 Return data for the given index and role. More...
 
bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
 Set data for the given index and role (visibility toggling). More...
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 Return item flags for the given index. More...
 
Qt::DropActions supportedDropActions () const override
 Return supported drop actions (Copy and Move). More...
 
Qt::DropActions supportedDragActions () const override
 Return supported drag actions (Copy and Move). More...
 
QStringList mimeTypes () const override
 Return the list of supported MIME types for drag-and-drop. More...
 
QMimeData * mimeData (const QModelIndexList &indexes) const override
 Create MIME data for the given model indices. More...
 
bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
 Handle dropped MIME data to reorder layers. More...
 
void SetControlledRenderer (mitk::RenderWindowLayerUtilities::RendererVector controlledRenderer)
 Set the list of controlled renderers and initialize layer data for all nodes. More...
 
void SetCurrentRenderer (mitk::BaseRenderer *baseRenderer)
 Set the current base renderer and refresh the model. More...
 
mitk::BaseRenderer::Pointer GetCurrentRenderer () const
 Get the currently active base renderer. More...
 
void AddDataNodeToAllRenderer (mitk::DataNode *dataNode)
 Insert the given data node into all controlled render windows at the top layer. More...
 
- Public Member Functions inherited from QmitkAbstractDataStorageModel
 ~QmitkAbstractDataStorageModel () override
 
void SetDataStorage (mitk::DataStorage *dataStorage)
 Sets the data storage and registers node event listeners. More...
 
mitk::DataStorage::Pointer GetDataStorage () const
 Returns a locked pointer to the current data storage. More...
 
void SetNodePredicate (const mitk::NodePredicateBase *nodePredicate)
 Sets the node predicate and triggers a model update. More...
 
const mitk::NodePredicateBase * GetNodePredicate () const
 Returns the currently set node predicate. More...
 

Additional Inherited Members

- Protected Member Functions inherited from QmitkAbstractDataStorageModel
 QmitkAbstractDataStorageModel (QObject *parent=nullptr)
 
 QmitkAbstractDataStorageModel (mitk::DataStorage *dataStorage, QObject *parent=nullptr)
 
- Protected Attributes inherited from QmitkAbstractDataStorageModel
mitk::WeakPointer< mitk::DataStorage > m_DataStorage
 
mitk::NodePredicateBase::ConstPointer m_NodePredicate
 

Detailed Description

List model that displays the layer stack for a specific render window with drag-and-drop support.

QmitkRenderWindowDataStorageListModel is a single-column list model derived from QmitkAbstractDataStorageModel. It shows data nodes assigned to a render window sorted by their layer property, with a visibility checkbox, node icon, and node name for each entry.

The model supports drag-and-drop of data node pointers for reordering layers. When a node is dropped onto another, the RenderWindowLayerController is used to move it to the target layer position. Newly added nodes are automatically inserted into all controlled render windows at the top layer position.

See also
QmitkAbstractDataStorageModel, QmitkDataStorageLayerStackModel, QmitkRenderWindowDataStorageInspector, mitk::RenderWindowLayerController, mitk::RenderWindowLayerUtilities

Definition at line 45 of file QmitkRenderWindowDataStorageListModel.h.

Constructor & Destructor Documentation

◆ QmitkRenderWindowDataStorageListModel()

QmitkRenderWindowDataStorageListModel::QmitkRenderWindowDataStorageListModel ( QObject *  parent = nullptr)

Construct the list model.

Initializes the internal RenderWindowLayerController.

Parameters
[in]parentOptional parent QObject.

Member Function Documentation

◆ AddDataNodeToAllRenderer()

void QmitkRenderWindowDataStorageListModel::AddDataNodeToAllRenderer ( mitk::DataNode *  dataNode)

Insert the given data node into all controlled render windows at the top layer.

Uses the RenderWindowLayerController to insert the node at the highest layer position in each managed render window.

Parameters
[in]dataNodeThe data node to insert.

◆ columnCount()

int QmitkRenderWindowDataStorageListModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
override

Return the number of columns (always 1).

Parameters
[in]parentThe parent index. Must be invalid for a valid count; returns 0 if valid.
Returns
1.

◆ data()

QVariant QmitkRenderWindowDataStorageListModel::data ( const QModelIndex &  index,
int  role 
) const
override

Return data for the given index and role.

Supported roles:

  • Qt::CheckStateRole: Node visibility in the current renderer.
  • Qt::DisplayRole: Data node name.
  • Qt::ToolTipRole: "Name of the data node."
  • Qt::DecorationRole: Node type icon from QmitkNodeDescriptorManager.
  • Qt::UserRole / QmitkDataNodeRawPointerRole: Raw mitk::DataNode pointer.
  • QmitkDataNodeRole: mitk::DataNode::Pointer wrapped in a QVariant.
Parameters
[in]indexThe model index.
[in]roleThe data role.
Returns
The requested data, or an invalid QVariant.

◆ DataStorageChanged()

void QmitkRenderWindowDataStorageListModel::DataStorageChanged ( )
overridevirtual

Called when the data storage has been changed.

Updates the layer controller's data storage reference and refreshes the model.

Implements QmitkAbstractDataStorageModel.

◆ dropMimeData()

bool QmitkRenderWindowDataStorageListModel::dropMimeData ( const QMimeData *  data,
Qt::DropAction  action,
int  row,
int  column,
const QModelIndex &  parent 
)
override

Handle dropped MIME data to reorder layers.

When data nodes are dropped onto a target item, uses the RenderWindowLayerController to move the dropped nodes to the layer position of the target.

Parameters
[in]dataThe MIME data containing serialized data node pointers.
[in]actionThe drop action.
[in]rowThe target row (unused).
[in]columnThe target column.
[in]parentThe model index of the drop target.
Returns
true if the drop was successfully handled, false otherwise.

◆ flags()

Qt::ItemFlags QmitkRenderWindowDataStorageListModel::flags ( const QModelIndex &  index) const
override

Return item flags for the given index.

Valid items are enabled, selectable, checkable, draggable, and droppable. An invalid index is only droppable (to allow drops on empty space).

Parameters
[in]indexThe model index to query.
Returns
The item flags.

◆ GetCurrentRenderer()

mitk::BaseRenderer::Pointer QmitkRenderWindowDataStorageListModel::GetCurrentRenderer ( ) const

Get the currently active base renderer.

Returns
Smart pointer to the current mitk::BaseRenderer, or nullptr if none is set or it has expired.

◆ index()

QModelIndex QmitkRenderWindowDataStorageListModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const
override

Create a model index for the given row and column.

Parameters
[in]rowThe row number.
[in]columnThe column number (always 0 for this single-column model).
[in]parentThe parent index (must be invalid for this flat model).
Returns
A valid QModelIndex if the position is within range, otherwise an invalid index.

◆ mimeData()

QMimeData* QmitkRenderWindowDataStorageListModel::mimeData ( const QModelIndexList &  indexes) const
override

Create MIME data for the given model indices.

Serializes the raw data node pointers from the selected indices into a QByteArray using the QmitkMimeTypes::DataNodePtrs format.

Parameters
[in]indexesThe list of model indices to serialize.
Returns
Pointer to the created QMimeData. Ownership is transferred to the caller.

◆ mimeTypes()

QStringList QmitkRenderWindowDataStorageListModel::mimeTypes ( ) const
override

Return the list of supported MIME types for drag-and-drop.

Includes QmitkMimeTypes::DataNodePtrs in addition to the default MIME types.

Returns
List of supported MIME type strings.

◆ NodeAdded()

void QmitkRenderWindowDataStorageListModel::NodeAdded ( const mitk::DataNode *  node)
overridevirtual

Called when a data node has been added to the data storage.

Inserts the new node into all controlled render windows at the top layer position, then refreshes the model.

Parameters
[in]nodeThe data node that was added.

Implements QmitkAbstractDataStorageModel.

◆ NodeChanged()

void QmitkRenderWindowDataStorageListModel::NodeChanged ( const mitk::DataNode *  node)
overridevirtual

Called when a data node has been changed.

Parameters
[in]nodeThe data node that was changed.
Note
Currently a no-op because the NodeChanged event is sent too frequently.

Implements QmitkAbstractDataStorageModel.

◆ NodePredicateChanged()

void QmitkRenderWindowDataStorageListModel::NodePredicateChanged ( )
overridevirtual

Called when the node predicate has been changed. Refreshes the model data.

Implements QmitkAbstractDataStorageModel.

◆ NodeRemoved()

void QmitkRenderWindowDataStorageListModel::NodeRemoved ( const mitk::DataNode *  node)
overridevirtual

Called when a data node has been removed from the data storage. Refreshes the model.

Parameters
[in]nodeThe data node that was removed.

Implements QmitkAbstractDataStorageModel.

◆ parent()

QModelIndex QmitkRenderWindowDataStorageListModel::parent ( const QModelIndex &  child) const
override

Return the parent index (always invalid, since this is a flat list model).

Parameters
[in]childThe child index (unused).
Returns
An invalid QModelIndex.

◆ rowCount()

int QmitkRenderWindowDataStorageListModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
override

Return the number of rows (layers) in the model.

Parameters
[in]parentThe parent index. Must be invalid for a valid count; returns 0 if valid.
Returns
The number of data nodes in the current layer stack.

◆ SetControlledRenderer()

void QmitkRenderWindowDataStorageListModel::SetControlledRenderer ( mitk::RenderWindowLayerUtilities::RendererVector  controlledRenderer)

Set the list of controlled renderers and initialize layer data for all nodes.

Iterates over all data nodes in the data storage and inserts each one into all controlled render windows via AddDataNodeToAllRenderer().

Parameters
[in]controlledRendererVector of base renderers to manage.

◆ SetCurrentRenderer()

void QmitkRenderWindowDataStorageListModel::SetCurrentRenderer ( mitk::BaseRenderer *  baseRenderer)

Set the current base renderer and refresh the model.

Switches the model to display the layer stack of the given renderer.

Parameters
[in]baseRendererThe base renderer whose layer stack should be displayed.

◆ setData()

bool QmitkRenderWindowDataStorageListModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
)
override

Set data for the given index and role (visibility toggling).

Only handles Qt::CheckStateRole to toggle the visibility of the data node in the current renderer. Triggers a render window update on success.

Parameters
[in]indexThe model index of the item to modify.
[in]valueThe new value (Qt::CheckState as int).
[in]roleThe data role (only Qt::CheckStateRole is handled).
Returns
true if the visibility was successfully changed, false otherwise.

◆ supportedDragActions()

Qt::DropActions QmitkRenderWindowDataStorageListModel::supportedDragActions ( ) const
override

Return supported drag actions (Copy and Move).

Returns
Qt::CopyAction | Qt::MoveAction.

◆ supportedDropActions()

Qt::DropActions QmitkRenderWindowDataStorageListModel::supportedDropActions ( ) const
override

Return supported drop actions (Copy and Move).

Returns
Qt::CopyAction | Qt::MoveAction.

The documentation for this class was generated from the following file: