# Remote interaction. Gestures handling

**URL:** https://discourse.vtk.org/t/remote-interaction-gestures-handling/5989
**Category:** Web
**Created:** [June 14, 2021, 10:42am UTC](https://discourse.vtk.org/t/remote-interaction-gestures-handling/5989 "2021-06-14T10:42:18Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![EMalikova](https://discourse.vtk.org/user_avatar/discourse.vtk.org/emalikova/32/5310_2.png) [@EMalikova](https://discourse.vtk.org/u/EMalikova)
#### Post date: [June 14, 2021, 10:42am UTC](https://discourse.vtk.org/t/remote-interaction-gestures-handling/5989/1 "2021-06-14T10:42:18Z")

</div>

Dear All,  
I am working with VTK-based remote vis from this [template](https://github.com/Kitware/web-project-templates) and I have to implement a gesture support.  
It seems that for this I have to extend code with rpcGestureEvent similarly to how it is done for rpcRemoteWheel in  
[js code](https://github.com/Kitware/web-project-templates/blob/master/vue-vtkjs-pvw-template/src/components/widgets/RemoteRenderingView/script.js#L22) and [python RPC implementation](https://github.com/Kitware/web-project-templates/blob/master/vue-vtkjs-pvw-template/server/vtkpython/vtk_protocol.py#L60)

However, I am not sure how to write a python part, what the event type and other data will be transferred and etc. Do I understand correctly that for this I should reference a [vtkInteractorStyleRemoteMouse](https://kitware.github.io/vtk-js/api/Interaction_Style_InteractorStyleRemoteMouse.html) class ?  
Is there any example of handling gestures in remote visualisation such as pinch, tap?

Thank you very much in advance,  
Best regards,  
Evgeniya

---

<div class="post-metadata">

### Author: ![EMalikova](https://discourse.vtk.org/user_avatar/discourse.vtk.org/emalikova/32/5310_2.png) [@EMalikova](https://discourse.vtk.org/u/EMalikova)
#### Post date: [June 15, 2021, 1:02pm UTC](https://discourse.vtk.org/t/remote-interaction-gestures-handling/5989/2 "2021-06-15T13:02:55Z")

</div>

Update:  
Sorry for the inconvenience. Turned out to be straightforward, according to data transmitted from [vtkInteractorStyleRemoteMouse](https://kitware.github.io/vtk-js/api/Interaction_Style_InteractorStyleRemoteMouse.html) class.

For example, the pinch handling with camera zoom that worked for me:

@exportRpc(“viewport.gesture”)  
def updateGesture(self, event):

```
  if 'StartPinch' in event["type"]:
    self.getApplication().InvokeEvent('StartInteractionEvent')
    renderWindow = self.getView(event['view'])
    print("StartPinch")
    camera = renderWindow.GetRenderers().GetFirstRenderer().GetActiveCamera()
    self.fp = camera.GetFocalPoint()
    self.pos = camera.GetPosition()
    
  if 'Pinch' in event["type"]:
    renderWindow = self.getView(event['view'])
    
    
    if renderWindow and 'scale' in event:
       scaleF=1.5
       zoomFactor = event['scale']/scaleF;

       camera = renderWindow.GetRenderers().GetFirstRenderer().GetActiveCamera()
       
       camera.Zoom(zoomFactor)
     
       renderWindow.Modified()

  if 'EndPinch' in event["type"]:
    self.getApplication().InvokeEvent('EndInteractionEvent')
```
