<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>​Hi all,<br>
</p>
<p><br>
</p>
<p>I'd like to integrate vtkOrientationMarkerWidget into vtk_web_cone.py.  When I run this code and open a browser to http://localhost:8080/apps/cone, I encountered an exception (pls see attached fig1). <font size="3">Then, I chose Debug to look into where </font>throws
 this exception<font size="3">(pls see attached fig2)</font><span style="font-size:12pt">. </span><span style="font-size:12pt">I list my code below. What's the problem? I guess it may be related to "widget.SetInteractor(renderWindowInteractor)". Any suggestions
 are welcomed. Thanks in advance.</span></p>
<p><span style="font-size:12pt"><br>
</span></p>
<p><span style="font-size:12pt">Regards,</span></p>
<p><span style="font-size:12pt"><br>
</span></p>
<p><span style="font-size:12pt">Zhuangming Shen</span></p>
<p><span style="font-size:12pt"><br>
</span></p>
<p><span style="font-size:12pt"><br>
</span></p>
<p><span style="font-size:12pt">==================================================================</span></p>
<p></p>
<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, server</div>
<div>from vtk.web import wamp as vtk_wamp</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 File Opener class to handle clients requests</div>
<div># =============================================================================</div>
<div><br>
</div>
<div>class _WebCone(vtk_wamp.ServerProtocol):<br>
</div>
<div><br>
</div>
<div>    # Application configuration</div>
<div>    view    = None</div>
<div>    authKey = "vtkweb-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>        # 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>            renderWindowInteractor.GetInteractorStyle().SetCurrentStyleToTrackballCamera()</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>            renderer.AddActor(actor)</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span></div>
<div>            # axes<br>
</div>
<div>            axes_actor = vtk.vtkAxesActor()</div>
<div>            <br>
</div>
<div>            widget = vtk.vtkOrientationMarkerWidget()</div>
<div>            widget.SetOrientationMarker(axes_actor)</div>
<div>            <span style="color:rgb(255,0,0); text-decoration:none">widget.SetInteractor(renderWindowInteractor)</span></div>
<div>            widget.SetViewport(0,0,0.2,0.2)</div>
<div>            widget.SetEnabled(True)</div>
<div>            widget.InteractiveOff()</div>
<div>            </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.Application.GetObjectIdMap().SetActiveObject("VIEW", renderWindow)</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>    # Exctract 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)<br>
</div>
<p><br>
</p>
</body>
</html>