Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
Medical Imaging Interaction Toolkit
mitk::RenderingTestHelper Class Reference

#include <mitkRenderingTestHelper.h>

Collaboration diagram for mitk::RenderingTestHelper:

Classes

class  ArgcHelperClass
 The ArgcHelperClass class is a convinience class to convert a vector of strings to the standard c++ argv and argc arguments. This is necessary for the vtkTesting::Test, since is requires the reference image (and other optional parameters) via command line. More...
 

Public Member Functions

 RenderingTestHelper (int width, int height, int argc, char *argv[], AntiAliasing antiAliasing=AntiAliasing::None)
 Generate a rendering test helper object including a render window of the size width * height (in pixel). More...
 
 RenderingTestHelper (int width, int height, AntiAliasing antiAliasing=AntiAliasing::None)
 Generate a rendering test helper object including a render window of the size width * height (in pixel). More...
 
 ~RenderingTestHelper ()
 
vtkRenderer * GetVtkRenderer ()
 Getter for the vtkRenderer. More...
 
vtkRenderWindow * GetVtkRenderWindow ()
 Getter for the vtkRenderWindow which should be used to call vtkRegressionTestImage. More...
 
void SaveAsPNG (std::string fileName)
 Method can be used to save a screenshot (e.g. reference screenshot as a .png file. More...
 
void SetAutomaticallyCloseRenderWindow (bool automaticallyCloseRenderWindow)
 SetStopRenderWindow Convenience method to make the renderwindow hold after rendering. Usefull for debugging. More...
 
void SetImageProperty (const char *propertyKey, mitk::BaseProperty *property)
 This method set the property of the member datastorage. More...
 
void SetViewDirection (mitk::SliceNavigationController::ViewDirection viewDirection)
 Set the view direction of the renderwindow (e.g. sagittal, coronal, axial) More...
 
void ReorientSlices (mitk::Point3D origin, mitk::Vector3D rotation)
 Reorient the slice (e.g. rotation and translation like the swivel mode). More...
 
void Render ()
 Render everything into an mitkRenderWindow. Call SetViewDirection() and SetProperty() before this method. More...
 
mitk::DataStorage::Pointer GetDataStorage ()
 Returns the datastorage, in order to modify the data inside a rendering test. More...
 
void SetMapperID (mitk::BaseRenderer::StandardMapperSlot id)
 SetMapperID Change between Standard2D and 3D mappers. 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 SetMapperIDToRender3D ()
 SetMapperIDToRender3D Convenience method to render in a 3D renderwindow. More...
 
void SetMapperIDToRender2D ()
 SetMapperIDToRender2D Convenience method to render in a 2D renderwindow. More...
 
void SaveReferenceScreenShot (std::string fileName)
 SaveReferenceScreenShot Convenience method to save a reference screen shot. More...
 
bool CompareRenderWindowAgainstReference (int argc, char *argv[], double threshold=10.0)
 CompareRenderWindowAgainstReference Convenience method to compare the image rendered in the internal renderwindow against a reference screen shot. More...
 

Protected Member Functions

void Initialize (int width, int height, AntiAliasing antiAliasing=AntiAliasing::None)
 Initialize Internal method to initialize the renderwindow and set the datastorage. More...
 
void AddToStorage (const std::string &filename)
 This method tries to load the given file into a member datastorage, in order to render it. More...
 
void SetInputFileNames (int argc, char *argv[])
 This method tries to parse the given argv for files (e.g. images) and load them into a member datastorage, in order to render it. More...
 

Protected Attributes

mitk::RenderWindow::Pointer m_RenderWindow
 
mitk::DataStorage::Pointer m_DataStorage
 
bool m_AutomaticallyCloseRenderWindow
 

Detailed Description

Definition at line 28 of file mitkRenderingTestHelper.h.

Constructor & Destructor Documentation

◆ RenderingTestHelper() [1/2]

mitk::RenderingTestHelper::RenderingTestHelper ( int  width,
int  height,
int  argc,
char *  argv[],
AntiAliasing  antiAliasing = AntiAliasing::None 
)

Generate a rendering test helper object including a render window of the size width * height (in pixel).

Parameters
argcNumber of parameters. (here: Images) "Usage: [filename1 filenam2 -V referenceScreenshot (optional -T /directory/to/save/differenceImage)]
argvGiven parameters. If no data is inserted via commandline, you can add data later via AddNodeToDataStorage().
renderingModeThe rendering mode.

Definition at line 52 of file mitkRenderingTestHelper.cpp.

References Initialize(), and SetInputFileNames().

◆ RenderingTestHelper() [2/2]

mitk::RenderingTestHelper::RenderingTestHelper ( int  width,
int  height,
AntiAliasing  antiAliasing = AntiAliasing::None 
)

Generate a rendering test helper object including a render window of the size width * height (in pixel).

Definition at line 44 of file mitkRenderingTestHelper.cpp.

References Initialize().

◆ ~RenderingTestHelper()

mitk::RenderingTestHelper::~RenderingTestHelper ( )

Default destructor

Definition at line 132 of file mitkRenderingTestHelper.cpp.

Member Function Documentation

◆ AddNodeToStorage()

void mitk::RenderingTestHelper::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 287 of file mitkRenderingTestHelper.cpp.

References mitk::RenderingManager::GetInstance(), mitk::RenderingManager::InitializeViews(), and m_DataStorage.

Referenced by addPlaneToDataStorage(), and createTextAnnotationWithLayouter().

◆ AddToStorage()

void mitk::RenderingTestHelper::AddToStorage ( const std::string &  filename)
protected

This method tries to load the given file into a member datastorage, in order to render it.

Parameters
fileNameThe filename of the file to be loaded (including path).

Definition at line 273 of file mitkRenderingTestHelper.cpp.

References mitk::RenderingManager::GetInstance(), mitk::RenderingManager::InitializeViews(), mitk::IOUtil::Load(), m_DataStorage, and MITK_ERROR.

Referenced by SetInputFileNames().

◆ CompareRenderWindowAgainstReference()

bool mitk::RenderingTestHelper::CompareRenderWindowAgainstReference ( int  argc,
char *  argv[],
double  threshold = 10.0 
)

CompareRenderWindowAgainstReference Convenience method to compare the image rendered in the internal renderwindow against a reference screen shot.

Usage of vtkTesting::Test: vtkTesting::Test( argc, argv, vtkRenderWindow, threshold ) Set a vtkRenderWindow containing the desired scene. This is automatically rendered. vtkTesting::Test() automatically searches in argc and argv[] for a path a valid image with -V. If the test failed with the first image (foo.png) it checks if there are images of the form foo_N.png (where N=1,2,3...) and compare against them. This allows for multiple valid images.

Parameters
argcNumber of arguments.
argvArguments must(!) contain the term "-V Path/To/Valid/Image.png"
thresholdAllowed difference between two images. Default = 10.0 and was taken from VTK.
Returns
True if the images are equal regarding the threshold. False in all other cases.

Definition at line 230 of file mitkRenderingTestHelper.cpp.

References GetVtkRenderWindow(), and Render().

Referenced by createTextAnnotationWithLayouter(), mitkImageVtkMapper2DColorTest(), mitkImageVtkMapper2DLevelWindowTest(), mitkImageVtkMapper2DLookupTableTest(), mitkImageVtkMapper2DOpacityTest(), mitkImageVtkMapper2DOpacityTransferFunctionTest(), mitkImageVtkMapper2DResliceInterpolationPropertyTest(), mitkImageVtkMapper2DSwivelTest(), mitkImageVtkMapper2DTest(), mitkImageVtkMapper2DTransferFunctionTest(), mitkPlaneGeometryDataMapper2DTest(), mitkPointSetVtkMapper2DGlyphTypeTest(), mitkPointSetVtkMapper2DImageTest(), mitkPointSetVtkMapper2DTest(), mitkPointSetVtkMapper2DTransformedPointsTest(), mitkSceneIOCompatibilityTest(), mitkSurfaceDepthSortingTest(), and mitkSurfaceVtkMapper3DTest().

◆ GetDataStorage()

◆ GetVtkRenderer()

vtkRenderer * mitk::RenderingTestHelper::GetVtkRenderer ( )

Getter for the vtkRenderer.

Definition at line 215 of file mitkRenderingTestHelper.cpp.

References m_RenderWindow.

Referenced by mitkSurfaceVtkMapper3DTest(), mitkViewportRenderingTest(), and SaveAsPNG().

◆ GetVtkRenderWindow()

vtkRenderWindow * mitk::RenderingTestHelper::GetVtkRenderWindow ( )

◆ Initialize()

void mitk::RenderingTestHelper::Initialize ( int  width,
int  height,
AntiAliasing  antiAliasing = AntiAliasing::None 
)
protected

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

Parameters
widthHeight of renderwindow.
heightWidth of renderwindow.
renderingModeThe rendering mode.

Definition at line 60 of file mitkRenderingTestHelper.cpp.

References mitk::RenderingManager::GetInstance(), mitk::UIDGenerator::GetUID(), GetVtkRenderWindow(), m_DataStorage, m_RenderWindow, MITK_INFO, mitkThrowException, mitk::RenderWindow::New(), mitk::StandaloneDataStorage::New(), mitk::RenderingManager::SetAntiAliasing(), and SetMapperIDToRender2D().

Referenced by RenderingTestHelper().

◆ Render()

void mitk::RenderingTestHelper::Render ( )

◆ ReorientSlices()

void mitk::RenderingTestHelper::ReorientSlices ( mitk::Point3D  origin,
mitk::Vector3D  rotation 
)

Reorient the slice (e.g. rotation and translation like the swivel mode).

Definition at line 208 of file mitkRenderingTestHelper.cpp.

References mitk::BaseRenderer::GetInstance(), and m_RenderWindow.

Referenced by mitkImageVtkMapper2DResliceInterpolationPropertyTest(), and mitkImageVtkMapper2DSwivelTest().

◆ SaveAsPNG()

void mitk::RenderingTestHelper::SaveAsPNG ( std::string  fileName)

Method can be used to save a screenshot (e.g. reference screenshot as a .png file.

Parameters
fileNameThe filename of the new screenshot (including path).

Definition at line 245 of file mitkRenderingTestHelper.cpp.

References GetVtkRenderer().

Referenced by mitkViewportRenderingTest(), and SaveReferenceScreenShot().

◆ SaveReferenceScreenShot()

◆ SetAutomaticallyCloseRenderWindow()

void mitk::RenderingTestHelper::SetAutomaticallyCloseRenderWindow ( bool  automaticallyCloseRenderWindow)

SetStopRenderWindow Convenience method to make the renderwindow hold after rendering. Usefull for debugging.

Parameters
flagFlag indicating whether the renderwindow should automatically close (false, default) or stay open (true). Usefull for debugging.

Definition at line 263 of file mitkRenderingTestHelper.cpp.

References m_AutomaticallyCloseRenderWindow.

Referenced by createTextAnnotationWithLayouter(), and mitkViewportRenderingTest().

◆ SetImageProperty()

void mitk::RenderingTestHelper::SetImageProperty ( const char *  propertyKey,
mitk::BaseProperty property 
)

This method set the property of the member datastorage.

Parameters
propertySet a property for each image in the datastorage m_DataStorage. If you want to set the property for a single data node, use GetDataStorage() and set the property yourself for the destinct node.

Definition at line 220 of file mitkRenderingTestHelper.cpp.

References m_DataStorage, and mitk::NodePredicateDataType::New().

Referenced by mitkImageVtkMapper2DColorTest(), mitkImageVtkMapper2DLevelWindowTest(), mitkImageVtkMapper2DLookupTableTest(), mitkImageVtkMapper2DOpacityTest(), mitkImageVtkMapper2DOpacityTransferFunctionTest(), mitkImageVtkMapper2DResliceInterpolationPropertyTest(), and mitkImageVtkMapper2DTransferFunctionTest().

◆ SetInputFileNames()

void mitk::RenderingTestHelper::SetInputFileNames ( int  argc,
char *  argv[] 
)
protected

This method tries to parse the given argv for files (e.g. images) and load them into a member datastorage, in order to render it.

Parameters
argcNumber of parameters.
argvGiven parameters.

Definition at line 180 of file mitkRenderingTestHelper.cpp.

References AddToStorage().

Referenced by RenderingTestHelper().

◆ SetMapperID()

void mitk::RenderingTestHelper::SetMapperID ( mitk::BaseRenderer::StandardMapperSlot  id)

SetMapperID Change between Standard2D and 3D mappers.

Parameters
idEnum mitk::BaseRenderer::StandardMapperSlot which defines the mapper.

Definition at line 136 of file mitkRenderingTestHelper.cpp.

References m_RenderWindow.

Referenced by mitkSurfaceVtkMapper3DTest(), SetMapperIDToRender2D(), and SetMapperIDToRender3D().

◆ SetMapperIDToRender2D()

void mitk::RenderingTestHelper::SetMapperIDToRender2D ( )

SetMapperIDToRender2D Convenience method to render in a 2D renderwindow.

Definition at line 148 of file mitkRenderingTestHelper.cpp.

References SetMapperID(), and mitk::BaseRenderer::Standard2D.

Referenced by Initialize().

◆ SetMapperIDToRender3D()

void mitk::RenderingTestHelper::SetMapperIDToRender3D ( )

SetMapperIDToRender3D Convenience method to render in a 3D renderwindow.

Warning
Does not add helper objects like the image planes to render images in 3D.

Definition at line 141 of file mitkRenderingTestHelper.cpp.

References GetDataStorage(), mitk::RenderingManager::GetInstance(), mitk::RenderingManager::InitializeViews(), SetMapperID(), and mitk::BaseRenderer::Standard3D.

Referenced by mitkSurfaceDepthSortingTest().

◆ SetViewDirection()

Member Data Documentation

◆ m_AutomaticallyCloseRenderWindow

bool mitk::RenderingTestHelper::m_AutomaticallyCloseRenderWindow
protected

Definition at line 208 of file mitkRenderingTestHelper.h.

Referenced by Render(), and SetAutomaticallyCloseRenderWindow().

◆ m_DataStorage

mitk::DataStorage::Pointer mitk::RenderingTestHelper::m_DataStorage
protected

◆ m_RenderWindow

mitk::RenderWindow::Pointer mitk::RenderingTestHelper::m_RenderWindow
protected

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