vtkRenderWindowInteractor.cxx 37.2 KB
Newer Older
Ken Martin's avatar
Ken Martin committed
1 2
/*=========================================================================

Ken Martin's avatar
Ken Martin committed
3
  Program:   Visualization Toolkit
Ken Martin's avatar
Ken Martin committed
4
  Module:    vtkRenderWindowInteractor.cxx
Ken Martin's avatar
Ken Martin committed
5

6
  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 8
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9

10 11
     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
     PURPOSE.  See the above copyright notice for more information.
Ken Martin's avatar
Ken Martin committed
13 14

=========================================================================*/
Ken Martin's avatar
Ken Martin committed
15
#include "vtkRenderWindowInteractor.h"
16

17
#include "vtkCamera.h"
18
#include "vtkCommand.h"
Ken Martin's avatar
Ken Martin committed
19
#include "vtkGraphicsFactory.h"
20
#include "vtkInteractorStyleSwitchBase.h"
21
#include "vtkMath.h"
22 23
#include "vtkPropPicker.h"
#include "vtkRenderWindow.h"
24 25
#include "vtkRenderer.h"
#include "vtkRendererCollection.h"
26
#include "vtkDebugLeaks.h"
27
#include "vtkObserverMediator.h"
28 29
#include "vtkPickingManager.h"

30
#include <map>
31

32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49

// PIMPL'd class to keep track of timers. It maps the ids returned by CreateTimer()
// to the platform-specific representation for timer ids.
struct vtkTimerStruct
{
  int Id;
  int Type;
  unsigned long Duration;
  vtkTimerStruct() : Id(0),Type(vtkRenderWindowInteractor::OneShotTimer),Duration(10) {}
  vtkTimerStruct(int platformTimerId, int timerType, unsigned long duration)
    {
      this->Id = platformTimerId;
      this->Type = timerType;
      this->Duration = duration;
    }
};


50 51
class vtkTimerIdMap : public std::map<int,vtkTimerStruct> {};
typedef std::map<int,vtkTimerStruct>::iterator vtkTimerIdMapIterator;
52

53
// Initialize static variable that keeps track of timer ids for
54
// render window interactors.
55
static int vtkTimerId = 1;
56 57

//----------------------------------------------------------------------------
58
vtkCxxSetObjectMacro(vtkRenderWindowInteractor,Picker,vtkAbstractPicker);
Ken Martin's avatar
Ken Martin committed
59

60
//----------------------------------------------------------------------
Ken Martin's avatar
Ken Martin committed
61
// Construct object so that light follows camera motion.
Ken Martin's avatar
Ken Martin committed
62
vtkRenderWindowInteractor::vtkRenderWindowInteractor()
Ken Martin's avatar
Ken Martin committed
63
{
64
  this->RenderWindow    = NULL;
65 66 67 68
  // Here we are using base, and relying on the graphics factory or standard
  // object factory logic to create the correct instance, which should be the
  // vtkInteractorStyleSwitch when linked to the interactor styles, or
  // vtkInteractorStyleSwitchBase if the style module is not linked.
Ken Martin's avatar
Ken Martin committed
69
  this->InteractorStyle = NULL;
70
  this->SetInteractorStyle(vtkInteractorStyleSwitchBase::New());
Ken Martin's avatar
Ken Martin committed
71
  this->InteractorStyle->Delete();
72

Ken Martin's avatar
Ken Martin committed
73
  this->LightFollowCamera = 1;
74
  this->Initialized = 0;
75
  this->Enabled = 0;
76
  this->EnableRender = true;
Ken Martin's avatar
Ken Martin committed
77
  this->DesiredUpdateRate = 15;
78 79
  // default limit is 3 hours per frame
  this->StillUpdateRate = 0.0001;
80

81
  this->Picker = this->CreateDefaultPicker();
82 83
  this->Picker->Register(this);
  this->Picker->Delete();
84

85
  this->PickingManager = 0;
86 87 88
  vtkPickingManager* pm = this->CreateDefaultPickingManager();
  this->SetPickingManager(pm);
  pm->Delete();
89

90 91
  this->EventPosition[0] = this->LastEventPosition[0] = 0;
  this->EventPosition[1] = this->LastEventPosition[1] = 0;
92

93 94 95 96 97 98 99
  for (int i = 0; i < VTKI_MAX_POINTERS; ++i)
    {
    this->EventPositions[i][0] = this->LastEventPositions[i][0] = 0;
    this->EventPositions[i][1] = this->LastEventPositions[i][1] = 0;
    }
  this->PointerIndex = 0;

Sebastien Barre's avatar
Sebastien Barre committed
100 101 102
  this->EventSize[0] = 0;
  this->EventSize[1] = 0;

103 104
  this->Size[0] = 0;
  this->Size[1] = 0;
105

106 107
  this->NumberOfFlyFrames = 15;
  this->Dolly = 0.30;
108

109
  this->AltKey = 0;
110 111 112
  this->ControlKey = 0;
  this->ShiftKey = 0;
  this->KeyCode = 0;
113 114 115 116
  this->Rotation = 0;
  this->LastRotation = 0;
  this->Scale = 0;
  this->LastScale = 0;
117
  this->RepeatCount = 0;
118
  this->KeySym = 0;
119 120 121 122
  this->TimerEventId = 0;
  this->TimerEventType = 0;
  this->TimerEventDuration = 0;
  this->TimerEventPlatformId = 0;
123

124
  this->TimerMap = new vtkTimerIdMap;
125
  this->TimerDuration = 10;
126
  this->ObserverMediator = 0;
Karthik Krishnan's avatar
Karthik Krishnan committed
127
  this->HandleEventLoop = false;
128

129
  this->UseTDx=false; // 3DConnexion device.
130 131 132

  for (int i=0; i < VTKI_MAX_POINTERS; i++)
    {
133
    this->PointerIndexLookup[i] = 0;
134
    this->PointersDown[i] = 0;
135 136
    }

137 138 139
  this->RecognizeGestures = true;
  this->PointersDownCount = 0;
  this->CurrentGesture = vtkCommand::StartEvent;
Ken Martin's avatar
Ken Martin committed
140 141
}

