Medical Imaging Interaction Toolkit  2016.11.0
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 (mitk::DataNode::Pointer item)
 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 _DataNode 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 ()
 Standard Dtor. Nothing to do here. More...
 
virtual int Find (const mitk::DataNode *_DataNode) const
 Seaches 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 NULL) 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 OnDataNodeDeleteOrModified (const itk::Object *caller, const itk::EventObject &event)
 Called when a node is deleted or the name property of the node was modified. Calls RemoveNode or SetNode then. 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 _DataNode is simply appended to the combobox. More...
 
void Init ()
 Init-function this class with the given dataStorage and _Predicate. This function is called by all ctors. More...
 
virtual void Reset ()
 Reset function whenever datastorage or predicate changes. More...
 

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_NodesModifiedObserverTags
 Holds the tags of the node-modified observers. (must be updated everytime m_Nodes changes) More...
 
std::vector< long > m_NodesDeleteObserverTags
 Holds the tags of the node-modified observers. (must be updated everytime m_Nodes changes) More...
 
std::map< mitk::DataNode *, const mitk::BaseProperty * > m_PropertyToNode
 Maps a a specific node to (Name-)property. This is needed because we have to find the assiociated node whenever the name property of a node changed. 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

Dont forget that this class inherits from QComboBox and you can therefore use the whole API of QComboBox.

Definition at line 45 of file QmitkDataStorageComboBox.h.

Constructor & Destructor Documentation

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

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

Definition at line 23 of file QmitkDataStorageComboBox.cpp.

References Init().

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 33 of file QmitkDataStorageComboBox.cpp.

References Init(), and SetDataStorage().

Member Function Documentation

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

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

Definition at line 155 of file QmitkDataStorageComboBox.cpp.

References InsertNode(), and m_BlockEvents.

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

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

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

Reimplemented in QmitkDataStorageComboBoxWithSelectNone.

Definition at line 281 of file QmitkDataStorageComboBox.cpp.

References m_Nodes.

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

bool QmitkDataStorageComboBox::GetAutoSelectNewItems ( )
virtual

Returns the AutoSelectNewItems.

See also
SetAutoSelectNewItems

Definition at line 104 of file QmitkDataStorageComboBox.cpp.

References m_AutoSelectNewNodes.

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

Get the DataStorage this ComboBox listens to.

Definition at line 67 of file QmitkDataStorageComboBox.cpp.

References mitk::WeakPointer< TObjectType >::GetPointer(), and m_DataStorage.

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 77 of file QmitkDataStorageComboBox.cpp.

References HasIndex(), and m_Nodes.

Referenced by GetSelectedNode().

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

Returns all nodes that are stored in this combobox.

Definition at line 92 of file QmitkDataStorageComboBox.cpp.

References m_Nodes, and mitk::New().

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

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

Definition at line 72 of file QmitkDataStorageComboBox.cpp.

References m_Predicate.

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

Returns the selected _DataNode or 0 if there is none.

Reimplemented in QmitkDataStorageComboBoxWithSelectNone.

Definition at line 82 of file QmitkDataStorageComboBox.cpp.

References GetNode().

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

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 276 of file QmitkDataStorageComboBox.cpp.

References m_Nodes.

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

void QmitkDataStorageComboBox::Init ( )
protected

Init-function this class with the given dataStorage and _Predicate. This function is called by all ctors.

Definition at line 390 of file QmitkDataStorageComboBox.cpp.

References OnCurrentIndexChanged().

Referenced by QmitkDataStorageComboBox().

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 _DataNode 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

property of the node because this is the only thing we are interested in !!!!!

Reimplemented in QmitkDataStorageComboBoxWithSelectNone.

Definition at line 302 of file QmitkDataStorageComboBox.cpp.

References Find(), mitk::DataNode::GetProperty(), mitk::BaseProperty::GetValueAsString(), HasIndex(), m_AutoSelectNewNodes, m_Nodes, m_NodesDeleteObserverTags, m_NodesModifiedObserverTags, m_Predicate, m_PropertyToNode, mitk::New(), OnDataNodeDeleteOrModified(), and RemoveNode().

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

void QmitkDataStorageComboBox::OnCurrentIndexChanged ( int  index)
protectedslot

Slot for signal when the user selects another item.

Definition at line 294 of file QmitkDataStorageComboBox.cpp.

References GetSelectedNode(), and OnSelectionChanged().

Referenced by Init().

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

Called when a node is deleted or the name property of the node was modified. Calls RemoveNode or SetNode then.

Definition at line 223 of file QmitkDataStorageComboBox.cpp.

References m_BlockEvents, m_PropertyToNode, RemoveNode(), and SetNode().

Referenced by InsertNode().

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

Throw a signal when the _DataNode selection changed.

Referenced by OnCurrentIndexChanged().

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 167 of file QmitkDataStorageComboBox.cpp.

References mitk::DataNode::GetProperty(), HasIndex(), m_Nodes, m_NodesDeleteObserverTags, m_NodesModifiedObserverTags, and m_PropertyToNode.

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

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 194 of file QmitkDataStorageComboBox.cpp.

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

void QmitkDataStorageComboBox::Reset ( void  )
protectedvirtual
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 218 of file QmitkDataStorageComboBox.cpp.

References m_AutoSelectNewNodes.

void QmitkDataStorageComboBox::SetDataStorage ( mitk::DataStorage dataStorage)
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 205 of file QmitkDataStorageComboBox.cpp.

References HasIndex(), and InsertNode().

Referenced by OnDataNodeDeleteOrModified(), and SetNode().

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 213 of file QmitkDataStorageComboBox.cpp.

References Find(), and SetNode().

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

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

If predicate is NULL all nodes will be selected. If predicate changes the whole combobox will be resetted.

Definition at line 146 of file QmitkDataStorageComboBox.cpp.

References m_Predicate, and Reset().

Referenced by QmitkToolReferenceDataSelectionBox::UpdateDataDisplay().

void QmitkDataStorageComboBox::SetSelectedNode ( mitk::DataNode::Pointer  item)
slot

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

Definition at line 262 of file QmitkDataStorageComboBox.cpp.

References Find(), and MITK_INFO.

Referenced by QmitkFunctionalityComponentContainer::ImageSelected().

Member Data Documentation

bool QmitkDataStorageComboBox::m_AutoSelectNewNodes
protected

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

Definition at line 240 of file QmitkDataStorageComboBox.h.

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

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 236 of file QmitkDataStorageComboBox.h.

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

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 204 of file QmitkDataStorageComboBox.h.

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

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

Holds the tags of the node-modified observers. (must be updated everytime m_Nodes changes)

Definition at line 225 of file QmitkDataStorageComboBox.h.

Referenced by InsertNode(), QmitkDataStorageComboBoxWithSelectNone::RemoveNode(), and RemoveNode().

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

Holds the tags of the node-modified observers. (must be updated everytime m_Nodes changes)

Definition at line 220 of file QmitkDataStorageComboBox.h.

Referenced by InsertNode(), QmitkDataStorageComboBoxWithSelectNone::RemoveNode(), and RemoveNode().

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 210 of file QmitkDataStorageComboBox.h.

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

std::map<mitk::DataNode *, const mitk::BaseProperty *> QmitkDataStorageComboBox::m_PropertyToNode
protected

Maps a a specific node to (Name-)property. This is needed because we have to find the assiociated node whenever the name property of a node changed.

Definition at line 231 of file QmitkDataStorageComboBox.h.

Referenced by InsertNode(), OnDataNodeDeleteOrModified(), QmitkDataStorageComboBoxWithSelectNone::RemoveNode(), and RemoveNode().


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