VTK  9.3.20240422
Macros
WidgetTestingMacros.h File Reference
#include "vtkCamera.h"
#include "vtkDebugLeaks.h"
#include "vtkMath.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkSmartPointer.h"
#include <vtkAbstractTransform.h>
#include <vtkActor.h>
#include <vtkAssemblyPath.h>
#include <vtkFollower.h>
#include <vtkInformation.h>
#include <vtkLineWidget2.h>
#include <vtkMatrix4x4.h>
#include <vtkPointHandleRepresentation2D.h>
#include <vtkPointPlacer.h>
#include <vtkPolyData.h>
#include <vtkProp.h>
#include <vtkPropCollection.h>
#include <vtkProperty.h>
#include <vtkProperty2D.h>
Include dependency graph for WidgetTestingMacros.h:

Go to the source code of this file.

Macros

#define EXERCISE_BASIC_OBJECT_METHODS(object)
 tests basic vtkObject methods
 
#define TEST_SET_GET_BOOLEAN(object, variable)
 test object by calling Set on the variable with false, true, 0, 1, On, Off
 
#define TEST_SET_GET_INT(object, variable, value)
 test an integer variable on the object by setting it to input value using Set, and testing it via the Get
 
#define TEST_SET_GET_INT_RANGE(object, variable, min, max)
 Test an integer variable on object over the range, calls test set get in with min - epsilon, min, min + epsilon, (min+max)/2, max - epsilon, max, max + epsilon, where first and last test should report errors epsilon defined as 1.
 
#define TEST_SET_GET_DOUBLE(object, variable, value)
 test a double variable on the object by setting it to input value using Set, and testing it via the Get
 
#define TEST_SET_GET_DOUBLE_RANGE(object, variable, min, max)
 Test a double variable on object over the range, calls test set get in with min - epsilon, min, min + epsilon, (min+max)/2, max - epsilon, max, max + epsilon, where first and last test should report errors epsilon set to 1.0.
 
#define TEST_SET_GET_VECTOR3_DOUBLE(object, variable, x, y, z)
 test a vector variable on the object by setting it to a the values x, y, z passed in using Set, and testing it via the Get
 
#define TEST_SET_GET_VECTOR2(object, variable, x, y)
 test a vector variable on the object by setting it to a the values x, y passed in using Set, and testing it via the Get
 
#define TEST_SET_GET_VECTOR2_INT_RANGE(object, variable, min, max)
 test an integer vector2 variable on the object over the range, calls test set get in with min - epsilon, min, min + epsilon, (min+max)/2, max - epsilon, max, max + epsilon, where first and last test should report errors.
 
#define TEST_SET_GET_VECTOR2_DOUBLE_RANGE(object, variable, min, max)
 test a double vector2 variable on the object over the range, calls test set get in with min - epsilon, min, min + epsilon, (min+max)/2, max - epsilon, max, max + epsilon, where first and last test should report errors.
 
#define TEST_SET_GET_VECTOR3_DOUBLE_RANGE(object, variable, min, max)
 Test a double vector variable on object over the range, calls test set get in with min - epsilon, min, min + epsilon, (min+max)/2, max - epsilon, max, max + epsilon, where first and last test should report errors.
 
#define TEST_SET_GET_STRING(object, variable)
 test a string variable on the object by calling Set/Get
 
#define TEST_SET_GET_CHAR(object, variable)
 test a char variable on the object by calling Set/Get
 
#define EXERCISE_BASIC_INTERACTOR_OBSERVER_METHODS(object)
 test vtkInteractorObserver methods
 
#define EXERCISE_BASIC_ABSTRACT_METHODS(object)
 test vtkAbstractWidget methods
 
#define EXERCISE_BASIC_BORDER_METHODS(object)
 test vtkBorderWidget methods
 
#define EXERCISE_BASIC_HOVER_METHODS(object)
 test vtkHoverWidget methods, timer duration is clamped so range macro will fail
 
#define EXERCISE_BASIC_PROP_METHODS(className, object)
 test vtkProp methods
 
#define NOT_DEFINED_CONSUMERS_FAIL()
 
#define EXERCISE_BASIC_REPRESENTATION_METHODS(className, object)
 test vtkWidgetRepresentation methods
 