142
//----------------------------------------------------------------------
Ken Martin's avatar
Ken Martin committed
143
vtkRenderWindowInteractor::~vtkRenderWindowInteractor()
Ken Martin's avatar
Ken Martin committed
144
{
Ken Martin's avatar
Ken Martin committed
145 146 147 148
  if (this->InteractorStyle != NULL)
    {
    this->InteractorStyle->UnRegister(this);
    }
149 150 151 152
  if ( this->Picker)
    {
    this->Picker->UnRegister(this);
    }
153
  delete [] this->KeySym;
154 155 156 157
  if ( this->ObserverMediator)
    {
    this->ObserverMediator->Delete();
    }
158
  delete this->TimerMap;
159

160
  this->SetPickingManager(0);
161
  this->SetRenderWindow(0);
Ken Martin's avatar
Ken Martin committed
162 163
}

164
//----------------------------------------------------------------------
165 166
vtkRenderWindowInteractor *vtkRenderWindowInteractor::New()
{
Ken Martin's avatar
Ken Martin committed
167
  // First try to create the object from the vtkObjectFactory
168
  vtkObject* ret =
Ken Martin's avatar
Ken Martin committed
169
    vtkGraphicsFactory::CreateInstance("vtkRenderWindowInteractor");
170 171
  if ( ret )
    {
172
    return static_cast<vtkRenderWindowInteractor *>(ret);
173 174 175 176 177
    }
#ifdef VTK_DEBUG_LEAKS
  vtkDebugLeaks::ConstructClass("vtkRenderWindowInteractor");
#endif
  return new vtkRenderWindowInteractor;
Ken Martin's avatar
Ken Martin committed
178
}
Ken Martin's avatar
Ken Martin committed
179

180
//----------------------------------------------------------------------
Ken Martin's avatar
Ken Martin committed
181 182
void vtkRenderWindowInteractor::Render()
{
183
  if (this->RenderWindow && this->Enabled && this->EnableRender)
Ken Martin's avatar
Ken Martin committed
184 185 186
    {
    this->RenderWindow->Render();
    }
187 188 189
  // outside the above test so that third-party code can redirect
  // the render to the appropriate class
  this->InvokeEvent(vtkCommand::RenderEvent, NULL);
Ken Martin's avatar
Ken Martin committed
190 191
}

192
//----------------------------------------------------------------------
Ken Martin's avatar
Ken Martin committed
193 194
// treat renderWindow and interactor as one object.
// it might be easier if the GetReference count method were redefined.
195
void vtkRenderWindowInteractor::UnRegister(vtkObjectBase *o)
Ken Martin's avatar
Ken Martin committed
196 197 198 199 200 201 202 203 204 205 206 207
{
  if (this->RenderWindow && this->RenderWindow->GetInteractor() == this &&
      this->RenderWindow != o)
    {
    if (this->GetReferenceCount()+this->RenderWindow->GetReferenceCount() == 3)
      {
      this->RenderWindow->SetInteractor(NULL);
      this->SetRenderWindow(NULL);
      }
    }

  this->vtkObject::UnRegister(o);
208 209
}

210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
//----------------------------------------------------------------------
void vtkRenderWindowInteractor::Start()
{
  // Let the compositing handle the event loop if it wants to.
  if (this->HasObserver(vtkCommand::StartEvent) && !this->HandleEventLoop)
    {
    this->InvokeEvent(vtkCommand::StartEvent,NULL);
    return;
    }

  // As a convenience, initialize if we aren't initialized yet.
  if (!this->Initialized)
    {
    this->Initialize();

    if (!this->Initialized)
      {
      return;
      }
    }

  // Pass execution to the subclass which will run the event loop,
  // this will not return until TerminateApp is called.
  this->StartEventLoop();
}

236
//----------------------------------------------------------------------
LYMB Demo's avatar
LYMB Demo committed
237 238
void vtkRenderWindowInteractor::SetRenderWindow(vtkRenderWindow *aren)
{
239
  if (this->RenderWindow != aren)
LYMB Demo's avatar
LYMB Demo committed
240
    {
241 242 243
    // to avoid destructor recursion
    vtkRenderWindow *temp = this->RenderWindow;
    this->RenderWindow = aren;
244 245 246 247
    if (temp != NULL)
      {
      temp->UnRegister(this);
      }
Ken Martin's avatar
Ken Martin committed
248
    if (this->RenderWindow != NULL)
249 250 251
      {
      this->RenderWindow->Register(this);
      if (this->RenderWindow->GetInteractor() != this)
252 253 254
        {
        this->RenderWindow->SetInteractor(this);
        }
255
      }
LYMB Demo's avatar
LYMB Demo committed
256 257
    }
}
258

259
//----------------------------------------------------------------------
260
void vtkRenderWindowInteractor::SetInteractorStyle(vtkInteractorObserver *style)
261
{
Will Schroeder's avatar
Will Schroeder committed
262
  if (this->InteractorStyle != style)
263
    {
Ken Martin's avatar
Ken Martin committed
264
    // to avoid destructor recursion
265
    vtkInteractorObserver *temp = this->InteractorStyle;
Will Schroeder's avatar
Will Schroeder committed
266
    this->InteractorStyle = style;
Ken Martin's avatar
Ken Martin committed
267
    if (temp != NULL)
268
      {
269
      temp->SetInteractor(0);
Ken Martin's avatar
Ken Martin committed
270 271 272 273 274 275
      temp->UnRegister(this);
      }
    if (this->InteractorStyle != NULL)
      {
      this->InteractorStyle->Register(this);
      if (this->InteractorStyle->GetInteractor() != this)
276 277 278
        {
        this->InteractorStyle->SetInteractor(this);
        }
279 280 281 282
      }
    }
}

283
//----------------------------------------------------------------------
284
void vtkRenderWindowInteractor::UpdateSize(int x,int y)
285
{
Ken Martin's avatar
Ken Martin committed
286 287
  // if the size changed send this on to the RenderWindow
  if ((x != this->Size[0])||(y != this->Size[1]))
288
    {
289 290
    this->Size[0] = this->EventSize[0] = x;
    this->Size[1] = this->EventSize[1] = y;
Ken Martin's avatar
Ken Martin committed
291
    this->RenderWindow->SetSize(x,y);
292
    }
Will Schroeder's avatar
Will Schroeder committed
293 294
}

