VTK
dox/Rendering/vtkInteractorObserver.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkInteractorObserver.h
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 =========================================================================*/
00047 #ifndef __vtkInteractorObserver_h
00048 #define __vtkInteractorObserver_h
00049 
00050 #include "vtkObject.h"
00051 
00052 class vtkRenderWindowInteractor;
00053 class vtkRenderer;
00054 class vtkCallbackCommand;
00055 class vtkObserverMediator;
00056 
00057 
00058 class VTK_RENDERING_EXPORT vtkInteractorObserver : public vtkObject
00059 {
00060 public:
00061   vtkTypeMacro(vtkInteractorObserver,vtkObject);
00062   void PrintSelf(ostream& os, vtkIndent indent);
00063 
00065 
00071   virtual void SetEnabled(int) {};
00072   int GetEnabled() {return this->Enabled;}
00073   void EnabledOn() {this->SetEnabled(1);}
00074   void EnabledOff() {this->SetEnabled(0);}
00075   void On() {this->SetEnabled(1);}
00076   void Off() {this->SetEnabled(0);}
00078 
00080 
00085   virtual void SetInteractor(vtkRenderWindowInteractor* iren);
00086   vtkGetObjectMacro(Interactor, vtkRenderWindowInteractor);
00088 
00090 
00098   vtkSetClampMacro(Priority,float,0.0f,1.0f);
00099   vtkGetMacro(Priority,float);
00101 
00103 
00107   vtkSetMacro(KeyPressActivation,int);
00108   vtkGetMacro(KeyPressActivation,int);
00109   vtkBooleanMacro(KeyPressActivation,int);
00111   
00113 
00119   vtkSetMacro(KeyPressActivationValue,char);
00120   vtkGetMacro(KeyPressActivationValue,char);
00122 
00124 
00130   vtkGetObjectMacro(DefaultRenderer,vtkRenderer);
00131   virtual void SetDefaultRenderer(vtkRenderer*);
00133 
00135 
00143   vtkGetObjectMacro(CurrentRenderer,vtkRenderer);
00144   virtual void SetCurrentRenderer(vtkRenderer*);
00146 
00148   virtual void OnChar();
00149   
00151 
00153   static void ComputeDisplayToWorld(vtkRenderer *ren, double x, double y, 
00154                                     double z, double worldPt[4]);
00155   static void ComputeWorldToDisplay(vtkRenderer *ren, double x, double y, 
00156                                     double z, double displayPt[3]);
00158 
00159   //BTX
00161 
00169   void GrabFocus(vtkCommand *mouseEvents, vtkCommand *keypressEvents=NULL);
00170   void ReleaseFocus();
00171   //ETX
00173 
00174 protected:
00175   vtkInteractorObserver();
00176   ~vtkInteractorObserver();
00177 
00179 
00182   virtual void StartInteraction();
00183   virtual void EndInteraction();
00185 
00187 
00189   static void ProcessEvents(vtkObject* object, 
00190                             unsigned long event,
00191                             void* clientdata, 
00192                             void* calldata);
00194 
00196 
00197   void ComputeDisplayToWorld(double x, double y, double z, 
00198                              double worldPt[4]);
00199   void ComputeWorldToDisplay(double x, double y, double z, 
00200                              double displayPt[3]);
00202     
00203   // The state of the widget, whether on or off (observing events or not)
00204   int Enabled;
00205   
00206   // Used to process events
00207   vtkCallbackCommand* EventCallbackCommand; //subclasses use one
00208   vtkCallbackCommand* KeyPressCallbackCommand; //listens to key activation
00209 
00210   // Priority at which events are processed
00211   float Priority;
00212 
00213   // Keypress activation controls
00214   int KeyPressActivation;
00215   char KeyPressActivationValue;
00216 
00217   // Used to associate observers with the interactor
00218   vtkRenderWindowInteractor *Interactor;
00219   
00220   // Internal ivars for processing events
00221   vtkRenderer *CurrentRenderer;
00222   vtkRenderer *DefaultRenderer;
00223 
00224   unsigned long CharObserverTag;
00225   unsigned long DeleteObserverTag;
00226 
00227   // The mediator used to request resources from the interactor.
00228   vtkObserverMediator *ObserverMediator;
00229   int RequestCursorShape(int requestedShape);
00230 
00231 private:
00232   vtkInteractorObserver(const vtkInteractorObserver&);  // Not implemented.
00233   void operator=(const vtkInteractorObserver&);  // Not implemented.
00234   
00235 };
00236 
00237 #endif