Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkDataStorageComboBox Class Reference

Displays all or a subset (defined by a predicate) of nodes of the Data Storage. More...

#include <QmitkDataStorageComboBox.h>

Inheritance diagram for QmitkDataStorageComboBox:
Collaboration diagram for QmitkDataStorageComboBox:

Public Slots

void SetSelectedNode (const mitk::DataNode::Pointer &node)
 Slot for signal when user wants to set a node as current selected node. More...
 

Signals

void OnSelectionChanged (const mitk::DataNode *)
 Throw a signal when the data node selection changed. More...
 

Public Member Functions

 QmitkDataStorageComboBox (QWidget *parent=nullptr, bool autoSelectNewNodes=false)
 Ctor for an empty combobox. Use setDataStorage and setPredicate afterwards. More...
 
 QmitkDataStorageComboBox (mitk::DataStorage *dataStorage, const mitk::NodePredicateBase *predicate, QWidget *parent=nullptr, bool autoSelectNewNodes=false)
 Ctor for constructing QmitkDataStorageComboBox with given DataStorageComboBox and given predicate. More...
 
 ~QmitkDataStorageComboBox () override
 Standard Dtor. Nothing to do here. More...
 
virtual int Find (const mitk::DataNode *dataNode) const
 Searches for a given node and returns a valid index or -1 if the node was not found. More...
 
mitk::DataStorage::Pointer GetDataStorage () const
 Get the DataStorage this ComboBox listens to. More...
 
const mitk::NodePredicateBase::ConstPointer GetPredicate () const
 Return the predicate (may be nullptr) that is responsible for the dataNode selection of this ComboBox. More...
 
virtual mitk::DataNode::Pointer GetNode (int index) const
 Returns the dataNode at Index index or 0 if the index is out of bounds. More...
 
virtual mitk::DataNode::Pointer GetSelectedNode () const
 Returns the selected dataNode or 0 if there is none. More...
 
mitk::DataStorage::SetOfObjects::ConstPointer GetNodes () const
 Returns all nodes that are stored in this combobox. More...
 
virtual bool GetAutoSelectNewItems ()
 
void SetDataStorage (mitk::DataStorage *dataStorage)
 Set the DataStorage this ComboBox should listen to. More...
 
void SetPredicate (const mitk::NodePredicateBase *predicate)
 Set the predicate for this ComboBox. (QmitkDataStorageComboBox is now owner of the predicate) More...
 
virtual void AddNode (const mitk::DataNode *dataNode)
 
virtual void RemoveNode (int index)
 
virtual void RemoveNode (const mitk::DataNode *dataNode)
 
virtual void SetNode (int index, const mitk::DataNode *dataNode)
 
virtual void SetNode (const mitk::DataNode *dataNode, const mitk::DataNode *otherDataNode)
 
virtual void SetAutoSelectNewItems (bool autoSelectNewItems)
 
virtual void OnPropertyListChanged (const itk::Object *caller, const itk::EventObject &event)
 Called when the name property of the node was modified. More...
 

Protected Slots

void OnCurrentIndexChanged (int)
 Slot for signal when the user selects another item. More...
 

Protected Member Functions

bool HasIndex (unsigned int index) const
 Checks if the given index is within the range of the m_Nodes vector. More...
 
virtual void InsertNode (int index, const mitk::DataNode *dataNode)
 Inserts a new node at the given index. If the index does not exist, the data node is simply appended to the combobox. More...
 
void Init ()
 Init-function this class with the given data storage and predicate. This function is called by all ctors. More...
 
virtual void Reset ()
 Reset function whenever data storage or predicate changes. More...
 
void RemoveNodeAndPropertyLists (int index)
 
virtual void UpdateComboBoxText (const mitk::PropertyList *)
 

Protected Attributes

mitk::WeakPointer< mitk::DataStoragem_DataStorage
 
mitk::NodePredicateBase::ConstPointer m_Predicate
 Holds the predicate that is responsible for the dataNode selection of this ComboBox. If the predicate is 0, every dataNode will be selected. More...
 
std::vector< mitk::DataNode * > m_Nodes
 
std::vector< long > m_DataNodePropertyListObserverTags
 Holds the tags of the data node property observers. More...
 
std::vector< long > m_BaseDatapropertyListObserverTags
 Holds the tags of the base data property observers. More...
 
bool m_BlockEvents
 Event function guard. Each function which is called by an event mechanism first checks if this is true in order to avoid endless loops. More...
 
bool m_AutoSelectNewNodes
 If set to "true" new Nodes will be automatically selected. More...
 

Detailed Description

Displays all or a subset (defined by a predicate) of nodes of the Data Storage.