#define EXERCISE_BASIC_ANGLE_REPRESENTATION_METHODS(className, object)
 test vtkAngleRepresentation methods
 
#define EXERCISE_BASIC_BORDER_REPRESENTATION_METHODS(className, object)
 test vtkBorderRepresentation methods
 
#define TEST_SET_GET_PROPERTY(object, variable)
 test objects that have Property and SelectedProperty set/get, with vtkProperty
 
#define EXERCISE_BASIC_HANDLE_REPRESENTATION_METHODS(className, object)
 test vtkHandleRepresentation methods these don't work well in isolation, seg faults when try to get/set display and world positions.
 
#define EXERCISE_BASIC_ABSTRACT_POLYGONAL_HANDLE_REPRESENTATION3D_METHODS(className, object)
 test vtkAbstractPolygonalHandleRepresentation3D methods
 

Macro Definition Documentation

◆ EXERCISE_BASIC_OBJECT_METHODS

#define EXERCISE_BASIC_OBJECT_METHODS (   object)
Value:
do \
{ \
if (object == nullptr) \
{ \
std::cerr << "EXERCISE_BASIC_OBJECT_METHODS( with nullptr object )" << std::endl; \
return EXIT_FAILURE; \
} \
object->Print(std::cout); \
std::cout << "Name of Class = " << object->GetClassName() << std::endl; \
std::cout << "Name of Superclass = " << object->Superclass::GetClassName() << std::endl; \
} while (false)

tests basic vtkObject methods

Definition at line 29 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_BOOLEAN

#define TEST_SET_GET_BOOLEAN (   object,
  variable 
)

test object by calling Set on the variable with false, true, 0, 1, On, Off

Definition at line 43 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_INT

#define TEST_SET_GET_INT (   object,
  variable,
  value 
)
Value:
do \
{ \
object->Set##variable(value); \
if (object->Get##variable() != value) \
{ \
std::cerr << "Error in Set/Get" #variable << " using value " << value << std::endl; \
return EXIT_FAILURE; \
} \
} while (false)

test an integer variable on the object by setting it to input value using Set, and testing it via the Get

Definition at line 79 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_INT_RANGE

#define TEST_SET_GET_INT_RANGE (   object,
  variable,
  min,
  max 
)
Value:
do \
{ \
int epsilon = 1; \
int val = min - epsilon; \
TEST_SET_GET_INT(object, variable, val); \
val = min; \
TEST_SET_GET_INT(object, variable, val); \
val = min + epsilon; \
TEST_SET_GET_INT(object, variable, val); \
val = (min + max) / 2; \
TEST_SET_GET_INT(object, variable, val); \
val = max - epsilon; \
TEST_SET_GET_INT(object, variable, val); \
val = max; \
TEST_SET_GET_INT(object, variable, val); \
val = max + epsilon; \
TEST_SET_GET_INT(object, variable, val); \
} while (false)
#define max(a, b)

Test an integer variable on object over the range, calls test set get in with min - epsilon, min, min + epsilon, (min+max)/2, max - epsilon, max, max + epsilon, where first and last test should report errors epsilon defined as 1.

Definition at line 94 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_DOUBLE

#define TEST_SET_GET_DOUBLE (   object,
  variable,
  value 
)
Value:
do \
{ \
object->Set##variable(value); \
if (object->Get##variable() != value) \
{ \
std::cerr << "Error in Set/Get" #variable << " using value '" << value << "', got '" \
<< object->Get##variable() << "'" << std::endl; \
return EXIT_FAILURE; \
} \
} while (false)

test a double variable on the object by setting it to input value using Set, and testing it via the Get

Definition at line 116 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_DOUBLE_RANGE

#define TEST_SET_GET_DOUBLE_RANGE (   object,
  variable,
  min,
  max 
)
Value:
do \
{ \
double epsilon = 1.0; \
double val = min - epsilon; \
TEST_SET_GET_DOUBLE(object, variable, val); \
val = min; \
TEST_SET_GET_DOUBLE(object, variable, val); \
val = min + epsilon; \
TEST_SET_GET_DOUBLE(object, variable, val); \
val = (min + max) / 2.0; \
TEST_SET_GET_DOUBLE(object, variable, val); \
val = max - epsilon; \
TEST_SET_GET_DOUBLE(object, variable, val); \
val = max; \
TEST_SET_GET_DOUBLE(object, variable, val); \
val = max + epsilon; \
TEST_SET_GET_DOUBLE(object, variable, val); \
} while (false)

