File: SaveScreenshot.py

package info (click to toggle)
paraview 5.4.1%2Bdfsg4-3.1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 218,616 kB
  • sloc: cpp: 2,331,508; ansic: 322,365; python: 111,051; xml: 79,203; tcl: 47,013; yacc: 4,877; java: 4,438; perl: 3,238; sh: 2,920; lex: 1,908; f90: 748; makefile: 273; pascal: 228; objc: 83; fortran: 31
file content (107 lines) | stat: -rw-r--r-- 2,787 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
from __future__ import print_function

# Test to save screenshot from various views
from paraview.simple import *

from paraview import smtesting
smtesting.ProcessCommandLineArguments()

def RegressionTest(imageName):
    from paraview.vtk.vtkTestingRendering import vtkTesting
    testing = vtkTesting()
    testing.AddArgument("-T")
    testing.AddArgument(smtesting.TempDir)
    testing.AddArgument("-V")
    testing.AddArgument(smtesting.DataDir + "/Baseline/" + imageName)
    return testing.RegressionTest(smtesting.TempDir + "/" + imageName, 10) == vtkTesting.PASSED

renderView1 = CreateView('RenderView')
renderView1.ViewSize = [200, 200]

# get layout
layout1 = GetLayout()

# split cell
layout1.SplitHorizontal(0, 0.5)

# set active view
SetActiveView(None)

# Create a new 'Render View'
renderView2 = CreateView('RenderView')
renderView2.ViewSize = [200, 200]
renderView2.AxesGrid = 'GridAxes3DActor'
renderView2.StereoType = 0
renderView2.Background = [0.32, 0.34, 0.43]

# place view in the layout
layout1.AssignView(2, renderView2)

# split cell
layout1.SplitVertical(2, 0.5)

# set active view
SetActiveView(None)

# Create a new 'Line Chart View'
lineChartView1 = CreateView('XYChartView')
lineChartView1.ViewSize = [200, 200]

# place view in the layout
layout1.AssignView(6, lineChartView1)

# set active view
SetActiveView(renderView1)

# split cell
layout1.SplitVertical(1, 0.5)

# set active view
SetActiveView(None)

# Create a new 'Bar Chart View'
barChartView1 = CreateView('XYBarChartView')
barChartView1.ViewSize = [200, 200]

# place view in the layout
layout1.AssignView(4, barChartView1)

# set active view
SetActiveView(renderView1)
Wavelet()
r = Show()
r.Representation = "Outline"
Render()
SaveScreenshot(smtesting.TempDir + "/SaveScreenshotOutline.png", magnification=2)

SetActiveView(renderView2)
r = GetDisplayProperties()
r.Representation = "Surface"
Show()
Render()
ResetCamera()
SaveScreenshot(smtesting.TempDir + "/SaveScreenshotSurface.png", magnification=2)

SetActiveView(lineChartView1)
p = PlotOverLine(Source = "High Resolution Line Source")
p.Source.Point1 = [-10.0, -10.0, -10.0]
p.Source.Point2 = [10.0, 10.0, 10.0]
p.Source.Resolution = 10
Show()
Render()
SaveScreenshot(smtesting.TempDir + "/SaveScreenshotLinePlot.png", magnification=2)

SetActiveView(barChartView1)
Show()
Render()
SaveScreenshot(smtesting.TempDir + "/SaveScreenshotBarPlot.png", magnification=2)

val1 = RegressionTest("SaveScreenshotOutline.png")
val2 = RegressionTest("SaveScreenshotSurface.png")

# charts are not rendering correctly when magnification factor is large.
# val3 = RegressionTest("SaveScreenshotLinePlot.png")
# val4 = RegressionTest("SaveScreenshotBarPlot.png")

if not (val1 and val2): # and val3 and val4):
    raise RuntimeError("Test Failed")