Author
Michael Mueller
Version
4.0
Date
2009-02-09

Definition at line 38 of file QmitkDataStorageComboBox.h.

Constructor & Destructor Documentation

◆ QmitkDataStorageComboBox() [1/2]

QmitkDataStorageComboBox::QmitkDataStorageComboBox ( QWidget *  parent = nullptr,
bool  autoSelectNewNodes = false 
)

Ctor for an empty combobox. Use setDataStorage and setPredicate afterwards.

Definition at line 17 of file QmitkDataStorageComboBox.cpp.

References Init().

◆ QmitkDataStorageComboBox() [2/2]

QmitkDataStorageComboBox::QmitkDataStorageComboBox ( mitk::DataStorage dataStorage,
const mitk::NodePredicateBase predicate,
QWidget *  parent = nullptr,
bool  autoSelectNewNodes = false 
)

Ctor for constructing QmitkDataStorageComboBox with given DataStorageComboBox and given predicate.

Definition at line 27 of file QmitkDataStorageComboBox.cpp.

References Init(), and SetDataStorage().

◆ ~QmitkDataStorageComboBox()

QmitkDataStorageComboBox::~QmitkDataStorageComboBox ( )
override

Standard Dtor. Nothing to do here.

Definition at line 42 of file QmitkDataStorageComboBox.cpp.

References AddNode(), mitk::WeakPointer< T >::IsExpired(), mitk::WeakPointer< T >::Lock(), m_DataStorage, m_Nodes, and RemoveNode().

Member Function Documentation

◆ AddNode()

void QmitkDataStorageComboBox::AddNode ( const mitk::DataNode dataNode)
virtual

Adds a node to the ComboBox. Gets called every time a DataStorage Add Event was thrown.

Definition at line 165 of file QmitkDataStorageComboBox.cpp.

References InsertNode(), and m_BlockEvents.

Referenced by Reset(), SetDataStorage(), and ~QmitkDataStorageComboBox().

◆ Find()

int QmitkDataStorageComboBox::Find ( const mitk::DataNode dataNode) const
virtual

Searches for a given node and returns a valid index or -1 if the node was not found.

Reimplemented in QmitkDataStorageComboBoxWithSelectNone.

Definition at line 62 of file QmitkDataStorageComboBox.cpp.

References m_Nodes.

Referenced by QmitkDataStorageComboBoxWithSelectNone::Find(), InsertNode(), RemoveNode(), QmitkInitialValuesDelegate::setEditorData(), SetNode(), SetSelectedNode(), and UpdateComboBoxText().

◆ GetAutoSelectNewItems()

bool QmitkDataStorageComboBox::GetAutoSelectNewItems ( )
virtual

Returns the AutoSelectNewItems.

See also
SetAutoSelectNewItems

Definition at line 111 of file QmitkDataStorageComboBox.cpp.

References m_AutoSelectNewNodes.

◆ GetDataStorage()

mitk::DataStorage::Pointer QmitkDataStorageComboBox::GetDataStorage ( ) const

Get the DataStorage this ComboBox listens to.

Definition at line 74 of file QmitkDataStorageComboBox.cpp.

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

◆ GetNode()

mitk::DataNode::Pointer QmitkDataStorageComboBox::GetNode ( int  index) const
virtual

Returns the dataNode at Index index or 0 if the index is out of bounds.

Reimplemented in QmitkDataStorageComboBoxWithSelectNone.

Definition at line 84 of file QmitkDataStorageComboBox.cpp.

References HasIndex(), and m_Nodes.

Referenced by GetSelectedNode().

◆ GetNodes()

mitk::DataStorage::SetOfObjects::ConstPointer QmitkDataStorageComboBox::GetNodes ( ) const

Returns all nodes that are stored in this combobox.

Definition at line 99 of file QmitkDataStorageComboBox.cpp.

References m_Nodes.

◆ GetPredicate()

const mitk::NodePredicateBase::ConstPointer QmitkDataStorageComboBox::GetPredicate ( ) const

Return the predicate (may be nullptr) that is responsible for the dataNode selection of this ComboBox.

Definition at line 79 of file QmitkDataStorageComboBox.cpp.

References m_Predicate.

◆ GetSelectedNode()

mitk::DataNode::Pointer QmitkDataStorageComboBox::GetSelectedNode ( ) const
virtual

Returns the selected dataNode or 0 if there is none.

Reimplemented in QmitkDataStorageComboBoxWithSelectNone.

Definition at line 89 of file QmitkDataStorageComboBox.cpp.

References GetNode().

Referenced by OnCurrentIndexChanged(), QmitkInitialValuesDelegate::setModelData(), and QmitkNDIToolDelegate::setModelData().

