MCPcopy Create free account
hub / github.com/MITK/MITK / SetWorkingData

Method SetWorkingData

Modules/Segmentation/src/Controllers/mitkToolManager.cpp:322–359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320}
321
322void mitk::ToolManager::SetWorkingData(DataVectorType data)
323{
324 if (data != m_WorkingData)
325 {
326 // remove observers from old nodes
327 for (auto dataIter = m_WorkingData.begin(); dataIter != m_WorkingData.end(); ++dataIter)
328 {
329 auto searchIter = m_WorkingDataObserverTags.find(*dataIter);
330 if (searchIter != m_WorkingDataObserverTags.end())
331 {
332 (*dataIter)->RemoveObserver(searchIter->second);
333 }
334 }
335
336 m_WorkingData = data;
337 // TODO tell active tool?
338
339 // Quick workaround for bug #16598
340 if (m_WorkingData.empty())
341 this->ActivateTool(-1);
342 // workaround end
343
344 m_ActiveWorkingLabel = MultiLabelSegmentation::UNLABELED_VALUE; //changing the working data also leads to a reset of the active label.
345
346 // attach new observers
347 m_WorkingDataObserverTags.clear();
348 for (auto dataIter = m_WorkingData.begin(); dataIter != m_WorkingData.end(); ++dataIter)
349 {
350 itk::MemberCommand<ToolManager>::Pointer command = itk::MemberCommand<ToolManager>::New();
351 command->SetCallbackFunction(this, &ToolManager::OnOneOfTheWorkingDataDeleted);
352 command->SetCallbackFunction(this, &ToolManager::OnOneOfTheWorkingDataDeletedConst);
353 m_WorkingDataObserverTags.insert(
354 std::pair<DataNode *, unsigned long>((*dataIter), (*dataIter)->AddObserver(itk::DeleteEvent(), command)));
355 }
356
357 WorkingDataChanged.Send();
358 }
359}
360
361void mitk::ToolManager::OnOneOfTheWorkingDataDeletedConst(const itk::Object *caller, const itk::EventObject &e)
362{

Callers 6

RunTestWithParametersMethod · 0.80
TestSetterMethodsMethod · 0.80
OnAnySelectionChangedMethod · 0.80

Calls 9

ActivateToolMethod · 0.95
AddObserverMethod · 0.80
NewFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
findMethod · 0.45
emptyMethod · 0.45
clearMethod · 0.45
SendMethod · 0.45

Tested by 2

RunTestWithParametersMethod · 0.64
TestSetterMethodsMethod · 0.64