|
|
Line 36: |
Line 36: |
| ==Representations and Views== | | ==Representations and Views== |
|
| |
|
| Once a pipeline is created, it can be rendered using representations and views. A view is essentially a “window” in which multiple representations can be displayed. When the view is a VTK view (such as RenderView), this corresponds to a collection of objects including vtkRenderers and a vtkRenderWindow. However, there is no requirement for a view to be a VTK view or to render anything. A representation is a collection of objects, usually a pipeline, that takes a data object, converts it to something that can be rendered, and renders it. When the view is a VTK view, this corresponds to a collection of objects including geometry filters, level-of-detail algorithms, vtkMappers and vtkActors. The simple module automatically creates a view after connecting to a server (including the built-in connection when using the stand-alone mode). Furthermore, the simple module creates a representation the first time a pipeline object is displayed with Show().
| | {{ParaView/Template/DeprecatedUsersGuide}} |
| It is easy to create new views.
| |
| | |
| <source lang="python">
| |
| >>> view = CreateRenderView()
| |
| </source>
| |
| | |
| CreateRenderView() is a special method that creates the render view appropriate for the ActiveConnection (or for another connection specified as an argument). It returns a sub-class of Proxy. Like the constructor of Proxy, it can take an arbitrary number of keyword arguments to set initial values for properties. Note that ParaView makes the view that was created last the active view. When using Show() without a view argument, the pipeline is shown in the active view. You can get a list of views as well as the active view as follows:
| |
| | |
| <source lang="python">
| |
| >>> GetRenderViews()
| |
| [<paraview.servermanager.RenderView object at 0xaf64ef0>, <paraview.servermanager.RenderView object at 0xaf64b70>]
| |
| >>> GetActiveView()
| |
| <paraview.servermanager.RenderView object at 0xaf64b70>
| |
| </source>
| |
| | |
| You can also change the active view using SetActiveView().
| |
| | |
| Once you have a render view, you can use pass it to Show in order to select in which view a pipeline object is displayed. You can also pass it to Render() to select which view is rendered.
| |
| | |
| <source lang="python">
| |
| >>> Show(elev, GetRenderViews()[1])
| |
| <paraview.servermanager.GeometryRepresentation object at 0xaf64e30>
| |
| >>> Render(GetRenderViews()[1])
| |
| </source>
| |
| | |
| Notice that Show() returns a representation object (aka DisplayProperties in the simple module). This object can be used to manipulate how the pipeline object is displayed in the view. You can also access the display properties of an object using GetDisplayProperties().
| |
| | |
| <source lang="python">
| |
| >>> dp = GetDisplayProperties(elev)
| |
| >>> dp
| |
| <paraview.servermanager.GeometryRepresentation object at 0xaf649d0>
| |
| </source>
| |
| | |
| Display properties and views have a large number of properties some of which are poorly documented. We will cover some them here.
| |
| | |
| <source lang="python">
| |
| >>> from paraview.simple import *
| |
| # Create a simple pipeline
| |
| >>> sph = Sphere()
| |
| >>> elev = Elevation(sph)
| |
| >>> Show(elev)
| |
| >>> Render()
| |
| # Set the representation type of elev
| |
| >>> dp = GetDisplayProperties(elev)
| |
| >>> dp.Representation = 'Points'
| |
| # Here is how you get the list of representation types
| |
| >>> dp.GetProperty("Representation").Available
| |
| ['Outline', 'Points', 'Wireframe', 'Surface', 'Surface With Edges']
| |
| >>> Render()
| |
| # Change the representation to wireframe
| |
| >>> dp.Representation = 'Wireframe'
| |
| >>> Render()
| |
| # Let’s get some information about the output of the elevation
| |
| # filter. We want to color the representation by one of it’s
| |
| # arrays.
| |
| # Second array = Elevation. Interesting. Let’s use this one.
| |
| >>> ai = elev.PointData[1]
| |
| >>> ai.GetName()
| |
| 'Elevation'
| |
| # What is its range?
| |
| >>> ai.GetRange()
| |
| (0.0, 0.5)
| |
| # To color the representation by an array, we need to first create
| |
| # a lookup table. We use the range of the Elevation array
| |
| >>> dp.LookupTable = MakeBlueToRedLT(0, 0.5)
| |
| >>> dp.ColorAttributeType = 'POINT_DATA'
| |
| >>> dp.ColorArrayName = 'Elevation' # color by Elevation
| |
| >>> Render()
| |
| </source>
| |
| | |
| Here is the result:
| |
| [[Image:SMView.png|thumb|center|800px|'''Figure 14.2''' Object displayed in a view]]
| |
| | |
| | |
| Once you create a scene, you will probably want to interact with the camera and ResetCamera() is likely to be insufficient. In this case, you can directly get the camera from the view and manipulate it. GetActiveCamera() returns a VTK object (not a proxy) with which you can interact.
| |
| | |
| <source lang="python">
| |
| >>> camera = GetActiveCamera()
| |
| >>> camera
| |
| <libvtkCommonPython.vtkCamera vtkobject at 0xe290>
| |
| >>> camera.Elevation(45)
| |
| >>> Render()
| |
| </source>
| |
| | |
| Another common thing to do is to save the view as an image. For this purpose, you can use the WriteImage() method provided by the view:
| |
| | |
| <source lang="python">
| |
| >> WriteImage("/Users/berk/image.png")
| |
| </source>
| |
| | |
| The resulting image.png looks like this. See the documentation for WriteImage() for details on choosing file type, as well as a magnification factor to save images larger than the view size.
| |
| | |
| [[Image:Image.jpg|thumb|center|800px|'''Figure 14.3''' Saving a view as an image]]
| |
|
| |
|
| =Advanced Concepts= | | =Advanced Concepts= |
Katie O adding to ParaView Guide LaTex
Note: This document if based on ParaView 3.6 or higher. If you are using 3.4, go to the history page and select the version from May 13, 2009.
ParaView and Python
ParaView offers rich scripting support through Python. This support is available as part of the ParaView client (paraview), an MPI-enabled batch application (pvbatch), the ParaView python client (pvpython), or any other Python-enabled application. Using Python, users and developers can gain access to the ParaView engine called Server Manager.
Note: Server Manager is a library that is designed to make it easy to build distributed client-server applications.
This document is a short introduction to ParaView's Python interface. You may also visit the Python recipes page for some examples.
Quick Start - a Tutorial
PAGE DELETED
The ParaView's Python documentation has been moved from the Wiki to The ParaView Python Documentation. Please use the history if you want to access the old version of this document.
paraview.simple Module
PAGE DELETED
The Paraview's User Guide and Reference Manual have been moved from the Wiki to The ParaView Guide. Please use the history if you want to access the old version of this document.
Proxies and Properties
Proxies
PAGE DELETED
The Paraview's User Guide and Reference Manual have been moved from the Wiki to The ParaView Guide. Please use the history if you want to access the old version of this document.
Properties
PAGE DELETED
The Paraview's User Guide and Reference Manual have been moved from the Wiki to The ParaView Guide. Please use the history if you want to access the old version of this document.
Domains
PAGE DELETED
The Paraview's User Guide and Reference Manual have been moved from the Wiki to The ParaView Guide. Please use the history if you want to access the old version of this document.
Source Proxies
PAGE DELETED
The Paraview's User Guide and Reference Manual have been moved from the Wiki to The ParaView Guide. Please use the history if you want to access the old version of this document.
Representations and Views
PAGE DELETED
The Paraview's User Guide and Reference Manual have been moved from the Wiki to The ParaView Guide. Please use the history if you want to access the old version of this document.
Advanced Concepts
Dealing with lookup tables
PAGE DELETED
The Paraview's User Guide and Reference Manual have been moved from the Wiki to The ParaView Guide. Please use the history if you want to access the old version of this document.
Loading State and Manipulating It
PAGE DELETED
The Paraview's User Guide and Reference Manual have been moved from the Wiki to The ParaView Guide. Please use the history if you want to access the old version of this document.
Dealing with Time
PAGE DELETED
The Paraview's User Guide and Reference Manual have been moved from the Wiki to The ParaView Guide. Please use the history if you want to access the old version of this document.
Animating
PAGE DELETED
The Paraview's User Guide and Reference Manual have been moved from the Wiki to The ParaView Guide. Please use the history if you want to access the old version of this document.
Loading Data Files
PAGE DELETED
The Paraview's User Guide and Reference Manual have been moved from the Wiki to The ParaView Guide. Please use the history if you want to access the old version of this document.
Writing Data Files (ParaView 3.9 or later)
PAGE DELETED
The Paraview's User Guide and Reference Manual have been moved from the Wiki to The ParaView Guide. Please use the history if you want to access the old version of this document.
Exporting CSV Data
PAGE DELETED
The Paraview's User Guide and Reference Manual have been moved from the Wiki to The ParaView Guide. Please use the history if you want to access the old version of this document.
Updating View Layout
PAGE DELETED
The Paraview's User Guide and Reference Manual have been moved from the Wiki to The ParaView Guide. Please use the history if you want to access the old version of this document.
Multiple Renders
PAGE DELETED
The Paraview's User Guide and Reference Manual have been moved from the Wiki to The ParaView Guide. Please use the history if you want to access the old version of this document.