◆ HasIndex()

bool QmitkDataStorageComboBox::HasIndex ( unsigned int  index) const
protected

Checks if the given index is within the range of the m_Nodes vector.

Definition at line 242 of file QmitkDataStorageComboBox.cpp.

References m_Nodes.

Referenced by GetNode(), InsertNode(), RemoveNode(), and SetNode().

◆ Init()

void QmitkDataStorageComboBox::Init ( )
protected

Init-function this class with the given data storage and predicate. This function is called by all ctors.

Definition at line 368 of file QmitkDataStorageComboBox.cpp.

References OnCurrentIndexChanged().

Referenced by QmitkDataStorageComboBox().

◆ InsertNode()

void QmitkDataStorageComboBox::InsertNode ( int  index,
const mitk::DataNode dataNode 
)
protectedvirtual

Inserts a new node at the given index. If the index does not exist, the data node is simply appended to the combobox.

This function is used by AddNode() and SetNode() because they just to the same:

  1. If node is replaced (that is when index exists), the itk::Event observer will be removed
  2. Check Node against Predicate
  3. Register for itk::Events on the node
  4. Insert Node and show in combobox

Reimplemented in QmitkDataStorageComboBoxWithSelectNone.

Definition at line 268 of file QmitkDataStorageComboBox.cpp.

References Find(), mitk::DataNode::GetData(), mitk::DataNode::GetName(), mitk::DataNode::GetPropertyList(), mitk::BaseData::GetPropertyList(), HasIndex(), m_AutoSelectNewNodes, m_BaseDatapropertyListObserverTags, m_DataNodePropertyListObserverTags, m_Nodes, m_Predicate, OnPropertyListChanged(), and RemoveNode().

Referenced by AddNode(), QmitkDataStorageComboBoxWithSelectNone::InsertNode(), QmitkDataStorageComboBoxWithSelectNone::SetNode(), and SetNode().

◆ OnCurrentIndexChanged

void QmitkDataStorageComboBox::OnCurrentIndexChanged ( int  index)
protectedslot

Slot for signal when the user selects another item.

Definition at line 247 of file QmitkDataStorageComboBox.cpp.

References GetSelectedNode(), and OnSelectionChanged().

Referenced by Init().

◆ OnPropertyListChanged()

void QmitkDataStorageComboBox::OnPropertyListChanged ( const itk::Object *  caller,
const itk::EventObject &  event 
)
virtual

Called when the name property of the node was modified.

Definition at line 224 of file QmitkDataStorageComboBox.cpp.

References m_BlockEvents, and UpdateComboBoxText().

Referenced by InsertNode().

◆ OnSelectionChanged

void QmitkDataStorageComboBox::OnSelectionChanged ( const mitk::DataNode )
signal

Throw a signal when the data node selection changed.

Referenced by OnCurrentIndexChanged(), and QmitkNodeDetailsDialog::QmitkNodeDetailsDialog().

◆ RemoveNode() [1/2]

void QmitkDataStorageComboBox::RemoveNode ( int  index)
virtual

Removes a node from the ComboBox at a specified index (if the index exists). Gets called when a DataStorage Remove Event was thrown.

Reimplemented in QmitkDataStorageComboBoxWithSelectNone.

Definition at line 177 of file QmitkDataStorageComboBox.cpp.

References HasIndex(), and RemoveNodeAndPropertyLists().

Referenced by InsertNode(), RemoveNode(), Reset(), SetDataStorage(), and ~QmitkDataStorageComboBox().

◆ RemoveNode() [2/2]

void QmitkDataStorageComboBox::RemoveNode ( const mitk::DataNode dataNode)
virtual

Removes a node from the ComboBox. Gets called when a DataStorage Remove Event was thrown.

Definition at line 187 of file QmitkDataStorageComboBox.cpp.

References Find(), m_BlockEvents, and RemoveNode().

◆ RemoveNodeAndPropertyLists()

◆ Reset()

void QmitkDataStorageComboBox::Reset ( void  )
protectedvirtual

◆ SetAutoSelectNewItems()

void QmitkDataStorageComboBox::SetAutoSelectNewItems ( bool  autoSelectNewItems)
virtual

Sets AutoSelectNewItems flag. If set to true new Nodes will be automatically selected. Default is false.

Definition at line 219 of file QmitkDataStorageComboBox.cpp.

References m_AutoSelectNewNodes.

◆ SetDataStorage()

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

Set the DataStorage this ComboBox should listen to.

If DataStorage is 0 nothing will be shown. If DataStorage is reset the combobox will be reset.

