1515import numpy as np
1616import pyvista as pv
1717from pyvista import _vtk as vtk
18+ from pyvista .themes import DefaultTheme
1819from tqdm import tqdm
1920
2021from ansys .mapdl .reader import _binary_reader , _reader , elements
@@ -60,7 +61,7 @@ def access_bit(data, num):
6061
6162EMAIL_ME = """Please raise an issue at:
6263https://github.com/pyansys/pymapdl-reader/issues
63- Or email the developer at alexander.kaszynski @ansys.com
64+ Or email the PyAnsys support team at pyansys.support @ansys.com
6465"""
6566np .seterr (divide = "ignore" , invalid = "ignore" )
6667
@@ -3020,7 +3021,8 @@ def _plot_point_scalars(
30203021 plotter .add_axes ()
30213022
30223023 # set background
3023- plotter .background_color = kwargs .pop ("background" , None )
3024+ theme = DefaultTheme ()
3025+ theme .background = kwargs .pop ("background" , None )
30243026
30253027 # remove extra keyword args
30263028 kwargs .pop ("node_components" , None )
@@ -3034,14 +3036,13 @@ def _plot_point_scalars(
30343036
30353037 # set scalar bar text colors
30363038 if text_color :
3037- text_color = pv .parse_color (text_color )
3038- plotter .scalar_bar .GetLabelTextProperty ().SetColor (text_color )
3039- plotter .scalar_bar .GetAnnotationTextProperty ().SetColor (text_color )
3040- plotter .scalar_bar .GetTitleTextProperty ().SetColor (text_color )
3039+ theme = DefaultTheme ()
3040+ theme .color = text_color
3041+ pv .global_theme .load_theme (theme )
30413042
30423043 # NAN/missing data are white
30433044 # plotter.renderers[0].SetUseDepthPeeling(1) # <-- for transparency issues
3044- plotter . mapper . GetLookupTable (). SetNanColor ( 1 , 1 , 1 , 1 )
3045+ theme . nan_color = [ 1 , 1 , 1 , 1 ]
30453046
30463047 if cpos :
30473048 plotter .camera_position = cpos
@@ -3103,7 +3104,6 @@ def exit_callback(plotter, RenderWindowInteractor, event):
31033104 first_loop = True
31043105 cached_normals = [None for _ in range (n_frames )]
31053106 while self ._animating :
3106-
31073107 for j , angle in enumerate (np .linspace (0 , np .pi * 2 , n_frames + 1 )[:- 1 ]):
31083108 mag_adj = np .sin (angle )
31093109 if scalars is not None :
@@ -3121,12 +3121,8 @@ def exit_callback(plotter, RenderWindowInteractor, event):
31213121 copied_mesh .point_data ["Normals" ][:] = cached_normals [j ]
31223122
31233123 if add_text :
3124- # 2 maps to vtk.vtkCornerAnnotation.UpperLeft
3125- plotter .textActor .SetText (
3126- 2 ,
3127- "%s\n Phase %.1f Degrees"
3128- % (result_text , (angle * 180 / np .pi )),
3129- )
3124+ phase = angle * 180 / np .pi
3125+ plotter .add_text (f"{ result_text } \n Phase { phase } Degrees" )
31303126
31313127 # at max supported framerate
31323128 plotter .update (1 , force_redraw = True )
@@ -3264,7 +3260,8 @@ def _animate_point_scalars(
32643260 plotter .add_axes ()
32653261
32663262 # set background
3267- plotter .background_color = kwargs .pop ("background" , None )
3263+ theme = DefaultTheme ()
3264+ theme .background = kwargs .pop ("background" , None )
32683265
32693266 # remove extra keyword args
32703267 kwargs .pop ("node_components" , None )
@@ -3279,14 +3276,12 @@ def _animate_point_scalars(
32793276
32803277 # set scalar bar text colors
32813278 if text_color :
3282- text_color = pv .parse_color (text_color )
3283- plotter .scalar_bar .GetLabelTextProperty ().SetColor (text_color )
3284- plotter .scalar_bar .GetAnnotationTextProperty ().SetColor (text_color )
3285- plotter .scalar_bar .GetTitleTextProperty ().SetColor (text_color )
3279+ theme .color = text_color
3280+ pv .global_theme .load_theme (theme )
32863281
32873282 # NAN/missing data are white
32883283 # plotter.renderers[0].SetUseDepthPeeling(1) # <-- for transparency issues
3289- plotter . mapper . GetLookupTable (). SetNanColor ( 1 , 1 , 1 , 1 )
3284+ theme . nan_color = [ 1 , 1 , 1 , 1 ]
32903285
32913286 if cpos :
32923287 plotter .camera_position = cpos
@@ -3335,8 +3330,7 @@ def q_callback():
33353330 copied_mesh .active_scalars [:] = data
33363331
33373332 if text is not None :
3338- # 2 maps to vtk.vtkCornerAnnotation.UpperLeft
3339- plotter .textActor .SetText (2 , text [i ])
3333+ plotter .add_text (text [i ])
33403334
33413335 # at max supported framerate
33423336 plotter .update (1 , force_redraw = True )
0 commit comments