VTK  9.1.0
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 More...
 
#define TEST_SET_GET_BOOLEAN(object, variable)
 test object by calling Set on the variable with false, true, 0, 1, On, Off More...
 
#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 More...
 
#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. More...
 
#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 More...
 
#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. More...
 
#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 More...
 
#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 More...
 
#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. More...
 
#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. More...
 
#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. More...
 
#define TEST_SET_GET_STRING(object, variable)
 test a string variable on the object by calling Set/Get More...
 
#define TEST_SET_GET_CHAR(object, variable)
 test a char variable on the object by calling Set/Get More...
 
#define EXERCISE_BASIC_INTERACTOR_OBSERVER_METHODS(object)
 test vtkInteractorObserver methods More...
 
#define EXERCISE_BASIC_ABSTRACT_METHODS(object)
 test vtkAbstractWidget methods More...
 
#define EXERCISE_BASIC_BORDER_METHODS(object)
 test vtkBorderWidget methods More...
 
#define EXERCISE_BASIC_HOVER_METHODS(object)
 test vtkHoverWidget methods, timer duration is clamped so range macro will fail More...
 
#define EXERCISE_BASIC_PROP_METHODS(className, object)
 test vtkProp methods More...
 
#define NOT_DEFINED_CONSUMERS_FAIL()
 
#define EXERCISE_BASIC_REPRESENTATION_METHODS(className, object)
 test vtkWidgetRepresentation methods More...
 
#define EXERCISE_BASIC_ANGLE_REPRESENTATION_METHODS(className, object)
 test vtkAngleRepresentation methods More...
 
#define EXERCISE_BASIC_BORDER_REPRESENTATION_METHODS(className, object)
 test vtkBorderRepresentation methods More...
 
#define EXERCISE_BASIC_IMPLICIT_PLANE_REPRESENTATION_METHODS(className, object)
 test vtkAngleRepresentation methods More...
 
#define TEST_SET_GET_PROPERTY(object, variable)
 test objects that have Property and SelectedProperty set/get, with vtkProperty More...
 
#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. More...
 
#define EXERCISE_BASIC_ABSTRACT_POLYGONAL_HANDLE_REPRESENTATION3D_METHODS(className, object)
 test vtkAbstractPolygonalHandleRepresentation3D methods More...
 

Macro Definition Documentation

◆ EXERCISE_BASIC_OBJECT_METHODS

#define EXERCISE_BASIC_OBJECT_METHODS (   object)
Value:
{ \
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; \
}

tests basic vtkObject methods

Definition at line 27 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_BOOLEAN

#define TEST_SET_GET_BOOLEAN (   object,
  variable 
)
Value:
object->Set##variable(false); \
object->Set##variable(true); \
if (object->Get##variable() != 1) \
{ \
std::cerr << "Error in Set/Get" #variable << ", Get" #variable << " is " \
<< object->Get##variable() << " instead of 1" << std::endl; \
return EXIT_FAILURE; \
} \
object->Set##variable(false); \
if (object->Get##variable() != 0) \
{ \
std::cerr << "Error in Set/Get" #variable << ", Get" #variable << " is " \
<< object->Get##variable() << " instead of 0" << std::endl; \
return EXIT_FAILURE; \
} \
object->variable##On(); \
if (object->Get##variable() != 1) \
{ \
std::cerr << "Error in On/Get" #variable << ", Get" #variable << " is " \
<< object->Get##variable() << " instead of 1" << std::endl; \
return EXIT_FAILURE; \
} \
object->variable##Off(); \
if (object->Get##variable() != 0) \
{ \
std::cerr << "Error in Off/Get" #variable << ", Get" #variable << " is " \
<< object->Get##variable() << " instead of 0" << std::endl; \
return EXIT_FAILURE; \
}

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

Definition at line 40 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_INT

#define TEST_SET_GET_INT (   object,
  variable,
  value 
)
Value:
{ \
object->Set##variable(value); \
if (object->Get##variable() != value) \
{ \
std::cerr << "Error in Set/Get" #variable << " using value " << value << std::endl; \
return EXIT_FAILURE; \
} \
}
@ value
Definition: vtkX3D.h:226

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

Definition at line 73 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_INT_RANGE

#define TEST_SET_GET_INT_RANGE (   object,
  variable,
  min,
  max 
)
Value:
{ \
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); \
}
#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 87 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_DOUBLE

#define TEST_SET_GET_DOUBLE (   object,
  variable,
  value 
)
Value:
{ \
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; \
} \
}

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

Definition at line 108 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_DOUBLE_RANGE

#define TEST_SET_GET_DOUBLE_RANGE (   object,
  variable,
  min,
  max 
)
Value:
{ \
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); \
}

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 123 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_VECTOR3_DOUBLE

#define TEST_SET_GET_VECTOR3_DOUBLE (   object,
  variable,
  x,
  y,
 
)
Value:
{ \
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; \
} \
}

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 144 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_VECTOR2

