VTK
vtkInteractorObserver.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkInteractorObserver.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
47 #ifndef __vtkInteractorObserver_h
48 #define __vtkInteractorObserver_h
49 
50 #include "vtkObject.h"
51 
53 class vtkRenderer;
54 class vtkCallbackCommand;
56 
57 
59 {
60 public:
62  void PrintSelf(ostream& os, vtkIndent indent);
63 
65 
71  virtual void SetEnabled(int) {};
72  int GetEnabled() {return this->Enabled;}
73  void EnabledOn() {this->SetEnabled(1);}
74  void EnabledOff() {this->SetEnabled(0);}
75  void On() {this->SetEnabled(1);}
76  void Off() {this->SetEnabled(0);}
78 
80 
85  virtual void SetInteractor(vtkRenderWindowInteractor* iren);
86  vtkGetObjectMacro(Interactor, vtkRenderWindowInteractor);
88 
90 
98  vtkSetClampMacro(Priority,float,0.0f,1.0f);
99  vtkGetMacro(Priority,float);
101 
103 
107  vtkSetMacro(KeyPressActivation,int);
108  vtkGetMacro(KeyPressActivation,int);
109  vtkBooleanMacro(KeyPressActivation,int);
111 
113 
119  vtkSetMacro(KeyPressActivationValue,char);
120  vtkGetMacro(KeyPressActivationValue,char);
122 
124 
130  vtkGetObjectMacro(DefaultRenderer,vtkRenderer);
131  virtual void SetDefaultRenderer(vtkRenderer*);
133 
135 
143  vtkGetObjectMacro(CurrentRenderer,vtkRenderer);
144  virtual void SetCurrentRenderer(vtkRenderer*);
146 
148  virtual void OnChar();
149 
151 
153  static void ComputeDisplayToWorld(vtkRenderer *ren, double x, double y,
154  double z, double worldPt[4]);
155  static void ComputeWorldToDisplay(vtkRenderer *ren, double x, double y,
156  double z, double displayPt[3]);
158 
159  //BTX
161 
169  void GrabFocus(vtkCommand *mouseEvents, vtkCommand *keypressEvents=NULL);
170  void ReleaseFocus();
171  //ETX
173 
174 protected:
177 
179 
182  virtual void StartInteraction();
183  virtual void EndInteraction();
185 
187 
189  static void ProcessEvents(vtkObject* object,
190  unsigned long event,
191  void* clientdata,
192  void* calldata);
194 
196 
197  void ComputeDisplayToWorld(double x, double y, double z,
198  double worldPt[4]);
199  void ComputeWorldToDisplay(double x, double y, double z,
200  double displayPt[3]);
202 
203  // The state of the widget, whether on or off (observing events or not)
204  int Enabled;
205 
206  // Used to process events
208  vtkCallbackCommand* KeyPressCallbackCommand; //listens to key activation
209 
210  // Priority at which events are processed
211  float Priority;
212 
213  // Keypress activation controls
216 
217  // Used to associate observers with the interactor
219 
220  // Internal ivars for processing events
223 
224  unsigned long CharObserverTag;
225  unsigned long DeleteObserverTag;
226 
227  // The mediator used to request resources from the interactor.
229  int RequestCursorShape(int requestedShape);
230 
231 private:
232  vtkInteractorObserver(const vtkInteractorObserver&); // Not implemented.
233  void operator=(const vtkInteractorObserver&); // Not implemented.
234 
235 };
236 
237 #endif