Medical Imaging Interaction Toolkit  2018.4.99-389bf124
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 >
 

Public Slots

void SetSelectOnlyVisibleNodes (bool selectOnlyVisibleNodes)
 
void SetCurrentSelection (NodeList selectedNodes)
 
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)
 

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
 

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)
 
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 32 of file QmitkAbstractNodeSelectionWidget.h.

Member Typedef Documentation

◆ NodeList

Constructor & Destructor Documentation

◆ QmitkAbstractNodeSelectionWidget()

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

Definition at line 17 of file QmitkAbstractNodeSelectionWidget.cpp.

◆ ~QmitkAbstractNodeSelectionWidget()

QmitkAbstractNodeSelectionWidget::~QmitkAbstractNodeSelectionWidget ( )
overridevirtual

Member Function Documentation

◆ AllowEmissionOfSelection()

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 QmitkMultiNodeSelectionWidget.

Definition at line 251 of file QmitkAbstractNodeSelectionWidget.cpp.

Referenced by EmitSelection(), and RemoveNodeFromSelection().

◆ CompileEmitSelection()

QmitkAbstractNodeSelectionWidget::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).

Definition at line 324 of file QmitkAbstractNodeSelectionWidget.cpp.

References m_NodePredicate, and m_SelectOnlyVisibleNodes.

Referenced by QmitkSingleNodeSelectionWidget::eventFilter(), GetSelectedNodes(), HandleChangeOfInternalSelection(), QmitkMultiNodeSelectionWidget::OnEditSelection(), RemoveNodeFromSelection(), QmitkMultiNodeSelectionWidget::SetSelectionCheckFunction(), and SetSelectOnlyVisibleNodes().

◆ CurrentSelectionChanged

void QmitkAbstractNodeSelectionWidget::CurrentSelectionChanged ( NodeList  nodes)
signal

Referenced by EmitSelection().

◆ 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 emited.

Definition at line 256 of file QmitkAbstractNodeSelectionWidget.cpp.

References AllowEmissionOfSelection(), CurrentSelectionChanged(), and EqualNodeSelections().

Referenced by HandleChangeOfInternalSelection(), RemoveNodeFromSelection(), QmitkMultiNodeSelectionWidget::SetSelectionCheckFunction(), and SetSelectOnlyVisibleNodes().

◆ GetCurrentExternalSelection()

const QmitkAbstractNodeSelectionWidget::NodeList & QmitkAbstractNodeSelectionWidget::GetCurrentExternalSelection ( ) const
protected

Definition at line 288 of file QmitkAbstractNodeSelectionWidget.cpp.

◆ GetCurrentInternalSelection()

◆ GetEmptyInfo()

QString QmitkAbstractNodeSelectionWidget::GetEmptyInfo ( ) const

Definition at line 176 of file QmitkAbstractNodeSelectionWidget.cpp.

References m_EmptyInfo.

◆ GetInvalidInfo()

QString QmitkAbstractNodeSelectionWidget::GetInvalidInfo ( ) const

Definition at line 171 of file QmitkAbstractNodeSelectionWidget.cpp.

References m_InvalidInfo.

◆ GetNodePredicate()

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

Definition at line 166 of file QmitkAbstractNodeSelectionWidget.cpp.

References m_NodePredicate.

◆ GetPopUpHint()

QString QmitkAbstractNodeSelectionWidget::GetPopUpHint ( ) const

Definition at line 186 of file QmitkAbstractNodeSelectionWidget.cpp.

References m_PopUpHint.

◆ GetPopUpTitel()

QString QmitkAbstractNodeSelectionWidget::GetPopUpTitel ( ) const

Definition at line 181 of file QmitkAbstractNodeSelectionWidget.cpp.

References m_PopUpTitel.

◆ GetSelectedNodes()

QmitkAbstractNodeSelectionWidget::NodeList QmitkAbstractNodeSelectionWidget::GetSelectedNodes ( ) const

Returns the selected nodes, as emitted with CurrentSelectionChanged

Definition at line 46 of file QmitkAbstractNodeSelectionWidget.cpp.

References CompileEmitSelection().

◆ GetSelectionIsOptional()

bool QmitkAbstractNodeSelectionWidget::GetSelectionIsOptional ( ) const

Definition at line 191 of file QmitkAbstractNodeSelectionWidget.cpp.

References m_IsOptional.

◆ GetSelectOnlyVisibleNodes()

bool QmitkAbstractNodeSelectionWidget::GetSelectOnlyVisibleNodes ( ) const

Definition at line 196 of file QmitkAbstractNodeSelectionWidget.cpp.

References m_SelectOnlyVisibleNodes.

◆ HandleChangeOfInternalSelection()

void QmitkAbstractNodeSelectionWidget::HandleChangeOfInternalSelection ( NodeList  newInternalSelection)
protected

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

If the emission is needed and allowed it will also trigger the emission via EmitSelection().

Definition at line 131 of file QmitkAbstractNodeSelectionWidget.cpp.

References CompileEmitSelection(), EmitSelection(), OnInternalSelectionChanged(), ReviseSelectionChanged(), SetCurrentInternalSelection(), and UpdateInfo().