295 296
// This function is used to return an index given an ID
// and allocate one if needed
297
int vtkRenderWindowInteractor::GetPointerIndexForContact(size_t dwID)
298 299 300
{
  for (int i=0; i < VTKI_MAX_POINTERS; i++)
    {
301
    if (this->PointerIndexLookup[i] == dwID+1)
302 303 304 305 306 307 308
      {
      return i;
      }
    }

  for (int i=0; i < VTKI_MAX_POINTERS; i++)
    {
309
    if (this->PointerIndexLookup[i] == 0)
310
      {
311
      this->PointerIndexLookup[i] = dwID+1;
312 313 314 315 316 317 318 319 320
      return i;
      }
    }

  // Out of contacts
  return -1;
}

// This function is used to return an index given an ID
321
int vtkRenderWindowInteractor::GetPointerIndexForExistingContact(size_t dwID)
322 323 324
{
  for (int i=0; i < VTKI_MAX_POINTERS; i++)
    {
325
    if (this->PointerIndexLookup[i] == dwID+1)
326 327 328 329 330 331 332 333 334
      {
      return i;
      }
    }

  // Not found
  return -1;
}

335
void vtkRenderWindowInteractor::ClearContact(size_t dwID)
336 337 338
{
  for (int i=0; i < VTKI_MAX_POINTERS; i++)
    {
339
    if (this->PointerIndexLookup[i] == dwID+1)
340
      {
341
      this->PointerIndexLookup[i] = 0;
342 343 344 345 346
      return;
      }
    }
}

347 348 349 350 351 352 353
void vtkRenderWindowInteractor::ClearPointerIndex(int i)
{
  if (i < VTKI_MAX_POINTERS)
    {
    this->PointerIndexLookup[i] = 0;
    }
}
354

355 356 357 358 359 360 361 362 363
// This function is used to return an index given an ID
bool vtkRenderWindowInteractor::IsPointerIndexSet(int i)
{
  if (i < VTKI_MAX_POINTERS)
    {
    return (this->PointerIndexLookup[i] != 0);
    }
  return false;
}
364

365
//----------------------------------------------------------------------
Will Schroeder's avatar
Will Schroeder committed
366 367
// Creates an instance of vtkPropPicker by default
vtkAbstractPropPicker *vtkRenderWindowInteractor::CreateDefaultPicker()
368
{
Will Schroeder's avatar
Will Schroeder committed
369
  return vtkPropPicker::New();
370 371
}

372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403
//----------------------------------------------------------------------
// Creates an instance of vtkPickingManager by default
vtkPickingManager* vtkRenderWindowInteractor::CreateDefaultPickingManager()
{
  return vtkPickingManager::New();
}

//----------------------------------------------------------------------
void vtkRenderWindowInteractor::SetPickingManager(vtkPickingManager* pm)
{
  if(this->PickingManager == pm)
    {
    return;
    }

  vtkPickingManager* tempPickingManager = this->PickingManager;
  this->PickingManager = pm;
  if (this->PickingManager)
    {
    this->PickingManager->Register(this);
    this->PickingManager->SetInteractor(this);
    }

  if(tempPickingManager)
    {
    tempPickingManager->SetInteractor(0);
    tempPickingManager->UnRegister(this);
    }

  this->Modified();
}

404
//----------------------------------------------------------------------
Ken Martin's avatar
Ken Martin committed
405
void vtkRenderWindowInteractor::ExitCallback()
406
{
Ken Martin's avatar
Ken Martin committed
407
  if (this->HasObserver(vtkCommand::ExitEvent))
408
    {
Ken Martin's avatar
Ken Martin committed
409
    this->InvokeEvent(vtkCommand::ExitEvent,NULL);
410
    }
Ken Martin's avatar
Ken Martin committed
411
  else
412
    {
Ken Martin's avatar
Ken Martin committed
413
    this->TerminateApp();
414 415 416
    }
}

417
//----------------------------------------------------------------------
Ken Martin's avatar
Ken Martin committed
418
void vtkRenderWindowInteractor::UserCallback()
419
{
Ken Martin's avatar
Ken Martin committed
420
  this->InvokeEvent(vtkCommand::UserEvent,NULL);
421 422
}

423
//----------------------------------------------------------------------
Ken Martin's avatar
Ken Martin committed
424
void vtkRenderWindowInteractor::StartPickCallback()
425
{
Ken Martin's avatar
Ken Martin committed
426
  this->InvokeEvent(vtkCommand::StartPickEvent,NULL);
427 428
}

429
//----------------------------------------------------------------------
Ken Martin's avatar
Ken Martin committed
430
void vtkRenderWindowInteractor::EndPickCallback()
431
{
Ken Martin's avatar
Ken Martin committed
432
  this->InvokeEvent(vtkCommand::EndPickEvent,NULL);
433 434
}

435
//----------------------------------------------------------------------
436
void vtkRenderWindowInteractor::FlyTo(vtkRenderer *ren, double x, double y, double z)
437
{
438 439
  double flyFrom[3], flyTo[3];
  double d[3], focalPt[3];
440 441 442 443 444 445 446 447
  int i, j;

  flyTo[0]=x; flyTo[1]=y; flyTo[2]=z;
  ren->GetActiveCamera()->GetFocalPoint(flyFrom);
  for (i=0; i<3; i++)
    {
    d[i] = flyTo[i] - flyFrom[i];
    }
448 449
  double distance = vtkMath::Normalize(d);
  double delta = distance/this->NumberOfFlyFrames;
450

451 452 453 454 455 456 457 458
  for (i=1; i<=NumberOfFlyFrames; i++)
    {
    for (j=0; j<3; j++)
      {
      focalPt[j] = flyFrom[j] + d[j]*i*delta;
      }
    ren->GetActiveCamera()->SetFocalPoint(focalPt);
    ren->GetActiveCamera()->Dolly(this->Dolly/this->NumberOfFlyFrames + 1.0);
459
    ren->GetActiveCamera()->OrthogonalizeViewUp();
460
    ren->ResetCameraClippingRange();
461
    this->Render();
462 463 464
    }
}

