Skip to content

Commit a634352

Browse files
authored
Plotter: return_cpos (kwargs) updates with a field display (#141)
* Fix cpos argument * use plotter.camera_position * Flake8 compliancy * add version check for rturn_cpos case * flake8 compliancy
1 parent 0a2b8ce commit a634352

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

ansys/dpf/core/plotter.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from ansys.dpf.core.common import locations, DefinitionLabels
1313
from ansys.dpf.core.common import shell_layers as eshell_layers
1414
from ansys.dpf.core import errors as dpf_errors
15+
from ansys.dpf.core.check_version import meets_version
1516

1617

1718
def plot_chart(fields_container):
@@ -257,6 +258,8 @@ def plot_contour(
257258

258259
# create the plotter and add the meshes
259260
background = kwargs.pop("background", None)
261+
cpos = kwargs.pop("cpos", None)
262+
return_cpos = kwargs.pop("return_cpos", None)
260263

261264
try:
262265
import pyvista as pv
@@ -279,10 +282,25 @@ def plot_contour(
279282
if background is not None:
280283
plotter.set_background(background)
281284

285+
if cpos is not None:
286+
plotter.camera_position = cpos
287+
282288
# show result
283289
if show_axes:
284290
plotter.add_axes()
285-
return plotter.show()
291+
if return_cpos is None:
292+
return plotter.show()
293+
else:
294+
pv_version = pv.__version__
295+
version_to_reach = '0.32.0'
296+
meet_ver = meets_version(pv_version, version_to_reach)
297+
if meet_ver:
298+
return plotter.show(return_cpos=return_cpos)
299+
else:
300+
txt = """To use the return_cpos option, please upgrade
301+
your pyvista module with a version higher than """
302+
txt += version_to_reach
303+
raise core.errors.DpfVersionNotSupported(version_to_reach, txt)
286304

287305
def _plot_contour_using_vtk_file(self, fields_container, notebook=None):
288306
"""Plot the contour result on its mesh support.

0 commit comments

Comments
 (0)