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/page.py
ADDED
|
@@ -0,0 +1,541 @@
|
|
|
1
|
+
import fnmatch
|
|
2
|
+
import logging
|
|
3
|
+
import re
|
|
4
|
+
import warnings
|
|
5
|
+
|
|
6
|
+
from contextlib import contextmanager
|
|
7
|
+
|
|
8
|
+
from ..tecutil import _tecutil
|
|
9
|
+
from ..constant import *
|
|
10
|
+
from ..exception import *
|
|
11
|
+
from .. import macro, session, tecutil
|
|
12
|
+
from ..tecutil import Index, lock, lock_attributes, sv
|
|
13
|
+
from .frame import Frame
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
log = logging.getLogger(__name__)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@lock_attributes
|
|
20
|
+
class Page(object):
|
|
21
|
+
"""`Page <tecplot.layout.Page>` object within a layout, holding onto one or more `Frames <tecplot.layout.Frame>`.
|
|
22
|
+
|
|
23
|
+
Parameters:
|
|
24
|
+
uid (`int`, optional): This must be a *valid* unique ID
|
|
25
|
+
number pointing internally to a `Page <tecplot.layout.Page>` object or `None`. A new
|
|
26
|
+
`Page <tecplot.layout.Page>` is created if set to `None`. (default: `None`)
|
|
27
|
+
|
|
28
|
+
Warning:
|
|
29
|
+
Though it is possible to create a `Page <tecplot.layout.Page>` object using the
|
|
30
|
+
constructor, it is usually sufficient to obtain a page through
|
|
31
|
+
`tecplot.add_page`, `tecplot.active_page`, `tecplot.page` or
|
|
32
|
+
`tecplot.pages`.
|
|
33
|
+
|
|
34
|
+
A `Page <tecplot.layout.Page>` can be thought of like a canvas onto which one or more
|
|
35
|
+
`Frames <tecplot.layout.Frame>` can be laid out. The engine guarantees there will
|
|
36
|
+
always be at least one `Page <tecplot.layout.Page>` in the layout which can be accessed
|
|
37
|
+
via `tecplot.active_page`:
|
|
38
|
+
|
|
39
|
+
.. code-block:: python
|
|
40
|
+
|
|
41
|
+
import tecplot
|
|
42
|
+
|
|
43
|
+
page = tecplot.active_page()
|
|
44
|
+
page.name = 'Page 001'
|
|
45
|
+
|
|
46
|
+
# prints: "Page 001"
|
|
47
|
+
print(page.name)
|
|
48
|
+
|
|
49
|
+
# prints: "Frame 001"
|
|
50
|
+
for frame in page.frames():
|
|
51
|
+
print(frame.name)
|
|
52
|
+
"""
|
|
53
|
+
def __init__(self, uid):
|
|
54
|
+
self.uid = uid
|
|
55
|
+
self.framelist = None
|
|
56
|
+
"""The unique ID number of this Page, internal to the |Tecplot Engine|."""
|
|
57
|
+
self._sv = [sv.PAGE]
|
|
58
|
+
|
|
59
|
+
def __str__(self):
|
|
60
|
+
"""Brief string representation.
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
`str`: Brief representation of this `Page <tecplot.layout.Page>`.
|
|
64
|
+
|
|
65
|
+
Example:
|
|
66
|
+
|
|
67
|
+
.. code-block:: python
|
|
68
|
+
|
|
69
|
+
import tecplot
|
|
70
|
+
page = tecplot.active_page()
|
|
71
|
+
page.name = 'Page 001'
|
|
72
|
+
|
|
73
|
+
# will print: 'Page: "Page 001"'
|
|
74
|
+
print(page)
|
|
75
|
+
"""
|
|
76
|
+
return 'Page: "{name}"'.format(name=self.name)
|
|
77
|
+
|
|
78
|
+
def __repr__(self):
|
|
79
|
+
"""Executable string representation.
|
|
80
|
+
|
|
81
|
+
Returns:
|
|
82
|
+
`str`: Internal representation of this `Page <tecplot.layout.Page>`.
|
|
83
|
+
|
|
84
|
+
The string returned can be executed to generate an identical
|
|
85
|
+
copy of this `Page <tecplot.layout.Page>` object:
|
|
86
|
+
|
|
87
|
+
.. code-block:: python
|
|
88
|
+
|
|
89
|
+
import tecplot
|
|
90
|
+
from tecplot.layout import Page
|
|
91
|
+
|
|
92
|
+
page = tecplot.active_page()
|
|
93
|
+
|
|
94
|
+
'''
|
|
95
|
+
The "repr" string of the Page is executable code.
|
|
96
|
+
The following will print: "Page(uid=1)"
|
|
97
|
+
'''
|
|
98
|
+
print(repr(page))
|
|
99
|
+
|
|
100
|
+
page2 = None
|
|
101
|
+
exec('page2 = '+repr(page))
|
|
102
|
+
|
|
103
|
+
'''
|
|
104
|
+
At this point, page2 is just another handle to
|
|
105
|
+
the exact same page object in the Tecplot Engine
|
|
106
|
+
'''
|
|
107
|
+
assert page2 == page
|
|
108
|
+
"""
|
|
109
|
+
return 'Page(uid={uid})'.format(uid=self.uid)
|
|
110
|
+
|
|
111
|
+
def __eq__(self, other):
|
|
112
|
+
"""Checks for `Page <tecplot.layout.Page>` equality in the |Tecplot Engine|.
|
|
113
|
+
|
|
114
|
+
Returns:
|
|
115
|
+
`bool`: `True` if the unique ID numbers are the same for both `Pages <tecplot.layout.Page>`.
|
|
116
|
+
|
|
117
|
+
Example:
|
|
118
|
+
|
|
119
|
+
.. code-block:: python
|
|
120
|
+
|
|
121
|
+
import tecplot
|
|
122
|
+
|
|
123
|
+
page1 = tecplot.active_page()
|
|
124
|
+
page2 = tecplot.add_page()
|
|
125
|
+
|
|
126
|
+
assert page1 != page2
|
|
127
|
+
assert tecplot.active_page() == page2
|
|
128
|
+
"""
|
|
129
|
+
return self.uid == other.uid
|
|
130
|
+
|
|
131
|
+
@lock()
|
|
132
|
+
def __contains__(self, frame):
|
|
133
|
+
with self.activated():
|
|
134
|
+
result = False
|
|
135
|
+
if _tecutil.FrameGetCount():
|
|
136
|
+
with session.suspend():
|
|
137
|
+
_tecutil.FrameLightweightLoopStart()
|
|
138
|
+
try:
|
|
139
|
+
while True:
|
|
140
|
+
if frame.uid == _tecutil.FrameGetUniqueID():
|
|
141
|
+
result = True
|
|
142
|
+
break
|
|
143
|
+
if not _tecutil.FrameLightweightLoopNext():
|
|
144
|
+
break
|
|
145
|
+
finally:
|
|
146
|
+
_tecutil.FrameLightweightLoopEnd()
|
|
147
|
+
return result
|
|
148
|
+
|
|
149
|
+
def __getitem__(self, pattern):
|
|
150
|
+
return self.frame(pattern)
|
|
151
|
+
|
|
152
|
+
def __iter__(self):
|
|
153
|
+
self.framelist = list(self.frames())
|
|
154
|
+
return self
|
|
155
|
+
|
|
156
|
+
def __next__(self):
|
|
157
|
+
try:
|
|
158
|
+
return self.framelist.pop(0)
|
|
159
|
+
except (KeyError, IndexError):
|
|
160
|
+
raise StopIteration
|
|
161
|
+
|
|
162
|
+
@property
|
|
163
|
+
def aux_data(self):
|
|
164
|
+
"""Auxiliary data for this page.
|
|
165
|
+
|
|
166
|
+
Returns: `AuxData`
|
|
167
|
+
|
|
168
|
+
This is the auxiliary data attached to the page. Such data is written
|
|
169
|
+
to the layout file by default and can be retrieved later. Example
|
|
170
|
+
usage::
|
|
171
|
+
|
|
172
|
+
>>> aux = tp.active_page().aux_data
|
|
173
|
+
>>> aux['Result'] = '3.14159'
|
|
174
|
+
>>> print(aux['Result'])
|
|
175
|
+
3.14159
|
|
176
|
+
"""
|
|
177
|
+
return session.AuxData(self, AuxDataObjectType.Page)
|
|
178
|
+
|
|
179
|
+
@property
|
|
180
|
+
def position(self):
|
|
181
|
+
"""`Index`: Index of the Page
|
|
182
|
+
|
|
183
|
+
The page positions are 0 based positions relative to the current page,
|
|
184
|
+
where the current page has a position value of 0, the next page 1,
|
|
185
|
+
the page after that 2, and so on.
|
|
186
|
+
"""
|
|
187
|
+
return Index(_tecutil.PageGetPosByUniqueID(self.uid) - 1)
|
|
188
|
+
|
|
189
|
+
@property
|
|
190
|
+
def name(self):
|
|
191
|
+
"""`str`: Name of the page.
|
|
192
|
+
|
|
193
|
+
This is the name used when searching for `Page <tecplot.layout.Page>` objects in
|
|
194
|
+
`tecplot.pages` and `tecplot.page`. It does not have to be unique.
|
|
195
|
+
|
|
196
|
+
Example:
|
|
197
|
+
|
|
198
|
+
.. code-block:: python
|
|
199
|
+
|
|
200
|
+
import tecplot
|
|
201
|
+
|
|
202
|
+
page = tecplot.active_page()
|
|
203
|
+
page.name = 'My Data'
|
|
204
|
+
|
|
205
|
+
# prints: "this page: My Data"
|
|
206
|
+
print('this page:', page.name)
|
|
207
|
+
"""
|
|
208
|
+
with self.activated():
|
|
209
|
+
return _tecutil.PageGetName()[1]
|
|
210
|
+
|
|
211
|
+
@name.setter
|
|
212
|
+
@lock()
|
|
213
|
+
def name(self, name):
|
|
214
|
+
with self.activated():
|
|
215
|
+
if not _tecutil.PageSetName(name):
|
|
216
|
+
raise TecplotSystemError()
|
|
217
|
+
|
|
218
|
+
@property
|
|
219
|
+
def paper(self):
|
|
220
|
+
"""`Paper`: The `Paper` defined in this `Page <tecplot.layout.Page>`.
|
|
221
|
+
|
|
222
|
+
Every `Page <tecplot.layout.Page>` has the concept of a workspace which includes
|
|
223
|
+
all `Frames <tecplot.layout.Frame>` as well as a sub-area of the workspace
|
|
224
|
+
called the `Paper`. The limits of the `Paper` with respect to
|
|
225
|
+
the placement of `Frames <tecplot.layout.Frame>` is used when exporting
|
|
226
|
+
certain image formats.
|
|
227
|
+
"""
|
|
228
|
+
return Paper(self)
|
|
229
|
+
|
|
230
|
+
@property
|
|
231
|
+
def active(self):
|
|
232
|
+
"""Checks if this `Page <tecplot.layout.Page>` is active.
|
|
233
|
+
|
|
234
|
+
Returns:
|
|
235
|
+
`bool`: `True` if active.
|
|
236
|
+
"""
|
|
237
|
+
return self.uid == _tecutil.PageGetUniqueID()
|
|
238
|
+
|
|
239
|
+
@lock()
|
|
240
|
+
def activate(self):
|
|
241
|
+
"""Activates the `Page <tecplot.layout.Page>`.
|
|
242
|
+
|
|
243
|
+
Raises:
|
|
244
|
+
`TecplotRuntimeError`: Page does not exist.
|
|
245
|
+
`TecplotSystemError`: Could not activate the page.
|
|
246
|
+
"""
|
|
247
|
+
if not self.active:
|
|
248
|
+
if not self.exists:
|
|
249
|
+
raise TecplotRuntimeError('page does not exists')
|
|
250
|
+
elif not _tecutil.PageSetCurrentByUniqueID(self.uid):
|
|
251
|
+
raise TecplotSystemError('could not activate page')
|
|
252
|
+
|
|
253
|
+
@contextmanager
|
|
254
|
+
def activated(self):
|
|
255
|
+
current_page = Page(_tecutil.PageGetUniqueID())
|
|
256
|
+
if self == current_page:
|
|
257
|
+
yield
|
|
258
|
+
else:
|
|
259
|
+
self.activate()
|
|
260
|
+
try:
|
|
261
|
+
yield
|
|
262
|
+
finally:
|
|
263
|
+
current_page.activate()
|
|
264
|
+
|
|
265
|
+
def active_frame(self):
|
|
266
|
+
"""Returns the active `Frame <tecplot.layout.Frame>`.
|
|
267
|
+
|
|
268
|
+
Returns:
|
|
269
|
+
`Frame <tecplot.layout.Frame>`: The active `Frame <tecplot.layout.Frame>`.
|
|
270
|
+
|
|
271
|
+
This implicitly activates this `Page <tecplot.layout.Page>` and returns the active
|
|
272
|
+
`Frame <tecplot.layout.Frame>` attached to it.
|
|
273
|
+
"""
|
|
274
|
+
self.activate()
|
|
275
|
+
if _tecutil.FrameGetCount():
|
|
276
|
+
return Frame(_tecutil.FrameGetActiveID(), self)
|
|
277
|
+
|
|
278
|
+
@lock()
|
|
279
|
+
def add_frame(self, position=None, size=None):
|
|
280
|
+
"""Creates a new `Frame <tecplot.layout.Frame>` in this `Page <tecplot.layout.Page>`.
|
|
281
|
+
|
|
282
|
+
Parameters:
|
|
283
|
+
position (`tuple` of `floats <float>` (x,y), optional): The
|
|
284
|
+
position (in inches) of the frame relative to the top left
|
|
285
|
+
corner of the paper. If supplied, size must also be supplied.
|
|
286
|
+
size (`tuple` of `floats <float>` (width,height), optional): The
|
|
287
|
+
size (in inches) of the frame. If supplied, position must also
|
|
288
|
+
be supplied.
|
|
289
|
+
|
|
290
|
+
Returns:
|
|
291
|
+
`Frame <tecplot.layout.Frame>`: The newly created and activated `Frame <tecplot.layout.Frame>`.
|
|
292
|
+
|
|
293
|
+
This implicitly activates the `Page <tecplot.layout.Page>` and creates and activates
|
|
294
|
+
a new `Frame <tecplot.layout.Frame>`.
|
|
295
|
+
|
|
296
|
+
.. code-block:: python
|
|
297
|
+
|
|
298
|
+
import tecplot as tp
|
|
299
|
+
|
|
300
|
+
frame = tp.active_page().add_frame(position=(1, 0.25), size=(8, 9))
|
|
301
|
+
"""
|
|
302
|
+
supplied_frame_size = bool(position or size)
|
|
303
|
+
|
|
304
|
+
if __debug__:
|
|
305
|
+
if bool(position) ^ bool(size):
|
|
306
|
+
raise TecplotValueError('must supply position and size')
|
|
307
|
+
msg = 'position and size must be 2-tuple'
|
|
308
|
+
if supplied_frame_size:
|
|
309
|
+
if hasattr(position, '__iter__') and hasattr(size, '__iter__'):
|
|
310
|
+
if len(position) != 2 or len(size) != 2:
|
|
311
|
+
raise TecplotValueError(msg)
|
|
312
|
+
else:
|
|
313
|
+
raise TecplotTypeError(msg)
|
|
314
|
+
|
|
315
|
+
pos = tecutil.XY(*(position or (0, 0)))
|
|
316
|
+
size = tecutil.XY(*(size or (0, 0)))
|
|
317
|
+
|
|
318
|
+
self.activate()
|
|
319
|
+
if not _tecutil.FrameCreateNew(supplied_frame_size, pos.x, pos.y, size.x, size.y):
|
|
320
|
+
raise TecplotSystemError('could not create new frame')
|
|
321
|
+
else:
|
|
322
|
+
uid = _tecutil.FrameGetActiveID()
|
|
323
|
+
if uid > 0:
|
|
324
|
+
return Frame(uid, self)
|
|
325
|
+
else:
|
|
326
|
+
raise TecplotRuntimeError('could not get id of newly created active frame')
|
|
327
|
+
|
|
328
|
+
@lock()
|
|
329
|
+
def delete_frame(self, frame):
|
|
330
|
+
"""Removes the frame from this `Page <tecplot.layout.Page>`.
|
|
331
|
+
|
|
332
|
+
Raises:
|
|
333
|
+
`TecplotRuntimeError`: If `Frame <tecplot.layout.Frame>` is not in this `Page <tecplot.layout.Page>`.
|
|
334
|
+
`TecplotSystemError`: Could not delete the frame.
|
|
335
|
+
"""
|
|
336
|
+
if frame not in self:
|
|
337
|
+
raise TecplotRuntimeError('frame is not in this page')
|
|
338
|
+
else:
|
|
339
|
+
with frame.activated():
|
|
340
|
+
if not _tecutil.FrameDeleteActive():
|
|
341
|
+
raise TecplotSystemError()
|
|
342
|
+
|
|
343
|
+
@lock()
|
|
344
|
+
def frame(self, pattern):
|
|
345
|
+
"""Returns the `Frame <tecplot.layout.Frame>` by name.
|
|
346
|
+
|
|
347
|
+
Parameters:
|
|
348
|
+
pattern (`str` or `re.Pattern <re.compile>`): Case-insensitive
|
|
349
|
+
`glob-style pattern string <fnmatch.fnmatch>` or a compiled
|
|
350
|
+
`regex pattern instance <re.compile>` used to match the frame
|
|
351
|
+
by name.
|
|
352
|
+
|
|
353
|
+
Returns:
|
|
354
|
+
`Frame <tecplot.layout.Frame>`: The first `Frame <tecplot.layout.Frame>` identified by *pattern*.
|
|
355
|
+
|
|
356
|
+
.. note::
|
|
357
|
+
A `Page <tecplot.layout.Page>` can contain `Frames <tecplot.layout.Frame>` with identical names and only
|
|
358
|
+
the first match found is returned. This is not guaranteed to be
|
|
359
|
+
deterministic and care should be taken to have only `Frames
|
|
360
|
+
<tecplot.layout.Frame>` with unique names when this feature is used.
|
|
361
|
+
|
|
362
|
+
Example:
|
|
363
|
+
|
|
364
|
+
.. code-block:: python
|
|
365
|
+
:emphasize-lines: 11
|
|
366
|
+
|
|
367
|
+
import tecplot
|
|
368
|
+
page = tecplot.active_page()
|
|
369
|
+
|
|
370
|
+
frameA = page.add_frame()
|
|
371
|
+
frameA.name = 'A'
|
|
372
|
+
|
|
373
|
+
frameB = page.add_frame()
|
|
374
|
+
frameB.name = 'B'
|
|
375
|
+
|
|
376
|
+
assert frameB.active
|
|
377
|
+
assert frameA == page.frame('A')
|
|
378
|
+
"""
|
|
379
|
+
pattern_type = getattr(re, 'Pattern', getattr(re, '_pattern_type', None))
|
|
380
|
+
if not isinstance(pattern, pattern_type):
|
|
381
|
+
regex = re.compile(fnmatch.translate(pattern), re.IGNORECASE)
|
|
382
|
+
else:
|
|
383
|
+
regex = pattern
|
|
384
|
+
|
|
385
|
+
with self.activated():
|
|
386
|
+
frame = None
|
|
387
|
+
if _tecutil.FrameGetCount():
|
|
388
|
+
with session.suspend():
|
|
389
|
+
_tecutil.FrameLightweightLoopStart()
|
|
390
|
+
try:
|
|
391
|
+
while True:
|
|
392
|
+
if regex.match(_tecutil.FrameGetName()[1]):
|
|
393
|
+
frame = Frame(_tecutil.FrameGetUniqueID(), self)
|
|
394
|
+
break
|
|
395
|
+
if not _tecutil.FrameLightweightLoopNext():
|
|
396
|
+
break
|
|
397
|
+
finally:
|
|
398
|
+
_tecutil.FrameLightweightLoopEnd()
|
|
399
|
+
if __debug__:
|
|
400
|
+
if (
|
|
401
|
+
frame is None and
|
|
402
|
+
isinstance(pattern, str) and
|
|
403
|
+
any(c in pattern for c in '*?[]')
|
|
404
|
+
):
|
|
405
|
+
msg = 'no frame found matching: "{}"'.format(pattern)
|
|
406
|
+
warning = TecplotPatternMatchWarning(pattern, msg, 'glob')
|
|
407
|
+
warnings.warn(warning)
|
|
408
|
+
return frame
|
|
409
|
+
|
|
410
|
+
@lock()
|
|
411
|
+
def frames(self, pattern=None):
|
|
412
|
+
"""Returns a `list` of `Frames <tecplot.layout.Frame>` matching the specified pattern.
|
|
413
|
+
|
|
414
|
+
Parameters:
|
|
415
|
+
pattern (`str` or `re.Pattern <re.compile>`, optional):
|
|
416
|
+
Case-insensitive `glob-style pattern string <fnmatch.fnmatch>`
|
|
417
|
+
or a compiled `regex pattern instance <re.compile>` used to
|
|
418
|
+
match frame names.
|
|
419
|
+
|
|
420
|
+
Returns:
|
|
421
|
+
`list`: `Frames <tecplot.layout.Frame>` identified by *pattern* or all frames if
|
|
422
|
+
no *pattern* is specified.
|
|
423
|
+
|
|
424
|
+
Example:
|
|
425
|
+
|
|
426
|
+
.. code-block:: python
|
|
427
|
+
|
|
428
|
+
import tecplot
|
|
429
|
+
|
|
430
|
+
page = tecplot.active_page()
|
|
431
|
+
page.add_frame() # create a second frame
|
|
432
|
+
|
|
433
|
+
# iterate over all frames and print their names
|
|
434
|
+
for frame in page.frames():
|
|
435
|
+
print(frame.name)
|
|
436
|
+
|
|
437
|
+
# store a persistent list of frames
|
|
438
|
+
frames = page.frames()
|
|
439
|
+
|
|
440
|
+
# prints: ['Frame 001', 'Frame 002']
|
|
441
|
+
print([f.name for f in frames])
|
|
442
|
+
"""
|
|
443
|
+
if pattern:
|
|
444
|
+
pattern_type = getattr(re, 'Pattern', getattr(re, '_pattern_type', None))
|
|
445
|
+
if not isinstance(pattern, pattern_type):
|
|
446
|
+
regex = re.compile(fnmatch.translate(pattern), re.IGNORECASE)
|
|
447
|
+
else:
|
|
448
|
+
regex = pattern
|
|
449
|
+
|
|
450
|
+
with self.activated():
|
|
451
|
+
framelist = []
|
|
452
|
+
if _tecutil.FrameGetCount():
|
|
453
|
+
with session.suspend():
|
|
454
|
+
_tecutil.FrameLightweightLoopStart()
|
|
455
|
+
try:
|
|
456
|
+
while True:
|
|
457
|
+
success, name = _tecutil.FrameGetName()
|
|
458
|
+
if success:
|
|
459
|
+
if pattern is None or regex.match(name):
|
|
460
|
+
framelist.append(Frame(_tecutil.FrameGetUniqueID(), self))
|
|
461
|
+
if not _tecutil.FrameLightweightLoopNext():
|
|
462
|
+
break
|
|
463
|
+
finally:
|
|
464
|
+
_tecutil.FrameLightweightLoopEnd()
|
|
465
|
+
if __debug__:
|
|
466
|
+
if (
|
|
467
|
+
not framelist and
|
|
468
|
+
pattern is not None and
|
|
469
|
+
isinstance(pattern, str) and
|
|
470
|
+
any(c in pattern for c in '*?[]')
|
|
471
|
+
):
|
|
472
|
+
msg = 'no frames found matching: "{}"'.format(pattern)
|
|
473
|
+
warning = TecplotPatternMatchWarning(pattern, msg, 'glob')
|
|
474
|
+
warnings.warn(warning)
|
|
475
|
+
return framelist
|
|
476
|
+
|
|
477
|
+
@property
|
|
478
|
+
@lock()
|
|
479
|
+
def exists(self):
|
|
480
|
+
"""Checks if the `Page <tecplot.layout.Page>` exists in the current layout.
|
|
481
|
+
|
|
482
|
+
This will return `False` after the `Page <tecplot.layout.Page>` has been deleted:
|
|
483
|
+
|
|
484
|
+
.. code-block:: python
|
|
485
|
+
|
|
486
|
+
import tecplot as tp
|
|
487
|
+
page = tp.add_page()
|
|
488
|
+
assert page.exists
|
|
489
|
+
tp.delete_page(page)
|
|
490
|
+
assert not page.exists
|
|
491
|
+
"""
|
|
492
|
+
current_page = _tecutil.PageGetUniqueID()
|
|
493
|
+
try:
|
|
494
|
+
for _ in range(_tecutil.PageGetCount()):
|
|
495
|
+
_tecutil.PageSetCurrentToNext()
|
|
496
|
+
if self.uid == _tecutil.PageGetUniqueID():
|
|
497
|
+
return True
|
|
498
|
+
return False
|
|
499
|
+
finally:
|
|
500
|
+
if current_page != _tecutil.PageGetUniqueID():
|
|
501
|
+
_tecutil.PageSetCurrentByUniqueID(current_page)
|
|
502
|
+
|
|
503
|
+
@lock()
|
|
504
|
+
def tile_frames(self, mode=TileMode.Grid):
|
|
505
|
+
"""Tile frames based on a certain mode.
|
|
506
|
+
|
|
507
|
+
Parameters:
|
|
508
|
+
mode (`TileMode`, optional): Direction and layout mode for tiling
|
|
509
|
+
frames. Possible values: `TileMode.Grid` (default),
|
|
510
|
+
`TileMode.Columns`, `TileMode.Rows`, `TileMode.Wrap`.
|
|
511
|
+
|
|
512
|
+
Example usage::
|
|
513
|
+
|
|
514
|
+
>>> from tecplot.constant import TileMode
|
|
515
|
+
>>> page.tile_frame(TileMode.Wrap)
|
|
516
|
+
"""
|
|
517
|
+
with self.activated():
|
|
518
|
+
macro.execute_extended_command('Multi Frame Manager', mode.value)
|
|
519
|
+
|
|
520
|
+
|
|
521
|
+
@lock_attributes
|
|
522
|
+
class Paper(object):
|
|
523
|
+
"""The `Paper` boundary defined on a workspace.
|
|
524
|
+
|
|
525
|
+
This is the area used for certain image output formats. It
|
|
526
|
+
is defined for a specific `Page <tecplot.layout.Page>`. `Frames <tecplot.layout.Frame>` can be
|
|
527
|
+
laid out in reference to this sub-area of the workspace.
|
|
528
|
+
"""
|
|
529
|
+
def __init__(self, page):
|
|
530
|
+
self.page = page
|
|
531
|
+
self._sv = page._sv + [sv.PAPER]
|
|
532
|
+
|
|
533
|
+
@property
|
|
534
|
+
def dimensions(self):
|
|
535
|
+
"""Width and height (read-only).
|
|
536
|
+
|
|
537
|
+
the dimensions, *(width, height)* in inches, of the
|
|
538
|
+
currently defined paper in the Tecplot workspace.
|
|
539
|
+
"""
|
|
540
|
+
with self.page.activated():
|
|
541
|
+
return _tecutil.PaperGetDimensions()
|