465
//----------------------------------------------------------------------
466
void vtkRenderWindowInteractor::FlyToImage(vtkRenderer *ren, double x, double y)
467
{
468 469
  double flyFrom[3], flyTo[3];
  double d[3], focalPt[3], position[3], positionFrom[3];
470 471 472 473 474 475 476 477 478 479
  int i, j;

  flyTo[0]=x; flyTo[1]=y;
  ren->GetActiveCamera()->GetFocalPoint(flyFrom);  flyTo[2] = flyFrom[2];
  ren->GetActiveCamera()->GetPosition(positionFrom);
  for (i=0; i<2; i++)
    {
    d[i] = flyTo[i] - flyFrom[i];
    }
  d[2] = 0.0;
480 481
  double distance = vtkMath::Normalize(d);
  double delta = distance/this->NumberOfFlyFrames;
482

483 484 485 486 487 488 489 490 491 492 493
  for (i=1; i<=NumberOfFlyFrames; i++)
    {
    for (j=0; j<3; j++)
      {
      focalPt[j] = flyFrom[j] + d[j]*i*delta;
      position[j] = positionFrom[j] + d[j]*i*delta;
      }
    ren->GetActiveCamera()->SetFocalPoint(focalPt);
    ren->GetActiveCamera()->SetPosition(position);
    ren->GetActiveCamera()->Dolly(this->Dolly/this->NumberOfFlyFrames + 1.0);
    ren->ResetCameraClippingRange();
494
    this->Render();
495 496 497
    }
}

Will Schroeder's avatar
Will Schroeder committed
498
//----------------------------------------------------------------------------
499
vtkRenderer* vtkRenderWindowInteractor::FindPokedRenderer(int x,int y)
Will Schroeder's avatar
Will Schroeder committed
500 501 502 503 504 505 506 507
{
  vtkRendererCollection *rc;
  vtkRenderer *aren;
  vtkRenderer *currentRenderer=NULL, *interactiveren=NULL, *viewportren=NULL;
  int numRens, i;

  rc = this->RenderWindow->GetRenderers();
  numRens = rc->GetNumberOfItems();
508 509

  for (i = numRens -1; (i >= 0) && !currentRenderer; i--)
Will Schroeder's avatar
Will Schroeder committed
510
    {
511
    aren = static_cast<vtkRenderer *>(rc->GetItemAsObject(i));
512
    if (aren->IsInViewport(x,y) && aren->GetInteractive())
Will Schroeder's avatar
Will Schroeder committed
513 514 515 516 517 518 519 520 521 522 523 524
      {
      currentRenderer = aren;
      }

    if (interactiveren == NULL && aren->GetInteractive())
      {
      // Save this renderer in case we can't find one in the viewport that
      // is interactive.
      interactiveren = aren;
      }
    if (viewportren == NULL && aren->IsInViewport(x, y))
      {
525
      // Save this renderer in case we can't find one in the viewport that
Will Schroeder's avatar
Will Schroeder committed
526 527 528 529
      // is interactive.
      viewportren = aren;
      }
    }//for all renderers
530

Will Schroeder's avatar
Will Schroeder committed
531 532 533 534 535 536
  // We must have a value.  If we found an interactive renderer before, that's
  // better than a non-interactive renderer.
  if ( currentRenderer == NULL )
    {
    currentRenderer = interactiveren;
    }
537

Will Schroeder's avatar
Will Schroeder committed
538 539 540 541 542 543 544 545 546
  // We must have a value.  If we found a renderer that is in the viewport,
  // that is better than any old viewport (but not as good as an interactive
  // one).
  if ( currentRenderer == NULL )
    {
    currentRenderer = viewportren;
    }

  // We must have a value - take anything.
547
  if ( currentRenderer == NULL)
Will Schroeder's avatar
Will Schroeder committed
548
    {
Ken Martin's avatar
Ken Martin committed
549
    aren = rc->GetFirstRenderer();
Will Schroeder's avatar
Will Schroeder committed
550 551 552 553 554 555
    currentRenderer = aren;
    }

  return currentRenderer;
}

556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704
//----------------------------------------------------------------------------
void vtkRenderWindowInteractor::SetScale(double scale)
{
  this->LastScale = this->Scale;
  if (this->Scale != scale)
    {
    this->Scale = scale;
    this->Modified();
    }
}

//----------------------------------------------------------------------------
void vtkRenderWindowInteractor::SetRotation(double rot)
{
  this->LastRotation = this->Rotation;
  if (this->Rotation != rot)
    {
    this->Rotation = rot;
    this->Modified();
    }
}

//----------------------------------------------------------------------------
void vtkRenderWindowInteractor::SetTranslation(double val[2])
{
  this->LastTranslation[0] = this->Translation[0];
  this->LastTranslation[1] = this->Translation[1];
  if (this->Translation[0] != val[0] ||
      this->Translation[1] != val[1])
    {
    this->Translation[0] = val[0];
    this->Translation[1] = val[1];
    this->Modified();
    }
}

//----------------------------------------------------------------------------
void vtkRenderWindowInteractor::RecognizeGesture(vtkCommand::EventIds event)
{
  // we know we are in multitouch now, so start recognizing

  // more than two pointers we ignore
  if (this->PointersDownCount > 2)
    {
    return;
    }

  // store the initial positions
  if (event == vtkCommand::LeftButtonPressEvent)
    {
    for (int i = 0; i < VTKI_MAX_POINTERS; i++)
      {
      if (this->PointersDown[i])
        {
        this->StartingEventPositions[i][0] =
          this->EventPositions[i][0];
        this->StartingEventPositions[i][1] =
          this->EventPositions[i][1];
        }
      }
    // we do not know what the gesture is yet
    this->CurrentGesture = vtkCommand::StartEvent;
    return;
    }

  // end the gesture if needed
  if (event == vtkCommand::LeftButtonReleaseEvent)
    {
    if (this->CurrentGesture == vtkCommand::PinchEvent)
      {
      this->EndPinchEvent();
      }
    if (this->CurrentGesture == vtkCommand::RotateEvent)
      {
      this->EndRotateEvent();
      }
    if (this->CurrentGesture == vtkCommand::PanEvent)
      {
      this->EndPanEvent();
      }
    this->CurrentGesture = vtkCommand::StartEvent;
    return;
    }

  // what are the two pointers we are working with
  int count = 0;
  int *posVals[2];
  int *startVals[2];
  for (int i = 0; i < VTKI_MAX_POINTERS; i++)
    {
    if (this->PointersDown[i])
      {
      posVals[count] = this->EventPositions[i];
      startVals[count] = this->StartingEventPositions[i];
      count++;
      }
    }

  // The meat of the algorithm
  // on move events we analyze them to determine what type
  // of movement it is and then deal with it.
  if (event == vtkCommand::MouseMoveEvent)
    {
    // calculate the distances
    double originalDistance = sqrt(
        static_cast<double>(
        (startVals[0][0] - startVals[1][0])*(startVals[0][0] - startVals[1][0])
        + (startVals[0][1] - startVals[1][1])*(startVals[0][1] - startVals[1][1])));
    double newDistance = sqrt(
        static_cast<double>(
        (posVals[0][0] - posVals[1][0])*(posVals[0][0] - posVals[1][0])
        + (posVals[0][1] - posVals[1][1])*(posVals[0][1] - posVals[1][1])));

    // calculate rotations
    double originalAngle =
      vtkMath::DegreesFromRadians( atan2((double)startVals[1][1] - startVals[0][1],
                                         (double)startVals[1][0] - startVals[0][0]));
    double newAngle =
      vtkMath::DegreesFromRadians( atan2( (double)posVals[1][1] - posVals[0][1],
                                          (double)posVals[1][0] - posVals[0][0]));

    // angles are cyclic so watch for that, 1 and 359 are only 2 apart :)
    double angleDeviation = newAngle - originalAngle;
    newAngle = (newAngle+180.0 >= 360.0 ? newAngle - 180.0 : newAngle + 180.0);
    originalAngle = (originalAngle+180.0 >= 360.0 ? originalAngle - 180.0 : originalAngle + 180.0);
    if (fabs(newAngle - originalAngle) < fabs(angleDeviation))
      {
      angleDeviation = newAngle - originalAngle;
      }

    // calculate the translations
    double trans[2];
      trans[0] = (posVals[0][0] - startVals[0][0] + posVals[1][0] - startVals[1][0])/2.0;
      trans[1] = (posVals[0][1] - startVals[0][1] + posVals[1][1] - startVals[1][1])/2.0;

    // OK we want to
    // - immediately respond to the user
    // - allow the user to zoom without panning (saves focal point)
    // - allow the user to rotate without panning (saves focal point)

    // do we know what gesture we are doing yet? If not
    // see if we can figure it out
    if (this->CurrentGesture == vtkCommand::StartEvent)
      {
      // pinch is a move to/from the center point
      // rotate is a move along the circumference
      // pan is a move of the center point
      // compute the distance along each of these axes in pixels
      // the first to break thresh wins
705 706
      double thresh = 0.01*sqrt(
        static_cast<double>(this->Size[0]*this->Size[0] + this->Size[1]*this->Size[1]));
707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762
      if (thresh < 15.0)
        {
        thresh = 15.0;
        }
      double pinchDistance = fabs(newDistance - originalDistance);
      double rotateDistance = newDistance*3.1415926*fabs(angleDeviation)/360.0;
      double panDistance = sqrt(trans[0]*trans[0] + trans[1]*trans[1]);
      if (pinchDistance > thresh
          && pinchDistance > rotateDistance
          && pinchDistance > panDistance)
        {
        this->CurrentGesture = vtkCommand::PinchEvent;
        this->Scale = 1.0;
        this->StartPinchEvent();
        }
      else if (rotateDistance > thresh
          && rotateDistance > panDistance)
        {
        this->CurrentGesture = vtkCommand::RotateEvent;
        this->Rotation = 0.0;
        this->StartRotateEvent();
        }
      else if (panDistance > thresh)
        {
        this->CurrentGesture = vtkCommand::PanEvent;
        this->Translation[0] = 0.0;
        this->Translation[1] = 0.0;
        this->StartPanEvent();
        }
      }

    // if we have found a specific type of movement then
    // handle it
    if (this->CurrentGesture == vtkCommand::RotateEvent)
      {
      this->SetRotation(angleDeviation);
      this->RotateEvent();
      }

    if (this->CurrentGesture == vtkCommand::PinchEvent)
      {
        vtkErrorMacro("See pinch");
      this->SetScale(newDistance/originalDistance);
      this->PinchEvent();
      }

    if (this->CurrentGesture == vtkCommand::PanEvent)
      {
      this->SetTranslation(trans);
      this->PanEvent();
      }

    }

}

763 764 765 766

// Timer methods. There are two basic groups of methods, those for backward
// compatibility (group #1) and those that operate on specific timers (i.e.,
// use timer ids). The first group of methods implicitly assume that there is
767
// only one timer at a time running. This was okay in the old days of VTK when
768 769 770 771
// only the interactors used timers. However with the introduction of new 3D
// widgets into VTK multiple timers often run simultaneously.
//
//old-style group #1
772
int vtkRenderWindowInteractor::CreateTimer(int timerType)
773 774
{
  int platformTimerId, timerId;
775
  if ( timerType == VTKI_TIMER_FIRST )
776 777 778 779
    {
    unsigned long duration = this->TimerDuration;
    timerId = vtkTimerId; //just use current id, assume we don't have mutliple timers
    platformTimerId = this->InternalCreateTimer(timerId,RepeatingTimer,duration);
780
    if ( 0 == platformTimerId )
781 782 783 784 785 786 787 788 789 790 791
      {
      return 0;
      }
    (*this->TimerMap)[timerId] = vtkTimerStruct(platformTimerId,RepeatingTimer,duration);
    return timerId;
    }

  else //VTKI_TIMER_UPDATE is just updating last created timer
    {
    return 1; //do nothing because repeating timer has been created
    }
792
}
793 794 795

//old-style group #1
//just destroy last one created
796
int vtkRenderWindowInteractor::DestroyTimer()
797 798 799 800 801 802 803 804 805 806 807
{
  int timerId = vtkTimerId;
  vtkTimerIdMapIterator iter = this->TimerMap->find(timerId);
  if ( iter != this->TimerMap->end() )
    {
    this->InternalDestroyTimer((*iter).second.Id);
    this->TimerMap->erase(iter);
    return 1;
    }

  return 0;
808
}
809 810

//new-style group #2 returns timer id
811
int vtkRenderWindowInteractor::CreateRepeatingTimer(unsigned long duration)
812 813 814
{
  int timerId = ++vtkTimerId;
  int platformTimerId = this->InternalCreateTimer(timerId,RepeatingTimer,duration);
815
  if ( 0 == platformTimerId )
816 817 818 819 820
    {
    return 0;
    }
  (*this->TimerMap)[timerId] = vtkTimerStruct(platformTimerId,RepeatingTimer,duration);
  return timerId;
821
}
822 823

//new-style group #2 returns timer id
824
int vtkRenderWindowInteractor::CreateOneShotTimer(unsigned long duration)
825 826 827
{
  int timerId = ++vtkTimerId;
  int platformTimerId = this->InternalCreateTimer(timerId,OneShotTimer,duration);
828
  if ( 0 == platformTimerId )
829 830 831 832 833
    {
    return 0;
    }
  (*this->TimerMap)[timerId] = vtkTimerStruct(platformTimerId,OneShotTimer,duration);
  return timerId;
834
}
835 836

//new-style group #2 returns type (non-zero unless bad timerId)
837
int vtkRenderWindowInteractor::IsOneShotTimer(int timerId)
838 839 840 841
{
  vtkTimerIdMapIterator iter = this->TimerMap->find(timerId);
  if ( iter != this->TimerMap->end() )
    {
842
    return ((*iter).second.Type == OneShotTimer);
843 844
    }
  return 0;
845
}
846 847

//new-style group #2 returns duration (non-zero unless bad timerId)
848
unsigned long vtkRenderWindowInteractor::GetTimerDuration(int timerId)
849 850 851 852 853 854 855
{
  vtkTimerIdMapIterator iter = this->TimerMap->find(timerId);
  if ( iter != this->TimerMap->end() )
    {
    return (*iter).second.Duration;
    }
  return 0;
856
}
857 858

//new-style group #2 returns non-zero if timer reset
859
int vtkRenderWindowInteractor::ResetTimer(int timerId)
860 861 862 863 864 865 866
{
  vtkTimerIdMapIterator iter = this->TimerMap->find(timerId);
  if ( iter != this->TimerMap->end() )
    {
    this->InternalDestroyTimer((*iter).second.Id);
    int platformTimerId = this->InternalCreateTimer(timerId, (*iter).second.Type,
                                                    (*iter).second.Duration);
867
    if ( platformTimerId != 0 )
868 869 870 871 872 873 874 875 876 877
      {
      (*iter).second.Id = platformTimerId;
      return 1;
      }
    else
      {
      this->TimerMap->erase(iter);
      }
    }
  return 0;
878
}
879 880

//new-style group #2 returns non-zero if timer destroyed
881
int vtkRenderWindowInteractor::DestroyTimer(int timerId)
882 883 884 885 886 887 888 889 890
{
  vtkTimerIdMapIterator iter = this->TimerMap->find(timerId);
  if ( iter != this->TimerMap->end() )
    {
    this->InternalDestroyTimer((*iter).second.Id);
    this->TimerMap->erase(iter);
    return 1;
    }
  return 0;
891
}
892 893

// Stubbed out dummys
894
int vtkRenderWindowInteractor::InternalCreateTimer(int vtkNotUsed(timerId), int vtkNotUsed(timerType),
895 896 897 898 899 900 901 902 903 904
                                                   unsigned long vtkNotUsed(duration))
{
  return 0;
}

int vtkRenderWindowInteractor::InternalDestroyTimer(int vtkNotUsed(platformTimerId))
{
  return 0;
}

905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926
// Translate from platformTimerId to the corresponding (VTK) timerId.
// Returns 0 (invalid VTK timerId) if platformTimerId is not found in the map.
// This first stab at an implementation just iterates the map until it finds
// the sought platformTimerId. If performance becomes an issue (lots of timers,
// all firing frequently...) we could speed this up by making a reverse map so
// this method is a quick map lookup.
int vtkRenderWindowInteractor::GetVTKTimerId(int platformTimerId)
{
  int timerId = 0;
  vtkTimerIdMapIterator iter = this->TimerMap->begin();
  for ( ; iter != this->TimerMap->end(); ++iter )
    {
    if ((*iter).second.Id == platformTimerId)
      {
      timerId = (*iter).first;
      break;
      }
    }

  return timerId;
}

927 928 929 930 931 932
// Access to the static variable
int vtkRenderWindowInteractor::GetCurrentTimerId()
{
  return vtkTimerId;
}

Will Schroeder's avatar
Will Schroeder committed
933
//----------------------------------------------------------------------------
934
void vtkRenderWindowInteractor::PrintSelf(ostream& os, vtkIndent indent)
935
{
Brad King's avatar
Brad King committed
936
  this->Superclass::PrintSelf(os,indent);
937

Ken Martin's avatar
Ken Martin committed
938
  os << indent << "InteractorStyle:    " << this->InteractorStyle << "\n";
Ken Martin's avatar
Ken Martin committed
939 940
  os << indent << "RenderWindow:    " << this->RenderWindow << "\n";
  if ( this->Picker )
941
    {
Ken Martin's avatar
Ken Martin committed
942
    os << indent << "Picker: " << this->Picker << "\n";
943
    }
Ken Martin's avatar
Ken Martin committed
944
  else
945
    {
Ken Martin's avatar
Ken Martin committed
946
    os << indent << "Picker: (none)\n";
947
    }
948 949 950 951 952 953 954 955
  if ( this->ObserverMediator )
    {
    os << indent << "Observer Mediator: " << this->ObserverMediator << "\n";
    }
  else
    {
    os << indent << "Observer Mediator: (none)\n";
    }
Ken Martin's avatar
Ken Martin committed
956 957 958 959 960
  os << indent << "LightFollowCamera: " << (this->LightFollowCamera ? "On\n" : "Off\n");
  os << indent << "DesiredUpdateRate: " << this->DesiredUpdateRate << "\n";
  os << indent << "StillUpdateRate: " << this->StillUpdateRate << "\n";
  os << indent << "Initialized: " << this->Initialized << "\n";
  os << indent << "Enabled: " << this->Enabled << "\n";
961
  os << indent << "EnableRender: " << this->EnableRender << "\n";
Ken Martin's avatar
Ken Martin committed
962 963
  os << indent << "EventPosition: " << "( " << this->EventPosition[0] <<
    ", " << this->EventPosition[1] << " )\n";
964
  os << indent << "LastEventPosition: " << "( " << this->LastEventPosition[0]
965
     << ", " << this->LastEventPosition[1] << " )\n";
Sebastien Barre's avatar
Sebastien Barre committed
966 967
  os << indent << "EventSize: " << "( " << this->EventSize[0] <<
    ", " << this->EventSize[1] << " )\n";
Ken Martin's avatar
Ken Martin committed
968 969
  os << indent << "Viewport Size: " << "( " << this->Size[0] <<
    ", " << this->Size[1] << " )\n";
970 971
  os << indent << "Number of Fly Frames: " << this->NumberOfFlyFrames <<"\n";
  os << indent << "Dolly: " << this->Dolly <<"\n";
972
  os << indent << "ControlKey: " << this->ControlKey << "\n";
973
  os << indent << "AltKey: " << this->AltKey << "\n";
974 975
  os << indent << "ShiftKey: " << this->ShiftKey << "\n";
  os << indent << "KeyCode: " << this->KeyCode << "\n";
976
  os << indent << "KeySym: " << (this->KeySym ? this->KeySym : "(null)")
Ken Martin's avatar
Ken Martin committed
977
     << "\n";
978
  os << indent << "RepeatCount: " << this->RepeatCount << "\n";
979
  os << indent << "Timer Duration: " << this->TimerDuration << "\n";
980 981 982 983
  os << indent << "TimerEventId: " << this->TimerEventId << "\n";
  os << indent << "TimerEventType: " << this->TimerEventType << "\n";
  os << indent << "TimerEventDuration: " << this->TimerEventDuration << "\n";
  os << indent << "TimerEventPlatformId: " << this->TimerEventPlatformId << "\n";
984
  os << indent << "UseTDx: " << this->UseTDx << endl;
985
  os << indent << "Recognize Gestures: " << this->RecognizeGestures << endl;
986
}
987

988
//----------------------------------------------------------------------------
989
void vtkRenderWindowInteractor::Initialize()
990
{
991
  this->Initialized=1;
992
  this->Enable();
993
  this->Render();
994 995
}

996
//----------------------------------------------------------------------------
997 998 999
void vtkRenderWindowInteractor::HideCursor()
{
  this->RenderWindow->HideCursor();
1000 1001 1002
}

//----------------------------------------------------------------------------
1003 1004 1005
void vtkRenderWindowInteractor::ShowCursor()
{
  this->RenderWindow->ShowCursor();
1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018
}

//----------------------------------------------------------------------------
vtkObserverMediator *vtkRenderWindowInteractor::GetObserverMediator()
{
  if ( !this->ObserverMediator )
    {
    this->ObserverMediator = vtkObserverMediator::New();
    this->ObserverMediator->SetInteractor(this);
    }

  return this->ObserverMediator;
}
1019 1020 1021 1022

//------------------------------------------------------------------
void vtkRenderWindowInteractor::MouseMoveEvent()
{
1023
  if (!this->Enabled)
1024 1025 1026
    {
    return;
    }
1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037

  // handle gestures or not?
  if (this->RecognizeGestures && this->PointersDownCount > 1)
    {
    // handle the gesture
    this->RecognizeGesture(vtkCommand::MouseMoveEvent);
    }
  else
    {
    this->InvokeEvent(vtkCommand::MouseMoveEvent, NULL);
    }
1038 1039 1040 1041 1042
}

//------------------------------------------------------------------
void vtkRenderWindowInteractor::RightButtonPressEvent()
{
1043
  if (!this->Enabled)
1044 1045 1046 1047 1048 1049 1050 1051 1052
    {
    return;
    }
  this->InvokeEvent(vtkCommand::RightButtonPressEvent, NULL);
}

//------------------------------------------------------------------
void vtkRenderWindowInteractor::RightButtonReleaseEvent()
{
1053
  if (!this->Enabled)
1054 1055 1056 1057 1058 1059 1060 1061 1062
    {
    return;
    }
  this->InvokeEvent(vtkCommand::RightButtonReleaseEvent, NULL);
}

//------------------------------------------------------------------
void vtkRenderWindowInteractor::LeftButtonPressEvent()
{
1063
  if (!this->Enabled)
1064 1065 1066
    {
    return;
    }
1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089

  // are we translating multitouch into gestures?
  if (this->RecognizeGestures)
    {
    if (!this->PointersDown[this->PointerIndex])
      {
      this->PointersDown[this->PointerIndex] = 1;
      this->PointersDownCount++;
      }
    // do we have multitouch
    if (this->PointersDownCount > 1)
      {
      // did we just transition to multitouch?
      if (this->PointersDownCount == 2)
        {
        this->InvokeEvent(vtkCommand::LeftButtonReleaseEvent, NULL);
        }
      // handle the gesture
      this->RecognizeGesture(vtkCommand::LeftButtonPressEvent);
      return;
      }
    }

1090 1091 1092 1093 1094 1095
  this->InvokeEvent(vtkCommand::LeftButtonPressEvent, NULL);
}

//------------------------------------------------------------------
void vtkRenderWindowInteractor::LeftButtonReleaseEvent()
{
1096
  if (!this->Enabled)
1097 1098 1099
    {
    return;
    }
1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115

  if (this->RecognizeGestures)
    {
    if (this->PointersDown[this->PointerIndex])
      {
      this->PointersDown[this->PointerIndex] = 0;
      this->PointersDownCount--;
      }
    // do we have multitouch
    if (this->PointersDownCount > 1)
      {
      // handle the gesture
      this->RecognizeGesture(vtkCommand::LeftButtonReleaseEvent);
      return;
      }
    }
1116 1117 1118 1119 1120 1121
  this->InvokeEvent(vtkCommand::LeftButtonReleaseEvent, NULL);
}

//------------------------------------------------------------------
void vtkRenderWindowInteractor::MiddleButtonPressEvent()
{
1122
  if (!this->Enabled)
1123 1124 1125 1126 1127 1128 1129 1130 1131
    {
    return;
    }
  this->InvokeEvent(vtkCommand::MiddleButtonPressEvent, NULL);
}

//------------------------------------------------------------------
void vtkRenderWindowInteractor::MiddleButtonReleaseEvent()
{
1132
  if (!this->Enabled)
1133 1134 1135 1136 1137 1138 1139 1140 1141
    {
    return;
    }
  this->InvokeEvent(vtkCommand::MiddleButtonReleaseEvent, NULL);
}

//------------------------------------------------------------------
void vtkRenderWindowInteractor::MouseWheelForwardEvent()
{
1142
  if (!this->Enabled)
1143 1144 1145 1146 1147 1148 1149 1150 1151
    {
    return;
    }
  this->InvokeEvent(vtkCommand::MouseWheelForwardEvent, NULL);
}

//------------------------------------------------------------------
void vtkRenderWindowInteractor::MouseWheelBackwardEvent()
{
1152
  if (!this->Enabled)
1153 1154 1155 1156 1157 1158 1159 1160 1161
    {
    return;
    }
  this->InvokeEvent(vtkCommand::MouseWheelBackwardEvent, NULL);
}

//------------------------------------------------------------------
void vtkRenderWindowInteractor::ExposeEvent()
{
1162
  if (!this->Enabled)
1163 1164 1165 1166 1167 1168 1169 1170 1171
    {
    return;
    }
  this->InvokeEvent(vtkCommand::ExposeEvent, NULL);
}

//------------------------------------------------------------------
void vtkRenderWindowInteractor::ConfigureEvent()
{
1172
  if (!this->Enabled)
1173 1174 1175 1176 1177 1178 1179 1180 1181
    {
    return;
    }
  this->InvokeEvent(vtkCommand::ConfigureEvent, NULL);
}

//------------------------------------------------------------------
void vtkRenderWindowInteractor::EnterEvent()
{
1182
  if (!this->Enabled)
1183 1184 1185 1186 1187 1188 1189 1190 1191
    {
    return;
    }
  this->InvokeEvent(vtkCommand::EnterEvent, NULL);
}

//------------------------------------------------------------------
void vtkRenderWindowInteractor::LeaveEvent()
{
1192
  if (!this->Enabled)
1193 1194 1195 1196 1197 1198 1199 1200 1201
    {
    return;
    }
  this->InvokeEvent(vtkCommand::LeaveEvent, NULL);
}

//------------------------------------------------------------------
void vtkRenderWindowInteractor::KeyPressEvent()
{
1202
  if (!this->Enabled)
1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221
    {
    return;
    }
  this->InvokeEvent(vtkCommand::KeyPressEvent, NULL);
}

//------------------------------------------------------------------
void vtkRenderWindowInteractor::KeyReleaseEvent()
{
  if (!this->Enabled)
    {
    return;
    }
  this->InvokeEvent(vtkCommand::KeyReleaseEvent, NULL);
}

//------------------------------------------------------------------
void vtkRenderWindowInteractor::CharEvent()
{
1222
  if (!this->Enabled)
1223 1224 1225 1226 1227 1228 1229 1230 1231
    {
    return;
    }
  this->InvokeEvent(vtkCommand::CharEvent, NULL);
}

//------------------------------------------------------------------
void vtkRenderWindowInteractor::ExitEvent()
{
1232
  if (!this->Enabled)
1233 1234 1235 1236 1237 1238
    {
    return;
    }
  this->InvokeEvent(vtkCommand::ExitEvent, NULL);
}

1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265
//------------------------------------------------------------------
void vtkRenderWindowInteractor::StartPinchEvent()
{
  if (!this->Enabled)
    {
    return;
    }
  this->InvokeEvent(vtkCommand::StartPinchEvent, NULL);
}
//------------------------------------------------------------------
void vtkRenderWindowInteractor::PinchEvent()
{
  if (!this->Enabled)
    {
    return;
    }
  this->InvokeEvent(vtkCommand::PinchEvent, NULL);
}
//------------------------------------------------------------------
void vtkRenderWindowInteractor::EndPinchEvent()
{
  if (!this->Enabled)
    {
    return;
    }
  this->InvokeEvent(vtkCommand::EndPinchEvent, NULL);
}
1266

1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350
//------------------------------------------------------------------
void vtkRenderWindowInteractor::StartRotateEvent()
{
  if (!this->Enabled)
    {
    return;
    }
  this->InvokeEvent(vtkCommand::StartRotateEvent, NULL);
}
//------------------------------------------------------------------
void vtkRenderWindowInteractor::RotateEvent()
{
  if (!this->Enabled)
    {
    return;
    }
  this->InvokeEvent(vtkCommand::RotateEvent, NULL);
}
//------------------------------------------------------------------
void vtkRenderWindowInteractor::EndRotateEvent()
{
  if (!this->Enabled)
    {
    return;
    }
  this->InvokeEvent(vtkCommand::EndRotateEvent, NULL);
}

//------------------------------------------------------------------
void vtkRenderWindowInteractor::StartPanEvent()
{
  if (!this->Enabled)
    {
    return;
    }
  this->InvokeEvent(vtkCommand::StartPanEvent, NULL);
}
//------------------------------------------------------------------
void vtkRenderWindowInteractor::PanEvent()
{
  if (!this->Enabled)
    {
    return;
    }
  this->InvokeEvent(vtkCommand::PanEvent, NULL);
}
//------------------------------------------------------------------
void vtkRenderWindowInteractor::EndPanEvent()
{
  if (!this->Enabled)
    {
    return;
    }
  this->InvokeEvent(vtkCommand::EndPanEvent, NULL);
}

//------------------------------------------------------------------
void vtkRenderWindowInteractor::TapEvent()
{
  if (!this->Enabled)
    {
    return;
    }
  this->InvokeEvent(vtkCommand::TapEvent, NULL);
}
//------------------------------------------------------------------
void vtkRenderWindowInteractor::LongTapEvent()
{
  if (!this->Enabled)
    {
    return;
    }
  this->InvokeEvent(vtkCommand::LongTapEvent, NULL);
}

//------------------------------------------------------------------
void vtkRenderWindowInteractor::SwipeEvent()
{
  if (!this->Enabled)
    {
    return;
    }
  this->InvokeEvent(vtkCommand::SwipeEvent, NULL);
}