-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Add customization APIs #465
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
Merged
Merged
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
0ed5db8
feat: Add customization APIs
AlejandroFernandezLuces d85217f
fix: unneeded docs
AlejandroFernandezLuces 082546e
chore: adding changelog file 465.miscellaneous.md [dependabot-skip]
pyansys-ci-bot 43ab206
fix: bugs and docs
AlejandroFernandezLuces 7aed2b6
Merge branch 'feat/customization-api' of https://github.com/ansys/ans…
AlejandroFernandezLuces 9626ba9
feat: add more customization apis
moe-ad 4205584
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 7480408
Merge branch 'main' into feat/customization-api
AlejandroFernandezLuces c4a1118
Merge branch 'main' into feat/customization-api
moe-ad 6c24cd5
Merge branch 'main' into feat/customization-api
AlejandroFernandezLuces 2b1c73a
Merge branch 'feat/customization-api' of https://github.com/ansys/ans…
AlejandroFernandezLuces 44a33a8
fix: Revert API changes
AlejandroFernandezLuces 9185175
test: Add tests for the public API
AlejandroFernandezLuces 98e857e
Merge branch 'main' into feat/customization-api
AlejandroFernandezLuces 26d450e
fix: Avoid using 3DText
AlejandroFernandezLuces e10f37a
Merge branch 'feat/customization-api' of https://github.com/ansys/ans…
AlejandroFernandezLuces 1ab9bb7
fix: Fixes and reset image cache
AlejandroFernandezLuces e8f977a
chore: adding changelog file 465.maintenance.md [dependabot-skip]
pyansys-ci-bot 586308a
fix: add text
AlejandroFernandezLuces 995e084
Merge branch 'feat/customization-api' of https://github.com/ansys/ans…
AlejandroFernandezLuces 45e9362
fix: Revert
AlejandroFernandezLuces 1358546
Merge branch 'main' into feat/customization-api
AlejandroFernandezLuces 9673fe3
debug
AlejandroFernandezLuces f7c3b0a
debug
AlejandroFernandezLuces 9a4d2d4
debug
AlejandroFernandezLuces a926f70
debug
AlejandroFernandezLuces 4decc89
debug: Remove doc dep, comment example except show
AlejandroFernandezLuces 2279c8d
debug: remove example
AlejandroFernandezLuces d2393f2
fix: Example
AlejandroFernandezLuces 1a5464f
fix: Improve example
AlejandroFernandezLuces 0c7b7fc
fix: Example
AlejandroFernandezLuces 5b6e175
Update ci_cd.yml
AlejandroFernandezLuces 1f861e5
fix: Example titles
AlejandroFernandezLuces d23397b
Merge branch 'feat/customization-api' of https://github.com/ansys/ans…
AlejandroFernandezLuces 83983a3
Merge branch 'main' into feat/customization-api
AlejandroFernandezLuces 8837bf8
fix: Add sections
AlejandroFernandezLuces a8ef11a
chore: adding changelog file 465.added.md [dependabot-skip]
pyansys-ci-bot a966121
fix: Typehints
AlejandroFernandezLuces 3c5051b
Merge branch 'feat/customization-api' of https://github.com/ansys/ans…
AlejandroFernandezLuces 260264f
fix: Homogenize examples
AlejandroFernandezLuces b938010
fix: Remove unneeded check
AlejandroFernandezLuces 72f801f
fix: Feedback
AlejandroFernandezLuces f840d88
chore: adding changelog file 465.maintenance.md [dependabot-skip]
pyansys-ci-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Feat: Add customization APIs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| Basic usage examples | ||
| ==================== | ||
|
|
||
| These examples show how to use the general plotter included in the Visualization Interface Tool. | ||
| These examples show how to use the general plotter included in the Visualization Interface Tool. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| # Copyright (C) 2024 - 2026 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. | ||
|
|
||
| """ | ||
| .. _api_ex: | ||
|
|
||
| Customization API example | ||
| ========================= | ||
|
|
||
| This example demonstrates how to use the customization API of the visualization interface | ||
| to add various elements to a PyVista scene, such as points, lines, planes, and text annotations. | ||
| The example also shows how to plot a simple sphere mesh and customize its appearance. | ||
|
|
||
| """ | ||
|
|
||
|
|
||
| from ansys.tools.visualization_interface import Plotter | ||
| import pyvista as pv | ||
|
|
||
| # Create a plotter using the Plotly backend and add basic geometry. | ||
|
|
||
| plotter = Plotter() | ||
|
|
||
| # Add a sphere - this works fine | ||
| sphere = pv.Sphere(radius=1.0, center=(0, 0, 0)) | ||
| plotter.plot(sphere) | ||
|
|
||
|
|
||
| # Add point markers to highlight specific locations. | ||
|
|
||
| key_points = [ | ||
| [1, 0, 0], # Point on X axis | ||
| [0, 1, 0], # Point on Y axis | ||
| [0, 0, 1], # Point on Z axis | ||
| ] | ||
|
|
||
| plotter.add_points(key_points, color='red', size=10) | ||
|
|
||
| # Add line segments to show coordinate axes. | ||
|
|
||
| # X axis | ||
| x_axis = [[0, 0, 0], [1.5, 0, 0]] | ||
| plotter.add_lines(x_axis, color='red', width=4.0) | ||
|
|
||
| # Y axis | ||
| y_axis = [[0, 0, 0], [0, 1.5, 0]] | ||
| plotter.add_lines(y_axis, color='green', width=4.0) | ||
|
|
||
| # Z axis | ||
| z_axis = [[0, 0, 0], [0, 0, 1.5]] | ||
| plotter.add_lines(z_axis, color='blue', width=4.0) | ||
|
|
||
|
|
||
| # Add a plane to show a reference surface. | ||
|
|
||
| plotter.add_planes( | ||
| center=(0, 0, 0), | ||
| normal=(0, 0, 1), | ||
| i_size=2.5, | ||
| j_size=2.5, | ||
| color='lightblue', | ||
| opacity=0.2 | ||
| ) | ||
|
|
||
|
|
||
| # Scene title at the top center | ||
| plotter.add_text("Customization API Example", position=(0.5, 0.95), font_size=18, color='white') | ||
|
|
||
| # Additional labels at the top corners | ||
| plotter.add_text("Plotly Backend", position=(0.05, 0.95), font_size=12, color='lightblue') | ||
| plotter.add_text("3D Visualization", position=(0.95, 0.95), font_size=12, color='lightgreen') | ||
|
|
||
| # Display the visualization with all customizations. | ||
|
|
||
| plotter.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| # Copyright (C) 2024 - 2026 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. | ||
|
|
||
| """ | ||
| .. _plotly_customization_api_example: | ||
|
|
||
| Backend-Agnostic Customization APIs (Plotly) | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
| This example demonstrates the backend-agnostic customization APIs with | ||
| the Plotly backend. | ||
|
|
||
| The same API calls work with both PyVista and Plotly backends, demonstrating | ||
| the true backend-agnostic nature of these methods. | ||
| """ | ||
|
|
||
| import pyvista as pv | ||
| from ansys.tools.visualization_interface import Plotter | ||
| from ansys.tools.visualization_interface.backends.plotly.plotly_interface import PlotlyBackend | ||
|
|
||
| # Create a plotter using the Plotly backend and add basic geometry. | ||
|
|
||
| plotter = Plotter(backend=PlotlyBackend()) | ||
|
|
||
| # Add a sphere - this works fine | ||
| sphere = pv.Sphere(radius=1.0, center=(0, 0, 0)) | ||
| plotter.plot(sphere) | ||
|
|
||
| # Add point markers to highlight specific locations. | ||
|
|
||
| key_points = [ | ||
| [1, 0, 0], # Point on X axis | ||
| [0, 1, 0], # Point on Y axis | ||
| [0, 0, 1], # Point on Z axis | ||
| ] | ||
|
|
||
| plotter.add_points(key_points, color='red', size=10) | ||
|
|
||
| # Add line segments to show coordinate axes. | ||
|
|
||
| # X axis | ||
| x_axis = [[0, 0, 0], [1.5, 0, 0]] | ||
| plotter.add_lines(x_axis, color='red', width=4.0) | ||
|
|
||
| # Y axis | ||
| y_axis = [[0, 0, 0], [0, 1.5, 0]] | ||
| plotter.add_lines(y_axis, color='green', width=4.0) | ||
|
|
||
| # Z axis | ||
| z_axis = [[0, 0, 0], [0, 0, 1.5]] | ||
| plotter.add_lines(z_axis, color='blue', width=4.0) | ||
|
|
||
|
|
||
|
|
||
| # Add a plane to show a reference surface. | ||
|
|
||
| plotter.add_planes( | ||
| center=(0, 0, 0), | ||
| normal=(0, 0, 1), | ||
| i_size=2.5, | ||
| j_size=2.5, | ||
| color='lightblue', | ||
| opacity=0.2 | ||
| ) | ||
|
|
||
|
|
||
| # Add text annotations using 2D normalized coordinates (0-1 range). | ||
|
|
||
| # Scene title at the top center | ||
| plotter.add_text("Customization API Example", position=(0.5, 0.95), font_size=18, color='white') | ||
|
|
||
| # Additional labels at the top corners | ||
| plotter.add_text("Plotly Backend", position=(0.05, 0.95), font_size=12, color='lightblue') | ||
| plotter.add_text("3D Visualization", position=(0.95, 0.95), font_size=12, color='lightgreen') | ||
|
|
||
|
|
||
| # Display the visualization with all customizations. | ||
|
|
||
|
|
||
| # Uncomment to show in browser: | ||
| plotter.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.