Medical Imaging Interaction Toolkit  2016.11.0
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[], mitk::BaseRenderer::RenderingMode::Type renderingMode=mitk::BaseRenderer::RenderingMode::Standard)
 Generate a rendering test helper object including a render window of the size width * height (in pixel). More...
 
 RenderingTestHelper (int width, int height, mitk::BaseRenderer::RenderingMode::Type renderingMode=mitk::BaseRenderer::RenderingMode::Standard)
 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...
 
bool IsAdvancedOpenGL ()
 Returns true if the opengl context is compatible for advanced vtk effects. More...
 

Protected Member Functions

void Initialize (int width, int height, mitk::BaseRenderer::RenderingMode::Type renderingMode=mitk::BaseRenderer::RenderingMode::Standard)
 Initialize Internal method to initialize the renderwindow and set the datastorage. More...
 
void PrintGLInfo ()
 Prints the opengl information, e.g. version, vendor and extensions, This function can only be called after an opengl context is active. It only prints the context after the vtkRenderwindow is fully initialized. 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 32 of file mitkRenderingTestHelper.h.

Constructor & Destructor Documentation

mitk::RenderingTestHelper::RenderingTestHelper ( int  width,
int  height,
int  argc,
char *  argv[],
mitk::BaseRenderer::RenderingMode::Type  renderingMode = mitk::BaseRenderer::RenderingMode::Standard 
)

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().
renderingModeEnable Standard, Multisample or DepthPeeling

Definition at line 57 of file mitkRenderingTestHelper.cpp.

References Initialize(), and SetInputFileNames().

mitk::RenderingTestHelper::RenderingTestHelper ( int  width,
int  height,
mitk::BaseRenderer::RenderingMode::Type  renderingMode = mitk::BaseRenderer::RenderingMode::Standard 
)

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

Definition at line 49 of file mitkRenderingTestHelper.cpp.

References Initialize().

mitk::RenderingTestHelper::~RenderingTestHelper ( )

Default destructor

Definition at line 124 of file mitkRenderingTestHelper.cpp.

Member Function Documentation

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 302 of file mitkRenderingTestHelper.cpp.

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

Referenced by addPlaneToDataStorage(), and mitkSurfaceVtkMapper3DTexturedSphereTest().

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 288 of file mitkRenderingTestHelper.cpp.

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

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 245 of file mitkRenderingTestHelper.cpp.

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

vtkRenderer * mitk::RenderingTestHelper::GetVtkRenderer ( )

Getter for the vtkRenderer.

Definition at line 230 of file mitkRenderingTestHelper.cpp.

Referenced by mitkSurfaceVtkMapper3DTest(), and mitkViewportRenderingTest().

vtkRenderWindow * mitk::RenderingTestHelper::GetVtkRenderWindow ( )

Getter for the vtkRenderWindow which should be used to call vtkRegressionTestImage.

Definition at line 240 of file mitkRenderingTestHelper.cpp.

Referenced by mitkPointSetVtkMapper2DGlyphTypeTest(), mitkPointSetVtkMapper2DImageTest(), mitkPointSetVtkMapper2DTest(), and mitkViewportRenderingTest().

void mitk::RenderingTestHelper::Initialize ( int  width,
int  height,
mitk::BaseRenderer::RenderingMode::Type  renderingMode = mitk::BaseRenderer::RenderingMode::Standard 
)
protected

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

Parameters
widthHeight of renderwindow.
heightWidth of renderwindow.
renderingModeEnable Standard, Multisampling or Depthpeeling

Definition at line 65 of file mitkRenderingTestHelper.cpp.

References m_DataStorage, MITK_INFO, mitk::RenderWindow::New(), and mitk::StandaloneDataStorage::New().

Referenced by RenderingTestHelper().

bool mitk::RenderingTestHelper::IsAdvancedOpenGL ( )

Returns true if the opengl context is compatible for advanced vtk effects.

Definition at line 128 of file mitkRenderingTestHelper.cpp.

Referenced by mitkSurfaceDepthPeelingTest().

void mitk::RenderingTestHelper::PrintGLInfo ( )
protected

Prints the opengl information, e.g. version, vendor and extensions, This function can only be called after an opengl context is active. It only prints the context after the vtkRenderwindow is fully initialized.

Definition at line 136 of file mitkRenderingTestHelper.cpp.

References MITK_INFO.

void mitk::RenderingTestHelper::Render ( )

Render everything into an mitkRenderWindow. Call SetViewDirection() and SetProperty() before this method.

Definition at line 168 of file mitkRenderingTestHelper.cpp.

References m_DataStorage, and MITK_ERROR.

Referenced by mitkImageVtkMapper2DResliceInterpolationPropertyTest(), and mitkViewportRenderingTest().

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 223 of file mitkRenderingTestHelper.cpp.

References mitk::BaseRenderer::GetInstance().

Referenced by mitkImageVtkMapper2DResliceInterpolationPropertyTest(), and mitkImageVtkMapper2DSwivelTest().

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 260 of file mitkRenderingTestHelper.cpp.

References mitk::New().

Referenced by mitkViewportRenderingTest().

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 278 of file mitkRenderingTestHelper.cpp.

Referenced by mitkViewportRenderingTest().

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 235 of file mitkRenderingTestHelper.cpp.

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

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

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 195 of file mitkRenderingTestHelper.cpp.

Referenced by RenderingTestHelper().

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 151 of file mitkRenderingTestHelper.cpp.

Referenced by mitkSurfaceVtkMapper3DTest(), and mitkSurfaceVtkMapper3DTexturedSphereTest().

void mitk::RenderingTestHelper::SetMapperIDToRender2D ( )

SetMapperIDToRender2D Convenience method to render in a 2D renderwindow.

Definition at line 163 of file mitkRenderingTestHelper.cpp.

References mitk::BaseRenderer::Standard2D.

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 156 of file mitkRenderingTestHelper.cpp.

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

Referenced by mitkSurfaceDepthPeelingTest(), and mitkSurfaceDepthSortingTest().

Member Data Documentation

bool mitk::RenderingTestHelper::m_AutomaticallyCloseRenderWindow
protected

Definition at line 221 of file mitkRenderingTestHelper.h.

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

Definition at line 219 of file mitkRenderingTestHelper.h.

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

Definition at line 218 of file mitkRenderingTestHelper.h.


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