VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkObject.h,v $ 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00046 #ifndef __vtkObject_h 00047 #define __vtkObject_h 00048 00049 #include "vtkObjectBase.h" 00050 #include "vtkSetGet.h" 00051 #include "vtkTimeStamp.h" 00052 00053 class vtkSubjectHelper; 00054 class vtkCommand; 00055 00056 class VTK_COMMON_EXPORT vtkObject : public vtkObjectBase 00057 { 00058 public: 00059 vtkTypeRevisionMacro(vtkObject,vtkObjectBase); 00060 00063 static vtkObject *New(); 00064 00065 #ifdef _WIN32 00066 // avoid dll boundary problems 00067 void* operator new( size_t tSize ); 00068 void operator delete( void* p ); 00069 #endif 00070 00072 virtual void DebugOn(); 00073 00075 virtual void DebugOff(); 00076 00078 unsigned char GetDebug(); 00079 00081 void SetDebug(unsigned char debugFlag); 00082 00085 static void BreakOnError(); 00086 00091 virtual void Modified(); 00092 00094 virtual unsigned long GetMTime(); 00095 00100 virtual void PrintSelf(ostream& os, vtkIndent indent); 00101 00103 00105 static void SetGlobalWarningDisplay(int val); 00106 static void GlobalWarningDisplayOn(){vtkObject::SetGlobalWarningDisplay(1);}; 00107 static void GlobalWarningDisplayOff() 00108 {vtkObject::SetGlobalWarningDisplay(0);}; 00109 static int GetGlobalWarningDisplay(); 00111 00113 00122 unsigned long AddObserver(unsigned long event, vtkCommand *, 00123 float priority=0.0f); 00124 unsigned long AddObserver(const char *event, vtkCommand *, 00125 float priority=0.0f); 00126 vtkCommand *GetCommand(unsigned long tag); 00127 void RemoveObserver(vtkCommand*); 00128 void RemoveObservers(unsigned long event, vtkCommand *); 00129 void RemoveObservers(const char *event, vtkCommand *); 00130 int HasObserver(unsigned long event, vtkCommand *); 00131 int HasObserver(const char *event, vtkCommand *); 00132 //ETX 00133 void RemoveObserver(unsigned long tag); 00134 void RemoveObservers(unsigned long event); 00135 void RemoveObservers(const char *event); 00136 void RemoveAllObservers(); //remove every last one of them 00137 int HasObserver(unsigned long event); 00138 int HasObserver(const char *event); 00140 00151 // This method invokes an event and return whether the event was 00152 // aborted or not. If the event was aborted, the return value is 1, 00153 // otherwise it is 0. 00154 //BTX 00155 int InvokeEvent(unsigned long event, void *callData); 00156 int InvokeEvent(const char *event, void *callData); 00157 //ETX 00158 int InvokeEvent(unsigned long event) { return this->InvokeEvent(event, NULL); }; 00159 int InvokeEvent(const char *event) { return this->InvokeEvent(event, NULL); }; 00160 00161 protected: 00162 vtkObject(); 00163 virtual ~vtkObject(); 00164 00165 // See vtkObjectBase.h. 00166 virtual void RegisterInternal(vtkObjectBase*, int check); 00167 virtual void UnRegisterInternal(vtkObjectBase*, int check); 00168 00169 unsigned char Debug; // Enable debug messages 00170 vtkTimeStamp MTime; // Keep track of modification time 00171 vtkSubjectHelper *SubjectHelper; // List of observers on this object 00172 00174 00181 void InternalGrabFocus(vtkCommand *mouseEvents, vtkCommand *keypressEvents=NULL); 00182 void InternalReleaseFocus(); 00183 //ETX 00185 00186 private: 00187 vtkObject(const vtkObject&); // Not implemented. 00188 void operator=(const vtkObject&); // Not implemented. 00189 }; 00190 00191 #endif 00192