Skip to content

chore: Investigate and implement animations properly #532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@

# vector
vector1 = Vector(
solver=session, surfaces=["solid_up:1:830"], scale=4.0, skip=0, field="temperature"
solver=session, surfaces=["solid_up:1:830"], scale=25.0, skip=0, field="temperature"
)
p_vect = GraphicsWindow()
p_vect.add_graphics(vector1)
Expand Down
27 changes: 1 addition & 26 deletions src/ansys/fluent/visualization/graphics/graphics_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@


class _GraphicsWindow:
"""Create a graphics window to perform operations like display,
save, animate, etc. on graphics objects.
"""
"""Create a graphics window to perform operations on graphics objects."""

def __init__(self, grid: tuple = (1, 1)):
"""__init__ method of GraphicsWindow class."""
Expand Down Expand Up @@ -146,29 +144,6 @@ def refresh(
windows_id=[self.window_id], session_id=session_id, overlay=overlay
)

def animate(
self,
session_id: str | None = "",
) -> None:
"""Animate windows.

Parameters
----------
session_id : str, optional
Session ID for animating the windows that belong only to this
session. The default is ``""``, in which case the windows in all
sessions are animated.

Raises
------
NotImplementedError
If not implemented.
"""
if self.window_id:
graphics_windows_manager.animate_windows(
windows_id=[self.window_id], session_id=session_id
)

def close(
self,
session_id: str | None = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def __init__(
self.overlay: bool = False
self.fetch_data: bool = False
self.show_window: bool = True
self.animate: bool = False
self.close: bool = False
self.refresh: bool = False
self.update: bool = False
Expand Down Expand Up @@ -183,8 +182,6 @@ def _render_graphics(self, position=(0, 0), opacity=1):
self._display_xy_plot(position, opacity)
elif obj.__class__.__name__ == "MonitorPlot":
self._display_monitor_plot(position, opacity)
if self.animate:
self.renderer.write_frame()
self.renderer._set_camera(pyviz.config.view)

def add_graphics(self, position, opacity=1):
Expand Down Expand Up @@ -544,7 +541,6 @@ def refresh():
with GraphicsWindowsManager._condition:
plotter = window.renderer
if window.close:
window.animate = False
plotter.close()
return
if not window.update:
Expand Down Expand Up @@ -685,38 +681,6 @@ def refresh_windows(
window.refresh = True
self.plot(window.post_object, window.id, overlay=overlay)

def animate_windows(
self,
session_id: Optional[str] = "",
windows_id=None,
) -> None:
"""Animate windows.

Parameters
----------
session_id : str, optional
Session ID for animating the windows that belong only to this
session. The default is ``""``, in which case the windows in all
sessions are animated.
windows_id : List[str], optional
List of IDs for the windows to animate. The default is ``[]``, in which
case all windows are animated.

Raises
------
NotImplementedError
If not implemented.
"""
if windows_id is None:
windows_id = []
with self._condition:
windows_id = self._get_windows_id(session_id, windows_id)
for window_id in windows_id:
window = self._post_windows.get(window_id)
if window:
window.animate = True
window.renderer.get_animation(window.id)

def close_windows(
self,
session_id: Optional[str] = "",
Expand Down Expand Up @@ -1041,7 +1005,6 @@ def _display(self, grid=(1, 1)) -> None:
if self._window_id:
window = self._post_windows.get(self._window_id)
plotter = window.renderer.plotter if window else None
animate = window.animate if window else False
if not plotter or plotter._closed:
window = GraphicsWindow(
self._window_id, self._post_object, grid=self._grid
Expand All @@ -1057,7 +1020,6 @@ def _display(self, grid=(1, 1)) -> None:
window._opacity = self._opacity
window.fetch_data = self._fetch_data
window.overlay = self._overlay
window.animate = animate
window.update = True
self._post_windows[self._window_id] = window
self._post_object = None
Expand Down
10 changes: 0 additions & 10 deletions src/ansys/fluent/visualization/graphics/pyvista/graphics_defns.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,6 @@ def save_graphic(self, file_name: str):
"""
self.plotter.save_graphic(file_name)

def get_animation(self, win_id: str):
"""Animate windows.

Parameters
----------
win_id : str
ID for the window to animate.
"""
self.plotter.open_gif(f"{win_id}.gif")

def close(self):
"""Close graphics window."""
self.plotter.close()
23 changes: 0 additions & 23 deletions src/ansys/fluent/visualization/plotter/plotter_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,29 +113,6 @@ def refresh(
windows_id=[self.window_id], session_id=session_id
)

def animate(
self,
session_id: str | None = "",
) -> None:
"""Animate windows.

Parameters
----------
session_id : str, optional
Session ID for animating the windows that belong only to this
session. The default is ``""``, in which case the windows in all
sessions are animated.

Raises
------
NotImplementedError
If not implemented.
"""
if self.window_id:
plotter_windows_manager.animate_windows(
windows_id=[self.window_id], session_id=session_id
)

def close(
self,
session_id: str | None = "",
Expand Down
25 changes: 0 additions & 25 deletions src/ansys/fluent/visualization/plotter/plotter_windows_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,31 +414,6 @@ def refresh_windows(
window.refresh = True
self.plot(window.post_object, window.id)

def animate_windows(
self,
session_id: Optional[str] = "",
windows_id=None,
) -> None:
"""Animate windows.

Parameters
----------
session_id : str, optional
Session ID for animating the windows that belong only to this
session. The default is ``""``, in which case the windows in all
sessions are animated.
windows_id : List[str], optional
List of IDs for the windows to animate. The default is ``[]``, in which
case all windows are animated.
Raises
------
NotImplementedError
If not implemented.
"""
if windows_id is None:
windows_id = []
raise NotImplementedError("animate_windows not implemented.")

def close_windows(
self,
session_id: Optional[str] = "",
Expand Down
24 changes: 1 addition & 23 deletions src/ansys/fluent/visualization/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@


class GraphicsWindow:
"""Create a graphics window to perform operations like display,
save, animate on graphics and plot objects.
"""Create a graphics window to perform operations on graphics and plot objects.

Examples
--------
Expand Down Expand Up @@ -228,27 +227,6 @@ def refresh(
if self.window_id:
self._renderer.refresh(session_id=session_id, overlay=overlay)

def animate(
self,
session_id: str | None = "",
) -> None:
"""Animate windows.

Parameters
----------
session_id : str, optional
Session ID for animating the windows that belong only to this
session. The default is ``""``, in which case the windows in all
sessions are animated.

Raises
------
NotImplementedError
If not implemented.
"""
if self.window_id:
self._renderer.animate(session_id=session_id)

def close(
self,
session_id: str | None = "",
Expand Down
26 changes: 0 additions & 26 deletions src/ansys/fluent/visualization/visualization_windows_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,32 +153,6 @@ def refresh_windows(
"""
pass

@abstractmethod
def animate_windows(
self,
session_id: Optional[str] = "",
windows_id: Optional[List[str]] = [],
) -> None:
"""Animate windows.

Parameters
----------
session_id : str, optional
Session id to animate. If specified, animation will be created
for windows which belong to specified session. Otherwise
animation will be created for all windows.

windows_id : List[str], optional
Windows id to animate. If not specified, animation will be
created for all windows.

Raises
------
NotImplementedError
If not implemented.
"""
pass

@abstractmethod
def close_windows(
self,
Expand Down