Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 16 additions & 21 deletions ansys/mapdl/reader/rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import numpy as np
import pyvista as pv
from pyvista import _vtk as vtk
from pyvista.themes import DefaultTheme
from tqdm import tqdm

from ansys.mapdl.reader import _binary_reader, _reader, elements
Expand Down Expand Up @@ -60,7 +61,7 @@ def access_bit(data, num):

EMAIL_ME = """Please raise an issue at:
https://github.com/pyansys/pymapdl-reader/issues
Or email the developer at alexander.kaszynski@ansys.com
Or email the PyAnsys support team at pyansys.support@ansys.com
"""
np.seterr(divide="ignore", invalid="ignore")

Expand Down Expand Up @@ -3020,7 +3021,8 @@ def _plot_point_scalars(
plotter.add_axes()

# set background
plotter.background_color = kwargs.pop("background", None)
theme = DefaultTheme()
theme.background = kwargs.pop("background", None)

# remove extra keyword args
kwargs.pop("node_components", None)
Expand All @@ -3034,14 +3036,13 @@ def _plot_point_scalars(

# set scalar bar text colors
if text_color:
text_color = pv.parse_color(text_color)
plotter.scalar_bar.GetLabelTextProperty().SetColor(text_color)
plotter.scalar_bar.GetAnnotationTextProperty().SetColor(text_color)
plotter.scalar_bar.GetTitleTextProperty().SetColor(text_color)
theme = DefaultTheme()
theme.color = text_color
pv.global_theme.load_theme(theme)

# NAN/missing data are white
# plotter.renderers[0].SetUseDepthPeeling(1) # <-- for transparency issues
plotter.mapper.GetLookupTable().SetNanColor(1, 1, 1, 1)
theme.nan_color = [1, 1, 1, 1]

if cpos:
plotter.camera_position = cpos
Expand Down Expand Up @@ -3120,12 +3121,8 @@ def exit_callback(plotter, RenderWindowInteractor, event):
copied_mesh.point_data["Normals"][:] = cached_normals[j]

if add_text:
# 2 maps to vtk.vtkCornerAnnotation.UpperLeft
plotter.textActor.SetText(
2,
"%s\nPhase %.1f Degrees"
% (result_text, (angle * 180 / np.pi)),
)
phase = angle * 180 / np.pi
plotter.add_text(f"{result_text} \nPhase {phase} Degrees")

# at max supported framerate
plotter.update(1, force_redraw=True)
Expand Down Expand Up @@ -3263,7 +3260,8 @@ def _animate_point_scalars(
plotter.add_axes()

# set background
plotter.background_color = kwargs.pop("background", None)
theme = DefaultTheme()
theme.background = kwargs.pop("background", None)

# remove extra keyword args
kwargs.pop("node_components", None)
Expand All @@ -3278,14 +3276,12 @@ def _animate_point_scalars(

# set scalar bar text colors
if text_color:
text_color = pv.parse_color(text_color)
plotter.scalar_bar.GetLabelTextProperty().SetColor(text_color)
plotter.scalar_bar.GetAnnotationTextProperty().SetColor(text_color)
plotter.scalar_bar.GetTitleTextProperty().SetColor(text_color)
theme.color = text_color
pv.global_theme.load_theme(theme)

# NAN/missing data are white
# plotter.renderers[0].SetUseDepthPeeling(1) # <-- for transparency issues
plotter.mapper.GetLookupTable().SetNanColor(1, 1, 1, 1)
theme.nan_color = [1, 1, 1, 1]

if cpos:
plotter.camera_position = cpos
Expand Down Expand Up @@ -3334,8 +3330,7 @@ def q_callback():
copied_mesh.active_scalars[:] = data

if text is not None:
# 2 maps to vtk.vtkCornerAnnotation.UpperLeft
plotter.textActor.SetText(2, text[i])
plotter.add_text(text[i])

# at max supported framerate
plotter.update(1, force_redraw=True)
Expand Down
12 changes: 12 additions & 0 deletions tests/test_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,18 @@ def test_plot_pontoon_nodal_displacement():
)


@skip_plotting
@pytest.mark.skipif(pontoon is None, reason="Requires example files")
def test_plot_pontoon_nodal_displacement_with_text_color():
pontoon.plot_nodal_solution(
0,
show_displacement=True,
overlay_wireframe=True,
off_screen=True,
text_color="k",
)


@skip_plotting
@pytest.mark.skipif(pontoon is None, reason="Requires example files")
def test_plot_pontoon_nodal_displacement():
Expand Down