Referenced by QmitkSingleNodeSelectionWidget::EditSelection(), QmitkMultiNodeSelectionWidget::OnEditSelection(), QmitkSingleNodeSelectionWidget::OnNodeAddedToStorage(), RemoveNodeFromSelection(), SetCurrentSelection(), SetDataStorage(), SetNodePredicate(), and SetSelectionIsOptional().

◆ OnDataStorageChanged()

void QmitkAbstractNodeSelectionWidget::OnDataStorageChanged ( )
protectedvirtual

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

Definition at line 297 of file QmitkAbstractNodeSelectionWidget.cpp.

Referenced by SetDataStorage(), and SetSelectionIsOptional().

◆ OnInternalSelectionChanged()

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 QmitkMultiNodeSelectionWidget.

Definition at line 301 of file QmitkAbstractNodeSelectionWidget.cpp.

References OnNodeAddedToStorage().

Referenced by HandleChangeOfInternalSelection().

◆ OnNodeAddedToStorage()

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 QmitkSingleNodeSelectionWidget.

Definition at line 310 of file QmitkAbstractNodeSelectionWidget.cpp.

References OnNodeRemovedFromStorage(), and RemoveNodeFromSelection().

Referenced by OnInternalSelectionChanged().

◆ OnNodePredicateChanged()

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().

Definition at line 293 of file QmitkAbstractNodeSelectionWidget.cpp.

Referenced by SetNodePredicate().

◆ OnNodeRemovedFromStorage()

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 if he was a part. Default implementation does nothing.

Definition at line 320 of file QmitkAbstractNodeSelectionWidget.cpp.

Referenced by OnNodeAddedToStorage().

◆ 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.

Definition at line 342 of file QmitkAbstractNodeSelectionWidget.cpp.

References AllowEmissionOfSelection(), CompileEmitSelection(), EmitSelection(), HandleChangeOfInternalSelection(), m_NodePredicate, MITK_ERROR, and UpdateInfo().

Referenced by QmitkMultiNodeSelectionWidget::OnClearSelection(), and OnNodeAddedToStorage().

◆ ReviseSelectionChanged()

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 QmitkSingleNodeSelectionWidget.

Definition at line 247 of file QmitkAbstractNodeSelectionWidget.cpp.

Referenced by HandleChangeOfInternalSelection().

◆ SetCurrentInternalSelection()

void QmitkAbstractNodeSelectionWidget::SetCurrentInternalSelection ( NodeList  selectedNodes)
protected

◆ SetCurrentSelection

◆ 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.

Definition at line 51 of file QmitkAbstractNodeSelectionWidget.cpp.

References HandleChangeOfInternalSelection(), mitk::WeakPointer< T >::Lock(), m_DataStorage, and OnDataStorageChanged().

◆ 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 wanted

Definition at line 219 of file QmitkAbstractNodeSelectionWidget.cpp.

References info(), m_EmptyInfo, and UpdateInfo().

◆ 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 wanted

Definition at line 213 of file QmitkAbstractNodeSelectionWidget.cpp.

References info(), m_InvalidInfo, and UpdateInfo().

◆ 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.

Definition at line 98 of file QmitkAbstractNodeSelectionWidget.cpp.

References HandleChangeOfInternalSelection(), m_NodePredicate, m_SelectOnlyVisibleNodes, and OnNodePredicateChanged().

◆ 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 wanted

Definition at line 230 of file QmitkAbstractNodeSelectionWidget.cpp.

References info(), and m_PopUpHint.

◆ 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 wanted

Definition at line 225 of file QmitkAbstractNodeSelectionWidget.cpp.

References info(), and m_PopUpTitel.

◆ 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.

Definition at line 235 of file QmitkAbstractNodeSelectionWidget.cpp.

References HandleChangeOfInternalSelection(), m_IsOptional, OnDataStorageChanged(), and UpdateInfo().

◆ SetSelectOnlyVisibleNodes

void QmitkAbstractNodeSelectionWidget::SetSelectOnlyVisibleNodes ( bool  selectOnlyVisibleNodes)
slot

◆ 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, and QmitkMultiNodeSelectionWidget.

Referenced by HandleChangeOfInternalSelection(), RemoveNodeFromSelection(), SetEmptyInfo(), SetInvalidInfo(), and SetSelectionIsOptional().

Member Data Documentation

◆ m_DataStorage

◆ m_EmptyInfo

QString QmitkAbstractNodeSelectionWidget::m_EmptyInfo
protected

◆ m_InvalidInfo

QString QmitkAbstractNodeSelectionWidget::m_InvalidInfo
protected

◆ m_IsOptional

◆ m_NodePredicate

◆ m_PopUpHint

QString QmitkAbstractNodeSelectionWidget::m_PopUpHint
protected

◆ m_PopUpTitel

QString QmitkAbstractNodeSelectionWidget::m_PopUpTitel
protected

◆ m_SelectOnlyVisibleNodes

bool QmitkAbstractNodeSelectionWidget::m_SelectOnlyVisibleNodes
protected

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