Commit 0c02cf6e authored by Will Schroeder's avatar Will Schroeder

ENH:Grab and release focus on sequence of interaction events

parent 8ee99f5e
......@@ -20,10 +20,10 @@
#include "vtkMath.h"
#include "vtkObjectFactory.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkCommand.h"
#include "vtkCallbackCommand.h"
#include "vtkWindows.h"
vtkCxxRevisionMacro(vtkInteractorStyleFlight, "1.30");
vtkCxxRevisionMacro(vtkInteractorStyleFlight, "1.31");
vtkStandardNewMacro(vtkInteractorStyleFlight);
class CPIDControl
......@@ -252,7 +252,9 @@ void vtkInteractorStyleFlight::OnLeftButtonDown()
{
return;
}
//
this->Interactor->GrabFocus(this->EventCallbackCommand);
vtkCamera* cam = this->CurrentRenderer->GetActiveCamera();
switch (this->State)
{
......@@ -277,6 +279,10 @@ void vtkInteractorStyleFlight::OnLeftButtonUp()
default :
break;
}
if ( this->Interactor )
{
this->Interactor->ReleaseFocus();
}
}
//---------------------------------------------------------------------------
......@@ -299,7 +305,9 @@ void vtkInteractorStyleFlight::OnRightButtonDown()
{
return;
}
//
this->Interactor->GrabFocus(this->EventCallbackCommand);
vtkCamera* cam = this->CurrentRenderer->GetActiveCamera();
switch (this->State)
{
......@@ -324,6 +332,10 @@ void vtkInteractorStyleFlight::OnRightButtonUp()
default :
break;
}
if ( this->Interactor )
{
this->Interactor->ReleaseFocus();
}
}
//---------------------------------------------------------------------------
......
......@@ -16,12 +16,12 @@
#include "vtkAbstractPropPicker.h"
#include "vtkAssemblyPath.h"
#include "vtkCommand.h"
#include "vtkCallbackCommand.h"
#include "vtkMath.h"
#include "vtkObjectFactory.h"
#include "vtkRenderWindowInteractor.h"
vtkCxxRevisionMacro(vtkInteractorStyleImage, "1.25");
vtkCxxRevisionMacro(vtkInteractorStyleImage, "1.26");
vtkStandardNewMacro(vtkInteractorStyleImage);
//----------------------------------------------------------------------------
......@@ -122,7 +122,7 @@ void vtkInteractorStyleImage::OnLeftButtonDown()
}
// Redefine this button to handle window/level
this->Interactor->GrabFocus(this->EventCallbackCommand);
if (!this->Interactor->GetShiftKey() && !this->Interactor->GetControlKey())
{
this->WindowLevelStartPosition[0] = x;
......@@ -145,6 +145,10 @@ void vtkInteractorStyleImage::OnLeftButtonUp()
{
case VTKIS_WINDOW_LEVEL:
this->EndWindowLevel();
if ( this->Interactor )
{
this->Interactor->ReleaseFocus();
}
break;
}
......@@ -166,7 +170,7 @@ void vtkInteractorStyleImage::OnRightButtonDown()
}
// Redefine this button + shift to handle pick
this->Interactor->GrabFocus(this->EventCallbackCommand);
if (this->Interactor->GetShiftKey())
{
this->StartPick();
......@@ -187,6 +191,10 @@ void vtkInteractorStyleImage::OnRightButtonUp()
{
case VTKIS_PICK:
this->EndPick();
if ( this->Interactor )
{
this->Interactor->ReleaseFocus();
}
break;
}
......
......@@ -15,7 +15,7 @@
#include "vtkInteractorStyleJoystickActor.h"
#include "vtkCamera.h"
#include "vtkCommand.h"
#include "vtkCallbackCommand.h"
#include "vtkMath.h"
#include "vtkObjectFactory.h"
#include "vtkRenderWindowInteractor.h"
......@@ -25,7 +25,7 @@
#include "vtkTransform.h"
#include "vtkMatrix4x4.h"
vtkCxxRevisionMacro(vtkInteractorStyleJoystickActor, "1.31");
vtkCxxRevisionMacro(vtkInteractorStyleJoystickActor, "1.32");
vtkStandardNewMacro(vtkInteractorStyleJoystickActor);
//----------------------------------------------------------------------------
......@@ -78,6 +78,7 @@ void vtkInteractorStyleJoystickActor::OnLeftButtonDown()
return;
}
this->Interactor->GrabFocus(this->EventCallbackCommand);
if (this->Interactor->GetShiftKey())
{
this->StartPan();
......@@ -109,8 +110,13 @@ void vtkInteractorStyleJoystickActor::OnLeftButtonUp()
this->EndRotate();
break;
}
if ( this->Interactor )
{
this->Interactor->ReleaseFocus();
}
}
//----------------------------------------------------------------------------
void vtkInteractorStyleJoystickActor::OnMiddleButtonDown()
{
......@@ -124,6 +130,7 @@ void vtkInteractorStyleJoystickActor::OnMiddleButtonDown()
return;
}
this->Interactor->GrabFocus(this->EventCallbackCommand);
if (this->Interactor->GetControlKey())
{
this->StartDolly();
......@@ -147,6 +154,11 @@ void vtkInteractorStyleJoystickActor::OnMiddleButtonUp()
this->EndPan();
break;
}
if ( this->Interactor )
{
this->Interactor->ReleaseFocus();
}
}
//----------------------------------------------------------------------------
......@@ -162,6 +174,7 @@ void vtkInteractorStyleJoystickActor::OnRightButtonDown()
return;
}
this->Interactor->GrabFocus(this->EventCallbackCommand);
this->StartUniformScale();
}
......@@ -172,6 +185,10 @@ void vtkInteractorStyleJoystickActor::OnRightButtonUp()
{
case VTKIS_USCALE:
this->EndUniformScale();
if ( this->Interactor )
{
this->Interactor->ReleaseFocus();
}
break;
}
}
......
......@@ -15,13 +15,13 @@
#include "vtkInteractorStyleJoystickCamera.h"
#include "vtkCamera.h"
#include "vtkCommand.h"
#include "vtkCallbackCommand.h"
#include "vtkMath.h"
#include "vtkObjectFactory.h"
#include "vtkRenderer.h"
#include "vtkRenderWindowInteractor.h"
vtkCxxRevisionMacro(vtkInteractorStyleJoystickCamera, "1.30");
vtkCxxRevisionMacro(vtkInteractorStyleJoystickCamera, "1.31");
vtkStandardNewMacro(vtkInteractorStyleJoystickCamera);
//----------------------------------------------------------------------------
......@@ -67,6 +67,7 @@ void vtkInteractorStyleJoystickCamera::OnLeftButtonDown()
return;
}
this->Interactor->GrabFocus(this->EventCallbackCommand);
if (this->Interactor->GetShiftKey())
{
if (this->Interactor->GetControlKey())
......@@ -112,6 +113,10 @@ void vtkInteractorStyleJoystickCamera::OnLeftButtonUp()
this->EndRotate();
break;
}
if ( this->Interactor )
{
this->Interactor->ReleaseFocus();
}
}
//----------------------------------------------------------------------------
......@@ -124,6 +129,7 @@ void vtkInteractorStyleJoystickCamera::OnMiddleButtonDown()
return;
}
this->Interactor->GrabFocus(this->EventCallbackCommand);
this->StartPan();
}
......@@ -136,6 +142,10 @@ void vtkInteractorStyleJoystickCamera::OnMiddleButtonUp()
this->EndPan();
break;
}
if ( this->Interactor )
{
this->Interactor->ReleaseFocus();
}
}
//----------------------------------------------------------------------------
......@@ -148,6 +158,7 @@ void vtkInteractorStyleJoystickCamera::OnRightButtonDown()
return;
}
this->Interactor->GrabFocus(this->EventCallbackCommand);
this->StartDolly();
}
......@@ -160,6 +171,10 @@ void vtkInteractorStyleJoystickCamera::OnRightButtonUp()
this->EndDolly();
break;
}
if ( this->Interactor )
{
this->Interactor->ReleaseFocus();
}
}
//----------------------------------------------------------------------------
......@@ -172,10 +187,12 @@ void vtkInteractorStyleJoystickCamera::OnMouseWheelForward()
return;
}
this->Interactor->GrabFocus(this->EventCallbackCommand);
this->StartDolly();
double factor = 10.0 * 0.2 * this->MouseWheelMotionFactor;
this->Dolly(pow((double)1.1, factor));
this->EndDolly();
this->Interactor->ReleaseFocus();
}
//----------------------------------------------------------------------------
......@@ -188,10 +205,12 @@ void vtkInteractorStyleJoystickCamera::OnMouseWheelBackward()
return;
}
this->Interactor->GrabFocus(this->EventCallbackCommand);
this->StartDolly();
double factor = 10.0 * -0.2 * this->MouseWheelMotionFactor;
this->Dolly(pow((double)1.1, factor));
this->EndDolly();
this->Interactor->ReleaseFocus();
}
//----------------------------------------------------------------------------
......
......@@ -16,7 +16,7 @@
#include "vtkActor.h"
#include "vtkCamera.h"
#include "vtkCommand.h"
#include "vtkCallbackCommand.h"
#include "vtkExtractEdges.h"
#include "vtkMath.h"
#include "vtkObjectFactory.h"
......@@ -27,7 +27,7 @@
#include "vtkRenderer.h"
#include "vtkSphereSource.h"
vtkCxxRevisionMacro(vtkInteractorStyleTerrain, "1.9");
vtkCxxRevisionMacro(vtkInteractorStyleTerrain, "1.10");
vtkStandardNewMacro(vtkInteractorStyleTerrain);
//----------------------------------------------------------------------------
......@@ -105,6 +105,7 @@ void vtkInteractorStyleTerrain::OnLeftButtonDown ()
return;
}
this->Interactor->GrabFocus(this->EventCallbackCommand);
this->StartRotate();
}
......@@ -115,6 +116,10 @@ void vtkInteractorStyleTerrain::OnLeftButtonUp ()
{
case VTKIS_ROTATE:
this->EndRotate();
if ( this->Interactor )
{
this->Interactor->ReleaseFocus();
}
break;
}
}
......@@ -129,6 +134,7 @@ void vtkInteractorStyleTerrain::OnMiddleButtonDown ()
return;
}
this->Interactor->GrabFocus(this->EventCallbackCommand);
this->StartPan();
}
......@@ -139,6 +145,10 @@ void vtkInteractorStyleTerrain::OnMiddleButtonUp ()
{
case VTKIS_PAN:
this->EndPan();
if ( this->Interactor )
{
this->Interactor->ReleaseFocus();
}
break;
}
}
......@@ -153,6 +163,7 @@ void vtkInteractorStyleTerrain::OnRightButtonDown ()
return;
}
this->Interactor->GrabFocus(this->EventCallbackCommand);
this->StartDolly();
}
......@@ -163,6 +174,10 @@ void vtkInteractorStyleTerrain::OnRightButtonUp ()
{
case VTKIS_DOLLY:
this->EndDolly();
if ( this->Interactor )
{
this->Interactor->ReleaseFocus();
}
break;
}
}
......
......@@ -16,7 +16,7 @@
#include "vtkCamera.h"
#include "vtkCellPicker.h"
#include "vtkCommand.h"
#include "vtkCallbackCommand.h"
#include "vtkMath.h"
#include "vtkMatrix4x4.h"
#include "vtkObjectFactory.h"
......@@ -25,7 +25,7 @@
#include "vtkRenderer.h"
#include "vtkTransform.h"
vtkCxxRevisionMacro(vtkInteractorStyleTrackballActor, "1.33");
vtkCxxRevisionMacro(vtkInteractorStyleTrackballActor, "1.34");
vtkStandardNewMacro(vtkInteractorStyleTrackballActor);
//----------------------------------------------------------------------------
......@@ -96,6 +96,7 @@ void vtkInteractorStyleTrackballActor::OnLeftButtonDown()
return;
}
this->Interactor->GrabFocus(this->EventCallbackCommand);
if (this->Interactor->GetShiftKey())
{
this->StartPan();
......@@ -127,6 +128,11 @@ void vtkInteractorStyleTrackballActor::OnLeftButtonUp()
this->EndRotate();
break;
}
if ( this->Interactor )
{
this->Interactor->ReleaseFocus();
}
}
//----------------------------------------------------------------------------
......@@ -142,6 +148,7 @@ void vtkInteractorStyleTrackballActor::OnMiddleButtonDown()
return;
}
this->Interactor->GrabFocus(this->EventCallbackCommand);
if (this->Interactor->GetControlKey())
{
this->StartDolly();
......@@ -165,6 +172,11 @@ void vtkInteractorStyleTrackballActor::OnMiddleButtonUp()
this->EndPan();
break;
}
if ( this->Interactor )
{
this->Interactor->ReleaseFocus();
}
}
//----------------------------------------------------------------------------
......@@ -180,6 +192,7 @@ void vtkInteractorStyleTrackballActor::OnRightButtonDown()
return;
}
this->Interactor->GrabFocus(this->EventCallbackCommand);
this->StartUniformScale();
}
......@@ -192,6 +205,11 @@ void vtkInteractorStyleTrackballActor::OnRightButtonUp()
this->EndUniformScale();
break;
}
if ( this->Interactor )
{
this->Interactor->ReleaseFocus();
}
}
//----------------------------------------------------------------------------
......
......@@ -15,14 +15,14 @@
#include "vtkInteractorStyleTrackballCamera.h"
#include "vtkCamera.h"
#include "vtkCommand.h"
#include "vtkCallbackCommand.h"
#include "vtkMath.h"
#include "vtkObjectFactory.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
vtkCxxRevisionMacro(vtkInteractorStyleTrackballCamera, "1.32");
vtkCxxRevisionMacro(vtkInteractorStyleTrackballCamera, "1.33");
vtkStandardNewMacro(vtkInteractorStyleTrackballCamera);
//----------------------------------------------------------------------------
......@@ -80,6 +80,7 @@ void vtkInteractorStyleTrackballCamera::OnLeftButtonDown()
return;
}
this->Interactor->GrabFocus(this->EventCallbackCommand);
if (this->Interactor->GetShiftKey())
{
if (this->Interactor->GetControlKey())
......@@ -125,6 +126,11 @@ void vtkInteractorStyleTrackballCamera::OnLeftButtonUp()
this->EndRotate();
break;
}
if ( this->Interactor )
{
this->Interactor->ReleaseFocus();
}
}
//----------------------------------------------------------------------------
......@@ -137,6 +143,7 @@ void vtkInteractorStyleTrackballCamera::OnMiddleButtonDown()
return;
}
this->Interactor->GrabFocus(this->EventCallbackCommand);
this->StartPan();
}
......@@ -147,6 +154,10 @@ void vtkInteractorStyleTrackballCamera::OnMiddleButtonUp()
{
case VTKIS_PAN:
this->EndPan();
if ( this->Interactor )
{
this->Interactor->ReleaseFocus();
}
break;
}
}
......@@ -161,6 +172,7 @@ void vtkInteractorStyleTrackballCamera::OnRightButtonDown()
return;
}
this->Interactor->GrabFocus(this->EventCallbackCommand);
this->StartDolly();
}
......@@ -171,6 +183,11 @@ void vtkInteractorStyleTrackballCamera::OnRightButtonUp()
{
case VTKIS_DOLLY:
this->EndDolly();
if ( this->Interactor )
{
this->Interactor->ReleaseFocus();
}
break;
}
}
......@@ -185,10 +202,12 @@ void vtkInteractorStyleTrackballCamera::OnMouseWheelForward()
return;
}
this->Interactor->GrabFocus(this->EventCallbackCommand);
this->StartDolly();
double factor = this->MotionFactor * 0.2 * this->MouseWheelMotionFactor;
this->Dolly(pow((double)1.1, factor));
this->EndDolly();
this->Interactor->ReleaseFocus();
}
//----------------------------------------------------------------------------
......@@ -201,10 +220,12 @@ void vtkInteractorStyleTrackballCamera::OnMouseWheelBackward()
return;
}
this->Interactor->GrabFocus(this->EventCallbackCommand);
this->StartDolly();
double factor = this->MotionFactor * -0.2 * this->MouseWheelMotionFactor;
this->Dolly(pow((double)1.1, factor));
this->EndDolly();
this->Interactor->ReleaseFocus();
}
//----------------------------------------------------------------------------
......
......@@ -34,8 +34,9 @@
#include "vtkSphereSource.h"
#include "vtkTransform.h"
#include "vtkWorldPointPicker.h"
#include "vtkCallbackCommand.h"
vtkCxxRevisionMacro(vtkInteractorStyleUnicam, "1.36");
vtkCxxRevisionMacro(vtkInteractorStyleUnicam, "1.37");
vtkStandardNewMacro(vtkInteractorStyleUnicam);
// define 'TheTime()' function-- returns time in elapsed seconds
......@@ -124,14 +125,16 @@ void vtkInteractorStyleUnicam::SetWorldUpVector(double x, double y, double z)
//----------------------------------------------------------------------------
void vtkInteractorStyleUnicam::OnLeftButtonDown()
{
this->Interactor->GrabFocus(this->EventCallbackCommand);
int x = this->Interactor->GetEventPosition()[0];
int y = this->Interactor->GetEventPosition()[1];
this->ButtonDown = VTK_UNICAM_BUTTON_LEFT;
if (this->UseTimers)
{
this->Interactor->CreateTimer(VTKI_TIMER_UPDATE);
}
if (this->UseTimers)
{
this->Interactor->CreateTimer(VTKI_TIMER_UPDATE);
}
this->DTime = TheTime();
this->Dist = 0;
......@@ -264,7 +267,7 @@ void vtkInteractorStyleUnicam::OnLeftButtonUp()
// calculate scale so focus sphere always is the same size on the screen
double s = 0.02 * vtkMath::Dot(at_v, vec);
this->FocusSphere->SetScale (s, s, s);
this->FocusSphere->SetScale(s, s, s);
this->FindPokedRenderer(x, y);
this->FocusSphereRenderer = this->CurrentRenderer;
......@@ -282,6 +285,8 @@ void vtkInteractorStyleUnicam::OnLeftButtonUp()
{
rwi->DestroyTimer();
}
this->Interactor->ReleaseFocus();
}
//----------------------------------------------------------------------------
......@@ -455,9 +460,13 @@ void vtkInteractorStyleUnicam::RotateXY( int X, int Y )
//
const double OVER_THE_TOP_THRESHOLD = 0.99;
if (vtkMath::Dot(UPvec, atV) > OVER_THE_TOP_THRESHOLD && rdist < 0)
{
rdist = 0;
}
if (vtkMath::Dot(UPvec, atV) < -OVER_THE_TOP_THRESHOLD && rdist > 0)
{
rdist = 0;
}
MyRotateCamera(center[0], center[1], center[2],
rightV[0], rightV[1], rightV[2],
......@@ -577,7 +586,7 @@ void vtkInteractorStyleUnicam::GetRightVandUpV(double *p, vtkCamera *cam,
double vec[3];
for(i=0; i<3; i++)
{
vec[i] = p[i] - from[i];
vec[i] = p[i] - from[i];
}
// Get shortest distance 'l' between the viewing position and
......@@ -600,7 +609,6 @@ void vtkInteractorStyleUnicam::GetRightVandUpV(double *p, vtkCamera *cam,
// to 'atV' & 'rightV')
vtkMath::Normalize(rightV);
vtkMath::Normalize(upV);
for(i=0; i<3; i++)
{
......@@ -650,7 +658,6 @@ void vtkInteractorStyleUnicam::MyRotateCamera(double cx, double cy, double cz,
// IMPORTANT! If you don't re-compute view plane normal, the camera
// view gets all messed up.
camera->ComputeViewPlaneNormal();
t->Delete();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment