Medical Imaging Interaction Toolkit  2018.4.99-bd7b41ba
Medical Imaging Interaction Toolkit
mitk::InteractionTestHelper Class Reference

Creates everything needed to load and playback interaction events. More...

#include <mitkInteractionTestHelper.h>

Collaboration diagram for mitk::InteractionTestHelper:

Public Types

typedef std::vector< mitk::RenderWindow::PointerRenderWindowListType
 

Public Member Functions

 InteractionTestHelper (const std::string &interactionXmlFilePath)
 InteractionTestHelper set up all neseccary objects by calling Initialize. More...
 
virtual ~InteractionTestHelper ()
 
mitk::DataStorage::Pointer GetDataStorage ()
 Returns the datastorage, in order to modify the data inside a rendering test. More...
 
void AddNodeToStorage (mitk::DataNode::Pointer node)
 AddNodeToStorage Add a node to the datastorage and perform a reinit which is necessary for rendering. More...
 
void PlaybackInteraction ()
 PlaybackInteraction playback loaded interaction by passing events to the dispatcher. More...
 
void SetTimeStep (int newTimeStep)
 SetTimeStep Sets timesteps of all SliceNavigationControllers to given timestep. More...
 
const RenderWindowListTypeGetRenderWindowList ()
 
RenderWindowGetRenderWindowByName (const std::string &name)
 GetRenderWindowByName Get renderWindow by the name of its renderer. More...
 
RenderWindowGetRenderWindowByDefaultViewDirection (mitk::SliceNavigationController::ViewDirection viewDirection)
 GetRenderWindowByDefaultViewDirection Get a renderWindow by its default viewdirection. More...
 
RenderWindowGetRenderWindow (unsigned int index)
 GetRenderWindow Get renderWindow at position 'index'. More...
 
void AddDisplayPlaneSubTree ()
 AddDisplayPlaneSubTree. More...
 
void Set3dCameraSettings ()
 

Protected Member Functions

void Initialize (const std::string &interactionXmlFilePath)
 Initialize Internal method to initialize the renderwindow and set the datastorage. More...
 
void LoadInteraction ()
 LoadInteraction loads events from xml file. More...
 

Protected Attributes

mitk::XML2EventParser::EventContainerType m_Events
 
std::string m_InteractionFilePath
 
RenderWindowListType m_RenderWindowList
 
mitk::DataStorage::Pointer m_DataStorage
 
mitk::MouseModeSwitcher::Pointer m_MouseModeSwitcher
 

Detailed Description

Creates everything needed to load and playback interaction events.

The interaction is loaded from an xml file and the event are created. This file is usually a recorded user interaction with the GUI. This can be done with InteractionEventRecorder plugin. Also all necessary objects to handle interaction events are generated. The user of this class is responsible to add the data object to interact with to the data storage of InteractionTestHelper. And must also make sure that a proper data interactor is associated with the data object.

To test a PointSet interaction for instance make sure you have a PointSet node and a PointSetDataInteractor. Then just add the node to the storage of the your InteractionTestHelper by calling InteractionTestHelper::AddNodeToStorage. Use InteractionTestHelper::PlaybackInteraction to execute. The result can afterwards be compared to a reference object.

Make sure to destroy the test helper instance after each test, since all render windows and its renderers have to be unregistered.

See also
XML2EventParser
EventFactory
EventRecorder

Definition at line 51 of file mitkInteractionTestHelper.h.

Member Typedef Documentation

◆ RenderWindowListType

Constructor & Destructor Documentation

◆ InteractionTestHelper()

mitk::InteractionTestHelper::InteractionTestHelper ( const std::string &  interactionXmlFilePath)

InteractionTestHelper set up all neseccary objects by calling Initialize.

Parameters
interactionXmlFilePathpath to xml file containing events and configuration information for the render windows.

Definition at line 29 of file mitkInteractionTestHelper.cpp.

References Initialize().

◆ ~InteractionTestHelper()

Member Function Documentation

◆ AddDisplayPlaneSubTree()

void mitk::InteractionTestHelper::AddDisplayPlaneSubTree ( )

◆ AddNodeToStorage()

void mitk::InteractionTestHelper::AddNodeToStorage ( mitk::DataNode::Pointer  node)

AddNodeToStorage Add a node to the datastorage and perform a reinit which is necessary for rendering.

Parameters
nodeThe data you want to add.

Definition at line 202 of file mitkInteractionTestHelper.cpp.

References m_DataStorage, and Set3dCameraSettings().

◆ GetDataStorage()

mitk::DataStorage::Pointer mitk::InteractionTestHelper::GetDataStorage ( )

Returns the datastorage, in order to modify the data inside a rendering test.

Definition at line 197 of file mitkInteractionTestHelper.cpp.

References m_DataStorage.

◆ GetRenderWindow()

mitk::RenderWindow * mitk::InteractionTestHelper::GetRenderWindow ( unsigned int  index)

GetRenderWindow Get renderWindow at position 'index'.

Parameters
indexPosition within the renderWindow list.
Returns
nullptr if index is out of bounds.

Definition at line 302 of file mitkInteractionTestHelper.cpp.

References m_RenderWindowList.

◆ GetRenderWindowByDefaultViewDirection()

mitk::RenderWindow * mitk::InteractionTestHelper::GetRenderWindowByDefaultViewDirection ( mitk::SliceNavigationController::ViewDirection  viewDirection)

GetRenderWindowByDefaultViewDirection Get a renderWindow by its default viewdirection.

