<div dir="ltr"><div dir="ltr"><div dir="ltr">Below is an example, but Google should be able to help you also on the JS side...<div><a href="https://github.com/Kitware/vtk-js/blob/master/Sources/Rendering/Core/RenderWindowInteractor/index.js#L214-L222">https://github.com/Kitware/vtk-js/blob/master/Sources/Rendering/Core/RenderWindowInteractor/index.js#L214-L222</a><br></div><div><br></div><div>Then for the RPC part you can find some inspiration there even if it is on ParaView</div><div><a href="https://github.com/Kitware/paraviewweb-examples">https://github.com/Kitware/paraviewweb-examples</a><br></div><div><br></div><div>Just FYI, if that make sense for what you are trying to do, we have support contract that could speed up the process on your end.</div><div><br></div><div>HTH,</div><div><br></div><div>Seb</div><div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Dec 3, 2018 at 9:22 AM ivan rodriguez <<a href="mailto:ivandiegorodriguez@gmail.com">ivandiegorodriguez@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks for the explanation! I don't really know how to add a listener on the client side so I'll really appreciate any help with that.  Do you have some example or do you know if there are some examples online about that?<div><br></div><div><div><br><div><br><div><br></div><div><br><div><br></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Dec 3, 2018 at 5:12 PM Sebastien Jourdain <<a href="mailto:sebastien.jourdain@kitware.com" target="_blank">sebastien.jourdain@kitware.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I'm not saying it is not the way to go. You just need to add a listener on the client side for the keyPress and forward that to the server.<div>That's it. Nothing more than that.</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Dec 3, 2018 at 9:06 AM ivan rodriguez <<a href="mailto:ivandiegorodriguez@gmail.com" target="_blank">ivandiegorodriguez@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks for the quick response! <div><br></div><div>I have an application written in VTK doing an animation through a timerCallback and using key events and I wanted to have a similar version for the browser. </div><div>So if vtkWeb is not the right way to go, do you know if vtk.js could be a good option for that?</div><div><br></div><div>Thanks!</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Dec 3, 2018 at 4:54 PM Sebastien Jourdain <<a href="mailto:sebastien.jourdain@kitware.com" target="_blank">sebastien.jourdain@kitware.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">The event handling needs to happen on the client side (JS) which should then trigger a RPC call to the server to adjust the resolution of the server data. I don't think we register any key listener in the browser that's why they don't get forwarded to the server.</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Dec 3, 2018 at 8:47 AM ivan rodriguez <<a href="mailto:ivandiegorodriguez@gmail.com" target="_blank">ivandiegorodriguez@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hello,<div><br></div><div>I'm using the module vtkWeb for Remote Rendering, following this simple python example:</div><div><br></div><div><font color="#1155cc"><u><a href="https://github.com/dmreagan/vtk-remote-render/blob/master/server/vtk_server.py" target="_blank">https://github.com/dmreagan/vtk-remote-render/blob/master/server/vtk_server.py</a></u></font><br></div><div><font color="#1155cc"><u><br></u></font></div><div>and I have modified it in order to include a keyPress event. The code works but the </div><div>key event is not working . Please find my code below (the only modification from the link is the class MyInteractorStyle ).</div><div><br></div><div>I'll really appreciate any help with this! </div><div><br></div><div>Thanks !!</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div>##########################################################################</div><div>##########################################################################</div><div><br></div><div><div># import to process args</div><div>import sys</div><div>import os</div><div><br></div><div># import vtk modules.</div><div>import vtk</div><div>from vtk.web import protocols</div><div>from vtk.web import wslink as vtk_wslink</div><div>from wslink import server</div><div><br></div><div>try:</div><div>    import argparse</div><div>except ImportError:</div><div>    # since  Python 2.6 and earlier don't have argparse, we simply provide</div><div>    # the source for the same as _argparse and we use it instead.</div><div>    from vtk.util import _argparse as argparse</div><div><br></div><div># =============================================================================</div><div># Create custom ServerProtocol class to handle clients requests</div><div># =============================================================================</div><div><br></div><div><br></div><div>class MyInteractorStyle(vtk.vtkInteractorStyleTrackballCamera):</div><div><br></div><div>    def __init__(self,renderer, cone):</div><div>        self.parent = renderer.GetInteractor()</div><div><span style="white-space:pre-wrap">      </span>self.resolution=5</div><div><span style="white-space:pre-wrap">        </span>self.cone = cone</div><div><br></div><div>        self.AddObserver("KeyPressEvent",self.keyPressEvent)</div><div><br></div><div>    def keyPressEvent(self,obj,event):</div><div>        key = self.parent.GetKeySym()</div><div>        if key == 'l':</div><div><span style="white-space:pre-wrap">      </span>    print(key)</div><div><span style="white-space:pre-wrap"> </span>    self.cone.SetResolution(self.resolution)</div><div><span style="white-space:pre-wrap">   </span>    self.resolution+=1</div><div>        return</div><div><br></div><div><br></div><div><br></div><div><br></div><div>class _WebCone(vtk_wslink.ServerProtocol):</div><div><br></div><div>    # Application configuration</div><div>    view    = None</div><div>    authKey = "wslink-secret"</div><div><br></div><div>    def initialize(self):</div><div>        global renderer, renderWindow, renderWindowInteractor, cone, mapper, actor</div><div><br></div><div>        # Bring used components</div><div>        self.registerVtkWebProtocol(protocols.vtkWebMouseHandler())</div><div>        self.registerVtkWebProtocol(protocols.vtkWebViewPort())</div><div>        self.registerVtkWebProtocol(protocols.vtkWebViewPortImageDelivery())</div><div>        self.registerVtkWebProtocol(protocols.vtkWebViewPortGeometryDelivery())</div><div><br></div><div>        # Update authentication key to use</div><div>        self.updateSecret(_WebCone.authKey)</div><div><br></div><div>        # Create default pipeline (Only once for all the session)</div><div>        if not _WebCone.view:</div><div>            # VTK specific code</div><div>            renderer = vtk.vtkRenderer()</div><div>            renderWindow = vtk.vtkRenderWindow()</div><div>            renderWindow.AddRenderer(renderer)</div><div><br></div><div>            renderWindowInteractor = vtk.vtkRenderWindowInteractor()</div><div>            renderWindowInteractor.SetRenderWindow(renderWindow)</div><div>            </div><div><span style="white-space:pre-wrap">      </span>    <br></div><div><br></div><div>            cone = vtk.vtkConeSource()</div><div>            mapper = vtk.vtkPolyDataMapper()</div><div>            actor = vtk.vtkActor()</div><div><br></div><div>            mapper.SetInputConnection(cone.GetOutputPort())</div><div>            actor.SetMapper(mapper)</div><div><br></div><div><span style="white-space:pre-wrap">  </span>    renderWindowInteractor.SetInteractorStyle(MyInteractorStyle(renderWindow, cone))</div><div><br></div><div>            renderer.AddActor(actor)</div><div>            renderer.ResetCamera()</div><div>            renderWindow.Render()</div><div><br></div><div>            # VTK Web application specific</div><div>            _WebCone.view = renderWindow</div><div>            self.getApplication().GetObjectIdMap().SetActiveObject("VIEW", renderWindow)</div><div><br></div><div><span style="white-space:pre-wrap">       </span>  #  renderWindowInteractor.Start()</div><div><br></div><div># =============================================================================</div><div># Main: Parse args and start server</div><div># =============================================================================</div><div><br></div><div>if __name__ == "__main__":</div><div>    # Create argument parser</div><div>    parser = argparse.ArgumentParser(description="VTK/Web Cone web-application")</div><div><br></div><div>    # Add default arguments</div><div>    server.add_arguments(parser)</div><div><br></div><div>    # Extract arguments</div><div>    args = parser.parse_args()</div><div><br></div><div>    # Configure our current application</div><div>    _WebCone.authKey = args.authKey</div><div><br></div><div>    # Start server</div><div>    server.start_webserver(options=args, protocol=_WebCone)</div></div><div><br></div></div></div></div></div>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">https://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>