vtkSlicerComponentGUI.h

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 #ifndef __vtkSlicerComponentGUI_h
00012 #define __vtkSlicerComponentGUI_h
00013 
00014 #include "vtkObject.h"
00015 #include "vtkKWObject.h"
00016 #include "vtkSlicerBaseGUIWin32Header.h"
00017 #include "vtkSlicerApplicationLogic.h"
00018 #include "vtkMRMLScene.h"
00019 #include "vtkMRMLNode.h"
00020 #include "vtkSlicerLogic.h"
00021 #include "vtkObserverManager.h"
00022 
00023 
00024 class vtkCallbackCommmand;
00025 class vtkSlicerGUIUpdate;
00026 class vtkSlicerLogicUpdate;
00027 class vtkSlicerMRMLUpdate;
00028 class vtkKWApplication;
00029 class vtkKWFrame;
00030 
00031 
00032 //BTX
00033 
00034 #ifndef vtkSetMRMLNodeMacro
00035 #define vtkSetMRMLNodeMacro(node,value)  { \
00036   vtkObject *oldNode = (node); \
00037   this->MRMLObserverManager->SetObject ( vtkObjectPointer( &(node)), (value) ); \
00038   if ( oldNode != (node) ) \
00039     { \
00040     this->InvokeEvent (vtkCommand::ModifiedEvent); \
00041     } \
00042 };
00043 #endif
00044 
00045 #ifndef vtkSetAndObserveMRMLNodeMacro
00046 #define vtkSetAndObserveMRMLNodeMacro(node,value)  { \
00047   vtkObject *oldNode = (node); \
00048   this->MRMLObserverManager->SetAndObserveObject ( vtkObjectPointer( &(node) ), (value) ); \
00049   if ( oldNode != (node) ) \
00050     { \
00051     this->InvokeEvent (vtkCommand::ModifiedEvent); \
00052     } \
00053 };
00054 #endif
00055 
00056 #ifndef vtkSetAndObserveMRMLNodeEventsMacro
00057 #define vtkSetAndObserveMRMLNodeEventsMacro(node,value,events)  { \
00058   vtkObject *oldNode = (node); \
00059   this->MRMLObserverManager->SetAndObserveObjectEvents ( vtkObjectPointer( &(node)), (value), (events)); \
00060   if ( oldNode != (node) ) \
00061     { \
00062     this->InvokeEvent (vtkCommand::ModifiedEvent); \
00063     } \
00064 };
00065 #endif
00066 
00067 //ETX
00068 
00072 //
00073 class VTK_SLICER_BASE_GUI_EXPORT vtkSlicerComponentGUI : public vtkKWObject
00074 {
00075 
00076 public:
00078   static vtkSlicerComponentGUI* New ( );
00079   vtkTypeRevisionMacro ( vtkSlicerComponentGUI, vtkKWObject );
00080   void PrintSelf ( ostream& os, vtkIndent indent );
00081 
00084   vtkGetObjectMacro ( ApplicationLogic, vtkSlicerApplicationLogic );
00085   virtual void SetApplicationLogic ( vtkSlicerApplicationLogic *logic )
00086     { this->SetLogic ( vtkObjectPointer (&this->ApplicationLogic), logic );};
00087   void SetAndObserveApplicationLogic ( vtkSlicerApplicationLogic *logic )
00088     { this->SetAndObserveLogic ( vtkObjectPointer (&this->ApplicationLogic) , logic ); };
00089 
00093   vtkGetObjectMacro ( MRMLScene, vtkMRMLScene );
00094   
00097   void SetMRMLScene ( vtkMRMLScene *mrml )
00098     {
00099     vtkObject *oldValue = this->MRMLScene;
00100     this->MRMLObserverManager->SetObject ( vtkObjectPointer( &this->MRMLScene), mrml );
00101     if ( oldValue != this->MRMLScene )
00102       {
00103       this->InvokeEvent (vtkCommand::ModifiedEvent);
00104       }
00105     }
00106 
00107   void SetAndObserveMRMLScene ( vtkMRMLScene *mrml )
00108     {
00109     vtkObject *oldValue = this->MRMLScene;
00110     this->MRMLObserverManager->SetAndObserveObject ( vtkObjectPointer( &this->MRMLScene), mrml );
00111     if ( oldValue != this->MRMLScene )
00112       {
00113       this->InvokeEvent (vtkCommand::ModifiedEvent);
00114       }
00115     }
00116 
00117   void SetAndObserveMRMLSceneEvents ( vtkMRMLScene *mrml, vtkIntArray *events )
00118     {
00119     vtkObject *oldValue = this->MRMLScene;
00120     this->MRMLObserverManager->SetAndObserveObjectEvents ( vtkObjectPointer( &this->MRMLScene), mrml, events );
00121     if ( oldValue != this->MRMLScene )
00122       {
00123       this->InvokeEvent (vtkCommand::ModifiedEvent);
00124       }
00125     }
00126   
00127   void SetLogic ( vtkObject **logicPtr, vtkObject *logic );
00128   void SetAndObserveLogic ( vtkObject **logicPtr, vtkObject *logic );
00129   
00132   virtual void AddGUIObservers ( ) { };
00133   virtual void RemoveGUIObservers ( ) { };
00134   
00138   vtkGetObjectMacro (LogicCallbackCommand, vtkCallbackCommand);
00139   vtkGetObjectMacro (GUICallbackCommand, vtkCallbackCommand);
00140   
00144   void SetInLogicCallbackFlag (int flag) {
00145     this->InLogicCallbackFlag = flag;
00146   }
00147   vtkGetMacro(InLogicCallbackFlag, int);
00148   void SetInMRMLCallbackFlag (int flag) {
00149     this->InMRMLCallbackFlag = flag;
00150   }
00151   vtkGetMacro(InMRMLCallbackFlag, int);
00152   void SetInGUICallbackFlag (int flag) {
00153     this->InGUICallbackFlag = flag;
00154     }
00155   vtkGetMacro(InGUICallbackFlag, int);
00156   
00159   vtkSetStringMacro ( GUIName );
00160   vtkGetStringMacro ( GUIName );
00161   
00165   virtual void BuildGUI ( void ) { }
00166   virtual void BuildGUI ( vtkKWFrame * vtkNotUsed(f) ) {}
00167   virtual void BuildGUI ( vtkKWFrame * vtkNotUsed(f), double * vtkNotUsed(bgColor) ) {}
00168 
00172   virtual void TearDownGUI ( ) { };
00173   
00176   virtual void ProcessLogicEvents ( vtkObject * /*caller*/,
00177                                     unsigned long /*event*/, void * /*callData*/ ) { };
00180   virtual void ProcessGUIEvents ( vtkObject * /*caller*/, 
00181                                   unsigned long /*event*/, void * /*callData*/ ) { };
00182   
00185   virtual void ProcessMRMLEvents ( vtkObject * /*caller*/, 
00186                                    unsigned long /*event*/, void * /*callData*/ ) { };
00187   
00194   virtual void Enter ( ) { }
00195   virtual void Exit ( ) { }
00196   virtual void Enter ( vtkMRMLNode* vtkNotUsed(node) ) { this->Enter(); }
00197   
00198 protected:
00200   vtkSlicerApplicationLogic *ApplicationLogic;
00201   vtkMRMLScene *MRMLScene;
00202   
00204   char *GUIName;
00205   
00206   //BTX
00211   static void MRMLCallback( vtkObject *__caller,
00212                             unsigned long eid, void *__clientData, void *callData );
00213   static void LogicCallback( vtkObject *__caller,
00214                              unsigned long eid, void *__clientData, void *callData );
00215   static void GUICallback( vtkObject *__caller,
00216                            unsigned long eid, void *__clientData, void *callData );    
00217   //ETX
00218   
00221   vtkCallbackCommand *LogicCallbackCommand;
00222   vtkCallbackCommand *GUICallbackCommand;
00223   vtkCallbackCommand *MRMLCallbackCommand;
00224   
00226   vtkSlicerComponentGUI ( );
00227   virtual ~vtkSlicerComponentGUI ( );
00228   
00231   int InLogicCallbackFlag;
00232   int InMRMLCallbackFlag;
00233   int InGUICallbackFlag;
00234   
00235   vtkObserverManager *MRMLObserverManager;
00236   
00237 private:
00238   vtkSlicerComponentGUI ( const vtkSlicerComponentGUI& ); 
00239   void operator = ( const vtkSlicerComponentGUI& ); 
00240 };
00241 
00242 
00243 #endif
00244 
00245 

Generated on 6 Apr 2011 for Slicer3 by  doxygen 1.6.1