Test a double variable on object over the range, calls test set get in with min - epsilon, min, min + epsilon, (min+max)/2, max - epsilon, max, max + epsilon, where first and last test should report errors epsilon set to 1.0.

Definition at line 132 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_VECTOR3_DOUBLE

#define TEST_SET_GET_VECTOR3_DOUBLE (   object,
  variable,
  x,
  y,
 
)
Value:
do \
{ \
object->Set##variable(x, y, z); \
double* val = object->Get##variable(); \
if (val == nullptr || val[0] != x || val[1] != y || val[2] != z) \
{ \
std::cerr << "Error in Set/Get" #variable << std::endl; \
return EXIT_FAILURE; \
} \
} while (false)

test a vector variable on the object by setting it to a the values x, y, z passed in using Set, and testing it via the Get

Definition at line 154 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_VECTOR2

#define TEST_SET_GET_VECTOR2 (   object,
  variable,
  x,
 
)
Value:
do \
{ \
object->Set##variable(x, y); \
int* val = object->Get##variable(); \
if (val == nullptr || val[0] != x || val[1] != y) \
{ \
std::cerr << "Error in Set/Get" #variable << std::endl; \
return EXIT_FAILURE; \
} \
} while (false)

test a vector variable on the object by setting it to a the values x, y passed in using Set, and testing it via the Get

Definition at line 168 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_VECTOR2_INT_RANGE

#define TEST_SET_GET_VECTOR2_INT_RANGE (   object,
  variable,
  min,
  max 
)
Value:
do \
{ \
int epsilon = 1; \
TEST_SET_GET_VECTOR2(object, variable, min - epsilon, min - epsilon); \
TEST_SET_GET_VECTOR2(object, variable, min, min); \
TEST_SET_GET_VECTOR2(object, variable, min + epsilon, min + epsilon); \
int half = (min + max / 2); \
TEST_SET_GET_VECTOR2(object, variable, half, half); \
TEST_SET_GET_VECTOR2(object, variable, max - epsilon, max - epsilon); \
TEST_SET_GET_VECTOR2(object, variable, max, max); \
TEST_SET_GET_VECTOR2(object, variable, max + epsilon, max + epsilon); \
} while (false)

test an integer vector2 variable on the object over the range, calls test set get in with min - epsilon, min, min + epsilon, (min+max)/2, max - epsilon, max, max + epsilon, where first and last test should report errors.

For now all three elements are set to the same thing each time. epsilon set to 1

Definition at line 185 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_VECTOR2_DOUBLE_RANGE

#define TEST_SET_GET_VECTOR2_DOUBLE_RANGE (   object,
  variable,
  min,
  max 
)
Value:
do \
{ \
double epsilon = 1.0; \
TEST_SET_GET_VECTOR2(object, variable, min - epsilon, min - epsilon); \
TEST_SET_GET_VECTOR2(object, variable, min, min); \
TEST_SET_GET_VECTOR2(object, variable, min + epsilon, min + epsilon); \
double half = (min + max / 2.0); \
TEST_SET_GET_VECTOR2(object, variable, half, half); \
TEST_SET_GET_VECTOR2(object, variable, max - epsilon, max - epsilon); \
TEST_SET_GET_VECTOR2(object, variable, max, max); \
TEST_SET_GET_VECTOR2(object, variable, max + epsilon, max + epsilon); \
} while (false)

test a double vector2 variable on the object over the range, calls test set get in with min - epsilon, min, min + epsilon, (min+max)/2, max - epsilon, max, max + epsilon, where first and last test should report errors.

For now all three elements are set to the same thing each time. epsilon set to 1.0

Definition at line 204 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_VECTOR3_DOUBLE_RANGE

