-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainPythonView.py
More file actions
executable file
·35 lines (29 loc) · 1.25 KB
/
mainPythonView.py
File metadata and controls
executable file
·35 lines (29 loc) · 1.25 KB
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
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright 2023-2024 TotalEnergies.
# SPDX-FileContributor: Alexandre Benedicto
# type: ignore
# ruff: noqa
try:
import matplotlib.pyplot as plt
from paraview import python_view
import geos.pv.utils.paraviewTreatments as pvt
from geos.pv.pythonViewUtils.Figure2DGenerator import (
Figure2DGenerator, )
plt.close()
if len( sourceNames ) == 0: # noqa: F821
raise ValueError( "No source name was found. Please check at least one source in <<Input Sources>>." )
dataframes = pvt.getDataframesFromMultipleVTKSources(
sourceNames,
variableName # noqa: F821
)
dataframe = pvt.mergeDataframes( dataframes, variableName ) # noqa: F821
obj_figure = Figure2DGenerator( dataframe, userChoices ) # noqa: F821
fig = obj_figure.getFigure()
def setup_data( view ) -> None: # noqa
pass
def render( view, width: int, height: int ): # noqa
fig.set_size_inches( float( width ) / 100.0, float( height ) / 100.0 )
imageToReturn = python_view.figure_to_image( fig )
return imageToReturn
except Exception as e:
raise ChildProcessError( f"Error during the plot:\n{ e }" ) from e