Public Types | Signals | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes

QmitkToolReferenceDataSelectionBox Class Reference
[Classes related to InteractiveSegmentationWidgets]

Display the data selection of a ToolManager. More...

#include <QmitkToolReferenceDataSelectionBox.h>

Collaboration diagram for QmitkToolReferenceDataSelectionBox:
Collaboration graph
[legend]

List of all members.

Public Types

enum  DisplayMode { ListDataIfAllToolsMatch, ListDataIfAnyToolMatches }
 

What kind of items should be displayed.

More...

Signals

void ReferenceNodeSelected (const mitk::DataNode *)

Public Member Functions

 QmitkToolReferenceDataSelectionBox (QWidget *parent=0, mitk::DataStorage *storage=0)
virtual ~QmitkToolReferenceDataSelectionBox ()
mitk::DataStorageGetDataStorage ()
void SetDataStorage (mitk::DataStorage &storage)
void Initialize (mitk::DataStorage *)
 initialization with a data storage object
void UpdateDataDisplay ()
mitk::ToolManagerGetToolManager ()
void SetToolManager (mitk::ToolManager &)
void OnToolManagerReferenceDataModified ()
void SetToolGroupsForFiltering (const std::string &groups)
 No brief description.
void SetDisplayMode (DisplayMode mode)
 How the list contents is determined.

Protected Slots

void OnReferenceDataSelected (const mitk::DataNode *node)
void EnsureOnlyReferenceImageIsVisibile ()

Protected Member Functions

mitk::DataStorage::SetOfObjects::ConstPointer GetAllPossibleReferenceImages ()
mitk::NodePredicateBase::ConstPointer GetAllPossibleReferenceImagesPredicate ()

Protected Attributes

mitk::ToolManager::Pointer m_ToolManager
QmitkDataStorageComboBoxm_ReferenceDataSelectionBox
bool m_SelfCall
DisplayMode m_DisplayMode
std::string m_ToolGroupsForFiltering
QVBoxLayout * m_Layout

Detailed Description

Display the data selection of a ToolManager.

See also:
mitk::ToolManager
mitk::DataStorage

There is a separate page describing the general design of QmitkInteractiveSegmentation: QmitkInteractiveSegmentationTechnicalPage

Shows the reference data of a ToolManager in a segmentation setting.

The reference image can be selected from a combobox, where all images of the scene are listed.

Author:
maleike

Definition at line 47 of file QmitkToolReferenceDataSelectionBox.h.


Member Enumeration Documentation

What kind of items should be displayed.

Every mitk::Tool holds a NodePredicateBase object, telling the kind of data that this tool will successfully work with. There are two ways that this list box deals with these predicates.

DEFAULT is: list data if ANY one of the displayed tools' predicate matches. Other option: list data if ALL one of the displayed tools' predicate matches

Enumerator:
ListDataIfAllToolsMatch 
ListDataIfAnyToolMatches 

Definition at line 63 of file QmitkToolReferenceDataSelectionBox.h.


Constructor & Destructor Documentation

QmitkToolReferenceDataSelectionBox::QmitkToolReferenceDataSelectionBox ( QWidget *  parent = 0,
mitk::DataStorage storage = 0 
)
QmitkToolReferenceDataSelectionBox::~QmitkToolReferenceDataSelectionBox (  ) [virtual]

Member Function Documentation

void QmitkToolReferenceDataSelectionBox::EnsureOnlyReferenceImageIsVisibile (  ) [protected, slot]

Definition at line 107 of file QmitkToolReferenceDataSelectionBox.cpp.

References GetAllPossibleReferenceImages(), mitk::RenderingManager::GetInstance(), m_ToolManager, and mitk::DataNode::SetVisibility().

Referenced by OnReferenceDataSelected(), and UpdateDataDisplay().

{
  mitk::DataNode* selectedNode = m_ToolManager->GetReferenceData(0);

  mitk::DataStorage::SetOfObjects::ConstPointer allImageNodes = GetAllPossibleReferenceImages();
  for ( mitk::DataStorage::SetOfObjects::const_iterator nodeIter = allImageNodes->begin();
    nodeIter != allImageNodes->end();
    ++nodeIter )
  {
    mitk::DataNode* currentNode = (*nodeIter).GetPointer();

    currentNode->SetVisibility( currentNode == selectedNode ); // only the selected one is visible, everything else is invisible
  }

  mitk::RenderingManager::GetInstance()->RequestUpdateAll();

}
mitk::DataStorage::SetOfObjects::ConstPointer QmitkToolReferenceDataSelectionBox::GetAllPossibleReferenceImages (  ) [protected]

display everything matching the predicate

Definition at line 182 of file QmitkToolReferenceDataSelectionBox.cpp.

References mitk::DataStorage::GetAll(), GetAllPossibleReferenceImagesPredicate(), mitk::DataStorage::GetSubset(), and m_ToolManager.

Referenced by EnsureOnlyReferenceImageIsVisibile().

{
  mitk::DataStorage* dataStorage = m_ToolManager->GetDataStorage();
  if (!dataStorage)
  {
    return mitk::DataStorage::SetOfObjects::New().GetPointer();
  }

  mitk::NodePredicateBase::ConstPointer completePredicate = GetAllPossibleReferenceImagesPredicate();

  mitk::DataStorage::SetOfObjects::ConstPointer allObjects;

  if (completePredicate.IsNotNull())
  {
    allObjects = dataStorage->GetSubset( completePredicate );
  }
  else
  {
    allObjects = dataStorage->GetAll();
  }

  mitk::ToolManager::DataVectorType resultVector;

  for ( mitk::DataStorage::SetOfObjects::const_iterator objectIter = allObjects->begin();
    objectIter != allObjects->end();
    ++objectIter )
  {
    mitk::DataNode* node = (*objectIter).GetPointer();
    resultVector.push_back( node );
  }


  mitk::DataStorage::SetOfObjects::ConstPointer sceneImages = dataStorage->GetSubset( completePredicate );
  return sceneImages;
}
mitk::NodePredicateBase::ConstPointer QmitkToolReferenceDataSelectionBox::GetAllPossibleReferenceImagesPredicate (  ) [protected]

