Medical Imaging Interaction Toolkit  2024.06.99-60d9b802
Medical Imaging Interaction Toolkit
QmitkAbstractNodeSelectionWidget Class Referenceabstract

Abstract base class for the selection of data from a data storage. More...

#include <QmitkAbstractNodeSelectionWidget.h>

Inheritance diagram for QmitkAbstractNodeSelectionWidget:
Collaboration diagram for QmitkAbstractNodeSelectionWidget:

Public Types

using NodeList = QList< mitk::DataNode::Pointer >
 
using ConstNodeStdVector = std::vector< mitk::DataNode::ConstPointer >
 

Public Slots

void SetSelectOnlyVisibleNodes (bool selectOnlyVisibleNodes)
 Change the selection modus of the item view's selection model. More...
 
void SetCurrentSelection (NodeList selectedNodes)
 Transform a list of data nodes (a selection) into a model selection and set this as a new selection of the selection model of the private member item view. More...
 
void SetInvalidInfo (QString info)
 
void SetEmptyInfo (QString info)
 
void SetPopUpTitel (QString info)
 
void SetPopUpHint (QString info)
 
void SetSelectionIsOptional (bool isOptional)
 

Signals

void CurrentSelectionChanged (NodeList nodes)
 A signal that will be emitted if the selected node has changed. More...
 

Public Member Functions

 QmitkAbstractNodeSelectionWidget (QWidget *parent=nullptr)
 
virtual ~QmitkAbstractNodeSelectionWidget () override
 
void SetDataStorage (mitk::DataStorage *dataStorage)
 Sets the data storage that will be used / monitored by widget. More...
 
void SetNodePredicate (const mitk::NodePredicateBase *nodePredicate)
 
const mitk::NodePredicateBaseGetNodePredicate () const
 
QString GetInvalidInfo () const
 
QString GetEmptyInfo () const
 
QString GetPopUpTitel () const
 
QString GetPopUpHint () const
 
bool GetSelectionIsOptional () const
 
bool GetSelectOnlyVisibleNodes () const
 
NodeList GetSelectedNodes () const
 
ConstNodeStdVector GetSelectedNodesStdVector () const
 
void OnSelectionReceived (const std::string &context, const std::vector< mitk::DataNode::Pointer > &selection) override
 Callback method for received selections. More...
 

Protected Slots

void RemoveNodeFromSelection (const mitk::DataNode *node)
 

Protected Member Functions

virtual void UpdateInfo ()=0
 
virtual void OnNodePredicateChanged ()
 
virtual void OnDataStorageChanged ()
 
virtual void OnInternalSelectionChanged ()
 
virtual void OnNodeAddedToStorage (const mitk::DataNode *node)
 
virtual void OnNodeRemovedFromStorage (const mitk::DataNode *node)
 
virtual void OnNodeModified (const itk::Object *caller, const itk::EventObject &event)
 
void HandleChangeOfInternalSelection (NodeList newInternalSelection)
 
NodeList CompileEmitSelection () const
 
virtual void ReviseSelectionChanged (const NodeList &oldInternalSelection, NodeList &newInternalSelection)
 
virtual bool AllowEmissionOfSelection (const NodeList &emissionCandidates) const
 
void EmitSelection (const NodeList &emissionCandidates)
 
void SetCurrentInternalSelection (NodeList selectedNodes)
 
const NodeListGetCurrentInternalSelection () const
 
const NodeListGetCurrentExternalSelection () const
 

Protected Attributes

mitk::WeakPointer< mitk::DataStoragem_DataStorage
 
mitk::NodePredicateBase::ConstPointer m_NodePredicate
 
QString m_InvalidInfo
 
QString m_EmptyInfo
 
QString m_PopUpTitel
 
QString m_PopUpHint
 
bool m_IsOptional
 
bool m_SelectOnlyVisibleNodes
 

Detailed Description

Abstract base class for the selection of data from a data storage.

Definition at line 31 of file QmitkAbstractNodeSelectionWidget.h.

Member Typedef Documentation

◆ ConstNodeStdVector

Other node container type often used in the code base.

Definition at line 67 of file QmitkAbstractNodeSelectionWidget.h.

◆ NodeList

Constructor & Destructor Documentation

◆ QmitkAbstractNodeSelectionWidget()

QmitkAbstractNodeSelectionWidget::QmitkAbstractNodeSelectionWidget ( QWidget *  parent = nullptr)
explicit