Definition at line 116 of file QmitkDataStorageComboBox.cpp.

References AddNode(), mitk::WeakPointer< T >::IsExpired(), mitk::WeakPointer< T >::Lock(), m_DataStorage, RemoveNode(), and Reset().

Referenced by QmitkToolReferenceDataSelectionBox::Initialize(), and QmitkDataStorageComboBox().

◆ SetNode() [1/2]

void QmitkDataStorageComboBox::SetNode ( int  index,
const mitk::DataNode dataNode 
)
virtual

Set a dataNode in the ComboBox at the specified index (if the index exists). Internally the method just calls RemoveNode(unsigned int)

Reimplemented in QmitkDataStorageComboBoxWithSelectNone.

Definition at line 198 of file QmitkDataStorageComboBox.cpp.

References mitk::DataNode::GetName(), HasIndex(), InsertNode(), and m_Nodes.

Referenced by SetNode().

◆ SetNode() [2/2]

void QmitkDataStorageComboBox::SetNode ( const mitk::DataNode dataNode,
const mitk::DataNode otherDataNode 
)
virtual

Replaces a dataNode in the combobox by an otherDataNode. Internally the method just calls SetNode(unsigned int, mitk::DataNode*)

Definition at line 214 of file QmitkDataStorageComboBox.cpp.

References Find(), and SetNode().

◆ SetPredicate()

void QmitkDataStorageComboBox::SetPredicate ( const mitk::NodePredicateBase predicate)

Set the predicate for this ComboBox. (QmitkDataStorageComboBox is now owner of the predicate)

If predicate is nullptr all nodes will be selected. If predicate changes the whole combobox will be reset.

Definition at line 156 of file QmitkDataStorageComboBox.cpp.

References m_Predicate, and Reset().

Referenced by QmitkToolReferenceDataSelectionBox::UpdateDataDisplay().

◆ SetSelectedNode

void QmitkDataStorageComboBox::SetSelectedNode ( const mitk::DataNode::Pointer node)
slot

Slot for signal when user wants to set a node as current selected node.

Definition at line 255 of file QmitkDataStorageComboBox.cpp.

References Find(), and MITK_INFO.

◆ UpdateComboBoxText()

void QmitkDataStorageComboBox::UpdateComboBoxText ( const mitk::PropertyList propertyList)
protectedvirtual

Definition at line 440 of file QmitkDataStorageComboBox.cpp.

References Find(), mitk::BaseData::GetPropertyList(), and m_Nodes.

Referenced by OnPropertyListChanged().

Member Data Documentation

◆ m_AutoSelectNewNodes

bool QmitkDataStorageComboBox::m_AutoSelectNewNodes
protected

If set to "true" new Nodes will be automatically selected.

Definition at line 222 of file QmitkDataStorageComboBox.h.

Referenced by GetAutoSelectNewItems(), InsertNode(), and SetAutoSelectNewItems().

◆ m_BaseDatapropertyListObserverTags

std::vector<long> QmitkDataStorageComboBox::m_BaseDatapropertyListObserverTags
protected

Holds the tags of the base data property observers.

Definition at line 213 of file QmitkDataStorageComboBox.h.

Referenced by InsertNode(), and RemoveNodeAndPropertyLists().

◆ m_BlockEvents

bool QmitkDataStorageComboBox::m_BlockEvents
protected

Event function guard. Each function which is called by an event mechanism first checks if this is true in order to avoid endless loops.

Definition at line 218 of file QmitkDataStorageComboBox.h.

Referenced by AddNode(), OnPropertyListChanged(), and RemoveNode().

◆ m_DataNodePropertyListObserverTags

std::vector<long> QmitkDataStorageComboBox::m_DataNodePropertyListObserverTags
protected

Holds the tags of the data node property observers.

Definition at line 208 of file QmitkDataStorageComboBox.h.

Referenced by InsertNode(), and RemoveNodeAndPropertyLists().

◆ m_DataStorage

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

Pointer to the DataStorage from which the nodes are selected (remember: in BlueBerry there might be more than one DataStorage).

Definition at line 192 of file QmitkDataStorageComboBox.h.

Referenced by GetDataStorage(), Reset(), SetDataStorage(), and ~QmitkDataStorageComboBox().

◆ m_Nodes

◆ m_Predicate

mitk::NodePredicateBase::ConstPointer QmitkDataStorageComboBox::m_Predicate
protected

Holds the predicate that is responsible for the dataNode selection of this ComboBox. If the predicate is 0, every dataNode will be selected.

Definition at line 198 of file QmitkDataStorageComboBox.h.

Referenced by GetPredicate(), InsertNode(), Reset(), and SetPredicate().


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