You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/user_guide/migration.rst
+33-36Lines changed: 33 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,27 +4,25 @@ Migration
4
4
#########
5
5
6
6
In this section two guides are provided to help you migrate from PyVista plotters to the Ansys Tools Visualization Interface plotters.
7
-
The first one addresses code migration, and the second one addresses documentation migration.
8
7
9
-
Code migration guide
10
-
====================
8
+
Code migration
9
+
==============
10
+
This topic explains how to migrate from PyVista plotters to the new Ansys Tools Visualization Interface plotters. Because cases vary greatly, it provides a few examples that cover the most common scenarios.
11
11
12
-
This guide intends to help users transition from PyVista plotters to the new Ansys Tools Visualization Interface plotters. Since cases are very different
13
-
from each other, a few examples are provided to cover the most common scenarios.
14
-
15
-
From simple PyVista mesh plotting to the Ansys visualization interface plotter
If you only need to plot simple PyVista meshes, you can directly replace your PyVista plotter code with the Ansys Tools Visualization Interface plotter code.
18
-
On top of common PyVista functionalities, the Ansys Tools Visualization Interface plotter provides additional interactivity such as view buttons, mesh slicing, etc.
19
-
Here is an example of how to do this:
15
+
On top of common PyVista functionalities, the Ansys Tools Visualization Interface plotter provides additional interactivity such as view buttons and mesh slicing.
16
+
17
+
The following code shows how to do the plotter code replacement:
20
18
21
19
- PyVista code:
22
20
23
21
.. code-block:: python
24
22
25
23
import pyvista as pv
26
24
27
-
# Create a pyvista mesh
25
+
# Create a PyVista mesh
28
26
mesh = pv.Cube()
29
27
30
28
# Create a plotter
@@ -43,7 +41,7 @@ Here is an example of how to do this:
43
41
import pyvista as pv
44
42
from ansys.tools.visualization_interface import Plotter
45
43
46
-
# Create a pyvista mesh
44
+
# Create a PyVista mesh
47
45
mesh = pv.Cube()
48
46
49
47
# Create a plotter
@@ -56,10 +54,10 @@ Here is an example of how to do this:
56
54
pl.show()
57
55
58
56
59
-
Convert your custom meshes to MeshObjectPlot and use the Ansys visualization interface plotter
Your custom object must have a method that returns a PyVista mesh and a method that exposes a ``name`` or ``id`` attribute of your object.
60
+
Your custom object must have a method that returns a PyVista mesh and a method that exposes a ``name`` or ``id`` attribute of your object:
63
61
64
62
.. code-block:: python
65
63
@@ -75,7 +73,7 @@ Your custom object must have a method that returns a PyVista mesh and a method t
75
73
returnself.name
76
74
77
75
78
-
Then you need to create a ``MeshObjectPlot`` instance that relates the PyVista mesh with your custom object.
76
+
You then need to create a ``MeshObjectPlot`` instance that relates the PyVista mesh with your custom object:
79
77
80
78
.. code-block:: python
81
79
@@ -90,11 +88,10 @@ Then you need to create a ``MeshObjectPlot`` instance that relates the PyVista m
90
88
With this, you can use the Ansys Tools Visualization Interface plotter to visualize your custom object. It enables interactivity such as picking and hovering.
91
89
92
90
93
-
Customizing the PyVista backend
94
-
-------------------------------
91
+
Customize the PyVista backend
92
+
-----------------------------
95
93
96
-
You can customize the backend of the Ansys Tools Visualization Interface plotter to enable or turn off certain functionalities. For example,
97
-
if you want to enable picking, you can do it as follows:
94
+
You can customize the backend of the Ansys Tools Visualization Interface plotter to enable or turn off certain functionalities. The following code shows how to enable picking:
98
95
99
96
.. code-block:: python
100
97
@@ -112,8 +109,8 @@ if you want to enable picking, you can do it as follows:
112
109
# Show the plotter
113
110
pl.show()
114
111
115
-
If you want to go further and customize the backend even more, you can create your own backend by inheriting from the ``PyVistaBackendInterface`` class
116
-
and implementing the required methods. You can find more information about this in the backend documentation:
112
+
If you want to customize the backend even more, you can create your own backend by inheriting from the ``PyVistaBackendInterface`` class
113
+
and implementing the required methods:
117
114
118
115
.. code-block:: python
119
116
@@ -124,9 +121,9 @@ and implementing the required methods. You can find more information about this
124
121
Parameters
125
122
----------
126
123
plottable_object : Any
127
-
One or more objects to add.
124
+
One or more objects plot.
128
125
name_filter : str, default: None.
129
-
Regular expression with the desired name or names to include in the plotter.
126
+
Regular expression with the desired name or names to include in the plotter.
130
127
**plotting_options : dict, default: None
131
128
Keyword arguments. For allowable keyword arguments, see the
@@ -142,7 +139,7 @@ and implementing the required methods. You can find more information about this
142
139
Parameters
143
140
----------
144
141
plottable_object : Any
145
-
Object to add.
142
+
Object to plot.
146
143
name_filter : str
147
144
Regular expression with the desired name or names to include in the plotter.
148
145
**plotting_options : dict, default: None
@@ -154,18 +151,18 @@ and implementing the required methods. You can find more information about this
154
151
155
152
156
153
The rest of the methods are implemented for you. This ensures that while you can customize what you need for plotting, the rest of the functionalities still work as expected.
157
-
If you need to even go further, you can also create your own plotter by inheriting from the ``BaseBackend`` class and implementing the required methods,
154
+
If you need to even go further, you can create your own plotter by inheriting from the ``BaseBackend`` class and implementing the required methods,
158
155
although this may break existing features. You can find more information about this in the plotter documentation.
159
156
160
157
Customize the picker or hover behavior
161
158
--------------------------------------
162
-
You can customize the picker of the Ansys Tools Visualization Interface plotter to decide what happens when an object is picked or hovered.
159
+
You can customize the picker of the Ansys Tools Visualization Interface plotter to decide what happens when you pick or hover over an object.
163
160
For example, if you want to print the name of the picked object, you can do it as described in the custom picker example.
164
161
165
-
Using PyVista Qt backend
166
-
------------------------
167
-
You can use the PyVista Qt backend with the Ansys Tools Visualization Interface plotter. To do this, you need to set the PyVista backend to Qt
168
-
before creating the plotter. Here is an example of how to do this:
162
+
Use the PyVista Qt backend
163
+
--------------------------
164
+
You can use the PyVista Qt backend with the Ansys Tools Visualization Interface plotter. To do this, you must set the PyVista backend to Qt
165
+
before creating the plotter:
169
166
170
167
.. code-block:: python
171
168
@@ -176,14 +173,14 @@ before creating the plotter. Here is an example of how to do this:
176
173
pl.backend.enable_widgets()
177
174
pv_backend.scene.show()
178
175
179
-
With this, you can integrate the plotter into a PyQt or PySide app by disabling ``show_qt`` parameter.
180
-
You can find more information about this in the `PyVista documentation <https://qtdocs.pyvista.org/>`_.
176
+
You can then integrate the plotter into a PyQt or PySide app by disabling the ``show_qt`` parameter.
177
+
For more information about this, see the `PyVista documentation <https://qtdocs.pyvista.org/>`_.
181
178
182
179
183
-
Documentation migration guide
184
-
=============================
180
+
Documentation configuration migration
181
+
=====================================
185
182
186
-
This guide is intended to help users transition from PyVista documentation configuration to the new Ansys Tools Visualization Interface documentation configuration.
183
+
This topic explains how to migrate from the PyVista documentation configuration to the new Ansys Tools Visualization Interface documentation configuration.
0 commit comments