VTK
vtkInteractorStyle.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkInteractorStyle.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 =========================================================================*/
100 #ifndef __vtkInteractorStyle_h
101 #define __vtkInteractorStyle_h
102 
103 #include "vtkInteractorObserver.h"
104 
105 // Motion flags
106 
107 #define VTKIS_START 0
108 #define VTKIS_NONE 0
109 
110 #define VTKIS_ROTATE 1
111 #define VTKIS_PAN 2
112 #define VTKIS_SPIN 3
113 #define VTKIS_DOLLY 4
114 #define VTKIS_ZOOM 5
115 #define VTKIS_USCALE 6
116 #define VTKIS_TIMER 7
117 #define VTKIS_FORWARDFLY 8
118 #define VTKIS_REVERSEFLY 9
119 
120 #define VTKIS_ANIM_OFF 0
121 #define VTKIS_ANIM_ON 1
122 
123 class vtkActor2D;
124 class vtkActor;
125 class vtkCallbackCommand;
127 class vtkOutlineSource;
128 class vtkPolyDataMapper;
129 class vtkProp3D;
130 class vtkProp;
132 
134 {
135 public:
139  static vtkInteractorStyle *New();
140 
142  void PrintSelf(ostream& os, vtkIndent indent);
143 
146  virtual void SetInteractor(vtkRenderWindowInteractor *interactor);
147 
153  virtual void SetEnabled(int);
154 
156 
162  vtkSetClampMacro(AutoAdjustCameraClippingRange, int, 0, 1 );
163  vtkGetMacro(AutoAdjustCameraClippingRange, int );
164  vtkBooleanMacro(AutoAdjustCameraClippingRange, int );
166 
170  void FindPokedRenderer(int,int);
171 
173 
174  vtkGetMacro(State,int);
176 
178 
179  vtkGetMacro(UseTimers,int);
180  vtkSetMacro(UseTimers,int);
181  vtkBooleanMacro(UseTimers,int);
183 
185 
189  vtkSetClampMacro(TimerDuration,unsigned long,1,100000);
190  vtkGetMacro(TimerDuration,unsigned long);
192 
194 
195  vtkSetMacro(HandleObservers,int);
196  vtkGetMacro(HandleObservers,int);
197  vtkBooleanMacro(HandleObservers,int);
199 
201 
202  virtual void OnMouseMove() {};
203  virtual void OnLeftButtonDown() {};
204  virtual void OnLeftButtonUp() {};
205  virtual void OnMiddleButtonDown() {};
206  virtual void OnMiddleButtonUp() {};
207  virtual void OnRightButtonDown() {};
208  virtual void OnRightButtonUp() {};
209  virtual void OnMouseWheelForward() {};
210  virtual void OnMouseWheelBackward() {};
212 
215  virtual void OnChar();
216 
217  // OnKeyDown is triggered by pressing any key (identical to OnKeyPress()).
218  // An empty implementation is provided. The behavior of this function should
219  // be specified in the subclass.
220  virtual void OnKeyDown() {};
221 
222  // OnKeyUp is triggered by releaseing any key (identical to OnKeyRelease()).
223  // An empty implementation is provided. The behavior of this function should
224  // be specified in the subclass.
225  virtual void OnKeyUp() {};
226 
227  // OnKeyPress is triggered by pressing any key (identical to OnKeyDown()).
228  // An empty implementation is provided. The behavior of this function should
229  // be specified in the subclass.
230  virtual void OnKeyPress() {};
231 
232  // OnKeyRelease is triggered by pressing any key (identical to OnKeyUp()).
233  // An empty implementation is provided. The behavior of this function should
234  // be specified in the subclass.
235  virtual void OnKeyRelease() {};
236 
238 
239  virtual void OnExpose() {};
240  virtual void OnConfigure() {};
241  virtual void OnEnter() {};
242  virtual void OnLeave() {};
244 
247  virtual void OnTimer();
248 
250 
254  virtual void Rotate() {};
255  virtual void Spin() {};
256  virtual void Pan() {};
257  virtual void Dolly() {};
258  virtual void Zoom() {};
259  virtual void UniformScale() {};
261 
263 
264  virtual void StartState(int newstate);
265  virtual void StopState();
267 
269 
270  virtual void StartAnimate();
271  virtual void StopAnimate();
272  virtual void StartRotate();
273  virtual void EndRotate();
274  virtual void StartZoom();
275  virtual void EndZoom();
276  virtual void StartPan();
277  virtual void EndPan();
278  virtual void StartSpin();
279  virtual void EndSpin();
280  virtual void StartDolly();
281  virtual void EndDolly();
282  virtual void StartUniformScale();
283  virtual void EndUniformScale();
284  virtual void StartTimer();
285  virtual void EndTimer();
287 
289 
293  virtual void HighlightProp(vtkProp *prop);
294  virtual void HighlightActor2D(vtkActor2D *actor2D);
295  virtual void HighlightProp3D(vtkProp3D *prop3D);
297 
299 
301  vtkSetVector3Macro(PickColor,double);
302  vtkGetVectorMacro(PickColor, double, 3);
304 
306 
309  vtkSetMacro(MouseWheelMotionFactor, double);
310  vtkGetMacro(MouseWheelMotionFactor, double);
312 
314 
316  vtkGetObjectMacro(TDxStyle,vtkTDxInteractorStyle);
317  virtual void SetTDxStyle(vtkTDxInteractorStyle *tdxStyle);
319 
321 
322  void DelegateTDxEvent(unsigned long event,
323  void *calldata);
325 
326 protected:
329 
331 
332  static void ProcessEvents(vtkObject* object,
333  unsigned long event,
334  void* clientdata,
335  void* calldata);
337 
338  // Keep track of current state
339  int State;
340  int AnimState;
341 
342  // Should observers be handled here, should we fire timers
344  int UseTimers;
345  int TimerId; //keep track of the timers that are created/destroyed
346 
348 
349  // For picking and highlighting props
356  int PropPicked; // bool: prop picked?
357  double PickColor[3]; // support 2D picking
359 
360  // Control the timer duration
361  unsigned long TimerDuration; //in milliseconds
362 
363  // Forward evets to the RenderWindowInteractor
365 
367 
368 private:
369  vtkInteractorStyle(const vtkInteractorStyle&); // Not implemented.
370  void operator=(const vtkInteractorStyle&); // Not implemented.
371 };
372 
373 #endif