Commit 21c89fd5 authored by Cory Quammen's avatar Cory Quammen Committed by Kitware Robot
Browse files

Merge topic 'python-view-test-update'

c0bc5e9b

 Update Python view scripts for matplotlib 2.0
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Utkarsh Ayachit's avatarUtkarsh Ayachit <utkarsh.ayachit@kitware.com>
Merge-request: !2078
parents 1e4ef7b5 c0bc5e9b
Pipeline #84456 failed with stage
in 0 seconds
......@@ -5,6 +5,10 @@ import sys
script = """
from paraview.vtk.util import numpy_support
import matplotlib.style
import matplotlib as mpl
mpl.style.use('classic')
# Utility to get next color
def getNextColor():
......@@ -22,7 +26,6 @@ def render(view,width,height):
figure = python_view.matplotlib_figure(width,height)
ax = figure.add_subplot(111)
ax.hold = True
numObjects = view.GetNumberOfVisibleDataObjects()
print ("num visible objects: ", numObjects)
for i, color in zip(range(0,numObjects), getNextColor()):
......@@ -35,8 +38,6 @@ def render(view,width,height):
x, y = pts[:,0], pts[:,1]
ax.scatter(x, y, color=color)
ax.hold = False
return python_view.figure_to_image(figure)
"""
......
......@@ -11,7 +11,7 @@
<!-- Set the script -->
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/ViewFrame/ProxyPanel/Script/1pqPopOutWidget0/Script/qt_scrollarea_viewport" command="mousePress" arguments="1,1,0,157,31" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/ViewFrame/ProxyPanel/Script/1pqPopOutWidget0/Script/qt_scrollarea_viewport" command="mouseRelease" arguments="1,0,0,157,31" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/ViewFrame/ProxyPanel/Script/1pqPopOutWidget0/Script" command="set_string" arguments="from paraview import vtk&#xA;from paraview.vtk import vtkDataObject&#xA;from paraview.vtk.util import numpy_support&#xA;&#xA;def setup_data(view):&#xA; numVisibleObjects = view.GetNumberOfVisibleDataObjects()&#xA; for i in range(numVisibleObjects):&#xA; dataObject = view.GetVisibleDataObjectForSetup(i)&#xA; if dataObject:&#xA; pd = dataObject.GetPointData()&#xA;&#xA; # Enable desired arrays&#xA; desiredArrays = [&quot;X&quot;, &quot;Y&quot;, &quot;Z&quot;]&#xA; for arrayName in desiredArrays:&#xA; view.SetAttributeArrayStatus(i, vtkDataObject.POINT, arrayName, 1)&#xA;&#xA;def render(view, width, height):&#xA; from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas&#xA; from matplotlib.figure import Figure&#xA;&#xA; figure = Figure()&#xA; figureCanvas = FigureCanvas(figure)&#xA; figure.set_dpi(72)&#xA; figure.set_size_inches(float(width)/72.0, float(height)/72.0)&#xA;&#xA; # Set the border color of the figure&#xA;&#xA; ax = figure.add_subplot(1,1,1, axisbg=&quot;white&quot;)&#xA; ax.hold(True)&#xA; numVisibleObjects = view.GetNumberOfVisibleDataObjects()&#xA; for i in range(numVisibleObjects):&#xA; dataObject = view.GetVisibleDataObjectForRendering(i)&#xA; if dataObject:&#xA; pd = dataObject.GetPointData()&#xA; xArray = pd.GetArray(&quot;X&quot;)&#xA; yArray = pd.GetArray(&quot;Y&quot;)&#xA; zArray = pd.GetArray(&quot;Z&quot;)&#xA; if not xArray or not yArray or not zArray:&#xA; continue&#xA;&#xA; np_xArray = numpy_support.vtk_to_numpy(xArray)&#xA; np_yArray = numpy_support.vtk_to_numpy(yArray)&#xA; np_zArray = abs(300*numpy_support.vtk_to_numpy(zArray))&#xA;&#xA; if xArray != None and yArray != None and zArray != None:&#xA; ax.scatter(np_xArray, np_yArray, np_zArray, alpha=0.5)&#xA;&#xA; ax.hold(False)&#xA;&#xA; from paraview import python_view&#xA; image = python_view.figure_to_image(figure)&#xA;&#xA; return image" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/ViewFrame/ProxyPanel/Script/1pqPopOutWidget0/Script" command="set_string" arguments="from paraview import vtk&#xA;from paraview.vtk import vtkDataObject&#xA;from paraview.vtk.util import numpy_support&#xA;import matplotlib.style&#xA;import matplotlib as mpl&#xA;mpl.style.use('classic')&#xA;&#xA;def setup_data(view):&#xA; numVisibleObjects = view.GetNumberOfVisibleDataObjects()&#xA; for i in range(numVisibleObjects):&#xA; dataObject = view.GetVisibleDataObjectForSetup(i)&#xA; if dataObject:&#xA; pd = dataObject.GetPointData()&#xA;&#xA; # Enable desired arrays&#xA; desiredArrays = [&quot;X&quot;, &quot;Y&quot;, &quot;Z&quot;]&#xA; for arrayName in desiredArrays:&#xA; view.SetAttributeArrayStatus(i, vtkDataObject.POINT, arrayName, 1)&#xA;&#xA;def render(view, width, height):&#xA; from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas&#xA; from matplotlib.figure import Figure&#xA;&#xA; figure = Figure()&#xA; figureCanvas = FigureCanvas(figure)&#xA; figure.set_dpi(72)&#xA; figure.set_size_inches(float(width)/72.0, float(height)/72.0)&#xA;&#xA; # Set the border color of the figure&#xA;&#xA; ax = figure.add_subplot(1,1,1, facecolor=&quot;white&quot;)&#xA; numVisibleObjects = view.GetNumberOfVisibleDataObjects()&#xA; for i in range(numVisibleObjects):&#xA; dataObject = view.GetVisibleDataObjectForRendering(i)&#xA; if dataObject:&#xA; pd = dataObject.GetPointData()&#xA; xArray = pd.GetArray(&quot;X&quot;)&#xA; yArray = pd.GetArray(&quot;Y&quot;)&#xA; zArray = pd.GetArray(&quot;Z&quot;)&#xA; if not xArray or not yArray or not zArray:&#xA; continue&#xA;&#xA; np_xArray = numpy_support.vtk_to_numpy(xArray)&#xA; np_yArray = numpy_support.vtk_to_numpy(yArray)&#xA; np_zArray = abs(300*numpy_support.vtk_to_numpy(zArray))&#xA;&#xA; if xArray != None and yArray != None and zArray != None:&#xA; ax.scatter(np_xArray, np_yArray, np_zArray, alpha=0.5)&#xA;&#xA; from paraview import python_view&#xA; image = python_view.figure_to_image(figure)&#xA;&#xA; return image" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/ViewFrame/ProxyPanel/Script/1pqPopOutWidget0/Script" command="key" arguments="16777220" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/ViewFrame/ProxyPanel/Script/1pqPopOutWidget0/Script" command="key" arguments="16777217" />
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment