pytecplot 1.5.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pytecplot-1.5.2.dist-info/LICENSE.html +77 -0
- pytecplot-1.5.2.dist-info/METADATA +508 -0
- pytecplot-1.5.2.dist-info/RECORD +97 -0
- pytecplot-1.5.2.dist-info/WHEEL +5 -0
- pytecplot-1.5.2.dist-info/top_level.txt +1 -0
- tecplot/__init__.py +94 -0
- tecplot/annotation/__init__.py +7 -0
- tecplot/annotation/annotation.py +223 -0
- tecplot/annotation/geometry.py +369 -0
- tecplot/annotation/georeference.py +33 -0
- tecplot/annotation/image.py +185 -0
- tecplot/annotation/iter.py +105 -0
- tecplot/annotation/polyline.py +381 -0
- tecplot/annotation/text.py +744 -0
- tecplot/constant.py +401 -0
- tecplot/data/__init__.py +34 -0
- tecplot/data/array.py +645 -0
- tecplot/data/create.py +1 -0
- tecplot/data/dataset.py +1809 -0
- tecplot/data/extract.py +544 -0
- tecplot/data/face_neighbors.py +494 -0
- tecplot/data/facemap.py +814 -0
- tecplot/data/load.py +2075 -0
- tecplot/data/nodemap.py +577 -0
- tecplot/data/operate.py +928 -0
- tecplot/data/query.py +334 -0
- tecplot/data/save.py +343 -0
- tecplot/data/variable.py +280 -0
- tecplot/data/zone.py +841 -0
- tecplot/exception.py +201 -0
- tecplot/export/__init__.py +13 -0
- tecplot/export/animation.py +521 -0
- tecplot/export/export_setup.py +318 -0
- tecplot/export/image.py +577 -0
- tecplot/export/print_setup.py +218 -0
- tecplot/export/time_animation.py +607 -0
- tecplot/extension/__init__.py +14 -0
- tecplot/extension/ipython.py +68 -0
- tecplot/layout/__init__.py +20 -0
- tecplot/layout/frame.py +1285 -0
- tecplot/layout/layout.py +488 -0
- tecplot/layout/page.py +541 -0
- tecplot/legend/__init__.py +4 -0
- tecplot/legend/contour_legend.py +516 -0
- tecplot/legend/legend.py +141 -0
- tecplot/legend/line_legend.py +66 -0
- tecplot/legend/rgb_coloring_legend.py +291 -0
- tecplot/legend/scatter_legend.py +136 -0
- tecplot/macro.py +339 -0
- tecplot/plot/__init__.py +62 -0
- tecplot/plot/axes.py +881 -0
- tecplot/plot/axis.py +1350 -0
- tecplot/plot/blanking.py +584 -0
- tecplot/plot/contour.py +1302 -0
- tecplot/plot/effects.py +162 -0
- tecplot/plot/fieldmap.py +2159 -0
- tecplot/plot/grid.py +758 -0
- tecplot/plot/isosurface.py +1167 -0
- tecplot/plot/labels.py +338 -0
- tecplot/plot/linemap.py +1905 -0
- tecplot/plot/linking.py +489 -0
- tecplot/plot/plot.py +1791 -0
- tecplot/plot/rgb_coloring.py +281 -0
- tecplot/plot/scatter.py +396 -0
- tecplot/plot/slice.py +1544 -0
- tecplot/plot/streamtrace.py +1949 -0
- tecplot/plot/symbol.py +567 -0
- tecplot/plot/ticks.py +666 -0
- tecplot/plot/title.py +380 -0
- tecplot/plot/vector.py +679 -0
- tecplot/plot/view.py +868 -0
- tecplot/session/__init__.py +112 -0
- tecplot/session/aux_data.py +276 -0
- tecplot/session/config.py +92 -0
- tecplot/session/session.py +425 -0
- tecplot/session/state_changed.py +225 -0
- tecplot/session/style.py +504 -0
- tecplot/tecutil/__init__.py +16 -0
- tecplot/tecutil/arglist.py +230 -0
- tecplot/tecutil/captured_output.py +177 -0
- tecplot/tecutil/constant.py +1312 -0
- tecplot/tecutil/index_set.py +118 -0
- tecplot/tecutil/lock.py +36 -0
- tecplot/tecutil/message_pb2.py +39 -0
- tecplot/tecutil/preamble.py +54 -0
- tecplot/tecutil/stringlist.py +114 -0
- tecplot/tecutil/sv.py +1662 -0
- tecplot/tecutil/tecutil.py +12402 -0
- tecplot/tecutil/tecutil_client.py +627 -0
- tecplot/tecutil/tecutil_connector.py +937 -0
- tecplot/tecutil/tecutil_rpc.py +6845 -0
- tecplot/tecutil/util.py +332 -0
- tecplot/text/__init__.py +3 -0
- tecplot/text/font.py +224 -0
- tecplot/text/label_format.py +374 -0
- tecplot/text/textbox.py +106 -0
- tecplot/version.py +41 -0
tecplot/layout/layout.py
ADDED
|
@@ -0,0 +1,488 @@
|
|
|
1
|
+
|
|
2
|
+
import fnmatch
|
|
3
|
+
import logging
|
|
4
|
+
import re
|
|
5
|
+
import warnings
|
|
6
|
+
|
|
7
|
+
from os import path
|
|
8
|
+
|
|
9
|
+
from ..tecutil import _tecutil
|
|
10
|
+
from ..constant import *
|
|
11
|
+
from ..exception import *
|
|
12
|
+
from .. import session, tecutil
|
|
13
|
+
from ..tecutil import sv
|
|
14
|
+
from .page import Page
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
log = logging.getLogger(__name__)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@tecutil.lock()
|
|
21
|
+
def new_layout():
|
|
22
|
+
"""Clears the current layout and creates a blank frame.
|
|
23
|
+
|
|
24
|
+
This will invalidate any object instances previously obtained:
|
|
25
|
+
|
|
26
|
+
.. code-block:: python
|
|
27
|
+
:emphasize-lines: 4
|
|
28
|
+
|
|
29
|
+
import tecplot
|
|
30
|
+
|
|
31
|
+
frame = tecplot.active_frame()
|
|
32
|
+
tecplot.new_layout()
|
|
33
|
+
|
|
34
|
+
# frame object is no longer usable.
|
|
35
|
+
# the following will print:
|
|
36
|
+
# <class 'ValueError'> 255 is not a valid PlotType
|
|
37
|
+
try:
|
|
38
|
+
frame.plot_type
|
|
39
|
+
except Exception as e:
|
|
40
|
+
print(type(e),e)
|
|
41
|
+
"""
|
|
42
|
+
_tecutil.NewLayout()
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@tecutil.lock()
|
|
46
|
+
def load_layout(filename):
|
|
47
|
+
"""Reads a layout file and replaces the active frame.
|
|
48
|
+
|
|
49
|
+
Parameters:
|
|
50
|
+
filename (`str`): The file name of the layout to be loaded.
|
|
51
|
+
(See note below conerning absolute and relative paths.)
|
|
52
|
+
|
|
53
|
+
Raises:
|
|
54
|
+
`TecplotOSError`: If file can not be found.
|
|
55
|
+
`TecplotSystemError`: If the file could not be loaded.
|
|
56
|
+
|
|
57
|
+
.. note:: **Absolute and relative paths with PyTecplot**
|
|
58
|
+
|
|
59
|
+
Relative paths, when used within the PyTecplot API are always from
|
|
60
|
+
Python's current working directory which can be obtained by calling
|
|
61
|
+
:func:`os.getcwd()`. This is true for batch and `connected
|
|
62
|
+
<tecplot.session.connect()>` modes. One exception to this is paths
|
|
63
|
+
within a macro command or file which will be relative to the |Tecplot
|
|
64
|
+
Engine|'s home directory, which is typically the |Tecplot 360|
|
|
65
|
+
installation directory. Finally, when connected to a remote (non-local)
|
|
66
|
+
instance of Tecplot 360, only absolute paths are allowed.
|
|
67
|
+
|
|
68
|
+
Note that backslashes must be escaped which is especially important for
|
|
69
|
+
windows paths such as ``"C:\\\\Users"`` or ``"\\\\\\\\server\\\\path"``
|
|
70
|
+
which will resolve to ``"C:\\Users"`` and ``"\\\\server\\path"``
|
|
71
|
+
respectively. Alternatively, one may use Python's raw strings:
|
|
72
|
+
``r"C:\\Users"`` and ``r"\\\\server\\path"``
|
|
73
|
+
|
|
74
|
+
This will replace the current layout and therefore will invalidate any
|
|
75
|
+
object instances previously obtained:
|
|
76
|
+
|
|
77
|
+
.. code-block:: python
|
|
78
|
+
:emphasize-lines: 8
|
|
79
|
+
|
|
80
|
+
import os
|
|
81
|
+
import tecplot as tp
|
|
82
|
+
|
|
83
|
+
frame = tp.active_frame()
|
|
84
|
+
|
|
85
|
+
examples = tp.session.tecplot_examples_directory()
|
|
86
|
+
layoutfile = os.path.join(examples, 'SimpleData', 'F18.lay')
|
|
87
|
+
tp.load_layout(layoutfile)
|
|
88
|
+
|
|
89
|
+
# frame object is no longer usable.
|
|
90
|
+
# the following will print:
|
|
91
|
+
# <class 'ValueError'> 255 is not a valid PlotType
|
|
92
|
+
try:
|
|
93
|
+
frame.plot_type
|
|
94
|
+
except Exception as e:
|
|
95
|
+
print(type(e),e)
|
|
96
|
+
"""
|
|
97
|
+
filepath = tecutil.normalize_path(filename)
|
|
98
|
+
with tecutil.ArgList(FNAME=filepath) as arglist:
|
|
99
|
+
if not _tecutil.OpenLayoutX(arglist):
|
|
100
|
+
raise TecplotSystemError(filepath)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@tecutil.lock()
|
|
104
|
+
def save_layout(filename, include_data=None, include_preview=None,
|
|
105
|
+
use_relative_paths=None, post_layout_commands=None,
|
|
106
|
+
pages=None):
|
|
107
|
+
"""Writes the current layout to a file.
|
|
108
|
+
|
|
109
|
+
Parameters:
|
|
110
|
+
filename (`str`): The path to the output filename. (See note
|
|
111
|
+
below conerning absolute and relative paths.)
|
|
112
|
+
include_data (`bool`, optional): Associated value indicates
|
|
113
|
+
if the layout should be saved as a layout package where the data
|
|
114
|
+
is included with the style information or if it should reference
|
|
115
|
+
linked data. If 'include_data' is None and the filename ends
|
|
116
|
+
with '.lpk', then the file will be saved as a layout package file.
|
|
117
|
+
(default: None)
|
|
118
|
+
include_preview (`bool`, optional): Associated value
|
|
119
|
+
indicates if the layout package should also include a preview
|
|
120
|
+
image. This argument only applies if the include data option is
|
|
121
|
+
True. (default: `True`)
|
|
122
|
+
use_relative_paths (`bool`, optional): Associated value
|
|
123
|
+
indicates if the layout should be saved using relative paths.
|
|
124
|
+
This argument only applies if the include data option is `False`.
|
|
125
|
+
(default: `False`)
|
|
126
|
+
post_layout_commands (`str`, optional): A character string
|
|
127
|
+
containing a set of Tecplot macro commands that are appended to
|
|
128
|
+
the layout or layout package file. These can be almost anything
|
|
129
|
+
and are generally used to store add-on specific state
|
|
130
|
+
information using ``$!EXTENDEDCOMMAND`` commands. (default:
|
|
131
|
+
`None`)
|
|
132
|
+
pages (`list` of `Page <layout.Page>` objects, optional): If `None`, all pages
|
|
133
|
+
are written to the layout, otherwise the specified subset of pages
|
|
134
|
+
are written. (default: `None`)
|
|
135
|
+
|
|
136
|
+
.. note:: **Absolute and relative paths with PyTecplot**
|
|
137
|
+
|
|
138
|
+
Relative paths, when used within the PyTecplot API are always from
|
|
139
|
+
Python's current working directory which can be obtained by calling
|
|
140
|
+
:func:`os.getcwd()`. This is true for batch and `connected
|
|
141
|
+
<tecplot.session.connect()>` modes. One exception to this is paths
|
|
142
|
+
within a macro command or file which will be relative to the |Tecplot
|
|
143
|
+
Engine|'s home directory, which is typically the |Tecplot 360|
|
|
144
|
+
installation directory. Finally, when connected to a remote (non-local)
|
|
145
|
+
instance of Tecplot 360, only absolute paths are allowed.
|
|
146
|
+
|
|
147
|
+
Note that backslashes must be escaped which is especially important for
|
|
148
|
+
windows paths such as ``"C:\\\\Users"`` or ``"\\\\\\\\server\\\\path"``
|
|
149
|
+
which will resolve to ``"C:\\Users"`` and ``"\\\\server\\path"``
|
|
150
|
+
respectively. Alternatively, one may use Python's raw strings:
|
|
151
|
+
``r"C:\\Users"`` and ``r"\\\\server\\path"``
|
|
152
|
+
|
|
153
|
+
.. note::
|
|
154
|
+
|
|
155
|
+
If you receive an exception with the error message "Journal should be
|
|
156
|
+
valid in all frames", then you must save a data file using
|
|
157
|
+
`save_tecplot_ascii` or `save_tecplot_plt` before saving the layout.
|
|
158
|
+
|
|
159
|
+
In this example, we load an example layout file and then save it as a
|
|
160
|
+
packaged layout file:
|
|
161
|
+
|
|
162
|
+
.. code-block:: python
|
|
163
|
+
:emphasize-lines: 8
|
|
164
|
+
|
|
165
|
+
import os
|
|
166
|
+
import tecplot
|
|
167
|
+
|
|
168
|
+
examples_dir = tecplot.session.tecplot_examples_directory()
|
|
169
|
+
infile = os.path.join(examples_dir, 'SimpleData', 'F18.lay')
|
|
170
|
+
|
|
171
|
+
tecplot.load_layout(infile)
|
|
172
|
+
tecplot.save_layout('output.lpk')
|
|
173
|
+
"""
|
|
174
|
+
if include_data is None and filename.lower().endswith('.lpk'):
|
|
175
|
+
include_data = True
|
|
176
|
+
|
|
177
|
+
with tecutil.ArgList() as arglist:
|
|
178
|
+
arglist[sv.FNAME] = tecutil.normalize_path(filename)
|
|
179
|
+
|
|
180
|
+
for arg, svarg in [(include_data, sv.INCLUDEDATA),
|
|
181
|
+
(include_preview, sv.INCLUDEPREVIEW),
|
|
182
|
+
(use_relative_paths, sv.USERELATIVEPATHS),
|
|
183
|
+
(post_layout_commands, sv.POSTLAYOUTCOMMANDS)]:
|
|
184
|
+
if arg is not None:
|
|
185
|
+
arglist[svarg] = arg
|
|
186
|
+
|
|
187
|
+
if pages is not None:
|
|
188
|
+
# Allow either an int array or page object array
|
|
189
|
+
if isinstance(pages[0], int):
|
|
190
|
+
arglist[sv.PAGELIST] = tecutil.IndexSet(P for P in pages)
|
|
191
|
+
else:
|
|
192
|
+
arglist[sv.PAGELIST] = tecutil.IndexSet(P.position
|
|
193
|
+
for P in pages)
|
|
194
|
+
|
|
195
|
+
if not _tecutil.SaveLayoutX(arglist):
|
|
196
|
+
raise TecplotSystemError()
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def active_page():
|
|
200
|
+
"""Returns the currently active page.
|
|
201
|
+
|
|
202
|
+
Returns:
|
|
203
|
+
`Page <layout.Page>`: The currently active page.
|
|
204
|
+
|
|
205
|
+
Only one `Page <layout.Page>` can be active at any given time. As long as the page is not
|
|
206
|
+
deleted (through a call to `new_layout` or `load_layout` for example) this
|
|
207
|
+
can be used to bring it back to the active state:
|
|
208
|
+
|
|
209
|
+
.. code-block:: python
|
|
210
|
+
:emphasize-lines: 3
|
|
211
|
+
|
|
212
|
+
import tecplot
|
|
213
|
+
|
|
214
|
+
page1 = tecplot.active_page()
|
|
215
|
+
page2 = tecplot.add_page()
|
|
216
|
+
|
|
217
|
+
# page2 is now active
|
|
218
|
+
assert page2.active
|
|
219
|
+
|
|
220
|
+
# we can bring page1 back to the front:
|
|
221
|
+
page1.activate()
|
|
222
|
+
assert page1.active
|
|
223
|
+
"""
|
|
224
|
+
return Page(_tecutil.PageGetUniqueID())
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def num_pages():
|
|
228
|
+
"""Returns the number of pages in the layout.
|
|
229
|
+
|
|
230
|
+
Returns: `int`
|
|
231
|
+
|
|
232
|
+
Example usage::
|
|
233
|
+
|
|
234
|
+
>>> print(tecplot.layout.num_pages())
|
|
235
|
+
1
|
|
236
|
+
"""
|
|
237
|
+
return _tecutil.PageGetCount()
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
@tecutil.lock()
|
|
241
|
+
def add_page():
|
|
242
|
+
"""Adds a `Page <layout.Page>` to the layout.
|
|
243
|
+
|
|
244
|
+
Returns:
|
|
245
|
+
`Page <layout.Page>`: The newly created page.
|
|
246
|
+
|
|
247
|
+
This will implicitly activate the newly created page:
|
|
248
|
+
|
|
249
|
+
.. code-block:: python
|
|
250
|
+
:emphasize-lines: 3
|
|
251
|
+
|
|
252
|
+
import tecplot
|
|
253
|
+
page1 = tecplot.active_page()
|
|
254
|
+
page2 = tecplot.add_page()
|
|
255
|
+
# page2 is now active
|
|
256
|
+
assert page2.active
|
|
257
|
+
"""
|
|
258
|
+
if _tecutil.PageCreateNew():
|
|
259
|
+
return Page(_tecutil.PageGetUniqueID())
|
|
260
|
+
else:
|
|
261
|
+
raise TecplotSystemError('could not add-create-new page')
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
@tecutil.lock()
|
|
265
|
+
def delete_page(page_to_delete):
|
|
266
|
+
"""Removes a `Page <layout.Page>` from the layout.
|
|
267
|
+
|
|
268
|
+
This will render any `Page <layout.Page>` object pointing to the deleted `Page <layout.Page>` useless.
|
|
269
|
+
The unique ID will not be used again in the active session and it is up
|
|
270
|
+
to the user to clear the python object using `del`:
|
|
271
|
+
|
|
272
|
+
.. code-block:: python
|
|
273
|
+
:emphasize-lines: 5
|
|
274
|
+
|
|
275
|
+
import tecplot as tp
|
|
276
|
+
from tecplot.exception import TecplotRuntimeError
|
|
277
|
+
|
|
278
|
+
page = tp.add_page()
|
|
279
|
+
tp.delete_page(page)
|
|
280
|
+
|
|
281
|
+
next_page = tp.active_page()
|
|
282
|
+
|
|
283
|
+
assert page != next_page
|
|
284
|
+
assert not page.active
|
|
285
|
+
|
|
286
|
+
try:
|
|
287
|
+
# the page is gone so activating
|
|
288
|
+
# will produce an exception
|
|
289
|
+
page.activate()
|
|
290
|
+
except TecplotRuntimeError as e:
|
|
291
|
+
print(e)
|
|
292
|
+
|
|
293
|
+
del page # clear the python object
|
|
294
|
+
"""
|
|
295
|
+
page_to_delete.activate()
|
|
296
|
+
_tecutil.PageDelete()
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
@tecutil.lock()
|
|
300
|
+
def next_page():
|
|
301
|
+
"""Activates and returns the next page.
|
|
302
|
+
|
|
303
|
+
Returns:
|
|
304
|
+
`layout.Page`: The next page in the layout.
|
|
305
|
+
|
|
306
|
+
`Page <layout.Page>` objects are stored in an ordered stack in the |Tecplot Engine|. This
|
|
307
|
+
method rotates the stack and returns the resulting active `Page <layout.Page>`:
|
|
308
|
+
|
|
309
|
+
.. code-block:: python
|
|
310
|
+
:emphasize-lines: 6
|
|
311
|
+
|
|
312
|
+
import tecplot
|
|
313
|
+
from tecplot.layout import next_page
|
|
314
|
+
|
|
315
|
+
page1 = tecplot.active_page()
|
|
316
|
+
page2 = tecplot.add_page()
|
|
317
|
+
page3 = next_page()
|
|
318
|
+
|
|
319
|
+
# page1 is now the active page
|
|
320
|
+
# and is the same as page3
|
|
321
|
+
assert page1.active
|
|
322
|
+
assert page3 == page1
|
|
323
|
+
"""
|
|
324
|
+
_tecutil.PageSetCurrentToNext()
|
|
325
|
+
return active_page()
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def page(pattern):
|
|
329
|
+
"""Returns the page by name.
|
|
330
|
+
|
|
331
|
+
Parameters:
|
|
332
|
+
pattern (`str` or `re.Pattern <re.compile>`): Case-insensitive
|
|
333
|
+
`glob-style pattern string <fnmatch.fnmatch>` or a compiled
|
|
334
|
+
`regex pattern instance <re.compile>` used to match the page by
|
|
335
|
+
name.
|
|
336
|
+
|
|
337
|
+
Returns:
|
|
338
|
+
`Page <layout.Page>`: The first page identified by *pattern*.
|
|
339
|
+
|
|
340
|
+
.. note::
|
|
341
|
+
|
|
342
|
+
A layout can contain `pages <tecplot.layout.Page>` with identical names and only the
|
|
343
|
+
first match found is returned. This is not guaranteed to be
|
|
344
|
+
deterministic and care should be taken to have only `pages <tecplot.layout.Page>` with
|
|
345
|
+
unique names when this feature is used.
|
|
346
|
+
|
|
347
|
+
Example:
|
|
348
|
+
|
|
349
|
+
.. code-block:: python
|
|
350
|
+
:emphasize-lines: 6
|
|
351
|
+
|
|
352
|
+
import tecplot
|
|
353
|
+
page11 = tecplot.add_page()
|
|
354
|
+
page11.name = 'Page 11'
|
|
355
|
+
page12 = tecplot.add_page()
|
|
356
|
+
page12.name = 'Page 12'
|
|
357
|
+
assert page12 == tecplot.page('Page 1*')
|
|
358
|
+
"""
|
|
359
|
+
return next(pages(pattern), None)
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
def pages(pattern=None):
|
|
363
|
+
"""Yields pages matching a specified pattern.
|
|
364
|
+
|
|
365
|
+
Parameters:
|
|
366
|
+
pattern (`str` or `re.Pattern <re.compile>`, optional):
|
|
367
|
+
Case-insensitive `glob-style pattern string <fnmatch.fnmatch>` or a
|
|
368
|
+
compiled `regex pattern instance <re.compile>` used to match page
|
|
369
|
+
names.
|
|
370
|
+
|
|
371
|
+
Returns:
|
|
372
|
+
`Page <layout.Page>`: Generator of pages identified by *pattern* or all pages if
|
|
373
|
+
no *pattern* is specified.
|
|
374
|
+
|
|
375
|
+
This function returns a generator which can only be iterated over once.
|
|
376
|
+
It can be converted to a `list` for persistence:
|
|
377
|
+
|
|
378
|
+
.. code-block:: python
|
|
379
|
+
|
|
380
|
+
import tecplot
|
|
381
|
+
|
|
382
|
+
# iterate over all frames in
|
|
383
|
+
# all pages and print their names
|
|
384
|
+
for page in tecplot.pages():
|
|
385
|
+
for frame in page.frames():
|
|
386
|
+
print(frame.name)
|
|
387
|
+
|
|
388
|
+
# store a persistent list of pages
|
|
389
|
+
pages = list(tecplot.pages())
|
|
390
|
+
"""
|
|
391
|
+
if pattern:
|
|
392
|
+
pattern_type = getattr(re, 'Pattern', getattr(re, '_pattern_type', None))
|
|
393
|
+
if not isinstance(pattern, pattern_type):
|
|
394
|
+
regex = re.compile(fnmatch.translate(pattern), re.IGNORECASE)
|
|
395
|
+
else:
|
|
396
|
+
regex = pattern
|
|
397
|
+
|
|
398
|
+
if __debug__:
|
|
399
|
+
found = False
|
|
400
|
+
for i in range(num_pages()):
|
|
401
|
+
current_page = Page(_tecutil.PageGetUniqueID())
|
|
402
|
+
if pattern is None or regex.match(current_page.name):
|
|
403
|
+
if __debug__:
|
|
404
|
+
found = True
|
|
405
|
+
yield current_page
|
|
406
|
+
next_page()
|
|
407
|
+
|
|
408
|
+
if __debug__:
|
|
409
|
+
if (
|
|
410
|
+
not found and
|
|
411
|
+
pattern is not None and
|
|
412
|
+
isinstance(pattern, str) and
|
|
413
|
+
any(c in pattern for c in '*?[]')
|
|
414
|
+
):
|
|
415
|
+
msg = 'no pages found matching: "{}"'.format(pattern)
|
|
416
|
+
warning = TecplotPatternMatchWarning(pattern, msg, 'glob')
|
|
417
|
+
warnings.warn(warning)
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
def active_frame():
|
|
421
|
+
"""Returns the active frame.
|
|
422
|
+
|
|
423
|
+
Returns:
|
|
424
|
+
`Frame <layout.Frame>`: Currently active frame.
|
|
425
|
+
"""
|
|
426
|
+
return active_page().active_frame()
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
def frames(frame_pattern=None, page_pattern=None):
|
|
430
|
+
"""Returns a generator of frames matching the specified pattern.
|
|
431
|
+
|
|
432
|
+
Parameters:
|
|
433
|
+
frame_pattern (`str` or `re.Pattern <re.compile>`): Case-insensitive
|
|
434
|
+
`glob-style pattern string <fnmatch.fnmatch>` or a compiled
|
|
435
|
+
`regex pattern instance <re.compile>` used to match the frame by
|
|
436
|
+
name. All frames are returned if no pattern is specified.
|
|
437
|
+
page_pattern (`str` or `re.Pattern <re.compile>`): Case-insensitive
|
|
438
|
+
`glob-style pattern string <fnmatch.fnmatch>` or a compiled
|
|
439
|
+
`regex pattern instance <re.compile>` used to match the page by
|
|
440
|
+
name. All pages are included if no pattern is specified.
|
|
441
|
+
|
|
442
|
+
Returns:
|
|
443
|
+
`Frame <layout.Frame>`: Generator of frames identified by name patterns.
|
|
444
|
+
|
|
445
|
+
.. code-block:: python
|
|
446
|
+
|
|
447
|
+
import tecplot
|
|
448
|
+
|
|
449
|
+
# print name of all frames on all pages
|
|
450
|
+
for frame in tecplot.frames():
|
|
451
|
+
print(frame.name)
|
|
452
|
+
"""
|
|
453
|
+
for page in pages(page_pattern):
|
|
454
|
+
for frame in page.frames(frame_pattern):
|
|
455
|
+
yield frame
|
|
456
|
+
|
|
457
|
+
def aux_data():
|
|
458
|
+
"""Auxiliary data for the current layout.
|
|
459
|
+
|
|
460
|
+
Returns:
|
|
461
|
+
`AuxData`
|
|
462
|
+
|
|
463
|
+
This is the auxiliary data attached to the entire layout containing all
|
|
464
|
+
frames and datasets currently held by the Tecplot Engine. Such data is
|
|
465
|
+
written to the layout file by default and can be retrieved later. Example
|
|
466
|
+
usage:
|
|
467
|
+
|
|
468
|
+
.. code-block:: python
|
|
469
|
+
|
|
470
|
+
import tecplot as tp
|
|
471
|
+
|
|
472
|
+
aux = tp.layout.aux_data()
|
|
473
|
+
aux['info'] = '''\
|
|
474
|
+
This layout contains a lot of things:
|
|
475
|
+
1. Something
|
|
476
|
+
2. Something else
|
|
477
|
+
3. Also this'''
|
|
478
|
+
|
|
479
|
+
'''
|
|
480
|
+
The following will print (including newlines):
|
|
481
|
+
This layout contains a lot of things:
|
|
482
|
+
1. Something
|
|
483
|
+
2. Something else
|
|
484
|
+
3. Also this
|
|
485
|
+
'''
|
|
486
|
+
print(aux['info'])
|
|
487
|
+
"""
|
|
488
|
+
return session.AuxData(None, AuxDataObjectType.Layout)
|