Build up predicate:

  • ask each tool that is displayed for a predicate (indicating the type of data that this tool will work with)
  • connect all predicates using AND or OR, depending on the parameter m_DisplayMode (ListDataIfAllToolsMatch or ListDataIfAnyToolMatches)
    See also:
    SetDisplayMode

Definition at line 135 of file QmitkToolReferenceDataSelectionBox.cpp.

References mitk::Tool::GetGroup(), mitk::Tool::GetName(), mitk::Tool::GetReferenceDataPreference(), ListDataIfAnyToolMatches, m_DisplayMode, m_ToolGroupsForFiltering, m_ToolManager, mitk::NodePredicateAnd::New(), and mitk::NodePredicateOr::New().

Referenced by GetAllPossibleReferenceImages(), and UpdateDataDisplay().

{
  std::vector< mitk::NodePredicateBase::ConstPointer > m_Predicates;
  m_Predicates.clear();
  mitk::NodePredicateBase::ConstPointer completePredicate = NULL;

  const mitk::ToolManager::ToolVectorTypeConst allTools = m_ToolManager->GetTools();

  for ( mitk::ToolManager::ToolVectorTypeConst::const_iterator iter = allTools.begin();
    iter != allTools.end();
    ++iter )
  {
    const mitk::Tool* tool = *iter;

    if ( (m_ToolGroupsForFiltering.empty()) || ( m_ToolGroupsForFiltering.find( tool->GetGroup() ) != std::string::npos ) ||
      ( m_ToolGroupsForFiltering.find( tool->GetName() )  != std::string::npos )
      )
    {
      if (completePredicate)
      {
        if ( m_DisplayMode == ListDataIfAnyToolMatches )
        {
          m_Predicates.push_back( mitk::NodePredicateOr::New( completePredicate, tool->GetReferenceDataPreference() ).GetPointer() );
        }
        else
        {
          m_Predicates.push_back( mitk::NodePredicateAnd::New( completePredicate, tool->GetReferenceDataPreference() ).GetPointer() );
        }
        completePredicate = m_Predicates.back();
      }
      else
      {
        completePredicate = tool->GetReferenceDataPreference();
      }
    }
  }

  return completePredicate;
}
mitk::DataStorage * QmitkToolReferenceDataSelectionBox::GetDataStorage (  )

Definition at line 56 of file QmitkToolReferenceDataSelectionBox.cpp.

References m_ToolManager.

{
  return m_ToolManager->GetDataStorage();
}
mitk::ToolManager * QmitkToolReferenceDataSelectionBox::GetToolManager (  )

Definition at line 74 of file QmitkToolReferenceDataSelectionBox.cpp.

References m_ToolManager.

{
  return m_ToolManager;
}
void QmitkToolReferenceDataSelectionBox::Initialize ( mitk::DataStorage storage )
void QmitkToolReferenceDataSelectionBox::OnReferenceDataSelected ( const mitk::DataNode node ) [protected, slot]

Definition at line 96 of file QmitkToolReferenceDataSelectionBox.cpp.

References EnsureOnlyReferenceImageIsVisibile(), m_SelfCall, m_ToolManager, and ReferenceNodeSelected().

Referenced by QmitkToolReferenceDataSelectionBox().

{
  emit ReferenceNodeSelected(selectedNode);

  m_SelfCall = true;
  m_ToolManager->SetReferenceData( const_cast< mitk::DataNode*>(selectedNode)); // maybe NULL
  m_SelfCall = false;

  EnsureOnlyReferenceImageIsVisibile();
}
void QmitkToolReferenceDataSelectionBox::OnToolManagerReferenceDataModified (  )
void QmitkToolReferenceDataSelectionBox::ReferenceNodeSelected ( const mitk::DataNode  ) [signal]
void QmitkToolReferenceDataSelectionBox::SetDataStorage ( mitk::DataStorage storage )

Definition at line 61 of file QmitkToolReferenceDataSelectionBox.cpp.

References m_ToolManager.

{
  m_ToolManager->SetDataStorage(storage);
}
void QmitkToolReferenceDataSelectionBox::SetDisplayMode ( QmitkToolReferenceDataSelectionBox::DisplayMode  mode )

How the list contents is determined.

See also documentation of DisplayMode.

See also:
DisplayMode

Definition at line 227 of file QmitkToolReferenceDataSelectionBox.cpp.

References m_DisplayMode, and UpdateDataDisplay().

{
  if (m_DisplayMode != mode)
  {
    m_DisplayMode = mode;
    UpdateDataDisplay();
  }
}
void QmitkToolReferenceDataSelectionBox::SetToolGroupsForFiltering ( const std::string &  groups )

No brief description.

Should be called to restrict the number of tools that are evaluated to build up the list. Default is to ask all tools for their predicate, by setting the 'groups' string this can be restricted to certain groups of tools or single tools.

Definition at line 221 of file QmitkToolReferenceDataSelectionBox.cpp.

References m_ToolGroupsForFiltering, and UpdateDataDisplay().

void QmitkToolReferenceDataSelectionBox::SetToolManager ( mitk::ToolManager newManager )
void QmitkToolReferenceDataSelectionBox::UpdateDataDisplay (  )

Member Data Documentation


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines