VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vtkRenderWindowInteractor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkRenderWindowInteractor.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 =========================================================================*/
53 #ifndef __vtkRenderWindowInteractor_h
54 #define __vtkRenderWindowInteractor_h
55 
56 #include "vtkRenderingCoreModule.h" // For export macro
57 #include "vtkObject.h"
58 
59 class vtkTimerIdMap;
60 
61 // Timer flags for win32/X compatibility
62 #define VTKI_TIMER_FIRST 0
63 #define VTKI_TIMER_UPDATE 1
64 
65 class vtkAbstractPicker;
67 class vtkAssemblyPath;
69 class vtkRenderWindow;
70 class vtkRenderer;
73 class vtkPickingManager;
74 
76 {
77 //BTX
79 //ETX
80 public:
83  void PrintSelf(ostream& os, vtkIndent indent);
84 
86 
88  virtual void Initialize();
89  void ReInitialize() { this->Initialized = 0; this->Enabled = 0;
90  this->Initialize(); }
92 
95  virtual void UnRegister(vtkObjectBase *o);
96 
100  virtual void Start() {}
101 
103 
110  virtual void Enable() { this->Enabled = 1; this->Modified();}
111  virtual void Disable() { this->Enabled = 0; this->Modified();}
112  vtkGetMacro(Enabled, int);
114 
116 
118  vtkBooleanMacro(EnableRender, bool);
119  vtkSetMacro(EnableRender, bool);
120  vtkGetMacro(EnableRender, bool);
122 
124 
125  void SetRenderWindow(vtkRenderWindow *aren);
128 
131  virtual void UpdateSize(int x,int y);
132 
134 
149  virtual int CreateTimer(int timerType); //first group, for backward compatibility
150  virtual int DestroyTimer(); //first group, for backward compatibility
152 
155  int CreateRepeatingTimer(unsigned long duration);
156 
159  int CreateOneShotTimer(unsigned long duration);
160 
163  int IsOneShotTimer(int timerId);
164 
166  unsigned long GetTimerDuration(int timerId);
167 
169  int ResetTimer(int timerId);
170 
173  int DestroyTimer(int timerId);
174 
176  virtual int GetVTKTimerId(int platformTimerId);
177 
178  //BTX
179  // Moved into the public section of the class so that classless timer procs
180  // can access these enum members without being "friends"...
181  enum {OneShotTimer=1,RepeatingTimer};
182  //ETX
183 
185 
192  vtkSetClampMacro(TimerDuration,unsigned long,1,100000);
193  vtkGetMacro(TimerDuration,unsigned long);
195 
197 
207  vtkSetMacro(TimerEventId, int);
208  vtkGetMacro(TimerEventId, int);
209  vtkSetMacro(TimerEventType, int);
210  vtkGetMacro(TimerEventType, int);
211  vtkSetMacro(TimerEventDuration, int);
212  vtkGetMacro(TimerEventDuration, int);
213  vtkSetMacro(TimerEventPlatformId, int);
214  vtkGetMacro(TimerEventPlatformId, int);
216 
220  virtual void TerminateApp(void) {}
221 
223 
225  virtual void SetInteractorStyle(vtkInteractorObserver *);
226  vtkGetObjectMacro(InteractorStyle,vtkInteractorObserver);
228 
230 
232  vtkSetMacro(LightFollowCamera,int);
233  vtkGetMacro(LightFollowCamera,int);
234  vtkBooleanMacro(LightFollowCamera,int);
236 
238 
243  vtkSetClampMacro(DesiredUpdateRate,double,0.0001,VTK_FLOAT_MAX);
244  vtkGetMacro(DesiredUpdateRate,double);
246 
248 
251  vtkSetClampMacro(StillUpdateRate,double,0.0001,VTK_FLOAT_MAX);
252  vtkGetMacro(StillUpdateRate,double);
254 
256 
257  vtkGetMacro(Initialized,int);
259 
261 
265  virtual void SetPicker(vtkAbstractPicker*);
268 
271  virtual vtkAbstractPropPicker *CreateDefaultPicker();
272 
274 
277  virtual void SetPickingManager(vtkPickingManager*);
278  vtkGetObjectMacro(PickingManager,vtkPickingManager);
280 
282 
284  virtual void ExitCallback();
285  virtual void UserCallback();
286  virtual void StartPickCallback();
287  virtual void EndPickCallback();
289 
291  virtual void GetMousePosition(int *x, int *y) { *x = 0 ; *y = 0; }
292 
294 
296  void HideCursor();
297  void ShowCursor();
299 
302  virtual void Render();
303 
305 
308  void FlyTo(vtkRenderer *ren, double x, double y, double z);
309  void FlyTo(vtkRenderer *ren, double *x)
310  {this->FlyTo(ren, x[0], x[1], x[2]);}
311  void FlyToImage(vtkRenderer *ren, double x, double y);
312  void FlyToImage(vtkRenderer *ren, double *x)
313  {this->FlyToImage(ren, x[0], x[1]);}
315 
317 
318  vtkSetClampMacro(NumberOfFlyFrames,int,1,VTK_INT_MAX);
319  vtkGetMacro(NumberOfFlyFrames,int);
321 
323 
325  vtkSetMacro(Dolly,double);
326  vtkGetMacro(Dolly,double);
328 
330 
335  vtkGetVector2Macro(EventPosition,int);
336  vtkGetVector2Macro(LastEventPosition,int);
337  vtkSetVector2Macro(LastEventPosition,int);
338  virtual void SetEventPosition(int x, int y)
339  {
340  vtkDebugMacro(<< this->GetClassName() << " (" << this
341  << "): setting EventPosition to (" << x << "," << y << ")");
342  if (this->EventPosition[0] != x || this->EventPosition[1] != y ||
343  this->LastEventPosition[0] != x || this->LastEventPosition[1] != y)
344  {
345  this->LastEventPosition[0] = this->EventPosition[0];
346  this->LastEventPosition[1] = this->EventPosition[1];
347  this->EventPosition[0] = x;
348  this->EventPosition[1] = y;
349  this->Modified();
350  }
351  }
352  virtual void SetEventPosition(int pos[2])
353  {
354  this->SetEventPosition(pos[0], pos[1]);
355  }
356  virtual void SetEventPositionFlipY(int x, int y)
357  {
358  this->SetEventPosition(x, this->Size[1] - y - 1);
359  }
360  virtual void SetEventPositionFlipY(int pos[2])
361  {
362  this->SetEventPositionFlipY(pos[0], pos[1]);
363  }
365 
367 
368  vtkSetMacro(AltKey, int);
369  vtkGetMacro(AltKey, int);
371 
373 
374  vtkSetMacro(ControlKey, int);
375  vtkGetMacro(ControlKey, int);
377 
379 
380  vtkSetMacro(ShiftKey, int);
381  vtkGetMacro(ShiftKey, int);
383 
385 
386  vtkSetMacro(KeyCode, char);
387  vtkGetMacro(KeyCode, char);
389 
391 
393  vtkSetMacro(RepeatCount, int);
394  vtkGetMacro(RepeatCount, int);
396 
398 
403  vtkSetStringMacro(KeySym);
404  vtkGetStringMacro(KeySym);
406 
408 
410  int y,
411  int ctrl=0,
412  int shift=0,
413  char keycode=0,
414  int repeatcount=0,
415  const char* keysym=0)
416  {
417  this->LastEventPosition[0] = this->EventPosition[0];
418  this->LastEventPosition[1] = this->EventPosition[1];
419  this->EventPosition[0] = x;
420  this->EventPosition[1] = y;
421  this->ControlKey = ctrl;
422  this->ShiftKey = shift;
423  this->KeyCode = keycode;
424  this->RepeatCount = repeatcount;
425  if(keysym)
426  {
427  this->SetKeySym(keysym);
428  }
429  this->Modified();
430  }
432 
434 
437  int y,
438  int ctrl=0,
439  int shift=0,
440  char keycode=0,
441  int repeatcount=0,
442  const char* keysym=0)
443  {
444  this->SetEventInformation(x,
445  this->Size[1] - y - 1,
446  ctrl,
447  shift,
448  keycode,
449  repeatcount,
450  keysym);
451  }
453 
455 
456  void SetKeyEventInformation(int ctrl=0,
457  int shift=0,
458  char keycode=0,
459  int repeatcount=0,
460  const char* keysym=0)
461  {
462  this->ControlKey = ctrl;
463  this->ShiftKey = shift;
464  this->KeyCode = keycode;
465  this->RepeatCount = repeatcount;
466  if(keysym)
467  {
468  this->SetKeySym(keysym);
469  }
470  this->Modified();
471  }
473 
475 
482  vtkSetVector2Macro(Size,int);
483  vtkGetVector2Macro(Size,int);
484  vtkSetVector2Macro(EventSize,int);
485  vtkGetVector2Macro(EventSize,int);
487 
491  virtual vtkRenderer *FindPokedRenderer(int,int);
492 
499  vtkObserverMediator *GetObserverMediator();
500 
502 
507  vtkSetMacro(UseTDx,bool);
508  vtkGetMacro(UseTDx,bool);
510 
512 
515  virtual void MouseMoveEvent();
516  virtual void RightButtonPressEvent();
517  virtual void RightButtonReleaseEvent();
518  virtual void LeftButtonPressEvent();
519  virtual void LeftButtonReleaseEvent();
520  virtual void MiddleButtonPressEvent();
521  virtual void MiddleButtonReleaseEvent();
522  virtual void MouseWheelForwardEvent();
523  virtual void MouseWheelBackwardEvent();
524  virtual void ExposeEvent();
525  virtual void ConfigureEvent();
526  virtual void EnterEvent();
527  virtual void LeaveEvent();
528  virtual void KeyPressEvent();
529  virtual void KeyReleaseEvent();
530  virtual void CharEvent();
531  virtual void ExitEvent();
533 
534 protected:
537 
540 
541  // Used as a helper object to pick instances of vtkProp
544 
547  virtual vtkPickingManager *CreateDefaultPickingManager();
548 
550  int Enabled;
552  int Style;
557 
558  // Event information
559  int AltKey;
561  int ShiftKey;
562  char KeyCode;
564  char* KeySym;
565  int EventPosition[2];
566  int LastEventPosition[2];
567  int EventSize[2];
568  int Size[2];
573 
574  // control the fly to
576  double Dolly;
577 
578 //BTX
580 
587  friend class vtkInteractorObserver;
588  void GrabFocus(vtkCommand *mouseEvents, vtkCommand *keypressEvents=NULL)
589  {this->Superclass::InternalGrabFocus(mouseEvents,keypressEvents);}
592 //ETX
594 
598 
599 //BTX
600  // Timer related members
601  friend struct vtkTimerStruct;
602  vtkTimerIdMap *TimerMap; // An internal, PIMPLd map of timers and associated attributes
603  unsigned long TimerDuration; //in milliseconds
605 
609  virtual int InternalCreateTimer(int timerId, int timerType, unsigned long duration);
610  virtual int InternalDestroyTimer(int platformTimerId);
611  int GetCurrentTimerId();
612 //ETX
614 
615  // Force the interactor to handle the Start() event loop, ignoring any
616  // overrides. (Overrides are registered by observing StartEvent on the
617  // interactor.)
619 
620  bool UseTDx; // 3DConnexion device.
621 
622 private:
623  vtkRenderWindowInteractor(const vtkRenderWindowInteractor&); // Not implemented.
624  void operator=(const vtkRenderWindowInteractor&); // Not implemented.
625 };
626 
627 #endif
virtual void SetEventPositionFlipY(int pos[2])
virtual void GetMousePosition(int *x, int *y)
abstract base class for most VTK objects
Definition: vtkObject.h:61
void SetEventInformation(int x, int y, int ctrl=0, int shift=0, char keycode=0, int repeatcount=0, const char *keysym=0)
void SetEventInformationFlipY(int x, int y, int ctrl=0, int shift=0, char keycode=0, int repeatcount=0, const char *keysym=0)
#define VTK_INT_MAX
Definition: vtkType.h:131
#define vtkGetMacro(name, type)
Definition: vtkSetGet.h:83
virtual void SetRenderWindow(vtkRenderWindow *renwin)
vtkInteractorObserver * InteractorStyle
abstract specification for renderers
Definition: vtkRenderer.h:63
void SetKeyEventInformation(int ctrl=0, int shift=0, char keycode=0, int repeatcount=0, const char *keysym=0)
#define vtkSetClampMacro(name, type, min, max)
Definition: vtkSetGet.h:133
#define vtkSetStringMacro(name)
Definition: vtkSetGet.h:94
#define vtkDebugMacro(x)
Definition: vtkSetGet.h:454
GLint GLint GLint GLint GLint GLint y
Definition: vtkgl.h:11318
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:619
virtual void SetEventPosition(int pos[2])
void GrabFocus(vtkCommand *mouseEvents, vtkCommand *keypressEvents=NULL)
an abstract superclass for classes observing events invoked by vtkRenderWindowInteractor ...
void FlyTo(vtkRenderer *ren, double *x)
GLdouble GLdouble z
Definition: vtkgl.h:11754
platform-independent render window interaction including picking and frame rate control.
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
void InternalReleaseFocus()
void InternalGrabFocus(vtkCommand *mouseEvents, vtkCommand *keypressEvents=NULL)
superclass for callback/observer methods
Definition: vtkCommand.h:325
#define VTK_FLOAT_MAX
Definition: vtkType.h:139
virtual void PrintSelf(ostream &os, vtkIndent indent)
virtual void UnRegister(vtkObjectBase *o)
a list of nodes that form an assembly path
vtkObserverMediator * ObserverMediator
a simple class to control print indentation
Definition: vtkIndent.h:38
const char * GetClassName() const
virtual void Modified()
record and play VTK events passing through a vtkRenderWindowInteractor
abstract base class for most VTK objects
Definition: vtkObjectBase.h:58
#define vtkGetStringMacro(name)
Definition: vtkSetGet.h:120
virtual void SetEventPosition(int x, int y)
#define vtkGetObjectMacro(name, type)
Definition: vtkSetGet.h:222
vtkWeakPointer< vtkRenderWindow > RenderWindow
abstract API for pickers that can pick an instance of vtkProp
#define vtkGetVector2Macro(name, type)
Definition: vtkSetGet.h:260
create a window for renderers to draw into
#define VTKRENDERINGCORE_EXPORT
define API for picking subclasses
#define vtkBooleanMacro(name, type)
Definition: vtkSetGet.h:234
static vtkObject * New()
void FlyToImage(vtkRenderer *ren, double *x)
#define vtkSetVector2Macro(name, type)
Definition: vtkSetGet.h:244
manage contention for cursors and other resources
#define vtkSetMacro(name, type)
Definition: vtkSetGet.h:69
virtual void SetEventPositionFlipY(int x, int y)