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

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 =========================================================================*/
00055 #ifndef __vtkInteractorObserver_h
00056 #define __vtkInteractorObserver_h
00057 
00058 #include "vtkObject.h"
00059 
00060 class vtkRenderWindowInteractor;
00061 class vtkRenderer;
00062 class vtkCallbackCommand;
00063 
00064 class VTK_RENDERING_EXPORT vtkInteractorObserver : public vtkObject
00065 {
00066 public:
00067   vtkTypeRevisionMacro(vtkInteractorObserver,vtkObject);
00068   void PrintSelf(ostream& os, vtkIndent indent);
00069 
00071 
00077   virtual void SetEnabled(int) {};
00078   int GetEnabled() {return this->Enabled;}
00079   void EnabledOn() {this->SetEnabled(1);}
00080   void EnabledOff() {this->SetEnabled(0);}
00081   void On() {this->SetEnabled(1);}
00082   void Off() {this->SetEnabled(0);}
00084 
00086 
00091   virtual void SetInteractor(vtkRenderWindowInteractor* iren);
00092   vtkGetObjectMacro(Interactor, vtkRenderWindowInteractor);
00094 
00096 
00104   vtkSetClampMacro(Priority,float,0.0f,1.0f);
00105   vtkGetMacro(Priority,float);
00107 
00109 
00113   vtkSetMacro(KeyPressActivation,int);
00114   vtkGetMacro(KeyPressActivation,int);
00115   vtkBooleanMacro(KeyPressActivation,int);
00117   
00119 
00125   vtkSetMacro(KeyPressActivationValue,char);
00126   vtkGetMacro(KeyPressActivationValue,char);
00128 
00130 
00136   vtkGetObjectMacro(DefaultRenderer,vtkRenderer);
00137   virtual void SetDefaultRenderer(vtkRenderer*);
00139 
00141 
00149   vtkGetObjectMacro(CurrentRenderer,vtkRenderer);
00150   virtual void SetCurrentRenderer(vtkRenderer*);
00152 
00153   // Sets up the keypress-i event. 
00154   virtual void OnChar();
00155   
00156 protected:
00157   vtkInteractorObserver();
00158   ~vtkInteractorObserver();
00159 
00161 
00164   virtual void StartInteraction();
00165   virtual void EndInteraction();
00167 
00169 
00171   static void ProcessEvents(vtkObject* object, 
00172                             unsigned long event,
00173                             void* clientdata, 
00174                             void* calldata);
00176 
00178 
00179   void ComputeDisplayToWorld(double x, double y, double z, 
00180                              double worldPt[4]);
00181   void ComputeWorldToDisplay(double x, double y, double z, 
00182                              double displayPt[3]);
00184     
00185   // The state of the widget, whether on or off (observing events or not)
00186   int Enabled;
00187   
00188   // Used to process events
00189   vtkCallbackCommand* EventCallbackCommand; //subclasses use one
00190   vtkCallbackCommand* KeyPressCallbackCommand; //listens to key activation
00191 
00192   // Priority at which events are processed
00193   float Priority;
00194 
00195   // Keypress activation controls
00196   int KeyPressActivation;
00197   char KeyPressActivationValue;
00198 
00199   // Used to associate observers with the interactor
00200   vtkRenderWindowInteractor *Interactor;
00201   
00202   // Internal ivars for processing events
00203   vtkRenderer *CurrentRenderer;
00204   vtkRenderer *DefaultRenderer;
00205 
00206   unsigned long CharObserverTag;
00207   unsigned long DeleteObserverTag;
00208 
00209 private:
00210   vtkInteractorObserver(const vtkInteractorObserver&);  // Not implemented.
00211   void operator=(const vtkInteractorObserver&);  // Not implemented.
00212   
00213 };
00214 
00215 #endif