#define TEST_SET_GET_VECTOR2 (   object,
  variable,
  x,
 
)
Value:
{ \
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; \
} \
}

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 157 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_VECTOR2_INT_RANGE

#define TEST_SET_GET_VECTOR2_INT_RANGE (   object,
  variable,
  min,
  max 
)
Value:
{ \
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); \
}

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 173 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_VECTOR2_DOUBLE_RANGE

#define TEST_SET_GET_VECTOR2_DOUBLE_RANGE (   object,
  variable,
  min,
  max 
)
Value:
{ \
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); \
}

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 191 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_VECTOR3_DOUBLE_RANGE

#define TEST_SET_GET_VECTOR3_DOUBLE_RANGE (   object,
  variable,
  min,
  max 
)
Value:
{ \
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); \
}

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 209 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 223 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_CHAR

#define TEST_SET_GET_CHAR (   object,
  variable 
)
Value:
{ \
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); \
}

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

Definition at line 262 of file WidgetTestingMacros.h.

◆ EXERCISE_BASIC_INTERACTOR_OBSERVER_METHODS

#define EXERCISE_BASIC_INTERACTOR_OBSERVER_METHODS (   object)

test vtkInteractorObserver methods

Definition at line 281 of file WidgetTestingMacros.h.

◆ EXERCISE_BASIC_ABSTRACT_METHODS

#define EXERCISE_BASIC_ABSTRACT_METHODS (   object)
Value:
{ \
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; \
} \
}

test vtkAbstractWidget methods

Definition at line 374 of file WidgetTestingMacros.h.

◆ EXERCISE_BASIC_BORDER_METHODS

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

test vtkBorderWidget methods

Definition at line 393 of file WidgetTestingMacros.h.

◆ EXERCISE_BASIC_HOVER_METHODS

#define EXERCISE_BASIC_HOVER_METHODS (   object)
Value:
{ \
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); \
}

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

Definition at line 401 of file WidgetTestingMacros.h.

◆ EXERCISE_BASIC_PROP_METHODS

#define EXERCISE_BASIC_PROP_METHODS (   className,
  object 
)

test vtkProp methods

Definition at line 412 of file WidgetTestingMacros.h.

◆ NOT_DEFINED_CONSUMERS_FAIL

#define NOT_DEFINED_CONSUMERS_FAIL ( )
Value:
{ \
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); \
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; \
} \
}
static vtkSmartPointer< T > New()
Create an instance of a VTK object.

Definition at line 471 of file WidgetTestingMacros.h.

◆ EXERCISE_BASIC_REPRESENTATION_METHODS

#define EXERCISE_BASIC_REPRESENTATION_METHODS (   className,
  object 
)

test vtkWidgetRepresentation methods

Definition at line 501 of file WidgetTestingMacros.h.

◆ EXERCISE_BASIC_ANGLE_REPRESENTATION_METHODS

#define EXERCISE_BASIC_ANGLE_REPRESENTATION_METHODS (   className,
  object 
)

test vtkAngleRepresentation methods

Definition at line 557 of file WidgetTestingMacros.h.

◆ EXERCISE_BASIC_BORDER_REPRESENTATION_METHODS

#define EXERCISE_BASIC_BORDER_REPRESENTATION_METHODS (   className,
  object 
)

test vtkBorderRepresentation methods

Definition at line 635 of file WidgetTestingMacros.h.

◆ EXERCISE_BASIC_IMPLICIT_PLANE_REPRESENTATION_METHODS

#define EXERCISE_BASIC_IMPLICIT_PLANE_REPRESENTATION_METHODS (   className,
  object 
)
Value:
{ \
EXERCISE_BASIC_REPRESENTATION_METHODS(className, object); \
TEST_SET_GET_VECTOR3_DOUBLE_RANGE(node1, Origin, -100, 100); \
TEST_SET_GET_VECTOR3_DOUBLE_RANGE(node1, Normal, -1, 1); \
TEST_SET_GET_BOOLEAN(node1, NormalToXAxis); \
TEST_SET_GET_BOOLEAN(node1, NormalToYAxis); \
TEST_SET_GET_BOOLEAN(node1, NormalToZAxis); \
TEST_SET_GET_BOOLEAN(node1, Tubing); \
TEST_SET_GET_BOOLEAN(node1, DrawPlane); \
TEST_SET_GET_BOOLEAN(node1, OutlineTranslation); \
TEST_SET_GET_BOOLEAN(node1, OutsideBounds); \
TEST_SET_GET_BOOLEAN(node1, ScaleEnabled); \
}
#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,...
@ Normal
Definition: vtkX3D.h:51

test vtkAngleRepresentation methods

Definition at line 736 of file WidgetTestingMacros.h.

◆ TEST_SET_GET_PROPERTY

#define TEST_SET_GET_PROPERTY (   object,
  variable 
)
Value:
{ \
vtkSmartPointer<vtkProperty> prop1 = vtkSmartPointer<vtkProperty>::New(); \
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; \
} \
}

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

Definition at line 753 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 783 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 877 of file WidgetTestingMacros.h.