◆ ~QmitkAbstractNodeSelectionWidget()

virtual QmitkAbstractNodeSelectionWidget::~QmitkAbstractNodeSelectionWidget ( )
overridevirtual

Member Function Documentation

◆ AllowEmissionOfSelection()

virtual bool QmitkAbstractNodeSelectionWidget::AllowEmissionOfSelection ( const NodeList emissionCandidates) const
protectedvirtual

This function will be called before the CurrentSelectionChanged signal is emitted. The return value indicates if the signal should be emitted (true = emission; false = no emission). The default implementation always returns true.

Parameters
emissionCandidatesThe nodes that will be emitted if the function returns true.

Reimplemented in QmitkSynchronizedNodeSelectionWidget, and QmitkMultiNodeSelectionWidget.

◆ CompileEmitSelection()

NodeList QmitkAbstractNodeSelectionWidget::CompileEmitSelection ( ) const
protected

Compiles the list of node that would be emitted. It always contains the internal selection. Depending on SelectOnlyVisibleNodes it also adds all external select nodes that weren't visible (failed the predicate).

◆ CurrentSelectionChanged

void QmitkAbstractNodeSelectionWidget::CurrentSelectionChanged ( NodeList  nodes)
signal

A signal that will be emitted if the selected node has changed.

nodes A list of data nodes that are newly selected.

◆ EmitSelection()

void QmitkAbstractNodeSelectionWidget::EmitSelection ( const NodeList emissionCandidates)
protected

Checks if the new emission differs from the last emission. If this is the case and AllowEmissionOfSelection() returns true the new selection will be emitted.

◆ GetCurrentExternalSelection()

const NodeList& QmitkAbstractNodeSelectionWidget::GetCurrentExternalSelection ( ) const
protected

◆ GetCurrentInternalSelection()

const NodeList& QmitkAbstractNodeSelectionWidget::GetCurrentInternalSelection ( ) const
protected

◆ GetEmptyInfo()

QString QmitkAbstractNodeSelectionWidget::GetEmptyInfo ( ) const

◆ GetInvalidInfo()

QString QmitkAbstractNodeSelectionWidget::GetInvalidInfo ( ) const

◆ GetNodePredicate()

const mitk::NodePredicateBase* QmitkAbstractNodeSelectionWidget::GetNodePredicate ( ) const

◆ GetPopUpHint()

QString QmitkAbstractNodeSelectionWidget::GetPopUpHint ( ) const

◆ GetPopUpTitel()

QString QmitkAbstractNodeSelectionWidget::GetPopUpTitel ( ) const

◆ GetSelectedNodes()

NodeList QmitkAbstractNodeSelectionWidget::GetSelectedNodes ( ) const

Returns the selected nodes, as emitted with CurrentSelectionChanged

◆ GetSelectedNodesStdVector()

ConstNodeStdVector QmitkAbstractNodeSelectionWidget::GetSelectedNodesStdVector ( ) const

Convenience method that returns the selected nodes as ConstNodeStdVector. This is a type also often used in the mitk code base.

◆ GetSelectionIsOptional()

bool QmitkAbstractNodeSelectionWidget::GetSelectionIsOptional ( ) const

◆ GetSelectOnlyVisibleNodes()

bool QmitkAbstractNodeSelectionWidget::GetSelectOnlyVisibleNodes ( ) const

◆ HandleChangeOfInternalSelection()

void QmitkAbstractNodeSelectionWidget::HandleChangeOfInternalSelection ( NodeList  newInternalSelection)
protected

Method is called if the internal selection has changed. It will call following methods, that can be overridden to change behavior in derived classes:

◆ OnDataStorageChanged()

virtual void QmitkAbstractNodeSelectionWidget::OnDataStorageChanged ( )
protectedvirtual

Method is called if the data storage has changed. The selection will be automatically be reset afterwards. The default implementation does nothing.

Reimplemented in QmitkSingleNodeSelectionWidget, and QmitkSynchronizedNodeSelectionWidget.

◆ OnInternalSelectionChanged()

virtual void QmitkAbstractNodeSelectionWidget::OnInternalSelectionChanged ( )
protectedvirtual

This member function will called when ever a new internal selection has been determined. This can be used to update the state of internal widgets. The default implementation does nothing.

Reimplemented in QmitkSynchronizedNodeSelectionWidget, and QmitkMultiNodeSelectionWidget.

◆ OnNodeAddedToStorage()

