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 "vtkRenderingCoreModule.h" // For export macro 00051 #include "vtkObject.h" 00052 00053 class vtkAbstractPropPicker; 00054 class vtkAssemblyPath; 00055 class vtkRenderWindowInteractor; 00056 class vtkRenderer; 00057 class vtkCallbackCommand; 00058 class vtkObserverMediator; 00059 class vtkPickingManager; 00060 00061 class VTKRENDERINGCORE_EXPORT vtkInteractorObserver : public vtkObject 00062 { 00063 public: 00064 vtkTypeMacro(vtkInteractorObserver,vtkObject); 00065 void PrintSelf(ostream& os, vtkIndent indent); 00066 00068 00074 virtual void SetEnabled(int) {} 00075 int GetEnabled() {return this->Enabled;} 00076 void EnabledOn() {this->SetEnabled(1);} 00077 void EnabledOff() {this->SetEnabled(0);} 00078 void On() {this->SetEnabled(1);} 00079 void Off() {this->SetEnabled(0);} 00081 00083 00089 virtual void SetInteractor(vtkRenderWindowInteractor* iren); 00090 vtkGetObjectMacro(Interactor, vtkRenderWindowInteractor); 00092 00094 00102 vtkSetClampMacro(Priority,float,0.0f,1.0f); 00103 vtkGetMacro(Priority,float); 00105 00107 00109 vtkBooleanMacro(PickingManaged, bool); 00110 vtkSetMacro(PickingManaged, bool); 00111 vtkGetMacro(PickingManaged, bool); 00113 00115 00119 vtkSetMacro(KeyPressActivation,int); 00120 vtkGetMacro(KeyPressActivation,int); 00121 vtkBooleanMacro(KeyPressActivation,int); 00123 00125 00131 vtkSetMacro(KeyPressActivationValue,char); 00132 vtkGetMacro(KeyPressActivationValue,char); 00134 00136 00142 vtkGetObjectMacro(DefaultRenderer,vtkRenderer); 00143 virtual void SetDefaultRenderer(vtkRenderer*); 00145 00147 00155 vtkGetObjectMacro(CurrentRenderer,vtkRenderer); 00156 virtual void SetCurrentRenderer(vtkRenderer*); 00158 00160 virtual void OnChar(); 00161 00163 00165 static void ComputeDisplayToWorld(vtkRenderer *ren, double x, double y, 00166 double z, double worldPt[4]); 00167 static void ComputeWorldToDisplay(vtkRenderer *ren, double x, double y, 00168 double z, double displayPt[3]); 00170 00171 //BTX 00173 00181 void GrabFocus(vtkCommand *mouseEvents, vtkCommand *keypressEvents=NULL); 00182 void ReleaseFocus(); 00183 //ETX 00185 00186 protected: 00187 vtkInteractorObserver(); 00188 ~vtkInteractorObserver(); 00189 00191 00194 virtual void StartInteraction(); 00195 virtual void EndInteraction(); 00197 00199 00201 static void ProcessEvents(vtkObject* object, 00202 unsigned long event, 00203 void* clientdata, 00204 void* calldata); 00206 00208 00209 void ComputeDisplayToWorld(double x, double y, double z, 00210 double worldPt[4]); 00211 void ComputeWorldToDisplay(double x, double y, double z, 00212 double displayPt[3]); 00214 00215 // The state of the widget, whether on or off (observing events or not) 00216 int Enabled; 00217 00218 // Used to process events 00219 vtkCallbackCommand* EventCallbackCommand; //subclasses use one 00220 vtkCallbackCommand* KeyPressCallbackCommand; //listens to key activation 00221 00222 // Priority at which events are processed 00223 float Priority; 00224 00225 // This variable controls whether the picking is managed by the Picking 00226 // Manager process or not. True by default. 00227 bool PickingManaged; 00228 00231 virtual void RegisterPickers(); 00232 00234 void UnRegisterPickers(); 00235 00238 virtual void PickersModified(); 00239 00242 vtkPickingManager* GetPickingManager(); 00243 00245 00248 vtkAssemblyPath* GetAssemblyPath(double X, double Y, double Z, 00249 vtkAbstractPropPicker* picker); 00251 00252 // Keypress activation controls 00253 int KeyPressActivation; 00254 char KeyPressActivationValue; 00255 00256 // Used to associate observers with the interactor 00257 vtkRenderWindowInteractor *Interactor; 00258 00259 // Internal ivars for processing events 00260 vtkRenderer *CurrentRenderer; 00261 vtkRenderer *DefaultRenderer; 00262 00263 unsigned long CharObserverTag; 00264 unsigned long DeleteObserverTag; 00265 00266 // The mediator used to request resources from the interactor. 00267 vtkObserverMediator *ObserverMediator; 00268 int RequestCursorShape(int requestedShape); 00269 00270 private: 00271 vtkInteractorObserver(const vtkInteractorObserver&); // Not implemented. 00272 void operator=(const vtkInteractorObserver&); // Not implemented. 00273 00274 }; 00275 00276 #endif