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