virtual void QmitkAbstractNodeSelectionWidget::OnNodeAddedToStorage ( const mitk::DataNode node)
protectedvirtual

Method is called when a node is added to the storage. Default implementation does nothing. Derived widgets can override the method if they want to react on new nodes in the storage.

Reimplemented in QmitkSynchronizedNodeSelectionWidget, and QmitkSingleNodeSelectionWidget.

◆ OnNodeModified()

virtual void QmitkAbstractNodeSelectionWidget::OnNodeModified ( const itk::Object *  caller,
const itk::EventObject &  event 
)
protectedvirtual

Method is called when a node is modified. The modified node is passed as 'caller' variable. Default implementation handles changes that are related to the node predicate:

  • If the node does not fit the node predicate anymore, it will be removed.
  • If the node was part of the external selection and now fits the node predicate, a new selection is compiled and emitted. Derived widgets can override the method if they want to react on modified nodes.

Reimplemented in QmitkSynchronizedNodeSelectionWidget.

◆ OnNodePredicateChanged()

virtual void QmitkAbstractNodeSelectionWidget::OnNodePredicateChanged ( )
protectedvirtual

Method is called if the predicate has changed, before the selection will be updated according to the new predicate. The default implementation does nothing.

Remarks
If you are only interested to know when the selection has changed, overwrite OnInternalSelectionChange().

Reimplemented in QmitkSingleNodeSelectionWidget, and QmitkSynchronizedNodeSelectionWidget.

◆ OnNodeRemovedFromStorage()

virtual void QmitkAbstractNodeSelectionWidget::OnNodeRemovedFromStorage ( const mitk::DataNode node)
protectedvirtual

Method is called when a node is removed from the storage. The removed node is passed as variable. This member is called directly before the node will be removed from the current selection. Default implementation does nothing. Derived widgets can override the method if they want to handle to-be-removed nodes before.

◆ OnSelectionReceived()

void QmitkAbstractNodeSelectionWidget::OnSelectionReceived ( const std::string &  context,
const std::vector< mitk::DataNode::Pointer > &  selection 
)
overridevirtual

Callback method for received selections.

Parameters
contextAn arbitrary string that sender and receiver agreed upon to establish a connection.
selectionThe sent selection of potentially multiple data nodes.

Implements mitk::INodeSelectionListener.

◆ RemoveNodeFromSelection

void QmitkAbstractNodeSelectionWidget::RemoveNodeFromSelection ( const mitk::DataNode node)
protectedslot

Call to remove a node from the current selection. If the node is part of the current selection, this will trigger ReviseSelectionChanged(), AllowEmissionOfSelection() and if there is really a change, will also emit CurrentSelectionChanged.

◆ ReviseSelectionChanged()

virtual void QmitkAbstractNodeSelectionWidget::ReviseSelectionChanged ( const NodeList oldInternalSelection,
NodeList newInternalSelection 
)
protectedvirtual

This member function is called if the internal selection is about to be changed by the base implementation. This is the slot where derived classes can revise and change the internal selection before widget updates, signal emissions and other things are triggered. Default implementation does nothing, thus it keeps the passed internal selection as compiled by the base implementation.

Reimplemented in QmitkSynchronizedNodeSelectionWidget, and QmitkSingleNodeSelectionWidget.

◆ SetCurrentInternalSelection()

void QmitkAbstractNodeSelectionWidget::SetCurrentInternalSelection ( NodeList  selectedNodes)
protected

◆ SetCurrentSelection

void QmitkAbstractNodeSelectionWidget::SetCurrentSelection ( NodeList  selectedNodes)
slot

Transform a list of data nodes (a selection) into a model selection and set this as a new selection of the selection model of the private member item view.

The function filters the given list of nodes according to the 'm_SelectOnlyVisibleNodes' member variable. If necessary, the non-visible nodes are stored. This is done if 'm_SelectOnlyVisibleNodes' is false: In this case the selection may be filtered and only a subset of the selected nodes may be visible and therefore (de-)selectable in the data storage viewer. By storing the non-visible nodes it is possible to send the new, modified selection but also include the selected nodes from the original selection that could not be modified (see 'SetSelectOnlyVisibleNodes').

nodes A list of data nodes that should be newly selected.

◆ SetDataStorage()

void QmitkAbstractNodeSelectionWidget::SetDataStorage ( mitk::DataStorage dataStorage)

Sets the data storage that will be used / monitored by widget.

