NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
niftkDataStorageCheckableComboBox.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 /*=============================================================================
16  This file was copy-pasted from MITK and modified.
17  MITK copyright statement is below.
18 =============================================================================*/
19 
20 /*===================================================================
21 
22 The Medical Imaging Interaction Toolkit (MITK)
23 
24 Copyright (c) German Cancer Research Center,
25 Division of Medical and Biological Informatics.
26 All rights reserved.
27 
28 This software is distributed WITHOUT ANY WARRANTY; without
29 even the implied warranty of MERCHANTABILITY or FITNESS FOR
30 A PARTICULAR PURPOSE.
31 
32 See LICENSE.txt or http://www.mitk.org for details.
33 
34 ===================================================================*/
35 
36 #ifndef niftkDataStorageCheckableComboBox_h
37 #define niftkDataStorageCheckableComboBox_h
38 
39 #include "niftkCoreGuiExports.h"
40 #include <ctkCheckableComboBox.h>
41 #include <mitkDataStorage.h>
42 #include <mitkDataNode.h>
43 #include <mitkWeakPointer.h>
44 #include <mitkNodePredicateBase.h>
45 #include <QComboBox>
46 #include <map>
47 
48 namespace niftk
49 {
50 
51 class NIFTKCOREGUI_EXPORT DataStorageCheckableComboBox : public ctkCheckableComboBox
52 {
53  //#CLASS-MACROS,FRIENDS
54  Q_OBJECT
55 
56  //#CTORS/DTOR
57  public:
61  DataStorageCheckableComboBox(QWidget* parent = 0, bool _AutoSelectNewNodes=false);
62 
66  DataStorageCheckableComboBox( mitk::DataStorage* _DataStorage,
67  const mitk::NodePredicateBase* _Predicate,
68  QWidget* parent = 0, bool _AutoSelectNewNodes = false);
69 
74 
78  virtual int Find( const mitk::DataNode* _DataNode ) const;
79 
80  //#PUBLIC GETTER
81  public:
85  mitk::DataStorage::Pointer GetDataStorage() const;
89  const mitk::NodePredicateBase::ConstPointer GetPredicate() const;
93  virtual mitk::DataNode::Pointer GetNode(int index) const;
97  virtual std::vector<mitk::DataNode*> GetSelectedNodes() const;
101  mitk::DataStorage::SetOfObjects::ConstPointer GetNodes() const;
106  virtual bool GetAutoSelectNewItems();
107 
108  //#PUBLIC SETTER
109  public:
114  void SetDataStorage(mitk::DataStorage* dataStorage);
119  void SetPredicate(const mitk::NodePredicateBase* _Predicate);
123  virtual void AddNode(const mitk::DataNode* _DataNode);
128  virtual void RemoveNode(int index);
132  virtual void RemoveNode(const mitk::DataNode* _DataNode);
137  virtual void SetNode(int index, const mitk::DataNode* _DataNode);
142  virtual void SetNode(const mitk::DataNode* _DataNode, const mitk::DataNode* _OtherDataNode);
147  virtual void SetAutoSelectNewItems(bool _AutoSelectNewItems);
152  virtual void OnDataNodeDeleteOrModified(const itk::Object *caller, const itk::EventObject &event);
153 
154  signals:
158  void OnSelectionChanged(const mitk::DataNode*);
159 
160  //#PROTECTED GETTER
161  protected:
165  bool HasIndex(unsigned int index) const;
166 
167  //#PROTECTED SETTER
168  protected slots:
169 
170  //#PUBLIC SETTER
171  public slots:
175  void SetSelectedNode(mitk::DataNode::Pointer item);
176 
177  protected:
188  virtual void InsertNode(int index, const mitk::DataNode* _DataNode);
189 
193  void Init();
194 
198  virtual void Reset();
199 
200  protected:
201  //#PROTECTED MEMBER VARS
206  mitk::WeakPointer<mitk::DataStorage> m_DataStorage;
207 
212  mitk::NodePredicateBase::ConstPointer m_Predicate;
213 
217  std::vector<mitk::DataNode*> m_Nodes;
218 
222  std::vector<long> m_NodesModifiedObserverTags;
223 
227  std::vector<long> m_NodesDeleteObserverTags;
228 
233  std::map<mitk::DataNode*, const mitk::BaseProperty*> m_PropertyToNode;
234 
239 
243 };
244 
245 } // end namespace
246 
247 #endif
mitk::WeakPointer< mitk::DataStorage > m_DataStorage
Definition: niftkDataStorageCheckableComboBox.h:206
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.
Definition: niftkDataStorageCheckableComboBox.h:212
Definition: niftkDataStorageCheckableComboBox.h:51
std::vector< long > m_NodesModifiedObserverTags
Holds the tags of the node-modified observers. (must be updated everytime m_Nodes changes) ...
Definition: niftkDataStorageCheckableComboBox.h:222
bool m_BlockEvents
Event function guard. Each function which is called by an event mechanism first checks if this is tru...
Definition: niftkDataStorageCheckableComboBox.h:238
std::vector< mitk::DataNode * > m_Nodes
Definition: niftkDataStorageCheckableComboBox.h:217
GLuint index
Definition: glew.h:1798
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...
Definition: niftkDataStorageCheckableComboBox.h:233
cl_event event
Definition: glew.h:3231
std::vector< long > m_NodesDeleteObserverTags
Holds the tags of the node-modified observers. (must be updated everytime m_Nodes changes) ...
Definition: niftkDataStorageCheckableComboBox.h:227
Definition: niftkExceptionObject.h:21
bool m_AutoSelectNewNodes
If set to "true" new Nodes will be automatically selected.
Definition: niftkDataStorageCheckableComboBox.h:242