/usr/include/vtk-7.1/vtkSetGet.h is in libvtk7-dev 7.1.1+dfsg1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 | /*=========================================================================
Program: Visualization Toolkit
Module: vtkSetGet.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class SetGet
*
* The SetGet macros are used to interface to instance variables
* in a standard fashion. This includes properly treating modified time
* and printing out debug information.
*
* Macros are available for built-in types; for character strings;
* vector arrays of built-in types size 2,3,4; for setting objects; and
* debug, warning, and error printout information.
*/
#ifndef vtkSetGet_h
#define vtkSetGet_h
#include "vtkCommonCoreModule.h" // For export macro
#include "vtkSystemIncludes.h"
#include <math.h>
#include <typeinfo>
//----------------------------------------------------------------------------
// Check for unsupported old compilers.
#if defined(_MSC_VER) && _MSC_VER <= 1400
# error VTK requires MSVC++ 9.0 aka Visual Studio 2008 or newer
#endif
#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2))
# error VTK requires GCC 4.2 or newer
#endif
// Convert a macro representing a value to a string.
//
// Example: vtkQuoteMacro(__LINE__) will expand to "1234" whereas
// vtkInternalQuoteMacro(__LINE__) will expand to "__LINE__"
#define vtkInternalQuoteMacro(x) #x
#define vtkQuoteMacro(x) vtkInternalQuoteMacro(x)
// A macro to get the name of a type
#define vtkImageScalarTypeNameMacro(type) \
(((type) == VTK_VOID) ? "void" : \
(((type) == VTK_BIT) ? "bit" : \
(((type) == VTK_CHAR) ? "char" : \
(((type) == VTK_SIGNED_CHAR) ? "signed char" : \
(((type) == VTK_UNSIGNED_CHAR) ? "unsigned char" : \
(((type) == VTK_SHORT) ? "short" : \
(((type) == VTK_UNSIGNED_SHORT) ? "unsigned short" : \
(((type) == VTK_INT) ? "int" : \
(((type) == VTK_UNSIGNED_INT) ? "unsigned int" : \
(((type) == VTK_LONG) ? "long" : \
(((type) == VTK_UNSIGNED_LONG) ? "unsigned long" : \
(((type) == VTK_LONG_LONG) ? "long long" : \
(((type) == VTK_UNSIGNED_LONG_LONG) ? "unsigned long long" : \
(((type) == VTK___INT64) ? "__int64" : \
(((type) == VTK_UNSIGNED___INT64) ? "unsigned __int64" : \
(((type) == VTK_FLOAT) ? "float" : \
(((type) == VTK_DOUBLE) ? "double" : \
(((type) == VTK_ID_TYPE) ? "idtype" : \
(((type) == VTK_STRING) ? "string" : \
(((type) == VTK_UNICODE_STRING) ? "unicode string" : \
(((type) == VTK_VARIANT) ? "variant" : \
(((type) == VTK_OBJECT) ? "object" : \
"Undefined"))))))))))))))))))))))
//
// Set built-in type. Creates member Set"name"() (e.g., SetVisibility());
//
#define vtkSetMacro(name,type) \
virtual void Set##name (type _arg) \
{ \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting " #name " to " << _arg); \
if (this->name != _arg) \
{ \
this->name = _arg; \
this->Modified(); \
} \
}
//
// Get built-in type. Creates member Get"name"() (e.g., GetVisibility());
//
#define vtkGetMacro(name,type) \
virtual type Get##name () { \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " of " << this->name ); \
return this->name; \
}
//
// Set character string. Creates member Set"name"()
// (e.g., SetFilename(char *));
//
#define vtkSetStringMacro(name) \
virtual void Set##name (const char* _arg) \
{ \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting " << #name " to " << (_arg?_arg:"(null)") ); \
if ( this->name == NULL && _arg == NULL) { return;} \
if ( this->name && _arg && (!strcmp(this->name,_arg))) { return;} \
delete [] this->name; \
if (_arg) \
{ \
size_t n = strlen(_arg) + 1; \
char *cp1 = new char[n]; \
const char *cp2 = (_arg); \
this->name = cp1; \
do { *cp1++ = *cp2++; } while ( --n ); \
} \
else \
{ \
this->name = NULL; \
} \
this->Modified(); \
}
//
// Get character string. Creates member Get"name"()
// (e.g., char *GetFilename());
//
#define vtkGetStringMacro(name) \
virtual char* Get##name () { \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " of " << (this->name?this->name:"(null)")); \
return this->name; \
}
//
// Set built-in type where value is constrained between min/max limits.
// Create member Set"name"() (eg., SetRadius()). #defines are
// convenience for clamping open-ended values.
// The Get"name"MinValue() and Get"name"MaxValue() members return the
// min and max limits.
//
#define vtkSetClampMacro(name,type,min,max) \
virtual void Set##name (type _arg) \
{ \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting " << #name " to " << _arg ); \
if (this->name != (_arg<min?min:(_arg>max?max:_arg))) \
{ \
this->name = (_arg<min?min:(_arg>max?max:_arg)); \
this->Modified(); \
} \
} \
virtual type Get##name##MinValue () \
{ \
return min; \
} \
virtual type Get##name##MaxValue () \
{ \
return max; \
}
//
// This macro defines a body of set object macro. It can be used either in
// the header file vtkSetObjectMacro or in the implementation one
// vtkSetObjectMacro. It sets the pointer to object; uses vtkObject
// reference counting methodology. Creates method
// Set"name"() (e.g., SetPoints()).
//
#define vtkSetObjectBodyMacro(name,type,args) \
{ \
vtkDebugMacro(<< this->GetClassName() << " (" << this \
<< "): setting " << #name " to " << args ); \
if (this->name != args) \
{ \
type* tempSGMacroVar = this->name; \
this->name = args; \
if (this->name != NULL) { this->name->Register(this); } \
if (tempSGMacroVar != NULL) \
{ \
tempSGMacroVar->UnRegister(this); \
} \
this->Modified(); \
} \
}
//
// Set pointer to object; uses vtkObject reference counting methodology.
// Creates method Set"name"() (e.g., SetPoints()). This macro should
// be used in the header file.
//
#define vtkSetObjectMacro(name,type) \
virtual void Set##name (type* _arg) \
{ \
vtkSetObjectBodyMacro(name,type,_arg); \
}
//
// Set pointer to object; uses vtkObject reference counting methodology.
// Creates method Set"name"() (e.g., SetPoints()). This macro should
// be used in the implementation file. You will also have to write
// prototype in the header file. The prototype should look like this:
// virtual void Set"name"("type" *);
//
// Please use vtkCxxSetObjectMacro not vtkSetObjectImplementationMacro.
// The first one is just for people who already used it.
#define vtkSetObjectImplementationMacro(class,name,type) \
vtkCxxSetObjectMacro(class,name,type)
#define vtkCxxSetObjectMacro(class,name,type) \
void class::Set##name (type* _arg) \
{ \
vtkSetObjectBodyMacro(name,type,_arg); \
}
//
// Get pointer to object wrapped in vtkNew. Creates member Get"name"
// (e.g., GetPoints()). This macro should be used in the header file.
//
#define vtkGetNewMacro(name,type) \
virtual type *Get##name () \
{ \
vtkDebugMacro(<< this->GetClassName() << " (" << this \
<< "): returning " #name " address " \
<< this->name.GetPointer() ); \
return this->name.GetPointer(); \
}
//
// Get pointer to object. Creates member Get"name" (e.g., GetPoints()).
// This macro should be used in the header file.
//
#define vtkGetObjectMacro(name,type) \
virtual type *Get##name () \
{ \
vtkDebugMacro(<< this->GetClassName() << " (" << this \
<< "): returning " #name " address " << this->name ); \
return this->name; \
}
//
// Create members "name"On() and "name"Off() (e.g., DebugOn() DebugOff()).
// Set method must be defined to use this macro.
//
#define vtkBooleanMacro(name,type) \
virtual void name##On () { this->Set##name(static_cast<type>(1));} \
virtual void name##Off () { this->Set##name(static_cast<type>(0));}
//
// Following set macros for vectors define two members for each macro. The first
// allows setting of individual components (e.g, SetColor(float,float,float)),
// the second allows setting from an array (e.g., SetColor(float* rgb[3])).
// The macros vary in the size of the vector they deal with.
//
#define vtkSetVector2Macro(name,type) \
virtual void Set##name (type _arg1, type _arg2) \
{ \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting " << #name " to (" << _arg1 << "," << _arg2 << ")"); \
if ((this->name[0] != _arg1)||(this->name[1] != _arg2)) \
{ \
this->name[0] = _arg1; \
this->name[1] = _arg2; \
this->Modified(); \
} \
} \
void Set##name (type _arg[2]) \
{ \
this->Set##name (_arg[0], _arg[1]); \
}
#define vtkGetVector2Macro(name,type) \
virtual type *Get##name () \
{ \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " pointer " << this->name); \
return this->name; \
} \
virtual void Get##name (type &_arg1, type &_arg2) \
{ \
_arg1 = this->name[0]; \
_arg2 = this->name[1]; \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " = (" << _arg1 << "," << _arg2 << ")"); \
} \
virtual void Get##name (type _arg[2]) \
{ \
this->Get##name (_arg[0], _arg[1]);\
}
#define vtkSetVector3Macro(name,type) \
virtual void Set##name (type _arg1, type _arg2, type _arg3) \
{ \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting " << #name " to (" << _arg1 << "," << _arg2 << "," << _arg3 << ")"); \
if ((this->name[0] != _arg1)||(this->name[1] != _arg2)||(this->name[2] != _arg3)) \
{ \
this->name[0] = _arg1; \
this->name[1] = _arg2; \
this->name[2] = _arg3; \
this->Modified(); \
} \
} \
virtual void Set##name (type _arg[3]) \
{ \
this->Set##name (_arg[0], _arg[1], _arg[2]);\
}
#define vtkGetVector3Macro(name,type) \
virtual type *Get##name () \
{ \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " pointer " << this->name); \
return this->name; \
} \
virtual void Get##name (type &_arg1, type &_arg2, type &_arg3) \
{ \
_arg1 = this->name[0]; \
_arg2 = this->name[1]; \
_arg3 = this->name[2]; \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " = (" << _arg1 << "," << _arg2 << "," << _arg3 << ")"); \
} \
virtual void Get##name (type _arg[3]) \
{ \
this->Get##name (_arg[0], _arg[1], _arg[2]);\
}
#define vtkSetVector4Macro(name,type) \
virtual void Set##name (type _arg1, type _arg2, type _arg3, type _arg4) \
{ \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting " << #name " to (" << _arg1 << "," << _arg2 << "," << _arg3 << "," << _arg4 << ")"); \
if ((this->name[0] != _arg1)||(this->name[1] != _arg2)||(this->name[2] != _arg3)||(this->name[3] != _arg4)) \
{ \
this->name[0] = _arg1; \
this->name[1] = _arg2; \
this->name[2] = _arg3; \
this->name[3] = _arg4; \
this->Modified(); \
} \
} \
virtual void Set##name (type _arg[4]) \
{ \
this->Set##name (_arg[0], _arg[1], _arg[2], _arg[3]);\
}
#define vtkGetVector4Macro(name,type) \
virtual type *Get##name () \
{ \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " pointer " << this->name); \
return this->name; \
} \
virtual void Get##name (type &_arg1, type &_arg2, type &_arg3, type &_arg4) \
{ \
_arg1 = this->name[0]; \
_arg2 = this->name[1]; \
_arg3 = this->name[2]; \
_arg4 = this->name[3]; \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " = (" << _arg1 << "," << _arg2 << "," << _arg3 << "," << _arg4 << ")"); \
} \
virtual void Get##name (type _arg[4]) \
{ \
this->Get##name (_arg[0], _arg[1], _arg[2], _arg[3]);\
}
#define vtkSetVector6Macro(name,type) \
virtual void Set##name (type _arg1, type _arg2, type _arg3, type _arg4, type _arg5, type _arg6) \
{ \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): setting " << #name " to (" << _arg1 << "," << _arg2 << "," << _arg3 << "," << _arg4 << "," << _arg5 << "," << _arg6 << ")"); \
if ((this->name[0] != _arg1)||(this->name[1] != _arg2)||(this->name[2] != _arg3)||(this->name[3] != _arg4)||(this->name[4] != _arg5)||(this->name[5] != _arg6)) \
{ \
this->name[0] = _arg1; \
this->name[1] = _arg2; \
this->name[2] = _arg3; \
this->name[3] = _arg4; \
this->name[4] = _arg5; \
this->name[5] = _arg6; \
this->Modified(); \
} \
} \
virtual void Set##name (type _arg[6]) \
{ \
this->Set##name (_arg[0], _arg[1], _arg[2], _arg[3], _arg[4], _arg[5]);\
}
#define vtkGetVector6Macro(name,type) \
virtual type *Get##name () \
{ \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " pointer " << this->name); \
return this->name; \
} \
virtual void Get##name (type &_arg1, type &_arg2, type &_arg3, type &_arg4, type &_arg5, type &_arg6) \
{ \
_arg1 = this->name[0]; \
_arg2 = this->name[1]; \
_arg3 = this->name[2]; \
_arg4 = this->name[3]; \
_arg5 = this->name[4]; \
_arg6 = this->name[5]; \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " = (" << _arg1 << "," << _arg2 << "," << _arg3 << "," << _arg4 << "," << _arg5 <<"," << _arg6 << ")"); \
} \
virtual void Get##name (type _arg[6]) \
{ \
this->Get##name (_arg[0], _arg[1], _arg[2], _arg[3], _arg[4], _arg[5]);\
}
//
// General set vector macro creates a single method that copies specified
// number of values into object.
// Examples: void SetColor(c,3)
//
#define vtkSetVectorMacro(name,type,count) \
virtual void Set##name(type data[]) \
{ \
int i; \
for (i=0; i<count; i++) { if ( data[i] != this->name[i] ) { break; }} \
if ( i < count ) \
{ \
for (i=0; i<count; i++) { this->name[i] = data[i]; }\
this->Modified(); \
} \
}
//
// Get vector macro defines two methods. One returns pointer to type
// (i.e., array of type). This is for efficiency. The second copies data
// into user provided array. This is more object-oriented.
// Examples: float *GetColor() and void GetColor(float c[count]).
//
#define vtkGetVectorMacro(name,type,count) \
virtual type *Get##name () \
{ \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " << #name " pointer " << this->name); \
return this->name; \
} \
virtual void Get##name (type data[count]) \
{ \
for (int i=0; i<count; i++) { data[i] = this->name[i]; }\
}
// Use a global function which actually calls:
// vtkOutputWindow::GetInstance()->DisplayText();
// This is to avoid vtkObject #include of vtkOutputWindow
// while vtkOutputWindow #includes vtkObject
extern VTKCOMMONCORE_EXPORT void vtkOutputWindowDisplayText(const char*);
extern VTKCOMMONCORE_EXPORT void vtkOutputWindowDisplayErrorText(const char*);
extern VTKCOMMONCORE_EXPORT void vtkOutputWindowDisplayWarningText(const char*);
extern VTKCOMMONCORE_EXPORT void vtkOutputWindowDisplayGenericWarningText(const char*);
extern VTKCOMMONCORE_EXPORT void vtkOutputWindowDisplayDebugText(const char*);
//
// This macro is used for any output that may not be in an instance method
// vtkGenericWarningMacro(<< "this is debug info" << this->SomeVariable);
//
#define vtkGenericWarningMacro(x) \
{ if (vtkObject::GetGlobalWarningDisplay()) { \
vtkOStreamWrapper::EndlType endl; \
vtkOStreamWrapper::UseEndl(endl); \
vtkOStrStreamWrapper vtkmsg; \
vtkmsg << "Generic Warning: In " __FILE__ ", line " << __LINE__ << "\n" x \
<< "\n\n"; \
vtkOutputWindowDisplayGenericWarningText(vtkmsg.str());\
vtkmsg.rdbuf()->freeze(0);}}
//
// This macro is used for debug statements in instance methods
// vtkDebugMacro(<< "this is debug info" << this->SomeVariable);
//
#define vtkDebugMacro(x) \
vtkDebugWithObjectMacro(this,x)
//
// This macro is used to print out warning messages.
// vtkWarningMacro(<< "Warning message" << variable);
//
#define vtkWarningMacro(x) \
vtkWarningWithObjectMacro(this,x)
//
// This macro is used to print out errors
// vtkErrorMacro(<< "Error message" << variable);
//
#define vtkErrorMacro(x) \
vtkErrorWithObjectMacro(this,x)
//
// This macro is used to print out errors
// vtkErrorWithObjectMacro(self, << "Error message" << variable);
//
#define vtkErrorWithObjectMacro(self, x) \
{ \
if (vtkObject::GetGlobalWarningDisplay()) \
{ \
vtkOStreamWrapper::EndlType endl; \
vtkOStreamWrapper::UseEndl(endl); \
vtkOStrStreamWrapper vtkmsg; \
vtkmsg << "ERROR: In " __FILE__ ", line " << __LINE__ \
<< "\n" << self->GetClassName() << " (" << self \
<< "): " x << "\n\n"; \
if ( self->HasObserver("ErrorEvent") ) \
{ \
self->InvokeEvent("ErrorEvent", vtkmsg.str()); \
} \
else \
{ \
vtkOutputWindowDisplayErrorText(vtkmsg.str()); \
} \
vtkmsg.rdbuf()->freeze(0); vtkObject::BreakOnError(); \
} \
}
//
// This macro is used to print out warnings
// vtkWarningWithObjectMacro(self, "Warning message" << variable);
//
#define vtkWarningWithObjectMacro(self, x) \
{ \
if (vtkObject::GetGlobalWarningDisplay()) \
{ \
vtkOStreamWrapper::EndlType endl; \
vtkOStreamWrapper::UseEndl(endl); \
vtkOStrStreamWrapper vtkmsg; \
vtkmsg << "Warning: In " __FILE__ ", line " << __LINE__ \
<< "\n" << self->GetClassName() << " (" << self \
<< "): " x << "\n\n"; \
if ( self->HasObserver("WarningEvent") ) \
{ \
self->InvokeEvent("WarningEvent", vtkmsg.str()); \
} \
else \
{ \
vtkOutputWindowDisplayWarningText(vtkmsg.str()); \
} \
vtkmsg.rdbuf()->freeze(0); \
} \
}
#ifdef NDEBUG
# define vtkDebugWithObjectMacro(self, x)
#else
# define vtkDebugWithObjectMacro(self, x) \
{ \
if (self->GetDebug() && vtkObject::GetGlobalWarningDisplay()) \
{ \
vtkOStreamWrapper::EndlType endl; \
vtkOStreamWrapper::UseEndl(endl); \
vtkOStrStreamWrapper vtkmsg; \
vtkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << "\n" \
<< self->GetClassName() << " (" << self << "): " x << "\n\n"; \
vtkOutputWindowDisplayDebugText(vtkmsg.str()); \
vtkmsg.rdbuf()->freeze(0); \
} \
}
#endif
//
// This macro is used to quiet compiler warnings about unused parameters
// to methods. Only use it when the parameter really shouldn't be used.
// Don't use it as a way to shut up the compiler while you take your
// sweet time getting around to implementing the method.
//
#define vtkNotUsed(x)
//
// This macro is used for functions which may not be used in a translation unit
// due to different paths taken based on template types. Please give a reason
// why the function may be considered unused (within a translation unit). For
// example, a template specialization might not be used in compiles of sources
// which use different template types.
//
#ifdef __GNUC__
#define vtkMaybeUnused(reason) __attribute__((unused))
#else
#define vtkMaybeUnused(reason)
#endif
#define vtkWorldCoordinateMacro(name) \
virtual vtkCoordinate *Get##name##Coordinate () \
{ \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " #name "Coordinate address " << this->name##Coordinate ); \
return this->name##Coordinate; \
} \
virtual void Set##name(double x[3]) {this->Set##name(x[0],x[1],x[2]);} \
virtual void Set##name(double x, double y, double z) \
{ \
this->name##Coordinate->SetValue(x,y,z); \
} \
virtual double *Get##name() \
{ \
return this->name##Coordinate->GetValue(); \
}
#define vtkViewportCoordinateMacro(name) \
virtual vtkCoordinate *Get##name##Coordinate () \
{ \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " #name "Coordinate address " << this->name##Coordinate ); \
return this->name##Coordinate; \
} \
virtual void Set##name(double x[2]) {this->Set##name(x[0],x[1]);} \
virtual void Set##name(double x, double y) \
{ \
this->name##Coordinate->SetValue(x,y); \
} \
virtual double *Get##name() \
{ \
return this->name##Coordinate->GetValue(); \
}
// Allows definition of vtkObject API such that NewInstance may return a
// superclass of thisClass.
#define vtkAbstractTypeMacroWithNewInstanceType(thisClass,superclass,instanceType,thisClassName) \
protected: \
const char* GetClassNameInternal() const VTK_OVERRIDE \
{ \
return thisClassName; \
} \
public: \
typedef superclass Superclass; \
static vtkTypeBool IsTypeOf(const char *type) \
{ \
if ( !strcmp(thisClassName,type) ) \
{ \
return 1; \
} \
return superclass::IsTypeOf(type); \
} \
vtkTypeBool IsA(const char *type) VTK_OVERRIDE \
{ \
return this->thisClass::IsTypeOf(type); \
} \
static thisClass* SafeDownCast(vtkObjectBase *o) \
{ \
if ( o && o->IsA(thisClassName) ) \
{ \
return static_cast<thisClass *>(o); \
} \
return NULL;\
} \
VTK_NEWINSTANCE instanceType *NewInstance() const \
{ \
return instanceType::SafeDownCast(this->NewInstanceInternal()); \
}
// Same as vtkTypeMacro, but adapted for cases where thisClass is abstract.
#define vtkAbstractTypeMacro(thisClass,superclass) \
vtkAbstractTypeMacroWithNewInstanceType(thisClass, superclass, thisClass, #thisClass) \
public:
// Macro used to determine whether a class is the same class or
// a subclass of the named class.
#define vtkTypeMacro(thisClass,superclass) \
vtkAbstractTypeMacro(thisClass, superclass) \
protected: \
vtkObjectBase *NewInstanceInternal() const VTK_OVERRIDE \
{ \
return thisClass::New(); \
} \
public:
// Macro to use when you are a direct child class of vtkObjectBase, instead
// of vtkTypeMacro. This is required to properly specify NewInstanceInternal
// as a virtual method.
// It is used to determine whether a class is the same class or a subclass
// of the named class.
#define vtkBaseTypeMacro(thisClass,superclass) \
vtkAbstractTypeMacro(thisClass, superclass) \
protected: \
virtual vtkObjectBase *NewInstanceInternal() const \
{ \
return thisClass::New(); \
} \
public:
// Version of vtkAbstractTypeMacro for when thisClass is templated.
// For templates, we use the compiler generated typeid(...).name() identifier
// to distinguish classes. Otherwise, the template parameter names would appear
// in the class name, rather than the actual parameters. The resulting name may
// not be human readable on some platforms, but it will at least be unique. On
// GCC 4.9.2 release builds, this ends up being the same performance-wise as
// returning a string literal as the name() string is resolved at compile time.
//
// If either class has multiple template parameters, the commas will interfere
// with the macro call. In this case, create a typedef to the multi-parameter
// template class and pass that into the macro instead.
#define vtkAbstractTemplateTypeMacro(thisClass,superclass) \
vtkAbstractTypeMacroWithNewInstanceType(thisClass, superclass, thisClass, typeid(thisClass).name()) \
public:
// Version of vtkTypeMacro for when thisClass is templated.
// See vtkAbstractTemplateTypeMacro for more info.
#define vtkTemplateTypeMacro(thisClass,superclass) \
vtkAbstractTemplateTypeMacro(thisClass, superclass) \
protected: \
vtkObjectBase *NewInstanceInternal() const VTK_OVERRIDE \
{ \
return thisClass::New(); \
} \
public:
// Macro to implement the instantiator's wrapper around the New()
// method. Use this macro if and only if vtkStandardNewMacro or
// vtkObjectFactoryNewMacro is not used by the class.
#define vtkInstantiatorNewMacro(thisClass) \
extern vtkObject* vtkInstantiator##thisClass##New(); \
vtkObject* vtkInstantiator##thisClass##New() \
{ \
return thisClass::New(); \
}
// NOTE: This is no longer the prefer method for dispatching an array to a
// worker template. See vtkArrayDispatch for the new approach.
//
// The vtkTemplateMacro is used to centralize the set of types
// supported by Execute methods. It also avoids duplication of long
// switch statement case lists.
//
// This version of the macro allows the template to take any number of
// arguments. Example usage:
// switch(array->GetDataType())
// {
// vtkTemplateMacro(myFunc(static_cast<VTK_TT*>(data), arg2));
// }
#define vtkTemplateMacroCase(typeN, type, call) \
case typeN: { typedef type VTK_TT; call; }; break
#define vtkTemplateMacro(call) \
vtkTemplateMacroCase(VTK_DOUBLE, double, call); \
vtkTemplateMacroCase(VTK_FLOAT, float, call); \
vtkTemplateMacroCase(VTK_LONG_LONG, long long, call); \
vtkTemplateMacroCase(VTK_UNSIGNED_LONG_LONG, unsigned long long, call); \
vtkTemplateMacroCase(VTK_ID_TYPE, vtkIdType, call); \
vtkTemplateMacroCase(VTK_LONG, long, call); \
vtkTemplateMacroCase(VTK_UNSIGNED_LONG, unsigned long, call); \
vtkTemplateMacroCase(VTK_INT, int, call); \
vtkTemplateMacroCase(VTK_UNSIGNED_INT, unsigned int, call); \
vtkTemplateMacroCase(VTK_SHORT, short, call); \
vtkTemplateMacroCase(VTK_UNSIGNED_SHORT, unsigned short, call); \
vtkTemplateMacroCase(VTK_CHAR, char, call); \
vtkTemplateMacroCase(VTK_SIGNED_CHAR, signed char, call); \
vtkTemplateMacroCase(VTK_UNSIGNED_CHAR, unsigned char, call)
// This is same as Template macro with additional case for VTK_STRING.
#define vtkExtendedTemplateMacro(call) \
vtkTemplateMacro(call); \
vtkTemplateMacroCase(VTK_STRING, vtkStdString, call)
// The vtkTemplate2Macro is used to dispatch like vtkTemplateMacro but
// over two template arguments instead of one.
//
// Example usage:
// switch(vtkTemplate2PackMacro(array1->GetDataType(),
// array2->GetDataType()))
// {
// vtkTemplateMacro(myFunc(static_cast<VTK_T1*>(data1),
// static_cast<VTK_T2*>(data2),
// otherArg));
// }
#define vtkTemplate2Macro(call) \
vtkTemplate2MacroCase1(VTK_DOUBLE, double, call); \
vtkTemplate2MacroCase1(VTK_FLOAT, float, call); \
vtkTemplate2MacroCase1(VTK_LONG_LONG, long long, call); \
vtkTemplate2MacroCase1(VTK_UNSIGNED_LONG_LONG, unsigned long long, call); \
vtkTemplate2MacroCase1(VTK_ID_TYPE, vtkIdType, call); \
vtkTemplate2MacroCase1(VTK_LONG, long, call); \
vtkTemplate2MacroCase1(VTK_UNSIGNED_LONG, unsigned long, call); \
vtkTemplate2MacroCase1(VTK_INT, int, call); \
vtkTemplate2MacroCase1(VTK_UNSIGNED_INT, unsigned int, call); \
vtkTemplate2MacroCase1(VTK_SHORT, short, call); \
vtkTemplate2MacroCase1(VTK_UNSIGNED_SHORT, unsigned short, call); \
vtkTemplate2MacroCase1(VTK_CHAR, char, call); \
vtkTemplate2MacroCase1(VTK_SIGNED_CHAR, signed char, call); \
vtkTemplate2MacroCase1(VTK_UNSIGNED_CHAR, unsigned char, call)
#define vtkTemplate2MacroCase1(type1N, type1, call) \
vtkTemplate2MacroCase2(type1N, type1, VTK_DOUBLE, double, call); \
vtkTemplate2MacroCase2(type1N, type1, VTK_FLOAT, float, call); \
vtkTemplate2MacroCase2(type1N, type1, VTK_LONG_LONG, long long, call); \
vtkTemplate2MacroCase2(type1N, type1, VTK_UNSIGNED_LONG_LONG, unsigned long long, call); \
vtkTemplate2MacroCase2(type1N, type1, VTK_ID_TYPE, vtkIdType, call); \
vtkTemplate2MacroCase2(type1N, type1, VTK_LONG, long, call); \
vtkTemplate2MacroCase2(type1N, type1, VTK_UNSIGNED_LONG, unsigned long, call); \
vtkTemplate2MacroCase2(type1N, type1, VTK_INT, int, call); \
vtkTemplate2MacroCase2(type1N, type1, VTK_UNSIGNED_INT, unsigned int, call); \
vtkTemplate2MacroCase2(type1N, type1, VTK_SHORT, short, call); \
vtkTemplate2MacroCase2(type1N, type1, VTK_UNSIGNED_SHORT, unsigned short, call); \
vtkTemplate2MacroCase2(type1N, type1, VTK_CHAR, char, call); \
vtkTemplate2MacroCase2(type1N, type1, VTK_SIGNED_CHAR, signed char, call); \
vtkTemplate2MacroCase2(type1N, type1, VTK_UNSIGNED_CHAR, unsigned char, call)
#define vtkTemplate2MacroCase2(type1N, type1, type2N, type2, call) \
case vtkTemplate2PackMacro(type1N, type2N): { \
typedef type1 VTK_T1; \
typedef type2 VTK_T2; \
call; \
}; break
#define vtkTemplate2PackMacro(type1N, type2N) \
((((type1N) & 0xFF) << 8) | \
((type2N) & 0xFF))
// The vtkArrayIteratorTemplateMacro is used to centralize the set of types
// supported by Execute methods. It also avoids duplication of long
// switch statement case lists.
//
// This version of the macro allows the template to take any number of
// arguments.
//
// Note that in this macro VTK_TT is defined to be the type of the iterator
// for the given type of array. One must include the
// vtkArrayIteratorIncludes.h header file to provide for extending of this macro
// by addition of new iterators.
//
// Example usage:
// vtkArrayIter* iter = array->NewIterator();
// switch(array->GetDataType())
// {
// vtkArrayIteratorTemplateMacro(myFunc(static_cast<VTK_TT*>(iter), arg2));
// }
// iter->Delete();
//
#define vtkArrayIteratorTemplateMacroCase(typeN, type, call) \
vtkTemplateMacroCase(typeN, vtkArrayIteratorTemplate<type>, call)
#define vtkArrayIteratorTemplateMacro(call) \
vtkArrayIteratorTemplateMacroCase(VTK_DOUBLE, double, call); \
vtkArrayIteratorTemplateMacroCase(VTK_FLOAT, float, call); \
vtkArrayIteratorTemplateMacroCase(VTK_LONG_LONG, long long, call); \
vtkArrayIteratorTemplateMacroCase(VTK_UNSIGNED_LONG_LONG, unsigned long long, call); \
vtkArrayIteratorTemplateMacroCase(VTK_ID_TYPE, vtkIdType, call); \
vtkArrayIteratorTemplateMacroCase(VTK_LONG, long, call); \
vtkArrayIteratorTemplateMacroCase(VTK_UNSIGNED_LONG, unsigned long, call); \
vtkArrayIteratorTemplateMacroCase(VTK_INT, int, call); \
vtkArrayIteratorTemplateMacroCase(VTK_UNSIGNED_INT, unsigned int, call); \
vtkArrayIteratorTemplateMacroCase(VTK_SHORT, short, call); \
vtkArrayIteratorTemplateMacroCase(VTK_UNSIGNED_SHORT, unsigned short, call); \
vtkArrayIteratorTemplateMacroCase(VTK_CHAR, char, call); \
vtkArrayIteratorTemplateMacroCase(VTK_SIGNED_CHAR, signed char, call); \
vtkArrayIteratorTemplateMacroCase(VTK_UNSIGNED_CHAR, unsigned char, call); \
vtkArrayIteratorTemplateMacroCase(VTK_STRING, vtkStdString, call); \
vtkTemplateMacroCase(VTK_BIT, vtkBitArrayIterator, call);
//----------------------------------------------------------------------------
// Setup legacy code policy.
// Define VTK_LEGACY macro to mark legacy methods where they are
// declared in their class. Example usage:
//
// // @deprecated Replaced by MyOtherMethod() as of VTK 5.0.
// VTK_LEGACY(void MyMethod());
#if defined(VTK_LEGACY_REMOVE)
// Remove legacy methods completely. Put a bogus declaration in
// place to avoid stray semicolons because this is an error for some
// compilers. Using a class forward declaration allows any number
// of repeats in any context without generating unique names.
# define VTK_LEGACY(method) VTK_LEGACY__0(method,__LINE__)
# define VTK_LEGACY__0(method,line) VTK_LEGACY__1(method,line)
# define VTK_LEGACY__1(method,line) class vtkLegacyMethodRemoved##line
#elif defined(VTK_LEGACY_SILENT) || defined(VTK_WRAPPING_CXX)
// Provide legacy methods with no warnings.
# define VTK_LEGACY(method) method
#else
// Setup compile-time warnings for uses of deprecated methods if
// possible on this compiler.
# if defined(__GNUC__) && !defined(__INTEL_COMPILER)
# define VTK_LEGACY(method) method __attribute__((deprecated))
# elif defined(_MSC_VER)
# define VTK_LEGACY(method) __declspec(deprecated) method
# else
# define VTK_LEGACY(method) method
# endif
#endif
// Macros to create runtime deprecation warning messages in function
// bodies. Example usage:
//
// #if !defined(VTK_LEGACY_REMOVE)
// void vtkMyClass::MyOldMethod()
// {
// VTK_LEGACY_BODY(vtkMyClass::MyOldMethod, "VTK 5.0");
// }
// #endif
//
// #if !defined(VTK_LEGACY_REMOVE)
// void vtkMyClass::MyMethod()
// {
// VTK_LEGACY_REPLACED_BODY(vtkMyClass::MyMethod, "VTK 5.0",
// vtkMyClass::MyOtherMethod);
// }
// #endif
#if defined(VTK_LEGACY_REMOVE) || defined(VTK_LEGACY_SILENT)
# define VTK_LEGACY_BODY(method, version)
# define VTK_LEGACY_REPLACED_BODY(method, version, replace)
#else
# define VTK_LEGACY_BODY(method, version) \
vtkGenericWarningMacro(#method " was deprecated for " version " and will be removed in a future version.")
# define VTK_LEGACY_REPLACED_BODY(method, version, replace) \
vtkGenericWarningMacro(#method " was deprecated for " version " and will be removed in a future version. Use " #replace " instead.")
#endif
// Qualifiers used for function arguments and return types indicating that the
// class is wrapped externally.
#define VTK_WRAP_EXTERN
//----------------------------------------------------------------------------
// Switch case fall-through policy.
// Use "VTK_FALLTHROUGH;" to annotate deliberate fall-through in switches,
// use it analogously to "break;". The trailing semi-colon is required.
#if __cplusplus >= 201103L && defined(__has_warning)
# if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
# define VTK_FALLTHROUGH [[clang::fallthrough]]
# endif
#endif
#ifndef VTK_FALLTHROUGH
# define VTK_FALLTHROUGH ((void)0)
#endif
#endif
// VTK-HeaderTest-Exclude: vtkSetGet.h
|