Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkVtkWidgetRenderingTest.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "mitkVtkWidgetRendering.h"
18 #include <vtkRenderWindow.h>
19 #include <vtkScalarBarWidget.h>
20 
21 #include "mitkTestingMacros.h"
22 
23 #include <iostream>
24 
34 int mitkVtkWidgetRenderingTest(int /* argc */, char * /*argv*/ [])
35 {
36  // always start with this!
37  MITK_TEST_BEGIN("mitkVTKWidgetRenderingTest")
38 
39  // Test: instantiation
41  MITK_TEST_CONDITION_REQUIRED(widgetRendering.IsNotNull(), "Testing instantiation")
42 
43  // Test: Create and set vtkRenderWindow
44  vtkRenderWindow *renderWindow = vtkRenderWindow::New();
45  // mitk::VtkPropRenderer::Pointer propRenderer = mitk::VtkPropRenderer::New( "the renderer", renderWindow );
46  // propRenderer->SetMapperID(2);
47  widgetRendering->SetRenderWindow(renderWindow);
48  MITK_TEST_CONDITION_REQUIRED(widgetRendering->GetRenderWindow() == renderWindow, "Setting vtkRenderWindow...")
49 
50  // Test: Try to enable before widget has been set (should stay disabled)
51  widgetRendering->Enable();
52  MITK_TEST_CONDITION(!widgetRendering->IsEnabled(), "Trying to enable widget rendering before setting widget")
53  widgetRendering->Disable();
54 
55  // Test: Retrieve widget before it has been set (should return NULL)
56  MITK_TEST_CONDITION(widgetRendering->GetVtkWidget() == nullptr, "Trying to retrieve widget before it has been set")
57 
58  // Test: Create vtkWidget instance (vtkScalarWidget) and add it
59  vtkScalarBarWidget *scalarBarWidget = vtkScalarBarWidget::New();
60  widgetRendering->SetVtkWidget(scalarBarWidget);
61  MITK_TEST_CONDITION(widgetRendering->GetVtkWidget() == scalarBarWidget, "Retrieving widget after it has been set")
62 
63  // Test: Try to enable widget rendering (should work now)
64  widgetRendering->Enable();
65  MITK_TEST_CONDITION(widgetRendering->IsEnabled(), "Enabling widget rendering")
66 
67  // Test: Try to disable widget rendering (should be disabled)
68  widgetRendering->Disable();
69  MITK_TEST_CONDITION(!widgetRendering->IsEnabled(), "Disabling widget rendering")
70 
71  // Clean up
72  scalarBarWidget->Delete();
73  renderWindow->Delete();
74 
75  // write your own tests here and use the macros from mitkTestingMacros.h !!!
76  // do not write to std::cout and do not return from this function yourself!
77 
78  // always end with this!
80 }
int mitkVtkWidgetRenderingTest(int, char *[])
#define MITK_TEST_CONDITION_REQUIRED(COND, MSG)
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
#define MITK_TEST_CONDITION(COND, MSG)
and MITK_TEST_END()
static Pointer New()
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.