Hello, Sorry about my simple question. I was testing remoteview using exist example. (vtk_server.py). I added a simple vtkBoxWidget. After I couldn’t any interaction on remoteview or when I interact window the session crashed. How can I interact with this widget on remoteview. Please help me and give me suggestions.
If you define in python initialize method any widgets. You can solve this problem. But I didn’t understand why we are defining it like this.
why is that! I need to learn the reason.
Please share your code otherwise it is hard to tell where it was defined. Initialize method is only called onced and only when the server is ready. I’m not sure where you put your code before.
Hello, Thank u for your interest. If I write the box widget on initializing method its works. But it actually has to work like this, isn’t it?
class _WebCone(vtk_wslink.ServerProtocol):
# Application configuration
view = None
authKey = "wslink-secret"
def initialize(self):
global renderer, renderWindow, renderWindowInteractor, cone, mapper, actor
# Bring used components
self.registerVtkWebProtocol(protocols.vtkWebMouseHandler())
self.registerVtkWebProtocol(protocols.vtkWebViewPort())
self.registerVtkWebProtocol(protocols.vtkWebPublishImageDelivery(decode=False))
self.registerVtkWebProtocol(protocols.vtkWebViewPortGeometryDelivery())
# Update authentication key to use
self.updateSecret(_WebCone.authKey)
# tell the C++ web app to use no encoding.
# ParaViewWebPublishImageDelivery must be set to decode=False to match.
self.getApplication().SetImageEncoding(0)
# Create default pipeline (Only once for all the session)
if not _WebCone.view:
# VTK specific code
renderer = vtk.vtkRenderer()
renderWindow = vtk.vtkRenderWindow()
renderWindow.AddRenderer(renderer)
renderWindowInteractor = vtk.vtkRenderWindowInteractor()
renderWindowInteractor.SetRenderWindow(renderWindow)
renderWindowInteractor.GetInteractorStyle().SetCurrentStyleToTrackballCamera()
cone = vtk.vtkConeSource()
mapper = vtk.vtkPolyDataMapper()
actor = vtk.vtkActor()
mapper.SetInputConnection(cone.GetOutputPort())
actor.SetMapper(mapper)
renderer.AddActor(actor)
boxWidget = vtk.vtkBoxWidget()
boxWidget.SetInteractor(renderWindowInteractor)
boxWidget.SetProp3D(actor)
boxWidget.SetPlaceFactor(1.25)
boxWidget.PlaceWidget()
boxWidget.On()
renderer.ResetCamera()
renderWindow.Render()
# VTK Web application specific
_WebCone.view = renderWindow
self.getApplication().GetObjectIdMap().SetActiveObject("VIEW", renderWindow)