VTK
|
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 00160 00168 void GrabFocus(vtkCommand *mouseEvents, vtkCommand *keypressEvents=NULL); 00169 void ReleaseFocus(); 00170 //ETX 00172 00173 protected: 00174 vtkInteractorObserver(); 00175 ~vtkInteractorObserver(); 00176 00178 00181 virtual void StartInteraction(); 00182 virtual void EndInteraction(); 00184 00186 00188 static void ProcessEvents(vtkObject* object, 00189 unsigned long event, 00190 void* clientdata, 00191 void* calldata); 00193 00195 00196 void ComputeDisplayToWorld(double x, double y, double z, 00197 double worldPt[4]); 00198 void ComputeWorldToDisplay(double x, double y, double z, 00199 double displayPt[3]); 00201 00202 // The state of the widget, whether on or off (observing events or not) 00203 int Enabled; 00204 00205 // Used to process events 00206 vtkCallbackCommand* EventCallbackCommand; //subclasses use one 00207 vtkCallbackCommand* KeyPressCallbackCommand; //listens to key activation 00208 00209 // Priority at which events are processed 00210 float Priority; 00211 00212 // Keypress activation controls 00213 int KeyPressActivation; 00214 char KeyPressActivationValue; 00215 00216 // Used to associate observers with the interactor 00217 vtkRenderWindowInteractor *Interactor; 00218 00219 // Internal ivars for processing events 00220 vtkRenderer *CurrentRenderer; 00221 vtkRenderer *DefaultRenderer; 00222 00223 unsigned long CharObserverTag; 00224 unsigned long DeleteObserverTag; 00225 00226 // The mediator used to request resources from the interactor. 00227 vtkObserverMediator *ObserverMediator; 00228 int RequestCursorShape(int requestedShape); 00229 00230 private: 00231 vtkInteractorObserver(const vtkInteractorObserver&); // Not implemented. 00232 void operator=(const vtkInteractorObserver&); // Not implemented. 00233 00234 }; 00235 00236 #endif