Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Rendering/vtkInteractorObserver.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkInteractorObserver.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 =========================================================================*/
00043 #ifndef __vtkInteractorObserver_h
00044 #define __vtkInteractorObserver_h
00045 
00046 #include "vtkObject.h"
00047 
00048 class vtkRenderWindowInteractor;
00049 class vtkRenderer;
00050 class vtkCallbackCommand;
00051 
00052 class VTK_RENDERING_EXPORT vtkInteractorObserver : public vtkObject
00053 {
00054 public:
00055   vtkTypeRevisionMacro(vtkInteractorObserver,vtkObject);
00056   void PrintSelf(ostream& os, vtkIndent indent);
00057 
00059 
00065   virtual void SetEnabled(int) {};
00066   int GetEnabled() {return this->Enabled;}
00067   void EnabledOn() {this->SetEnabled(1);}
00068   void EnabledOff() {this->SetEnabled(0);}
00069   void On() {this->SetEnabled(1);}
00070   void Off() {this->SetEnabled(0);}
00072 
00074 
00079   virtual void SetInteractor(vtkRenderWindowInteractor* iren);
00080   vtkGetObjectMacro(Interactor, vtkRenderWindowInteractor);
00082 
00084 
00092   vtkSetClampMacro(Priority,float,0.0f,1.0f);
00093   vtkGetMacro(Priority,float);
00095 
00097 
00101   vtkSetMacro(KeyPressActivation,int);
00102   vtkGetMacro(KeyPressActivation,int);
00103   vtkBooleanMacro(KeyPressActivation,int);
00105   
00107 
00113   vtkSetMacro(KeyPressActivationValue,char);
00114   vtkGetMacro(KeyPressActivationValue,char);
00116 
00118 
00124   vtkGetObjectMacro(DefaultRenderer,vtkRenderer);
00125   virtual void SetDefaultRenderer(vtkRenderer*);
00127 
00129 
00137   vtkGetObjectMacro(CurrentRenderer,vtkRenderer);
00138   virtual void SetCurrentRenderer(vtkRenderer*);
00140 
00141   // Sets up the keypress-i event. 
00142   virtual void OnChar();
00143   
00144 protected:
00145   vtkInteractorObserver();
00146   ~vtkInteractorObserver();
00147 
00149 
00152   virtual void StartInteraction();
00153   virtual void EndInteraction();
00155 
00157 
00159   static void ProcessEvents(vtkObject* object, 
00160                             unsigned long event,
00161                             void* clientdata, 
00162                             void* calldata);
00164 
00166 
00167   void ComputeDisplayToWorld(double x, double y, double z, 
00168                              double worldPt[4]);
00169   void ComputeWorldToDisplay(double x, double y, double z, 
00170                              double displayPt[3]);
00172     
00173   // The state of the widget, whether on or off (observing events or not)
00174   int Enabled;
00175   
00176   // Used to process events
00177   vtkCallbackCommand* EventCallbackCommand; //subclasses use one
00178   vtkCallbackCommand* KeyPressCallbackCommand; //listens to key activation
00179 
00180   // Priority at which events are processed
00181   float Priority;
00182 
00183   // Keypress activation controls
00184   int KeyPressActivation;
00185   char KeyPressActivationValue;
00186 
00187   // Used to associate observers with the interactor
00188   vtkRenderWindowInteractor *Interactor;
00189   
00190   // Internal ivars for processing events
00191   vtkRenderer *CurrentRenderer;
00192   vtkRenderer *DefaultRenderer;
00193 
00194 private:
00195   vtkInteractorObserver(const vtkInteractorObserver&);  // Not implemented.
00196   void operator=(const vtkInteractorObserver&);  // Not implemented.
00197   
00198 };
00199 
00200 #endif