Exemplo n.º 1
0
    def initialize(self):
        # Bring used components
        self.registerVtkWebProtocol(pv_protocols.ParaViewWebMouseHandler())
        self.registerVtkWebProtocol(pv_protocols.ParaViewWebViewPort())
        self.registerVtkWebProtocol(
            pv_protocols.ParaViewWebPublishImageDelivery(decode=False))
        self.updateSecret(_DemoServer.authKey)

        # tell the C++ web app to use no encoding.
        # ParaViewWebPublishImageDelivery must be set to decode=False to match.
        self.getApplication().SetImageEncoding(0)

        # Disable interactor-based render calls
        simple.GetRenderView().EnableRenderOnInteraction = 0
        simple.GetRenderView().Background = [0, 0, 0]
        cone = simple.Cone()
        simple.Show(cone)
        simple.Render()

        # Update interaction mode
        pxm = simple.servermanager.ProxyManager()
        interactionProxy = pxm.GetProxy('settings',
                                        'RenderViewInteractionSettings')
        interactionProxy.Camera3DManipulators = [
            'Rotate', 'Pan', 'Zoom', 'Pan', 'Roll', 'Pan', 'Zoom', 'Rotate',
            'Zoom'
        ]
Exemplo n.º 2
0
    def initialize(self):
        # Bring used components
        self.registerVtkWebProtocol(pv_protocols.ParaViewWebMouseHandler())
        self.registerVtkWebProtocol(
            pv_protocols.ParaViewWebViewPort(_Server.viewportScale,
                                             _Server.viewportMaxWidth,
                                             _Server.viewportMaxHeight))
        self.registerVtkWebProtocol(
            pv_protocols.ParaViewWebPublishImageDelivery(decode=False))
        self.registerVtkWebProtocol(pv_protocols.ParaViewWebLocalRendering())

        # Update authentication key to use
        self.updateSecret(_Server.authKey)

        # tell the C++ web app to use no encoding. ParaViewWebPublishImageDelivery must be set to decode=False to match.
        self.getApplication().SetImageEncoding(0)

        # Disable interactor-based render calls
        view = simple.GetRenderView()
        view.EnableRenderOnInteraction = 0
        view.BackgroundColorMode = "Gradient"
        view.Background = [0, 0, 0]
        view.Background2 = [0.5, 0.5, 0.5]

        # ProxyManager helper
        pxm = simple.servermanager.ProxyManager()

        # Update interaction mode
        interactionProxy = pxm.GetProxy('settings',
                                        'RenderViewInteractionSettings')
        interactionProxy.Camera3DManipulators = [
            'Rotate', 'Pan', 'Zoom', 'Pan', 'Roll', 'Pan', 'Zoom', 'Rotate',
            'Zoom'
        ]

        # Custom rendering settings
        renderingSettings = pxm.GetProxy('settings', 'RenderViewSettings')
        renderingSettings.LODThreshold = _Server.settingsLODThreshold

        # Put something in the scene
        simple.Cone()
        rep = simple.Show()
        rep.Representation = 'Surface With Edges'
        rep.LineWidth = 2

        simple.Render()
Exemplo n.º 3
0
    def __init__(self, center=(0, 0, 0), radius=1, height=1):
        self.center = center
        self.radius = radius
        self.height = height

        self.method = 'vtk.data.add_cone'

        self.kwargs = {
            'Center': self.center,
            'Radius': self.radius,
            'Height': self.height,
        }
        simple.Show(simple.Cone(**self.kwargs))

        self.id = f"cone_{self._id}"
        Cone._id += 1

        super().__init__(type='cone')
    def drawCone(self):

        ##################################################
        # create a new Cone object
        self.cone1 = simple.Cone()

        ## In a Paraview Trace recorded session, the 'simple.' object is
        ## not necessary.  Take your Trace output and add 'simple.' to all
        ## the capitalized functions and add 'self.' to the local
        ## variables, and try just dropping it in here.

        # set active source
        simple.SetActiveSource(self.cone1)

        # get active view
        self.renderView1 = simple.GetActiveViewOrCreate('RenderView')

        # show data in view
        self.cone1Display = simple.Show(self.cone1, self.renderView1)

        # trace defaults for the display properties.
        self.cone1Display.Representation = 'Surface'

        # reset view to fit data
        self.renderView1.ResetCamera()

        # Properties modified on cone1
        self.cone1.Resolution = 12

        # change solid color
        self.cone1Display.DiffuseColor = [0.666, 0.0, 1.0]

        # reset view to fit data
        self.renderView1.ResetCamera()

        # update the view to ensure updated data information
        self.renderView1.Update()

        # current camera placement for renderView1
        self.renderView1.CameraPosition = [1.25, -3.0, -0.4]
        self.renderView1.CameraViewUp = [0.75, 0.2, 0.6]
        self.renderView1.CameraParallelScale = 0.85
    def initialize(self):
        # Bring used components
        self.registerVtkWebProtocol(pv_protocols.ParaViewWebMouseHandler())
        self.registerVtkWebProtocol(
            pv_protocols.ParaViewWebViewPort(
                MultiViewServer.viewportScale,
                MultiViewServer.viewportMaxWidth,
                MultiViewServer.viewportMaxHeight))
        self.registerVtkWebProtocol(
            pv_protocols.ParaViewWebPublishImageDelivery(decode=False))

        # Update authentication key to use
        self.updateSecret(MultiViewServer.authKey)

        # tell the C++ web app to use no encoding. ParaViewWebPublishImageDelivery must be set to decode=False to match.
        self.getApplication().SetImageEncoding(0)

        # Create of 2 views with different content
        self.registerVtkWebProtocol(
            UserProtocol(
                [self.addView(simple.Cone()),
                 self.addView(simple.Sphere())]))