#define TEST_SET_GET_VECTOR3_DOUBLE_RANGE (   object,
  variable,
  min,
  max 
)
Value:
do \
{ \
double epsilon = 1.0; \
TEST_SET_GET_VECTOR3_DOUBLE(object, variable, min - epsilon, min - epsilon, min - epsilon); \
TEST_SET_GET_VECTOR3_DOUBLE(object, variable, min, min, min); \
TEST_SET_GET_VECTOR3_DOUBLE(object, variable, min + epsilon, min + epsilon, min + epsilon); \
double half = (min + max / 2.0); \
TEST_SET_GET_VECTOR3_DOUBLE(object, variable, half, half, half); \
TEST_SET_GET_VECTOR3_DOUBLE(object, variable, max - epsilon, max - epsilon, max - epsilon); \
TEST_SET_GET_VECTOR3_DOUBLE(object, variable, max, max, max); \
TEST_SET_GET_VECTOR3_DOUBLE(object, variable, max + epsilon, max + epsilon, max + epsilon); \
} while (false)

Test a double vector variable on object over the range, calls test set get in with min - epsilon, min, min + epsilon, (min+max)/2, max - epsilon, max, max + epsilon, where first and last test should report errors.

For now all three elements are set to the same thing each time. epsilon set to 1.0

Definition at line 223 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_STRING

#define TEST_SET_GET_STRING (   object,
  variable 
)

test a string variable on the object by calling Set/Get

Definition at line 238 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_CHAR

#define TEST_SET_GET_CHAR (   object,
  variable 
)
Value:
do \
{ \
const char originalChar = object->Get##variable(); \
object->Set##variable('t'); \
if (object->Get##variable() != 't') \
{ \
std::cerr << "Error in Set/Get" #variable << " with a literal 't'" << std::endl; \
return EXIT_FAILURE; \
} \
object->Set##variable('3'); \
if (object->Get##variable() != '3') \
{ \
std::cerr << "Error in Set/Get" #variable << " with a literal '3'" << std::endl; \
return EXIT_FAILURE; \
} \
object->Set##variable(originalChar); \
} while (false)

test a char variable on the object by calling Set/Get

Definition at line 278 of file WidgetTestingMacros.h.

◆ EXERCISE_BASIC_INTERACTOR_OBSERVER_METHODS

#define EXERCISE_BASIC_INTERACTOR_OBSERVER_METHODS (   object)

test vtkInteractorObserver methods

Definition at line 298 of file WidgetTestingMacros.h.

◆ EXERCISE_BASIC_ABSTRACT_METHODS

#define EXERCISE_BASIC_ABSTRACT_METHODS (   object)
Value:
do \
{ \
EXERCISE_BASIC_INTERACTOR_OBSERVER_METHODS(object); \
TEST_SET_GET_BOOLEAN(object, ProcessEvents); \
if (object->GetEventTranslator() == nullptr) \
{ \
std::cerr << "Error getting event translator, is null." << std::endl; \
return EXIT_FAILURE; \
} \
object->CreateDefaultRepresentation(); \
object->Render(); \
if (object->GetParent() != nullptr) \
{ \
std::cerr << "Error, parent is not null." << std::endl; \
return EXIT_FAILURE; \
} \
} while (false)

test vtkAbstractWidget methods

Definition at line 392 of file WidgetTestingMacros.h.

◆ EXERCISE_BASIC_BORDER_METHODS

#define EXERCISE_BASIC_BORDER_METHODS (   object)
Value:
do \
{ \
EXERCISE_BASIC_ABSTRACT_METHODS(object); \
TEST_SET_GET_BOOLEAN(object, Selectable); \
TEST_SET_GET_BOOLEAN(object, Resizable); \
} while (false)

test vtkBorderWidget methods

Definition at line 412 of file WidgetTestingMacros.h.

◆ EXERCISE_BASIC_HOVER_METHODS

#define EXERCISE_BASIC_HOVER_METHODS (   object)
Value:
do \
{ \
EXERCISE_BASIC_ABSTRACT_METHODS(object); \
TEST_SET_GET_INT(object, TimerDuration, 1); \
TEST_SET_GET_INT(object, TimerDuration, 2); \
TEST_SET_GET_INT(object, TimerDuration, 50000); \
TEST_SET_GET_INT(object, TimerDuration, 99999); \
TEST_SET_GET_INT(object, TimerDuration, 100000); \
} while (false)

test vtkHoverWidget methods, timer duration is clamped so range macro will fail

Definition at line 421 of file WidgetTestingMacros.h.

◆ EXERCISE_BASIC_PROP_METHODS

#define EXERCISE_BASIC_PROP_METHODS (   className,
  object 
)

test vtkProp methods

Definition at line 433 of file WidgetTestingMacros.h.

◆ NOT_DEFINED_CONSUMERS_FAIL

#define NOT_DEFINED_CONSUMERS_FAIL ( )
Value:
do \
{ \
object->AddConsumer(actor); \
if (object->IsConsumer(actor) != 1) \
{ \
std::cerr << "Failed IsConsumer check for a valid consumer." << std::endl; \
return EXIT_FAILURE; \
} \
if (object->IsConsumer(nullptr) != 0) \
{ \
std::cerr << "Failed IsConsumer check for a null consumer." << std::endl; \
return EXIT_FAILURE; \
} \
vtkSmartPointer<vtkActor> actor2 = object->GetConsumer(0); \
if (actor2 != actor) \
{ \
std::cerr << "Failed get consumer check for a valid consumer." << std::endl; \
return EXIT_FAILURE; \
} \
object->RemoveConsumer(actor); \
actor2 = object->GetConsumer(0); \
if (actor2 != nullptr) \
{ \
std::cerr << "Failed get consumer check for an invalid consumer number 0." << std::endl; \
return EXIT_FAILURE; \
} \
} while (false)
Hold a reference to a vtkObjectBase instance.
static vtkSmartPointer< T > New()
Create an instance of a VTK object.

Definition at line 493 of file WidgetTestingMacros.h.

◆ EXERCISE_BASIC_REPRESENTATION_METHODS

#define EXERCISE_BASIC_REPRESENTATION_METHODS (   className,
  object 
)

