[vtkusers] Two questions about handling multitouch events in VTK
HuaweiTu
tuhuawei09 at gmail.com
Fri Dec 28 08:13:18 EST 2012
Hi Joachim,
I hope you are fine.
According your suggestion, I have done some coding to handle multitouch
gesture events and recorded the corresponding gesture parameters, such as x,
y coordinates. Then I want to pass these parameters to the transition matrix
of VTK, so as to trigger corresponding manipulations of 3D image. Take the
following code as an example, I declared a Sphere object and used "move" for
3D image translation:
sphere = vtkSphereSource.New();
sphere.SetThetaResolution(8);
sphere.SetPhiResolution(16);
shrink = vtkShrinkPolyData.New();
shrink.SetInputConnection(sphere.GetOutputPort());
shrink.SetShrinkFactor(0.9);
move = vtkTransform.New();
move.Translate(_random.NextDouble(), _random.NextDouble(),
_random.NextDouble());
moveFilter = vtkTransformPolyDataFilter.New();
moveFilter.SetTransform(move);
moveFilter.SetInputConnection(shrink.GetOutputPort());
mapper = vtkPolyDataMapper.New();
mapper.SetInputConnection(moveFilter.GetOutputPort());
actor = vtkActor.New();
actor.SetMapper(mapper);
actor.GetProperty().SetColor(1, 0, 0);
ren1 = vtkRenderer.New();
renWin = vtkRenderWindow.New();
renWin.AddRenderer(ren1);
iren = vtkRenderWindowInteractor.New();
iren.SetRenderWindow(renWin);
ren1.AddViewProp(actor);
renWin.SetSize(500, 500);
renWin.Render();
iren.Initialize();
iren.Start();
In my current code, if the user performs a pan gesture, then a pan event is
triggered:
private void ProcessPan(object sender, GestureEventArgs args)
{
_translate.X += args.PanTranslation.Width;
_translate.Y += args.PanTranslation.Height; }
What I want to do is to pass the _translate.X, _translate.Y to move.
Translate() as two parameters, so that 3D image can be moved correspondingly
as user's pan gesture.
However, I tried several methods (e.g. set global variables) but no one can
work well. If possible, please give me some hints of how to do it.
Thank you very much for your kind help.
Wish you a happy new year.
--
View this message in context: http://vtk.1045678.n5.nabble.com/Two-questions-about-handling-multitouch-events-in-VTK-tp5717707p5717739.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list