00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision: 18127 $ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #ifndef QmitkDataStorageComboBox_h 00019 #define QmitkDataStorageComboBox_h 00020 00021 // Own Includes 00022 #include "mitkDataStorage.h" 00023 #include "mitkDataNode.h" 00024 #include "mitkWeakPointer.h" 00025 #include "mitkNodePredicateBase.h" 00026 00027 // Toolkit Includes 00028 #include <QComboBox> 00029 #include <map> 00030 00031 // Forward Declartions 00032 00043 class QMITK_EXPORT QmitkDataStorageComboBox : public QComboBox 00044 { 00045 //#CLASS-MACROS,FRIENDS 00046 Q_OBJECT 00047 00048 //#CTORS/DTOR 00049 public: 00053 QmitkDataStorageComboBox(QWidget* parent = 0, bool _AutoSelectNewNodes=false); 00054 00058 QmitkDataStorageComboBox( mitk::DataStorage* _DataStorage, const mitk::NodePredicateBase* _Predicate, QWidget* parent = 0, bool _AutoSelectNewNodes=false); 00059 00063 ~QmitkDataStorageComboBox(); 00064 00068 int Find( const mitk::DataNode* _DataNode ) const; 00069 00070 //#PUBLIC GETTER 00071 public: 00075 mitk::DataStorage::Pointer GetDataStorage() const; 00079 const mitk::NodePredicateBase::ConstPointer GetPredicate() const; 00083 mitk::DataNode::Pointer GetNode(int index) const; 00087 mitk::DataNode::Pointer GetSelectedNode() const; 00091 mitk::DataStorage::SetOfObjects::ConstPointer GetNodes() const; 00096 virtual bool GetAutoSelectNewItems(); 00097 00098 //#PUBLIC SETTER 00099 public: 00104 void SetDataStorage(mitk::DataStorage* dataStorage); 00109 void SetPredicate(const mitk::NodePredicateBase* _Predicate); 00113 virtual void AddNode(const mitk::DataNode* _DataNode); 00117 virtual void RemoveNode(int index); 00121 virtual void RemoveNode(const mitk::DataNode* _DataNode); 00126 virtual void SetNode(int index, const mitk::DataNode* _DataNode); 00131 virtual void SetNode(const mitk::DataNode* _DataNode, const mitk::DataNode* _OtherDataNode); 00135 virtual void SetAutoSelectNewItems(bool _AutoSelectNewItems); 00139 virtual void OnDataNodeDeleteOrModified(const itk::Object *caller, const itk::EventObject &event); 00140 00141 00142 00143 signals: 00147 void OnSelectionChanged(const mitk::DataNode*); 00148 00149 00150 //#PROTECTED GETTER 00151 protected: 00155 bool HasIndex(unsigned int index) const; 00156 00157 //#PROTECTED SETTER 00158 protected slots: 00162 void OnCurrentIndexChanged(int); 00163 00164 //#PUBLIC SETTER 00165 public slots: 00169 void SetSelectedNode(mitk::DataNode::Pointer item); 00170 00171 protected: 00181 virtual void InsertNode(int index, const mitk::DataNode* _DataNode); 00182 00186 void Init(); 00187 00191 void Reset(); 00192 00193 protected: 00194 //#PROTECTED MEMBER VARS 00199 mitk::WeakPointer<mitk::DataStorage> m_DataStorage; 00200 00205 mitk::NodePredicateBase::ConstPointer m_Predicate; 00206 00210 std::vector<mitk::DataNode*> m_Nodes; 00211 00215 std::vector<long> m_NodesModifiedObserverTags; 00216 00220 std::vector<long> m_NodesDeleteObserverTags; 00221 00226 std::map<mitk::DataNode*, const mitk::BaseProperty*> m_PropertyToNode; 00227 00231 bool m_BlockEvents; 00232 00235 bool m_AutoSelectNewNodes; 00236 00237 }; 00238 00239 #endif // QmitkDataStorageComboBox_h 00240