Go to the documentation of this file. 1 #ifndef vtkWidgetTestingMacros_h 2 #define vtkWidgetTestingMacros_h 27 #define EXERCISE_BASIC_OBJECT_METHODS( object ) \ 29 if ( object == nullptr ) \ 31 std::cerr << "EXERCISE_BASIC_OBJECT_METHODS( with nullptr object )" << std::endl; \ 32 return EXIT_FAILURE; \ 34 object->Print( std::cout ); \ 35 std::cout << "Name of Class = " << object->GetClassName() << std::endl; \ 36 std::cout << "Name of Superclass = " << object->Superclass::GetClassName() << std::endl; \ 40 #define TEST_SET_GET_BOOLEAN( object, variable ) \ 41 object->Set##variable( false ); \ 42 object->Set##variable( true ); \ 43 if( object->Get##variable() != 1 ) \ 45 std::cerr << "Error in Set/Get"#variable << ", Get"#variable << " is " << object->Get##variable() << " instead of 1" << std::endl; \ 46 return EXIT_FAILURE; \ 48 object->Set##variable( false ); \ 49 if( object->Get##variable() != 0 ) \ 51 std::cerr << "Error in Set/Get"#variable << ", Get"#variable << " is " << object->Get##variable() << " instead of 0" << std::endl; \ 52 return EXIT_FAILURE; \ 54 object->variable##On(); \ 55 if( object->Get##variable() != 1 ) \ 57 std::cerr << "Error in On/Get"#variable << ", Get"#variable << " is " << object->Get##variable() << " instead of 1" << std::endl; \ 58 return EXIT_FAILURE; \ 60 object->variable##Off(); \ 61 if( object->Get##variable() != 0 ) \ 63 std::cerr << "Error in Off/Get"#variable << ", Get"#variable << " is " << object->Get##variable() << " instead of 0" << std::endl; \ 64 return EXIT_FAILURE; \ 69 #define TEST_SET_GET_INT( object, variable, value ) \ 71 object->Set##variable( value ); \ 72 if( object->Get##variable() != value ) \ 74 std::cerr << "Error in Set/Get"#variable << " using value " << value << std::endl; \ 75 return EXIT_FAILURE; \ 83 #define TEST_SET_GET_INT_RANGE( object, variable, min, max ) \ 86 int val = min - epsilon; \ 87 TEST_SET_GET_INT( object, variable, val); \ 89 TEST_SET_GET_INT( object, variable, val); \ 90 val = min + epsilon; \ 91 TEST_SET_GET_INT( object, variable, val); \ 92 val = (min + max) / 2; \ 93 TEST_SET_GET_INT( object, variable, val); \ 94 val = max - epsilon; \ 95 TEST_SET_GET_INT( object, variable, val); \ 97 TEST_SET_GET_INT( object, variable, val); \ 98 val = max + epsilon; \ 99 TEST_SET_GET_INT( object, variable, val); \ 104 #define TEST_SET_GET_DOUBLE( object, variable, value ) \ 106 object->Set##variable( value ); \ 107 if( object->Get##variable() != value ) \ 109 std::cerr << "Error in Set/Get"#variable << " using value '" << value << "', got '" << object->Get##variable() << "'" << std::endl; \ 110 return EXIT_FAILURE; \ 118 #define TEST_SET_GET_DOUBLE_RANGE( object, variable, min, max ) \ 120 double epsilon = 1.0; \ 121 double val = min - epsilon; \ 122 TEST_SET_GET_DOUBLE( object, variable, val); \ 124 TEST_SET_GET_DOUBLE( object, variable, val); \ 125 val = min + epsilon; \ 126 TEST_SET_GET_DOUBLE( object, variable, val); \ 127 val = (min + max) / 2.0; \ 128 TEST_SET_GET_DOUBLE( object, variable, val); \ 129 val = max - epsilon; \ 130 TEST_SET_GET_DOUBLE( object, variable, val); \ 132 TEST_SET_GET_DOUBLE( object, variable, val); \ 133 val = max + epsilon; \ 134 TEST_SET_GET_DOUBLE( object, variable, val); \ 139 #define TEST_SET_GET_VECTOR3_DOUBLE( object, variable, x, y, z ) \ 141 object->Set##variable( x, y, z ); \ 142 double *val = object->Get##variable(); \ 143 if( val == nullptr || val[0] != x || val[1] != y || val[2] != z ) \ 145 std::cerr << "Error in Set/Get"#variable << std::endl; \ 146 return EXIT_FAILURE; \ 153 #define TEST_SET_GET_VECTOR2( object, variable, x, y ) \ 155 object->Set##variable( x, y ); \ 156 int *val = object->Get##variable(); \ 157 if( val == nullptr || val[0] != x || val[1] != y ) \ 159 std::cerr << "Error in Set/Get"#variable << std::endl; \ 160 return EXIT_FAILURE; \ 169 #define TEST_SET_GET_VECTOR2_INT_RANGE( object, variable, min, max ) \ 172 TEST_SET_GET_VECTOR2(object, variable, min - epsilon, min - epsilon); \ 173 TEST_SET_GET_VECTOR2(object, variable, min, min); \ 174 TEST_SET_GET_VECTOR2(object, variable, min + epsilon, min + epsilon); \ 175 int half = (min+max/2); \ 176 TEST_SET_GET_VECTOR2(object, variable, half, half); \ 177 TEST_SET_GET_VECTOR2(object, variable, max - epsilon, max - epsilon); \ 178 TEST_SET_GET_VECTOR2(object, variable, max, max); \ 179 TEST_SET_GET_VECTOR2(object, variable, max + epsilon, max + epsilon); \ 187 #define TEST_SET_GET_VECTOR2_DOUBLE_RANGE( object, variable, min, max ) \ 189 double epsilon = 1.0; \ 190 TEST_SET_GET_VECTOR2(object, variable, min - epsilon, min - epsilon); \ 191 TEST_SET_GET_VECTOR2(object, variable, min, min); \ 192 TEST_SET_GET_VECTOR2(object, variable, min + epsilon, min + epsilon); \ 193 double half = (min+max/2.0); \ 194 TEST_SET_GET_VECTOR2(object, variable, half, half); \ 195 TEST_SET_GET_VECTOR2(object, variable, max - epsilon, max - epsilon); \ 196 TEST_SET_GET_VECTOR2(object, variable, max, max); \ 197 TEST_SET_GET_VECTOR2(object, variable, max + epsilon, max + epsilon); \ 205 #define TEST_SET_GET_VECTOR3_DOUBLE_RANGE( object, variable, min, max ) \ 207 double epsilon = 1.0; \ 208 TEST_SET_GET_VECTOR3_DOUBLE(object, variable, min - epsilon, min - epsilon, min - epsilon); \ 209 TEST_SET_GET_VECTOR3_DOUBLE(object, variable, min, min, min); \ 210 TEST_SET_GET_VECTOR3_DOUBLE(object, variable, min + epsilon, min + epsilon, min + epsilon); \ 211 double half = (min+max/2.0); \ 212 TEST_SET_GET_VECTOR3_DOUBLE(object, variable, half, half, half); \ 213 TEST_SET_GET_VECTOR3_DOUBLE(object, variable, max - epsilon, max - epsilon, max - epsilon); \ 214 TEST_SET_GET_VECTOR3_DOUBLE(object, variable, max, max, max); \ 215 TEST_SET_GET_VECTOR3_DOUBLE(object, variable, max + epsilon, max + epsilon, max + epsilon); \ 219 #define TEST_SET_GET_STRING( object, variable ) \ 221 const char * originalStringPointer = object->Get##variable(); \ 222 std::string originalString; \ 223 if( originalStringPointer != nullptr ) \ 225 originalString = originalStringPointer; \ 227 object->Set##variable( "testing with a const char"); \ 228 if( strcmp(object->Get##variable(), "testing with a const char") != 0) \ 230 std::cerr << "Error in Set/Get"#variable << " with a string literal" << std::endl; \ 231 return EXIT_FAILURE; \ 233 std::string string1 = "testingIsGood"; \ 234 object->Set##variable( string1.c_str() ); \ 235 if( object->Get##variable() != string1 ) \ 237 std::cerr << "Error in Set/Get"#variable << std::endl; \ 238 return EXIT_FAILURE; \ 240 std::string string2 = "moreTestingIsBetter"; \ 241 object->Set##variable( string2.c_str() ); \ 242 if( object->Get##variable() != string2 ) \ 244 std::cerr << "Error in Set/Get"#variable << std::endl; \ 245 return EXIT_FAILURE; \ 247 if( originalStringPointer != nullptr ) \ 249 object->Set##variable( originalString.c_str() ); \ 253 object->Set##variable( nullptr ); \ 258 #define TEST_SET_GET_CHAR( object, variable ) \ 260 const char originalChar = object->Get##variable(); \ 261 object->Set##variable( 't'); \ 262 if( object->Get##variable() != 't') \ 264 std::cerr << "Error in Set/Get"#variable << " with a literal 't'" << std::endl; \ 265 return EXIT_FAILURE; \ 267 object->Set##variable( '3'); \ 268 if( object->Get##variable() != '3') \ 270 std::cerr << "Error in Set/Get"#variable << " with a literal '3'" << std::endl; \ 271 return EXIT_FAILURE; \ 273 object->Set##variable( originalChar ); \ 277 #define EXERCISE_BASIC_INTERACTOR_OBSERVER_METHODS(object) \ 279 EXERCISE_BASIC_OBJECT_METHODS(object); \ 280 vtkSmartPointer<vtkRenderer> ren1 = vtkSmartPointer< vtkRenderer >::New(); \ 281 vtkSmartPointer< vtkCamera > cam1 = vtkSmartPointer< vtkCamera >::New(); \ 282 ren1->SetActiveCamera(cam1); \ 283 vtkSmartPointer< vtkRenderWindow > renWin = vtkSmartPointer< vtkRenderWindow >::New(); \ 284 renWin->SetMultiSamples(0); \ 285 renWin->AddRenderer(ren1); \ 286 if (object->GetInteractor() != nullptr) \ 288 std::cout << "Object has an interactor already defined." << std::endl; \ 290 vtkSmartPointer<vtkRenderWindowInteractor> iren = vtkSmartPointer<vtkRenderWindowInteractor>::New(); \ 291 iren->SetRenderWindow(renWin); \ 292 object->SetInteractor(iren); \ 293 if (object->GetInteractor() != iren) \ 295 std::cerr << "Error in Set/GetInteractor" << std::endl; \ 296 return EXIT_FAILURE; \ 298 if (object->GetDefaultRenderer() != nullptr) \ 300 std::cout << "Object has default renderer already defined." << std::endl; \ 303 vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New(); \ 304 renWin->AddRenderer(ren); \ 305 object->SetDefaultRenderer(ren); \ 306 if (object->GetDefaultRenderer() != ren) \ 308 std::cerr << "Error in Set/GetDefaultRenderer, default renderer is " << (object->GetDefaultRenderer() == nullptr ? "nullptr" : "not null") << std::endl; \ 309 return EXIT_FAILURE; \ 311 object->SetCurrentRenderer(ren); \ 312 if (object->GetCurrentRenderer() != ren) \ 314 std::cerr << "Get current renderer failed." << std::endl; \ 317 iren->Initialize(); \ 321 object->CreateDefaultRepresentation(); \ 322 TEST_SET_GET_BOOLEAN( object, Enabled); \ 324 if (!object->GetEnabled()) \ 326 std::cerr << "Error in On" << std::endl; \ 327 return EXIT_FAILURE; \ 330 if (object->GetEnabled()) \ 332 std::cerr << "Error in Off" << std::endl; \ 333 return EXIT_FAILURE; \ 336 TEST_SET_GET_DOUBLE( object, Priority, 0.0); \ 337 float min = object->GetPriorityMinValue(); \ 338 float max = object->GetPriorityMaxValue(); \ 339 std::cout << "Priority min = " << min << ", max = " << max << std::endl; \ 340 TEST_SET_GET_DOUBLE( object, Priority, 0.1f); \ 341 TEST_SET_GET_DOUBLE( object, Priority, 0.5f); \ 342 TEST_SET_GET_DOUBLE( object, Priority, 0.9f); \ 343 TEST_SET_GET_DOUBLE( object, Priority, 1.0f); \ 345 TEST_SET_GET_BOOLEAN( object, KeyPressActivation); \ 346 TEST_SET_GET_CHAR( object, KeyPressActivationValue); \ 352 double x = 1.0, y = 1.0, z = 1.0; \ 353 object->ComputeDisplayToWorld(ren, x, y, z, worldPt); \ 354 std::cout << "Display " << x << "," << y << "," << z << " to world = " << worldPt[0] << "," << worldPt[1] << "," << worldPt[2] << "," << worldPt[3] << std::endl; \ 355 double displayPt[3]; \ 356 object->ComputeWorldToDisplay(ren, x, y, z, displayPt); \ 357 std::cout << "World " << x << "," << y << "," << z << " to display = " << displayPt[0] << "," << displayPt[1] << "," << displayPt[2] << std::endl; \ 360 object->GrabFocus(nullptr, nullptr); \ 361 object->ReleaseFocus(); \ 365 #define EXERCISE_BASIC_ABSTRACT_METHODS(object) \ 367 EXERCISE_BASIC_INTERACTOR_OBSERVER_METHODS(object); \ 368 TEST_SET_GET_BOOLEAN( object, ProcessEvents); \ 369 if (object->GetEventTranslator() == nullptr) \ 371 std::cerr << "Error getting event translator, is null." << std::endl; \ 372 return EXIT_FAILURE; \ 374 object->CreateDefaultRepresentation(); \ 376 if (object->GetParent() != nullptr) \ 378 std::cerr << "Error, parent is not null." << std::endl; \ 379 return EXIT_FAILURE; \ 384 #define EXERCISE_BASIC_BORDER_METHODS(object) \ 386 EXERCISE_BASIC_ABSTRACT_METHODS(object); \ 387 TEST_SET_GET_BOOLEAN( object, Selectable); \ 388 TEST_SET_GET_BOOLEAN( object, Resizable); \ 392 #define EXERCISE_BASIC_HOVER_METHODS(object) \ 394 EXERCISE_BASIC_ABSTRACT_METHODS (object); \ 395 TEST_SET_GET_INT( object, TimerDuration, 1); \ 396 TEST_SET_GET_INT( object, TimerDuration, 2); \ 397 TEST_SET_GET_INT( object, TimerDuration, 50000); \ 398 TEST_SET_GET_INT( object, TimerDuration, 99999); \ 399 TEST_SET_GET_INT( object, TimerDuration, 100000); \ 403 #define EXERCISE_BASIC_PROP_METHODS(className, object) \ 405 EXERCISE_BASIC_OBJECT_METHODS(object); \ 406 vtkSmartPointer<vtkPropCollection> propCollection = vtkSmartPointer<vtkPropCollection>::New(); \ 407 object->GetActors(propCollection); \ 408 object->GetActors2D(propCollection); \ 409 object->GetVolumes(propCollection); \ 411 TEST_SET_GET_BOOLEAN( object, Visibility); \ 412 TEST_SET_GET_BOOLEAN( object, Pickable); \ 413 TEST_SET_GET_BOOLEAN( object, Dragable); \ 414 TEST_SET_GET_BOOLEAN( object, UseBounds); \ 415 object->UseBoundsOff(); \ 419 vtkMTimeType redrawMTime = object->GetRedrawMTime(); \ 420 std::cout << "Redraw Modified Time = " << redrawMTime << std::endl; \ 422 vtkSmartPointer< className > copyProp = vtkSmartPointer< className >::New(); \ 423 object->ShallowCopy(copyProp); \ 425 object->InitPathTraversal(); \ 427 vtkSmartPointer<vtkAssemblyPath> assemblyPath = vtkSmartPointer<vtkAssemblyPath>::New(); \ 428 assemblyPath = object->GetNextPath(); \ 429 std::cout << "Number of paths = " << object->GetNumberOfPaths() << std::endl; \ 431 vtkSmartPointer<vtkMatrix4x4> mat = vtkSmartPointer<vtkMatrix4x4>::New(); \ 432 object->PokeMatrix(mat); \ 433 mat = object->GetMatrix(); \ 434 if (mat == nullptr) \ 436 std::cout << "No matrix." << std::endl; \ 439 vtkSmartPointer<vtkInformation> info = vtkSmartPointer<vtkInformation>::New(); \ 440 info = object->GetPropertyKeys(); \ 441 if (info != nullptr) \ 443 info->Print(std::cout); \ 447 std::cout << "No property keys" << std::endl; \ 449 object->SetPropertyKeys(info); \ 450 std::cout << "Has null required keys? " << object->HasKeys(nullptr) << std::endl; \ 452 std::cout << "Skipping the internal render calls, requires vtkViewPort. Testing get macros." << std::endl; \ 453 std::cout << "HasTranslucentPolygonalGeometry = " << object->HasTranslucentPolygonalGeometry() << std::endl; \ 454 std::cout << "AllocatedRenderTime = " << object->GetAllocatedRenderTime() << std::endl; \ 455 std::cout << "RenderTimeMultiplier = " << object->GetRenderTimeMultiplier() << std::endl; \ 456 std::cout << "SupportsSelection = " << object->GetSupportsSelection() << std::endl; \ 457 std::cout << "NumberOfConsumers = " << object->GetNumberOfConsumers() << std::endl; \ 461 #define NOT_DEFINED_CONSUMERS_FAIL() \ 463 vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); \ 464 object->AddConsumer(actor); \ 465 if (object->IsConsumer(actor) != 1) \ 467 std::cerr << "Failed IsConsumer check for a valid consumer." << std::endl;\ 468 return EXIT_FAILURE; \ 470 if (object->IsConsumer(nullptr) != 0) \ 472 std::cerr << "Failed IsConsumer check for a null consumer." << std::endl; \ 473 return EXIT_FAILURE; \ 475 vtkSmartPointer<vtkActor> actor2 = object->GetConsumer(0); \ 476 if (actor2 != actor) \ 478 std::cerr << "Failed get consumer check for a valid consumer." << std::endl; \ 479 return EXIT_FAILURE; \ 481 object->RemoveConsumer(actor); \ 482 actor2 = object->GetConsumer(0); \ 483 if (actor2 != nullptr) \ 485 std::cerr << "Failed get consumer check for an invalid consumer number 0." << std::endl; \ 486 return EXIT_FAILURE; \ 491 #define EXERCISE_BASIC_REPRESENTATION_METHODS(className, object) \ 492 std::cout << "Creating a renderer and a default widget..." << std::endl; \ 493 vtkSmartPointer< vtkCamera > cam1 = vtkSmartPointer< vtkCamera >::New(); \ 494 vtkSmartPointer< vtkRenderer > ren1 = vtkSmartPointer< vtkRenderer >::New(); \ 495 ren1->SetActiveCamera(cam1); \ 496 vtkSmartPointer< vtkRenderWindow > renWin = vtkSmartPointer< vtkRenderWindow >::New(); \ 497 renWin->SetMultiSamples(0); \ 498 renWin->AddRenderer(ren1); \ 499 vtkSmartPointer<vtkRenderWindowInteractor> iren = vtkSmartPointer<vtkRenderWindowInteractor>::New(); \ 500 iren->SetRenderWindow(renWin); \ 503 object->SetRenderer(ren1); \ 504 vtkSmartPointer<vtkRenderer> ren2 = object->GetRenderer(); \ 507 std::cerr << "Failure in GetRenderer." << std::endl; \ 508 return EXIT_FAILURE; \ 511 object->BuildRepresentation(); \ 513 double bounds[6] = {-1.0, 0.0, -10.0, 10.0, -5.0, 2.0}; \ 514 object->PlaceWidget(bounds); \ 515 const double *bounds2 = object->GetBounds(); \ 516 if (bounds2 == nullptr) \ 518 std::cout << "GetBounds is null." << std::endl; \ 522 std::cout << "Bounds = " << bounds[0] << "," << bounds[1] << "," << bounds[2] << "," << bounds[3] << "," << bounds[4] << "," << bounds[5] << std::endl; \ 525 double eventPos[2] = {10.0, 10.0}; \ 526 object->StartWidgetInteraction(eventPos); \ 527 object->WidgetInteraction(eventPos); \ 528 object->EndWidgetInteraction(eventPos); \ 529 std::cout << "InteractionState computed to be = " << object->ComputeInteractionState(10, 10, 0) << std::endl; \ 530 std::cout << "GetInteractionState = " << object->GetInteractionState() << std::endl; \ 531 object->Highlight(0); \ 532 object->Highlight(1); \ 534 TEST_SET_GET_DOUBLE_RANGE(object, PlaceFactor, 1.01, 1000.0); \ 535 TEST_SET_GET_DOUBLE_RANGE(object, HandleSize, 1.002, 999.0); \ 536 TEST_SET_GET_BOOLEAN(object, NeedToRender); \ 538 std::cout << "Trying to get back to init state for further testing." << std::endl; \ 539 object->SetPlaceFactor(0.5); \ 540 object->SetHandleSize(0.05); \ 541 std::cout << "Done basic rep methods" << std::endl; \ 542 EXERCISE_BASIC_PROP_METHODS(className, object); 545 #define EXERCISE_BASIC_ANGLE_REPRESENTATION_METHODS(className, object) \ 547 vtkSmartPointer<vtkPointHandleRepresentation2D> phandle0 = vtkSmartPointer<vtkPointHandleRepresentation2D>::New(); \ 548 object->SetHandleRepresentation(phandle0); \ 549 object->InstantiateHandleRepresentation(); \ 551 std::cout << "GetAngle = " << object->GetAngle() << std::endl; \ 554 object->GetPoint1WorldPosition(pos); \ 555 std::cout << "GetPoint1WorldPosition = " << pos[0] << ", " << pos[1] << ", " << pos[2] << std::endl; \ 556 object->GetCenterWorldPosition(pos); \ 557 std::cout << "GetCenterWorldPosition = " << pos[0] << ", " << pos[1] << ", " << pos[2] << std::endl; \ 558 object->GetPoint2WorldPosition(pos); \ 559 std::cout << "GetPoint2WorldPosition = " << pos[0] << ", " << pos[1] << ", " << pos[2] << std::endl; \ 565 object->SetCenterDisplayPosition(pos2); \ 566 object->GetCenterDisplayPosition(pos); \ 567 if (pos[0] != pos2[0] || \ 568 pos[0] != pos2[0] || \ 571 std::cerr << "Failed to SetCenterDisplayPosition to " << pos2[0] << ", " << pos2[1] << ", " << pos2[2] << ", instead got " << pos[0] << ", " << pos[1] << ", " << pos[2] << std::endl; \ 572 return EXIT_FAILURE; \ 576 object->SetPoint1DisplayPosition(pos2); \ 577 object->GetPoint1DisplayPosition(pos); \ 578 if (pos[0] != pos2[0] || \ 579 pos[0] != pos2[0] || \ 582 std::cerr << "Failed to SetPoint1DisplayPosition to " << pos2[0] << ", " << pos2[1] << ", " << pos2[2] << ", instead got " << pos[0] << ", " << pos[1] << ", " << pos[2] << std::endl; \ 583 return EXIT_FAILURE; \ 587 object->SetPoint2DisplayPosition(pos2); \ 588 object->GetPoint2DisplayPosition(pos); \ 589 if (pos[0] != pos2[0] || \ 590 pos[0] != pos2[0] || \ 593 std::cerr << "Failed to SetPoint2DisplayPosition to " << pos2[0] << ", " << pos2[1] << ", " << pos2[2] << ", instead got " << pos[0] << ", " << pos[1] << ", " << pos[2] << std::endl; \ 594 return EXIT_FAILURE; \ 597 vtkSmartPointer<vtkPointHandleRepresentation2D> phandle = vtkSmartPointer<vtkPointHandleRepresentation2D>::New(); \ 598 object->SetHandleRepresentation(phandle); \ 599 object->InstantiateHandleRepresentation(); \ 601 vtkSmartPointer<vtkHandleRepresentation> handleRep = nullptr; \ 602 handleRep = object->GetPoint1Representation(); \ 603 handleRep = object->GetPoint2Representation(); \ 604 handleRep = object->GetCenterRepresentation(); \ 606 TEST_SET_GET_INT_RANGE(object, Tolerance, 2, 99); \ 607 TEST_SET_GET_STRING( object, LabelFormat); \ 608 TEST_SET_GET_BOOLEAN( object, Ray1Visibility); \ 609 TEST_SET_GET_BOOLEAN( object, Ray2Visibility); \ 610 TEST_SET_GET_BOOLEAN( object, ArcVisibility); \ 612 double e[2] = {5.0, 1.0}; \ 613 object->CenterWidgetInteraction(e); \ 614 EXERCISE_BASIC_REPRESENTATION_METHODS(className, object); \ 618 #define EXERCISE_BASIC_BORDER_REPRESENTATION_METHODS(className, object) \ 620 EXERCISE_BASIC_REPRESENTATION_METHODS(className, object); \ 622 double pos[2] = {10.0, 11.0}; \ 623 double *pos2 = nullptr; \ 624 object->SetPosition(pos); \ 625 pos2 = object->GetPosition(); \ 626 if (pos2 == nullptr) \ 628 std::cerr << "Failure in Get/Set Position pos, got null position back." << std::endl; \ 629 return EXIT_FAILURE; \ 631 else if (pos2[0] != pos[0] || \ 634 std::cerr << "Failure in Get/Set Position pos, expected " << pos[0] << ", " << pos[1] << ", instead got " << pos2[0] << ", " << pos2[1] << std::endl; \ 635 return EXIT_FAILURE; \ 639 std::cout << "Set Position to " << pos2[0] << ", " << pos2[1] << std::endl; \ 643 object->SetPosition(pos[0], pos[1]); \ 644 pos2 = object->GetPosition(); \ 645 if (pos2 == nullptr || \ 646 pos2[0] != pos[0] || \ 649 std::cerr << "Failure in Get/Set Position x,y, expected " << pos[0] << ", " << pos[1] << ", instead got " << pos2[0] << ", " << pos2[1] << std::endl; \ 650 return EXIT_FAILURE; \ 652 vtkSmartPointer<vtkCoordinate> coord = object->GetPositionCoordinate(); \ 653 pos2 = coord->GetValue(); \ 654 if (pos2 == nullptr || \ 655 pos2[0] != pos[0] || \ 658 std::cerr << "Failure in Get/ Coordinate, expected " << pos[0] << ", " << pos[1] << ", instead got " << pos2[0] << ", " << pos2[1] << std::endl; \ 659 return EXIT_FAILURE; \ 663 object->SetPosition2(pos); \ 664 pos2 = object->GetPosition2(); \ 665 if (pos2 == nullptr || \ 666 pos2[0] != pos[0] || \ 669 std::cerr << "Failure in Get/Set Position2 pos, expected " << pos[0] << ", " << pos[1] << ", instead got " << pos2[0] << ", " << pos2[1] << std::endl; \ 670 return EXIT_FAILURE; \ 673 object->SetPosition2(pos[0], pos[1]); \ 674 pos2 = object->GetPosition2(); \ 675 if (pos2 == nullptr || \ 676 pos2[0] != pos[0] || \ 679 std::cerr << "Failure in Get/Set Position2 x,y, expected " << pos[0] << ", " << pos[1] << ", instead got " << pos2[0] << ", " << pos2[1] << std::endl; \ 680 return EXIT_FAILURE; \ 682 coord = object->GetPosition2Coordinate(); \ 683 pos2 = coord->GetValue(); \ 684 if (pos2 == nullptr || \ 685 pos2[0] != pos[0] || \ 688 std::cerr << "Failure in Get/ Coordinate 2, expected " << pos[0] << ", " << pos[1] << ", instead got " << pos2[0] << ", " << pos2[1] << std::endl; \ 689 return EXIT_FAILURE; \ 692 TEST_SET_GET_INT(object, ShowBorder, 0); \ 693 TEST_SET_GET_INT(object, ShowBorder, 1); \ 694 TEST_SET_GET_INT(object, ShowBorder, 2); \ 695 object->SetShowBorderToOff(); \ 696 object->SetShowBorderToOn(); \ 697 object->SetShowBorderToActive(); \ 699 vtkSmartPointer<vtkProperty2D> borderProperty = object->GetBorderProperty(); \ 701 TEST_SET_GET_BOOLEAN( object, ProportionalResize); \ 703 TEST_SET_GET_VECTOR2_INT_RANGE(object, MinimumSize, 0, 100); \ 704 TEST_SET_GET_VECTOR2_INT_RANGE(object, MaximumSize, 0, 100); \ 705 TEST_SET_GET_INT_RANGE(object, Tolerance, 2, 9); \ 707 double *selPoint = object->GetSelectionPoint(); \ 710 std::cout << "Selection Point = " << selPoint[0] << ", " << selPoint[1] << std::endl; \ 713 TEST_SET_GET_BOOLEAN( object,Moving); \ 716 object->GetSize(size); \ 717 std::cout << "Size = " << size[0] << ", " << size[1] << std::endl; \ 719 int interactionState = object->ComputeInteractionState(10, 10); \ 720 std::cout << "Interaction state = " << interactionState << std::endl; \ 724 #define EXERCISE_BASIC_IMPLICIT_PLANE_REPRESENTATION_METHODS(className, object) \ 726 EXERCISE_BASIC_REPRESENTATION_METHODS(className, object); \ 728 TEST_SET_GET_VECTOR3_DOUBLE_RANGE(node1, Origin, -100, 100); \ 729 TEST_SET_GET_VECTOR3_DOUBLE_RANGE(node1, Normal, -1, 1); \ 730 TEST_SET_GET_BOOLEAN( node1, NormalToXAxis); \ 731 TEST_SET_GET_BOOLEAN( node1, NormalToYAxis); \ 732 TEST_SET_GET_BOOLEAN( node1, NormalToZAxis); \ 733 TEST_SET_GET_BOOLEAN( node1, Tubing); \ 734 TEST_SET_GET_BOOLEAN( node1, DrawPlane); \ 735 TEST_SET_GET_BOOLEAN( node1, OutlineTranslation); \ 736 TEST_SET_GET_BOOLEAN( node1, OutsideBounds); \ 737 TEST_SET_GET_BOOLEAN( node1, ScaleEnabled); \ 742 #define TEST_SET_GET_PROPERTY(object, variable)\ 744 vtkSmartPointer<vtkProperty> prop1 = vtkSmartPointer<vtkProperty>::New(); \ 745 double colour[3] = {0.2, 0.3, 0.4}; \ 746 prop1->SetColor(colour); \ 747 node1->Set##variable(prop1); \ 748 vtkSmartPointer<vtkProperty> prop = node1->Get##variable(); \ 751 std::cerr << "Got null variable property back after setting it!" << std::endl; \ 752 return EXIT_FAILURE; \ 754 double *col = prop->GetColor(); \ 757 std::cerr << "Got null colour back!" << std::endl; \ 758 return EXIT_FAILURE; \ 760 if (col[0] != colour[0] || \ 761 col[1] != colour[1] || \ 762 col[2] != colour[2]) \ 764 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; \ 765 return EXIT_FAILURE; \ 771 #define EXERCISE_BASIC_HANDLE_REPRESENTATION_METHODS(className, object) \ 776 EXERCISE_BASIC_REPRESENTATION_METHODS(className, object); \ 778 double dpos[3], wpos[3]; \ 788 std::cout << "Testing SetWorldPosition" << std::endl; \ 790 object->SetWorldPosition(wpos); \ 791 std::cout << "Testing GetWorldPosition" << std::endl; \ 792 object->GetWorldPosition(pos2); \ 793 if (pos2[0] != wpos[0] || \ 794 pos2[1] != wpos[1] || \ 795 pos2[2] != wpos[2]) \ 797 std::cerr << "Failure in Get WorldPosition pos2, expected " << wpos[0] << ", " << wpos[1] << ", " << wpos[2] << ", instead got " << pos2[0] << ", " << pos2[1] << ", " << pos2[2] << std::endl; \ 798 return EXIT_FAILURE; \ 800 pos3 = object->GetWorldPosition(); \ 803 std::cerr << "Failure in double * GetWorldPosition , expected " << wpos[0] << ", " << wpos[1] << ", " << wpos[2] << ", instead got a null pointer." << std::endl; \ 804 return EXIT_FAILURE; \ 806 if (pos3[0] != wpos[0] || \ 807 pos3[1] != wpos[1] || \ 808 pos3[2] != wpos[2]) \ 810 std::cerr << "Failure in double * GetWorldyPosition , expected " << wpos[0] << ", " << wpos[1] << ", " << wpos[2] << ", instead got " << pos3[0] << ", " << pos3[1] << ", " << pos3[2] << std::endl; \ 811 return EXIT_FAILURE; \ 813 std::cout << "Done testing world position." << std::endl; \ 815 std::cout << "Testing Set/Get Display Position" << std::endl; \ 818 object->GetDisplayPosition(pos2); \ 819 std::cout << "After GetDisplayPosition." << std::endl; \ 820 object->SetDisplayPosition(dpos); \ 821 std::cout << "After SetDisplayPosition" << std::endl; \ 822 object->GetDisplayPosition(pos2); \ 823 std::cout << "After GetDisplayPosition second time." << std::endl; \ 824 if (pos2[0] != 0 || \ 827 std::cerr << "Failure in GetDisplayPosition pos2, expected (0,0) instead got " << pos2[0] << ", " << pos2[1] << std::endl; \ 828 return EXIT_FAILURE; \ 830 pos3 = object->GetDisplayPosition(); \ 833 std::cerr << "Failure in double * GetDisplayPosition, expected (0,0) instead got a null pointer." << std::endl; \ 834 return EXIT_FAILURE; \ 836 if (pos3[0] != 0 || \ 839 std::cerr << "Failure in double * GetDisplayPosition , expected (0,0) instead got " << pos3[0] << ", " << pos3[1] << std::endl; \ 840 return EXIT_FAILURE; \ 842 TEST_SET_GET_INT_RANGE(object, Tolerance, 2, 99); \ 843 TEST_SET_GET_BOOLEAN( object, ActiveRepresentation); \ 844 TEST_SET_GET_BOOLEAN( object, Constrained); \ 846 vtkSmartPointer<vtkRenderer> ren3 = object->GetRenderer(); \ 847 double posToCheck[3] = {0.0, 0.0, 0.0}; \ 848 int flag = object->CheckConstraint(ren3, posToCheck); \ 849 std::cout << "Check Constraint = " << flag << std::endl; \ 851 std::cout << "MTime = " << object->GetMTime() << std::endl; \ 853 vtkSmartPointer<vtkPointPlacer> pplacer = vtkSmartPointer<vtkPointPlacer>::New(); \ 854 object->SetPointPlacer(pplacer); \ 855 vtkSmartPointer<vtkPointPlacer> pplacer2 = object->GetPointPlacer(); \ 856 if (pplacer2 != pplacer) \ 858 std::cerr << "Error in Set/Get point placer." << std::endl; \ 859 return EXIT_FAILURE; \ 861 flag = object->CheckConstraint(ren3, posToCheck); \ 862 std::cout << "Check Constraint after setting point placer = " << flag << std::endl; \ 866 #define EXERCISE_BASIC_ABSTRACT_POLYGONAL_HANDLE_REPRESENTATION3D_METHODS(className, object) \ 868 EXERCISE_BASIC_HANDLE_REPRESENTATION_METHODS(className, object); \ 870 vtkSmartPointer<vtkPolyData> pd = vtkSmartPointer<vtkPolyData>::New(); \ 871 object->SetHandle(pd); \ 872 vtkSmartPointer<vtkPolyData> pd2 = object->GetHandle(); \ 873 if (pd2 == nullptr) \ 875 std::cerr << "Error getting handle, null pointer." << std::endl; \ 876 return EXIT_FAILURE; \ 880 std::cerr << "Error getting handle, not the same as set." << std::endl; \ 881 return EXIT_FAILURE; \ 883 TEST_SET_GET_PROPERTY(object, Property); \ 884 TEST_SET_GET_PROPERTY(object, SelectedProperty); \ 886 vtkSmartPointer<vtkAbstractTransform> at = object->GetTransform(); \ 888 TEST_SET_GET_BOOLEAN(object, LabelVisibility); \ 889 TEST_SET_GET_STRING(object, LabelText); \ 890 TEST_SET_GET_VECTOR3_DOUBLE_RANGE(object, LabelTextScale, 0.0, 10.0); \ 892 vtkSmartPointer<vtkFollower> follower = object->GetLabelTextActor(); \ 893 if (follower == nullptr) \ 895 std::cout << "Follower is null." << std::endl; \ 898 object->SetUniformScale(-1.0); \ 899 object->SetUniformScale(0.0); \ 900 object->SetUniformScale(1.0); \ 901 object->SetUniformScale(35.44); \ 903 TEST_SET_GET_BOOLEAN(object, HandleVisibility); \