dataStorage A pointer to the data storage to set.

◆ SetEmptyInfo

void QmitkAbstractNodeSelectionWidget::SetEmptyInfo ( QString  info)
slot

Set the info text that should be displayed if no (valid) node is selected, but a selection is optional. The string can contain HTML code, if desired.

◆ SetInvalidInfo

void QmitkAbstractNodeSelectionWidget::SetInvalidInfo ( QString  info)
slot

Set the info text that should be displayed if no (valid) node is selected, but a selection is mandatory. The string can contain HTML code, if desired.

◆ SetNodePredicate()

void QmitkAbstractNodeSelectionWidget::SetNodePredicate ( const mitk::NodePredicateBase nodePredicate)

Sets the node predicate and updates the widget, according to the node predicate. Implement OnNodePredicateChange() for custom actualization of a derived widget class.

nodePredicate A pointer to node predicate.

◆ SetPopUpHint

void QmitkAbstractNodeSelectionWidget::SetPopUpHint ( QString  info)
slot

Set the hint text of the popup that is displayed to alter the selection. The string can contain HTML code, if desired.

◆ SetPopUpTitel

void QmitkAbstractNodeSelectionWidget::SetPopUpTitel ( QString  info)
slot

Set the caption of the popup that is displayed to alter the selection. The string can contain HTML code, if desired.

◆ SetSelectionIsOptional

void QmitkAbstractNodeSelectionWidget::SetSelectionIsOptional ( bool  isOptional)
slot

Set the widget into an optional mode. Optional means that the selection of no valid node does not mean an invalid state. Thus no node is a valid "node" selection too.

◆ SetSelectOnlyVisibleNodes

void QmitkAbstractNodeSelectionWidget::SetSelectOnlyVisibleNodes ( bool  selectOnlyVisibleNodes)
slot

Change the selection modus of the item view's selection model.

If true, an incoming selection will be filtered (reduced) to only those nodes that are visible by the current view. An outgoing selection can then at most contain the filtered nodes. If false, the incoming non-visible selection will be stored and later added to the outgoing selection, to include the original selection that could not be modified. The part of the original selection, that is non-visible are the nodes, that do not fullfill the predicate.

selectOnlyVisibleNodes The bool value to define the selection modus.

◆ UpdateInfo()

virtual void QmitkAbstractNodeSelectionWidget::UpdateInfo ( )
protectedpure virtual

Method is called if the display of the selected nodes should be updated (e.g. because the selection changed).

Implemented in QmitkSingleNodeSelectionWidget, QmitkSynchronizedNodeSelectionWidget, and QmitkMultiNodeSelectionWidget.

Member Data Documentation

◆ m_DataStorage

mitk::WeakPointer<mitk::DataStorage> QmitkAbstractNodeSelectionWidget::m_DataStorage
protected

Definition at line 224 of file QmitkAbstractNodeSelectionWidget.h.

◆ m_EmptyInfo

QString QmitkAbstractNodeSelectionWidget::m_EmptyInfo
protected

Definition at line 228 of file QmitkAbstractNodeSelectionWidget.h.

◆ m_InvalidInfo

QString QmitkAbstractNodeSelectionWidget::m_InvalidInfo
protected

Definition at line 227 of file QmitkAbstractNodeSelectionWidget.h.

◆ m_IsOptional

bool QmitkAbstractNodeSelectionWidget::m_IsOptional
protected

See documentation of SetSelectOnlyVisibleNodes for details

Definition at line 233 of file QmitkAbstractNodeSelectionWidget.h.

◆ m_NodePredicate

mitk::NodePredicateBase::ConstPointer QmitkAbstractNodeSelectionWidget::m_NodePredicate
protected

Definition at line 225 of file QmitkAbstractNodeSelectionWidget.h.

◆ m_PopUpHint

QString QmitkAbstractNodeSelectionWidget::m_PopUpHint
protected

Definition at line 230 of file QmitkAbstractNodeSelectionWidget.h.

◆ m_PopUpTitel

QString QmitkAbstractNodeSelectionWidget::m_PopUpTitel
protected

Definition at line 229 of file QmitkAbstractNodeSelectionWidget.h.

◆ m_SelectOnlyVisibleNodes

bool QmitkAbstractNodeSelectionWidget::m_SelectOnlyVisibleNodes
protected

See documentation of SetSelectionIsOptional for details

Definition at line 235 of file QmitkAbstractNodeSelectionWidget.h.


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