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
1 change: 1 addition & 0 deletions doc/changelog.d/179.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fix: Reduce import time of the library
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ classifiers = [
]
dependencies = [
"pyvista >= 0.43.0,<1",
"beartype >= 0.17.0,<1",
"websockets >= 12.0,< 14",
"trame >= 3.6.0,<4",
"trame-vtk >= 2.8.7,<3",
Expand Down
3 changes: 1 addition & 2 deletions src/ansys/tools/visualization_interface/backends/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

"""Module for the backend base class."""
from abc import ABC, abstractmethod

from beartype.typing import Any, Iterable
from typing import Any, Iterable


class BaseBackend(ABC):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
# SOFTWARE.
"""Provides a wrapper to aid in plotting."""
from abc import abstractmethod
import importlib.util
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union

from beartype.typing import Any, Dict, List, Optional, Union
import numpy as np
import pyvista as pv
from vtkmodules.vtkCommonCore import vtkCommand
from vtkmodules.vtkInteractionWidgets import vtkHoverWidget
Expand All @@ -32,10 +32,6 @@
import ansys.tools.visualization_interface
from ansys.tools.visualization_interface.backends._base import BaseBackend
from ansys.tools.visualization_interface.backends.pyvista.pyvista_interface import PyVistaInterface
from ansys.tools.visualization_interface.backends.pyvista.trame_local import (
_HAS_TRAME,
TrameVisualizer,
)
from ansys.tools.visualization_interface.backends.pyvista.widgets.displace_arrows import (
CameraPanDirection,
DisplacementArrow,
Expand All @@ -57,6 +53,11 @@
from ansys.tools.visualization_interface.utils.color import Color
from ansys.tools.visualization_interface.utils.logger import logger

_HAS_TRAME = importlib.util.find_spec("pyvista.trame") and importlib.util.find_spec("trame.app")

if TYPE_CHECKING:
import numpy as np


class PyVistaBackendInterface(BaseBackend):
"""Provides the interface for the Visualization Interface Tool plotter.
Expand Down Expand Up @@ -193,7 +194,7 @@ def add_widget(self, widget: Union[PlotterWidget, List[PlotterWidget]]):
self._widgets.append(widget)
widget.update()

def select_object(self, custom_object: Union[MeshObjectPlot, EdgePlot], pt: np.ndarray) -> None:
def select_object(self, custom_object: Union[MeshObjectPlot, EdgePlot], pt: "np.ndarray") -> None:
"""Select a custom object in the plotter.

This method highlights the edges of a body and adds a label. It also adds
Expand Down Expand Up @@ -463,6 +464,9 @@ def show_plotter(self, screenshot: Optional[str] = None) -> None:

"""
if self._use_trame and _HAS_TRAME:
from ansys.tools.visualization_interface.backends.pyvista.trame_local import (
TrameVisualizer,
)
visualizer = TrameVisualizer()
visualizer.set_scene(self._pl)
visualizer.show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
# SOFTWARE.
"""Provides plotting for various PyAnsys objects."""
import re
from typing import Union
from typing import Any, Dict, List, Optional, Union

from beartype.typing import Any, Dict, List, Optional
import pyvista as pv
from pyvista.plotting.plotter import Plotter as PyVistaPlotter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""Provides `trame <https://kitware.github.io/trame/index.html>`_ visualizer interface for visualization."""

try:
from pyvista.trame.ui import plotter_ui
from trame.app import get_server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
# from the websocket. This is a trusted source, so we can ignore this vulnerability.
# Potentially, someone could send a malicious pickle object and execute arbitrary code.
import pickle # nosec B403
from typing import Union

from beartype.typing import Union
import pyvista as pv
from websockets.sync.client import connect

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
# SOFTWARE.
"""Provides the hide buttons widget for the PyAnsys plotter."""
from pathlib import Path
from typing import TYPE_CHECKING

from beartype.typing import TYPE_CHECKING
from vtk import vtkActor, vtkButtonWidget, vtkPNGReader

from ansys.tools.visualization_interface.backends.pyvista.widgets.widget import PlotterWidget
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
# SOFTWARE.
"""Provides the measure widget for the PyAnsys plotter."""
from pathlib import Path
from typing import TYPE_CHECKING

from beartype.typing import TYPE_CHECKING
from vtk import vtkActor, vtkButtonWidget, vtkPNGReader

from ansys.tools.visualization_interface.backends.pyvista.widgets.widget import PlotterWidget
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
# SOFTWARE.
"""Provides the measure widget for the PyAnsys plotter."""
from pathlib import Path
from typing import TYPE_CHECKING

from beartype.typing import TYPE_CHECKING
import pyvista as pv
from vtk import vtkActor, vtkButtonWidget, vtkPNGReader

Expand Down
2 changes: 1 addition & 1 deletion src/ansys/tools/visualization_interface/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# SOFTWARE.

"""Module for the Plotter class."""
from beartype.typing import Any
from typing import Any

from ansys.tools.visualization_interface.backends._base import BaseBackend
from ansys.tools.visualization_interface.backends.pyvista.pyvista import PyVistaBackend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"""Provides the edge type for plotting."""


from beartype.typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any

import pyvista as pv

if TYPE_CHECKING:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"""Provides the ``MeshObjectPlot`` class."""


from beartype.typing import Any, List, Union
from typing import Any, List, Union

import pyvista as pv

from ansys.tools.visualization_interface.types.edge_plot import EdgePlot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# SOFTWARE.
"""Provides the ``ClipPlane`` class."""

from beartype.typing import Tuple
from typing import Tuple


class ClipPlane:
Expand Down
Loading