Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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/392.miscellaneous.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Feat(Plotly): Add view buttons, toggle bounding box axes and change between orthogonal and perspective projections
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from pyvista import PolyData

from ansys.tools.visualization_interface.backends._base import BaseBackend
from ansys.tools.visualization_interface.backends.plotly.widgets.button_manager import ButtonManager
from ansys.tools.visualization_interface.types.mesh_object_plot import MeshObjectPlot


Expand All @@ -37,6 +38,12 @@ class PlotlyBackend(BaseBackend):
def __init__(self) -> None:
"""Initialize the Plotly backend."""
self._fig = go.Figure()
self._button_manager = ButtonManager(self._fig)

# Stack buttons vertically on the left side
self._button_manager.add_plane_view_buttons()
self._button_manager.add_coordinate_system_toggle_button()
self._button_manager.add_projection_toggle_button()

def _pv_to_mesh3d(self, pv_mesh: Union[PolyData, pv.MultiBlock]) -> Union[go.Mesh3d, list]:
"""Convert a PyVista PolyData or MultiBlock mesh to Plotly Mesh3d format.
Expand Down Expand Up @@ -101,6 +108,7 @@ def _convert_polydata_to_mesh3d(self, pv_mesh: PolyData) -> go.Mesh3d:

return go.Mesh3d(x=x, y=y, z=z, i=i, j=j, k=k)


@property
def layout(self) -> Any:
"""Get the current layout of the Plotly figure.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (C) 2024 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""Widgets module init."""
Loading
Loading