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 //
550 // This macro is used for functions which may not be used in a translation unit
551 // due to different paths taken based on template types. Please give a reason
552 // why the function may be considered unused (within a translation unit). For
553 // example, a template specialization might not be used in compiles of sources
554 // which use different template types.
555 //
556 #ifdef __GNUC__
557 #define vtkMaybeUnused(reason) __attribute__((unused))
558 #else
559 #define vtkMaybeUnused(reason)
560 #endif
561 
562 #define vtkWorldCoordinateMacro(name) \
563 virtual vtkCoordinate *Get##name##Coordinate () \
564 { \
565  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " #name "Coordinate address " << this->name##Coordinate ); \
566  return this->name##Coordinate; \
567 } \
568 virtual void Set##name(double x[3]) {this->Set##name(x[0],x[1],x[2]);}; \
569 virtual void Set##name(double x, double y, double z) \
570 { \
571  this->name##Coordinate->SetValue(x,y,z); \
572 } \
573 virtual double *Get##name() \
574 { \
575  return this->name##Coordinate->GetValue(); \
576 }
577 
578 #define vtkViewportCoordinateMacro(name) \
579 virtual vtkCoordinate *Get##name##Coordinate () \
580 { \
581  vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " #name "Coordinate address " << this->name##Coordinate ); \
582  return this->name##Coordinate; \
583 } \
584 virtual void Set##name(double x[2]) {this->Set##name(x[0],x[1]);}; \
585 virtual void Set##name(double x, double y) \
586 { \
587  this->name##Coordinate->SetValue(x,y); \
588 } \
589 virtual double *Get##name() \
590 { \
591  return this->name##Coordinate->GetValue(); \
592 }
593 
594 // Allows definition of vtkObject API such that NewInstance may return a
595 // superclass of thisClass.
596 #define vtkAbstractTypeMacroWithNewInstanceType(thisClass,superclass,instanceType) \
597  typedef superclass Superclass; \
598  private: \
599  virtual const char* GetClassNameInternal() const { return #thisClass; } \
600  public: \
601  static int IsTypeOf(const char *type) \
602  { \
603  if ( !strcmp(#thisClass,type) ) \
604  { \
605  return 1; \
606  } \
607  return superclass::IsTypeOf(type); \
608  } \
609  virtual int IsA(const char *type) \
610  { \
611  return this->thisClass::IsTypeOf(type); \
612  } \
613  static thisClass* SafeDownCast(vtkObjectBase *o) \
614  { \
615  if ( o && o->IsA(#thisClass) ) \
616  { \
617  return static_cast<thisClass *>(o); \
618  } \
619  return NULL;\
620  } \
621  instanceType *NewInstance() const \
622  { \
623  return instanceType::SafeDownCast(this->NewInstanceInternal()); \
624  }
625 
626 // Same as vtkTypeMacro, but adapted for cases where thisClass is abstact.
627 #define vtkAbstractTypeMacro(thisClass,superclass) \
628  vtkAbstractTypeMacroWithNewInstanceType(thisClass, superclass, thisClass)
629 
630 // Macro used to determine whether a class is the same class or
631 // a subclass of the named class.
632 #define vtkTypeMacro(thisClass,superclass) \
633  vtkAbstractTypeMacro(thisClass, superclass) \
634  protected: \
635  virtual vtkObjectBase *NewInstanceInternal() const \
636  { \
637  return thisClass::New(); \
638  } \
639  public:
640 
641 // Legacy versions of vtkTypeMacro and helpers.
642 #if !defined(VTK_LEGACY_REMOVE)
643 # define vtkExportedTypeRevisionMacro(thisClass,superclass,dllExport) \
644  vtkTypeMacro(thisClass,superclass)
645 # define vtkTypeRevisionMacro(thisClass,superclass) \
646  vtkTypeMacro(thisClass,superclass)
647 # define vtkCxxRevisionMacro(thisClass, revision)
648 #endif
649 
650 // Macro to implement the instantiator's wrapper around the New()
651 // method. Use this macro if and only if vtkStandardNewMacro or
652 // vtkObjectFactoryNewMacro is not used by the class.
653 #define vtkInstantiatorNewMacro(thisClass) \
654  extern vtkObject* vtkInstantiator##thisClass##New(); \
655  vtkObject* vtkInstantiator##thisClass##New() \
656  { \
657  return thisClass::New(); \
658  }
659 
660 // The vtkTemplateMacro is used to centralize the set of types
661 // supported by Execute methods. It also avoids duplication of long
662 // switch statement case lists.
663 //
664 // This version of the macro allows the template to take any number of
665 // arguments. Example usage:
666 // switch(array->GetDataType())
667 // {
668 // vtkTemplateMacro(myFunc(static_cast<VTK_TT*>(data), arg2));
669 // }
670 #define vtkTemplateMacroCase(typeN, type, call) \
671  case typeN: { typedef type VTK_TT; call; }; break
672 #define vtkTemplateMacro(call) \
673  vtkTemplateMacroCase(VTK_DOUBLE, double, call); \
674  vtkTemplateMacroCase(VTK_FLOAT, float, call); \
675  vtkTemplateMacroCase_ll(VTK_LONG_LONG, long long, call) \
676  vtkTemplateMacroCase_ll(VTK_UNSIGNED_LONG_LONG, unsigned long long, call) \
677  vtkTemplateMacroCase_si64(VTK___INT64, __int64, call) \
678  vtkTemplateMacroCase_ui64(VTK_UNSIGNED___INT64, unsigned __int64, call) \
679  vtkTemplateMacroCase(VTK_ID_TYPE, vtkIdType, call); \
680  vtkTemplateMacroCase(VTK_LONG, long, call); \
681  vtkTemplateMacroCase(VTK_UNSIGNED_LONG, unsigned long, call); \
682  vtkTemplateMacroCase(VTK_INT, int, call); \
683  vtkTemplateMacroCase(VTK_UNSIGNED_INT, unsigned int, call); \
684  vtkTemplateMacroCase(VTK_SHORT, short, call); \
685  vtkTemplateMacroCase(VTK_UNSIGNED_SHORT, unsigned short, call); \
686  vtkTemplateMacroCase(VTK_CHAR, char, call); \
687  vtkTemplateMacroCase(VTK_SIGNED_CHAR, signed char, call); \
688  vtkTemplateMacroCase(VTK_UNSIGNED_CHAR, unsigned char, call)
689 
690 // This is same as Template macro with additional case for VTK_STRING.
691 #define vtkExtendedTemplateMacro(call) \
692  vtkTemplateMacro(call); \
693  vtkTemplateMacroCase(VTK_STRING, vtkStdString, call)
694 
695 // The vtkArrayIteratorTemplateMacro is used to centralize the set of types
696 // supported by Execute methods. It also avoids duplication of long
697 // switch statement case lists.
698 //
699 // This version of the macro allows the template to take any number of
700 // arguments.
701 //
702 // Note that in this macro VTK_TT is defined to be the type of the iterator
703 // for the given type of array. One must include the
704 // vtkArrayIteratorIncludes.h header file to provide for extending of this macro
705 // by addition of new iterators.
706 //
707 // Example usage:
708 // vtkArrayIter* iter = array->NewIterator();
709 // switch(array->GetDataType())
710 // {
711 // vtkArrayIteratorTemplateMacro(myFunc(static_cast<VTK_TT*>(iter), arg2));
712 // }
713 // iter->Delete();
714 //
715 #define vtkArrayIteratorTemplateMacroCase(typeN, type, call) \
716  vtkTemplateMacroCase(typeN, vtkArrayIteratorTemplate<type>, call)
717 #define vtkArrayIteratorTemplateMacro(call) \
718  vtkArrayIteratorTemplateMacroCase(VTK_DOUBLE, double, call); \
719  vtkArrayIteratorTemplateMacroCase(VTK_FLOAT, float, call); \
720  vtkArrayIteratorTemplateMacroCase_ll(VTK_LONG_LONG, long long, call); \
721  vtkArrayIteratorTemplateMacroCase_ll(VTK_UNSIGNED_LONG_LONG, unsigned long long, call);\
722  vtkArrayIteratorTemplateMacroCase_si64(VTK___INT64, __int64, call); \
723  vtkArrayIteratorTemplateMacroCase_ui64(VTK_UNSIGNED___INT64, unsigned __int64, call); \
724  vtkArrayIteratorTemplateMacroCase(VTK_ID_TYPE, vtkIdType, call); \
725  vtkArrayIteratorTemplateMacroCase(VTK_LONG, long, call); \
726  vtkArrayIteratorTemplateMacroCase(VTK_UNSIGNED_LONG, unsigned long, call); \
727  vtkArrayIteratorTemplateMacroCase(VTK_INT, int, call); \
728  vtkArrayIteratorTemplateMacroCase(VTK_UNSIGNED_INT, unsigned int, call); \
729  vtkArrayIteratorTemplateMacroCase(VTK_SHORT, short, call); \
730  vtkArrayIteratorTemplateMacroCase(VTK_UNSIGNED_SHORT, unsigned short, call); \
731  vtkArrayIteratorTemplateMacroCase(VTK_CHAR, char, call); \
732  vtkArrayIteratorTemplateMacroCase(VTK_SIGNED_CHAR, signed char, call); \
733  vtkArrayIteratorTemplateMacroCase(VTK_UNSIGNED_CHAR, unsigned char, call); \
734  vtkArrayIteratorTemplateMacroCase(VTK_STRING, vtkStdString, call); \
735  vtkTemplateMacroCase(VTK_BIT, vtkBitArrayIterator, call);
736 
737 // Add "long long" to the template macro if it is enabled.
738 #if defined(VTK_TYPE_USE_LONG_LONG)
739 # define vtkTemplateMacroCase_ll(typeN, type, call) \
740  vtkTemplateMacroCase(typeN, type, call);
741 # define vtkArrayIteratorTemplateMacroCase_ll(typeN, type, call) \
742  vtkArrayIteratorTemplateMacroCase(typeN, type, call)
743 #else
744 # define vtkTemplateMacroCase_ll(typeN, type, call)
745 # define vtkArrayIteratorTemplateMacroCase_ll(typeN, type, call)
746 #endif
747 
748 // Add "__int64" to the template macro if it is enabled.
749 #if defined(VTK_TYPE_USE___INT64)
750 # define vtkTemplateMacroCase_si64(typeN, type, call) \
751  vtkTemplateMacroCase(typeN, type, call);
752 # define vtkArrayIteratorTemplateMacroCase_si64(typeN, type, call) \
753  vtkArrayIteratorTemplateMacroCase(typeN, type, call)
754 #else
755 # define vtkTemplateMacroCase_si64(typeN, type, call)
756 # define vtkArrayIteratorTemplateMacroCase_si64(typeN, type, call)
757 #endif
758 
759 // Add "unsigned __int64" to the template macro if it is enabled and
760 // can be converted to double.
761 #if defined(VTK_TYPE_USE___INT64) && defined(VTK_TYPE_CONVERT_UI64_TO_DOUBLE)
762 # define vtkTemplateMacroCase_ui64(typeN, type, call) \
763  vtkTemplateMacroCase(typeN, type, call);
764 # define vtkArrayIteratorTemplateMacroCase_ui64(typeN, type, call) \
765  vtkArrayIteratorTemplateMacroCase(typeN, type, call);
766 #else
767 # define vtkTemplateMacroCase_ui64(typeN, type, call)
768 # define vtkArrayIteratorTemplateMacroCase_ui64(typeN, type, call)
769 #endif
770 
771 //----------------------------------------------------------------------------
772 // Setup legacy code policy.
773 
774 // Define VTK_LEGACY macro to mark legacy methods where they are
775 // declared in their class. Example usage:
776 //
777 // // @deprecated Replaced by MyOtherMethod() as of VTK 5.0.
778 // VTK_LEGACY(void MyMethod());
779 #if defined(VTK_LEGACY_REMOVE)
780  // Remove legacy methods completely. Put a bogus declaration in
781  // place to avoid stray semicolons because this is an error for some
782  // compilers. Using a class forward declaration allows any number
783  // of repeats in any context without generating unique names.
784 
785 # define VTK_LEGACY(method) VTK_LEGACY__0(method,__LINE__)
786 # define VTK_LEGACY__0(method,line) VTK_LEGACY__1(method,line)
787 # define VTK_LEGACY__1(method,line) class vtkLegacyMethodRemoved##line
788 
789 #elif defined(VTK_LEGACY_SILENT) || defined(VTK_WRAPPING_CXX)
790  // Provide legacy methods with no warnings.
791 # define VTK_LEGACY(method) method
792 #else
793  // Setup compile-time warnings for uses of deprecated methods if
794  // possible on this compiler.
795 # if defined(__GNUC__) && !defined(__INTEL_COMPILER) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
796 # define VTK_LEGACY(method) method __attribute__((deprecated))
797 # elif defined(_MSC_VER)
798 # define VTK_LEGACY(method) __declspec(deprecated) method
799 # else
800 # define VTK_LEGACY(method) method
801 # endif
802 #endif
803 
804 // Macros to create runtime deprecation warning messages in function
805 // bodies. Example usage:
806 //
807 // #if !defined(VTK_LEGACY_REMOVE)
808 // void vtkMyClass::MyOldMethod()
809 // {
810 // VTK_LEGACY_BODY(vtkMyClass::MyOldMethod, "VTK 5.0");
811 // }
812 // #endif
813 //
814 // #if !defined(VTK_LEGACY_REMOVE)
815 // void vtkMyClass::MyMethod()
816 // {
817 // VTK_LEGACY_REPLACED_BODY(vtkMyClass::MyMethod, "VTK 5.0",
818 // vtkMyClass::MyOtherMethod);
819 // }
820 // #endif
821 #if defined(VTK_LEGACY_REMOVE) || defined(VTK_LEGACY_SILENT)
822 # define VTK_LEGACY_BODY(method, version)
823 # define VTK_LEGACY_REPLACED_BODY(method, version, replace)
824 #else
825 # define VTK_LEGACY_BODY(method, version) \
826  vtkGenericWarningMacro(#method " was deprecated for " version " and will be removed in a future version.")
827 # define VTK_LEGACY_REPLACED_BODY(method, version, replace) \
828  vtkGenericWarningMacro(#method " was deprecated for " version " and will be removed in a future version. Use " #replace " instead.")
829 #endif
830 
831 // Qualifiers used for function arguments and return types indicating that the
832 // class is wrapped externally.
833 #define VTK_WRAP_EXTERN
834 
835 #endif
836 // 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 *)