Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkToolReferenceDataSelectionBox.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
19 //#include "QmitkPropertyListPopup.h"
20 
21 #include "mitkNodePredicateAnd.h"
24 #include "mitkNodePredicateNot.h"
25 #include "mitkNodePredicateOr.h"
27 
28 #include "mitkRenderingManager.h"
29 
31 
33  : QWidget(parent), m_SelfCall(false), m_DisplayMode(ListDataIfAnyToolMatches), m_ToolGroupsForFiltering("default")
34 {
36 
37  m_Layout = new QVBoxLayout(this);
38  this->setLayout(m_Layout);
39 
42 
44  SIGNAL(OnSelectionChanged(const mitk::DataNode *)),
45  this,
47 
50 }
51 
53 {
56 }
57 
59 {
60  return m_ToolManager->GetDataStorage();
61 }
62 
64 {
65  m_ToolManager->SetDataStorage(storage);
66 }
67 
69 {
71 
73 }
74 
76 {
77  return m_ToolManager;
78 }
79 
81  mitk::ToolManager &newManager) // no NULL pointer allowed here, a manager is required
82 {
85 
86  m_ToolManager = &newManager;
87 
88  m_ToolManager->ReferenceDataChanged += mitk::MessageDelegate<QmitkToolReferenceDataSelectionBox>(
90 
92 }
93 
95 {
98 }
99 
101 {
102  emit ReferenceNodeSelected(selectedNode);
103 
104  m_SelfCall = true;
105  m_ToolManager->SetReferenceData(const_cast<mitk::DataNode *>(selectedNode)); // maybe NULL
106  m_SelfCall = false;
107 
109 }
110 
112 {
113  mitk::DataNode *selectedNode = m_ToolManager->GetReferenceData(0);
114 
116  for (mitk::DataStorage::SetOfObjects::const_iterator nodeIter = allImageNodes->begin();
117  nodeIter != allImageNodes->end();
118  ++nodeIter)
119  {
120  mitk::DataNode *currentNode = (*nodeIter).GetPointer();
121 
122  currentNode->SetVisibility(currentNode ==
123  selectedNode); // only the selected one is visible, everything else is invisible
124  }
125 
127 }
128 
130 {
131  if (m_SelfCall)
132  return;
133 
134  const mitk::DataNode *node = m_ToolManager->GetReferenceData(0);
135  emit ReferenceNodeSelected(node);
136 
138 }
139 
141 {
150  std::vector<mitk::NodePredicateBase::ConstPointer> m_Predicates;
151  m_Predicates.clear();
152  mitk::NodePredicateBase::ConstPointer completePredicate = NULL;
153 
154  const mitk::ToolManager::ToolVectorTypeConst allTools = m_ToolManager->GetTools();
155 
156  for (mitk::ToolManager::ToolVectorTypeConst::const_iterator iter = allTools.begin(); iter != allTools.end(); ++iter)
157  {
158  const mitk::Tool *tool = *iter;
159 
160  if ((m_ToolGroupsForFiltering.empty()) || (m_ToolGroupsForFiltering.find(tool->GetGroup()) != std::string::npos) ||
161  (m_ToolGroupsForFiltering.find(tool->GetName()) != std::string::npos))
162  {
163  if (completePredicate)
164  {
166  {
167  m_Predicates.push_back(
168  mitk::NodePredicateOr::New(completePredicate, tool->GetReferenceDataPreference()).GetPointer());
169  }
170  else
171  {
172  m_Predicates.push_back(
173  mitk::NodePredicateAnd::New(completePredicate, tool->GetReferenceDataPreference()).GetPointer());
174  }
175  completePredicate = m_Predicates.back();
176  }
177  else
178  {
179  completePredicate = tool->GetReferenceDataPreference();
180  }
181  }
182  }
183 
184  return completePredicate;
185 }
186 
188 {
189  mitk::DataStorage *dataStorage = m_ToolManager->GetDataStorage();
190  if (!dataStorage)
191  {
192  return mitk::DataStorage::SetOfObjects::New().GetPointer();
193  }
194 
196 
198 
202  if (completePredicate.IsNotNull())
203  {
204  allObjects = dataStorage->GetSubset(completePredicate);
205  }
206  else
207  {
208  allObjects = dataStorage->GetAll();
209  }
210 
212 
213  for (mitk::DataStorage::SetOfObjects::const_iterator objectIter = allObjects->begin();
214  objectIter != allObjects->end();
215  ++objectIter)
216  {
217  mitk::DataNode *node = (*objectIter).GetPointer();
218  resultVector.push_back(node);
219  }
220 
221  mitk::DataStorage::SetOfObjects::ConstPointer sceneImages = dataStorage->GetSubset(completePredicate);
222  return sceneImages;
223 }
224 
226 {
227  m_ToolGroupsForFiltering = groups;
229 }
230 
232 {
233  if (m_DisplayMode != mode)
234  {
235  m_DisplayMode = mode;
237  }
238 }
virtual const char * GetName() const =0
Returns the name of this tool. Make it short!
std::vector< Tool::ConstPointer > ToolVectorTypeConst
mitk::NodePredicateBase::ConstPointer GetAllPossibleReferenceImagesPredicate()
Base class of all tools used by mitk::ToolManager.
Definition: mitkTool.h:92
Data management class that handles 'was created by' relations.
static Pointer New()
void Initialize(mitk::DataStorage *)
initialization with a data storage object
void SetVisibility(bool visible, const mitk::BaseRenderer *renderer=nullptr, const char *propertyKey="visible")
Convenience method for setting visibility properties (instances of BoolProperty)
Displays all or a subset (defined by a predicate) of nodes of the Data Storage.
std::vector< DataNode * > DataVectorType
static Pointer New()
virtual mitk::ToolManager * GetToolManager()
Returns ToolManager object.
itk::SmartPointer< const Self > ConstPointer
void SetToolGroupsForFiltering(const std::string &groups)
No brief description.
virtual SetOfObjects::ConstPointer GetAll() const =0
returns a set of all data objects that are stored in the data storage
SetOfObjects::ConstPointer GetSubset(const NodePredicateBase *condition) const
returns a set of data objects that meet the given condition(s)
static RenderingManager * GetInstance()
void SetPredicate(const mitk::NodePredicateBase *_Predicate)
Set the predicate for this ComboBox. (QmitkDataStorageComboBox is now owner of the predicate) ...
virtual NodePredicateBase::ConstPointer GetReferenceDataPreference() const
Definition: mitkTool.cpp:188
void OnReferenceDataSelected(const mitk::DataNode *node)
mitk::DataStorage::SetOfObjects::ConstPointer GetAllPossibleReferenceImages()
virtual const char * GetGroup() const
Name of a group.
Definition: mitkTool.cpp:106
void SetDisplayMode(DisplayMode mode)
How the list contents is determined.
DisplayMode
What kind of items should be displayed.
void ReferenceNodeSelected(const mitk::DataNode *)
void RequestUpdateAll(RequestType type=REQUEST_UPDATE_ALL)
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66
static mitk::ToolManagerProvider * GetInstance()
Returns an instance of ToolManagerProvider service.
void SetDataStorage(mitk::DataStorage *dataStorage)
Set the DataStorage this ComboBox should listen to.
Manages and coordinates instances of mitk::Tool.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.