test vtkWidgetRepresentation methods

Definition at line 528 of file WidgetTestingMacros.h.

◆ EXERCISE_BASIC_ANGLE_REPRESENTATION_METHODS

#define EXERCISE_BASIC_ANGLE_REPRESENTATION_METHODS (   className,
  object 
)

test vtkAngleRepresentation methods

Definition at line 582 of file WidgetTestingMacros.h.

◆ EXERCISE_BASIC_BORDER_REPRESENTATION_METHODS

#define EXERCISE_BASIC_BORDER_REPRESENTATION_METHODS (   className,
  object 
)

test vtkBorderRepresentation methods

Definition at line 661 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_PROPERTY

#define TEST_SET_GET_PROPERTY (   object,
  variable 
)
Value:
do \
{ \
double colour[3] = { 0.2, 0.3, 0.4 }; \
prop1->SetColor(colour); \
node1->Set##variable(prop1); \
vtkSmartPointer<vtkProperty> prop = node1->Get##variable(); \
if (!prop) \
{ \
std::cerr << "Got null variable property back after setting it!" << std::endl; \
return EXIT_FAILURE; \
} \
double* col = prop->GetColor(); \
if (!col) \
{ \
std::cerr << "Got null colour back!" << std::endl; \
return EXIT_FAILURE; \
} \
if (col[0] != colour[0] || col[1] != colour[1] || col[2] != colour[2]) \
{ \
std::cerr << "Got wrong colour back after setting it! Expected " << colour[0] << ", " \
<< colour[1] << ", " << colour[2] << ", but got " << col[0] << ", " << col[1] \
<< ", " << col[2] << std::endl; \
return EXIT_FAILURE; \
} \
} while (false)
T * Get() const noexcept
Get the contained pointer.

test objects that have Property and SelectedProperty set/get, with vtkProperty

Definition at line 763 of file WidgetTestingMacros.h.

◆ EXERCISE_BASIC_HANDLE_REPRESENTATION_METHODS

#define EXERCISE_BASIC_HANDLE_REPRESENTATION_METHODS (   className,
  object 
)

test vtkHandleRepresentation methods these don't work well in isolation, seg faults when try to get/set display and world positions.

Definition at line 794 of file WidgetTestingMacros.h.

◆ EXERCISE_BASIC_ABSTRACT_POLYGONAL_HANDLE_REPRESENTATION3D_METHODS

#define EXERCISE_BASIC_ABSTRACT_POLYGONAL_HANDLE_REPRESENTATION3D_METHODS (   className,
  object 
)

test vtkAbstractPolygonalHandleRepresentation3D methods

Definition at line 889 of file WidgetTestingMacros.h.