Exemplo n.º 6
0
    def initialize(self):
        # Bring used components
        self.registerVtkWebProtocol(pv_protocols.ParaViewWebMouseHandler())
        self.registerVtkWebProtocol(pv_protocols.ParaViewWebViewPort())
        self.registerVtkWebProtocol(
            pv_protocols.ParaViewWebViewPortImageDelivery())
        self.updateSecret(_DemoServer.authKey)

        # Disable interactor-based render calls
        simple.GetRenderView().EnableRenderOnInteraction = 0
        simple.GetRenderView().Background = [0, 0, 0]
        cone = simple.Cone()
        simple.Show(cone)
        simple.Render()
        # Update interaction mode
        pxm = simple.servermanager.ProxyManager()
        interactionProxy = pxm.GetProxy('settings',
                                        'RenderViewInteractionSettings')
        interactionProxy.Camera3DManipulators = [
            'Rotate', 'Pan', 'Zoom', 'Pan', 'Roll', 'Pan', 'Zoom', 'Rotate',
            'Zoom'
        ]
Exemplo n.º 7
0
import os, time

from wslink import register as exportRpc

from paraview import simple, servermanager
from paraview.web import protocols as pv_protocols

# Make sure only one cone is available
cone = simple.Cone()


class ParaViewCone(pv_protocols.ParaViewWebProtocol):
    @exportRpc("vtk.initialize")
    def createVisualization(self):
        simple.Show(cone)
        return self.resetCamera()

    @exportRpc("vtk.camera.reset")
    def resetCamera(self):
        view = self.getView('-1')
        simple.Render(view)
        simple.ResetCamera(view)
        try:
            view.CenterOfRotation = view.CameraFocalPoint
        except:
            pass

        self.getApplication().InvalidateCache(view.SMProxy)
        self.getApplication().InvokeEvent('UpdateEvent')

        return view.GetGlobalIDAsString()
Exemplo n.º 8
0
    can be overriden if need be::

        --port 8080
             Port number on which the HTTP server will listen to.

        --content /path-to-web-content/
             Directory that you want to server as static web content.
             By default, this variable is empty which mean that we rely on another server
             to deliver the static content and the current process only focus on the
             WebSocket connectivity of clients.

        --authKey paraviewweb-secret
             Secret key that should be provided by the client to allow it to make any
             WebSocket communication. The client will assume if none is given that the
             server expect "paraviewweb-secret" as secret key.
"""

import sys

from paraview import simple, web

if __name__ == '__main__':
    # Setup the visualization pipeline.
    simple.Cone()
    simple.Show()
    simple.Render()

    # Start the web-server.
    web.start(
        description="""ParaView/Web sample visaulization web-application.""")
Exemplo n.º 9
0
# Version information.
print("ParaView %d.%d.%d on Python %s" %
      (pv.paraview.servermanager.vtkSMProxyManager.GetVersionMajor(),
       pv.paraview.servermanager.vtkSMProxyManager.GetVersionMinor(),
       pv.paraview.servermanager.vtkSMProxyManager.GetVersionPatch(),
       platform.python_version()))

# Even if you start multiple pvbatch using MPI, this script is only
# executed by rank 0. Check this assumption.
assert mpi4py.MPI.COMM_WORLD.rank == 0

# Output directory provided on command line.
outdir = sys.argv[1]

# Render a cone.
pv.Cone()
pv.Show()
pv.Render()
print("rendered")

# PNG image (serial).
filename = "%s/cone.png" % outdir
pv.SaveScreenshot(filename)
print(filename)

# Legacy VTK file (ASCII, serial).
filename = "%s/cone.vtk" % outdir
pv.SaveData(filename, FileType="Ascii")
print(filename)

# XML VTK files (parallel).