19 #include <itkCommand.h>
28 m_AutoSelectNewNodes(_AutoSelectNewNodes)
36 bool _AutoSelectNewNodes)
39 m_Predicate(_Predicate),
41 m_AutoSelectNewNodes(_AutoSelectNewNodes)
84 if (this->count() == 0)
87 int currentIndex = this->currentIndex();
89 return currentIndex >= 0 ? this->
GetNode(currentIndex) :
nullptr;
98 _SetOfObjects->push_back(*it);
101 return _SetOfObjects.GetPointer();
190 this->removeItem(index);
215 this->
SetNode(this->
Find(_DataNode), _OtherDataNode);
230 const itk::ModifiedEvent *modifiedEvent =
dynamic_cast<const itk::ModifiedEvent *
>(&event);
242 if (it->second == _NameProperty)
245 this->
SetNode(it->first, it->first);
264 int index = this->
Find(item);
267 MITK_INFO <<
"QmitkDataStorageComboBox: item not available";
271 this->setCurrentIndex(index);
285 auto nodeIt = std::find(
m_Nodes.begin(),
m_Nodes.end(), _DataNode);
288 index = std::distance(
m_Nodes.begin(), nodeIt);
296 if (index >= 0 && index < this->count())
308 bool addNewNode =
false;
309 bool insertNewNode =
false;
310 bool changedNode =
false;
316 if (_DataNode !=
m_Nodes.at(index))
320 insertNewNode =
true;
339 if (this->
Find(_DataNode) != -1)
366 m_Nodes.push_back(_NonConstDataNode);
367 else if (insertNewNode)
371 std::string _NonConstDataNodeName =
"unnamed node";
378 this->addItem(QString::fromStdString(_NonConstDataNodeName));
381 this->setCurrentIndex(index);
386 this->setItemText(index, QString::fromStdString(_NonConstDataNodeName));
421 for (mitk::DataStorage::SetOfObjects::ConstIterator nodeIt = setOfObjects->Begin(); nodeIt != setOfObjects->End();
425 this->
AddNode(nodeIt.Value().GetPointer());
void RemoveListener(const AbstractDelegate &delegate) const
void AddListener(const AbstractDelegate &delegate) const
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 nod...
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 SetN...
Data management class that handles 'was created by' relations.
itk::SmartPointer< Self > Pointer
void SetSelectedNode(mitk::DataNode::Pointer item)
Slot for signal when user wants to set a node as current selected node.
std::vector< long > m_NodesModifiedObserverTags
Holds the tags of the node-modified observers. (must be updated everytime m_Nodes changes) ...
virtual mitk::DataNode::Pointer GetNode(int index) const
Returns the _DataNode at Index index or 0 if the index is out of bounds.
void Init()
Init-function this class with the given dataStorage and _Predicate. This function is called by all ct...
std::vector< mitk::DataNode * > m_Nodes
~QmitkDataStorageComboBox()
Standard Dtor. Nothing to do here.
mitk::WeakPointer< mitk::DataStorage > m_DataStorage
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 ...
QmitkDataStorageComboBox(QWidget *parent=nullptr, bool _AutoSelectNewNodes=false)
Ctor for an empty combobox. Use setDataStorage and setPredicate afterwards.
void OnCurrentIndexChanged(int)
Slot for signal when the user selects another item.
mitk::BaseProperty * GetProperty(const char *propertyKey, const mitk::BaseRenderer *renderer=nullptr) const
Get the property (instance of BaseProperty) with key propertyKey from the PropertyList of the rendere...
virtual void SetNode(int index, const mitk::DataNode *_DataNode)
virtual void SetAutoSelectNewItems(bool _AutoSelectNewItems)
mitk::DataStorage::SetOfObjects::ConstPointer GetNodes() const
Returns all nodes that are stored in this combobox.
itk::SmartPointer< const Self > ConstPointer
virtual void AddNode(const mitk::DataNode *_DataNode)
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.
ObjectType * GetPointer() const
virtual SetOfObjects::ConstPointer GetAll() const =0
returns a set of all data objects that are stored in the data storage
Abstract base class for properties.
bool m_AutoSelectNewNodes
If set to "true" new Nodes will be automatically selected.
mitk::DataStorage::Pointer m_DataStorage
SetOfObjects::ConstPointer GetSubset(const NodePredicateBase *condition) const
returns a set of data objects that meet the given condition(s)
virtual std::string GetValueAsString() const
bool m_BlockEvents
Event function guard. Each function which is called by an event mechanism first checks if this is tru...
void SetPredicate(const mitk::NodePredicateBase *_Predicate)
Set the predicate for this ComboBox. (QmitkDataStorageComboBox is now owner of the predicate) ...
virtual bool GetAutoSelectNewItems()
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.
DataStorageEvent AddNodeEvent
AddEvent is emitted whenever a new node has been added to the DataStorage.
virtual void RemoveNode(int index)
mitk::DataStorage::Pointer GetDataStorage() const
Get the DataStorage this ComboBox listens to.
virtual mitk::DataNode::Pointer GetSelectedNode() const
Returns the selected _DataNode or 0 if there is none.
std::vector< long > m_NodesDeleteObserverTags
Holds the tags of the node-modified observers. (must be updated everytime m_Nodes changes) ...
void OnSelectionChanged(const mitk::DataNode *)
Throw a signal when the _DataNode selection changed.
DataStorageEvent RemoveNodeEvent
RemoveEvent is emitted directly before a node is removed from the DataStorage.
const mitk::NodePredicateBase::ConstPointer GetPredicate() const
Return the predicate (may be NULL) that is responsible for the _DataNode selection of this ComboBox...
virtual void Reset()
Reset function whenever datastorage or predicate changes.
Interface for evaluation conditions used in the DataStorage class GetSubset() method.
bool HasIndex(unsigned int index) const
Checks if the given index is within the range of the m_Nodes vector.
Class for nodes of the DataTree.
void SetDataStorage(mitk::DataStorage *dataStorage)
Set the DataStorage this ComboBox should listen to.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.