Medical Imaging Interaction Toolkit  2024.06.00
Medical Imaging Interaction Toolkit
QmitkSingleNodeSelectionWidget Class Reference

Widget that represents a node selection of (max) one node. It acts like a button. Clicking on it allows to change the selection. More...

#include <QmitkSingleNodeSelectionWidget.h>

Inheritance diagram for QmitkSingleNodeSelectionWidget:
Collaboration diagram for QmitkSingleNodeSelectionWidget:

Public Types

using NodeList = QmitkAbstractNodeSelectionWidget::NodeList
 
- Public Types inherited from QmitkAbstractNodeSelectionWidget
using NodeList = QList< mitk::DataNode::Pointer >
 
using ConstNodeStdVector = std::vector< mitk::DataNode::ConstPointer >
 

Public Slots

void SetCurrentSelectedNode (mitk::DataNode *selectedNode)
 
void SetAutoSelectNewNodes (bool autoSelect)
 
- Public Slots inherited from QmitkAbstractNodeSelectionWidget
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)
 

Public Member Functions

 QmitkSingleNodeSelectionWidget (QWidget *parent=nullptr)
 
mitk::DataNode::Pointer GetSelectedNode () const
 
bool GetAutoSelectNewNodes () const
 
- Public Member Functions inherited from QmitkAbstractNodeSelectionWidget
 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
 

Protected Slots

virtual void OnClearSelection ()
 
- Protected Slots inherited from QmitkAbstractNodeSelectionWidget
void RemoveNodeFromSelection (const mitk::DataNode *node)
 

Protected Member Functions

void ReviseSelectionChanged (const NodeList &oldInternalSelection, NodeList &newInternalSelection) override
 
bool eventFilter (QObject *obj, QEvent *ev) override
 
void EditSelection ()
 
void UpdateInfo () override
 
void OnDataStorageChanged () override
 
void OnNodeAddedToStorage (const mitk::DataNode *node) override
 
void OnNodePredicateChanged () override
 
void AutoSelectNodes ()
 
mitk::DataNode::Pointer DetermineAutoSelectNode (const NodeList &ignoreNodes={})
 
- Protected Member Functions inherited from QmitkAbstractNodeSelectionWidget
virtual void OnInternalSelectionChanged ()
 
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 bool AllowEmissionOfSelection (const NodeList &emissionCandidates) const
 
void EmitSelection (const NodeList &emissionCandidates)
 
void SetCurrentInternalSelection (NodeList selectedNodes)
 
const NodeListGetCurrentInternalSelection () const
 
const NodeListGetCurrentExternalSelection () const
 

Protected Attributes

bool m_AutoSelectNodes
 
Ui_QmitkSingleNodeSelectionWidget m_Controls
 
- Protected Attributes inherited from QmitkAbstractNodeSelectionWidget
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
 

Additional Inherited Members

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

Detailed Description

Widget that represents a node selection of (max) one node. It acts like a button. Clicking on it allows to change the selection.

Remarks
This class provides a public function 'SetAutoSelectNewNodes' that can be used to enable the auto selection mode (default is false). The user of this class calling this function has to make sure that the base-class Q_SIGNAL 'CurrentSelectionChanged', which will be emitted by this function, is already connected to a receiving slot, if the initial valid auto selection should not get lost.

Definition at line 40 of file QmitkSingleNodeSelectionWidget.h.

Member Typedef Documentation

◆ NodeList

Constructor & Destructor Documentation

◆ QmitkSingleNodeSelectionWidget()

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

Member Function Documentation

◆ AutoSelectNodes()

void QmitkSingleNodeSelectionWidget::AutoSelectNodes ( )
protected

◆ DetermineAutoSelectNode()

mitk::DataNode::Pointer QmitkSingleNodeSelectionWidget::DetermineAutoSelectNode ( const NodeList ignoreNodes = {})
protected

Helper function that gets a suitable auto selected node from the datastorage that fits to the predicate settings.

Parameters
ignoreNodesYou may pass a list of nodes that must not be chosen as auto selected node.

◆ EditSelection()

void QmitkSingleNodeSelectionWidget::EditSelection ( )
protected

◆ eventFilter()

bool QmitkSingleNodeSelectionWidget::eventFilter ( QObject *  obj,
QEvent *  ev 
)
overrideprotected

◆ GetAutoSelectNewNodes()

bool QmitkSingleNodeSelectionWidget::GetAutoSelectNewNodes ( ) const

◆ GetSelectedNode()

mitk::DataNode::Pointer QmitkSingleNodeSelectionWidget::GetSelectedNode ( ) const

◆ OnClearSelection

virtual void QmitkSingleNodeSelectionWidget::OnClearSelection ( )
protectedvirtualslot

◆ OnDataStorageChanged()

void QmitkSingleNodeSelectionWidget::OnDataStorageChanged ( )
overrideprotectedvirtual

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

Reimplemented from QmitkAbstractNodeSelectionWidget.

◆ OnNodeAddedToStorage()

void QmitkSingleNodeSelectionWidget::OnNodeAddedToStorage ( const mitk::DataNode node)
overrideprotectedvirtual

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 from QmitkAbstractNodeSelectionWidget.

◆ OnNodePredicateChanged()

void QmitkSingleNodeSelectionWidget::OnNodePredicateChanged ( )
overrideprotectedvirtual

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 from QmitkAbstractNodeSelectionWidget.

◆ ReviseSelectionChanged()

void QmitkSingleNodeSelectionWidget::ReviseSelectionChanged ( const NodeList oldInternalSelection,
NodeList newInternalSelection 
)
overrideprotectedvirtual

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 from QmitkAbstractNodeSelectionWidget.

◆ SetAutoSelectNewNodes

void QmitkSingleNodeSelectionWidget::SetAutoSelectNewNodes ( bool  autoSelect)
slot

Sets the auto selection mode (default is false). If auto select is true and the following conditions are fulfilled, the widget will select a node automatically from the data storage:

  • a data storage is set
  • data storage contains at least one node that matches the given predicate
  • no selection is set
Remarks
Enabling the auto selection mode by calling 'SetAutoSelectNewNodes(true)' will directly emit a 'QmitkSingleNodeSelectionWidget::CurrentSelectionChanged' Q_SIGNAL if a valid auto selection was made. If this initial emission should not get lost, auto selection mode needs to be enabled after this selection widget has been connected via the 'QmitkSingleNodeSelectionWidget::CurrentSelectionChanged' Q_SIGNAL to a receiving function.

◆ SetCurrentSelectedNode

void QmitkSingleNodeSelectionWidget::SetCurrentSelectedNode ( mitk::DataNode selectedNode)
slot

◆ UpdateInfo()

void QmitkSingleNodeSelectionWidget::UpdateInfo ( )
overrideprotectedvirtual

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

Implements QmitkAbstractNodeSelectionWidget.

Member Data Documentation

◆ m_AutoSelectNodes

bool QmitkSingleNodeSelectionWidget::m_AutoSelectNodes
protected

See documentation of SetAutoSelectNewNodes for details

Definition at line 93 of file QmitkSingleNodeSelectionWidget.h.

◆ m_Controls

Ui_QmitkSingleNodeSelectionWidget QmitkSingleNodeSelectionWidget::m_Controls
protected

Definition at line 95 of file QmitkSingleNodeSelectionWidget.h.


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