Skip to content

Commit 1f2e907

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent c520cfb commit 1f2e907

File tree

4 files changed

+38
-15
lines changed

4 files changed

+38
-15
lines changed

doc/source/user_guide/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ The Visualization Interface Tool provides a base class, ``AbstractPicker``, for
117117
callbacks of the plotter. This class provides a set of methods that can be overridden so that you can adapt the
118118
picker and hover functionalities to the specific need of your PyAnsys library.
119119

120-
The first thing you must do is to create a class that inherits from the ``AbstractPicker`` class. After that, see
120+
The first thing you must do is to create a class that inherits from the ``AbstractPicker`` class. After that, see
121121
these main use cases for customizing the picker and hover callbacks:
122122

123123
* You may want to change the way that objects are picked in the plotter. To do this, you can override the

examples/00-basic-pyvista-examples/custom_picker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def pick_select_object(self, custom_object: MeshObjectPlot, pt: "np.ndarray") ->
101101
)
102102
# Add the label actor to the list of added actors
103103
added_actors.append(label_actor)
104-
104+
105105
# Add the picked object to the picked dictionary if not already present, to keep track of it
106106
if custom_object.name not in self._picked_dict:
107107
self._picked_dict[custom_object.name] = custom_object
@@ -150,7 +150,7 @@ def hover_select_object(self, custom_object: MeshObjectPlot, actor: "Actor") ->
150150
show_points=False,
151151
)
152152
self._added_hover_labels.append(label_actor)
153-
153+
154154
def hover_unselect_object(self):
155155
"""Remove all hover labels from the scene."""
156156
for label in self._added_hover_labels:
@@ -159,7 +159,7 @@ def hover_unselect_object(self):
159159
@property
160160
def picked_dict(self) -> dict:
161161
"""Return the dictionary of picked objects.
162-
162+
163163
Returns
164164
-------
165165
dict

src/ansys/tools/visualization_interface/backends/pyvista/picker.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
# Copyright (C) 2024 - 2025 ANSYS, Inc. and/or its affiliates.
2+
# SPDX-License-Identifier: MIT
3+
#
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
123
"""Module for managing picking and hovering of objects in a PyVista plotter."""
224
from typing import TYPE_CHECKING, Union
325

@@ -7,9 +29,10 @@
729

830
if TYPE_CHECKING:
931
import numpy as np
10-
from ansys.tools.visualization_interface.backends.pyvista.pyvista import Plotter
1132
from pyvista import Actor
1233

34+
from ansys.tools.visualization_interface.backends.pyvista.pyvista import Plotter
35+
1336
class AbstractPicker:
1437
"""Abstract base class for pickers."""
1538

@@ -44,7 +67,7 @@ class Picker(AbstractPicker):
4467
currently selected and hovered objects, and provides methods to select and unselect
4568
them.
4669
47-
70+
4871
Parameters
4972
----------
5073
plotter_backend : Plotter
@@ -164,7 +187,7 @@ def hover_select_object(self, custom_object: Union[MeshObjectPlot, EdgePlot], ac
164187
show_points=False,
165188
)
166189
self._added_hover_labels.append(label_actor)
167-
190+
168191
def hover_unselect_object(self):
169192
"""Remove all hover labels from the scene."""
170193
for label in self._added_hover_labels:

src/ansys/tools/visualization_interface/backends/pyvista/pyvista.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
import ansys.tools.visualization_interface
3434
from ansys.tools.visualization_interface.backends._base import BaseBackend
35+
from ansys.tools.visualization_interface.backends.pyvista.picker import AbstractPicker, Picker
3536
from ansys.tools.visualization_interface.backends.pyvista.pyvista_interface import PyVistaInterface
3637
from ansys.tools.visualization_interface.backends.pyvista.widgets.dark_mode import DarkModeButton
3738
from ansys.tools.visualization_interface.backends.pyvista.widgets.displace_arrows import (
@@ -54,14 +55,13 @@
5455
from ansys.tools.visualization_interface.types.edge_plot import EdgePlot
5556
from ansys.tools.visualization_interface.utils.color import Color
5657
from ansys.tools.visualization_interface.utils.logger import logger
57-
from ansys.tools.visualization_interface.backends.pyvista.picker import Picker, AbstractPicker
5858

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

6161
DARK_MODE_THRESHOLD = 120
6262

6363
if TYPE_CHECKING:
64-
import numpy as np
64+
pass
6565

6666

6767
class PyVistaBackendInterface(BaseBackend):
@@ -563,12 +563,12 @@ def __init__(
563563
) -> None:
564564
"""Initialize the generic plotter."""
565565
super().__init__(
566-
use_trame,
567-
allow_picking,
568-
allow_hovering,
569-
plot_picked_names,
570-
use_qt=use_qt,
571-
show_qt=show_qt,
566+
use_trame,
567+
allow_picking,
568+
allow_hovering,
569+
plot_picked_names,
570+
use_qt=use_qt,
571+
show_qt=show_qt,
572572
custom_picker=custom_picker
573573
)
574574

0 commit comments

Comments
 (0)