Parameters
viewDirection
Returns
nullptr if not found.

Definition at line 287 of file mitkInteractionTestHelper.cpp.

References m_RenderWindowList.

◆ GetRenderWindowByName()

mitk::RenderWindow * mitk::InteractionTestHelper::GetRenderWindowByName ( const std::string &  name)

GetRenderWindowByName Get renderWindow by the name of its renderer.

Parameters
nameThe name of the renderer of the desired renderWindow.
Returns
nullptr if not found.

Definition at line 273 of file mitkInteractionTestHelper.cpp.

References m_RenderWindowList.

◆ GetRenderWindowList()

const RenderWindowListType& mitk::InteractionTestHelper::GetRenderWindowList ( )
inline

Definition at line 90 of file mitkInteractionTestHelper.h.

References AddDisplayPlaneSubTree().

◆ Initialize()

void mitk::InteractionTestHelper::Initialize ( const std::string &  interactionXmlFilePath)
protected

Initialize Internal method to initialize the renderwindow and set the datastorage.

Exceptions
mitk::Exceptionif interaction xml file can not be loaded.

Definition at line 35 of file mitkInteractionTestHelper.cpp.

References AddDisplayPlaneSubTree(), mitk::SliceNavigationController::Axial, mitk::RenderingManager::GetInstance(), m_DataStorage, m_InteractionFilePath, m_MouseModeSwitcher, m_RenderWindowList, mitkThrow, mitk::RenderWindow::New(), mitk::StandaloneDataStorage::New(), mitk::MouseModeSwitcher::New(), mitk::BaseRenderer::Standard2D, mitk::BaseRenderer::Standard3D, mitk::InteractionEventConst::xmlCameraFocalPointX(), mitk::InteractionEventConst::xmlCameraFocalPointY(), mitk::InteractionEventConst::xmlCameraFocalPointZ(), mitk::InteractionEventConst::xmlCameraPositionX(), mitk::InteractionEventConst::xmlCameraPositionY(), mitk::InteractionEventConst::xmlCameraPositionZ(), mitk::InteractionEventConst::xmlEventPropertyMapperID(), mitk::InteractionEventConst::xmlEventPropertyRendererName(), mitk::InteractionEventConst::xmlEventPropertyViewDirection(), mitk::InteractionEventConst::xmlRenderSizeX(), mitk::InteractionEventConst::xmlRenderSizeY(), mitk::InteractionEventConst::xmlRenderSizeZ(), mitk::InteractionEventConst::xmlTagConfigRoot(), mitk::InteractionEventConst::xmlTagInteractions(), mitk::InteractionEventConst::xmlTagRenderer(), mitk::InteractionEventConst::xmlViewUpX(), mitk::InteractionEventConst::xmlViewUpY(), and mitk::InteractionEventConst::xmlViewUpZ().

Referenced by InteractionTestHelper().

◆ LoadInteraction()

void mitk::InteractionTestHelper::LoadInteraction ( )
protected

LoadInteraction loads events from xml file.

Parameters
interactionXmlPathpath to xml file with interaction events.

Definition at line 248 of file mitkInteractionTestHelper.cpp.

References m_Events, and m_InteractionFilePath.

Referenced by PlaybackInteraction().

◆ PlaybackInteraction()

void mitk::InteractionTestHelper::PlaybackInteraction ( )

PlaybackInteraction playback loaded interaction by passing events to the dispatcher.

Definition at line 209 of file mitkInteractionTestHelper.cpp.

References mitk::RenderingManager::GetInstance(), mitk::RenderingManager::InitializeViewsByBoundingObjects(), LoadInteraction(), m_DataStorage, m_Events, and m_RenderWindowList.

◆ Set3dCameraSettings()

◆ SetTimeStep()

void mitk::InteractionTestHelper::SetTimeStep ( int  newTimeStep)

SetTimeStep Sets timesteps of all SliceNavigationControllers to given timestep.

Parameters
newTimeStepnew timestep

Does the same as using ImageNavigators Time slider. Use this if your data was modified in a timestep other than 0.

Definition at line 259 of file mitkInteractionTestHelper.cpp.

References mitk::SliceNavigationController::GetCreatedWorldGeometry(), mitk::RenderingManager::GetInstance(), mitk::BaseController::GetTime(), mitk::RenderingManager::GetTimeNavigationController(), mitk::RenderingManager::InitializeViewsByBoundingObjects(), mitk::TimeGeometry::IsValidTimeStep(), m_DataStorage, and mitk::Stepper::SetPos().

Member Data Documentation

◆ m_DataStorage

mitk::DataStorage::Pointer mitk::InteractionTestHelper::m_DataStorage
protected

◆ m_Events

mitk::XML2EventParser::EventContainerType mitk::InteractionTestHelper::m_Events
protected

Definition at line 134 of file mitkInteractionTestHelper.h.

Referenced by LoadInteraction(), and PlaybackInteraction().

◆ m_InteractionFilePath

std::string mitk::InteractionTestHelper::m_InteractionFilePath
protected

Definition at line 136 of file mitkInteractionTestHelper.h.

Referenced by Initialize(), LoadInteraction(), and Set3dCameraSettings().

◆ m_MouseModeSwitcher

mitk::MouseModeSwitcher::Pointer mitk::InteractionTestHelper::m_MouseModeSwitcher
protected

Definition at line 140 of file mitkInteractionTestHelper.h.

Referenced by Initialize().

◆ m_RenderWindowList


The documentation for this class was generated from the following files: